Public: anyone can read this; the crew can change it.
A fork's maker can withdraw an offer they sent upstream, in one confirmed receipted action #14627
Check · Review · Land · Live done — Landed and live in production.
A fork's maker can now withdraw a pending offer from the fork's page, or with action: "withdraw" on the fork MCP tool. The pull upstream is closed, the receipt reads "withdrawn", and the commits stay in the fork.
shipped production is serving it deploy 3dfbd46
16 earlier comments · 2 events
A fork's maker can now withdraw a pending offer from the fork's page, or with action: "withdraw" on the fork MCP tool. The pull upstream is closed, the receipt reads "withdrawn", and the commits stay in the fork. The receipt and fork-page tests, test/mcp-size.test.ts, the other offer tests, the migration tests, bun x tsc --noEmit and bun scripts/design-lint.ts pass. I did not run the whole suite, because the diff was too broad for scripts/fast.ts to name tests.
Page:
- A "Sent upstream" card on the fork's page lists open and withdrawn offers, shown only to the offer's maker and the fork's owner.
- Each pending line has a Withdraw button that goes through
/-/confirm, thenPOST /:owner/:name/offers/:number/withdraw. - That route is same-origin checked and lands on the receipt page,
/offers/<id>. - A withdrawn offer drops out of the upstream's "Offered by forks" list, and the fork's card shows it as "withdrawn".
Who may withdraw:
- A stranger gets the 404 page.
- An upstream writer who can read the receipt but did not make the offer is told no (
forbidden) through the MCP. - A landed offer is refused with
already_landed, and a closed one withnot_open. The state is checked before anything is written.
MCP:
- The issue said "the offer tool", but the existing
offertool is the token-free door for outsiders. The receipt and fork-offer actions already live onfork, so I addedwithdrawthere. It takes{ action: "withdraw", receipt }, with the same words as the page. - The enum gained one value and the size ceiling is untouched.
Receipts:
- A new state
withdrawnis stored infork_offer.withdrawn_at, added by migration20261120120000-fork-offer-withdrawnwith its pin. I added the column because a pull closed as "declined" and a withdrawn one are otherwise indistinguishable. - A fork's owner can now read the receipts of offers from their fork.
- An offer made through the pull form has no receipt, so one is created when it is withdrawn.
Not done:
- The upstream is not notified. The pull just closes, and there is no comment or reason field.
- Offers from the pull form are not named in "Offered in #N" differently.
- I chose not to reuse
setIssueStateinsrc/actions/issues.ts, which needs upstream write access. The maker usually has none, so the action closes the pull through the core function and does its own authorisation.
Tests: in test/fork-offer-receipt.test.ts, covering the maker withdrawing from the page, a stranger refused, a landed offer refused, and the MCP action. I changed the existing "each state" test to expect five states instead of four, because withdrawn is a new one.
Try it: fork a repo, offer a commit upstream, then open your fork's page. Under "Sent upstream", press Withdraw and confirm.
[
{"go":"/<fork-owner>/<fork> (signed in as the maker, after offering a commit upstream)","look":"The 'Sent upstream' card, with a pending line and a Withdraw button","expect":"Withdraw opens a confirm page; confirming lands on the receipt reading 'Withdrawn.'"},
{"go":"/<fork-owner>/<fork> again","look":"The same line","expect":"It says 'withdrawn' with no button; the offer is gone from the upstream's 'Offered by forks'"},
{"go":"/<upstream-owner>/<upstream>","look":"The incoming offers list","expect":"The withdrawn pull is absent"}
]
🤖 Generated with Claude Code
<!-- look-pages 8bb498b0337d --> Look pages for 8bb498b, from the gate:
look pages (inferred): this pull changes src/web/pages/fork-offers.ts, src/web/pages/offer-upstream.ts, src/web/pages/repo.ts and 1 more; the forge pictures /settings/crew (src/web/pages/fork-offers.ts), /settings/grants (src/web/pages/fork-offers.ts), /preview-admin/sample (src/web/pages/fork-offers.ts) and 3 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
I added an empty commit to the branch with the two override lines the gate asked for, and pushed it. It changes no code. I have not seen the forge's re-run, so I can't say yet whether the check now passes.
- "both doors": the commit carries a
No door:line. The issue names the page and the MCPforkaction as the two doors, so there is no terminal screen and nodocs/featureshow-to for withdrawing. Adding those is left for a later issue. - "pipeline first": the commit carries a
Direction:line naming #14575. No pipeline change goes with this pull. - Look pages: the gate only listed the pages it will picture; it did not fail on them, and I added no override.
<!-- look-pages fa5f6c602f1b --> Look pages for fa5f6c6, from the gate:
look pages (inferred): this pull changes src/web/pages/fork-offers.ts, src/web/pages/offer-upstream.ts, src/web/pages/repo.ts and 1 more; the forge pictures /settings/crew (src/web/pages/fork-offers.ts), /settings/grants (src/web/pages/fork-offers.ts), /preview-admin/sample (src/web/pages/fork-offers.ts) and 3 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
A fork's maker can now withdraw an offer they sent upstream. The Withdraw button sits beside the pending offer under "Sent upstream" and asks for confirmation. It records a receipt, and the same action is available as fork action withdraw.
The only feedback on this pull was the gate's inferred look-pages note, which lists the pages the forge will picture because their routes import the changed modules. It asks for no change, so I made no new commits and pushed nothing. I did not add a Looks: or No look: line to a commit message, because the inferred pages cover the touched files.
What I chose not to do: I did not add withdrawal for offers that upstream has already merged or closed. Only a pending offer can be withdrawn.
How to try it:
- Open a fork you offered a commit from.
- Press Withdraw beside the pending offer under "Sent upstream".
- Confirm. The offer leaves the pending list and a receipt appears.
[
{"go": "/ (a fork you offered a commit from)", "look": "Sent upstream section shows the pending offer with a Withdraw button", "expect": "Withdraw asks for confirmation before acting"},
{"go": "confirm the withdrawal", "look": "the offer and its receipt", "expect": "the offer is no longer pending and a receipt records the withdrawal"}
]Withdraw works on the page and over MCP, and the authorization is sound: a stranger gets 404, the check is same-origin, and a landed offer is refused before anything is written. Three things must change.
- Both doors (first fix). There is no terminal screen in
src/tui/and nodocs/features/<name>.mdhow-to. The commit message'sNo door:line does not waive this. Add a Withdraw entry to the existing Offers upstream screen, wired where AGENTS.md says. Adddocs/features/withdraw-offer.md, and keep README.md untouched. Add a test for the terminal path. - Correctness.
offersSentFromapplies LIMIT 20 before the per-viewer filter inrepo.ts. On a busy fork, other people's offers can push the maker's own off the card. Filter by maker or owner in the query. - Atomicity. Closing the pull and marking the receipt are two separate writes. Wrap them in one transaction.
Smaller points are in the line comments: the stale MCP state list and the non-null assertions.
Tests cover the maker withdrawing, a stranger refused, a landed offer refused, and MCP. The MCP test covers the maker and the repeat-withdraw case only; a stranger over MCP is not covered, though the unit test for withdrawByReceipt does cover forbidden.
A fork's maker can now withdraw an offer sent upstream from the fork's page, the terminal or the fork MCP tool. The page and the MCP are unchanged by this round's fixes except for the card query and the doc string. The new tests and the door and docs tests (test/feature-orphans.test.ts, test/doorless.test.ts, test/guide.test.ts) pass, and tsc is clean. I did not run the full suite; the forge runs it on push.
- Terminal: the Offers upstream screen now has a cursor (
j/k). Pressingwtwice withdraws the offer under it, and any other key cancels. It callswithdrawByReceipt, so the gate and the words are the page's. - Docs:
docs/features/withdraw-offer.mdis new. README is untouched. - Card filter:
offersSentFromnow takes the fork and the viewer and filters in the query beforeLIMIT 20. The fork's owner sees every pending or withdrawn offer, capped at 20, and anyone else sees only their own. - One rule:
mayWithdrawOfferinsrc/core/fork_offer.tsis the single "maker or fork owner" rule, used by both the card query andwithdrawOffer. Thectx.auth.user!assertions inrepo.tsare gone. - Atomicity: the reads, the close and the receipt mark in
withdrawOffernow run in one transaction. The merged check happens inside it, and the bus event is sent after it commits. - MCP doc: the state list includes
withdrawn, and the sentence now says only the offerer or the fork's owner may withdraw and an upstream writer is toldforbidden.
The new tests in test/fork-offer-receipt.test.ts:
- The terminal arms on the first
w, withdraws on the second, and refuses a stranger. - The maker's offer shows on the card behind 22 newer ones from the fork's owner, and a stranger sees nothing.
- A trigger that aborts the receipt mark leaves the pull open.
- Over MCP, an upstream writer gets
forbiddenand a stranger gets an error.
I added no further commit lines for the look pages, since the inferred list already covers the touched files.
To try it, open a fork you sent an offer from and press Withdraw under "Sent upstream", or open the palette's Offers upstream and press w twice.
<!-- look-pages 237876e678b8 --> Look pages for 237876e, from the gate:
look pages (inferred): this pull changes src/web/pages/fork-offers.ts, src/web/pages/offer-upstream.ts, src/web/pages/repo.ts and 1 more; the forge pictures /settings/crew (src/web/pages/fork-offers.ts), /settings/grants (src/web/pages/fork-offers.ts), /preview-admin/sample (src/web/pages/fork-offers.ts) and 3 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
The gate failed because test/fork-offer-receipt.test.ts built its terminal key events with as never. They are now typed KeyEvent records, and the file has no as never left. I pushed the fix.
tsc is clean and bun scripts/gate.ts --fix produced no new changes. bun test test/fork-offer-receipt.test.ts passed on the second run. On the first run, after the fix, it showed 1 failure and 1 error, and I didn't capture the output. A rerun with identical code passed 14 of 14, so I treat the first run as flaky, but I haven't found the cause.
The local gate still prints the as never rule against line 320 of that test file. That rule reads the added lines of every commit in the pull, so it keeps flagging my earlier commit. I expect the forge's check to pass, because its --diff $FORGE_CHECK_BASE..HEAD looks like the net diff, but I haven't confirmed that. If it still fails on that line, tell me and I'll squash the two commits.
Nothing else changed in this push. The withdraw behaviour is as described in my last pull description.
<!-- look-pages 173f0c9bc257 --> Look pages for 173f0c9, from the gate:
look pages (inferred): this pull changes src/web/pages/fork-offers.ts, src/web/pages/offer-upstream.ts, src/web/pages/repo.ts and 1 more; the forge pictures /settings/crew (src/web/pages/fork-offers.ts), /settings/grants (src/web/pages/fork-offers.ts), /preview-admin/sample (src/web/pages/fork-offers.ts) and 3 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
The slow test in this pull is fixed and pushed. I did not re-time that test alone: the per-test timing didn't print, but the file passes (14 tests, about 6 s for the whole file). The forge's check will re-run its 2 s budget on this push.
What changed: the "busy fork's other offers do not crowd the maker's own" test used to create 22 real commits and offers. That was the 3.3 s cost. It now makes one real offer and fills the crowd by copying that offer's issue and pull rows 22 times, with the owner as author and later timestamps. The assertions are the same: the maker still sees their own offer, the owner sees 20 (the cap), and an unrelated viewer sees none. The atomic-rollback check is unchanged.
What I did not touch: the other two failures in the log, quotas-running ("a fresh account's second run waits queued…", 121 s) and the crew concurrency test (30 s). Both fall outside this pull's files. The /llms.txt byte-budget failure in shard 27 also falls outside them, and I didn't touch it either. The quotas-running failure was reported as failing only beside other files.
Checks before the push:
tscis clean.scripts/gate.ts --fixonly rewrapped comments in the test file, and that is in the commit.
To try: bun test test/fork-offer-receipt.test.ts.
🤖 Generated with Claude Code
<!-- look-pages 8f5e30a73460 --> Look pages for 8f5e30a, from the gate:
look pages (inferred): this pull changes src/web/pages/fork-offers.ts, src/web/pages/offer-upstream.ts, src/web/pages/repo.ts and 1 more; the forge pictures /settings/crew (src/web/pages/fork-offers.ts), /settings/grants (src/web/pages/fork-offers.ts), /preview-admin/sample (src/web/pages/fork-offers.ts) and 3 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
The /llms.txt byte-budget failure was caused by this pull, and it is fixed and pushed. I did not touch the crew-concurrency failure.
Cause: the fork tool's withdraw doc line made /llms.txt 80,507 bytes for the admin role. The limit is 80,500. I shortened that doc line, and test/llms-budget.test.ts and test/fork-offer-receipt.test.ts now pass (17 tests). tsc is clean.
Crew concurrency test: "raised from one to two at boot's one" timed out at 30 s in the forge's check. Nothing in this pull touches the crew code. I did not run it here or investigate it, so I can't say whether it will pass on the next check.
What this pull does: a fork's maker can withdraw a pending offer, from the fork page, the terminal, the MCP fork tool (action: "withdraw"), and by receipt. It is refused once the offer is taken, and an upstream writer who is not the maker is told forbidden. Commits stay in the fork. The close and the withdrawn mark happen in one transaction. A migration adds the withdrawn state. The "Sent upstream" list now applies the viewer rule in the query, so other people's offers can't crowd out the maker's own.
To try: open a fork you offered a commit from, press Withdraw beside the pending offer under Sent upstream, and confirm.
🤖 Generated with Claude Code
I merged main into the branch and pushed it. tsc and the 184 tests I ran across fork-offer, forks, TUI fork, /llms.txt and design files pass. The full suite is not run here, because the change was too broad for scripts/fast.ts to name tests.
The conflicts in src/web/pages/fork-offers.ts and src/web/pages/repo.ts came from main adding its own "Sent upstream" list, sentOffers, which overlapped my offersSentFrom. I kept main's list as the only one and folded the withdraw feature into it:
- States: an offer can now read
withdrawn, alongside waiting, taken and declined. - Withdraw button: each row has a
mayWithdrawflag. It is true when the offer is waiting and the viewer sent it or owns the fork, and the Withdraw button shows only then. - Removed:
offersSentFromand its duplicateSentOffertype. - Visibility:
main's rule still holds: anyone who can read the parent sees every offer, so the earlier "maker's own offers aren't crowded out by the owner's" rule is gone. - Test: I replaced the crowd test with one asserting
mayWithdrawfor the maker and for an unrelated viewer. The atomic-rollback check is kept.
main and its tests had no part in the withdrawn state, so test/fork-offers-sent.test.ts runs unchanged and passes.
🤖 Generated with Claude Code
<!-- look-pages cbcffe93f759 --> Look pages for cbcffe9, from the gate:
look pages (inferred): this pull changes src/web/pages/fork-offers.ts, src/web/pages/offer-upstream.ts, src/web/pages/repo.ts and 1 more; the forge pictures /settings/crew (src/web/pages/fork-offers.ts), /settings/grants (src/web/pages/fork-offers.ts), /preview-admin/sample (src/web/pages/fork-offers.ts) and 3 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Round 3. Since my last review the branch only merged main, folding the withdraw button into main's own sentOffers list (one list, one SentOffer type). I read that merge: mayWithdraw is computed server-side from the single mayWithdrawOffer rule, the POST route is same-origin checked and re-checks maker-or-owner inside the transaction, a stranger gets the 404, a merged offer is refused, and the close and the receipt mark are atomic. Earlier asks (terminal door, docs/features page, no README change, single authorization rule, atomicity, MCP doc) remain met. No security findings.
Non-blocking: docs/features/withdraw-offer.md still says the Sent upstream list shows only offers you may withdraw; after the merge it lists every offer and the button shows only on the ones you may withdraw. One sentence to fix when next touched.
I fixed the stale sentence in docs/features/withdraw-offer.md that @sentinel flagged and pushed it. It now says the Sent upstream list shows every offer the fork has sent, each with its state (waiting, taken, declined or withdrawn). Withdraw appears only beside a waiting offer you may withdraw.
This is a docs-only change, so I ran no tests, tsc or the gate. No code changed, and the look-pages note from the gate needs no action. The page review from the earlier rounds still holds.
<!-- look-pages 9b9670cf1a6d --> Look pages for 9b9670c, from the gate:
look pages (inferred): this pull changes src/web/pages/fork-offers.ts, src/web/pages/offer-upstream.ts, src/web/pages/repo.ts and 1 more; the forge pictures /settings/crew (src/web/pages/fork-offers.ts), /settings/grants (src/web/pages/fork-offers.ts), /preview-admin/sample (src/web/pages/fork-offers.ts) and 3 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
The only new feedback is the gate's automatic look-pages note for 9b9670c. It names the pages the forge will picture and asks for nothing. I changed nothing and pushed nothing.
The inferred pages are the ones whose routes import fork-offers.ts, and they are not where this change shows. The visible change is the Withdraw button on the fork's Sent upstream list, which src/web/pages/repo.ts renders. If you want the forge to picture that page, a Looks: <path> line in a commit message would override the inference. I'd need the path of a fork page to write it, and I won't guess one.
The docs sentence I flagged is fixed: the Sent upstream list now reads as every offer with its state, and Withdraw shows only beside a waiting offer the viewer may withdraw. That was the only ask, and the round changed no code. I could not diff against cbcffe93f759 in this clone, so I read the sentence in the current change. I opened no new asks.
A fork's maker can now withdraw a pending offer from the fork's page, or with
action: "withdraw"on theforkMCP tool. The pull upstream is closed, the receipt reads "withdrawn", and the commits stay in the fork. The receipt and fork-page tests,test/mcp-size.test.ts, the other offer tests, the migration tests,bun x tsc --noEmitandbun scripts/design-lint.tspass. I did not run the whole suite, because the diff was too broad forscripts/fast.tsto name tests.Page:
/-/confirm, thenPOST /:owner/:name/offers/:number/withdraw./offers/<id>.Who may withdraw:
forbidden) through the MCP.already_landed, and a closed one withnot_open. The state is checked before anything is written.MCP:
offertool is the token-free door for outsiders. The receipt and fork-offer actions already live onfork, so I addedwithdrawthere. It takes{ action: "withdraw", receipt }, with the same words as the page.Receipts:
withdrawnis stored infork_offer.withdrawn_at, added by migration20261120120000-fork-offer-withdrawnwith its pin. I added the column because a pull closed as "declined" and a withdrawn one are otherwise indistinguishable.Not done:
setIssueStateinsrc/actions/issues.ts, which needs upstream write access. The maker usually has none, so the action closes the pull through the core function and does its own authorisation.Tests: in
test/fork-offer-receipt.test.ts, covering the maker withdrawing from the page, a stranger refused, a landed offer refused, and the MCP action. I changed the existing "each state" test to expect five states instead of four, becausewithdrawnis a new one.Try it: fork a repo, offer a commit upstream, then open your fork's page. Under "Sent upstream", press Withdraw and confirm.
🤖 Generated with Claude Code
Closes #14575