fix(build): make semantic id-remap idempotent for dot-dir files (#1924) - #1926
Closed
SinghAman21 wants to merge 2 commits into
Closed
fix(build): make semantic id-remap idempotent for dot-dir files (#1924)#1926SinghAman21 wants to merge 2 commits into
SinghAman21 wants to merge 2 commits into
Conversation
…hify-Labs#1924) A non-AST node whose source_file sits in a dot-directory (e.g. .claude/CLAUDE.md) had its id re-prefixed with the parent segment on every incremental rebuild, so graph.json never converged: claude_claude_graphify_trigger -> claude_claude_claude_graphify_trigger (one claude_ per run) The canonical full-path stem (claude_claude) contains the shorter zero-parent legacy stem (claude) as a proper prefix. _semantic_id_remap only skipped old_stem == new_stem, so an already-canonical id still matched the shorter "claude" form, got one segment stripped, and had the full stem re-prepended forever. Preserved nodes ride the build_merge path through this remap on every update, so 0-re-extracted runs still mutated. Add the already-canonical guard the read-only graph_has_legacy_ids() detector already uses: skip when norm_nid == new_stem or starts with new_stem + "_". Legacy migration (bare-stem and file-node forms) still runs exactly once.
Collaborator
|
Thanks for this. The same dot-dir id-accretion bug (#1924) was already fixed on v8 by #1917 (19c496d): the idempotency guard in _semantic_id_remap skips an id that already carries its canonical stem, so a file like .claude/CLAUDE.md migrates once and then stays stable. Verified against the #1924 repro. Closing as already-resolved rather than merging a second fix for the same path — much appreciated regardless. |
Contributor
Author
|
hey @safishamsi thanks for your explanation. |
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.
Fix non-idempotent node IDs for files in dot-directories (#1924)
Running an incremental rebuild twice over an unchanged corpus should produce an identical graph. For files under a dot-directory it doesn't — .claude/CLAUDE.md's node ID gains one claude_ every run and never converges (claude_claude_graphify_trigger → claude_claude_claude_graphify_trigger → …). Logs show 0 re-extracted, so it's the preserved-node path, not extraction.
Cause: semantic_id_remap() rewrites legacy IDs to the canonical full-path stem. For a dot-dir file the canonical stem (claude_claude) contains the shorter legacy stem (claude) as a prefix. The guard only skipped old_stem == new_stem, so an already-canonical ID still matched the claude prefix, lost one segment, and got the full stem prepended back — +1 each run.
Fix: skip the remap when the ID is already canonical (== new_stem or starts with new_stem + "_"), the same guard graph_has_legacy_ids() already uses. Legitimate legacy migration still runs once.
Testing: added tests/test_semantic_id_remap_idempotent.py (stable across reruns, legacy forms still migrate once); build/merge/watch/id suites pass.