Reference grammar kernel: one owner for what a provision reference looks like

↗ view on GitHub · Eli Ziff · 2026-07-31 · a8cdd08c

legalAmendOps and docxStructuralLint had each grown their own copy of the
reference shape; legalTextSkeleton counts references through the lint's
copy. legalReferenceGrammar now owns PROVISION_REF/FR_PROVISION_REF,
compactLabel(Fr), joinLocator and isExternalReference verbatim, and both
consumers import from it (joinLocator and isExternalReference are
re-exported from their old homes so no importer's surface moves).

Extraction is verbatim; behaviour is DEMONSTRATED unchanged, not assumed -
digest differential HEAD vs this commit, all identical:
  - 16 EN+FR amending acts (legal-generalization-corpus): full AmendOp
    object digests + target/newLabel/afterChild labels
  - 69 LegalBench-RAG mini documents: skeleton node labels+spans,
    crossReferences summary, defined terms
  - 400 real DOCX: full lint findings+notes digests (18,384 references,
    5,090 resolved, 1,732 external, 317 docs with findings)
59 existing tests pass, tsc --noEmit clean.

New on top of the move: findProvisionReferences, a FREE-TEXT detector the
anchored dialect cannot be (measured on the mini corpus: PROVISION_REF
fires on 9,989 maud spans, 2,035 of them a bare provision word with no
label; 69% bare on contractnli). It requires a non-empty label and adds
roman container numbering - "Article VIII" occurs 612x in maud, 7.7% of
that source's literal references, against 5 "Section <roman>" spans
corpus-wide. Known deliberate misses, each with its number, are in the
module header.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H9ToHYJVDxfeJcJwdzrP2H
Repository eliziff/Beaver
Author Eli Ziff <eliasziff@gmail.com>
Authored
Parents a40f46ee
Stats 4 files changed , +399 , -44
Part of SourceDoc / DOCX engine: redlines, tracked changes, editing benchmark

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-a8cdd08c.md from inside the repo you want the change in.

⬇ Download capture-commit-a8cdd08c.md