按用户明确要求,治理封存不再替 WeKnora 判断正文块“应该”有独立索引: 删除 status/chunk_type/parent/mixed/flat 推导的 needOriginal、mixedDocs 及覆盖门槛;删除 parent 类型搭配限制,仅保留父引用存在与同 knowledge。 capture/preflight/archive/load/replay/writeset 共用校验同步更新,移除已无 用途的 worker 永久失败分类。 保留真实导出范围、PG/ES 原始正文/问题 metadata/vector、tenant/KB/ knowledge/chunk 身份、清单摘要、资源字节、Wiki/问题索引 source_id 及真实 悬空引用等完整性检查;不修改源端,不补数据/索引。旧测试改为原样捕获正例, 新增 status0/2 缺正文索引和父类型不匹配的接受回归,以及 archive/readback 逐行/逐记录比对。 验证:v071、cmd/worker、Go 全量、make verify 17 项。
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"knowledge-governance/internal/jobs"
|
||||
)
|
||||
|
||||
func TestLibraryCaptureValidationFailureIsTerminal(t *testing.T) {
|
||||
original := errors.New("LIBRARYCTL_FAILED: unverified legacy library chunk index coverage;已执行 recover 并确认写入者恢复")
|
||||
got := terminalLibraryCaptureError(original)
|
||||
terminal, code := jobs.Terminal(got)
|
||||
if !terminal || code != jobs.ErrCodeValidationFailed {
|
||||
t.Fatalf("validation failure must park immediately: terminal=%v code=%q err=%v", terminal, code, got)
|
||||
}
|
||||
if got.Error() != original.Error() {
|
||||
t.Fatalf("original cause changed: got %q want %q", got.Error(), original.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibraryCaptureTransientFailureStillRetries(t *testing.T) {
|
||||
for _, message := range []string{
|
||||
"library agent is unreachable",
|
||||
"context deadline exceeded",
|
||||
`LIBRARYCTL_FAILED: job "lib-internal-x" already exists with state "failed";已执行 recover 并确认写入者恢复`,
|
||||
} {
|
||||
got := terminalLibraryCaptureError(errors.New(message))
|
||||
if terminal, code := jobs.Terminal(got); terminal {
|
||||
t.Fatalf("%q must stay retryable, got terminal code=%q", message, code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibraryCaptureOriginalFailureSurvivesRetryOverwrite(t *testing.T) {
|
||||
// 队列第二次 attempt 的 already exists 不能替换第一因;分类器保留首个
|
||||
// 校验错误为永久失败,因此队列不会产生第二次自动 attempt。
|
||||
first := errors.New("LIBRARYCTL_FAILED: unverified legacy library chunk index coverage;已执行 recover 并确认写入者恢复")
|
||||
second := errors.New(`LIBRARYCTL_FAILED: job "lib-internal-20261105T054158" already exists with state "failed";已执行 recover 并确认写入者恢复`)
|
||||
classified := terminalLibraryCaptureError(first)
|
||||
if terminal, _ := jobs.Terminal(classified); !terminal {
|
||||
t.Fatal("first validation error must terminate before retry")
|
||||
}
|
||||
if terminal, _ := jobs.Terminal(second); terminal {
|
||||
t.Fatal("second retry error must not be terminal")
|
||||
}
|
||||
if !strings.Contains(classified.Error(), "unverified legacy library chunk index coverage") {
|
||||
t.Fatalf("first cause lost: %v", classified)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user