Skip to content

Book harness: keep session state after a hang, and compare like with like - #12

Merged
rocky merged 4 commits into
masterfrom
book-harness-state
Nov 20, 2026
Merged

rocky merged 4 commits into
masterfrom
book-harness-state

Conversation

@tombouctou

Copy link
Copy Markdown
Contributor

Changes how the book/ harness (Mathics3 vs WMA 15 on the Combinatorica book notebooks) runs and compares cells, so that its own behavior no longer skews the pass shares.

  • State after a hang: after the Mathics3 process restarts, earlier cells that assign are replayed, and so are other finished cells that took ≤ 20 s. A replay that fails is recorded in replay_lost. A later failing cell that uses one of its symbols gets the verdict skip-after-hang.
  • Timing / AbsoluteTiming / ByteCount: compared by shape only. This now also applies when deciding whether a cell is "random" (WMA results differ between seeds). Before, every timing cell passed unchecked through that check. Cells that plot or fit timing lists are compared by shape too.
  • Cells with several expressions: both harnesses evaluate them as one CompoundExpression.
  • %: both harnesses set $Line/Out[i] per cell. A failing % cell right after a cell that isn't compared is skipped.
  • Crash at the cell time limit: the runner records it itself as timeout (crash_at_timeout).
  • run_wma.wls: drops . from $Path. Run from the repo root, it was loading this repository's Mathics3 Combinatorica/ instead of WMA's own. It now stops if the package didn't load.
  • run.sh accepts PKG= to load another copy of the package.

Rerun on all five notebooks (120 s per cell). Pass shares, old → new: Chapter3 79.1 → 78.7 %, Chapter4 71.6 → 71.2 %, Chapter5 72.5 → 72.0 %, newFeatures 83.6 → 87.2 %, tutorial 100 → 100 %. The small drops come from the timing loophole being closed: about 17 cells had passed through it. The newFeatures gain is run-to-run timing near the 120 s limit.

Not in this PR: test/test_book_examples.py and the stored book/wma / book/mathics data still use the old evaluation.

🤖 Generated with Claude Code

tombouctou and others added 4 commits November 19, 2026 22:26
…like

- After a restart, replay every earlier cell that finished and assigns
  something, whatever its time; list the ones that cannot be redone in
  replay_lost, and let compare.py skip failures that depend on them
  (skip-after-hang).
- Evaluate a cell with several expressions as one CompoundExpression, in
  both harnesses.
- Make cell i input $Line = i with Out[i] its value, in both harnesses, so
  % and %% work as in a notebook.
- Record a crash as the time limit fires as a timeout (crash_at_timeout),
  in run_mathics.py and in the watchdog.
- compare.py: decide whether a Timing/ByteCount cell is random on its
  shape, so a different timing alone no longer makes it pass unchecked.
- run.sh: PKG= selects another copy of the package.

MATH-421

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run from the repository root, Needs["Combinatorica`"] found the Mathics3
package's Combinatorica/ directory through "." on $Path, failed to load it,
and every cell ran against WMA's built-in graph functions. Drop "." from
$Path, and stop when the package did not load.

MATH-421

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
newFeatures 46 is UnrankSetPartition[%, 5] right after an Information
cell, whose usage text is never compared.

MATH-421

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A cell such as ListPlot[First /@ rt] or Fit[First /@ rt, ...] works on
the values an earlier rt = Table[Timing[...], ...] assigned: compare it by
shape as well. Only a top-level assignment of an expression with Timing
marks a symbol; c in Timing[c = ConnectedComponents[s]; ] is a value.

MATH-421

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rocky

rocky commented Nov 20, 2026

Copy link
Copy Markdown
Member

LGTM

@rocky
rocky merged commit 4ba89f0 into master Nov 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants