"""Check 13: a Crux quoted from a conversation is complete without Sources (AGENTS.md §2); one quoted from a local file still needs its fingerprint.""" import json import shutil import subprocess import sys import tempfile import unittest from pathlib import Path ROOT = Path(__file__).resolve().parents[2] FIX = ROOT / "tests/fixtures/minimal-kb" LINT = ROOT / ".agents/skills/ckb-lint/scripts/lint_report.py" PAGE = "---\ntype: decision\ntldr: x\nstatus: accepted\ndecided_on: 2026-11-11\ndecided_by: A\n---\n\n# D\n\n## Crux\n\n{quote}\n" class CruxWithoutSources(unittest.TestCase): def crux_findings(self, quote): with tempfile.TemporaryDirectory() as d: kb = Path(d) / "kb" shutil.copytree(str(FIX), str(kb)) (kb / "wiki/decisions").mkdir(exist_ok=True) (kb / "wiki/decisions/0099-x.md").write_text(PAGE.format(quote=quote), encoding="utf-8") r = subprocess.run([sys.executable, str(LINT), "--json", "--today", "2026-11-11"], cwd=str(kb), capture_output=True, text=True, encoding="utf-8") data = json.loads(r.stdout) return [f for t in data["trees"] for f in t.get("crux", []) if "0099-x" in f] def test_chat_attributed_crux_needs_no_sources(self): self.assertEqual(self.crux_findings("> We decided this today, plainly.\n— Chat conversation, A, 2026-11-11"), []) def test_file_attributed_crux_still_needs_sources(self): found = self.crux_findings("> Some quoted line from the notes file.\n— `raw/archive/notes.md`, under \"X\"") self.assertTrue(any("Sources" in f for f in found), found) if __name__ == "__main__": unittest.main()