@hunter-harness/workflow-harness 0.2.30 → 0.2.31

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.
Files changed (146) hide show
  1. package/harness/bundles/general/claude-code/.harness-build.json +1 -1
  2. package/harness/bundles/general/claude-code/harness-archive/SKILL.md +3 -3
  3. package/harness/bundles/general/claude-code/harness-codebase-map/SKILL.md +3 -3
  4. package/harness/bundles/general/claude-code/harness-knowledge-ingest/SKILL.md +3 -3
  5. package/harness/bundles/general/claude-code/harness-knowledge-query/SKILL.md +3 -3
  6. package/harness/bundles/general/claude-code/harness-plan/SKILL.md +6 -6
  7. package/harness/bundles/general/claude-code/harness-plan/checklist.md +10 -4
  8. package/harness/bundles/general/claude-code/harness-plan/reference.md +17 -17
  9. package/harness/bundles/general/claude-code/harness-review/SKILL.md +3 -3
  10. package/harness/bundles/general/claude-code/harness-run/SKILL.md +4 -4
  11. package/harness/bundles/general/claude-code/harness-run/checklist.md +2 -2
  12. package/harness/bundles/general/claude-code/harness-run/reference.md +3 -12
  13. package/harness/bundles/general/claude-code/harness-submit/SKILL.md +3 -3
  14. package/harness/bundles/general/claude-code/harness-sync/SKILL.md +3 -3
  15. package/harness/bundles/general/claude-code/harness-test/SKILL.md +3 -3
  16. package/harness/bundles/general/claude-code/scripts/harness_gate.py +97 -14
  17. package/harness/bundles/general/claude-code/scripts/harness_plan_finalize.py +364 -74
  18. package/harness/bundles/general/codebuddy/.harness-build.json +1 -1
  19. package/harness/bundles/general/codebuddy/harness-archive/SKILL.md +3 -3
  20. package/harness/bundles/general/codebuddy/harness-codebase-map/SKILL.md +3 -3
  21. package/harness/bundles/general/codebuddy/harness-knowledge-ingest/SKILL.md +3 -3
  22. package/harness/bundles/general/codebuddy/harness-knowledge-query/SKILL.md +3 -3
  23. package/harness/bundles/general/codebuddy/harness-plan/SKILL.md +6 -6
  24. package/harness/bundles/general/codebuddy/harness-plan/checklist.md +10 -4
  25. package/harness/bundles/general/codebuddy/harness-plan/reference.md +17 -17
  26. package/harness/bundles/general/codebuddy/harness-review/SKILL.md +3 -3
  27. package/harness/bundles/general/codebuddy/harness-run/SKILL.md +4 -4
  28. package/harness/bundles/general/codebuddy/harness-run/checklist.md +2 -2
  29. package/harness/bundles/general/codebuddy/harness-run/reference.md +3 -12
  30. package/harness/bundles/general/codebuddy/harness-submit/SKILL.md +3 -3
  31. package/harness/bundles/general/codebuddy/harness-sync/SKILL.md +3 -3
  32. package/harness/bundles/general/codebuddy/harness-test/SKILL.md +3 -3
  33. package/harness/bundles/general/codebuddy/scripts/harness_gate.py +97 -14
  34. package/harness/bundles/general/codebuddy/scripts/harness_plan_finalize.py +364 -74
  35. package/harness/bundles/general/codex/.harness-build.json +1 -1
  36. package/harness/bundles/general/codex/harness-archive/SKILL.md +3 -3
  37. package/harness/bundles/general/codex/harness-codebase-map/SKILL.md +3 -3
  38. package/harness/bundles/general/codex/harness-knowledge-ingest/SKILL.md +3 -3
  39. package/harness/bundles/general/codex/harness-knowledge-query/SKILL.md +3 -3
  40. package/harness/bundles/general/codex/harness-plan/SKILL.md +6 -6
  41. package/harness/bundles/general/codex/harness-plan/checklist.md +10 -4
  42. package/harness/bundles/general/codex/harness-plan/reference.md +17 -17
  43. package/harness/bundles/general/codex/harness-review/SKILL.md +3 -3
  44. package/harness/bundles/general/codex/harness-run/SKILL.md +4 -4
  45. package/harness/bundles/general/codex/harness-run/checklist.md +2 -2
  46. package/harness/bundles/general/codex/harness-run/reference.md +3 -12
  47. package/harness/bundles/general/codex/harness-submit/SKILL.md +3 -3
  48. package/harness/bundles/general/codex/harness-sync/SKILL.md +3 -3
  49. package/harness/bundles/general/codex/harness-test/SKILL.md +3 -3
  50. package/harness/bundles/general/codex/scripts/harness_gate.py +97 -14
  51. package/harness/bundles/general/codex/scripts/harness_plan_finalize.py +364 -74
  52. package/harness/bundles/general/cursor/.harness-build.json +1 -1
  53. package/harness/bundles/general/cursor/harness-archive/SKILL.md +3 -3
  54. package/harness/bundles/general/cursor/harness-codebase-map/SKILL.md +3 -3
  55. package/harness/bundles/general/cursor/harness-knowledge-ingest/SKILL.md +3 -3
  56. package/harness/bundles/general/cursor/harness-knowledge-query/SKILL.md +3 -3
  57. package/harness/bundles/general/cursor/harness-plan/SKILL.md +6 -6
  58. package/harness/bundles/general/cursor/harness-plan/checklist.md +10 -4
  59. package/harness/bundles/general/cursor/harness-plan/reference.md +17 -17
  60. package/harness/bundles/general/cursor/harness-review/SKILL.md +3 -3
  61. package/harness/bundles/general/cursor/harness-run/SKILL.md +4 -4
  62. package/harness/bundles/general/cursor/harness-run/checklist.md +2 -2
  63. package/harness/bundles/general/cursor/harness-run/reference.md +3 -12
  64. package/harness/bundles/general/cursor/harness-submit/SKILL.md +3 -3
  65. package/harness/bundles/general/cursor/harness-sync/SKILL.md +3 -3
  66. package/harness/bundles/general/cursor/harness-test/SKILL.md +3 -3
  67. package/harness/bundles/general/cursor/scripts/harness_gate.py +97 -14
  68. package/harness/bundles/general/cursor/scripts/harness_plan_finalize.py +364 -74
  69. package/harness/bundles/java/claude-code/.harness-build.json +1 -1
  70. package/harness/bundles/java/claude-code/harness-apidoc/SKILL.md +3 -3
  71. package/harness/bundles/java/claude-code/harness-archive/SKILL.md +3 -3
  72. package/harness/bundles/java/claude-code/harness-codebase-map/SKILL.md +3 -3
  73. package/harness/bundles/java/claude-code/harness-knowledge-ingest/SKILL.md +3 -3
  74. package/harness/bundles/java/claude-code/harness-knowledge-query/SKILL.md +3 -3
  75. package/harness/bundles/java/claude-code/harness-package/SKILL.md +3 -3
  76. package/harness/bundles/java/claude-code/harness-plan/SKILL.md +6 -6
  77. package/harness/bundles/java/claude-code/harness-plan/checklist.md +10 -4
  78. package/harness/bundles/java/claude-code/harness-plan/reference.md +17 -17
  79. package/harness/bundles/java/claude-code/harness-review/SKILL.md +3 -3
  80. package/harness/bundles/java/claude-code/harness-run/SKILL.md +4 -4
  81. package/harness/bundles/java/claude-code/harness-submit/SKILL.md +3 -3
  82. package/harness/bundles/java/claude-code/harness-sync/SKILL.md +3 -3
  83. package/harness/bundles/java/claude-code/harness-test/SKILL.md +3 -3
  84. package/harness/bundles/java/claude-code/scripts/harness_gate.py +97 -14
  85. package/harness/bundles/java/claude-code/scripts/harness_plan_finalize.py +364 -74
  86. package/harness/bundles/java/codebuddy/.harness-build.json +1 -1
  87. package/harness/bundles/java/codebuddy/harness-apidoc/SKILL.md +3 -3
  88. package/harness/bundles/java/codebuddy/harness-archive/SKILL.md +3 -3
  89. package/harness/bundles/java/codebuddy/harness-codebase-map/SKILL.md +3 -3
  90. package/harness/bundles/java/codebuddy/harness-knowledge-ingest/SKILL.md +3 -3
  91. package/harness/bundles/java/codebuddy/harness-knowledge-query/SKILL.md +3 -3
  92. package/harness/bundles/java/codebuddy/harness-package/SKILL.md +3 -3
  93. package/harness/bundles/java/codebuddy/harness-plan/SKILL.md +6 -6
  94. package/harness/bundles/java/codebuddy/harness-plan/checklist.md +10 -4
  95. package/harness/bundles/java/codebuddy/harness-plan/reference.md +17 -17
  96. package/harness/bundles/java/codebuddy/harness-review/SKILL.md +3 -3
  97. package/harness/bundles/java/codebuddy/harness-run/SKILL.md +4 -4
  98. package/harness/bundles/java/codebuddy/harness-submit/SKILL.md +3 -3
  99. package/harness/bundles/java/codebuddy/harness-sync/SKILL.md +3 -3
  100. package/harness/bundles/java/codebuddy/harness-test/SKILL.md +3 -3
  101. package/harness/bundles/java/codebuddy/scripts/harness_gate.py +97 -14
  102. package/harness/bundles/java/codebuddy/scripts/harness_plan_finalize.py +364 -74
  103. package/harness/bundles/java/codex/.harness-build.json +1 -1
  104. package/harness/bundles/java/codex/harness-apidoc/SKILL.md +3 -3
  105. package/harness/bundles/java/codex/harness-archive/SKILL.md +3 -3
  106. package/harness/bundles/java/codex/harness-codebase-map/SKILL.md +3 -3
  107. package/harness/bundles/java/codex/harness-knowledge-ingest/SKILL.md +3 -3
  108. package/harness/bundles/java/codex/harness-knowledge-query/SKILL.md +3 -3
  109. package/harness/bundles/java/codex/harness-package/SKILL.md +3 -3
  110. package/harness/bundles/java/codex/harness-plan/SKILL.md +6 -6
  111. package/harness/bundles/java/codex/harness-plan/checklist.md +10 -4
  112. package/harness/bundles/java/codex/harness-plan/reference.md +17 -17
  113. package/harness/bundles/java/codex/harness-review/SKILL.md +3 -3
  114. package/harness/bundles/java/codex/harness-run/SKILL.md +4 -4
  115. package/harness/bundles/java/codex/harness-submit/SKILL.md +3 -3
  116. package/harness/bundles/java/codex/harness-sync/SKILL.md +3 -3
  117. package/harness/bundles/java/codex/harness-test/SKILL.md +3 -3
  118. package/harness/bundles/java/codex/scripts/harness_gate.py +97 -14
  119. package/harness/bundles/java/codex/scripts/harness_plan_finalize.py +364 -74
  120. package/harness/bundles/java/cursor/.harness-build.json +1 -1
  121. package/harness/bundles/java/cursor/harness-apidoc/SKILL.md +3 -3
  122. package/harness/bundles/java/cursor/harness-archive/SKILL.md +3 -3
  123. package/harness/bundles/java/cursor/harness-codebase-map/SKILL.md +3 -3
  124. package/harness/bundles/java/cursor/harness-knowledge-ingest/SKILL.md +3 -3
  125. package/harness/bundles/java/cursor/harness-knowledge-query/SKILL.md +3 -3
  126. package/harness/bundles/java/cursor/harness-package/SKILL.md +3 -3
  127. package/harness/bundles/java/cursor/harness-plan/SKILL.md +6 -6
  128. package/harness/bundles/java/cursor/harness-plan/checklist.md +10 -4
  129. package/harness/bundles/java/cursor/harness-plan/reference.md +17 -17
  130. package/harness/bundles/java/cursor/harness-review/SKILL.md +3 -3
  131. package/harness/bundles/java/cursor/harness-run/SKILL.md +4 -4
  132. package/harness/bundles/java/cursor/harness-submit/SKILL.md +3 -3
  133. package/harness/bundles/java/cursor/harness-sync/SKILL.md +3 -3
  134. package/harness/bundles/java/cursor/harness-test/SKILL.md +3 -3
  135. package/harness/bundles/java/cursor/scripts/harness_gate.py +97 -14
  136. package/harness/bundles/java/cursor/scripts/harness_plan_finalize.py +364 -74
  137. package/harness/manifests/general/claude-code.json +19 -19
  138. package/harness/manifests/general/codebuddy.json +19 -19
  139. package/harness/manifests/general/codex.json +19 -19
  140. package/harness/manifests/general/cursor.json +19 -19
  141. package/harness/manifests/java/claude-code.json +19 -19
  142. package/harness/manifests/java/codebuddy.json +19 -19
  143. package/harness/manifests/java/codex.json +19 -19
  144. package/harness/manifests/java/cursor.json +19 -19
  145. package/hunter-workflow-family.json +4 -4
  146. package/package.json +1 -1
