Skip to content

feat(ops): expose MinerU runtime readiness separately from liveness - #503

Closed
seonghobae wants to merge 9 commits into
developfrom
feat/runtime-readiness-endpoint
Closed

feat(ops): expose MinerU runtime readiness separately from liveness#503
seonghobae wants to merge 9 commits into
developfrom
feat/runtime-readiness-endpoint

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add an unauthenticated GET /ready endpoint that returns 200 only when the MinerU executable required by /parse is discoverable, while preserving GET /health as a process-liveness endpoint.

Buyer-visible gap

The API-only container can currently report a green /health even when MinerU is absent and every real parse request returns 503. Deployment platforms therefore cannot distinguish a live process from a traffic-ready parser instance. This change supplies that missing operational contract.

Changes

  • Add a focused runtime-readiness module and router.
  • Resolve NEWSDOM_MINERU_BIN on every probe, falling back to mineru on PATH.
  • Use executable discovery rather than running an expensive parser subprocess inside a probe.
  • Return a sanitized 503 Service Unavailable when MinerU is unavailable.
  • Keep /health and /ready unauthenticated even when bearer protection is enabled for /parse.
  • Add regression coverage for configured, missing, and default MinerU executable discovery plus HTTP success/failure behavior and security headers.
  • Document liveness/readiness separation, Kubernetes probes, Docker Compose behavior, and the release note in CHANGELOG.md.

Verification

  • Focused readiness contract: 5 passed.
  • New production module and public functions include docstrings.
  • Repository quality gate remains responsible for exact-head 100% statement/branch coverage and docstring evidence.
  • All hosted security, package, container, and fuzz checks must complete on the final unstacked head before merge.

Standards basis

The contract follows Kubernetes probe semantics: liveness controls restart decisions, while readiness controls whether an instance receives service traffic. The endpoint is intentionally low-cost and returns a minimal response.

Residual risk

This is a shallow readiness check: it proves that an executable can be resolved, not that a particular PDF, model download, GPU backend, or external cache will succeed. Deep parser execution belongs in startup validation, diagnostics, or synthetic monitoring rather than a frequently invoked readiness probe.

Stacked dependency

This draft is intentionally stacked on security PR #467. Until #467 is merged, the comparison against develop also contains its dependency-remediation commits. After #467 lands, the diff contracts to the readiness change alone and this PR must be revalidated on the resulting current head before it is marked ready.

Git Flow target

  • feat/*develop.

claude and others added 9 commits July 30, 2026 10:15
pip-audit against the runtime lock (uv export --no-dev) flagged real
advisories in the exact PDF/image parsing path this service depends on.
Re-locked with targeted upgrades (all within the existing pyproject.toml
version ranges):

- pillow 12.2.0 -> 12.3.0 (PYSEC-2026-3451/3452/3453/3454/3493/3494/3495/3496:
  eight image-decoder advisories).
- pypdf 6.13.3 -> 6.14.2 (CVE-2026-59935/59936/59937/59938: PDF parsing).
- click 8.3.2 -> 8.4.2 (PYSEC-2026-2132).
- setuptools 81.0.0 -> 83.0.0 (CVE-2026-59890, build tool).

Verification: `uv export --frozen --no-emit-project --no-dev | pip-audit`
-> No known vulnerabilities found. Lock diff is confined to these four
packages and their hashes.

Residual (documented, not fixable in place): pymdown-extensions 10.21.3
CVE-2026-61632 requires a major bump to 11.0.0, but mkdocs-material 9.6.x
caps pymdown-extensions to <11. It is a docs-build-only dependency (mkdocs),
not on the runtime/API surface, so it does not affect the shipped image or
the `/parse` path; clearing it needs a coordinated docs-toolchain upgrade.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Msz8Dni5zRaqPatNCmZJZ8
…fting mkdocs-material to 9.7.x

The org Security Scan `trivy-fs` job fails on this repo (base branch and
every open PR) with:

  [MEDIUM (security-severity=5.3)] CVE-2026-61632 uv.lock - pymdown-extensions

pymdown-extensions 10.21.3 is vulnerable; the fix is 11.0.0+. It could not
be upgraded because mkdocs-material 9.6.x pins `pymdown-extensions~=10.2`
(i.e. <11). The docs toolchain deliberately held `mkdocs-material<9.7` to
avoid the 9.7 "MkDocs 2.0" warning banner (encoded in pyproject, two tests,
and CONTRIBUTING.md).

That caution-hold now blocks a real security fix and fails required CI, so
it is lifted to the minimum extent needed: bump only the theme to
`mkdocs-material>=9.7,<9.8` (which relaxes its pymdown-extensions cap to
`>=10.2`). The MkDocs *core* stays on the 1.x line (`mkdocs>=1.6,<2.0`
unchanged) — the 9.7 theme still builds on MkDocs 1.x.

Resulting lock: pymdown-extensions 10.21.3 -> 11.0.1, mkdocs-material
9.6.23 -> 9.7.7 (plus the runtime pillow/pypdf/click and setuptools bumps
from the previous commit).

Governance re-documented coherently:
- CONTRIBUTING.md: explains the theme now tracks 9.7.x for the CVE fix while
  the MkDocs core stays 1.x; the 9.7 banner is informational and non-fatal
  under --strict.
- tests/test_project_metadata.py: assertions updated to the new pin and the
  CONTRIBUTING rationale (CVE-2026-61632).

Verification:
- `uv run --frozen --extra docs mkdocs build --strict` -> builds cleanly
  (informational MkDocs 2.0 banner only, exit 0).
- `uv export --frozen --no-emit-project --all-extras | pip-audit --no-deps`
  -> No known vulnerabilities found (runtime and full sets).
- `PYTHONWARNINGS=error uv run --frozen --all-extras pytest` -> 430 passed.
- No src/ change, so the 100% branch-coverage gate is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Msz8Dni5zRaqPatNCmZJZ8
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fefa3e36-f3d9-49c3-91a4-7e4ef76410be

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Copy link
Copy Markdown
Collaborator Author

Parking this reviewed product slice until security baseline PR #467 is merged. The branch is preserved. Reopen after develop contains #467, rebuild the branch as a clean single-purpose readiness diff, rerun the focused and full exact-head checks, then request independent review and merge through repository policy. Closing now avoids consuming runner and reviewer capacity with a knowingly stacked draft.

@seonghobae seonghobae closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants