Skip to content

Document Parser SDK and Format Router Architecture ​

6. Core Data Structures ​

Every parser produces a ParsedDocument composed of DocumentElement and DocumentTree records so that 40 byte WRL Chunker matches trace back to exact source byte offsets, line ranges, pages, and sections:

Type or StructKey FieldsPurpose
DocumentMetadocument_sha256: str, mime_type: str | None, filename: str | None, suffix: strCoordinator supplied document identity envelope passed to /parse.
EnvelopeElementid: str, element_type: str, content: str, source_start_offset: int | None, source_end_offset: int | None, source_start_line: int | None, source_end_line: int | NoneStructural block carrying exact 0 based, end exclusive UTF 8 byte and line spans.
TreeNodeid: str, node_type: str, title: str | None, content: str, level: int, source_start_offset: int | None, source_end_offset: int | None, children: list[TreeNode]Hierarchical tree node used by ingest_core for WRL chunking and fallback gate evaluation.
ParsedDocumentid: Uuid, metadata: DocumentMetadata, elements: list[DocumentElement], structure: DocumentStructure, document_tree: DocumentTree | NoneComplete parse output persisted to shared-storage and indexed into rbix.
EnrichmentResultadded_elements: list[DocumentElement], annotations: dict[Uuid, list[Annotation]], additional_metadata: dict[str, Any], stage_metrics: StageMetricsAdditive enrichment payload emitted by gliner2_runner or custom enrichers.

7. Python SDK Reference (pycaber.parser_sdk) ​

The Python SDK (packages/pycaber_parser and pycaber.parser_sdk) exposes callback registration hooks and the multi process WorkerSupervisor server:

  • pycaber.parser_sdk.register_parser(callback): Registers callback(file_path: str, config: dict) -> dict | str invoked on POST /parse.
  • pycaber.parser_sdk.register_enricher(callback): Registers callback(document_json_path: str, config: dict) -> dict | str invoked on POST /enrich.
  • pycaber.parser_sdk.serve(config=None, port=None): Starts the Axum and Tokio HTTP container server (default port 8081), releasing the Python GIL during network I/O.
  • pycaber.parser_sdk.serve_worker_supervisor(capabilities, config=None, port=None, python_path=None, scripts_dir=None, default_capability=None): Launches the fault tolerant multi process WorkerSupervisor (start_tolerant) supporting capabilities [("docling", "docling_runner"), ("markdown", "markdown_runner"), ("gliner2", "gliner2_runner"), ("metadata", "metadata_runner")].

8. Container HTTP REST Wire Protocol (schema_version: "4.2") ​

MethodEndpointRequest PayloadSuccess ResponseStatus CodesDescription
POST/parseParseRequest (handle, doc, config)ParseResponse (document, metrics)200, 400, 500, 503Primary structural and byte span extraction endpoint.
POST/enrichEnrichRequest (document, handle, doc, config)EnrichResponse (result, metrics)200, 400, 500, 503Additive NER (gliner2) and metadata enrichment endpoint.
GET/healthNoneHealthStatus (healthy, capabilities)200, 503Liveness and per capability readiness probe.
GET/manifestNoneParserManifest200Declares supported formats, capabilities, and GPU requirements.