feat(data-layout): route managed-mcp.json + project resource cache to the partition (#374 P1-2C) - #417
Open
jeff-r2026 wants to merge 1 commit into
Open
Conversation
… the partition (#374 P1-2C) Completes the P1-2 partition routing deferred from #406: the two remaining A1 items that still landed in the business workspace for a project install now follow the machine-data home. - `managed-mcp.json` (per-project MCP injection manifest) and the project-scope `local-agent/resources` cache (the 4MB the issue calls out) move to `~/.teamai/projects/<slug>/` for a partitioned install, keeping the workspace clean. (local-agent's own config/manifest are A2 — already global under ~/.teamai — and are untouched.) The trap these were deferred for: both are resolved from two sides — callers that hold a full LocalConfig (mcp-reconcile / mcp-cmd / uninstall) and the local-agent subsystem, which only carries (scope, projectRoot) and has no LocalConfig. If only one side moved, a partitioned install's writer and reader would disagree (partition vs legacy) and desync. Fix: one shared resolver. - `managedMcpManifestPath(dataHome)` now takes a resolved data home. LocalConfig holders pass `getDataHome(localConfig)`. - New `resolveDataHomeForScope(scope, projectRoot)` in config.ts reproduces detection's double-read (user → ~/.teamai; project → getDataHome of detectProjectConfig's result, i.e. partition for a new/migrated install, else legacy). The local-agent managed-mcp + resource paths route through it, so both sides always land on the identical directory. - `getResourceRepoPath` (local-agent) is now async and uses the shared resolver for its project branch; user scope is unchanged (~/.teamai/local-agent/resources). - `ensureProjectGitignore` now runs only when the cache actually lands inside the workspace (a legacy install) — a partitioned cache lives under ~/.teamai, so there is nothing in the workspace to ignore. Test plan (all green): - npx tsc --noEmit — clean; npx vitest run — 191 files / 2644 tests pass - new real git+fs integration tests (detect-subdir.test.ts) prove the desync guard: `resolveDataHomeForScope` == `getDataHome(detectProjectConfig(...))` for legacy, subdirectory, user, non-git, AND partitioned installs (config in ~/.teamai/projects/<slug>/ resolves to the partition from both sides). Note: the full http-backend local-agent install flow (install_skill/install_mcp end-to-end) is covered by the 65 existing local-agent unit tests; a live-backend e2e remains a manual TODO, as with the http provider. Refs #374 (P1-2C).
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.
Context
Completes the P1-2 partition routing deferred from #406. Two A1 items still landed
in the business workspace for a project install; they now follow the
machine-data home so a partitioned install has zero teamai residue:
managed-mcp.json— the per-project MCP injection manifest.local-agent/resources— the ~4MB skill cache the issue calls out.(local-agent's own config/manifest are A2 — already global under
~/.teamai— andare left untouched, per the issue's A1/A2 split.)
Why these were deferred (the desync trap)
Both are resolved from two sides: callers holding a full
LocalConfig(
mcp-reconcile/mcp-cmd/uninstall) and the local-agent subsystem,which only carries
(scope, projectRoot)and has noLocalConfig. Converging oneside alone would make a partitioned install's writer and reader disagree
(partition vs legacy) and desync. So both must resolve through one source.
What this PR does
managedMcpManifestPath(dataHome)now takes a resolved data home;LocalConfig holders pass
getDataHome(localConfig).resolveDataHomeForScope(scope, projectRoot)(config.ts) reproducesdetection's double-read: user →
~/.teamai; project →getDataHomeofdetectProjectConfig's result (partition for a new/migrated install, elselegacy
<projectRoot>/.teamai). The local-agent managed-mcp + resource pathsroute through it, so both sides always land on the identical directory.
getResourceRepoPath(local-agent) is now async and uses the shared resolverfor its project branch; user scope unchanged (
~/.teamai/local-agent/resources).ensureProjectGitignoreruns only when the cache actually lands inside theworkspace (a legacy install); a partitioned cache is under
~/.teamai, sothere's nothing in the workspace to ignore.
Test plan (all executed green)
npx tsc --noEmit— cleannpx vitest run— 191 files / 2644 tests passdetect-subdir.test.ts) prove thedesync guard:
resolveDataHomeForScope==getDataHome(detectProjectConfig(...))for legacy, subdirectory, user, non-git, and partitioned installs
(config in
~/.teamai/projects/<slug>/resolves to the partition fromboth sides).
Note: the full http-backend local-agent install flow (
install_skill/install_mcpend-to-end) is covered by the 65 existing local-agent unit tests; a live-backend
e2e remains a manual TODO, as with the http provider.
Refs #374 (P1-2C).