store: the listing guard catches every call shape (Astra round 3 P2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+134
−30
docs/superpowers/reviews/CODEX-FINDINGS-store-versioning.md+55 −1docs/superpowers/specs/2026-11-22-store-versioning-design.md+4 −2internal/objstore/versionlist_test.go+75 −27
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-store-versioning.md b/docs/superpowers/reviews/CODEX-FINDINGS-store-versioning.md| index 6842e39a1..c1883dd90 100644 |
| --- a/docs/superpowers/reviews/CODEX-FINDINGS-store-versioning.md |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-store-versioning.md |
| @@ -231,4 +231,58 @@ Copy replacements below preserve formatting arguments unless noted. “Keep” m |
| | `cli.versions.more` | Change | `more: run the same command with --after %s` | Preserves target and key; pass the safely quoted cursor as the sole argument. | |
| | `docs.cli.store_versioning` | Keep | — | Correctly distinguishes permanent enablement from bounded retention. | |
| | `docs.cli.store_versions` | Change | Replace the final paragraph with: “`deleted` marks a delete. It holds no bytes. When there are more versions, the last line gives the `--after` value for the next page. Run the same command with that value.” | Matches the corrected paging instruction. | |
| -| `docs.cli.store_restore` | Change | Replace the final sentence with: “It also refuses a store whose bucket doesn't currently have versioning enabled, and a store that blocks uploads because its plan's storage is full.” | Avoids describing every non-Enabled bucket as never enabled. | |
| \ No newline at end of file |
| +| `docs.cli.store_restore` | Change | Replace the final sentence with: “It also refuses a store whose bucket doesn't currently have versioning enabled, and a store that blocks uploads because its plan's storage is full.” | Avoids describing every non-Enabled bucket as never enabled. | |
| + |
| +--- |
| + |
| +# Round 3 |
| + |
| +**Paul's ruling on round 2's P1, 2026-11-22: option 3.** It was relayed from the Slopbox session and recorded on #1380. Built in `1ae9761bb`: `objstore.ListObjectVersionsPage` is the one listing helper, with a call-site guard and an SDK-level XML fixture. |
| + |
| +Reviewer: Astra (`gpt-6-astra`, effort high, `codex exec -s read-only`). Brief: `CODEX-REVIEW-BRIEF-store-versioning-R3.md`. Reviewed `8a67586ff..1ae9761bb` and the whole branch `74aeb271c..1ae9761bb`. |
| + |
| +**Verdict: READY AFTER FIXES.** No P1, one P2. Round 2's P1 and all four P2s are resolved, and every census unit and envelope is approved. |
| + |
| +## The P2: fixed without reopening (stopping rule 1) |
| + |
| +**The guard missed some call shapes:** method values, method expressions, package-level initializers, and the SDK's raw version paginator. `listingBypasses` now walks whole files and flags any `ListObjectVersions` reference outside the helper's own body, plus any `NewListObjectVersionsPaginator`. `TestListingGuardCatchesEveryShape` holds a negative fixture for each shape, and positive fixtures for the helper and for interface declarations. The change is test-only. |
| + |
| +## Reply, whole |
| + |
| +- **R2 P1, XML-invalid keys break recovery — resolved.** All four production listing paths use the encoded-listing helper. [versionlist.go:39](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/internal/objstore/versionlist.go:39) |
| +- **R2 P2, pagination loses target/key — resolved.** The instruction preserves the original command and quotes the cursor. [store_versioning.go:391](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/store_versioning.go:391) |
| +- **R2 P2, retention validation ordering/zero — resolved.** Explicit values are checked before session resolution. [store.go:188](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/store.go:188), [store_versioning.go:253](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/store_versioning.go:253) |
| +- **R2 P2, indefinite-retention wording — resolved.** Copy now states that old versions expire. [store_versioning_copy.go:17](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/internal/console/store_versioning_copy.go:17) |
| +- **R2 P2, older-console recovery instruction — resolved.** It directs the user to repeat the original create command. [store_versioning.go:53](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/store_versioning.go:53) |
| + |
| +Reviewed both specified diffs through `1ae9761bb`. **No P1; one P2.** No files, index or branches changed; no tests run. The round 3 diff passes `git diff --check`. |
| + |
| +1. **P2 — The guard does not catch every alternative listing call shape.** |
| + |
| + **Section:** §6.6, enforcing Paul’s centralized-listing ruling. |
| + **Fault family:** every store version listing crosses the encoded-listing boundary. |
| + |
| + **Evidence:** [versionlist_test.go:333](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/internal/objstore/versionlist_test.go:333) visits only function declarations; [line 339](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/internal/objstore/versionlist_test.go:339) checks only calls whose immediate function is a selector named `ListObjectVersions`. |
| + |
| + **Failure scenario:** `list := api.ListObjectVersions; list(ctx, in)` passes this guard. So does an immediately invoked package-level initializer. `awss3.NewListObjectVersionsPaginator(api, in).NextPage(ctx)` also bypasses it: the SDK performs the raw listing internally. A future store caller can therefore reintroduce the original failure while this required guard remains green. Current production callers do use the helper, making this an enforcement gap rather than a current runtime blocker. |
| + |
| + **Fix:** inspect complete files, reject method references outside the helper—including method values/expressions—and reject direct SDK version-paginator construction. Add negative fixtures for these shapes and a positive fixture for the helper. |
| + |
| +The helper’s decoding, raw-response fallback and decode-error handling are sound by inspection. Version-specific URL deletion remains within the existing object grant; AWS documents its `s3:DeleteObjectVersion` permission. [AWS DeleteObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html) |
| + |
| +Apply the P2 without reopening review, under the stopping rule. |
| + |
| +READY AFTER FIXES |
| + |
| +Census verdicts apply to `1ae9761bb`, independently of the guard finding. The three external-unit hashes and four non-root envelope hashes match. |
| + |
| +| Unit or envelope | Verdict | Evidence and basis | |
| +|---|---|---| |
| +| `infra/modules/region-host/main.tf:external` | APPROVE | Switched, scoped grant; dedicated-prefix exclusions; boundary unchanged. [main.tf:1149](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/infra/modules/region-host/main.tf:1149) | |
| +| `infra/modules/region-host/variables.tf:external` | APPROVE | Default-false operator input; no runtime read. [variables.tf:309](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/infra/modules/region-host/variables.tf:309) | |
| +| `infra/modules/region-host/tests/store_versioning.tftest.hcl:external` | APPROVE | Mock-provider planning tests; `legacy / accepted-legacy` disposition appropriate. [store_versioning.tftest.hcl:7](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/infra/modules/region-host/tests/store_versioning.tftest.hcl:7) | |
| +| `.` envelope | APPROVE | CLI validation, response checks and presentation add no root filesystem or execution authority. [store_versioning.go:236](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/store_versioning.go:236) | |
| +| `infra/modules/region-host` envelope | APPROVE | Operator-controlled IAM scope retains all four prefix restrictions. [main.tf:1182](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/infra/modules/region-host/main.tf:1182) | |
| +| `infra/modules/region-host/tests` envelope | APPROVE | Mock grant, boundary and refusal assertions only. [store_versioning.tftest.hcl:56](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/infra/modules/region-host/tests/store_versioning.tftest.hcl:56) | |
| +| `internal/objstore` envelope | APPROVE | Ownership checks preserved; URL deletion names the listed version in the same authorized bucket; no new root filesystem input. [walk.go:727](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/internal/objstore/walk.go:727), [versionlist.go:103](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/internal/objstore/versionlist.go:103) | |
| +| `internal/provision` envelope | APPROVE | Additive manifest field; record-write classifications preserved. [provision.go:403](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/internal/provision/provision.go:403), [store_versioning_census_test.go:19](/Users/paulcampbell/amadan.net/carlos/platform/.claude/worktrees/store-versioning/internal/provision/store_versioning_census_test.go:19) | |
| \ No newline at end of file |
diff --git a/docs/superpowers/specs/2026-11-22-store-versioning-design.md b/docs/superpowers/specs/2026-11-22-store-versioning-design.md| index 270f6503e..f6b5ea82e 100644 |
| --- a/docs/superpowers/specs/2026-11-22-store-versioning-design.md |
| +++ b/docs/superpowers/specs/2026-11-22-store-versioning-design.md |
| @@ -1,6 +1,6 @@ |
| # 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 · |
| +**Date:** 2026-11-22 · **Status:** APPROVED (Astra, round 3: ready after fixes, applied) · |
| **Branch:** `store-versioning` from `origin/main` `74aeb271c` · |
| **Author:** Claude Opus 5.5, for Paul · **Discussion:** carlos/platform #1372. |
| @@ -18,7 +18,9 @@ character breaks listing and restore) is round 1's "retained versions stay |
| recoverable" family two rounds running, so stopping rule 2 applies and the |
| choice is Paul's (options in the findings file; the recommendation is one |
| encoded-listing helper with a guard test). The four P2s are fixed. **Paul ruled option 3 (2026-11-22)**, built for |
| -round 3: §6.6. |
| +round 3: §6.6. Round 3: Astra on `1ae9761bb` returned READY AFTER |
| +FIXES: no P1, one P2 (the guard missed method values and the SDK |
| +paginator), fixed without reopening the review. |
| 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"). |
diff --git a/internal/objstore/versionlist_test.go b/internal/objstore/versionlist_test.go| index f20a82a7f..c5109af33 100644 |
| --- a/internal/objstore/versionlist_test.go |
| +++ b/internal/objstore/versionlist_test.go |
| @@ -10,7 +10,6 @@ import ( |
| "net/http" |
| "net/http/httptest" |
| "net/url" |
| - "os" |
| "path/filepath" |
| "sort" |
| "strconv" |
| @@ -307,10 +306,43 @@ func TestXMLSafeKey(t *testing.T) { |
| } |
| } |
| -// The guard: in the store code (internal/objstore, internal/console), the |
| -// only ListObjectVersions call outside tests is the one inside |
| -// ListObjectVersionsPage. internal/release lists the deployment bucket's |
| -// own versions and is not store code. |
| +// listingBypasses names every way file reaches S3's version listing other |
| +// than through ListObjectVersionsPage: any reference to a ListObjectVersions |
| +// method (a call, a method value such as `list := api.ListObjectVersions`, |
| +// a method expression, in a function body or a package-level initializer), |
| +// and the SDK's version paginator, which lists raw internally. Only the |
| +// helper's own body is exempt. Interface method declarations are fields, |
| +// not references, so the seams that declare the method are not flagged. |
| +func listingBypasses(fset *token.FileSet, f *ast.File, base string) []string { |
| + var out []string |
| + var walk func(n ast.Node, inHelper bool) |
| + walk = func(n ast.Node, inHelper bool) { |
| + ast.Inspect(n, func(n ast.Node) bool { |
| + switch n := n.(type) { |
| + case *ast.FuncDecl: |
| + if n.Body != nil { |
| + walk(n.Body, base == "versionlist.go" && n.Recv == nil && n.Name.Name == "ListObjectVersionsPage") |
| + } |
| + return false |
| + case *ast.SelectorExpr: |
| + if n.Sel.Name == "ListObjectVersions" && !inHelper { |
| + out = append(out, fmt.Sprintf("%s: references ListObjectVersions", fset.Position(n.Pos()))) |
| + } |
| + case *ast.Ident: |
| + if n.Name == "NewListObjectVersionsPaginator" { |
| + out = append(out, fmt.Sprintf("%s: uses the SDK's raw version paginator", fset.Position(n.Pos()))) |
| + } |
| + } |
| + return true |
| + }) |
| + } |
| + walk(f, false) |
| + return out |
| +} |
| + |
| +// The guard: in the store code (internal/objstore, internal/console), every |
| +// version listing goes through ListObjectVersionsPage. internal/release |
| +// lists the deployment bucket's own versions and is not store code. |
| func TestEveryStoreVersionListingUsesTheHelper(t *testing.T) { |
| for _, dir := range []string{".", "../console"} { |
| files, err := filepath.Glob(filepath.Join(dir, "*.go")) |
| @@ -321,33 +353,49 @@ func TestEveryStoreVersionListingUsesTheHelper(t *testing.T) { |
| if strings.HasSuffix(file, "_test.go") { |
| continue |
| } |
| - src, err := os.ReadFile(file) |
| - if err != nil { |
| - t.Fatal(err) |
| - } |
| fset := token.NewFileSet() |
| - f, err := parser.ParseFile(fset, file, src, 0) |
| + f, err := parser.ParseFile(fset, file, nil, 0) |
| if err != nil { |
| t.Fatal(err) |
| } |
| - for _, decl := range f.Decls { |
| - fn, ok := decl.(*ast.FuncDecl) |
| - if !ok || fn.Body == nil { |
| - continue |
| - } |
| - ast.Inspect(fn.Body, func(n ast.Node) bool { |
| - call, ok := n.(*ast.CallExpr) |
| - if !ok { |
| - return true |
| - } |
| - sel, ok := call.Fun.(*ast.SelectorExpr) |
| - if ok && sel.Sel.Name == "ListObjectVersions" && !(filepath.Base(file) == "versionlist.go" && fn.Name.Name == "ListObjectVersionsPage") { |
| - t.Errorf("%s: %s calls ListObjectVersions directly; list store versions through objstore.ListObjectVersionsPage", |
| - fset.Position(call.Pos()), fn.Name.Name) |
| - } |
| - return true |
| - }) |
| + for _, p := range listingBypasses(fset, f, filepath.Base(file)) { |
| + t.Errorf("%s; list store versions through objstore.ListObjectVersionsPage", p) |
| } |
| } |
| } |
| } |
| + |
| +// The guard catches every shape Astra round 3 named, and passes the helper. |
| +func TestListingGuardCatchesEveryShape(t *testing.T) { |
| + const head = "package x\nimport (\n\t\"context\"\n\tawss3 \"github.com/aws/aws-sdk-go-v2/service/s3\"\n)\nvar _ = context.Background\nvar _ awss3.Options\n" |
| + for name, src := range map[string]string{ |
| + "call": "func f(api *awss3.Client) { api.ListObjectVersions(context.Background(), nil) }", |
| + "method value": "func f(api *awss3.Client) { list := api.ListObjectVersions; list(context.Background(), nil) }", |
| + "method expr": "func f(api *awss3.Client) { _ = (*awss3.Client).ListObjectVersions }", |
| + "package var": "var c *awss3.Client\nvar list = c.ListObjectVersions", |
| + "init closure": "var x = func() int { var c *awss3.Client; c.ListObjectVersions(context.Background(), nil); return 0 }()", |
| + "paginator": "func f(api *awss3.Client) { awss3.NewListObjectVersionsPaginator(api, nil) }", |
| + "helper method": "type T struct{}\nfunc (T) ListObjectVersionsPage(api *awss3.Client) { api.ListObjectVersions(context.Background(), nil) }", |
| + } { |
| + fset := token.NewFileSet() |
| + f, err := parser.ParseFile(fset, "versionlist.go", head+src, 0) |
| + if err != nil { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + if got := listingBypasses(fset, f, "versionlist.go"); len(got) == 0 { |
| + t.Errorf("%s: the guard missed it", name) |
| + } |
| + } |
| + ok := head + "type L interface{ ListObjectVersions() }\nfunc ListObjectVersionsPage(api *awss3.Client) { api.ListObjectVersions(context.Background(), nil) }" |
| + fset := token.NewFileSet() |
| + f, err := parser.ParseFile(fset, "versionlist.go", ok, 0) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := listingBypasses(fset, f, "versionlist.go"); len(got) != 0 { |
| + t.Errorf("the helper and an interface declaration were flagged: %v", got) |
| + } |
| + if got := listingBypasses(fset, f, "other.go"); len(got) != 1 { |
| + t.Errorf("a helper-named function in another file must not be exempt: %v", got) |
| + } |
| +} |