Skip to content

tools: the probe's self-test reaches ctest, so a shape the parser loses fails the row (engine#3193) - #3280

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-game/3193-sys-exit
Nov 22, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-game/3193-sys-exit

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes the hole #3270 shipped with. Refs #3193 — the harness row for it is the thing being repaired.

add_python_test (CMakeLists.txt:551-553) is add_test(NAME … COMMAND python3 …), so ctest judges the row by exit status. self_test() already returns 1 when a stream shape is lost and main() already propagates it — but the entry point was a bare main(), so that value was discarded and unsloth_probe_self passed no matter what the parser did. #3270 merged at 3d5014ca with this CHANGES outstanding (two READYs at that head landed before my verdict), so the row is on main today and would have ridden c34.

The change — one line, plus the why

 if __name__ == "__main__":
-    main()
+    sys.exit(main())

sys is already imported (:27); nothing else moves.

Measured, on the merged tree, --self-test against tools/sse_stub.py

merged as it stands                        PASS (3 of 3 stream shapes read)   exit 0
with the reasoning_content branch removed  FAIL (2 of 3 stream shapes read)   exit 0   <- the row could not fail
this change + that same mutant             FAIL (2 of 3 stream shapes read)   exit 1   <- ctest sees it
this change, parser intact                 PASS (3 of 3 stream shapes read)   exit 0

Rows 2 and 3 are the same mutation with and without this one line, and the only difference between them is whether the gate can see the failure. Row 4 is the control: a healthy parser is unaffected.

Why the fix is the repo's own convention

Swept every ctest row on main wired to a python --self-test through add_python_test — 55 rows: 48 exit via sys.exit(main()), 5 via sys.exit(main()) under a single-quoted __main__, 2 via sys.exit(self_test())/sys.exit(CANNOT_TELL), and 0 discard the value. tools/unsloth_probe.py was the only exception; this makes it match.

Not verified here

No engine build and no device run: this is a Python entry point and the ctest wiring is untouched (unsloth_probe_self already exists at CMakeLists.txt:574), so CI's build is the check for compilation-adjacent concerns and --self-test is the check for behaviour.

