Files
FabledGrimoire/tests/test_reply_discipline.py
bvandeusenandClaude Opus 5.5 0f5ef0be63
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 56s
CI & Build / integration (push) Successful in 1m4s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / Build & push image (push) Successful in 44s
rename(547): the server is grimoire — package, image, DB defaults, backups
Step 2 of the Scribe -> Grimoire rename.

- src/scribe -> src/grimoire, and every import, patch target, module path,
  hypercorn entry point and `python -m grimoire.restore` with it; pyproject,
  uv.lock and the frontend package are named grimoire.
- Image git.fabledsword.com/bvandeusen/fabledgrimoire; CI's Postgres service
  runs as grimoire / grimoire_test.
- Compose files default the DB user, database and (prod) volume to grimoire,
  each overridable from .env, so an install created as Scribe keeps its data
  by setting POSTGRES_USER, POSTGRES_DB and PGDATA_VOLUME.
- Backups are written as grimoire-<ts>.tar with format grimoire-backup-tar.
  Archives named scribe-* with the scribe-backup-tar manifest still restore
  and are still counted at the destination (folder and S3), with tests.
- Exports, the MCP auth realm, the ASGI scope key and the persistent logger
  carry the new name.

Kept on purpose: the secret-sealing key label stays "scribe.secrets.v1",
because every stored secret was derived under it.

Plugin identity (plugin name, hooks, env vars, .scribe marker, skills) is
step 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 10:50:45 -04:00

138 lines
5.8 KiB
Python

"""A reply's sections are chosen, not filled.
WHY THIS EXISTS
A reply can carry every section the table asks for — placement, what changed,
what needs the operator, what comes next — and still be unreadable: adherence
passes and the read test fails. An instruction to pick a kind of reply "then
fill its sections" is an instruction to complete a form, and with no ceiling a
section with a heading and nothing to say gets filled rather than dropped. A
faithful reply and an unreadable one become the same reply.
WHAT IS PINNED
The discipline, not the scaffold. The fifteen categories and their sections are
unchanged and are not this file's subject:
1. Sections are chosen — a standing question is always answered, an
explanation earns its place.
2. The reply is as short as the answer allows, and gets a second pass for
what can go.
3. "Needs you" takes BOTH tests: theirs to decide, and blocking.
4. A decision already made is acted on rather than re-argued.
WHY THERE IS NO ABSENCE CHECK HERE
The obvious guard — assert the skill never tells anyone to "fill" a section —
is a trap. This skill legitimately discusses
filling in order to warn against it ("not a form to complete", "a section
filled because it was in the table"), so an absence check would fail on the
corrected text: a false alarm about the very thing it protects.
So every assertion here is a PRESENCE check, and one is POSITIONAL —
`test_the_needs_you_test_sits_with_the_needs_you_section` pins where the test
lives, not merely that the words occur somewhere in the file. Each fails
against a skill that says to fill its sections.
"""
from __future__ import annotations
import pathlib
ROOT = pathlib.Path(__file__).resolve().parents[1]
SKILL = ROOT / "plugin/skills/reporting-back/SKILL.md"
def _flat() -> str:
"""Whitespace-flattened: the file is hard-wrapped, so phrases straddle lines."""
return " ".join(SKILL.read_text().split()).lower()
def test_sections_are_chosen_rather_than_completed():
"""The framing the operator reacted to was "fill its sections"."""
text = _flat()
assert "not a form to complete" in text
# Both halves of the distinction, or "choose" collapses back into "fill":
# a standing question is answered even when the answer is nothing, an
# explanation is dropped when it changes nothing.
assert "always answered, even when the answer is nothing" in text
assert "changes what the operator does or decides" in text
def test_the_reply_carries_a_length_discipline():
"""Without a ceiling, every section is an invitation to keep writing."""
text = _flat()
assert "write the shortest reply that carries the answer" in text
# And the ceiling has named exceptions, so this cannot be read as
# "always be terse" — a measurement the operator asked for still earns room.
assert "extra length has to be earned" in text
def test_the_reply_gets_a_second_pass_for_what_can_go():
"""Cutting is a separate act from writing, and needs saying separately.
A check that asks only whether anything is MISSING is one a bloated reply
passes.
"""
text = _flat()
assert "what can go" in text
# Cutting must not read as withholding, or it will not be done.
assert "cutting is not hiding" in text
def test_the_needs_you_test_sits_with_the_needs_you_section():
"""POSITIONAL. The test has to be where the section is defined.
A reader reaches this while writing that section; stated anywhere else it
is a paragraph nobody is reading at the moment it applies. Asserted by
offset rather than by presence, so moving it away fails here.
"""
raw = " ".join(SKILL.read_text().split())
lowered = raw.lower()
needs_you = lowered.index("- **needs you** — an action")
the_test = lowered.index("is this theirs to decide")
next_bullet = lowered.index("- **next** —", needs_you)
assert needs_you < the_test < next_bullet, (
"the needs-you test has moved out of the Needs you bullet; a reader "
"writing that section will not meet it"
)
# Both halves are load-bearing: "theirs" alone still admits a question the
# session could have answered, "blocking" alone admits one that is not
# theirs to make.
assert "work waiting on it" in lowered
assert "not for what you are unsure about" in lowered
def test_a_settled_decision_is_acted_on_rather_than_re_argued():
"""Re-opening a decision reads as self-contradiction, not as diligence.
Phrased as a practice rather than a prohibition: the instruction
is what to DO with a decision, with the failure named after it.
"""
text = _flat()
assert "a decision already made gets acted on" in text
assert "reads as contradicting yourself rather than as being careful" in text
# The escape hatch stays open, or this becomes a rule against ever
# correcting anything — which is the opposite of what is wanted.
assert "genuinely overturns the choice" in text
def test_the_scaffold_itself_is_untouched():
"""This step changed the discipline AROUND the sections, not the sections.
If a future edit deletes a category while tightening the prose, that is a
change to the scaffold itself and should not ride along silently here.
"""
text = _flat()
for section in ("where this sits", "what now works", "how / why",
"needs you", "next"):
assert section in text, f"completion-report section {section!r} is gone"
# The kinds live in the delivered shapes; the skill keeps the reasoning and the worked completion report.
from grimoire.services import reply_shapes
shapes = " ".join(s.title + " " + s.text for s in reply_shapes.SHAPES.values()).lower()
for kind in ("completion", "finding", "blocked", "progress",
"decision", "clarification", "handoff", "approval", "conflict"):
assert kind in shapes, f"reply kind {kind!r} is gone"