@@ -3,7 +3,7 @@ name: harness-knowledge-ingest
3
3
  description: 从 .harness/archive 归档整理、同步和维护项目知识索引。适用场景:ingest knowledge、sync
4
4
  knowledge、rebuild knowledge index、promote knowledge、确认知识条目、检查知识库是否过期。
5
5
  ---
6
- <!-- generated by harness_deploy.py; core=1627e6c5efeb0f1d; overlay=java; agent=codebuddy; do not edit -->
6
+ <!-- generated by harness_deploy.py; core=5e077a99a90502cb; overlay=java; agent=codebuddy; do not edit -->
7
7
  # harness-knowledge-ingest
8
8
 
9
9
  从 `.harness/archive/**/reports/final/summary-data.json` 抽取项目知识,生成并维护本地 `.harness/knowledge/` 索引。
@@ -238,12 +238,12 @@ powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' sync
238
238
  `events.ndjson` 为唯一事实源(schema_version 3,兼容读取 v1/v2;`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止用 Write/Edit 直接维护**。直接修改的内容会在 `phase.end` 或 finalize 时被完整重建覆盖,属于数据丢失;需要保留的详情必须进入事件 `note`。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
239
239
 
240
240
  ```powershell
241
- python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
241
+ python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --run-id <phase-run-id> --attempt <n> --note "<触发指令>"
242
242
  ```
243
243
 
244
244
  > **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
245
245
 
246
246
  > **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
247
247
 
248
- 每次阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`;重试同一阶段时增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
248
+ 每个阶段的 `phase.start` 与对应 `phase.end` 必须复用同一 `--run-id` / `--attempt`;阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`。重试同一阶段时生成新的 run-id 并增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
249
249
  > 片段:logging · phase=`knowledge-ingest` · 默认控制台报告;变更上下文写 phase/decision/issue/artifact
@@ -3,7 +3,7 @@ name: harness-knowledge-query
3
3
  description: 根据新需求、设计任务、代码修改请求或问题排查,在规划和编码前查询 .harness/knowledge
4
4
  历史上下文。适用场景:query knowledge、查找历史需求、根据归档理解需求、继续之前类似开发、生成需求上下文包。
5
5
  ---
6
- <!-- generated by harness_deploy.py; core=1627e6c5efeb0f1d; overlay=java; agent=codebuddy; do not edit -->
6
+ <!-- generated by harness_deploy.py; core=5e077a99a90502cb; overlay=java; agent=codebuddy; do not edit -->
7
7
  # harness-knowledge-query
8
8
 
9
9
  并行 change 中查询必须传 `--change <change-id>`;成功后以该 change 的 `meta/knowledge-context.json` 为稳定指针。全局 `context-packs/latest.json` 仅向后兼容,不得用于判断多个 active change 的上下文归属。
@@ -136,12 +136,12 @@ powershell.exe -Command "python '<ingest-skill-dir>\scripts\harness_knowledge.py
136
136
  `events.ndjson` 为唯一事实源(schema_version 3,兼容读取 v1/v2;`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止用 Write/Edit 直接维护**。直接修改的内容会在 `phase.end` 或 finalize 时被完整重建覆盖,属于数据丢失;需要保留的详情必须进入事件 `note`。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
137
137
 
138
138
  ```powershell
139
- python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
139
+ python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --run-id <phase-run-id> --attempt <n> --note "<触发指令>"
140
140
  ```
141
141
 
142
142
  > **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
143
143
 
144
144
  > **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
145
145
 
146
- 每次阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`;重试同一阶段时增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
146
+ 每个阶段的 `phase.start` 与对应 `phase.end` 必须复用同一 `--run-id` / `--attempt`;阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`。重试同一阶段时生成新的 run-id 并增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
147
147
  > 片段:logging · phase=`knowledge-query` · 独立运行时控制台报告;变更上下文写 decision/issue/artifact
@@ -2,7 +2,7 @@
2
2
  name: harness-package
3
3
  description: 增量模块打包:拉取最新→编译验证→mvn package→汇总 jar/war。使用场景:打包、package、发版准备
4
4
  ---
5
- <!-- generated by harness_deploy.py; core=1627e6c5efeb0f1d; overlay=java; agent=codebuddy; do not edit -->
5
+ <!-- generated by harness_deploy.py; core=5e077a99a90502cb; overlay=java; agent=codebuddy; do not edit -->
6
6
  # harness-package — 增量模块打包(Java overlay)
7
7
 
8
8
  ## Purpose
@@ -67,12 +67,12 @@ description: 增量模块打包:拉取最新→编译验证→mvn package→
67
67
  `events.ndjson` 为唯一事实源(schema_version 3,兼容读取 v1/v2;`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止用 Write/Edit 直接维护**。直接修改的内容会在 `phase.end` 或 finalize 时被完整重建覆盖,属于数据丢失;需要保留的详情必须进入事件 `note`。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
68
68
 
69
69
  ```powershell
70
- python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
70
+ python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --run-id <phase-run-id> --attempt <n> --note "<触发指令>"
71
71
  ```
72
72
 
73
73
  > **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
74
74
 
75
75
  > **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
76
76
 
77
- 每次阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`;重试同一阶段时增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
77
+ 每个阶段的 `phase.start` 与对应 `phase.end` 必须复用同一 `--run-id` / `--attempt`;阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`。重试同一阶段时生成新的 run-id 并增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
78
78
  > 片段:logging · phase=`package`
@@ -2,7 +2,7 @@
2
2
  name: harness-plan
3
3
  description: 将需求转化为设计文档+实施计划+完整测试场景表,必须在编码前完成。使用场景:需求分析、feature plan、技术方案设计、实现方案规划
4
4
  ---
5
- <!-- generated by harness_deploy.py; core=1627e6c5efeb0f1d; overlay=java; agent=codebuddy; do not edit -->
5
+ <!-- generated by harness_deploy.py; core=5e077a99a90502cb; overlay=java; agent=codebuddy; do not edit -->
6
6
  # harness-plan — 需求规划
7
7
 
8
8
  ## Purpose
@@ -64,14 +64,14 @@ description: 将需求转化为设计文档+实施计划+完整测试场景表
64
64
  | 阶段 | 动作 |
65
65
  |------|------|
66
66
  | 0 | 用当前解释器运行 `harness_runtime.py doctor`,后续消费绝对 argv;git status;脏工作区 → baseline 隔离 + `decision`,不询问 |
67
- | 0.5 | 先初始化 change-name + `phase.start`,从第一条知识查询起保留事件证据 |
67
+ | 0.5 | 先初始化 change-name、plan-run-id attempt(首次为 1),用同一身份追加 `phase.start`;从第一条知识查询起保留事件证据,并在 finalizer 中复用该身份 |
68
68
  | 1 | `harness-knowledge-query` 单次 query(内部 ensure-current;失败记 `issue`) |
69
69
  | 2 | 歧义优先检查 + 复杂度分级;先确认会改变实现方向的语义歧义 |
70
70
  | 3 | 按复杂度执行有预算的代码探索;简单修复不得扩散到无关模块 |
71
71
  | 4 | **设计审批包** blocking user confirmation;确认事件早于 approved 设计文档和 `meta/worktree.json` |
72
72
  | 5–6 | plan + implementation-detail + test-scenarios → `plans/` |
73
73
  | 7.5 | 仅 `--adversarial` 对抗评审 |
74
- | 8 | 在临时产物集上运行 `harness_plan_finalize.py finalize`;原子发布、唯一 `phase.end`、render → `checklist.md` |
74
+ | 8 | 在临时产物集上运行 `harness_plan_finalize.py finalize`,随后立即运行 `verify`;原子发布、派生清单计数对账、完整生命周期、render → `checklist.md` |
75
75
 
76
76
  change-name 范围变更 → 提示重命名或记 🟡WARN(→ `reference.md`)
77
77
 
@@ -88,7 +88,7 @@ change-name 范围变更 → 提示重命名或记 🟡WARN(→ `reference.md`
88
88
  |------|------|
89
89
  | 产物路径 | 只写 `.harness/changes/<cn>/`;禁止 superpowers 输入 |
90
90
  | 设计审批包 | 一次 blocking user confirmation 含 worktree(读 `harness.json` `defaultWorktree`) |
91
- | 阶段 8 | spec/plan/detail/scenarios/worktree.json 先进入 staging;仅 finalizer 校验成功后发布并写唯一 `phase.end`/log,失败不得手工补终态 |
91
+ | 阶段 8 | spec/plan/detail/scenarios/worktree.json 先进入 staging;仅 finalizer 校验成功后发布并写唯一 `phase.end`/log;随后 `verify` 必须确认 start/end、收据哈希、全部任务表和非空场景清单一致,失败不得手工补终态 |
92
92
  | Plan 结束 | **禁止**询问执行模式;只提示 `/harness-run` |
93
93
  | 知识查询 | 0.5 失败不得假装已读历史 |
94
94
  | 歧义优先检查 | 否定、对比、动作对象或范围存在多种合理解释时,最小取证后先给推荐理解并一次一问;确认前不深挖错误方向 |
@@ -116,12 +116,12 @@ change-name 范围变更 → 提示重命名或记 🟡WARN(→ `reference.md`
116
116
  `events.ndjson` 为唯一事实源(schema_version 3,兼容读取 v1/v2;`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止用 Write/Edit 直接维护**。直接修改的内容会在 `phase.end` 或 finalize 时被完整重建覆盖,属于数据丢失;需要保留的详情必须进入事件 `note`。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
117
117
 
118
118
  ```powershell
119
- python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
119
+ python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --run-id <phase-run-id> --attempt <n> --note "<触发指令>"
120
120
  ```
121
121
 
122
122
  > **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
123
123
 
124
124
  > **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
125
125
 
126
- 每次阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`;重试同一阶段时增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
126
+ 每个阶段的 `phase.start` 与对应 `phase.end` 必须复用同一 `--run-id` / `--attempt`;阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`。重试同一阶段时生成新的 run-id 并增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
127
127
  > 片段:logging · phase=`plan`
@@ -14,7 +14,7 @@ description: harness-plan 的阶段检查清单和覆盖检查列表。仅在执
14
14
 
15
15
  ## 阶段 0.5:事件初始化与知识查询
16
16
 
17
- - [ ] 先确定 change-name,并立即用 `harness_events.py append` 追加 `phase.start`
17
+ - [ ] 先确定 change-name、稳定的 plan-run-id 与 attempt(首次为 1),立即用 `harness_events.py append ... --phase plan --type phase.start --run-id <plan-run-id> --attempt <attempt>` 追加开始事件
18
18
  - [ ] 再执行一次 knowledge `query`;由 query 内部 ensure-current,不另跑前置 sync
19
19
  - [ ] 查询失败追加 `issue`,不得重跑“sync + query”循环或假装已读取历史
20
20
 
@@ -210,8 +210,11 @@ source: harness-plan
210
210
  > **缺任一文件 → ❌FAIL,不得宣称 plan 完成。**
211
211
 
212
212
  - [ ] 所有待发布产物先写入 staging,不直接覆盖正式 change 目录
213
- - [ ] 执行 `harness_plan_finalize.py finalize --change-dir ... --staging-dir ... --change ... --run-id ... --attempt ... --json`
213
+ - [ ] 执行 `harness_plan_finalize.py finalize --change-dir ... --staging-dir ... --change ... --run-id <plan-run-id> --attempt <attempt> --json`;身份必须与本次 `phase.start` 完全相同
214
214
  - [ ] finalizer 返回 `ok=true` 与 `artifactsHash`;重复执行返回 `idempotent=true`
215
+ - [ ] 紧接着执行 `harness_plan_finalize.py verify --change-dir ... --json`
216
+ - [ ] verify 返回 `phaseStartCount=1`、`phaseEndCount=1`、`phaseEndStatus=OK`、`receiptConsistent=true`
217
+ - [ ] verify 的 `taskCount` 等于全部任务表行数,`scenarioCount` 等于 Markdown 中全部唯一场景 ID 数;任一为 0 或不一致即 ❌FAIL
215
218
  - [ ] finalizer 失败时正式目录无半发布产物、无成功 `phase.end`、无伪造 execution log
216
219
  - [ ] 禁止在 finalizer 之前手工追加成功 `phase.end`
217
220
 
@@ -222,6 +225,9 @@ source: harness-plan
222
225
  | `.harness/changes/<change>/plans/<change>-implementation-detail.md` | ✅ | □ |
223
226
  | `.harness/changes/<change>/plans/<change>-test-scenarios.md` | ✅ | □ |
224
227
  | `.harness/changes/<change>/meta/worktree.json` | ✅ | □ |
228
+ | `.harness/changes/<change>/meta/implementation-checkpoints.json` | ✅ | □ |
229
+ | `.harness/changes/<change>/meta/scenario-manifest.json`(非空且计数一致) | ✅ | □ |
230
+ | `.harness/changes/<change>/meta/plan-finalization.json`(finalized) | ✅ | □ |
225
231
  | `.harness/changes/<change>/logs/execution-log.md` | ✅ | □ |
226
232
  | `.harness/changes/<change>/events.ndjson` | ✅ | □ |
227
233
 
@@ -244,7 +250,7 @@ source: harness-plan
244
250
 
245
251
  ## 关键原则
246
252
 
247
- - **产物路径唯一性**:`.harness/changes/<change-name>/` 是唯一真相源,plan 产物必须直接写入此目录
253
+ - **产物路径唯一性**:正式 `.harness/changes/<change-name>/` 是唯一真相源;plan 只写 staging,由 finalizer 原子发布,禁止先写正式目录再补 staging
248
254
  - **原生规划协议**:阶段 4/6 使用 clarification、decision-grilling、implementation-planning 三段内置协议,不运行时依赖 Superpowers/grill-me/writing-plans
249
255
  - **阶段 4 是强制阻断检查点**——展示设计审批包后必须停下来问用户,收到回复后才能写 approved 设计文档。不要跳过
250
256
  - 代码探索只读不写——这个阶段的目标是理解,不是修改
@@ -255,7 +261,7 @@ source: harness-plan
255
261
 
256
262
  ## 事件记录(前置规则)
257
263
 
258
- - [ ] 确定 change-name 后立即 append `phase.start` 事件;各阶段用 `harness_events.py append` 写入 `decision` / `issue` / `artifact`
264
+ - [ ] 确定 change-name 后立即用稳定且可复用的 `--run-id` / `--attempt` append `phase.start` 事件;各阶段用 `harness_events.py append` 写入 `decision` / `issue` / `artifact`
259
265
  - [ ] 阶段 0 在 change-name 确定前可不写事件;阶段 0.5 确定 change-name 后必须开始记录
260
266
 
261
267
  ## 需求范围缩减后的 change-name 检查 ⚠️
@@ -228,35 +228,35 @@ status: approved
228
228
 
229
229
  #### 1.1 <类名.方法名>
230
230
 
231
- | # | 分类 | 场景描述 | 输入 | 预期 | 执行层级 | 预计时长 | 资源预算 | 超时 | 可复用证据 |
232
- |:--:|:----:|----------|------|------|----------|----------|----------|------|------------|
233
- | UT-001 | 正常 | ... | ... | ... | affected | ≤10s | 1 worker / ≤512MB | 30s | inputsHash + command |
234
- | UT-002 | 异常 | ... | ... | 抛 xxxException | affected | ≤10s | 1 worker / ≤512MB | 30s | inputsHash + command |
235
- | UT-003 | 边界 | ... | ... | ... | module | ≤60s | ≤50% CPU / ≤1GB | 120s | ledger identity |
231
+ | ID | 优先级 | 分类 | 场景描述 | 输入 | 预期 | 执行层级 | 预计时长 | 资源预算 | 超时 | 可复用证据 |
232
+ |:--:|:------:|:----:|----------|------|------|----------|----------|----------|------|------------|
233
+ | UT-001 | P0 | 正常 | ... | ... | ... | affected | ≤10s | 1 worker / ≤512MB | 30s | inputsHash + command |
234
+ | UT-002 | P0 | 异常 | ... | ... | 抛 xxxException | affected | ≤10s | 1 worker / ≤512MB | 30s | inputsHash + command |
235
+ | UT-003 | P1 | 边界 | ... | ... | ... | module | ≤60s | ≤50% CPU / ≤1GB | 120s | ledger identity |
236
236
 
237
237
  ### 二、接口测试场景
238
238
 
239
239
  #### 2.1 POST /xxx
240
240
 
241
- | # | 分类 | 场景描述 | 关键字段 | HTTP | code | message | 执行层级 | 预计时长 | 资源预算 | 超时 | 可复用证据 |
242
- |:--:|:----:|----------|----------|:----:|:----:|--------|----------|----------|----------|------|------------|
243
- | API-001 | 正常 | ... | ... | 200 | 0 | 成功 | module | ≤60s | 1 service / ≤1GB | 120s | environmentHash + ledger |
244
- | API-002 | 校验 | ... | ... | 200 | xxx | ... | affected | ≤20s | 1 service / ≤1GB | 60s | environmentHash + ledger |
241
+ | ID | 优先级 | 分类 | 场景描述 | 关键字段 | HTTP | code | message | 执行层级 | 预计时长 | 资源预算 | 超时 | 可复用证据 |
242
+ |:--:|:------:|:----:|----------|----------|:----:|:----:|--------|----------|----------|----------|------|------------|
243
+ | API-001 | P0 | 正常 | ... | ... | 200 | 0 | 成功 | module | ≤60s | 1 service / ≤1GB | 120s | environmentHash + ledger |
244
+ | API-002 | P1 | 校验 | ... | ... | 200 | xxx | ... | affected | ≤20s | 1 service / ≤1GB | 60s | environmentHash + ledger |
245
245
 
246
246
  ### 三、数据兼容场景
247
247
 
248
- | # | 分类 | 场景描述 | 操作 | 数据特征 | 预期 | 执行层级 | 预计时长 | 资源预算 | 超时 | 可复用证据 |
249
- |:--:|:----:|----------|:----:|----------|------|----------|----------|----------|------|------------|
250
- | COM-001 | 旧数据 | ... | ... | ... | ... | module | ≤60s | isolated DB / ≤1GB | 120s | dbSchemaHash + ledger |
248
+ | ID | 优先级 | 分类 | 场景描述 | 操作 | 数据特征 | 预期 | 执行层级 | 预计时长 | 资源预算 | 超时 | 可复用证据 |
249
+ |:--:|:------:|:----:|----------|:----:|----------|------|----------|----------|----------|------|------------|
250
+ | COM-001 | P1 | 旧数据 | ... | ... | ... | ... | module | ≤60s | isolated DB / ≤1GB | 120s | dbSchemaHash + ledger |
251
251
 
252
252
  ### 四、集成场景
253
253
 
254
- | # | 分类 | 场景描述 | 前置条件 | 步骤 | 预期 | 执行层级 | 预计时长 | 资源预算 | 超时 | 可复用证据 |
255
- |:--:|:----:|----------|----------|------|------|----------|----------|----------|------|------------|
256
- | INT-001 | 端到端 | ... | ... | N 步操作 | ... | candidate | ≤10m | ≤50% CPU / ≤2GB | 15m | verification identity |
254
+ | ID | 优先级 | 分类 | 场景描述 | 前置条件 | 步骤 | 预期 | 执行层级 | 预计时长 | 资源预算 | 超时 | 可复用证据 |
255
+ |:--:|:------:|:----:|----------|----------|------|------|----------|----------|----------|------|------------|
256
+ | INT-001 | P0 | 端到端 | ... | ... | N 步操作 | ... | candidate | ≤10m | ≤50% CPU / ≤2GB | 15m | verification identity |
257
257
  ```
258
258
 
259
- 执行层级固定为 `affected`(快速反馈)、`module`(变更模块门禁)、`candidate`(产品候选)。禁止所有场景默认跑全仓库;无法给出预算或超时时必须说明原因,并拆分或隔离高成本场景。只有 command、inputs/toolchain/environment 身份一致的成功 ledger 证据可以复用。
259
+ 新计划必须显式使用 `ID` 和 `优先级` 列;`P0/P1` 都要求 ledger 证据,`P2` 才是 advisory。解析器兼容旧的 `#`、`分类`、`场景描述` 表头,旧表缺优先级时保守按 `P1` 处理。执行层级固定为 `affected`(快速反馈)、`module`(变更模块门禁)、`candidate`(产品候选)。禁止所有场景默认跑全仓库;无法给出预算或超时时必须说明原因,并拆分或隔离高成本场景。只有 command、inputs/toolchain/environment 身份一致的成功 ledger 证据可以复用。
260
260
 
261
261
  ## 产物保存规则(跨阶段:阶段0.5/4/6/8)
262
262
 
@@ -299,7 +299,7 @@ status: approved
299
299
 
300
300
  > 如果 frontmatter 缺失,后续 run/test/review/submit/archive 不得依赖模型猜测 change-name。
301
301
 
302
- 4. **初始化结构化事件**:确定 change-name 后,立即运行 `harness_events.py append --type phase.start`。脚本负责建立父目录和 `events.ndjson`;执行日志在 `phase.end` 时由完整事件流渲染,任何阶段都不得直接用 Write/Edit 维护该投影。
302
+ 4. **初始化结构化事件**:确定 change-name 后,立即生成稳定的 `<plan-run-id>`(同一次 plan 尝试内不得改变;首次 `<attempt>` 为 `1`),运行 `harness_events.py append --change-dir ... --phase plan --type phase.start --run-id <plan-run-id> --attempt <attempt>`。finalizer 必须复用完全相同的 `--run-id` / `--attempt`,否则 verify 会按生命周期身份 fail-closed。脚本负责建立父目录和 `events.ndjson`;执行日志在 `phase.end` 时由完整事件流渲染,任何阶段都不得直接用 Write/Edit 维护该投影。
303
303
 
304
304
  5. **保存计划文件**:计划文件包含 YAML frontmatter(含 change-name),保存到:
305
305
  - `.harness/changes/<change-name>/plans/<change-name>-plan.md`(简洁任务表)
@@ -3,7 +3,7 @@ name: harness-review
3
3
  description: 6维度代码审查(架构/安全/规范/兼容/测试/性能),对照项目规则(见
4
4
  .harness/context-index.json)和测试场景表,在隔离上下文运行。使用场景:代码审查、提交前检查、合并评审
5
5
  ---
6
- <!-- generated by harness_deploy.py; core=1627e6c5efeb0f1d; overlay=java; agent=codebuddy; do not edit -->
6
+ <!-- generated by harness_deploy.py; core=5e077a99a90502cb; overlay=java; agent=codebuddy; do not edit -->
7
7
  # harness-review — 代码审查
8
8
 
9
9
  ## Purpose
@@ -143,12 +143,12 @@ review 读取 `state-snapshot.json`(`harness_state.py` / state-layout-protocol
143
143
  `events.ndjson` 为唯一事实源(schema_version 3,兼容读取 v1/v2;`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止用 Write/Edit 直接维护**。直接修改的内容会在 `phase.end` 或 finalize 时被完整重建覆盖,属于数据丢失;需要保留的详情必须进入事件 `note`。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
144
144
 
145
145
  ```powershell
146
- python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
146
+ python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --run-id <phase-run-id> --attempt <n> --note "<触发指令>"
147
147
  ```
148
148
 
149
149
  > **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
150
150
 
151
151
  > **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
152
152
 
153
- 每次阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`;重试同一阶段时增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
153
+ 每个阶段的 `phase.start` 与对应 `phase.end` 必须复用同一 `--run-id` / `--attempt`;阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`。重试同一阶段时生成新的 run-id 并增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
154
154
  > 片段:logging · phase=`review` · 事件:phase/decision/verification/issue/artifact
@@ -2,7 +2,7 @@
2
2
  name: harness-run
3
3
  description: 按变更簇执行 TDD 编码循环(RED→GREEN→REFACTOR→编译验证),逐变更簇实现计划中的任务。使用场景:开始编码、实现功能、写代码、TDD 编码
4
4
  ---
5
- <!-- generated by harness_deploy.py; core=1627e6c5efeb0f1d; overlay=java; agent=codebuddy; do not edit -->
5
+ <!-- generated by harness_deploy.py; core=5e077a99a90502cb; overlay=java; agent=codebuddy; do not edit -->
6
6
  # harness-run — 需求编码
7
7
 
8
8
  ## Purpose
@@ -56,7 +56,7 @@ description: 按变更簇执行 TDD 编码循环(RED→GREEN→REFACTOR→编
56
56
 
57
57
  ## Workflow 概要
58
58
 
59
- 0. 加载上下文:先 `harness_change.py resolve [--change] --json`(多 active 缺参 → `CHANGE_SELECTION_REQUIRED`,禁止按 mtime 猜测);读 spec/plan/detail/scenarios/ledger/run-task-status/worktree;`--fixback` 读 fixback → **`harness_gate.py begin --phase run --change <id>`**(内部 claim + phase.start + identity;禁止手工 Write `events.ndjson` / 手工 `phase.end`)
59
+ 0. 加载上下文:先 `harness_change.py resolve [--change] --json`(多 active 缺参 → `CHANGE_SELECTION_REQUIRED`,禁止按 mtime 猜测);读 spec/plan/detail/scenarios/ledger/run-task-status/worktree;`--fixback` 读 fixback → **`harness_gate.py begin --phase run --change <id>`**(先 fail-closed 校验 Plan 收据/哈希/完整生命周期/全部任务/非空场景清单,再 claim + phase.start + identity;禁止手工 Write `events.ndjson` / 手工 `phase.end`)
60
60
  0.5. **测试基础设施探测**(先写 `CHECKING`,四项证据齐备后再结论)→ `reference.md` Step 0.5;进入 TDD 前执行 `harness_test_guard.py begin --project . --change-dir ".harness/changes/<cn>" --json`
61
61
  1. **变更簇 TDD** — `protocols.md` `run-tdd-protocol`;批量 RED/GREEN;按需 `change-cluster-review-protocol`(高风险 + reviewer 预检可用)
62
62
  2. 构建验证 + **仅**通过 `harness_ledger.py record` 写 ledger(禁止 Write/Edit `verification-ledger.json`);`diff-hash --change-dir` 纳入 ignored tests → `reference.md` Step 2c
@@ -142,12 +142,12 @@ python <skills-root>/scripts/harness_test_guard.py record --project . --change-d
142
142
  `events.ndjson` 为唯一事实源(schema_version 3,兼容读取 v1/v2;`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止用 Write/Edit 直接维护**。直接修改的内容会在 `phase.end` 或 finalize 时被完整重建覆盖,属于数据丢失;需要保留的详情必须进入事件 `note`。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
143
143
 
144
144
  ```powershell
145
- python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
145
+ python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --run-id <phase-run-id> --attempt <n> --note "<触发指令>"
146
146
  ```
147
147
 
148
148
  > **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
149
149
 
150
150
  > **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
151
151
 
152
- 每次阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`;重试同一阶段时增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
152
+ 每个阶段的 `phase.start` 与对应 `phase.end` 必须复用同一 `--run-id` / `--attempt`;阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`。重试同一阶段时生成新的 run-id 并增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
153
153
  > 片段:logging · phase=`run`
@@ -3,7 +3,7 @@ name: harness-submit
3
3
  description: 最终提交封装:验证→中文 commit→提交/推送;worktree 模式含 --no-ff
4
4
  合并回主分支。使用场景:提交代码、commit、push、合并分支、merge to main、完成开发
5
5
  ---
6
- <!-- generated by harness_deploy.py; core=1627e6c5efeb0f1d; overlay=java; agent=codebuddy; do not edit -->
6
+ <!-- generated by harness_deploy.py; core=5e077a99a90502cb; overlay=java; agent=codebuddy; do not edit -->
7
7
  # harness-submit — 最终提交(含 worktree 合并)
8
8
 
9
9
  ## Purpose
@@ -164,12 +164,12 @@ git 经 PowerShell;commit/报告不得含明文密钥。遵循 `../protocols/s
164
164
  `events.ndjson` 为唯一事实源(schema_version 3,兼容读取 v1/v2;`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止用 Write/Edit 直接维护**。直接修改的内容会在 `phase.end` 或 finalize 时被完整重建覆盖,属于数据丢失;需要保留的详情必须进入事件 `note`。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
165
165
 
166
166
  ```powershell
167
- python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
167
+ python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --run-id <phase-run-id> --attempt <n> --note "<触发指令>"
168
168
  ```
169
169
 
170
170
  > **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
171
171
 
172
172
  > **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
173
173
 
174
- 每次阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`;重试同一阶段时增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
174
+ 每个阶段的 `phase.start` 与对应 `phase.end` 必须复用同一 `--run-id` / `--attempt`;阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`。重试同一阶段时生成新的 run-id 并增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
175
175
  > 片段:logging · phase=`submit`/`merge`
@@ -4,7 +4,7 @@ description: Use when the user asks to synchronize, refresh, or validate Harness
4
4
  metadata, adapters, knowledge, rules, instruction entrypoints, config origins,
5
5
  or CodeGraph status.
6
6
  ---
7
- <!-- generated by harness_deploy.py; core=1627e6c5efeb0f1d; overlay=java; agent=codebuddy; do not edit -->
7
+ <!-- generated by harness_deploy.py; core=5e077a99a90502cb; overlay=java; agent=codebuddy; do not edit -->
8
8
  # harness-sync
9
9
 
10
10
  ## Purpose
@@ -57,12 +57,12 @@ CLI 负责 Python runtime 解析、投影事务、knowledge、rules、map、指
57
57
  `events.ndjson` 为唯一事实源(schema_version 3,兼容读取 v1/v2;`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止用 Write/Edit 直接维护**。直接修改的内容会在 `phase.end` 或 finalize 时被完整重建覆盖,属于数据丢失;需要保留的详情必须进入事件 `note`。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
58
58
 
59
59
  ```powershell
60
- python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
60
+ python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --run-id <phase-run-id> --attempt <n> --note "<触发指令>"
61
61
  ```
62
62
 
63
63
  > **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
64
64
 
65
65
  > **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
66
66
 
67
- 每次阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`;重试同一阶段时增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
67
+ 每个阶段的 `phase.start` 与对应 `phase.end` 必须复用同一 `--run-id` / `--attempt`;阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`。重试同一阶段时生成新的 run-id 并增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
68
68
  > 片段:logging · phase=`sync`
@@ -2,7 +2,7 @@
2
2
  name: harness-test
3
3
  description: 测试执行:读取场景表,执行单元测试+API接口测试+数据兼容验证,输出测试报告。当用户说'跑测试/验证/跑用例/接口测试/单元测试'时使用
4
4
  ---
5
- <!-- generated by harness_deploy.py; core=1627e6c5efeb0f1d; overlay=java; agent=codebuddy; do not edit -->
5
+ <!-- generated by harness_deploy.py; core=5e077a99a90502cb; overlay=java; agent=codebuddy; do not edit -->
6
6
  # harness-test — 测试执行
7
7
 
8
8
  ## Purpose
@@ -211,12 +211,12 @@ python <skills-root>/scripts/harness_test_guard.py record --project . --change-d
211
211
  `events.ndjson` 为唯一事实源(schema_version 3,兼容读取 v1/v2;`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止用 Write/Edit 直接维护**。直接修改的内容会在 `phase.end` 或 finalize 时被完整重建覆盖,属于数据丢失;需要保留的详情必须进入事件 `note`。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
212
212
 
213
213
  ```powershell
214
- python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
214
+ python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --run-id <phase-run-id> --attempt <n> --note "<触发指令>"
215
215
  ```
216
216
 
217
217
  > **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
218
218
 
219
219
  > **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
220
220
 
221
- 每次阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`;重试同一阶段时增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
221
+ 每个阶段的 `phase.start` 与对应 `phase.end` 必须复用同一 `--run-id` / `--attempt`;阶段结束必须写 `--status OK|WARN|FAIL|BLOCKED`。重试同一阶段时生成新的 run-id 并增加 `--attempt <n>`,不得覆盖或伪装成一次执行。跨工具继续执行时写 `--executor-tool <codex|claude-code|codebuddy|cursor>`,并在接棒事件写 `--handoff-from-tool` / `--handoff-reason`;也可由 `HUNTER_HARNESS_TOOL/AGENT/MODEL/RUN_ID` 环境变量统一注入。
222
222
  > 片段:logging · phase=`test` · 事件:phase/command/verification/decision/issue/artifact
@@ -33,6 +33,7 @@ import harness_change as hc # noqa: E402
33
33
  import harness_events as he # noqa: E402
34
34
  import harness_ledger as hl # noqa: E402
35
35
  import harness_paths as hp # noqa: E402
36
+ import harness_plan_finalize as hpf # noqa: E402
36
37
  import harness_workflow_policy as hwp # noqa: E402
37
38
  import harness_test_guard as htg # noqa: E402
38
39
 
@@ -1588,10 +1589,11 @@ def _phase_event_exists(change_dir: Path, phase: str, type_: str, run_id: str) -
1588
1589
 
1589
1590
 
1590
1591
  def _validate_scenario_coverage(change_dir: Path) -> dict[str, Any]:
1591
- """C9: validate all P0 scenarios have a ledger entry with scenarioIds covering them.
1592
+ """C9: validate all ledger-required scenarios are covered by ledger entries.
1592
1593
 
1593
1594
  Reads meta/scenario-manifest.json and evidence/verification-ledger.json.
1594
- Returns ok=True when manifest missing (backward compat) or all P0 scenarios covered.
1595
+ Returns ok=True when a legacy manifest is missing or all required scenarios
1596
+ are covered. A present but empty manifest is always invalid.
1595
1597
  """
1596
1598
  manifest_path = change_dir / "meta" / "scenario-manifest.json"
1597
1599
  if not manifest_path.is_file():
@@ -1604,24 +1606,52 @@ def _validate_scenario_coverage(change_dir: Path) -> dict[str, Any]:
1604
1606
  "code": "SCENARIO_MANIFEST_INVALID",
1605
1607
  "message": f"scenario-manifest.json unreadable: {exc}",
1606
1608
  }
1607
- scenarios = manifest.get("scenarios") or []
1608
- p0_ids = {
1609
+ scenarios = manifest.get("scenarios") if isinstance(manifest, dict) else None
1610
+ if not isinstance(scenarios, list):
1611
+ return {
1612
+ "ok": False,
1613
+ "code": "SCENARIO_MANIFEST_INVALID",
1614
+ "message": "scenario-manifest.json scenarios must be a list",
1615
+ }
1616
+ if not scenarios:
1617
+ return {
1618
+ "ok": False,
1619
+ "code": "SCENARIO_MANIFEST_EMPTY",
1620
+ "message": "scenario-manifest.json must contain at least one scenario",
1621
+ }
1622
+ invalid_items = [
1623
+ index
1624
+ for index, scenario in enumerate(scenarios)
1625
+ if not isinstance(scenario, dict) or not str(scenario.get("id") or "").strip()
1626
+ ]
1627
+ if invalid_items:
1628
+ return {
1629
+ "ok": False,
1630
+ "code": "SCENARIO_MANIFEST_INVALID",
1631
+ "message": f"scenario entries missing IDs at indexes: {invalid_items}",
1632
+ }
1633
+ required_ids = {
1609
1634
  str(s.get("id"))
1610
1635
  for s in scenarios
1611
1636
  if isinstance(s, dict)
1612
- and str(s.get("priority", "")).upper() == "P0"
1613
- and s.get("requiredEvidenceKind") == "ledger"
1637
+ and (
1638
+ s.get("requiredEvidenceKind") == "ledger"
1639
+ or (
1640
+ not s.get("requiredEvidenceKind")
1641
+ and str(s.get("priority", "")).upper() in {"P0", "P1"}
1642
+ )
1643
+ )
1614
1644
  }
1615
- if not p0_ids:
1616
- return {"ok": True, "code": "NO_P0_SCENARIOS"}
1645
+ if not required_ids:
1646
+ return {"ok": True, "code": "NO_LEDGER_REQUIRED_SCENARIOS"}
1617
1647
 
1618
1648
  ledger_path = change_dir / "evidence" / "verification-ledger.json"
1619
1649
  if not ledger_path.is_file():
1620
1650
  return {
1621
1651
  "ok": False,
1622
1652
  "code": "SCENARIO_COVERAGE_FAILED",
1623
- "message": "ledger missing; cannot verify P0 scenario coverage",
1624
- "missing": sorted(p0_ids),
1653
+ "message": "ledger missing; cannot verify required scenario coverage",
1654
+ "missing": sorted(required_ids),
1625
1655
  }
1626
1656
  try:
1627
1657
  ledger = json.loads(ledger_path.read_text(encoding="utf-8-sig"))
@@ -1630,7 +1660,7 @@ def _validate_scenario_coverage(change_dir: Path) -> dict[str, Any]:
1630
1660
  "ok": False,
1631
1661
  "code": "SCENARIO_COVERAGE_FAILED",
1632
1662
  "message": f"ledger unreadable: {exc}",
1633
- "missing": sorted(p0_ids),
1663
+ "missing": sorted(required_ids),
1634
1664
  }
1635
1665
  covered: set[str] = set()
1636
1666
  validations = ledger.get("validations") or {}
@@ -1640,15 +1670,38 @@ def _validate_scenario_coverage(change_dir: Path) -> dict[str, Any]:
1640
1670
  ids = entry.get("scenarioIds")
1641
1671
  if isinstance(ids, list):
1642
1672
  covered.update(str(i) for i in ids)
1643
- missing = sorted(p0_ids - covered)
1673
+ missing = sorted(required_ids - covered)
1644
1674
  if missing:
1645
1675
  return {
1646
1676
  "ok": False,
1647
1677
  "code": "SCENARIO_COVERAGE_FAILED",
1648
- "message": f"P0 scenarios without ledger entry: {', '.join(missing)}",
1678
+ "message": (
1679
+ "ledger-required scenarios without ledger entry: "
1680
+ + ", ".join(missing)
1681
+ ),
1649
1682
  "missing": missing,
1650
1683
  }
1651
- return {"ok": True, "code": "SCENARIO_COVERAGE_OK", "covered": sorted(covered & p0_ids)}
1684
+ return {
1685
+ "ok": True,
1686
+ "code": "SCENARIO_COVERAGE_OK",
1687
+ "covered": sorted(covered & required_ids),
1688
+ }
1689
+
1690
+
1691
+ def validate_plan_handoff(change_dir: Path) -> dict[str, Any]:
1692
+ """Verify a finalized modern plan before the first run-side effect."""
1693
+ receipt_path = change_dir / "meta" / "plan-finalization.json"
1694
+ plans_root = change_dir / "plans"
1695
+ has_plan_artifacts = plans_root.is_dir() and any(
1696
+ plans_root.glob("*-plan.md")
1697
+ )
1698
+ if not receipt_path.is_file() and not has_plan_artifacts:
1699
+ return {
1700
+ "ok": True,
1701
+ "code": "PLAN_HANDOFF_NOT_APPLICABLE",
1702
+ "skipped": True,
1703
+ }
1704
+ return hpf.verify_plan(change_dir)
1652
1705
 
1653
1706
 
1654
1707
  def cmd_begin(args: argparse.Namespace) -> int:
@@ -1663,6 +1716,35 @@ def cmd_begin(args: argparse.Namespace) -> int:
1663
1716
  extra={k: v for k, v in resolved.items() if k not in {"ok", "message"}},
1664
1717
  )
1665
1718
  change_dir = Path(resolved["changeDir"])
1719
+ plan_verification: dict[str, Any] | None = None
1720
+ if args.phase == "run":
1721
+ plan_verification = validate_plan_handoff(change_dir)
1722
+ if not plan_verification.get("ok"):
1723
+ code = str(
1724
+ plan_verification.get("code") or "PLAN_HANDOFF_INVALID"
1725
+ )
1726
+ message = str(
1727
+ plan_verification.get("error")
1728
+ or plan_verification.get("message")
1729
+ or "finalized plan verification failed"
1730
+ )
1731
+ record_blocked_attempt(
1732
+ change_dir,
1733
+ phase=args.phase,
1734
+ code=code,
1735
+ message=message,
1736
+ run_id=args.run_id or os.environ.get("HUNTER_HARNESS_RUN_ID"),
1737
+ )
1738
+ return emit_error(
1739
+ code,
1740
+ message,
1741
+ as_json=as_json,
1742
+ extra={
1743
+ key: value
1744
+ for key, value in plan_verification.items()
1745
+ if key not in {"ok", "code", "error", "message"}
1746
+ },
1747
+ )
1666
1748
  concurrency_block = hc.check_concurrency_block(project, resolved["changeId"])
1667
1749
  if concurrency_block is not None:
1668
1750
  record_blocked_attempt(
@@ -1847,6 +1929,7 @@ def cmd_begin(args: argparse.Namespace) -> int:
1847
1929
  "event": event_result,
1848
1930
  "testGuard": guard_result,
1849
1931
  "policySchemaVersion": policy.get("schemaVersion"),
1932
+ "planVerification": plan_verification,
1850
1933
  "projection": projection,
1851
1934
  "executionRootSource": execution_hint["source"],
1852
1935
  }