source-extraction-coverage
Template skill (doc 08, doc 01). The estimate/yield pair is the whole point: it is how the 2%-coverage failure (LLM-extracted a doc and silently produced ~2% of its text) becomes a loud, machine-checkable signal instead of a silent loss.
Trigger
/extract-source <path> [--type auto|pdf|docx|xlsx|html|scanned]
Preconditions
- Source lives in the off-repo read-only archive; record its
sha256. - Type is detected by content/structure, not filename (incident D4: names lie about content).
Steps
- Estimate first. Before extracting, declare
extraction_estimatein the landing-page frontmatter: roughly how much extractable content this source holds (page count, table count, "text-heavy" vs "image-only"). This is a commitment made before you see the result, so a shortfall is undeniable. - Pick the recipe by type (use ADOPT-tier permissive tools from doc 12):
pdf(born-digital): deterministic text+geometry (pdfplumber/Docling);pdf(scanned/image-only) → route to thescannedrecipe (OCR as labeled interpretation, doc 11).docx: structured access (python-docx) + semantic Markdown (mammoth).xlsx: formula-graph read (openpyxl) / fast data read (calamine) — classify by scanned structure, not sheet names (D4).html: typed-element extraction; strip nav/boilerplate.scanned: OCR with a blur gate (OpenCV Laplacian-variance → too blurry stays provisional); OCR output is a claim, not source text.text/markup: section-aware deterministic copy with paragraph or section estimate/yield.small-json/config: key/schema-aware metadata extraction with generated JSON excluded before extraction.code-doc: docstring/comment metadata only; never recursive source-tree ingestion.
- Extract deterministically. Tools, not an LLM, do the bulk copy. (LLM bulk extraction yielded ~2% coverage — never the bulk path.)
- Record yield. Write
extraction_yieldafter extraction (pages/tables actually produced, % of estimate). - Flag shortfall. If
yield << estimate, mark the sourceextraction: shallowand queue it for a different recipe. Do not let it pass as "done."
Verification
- Frontmatter has BOTH
extraction_estimate(pre) andextraction_yield(post); a validator script rejects a page missing either. - Sources flagged
shallowappear in the re-extraction backlog, not the trusted set. - Generated/repetitive JSON and source-tree noise are exclusions, not shallow extraction failures.
Cleanup
- Raw source never copied into any repo; only derived parts + a
sources:sha256 pointer.
Incident appendix
| Rule | Why |
|---|---|
| Estimate before, yield after | The 2%-coverage loss was invisible until the pair made it loud |
| Classify on structure not name | D4: sheet/file names misclassify content |
| OCR output is a claim | doc 11: scanned text is interpretation, enters the provisional gate |