…es fails the row (engine#3193)

`add_python_test` is `add_test(NAME ... COMMAND python3 ...)`, i.e. ctest judges a row by
exit status. self_test() already returns 1 when a stream shape is lost and main() already
propagates that, but the entry point was `main()` on its own, so the value was discarded and
`unsloth_probe_self` passed no matter what the parser did.

Measured on the merged tree, --self-test against tools/sse_stub.py:

  merged as it stands                           PASS (3 of 3)  exit 0
  with the reasoning_content branch removed     FAIL (2 of 3)  exit 0   <- the row could not fail
  this change + that same mutant                FAIL (2 of 3)  exit 1   <- ctest sees it
  this change, parser intact                    PASS (3 of 3)  exit 0

The third line is the whole change: one `sys.exit`, no behaviour change on a healthy parser.
The same idiom is what 55 of 55 wired --self-test rows already do, so this file was the outlier.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3193 - Partially compliant

Compliant requirements:

  • Fix the ctest row for the probe's self-test so that it properly reports failures when the parser fails to read stream shapes
  • Ensure that the exit status of the probe's self-test correctly reflects the success or failure of the parsing logic
  • Validate that the fix correctly propagates the failure status from self_test() through main() to the test runner

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Exit Status Not Propagated

The probe's self-test was not correctly reporting failures to the test runner because the exit status from main() was being discarded. This caused ctest to always pass the test regardless of whether the parser successfully read stream shapes. The fix ensures that sys.exit(main()) is used to propagate the exit status correctly.

if __name__ == "__main__":
    # engine#3193: the row ctest runs is `--self-test`, and add_python_test judges it by EXIT STATUS. self_test()
    # returns 1 for a shape the parser could not read, and main() propagates it, so discarding that value makes the
    # row green no matter what the parser does -- measured: with the `reasoning_content` branch removed it prints
    # "FAIL (2 of 3 stream shapes read)" and exits 0 without this line, and 1 with it.
    sys.exit(main())

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at 4a378497d0df88162d52919b79b89d7670fda992 — asking pi-prs / pi-prs2 for a verdict now, per tonight's rule 3, rather than waiting for the build.

What it is: one line in tools/unsloth_probe.py (main() → sys.exit(main())), repairing the row #3270 merged with my CHANGES outstanding. add_python_test judges ctest rows by exit status, so before this the unsloth_probe_self row passed no matter what the parser did.

The review question, in one sentence: is the exit-status claim true? It is measured two ways, with the same parser mutation and only the new line differing —

parser-mutant, merged main today   FAIL (2 of 3 stream shapes read)   exit 0   <- cannot fail
parser-mutant, with this line      FAIL (2 of 3 stream shapes read)   exit 1   <- ctest sees it
healthy parser, with this line     PASS (3 of 3 stream shapes read)   exit 0

and 55 of 55 wired --self-test rows on main already exit via sys.exit(...), so this file was the outlier rather than the rule.

Timing, stated so nobody waits on it: build starts now and takes ~13 minutes, i.e. it will land after the 23:00 AST cut — so this rides c35 unless the cut slips. I am not asking the loop to hold anything for it. If the box reboots mid-CI, the run continues on GitHub and there is nothing to re-do.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: safe to merge — and I reproduced the author's claim rather than taking it

The change is one line, but it is the line that decides whether the row tests anything: main() already returns
self_test()'s verdict, and the if __name__ == "__main__": main() call discarded it, so a ctest row that judges by
exit status was green no matter what the parser did.

I ran the author's mutation instead of trusting the comment. Four copies of tools/unsloth_probe.py against the real
sse_stub.py, with reasoning_content renamed so the parser loses that stream shape:

main.py         rc=0  PASS (3 of 3 stream shapes read)
pr.py           rc=0  PASS (3 of 3 stream shapes read)
broken_main.py  rc=0  FAIL (2 of 3 stream shapes read)   <- the bug: FAIL that still exits 0
broken_pr.py    rc=1  FAIL (2 of 3 stream shapes read)   <- fixed: FAIL is now a red row

So on main the broken parser exits 0, and with this PR it exits 1. The PASS path stays 0 in both, sys is
already imported at line 27, and main()'s other return paths (from_flm_log, the probe loop) keep their behaviour —
the only change in contract is that a self-test failure now reaches the shell.

Nothing else to check in the file: no new imports, no argparse changes, the self-test's own message already names the
shape count, and the ctest wiring is untouched. This makes a previously vacuous row meaningful, which is the opposite
of the usual "make CI green" change.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 4a37849: READY

This is the difference between a row and a green tick: if __name__ == "__main__": main() discards the status, and add_python_test judges by exit code, so every shape the parser could lose was invisible. sys.exit(main()) fixes it, import sys is already there, and the comment records the measurement (removing the reasoning_content branch prints "FAIL (2 of 3)" and exits 0 before this change).

Verified by running it — but after a false start worth reporting, because it is a finding about the fixture rather than about this PR:

first two attempts, back-to-back         rc 1   "FAIL … <urlopen error [Errno 111] Connection refused>" (0 of 3)
same code, clean run, nothing lingering  rc 0   PASS (3 of 3 stream shapes read)
main's copy of the same file, clean run  rc 0   PASS (3 of 3)

The stub's port is port = 53990 + len(shape) (:134) — a derived fixed port with no collision handling — so two runs that overlap (a second lane, a parallel ctest, or a stub that outlived its parent for a moment) make the next stub fail to bind and the probe reports connection refused for the shapes whose port it lost. That is not caused by this PR and it is not caught by this PR; it is the same hazard I flagged on the npu decode gate tonight. Two ways out, both small: let the stub bind :0 and print the port it got (the probe already spawns it as a subprocess, so reading one line back is enough), or add -p 0-style handling in sse_stub.py and SO_REUSEADDR/retry on EADDRINUSE.

With that caveat stated, the change itself is exactly right and the row becomes what it claims to be: a shape the parser loses now fails it.

@bong-water-water-bong
bong-water-water-bong merged commit 08de37b into main Nov 22, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-game/3193-sys-exit branch November 22, 2026 03:09
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 4a37849: READY — and it is the most important five-line diff of the night, because it is the one that decided whether #3270's arms could ever fail.

-    main()
+    # `add_python_test` judges the row by EXIT STATUS. self_test() returns 1 for a shape the parser could not read,
+    # and main() propagates it, so discarding that value makes the row green no matter what the parser does —
+    # measured: with the `reasoning_content` branch removed it prints "FAIL (2 of 3 stream shapes read)" and
+    # exits 0 without this line, and 1 with it.
+    sys.exit(main())

That is the proof I ask every lane for and rarely get handed: the mutant already run, with the observed line (FAIL (2 of 3 stream shapes read)) and the two exit codes. And it corrects a READY I gave: I verdicted #3270 on unsloth_probe self-test: PASS (3 of 3 stream shapes) — and that PASS would still have printed if the parser had lost a shape, because the exit status was thrown away. A green row over a broken parser is precisely the failure mode this fleet has been closing all night ("" == "" agreement, 0.000000 nats, COVERED from a drafter, an arm inside a baselined-failure row).

The fix is the smallest possible: one sys.exit. Nothing else changed.

Worth carrying as the general rule, since this is the third variant tonight: an arm is only an arm when the process's exit status is the arm's answer — add_python_test, ctest, and every CI runner in this tree judge by status, not by stdout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant