@hunter-harness/workflow-harness 0.2.15 → 0.2.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.
Files changed (178) 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 +1 -1
  3. package/harness/bundles/general/claude-code/harness-codebase-map/SKILL.md +1 -1
  4. package/harness/bundles/general/claude-code/harness-knowledge-ingest/SKILL.md +1 -1
  5. package/harness/bundles/general/claude-code/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
  6. package/harness/bundles/general/claude-code/harness-knowledge-query/SKILL.md +1 -1
  7. package/harness/bundles/general/claude-code/harness-plan/SKILL.md +1 -1
  8. package/harness/bundles/general/claude-code/harness-review/SKILL.md +1 -1
  9. package/harness/bundles/general/claude-code/harness-review/reference.md +13 -0
  10. package/harness/bundles/general/claude-code/harness-run/SKILL.md +1 -1
  11. package/harness/bundles/general/claude-code/harness-submit/SKILL.md +1 -1
  12. package/harness/bundles/general/claude-code/harness-sync/SKILL.md +1 -1
  13. package/harness/bundles/general/claude-code/harness-test/SKILL.md +1 -1
  14. package/harness/bundles/general/claude-code/scripts/harness_gate.py +75 -0
  15. package/harness/bundles/general/claude-code/scripts/harness_integration.py +38 -0
  16. package/harness/bundles/general/claude-code/scripts/harness_ledger.py +70 -3
  17. package/harness/bundles/general/claude-code/scripts/harness_paths.py +17 -0
  18. package/harness/bundles/general/claude-code/scripts/harness_plan_finalize.py +147 -0
  19. package/harness/bundles/general/claude-code/scripts/harness_profile.py +58 -7
  20. package/harness/bundles/general/claude-code/scripts/harness_review.py +107 -0
  21. package/harness/bundles/general/codebuddy/.harness-build.json +1 -1
  22. package/harness/bundles/general/codebuddy/harness-archive/SKILL.md +1 -1
  23. package/harness/bundles/general/codebuddy/harness-codebase-map/SKILL.md +1 -1
  24. package/harness/bundles/general/codebuddy/harness-knowledge-ingest/SKILL.md +1 -1
  25. package/harness/bundles/general/codebuddy/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
  26. package/harness/bundles/general/codebuddy/harness-knowledge-query/SKILL.md +1 -1
  27. package/harness/bundles/general/codebuddy/harness-plan/SKILL.md +1 -1
  28. package/harness/bundles/general/codebuddy/harness-review/SKILL.md +1 -1
  29. package/harness/bundles/general/codebuddy/harness-review/reference.md +13 -0
  30. package/harness/bundles/general/codebuddy/harness-run/SKILL.md +1 -1
  31. package/harness/bundles/general/codebuddy/harness-submit/SKILL.md +1 -1
  32. package/harness/bundles/general/codebuddy/harness-sync/SKILL.md +1 -1
  33. package/harness/bundles/general/codebuddy/harness-test/SKILL.md +1 -1
  34. package/harness/bundles/general/codebuddy/scripts/harness_gate.py +75 -0
  35. package/harness/bundles/general/codebuddy/scripts/harness_integration.py +38 -0
  36. package/harness/bundles/general/codebuddy/scripts/harness_ledger.py +70 -3
  37. package/harness/bundles/general/codebuddy/scripts/harness_paths.py +17 -0
  38. package/harness/bundles/general/codebuddy/scripts/harness_plan_finalize.py +147 -0
  39. package/harness/bundles/general/codebuddy/scripts/harness_profile.py +58 -7
  40. package/harness/bundles/general/codebuddy/scripts/harness_review.py +107 -0
  41. package/harness/bundles/general/codex/.harness-build.json +1 -1
  42. package/harness/bundles/general/codex/harness-archive/SKILL.md +1 -1
  43. package/harness/bundles/general/codex/harness-codebase-map/SKILL.md +1 -1
  44. package/harness/bundles/general/codex/harness-knowledge-ingest/SKILL.md +1 -1
  45. package/harness/bundles/general/codex/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
  46. package/harness/bundles/general/codex/harness-knowledge-query/SKILL.md +1 -1
  47. package/harness/bundles/general/codex/harness-plan/SKILL.md +1 -1
  48. package/harness/bundles/general/codex/harness-review/SKILL.md +1 -1
  49. package/harness/bundles/general/codex/harness-review/reference.md +13 -0
  50. package/harness/bundles/general/codex/harness-run/SKILL.md +1 -1
  51. package/harness/bundles/general/codex/harness-submit/SKILL.md +1 -1
  52. package/harness/bundles/general/codex/harness-sync/SKILL.md +1 -1
  53. package/harness/bundles/general/codex/harness-test/SKILL.md +1 -1
  54. package/harness/bundles/general/codex/scripts/harness_gate.py +75 -0
  55. package/harness/bundles/general/codex/scripts/harness_integration.py +38 -0
  56. package/harness/bundles/general/codex/scripts/harness_ledger.py +70 -3
  57. package/harness/bundles/general/codex/scripts/harness_paths.py +17 -0
  58. package/harness/bundles/general/codex/scripts/harness_plan_finalize.py +147 -0
  59. package/harness/bundles/general/codex/scripts/harness_profile.py +58 -7
  60. package/harness/bundles/general/codex/scripts/harness_review.py +107 -0
  61. package/harness/bundles/general/cursor/.harness-build.json +1 -1
  62. package/harness/bundles/general/cursor/harness-archive/SKILL.md +1 -1
  63. package/harness/bundles/general/cursor/harness-codebase-map/SKILL.md +1 -1
  64. package/harness/bundles/general/cursor/harness-knowledge-ingest/SKILL.md +1 -1
  65. package/harness/bundles/general/cursor/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
  66. package/harness/bundles/general/cursor/harness-knowledge-query/SKILL.md +1 -1
  67. package/harness/bundles/general/cursor/harness-plan/SKILL.md +1 -1
  68. package/harness/bundles/general/cursor/harness-review/SKILL.md +1 -1
  69. package/harness/bundles/general/cursor/harness-review/reference.md +13 -0
  70. package/harness/bundles/general/cursor/harness-run/SKILL.md +1 -1
  71. package/harness/bundles/general/cursor/harness-submit/SKILL.md +1 -1
  72. package/harness/bundles/general/cursor/harness-sync/SKILL.md +1 -1
  73. package/harness/bundles/general/cursor/harness-test/SKILL.md +1 -1
  74. package/harness/bundles/general/cursor/scripts/harness_gate.py +75 -0
  75. package/harness/bundles/general/cursor/scripts/harness_integration.py +38 -0
  76. package/harness/bundles/general/cursor/scripts/harness_ledger.py +70 -3
  77. package/harness/bundles/general/cursor/scripts/harness_paths.py +17 -0
  78. package/harness/bundles/general/cursor/scripts/harness_plan_finalize.py +147 -0
  79. package/harness/bundles/general/cursor/scripts/harness_profile.py +58 -7
  80. package/harness/bundles/general/cursor/scripts/harness_review.py +107 -0
  81. package/harness/bundles/java/claude-code/.harness-build.json +1 -1
  82. package/harness/bundles/java/claude-code/harness-apidoc/SKILL.md +1 -1
  83. package/harness/bundles/java/claude-code/harness-archive/SKILL.md +1 -1
  84. package/harness/bundles/java/claude-code/harness-codebase-map/SKILL.md +1 -1
  85. package/harness/bundles/java/claude-code/harness-knowledge-ingest/SKILL.md +1 -1
  86. package/harness/bundles/java/claude-code/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
  87. package/harness/bundles/java/claude-code/harness-knowledge-query/SKILL.md +1 -1
  88. package/harness/bundles/java/claude-code/harness-package/SKILL.md +1 -1
  89. package/harness/bundles/java/claude-code/harness-plan/SKILL.md +1 -1
  90. package/harness/bundles/java/claude-code/harness-review/SKILL.md +1 -1
  91. package/harness/bundles/java/claude-code/harness-review/reference.md +13 -0
  92. package/harness/bundles/java/claude-code/harness-run/SKILL.md +1 -1
  93. package/harness/bundles/java/claude-code/harness-submit/SKILL.md +1 -1
  94. package/harness/bundles/java/claude-code/harness-sync/SKILL.md +1 -1
  95. package/harness/bundles/java/claude-code/harness-test/SKILL.md +1 -1
  96. package/harness/bundles/java/claude-code/scripts/harness_gate.py +75 -0
  97. package/harness/bundles/java/claude-code/scripts/harness_integration.py +38 -0
  98. package/harness/bundles/java/claude-code/scripts/harness_ledger.py +70 -3
  99. package/harness/bundles/java/claude-code/scripts/harness_paths.py +17 -0
  100. package/harness/bundles/java/claude-code/scripts/harness_plan_finalize.py +147 -0
  101. package/harness/bundles/java/claude-code/scripts/harness_profile.py +58 -7
  102. package/harness/bundles/java/claude-code/scripts/harness_review.py +107 -0
  103. package/harness/bundles/java/codebuddy/.harness-build.json +1 -1
  104. package/harness/bundles/java/codebuddy/harness-apidoc/SKILL.md +1 -1
  105. package/harness/bundles/java/codebuddy/harness-archive/SKILL.md +1 -1
  106. package/harness/bundles/java/codebuddy/harness-codebase-map/SKILL.md +1 -1
  107. package/harness/bundles/java/codebuddy/harness-knowledge-ingest/SKILL.md +1 -1
  108. package/harness/bundles/java/codebuddy/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
  109. package/harness/bundles/java/codebuddy/harness-knowledge-query/SKILL.md +1 -1
  110. package/harness/bundles/java/codebuddy/harness-package/SKILL.md +1 -1
  111. package/harness/bundles/java/codebuddy/harness-plan/SKILL.md +1 -1
  112. package/harness/bundles/java/codebuddy/harness-review/SKILL.md +1 -1
  113. package/harness/bundles/java/codebuddy/harness-review/reference.md +13 -0
  114. package/harness/bundles/java/codebuddy/harness-run/SKILL.md +1 -1
  115. package/harness/bundles/java/codebuddy/harness-submit/SKILL.md +1 -1
  116. package/harness/bundles/java/codebuddy/harness-sync/SKILL.md +1 -1
  117. package/harness/bundles/java/codebuddy/harness-test/SKILL.md +1 -1
  118. package/harness/bundles/java/codebuddy/scripts/harness_gate.py +75 -0
  119. package/harness/bundles/java/codebuddy/scripts/harness_integration.py +38 -0
  120. package/harness/bundles/java/codebuddy/scripts/harness_ledger.py +70 -3
  121. package/harness/bundles/java/codebuddy/scripts/harness_paths.py +17 -0
  122. package/harness/bundles/java/codebuddy/scripts/harness_plan_finalize.py +147 -0
  123. package/harness/bundles/java/codebuddy/scripts/harness_profile.py +58 -7
  124. package/harness/bundles/java/codebuddy/scripts/harness_review.py +107 -0
  125. package/harness/bundles/java/codex/.harness-build.json +1 -1
  126. package/harness/bundles/java/codex/harness-apidoc/SKILL.md +1 -1
  127. package/harness/bundles/java/codex/harness-archive/SKILL.md +1 -1
  128. package/harness/bundles/java/codex/harness-codebase-map/SKILL.md +1 -1
  129. package/harness/bundles/java/codex/harness-knowledge-ingest/SKILL.md +1 -1
  130. package/harness/bundles/java/codex/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
  131. package/harness/bundles/java/codex/harness-knowledge-query/SKILL.md +1 -1
  132. package/harness/bundles/java/codex/harness-package/SKILL.md +1 -1
  133. package/harness/bundles/java/codex/harness-plan/SKILL.md +1 -1
  134. package/harness/bundles/java/codex/harness-review/SKILL.md +1 -1
  135. package/harness/bundles/java/codex/harness-review/reference.md +13 -0
  136. package/harness/bundles/java/codex/harness-run/SKILL.md +1 -1
  137. package/harness/bundles/java/codex/harness-submit/SKILL.md +1 -1
  138. package/harness/bundles/java/codex/harness-sync/SKILL.md +1 -1
  139. package/harness/bundles/java/codex/harness-test/SKILL.md +1 -1
  140. package/harness/bundles/java/codex/scripts/harness_gate.py +75 -0
  141. package/harness/bundles/java/codex/scripts/harness_integration.py +38 -0
  142. package/harness/bundles/java/codex/scripts/harness_ledger.py +70 -3
  143. package/harness/bundles/java/codex/scripts/harness_paths.py +17 -0
  144. package/harness/bundles/java/codex/scripts/harness_plan_finalize.py +147 -0
  145. package/harness/bundles/java/codex/scripts/harness_profile.py +58 -7
  146. package/harness/bundles/java/codex/scripts/harness_review.py +107 -0
  147. package/harness/bundles/java/cursor/.harness-build.json +1 -1
  148. package/harness/bundles/java/cursor/harness-apidoc/SKILL.md +1 -1
  149. package/harness/bundles/java/cursor/harness-archive/SKILL.md +1 -1
  150. package/harness/bundles/java/cursor/harness-codebase-map/SKILL.md +1 -1
  151. package/harness/bundles/java/cursor/harness-knowledge-ingest/SKILL.md +1 -1
  152. package/harness/bundles/java/cursor/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
  153. package/harness/bundles/java/cursor/harness-knowledge-query/SKILL.md +1 -1
  154. package/harness/bundles/java/cursor/harness-package/SKILL.md +1 -1
  155. package/harness/bundles/java/cursor/harness-plan/SKILL.md +1 -1
  156. package/harness/bundles/java/cursor/harness-review/SKILL.md +1 -1
  157. package/harness/bundles/java/cursor/harness-review/reference.md +13 -0
  158. package/harness/bundles/java/cursor/harness-run/SKILL.md +1 -1
  159. package/harness/bundles/java/cursor/harness-submit/SKILL.md +1 -1
  160. package/harness/bundles/java/cursor/harness-sync/SKILL.md +1 -1
  161. package/harness/bundles/java/cursor/harness-test/SKILL.md +1 -1
  162. package/harness/bundles/java/cursor/scripts/harness_gate.py +75 -0
  163. package/harness/bundles/java/cursor/scripts/harness_integration.py +38 -0
  164. package/harness/bundles/java/cursor/scripts/harness_ledger.py +70 -3
  165. package/harness/bundles/java/cursor/scripts/harness_paths.py +17 -0
  166. package/harness/bundles/java/cursor/scripts/harness_plan_finalize.py +147 -0
  167. package/harness/bundles/java/cursor/scripts/harness_profile.py +58 -7
  168. package/harness/bundles/java/cursor/scripts/harness_review.py +107 -0
  169. package/harness/manifests/general/claude-code.json +21 -21
  170. package/harness/manifests/general/codebuddy.json +21 -21
  171. package/harness/manifests/general/codex.json +21 -21
  172. package/harness/manifests/general/cursor.json +21 -21
  173. package/harness/manifests/java/claude-code.json +23 -23
  174. package/harness/manifests/java/codebuddy.json +23 -23
  175. package/harness/manifests/java/codex.json +23 -23
  176. package/harness/manifests/java/cursor.json +23 -23
  177. package/hunter-workflow-family.json +2 -2
  178. package/package.json +1 -1
@@ -2,5 +2,5 @@
2
2
  "schemaVersion": 1,
3
3
  "overlay": "none",
4
4
  "agent": "claude-code",
5
- "coreHash": "6232f66fbf691292"
5
+ "coreHash": "21a7451404d2c0ff"
6
6
  }
@@ -20,7 +20,7 @@ disallowed-tools:
20
20
  - Bash(awk *)
21
21
  - Bash(curl *)
22
22
  ---
23
- <!-- generated by harness_deploy.py; core=8fbcf97a5a4408df; overlay=none; agent=claude-code; do not edit -->
23
+ <!-- generated by harness_deploy.py; core=21a7451404d2c0ff; overlay=none; agent=claude-code; do not edit -->
24
24
  # harness-archive — 变更归档
25
25
 
26
26
  ## Purpose
@@ -20,7 +20,7 @@ disallowed-tools:
20
20
  - Bash(awk *)
21
21
  - Bash(curl *)
22
22
  ---
23
- <!-- generated by harness_deploy.py; core=8fbcf97a5a4408df; overlay=none; agent=claude-code; do not edit -->
23
+ <!-- generated by harness_deploy.py; core=21a7451404d2c0ff; overlay=none; agent=claude-code; do not edit -->
24
24
  # harness-codebase-map — 代码库地图
