fix: make RPM jitter exemption side-aware with one-shot room

Verifier adversarial cases showed pooled-room exemption could hide real
breaches: edge rows may only borrow from the neighbor on their own side,
and neighbor room is consumed globally so two windows cannot claim the
same slot. Also parse SQLite created_at as UTC, guard the dispatch
semaphore on progress-callback failure, and print a caveat that rescore
live checks reflect current db3 state.
This commit is contained in:
2026-07-21 07:42:54 -04:00
parent 8c178a249c
commit 5dfd88c4d6
3 changed files with 87 additions and 24 deletions
+31
View File
@@ -237,6 +237,37 @@ class TestInvariants:
]
inv_rpm_never_exceeded(rows, {"s1": 5})
def test_rpm_jitter_is_side_aware(self):
# verifier 对抗样例①: 左贴边行只能借左邻余量——左邻已满、右邻
# 全空时,7 行(2 行贴左界)仍是真实击穿,不得借右邻豁免
rows = [
_row(f"L{i}", created_at=f"2026-07-20T10:00:{s:02d}")
for i, s in enumerate([10, 20, 30, 40, 50]) # 左邻(10:00)满额 5
]
rows += [
_row(f"M{i}", created_at=f"2026-07-20T10:01:{s:02d}")
for i, s in enumerate([0, 1, 10, 20, 30, 40, 50]) # 本窗 7 行,2 行贴左界
]
with pytest.raises(AssertionError):
inv_rpm_never_exceeded(rows, {"s1": 5})
def test_rpm_jitter_room_not_double_claimed(self):
# verifier 对抗样例②: 两个超限窗不得重复认领中间窗的同 1 个余量
rows = [
_row(f"A{i}", created_at=f"2026-07-20T10:00:{s:02d}")
for i, s in enumerate([10, 20, 30, 40, 50, 59]) # 6 行,1 行贴右界
]
rows += [
_row(f"B{i}", created_at=f"2026-07-20T10:01:{s:02d}")
for i, s in enumerate([10, 20, 30, 40]) # 中间窗 4 行,仅 1 余量
]
rows += [
_row(f"C{i}", created_at=f"2026-07-20T10:02:{s:02d}")
for i, s in enumerate([1, 10, 20, 30, 40, 50]) # 6 行,1 行贴左界
]
with pytest.raises(AssertionError):
inv_rpm_never_exceeded(rows, {"s1": 5})
def test_rss_stable(self):
inv_rss_stable([100.0, 105.0, 110.0], max_growth_mb=50.0)
with pytest.raises(AssertionError):