Test setup charges zero units of tts, so it may not exhaust the cap it claims to
The finding
The setup calls store.consume_usage(<today>, "tts", 0), and the comment says "today's tts is already spent". If the third argument is the amount to charge (the usual meaning of consume_usage), this records nothing. Today's tts usage would stay at 0 against a limit of 1, so budget.available("tts") should be True, contradicting the final assert seen["tts_available"] is False. In that case the test either fails, or passes only for an unrelated reason, such as the budget counting the call itself or reading a different store. Either way it would not verify that a prior store-backed charge is honoured by the CLI dispatcher. If the third argument is instead a limit (where 0 might mean 'uncapped'), the call again does not reliably model spent usage.
1| from __future__ import annotations
2|
3| import asyncio
4| import functools
5| import hashlib
6| import hmac
7| import json
8| import sys
9| import textwrap
10| from datetime import UTC, datetime, timedelta
11| from importlib.metadata import EntryPoint
12| from pathlib import Path
13|
14| import httpx
15| import pytest
16| from argus_cortex.net import afetch
17| from typer.testing import CliRunner
18|
19| from argus_scout.channels import (
20| ENTRY_POINT_GROUP,
21| BoundChannel,
22| ChannelError,The work pack
Recommendation. Charge one real unit so usage reaches the configured limit, e.g. store.consume_usage(today, "tts", 1) (or whatever the amount/limit signature requires). Also assert that the store's recorded usage for today equals 1 before invoking the CLI, so the precondition is explicit.
Acceptance criteria
- Address: Test setup charges zero units of tts, so it may not exhaust the cap it claims to
- Keep the change scoped to the cited file/symbols unless impact requires otherwise
- Charge one real unit so usage reaches the configured limit, e.g.
store.consume_usage(today, "tts", 1)(or whatever the amount/limit signature requires). Also assert that the store's recorded usage for today equals 1 before invoking the CL - Re-check
tests/test_channels.pyafter the fix
Status
- claimed
- resolved
The fix
10dc6dafff test: the CLI caps test charges and checks its spent tts unit explicitly.
@@ -713,7 +713,9 @@ def test_cli_deliver_charges_the_speech_caps(tmp_path, monkeypatch): path.write_text("channels:\n - kind: text\n name: log\nbudget:\n limits:\n tts: 1\n") with SqliteStore(tmp_path / "scout.db") as store: store.add_report("status", T0, "UPS on battery", {"severity": "critical"})- store.consume_usage(datetime.now(UTC).date().isoformat(), "tts", 0) # today's tts is already spent+ today = datetime.now(UTC).date().isoformat()+ assert store.consume_usage(today, "tts", 1) == (True, 1) # one charge against a limit of 1: spent+ assert store.usage_counts(today) == {"tts": 1} seen = {} real = cli_module.build_dispatcher How it was judged
Waiver evidence waived: Test-only: consume_usage's third argument is the limit (0 = unlimited), so the old setup did charge one unit and the test was correct; the change makes the charge and the precondition explicit, so the
Judged 24 Nov 2026, 04:52 UTC against dev at d0c0f66.
This fix strengthens a test. The stronger test passes on dev's code as well, so there is no failure on dev for it to show. It resolved on a written waiver of at least twenty characters, recorded with the pack:
Test-only: consume_usage's third argument is the limit (0 = unlimited), so the old setup did charge one unit and the test was correct; the change makes the charge and the precondition explicit, so there is no dev failure to reproduce.