25
25
 
26
26
  ## Purpose
@@ -20,7 +20,7 @@ disallowed-tools:
20
20
  - Bash(awk *)
21
21
  - Bash(curl *)
22
22
  ---
23
- <!-- generated by harness_deploy.py; core=8fbcf97a5a4408df; overlay=none; agent=claude-code; do not edit -->
23
+ <!-- generated by harness_deploy.py; core=21a7451404d2c0ff; overlay=none; agent=claude-code; do not edit -->
24
24
  # harness-knowledge-ingest
25
25
 
26
26
  从 `.harness/archive/**/reports/final/summary-data.json` 抽取项目知识,生成并维护本地 `.harness/knowledge/` 索引。
@@ -4552,6 +4552,11 @@ def main(argv: list[str] | None = None) -> int:
4552
4552
  query.add_argument("--status", action="append", dest="statuses", default=[], help="Only return entries with this lifecycle status")
4553
4553
  query.add_argument("--type", action="append", dest="types", default=[], help="Only return entries of this knowledge type")
4554
4554
  query.add_argument("--change", default=None, help="Write a change-scoped knowledge-context pointer")
4555
+ query.add_argument(
4556
+ "--verbose",
4557
+ action="store_true",
4558
+ help="Emit full payload including matches array (default: compact output for host decisioning)",
4559
+ )
4555
4560
 
4556
4561
  promote = sub.add_parser("promote", help="Promote a candidate knowledge entry to active")
4557
4562
  promote.add_argument("--project", default=".", help="Project root containing .harness/knowledge")
@@ -4652,7 +4657,17 @@ def main(argv: list[str] | None = None) -> int:
4652
4657
  Path(args.project), args.query, args.limit, args.files, args.statuses,
4653
4658
  args.types, args.change,
4654
4659
  )
4655
- print(json.dumps(result, ensure_ascii=False, indent=2))
4660
+ if getattr(args, "verbose", False):
4661
+ print(json.dumps(result, ensure_ascii=False, indent=2))
4662
+ else:
4663
+ # C5: compact output — omit matches array; host reads context pack for details.
4664
+ compact = {
4665
+ "query": result["query"],
4666
+ "matchCount": result["matchCount"],
4667
+ "contextPack": result["contextPack"],
4668
+ "planInput": result["planInput"],
4669
+ }
4670
+ print(json.dumps(compact, ensure_ascii=False, indent=2))
4656
4671
  return 0
4657
4672
  if args.command == "promote":
4658
4673
  try:
@@ -20,7 +20,7 @@ disallowed-tools:
20
20
  - Bash(awk *)
21
21
  - Bash(curl *)
22
22
  ---
23
- <!-- generated by harness_deploy.py; core=8fbcf97a5a4408df; overlay=none; agent=claude-code; do not edit -->
23
+ <!-- generated by harness_deploy.py; core=21a7451404d2c0ff; overlay=none; agent=claude-code; do not edit -->
24
24
  # harness-knowledge-query
25
25
 
26
26
  并行 change 中查询必须传 `--change <change-id>`;成功后以该 change 的 `meta/knowledge-context.json` 为稳定指针。全局 `context-packs/latest.json` 仅向后兼容,不得用于判断多个 active change 的上下文归属。
@@ -20,7 +20,7 @@ disallowed-tools:
20
20
  - Bash(awk *)
21
21
  - Bash(curl *)
22
22
  ---
23
- <!-- generated by harness_deploy.py; core=8fbcf97a5a4408df; overlay=none; agent=claude-code; do not edit -->
23
+ <!-- generated by harness_deploy.py; core=21a7451404d2c0ff; overlay=none; agent=claude-code; do not edit -->
24
24
  # harness-plan — 需求规划
25
25
 
26
26
  ## Purpose
@@ -21,7 +21,7 @@ disallowed-tools:
21
21
  - Bash(curl *)
22
22
  - Bash(codegraph *)
23
23
  ---
24
- <!-- generated by harness_deploy.py; core=8fbcf97a5a4408df; overlay=none; agent=claude-code; do not edit -->
24
+ <!-- generated by harness_deploy.py; core=21a7451404d2c0ff; overlay=none; agent=claude-code; do not edit -->
25
25
  # harness-review — 代码审查
26
26
 
27
27
  ## Purpose
