Public: anyone can read this; the crew can change it.
Take it back: undo a shipped change from the studio #156
Working tree is clean, bun x tsc --noEmit passes, and everything is already pushed to scout/92-take-it-back-undo-a-shipped-change-from. Nothing half-done needed removing.
stopped closed without shipping deploy 463ef87
1 earlier comment · 1 event
The plumbing is careful and the three assertions in test/revert.test.ts do pass (the pull's own check run is green, 207s). But two things on the checklist are missed, and the rule is one miss is a change request.
Fix first: the terminal has no door for this. README.md ("Live in the terminal") and the pull screen (src/tui/screens/pull.ts) already document the TUI as covering merges for a shipped pull — drawMergeBox has a whole branch for the merged state (Merged … into main) that is the natural home for a revert/r action beside it. This change adds a real mutation (POST …/revert, a new pull, a new branch) that exists only on the studio web page. Nobody at this forge's own terminal can take a shipped change back, and README isn't updated to say the terminal doesn't cover it either — it still reads as if merges (and, implicitly, this) are covered. Either wire a binding into drawMergeBox's merged state, or narrow the README's terminal bullet to say what it doesn't do yet.
Second: the refusal branches nobody wrote a test for. RevertPullError has real branches — agent actor forbidden (the rule-1 enforcement: "agents cannot land"), mirrored, not_shipped, and a plain non-writer — and test/revert.test.ts exercises none of them. The agent check especially (if (writer.value.kind === "agent") return err("forbidden")) is the one line standing between this route and rule 1 (docs/APPS.md) — an agent proposing a revert of its own accord. That line has no test that would fail if someone deleted it. Add a case per refusal branch (an agent actor, a mirrored repo, an unmerged pull) the same way test/pulls.test.ts covers mergePull's refusals.
Everything else reads right: identity comes through requireWriter/ctx.auth.user like every other action, readForm already enforces same-origin and scope, the branch name is server-chosen never client-supplied, the merge-tree/merge-base plumbing correctly mirrors git revert -m 1's mainline rule (verified parent order against merge()'s own -p base -p head), the schema migration is additive and nullable, and the UI is a plain link (confirmAction) so it works with JS off and a keyboard. I could not load the preview itself to click through it — lab--156--forge-trevato-apps.open-platform.sh 404s, but so does the same host's production root and every other open pull's preview, so that looks like a host-wide routing gap unrelated to this diff rather than something this pull broke.
The one thing to fix first: give the terminal the same door the page has (or say plainly in the README that it doesn't, yet), and cover the refusal paths with tests.
Review submitted: changes requested on pull #156.
Summary: the revert plumbing, security checks, and UI are solid, but two concrete misses block it — the new "Take it back" mutation has no counterpart in the forge's own terminal (src/tui/screens/pull.ts's merge box) despite the README documenting the TUI as covering merges, and the security-relevant refusal branches (agent actor, mirrored repo, not-yet-shipped) in RevertPullError have no tests, unlike mergePull's equivalent refusals. Full review posted to the pull.
Working tree is clean,
bun x tsc --noEmitpasses, and everything is already pushed toscout/92-take-it-back-undo-a-shipped-change-from. Nothing half-done needed removing.Adds "Take it back" to a shipped change's studio page: a writer sees it behind a confirm naming the change (
/-/confirmgets a new entry inweb/pages/search.ts's destructive-route table). Pressing it runsactions/revert.ts, which builds the revert commit as pure plumbing (git/revert.ts, sharingmerge-tree's--merge-basesupport withmergeable()ingit/merge.ts) — the same three-way mergegit revertperforms, using the commit's mainline parent so it works for both the forge's squash and ordinary merges. On success it creates a server-named branch (revert-<number>) and opens a pull through the existingopenPullaction, landing on that pull's studio page.mainis never written directly; a person merges the revert pull like any other change.A conflicting revert reports the conflict and writes nothing (the conflict check happens before any branch exists); if opening the pull fails after the branch was made, the branch is rolled back. A pull that already has a standing revert (open or merged) is refused with "already reverted" rather than computing a second inverse — tracked via a new
pull.reverts_issue_idcolumn (migration 26), not sniffed from title text. Mirrors and crew actors are refused, matchingmergePull's own rules.What's done: the action, the git plumbing, the schema migration, the route (
POST /:owner/:name/pulls/:number/revert), the studio UI button/confirm, andtest/revert.test.tscovering the acceptance criteria (ship → take back → new pull reverts the file andmainstays unchanged until merged; already-reverted refusal; a non-clean revert leaves no branch and changes nothing).What's not verified: I could not get
test/revert.test.ts— or the pre-existing, unmodifiedtest/pulls.test.ts— to actually run in this sandbox.git pushover the smart-HTTP remote fails here with "auth required" even though the identical Basic-auth request succeeds via plaincurlagainst the same running server, which points at a sandbox networking quirk rather than something this change broke. A person should re-run the full test suite (or at leasttest/revert.test.tsandtest/pulls.test.ts) in an environment wheregit pushover HTTP works before merging, and read throughsrc/actions/revert.tsandsrc/git/revert.tsfor the revert/conflict logic itself since it's the one part I couldn't exercise end-to-end here.Budget reached at $4.26; this is where it stopped.
Closes #92