Skip to content

fix(detect): drop a previous checkout's absolute manifest keys - #4175

Closed
SrijanSriv wants to merge 2 commits into
Graphify-Labs:v8from
SrijanSriv:fix/3581-reclone-manifest
Closed

SrijanSriv wants to merge 2 commits into
Graphify-Labs:v8from
SrijanSriv:fix/3581-reclone-manifest

Conversation

@SrijanSriv

@SrijanSriv SrijanSriv commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

A re-clone must not keep absolute manifest keys that point at the previous checkout.

save_manifest drops a row when Path(f).exists() is false, so a move is already clean. A re-clone copies graphify-out/ while the old checkout is still on disk, so that check keeps the old absolute keys. The scan prune then skips them because _in_root is false, and _to_relative_for_storage writes them absolute again. They never share a stored key with the new relative rows, so both halves stay. The drop runs only when scan_corpus is set. A subset save omits it and keeps every live out-of-root row (#917).

_previous_checkout_absolute_keys drops a group only when _to_relative_for_storage would keep the keys absolute, at least two of them share one directory prefix, and each path under that prefix is a relative key this save writes. The longest suffix wins, so src/c.py beats c.py. save_manifest calls it only when scan_corpus is set, after the exists check and before the #1908 scan prune. A row that relativizes into the storage root is not a candidate, so a sibling directory from #3785 stays.

Related to #3581. This does not use a closing keyword. Part 2 of that issue, graph.json after --force, is not in this diff. #3583 is a different path spelling and is not touched.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Tests or CI
  • Refactor
  • Security fix

Verification & Invariants

  • Read the CONTRIBUTING.md guide.

  • Reproduced the issue and identified the invariant.

  • Made the smallest fix necessary.

  • Added a regression test (if bug fix) or isolated boundary test.

  • Kept the PR description synchronized with the final implementation.

  • Documented any limitations / unsupported cases explicitly.

  • Reproduced on v8 at 5c7b847: uv run pytest tests/test_detect.py::test_save_manifest_reclone_drops_other_checkout_when_scan_corpus_is_set tests/test_detect.py::test_save_manifest_drops_other_checkout_keys_mixed_with_relative_keys -q failed. The manifest had six keys. Extra items were the absolute paths of a.py, b.py, and src/c.py under checkout-a.

  • Follow-up on 3a05b3b: uv run pytest tests/test_detect.py::test_save_manifest_subset_save_keeps_other_checkout_absolute_keys tests/test_detect.py::test_save_manifest_subset_save_keeps_includes_that_share_basenames -q failed. The subset save left only a.py, b.py, and src/c.py. The include pair a.py and b.py outside the root was gone.

  • Decoy: one include row named a.py, while the project also has a.py, stays absolute. Two include rows, notes.md and extra.md, stay when those suffixes are not relative keys this save writes. A subset save that restamps a.py and b.py keeps two include rows with those same names. A fix that drops every absolute key, or every shared file name, or every out-of-root row on a subset save, fails one of those tests. test_save_manifest_full_scan_keeps_out_of_root_rows still passes.

  • Left alone: the exists check that already cleans a move, _to_relative_for_storage, _manifest_storage_anchor, graph.json, and --force.

  • Limitations: one absolute key alone stays, because it cannot be told apart from one include row. On a full scan, two include rows whose paths under one outside directory equal relative keys of this project are dropped. Pass those files in files on each full scan if they must stay. A subset save keeps them.

How was this tested?

Python 3.12.12 and Python 3.13.3. Python 3.10 is not installed here.

uv run pytest tests/test_detect.py::test_save_manifest_reclone_drops_other_checkout_when_scan_corpus_is_set tests/test_detect.py::test_save_manifest_reclone_drops_other_checkout_when_scan_corpus_is_unset tests/test_detect.py::test_save_manifest_drops_other_checkout_keys_mixed_with_relative_keys -q
# before the fix, on v8 at 5c7b847: FAILED
# assert {'/private/var/.../checkout-a/a.py', '.../b.py', '.../src/c.py', 'a.py', 'b.py', 'src/c.py'} == {'a.py', 'b.py', 'src/c.py'}

uv run pytest tests/test_detect.py::test_save_manifest_subset_save_keeps_other_checkout_absolute_keys tests/test_detect.py::test_save_manifest_subset_save_keeps_includes_that_share_basenames -q
# on 3a05b3b, before the subset-save gate: FAILED
# subset save left {'a.py', 'b.py', 'src/c.py'} and dropped the include pair

uv run pytest tests/test_detect.py::test_save_manifest_reclone_drops_other_checkout_when_scan_corpus_is_set tests/test_detect.py::test_save_manifest_subset_save_keeps_other_checkout_absolute_keys tests/test_detect.py::test_save_manifest_subset_save_keeps_includes_that_share_basenames tests/test_detect.py::test_save_manifest_move_has_no_absolute_key_when_scan_corpus_is_set tests/test_detect.py::test_save_manifest_move_has_no_absolute_key_when_scan_corpus_is_unset tests/test_detect.py::test_save_manifest_drops_other_checkout_keys_mixed_with_relative_keys tests/test_detect.py::test_save_manifest_keeps_one_include_that_shares_a_basename tests/test_detect.py::test_save_manifest_keeps_includes_whose_paths_are_not_this_tree tests/test_detect.py::test_save_manifest_full_scan_keeps_out_of_root_rows tests/test_detect.py::test_save_manifest_subset_save_preserves_untouched_rows -q
# after the gate: 10 passed

uv run pytest tests/test_detect.py -q
# after the fix, Python 3.12.12: 293 passed

uv run ruff check graphify/detect.py tests/test_detect.py
# All checks passed

uv run pyright graphify/detect.py
# 9 errors, 3 warnings, all on existing lines
# the new helpers are not in that list

Graphify-specific checklist

  • I updated generated skill artifacts (uv run python -m tools.skillgen --bless) when changing their source fragments.
  • I confirmed that AST/structural extraction remains deterministic (no ambient state dependencies like ENV variables).
  • I reviewed changes for security implications (no unsafe interpolation into shell/Python).
  • I confirmed no API keys or local-only graph data are included.
  • (If applicable) I disclosed AI authorship in my commit messages.

A re-clone copies graphify-out while the old checkout is still on disk, so those absolute rows survive Path.exists() and never collapse into the new relative keys.
@SrijanSriv
SrijanSriv requested a review from safishamsi as a code owner October 6, 2026 19:36
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Thanks for the pull request, @SrijanSriv. 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.

@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.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.


Graphify review — findings

Makes save_manifest drop absolute keys left over from a previous checkout when a graphify-out directory is copied into a fresh clone (#3581). _previous_checkout_absolute_keys groups absolute keys by the longest existing-directory prefix whose remainder matches a relative key the current save writes. Groups of two or more are discarded whether or not scan_corpus is passed, while a lone match stays as an include row and nothing is pruned when root is unset.

Worth a look

  • save_manifest now prunes out-of-root absolute rows even for subset saves — graphify/detect.py:2645 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 3011 functions depend on the 601 functions this change touches.

Health — this change adds coupling hotspots:

  • new: extract() — 778 callers, 50 callees
  • new: _rebuild_code() — 149 callers, 56 callees
  • new: detect() — 121 callers, 16 callees
  • new: save_manifest() — 47 callers, 15 callees
  • new: _extract_generic() — 18 callers, 31 callees
  • new: extract_js() — 87 callers, 4 callees
  • new: extract_files_direct() — 17 callers, 20 callees
  • new: extract_xaml() — 19 callers, 17 callees
  • …and 56 more — each is listed as a finding

Verification — 3011 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: 1118 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

64 of 334 test file(s) selected (19%) via static blast radius.

  • tests/test_astro_extraction.py — impact
  • tests/test_atomic_writes.py — impact
  • tests/test_build.py — impact
  • tests/test_cargo_introspect.py — impact
  • tests/test_charmap_encoding.py — impact
  • tests/test_chunking.py — impact
  • tests/test_cjs_module_extension.py — impact
  • tests/test_claude_cli_backend.py — impact
  • tests/test_cpp_nested_and_cli.py — impact
  • tests/test_detect.py — impact, changed-test
  • tests/test_docx_to_markdown.py — impact
  • tests/test_dotnet.py — impact
  • tests/test_evidence_binding.py — impact
  • tests/test_extract.py — impact
  • tests/test_extract_cli.py — impact
  • tests/test_extract_php_closures.py — impact
  • tests/test_file_slice.py — impact
  • tests/test_file_truncation_warning.py — impact
  • tests/test_ignore_file_encoding.py — impact
  • tests/test_image_vision.py — impact
  • tests/test_import_extension_resolution.py — impact
  • tests/test_incremental_mtime_collision.py — impact
  • tests/test_indirect_call_block_scoped_shadow.py — impact
  • tests/test_indirect_dispatch.py — impact
  • tests/test_indirect_dispatch_assign_return.py — impact
  • tests/test_indirect_dispatch_getattr.py — impact
  • tests/test_js_exported_scalar_bindings.py — impact
  • tests/test_languages.py — impact
  • tests/test_llm_backends.py — impact
  • tests/test_long_path_hashing.py — impact
  • tests/test_manifest_ingest.py — impact
  • tests/test_markdown_code_spans.py — impact
  • tests/test_mcp_ingest.py — impact
  • tests/test_multilang.py — impact
  • tests/test_non_regular_files.py — impact
  • tests/test_office_incremental.py — impact
  • tests/test_office_limits.py — impact
  • tests/test_ollama.py — impact
  • tests/test_out_dir_evidence.py — impact
  • tests/test_oversized_document_slicing.py — impact
  • tests/test_package_json_subpath_imports.py — impact
  • tests/test_pdf_extra_warning.py — impact
  • tests/test_pdf_slicing.py — impact
  • tests/test_pdf_token_estimate.py — impact
  • tests/test_phantom_external_import.py — impact
  • tests/test_pipeline.py — impact
  • tests/test_python_underscore_resolution.py — impact
  • tests/test_rationale.py — impact
  • tests/test_ruby_resolution.py — impact
  • tests/test_scala_context_bounds.py — impact
  • … and 14 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.

· 1 grounded finding(s) anchored inline below; 63 more finding(s) on lines outside this diff (see the check run).

Comment thread graphify/detect.py Resolved
A hook that omits scan_corpus was dropping include rows whose names matched the files it restamped. The previous-checkout drop now runs only when scan_corpus is set.
safishamsi pushed a commit that referenced this pull request Oct 7, 2026
A re-clone that copies graphify-out/ while the old checkout is still on disk
left absolute manifest keys pointing at the old path, which survived the
exists()/in-root prune and persisted alongside the new relative keys. On a full
scan, drop stale absolute keys that duplicate a freshly-written relative key
under a real shared directory prefix.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
filipechagas added a commit to lawnstarter/graphify that referenced this pull request Oct 7, 2026
* upstream/v8: (184 commits)
  release: 0.9.80 — include Graphify-Labs#4195, Graphify-Labs#4198
  feat(python): resolve obj.method() through an annotated/constructor-bound local (Graphify-Labs#4198)
  perf(extract): resolve and parse each path once in the id remap and call tie-break
  release: 0.9.80
  fix(deps): raise tree-sitter runtime floor to >=0.25 for ABI 15 grammars (Graphify-Labs#4148)
  fix(build): give --no-cluster graph.json the same endpoint rules as build_from_json
  fix(watch): keep extract()'s run-only keys out of --no-cluster graph.json
  fix(watch): drop an external import stub once no edge references it
  fix(detect): drop a previous checkout's absolute manifest keys (Graphify-Labs#4175)
  fix(python): keep TYPE_CHECKING-only imports out of import cycles (Graphify-Labs#3159)
  fix(python): resolve self.<attr>.<method>() calls through the attribute's constructor type (Graphify-Labs#2860)
  fix(cache): treat an AST hit whose import target is gone as a miss
  fix(extract): preserve cross-drive syntax warnings
  fix(extract): let the Windows console script use the extraction pool
  fix(resolution): keep re_exports from both files whose ids collide
  fix(markdown): resolve links to file names that contain a space
  fix(java): capture methods and calls inside anonymous class bodies
  test: skip optional-extra tests when the extra is not installed (Graphify-Labs#4190)
  fix(serve): show the graph's build commit in graph_stats
  perf(serve): build the MCP traversal view and shortest-path graphs once per graph
  ...

# Conflicts:
#	CHANGELOG.md
#	graphify/extract.py
#	graphify/extractors/engine.py
#	graphify/serve.py
#	pyproject.toml
#	uv.lock
filipechagas added a commit to lawnstarter/graphify that referenced this pull request Oct 7, 2026
* upstream/v8: (184 commits)
  release: 0.9.80 — include Graphify-Labs#4195, Graphify-Labs#4198
  feat(python): resolve obj.method() through an annotated/constructor-bound local (Graphify-Labs#4198)
  perf(extract): resolve and parse each path once in the id remap and call tie-break
  release: 0.9.80
  fix(deps): raise tree-sitter runtime floor to >=0.25 for ABI 15 grammars (Graphify-Labs#4148)
  fix(build): give --no-cluster graph.json the same endpoint rules as build_from_json
  fix(watch): keep extract()'s run-only keys out of --no-cluster graph.json
  fix(watch): drop an external import stub once no edge references it
  fix(detect): drop a previous checkout's absolute manifest keys (Graphify-Labs#4175)
  fix(python): keep TYPE_CHECKING-only imports out of import cycles (Graphify-Labs#3159)
  fix(python): resolve self.<attr>.<method>() calls through the attribute's constructor type (Graphify-Labs#2860)
  fix(cache): treat an AST hit whose import target is gone as a miss
  fix(extract): preserve cross-drive syntax warnings
  fix(extract): let the Windows console script use the extraction pool
  fix(resolution): keep re_exports from both files whose ids collide
  fix(markdown): resolve links to file names that contain a space
  fix(java): capture methods and calls inside anonymous class bodies
  test: skip optional-extra tests when the extra is not installed (Graphify-Labs#4190)
  fix(serve): show the graph's build commit in graph_stats
  perf(serve): build the MCP traversal view and shortest-path graphs once per graph
  ...

# Conflicts:
#	CHANGELOG.md
#	graphify/extract.py
#	graphify/extractors/engine.py
#	graphify/serve.py
#	pyproject.toml
#	uv.lock
@safishamsi

Copy link
Copy Markdown
Member

Thanks for this, @SrijanSriv. This same fix already landed earlier (released in 0.9.80), so the manifest-key detection you add is present on the default branch. Closing as already shipped. Your other PRs in this batch did land in 0.9.87.

@safishamsi safishamsi closed this Oct 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

Development

Successfully merging this pull request may close these issues.

2 participants