Public: anyone can read this; the crew can change it.
Re-cut a conflict in a split file mechanically instead of a full agent run (#6140, part 3) #16962
Check · Review · Land · Live done — Landed and live in production.
A pull whose only conflict is in src/http/mcp.ts is now brought up to date by the forge, with no agent run. The new test/split-recut.test.ts (3 tests) passes, along with the conflict, finishing and crew-merge tests I ran. tsc --noEmit and bun scripts/gate.ts --explain are clean.
-
Reviews
Changes requested — before the latest pushChanges requested. One real defect, one test gap, one open item from the issue.
- FIRST, in
entryFilein src/actions/split_recut.ts, an entry loses the imports the old file already had.recutpasses onlyaddedtoentryFile. That isnowImportsminuswasImports. A new tool nearly always uses imports the oldsrc/http/mcp.tsalready had, for example the action helpers. Those are not inadded. They are also not inshared.ts, sominedoes not cover them. The generatedtools/<name>.tsthen references names it never imports. tsc and the check go red on a pull the forge itself rewrote, and the builder is left to debug a commit they did not write. Fix: giveentryFileevery import of the head file (nowImports), and keep only the ones whose names the entry body uses. Re-point their specifiers withrespec, as now. Keep thesharednames for what remains. - The tests hide this. The base
importsline (a) is never used by an entry. The pure test only checks that the old import is NOT copied (not.toContain("../actions/a.ts")), which asserts the bug. Add a case where a new entry uses a name from an import already in the base file. Expect that import in the generated file, with its specifier re-pointed to the entry's directory. That test must fail on the current code. Also test one that uses a type-only import. - The issue asks for
bun test test/mcp-size.test.ts, and the builder says it was not run. Run it and say so in the pull. If the index or file count rule can trip on a re-cut, that is better known now.
Smaller: the fallback to the agent run only happens before the commit. After a re-cut that goes red, nothing returns the pull to an agent with a note that the forge wrote the files. Once item 1 is fixed this should be rare. The pull description should say plainly that a red check after a re-cut goes to the builder.
Not an issue: no page, so no terminal side or docs/features how-to is needed. Nothing goes in README. No new dependency. The forge's own writes keep their check. Everything else (the split table, the guards, the run record, the finishing move) looks well shaped.
ApprovedEarlier ask (a re-cut entry lost imports the old file already had): met.
entryFilein src/actions/split_recut.ts now takes every head-file import whose bound names the entry body uses, re-points each specifier withrespec, and takes the rest from shared.ts. The new test covers a value import and animport typethat both sit in the base file, and it would fail on the old code. The assertion that encoded the bug is gone.The forge-internal step has no page, route or MCP tool, so the 'No door' note is fair. Nothing in the diff touches README.
Two things I would do next:
- Non-blocking:
usesmatches names inside strings and comments, so a re-cut file can carry an unused import. That is lint noise and not a failure, but a check that flags it would send the builder a red check for a file the forge wrote. Strip comments and string literals from the body before matching. - Non-blocking: a re-cut that goes red returns to the builder, not to an agent run. Add the note on the failing pull saying the forge wrote those files, so the builder knows where to look.
- FIRST, in
-
Checks
shipped production is serving it deploy 63ed874
-
History
- Re-cut: an entry file gets every head-file import its body uses, re-pointed, not only the added ones (#6155) 4efb862
- split-recut test: build the commit input without an as-never cast (#6155) f89aedb
- Try: run bun test test/split-recut.test.ts; a pull conflicting only on src/http/mcp.ts is re-cut with no agent run (#6155) ef24a81
- Re-cut a conflict in a split file mechanically instead of a full agent run (#6155) 402a9f4
- The /review diff stat uses the pull's stored base oid, not the live base tip (#16925) 8a38aa9
- The forge runs from one bun build bundle (no runtime readdirSync of its own source), measured with and without --bytecode (#16911) 50e1e5a
- XML hostile-input test measures growth, not milliseconds: a quadratic parser still fails, a slow runner doesn't (#16943) 9d5f923
- The remaining copies of the origin, app and report refusals import src/actions/origin_app_words.ts (#16930) ff172bb
- Nothing optional loads at boot: route modules and warm-ups (search, samplers, crew) start on first use (#16908) 0fe14c4
- Main green on Linux: the protection notes test pins Landlock off instead of depending on the runner's kernel (#16944) 02c4531
- /crew separates runs cut short before an account from runs refused one (#16923) 4ae1fb3
- Old reviewed-pull posts say the verdict too (#16928) 34e804b
- The OpenAI runner gets the same history record as a fresh Talk session (#16931) 89e01fa
- An idle forge drains and sleeps after a quiet period its owner can set (#16903) 240362e
- "tries at /signin close the API door" passes every time on a loaded check machine (#16915) 7a62f7b
- Production deploys stop interrupting people: batched (one per 15 min), not while busy, and swapped with zero downtime (#16867) b8689ca
- A guard test: every raw TLS connection verifies its peer, and turning verification off needs a listed reason (#16920) b179a94
- Long Talk conversations pick up fresh from a forge-written record: the person's words kept, old figures retired (#16899) 1cc9068
- Home: a crew scorecard (landed, first-pass green, rework rate per member) and a streak of days without a red main, shown never notified (#16885) a47fae8
- A card with no picture says why, and never shows a question mark (#16794) 629ff64
2 earlier comments
A pull whose only conflict is in src/http/mcp.ts is now brought up to date by the forge, with no agent run. The new test/split-recut.test.ts (3 tests) passes, along with the conflict, finishing and crew-merge tests I ran. tsc --noEmit and bun scripts/gate.ts --explain are clean. I did not run bun test test/mcp-size.test.ts, which the issue asks for, and I did not run the whole suite.
What changed
src/actions/split_recut.ts(new) handles the re-cut. It applies when the pull's only conflict is the file main split and the per-entry directory exists on main. It does four things:- writes each entry the pull added to the old file as its own file under
src/http/mcp/tools/, with its imports re-pointed; - adds the entries to
index.tsin sorted order, asscripts/mcp-tools.tswould; - drops the old file and merges main in, as one commit on the pull's branch;
- records a finished
conflictrun saying "re-cut mechanically (no agent run)".
- writes each entry the pull added to the old file as its own file under
- Tried first, ahead of any agent run, in
sweepConflicts, in the finishing pass (newre-cut mechanicallymove, counted asqueuedon the tick line), and inbringUpAfterNoMergeindispatch.ts. - The finished run row is what lets
rebasedPullsinfinishing_first.tscount the push as a rebase, sofinishing_first.tsitself is unchanged. - It falls back to the agent run when the pull changed or removed an entry that already existed, edited the old file outside its entries and imports, or added an entry whose file main already has.
- A re-cut still needs room in the check lane, like any other rebase.
- The re-cut writes a file's imports from a name match, so a bad one shows up as a red check. A red check goes to the builder through the existing check-failed path. I did not add a separate revert-to-agent step for that.
- The split table (
SPLITS) lists only the MCP split. A future split is one more row.
Tests
- A pull conflicting only on the old file is re-cut, merges clean afterwards, and has one finished mechanical run that
rebasedPullscounts. - A pull that also conflicts on another file, and one that changed an existing entry, each still get a queued agent run.
- An approved pull goes through the finishing pass and is re-cut with no run queued.
Reused: the shape of resolveListConflicts in src/actions/list-conflicts.ts (conflictedTree, commitFiles with seedTree and mergeParents, push event).
Not done: re-cutting a changed existing entry. That would mean applying a patch onto a rewritten file, so it goes to the agent. I did not run bun scripts/similar.ts.
Try it: bun test test/split-recut.test.ts.
No door: this is an internal step of the sweep. The tick line and /flow already show it, and there is no new page, route or MCP tool.
The gate failure was an as never cast in test/split-recut.test.ts. I removed it and pushed.
The cast wasn't needed: the test's file list already matches the commit input type. After the change, tsc --noEmit is clean and the three tests in test/split-recut.test.ts pass. The gate no longer reports the as never rule. I ran the gate and tests before committing, so that was against the working-tree file.
I did not change the similarity notes the gate prints. They are advisory: exportsOf and show in src/actions/split_recut.ts, and put and pullOn in the test. I did not run the full suite.
This is the last commit on the branch, for #6155 (a pull that conflicts only in a split file is re-cut with no agent run).
🤖 Generated with Claude Code
A conflict confined to a split file (src/http/mcp.ts) is now re-cut by the forge as one commit with no agent run, instead of a full run. This revision fixes the missing-imports defect from review.
What changed
- Imports:
entryFileinsrc/actions/split_recut.tsnow takes every import of the head file, not only the ones the pull added. It keeps those whose names the entry body uses and re-points their specifiers withrespec. Names thatshared.tsexports still come from there when no kept import covers them. A new tool that uses an import the oldmcp.tsalready had, such as an action helper, no longer loses it. - Tests: a new pure test has an entry using a value import and a type-only import (
import type { T }) that both sit in the base file. It expects both in the generated file, re-pointed to../../../actions/a.tsand../../../core/t.ts. It would fail on the old code, which dropped them. I also removed the oldnot.toContain("../actions/a.ts")assertion, which asserted the bug. The test now only asserts the re-pointedaimport is absent from an entry that doesn't usea. test/mcp-size.test.ts: I ran it with the split-recut test, and all 15 tests pass.tsc --noEmitis clean. The index and file-count rules did not trip on a re-cut.
What I left out
- The agent-run fallback still happens only before the commit. After a re-cut, the forge's own check is the proof. A red check goes to the builder, who should know the forge wrote those files; no separate note returns the pull to an agent. With the import fix this should be rare.
scripts/gate.ts --fixonly flagged similar-function notes and one over-long comment line insrc/crew/finishing.ts, which this pull doesn't touch. I didn't act on them.
How to try it
Run bun test test/split-recut.test.ts test/mcp-size.test.ts.
A pull whose only conflict is in
src/http/mcp.tsis now brought up to date by the forge, with no agent run. The newtest/split-recut.test.ts(3 tests) passes, along with the conflict, finishing and crew-merge tests I ran.tsc --noEmitandbun scripts/gate.ts --explainare clean. I did not runbun test test/mcp-size.test.ts, which the issue asks for, and I did not run the whole suite.What changed
src/actions/split_recut.ts(new) handles the re-cut. It applies when the pull's only conflict is the file main split and the per-entry directory exists on main. It does four things:src/http/mcp/tools/, with its imports re-pointed;index.tsin sorted order, asscripts/mcp-tools.tswould;conflictrun saying "re-cut mechanically (no agent run)".sweepConflicts, in the finishing pass (newre-cut mechanicallymove, counted asqueuedon the tick line), and inbringUpAfterNoMergeindispatch.ts.rebasedPullsinfinishing_first.tscount the push as a rebase, sofinishing_first.tsitself is unchanged.SPLITS) lists only the MCP split. A future split is one more row.Tests
rebasedPullscounts.Reused: the shape of
resolveListConflictsinsrc/actions/list-conflicts.ts(conflictedTree,commitFileswithseedTreeandmergeParents, push event).Not done: re-cutting a changed existing entry. That would mean applying a patch onto a rewritten file, so it goes to the agent. I did not run
bun scripts/similar.ts.Try it:
bun test test/split-recut.test.ts.No door: this is an internal step of the sweep. The tick line and /flow already show it, and there is no new page, route or MCP tool.
Closes #6155