fix(telemetry): silence is only an answer where the ledger was watching (#4268)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 10s
CI & Build / TypeScript typecheck (push) Successful in 55s
CI & Build / integration (push) Successful in 59s
CI & Build / Python tests (push) Successful in 1m44s
CI & Build / Build & push image (push) Successful in 31s

`band_hugs_floor` compares an arm's weakest tenth against its floor, and
#4225 made it SUSPEND rather than soften when the floor moved inside the
window — because across a change the scores and the bar come from two
different populations. It reads `floor_moves_since`, which answers "did
this arm's floor move", and it read an empty answer as "no, it held
steady".

Those are the same answer only where the ledger was watching. Before an
arm's first floor row there is nothing to move, nothing to report, and no
way to tell a steady floor from an unrecorded one. The suspension was
reading absence of evidence as evidence of absence, and the symptom is the
one #4225 documented: a band "-0.0208 above its floor" — an impossible
negative distance, printed with the suspension silent.

Every install passes through this. The ledger's first row for an arm is
written when that install first boots the release that records baselines,
so any window longer than the install is old reaches back past it. The
lowered-floor direction hides: the gap comes out comfortably positive and
reads as a clean bill of health.

`floor_history_gaps(since)` answers the question its companion cannot:
which arms' floor history does not REACH the start of the window. Arms
come from `surface_names()`, not from the ledger — an arm the ledger has
never heard of is exactly the one at risk, so it cannot be the ledger that
decides which arms get asked about.

Baselines count here, which is the one place the two deliberately
disagree. A baseline records a default without changing it, so it is not a
move and `floor_moves_since` filters it out. It IS the ledger beginning to
observe the arm, and from that moment silence genuinely means the floor
held — filtering it out here would suspend the band check forever on every
install that has never tuned.

`floor_history_unknown` sits between the known move and the band, so an
arm with a date to give gives it. Two sentences, because the remedies
differ: a date says ask again with a smaller `days`; no history at all
says there is nothing to wait for, and names what starts the record.

Why now: #4261 measures the work-log change by reading these warnings, and
every window for the next month opens before this ledger's first row.
Measuring against an instrument that prints a number it cannot support is
the #4225 trap one level up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01821k5B3Ysecp9fNYs92Kuy
This commit is contained in:
2026-09-21 14:38:16 -04:00
co-authored by Claude Opus 5
parent a58a225d7b
commit 42360f616c
4 changed files with 367 additions and 6 deletions
+126 -2
View File
@@ -49,10 +49,10 @@ def src(**kw) -> dict:
def warn(sources, usage=None, rule_usage=None, floors=None,
min_calls=N, epsilon=EPS, floor_moves=None) -> list[dict]:
min_calls=N, epsilon=EPS, floor_moves=None, floor_gaps=None) -> list[dict]:
return _compute_warnings(
sources, usage or {}, rule_usage or {}, floors or {}, min_calls, epsilon,
floor_moves or {},
floor_moves or {}, floor_gaps or {},
)
@@ -523,3 +523,127 @@ def test_the_registry_declares_which_arms_ask_a_fixed_question():
# not fixed, and marking one would silence a warning that works there.
for varying in ("auto_inject", "write_path", "pre_tool_rule", "prompt_rule"):
assert POINTS[varying].fixed_query is False, varying
# ── floor_history_unknown: the window reaches back past the ledger ─────────
#
# THE SAME SUSPENSION, FOR THE CASE THE ONE ABOVE CANNOT SEE.
#
# `floor_moved_mid_window` fires on a move the ledger recorded. The check
# overhead reads an EMPTY `floor_moves` as "the floor held steady" — and that
# reading is sound only where the ledger was watching. Before an arm's first
# floor row, "no move recorded" and "no move" are different statements, and
# the first was standing in for the second.
#
# It showed up the day this instance's ledger was seeded. Its earliest event
# of any kind is 2026-09-17; `write_path_rule`'s only floor row is a release
# baseline written 2026-09-21; a 30-day window opens 2026-08-22. The readout
# printed that arm's band as "-0.0208 above its floor" — the impossible
# negative the section above exists to prevent — with the suspension silent,
# because there was nothing on record for it to notice.
#
# The distinction is not academic for #4261: every window for the next month
# opens before that date, and measuring a change against an instrument that
# reports a number it cannot support is the #4225 trap one level up.
GAP_FROM = "2026-09-21T11:58:00+00:00"
def test_an_arm_whose_floor_history_starts_mid_window_is_suspended() -> None:
ws = warn({"write_path_rule": src(calls=100, zero_result_calls=5, p10=0.6992)},
floors={"write_path_rule": 0.72},
floor_gaps={"write_path_rule": GAP_FROM})
assert "floor_history_unknown" in codes(ws, "write_path_rule")
assert "band_hugs_floor" not in codes(ws), (
"a suspended check must not also answer"
)
def test_the_negative_gap_that_exposed_this_is_never_printed() -> None:
"""The observed symptom, reproduced: p10 0.6992 under a floor of 0.72 is
a band -0.0208 "above" its floor. Arithmetically impossible inside one
population, and no reader can act on it."""
ws = warn({"write_path_rule": src(calls=100, zero_result_calls=5, p10=0.6992)},
floors={"write_path_rule": 0.72},
floor_gaps={"write_path_rule": GAP_FROM})
assert not any(w.get("numbers", {}).get("gap", 0) < 0 for w in ws)
def test_a_healthy_looking_gap_is_suspended_too() -> None:
"""The direction that hides. A gap of 0.10 reads as a comfortable margin
and is computed against a bar nothing can vouch for over that window — the
same asymmetry as a lowered floor, and the reason this suspends rather
than only catching negatives."""
ws = warn({"write_path_rule": src(calls=100, zero_result_calls=5, p10=0.82)},
floors={"write_path_rule": 0.72},
floor_gaps={"write_path_rule": GAP_FROM})
assert "floor_history_unknown" in codes(ws, "write_path_rule")
def test_an_arm_with_no_history_at_all_says_how_to_start_one() -> None:
"""`None` rather than a date: there is nothing to wait for, so the remedy
is different and the sentence has to be too. A reader told to "wait for
2026-…" when no date exists would wait forever."""
w = next(w for w in warn(
{"write_path_rule": src(calls=100, zero_result_calls=5, p10=0.6992)},
floors={"write_path_rule": 0.72},
floor_gaps={"write_path_rule": None},
) if w["code"] == "floor_history_unknown")
assert w["numbers"]["known_from"] is None
assert "no floor history" in w["detail"]
assert "tune_retrieval" in w["detail"], "a finding with no remedy is a complaint"
def test_the_dated_case_says_when_the_check_comes_back() -> None:
w = next(w for w in warn(
{"write_path_rule": src(calls=100, zero_result_calls=5, p10=0.6992)},
floors={"write_path_rule": 0.72},
floor_gaps={"write_path_rule": GAP_FROM},
) if w["code"] == "floor_history_unknown")
assert w["numbers"]["known_from"] == GAP_FROM
assert GAP_FROM in w["detail"] and "days" in w["detail"]
def test_a_covered_arm_is_still_judged() -> None:
"""The mirror error, and the expensive one. An arm absent from the gap map
is fully covered; suspending it would retire a working check on the
strength of nothing."""
ws = warn({"write_path_rule": src(calls=100, zero_result_calls=5, p10=0.7205)},
floors={"write_path_rule": 0.72}, floor_gaps={})
assert "band_hugs_floor" in codes(ws, "write_path_rule")
assert "floor_history_unknown" not in codes(ws)
def test_a_known_move_wins_over_a_history_gap() -> None:
"""Both can apply — a ledger that starts mid-window may still have caught
a move inside it. The arm that has a date to give should give it, and
exactly one line should be printed either way."""
ws = warn({"write_path_rule": src(calls=100, zero_result_calls=5, p10=0.6992)},
floors={"write_path_rule": 0.72},
floor_moves={"write_path_rule": MOVED},
floor_gaps={"write_path_rule": GAP_FROM})
assert "floor_moved_mid_window" in codes(ws, "write_path_rule")
assert "floor_history_unknown" not in codes(ws)
assert "band_hugs_floor" not in codes(ws)
def test_only_the_uncovered_arm_is_suspended() -> None:
"""Coverage is per-arm: the ledger can start watching one arm before
another, and one arm's blind spot says nothing about the next."""
ws = warn(
{"write_path_rule": src(calls=100, zero_result_calls=5, p10=0.7205),
"auto_inject": src(calls=100, zero_result_calls=5, p10=0.705)},
floors={"write_path_rule": 0.72, "auto_inject": 0.70},
floor_gaps={"write_path_rule": GAP_FROM},
)
assert "floor_history_unknown" in codes(ws, "write_path_rule")
assert "band_hugs_floor" in codes(ws, "auto_inject")
def test_a_quiet_arm_is_not_suspended_either() -> None:
"""Below `min_calls` nothing in this block runs — a ledger gap does not
promote an arm nobody used into something worth a line."""
ws = warn({"write_path_rule": src(calls=1, zero_result_calls=0, p10=0.6992)},
floors={"write_path_rule": 0.72},
floor_gaps={"write_path_rule": GAP_FROM})
assert "floor_history_unknown" not in codes(ws)