fix(8192): a gated arm's declines include the calls its cue gate withheld
CI & Build / TypeScript typecheck (push) Successful in 37s
CI & Build / Plugin hooks (push) Successful in 15s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Python tests (push) Successful in 2m10s
CI & Build / integration (push) Successful in 2m15s
CI & Build / Build & push image (push) Successful in 21s

#8192 "The cannot_decline warning reads the result count from before the cue
gate, so a gated arm can never show a decline", step 3 of milestone 669.

auto_inject logs its ranked results before the cue gate decides, so a call
the gate silenced still reads as a hit, and cannot_decline fired on an arm
whose gate withholds most calls (since 11-23, gate_kept = 0 on 55 of 69,
40 of 44 and 71 of 84 calls a day, with result_count never 0).

The readout gains a `gate` block per source (gated_calls, declined_by_gate),
null where no row carried a gate decision, and cannot_decline counts
zero_result_calls plus declined_by_gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 16:15:53 -05:00
co-authored by Claude Opus 5.5
parent deb991b2cc
commit 163d32859f
4 changed files with 99 additions and 13 deletions
+25
View File
@@ -97,6 +97,31 @@ def test_an_arm_that_does_decline_is_not_flagged() -> None:
assert "cannot_decline" not in codes(ws)
def test_a_gated_arm_whose_gate_declines_is_not_flagged() -> None:
"""A gated arm logs its ranked results before the cue gate decides, so a
call the gate silenced still reads as a hit in `zero_result_calls`. Those
withheld calls are declines too."""
gated = src(calls=300, zero_result_calls=0,
gate={"gated_calls": 300, "declined_by_gate": 240})
assert "cannot_decline" not in codes(warn({"auto_inject": gated}))
def test_counting_zero_results_alone_would_flag_that_arm() -> None:
"""The same arm with its gate block dropped, which is how the check read it
before: the warning fires, so the test above is not passing by accident."""
assert "cannot_decline" in codes(
warn({"auto_inject": src(calls=300, zero_result_calls=0)}))
def test_a_gated_arm_that_never_declines_anywhere_is_flagged() -> None:
gated = src(calls=300, zero_result_calls=0,
gate={"gated_calls": 300, "declined_by_gate": 0})
ws = warn({"auto_inject": gated})
w = next(w for w in ws if w["code"] == "cannot_decline")
assert w["numbers"] == {"calls": 300, "zero_result_calls": 0, "declined_by_gate": 0}
assert "cue gate" in w["detail"]
def test_an_arm_not_known_to_log_unconditionally_is_exempt(monkeypatch) -> None:
"""A structurally-zero decline count is a logging bug, not a floor.