54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
import hashlib
|
|
|
|
import pytest
|
|
|
|
from tht.pi_skill_projection import (
|
|
FRAGMENT_ORDER,
|
|
PROJECTION_PATH,
|
|
projection_is_current,
|
|
render_projection,
|
|
)
|
|
|
|
|
|
BASELINE_SHA256 = "626a794071c095a4f20fffabb3bab901f05c101590adbdc58e45adfae56f3219"
|
|
|
|
|
|
def test_modular_pi_skill_renders_the_byte_identical_approved_projection():
|
|
rendered = render_projection()
|
|
|
|
assert FRAGMENT_ORDER == (
|
|
("{{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"),
|
|
("{{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"
|
|
)
|
|
)
|