Repository navigation
Test the real Tauri-to-daemon seam end-to-end (ADR-048) - #1563
Conversation
…test ADR-048 step 1: SpawnedDaemon now yields a connected GrpcClient plus a tauri::test::mock_app() with it managed, so tests obtain a real tauri::State<GrpcClient> via Manager::state() and call #[tauri::command] handlers directly — no webview, no mock-on-mock. Node CRUD round-trip (create/read/update/delete, hierarchy, properties) now runs through the actual production command layer against a real headless daemon. Also fixes build-sidecars.ts, which failed on a fresh checkout/worktree because binaries/ is .gitignore'd and never pre-created before cp. Co-Authored-By: Claude <[email protected]>
Three more ADR-048 priority flows, all against the real Tauri command layer and a real headless daemon: - indent/outdent + rapid-Enter ordering: real move_node/reorder_node sequencing (the #662 race pattern), rapid sibling creation order, and concurrent reorders of distinct nodes. - commits-per-edit (#1492 backend half): one update_node call moves the version by exactly one, and reusing a stale pre-confirmation version is OCC-rejected — proves self-conflict is structurally caught. - model-download terminal state incl. cancel: drives the real DownloadModel gRPC stream directly (chat_model_download's AppHandle is hardcoded to the real Wry runtime, so it can't be called through tauri::test's MockRuntime — a structural constraint, not a harness gap) plus the State-only cancel/list/load/unload commands. TauriTestApp gains handle() for AppHandle-taking commands whose bodies don't require the real runtime. Co-Authored-By: Claude <[email protected]>
Cross-window hierarchy sync: two independent GrpcClient connections to the same daemon (modeling two windows) observe each other's writes and converge — no shared in-process state, only the daemon in common. Optimistic-edit-vs-echo race (ADR-048's primary motivating flow): drives the REAL watcher::run against a real daemon and a real Tauri event bus (tauri::test's MockRuntime), not a reimplementation. Along the way, discovered watcher.rs's own module doc was stale — it claimed the gRPC watcher was "inert" pending an in-process DomainEventForwarder, but grep + lib.rs:335 confirm watcher::spawn is unconditionally live and DomainEventForwarder no longer exists anywhere in the codebase. Corrected the doc and made watcher::run generic over tauri::Runtime (previously hardcoded to the real Wry runtime) solely so this test can drive the actual production function under MockRuntime. Co-Authored-By: Claude <[email protected]>
…e it never could have caught Deletes src/tests/integration/tauri-commands.test.ts (ADR-048): it exercised zero production lines — a vi.fn() configured to return a value, invoked, and asserted it returned what it was told to return. Real coverage of the Tauri command layer now lives in the Rust seam tests added in prior commits. While hardening those tests against full-suite concurrency, found a genuine intermittent race (~1/15 full-suite runs): concurrent reorders of distinct siblings to opposite boundary positions can produce an inconsistent final order, because move_node's same-parent branch reads sibling order values and writes the new order back as two separate, non-transactional steps. Filed #1561 with root cause and a suggested fix. Split the covering test in indent_outdent_rapid_ordering_test.rs: the RPC-success assertion stays enabled, the strict-final-order assertion is now #[ignore]'d as a documented regression test for #1561 rather than left flaky in the suite. Co-Authored-By: Claude <[email protected]>
…ode lint The pre-push gate (scripts/test-gate.ts, ADR-047) only ever ran `bun run test:all`, which covers `-p nodespace-core --lib` — the desktop-app Rust integration tests under packages/desktop-app/src-tauri/tests/ (including the pre-existing daemon_readiness_test.rs and schema_parity_test.rs) never ran anywhere. Added a `cargo test -p nodespace-app` step, using NODESPACED_TEST_BIN to point at the binary the gate already builds for the e2e step. That surfaced a real problem: rust:lint runs clippy with -D warnings, and each `tests/*.rs` file compiled `mod support;` as its own private copy of the shared fixtures, so clippy's dead-code lint flagged whatever subset any single test binary didn't happen to use. Fixed by extracting the fixtures into their own crate (test-support/), compiled once and used across every test file, added as a workspace member and a dev-dependency of nodespace-app. Co-Authored-By: Claude <[email protected]>
…test Startup readiness: extends daemon_readiness_test.rs's signal-only coverage to the data plane — a real create_node call against a not-yet-bound daemon fails cleanly (not a hang, not a panic), and the SAME lazy GrpcClient/State succeeds immediately once the daemon is healthy, with no explicit reconnect step. This is what the frontend's connect_lazy story actually depends on at app startup. "Degraded state" as a Svelte-visible concept already has real, thorough coverage in src/tests/e2e/daemon-readiness.e2e.ts (ADR-044/#1525) — not duplicated here; there is no separate Rust-side "degraded" enum (DaemonStatus is Healthy/Starting/NotRunning only). Adapter contract (ADR-048 decision 5): adapter-contract.e2e.ts already proves HttpAdapter/dev-proxy parity and explicitly notes the Tauri-IPC half needs a Rust-side test. Added it: the same three scenarios (task tri-state clear/set/no-change, create-with-InsertPosition, move-with-InsertPosition) driven through the real #[tauri::command] functions, asserting the same outcomes. Updated the TS file's doc comment to point at it. Co-Authored-By: Claude <[email protected]>
…eadlock The last ADR-048 priority flow: no dedicated "send chat" command exists (per scripts/aichat.ts's own doc comment) — a turn is a batch-update (append user message + status:processing) that the daemon's event watcher picks up, then poll get_node until idle with a new assistant reply. Drives ministral-3b-q4km (smallest catalog model, already downloaded locally) as the fastest available REAL model; no stub engine exists anywhere in the codebase and building one would mean carving a test-only path into the production model-selection logic in local_agent_service.rs, out of scope here. While debugging why this hung indefinitely, found a real bug in SpawnedDaemon: it pipes the daemon's stdout/stderr but never drains them. llama.cpp's own logging (Metal kernel compilation alone is dozens of lines per model load, outside RUST_LOG's filter entirely) overflows the ~64KB OS pipe buffer during any test that loads a real model, and the daemon then blocks on its next write() call — a silent, total hang with 0% CPU, easy to mistake for "still loading." Fixed by draining both pipes on background threads for the daemon's entire lifetime (matching the existing E2E_VERBOSE convention from the TypeScript harness to optionally echo instead of discard). This was latent in daemon_readiness_test.rs and schema_parity_test.rs too — they simply never logged enough to trigger it. With the fix, the ai-chat test runs in ~17s — well within an acceptable pre-push gate cost, not the multi-minute hang it looked like before the fix. Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis PR delivers on ADR-048's core mandate: the Tauri command layer — the actual shipping path, previously covered by a mock-on-mock test that exercised zero production lines — now has real integration coverage against a real headless The pipe-buffer-drain fix is real and correctly implemented — I traced it against This is a net-positive, well-engineered change that closes a real, previously-acknowledged coverage gap and finds two genuine bugs along the way (the pipe deadlock, and the #1561 reorder race). I have some findings below, none of which should block merge, but the environment-coupling issue (model download) is worth a deliberate decision rather than silent acceptance. FindingsCritical IssuesNone. I did not find a security, correctness, or architectural issue that should block merge. Suggested Improvements
Nitpicks
Verification performed
|
malibio
left a comment
There was a problem hiding this comment.
Reviewed commit 3e83985. Pragmatic code review posted above — net positive, no blockers. Two Improvement-level findings (model-download environment coupling; duplicated env mutex naming) and three nits. See full review comment for details.
…env mutex Addresses the two Improvement-level findings from the PR review: - ai_chat_send_to_idle_test.rs and model_download_terminal_state_test.rs hard-depended on ministral-3b-q4km already being present under ~/.nodespace/models/, with no provisioning step and no clean failure mode — a fresh machine would hang on a live multi-gigabyte HuggingFace download rather than fail fast. Added model_file_available() to the shared test-support crate and a skip-with-clear-message path in both files (a macro in the download test, since three of its four tests need it) so the pre-push gate degrades gracefully instead of hanging on a machine that hasn't provisioned the model yet. - daemon_readiness_test.rs defined its own file-local ENV_MUTEX duplicating the shared crate's CONNECT_MUTEX under a different name. Made CONNECT_MUTEX pub and switched daemon_readiness_test.rs to use it, so there's one process-wide-env-mutation lock, not two names for the same concept. Also added a one-line comment at optimistic_echo_race_test.rs's TauriTestApp::connect call site clarifying the two-mutex-acquisitions shape the reviewer traced through (safe, but subtle enough to note). Skipped two nit-level suggestions per the review's own framing: - Joining SpawnedDaemon's drain threads on Drop: reviewer confirmed this is harmless today (process exit reclaims them); adding join-with-timeout is marginal complexity for a test-only harness. - Strengthening the cancel test to mid-flight: reviewer confirmed the current scope (cancel of a non-in-progress download) is a reasonable, already-disclosed tradeoff given a live in-flight multi-GB download would be nondeterministic/slow to test reliably. Co-Authored-By: Claude <[email protected]>
Addressed review feedbackImprovements addressed (2/2):
Nit addressed (1/3):
Nits skipped (2/3), per the review's own framing:
All changes verified: Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: All changes are additive/mechanical — a skip-guard added to existing tests, a rename/consolidation of an internal test-only mutex, and a comment. No architectural changes, no new functionality, no changes to the actual product code being tested. Low risk, straightforward to verify by reading the diff. |
Summary
Implements ADR-048: extends the existing Rust
SpawnedDaemonintegration-test harness (previously used only bydaemon_readiness_test.rs) to drive the real Tauri command layer directly — no webview, no mock-on-mock — against a real headlessnodespacedand real SQLite.SpawnedDaemon(real daemon process) +TauriTestApp(atauri::test::mock_app()with a connectedGrpcClientmanaged as state), giving tests a realtauri::State<GrpcClient>viaManager::state()— the sanctioned construction path, sincetauri::Statehas no public constructor. Extracted into its own crate (test-support/) so clippy's dead-code lint sees one compilation shared across every test file instead of flagging whichever subset any single test binary doesn't use.src/tests/integration/tauri-commands.test.ts— the mock-on-mock file that exercised zero production lines.watcher::run(made generic overtauri::Runtimefor testability) against a realWatchNodesstream and a real Tauri event bus. Along the way foundwatcher.rs's module doc was stale (claimed the gRPC watcher was inert; it's the sole live event path — fixed the comment).ministral-3b-q4km(smallest catalog model, already downloaded) since no stub inference engine exists anywhere in the codebasedaemon_readiness_test.rs's signal-only coverage)GrpcClientconnections to one daemon)adapter-contract.e2e.ts's HttpAdapter/dev-proxy parity checks, driving the same 3 scenarios through the real Tauri command layer.update_nodecall moves the version by exactly one, and a stale pre-confirmation version is OCC-rejected.cargo test -p nodespace-appintoscripts/test-gate.ts— the desktop-app Rust integration tests (including the pre-existingdaemon_readiness_test.rs/schema_parity_test.rs) previously ran nowhere at all.Bugs found and fixed along the way
SpawnedDaemonpipe-buffer deadlock: stdout/stderr were piped but never drained. llama.cpp's own logging overflows the ~64KB OS pipe buffer during any test that loads a real model, silently hanging the daemon (0% CPU) on its nextwrite(). Fixed by draining both pipes on background threads (optionally echoing underE2E_VERBOSE, matching the TS harness convention). This was latent in the pre-existing tests too.build-sidecars.ts: failed on a fresh checkout/worktree becausebinaries/is.gitignore'd and never pre-created beforecp. AddedmkdirSync.move_node's same-parent reorder branch — sibling read, order computation, and write-back aren't wrapped in a transaction, so two concurrent reorders can compute overlapping fractional-order keys. The covering test is split: the RPC-success assertion stays enabled, the strict-final-order assertion is#[ignore]'d as a documented regression test for Concurrent sibling reorders can race on the fractional-order read-then-write window #1561.e2e-testing.md(sidecars are.gitignore'd/built on demand, not committed).Test plan
bun run test:all— 147 frontend files / 3949 tests, 17 skill tests, 966 Rust core tests, all passingbun run quality:fix— clean, no changes neededscripts/test-gate.ts(the actual pre-push gate) run twice end-to-end, all green/pragmatic-code-reviewto follow before mergeCloses #1499.
🤖 Generated with Claude Code