Repository navigation
Serialize nodespace-agent/daemon/cli's libsql-ffi-linked tests - #2524
Conversation
#2431/PR #2514 serialized nodespace-core's own tests against a real, unsynchronized check-then-act race in libsql-ffi's vendored WAL-manager singleton, but left nodespace-agent/daemon/cli's SqliteStore-touching tests running unserialized under rust:test:workspace. Ran each affected target at --test-threads=16 over ~290 repeated runs (matching #2431's own methodology) and reproduced the same failure shape once in 100 runs of nodespace-agent's lib suite: a setup-time NodeService::new() panic (QueryFailed("Failed to query nodes")) with no code change between that run and every surrounding passing run of the identical test. Add rust:test:libsql-linked (cargo test --lib --bins --tests -p nodespace-agent -p nodespace-daemon -p nodespace-cli -- --test-threads=1), wire it into rust:test, and exclude these three packages from rust:test:workspace's --test-threads=2 run — the same shape as rust:test:core. Correct the SqliteStore doc comment, which previously described this as a deliberate deferral on the assumption these suites were "tens of tests, not 1000+" (nodespace-agent's own --lib target alone runs 621 tests in one process), to document the actual empirical finding and the now-extended scope. Also fixes a pre-existing clippy collapsible-match lint failure in node_service/mod.rs (unrelated to the libsql-ffi race, blocking `bun run quality:fix` on this branch) — mutation-tested to confirm the refactor preserves the test's assertion coverage. Co-Authored-By: Claude <[email protected]>
|
Reviewed (adversarial pass): independently confirmed |
Summary
#2431/PR #2514 serialized
nodespace-core's own lib/bin/test targets (rust:test:core,--test-threads=1) to close a real, unsynchronized check-then-act race inlibsql-ffi's vendoredSQLite3MultipleCiphersWAL-manager singleton.libsql-ffiis also linked transitively intonodespace-agent,nodespace-daemon, andnodespace-cli, whoseSqliteStore-touching tests were left running unserialized (--test-threads=2) underrust:test:workspace. This issue asked us to determine empirically whether that gap is practically reachable, and either extend the fix or make and document a deliberate defer decision.Path taken: extend. The race reproduced directly in
nodespace-agent's lib test suite.Empirical findings
Ran each
SqliteStore-touching test target acrossnodespace-agent,nodespace-daemon, andnodespace-cliat--test-threads=16over many repeated runs, matching #2431's own methodology:nodespace-agent --lib(621 tests)NodeService::new()setup-time panic,QueryFailed("Failed to query nodes"), no code change between the failing run and every surrounding passing run of the identical testpty::manager::tests::ultra_short_lived_processes_are_prunedtiming flake under CPU load, unrelated to SQLitenodespace-daemon --lib(187 tests)nodespace-daemon—grpc_round_trip,import_round_trip,agent_session_grpcnodespace-cli—cli_integration,import_dir_multinodespace-agent—search_nodes_enumerate,live_unset_schema_field,matrix_scenario_winnabilitynodespace-agent—live_update_node_noop_gate,live_resolve_query_decomposition_shapes#[ignore]d (requires a local GGUF), so these ran 0 actual tests either wayThe one genuine reproduction hit the exact failure shape #2431 documented for
nodespace-core: a setup-time query failure (viaNodeService::new()→seed_local_person_if_needed→ aquery_nodescall inside the same process as 15 other concurrently-openingSqliteStores) that doesn't reproduce on code inspection and didn't recur on the very next run of the identical test. (Note: the panic message itself only shows"Failed to query nodes"becauseNodeServiceError::query_failed(e.to_string())callsanyhow::Error::to_string(), which prints only the top.context()frame and drops the underlying cause chain — a separate, pre-existing loss of diagnostic detail, not something this PR changes.)nodespace-daemon's lib and every explicitly-named integration target stayed clean across ~190 further runs. The root cause (documented onSqliteStoreinpackages/core/src/db/sqlite_store/mod.rs) has no principled guarded region narrower than "every operation on every connection, for the life of the process," and a genuine reproduction via the identical mechanism already landed in one of the three crates — so a clean run elsewhere reads as that suite being smaller (fewer concurrentSqliteStore::new()calls competing for the same instant), not as that target being unexposed.Change
package.json: addedrust:test:libsql-linked(cargo test --lib --bins --tests -p nodespace-agent -p nodespace-daemon -p nodespace-cli -- --test-threads=1), wired intorust:test, and excluded these three packages fromrust:test:workspace's--test-threads=2run — the same shape asrust:test:core.packages/core/src/db/sqlite_store/mod.rs: corrected theSqliteStoredoc comment, which previously described the agent/daemon/cli exposure as a "deliberate, tracked deferral" on the assumption those suites were "tens of tests, not 1000+" (that assumption undercounted —nodespace-agent's own--libtarget alone runs 621 tests in one process). The comment now documents the actual empirical finding and the extended scope.nodespace-cli's own--libtarget has no directSqliteStoreconstruction (only its two integration test files do), so its practical exposure is narrower than the other two, but it's included in the same script for consistency with the whole-crate granularityrust:test:corealready established (cargo's--test-threadsis a per-invocation flag, not a per-test one, so splitting finer within a crate isn't a maintainable option without fragile test-name filtering).Test plan
bun run test:allpasses with no new failuresbun run quality:fixis cleanrust:test:workspace(with the new excludes) no longer runs agent/daemon/cli testsrust:test:libsql-linkedruns all three crates' lib/bin/test targets at--test-threads=1with 0 failures