Repository navigation
Resolve the registry path through NODESPACE_HOME so a redirected DB can't poison it (closes #1648) - #1655
Conversation
…an't poison it (closes #1648) The registry path (databases.toml) was hard-wired to the real home directory while the served DB path honored NODESPACED_DB_PATH, so a harness that redirected the database but inherited HOME seeded ~/.nodespace/databases.toml with a temp-dir default. The daemon then served a doomed temp database as "Default" (macOS purges /var/folders, so the data silently disappears) and the boot log claimed a different path than the one actually served. - Add nodespace_home()/nodespace_dir() honoring NODESPACE_HOME; route both the registry path and resolve_db_path's default through them so a single override isolates all NodeSpace state. - Repair a poisoned default at boot: repair_doomed_default re-points the default to the standard path when it lives under a system temp dir while the registry itself does not; a no-op for intentionally isolated (temp) registries. - Log the registry-resolved served path ("serving default database") rather than the requested boot path. - Isolate the real-binary spawn harnesses (test-support, e2e daemon-harness, benchmark script) with NODESPACE_HOME so test runs never touch ~/.nodespace. Co-Authored-By: Claude <[email protected]>
|
APPROVE — correct, conservative fix for the data-loss bug; the subtle repair-vs-fixture logic is right. Root cause closedThe bug was the split: registry path hard-wired to The repair predicate is precise (the part most likely to be wrong, and it's right)
Also right
Closes #1648. Approve. |
Problem
~/.nodespace/databases.toml(the user-level database registry) could be seeded with a temp-dir path by test harnesses or temp-DB daemon runs, after which every boot served a doomed temp database as "Default". macOS purges/var/folders, so all data written there silently disappears — and the boot log printed a different path than the one actually served.Root cause: the registry path was hard-wired to the real
$HOME/.nodespacewhile the served DB path honoredNODESPACED_DB_PATH. A harness that redirected the DB but inheritedHOMEwrote its temp path into the real registry.Fix
NODESPACE_HOME— newnodespace_home()/nodespace_dir()resolver; both the registry path andresolve_db_path's default route through it, so one override isolates all NodeSpace state in lockstep.repair_doomed_defaultre-points the default to the standard path when it lives under a system temp dir while the registry itself does not; a no-op for intentionally isolated (temp) registries, so test fixtures are never clobbered.serving default database) instead of the requested boot path; theStartingline's field is renamedrequested_db_path.SpawnedDaemon, the e2edaemon-harness.ts, and the benchmark script) setNODESPACE_HOMEunder their temp dir, so test runs never touch~/.nodespace.Tests
default_is_doomedtruth table,repair_doomed_defaultno-op for an isolated registry,set_standard_defaultreplaces the previous default. Daemon lib suite green (67 tests).test:all+cargo build --bin nodespaced+test:e2e) green locally.Acceptance
~/.nodespace/databases.toml.Closes #1648.