Repository navigation
fix(watch): record a contended incremental request instead of dropping it (#4800) - #4802
Deepjyoti-Sarmah wants to merge 8 commits into
Conversation
|
Thanks for the pull request, @Deepjyoti-Sarmah. 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.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 4 advisory finding(s) below merit a look before merge.
Not checked: tests were not run; formal verification proved 0 of 4 changed function(s) (1 sampled, not proven, 3 not verified).
Formal verification. PR-changed functions: 1/4 verified (0 proven, 1 may-equivalent, 0 distinguished) · 3 not verified (1 vacuous, 2 unsupported).
Not verified on this run: dispatch\_command (vacuous: never exercised), detect\_incremental (unsupported), \_rebuild\_code (unsupported).
Graphify review — findings
Makes graphify update re-extract only files whose content differs from the manifest, so a warm tree costs what changed instead of the whole corpus; --force and a missing, unreadable or empty manifest still take the full path. Adds a third .pending_incremental marker alongside .pending_changes and .pending_full, so an incremental request that loses the lock is queued rather than dropped, and the lock holder's drain now has to pick between full, incremental and explicit-path passes. Extracts classify_manifest_deletions out of detect_incremental to split vanished manifest rows into deleted (gone from disk) and excluded (still on disk but out of scan), with resolution inputs counted as scanned.
Worth a look
- Blocking full-rebuild request downgraded to incremental by a queued incremental marker —
graphify/watch.py:2051· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
- Queued incremental marker is consumed and dropped when the lock holder has explicit changed_paths —
graphify/watch.py:2045· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
- Root containment check accepts '..' paths outside the root —
graphify/detect.py:3095· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
- absolute_identity is called before the falsy source_file guard, so None or empty paths are no longer short-circuited —
graphify/watch.py:2516· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 4039 functions depend on the 408 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_rebuild_code()— 228 callers, 70 callees - worse:
load_manifest()— 17 callers, 5 callees - worse:
classify_manifest_files()— 4 callers, 5 callees
Verification — 4039 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: 2543 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
121 of 467 test file(s) selected (26%) via static blast radius.
tests/test_affected_cli.py— impacttests/test_agents_platform.py— impacttests/test_astro_extraction.py— impacttests/test_atomic_writes.py— impacttests/test_backend_opt_in.py— impacttests/test_binary_media_words.py— impacttests/test_build.py— impacttests/test_cache_stale_import_target.py— impacttests/test_cargo_introspect.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_cjs_module_extension.py— impacttests/test_claude_cli_backend.py— impacttests/test_cli_export.py— impacttests/test_cloud_cta.py— impacttests/test_codebuddy.py— impacttests/test_compact_graph_json.py— impacttests/test_dedup_shrink_refuses_force_write.py— impacttests/test_detect.py— impacttests/test_devin.py— impacttests/test_docx_to_markdown.py— impacttests/test_dotnet.py— impacttests/test_ejs_extractor.py— impacttests/test_elixir_import_resolution.py— impacttests/test_elixir_qualified_calls.py— impacttests/test_elixir_unqualified_call_scope.py— impacttests/test_evidence_binding.py— impacttests/test_explain_cli.py— impacttests/test_explain_same_file_tie.py— impacttests/test_export_direction.py— impacttests/test_ext_tagged_id_clash.py— impacttests/test_external_stub_endpoints.py— impacttests/test_extract.py— impacttests/test_extract_cli.py— impacttests/test_extract_cost_ledger.py— impacttests/test_file_slice.py— impacttests/test_file_truncation_warning.py— impacttests/test_global_add_tag_inference.py— impacttests/test_god_nodes_cli.py— impacttests/test_hollow_chunks_arm_shrink_guard.py— impacttests/test_hook_guard_token_match.py— impacttests/test_hook_nudge_wording.py— impacttests/test_hook_out_of_project_paths.py— impacttests/test_hook_strict.py— impacttests/test_ignore_file_encoding.py— impacttests/test_image_vision.py— impacttests/test_import_extension_resolution.py— impacttests/test_incomplete_build_guard.py— impacttests/test_incremental_mtime_collision.py— impacttests/test_incremental_unscanned_placeholders.py— impact- … and 71 more
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Docs that may be stale (advisory)
graphify/skill-agents.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 626-735): references changed symbols_corpusgraphify/skill-aider.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 706-788): references changed symbols_corpusgraphify/skill-amp.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 626-735): references changed symbols_corpusgraphify/skill-claw.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 629-738): references changed symbols_corpusgraphify/skill-codex.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 630-739): references changed symbols_corpusgraphify/skill-copilot.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 629-738): references changed symbols_corpusgraphify/skill-devin.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 824-907): references changed symbols_corpusgraphify/skill-droid.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 626-735): references changed symbols_corpusgraphify/skill-kilo.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 629-738): references changed symbols_corpusgraphify/skill-kiro.md§ Step 9 - Save manifest, update cost tracker, clean up, and report (lines 629-738): references changed symbols_corpus
…and 10 more.
Formal verification
Could not verify: Could not verify dispatch\_command.
The verifier did not have enough to check dispatch\_command, 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: no capturable inputs from the test suite; property tier: not verifiable: all 40 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly SystemExit — names the real obstacle, not a sampling gap)
Could not verify: Could not verify detect\_incremental.
The verifier did not have enough to check detect\_incremental, 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: no capturable inputs from the test suite; property tier: nondeterministic output (both versions disagreed with themselves on the witness) — not a behaviour change; a function whose output is not a function of its inputs (random / time / uuid / os.urandom, or state carried across calls) cannot be soundly distinguished by execution, so this tier abstains for the whole function
No difference found (not proven): No behavior difference found in \_queue\_pending\_full (not a proof).
The verifier ran both versions of \_queue\_pending\_full on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
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: no capturable inputs from the test suite; property tier: nondeterministic output (both versions disagreed with themselves on the witness) — not a behaviour change; a function whose output is not a function of its inputs (random / time / uuid / os.urandom, or state carried across calls) cannot be soundly distinguished by execution, so this tier abstains for the whole function
· 3 more finding(s) on lines outside this diff (see the check run).
…g it An incremental rebuild derives its change set from the manifest inside the lock, so it names no paths and had nothing to append to .pending_changes, while .pending_full would have meant "re-extract everything". Losing the lock therefore dropped the request, and the False it returned was indistinguishable from the "queued, it will run" answer a caller gets for the other two kinds. This is latent rather than an incident: no non-blocking incremental caller exists today, because the CLI blocks on the lock and the watcher and hooks pass explicit paths. The fix completes the design. The request is now recorded as a .pending_incremental marker, and any holder that drains it runs an incremental pass, including a holder whose own request was a full one. Reported by review on Graphify-Labs#4769. Fixes the latent drop for Graphify-Labs#4769's incremental kind.
9ce7e72 to
10f9321
Compare
|
Landed in 0.9.102 (published to PyPI), cherry-picked with your authorship preserved (the three unique commits on top of #4801). Thanks @Deepjyoti-Sarmah. |
What does this PR do?
Part of #4800, stacked on #4801. That PR gives
graphify updatea change set derivedfrom the manifest. A request built that way names no paths, and this PR is what
happens when such a request loses the per-repo lock.
_rebuild_codeasks for the lock before it does anything. If another rebuild holdsit, each request kind records what it could not do so the holder can run it later:
The derived kind has no path list to append and cannot use
.pending_full: the drainruns after the lock it just won, so a full marker would upgrade its own incremental
pass. So it recorded nothing, printed "nothing to queue", and returned
False, whichis the same answer a caller gets when its change set was recorded and will run.
The review bot on #4801 flags this at
graphify/watch.py:1979, rated high. This PRcloses that finding.
An explicit
changed_pathsstill wins, and.pending_fullstill wins overeverything. The late-arrival loop drains the third marker too and breaks only when
all three records are empty.
Three commits
The first is pure coverage of the contract that already holds for the other two kinds
(
.pending_full/.pending_changessemantics, and a caller that wins the lock notupgrading itself). It passes on the base branch. The second adds the marker, the
wiring and the tests for it, in one commit, so a revert removes the behaviour and its
tests together. The third updates comments that described two kinds.
The contract the tests pin
tests/test_update_lock_contention.py, six tests, real lock and real queue files, nomonkeypatching. Contention is created by holding the lock in-process;
flockis peropen file description, so a second open in the same process conflicts:
I3 is the one worth reading. The call that ends up doing the work asks for the
default pass, which is a full one, so a single re-extracted file can only come from
the winner's own drain honouring the marker. Calling
_rebuild_code(incremental=True)again and calling that "honoured" would be the test re-asking, which proves nothing
about the queue.
No sleeps. Content changes carry an explicit
os.utimebump, so nothing depends onfilesystem timestamp granularity.
Type of change
Verification & Invariants
A request that loses the lock must either leave something the holder can act on, or
tell its caller it was not served. It must not return the same
Falsethat means"queued and will run".
Merge Danger
Door: two-way. One new marker file under
graphify-out/and the drain that readsit. Reverting the middle commit removes the behaviour and its tests together.
Blast Radius: narrow, and limited to builds that lose the lock:
another process is now honoured: the winner runs an incremental pass rather than a
full one when no explicit paths and no full marker are present.
.pending_fullstill wins over everything, and an explicitchanged_pathsstillwins over the derived set.
write-before-lock order is deliberate and unchanged: reversing it broke
tests/test_watch.py::test_rebuild_code_empty_change_set_does_not_claim_queued(Full-corpus rebuild requests are dropped on lock contention (log says "changes queued"), and a full rebuild never drains late incremental work #4274) in an earlier attempt at this area.
content diff, so it is cheap and it cannot miss work.
Limitations
caller exists today:
graphify updateblocks on the lock, and the watcher and thehooks pass explicit paths, so they use
.pending_changes. The hole opens the daysomething calls
_rebuild_code(incremental=True)without blocking, which is areasonable thing to add later.
the winner's own request was a full one. That is the intended semantics (a queued
incremental request has to be honoured), and it is what I3 pins. A full request
still wins if
.pending_fullis also present.as it does today: the request is dropped. Nothing breaks.
test_i4_a_queued_full_marker_still_upgrades_a_blocking_incremental_callerqueues amarker and expects a full pass, but the gate runs before the drain, so an untouched
tree returns at the gate and never reaches the queue. It now carries one change
first, the same way
test_default_is_the_full_pathin perf(update): re-extract only the files whose content changed (#4800) #4801 does. The assertion isunchanged.
How was this tested?
Red on the base branch, for the intended reason:
Green with the fix, including the mutation check. Removing the marker write from
commit 2 puts both I1 tests back to red, which is how I know they are not vacuous:
8895 is #4801's 8889 plus the six tests here. The suite ran with
PYTHONPATHset tothe repo, so the tests that shell out via
sys.executable -m graphifyload this treerather than the installed package.
Diffstat against the base branch:
Not tested: Windows. The marker uses the same
Path.touch()/unlink()pattern asthe two existing records.
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (N/A: no skill fragments touched.)