test_descriptions.py¶
tests/test_descriptions.py
Tests for the JSON tool-description loader.
test_a_bare_string_description_is_accepted
None test_descriptions.test_a_bare_string_description_is_accepted(Path tmp_path, pytest.MonkeyPatch monkeypatch)
A one-sentence description may be a bare string.
tests/test_descriptions.py:361
Checks
assert d.load_descriptions() == {"dossier": "Just the one line."}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_a_bare_string_description_is_accepted → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_a_bare_string_description_is_accepted → load_descriptions → _entry → _joined → all |
Source · 10 lines
def test_a_bare_string_description_is_accepted(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""The list form exists for diff readability, not as a ceremony a short
description has to perform."""
_redirect(monkeypatch, tmp_path)
_put(tmp_path, "dossier", {"tool": "dossier", "description": "Just the one line."})
assert d.load_descriptions() == {"dossier": "Just the one line."}
Activity · 3 steps
test_bad_json_names_the_file
None test_descriptions.test_bad_json_names_the_file(Path tmp_path, pytest.MonkeyPatch monkeypatch)
Malformed JSON names the file it is in.
tests/test_descriptions.py:329
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_bad_json_names_the_file → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_bad_json_names_the_file → load_descriptions → _entry → _joined → all |
Source · 9 lines
def test_bad_json_names_the_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""A bare `JSONDecodeError` gives a line and column but not a filename, and these
are hand-edited content files — the filename is the first thing you need."""
_redirect(monkeypatch, tmp_path)
(tmp_path / "dossier.json").write_text('{"tool": "dossier",}', encoding="utf-8")
with pytest.raises(ValueError, match="dossier.json is not valid JSON"):
d.load_descriptions()
Activity · 4 steps
test_empty_directory_is_an_error
None test_descriptions.test_empty_directory_is_an_error(Path tmp_path, pytest.MonkeyPatch monkeypatch)
An empty descriptions directory raises instead of returning {}.
tests/test_descriptions.py:236
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_empty_directory_is_an_error → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_empty_directory_is_an_error → load_descriptions → _entry → _joined → all |
Source · 8 lines
def test_empty_directory_is_an_error(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""This is the packaging failure: a wheel built without the data files would
otherwise start a server advertising nothing, with no explanation."""
_redirect(monkeypatch, tmp_path)
with pytest.raises(ValueError, match="no tool descriptions"):
d.load_descriptions()
Activity · 3 steps
test_filename_and_declared_tool_must_agree
None test_descriptions.test_filename_and_declared_tool_must_agree(Path tmp_path, pytest.MonkeyPatch monkeypatch)
A file whose declared tool disagrees with its filename is refused.
tests/test_descriptions.py:263
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_filename_and_declared_tool_must_agree → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_filename_and_declared_tool_must_agree → load_descriptions → _entry → _joined → all |
Source · 12 lines
def test_filename_and_declared_tool_must_agree(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""Otherwise a copied-and-edited file describes one tool under another's name,
and the correspondence test above would still pass because the FILENAME set is
right."""
_redirect(monkeypatch, tmp_path)
_put(tmp_path, "callers", {"tool": "callees", "description": ["mismatched"]})
with pytest.raises(ValueError, match="declares tool"):
d.load_descriptions()
Activity · 4 steps
test_missing_snippet_is_refused
None test_descriptions.test_missing_snippet_is_refused(Path tmp_path, pytest.MonkeyPatch monkeypatch)
An unknown snippet name is refused.
tests/test_descriptions.py:203
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_missing_snippet_is_refused → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_missing_snippet_is_refused → load_descriptions → _entry → _joined → all |
Source · 8 lines
def test_missing_snippet_is_refused(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""@brief A typo'd include must fail rather than silently append nothing."""
_redirect(monkeypatch, tmp_path)
_put(tmp_path, "dossier", {"description": ["Body."], "include": ["row"]})
with pytest.raises(ValueError, match="no such snippet"):
d.load_descriptions()
Activity · 4 steps
test_missing_template_is_refused
None test_descriptions.test_missing_template_is_refused(Path tmp_path, pytest.MonkeyPatch monkeypatch)
A template name that does not exist is refused.
tests/test_descriptions.py:280
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_missing_template_is_refused → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_missing_template_is_refused → load_descriptions → _entry → _joined → all |
Source · 8 lines
def test_missing_template_is_refused(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""@brief A typo'd template name must fail, not yield empty text."""
_redirect(monkeypatch, tmp_path)
_put(tmp_path, "callers", {"tool": "callers", "template": "neighbour", "vars": {}})
with pytest.raises(ValueError, match="no such template"):
d.load_descriptions()
Activity · 4 steps
test_missing_var_is_refused
None test_descriptions.test_missing_var_is_refused(Path tmp_path, pytest.MonkeyPatch monkeypatch)
A template var the text needs but the file omits is refused.
tests/test_descriptions.py:312
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_missing_var_is_refused → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_missing_var_is_refused → load_descriptions → _entry → _joined → all |
Source · 12 lines
def test_missing_var_is_refused(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""@brief An unsupplied placeholder must fail rather than render a brace."""
_redirect(monkeypatch, tmp_path)
(tmp_path / "_templates").mkdir()
(tmp_path / "_templates" / "t.json").write_text(
json.dumps({"text": ["hello {lead} and {seam}"]}), encoding="utf-8"
)
_put(tmp_path, "callers", {"template": "t", "vars": {"lead": "x"}})
with pytest.raises(ValueError, match="needs var"):
d.load_descriptions()
Activity · 6 steps
test_no_description_claims_an_elided_field_is_null
None test_descriptions.test_no_description_claims_an_elided_field_is_null()
The neighbours template no longer claims a key row's confidence is null.
tests/test_descriptions.py:189
Checks
assert "is null" not in text, "a description claims a field is null; it is absent"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_no_description_claims_an_elided_field_is_null → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_no_description_claims_an_elided_field_is_null → load_descriptions → _entry → _joined → all |
Source · 9 lines
def test_no_description_claims_an_elided_field_is_null() -> None:
"""A REGRESSION TEST for a real contradiction: the template said `confidence` is
null on a 'key' row, and that became false when `wire` began eliding fields carrying
no value. A description that contradicts the payload is worse than a vague one,
because a model acts on it."""
for text in d.load_descriptions().values():
assert "is null" not in text, "a description claims a field is null; it is absent"
Activity · 2 steps
test_non_string_description_is_refused
None test_descriptions.test_non_string_description_is_refused(Path tmp_path, pytest.MonkeyPatch monkeypatch)
A non-string description value is refused.
tests/test_descriptions.py:343
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_non_string_description_is_refused → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_non_string_description_is_refused → load_descriptions → _entry → _joined → all |
Source · 13 lines
def test_non_string_description_is_refused(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""Covers the absent case too: `description` missing entirely arrives here as
None, and must not join to an empty string."""
_redirect(monkeypatch, tmp_path)
_put(tmp_path, "dossier", {"tool": "dossier", "description": [1, 2]})
with pytest.raises(ValueError, match="must be a string or a list"):
d.load_descriptions()
_put(tmp_path, "dossier", {"tool": "dossier", "priority": 1})
with pytest.raises(ValueError, match="must be a string or a list"):
d.load_descriptions()
Activity · 7 steps
test_registration_order_follows_declared_priority
None test_descriptions.test_registration_order_follows_declared_priority()
Declared priority orders registration; dossier leads.
tests/test_descriptions.py:157
Checks
assert list(d.load_descriptions()) == ["dossier", "search"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_registration_order_follows_declared_priority → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_registration_order_follows_declared_priority → load_descriptions → _entry → _joined → all |
Source · 14 lines
def test_registration_order_follows_declared_priority() -> None:
"""Order is part of how the tool list reads, and `dossier` leading is deliberate —
its description opens with CALL THIS FIRST.
@brief The tier-1 list is ordered by declared priority.
@return None.
@version 2
"""
assert list(d.load_descriptions()) == ["dossier", "search"]
# ─── every malformed input fails loudly ──────────────────────────────────────
Activity · 1 steps
test_shipped_descriptions_are_rendered_and_substantial
None test_descriptions.test_shipped_descriptions_are_rendered_and_substantial()
No shipped description is empty or left with an unfilled placeholder.
Checks
assert len(text) > 40, f"{name}: description is suspiciously short"assert "{" not in text and "}" not in text, f"{name}: unrendered placeholder"assert not text.startswith(" ") and not text.endswith(" "), f"{name}: stray edge space"assert " " not in text, f"{name}: double space — a description line ended with one"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_shipped_descriptions_are_rendered_and_substantial → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_shipped_descriptions_are_rendered_and_substantial → load_descriptions → _entry → _joined → all |
Source · 23 lines
def test_shipped_descriptions_are_rendered_and_substantial() -> None:
"""An unfilled `{placeholder}` reaching a model's tool list is the specific
failure the template mechanism can produce, and it looks like working prose
until you read it closely.
BOTH TIERS, because `load_descriptions()` defaults to tier 1 and a bare call would
silently stop covering the five tier-0 files the moment they arrived — a coverage hole
that looks exactly like a passing test. It caught real prose on the way in: the moved
`build_or_refresh` text wrote `options=` with braces and a literal tag-to-role mapping,
which this assertion reads as an unrendered placeholder, so the wording was changed
rather than the invariant."""
loaded = {
**d.load_descriptions(tier=1),
**d.load_descriptions(tier=0),
**d.load_descriptions(tier=2), # 2.0.0: the prompts
}
for name, text in loaded.items():
assert len(text) > 40, f"{name}: description is suspiciously short"
assert "{" not in text and "}" not in text, f"{name}: unrendered placeholder"
assert not text.startswith(" ") and not text.endswith(" "), f"{name}: stray edge space"
assert " " not in text, f"{name}: double space — a description line ended with one"
Activity · 6 steps
test_snippet_with_a_placeholder_is_refused
None test_descriptions.test_snippet_with_a_placeholder_is_refused(Path tmp_path, pytest.MonkeyPatch monkeypatch)
A snippet containing a placeholder is refused.
tests/test_descriptions.py:216
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_snippet_with_a_placeholder_is_refused → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_snippet_with_a_placeholder_is_refused → load_descriptions → _entry → _joined → all |
Source · 15 lines
def test_snippet_with_a_placeholder_is_refused(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""An include takes no vars, so a placeholder in a snippet would reach a model's
tool list as a literal brace. Refused with the fix named — use `template`."""
_redirect(monkeypatch, tmp_path)
(tmp_path / "_templates").mkdir()
(tmp_path / "_templates" / "s.json").write_text(
json.dumps({"text": ["needs {a}"]}), encoding="utf-8"
)
_put(tmp_path, "dossier", {"description": ["Body."], "include": ["s"]})
with pytest.raises(ValueError, match="use 'template' instead"):
d.load_descriptions()
Activity · 6 steps
test_unknown_key_is_refused
None test_descriptions.test_unknown_key_is_refused(Path tmp_path, pytest.MonkeyPatch monkeypatch)
An unknown key is refused rather than ignored.
tests/test_descriptions.py:249
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_unknown_key_is_refused → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_unknown_key_is_refused → load_descriptions → _entry → _joined → all |
Source · 9 lines
def test_unknown_key_is_refused(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""`descriptio` for `description` must not parse to a tool with no text. Same
reasoning as the dispatch manifest's entry-level rejection."""
_redirect(monkeypatch, tmp_path)
_put(tmp_path, "dossier", {"tool": "dossier", "descriptio": ["typo"]})
with pytest.raises(ValueError, match="unknown key"):
d.load_descriptions()
Activity · 4 steps
test_unused_var_is_refused
None test_descriptions.test_unused_var_is_refused(Path tmp_path, pytest.MonkeyPatch monkeypatch)
A template var the text never uses is refused.
tests/test_descriptions.py:293
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-001 | measured | test_unused_var_is_refused → load_descriptions |
| REQ-DDB-WIKI-054 | inferred | test_unused_var_is_refused → load_descriptions → _entry → _joined → all |
Source · 14 lines
def test_unused_var_is_refused(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""The subtle half of the template contract. A RENAMED placeholder still renders —
the old var is simply ignored and the new `{brace}` stays literal — so refusing an
unused var is what turns that into an error instead of prose a model reads."""
_redirect(monkeypatch, tmp_path)
(tmp_path / "_templates").mkdir()
(tmp_path / "_templates" / "t.json").write_text(
json.dumps({"text": ["hello {lead}"]}), encoding="utf-8"
)
_put(tmp_path, "callers", {"template": "t", "vars": {"lead": "x", "stale": "y"}})
with pytest.raises(ValueError, match="not used by template"):
d.load_descriptions()