Stamp graph.json with generated_at, warn on stale graphify query#1624
Open
edgestack-ai wants to merge 3 commits into
Open
Stamp graph.json with generated_at, warn on stale graphify query#1624edgestack-ai wants to merge 3 commits into
edgestack-ai wants to merge 3 commits into
Conversation
graph.json now records an ISO generated_at timestamp alongside the existing built_at_commit, written in export.to_json (the single chokepoint every build/update/watch path already funnels through). graphify query compares that stamp against the last commit time of the repo the graph indexes (resolved the same way build.py's _infer_merge_root already does, via the .graphify_root sidecar) and prints one warning line to stderr when the graph predates it. Missing or unreadable stamps (graphs built by an older graphify version) warn too, telling the caller to regenerate. Outside a git repo, or if git isn't available, the check is silently skipped rather than raising - query output is otherwise unchanged.
…eness Root-cause fix for the review round on the generated_at/staleness feature: 1. graph.json stamping was only in export.to_json(), so --no-cluster extract (__main__.py) and --no-cluster update (watch.py) wrote unstamped graphs that check_staleness could never flag. Extracted the stamping logic into one chokepoint, stamp_graph_metadata(), that every writer now calls. 2. check_staleness inferred the indexed repo's root from the graph file's own location, so a graph written via --out <elsewhere> could never be compared against the right repo. The root is now recorded IN the graph at write time (indexed_repo_root) and check_staleness prefers that, falling back to location-based inference only for legacy graphs that predate the field. 3. _canonical_graph_for_compare/_canonical_topology_for_compare (watch.py) now also exclude generated_at/indexed_repo_root from same-graph/topology comparisons, alongside the existing built_at_commit exclusion - required so the --no-cluster update path's "no changes, left untouched" detection keeps working now that every write is timestamped. Added coverage for all 3 reviewer repro cases: --no-cluster extract stamps (test_extract_cli.py), --no-cluster update stamps (test_watch.py), and --out-elsewhere staleness detection via the recorded root (test_export.py).
The merge-driver command wrote graph.json directly (__main__.py) bypassing stamp_graph_metadata() (d1692f4's chokepoint), so a merge-committed graph.json carried no generated_at/indexed_repo_root and check_staleness could never flag it as stale. merge-driver has no natural indexed-root argument - git invokes it as `graphify merge-driver %O %A %B` with three throwaway temp file paths, not the real graphify-out/graph.json location. Resolve the actual repo root via `git rev-parse --show-toplevel` (git runs merge drivers with cwd at the top of the work tree), falling back to the current side's previously recorded indexed_repo_root, then to cwd. Added tests/test_merge_driver_cli.py covering both the normal path and the outside-a-git-repo fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
export.to_json(the single write chokepoint every build/update/watch path funnels through) now stampsgenerated_at(ISO UTC) intograph.json's top level, alongside the existingbuilt_at_commit.graphify querycompares that stamp against the last commit time of the repo the graph indexes (resolved via the same.graphify_rootsidecar conventionbuild.py::_infer_merge_rootalready uses) and prints one warning line to stderr when the graph is older than the repo's latest commit.Test plan
uv run ruff check graphify/export.py graphify/__main__.py— cleanuv run pytest tests/test_export.py tests/test_query_cli.py tests/test_cli_export.py— 73 passeduv run pytest tests/— 2769 passed / 27 pre-existing failures (all Windows path-separator flakiness in unrelated tests, reproduced identically onv8HEAD without this change)[graphify] warning: graph.json was generated ... but the indexed repo's last commit is ... - graph is stale, run \graphify .` (or `graphify update`) to refresh` on stderr, confirmed a stamp-less graph produces a "no stamp, regenerate" warning, and confirmed no crash/warning outside a git repo.