Skip to content

fix(watch): rebuild the full corpus when graph.json is missing - #5021

Closed
azizur100389 wants to merge 1 commit into
Graphify-Labs:v8from
azizur100389:codex/recover-missing-graph
Closed

azizur100389 wants to merge 1 commit into
Graphify-Labs:v8from
azizur100389:codex/recover-missing-graph

Conversation

@azizur100389

@azizur100389 azizur100389 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5016.

What does this PR do?

With no source changes, update exits successfully without recreating the file. With one changed source, it creates a graph containing only that source. The manifest identifies changed bytes but cannot supply unchanged nodes and edges.

The manifest-derived incremental path now requires an existing graph.json. The existing full rebuild path handles a missing graph, including the case where one source also changed. The guard applies to the manifest-derived graphify update path.

Reproduction

  1. Put def first(): return 1 in first.py and def second(): return 2 in second.py in a clean directory.
  2. Run graphify update . --no-cluster.
  3. Delete only graphify-out/graph.json. Leave graphify-out/manifest.json in place.
  4. Run the same update again. Repeat after changing just first.py.

Verification

  • uv sync --all-extras --frozen on Python 3.12.
  • python -m pytest -q --tb=short tests/test_update_missing_graph.py — 2 passed. The new failure cases reproduce on unchanged v8 at 59b5ab11.
  • python -m ruff check ., python -m pre_commit run --all-files, and all five python -m tools.skillgen checks passed.
  • GitHub CI passed on Python 3.10, 3.12, 3.13 and 3.14 with 9994 tests passed per version, 20 built-in skips and one expected failure. The 20 Bun Pi guard tests and CLI install smoke checks passed.
  • Fresh wheel installation, CLI help, skill install and AST-only graph update passed on Windows. Pyright, Bandit, pip-audit and native Bun results match clean v8.
  • Full Windows Python 3.12 suite: 9825 passed, 30 failed, 159 built-in skips and one expected failure. Clean v8 reproduced 29 failing test IDs. The additional test stopped at a transient git add error before running its post-commit hook. It passed in isolation on clean v8 and all three affected branches.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

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

@azizur100389
azizur100389 marked this pull request as ready for review November 5, 2026 11:14

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

Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).

Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 unsupported).

Not verified on this run: \_rebuild\_code (unsupported).


Graphify review — findings

Fixes _rebuild_code rebuilding only the changed files when graph.json is missing but manifest.json survives, which dropped every unchanged node from the recreated graph. The manifest-driven incremental path now runs only when graph.json exists, and otherwise falls through to the full extraction, so a deleted graph is rebuilt from all sources. The guard sits on the manifest-derived branch, so a caller that passes changed_paths directly still goes down the incremental path without the check.

Worth a look

  • Missing-graph guard skipped when caller supplies changed_paths — graphify/watch.py:2420 · Escalate · medium
    • NOT verified (no proof, no reproducing execution) — needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 713 functions depend on the 123 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: _rebuild_code() — 254 callers, 73 callees

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

Test selection

Test selection

37 of 519 test file(s) selected (7%) via static blast radius.

  • tests/test_cache_stale_import_target.py — impact
  • tests/test_code_only_scope_4923.py — impact
  • tests/test_compact_graph_json.py — impact
  • tests/test_csharp_method_owner_labels.py — impact
  • tests/test_elixir_import_resolution.py — impact
  • tests/test_elixir_qualified_calls.py — impact
  • tests/test_elixir_unqualified_call_scope.py — impact
  • tests/test_export_direction.py — impact
  • tests/test_external_stub_endpoints.py — impact
  • tests/test_go_receiver_member_calls.py — impact
  • tests/test_incremental_unscanned_placeholders.py — impact
  • tests/test_java_member_calls.py — impact
  • tests/test_kotlin_grammar.py — impact
  • tests/test_labeling.py — impact
  • tests/test_language_override_lifecycle.py — impact
  • tests/test_linked_worktree_reconcile.py — impact
  • tests/test_lost_saved_semantic_nodes.py — impact
  • tests/test_markdown_code_spans.py — impact
  • tests/test_no_cluster_undeclared_endpoints.py — impact
  • tests/test_pr10_watch_overrides.py — impact
  • tests/test_python_inherited_method_calls.py — impact
  • tests/test_python_injected_factory_calls.py — impact
  • tests/test_python_property_reads.py — impact
  • tests/test_python_pytest_fixture_receivers.py — impact
  • tests/test_rust_use_trees.py — impact
  • tests/test_semantic_origin_stamp.py — impact
  • tests/test_skill_persisted_scan_options.py — impact
  • tests/test_solidity_inherited_calls.py — impact
  • tests/test_terraform_modules.py — impact
  • tests/test_undirected_two_file_import_cycle.py — impact
  • tests/test_update_incremental.py — impact
  • tests/test_update_lock_contention.py — impact
  • tests/test_update_missing_graph.py — impact, changed-test
  • tests/test_update_no_change_gate.py — impact
  • tests/test_watch.py — impact
  • tests/test_watch_identity_cache.py — impact
  • tests/test_watch_manifest_location.py — impact

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.

Formal verification

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

· 1 more finding(s) on lines outside this diff (see the check run).

@safishamsi

Copy link
Copy Markdown
Member

Landed on v8 and shipped in 0.9.104 (now on PyPI). I cherry-picked your commit with -x so it keeps your authorship. Thanks for the full-rebuild fallback when graph.json is missing (#5020), @azizur100389.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: graphify update skips or partially rebuilds a missing graph when the manifest survives

2 participants