Repository navigation
Description
Part of #3322 (Tauri extension points for the desktop app).
Summary
Move core's two build-script helpers into a new crate, nodespace-app-build, at packages/desktop-app/app-build:
drop_unstaged_bundle_entries, which lets a debug build and tests run without staged sidecars;sync_stale_sidecar, which stopstauri_buildfrom overwriting a freshtarget/<profile>/<bin>with a stale staged sidecar.
Any app crate built on core, core's own included, can then call them from its build.rs (ADR-082 (proposed) §3.1 and §3.7, item 3). test-support uses the crate as an ordinary dependency instead of a #[path] include.
drop_unstaged_bundle_entries also stops hard-coding core's skill path: it drops any unstaged resources entry. For core's config the result is exactly today's.
Context
src-tauri/build.rs
SKILL_RESOURCES(70).drop_unstaged_bundle_entries(72-170):- it runs only in debug builds, and only when
TAURI_CONFIGis unset; - it reads
tauri.conf.jsonfrom the build script's working directory; - it drops
externalBinentries whose<entry>-<triple><exe>file is missing; - it drops the
resources/skill/**/*entry whenresources/skillis missing or empty; - it writes the result as a
TAURI_CONFIGpatch and prints onecargo:warning; - it emits
rerun-if-changedon the nearest existing ancestor of each dropped path.
- it runs only in debug builds, and only when
sync_external_bin_staging(15-66) stays in core'sbuild.rs, because itsEXTERNAL_BIN_NAMESlist is core's own. It callsbuild_support::sync_stale_sidecar.
src-tauri/build_support.rs
- 141 lines. It holds
sync_stale_sidecar(111). - Its module doc says it is a shared file rather than a crate, because
test-supportdepends on the app, so a build dependency back onto the app would be a cycle. - That no longer holds: the new crate depends on nothing in the app.
test-support (in app-lib/test-support after #3303)
- It includes the file through
#[path]. - It re-exports
sync_stale_sidecarfortests/it/sidecar_staging_sync_test.rs.
Why the skill path has to go. In a generated app config, such as the Pro app crate's, resource paths point into a core checkout. A fixed "resources/skill/**/*" string would never match there.
Scope
New packages/desktop-app/app-build/
Cargo.toml
- Package
nodespace-app-build, libnodespace_app_build. version.workspace = true,edition.workspace = true,publish = false.- The only dependency is
serde_json = { workspace = true }. - No
tauridependency, so the crate runs in the ordinary workspace nextest run on every platform.
src/lib.rs: a crate doc, written generically for "an app crate built on core's library". It says what each helper is for, and that both are called before tauri_build::build().
src/sidecar_staging.rs
build_support.rsmoved here (git mv), withpub fn sync_stale_sidecar.- Rewrite the "why not a crate" paragraph of its doc.
src/bundle_entries.rs
pub fn drop_unstaged_bundle_entries(): the wrapper that reads the environment. Its behaviour is today's.- A pure function that returns the patch and the list of missing paths:
fn plan( conf: &serde_json::Value, target_triple: &str, exe_suffix: &str, file_exists: impl Fn(&Path) -> bool, dir_has_entries: impl Fn(&Path) -> bool, ) -> Option<Plan>
- The generalized rule: keep a string
resourcesentry when its base directory exists and is non-empty. Otherwise, drop the entry and list it as missing.- The base directory is the path up to the first
*,?or[. If there is none, it is the path itself.
- The base directory is the path up to the first
- Non-string entries and a map-form
resourceskeep today's handling. They stay as declared, and a map means the function does nothing. - Keep the warning's shape, and reword its hint generically, for example "only needed to run the app; stage them to include them".
Core's app crate
src-tauri/Cargo.toml: addnodespace-app-build = { path = "../app-build" }to[build-dependencies]. Dropserde_jsonifbuild.rsno longer uses it.src-tauri/build.rs:- remove
mod build_support;,SKILL_RESOURCESanddrop_unstaged_bundle_entries; - call
nodespace_app_build::drop_unstaged_bundle_entries(); - have
sync_external_bin_stagingcallnodespace_app_build::sync_stale_sidecar; - keep the ordering comment: both run before
tauri_build::build().
- remove
- Delete
src-tauri/build_support.rs, which has moved.
Test support and tooling
app-lib/test-support:- add
nodespace-app-build = { path = "../../app-build" }; - replace the
#[path]module withpub use nodespace_app_build::sync_stale_sidecar;; - update the comment there.
- add
- Root
Cargo.toml: add the member. scripts/gate-scope.ts: add"packages/desktop-app/app-build/"toRUST_DIRS, and add a case togate-scope.test.ts.packages/desktop-app/vite.config.js: add"**/app-build/**"to the watch ignore list.scripts/test-app-units.ts: its comments namebuild.rs'sdrop_unstaged_bundle_entries. Point them at the helper crate. The logic doesn't change.
Out of scope
sync_external_bin_stagingandEXTERNAL_BIN_NAMES, which stay core's own.- The Pro app crate's
build.rs, which is a sync item.
Steps
- Run the CLAUDE.md startup sequence. Self-assign at pickup; the worktree is
issue-<N>-app-build-helpers. - Create the crate, and move
build_support.rsinto it. - Write
plan, the wrapper and their tests, then switch core'sbuild.rsover. - Update test-support and the tooling.
- In a fresh worktree with nothing staged, check two builds:
cargo build -p nodespace-app(debug) succeeds and prints the same list of missing paths as before; only the hint's wording changes;cargo build --release -p nodespace-appstill fails on the missing sidecars.
- Run
bun run quality:fix, thenbun run test:changed.
Acceptance criteria
-
nodespace-app-buildexists, has notauridependency, andbun run rust:testruns its unit tests. - Core's
build.rsuses the crate for both helpers, andbuild_support.rsis gone. - For core's
tauri.conf.jsonwith nothing staged, theTAURI_CONFIGpatch is exactly today's,{"bundle":{"resources":["resources/models/**/*"],"externalBin":[]}}, and a test pins it. - A debug build in a fresh worktree succeeds, and a release build still fails without staged sidecars.
-
sidecar_staging_sync_testpasses through test-support's new re-export. -
bun run scripts/check-pro-boundary.tspasses.BASELINESare lowered to the exact new counts wherever this PR removes markers, and no count rises. - No product names or GitHub issue numbers in the new code or docs.
Tests and verification
New tests in app-build/src/bundle_entries.rs:
keeps_everything_when_everything_is_staged(returnsNone)drops_an_unstaged_sidecardrops_a_resource_whose_base_directory_is_empty_or_missingkeeps_a_resource_whose_base_directory_has_a_file(the.gitkeepcase ofresources/models)leaves_non_string_entries_as_declaredcore_config_with_nothing_staged_matches_todays_patch(reads../src-tauri/tauri.conf.jsonthroughinclude_str!)
Mutation-check each new test: break the code path it covers, confirm the test fails, then restore.
cargo test -p nodespace-app-build
cargo test --lib --bins -p nodespace-app-lib -p nodespace-app -p nodespace-app-test-support -- --test-threads=2
cargo build --bin nodespaced && NODESPACED_TEST_BIN="$PWD/target/debug/nodespaced" cargo test -p nodespace-app-lib --test it sidecar_staging_sync_test:: -- --test-threads=1
cargo clippy -p nodespace-app-build -p nodespace-app -p nodespace-app-test-support --all-targets -- -D warnings -D clippy::unused-async
NODESPACE_PRO_SUPABASE_URL=https://example.invalid NODESPACE_PRO_ANON_KEY=dummy cargo check -p nodespace-app
bun test scripts/gate-scope.test.ts
bun run test:changed # gate files changed, so every tier runs
Dependencies
Risks and rollback
- A build-script regression breaks every build.
planis pure and unit-tested, and the core-config test pins today's output. - The Pro build. sync passes
--config, which setsTAURI_CONFIG, so the helper leaves its bundle config alone, as it does today. - Rollback: revert.
Plan key: C2.6 (pro-boundary DAG).
🤖 Generated with Claude Code
Activity
mstomar125 commentedon Sep 30, 2026
Completed in #3386 (merged). Auto-close did not fire; closing manually.