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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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.

Notes

shipped production is serving it deploy 3fede26

opened this

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. severPreview in src/actions/sever_undo.ts is 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.reattached event. 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 fork tool, action: "sever" only plans. confirm: true does it, and undo: true follows again. dryRun: false still severs, so existing callers keep working. I added no new tool.
  • Terminal. On the repository About screen, x shows the same preview and U undoes a sever.
  • Words. DETACH_AGAIN used to say "no undo"; it now describes Undo. I edited the two assertions that quoted the old sentence, in test/confirm-detach.test.ts and test/danger-language.test.ts, because those tests were checking old wording.
  • Docs. docs/features/fork-sever.md is 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.looks pages 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

Closes #15745

6 earlier comments · 2 events
commented

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. severPreview in src/actions/sever_undo.ts is 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.reattached event. 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 fork tool, action: "sever" only plans. confirm: true does it, and undo: true follows again. dryRun: false still severs, so existing callers keep working. I added no new tool.
  • Terminal. On the repository About screen, x shows the same preview and U undoes a sever.
  • Words. DETACH_AGAIN used to say "no undo"; it now describes Undo. I edited the two assertions that quoted the old sentence, in test/confirm-detach.test.ts and test/danger-language.test.ts, because those tests were checking old wording.
  • Docs. docs/features/fork-sever.md is 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.looks pages 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

commented

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: true only plans: it says what stops and who is affected.
  • confirm: true with an admin token does the sever.
  • The sever leaves a receipt.
  • undo: true follows the parent again within seven days.
  • The MCP detach tool and fork with action: "sever" take confirm and undo.

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 --noEmit is clean.
  • bun scripts/gate.ts --fix changed nothing. It reported only a similarity note between undoSeverSubmit and liftSubmit.
  • 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.ts named 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.

Changes requested — before the latest push

Undo and the preview work, but these need fixing in one round.

  1. (first) MCP undo: true in 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.
  2. 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.
  3. 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.
  4. Tests: the new file never covers the parent_gone and running refusals, the open-offer count, the TUI U key, 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.
  5. TUI U undoes at once with no confirm while x confirms; keep the doors alike.
commented

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): undoSever now refuses agents on every door, and the MCP undo: true checks 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 dl under 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): relinkFork writes the link and cuts it again if keeping the parent's objects fails. undoSever also removes it if the database write or the history append throws. A failed undo leaves the sever whole.
  • Tests (4): test/sever-fork.test.ts and test/tui-about-detach.test.ts now 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 U key.

    The MCP plan assertion now compares the full text for the same viewer.

  • U key (5): U now asks first ("Undo the sever", Undo / Cancel), like x.

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.

commented

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.

commented

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.ts holds 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 records repo.reattached. If any step fails, the fork stays as the sever left it. relinkFork and unlinkFork in src/git/repos.ts do 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.ts covers 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, undo and 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 U key and its confirm screen.
  • Gate notes: two similarity questions remain. undoSeverSubmit resembles liftSubmit, and the login helper in sever-fork.test.ts resembles signIn in danger-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.

Changes requested — before the latest push

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.

  1. 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.
  2. Both doors. The terminal has no undo and no preview screen: the About x confirm is unchanged and there is no U. What a person can do on the page they must be able to do in the terminal, as a screen in src/tui/.
  3. The shared words now lie on the doors without an undo. DETACH_AGAIN (src/actions/detach_words.ts), used by detachPlanWords for 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.

commented

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 records repo.detached and repo.reattached.
  • MCP (detach, or fork with action: "sever"): without confirm: true it only returns the plan, in the preview's words, and changes nothing. confirm: true severs and undo: true follows the parent again. Both refuse agent tokens and tokens without admin scope. dryRun: false still severs, as it did before.
  • Terminal (About screen, src/tui/screens/about.ts): x opens a confirm showing the preview. U appears 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 login helper in test/sever-fork.test.ts as it was. Sharing it with signIn in test/danger-language.test.ts would 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

commented

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 records repo.detached and repo.reattached.
  • MCP (detach, or fork with action: "sever"): without confirm: true it only returns the plan and changes nothing. confirm: true severs and undo: true follows the parent again. Both refuse agent tokens and tokens without admin scope. dryRun: false still severs, as it did before.
  • Terminal (About screen, src/tui/screens/about.ts): x opens a confirm showing the preview. U appears 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 login helper in test/sever-fork.test.ts, which the gate notes is like signIn in test/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 undoSeverSubmit looks like liftSubmit in src/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

Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs