Compare commits

...

11 Commits

Author SHA1 Message Date
Zhero & Rin 6a12196bf3 fix(reconciliation): 失败提示改中文并去掉绑定页 090
build / build (push) Successful in 1m51s
- 页面 9 个出口统一走 reconciliationMessages:四个内部码不再进入 DOM,未知码回退中文;批次行/阶段码同样翻译。
- 绑定页加载与点击前读 /api/v1/kb-bindings 预检:测试环境未配置当场提示且不发 POST;未启用优先于绑定缺失。
- 运行时读按上游 401/403 与连接失败拆成 runtime_key_forbidden / runtime_unreachable,保留 404 与未配置语义。
- EnvironmentLabel 与前端环境标签改「测试/生产知识库」,不再出现 090。
- 验:make verify 17 项全绿;go test 三包、web 656 用例、typecheck 通过。
2026-12-02 10:36:15 +08:00
zheromiku 8210af7847 Merge pull request 'fix(web): 整理发布管理页,生产已同步时不再提供启动同步' (#44) from fix/release-page-layout into main
build / build (push) Successful in 1m46s
2026-12-01 22:20:40 +08:00
zheromiku e5040d88d8 Merge pull request 'fix(reconciliation): 处置视图列名限定 + 非法 document_id 返回 400(CYWL-34)' (#50) from fix/t6-action-view-and-path into main
build / build (push) Successful in 2m41s
Merge pull request 'fix(reconciliation): 处置视图列名限定 + 非法 document_id 返回 400(CYWL-34)' (#50) from fix/t6-action-view-and-path into main
2026-12-01 20:39:22 +08:00
zheromiku 839b4ca2cf fix(reconciliation): 处置视图列名限定,非法 document_id 返回 400
build / build (push) Successful in 1m57s
QA 在候选上实测出两条:
- P0 处置接口 500:LoadReconciliationActionView 的 SELECT 用了未限定的
  reconciliationFindingColumns,而语句 JOIN 了 reconciliation_runs 与
  test_publications(两者也有 id/title/path/source),PostgreSQL 直接报
  column reference "id" is ambiguous,writeback/requeue/remove 全部 500。
  改为按别名限定列(qualifiedFindingColumns),补真库集成用例。
- R-102 契约偏差:空的 document_id 被多段路由规范化成 307、含未编码斜杠的 id
  落到 404,契约要求 400。补子树兜底路由,并在鉴权之后加 guard 把 // 路径拦成 400
  (未登录仍是 401),补接口用例。
2026-12-01 20:36:57 +08:00
zheromiku b662520439 Merge pull request 'fix(reconciliation): worker 在对账接线时注册 reconciliation.run(CYWL-34)' (#49) from fix/t6-worker-handler-gate into main
build / build (push) Successful in 2m3s
Merge pull request 'fix(reconciliation): worker 在对账接线时注册 reconciliation.run(CYWL-34)' (#49) from fix/t6-worker-handler-gate into main
2026-12-01 20:15:25 +08:00
zheromiku 9dddda8491 Merge pull request 'fix(reconciliation): 对账任务入队 id 超长导致每批 queue_unavailable(CYWL-34)' (#48) from fix/t6-enqueue-job-id into main
build / build (push) Successful in 2m17s
Merge pull request 'fix(reconciliation): 对账任务入队 id 超长导致每批 queue_unavailable(CYWL-34)' (#48) from fix/t6-enqueue-job-id into main
2026-12-01 19:49:51 +08:00
zheromiku 28fb449d17 Merge pull request 'fix(reconciliation): 定时批占位语句修 42P08(CYWL-34)' (#47) from fix/t6-schedule-claim-42p08 into main
build / build (push) Successful in 2m28s
Merge pull request 'fix(reconciliation): 定时批占位语句修 42P08(CYWL-34)' (#47) from fix/t6-schedule-claim-42p08 into main
2026-12-01 19:14:44 +08:00
zheromiku f45b6fc8c9 Merge pull request 'fix(reconciliation): R6 改用 removal_candidates 视图 + 定时批每日一位(CYWL-34)' (#46) from fix/t6-r6-count-and-scheduler into main
build / build (push) Successful in 1m58s
Merge pull request 'fix(reconciliation): R6 改用 removal_candidates 视图 + 定时批每日一位(CYWL-34)' (#46) from fix/t6-r6-count-and-scheduler into main
2026-12-01 18:58:58 +08:00
zheromiku dc28f0b65c Merge pull request 'fix(reconciliation): 用 RECONCILIATION_ENABLED 独立接线对账服务(CYWL-34)' (#45) from fix/t6-reconciliation-switch into main
build / build (push) Successful in 2m55s
Merge pull request 'fix(reconciliation): 用 RECONCILIATION_ENABLED 独立接线对账服务(CYWL-34)' (#45) from fix/t6-reconciliation-switch into main
2026-12-01 18:37:51 +08:00
姚章浩 1b2db5045a style(web): 按 prettier 格式化发布管理页
build / build (push) Successful in 2m46s
CI format 检查报 src/ReleaseTargets.tsx 新出现未格式化;只跑了 prettier --write,无逻辑改动。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 18:34:04 +08:00
姚章浩 f9e8e5e013 fix(web): 整理发布管理页,生产已同步时不再提供启动同步
build / build (push) Failing after 1m7s
配色回到全站钴蓝与中性灰 token;折叠区原先引用不存在的 CSS 变量导致无边框,已修正。生产生效版本即当前测试封存时,主按钮为不可点的「已同步」,次按钮为「重新封存测试版本」,不再催授权缺项。删去重复的测试库封存卡,生产保护卡满宽,状态四格横排。移除页面上的「文档级发布(旧流程)」与「关联旧封存来源证据」入口,后端接口保留。验证:tsc -b 通过,vitest 全量 635 通过(新增已同步用例),本机 8088 数据截图核对桌面与 390px。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 17:24:30 +08:00
31 changed files with 945 additions and 449 deletions
+1 -1
View File
@@ -50,7 +50,7 @@
"/api/v1/reconciliation/findings/{id}/writeback": {"post":{"tags":["Reconciliation"],"operationId":"writebackReconciliationFinding","summary":"仅限 R5:以 WeKnora 状态回写台账 processing_state,写审计;completed 不可降级","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-Governance-Action","in":"header","required":true,"schema":{"const":"reconciliation-action"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员或文档工程师"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"reconciliation_writeback_stale 或迁移不允许"},"500":{"$ref":"#/components/responses/InternalError"}}}}, "/api/v1/reconciliation/findings/{id}/writeback": {"post":{"tags":["Reconciliation"],"operationId":"writebackReconciliationFinding","summary":"仅限 R5:以 WeKnora 状态回写台账 processing_state,写审计;completed 不可降级","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-Governance-Action","in":"header","required":true,"schema":{"const":"reconciliation-action"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员或文档工程师"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"reconciliation_writeback_stale 或迁移不允许"},"500":{"$ref":"#/components/responses/InternalError"}}}},
"/api/v1/reconciliation/findings/{id}/requeue": {"post":{"tags":["Reconciliation"],"operationId":"requeueReconciliationFinding","summary":"仅限 R1/R4:R1 清空 document_id 后重排上传;R4 先删旧知识再重传,删除失败则台账不变","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-Governance-Action","in":"header","required":true,"schema":{"const":"reconciliation-action"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员或文档工程师"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"finding 状态或台账身份已变化"},"500":{"$ref":"#/components/responses/InternalError"}}}}, "/api/v1/reconciliation/findings/{id}/requeue": {"post":{"tags":["Reconciliation"],"operationId":"requeueReconciliationFinding","summary":"仅限 R1/R4:R1 清空 document_id 后重排上传;R4 先删旧知识再重传,删除失败则台账不变","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-Governance-Action","in":"header","required":true,"schema":{"const":"reconciliation-action"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员或文档工程师"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"finding 状态或台账身份已变化"},"500":{"$ref":"#/components/responses/InternalError"}}}},
"/api/v1/reconciliation/findings/{id}/remove": {"post":{"tags":["Reconciliation"],"operationId":"removeReconciliationFinding","summary":"仅限 R2:按远端 document_id 从测试库删除;404 视为已删除;重复点击幂等","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-Governance-Action","in":"header","required":true,"schema":{"const":"reconciliation-action"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"该文档已被现行台账收养"},"500":{"$ref":"#/components/responses/InternalError"}}}}, "/api/v1/reconciliation/findings/{id}/remove": {"post":{"tags":["Reconciliation"],"operationId":"removeReconciliationFinding","summary":"仅限 R2:按远端 document_id 从测试库删除;404 视为已删除;重复点击幂等","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-Governance-Action","in":"header","required":true,"schema":{"const":"reconciliation-action"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"该文档已被现行台账收养"},"500":{"$ref":"#/components/responses/InternalError"}}}},
"/api/v1/reconciliation/documents/{document_id}/progress": {"get":{"tags":["Reconciliation"],"operationId":"getReconciliationDocumentProgress","summary":"实时转发并脱敏 WeKnora 文档处理阶段与历史失败;未配置平台只读 Key 时返回 503 runtime_read_unavailable","parameters":[{"name":"document_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"$ref":"#/components/responses/ServiceUnavailable"}}}}, "/api/v1/reconciliation/documents/{document_id}/progress": {"get":{"tags":["Reconciliation"],"operationId":"getReconciliationDocumentProgress","summary":"实时转发并脱敏 WeKnora 文档处理阶段与历史失败;未配置平台只读 Key、Key 无权限、连接不可达时返回 503,code 分别为 runtime_read_unavailable / runtime_key_forbidden / runtime_unreachable","parameters":[{"name":"document_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"$ref":"#/components/responses/ServiceUnavailable"}}}},
"/api/v1/qa-ops/master/field-options": {"get":{"operationId":"getQAMasterFieldOptions","tags":["QA operations"],"summary":"只读主表五字段的正式可选范围,与模型共享同一分类字典;不返回业务问答","parameters":[],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员且写入须同源操作意图"},"409":{"description":"版本、输入或nonce冲突,未覆盖现有数据"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"description":"独立治理存储不可用,不将失败伪装为已保存"}}}}, "/api/v1/qa-ops/master/field-options": {"get":{"operationId":"getQAMasterFieldOptions","tags":["QA operations"],"summary":"只读主表五字段的正式可选范围,与模型共享同一分类字典;不返回业务问答","parameters":[],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员且写入须同源操作意图"},"409":{"description":"版本、输入或nonce冲突,未覆盖现有数据"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"description":"独立治理存储不可用,不将失败伪装为已保存"}}}},
"/api/v1/qa-ops/master/records/{id}/fields": {"post":{"operationId":"patchQAMasterFields","tags":["QA operations"],"summary":"只更新明确选择的字段并留幂等审计;不改原始正文、其他空白、旧复核或冻结证据。未覆盖的是否正确固定为待确认,拒绝是或否;已覆盖点踩固定为否。quality.correctness_rule=coverage-correctness-v1标记覆盖/正确性固定投影,原字段和复核证据保留","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-Governance-Action","in":"header","required":true,"schema":{"const":"qa-master-fields"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员且写入须同源操作意图"},"409":{"description":"版本、输入或nonce冲突,未覆盖现有数据"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"description":"独立治理存储不可用,不将失败伪装为已保存"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["input_hash","input_epoch","base_revision","base_review_revision","nonce","fields"],"properties":{"input_hash":{"type":"string","pattern":"^[a-f0-9]{64}$"},"input_epoch":{"type":"integer","minimum":1},"base_revision":{"type":"integer","minimum":0},"base_review_revision":{"type":"integer","minimum":0},"nonce":{"type":"string","pattern":"^[a-zA-Z0-9][a-zA-Z0-9_.:-]{15,127}$"},"fields":{"type":"object","additionalProperties":false,"minProperties":1,"maxProperties":5,"properties":{"is_correct":{"type":"string","enum":["是","否","待确认"]},"product_category":{"type":"string","enum":["CR/CRA/H/AP","CRV","CR配件","Nova及系列","Nova配件","MG400","MG400配件","M1 Pro","VX500","新示教器","DobotStudio Pro","仿真软件","维护工具","教育所有产品","人形机器人","四六足机器人","X-Trainer","码垛解决方案","码垛插件","焊接解决方案","焊接插件","移动复合机器人","生态插件","生态合作","安全皮肤","未知"]},"problem_type":{"type":"string","enum":["参数","故障","使用配置","二次开发","资料获取","咨询","认证","案例","售后","培训与学习","其他"]},"root_cause":{"type":"string","enum":["知识缺失","检索不到","结果不清","答案生成错误","问题质量差","非知识范围","知识过期"]},"coverage":{"type":"string","enum":["是","否","否但不计入"]}}}}}}}}}}, "/api/v1/qa-ops/master/records/{id}/fields": {"post":{"operationId":"patchQAMasterFields","tags":["QA operations"],"summary":"只更新明确选择的字段并留幂等审计;不改原始正文、其他空白、旧复核或冻结证据。未覆盖的是否正确固定为待确认,拒绝是或否;已覆盖点踩固定为否。quality.correctness_rule=coverage-correctness-v1标记覆盖/正确性固定投影,原字段和复核证据保留","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-Governance-Action","in":"header","required":true,"schema":{"const":"qa-master-fields"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员且写入须同源操作意图"},"409":{"description":"版本、输入或nonce冲突,未覆盖现有数据"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"description":"独立治理存储不可用,不将失败伪装为已保存"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["input_hash","input_epoch","base_revision","base_review_revision","nonce","fields"],"properties":{"input_hash":{"type":"string","pattern":"^[a-f0-9]{64}$"},"input_epoch":{"type":"integer","minimum":1},"base_revision":{"type":"integer","minimum":0},"base_review_revision":{"type":"integer","minimum":0},"nonce":{"type":"string","pattern":"^[a-zA-Z0-9][a-zA-Z0-9_.:-]{15,127}$"},"fields":{"type":"object","additionalProperties":false,"minProperties":1,"maxProperties":5,"properties":{"is_correct":{"type":"string","enum":["是","否","待确认"]},"product_category":{"type":"string","enum":["CR/CRA/H/AP","CRV","CR配件","Nova及系列","Nova配件","MG400","MG400配件","M1 Pro","VX500","新示教器","DobotStudio Pro","仿真软件","维护工具","教育所有产品","人形机器人","四六足机器人","X-Trainer","码垛解决方案","码垛插件","焊接解决方案","焊接插件","移动复合机器人","生态插件","生态合作","安全皮肤","未知"]},"problem_type":{"type":"string","enum":["参数","故障","使用配置","二次开发","资料获取","咨询","认证","案例","售后","培训与学习","其他"]},"root_cause":{"type":"string","enum":["知识缺失","检索不到","结果不清","答案生成错误","问题质量差","非知识范围","知识过期"]},"coverage":{"type":"string","enum":["是","否","否但不计入"]}}}}}}}}}},
"/api/v1/qa-ops/master/weekly-drafts/{week}": {"get":{"operationId":"getQAWeeklyDraft","tags":["QA operations"],"summary":"读取租户指定北京时间ISO周的持久草稿;不存在时revision=0且不创建记录","parameters":[{"name":"week","in":"path","required":true,"schema":{"type":"string","pattern":"^[0-9]{4}-W[0-9]{2}$"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员且写入须同源操作意图"},"409":{"description":"版本、输入或nonce冲突,未覆盖现有数据"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"description":"独立治理存储不可用,不将失败伪装为已保存"}}},"post":{"operationId":"saveQAWeeklyDraft","tags":["QA operations"],"summary":"防抖编辑保存:版本锁、逐版历史及同nonce重放;正文不会触发外发/归档","parameters":[{"name":"week","in":"path","required":true,"schema":{"type":"string","pattern":"^[0-9]{4}-W[0-9]{2}$"}},{"name":"X-Governance-Action","in":"header","required":true,"schema":{"const":"qa-weekly-draft"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员且写入须同源操作意图"},"409":{"description":"版本、输入或nonce冲突,未覆盖现有数据"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"description":"独立治理存储不可用,不将失败伪装为已保存"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["base_revision","nonce","markdown"],"properties":{"base_revision":{"type":"integer","minimum":0},"nonce":{"type":"string","pattern":"^[a-zA-Z0-9][a-zA-Z0-9_.:-]{15,127}$"},"markdown":{"type":"string","maxLength":262144,"description":"UTF-8正文最多256KiB;允许空正文,保存草稿不等于发布"}}}}}}}}, "/api/v1/qa-ops/master/weekly-drafts/{week}": {"get":{"operationId":"getQAWeeklyDraft","tags":["QA operations"],"summary":"读取租户指定北京时间ISO周的持久草稿;不存在时revision=0且不创建记录","parameters":[{"name":"week","in":"path","required":true,"schema":{"type":"string","pattern":"^[0-9]{4}-W[0-9]{2}$"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员且写入须同源操作意图"},"409":{"description":"版本、输入或nonce冲突,未覆盖现有数据"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"description":"独立治理存储不可用,不将失败伪装为已保存"}}},"post":{"operationId":"saveQAWeeklyDraft","tags":["QA operations"],"summary":"防抖编辑保存:版本锁、逐版历史及同nonce重放;正文不会触发外发/归档","parameters":[{"name":"week","in":"path","required":true,"schema":{"type":"string","pattern":"^[0-9]{4}-W[0-9]{2}$"}},{"name":"X-Governance-Action","in":"header","required":true,"schema":{"const":"qa-weekly-draft"}}],"responses":{"200":{"$ref":"#/components/responses/Envelope"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"需要登录"},"403":{"description":"仅管理员且写入须同源操作意图"},"409":{"description":"版本、输入或nonce冲突,未覆盖现有数据"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"description":"独立治理存储不可用,不将失败伪装为已保存"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["base_revision","nonce","markdown"],"properties":{"base_revision":{"type":"integer","minimum":0},"nonce":{"type":"string","pattern":"^[a-zA-Z0-9][a-zA-Z0-9_.:-]{15,127}$"},"markdown":{"type":"string","maxLength":262144,"description":"UTF-8正文最多256KiB;允许空正文,保存草稿不等于发布"}}}}}}}},
+2 -2
View File
@@ -123,7 +123,7 @@ WeKnora v0.9.1 新增了系统管理员「任务队列」(CHANGELOG #4732、#5
- 键名 `WEKNORA_RUNTIME_KEY_FILE`,值为**绝对路径**,secret 文件挂载进容器;不写进 compose 环境变量、不进 Git。 - 键名 `WEKNORA_RUNTIME_KEY_FILE`,值为**绝对路径**,secret 文件挂载进容器;不写进 compose 环境变量、不进 Git。
- 启动时读取一次,权限 0400;换 Key 需重启平台(与现有 `*_API_KEY_FILE` 一致,不做热加载)。 - 启动时读取一次,权限 0400;换 Key 需重启平台(与现有 `*_API_KEY_FILE` 一致,不做热加载)。
- “变量为空”与“变量有值但文件缺失/不可读”要区分:前者静默降级;后者启动不失败,写一条 WARN 日志,运行时按未配置处理。 - “变量为空”与“变量有值但文件缺失/不可读”要区分:前者静默降级;后者启动不失败,写一条 WARN 日志,运行时按未配置处理。
- 两种情况都让 `runtime/queues`、`runtime/documents/{id}` 返回 503 `runtime_read_unavailable`,`/monitor/overview` 的 `weknora_queues` 为 `null`;对账本身只需租户 Key,照常运行。 - 两种情况都让 `runtime/queues` 返回 503 `runtime_read_unavailable`、`/monitor/overview` 的 `weknora_queues` 为 `null`;`runtime/documents/{id}` 另按上游结果细分:未配置 Key → `runtime_read_unavailable`,401/403 → `runtime_key_forbidden`,其他连接/上游失败 → `runtime_unreachable`。对账本身只需租户 Key,照常运行。
## 6. 运行方式 ## 6. 运行方式
@@ -154,7 +154,7 @@ T6a 的**第一个提交**必须先把以下接口写进 `api/openapi.yaml`,
| POST | `/api/v1/reconciliation/findings/{id}/writeback` | 仅限 R5:以 WeKnora 状态回写台账,写审计;返回更新后的 finding | 管理员、文档工程师 | | POST | `/api/v1/reconciliation/findings/{id}/writeback` | 仅限 R5:以 WeKnora 状态回写台账,写审计;返回更新后的 finding | 管理员、文档工程师 |
| POST | `/api/v1/reconciliation/findings/{id}/requeue` | 仅限 R1/R4:R1 清空 `knowledge_id` 后重排上传;R4 先删旧 knowledge 再重传,删除失败则动作失败且台账不变;写审计 | 管理员、文档工程师 | | POST | `/api/v1/reconciliation/findings/{id}/requeue` | 仅限 R1/R4:R1 清空 `knowledge_id` 后重排上传;R4 先删旧 knowledge 再重传,删除失败则动作失败且台账不变;写审计 | 管理员、文档工程师 |
| POST | `/api/v1/reconciliation/findings/{id}/remove` | 仅限 R2:按 `knowledge_id` 从测试库删除,404 视为已删除;写审计;重复点击幂等 | 管理员 | | POST | `/api/v1/reconciliation/findings/{id}/remove` | 仅限 R2:按 `knowledge_id` 从测试库删除,404 视为已删除;写审计;重复点击幂等 | 管理员 |
| GET | `/api/v1/reconciliation/documents/{document_id}/progress` | 实时转发 WeKnora `runtime/documents/{id}`,经过脱敏;未配置平台 Key 时返回 503 `runtime_read_unavailable` | 所有登录角色 | | GET | `/api/v1/reconciliation/documents/{document_id}/progress` | 实时转发 WeKnora `runtime/documents/{id}`,经过脱敏;未配置平台 Key、Key 无权限、连接不可达时返回 503,code 分别为 `runtime_read_unavailable` / `runtime_key_forbidden` / `runtime_unreachable` | 所有登录角色 |
| GET | `/api/v1/monitor/overview`(已有) | 新增 `weknora_queues` 字段(来自 `runtime/queues`,不可用时为 null);删除 Embedding/LLM 两张常量"未知"卡 | 不变 | | GET | `/api/v1/monitor/overview`(已有) | 新增 `weknora_queues` 字段(来自 `runtime/queues`,不可用时为 null);删除 Embedding/LLM 两张常量"未知"卡 | 不变 |
**`/api/v1/monitor/tasks`(已有,T6a 增量)**:每行新增可选 `weknora_url`(目标测试知识库的 WeKnora 控制台链接;未配置测试端点时为空字符串),供文件详情抽屉在 progress 返回 503 时显示跳转链接。该字段为附加字段,既有字段与筛选语义不变;与 finding 的 `weknora_url` 使用同一拼接规则(`internal/platform/weknora.KnowledgeBaseConsoleURL`)。 **`/api/v1/monitor/tasks`(已有,T6a 增量)**:每行新增可选 `weknora_url`(目标测试知识库的 WeKnora 控制台链接;未配置测试端点时为空字符串),供文件详情抽屉在 progress 返回 503 时显示跳转链接。该字段为附加字段,既有字段与筛选语义不变;与 finding 的 `weknora_url` 使用同一拼接规则(`internal/platform/weknora.KnowledgeBaseConsoleURL`)。
+1 -1
View File
@@ -145,7 +145,7 @@ T6a 对账后端(第一个提交 = OpenAPI 契约)──► T6b 对账前端
- 新建 `reconciliation_runs` / `reconciliation_findings` 两张表:`runs` 永久保留;`findings` 按 `run_id` 整批清理,保留最近 30 批且不超过 90 天(Q5)。同一测试库的 `running` 批次用部分唯一索引约束(`WHERE state='running'`)。 - 新建 `reconciliation_runs` / `reconciliation_findings` 两张表:`runs` 永久保留;`findings` 按 `run_id` 整批清理,保留最近 30 批且不超过 90 天(Q5)。同一测试库的 `running` 批次用部分唯一索引约束(`WHERE state='running'`)。
- 对账扫描使用 `page_size=1000`:要把 `internal/platform/weknora/client.go` 的 `validPage` 上限从 100 放开(或给对账单独一条扫描路径),不能沿用上传恢复的 100。扫描全程串行(在途 1 个请求),R1/R2 确认可用 `reconciliation_confirm_concurrency`(默认 1、上限 8),不复用 `ingestion_concurrency`。 - 对账扫描使用 `page_size=1000`:要把 `internal/platform/weknora/client.go` 的 `validPage` 上限从 100 放开(或给对账单独一条扫描路径),不能沿用上传恢复的 100。扫描全程串行(在途 1 个请求),R1/R2 确认可用 `reconciliation_confirm_concurrency`(默认 1、上限 8),不复用 `ingestion_concurrency`。
- 与整库导出/发布不互斥;批次开始和结束时各检测一次是否有导出/发布作业在跑,命中则写 `window_overlapped=true`,该批 R1/R2 的 `confirmation_state='pending'`(Q6)。 - 与整库导出/发布不互斥;批次开始和结束时各检测一次是否有导出/发布作业在跑,命中则写 `window_overlapped=true`,该批 R1/R2 的 `confirmation_state='pending'`(Q6)。
- 平台级只读 Key 走 `WEKNORA_RUNTIME_KEY_FILE`(绝对路径 secret 文件,启动读取一次,不做热加载);未配置或文件不可读时 `runtime/*` 返回 503 `runtime_read_unavailable`,对账不受影响(Q7)。 - 平台级只读 Key 走 `WEKNORA_RUNTIME_KEY_FILE`(绝对路径 secret 文件,启动读取一次,不做热加载);未配置或文件不可读时 `runtime/queues` 返回 503 `runtime_read_unavailable`,`runtime/documents/{id}` 按上游结果细分 `runtime_read_unavailable` / `runtime_key_forbidden` / `runtime_unreachable`,对账不受影响(Q7)。
- 状态映射只写在服务端一处,接口返回 `normalized_state`;R5 回写按迁移矩阵校验,`completed` 不可降级。 - 状态映射只写在服务端一处,接口返回 `normalized_state`;R5 回写按迁移矩阵校验,`completed` 不可降级。
- 处置动作:新增 finding 级 `requeue`(R1/R4)与 `remove`(R2);R6 复用现有 `POST /test-publications/{id}/removal`(`removal-retry` 只重试已失败移除)。R1/R4 不能走 `retryPublicationsBatch`,R2 不能走测试库移除,原因见需求 §7(Q9)。 - 处置动作:新增 finding 级 `requeue`(R1/R4)与 `remove`(R2);R6 复用现有 `POST /test-publications/{id}/removal`(`removal-retry` 只重试已失败移除)。R1/R4 不能走 `retryPublicationsBatch`,R2 不能走测试库移除,原因见需求 §7(Q9)。
- 扫描保留 offset 翻页,不引入游标;并发增删造成的个别漏项在下一批补上(Q10)。 - 扫描保留 offset 翻页,不引入游标;并发增删造成的个别漏项在下一批补上(Q10)。
+4
View File
@@ -46,6 +46,10 @@ func writeReconciliationError(w http.ResponseWriter, err error) {
writeJSON(w, http.StatusNotFound, map[string]string{"error": "reconciliation record not found"}) writeJSON(w, http.StatusNotFound, map[string]string{"error": "reconciliation record not found"})
case errors.Is(err, reconciliation.ErrActionConflict), errors.Is(err, reconciliation.ErrActionNotAllowed): case errors.Is(err, reconciliation.ErrActionConflict), errors.Is(err, reconciliation.ErrActionNotAllowed):
writeJSON(w, http.StatusConflict, map[string]string{"error": "reconciliation_state_changed", "code": "reconciliation_state_changed"}) writeJSON(w, http.StatusConflict, map[string]string{"error": "reconciliation_state_changed", "code": "reconciliation_state_changed"})
case errors.Is(err, reconciliation.ErrRuntimeForbidden):
writeJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "runtime_key_forbidden", "code": "runtime_key_forbidden"})
case errors.Is(err, reconciliation.ErrRuntimeUnreachable):
writeJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "runtime_unreachable", "code": "runtime_unreachable"})
case errors.Is(err, reconciliation.ErrRuntimeUnavailable): case errors.Is(err, reconciliation.ErrRuntimeUnavailable):
writeJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "runtime_read_unavailable", "code": "runtime_read_unavailable"}) writeJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "runtime_read_unavailable", "code": "runtime_read_unavailable"})
case errors.Is(err, reconciliation.ErrRemoteFailed): case errors.Is(err, reconciliation.ErrRemoteFailed):
+40
View File
@@ -126,3 +126,43 @@ func TestReconciliationFindingTypeValidation(t *testing.T) {
t.Fatalf("invalid type = %d", recorder.Code) t.Fatalf("invalid type = %d", recorder.Code)
} }
} }
func TestReconciliationProgressRejectsMalformedDocumentIDWith400(t *testing.T) {
service := &reconciliationServiceStub{}
handler, err := NewHandler(Config{Store: &fakeJobStore{}, Reconciliation: service})
if err != nil {
t.Fatal(err)
}
for _, path := range []string{
"/api/v1/reconciliation/documents//progress",
"/api/v1/reconciliation/documents/doc-1/extra/progress",
} {
recorder := httptest.NewRecorder()
handler.ServeHTTP(recorder, reconciliationRequest(http.MethodGet, path, roleViewer, ""))
if recorder.Code != http.StatusBadRequest || !strings.Contains(recorder.Body.String(), "invalid document id") {
t.Fatalf("%s = %d %s, want 400 invalid document id", path, recorder.Code, recorder.Body.String())
}
}
}
func TestReconciliationProgressClassifiesRuntimeFailures(t *testing.T) {
cases := []struct {
err error
code string
}{
{reconciliation.ErrRuntimeForbidden, "runtime_key_forbidden"},
{reconciliation.ErrRuntimeUnreachable, "runtime_unreachable"},
{reconciliation.ErrRuntimeUnavailable, "runtime_read_unavailable"},
}
for _, tc := range cases {
handler, err := NewHandler(Config{Store: &fakeJobStore{}, Reconciliation: &reconciliationServiceStub{err: tc.err}})
if err != nil {
t.Fatal(err)
}
recorder := httptest.NewRecorder()
handler.ServeHTTP(recorder, reconciliationRequest(http.MethodGet, "/api/v1/reconciliation/documents/doc-1/progress", roleViewer, ""))
if recorder.Code != http.StatusServiceUnavailable || !strings.Contains(recorder.Body.String(), tc.code) {
t.Fatalf("%v = %d %s, want 503 %s", tc.err, recorder.Code, recorder.Body.String(), tc.code)
}
}
}
+19 -2
View File
@@ -855,15 +855,32 @@ func NewHandler(config Config) (http.Handler, error) {
mux.HandleFunc("POST /api/v1/job-failures/{id}/requeue", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("POST /api/v1/job-failures/{id}/requeue", func(w http.ResponseWriter, r *http.Request) {
requeueJobFailure(w, r, config) requeueJobFailure(w, r, config)
}) })
// 契约要求非法 document_id 返回 400:空段(documents//progress)会被 ServeMux
// 规范化成 307,含未编码斜杠的 id 会落到 404。这里在路由前判定形状,且不新增
// 端点(契约已冻结);放在鉴权之后,未登录仍是 401,保持 401 → 400 的顺序。
guard := func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
const prefix = "/api/v1/reconciliation/documents/"
if strings.HasPrefix(r.URL.Path, prefix) {
rest := strings.TrimPrefix(r.URL.Path, prefix)
segments := strings.Split(rest, "/")
if strings.Contains(r.URL.Path, "//") || len(segments) != 2 || segments[0] == "" || segments[1] != "progress" {
writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid document id"})
return
}
}
next.ServeHTTP(w, r)
})
}
if config.Auth != nil { if config.Auth != nil {
if config.Auth.Store == nil { if config.Auth.Store == nil {
return nil, errors.New("auth configuration requires a store") return nil, errors.New("auth configuration requires a store")
} }
config.authRoutes(mux) config.authRoutes(mux)
config.userRoutes(mux) config.userRoutes(mux)
return masterNoStore(config.Auth.authenticate(mux)), nil return masterNoStore(config.Auth.authenticate(guard(mux))), nil
} }
return masterNoStore(mux), nil return masterNoStore(guard(mux)), nil
} }
type createJobRequest struct { type createJobRequest struct {
+2 -2
View File
@@ -30,9 +30,9 @@ func ValidEnvironment(value string) bool {
func EnvironmentLabel(value string) string { func EnvironmentLabel(value string) string {
if value == EnvProduction { if value == EnvProduction {
return "生产 090" return "生产知识库"
} }
return "测试 090" return "测试知识库"
} }
var ( var (
+9
View File
@@ -221,3 +221,12 @@ func TestAuditTextBoundsWithoutSplittingUTF8(t *testing.T) {
t.Fatal("blank audit source must stay empty, never a placeholder") t.Fatal("blank audit source must stay empty, never a placeholder")
} }
} }
func TestEnvironmentLabelNamesTheKnowledgeBaseNotTheOldVersion(t *testing.T) {
if got := EnvironmentLabel(EnvTest); got != "测试知识库" {
t.Fatalf("test label = %q", got)
}
if got := EnvironmentLabel(EnvProduction); got != "生产知识库" {
t.Fatalf("production label = %q", got)
}
}
@@ -112,3 +112,51 @@ func TestScheduledReconciliationClaimsOncePerDayAfterFailure(t *testing.T) {
t.Fatalf("next-day claim claimed=%t err=%v", claimed, err) t.Fatalf("next-day claim claimed=%t err=%v", claimed, err)
} }
} }
// TestLoadReconciliationActionViewJoinsWithoutAmbiguity freezes the action-view
// SQL: it joins reconciliation_runs and test_publications, both of which also
// own id/title/path, so an unqualified column list fails with
// `column reference "id" is ambiguous` and every writeback/requeue/remove
// answered 500 instead of touching the finding.
func TestLoadReconciliationActionViewJoinsWithoutAmbiguity(t *testing.T) {
url := isolatedIntegrationDatabaseURL(t, os.Getenv("TEST_DATABASE_URL"))
if url == "" {
t.Skip("TEST_DATABASE_URL is not set")
}
ctx := context.Background()
pool, err := pgxpool.New(ctx, url)
if err != nil {
t.Fatal(err)
}
defer pool.Close()
if err := ApplyMigrations(ctx, pool); err != nil {
t.Fatal(err)
}
started := time.Date(2026, 12, 1, 2, 0, 0, 0, time.UTC)
exec := func(query string, args ...any) {
t.Helper()
if _, err := pool.Exec(ctx, query, args...); err != nil {
t.Fatal(err)
}
}
exec(`INSERT INTO source_connections(id,source_type,name,enabled) VALUES('conn-action','dingtalk','处置视图用例',TRUE)`)
exec(`INSERT INTO source_items(id,source_connection_id,stable_external_id,canonical_uri_hash,title,item_type,policy_state)
VALUES('si-action','conn-action','action.md',repeat('d',64),'处置视图','file','blocked')`)
exec(`INSERT INTO source_item_versions(id,source_item_id,revision,content_state) VALUES('sv-action','si-action','r1','verified')`)
exec(`INSERT INTO test_publications(id,source_item_version_id,test_kb_id,knowledge_id,ingest_state,processing_state,retrieval_state)
VALUES('pub-action','sv-action','kb-action','doc-action','uploaded','completed','unpublished')`)
exec(`INSERT INTO reconciliation_runs(id,test_kb_id,state,trigger,started_at,counts,created_at)
VALUES('run-action','kb-action','succeeded','manual',$1,'{}'::jsonb,$1)`, started)
exec(`INSERT INTO reconciliation_findings(id,run_id,finding_type,publication_id,knowledge_id,title,ledger_state,suggested_action)
VALUES('finding-action','run-action','R6','pub-action','doc-action','处置视图','completed','enter_removal')`)
store := NewStore(pool)
view, err := store.LoadReconciliationActionView(ctx, "finding-action")
if err != nil {
t.Fatalf("action view error = %v (ambiguous columns surface here)", err)
}
if view.TestKBID != "kb-action" || !view.CurrentExists || view.CurrentProcessingState != "completed" ||
view.CurrentKnowledgeID != "doc-action" || view.Finding.ID != "finding-action" {
t.Fatalf("action view = %#v", view)
}
}
@@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"strings"
"time" "time"
"github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5"
@@ -315,6 +316,19 @@ const reconciliationFindingColumns = `id,run_id,finding_type,publication_id,know
target_scope,ledger_state,weknora_parse_status,normalized_state,ledger_sha256,declared_sha256, target_scope,ledger_state,weknora_parse_status,normalized_state,ledger_sha256,declared_sha256,
weknora_file_md5,evidence_level,confirmation_state,detail,suggested_action,action_state,weknora_url` weknora_file_md5,evidence_level,confirmation_state,detail,suggested_action,action_state,weknora_url`
// qualifiedFindingColumns prefixes every column with the table alias. A bare
// column list breaks as soon as the finding is joined with reconciliation_runs
// or test_publications: those tables also have id/title/path/source, so
// PostgreSQL rejects the statement with "column reference \"id\" is ambiguous"
// and every writeback/requeue/remove answered 500.
func qualifiedFindingColumns(alias string) string {
columns := strings.Split(reconciliationFindingColumns, ",")
for index, column := range columns {
columns[index] = alias + "." + strings.TrimSpace(column)
}
return strings.Join(columns, ",")
}
func scanReconciliationFinding(row rowScanner) (governance.ReconciliationFinding, error) { func scanReconciliationFinding(row rowScanner) (governance.ReconciliationFinding, error) {
var finding governance.ReconciliationFinding var finding governance.ReconciliationFinding
if err := row.Scan(&finding.ID, &finding.RunID, &finding.Type, &finding.PublicationID, &finding.DocumentID, if err := row.Scan(&finding.ID, &finding.RunID, &finding.Type, &finding.PublicationID, &finding.DocumentID,
@@ -390,7 +404,7 @@ func lockOpenReconciliationFinding(ctx context.Context, tx pgx.Tx, id string) er
func (s *Store) LoadReconciliationActionView(ctx context.Context, findingID string) (governance.ReconciliationActionView, error) { func (s *Store) LoadReconciliationActionView(ctx context.Context, findingID string) (governance.ReconciliationActionView, error) {
var view governance.ReconciliationActionView var view governance.ReconciliationActionView
var currentExists bool var currentExists bool
row := s.db.QueryRow(ctx, `SELECT `+reconciliationFindingColumns+`, row := s.db.QueryRow(ctx, `SELECT `+qualifiedFindingColumns("finding")+`,
run.test_kb_id,run.started_at, run.test_kb_id,run.started_at,
publication.id IS NOT NULL, publication.id IS NOT NULL,
COALESCE(publication.processing_state,''),COALESCE(publication.knowledge_id,''), COALESCE(publication.processing_state,''),COALESCE(publication.knowledge_id,''),
+7 -2
View File
@@ -2,6 +2,7 @@ package reconciliation
import ( import (
"context" "context"
"net/http"
"strings" "strings"
"time" "time"
@@ -96,10 +97,14 @@ func (p *RuntimeProvider) DocumentProgress(ctx context.Context, documentID strin
} }
detail, err := client.DocumentProgress(ctx, documentID) detail, err := client.DocumentProgress(ctx, documentID)
if err != nil { if err != nil {
if weknora.IsNotFound(err) { switch {
case weknora.IsNotFound(err):
return governance.ReconciliationProgress{}, err return governance.ReconciliationProgress{}, err
case weknora.StatusCode(err) == http.StatusUnauthorized || weknora.StatusCode(err) == http.StatusForbidden:
return governance.ReconciliationProgress{}, ErrRuntimeForbidden
default:
return governance.ReconciliationProgress{}, ErrRuntimeUnreachable
} }
return governance.ReconciliationProgress{}, ErrRuntimeUnavailable
} }
progress := governance.ReconciliationProgress{ progress := governance.ReconciliationProgress{
DocumentID: detail.Document.ID, ParseStatus: detail.Document.ParseStatus, DocumentID: detail.Document.ID, ParseStatus: detail.Document.ParseStatus,
+42
View File
@@ -107,3 +107,45 @@ func TestRuntimeProviderDropsSensitiveUpstreamFields(t *testing.T) {
t.Fatalf("projection dropped real fields: %#v", progress) t.Fatalf("projection dropped real fields: %#v", progress)
} }
} }
func TestRuntimeProviderClassifiesForbiddenAndUnreachable(t *testing.T) {
cases := []struct {
name string
status int
want error
}{
{"forbidden", http.StatusForbidden, ErrRuntimeForbidden},
{"unauthorized", http.StatusUnauthorized, ErrRuntimeForbidden},
{"upstream-500", http.StatusInternalServerError, ErrRuntimeUnreachable},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(tc.status)
}))
defer server.Close()
provider := NewRuntimeProvider(RuntimeConfig{
BaseURL: func(context.Context) string { return server.URL },
APIKey: "runtime-key", Timeout: 5 * time.Second,
})
if _, err := provider.DocumentProgress(context.Background(), "doc-1"); !errors.Is(err, tc.want) {
t.Fatalf("status %d err=%v, want %v", tc.status, err, tc.want)
}
})
}
}
func TestRuntimeProviderClassifiesClosedListenerAsUnreachable(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = json.NewEncoder(w).Encode(map[string]any{"success": true, "data": map[string]any{}})
}))
url := server.URL
server.Close()
provider := NewRuntimeProvider(RuntimeConfig{
BaseURL: func(context.Context) string { return url },
APIKey: "runtime-key", Timeout: 2 * time.Second,
})
if _, err := provider.DocumentProgress(context.Background(), "doc-1"); !errors.Is(err, ErrRuntimeUnreachable) {
t.Fatalf("closed listener err=%v, want %v", err, ErrRuntimeUnreachable)
}
}
+7
View File
@@ -21,6 +21,10 @@ var (
ErrActionNotAllowed = errors.New("reconciliation action not allowed") ErrActionNotAllowed = errors.New("reconciliation action not allowed")
ErrRemoteFailed = errors.New("reconciliation remote call failed") ErrRemoteFailed = errors.New("reconciliation remote call failed")
ErrRuntimeUnavailable = errors.New("weknora runtime read unavailable") ErrRuntimeUnavailable = errors.New("weknora runtime read unavailable")
// ErrRuntimeForbidden / ErrRuntimeUnreachable 把「Key 无权限」与「连不上」
// 从 ErrRuntimeUnavailable 里拆出来:页面要给两种不同的中文,不能再折叠。
ErrRuntimeForbidden = errors.New("weknora runtime key forbidden")
ErrRuntimeUnreachable = errors.New("weknora runtime read unreachable")
) )
type Store interface { type Store interface {
@@ -326,6 +330,9 @@ func (s *Service) Progress(ctx context.Context, documentID string) (governance.R
switch { switch {
case err == nil: case err == nil:
return progress, nil return progress, nil
case errors.Is(err, ErrRuntimeForbidden), errors.Is(err, ErrRuntimeUnreachable), errors.Is(err, ErrRuntimeUnavailable):
// Provider 已经分好类;这里若再折叠,页面就永远看不到两种不同原因。
return governance.ReconciliationProgress{}, err
case weknora.StatusCode(err) == 404: case weknora.StatusCode(err) == 404:
return governance.ReconciliationProgress{}, ErrNotFound return governance.ReconciliationProgress{}, ErrNotFound
default: default:
+15
View File
@@ -580,3 +580,18 @@ func TestCreateRunEnqueuesJobWithinJobIDLimit(t *testing.T) {
t.Fatalf("payload = %s", request.Payload) t.Fatalf("payload = %s", request.Payload)
} }
} }
type progressRuntimeStub struct{ err error }
func (s progressRuntimeStub) DocumentProgress(context.Context, string) (governance.ReconciliationProgress, error) {
return governance.ReconciliationProgress{}, s.err
}
func TestProgressPassesProviderClassificationInsteadOfRefolding(t *testing.T) {
for _, want := range []error{ErrRuntimeForbidden, ErrRuntimeUnreachable, ErrRuntimeUnavailable} {
service := &Service{runtime: progressRuntimeStub{err: want}}
if _, err := service.Progress(context.Background(), "doc-1"); !errors.Is(err, want) {
t.Fatalf("Progress err=%v, want %v", err, want)
}
}
}
-47
View File
@@ -410,53 +410,6 @@ export function ModulePage({
return ( return (
<div className="release-module"> <div className="release-module">
<ReleaseTargets /> <ReleaseTargets />
<details className="release-legacy">
<summary>文档级发布(旧流程,折叠保留):单篇文档发布成功不等于整库发布成功</summary>
<ReleaseManagement
reviewPage={reviewPage}
reviewLoading={reviewLoading}
reviewError={reviewError}
reviewingId={reviewingId}
batchPage={batchPage}
batchDetail={batchDetail}
batchLoading={batchLoading}
batchError={batchError}
mutatingBatchId={mutatingBatchId}
onReview={onReview}
onBatchReview={onBatchReview}
reviewBatchMessage={reviewBatchMessage}
onReviewRefresh={onReviewRefresh}
onCreateBatch={onCreateBatch}
onSealBatch={onSealBatch}
onSelectBatch={onSelectBatch}
onBatchRefresh={onBatchRefresh}
releaseCapabilities={releaseCapabilities}
releasePlan={releasePlan}
releaseChangeSet={releaseChangeSet}
changeSetBusy={changeSetBusy}
changeSetError={changeSetError}
onGenerateChangeSet={onGenerateChangeSet}
onConfirmChangeSet={onConfirmChangeSet}
selectedDeleteIDs={selectedDeleteIDs}
onToggleDelete={onToggleDelete}
executionPage={executionPage}
executionDetail={executionDetail}
executionChain={executionChain}
executionLoading={executionLoading}
executionError={executionError}
onSelectExecution={onSelectExecution}
onExecutionRefresh={onExecutionRefresh}
pendingReleaseAction={pendingReleaseAction}
releaseActionPhrase={releaseActionPhrase}
releaseActionBusy={releaseActionBusy}
releaseActionError={releaseActionError}
releaseActionMessage={releaseActionMessage}
onStartReleaseAction={onStartReleaseAction}
onReleaseActionPhrase={onReleaseActionPhrase}
onSubmitReleaseAction={onSubmitReleaseAction}
onCancelReleaseAction={onCancelReleaseAction}
/>
</details>
</div> </div>
) )
} }
+6 -6
View File
@@ -140,12 +140,12 @@ describe('KnowledgeBaseBinding', () => {
}) })
) )
await render() await render()
expect(host.textContent).toContain('当前生效 · 测试 090') expect(host.textContent).toContain('当前生效 · 测试知识库')
expect(host.textContent).toContain('test 内部资料(kb-test-…)') expect(host.textContent).toContain('test 内部资料(kb-test-…)')
await click('验证并读取知识库') await click('验证并读取知识库')
await click('生产 090') await click('生产知识库')
expect(host.textContent).toContain('当前生效 · 生产 090') expect(host.textContent).toContain('当前生效 · 生产知识库')
expect(host.textContent).toContain('production 内部资料') expect(host.textContent).toContain('production 内部资料')
await act(async () => { await act(async () => {
@@ -175,7 +175,7 @@ describe('KnowledgeBaseBinding', () => {
expect(host.textContent).toContain('候选实例拒绝保存') expect(host.textContent).toContain('候选实例拒绝保存')
// 顶部当前生效仍是旧值;草稿只存在于下方。 // 顶部当前生效仍是旧值;草稿只存在于下方。
expect(host.textContent).toContain('test 内部资料(kb-test-…)') expect(host.textContent).toContain('test 内部资料(kb-test-…)')
expect(host.textContent).not.toContain('当前生效 · 测试 090新内部库') expect(host.textContent).not.toContain('当前生效 · 测试知识库新内部库')
const put = fetchMock.mock.calls.find((call) => call[1]?.method === 'PUT') const put = fetchMock.mock.calls.find((call) => call[1]?.method === 'PUT')
expect(put).toBeTruthy() expect(put).toBeTruthy()
const body = JSON.parse(String((put![1] as { body: string }).body)) const body = JSON.parse(String((put![1] as { body: string }).body))
@@ -250,11 +250,11 @@ describe('KnowledgeBaseBinding', () => {
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(json(snapshot))) vi.stubGlobal('fetch', vi.fn().mockResolvedValue(json(snapshot)))
await render('viewer') await render('viewer')
expect(host.textContent).toContain('普通用户只读') expect(host.textContent).toContain('普通用户只读')
expect(host.textContent).toContain('当前生效 · 测试 090') expect(host.textContent).toContain('当前生效 · 测试知识库')
expect(host.querySelectorAll('input')).toHaveLength(0) expect(host.querySelectorAll('input')).toHaveLength(0)
expect( expect(
[...host.querySelectorAll('button')].every((button) => [...host.querySelectorAll('button')].every((button) =>
['测试 090', '生产 090'].includes(button.textContent?.trim() ?? '') ['测试知识库', '生产知识库'].includes(button.textContent?.trim() ?? '')
) )
).toBe(true) ).toBe(true)
}) })
+3 -2
View File
@@ -21,9 +21,10 @@ import type {
} from './knowledgeBaseBindings' } from './knowledgeBaseBindings'
import { validServiceEndpoint } from './uiSettings' import { validServiceEndpoint } from './uiSettings'
// 环境名只表达用途,不把版本号写进去:实例已迁到 0.9.1,090 是历史部署名。
const environments: { key: KBEnvironment; label: string; short: string }[] = [ const environments: { key: KBEnvironment; label: string; short: string }[] = [
{ key: 'test', label: '测试 090', short: '测试' }, { key: 'test', label: '测试知识库', short: '测试' },
{ key: 'production', label: '生产 090', short: '生产' }, { key: 'production', label: '生产知识库', short: '生产' },
] ]
type Busy = '' | 'catalog' | 'saving' type Busy = '' | 'catalog' | 'saving'
-45
View File
@@ -1,45 +0,0 @@
import { afterEach, expect, it, vi } from 'vitest'
import { renderToStaticMarkup } from 'react-dom/server'
import { associateLegacySource, LegacySourceAssociation } from './LegacySourceAssociation'
afterEach(() => vi.unstubAllGlobals())
const reply = (status: number, data: unknown) => new Response(JSON.stringify(data), { status })
it('only sends exact snapshot and scope; association is not publishing', async () => {
const fetchMock = vi
.fn()
.mockResolvedValue(
reply(200, { associated: true, published: false, snapshot_id: 'snapshot', source_id: 'a'.repeat(64) })
)
vi.stubGlobal('fetch', fetchMock)
expect(await associateLegacySource('internal', 'snapshot')).toBe('a'.repeat(64))
expect(fetchMock.mock.calls).toHaveLength(1)
expect(fetchMock.mock.calls[0][0]).toBe('/api/v1/library/source-associations')
expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({ scope: 'internal', snapshot_id: 'snapshot' })
})
it('rejects wrong-snapshot and incomplete readback, and shows evidence errors', async () => {
for (const value of [
{ associated: true, published: false, snapshot_id: 'wrong', source_id: 'a'.repeat(64) },
{ associated: true, snapshot_id: 'snapshot' },
]) {
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(reply(200, value)))
await expect(associateLegacySource('internal', 'snapshot')).rejects.toThrow('来源关联回执')
}
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(reply(409, { error: 'original capture identity mismatch' })))
await expect(associateLegacySource('internal', 'snapshot')).rejects.toThrow('original capture identity mismatch')
})
it('hides association controls from non-admin and distinguishes it from publication', () => {
expect(
renderToStaticMarkup(
<LegacySourceAssociation scope="internal" snapshots={[]} admin={false} onBound={async () => {}} />
)
).toBe('')
const html = renderToStaticMarkup(
<LegacySourceAssociation scope="internal" snapshots={[]} admin onBound={async () => {}} />
)
expect(html).toContain('只追加治理关联')
expect(html).toContain('disabled')
expect(html).toContain('核验原证据并关联')
})
-83
View File
@@ -1,83 +0,0 @@
import { useState } from 'react'
import type { LibrarySnapshot } from './librarySnapshots'
export async function associateLegacySource(scope: string, snapshotID: string): Promise<string> {
const response = await fetch('/api/v1/library/source-associations', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify({ scope, snapshot_id: snapshotID }),
})
const value = (await response.json().catch(() => null)) as Record<string, unknown> | null
if (!response.ok)
throw new Error(typeof value?.error === 'string' ? value.error : `来源关联失败(HTTP ${response.status})`)
if (
value?.associated !== true ||
value.published !== false ||
value.snapshot_id !== snapshotID ||
typeof value.source_id !== 'string' ||
!/^[a-f0-9]{64}$/.test(value.source_id)
) {
throw new Error('来源关联回执不完整或快照身份不符')
}
return value.source_id
}
export function LegacySourceAssociation({
scope,
snapshots,
admin,
onBound,
}: {
scope: string
snapshots: LibrarySnapshot[]
admin: boolean
onBound: () => Promise<void>
}) {
const [snapshotID, setSnapshotID] = useState('')
const [pending, setPending] = useState(false)
const [notice, setNotice] = useState('')
if (!admin) return null
const choices = snapshots.filter((item) => item.scope === scope)
const bind = async () => {
if (pending || !choices.some((item) => item.snapshot_id === snapshotID)) return
setPending(true)
setNotice('')
try {
const sourceID = await associateLegacySource(scope, snapshotID)
setNotice(`来源证据已核验关联:${sourceID}。没有发布内容;发布授权与写入闸门仍独立检查。`)
await onBound()
} catch (error) {
setNotice(error instanceof Error ? error.message : '来源关联失败')
} finally {
setPending(false)
}
}
return (
<details className="rel-source-identity">
<summary>关联旧封存的原始来源证据(管理员)</summary>
<p>
只追加治理关联,保留原快照与摘要。服务端核对原捕获响应、执行器指纹及清单;备份、来源不符或证据缺失均拒绝,不凭同一范围认领。
</p>
<label>
待核验的历史快照
<select
aria-label="待核验的历史快照"
value={snapshotID}
disabled={pending}
onChange={(event) => setSnapshotID(event.target.value)}
>
<option value="">选择准确快照摘要</option>
{choices.map((item) => (
<option key={item.snapshot_id} value={item.snapshot_id}>
{item.snapshot_id}
</option>
))}
</select>
</label>
<button type="button" disabled={pending || !snapshotID} onClick={() => void bind()}>
{pending ? '核验中…' : '核验原证据并关联'}
</button>
{notice ? <p role="status">{notice}</p> : null}
</details>
)
}
+15
View File
@@ -104,6 +104,21 @@ describe('reconciliation findings', () => {
const failed = renderToStaticMarkup(<ReconciliationFindingsView {...props} error="读取对账批次失败" />) const failed = renderToStaticMarkup(<ReconciliationFindingsView {...props} error="读取对账批次失败" />)
expect(failed).toContain('读取对账批次失败') expect(failed).toContain('读取对账批次失败')
}) })
it('translates a failed batch code instead of rendering the internal code', () => {
const html = renderToStaticMarkup(
<ReconciliationFindingsView
{...props}
runs={{
items: [{ ...run, state: 'failed', error_code: 'remote_unavailable' }],
total: 1,
limit: 20,
offset: 0,
}}
/>
)
expect(html).toContain('测试知识库连接失败')
expect(html).not.toContain('remote_unavailable')
})
it('links a finding to WeKnora when the backend supplies a URL', () => { it('links a finding to WeKnora when the backend supplies a URL', () => {
const html = renderToStaticMarkup( const html = renderToStaticMarkup(
<FindingDetail <FindingDetail
+7 -9
View File
@@ -7,7 +7,8 @@ import type {
ReconciliationProgress, ReconciliationProgress,
ReconciliationRunPage, ReconciliationRunPage,
} from './reconciliationApi' } from './reconciliationApi'
import { fetchReconciliationProgress, ReconciliationRequestError } from './reconciliationApi' import { fetchReconciliationProgress } from './reconciliationApi'
import { reconciliationErrorText, reconciliationFailureText, reconciliationStageText } from './reconciliationMessages'
import './monitorWorkbench.css' import './monitorWorkbench.css'
const time = (value: string | null | undefined) => const time = (value: string | null | undefined) =>
@@ -49,6 +50,7 @@ interface FindingsProps {
busy: boolean busy: boolean
canOperate: boolean canOperate: boolean
canRemove: boolean canRemove: boolean
bindingMissing?: boolean
error: string error: string
message: string message: string
onTab: (tab: 'findings' | 'platform') => void onTab: (tab: 'findings' | 'platform') => void
@@ -152,7 +154,7 @@ export function ReconciliationFindingsView(p: FindingsProps) {
</select> </select>
</label> </label>
{p.canOperate ? ( {p.canOperate ? (
<button className="primary" disabled={p.busy || !p.selectedKB} onClick={p.onCreate}> <button className="primary" disabled={p.busy || (!p.selectedKB && !p.bindingMissing)} onClick={p.onCreate}>
{p.busy ? '提交中…' : '立即对账'} {p.busy ? '提交中…' : '立即对账'}
</button> </button>
) : ( ) : (
@@ -164,7 +166,7 @@ export function ReconciliationFindingsView(p: FindingsProps) {
<p className="monitor-muted"> <p className="monitor-muted">
{time(run.started_at)} · {run.trigger === 'schedule' ? '定时' : '手动'} · 台账 {run.ledger_count} 条 · {time(run.started_at)} · {run.trigger === 'schedule' ? '定时' : '手动'} · 台账 {run.ledger_count} 条 ·
库内 {run.kb_count} 条{run.window_overlapped ? ' · 与整库作业重叠,R1/R2 待确认' : ''} 库内 {run.kb_count} 条{run.window_overlapped ? ' · 与整库作业重叠,R1/R2 待确认' : ''}
{run.error_code ? ` · 失败:${run.error_code}` : ''} {run.error_code ? ` · 失败:${reconciliationFailureText(run.error_code)}` : ''}
</p> </p>
<div className="monitor-diff-counts"> <div className="monitor-diff-counts">
{countKeys.map((key) => ( {countKeys.map((key) => (
@@ -369,11 +371,7 @@ export function WeKnoraProgress({
.catch((err) => { .catch((err) => {
if (controller.signal.aborted) return if (controller.signal.aborted) return
setProgress(null) setProgress(null)
if (err instanceof ReconciliationRequestError && err.code === 'runtime_read_unavailable') { setError(reconciliationErrorText(err))
setError('未配置 WeKnora 只读 Key,无法读取实时处理详情。')
} else {
setError(err instanceof Error ? err.message : '读取 WeKnora 处理详情失败')
}
}) })
.finally(() => { .finally(() => {
if (!controller.signal.aborted) setLoading(false) if (!controller.signal.aborted) setLoading(false)
@@ -411,7 +409,7 @@ export function WeKnoraProgress({
{progress.stages.map((stage) => ( {progress.stages.map((stage) => (
<li key={`${stage.name}-${stage.status}`}> <li key={`${stage.name}-${stage.status}`}>
<b>{stage.name}</b> {stage.status} <b>{stage.name}</b> {stage.status}
{stage.error_code ? ` · ${stage.error_code}` : ''} {stage.error_code ? ` · ${reconciliationStageText(stage.error_code)}` : ''}
{stage.finished_at ? ` · ${time(stage.finished_at)}` : ''} {stage.finished_at ? ` · ${time(stage.finished_at)}` : ''}
</li> </li>
))} ))}
+11 -2
View File
@@ -30,7 +30,7 @@ describe('WeKnora progress drawer block', () => {
) )
await act(async () => root.render(<WeKnoraProgress documentID="doc-1" />)) await act(async () => root.render(<WeKnoraProgress documentID="doc-1" />))
await act(async () => await Promise.resolve()) await act(async () => await Promise.resolve())
expect(container.textContent).toContain('未配置 WeKnora 只读 Key') expect(container.textContent).toContain('缺少平台运行时读权限')
}) })
it('shows stages and failures when available', async () => { it('shows stages and failures when available', async () => {
vi.stubGlobal( vi.stubGlobal(
@@ -43,7 +43,14 @@ describe('WeKnora progress drawer block', () => {
parse_status: 'failed', parse_status: 'failed',
ingestion_status: 'failed', ingestion_status: 'failed',
wiki_status: 'none', wiki_status: 'none',
stages: [{ name: 'parse', status: 'failed', error_code: 'E1', finished_at: '2026-12-01T00:00:00Z' }], stages: [
{
name: 'parse',
status: 'failed',
error_code: 'remote_unavailable',
finished_at: '2026-12-01T00:00:00Z',
},
],
failures: [ failures: [
{ task_type: 'parse', fail_count: 2, failed_at: '2026-12-01T00:00:00Z', last_error: '解析失败' }, { task_type: 'parse', fail_count: 2, failed_at: '2026-12-01T00:00:00Z', last_error: '解析失败' },
], ],
@@ -60,5 +67,7 @@ describe('WeKnora progress drawer block', () => {
expect(container.textContent).toContain('parse') expect(container.textContent).toContain('parse')
expect(container.textContent).toContain('解析失败') expect(container.textContent).toContain('解析失败')
expect(container.textContent).toContain('failed') expect(container.textContent).toContain('failed')
expect(container.textContent).toContain('测试知识库连接失败')
expect(container.textContent).not.toContain('remote_unavailable')
}) })
}) })
+30
View File
@@ -892,6 +892,36 @@ describe('ReleaseTargetsView(确认稿布局)', () => {
expect(known).not.toMatch(/建立目标权威基线(维护隔离)<\/button>/) expect(known).not.toMatch(/建立目标权威基线(维护隔离)<\/button>/)
}) })
it('生产生效版本就是当前测试封存时,主按钮是不可点的“已同步”,前进方向换成重新封存', () => {
const html = render({
sync: { canSign: true, pendingGrant: false, onGrant: vi.fn(), canStart: true, pending: false, onStart: vi.fn() },
overview: {
...overview,
gate: { sync_allowed: true, reasons: [] },
production: {
state: 'known',
version: {
id: 'v-same',
kind: 'production_effective',
snapshot_id: internalSnapshot.snapshot_id,
version_label: '',
source_job_id: 'libsync-1',
evidence: {},
created_by: 'admin',
created_at: '2026-10-29T09:00:00Z',
},
},
},
})
// 闸口放行也不许再把同一份内容同步一遍
expect(html).not.toContain('▶ 启动同步')
expect(html).toMatch(/<button[^>]*class="rel-primary rel-synced"[^>]*disabled[^>]*>✓ 已同步/)
expect(html).toContain('生产已是当前测试封存')
expect(html).toMatch(/class="rel-secondary"[^>]*>重新封存测试版本/)
// 已同步时签发授权没有意义,不出现签发入口
expect(html).not.toContain('签发同步授权(30 分钟)')
})
it('闸口全满足时“启动同步”真的可点,并给出执行说明', () => { it('闸口全满足时“启动同步”真的可点,并给出执行说明', () => {
const html = render({ const html = render({
sync: { canSign: false, pendingGrant: false, onGrant: vi.fn(), canStart: true, pending: false, onStart: vi.fn() }, sync: { canSign: false, pendingGrant: false, onGrant: vi.fn(), canStart: true, pending: false, onStart: vi.fn() },
+51 -44
View File
@@ -1,4 +1,3 @@
import { LegacySourceAssociation } from './LegacySourceAssociation'
import { useCallback, useEffect, useRef, useState } from 'react' import { useCallback, useEffect, useRef, useState } from 'react'
import { import {
createLibraryRestoreAuthorization, createLibraryRestoreAuthorization,
@@ -981,10 +980,6 @@ interface ReadyProps {
prebackup: LibraryOverview['prebackup'] prebackup: LibraryOverview['prebackup']
gate: LibraryOverview['gate'] gate: LibraryOverview['gate']
authorization: LibraryOverview['authorization'] authorization: LibraryOverview['authorization']
canCapture: boolean
canWrite: boolean
pendingCapture: boolean
onCapture: () => void
onOpen: () => void onOpen: () => void
sync: ReleaseSyncActions sync: ReleaseSyncActions
baseline: ReleaseBaselineActions baseline: ReleaseBaselineActions
@@ -1006,16 +1001,12 @@ function ReadyBody({
sync, sync,
baseline, baseline,
verification, verification,
canCapture,
canWrite,
pendingCapture,
onCapture,
onOpen, onOpen,
}: ReadyProps) { }: ReadyProps) {
const snapshot = view.snapshot const snapshot = view.snapshot
return ( return (
<> <>
<div className="rel-grid"> <div>
<ProtectionCard <ProtectionCard
production={production} production={production}
productionNote={productionNote} productionNote={productionNote}
@@ -1043,17 +1034,6 @@ function ReadyBody({
</header> </header>
<StageBar view={view} /> <StageBar view={view} />
</div> </div>
<div className="rel-panel rel-seal">
<div>
<h2>测试库封存</h2>
<p>
{snapshot
? `最近一次封存 ${stamp(snapshot.created_at)},快照 ${snapshot.snapshot_id.slice(0, 12)}。封存只读测试库,不影响生产。`
: '还没有测试库封存。封存会短暂停住测试写入者,导出完整版本后恢复。'}
</p>
</div>
<span className="rel-hint">{canCapture ? '封存入口在页面顶部“下一步”。' : captureHint(view, canWrite)}</span>
</div>
</> </>
) )
} }
@@ -1884,7 +1864,22 @@ export function ReleaseTargetsView(props: ViewProps) {
const sealed = Boolean(view.snapshot) const sealed = Boolean(view.snapshot)
const authorizationActive = authorization.state === 'active' const authorizationActive = authorization.state === 'active'
// 主按钮永远是"同步"或"查看当前任务";准备动作(封存/基线/恢复验证/授权) // 生产生效版本就是这份测试封存时,再同步只会把同一份内容重写一遍(还要停机维护),
// 所以主按钮改成不可点的"已同步",前进方向换成封存新版本。闸口放行与否不影响这个判断。
const inSync =
!runningJob &&
productionClass === 'known' &&
Boolean(target?.snapshot_id) &&
production?.version?.snapshot_id === target?.snapshot_id
const captureAction = {
label: pendingCapture ? '封存中…' : sealed ? '重新封存测试版本' : '封存测试版本',
hint: sealed
? '生产已是当前测试封存,无需同步;测试库有新内容时先封存新版本。'
: '还没有测试库封存。封存只读导出测试库(短暂停住测试写入者),不影响生产。',
disabled: pendingCapture,
run: onCapture,
}
// 主按钮永远是"同步"、"已同步"或"查看当前任务";准备动作(封存/基线/授权)
// 作为次要按钮按状态出现,页面因此只有一个前进方向。 // 作为次要按钮按状态出现,页面因此只有一个前进方向。
const primaryAction = runningJob const primaryAction = runningJob
? { ? {
@@ -1893,6 +1888,13 @@ export function ReleaseTargetsView(props: ViewProps) {
disabled: false, disabled: false,
run: () => document.getElementById('rel-progress')?.scrollIntoView?.({ behavior: 'smooth', block: 'start' }), run: () => document.getElementById('rel-progress')?.scrollIntoView?.({ behavior: 'smooth', block: 'start' }),
} }
: inSync
? {
label: '✓ 已同步',
hint: canCapture ? captureAction.hint : `生产已是当前测试封存,无需同步。${captureHint(view, canWrite)}`,
disabled: true,
run: () => {},
}
: { : {
label: sync.pending ? '投递中…' : '▶ 启动同步', label: sync.pending ? '投递中…' : '▶ 启动同步',
hint: sync.canStart hint: sync.canStart
@@ -1903,13 +1905,12 @@ export function ReleaseTargetsView(props: ViewProps) {
} }
const prepAction = !sealed const prepAction = !sealed
? canCapture ? canCapture
? { ? captureAction
label: pendingCapture ? '封存中…' : '封存测试版本',
hint: '只读导出测试库,生成一份可发布的整库版本。',
disabled: pendingCapture,
run: onCapture,
}
: { label: '尚无封存', hint: captureHint(view, canWrite), disabled: true, run: () => {} } : { label: '尚无封存', hint: captureHint(view, canWrite), disabled: true, run: () => {} }
: inSync
? canCapture
? captureAction
: null
: productionClass === 'nonempty' && baseline.canStart : productionClass === 'nonempty' && baseline.canStart
? { ? {
label: baseline.pending ? '投递中…' : '建立目标权威基线(维护隔离)', label: baseline.pending ? '投递中…' : '建立目标权威基线(维护隔离)',
@@ -1988,8 +1989,13 @@ export function ReleaseTargetsView(props: ViewProps) {
<div className="rel-panel rel-status"> <div className="rel-panel rel-status">
<p className="rel-scope-state"> <p className="rel-scope-state">
{scopeName(scope)} ·{' '} {scopeName(scope)} ·{' '}
{active ? `${jobKindText(view.job?.kind)}进行中` : sealed ? '已封存,同步按条件放行' : '尚无测试封存'} {active
{sealed ? '(需要新版本时点上方“封存测试版本”)' : ''} ? `${jobKindText(view.job?.kind)}进行中`
: inSync
? '生产已是当前测试封存'
: sealed
? '已封存,同步按条件放行'
: '尚无测试封存'}
</p> </p>
<dl className="rel-status-grid"> <dl className="rel-status-grid">
<div> <div>
@@ -1998,6 +2004,15 @@ export function ReleaseTargetsView(props: ViewProps) {
{sealed ? `快照 ${view.snapshot!.snapshot_id.slice(0, 12)}` : '尚无'} {sealed ? `快照 ${view.snapshot!.snapshot_id.slice(0, 12)}` : '尚无'}
</dd> </dd>
<small>{sealed ? stamp(view.snapshot!.created_at) : '先封存测试版本'}</small> <small>{sealed ? stamp(view.snapshot!.created_at) : '先封存测试版本'}</small>
{/* 封存入口跟着"测试封存"这一格走:主操作区已经放了封存按钮时不再重复;
不能封存时把接口给的真实原因写在这里,而不是只藏在按钮 title 里。 */}
{runningJob || prepAction === captureAction ? null : canCapture ? (
<button type="button" className="rel-link rel-cell-action" onClick={onCapture} disabled={pendingCapture}>
{captureAction.label}
</button>
) : (
<small className="rel-unknown">{captureHint(view, canWrite)}</small>
)}
</div> </div>
<div> <div>
<dt>生产当前</dt> <dt>生产当前</dt>
@@ -2010,6 +2025,8 @@ export function ReleaseTargetsView(props: ViewProps) {
<small> <small>
{authorizationActive {authorizationActive
? `有效至 ${stamp(authorization.expires_at ?? '')}` ? `有效至 ${stamp(authorization.expires_at ?? '')}`
: inSync
? '已同步,无需签发'
: sync.canSign : sync.canSign
? '可在下方签发' ? '可在下方签发'
: '需管理员签发'} : '需管理员签发'}
@@ -2045,7 +2062,7 @@ export function ReleaseTargetsView(props: ViewProps) {
) : null} ) : null}
<button <button
type="button" type="button"
className="rel-primary" className={inSync ? 'rel-primary rel-synced' : 'rel-primary'}
onClick={primaryAction.run} onClick={primaryAction.run}
disabled={primaryAction.disabled} disabled={primaryAction.disabled}
title={primaryAction.hint} title={primaryAction.hint}
@@ -2056,12 +2073,13 @@ export function ReleaseTargetsView(props: ViewProps) {
版本与快照 版本与快照
</button> </button>
</div> </div>
{gate.reasons.length > 0 ? ( {/* 已同步时闸口缺项(多半只是授权过期)跟下一步无关:不催、不自动展开,缺项仍在折叠区里可查。 */}
{gate.reasons.length > 0 && !inSync ? (
<p className="rel-hint">还差 {gate.reasons.length} 项条件,展开“发布前检查”查看原因。</p> <p className="rel-hint">还差 {gate.reasons.length} 项条件,展开“发布前检查”查看原因。</p>
) : null} ) : null}
</div> </div>
<details className="rel-check" id="rel-check" open={gate.reasons.length > 0}> <details className="rel-check" id="rel-check" open={gate.reasons.length > 0 && !inSync}>
<summary> <summary>
发布前检查 发布前检查
{gate.reasons.length > 0 ? `(${gate.reasons.length} 项未满足)` : '(已满足)'} {gate.reasons.length > 0 ? `(${gate.reasons.length} 项未满足)` : '(已满足)'}
@@ -2127,10 +2145,6 @@ export function ReleaseTargetsView(props: ViewProps) {
sync={sync} sync={sync}
baseline={baseline} baseline={baseline}
verification={verification} verification={verification}
canCapture={canCapture}
canWrite={canWrite}
pendingCapture={pendingCapture}
onCapture={onCapture}
onOpen={() => onDrawer(true)} onOpen={() => onDrawer(true)}
/> />
)} )}
@@ -2560,13 +2574,6 @@ export function ReleaseTargets() {
onCapture={() => void startCapture()} onCapture={() => void startCapture()}
onRecover={(windowJobID) => void recover(windowJobID)} onRecover={(windowJobID) => void recover(windowJobID)}
/> />
<LegacySourceAssociation
key={scope}
scope={scope}
snapshots={page?.snapshots ?? []}
admin={role === 'admin'}
onBound={() => load()}
/>
</> </>
) )
} }
+2 -2
View File
@@ -228,8 +228,8 @@ describe('SystemSettingsView', () => {
) )
for (const text of [ for (const text of [
'知识库绑定', '知识库绑定',
'测试 090', '测试知识库',
'生产 090', '生产知识库',
'正在读取知识库绑定…', '正在读取知识库绑定…',
'连接与绑定诊断', '连接与绑定诊断',
'测试 WeKnora', '测试 WeKnora',
+151
View File
@@ -0,0 +1,151 @@
// @vitest-environment jsdom
import { act } from 'react'
import { createRoot } from 'react-dom/client'
import type { Root } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { WeKnoraMonitor } from './WeKnoraMonitor'
import { AuthContext } from './auth'
import { reconciliationMessages } from './reconciliationMessages'
const binding = (environment: 'test' | 'production', configured: boolean) => ({
environment,
revision: 1,
base_url: configured ? `https://${environment}.weknora.example` : '',
key_configured: configured,
key_source: configured ? 'sealed' : '',
key_tail: '',
internal_kb_id: '',
internal_kb_name: '',
external_kb_id: '',
external_kb_name: '',
verification: configured ? 'verified' : 'not_configured',
checked_at: null,
updated_by: 'admin',
updated_at: null,
source: 'web',
storage_ready: true,
replanned: 0,
retired_duplicates: 0,
internal_fallback: '',
external_fallback: '',
frozen: 0,
retargetable: 0,
})
const auth = {
identity: {
id: 'admin-1',
username: 'admin',
display_name: 'admin',
role: 'admin' as const,
must_change_password: false,
},
ready: true,
login: async () => null,
logout: async () => {},
changePassword: async () => null,
signedOut: 0,
notifySignedOut: () => {},
}
let container: HTMLDivElement
let root: Root
const flush = async () => {
await act(async () => {
await new Promise((resolve) => setTimeout(resolve, 0))
})
}
const json = (value: unknown, status = 200) =>
new Response(JSON.stringify(value), { status, headers: { 'Content-Type': 'application/json' } })
beforeEach(() => {
;(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true
container = document.createElement('div')
document.body.appendChild(container)
root = createRoot(container)
})
afterEach(() => {
act(() => root.unmount())
container.remove()
vi.unstubAllGlobals()
})
const renderMonitor = async () => {
await act(async () =>
root.render(
<AuthContext.Provider value={auth}>
<WeKnoraMonitor />
</AuthContext.Provider>
)
)
await flush()
await flush()
}
describe('monitor binding preflight', () => {
it('shows the test-binding reason before the KB is selectable and never posts a run', async () => {
const fetchMock = vi.fn(async (input: RequestInfo | URL, _init?: RequestInit) => {
const url = String(input)
if (url === '/api/v1/kb-bindings') {
return json({
data: {
environments: [binding('test', false), binding('production', true)],
storage_ready: true,
},
})
}
if (url.startsWith('/api/v1/reconciliation/runs')) {
return json({ data: { items: [], total: 0, limit: 20, offset: 0 } })
}
return json({ error: 'not available in this fixture' }, 503)
})
vi.stubGlobal('fetch', fetchMock)
await renderMonitor()
expect(container.textContent).toContain(reconciliationMessages.bindingMissing)
const create = [...container.querySelectorAll('button')].find((button) => button.textContent?.trim() === '立即对账')
expect(create).toBeTruthy()
expect(create?.hasAttribute('disabled')).toBe(false)
await act(async () => create!.click())
await flush()
expect(container.textContent).toContain(reconciliationMessages.bindingMissing)
const posts = fetchMock.mock.calls.filter(
([url, init]) => String(url).includes('/api/v1/reconciliation/runs') && init?.method === 'POST'
)
expect(posts).toHaveLength(0)
})
it('keeps the not-enabled reason when the service is unwired and the binding is also missing', async () => {
const fetchMock = vi.fn(async (input: RequestInfo | URL, _init?: RequestInit) => {
const url = String(input)
if (url === '/api/v1/kb-bindings') {
return json({
data: {
environments: [binding('test', false), binding('production', false)],
storage_ready: true,
},
})
}
if (url.startsWith('/api/v1/reconciliation/runs')) {
return json({ error: 'reconciliation_not_configured', code: 'reconciliation_not_configured' }, 503)
}
return json({ error: 'not available in this fixture' }, 503)
})
vi.stubGlobal('fetch', fetchMock)
await renderMonitor()
expect(container.textContent).toContain(reconciliationMessages.notEnabled)
expect(container.textContent).not.toContain(reconciliationMessages.bindingMissing)
const create = [...container.querySelectorAll('button')].find((button) => button.textContent?.trim() === '立即对账')
expect(create?.hasAttribute('disabled')).toBe(false)
await act(async () => create!.click())
await flush()
expect(container.textContent).toContain(reconciliationMessages.notEnabled)
expect(container.textContent).not.toContain(reconciliationMessages.bindingMissing)
})
})
+1 -1
View File
@@ -62,7 +62,7 @@ describe('platform task drawer', () => {
) )
await act(async () => root.render(<TaskDetail item={item} onClose={vi.fn()} />)) await act(async () => root.render(<TaskDetail item={item} onClose={vi.fn()} />))
await act(async () => await Promise.resolve()) await act(async () => await Promise.resolve())
expect(container.textContent).toContain('未配置 WeKnora 只读 Key') expect(container.textContent).toContain('缺少平台运行时读权限')
expect(container.querySelector('a[href="https://weknora.test/platform/knowledge-bases/kb-1"]')).not.toBeNull() expect(container.querySelector('a[href="https://weknora.test/platform/knowledge-bases/kb-1"]')).not.toBeNull()
}) })
}) })
+44 -8
View File
@@ -14,6 +14,7 @@ import {
import type { MonitorFilters, MonitorTask, MonitorTaskPage } from './monitorTasks' import type { MonitorFilters, MonitorTask, MonitorTaskPage } from './monitorTasks'
import { requeueJobFailure, retryPublicationsBatch, startPublicationRemoval } from './testPublications' import { requeueJobFailure, retryPublicationsBatch, startPublicationRemoval } from './testPublications'
import { fetchActiveUISettings, settingsRefreshDelays } from './uiSettings' import { fetchActiveUISettings, settingsRefreshDelays } from './uiSettings'
import { fetchKBBindings } from './knowledgeBaseBindings'
import { useOptionalAuth } from './auth' import { useOptionalAuth } from './auth'
import { WorkspaceContextTabsSetter } from './workspaceContext' import { WorkspaceContextTabsSetter } from './workspaceContext'
import { ReconciliationFindingsView, FindingDetail, ServiceStrip, WeKnoraProgress } from './ReconciliationFindings' import { ReconciliationFindingsView, FindingDetail, ServiceStrip, WeKnoraProgress } from './ReconciliationFindings'
@@ -27,6 +28,7 @@ import {
writebackFinding, writebackFinding,
} from './reconciliationApi' } from './reconciliationApi'
import type { ReconciliationFinding, ReconciliationFindingPage, ReconciliationRunPage } from './reconciliationApi' import type { ReconciliationFinding, ReconciliationFindingPage, ReconciliationRunPage } from './reconciliationApi'
import { isTestBindingMissing, reconciliationErrorText, reconciliationMessages } from './reconciliationMessages'
import './monitorWorkbench.css' import './monitorWorkbench.css'
const emptyRuns: ReconciliationRunPage = { items: [], total: 0, limit: 20, offset: 0 } const emptyRuns: ReconciliationRunPage = { items: [], total: 0, limit: 20, offset: 0 }
@@ -608,6 +610,7 @@ export function WeKnoraMonitor({
const [reconLoading, setReconLoading] = useState(true) const [reconLoading, setReconLoading] = useState(true)
const [reconBusy, setReconBusy] = useState(false) const [reconBusy, setReconBusy] = useState(false)
const [reconError, setReconError] = useState('') const [reconError, setReconError] = useState('')
const [bindingError, setBindingError] = useState('')
const [reconMessage, setReconMessage] = useState('') const [reconMessage, setReconMessage] = useState('')
const [reconRev, setReconRev] = useState(0) const [reconRev, setReconRev] = useState(0)
const [overview, setOverview] = useState<MonitorOverview | null>(null), const [overview, setOverview] = useState<MonitorOverview | null>(null),
@@ -727,6 +730,23 @@ export function WeKnoraMonitor({
if (selectedKB || !overview?.knowledge_bases.length) return if (selectedKB || !overview?.knowledge_bases.length) return
setSelectedKB(overview.knowledge_bases[0].id) setSelectedKB(overview.knowledge_bases[0].id)
}, [overview, selectedKB]) }, [overview, selectedKB])
// 绑定快照与批次列表分开取:批次列表成功会清空 reconError,不能把
// 「测试环境未配置」也塞进同一个 state,否则一刷新就消失。
useEffect(() => {
if (tab !== 'findings') return
const c = new AbortController()
void fetchKBBindings(c.signal)
.then((snapshot) => {
if (!c.signal.aborted) {
setBindingError(isTestBindingMissing(snapshot) ? reconciliationMessages.bindingMissing : '')
}
})
.catch(() => {
// 预检失败不阻塞页面:真正触发时仍由批次错误兜底。
if (!c.signal.aborted) setBindingError('')
})
return () => c.abort()
}, [tab, reconRev])
useEffect(() => { useEffect(() => {
if (tab !== 'findings') return if (tab !== 'findings') return
const c = new AbortController() const c = new AbortController()
@@ -742,7 +762,7 @@ export function WeKnoraMonitor({
.catch((e) => { .catch((e) => {
if (!c.signal.aborted) { if (!c.signal.aborted) {
setRuns(emptyRuns) setRuns(emptyRuns)
setReconError(e instanceof Error ? e.message : '读取对账批次失败') setReconError(reconciliationErrorText(e))
} }
}) })
.finally(() => { .finally(() => {
@@ -767,7 +787,7 @@ export function WeKnoraMonitor({
.catch((e) => { .catch((e) => {
if (!c.signal.aborted) { if (!c.signal.aborted) {
setFindings(emptyFindings) setFindings(emptyFindings)
setReconError(e instanceof Error ? e.message : '读取差异清单失败') setReconError(reconciliationErrorText(e))
} }
}) })
.finally(() => { .finally(() => {
@@ -777,20 +797,35 @@ export function WeKnoraMonitor({
}, [tab, selectedRunID, findingFilters, findingOffset, reconRev]) }, [tab, selectedRunID, findingFilters, findingOffset, reconRev])
const createRun = async () => { const createRun = async () => {
if (reconBusy) return if (reconBusy) return
setReconBusy(true)
setReconMessage('')
try {
// 未启用优先:服务没接线时,绑定缺失只是次要事实;直接调接口只会
// 得到同一个 503,页面应保持「未启用」而不是切换成绑定提示。
if (reconError === reconciliationMessages.notEnabled) {
setReconMessage(reconciliationMessages.notEnabled)
return
}
// 先判绑定再判 KB:绑定被清空时 overview 可能没有可选库,按钮
// 若先要求 selectedKB,用户就永远看不到「测试环境未配置」。
const binding = await fetchKBBindings().catch(() => null)
if (binding && isTestBindingMissing(binding)) {
setBindingError(reconciliationMessages.bindingMissing)
setReconMessage(reconciliationMessages.bindingMissing)
return
}
setBindingError('')
const kbID = selectedKB || overview?.knowledge_bases[0]?.id || '' const kbID = selectedKB || overview?.knowledge_bases[0]?.id || ''
if (!kbID) { if (!kbID) {
setReconMessage('请先选择测试知识库') setReconMessage('请先选择测试知识库')
return return
} }
setReconBusy(true)
setReconMessage('')
try {
const run = await createReconciliationRun(kbID) const run = await createReconciliationRun(kbID)
setSelectedRunID(run.id) setSelectedRunID(run.id)
setReconMessage('已提交对账;扫描在后台执行,完成后刷新可见。') setReconMessage('已提交对账;扫描在后台执行,完成后刷新可见。')
setReconRev((x) => x + 1) setReconRev((x) => x + 1)
} catch (e) { } catch (e) {
setReconMessage(e instanceof Error ? e.message : '触发对账失败') setReconMessage(reconciliationErrorText(e))
} finally { } finally {
setReconBusy(false) setReconBusy(false)
} }
@@ -818,7 +853,7 @@ export function WeKnoraMonitor({
setReconMessage('处置已受理;状态以服务端读回为准。') setReconMessage('处置已受理;状态以服务端读回为准。')
setReconRev((x) => x + 1) setReconRev((x) => x + 1)
} catch (e) { } catch (e) {
setReconMessage(e instanceof Error ? e.message : '处置失败') setReconMessage(reconciliationErrorText(e))
} finally { } finally {
setReconBusy(false) setReconBusy(false)
} }
@@ -924,7 +959,8 @@ export function WeKnoraMonitor({
busy={reconBusy} busy={reconBusy}
canOperate={canOperate} canOperate={canOperate}
canRemove={canRemove} canRemove={canRemove}
error={reconError} error={reconError || bindingError}
bindingMissing={Boolean(bindingError)}
message={reconMessage} message={reconMessage}
onTab={setTab} onTab={setTab}
onSelectRun={(id) => { onSelectRun={(id) => {
+61
View File
@@ -0,0 +1,61 @@
import { describe, expect, it } from 'vitest'
import { ReconciliationRequestError } from './reconciliationApi'
import {
isTestBindingMissing,
reconciliationErrorText,
reconciliationFailureText,
reconciliationMessages,
reconciliationStageText,
} from './reconciliationMessages'
import type { KBBindingSnapshot } from './knowledgeBaseBindings'
const snapshot = (test: { base_url: string; key_configured: boolean }): KBBindingSnapshot =>
({ test, production: { base_url: 'https://prod.example', key_configured: true } }) as unknown as KBBindingSnapshot
describe('reconciliation error copy', () => {
it('maps the three required failures to distinct Chinese sentences', () => {
expect(reconciliationFailureText('reconciliation_not_configured')).toBe(reconciliationMessages.notEnabled)
expect(reconciliationFailureText('runtime_key_forbidden')).toBe(reconciliationMessages.runtimeKeyForbidden)
expect(reconciliationFailureText('runtime_unreachable')).toBe(reconciliationMessages.runtimeUnreachable)
const texts = [
reconciliationMessages.notEnabled,
reconciliationMessages.bindingMissing,
reconciliationMessages.runtimeKeyForbidden,
reconciliationMessages.runtimeUnreachable,
]
expect(new Set(texts).size).toBe(texts.length)
})
it('never renders the four internal codes', () => {
for (const code of [
'reconciliation_not_configured',
'reconciliation_failed',
'remote_unavailable',
'runtime_read_unavailable',
]) {
const text = reconciliationFailureText(code)
expect(text).not.toContain(code)
expect(text.trim().length).toBeGreaterThan(0)
}
})
it('falls back to Chinese for an unknown code instead of echoing it', () => {
expect(reconciliationFailureText('some_new_code')).toBe(reconciliationMessages.generic)
expect(reconciliationFailureText('some_new_code')).not.toContain('some_new_code')
expect(reconciliationStageText('E1')).toBe(reconciliationMessages.stageGeneric)
})
it('uses the request code, not the raw server message', () => {
const error = new ReconciliationRequestError('remote_unavailable', 500, 'remote_unavailable')
expect(reconciliationErrorText(error)).toBe(reconciliationMessages.remoteFailed)
expect(reconciliationErrorText(error)).not.toContain('remote_unavailable')
})
it('treats a missing address or key as an unconfigured test binding', () => {
expect(isTestBindingMissing(snapshot({ base_url: 'https://test.example', key_configured: true }))).toBe(false)
expect(isTestBindingMissing(snapshot({ base_url: '', key_configured: true }))).toBe(true)
expect(isTestBindingMissing(snapshot({ base_url: 'https://test.example', key_configured: false }))).toBe(true)
})
})
+69
View File
@@ -0,0 +1,69 @@
import type { KBBindingSnapshot } from './knowledgeBaseBindings'
import { ReconciliationRequestError } from './reconciliationApi'
// 页面只认这几句人话:错误码属于接口契约,不能直接进 DOM。所有出口
// (顶部条、操作区、批次行、阶段、两个抽屉)都从这里取,避免同一原因
// 在不同位置各写一句后漂移。
export const reconciliationMessages = {
notEnabled: '导入对账未启用,请联系管理员开启',
bindingMissing: '系统设置 → 知识库绑定:测试环境未配置',
runtimeKeyMissing: '缺少平台运行时读权限:请确认平台只读 Key 已配置并已授权',
runtimeKeyForbidden: '缺少平台运行时读权限:请在 WeKnora 为平台只读 Key 授予 system_runtime_read',
runtimeUnreachable: '测试知识库连接不可达或运行时读失败:请检查系统设置 → 知识库绑定中的地址与网络',
runInProgress: '该测试知识库已有对账批次在运行,请等本轮结束后再试',
stateChanged: '记录状态已变化,请刷新后重试',
remoteFailed: '测试知识库连接失败:请检查系统设置 → 知识库绑定中的测试环境地址与 Key',
queueUnavailable: '对账任务队列不可用,请联系管理员',
ledgerUnavailable: '台账读取失败,请稍后重试或联系管理员',
overlapCheckFailed: '无法确认整库作业状态,请稍后重试',
scanFailed: '对账扫描失败,请稍后重试或联系管理员',
previousCountsFailed: '读取上一批对账结果失败,请稍后重试',
completeFailed: '保存对账结果失败,请稍后重试或联系管理员',
generic: '对账操作失败,请稍后重试或联系管理员',
stageGeneric: '其他原因',
} as const
const failureMessages: Record<string, string> = {
reconciliation_not_configured: reconciliationMessages.notEnabled,
reconciliation_failed: reconciliationMessages.generic,
reconciliation_remote_failed: reconciliationMessages.remoteFailed,
remote_unavailable: reconciliationMessages.remoteFailed,
remote_scan_failed: reconciliationMessages.remoteFailed,
remote_confirm_failed: reconciliationMessages.remoteFailed,
runtime_read_unavailable: reconciliationMessages.runtimeKeyMissing,
runtime_key_forbidden: reconciliationMessages.runtimeKeyForbidden,
runtime_unreachable: reconciliationMessages.runtimeUnreachable,
reconciliation_run_in_progress: reconciliationMessages.runInProgress,
reconciliation_state_changed: reconciliationMessages.stateChanged,
queue_unavailable: reconciliationMessages.queueUnavailable,
ledger_unavailable: reconciliationMessages.ledgerUnavailable,
overlap_check_failed: reconciliationMessages.overlapCheckFailed,
scan_failed: reconciliationMessages.scanFailed,
previous_counts_failed: reconciliationMessages.previousCountsFailed,
complete_failed: reconciliationMessages.completeFailed,
}
// 未知码不回显原文:英文码是内部契约,用户只需要知道「失败了、接下来做什么」。
export function reconciliationFailureText(code: string): string {
return failureMessages[code] ?? reconciliationMessages.generic
}
// 阶段码来自上游,可能是任意值;已知平台码照样翻译,未知只给「其他原因」。
export function reconciliationStageText(code: string): string {
return failureMessages[code] ?? reconciliationMessages.stageGeneric
}
export function reconciliationErrorText(error: unknown): string {
if (error instanceof ReconciliationRequestError) {
return reconciliationFailureText(error.code)
}
// 本地抛出的校验错误是中文;真正未知的错误也不要把英文原文塞进页面。
if (error instanceof Error && error.message) return error.message
return reconciliationMessages.generic
}
// 与 kbbinding.Resolve 的 fail-closed 语义对齐:地址或密钥任一缺失,
// 运行时读与对账远端都会失败,页面应先说「测试环境未配置」。
export function isTestBindingMissing(snapshot: KBBindingSnapshot): boolean {
return !snapshot.test.base_url.trim() || !snapshot.test.key_configured
}
+255 -162
View File
@@ -1,11 +1,13 @@
/* 发布管理:按已确认稿的布局与色系(浅底、青绿主色、白色圆角面板)。 */ /* 发布管理:沿用全站工作台视觉(styles.css 的钴蓝 + 中性灰 token)。
以前这一页自带一套青绿色并用 !important 压过全局按钮,看起来像另一个系统;
现在只在这里起别名,颜色一律回到全局 token,语义色(绿=完成、红=失败)也取全局。 */
.release-targets { .release-targets {
--rel-ink: #26394a; --rel-ink: var(--ink-strong);
--rel-muted: #7b8d9a; --rel-muted: var(--ink-mute);
--rel-line: #dce6ed; --rel-line: var(--border-base);
--rel-teal: #269e88; --rel-accent: var(--c-primary);
--rel-teal-dark: #228b75; --rel-accent-hover: var(--c-primary-hover);
--rel-teal-soft: #eaf8f3; --rel-accent-soft: var(--bg-active);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 16px; gap: 16px;
@@ -15,11 +17,13 @@
} }
.release-targets h2 { .release-targets h2 {
margin: 0; margin: 0;
font-size: 18px; font-size: 15px;
font-weight: 600;
} }
.release-targets h3 { .release-targets h3 {
margin: 0; margin: 0;
font-size: 14px; font-size: 13px;
font-weight: 600;
} }
.rel-head { .rel-head {
display: flex; display: flex;
@@ -42,27 +46,44 @@
.release-targets button { .release-targets button {
font: inherit; font: inherit;
cursor: pointer; cursor: pointer;
background: #fff; background: var(--bg-panel);
border: 1px solid #d6e2e8; border: 1px solid var(--border-strong);
border-radius: 7px; border-radius: var(--r-md);
padding: 7px 14px; padding: 6px 14px;
color: #41596b; color: var(--ink-base);
} }
.release-targets button:hover:not(:disabled) { .release-targets button:hover:not(:disabled) {
background: #edf8f5; background: var(--bg-hover);
} }
.release-targets button:disabled { .release-targets button:disabled {
cursor: not-allowed; cursor: not-allowed;
opacity: 0.55; opacity: 0.55;
} }
.release-targets button:focus-visible {
outline: none;
box-shadow: var(--c-focus-ring);
}
.rel-primary { .rel-primary {
background: var(--rel-teal) !important; background: var(--rel-accent) !important;
border-color: var(--rel-teal) !important; border-color: var(--rel-accent) !important;
color: #fff !important; color: #fff !important;
font-weight: 600; font-weight: 600;
} }
.rel-primary:hover:not(:disabled) {
background: var(--rel-accent-hover) !important;
border-color: var(--rel-accent-hover) !important;
}
/* "已同步"是结论不是失效按钮:不走半透明禁用态,用完成色说清楚已经到位。 */
.rel-primary.rel-synced,
.rel-primary.rel-synced:disabled {
opacity: 1;
cursor: default;
background: var(--c-done-bg) !important;
border-color: var(--c-done-border) !important;
color: var(--c-done) !important;
}
.rel-secondary { .rel-secondary {
background: #fff; background: var(--bg-panel);
} }
.rel-tabs { .rel-tabs {
display: flex; display: flex;
@@ -70,54 +91,63 @@
flex-wrap: wrap; flex-wrap: wrap;
} }
.rel-tab { .rel-tab {
width: 310px; width: 300px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 12px; gap: 12px;
padding: 13px 18px !important; padding: 12px 16px !important;
text-align: left; text-align: left;
border-radius: 9px !important; border-radius: var(--r-lg) !important;
border: 1px solid var(--rel-line) !important;
box-shadow: var(--shadow-card);
} }
.rel-tab strong { .rel-tab strong {
font-size: 16px; font-size: 15px;
font-weight: 600;
color: var(--ink-strong);
} }
.rel-tab.selected { .rel-tab.selected {
background: var(--rel-teal-soft) !important; background: var(--rel-accent-soft) !important;
border: 2px solid var(--rel-teal) !important; border-color: var(--rel-accent) !important;
box-shadow: inset 0 0 0 1px var(--rel-accent);
}
.rel-tab.selected strong {
color: var(--rel-accent);
} }
.rel-pill { .rel-pill {
border-radius: 5px; border-radius: 999px;
font-size: 12px; font-size: 12px;
padding: 2px 9px; padding: 1px 9px;
white-space: nowrap; white-space: nowrap;
border: 1px solid transparent; border: 1px solid transparent;
} }
.rel-pill.green { .rel-pill.green {
color: #228368; color: var(--c-done);
background: #e6f5ef; background: var(--c-done-bg);
border-color: #bfe6d8; border-color: var(--c-done-border);
} }
.rel-pill.blue { .rel-pill.blue {
color: #387eb8; color: var(--c-run);
background: #eaf3fc; background: var(--c-run-bg);
border-color: #c6ddf1; border-color: var(--c-run-border);
} }
.rel-pill.gray { .rel-pill.gray {
color: #7c8d99; color: var(--c-dead);
background: #eff3f6; background: var(--c-dead-bg);
border-color: #dde5ea; border-color: var(--border-base);
} }
.rel-pill.red { .rel-pill.red {
color: #b4381f; color: var(--c-fail);
background: #fdecea; background: var(--c-fail-bg);
border-color: #f3c6bc; border-color: var(--c-fail-border);
} }
.rel-panel { .rel-panel {
background: #fff; background: var(--bg-panel);
border: 1px solid var(--rel-line); border: 1px solid var(--rel-line);
border-radius: 12px; border-radius: var(--r-lg);
padding: 20px 22px; box-shadow: var(--shadow-card);
padding: 18px 20px;
min-width: 0; min-width: 0;
} }
.rel-between { .rel-between {
@@ -129,7 +159,7 @@
} }
.rel-panel-head { .rel-panel-head {
display: flex; display: flex;
align-items: flex-start; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 12px; gap: 12px;
margin-bottom: 12px; margin-bottom: 12px;
@@ -140,18 +170,18 @@
color: var(--rel-muted); color: var(--rel-muted);
} }
.rel-jobhead h2 { .rel-jobhead h2 {
font-size: 19px; font-size: 16px;
} }
.rel-versionline { .rel-versionline {
margin: 12px 0 0; margin: 12px 0 0;
color: #496579; color: var(--ink-base);
font-size: 14px; font-size: 13px;
} }
.rel-versionline b { .rel-versionline b {
color: var(--rel-teal-dark); color: var(--rel-accent);
} }
.rel-unknown { .rel-unknown {
color: #9aa9b4 !important; color: var(--ink-faint) !important;
font-weight: 500; font-weight: 500;
} }
.rel-metrics { .rel-metrics {
@@ -161,8 +191,8 @@
margin: 16px 0 0; margin: 16px 0 0;
} }
.rel-metrics div { .rel-metrics div {
border: 1px solid #e6edf2; border: 1px solid var(--border-soft);
border-radius: 9px; border-radius: var(--r-md);
padding: 10px 12px; padding: 10px 12px;
} }
.rel-metrics dt { .rel-metrics dt {
@@ -173,21 +203,22 @@
margin: 4px 0 0; margin: 4px 0 0;
font-size: 20px; font-size: 20px;
font-weight: 700; font-weight: 700;
font-variant-numeric: tabular-nums;
} }
.rel-checklist { .rel-checklist {
list-style: none; list-style: none;
display: flex; display: flex;
gap: 22px; flex-direction: column;
flex-wrap: wrap; gap: 8px;
margin: 14px 0 0; margin: 14px 0 0;
padding: 11px 14px; padding: 12px 14px;
border-radius: 9px; border-radius: var(--r-md);
background: #f2faf6; background: var(--bg-soft);
font-size: 13px; font-size: 13px;
color: #228368; color: var(--c-done);
} }
.rel-checklist .unknown { .rel-checklist .unknown {
color: #8a9aa6; color: var(--ink-faint);
} }
.rel-footnote { .rel-footnote {
margin: 12px 0 0; margin: 12px 0 0;
@@ -216,8 +247,8 @@
.rel-drawer-table th, .rel-drawer-table th,
.rel-parts th { .rel-parts th {
text-align: left; text-align: left;
background: #f8fafb; background: var(--bg-soft);
color: #8a9aa6; color: var(--rel-muted);
font-size: 12px; font-size: 12px;
font-weight: 500; font-weight: 500;
padding: 9px 12px; padding: 9px 12px;
@@ -227,7 +258,7 @@
.rel-drawer-table td, .rel-drawer-table td,
.rel-parts td { .rel-parts td {
padding: 10px 12px; padding: 10px 12px;
border-top: 1px solid #eef2f5; border-top: 1px solid var(--border-soft);
vertical-align: top; vertical-align: top;
} }
.rel-table-empty { .rel-table-empty {
@@ -238,8 +269,8 @@
} }
.rel-protection dl { .rel-protection dl {
display: grid; display: grid;
grid-template-columns: auto 1fr; grid-template-columns: 11.5em 1fr;
gap: 8px 14px; gap: 8px 16px;
margin: 0 0 12px; margin: 0 0 12px;
font-size: 13px; font-size: 13px;
} }
@@ -249,6 +280,8 @@
.rel-protection dd { .rel-protection dd {
margin: 0; margin: 0;
color: var(--rel-ink); color: var(--rel-ink);
font-variant-numeric: tabular-nums;
word-break: break-all;
} }
.rel-hint { .rel-hint {
margin: 0 0 10px; margin: 0 0 10px;
@@ -259,39 +292,39 @@
.rel-warn { .rel-warn {
margin: 12px 0 0; margin: 12px 0 0;
font-size: 12px; font-size: 12px;
color: #986b24; color: var(--c-warn);
background: #fff8e8; background: var(--c-warn-bg);
border: 1px solid #ead7b0; border: 1px solid var(--c-warn-border);
border-radius: 7px; border-radius: var(--r-md);
padding: 8px 10px; padding: 8px 10px;
line-height: 1.6; line-height: 1.6;
} }
.rel-notice { .rel-notice {
margin: 0; margin: 0;
font-size: 12px; font-size: 12px;
color: #986b24; color: var(--c-warn);
background: #fff8e8; background: var(--c-warn-bg);
border: 1px solid #ead7b0; border: 1px solid var(--c-warn-border);
border-radius: 8px; border-radius: var(--r-md);
padding: 9px 12px; padding: 9px 12px;
line-height: 1.6; line-height: 1.6;
} }
.rel-blocked { .rel-blocked {
border: 1px solid #f3c2b8; border: 1px solid var(--c-fail-border);
background: #fff6f3; background: var(--c-fail-bg);
border-radius: 10px; border-radius: var(--r-lg);
padding: 12px 16px; padding: 12px 16px;
} }
.rel-blocked strong { .rel-blocked strong {
display: block; display: block;
color: #a03a1e; color: var(--c-fail);
font-size: 13px; font-size: 13px;
margin-bottom: 3px; margin-bottom: 3px;
} }
.rel-blocked p { .rel-blocked p {
margin: 0; margin: 0;
font-size: 12px; font-size: 12px;
color: #7c2d12; color: var(--c-fail);
} }
/* 阶段条 */ /* 阶段条 */
@@ -300,7 +333,7 @@
align-items: stretch; align-items: stretch;
gap: 8px; gap: 8px;
list-style: none; list-style: none;
margin: 16px 0 6px; margin: 4px 0 8px;
padding: 0; padding: 0;
flex-wrap: wrap; flex-wrap: wrap;
} }
@@ -310,11 +343,11 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 2px; gap: 2px;
padding: 11px 12px; padding: 10px 12px;
border-radius: 8px; border-radius: var(--r-md);
background: #f5f8fa; background: var(--bg-soft);
border: 1px solid #e1e8ed; border: 1px solid var(--border-soft);
color: #8a9aa6; color: var(--ink-faint);
font-size: 13px; font-size: 13px;
} }
.rel-step strong { .rel-step strong {
@@ -325,13 +358,14 @@
font-size: 11px; font-size: 11px;
} }
.rel-step.done { .rel-step.done {
color: #25886b; color: var(--c-done);
background: #f0faf5; background: var(--c-done-bg);
border-color: var(--c-done-border);
} }
.rel-step.live { .rel-step.live {
color: #167f70; color: var(--c-run);
background: #e9f8f4; background: var(--c-run-bg);
border-color: #4eb49f; border-color: var(--c-run-border);
font-weight: 700; font-weight: 700;
} }
.rel-step-mark { .rel-step-mark {
@@ -350,22 +384,6 @@
line-height: 1.6; line-height: 1.6;
} }
/* 仅剩的次级操作:封存测试版本 */
.rel-seal {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
flex-wrap: wrap;
background: #fbfdfe;
}
.rel-seal p {
margin: 6px 0 0;
font-size: 12px;
color: var(--rel-muted);
line-height: 1.6;
}
/* 同步中 */ /* 同步中 */
.rel-jobmeta { .rel-jobmeta {
margin: 8px 0 0; margin: 8px 0 0;
@@ -374,7 +392,7 @@
} }
.rel-progress-foot { .rel-progress-foot {
margin-top: 12px; margin-top: 12px;
border-top: 1px solid #eef2f5; border-top: 1px solid var(--border-soft);
padding-top: 10px; padding-top: 10px;
font-size: 12px; font-size: 12px;
color: var(--rel-muted); color: var(--rel-muted);
@@ -383,14 +401,14 @@
border: 0 !important; border: 0 !important;
background: transparent !important; background: transparent !important;
padding: 2px 4px !important; padding: 2px 4px !important;
color: #2b7fa6 !important; color: var(--rel-accent) !important;
font-size: 12px; font-size: 12px;
} }
.rel-datacard { .rel-datacard {
border: 1px solid #dce6ed; border: 1px solid var(--rel-line);
border-radius: 10px; border-radius: var(--r-lg);
padding: 14px 16px; padding: 14px 16px;
background: #fff; background: var(--bg-panel);
} }
.rel-datacard header { .rel-datacard header {
display: flex; display: flex;
@@ -405,19 +423,20 @@
} }
.rel-datacount strong { .rel-datacount strong {
font-size: 24px; font-size: 24px;
color: #9aa9b4; color: var(--ink-faint);
margin-right: 4px; margin-right: 4px;
font-variant-numeric: tabular-nums;
} }
.rel-progress { .rel-progress {
height: 6px; height: 6px;
border-radius: 8px; border-radius: 8px;
background: #edf1f4; background: var(--bg-softer);
overflow: hidden; overflow: hidden;
} }
.rel-progress span { .rel-progress span {
display: block; display: block;
height: 100%; height: 100%;
background: var(--rel-teal); background: var(--rel-accent);
} }
.rel-datadetail { .rel-datadetail {
margin: 10px 0 0; margin: 10px 0 0;
@@ -434,27 +453,27 @@
padding: 4px 11px; padding: 4px 11px;
} }
.rel-filters .chosen { .rel-filters .chosen {
color: #168b73; color: var(--rel-accent);
background: #ebf8f3; background: var(--rel-accent-soft);
border-color: #a6d7c8; border-color: var(--c-run-border);
} }
.rel-log { .rel-log {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
gap: 12px; gap: 12px;
flex-wrap: wrap; flex-wrap: wrap;
background: #f9fbfc; background: var(--bg-soft);
border-top: 1px solid #eef2f5; border-top: 1px solid var(--border-soft);
padding: 10px 12px; padding: 10px 12px;
font-size: 12px; font-size: 12px;
color: #7b8e9c; color: var(--rel-muted);
} }
/* 版本与快照抽屉 */ /* 版本与快照抽屉 */
.rel-drawer-backdrop { .rel-drawer-backdrop {
position: fixed; position: fixed;
inset: 0; inset: 0;
background: rgba(20, 52, 74, 0.4); background: rgb(0 0 0 / 32%);
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
z-index: 40; z-index: 40;
@@ -463,9 +482,9 @@
width: min(1024px, 92vw); width: min(1024px, 92vw);
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
background: #fff; background: var(--bg-panel);
border-left: 1px solid #dce6ed; border-left: 1px solid var(--rel-line);
box-shadow: -12px 0 32px rgba(19, 44, 61, 0.18); box-shadow: var(--shadow-float);
padding: 22px 26px 28px; padding: 22px 26px 28px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -493,13 +512,13 @@
margin-top: 2px; margin-top: 2px;
} }
.rel-drawer-table tr.selected td { .rel-drawer-table tr.selected td {
background: #f4fbf8; background: var(--rel-accent-soft);
} }
.rel-snapshot { .rel-snapshot {
border: 1px solid #cfe6dd; border: 1px solid var(--rel-line);
border-radius: 10px; border-radius: var(--r-lg);
padding: 16px 18px; padding: 16px 18px;
background: #fbfefd; background: var(--bg-soft);
} }
.rel-snapshot header { .rel-snapshot header {
display: flex; display: flex;
@@ -515,9 +534,9 @@
margin: 12px 0; margin: 12px 0;
} }
.rel-snapshot-grid div { .rel-snapshot-grid div {
border: 1px solid #e2eef7; border: 1px solid var(--border-soft);
border-radius: 8px; border-radius: var(--r-md);
background: #fff; background: var(--bg-panel);
padding: 9px 11px; padding: 9px 11px;
} }
.rel-snapshot-grid dt { .rel-snapshot-grid dt {
@@ -534,12 +553,12 @@
.rel-parts summary { .rel-parts summary {
cursor: pointer; cursor: pointer;
font-size: 12px; font-size: 12px;
color: #2b7fa6; color: var(--rel-accent);
} }
.rel-parts table { .rel-parts table {
margin-top: 8px; margin-top: 8px;
border: 1px solid #e6edf2; border: 1px solid var(--border-soft);
border-radius: 8px; border-radius: var(--r-md);
overflow: hidden; overflow: hidden;
} }
.rel-drawer-actions { .rel-drawer-actions {
@@ -548,12 +567,12 @@
flex-wrap: wrap; flex-wrap: wrap;
} }
.rel-danger { .rel-danger {
border-color: #e7b4a8 !important; border-color: var(--c-fail-border) !important;
color: #b4381f !important; color: var(--c-fail) !important;
} }
.rel-drawer-foot { .rel-drawer-foot {
margin-top: auto; margin-top: auto;
border-top: 1px solid #eef2f5; border-top: 1px solid var(--border-soft);
padding-top: 14px; padding-top: 14px;
display: flex; display: flex;
align-items: center; align-items: center;
@@ -602,7 +621,7 @@
margin: 2px 0 0; margin: 2px 0 0;
font-style: normal; font-style: normal;
font-size: 11px; font-size: 11px;
color: var(--rel-muted, #7b8d9a); color: var(--ink-faint);
} }
.rel-scope-note { .rel-scope-note {
@@ -617,13 +636,13 @@
margin: 0 0 12px; margin: 0 0 12px;
} }
.rel-drawer-kinds div { .rel-drawer-kinds div {
border: 1px solid var(--rel-line, #dce6ed); border: 1px solid var(--rel-line);
border-radius: 8px; border-radius: var(--r-md);
padding: 8px 10px; padding: 8px 10px;
} }
.rel-drawer-kinds dt { .rel-drawer-kinds dt {
font-size: 11px; font-size: 11px;
color: var(--rel-muted, #7b8d9a); color: var(--rel-muted);
} }
.rel-drawer-kinds dd { .rel-drawer-kinds dd {
margin: 3px 0 0; margin: 3px 0 0;
@@ -645,12 +664,12 @@
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
gap: 10px; gap: 10px;
border-bottom: 1px dashed var(--rel-line, #dce6ed); border-bottom: 1px dashed var(--rel-line);
padding: 4px 0; padding: 4px 0;
font-size: 12px; font-size: 12px;
} }
.rel-maintenance-rows span { .rel-maintenance-rows span {
color: var(--rel-muted, #7b8d9a); color: var(--rel-muted);
} }
.rel-maintenance-rows b { .rel-maintenance-rows b {
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
@@ -687,9 +706,9 @@
padding: 4px 10px; padding: 4px 10px;
} }
.rel-history-filters button.active { .rel-history-filters button.active {
color: #168b73; color: var(--rel-accent);
background: #ebf8f3; background: var(--rel-accent-soft);
border-color: #a6d7c8; border-color: var(--c-run-border);
} }
.rel-history-pager { .rel-history-pager {
display: flex; display: flex;
@@ -706,33 +725,44 @@
white-space: pre-wrap; white-space: pre-wrap;
word-break: break-word; word-break: break-word;
font-size: 11px; font-size: 11px;
background: #f7fafc; background: var(--bg-soft);
border: 1px solid #e6edf2; border: 1px solid var(--border-soft);
border-radius: 7px; border-radius: var(--r-md);
padding: 8px; padding: 8px;
} }
/* 发布管理精简版:一个状态卡 + 一个主按钮,其余收进折叠区。 */ /* 发布管理精简版:一个状态卡 + 一个主按钮,其余收进折叠区。 */
.rel-status { .rel-status {
display: grid; display: grid;
gap: 14px; gap: 16px;
padding: 18px 20px; padding: 18px 20px;
} }
.rel-scope-state {
margin: 0;
font-size: 13px;
font-weight: 600;
color: var(--ink-base);
}
/* 四格状态是一条从测试到生产的链:用竖分隔线排成一行,不再各自加框。 */
.rel-status-grid { .rel-status-grid {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 14px; gap: 14px 0;
margin: 0; margin: 0;
} }
.rel-status-grid div { .rel-status-grid div {
border: 1px solid var(--border); padding: 2px 16px;
border-radius: 10px; min-width: 0;
padding: 10px 12px; }
background: var(--card); .rel-status-grid > div:first-child {
padding-left: 0;
}
.rel-status-grid > div + div {
border-left: 1px solid var(--border-soft);
} }
.rel-status-grid dt { .rel-status-grid dt {
font-size: 12px; font-size: 12px;
color: var(--muted-foreground); color: var(--ink-mute);
margin-bottom: 4px; margin-bottom: 4px;
} }
.rel-status-grid dd { .rel-status-grid dd {
@@ -740,23 +770,30 @@
font-weight: 600; font-weight: 600;
font-size: 15px; font-size: 15px;
word-break: break-all; word-break: break-all;
font-variant-numeric: tabular-nums;
} }
.rel-status-grid small { .rel-status-grid small {
display: block; display: block;
margin-top: 4px; margin-top: 4px;
color: var(--muted-foreground); color: var(--ink-mute);
font-size: 12px; font-size: 12px;
font-variant-numeric: tabular-nums;
}
.rel-status-grid .rel-cell-action {
margin: 4px 0 0 -4px;
} }
.rel-status-actions { .rel-status-actions {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
align-items: center; align-items: center;
gap: 10px; gap: 10px;
padding-top: 14px;
border-top: 1px solid var(--border-soft);
} }
.rel-next { .rel-next {
flex: 1 1 320px; flex: 1 1 320px;
margin: 0; margin: 0;
color: var(--muted-foreground); color: var(--ink-mute);
font-size: 13px; font-size: 13px;
} }
.rel-next span { .rel-next span {
@@ -764,27 +801,83 @@
margin-right: 8px; margin-right: 8px;
padding: 1px 8px; padding: 1px 8px;
border-radius: 999px; border-radius: 999px;
background: var(--accent); background: var(--bg-active);
color: var(--foreground); color: var(--rel-accent);
font-size: 12px; font-size: 12px;
font-weight: 600;
} }
/* 折叠区统一成一种样式:卡片 + 自绘箭头,取代浏览器默认的小三角。 */
.rel-check, .rel-check,
.rel-advanced { .rel-advanced {
border: 1px solid var(--border); border: 1px solid var(--rel-line);
border-radius: 12px; border-radius: var(--r-lg);
padding: 4px 16px 12px; padding: 0 18px;
background: var(--card); background: var(--bg-panel);
box-shadow: var(--shadow-card);
} }
.rel-check summary, .rel-check > summary,
.rel-advanced summary { .rel-advanced > summary {
list-style: none;
display: flex;
align-items: center;
gap: 8px;
cursor: pointer; cursor: pointer;
padding: 10px 0; padding: 13px 0;
font-size: 13px;
font-weight: 600; font-weight: 600;
color: var(--ink-strong);
}
.rel-check > summary::-webkit-details-marker,
.rel-advanced > summary::-webkit-details-marker {
display: none;
}
.rel-check > summary::before,
.rel-advanced > summary::before {
content: '';
flex: none;
width: 6px;
height: 6px;
border-right: 1.5px solid var(--ink-mute);
border-bottom: 1.5px solid var(--ink-mute);
transform: rotate(-45deg);
transition: transform 0.15s ease;
}
.rel-check[open] > summary::before,
.rel-advanced[open] > summary::before {
transform: rotate(45deg);
}
.rel-check[open],
.rel-advanced[open] {
padding-bottom: 16px;
} }
.rel-check .rel-gate, .rel-check .rel-gate,
.rel-check .rel-checklist { .rel-check .rel-checklist {
margin: 6px 0 10px; margin: 6px 0 10px;
} }
/* 恢复验证是嵌在检查区里的子块:给它统一行距,按钮不再贴着上面的报告折叠。 */
.rel-verification {
margin-top: 14px;
padding-top: 14px;
border-top: 1px solid var(--border-soft);
}
.rel-verification > * + * {
margin-top: 8px;
}
.rel-verification > p.rel-hint {
margin-bottom: 0;
}
.rel-advanced > * + * { .rel-advanced > * + * {
margin-top: 10px; margin-top: 10px;
} }
/* 放在文件末尾:要压过上面同优先级的桌面规则。 */
@media (max-width: 760px) {
.rel-status-grid div,
.rel-status-grid > div:first-child {
padding: 0;
}
.rel-status-grid > div + div {
border-left: 0;
}
}