Anonymous - 2026-10-09

Originally posted by: coderabbitai[bot]

Review in Change Stack →

📝 Walkthrough
The pull request adds an MLX runtime option for local DeepSeek OCR on Apple Silicon and documents its CLI setup. It also changes EPUB rendering to omit unannotated solid-white images and adds tests for the runtime and rendering behavior. **Changes: MLX OCR runtime** |Layer / File(s)|Summary| |:---|:---| |**Runtime selection and MLX model loading**
`pdf_craft/ocr_config.py`, `pdf_craft_tool/runtime.py`, `pdf_craft/pdf/page_extractor.py`, `tests/test_ocr_config.py`|The OCR configuration accepts a `cuda` or `mlx` runtime. The environment setting selects the runtime, and the page extractor binds the MLX loader and model preprocessing when the runtime is `mlx`. The OCR test mocks the loader and checks the backend methods.| |**Apple Silicon CLI setup**
`pdf_craft_tool/requirements-mlx.txt`, `docs/en/MLX_CLI.md`, `README.md`|The requirements file adds MLX runtime dependencies. The guide and README describe the Apple Silicon CLI setup and invocation.| **Solid-white EPUB image filtering** |Layer / File(s)|Summary| |:---|:---| |**Detect and omit unannotated white images**
`pdf_craft/common/asset.py`, `pdf_craft/renderer/epub/render.py`, `tests/test_anchored_content_rendering.py`|The renderer omits an image when it is solid white and has no title, content, or caption. Parameterized tests check image inclusion and text continuity across image color, mode, and title cases.| **Priority:** ➖ Normal **Estimated code review effort:** 3 (Moderate) | ~25 minutes **Change:** Feature · **Severity of issue fixed:** Medium ### Sequence Diagram(s) :::mermaid sequenceDiagram participant Runtime as PDF_CRAFT_DEEPSEEK_OCR_LOCAL_RUNTIME participant Config as DeepSeekOCRLocalConfig participant Extractor as PageExtractorNode participant Loader as deepseek_ocr_mlx Runtime->>Config: Set runtime to mlx Config->>Extractor: Provide OCR runtime setting Extractor->>Loader: Bind loader and model preprocessing **Suggested reviewers:** `moskize91`
Merge Risk: 🔵 Low · up to 68199
MLX OCR may fail with an unsupported setting or nonzero device number, and the guide’s command may use the wrong Python installation. The documented lowercase setting and README command provide workable paths; the remaining fixes are advisable before broader use.
Security architecture risk: 🔵 Low · up to 68199
The change is opt-in and retains the existing conversion workflow. Offline-only behavior and recovery after loading failures are not fully established, but no introduced security vulnerability was verified. **Retained concerns** - **Low · security · inferred:** The opt-in loader replacement leaves continuity of the documented offline-only guarantee unresolved. local_only reaches the original factory but is not supplied to the replacement callable. Enforcement may remain elsewhere in the external extractor, so this is a security-contract uncertainty, not a verified network-access bypass.

Security review details

**Security Blast Radius** - _inferred_ — The new external code executes inside the caller's conversion process and therefore inherits its operating-system permissions. Demonstrated activation requires application or environment configuration, not merely supplying a PDF. Any compromised loader would consequently affect resources available to that process; cross-tenant or service-wide exposure was not established by the supplied topology. **Trust Boundaries and Controls** - _observed_ — The existing offline policy is passed to the factory, but replacement of load and _select_model transfers subsequent loading responsibility to an external callable without an explicit offline argument. The CLI defaults local_only to true. Missing external implementations prevent determining whether another enforcement layer preserves that restriction. **Resilience and Maintainability Implications** - _observed_ — The MLX-specific test verifies factory arguments, extractor loading invocation and callable identity using mocks. It does not exercise the replacement loader, demonstrate offline enforcement, or resolve retry, interruption and concurrency behavior after partial loading. Those gaps limit assurance of policy preservation and failure containment. **Hardening Proposals** - _proposed_ — Define and verify an explicit adapter contract for offline-only loading, cache and revision selection, and safe recovery after partial initialization. Include cached and missing-model cases with network access prohibited, repeated loading and interrupted-load recovery. - _proposed_ — Record an immutable revision for the external fork and a tested extractor compatibility range so future dependency changes cannot silently alter loading controls or recovery behavior.
Pre-merge checks: <picture>Passed</picture> 3 · <picture>Failed</picture> 2
<picture>Failed</picture> Failed checks: 2 warnings | Check name | Status | Explanation | Resolution | | :------------------------ | :----------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Out of Scope Changes check | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | The solid-white image omission in `pdf_craft/common/asset.py` and `pdf_craft/renderer/epub/render.py`, together with its rendering test changes, does not implement Apple Silicon GPU acceleration for i… | Remove the solid-white image feature and its related tests from this pull request, or move them to a separate pull request with a linked issue for that behavior. | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 7 files. (3 skipped: 3… | Write docstrings for the functions missing them to satisfy the coverage threshold. |
<picture>Passed</picture> Passed checks: 3 passed
| Check name | Status | Explanation | | :----------------- | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Issue `#246` requests GPU acceleration for Apple Silicon Macs. `DeepSeekOCRLocalConfig` adds `runtime="mlx"` in `pdf_craft/ocr_config.py`. `pdf_craft_tool/runtime.py` accepts the runtime environment set… | | Description Check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped - CodeRabbit’s high-level summary is enabled. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: adding local DeepSeek OCR support through MLX. |
Full details: Out of Scope Changes check
**Explanation** The solid-white image omission in `pdf_craft/common/asset.py` and `pdf_craft/renderer/epub/render.py`, together with its rendering test changes, does not implement Apple Silicon GPU acceleration for issue `#246`. The PR description identifies this as a separate commit, but the changes remain in this pull request.
Full details: Docstring Coverage
**Explanation** Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 7 files. (3 skipped: 3 unsupported.)
  • [ ] Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create a new PR
  • [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.