第三十一轮收尾: 结构化保存走文本级合并(保住手写注释) + 别名卡片文案按老板口径删减
一、结构化 PUT /config 不再整份重渲染(这次真踩过的事故)
- 起因:模型页「保存映射」只改 aliases 一段,却走 render_yaml 整份重渲染,把 gateway.yaml 里
历轮手写的现场注释(协议线实测结论、各家鉴权差异、会话头要求…)整段抹掉(90 → 48 行)。
- app/settings.py 新增 merge_submitted_sections():把本次提交的段替换进原文,其余字节一个都不动。
三条边界都是实测踩出来的:
① 只重写**值真的变了**的段(write_config_merged 拿 raw_old 逐段比对)—— 面板 PUT 的是整份视图,
没变的段必须原样留着,否则一次无关保存就把 server.retry 那类行尾注释冲掉;
② 被替换段的**段尾说明/页脚**用 _split_tail 留在原位 —— 改 providers 不能顺手动掉 server 上方的说明书;
③ 新增段用 _doc_start 插在下一段**说明书之前** —— 否则别人的说明书会变成新段的抬头;
④ 合并后回读校验:解析失败或与提交内容不等 → 退回整份重渲染(配置一定正确,只赔注释)并记 ERROR。
- app/main.py:结构化保存改调 write_config_merged;日志升级为 写盘=merged|rendered / 重写段=<清单>。
- 结构化的唯一调用方是模型页(只提交 aliases 一段);网关配置页走 YAML 原文,两路都不丢注释。
二、别名卡片文案(老板 2026-09-18 口径)
- 删掉卡头副标题(aliasSub:客户端固定写 model: {id},网关转发到你选的模型)与 member 的只读行
(aliasReadonly:只读:映射由管理员在网关配置里选择),两行说明保留;Models.vue 连带删掉 .alias-ro 样式,
中英 i18n 753 → 751(仍对称)。
三、验证
- 单测 189 passed / 0 failed:新增 test_merged_write_keeps_neighbour_docs_and_skips_unchanged(上面三条边界);
改写 test_alias_panel_round_trip_and_save_validation —— 旧写法 PUT 整份视图,而 view_to_raw 会把面板默认值
materialize 进 providers(token ''/rate_limit_rps null/requires_session_header false/endpoints/vision false…),
providers 因此被判"变了"、注释被重写,断言必挂;改成面板真实载荷 {config:{aliases:…}} 后绿。
- scripts/ci_check.sh 全绿(compileall + 单测 + i18n/SVG 体检 + vue-tsc + build)。
- 生产实测(重启后 pid 1912449):值没变的保存 → gateway.yaml 逐字节一致;临时改 note → 差异只有 2 行;
改回 → md5 回到 64ca52b83ab1bb3a7db40d0073554887;页面点「保存映射」→ 日志 重写段=无、文件未变。
前端新入口 index-B5GZJuR8.js(旧 index-BJNJXWEY.js 404),admin/member 双角色真浏览器复验通过。
四、data/gateway.yaml
- 提交的是**注释完整的生产版**:HEAD 里那版是被抹过的 render 产物,工作区这版恢复了被误删的手写注释
并补了带说明的 aliases 段(注释行 100,⊇ 上一版)。
遗留(未动,等老板定):整份视图 PUT 仍会在 providers 上 materialize 面板默认值(那段行内注释会赔);
当前无 UI 走这条路,根治需让 view_to_raw 不再补默认值。
This commit is contained in:
1 parent
76ffbad4f7
commit
ad734579af
7 files changed
+628
-402
No files matched your search
@@ -409,9 +409,8 @@ export default {
|
||||
probedLine: 'probed via {p}',
|
||||
// Round 31: virtual model id (alias) — clients always send model: wjd, the gateway
|
||||
// forwards to the model an admin picks. An alias is not a model: it never shows up in
|
||||
// the speed-test list or the model counts, only in this card and its read-only row.
|
||||
// the speed-test list or the model counts, only in this card.
|
||||
aliasCard: 'Virtual model id (alias)',
|
||||
aliasSub: 'Clients always send model: {id}; the gateway forwards to the model you pick',
|
||||
aliasLine: 'Only the chat/completions (OpenAI) format is supported: calling {id} on /v1/messages or /v1/responses is rejected with 400 at the gateway (it never translates formats).',
|
||||
aliasInherit: 'Vision, forced params and pricing all follow the target model — the alias stores no configuration of its own, so switching the target switches everything.',
|
||||
aliasName: 'Alias id',
|
||||
@@ -422,7 +421,6 @@ export default {
|
||||
aliasEnabled: 'Enabled',
|
||||
aliasDisabled: 'Disabled',
|
||||
aliasNotConfigured: 'No target model configured yet — clients sending model: {id} get "unknown model".',
|
||||
aliasReadonly: 'Read-only: the mapping is chosen by an admin in the gateway config',
|
||||
aliasSave: 'Save mapping',
|
||||
aliasSaved: '{id} → {target} is live',
|
||||
aliasSaveFail: 'Save failed',
|
||||
|
||||
Reference in new issue
Block a user