Skip to content

[bug] databases.toml can be seeded with a tempdir database path — daemon then silently serves a doomed default DB (data-loss class) #1648

Closed

Description

@mstomar125

Observed (dev machine, current main)

~/.nodespace/databases.toml contained exactly one registered database:

default_database = "01KX3JK6HE68SYKBA2S6D97EEF"
[[databases]]
id = "01KX3JK6HE68SYKBA2S6D97EEF"
name = "Default"
path = "/var/folders/3w/.../T/.tmpnHTMLn/db"   # tempfile::TempDir path!
created_at = "2026-07-09T13:55:36Z"

Some process on Jul 9 (test harness or a daemon run pointed at a temp DB) seeded the USER-LEVEL registry with its temporary database path. Every daemon boot since then loads that registry and serves the temp-dir database as "Default".

Two aggravating factors:

  1. The boot log lies: nodespaced logs db_path=~/.nodespace/database/nodespace.db at startup while the registry routes the default database to the temp path — the served DB and the logged path disagree.
  2. macOS periodically purges /var/folders temp dirs — all user data written to that "Default" database is destined for silent deletion. Symptom for a real user: notes vanish / app comes up empty.

Fix direction

  • Tests/dev harnesses must never write the user-level registry: registry path must follow the DB-path override (or honor an env like NODESPACE_HOME) so temp-DB runs use a temp registry.
  • Boot should log the actual registry-resolved default path, not the flag/env value it ignored.
  • Boot-time sanity check: if the default database path is missing or resides under a system temp location, warn loudly and fall back to (or re-register) the standard ~/.nodespace/database path instead of silently serving a doomed DB.

Acceptance

  • Running the test suites never mutates ~/.nodespace/databases.toml.
  • A registry whose default path is gone/temp produces a visible warning + safe fallback, and the boot log reflects the DB actually served.

Activity

  1. added a commit that references this issue on Jul 14, 2026
    cec4529
  2. mstomar125 commented on Jul 14, 2026

    @mstomar125
    ContributorAuthor

    Resolved by #1655 (merged to main cec45296).

    NODESPACE_HOME now resolves the registry (databases.toml) and the served DB default through the same home dir, so redirecting one no longer poisons the other. Boot re-points a default that lives under a system temp dir (while the registry itself doesn't) to the standard path and logs the registry-resolved served path. The real-binary spawn harnesses (test-support, e2e daemon-harness, benchmark script) set NODESPACE_HOME so test runs never touch ~/.nodespace.

    Adversarially re-reviewed: repair only fires for a genuinely-doomed default and preserves unrelated registered DBs; healthy/community boot is an unchanged no-op. Note (follow-up): registry-only isolation — daemon.toml/models still resolve via HOME (pre-existing, out of scope here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions