carlos / platform Public

reviews: Astra brief for nearest-region-scan, round 2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 9a6311d8616d7c5b4cf72db695e6b7ebf3fd24e7 parent c912aa0
1 file changed, +121 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-nearest-region-scan-R2.md +121 −0

CI passed — run details

diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-nearest-region-scan-R2.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-nearest-region-scan-R2.md
new file mode 100644
index 000000000..9c15ce273
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-nearest-region-scan-R2.md
@@ -0,0 +1,121 @@
+# Review brief: nearest-region never-reuse Task 11 (AWS adapter scan), round 2 of 3
+
+Repo carlos/platform, branch `nearest-region-scan`, commit c912aa0e (the
+round 1 fixes; this brief is the commit after it).
+Under review: the diff `origin/main..nearest-region-scan` (base 0a32ce38):
+`scripts/hosts-used-scan-aws.sh`, `cmd/console/hostsused_scan_test.go`,
+the TestMain hook in `cmd/console/main_test.go`, and one README line.
+Authorities (merged on main): `docs/superpowers/plans/2026-10-26-nearest-region-never-reuse.md`
+(Task 11, the "Rework" section: offline `console hosts-used roster/activate`
+replaced the live `import`; Task 11's text still says import, ignore that;
+Global Constraints), `docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md`
+§3b, README "The hostname history" and "Completing the history".
+Code the script feeds: `internal/provision/hostsused_map.go` (`TargetListing`,
+`HostsFromBucketListing`), `internal/layout/hostsused.go`
+(`HostsFromBoxListing`), `cmd/console/hostsused.go` (`readListings`, the
+roster file) and `internal/console/hostsused_activate.go` (`HostsRoster`,
+`Activate`: how it joins `kind:target`, what `ok:false` and unmapped
+entries do).
+
+You are an independent reviewer. Read the script, then the code it feeds,
+and check every claim in its header and the commit message against that
+code.
+
+## Fixed: do not re-argue
+
+- The script lives in this repo's `scripts/` (the plan's file map), not in
+ infra. README copy beyond removing "(in infra)" is out of scope.
+- Provider-neutral core (plan Global Constraints): S3 and SSM appear only
+ in the adapter. The roster stays provider-neutral; the AWS coordinates
+ (instance, region, data dir per box; replica prefix, region per bucket)
+ come from a separate operator-written `--targets` file. The replica
+ prefix is required, never defaulted.
+- No S3 output location for SSM: the roster never supplies one, so long
+ output is paged through `get-command-invocation`, or the target fails.
+- `instances/_probe` and `.instances/_probe` on every box are reported
+ unmapped by the Task 6 mapper, so activate would refuse on a real box.
+ That is the mapper's fault, filed as amadan discussion 437, and out of
+ scope here.
+- Local tests: only the touched package with `-run`. CI runs the rest.
+
+## What to check
+
+1. Read-only. The only AWS calls are `s3api list-objects-v2`,
+ `ssm send-command` (AWS-RunShellScript) and `ssm get-command-invocation`.
+ The remote script writes nothing on the box. Nothing an operator or a
+ roster supplies (target names, instance id, region, data_dir, prefix)
+ can inject shell into the local script or the remote command.
+2. No silent miss. Every roster target gets exactly one line. S3: every
+ page is followed (IsTruncated, NextContinuationToken), keys are never
+ split or altered (newlines, spaces, unicode), an error on any page
+ fails the target with no partial entries. SSM: the 24,000-character
+ output limit cannot truncate a listing without failing the target;
+ the page reassembly, sha256, length and line-count checks hold; a
+ listing that changes between pages is retried or failed, never merged;
+ `find` errors fail the target; paths are relative to the data dir as
+ `HostsFromBoxListing` expects.
+3. Output contract. Each line decodes as `provision.TargetListing`; `kind`
+ and `target` join to the roster's `bucket:<name>` / `box:<name>`
+ (including fleet boxes `box:fleet/<f>/<label>`); `prefix` means what
+ `HostsFromBucketListing` takes it to mean, including the empty prefix
+ (whole bucket listed). An `ok:false` line is refused by activate.
+4. Failure handling. Every failure path (missing coordinates, AWS error,
+ SSM status other than Success, poll timeout, decode failure) emits
+ `ok:false` with a usable error; exit codes are as documented; the
+ output file is never left half-written.
+5. Portability for an operator laptop: bash 3.2 (macOS), BSD tools
+ (`base64 -d`, `shasum`), and the remote side as POSIX sh under SSM.
+6. The tests: do they witness pagination on both sides, the S3 and SSM
+ failures, and that the real `activate` accepts the output? Would they
+ catch a regression in each of 1-4? Does the fake behave like the real
+ CLI where it matters (InvocationDoesNotExist, 24,000-character cap)?
+
+## Round 2
+
+Earlier rounds: round 1, `docs/superpowers/reviews/CODEX-FINDINGS-nearest-region-scan-r1.md`
+(NOT READY: two P1, two P2). The round number counts every earlier
+review of this change, under any file name or reviewer. The fixes are
+commit c912aa0e; its message maps each finding to its fix and witness.
+
+First give one line per P1 and P2 from round 1: resolved, partly, or
+not. Carry every unresolved or partly resolved finding forward at its
+current severity, then add new findings. The verdict covers everything
+outstanding, earlier rounds included. Name the fault family of every
+finding: if a round 2 finding falls in the same family as a round 1 P1
+(completeness of the remote inventory before checksumming; agreement
+between the configured and the inventoried namespace), say so.
+
+## Severity
+
+- **P1**: unsafe, would not compile, a test fails, or it would not work.
+ Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review. (The
+ census, and review of any newly changed security, root, termination
+ or production-storage behaviour, still check the fix; see AGENTS.md,
+ "Stopping rules".)
+- **P3**: clarity or polish. Goes on a follow-up list; never a reason for
+ another round.
+
+A P1 states its failure scenario and the evidence (file:line). Do not
+raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3. Each gives the section or task, the problem,
+the evidence (file:line, verified), the failure scenario, a concrete
+fix and the invariant or trust boundary it breaks (that is its fault
+family). End with exactly one verdict:
+
+- **READY**: no P1 and no P2.
+- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another
+ round.
+- **NOT READY**: one or more P1s, listed.
+
+In round 3, a NOT READY also says whether the P1s share one cause, and
+whether refusing the case up front or cutting the feature would remove
+them.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of
+your own. Do not run the full test suites. You may run
+`go test ./cmd/console -run TestHostsUsedScanAWS -count=1` and bash
+experiments on the script; never call real AWS.