Deterministic generators for the synthetic test documents used by the Resecta on-device iOS redaction app.
Three documents are the primary outputs, all entirely synthetic:
- A sample bank statement (
sample-bank-statement.pdf) — also shipped as the in-app sample document; the app repository's tests pin both of its copies to this file's SHA-256, and its commit hook checks that the two are byte-identical. - The Hartwell loan/mortgage packet (
packet.pdf) — a 12-page, PII-dense multi-exhibit document that serves as the primary labeled detection corpus; the app repository's engine tests carry a copy, pinned to this file's SHA-256. - The capture masters (
capture-masters-2026-08.pdf) — a 16-page print document for the test harness's capture and OCR evaluation legs: four pages imported from the packet plus twelve born-digital exhibits (mail and forms, court and FOIA, medical and HR), with its own ground truth and a fiducial-marks sidecar.
The repository also commits fixture sets built for testing the app and for calibrating its verification tooling:
planted/— PDFs written bytools/build_planted_corpus.py, each carrying one planted value on one surface of the file (among them visible or hidden text, an image, an annotation, metadata, a form field, a bookmark, a prior revision, an embedded file and a JavaScript action), plus clean controls; they calibrate the leak oracle intools/verify_oracle.py;t23/— rotated, annotated and incrementally updated copies of the packet;robustness/— page-size and page-count boundaries, encrypted and byte-damaged copies of the packet;- the search ground truth described below;
hidden_layer/— single-page scan-like PDFs whose invisible text layer is placed at chosen offsets from the printed words, each with an expected file of its geometry and named box scenarios, and the generator, checks and recorded mutants that rebuild them (seehidden_layer/README.md);filled_forms/— one synthetic intake form filled by reportlab, pypdf, PyMuPDF and macOS PDFKit, with a widget-free control, a dynamic XFA form and three reject documents, each with an expected file of its fields, values, flags and appearances (seefilled_forms/README.md);scripts_handwriting/— non-Latin and mixed-script pages from three PDF writers, their scanned twins (with no layer, their own layer, or a layer from recorded text recognition) and synthetic handwriting, each with an expected file of its text, gloss, ink and decoded layer (seescripts_handwriting/README.md);structure/— unusual, at-the-limit and malformed or hostile-shaped files, every active element inert, each with an expected file of the one structural property it holds (seestructure/README.md).
Four rules hold for the three documents:
- every person and organization the documents are about is invented (real agencies, courts and statutes appear only as the furniture of the public forms and filings the exhibits imitate), identifiers are invented or taken from published test and reserved ranges, and every value is disclosed in the generator source;
- no invented entity is added to a name list the app ships (a project rule; no automated check covers it);
- document text stays within printable ASCII;
- the outputs are byte-reproducible from a given commit and its locked dependency versions.
License: Apache-2.0. The bundled Inter font is under the SIL
Open Font License 1.1 — see NOTICE and fonts/.
Python 3.12, pinned by .python-version and CI (pyproject.toml allows newer;
only 3.12 is tested). uv is the supported install
path:
uv syncuv sync installs the generators' dependencies and the dev group (ruff, mypy,
pytest). The packet and statement generators use reportlab and pypdf; the
rasterized variants use pymupdf, pillow and numpy. Two tools also need the
opt-in harness group (uv sync --group harness): tools/register_capture.py
for OpenCV and pypdfium2, and tools/verify_oracle.py for OpenCV.
Every pull request and every push to main runs two jobs
(.github/workflows/ci.yml). build checks the lockfile, rebuilds the packet
and compares packet.pdf and packet-ground-truth.json byte-for-byte with the
committed files, runs the acceptance suite, rebuilds and compares
sample-bank-statement.pdf the same way, runs the statement's acceptance suite
(verify.py, with poppler installed on the runner), then builds the variants.
lint runs ruff check, ruff format --check, mypy and pytest, then runs
each tool under tools/ once: the argument parsers' help, the checksum writer
on a temporary directory, the query-bank generator against its committed output
and the planted-corpus generator on a temporary copy. The acceptance suite
byte-compares the capture-masters ground truth with the committed file, and the
acceptance and variants steps both rebuild the capture-masters PDF in memory
and check it and its fiducial sidecar against the two SHA-256 pins in
packet/build_capture.py. The acceptance suite also checks the packet's
extracted text against the brand denylist verify.py applies to the statement
(packet/brand_denylist.py; the one name exempted is the agency the packet's
own specimen disclaimer names). The fixture sets under planted/, t23/ and
robustness/ are not rebuilt in CI. The pytest suite checks the committed
hidden_layer/ documents and rebuilds the smallest of them byte for byte,
and checks and rebuilds the filled_forms/ documents (all but the two
recorded PDFKit files).
A second workflow, security.yml, runs pip-audit over the locked set weekly and
on every pull request and reports what it finds in the job summary without
failing the run.
# Core deliverables: packet.pdf + packet-ground-truth.json (deterministic)
uv run python -m packet.build_packet
# The bank-statement generator (byte-identical to the in-app sample)
uv run python generate_statement.py
# The capture masters + ground truth + marks sidecar (asserts packet.pdf is unchanged)
uv run python -m packet.build_capture
# Test-only variants + perf filler (-> variants/, gitignored)
uv run python -m packet.variants
# Acceptance: structural checks + byte-determinism (exit 0 = all green;
# it rebuilds the packet and capture files in place)
uv run python -m packet.acceptanceuv run python verify.py runs twelve checks on the bank statement (content,
fonts, arithmetic, metadata) and requires pdftotext/pdffonts (poppler).
documents.manifest.json pins the SHA-256 of each document and variant
(tools/verify_oracle.py reads it); prepare_fonts.py rebuilds fonts/ from
the Inter release (see fonts/NOTICE.md).
The packet is assembled in a fixed page order (0-indexed pageIndex):
0,1 URLA-B | 2 URLA-A | 3,4,5 statement (embedded) | 6,7 1040 | 8 ACH | 9 W-2 | 10 gov ID | 11 vehicle
packet/
personas.py the Hartwell household + org entities (single source of values)
occurrences.py every drawn occurrence as structured data
manifest.py draw-time bounding-box capture + ground-truth emit
layout.py geometry, fonts, palette, and form-furniture helpers
schema.py ground-truth schema validation
build_packet.py one-pass assembler -> packet.pdf + packet-ground-truth.json
variants.py scan-sim / rotate / the degrade ladder / perf filler (test-only),
and the fiducial stamping the capture masters use
acceptance.py structural acceptance suite + byte-determinism
generators/ one module per packet exhibit (urla_a, urla_b, t1040, ach, w2,
govid, veh, stmt) and five for the capture exhibits (mail, forms,
court, medical, hr)
build_capture.py assembles the capture masters, their ground truth and marks sidecar
occurrences_capture.py the capture masters' drawn occurrences
aruco.py the marker table behind the capture fiducials
pdfutil.py a shared pypdf pass over the emitted PDFs
t23.py the rotated / annotated / incremental-update fixtures (t23/)
robustness.py the scale, page-cap and encryption fixtures (robustness/)
fuzz.py copies the byte-damaged packets built by resecta-datapipeline
into robustness/fuzz/ and writes their sidecar
packet-ground-truth.json carries one record per drawn occurrence (the 106
occurrences), each with a normalized (0–1, bottom-left origin) bounding box
that compares directly against the engine's detection rectangles. The 20
records carried over from the embedded statement (carried_stmt) ship with
bbox: null and measured_pending: true: their geometry is not resolved, so
they are checked by count, not by rectangle.
Schema 2 adds three columns to every record. context_class names the
name-context shape a value is drawn in, from the same vocabulary the synthetic
text corpus of resecta-datapipeline
uses (caption_left, role_label,
title_label, closing_line, body_prose, ... or none); every packet
record carries none (its names all sit under form-field labels), the capture
masters carry sixteen classed rows. caption_clearance_pt and caption_text
record the nearest furniture text above the value that overlaps it horizontally
and the vertical gap to it in points, measured from the draw geometry; a
negative clearance means the caption overprints the value.
The rasterized variants (variants/, built, never committed) narrow every
record to the OCR leg. The degrade-ladder rungs also add a polygon beside
each box: the skew rung's rotated quad, whose axis-aligned hull is the record's
bbox; every other rung inherits the master's geometry. The degrade ladder is
one declarative table (packet/variants.py _RUNGS) applied to both masters:
skew 1.5°, blur, low-DPI 100 and 75, JPEG quality 85 and 70, seeded noise,
duplex bleed-through, and fax at 204×98 and 204×196 DPI (1-bit). Every rung is
a pure function of the master's bytes and its recorded seed, so under the
locked dependency versions the outputs are byte-reproducible. The same module's
build_hidden writes the hidden-text variants (variants/packet-hidden-*) that
the iOS app's verification-corpus runner reads from this repository's root;
nothing in this repository calls it.
search-ground-truth/ holds the frozen expectations for the app's search
feature on the packet and its scan-simulated variant: search-queries.json
(the query bank, generated by tools/build_search_queries.py) and one
*.search-gt.json sidecar per document, emitted by tools/search_oracle.py
from an official harness run plus the adjudication file. The sidecars change
only through a row in
REBASELINE-LOG.md, which records
what changed, why, and its kind: the initial freeze, a bug fix, an intentional
rebaseline or a regenerated OCR leg.
These are build/development dependencies of the generators; none of them ship in the Resecta iOS app, and none contribute code to the synthetic document outputs:
- fonttools (MIT), opentype-feature-freezer (Apache-2.0), pypdf (BSD), reportlab (BSD), pillow (MIT-CMU), numpy (BSD-3-Clause, with bundled components under 0BSD, MIT, Zlib and CC0-1.0; the seeded noise rung of the degrade ladder).
- The
devgroup (ruff, mypy, pytest — MIT) and the opt-inharnessgroup (opencv-python-headless — Apache-2.0; pypdfium2 — BSD-3-Clause / Apache-2.0; both wheels bundle third-party libraries under their own licenses; augraphy, albumentations, pdfplumber — MIT) are tooling only. - PyMuPDF (pymupdf) — AGPL-3.0. Used only by this repository's own tooling: to rasterize the scan-simulation and degrade variants, to compose the oversized-page robustness fixtures, and as a text extractor in the acceptance suite, the fixture builders' self-checks and the search and verification tools. The AGPL copyleft applies to PyMuPDF and its derivative works; the synthetic documents this tool emits are data outputs, not a derivative of PyMuPDF's source, and the generator is not network-served. No AGPL obligation attaches to the generated documents or to this Apache-2.0 repository.