Repository navigation
feat: suggest a move, and where it goes, for a tangle of files - #41
Merged
Merged
Conversation
A symbol on a cut often uses a type or constant declared beside it. Left behind, that helper makes the new home import the old file, and the cut edge comes back. The prototype now moves the whole closure. When code that stays also uses a helper, the old file imports it from the new home. Also count only a variable statement's own declarators as top-level names. A walk found the locals inside function bodies too, and each one looked like a helper. At file granularity on four public repositories, the best home now frees the cycle for 107 of 111 placed cuts, up from 59. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
The cut search scores one edge at a time and never asks how much code a cut moves. A move can remove several edges into one file at once, when they all import the same declaration. The prototype now tries moves: a declaration that a tangle file imports, or every declaration on one edge, with its helpers. It ranks them by the largest cycle left, then the largest runtime cycle, then the lines moved. Erasure is decided per binding: `import type`, or a name an interface or type alias declares. A new file is named after the first declaration the move was asked for, instead of `moved.ts`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
A `const` and an `interface` can share a name. The prototype kept one span per name, so a move took the `const` and left the `interface` behind, and the cycle stayed. A round 5 judge caught it. Function overloads had the same problem. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
When every member of a tangle is a file, thicket now searches for declarations to move instead of an edge to cut. Each move takes its helpers along. The report prints `suggested move:` and `move to:`, and the JSON gains a `move` field. A module tangle keeps the edge search, and so does a file tangle no move breaks. Blind judges preferred the move to the edge cut 19 times to 8. The home ranking prefers an existing file that is just as safe as a new one. On the 11 judged homes that changed, two judges rated the new pick good 6 and 7 times, against 2 and 1 for the old pick. There is no off switch. AGENTS.md §4b now reserves flags for opinions that hide something. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
Round 6 judged the shipped output, and all five preregistered bars held. The judges' reasons exposed two bugs. `leaves:` measured the cycle left with the code in a new file, so it overstated what remains when the home is an existing file. And two rejected homes were files that only re-export. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
Some generators write no banner, so the banner scan misses their output, and the move search picked such files as homes. A file named `*.gen.ts` is now skipped like a generated directory. The denominator skips it too. The report counts these files on their own, and --include-generated brings them back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
Three fixes to the cycle a move is said to leave. Only the tangle's files and the home count, not a cycle the home was already in. Edges the report dissolves first are dropped in the home check too, as in the search. And a file that re-exports from the owner beside code of its own keeps its edge, because symbolsOf now records every `export … from` target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y
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.
What changes
When every member of a tangle is a file, thicket searches for declarations to move instead of an edge to cut.
suggested move:,move to:andleaves:.move ·arrow.movefield.There is no off switch. AGENTS.md §4b now reserves flags for opinions that hide a file or a finding.
Code
src/extract/symbols.tsreads each file's bindings, declaration spans and identifier uses.Project.symbolsOfmemoizes it.src/graph/moves.tsholds the move search and the home ranking.src/run.tstries a move before the edge cut.src/report/markdown.tsrenders it.Evidence
The prototype work and rounds 4 and 5 are recorded in
docs/plans/2026-11-11-placement.md.Tests
tests/moves.test.ts, with the new fixturetests/fixtures/moves/🤖 Generated with Claude Code
https://claude.ai/code/session_01S7cyneSpBhH5XCwE3t8w1Y