There is a newer version of the record available.

Published May 9, 2026 | Version v0.2.0

caseywdunn/corpus: v0.2.0

Authors/Creators

  • 1. Yale University

Description

A hardening + iteration release. v0.2 closes out v0.1's deferred items (vision pass at corpus scale, expanded lexicon + taxonomy support, Bouchet batch-script fixes), adds a real update lifecycle (per-stage resume, input fingerprints, update_corpus.py orchestrator), and lays in a robustness + observability layer (structured stage_failures[], silent-failure quality gates, corpus_status rollup, network circuit breakers). Three substantive bugs surfaced during release validation and ship in this version: a SLURM-array slicing race that corrupted per-doc state files (#55), an input_fingerprint gap that silently skipped lexicon refreshes on --resume (#56), and a broken tesseract-data-* block in environment.yaml that broke fresh installs (#52). The deploy stack also moved from single-EC2 + Let's Encrypt to a shared ALB + ACM pattern that supports multiple organism corpuscles on one hostname-routed load balancer. Geographic extraction (#13) and trait extraction (#14) are pushed to later releases.

Added

Update lifecycle

  • update_corpus.py orchestrator (#32) — one command runs the pipeline + every post-pipeline script in dependency order with --resume. Forwards the full Stage 1 flag surface so callers don't lose pipeline knobs. Makes "add papers and update everything" a one-liner.
  • Granular per-stage resume (#28) — replaces the all-or-nothing summary.json completion marker with per-stage status tracked in pipeline_state.json. Stages whose artifact is already present and whose inputs haven't drifted are skipped on --resume.
  • Input fingerprints on annotation artifacts (#29) — lexicon_sha256 and taxonomy_snapshot_date are stamped into chunks.json / taxa.json / anatomy.json so staleness is detectable without re-reading the source files.
  • --re-annotate-stale flag (#33) — re-runs only the lexicon categories whose fingerprint changed. Subsumed by per-stage resume + per-category fingerprints.
  • Idempotency contracts on post-pipeline scripts (#30) — build_biblio_authority, build_taxon_mentions, backfill_intext_citations, and reconcile_corpus_to_biblio audited + tested for re-run safety.
  • --audit-orphans (#31) — read-only listing of documents/<HASH>/ directories (and LanceDB rows) whose source PDF is no longer in the input set. Deletion stays manual.

Robustness + observability

  • Structured stage_failures[] + per-stage timing (#34) — reason codes (timeout, crash, external_unavailable, unsupported_format, corrupted, quality_gate) replace v0.1's free-text errors[]. Every downstream tool reads from the new schema.
  • Silent-failure quality gates (#36) — flag empty text layers, gibberish OCR output, all-black figures, zero-reference papers, and collapsed-extraction chunks. Surfaces what v0.1 was happily writing without complaint.
  • corpus_status (#40) — single command rolls up stage completion, failure breakdown by reason, quality flags, and staleness across the whole build. Dashboard for everything else in this section and the update lifecycle.
  • Huge-document hard cap (#35) — page-count gate with a structured too_large flag for monographs that would blow past reasonable wallclock. Haeckel 1888 Challenger Siphonophorae is the canary.
  • External-service flakiness layer (#37) — shared retry + backoff + circuit breaker + cache for Grobid, BHL, CrossRef, OpenAlex via pipeline/external.py. STRICT_NETWORK env var fails-fast for release builds.
  • Standardized --dry-run (#41) — across all pipeline + post-pipeline CLIs, replacing the prior 4-of-10 inconsistent state.

Vision + figures

  • SLURM array support for the vision pass (#27) — batch_pass3b.sh now parallelizes the same way batch_pipeline.sh does. Prerequisite for running Pass 3b (Qwen2.5-VL-7B) at corpus scale (#11).
  • Archaic plate prefixes + Roman-numeral support in figure extraction (#16) — recovers figure numbers from 19th-c. and early-20th-c. caption conventions (Tab. III., Pl. XII.) the v0.1 heuristics didn't match.

Indices + features

  • BibTeX round-trip curation (#26) — bib_export serializes biblio_authority.sqlite to BibTeX; bib_import brings hand edits back into the authority database. Closes the loop on user curation of corpus bibliography.
  • Multi-category lexicons (#24) — --lexicon CATEGORY:PATH accepts any number of YAML files (anatomy, biogeography, …); top-level keys define categories. Annotations carry a category field so per-category resume works.
  • Plant-source taxonomy support (#23) — ingest_taxonomy.py accepts non-WoRMS Darwin Core archives, including taxa.tsv Taxon-core layouts (#22).
  • Expanded default Tesseract language pack coverage (#46) — the OCR fallback union covers more 19th-c. European scripts.

MCP server

  • Corpuscle-aware server name (#17) — the deployed MCP server identifies itself as corpus:<corpuscle> rather than the bare corpus, with __version__ from pipeline/version.py surfaced via bundle_info.
  • Inline figure bytes from get_figure_image — returns PNG content directly so MCP clients don't need filesystem access to the bundle.
  • Two-layer client-side instructions. The InitializeResult.instructions blob now joins a packaged default (mcpsrv/default_instructions.md) with an optional per-corpuscle override prepended on top. Default guidance (defer to corpus taxonomy + bibliography, preserve historical terminology) ships with the server and reaches every client with no operator action; corpus-specific nudges land first via <corpuscle>/instructions.md when present. templates/instructions.md is the starting scaffold for the corpuscle layer.
  • /healthz liveness probe on the SSE transport. Returns 200 ok without requiring the bearer token — mounted ahead of the auth middleware in mcpsrv.transport._HealthzASGI so uptime monitors and reverse-proxy readiness checks don't need the shared secret. Exposed through deploy/nginx.conf as location = /healthz.

Internal

  • pipeline/ package (#42, #44, #45) — the ~1700-line process_corpus.py is split into focused submodules (pipeline.annotate, pipeline.chunking, pipeline.metadata, pipeline.figure_passes, pipeline.scan, pipeline.extract, pipeline.runner, pipeline.main). process_corpus.py is now a thin CLI shim. No behavior change.
  • mcpsrv/ package (#15) — the ~2050-line mcp_server.py is split per concern (papers / taxonomy / bibliography / figures / transports). No behavior change.
  • bib/ package (#43) — bundles bib_metadata, bib_export, and bib_import into a single namespace.
  • Single-source __version__ in pipeline/version.py, stamped into bundle manifests + MCP bundle_info. main / dev / vN branching model adopted; dev carries a PEP 440 pre-release suffix (0.2.0.dev0 → 0.2.0).
  • schema_version field on persistent artifacts so future schema changes can be detected without parsing.
  • pngquant added to the build environment (#25) so bundled PNGs ship pre-compressed.

Changed

  • Repo layout cleanup. Library modules figures.py, taxa.py, grobid_client.py, embeddings.py, vision.py, external.py, and version.py moved from the repo root into the pipeline/ package — they were never run directly, only imported. Import sites: from figures import … → from pipeline.figures import … (and likewise for the other six). One-off utilities (dedup_ghost_works.py, unify_doi_corpus_key.py) moved to tools/. PLAN.md moved to dev_docs/. The repo root now holds only user-facing CLI entry points.
  • Anatomy-only naming scrubbed throughout. The lexicon system is no longer hard-coded to anatomy; field and file names use lexicon / category instead. Documentation refreshed in lock step.
  • CLAUDE.md → AGENTS.md — generic agent-guidance filename for compatibility with non-Claude assistants.
  • MCP hot paths trimmed for token cost — list_papers row shape reduced; previously unbounded MCP list returns are now bounded.
  • Per-PDF subprocess gated by platform (#18) — the docling subprocess wrapper, originally added to contain a Linux segfault, no longer runs on macOS where it was pure overhead.
  • Deploy architecture: ALB + ACM, multi-organism support. Was single-EC2 + nginx + Let's Encrypt; now each EC2 sits behind a shared Application Load Balancer (siphonophores-mcp-alb) that terminates TLS with an ACM wildcard cert. nginx on the instance drops to plain :80 (no certbot, no TLS). Adds a default /health endpoint nginx serves directly for ALB target-group health checks (separate from the /healthz MCP probe under bearer auth). One listener rule per organism (host-header match → target group), so adding cnidaria.siphonophores.org etc. is a target-group + listener-rule + DNS CNAME, no new TLS infra. CloudFormation BucketName parameter now optional via a new CreateBucket flag so re-deploys can attach to an existing bundle bucket. Full runbook rewritten: dev_docs/DEPLOY.md.
  • INSTALL.md promoted to repo root. Moved from dev_docs/ since the content (jbig2enc, OCR language packs, Grobid, pip fallback) is user-facing and belongs alongside README, CONTRIBUTING, and CHANGELOG. dev_docs/ keeps its maintainer-only docs (PLAN, DEPLOY, BOUCHET, MCP_TOOLS, TESTING, OVERVIEW). All cross-references updated.

Fixed

  • Bouchet batch scripts (#20, #21) — native-library load problems, CUDA / torch wheel selection, and a fail-loud preflight so configuration drift surfaces before the array launches instead of after each task fails individually.
  • deploy/stack.yaml (#6) — removed stale default-VPC assumptions that broke deploys on accounts without a default VPC.
  • Docling extraction fails loudly instead of writing placeholder text when the parser produces nothing usable.
  • Missing PyMuPDF surfaces as a stage failure instead of a silent skip.
  • --skip-pipeline rejected with --re-annotate-stale — previously these silently combined into a no-op.
  • rapidfuzz required at import in unify_doi_corpus_key and dedup_ghost_works — failure surfaces at startup, not partway through a run.
  • ingest_to_vector_db import wired into pipeline.main — was silently dropped during the package extraction.
  • package_for_serve discovers lexicon outputs dynamically — no more hardcoded list that drifted from the multi-category lexicon work; also bundles instructions.md and warns on missing top-level files.
  • Three issues filed during release validation (#47, #48, #49) — path handling, cross-paper leakage in a query path, and an incorrect rank field. Closed before release.
  • Stage 1 SLURM array tasks could process the same PDF concurrently and corrupt per-doc state files (#55). The pre-resume filter at the top of pipeline.main.main() ran before batch slicing, so each array task's slice depended on disk state at task-start time. Tasks starting later saw fewer remaining hashes; their slice indices then landed on different members of the list, producing overlapping batches. The two writers raced on a shared pipeline_state.json.tmp filename, leaving either an interleaved-bytes payload (31 corrupted summaries in the production run that surfaced this) or a FileNotFoundError on the rename. Fixed by slicing on the unfiltered hash list (_slice_hashes_for_batch in pipeline.main); resume skipping is now done per-doc inside the loop. Belt-and-braces: _save_pipeline_state and create_summary_json now use per-writer tmp filenames (.tmp.<pid>.<ns>) so any future regression that re-introduces concurrent writers on the same hash gets last-write-wins atomicity instead of corruption. Regression tests in tests/test_batch_slicing.py.
  • --resume outer fast-path ignored input_fingerprint, so editing a lexicon or taxonomy never invalidated already-recorded stages (#56). The per-doc fast-path skip in pipeline.main called _all_stage_artifacts_complete without forwarding the live taxonomy/lexicon fingerprints, so a doc whose taxa_and_lexicon_extraction stage was recorded under (e.g.) a taxonomy-only fingerprint was silently skipped on a re-run that loaded a real lexicon — even though the inner per-stage gate would have correctly flagged it stale, that gate was unreachable. Effective result: the only way to force a lexicon refresh was bumping PIPELINE_VERSION. Production occurrence: 12,669 docs in job 11108546 carried a fingerprint without lexicons because the source YAML had loaded as {}; the resume run silently passed over all of them. Fixed by adding expected_fingerprints to _all_stage_artifacts_complete and a shared _expected_fingerprints_for_run helper that both main.py's outer gate and runner.py's inner gate now use, keeping the two staleness notions in lockstep. Regression tests in test_per_stage_resume.py.
  • environment.yaml references to tesseract-data-<code> packages (#52, closes #9) — the 12 per-language entries added in #46 listed package names that don't exist on conda-forge, so a fresh conda env create failed with PackagesNotFoundError. Existing dev envs survived because incremental updates silently skipped the missing packages. Replaced with a new tools/install_tessdata.sh helper that downloads the default fallback set (deu, fra, rus, lat, spa, por, chi_sim, chi_tra, jpn, ell, kor, grc, deu_latf) directly from tessdata_best. Idempotent; takes a custom language list as positional args; honors TESSDATA_DIR for non-conda installs. Subsumes the v0.1 deu_latf-on-Bouchet manual install (#9) — deu_latf is now part of the default download.

Removed

  • bib_metadata.py shim — the deprecated re-export shim is removed. Migrate any leftover from bib_metadata import … imports to from bib import … (or from bib.parser import … for private helpers).

Deferred / known limitations

  • Streamable HTTP transport with OAuth (#5) — deferred indefinitely. SSE + bearer-token works for the ~20-collaborator deploy target; revisit only if wider distribution materializes or MCP clients drop SSE support.
  • Geographic mention layer (#13) — pushed to v2.0+; the mention-layer surface is likely to be reworked at the major-version boundary.
  • Trait extraction + identification keys (#14) — v0.3 candidate. Substantial enough to warrant its own plan section when picked up.
  • Embedding model migration path (#38) — design-only for v0.2; implement when a model swap is actually needed (BGE-M3 v2 or a different family).
  • MCP server lazy index loading (#39) — premature at 1.8K papers; documented as a known scaling cliff for 10K+ corpuses.

Files

caseywdunn/corpus-v0.2.0.zip

Files (32.0 MB)

Name Size
md5:1759884d1099d38400b32543b7e62c12
32.0 MB Preview Download

Additional details

Related works

Software