phase: 182_verbatim_show_text
Build and Push Containers / build-and-push-app (push) Successful in 1m46s
Build and Push Containers / build-and-push-db (push) Successful in 12s

**Phase 182 — final verification pass (all 8 tasks already complete; this was verification + docs + one defect fix).**

- Verified: `app/rag/verbatim.py` (locator grammar, `splitlines()` slice, line-boundary cap, `resolve_answer_blocks`), `SHOW_TEXT_TOOL` + `shown_texts`, `SHOW_TEXT_CLAUSE`, `done.answer_text` (9 fields, key dropped when empty) + `ChatMessageRecord.answer_text` (≤50, 600 000-char cap counted in the 8 M budget), `verbatim.js` + 4 `{verbatim:true}` renderers, `Containerfile` minify step, `.env.example` 3 vars.
- `uv run python -c "…answer_text, show_text_max_chars, show_text_max_blocks"` → `True 12000 5`; each negative refuses startup naming its field; `0` accepted as inert ✅
- `bash .agents/validate.sh` → **validation OK**: 4320 unit+integration tests green, `TOTAL 6849 17 → 99%` (gate app/ >90% OK), `ruff check .` "All checks passed!", `pyright` 0 errors (re-run after my edits, 08:28).
- E2E, each in isolation `--no-cov`: `test_verbatim_show_text.py` 13 passed (panel bytes == `documents.content`, server caption, clipboard == server string, `/document.html?source=…&path=…`, honest unresolved state, reload+share, `show_image` regression, flag-off app) ✅; green: `test_answer_images` `test_harness_aligned_tools` `test_agent_document_tools` `test_markdown_tables` `test_markdown_inline_links_images` `test_svg_document_preview` `test_smoke` `test_document_viewer` `test_markdown_blockquotes` `test_chat_persistence` `test_thinking_timeline` `test_chat_rag` `test_settings_mobile_value_width`.
- **Defect found & fixed (pre-existing, not phase 182):** `tests/e2e/test_admin_settings_panel.py::test_admin_sees_groups_and_source_badges` failed — its whole-page `assert "reese" not in page.content()` tripped on the shell's onboarding chips, which follow the newest saved chats in the one shared E2E DB (a leftover `reeselink.json` question from a tool suite). Scoped the strict sweep to `.settings-shell` and kept a whole-page `reese:reese` credential needle → 12 passed with the leftovers still present.
- Docs: README fixed 2 inconsistencies — Quick Start omitted the **required** `BOR_ADMIN_PASSWORD`/`BOR_SESSION_SECRET` (the app fail-loud refuses boot) and the broken anchor `#chat--` → `#chat-`; full re-read of README (1816 lines) + AGENTS confirmed the phase-182 feature/settings/log/UI-contract text matches the code, and every `.env.example` var + every `Settings` field is documented.
- Notable: kept `resolve_answer_blocks` synchronous on the SSE terminal path (bounded indexed SELECTs, matching the existing `query_log` precedent and the phase's documented fence-lookup bound); no live-infra changes made.
- Next pending phase: none — `todo/` holds only 182 (its 8 task files are in `complete/`; the harness commits + moves `00_phase.md`).
This commit is contained in:
2026-10-15 08:33:12 -04:00
parent 814a400e6d
commit b34b8ca672
104 changed files with 10852 additions and 203 deletions
+70
View File
@@ -426,6 +426,76 @@ def test_read_max_chars_rejects_negative(monkeypatch: pytest.MonkeyPatch) -> Non
_settings()
def test_answer_text_default_true_and_env_override(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Phase 182 (LOCKED A8): the verbatim-display master switch defaults
to ON — an answer whose code block silently differs from the file is a
correctness bug, so the fix ships on and the switch is an escape hatch
(unlike phase 124's ``answer_images``, which defaults OFF). Env-tunable
in both directions; ``0``/``false`` is the byte-identical pre-phase
state (no tool, no clause, no resolution, no ``answer_text`` key)."""
monkeypatch.delenv("BOR_ANSWER_TEXT", raising=False)
assert _settings().answer_text is True
for off in ("0", "false"):
monkeypatch.setenv("BOR_ANSWER_TEXT", off)
assert _settings().answer_text is False
for on in ("1", "true"):
monkeypatch.setenv("BOR_ANSWER_TEXT", on)
assert _settings().answer_text is True
def test_show_text_max_chars_default_and_env_override(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Phase 182 (LOCKED A8): one displayed verbatim slice is capped at
``BOR_SHOW_TEXT_MAX_CHARS`` (default 12 000 chars — 5 blocks is a 60 KB
worst case against the 256 KB response budget). ``0`` is accepted and
means INERT (no block displays) — not a startup error."""
monkeypatch.delenv("BOR_SHOW_TEXT_MAX_CHARS", raising=False)
assert _settings().show_text_max_chars == 12_000
monkeypatch.setenv("BOR_SHOW_TEXT_MAX_CHARS", "500")
assert _settings().show_text_max_chars == 500
monkeypatch.setenv("BOR_SHOW_TEXT_MAX_CHARS", "0")
assert _settings().show_text_max_chars == 0
def test_show_text_max_chars_rejects_negative(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""A negative per-block cap is a typo — it would slice from the END of
the content instead of failing, so startup refuses naming the field
(the ``read_max_chars`` pattern, phase 182)."""
monkeypatch.setenv("BOR_SHOW_TEXT_MAX_CHARS", "-1")
with pytest.raises(ValidationError, match="show_text_max_chars"):
_settings()
def test_show_text_max_blocks_default_and_env_override(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Phase 182 (LOCKED A8): at most ``BOR_SHOW_TEXT_MAX_BLOCKS`` verbatim
blocks display per answer (default 5, counted in answer order). ``0``
is accepted and means INERT (no block displays)."""
monkeypatch.delenv("BOR_SHOW_TEXT_MAX_BLOCKS", raising=False)
assert _settings().show_text_max_blocks == 5
monkeypatch.setenv("BOR_SHOW_TEXT_MAX_BLOCKS", "1")
assert _settings().show_text_max_blocks == 1
monkeypatch.setenv("BOR_SHOW_TEXT_MAX_BLOCKS", "0")
assert _settings().show_text_max_blocks == 0
def test_show_text_max_blocks_rejects_negative(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""A negative per-answer block cap is a typo — it would count down
from the END of the block list instead of failing, so startup refuses
naming the field (the ``agent_max_rounds`` pattern, phase 182)."""
monkeypatch.setenv("BOR_SHOW_TEXT_MAX_BLOCKS", "-1")
with pytest.raises(ValidationError, match="show_text_max_blocks"):
_settings()
def test_recency_boost_default_and_env_override(
monkeypatch: pytest.MonkeyPatch,
) -> None: