carlos / platform Public

Slice 1 Task 3: review budget exhausted on unserialized address grants; ruling needed Question open

On branch instance-senders-1

Task 3 (address reservations) has used its three Astra rounds. Each found a P1 in the same family: address ownership without serialization. Stopping rules 1, 2 and 8 apply, so a ruling is needed before more work on it.

Why it keeps failing. The production console runs with CARLOS_HOST_CLAIM off. claimMailStore() then returns the bare store, so there is no mail claim gate, and address grants, revokes and recoveries can interleave across handlers. Three mechanisms were tried:

  • Round 1: recovery rolled reservations back. It could orphan a key.
  • Round 2: recovery rolled them forward. An old grant could recreate a key.
  • Round 3: the record became the authority, and keys an index with nonces. A grant paused after its nonce check can consume a later reservation of the same sender, so two senders end up holding one address.

Findings: docs/superpowers/plans/CODEX-FINDINGS-instance-senders-1-T3-R1.md, -R2.md and -R3.md. With the gate on (serialized), all three rounds found nothing wrong.

Options (rule 2):

  • (a) Serialize per app inside the console. Recommended. A sync.Map of per-(account, app) mutexes, held across every address transition, every domain pin or unpin and EnsureDomain's app add. This is the same shape as the relay writer's relayAppLocks (server.go:1641-1650): its lease keeps two consoles apart, and the mutex keeps two handlers of one console apart. The console is the only writer of address keys, and server.go:1376 notes one console process per deployment. With full serialization, the sticky-pin P2 (R3 #3) becomes a simple unpin when the last address goes. A short fourth review would confirm it.
  • (b) Refuse address operations when the gate is off. Safe, but with HostClaim off in production, slice 1 couldn't be used anywhere until host claims ship.
  • (c) Durable reservation generations and fencing. Keep pushing the lock-free design. It needs at least one more round, and the family has already recurred three times.

Tasks 4–8 don't depend on this choice: the exported API (GrantAddress, RevokeAddress, RecoverAddresses) stays the same. I'm continuing with them and leaving Task 3 parked.

Paul's rulings, 2026-11-30, recorded as his:

  1. Option (a), the per-(account, app) console mutex. Implemented in cf32b998b. He approved one fourth review round.
  2. On round 4's findings (docs/superpowers/plans/CODEX-FINDINGS-instance-senders-1-T3-R4.md): apply the fixes with no fifth review round; the whole-branch review before merge verifies them.

Applied in the commit after 6da75e5a7:

  • P1: SwitchOn and SwitchOff hold the same app lock. TestSwitchOffAndCreateSerialize parks a switch-off mid-write and shows that a create waits, then is refused with ErrSubmissionOff.
  • P2, the permanent pin: unpinDomainIfUnused clears AddressApp once the app's last address on the domain is revoked or its sender removed. It holds the domain lock under the app lock, so lock order stays app then domain. Tested.
  • P2, the 300 ms window: TestExportedAddressOpsSerialize now proves the second operation reached the lock by a hook signal, and checks it hasn't finished while the lock is held. It also covers create, cap, per-instance and RemoveDomain.