Public: anyone can read this; the crew can change it.
A forge whose payment lapses sleeps after a grace period, and no webhook ever deletes one #11372
A forge whose payment lapses now goes to sleep after a grace period, and nothing reachable from the webhook deletes its data. The earlier tries failed on test/job-slices.test.ts; the one-line fix was already committed (01925571a) but never got a green check. This push adds a merge of current main (16 commits).
stopped parked by the crew deploy c8dc2c0
4 earlier comments
A forge whose payment lapses now goes to sleep after a grace period, and nothing reachable from the webhook deletes its data. The earlier tries failed on test/job-slices.test.ts; the one-line fix was already committed (01925571a) but never got a green check. This push adds a merge of current main (16 commits). With that merge, gate.ts, tsc --noEmit and the four covering test files pass here: 33 tests, 0 failures. I did not run the full suite; the forge's check does that on this push.
What changed
- Grace: a past-due forge keeps running. Its admins get a pay link, and the operator sees the state on
/forgesand in the terminal screen. The grace length is a setting, default 7 days (src/settings/limits.ts,src/billing/lapse.ts). - After grace, or on cancellation at period end: status becomes
none. The forge is put to sleep, and a wake shows a plain page with what happened, a pay-again button, and how to export the data (src/web/pages/lapsed.ts). The apps stop answering. - Payment resumes: paying again wakes the forge as it was.
- Retention: data is kept at least 30 days after the lapse, also a setting. Removal after that is an admin's explicit action and is never automatic.
- Exempt plans: forges on the free plan or with a
grantedentitlement are untouched. - Where it plugs in: the lapse sleep rides the shared subscription sync (
src/billing/sync.ts), the Stripe webhook (src/http/stripe_hook.ts), and the spawn host and clients (src/spawn/). - Tests:
test/billing-lapse.test.tsdrives active → grace → none → active through the fake provider. It asserts the forge is running in grace, asleep and unwakeable after, and awake again on payment, and that no code path from the webhook removes a forge directory.test/lapse-forges.test.tscovers the/forgesrow. - Docs:
docs/features/billing-lapse.mddescribes the feature, anddocs/MCP.mdis regenerated for the limits tool.
What I chose not to do
- No automatic deletion, and no new delete action. The admin's explicit removal after the retention window already exists.
How to try it
- Run
bun test test/billing-lapse.test.ts. - On a preview, open
/admin/limitsto see the grace and retention settings.
🤖 Generated with Claude Code
I fixed the test/billing-lapse.test.ts failure and pushed. The boot-beside-peer failure is a slow test I did not fix.
test/billing-lapse.test.ts: "the request that met the lapse put the awake forge to sleep" waited on a sleep that the request starts and never awaits. On a loaded machine that sleep can land late or not at all. The test now also callssleepLapsed(app), the same sweep the forge runs on a timer, so the sleep lands whichever comes first. It then asserts the forge is asleep and the wake refused. I also cut the polling wait from ten seconds to two. The file passed three runs in a row andtscis clean; I did not re-run the other lapse test files after this edit.test/boot-beside-peer.test.ts: "healthz answers within 1 s throughout a boot beside a draining forge's batch of 8" is slow, and my change does not touch it. It takes about 32 s here with my branch, and the same 32 s on a fresh checkout oforigin/main. Its loop gives healthz up to 30 s to come up, so a busy shard pushes it over. I left the test and the code alone.
Say so if you want me to loosen that test's wait as a separate change. The forge's check will show whether it fails again.
I pushed a change aimed at the test/billing-lapse.test.ts failure, but I could not reproduce that failure here, so the fix rests on a guess about the cause.
Lapse test failure
- The failure shows up only in the forge's sharded check. It did not appear once in 24 local runs, several of them under CPU load.
- The likely cause is a race. When a request meets a lapsed forge, it starts that forge's sleep without waiting for it. The child leaves the cache straight away, but its database closes a little later. The test saw the child gone and moved on while the close was still running.
src/spawn/host.tsnow records those request-started sleeps, and a newsettleLapseSleeps(app)waits for them to finish. The test calls it before asserting the forge is asleep. This changes which sleeps are tracked, not when the forge sleeps.- Local results:
tsc --noEmitandbun scripts/gate.tsare clean, and the lapse,lapse-forgesandsnapshot-resumetests pass (30 tests, 0 fail). - If it fails again, its error will be in the full check log above the tail you sent; I only had the tail.
Checks-queue failure
- "a new head on a pull stops its running check for the old head" is in
test/checks-queue.test.ts, which this pull does not touch. All 10 tests in that file pass alone here, so I left it as it is.
I merged main into the branch and pushed it. The only conflict was in src/billing/sync.ts.
Both sides touched the end of syncSubscription, so I kept both. After the entitlement is written, a lapsed forge is put to sleep (this pull's change), and then tellPlan runs (from main). The imports for both (sleepChild, lapseOf, tellPlan) are kept too.
bun x tsc --noEmit and bun scripts/gate.ts printed no errors. I ran six billing and lapse test files and all 58 tests passed:
billing-lapseplan-noticestripe-hookstripe-sweeplapse-forgesbilling
scripts/fast.ts named 2253 of 2803 test files for this diff, so I did not run the full set here. The forge's check runs it on this push.
A forge whose payment lapses now goes to sleep after a grace period, and nothing reachable from the webhook deletes its data. The earlier tries failed on
test/job-slices.test.ts; the one-line fix was already committed (01925571a) but never got a green check. This push adds a merge of current main (16 commits). With that merge,gate.ts,tsc --noEmitand the four covering test files pass here: 33 tests, 0 failures. I did not run the full suite; the forge's check does that on this push.What changed
/forgesand in the terminal screen. The grace length is a setting, default 7 days (src/settings/limits.ts,src/billing/lapse.ts).none. The forge is put to sleep, and a wake shows a plain page with what happened, a pay-again button, and how to export the data (src/web/pages/lapsed.ts). The apps stop answering.grantedentitlement are untouched.src/billing/sync.ts), the Stripe webhook (src/http/stripe_hook.ts), and the spawn host and clients (src/spawn/).test/billing-lapse.test.tsdrives active → grace → none → active through the fake provider. It asserts the forge is running in grace, asleep and unwakeable after, and awake again on payment, and that no code path from the webhook removes a forge directory.test/lapse-forges.test.tscovers the/forgesrow.docs/features/billing-lapse.mddescribes the feature, anddocs/MCP.mdis regenerated for the limits tool.What I chose not to do
How to try it
bun test test/billing-lapse.test.ts./admin/limitsto see the grace and retention settings.🤖 Generated with Claude Code
Closes #11140