fix(688): remove the last live-corpus tripwires and three fabricated/wrong numbers

Review round 3, both reviewers, NOT-MERGEABLE. Nothing needed rework — the code path
was found sound and mutation-sensitive (a 17-mutation battery caught every mutation with
the semantically correct test). What was left were tripwires and prose.

TRIPWIRES
- `assert need > 20` was the tightest live-corpus assertion left in the blocking job:
  it reds after 16 over-ceiling additions, while `flags_minority` — the property #688
  exists to protect — survives to 36. An arbitrary threshold on a live order statistic is
  the ratchet wearing a different hat. Removed; the measured headroom lives in prose,
  where being out of date costs a doc fix rather than someone else's red build. This also
  removes an unbounded `while` loop that HUNG the suite rather than failing it when the
  ratio could not reach the cap.
- test_main_reports_ceiling_drift hardcoded ceiling 999, which is not guaranteed above
  p95: ten valid 1000-line records make 999 calibrated and silently delete the test's only
  assertion. Now derived as max+1, off the tail by definition.
- test_main_actually_REPORTS_the_ceiling_and_the_trend required >=1 over-ceiling record.
  The ceiling is ALLOWED to go green (test_oversized_records_can_go_green says so), so
  that would red the blocking job the day someone consolidates the last offender —
  punishing exactly the work the warning asks for. Restated as an IFF.
- test_no_budget_flag_means_no_retirement_warning asserted no bare "RETIRED" in stderr; a
  legitimate stale record whose TITLE contains the word reds it. Matched precisely now.
- Added the >100-record vacuity guard its siblings carry to the derived-ceiling test.

NUMBERS — all three were mine, and two are the failure mode this repo calls worse than
no note at all (a confident claim that was never measured):
- "the lengths above the ceiling ran 60, 61, 62, 63 then jumped to 81" is FABRICATED. No
  record of 61, 62 or 63 lines exists at origin/main, at the #672 sha, or at the #706 sha.
  Measured, the sequence is 59, 59, 60, 60 then 81 — a 21-line jump, so the conclusion was
  if anything understated. Corrected in all three places it was repeated, including the
  canonical v4 row of docs.corpus-size-signal.
- The crosscheck record called `decisions-guard` a REQUIRED check — introduced by the
  previous commit in the sentence rewritten to fix an overclaim. Verified against Gitea
  branch protection: `main` requires exactly `Build & test (.NET)`, `EF migration
  integrity` and `review-verdict/h10`. NEITHER script-tests NOR decisions-guard is
  required; the record now says so.
- docs.corpus-size-signal said 37 additions "to reach" the cap two paragraphs above 38
  "below the cap" — a same-document numeric inconsistency of exactly the class this change
  set out to remove. Both now state 38 to BREACH, noting 37 lands on 0.25 and passes.
- Also: the old bound's accepted range is 39..229 (not 43..229 — 43 is the NEW bound's
  lower edge); "95% over the ceiling" was 100%; `oversized_records` said the #620
  distribution began at 0 lines where the record itself says 2.

Verification: 428 scripts/tests pass; ruff at baseline parity (47); validator exits 0 with
no drift notice; corpus at p90=60, 18/183 over the ceiling, record trimmed to 60 lines so
main ships calibrated.

