Skip to content

fix: refresh graph freshness after no-op updates - #952

Closed
anusbutt wants to merge 1 commit into
tirth8205:stagingfrom
anusbutt:investigate/graph-freshness
Closed

anusbutt wants to merge 1 commit into
tirth8205:stagingfrom
anusbutt:investigate/graph-freshness

Conversation

@anusbutt

@anusbutt anusbutt commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a freshness inconsistency where successful incremental updates with zero structural graph changes could leave the stored Git SHA at the previous commit.

This created a contradiction where the update path reported the graph as up to date while get_minimal_context() still returned stale_graph.

What changed

  • Advance VCS freshness metadata after successful authoritative Git synchronization, even when zero graph mutations occur.
  • Keep explicit changed_files, watch batches, and non-authoritative bases conservative.
  • Do not advance freshness when discovery or parsing fails.
  • Return an error instead of "Graph is up to date" for incomplete incremental updates.
  • Add regression coverage for empty commits, zero-structural-change updates, explicit file lists, parse failures, and strict Git discovery.

Validation

  • 140 passed for incremental + Git integration tests
  • Full CI pytest: 2,990 passed, 9 skipped, 2 xpassed
  • Coverage: 85.02%
  • Ruff: passed
  • mypy: passed
  • Bandit: passed
  • git diff --check: passed

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.65 (MEDIUM) — 13 changed function(s)/class(es), 2 affected flow(s), 3 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.65 medium code_review_graph/incremental.py::_store_vcs_metadata code_review_graph/incremental.py:772 no
0.55 medium code_review_graph/incremental.py::get_changed_files code_review_graph/incremental.py:841 yes
0.55 medium code_review_graph/incremental.py::full_build code_review_graph/incremental.py:1273 yes
0.55 medium code_review_graph/incremental.py::incremental_update code_review_graph/incremental.py:1383 yes
0.30 low code_review_graph/tools/build.py::build_or_update_graph code_review_graph/tools/build.py:465 yes
0.30 low tests/test_integration_git.py::fail_parse tests/test_integration_git.py:588 no
0.15 low tests/test_integration_git.py::_graph_structure_snapshot tests/test_integration_git.py:448 yes
0.05 low tests/test_incremental.py::TestGitOperations tests/test_incremental.py:550 no
0.05 low tests/test_incremental.py::TestGitOperations.test_get_changed_files_strict_failure_does_not_fallback tests/test_incremental.py:579 (test)
0.05 low tests/test_integration_git.py::test_automatic_update_after_empty_commit_refreshes_freshness tests/test_integration_git.py:474 (test)

Affected execution flows

  • _run — criticality 0.36, 68 node(s) across 1 file(s)
  • process — criticality 0.35, 41 node(s) across 1 file(s)

Test gaps

  • code_review_graph/incremental.py::_store_vcs_metadata (code_review_graph/incremental.py:772)
  • tests/test_incremental.py::TestGitOperations (tests/test_incremental.py:550)
  • tests/test_integration_git.py::fail_parse (tests/test_integration_git.py:588)

Token savings: this graph-backed report used ~47,636 fewer tokens (~80%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

@tirth8205

Copy link
Copy Markdown
Owner

Integrated on integration/token-efficiency-hardening as 66309ec. Authoritative no-op synchronisation now advances the stored Git anchor after empty or unsupported-file commits, avoiding repeated stale-graph reports. Explicit batches and parse or discovery failures preserve the previous anchor, and the corresponding incremental and Git regressions passed.

tirth8205 added a commit that referenced this pull request Sep 13, 2026
The #952 port made any per-file parse error veto the freshness metadata
and only recorded the Git anchor on "authoritative" updates. Verified
consequences on the branch, all absent on main:

- a full build with one unparseable file stored no anchor, so every later
  update became a full rebuild;
- an incremental update with one failing file never advanced, so every
  later update re-diffed the same range and reported status=error;
- watch batches never recorded HEAD, so every query after a commit carried
  the stale-graph caveat and asked the agent to run update.

Record the anchor whenever files were stored or the authoritative no-op
sync confirmed HEAD (the #952 improvement), report failed files in the
build result (status "partial", named in the summary) and on the CLI's
stderr, and keep postprocessing for the files that did parse. Explicit
batches that store nothing still keep the old anchor.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016yGn8rDJSeJCRcRf4cmciH
tirth8205 added a commit that referenced this pull request Sep 13, 2026
Strict change discovery raises when the Git diff against the stored anchor
fails. The CLI caught that, but the MCP build tool let it escape as a bare
exception instead of the status/summary shape every other failure uses.
Catch it in the build tool and have the CLI treat an error status the way
it treated the exception: message on stderr, exit code 1.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016yGn8rDJSeJCRcRf4cmciH
@tirth8205
tirth8205 changed the base branch from main to staging September 15, 2026 13:10
@tirth8205

Copy link
Copy Markdown
Owner

Merged into staging through the integration PR #988 (merge commit 3030ca8). Your change is carried by commit 66309ec, which keeps you as the author (anusbutt). It will be promoted staging → testing → main and released from there. Thank you for the contribution! Closing this PR since its content is now on staging.

@tirth8205 tirth8205 closed this Sep 15, 2026
Bakul2006 pushed a commit to Bakul2006/code-review-graph that referenced this pull request Sep 15, 2026
…updates

Port the reviewed token-efficiency implementation with targeted regression coverage.

Source-PR: tirth8205#952
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.

2 participants