Repository navigation
Conversation
…the deadline across a relaunch (D19 carry)
The items the last review of stage 2 left for a small hardening pair (the shared engine, byte-identical in both
corpora; this corpus's README and theme.mjs):
- A stall in a step only the metrics need, on every page, no longer fails the job: once two page readings are given
up at their limit in such a step, the metrics breaker leaves every page reading after to its checks and counts, with
one metrics problem and one crop problem for the run.
- A reading whose browser disconnects stops then, rather than wait out its limit; a reading about to start relaunches
a browser it finds disconnected; opening a reading's context and page waits 30 s at most.
- A reading that waited for a relaunch takes the time left after the wait; no relaunch starts past the deadline, and
one waits no longer than the time left.
- Only readings on the current browser count towards a relaunch, and a replaced browser is closed once its last
reading ends.
- The run's deadline also counts from the job's start (HARNESS_JOB_START, noted in harness.yml's first step;
HARNESS_JOB_LIMIT, 40 minutes), whichever comes first.
- The limits take decimal digits alone.
- Settling waits for document.fonts.ready 15 s at most, in the page (and, on the Sphinx corpus, MathJax's startup
30 s).
- harness.yml tries `npx playwright install --with-deps chromium` three times.
- The self-test pins drawn.uncounted (the page-level entries too) and `{in}`, looks up the selector that throws from
the expected counts, forces the surviving mutants it can, and removes its temporary directories however a case ends.
Part of QuantEcon/project-theme-parity#15 (D19, QuantEcon/project-theme-parity#80). The twin is the same change in QuantEcon/test-lecture-theme-mystmd, on the same branch, harness/hardening.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WT8bMcHqHDAeUKbY94TYzg
There was a problem hiding this comment.
🟡 Changes recommended
The initial browser launch bypasses the job deadline, risking time reserved for results, while later timeouts incorrectly inflate breaker-opening provenance.
2 open issues
What changed in this PR
Hardens the shared harness against metrics stalls, browser crashes, and deadline overruns while preserving completed checks and counts.
Changes:
- Adds a metrics breaker, browser recovery, and job-aware deadlines.
- Bounds font and MathJax waits and retries browser installation.
- Expands regression tests, cleanup, provenance, and documentation.
| File | Description |
|---|---|
| tests/harness/theme.mjs | Bounds MathJax startup waits. |
| tests/harness/selftest/run.mjs | Adds hardening tests and temporary-directory cleanup. |
| tests/harness/run.mjs | Reports deadlines, breaker activity, and uncounted results. |
| tests/harness/README.md | Documents recovery, limits, and test coverage. |
| tests/harness/lib/visual.mjs | Makes the crop budget configurable for tests. |
| tests/harness/lib/util.mjs | Bounds page readiness waits. |
| tests/harness/lib/engine.mjs | Implements the breaker, browser recovery, and deadlines. |
| .github/workflows/harness.yml | Records job start and retries browser installation. |
Review effort: Balanced (adaptive)
Comment on lines
+647
to
+648
| if (why && left <= 0) { retire(old); return Promise.resolve(); } | ||
| launching = Promise.resolve().then(() => launch(why ? Math.min(LAUNCH_LIMIT, left) : LAUNCH_LIMIT)).then( |
| } | ||
| const { result, givenUp: g } = await limited(Math.min(readingLimit, left), left < readingLimit, (state) => body(browser, state), settle, { browser, words }); | ||
| if (g) givenUp.push({ ...who, cause: g.cause, step: g.step, why: g.why, closed: g.closed, at: new Date().toISOString() }); | ||
| if (breaker && g?.cause === "reading limit" && who.family === "page" && metricsStep(g.step)) { |
…nly the readings that opened it Two points from Copilot's automatic review of #27 and QuantEcon/test-lecture-theme-mystmd#28: - browsers().first() launched even when the run's deadline (the job's, above all) had already passed, which could spend up to Playwright's 180 s launch limit of the time left to write and upload. Now no browser is launched past the deadline: every reading is not started, and provenance's browser build is null. A launch with time left still has Playwright's own limit, as a launch that failed early would stop the run with nothing written. - The metrics breaker went on recording readings given up after it had opened, so `tripped_by` and the summary named more readings than opened it. Now it records only those; later ones are in reading_limit.at_limit. The self-test pins both: a stand-in pool with its deadline passed launches nothing, the breaker's unit case gives up a third reading after it opens, and scenario J (the job's deadline already passed) checks no browser was launched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WT8bMcHqHDAeUKbY94TYzg
mmcky
added a commit
to QuantEcon/test-lecture-theme-mystmd
that referenced
this pull request
Dec 2, 2026
…nly the readings that opened it Two points from Copilot's automatic review of QuantEcon/test-lecture-theme-sphinx#27 and #28: - browsers().first() launched even when the run's deadline (the job's, above all) had already passed, which could spend up to Playwright's 180 s launch limit of the time left to write and upload. Now no browser is launched past the deadline: every reading is not started, and provenance's browser build is null. A launch with time left still has Playwright's own limit, as a launch that failed early would stop the run with nothing written. - The metrics breaker went on recording readings given up after it had opened, so `tripped_by` and the summary named more readings than opened it. Now it records only those; later ones are in reading_limit.at_limit. The self-test pins both: a stand-in pool with its deadline passed launches nothing, the breaker's unit case gives up a third reading after it opens, and scenario J (the job's deadline already passed) checks no browser was launched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WT8bMcHqHDAeUKbY94TYzg
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


The corpus hardening pair: the three defects the last review of stage 2 found, and the nits, test gaps and older items it carried, in the shared engine (byte-identical in both corpora:
lib/*.mjs,run.mjs,selftest/run.mjs,harness.yml), this corpus's README and itstheme.mjs(MathJax's startup wait bounded). Part of QuantEcon/project-theme-parity#15 (D19, QuantEcon/project-theme-parity#80). The twin is QuantEcon/test-lecture-theme-mystmd#28, on the same branch,harness/hardening, which the engine-drift check pairs this one with. By D19, metrics and crops are evidence only: none of this changes what a reading measures or crops, only what a run does when a reading or a browser stalls, crashes or runs out of time.The three defects
1. A metrics-only stall on every page failed the job. Each reading given up in a step only the metrics need kept its counts but cost its worker the full reading limit, so a stall there on every page used up the run's limit, and the readings not started lost their checks and counts (exit 1), against "Warn, don't fail". Now a metrics breaker (
engine.mjs,readingsandpageTask): once two page readings have been given up at their own limit in a step only the metrics need (measuring a family, the body text, the fonts, the crops), every page reading after takes its checks and counts alone, with no metrics or crops. One metrics problem and one crop problem for the run say so, as do the summary ("The metrics breaker opened at …") andprovenance.json(reading_limit.metrics_breaker:threshold,tripped_by,opened,skipped). Readings already in such a step when it opens may still stall to their limit, side by side, so the stall costs one or two reading limits of time, not one per page reading. A per-step budget of its own, the optional half of the suggested fix, is not added: a stalled evaluation cannot be stopped without giving up its reading, so it would only give the reading up sooner, at the price of a new cause and new wording, and the breaker already bounds the cost. Test:limitCheck's H (everylong_cellsreading held in its fonts step, readings 10 s, run 45 s): exit 0, the two desktop readings given up there keeping their checks, counts and metrics rows, the four after left to their checks and counts, every check run and every count taken. On main's engine (a copy of main with the branch's self-test, its new functions exported as main has them) H exits 1: four readings given up in their fonts step, one at the run's limit, one not started. The carry's own scenario (the fonts step looping on every page, readings 10 s, run 40 s, six pages): main exits 1 after 41 s in both corpora (16 readings given up, 20 not started); this branch exits 0 after 26 s here and 35 s in the twin (the first four given up side by side, no reading not started, every check run and every count taken). Also a unit case: the breaker opens on the second page reading given up in such a step, not on a feature's or a count's.2. After a browser crash, a reading could wait out its full limit.
limitedraced only its timer,get()handed out a disconnected browser, and opening a context or page had no bound. Nowlimitedalso settles, as an error, when the reading's browser disconnects (or had already), and removes its listener after;get()relaunches a browser it finds disconnected before handing it out; and opening a reading's browser context or page waits 30 s at most (the reading stops on it, a late one is closed, and the browser is relaunched: "did not open a reading's … in 30 s"). Tests, in the unit cases with stand-in browsers: a reading whose browser disconnects at 100 ms stops then with "the reading stopped (the browser disconnected)", not at its 5 s limit, and one whose browser had disconnected stops at once (on main: given up at its limit, causereading limit); a browser found disconnected as a reading is about to start is relaunched first (on main: the disconnected browser handed out); a reading the browser does not open a page for stops, and the browser is relaunched. AndlimitCheck's G, end to end: the browser killed with two readings at a time; the readings on it stop, the browser relaunches once, and the readings that start while it relaunches wait for it and run as on the good site. The carry's scenario on this branch (the Sphinx corpus, the browser killed at 8 s to 21.5 s in 1.5 s steps, readings 20 s): no reading reached its limit in 10 trials (the last review saw 3 of 10 on main), each run ended in 23 to 25 s with one relaunch, and one reading caught as it opened its context stopped then.3. A reading that waited for a relaunch kept its old budget.
leftwas computed beforeawait b.get(), andafter()relaunched past the deadline. Now a reading gets its browser first and counts the time left after the wait, so with none left it is not started, naming the deadline; no relaunch starts past the deadline; and a relaunch waits for its browser (Playwright's launchtimeout) no longer than the time left. Tests, in the unit cases: a reading that waits for a relaunch slower than the time left is not started and never runs (on main: it ran, past the deadline); no relaunch past the deadline, and a relaunch's launch bounded by the time left (on main: the dead browser handed out, and the launch given no bound). The carry's scenario (the Sphinx corpus, a relaunch that takes 20 s, the browser killed at 15 s, the run 25 s): main ended after 41 s, 16 s past its deadline; this branch after 26 s, with the readings left naming the run's limit and no relaunch started for them.The nits and gaps
streakcounted readings on browsers already replacedclose()at the run's end waits for those already closing. A unit case pins both: open while a reading still uses it, closed after.harness.yml's first step notes the job's start (JOB_STARTED_MS, before the checkout), given to the rendered checks step alone asHARNESS_JOB_START;runDeadlinetakes the nearer of the run's 25 minutes from its start and 40 minutes from the job's (HARNESS_JOB_LIMIT), and names which (run_limit.deadline_by,run_limit.job, and the rows' and summary's wording). A job start that is not digits, or lies more than a minute ahead or 45 minutes back, is refused. Unit cases pin the choice and the refusals;limitCheck's J runsrun.mjswith the job's deadline already passed. The self-test's own runs ofrun.mjsnever see the job's start or limits.0x2710,1e4and" 20000 "HARNESS_READING_LIMIT,HARNESS_RUN_LIMITandHARNESS_JOB_LIMITtake decimal digits alone (a sign, a point, a space, an exponent or hexadecimal refused, and recorded).limited(a reading given up before its context opened:closednull, its body told it was given up and stopped at its next step); N14, N15 and L19 by scenario D's new reading, the renderer killed at the second shot of its crops (that reading must stop on it, keeping its rows, counts, metrics and first crop, its failed shots a crop problem each and nothing more); N16 and N17 by the stand-in unit cases and scenario G (two readings at a time: a reading that starts during a relaunch waits for it, and the browser relaunches once); L07 and L08 by unit cases of the crop step with a signal that turns at a chosen read (given up as its first crop is written: that crop removed, no further shot; given up after it: the crop kept, no further shot); C04 by a reading's own crop budget, whichcropReadingnow takes as an argument (shortened to 1 ms); C16 by a clipped surface below the window, which must be shot with the page scrolled to it. With 27 mutants of this pair's own code, 39 in all (the shared engine, run in the Sphinx corpus, each in a process group of its own, after an unmutated run that passes): 38 killed, 1 surviving, D2f (opening a context with no bound), which no fixture forces, as no fixture stops the browser between two readings; the unit cases give a reading that error, and its browser is relaunched. N17 and F2 (readyWithinwith no timer) first hung the unit cases; the settle case now races its waits against a timer of its own, and both are killed by an assertion (N17 by scenario G alone).harness-selftest-<pid>-<what>-…: each case removes its own when it ends; whatever is left is removed as the self-test exits (an error, Ctrl-C, SIGTERM or SIGHUP, which also stop therun.mjsruns it started in the background); and those of a self-test killed outright (SIGKILL) are removed by the next, once that process has gone. After both full self-tests, noharness-selftest-*directory was left in the system's temp directory.npx playwright install --with-deps chromiumis tried three times, 30 s and then 60 s apart, with a warning for each retry and an error after the third.{in}{select, in, text}tests the firstindescendant's text (none: not counted),{select, text}the element's own, on a page where they differ.drawn.uncountedchecknow comparesuncountedwith what the expected counts imply, in order: a page reading with no count taken is one entry, family null, whosewhyis that reading's error rows' detail (the bad site's missing page, and its page whose dark scheme does not take effect); the selector that throws is one entry a reading, saying so.whylabelwhy"). The one label I found that misleads: the summary's "Empty counts: N, from M reading(s) not taken", which counteduncountedentries as readings though the selector that throws is one family's count in a reading that took the rest. It now says which: "from M page reading(s) with no count taken and K count(s) of one family not taken (…)". Today's live sites have no empty counts, so their summaries are unchanged. This is my guess at the nit, for the review to confirm: if it meant anotherwhy, that one is still open.expected-good-counts.csvleaves empty at every reading of the good site, so neitherdrawnChecknorquietTablerests on the selector's text; the self-test stops unless there is exactly one.mystmd_nativephone-dark hangdocument.fonts.readynow waits 15 s at most, bounded in the page, as do MathJax's startup (30 s, in this corpus'stheme.mjs). A unit case pins it with a web font that never comes (before: settling still waiting after 8 s). A page whose main thread has stopped still answers nothing, so its reading is given up at its limit in the step it was in, whichreading_limit.at_limitnames.div.highlight's rounded edge, for stage 3's comparator to tolerate.Copilot's automatic review
Copilot reviewed both pull requests on its own, by the repositories' setting; no reviewer was requested. Its two points are taken in the second commit. The first browser is no longer launched once the deadline has passed: every reading is then not started, and
provenance.json's browser build is null (scenario J now checks it). And the metrics breaker records only the readings that opened it, where it went on recording those given up after (with four workers,tripped_byand the summary named four readings, not two); a unit case gives up a third reading after it opens. A first launch with time left keeps Playwright's own 180 s limit rather than the time left: a launch that fails stops the run with exit 2 and nothing written, which is worse than a late start, and no reading starts past the deadline either way.Outputs on today's sites
run.mjs --urlfrom this branch's first commit against both live sites (2026-12-02; the second commit changes nothing a run with time left and no breaker does), compared with main's run on the same site (2026-11-30, both mains unchanged since, so the same builds), and, for the Sphinx site, with a second run of main's code (2026-12-02) to show the noise:sha256(19 rows; main against main's second run: 11)launch-notebooksin light and dark isskipon main (github.com answered 429, and 503 on main's second run) andfailhere (it answered); andfiguresphone light'sconsolerow,failin all three, also names "Permissions policy violation: compute-pressure is not allowed in this document", which the page's embedded YouTube player logged in this run alonecode-celloncode_cellsandlong_cells(main against main's second run: 7, the same kind), the rasteriser noise the carry leaves to stage 3's comparatorsha256includedadmonitions(itsconsolerowfail); this run did not (pass)1e6e70a5…on bothEach run took as long as main's (207 s and 278 s), every reading finished, the browser was not relaunched, and the breaker did not open:
reading_limit.metrics_breakerrecords its rule, with nothing tripped or skipped, andrun_limit.jobis null outside CI.Tests
limitedcase also differs on main, but only in wording: main names the module's limit, not the one it was given.CI
Green on both pull requests at their second commits, every step on the first attempt, with no warning on either run (no reading given up or not started, no metrics or crop problem); the engine-drift step found the twins' shared files the same. The rendered checks jobs' steps:
The Sphinx install took six minutes on its first and only try (no retry warning); the time is the runner's apt, not the harness.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WT8bMcHqHDAeUKbY94TYzg