feat: text-layer grounding (extractor authority, guard rescue tier, verifier oracle + hi-DPI crops)
- backend/text_layer.py: PyMuPDF text-layer extraction, fuzzy evidence
bbox matching, 300-DPI crop rendering, coverage-gap signal
- extractor (classic + agent): TEXT LAYER block appended at call sites;
grounding guard gains text-layer rescue tier (grounding=text_layer stamp)
- verifier: {text_layer} oracle excerpt + evidence-located hi-DPI crops
replacing full-page images (fallback preserved, I2 guard intact)
- coverage gaps: text-bearing pages with zero extraction -> failed-scope
gap findings (agent) / log-only (classic)
- config knobs: TEXT_LAYER_ENABLED/MIN_CHARS/MAX_CHARS, VERIFY_TEXT_MAX_CHARS,
VERIFY_HI_DPI_CROPS, VERIFY_CROP_DPI, VERIFY_CROP_MARGIN_PTS
- tests: 22 new (text_layer unit, grounding/render, runner-level flow)
Spec: docs/superpowers/specs/2026-08-12-text-layer-grounding-design.md
This commit is contained in:
+4
-1
@@ -230,6 +230,7 @@ Rules you must never break:
|
||||
- Every object must include source_text copied verbatim from the sheet whenever text is available.
|
||||
- If the object is graphical and has no text, describe it visually and mark confidence low or medium.
|
||||
- Preserve tags, marks, room numbers, sheet numbers, detail references, and abbreviations exactly as shown.
|
||||
TEXT LAYER GROUNDING: when a TEXT LAYER block is present in the user message, it is the sheet's deterministic PDF text layer and is authoritative for alphanumeric content (counts, dimensions, member tags, note text). Trust it over your reading of the image for numbers, tags, and note text; quote source_text from it verbatim. Use the image for geometry, symbols, linework, and anything absent from the text layer.
|
||||
- Use null when information is not determinable.
|
||||
- Keep objects atomic.
|
||||
- Use plain ASCII only.
|
||||
@@ -467,7 +468,9 @@ Respond only with valid JSON."""
|
||||
VERIFY_USER_INSTRUCTION = """Verify this finding's evidence against the attached sheet images.
|
||||
Respond ONLY with a valid JSON object - no markdown fences, no explanation:
|
||||
{ "verdicts": [ { "sheet": "string", "source_text": "the evidence text judged", "verdict": "confirmed | corrected | not_found", "actual_text": "verbatim sheet text when corrected, else null", "notes": "string or null" } ] }
|
||||
Finding: {finding}"""
|
||||
Finding: {finding}
|
||||
TEXT LAYER (deterministic page text extracted from the PDF - an oracle for alphanumeric content such as counts, dimensions, and member tags; when it disagrees with the extracted evidence, trust it and cite it as actual_text):
|
||||
{text_layer}"""
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user