gortex icon indicating copy to clipboard operation
gortex copied to clipboard

bug: MCP analyze ignores workspace scoping; health kind also ignores an explicit repo target

Open tydude001 opened this issue 4 months ago • 0 comments

Summary

MCP analyze results are not scoped to the session's bound workspace: with the default one-workspace-per-repo layout, unscoped calls return symbols from all tracked repos. Passing target {repo: "<name>"} fixes it for some kinds (clones, dead_code) but the health kind ignores the repo selector entirely — in both name and path form — while accepting it without error.

The CLI is not affected: gortex analyze --kind health_score run from a repo cwd scopes correctly. So the graph and analyzers can scope; the MCP facade is what loses the binding.

Environment

  • daemon v0.61.1+89263194, linux/amd64, go1.26.5, systemd user unit
  • 14 tracked repos, default workspaces (one per repo, no shared workspace: declarations)
  • MCP session bound to repo vault-stack — workspace(operation:"active_project") returns bound: true, project: vault-stack, workspace: vault-stack
  • v0.61.4's release notes don't mention this area; happy to retest on latest if you expect it's fixed

Reproduction

  1. Unscoped analyze is global, not workspace-bound. From the session bound to vault-stack (a ~50-symbol bash repo):

    analyze kind=health            → {"symbol_count":4393, ..., "worst_symbols":[
        {"id":"tradebot::stdlib::time::time", ...},
        {"id":"scripts/media/encoder.py::encoder_thread", ...},
        {"id":"tradebot/bot/backtest.py::run_momentum", ...}]}
    

    Every worst symbol is from a different tracked repo. analyze kind=clones likewise returns clusters from gortex-web, tradebot, whatdowewatch, rivalbot — none from the bound repo.

  2. health ignores an explicit repo target. Both forms return the identical 4393-symbol global result:

    analyze kind=health target={"repo": "vault-stack"}
    analyze kind=health target={"repo": "/home/tyler/projects/vault-stack"}
    

    No error — the selector is accepted and silently ignored. (An invalid selector key is rejected with unknown target selector, so the target is being parsed.)

  3. The selector works for other kinds, which is what isolates the bug to health:

    analyze kind=clones target={"repo": "vault-stack"}   → 0 clusters (correct for this repo)
    
  4. CLI control. From the repo's directory:

    gortex analyze --kind health_score --format json     → 47 symbols, all vault-stack (correct)
    

Expected

  • MCP analyze with no target should default to the session's bound workspace, matching CLI behavior (or at minimum the docs should say it's global).
  • Every kind should honor target.repo; accepting the selector and ignoring it is the worst combination, since results look plausible until a foreign path shows up.

Possibly related

  • The MCP and CLI kind lists have diverged: MCP exposes health and clones; the CLI exposes health_score and has no clones. If MCP health is a distinct global aggregator rather than a facade over health_score, that would explain repro 2 — but it silently accepting target.repo still seems wrong.
  • #322 (analyze kind=routes mixes fields) may share plumbing but describes field attribution, not scope.

tydude001 avatar Jul 26 '26 00:07 tydude001