phase: 145_git_source_links
**Phase 145 final verification pass — all green, no code changes needed** - **Verified (no defects found):** resolver `origin_for_source` + `_url_basename` (scp/`.git`/trailing-slash, sanitize, ambiguity WARNING); `origin:`/`branch:` lines in all four read shapes via shared `_origin_lines`; HIGH `<tools>` origin rule (verbatim + only-byte-change pins); `DocContent.origin_url/origin_branch` (absent-never-null serializer); `renderDocument` "Original" anchor (copyable verbatim URL, `_blank`/`noopener`, branch in title); mock scripted origin-link flow (disjoint trigger — grep-verified vs all other E2E files) - **Tests:** `uv run pytest --cov=app --cov-report=term-missing` → 3402 passed, `app/` coverage **99%** (>90% gate); `uv run pytest tests/e2e/test_git_source_links.py -v --no-cov` → **4 passed** in isolation; `uv run ruff check .` → clean; `uv run pyright` → 0 errors, 0 warnings - **Completion criteria:** (1) git read results carry origin/branch, local byte-identical — ✅ (unit pins + E2E control); (2) HIGH `<tools>` rule pinned, LOW byte-identical — ✅; (3) modal AND /document.html show Original link, branch in label when pinned, nothing for local — ✅; (4) full suite green + coverage + E2E + lint/types — ✅; (5) no completed-phase behavior change (read header line 1, mock prefix, done frame/SourceRef untouched, LOW sha) — ✅ - **Extra regression check:** re-ran shared-mock E2E suites `test_read_line_ranges.py` (2 passed) and `test_document_viewer.py` (8 passed) — no cross-suite regressions from the `mock_llm.py` addition - **Documentation:** README.md reviewed in full (env table ⊇ `.env.example`, pages/routes, config defaults, scripts, 17-color palette, 300 s guard, 2 s sync poll, phase-145 provenance section matches implementation) and AGENTS.md (72rem container, no-CDN test, smoke test, gitignore, gates) — **verified consistent, no changes needed** - **Notable:** phase-116 screenshot PNG was regenerated during this phase's E2E runs (byte re-encode only, visually identical, correct no-anchor local-source meta row) — left in tree for the harness commit - **Next pending phase:** `146_search_tool_scope` (then 147, 148, 149)
This commit is contained in:
@@ -48,6 +48,7 @@ import pytest
|
||||
from app.config import Settings
|
||||
from app.models import Document
|
||||
from app.rag.prompts import (
|
||||
ORIGIN_RULE,
|
||||
PERSONA,
|
||||
SHOW_IMAGE_CLAUSE,
|
||||
SUGGEST_INTRO,
|
||||
@@ -463,6 +464,43 @@ def test_tools_section_phase72_clauses_in_high_prompt_not_low() -> None:
|
||||
assert "including the source name" not in low
|
||||
|
||||
|
||||
def test_tools_section_phase145_origin_rule() -> None:
|
||||
"""Phase 145 (task 02): the ``<tools>`` ``read`` clause carries the
|
||||
original-source rule (LOCKED verbatim in :data:`ORIGIN_RULE`) — when
|
||||
the answer uses a document whose read result carries an ``origin:``
|
||||
line, it includes the original source (a link to the repository
|
||||
from the origin line, with the document's path and the pinned branch
|
||||
where shown) so the user opens the complete original in one step.
|
||||
The rule rides the HIGH prompt (``<tools>`` is HIGH-only) and never
|
||||
the LOW/deflection prompt. The citation discipline is UNCHANGED —
|
||||
the rule extends the ANSWERS of cited documents; it does not widen
|
||||
the cite set (the "cite only what you read" sentence stays
|
||||
byte-identical — pinned in ``test_prompt_lock``)."""
|
||||
# The rule is present verbatim in the constant, exactly once, and at
|
||||
# its exact position (the read clause's end, before the grep clause).
|
||||
assert TOOLS_SECTION.count(ORIGIN_RULE) == 1
|
||||
assert (
|
||||
"it searches the whole document. "
|
||||
+ ORIGIN_RULE
|
||||
+ " `grep` locates an exact string"
|
||||
) in TOOLS_SECTION
|
||||
# It rides the built HIGH prompt with the rest of the section.
|
||||
doc = _doc("kubernetes.md", "Talos Linux on three nodes.", "Kubernetes")
|
||||
high = build_high_prompt([doc])
|
||||
assert ORIGIN_RULE in high
|
||||
# ...and never the LOW/deflection prompt (``<tools>`` is HIGH-only).
|
||||
for low in (build_deflect_prompt(["T1"]), build_deflect_prompt([])):
|
||||
assert ORIGIN_RULE not in low
|
||||
# The citation discipline is UNCHANGED: the rule does not widen the
|
||||
# cite set (the "cite only what you read" sentence is untouched).
|
||||
assert (
|
||||
"Cite only the document(s) you read — or, if you answered from a "
|
||||
"suggested summary without reading it, cite that suggested "
|
||||
"document — never a document you neither read nor used."
|
||||
) in high
|
||||
assert "Cite only the document(s) you read" in SUGGEST_INTRO
|
||||
|
||||
|
||||
def test_documents_section_leads_with_the_suggest_intro() -> None:
|
||||
"""Phase 118, task 03: the ``<documents>`` section leads with the
|
||||
start-here :data:`SUGGEST_INTRO` line BEFORE the first block (the
|
||||
|
||||
Reference in New Issue
Block a user