Scripts: coverage_gate.py ignores the sweep's exit code, so a failed sweep passes and --update can lower the baseline to match it #2250

Open
opened 2026-11-25 11:42:11 +00:00 by itsonewi · 1 comment
itsonewi commented 2026-11-25 11:42:11 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by itsonewi on 2026-11-25T11:42:11Z.


Summary

scripts/coverage_gate.py (426a5a7) runs the sweep and then reads only its stdout:

proc = subprocess.run(cmd, capture_output=True, text=True)
try:
    run = sweep_json(proc.stdout)
except ValueError as e:
    ...
    return 2

proc.returncode is never inspected. If the sweep exits non-zero but still printed a report line that parses - a worker that died after the summary, a panic or an OOM on the last programs, a sweep cut short with a partial count - the gate treats it as a complete sweep and compares it against the baseline.

Why it matters more with --update

--update writes the baseline before anything is compared, and from whatever the sweep reported:

if args.update:
    ...
    args.baseline.write_text(json.dumps({"stages": run["stages"]}, ...))
    print(f"baseline written: {args.baseline}")
    return 0

So a failed sweep does not just pass once: it can replace the committed reference with the lower counts of the build that failed, and every later run compares against that. The gate then reports "no regressions" for exactly the translation loss it exists to catch.

Not #2196, #2250 or #2099

  • #2196 is --validate never being passed, so validator_failed is always 0.
  • #2250 / #2253 are the empty sweep erasing the baseline.
  • #2099 is argument and error-path hardening: a missing --xcl/--rpf, an unreadable --run-json, malformed JSON, a spawn failure. A subprocess that starts, runs and exits non-zero is not one of those - that path has no check at all.

Suggested fix

if proc.returncode != 0:
    print(f"the sweep exited {proc.returncode}: {proc.stderr[-2000:]}", file=sys.stderr)
    return 2

right after subprocess.run, before sweep_json(proc.stdout). --run-json is unaffected (no process is started). Two tests in scripts/test_coverage_gate.py would cover it: a sweep fixture that exits 1 with a valid report line (expect 2, and the baseline byte-for-byte unchanged with --update).

Tested

  • Nothing run: read from 426a5a7 without a checkout. The claim is the absence of a read of proc.returncode in the file.

AI use

  • Claude (Opus 5.5) read scripts/coverage_gate.py and scripts/test_coverage_gate.py on 426a5a7 and wrote this report; the human account checked the lines against the file before opening it.
<!-- greyfinch-sync:ivall/xcl:issue:6603682903 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2260). Originally posted by [itsonewi](https://github.com/itsonewi) on 2026-11-25T11:42:11Z. --- ### Summary `scripts/coverage_gate.py` (`426a5a7`) runs the sweep and then reads only its stdout: ```python proc = subprocess.run(cmd, capture_output=True, text=True) try: run = sweep_json(proc.stdout) except ValueError as e: ... return 2 ``` `proc.returncode` is never inspected. If the sweep exits non-zero but still printed a report line that parses - a worker that died after the summary, a panic or an OOM on the last programs, a sweep cut short with a partial count - the gate treats it as a complete sweep and compares it against the baseline. ### Why it matters more with `--update` `--update` writes the baseline **before** anything is compared, and from whatever the sweep reported: ```python if args.update: ... args.baseline.write_text(json.dumps({"stages": run["stages"]}, ...)) print(f"baseline written: {args.baseline}") return 0 ``` So a failed sweep does not just pass once: it can replace the committed reference with the lower counts of the build that failed, and every later run compares against that. The gate then reports "no regressions" for exactly the translation loss it exists to catch. ### Not #2196, #2250 or #2099 - #2196 is `--validate` never being passed, so `validator_failed` is always 0. - #2250 / #2253 are the empty sweep erasing the baseline. - #2099 is argument and error-path hardening: a missing `--xcl`/`--rpf`, an unreadable `--run-json`, malformed JSON, a spawn failure. A subprocess that starts, runs and exits non-zero is not one of those - that path has no check at all. ### Suggested fix ```python if proc.returncode != 0: print(f"the sweep exited {proc.returncode}: {proc.stderr[-2000:]}", file=sys.stderr) return 2 ``` right after `subprocess.run`, before `sweep_json(proc.stdout)`. `--run-json` is unaffected (no process is started). Two tests in `scripts/test_coverage_gate.py` would cover it: a sweep fixture that exits 1 with a valid report line (expect 2, and the baseline byte-for-byte unchanged with `--update`). **Tested** - Nothing run: read from `426a5a7` without a checkout. The claim is the absence of a read of `proc.returncode` in the file. **AI use** - Claude (Opus 5.5) read `scripts/coverage_gate.py` and `scripts/test_coverage_gate.py` on `426a5a7` and wrote this report; the human account checked the lines against the file before opening it.
Creaa commented 2026-11-25 12:06:28 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by Creaa on 2026-11-25T11:48:25Z.


I’m taking this. The fix and regression test are ready locally. I’m running the full workspace suite before opening the PR.

<!-- greyfinch-sync:ivall/xcl:comment:7161524211 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2260#issuecomment-7161524211). Originally posted by [Creaa](https://github.com/Creaa) on 2026-11-25T11:48:25Z. --- I’m taking this. The fix and regression test are ready locally. I’m running the full workspace suite before opening the PR.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#2250
No description provided.