provision, docs: replace first recorded and re-pinned
The record-write census re-pins Enable and EnableEnvironment (the same Put). The plan's ruling 6 note records Paul's ruling (replace first as a standing rule for this family; the reap-order extension kept) and case 1, seed 5063.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+8
−1
docs/superpowers/plans/2026-11-13-platform-mail-submission.md+2 −1internal/provision/platform_mail_submission_census_test.go+6 −0
CI passed — run details
diff --git a/docs/superpowers/plans/2026-11-13-platform-mail-submission.md b/docs/superpowers/plans/2026-11-13-platform-mail-submission.md| index 5f5fbe4de..3c946bdcf 100644 |
| --- a/docs/superpowers/plans/2026-11-13-platform-mail-submission.md |
| +++ b/docs/superpowers/plans/2026-11-13-platform-mail-submission.md |
| @@ -83,7 +83,8 @@ Plan choices that are not gaps, for the plan reviewer (each resolves an item on |
| - *The stronger simulation check* (every SMTP key a bundle holds must be live) showed a switch-on that failed after deleting an owned environment's IAM user but before taking the five out of its bundle. The record still named the deleted user, so the next switch-off's `EnableEnvironment` read the bundle as delivered and minted nothing. Fix: before any delivery walk skips a mint because a bundle already holds the recorded key (`Enable`, `EnableEnvironment`, so switch-off's step 1 among them), it asks IAM through a new read, `Provisioner.KeyState` (IAM `ListAccessKeys`; the in-memory fake has it too), and re-mints unless the key exists under that user and is active (or inactive, for a paused sender: a pause deactivates keys on purpose). **An unreadable key state refuses the walk** rather than reading as missing: a switch-off then stops before it writes the switch, so the app stays switched and keeps submitting, whereas reaping and re-minting on a read failure would delete a key running instances may still use. |
| - *Astra's census review of 76f4f582c* (all units accepted; P2-1 and P2-3 resolved, P2-2 partly): `ReapEnvironment` deleted the keys and user before taking the five out of the bundle, so a failed bundle write left a switched app's environment with its From beside a dead key, and a spawn with the switch unreadable took SMTP from it. Fix: the bundle write comes first, then the keys and the user; a re-run finishes the deletion. **The same order is applied to the week-7 reap of the app-level user** (`ReapAppUserAfterSubmission`): the default bundle is made a switched app's (From, none of the five) before the user goes. The seed sweep found that sibling (seed 2009: a switch-on failed after `On:true` with the five still in the default bundle, then the hourly reap deleted the user under them). This applies Paul's ruled order to the second place a switched app's user is deleted, so he should confirm it. |
| - The simulation now checks, at every step, every SMTP key that an instance would use: after a switch-off, and while switched wherever `activator.MailUnknownSubmits` (the agent's own rule for an unreadable switch) picks SMTP. Scripted steps cover a key lost in AWS before a switch-off and a switch-off whose key state is unreadable (refused, still switched). Mutation-checked: without the key check, the lost-key step fails; with the old reap order, the part-failed switch-on (team's write #2) fails; without the week-7 reap's bundle write, seed 2009 fails. |
| - - **Found by a wider sweep, not fixed (same family, for Paul):** seed 5063 (`SUBMISSION_SIM_FIRST=5063 SUBMISSION_SIM_SEEDS=1`, outside CI's default 60 seeds). A switched app whose failed switch-on left the five in the default bundle beside its From is switched off with `MintKey` failing. The Enable walk finds delivery incomplete (here a `_FROM` left stale by a re-declare), and it reaps every key but the pending one before it mints ("reap before minting"), so the delivered key goes and no new one arrives. The switch stays on and instances that read it submit, but an instance started while the agent cannot read the switch takes SMTP from a bundle naming a deleted key. This predates these fixes; the per-step key check is what shows it. |
| + - **Ruled by Paul, 2026-11-14: replace first, as a standing rule for this family; the reap-order extension kept.** Any case in this family where a working credential or channel is removed before its replacement is in place is fixed by putting the replacement in place first and removing after, without asking again; each is listed here. Anything of a different shape still goes to Paul. The week-7 reap's order (settings out of the default bundle before the app-level user is deleted) stays. |
| + - **Replace first, case 1: seed 5063** (found by a 120-seed sweep from 5000, outside CI's default 60). A switched app whose failed switch-on left the five in the default bundle beside its From was switched off with `MintKey` failing. The Enable walk found delivery incomplete (a stale `_FROM`) and, reaping before minting, deleted the key the bundle still named, so the failed mint left the bundle naming a deleted key and an instance started with the switch unreadable took SMTP from it. Fix: `Enable` and `EnableEnvironment` keep the key the bundle names (beside a pending rotation's) through the reap, mint and deliver the new key and record it, and only then delete the old one (`keepBeforeMint`, `retireReplacedKey`). A failed mint leaves the old working key in place. With a rotation pending as well, IAM's two-key ceiling refuses the mint, and the walk fails with both keys kept. Seed numbers do not survive a code change (each door's fault draw counts its store operations, and the fix adds a read), so the witnesses are scripted: the default bundle, and team's bundle, each lose one of the five while their key is live, and the switch-off's mint for that bundle fails. Mutation-checked: without the kept key in either walk, its scripted step fails. |
| The copy review (Task 6 P2-6) is still Paul's; the copy record stays a draft. |
diff --git a/internal/provision/platform_mail_submission_census_test.go b/internal/provision/platform_mail_submission_census_test.go| index 201563a7c..23622d596 100644 |
| --- a/internal/provision/platform_mail_submission_census_test.go |
| +++ b/internal/provision/platform_mail_submission_census_test.go |
| @@ -112,6 +112,12 @@ func platformMailSubmissionWriteCensusInventory() []censusEntry { |
| {"internal/mail/walk.go", "claimUnserializedEnable", "reference", "id:Put", "74ac715f1700b2655a9c34a2ca55afe48704ea0f07154591036cf1855d2498e1"}, |
| {"internal/mail/walk_environment.go", "claimUnserializedEnableEnvironment", "reference", "id:Put", "73d110a93a3b420f444ee051b6e389d874f2431f3be3372e2a68c2c0a613aa9e"}, |
| {"internal/mail/walk_environment.go", "claimUnserializedReapEnvironment", "reference", "id:Put", "12f50770d608d967c3514a31cc2c9520fd8089feaa9d327fd1dd77752c45f0c6"}, |
| + // Ruled by Paul, 2026-11-14 (replace first): Enable and |
| + // EnableEnvironment keep the key the bundle still names until its |
| + // replacement is delivered and recorded, then delete it (a bundle |
| + // read and a DeleteKey; no new record write). The same Put. |
| + {"internal/mail/walk.go", "claimUnserializedEnable", "reference", "id:Put", "d99d41b7291415473e2ee908947e1510c2485f1520b61b9a42b7e903058e1717"}, |
| + {"internal/mail/walk_environment.go", "claimUnserializedEnableEnvironment", "reference", "id:Put", "46bfa7f374d9962703b607d533b0d051f8ab53ae340323d4416d8947c3104e23"}, |
| } |
| for _, r := range repins { |
| found := false |