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

Merged opened this

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

Merged

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.

Notes

shipped production is serving it deploy 6521495

opened this

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, then POST /: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 with not_open. The state is checked before anything is written.

MCP:

  • The issue said "the offer tool", but the existing offer tool is the token-free door for outsiders. The receipt and fork-offer actions already live on fork, so I added withdraw there. 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 withdrawn is stored in fork_offer.withdrawn_at, added by migration 20261120120000-fork-offer-withdrawn with 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 setIssueState in src/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

Closes #14575

Show 10 earlier items

7 earlier comments · 1 event
commented

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:

  • tsc is clean.
  • scripts/gate.ts --fix only 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

commented

<!-- 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
commented

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

commented

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 mayWithdraw flag. 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: offersSentFrom and its duplicate SentOffer type.
  • 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 mayWithdraw for 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

commented

<!-- 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
Approved — before the latest push

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.

commented

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.

commented

<!-- 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
commented

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.

Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs