carlos / platform Public

review: Astra findings and brief corrections for flake-appregion

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev e6ad143a8c5371bf3b68bb8081a24987f1e5a22e parent 2a5f24c
2 files changed, +38 −0
  • docs/superpowers/reviews/FINDINGS-flake-appregion-replaced.md +26 −0
  • docs/superpowers/reviews/REVIEW-BRIEF-flake-appregion-replaced.md +12 −0
diff --git a/docs/superpowers/reviews/FINDINGS-flake-appregion-replaced.md b/docs/superpowers/reviews/FINDINGS-flake-appregion-replaced.md
new file mode 100644
index 000000000..40e16a47a
--- /dev/null
+++ b/docs/superpowers/reviews/FINDINGS-flake-appregion-replaced.md
@@ -0,0 +1,26 @@
+Reviewed commit `2a5f24c10f1ce8b37bc5fe358d188fc47a6a476f` against the brief’s base, `619c64c5`. Round 1. No P1 findings; two P2 corrections to the brief. No defect found in the test change.
+
+1. **P2 — The 200 ms probe explanation does not apply to this POST.**
+ Evidence: [review brief:65](/home/paulca/amadan.net/carlos/platform-flake-appregion/docs/superpowers/reviews/REVIEW-BRIEF-flake-appregion-replaced.md:65). In the installed Go 1.26.10 source, [transfer.go:179](/home/paulca/.local/go-dist/src/net/http/transfer.go:179) restricts `probeRequestBody` to methods that usually lack bodies; POST skips it. Instead, [transfer.go:106](/home/paulca/.local/go-dist/src/net/http/transfer.go:106) sets `FlushHeaders`, and [request.go:754](/home/paulca/.local/go-dist/src/net/http/request.go:754) flushes before copying the body.
+
+ The failure scenario remains valid: the handler can signal `reading` before either pipe write supplies bytes. However, no 200 ms delay is required. **Fix:** explain the direct header flush and remove the probe-based timing explanation.
+
+2. **P2 — The resolver’s response-status list omits the linked-app guard.**
+ Evidence: [review brief:40](/home/paulca/amadan.net/carlos/platform-flake-appregion/docs/superpowers/reviews/REVIEW-BRIEF-flake-appregion-replaced.md:40). [appregionset.go:488](/home/paulca/amadan.net/carlos/platform-flake-appregion/internal/console/appregionset.go:488) calls `refuseLinkedPage`, which renders the guard’s status. That guard returns 503 on lookup failure at [linkedpolicy.go:340](/home/paulca/amadan.net/carlos/platform-flake-appregion/internal/console/linkedpolicy.go:340), or 409 for a linked app at line 354.
+
+ Those cases contradict the stated list of 302, 404 and 500, although neither introduces a 403. **Fix:** include 409 and 503, or state only that the resolver cannot return 403.
+
+The six requested checks otherwise hold:
+
+- **403 attribution:** The route registration, wrappers, admission gate, account resolver and linked-app guard provide no alternative 403 path for this request. The CSRF refusal at `appregionset.go:439` explains it.
+- **Blocking and timeout:** The client transport consumes the five-byte prefix independently of the handler reading it. An early transport failure closes the request body, releasing the pipe writer with an error. Once the prefix is consumed, the existing 10-second select still detects a handler that never reads. That timer does not cover the preceding write or provide an overall request deadline.
+- **Signal ordering:** The middleware wraps the body without reading it. `accountAppIncarnation` completes before `csrfFormOK` initiates the read that fires `firstReadSignal`. Standard-library socket buffering does not invoke this wrapper.
+- **Preserved coverage:** The prefix write completes before the replacement, while the token, region and EOF remain withheld until afterwards. The unchanged assertions still check 303, unchanged replacement region and no region audit event. Moving `ParseForm` ahead of incarnation resolution is a valid mutation witness: it would resolve the replacement and permit its region change.
+- **Comment accuracy:** The new comment correctly describes pipe-write ordering and the signal firing before bytes arrive.
+- **Transport errors:** `t.Error(err)` marks the test failed; sending a nil response does not conceal the error. The later “no response” check adds another failure.
+
+Validation was limited to source inspection. The permitted targeted test command failed before compilation because Go could not create its build directory in the read-only sandbox. I did not independently reproduce the brief’s stress or mutation results. No files were changed.
+
+Apply the two P2 documentation corrections without another review round.
+
+**READY AFTER FIXES**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/REVIEW-BRIEF-flake-appregion-replaced.md b/docs/superpowers/reviews/REVIEW-BRIEF-flake-appregion-replaced.md
index 372541a50..12f7a3d2f 100644
--- a/docs/superpowers/reviews/REVIEW-BRIEF-flake-appregion-replaced.md
+++ b/docs/superpowers/reviews/REVIEW-BRIEF-flake-appregion-replaced.md
@@ -155,3 +155,15 @@ exactly one verdict:
Do not edit files. Do not spawn subagents of your own. Do not run the
full test suites. If you run anything, run only
`go test ./internal/console -run 'TestAppRegionBrowserRefusesAnAppReplacedMidRequest$' -count=20`.
+
+## Corrections after review (Astra round 1, READY AFTER FIXES)
+
+1. The 200 ms body-probe explanation above is wrong for this request:
+ net/http restricts probeRequestBody to methods that usually lack a
+ body, and POST skips it. The client flushes the request headers
+ directly, so the handler can start reading, and fire `reading`, before
+ either pipe write has supplied a byte. The race and the fix stand; no
+ 200 ms delay is involved.
+2. The resolver steps before the CSRF check can also answer 409 and 503
+ (the linked-app guard, refuseLinkedPage). None of them answers 403, so
+ the attribution of the 403 to the CSRF refusal stands.