carlos / platform Public

docs: Astra's round 1 findings for the stage-hold flake fix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 7fa4a3d3cc81e184118e86ded2dacf216f63432d parent 39e1a1d
1 file changed, +35 −0
  • docs/superpowers/reviews/FINDINGS-flake-demo-claim-stage-hold.md +35 −0

CI passed — run details

diff --git a/docs/superpowers/reviews/FINDINGS-flake-demo-claim-stage-hold.md b/docs/superpowers/reviews/FINDINGS-flake-demo-claim-stage-hold.md
new file mode 100644
index 000000000..11e55c0e7
--- /dev/null
+++ b/docs/superpowers/reviews/FINDINGS-flake-demo-claim-stage-hold.md
@@ -0,0 +1,35 @@
+Reviewed commit `a6f2d24078b344ca636931a001daaeb930609e4b`, round 1 of 3.
+
+**P1: none.**
+
+**P2 — The new assertion accepts a stale stage-start clock, weakening the hold check.**
+
+Evidence: [assertHeld(), lines 24–34](/home/paulca/amadan.net/carlos/platform-flake-stagehold/internal/console/testdata/demo_claim_browser.mjs:24) checks stage order and each recorded duration independently. It never checks that the start belongs to the stage being measured. Both `hold()` and `held()` use the same mutable `since` in [demo_claim.js, lines 152–158](/home/paulca/amadan.net/carlos/platform-flake-stagehold/internal/console/static/demo_claim.js:152).
+
+Failure scenario: remove the `since = performance.now()` assignment at [demo_claim.js:262](/home/paulca/amadan.net/carlos/platform-flake-stagehold/internal/console/static/demo_claim.js:262). Stage 1 still waits at least 650 ms. Subsequent calls to `hold()` compute zero remaining delay because `since` still refers to stage 1. Stages 2 and 3 can therefore advance after only their paint/fetch overhead, while every recorded `to - from` exceeds 650 ms. Stage order remains correct, so the new assertion passes. The previous adjacent-stage timing assertion would reject those short stages.
+
+The invariant is: **each measured hold must start within its own stage, after the preceding stage ended.**
+
+Concrete fix: retain the existing checks and, for stages 2 and 3, assert that `hold.from >= previousHold.to`. The current implementation satisfies this because it resets `since` after the next stage’s double rAF. Add the omitted-reset case to the mutation verification. This is missing test protection, not a demonstrated production failure; fix it without reopening review.
+
+**P3: none.**
+
+The remaining checks:
+
+1. **Production behavior:** `held()` is defined inside the `progress && !token` guard, after `since` is initialized. Its fixed dataset key and numeric values introduce no normal exception path. It changes no timer or clock variable. I found no production selector or reader for `data-stage-held`, and no runtime DOM snapshot that would be invalidated by it.
+
+2. **Recording boundaries:** all three call sites use the same `since` as `hold()`. The recorded end is technically **before** the next state’s DOM writes and paint, rather than “no earlier” as the brief asks. That is conservative: it cannot inflate the hold by including time after the transition. In `finish()`, it follows the last explicit validation throw, with no asynchronous boundary before the claimed state is exposed. Fetch or validation failures record no hold and enter the existing retry path.
+
+3. **Regression detection:** removing `held()` produces missing records and fails. Skipping a stage fails the order check. Removing `await` from the intermediate holds produces short recorded durations unless actual scheduling delays supply the elapsed time. Resetting `since` later moves the measured start forward and is conservative. Failing to reset it is the uncovered case above.
+
+4. **Timing allowance:** the 648.8 ms threshold is justified for the stated Chromium configuration. Positive fractional WebIDL integer conversion truncates the delay; Chromium 151 uses 100 µs coarsening with jitter for non-isolated contexts. The shared start cancels algebraically, leaving the hold-read and end-read errors. Timer scheduling waits for the converted duration; load adds delay. Apparent early completion relative to the original fractional request and coarsened readings is what the allowance covers. Sources: [https://webidl.spec.whatwg.org/#abstract-opdef-converttoint](https://webidl.spec.whatwg.org/#abstract-opdef-converttoint), [https://raw.githubusercontent.com/chromium/chromium/151.0.7922.173/third_party/blink/renderer/core/timing/time_clamper.h](https://raw.githubusercontent.com/chromium/chromium/151.0.7922.173/third_party/blink/renderer/core/timing/time_clamper.h), [https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers](https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers).
+
+5. **Observer delivery:** the current awaited timers and paint boundaries separate writes. If multiple stage writes were collapsed into one callback, the observer would retain only the latest attribute value; a required stage’s hold would be missing and the assertion would fail.
+
+6. **Remaining timing checks:** the pre-existing [500 ms Node-side button check](/home/paulca/amadan.net/carlos/platform-flake-stagehold/internal/console/testdata/demo_claim_browser.mjs:259) can falsely fail when Node or protocol processing is delayed past submission. It need not change in this branch. A separate fix can remove that intermediate check while retaining the page-clock duration assertion at line 262.
+
+7. **Constants and goldens:** keeping an independent `650` expectation in the test is appropriate; reading the production value would let an accidental reduction change both behavior and expectation. I verified the script hashes `167c6323732b` and `abd45e02c318` and the content-hashed asset URL mechanism. The footer goldens cover server-rendered bytes, not runtime attributes. I did not independently regenerate the eight digests.
+
+`git diff --check` passed. The permitted fast test could not start: Go could not create its build directory in the read-only sandbox. No files were edited. The branch-specific diff contains the five files described; the additional two-tip differences against current `origin/main` are later lease changes.
+
+**READY AFTER FIXES**
\ No newline at end of file