fix: scope memory tools per-user in multi-tenant mode

Memory tools (search, write, read, tree) held a single workspace
created at startup with GATEWAY_USER_ID. In multi-tenant mode, all
users' tool calls searched the default user's scope.

Add WorkspaceResolver trait that resolves workspaces per-request using
JobContext.user_id. In single-user mode, returns the startup workspace.
In multi-tenant mode (GATEWAY_USER_TOKENS configured), creates and
caches per-user workspaces on demand.

Includes regression tests for workspace resolution and user isolation.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
Andrew Preece
2026-03-23 18:01:30 +00:00
co-authored by Claude Opus 4.6
parent b394c0cfdd
commit 76431159c8
5 changed files with 407 additions and 55 deletions
+4 -3
View File
@@ -3403,9 +3403,10 @@ impl ExtensionManager {
// No auth section — setup_is_complete was already checked above,
// so if we reach here the setup requirements are satisfied.
if cap_file.setup.is_none() {
return ToolAuthState::NoAuth;
}
let setup = match &cap_file.setup {
Some(s) => s,
None => return ToolAuthState::NoAuth,
};
let all_provided = futures::future::join_all(
setup