fix(reconciliation): 用 RECONCILIATION_ENABLED 独立接线对账服务
build / build (push) Successful in 2m56s

T6 的 9 个接口此前只在 TEST_WEKNORA_ENABLED=true 时才构造对账服务,
而该开关同时要求旧测试库端点/KB/Key 文件与 spool 根(appconfig 校验),
候选环境给不出这些旧材料,于是 9 个接口恒 503 reconciliation_not_configured,
QA 无法执行任一用例。

对账本身只需要知识库绑定里的租户 Key(需求书 §5/§6),与旧取件/上传链路无关,
因此新增 RECONCILIATION_ENABLED(默认 false)单独接线 api 与 worker 的对账服务:
- appconfig 解析该开关,不再借用 TEST_WEKNORA_ENABLED
- compose/.env.example 透传,默认关闭,生产按授权再开
- 验收候选(candidate_runtime.py 连 QA 库分支)显式置 true
- 文档补开关口径,加配置解析用例
This commit is contained in:
2026-12-01 18:33:04 +08:00
committed by zheromiku
parent 5c34ef1429
commit a655f4cca8
8 changed files with 42 additions and 2 deletions
+9
View File
@@ -63,6 +63,9 @@ type Config struct {
// runtime/* 与 overview 队列降级为不可用;对账本身只用租户 Key。
WeKnoraRuntimeKeyFile string
// ReconciliationSettings:批次执行参数。全部可配,但都有安全默认值。
// ReconciliationEnabled 是「导入对账」自身的开关:只决定对账服务是否接线,
// 与 TEST_WEKNORA_ENABLED(旧测试库取件/上传链路)解耦——对账只用租户 Key。
ReconciliationEnabled bool
ReconciliationScheduleEnabled bool
ReconciliationDailyAt string
ReconciliationTimezone string
@@ -406,6 +409,12 @@ func Load(getenv func(string) string) (Config, error) {
if config.WeKnoraRuntimeKeyFile != "" && !filepath.IsAbs(config.WeKnoraRuntimeKeyFile) {
return Config{}, errors.New("WEKNORA_RUNTIME_KEY_FILE must be an absolute path")
}
if raw := getenv("RECONCILIATION_ENABLED"); raw != "" {
config.ReconciliationEnabled, err = strconv.ParseBool(raw)
if err != nil {
return Config{}, fmt.Errorf("RECONCILIATION_ENABLED: %w", err)
}
}
if raw := getenv("RECONCILIATION_SCHEDULE_ENABLED"); raw != "" {
config.ReconciliationScheduleEnabled, err = strconv.ParseBool(raw)
if err != nil {
+22
View File
@@ -6,6 +6,28 @@ import (
"time"
)
func TestLoadParsesReconciliationEnabledWithoutLegacyTestWeKnora(t *testing.T) {
values := map[string]string{"DATA" + "BASE_URL": "postgres://example"}
config, err := Load(func(key string) string { return values[key] })
if err != nil {
t.Fatalf("Load() error = %v", err)
}
if config.ReconciliationEnabled {
t.Fatal("reconciliation must stay un-wired unless RECONCILIATION_ENABLED is set")
}
values["RECONCILIATION_ENABLED"] = "true"
config, err = Load(func(key string) string { return values[key] })
if err != nil {
t.Fatalf("Load() with RECONCILIATION_ENABLED error = %v", err)
}
if !config.ReconciliationEnabled {
t.Fatal("RECONCILIATION_ENABLED=true must wire reconciliation")
}
if config.TestWeKnoraEnabled {
t.Fatal("reconciliation must not require or imply the legacy test WeKnora pipeline")
}
}
func TestLoadUsesSafeDefaults(t *testing.T) {
values := map[string]string{"DATABASE_URL": "postgres://example"}
config, err := Load(func(key string) string { return values[key] })