Skip to content

feat(spec-analyze): MCP knowledge-graph cache in front of discovery (FASE 1)#3

Draft
GorlemZ wants to merge 3 commits into
mainfrom
mcp-integration
Draft

feat(spec-analyze): MCP knowledge-graph cache in front of discovery (FASE 1)#3
GorlemZ wants to merge 3 commits into
mainfrom
mcp-integration

Conversation

@GorlemZ

@GorlemZ GorlemZ commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Cosa

Aggancia il workflow spec-analyze (workflows/spec-analyze.js) alla knowledge-graph MCP vibingwithclaude come cache davanti alla fase di discovery.

  • All'avvio: Context lookup interroga l'MCP; su fresh hit (bundle commit_sha == HEAD) il broker materializza repo-map/ + comments.md dal grafo e la discovery viene saltata.
  • Su miss / MCP giù / useIndex=false: discovery come sempre, poi Index write-back popola il grafo (non-bloccante). Zero regressioni quando l'MCP non c'è.

Modifiche

  • workflows/spec-analyze.js — fasi Context lookup + Index write-back, agent context-broker/indexer, args useIndex/workspace (sanitizzato a [a-z0-9-]), sidecar JSON machine-readable nei prompt cartographer/crawler.
  • workflows/repo_map_to_bundle.py — transform deterministico md/JSON → ingest bundle (stdlib), con test offline.
  • workflows/MCP-CACHE.md — documentazione feature + contratto nodi/workspace + backlog FASE 2.

Vincoli / invarianti

  • La cache non sovrascrive mai la verità as-is: in dubbio → miss → discovery piena.
  • Write-back best-effort/non-fatale; ingest_bundle (schema_version: "1.0", validato) con fallback upsert_node/add_link.
  • replace_edges solo su bundle con i nodi da rilinkare; bundle vuoti omessi → niente wipe di edge.
  • Il broker si auto-verifica (wc/ls sui target) prima di dichiarare fresh (il body JS non ha filesystem).

Validazione

  • Spike MCP: reachability read+write da agent Workflow ✅; ingest_bundle accetta schema_version:"1.0", body_md/extra/links round-trip ✅.
  • Code-review (high effort, 3 finder): 5 fix applicati + bug di caricamento (backtick nel template literal) corretto. JS+PY syntax OK.

Non incluso (deferred)

  • FASE 2: staleness per-area (diff path↔aree, cartographer scoped, ri-sintesi index.md).
  • E2E live su repo reale — da fare.
  • Fix drift pre-esistente di run_cost.py (ROLE_PHASE/PHASE_ORDER) — separato.

🤖 Generated with Claude Code

GorlemZ and others added 3 commits July 1, 2026 11:16
…FASE 1)

- Context lookup phase: reuse indexed repo-map/+comments.md on a fresh
  (commit_sha==HEAD) hit and skip discovery; miss => original flow unchanged
- Index write-back phase: ingest cartographer/crawler output (non-blocking)
- repo_map_to_bundle.py: deterministic md/JSON -> ingest bundle transform
- machine-readable sidecars (repo-map/index.json, comments.index.json)
- useIndex/workspace args; workspace sanitized to [a-z0-9-]
- docs in workflows/MCP-CACHE.md; FASE 2 (per-area staleness) deferred

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- repo_map_to_bundle.py: fix crash when writing the --out summary with
  0 or 1 bundles (regression from omitting empty bundles); the indexer
  always uses --out, so an empty/partial discovery would have crashed
- workspace: fall back to sanitized repo if a caller passes a workspace
  that sanitizes to empty (never send an empty workspace to the MCP)
- context-broker prompt: make purpose->card.summary mapping explicit for
  fresh-hit index.md materialization

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- workflows/check_mcp.py (stdlib): single-source-of-truth root .env for
  MCP_URL/MCP_API_KEY (never hardcoded in the workflow). Missing .env ->
  create template + .gitignore and stop (like the Atlassian preflight);
  present -> idempotently (re)register the MCP server from .env and ping it
  (JSON-RPC initialize). Unreachable = warning (workflow degrades to
  no-cache via useIndex), never blocking. Prints resolved SPEC_OUTPUT_DIR.
- default outputDir -> ./output[-goals]; launcher passes SPEC_OUTPUT_DIR
  (absolute) as args.outputDir so output always lands in this repo.
- .gitignore + .env.example; README + MCP-CACHE.md preflight docs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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