cert import (#1429): rev 3 records the read order and ReconcileImport
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+33
−20
docs/superpowers/specs/2026-11-25-cert-import-1429-design.md+33 −20
diff --git a/docs/superpowers/specs/2026-11-25-cert-import-1429-design.md b/docs/superpowers/specs/2026-11-25-cert-import-1429-design.md| index 5ed852f5a..f69516a5d 100644 |
| --- a/docs/superpowers/specs/2026-11-25-cert-import-1429-design.md |
| +++ b/docs/superpowers/specs/2026-11-25-cert-import-1429-design.md |
| @@ -102,28 +102,41 @@ field, and those consoles refuse this door. Two acquisitions that collide |
| on all four within one second are the same account and app, so the same |
| authority. |
| -Enforced by three functions in `internal/domains`, each the only |
| -implementation of its decision: |
| +Enforced in `internal/domains/certimport_invariant.go`, each function the |
| +only implementation of its decision. Every one reads the entry's revision |
| +FIRST, then the claim, then acts on that revision only: a claim read |
| +before the entry could judge a successor's entry by a predecessor's |
| +claim (the simulation catches the other order). |
| - **`WriteImport`**, the only writer (the console door calls it). Each of |
| - at most three attempts starts from fresh reads: the claim (refused |
| - unless the caller's account and app hold it, live and exact), then the |
| - object's revision, then a `Put` conditioned on that revision |
| - (create-only when absent). A conflict starts a new attempt from fresh |
| - reads; it never retries with only a fresh ETag. After the `Put` it |
| - re-reads the claim; if the claim no longer matches, or the re-read |
| - fails, it withdraws its own write with `DeleteIfMatch` on the revision |
| - it wrote, and fails. |
| -- **`RemoveImport`**, the operator's remove: read, then `DeleteIfMatch` |
| - on that revision; a conflict re-reads. Never an unconditional delete. |
| -- **`StaleImport`**, the issuer reconcile's only delete decision: stale |
| - when the binding doesn't parse or names another host, when the leaf |
| - expired more than 30 days ago, when the claim was read and is absent, |
| - or when it is present and doesn't match the binding. A claim the |
| - listing named but could not read (`ClaimCache.ListWithUnread`) keeps |
| - the import; a failed listing decides nothing. The reconcile deletes |
| - with `DeleteIfMatch` on the ETag it read, never on an unknown ETag, at |
| - most five a pass, on the issuer only. |
| + at most three attempts starts from fresh reads: the object's revision, |
| + then the claim (refused unless the caller's account and app hold it, |
| + live, exact, with a `created_at`, not quarantined), then a `Put` |
| + conditioned on that revision (create-only when absent). A conflict |
| + starts a new attempt from fresh reads; never a retry with only a fresh |
| + ETag. After the `Put` it re-reads the claim; if it no longer matches, |
| + or the re-read fails, it withdraws its own write with `DeleteIfMatch` |
| + on the revision it wrote, and fails. |
| +- **`RemoveImport(host, account, app)`**, the operator's remove: read the |
| + revision, refuse unless `account`/`app` still hold the claim, then |
| + `DeleteIfMatch` on that revision; a conflict re-reads. Never an |
| + unconditional delete, so a remover on a stale view cannot delete a |
| + successor's import. |
| +- **`StaleImport`**, the only delete decision: stale when the binding |
| + doesn't parse or names another host, when the leaf expired more than |
| + 30 days ago, when the claim was read and is absent, or present and not |
| + matching. An unread claim keeps the import. |
| +- **`ReconcileImport(host)`**, the one place that applies it: entry |
| + revision, then claim, then `StaleImport`, then `DeleteIfMatch`. The |
| + issuer's minute pass uses `ClaimCache.ListWithUnread` only as a |
| + prefilter (which hosts to look at); it never deletes on the cached |
| + view. A failed listing decides nothing; at most five |
| + `ReconcileImport` calls a pass; issuer only. |
| + |
| +Known consequence of second-granular stamps: if an account detaches and |
| +re-attaches the same name to the same app within one second, a |
| +reconcile that read the claim as gone in between may remove the import. |
| +The operator re-imports. (Simulation seed 757.) |
| The generic cert sweep skips `+import` names (it deletes unconditionally), |
| so the reconcile is the only expiry path for imports. |