fix(incremental): use git --name-status -M to detect renames + prune old-path nodes (#366)#397
Open
tirth8205 wants to merge 1 commit into
Open
Conversation
…d paths (Egonex-AI#366) Incremental `/understand` runs build the changed-file list via `git diff <base>..HEAD --name-only`. Git's default rename detection collapses a rename into a single new-path line, so the prune step never sees the old path. The pre-rename node (and every edge that touched it) survives in the graph as an orphan after the rename commit is analyzed. Switch to `git diff <base>..HEAD --name-status -M` and route each status: - `M`, `A`, `T`, `U` → analyze - `D` → prune-only - `R<score>\told\tnew` → prune `old`, analyze `new` - `C<score>\told\tnew` → analyze `new` only (source survives) Parsing happens in a new shared helper, `parse-git-changes.mjs`, which writes two newline-delimited files (`changed-files.txt`, `prune-files.txt`) that SKILL.md feeds to `compute-batches.mjs --changed-files=…` and to the prune step. The prune step now takes the union of both sets so renamed/deleted files no longer leave stale nodes + edges behind. Adds `tests/skill/understand/test_parse_git_changes.test.mjs` covering the parser's branches (M, A, D, R, C, T, U, unknown status, empty input) plus a CLI end-to-end check that the two output files contain the expected sorted paths. No real git invocation needed — the fixtures are raw `--name-status` strings. Addresses Bug 1 of 3 from Egonex-AI#366. Bugs 2 (inbound-edge pruning) and 3 (importMap recovery) are covered by separate follow-up PRs. Refs Egonex-AI#366 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Addresses Bug 1 of 3 from #366: renamed/moved files left orphaned
old-path nodes (plus every edge that referenced them) in the knowledge
graph after an incremental
/understandrun.skills/understand/SKILL.mdfromgit diff <base>..HEAD --name-onlyto
git diff <base>..HEAD --name-status -M. The plain--name-onlyform reports a rename as only the new path, so the prune step never
saw the old path; with
-Mthe rename appears asR<score>\told\tnewand we can route the two paths to differentbuckets.
skills/understand/parse-git-changes.mjsthat splits the
--name-statuslines into two disjoint sets:changed-files.txt— paths to analyze:M,A,T,U,plus the new path of
R<score>renames andC<score>copies.prune-files.txt— paths to prune-only:Ddeletions plusthe old path of
R<score>renames. Copies do not prune thesource because the original file still exists.
sets — re-analyzed files still need their old nodes dropped, and
prune-only files need removal without a replacement.
tests/skill/understand/test_parse_git_changes.test.mjswith16 cases covering all status branches (M / A / D / R / C / T / U /
unknown / empty) plus a CLI round-trip. Fixtures are raw
--name-statusstrings — no real git invocation needed.Scope
Only Bug 1. Two follow-up PRs cover Bugs 2 (inbound-edge pruning) and
3 (
importMaprecovery on rename) independently — they have nooverlap with the change-detection path touched here.
Marked
Refs #366rather thanCloses #366since two of the threebugs ship in separate PRs.
Test plan
pnpm test— 216 tests pass (200 prior + 16 new).pnpm lint— clean.git mv docs/a.md docs/b.md,commit, run
/understand(incremental). Confirm the resultinggraph contains only
document:docs/b.md, not the staledocument:docs/a.mdnode + its edges.Refs #366
🤖 Generated with Claude Code