Repository navigation
Let an app crate name its daemon and ship core's window capability in the library - #3613
Conversation
Automated pragmatic-code-review (medium depth)Review Type: Initial Review Scope: the two "Tauri (ADR-082 §4)" acceptance items of #3414 only. Checked against accepted ADR-082 §4, §4.5, §4.6, §8 and §9, ADR-084 §4, and Tauri 2.11.2 / tauri-codegen 2.6.2 / tauri-build 2.6.2 / tauri-utils 2.9.2 source. Review was done by reading the code; nothing was built or run except Requirements Check
Code Review FindingsNo blockers. The
The 🟢 Suggestion: say that the capability's plugin set is part of the app-crate contract📁 🟢 Suggestion: give
|
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-review verdicts). Full findings in the review comment above.
Address review: round 1Review round 1 (report) came back APPROVE, with five optional findings and no blockers. Changes are in Addressed (4)
Skipped (1)
Checks after the change: run under the machine slot, with no daemon and no model loaded.
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The round changes doc comments, one capability identifier string (with its pin test), and one test that now checks a second key. No logic changes, and every change is tested and mutation-checked where it is testable. The review approved the design and logic, and those are untouched. 🤖 Generated with Claude Code |
… the library AppExtensions::daemon_profile(profile) names the daemon an app built on core installs and starts. run installs it into the process-wide profile before the runtime and the app exist; AppExtensions::none() installs the build's default. A service_env key that repeats one of the variables core's launcher writes itself (CORE_SERVICE_ENV) is refused, and write_plist now writes those keys from the same constants. DaemonProfile is re-exported from extensions and the crate root. Core's window capability moves from src-tauri/capabilities/default.json to app-lib/src/window-capability.json. window_capability::add adds it with Manager::add_capability as the first statement of core's setup, and window_capability::plugin_crates lists the plugin crates an app crate must depend on directly. The app crate's tests check its manifest and resolve the capability against its real ACL on MockRuntime; main builds its context through one runtime-generic context() so generate_context! expands once per binary. EXTENSION_API_VERSION goes to 2.1 in Rust and TypeScript, and the surface snapshot records the new version. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- window_capability's module doc says the plugins it grants are part of the versioned app-crate contract, and that granting a new one is a major EXTENSION_API_VERSION change; the pin test's message says so too. - The capability's identifier is core-window, apart from the default identifier an app crate's own capability files usually carry. - daemon_profile's rustdoc lists the whole ADR-084 §4.2 contract, including core's tray on --tray. - The config test also refuses removeUnusedCommands under its kebab-case alias, which Tauri reads too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
81fb7f2 to
9d9ca0f
Compare
Part of #3414 (its "Tauri (ADR-082 §4)" acceptance items).
An app crate built on core can now name the daemon it installs and starts with
AppExtensions::daemon_profile(profile). Core's window capability now ships in the library, which adds it at startup withManager::add_capability, so every app crate built on core gets it without a capability file of its own. WithAppExtensions::none(), core keeps its own profile (DaemonProfile::community()) and its own update source, and the free app behaves exactly as before.AppExtensions::update_sourcewas already on main, so this PR leaves it alone.Extension API
EXTENSION_API_VERSIONgoes from 2.0 to 2.1, in Rust (app-lib/src/extensions/mod.rs) and TypeScript (src/lib/plugins/ui-extensions.ts) together. Under ADR-082 §8 this is a minor bump, because it only adds things:AppExtensions::daemon_profile(DaemonProfile) -> Self, withDaemonProfilere-exported fromextensionsand the crate root;nodespace_app_lib::window_capability:CAPABILITY,add(manager)andplugin_crates().plugin_crates()lets an app crate check its own manifest against the plugins core's capability grants.The TypeScript surface doesn't change. The surface snapshot was re-recorded only because it stores the version; its diff is the one
minorline.extension-api-version-agreement.test.tspasses.What changed
Daemon profile (
daemon_profile.rs,extensions/mod.rs,lib.rs,daemon_setup.rs). This is ported from parked draft #3416, which was built against the drafts. Following ADR-082 §4.5, the profile carries onlybinary_nameandservice_env, with noproductfield.AppExtensions::daemon_profile(profile)stores the profile, and the last call wins. Its rustdoc says what each field controls, which shared service identity no profile can change (ADR-084 §4), and that the named daemon must honour the registration contract in ADR-084 §4.2.service_envkey that repeats one of the two variables core's launcher writes itself (NODESPACED_SOCKET,NODESPACE_UI_BINARY) panics, naming the key. launchd would otherwise accept the duplicate key and silently replace core's value.CORE_SERVICE_ENVis the one list of those variables.write_plistnow writes its two<key>s from the same constants, and the plist test asserts that the list equals what the plist writes. The rendered plist is byte-for-byte unchanged.runinstalls the profile withdaemon_profile::install(extensions.take_daemon_profile()), right after the Windows stdio redirect and before the runtime, the builder or any setup exist. That puts it ahead of every reader, the first of which is core's stale-daemon kill in setup.installpanics if something read or set the profile first, because that is an ordering bug. With no profile supplied, it installsprofile_for_this_build().assembleignores the profile, so tests onMockRuntimenever touch the process-wide one.Window capability (
window_capability.rs,window-capability.json,lib.rs,src-tauri)git mv src-tauri/capabilities/default.json app-lib/src/window-capability.json. The window and permissions are unchanged. The identifier becomescore-window(review round 1), so it can't be confused with an app crate's own capability, which Tauri's scaffold namesdefault. The$schemaline is dropped because its relative path no longer pointed anywhere.src-tauri/capabilities/is gone.window_capability::add(app)?is the first statement of core's setup. Tauri creates the config windows and then runs setup inside the event loop's Ready callback (tauri2.11app.rs,fn setup), so no IPC call can reach the app before the capability is in place.tauri_buildassembled from the app crate's direct dependencies, andResolved::resolve(..).unwrap()panics on a plugin it doesn't know. A missing dependency therefore builds cleanly and panics only when the app starts. The new tests catch that first (see below).run's "What an app crate must do" list now points atwindow_capability::plugin_crates. It also says to leavebuild.removeUnusedCommandsoff, because that setting strips plugin commands that no capability file grants.src-tauri/src/main.rsexpandstauri::generate_context!()once, in a runtime-genericfn context<R: tauri::Runtime>() -> tauri::Context<R>.maincalls it onWryand the tests call it onMockRuntime. On macOS the macro embeds the Info.plist under a fixed symbol, so a second expansion in the test module failed to link (_EMBED_INFO_PLIST is already defined). Clippy doesn't catch that because it never links, but the test run did.src-tauri/Cargo.tomlgets dev-dependencies for those tests:tauriwithtest,serde_jsonandtoml0.8, all already in the lockfile. Its comment on the plugin dependencies now says why they are there.Tests
Every Rust run went through the machine slot, as
test:changed's Rust tier does. No daemon was spawned, no model was loaded, and nothing ran against the GPU.cargo clippy -p nodespace-app-lib -p nodespace-app --all-targets -- -D warnings -D clippy::unused-async: clean.cargo fmt -p nodespace-app-lib -p nodespace-app -- --check: clean.cargo-nextest nextest run -p nodespace-app-lib --lib: 324 of 324 passed.cargo-nextest nextest run -p nodespace-app-lib --test it -E 'test(/^extension_daemon_profile_test::/)': 2 of 2 passed. This is the onlyitmodule run, because the others spawnnodespaced.cargo-nextest nextest run -p nodespace-app --bins: 4 of 4 passed (the newwindow_capability_tests).cargo test --lib --bins -p nodespace-app -p nodespace-app-lib -p nodespace-app-test-support -- --test-threads=2, which is the gate'stest-app-unitsinvocation: 4, 324 and 0 passed.bun run --cwd packages/desktop-app test src/tests/extension-api src/tests/plugins/ui-extensions.test.ts src/tests/build/nodespace-extensions-plugin.test.ts: 6 files, 149 tests passed, includingextension-api-version-agreementand the surface snapshot.bun run scripts/check-pro-boundary.ts: exit 0. The push check passed.New tests:
daemon_profile::tests::install_into_stores_a_supplied_profile,…falls_back_to_the_build_default_when_nothing_is_supplied,…refuses_a_cell_that_is_already_setNonemeans the build default…an_installed_profile_is_what_every_read_sees,…installing_after_a_read_panics(each re-runs itself alone in a child process)active()and the Windows image name read; a late install panics, naming the ordering bug…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_variables(renamed)CORE_SERVICE_ENVextensions::fixture_tests::daemon_profile::{none_carries_no_daemon_profile, a_named_daemon_profile_is_carried_to_run_and_the_last_call_wins, a_service_env_key_core_sets_itself_is_refused, assemble_builds_with_a_daemon_profile_and_does_not_install_it}AppExtensionsmethod onMockRuntimeextensions::fixture_tests::extension_api_version_is_two_onerun_wiring_tests::run_installs_the_extension_daemon_profile_before_building_the_app.setup(, exactly oncerun_wiring_tests::setup_adds_the_window_capability_before_anything_elsewindow_capability::add(app)?;is setup's first statement, exactly oncewindow_capability::tests::the_capability_grants_the_main_window_what_the_frontend_needscore-window; window and permissions unchanged by the move;plugin_crates()pinned, and its message says a new plugin is a major bumpwindow_capability::tests::plugin_crates_names_the_crate_of_each_granted_plugin_oncecore:skipped, scoped (object) permissions read, duplicates droppedtests/it/extension_daemon_profile_test::{an_app_crate_names_its_own_daemon_profile, an_app_crate_cannot_replace_the_socket_core_registers}nodespace-appwindow_capability_tests::the_app_crate_depends_directly_on_every_plugin_the_window_capability_grantsplugin_crates()is a key of the app crate's[dependencies]…the_window_capability_resolves_against_this_crates_acladdsucceeds against the ACLtauri_buildbuilt for this crate (its real context, onMockRuntime)…the_window_capability_grants_the_main_window_and_no_otherplugin:app|versionfrommainis refused beforeaddand answered after it; a window labelledotherstays refused…the_tauri_config_leaves_unused_plugin_commands_intauri.conf.jsondoesn't turn onbuild.removeUnusedCommands, under either spelling Tauri readsNot done here: a GUI smoke run (
dev:taurior a release bundle), because this session has no interactive display. The IPC test above checks the same grant through Tauri's real ACL path. A smoke run before release would confirm the dialog, the opener and window close on a device.Mutation check
22 mutations, each applied, run against its tests, then reverted. 22 of 22 caught.
install_intoignores the supplied profileinstall_into_stores_a_supplied_profile,an_installed_profile_is_what_every_read_seesinstallignores an already-set profileinstalling_after_a_read_panicsinstallwrites a private cellan_installed_profile_is_what_every_read_seesNODESPACE_UI_BINARYa_key_that_only_resembles_a_reserved_one_is_alloweddaemon_profile()refusal disableda_service_env_key_core_sets_itself_is_refused,an_app_crate_cannot_replace_the_socket_core_registersdaemon_profile()drops the profilea_named_daemon_profile_is_carried_to_run_and_the_last_call_winsassembleinstalls the profileassemble_builds_with_a_daemon_profile_and_does_not_install_itnone()carries a profilenone_carries_no_daemon_profilerunnever installsrun_installs_the_extension_daemon_profile_before_building_the_appruninstalls after the runtime is builtclipboard-manager:defaulttauri-plugin-dialogsettingsplugin_crateskeepscore:plugin_cratesignores scoped permissionsadd()grants nothingset_menusetup_adds_the_window_capability_before_anything_elseremoveUnusedCommands: truethe_tauri_config_leaves_unused_plugin_commands_inremove-unused-commands: true(the kebab alias, added in review round 1)extension-api-version-agreement(TS),extension_api_version_is_two_oneAcceptance mapping (#3414, Tauri section)
AppExtensions::daemon_profileandAppExtensions::update_sourcelet an app built on core supply itsDaemonProfileandUpdateSource, and core uses its own defaults withAppExtensions::none().daemon_profileis new here;update_sourcewas already on main.none_carries_no_daemon_profileandinstall_into_falls_back_to_the_build_default_when_nothing_is_suppliedcover the profile default. The existingnone_manages_the_builtin_update_sourcecovers the update-source default.Manager::add_capability(window_capability::add, first in setup). A core test fails if that capability names a plugin core's app crate doesn't depend on directly:the_app_crate_depends_directly_on_every_plugin_the_window_capability_grantschecks the manifest, andthe_window_capability_resolves_against_this_crates_aclchecks the real ACL. Mutations W1 and W2 show both fail.Out of scope here, and left for later PRs: typed subtypes and edge fields, frontend
nodeTypesandtreeItemActions, the redesign of the versioning snapshot gate, and docs.Pro boundary
bun run scripts/check-pro-boundary.tsexits 0. New code and comments name extension points for what they do.Documentation
Manager::add_capability)daemon_profilerustdocNo docs change in this PR.
architecture/extension-points.mdis a separate #3414 item.🤖 Generated with Claude Code