carlos / platform Public

Merge remote-tracking branch 'origin/main' into race-activator-1249

claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev b32f94cc0d5ec431c9e3b4b683fe80e108477c3d parent 6fa7217parent a6bbbf5
6 files changed, +297 −44
  • docs/superpowers/reviews/FINDINGS-flake-demo-claim-stage-hold.md +35 −0
  • docs/superpowers/reviews/REVIEW-BRIEF-flake-demo-claim-stage-hold.md +196 −0
  • internal/console/demo_claim_footer_test.go +8 −8
  • internal/console/static/demo_claim.js +7 −0
  • internal/console/testdata/demo_claim_browser.mjs +37 −18
  • internal/console/testdata/demo_claim_layout.mjs +14 −18

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
diff --git a/docs/superpowers/reviews/REVIEW-BRIEF-flake-demo-claim-stage-hold.md b/docs/superpowers/reviews/REVIEW-BRIEF-flake-demo-claim-stage-hold.md
new file mode 100644
index 000000000..8bfffe46e
--- /dev/null
+++ b/docs/superpowers/reviews/REVIEW-BRIEF-flake-demo-claim-stage-hold.md
@@ -0,0 +1,196 @@
+# Review brief: demo claim stage-hold flake, round 1 of 3
+
+Repo carlos/platform, branch `flake-demo-claim-stage-hold`, fix commit
+f1193adc2653e12dc8cab648d9fc0d3a84dbe99e, golden commit
+9ced5534862463871a92ca667cfc750120f54221.
+Under review: the diff `origin/main..flake-demo-claim-stage-hold`. The
+branch started at 365a79ca. It merged main at 619c64c5 (the sibling
+navigation-wait fix, which also edits `demo_claim_browser.mjs`) without
+conflicts in f4d68f71. Line numbers below are at the branch tip. Changed
+files:
+
+- `internal/console/static/demo_claim.js` (product JS, +7 lines)
+- `internal/console/testdata/demo_claim_layout.mjs` (`watchClaimCSP`)
+- `internal/console/testdata/demo_claim_browser.mjs`
+- `internal/console/demo_claim_footer_test.go` (eight page digests)
+
+This brief is the only other file. Authority: `demo_claim.js` as merged
+on main (its hold rule, below). The fix must not change what users see
+or the page's timing, and it must not weaken what the test proves.
+
+You are an independent reviewer. Read this brief, then the code it
+names, and check every claim against that code.
+
+## The failure and its history
+
+CI, 2026-11-19, branch `flake-lease-teardown`, shard internal_console@16:
+
+```
+TestDemoClaimUXHeadlessFast390
+AssertionError: [{"stage":1,"time":95.1},{"stage":2,"time":734},{"stage":3,"time":1411.7},{"stage":4,"time":2107.1}]
+ at runUX (internal/console/testdata/demo_claim_browser.mjs:180) assert(b.time-a.time >= heldAtLeast)
+```
+
+Stage 1 to 2 measured 638.9 ms against `heldAtLeast = 640`. The same
+check had already failed at 649.8 ms and 648.5 ms (2026-11-11, #897), and
+at 644.9 ms and 648.4 ms for stage 1 (2026-11-10/11). Each time the slack
+was widened (to 10 ms) or stage 1 was given a domInteractive /
+first-paint correction.
+
+## Why the observer's clock was wrong
+
+The test timed each stage with a MutationObserver on `data-stage` /
+`data-state` and took `performance.now()` inside the callback. That is
+when the callback ran, not when the page started holding the stage. The
+page's hold starts after a double `requestAnimationFrame` that follows
+the DOM change (`since`, `demo_claim.js:262`; stage 1 at `:357`), and
+the callback runs at the microtask checkpoint of the task that changed
+the DOM. Neither end is the page's clock, and the gap between them
+depends on frame timing and load. So a stage the page held for 650 ms
+can measure short by an arbitrary amount on a loaded worker, and no
+slack is the right size.
+
+## The page's real hold rule
+
+From `demo_claim.js`:
+
+- `minimum = 650` (`:8`).
+- Stage 1 (server-painted): after the first double rAF, `since` is set
+ and the first poll is armed for `minimum` (`:357`).
+- `hold()` (`:154`) waits `max(0, minimum - (now - since))`, so it ends
+ no sooner than `since + 650` by the page's clock, less what setTimeout
+ drops (below).
+- `advance(target)` (`:264-267`) runs `await hold(); await setStage(stage + 1)`
+ per step. So each stage shows at `max(since + 650, when the poll
+ answered)`: the server answer can make a hold longer, never shorter.
+- `setStage` (`:245`) changes the DOM, waits a double rAF, then sets
+ `since` for the new stage (`:262`).
+- Stage 3 to claimed: `await hold(); await finish(result)` (`:329`).
+ `finish` fetches the page, then shows the claimed state.
+- Stopping/aborted: `await hold()` then the failure view (`:315`).
+
+## The fix
+
+- `demo_claim.js:158` adds `held()`, which writes
+ `data-stage-held="<stage left> <since> <performance.now()>"` on
+ `#claim-progress`. It is called at the top of `setStage` (`:246`, before
+ any DOM change for the new stage), in `finish` just before the claimed
+ state is shown (`:291`, same task as `claim.dataset.state = "claimed"`),
+ and on the stopping/aborted path after its hold (`:316`). It reads two
+ clocks and writes one attribute. Nothing styles or reads
+ `data-stage-held`. It does not touch `since`, `hold()` or any timer.
+- `demo_claim_layout.mjs` (`watchClaimCSP`): the observer now records only
+ the order of the stages shown (`window.claimStages`). A second observer
+ on `#claim-progress` for `data-stage-held` collects each page-recorded
+ hold into `window.claimHolds` (`:89-93`). The domInteractive /
+ first-paint heuristic is gone. The blank-frame counter is unchanged.
+- `demo_claim_browser.mjs`: `assertHeld()` (`:24`) checks that stages 1,
+ 2, 3, 4 were shown in order and that the page-recorded hold of each of
+ stages 1 to 3 is `>= heldAtLeast`. Both callers (the fast scene, `:232`,
+ and every `liveMotion` variant, `:284`) use it.
+- `heldAtLeast = 650 - 1 - 0.2` (`:20`). The 1 ms: `setTimeout` takes a
+ WebIDL `long`, so the fractional delay `hold()` asks for is truncated
+ (under 1 ms lost). The 0.2 ms: Chromium coarsens `performance.now()` to
+ 100 µs with jitter on a page that is not cross-origin isolated (the
+ console sends no COOP/COEP), so each reading is off by under 0.1 ms.
+ `since` is both the hold's base and the recorded start, so its error
+ cancels. The reading inside `hold()` and the recorded end do not. The
+ bound is: recorded hold > 649 - e(hold read) + e(end read) > 648.8.
+- The working-button hold (`:252-262`) keeps its check. It does not have
+ the observer's weakness: the test reads `performance.now()` in the page
+ before `requestSubmit()` and again inside the overridden `submit`, so the
+ two readings bracket a whole-number `wait(650)` plus a double rAF. It
+ now uses the tighter `heldAtLeast` (648.8 instead of 640).
+- `demo_claim_footer_test.go`: `TestDemoClaimFooterAbsentKeepsOldBytes`
+ pins the sha256 of eight rendered claim pages. The pages link the
+ script by a content-hashed path (`assetURL`, `assets.go:67`), so the
+ new script moved all eight. I rendered the eight pages with main's
+ script and with this one (throwaway test, deleted). After replacing
+ `static/<hash>/demo_claim.js` with a placeholder, each pair is
+ byte-identical. The only difference is `167c6323732b` to `abd45e02c318`.
+ The new digests are the ones the failing test printed. No other file
+ pins the old hash or digests.
+
+## Evidence (docs-t1, Chromium 151.0.7922.173, node v24.19.0, load about 40 on 16 cores)
+
+- Mutation: `minimum = 600` in `demo_claim.js` (reverted). Fast390 fails:
+ holds 622.7, 601.7, 611.3 ms.
+- Mutation: `await hold()` removed from `advance` (reverted). Fast390
+ fails: stage 2 held 0 ms.
+- After, at f1193adc: `go test ./internal/console -run 'TestDemoClaim|TestDemoSpentToken|TestAppSource' -count=3 -timeout 40m -v`.
+ Rounds 1 and 2 passed every browser test: UX (Headless, Fast390/1280,
+ four Motion), BrowserHeadless, SpentTokenBrowserHeadless, KeptHeadless,
+ SelectStepUpHeadless, AppSourceHeadless, CountdownBrowser. Round 3
+ passed all the non-UX browser tests (each 3/3), then the package hit its
+ 40-minute timeout in `TestDemoClaimUXRetryRemainsClosed` on a machine at
+ load 40 on 16 cores. That was a timeout, not an assertion.
+ `TestDemoClaimFooterAbsentKeepsOldBytes` failed in every round: that is
+ the digest golden above, fixed in 9ced5534.
+- After, at 9ced5534: `go test ./internal/console -run 'TestDemoClaimUX|TestDemoSpentToken|TestDemoClaimFooter' -count=1 -timeout 30m -v`
+ gave `ok ... 144.430s`, with every UX browser test, the spent-token
+ browser test and all eight footer tests PASS. So each UX browser test has
+ passed three times.
+- After the merge, at f4d68f71: `go test ./internal/console -run 'TestDemoClaimUX|TestDemoSpentTokenBrowserHeadless|TestDemoClaimBrowserHeadless|TestDemoClaimSelectStepUpHeadless|TestDemoClaimKeptHeadless|TestDemoClaimFooterAbsent' -count=1 -timeout 30m -v`
+ gave `ok ... 260.685s`, with all fourteen PASS.
+- Census and code-health do not read these files (no references in
+ `internal/provision` census tests, `internal/codehealth` or
+ `.amadan/code-health.tsv`), so I did not run them.
+
+## What to check
+
+1. Production behaviour unchanged: is there any path where `held()` can
+ throw, run before `progress`/`since` exist, change a timer, or alter
+ layout or style? Does any CSS or JS select on `#claim-progress`
+ attributes so that a new `data-*` attribute matters? Does any golden or
+ snapshot include runtime attributes of `#claim-progress`?
+2. Is `data-stage-held`'s start the same `since` that `hold()` used for
+ that stage, and its end no earlier than the moment the next state
+ shows? Check all three call sites. In `finish`, `held()` (`:291`) comes
+ after the last `throw` (`:282`) and after a few DOM writes in the same
+ task (`:284-290`), with no paint between them and the claimed state
+ (`:294`); a failed `finish` is retried by the next poll and records
+ nothing until it succeeds. Confirm.
+3. Does the assertion still fail for a page that skips or shortens its
+ hold? Think of variants other than the two mutations above: `held()`
+ removed (holds missing), hold awaited without `await`, `since` reset
+ late.
+4. Is the 0.2 ms coarsening allowance right for this Chromium, and is the
+ truncation argument right (fraction of a `long` delay)? Can a DOM timer
+ fire early relative to `performance.now()`?
+5. Can the `data-stage-held` observer miss a write (two writes before one
+ callback)? If it did, the test fails rather than passes; confirm.
+6. Is any timing check left on the observer's clock, or on node's clock in
+ a way that can fail under load? Known and left as is: the
+ `button submitted before 650ms` check (`demo_claim_browser.mjs:260`)
+ waits 500 ms in node and expects no submit yet. Under heavy load it can
+ only fail falsely, not pass falsely. Say whether it should change in
+ this branch.
+7. `minimum` is written twice: page (`demo_claim.js:8`) and test
+ (`demo_claim_browser.mjs:19`). Acceptable, or should the test read it
+ from the page?
+
+## 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.
+- **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 problem, the evidence
+(file:line, verified), the failure scenario and a concrete fix. 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. If you run anything, run only
+`go test ./internal/console -run 'TestDemoClaimUXHeadlessFast'`.
diff --git a/internal/console/demo_claim_footer_test.go b/internal/console/demo_claim_footer_test.go
index 5afa4413d..9d3055649 100644
--- a/internal/console/demo_claim_footer_test.go
+++ b/internal/console/demo_claim_footer_test.go
@@ -19,14 +19,14 @@ import (
const demoClaimFooterBaseStyleHash = "'sha256-VcClWuJxRJ9RoxIxo86MojoN2XfkXt2ui8g5v8Qpc30='"
var demoClaimFooterBaseDigests = map[string]string{
- "template-zero": "c911c3466bc78c136ee04bbccf0a8e08b876ad30ff783ecbead9aa2fc3270bbc",
- "template-missing": "3e7b0a796e966c26d30161b698c23a220e0414bd4e95df3088cdf476313d98cd",
- "template-error": "a49ba730c659ba4cdecbf32c30595a015a6589b9d00e0d235cd1bbac959e6b9f",
- "template-claimed": "5f9c597911627798e931e7ed590aca67271e3ca214e40aa27aeb567c7943e103",
- "template-proof": "0fcad79d49b5de2b052a2832fc3b3f938d23294cb26353143817aeb1466a6ccd",
- "error-page": "faeda6bf43481d6e3d0e1d487cf9730bad83621cdfca4e79a01eb958bb1dc191",
- "get-claim": "506513ae098ebcbeb629cf3ee2aa53912177fc4ea21b48ad29afec68ffc80bc5",
- "get-kept": "26a877042107a98b471e8d1369dedd09045c9374b9eda652a1a902cbbc16d6b9",
+ "template-zero": "dad989489605277fa8543db00448b4a0b98fa7a633b1968fb1f0e983a237d756",
+ "template-missing": "775cadb69c8800dc0275f152998b609a30ffe06607f4a5c7d0f52c2bdb19f58b",
+ "template-error": "3e59c3e8fc3620f919567b3e5b5d6298d6dcdf14f9add0b6ad10dae5db374ba1",
+ "template-claimed": "4ae3de201cc7ddd5573299120bc50f56ff0e5f08d33fe6a2bba2ae3a624a3fd9",
+ "template-proof": "fedb090b5ae89fa05314c5f4b117db88b67af238f4f0bd131baa2e01246ca701",
+ "error-page": "dba2b0c8f67b50dcd28b9b58d5e935d7fd7e2a4b8bf850ea9ca35ef561810701",
+ "get-claim": "db110cba19b057e2560040958f9cf879f114b9abfd53c735dce3b10bfd562d68",
+ "get-kept": "93089f76857c98c80b1c6ba4e12e1af546403bf6690da61ef264a5d52649716c",
}
const (
diff --git a/internal/console/static/demo_claim.js b/internal/console/static/demo_claim.js
index 209233e6e..33a1f14f4 100644
--- a/internal/console/static/demo_claim.js
+++ b/internal/console/static/demo_claim.js
@@ -152,6 +152,10 @@
let stage = Number(progress.dataset.stage), since = performance.now(), failures = 0;
const setStatus = text => { if (status.textContent !== text) status.textContent = text; };
const hold = async () => { await wait(Math.max(0, minimum - (performance.now() - since))); };
+ // Records the stage being left, the clock reading its hold counted from
+ // and now, the moment the next state shows. Only the browser tests read
+ // it: they check the hold on the page's own clock.
+ const held = () => { progress.dataset.stageHeld = `${stage} ${since} ${performance.now()}`; };
// Reassurance while the server works. The bar is honest: each stage owns
// a band ending at the next stage's mark, and within it the bar eases
@@ -239,6 +243,7 @@
timers.push(setInterval(draw, 500), setInterval(rotate, 4500));
const setStage = async n => {
+ held();
stage = n;
entered = performance.now();
shown = Math.max(shown, marks[Math.min(n, 3)]);
@@ -283,6 +288,7 @@
for (const text of claim.querySelectorAll(".claim-open-address")) text.textContent = url.origin;
const address = claim.querySelector(".claim-address .claim-new");
if (address) address.textContent = url.host;
+ held();
settle();
heading.textContent = claim.dataset.completeHeading;
claim.dataset.state = "claimed";
@@ -307,6 +313,7 @@
(result.committed !== undefined && typeof result.committed !== "boolean")) throw new Error();
if (result.state === "stopping" || result.state === "aborted") {
await hold();
+ held();
settle();
progress.querySelector(".claim-bar")?.remove();
elapsed?.remove();
diff --git a/internal/console/testdata/demo_claim_browser.mjs b/internal/console/testdata/demo_claim_browser.mjs
index 3596317e0..d1d8ed238 100644
--- a/internal/console/testdata/demo_claim_browser.mjs
+++ b/internal/console/testdata/demo_claim_browser.mjs
@@ -4,15 +4,41 @@ import {writeFile} from 'node:fs/promises';
import {captureClaim, watchClaimCSP} from './demo_claim_layout.mjs';
import {checkClaimMotion} from './demo_claim_motion.mjs';
-// The page holds each stage, and a working button, for 650 ms by its own
-// timers. Chromium runs timers in whole milliseconds and coarsens
-// performance.now() (about 0.1 ms, with jitter), so a hold the page kept
-// can measure a little under 650 here: 649.8 ms on CI, and 648.5 ms on a
-// loaded CI worker later the same day (2026-11-11, #897). Ten milliseconds
-// of slack absorbs that. A page that skipped its hold would still come up
-// hundreds of milliseconds short, and one that shortened it noticeably
-// still fails.
-const heldAtLeast = 640;
+// The page holds each stage, and a working button, at least 650 ms by its
+// own timers. Each stage's hold is checked on the page's own clock: the page
+// records the reading its hold counted from and the reading as the next
+// state showed (data-stage-held). Timing the stages from a MutationObserver
+// here measured when the observer ran, which a loaded CI worker delays by an
+// arbitrary amount: 649.8 ms and 648.5 ms (2026-11-11, #897), then 638.9 ms
+// against 10 ms of slack (2026-11-19). What remains is the page's own
+// rounding: setTimeout drops the fraction of the delay the page asks for
+// (under 1 ms), and Chromium coarsens performance.now() to 100 µs with
+// jitter, under 0.1 ms on each of the two readings that do not cancel out.
+// The working button's hold is a whole 650 ms timer, bracketed by readings
+// taken before the submit and in it, so the same bound holds there.
+const minimum = 650;
+const heldAtLeast = minimum - 1 - 0.2;
+
+// assertHeld checks the page showed stages 1 to 4 in order and held each of
+// the first three for the minimum by its own clock. Each hold must start in
+// its own stage, at or after the previous stage ended: a hold counted from
+// an earlier stage's start (a reset of since lost) would pass on duration
+// alone while the later stages flashed by.
+async function assertHeld() {
+ const stages = await evaluate('window.claimStages');
+ const holds = await evaluate('window.claimHolds');
+ const report = JSON.stringify({stages, holds});
+ let previous;
+ for (const stage of [1,2,3]) {
+ const at = stages.indexOf(stage);
+ assert(at >= 0 && stages[at+1] === stage+1, report);
+ const hold = holds.find(row => row.stage === stage);
+ assert(hold && Number.isFinite(hold.held), report);
+ assert(hold.held >= heldAtLeast, report);
+ if (previous) assert(hold.from >= previous.to, report);
+ previous = hold;
+ }
+}
const [binary, profile, target, screenshots, expectedError] = process.argv.slice(2);
const chrome = spawn(binary, ['--headless', '--no-sandbox', '--disable-gpu',
@@ -209,13 +235,7 @@ async function runUX(scenes) {
}
if (scene.Name === 'fast') {
await until('document.getElementById("claim").dataset.state === "claimed"');
- const stages = await evaluate('window.claimStageTimes');
- for (const stage of [1,2,3]) {
- const a = stages.find(row => row.stage === stage);
- const b = stages.find(row => row.stage === stage+1);
- assert(a && b,JSON.stringify(stages));
- assert(b.time-a.time >= heldAtLeast,JSON.stringify(stages));
- }
+ await assertHeld();
assert.equal(await evaluate('window.claimBlankFrames'),0,'blank progress frame');
await captureClaim(call,evaluate,screenshots,'live-done',[390,1280]);
const since = commits.length;
@@ -267,8 +287,7 @@ async function liveMotion(scene) {
} else {
assert.equal(await evaluate(`document.getAnimations().some(a=>a.animationName==='claim-burst')`),true);
}
- const stages = await evaluate('window.claimStageTimes');
- for (const n of [1,2,3]) assert(stages.find(s=>s.stage===n+1).time-stages.find(s=>s.stage===n).time>=heldAtLeast,JSON.stringify(stages));
+ await assertHeld();
assert.equal(await evaluate('window.claimBlankFrames'),0);
await new Promise(resolve=>setTimeout(resolve,450));
if (screenshots) {
diff --git a/internal/console/testdata/demo_claim_layout.mjs b/internal/console/testdata/demo_claim_layout.mjs
index 0d2ae4eeb..7eb01d9ca 100644
--- a/internal/console/testdata/demo_claim_layout.mjs
+++ b/internal/console/testdata/demo_claim_layout.mjs
@@ -67,34 +67,30 @@ export async function captureClaim(call, evaluate, screenshots, state, widths =
export const watchClaimCSP = `
window.claimCSPViolations = [];
- window.claimStageTimes = [];
+ window.claimStages = [];
+ window.claimHolds = [];
window.claimBlankFrames = 0;
document.addEventListener('DOMContentLoaded', () => {
const claim = document.getElementById('claim');
const progress = document.getElementById('claim-progress');
if (!progress) return;
- let last;
+ // The order of the stages shown, not their timing: an observer runs
+ // some time after the page changed, later the more loaded the machine,
+ // so holds timed here came up short on CI (demo_claim_browser.mjs).
const record = () => {
const stage = claim.dataset.state === 'claimed' ? 4 : Number(progress.dataset.stage);
- if (stage === last) return;
- // The first stage is timed from when the document finished parsing
- // (domInteractive), which is always before the page's script starts
- // its own 650 ms clock. This event can fire after the page has
- // already painted and started that clock, and the first-paint entry
- // may not be posted yet, so timing from here, or from first paint
- // when it is missing, shorted the stage (644.9 ms and 648.4 ms on CI,
- // 2026-11-10/11).
- let time = performance.now();
- if (last === undefined) {
- const nav = performance.getEntriesByType('navigation')[0];
- const paint = performance.getEntriesByName('first-contentful-paint')[0];
- time = Math.min(time, nav?.domInteractive || time, paint?.startTime ?? time);
- }
- window.claimStageTimes.push({stage,time});
- last = stage;
+ if (stage !== window.claimStages.at(-1)) window.claimStages.push(stage);
};
record();
new MutationObserver(record).observe(claim,{attributes:true,subtree:true,attributeFilter:['data-stage','data-state']});
+ // Each hold as the page timed it (data-stage-held, demo_claim.js): the
+ // stage left, the clock reading its hold counted from, and the reading
+ // as the next state showed. The page writes it once per change, at
+ // least a hold apart, so each write gets its own callback.
+ new MutationObserver(() => {
+ const [stage, from, to] = progress.dataset.stageHeld.split(' ').map(Number);
+ window.claimHolds.push({stage, from, to, held:to-from});
+ }).observe(progress,{attributes:true,attributeFilter:['data-stage-held']});
const frame = () => {
const finished = document.getElementById('claim-finished');
if (progress.getBoundingClientRect().height === 0 && (!finished || finished.getBoundingClientRect().height === 0)) window.claimBlankFrames++;