Commit graph

22 commits

Author SHA1 Message Date
jedarden
7fed5a0a6f docs(pdftract-5l9m): add CI validation script and verification note
Add CI validation script for checking unauthorized expose_secret() call
sites. The script validates that all uses of expose_secret() are in
approved locations (SecretFingerprint and test code).

Also add verification note summarizing the bead completion status.

Per pdftract-5l9m acceptance criteria:
- CI grep guard rejects unauthorized expose_secret() call sites
- Verification documents existing SecretString wrapping status

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-05-18 01:05:33 -04:00
jedarden
6aabfa0c96 feat(pdftract-q15sh): implement v1 fingerprint algorithm
Implement Merkle SHA-256 fingerprint algorithm for PDF structural
fingerprinting as specified in Phase 1.7 of the plan.

Components:
- FingerprintInput struct with page data and catalog flags
- Per-page hashing: content streams (normalized), resources (sorted),
  geometry (4dp banker's rounding)
- Structure tree hash for tagged PDFs
- Catalog feature flag byte (encryption, JS, XFA, OCG)

Acceptance criteria:
- INV-3: 100% reproducible fingerprints (test passes)
- INV-13: Output format ^pdftract-v1:[0-9a-f]{64}$ (test passes)
- Performance: 100-page PDF in < 1ms (test passes)
- KU-7: WARN - no linearized fixtures available

Closes pdftract-q15sh

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 01:02:30 -04:00
jedarden
a34f9c18d0 docs(pdftract-1g87): create mdBook scaffolding for user documentation
- book.toml with title, authors, build directory, edit-url-template
- src/SUMMARY.md with complete TOC for all planned sections
- src/introduction.md: what pdftract does and doesn't do (Non-Goals)
- src/installation.md: cargo, pip, Homebrew, Docker; KU-12 caveat verbatim
- src/quickstart.md: five-minute walkthrough with executable commands
- 39 draft placeholder files for CLI reference, schema, profiles, SDKs, advanced topics, troubleshooting, FAQ

mdbook build completes cleanly with zero warnings (linkcheck optional).

See notes/pdftract-1g87.md for verification details.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 00:38:51 -04:00
jedarden
f76f3a647b test(pdftract-5tmcg): add cycle detection test for page tree flattener
Add test_cycle_detection_in_page_tree to verify that circular references
in the /Pages tree are detected and handled gracefully without panicking.
The test creates a page tree with a cycle (parent -> child1 -> child2 -> child1)
and verifies that the flattener returns the valid pages while pruning the
cyclic portion.

Acceptance criteria verified:
- 3-level /Pages inheritance with MediaBox: PASS
- EC-09 missing MediaBox defaults to US Letter: PASS
- /Pages tree with cycles detected: PASS
- /Rotate value 45 clamped to 0: PASS
- Page count validation: PASS
- proptest random shapes never panic: PASS
- INV-8 no panics on invalid input: PASS

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Bead-Id: pdftract-5tmcg
Bead-Id: pdftract-4iier
2026-05-18 00:38:44 -04:00
jedarden
b1317457e7 feat(pdftract-3nnqy): implement StreamDecoder trait, filter pipeline, and bomb limit
- StreamDecoder trait with decode() method for filter-specific decoding
- Per-filter implementations: FlateDecoder, ASCII85Decoder, ASCIIHexDecoder, PassthroughDecoder
- decode_stream() function with single and array filter handling
- Filter abbreviation normalization (/A85 -> ASCII85Decode, /Fl -> FlateDecode)
- ExtractionOptions with max_decompress_bytes (default 2 GB)
- Document-level decompression counter with chunked bomb limit checking
- Unknown filter returns raw bytes with STRUCT_UNKNOWN_FILTER diagnostic
- All 183 tests pass

Acceptance criteria:
- decode_stream() handles single-filter and array-filter cases: PASS
- /DecodeParms array correctly paired with /Filter array: PASS
- Critical test [/ASCII85Decode /FlateDecode] applies filters in order: PASS
- Filter abbreviations normalized: PASS
- 2 GB bomb limit with STREAM_BOMB diagnostic: PASS
- Unknown filter passthrough with STRUCT_UNKNOWN_FILTER: PASS
- INV-8 maintained (no panics, partial bytes on error): PASS

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-05-18 00:34:28 -04:00
jedarden
6a142369b9 docs(pdftract-4iier): complete per-profile README documentation
Complete per-profile README documentation for all 9 built-in profiles.
Each README follows the consistent 6-section structure with match criteria,
extracted fields, known limitations, sample input pointers, and configuration tips.

Fix: receipt README date field type (string → date to match YAML).

Files updated:
- profiles/builtin/invoice/README.md
- profiles/builtin/receipt/README.md
- profiles/builtin/contract/README.md
- profiles/builtin/scientific_paper/README.md
- profiles/builtin/slide_deck/README.md
- profiles/builtin/form/README.md
- profiles/builtin/bank_statement/README.md
- profiles/builtin/legal_filing/README.md
- profiles/builtin/book_chapter/README.md
- notes/pdftract-4iier.md

Acceptance criteria:
- All 9 README files exist at correct paths
- All follow consistent 6-section structure
- All Extracted Fields tables match YAML profile_fields
- All Known Limitations sections are non-empty and profile-specific
- All Sample Input pointers reference existing fixtures
- xtask doc-profile skeleton generator is implemented

Co-Authored-By: Claude Code (glm-4.7) <noreply@anthropic.com>
2026-05-18 00:32:06 -04:00
jedarden
cedc9a86af fix(pdftract-1yad): enable proptest tests and update verification note
- Remove incorrect #[cfg(feature = "proptest")] since proptest is not behind a feature
- Update verification note to reflect 30 passing tests (includes 2 proptest tests)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 00:15:00 -04:00
jedarden
e0b8044797 feat(pdftract-1bn): implement cross-compilation build matrix for 5 target triples
Implement the per-target build steps inside pdftract-ci for all five
release target triples. Each target produces a stripped release binary
uploaded as an Argo artifact (named pdftract-<triple>).

Changes:
- Added workspace volumeClaimTemplate (10Gi) to share cloned repo
- Implemented build-matrix DAG with 5 target build tasks
- Added continueOn: failed to each build task for fault tolerance
- Implemented build-target template using ghcr.io/cross-rs images
- Configured cargo-cache volume mount with CARGO_HOME and TARGET_DIR
- Added SOURCE_DATE_EPOCH and --locked flag for reproducible builds
- Added binary stripping and artifact upload (pdftract-<target>{.exe})

Targets:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-gnu

Acceptance criteria:
- PASS: All five build steps in build-matrix DAG
- PASS: Binaries upload as artifacts with correct pattern
- WARN: Build time <= 8 min (cannot verify without running pipeline)
- WARN: Stripped binary <= 4 MB (cannot verify without running pipeline)
- PASS: Failure isolation with continueOn: failed

Verification note: notes/pdftract-1bn.md

Refs: pdftract-1bn, Phase 0 lines 1001-1009, ADR-009
2026-05-18 00:06:55 -04:00
jedarden
b15754b586 feat(pdftract-1bn): add cross-compilation build matrix WorkflowTemplate
Implement the build-matrix DAG template in pdftract-ci WorkflowTemplate
with cross-compilation for all five release target triples using
ghcr.io/cross-rs Docker images.

Targets:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-gnu

Each target:
- Builds in parallel via DAG task with continueOn.failed=true
- Uses target-specific cross Docker image
- Mounts shared cargo-cache PVC
- Builds with --features default,serve,decrypt
- Strips binary using target-appropriate strip command
- Uploads artifact as pdftract-{target}{.exe}

Acceptance criteria:
- PASS: All five build steps in build-matrix DAG
- PASS: All five binaries upload as artifacts
- PASS: Failure isolation with continueOn
- WARN: Build time <= 8 min (runtime verification required)
- WARN: Binary size <= 4 MB (runtime verification required)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 23:59:00 -04:00
jedarden
69366da537 docs(pdftract-2bsfc): add verification note 2026-05-17 23:57:00 -04:00
jedarden
844e796af4 docs(pdftract-1bn): add verification note for cross-compilation build matrix
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-05-17 23:54:51 -04:00
jedarden
b535638104 feat(pdftract-2bsfc): implement document catalog parser with PageLabels number tree
Implement the document catalog parser (/Root traversal) for PDF documents.
The catalog parser extracts all key entries from the document catalog
including Pages, Outlines, MarkInfo, StructTreeRoot, AcroForm, Names,
Metadata, PageLabels, OCProperties, OpenAction, AA, and Version.

Key structures:
- MarkInfo: parses /MarkInfo dictionary with is_tagged, user_properties, suspects
- PageLabelStyle: enum for all label styles (D, R, r, A, a)
- PageLabel: single page label with style, prefix, and start value
- PageLabelsTree: number tree parser for /PageLabels with /Nums and /Kids support
- OcProperties: stub for OCG implementation (delegated to dedicated bead)
- Catalog: main catalog struct with all required and optional fields

Number tree implementation:
- Parses /Nums arrays (leaf nodes with alternating key-value pairs)
- Supports /Kids arrays (internal nodes for recursive tree traversal)
- Provides get_label_with_start() and get_label() methods for lookup
- Correctly formats roman numerals (uppercase/lowercase) and letter sequences

All 27 tests pass including proptests for fuzzing robustness (INV-8).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 23:45:45 -04:00
jedarden
3af009440e fix(pdftract-5z5d8): fix provenance validation script
Fixed scripts/check-provenance.sh to properly validate PROVENANCE.md
against actual fixture files. The script was failing silently due to
subshell EXIT trap removing temp files before parent could read them,
and arithmetic expansion returning exit code 1 on zero value.

Changes:
- Replaced subshell pipes with process substitution
- Moved temp file cleanup to after reading
- Added validated variable initialization
- Added || true to prevent exit on zero arithmetic

All 200 classifier corpus fixtures have valid provenance entries
with matching SHA256 hashes. PROVENANCE.md already existed with
complete documentation.

Refs: pdftract-5z5d8
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-05-17 23:43:37 -04:00
jedarden
88278c362f feat(pdftract-4hn1): use Cow<'static, str> for diagnostic messages
Changed Diagnostic::msg from String to Cow<'static, str> to avoid
allocations for static error messages. Static messages now use
Cow::Borrowed, while dynamic formatted messages use Cow::Owned.

Also fixed peek_token lifetime issue - was returning reference to
local variable, now returns reference from cache.

Acceptance criteria:
- Token enum with all required variants
- Lexer struct with position tracking and diagnostics
- Diagnostic uses Cow<'static, str> for zero-allocation static messages
- All public methods implemented: new, next_token, peek_token, position, take_diagnostics
- All internal helpers implemented

Refs: pdftract-4hn1

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Bead-Id: pdftract-4hn1
2026-05-17 23:23:38 -04:00
jedarden
8b5dd4febb docs(pdftract-4iier): add per-profile README documentation for all 9 built-in profiles
This commit creates user-facing documentation for each built-in profile:

- Profile YAML files defining match criteria, priority, and extracted fields
- Per-profile READMEs with match criteria summary, extracted fields table,
  known limitations, sample input pointers, and configuration tips
- xtask skeleton generator for automated README generation

Profiles documented:
- invoice: Commercial invoices with line items, vendor/customer, totals
- receipt: POS receipts with items, payment method
- contract: Legal contracts with parties, effective date, term, signatures
- scientific_paper: Academic papers with title, authors, abstract, DOI, references
- slide_deck: Presentation slides with title, presenter, date, slide titles
- form: Fillable forms (degenerate case: uses Phase 7.4 form_fields)
- bank_statement: Bank statements with account info, period, balances, transactions
- legal_filing: Court filings with case number, court, parties, filing date, docket
- book_chapter: Book chapters with title, chapter number, author, section headings

Closes: pdftract-4iier
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 23:19:00 -04:00
jedarden
5e66846288 docs(pdftract-147a): author SDK contract specification
Add comprehensive SDK contract specification at docs/notes/sdk-contract.md.
This document serves as the constitutional specification for all pdftract
SDK implementations across all languages.

The contract defines:
- Method surface (9 methods mirroring CLI/MCP tools)
- Error mapping (CLI exit codes → native exceptions)
- Versioning compatibility rules (MAJOR lock, MINOR flexibility)
- Option-naming conventions (CLI flag → language-native case)
- Native type-mapping requirements (Document, Page, Span, Block, Match, Fingerprint, Classification)
- Async conventions per language
- Conformance enforcement (100% pass required)
- Change policy (ADR required for contract changes)

Verification note: notes/pdftract-147a.md

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 23:13:55 -04:00
jedarden
1747812323 docs(pdftract-1wqec): verify CI scaffolding acceptance criteria
- Confirm pdftract-ci.yaml exists in declarative-config
- Verify WorkflowTemplate deployed to argo-workflows namespace
- Document all scaffold templates are present with placeholders
- Note: ArgoCD sync will reconcile minor version drift

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 07:12:16 -04:00
jedarden
891718319e docs(pdftract-1wqec): verify manual workflow execution succeeds
Updated verification notes with successful manual workflow test results.
All DAG steps completed successfully; publish-if-tag correctly skipped.
2026-05-17 07:06:38 -04:00
jedarden
5a6449a8cf docs(phase-0.1): verify pdftract-ci scaffolding complete
The pdftract-ci WorkflowTemplate was already created in declarative-config
in a previous session. This commit adds verification notes confirming all
acceptance criteria are met:

- WorkflowTemplate exists in k8s/iad-ci/argo-workflows/pdftract-ci.yaml
- Template synced to iad-ci cluster (argo-workflows namespace)
- DAG structure: setup -> [build-matrix, test-matrix, quality-matrix,
  bench-matrix] -> publish-if-tag
- All required configuration present (parameters, securityContext,
  volumeClaimTemplates, podGC, TTL)
- Webhook payload schema documented in YAML comments
- Empty step skeletons ready for Phase 0 sibling beads

Manual workflow test attempted but encountered transient Rackspace Spot
CSI storage attachment issue (infrastructure, not template defect).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 06:58:21 -04:00
jedarden
9f27d16f25 docs(phase-0.1): verify pdftract-ci scaffolding complete
Verified the pdftract-ci WorkflowTemplate exists in declarative-config
and is correctly synced to the iad-ci cluster. All scaffolding
requirements met for Phase 0.1.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 03:24:36 -04:00
jedarden
f2bf29b0c8 docs(Phase 0.1): document pdftract-ci scaffold status
Verify completion of Phase 0.1 scaffolding bead. The WorkflowTemplate
was already implemented in declarative-config with all required elements:
- DAG structure with empty step skeletons
- VolumeClaimTemplates for cargo cache
- Exit handler, security context, imagePullSecrets
- Webhook payload schema documentation

Subsequent Phase 0 beads can now develop each DAG leg in parallel.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 02:43:48 -04:00
jedarden
427c353fbc docs(Phase 0.1): document pdftract-ci scaffold status
The pdftract-ci.yaml WorkflowTemplate scaffold already exists in
declarative-config (commit 8248a1f). This notes file documents the
current state and pending ArgoCD sync.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 01:52:42 -04:00