Add amendment calculus: prose-to-ops parser + verifying applier

↗ view on GitHub · Eli Ziff · 2026-07-28 · 081ad819

Legal text's native diff language, compiled both ways short of prose
generation: parseAmendmentInstructions turns US cut-and-bite and
Canadian replace-style amendment prose into typed ops addressed by
skeleton labels; applyAmendOps consolidates them deterministically and
doubles as the verifier (typed failures: target_not_found,
old_text_ambiguous, overlapping_ops - nothing silently mostly-applies).
Scoped heads (portion of/heading of) are refused, not guessed.

Measured zero-tuning against USLM gold (40 amendment-bearing public
laws, 4,349 typed amendingActions): quotedText recall 90.1%
(2,313/2,566), quotedContent onset recall 58.0%, 1,977 ops compiled,
195 refusals. Residual misses concentrate in one deeply nested tax act
and are refusals rather than misapplications; the 'substituting X for
Y' form was deliberately left out because block-interior prose would
compile false ops. Unit tests 15/15 cover both grammars, ambiguity
refusal, every-occurrence, period-at-end anchors, and scope isolation.

Prior-art vetting: legislative XML suites (Xcential LegisPro, Akoma
Ntoso change mgmt) are government-side and closed; recent generative
consolidation tops out at 61-63% correct (arXiv:2501.16794, LegiFrance)
and 50.3%/20.5% exact single/multi-step (NLLP 2025 German study) -
similarity metrics mislead, exactness is the product. Nobody ships a
contract-side deterministic applier, and none double as a rejection
sampler for small-model op translation.

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 b3b6e9e6
Stats 3 files changed , +1131
Part of Deterministic legal-text tools ("SLA audit organs")

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-081ad819.md from inside the repo you want the change in.

⬇ Download capture-commit-081ad819.md