fix(knowledge): close root span on terminal state, enrich stage metadata

The root span created by OpenAttempt was never closed: PostProcess only
ended the postprocess stage, so the root row stayed at status=running
forever even after parse_status flipped to completed/failed. The
timeline rendered "进行中" indefinitely on the root, defeating the
whole "is the document done" question the timeline is meant to answer.

- SpanTracker.FinalizeAttempt(kid, attempt, status, output, code, msg):
  closes the root row idempotently. Re-closing a terminal root no-ops
  so success / cascade-fail / dead-letter paths can fire without
  coordination.
- PostProcess.Handle calls FinalizeAttempt(done) after EndSpan(postprocess)
  on the success path. Async downstream work (summary/question/wiki/
  graph) still records its own spans; their completion extends the
  trace's wall-clock end-time but doesn't reopen the root.
- FailSpan auto-closes the root when a MAIN pipeline stage fails
  (docreader / chunking / embedding / multimodal / postprocess).
  Cascade-cancelled siblings stay closed-with-the-cascade as before.
- Dead-letter callback (router/task.go) accepts the SpanTracker via
  DI and calls FinalizeAttempt(failed, TASK_TIMEOUT) when a
  document-related task exhausts retries. The probe payload now
  extracts the Attempt field that Document/Manual/PostProcess
  payloads already thread through.

Stage spans were also being recorded with nil input/output, leaving
the new detail panel with timestamps only. Each Begin/End site now
emits useful work metrics:
- DocReader input: file_name, file_type, is_url, url
              output: text_length, images_found, is_audio, pages
- Chunking input: chunks_planned
            output: chunks_written, total_text_chars
- Embedding input: chunks_to_embed, model_id, dim
             output: vectors_written, storage_bytes
- Multimodal input: image_count, enable_ocr, enable_caption
- PostProcess output: chunks_total, enqueued_summary, _question, _wiki, _graph

i18n: add knowledgeStages.root ("Knowledge processing") so the UI
can render a localized name instead of the raw span identifier.
This commit is contained in:
wizardchen
2026-05-27 16:54:09 +08:00
committed by lyingbug
parent c5722234ef
commit 4db6e69b4e
8 changed files with 218 additions and 20 deletions
+1
View File
@@ -390,6 +390,7 @@ export default {
knowledgeStages: {
title: 'Processing pipeline',
root: 'Knowledge processing',
attempt: 'Attempt {n}',
attemptLatest: 'Attempt {n} (latest)',
retry: 'Retry parsing',
+1
View File
@@ -396,6 +396,7 @@ export default {
},
knowledgeStages: {
title: "처리 파이프라인",
root: "지식 처리",
attempt: "{n}번째 시도",
attemptLatest: "{n}번째 시도 (최신)",
retry: "다시 파싱",
+1
View File
@@ -360,6 +360,7 @@ export default {
},
knowledgeStages: {
title: 'Конвейер обработки',
root: 'Обработка знаний',
attempt: 'Попытка {n}',
attemptLatest: 'Попытка {n} (последняя)',
retry: 'Повторить парсинг',
+1
View File
@@ -393,6 +393,7 @@ export default {
},
knowledgeStages: {
title: "处理流水线",
root: "知识处理",
attempt: "第 {n} 次尝试",
attemptLatest: "第 {n} 次尝试(最新)",
retry: "重新解析",