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
+24 -7
View File
@@ -103,13 +103,14 @@ def test_the_readout_reports_unmeasured_suppression_as_none():
from grimoire.services.retrieval_telemetry import _bucket
# calls, zero, p10, p50, p90, min, max, avg_n, dur,
# measured, supp_calls, supp_zero, miss_calls, miss_p50, miss_p90, miss_max
# measured, supp_calls, supp_zero, miss_calls, miss_p50, miss_p90, miss_max,
# gated, gate_declined
unmeasured = _bucket([326, 114, 0.6, 0.68, 0.77, 0.55, 0.85, 1.7, 130.9,
0, 0, 0, 0, None, None, None])
0, 0, 0, 0, None, None, None, 0, 0])
assert unmeasured["suppression"] is None
measured = _bucket([35, 34, 0.75, 0.75, 0.75, 0.75, 0.75, 0.03, 51.9,
35, 9, 9, 0, None, None, None])
35, 9, 9, 0, None, None, None, 0, 0])
assert measured["suppression"] == {
"measured_calls": 35,
"calls_with_suppression": 9,
@@ -1124,13 +1125,14 @@ def test_the_readout_reports_unmeasured_near_misses_as_none():
from grimoire.services.retrieval_telemetry import _bucket
# calls, zero, p10, p50, p90, min, max, avg_n, dur,
# measured, supp_calls, supp_zero, miss_calls, miss_p50, miss_p90, miss_max
# measured, supp_calls, supp_zero, miss_calls, miss_p50, miss_p90, miss_max,
# gated, gate_declined
none_measured = _bucket([326, 114, 0.6, 0.68, 0.77, 0.55, 0.85, 1.7, 130.9,
0, 0, 0, 0, None, None, None])
0, 0, 0, 0, None, None, None, 0, 0])
assert none_measured["near_misses"] is None
measured = _bucket([326, 114, 0.6, 0.68, 0.77, 0.55, 0.85, 1.7, 130.9,
0, 0, 0, 114, 0.61, 0.7104, 0.7189])
0, 0, 0, 114, 0.61, 0.7104, 0.7189, 0, 0])
assert measured["near_misses"] == {
"measured_calls": 114,
"p50": 0.61,
@@ -1139,6 +1141,21 @@ def test_the_readout_reports_unmeasured_near_misses_as_none():
}
def test_the_readout_reports_the_cue_gate_only_where_rows_carried_one():
"""An ungated arm, or a window older than the gate, has no gate block:
a zeroed one would claim the gate declined nothing."""
from grimoire.services.retrieval_telemetry import _bucket
ungated = _bucket([326, 0, 0.6, 0.68, 0.77, 0.55, 0.85, 3.9, 130.9,
0, 0, 0, 0, None, None, None, 0, 0])
assert ungated["gate"] is None
gated = _bucket([69, 0, 0.77, 0.8, 0.86, 0.7, 0.9, 3.9, 1065.0,
0, 0, 0, 0, None, None, None, 69, 55])
assert gated["gate"] == {"gated_calls": 69, "declined_by_gate": 55}
assert gated["zero_result_calls"] == 0
def test_the_readout_carries_no_field_derivable_from_its_neighbours():
"""No readout field is a sum of the two beside it.
@@ -1150,7 +1167,7 @@ def test_the_readout_carries_no_field_derivable_from_its_neighbours():
from grimoire.services.retrieval_telemetry import _bucket
b = _bucket([326, 114, 0.6, 0.68, 0.77, 0.55, 0.85, 1.7, 130.9,
0, 0, 0, 114, 0.61, 0.71, 0.72])
0, 0, 0, 114, 0.61, 0.71, 0.72, 0, 0])
derivable = {
k for k, v in b.items()
if isinstance(v, int) and not isinstance(v, bool)