Add Stop-A SLO-boundary guard
When a truncated probe's measured pass-rate lands within trace.adaptive_stop. boundary_delta of the SLO target, re-measure on the full window and use that verdict. Offered-L-C-A convergence cannot see engine-state drift in the window tail, so a near-knee truncated verdict is untrustworthy (validated: prefix 0.96 vs full 0.946 at threshold 0.08594). The guard fires only on feasibility-knee probes, so non-boundary probes keep the Stop-A saving. Default delta=0.02. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,7 @@ from aituner.store import StudyStore
|
||||
from aituner.trace import load_trace_requests, summarize_window
|
||||
from aituner.worker import (
|
||||
_adaptive_replay_set,
|
||||
_should_extend_on_boundary,
|
||||
_best_feasible_probe_record,
|
||||
_latency_summary,
|
||||
_run_one_request,
|
||||
@@ -476,6 +477,60 @@ class CoreFlowTests(unittest.TestCase):
|
||||
self.assertIsNone(no_cert)
|
||||
self.assertEqual(len(passthrough), len(requests))
|
||||
|
||||
def test_boundary_guard_extends_only_near_the_slo_knee(self) -> None:
|
||||
converged = {"converged": True}
|
||||
# Truncated, converged, pass-rate on the knee -> re-measure full.
|
||||
self.assertTrue(
|
||||
_should_extend_on_boundary(
|
||||
pass_rate=0.961, target_pass_rate=0.95, certificate=converged,
|
||||
truncated=True, boundary_delta=0.02,
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
_should_extend_on_boundary(
|
||||
pass_rate=0.946, target_pass_rate=0.95, certificate=converged,
|
||||
truncated=True, boundary_delta=0.02,
|
||||
)
|
||||
)
|
||||
# Clearly feasible / clearly infeasible -> trust the truncated verdict.
|
||||
self.assertFalse(
|
||||
_should_extend_on_boundary(
|
||||
pass_rate=0.99, target_pass_rate=0.95, certificate=converged,
|
||||
truncated=True, boundary_delta=0.02,
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
_should_extend_on_boundary(
|
||||
pass_rate=0.50, target_pass_rate=0.95, certificate=converged,
|
||||
truncated=True, boundary_delta=0.02,
|
||||
)
|
||||
)
|
||||
# Not truncated, not converged, guard disabled, or no certificate -> no extend.
|
||||
self.assertFalse(
|
||||
_should_extend_on_boundary(
|
||||
pass_rate=0.95, target_pass_rate=0.95, certificate=converged,
|
||||
truncated=False, boundary_delta=0.02,
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
_should_extend_on_boundary(
|
||||
pass_rate=0.95, target_pass_rate=0.95, certificate={"converged": False},
|
||||
truncated=True, boundary_delta=0.02,
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
_should_extend_on_boundary(
|
||||
pass_rate=0.95, target_pass_rate=0.95, certificate=converged,
|
||||
truncated=True, boundary_delta=0.0,
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
_should_extend_on_boundary(
|
||||
pass_rate=0.95, target_pass_rate=0.95, certificate=None,
|
||||
truncated=True, boundary_delta=0.02,
|
||||
)
|
||||
)
|
||||
|
||||
def test_lca_similarity_matrix_separates_different_profiles(self) -> None:
|
||||
window = WindowRecord(
|
||||
window_id="base",
|
||||
|
||||
Reference in New Issue
Block a user