fix(knowledge): unstick summary and isolate manual re-index trace attempts
Manually uploaded text documents could get stuck showing "generating summary" forever, and editing/re-saving a document mixed its trace into the previous attempt. Three related fixes: 1. finalizeIndexedKnowledgeState no longer marks a text document completed the moment chunks are indexed. Doing so made KnowledgePostProcess hit its non-processing guard and skip the summary/question/graph fan-out, stranding summary_status on "pending". The row now stays "processing" (still retrievable via enable_status=enabled) and post-process remains the sole authority that drives processing -> finalizing -> completed. 2. ProcessManualUpdate now allocates a fresh span-tracking attempt via OpenAttempt. Previously it ran with attempt 0, so processChunks dropped every stage span and KnowledgePostProcess fell back to LatestAttempt, piling the new run's summary/wiki subspans onto the prior attempt's trace. 3. Enrichment workers (summary, question, graph extract) skip when a newer attempt has superseded theirs. A stale subtask from a previous upload/edit/reparse must not read deleted chunks or decrement the new attempt's pending_subtasks_count, which would race-promote the row to completed before the new attempt finishes. Updated TestFinalizeIndexedKnowledgeState to expect the deferred completion for text documents.
This commit is contained in:
@@ -18,10 +18,10 @@ func TestFinalizeIndexedKnowledgeState(t *testing.T) {
|
||||
wantSummaryStatus string
|
||||
}{
|
||||
{
|
||||
name: "text document is completed once chunks are indexed",
|
||||
name: "text document stays processing so post-process can fan out enrichment",
|
||||
textChunkCount: 2,
|
||||
wantParseStatus: types.ParseStatusCompleted,
|
||||
wantSummaryStatus: types.SummaryStatusPending,
|
||||
wantParseStatus: types.ParseStatusProcessing,
|
||||
wantSummaryStatus: types.SummaryStatusNone,
|
||||
},
|
||||
{
|
||||
name: "empty indexed document is completed without summary work",
|
||||
|
||||
Reference in New Issue
Block a user