Skip to content

Bring phase 2 into main (PR #2 landed on phase-1-foundation) - #3

Merged
OnePieceMonkey merged 12 commits into
mainfrom
phase-1-foundation
Oct 2, 2026
Merged

OnePieceMonkey merged 12 commits into
mainfrom
phase-1-foundation

Conversation

@OnePieceMonkey

Copy link
Copy Markdown
Owner

PR #2 was merged into phase-1-foundation seconds after #1 merged into main, before GitHub retargeted it. This PR brings those commits (phase 2 corpus, harness and the Nemotron agent loop) into main. No new changes.

🤖 Generated with Claude Code

OnePieceMonkey and others added 12 commits October 2, 2026 20:38
…ation

zod model for the MVP subset of EN 16931 with decimal strings only. deriveAmounts computes BT-131, the VAT breakdown (BG-23) and all totals (BG-22) with decimal.js and half-up rounding; category O reports rate 0 as XRechnung BR-DE-14 requires.

Refs: CORE-01, EXT-01

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
readCii turns test suite XML into ground truth (MVP subset, keeps #SKONTO# line breaks). buildCii writes schema-ordered CII from model + derived amounts, byte-identical for the same input.

Refs: CORE-02

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uite

19 in-scope suite invoices (380, EUR, no allowances/prepaid/rounding, credit transfer). Derived totals match the printed ones (VAT ±0.01 per BR-CO-17); model -> CII -> verifier is ACCEPTABLE for 19/19. CI fetches the suite before tests and runs roundtrip:check.

Refs: CORE-01, CORE-02

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Units (2162 Rec 20/21 codes plus German words), countries, VAT categories, currency, dates and decimals. Code lists generated from the pinned KoSIT configuration. Unknown or ambiguous values fail with a reason instead of being guessed; a bare 0 % never becomes a category.

Refs: EXT-04

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A value is kept only if its quote occurs on the cited page of the text layer (whitespace/case/dash tolerant, no fuzzy matching) and the printed value occurs inside the quote.

Refs: EXT-03

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pdfkit with standard fonts, uncompressed and with a content-derived trailer ID so rebuilds are byte-identical across Node versions. Layouts classic, modern, compact; noise options for number/date format, label wording, block order, small font and page splits. Fields absent from the model are not printed. extractPageTexts reads the text layer with pdfjs-dist.

Refs: EVAL-01, EVAL-02

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Placeholders of the test suite are replaced by fictional values. Sets: clean (3 layouts), noisy (2 variants), mutated (13 mutation types, each verified against the verifier), holdout 4 invoices chosen by hash and locked until phase 5. pnpm eval writes JSON and Markdown reports with validity, field accuracy per BT, invented fields, provenance, iterations, cost and runtime. Finding: unit 'Stück' yields BR-CL-23 but the verifier still answers ACCEPTABLE.

Refs: EVAL-01, EVAL-03, EVAL-04, EVAL-05, EVAL-06

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nemotron extraction with constrained JSON and one retry; assembly with evidence check and normalization; repair plans from Nemotron Ultra filtered by the patch guard; agent loop with at most 3 rounds that stops when issues stop decreasing; consistency warnings for printed totals; JSONL audit chain (RFC 8785 + SHA-256) and pnpm audit:verify.

Refs: EXT-01, EXT-02, EXT-05, CORE-03, REP-01, REP-02, REP-03, REP-04, AUD-01, AUD-02, AUD-03, OPS-04

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ent loop

A line whose quantity x price differs from its printed amount triggers repair and otherwise NEEDS_INPUT, never a valid output. Shape checks reject role mix-ups the validator accepts (postcode as city, 'postcode city' as street, non-e-mails). One value+quote may not back fields of different kinds, and a German city must follow its postcode. Lines use one row quote instead of per-field quotes (long invoices were truncated). Tests cover NEEDS_INPUT, user input with provenance 'user' and the line-mismatch stop.

Refs: EXT-02, EXT-03, EXT-05, REP-02, REP-04, CORE-03

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…evel errors

pnpm eval --pipeline agent runs extraction, repair, verifier and audit per document. Reports add the kill-gate count (valid, BT-112/BT-115 correct, full provenance), invented and wrong fields per document, missing fields and open issues. Corpus hygiene: placeholder invoice numbers, '-' and 'nicht vorhanden' contacts, and long line IDs replaced.

Refs: EVAL-04, CORE-01

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clean 41/45 (91 %) valid with correct totals and full provenance, noisy 23/30, mutated 25/26 as expected. Findings, test-data hygiene and backlog items recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Phase 2 + core loop: corpus, harness, Nemotron agent loop (kill gate met)
@OnePieceMonkey
OnePieceMonkey merged commit a581442 into main Oct 2, 2026
3 checks passed
@OnePieceMonkey
OnePieceMonkey deleted the phase-1-foundation branch October 7, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant