Repository navigation
Make the paced-reveal check observe every redraw, not sample on a timer - #718
Conversation
…a starved runner (#691) Opt-in CDP Emulation.setCPUThrottlingRate on the measured page; unset it is a no-op. Tested: at 50x the unmodified check fails 'grow through 3 different lengths' with redraws 5, as in CI run 42951835425.
…tick against the widget (#691) Lengths, quartile times, code blocks and sources are read from a MutationObserver on the messages container, timestamped in the page; the 25 ms sampler stays for stall and the end of the reply. The widget's own timers move its clock back by how late they fired, so a starved runner still sees every tick on time; the lateness is added to the stall-stretched bounds. The threshold of 4 lengths is unchanged. Tested: 20/20 unthrottled, 20/20 under 20 busy processes, 20/20 at 8x and 50x CPU throttling, 20/20 with 300 ms stalls (the unmodified check: 0/20).
…tarvation switches (#691) Docs only; the README commands were run.
Preview Deployment
This preview will be updated automatically when you push new commits. |
|
Review round 1, outcomes (fix commits on this branch):
Note: Biome with no repo config reports pre-existing formatting and an unused |
…urn field (#691); tested: check passes, stall reproduction still fails as documented
|
Review round 2 outcomes (commit fc504c1):
Tested: |
|
PM verdict: ready and merged. Every criterion met (root cause with evidence and reproduction, observer-based lengths plus the forgiving clock fallback with explanation, threshold 4 and all controls kept, 20-run stability tables, README and header updated, hygiene test passes, widget unchanged). All review findings from rounds 1 and 2 have outcomes. After updating the branch, Lint, Test (3.11), Test (3.12), Frontend Tests and deploy all passed; Integration Tests skipped. Squash-merged; #691 closed. |
Summary
frontend/browser-harness/paced-reveal-check.mjsfailed on the CI runner with "the reader saw the reply grow through 3 different lengths" (#691). This makes the check observe every redraw and removes the dependence on runner speed, without touchingfrontend/osa-chat-widget.js, theREVEAL_*constants, or the threshold of 4 distinct lengths.Root cause, with evidence
The first hypothesis was that the 25 ms timer sampler undercounts redraws on a starved main thread. The reproduction shows that this is true but is the minor cause. The main cause is in the widget's design: the reveal is a deadline (
REVEAL_LAG_MS500), so a tick that runs late draws a bigger slice to keep to it. On a starved runner the widget itself draws fewer, larger steps, and nothing that counts lengths can count steps that were not taken.[7, 344, 888]characters, one slice 200 to 250 ms after the previous one (a late tick drawing a bigger slice), in the same shape as the CI log. The mechanism (a late tick drawing a bigger slice) is shown with five 300 ms stalls; five 150 ms stalls do not reproduce the CI numbers (5 lengths, passes), so the exact stall pattern on the CI runner is unknown. The fix does not depend on it: the forgiving clock removes lateness whatever its source.gh run list --workflow Tests --status failure --limit 200(102 failed runs, back to 2025-12-23) plusgh run view --log-failedon each found the assertion text in two other runs (36784174307, 36574519801), both of which passed it ("grew through 5 / 6 different lengths") and failed on other checks.Changes
PACED_REVEAL_CPU_THROTTLE=<rate>(CDPEmulation.setCPUThrottlingRate) and laterPACED_REVEAL_STALL_MS=<ms>(the page's main thread blocked that long five times from 90 ms after the first text, 240 ms apart, a deterministic stand-in for a busy neighbour).MutationObserver(childList, subtree, characterData) on.osa-chat-messagesrecords[performance.now(), reply text length, code block lengths, sources, forgiven]at every redraw, in the page.distinctLengths, p25/p50/p75/p100, the code-block and sources checks are derived from those records. The 25 ms sampler stays forstalland for the end-of-reply detection.lateTicks) is added to the stall-stretched time bounds (stall = max(worst late sample, lateTicks), same cap), because a reveal whose ticks were late takes that much longer in real time.PACED_REVEAL_REAL_CLOCK=1turns the clock adjustment off, which is how the failure is reproduced.Every assertion and control is kept: threshold 4, burst, silence, fresh conversation, reduced-motion comparison, code block drawn whole, no early sources, stall-stretched bounds.
Evidence
Pre-fix is the unmodified measurement (commit 1 plus the stall switch applied to it); post-fix is this branch. Each is a loop of the check in headless Chrome 157 on a 10-core Mac.
yesprocesses on 10 cores, 20 runsPACED_REVEAL_STALL_MS=300), 20 runsCPU load and 4x to 8x throttling alone do not reproduce the failure here: they slow the page evenly, and a tick-by-tick reveal still draws 5 or more steps. What reproduces it is the page stopping for 150 ms or more, so that is what the deterministic switch does.
Commands run
bun install: 11 packages installed.bun frontend/browser-harness/paced-reveal-check.mjs: all checks passed (7 lengths, 9 redraws, stall 17).uv run pytest tests/test_frontend/test_embed_snippet_hygiene.py -q --no-cov: 17 passed.bun frontend/test-widget-paced-streaming.js: 373 checks, 0 failed.gh run list --workflow Tests --status failure --limit 200andgh run view <id> --log-failed | grep: see above.No new test file, so no workflow change.
frontend/osa-chat-widget.jsis unchanged; the evidence shows no widget defect (the coalescing on a late tick is the designed deadline behaviour).Closes #691
Design note: CI now runs the widget with an adjusted clock, so late-tick coalescing (fewer, larger steps by design, REVEAL_LAG_MS) is intentionally not tested by this check. With the widget's pacing forced off the check still fails, with and without a stall, so it keeps its teeth.