From 60ad3b17c29b9cf223191d9a884175c151fc70cd Mon Sep 17 00:00:00 2001 From: Bolin Chen Date: Thu, 3 Sep 2026 23:55:05 +0000 Subject: [PATCH] test(autonudge): pin the gate premise the paused-loop tests rely on The five paused-loop tests for monitor_update depend on `gate=True` putting their `_FakeLoop` on the LEGACY side of `is_structured_monitor_loop`, which reads `monitor is not None and not gate`. The class docstring states that dependency; nothing executes it. So an edit to the predicate reports itself only as five assertion failures against "cannot apply legacy fields to a structured monitor" -- a refusal string that names neither the flag nor the routing, and reads as a bug in the wording under test rather than in the classification upstream of it. That is how the same five went red on main for several hours after two PRs that were each correct alone landed three hours apart. The added test asserts the three classifications the doubles rely on against the production predicate: a gated prompt loop carrying probe state is legacy, a controller record is structured, a plain prompt loop is legacy. Dropping the `gate` term from the predicate now fails six tests instead of five, and the sixth names the predicate, so the batch carries its own cause. Test-only; no production behaviour changes. Co-authored-by: Kiro Crew --- test/test_autonudge_stop_auth.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/test_autonudge_stop_auth.py b/test/test_autonudge_stop_auth.py index b1605e1c8c6..2f89050e84a 100644 --- a/test/test_autonudge_stop_auth.py +++ b/test/test_autonudge_stop_auth.py @@ -680,6 +680,28 @@ def test_applier_monitor_update_budget_stopped_denial_names_the_budget(monkeypat assert "max_cycles" not in result +def test_a_probe_state_double_is_a_legacy_loop_only_while_it_carries_the_gate(): + """Pin ``_FakeLoop``'s premise against the production predicate itself. + + ``monitor_update`` splits on record KIND before it reads a single bound, and a + ``monitor`` object alone does not decide that kind. So every paused-loop test + below depends on ``gate=True`` putting its double on the LEGACY side — a + dependency the class docstring states but nothing executes, so an edit to + ``is_structured_monitor_loop`` reports itself only as five assertion failures + against a refusal string that names neither the flag nor the routing. This one + fails alongside them naming the predicate, so the batch has a cause in it. + """ + from kiro_crew.autonudge import is_structured_monitor_loop + + gated_prompt_loop = _FakeLoop("loop-gated", monitor=_FakeMonitor(), gate=True) + controller_record = _FakeLoop("loop-structured", monitor=_FakeMonitor()) + plain_prompt_loop = _FakeLoop("loop-plain") + + assert not is_structured_monitor_loop(gated_prompt_loop) + assert is_structured_monitor_loop(controller_record) + assert not is_structured_monitor_loop(plain_prompt_loop) + + def test_applier_owed_terminal_turn_is_not_reported_as_a_spent_cap(monkeypatch): """A channel loop whose subject MERGED must not be told it ran out of cycles.