@@ -84,3 +84,16 @@ RED 高风险建议: N | YELLOW 中低风险建议: M | 仅供参考,不阻塞
84
84
  ```
85
85
 
86
86
  fixback 是给后续修复循环使用的结构化清单,不替代 review-report;无 RED/YELLOW 时记录跳过原因,不生成空文件。
87
+
88
+ ## CodeGraph Identity 合同(C12)
89
+
90
+ 调用 `codegraph_explore` 后必须校验响应中的 `repositoryId` / `indexedHead` / `indexedAt`:
91
+
92
+ - `repositoryId` 必须与 `harness_paths.repository_identity(project_root)` 一致
93
+ - `indexedHead` 必须与当前 HEAD 一致
94
+ - `indexedAt` 必须存在
95
+
96
+ identity 不匹配时记 `CODEGRAPH_IDENTITY_MISMATCH` warning,降级为 Grep/Glob + Read。
97
+ identity 匹配时正常使用 codegraph 结果。
98
+
99
+ 校验函数:`harness_review.validate_codegraph_identity(response, expected_repository_id, expected_head)`。
@@ -21,7 +21,7 @@ disallowed-tools:
21
21
  - Bash(curl *)
22
22
  - Bash(codegraph *)
23
23
  ---
24
- <!-- generated by harness_deploy.py; core=8fbcf97a5a4408df; overlay=none; agent=claude-code; do not edit -->
24
+ <!-- generated by harness_deploy.py; core=21a7451404d2c0ff; overlay=none; agent=claude-code; do not edit -->
25
25
  # harness-run — 需求编码
26
26
 
27
27
  ## Purpose
@@ -20,7 +20,7 @@ disallowed-tools:
20
20
  - Bash(awk *)
21
21
  - Bash(curl *)
22
22
  ---
23
- <!-- generated by harness_deploy.py; core=8fbcf97a5a4408df; overlay=none; agent=claude-code; do not edit -->
23
+ <!-- generated by harness_deploy.py; core=21a7451404d2c0ff; overlay=none; agent=claude-code; do not edit -->
24
24
  # harness-submit — 最终提交(含 worktree 合并)
25
25
 
26
26
  ## Purpose
@@ -19,7 +19,7 @@ disallowed-tools:
19
19
  - Bash(awk *)
20
20
  - Bash(curl *)
21
21
  ---
22
- <!-- generated by harness_deploy.py; core=8fbcf97a5a4408df; overlay=none; agent=claude-code; do not edit -->
22
+ <!-- generated by harness_deploy.py; core=21a7451404d2c0ff; overlay=none; agent=claude-code; do not edit -->
23
23
  # harness-sync — 元数据同步
24
24
 
25
25
  ## Purpose
@@ -22,7 +22,7 @@ disallowed-tools:
22
22
  - Bash(node *)
23
23
  - Bash(codegraph *)
24
24
  ---
25
- <!-- generated by harness_deploy.py; core=8fbcf97a5a4408df; overlay=none; agent=claude-code; do not edit -->
25
+ <!-- generated by harness_deploy.py; core=21a7451404d2c0ff; overlay=none; agent=claude-code; do not edit -->
26
26
  # harness-test — 测试执行
27
27
 
28
28
  ## Purpose
@@ -1201,6 +1201,70 @@ def _phase_event_exists(change_dir: Path, phase: str, type_: str, run_id: str) -
1201
1201
  )
1202
1202
 
1203
1203
 
1204
+ def _validate_scenario_coverage(change_dir: Path) -> dict[str, Any]:
1205
+ """C9: validate all P0 scenarios have a ledger entry with scenarioIds covering them.
1206
+
1207
+ Reads meta/scenario-manifest.json and evidence/verification-ledger.json.
1208
+ Returns ok=True when manifest missing (backward compat) or all P0 scenarios covered.
1209
+ """
1210
+ manifest_path = change_dir / "meta" / "scenario-manifest.json"
1211
+ if not manifest_path.is_file():
1212
+ return {"ok": True, "code": "MANIFEST_MISSING", "skipped": True}
1213
+ try:
1214
+ manifest = json.loads(manifest_path.read_text(encoding="utf-8-sig"))
1215
+ except (OSError, json.JSONDecodeError) as exc:
1216
+ return {
1217
+ "ok": False,
1218
+ "code": "SCENARIO_MANIFEST_INVALID",
1219
+ "message": f"scenario-manifest.json unreadable: {exc}",
1220
+ }
1221
+ scenarios = manifest.get("scenarios") or []
1222
+ p0_ids = {
1223
+ str(s.get("id"))
1224
+ for s in scenarios
1225
+ if isinstance(s, dict)
1226
+ and str(s.get("priority", "")).upper() == "P0"
1227
+ and s.get("requiredEvidenceKind") == "ledger"
1228
+ }
1229
+ if not p0_ids:
1230
+ return {"ok": True, "code": "NO_P0_SCENARIOS"}
1231
+
1232
+ ledger_path = change_dir / "evidence" / "verification-ledger.json"
1233
+ if not ledger_path.is_file():
1234
+ return {
1235
+ "ok": False,
1236
+ "code": "SCENARIO_COVERAGE_FAILED",
1237
+ "message": "ledger missing; cannot verify P0 scenario coverage",
1238
+ "missing": sorted(p0_ids),
1239
+ }
1240
+ try:
1241
+ ledger = json.loads(ledger_path.read_text(encoding="utf-8-sig"))
1242
+ except (OSError, json.JSONDecodeError) as exc:
1243
+ return {
1244
+ "ok": False,
1245
+ "code": "SCENARIO_COVERAGE_FAILED",
1246
+ "message": f"ledger unreadable: {exc}",
1247
+ "missing": sorted(p0_ids),
1248
+ }
1249
+ covered: set[str] = set()
1250
+ validations = ledger.get("validations") or {}
1251
+ if isinstance(validations, dict):
1252
+ for entry in validations.values():
1253
+ if isinstance(entry, dict):
1254
+ ids = entry.get("scenarioIds")
1255
+ if isinstance(ids, list):
1256
+ covered.update(str(i) for i in ids)
1257
+ missing = sorted(p0_ids - covered)
1258
+ if missing:
1259
+ return {
1260
+ "ok": False,
1261
+ "code": "SCENARIO_COVERAGE_FAILED",
1262
+ "message": f"P0 scenarios without ledger entry: {', '.join(missing)}",
1263
+ "missing": missing,
1264
+ }
1265
+ return {"ok": True, "code": "SCENARIO_COVERAGE_OK", "covered": sorted(covered & p0_ids)}
1266
+
1267
+
1204
1268
  def cmd_begin(args: argparse.Namespace) -> int:
1205
1269
  as_json = bool(args.json)
1206
1270
  project = hc.resolve_main_project_root()
@@ -1470,6 +1534,17 @@ def cmd_close(args: argparse.Namespace) -> int:
1470
1534
  extra={k: v for k, v in ledger_result.items() if k not in {"ok", "message", "code"}},
1471
1535
  )
1472
1536
 
1537
+ # C9: scenario coverage check — all P0 scenarios must have a ledger entry.
1538
+ if args.phase in {"run", "test"}:
1539
+ coverage = _validate_scenario_coverage(change_dir)
1540
+ if not coverage.get("ok"):
1541
+ return emit_error(
1542
+ str(coverage.get("code", "SCENARIO_COVERAGE_FAILED")),
1543
+ str(coverage.get("message", "scenario coverage validation failed")),
1544
+ as_json=as_json,
1545
+ extra={k: v for k, v in coverage.items() if k not in {"ok", "message", "code"}},
1546
+ )
1547
+
1473
1548
  close_status = args.status
1474
1549
  close_code = "PHASE_CLOSED"
1475
1550
  if ledger_result.get("code") == "LEDGER_OK_DEGRADED":
@@ -1266,6 +1266,31 @@ def cmd_status(args: argparse.Namespace) -> int:
1266
1266
  return _emit(_txn_from_args(args).status())
1267
1267
 
1268
1268
 
1269
+ def cmd_journal(args: argparse.Namespace) -> int:
1270
+ """C5: journal 子命令 — 默认 compact (transactionId/currentStep/status),--verbose 全量。"""
1271
+ txn = _txn_from_args(args)
1272
+ full = txn.status()
1273
+ if getattr(args, "verbose", False):
1274
+ return _emit(full)
1275
+ # Derive currentStep: first non-DONE step, or last step name if all DONE.
1276
+ current_step = None
1277
+ for step in full.get("steps", []):
1278
+ if step.get("status") != "DONE":
1279
+ current_step = step.get("name")
1280
+ break
1281
+ if current_step is None and full.get("steps"):
1282
+ current_step = full["steps"][-1].get("name")
1283
+ overall_status = "DONE" if all(
1284
+ step.get("status") == "DONE" for step in full.get("steps", [])
1285
+ ) else "IN_PROGRESS"
1286
+ compact = {
1287
+ "transactionId": full.get("transactionId"),
1288
+ "currentStep": current_step,
1289
+ "status": overall_status,
1290
+ }
1291
+ return _emit(compact)
1292
+
1293
+
1269
1294
  def build_parser() -> argparse.ArgumentParser:
1270
1295
  parser = argparse.ArgumentParser(prog="harness_integration.py")
1271
1296
  sub = parser.add_subparsers(dest="command_name", required=True)
@@ -1287,6 +1312,19 @@ def build_parser() -> argparse.ArgumentParser:
1287
1312
  add("recover", cmd_recover)
1288
1313
  add("status", cmd_status)
1289
1314
 
1315
+ p_journal = sub.add_parser("journal")
1316
+ p_journal.add_argument("--change", required=True)
1317
+ p_journal.add_argument("--run-id", required=True)
1318
+ p_journal.add_argument("--target-branch", default="main")
1319
+ p_journal.add_argument("--feature-branch", required=True)
1320
+ p_journal.add_argument("--temp-root", required=True)
1321
+ p_journal.add_argument(
1322
+ "--verbose",
1323
+ action="store_true",
1324
+ help="emit full journal payload (default: compact transactionId/currentStep/status)",
1325
+ )
1326
+ p_journal.set_defaults(func=cmd_journal)
1327
+
1290
1328
  p_verify = sub.add_parser("verify")
1291
1329
  p_verify.add_argument("--change", required=True)
1292
1330
  p_verify.add_argument("--run-id", required=True)
@@ -100,6 +100,37 @@ def emit_json(payload: dict[str, Any], *, as_json: bool) -> None:
100
100
  sys.stdout.write(("ok" if ok else "error") + "\n")
101
101
 
102
102
 
103
+ def _compact_record_payload(payload: dict[str, Any]) -> dict[str, Any]:
104
+ """C5: record compact — ok/action/verification/status only."""
105
+ return {
106
+ "ok": payload.get("ok", True),
107
+ "action": payload.get("action"),
108
+ "verification": payload.get("verification"),
109
+ "status": payload.get("status"),
110
+ }
111
+
112
+
113
+ def _compact_can_reuse_payload(payload: dict[str, Any]) -> dict[str, Any]:
114
+ """C5: can-reuse compact — ok/reuse/code only."""
115
+ return {
116
+ "ok": payload.get("ok", True),
117
+ "reuse": payload.get("reuse"),
118
+ "code": payload.get("code"),
119
+ }
120
+
121
+
122
+ def emit_compact_or_verbose(
123
+ payload: dict[str, Any],
124
+ *,
125
+ as_json: bool,
126
+ verbose: bool,
127
+ compact_fn,
128
+ ) -> None:
129
+ """Emit compact payload by default; full payload when --verbose."""
130
+ out = payload if verbose else compact_fn(payload)
131
+ emit_json(out, as_json=as_json)
132
+
133
+
103
134
  def emit_error(message: str, *, as_json: bool, code: int = 1) -> int:
104
135
  payload = {"ok": False, "error": message}
105
136
  if as_json:
@@ -1227,6 +1258,7 @@ def cmd_hash(args: argparse.Namespace) -> int:
1227
1258
 
1228
1259
  def cmd_can_reuse(args: argparse.Namespace) -> int:
1229
1260
  as_json = bool(args.json)
1261
+ verbose = bool(getattr(args, "verbose", False))
1230
1262
  verification = args.verification
1231
1263
  if verification not in VERIFICATIONS:
1232
1264
  return emit_error(
@@ -1253,7 +1285,10 @@ def cmd_can_reuse(args: argparse.Namespace) -> int:
1253
1285
  "verification": verification,
1254
1286
  "detail": err,
1255
1287
  }
1256
- emit_json(payload, as_json=as_json)
1288
+ emit_compact_or_verbose(
1289
+ payload, as_json=as_json, verbose=verbose,
1290
+ compact_fn=_compact_can_reuse_payload,
1291
+ )
1257
1292
  return 0
1258
1293
  files = resolve_input_files(resolved_files, project_root)
1259
1294
  if not files:
@@ -1275,12 +1310,16 @@ def cmd_can_reuse(args: argparse.Namespace) -> int:
1275
1310
  except (OSError, ValueError, json.JSONDecodeError) as exc:
1276
1311
  return emit_error(f"can-reuse failed: {exc}", as_json=as_json)
1277
1312
 
1278
- emit_json(payload, as_json=as_json)
1313
+ emit_compact_or_verbose(
1314
+ payload, as_json=as_json, verbose=verbose,
1315
+ compact_fn=_compact_can_reuse_payload,
1316
+ )
1279
1317
  return 0
1280
1318
 
1281
1319
 
1282
1320
  def cmd_record(args: argparse.Namespace) -> int:
1283
1321
  as_json = bool(args.json)
1322
+ verbose = bool(getattr(args, "verbose", False))
1284
1323
  change_dir = resolve_path(args.change_dir)
1285
1324
  verification = args.verification
1286
1325
  if verification not in VERIFICATIONS:
@@ -1421,6 +1460,16 @@ def cmd_record(args: argparse.Namespace) -> int:
1421
1460
  if _nonempty_str(getattr(args, "tests_reused_from", None)):
1422
1461
  entry["testsReusedFrom"] = str(args.tests_reused_from).strip()
1423
1462
 
1463
+ # C9: bind scenario IDs from --scenario-ids to this ledger entry.
1464
+ scenario_ids_raw = getattr(args, "scenario_ids", None)
1465
+ if _nonempty_str(scenario_ids_raw):
1466
+ ids = [s.strip() for s in str(scenario_ids_raw).split(",") if s.strip()]
1467
+ if ids:
1468
+ entry["scenarioIds"] = ids
1469
+ elif "scenarioIds" in entry:
1470
+ # Fresh record without scenario-ids must not keep stale ids from prev.
1471
+ entry.pop("scenarioIds", None)
1472
+
1424
1473
  ledger["validations"][verification] = entry
1425
1474
  if "changeName" not in ledger:
1426
1475
  ledger["changeName"] = change_dir.name
@@ -1487,7 +1536,10 @@ def cmd_record(args: argparse.Namespace) -> int:
1487
1536
  "diffHash": ledger.get("diffHash"),
1488
1537
  "resolvedProjectRoot": str(project_root) if project_root else None,
1489
1538
  }
1490
- emit_json(payload, as_json=as_json)
1539
+ emit_compact_or_verbose(
1540
+ payload, as_json=as_json, verbose=verbose,
1541
+ compact_fn=_compact_record_payload,
1542
+ )
1491
1543
  return 0
1492
1544
 
1493
1545
 
@@ -1589,6 +1641,11 @@ def build_parser() -> argparse.ArgumentParser:
1589
1641
  default=None,
1590
1642
  help="optional environment hash to compare against ledger entry (UT-017)",
1591
1643
  )
1644
+ p_reuse.add_argument(
1645
+ "--verbose",
1646
+ action="store_true",
1647
+ help="emit full payload (default: compact ok/reuse/code)",
1648
+ )
1592
1649
  p_reuse.set_defaults(func=cmd_can_reuse)
1593
1650
 
1594
1651
  p_record = sub.add_parser("record", parents=[shared_json], help="write validation result into ledger")
@@ -1669,6 +1726,16 @@ def build_parser() -> argparse.ArgumentParser:
1669
1726
  default=None,
1670
1727
  help="ledger v3: scope reason (required when --applicability NOT_APPLICABLE)",
1671
1728
  )
1729
+ p_record.add_argument(
1730
+ "--scenario-ids",
1731
+ default=None,
1732
+ help="comma-separated scenario IDs from scenario-manifest.json to bind to this entry",
1733
+ )
1734
+ p_record.add_argument(
1735
+ "--verbose",
1736
+ action="store_true",
1737
+ help="emit full payload (default: compact ok/action/verification/status)",
1738
+ )
1672
1739
  p_record.set_defaults(func=cmd_record)
1673
1740
 
1674
1741
  p_diff = sub.add_parser(
@@ -83,6 +83,23 @@ def _git_common_dir(cwd: Path) -> Path | None:
83
83
  return common
84
84
 
85
85
 
86
+ def common_root(project_root: Path) -> Path:
87
+ """Resolve the shared "common" root for a project.
88
+
89
+ For a linked worktree, ``git rev-parse --git-common-dir`` points at the
90
+ main repository's ``.git`` directory; its parent is the main project root.
91
+ For the main worktree, the common dir is ``<root>/.git`` so the parent is
92
+ the project root itself. Falls back to the resolved input when not in a
93
+ git repo (e.g. exploratory scratch dirs).
94
+ """
95
+ cwd = Path(project_root).resolve()
96
+ common = _git_common_dir(cwd)
97
+ if common is None:
98
+ return cwd
99
+ # common dir is <root>/.git — its parent is the main project root.
100
+ return common.parent.resolve()
101
+
102
+
86
103
  def _root_commit(cwd: Path) -> str | None:
87
104
  raw = _git_text(cwd, "rev-list", "--max-parents=0", "HEAD")
88
105
  if not raw:
@@ -30,11 +30,117 @@ if hasattr(sys.stderr, "reconfigure"):
30
30
  SCHEMA_VERSION = 1
31
31
  _LINK = re.compile(r"\[[^\]]+\]\(([^)]+)\)")
32
32
 
33
+ # C8: valid ownerPhase values (lifecycle phases that can own tasks).
34
+ VALID_OWNER_PHASES = {"plan", "run", "test", "review", "submit"}
35
+
36
+ # C9: map scenario priority to required evidence kind.
37
+ PRIORITY_EVIDENCE_KIND = {
38
+ "P0": "ledger",
39
+ "P1": "ledger",
40
+ "P2": "advisory",
41
+ }
42
+
33
43
 
34
44
  def _result_error(code: str, message: str) -> dict[str, Any]:
35
45
  return {"ok": False, "code": code, "error": message}
36
46
 
37
47
 
48
+ def parse_test_scenarios(scenarios_path: Path) -> list[dict[str, str]]:
49
+ """C9: parse test-scenarios.md tables, extracting scenario rows.
50
+
51
+ Returns a list of dicts with keys: id / priority / scenario / verification /
52
+ ownerPhase / requiredEvidenceKind (last one derived from priority).
53
+ """
54
+ text = Path(scenarios_path).read_text(encoding="utf-8-sig")
55
+ lines = text.splitlines()
56
+ scenarios: list[dict[str, str]] = []
57
+ # Find all tables whose header includes "ID" and "优先级" (or "priority").
58
+ i = 0
59
+ while i < len(lines):
60
+ line = lines[i].strip()
61
+ if line.startswith("|") and "ID" in line and ("优先级" in line or "priority" in line):
62
+ header_line = line
63
+ headers = [h.strip() for h in header_line.strip("|").split("|")]
64
+ col_map: dict[str, int] = {}
65
+ for idx, name in enumerate(headers):
66
+ key = name.lower()
67
+ col_map[key] = idx
68
+ # Skip separator row
69
+ i += 2
70
+ while i < len(lines):
71
+ row = lines[i].strip()
72
+ if not row.startswith("|"):
73
+ break
74
+ cells = [c.strip() for c in row.strip("|").split("|")]
75
+ if len(cells) < len(headers):
76
+ i += 1
77
+ continue
78
+ scenario: dict[str, str] = {}
79
+ for cn, en in (
80
+ ("ID", "id"),
81
+ ("优先级", "priority"),
82
+ ("场景", "scenario"),
83
+ ("验证方式", "verification"),
84
+ ("owner phase", "ownerPhase"),
85
+ ):
86
+ if cn.lower() in col_map:
87
+ scenario[en] = cells[col_map[cn.lower()]]
88
+ # Derive requiredEvidenceKind from priority
89
+ priority = scenario.get("priority", "")
90
+ scenario["requiredEvidenceKind"] = PRIORITY_EVIDENCE_KIND.get(priority, "advisory")
91
+ scenarios.append(scenario)
92
+ i += 1
93
+ continue
94
+ i += 1
95
+ return scenarios
96
+
97
+
98
+ def parse_plan_tasks(plan_path: Path) -> list[dict[str, str]]:
99
+ """C8: parse plan.md task table rows, extracting optional ownerPhase/implementationDoneWhen/verificationPhase columns.
100
+
101
+ Returns a list of dicts with keys: # / 簇 / 任务 / ownerPhase / implementationDoneWhen /
102
+ verificationPhase / requiresExplicitAuthority (last four optional, only present when
103
+ the column header includes them).
104
+ """
105
+ text = Path(plan_path).read_text(encoding="utf-8-sig")
106
+ lines = text.splitlines()
107
+ # Find the task table: a header row starting with "| #" followed by a separator row.
108
+ header_idx = -1
109
+ for i, line in enumerate(lines):
110
+ stripped = line.strip()
111
+ if stripped.startswith("|") and "#" in stripped and "任务" in stripped:
112
+ header_idx = i
113
+ break
114
+ if header_idx < 0:
115
+ return []
116
+ header_line = lines[header_idx]
117
+ headers = [h.strip() for h in header_line.strip().strip("|").split("|")]
118
+ # Map header names to column indices (case-insensitive, English keys).
119
+ col_map: dict[str, int] = {}
120
+ for idx, name in enumerate(headers):
121
+ key = name.lower()
122
+ col_map[key] = idx
123
+ tasks: list[dict[str, str]] = []
124
+ for line in lines[header_idx + 2 :]: # skip header + separator
125
+ stripped = line.strip()
126
+ if not stripped.startswith("|"):
127
+ break # end of table
128
+ cells = [c.strip() for c in stripped.strip("|").split("|")]
129
+ if len(cells) < len(headers):
130
+ continue
131
+ task: dict[str, str] = {}
132
+ # Chinese headers
133
+ for cn, en in (("#", "num"), ("簇", "cluster"), ("任务", "task")):
134
+ if cn in col_map:
135
+ task[en] = cells[col_map[cn]]
136
+ # English optional columns
137
+ for en in ("ownerPhase", "implementationDoneWhen", "verificationPhase", "requiresExplicitAuthority"):
138
+ if en.lower() in col_map:
139
+ task[en] = cells[col_map[en.lower()]]
140
+ tasks.append(task)
141
+ return tasks
142
+
143
+
38
144
  def _atomic_write_json(path: Path, payload: dict[str, Any]) -> None:
39
145
  path.parent.mkdir(parents=True, exist_ok=True)
40
146
  fd, raw_tmp = tempfile.mkstemp(
@@ -146,6 +252,21 @@ def validate_staging(staging: Path, change_name: str) -> dict[str, Any]:
146
252
  f"{rel.as_posix()}: missing reference {raw_link}",
147
253
  )
148
254
 
255
+ # C8: validate ownerPhase values in plan.md task table.
256
+ plan_path = staging / "plans" / f"{change_name}-plan.md"
257
+ tasks = parse_plan_tasks(plan_path)
258
+ for task in tasks:
259
+ owner = task.get("ownerPhase")
260
+ if owner is not None and owner != "" and owner not in VALID_OWNER_PHASES:
261
+ return _result_error(
262
+ "PLAN_OWNER_PHASE_INVALID",
263
+ f"task {task.get('num', '?')}: ownerPhase '{owner}' not in {sorted(VALID_OWNER_PHASES)}",
264
+ )
265
+
266
+ # C9: parse test-scenarios.md for scenario manifest.
267
+ scenarios_path = staging / "plans" / f"{change_name}-test-scenarios.md"
268
+ scenarios = parse_test_scenarios(scenarios_path)
269
+
149
270
  digest = hashlib.sha256()
150
271
  artifact_names: list[str] = []
151
272
  for path in files:
@@ -159,6 +280,8 @@ def validate_staging(staging: Path, change_name: str) -> dict[str, Any]:
159
280
  "ok": True,
160
281
  "files": artifact_names,
161
282
  "artifactsHash": "sha256:" + digest.hexdigest(),
283
+ "tasks": tasks,
284
+ "scenarios": scenarios,
162
285
  }
163
286
 
164
287
 
@@ -367,6 +490,30 @@ def finalize_plan(
367
490
  finally:
368
491
  tmp.unlink(missing_ok=True)
369
492
 
493
+ # C8: write implementation-checkpoints.json with parsed task ownerPhase.
494
+ tasks = validation.get("tasks") or []
495
+ if tasks:
496
+ checkpoints_path = change_dir / "meta" / "implementation-checkpoints.json"
497
+ checkpoints_payload = {
498
+ "schemaVersion": 1,
499
+ "changeName": change_name,
500
+ "tasks": tasks,
501
+ "foundationGate": "approved",
502
+ }
503
+ _atomic_write_json(checkpoints_path, checkpoints_payload)
504
+ created.append(checkpoints_path)
505
+
506
+ # C9: write scenario-manifest.json with parsed scenarios.
507
+ scenarios = validation.get("scenarios") or []
508
+ manifest_path = change_dir / "meta" / "scenario-manifest.json"
509
+ manifest_payload = {
510
+ "schemaVersion": 1,
511
+ "changeName": change_name,
512
+ "scenarios": scenarios,
513
+ }
514
+ _atomic_write_json(manifest_path, manifest_payload)
515
+ created.append(manifest_path)
516
+
370
517
  pending_receipt = {
371
518
  "schemaVersion": SCHEMA_VERSION,
372
519
  "changeName": change_name,