<feed xmlns='http://www.w3.org/2005/Atom'>
<title>colitur.git/tools/test_check_citations.py, branch v0.10.1</title>
<subtitle>deterministic OCaml engine to compute and validate liturgical calendars for multiple rites, template-driven output to year 9999</subtitle>
<id>https://git.labunix.xyz/colitur.git/atom?h=v0.10.1</id>
<link rel='self' href='https://git.labunix.xyz/colitur.git/atom?h=v0.10.1'/>
<link rel='alternate' type='text/html' href='https://git.labunix.xyz/colitur.git/'/>
<updated>2026-08-19T13:47:37Z</updated>
<entry>
<title>fix(tools): close five more ways to defeat check_citations.py</title>
<updated>2026-08-19T13:47:37Z</updated>
<author>
<name>Lukasz Kasprzak</name>
<email>lukas@labunix.xyz</email>
</author>
<published>2026-08-19T13:47:37Z</published>
<link rel='alternate' type='text/html' href='https://git.labunix.xyz/colitur.git/commit/?id=174fe8b3fedf61cf1fa0dc7499573374133a8ca2'/>
<id>urn:sha1:174fe8b3fedf61cf1fa0dc7499573374133a8ca2</id>
<content type='text'>
Round 1 hardened check_citations.py against its own self-poisoning bug;
a review defeated it again. Five fixes, in the order they were found:

1. PATTERN silenced a whole comment block, not just the entry it was
   attached to -- a wrong citation on a DIFFERENT, unmarked entry in the
   same block (e.g. [season]'s own back-to-back trailing-comment style)
   was never checked at all. Fixed by scoping PATTERN with the identical
   leading/trailing pooling rule citations already use: an entry is
   excluded only by its own marker, never a neighbour's.

2. Explicit per-citation ranges (introduced in round 1 to replace a
   blanket +-2-line tolerance) had no upper bound, reintroducing the same
   defect at a much larger radius (LT.txt:8600-8650 passed if the text
   appeared anywhere in fifty lines). Capped at MAX_RANGE_WIDTH (3 lines);
   anything wider is reported MALFORMED, naming the entry and the width,
   instead of silently accepted.

3. The "pool too thin to verify" gate counted words, not rarity -- it
   flagged 11 genuinely correct citations (short Latin hagionyms with only
   one non-stopword) CANNOT VERIFY, while a match on nothing but "classis"
   (507 occurrences) passed freely alongside three siblings. Replaced with
   a frequency table over the whole LT.txt corpus: a token's evidence is
   1/(times seen), an item's evidence is its single rarest matched token
   (not a sum -- summing would let several merely-common words add up to
   "enough" between them, the same shape as the self-poisoning bug).

4. "LT.txt:12,459" (a comma typo for one number) parsed as two unrelated
   bare citations, 12 and 459, either of which could coincidentally match
   while the intended line was never checked. Detected as a
   thousands-separator-typo shape (a 1-2 digit token immediately followed
   by an exactly-3-digit one -- the only way a real LT.txt line number,
   which never exceeds 5 digits, splits under one comma) and rejected as
   malformed.

5. The self-test suite overstated its own coverage: of round 1's seven
   fixture cases, only two actually failed against the pre-round-1 script.
   Every test is now labelled REGRESSION or CHARACTERISATION, each
   verified by direct replay against the named prior version rather than
   asserted -- 14 of 33 are genuine regression tests.

Both of the review's own defeats (block-wide PATTERN silencing, the
50-line range) are reproduced as dedicated fixtures and confirmed caught;
both are also confirmed to slip through the pre-round-2 tool unchanged.

Claude-Session: https://claude.ai/code/session_017ZBxCCRM2ojnBupp3SBxV9
</content>
</entry>
<entry>
<title>fix(tools): harden check_citations.py against its own self-poisoning bug</title>
<updated>2026-08-19T13:01:18Z</updated>
<author>
<name>Lukasz Kasprzak</name>
<email>lukas@labunix.xyz</email>
</author>
<published>2026-08-19T13:01:18Z</published>
<link rel='alternate' type='text/html' href='https://git.labunix.xyz/colitur.git/commit/?id=7f263a0ec9a91d1a036cfd22ed38354d06500b1d'/>
<id>urn:sha1:7f263a0ec9a91d1a036cfd22ed38354d06500b1d</id>
<content type='text'>
Reproduced the defect: reintroducing the exact historical citation bug
(pointing class-1's citation back at LT.txt:12459, the value a prior
fix round corrected away from) made the tool report "147 citations
checked, 0 look wrong". The mechanism was that the corrective comment
documenting the old bug quotes the wrong historical value, and the
checker pooled every quoted phrase from the whole surrounding comment
block, so citing the wrong line matched the comment explaining why it
was wrong.

Four changes:

1. The word pool for a citation is now scoped to the entry(ies) it is
   attached to only -- never to quoted text elsewhere in the comment.
   This is the direct fix for the self-poisoning bug.
2. A citation whose pool has fewer than two distinctive words (Latin
   liturgical headings are short and stopword-heavy) cannot
   discriminate the right line from a wrong nearby one. Such a
   citation is now reported CANNOT VERIFY and fails the target,
   instead of silently passing.
3. The blanket +-2-line tolerance is gone. A bare "LT.txt:N" is
   checked at line N only; a heading that genuinely wraps must say so
   explicitly as "LT.txt:N-M". The allowance moves into the data,
   where it is visible.
4. The tool gets its own test suite, tools/test_check_citations.py,
   with a synthetic fixture covering: a correct citation, off-by-one
   and off-by-three mismatches, an explicit wrap range, a degenerate
   pool, a PATTERN-marked entry with no citation, and a dedicated
   regression test for the self-poisoning case itself. Wired into
   `dune test` via a new (rule (alias runtest) ...) in tools/dune (a
   plain (test ...) stanza cannot run a Python script), so it runs
   with the rest of the suite, not only as a `make` target.

Added a --file/--lt-file override to check_citations.py so the tool
(and its own tests) can point at a fixture without touching the real
lang/la.ini or docs/research/LT.txt. Confirmed the "SKIPPED, exit 0"
behaviour for a missing docs/research/LT.txt is unchanged.

tools/__pycache__/ (a stray artefact of this script, previously
untracked and ungitignored) is now in .gitignore.

Measured against the current lang/la.ini (another task is still
landing its sanctoral entries on this branch): 15 of 275 citations now
look wrong and 42 more cannot be verified, both far above the 0 the
unhardened tool reported. Not fixed here -- the data pass is separate,
once the sanctoral entries land.
</content>
</entry>
</feed>
