Repository navigation
Create the DB file on database create; error on wrong-database reads instead of serving the active DB - #1681
Merged
mstomar125 merged 1 commit intoJul 16, 2026
Merged
Conversation
…ad instead of serving the active DB database create only registered an entry in databases.toml — the file was never created (a lazy-open follow-on that never shipped), so a new database reported status=missing and the switcher wedged. - DatabaseManager::create now creates + opens the file and its schema before registering, caches the open handle, and rolls back (closes the handle, deletes the db/-wal/-shm files) if registration fails; a fresh database reports Open. insert_entry rolls back its in-memory mutation when the TOML save fails; register now errors on an absent file. - Database routing: the shared routed_database_services contract rejects a request that names a database (x-ns-database-id) on a daemon with no routing middleware installed with UNIMPLEMENTED, instead of silently serving the active database — a wrong-database read the caller can't detect. Header-less requests keep the default-database fallback, so the single-database Pro daemon and direct-construction tests are unchanged. This is what made semantic `search --database` (and any header-carrying request) silently return the active DB's results on the Pro daemon. Full multi-database routing on the Pro daemon additionally needs the routing layer installed there (tracked separately). Closes #1675 Closes #1676 Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
Author
|
APPROVE (adversarial re-review) Verified the one intended behavior change is isolated and no normal flow breaks:
Two low-severity nits accepted as best-effort on exceptional paths (documented behavior, match existing The Pro-build validation item (external Pro daemon may omit Merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two round-1 daemon findings on the multi-database (ADR-053) path:
database createnever created the DB file.DatabaseManager::create()registered the database in the registry but never created/opened the SQLite file, so a freshly-"created" database 500'd on first use.create()now creates and opens the file before registering, and rolls the registry entry back if the open fails.register()now errors when the target file is absent instead of silently registering a phantom.A wrong-
--databaseread silently served the active DB. When a request carried anx-ns-database-idheader naming a database the daemon has noDatabaseManagerfor, routing fell through to the default services and returned the active database's data — a silent wrong-answer.routed_database_services()now returnsUNIMPLEMENTEDfor a named-DB request when noDatabaseManageris present, while a header-less request keeps the default-fallback behavior. Verified safe for normal flows: the CLI and desktop app only stamp the header on an explicit database-switcher selection, never on the default single-DB path.Testing
bun run test:all+cargo build --bin nodespaced+test:e2e(full pre-push gate) green.Closes #1675
Closes #1676