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,9 +16,10 @@ reused here as closely as possible):
|
||||
``documents.summary``. The sentinel ``RESE-SUMMARY-SENTINEL-7f3a`` sits
|
||||
on the document's LAST line — **outside** the 24-token digest — so it
|
||||
is a marker for "the original, not the summary".
|
||||
* ``notes/qwen-llamacpp-notes.md`` — a markdown control doc, never
|
||||
summarized (phase 30 scope): the viewer must render it exactly as
|
||||
before, with no Summary panel.
|
||||
* ``notes/qwen-llamacpp-notes.md`` — a markdown doc that phase 118 (A2)
|
||||
summarizes TOO (the phase-30 non-markdown-only scope is retired): the
|
||||
viewer must show its Summary panel exactly like the yaml's, above the
|
||||
rendered markdown.
|
||||
|
||||
This phase only surfaces the stored field: the content endpoint returns
|
||||
``summary`` (task 01) and the shared ``renderDocument`` core draws the
|
||||
@@ -27,8 +28,8 @@ labeled ``.doc-summary`` panel above the content on BOTH surfaces (task
|
||||
exactly that contract. Phase 79 supersedes the phase-16 soft rule: the
|
||||
content endpoint is ``require_user``-gated, so the viewer surfaces and
|
||||
the API shape pin run under a signed-in session (the shape itself —
|
||||
``summary`` for the yaml, ``null`` for the markdown control — is
|
||||
unchanged).
|
||||
``summary`` for BOTH fixture docs, phase 118 A2 — is what the pins
|
||||
carry).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -98,13 +99,14 @@ def _run_in_thread(coro: Any) -> Any:
|
||||
|
||||
def _reset_db_and_import(mock_llm: int) -> ImportSummary:
|
||||
"""Truncate the KB (and query log + steering) and re-import the
|
||||
summary_kb fixtures — yaml summarized, md control not."""
|
||||
summary_kb fixtures — both docs summarized (phase 118, A2: the
|
||||
markdown doc too)."""
|
||||
with SessionLocal() as db:
|
||||
db.execute(text("TRUNCATE chunks, documents, query_log, steering_notes"))
|
||||
db.commit()
|
||||
summary = _run_in_thread(_import_fixtures(mock_llm))
|
||||
assert summary.added == 2 # yaml + md control
|
||||
assert summary.summaries == 1 and summary.summary_errors == 0
|
||||
assert summary.added == 2 # yaml + md
|
||||
assert summary.summaries == 2 and summary.summary_errors == 0 # A2: md too
|
||||
assert summary.errors == 0
|
||||
return summary
|
||||
|
||||
@@ -279,19 +281,30 @@ def test_modal_shows_panel_and_full_page_agrees(
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_markdown_doc_has_no_summary_panel(
|
||||
def test_markdown_doc_has_a_summary_panel(
|
||||
page: Page, app_url: str, mock_llm: int, db_ready: None
|
||||
) -> None:
|
||||
"""Control doc (markdown — never summarized): NO .doc-summary
|
||||
element on either surface, and the content renders exactly as
|
||||
before (first child of the content container is the doc body)."""
|
||||
"""Phase 118 (A2): the markdown doc is summarized TOO — the SAME
|
||||
labeled ``.doc-summary`` panel (the deterministic mock digest +
|
||||
pointer line) renders above the rendered markdown on BOTH surfaces
|
||||
(the phase-30 "markdown never summarized" control is retired with
|
||||
the non-markdown-only scope)."""
|
||||
_reset_db_and_import(mock_llm)
|
||||
page.set_default_timeout(30_000)
|
||||
login(page, app_url, next="/") # phase 79: the viewer content is gated
|
||||
|
||||
# Full page: no panel, markdown column untouched.
|
||||
digest_line, pointer_line = _summary_lines(SOURCE, MD_PATH)
|
||||
|
||||
# Full page: the labeled panel above the markdown column (the same
|
||||
# contract as the yaml — one shared renderer).
|
||||
page.goto(f"{app_url}/document.html?source={SOURCE}&path={MD_URL_PATH}")
|
||||
expect(page.locator(".doc-summary")).to_have_count(0)
|
||||
panel = page.locator(".doc-summary")
|
||||
expect(panel).to_have_count(1)
|
||||
expect(panel).to_be_visible()
|
||||
expect(panel).to_have_attribute("aria-label", "Summary")
|
||||
expect(panel.locator(".doc-summary-title")).to_have_text("Summary")
|
||||
expect(panel).to_contain_text(digest_line)
|
||||
expect(panel).to_contain_text(pointer_line)
|
||||
expect(page.locator("#doc-content .doc-md")).to_have_count(1)
|
||||
expect(page.locator("#doc-content")).to_contain_text(
|
||||
"came out of a week of"
|
||||
@@ -300,10 +313,10 @@ def test_markdown_doc_has_no_summary_panel(
|
||||
"() => [...document.querySelector('#doc-content').children]"
|
||||
".map((el) => el.className)"
|
||||
)
|
||||
assert order == ["doc-md"], f"markdown doc gained children: {order}"
|
||||
assert order == ["doc-summary", "doc-md"], f"panel not first: {order}"
|
||||
|
||||
# Modal: same story — no panel, .doc-md is the sole content child.
|
||||
# (the session is already signed in — the form login above)
|
||||
# Modal: same story — the panel above .doc-md (the session is
|
||||
# already signed in — the form login above).
|
||||
page.goto(f"{app_url}/sources.html")
|
||||
# Phase 97: the re-mount lands on the tree's top level — drill to
|
||||
# the notes level where the row lives (the drill is the only
|
||||
@@ -314,7 +327,11 @@ def test_markdown_doc_has_no_summary_panel(
|
||||
expect(row).to_have_count(1)
|
||||
row.locator("td:nth-child(2) a.doc-link").click()
|
||||
expect(page.locator(".doc-modal")).to_be_visible()
|
||||
expect(page.locator("#doc-modal .doc-summary")).to_have_count(0)
|
||||
modal_panel = page.locator("#doc-modal .doc-summary")
|
||||
expect(modal_panel).to_have_count(1)
|
||||
expect(modal_panel).to_be_visible()
|
||||
expect(modal_panel).to_contain_text(digest_line)
|
||||
expect(modal_panel).to_contain_text(pointer_line)
|
||||
expect(page.locator("#doc-modal .doc-md")).to_have_count(1)
|
||||
expect(page.locator("#doc-modal-content")).to_contain_text(
|
||||
"came out of a week of"
|
||||
@@ -323,7 +340,7 @@ def test_markdown_doc_has_no_summary_panel(
|
||||
"() => [...document.querySelector('#doc-modal-content').children]"
|
||||
".map((el) => el.className)"
|
||||
)
|
||||
assert order == ["doc-md"], f"markdown modal gained children: {order}"
|
||||
assert order == ["doc-summary", "doc-md"], f"markdown modal order: {order}"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -336,10 +353,9 @@ def test_content_api_summary_shape(
|
||||
page: Page, app_url: str, mock_llm: int, db_ready: None
|
||||
) -> None:
|
||||
"""``GET /api/documents/content`` carries ``summary`` — the string
|
||||
for the summarized yaml, ``null`` for the markdown control. Phase 79
|
||||
superseded the phase-16 soft rule: the endpoint is require_user, so
|
||||
the pin runs under the form-login session (the shape itself is
|
||||
unchanged)."""
|
||||
for BOTH fixture docs (phase 118, A2: the markdown doc too). Phase
|
||||
79 superseded the phase-16 soft rule: the endpoint is require_user,
|
||||
so the pin runs under the form-login session."""
|
||||
_reset_db_and_import(mock_llm)
|
||||
login(page, app_url, next="/")
|
||||
|
||||
@@ -364,5 +380,10 @@ def test_content_api_summary_shape(
|
||||
assert resp_md.status == 200
|
||||
md_body = resp_md.json()
|
||||
assert md_body["format"] == "md"
|
||||
assert md_body["summary"] is None, "markdown docs never carry a summary"
|
||||
# Phase 118 (A2): the markdown doc carries its summary too — the
|
||||
# same byte-stable digest + pointer line.
|
||||
md_digest_line, _ = _summary_lines(SOURCE, MD_PATH)
|
||||
assert md_body["summary"] == (
|
||||
f"{md_digest_line}\nSource: {SOURCE}/{MD_PATH}"
|
||||
)
|
||||
assert "came out of a week of" in md_body["content"]
|
||||
|
||||
Reference in New Issue
Block a user