carlos / platform Public

review: Astra round 1 findings and round 2 brief, audit-aws-timeouts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 1325f6ec6d49bdd004ea5a637d7133d901bc50a1 parent 43f121e
2 files changed, +162 −0
  • docs/superpowers/reviews/FINDINGS-audit-aws-timeouts-R1.md +63 −0
  • docs/superpowers/reviews/REVIEW-BRIEF-audit-aws-timeouts-R2.md +99 −0

CI passed — run details

diff --git a/docs/superpowers/reviews/FINDINGS-audit-aws-timeouts-R1.md b/docs/superpowers/reviews/FINDINGS-audit-aws-timeouts-R1.md
new file mode 100644
index 000000000..0db62a974
--- /dev/null
+++ b/docs/superpowers/reviews/FINDINGS-audit-aws-timeouts-R1.md
@@ -0,0 +1,63 @@
+Reviewed `91e6d5b54af585128265effb56108ff920b1d530`, round **1 of 3**, against merge base `15b1ee6b6a65a52b82075003d8d6c2bcbb100ca5`. The pinned tip adds only the brief to the implementation commit named there.
+
+Found **one P1 and two P2s**.
+
+1. **P1 — The body timer can abort a transfer that is making progress.**
+
+ **Evidence:** [stall.go:125](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/rootaws/stall.go:125) starts a timer around the entire underlying `Read`; [stall.go:141](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/rootaws/stall.go:141) closes the body when it expires. But Go’s HTTP/1 [chunked reader:97](/home/paulca/.local/go-dist/src/net/http/internal/chunked.go:97) can perform successive underlying reads within one chunk before returning. Its early-return checks concern chunk boundaries; within a chunk, lines 131–146 continue filling the supplied buffer.
+
+ **Failure scenario:** An S3-compatible endpoint sends a large HTTP chunk incrementally. A consumer requests 32 KiB, while the server delivers 128 bytes each second. Data arrives throughout the 120-second interval, but the chunked reader has not filled the buffer or finished the chunk. The timer closes this healthy transfer and returns `bodyStallError`. Larger buffers used during downloads make this relevant beyond unusually small transfer rates.
+
+ The existing [trickle test:218](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/rootaws/stall_test.go:218) writes and flushes complete 16 KiB chunks. It does not exercise incremental delivery *within* a chunk.
+
+ **Fix:** Measure progress below HTTP chunk decoding, while retaining request-scoped cancellation and the exemption for pauses between consumer reads. Avoid connection-wide deadlines that could terminate unrelated HTTP/2 streams. Add a regression test that delivers one chunk in smaller fragments, with every fragment arriving within the idle limit but the enclosing `Read` taking longer.
+
+ **Fault family:** Transfer progress — receiving bytes must prevent an idle timeout. This is a source-verified failure scenario; execution was blocked by the sandbox.
+
+2. **P2 — Move storage probes remain an unbounded root-side gap.**
+
+ **Evidence:** [movesstore.go:48](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/host/movesstore.go:48) constructs an S3 client directly, without either new bound. Its list, put, get and delete operations use the incoming context unchanged. [movesreport.go:549](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/host/movesreport.go:549) supplies that context without a deadline. The instances loop creates it from `context.Background()` at [agent.go:4663](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/host/agent.go:4663), then calls `runMovesPass` at line 4699. The pass holds `w.pass` throughout, starting at [movespass.go:1096](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/host/movespass.go:1096).
+
+ **Failure scenario:** During a move’s target storage check, a configured object store accepts the request and stops answering. The instances loop remains blocked, holding the moves-pass mutex; another pass cannot progress either. This retains the root-agent failure the audit is addressing.
+
+ **Fix:** Give these small probe operations explicit request deadlines covering response-body consumption, or apply the corrected shared stall policy to this directly constructed client. Preserve its delivered static credentials, endpoint and checksum settings.
+
+ **Fault family:** Root-worker liveness — an external storage probe must not indefinitely occupy the shared worker.
+
+3. **P2 — The stated six-minute worst-case duration is incorrect.**
+
+ **Evidence:** [stall.go:26](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/rootaws/stall.go:26) claims approximately six minutes “at worst.” The header and body timers are independent.
+
+ **Failure scenario:** Each attempt receives headers just before 120 seconds, then stalls while the SDK decodes the body for another 120 seconds. Three attempts take nearly twelve minutes, plus connection establishment and retry delays. Successful body progress before the eventual stall can extend elapsed time further; upload time is also deliberately unbounded by these timers.
+
+ **Fix:** Describe these as per-phase inactivity limits. Restrict the six-minute estimate to three attempts each encountering one immediate 120-second stall, excluding other elapsed time. Keep whole-request and whole-pass deadlines as separate guarantees.
+
+ **Fault family:** Timeout contract — operational duration claims must match the implemented bounds.
+
+No P3 findings.
+
+The remaining checks produced these conclusions:
+
+- **Configuration compatibility:** Keeping the client buildable preserves CA-bundle handling and defaults-mode dial/TLS adjustments. `s3compat` still applies its endpoint and middleware settings. Caller `WithHTTPClient` options can deliberately replace the header-bound client; ordinary `WithAPIOptions` calls append in this installed SDK and retain the body middleware. Arbitrary caller options can still replace the API-options slice. These are caller-controlled extension points, not newly granted tenant authority.
+- **Connection pooling:** Sharing depends on defaults mode. Legacy mode can retain the shared buildable client; supported non-legacy modes clone it during service-client construction, as shown in [the SDK’s client resolver:554](/home/paulca/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/s3@v1.105.0/api_client.go:554). Existing transport limits remain intact. I found no correctness issue from pooling.
+- **Retries:** The timeout interfaces make errors returned during SDK deserialization retryable. A streamed `GetObject` body failure occurs after the SDK operation returns, so the SDK does **not** automatically retry that read. For example, [S3Store.Get:935](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/release/store.go:935) returns the subsequent `io.ReadAll` error directly. All new integration tests configure one attempt, so they do not demonstrate retries.
+- **Timer lifecycle:** Serial reads reuse one timer, stopped after each read. Ordinary consumer pauses leave it disarmed. I found no additional persistent timer/goroutine leak or wrapper-field race with concurrent `Close` for the default HTTP bodies. There is an expiry/completion boundary race, as the implementation comments acknowledge.
+- **Values and streaming:** The three cited existing limits are indeed 120 seconds. They support retaining that conservative value, but do not establish that every shorter value would be safe. Multipart request-body upload time and presigning are not capped by these response timers. Event-stream decoding passes through the body wrapper and is subject to finding 1.
+- **Lease cleanup:** Both error paths release immediately, preserve the original construction error and clear `c.release`, preventing a second release from the outer defer. `Held.Release` still stops the renewer before releasing remotely. No cut-state or ordering regression found.
+- **Other exclusions:** `grouprollaws` has its own bounds; the host-fence loop supplies a two-minute pass deadline; `NewStagingMirrorAt` has no production callers. The mail sender, non-group SSM loader and diagnostic `moveprobe` are reasonable follow-up scope. The move storage probe is the exception described above.
+
+The tests provide useful regression coverage, with limits. Loader assertions and the lease-release deadline assertion would detect the old behavior. The stall tests would hang without the bounds; their ten-second elapsed-time assertion is checked only after return and is not itself a watchdog. CA-bundle, trickle and pausing-reader tests protect compatibility and need not fail against the old implementation. The trickle test’s 50 ms sleeps against a 300 ms timeout can flake if a loaded runner delays the server sufficiently.
+
+**Census verdicts for this tip:**
+
+| Unit or envelope | Verdict | Evidence and basis |
+|---|---|---|
+| `internal/rootaws/stall.go:idleBody.Read` | **Approve `legacy` / `accepted-legacy`** | [stall.go:95](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/rootaws/stall.go:95) supplies an existing HTTP response body; lines 121–143 read and close it. No filesystem path, executable or additional root authority is introduced. |
+| `internal/rootaws` envelope | **Approve** | Reviewed [config.go:39](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/rootaws/config.go:39), the complete new `stall.go`, and loader/middleware dependencies. Root credential refusals and shared-file suppression remain enforced. The functional timeout defect above does not widen root’s read authority. |
+| `internal/host` envelope | **Approve** | Reviewed [movescut.go:889](/home/paulca/amadan.net/carlos/platform-audit-aws-timeouts/internal/host/movescut.go:889) through `releaseLease`, its `Held.Release` dependency and the added test. The change bounds an existing release; it introduces no new target, read authority or weakened guard. |
+
+These are census authority verdicts, not approval of the branch’s functional behavior.
+
+`git diff --check` passed. Targeted tests could not start because Go could not create its build directory in the read-only sandbox. No test execution or census-test pass is claimed. No files were edited, no subagents were spawned, and no full suites were run.
+
+**NOT READY**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/REVIEW-BRIEF-audit-aws-timeouts-R2.md b/docs/superpowers/reviews/REVIEW-BRIEF-audit-aws-timeouts-R2.md
new file mode 100644
index 000000000..11befdb14
--- /dev/null
+++ b/docs/superpowers/reviews/REVIEW-BRIEF-audit-aws-timeouts-R2.md
@@ -0,0 +1,99 @@
+# Review brief: branch audit-aws-timeouts, round 2 of 3
+
+Repo carlos/platform, branch `audit-aws-timeouts`, commit 43f121edd3496fdec7f0b0c6d02aa1c4fd416015.
+Under review: the diff `origin/main...43f121edd3496fdec7f0b0c6d02aa1c4fd416015` (base 15b1ee6b).
+Authorities: AGENTS.md on main ("The census", "Stopping rules"). Context:
+amadan discussion #1123 (Go audit backlog, first batch item 1).
+
+You are an independent reviewer. Read the diff, then the code it touches,
+and check every claim in the commit messages against that code. This
+branch changes **production storage** behaviour: every AWS client the
+platform builds through internal/rootaws, including the root host agent's.
+
+You are also the census reviewer: the card is
+`docs/superpowers/notes/census-proposal-audit-aws-timeouts.md`. Give a
+verdict for every unit and envelope it lists, citing the lines you read,
+per AGENTS.md "Getting a change approved" step 4.
+
+## What to check
+
+1. `internal/rootaws/stall.go`: ResponseHeaderTimeout 120 s and a
+ body-idle timeout 120 s that runs only while a Read is waiting. Can it
+ ever cut a transfer that is making progress, or a caller that pauses
+ between reads (streamed GetObject handed to a slow consumer, multipart
+ or manager uploads, S3 Select/streaming APIs, presigned flows)? Does the
+ timer leak (goroutine or timer per body) or race with Close? Is the
+ error surfaced so the SDK retries it sensibly?
+2. Installing one HTTP client per loaded config: any loss of an existing
+ option (AWS_CA_BUNDLE, custom endpoints via s3compat, defaults modes,
+ caller-supplied HTTP clients overriding ours or being overridden)?
+ Ordering: bounds are added ahead of caller options; can a caller
+ option silently remove them, and is that acceptable?
+3. Shared connection pool across service clients from one config: any
+ effect on behaviour or limits?
+4. Values: 120 s each, so a stalled call with 3 SDK attempts fails in
+ about 6.5 min at worst. Is that consistent with the per-request limits
+ already in the tree (hostbox.RequestLimit, lease stagingRequestTimeout,
+ generationRequestLimit)? Would a shorter value break anything you can
+ name?
+5. `internal/host/movescut.go`: error-path lease releases now go through
+ `releaseLease` (10 s) and log a failure instead of dropping it. Any
+ ordering change against the renewer stop or the cut's state?
+6. The implementer's list of sites NOT covered (grouprollaws, hostfence,
+ mail/sessend, hostenv SSM non-root path, movesstore, NewStagingMirrorAt,
+ cmd/moveprobe): is any root-side one a real gap that should be covered
+ in this branch rather than a follow-up?
+7. Tests: would each fail against the old code? Any wall-clock sleeps that
+ could flake on a loaded runner?
+
+## Round 2
+
+Earlier rounds: round 1, Astra, `docs/superpowers/reviews/FINDINGS-audit-aws-timeouts-R1.md`
+(NOT READY: one P1, two P2s; census approved at 91e6d5b5).
+
+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.
+
+Fixes since round 1: 93be380b (progress measured on the connection below
+TLS and chunk decoding, via a wrapped DialContext and an httptrace GotConn
+lookup; comment on per-phase limits), 6bf4d1e8 (move storage probe gets
+the shared bounds via rootaws.StallHTTPClient / StallAPIOptions), 43f121ed
+(census overlay re-run). The implementer notes one accepted gap: a
+connection the wrapper did not dial (another HTTP client, or a
+non-legacy AWS_DEFAULTS_MODE swapping DialContext) gets only the header
+bound, by choice, so a healthy transfer is never cut. Judge whether that
+is acceptable. The census card has changed (new unit progressConn.Read,
+changed unit host probeStore): give fresh verdicts for every unit and
+envelope at this tip.
+
+## 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). Then the census verdict per unit and envelope. 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.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of
+your own. Do not run the full test suites.