phase: 118_summary_seed_context
**Phase 118 final verification pass — complete.** All criteria verified; 4 pre-existing defects found and fixed.
- **Verified:** summary-seed wiring (`select_suggested` top-5 no-floor → summary blocks, no full text in HIGH prompt), all-doc markdown summaries + NULL backfill (`summary_backfilled`, no `sources_meta` bump), `read` adds full text with `read_docs`-only dedupe, `done.sources` = suggested+read / durable record = suggested+related+read + `suggested=N` log line (seen live in E2E), byte-locked PERSONA/LOW/TOOLS_SECTION, battery gate PASS recorded in `TOOL_CALLING_TESTING.md` §10 (turbo 2026-09-16: 1/2/4 GREEN, cond-3 reported 9/10 per A7, contract 21/21, caps 0).
- **Defects fixed (all pre-existing, none phase-118):** ① `ChatMessage` schema missing the phase-113 `related` key → `extra="forbid"` 422'd every done-time auto-save of grounded turns with a related tier, leaving `message_count=1` (root cause of `test_share_chat` 3F; browser-level instrumentation proved the PUT 422) — added the field + unit/integration pins; ② `test_theme_semantic_completion` pins stale vs phase-117 debox (border/chip removed) — re-targeted to assert border/chip *absence*; ③ `test_header_consistency` `<26`px pin red on 26.125px native date-input line — bound relaxed to `<34` (wrap-detection intent kept); ④ `test_navbar_refresh` bor.chat.v1 key set updated for `related`.
- **Test/lint/coverage:** `uv run pytest --cov=app --cov-report=term-missing` → **2506 passed, app/ 99%** (>90%); `uv run ruff check . && uv run pyright` → clean, 0 errors.
- **E2E:** new story suite in isolation → **2 passed**; full 103-suite matrix sweep (each isolated) → **all 103 green** after the fixes; `test_share_chat` 4 passed, `test_theme_semantic_completion` 8 passed, `test_header_consistency` 3 passed, `test_navbar_refresh` 7 passed.
- **Deviations:** none from LOCKED decisions. Note: orphaned diagnostic uvicorn processes briefly made E2E sessions exercise stale code — killed and re-verified; a sweep-regenerated tracked screenshot was restored. No commits made (harness commits).
- **Completion criteria:** all 7 ✅ (commit/phase-move is the harness's step).
- **Next pending phase:** none — `todo/` holds only this phase's overview pending the harness move.
This commit is contained in:
@@ -16,6 +16,7 @@ import hashlib
|
||||
|
||||
from app.rag.prompts import (
|
||||
PERSONA,
|
||||
SUGGEST_INTRO,
|
||||
TOOLS_SECTION,
|
||||
_base,
|
||||
build_deflect_prompt,
|
||||
@@ -67,9 +68,16 @@ def test_high_and_low_bases_byte_locked() -> None:
|
||||
|
||||
# ---------- TOOLS_SECTION (the HIGH prompt's locked ``<tools>`` copy) ----------
|
||||
|
||||
#: Pre-phase-112 anchors for ``TOOLS_SECTION``.
|
||||
TOOLS_SECTION_SHA256 = "b834cbe368055e65da82ae3e37a91e6c658c713954703fc79b849a6ebdf4aa53"
|
||||
TOOLS_SECTION_LEN = 2273
|
||||
#: Anchors for ``TOOLS_SECTION`` — pre-phase-112 values, RE-CUT for
|
||||
#: phase 118 (task 04, A6, owner directive 2026-09-15): the ``read``
|
||||
#: clause was rewritten for the summary-seed mode (the ``<documents>``
|
||||
#: section holds SUMMARIES — ``read`` adds the full text; only an
|
||||
#: already-read document is refused). Only that clause moved — the
|
||||
#: prefix (the ``ls``-clause opening) and the suffix (the
|
||||
#: discipline-rules ending) survived byte-identical, so they are the
|
||||
#: same anchors as pre-phase-118.
|
||||
TOOLS_SECTION_SHA256 = "87ee80faf0170da6ab1de518177313def6460785613fa074312a2a5f9f071750"
|
||||
TOOLS_SECTION_LEN = 2465
|
||||
TOOLS_SECTION_PREFIX = (
|
||||
"<tools>\n"
|
||||
"You may extend your context with three tools. `ls` lists the "
|
||||
@@ -120,3 +128,51 @@ def test_deflect_body_byte_locked() -> None:
|
||||
assert prompt.index("DEFLECT_MODE") < prompt.index(
|
||||
"Reply in plain text only"
|
||||
) # the marker precedes the plain-text line
|
||||
|
||||
|
||||
#: The full LOW prompt build on the canonical fixture titles — sha-pinned
|
||||
#: (phase 118, task 03): the deflection path is UNTOUCHED by the
|
||||
#: summary-seed re-revision (LOCKED A8) — the same inputs must produce
|
||||
#: the pre-phase bytes, so this anchor is a pre-phase-118 value.
|
||||
LOW_PROMPT_SHA256 = "726eddb4eb3bcc26c840011f6f8635d6af55aa09d4d064bbb9e256caa9665837"
|
||||
LOW_PROMPT_LEN = 968
|
||||
|
||||
|
||||
def test_low_prompt_build_byte_identical_to_pre_phase() -> None:
|
||||
"""Phase 118 contract: the LOW prompt output is byte-identical to
|
||||
pre-phase for identical inputs — the summary seeding (and the new
|
||||
``SUGGEST_INTRO`` line) never leaks into the deflection path."""
|
||||
prompt = build_deflect_prompt(["T1", "T2"])
|
||||
assert len(prompt) == LOW_PROMPT_LEN
|
||||
assert _sha256(prompt) == LOW_PROMPT_SHA256
|
||||
assert "SUGGEST_INTRO" not in prompt and "<documents>" not in prompt
|
||||
|
||||
|
||||
# ---------- SUGGEST_INTRO (phase 118, task 03 — the start-here framing) ----------
|
||||
|
||||
#: Phase-118 anchors for ``SUGGEST_INTRO`` — the ``<documents>``
|
||||
#: section's intro line (the owner's "start here if these summaries seem
|
||||
#: right to you" framing, TODO L3). The E2E mock's ``_document_block``
|
||||
#: parser is regex-based over the block markup (which stays byte-stable
|
||||
#: around the intro), so this constant is a prompt-copy lock, pinned the
|
||||
#: way ``TOOLS_SECTION`` is: sha256 + prefix + total length.
|
||||
SUGGEST_INTRO_SHA256 = "7b14d2dedc6ebc4e440d32dd1edb979a7461c94034b9541c9f37b9042f394d3a"
|
||||
SUGGEST_INTRO_LEN = 323
|
||||
SUGGEST_INTRO_PREFIX = (
|
||||
"The blocks below are the summaries of the top-ranked documents for "
|
||||
"your question — start here if one seems right to you: "
|
||||
)
|
||||
|
||||
|
||||
def test_suggest_intro_byte_locked() -> None:
|
||||
"""The start-here framing is LOCKED copy (phase 118): sha256 + exact
|
||||
prefix + total length; the three contracts it must carry (summaries
|
||||
are the starting points; ``read`` adds the full text, which is NOT
|
||||
in the prompt until read; cite by path) are pinned as substrings."""
|
||||
assert len(SUGGEST_INTRO) == SUGGEST_INTRO_LEN
|
||||
assert _sha256(SUGGEST_INTRO) == SUGGEST_INTRO_SHA256
|
||||
assert SUGGEST_INTRO.startswith(SUGGEST_INTRO_PREFIX)
|
||||
assert "call `read`" in SUGGEST_INTRO
|
||||
assert "combined `source/path`" in SUGGEST_INTRO
|
||||
assert "its full text is not in the prompt until you read it" in SUGGEST_INTRO
|
||||
assert "Cite the document(s) you used, by path." in SUGGEST_INTRO
|
||||
|
||||
Reference in New Issue
Block a user