Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
test: validate snapshot wheels and deterministic rendering failures
myhlolic42b88469f8c
diff --git a/.github/workflows/docvortex-boundary.yml b/.github/workflows/docvortex-boundary.ymlindex 263a9821..13b7ea3f 100644--- a/.github/workflows/docvortex-boundary.yml+++ b/.github/workflows/docvortex-boundary.yml@@ -167,7 +167,7 @@ jobs:assert any(path.is_relative_to(root) for root in site_roots), (name, path, site_roots)info = backend_info()assert info["backend"] == "rust", info- assert native.PROTOCOL_VERSION >= 11 and info["protocol"] == native.PROTOCOL_VERSION, info+ assert native.PROTOCOL_VERSION >= 12 and info["protocol"] == native.PROTOCOL_VERSION, infoassert info["extension_sha256"] == hashlib.sha256(origins["native"].read_bytes()).hexdigest(), infoartifact = json.loads(Path(".boundary/engine-artifact.json").read_text(encoding="utf-8"))distribution = importlib.metadata.distribution("docvortex")@@ -243,7 +243,7 @@ jobs:- name: Verify public contracts and deterministic inference replayrun: |if [[ -f .venv/Scripts/activate ]]; then source .venv/Scripts/activate; else source .venv/bin/activate; fi- python -I -m pytest -q -o addopts='' --import-mode=importlib \+ python -I -m pytest -q -o addopts='' -o pythonpath=tests/unittest --import-mode=importlib \tests/unittest/test_docvortex_import_boundary.py \tests/unittest/test_backend_architecture.py \tests/unittest/test_docvortex_protocol.py \@@ -256,6 +256,7 @@ jobs:tests/unittest/test_pdf_cpu_reuse.py \tests/unittest/test_pdf_memory_lifecycle.py \tests/unittest/test_pdf_render_session_integration.py \+ tests/unittest/test_pdf_window_snapshots.py \tests/unittest/test_flash_pdf_render_scheduling.py \tests/unittest/test_process_heap_memory.py- name: Retain exact wheel and installation evidencediff --git a/tests/unittest/test_pdf_analyze_visual_blocks.py b/tests/unittest/test_pdf_analyze_visual_blocks.pyindex 5517746e..4e5a09e1 100644--- a/tests/unittest/test_pdf_analyze_visual_blocks.py+++ b/tests/unittest/test_pdf_analyze_visual_blocks.py@@ -1747,6 +1747,21 @@ def test_doc_analyze_flash_returns_complete_model_json_and_typed_middle_json(monevents.append("attach_visual")original_attach_visual_block_images(*args, **kwargs) # type: ignore[arg-type]+ def fake_render_crops(+ pdf_bytes, prepared_pages, start_page_id, end_page_id, timeout=None, threads=None, *, session=None+ ):+ """在当前裁图进程边界提供固定页图,保留真实编码、窗口顺序与释放断言。"""+ page_images = fake_load_images_for_window(+ pdf_bytes, start_page_id=start_page_id, end_page_id=end_page_id,+ image_type="pil_img", timeout=timeout, threads=threads,+ )+ try:+ tracked_attach_visual_block_images(prepared_pages, page_images, start_page_id)+ return [[(index, block.get("image_base64")) for index, block in page] for page in prepared_pages]+ finally:+ for item in page_images:+ item["img_pil"].close()+original_normalize_model_list = normalization._normalize_pdf_model_listdef tracked_normalize_model_list(model_list: list[list[dict[str, object]]]) -> None:@@ -1765,6 +1780,7 @@ def test_doc_analyze_flash_returns_complete_model_json_and_typed_middle_json(monmonkeypatch.setattr(pipeline, "PDFDocument", lambda _: fake_pdf_doc)monkeypatch.setattr(window, "_configured_window_size", lambda default: 2)monkeypatch.setattr("docvortex.document.pdf.images.load_images_from_pdf_bytes_range", fake_load_images_for_window)+ monkeypatch.setattr("docvortex.document.pdf.images._load_visual_crops_from_pdf_bytes_range", fake_render_crops)monkeypatch.setattr(visuals, "_attach_prepared_visual_block_images", tracked_attach_visual_block_images)monkeypatch.setattr(pipeline, "_normalize_pdf_model_list", tracked_normalize_model_list)monkeypatch.setattr(pipeline.time, "perf_counter", fake_perf_counter)diff --git a/tests/unittest/test_pdf_render_session_integration.py b/tests/unittest/test_pdf_render_session_integration.pyindex c2992d9d..9343084d 100644--- a/tests/unittest/test_pdf_render_session_integration.py+++ b/tests/unittest/test_pdf_render_session_integration.py@@ -134,11 +134,22 @@ def test_async_cancel_reclaims_session_and_pixels(pdf_input: bytes, model_stub:assert states and states[0].images_list == [] and (states[0].np_images == [])-def test_host_timeout_closes_document_session(pdf_input: bytes, model_stub: SimpleNamespace) -> None:+def test_host_timeout_closes_document_session(+ pdf_input: bytes, model_stub: SimpleNamespace, monkeypatch: pytest.MonkeyPatch+) -> None:"""宿主 timeout 显式传到引擎,失败清理会话而非静默回退。"""with PDFDocument(pdf_input) as document:+ session = document.get_render_session()+ session.render(image_type="base64_img")+ receive = session._receive++ def expired_response(worker, request_id, deadline, **kwargs):+ """用确定过期的响应截止时间覆盖各平台时钟粒度,保留真实失败清理。"""+ return receive(worker, request_id, float("-inf"), **kwargs)++ monkeypatch.setattr(session, "_receive", expired_response)with pytest.raises(TimeoutError):- images.load_images_from_pdf_bytes_range(pdf_input, document=document, timeout=1e-09)+ images.load_images_from_pdf_bytes_range(pdf_input, document=document, timeout=1.0)assert document.get_render_session()._closed