docs(6209): twelve more test files say which behaviour they pin
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 52s
CI & Build / integration (push) Successful in 1m12s
CI & Build / Python tests (push) Successful in 1m53s
CI & Build / Build & push image (push) Successful in 12s

shape ledger, MCP projects/search/rulebooks tools, backup, chunking,
plugin context, derived mirror, rule band, shape form gate, plugin
version mint and note usage tests drop issue, milestone and rule numbers,
dates and one-install figures from docstrings, comments and messages.
Three shape-form-gate test names that told the discovery story now name
the property: a registry module's helpers are not service functions, the
divergence gate silences only a family contradiction, and callable helpers
beside a callable canon still prompt. The rulebook tool-count comment that
logged each milestone's additions is replaced by the reason it is a count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 21:24:50 -04:00
co-authored by Claude Opus 5.5
parent 91c96a8b8a
commit d41e72d26c
12 changed files with 223 additions and 265 deletions
+22 -23
View File
@@ -1,9 +1,9 @@
"""chunk_document — the document shape a record is embedded as (#280).
"""chunk_document — the document shape a record is embedded as.
The model window is 512 tokens and fastembed truncates silently, so before
chunking, everything past ~400 words of a record was PERMANENTLY invisible to
semantic search. These tests pin the two halves of the fix's contract: short
records keep the exact historical shape (the corpus's sharpest vectors are
The model window is 512 tokens and fastembed truncates silently, so without
chunking everything past ~400 words of a record would be invisible to
semantic search. These tests pin the two halves of the contract: short
records keep the single-document shape (the corpus's sharpest vectors are
untouched), and long records lose NOTHING — every line of the body lands in
some chunk, each chunk inside the window budget, each carrying the title as
its topical anchor.
@@ -29,7 +29,7 @@ def _long_section(tag: str, paragraphs: int = 6, sentence: str = None) -> str:
def test_a_short_record_yields_exactly_the_historical_shape():
"""Snippets and reference notes are the sharpest records in the corpus
(#2485) precisely because of this shape — chunking must not touch them."""
precisely because of this shape — chunking must not touch them."""
assert chunk_document("A title", "A short body") == [
embedding_text("A title", "A short body")
]
@@ -54,8 +54,8 @@ def test_a_record_exactly_at_budget_stays_whole():
def test_every_line_of_a_long_body_lands_in_some_chunk():
"""The point of #280. Before chunking, a 2,000-word dev-log's last three
quarters could not influence retrieval at all. Nothing may be dropped."""
"""The point of chunking: every part of a 2,000-word dev-log can
influence retrieval. Nothing may be dropped."""
sections = [
f"## Topic {i}\n\n{_long_section(f'topic-{i}')}" for i in range(8)
]
@@ -139,12 +139,11 @@ def test_a_monster_single_paragraph_is_hard_split_not_dropped():
assert total_words == 2000
# --- no chunk is a heading alone (#4784) -------------------------------------
# --- no chunk is a heading alone ---------------------------------------------
#
# Found by judging live auto-inject menus: "## Work log — 2026-08-21",
# "## Findings worth carrying forward" and "Two dev→main PRs this session."
# were each a whole chunk, and took ranks 1–3 on vague queries — text about
# nothing embeds close to everything. Each case below is one of those shapes.
# A heading or a one-line preamble as a whole chunk ranks at the top of vague
# queries — text about nothing embeds close to everything. Each case below is
# one of those shapes.
_HEADING = re.compile(r"^#{1,6}\s")
@@ -220,7 +219,7 @@ def test_a_continuation_piece_repeats_the_heading_it_sits_under():
assert "## Child" in chunk
# --- the read path: best chunk wins (#280 step 4) ----------------------------
# --- the read path: best chunk wins ------------------------------------------
async def test_search_collapses_chunk_rows_to_best_chunk_per_note():
@@ -233,7 +232,7 @@ async def test_search_collapses_chunk_rows_to_best_chunk_per_note():
note_a, note_b = MagicMock(id=1), MagicMock(id=2)
# Rows are (Note, distance, chunk_index, chunk_text) — the chunk columns
# ride along so the collapse can report WHICH passage won (#4243).
# ride along so the collapse can report WHICH passage won.
rows = [
(note_a, 0.10, 3, "the passage that actually matched"),
(note_b, 0.20, 0, "b's best"),
@@ -259,19 +258,19 @@ async def test_search_collapses_chunk_rows_to_best_chunk_per_note():
# And the winning chunk is reported, not merely used for scoring. Without
# this a caller can only preview the head of the body — a span this query
# has already ranked lower than the one that won (#4243).
# has already ranked lower than the one that won.
assert report["best_chunk"][1] == {
"index": 3, "text": "the passage that actually matched",
}
assert report["best_chunk"][2]["index"] == 0
# --- the write path: one row per chunk (#280 step 3) -------------------------
# --- the write path: one row per chunk ---------------------------------------
def _session_ctx(log_rows=()):
"""A session stand-in. `log_rows` answers the work-log read a task's
document now needs (#4251) — answered explicitly rather than left to
document needs — answered explicitly rather than left to
autovivify, because `list(result.all())` on a bare MagicMock raises and is
swallowed, which would quietly make every one of these a no-log test."""
from unittest.mock import AsyncMock, MagicMock
@@ -318,9 +317,9 @@ async def test_upsert_stores_one_versioned_row_per_chunk():
async def test_a_tasks_work_logs_reach_the_rows_it_is_stored_as():
"""The wiring half of #4251: the shaper is pure and tested next door, so
what is pinned here is that the WRITER actually asks for the logs and
embeds what comes back. A log that is written, readable (#4241) and absent
"""The wiring half: the shaper is pure and tested next door, so what is
pinned here is that the WRITER actually asks for the logs and embeds what
comes back. A log that is written, readable and absent
from the index is the same half-surface one layer down."""
import datetime
from unittest.mock import AsyncMock, patch
@@ -380,7 +379,7 @@ async def test_backfill_reembeds_notes_with_a_stale_chunker_version():
session, ctx = _session_ctx()
# The opening scan, in order: ids already at the current version, every
# note id, vectors older than their note, tasks logged since their vectors.
# IDS ONLY — the text is re-read per note at embed time (#4262).
# IDS ONLY — the text is re-read per note at embed time.
session.execute = AsyncMock(side_effect=[
_ids(1), # note 1 is current
_ids(1, 2), # the corpus
@@ -402,7 +401,7 @@ async def test_backfill_reembeds_notes_with_a_stale_chunker_version():
def test_a_row_is_current_only_in_the_live_models_space():
"""#4132: the column is a width, not an identity, so a same-width model
"""The column is a width, not an identity, so a same-width model
swap writes a second geometry with no error. The backfill's "current"
predicate has to name BOTH halves of the stamp, on every embedding table."""
from scribe.models.embedding import (