Skip to content

Trial an in-app debug bridge so agents can inspect the running Tauri app (closes #3739) - #3776

Merged
malibio merged 9 commits into
mainfrom
issue-3739-tauri-debug-bridge
Oct 13, 2026
Merged

malibio merged 9 commits into
mainfrom
issue-3739-tauri-debug-bridge

Conversation

@malibio

@malibio malibio commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a development-only bridge plugin (tauri-plugin-mcp-bridge, pinned =0.13.0) behind a debug-bridge Cargo feature that only bun run dev:tauri passes. A release-profile build with the feature is a compile_error!.
  • Bound to 127.0.0.1 (the plugin's default is all interfaces, unauthenticated). Its permission is a capability of its own; the production window capability, CSP and withGlobalTauri: false in the committed config are unchanged. dev:tauri turns withGlobalTauri on for the dev run only, via --config src-tauri/tauri.debug-bridge.conf.json.
  • drop_unstaged_bundle_entries now merges an explicit TAURI_CONFIG over its patch instead of stepping aside, so --config no longer breaks debug builds in a fresh worktree.
  • Pins @hypothesi/tauri-mcp-cli and @hypothesi/tauri-mcp-server at 0.13.0. 0.13.1 requires tauri ~2.12.2 and would move tauri/wry for every build.
  • run-app skill gains the launch-and-inspect recipe; browser-dev-mode.md (docs repo) gains the matching section.

Proof (macOS WKWebView, dev:tauri, scratch HOME + pre-seeded daemon)

DOM snapshot, console + thrown error, JS eval, click + typed text persisting across reload, screenshot, a real command observed through the IPC monitor and one invoked directly: all worked. The user's real daemon was untouched. Two apps at once was not run; the plugin scans 100 ports up from 9223.

Findings

  • The IPC monitor only sees window.__TAURI__.core.invoke, not the app's own __TAURI_INTERNALS__ traffic.
  • Launching the app is not isolated by NODESPACE_HOME: it touches ~/.nodespace/bin, the default socket and the per-user launchd label. A scratch HOME with a pre-seeded healthy daemon avoids it.

Test plan

  • bun run test:changed (frontend, browser, scripts, skill, types, node-types, rust)
  • bun run quality:fix
  • Tests with and without the feature; release-profile build with the feature fails to compile

🤖 Generated with Claude Code

@malibio

malibio commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #3776 (closes #3739)

Review type: Initial. Recommendation: REQUEST CHANGES (one blocker, easy fix).

Requirements check

Acceptance criterion Status
Plugin optional dep behind a feature only dev:tauri enables, exact pins Met (=0.13.0, npm 0.13.0, feature not in default)
Release/bundle build can't compile or register it, pinned by test Not verifiable from the PR: the module and tests are not in the commit set (blocker below)
Permission only in the dev build, production capability not weakened Met by design (separate debug-bridge capability, window-capability.json untouched)
withGlobalTauri false in committed config, dev-only override Met (tauri.debug-bridge.conf.json via --config)
Production CSP unchanged Met (tauri.conf.json not in diff)
macOS proof, outcome comment Recorded by the main agent in the issue comment and PR body; consistent with the code and the SKILL.md recipe
run-app recipe Present
browser-dev-mode.md section Lives in nodespace-docs, outside this diff

Findings

🔴 Blocker: the new Rust source files are gitignored and not in the PR

.gitignore:111 (debug_*.rs) silently drops both new files:

  • packages/desktop-app/app-lib/src/debug_bridge.rs
  • packages/desktop-app/src-tauri/src/debug_bridge_tests.rs

git ls-files and git diff origin/main...HEAD show neither (they exist only as ignored files in this worktree). Consequences on a clean checkout, i.e. the merge gate:

  • packages/desktop-app/src-tauri/src/main.rs:18 has #[cfg(test)] mod debug_bridge_tests; unconditionally, so every src-tauri test build fails with "file not found" even without the feature.
  • dev:tauri (--features debug-bridge) fails to compile: pub mod debug_bridge; in lib.rs and crate::debug_bridge::plugin have no source.

Fix: rename away from the debug_ prefix (for example inspection_bridge.rs / inspection_bridge_tests.rs, updating lib.rs, extensions/mod.rs, main.rs and the nodespace_app_lib::debug_bridge::grant path in the test), or force-add. Renaming is better: the ignore pattern will otherwise bite the next editor. Verify with git ls-files | grep -i bridge afterwards.

Note this also means the "is a shipped build able to compile the bridge" question was answered from files a reviewer of the diff cannot see; the content of the local files is sound (below), so this is a packaging defect, not a design one.

🟡 Improvements

  • packages/desktop-app/src-tauri/src/debug_bridge_tests.rs (local), no_shipped_build_script_passes_the_bridge_feature: scans only packages/desktop-app/package.json. The release workflow (.github/workflows/release.yml, tauri-action with tauriScript: bunx tauri), the root package.json and scripts/*.ts are other places a feature could be passed. Today none passes it, and compile_error! covers a release-profile build regardless, so the risk is low; widening the scan to root package.json and the workflow file would make the pin match the claim in the module docs ("no release or bundle script passes it").
  • lib.rs:67-72: the compile_error! is keyed on not(debug_assertions), a proxy for "release". A profile with debug assertions on (a custom [profile], or RUSTFLAGS=-C debug-assertions) would compile it. Acceptable given the other layers; say "a build without debug assertions" in the message so it is accurate.
  • packages/desktop-app/package.json: @hypothesi/tauri-mcp-server is added but the recipe and ADR-035 stance use the CLI only. YAGNI: drop it unless something uses it (it also accounts for a good part of the bun.lock growth).
  • app-build/src/bundle_entries.rs merge_patch: logic is correct for RFC 7396 composition (objects recurse, arrays replace whole, a null survives so it deletes on the file the patch lands on, and a non-object base is reset). Behaviour change is limited to PROFILE=debug (release is unchanged since applies still returns false). One edge: a non-JSON TAURI_CONFIG silently returns and leaves the unstaged entries in, which is the intended "let tauri_build reject it". The tests cover pass-through and replace/null; consider one for an explicit bundle null over a non-null base key.

🟢 Verified, no action

  • Loopback: Config::localhost_only() in 0.13.0 binds 127.0.0.1, port 9223 (confirmed in the crate source); a unit test pins it. Unauthenticated socket is a documented upstream property, mitigated by feature gating.
  • Capability: separate debug-bridge capability, windows: ["main"], mcp-bridge:default only; test asserts core's capability does not mention the bridge.
  • Gating: optional dep in both crates, debug-bridge not in default, no other feature pulls it in, workspace cargo clippy --all-targets and release workflow (cargo build --release --bin ..., tauri-action) do not enable it. demo:tauri and tauri:build do not pass it.
  • Cargo.lock: additions only (the plugin, tokio-tungstenite/tungstenite, objc2 0.5/0.2 family, zune-jpeg, sha1, data-encoding); no existing crate version changed. The =0.13.0 pin (to avoid forcing a tauri bump) is reasonable and documented in the commit.
  • ADR-082 / sync boundary / AGENTS.md: comments name the capability, not a product; no #[allow(dead_code)], no #[deprecated], no issue numbers in code or docs.
  • SKILL.md: recipe is accurate against the code (port 9223, withGlobalTauri override, --port for a second app) and correctly warns that launching is not isolated by NODESPACE_HOME. The multi-worktree limitation is written down as required.

Recommendation

REQUEST CHANGES. Resolve the gitignored-files blocker (rename or force-add, then confirm the files appear in git diff origin/main...HEAD and bun run test:changed passes on a clean checkout). The rest is a net improvement and would be an APPROVE once that lands.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: REQUEST CHANGES (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Review response

Addressed (5/5)

  • 🔴 Gitignored sources: debug_bridge.rs and debug_bridge_tests.rs matched .gitignore debug_*.rs and were never in the PR. Renamed to webview_bridge.rs / webview_bridge_tests.rs; both are tracked now (git ls-files), and no other ignored source is referenced. The feature keeps the name debug-bridge.
  • 🟡 Shipped-build scan now covers the root package.json, scripts/*.ts (non-test) and .github/workflows/*.yml, not just this package's scripts.
  • 🟡 compile_error! and its comment now say "a build without debug assertions".
  • 🟡 Removed @hypothesi/tauri-mcp-server (only the CLI is used; ADR-035).
  • 🟢 Added a merge_patch test for an explicit null over a set key.

Verification: bun run test:changed passes (frontend, scripts, skill, types, node-types, rust); app and app-lib tests pass with and without the feature; a release-profile build with the feature still fails to compile.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The blocker was a packaging defect: the reviewer judged the file contents sound, and the fix is a mechanical rename plus reference updates, confirmed by the tracked-files list. The other changes are a clarified message, a wider test scan, a removed unused dependency and one extra unit test. No behavior changed.

🤖 Generated with Claude Code

@malibio

malibio commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Merge queue: #3776 was taken out of the queue — the merge gate failed on it, on top of main. Reproduce by merging or rebasing origin/main and running bun run test:changed, fix, push, and re-run bun run merge 3776.

test model_download_terminal_state_test::load_then_unload_reaches_a_clean_terminal_state ... ok
test node_crud_tauri_seam_test::creates_a_node_and_reads_it_back ... ok
test node_crud_tauri_seam_test::creates_a_parent_child_hierarchy_through_the_command_layer ... ok
test node_crud_tauri_seam_test::deletes_a_node_and_confirms_it_is_absent ... ok
test node_crud_tauri_seam_test::persists_node_properties_through_the_round_trip ... ok
test node_crud_tauri_seam_test::updates_a_node_and_increments_version_each_time ... ok
test optimistic_echo_race_test::newer_local_write_is_not_clobbered_by_a_late_echo_of_an_older_write ... ok
test optimistic_echo_race_test::watcher_delivers_a_real_node_created_event ... ok
test out_of_band_write_echo_test::a_windows_out_of_band_writes_reach_its_own_watcher ... ok
test out_of_band_write_echo_test::a_windows_store_writes_still_do_not_echo_back ... ok
test out_of_band_write_echo_test::a_windows_typed_relationship_edits_reach_its_own_watcher ... ok
test schema_parity_test::schema_parity_tests::test_architectural_parity_documented ... ok
test schema_parity_test::schema_parity_tests::test_http_and_tauri_use_same_schema_service ... ok
test schema_read_tauri_seam_test::get_all_schemas_returns_relationships_and_extends ... ok
test schema_read_tauri_seam_test::get_schema_definition_returns_relationships_and_extends ... ok
test sidecar_staging_sync_test::a_first_ever_build_with_no_staged_sidecar_yet_gets_one_created ... ok
test sidecar_staging_sync_test::a_sidecar_at_least_as_fresh_as_the_build_output_is_left_alone ... ok
test sidecar_staging_sync_test::a_stale_staged_sidecar_is_refreshed_from_the_fresher_build_output_before_tauri_build_runs ... ok
test sidecar_staging_sync_test::no_local_build_output_yet_leaves_the_sidecar_untouched ... ok
test startup_readiness_data_plane_test::a_command_fails_cleanly_before_readiness_and_succeeds_after_without_reconnecting ... ok
test startup_readiness_data_plane_test::the_data_plane_round_trip_answers_once_the_daemon_is_healthy ... ok
test window_routing_no_cross_talk_test::events_from_one_database_never_reach_a_window_pinned_to_another ... ok
failures:
---- daemon_readiness_test::check_daemon_status_command_reports_not_running_for_an_unbound_socket stdout ----
thread 'daemon_readiness_test::check_daemon_status_command_reports_not_running_for_an_unbound_socket' (76249193) panicked at packages/desktop-app/app-lib/tests/it/daemon_readiness_test.rs:111:5:
assertion `left == right` failed: check_daemon_status must report not_running for a socket nothing is listening on
  left: "incompatible_database"
 right: "not_running"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
    daemon_readiness_test::check_daemon_status_command_reports_not_running_for_an_unbound_socket
test result: FAILED. 58 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out; finished in 391.81s
error: test failed, to rerun pass `-p nodespace-app-lib --test it`
[stage exited with code 101]

  full output: /var/folders/6c/mkxnmpkx5zqc9jwwy20tjkyr0000gn/T/nodespace-gate-logs/_gate-merge-2026-10-13T09-11-36-060Z/tauri-seam-integration-tests-adr-048.log

✗ Tauri-seam integration tests (ADR-048) failed — merge blocked.
  Fix the failure, push, and re-run: bun run merge <PR#>

@malibio

malibio commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

New commit after review: the merge gate failed

The first bun run merge failed in the Tauri-seam stage, not on this PR's code: daemon_readiness_test::check_daemon_status_command_reports_not_running_for_an_unbound_socket got incompatible_database because the machine's real home held a refusal marker (~/.nodespace/incompatible-database-dev.json, written by a current-schema daemon refusing an older real database). The test would fail on any branch on a machine with such a marker.

Root cause: the daemon writes the marker under its NODESPACE_HOME-redirected state directory, but the app read it from the user's home only, so a refusal in the real home became the status of an unrelated, isolated run (and an isolated daemon's own refusal was invisible to the app pointed at it).

Fix (e5aa50500): incompatible_database::marker_path resolves through NODESPACE_HOME (empty = unset), else the user's home, with three unit tests; the seam test points NODESPACE_HOME at its temp dir. Full seam suite: 59 passed, 0 failed. Because this is production code added after the review, it needs a re-review.

@malibio

malibio commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review: PR #3776 (Re-Review)

Review Type: Re-Review (commits after 9e7f545: cb9c2ad, bca19ff, e5aa505)

Previous Review Summary

Previous verdict was REQUEST CHANGES: a Critical blocker (the bridge module and its tests were gitignored by the debug_*.rs pattern, so the PR did not build from a clean checkout) plus four lower items.

Previous findings

Finding Status
Blocker: gitignored debug_*.rs sources Resolved. Renamed to webview_bridge.rs / webview_bridge_tests.rs; git ls-files lists both; mod webview_bridge_tests; in src-tauri/src/main.rs and pub mod webview_bridge; in app-lib/src/lib.rs point at tracked files; no remaining debug_bridge module references. git status --ignored shows only build output (.svelte-kit, gen, sidecars, skill/dist), no ignored source.
Wider shipped-build scan Resolved. no_repository_build_or_release_path_passes_the_bridge_feature scans root package.json, scripts/*.ts (tests excluded) and .github/workflows/*.yml, with a sanity floor on the file count.
compile_error wording Resolved. The message and the comment now say "a build without debug assertions".
Remove @hypothesi/tauri-mcp-server Resolved. Dropped from desktop-app/package.json and bun.lock workspace entry; it remains only as the CLI's transitive dependency, which is correct.
merge_patch null test Resolved. an_explicit_null_over_a_set_key_is_kept_to_delete_it_from_the_file added.

New production change (e5aa505)

Does the app agree with the daemon? Yes, for the marker. state_home has the same semantics as the daemon's home_override_from (NODESPACE_HOME, empty treated as unset, then the user's home), joined with .nodespace/<incompatible_database_name(flavour)>, which is what nodespace_daemon::incompatible_database::marker_path writes via nodespace_dir(). All app-side marker readers/writers (current, clear_stale_marker, refusal_recorded, reset) go through the single marker_path(), so none of them is left on the real home.

Suggested Improvements

  • [Improvement] packages/proto/src/socket.rs:28-29 is now false. It states "the desktop app does not read that variable and uses the user's home". After this commit the app reads NODESPACE_HOME for the marker. Update the comment to say precisely what the app resolves through it (the refusal marker only), so the next reader does not "fix" it in either direction. The new state_home doc comment is good; the contract doc just needs to match.

  • [Improvement] Partial redirect inside the app. Everything else the app derives from the home still uses dirs::home_dir(): the socket default (services/grpc_client.rs:626), daemon_setup.rs (launchd plist, binary, log paths), bundled_model.rs, skill_setup.rs. With NODESPACE_HOME set in the environment that launches the app (a developer shell running tauri dev, for example) the app now dials the real-home socket and manages the real-home service, but reads the marker from the redirected home. The service-manager-launched daemon does not inherit the shell variable, so it writes the real-home marker. Result in that setup: a genuine refusal is not surfaced (daemon_down_status falls back to generic not-running), reset reports "there is no incompatible database to reset", and refusal_recorded cannot cut the start wait short. Before this commit those cases were consistent. This only bites a developer who exports NODESPACE_HOME globally (not Finder-launched users, not CI), and it is the documented isolation lever, so I am not blocking. If you want it airtight, either (a) say in the state_home comment that the marker follows the daemon only when the app and daemon were started with the same variable, or (b) have the marker follow the resolved socket's directory. Option (a) is enough.

  • [Improvement] Test coverage of the production wiring. The three state_home unit tests are pure and good, but nothing asserts that marker_path() actually reads NODESPACE_HOME (e.g. a regression that goes back to dirs::home_dir() alone would pass them). The seam test only proves it indirectly by the absence of a stale-marker failure. Optional: one integration test that writes a marker under a temp NODESPACE_HOME and expects daemon_status_body() to report incompatible_database. That also locks in the positive case the new env guard otherwise only hides.

Nitpicks

  • Nit: daemon_readiness_test.rs:110-115: the comment is accurate, but the test would also be sturdier asserting the temp dir has no .nodespace/ marker, making the isolation explicit.

Rule checks

  • Sync boundary: no Sync wording or code; comment mentions only ADR-053/"isolated daemon". Clean.
  • AGENTS.md: no compatibility shims, no dead_code/deprecations, no new literal node-type or lifecycle reads, no Sync markers. The bridge stays feature-gated, not in default, compile_error! on non-debug builds, covered by tests.
  • Test isolation: the env mutation uses the existing EnvGuard, and the integration crate runs under nextest (process per test), so no cross-test leakage.

Recommendation

APPROVE. The blocker and all four lesser findings are resolved; the new change is a small, correct alignment of the app's marker path with the daemon's. The proto doc comment fix is worth folding into this PR before merge; the rest is optional.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Re-review response

Addressed (3/3)

  • 🟡 packages/proto/src/socket.rs: the doc comment said the app does not read NODESPACE_HOME; it now says the app reads it only for the incompatible-database marker.
  • 🟡 state_home documents that the marker follows the daemon only when both were started with the same variable (the socket and service registration still sit under the user's home).
  • 🟢 Added check_daemon_status_reads_the_marker_under_a_redirected_home, which writes a marker under a temp NODESPACE_HOME and expects incompatible_database, so a regression of marker_path to the real home fails a test.

Skipped: the nit (asserting the temp dir holds no marker): the dir is created empty by tempdir() two lines above, so the assertion adds nothing.

bun run test:changed passes; the seam readiness tests pass (5).

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: Two doc comments and one added test; no production logic changed since the approved commit.

🤖 Generated with Claude Code

malibio and others added 9 commits October 13, 2026 12:05
…ONFIG (refs #3739)

dev:tauri now passes --config for the bridge's withGlobalTauri override, which
set TAURI_CONFIG and made the helper step aside, so a fresh worktree failed on
the unstaged skill installer. Merge the explicit config over the patch instead.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…#3739)

0.13.1 requires tauri ~2.12.2, which moved tauri and wry for every build in
Cargo.lock. 0.13.0 accepts tauri ^2, so the lockfile only gains the plugin's
own dependencies.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…n, drop the unused server package (refs #3739)

- Blocker: debug_bridge.rs and debug_bridge_tests.rs matched the debug_*.rs
  gitignore pattern and were never committed, so a clean checkout failed. Renamed
  to webview_bridge.rs / webview_bridge_tests.rs; the feature keeps its name.
- Scan the root package.json, scripts/*.ts and the CI workflows for the feature,
  not just this package's scripts.
- compile_error! now says a build without debug assertions.
- Remove @hypothesi/tauri-mcp-server: only the CLI is used.
- Test an explicit null over a set key in merge_patch.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…he daemon does (refs #3739)

The daemon writes the marker under its NODESPACE_HOME-redirected state directory,
but the app read it from the user's home only. A refusal recorded in the real
home (an older database refused by another build) therefore showed up as the
status of an unrelated, isolated run, and failed the not_running seam test on
any machine that held one. The app now honours the same redirect, and that test
points it at its temp dir.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… test the redirected-home wiring (refs #3739)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@malibio
malibio force-pushed the issue-3739-tauri-debug-bridge branch from 43c7efa to 47c987b Compare October 13, 2026 10:05
@malibio
malibio merged commit 6b5b4cb into main Oct 13, 2026
@malibio
malibio deleted the issue-3739-tauri-debug-bridge branch October 13, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant