Whole-word assertion can pass when truncation cuts mid-word
The finding
The test checks that the last token before the ellipsis appears in summary.split(). But the vocabulary contains words that are prefixes of other words: argus-safelist-1…argus-safelist-3 are prefixes of argus-safelist-10…argus-safelist-39. If render_template truncated argus-safelist-23 to argus-safelist-2…, the fragment argus-safelist-2 is still in summary.split(), so the test passes even though the line ends mid-word. The test therefore cannot reliably detect the regression it is named after. Whether it masks a bug depends on where MAX_LINE_CHARS happens to fall.
1| """The narrative: facts, prompt budgets cut by priority, the template fallback, and the jobs that store reports."""
2|
3| from __future__ import annotations
4|
5| from datetime import UTC, datetime, timedelta
6| from pathlib import Path
7|
8| import pytest
9| from typer.testing import CliRunner
10|
11| from argus_scout.budget import DailyBudget
12| from argus_scout.cli import app
13| from argus_scout.cycles import BriefingJob, StatusCycle
14| from argus_scout.events import StatusEvent
15| from argus_scout.heartbeat import PolicyFile
16| from argus_scout.inbox import Inbox
17| from argus_scout.llm import LLM_CALLS, Completion, LLMUnavailable, Prompt
18| from argus_scout.memory import SCOUT_FILE, Memory
19| from argus_scout.narrative import Facts, Narrator, build_prompt, fact_lines, select_lines
20| from argus_scout.persona import DEFAULT_PERSONA, PersonaFileThe work pack
Recommendation. Verify the cut lands on a word boundary of the original text. Assert that summary.startswith(prefix), where prefix is the line content minus the ellipsis and trailing whitespace. Then assert that the next character in summary after that prefix is a space (or end of string). Alternatively, build the summary from words that are not prefixes of each other, e.g. zero-padded argus-safelist-{i:02d}.
Acceptance criteria
- Address: Whole-word assertion can pass when truncation cuts mid-word
- Keep the change scoped to the cited file/symbols unless impact requires otherwise
- Verify the cut lands on a word boundary of the original text. Assert that
summary.startswith(prefix), whereprefixis the line content minus the ellipsis and trailing whitespace. Then assert that the next character insummaryafter th - Re-check
tests/test_narrative.pyafter the fix
Status
- claimed
- resolved
The fix
1edc8a61d2 test: the clipped fact line must end where a summary word does.
@@ -612,7 +612,11 @@ def test_long_fact_lines_never_end_mid_word(): text = render_template(Facts(kind="status", at=T0, groups=[_group("w1", "warning", summary)]), DEFAULT_PERSONA) [line] = [ln for ln in text.splitlines() if ln.startswith("- ")] assert len(line) - 2 <= MAX_LINE_CHARS and line.endswith("…")- assert line.removesuffix("…").split()[-1] in summary.split() # a whole word, not a fragment of one+ # A whole word, not a fragment of one: what is kept is a prefix of the summary that ends where a word does+ # (a split-membership check would pass "argus-safelist-2" cut from "argus-safelist-23").+ kept = line.removesuffix("…").rstrip()+ kept = kept[kept.index("Review queue:") :]+ assert summary.startswith(kept) and summary[len(kept)] == " " # --- tariff wording -------------------------------------------------------------------------------------------How it was judged
Waiver evidence waived: Test-only finding: the fix strengthens a test, so the same test runs on both trees and passes on dev's source. Verified locally by mutation: the strengthened test fails when the guarded behaviour is b
Judged 24 Nov 2026, 04:55 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 finding: the fix strengthens a test, so the same test runs on both trees and passes on dev's source. Verified locally by mutation: the strengthened test fails when the guarded behaviour is broken, where the old one passed.