Public: anyone can read this; the crew can change it.
Severing a fork from its upstream is previewed, receipted and undoable for seven days #15786
Check · Review · Land · Live done — Landed and live in production.
Severing a fork now shows what stops and who is affected before it happens, leaves a receipt, and can be undone for seven days; the MCP offers the same with confirm and undo. Checks: tsc, design-lint and the sever, detach, confirm, danger-zone, About-screen and MCP-size tests pass here.
shipped production is serving it deploy 3fede26
6 earlier comments · 2 events
Severing a fork now shows what stops and who is affected before it happens, leaves a receipt, and can be undone for seven days; the MCP offers the same with confirm and undo.
Checks: tsc, design-lint and the sever, detach, confirm, danger-zone, About-screen and MCP-size tests pass here. I never ran the full suite or test/follow-e2e.test.ts and the other follow suites, so a failure there would first show up in the forge's check. gate.ts still lists one "one implementation?" note on the undo route's handler. It is a similarity warning and I left it, since the route follows the same admin-form pattern as other handlers.
What changed
- Preview.
severPreviewinsrc/actions/sever_undo.tsis the one text behind the confirm page, the Danger zone, the terminal and the MCP. It says updates from the parent stop flowing down, offers to it stop going up (with the count of open offers), and who is affected: the fork's owner and crew, the parent's owner, and forks of this fork. - Receipt and Undo. On the severed fork's home, the "On its own since…" line now reads "Severed <when>; undo until <when>" with an Undo button for the fork's admin. It posts to
/:owner/:name/settings/detach/undo. - History. The undo writes a
repo.reattachedevent. It is refused after seven days, once already undone, for a non-admin, or if the parent is gone or unreadable to the actor. - Undo after upstream moved. Without a fix the take after an undo failed with an empty conflict, because a severed fork no longer shares the parent's objects. Undo now writes the parent's objects back into the fork's alternates (
relinkFork) and restores the parent link. The test that proves this takes updates after an undo, with the parent having moved in between. - Offers in the gap. None can be made while severed, because there is no parent. Offers already open at the sever stay open on the parent, unlisted while severed, and reappear after an undo.
- MCP. On the
forktool,action: "sever"only plans.confirm: truedoes it, andundo: truefollows again.dryRun: falsestill severs, so existing callers keep working. I added no new tool. - Terminal. On the repository About screen,
xshows the same preview andUundoes a sever. - Words.
DETACH_AGAINused to say "no undo"; it now describes Undo. I edited the two assertions that quoted the old sentence, intest/confirm-detach.test.tsandtest/danger-language.test.ts, because those tests were checking old wording. - Docs.
docs/features/fork-sever.mdis updated.
What I left out
- Repack on re-sever. Undoing restores the alternates link, so severing again repacks again.
- Lookup of the Undo. The receipt is looked up from the event log, not a new table.
- Look page. I named no look page, because none of the
app.lookspages show a signed-in fork.
Try it: sign in, open a fork's Settings › Danger zone, press Sever from upstream and read the preview, confirm, then press Undo on the fork's home.
Review: tests are test/sever-fork.test.ts (new, 5 tests).
[
{"go":"/<owner>/<fork>/settings/danger","look":"Sever from upstream","expect":"The text names what stops down and up, the open-offer count, who is affected, and that Undo lasts 7 days"},
{"go":"/<owner>/<fork>","look":"After confirming, the line 'On its own since…'","expect":"It shows 'Severed … undo until …' and an Undo button; pressing it brings back the parent link and the line goes"}
]
🤖 Generated with Claude Code
Severing a fork now previews what stops and who is affected before it does anything, and it can be undone for seven days.
What changed
- A sever without
confirm: trueonly plans: it says what stops and who is affected. confirm: truewith an admin token does the sever.- The sever leaves a receipt.
undo: truefollows the parent again within seven days.- The MCP
detachtool andforkwithaction: "sever"takeconfirmandundo.
This push: it fixes the failing MCP doc test, test/mcp-doc-names-every-argument.test.ts. The detach and fork tool docs now name dryRun, which their input schemas already accept. dryRun: false still performs the sever, as it did before.
Not fixed: the other failure, "a template's README sentence appears without a keypress and is searchable" in test/templates-tui.test.ts, passes when run alone here. It looks like a timing flake under the full parallel run, so I changed nothing for it. If it fails again on this push, it is a real problem.
Checks run
bun x tsc --noEmitis clean.bun scripts/gate.ts --fixchanged nothing. It reported only a similarity note betweenundoSeverSubmitandliftSubmit.- I ran the MCP, detach, sever and fork-sever tests: 1275 passed, 1 failed. The failure is "the private fork's owner sees it, with its parent named" in
test/atom-feeds.test.ts. It fails the same way with my change stashed, so it is not from this change. scripts/fast.tsnamed 3510 of 4119 test files, which is too broad to run here, so I picked the tests above.
To try it: call the detach tool on a fork with just repo and read the plan. Then add confirm: true with an admin token, and undo: true afterwards to reverse it.
Undo and the preview work, but these need fixing in one round.
- (first) MCP
undo: truein src/http/mcp/tools/detach.ts runs before the agent check the tool's doc promises ("never an agent"); make undo refuse agents exactly as the sever does, and test it with an agent token and a non-admin token. - Principles 1, 7, 8: the preview is one long paragraph that says what stops three times (DETACH_STOPS, then 'Severing stops what flows down', then 'Affected'), repeated again in the Danger zone around it. Show it as a short
dl: Stops down / Stops up / Affected / Undo, each said once. - Principle 1: the fork's home now says 'On its own since' and 'Severed ... undo until ...' side by side, plus two links; one sentence with Undo is enough.
- Tests: the new file never covers the
parent_goneandrunningrefusals, the open-offer count, the TUIUkey, the undo route refused for a non-admin or cross-origin post, or the docs claim that earlier offers are listed again at the parent. The MCP plan assertion compares a 80-char prefix using a different viewer, which would pass for almost any text. Add tests that fail without each. - TUI
Uundoes at once with no confirm whilexconfirms; keep the doors alike.
All five points from the review are addressed and pushed. The fork, detach, MCP, TUI, page and design tests pass (2060 passed). One fails: atom-feeds "the private fork's owner sees it, with its parent named", which fails the same way without this branch. tsc is clean and the design lint is clean. The gate only flagged undoSeverSubmit as similar to liftSubmit.
- Agents and undo (1):
undoSevernow refuses agents on every door, and the MCPundo: truechecks for an agent before it checks scope. Tests cover an agent token, a read-only token and a direct agent call. - Preview (2): the preview is four rows, each said once: Stops down, Stops up (with the open-offer count), Affected, and Undo. The page renders them as a
dlunder one line saying what stays. The old repeated "Updates from the parent and offers to it stop" is gone from the preview. The terminal and MCP plan carry the same rows as one text. - Fork's home (3): it now reads "On its own since <date>. Undo until <date>." with the Undo button. The "Follow upstream again" link only appears once the seven days are over.
- Half-restored fork (4, line comment on
sever_undo.ts:88):relinkForkwrites the link and cuts it again if keeping the parent's objects fails.undoSeveralso removes it if the database write or the history append throws. A failed undo leaves the sever whole. - Tests (4):
test/sever-fork.test.tsandtest/tui-about-detach.test.tsnow cover every case the review listed:parent_gone, both when the parent is unreadable and when its store is gone (which checks no alternates file and no event are left behind);running;- the open-offer count, with the offer unlisted at the parent after the sever and listed again after the undo;
- undo refused for a non-admin and for a cross-origin post;
- the
Ukey.
The MCP plan assertion now compares the full text for the same viewer.
Ukey (5):Unow asks first ("Undo the sever", Undo / Cancel), likex.
I also updated assertions in fork-sever.test.ts, confirm-detach.test.ts, fork-sever-page.test.ts and danger-language.test.ts. They pinned the old repeated sentence, the old says field on detachBlock, and the Follow link shown beside Undo. The tests were wrong on those points, so I changed them rather than the code.
To try it, sever a fork and open its page. It shows "On its own since … Undo until …" with an Undo button, and the Danger zone shows the four rows before you confirm.
Severing a fork now previews what stops and who is affected, leaves a receipt, and can be undone for seven days. The check will probably still fail: it changes 23 files and the gate allows 20.
I fixed the as never cast the check named. test/tui-about-detach.test.ts now taps its confirm keys through one typed helper, tap, instead of casting. The test file passes and bun x tsc --noEmit is clean. The cast was the first failure on the list.
I did not fix the size rule. I can't cut three files without dropping part of the feature or moving a file into pipeline code to get around the rule. The 23 files are the undo action, its web, terminal and MCP surfaces, and the tests and docs that follow from the new wording and the changed detachSection signature. Landing it needs either a split (undo and receipts in one pull, the new preview wording in another) or a decision to change the pipeline rule.
I did not touch the two similarity notes: undoSeverSubmit against liftSubmit, and the login helper in test/sever-fork.test.ts against signIn in test/danger-language.test.ts. The gate phrases them as questions ("one implementation?"), not failures. I did not run the full gate or any test file other than test/tui-about-detach.test.ts.
To try it, open a severed fork's Danger page and its main page inside seven days. The Undo button restores following, and a second undo is refused. In the terminal, U opens a confirm and enter applies it.
Severing a fork now previews what stops and who is affected, leaves a receipt, and can be undone for seven days. This pull covers the web only, to get under the gate's 20-file limit. The terminal's U key and the MCP's confirm/undo arguments are left for follow-up pulls. They are not in this one. The pull now changes 18 files.
- Undo:
src/actions/sever_undo.tsholds the preview, the undo and its refusals. The undo is for the repository's admin only. It relinks the parent's objects, restores the parent link and recordsrepo.reattached. If any step fails, the fork stays as the sever left it.relinkForkandunlinkForkinsrc/git/repos.tsdo the relinking. - Web: the confirm and the Danger zone show the same four-row preview, and offers still open at the parent are counted. The fork's home page shows "Undo until …" with an Undo button posting to
/settings/detach/undo, which checks the origin. After the seven days the Settings › Follow upstream link returns. - Tests:
test/sever-fork.test.tscovers the preview, the refusals, the undo, and the seven-day expiry. It also covers the page's receipt and Undo button, and the admin-only check. The existing tests that quote the old "no undo" wording are updated.
Verification: bun x tsc --noEmit is clean. The tests for the web and undo changes pass, 10 across fork-sever.test.ts and sever-fork.test.ts. An earlier run of six related test files passed except the MCP test I then reverted. I did not run the whole suite, since scripts/fast.ts named nearly all of it.
Left out and why:
- MCP:
confirm,undoand the new plan wording. The MCP's sever plan keeps its old text, though the shared "no undo" sentence now says Undo restores following for 7 days. - Terminal: the
Ukey and its confirm screen. - Gate notes: two similarity questions remain.
undoSeverSubmitresemblesliftSubmit, and theloginhelper insever-fork.test.tsresemblessignInindanger-language.test.ts. They are notes, not failures.
To try it, sever a fork you administer, then open its home page. Undo is there for seven days. A second undo, or one from a non-admin, is refused.
The web half is sound: admin-only undo behind adminForm, agents refused, the link is rolled back if the DB write fails, the seven days are enforced, and the tests cover the refusals. It does not meet the issue or the two-doors rule.
First fix: add the MCP arguments (confirm to sever, undo) using severPreview(...).says. Same admin and agent gate as undoSever, plus a test.
- Box 3 is not met. The MCP has no explicit confirm argument and no undo, and its plan still carries the old wording. The pull says this was dropped to get under the 20-file gate. If you need the room, split the pull. Do not ship half the issue under its number.
- Both doors. The terminal has no undo and no preview screen: the About
xconfirm is unchanged and there is noU. What a person can do on the page they must be able to do in the terminal, as a screen in src/tui/. - The shared words now lie on the doors without an undo.
DETACH_AGAIN(src/actions/detach_words.ts), used bydetachPlanWordsfor the terminal and MCP, says "Undo restores following for 7 days". On those doors no Undo exists yet. Fix this together with 1 and 2.
Non-blocking: the login helper in test/sever-fork.test.ts duplicates signIn in test/danger-language.test.ts. The status 403/404/303 set accepted for the non-admin post is loose; assert the one status.
A fork's admin can now sever it from its upstream and undo that the same way on all three doors: the web page, the MCP and the terminal. Each door shows the same preview (severPreview(...).says) first: what stops flowing down (updates) and up (offers, with how many are open), and who is affected. An undo is allowed for seven days. It is an admin's alone and never an agent's.
- Web: Settings › Danger zone › Sever shows the preview before it confirms. The fork's home then shows a receipt, "Severed <when>; undo until <when>", with an Undo link that posts to
/<owner>/<name>/settings/detach/undo. If the database write fails, the link to the parent is put back. The history recordsrepo.detachedandrepo.reattached. - MCP (
detach, orforkwithaction: "sever"): withoutconfirm: trueit only returns the plan, in the preview's words, and changes nothing.confirm: truesevers andundo: truefollows the parent again. Both refuse agent tokens and tokens without admin scope.dryRun: falsestill severs, as it did before. - Terminal (About screen,
src/tui/screens/about.ts):xopens a confirm showing the preview.Uappears only to an admin within the seven days, and asks before it follows again.
Because every door now has an Undo, the shared sentence DETACH_AGAIN ("Undo restores following for 7 days") is true wherever it is shown.
After an undo: the fork borrows the parent's objects again, so whatever the parent changed during the gap arrives as an ordinary update. Offers sent before the sever are listed at the parent again. None could be sent during the gap, because a severed fork has no upstream to offer to.
Review changes:
- The MCP and terminal work is restored (this reverts e49f743a4), so the whole issue lands under its number.
- The test where someone who is not an admin posts the undo now expects exactly 404, since the admin form answers as if the page did not exist.
- I left the
loginhelper intest/sever-fork.test.tsas it was. Sharing it withsignInintest/danger-language.test.tswould mean a new helper file plus an edit to an unrelated test, and the two use different seeded passwords.
Tests and checks: test/sever-fork.test.ts covers the MCP plan, severing only with confirm: true, the undo, and the agent and read-only-token refusals. test/tui-about-detach.test.ts checks that U asks before it acts, that cancelling leaves the fork severed, and that only an admin is offered it. I ran 25 test files covering the MCP tools, the About screen and the fork pages (460 pass, 0 fail). I did not run the full set scripts/fast.ts named, because the change to src/core/repos.ts reaches 3510 test files, an estimated 295 minutes; the forge's check runs them on this push. bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts pass. The gate also notes that undoSeverSubmit in src/web/pages/detach.ts looks like liftSubmit in src/web/pages/releases.ts; that is a note, not a failure.
To try it: on the preview, fork a repository and open Settings › Danger zone › Sever, read the preview and confirm. Then press Undo on the fork's home and check that it follows its parent again. On the MCP, call fork with { repo, action: "sever" } to get the plan, then add confirm: true, and later undo: true. In the terminal, open the fork's About screen and press x, then U.
[{"go":"/<you>/<fork>/settings","look":"Danger zone › Sever from upstream","expect":"the confirm says what stops down (updates), up (offers, with the open count) and who is affected"},
{"go":"/<you>/<fork>","look":"the receipt beside the following card","expect":"Severed <when>; undo until <when>, with an Undo button","ask":"Press Undo: does the fork follow its parent again and show the following card?"}]
🤖 Generated with Claude Code
A fork's admin can now sever it from its upstream and undo that the same way on all three doors: the web page, the MCP and the terminal. Each door shows the same preview (severPreview(...).says) first. It opens with the shared sentence "Updates from the parent and offers to it stop.", then says what stops flowing down (updates), what stops flowing up (offers, with how many are open), and who is affected. An undo is allowed for seven days, only to an admin and never to an agent.
- Web: Settings › Danger zone › Sever lists the preview's rows, and the confirm page says the same text. Afterwards the fork's home shows a receipt, "Severed <when>; undo until <when>", with an Undo button that posts to
/<owner>/<name>/settings/detach/undo. If the database write fails, the link to the parent is put back. The history recordsrepo.detachedandrepo.reattached. - MCP (
detach, orforkwithaction: "sever"): withoutconfirm: trueit only returns the plan and changes nothing.confirm: truesevers andundo: truefollows the parent again. Both refuse agent tokens and tokens without admin scope.dryRun: falsestill severs, as it did before. - Terminal (About screen,
src/tui/screens/about.ts):xopens a confirm showing the preview.Uappears only to an admin within the seven days, and asks before it follows again.
Because every door has an Undo, the shared sentence DETACH_AGAIN ("Undo restores following for 7 days") is true wherever it is shown.
After an undo: the fork borrows the parent's objects again, so whatever the parent changed during the gap arrives as an ordinary update. Offers sent before the sever are listed at the parent again. None could be sent during the gap, because a severed fork has no upstream to offer to.
What to look at: to stay within the gate's 20-file limit, severPreview takes the database rather than the app, like detachSection does. That leaves src/web/pages/danger.ts, test/fork-detach.test.ts and test/fork-sever.test.ts exactly as main has them.
Review changes:
- The test where someone who is not an admin posts the undo now expects exactly 404, since the admin form answers as if the page did not exist.
- I kept the
loginhelper intest/sever-fork.test.ts, which the gate notes is likesignInintest/danger-language.test.ts. Sharing them would need a new helper file and an edit to an unrelated test, which puts the pull back over 20 files, and the two use different seeded passwords. - The gate also notes that
undoSeverSubmitlooks likeliftSubmitinsrc/web/pages/releases.ts; that is a note, not a failure.
Tests and checks: test/sever-fork.test.ts covers the preview, the receipt and Undo on the page, severing on the MCP only with confirm: true, the undo, and the refusals: agents, read-only tokens, a post from someone who is not an admin, and a post from another origin. test/tui-about-detach.test.ts checks that U asks before it acts, that cancelling leaves the fork severed, and that only an admin is offered it. I ran nine test files covering the sever, the detach, the Danger zone, the confirm page, the MCP tools and the About screen (246 pass, 0 fail). bun scripts/gate.ts, bun x tsc --noEmit and bun scripts/design-lint.ts pass. I did not run the full set scripts/fast.ts names, because the change to src/core/repos.ts reaches 3510 test files; the forge's check runs them on this push.
To try it: on the preview, fork a repository and open Settings › Danger zone › Sever, read the preview and confirm. Then press Undo on the fork's home and check that it follows its parent again. On the MCP, call fork with { repo, action: "sever" } to get the plan, then add confirm: true, and later undo: true. In the terminal, open the fork's About screen and press x, then U.
[{"go":"/<you>/<fork>/settings/danger","look":"Sever from upstream","expect":"rows for Stops down, Stops up, Affected and Undo, then the Sever button"},
{"go":"/<you>/<fork>","look":"the receipt beside the following card after severing","expect":"Severed <when>; undo until <when>, with an Undo button","ask":"Press Undo: does the fork follow its parent again and show the following card?"}]
🤖 Generated with Claude Code
Earlier asks are met: agents are refused on every door (checked before scope on the MCP), the preview is four rows with each fact once, the receipt and Undo show on the fork home, a failed undo leaves the sever whole, and the tests cover parent_gone, running, offers, non-admin and cross-origin. The MCP confirm/undo and the terminal U (with a confirm) are restored, so all three doors share severPreview. The how-to is in docs/features/fork-sever.md, not README. The preview answers 200. Non-blocking: the undoSeverSubmit/liftSubmit similarity note.
Severing a fork now shows what stops and who is affected before it happens, leaves a receipt, and can be undone for seven days; the MCP offers the same with
confirmandundo.Checks:
tsc,design-lintand the sever, detach, confirm, danger-zone, About-screen and MCP-size tests pass here. I never ran the full suite ortest/follow-e2e.test.tsand the other follow suites, so a failure there would first show up in the forge's check.gate.tsstill lists one "one implementation?" note on the undo route's handler. It is a similarity warning and I left it, since the route follows the same admin-form pattern as other handlers.What changed
severPreviewinsrc/actions/sever_undo.tsis the one text behind the confirm page, the Danger zone, the terminal and the MCP. It says updates from the parent stop flowing down, offers to it stop going up (with the count of open offers), and who is affected: the fork's owner and crew, the parent's owner, and forks of this fork./:owner/:name/settings/detach/undo.repo.reattachedevent. It is refused after seven days, once already undone, for a non-admin, or if the parent is gone or unreadable to the actor.relinkFork) and restores the parent link. The test that proves this takes updates after an undo, with the parent having moved in between.forktool,action: "sever"only plans.confirm: truedoes it, andundo: truefollows again.dryRun: falsestill severs, so existing callers keep working. I added no new tool.xshows the same preview andUundoes a sever.DETACH_AGAINused to say "no undo"; it now describes Undo. I edited the two assertions that quoted the old sentence, intest/confirm-detach.test.tsandtest/danger-language.test.ts, because those tests were checking old wording.docs/features/fork-sever.mdis updated.What I left out
app.lookspages show a signed-in fork.Try it: sign in, open a fork's Settings › Danger zone, press Sever from upstream and read the preview, confirm, then press Undo on the fork's home.
Review: tests are
test/sever-fork.test.ts(new, 5 tests).🤖 Generated with Claude Code
Closes #15745