phase: 119_name_signal_read_chips
Build and Push Containers / build-and-push-app (push) Successful in 2m1s
Build and Push Containers / build-and-push-db (push) Successful in 18s

All verification complete. Final report:

**Phase 119 final verification pass — all criteria verified, one stale pin fixed.**
- Verified implementation of all 6 tasks: D1 component name-hit rule (`name_hit` flag, titles never matched, retired length tie-break), D2 `BOR_NAME_HIT_BONUS` (0.005 default, 0 = byte-identical kill switch, negative fails startup, selection-layer only, `eval_retrieval` `suggested:` line), D3 suggested-folder lines (after `SUGGEST_INTRO`, before first block), D4 cite-discipline `SUGGEST_INTRO` sentence (PERSONA/LOW/`TOOLS_SECTION` byte-pins intact), D5 `done.sources` = read docs only (frontend no-op on empty confirmed), D6 mock `repeat your folder map` echo + new suite + telemetry.
- Battery (replica restored per skill, fingerprint docs=1000/chunks=8866 verified, `eval_retrieval --from-file tests/fixtures/retrieval_battery.txt` re-run): **GATE PASS** — gitea README #4 in suggested top-5, forgejo 5/5 (README #1), gateway README in top-5 (#4), qwen3.8-27b quadlets top-5, Mongolia HIGH/fts=5 unchanged.
- New E2E in isolation: `4 passed` ×2 (deterministic). All 27 modified E2E suites in isolation: 26 green; **1 stale pin fixed** — `test_source_chip_quality.py` durable-record order pin pre-dated the D1 re-rank (`aliases` stem sub-component name-hits `ssh_aliases.txt`, deterministically lifting `backups.md` over `kubernetes.md`; probe-verified 0.016277 vs 0.016036, 4/4 stable) — re-pinned with the phase-119 rationale; suite green ×2.
- Gates: `uv run pytest --cov=app --cov-report=term-missing` → **2547 passed, app coverage 99%** (>90%); `uv run ruff check .` → All checks passed; `uv run pyright` → 0 errors.
- Completion criteria: 1 ✅ (battery, recorded), 2 ✅ (folder lines; block/LOW byte-identical pins green), 3 ✅ (read-only chips, zero-read chips nothing, related row + durable record untouched — unit+E2E agree), 4 ✅ (all green), 5 → commit/phase-move left to the harness per pass rules (nothing committed).
- Deviations: battery output + real-model telemetry recorded in `.agents/reports/119_name_signal_read_chips/task06_battery_and_e2e.md` and `TOOL_CALLING_TESTING.md` §11 (task files in `complete/` are immutable to this pass); gateway canonical doc at #4 vs overview's #3 was already documented at task 06 (containment gate met).
- Next pending phase: **none** — `todo/` holds only phase 119.
This commit is contained in:
2026-09-16 15:50:48 -04:00
parent 795fb56425
commit a5b63f83ad
89 changed files with 4377 additions and 655 deletions
+223
View File
@@ -1091,6 +1091,229 @@ def test_group_folder_listing_caps_files_at_fifty_keeps_the_total() -> None:
assert total50 == 50 and len(files50) == 50
# ---------- phase 119 (D3): the suggested-folder context lines ----------
def _patch_catalog(
monkeypatch: pytest.MonkeyPatch, catalog: dict[str, list[tuple[str, str, str]]]
) -> None:
"""Monkeypatch the ``ls`` fetchers (house style) with one source
catalog of ``(path, title, date)`` rows per source name."""
monkeypatch.setattr(
agent, "_source_document_rows", lambda db, source: catalog.get(source, [])
)
monkeypatch.setattr(agent, "_source_folder_summaries", lambda db, source: {})
def test_suggested_folder_lines_source_root_doc_lists_the_top_level(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""A suggested doc at the source root (``""`` prefix) renders the
``<source>/: …`` line with the source's top level — subfolders with
recursive counts, the suggested doc itself excluded."""
_patch_catalog(
monkeypatch,
{
"Homelab": [
("a/b/one.md", "One", "2024-06-15"),
("a/b/two.md", "Two", "2024-06-15"),
("a/c.md", "C", "2024-06-15"),
("z.md", "Z", "2024-06-15"),
]
},
)
assert agent.suggested_folder_lines(
cast("Session", object()), [_doc("Homelab", "z.md")]
) == ["Homelab/: a/ (3 docs)"]
def test_suggested_folder_lines_nested_doc_lists_the_parent_folder(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""A nested suggested doc renders the PARENT folder's line — the
direct children only: subfolder names (source-relative, recursive
counts) + the files by relative filename, the suggested doc itself
out of the entries."""
_patch_catalog(
monkeypatch,
{
"Homelab": [
("a/b/one.md", "One", "2024-06-15"),
("a/b/two.md", "Two", "2024-06-15"),
("a/c/d.md", "D", "2024-06-15"),
("a/e.md", "E", "2024-06-15"),
]
},
)
# The parent of a/b/one.md is a/b: one.md excluded, two.md stays.
assert agent.suggested_folder_lines(
cast("Session", object()), [_doc("Homelab", "a/b/one.md")]
) == ["Homelab/a/b/: two.md"]
# The parent of a/e.md is a: the subfolders (recursive counts — a/b
# carries two, a/c one) first, then the files; e.md excluded, so no
# file entries remain.
assert agent.suggested_folder_lines(
cast("Session", object()), [_doc("Homelab", "a/e.md")]
) == ["Homelab/a/: a/b/ (2 docs), a/c/ (1 doc)"]
def test_suggested_folder_lines_excludes_only_the_owning_doc(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""The doc that OWNS the line (the first suggested doc in that
folder) is the only one excluded — a folder whose sole entry was
the suggested doc renders its header alone (the empty-level
precedent)."""
_patch_catalog(
monkeypatch,
{
"Homelab": [("a/only.md", "Only", "2024-06-15")]
},
)
assert agent.suggested_folder_lines(
cast("Session", object()), [_doc("Homelab", "a/only.md")]
) == ["Homelab/a/:"]
def test_suggested_folder_lines_dedupes_by_source_and_prefix(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Dedupe: two suggested docs in the same folder ⇒ ONE line (the
first doc's position, the first doc excluded, the second listed);
the key is ``(source, prefix)`` — the same prefix under a DIFFERENT
source is a distinct line; suggested-doc order is the line order."""
_patch_catalog(
monkeypatch,
{
"Homelab": [
("a/b/one.md", "One", "2024-06-15"),
("a/b/two.md", "Two", "2024-06-15"),
("a/c.md", "C", "2024-06-15"),
("a/d/e.md", "E", "2024-06-15"),
("z.md", "Z", "2024-06-15"),
],
"Other": [("a/b/x.md", "X", "2024-06-15")],
},
)
docs = [
_doc("Homelab", "z.md"),
_doc("Homelab", "a/b/one.md"),
_doc("Homelab", "a/b/two.md"), # deduped (a/b already seen)
_doc("Homelab", "a/c.md"),
_doc("Homelab", "a/d/e.md"),
_doc("Other", "a/b/x.md"), # same prefix, different source
]
assert agent.suggested_folder_lines(cast("Session", object()), docs) == [
"Homelab/: a/ (4 docs)",
"Homelab/a/b/: two.md",
"Homelab/a/: a/b/ (2 docs), a/d/ (1 doc)",
"Homelab/a/d/:",
"Other/a/b/:",
]
def test_suggested_folder_lines_max_lines_caps_the_list(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""At most *max_lines* lines — the walk stops, suggested-doc order
kept (the first distinct folders win)."""
_patch_catalog(
monkeypatch,
{
"Homelab": [
("f1/x.md", "1", "2024-06-15"),
("f2/x.md", "2", "2024-06-15"),
("f3/x.md", "3", "2024-06-15"),
]
},
)
docs = [_doc("Homelab", p) for p in ("f1/x.md", "f2/x.md", "f3/x.md")]
lines = agent.suggested_folder_lines(cast("Session", object()), docs, max_lines=2)
assert lines == ["Homelab/f1/:", "Homelab/f2/:"]
assert agent.suggested_folder_lines(
cast("Session", object()), docs, max_lines=1
) == ["Homelab/f1/:"]
def test_suggested_folder_lines_max_entries_cap_and_remainder(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""At most *max_entries* entries, then `` +N more`` with the EXACT
remainder (the true pre-cap folder total — the owning doc leaves
it); the ``(1 doc)`` singular form; no `` +N more`` when every
entry fits."""
rows = [(f"big/s{i}/x.md", f"S{i}", "2024-06-15") for i in range(4)] + [
(f"big/f{i:02d}.md", f"F{i}", "2024-06-15") for i in range(10)
]
_patch_catalog(monkeypatch, {"S": rows})
db = cast("Session", object())
# 4 subfolders (one doc each) + 10 files − the owning f00.md = 13
# entries; 8 shown (the 4 subfolders + f01..f04) + 5 more. The
# subfolder entries are source-relative (``big/s0/``) — exactly as
# the model's own ls output names them.
assert agent.suggested_folder_lines(db, [_doc("S", "big/f00.md")]) == [
"S/big/: big/s0/ (1 doc), big/s1/ (1 doc), big/s2/ (1 doc), big/s3/ (1 doc), "
"f01.md, f02.md, f03.md, f04.md +5 more"
]
# A wide enough cap shows every entry — no remainder marker.
assert agent.suggested_folder_lines(db, [_doc("S", "big/f00.md")], max_entries=20) == [
"S/big/: big/s0/ (1 doc), big/s1/ (1 doc), big/s2/ (1 doc), big/s3/ (1 doc), "
"f01.md, f02.md, f03.md, f04.md, f05.md, f06.md, f07.md, f08.md, f09.md"
]
# The remainder is exact at a tighter cap too (3 subfolders shown —
# files only follow ALL subfolders, the ls order — 10 left).
assert agent.suggested_folder_lines(db, [_doc("S", "big/f00.md")], max_entries=3) == [
"S/big/: big/s0/ (1 doc), big/s1/ (1 doc), big/s2/ (1 doc) +10 more"
]
def test_suggested_folder_lines_entry_order_matches_the_ls_listing(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""The line's entry order IS the ``ls`` folder-level rendering order
(pinned against :func:`group_folder_listing` itself): the direct
subfolders first (path order), then the files (path order) — a
mixed folder where the file names and the subfolder names interleave
in path order still lists all subfolders before any file."""
rows = [
("a/a.md", "A", "2024-06-15"),
("a/b.md", "B", "2024-06-15"),
("a/c/d.md", "D", "2024-06-15"),
]
_patch_catalog(monkeypatch, {"Homelab": rows})
db = cast("Session", object())
suggested = _doc("Homelab", "a/b.md")
# The expected entry order, derived from group_folder_listing itself
# (subfolders → files, minus the owning doc) — the line must read
# the same as the model's own ls output.
sub, files, total = agent.group_folder_listing("Homelab", "a", rows, {})
assert total == 2
expected_entries = [
f"{g}/ ({c} {'doc' if c == 1 else 'docs'})" for g, c, _s in sub
] + [path.rsplit("/", 1)[-1] for _src, path, _t, _d in files if path != suggested.path]
# Subfolder source-relative (``a/c/``), files by relative filename.
assert expected_entries == ["a/c/ (1 doc)", "a.md"]
expected_line = f"Homelab/a/: {', '.join(expected_entries)}"
assert agent.suggested_folder_lines(db, [suggested]) == [expected_line]
def test_suggested_folder_lines_empty_suggested_yields_no_lines(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""No suggested docs → no lines (the caller then builds the
byte-identical phase-118 prompt) — and no fetcher call at all."""
calls: list[str] = []
def _rows(db: Any, source: str) -> list[tuple[str, str, str]]:
calls.append(source)
return []
monkeypatch.setattr(agent, "_source_document_rows", _rows)
monkeypatch.setattr(agent, "_source_folder_summaries", lambda db, source: {})
assert agent.suggested_folder_lines(cast("Session", object()), []) == []
assert calls == []
# ---------- the pinned drill-down templates (byte-for-byte) ----------