Repository navigation
Stop the stall-window comparison being decided by one noisy sample - #10246
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c033c6bdf7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ); | ||
|
|
||
| const withReset = await readsBeforeSettling(Math.floor(withoutReset / 2)); | ||
| if (withReset >= withoutReset * 1.25) return; |
There was a problem hiding this comment.
Do not accept the most favorable noisy sample
When the baseline run is scheduled more slowly than the following run, this condition can pass even if the lastHealthy reset is removed: the two otherwise identical loops then produce withReset / withoutReset >= 1.25 solely because the second loop completed more polls in the same wall-clock window. The observed runner variance can occur in either direction, and returning on the first success across three rounds increases the chance that a real regression is hidden; use a deterministic clock or a comparison that does not select the maximum favorable ratio.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
You are right, and best-of-three was the wrong shape. The noise runs in both directions, so a round that happened to schedule the second run faster could clear 1.25 on its own with the reset removed, and taking the most favourable round gave three chances at that instead of one. That is weaker than the single sample it replaced, which is the opposite of what I wanted.
Changed in 8cc9e16 to the majority of three rounds, always run, no early return. That is strictly stronger than the original single sample in both directions: it takes two unlucky rounds to fail a healthy reset, and two lucky ones to pass a missing one.
Re-verified both directions, three times each. Unchanged source passes every time. With lastHealthy = Date.now() deleted from model-lifecycle-events.ts:
0 of 3 rounds: 356 with a reset against 354 without; 365 against 361; 358 against 333
0 of 3 rounds: 359 against 355; 357 against 361; 358 against 359
0 of 3 rounds: 358 against 355; 360 against 360; 360 against 359
Which also puts a number on the noise you are describing: with the two loops identical, the widest excursion in nine paired samples was 358/333 = 1.075, against a 1.25 bar. Not proof it cannot go further on a windows-latest runner, but it is the margin the majority now has to beat twice rather than once.
On the deterministic clock: that is the right end state and I agree it beats any amount of sampling. It needs withBackgroundLoadNotice to take an injectable clock and timer, so it is a source change in src/lib/model-lifecycle-events.ts rather than a test one, and I did not want to put it in a PR whose job is unblocking a red main. Worth doing separately.
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Frontend unit tests (Windows)is red onmainat01262664e, on one subtest out of 6821:The source is fine.
withBackgroundLoadNoticestill setslastHealthy = Date.now()on every readable phase, and the whole suite passes on Linux.What the test measures
It cannot assert a read count against a millisecond budget, because the source reads
Date.now()and armssetTimeoutitself, so it runs on the wall clock and one poll costs about 1 ms locally against about 15 ms on a Windows runner. The comment at the top of the test says so, and records that the previous version assertedreads > 4against a 30 ms window and was both flaky on Windows and vacuous on Linux.So it measures the reset against the same loop without one, and requires the reset to carry the loop at least 1.25x further. Dividing the platform out like that is the right idea and I have kept it.
What it does not account for is that the two halves are separate wall-clock runs, taken one after the other. Anything that slows a shared
windows-latestrunner between them skews the ratio, and only ever downwards for whichever half got unlucky. A half-way restart should score about 1.5; this run scored 56/47 = 1.19 against a 1.25 bar. It missed by three reads.The change
Sample the pair up to three times and pass on the first round that clears the bar.
That costs nothing in strength, because the property under test is deterministic in the source. With the reset removed the two loops are the same loop, so every round scores about 1.0 and no amount of resampling gets one over 1.25. Only an unlucky measurement is retried, never a wrong answer. The failure message now reports every round rather than just the last, so a real regression reads as three consistent ~1.0 ratios instead of one borderline number.
Verified both directions:
npm testis 6821 pass / 0 faillastHealthy = Date.now()deleted frommodel-lifecycle-events.ts, the test still fails, through all three roundsThe second one is the check that matters. A retry loop that cannot fail is worse than the flake it replaces, so I removed the reset in the source and confirmed the test goes red before proposing this.
Scope
Nothing else in the file or the suite changes, and no source changes.
STALL_MSand the 1.25 bar are untouched, so the assertion is the same assertion, just not decided by a single sample.