feat: test shorter post-stop reentry guards
This commit is contained in:
@@ -49,13 +49,17 @@ def test_next_session_blocks_only_stop_day():
|
||||
assert _call(policy, ORD + 1, state, 1) is not None
|
||||
|
||||
|
||||
def test_five_session_cooldown_unlocks_at_exact_boundary():
|
||||
engine = PrecomputedDailyEngine([_candidate(ORD + 4), _candidate(ORD + 5)])
|
||||
policy = ReentryPolicy("cooldown_5", engine, RANKING_KEY)
|
||||
@pytest.mark.parametrize("sessions", [2, 3, 5])
|
||||
def test_cooldown_unlocks_at_exact_boundary(sessions):
|
||||
engine = PrecomputedDailyEngine([
|
||||
_candidate(ORD + sessions - 1),
|
||||
_candidate(ORD + sessions),
|
||||
])
|
||||
policy = ReentryPolicy(f"cooldown_{sessions}", engine, RANKING_KEY)
|
||||
state = _state()
|
||||
|
||||
assert _call(policy, ORD + 4, state, 4) is None
|
||||
assert _call(policy, ORD + 5, state, 5) is not None
|
||||
assert _call(policy, ORD + sessions - 1, state, sessions - 1) is None
|
||||
assert _call(policy, ORD + sessions, state, sessions) is not None
|
||||
|
||||
|
||||
def test_gate_reset_requires_failure_before_requalification():
|
||||
@@ -70,6 +74,30 @@ def test_gate_reset_requires_failure_before_requalification():
|
||||
assert emitted["_reentry_reason"] == "gate_failed_then_requalified"
|
||||
|
||||
|
||||
def test_strict_gate_reset_ignores_stop_day_failure():
|
||||
engine = PrecomputedDailyEngine([
|
||||
_candidate(ORD + 1),
|
||||
_candidate(ORD + 3),
|
||||
])
|
||||
policy = ReentryPolicy("strict_gate_reset", engine, RANKING_KEY)
|
||||
state = _state()
|
||||
|
||||
# An unqualified stop-day close alone does not reset the strict policy.
|
||||
assert _call(policy, ORD, state, 0) is None
|
||||
assert state["gate_went_unqualified"] is False
|
||||
assert _call(policy, ORD + 1, state, 1) is None
|
||||
|
||||
# A later unqualified close establishes the reset; only then may the next
|
||||
# qualified setup re-enter.
|
||||
assert _call(policy, ORD + 2, state, 2) is None
|
||||
assert state["gate_went_unqualified"] is True
|
||||
emitted = _call(policy, ORD + 3, state, 3)
|
||||
assert emitted is not None
|
||||
assert emitted["_reentry_reason"] == (
|
||||
"post_stop_gate_failed_then_requalified"
|
||||
)
|
||||
|
||||
|
||||
def test_improved_gate_reset_requires_better_stop_and_non_weaker_rank():
|
||||
engine = PrecomputedDailyEngine([
|
||||
_candidate(ORD + 1, stop=89.0, rank=82.0),
|
||||
|
||||
Reference in New Issue
Block a user