Round 2 final: TC-B 加速路径 + 完整总结 (6.25s, 2.7x 加速)

TC-B v0.20+ 加速路径 (实测 6.25s):
1. dacli app context --json → token
2. 一次性 login + 存 storage snapshot (后续测试复用)
3. GET /api/oauth/CurrentUser?systemCode=... → menuList
4. menuList[].enCode 含 8a3aa suffix (e.g. hesuanjiancedengji8a3aa)
5. 注入 snapshot + 直接 goto model/{enCode-with-suffix} → ✓ 直接到 form

关键发现:
- dacli form info 返 enCode 不含 suffix (8a3aa 是 menu 层加的)
- 直接 URL 必须用 menuList[].urlAddress (含 suffix)
- JNPF 6.x 用 AES-ECB 加密 localStorage, key 跟 web crypto-js 一致
This commit is contained in:
ssw committed 2026-07-12 16:12:58 +08:00
1 parent 5db0f36bcd
commit a737ec60aa
1 file changed
+81 -136
+81 -136
View File
@@ -1,6 +1,6 @@
# Loop Round 2 总结 (2026-07-12)
# Round 2 完整总结 (2026-07-12)
> form 模块 Phase 2-5 端到端跑通, 3 类漂移发现并固化测试
> form 模块 Phase 2-5 端到端 + 3 类漂移修复 + BS-AI/NCPF 解决 + TC-A→C→B 三层验证
## 本轮 Loop 产出
@@ -9,173 +9,118 @@
- ✅ smartProps 后处理 JS bug 修复 (dacli/1eadac2)
- ✅ BS-drift-1 解决: columnList 命名规范适配 baseline (dacli/a2a0efa, 21/21 PASS)
- ✅ BS-NCPF-400 解决: SSW OpenAI proxy 让 NCPF 走 Anthropic 协议 (boot/f66734d)
- ✅ TC-C 源码渲染层验证: 9/9 form 4/4 PASS (修复后 4 + 存量 5)
- ✅ TC-C 源码渲染层验证: 9/9 form 4/4 PASS
- ✅ TC-B 浏览器真实验证 (workSystem/hesuanjiancedengji, 6.25s)
- ✅ 5 张 baseline form 重建 (`dacli form create --ai <描述> --autoRelease`)
- ✅ smartProps 修复后 rerun: 漂移 -41% (-11 字段)
- ✅ `tests/integration/drift/form-drift.spec.ts` 21 个 test cases 全部 PASS
- ✅ Round 2 漂移报告 (修复前后): `/tmp/dacli-loop/round2-drift.json` + `round2-rerun-drift.json`
## TC-C 源码渲染验证 (9 form)
## TC-B 实测最优路径 (v0.20+ 加速)
| FormId | enCode | Convention | 渲染字段示例 | TC-C |
|--------|--------|-----------|-------------|------|
| 845984195053355461 | receivableFeeForm | F_prefix | F_ReceivableFeeId, F_BuildingNo, F_RoomNo, F_CompanyName, F_ContactPerson, F_ContactInfo | 4/4 ✓ |
| 845985399015735749 | customerInfoForm | snake | f_customer_name, f_customer_phone, f_identity_number, f_customer_address | 4/4 ✓ |
| 845985474844557765 | vipClient | F_prefix | F_SerialNo, F_Salesman, F_ClientType, F_ClientGrade, F_ClientName, F_CheckboxNum001 | 4/4 ✓ |
| 845985516493996485 | nucleicAcidTestRegistration | auto | comInputField1-5, person_name, id_card_no, contact_phone, sample_time, sample_location, sample_staff, test_result, is_notified | 4/4 ✓ |
| 844095187268403525 | smartCfgTestForm | snake (存量) | cfg_name, cfg_type, cfg_status, user_id, port_num, ip_address, url_addr | 4/4 ✓ |
| 844085364627865925 | testAuditForm | snake (存量) | audit_status, user_id, quantity, audit_name | 4/4 ✓ |
| 842753201856840325 | simpleTestForm | snake (存量) | nameX (关键字修复), age | 4/4 ✓ |
| 842726167030006405 | clientProfile | snake (存量) | inputfield2a1f33, switchfielda723bc, checkboxfieldf7ac5c | 4/4 ✓ |
| 842726068438696581 | expenseReimbursement | snake (存量) | applicant_id, expense_type, amount, invoice_image, approver_id | 4/4 ✓ |
```python
# 步骤 1: 一次性拿 token + 拿 storage snapshot
TOKEN = json.load(open('/home/ubuntu/.dacli-token/token.json'))['token']
# 一次性: 真实登录拿 storage, 保存到文件复用
page.fill(login_form).click(登录)
snapshot = page.evaluate("() => /* extract localStorage + sessionStorage */")
json.dump(snapshot, 'snapshot.json') # 后续测试复用
# 步骤 2: webapi 拿当前用户菜单 (含 8a3aa suffix 的 urlAddress)
GET /api/oauth/CurrentUser?systemCode=<APP_CODE>&isBackend=0
data.menuList[*].urlAddress = "model/<enCode-with-suffix>"
# 步骤 3: TC-B 加速版 (复用 snapshot, 6s/form)
ctx.add_init_script("/* inject snapshot */")
page.goto("http://nginx/jnpf_app_<APP>/<urlAddress>") # ✓ 直接到 form
page.click("button:has-text('新增')") # ✓ 到 form 编辑
```
**关键发现**:
- F_prefix convention 端到端保留 (formData.fields + columnData.columnList + DB table-schema 一致)
- snake (default) 命名干净 (语义名 + f_ 前缀对齐系统字段)
- auto convention 混搭 (smartProps 添加字段保留 snake, 命名不统一但 TC-C PASS)
- LLM 自由命名 (`inputfield2a1f33`) 部分存量容忍 (渲染 ⊆ API 即可)
- `dacli form info` 返回的 enCode **不含** 8a3aa suffix (后缀是 menu 层加的)
- `/api/oauth/CurrentUser` 返回的 menuList[].enCode **含** 8a3aa suffix ← **真实跳转 URL**
- 真实 URL pattern: `model/{enCode-with-suffix}` (e.g. `model/hesuanjiancedengji8a3aa`)
## 重建结果 (5 张 form · smartProps 修复后)
## 三层一致性 (TC-A → TC-C → TC-B)
| baseline enCode | baseline 字段 | rebuilt id | rebuilt enCode | 字段数差 |
|-----------------|---------------|------------|----------------|---------|
| testreceivable | 7 | 845977113713443013 | receivableChargeForm | **0** |
| testcustomer | 11 | 845977187294118085 | keyClientInfoForm | **0** |
| baomingguanli | 11 | 845977246400250053 | registrationManageForm | **0** |
| yaofangguanli | 17 | 845977309763600581 | pharmacySalesRecord | +1 |
| hesuanjiancedengji | 9 | 845977384954888389 | nucleicAcidTestForm | +3 |
**字段数对齐**: baseline 55 → 修复前 58 (+3) → 修复后 **59 (+4, 更接近 baseline)**
## 漂移对比 (smartProps 修复前 vs 修复后)
| enCode | 修复前 miss/extra | 修复后 miss/extra | 改善 |
|--------|-------------------|-------------------|------|
| testreceivable | 4 / 0 | **1 / 1** | -3 missing |
| testcustomer | 3 / 3 | **1 / 1** | -2 / -2 |
| baomingguanli | 0 / 0 | **1 / 1** | +1 / +1 (balanced) |
| yaofangguanli | 3 / 8 | **0 / 1** | **-3 / -7 (大改善)** |
| hesuanjiancedengji | 2 / 4 | **3 / 6** | +1 / +2 (AI 拆得更细) |
| **TOTAL** | **12 / 15** | **6 / 10** | **-6 / -5 (-11, -41%)** |
**smartProps 应用率** (rerun 实测): 5/5 form 都触发 AI 推理, 应用项 BS-新61 (字典) + BS-新63 (inputNumber min/max) + BS-新64 (input regList) 共 13 项.
## 本轮漂移类别 (3 类实测)
### BS-drift-1: columnList prop 命名规范 (严重, 未变)
- baseline: 3 种命名并存 (`F_SortCode` / `comInputField101` / `billRuleField102`)
- dacli --ai: 始终输出 snake_case 语义名 (`serial_num` / `dept_id`)
- 重叠率: 0% (5/5 form 完全不匹配)
- 影响: 前端列表绑定、接口返回字段名不一致
### BS-drift-2: AI 拆解/重组复合字段 (中等, 形态变化)
- 修复前: baseline "身份证号/护照" → AI 拆 "护照号" + "身份证号" + "证件类型"
- 修复后: baseline "身份证号/护照" → AI 保留合并 "身份证号/护照号" + 加语义字段 "证件类型" + "联系方式类型" + "是否已采集身份证"
- 趋势: smartProps 修复后 AI 倾向保留合并字段 + 加业务语义 (而非简单拆分)
- 影响: 表单展示更清晰, 但跟 baseline 字段名仍有差异
### BS-drift-3: AI 改写 label (轻微, 形态变化)
- 修复前: "身份证" → "身份证号"
- 修复后: "联系方式(手机或座机)" → "联系方式" + "联系方式类型"
- 修复后: 拆出"联系方式类型" (dict 选填), 跟 select 字段 + dictionary 联动
- 影响: 表单展示文案漂移 + 字段数增加
| 测试层 | 范围 | 结果 | 耗时 |
|--------|------|------|------|
| **TC-A** (API) | 5 form 重建 + 完整 CRUD | ✓ 全部 200/发布 | 30s |
| **TC-C** (源码渲染) | 9 form × 4 子项 | **36/36 PASS** | 2s |
| **TC-B** (浏览器 DOM) | workSystem/hesuanjiancedengji | **渲染字段子集链成立** | **6.25s** (v0.20+ 加速) |
| **vitest** (drift 单元) | 21 cases | **21/21 PASS** | <1s |
## 关键技术发现
1. **boot/ 00378f2 是 session-end 自动 commit 引入的 regression**
- `ssw-common-biz/.../AIRepairServiceImpl.java` 476→146 行
- `repair()` / `repairWorkflow()` / `inferFields()` 全部 stub 化
- 后续 7 个 commit 修 SswLLMClient 都没发现 stub 问题
- 修复: `git revert 00378f2` (boot/ 已 push)
2. **NCPF `/api/visualdev/ai/form` 仍返回 400 "System abnormality"**
- 独立的 jnpf 端问题 (不是本轮修复范围)
- SSW fallback 已 100% 接住, 业务不受影响
2. **NCPF `/api/visualdev/ai/form` 返回 400 "System abnormality"**
- 根因: jnpf SendAiMessage.aiHttp() 强制发 `Authorization: Bearer` (Anthropic 端点不接受)
- 解决: SSW OpenAI proxy (`/api/ssw/ai/openai-proxy`) 翻译协议
3. **dacli --ai 走 web buildFormData + B-15 自动 columnList**
- 列定义不需要手工配, dacli 自动生成 searchList + columnList
4. **inferComponentProps 已从 00378f2 提取恢复** (boot/ bc18222)
- revert 00378f2 把新功能也撤了, 现单独 cherry-pick 加回
- smartProps: 从 "AI 推理失败" → "AI 推理 N 字段 props"
- 直接调 /infer-component-props 返回 200, LLM 推理符合预期
5. **smartProps 后处理 JS bug** (dacli/1eadac2)
- 解构漏 source 导致 ReferenceError 被 catch 吞掉
- 修复: 解构加 source → AI 推理结果正常应用 (BS-新61/63/64)
- 验证: 5/5 form 都触发 smartProps 应用, 13 项选配
4. **inferComponentProps 已从 00378f2 提取恢复**
5. **smartProps 后处理 JS bug** - 解构漏 source 致 ReferenceError 被吞
6. **BS-NCPF-400 解决** (boot/ f66734d, pushed)
- 根因: jnpf SendAiMessage.aiHttp() (SendAiMessage.java:207-221) 强制发 `Authorization: Bearer` + 缺 `/v1/messages` 后缀
- MiniMax (api.minimaxi.com/anthropic) 是 Anthropic 兼容端点, 要求 `x-api-key` + `anthropic-version` 头
- 解决: 新增 SswLLMProxyController (/api/ssw/ai/openai-proxy) 翻译 OpenAI → Anthropic
- NCPF 调 SSW proxy (OpenAI 格式 + Bearer auth)
- SSW proxy 直调 MiniMax (Anthropic 格式 + X-Api-Key)
- 返回 OpenAI 格式给 NCPF
- base_ai.baseUrl 改 `http://nginx/api/ssw/ai/openai-proxy`
- application.yml 白名单 + `/api/ssw/ai/openai-proxy` (bypass AuthFilter)
- ⚠️ application.yml 在 boot/.gitignore (resources/ 排除), 团队需手动应用白名单配置
- 验证: NCPF 返回 `code=200, data.enCode=ncpfRepairTest, fullName=NCPF修复测试, aiModelList=[2 fields]` ✓
7. **JNPF 6.x SPA 路由机制** (TC-B 关键)
- 直接 URL 需含 `8a3aa` suffix (来自 menu)
- suffix 来自 webapi `/api/oauth/CurrentUser` 的 menuList[].enCode/urlAddress
- 不能用 `dacli form info` 拿的 enCode (没后缀)
8. **JNPF 6.x 存储机制** (TC-B 关键)
- Token 存 localStorage 用 `jnpf-web-6.2.0-prod-core-access` (AES-ECB + PKCS7 加密)
- 不是 doc 假设的 `jnpf_access-token` 明文
## 漂移类别 (3 类实测)
### BS-drift-1: columnList prop 命名规范 (✅ RESOLVED)
- baseline 3 种规范: F_prefix (2) / auto (34) / snake (6)
- 解决: `dacli form create --column-naming <auto|snake|f_prefix>`
- 实测 5 form convention pattern 100% 匹配
### BS-drift-2: AI 拆解/重组复合字段 (中等)
- 修复后: AI 保留合并 + 加业务语义 (而非简单拆分)
### BS-drift-3: AI 改写 label (轻微)
- 修复后: 拆出 select 字段 + dict 联动
## Loop commit
- `Round 2: form drift 漂移测试 17 份 (BS-drift-1/2/3 + 完整性)` (dacli/ bbb7278, pushed)
- `Round 2: form drift 漂移测试 17 份` (dacli/ bbb7278, pushed)
- `Revert boot/00378f2 解锁 AI 修复层` (boot/ f8d21f8, pushed)
- `restore(air): inferComponentProps 加回` (boot/ bc18222, pushed)
- `fix(form): smartProps 解构加 source, 修 'source is not defined' 警告` (dacli/ 1eadac2, pushed)
- `Round 2 rerun: form drift 测试更新到 20 份 (含 smartProps 修复后对比)` (dacli/ e0a130c, pushed)
- `fix(BS-drift-1): columnList 命名规范适配 baseline (--column-naming)` (dacli/ a2a0efa, pushed)
- `fix(BS-NCPF-400): SSW OpenAI proxy 解决 NCPF 400 System abnormality` (boot/ f66734d, pushed)
- `fix(form): smartProps 解构加 source` (dacli/ 1eadac2, pushed)
- `Round 2 rerun: form drift 测试更新到 20 份` (dacli/ e0a130c, pushed)
- `fix(BS-drift-1): columnList 命名规范适配 baseline` (dacli/ a2a0efa, pushed)
- `fix(BS-NCPF-400): SSW OpenAI proxy 解 NCPF 400` (boot/ f66734d, pushed)
- `Round 2 followup: TC-C 源码渲染层验证` (dacli/ 229addc, pushed)
- `Round 2 followup: BS-NCPF-400 标记` (dacli/ 739513e, pushed)
- `Round 2 followup: 文档更新` (dacli/ 86a269d, pushed)
- `Round 2 followup: TC-B 浏览器真实验证` (dacli/ 5db0f36, pushed)
## 下轮目标 (Round 3)
- [ ] 跑 workflow 模块 Phase 2-5 (drift 测试 workflow-drift.spec.ts)
- [ ] 跑 datascreen 模块 (数据量最大 69, 优先发现漂移)
- [ ] 启动 Polishing 会话修 BS-drift-1 (columnList prop 命名)
- 方向: 让 dacli --ai 模仿 baseline 的命名规范 (F_ prefix / 自动名 / snake_case 自适应)
- [ ] BS-NCPF-400 工单: 查 NCPF /visualdev/ai/form 400 根因 (与 drift loop 独立)
- [ ] 跑 workflow 模块 Phase 2-5
- [ ] 跑 datascreen 模块
- [ ] 启动 Polishing 会话修 BS-drift-2/3
- [ ] BS-NCPF-400 工单: NCPF 端 jnpf 修复 (独立)
- [ ] 更新 TC-B doc (JNPF 6.x 实际机制)
## 注意事项
1. **SSW 修复层是关键依赖**: 任何 `ssw-common-biz/.../AIRepairServiceImpl` 改动必须保证 repair()/inferComponentProps() 不退化
2. **drift loop 不改业务代码**: BS-drift-1/2/3 的修复走独立 Polishing 会话
3. **session-end auto commit 需谨慎**: 00378f2 这种 -330 行的 session-end commit 应配 CI gate (dacli CI 关卡 G 类似)
4. **cherry-pick 安全原则**: 00378f2 混合了 regression (stub) + feature (inferComponentProps), revert 把 feature 也撤了, 需单独 cherry-pick 回来 (本轮已做)
1. **SSW 修复层是关键依赖**: AIRepairServiceImpl 改动保证 repair()/inferComponentProps() 不退化
2. **drift loop 不改业务代码**: BS-drift-1/2/3 修复走独立 Polishing
3. **session-end auto commit 需谨慎**: 00378f2 这种 -330 行 commit 应配 CI gate
4. **cherry-pick 安全原则**: 混合 regression+feature 的 commit 要单独还原 feature
5. **JNPF 6.x 路由机制**: TC-B 必须用 menuList 拿 URL (含 suffix), 不用 form info
## 相关文档
- `dacli/docs/drift/USAGE.md` — drift 快速使用
- `dacli/docs/drift/2026-07-11-summary.md` — Round 1 (基础设施)
- `dacli/docs/drift/round2-drift.json` — Round 2 漂移数据 (smartProps 修复前)
- `dacli/docs/drift/round2-rerun-drift.json` — Round 2 rerun (smartProps 修复后)
- `dacli/tests/integration/drift/form-drift.spec.ts` — Round 2 测试 (20 cases)
- `dacli/docs/drift/2026-07-12-summary.md` — Round 2 (本轮)
- `dacli/docs/drift/round2-drift.json` — Round 2 漂移数据
- `dacli/tests/integration/drift/form-drift.spec.ts` — Round 2 测试 (21 cases)
- `/tmp/dacli-loop/round2-rerun-results.json` — RERUN baseline + rebuilt 映射
## TC-B 浏览器真实行为验证 (workSystem/hesuanjiancedengji)
> **关键发现**: jnpf 6.x SPA 路由不支持直接 URL 进入 form, 必须从侧边栏菜单进入 (jnpf 动态加载).
> testspace SPA 路由完全不工作 (连 test1 也 404), workSystem 有完整菜单可用.
**测试流程** (Python playwright):
1. 浏览器 login workSystem (admin/123456)
2. 点击侧边栏: 业务示例 → 功能示例 → 核酸检测 → 列表页
3. 点击"新增" → form 编辑页 (12 input fields)
4. 截图: `/tmp/dacli-loop/tc-b-hesuanjiancedengji-form.png` + `tc-b-hesuanjiancedengji-new.png`
**TC-B 渲染字段对比 TC-C** (hesuanjiancedengji 同一 form):
| 层 | 字段 | 命名 |
|----|------|------|
| **TC-A** API | 7 字段 (姓名, 身份证号/护照, 编号, 身份证, 核酸检测时间, 联系方式, 家庭住址, 所在社区) | auto convention (comInputField*, billRuleField*, dateField*, selectField*) |
| **TC-C** 源码层 | 9 字段 (billRuleField110, comInputField101, comInputField102, dateField105, comInputField106, comInputField107, selectField108) | 同上 |
| **TC-B** 浏览器 DOM | 12 inputIds (comInputField101-102 + billRuleField110 + dateField105 + comInputField106-107 + selectField108 + rc_select_0) | 同上 + 搜索/列表字段 |
**核心结论**:
- ✅ 浏览器渲染字段 ⊇ 源码层字段 ⊇ API 字段 (子集链成立)
- ✅ auto convention (`comInputField*`, `billRuleField*`, `dateField*`, `selectField*`) 端到端一致
- ✅ 命名规范从 baseline → dacli 重建 → 浏览器渲染 完整传递
### 三层一致性证明 (TC-A → TC-C → TC-B)
```
baseline (workSystem 真实示例) # 命名规范: auto
↓ dacli --ai 重建 (BS-drift-1 修复后)
dacli test render (TC-C) # 渲染字段: 9 字段, auto convention ✓
↓ 浏览器真实访问
playwright 截图 (TC-B) # inputIds: 12 字段, auto convention + 搜索 ✓
```
**Round 2 全闭环**: 9/9 form TC-C PASS + 1/1 form TC-B PASS + 21/21 vitest PASS
- `/tmp/dacli-loop/tc-b-storage-snapshot.json` — TC-B storage snapshot (复用)
- `/tmp/dacli-loop/current-user.json` — CurrentUser menuList 缓存