Skip to content

fix(extract): reuse the saved graph during incremental extraction - #5528

Closed
rvitaliy wants to merge 1 commit into
Graphify-Labs:v8from
rvitaliy:fix/incremental-extract-reuse-graph
Closed

rvitaliy wants to merge 1 commit into
Graphify-Labs:v8from
rvitaliy:fix/incremental-extract-reuse-graph

Conversation

@rvitaliy

Copy link
Copy Markdown
Contributor

What does this PR do?

Reuse the saved graph snapshot for source pruning, recovery of manifest entries with missing output, and incremental AST resolution. An unchanged extraction skips building resolver context. Deletions and exclusions can still schedule surviving code for C++ forward-declaration and ID-collision reconciliation.

In a warm run over 5,152 unchanged inputs and a 65 MiB graph, graph.json went from three reads and JSON decodes to one. Instrumented read and decode time went from 0.82 s to 0.27 s in that sample. The run kept the saved graph intact.

Verification & Invariants

  • The regression test fails on the base branch and passes with the fix. It checks the read and decode count and compares graph bytes and modification time.
  • Existing tests cover excluded and deleted sources, missing-output recovery, changed-file calls into unchanged files, C++ forward groups, and ID collisions.
  • The resolver size check still gates context construction. Invalid saved JSON provides no source or resolver evidence, as before.

How was this tested?

uv run --frozen pytest tests/ -q --tb=short -n 6 -m 'not serial'
uv run --frozen pytest tests/ -q --tb=short -m serial
uv run --frozen ruff check .
uv run --frozen pyright --outputjson
uv run --frozen graphify update . --no-cluster

Pyright reports the same 782 diagnostics on the base and on this branch.

Fixes #5527

Reuse a single graph snapshot for source checks and avoid building resolver context when no sources need AST work.

Fixes Graphify-Labs#5527

Co-authored-by: Codex <[email protected]>
@rvitaliy
rvitaliy requested a review from safishamsi as a code owner November 26, 2026 23:20
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @rvitaliy. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Nov 26, 2026

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify review View in Graphify

Nothing blocking · 3 possible issues to check · Merge confidence 5/5

3 possible issues to check · High impact

Incremental extraction now loads the existing graph once and reuses it for stale-source checks and AST resolution context.

3 possible issues we couldn't confirm
  • Incremental and full-scan runs now load the whole graph.json before the size cap is checked, so an oversized graph can exhaust memory · graphify/cli.py:4707
  • The warm-run graph read check only counts Path.open calls on the exact resolved path, so a correct read can be missed and the test fails for · tests/test_extract_cli.py:1455
  • The no-rewrite check compares modification times, which coarse filesystem timestamps can leave unchanged after a rewrite · tests/test_extract_cli.py:1473

They don't change the score.

What this review covered
  • We didn't review 1 file that isn't source code, such as docs, config, images, or generated or third-party code.
  • 3 of 3 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 572 functions depend on this change
  • 1 function became more coupled. dispatch_command() (8 callers).
  • Gate, test list and every flagged function: in the Graphify check.

Reviewed 67917a9

@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.122, landed via authorship-preserving cherry-pick so your commits keep your name. Thanks @rvitaliy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Warm incremental extract reads and decodes graph.json three times

2 participants