Repository navigation
build: ratchet instruction file byte budgets - #5132
Conversation
Measure instruction files in LF-normalized bytes alongside their existing line budgets. Record current byte-cap exceptions and preserve inherited-offender handling when a base ref predates the new baseline.
jakildev
left a comment
There was a problem hiding this comment.
Review — build: ratchet instruction file byte budgets
Verdict: needs-fix
The byte ratchet works and is well tested for the line-cap/byte-cap split, recorded-budget and inherited cases, but plan criterion 1(e), the byte warning band, has no test, so the byte ::warning / ::error paths and BYTE_WARN_BAND run in no test.
Needs-fix
scripts/fleet/tests/test_lint_instruction_size.py(AgainstRef, besidetest_an_introduced_excess_within_the_band_warns_and_passes/test_an_introduced_excess_past_the_band_fails, ~line 381–398) — the issue's acceptance criterion requires "an excess inside the 800-byte band warns and passes, past it fails", and the PR's byte-side--againstcoverage is the inherited case only (grepof the test file forband/800/BYTE_WARNfinds only the line-band cases). Add two cases: an introduced byte excess of ≤800 (e.g. +800) exits 0 withwithin the 800-byte band, and +801 exits 1 withpast the 800-byte band. Keep the line count under the line cap so only the byte path fires. Then re-runfleet-positive-controland update Row 1 of the evidence table to name the band cases.
Nits (follow-up)
scripts/lint_instruction_size.py(main,args.warn_band) —--warn-bandmoves only the line band; the byte band is the fixedBYTE_WARN_BAND, so--warn-band 0still tolerates 800 bytes. State "lines only" in the docstring and theVALIDATION.mdrow, or scale the flag by 80 for bytes.scripts/lint_instruction_size.pymodule docstring — the regeneration sentence still names onlywrite_baseline(scan_tree()[0]), and the line "so it shows in the PR diff where a reviewer weighs it. The baseline is regenerated only when" is now over-long; mention the byte baseline.scan_tree/scan_bytesare near-duplicate loops; a shared iterator over instruction files would keep the two in step.
Acceptance (issue #4970)
4 of 5 met. Unmet:
- Criterion 1(e): byte band warns at ≤800 and fails past it — no test exercises an introduced byte excess (mirrored in Needs-fix above).
Checked
- Read the full diff and
scripts/lint_instruction_size.py/scripts/ratchet_against.pyat head696c2a4. - Ran
scripts/fleet/tests/test_lint_instruction_size.py: 33 tests, OK. - Ran
scripts/lint_instruction_size.py --against origin/master: exit 0; three byte::notice budget raisedlines (16000 → 16105 / 20823 / 17883) match the new baseline; the nine line offenders are all inherited (same on master). - Combined exit-code logic for line + byte
report_againstreads correct (2 > 1 > 0;Noneonly when neither side is over). - CI:
instruction-size,instruction-refs,python-lint,comment-refs,whitespace,closes-lint,no-plan-filesgreen on the head;fleet-testsandrender-harness-testsstill running at review time, so unread — I ran the fleet suite for this script locally instead. - Not independently re-run: the 4-of-33 positive-control figure.
Escalation: author-agent to address, then re-request review.
🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)
Opus recheck not required.
|
Addressed feedback:
— worker (Codex) |
jakildev
left a comment
There was a problem hiding this comment.
Review — build: ratchet instruction file byte budgets
Verdict: approve
The one prior needs-fix (no test of the byte warning band) is closed by two new boundary tests at ea07fc0, and nothing else changed since the last review.
Prior-review resolution
- ✅
scripts/fleet/tests/test_lint_instruction_size.py(AgainstRef) — byte band untested — verified fixed at ea07fc0:test_an_introduced_byte_excess_within_the_band_warns_and_passes(+800 → rc 0,::warning … within the 800-byte band) andtest_an_introduced_byte_excess_past_the_band_fails(+801 → rc 1,::error … past the 800-byte band). Both fixtures are one line, so only the byte path fires. - ↗ Nits (follow-up) from the first pass (
--warn-bandlines-only wording, module docstring regeneration sentence,scan_tree/scan_bytesduplication) — deliberately deferred by the author; they ride the next PR on this surface, no label.
Acceptance (issue #4970)
5 of 5 met (criterion 1(e) now covered by the two band tests).
Checked
- Read the delta
696c2a4..ea07fc0(test file only, +32 lines); no executable code changed. - Ran
scripts/fleet/tests/test_lint_instruction_size.pyat head: 35 tests, OK. - Ran
scripts/lint_instruction_size.py --against origin/master: exit 0; three byte::notice budget raisedlines match the baseline; the five line offenders shown are inherited. - CI:
instruction-size,instruction-refs,python-lint,comment-refs,whitespace,closes-lint,no-plan-filesgreen on the head;fleet-testsandrender-harness-testshad not completed at review time, so unread — I ran the suite for this script locally instead. - Not independently re-run: the 6-of-35 positive-control figure.
Escalation: none. Safe for merge.
🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)
Opus recheck not required.
Summary
Test plan
bash scripts/fleet/tests/run_all.sh --only lint_instruction_sizefleet-positive-control scripts/fleet/tests/test_lint_instruction_size.py origin/master --include scripts/lint_instruction_size.py --include scripts/ratchet_against.pypython3 scripts/lint_instruction_size.py --against origin/masterruff check scripts/python3 scripts/fleet/tests/test_validation_index.pyAcceptance evidence
bash scripts/fleet/tests/run_all.sh --only lint_instruction_sizefleet-positive-control ... origin/masterpython3 scripts/lint_instruction_size.py --against origin/masterruff check scripts/python3 scripts/fleet/tests/test_validation_index.pyNotes for reviewer
fleet-pr-overlap --base masterfound only inherited base conflicts on thecross-cutting validation row (PRs #5101, #5110, #5119, #5121, and #5124).
Closes #4970