Claude a767d2bea8 P1-7: form create AI Login expired 自动 fallback web buildFormData 默认空 schema
## bug (jxcj M1 复盘, 2026-07-16)
NCPF 后端 AI (POST /visualdev/ai/form) Login expired 全局阻塞, 报
  code=400 msg=组件属性推理异常: OpenAI 响应无 choices: {"msg":"Login expired, please log in again","code":600}
SSW /ssw/ai/repair 也用同 token 必 fail (5s/10s/20s 浪费).
后果: jxcj M1 11 form 全部受影响, --ai 路径 exit 2, user 必须手动 --enCode + --fullName 重跑建空表单.

## 修复 (3 文件 + 1 单测, +75/-3)
1. _ssw_retry.ts: 加 isLoginExpired() helper (与 isTokenPlanExhausted 同模式)
2. form/_ai.ts:
   - AiFormResponse 加 loginExpired?: boolean 标记
   - callAiForm: NCPF Login expired 跳过 SSW fallback, 返 loginExpired=true
   - callSswAiRepair: SSW Login expired 跳过剩余重试, 同上
3. form/create.ts: --ai 段检测 loginExpired=true → user 传了 --enCode/--fullName 走 web buildFormData 默认空 schema (0 字段, state=1 可用), 未传 exit 2 提示
4. tests/unit/p1-7-ai-login-fallback.test.ts: 12 单测覆盖 isLoginExpired + callAiForm Login expired fallback (mock JnpfClient.postJson)

## 试通命令 (testspace)
- 12 单测 PASS (含 5s 退避)
- testspace 实跑 P17v3 form 创建+发布 PASS (正常 AI 路径不破坏)
- 回归: form-drift 21 + field-builder 18 + blindspot 16 + round12/13/15/17 = 121 tests PASS, 0 regression
- TS 编译: 46 errors baseline = 46 errors after (无新增)

## 关键决策
- 跳过 SSW fallback: SSW 同 token 必 fail, retry 浪费
- fallback 走 web buildFormData 默认空 schema: Login expired 不阻断 form 创建, user 后续用 form update --fields 加字段
- user 未传 --enCode/--fullName → exit 2: AI 不可用无法自动生成 enCode, 比 silent fallback 安全
- 用 (r as any).code 局部 cast: 不修 pre-existing 'let r: AiFormResponse' 类型 bug (留给后续 cleanup PR)
- 不动 BS-新113 5s/10s/20s retry 策略: 仍适用于 429 token plan (临时限流可恢复)
2026-07-16 06:43:32 +08:00
S
Description
dacli CLI — JNPF 平台 AI 驱动开发工具 (TS 版 v0.7)
3.9 MiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 99.4%
Shell 0.4%
Python 0.2%