kld-sdd 2.6.15 → 2.6.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/init.js +112 -73
- package/lib/skills-bundle.js +3 -0
- package/package.json +2 -1
- package/skywalk-sdd/openspec-shim.cjs +48 -0
- package/templates/git-hooks/commit-msg +46 -0
- package/templates/git-hooks/pre-commit +57 -0
- package/templates/git-hooks/pre-commit-consistency-check.cjs +193 -0
- package/templates/git-hooks/pre-push +57 -0
- package/templates/git-hooks/pre-push-consistency-check.cjs +197 -0
- package/templates/hooks/codebuddy/hooks/hook-gate-core.cjs +369 -0
- package/templates/hooks/codebuddy/hooks/sdd-apply-test-gate.cjs +41 -0
- package/templates/hooks/codebuddy/hooks/sdd-mid-checkpoint.cjs +108 -0
- package/templates/hooks/codebuddy/hooks/sdd-post-tool.cjs +36 -1
- package/templates/hooks/codebuddy/hooks/sdd-tdd-rhythm-gate.cjs +248 -0
- package/templates/hooks/codebuddy/settings.json +8 -0
- package/templates/skills/kld-sdd/opsx-apply/SKILL.md +13 -0
- package/templates/skills/kld-sdd/opsx-apply/checklist.md +15 -0
- package/templates/skills/kld-sdd/opsx-apply/reference.md +41 -0
- package/templates/skills/kld-sdd/opsx-consistency-check/SKILL.md +592 -0
- package/templates/skills/kld-sdd/tdd-rules/SKILL.md +1 -0
- package/templates/skills/kld-sdd/tdd-rules/rules/tdd-rhythm-enforcement.md +101 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# TDD 节奏强制规则
|
|
2
|
+
|
|
3
|
+
> 影响等级:CRITICAL
|
|
4
|
+
>
|
|
5
|
+
> 本规则由 `sdd-tdd-rhythm-gate.cjs` hook 自动强制执行,不可绕过。
|
|
6
|
+
|
|
7
|
+
## 1. 硬阻断规则(由 hook 强制执行)
|
|
8
|
+
|
|
9
|
+
### 1.1 批量更新阻断
|
|
10
|
+
|
|
11
|
+
禁止单次文件写入中修改 >3 个任务的状态(`[ ]` → `[x]`)。
|
|
12
|
+
每个任务必须通过 `task_update` → `check-task` 流程逐个更新。
|
|
13
|
+
|
|
14
|
+
**例外**:如果所有任务都有对应的 `task_update` 遥测事件,说明是 `check-task` 的合法批量更新,放行。
|
|
15
|
+
|
|
16
|
+
### 1.2 RED 证据阻断
|
|
17
|
+
|
|
18
|
+
RED 任务标记完成前,必须存在对应的 `test_result` 遥测事件:
|
|
19
|
+
- `type=test_result`
|
|
20
|
+
- `result=failure`
|
|
21
|
+
- `tdd_phase=red`
|
|
22
|
+
- `task_id` 匹配
|
|
23
|
+
|
|
24
|
+
### 1.3 GREEN 证据阻断
|
|
25
|
+
|
|
26
|
+
GREEN 任务标记完成前,必须存在对应的 `test_result` 遥测事件:
|
|
27
|
+
- `type=test_result`
|
|
28
|
+
- `result=success`
|
|
29
|
+
- `tdd_phase=green`
|
|
30
|
+
- `task_id` 匹配
|
|
31
|
+
|
|
32
|
+
### 1.4 节奏间隔阻断
|
|
33
|
+
|
|
34
|
+
GREEN 任务的 `test_result` 与其配对 RED 任务的 `test_result` 之间,
|
|
35
|
+
时间间隔必须 >60 秒。间隔过短视为批量执行信号。
|
|
36
|
+
|
|
37
|
+
### 1.5 REFACTOR 证据阻断
|
|
38
|
+
|
|
39
|
+
REFACTOR 任务标记完成前,必须存在对应的 `test_result` 遥测事件:
|
|
40
|
+
- `type=test_result`
|
|
41
|
+
- `result=success`
|
|
42
|
+
- `tdd_phase=refactor`
|
|
43
|
+
- `task_id` 匹配
|
|
44
|
+
|
|
45
|
+
## 2. 安全网(防止误阻断)
|
|
46
|
+
|
|
47
|
+
### 2.1 非 TDD 模式放行
|
|
48
|
+
|
|
49
|
+
`proposal.md` 的 `test-strategy` 为 `none` 或 `impl-first` 时,跳过全部 TDD 节奏检查。
|
|
50
|
+
|
|
51
|
+
### 2.2 post-tool 失败降级
|
|
52
|
+
|
|
53
|
+
如果 telemetry 中无任何 `test_result` 事件(说明 `sdd-post-tool.cjs` 可能未正常工作),
|
|
54
|
+
降级为警告模式,不阻断。
|
|
55
|
+
|
|
56
|
+
### 2.3 unknown 类型降级
|
|
57
|
+
|
|
58
|
+
任务类型无法识别时(旧格式 tasks.md 或手动创建),降级为警告,不阻断。
|
|
59
|
+
|
|
60
|
+
### 2.4 非 apply 阶段放行
|
|
61
|
+
|
|
62
|
+
仅在 apply 阶段活跃时触发检查。propose/spec/design/task/check/archive 阶段全部放行。
|
|
63
|
+
|
|
64
|
+
## 3. 软警告规则(由 hook 记录但不阻断)
|
|
65
|
+
|
|
66
|
+
### 3.1 时间异常警告
|
|
67
|
+
|
|
68
|
+
如果 apply 阶段 N 个 TDD 任务的每任务平均耗时 <120 秒,
|
|
69
|
+
记录 `telemetry_warning(tdd_timing_anomaly)`。
|
|
70
|
+
|
|
71
|
+
### 3.2 RED 缺失警告
|
|
72
|
+
|
|
73
|
+
如果 TDD 策略下 apply 阶段无任何失败的 `test_result`,
|
|
74
|
+
记录 `telemetry_warning(tdd_red_missing)`。
|
|
75
|
+
|
|
76
|
+
### 3.3 测试结果复用警告
|
|
77
|
+
|
|
78
|
+
如果多个 `task_update` 引用同一个 `test_result` 指纹,
|
|
79
|
+
记录 `telemetry_warning(task_update_reuse)`。
|
|
80
|
+
|
|
81
|
+
## 4. 中途检查点规则
|
|
82
|
+
|
|
83
|
+
每完成 10 个 TDD 任务后,强制执行检查点:
|
|
84
|
+
- 对比 `task_update` 事件数与 tasks.md `[x]` 数量
|
|
85
|
+
- 对比 `test_result` 事件数与 TDD 对数 × 2
|
|
86
|
+
- 不一致则输出警告
|
|
87
|
+
|
|
88
|
+
## 5. 上下文刷新规则
|
|
89
|
+
|
|
90
|
+
每个新 Layer 开始时,agent 必须重新读取 TDD 红绿节奏规则(§S2),
|
|
91
|
+
并显式声明将继续遵循严格 RED→GREEN 串行循环。
|
|
92
|
+
|
|
93
|
+
## 6. 任务类型识别
|
|
94
|
+
|
|
95
|
+
| tasks.md 中的类型值 | hook 返回 | 处理 |
|
|
96
|
+
|---------------------|----------|------|
|
|
97
|
+
| `测试-RED` | `red` | 检查 test_result(fail) |
|
|
98
|
+
| `实现-GREEN` | `green` | 检查 test_result(pass) + RED前置 + 间隔>60s |
|
|
99
|
+
| `重构-REFACTOR` | `refactor` | 检查 test_result(pass),不检查 RED 前置 |
|
|
100
|
+
| `配置`/`数据层`/`接口层`/`接口测试` | `non-tdd` | 放行 |
|
|
101
|
+
| 无法识别 | `unknown` | 警告放行 |
|