Restructure: add a reference-integrity gate before moves#2
Open
dubedad wants to merge 1 commit into
Open
Conversation
Adds a verification step to Restructure mode that proves what depends on a file before it is moved, across four scopes (in-vault, sibling-path, symlink, external/cross-boundary), plus a location-durability check and a copy-verify-parity-then-remove migrate discipline. Sharpens the Dead role (apparent disuse is not proof) and adds a no-orphaned-references check to the walk test. New references/reference-integrity.md documents the method. Co-Authored-By: Claude Opus 4.8 <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.
Restructure: add a reference-integrity gate before moves
What this changes
Restructure mode currently: classify files → propose → migrate → validate with the walk test. This PR inserts one step — verify reference integrity, before proposing — and tightens two things around it.
../), symlink, and external/cross-boundary (other repos or systems that hardcode paths in). This adds no new role — it flags a move: any file with a live referrer is held, and can't be classified Dead until the check comes back clean.Deadrole: a file is Dead only once step 4 confirms nothing depends on it. Apparent disuse is not proof.references/reference-integrity.mddocuments the method, tool-agnostically.Two files, +73/−4. No new dependencies, no template changes, nothing mandatory outside Restructure mode.
Why — the gap
Restructure's flow is "migration map → wait for your yes → move and check the result." This PR gives the yes something to stand on. The map shows where each file goes; nothing shows what depends on it. So the walk test proves the result is navigable, but nothing checks whether the act of moving a file broke a dependency the move couldn't see. The skill already senses this — step 5 says to leave a link "if anything might reference it." "Might" is a hunch. This PR turns the hunch into a checked list the approval gate can stand on — and it stays tool-agnostic (documented as shapes of checks, not a mandated script) so it works the same under Claude or a codex
agents.md.This is impact analysis (the DAMA-DMBOK term for "what breaks if I change this"), applied to a folder instead of a database — and it strengthens the human gate the method already has, rather than adding new ceremony.
Where it came from — a real test run
I ran Restructure mode against a genuinely messy real workspace: ~68 project folders, ~30k files, accumulated output from months of work. Classification was good. But bolting on a reference check before approving any move caught two things the walk test would have sailed straight past:
A third finding motivated the durability note: ~88 MB of active work was living only inside an ephemeral, git-ignored location, one cleanup away from unrecoverable. Reorganizing within a workspace that isn't itself durable is rearranging deck chairs.
None of these are exotic. They're the normal failure modes of moving files in a real system — which is exactly why a gate for them belongs in the tool.
Design notes
reference-integrity.mddocuments the shape of each check with illustrative commands, not a mandated script.