#!/usr/bin/env python3
"""Verify knowledge and skill persistence requirements are documented."""

from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
DOC = ROOT / "Docs" / "KnowledgeAndSkillFoundation.md"
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"

REQUIRED = {
    DOC: [
        "## Knowledge Persistence Requirements",
        "Stable knowledge profile ID",
        "Learned concepts by stable concept ID.",
        "Practical skill experience by taxonomy domain.",
        "Failed attempts that produced useful feedback",
        "Tutorial and contextual prompt state",
        "Optional knowledge checks answered, skipped, failed, or recently displayed.",
        "Teaching, observation, and shared-work learning events",
        "Schema version, migration marker",
        "The server is authoritative for writes in multiplayer.",
        "Persistence rule:",
    ],
    ROADMAP: [
        "[x] Add persistence requirements for knowledge, skill experience, learned concepts, failed attempts, and tutorial state.",
    ],
}


def main() -> None:
    missing: list[str] = []
    for path, snippets in REQUIRED.items():
        text = path.read_text(encoding="utf-8")
        for snippet in snippets:
            if snippet not in text:
                missing.append(f"{path.relative_to(ROOT)} missing {snippet!r}")
    if missing:
        raise SystemExit("FAILED: " + "; ".join(missing))
    print("OK: knowledge persistence requirements are documented.")


if __name__ == "__main__":
    main()
