Repository navigation
Description
Description
When graphify extract <target> is invoked from a working directory inside a different git repository, the resulting graph.json (and therefore GRAPH_REPORT.md) records the invoking repo's HEAD as built_at_commit, not the target's.
This is the same cwd-anchoring mistake that #2316 fixed for watch/update — it survives in the extract path:
cli.py(extract flow) callsto_json(...)without passingbuilt_at_commit.export.py:to_jsonfalls back to a module-local_git_head()that runsgit rev-parse HEADwith nocwd, so it inherits the process working directory.clusterthen deliberately preserves the extract-time stamp (Four silent failures with success exit codes: cluster-only ignores --backend, label prompt collides with theCommunity {cid}sentinel,tree --root <abs>flattens the hierarchy, built_at_commit stamped from cwd #2534), so the wrong SHA is propagated intoGRAPH_REPORT.md's "Built from commit" line and kept on every subsequent re-cluster.
Impact
- The report's own staleness instruction ("run
git rev-parse HEADin the repo and compare") can never match — the stamped SHA does not exist in the repo the graph describes (git cat-file -e <sha>fails). - Batch-building several targets from one shell stamps the same foreign SHA into all of them, so unrelated repos appear to be "built from" one identical commit.
- Because Four silent failures with success exit codes: cluster-only ignores --backend, label prompt collides with the
Community {cid}sentinel,tree --root <abs>flattens the hierarchy, built_at_commit stamped from cwd #2534 keeps the extract-time stamp by design, the wrong provenance is permanent until a full re-extract.
Reproduction (deterministic, no API key needed)
mkdir A B
git -C A init && git -C A commit --allow-empty -m target
git -C B init && git -C B commit --allow-empty -m invoker
mkdir -p A/graphify-out
cd B
python - <<'EOF'
import json, networkx as nx
from graphify.export import to_json
G = nx.Graph(); G.add_node("n", label="n")
to_json(G, {0: ["n"]}, "../A/graphify-out/graph.json", force=True)
print(json.load(open("../A/graphify-out/graph.json"))["built_at_commit"])
EOF
git -C ../A rev-parse HEAD # expected value
git rev-parse HEAD # actual stamped value (invoker's HEAD)The stamped value is B's HEAD; it should be A's. The same happens end-to-end via graphify extract ../A run from inside B.
Expected
built_at_commit identifies the HEAD of the repository the graph describes, regardless of where the command was invoked from — matching the behavior watch/update already have since #2316.
Environment
Observed on 0.9.39 (uv tool install) and confirmed present on the current v8 tip (0.9.41, e4bfd2a) by code inspection: export.py _git_head() takes no cwd, and the extract-path to_json call passes no built_at_commit.
I have a fix with a regression test ready and can open a PR.
Activity
C0KERNEL commentedon Aug 13, 2026
Resolved.