Skip to content

feat(mcp): expose index freshness and relationship provenance#544

Open
vvenegasv wants to merge 2 commits into
DeusData:mainfrom
vvenegasv:main
Open

feat(mcp): expose index freshness and relationship provenance#544
vvenegasv wants to merge 2 commits into
DeusData:mainfrom
vvenegasv:main

Conversation

@vvenegasv

@vvenegasv vvenegasv commented Jun 21, 2026

Copy link
Copy Markdown

What does this PR do?

This PR adds machine-readable freshness and provenance evidence to MCP responses, helping clients determine whether results come from a current index, a stale or partial index, direct source resolution, or heuristic inference.

Changes include:

  • Persisting the indexed Git HEAD and file coverage metrics for each project.
  • Extending index_status with additive evidence about indexed/current revisions, working tree state, freshness, coverage, and known limitations.
  • Returning edge_evidence from trace_path and trace_call_path when relationship provenance is available.
  • Preserving backward compatibility by returning unknown or unavailable values when older indexes do not contain the new metadata.

Why is this needed?

Consumers of the MCP need factual and inspectable signals to decide whether a result can be trusted as-is, whether the repository should be re-indexed, or whether the result should be verified directly against source code.

Rather than exposing an opaque reliability score, this change provides the underlying evidence needed for clients to make that decision.

Checklist

  • Every commit is signed off (git commit -s)
  • Tests pass locally (make -f Makefile.cbm test)
  • Lint passes (make -f Makefile.cbm lint-ci)
  • New behavior is covered by a test

### Motivation
- Provide inspectable, machine-readable evidence so clients can decide whether graph results are based on a current snapshot, a stale/partial snapshot, direct source resolution, heuristic inference, or unavailable provenance.
- Avoid opaque reliability scores by exposing factual fields (indexed HEAD, working-tree dirtiness, coverage counters, and per-edge provenance when available).
- Keep changes additive and backward-compatible so older indexes/clients continue to work.

### Description
- Persist project snapshot metadata and coverage counters: added `indexed_git_head`, `files_discovered`, `files_indexed`, `files_excluded`, and `files_failed` to the `projects` table and to `cbm_project_t`, with a non-destructive schema migration and an update API `cbm_store_update_project_coverage`; files changed: `src/store/store.h`, `src/store/store.c`, `src/pipeline/pipeline.c`.
- Capture the repository HEAD at snapshot time and store it during `cbm_store_upsert_project` instead of substituting current HEAD at query time; files changed: `src/store/store.c`, `src/git/git_context.c`, `src/git/git_context.h`.
- Expose working-tree freshness and index snapshot evidence in `index_status` by adding an additive `evidence` object containing `index_snapshot` (indexed/current HEADs, repository_state, snapshot_matches_* booleans, `freshness`), `coverage`, and `limitations` via `add_index_evidence_json`; file changed: `src/mcp/mcp.c`.
- Carry stored edge `properties` through BFS and add `edge_evidence` to `trace_path`/`trace_call_path` responses that derives `resolution_strategy`, source `confidence` (when present), `candidate_count`, `evidence_status` (verified|inferred|ambiguous|unavailable), and preserves prior response shape; files changed: `src/store/store.h`, `src/store/store.c`, `src/mcp/mcp.c`.
- Add `cbm_git_tracked_dirty()` to determine tracked-file dirtiness (explicitly excluding untracked files) and document semantics in README; file changed: `src/git/git_context.c`, `src/git/git_context.h`, and `README.md`.

### Testing
- Ran `scripts/build.sh` which completed successfully and produced `build/c/codebase-memory-mcp` (build: ✅).
- Launched `scripts/test.sh` under sanitizers; the test run was started but terminated in this environment before completion due to runtime limits (tests: started but incomplete ⚠️).
- Performed local compile+link verification of modified units as part of the build; no new compile errors reported (compile: ✅).
- Created an atomic local commit `8379965` with message `feat(mcp): expose index freshness and relation evidence`.

Signed-off-by: Codex <codex@openai.com>
…nce-feature

Report index & edge evidence, persist git head and file-coverage counts
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