bd416f73 hand-edited SKILL.md; port the same Language contract change to
projection.md.tmpl so the rendered projection is byte-identical again, and
update the approved baseline hash. The Postgres language-authority test
predated question detection: give the legacy manifest a too-short question
so it still proves the workspace fallback is pinned once and never re-read.
Also fix ruff E701 in test_administration.py.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
2.2 KiB
Python
56 lines
2.2 KiB
Python
import hashlib
|
|
|
|
import pytest
|
|
|
|
from tht.pi_skill_projection import (
|
|
FRAGMENT_ORDER,
|
|
PROJECTION_PATH,
|
|
projection_is_current,
|
|
render_projection,
|
|
)
|
|
|
|
# Approved session-language contract (#35) with question-language detection; unrelated workflow fragments stay byte-identical.
|
|
BASELINE_SHA256 = "ffa660b15defe89290f4a6f7de1b8372fb71e25935b0eef22a4575b5d97d2603"
|
|
|
|
|
|
def test_modular_pi_skill_renders_the_byte_identical_approved_projection():
|
|
rendered = render_projection()
|
|
|
|
assert FRAGMENT_ORDER == (
|
|
("{{EVIDENCE_RUNTIME_SEARCH}}", "evidence/runtime-search.md"),
|
|
("{{DISAMBIGUATION_OPEN_AMBIGUITY}}", "disambiguation/open-ambiguity.md"),
|
|
("{{DISAMBIGUATION_INSTRUCTIONS}}", "disambiguation/phase-1.md"),
|
|
("{{MEMORY_INSTRUCTIONS}}", "memory/phase-2.md"),
|
|
("{{DISAMBIGUATION_REWRITING_INSTRUCTIONS}}", "disambiguation/phase-3.md"),
|
|
("{{MEMORY_SOLVED_SEARCH_F4}}", "memory/solved-search-f4.md"),
|
|
("{{DISAMBIGUATION_SCHEMA_GROUNDING}}", "disambiguation/schema-grounding.md"),
|
|
("{{EVIDENCE_FORMULA_PROPOSALS}}", "evidence/formula-proposals.md"),
|
|
("{{MEMORY_SOLVED_SEARCH_F6}}", "memory/solved-search-f6.md"),
|
|
("{{MEMORY_SOLVED_SEARCH_F7}}", "memory/solved-search-f7.md"),
|
|
("{{MEMORY_PROMOTION_F8}}", "memory/phase-8-promotion.md"),
|
|
("{{MEMORY_SOLVED_FINALIZATION}}", "memory/solved-finalization.md"),
|
|
)
|
|
assert rendered == render_projection()
|
|
assert hashlib.sha256(rendered).hexdigest() == BASELINE_SHA256
|
|
assert PROJECTION_PATH.read_bytes() == rendered
|
|
|
|
|
|
def test_projection_check_detects_stale_output(tmp_path):
|
|
stale = tmp_path / "SKILL.md"
|
|
stale.write_bytes(b"stale\n")
|
|
|
|
assert projection_is_current(stale) is False
|
|
|
|
|
|
def test_projection_rejects_a_missing_or_repeated_static_placeholder():
|
|
with pytest.raises(ValueError, match="exactly once"):
|
|
render_projection(template=b"{{MEMORY_INSTRUCTIONS}}\n")
|
|
with pytest.raises(ValueError, match="exactly once"):
|
|
render_projection(
|
|
template=(
|
|
b"{{DISAMBIGUATION_INSTRUCTIONS}}\n"
|
|
b"{{MEMORY_INSTRUCTIONS}}\n"
|
|
b"{{MEMORY_INSTRUCTIONS}}\n"
|
|
)
|
|
)
|