Skip to content

Commit c7bc792

Browse files
tbitcsoz-agent
andcommitted
fix(tests): use limit=65536 for ceiling tests so 15% rule dominates over min_free_tokens
For limit=65536: reserved = max(0.15×65536, 2048) = 9830 tokens, giving effective_ceiling_pct = 85.0% as intended. The previous limit=4096 caused min_free_tokens=2048 (50% of 4096) to tighten the effective ceiling to 50%, so used=3400 (83%) incorrectly raised ContextFullError. Also updated test_context_full_error_at_ceiling to use the same limit=65536 with used=56000 (~85.4%) to trigger the hard ceiling correctly. Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent f1482ea commit c7bc792

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

tests/test_compliance.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,18 @@ class TestReq246CompressionThreshold:
448448
"""TEST-224 — fill below hard ceiling returns event (compression threshold signal)."""
449449

450450
def test_fill_below_ceiling_returns_event(self) -> None:
451-
"""used=3400 with limit=4096 is ~83% — below 85% ceiling, no exception (REQ-246)."""
451+
"""~83% fill — above the 80% compression threshold, below 85% hard ceiling (REQ-246).
452+
453+
We use limit=65536 so that the 15% reservation rule governs
454+
(0.15 * 65536 = 9830 > MIN_FREE_TOKENS=2048), giving an effective
455+
ceiling of 85% rather than the tighter 50% that would apply for
456+
small context windows.
457+
"""
452458
from specsmith.context_window import ContextFillTracker
453459

454-
tracker = ContextFillTracker(limit=4096)
455-
event = tracker.record(used=3400)
456-
# ~83% fill — above the 80% compression threshold, below the 85% hard ceiling
460+
# limit=65536: effective_ceiling = 85% (15% rule dominates over 2048 min)
461+
tracker = ContextFillTracker(limit=65536)
462+
event = tracker.record(used=55000) # ~83.9% — below the 85% ceiling
457463
assert event.pct >= 80.0, f"Fill should be >= 80%; got {event.pct}"
458464
assert event.pct < 85.0, f"Fill should be < 85%; got {event.pct}"
459465

@@ -478,16 +484,21 @@ class TestReq247HardCeiling:
478484
"""TEST-225 — ContextFullError raised at hard ceiling."""
479485

480486
def test_context_full_error_at_ceiling(self) -> None:
481-
"""used=3600 with limit=4096 is ~87.9% — raises ContextFullError (REQ-247)."""
487+
"""~85.4% fill raises ContextFullError at the hard ceiling (REQ-247).
488+
489+
Uses limit=65536 so the 15% reservation rule governs (effective ceiling
490+
= 85%), matching the intent of the hard-ceiling invariant.
491+
"""
482492
from specsmith.context_window import ContextFillTracker, ContextFullError
483493

484-
tracker = ContextFillTracker(limit=4096)
494+
# limit=65536: effective_ceiling = 85% (15% rule dominates)
495+
tracker = ContextFillTracker(limit=65536)
485496
with pytest.raises(ContextFullError) as exc_info:
486-
tracker.record(used=3600)
497+
tracker.record(used=56000) # ~85.4% — above the 85% ceiling
487498

488499
err = exc_info.value
489-
assert err.used == 3600
490-
assert err.limit == 4096
500+
assert err.used == 56000
501+
assert err.limit == 65536
491502
assert err.pct >= 85.0, f"pct should be >= 85; got {err.pct}"
492503

493504
def test_min_free_tokens_tightens_ceiling(self) -> None:

0 commit comments

Comments
 (0)