6 Commits
Author SHA1 Message Date
ssw 1ee28022a8 feat(dacli): workflow approve --auto-handle + 关卡 W 接入 quality-gate
tdd7 复盘第三批:

- src/commands/workflow/approve.ts: 重构为 buildApprovalCommand(hooks?),
  暴露 handle/audit 双 hook, --auto-handle 选项自动顺序 handle → audit
  (tdd7 debug §2.2 修复点 ⑥: 真实审批必须先 handle 才能提交)
  不传 --auto-handle 时保留原行为 (向后兼容)
- tests/unit/approve_auto_handle.test.ts: 2 用例 (含/不含 --auto-handle)
- scripts/quality-gate.sh: 增 [6/6] workflow runtime ladder 步骤,
  跨 app 跑 ssw-loop 关卡 W, advisory 不阻断 commit

总测试 86 文件 / 643 用例 全部通过, tsc --noEmit 0 错误
2026-07-30 15:44:12 +08:00
ssw d30ba199d3 auto(14b5ea1b9bd9): session end @ 2026-07-29T10:06:19 (+3f) 2026-07-29 10:06:20 +08:00
ssw f648d11c94 auto(14b5ea1b9bd9): session end @ 2026-07-27T10:18:52 (+4f) 2026-07-27 10:18:53 +08:00
ssw 87a246ed9e feat(dacli): Tier 1 固化 3 项 — hook + idempotent + health check
回应用户"还有哪些要 dacli 固化的" — 落地 Tier 1 全部 3 件:

[1/3] Pre-commit hook 加 doc:check (scripts/quality-gate.sh)
  - 质量门从 [1/3] tsc + [2/3] vitest + [3/3] smoke → [1/4]+[2/4]+[3/4]+[4/4]
  - 新 [3/4] doc:check (npx tsx scripts/check-doc-drift.ts) — 防回归
  - 任何 doc drift 立即阻断 commit (呼应 audit 2026-07-24 §6 治本建议)
  - DACLI_SKIP_GATE=1 紧急绕过 (与现有 tsc/vitest 一致)
  - 注释同步更新 pre-commit (scripts/githooks/pre-commit)

[2/3] form create --reuse-if-exists (src/commands/form/create.ts)
  - 防 BS-新131 AI agent 反复跑场景返工
  - 命中已存在 enCode → 跳过创建, 返回现有 id + state (state=0/1 都支持)
  - 抽 findExistingForm() 纯函数 + 6 个单元测试 (exact match, 不 fuzzy)
  - 新选项: --reuse-if-exists (默认 false, 向后兼容)

[3/3] app status 加 3 项深度健康检查 (src/commands/app/status.ts)
  - dbPing: GET /system/DataSource/{dbLinkId}/Actions/TestConnection (防 BS-E14)
    · 404/405 视为 skip (端点可能未暴露, 不阻断)
    · dbLinkId=0 视为 skip (主库, 不需测试)
  - llmPing: GET /visualdev/ai/health (防 --ai 路径 LLM 挂掉)
    · 404 视为 skip (端点可能未部署 health)
  - menuIntegrity: /oauth/CurrentUser menuList.urlAddress 不空 (防 BS-56 SPA 404)
    · 任意 fail → 退出码 1 (AI agent 应停下修复)
  - 人类可读模式 + --json 模式都展示 deepChecks 数组
  - 实战验证: tdd8 跑出 menuIntegrity 真问题 (4 项 menu urlAddress 空)

验证:
- typecheck 0 errors
- vitest 39 文件 / 393 tests pass (含 6 新 reuse-if-exists 测试)
- doc:check 0 drift
- 实战: dacli app status 跑出 3 项深度检查 + 1 个真 backend finding

测试未跑 (需要 live JNPF):
- form create --reuse-if-exists 端到端 (受 auto-classifier 误判限制)
2026-07-24 18:26:45 +08:00
sswandClaude 891a600245 test(guards): P2.5 — verify guards effective, reconcile stale test, un-quarantine
Verified (evidence, not guess): the guards ARE effective — command-scoped by design,
wired into form/create, form/release, dm/create, menu/create; BS-47/BS-50 fire
correctly when called with their command (as all production callers + verify_option.test.ts do).
The 12 failures were a STALE test, not broken guards:
- 8 'should-trigger' used pre-command-scoping calls → added command args (BS-47 'dict typeCreate', BS-50 'menu create')
- BS-15b / BS-28 / BS-32b: guards removed from registry long ago → dropped stale assertions
- BS-5: real check is ctx===null (not 'empty existingEnCodes') → fixed test
- BS-51 WARN / BS-44 INFO / BS-60 ERROR: test asserted wrong levels → fixed
- BS-60 repurposed (invalid jnpfKey / placeholder columnOptions, not missing vmodel) → fixed trigger
Impl: fixed objective dup-id bug — renamed 2nd 'BS-14' (type=4 view-release WARN) → 'BS-14b'.
Un-quarantined: removed --exclude from scripts/quality-gate.sh.

Verified: full gate green WITH blindspot_guards (tsc 0 + all unit incl. 41/41 guards + smoke).

Co-Authored-By: Claude <[email protected]>
2026-07-24 13:45:48 +08:00
sswandClaude 21eb5520c7 build(quality): P3 — real pre-commit gate (tsc+vitest+smoke); ceremony gate → advisory
Root-cause fix (audit §12.4.1): the only pre-commit gate was _gate_webapi,
which greps comment provenance / webapi ref-rate but NEVER runs tsc or vitest
→ 48 type errors + 20 failing tests could merge under an all-green gate (false green).

- scripts/quality-gate.sh: [1] tsc --noEmit (block) [2] vitest run tests/unit (block)
  [3] backend smoke (advisory local / mandatory CI). No ceremony (no magic-string grep).
  git rev-parse for root (no hardcoded /home/ubuntu).
- scripts/githooks/pre-commit (version-controlled): runs quality-gate (blocking),
  then _gate_webapi as advisory (never blocks).
- scripts/install-hooks.sh: git config core.hooksPath scripts/githooks
- README §232: gate now enforced, tsc rule 靠自觉 → 门强制

blindspot_guards.test.ts quarantined via --exclude (12 fails = registry drift,
PLAN §P2.5) — loudly documented, not silently hidden.

Verified: NEGATIVE test — injected a type error, gate BLOCKED the commit (exit 2);
removed → tsc 0, gate passes. Gate passes its own gate.

Co-Authored-By: Claude <[email protected]>
2026-07-24 09:58:07 +08:00