Repository navigation
ADR-053 Stage 5 (part 2): route import, embeddings, and agent-session requests - #1591
Merged
Merged
Conversation
… requests Applies the per-request database routing pattern established for NodeService to the remaining cleanly per-database services (ADR-053). Each gains a `route(&request)` helper — identical to `NodeServiceImpl::route` — that reads the `DatabaseManager` injected by `DbManagerLayer`, resolves `x-ns-database-id` (absent → default; unregistered → rejected), and returns the target database's service; with no manager present (Pro daemon, unit tests) it returns `self`, so behavior is unchanged. - ImportService: both handlers route, so an import writes to the targeted database. New test `import_rejects_unregistered_database_header`. - EmbeddingsService: all handlers route (search / queue / stale-count operate on the targeted database's vectors). The `stale_count_inner` helper stays on `self` — it runs on the already-routed impl. - AgentSessionService: only `launch_session` routes — the `PtySessionManager` is process-global (one Arc backs every database), so stream/write/resize/ terminate/list act on the shared session set regardless of database; launch is the sole handler that reads the per-database context assembler + node service (for context and capture), so it follows the targeted database. No impl constructor, `BaseServices` field, or `build_base_router` signature is touched — no cross-repo change; nodespaced-pro is unaffected. Deferred: LocalAgentService routing. Its model manager is process-global (with a pending hoist-to-shared refactor) while only its chat-turn processing is per-database; routing it now would prematurely couple to that unresolved split. cargo test -p nodespace-daemon green (lib 48); cargo fmt + clippy --all-targets -D warnings clean. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
Author
|
APPROVE Reviewed the full diff at
Clean — no changes requested. |
This was referenced Jul 9, 2026
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.
ADR-053 Stage 5 (part 2) — route import, embeddings, and agent-session requests
Part of the ADR-053 epic ("One Daemon, Multiple Local Databases", #1532). Follows part 1 (#1590), which added the
DbManagerLayerrouting middleware and routedNodeService. This applies the same, now-reviewed pattern to the remaining cleanly per-database services.What changed
Each service gains a
route(&request)helper — identical in shape toNodeServiceImpl::route— that reads theDatabaseManagerinjected byDbManagerLayer, resolvesx-ns-database-id(absent → default; unregistered → rejected, never silently served from the default), and returns the target database's service. With no manager present (the Pro daemon installs no layer; unit tests construct impls directly) it returnsself, so behavior is unchanged.import_rejects_unregistered_database_header.stale_count_innerhelper deliberately stays onself: it runs on the already-routed impl.launch_sessionroutes. ThePtySessionManageris process-global (oneArcbacks every database), so stream / write / resize / terminate / list act on the shared session set regardless of database.launch_sessionis the sole handler that reads the per-database context assembler and node service (for context + capture), so it follows the targeted database.Cross-repo
No impl constructor,
BaseServicesfield, orbuild_base_routersignature is touched — no cross-repo change;nodespaced-prois unaffected (it inherits the extension-aware handler bodies via its pinned core rev and, installing no layer, behaves identically).Verification
The routing wiring is enforced by the type-checker: a missed
self→thisswap surfaces as an unused-thiserror underclippy -D warnings, and returning the wrong service field is a type error. On top of that,import_rejects_unregistered_database_headerexercises the fail-closed path end-to-end for a non-NodeServiceservice (part 1'sroutes_requests_by_database_headeralready proves data isolation for the routing mechanism itself).cargo test -p nodespace-daemongreen (lib 48);cargo fmt --checkandcargo clippy --all-targets -- -D warningsclean.Deferred
LocalAgentService routing. Its model manager is process-global (with a pending hoist-to-shared refactor) while only its chat-turn processing is per-database; routing it now would prematurely couple to that unresolved global/per-database split. It will be handled together with the model-manager-to-shared work.