carlos / platform Public

docs: store versioning design (#1372)

Opt-in versioning for app, environment and private stores, with a
platform-owned noncurrent-version lifecycle (30 days default and floor),
a store credential that cannot destroy history by any route, owner
status and a copy-based restore. Refuses media conversion and browser
uploads on a versioned store, and non-AWS backends.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev c0ae07362272c333a58ac5475047597560de64c3 parent 74aeb27
1 file changed, +565 −0
  • docs/superpowers/specs/2026-11-22-store-versioning-design.md +565 −0
diff --git a/docs/superpowers/specs/2026-11-22-store-versioning-design.md b/docs/superpowers/specs/2026-11-22-store-versioning-design.md
new file mode 100644
index 000000000..5ec4fcd90
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-22-store-versioning-design.md
@@ -0,0 +1,565 @@
+# Store versioning: opt-in object history with platform-owned retention
+
+**Date:** 2026-11-22 · **Status:** DRAFT, built on its branch; review round 1 not yet run ·
+**Branch:** `store-versioning` from `origin/main` `74aeb271c` ·
+**Author:** Claude Opus 5.5, for Paul · **Discussion:** carlos/platform #1372.
+
+**Review history (stopping rules apply).** None yet. Round 1 is an
+independent review from the other model family (Astra for a Claude
+author), briefed from `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`.
+The census card for this branch is
+`docs/superpowers/notes/census-proposal-store-versioning.md`; it needs the
+same reviewer's verdict (AGENTS.md, "The census").
+
+**Builds on:** the object-storage primitive (`internal/objstore`, its
+walks and `storePolicyJSON`), per-environment stores
+(`2026-09-19-per-environment-store-design.md`), instance private storage
+(`2026-09-22-instance-private-storage-design.md`), browser uploads and media
+conversion (`2026-11-16-video-conversion-design.md` §5.2, §5.6, §11 A3/A4),
+and the store sizing sweep (`internal/console/economicspass.go`).
+
+**Stopping rule 5.** Who asks: Slopbox (Paul, 2026-11-22: "we build this
+ourselves, here, as a platform feature"). What they get: a Slopbox box's
+sealed blobs and the root app's keyring records survive a GC bug or a stolen
+store credential for 30 days. When it switches on: Slopbox opens signups to
+anyone but Paul only once this lands (Slopbox Plaza design §11.3, gap C1),
+so it switches on at the first Carloku deployment of Slopbox. The deployment
+switch (`store_versioning`, `CARLOS_STORE_VERSIONING`) is off by default and
+the doors refuse until an operator turns it on.
+
+---
+
+## 1. The problem
+
+A store's bucket is unversioned today. `storePolicyJSON` says so in a comment
+(`internal/objstore/aws.go:220-223`: "Nothing here ever calls
+PutBucketVersioning"). So any `DeleteObject` or overwrite by the store's own
+credential is final. Two things can issue one:
+
+1. **A bug in the app.** Slopbox stores sealed write-once blobs under random
+ ids and garbage-collects them after a grace period. A refcount bug in GC
+ deletes ciphertext nobody can rebuild.
+2. **A stolen store credential.** The credential is delivered into the app's
+ environment (`CARLOS_STORE_*`). Whoever reads that environment can delete
+ or overwrite every object in the bucket.
+
+Bucket versioning turns both into recoverable events: a delete leaves a
+delete marker, and an overwrite leaves the old bytes as a noncurrent
+version. It helps only if three more things hold, and they are most of this
+design:
+
+- the history ages out on a rule the platform owns, so a versioned bucket's
+ bill is bounded;
+- the store's own credential cannot destroy history by any route: not by
+ deleting a version, not by changing the lifecycle, not by suspending
+ versioning, not by writing a bucket policy;
+- the owner can see that it is on, and can get an object back, with the
+ `carlos` CLI alone (AGENTS.md, "Operate via API and CLI").
+
+## 2. The design in one paragraph
+
+A store record gains an additive `versioning` block: whether versioning is
+wanted, and how many days noncurrent versions are kept (30 by default). The
+grant walk converges the bucket to it: one platform-owned lifecycle rule
+(noncurrent versions expire after `keep_days`, expired delete markers are
+cleaned up), then versioning Enabled. On a new store that happens before the
+first credential is minted, so a credential to a versioned store never
+reaches a bucket that is not versioned yet. Every store user's inline policy
+gains an unconditional Deny on every action that can destroy a version or
+change the bucket's versioning, lifecycle or policy, and the permissions
+boundary already allows none of them. The console role gets a new, switched,
+customer-managed grant (`store_versioning`) with exactly the calls the walk,
+the sweep, teardown and restore make. A person turns versioning on or off
+with `carlos store versioning`; anyone with the store verbs lists an object's
+versions with `carlos store versions` and restores one with
+`carlos store restore`, which copies the old version back as a new current
+version and never deletes anything. Teardown empties every version before it
+deletes a versioned bucket, the sizing sweep counts every version, and media
+conversion and browser uploads refuse a versioned store, as they already
+refuse any bucket that has ever been versioned.
+
+## 3. Decisions
+
+1. **Opt-in per store, on every kind of store.** The app's own store, an
+ environment store, and an instance's private store are all the same
+ record (`objstore.KeyIn`), so all three take the same block. Settable at
+ create (`carlos store create --versioning`; for private stores, the app's
+ instances manifest, §6.3) and on an existing store (`carlos store
+ versioning on`).
+2. **Retention is platform-owned and bounded.** `keep_days` defaults to 30,
+ may be set from 30 to 365, and can never be lowered on an existing store
+ (§5.2). The rule never sets `NewerNoncurrentVersions`, so overwriting an
+ object many times cannot push its oldest version out early.
+3. **Off is a suspend, not an erase.** S3 cannot un-version a bucket.
+ `carlos store versioning off` sets Suspended and keeps the lifecycle
+ rule, so every version that already exists is still kept for `keep_days`
+ after it became noncurrent. Only objects written after "off" lose
+ protection. The block is never removed once written, because teardown and
+ the sizing sweep need to know a bucket may hold versions.
+4. **The store credential cannot destroy history, by any route** (§4). The
+ property is stated as "this credential cannot destroy a version", not as
+ "this action is absent from the Allow", and the MinIO contract test
+ checks it against a real server (§9.3). Explicit Denies, unconditional,
+ on every store, versioned or not.
+5. **Turning versioning on or off is a person's act.** The setter door takes
+ no service credential (`svcrole.Set{}`), so an app holding an Admin
+ service token cannot weaken its own store. Status, the version listing
+ and restore take Admin, like every other store verb: none of them can
+ remove anything.
+6. **Restore copies, never deletes.** A restore is a server-side
+ `CopyObject` of the chosen version onto the same key, making a new
+ current version. The version it replaced becomes noncurrent and is kept
+ like any other. Deleting a delete marker or a newer version would also
+ bring an object back, but it destroys a version, and a restore must not.
+7. **Versioned stores are refused by media conversion and browser uploads**
+ (§7). Conversion already refuses any bucket that has ever been versioned
+ (`storecfg.Verify`'s `versioning` check), and both features own the
+ bucket's lifecycle configuration. The refusal is both ways and stated up
+ front. Turning versioning on is therefore final for conversion on that
+ store; the docs say so.
+8. **AWS S3 only.** A console with `CARLOS_STORE_VERSIONING=1` and
+ `CARLOS_STORE_ENDPOINT` set refuses to boot (§8). On an S3-compatible
+ backend the store users are still AWS IAM users (`NewAWSProvisioner`'s
+ doc comment), so nothing would enforce §4 on the bucket's own server.
+9. **Versioned bytes are billed.** The sizing sweep lists every version of a
+ versioned store (`ListObjectVersions`), so noncurrent versions count
+ towards the store's size, its MB-day meter and its plan's storage limit
+ exactly as current objects do (§6.5).
+
+## 4. What the store credential can and cannot do
+
+### 4.1 Every route that destroys or hides a version
+
+The repo has paid for stating a rule as an absence (AGENTS.md, "A rule stated
+as an absence ... cannot see a second door"). So here is every route by which
+a principal with the store user's policy could make a noncurrent version
+unrecoverable before `keep_days`, and what closes it.
+
+| Route | Authorised as | Closed by |
+| --- | --- | --- |
+| `DeleteObject` with `versionId` | `s3:DeleteObjectVersion` | not in the boundary; explicit Deny |
+| `DeleteObjects` naming `VersionId` | `s3:DeleteObjectVersion`, per key | the same |
+| Replace the lifecycle with a short expiry | `s3:PutLifecycleConfiguration` | not in the boundary; explicit Deny |
+| Suspend versioning, then overwrite | `s3:PutBucketVersioning` | not in the boundary; explicit Deny. (Even then, only versions written after the suspend are exposed.) |
+| A bucket policy granting the user itself more | `s3:PutBucketPolicy` | not in the boundary; explicit Deny. A same-account resource policy naming the user is not limited by its permissions boundary, so this one matters. |
+| Delete the bucket policy the platform might write | `s3:DeleteBucketPolicy` | explicit Deny |
+| Object Lock settings that block the platform's own expiry or teardown | `s3:PutBucketObjectLockConfiguration`, `s3:PutObjectRetention`, `s3:PutObjectLegalHold`, `s3:BypassGovernanceRetention` | not in the boundary; explicit Deny |
+| Replicate the bucket elsewhere and lose the original | `s3:PutReplicationConfiguration` | explicit Deny |
+| Delete the bucket | `s3:DeleteBucket` | not in the boundary; explicit Deny; S3 also refuses a non-empty bucket |
+| `PutObject` / multipart complete / `CopyObject` over a key | `s3:PutObject` | not destructive: versioning keeps the old bytes |
+| `DeleteObject` without a version | `s3:DeleteObject` | not destructive: it writes a delete marker |
+| Flood a key with versions so the oldest expires | no action | the rule has no `NewerNoncurrentVersions` |
+| Shorten `keep_days` | the setter door | person-only, and `keep_days` can never be lowered (§5.2) |
+| Turn versioning off | the setter door | person-only; and off keeps history (decision 3) |
+
+The Denies go into `storePolicyJSON` unconditionally, for every store,
+versioned or not, as the anti-forgery pair already does: an explicit Deny
+costs nothing where the permission was already absent, and it holds on a
+backend whose own policy engine reads an action differently from AWS's.
+`storePolicyJSON` changes for every store, picked up on its next grant
+re-walk; the policy stays well inside IAM's 2,048-character inline limit
+(`TestStorePolicyFitsInlineLimit`).
+
+The permissions boundary (`infra/modules/region-host`,
+`store_boundary_statements`) does not change. It allows none of the actions
+above, and `store_versioning.tftest.hcl` asserts that it never does.
+
+### 4.2 What the credential still can do
+
+Read, write and delete current objects, exactly as today. It cannot list or
+read old versions: `s3:ListBucketVersions` and `s3:GetObjectVersion` are not
+granted, so an app cannot restore on its own. That is a follow-up if an app
+asks for it (§11); the boundary would have to grow, which is its own review.
+
+## 5. The record and the bucket
+
+### 5.1 The block
+
+```json
+"versioning": {
+ "enabled": true,
+ "keep_days": 30,
+ "at": "2026-11-22T10:04:05Z",
+ "by": "paul@example.com"
+}
+```
+
+`objstore.Versioning{Enabled bool; KeepDays int; At time.Time; By string}`,
+pointer field `Versioning *Versioning json:"versioning,omitempty"` on
+`objstore.Record`. Additive: `release.PurgeApp`'s local struct ignores it
+(`TestPurgeGuardIgnoresVersioningBlock`, beside the scanning and conversion
+twins). Absent means "never asked for", and is how every store written
+before this change parses.
+
+The record says what is wanted; the bucket says what is true. There is no
+"applied" field: `carlos store versioning status` reads the bucket and
+compares, as `carlos store uploads status` does.
+
+### 5.2 Rules on writing it
+
+- `keep_days` is from 30 to 365. 30 is the default and the floor, so a store
+ can never keep less history than the platform promises.
+- On an existing block, a new `keep_days` lower than the current one is
+ refused (`keep_days_lowered`). Raising it is allowed. This is what stops a
+ stolen session from shortening history to the floor and waiting; it can
+ only lengthen it, which costs money and destroys nothing.
+- `enabled: false` on a store with no block writes nothing and answers
+ "never on". There is nothing to suspend.
+- The block is never deleted, by any door. Teardown deletes the record last,
+ as ever.
+
+### 5.3 The lifecycle rule
+
+One rule, `ID: carlos-noncurrent-versions`, whole bucket (empty prefix
+filter), Enabled:
+
+- `NoncurrentVersionExpiration { NoncurrentDays: keep_days }`;
+- `Expiration { ExpiredObjectDeleteMarker: true }`, which removes a delete
+ marker once no version is left under it (nothing is left to restore).
+
+No `NewerNoncurrentVersions`, no transitions, no abort-multipart action.
+`PutBucketLifecycleConfiguration` replaces the whole configuration, so the
+walk reads the bucket's configuration first and writes only when it holds
+nothing or exactly this one rule (any `keep_days`). Anything else, such as an
+operator's rule on an adopted bucket or browser uploads' multipart rule, is
+refused with `objstore.ErrLifecycleInUse` and nothing is written. The
+platform never replaces a lifecycle rule it did not write.
+
+### 5.4 Converging the bucket
+
+`Versioner.EnsureVersioning(ctx, bucket, want)`:
+
+1. read the lifecycle configuration; refuse a foreign one (§5.3);
+2. if it is not exactly the rule for `want.KeepDays`, write it;
+3. `PutBucketVersioning` Enabled, or Suspended when `want.Enabled` is false.
+
+The rule goes first. Versioning Enabled with no rule would keep every
+version forever; the rule with versioning still off costs nothing. Every
+step is idempotent, so a half-failure is repaired by running it again.
+
+## 6. The walks
+
+### 6.1 Grant
+
+`GrantIn` converges versioning for a record with a block, at one of two
+points:
+
+- **a provisioned store** (re-walk): right after `EnsureUser`, before the
+ idempotence short-circuit, so a healthy store's re-walk still converges it
+ (the same placement, and the same reason, as the policy);
+- **a new store**: right after `EnsureBucket` and before the key is minted,
+ so the first credential is delivered only into a versioned bucket.
+
+A provisioner that is not a `Versioner` fails the walk with
+`ErrVersioningUnsupported` before it mints anything. The doors refuse that
+case first (§8), so this is the backstop.
+
+`ConvergeVersioningIn(ctx, s, p, acct, app, env)` is that step alone, for a
+provisioned store, like `ConvergePolicyIn`: it never mints, reaps or
+delivers. The setter door uses it.
+
+### 6.2 Teardown
+
+A record with a block may hold versions and delete markers, and S3 refuses
+to delete a bucket that holds either. `TeardownIn` therefore calls
+`Versioner.EmptyVersions(ctx, bucket)` instead of `EmptyBucket` for such a
+record: a paginated `ListObjectVersions`, and `DeleteObjects` naming every
+version id and delete marker, in batches of 1,000, surfacing per-key errors
+as `EmptyBucket` does. A provisioner that is not a `Versioner` refuses, and
+the record is left exactly as found, as for a missing scanner. Teardown is
+the owner's explicit destroy (a passkey door), so emptying history there is
+what was asked for; it is the only path that deletes a version.
+
+A bucket versioned by hand (no block) fails at `DeleteBucket`
+(`BucketNotEmpty`) with the record intact, as it does today. That is the
+safe direction.
+
+### 6.3 Private stores
+
+An instance's private store is declared by `instanceStoreProvisionFor`, not
+by a person. The app's instances manifest gains
+`store_versioning bool json:"store_versioning,omitempty"` (`provision.Manifest`,
+beside `PrivateStorage`), set with
+`carlos instances enable --private-storage --store-versioning`. When it is
+set, a private store this door declares for the first time is declared with
+`versioning: {enabled: true, keep_days: 30}`, so the grant walk that follows
+versions its bucket before the instance gets a credential. Existing private
+stores are not touched; `carlos store versioning on --app <a> --environment
+<e>` turns one on.
+
+Turning the manifest flag on is a person's act (the enable door already takes
+no service credential) and is refused when the deployment cannot version
+stores. Turning it off is never refused, matching `--private-storage=false`.
+A plain bool for the reason `PrivateStorage`'s comment gives: it is read at
+one door, at create time.
+
+### 6.4 Restore and the version listing
+
+`Versioner.ListVersions(ctx, bucket, key, max)` lists one key's versions,
+newest first: version id, whether it is current, whether it is a delete
+marker, size, and last-modified time. `ListObjectVersions` with `Prefix:
+key`, keeping only entries whose key is exactly `key`, at most 100.
+
+`Versioner.RestoreVersion(ctx, bucket, key, versionID)` is `CopyObject` with
+`CopySource: bucket/key?versionId=versionID`, `MetadataDirective: COPY` and
+`TaggingDirective: REPLACE` with no tags. The new current version carries no
+scan verdict, so the scanner judges it again; the console role needs no
+tagging permission for it. The door refuses, before copying: a version id
+that is not one of the key's versions (`no_version`), a delete marker
+(`delete_marker`), the version that is already current (`already_current`),
+a version over 5 GiB, `CopyObject`'s limit (`too_large`), and a store whose
+uploads are denied for its plan (`writes_denied`).
+
+### 6.5 Sizing
+
+`sizeStore` takes the record's block into account: a store with one is
+sized by summing the `Size` of every version `ListObjectVersions` returns
+(delete markers have none). The figure is still integer bytes from one daily
+sweep. A deployment with versioning switched on and then off at the IAM layer
+cannot list versions; the sweep then marks the store unswept, which `status`
+already says, rather than undercounting it.
+
+## 7. Media conversion and browser uploads
+
+- `carlos store versioning on` refuses a store whose record has a
+ `conversion` block (`store_in_use_by_media`): it has been verified for
+ conversion or has browser uploads, and both need versioning off and own
+ the lifecycle configuration.
+- `mediaStoreEligible` refuses a record with a versioning block before it
+ trusts a recorded verification (`store_unverified` with the `versioning`
+ check). A fresh verification already refuses such a bucket in
+ `storecfg.Verify`. Browser uploads go through the same check.
+- Both refusals are stated in `docs/site/media-conversion.md` and in the
+ `carlos store versioning` docs.
+
+Making the two compatible (one lifecycle configuration holding both rules,
+and a conversion engine that tolerates versions) is out of scope.
+
+## 8. Deployment switch and IAM
+
+### 8.1 The console
+
+`CARLOS_STORE_VERSIONING=1` sets `objstore.Deployment.Versioning`
+(`cmd/console` `storeBackend`, `storeVersioningOn`; it rides on the
+deployment rather than a new `console.Config` field because `serve` is at
+its code-health line ceiling). The walks never read it: a store's own record
+says whether it is versioned. Boot refuses it
+without `CARLOS_STORE_BACKEND`, and with `CARLOS_STORE_ENDPOINT` set
+(decision 8). Without it every new door answers 503
+`versioning_not_configured`, `carlos store create --versioning` and
+`carlos instances enable --store-versioning` are refused the same way, and
+nothing else changes: a store with a block is still torn down and sized
+correctly as long as the IAM grant is present.
+
+### 8.2 The host role: `store_versioning`
+
+A new `region-host` variable, `store_versioning` (bool, default false), and a
+customer-managed policy `<iam_name>-store-versioning` attached to the host
+role, because the role's inline policies are near IAM's 10,240-character
+total (the same reason as `host_store_conversion`). Exactly the calls the
+code makes, by the action that authorises each:
+
+| Call | Action | Resource |
+| --- | --- | --- |
+| `GetBucketVersioning` | `s3:GetBucketVersioning` | `arn:aws:s3:::<prefix>*` |
+| `PutBucketVersioning` | `s3:PutBucketVersioning` | the same |
+| `GetBucketLifecycleConfiguration` | `s3:GetLifecycleConfiguration` | the same |
+| `PutBucketLifecycleConfiguration` | `s3:PutLifecycleConfiguration` | the same |
+| `ListObjectVersions` (sweep, listing, teardown) | `s3:ListBucketVersions` | the same |
+| `DeleteObjects` with version ids (teardown) | `s3:DeleteObjectVersion` | `arn:aws:s3:::<prefix>*/*` |
+| `CopyObject` source with `versionId` (restore) | `s3:GetObjectVersion` | the same |
+| `CopyObject` destination (restore) | `s3:PutObject` | the same |
+
+And a Deny of `s3:PutBucketVersioning` and `s3:PutLifecycleConfiguration` on
+the deployment and data buckets, as the conversion policy denies its bucket
+writes there. Object-level actions cannot be denied on those buckets (the
+role writes and deletes versions in its own deployment bucket), so the
+object grants rest on the same preconditions conversion uses: a dedicated
+`store_bucket_prefix` ending in `-store-`, matching none of the deployment,
+data, sibling staging or managed fleet buckets.
+
+`s3:GetObjectVersion` lets the console read tenant bytes. It is the third
+such exception after scanning (`host_store_scan`) and conversion's HEAD, it
+is behind its own switch, and the console uses it only as a copy source.
+`host_store`'s comment ("it does not read tenant data") stays true for a
+deployment that leaves the switch off.
+
+The store user boundary does not change (§4.1).
+
+### 8.3 Who applies it
+
+The module change ships on `main` with no effect: the default is off and the
+boundary renders byte for byte as before (`off_by_default` asserts it).
+Turning it on is a `tofu apply` with `store_versioning = true` in the
+deployment root (`carlosframework/carloku-infrastructure` for Carloku), after
+a release tag carrying this module is cut and its `?ref=` bumped, then
+`CARLOS_STORE_VERSIONING=1` on the console. That apply changes IAM in a
+production account, so it needs Paul's scoped approval (AGENTS.md,
+"Production infrastructure needs scoped approval"). Nothing on this branch
+applies anything.
+
+## 9. Tests and gates
+
+### 9.1 objstore
+
+- `storePolicyJSON`: the history Deny statement is present for every store,
+ object and bucket halves, with exactly the actions of §4.1; the policy
+ never Allows any of them; the document fits 2,048 characters with every
+ optional statement on and a 63-character bucket name.
+- `MemProvisioner` implements `Versioner` (versioning state, lifecycle rule,
+ per-key version history, delete markers), and refuses a foreign lifecycle
+ rule like the AWS adapter.
+- AWS adapter against a stub S3: rule-first ordering; a foreign lifecycle
+ configuration refused with nothing written; our own rule left alone when
+ unchanged and rewritten when `keep_days` moved; Suspended keeps the rule;
+ `EmptyVersions` paginates, batches at 1,000, deletes markers too, and
+ surfaces per-key errors; `ListVersions` keeps only the exact key, newest
+ first, capped; `RestoreVersion` sends the version in `CopySource` and
+ `TaggingDirective: REPLACE`.
+- Walks: a first grant of a versioned record versions the bucket before
+ `MintKey` (the fake records call order); a healthy re-walk converges a
+ block added later; a non-`Versioner` fails before minting; teardown of a
+ versioned store empties every version and marker and deletes the bucket;
+ teardown with a non-`Versioner` leaves the record; `ConvergeVersioningIn`
+ never mints or delivers.
+- `TestPurgeGuardIgnoresVersioningBlock`.
+
+### 9.2 Console
+
+- The setter: person-only (an Admin service credential is refused), 503
+ without `StoreVersioning`, `keep_days` bounds, lowering refused, off with
+ no block writes nothing, on over a conversion block refused, a declared
+ but ungranted store records the block and the walk applies it later, a
+ provisioned store is converged at once, audit rows written.
+- Status, listing and restore: each refusal in §6.4, restore copies from the
+ version asked for, the record is never changed by them.
+- `store create --versioning` records the block; private stores under a
+ manifest with `store_versioning` are born with it; the instances enable
+ door refuses the flag without `StoreVersioning` and never refuses turning
+ it off.
+- `mediaStoreEligible` refuses a versioned record even when verified.
+- Sizing sums every version for a versioned store.
+- Route declarations, claim fixtures (POST doors refuse on a host-claim
+ console with a 409 listed in `claimUnsupported`; GETs are reads), parity.
+
+### 9.3 Against a real server
+
+`TestVersionedContractMinio` (CI step `30-minio-contract`, which must see
+its PASS line): a versioned bucket and the scoped user's policy carrying the
+§4.1 Denies. The scoped credential overwrites and deletes an object, then is
+refused `DeleteObject` with a version id, `DeleteObjects` with version ids,
+`PutBucketVersioning`, `PutBucketLifecycleConfiguration` and
+`PutBucketPolicy`. A root client then confirms every version is still there.
+The CI fixture's hand-written policy is extended to track `storePolicyJSON`.
+
+### 9.4 Infra
+
+`infra/modules/region-host/tests/store_versioning.tftest.hcl`: off creates
+nothing and leaves the boundary byte for byte; on creates exactly the
+statements of §8.2, attached to the host role; the Deny names the deployment
+and data buckets; each prefix precondition refuses; the boundary never
+allows a §4.1 action, with any combination of switches.
+
+### 9.5 Gates
+
+`go build ./...`, `go vet ./...`, `go test ./... -count=1` (`make test`),
+`gofmt -l .`, `make staticcheck`, `make code-health`, `make parity-doc`
+(no diff), `make tofu-test` (CI: tofu 1.13.9), and the census card.
+
+## 10. CLI, API and docs
+
+### 10.1 CLI
+
+```text
+carlos store create --app <a> [--environment <e>] --versioning [--keep-days <n>]
+carlos store versioning on --app <a> [--environment <e>] [--keep-days <n>]
+carlos store versioning off --app <a> [--environment <e>]
+carlos store versioning status --app <a> [--environment <e>]
+carlos store versions --app <a> [--environment <e>] --key <key>
+carlos store restore --app <a> [--environment <e>] --key <key> --version <id>
+carlos instances enable --app <a> --private-storage --store-versioning
+```
+
+`carlos store status` gains one line from the record (no bucket read). Each
+new node gets its `parity/parity.tsv` row (`gap`, console column empty:
+there is no console page for versioning in this slice) and a heading on
+`docs/site/cli.md`.
+
+Output, label and value pairs in the uploads style (copy deck:
+`docs/superpowers/notes/store-versioning-copy-deck.md`, awaiting copy
+review):
+
+```text
+versioning on
+keep old versions for 30 days
+bucket in place
+```
+
+```text
+VERSION MODIFIED SIZE STATE
+Wq3sVh1Hq2v7m4H0eS0pR8yIEwq0vM8A 2026-11-22 10:04 UTC 4.0 MiB current
+3HL4kqtJlcpXroDTDmJ.rmSpXd3dIbrH 2026-11-21 18:30 UTC - deleted
+```
+
+### 10.2 API
+
+| Route | Allow | What |
+| --- | --- | --- |
+| `GET /api/cli/apps/{account}/{app}/store/versioning` | Admin | the block and the bucket's state |
+| `POST /api/cli/apps/{account}/{app}/store/versioning` | person only | `{"enabled": bool, "keep_days": int}` |
+| `GET /api/cli/apps/{account}/{app}/store/versions?key=` | Admin | one key's versions |
+| `POST /api/cli/apps/{account}/{app}/store/restore` | Admin | `{"key": "...", "version_id": "..."}` |
+
+All four take `?environment=` like the other store doors. `POST .../store`
+accepts an optional `"versioning": {"keep_days": n}`, and the store reply
+gains `"versioning"` (the record's block, null when absent). The instances
+enable body accepts `"store_versioning": bool`.
+
+### 10.3 Docs
+
+- `docs/site/cli.md`: `#### carlos store versioning`, `#### carlos store
+ versions`, `#### carlos store restore`, the `--store-versioning` flag on
+ `carlos instances enable`, and the deployment switch.
+- `docs/site/media-conversion.md`: a versioned store cannot be converted or
+ take browser uploads, and turning versioning on is final for that.
+- `infra/modules/region-host/README.md`: the `store_versioning` switch.
+
+## 10.4 Host-claim consoles
+
+The two write doors (`POST .../store/versioning`, `POST .../store/restore`)
+refuse on a host-claim console with a 409 listed in `claimUnsupported`,
+after `apiAccountApp` and before the record is read, as browser uploads do.
+The two GETs are claim reads. A grant on a host-claim console that meets a
+versioning block fails with `ErrVersioningUnsupported`, because the claim
+provisioner wrapper is not a `Versioner`; claims are shelved, so this is a
+clean refusal rather than a gap.
+
+## 11. Out of scope, and follow-ups
+
+- A console page for versioning (parity rows are `gap`).
+- An app restoring its own objects (`s3:GetObjectVersion` and
+ `s3:ListBucketVersions` for the store credential; a boundary change).
+- Restoring a prefix or a point in time in one command; restoring objects
+ over 5 GiB (multipart copy).
+- Versioning together with conversion or browser uploads (§7).
+- S3-compatible backends (decision 8).
+- Object Lock / WORM retention.
+- Versioning existing private stores in bulk.
+
+## 11a. Census
+
+`internal/objstore`, `internal/provision`, the root package and
+`infra/modules/region-host` are in the root binary's census scope. The card
+is `docs/superpowers/notes/census-proposal-store-versioning.md` (claims in
+`docs/superpowers/notes/census-claims-store-versioning.tsv`, overlay
+`internal/provision/testdata/plan14-root-reads-store-versioning.tsv`). No
+root read is added: the only changed units are the region-host module's two
+files (tofu run by an operator) and its new test file; the Go envelopes are
+re-pinned for the objstore walks, the manifest field (nothing on a box reads
+it) and the CLI.
+
+## 12. Open questions for the reviewer
+
+1. Is person-only right for "off", given that off keeps history (decision
+ 3), or should it also need a passkey, like store destroy?
+2. Is a 365-day ceiling the right bound on `keep_days`?