Skip to content

rebuild when a hook only sees a rename destination or an ignore file - #5353

Open
SyedFahad7 wants to merge 2 commits into
Graphify-Labs:v8from
SyedFahad7:hook-rebuild-reconcile-fix
Open

SyedFahad7 wants to merge 2 commits into
Graphify-Labs:v8from
SyedFahad7:hook-rebuild-reconcile-fix

Conversation

@SyedFahad7

Copy link
Copy Markdown
Contributor

An incremental hook rebuild could return success and leave stale nodes in graph.json when the change list was only an untracked rename destination, such as util.py renamed to util.py.bak, or only an ignore file. The empty extraction batch returned before reconciliation, so sources that had left the corpus were never dropped, and files newly included by an ignore change were never indexed. The rebuild now continues with an empty batch so reconciliation can catch those sources, and a change to an ignore file also extracts files that are now in the corpus.

An incremental hook rebuild returned success without touching graph.json when the change list was only an untracked rename destination, such as util.py renamed to util.py.bak, or only an ignore file. The empty extraction batch returned before reconciliation, so stale nodes stayed in the graph. The rebuild now continues with an empty batch so reconciliation can drop sources that left the corpus, and a change to an ignore file also extracts newly included files.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 05:54
@github-actions github-actions Bot added the needs:title PR title should follow the conventional-commit format label Nov 20, 2026

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-actions

Copy link
Copy Markdown

Thanks @SyedFahad7! One small thing: our changelog and release notes are built from PR titles, so we use the conventional-commits format, for example:

fix(python): resolve a bare stdlib import correctly

Prefixes we use: feat, fix, docs, chore, refactor, test, perf, build, ci. Editing the PR title clears this automatically. This is just a nudge and does not block review.

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

Copy link
Copy Markdown

Thanks for the pull request, @SyedFahad7. 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.11 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 code review View in Graphify

Review completed · fdc6e9459917

Warning

Merge confidence: 3/5 · Review before merging · 🟠 High impact
1 P2 bug checked against the code · 2 possible issues not confirmed
5 not re-checked

Incremental rebuilds now reconcile rename destinations that are not extractable and respond to ignore-file changes.

Full summary

Incremental rebuilds now reconcile rename destinations that are not extractable and respond to ignore-file changes. An ignore-file change also enables VCS-ignore eviction during reconciliation.

Bugs (1)

P2 · Preserve deliberately indexed VCS-ignored entries when reconciling .graphifyignore changes in graphify/watch.py: ignore_changed currently applies unchanged VCS ignore rules to corpus-absent files and evicts their graph records. Inspect source

Detailed review · checked against the code

Editing .graphifyignore can evict deliberately indexed VCS-ignored files

A .graphifyignore-only change can remove graph entries for files that still match an unchanged .gitignore rule, even though incremental rebuilds otherwise preserve those deliberately indexed files.

Expected: The incremental rebuild preserves deliberately indexed VCS-ignored entries unless the VCS ignore rule itself is being intentionally honored.
Actually: The .graphifyignore change enables the full ignore predicate during reconciliation, which treats the file as newly ignored and evicts its graph records.

An incremental change list containing .graphifyignore sets ignore_changed, which is passed as honor_vcs_ignore to reconciliation. For an alive source absent from code_files, _ignored_now then applies is_ignored_full; if the unchanged VCS ignore rule matches, reconciliation treats the source as newly ignored and evicts its records. This newly added path bypasses the documented incremental preservation policy for deliberately indexed .gitignore-matched files.

  • Independent source review: The existing incremental-preservation test keeps a .gitignore-matched file when an ordinary code file changes, but does not cover an ignore-file change. The .graphifyignore-only tests cover graphify-ignore eviction, not preservation of a file matched by an unchanged VCS rule. No guard on the ignore-file-change route prevents the full predicate from matching.

Not confirmed (2 possible issues)

Leads worth a look; we didn't double-check these. They don't change the score.

Not confirmed · Test fails if the rebuild log wording changes, because it checks the exact console text 'newly-ignored file(s)' Inspect source

Detailed review · not confirmed

The test passes only if the printed message contains the exact phrase 'newly-ignored file(s)', even though the graph assertions already check the behavior.

Line 1646 reads captured stdout and requires the literal text 'newly-ignored file(s)'. Lines 1643-1645 already confirm that vendor.py is removed from the graph and app.py remains, which is the behavior the test is about. The same pattern appears at line 1577 with 'No tracked code files in change set - skipping rebuild', so the wording of these messages is effectively part of the test contract.

  • The rebuild implementation in graphify/watch.py is not shown, so it is unknown whether this message is user-facing or meant to be a stable interface.

  • The check that no skip message appears at line 1577 is a negative match and would also pass if the message were reworded.

  • Found by the per-file sweep; not double-checked.

Not confirmed · Errors while adding newly included files after an ignore-file change are swallowed, so those files silently stay unindexed Inspect source

Detailed review · not confirmed

When .gitignore or .graphifyignore changes, the block meant to queue newly included files drops any error without a message.

Lines 2779-2812 are added by this PR to append code files that are not yet in the graph to wanted when an ignore file changes (#​5329). The handler at 2811-2812 hides every failure, including from check_graph_file_size_cap and json.loads at 2784-2785. The later _reconcile_existing_graph call only catches RuntimeError and ValueError, so other failures in this block are never reported. The result is a rebuild that appears to succeed while the newly included files are missing from the graph.

  • Not checked whether _StoredSourcePaths.absolute_identity can raise for particular path values.

  • Not checked whether the later extraction handles an empty extract_targets list when only deleted paths remain.

  • Found by the per-file sweep; not double-checked.

Code graph and static checks · 1041 functions depend on this change

Impact & health

Impact — 1041 functions depend on the 600 functions this change touches.

Health — grade A; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):

  • _rebuild_code() — 284 callers, 77 callees (high)
  • dispatch_command() — 8 callers, 156 callees (high)
  • main() — 128 callers, 3 callees (high)
  • watch() — 8 callers, 15 callees (high)
  • _reconcile_existing_graph() — 6 callers, 16 callees (high)
  • _check_shrink() — 18 callers, 5 callees (high)
  • _run_cli() — 11 callers, 8 callees (high)
  • _reconcile_graph_html() — 8 callers, 5 callees (high)
  • …and 2 more

Formal checks — 1041 functions this change can affect weren't formally checked in this review. Formal checks are informational only.

Gate & verification

✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 765 function(s) in the blast radius were not formally verified this run

Test selection

49 of 601 test file(s) selected (8%) via static blast radius.

  • tests/test_4978_reconcile_cost.py — impact
  • tests/test_build.py — impact
  • 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_cpp_forward_declarations.py — impact
  • tests/test_cpp_incremental_type_resolution.py — impact
  • tests/test_cpp_member_declaration_identity.py — impact
  • tests/test_csharp_method_owner_labels.py — impact
  • tests/test_csharp_object_creation.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_java_nested_type_identity.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_markdown_sections.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_qualified_type_competition.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_js_resolution_inputs.py — impact
  • tests/test_update_lock_contention.py — impact
  • tests/test_update_missing_graph.py — impact
  • tests/test_update_no_change_gate.py — impact
  • tests/test_watch.py — impact, changed-test
  • tests/test_watch_identity_cache.py — impact
  • tests/test_watch_inotify_overflow.py — impact
  • tests/test_watch_manifest_location.py — impact
  • tests/test_watch_pruned.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.

This branch has not been deployed

No deployments
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 needs:title PR title should follow the conventional-commit format

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants