[Enhancement]: Reliable long-document indexing with resumable work, truthful progress, and safe recovery
Thank you for the recent work on parser progress, cache reuse, index versioning, and stalled-worker handling. I would appreciate prioritizing the remaining end-to-end reliability of long-document ingestion. A learner should be able to process a large textbook or mixed document collection, understand its real state, recover from interruption, and obtain a verifiably usable knowledge base without manually managing processes or cache files.
This is related to #1478 but broader than its stale-worker progress leak: it covers the complete parsing-to-persisted-index lifecycle. It also provides the ingestion foundation for #1610 and #1611. Please coordinate readiness requirements with the existing request #1209 rather than create a duplicate settings project.
Current code observations and scope
This request is based on static review of v1.6.12 and the existing indexing report. The recovery scenarios below are requested acceptance cases, not a claim that all have been reproduced against that release.
local.pyalready streams MinerU output throughon_output. Therefore, this is not a request to add a callback that already exists; the user-facing workflow must reliably expose meaningful progress from available signals.- That wrapper replaces an existing output directory and temporary output directory when starting a parse, and removes temporary output after a nonzero process exit. Successful external parse-cache reuse may avoid this path; the observation concerns recovery of an interrupted or failed parse, not a claim that all completed caches are deleted.
backend.pyturns a false return from local parsing into the same error suggesting MinerU installation or cloud mode. A runtime failure can therefore receive installation-oriented guidance even when installation was not the cause.- #1478 and its associated worker fix address an important ownership problem. Correct progress ownership is necessary, but does not by itself establish durable resume behavior, useful parser diagnostics, or verified completion of the whole index.
Why this deserves priority
Large textbooks can take substantial time to process, particularly on local hardware. Losing reusable work, showing an unchanged generic message, or reaching a stage's 100% without a usable index makes it difficult to decide whether to wait, retry, or change settings. Repeated retries can waste hours and further obscure the state.
Predictable long-running work is acceptable; unexplained state and avoidable repeated work are not. The learner should not need to infer progress from CPU utilization or inspect backend files. Reliable ingestion is also a prerequisite for trusting claims about source coverage and source-based answers.
Required outcomes
1. Know what can be processed before the expensive work
- Validate the selected parser, embedding model, file types, and essential dependencies with lightweight checks. Show which sources are supported and which need another supported path.
- Treat a mixed collection explicitly: accepted, unsupported, failed, and completed sources should remain distinguishable. Do not silently omit a TXT, spreadsheet, image, or other input while presenting the collection as fully indexed.
- Expose the effective local/cloud mode and the execution device when reliably known. Do not imply that an available GPU/NPU is being used when the selected backend does not use it. No silent cloud fallback or unexpected charge should be required for recovery.
2. Display honest progress for the complete job
- Show the current document, phase, completed work, and last meaningful progress. Distinguish model preparation/download, parsing, embedding, and final index persistence/validation.
- Show page or batch counts when the backend provides them. When it does not, show an indeterminate phase with the available activity and diagnostic state rather than fabricate a percentage or ETA.
- A stage reaching 100% must not imply that the entire knowledge base is ready. If counters restart for another document or phase, label that transition clearly; logs from an old task must not contaminate a new one.
- Refreshing or reconnecting the browser must restore the same authoritative task state. A browser connection must not own the lifetime of the indexing work.
3. Recover at a real, supported boundary
- Retain and validate completed reusable work across retry, backend restart, and interruption. A failed document should not require reparsing unrelated unchanged documents.
- When only the embedding configuration changes, reuse compatible parser outputs; when source or parser settings change, invalidate only affected work. Never reuse incompatible embeddings merely because their dimensions match.
- Persist enough task state to distinguish work that completed, work that failed, and work whose completion is unknown after a crash.
- Resume at the finest reliable boundary exposed by the backend. This does not demand continuing in the middle of an uncheckpointable inference call. If the interrupted document or stage must restart, say so and preserve other completed work.
- Offer understandable retry/cancel/resume behavior where supported. Prevent overlapping conflicting jobs and ensure a cancelled/failed worker cannot keep updating or overwriting the next job. Account for sleep/wake and restart without leaving a permanently live-looking task.
4. Fail with an actionable reason
- Distinguish missing installation, unsupported input, model download failure, timeout, resource exhaustion, invalid output, and embedding failure when those causes are available.
- Preserve useful, redacted failure details and identify the affected document and stage. Do not replace a known runtime timeout with generic installation advice.
- Treat total runtime limits and lack-of-progress detection as different controls. A demonstrably advancing job should not be mistaken for a stalled one, and a stuck job should not remain live indefinitely. Where only weak activity signals exist, represent uncertainty rather than claiming forward progress from CPU use alone.
- Give the user a relevant next step and indicate which completed work will be reused. Raising one timeout alone should not be considered a complete recovery solution.
5. Publish only a usable, accurately described result
- Validate the persisted index and intended embedding configuration before activating the new version. An embedding batch completing is not sufficient evidence of readiness.
- Preserve a previous usable index if a replacement build fails. The UI should clearly distinguish the last usable version from the rebuilding or failed version.
- Report which sources are included, failed, or excluded and their indexing status. A partially usable result can be offered explicitly, but must not look like full completion.
- Ensure completion timestamps and document counts belong to the resulting index version, survive restart, and match the sources it can actually retrieve.
Practical implementation direction
Build on the existing parsing cache, progress tracker, task ownership, and index-version mechanisms. The essential boundary is durable completed work plus an explicit job state; it need not become a distributed queue or a new orchestration framework.
Use bounded work units and compatible cache reuse where the parser supports them. Preserve original page/source locations if processing is split internally. Validate completed outputs before reuse and validate a rebuilt index before switching the active version. Keep subprocess ownership and error classification in the responsible layer.
Fast first-pass parsing on every device is not a requirement. Efficient reuse, visible progress, safe failure, and an understandable recovery path are. Supported local workflows should remain available without an obligatory paid service.
End-to-end completion cases
Please verify a small representative set using public/synthetic documents and controlled failures. Existing tests can simulate interruption boundaries; repeated full processing of a huge textbook is unnecessary.
- Mixed collection: a collection containing a large supported document, smaller supported files, and an unsupported file finishes or reports a precise partial outcome with correct counts and source inclusion.
- Long parse: preparation, parsing, embedding, and persistence remain distinguishable. Available backend progress reaches the UI; no stage counter masquerades as whole-job completion.
- Interrupted work: interrupt after one document is completed and during another; after restart/retry, validated completed work is reused and the unavoidable restart boundary is explained.
- Configuration change: changing embeddings reuses compatible parsing but creates a compatible new index; changing source/parser inputs does not reuse stale outputs.
- Failure reporting: simulate a parser timeout after successful startup, a missing executable, and invalid output. Each receives relevant guidance, not the same installation message.
- Ownership: cancelling or retrying cannot leave a stale worker writing into the replacement task. Refreshing the UI does not start a duplicate job.
- Safe activation: a failure during embedding or persistence leaves the previous usable index available; successful completion produces an index that can actually retrieve included sources after restart.
- Honest result: persisted version metadata, source counts, timestamps, and displayed readiness agree. Excluded/failed material cannot silently appear as fully indexed.
Please treat the successful recovery path and verified usable result as part of completion, not as optional polish after a happy-path import succeeds. This is what makes large source collections practical for sustained study.
Source: HKUDS/DeepTutor