"""Tests for the deployed-wiki rules in the llm-wiki template (SPEC 3.3). Generated by AI/LLM: 2026-09-30 - the template is self-contained and tells a deployed wiki to commit after ingest and housekeeping. """ from __future__ import annotations import pathlib import re import pytest from fiona.paths import llm_wiki_template TEMPLATE = llm_wiki_template() AGENTS = TEMPLATE / "AGENTS.md" SKILL = TEMPLATE / "utils" / "skills" / "fiona" / "SKILL.md" LOG = TEMPLATE / "wiki" / "log.md" def _body(path: pathlib.Path) -> str: """Return the markdown text after the frontmatter block. Generated by AI/LLM: 2026-09-30 - drop frontmatter before content checks. """ text = path.read_text(encoding="utf-8") return text.split("---", 2)[2] if text.startswith("---") else text @pytest.mark.parametrize("path", sorted(TEMPLATE.rglob("*.md")), ids=str) @pytest.mark.parametrize("needle", ["SPEC", "project agent rule", "scripts/run_"]) def test_template_markdown_has_no_outside_reference(path: pathlib.Path, needle: str) -> None: """SPEC 3.3.1: template markdown never cites files outside the template. Generated by AI/LLM: 2026-09-30 - a deployed wiki only has the template. """ assert needle not in path.read_text(encoding="utf-8") @pytest.mark.parametrize("link", ["./utils/skills/fiona/SKILL.md", "./utils/skills/fiona/llm-wiki-mod.md"]) def test_agents_links_skill_and_concept(link: str) -> None: """SPEC 3.3.2: the entry point links the Fiona skill and llm-wiki-mod. Generated by AI/LLM: 2026-09-30 - AGENTS.md is the wiki entry point. """ assert f"]({link})" in AGENTS.read_text(encoding="utf-8") @pytest.mark.parametrize("path", [AGENTS, SKILL], ids=["AGENTS", "SKILL"]) def test_deployed_wiki_commits_after_ingest(path: pathlib.Path) -> None: """SPEC 3.3.3: save after ingest and housekeeping, not only when asked. Generated by AI/LLM: 2026-09-30 - commits are the wiki's history. """ text = " ".join(path.read_text(encoding="utf-8").split()) assert "git save" in text assert not re.search(r"(commit|Run them)[^.]*only when the user asked", text) assert "Do not commit" not in text def test_seed_log_has_one_entry() -> None: """SPEC 3.3.4: a new wiki's log starts with one seed bullet. Generated by AI/LLM: 2026-09-30 - no product history in a new wiki. """ bullets = [line for line in _body(LOG).splitlines() if line.startswith("- ")] assert bullets == ["- DATE_PLACEHOLDER - Initialized the llm-wiki."]