Phase 0 + Phase 1: benchmark dataset decision and core library - #1
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docs/benchmark-dataset.md.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.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.Test plan
ai/testmock models covering failure paths (invalid/encrypted docs, repair loops, missing fields, unreadable docs, stream error propagation)pnpm typecheck/pnpm test/pnpm buildall green; CI workflow includedMock-tested only; first live-provider validation lands with Phase 2 evals.
🤖 Generated with Claude Code