Repository navigation
tools: the probe's self-test reaches ctest, so a shape the parser loses fails the row (engine#3193) - #3280
Conversation
…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.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
ready for review at What it is: one line in 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 — and Timing, stated so nobody waits on it: |
|
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: I ran the author's mutation instead of trusting the comment. Four copies of So on Nothing else to check in the file: no new imports, no argparse changes, the self-test's own message already names the |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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.
|
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 ( The fix is the smallest possible: one 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 — |
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) isadd_test(NAME … COMMAND python3 …), so ctest judges the row by exit status.self_test()already returns 1 when a stream shape is lost andmain()already propagates it — but the entry point was a baremain(), so that value was discarded andunsloth_probe_selfpassed no matter what the parser did. #3270 merged at3d5014cawith this CHANGES outstanding (two READYs at that head landed before my verdict), so the row is onmaintoday and would have ridden c34.The change — one line, plus the why
sysis already imported (:27); nothing else moves.Measured, on the merged tree,
--self-testagainsttools/sse_stub.pyRows 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
mainwired to a python--self-testthroughadd_python_test— 55 rows: 48 exit viasys.exit(main()), 5 viasys.exit(main())under a single-quoted__main__, 2 viasys.exit(self_test())/sys.exit(CANNOT_TELL), and 0 discard the value.tools/unsloth_probe.pywas 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_selfalready exists atCMakeLists.txt:574), so CI'sbuildis the check for compilation-adjacent concerns and--self-testis the check for behaviour.