Skip to content

fix(watch): refuse shrink after extractor failure (#2660) - #2663

Closed
ousamabenyounes wants to merge 1 commit into
Graphify-Labs:v8from
ousamabenyounes:fix/issue-2660
Closed

ousamabenyounes wants to merge 1 commit into
Graphify-Labs:v8from
ousamabenyounes:fix/issue-2660

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Contributor

Why

A full rebuild treated every node lost from a rebuilt source as an expected symbol deletion. When an extractor failed, that accounting allowed a smaller graph to overwrite the last good graph while reporting success.

Fixes #2660.

What changed

  • Track failed AST sources separately from successfully rebuilt sources.
  • Refuse a net shrink when any lost node belongs to a failed source.
  • Cover both clustered and --no-cluster rebuild paths, including preservation of the existing graph.

Why it is safe

Successful rebuilds and explicit deletions keep their existing accounting. The new refusal applies only when extraction already reported that the affected source failed.

Test verification (RED → GREEN)

Upstream v8 with only the new integration regression:

FAILED tests/test_watch.py::test_rebuild_refuses_loss_from_failed_source[False]
FAILED tests/test_watch.py::test_rebuild_refuses_loss_from_failed_source[True]
E   assert True is False
[graphify watch] graph.json updated
2 failed in 0.98s

Patched branch:

tests/test_watch.py: 121 passed, 2 skipped
Python changed-line coverage: 5/5 executable changed statements covered

Full local CI replay on Python 3.12 and 3.10 remained iso-better than upstream:

upstream: 2 failed, 4305 passed, 3 skipped
patched:  2 failed, 4308 passed, 3 skipped

The two unchanged failures are existing v8 failures in hidden-directory collection and the Unicode normalization property test. Skill generation checks, install smoke, and Ruff also passed.

@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 reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

This PR adds a failed_sources parameter to the shrink-guard logic in graphify/watch.py. During a full rebuild, sources whose AST extraction failed are now tracked and passed to _check_shrink, where their nodes are excluded from being "accounted for" as expected deletions — so a failed extractor no longer counts its dropped nodes as legitimate symbol removals and can no longer overwrite the previous graph. The change also wires failed_sources through both write paths in _rebuild_code (clustered and non-clustered), adds a CHANGELOG entry (#2660), and adds tests covering the new _check_shrink behavior and an end-to-end _rebuild_code scenario where a SQL extractor is made to fail. The surface area is limited to the watch/rebuild shrink-protection path and its tests.

No blocking issues surfaced. 2 lower-confidence candidates did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 662 functions depend on the 512 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: _rebuild_code() — 95 callers, 51 callees

Verification — 662 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 523 function(s) in the blast radius were not formally verified this run

Formal verification

Could not verify: Could not verify \_check\_shrink.

The verifier did not have enough to check \_check\_shrink, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: parameter `tmp` is annotated `'Path | None'` — outside the synthesizable primitive/collection set

Could not verify: Could not verify \_rebuild\_code.

The verifier did not have enough to check \_rebuild\_code, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: parameter `watch_path` is annotated `Path` — outside the synthesizable primitive/collection set

· 1 more finding(s) on lines outside this diff (see the check run).

@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.41 (graphifyy==0.9.41 on PyPI) (#2660). Credited in the release notes. Thanks @ousamabenyounes!

@safishamsi safishamsi closed this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants