Skip to content

fix: support page:last doclib locators - #5365

Closed
lylelllll wants to merge 1 commit into
opendatalab:nextfrom
lylelllll:codex/fix-page-last-locator
Closed

lylelllll wants to merge 1 commit into
opendatalab:nextfrom
lylelllll:codex/fix-page-last-locator

Conversation

@lylelllll

@lylelllll lylelllll commented Aug 6, 2026 •

Copy link
Copy Markdown

Motivation

mineru read "doc:<short_id>/tier:flash/page:last" is currently rejected even when the document's last page is cached. Numeric page locators work, but callers cannot use the documented last-page shorthand.

Fixes #5300

Modification

  • Accept last as a page token in read locators.
  • Resolve page:last against the document's page_count before the existing numeric page-range and target logic runs.
  • Return canonical numeric locators and content ranges in the response.
  • Return a clear invalid_locator error when the document page count is unavailable.
  • Add regression coverage for both the successful read path and the unavailable-page-count path.

BC-breaking

No. Existing numeric page, block, and character locators retain their current behavior and remain 1-based.

Testing

  • .venv/bin/python -m pytest -q -o addopts='' tests/unittest/test_doclib_cache_semantics.py tests/unittest/test_doclib_locators.py tests/unittest/test_doclib_progressive_reading.py (210 passed)
  • uvx ruff check mineru/doclib/server.py
  • uvx ruff check --ignore ANN001,E501 tests/unittest/test_doclib_cache_semantics.py (the ignored rules have existing violations outside this patch)
  • Direct parser/resolution smoke test for page:last/block:2/char:8

Model/GPU parsing E2E was not run because this change is isolated to doclib locator parsing and cached-content reads.

Checklist

  • Linting was run on the modified production code.
  • The reported bug is covered by regression tests.
  • Existing numeric locator and progressive-reading tests pass.
  • No downstream API or cache-format change is introduced.
  • CLA check passed.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Aug 6, 2026
myhloli added a commit that referenced this pull request Oct 11, 2026
Apply filename prefix matching to the final query token and paginate the
complete filtered candidate set with stable ordering and accurate totals.
Reuse input page-range syntax in read locators, including rN and all, and
preserve selected-page boundaries during block and character continuation.
Update CLI/SDK/HTTP contracts, bilingual help, documentation, and regressions.

Validation: 667 Doclib/CLI tests passed; Ruff and formatting checks passed.
Refs #5366, #5337, #5365.
@myhloli

myhloli commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Thank you for the contribution. Last-page selection is now supported on dev in aca9b06da through the same syntax used by parsing inputs.

Use page:r1 for the last page and page:r2 for the second-to-last page. Locators also accept ranges, comma-separated selections and all, such as page:r3-r1 and page:1,3,r1. Returned references use absolute page numbers. Relative selections require a known document page count; block/character and image reads require a single resolved page.

Range reads preserve the selected pages during continuation and stop when the selection is complete. Local validation: 667 related Doclib/CLI tests passed, with Ruff and formatting checks passing.

The page:last spelling proposed here is superseded by the shared page-selection syntax, so I am closing this PR.

Refs #5300.

@myhloli myhloli closed this Oct 11, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants