Repository navigation
Add a DaemonProfile for the app's daemon binary and service env (no behavior change) - #3391
Conversation
Pragmatic code review (initial, medium effort)Reviewed via the inlined Review Type: Initial Review Requirements Check
Code Review FindingsNo Critical or Important issues.
Checks that came back clean
Recommendation: APPROVE. No blocking issues; the only substantive follow-up is the reserved-key check, which belongs at the extension install point. |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment, GitHub blocks self-approval). Full findings in the review comment above.
Address-review summaryAddressed in e28ffd4 (documentation only, no code change):
Skipped, with reasons:
Verification after the fix: Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The follow-up commit changes three comment blocks only, with no logic, cfg gate or test change. Compilation, lint and ratchet were re-verified after the edit. The reviewer's verdict on the code was APPROVE with no Critical or Important findings. |
… DaemonProfile Add DaemonProfile (binary_name, service_env, product) and a process-wide active() profile. The build's default profile is chosen in one place, daemon_setup::profile_for_build_env / profile_for_this_build; daemon_binary_name, the Windows taskkill image name and the launchd plist environment now read the active profile instead of branching on is_pro_build. write_plist renders profile.service_env as escaped key/string pairs after core's own two variables, byte-identical to the previous Pro block for the same values and unchanged for a profile with none. Identity selections (label, socket, pid file, marker) are untouched. Co-Authored-By: Claude Sonnet 5 <[email protected]>
- daemon_profile module doc: scope the opening sentence to binary, Windows image name and service environment, so it no longer contradicts the note that label, socket, pid file and marker are not part of a profile. - windows_taskkill_image_name_tests doc: say the test ties image_name to daemon_binary_name(), not that the Windows call sites read the active profile. - profile_for_build_env doc: drop the carried-over XML-safe rationale, since write_plist escapes every service_env entry and this function renders no XML. Documentation only; no code change. Co-Authored-By: Claude Sonnet 5 <[email protected]>
e28ffd4 to
30eb943
Compare
Closes #3346
Summary
Adds
DaemonProfile(ADR-082 section 3.6, proposed) and routes every edition-dependent choice of which daemon binary the app runs and what extra environment its launchd registration carries through the process's active profile. Community and Pro builds behave exactly as they do today; this is a pure refactor.app-lib/src/daemon_profile.rs:DaemonProfile { binary_name, service_env, product },community(),image_name()(cfg(any(windows, test))), andactive()(aOnceLockinitialised fromdaemon_setup::profile_for_this_build). Docs use generic wording only.daemon_setup.rs:profile_for_build_env/profile_for_this_buildare the only code that picks binary, env or product by edition.daemon_binary_name()readsactive().binary_name.daemon_binary_name_for,daemon_image_name_forand thepro_envblock are deleted.write_plisttakes&DaemonProfileand rendersservice_envas escaped<key>/<string>pairs after core's own two variables.update_checkstill branch onis_pro_build(), as the issue specifies. Arguments are untouched.Paths follow the crate split: the issue's
packages/desktop-app/src-tauri/srcis nowpackages/desktop-app/app-lib/src(cratenodespace-app-lib).Deviations from the issue text
profile_for_build_env's first parameter is namedendpoint_url, notsupabase_url. The issue's name is acloudWordinghit on two lines; the neutral name keeps that marker flat. Signature and behaviour are otherwise as specified.DAEMON_BINARY_NAMEbecamepub(crate)socommunity()can use it (it now has no other reader).the_active_profile_starts_as_the_build_default, the only guard onactive()'s initialisation (detectable only in a build with the edition variables set; see mutation table).is_pro_buildalso lists two lines in daemon_setup.rs's inline tests (the import and the agreement testthe_profile_and_the_identity_selection_agree_on_the_edition), which pin that the profile selection and the identity selection agree.tauri devplist comparison was replaced by a stronger scratch check (below).Ratchet (
scripts/check-pro-boundary.ts), BASELINES untouchedMeasured on origin/main 1a0f437 versus this branch. No count rose.
Class under CLAUDE.md "Pro / Sync Boundary": a planned move of Pro code already in core (class 3), adding no behaviour. The Pro values that lived in
write_plist'spro_envnow live inprofile_for_build_env, and their pinning test (edition_values_select_the_edition_daemon_environment_and_productand the(Some, None)case) is new. That test and function carrynodespaced-pro,NODESPACED_PRO_*andis_pro_buildtext (theeditionBranchinglines in the new test module, offset by the deletedpro_edition_image_name_matches_pro_binaryand thepro_envblock). They are the code that #3354 deletes whole.Windows hunks (not compiled on macOS): please read each
All are one-line swaps to
daemon_profile::active().image_name():signal_daemon_to_stop(#[cfg(windows)])kill_running_daemon(#[cfg(windows)])image_namereturnsformat!("{}.exe", binary_name), the deleteddaemon_image_name_forbody withbinary_namein place of the edition lookup.windows_taskkill_image_name_testsnow guards that the image name cannot drift fromdaemon_binary_name().Verification
cargo clippy -p nodespace-app-lib --all-targets -- -D warnings -D clippy::unused-async: clean.cargo fmt -p nodespace-app-lib --check: clean.cargo test -p nodespace-app-lib --lib -- daemon_ macos_plist windows_taskkill sidecar_: 72 pass, in a community build and again in a build withNODESPACE_PRO_SUPABASE_URL=https://example.invalid NODESPACE_PRO_ANON_KEY=test.NODESPACE_PRO_SUPABASE_URL=... NODESPACE_PRO_ANON_KEY=test cargo check -p nodespace-app-lib --all-targetsandcargo check -p nodespace-app: compile.bun run test:changed: passed (tooling tests and the Rust workspace).bun run quality:scripts:fix: no changes.write_plist(with itspro_envblock) versus the new one, for community (1313 bytes), the Pro values (1486 bytes) and Pro values containing<,&,>(1507 bytes): identical bytes in all three.plutil -convert jsonandplutil -lint, so they assert what launchd will read, not just the text.Mutation results (each new test, one mutation per run; all killed)
productchangedcommunity_profile_carries_the_community_daemon_and_no_service_envservice_envnon-emptycommunity_plist_environment_holds_only_the_two_core_variablesbinary_namechangedcommunity_profile_carries_...(andimage_name_is_...)image_namedrops.exeimage_name_is_the_binary_name_with_the_windows_extension,active_profile_image_name_matches_the_installed_binary_nameimage_nameignoresbinary_nameimage_name_is_the_binary_name_with_the_windows_extension(custom-daemoncase)daemon_binary_name()returns another nameactive_profile_image_name_matches_the_installed_binary_namea_key_without_a_url_still_selects_the_community_profileedition_values_select_the_edition_daemon_environment_and_productedition_values_...anda_missing_anon_key_defaults_to_emptyedition_values_...a_missing_anon_key_defaults_to_emptyxml_escapedropped on keyservice_env_keys_and_values_are_xml_escapedxml_escapedropped on valueservice_env_keys_and_values_are_xml_escapedservice_env_renders_after_the_core_variables_in_orderservice_envnot renderedservice_env_renders_...andservice_env_keys_and_values_are_xml_escapedis_pro_build()forced truethe_profile_and_the_identity_selection_agree_on_the_editionprofile_for_this_buildignores the baked values (Pro-env build)the_profile_and_the_identity_selection_agree_on_the_editionactive()ignores the build default (Pro-env build)the_active_profile_starts_as_the_build_defaultNot verified
The two Windows hunks are not compiled here. The optional real-device
tauri devplist comparison was not run; the scratch byte comparison above stands in for it.🤖 Generated with Claude Code