Turn any document into clean, AI-ready Markdown. Local-first desktop app: reads scanned PDFs, batches folders, runs offline, and uses far fewer tokens than vision models.
Python desktop-appdocument-conversionllmlocal-firstmarkdownmarkitdownocrofflinepdf-to-markdownragrustsveltetauri
fix: validate OCR in locked release runtimes (#46)
Muhammad Ibrahime58d41953957
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex fe04f83..b292ab3 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -79,7 +79,9 @@ jobs:- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86with:enable-cache: true- cache-dependency-glob: app/src-tauri/resources/sidecar/requirements.lock+ cache-dependency-glob: |+ app/src-tauri/resources/sidecar/requirements.lock+ app/src-tauri/resources/sidecar/requirements-ocr.lock- name: Install sidecar test dependenciesshell: pwshrun: |@@ -91,6 +93,14 @@ jobs:- name: Run sidecar testsshell: pwshrun: '& $env:PYTHON -m unittest discover -s tests -p "test_*.py"'+ - name: Run locked OCR integration tests+ shell: pwsh+ env: { MDFLUX_REQUIRE_OCR_TESTS: "1" }+ run: |+ uv venv --python 3.12 .venv-ocr-ci+ $python = (Resolve-Path .venv-ocr-ci/Scripts/python.exe).Path+ uv pip install --python $python --require-hashes -r requirements-ocr.lock+ & $python -m unittest tests.test_ocr_runtimesidecar-linux:name: CI / Sidecar Linux@@ -103,7 +113,9 @@ jobs:- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86with:enable-cache: true- cache-dependency-glob: app/src-tauri/resources/sidecar/requirements.lock+ cache-dependency-glob: |+ app/src-tauri/resources/sidecar/requirements.lock+ app/src-tauri/resources/sidecar/requirements-ocr.lock- name: Install sidecar test dependenciesrun: |uv python install 3.12@@ -113,6 +125,12 @@ jobs:echo "PYTHON=$PYTHON" >> "$GITHUB_ENV"- name: Run sidecar testsrun: '$PYTHON -m unittest discover -s tests -p "test_*.py"'+ - name: Run locked OCR integration tests+ env: { MDFLUX_REQUIRE_OCR_TESTS: "1" }+ run: |+ uv venv --python 3.12 .venv-ocr-ci+ uv pip install --python .venv-ocr-ci/bin/python --require-hashes -r requirements-ocr.lock+ .venv-ocr-ci/bin/python -m unittest tests.test_ocr_runtimedependency-drift:name: CI / Dependency Driftdiff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.ymlindex ed59d6b..6428e54 100644--- a/.github/workflows/release-candidate.yml+++ b/.github/workflows/release-candidate.yml@@ -114,7 +114,9 @@ jobs:- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86with:enable-cache: true- cache-dependency-glob: app/src-tauri/resources/sidecar/requirements.lock+ cache-dependency-glob: |+ app/src-tauri/resources/sidecar/requirements.lock+ app/src-tauri/resources/sidecar/requirements-ocr.lock- name: Install and test sidecarshell: pwshrun: |@@ -123,6 +125,11 @@ jobs:$python = (Resolve-Path .venv-ci/Scripts/python.exe).Pathuv pip install --python $python --require-hashes -r requirements.lock& $python -m unittest discover -s tests -p "test_*.py"+ uv venv --python 3.12 .venv-ocr-ci+ $ocrPython = (Resolve-Path .venv-ocr-ci/Scripts/python.exe).Path+ uv pip install --python $ocrPython --require-hashes -r requirements-ocr.lock+ $env:MDFLUX_REQUIRE_OCR_TESTS = "1"+ & $ocrPython -m unittest tests.test_ocr_runtimesidecar-linux:name: RC / Sidecar Linux@@ -138,7 +145,9 @@ jobs:- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86with:enable-cache: true- cache-dependency-glob: app/src-tauri/resources/sidecar/requirements.lock+ cache-dependency-glob: |+ app/src-tauri/resources/sidecar/requirements.lock+ app/src-tauri/resources/sidecar/requirements-ocr.lock- name: Install and test sidecarrun: |uv python install 3.12@@ -146,6 +155,9 @@ jobs:PYTHON="$PWD/.venv-ci/bin/python"uv pip install --python "$PYTHON" --require-hashes -r requirements.lock"$PYTHON" -m unittest discover -s tests -p "test_*.py"+ uv venv --python 3.12 .venv-ocr-ci+ uv pip install --python .venv-ocr-ci/bin/python --require-hashes -r requirements-ocr.lock+ MDFLUX_REQUIRE_OCR_TESTS=1 .venv-ocr-ci/bin/python -m unittest tests.test_ocr_runtimedependency-drift:name: RC / Dependency Driftdiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex c3d2ec1..79589e9 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -104,6 +104,11 @@ jobs:with:ref: "${{ needs.validate-tag.outputs.commit }}"- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86+ with:+ enable-cache: true+ cache-dependency-glob: |+ app/src-tauri/resources/sidecar/requirements.lock+ app/src-tauri/resources/sidecar/requirements-ocr.lock- name: Install and test sidecarshell: pwshrun: |@@ -112,6 +117,11 @@ jobs:$python = (Resolve-Path .venv-ci/Scripts/python.exe).Pathuv pip install --python $python --require-hashes -r requirements.lock& $python -m unittest discover -s tests -p "test_*.py"+ uv venv --python 3.12 .venv-ocr-ci+ $ocrPython = (Resolve-Path .venv-ocr-ci/Scripts/python.exe).Path+ uv pip install --python $ocrPython --require-hashes -r requirements-ocr.lock+ $env:MDFLUX_REQUIRE_OCR_TESTS = "1"+ & $ocrPython -m unittest tests.test_ocr_runtimesidecar-linux:name: Release / Sidecar Linux@@ -123,6 +133,11 @@ jobs:with:ref: "${{ needs.validate-tag.outputs.commit }}"- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86+ with:+ enable-cache: true+ cache-dependency-glob: |+ app/src-tauri/resources/sidecar/requirements.lock+ app/src-tauri/resources/sidecar/requirements-ocr.lock- name: Install and test sidecarrun: |uv python install 3.12@@ -130,6 +145,9 @@ jobs:PYTHON="$PWD/.venv-ci/bin/python"uv pip install --python "$PYTHON" --require-hashes -r requirements.lock"$PYTHON" -m unittest discover -s tests -p "test_*.py"+ uv venv --python 3.12 .venv-ocr-ci+ uv pip install --python .venv-ocr-ci/bin/python --require-hashes -r requirements-ocr.lock+ MDFLUX_REQUIRE_OCR_TESTS=1 .venv-ocr-ci/bin/python -m unittest tests.test_ocr_runtimedependency-drift:name: Release / Dependency Driftdiff --git a/app/src-tauri/resources/sidecar/ocr.py b/app/src-tauri/resources/sidecar/ocr.pyindex 1d478ae..9c49df0 100644--- a/app/src-tauri/resources/sidecar/ocr.py+++ b/app/src-tauri/resources/sidecar/ocr.py@@ -8,6 +8,7 @@ pypdfium2 rasterises PDF pages for OCR.import importlib.utilimport osimport tempfile+from pathlib import PathIMAGE_EXTENSIONS: frozenset[str] = frozenset({".jpg", ".jpeg", ".png", ".gif", ".webp",@@ -42,23 +43,24 @@ def _make_engine(intra_op_threads: int = 0):concurrent batch workers don't oversubscribe the CPU."""n = int(intra_op_threads or 0)if importlib.util.find_spec("rapidocr") is not None:+ import rapidocrfrom rapidocr import RapidOCR- # Pin v6 small explicitly. RapidOCR 3.9+ already defaults here; we do not- # want a later wheel silently switching to medium (slower, +108 MB, worse det).++ # OmegaConf versions used by RapidOCR reject pathlib.Path values before+ # 2.2. RapidOCR normally assigns a Path to this setting during startup,+ # so set the bundled model directory explicitly as a plain string. Keep+ # this defensive conversion even with the >=2.3 dependency floor.+ models_dir = str(Path(rapidocr.__file__).resolve().parent / "models")params: dict = {"Global.log_level": "warning",- "Det.ocr_version": "PP-OCRv6",- "Det.model_type": "small",- "Rec.ocr_version": "PP-OCRv6",- "Rec.model_type": "small",+ "Global.model_root_dir": models_dir,}if n > 0:params["EngineConfig.onnxruntime.intra_op_num_threads"] = nparams["EngineConfig.onnxruntime.inter_op_num_threads"] = n- try:- return RapidOCR(params=params)- except Exception: # noqa: BLE001 — older/newer keys; use defaults- return RapidOCR()+ # RapidOCR 3.9 defaults to PP-OCRv6/small. Its Det./Rec version and model+ # type settings require Enum objects, so do not pass string lookalikes.+ return RapidOCR(params=params)from rapidocr_onnxruntime import RapidOCRif n > 0:diff --git a/app/src-tauri/resources/sidecar/requirements-full.lock b/app/src-tauri/resources/sidecar/requirements-full.lockindex 48ce019..c38e821 100644--- a/app/src-tauri/resources/sidecar/requirements-full.lock+++ b/app/src-tauri/resources/sidecar/requirements-full.lock@@ -1,9 +1,12 @@# This file was autogenerated by uv via the following command:-# uv pip compile requirements-full.in --universal --python-version 3.12 --generate-hashes --only-binary :all: --output-file requirements-full.lock+# uv pip compile requirements-full.in --universal --python-version 3.12 --generate-hashes --only-binary :all: --no-binary antlr4-python3-runtime --output-file requirements-full.lockannotated-types==0.8.0 \--hash=sha256:13b2beaad985e05e2d6407ee4c4f35590b11f8d693a258a561055cac8f64cab7 \--hash=sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0# via pydantic+antlr4-python3-runtime==4.9.3 \+ --hash=sha256:f224469b4168294902bb1efa80a8bf7855f24c99aef99cbefc1bcd3cce77881b+ # via omegaconfanyio==4.14.2 \--hash=sha256:9f505dda5ac9f0c8309b5e8bd445a8c2bf7246f3ce950121e45ea15bc41d1494 \--hash=sha256:cfa139f3ed1a23ee8f88a145ddb5ac7605b8bbfd8592baacd7ce3d8bb4313c7f@@ -883,10 +886,12 @@ numpy==2.5.2 \# pandas# rapidocr# shapely-omegaconf==2.0.6 \- --hash=sha256:92ca535a788d21651bf4c2eaf5c1ca4c7a8003b2dab4a87cbb09109784268806 \- --hash=sha256:9e349fd76819b95b47aa628edea1ff83fed5b25108608abdd6c7fdca188e302a- # via rapidocr+omegaconf==2.3.1 \+ --hash=sha256:3d701d14e9a8828f1edd28bb70b725908b34277cdd72cf7d6a83f94dadc6b6a0 \+ --hash=sha256:e5e7de64aeebeddaf8e6d3f7a783b32ac2a01c0fbd9c878012caecb891a1f42a+ # via+ # -r requirements-ocr.in+ # rapidocronnxruntime==1.29.0 \--hash=sha256:07c5907474dec4a2792fd7626b753dc66707808385a6d9eecf993db0066a9d0f \--hash=sha256:0d4f427afac434b0070fe992b540ddf20a7aff2265f760f314d91331935b6b98 \@@ -1503,7 +1508,6 @@ typing-extensions==4.16.0 \# anyio# beautifulsoup4# huggingface-hub- # omegaconf# openai# pydantic# pydantic-corediff --git a/app/src-tauri/resources/sidecar/requirements-ocr.in b/app/src-tauri/resources/sidecar/requirements-ocr.inindex e038e35..df87779 100644--- a/app/src-tauri/resources/sidecar/requirements-ocr.in+++ b/app/src-tauri/resources/sidecar/requirements-ocr.in@@ -1,3 +1,4 @@rapidocr>=3.9.2,<4+omegaconf>=2.3,<2.4.0.dev0onnxruntime>=1.29,<2pypdfium2>=5.13diff --git a/app/src-tauri/resources/sidecar/requirements-ocr.lock b/app/src-tauri/resources/sidecar/requirements-ocr.lockindex 63a19d2..48b798e 100644--- a/app/src-tauri/resources/sidecar/requirements-ocr.lock+++ b/app/src-tauri/resources/sidecar/requirements-ocr.lock@@ -1,5 +1,10 @@# This file was autogenerated by uv via the following command:-# uv pip compile requirements-ocr.in --constraint requirements-full.lock --universal --python-version 3.12 --generate-hashes --only-binary :all: --output-file requirements-ocr.lock+# uv pip compile requirements-ocr.in --constraint requirements-full.lock --universal --python-version 3.12 --generate-hashes --only-binary :all: --no-binary antlr4-python3-runtime --output-file requirements-ocr.lock+antlr4-python3-runtime==4.9.3 \+ --hash=sha256:f224469b4168294902bb1efa80a8bf7855f24c99aef99cbefc1bcd3cce77881b+ # via+ # -c requirements-full.lock+ # omegaconfcertifi==2026.7.22 \--hash=sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775 \--hash=sha256:741e2c3b351ddf169a738da9f2c048608ff7f2c5cc02f1ebc6b118bb090d5d55@@ -279,11 +284,12 @@ numpy==2.5.2 \# opencv-python# rapidocr# shapely-omegaconf==2.0.6 \- --hash=sha256:92ca535a788d21651bf4c2eaf5c1ca4c7a8003b2dab4a87cbb09109784268806 \- --hash=sha256:9e349fd76819b95b47aa628edea1ff83fed5b25108608abdd6c7fdca188e302a+omegaconf==2.3.1 \+ --hash=sha256:3d701d14e9a8828f1edd28bb70b725908b34277cdd72cf7d6a83f94dadc6b6a0 \+ --hash=sha256:e5e7de64aeebeddaf8e6d3f7a783b32ac2a01c0fbd9c878012caecb891a1f42a# via# -c requirements-full.lock+ # -r requirements-ocr.in# rapidocronnxruntime==1.29.0 \--hash=sha256:07c5907474dec4a2792fd7626b753dc66707808385a6d9eecf993db0066a9d0f \@@ -663,12 +669,6 @@ tqdm==4.70.0 \# via# -c requirements-full.lock# rapidocr-typing-extensions==4.16.0 \- --hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8 \- --hash=sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5- # via- # -c requirements-full.lock- # omegaconfurllib3==2.7.0 \--hash=sha256:231e0ec3b63ceb14667c67be60f2f2c40a518cb38b03af60abc813da26505f4c \--hash=sha256:9fb4c81ebbb1ce9531cce37674bbc6f1360472bc18ca9a553ede278ef7276897diff --git a/app/src-tauri/resources/sidecar/tests/test_ocr_runtime.py b/app/src-tauri/resources/sidecar/tests/test_ocr_runtime.pynew file mode 100644index 0000000..2f48908--- /dev/null+++ b/app/src-tauri/resources/sidecar/tests/test_ocr_runtime.py@@ -0,0 +1,56 @@+from __future__ import annotations++import importlib.util+import os+import sys+import tempfile+import unittest+from pathlib import Path+++SIDECAR_DIR = Path(__file__).resolve().parents[1]+if str(SIDECAR_DIR) not in sys.path:+ sys.path.insert(0, str(SIDECAR_DIR))++OCR_AVAILABLE = importlib.util.find_spec("rapidocr") is not None+++def setUpModule() -> None:+ if os.environ.get("MDFLUX_REQUIRE_OCR_TESTS") == "1" and not OCR_AVAILABLE:+ raise AssertionError("Locked OCR integration tests require rapidocr")++[email protected](OCR_AVAILABLE, "rapidocr is not installed in the core test environment")+class LockedOcrRuntimeTests(unittest.TestCase):+ def test_image_and_scanned_pdf_ocr(self) -> None:+ from PIL import Image, ImageDraw, ImageFont++ import ocr++ with tempfile.TemporaryDirectory(prefix="mdflux-ocr-test-") as tmp:+ root = Path(tmp)+ image_path = root / "ocr-test.png"+ pdf_path = root / "ocr-test-scanned.pdf"+ image = Image.new("RGB", (1400, 360), "white")+ font = ImageFont.load_default(size=72)+ ImageDraw.Draw(image).text(+ (60, 120),+ "MDFlux OCR integration test 2026",+ fill="black",+ font=font,+ stroke_width=1,+ )+ image.save(image_path)+ image.save(pdf_path, "PDF", resolution=150.0)++ image_text = ocr.ocr_image(str(image_path), intra_op_threads=1)+ self.assertTrue(image_text.strip(), "Image OCR returned no text")++ self.assertTrue(ocr.is_scanned_pdf(str(pdf_path)))+ pdf_text = ocr.ocr_pdf(str(pdf_path), intra_op_threads=1)+ self.assertTrue(pdf_text.strip(), "Scanned-PDF OCR returned no text")+ self.assertIn("## Page 1", pdf_text)+++if __name__ == "__main__":+ unittest.main()diff --git a/docs/cross-platform/releases-and-verification.md b/docs/cross-platform/releases-and-verification.mdindex 90a9ad1..072e7cf 100644--- a/docs/cross-platform/releases-and-verification.md+++ b/docs/cross-platform/releases-and-verification.md@@ -96,8 +96,10 @@ Optional flags:- `--keep-temp`: retain the extraction directory for debuggingThe verifier checks layout, `resources/edition.json`, dependency lock checksum, bundled Python-(Full), core/OCR/audio imports (Full), sidecar health, sample conversions, and confirms Full-does not write a provisioned runtime into application data.+(Full), core/OCR/audio imports (Full), sidecar health, sample conversions, real image and+scanned-PDF OCR (Full), and confirms Full does not write a provisioned runtime into application+data. CI also installs the locked OCR dependency set separately on Windows and Linux and runs+the same two OCR paths, protecting Lite's optional OCR installation.> Use the verifier version available in your checkout for CI and local checks.@@ -117,6 +119,7 @@ Every archive includes `resources/edition.json` (schema version 1) with `edition| Bundled interpreter present | No | Yes || Sidecar health request | Yes | Yes || Sample conversions | Yes | Yes |+| Image and scanned-PDF OCR | Locked-runtime CI | Yes || No runtime provisioning into app data | N/A | Yes |**Pending:** end-to-end verification reports for all four archives on clean Windows and Ubuntudiff --git a/scripts/make-portable-full.ps1 b/scripts/make-portable-full.ps1index 949bf7e..0788d60 100644--- a/scripts/make-portable-full.ps1+++ b/scripts/make-portable-full.ps1@@ -42,6 +42,11 @@ try {New-Item -ItemType Directory -Force -Path $stage | Out-NullCopy-Item -LiteralPath $exe -Destination (Join-Path $stage "MDFlux.exe")Copy-Item -LiteralPath $resources -Destination $stage -Recurse+ $stagedSidecar = Join-Path $stage "resources\sidecar"+ if (Test-Path -LiteralPath $stagedSidecar) {+ Remove-Item -LiteralPath $stagedSidecar -Recurse -Force+ }+ Copy-Item -LiteralPath $sidecarDir -Destination (Join-Path $stage "resources") -Recurse$runtime = Join-Path $stage "resources\runtime"New-Item -ItemType Directory -Force -Path $runtime | Out-NullCopy-Item -Path (Join-Path $pythonRoot '*') -Destination $runtime -Recurse -Forcediff --git a/scripts/make-portable.ps1 b/scripts/make-portable.ps1index 8eb5177..e2f4507 100644--- a/scripts/make-portable.ps1+++ b/scripts/make-portable.ps1@@ -5,6 +5,7 @@ $ErrorActionPreference = "Stop". (Join-Path $PSScriptRoot "windows\portable-common.ps1")$root = Split-Path -Parent $PSScriptRoot$tauriDir = Join-Path $root "app\src-tauri"+$sidecarDir = Join-Path $tauriDir "resources\sidecar"$releaseDir = Join-Path $tauriDir "target\release"$dist = Join-Path $root "dist"$fullLock = Join-Path $tauriDir "resources\sidecar\requirements-full.lock"@@ -29,6 +30,11 @@ try {New-Item -ItemType Directory -Force -Path $stage | Out-NullCopy-Item -LiteralPath $exe -Destination (Join-Path $stage "MDFlux.exe")Copy-Item -LiteralPath $resources -Destination $stage -Recurse+ $stagedSidecar = Join-Path $stage "resources\sidecar"+ if (Test-Path -LiteralPath $stagedSidecar) {+ Remove-Item -LiteralPath $stagedSidecar -Recurse -Force+ }+ Copy-Item -LiteralPath $sidecarDir -Destination (Join-Path $stage "resources") -Recurse$runtime = Join-Path $stage "resources\runtime"if (Test-Path -LiteralPath $runtime) { Remove-Item -LiteralPath $runtime -Recurse -Force }Write-EditionManifest -ResourcesDirectory (Join-Path $stage "resources") -Edition "lite" -Metadata $metadata -PythonVersion $nulldiff --git a/scripts/windows/portable-common.ps1 b/scripts/windows/portable-common.ps1index 4eecfcb..4286824 100644--- a/scripts/windows/portable-common.ps1+++ b/scripts/windows/portable-common.ps1@@ -46,6 +46,12 @@ function Test-WindowsPortableArchive {if (-not (Test-Path -LiteralPath $manifestPath)) { throw "Archive is missing resources\\edition.json" }$manifest = Get-Content -LiteralPath $manifestPath -Raw | ConvertFrom-Jsonif ($manifest.schema -ne 1 -or $manifest.edition -ne $Edition -or $manifest.platform -ne "windows-x64") { throw "Archive manifest does not match the defined Windows $Edition contract." }+ $packagedLock = Join-Path $resources "sidecar\requirements-full.lock"+ if (-not (Test-Path -LiteralPath $packagedLock)) { throw "Archive is missing the canonical dependency lock." }+ $packagedLockSha = (Get-FileHash -LiteralPath $packagedLock -Algorithm SHA256).Hash.ToLowerInvariant()+ if ($manifest.dependency_lock_sha256 -ne $packagedLockSha) {+ throw "Archive dependency lock checksum does not match its manifest."+ }$runtime = Join-Path $resources "runtime"if ($Edition -eq "lite") {if (Test-Path -LiteralPath $runtime) { throw "Lite archive unexpectedly contains resources\\runtime" }diff --git a/tests/release-fixtures/test_verifier.py b/tests/release-fixtures/test_verifier.pyindex 3e9501b..ba26556 100644--- a/tests/release-fixtures/test_verifier.py+++ b/tests/release-fixtures/test_verifier.py@@ -139,6 +139,10 @@ class ArchiveBuilderTests(unittest.TestCase):verify_no_full_provisioning=lambda *_args, **_kwargs: CheckResult("full-no-provisioning", True, "test provisioning snapshot"),+ verify_ocr_conversions=lambda *_args, **_kwargs: [+ CheckResult("ocr-image", True, "test OCR image"),+ CheckResult("ocr-scanned-pdf", True, "test OCR PDF"),+ ],)runtime_checks.start()self.addCleanup(runtime_checks.stop)@@ -183,6 +187,8 @@ class StructuralVerificationTests(ArchiveBuilderTests):by_name["edition-manifest-edition"].detail,"edition=full",)+ self.assertTrue(by_name["ocr-image"].passed)+ self.assertTrue(by_name["ocr-scanned-pdf"].passed)def test_lite_linux_tarball_layout(self) -> None:report = verify_archive(diff --git a/tools/dependencies/check.py b/tools/dependencies/check.pyindex 87c1c68..238eeec 100644--- a/tools/dependencies/check.py+++ b/tools/dependencies/check.py@@ -14,6 +14,11 @@ from pathlib import PathLOCK_LINE = re.compile(r"^([A-Za-z0-9_.-]+)==([^\s;\\]+)")HASH_LINE = re.compile(r"^\s*--hash=sha256:([0-9a-f]{64})\s*\\?$")INPUT_NAME = re.compile(r"^([A-Za-z0-9_.-]+)(?:\[[^]]+\])?(?:[<>=!~].*)?$")+REQUIRED_MINIMUM_VERSIONS = {+ # RapidOCR stores pathlib.Path values in its OmegaConf configuration.+ # OmegaConf 2.0.x rejects them at runtime even though imports succeed.+ "omegaconf": (2, 3, 0),+}@dataclass(frozen=True)@@ -71,6 +76,14 @@ def direct_requirements(path: Path) -> set[str]:return result+def numeric_version(version: str) -> tuple[int, ...]:+ """Return a comparable numeric prefix for ordinary PEP 440 versions."""+ match = re.match(r"^(\d+(?:\.\d+)*)", version)+ if not match:+ raise ValueError(f"unsupported locked version {version!r}")+ return tuple(int(part) for part in match.group(1).split("."))++def check(sidecar: Path) -> list[str]:errors: list[str] = []full_input = sidecar / "requirements-full.in"@@ -88,11 +101,28 @@ def check(sidecar: Path) -> list[str]:full_header = full_lock.read_text(encoding="utf-8").splitlines()[:2]header = "\n".join(full_header)- for required in ("requirements-full.in", "--universal", "--python-version 3.12", "--generate-hashes", "--only-binary :all:"):+ for required in (+ "requirements-full.in",+ "--universal",+ "--python-version 3.12",+ "--generate-hashes",+ "--only-binary :all:",+ "--no-binary antlr4-python3-runtime",+ ):if required not in header:errors.append(f"{full_lock}: missing regeneration option {required}")canonical = parse_lock(full_lock)+ for name, minimum in REQUIRED_MINIMUM_VERSIONS.items():+ package = canonical.get(name)+ if package is None:+ errors.append(f"canonical Full lock is missing required package {name}")+ elif numeric_version(package.version) < minimum:+ required = ".".join(str(part) for part in minimum)+ errors.append(+ f"canonical Full lock has incompatible {name}=={package.version}; "+ f"requires >={required}"+ )exports = {"core": (sidecar / "requirements.txt", sidecar / "requirements.lock"),"ocr": (sidecar / "requirements-ocr.in", sidecar / "requirements-ocr.lock"),@@ -118,6 +148,10 @@ def check(sidecar: Path) -> list[str]:export_header = "\n".join(export_path.read_text(encoding="utf-8").splitlines()[:2])if "--constraint requirements-full.lock" not in export_header:errors.append(f"{export_path}: must be generated with requirements-full.lock as a constraint")+ if feature == "ocr" and "--no-binary antlr4-python3-runtime" not in export_header:+ errors.append(+ f"{export_path}: must allow the pinned pure-Python antlr4 source package"+ )return errorsdiff --git a/tools/release/runtime_checks.py b/tools/release/runtime_checks.pyindex 11be6d4..0f61496 100644--- a/tools/release/runtime_checks.py+++ b/tools/release/runtime_checks.py@@ -314,6 +314,79 @@ def verify_conversions(return results+def verify_ocr_conversions(root: Path, *, platform: str) -> list[CheckResult]:+ """Exercise packaged OCR with both an image and an image-only PDF."""+ python = bundled_python_path(root, platform)+ sidecar_dir = root / "resources" / "sidecar"+ results: list[CheckResult] = []++ with tempfile.TemporaryDirectory(prefix="mdflux-ocr-fixture-") as scratch:+ scratch_dir = Path(scratch).resolve()+ fixture_code = f"""+from pathlib import Path+from PIL import Image, ImageDraw, ImageFont++root = Path({str(scratch_dir)!r})+image = Image.new("RGB", (1400, 360), "white")+font = ImageFont.load_default(size=72)+ImageDraw.Draw(image).text(+ (60, 120),+ "MDFlux OCR release verification 2026",+ fill="black",+ font=font,+ stroke_width=1,+)+image.save(root / "ocr-smoke.png")+image.save(root / "ocr-smoke-scanned.pdf", "PDF", resolution=150.0)+print("fixtures OK")+"""+ generated = _run_python(python, fixture_code, timeout=60.0)+ if generated.returncode != 0:+ detail = generated.stderr.strip() or generated.stdout.strip()+ return [CheckResult("ocr-fixtures", False, detail or "Fixture generation failed")]+ results.append(CheckResult("ocr-fixtures", True, "Image and scanned PDF generated"))++ for filename, check_name in (+ ("ocr-smoke.png", "ocr-image"),+ ("ocr-smoke-scanned.pdf", "ocr-scanned-pdf"),+ ):+ request = {+ "v": 1,+ "id": f"verify-{check_name}",+ "method": "convert-one",+ "params": {"path": str((scratch_dir / filename).resolve())},+ }+ try:+ response, error = _sidecar_request(+ python, sidecar_dir, request, timeout=300.0+ )+ except subprocess.TimeoutExpired:+ results.append(CheckResult(check_name, False, f"{filename}: timed out"))+ continue+ except OSError as exc:+ results.append(CheckResult(check_name, False, f"{filename}: {exc}"))+ continue++ if response is None:+ results.append(CheckResult(check_name, False, f"{filename}: {error}"))+ continue+ if not response.get("ok"):+ err = response.get("error") or {}+ detail = err.get("detail") or err.get("title") or "OCR failed"+ results.append(CheckResult(check_name, False, f"{filename}: {detail}"))+ continue++ markdown = str((response.get("result") or {}).get("markdown") or "")+ if not markdown.strip():+ results.append(CheckResult(check_name, False, f"{filename}: empty OCR output"))+ else:+ results.append(CheckResult(+ check_name, True, f"{filename}: {len(markdown)} chars"+ ))++ return results++def _snapshot_provisioning_paths(platform: str) -> dict[str, float | None]:root = app_data_root(platform)tracked = {diff --git a/tools/release/verify.py b/tools/release/verify.pyindex a369d43..a665362 100644--- a/tools/release/verify.py+++ b/tools/release/verify.py@@ -20,6 +20,7 @@ from .runtime_checks import (verify_conversions,verify_full_imports,verify_no_full_provisioning,+ verify_ocr_conversions,verify_sidecar_health,)@@ -139,6 +140,10 @@ def verify_archive():report.add(check)+ if edition == "full":+ for check in verify_ocr_conversions(extract_dir, platform=platform):+ report.add(check)+if edition == "full" and provisioning_before is not None:report.add(verify_no_full_provisioning(