- OKF export: a bare [[X]] becomes a bundle-root link when it resolves
(path, file name or title; `&`, spaces and brackets percent-encoded)
instead of degrading to plain text.
- N2 "degraded, not empty": retrieve reports DEGRADED for unread pages,
graph or exact search ("no candidates among what could be read");
lint reports Crux quotes and secret scans it could not do, and no
longer skips an unreadable file as binary in the secrets scan.
AGENTS.md rule; test_silent_reads guards new swallowed reads
(`# ok-silent: <reason>` for the deliberate ones).
- N17: case- and accent-insensitive fold in retrieve's tldr and scope
matching; lint check 20 flags page names that collide after folding.
- N7: one publish filter in both exporters drops HTML comments outside
code (unclosed to the end of the page), `--drop-section NAME` leaves out
sections, and a page whose frontmatter never closes is refused (exit 1).
- Test that an interrupted routine stays due until --mark.
- Docs: lint, retrieve and exporter skills, both manuals; goldens updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
3.1 KiB
Python
68 lines
3.1 KiB
Python
"""N17: one case- and accent-insensitive fold, kept identical where it is
|
|
copied (each skill's scripts stand alone), and lint check 20 built on it."""
|
|
import importlib.util
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import unicodedata
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
LINT = ROOT / ".agents/skills/ckb-lint/scripts/lint_report.py"
|
|
RETRIEVE = ROOT / ".agents/skills/ckb-retrieve/scripts/retrieve_candidates.py"
|
|
START = ROOT / ".agents/skills/ckb-lint/scripts/session_start.py"
|
|
|
|
|
|
def load(path):
|
|
spec = importlib.util.spec_from_file_location(path.stem, str(path))
|
|
mod = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(mod)
|
|
return mod
|
|
|
|
|
|
class Fold(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.lint, cls.retrieve, cls.start = load(LINT), load(RETRIEVE), load(START)
|
|
|
|
def test_maps_are_identical(self):
|
|
self.assertEqual(self.lint.FOLD_MAP, self.retrieve.FOLD_MAP)
|
|
self.assertEqual(self.lint.FOLD_MAP, self.start.SLUG_MAP)
|
|
|
|
def test_fold_equates_case_accents_and_composition(self):
|
|
decomposed = unicodedata.normalize("NFD", "Michał Kopeć")
|
|
for fold in (self.lint.fold, self.retrieve.fold):
|
|
self.assertEqual(fold("Michał Kopeć"), "michal kopec")
|
|
self.assertEqual(fold(decomposed), "michal kopec")
|
|
self.assertEqual(fold("ŁÓDŹ"), "lodz")
|
|
|
|
def test_lint_reports_names_that_collide_after_folding(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
kb = Path(tmp) / "kb"
|
|
shutil.copytree(str(ROOT / "tests/fixtures/minimal-kb"), str(kb))
|
|
page = "---\ntype: person\n---\n\n# X\n"
|
|
(kb / "wiki/entities/Kopeć.md").write_text(page, encoding="utf-8")
|
|
(kb / "wiki/entities/kopec.md").write_text(page, encoding="utf-8")
|
|
out = subprocess.run([sys.executable, str(LINT), "--today", "2026-11-23"], cwd=str(kb),
|
|
capture_output=True, text=True, encoding="utf-8").stdout
|
|
self.assertIn("names differ only by case or accents", out)
|
|
|
|
def test_retrieve_matches_a_title_without_its_accents(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
kb = Path(tmp) / "kb"
|
|
shutil.copytree(str(ROOT / "tests/fixtures/minimal-kb"), str(kb))
|
|
(kb / "wiki/entities/branch-a.md").write_text(
|
|
"---\ntype: place\ntldr: Łódź office opening hours\n---\n\n# Łódź office\n", encoding="utf-8")
|
|
out = subprocess.run([sys.executable, str(RETRIEVE), "lodz", "--root", str(kb),
|
|
"--no-bm25", "--today", "2026-11-23"],
|
|
capture_output=True, text=True, encoding="utf-8").stdout
|
|
# Only the folded tldr signal can find it: the query has no accent,
|
|
# the page text has no "lodz" for grep, and the file name doesn't either.
|
|
self.assertIn("wiki/entities/branch-a.md", out)
|
|
self.assertIn("tldr:", out.split("wiki/entities/branch-a.md", 1)[1].split("\n", 1)[0])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|