Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ jobs:
- name: Build shared library
run: zig build shared --summary all

- name: Verify recorded external-OCR routing (no live OCR)
run: |
python3 -m unittest discover -s benchmark/eval -p 'test_recorded_ocr.py'
python3 benchmark/eval/recorded_ocr.py \
--fixture benchmark/eval/recorded_ocr/jpx-mac-2026-11-01/fixture.json \
--output benchmark/eval/outputs/recorded-ocr-ci

- name: Upload recorded OCR routing evidence
if: always()
uses: actions/upload-artifact@v6
with:
name: recorded-ocr-routing
path: benchmark/eval/outputs/recorded-ocr-ci
if-no-files-found: warn

- name: Verify adaptive provenance and bounded recovery
run: |
python3 benchmark/eval/table_continuation_parity.py --output benchmark/eval/outputs/parser-020-ci/table-parity
Expand Down Expand Up @@ -266,6 +281,18 @@ jobs:
- name: Build WASM
run: zig build wasm

- uses: actions/setup-node@v6
with:
node-version: "22"

- name: Test actual WASM ABI and wrapper
run: node --test --test-concurrency=1 benchmark/eval/wasm/*.test.mjs

# GitHub's Ubuntu image supplies Chrome. The runner fails explicitly
# when unavailable; it never installs browser dependencies implicitly.
- name: Test staged browser delivery and Worker lifecycle
run: node benchmark/eval/wasm/browser.mjs benchmark/eval/outputs/wasm-browser-ci

- name: Enforce WASM size budget
run: |
wasm_size=$(wc -c < zig-out/bin/pdf_parser.wasm)
Expand All @@ -274,6 +301,14 @@ jobs:
exit 1
fi

- name: Upload WASM consumer evidence
if: always()
uses: actions/upload-artifact@v6
with:
name: wasm-consumer
path: benchmark/eval/outputs/wasm-browser-ci
if-no-files-found: warn

adaptive-ocr:
name: Adaptive OCR quality gate
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -338,3 +373,76 @@ jobs:
/tmp/ocr-hard-document-quality.json
/tmp/ocr-jpx-hard-document-quality.json
if-no-files-found: ignore

live-ocr-profile:
name: Live OCR arithmetic profile (strict corpus)
runs-on: ubuntu-24.04
container: debian:13.6-slim
timeout-minutes: 20
steps:
- name: Install build dependencies in the isolated CI container
run: |
apt-get update
apt-get install -y ca-certificates git curl xz-utils cmake ninja-build g++ binutils pkg-config \
python3 python3-pil libleptonica-dev liblcms2-dev libfreetype-dev libfontconfig-dev \
libjpeg-dev libpng-dev libtiff-dev zlib1g-dev tesseract-ocr-eng

- uses: actions/checkout@v7
with:
persist-credentials: false

- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.17.0

- name: Download pinned release archives (builder itself is offline)
run: |
python3 - <<'PY'
import importlib.util
from pathlib import Path
import sys
import urllib.request
sys.path.insert(0, str(Path("benchmark/eval").resolve()))
spec = importlib.util.spec_from_file_location("profile", "benchmark/eval/ocr_profile.py")
profile = importlib.util.module_from_spec(spec)
spec.loader.exec_module(profile)
cache = Path("benchmark/eval/raw_cache/live-ocr-profile")
cache.mkdir(parents=True, exist_ok=True)
for name, (version, url, digest) in profile.PINS.items():
suffix = ".tar.xz" if name == "poppler" else ".tar.gz"
target = cache / (name + "-" + version + suffix)
with urllib.request.urlopen(url, timeout=60) as response:
target.write_bytes(response.read())
profile.require_hash(target, digest)
PY

- name: Build task-local real OCR tools and parser
run: |
python3 -m unittest discover -s benchmark/eval -p 'test_ocr_profile.py'
python3 -m unittest discover -s benchmark/eval -p 'test_owned_process.py'
python3 benchmark/eval/ocr_profile.py build \
--source-cache benchmark/eval/raw_cache/live-ocr-profile \
--traineddata /usr/share/tesseract-ocr/5/tessdata/eng.traineddata \
--output benchmark/eval/outputs/live-ocr-profile
zig build --summary all
zig build benchmark-eval --summary all

- name: Enforce live raster identity, original strict corpus and semantic floors
run: |
python3 benchmark/eval/ocr_profile.py gate \
--profile benchmark/eval/outputs/live-ocr-profile/profile.json \
--output benchmark/eval/outputs/live-ocr-qualified

- name: Upload live qualification evidence
if: always()
uses: actions/upload-artifact@v6
with:
name: live-ocr-profile
path: |
benchmark/eval/outputs/live-ocr-profile/*.json
benchmark/eval/outputs/live-ocr-profile/*.stdout
benchmark/eval/outputs/live-ocr-profile/*.stderr
benchmark/eval/outputs/live-ocr-profile/build-attempt-*
benchmark/eval/outputs/live-ocr-qualified
if-no-files-found: warn
9 changes: 5 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ jobs:
- name: Build WASM
run: zig build wasm

- uses: actions/setup-node@v6
with:
node-version: "22"

- name: Prepare deploy directory
run: |
mkdir -p deploy
cp web/index.html deploy/
cp zig-out/bin/pdf_parser.wasm deploy/
run: node benchmark/eval/wasm/stage.mjs deploy

- name: Upload artifact
uses: actions/upload-pages-artifact@v5
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ record ordering, and compatibility rules.

The CLI/JSONL boundary is the default integration surface. The repository also
includes a C ABI, Python bindings, JavaScript adapters, a stateless HTTP wrapper,
and a WebAssembly build.
and a [browser WASM API](docs/wasm.md) with an owned Worker and versioned numeric ABI.

The JavaScript adapters use a host-selected executable, validate records, and
retain source positions. Node 22 or newer is required:
Expand Down
18 changes: 15 additions & 3 deletions benchmark/eval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ adversarial page-tree recovery.
checked-in corpus. Each row records the fixture id, source note, redistribution
status, PDF SHA256, and expected OCR/table/formula route counts. Manifest eval
loads this sidecar automatically when it sits next to `manifest.tsv` and fails
if the adaptive counters differ from those expectations. Large or raw third-party
if the adaptive counters differ from those expectations. On a mismatch, stderr
also includes a `route_count_mismatch` JSON diagnostic with the document id and
all expected/actual OCR, table, and formula counts; the command still fails.
These are routing-candidate counts, not counts of recognized tables or formulas.
Large or raw third-party
corpora should live under `benchmark/eval/raw_cache/`, which is ignored by git;
checked-in PDFs should stay small and redistributable. The
`jbig2-public-domain-preface` fixture is a deterministic page-10 derivative of
Expand Down Expand Up @@ -129,8 +133,8 @@ color JPX map/cover; the remaining JBIG2 object is only the small Google
watermark mask. The roughly 188 KB fixture forces rasterization of real JPX
content and gates the selected 300-DPI sparse-text fallback and readable cover
labels separately from noisy map detail. OCR-derived table/formula region counts
are recorded but remain observational because the pinned Linux and current macOS
toolchains segment the map differently while recovering the same required text:
are observational in this live semantic gate because Linux and macOS toolchains
segment the map differently while recovering the same required text:

```sh
qpdf --deterministic-id --object-streams=disable \
Expand All @@ -143,6 +147,14 @@ python3 benchmark/eval/ocr_hard_document_quality.py \
--output /tmp/pdf-parser-ocr-jpx-hard-document-quality.json
```

The separate [recorded external-OCR gate](recorded_ocr/README.md) checks the
original 4 table / 6 formula expectations against a hash-verified macOS TSV.
Strict live corpus evaluation still fails if its route counts differ.

For live Linux runs, the [OCR arithmetic profile](ocr_profile/README.md) builds
isolated, pinned tools and checks real rasterization, OCR, original route counts,
and semantic floors. Each environment must pass its qualification gate.

The ignored large corpus explicitly inventories a real technical reference with
CID Identity/no-ToUnicode cases and the full public-domain scan containing
JBIG2 and JPX images. These exercise honest fallback and routed OCR behavior;
Expand Down
Loading
Loading