Repository navigation
Let an app crate supply its DaemonProfile through AppExtensions - #3416
Closed
mstomar125 wants to merge 1 commit into
Closed
mstomar125 wants to merge 1 commit into
mstomar125 wants to merge 1 commit into
Conversation
AppExtensions gains daemon_profile(profile), and run installs the supplied profile, or the build's default, before it builds the app. - daemon_profile::install(Option<DaemonProfile>) sets the process-wide profile once and panics when it was already set, naming the ordering bug. install_into holds the set-once logic over a caller's cell. - AppExtensions::daemon_profile refuses a service_env key that is one of core's own launchd variables (CORE_SERVICE_ENV: NODESPACED_SOCKET, NODESPACE_UI_BINARY). write_plist writes those keys from the same constants. - assemble ignores the profile; tests drive it on MockRuntime and never write the process-wide cell. - DaemonProfile is re-exported from the library root. - Tests: install_into with a local cell, the real install and a late install each in a child process of the test binary, the extension fixture, a source-order pin on run, and an integration test that builds a profile from outside the library. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mstomar125
marked this pull request as draft
October 1, 2026 08:19
Contributor
Author
|
Superseded by #3613. It ports this draft's 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An app built on core can now name the daemon it installs and starts with
AppExtensions::daemon_profile(profile)(ADR-082 §3.2 and §3.6, proposed).runinstalls that profile before it builds the app. Core's own app passesAppExtensions::none(), which carries no profile, so it keeps the build's default and nothing changes for the free app.Closes #3347
Changes
daemon_profile.rsinstall(supplied: Option<DaemonProfile>)sets the process-wide profile tosupplied, or toprofile_for_this_build()when nothing is supplied. If the profile was already set, because something read it or installed one first, it panics with a message that names the ordering bug.install_into(cell, supplied) -> Result<(), DaemonProfile>holds the set-once logic over a caller's cell, so the unit tests use a localOnceLock.CORE_SERVICE_ENV = [SOCKET_ENV_VAR, UI_BINARY_ENV_VAR]is the one list of the variables core's launcher writes into the launchd plist itself.DaemonProfile::reserved_service_env_key()finds aservice_envkey that repeats one of them. The match is exact, the way launchd compares keys.active()'s docs now say thatruninstalls the profile, and that the lazy default only applies to a read before any install, which only tests make.extensions/mod.rsdaemon_profile: Option<DaemonProfile>, set bypub fn daemon_profile(self, profile) -> Self; the last call wins.binary_name: what is installed, registered, started, killed by image name on Windows, and checked by the startup product check;service_env: launchd only;product.daemon_profile()panics on aservice_envkey inCORE_SERVICE_ENV, naming the key. A duplicate plist key is accepted and would silently replace core's value.pub(crate) fn take_daemon_profile(&mut self)hands the profile torun.assembleignores it.daemon_setup.rswrite_plistnow writes core's two<key>s fromSOCKET_ENV_VARandUI_BINARY_ENV_VAR, the constantsCORE_SERVICE_ENVis built from.CORE_SERVICE_ENV, so the refusal list and what the plist writes cannot drift apart.lib.rspub use daemon_profile::DaemonProfile;at the library root.runcallsdaemon_profile::install(extensions.take_daemon_profile())right after the Windows stdio redirect, before the runtime and the builder exist. That precedes every reader: plugin setup, then core's.setup(kill_stale_daemon_sync→daemon_binary_name()), thenensure_daemon_running. It comes after the redirect, so a Windows release build logs the panic of a late install.Deviations from the issue
install/install_intotakeOption<DaemonProfile>, notDaemonProfile. The issue's test list asksinstall_intoto "fall back to the build default when nothing is supplied". With the fallback insideinstall_into, that test runs on a local cell, andrunreads simplyinstall(extensions.take_daemon_profile()).EXTENSION_API_VERSIONstays(1, 0). The issue says to bump the minor version, but:on_daemon_ready/on_channel_rebuiltin Add daemon-ready tasks and channel-rebuilt hooks to AppExtensions #3405, andupdate_sourcein Let an app crate supply its update source through AppExtensions #3410) merged without bumping;CLAUDE.mdbump rule covers the TypeScript host API, registry types, slot hosts and hook timing, none of which this PR touches;Bumping here alone would make Rust 1.1 for one of four additions, and the TypeScript constant would need to follow. When Enforce EXTENSION_API_VERSION: Rust matches TypeScript, fixture changes bump it #3321 lands, its
FIXTURE_FILESmay wanttests/it/extension_daemon_profile_test.rsalongside the two files it already lists.A child-process test for the real cell. The crate's unit tests run as threads of one process (
scripts/test-app-units.ts: plaincargo test --test-threads=2), and many tests readactive(). So a test that installs into the real cell re-runs itself alone in a child process of the test binary. Everything else uses a local cell, or only reads.Tests
daemon_profile::tests::install_into_stores_a_supplied_profileinstall_intoignoringsupplied→ fails…install_into_falls_back_to_the_build_default_when_nothing_is_suppliedNonestoresprofile_for_this_build(), soAppExtensions::none()ends at the build default…install_into_refuses_a_cell_that_is_already_setErr(profile)and the cell keeps its value…an_installed_profile_is_what_every_read_sees(own process)install(Some(custom))sets the real cell:active()and the Windows image name readcustom-daemoninstallwriting a private cell → fails…installing_after_a_read_panics(own process)installignoring theErr→ fails…core_service_env_names_the_socket_and_the_ui_binary,…a_reserved_service_env_key_is_found_wherever_it_sits,…a_key_that_only_resembles_a_reserved_one_is_alloweddaemon_setup::macos_plist_keepalive_tests::community_plist_environment_holds_only_the_core_variablesCORE_SERVICE_ENVwrite_plistwriting another socket key → failsextensions::fixture_tests::daemon_profile::none_carries_no_daemon_profileAppExtensions::none()carries no profilenone()withSome(..)→ fails…a_named_daemon_profile_is_carried_to_run_and_the_last_call_winstakeleaving it behind → fails…a_service_env_key_core_sets_itself_is_refusedNODESPACED_SOCKETandNODESPACE_UI_BINARYare refused by name…assemble_builds_with_a_daemon_profile_and_does_not_install_itMockRuntime, and the process profile stays the build defaultassembleinstalling → failsrun_wiring_tests::run_installs_the_extension_daemon_profile_before_building_the_app.setup(, exactly oncetests/it/extension_daemon_profile_test::an_app_crate_names_its_own_daemon_profilenodespace_app_lib::DaemonProfile { binary_name: "custom-daemon", service_env: vec![], product: "custom" }passes throughAppExtensions::none().daemon_profile(..)andassemble…an_app_crate_cannot_replace_the_socket_core_registersMutation check: 14 of 14 mutations caught (
3347-mutate.py, each mutation reverted afterwards).Pro-boundary ratchet
bun run scripts/check-pro-boundary.tspasses, and no count rises. This diff adds no marker;--changedlists only pre-existing lines inlib.rs. Marker counts are identical to this branch's base, origin/maina7d2f93d(both runs compared).BASELINESis unchanged:Checks
cargo fmt -p nodespace-app-lib: clean.cargo clippy -p nodespace-app-lib --all-targets -- -D warnings -D clippy::unused-async: clean, before and after rebasing onto Let an app crate supply its update source through AppExtensions #3410.bun run test:changed: passed, with the rust and scripts tiers (workspace nextest 4148 passed; app-lib units 307 of 307).cargo test -p nodespace-app-lib --lib: 317 of 317 passed;cargo test -p nodespace-app-lib --test it -- extension_daemon_profile_test: 2 of 2 passed.bun run scripts/check-pro-boundary.ts: passed, with counts identical to the base.git merge-treeagainst the Add a neutral daemon:data-plane-ready event and stop reloading on pro:tier-detected #3318 branch is clean. Let an app built on core supply its update source through AppExtensions #3320 is already merged (as Let an app crate supply its update source through AppExtensions #3410), and this branch is rebased onto it.main.rspassesAppExtensions::none(), soruninstallsprofile_for_this_build(), the same profileactive()defaulted to before. The plist renders byte-for-byte the same.🤖 Generated with Claude Code