From 0ff9671393eb185ab0bac8d08bcd6236c1433eed Mon Sep 17 00:00:00 2001 From: Timothy Date: Tue, 4 Aug 2026 22:52:03 +0200 Subject: [PATCH] fix(688): pin the minority band's constants and inclusivity; two prose corrections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review round 7. Its adjudication of the round-6 dispute went the branch's way — measured at `f394d6ce`, the sha the record actually cites, the #620-era distribution is n=167, min 2, median 26, p90 52. Round 6 had measured `fefd11dff` (p90 57), a different tree. The number stays as written. BLOCKING FINDING: the 2%/25% constants and their inclusive boundaries were not pinned at all. Mutating 0.02 -> 0.03, 0.25 -> 0.30, or either `<=` to `<` passed all eight calibration tests. Those are not free parameters — they ARE the documented CI-red thresholds, so a silent shift would quietly falsify the 38/718 figures in docs.corpus-size-signal and docs/ci-cd.md (a strict cap reds after 37 long additions, a strict floor after 717 short ones). test_the_minority_band_BOUNDARIES_are_exactly_where_documented pins all four. It uses 100-record fixtures so k over the ceiling IS k%, and both 2/100 and 25/100 are exactly representable and compare equal to the constants — true boundary cases, not near-misses. Verified by mutation: all four now fail it. PROSE - corpus-size-signal said what stays blocking is "what routine growth cannot break", immediately before explaining that 38 routine additions break it. Now "what no SINGLE ordinary addition can break", which is what is actually true. - docs/ci-cd.md said the fine claim is "never asserted"; it is never asserted AGAINST THE LIVE CORPUS, and IS asserted on synthetic distributions the tests own. Corrected — the distinction is the whole design. Correction to an earlier commit message in this branch (9d2b30dc3, already pushed, so recorded here rather than rewritten): it said the cross-check was clean on "all 183 real records". 183 is the active keyed-record count; the cross-check scans the record WINGS — 195 files at that commit, 190 of them carrying frontmatter. The check was clean; the figure named the wrong population. Verification: 432 scripts/tests pass; ruff at baseline parity (47); validator exits 0 with no drift notice; corpus at p90=60, 18/183, calibrated; new record still 60 lines. Decisions-Edit: yes Co-Authored-By: Claude Opus 5 (1M context) --- docs/ci-cd.md | 5 +-- .../records/docs/corpus-size-signal.md | 5 +-- scripts/tests/test_decisions_validate.py | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/docs/ci-cd.md b/docs/ci-cd.md index 357f1af20..f350d6c77 100644 --- a/docs/ci-cd.md +++ b/docs/ci-cd.md @@ -72,8 +72,9 @@ step is now continuous. The release boundary is instead where you: consolidating 15 of the 18 offenders away. The floor is a fraction rather than "at least one record", which would accept any ceiling up to 229 on the live corpus; as a fraction the accepted range is 43..180. - - **reported, never asserted** — the fine claim that the ceiling sits between the **90th and - 95th percentile**, i.e. at the tail boundary. `main()` prints a `::notice::` when it drifts. + - **reported, never asserted against the LIVE corpus** — the fine claim that the ceiling sits + between the **90th and 95th percentile**, i.e. at the tail boundary. `main()` prints a + `::notice::` when it drifts; the tests assert it only on distributions they own. It is an order statistic over a sparse distribution, so a single new record could move p90 by 21 lines and red the blocking job for whoever wrote it; a ceiling going out of date is the passage of corpus growth, not a defect in the commit under test, so it is treated like diff --git a/docs/decisions/records/docs/corpus-size-signal.md b/docs/decisions/records/docs/corpus-size-signal.md index da91b5123..650a7d0b2 100644 --- a/docs/decisions/records/docs/corpus-size-signal.md +++ b/docs/decisions/records/docs/corpus-size-signal.md @@ -65,8 +65,9 @@ all asserted, in the blocking job, a property of a corpus the commit under test The fine claim is genuinely useful and genuinely fragile, so it is now measured on every run and printed as a `::notice::` — the same treatment `stale_records` gets, and for the same stated reason: a constant going out of date is the passage of time, not a defect in this change. What stays -blocking is only what routine growth cannot break — each record moves a fraction by at most 1/N, so -from **18/183** over the ceiling it takes **38** consecutive over-ceiling additions to BREACH the +blocking is only what no SINGLE ordinary addition can break — each record moves a fraction by at +most 1/N, so from **18/183** over the ceiling it takes **38** consecutive over-ceiling additions to +BREACH the 25% cap (37 lands exactly on 0.25, which still passes), against **one** record to break v4. **The floor is a fraction, not `> 0`, and review is why.** The first draft of v5 asserted only diff --git a/scripts/tests/test_decisions_validate.py b/scripts/tests/test_decisions_validate.py index 917e952a0..6ce7d4833 100644 --- a/scripts/tests/test_decisions_validate.py +++ b/scripts/tests/test_decisions_validate.py @@ -1110,6 +1110,37 @@ def test_ceiling_calibration_is_empty_safe(): assert cal.n == 0 and not cal.marks_tail and not cal.flags_minority +def test_the_minority_band_BOUNDARIES_are_exactly_where_documented(): + """Pins both constants AND both inclusivities, which review found entirely unmutated. + + Mutating `0.02 -> 0.03`, `0.25 -> 0.30`, or either `<=` to `<` passed all eight calibration + tests. These are not free parameters — they ARE the documented CI-red thresholds, so a silent + shift changes them (a strict cap reds after 37 long additions instead of 38; a strict floor + after 717 short ones instead of 718), quietly falsifying the numbers in `docs.corpus-size-signal` + and `docs/ci-cd.md`. + + 100-record fixtures make the fraction exact and readable: k over the ceiling IS k%. Both + `2/100` and `25/100` are exactly representable and compare equal to the module constants, so + these are true boundary cases rather than near-misses. + """ + + def corpus(n_over: int, total: int = 100): + return [_rec_body(f"a.o{i}", 61) for i in range(n_over)] + [ + _rec_body(f"b.u{i}", 10) for i in range(total - n_over) + ] + + # The bounds are INCLUSIVE — exactly on either edge still passes. + assert dv.ceiling_calibration(corpus(2), 60).flags_minority, "the 2% floor must be inclusive" + assert dv.ceiling_calibration(corpus(25), 60).flags_minority, "the 25% cap must be inclusive" + + # ...and one record beyond either edge does not. + assert not dv.ceiling_calibration(corpus(1), 60).flags_minority, "1% is below the floor" + assert not dv.ceiling_calibration(corpus(26), 60).flags_minority, "26% is above the cap" + + # The constants themselves, so a change has to be deliberate and visible in the diff. + assert (dv.CEILING_MINORITY_MIN, dv.CEILING_MINORITY_MAX) == (0.02, 0.25) + + # `test_adding_ordinary_records_cannot_RED_the_blocking_property` used to live here. It appended two # long synthetic records to the LIVE corpus and asserted `flags_minority` on the result — which # crosses the 25% cap TWO records before the production bound does (56/221 vs 54/219), making the