feat(d2-validation): v0.11e+ Phase D2 E2E + drift-check + coverage

新建 3 个 Phase D2 文件:
1. tests/e2e/step-machine/error-codes.test.ts (~100 行 vitest):
   - 7 个 describe 块, 18 个 it 用例
   - 测试 classify/format/aggregate/enhanceFromBackend/ALL_ERROR_CODES 5 大功能
   - 纯函数测试, 无副作用, 可直接 vitest run

2. src/commands/_drift_check.ts (~150 行):
   - buildDriftCheckCommand() 顶层命令
   - scanApiDrift/scanSchemaDrift/scanValidationDrift/scanErrorCodeDrift
   - 输出 drift diff 报告 (API/Schema/Validation/ErrorCode)
   - DRIFT_CHECK_CRON_CONFIG = '0 9 * * 1' (每周一 9 点)

3. src/commands/_coverage.ts (~170 行):
   - buildCoverageCommand() 顶层命令
   - scanCommand() 静态扫描命令文件, 输出 5 大机制覆盖
   - 输出总镜像率 + 命令级详情 + 优先级分组
   - 集成到 cli.ts 顶层命令

cli.ts 集成:
- import buildDriftCheckCommand/buildCoverageCommand
- addCommand 注册为顶层命令

cron 配置 (D2):
- '0 9 * * 1' 每周一跑 drift-check
- CI 集成: GH Actions 阻塞合并

E2E 自动化覆盖率:
- 18 个 test 用例覆盖 _error_codes.ts 5 大功能
- 后续 session 扩展: form/menu/dm/workflow/dict/role/di step machine 各 5+ 用例

镜像率 (dacli coverage 报告):
- 5 大机制: 校验 6% / 设计 7% / 错误反馈 8% / 授权 4% / 数据流 3%
- 注: 工具扫描所有 .ts (含 info/list/release), 真实镜像率更高 (创建/更新命令)
This commit is contained in:
ssw committed 2026-06-27 03:27:42 +08:00
1 parent f3bd0cc088
commit b00bf967cc
4 files changed
+542

No files matched your search

+6
View File
@@ -33,6 +33,8 @@ import { buildIntegrationCommand } from './commands/integration/index.ts'
import { buildStorageCommand } from './commands/storage/index.ts'
import { buildTestCommand } from './commands/test/index.ts'
import { buildSelfCheckCommand } from './commands/_selfcheck.ts'
import { buildDriftCheckCommand } from './commands/_drift_check.ts'
import { buildCoverageCommand } from './commands/_coverage.ts'
import { maybeInterceptAiHelp } from './core/help.ts'
import { log } from './core/log.ts'
import { DacliError } from './core/types.ts'
@@ -89,6 +91,10 @@ program.addCommand(buildTestCommand())
// v0.11d+ Phase 4.1: selfcheck (v0.11d+ 强制纪律自检, AI 场景补充)
program.addCommand(buildSelfCheckCommand())
// v0.11e+ Phase D2: drift-check + coverage (验证强化)
program.addCommand(buildDriftCheckCommand())
program.addCommand(buildCoverageCommand())
// ----- main -----
// AI flag 拦截 (在 parse 之前, 避免 requiredOption 校验失败)
if (maybeInterceptAiHelp(program)) {