Repository navigation
Conversation
Running extract against a target from another repo's working directory stamped the invoker's HEAD into the target's graph.json: the extract write path never passed built_at_commit, so to_json's fallback ran git rev-parse HEAD in the process cwd. cluster then preserves the extract-time stamp by design (#2534), so GRAPH_REPORT.md's 'Built from commit' line can name a commit that does not exist in the repo it describes, and the staleness comparison the report suggests can never match. Batch-building several targets from one shell stamps the same foreign SHA into all of them. Same cwd-anchoring mistake #2316 fixed for watch/update, surviving in the extract path. Fix both layers: extract now passes the target's HEAD explicitly, and to_json's fallback asks the repo containing output_path instead of the cwd.
There was a problem hiding this comment.
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. 1 change(s) tested, no difference found (not proven).
Graphify review — findings
This PR changes how git commit provenance is determined when writing a graph's graph.json. It adds an optional cwd parameter to export._git_head() so callers can specify which repository to query, and updates to_json()'s fallback to derive the commit from the output path's repo rather than the shell's current working directory. The CLI's extract dispatch path is also updated to explicitly stamp the target repo's HEAD, and a new test verifies the fallback uses the output repo's commit rather than the invoking repo's. The surface area touches graphify/cli.py (extract dispatch), graphify/export.py (_git_head signature and to_json fallback), and adds one test in tests/test_export.py. The diff also references a large set of renamed/reorganized symbols across these files.
No blocking issues surfaced. 2 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 566 functions depend on the 194 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
to_json()— 44 callers, 6 callees
Verification — 566 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 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: not verifiable: all 23 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 \_git\_head.
The verifier did not have enough to check \_git\_head, 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 `cwd` is annotated `'str | Path | None'` — outside the synthesizable primitive/collection set
No difference found (not proven): No behavior difference found in to\_json (not a proof).
The verifier ran both versions of to\_json 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.
· 1 more finding(s) on lines outside this diff (see the check run).
Fixes #2696.
graphify extract <target>run from another repo's working directory stamps the invoker's HEAD into the target'sgraph.json: the extract write path never passesbuilt_at_commit, soto_json's fallback runsgit rev-parse HEADin the process cwd.clusterthen preserves the extract-time stamp by design (#2534), soGRAPH_REPORT.md's "Built from commit" line can name a commit that does not exist in the repo it describes, and the staleness comparison the report suggests can never match. Batch-building several targets from one shell stamps the same foreign SHA into all of them.This is the same cwd-anchoring mistake #2316 fixed for
watch/update, surviving in the extract path. The fix closes both layers:cli.py(extract): passbuilt_at_commitexplicitly, derived from the target via the cwd-awarewatch._git_head(cwd=target).export.py: give the module-local_git_headthe samecwdparameterwatch's has (update writes manifest.json to the CWD instead of the target — cross-project contamination, and the target gets no manifest #2316), and anchorto_json's fallback on the directory the graph is written into (output_pathlives in<target>/graphify-out/) rather than the shell's cwd — so any other caller that omitsbuilt_at_commitalso gets correct provenance.Test
tests/test_export.py::test_to_json_commit_fallback_uses_output_repo_not_cwd— builds two throwaway repos, chdirs into one, writes a graph into the other, and asserts the stamp is the target repo's HEAD. Fails before the patch (stamps the invoker), passes after.uv run pytest tests/ -q: 4253 passed, 42 skipped; the 5 failures (test_ollama_retry_cap.py×4,test_labeling.py::test_label_communities_batches_when_over_batch_size) are pre-existing on the untouchedv8tip and unrelated.