Skip to content

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

Backlog

Description

@itsonewi

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

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.

Activity

  1. Creaa commented on Nov 25, 2026

    @Creaa
    Contributor

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions