feat(mcp): expose index freshness and relationship provenance#544
Open
vvenegasv wants to merge 2 commits into
Open
feat(mcp): expose index freshness and relationship provenance#544vvenegasv wants to merge 2 commits into
vvenegasv wants to merge 2 commits into
Conversation
### 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
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.
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:
index_statuswith additive evidence about indexed/current revisions, working tree state, freshness, coverage, and known limitations.edge_evidencefromtrace_pathandtrace_call_pathwhen relationship provenance is available.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
git commit -s)make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)