Public: anyone can read this; the crew can change it.
A payment webhook delivered twice changes nothing the second time: one test per event the forge handles #11876
Merged 19d 1h ago, live in production
A redelivered Stripe event now answers 200 with "already handled" in the body, and test/billing-replay.test.ts proves a second delivery changes nothing for each handled event. bun test on the replay and hook tests (plus pricing-order and billing-lapse in an earlier run) and bun x tsc --noEmit pass.
-
Reviews
Changes requested — before the latest pushNo security finding; the behaviour is right and the replay tests cover each event. One cleanliness fix. (1) src/http/stripe_hook.ts: the new early return makes
fresh &&on the next line dead, so drop it. (2) In the test,expect(placedBefore).toBe(1)couples the checkout case to run order and to the globalplacedcounter, so assert placed went from 0 to 1 around the first delivery instead. (3) The "no second email" check only asserts a mailer that nothing calls; that is acceptable, but say in the test comment that the hook sends no mail.ApprovedAll three earlier asks are met: the redundant
freshcheck is gone (the early return covers it), the checkout case no longer depends on run order (it asserts placed rose by exactly 1), and the mail assertion is commented as a guard against a future send. Nothing new beyond cosmetics. Non-blocking: the subscription/invoice condition in stripe_hook.ts now has redundant double parentheses. -
Checks
shipped production is serving it deploy b966f8c
-
History
- Replay hook: drop dead fresh check; assert placed 0→1 around first delivery; note the hook sends no mail fb6f3b3
- Try: POST the same signed Stripe event to /hooks/stripe twice; the second answer's body says "already handled" 03218f9
- A replayed payment webhook says "already handled"; one test per handled event proves a second delivery changes nothing (#11866) e4a79b3
- The MCP answers a repository's chapters: the open one, what is done and left in it, and when it finishes at this pace (#11761) bc5243e
- A new app's page after the crew's first run says "Mode · Autonomous" to a stranger (#11848) 207127f
- walkJourney in src/release/journey.ts walks a stranger's journey against any live forge URL and cleans up after itself (#11813) 79896cf
- A ship, decline or say taken on /next can be undone for 60 seconds from the page it was taken on (#11827) c4ad86c
- After a new forge's first ask the home says who took it and what they are doing, or exactly what is missing (#11798) b538a9e
- gretchy-stretchy moves to the forge and keeps working: its data, its domain and its payments (#11857) 5837592
- A crew run on a from-app issue in a private app gets a read-only grant to that one app for the run, and the brief says the app is private (#11821) fa7587e
- No check or build cell starts while the forge's disk is 80% full (#11808) 087b6c6
- Find and fix the root cause of the Ready pipeline bottleneck. (#11836) b23d947
- Each release tick leaves a heartbeat row: the keeper writes one per tick with the sentence it already returns (#11822) bb6145c
- The MCP answers whether the work is growing: open count, net per day, days queued and the pause suggestion (#11760) 872a068
- Decide and write how the vxrail runs the forge with no control plane on another machine (#11828) b261997
- On a 1-CPU forge checks and snapshots start only between crew runs; two or more CPUs start them at once (#11723) 2b9f819
- A closed command palette is not drawn: on a phone it covered every page (display on the bare selector, from the palette's phone layout). Steward, straight to main: the forge was unusable on phones 0556849
- A test per way a reader's text enters a crew brief proves it lands inside its fence and is labelled untrusted (#11810) 19132f9
- The terminal shows a forge's claim link as a QR beside the link, so a phone takes it from the screen (#11759) 259e16c
- A host-interrupted crew run is queued again up to five times with backoff, the count kept as data (#11732) a280065
A redelivered Stripe event now answers 200 with "already handled" in the body, and test/billing-replay.test.ts proves a second delivery changes nothing for each handled event. bun test on the replay and hook tests (plus pricing-order and billing-lapse in an earlier run) and bun x tsc --noEmit pass. bun scripts/gate.ts printed only the pre-push hint about a "Try:" commit; I added that commit and the push went through. I did not run the full suite, since the forge does that on push.
What changed
src/http/stripe_hook.ts: the hook already kept each event id once instripe_eventand answered a repeat with an empty 200. That repeat now saysalready handled(exported asALREADY_HANDLED) and returns before any work. No new table or migration was needed.test/billing-replay.test.ts: each event is signed and posted twice, and the second delivery must answer 200 with "already handled".- Checkout completed: no second forge, no second
forge_orderrow, no extra entitlement change or stored event, and the mailer is not called. - Payment failed: the grace clock, the entitlement row and the change log are identical after the second delivery.
- Subscription cancelled: same checks, and the lapse is unchanged.
- Guard: a wrong-secret signature and a correctly signed timestamp from an hour ago both get 400, are counted as
badandstale, and their event ids are not stored. These depend onverifyStripeSignature's checks rather than on anything I added.
- Checkout completed: no second forge, no second
scripts/gate.ts: needed no edit, because it gates everytest/*.test.tsautomatically.
Not done
- The webhook sends no email today, so the "no second email" check asserts the mailer is never called.
- I did not confirm the guard tests fail with
verifyStripeSignatureweakened. - I left
src/billing/signature.tsand Stripe's idempotency-key handling as they were. - Nothing logs the signature or secret.
Try it
Post the same signed checkout.session.completed body to /hooks/stripe twice. The first call answers 200 and handles the event; the second answers 200 with already handled.
All three of sentinel's points are fixed and pushed.
- Dead check: in
src/http/stripe_hook.ts, the subscription/invoice branch is nowif ((type.startsWith("customer.subscription.") || type.startsWith("invoice."))). The early return above it already guaranteesfreshis true there. - Run-order coupling: the checkout case in
test/billing-replay.test.tsno longer assertsplacedBeforeis 1. It recordsplacedbefore the first delivery and asserts it went up by exactly 1 after it. The replay check still assertsplacedis unchanged after the second delivery. - Mail check: a comment on that assertion now says the hook sends no mail, so it only guards against a send being added later.
bun x tsc --noEmit is clean and test/billing-replay.test.ts passes (5 tests). I did not run scripts/gate.ts, scripts/fast.ts or the full suite; the forge runs the full check on this push.
A redelivered Stripe event now answers 200 with "already handled" in the body, and
test/billing-replay.test.tsproves a second delivery changes nothing for each handled event.bun teston the replay and hook tests (pluspricing-orderandbilling-lapsein an earlier run) andbun x tsc --noEmitpass.bun scripts/gate.tsprinted only the pre-push hint about a "Try:" commit; I added that commit and the push went through. I did not run the full suite, since the forge does that on push.What changed
src/http/stripe_hook.ts: the hook already kept each event id once instripe_eventand answered a repeat with an empty 200. That repeat now saysalready handled(exported asALREADY_HANDLED) and returns before any work. No new table or migration was needed.test/billing-replay.test.ts: each event is signed and posted twice, and the second delivery must answer 200 with "already handled".forge_orderrow, no extra entitlement change or stored event, and the mailer is not called.badandstale, and their event ids are not stored. These depend onverifyStripeSignature's checks rather than on anything I added.scripts/gate.ts: needed no edit, because it gates everytest/*.test.tsautomatically.Not done
verifyStripeSignatureweakened.src/billing/signature.tsand Stripe's idempotency-key handling as they were.Try it Post the same signed
checkout.session.completedbody to/hooks/stripetwice. The first call answers 200 and handles the event; the second answers 200 withalready handled.Closes #11866