"""
CamelotCorrespondenceExtractor — the rasterized page is the arbiter of
what is a table and where. Per page:

1. Extract, then detect: Camelot lattice and stream run on the CPU over
   the whole document first. Then the detector agent reads each page
   image, concurrently across pages, and returns the real tables, top to
   bottom, each with a rough box and a description.
2. Correspondence: assign Camelot chunks to detected tables by 2D bbox
   overlap. Lattice is tried first (trusted source); stream is the
   fallback for tables no lattice chunk matched. One chunk that is the
   best match for two-or-more tables -> combined (kept whole, flagged,
   never split). A table whose best chunk is truncated is completed from
   the leftover (orphan) chunks in step 3. Matching is deterministic —
   no LLM reads the cell values.
3. Assemble + completeness audit: join a table's matched chunks in order,
   then check the assembled data against the page's text layer (the same
   source Camelot reads) within the table's region. A value-like figure in
   the region's columns that is absent from the assembled data -> extend
   with the next leftover chunk and re-audit. When the leftover chunks run
   out, the missing figures are filled into the grid from the page text
   layer, recorded as `filled_cells`, and the table is re-audited. The gap
   is reported only if the table is still incomplete.

Report, don't drop (with guarded recovery): a detected table neither
flavor produced gets up to two targeted, region-constrained stream passes.
The first aims at the detector's box. If that yields nothing, the grid
locator relocates the table and the second aims at its region. If either
yields data the table is emitted as extracted; otherwise it is emitted
with status `detected_not_extracted` — reported explicitly, never
silently dropped.

Camelot's grid is the value source. The text-layer fill adds figures to
it and records each one as provenance. When a structure correction is
accepted, the emitted markdown is the LLM's, and the grounding guard
holds its numbers to the grid or the page text layer. State is in-memory
for the length of a run; there is no database.

The package is split by what a reader needs in view at once:

- `orchestrator` — constructor defaults, the per-page
  flow (detect, assign, recover, audit/extend/fill, emit), and the
  public `extract_tables` / `extract_tables_sync`.
- `geometry` — coordinate-frame conversions (Camelot points, detector
  0..1, top-left points) and region slicing (text-layer words, image
  crop). Deterministic; no LLM, no Camelot.
- `matching` — the argmax chunk-to-table assignment, combined-chunk
  inversion, orphan queue, and grid assembly.
- `recovery` — the targeted region-constrained stream pass and the
  grid-locator region pairing.
- `correction` — output-stage structure vetting against the cropped
  table image, with the grounding guard that, when `ground_values` is on,
  rejects any value absent from both Camelot's grid and the page text
  layer.

The Camelot layer (page rendering, both flavors in spawn-context
subprocesses, content-empty shell detection) is shared with the
camelot.llm extractor and lives in
`quber.core.extractors.camelot.acquire`.
"""

from quber.core.extractors.camelot.correspondence.orchestrator import CamelotCorrespondenceExtractor

__all__ = ["CamelotCorrespondenceExtractor"]
