Skeleton-first context: compile legal structure into the SourceDoc plane

↗ view on GitHub · Eli Ziff · 2026-07-28 · f5b74d72

legalTextSkeleton.ts parses the native numbering of agreements and
statutes - ARTICLE/PART/DIVISION containers, Section N.NN and statute
"8. (1)" forms, (a)/(i)/(A)/(1) enumeration ladders, Schedules and
Exhibits - into SourceDoc blocks, so local Library documents share the
lookup/slice/quote plane that legislation and case law already use.
The ladder resolver is a TS port of Text-Fidelity's counter-stack
parse (parse_heading_ladder): strict increments across all readings
before level opens, so (h)->(i) disambiguation emerges from pass
order; forward jumps and mid-counter opens are tolerated as gaps;
restarts get @n occurrence suffixes; backward values are recorded
violations. Defined terms reuse docxStructuralLint's collector (now
exported, with romanToInt and isExternalReference).

Tool surface: library_outline returns the complete structural map
with lookup handles (real 141k-char credit agreement: 310 nodes,
~7.2k-token outline, 82 defined terms, Section 8.01 enumerated
(a)-(n) with nested (e)(ii)(A)-(D)); library_read gains a section
locator for span-scoped reads ("8.01", "Article VIII", "s. 8(2)",
"Schedule 7.01"). Compile cost: ~25ms. 15 unit tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018bhP89cYSdEEjHNPnxacns
Repository eliziff/Beaver
Author Eli Ziff <eliasziff@gmail.com>
Authored
Parents baefea84
Stats 4 files changed , +996 , -3
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-f5b74d72.md from inside the repo you want the change in.

⬇ Download capture-commit-f5b74d72.md