Reference for the public Python surface. Generated from docstrings with mkdocstrings.
Package¶
parsecraft
¶
parsecraft package.
Modules:
-
__about__–Version information for ParseCraft.
-
__main__–Entry point for ParseCraft CLI.
-
adapters–Adapters: parse external inputs (Markdown, HTML, ...) into the canonical IR.
-
assets–Model-asset manager: pinned downloads, cache, license records.
-
backends–Backend protocol + registry — the extension surface of ParseCraft.
-
benchmark–Reproducible backend benchmarks over local documents (Phase 2 harness).
-
cache–Content-addressed conversion cache (keyed
DocumentResultstorage). -
cli–CLI module for ParseCraft.
-
config–Generic, self-contained configuration engine (Route A).
-
environment–Detected host environment — the bridge into
parsecraft.routingplanning. -
ir–Canonical IR: typed structured chunks + deterministic Markdown projection.
-
pipeline–Auto-mode executor: analysis entry points and plan → pages dispatch.
-
providers–Judge providers — plug-in modules resolved by
routing.judge_providers. -
routing–Auto-mode routing: deterministic signal→intent planning with a judge seam.
IR — models and projection¶
ir
¶
Canonical IR: typed structured chunks + deterministic Markdown projection.
Modules:
-
markdown–Deterministic Markdown projection of the canonical IR.
-
models–Canonical intermediate representation for ParseCraft.
Classes:
-
AssetKind–Kind of an extracted asset.
-
BBox–Axis-aligned bounding box in source coordinates (points).
-
ChunkKind–Kind of a structured chunk.
-
ChunkRelation–Relation from one chunk to another chunk id.
-
CrossPageRelation–Relation between content on different pages.
-
DetectedRegion–A region detected on a page (layout signal, not yet content).
-
Diagnostic–A recorded, non-fatal observation about a page.
-
DiagnosticLevel–Severity of a diagnostic entry.
-
DocumentMetadata–Document-level metadata and reproducibility anchors.
-
DocumentResult–Root of the canonical IR — everything projections need.
-
ExtractedAsset–An asset extracted from a page (image, LaTeX source, CSV, ...).
-
FailureCode–Machine-readable cause of a structured pass failure.
-
PageRange–Inclusive 1-based page range.
-
PageResult–All extracted content of one page, in reading order.
-
PageSignal–Deterministic per-page analysis signal (planner input state).
-
PassFailure–Structured failure record — typed, never a bare string.
-
PassKind–Processing pass that produced or judged a result.
-
PassStatus–Outcome of a processing pass.
-
QualitySignal–Named quality score in [0, 1] attached to a chunk or document.
-
RegionKind–Kind of a detected page region.
-
RelationKind–Kind of chunk or cross-page relation.
-
SourceSpan–Character span in the original text source.
-
StructuredChunk–One typed content unit — the package's currency.
-
TraceEntry–One processing pass recorded in the document's trace.
Functions:
-
render_block–Render one chunk and its descendants to Markdown, depth-first in order.
-
render_page–Render one page: marker comment, then every block in reading order.
-
to_markdown–Project a full document to deterministic Markdown (trailing newline).
-
utcnow–Timezone-aware now — single home for timestamps in IR construction.
BBox
¶
Bases: _ValueModel
Axis-aligned bounding box in source coordinates (points).
ChunkRelation
¶
Bases: _ValueModel
Relation from one chunk to another chunk id.
CrossPageRelation
¶
Bases: BaseModel
Relation between content on different pages.
DetectedRegion
¶
Bases: BaseModel
A region detected on a page (layout signal, not yet content).
Diagnostic
¶
Bases: BaseModel
A recorded, non-fatal observation about a page.
DocumentMetadata
¶
Bases: BaseModel
Document-level metadata and reproducibility anchors.
DocumentResult
¶
Bases: BaseModel
Root of the canonical IR — everything projections need.
-
Reference
irto_markdown
ExtractedAsset
¶
Bases: BaseModel
An asset extracted from a page (image, LaTeX source, CSV, ...).
PageRange
¶
Bases: _ValueModel
Inclusive 1-based page range.
PageResult
¶
Bases: BaseModel
All extracted content of one page, in reading order.
-
Reference
irrender_page
PageSignal
¶
Bases: BaseModel
Deterministic per-page analysis signal (planner input state).
PassFailure
¶
Bases: _ValueModel
Structured failure record — typed, never a bare string.
QualitySignal
¶
Bases: _ValueModel
Named quality score in [0, 1] attached to a chunk or document.
SourceSpan
¶
Bases: _ValueModel
Character span in the original text source.
StructuredChunk
¶
Bases: BaseModel
One typed content unit — the package's currency.
kind decides how :func:parsecraft.ir.markdown.to_markdown renders
content; metadata carries kind-specific hints (e.g.
heading_level, language) as stringly-typed JSON-safe values.
-
Reference
irrender_block
TraceEntry
¶
Bases: BaseModel
One processing pass recorded in the document's trace.
render_block
¶
render_block(chunk: StructuredChunk) -> str
Render one chunk and its descendants to Markdown, depth-first in order.
Source code in src/parsecraft/ir/markdown.py
80 81 82 83 | |
render_page
¶
render_page(page: PageResult) -> str
Render one page: marker comment, then every block in reading order.
Source code in src/parsecraft/ir/markdown.py
73 74 75 76 77 | |
to_markdown
¶
to_markdown(result: DocumentResult) -> str
Project a full document to deterministic Markdown (trailing newline).
Source code in src/parsecraft/ir/markdown.py
66 67 68 69 70 | |
Backends — protocol and registry¶
backends
¶
Backend protocol + registry — the extension surface of ParseCraft.
Modules:
-
docling–Docling backend family — MIT layout-aware parsing (CPU, heavy extra).
-
errors–Backend subsystem exceptions.
-
liteparse–LiteParse backend family — Apache-2.0 document parsing, CPU-only.
-
native–Built-in native backends: dependency-light document parsers.
-
ocr–OCR / document-VLM backend family — light entry points, heavy impls.
-
pandoc–Pandoc backend family — office/ODF/EPUB/RTF conversion (ADR-0005).
-
protocol–Public backend protocol: what a backend is and what a request carries.
-
registry–Backend registry: explicit registration first, lazy entry-point discovery.
-
source–Shared
file://URI resolution for source documents.
Classes:
-
AnalysisResult–Output of
DocumentBackend.analyze— planner input state. -
BackendAlreadyRegisteredError–Raised when explicit registration collides with an existing name.
-
BackendCapabilities–Static, import-free facts about a backend.
-
BackendConfig–Per-instance backend configuration passed to the factory.
-
BackendDescriptor–What the registry hands out: identity + capabilities, no code.
-
BackendError–Base class for all backend subsystem errors.
-
BackendFactory–What registration accepts: a light module-level object.
-
BackendLoadError–Recorded failure to load an entry-point backend (stored, not raised).
-
BackendNotFoundError–Raised when a backend name is not registered.
-
BackendRef–Identity of the backend that produced a result (provenance anchor).
-
BackendRegistry–Name → (descriptor, factory) binding with lazy plugin discovery.
-
BackendResult–Converged IR output of
DocumentBackend.convert. -
ConversionRequest–Everything a backend may do — bounds live here, not in global state.
-
DependencyUnavailableError–A backend's optional implementation module is not installed.
-
DocumentBackend–A backend: analyzes a source and converts bounded slices of it.
-
ModelAssetDescriptor–Pinned model-asset metadata (license + reproducibility contract).
-
PageSignal–Deterministic per-page analysis signal (planner input state).
-
SourceDocument–A document handed to a backend: path-based or in-memory.
AnalysisResult
¶
Bases: BaseModel
Output of DocumentBackend.analyze — planner input state.
-
Reference
backendsDocumentBackendanalyze
BackendAlreadyRegisteredError
¶
BackendAlreadyRegisteredError(name: str)
Bases: BackendError
Raised when explicit registration collides with an existing name.
Source code in src/parsecraft/backends/errors.py
21 22 23 | |
BackendCapabilities
¶
Bases: BaseModel
Static, import-free facts about a backend.
BackendConfig
¶
Bases: BaseModel
Per-instance backend configuration passed to the factory.
-
Reference
backends
BackendDescriptor
¶
Bases: BaseModel
What the registry hands out: identity + capabilities, no code.
-
Reference
backendsBackendRegistry
BackendFactory
¶
Bases: Protocol
What registration accepts: a light module-level object.
descriptor must carry the registry name; __call__ is the only
place heavy imports may happen.
-
Reference
backendsBackendRegistryregister
Methods:
-
__call__–Build a backend instance for
config.
__call__
¶
__call__(config: BackendConfig) -> DocumentBackend
Build a backend instance for config.
Source code in src/parsecraft/backends/protocol.py
163 164 165 | |
BackendLoadError
¶
Bases: BackendError
Recorded failure to load an entry-point backend (stored, not raised).
Discovery never raises — one broken plugin must not brick the registry.
Instances surface via BackendRegistry.load_errors so callers can
report them explicitly.
-
Reference
backendsBackendRegistryload_errors
Source code in src/parsecraft/backends/errors.py
34 35 36 37 38 | |
BackendNotFoundError
¶
BackendNotFoundError(name: str)
Bases: BackendError
Raised when a backend name is not registered.
Source code in src/parsecraft/backends/errors.py
13 14 15 | |
BackendRef
¶
Bases: BaseModel
Identity of the backend that produced a result (provenance anchor).
BackendRegistry
¶
BackendRegistry()
Name → (descriptor, factory) binding with lazy plugin discovery.
Thread-safety: all registry state (factories, load_errors, the
discovery flag) is guarded by an internal re-entrant lock and discovery
runs single-flight. The lock is NEVER held across factory(config) —
heavy model loads run outside it, so lookups never stall behind a load.
Instances are caller-owned: no memoization, no sharing (see AGENTS.md).
Methods:
-
create–Instantiate backend
name— the first heavy-import boundary. -
fingerprint–Deterministic identity of the registered backend set — a cache key.
-
get–Descriptor for
name; raises :class:BackendNotFoundError. -
list_backends–All known descriptors, sorted by name (deterministic output).
-
register–Register
factoryundernameexplicitly (highest precedence). -
supported_formats–Sorted union of every registered backend's supported formats.
Attributes:
-
load_errors(dict[str, BackendLoadError]) –Copy of recorded entry-point failures — callers must surface these.
Source code in src/parsecraft/backends/registry.py
54 55 56 57 58 | |
load_errors
property
¶
load_errors: dict[str, BackendLoadError]
Copy of recorded entry-point failures — callers must surface these.
create
¶
create(name: str, config: BackendConfig | None = None) -> DocumentBackend
Instantiate backend name — the first heavy-import boundary.
A fresh, caller-owned instance per call (no memoization): residency
and VRAM admission belong to the caller, and the registry lock is
never held across factory(config) — a multi-minute model load
never blocks concurrent lookups or registrations.
Source code in src/parsecraft/backends/registry.py
115 116 117 118 119 120 121 122 123 124 | |
fingerprint
¶
fingerprint() -> str
Deterministic identity of the registered backend set — a cache key.
Derived from each backend's name, version, and supported formats: properties of the installed backend set, never host hardware. Two registries with the same backend set yield the same fingerprint on any machine; changing any backend's identity or formats changes it.
Source code in src/parsecraft/backends/registry.py
104 105 106 107 108 109 110 111 112 113 | |
get
¶
get(name: str) -> BackendDescriptor
Descriptor for name; raises :class:BackendNotFoundError.
Source code in src/parsecraft/backends/registry.py
90 91 92 93 94 95 96 97 | |
list_backends
¶
list_backends() -> list[BackendDescriptor]
All known descriptors, sorted by name (deterministic output).
Source code in src/parsecraft/backends/registry.py
84 85 86 87 88 | |
register
¶
register(name: str, factory: BackendFactory) -> None
Register factory under name explicitly (highest precedence).
Source code in src/parsecraft/backends/registry.py
62 63 64 65 66 67 68 69 70 71 72 73 74 | |
supported_formats
¶
Sorted union of every registered backend's supported formats.
Source code in src/parsecraft/backends/registry.py
99 100 101 102 | |
BackendResult
¶
Bases: BaseModel
Converged IR output of DocumentBackend.convert.
-
Reference
backendsDocumentBackendconvert
ConversionRequest
¶
Bases: BaseModel
Everything a backend may do — bounds live here, not in global state.
cancellation is polled for a True result; timeouts and budgets are
hard expectations a backend must honor or return a structured failure.
-
Reference
backendsDocumentBackendconvert
DependencyUnavailableError
¶
Bases: BackendError
A backend's optional implementation module is not installed.
Source code in src/parsecraft/backends/errors.py
44 45 46 47 | |
DocumentBackend
¶
Bases: Protocol
A backend: analyzes a source and converts bounded slices of it.
-
Reference
backends
Methods:
-
analyze–Collect deterministic signals without converting content.
-
convert–Convert the requested slice into canonical IR pages.
analyze
¶
analyze(source: SourceDocument) -> AnalysisResult
Collect deterministic signals without converting content.
Source code in src/parsecraft/backends/protocol.py
144 145 146 | |
convert
¶
convert(request: ConversionRequest) -> BackendResult
Convert the requested slice into canonical IR pages.
Source code in src/parsecraft/backends/protocol.py
148 149 150 | |
ModelAssetDescriptor
¶
Bases: BaseModel
Pinned model-asset metadata (license + reproducibility contract).
PageSignal
¶
Bases: BaseModel
Deterministic per-page analysis signal (planner input state).
SourceDocument
¶
Bases: BaseModel
A document handed to a backend: path-based or in-memory.
-
Reference
backendsDocumentBackendanalyze
CLI¶
cli
¶
CLI module for ParseCraft.
Modules:
-
app–Typer CLI app for ParseCraft.
-
args–CLI arguments, options, and flags for ParseCraft.
-
benchmark–parsecraft benchmark— reproducible reports over local documents. -
commands–CLI command implementations for ParseCraft.
-
config–Configuration diagnostic surface: schema, engine builder, and rendering.
-
convert–parsecraft convert— analyze, route, execute, render the IR. -
errors–Shared CLI error type: a message plus the process exit code to use.
-
inspect–parsecraft inspect— per-page analysis signals plus a routing preview. -
models–parsecraft models— inspect and manage the pinned model-asset cache.