Decisions-Edit: yes
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-04 21:26:52 +02:00
co-authored by Claude Opus 5
parent b3a8826281
commit 0db56c3ebd
4 changed files with 53 additions and 34 deletions
+42 -23
View File
@@ -1013,7 +1013,7 @@ def test_real_corpus_ceiling_flags_a_nonempty_proper_minority():
remedy the assertion admitted was to RAISE the ceiling.
v4 `p90 <= ceiling <= p95`. Scale-free and correct AS A DEFINITION, but an order statistic
over a SPARSE distribution is a STEP function. At #688 the lengths above the ceiling ran
60, 61, 62, 63 and then jumped to 81, so ONE new record moved p90 by twenty lines and
59, 59, 60, 60 and then jump straight to 81, so ONE new record moved p90 by 21 lines and
reddened the BLOCKING `script-tests` job for whoever happened to write it. It reproduced
twice live (#672, #706) and both times the only in-scope remedy was to trim the new
record to fit the constant — the ratchet pointed at record authors, which is precisely
@@ -1062,17 +1062,21 @@ def test_ceiling_calibration_detects_drift_in_BOTH_directions():
# and the coarse property separates the same two failure modes
assert not dv.ceiling_calibration(recs, 999).flags_minority, "a ceiling nobody is over signals nothing"
assert not dv.ceiling_calibration(recs, 10).flags_minority, "95% over the ceiling is not a tail"
assert not dv.ceiling_calibration(recs, 10).flags_minority, "100% over the ceiling is not a tail"
assert dv.ceiling_calibration(recs, 60).flags_minority
def test_the_coarse_bound_REJECTS_a_badly_placed_ceiling_on_the_REAL_corpus():
"""The blocking property must have teeth, demonstrated against the live distribution.
def test_the_coarse_bound_REJECTS_a_badly_placed_ceiling():
"""The blocking property must have teeth.
Review's strongest finding on the first draft: a floor of `fraction_over > 0` was nearly
unfalsifiable — it accepted every ceiling from 39 to 229, including the ceiling of 200 that the
docstring itself offered as the case it catches, because one 230-line record keeps the count
nonzero. A FRACTION floor is what restores the teeth, so pin it on the real corpus.
unfalsifiable — measured on the live corpus it accepted every ceiling from 39 to 229, including
the ceiling of 200 the docstring itself offered as the case it catches, because one 230-line
record keeps the count nonzero. A FRACTION floor is what restores the teeth.
The rejections are pinned on a SYNTHETIC distribution: asserting that a specific absurd ceiling
stays rejected by the live corpus is itself growth-coupled (three new 200+ line records flip the
200 arm). Only the acceptance of today's ceiling is checked against live data.
"""
# The TEETH are demonstrated on an owned distribution, for the reason in
# `test_v4_would_have_reddened_where_v5_holds`: an assertion that a specific absurd ceiling is
@@ -1126,13 +1130,11 @@ def test_adding_ordinary_records_cannot_RED_the_blocking_property():
# ...and the v5 blocking property holds.
assert after.flags_minority, f"two ordinary additions reddened the blocking property: {after}"
# Live headroom, as a number, so a future reader can see how much slack there actually is: how
# many consecutive over-ceiling records it would take to BREACH the cap from here.
n, over = after.n, after.n_over
need = 0
while (over + need) / (n + need) <= dv.CEILING_MINORITY_MAX:
need += 1
assert need > 20, f"only {need} over-ceiling additions would breach the bound — too tight"
# NO headroom assertion here. An earlier draft asserted `need > 20` over the live corpus, and
# review measured it failing after 16 over-ceiling additions — an arbitrary threshold on a live
# order statistic is the ratchet wearing a different hat. The measured headroom (38 additions,
# or 718 short ones by dilution) is stated in `ceiling_calibration` and `docs.corpus-size-signal`
# where being out of date costs a doc correction, not a red build for an unrelated author.
def test_v4_would_have_reddened_where_v5_holds():
@@ -1149,7 +1151,7 @@ def test_v4_would_have_reddened_where_v5_holds():
Nothing about this demonstration needs the real corpus. The synthetic base reproduces the shape
that matters — a sparse gap just above the ceiling, exactly what #688 measured on `main` (60,
61, 62, 63, then a jump to 81) — so two over-ceiling additions advance the p90 index off the
60, 60, then a jump to 81) — so two over-ceiling additions advance the p90 index off the
ceiling and break v4, while v5 is untouched.
"""
base = (
@@ -1326,15 +1328,24 @@ def test_retired_budget_flag_says_it_is_ignored(capsys):
def test_no_budget_flag_means_no_retirement_warning(capsys):
# Match the retirement notice specifically, not a bare "RETIRED": a legitimate record whose
# TITLE contains that word and whose `stale-after` has passed gets printed by the stale notice,
# which would red this on an unrelated corpus change.
dv.main([])
assert "RETIRED" not in capsys.readouterr().err
assert "is RETIRED and was IGNORED" not in capsys.readouterr().err
def test_main_reports_ceiling_drift_as_a_NOTICE_and_still_exits_0(capsys):
"""The fine claim's live wiring (#688). A ceiling of 999 is parked far above p95, so the drift
notice must fire — and must NOT turn the run red, which is the entire point of the v5 split."""
assert dv.main(["--record-ceiling", "999"]) == 0
"""The fine claim's live wiring (#688): the drift notice must fire, and must NOT turn the run
red — the entire point of the v5 split.
The ceiling is DERIVED as one line above the longest record, so it is off the tail boundary by
definition. A hardcoded 999 looked safe and was not: review showed ten valid 1000-line records
would put p95 at 1000, making 999 calibrated and silently deleting this test's only assertion.
"""
longest = max(dv.record_prose_lines(r) for r in dl.all_active_records() if r.key)
assert dv.main(["--record-ceiling", str(longest + 1)]) == 0
err = capsys.readouterr().err
drift = [ln for ln in err.splitlines() if "drifted from the tail boundary" in ln]
assert len(drift) == 1, err
@@ -1355,6 +1366,7 @@ def test_main_reports_drift_IFF_the_ceiling_is_off_the_tail_boundary(capsys):
is genuinely exercised, so this cannot pass by never firing.
"""
recs = [r for r in dl.all_active_records() if r.key]
assert len(recs) > 100, f"corpus looks empty ({len(recs)}) — the derived ceilings need records"
lengths = sorted(dv.record_prose_lines(r) for r in recs)
# Both ceilings are DERIVED so each branch is guaranteed by construction, not by luck. Review
@@ -1385,15 +1397,22 @@ def test_main_actually_REPORTS_the_ceiling_and_the_trend(capsys):
"""The new signal's live wiring was untested: `if oversized:` -> `if False:`, or bumping the
default ceiling to 999999, left every test green while main() reported nothing. Only the pure
function `oversized_records()` was covered — so the replacement signal could silently do
nothing, which is the exact defect this change exists to retire."""
nothing, which is the exact defect this change exists to retire.
Stated as an IFF against the live offender list rather than `assert over` (#688): the ceiling
is ALLOWED to go green — `test_oversized_records_can_go_green` says so explicitly — so a bare
precondition that the corpus still has an offender would red the blocking job the day someone
consolidates the last one, punishing exactly the work the warning asks for."""
dv.main([])
err = capsys.readouterr().err
assert "prose lines across" in err, "the aggregate trend notice must always print"
assert "exceed the" in err and "prose ceiling" in err, "the per-record ceiling warning must print"
over = [r.key for r in dl.all_active_records()
if r.key and dv.record_prose_lines(r) > dv.RECORD_CEILING_DEFAULT]
assert over, "precondition: the live corpus has at least one over-ceiling record"
assert any(k in err for k in over), "the warning must NAME the offending records"
warned = "exceed the" in err and "prose ceiling" in err
assert warned is bool(over), f"ceiling warning printed={warned} but {len(over)} record(s) are over it"
if over:
assert any(k in err for k in over), "the warning must NAME the offending records"
def test_trend_notice_reports_record_prose_and_scaffolding_separately(capsys):