carlos / platform Public

reviews: Astra brief for nearest-region-scan, round 3 (last)

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

CI failed — run details

diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-nearest-region-scan-R3.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-nearest-region-scan-R3.md
new file mode 100644
index 000000000..048372f3b
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-nearest-region-scan-R3.md
@@ -0,0 +1,131 @@
+# Review brief: nearest-region never-reuse Task 11 (AWS adapter scan), round 3 of 3
+
+Repo carlos/platform, branch `nearest-region-scan`, commit 2060188d (Paul's
+cut after round 2; 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`, one README line, and the
+probe-directory skip in `internal/layout/hostsused.go` with its test.
+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.
+- Paul's cut after round 2 (amadan discussion 438, option 1): a bucket's
+ prefix is accepted only in plain form (segments of `[A-Za-z0-9._-]+`
+ joined by single slashes, no `.` or `..` segment, no empty segment, no
+ slash at either end, or ""), and anything else stops the whole run
+ before any AWS call; each S3 reply is checked strictly. Do not propose
+ normalising prefixes or listing the whole bucket instead.
+- Discussion 437 (Paul): the mapper skips the readiness probe's own
+ directory, `instancectl.ProbeDirName` under `instances/` and
+ `.instances/`, by exact name only, with anything inside it.
+- 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 3 (the last allowed)
+
+Earlier rounds: round 1 `docs/superpowers/reviews/CODEX-FINDINGS-nearest-region-scan-r1.md`
+(NOT READY: two P1, two P2; fixed in c912aa0e) and round 2
+`docs/superpowers/reviews/CODEX-FINDINGS-nearest-region-scan-r2.md`
+(NOT READY: one P1, one P2, one P3). Round 2 hit stopping rule 2 in two
+families (the configured vs inventoried namespace; malformed provider
+responses read as absence), and Paul chose the cut above. Commit 2060188d
+applies it; its message maps each change to its witness.
+
+First give one line per P1 and P2 from rounds 1 and 2: 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. Also check the probe-directory skip: that it skips exactly
+what the probe creates (internal/host/bootstrap.go, internal/instanceexec/probe.go)
+and nothing a host's data could be in. This is round 3: a NOT READY must
+also say whether its P1s share one cause, and whether refusing the case
+up front or cutting the feature would remove them.
+
+## 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.