Module map
The bundled assets are
data/import-benchmark-reference-us-v2.pdf and data/import-benchmark-reference-us-v2.gold.json. scripts/generate-import-reference-pdf.mjs regenerates the PDF from the manifest.
Record lifecycle
startImportBenchmark() appends a record before the expensive work begins. Import stages update the same record with transport, timing, usage, and parser diagnostics. A normal run becomes comparable only after the user confirms the preview.
Comparable statuses are:
confirmedfor a normal report import;reference-scoredfor a completed reference run with differences; andreference-passedfor an exact reference match.
Reference fixture and protocol
The current fixture identity isgetbased-reference-us-v2, fixture version 2, benchmark protocol version 2, with 68 expected markers across a three-page text PDF.
runBundledImportReferenceBenchmark():
- captures the provider and model selected at the start;
- loads the manifest and PDF without browser caching;
- extracts the PDF text through the production extractor;
- calls the production AI parser with raw-output capture and deterministic benchmark mode;
- scores both raw model output and the reconciled pipeline result; and
- persists either a completed score or a scrubbed failure record.
getBundledImportReferenceGoldBenchmark(). It is a locked comparison target, not a stored inference run.
When the fixture content or expected output changes, update the fixture ID or version. When parsing or scoring semantics change, bump IMPORT_REFERENCE_PROTOCOL_VERSION. Runs with different fixture/protocol identities must not compare.
Scoring layers
Reference scoring deliberately keeps two layers:- Raw model measures missing and unexpected results, exact marker fields, precision, recall, F1, marker mapping, values, units, reference ranges, date, and report type before deterministic correction.
- Pipeline result measures the final output after deterministic marker reconciliation.
Comparison identity
importBenchmarksUseSameInput() is the comparison gate:
- normal imports match by input hash;
- reference runs match by fixture ID, fixture version, and protocol version.
Runtime diagnostics
All providers contribute provider/model identity, timings, and usage when available. Local AI can additionally capture normalized adapter metadata such as:- native versus OpenAI-compatible API path;
- local, LAN, remote, or cloud execution location;
- context and maximum context length;
- quantization and parameter size;
- allocated VRAM and loaded-at-start state; and
- native generation speed, load duration, and first-response timing.
Persistence and privacy invariants
Benchmark arrays live inside the active profile’s imported-data blob, but they are deliberately device-local:persistImportBenchmarks()callssaveImportedData({ immediate: true, skipSync: true });stripLocalOnlyProfileData()removesimportBenchmarksanddeletedImportBenchmarkIdsbefore legacy and delta sync serialization; and- inbound merge restores the local values after merging remote data.
importBenchmarks.
Failure text is limited to 500 characters and scrubs bearer tokens and sk--style secrets. Keep raw prompts, report text, API keys, authorization headers, and provider response bodies out of benchmark records.
Verification
Run the full suite after changing this surface:tests/playwright/import-benchmarks.spec.js. It covers modal behavior, same-input gating, cloud-provider identity, raw-versus-corrected scoring, exact discrepancy review, background completion, normal-import capture, deletion, secret scrubbing, sync exclusion, and fixture integrity.
Local runtime metadata depends on the provider adapter contract covered by tests/api-provider-contracts.test.js and tests/test-provider-local-ai-runtime.js.
When changing the reference manifest, regenerate the PDF and run the fixture-integrity tests:
service-worker.js, bump version.js when required by the app release process, and review both files in the same change.