77bbc3ac6b
build / build (push) Successful in 1m38s
恢复 terminalLibraryCaptureError,但仅限仍存在的 missing library generated question index 和 empty library index content;已恢复写入者时走 jobs.Permanent(validation_failed),保留原消息。已取消的正文索引覆盖 marker 和网络超时仍重试。部署脚本另以新包提供旧基线稳定性采样;不恢复 R3f 已取消 的正文索引/父类型规则。 验证:worker 保留错误 RED→GREEN、v071、Go 全量、make verify 17 项。
66 lines
2.3 KiB
Go
66 lines
2.3 KiB
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
|
|
"knowledge-governance/internal/jobs"
|
|
)
|
|
|
|
// R3g: only retained deterministic capture failures become permanent after the
|
|
// agent has recovered the writer. Cancelled body-index coverage markers are
|
|
// deliberately absent.
|
|
func TestRetainedLibraryCaptureFailuresArePermanent(t *testing.T) {
|
|
for _, marker := range []string{
|
|
"missing library generated question index",
|
|
"empty library index content",
|
|
} {
|
|
t.Run(marker, func(t *testing.T) {
|
|
original := errors.New("LIBRARYCTL_FAILED: " + marker + ";已执行 recover 并确认写入者恢复")
|
|
got := terminalLibraryCaptureError(original)
|
|
terminal, code := jobs.Terminal(got)
|
|
if !terminal || code != jobs.ErrCodeValidationFailed {
|
|
t.Fatalf("retained validation failure must park immediately: terminal=%v code=%q err=%v", terminal, code, got)
|
|
}
|
|
if got.Error() != original.Error() {
|
|
t.Fatalf("original message changed: got %q want %q", got.Error(), original.Error())
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestCancelledCoverageFailureStaysRetryable(t *testing.T) {
|
|
for _, marker := range []string{
|
|
"unverified legacy library chunk index coverage",
|
|
"missing indexed library chunk",
|
|
} {
|
|
err := terminalLibraryCaptureError(errors.New(marker + ";已执行 recover 并确认写入者恢复"))
|
|
if terminal, code := jobs.Terminal(err); terminal {
|
|
t.Fatalf("cancelled marker %q must not be terminal; code=%q", marker, code)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestTransientLibraryCaptureFailureStaysRetryable(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 并确认写入者恢复`,
|
|
"missing library generated question index; writer restore not confirmed",
|
|
} {
|
|
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 TestRetainedFailureDoesNotChangeMessage(t *testing.T) {
|
|
original := errors.New("LIBRARYCTL_FAILED: missing library generated question index;已执行 recover 并确认写入者恢复")
|
|
got := terminalLibraryCaptureError(original)
|
|
if !strings.Contains(got.Error(), "missing library generated question index") {
|
|
t.Fatalf("lost original cause: %v", got)
|
|
}
|
|
}
|