Fixes F20-F24 from the 2.0.0 script review: zero-indent routine lists, escaped --do values, --remove continuation lines; <private> redaction across content blocks; OKF scalar quoting and code-fence titles; Unicode tokens in retrieve and consolidate; bad workload dates, frontmatter at EOF, `wiki/` refs without a slash, Starlight route collisions, labelled wikilinks, string source_files, real splash sections, <private> dropped from both exports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.9 KiB
Python
47 lines
1.9 KiB
Python
"""Retrieval must work for a KB written in Polish as well as English."""
|
|
import importlib.util
|
|
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"
|
|
RETRIEVE = ROOT / ".agents/skills/ckb-retrieve/scripts/retrieve_candidates.py"
|
|
|
|
|
|
def load(path, name):
|
|
spec = importlib.util.spec_from_file_location(name, str(path))
|
|
mod = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(mod)
|
|
return mod
|
|
|
|
|
|
class Unicode(unittest.TestCase):
|
|
def test_tokens_keep_polish_words_whole(self):
|
|
r = load(RETRIEVE, "retrieve_candidates")
|
|
self.assertIn("właścicielem", r.tokens("Kto jest właścicielem budżetu?"))
|
|
self.assertIn("budżetu", r.tokens("Kto jest właścicielem budżetu?"))
|
|
c = load(ROOT / ".agents/skills/ckb-consolidate/scripts/consolidate.py", "consolidate")
|
|
self.assertIn("łódź", c.words("Łódź i okolice"))
|
|
|
|
def test_polish_query_ranks_the_polish_page_first(self):
|
|
with tempfile.TemporaryDirectory() as d:
|
|
kb = Path(d) / "kb"
|
|
shutil.copytree(str(FIX), str(kb))
|
|
(kb / "wiki/entities/budzet.md").write_text(
|
|
"---\ntype: concept\ntldr: Właścicielem budżetu marketingowego jest Zofia Wróbel.\n---\n\n"
|
|
"# Budżet marketingowy\n\nWłaścicielem budżetu jest Zofia.\n", encoding="utf-8")
|
|
r = subprocess.run([sys.executable, str(RETRIEVE), "kto jest właścicielem budżetu", "--root", str(kb),
|
|
"--json", "--today", "2026-11-11", "--no-bm25"],
|
|
capture_output=True, text=True, encoding="utf-8")
|
|
self.assertEqual(r.returncode, 0, r.stderr)
|
|
top = json.loads(r.stdout)["candidates"][0]["path"]
|
|
self.assertEqual(top, "wiki/entities/budzet.md")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|