fix(reconciliation): 运行时读复用知识库绑定 Key
build / build (push) Successful in 1m59s

- 为什么:运行时读另用 WEKNORA_RUNTIME_KEY_FILE(0400 文件、启动读一次),当前部署没有该文件,队列与处理详情恒不可用;换 Key 还要重启,且与绑定页不同步。
- 做什么:RuntimeProvider 改为每次请求经 kbbinding.Resolve(EnvTest) 取地址与 Key,与 reconciliationRemote 共用同一 resolver;删除配置字段/校验、ReadRuntimeKeyFile 与测试、compose/env、启动 WARN。
- 三态:绑定不可用→503 runtime_read_unavailable;上游 401/403→502 runtime_read_forbidden;超时/DNS→502 runtime_read_unreachable;overview 增 weknora_queue_error,页面三句不同文案并保留 WeKnora 跳转链接。
- 同步:openapi progress 契约与 502、需求书 §5/Q7、阶段计划、运维手册、CHANGELOG。
- 验证:make verify 17 项 success;新增换 Key 二次请求头、401/403/不可达分类、Service 透传、overview 原因码、页面三文案用例。
This commit is contained in:
Zhero & Rin
2026-12-02 10:37:23 +08:00
committed by 姚章浩
parent 8210af7847
commit cbce82e3f1
25 changed files with 460 additions and 140 deletions
+22
View File
@@ -21,8 +21,25 @@ var (
ErrActionNotAllowed = errors.New("reconciliation action not allowed")
ErrRemoteFailed = errors.New("reconciliation remote call failed")
ErrRuntimeUnavailable = errors.New("weknora runtime read unavailable")
ErrRuntimeForbidden = errors.New("weknora runtime read permission missing")
ErrRuntimeUnreachable = errors.New("weknora runtime endpoint unreachable")
)
// RuntimeErrorCode is the stable code the browser branches on. Unclassified
// failures return "" so callers keep their generic fallback instead of guessing.
func RuntimeErrorCode(err error) string {
switch {
case errors.Is(err, ErrRuntimeForbidden):
return "runtime_read_forbidden"
case errors.Is(err, ErrRuntimeUnreachable):
return "runtime_read_unreachable"
case errors.Is(err, ErrRuntimeUnavailable):
return "runtime_read_unavailable"
default:
return ""
}
}
type Store interface {
ReapStaleReconciliationRuns(context.Context, time.Time, time.Duration) (int64, error)
ClaimReconciliationRun(context.Context, governance.ReconciliationRun, time.Time) (governance.ReconciliationRun, error)
@@ -328,6 +345,11 @@ func (s *Service) Progress(ctx context.Context, documentID string) (governance.R
return progress, nil
case weknora.StatusCode(err) == 404:
return governance.ReconciliationProgress{}, ErrNotFound
case errors.Is(err, ErrRuntimeUnavailable), errors.Is(err, ErrRuntimeForbidden), errors.Is(err, ErrRuntimeUnreachable):
// The provider already classified the failure; collapsing it here would
// erase the distinction between "no binding", "no permission" and
// "unreachable" that the page needs.
return governance.ReconciliationProgress{}, err
default:
return governance.ReconciliationProgress{}, ErrRuntimeUnavailable
}