Skip to content

Commit 8b54299

Browse files
committed
fix: correct stale Sphinx cross-refs in errors.py and add 5% boundary test
- BudgetExhausted and BudgetConfigError docstrings referenced firewall.budgets.BudgetManager (pre-split path); now point to firewall.budget_manager.BudgetManager - Add test_suggested_mode_boundary_exactly_five_percent_is_summary_not_handle_only to confirm 5% exactly lands in the summary bucket, not handle_only; guards against a future < → <= comparator change
1 parent 100cda9 commit 8b54299

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/agent_kernel/errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class FirewallError(AgentKernelError):
5050

5151

5252
class BudgetExhausted(AgentKernelError):
53-
"""Raised when a :class:`~agent_kernel.firewall.budgets.BudgetManager` has
53+
"""Raised when a :class:`~agent_kernel.firewall.budget_manager.BudgetManager` has
5454
no remaining cross-invocation context budget.
5555
5656
Distinct from :class:`FirewallError`: this error fires *before* the
@@ -61,7 +61,7 @@ class BudgetExhausted(AgentKernelError):
6161

6262

6363
class BudgetConfigError(AgentKernelError):
64-
"""Raised when a :class:`~agent_kernel.firewall.budgets.BudgetManager` is
64+
"""Raised when a :class:`~agent_kernel.firewall.budget_manager.BudgetManager` is
6565
constructed with invalid parameters, or asked to allocate/record/release
6666
a negative amount.
6767

tests/test_firewall.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,3 +534,16 @@ async def test_suggested_mode_boundary_exactly_twenty_percent_floors_summary() -
534534
await bm.record_usage(800)
535535
assert bm.suggested_mode("raw") == "summary"
536536
assert bm.suggested_mode("table") == "summary"
537+
538+
539+
@pytest.mark.asyncio
540+
async def test_suggested_mode_boundary_exactly_five_percent_is_summary_not_handle_only() -> None:
541+
# 5% exactly sits in the 5–20% summary bucket because the handle_only
542+
# guard is strictly-less-than: (0.05 < 0.05) is False. A future change
543+
# from `< 0.05` to `<= 0.05` would silently misplace this boundary.
544+
bm = BudgetManager(total_budget=1000)
545+
await bm.record_usage(950) # 5% remaining
546+
assert bm.suggested_mode("raw") == "summary"
547+
assert bm.suggested_mode("table") == "summary"
548+
assert bm.suggested_mode("summary") == "summary"
549+
assert bm.suggested_mode("handle_only") == "handle_only" # never relaxes

0 commit comments

Comments
 (0)