Skip to content

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
mainfrom
worktree-issue-374-p1-2c-managed-mcp-resources
Open

feat(data-layout): route managed-mcp.json + project resource cache to the partition (#374 P1-2C)#417
jeff-r2026 wants to merge 1 commit into
mainfrom
worktree-issue-374-p1-2c-managed-mcp-resources

Conversation

@jeff-r2026

Copy link
Copy Markdown
Collaborator

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.
  • project-scope local-agent/resources — the ~4MB skill cache the issue calls out.

(local-agent's own config/manifest are A2 — already global under ~/.teamai — and
are 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 no LocalConfig. Converging one
side 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).
  • New resolveDataHomeForScope(scope, projectRoot) (config.ts) reproduces
    detection's double-read: user → ~/.teamai; project → getDataHome of
    detectProjectConfig's result (partition for a new/migrated install, else
    legacy <projectRoot>/.teamai). 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 unchanged (~/.teamai/local-agent/resources).
  • ensureProjectGitignore runs only when the cache actually lands inside the
    workspace (a legacy install); a partitioned cache is under ~/.teamai, so
    there's nothing in the workspace to ignore.

Test plan (all executed green)

  • npx tsc --noEmit — clean
  • npx vitest run191 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).

… 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant