From 6827fa922fc688c2af43bde0baef2ce0bc34fad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E7=AB=A0=E6=B5=A9?= Date: Mon, 2 Nov 2026 11:11:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(candidate):=20=E5=A4=B9=E5=85=B7=E7=94=A8?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E6=8E=A2=E9=92=88=E8=AF=81=E7=A9=BA=E5=B9=B6?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E7=9C=9F=E5=AE=9E=E7=B4=A2=E5=BC=95=20mappin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 首轮试跑暴露三处夹具缺陷(都在 test-only 文件里,产品代码未动): - 目标骨架只核 knowledge_bases:最小夹具 schema 没有 tenants 表,改为按 KB 行数与 产品 ScopeContentEmpty 的十表计数证空; - 运行期索引曾把 GET _mapping 的结果再包一层 mappings,ES 400; 现在直接回放原 mapping 文档(properties 层级与封存时完全一致); - 目标指纹改在夹具分配桶名之后用同一份 env 计算,运行器再把桶名写进 API/worker env。 试跑两次均按 cleanup_empty_target_ui.py 精确清理并读回(resources 全不存在)。 --- .../v071/candidate_ui_fixture_test.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/internal/releaseadapter/v071/candidate_ui_fixture_test.go b/internal/releaseadapter/v071/candidate_ui_fixture_test.go index a9ec0e5..1131b68 100644 --- a/internal/releaseadapter/v071/candidate_ui_fixture_test.go +++ b/internal/releaseadapter/v071/candidate_ui_fixture_test.go @@ -91,15 +91,12 @@ UPDATE knowledge_bases SET embedding_model_id='candidate-model',vector_store_id= t.Fatalf("candidate target %s has %d rows in scope; the target must be empty before delivery", table, n) } } - var kbRows, tenantRows int64 + var kbRows int64 if err := fx.pool.QueryRow(ctx, `SELECT count(*) FROM knowledge_bases WHERE id=$1 AND tenant_id=$2`, wsTargetKB, wsTargetTenant).Scan(&kbRows); err != nil { t.Fatal(err) } - if err := fx.pool.QueryRow(ctx, `SELECT count(*) FROM tenants WHERE id=$1`, wsTargetTenant).Scan(&tenantRows); err != nil { - t.Fatal(err) - } - if kbRows != 1 || tenantRows < 1 { - t.Fatalf("empty target still needs its KB/tenant skeleton: kb=%d tenants=%d", kbRows, tenantRows) + if kbRows != 1 { + t.Fatalf("empty target still needs its KB skeleton: knowledge_bases rows=%d", kbRows) } mapping, err := fx.target(t).Search().MappingSHA256(ctx) @@ -211,8 +208,8 @@ UPDATE knowledge_bases SET embedding_model_id='candidate-model',vector_store_id= "target_fingerprint": fingerprint, "target": map[string]any{"tenant_id": wsTargetTenant, "knowledge_base_id": wsTargetKB, "database": os.Getenv("KG_LIBRARY_TEST_DATABASE_URL") != "", "empty_probe_counts": counts, - "knowledge_bases_rows": kbRows, "tenants_rows": tenantRows, - "note": "KB/tenant 骨架存在、十表内容为 0:这是首次发布的空目标,不是'没有目标'"}, + "knowledge_bases_rows": kbRows, + "note": "KB 骨架存在、十表内容为 0:这是首次发布的空目标,不是'没有目标'"}, "runtime_index": runtimeIndex, "mapping_sha256": mapping, "runtime_mapping_sha256": runtimeMapping, @@ -347,7 +344,7 @@ func candidateCreateIndex(ctx context.Context, base, index string, body map[stri return fmt.Errorf("runtime index %s already exists: refusing to reuse an unknown index", index) } } - payload, err := json.Marshal(map[string]any{"mappings": body}) + payload, err := json.Marshal(body) if err != nil { return err }