Skip to content

Phase 0 + Phase 1: benchmark dataset decision and core library - #1

Merged
RATCHAW merged 2 commits into
mainfrom
RATCHAW/start-roadmap-work
Jul 7, 2026
Merged

Phase 0 + Phase 1: benchmark dataset decision and core library#1
RATCHAW merged 2 commits into
mainfrom
RATCHAW/start-roadmap-work

Conversation

@RATCHAW

@RATCHAW RATCHAW commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Phase 0: benchmark dataset decision — 25 DocILE invoices + 25 CORD-v2 receipts, pinned by ID + checksum, fetched from canonical hosts (never vendored). Full decision record in docs/benchmark-dataset.md.
  • Phase 1: pnpm monorepo scaffold (TS strict, Vitest 4, tsdown, CI) and packages/core:
    • extract(): Zod schema + PDF/image → validated JSON with per-field { value, confidence, page, bbox } via a provenance wire schema; model-reported pages validated against the real PDF page count, degenerate bboxes dropped into issues.
    • streamExtract(): per-field events as wrappers complete, same validated final result.
    • Provider-agnostic (AI SDK v7 generateText + Output.object); typed failure paths (document rejection before token spend, DOCUMENT_UNREADABLE, MISSING_REQUIRED_FIELDS with partial, EXTRACTION_FAILED); repair re-prompts with usage accumulated; cost tracking with no built-in price table.
    • Transforms/defaults/catch rejected by design — they break the provenance guarantee.

Test plan

  • 53 Vitest tests against ai/test mock models covering failure paths (invalid/encrypted docs, repair loops, missing fields, unreadable docs, stream error propagation)
  • pnpm typecheck / pnpm test / pnpm build all green; CI workflow included

Mock-tested only; first live-provider validation lands with Phase 2 evals.

🤖 Generated with Claude Code

RATCHAW and others added 2 commits July 7, 2026 12:09
25 docs from each, pinned by ID + checksum, fetched from canonical hosts
(never vendored). SROIE and RVL-CDIP rejected: no field-level bbox ground
truth, so grounding accuracy — the auditability wedge — would be
unmeasurable. Full record in docs/benchmark-dataset.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pnpm monorepo scaffold (TS strict, Vitest 4, tsdown, CI) plus packages/core:

- extract(): Zod schema + PDF/image -> validated JSON where every leaf
  carries { value, confidence, page, bbox }. The user's schema is mirrored
  into a wire schema whose leaves are provenance wrappers; output is
  unwrapped, provenance-validated (page range vs real PDF page count,
  degenerate bboxes dropped into issues), then parsed against the original
  schema.
- streamExtract(): field events as each leaf's wrapper completes (confidence
  is deliberately the last wire key), plus the same validated final result.
- Provider-agnostic via AI SDK v7 (generateText + Output.object; models are
  passed in, no provider coupling). Transport retries delegated to the SDK;
  invalid output triggers repair re-prompts carrying the exact violations,
  with usage accumulated across attempts.
- Typed failure paths: document rejection before any token is spent
  (signature sniffing, media-type mismatch, encrypted/invalid PDFs),
  DOCUMENT_UNREADABLE, MISSING_REQUIRED_FIELDS (with partial extraction),
  EXTRACTION_FAILED.
- Transforms/defaults/catch are rejected by design: a transformed or
  defaulted value has no document provenance.
- 53 Vitest tests against ai/test mock models, failure paths first-class.

Mock-tested only; first live-provider validation lands with Phase 2 evals.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@RATCHAW
RATCHAW merged commit 3bbbab3 into main Jul 7, 2026
1 check passed
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