fix(knowledge): promote stale processing status to ready when index is ready (#418)#419
Open
voidborne-d wants to merge 1 commit intoHKUDS:mainfrom
Open
Conversation
…ts (HKUDS#418) When the persisted ``status`` in ``kb_config.json`` is still a "live" sentinel (``processing`` / ``initializing``) but a flat ``version-N`` directory on disk is already ready, ``get_info()`` previously returned ``status="processing"`` because the elif chain had no branch to recover the case. The UI therefore showed a perpetual "Processing…" banner even though the KB was fully usable. This typically happens when the progress writer or worker process crashes after the LlamaIndex version is finalised but before ``update_kb_status(name, "ready")`` rewrites kb_config.json — the on-disk truth and the persisted status diverge. Fix: in ``get_info``, after the existing ``effective_needs_reindex`` short-circuit, add a branch that promotes status to ``"ready"`` when: - status is currently ``processing`` or ``initializing``, - a ready ``version-N`` exists (``has_ready_llamaindex``), - and the persisted progress stage is not ``error``. The ``error`` guard preserves visibility of genuine indexing failures when an older ready version still exists. The promotion clears the stale progress banner to match the existing semantic in ``update_kb_status`` (where ready KBs drop progress). The persistent ``kb_config.json`` is left untouched on read; the next legitimate ``update_kb_status`` call cleans it up. 7 new tests in ``tests/knowledge/test_manager_get_info_status.py`` cover the headline HKUDS#418 reproduction, the completed-stage variant, the ``initializing`` variant, and the negative cases (error stage, no ready version yet, ready-status pass-through, mismatched-signature -> needs_reindex precedence).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #418.
get_info()now recognises the case wherekb_config.jsonstill saysstatus: "processing"(or"initializing") but a flatversion-N/directory already contains a ready index, and reportsstatus: "ready"instead of a perpetual processing banner.This happens when the progress writer or worker process is interrupted after the LlamaIndex version is finalised but before
update_kb_status(name, "ready")runs and rewriteskb_config.json— the on-disk truth and the persisted status diverge.Root cause
In
deeptutor/knowledge/manager.py::get_info()(lines 646–660 onmain), the elif chain that resolves the reported status had no branch for "status is a live sentinel + a ready index already exists":When
kb_config.jsonhad:status: "processing"progress.stage: "processing_documents"(stale)needs_reindex: false…and
version-1had adocstore.json(ready: trueper_is_storage_ready), the chain fell through andstatusstayed"processing". Issue #418 was opened by @TecFancy with this exact reproduction and a suggested fix.Fix
Insert a new branch after
effective_needs_reindexthat fires only when:status in {"processing", "initializing"}(live sentinel left over)has_ready_llamaindex(a flatversion-Nalready passes_is_storage_ready)progress.stage != "error"(don't silently mask real failures when an older ready version exists)When all three hold, promote
statusto"ready"and clearprogressfor that read so consumers don't render "ready" + a stale processing bar at the same time. This matches the existingupdate_kb_status(status="ready")semantic, which already popsprogressfrom the persistent payload.The persistent
kb_config.jsonis not rewritten insideget_info; it stays a pure read. The next legitimateupdate_kb_statuscall cleans up the on-disk state.Tests
7 new cases in
tests/knowledge/test_manager_get_info_status.py, all green:test_processing_with_ready_index_promotes_to_readyprocessing+ staleprocessing_documents+ ready version →ready,progress=Nonetest_processing_with_completed_progress_and_ready_index_promotesprogress.stage == "completed"test_initializing_with_ready_index_promotesinitializingis also a live sentineltest_processing_with_error_stage_is_not_promotedprogress.stage == "error"is not auto-healedtest_processing_without_ready_index_not_promotedversion-1/) staysprocessingtest_ready_status_unaffectedstatus="ready"happy path is unchangedtest_needs_reindex_takes_precedenceneeds_reindex(existing branch wins)tests/knowledge/total: 22 passed (15 pre-existing + 7 new), no regressions.ruff checkclean on both touched files. The pre-existingruff formatdrift indeeptutor/knowledge/manager.py(4 spots, all onmain@28e225e) is unrelated and untouched here.Scope
get_info(), no signature changes.info["status"],info["progress"],info["statistics"]["status"], andinfo["statistics"]["progress"]all consume the same locals.info["status"].Disclosure
Implementation by an AI agent (Claude Opus 4.7) with manual review. The reporter's analysis in #418 was also AI-disclosed (
deepseek-v4-pro); their suggested fix shape (elif status in {"processing","initializing"} and has_ready_llamaindex: status = "ready") matched my read of the code, with two refinements driven by reviewing the surrounding callsites:progress.stage == "error"so a failed re-index that still has an older ready version doesn't silently report "ready".progresson promotion to matchupdate_kb_status(status="ready")which popsprogressfrom the persistent payload, so consumers don't render a "ready" badge alongside a stale progress bar.Happy to drop the error-stage guard or the progress-clear if maintainer prefers a thinner patch.