@bonesofspring/ai-rules 0.2.41 → 0.2.42

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 (381) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +1 -1
  3. package/presets/_shared/ai-local/scripts/derive-gate-signals.mjs +7 -0
  4. package/presets/_shared/core/agent-team/agent-artifact-contracts.md +1 -0
  5. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +62 -5
  6. package/presets/claude/android-kotlin/agents/ci-investigator.md +1 -1
  7. package/presets/claude/android-kotlin/agents/debugger.md +1 -1
  8. package/presets/claude/android-kotlin/agents/feature-developer.md +1 -1
  9. package/presets/claude/android-kotlin/agents/migration-specialist.md +1 -1
  10. package/presets/claude/android-kotlin/agents/performance-auditor.md +1 -1
  11. package/presets/claude/android-kotlin/agents/qa-tester.md +1 -1
  12. package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
  13. package/presets/claude/android-kotlin/agents/task-router.md +1 -1
  14. package/presets/claude/android-kotlin/agents/tech-writer.md +1 -1
  15. package/presets/claude/android-kotlin/agents/unit-test-generator.md +1 -1
  16. package/presets/claude/android-kotlin/agents/unit-test-healer.md +1 -1
  17. package/presets/claude/android-kotlin/agents/unit-test-planner.md +1 -1
  18. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +62 -5
  19. package/presets/claude/android-kotlin/team/README.md +1 -1
  20. package/presets/claude/go/agents/feature-developer.md +1 -1
  21. package/presets/claude/go/agents/task-analyst.md +1 -1
  22. package/presets/claude/go/agents/task-router.md +1 -1
  23. package/presets/claude/go/hooks/chain-team-phases.sh +62 -5
  24. package/presets/claude/go/team/README.md +1 -1
  25. package/presets/claude/ios-swift/agents/feature-developer.md +1 -1
  26. package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
  27. package/presets/claude/ios-swift/agents/task-router.md +1 -1
  28. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +62 -5
  29. package/presets/claude/ios-swift/team/README.md +1 -1
  30. package/presets/claude/java/agents/feature-developer.md +1 -1
  31. package/presets/claude/java/agents/task-analyst.md +1 -1
  32. package/presets/claude/java/agents/task-router.md +1 -1
  33. package/presets/claude/java/hooks/chain-team-phases.sh +62 -5
  34. package/presets/claude/java/team/README.md +1 -1
  35. package/presets/claude/mcp-ts/agents/feature-developer.md +1 -1
  36. package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
  37. package/presets/claude/mcp-ts/agents/task-router.md +1 -1
  38. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +62 -5
  39. package/presets/claude/mcp-ts/team/README.md +1 -1
  40. package/presets/claude/next/agents/ci-investigator.md +1 -1
  41. package/presets/claude/next/agents/debugger.md +1 -1
  42. package/presets/claude/next/agents/feature-developer.md +1 -1
  43. package/presets/claude/next/agents/migration-specialist.md +1 -1
  44. package/presets/claude/next/agents/performance-auditor.md +1 -1
  45. package/presets/claude/next/agents/qa-tester.md +1 -1
  46. package/presets/claude/next/agents/solution-architect.md +1 -1
  47. package/presets/claude/next/agents/task-analyst.md +1 -1
  48. package/presets/claude/next/agents/task-router.md +1 -1
  49. package/presets/claude/next/agents/tech-writer.md +1 -1
  50. package/presets/claude/next/agents/unit-test-generator.md +1 -1
  51. package/presets/claude/next/agents/unit-test-healer.md +1 -1
  52. package/presets/claude/next/agents/unit-test-planner.md +1 -1
  53. package/presets/claude/next/hooks/chain-team-phases.sh +62 -5
  54. package/presets/claude/next/team/README.md +1 -1
  55. package/presets/claude/nuxt/agents/ci-investigator.md +1 -1
  56. package/presets/claude/nuxt/agents/debugger.md +1 -1
  57. package/presets/claude/nuxt/agents/feature-developer.md +1 -1
  58. package/presets/claude/nuxt/agents/migration-specialist.md +1 -1
  59. package/presets/claude/nuxt/agents/performance-auditor.md +1 -1
  60. package/presets/claude/nuxt/agents/qa-tester.md +1 -1
  61. package/presets/claude/nuxt/agents/solution-architect.md +1 -1
  62. package/presets/claude/nuxt/agents/task-analyst.md +1 -1
  63. package/presets/claude/nuxt/agents/task-router.md +1 -1
  64. package/presets/claude/nuxt/agents/tech-writer.md +1 -1
  65. package/presets/claude/nuxt/agents/unit-test-generator.md +1 -1
  66. package/presets/claude/nuxt/agents/unit-test-healer.md +1 -1
  67. package/presets/claude/nuxt/agents/unit-test-planner.md +1 -1
  68. package/presets/claude/nuxt/hooks/chain-team-phases.sh +62 -5
  69. package/presets/claude/nuxt/team/README.md +1 -1
  70. package/presets/claude/php-hexagonal/agents/feature-developer.md +1 -1
  71. package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
  72. package/presets/claude/php-hexagonal/agents/task-router.md +1 -1
  73. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +62 -5
  74. package/presets/claude/php-hexagonal/team/README.md +1 -1
  75. package/presets/claude/php-laravel/agents/feature-developer.md +1 -1
  76. package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
  77. package/presets/claude/php-laravel/agents/task-router.md +1 -1
  78. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +62 -5
  79. package/presets/claude/php-laravel/team/README.md +1 -1
  80. package/presets/claude/svelte/agents/ci-investigator.md +1 -1
  81. package/presets/claude/svelte/agents/debugger.md +1 -1
  82. package/presets/claude/svelte/agents/feature-developer.md +1 -1
  83. package/presets/claude/svelte/agents/migration-specialist.md +1 -1
  84. package/presets/claude/svelte/agents/performance-auditor.md +1 -1
  85. package/presets/claude/svelte/agents/qa-tester.md +1 -1
  86. package/presets/claude/svelte/agents/solution-architect.md +1 -1
  87. package/presets/claude/svelte/agents/task-analyst.md +1 -1
  88. package/presets/claude/svelte/agents/task-router.md +1 -1
  89. package/presets/claude/svelte/agents/tech-writer.md +1 -1
  90. package/presets/claude/svelte/agents/unit-test-generator.md +1 -1
  91. package/presets/claude/svelte/agents/unit-test-healer.md +1 -1
  92. package/presets/claude/svelte/agents/unit-test-planner.md +1 -1
  93. package/presets/claude/svelte/hooks/chain-team-phases.sh +62 -5
  94. package/presets/claude/svelte/team/README.md +1 -1
  95. package/presets/cursor/android-kotlin/agents/ci-investigator.md +1 -1
  96. package/presets/cursor/android-kotlin/agents/debugger.md +1 -1
  97. package/presets/cursor/android-kotlin/agents/feature-developer.md +1 -1
  98. package/presets/cursor/android-kotlin/agents/migration-specialist.md +1 -1
  99. package/presets/cursor/android-kotlin/agents/performance-auditor.md +1 -1
  100. package/presets/cursor/android-kotlin/agents/qa-tester.md +1 -1
  101. package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
  102. package/presets/cursor/android-kotlin/agents/task-router.md +1 -1
  103. package/presets/cursor/android-kotlin/agents/tech-writer.md +1 -1
  104. package/presets/cursor/android-kotlin/agents/unit-test-generator.md +1 -1
  105. package/presets/cursor/android-kotlin/agents/unit-test-healer.md +1 -1
  106. package/presets/cursor/android-kotlin/agents/unit-test-planner.md +1 -1
  107. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +62 -5
  108. package/presets/cursor/android-kotlin/team/README.md +1 -1
  109. package/presets/cursor/go/agents/feature-developer.md +1 -1
  110. package/presets/cursor/go/agents/task-analyst.md +1 -1
  111. package/presets/cursor/go/agents/task-router.md +1 -1
  112. package/presets/cursor/go/hooks/chain-team-phases.sh +62 -5
  113. package/presets/cursor/go/team/README.md +1 -1
  114. package/presets/cursor/ios-swift/agents/feature-developer.md +1 -1
  115. package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
  116. package/presets/cursor/ios-swift/agents/task-router.md +1 -1
  117. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +62 -5
  118. package/presets/cursor/ios-swift/team/README.md +1 -1
  119. package/presets/cursor/java/agents/feature-developer.md +1 -1
  120. package/presets/cursor/java/agents/task-analyst.md +1 -1
  121. package/presets/cursor/java/agents/task-router.md +1 -1
  122. package/presets/cursor/java/hooks/chain-team-phases.sh +62 -5
  123. package/presets/cursor/java/team/README.md +1 -1
  124. package/presets/cursor/mcp-ts/agents/feature-developer.md +1 -1
  125. package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
  126. package/presets/cursor/mcp-ts/agents/task-router.md +1 -1
  127. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +62 -5
  128. package/presets/cursor/mcp-ts/team/README.md +1 -1
  129. package/presets/cursor/next/agents/ci-investigator.md +1 -1
  130. package/presets/cursor/next/agents/debugger.md +1 -1
  131. package/presets/cursor/next/agents/feature-developer.md +1 -1
  132. package/presets/cursor/next/agents/migration-specialist.md +1 -1
  133. package/presets/cursor/next/agents/performance-auditor.md +1 -1
  134. package/presets/cursor/next/agents/qa-tester.md +1 -1
  135. package/presets/cursor/next/agents/solution-architect.md +1 -1
  136. package/presets/cursor/next/agents/task-analyst.md +1 -1
  137. package/presets/cursor/next/agents/task-router.md +1 -1
  138. package/presets/cursor/next/agents/tech-writer.md +1 -1
  139. package/presets/cursor/next/agents/unit-test-generator.md +1 -1
  140. package/presets/cursor/next/agents/unit-test-healer.md +1 -1
  141. package/presets/cursor/next/agents/unit-test-planner.md +1 -1
  142. package/presets/cursor/next/hooks/chain-team-phases.sh +62 -5
  143. package/presets/cursor/next/team/README.md +1 -1
  144. package/presets/cursor/nuxt/agents/ci-investigator.md +1 -1
  145. package/presets/cursor/nuxt/agents/debugger.md +1 -1
  146. package/presets/cursor/nuxt/agents/feature-developer.md +1 -1
  147. package/presets/cursor/nuxt/agents/migration-specialist.md +1 -1
  148. package/presets/cursor/nuxt/agents/performance-auditor.md +1 -1
  149. package/presets/cursor/nuxt/agents/qa-tester.md +1 -1
  150. package/presets/cursor/nuxt/agents/solution-architect.md +1 -1
  151. package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
  152. package/presets/cursor/nuxt/agents/task-router.md +1 -1
  153. package/presets/cursor/nuxt/agents/tech-writer.md +1 -1
  154. package/presets/cursor/nuxt/agents/unit-test-generator.md +1 -1
  155. package/presets/cursor/nuxt/agents/unit-test-healer.md +1 -1
  156. package/presets/cursor/nuxt/agents/unit-test-planner.md +1 -1
  157. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +62 -5
  158. package/presets/cursor/nuxt/team/README.md +1 -1
  159. package/presets/cursor/php-hexagonal/agents/feature-developer.md +1 -1
  160. package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
  161. package/presets/cursor/php-hexagonal/agents/task-router.md +1 -1
  162. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +62 -5
  163. package/presets/cursor/php-hexagonal/team/README.md +1 -1
  164. package/presets/cursor/php-laravel/agents/feature-developer.md +1 -1
  165. package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
  166. package/presets/cursor/php-laravel/agents/task-router.md +1 -1
  167. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +62 -5
  168. package/presets/cursor/php-laravel/team/README.md +1 -1
  169. package/presets/cursor/svelte/agents/ci-investigator.md +1 -1
  170. package/presets/cursor/svelte/agents/debugger.md +1 -1
  171. package/presets/cursor/svelte/agents/feature-developer.md +1 -1
  172. package/presets/cursor/svelte/agents/migration-specialist.md +1 -1
  173. package/presets/cursor/svelte/agents/performance-auditor.md +1 -1
  174. package/presets/cursor/svelte/agents/qa-tester.md +1 -1
  175. package/presets/cursor/svelte/agents/solution-architect.md +1 -1
  176. package/presets/cursor/svelte/agents/task-analyst.md +1 -1
  177. package/presets/cursor/svelte/agents/task-router.md +1 -1
  178. package/presets/cursor/svelte/agents/tech-writer.md +1 -1
  179. package/presets/cursor/svelte/agents/unit-test-generator.md +1 -1
  180. package/presets/cursor/svelte/agents/unit-test-healer.md +1 -1
  181. package/presets/cursor/svelte/agents/unit-test-planner.md +1 -1
  182. package/presets/cursor/svelte/hooks/chain-team-phases.sh +62 -5
  183. package/presets/cursor/svelte/team/README.md +1 -1
  184. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  185. package/presets/mavis/android-kotlin/agents/ci-investigator.md +1 -1
  186. package/presets/mavis/android-kotlin/agents/debugger.md +1 -1
  187. package/presets/mavis/android-kotlin/agents/feature-developer.md +1 -1
  188. package/presets/mavis/android-kotlin/agents/migration-specialist.md +1 -1
  189. package/presets/mavis/android-kotlin/agents/performance-auditor.md +1 -1
  190. package/presets/mavis/android-kotlin/agents/qa-tester.md +1 -1
  191. package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
  192. package/presets/mavis/android-kotlin/agents/task-router.md +1 -1
  193. package/presets/mavis/android-kotlin/agents/tech-writer.md +1 -1
  194. package/presets/mavis/android-kotlin/agents/unit-test-generator.md +1 -1
  195. package/presets/mavis/android-kotlin/agents/unit-test-healer.md +1 -1
  196. package/presets/mavis/android-kotlin/agents/unit-test-planner.md +1 -1
  197. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +62 -5
  198. package/presets/mavis/android-kotlin/team/README.md +1 -1
  199. package/presets/mavis/go/adapter-map.json +1 -1
  200. package/presets/mavis/go/agents/feature-developer.md +1 -1
  201. package/presets/mavis/go/agents/task-analyst.md +1 -1
  202. package/presets/mavis/go/agents/task-router.md +1 -1
  203. package/presets/mavis/go/hooks/chain-team-phases.sh +62 -5
  204. package/presets/mavis/go/team/README.md +1 -1
  205. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  206. package/presets/mavis/ios-swift/agents/feature-developer.md +1 -1
  207. package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
  208. package/presets/mavis/ios-swift/agents/task-router.md +1 -1
  209. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +62 -5
  210. package/presets/mavis/ios-swift/team/README.md +1 -1
  211. package/presets/mavis/java/adapter-map.json +1 -1
  212. package/presets/mavis/java/agents/feature-developer.md +1 -1
  213. package/presets/mavis/java/agents/task-analyst.md +1 -1
  214. package/presets/mavis/java/agents/task-router.md +1 -1
  215. package/presets/mavis/java/hooks/chain-team-phases.sh +62 -5
  216. package/presets/mavis/java/team/README.md +1 -1
  217. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  218. package/presets/mavis/mcp-ts/agents/feature-developer.md +1 -1
  219. package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
  220. package/presets/mavis/mcp-ts/agents/task-router.md +1 -1
  221. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +62 -5
  222. package/presets/mavis/mcp-ts/team/README.md +1 -1
  223. package/presets/mavis/next/adapter-map.json +1 -1
  224. package/presets/mavis/next/agents/ci-investigator.md +1 -1
  225. package/presets/mavis/next/agents/debugger.md +1 -1
  226. package/presets/mavis/next/agents/feature-developer.md +1 -1
  227. package/presets/mavis/next/agents/migration-specialist.md +1 -1
  228. package/presets/mavis/next/agents/performance-auditor.md +1 -1
  229. package/presets/mavis/next/agents/qa-tester.md +1 -1
  230. package/presets/mavis/next/agents/solution-architect.md +1 -1
  231. package/presets/mavis/next/agents/task-analyst.md +1 -1
  232. package/presets/mavis/next/agents/task-router.md +1 -1
  233. package/presets/mavis/next/agents/tech-writer.md +1 -1
  234. package/presets/mavis/next/agents/unit-test-generator.md +1 -1
  235. package/presets/mavis/next/agents/unit-test-healer.md +1 -1
  236. package/presets/mavis/next/agents/unit-test-planner.md +1 -1
  237. package/presets/mavis/next/hooks/chain-team-phases.sh +62 -5
  238. package/presets/mavis/next/team/README.md +1 -1
  239. package/presets/mavis/nuxt/adapter-map.json +1 -1
  240. package/presets/mavis/nuxt/agents/ci-investigator.md +1 -1
  241. package/presets/mavis/nuxt/agents/debugger.md +1 -1
  242. package/presets/mavis/nuxt/agents/feature-developer.md +1 -1
  243. package/presets/mavis/nuxt/agents/migration-specialist.md +1 -1
  244. package/presets/mavis/nuxt/agents/performance-auditor.md +1 -1
  245. package/presets/mavis/nuxt/agents/qa-tester.md +1 -1
  246. package/presets/mavis/nuxt/agents/solution-architect.md +1 -1
  247. package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
  248. package/presets/mavis/nuxt/agents/task-router.md +1 -1
  249. package/presets/mavis/nuxt/agents/tech-writer.md +1 -1
  250. package/presets/mavis/nuxt/agents/unit-test-generator.md +1 -1
  251. package/presets/mavis/nuxt/agents/unit-test-healer.md +1 -1
  252. package/presets/mavis/nuxt/agents/unit-test-planner.md +1 -1
  253. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +62 -5
  254. package/presets/mavis/nuxt/team/README.md +1 -1
  255. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  256. package/presets/mavis/php-hexagonal/agents/feature-developer.md +1 -1
  257. package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
  258. package/presets/mavis/php-hexagonal/agents/task-router.md +1 -1
  259. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +62 -5
  260. package/presets/mavis/php-hexagonal/team/README.md +1 -1
  261. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  262. package/presets/mavis/php-laravel/agents/feature-developer.md +1 -1
  263. package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
  264. package/presets/mavis/php-laravel/agents/task-router.md +1 -1
  265. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +62 -5
  266. package/presets/mavis/php-laravel/team/README.md +1 -1
  267. package/presets/mavis/svelte/adapter-map.json +1 -1
  268. package/presets/mavis/svelte/agents/ci-investigator.md +1 -1
  269. package/presets/mavis/svelte/agents/debugger.md +1 -1
  270. package/presets/mavis/svelte/agents/feature-developer.md +1 -1
  271. package/presets/mavis/svelte/agents/migration-specialist.md +1 -1
  272. package/presets/mavis/svelte/agents/performance-auditor.md +1 -1
  273. package/presets/mavis/svelte/agents/qa-tester.md +1 -1
  274. package/presets/mavis/svelte/agents/solution-architect.md +1 -1
  275. package/presets/mavis/svelte/agents/task-analyst.md +1 -1
  276. package/presets/mavis/svelte/agents/task-router.md +1 -1
  277. package/presets/mavis/svelte/agents/tech-writer.md +1 -1
  278. package/presets/mavis/svelte/agents/unit-test-generator.md +1 -1
  279. package/presets/mavis/svelte/agents/unit-test-healer.md +1 -1
  280. package/presets/mavis/svelte/agents/unit-test-planner.md +1 -1
  281. package/presets/mavis/svelte/hooks/chain-team-phases.sh +62 -5
  282. package/presets/mavis/svelte/team/README.md +1 -1
  283. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  284. package/presets/opencode/android-kotlin/agents/ci-investigator.md +1 -1
  285. package/presets/opencode/android-kotlin/agents/debugger.md +1 -1
  286. package/presets/opencode/android-kotlin/agents/feature-developer.md +1 -1
  287. package/presets/opencode/android-kotlin/agents/migration-specialist.md +1 -1
  288. package/presets/opencode/android-kotlin/agents/performance-auditor.md +1 -1
  289. package/presets/opencode/android-kotlin/agents/qa-tester.md +1 -1
  290. package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
  291. package/presets/opencode/android-kotlin/agents/task-router.md +1 -1
  292. package/presets/opencode/android-kotlin/agents/tech-writer.md +1 -1
  293. package/presets/opencode/android-kotlin/agents/unit-test-generator.md +1 -1
  294. package/presets/opencode/android-kotlin/agents/unit-test-healer.md +1 -1
  295. package/presets/opencode/android-kotlin/agents/unit-test-planner.md +1 -1
  296. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +62 -5
  297. package/presets/opencode/android-kotlin/team/README.md +1 -1
  298. package/presets/opencode/go/adapter-map.json +1 -1
  299. package/presets/opencode/go/agents/feature-developer.md +1 -1
  300. package/presets/opencode/go/agents/task-analyst.md +1 -1
  301. package/presets/opencode/go/agents/task-router.md +1 -1
  302. package/presets/opencode/go/hooks/chain-team-phases.sh +62 -5
  303. package/presets/opencode/go/team/README.md +1 -1
  304. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  305. package/presets/opencode/ios-swift/agents/feature-developer.md +1 -1
  306. package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
  307. package/presets/opencode/ios-swift/agents/task-router.md +1 -1
  308. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +62 -5
  309. package/presets/opencode/ios-swift/team/README.md +1 -1
  310. package/presets/opencode/java/adapter-map.json +1 -1
  311. package/presets/opencode/java/agents/feature-developer.md +1 -1
  312. package/presets/opencode/java/agents/task-analyst.md +1 -1
  313. package/presets/opencode/java/agents/task-router.md +1 -1
  314. package/presets/opencode/java/hooks/chain-team-phases.sh +62 -5
  315. package/presets/opencode/java/team/README.md +1 -1
  316. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  317. package/presets/opencode/mcp-ts/agents/feature-developer.md +1 -1
  318. package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
  319. package/presets/opencode/mcp-ts/agents/task-router.md +1 -1
  320. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +62 -5
  321. package/presets/opencode/mcp-ts/team/README.md +1 -1
  322. package/presets/opencode/next/adapter-map.json +1 -1
  323. package/presets/opencode/next/agents/ci-investigator.md +1 -1
  324. package/presets/opencode/next/agents/debugger.md +1 -1
  325. package/presets/opencode/next/agents/feature-developer.md +1 -1
  326. package/presets/opencode/next/agents/migration-specialist.md +1 -1
  327. package/presets/opencode/next/agents/performance-auditor.md +1 -1
  328. package/presets/opencode/next/agents/qa-tester.md +1 -1
  329. package/presets/opencode/next/agents/solution-architect.md +1 -1
  330. package/presets/opencode/next/agents/task-analyst.md +1 -1
  331. package/presets/opencode/next/agents/task-router.md +1 -1
  332. package/presets/opencode/next/agents/tech-writer.md +1 -1
  333. package/presets/opencode/next/agents/unit-test-generator.md +1 -1
  334. package/presets/opencode/next/agents/unit-test-healer.md +1 -1
  335. package/presets/opencode/next/agents/unit-test-planner.md +1 -1
  336. package/presets/opencode/next/hooks/chain-team-phases.sh +62 -5
  337. package/presets/opencode/next/team/README.md +1 -1
  338. package/presets/opencode/nuxt/adapter-map.json +1 -1
  339. package/presets/opencode/nuxt/agents/ci-investigator.md +1 -1
  340. package/presets/opencode/nuxt/agents/debugger.md +1 -1
  341. package/presets/opencode/nuxt/agents/feature-developer.md +1 -1
  342. package/presets/opencode/nuxt/agents/migration-specialist.md +1 -1
  343. package/presets/opencode/nuxt/agents/performance-auditor.md +1 -1
  344. package/presets/opencode/nuxt/agents/qa-tester.md +1 -1
  345. package/presets/opencode/nuxt/agents/solution-architect.md +1 -1
  346. package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
  347. package/presets/opencode/nuxt/agents/task-router.md +1 -1
  348. package/presets/opencode/nuxt/agents/tech-writer.md +1 -1
  349. package/presets/opencode/nuxt/agents/unit-test-generator.md +1 -1
  350. package/presets/opencode/nuxt/agents/unit-test-healer.md +1 -1
  351. package/presets/opencode/nuxt/agents/unit-test-planner.md +1 -1
  352. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +62 -5
  353. package/presets/opencode/nuxt/team/README.md +1 -1
  354. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  355. package/presets/opencode/php-hexagonal/agents/feature-developer.md +1 -1
  356. package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
  357. package/presets/opencode/php-hexagonal/agents/task-router.md +1 -1
  358. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +62 -5
  359. package/presets/opencode/php-hexagonal/team/README.md +1 -1
  360. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  361. package/presets/opencode/php-laravel/agents/feature-developer.md +1 -1
  362. package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
  363. package/presets/opencode/php-laravel/agents/task-router.md +1 -1
  364. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +62 -5
  365. package/presets/opencode/php-laravel/team/README.md +1 -1
  366. package/presets/opencode/svelte/adapter-map.json +1 -1
  367. package/presets/opencode/svelte/agents/ci-investigator.md +1 -1
  368. package/presets/opencode/svelte/agents/debugger.md +1 -1
  369. package/presets/opencode/svelte/agents/feature-developer.md +1 -1
  370. package/presets/opencode/svelte/agents/migration-specialist.md +1 -1
  371. package/presets/opencode/svelte/agents/performance-auditor.md +1 -1
  372. package/presets/opencode/svelte/agents/qa-tester.md +1 -1
  373. package/presets/opencode/svelte/agents/solution-architect.md +1 -1
  374. package/presets/opencode/svelte/agents/task-analyst.md +1 -1
  375. package/presets/opencode/svelte/agents/task-router.md +1 -1
  376. package/presets/opencode/svelte/agents/tech-writer.md +1 -1
  377. package/presets/opencode/svelte/agents/unit-test-generator.md +1 -1
  378. package/presets/opencode/svelte/agents/unit-test-healer.md +1 -1
  379. package/presets/opencode/svelte/agents/unit-test-planner.md +1 -1
  380. package/presets/opencode/svelte/hooks/chain-team-phases.sh +62 -5
  381. package/presets/opencode/svelte/team/README.md +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@
4
4
 
5
5
  No unpublished changes.
6
6
 
7
+ ## 0.2.42
8
+
9
+ ### A duplicate stop no longer stalls the next pipeline step
10
+
11
+ - **Gate by step id.** `humanGates` accepts `after:<step id>` as well as `after:<agent>`. `after:frame` pauses only the `frame` step when later steps reuse `task-analyst`. The next attempt stays unopened until `/task-continue`.
12
+ - **Duplicate stop.** A stop with no `attemptId` and no receipt, arriving within 15s of the attempt this transition just opened, does not set `awaiting_artifact_receipt`. A later stop with no receipt still stalls.
13
+ - **One `task_completed`.** A second completion of the same metrics file does not append another event.
14
+ - **Deferral reason.** Steps that share an agent stay serial. When the wave keeps one and defers the rest, the metric says `same agent already in the wave`.
15
+ - **Receipt paths.** Handoffs, producer prompts, and the artifact contract require `authoritativePaths` relative to the task folder (`brief.md`). A repo-root path is rejected. The team README example that showed one is corrected.
16
+ - **Self-learning.** `derive-gate-signals` skips files in `tasks/` (such as `.gitkeep`) instead of reporting `ENOTDIR`.
17
+
18
+ ### Upgrade
19
+
20
+ - `npx @bonesofspring/ai-rules update` replaces `hooks/chain-team-phases.sh` and the agent prompts, so the step-id gate, the duplicate-stop ignore, the single `task_completed`, and the receipt-path sentence land on re-init.
21
+ - `init` / `update` does not overwrite an existing `.ai.local/scripts/derive-gate-signals.mjs`. Replace that file with the package copy to pick up the `.gitkeep` skip.
22
+
7
23
  ## 0.2.41
8
24
 
9
25
  ### `/task` slash menu shows the command description
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonesofspring/ai-rules",
3
- "version": "0.2.41",
3
+ "version": "0.2.42",
4
4
  "description": "Presets of Cursor, Claude, Mavis, and OpenCode rules/commands for Revy Ross personal use",
5
5
  "license": "MIT",
6
6
  "author": "Revy Ross",
@@ -91,6 +91,13 @@ export function deriveGateSignals({ baseDir = DEFAULT_BASE_DIR, isDenied = defau
91
91
  }
92
92
 
93
93
  for (const name of names) {
94
+ let dirStat;
95
+ try {
96
+ dirStat = fs.statSync(path.join(tasksDir, name));
97
+ } catch {
98
+ continue;
99
+ }
100
+ if (!dirStat.isDirectory()) continue;
94
101
  const metricsPath = path.join(tasksDir, name, 'metrics.json');
95
102
  let raw;
96
103
  try {
@@ -73,6 +73,7 @@ A producer finishes its step by upserting only its owned artifact entry and term
73
73
  - `attemptId`: optional stable attempt ID supplied by the hook; when present it must match the active attempt
74
74
  - `summary`: one short factual sentence
75
75
  - `evidencePaths`: authoritative files that support the outcome
76
+ - `authoritativePaths`: paths relative to the task directory (`brief.md`). A repo-root path (`.ai.local/team/tasks/<slug>/brief.md`) resolves outside that directory and the hook rejects the receipt.
76
77
 
77
78
  `changes_requested` and `validation_failed` use artifact `status: "blocked"` while retaining their distinct receipt outcome. A later successful attempt updates the same owned entry to `completed`; timestamps and evidence must reflect the latest result. Do not infer success from a Markdown filename alone.
78
79
 
@@ -434,7 +434,21 @@ function endHumanGateIfResumed() {
434
434
  appendMetric({ type: 'human_gate_ended', at: now, gateStartedEventId: status.activeHumanGateEventId, source: 'hook', attributionConfidence: 'high' });
435
435
  delete status.activeHumanGateEventId;
436
436
  }
437
- function completeTaskMetrics() { appendMetric({ type: 'task_completed', at: now, outcome: status.state === 'completed' ? 'completed' : 'unknown', source: 'hook', attributionConfidence: 'high' }); }
437
+ function completeTaskMetrics() {
438
+ // Two hook processes can both enter completion before either writes the
439
+ // event. The metrics lock serializes them; the second sees the first write.
440
+ mutateMetrics((metrics) => {
441
+ if (metrics.events.some((event) => event && event.type === 'task_completed')) return;
442
+ metrics.events.push({
443
+ eventId: `${metrics.task.runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`,
444
+ type: 'task_completed',
445
+ at: now,
446
+ outcome: status.state === 'completed' ? 'completed' : 'unknown',
447
+ source: 'hook',
448
+ attributionConfidence: 'high',
449
+ });
450
+ });
451
+ }
438
452
  function recordSkippedStep(step, stepIndex) {
439
453
  for (const agent of getStepAgents(step)) {
440
454
  const runId = status.metricsRunId || `${slug}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
@@ -622,7 +636,7 @@ function handoffForWave(units, waveId) {
622
636
  `Invoke IN PARALLEL (one message, multiple Task calls): ${labels.join(' AND ')} for slug "${slug}"${waveId ? ` (waveId=${waveId})` : ''}. ` +
623
637
  `Each agent writes its artifact and owned receipt; the hook records slot joins from stops. Do not mutate status.json lifecycle fields. ` +
624
638
  `Artifact inputs: ${inputIds.length > 0 ? inputIds.join(', ') : 'manifest defaults'}; owned output IDs: ${outputIds.join('; ')}. ` +
625
- `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration.`
639
+ `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration. ${receiptPathClause()}`
626
640
  );
627
641
  }
628
642
  function blockedNotice(blockedIndex, agent) {
@@ -638,12 +652,22 @@ function noProgressNotice() {
638
652
  const pending = pendingStepIndexes().map((index) => steps[index].id || `step-${index}`);
639
653
  return `No schedulable step remains for slug "${slug}" (unsatisfied: ${pending.join(', ')}). Resume only via /task-continue ${slug}.`;
640
654
  }
655
+ function deferReason(wave, deferred) {
656
+ const sameAgent = deferred.some((index) => wave.some((chosen) => {
657
+ const left = getStepAgents(steps[chosen]);
658
+ return getStepAgents(steps[index]).some((agent) => left.includes(agent));
659
+ }));
660
+ if (sameAgent) return 'same agent already in the wave';
661
+ const missingScope = [...wave, ...deferred].some((index) => declaredScopes(steps[index]).length === 0);
662
+ if (missingScope) return 'writeScopes undeclared';
663
+ return 'writeScopes overlap';
664
+ }
641
665
  function dispatchReadyWave(prefixMessage) {
642
666
  const ready = computeReadySteps();
643
667
  if (ready.length === 0) return false;
644
668
  const { wave, deferred } = selectWave(ready);
645
669
  if (deferred.length > 0) {
646
- appendMetric({ type: 'parallel_conflict_deferred', at: now, stepIndex: wave[0], deferredStepIndexes: deferred, reason: 'ready set not conflict-free or writeScopes undeclared', source: 'hook', attributionConfidence: 'fallback' });
670
+ appendMetric({ type: 'parallel_conflict_deferred', at: now, stepIndex: wave[0], deferredStepIndexes: deferred, reason: deferReason(wave, deferred), source: 'hook', attributionConfidence: 'fallback' });
647
671
  }
648
672
  // Slot-filtered dispatch: only unsatisfied (stepIndex, agent) slots are invoked.
649
673
  const units = wave.flatMap((stepIndex) => unsatisfiedAgents(stepIndex).map((agent) => ({ stepIndex, agent })));
@@ -733,9 +757,12 @@ function metricsHandoff(agent) {
733
757
  return ' Metrics: use the supplied attemptId when available; for a parallel completion, write a minimal { attemptId, outcome } receipt to .metrics-receipts.json rather than relying on currentAgent. Do not calculate duration.';
734
758
  }
735
759
 
760
+ function receiptPathClause() {
761
+ return 'authoritativePaths are relative to the task folder (brief.md), not the repo root; put external files in evidencePaths.';
762
+ }
736
763
  function artifactHandoff(step, agent) {
737
764
  const inputIds = Array.isArray(step?.artifactInputIds) ? step.artifactInputIds.join(', ') : 'manifest defaults';
738
- return ` Artifact inputs: ${inputIds}; owned output ID: ${artifactOutputIdFor(step, agent)}. Bind the terminal receipt to the supplied attemptId.`;
765
+ return ` Artifact inputs: ${inputIds}; owned output ID: ${artifactOutputIdFor(step, agent)}. Bind the terminal receipt to the supplied attemptId. ${receiptPathClause()}`;
739
766
  }
740
767
 
741
768
  function handoffForAgent(agent, scope, step = null) {
@@ -753,7 +780,7 @@ function handoffForParallelStep(step) {
753
780
  `Invoke IN PARALLEL (one message, multiple Task calls): ${agents.join(' AND ')} for slug "${slug}". ` +
754
781
  `Each agent writes its artifact and owned receipt; the hook records parallelCompleted from stops. Do not mutate status.json lifecycle fields. ` +
755
782
  `Artifact inputs: ${Array.isArray(step.artifactInputIds) ? step.artifactInputIds.join(', ') : 'manifest defaults'}; owned output IDs: ${agents.map((agent) => `${agent}=${artifactOutputIdFor(step, agent)}`).join('; ')}. ` +
756
- `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration.`
783
+ `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration. ${receiptPathClause()}`
757
784
  );
758
785
  }
759
786
 
@@ -762,9 +789,35 @@ function hasGateAfter(agent, humanGates) {
762
789
  }
763
790
 
764
791
  function hasGateAfterStep(step, humanGates) {
792
+ if (!Array.isArray(humanGates) || !step) return false;
793
+ if (typeof step.id === 'string' && step.id.length > 0 && humanGates.includes(`after:${step.id}`)) return true;
765
794
  return getStepAgents(step).some((a) => hasGateAfter(a, humanGates));
766
795
  }
767
796
 
797
+ // A followup loop of the subagent that just finished arrives with no attemptId
798
+ // and no receipt for the attempt this same transition opened. That stop is not
799
+ // the next agent. A stop more than 15s later, still without a receipt, is a
800
+ // real missing receipt and must stall.
801
+ function isSchedulingEcho() {
802
+ if (typeof hookInput.attemptId === 'string' && hookInput.attemptId.length > 0) return false;
803
+ const entries = Object.entries(status.activeAttempts || {});
804
+ if (entries.length !== 1) return false;
805
+ const [attemptId, entry] = entries[0];
806
+ const previous = status.lastCompletedAttempt;
807
+ if (!previous || previous.completedAt !== entry.startedAt) return false;
808
+ const ageMs = Date.parse(now) - Date.parse(entry.startedAt);
809
+ if (!Number.isFinite(ageMs) || ageMs < 0 || ageMs > 15000) return false;
810
+ const previousJoined = Object.values(status.joinedSlots || {}).some((slot) => slot && slot.attemptId === previous.attemptId);
811
+ const linearAdvance = !isGraphMode() && typeof entry.stepIndex === 'number' && entry.stepIndex > 0;
812
+ if (!previousJoined && !linearAdvance) return false;
813
+ try {
814
+ const manifest = JSON.parse(fs.readFileSync(path.join(taskDir, 'artifact-manifest.json'), 'utf8'));
815
+ const artifacts = Array.isArray(manifest.artifacts) ? manifest.artifacts : [];
816
+ if (artifacts.some((item) => item && item.receipt && item.receipt.attemptId === attemptId)) return false;
817
+ } catch {}
818
+ return true;
819
+ }
820
+
768
821
  function legacyFlow() {
769
822
  // <<<hook-slot:LEGACY_FLOW>>>
770
823
  // <<<hook-slot:/LEGACY_FLOW>>>
@@ -918,6 +971,10 @@ if (pipelineParseError) {
918
971
  }
919
972
 
920
973
  steps = pipeline.steps || [];
974
+ if (isSchedulingEcho()) {
975
+ process.stdout.write('{}');
976
+ process.exit(0);
977
+ }
921
978
  const initialIdx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
922
979
  const initialStep = steps[initialIdx];
923
980
  const activeAttemptCountBeforeFinish = Object.keys(status.activeAttempts || {}).length;
@@ -99,7 +99,7 @@ If a Sentry/Datadog (or similar) MCP is ready and the task is a production error
99
99
 
100
100
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for `brief.md`, `decomposition.md`, and other authoritative prior artifacts for this step.
101
101
  - **Owned outputs:** `ci-report.md` plus any minimal CI fix paths; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `ci-report`) and preserve all foreign items in `manifest.artifacts[]`.
102
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
102
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
103
103
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
104
104
 
105
105
  Provide summary: failed check, root cause, files changed, validation commands run, `resolved`.
@@ -115,7 +115,7 @@ If a Sentry/Datadog (or similar) MCP is ready and the task is a production error
115
115
 
116
116
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for `brief.md`, `decomposition.md`, and other authoritative prior artifacts for this step.
117
117
  - **Owned outputs:** `debug-report.md`; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `debug`) and preserve all foreign items in `manifest.artifacts[]`.
118
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
118
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
119
119
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
120
120
 
121
121
  Handoff summary: root cause, recommended fix, files touched (if any), `fixApplied`.
@@ -146,5 +146,5 @@ Load requestable rule `mcp-usage` when verifying third-party library APIs (Conte
146
146
 
147
147
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for `brief.md`, `decomposition.md`, current scope, and applicable prior findings.
148
148
  - **Owned outputs:** `implementation.md` plus changed implementation/test paths; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `implementation`) and preserve all foreign items in `manifest.artifacts[]`.
149
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
149
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
150
150
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
@@ -86,7 +86,7 @@ Load requestable rule `mcp-usage` when verifying third-party library APIs (Conte
86
86
 
87
87
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for `brief.md`, `decomposition.md`, and other authoritative prior artifacts for this step.
88
88
  - **Owned outputs:** `migration-plan.md`; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `migration-plan`) and preserve all foreign items in `manifest.artifacts[]`.
89
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
89
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
90
90
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
91
91
 
92
92
  Hand off: orchestrator runs human gate (if configured), then `feature-developer` executes phases from the plan.
@@ -77,7 +77,7 @@ Load requestable rule `mcp-usage` when verifying third-party library APIs (Conte
77
77
 
78
78
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for brief when present and the scoped git diff / screens under audit.
79
79
  - **Owned outputs:** `perf-report.md`; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `perf-report`) and preserve all foreign items in `manifest.artifacts[]`.
80
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
80
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
81
81
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
82
82
 
83
83
  For standalone `perf-audit` intent, suggest `/technical-retro` or a follow-up `/task` to implement fixes.
@@ -72,7 +72,7 @@ Write the owned terminal receipt described under **Artifact contract**.
72
72
 
73
73
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for `brief.md`, `decomposition.md`, and other authoritative prior artifacts for this step.
74
74
  - **Owned outputs:** updated JUnit / instrumentation tests and handoff summary; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `qa`) and preserve all foreign items in `manifest.artifacts[]`.
75
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
75
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
76
76
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
77
77
 
78
78
  Provide summary:
@@ -143,5 +143,5 @@ If the prompt/brief has a tracker URL (Linear/Jira/Notion/…) and that MCP is r
143
143
 
144
144
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume `pipeline.json`, the manifest routing entry, user-approved decisions, and any authoritative architecture/approval entries.
145
145
  - **Owned outputs:** `brief.md` and `decomposition.md` (plus `ux-design.md` when produced); upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `analysis`) and preserve all foreign items in `manifest.artifacts[]`.
146
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
146
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
147
147
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
@@ -181,5 +181,5 @@ Return the routing receipt to the orchestrator. The orchestration runtime/hook e
181
181
 
182
182
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume the user request and any existing authoritative task/decision entries.
183
183
  - **Owned outputs:** `pipeline.json` and the routing entry in `manifest.artifacts[]`; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `routing`) and preserve all foreign items in `manifest.artifacts[]`.
184
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
184
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
185
185
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
@@ -77,7 +77,7 @@ Post-delivery: when behavior or public docs changed and `docs/specs/` is in play
77
77
 
78
78
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for `brief.md`, `decomposition.md`, and other authoritative prior artifacts for this step.
79
79
  - **Owned outputs:** `documentation.md` (and Docs paths only if the task explicitly requests); upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `documentation`) and preserve all foreign items in `manifest.artifacts[]`.
80
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
80
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
81
81
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
82
82
 
83
83
  Suggest `/technical-retro <slug>` when this is the final pipeline step.
@@ -63,7 +63,7 @@ Write the owned terminal receipt described under **Artifact contract**.
63
63
 
64
64
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for `brief.md`, `decomposition.md`, and other authoritative prior artifacts for this step.
65
65
  - **Owned outputs:** new/updated `*Test` sources under `src/test`; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `unit-tests`) and preserve all foreign items in `manifest.artifacts[]`.
66
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
66
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
67
67
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
68
68
 
69
69
  Run affected unit tests via `./gradlew test` (`gradle-tooling`) when feasible. Report commands, pass/fail, and gaps.
@@ -62,7 +62,7 @@ Write the owned terminal receipt described under **Artifact contract**.
62
62
 
63
63
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for `brief.md`, `decomposition.md`, and other authoritative prior artifacts for this step.
64
64
  - **Owned outputs:** fixed test sources; optional `debug-report.md` when complex; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `unit-test-heal`) and preserve all foreign items in `manifest.artifacts[]`.
65
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
65
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
66
66
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
67
67
 
68
68
  Report root cause, files changed, validation result, and remaining risk.
@@ -73,7 +73,7 @@ Write the owned terminal receipt described under **Artifact contract**.
73
73
 
74
74
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for `brief.md`, `decomposition.md`, and other authoritative prior artifacts for this step.
75
75
  - **Owned outputs:** `unit-test-plan.md`; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `unit-test-plan`) and preserve all foreign items in `manifest.artifacts[]`.
76
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
76
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
77
77
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
78
78
 
79
79
  Do not write test source files — that is `unit-test-generator`'s job.
@@ -471,7 +471,21 @@ function endHumanGateIfResumed() {
471
471
  appendMetric({ type: 'human_gate_ended', at: now, gateStartedEventId: status.activeHumanGateEventId, source: 'hook', attributionConfidence: 'high' });
472
472
  delete status.activeHumanGateEventId;
473
473
  }
474
- function completeTaskMetrics() { appendMetric({ type: 'task_completed', at: now, outcome: status.state === 'completed' ? 'completed' : 'unknown', source: 'hook', attributionConfidence: 'high' }); }
474
+ function completeTaskMetrics() {
475
+ // Two hook processes can both enter completion before either writes the
476
+ // event. The metrics lock serializes them; the second sees the first write.
477
+ mutateMetrics((metrics) => {
478
+ if (metrics.events.some((event) => event && event.type === 'task_completed')) return;
479
+ metrics.events.push({
480
+ eventId: `${metrics.task.runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`,
481
+ type: 'task_completed',
482
+ at: now,
483
+ outcome: status.state === 'completed' ? 'completed' : 'unknown',
484
+ source: 'hook',
485
+ attributionConfidence: 'high',
486
+ });
487
+ });
488
+ }
475
489
  function recordSkippedStep(step, stepIndex) {
476
490
  for (const agent of getStepAgents(step)) {
477
491
  const runId = status.metricsRunId || `${slug}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
@@ -659,7 +673,7 @@ function handoffForWave(units, waveId) {
659
673
  `Invoke IN PARALLEL (one message, multiple Task calls): ${labels.join(' AND ')} for slug "${slug}"${waveId ? ` (waveId=${waveId})` : ''}. ` +
660
674
  `Each agent writes its artifact and owned receipt; the hook records slot joins from stops. Do not mutate status.json lifecycle fields. ` +
661
675
  `Artifact inputs: ${inputIds.length > 0 ? inputIds.join(', ') : 'manifest defaults'}; owned output IDs: ${outputIds.join('; ')}. ` +
662
- `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration.`
676
+ `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration. ${receiptPathClause()}`
663
677
  );
664
678
  }
665
679
  function blockedNotice(blockedIndex, agent) {
@@ -675,12 +689,22 @@ function noProgressNotice() {
675
689
  const pending = pendingStepIndexes().map((index) => steps[index].id || `step-${index}`);
676
690
  return `No schedulable step remains for slug "${slug}" (unsatisfied: ${pending.join(', ')}). Resume only via /task-continue ${slug}.`;
677
691
  }
692
+ function deferReason(wave, deferred) {
693
+ const sameAgent = deferred.some((index) => wave.some((chosen) => {
694
+ const left = getStepAgents(steps[chosen]);
695
+ return getStepAgents(steps[index]).some((agent) => left.includes(agent));
696
+ }));
697
+ if (sameAgent) return 'same agent already in the wave';
698
+ const missingScope = [...wave, ...deferred].some((index) => declaredScopes(steps[index]).length === 0);
699
+ if (missingScope) return 'writeScopes undeclared';
700
+ return 'writeScopes overlap';
701
+ }
678
702
  function dispatchReadyWave(prefixMessage) {
679
703
  const ready = computeReadySteps();
680
704
  if (ready.length === 0) return false;
681
705
  const { wave, deferred } = selectWave(ready);
682
706
  if (deferred.length > 0) {
683
- appendMetric({ type: 'parallel_conflict_deferred', at: now, stepIndex: wave[0], deferredStepIndexes: deferred, reason: 'ready set not conflict-free or writeScopes undeclared', source: 'hook', attributionConfidence: 'fallback' });
707
+ appendMetric({ type: 'parallel_conflict_deferred', at: now, stepIndex: wave[0], deferredStepIndexes: deferred, reason: deferReason(wave, deferred), source: 'hook', attributionConfidence: 'fallback' });
684
708
  }
685
709
  // Slot-filtered dispatch: only unsatisfied (stepIndex, agent) slots are invoked.
686
710
  const units = wave.flatMap((stepIndex) => unsatisfiedAgents(stepIndex).map((agent) => ({ stepIndex, agent })));
@@ -828,9 +852,12 @@ function metricsHandoff(agent) {
828
852
  return ' Metrics: use the supplied attemptId when available; for a parallel completion, write a minimal { attemptId, outcome } receipt to .metrics-receipts.json rather than relying on currentAgent. Do not calculate duration.';
829
853
  }
830
854
 
855
+ function receiptPathClause() {
856
+ return 'authoritativePaths are relative to the task folder (brief.md), not the repo root; put external files in evidencePaths.';
857
+ }
831
858
  function artifactHandoff(step, agent) {
832
859
  const inputIds = Array.isArray(step?.artifactInputIds) ? step.artifactInputIds.join(', ') : 'manifest defaults';
833
- return ` Artifact inputs: ${inputIds}; owned output ID: ${artifactOutputIdFor(step, agent)}. Bind the terminal receipt to the supplied attemptId.`;
860
+ return ` Artifact inputs: ${inputIds}; owned output ID: ${artifactOutputIdFor(step, agent)}. Bind the terminal receipt to the supplied attemptId. ${receiptPathClause()}`;
834
861
  }
835
862
 
836
863
  function handoffForAgent(agent, scope, step = null) {
@@ -848,7 +875,7 @@ function handoffForParallelStep(step) {
848
875
  `Invoke IN PARALLEL (one message, multiple Task calls): ${agents.join(' AND ')} for slug "${slug}". ` +
849
876
  `Each agent writes its artifact and owned receipt; the hook records parallelCompleted from stops. Do not mutate status.json lifecycle fields. ` +
850
877
  `Artifact inputs: ${Array.isArray(step.artifactInputIds) ? step.artifactInputIds.join(', ') : 'manifest defaults'}; owned output IDs: ${agents.map((agent) => `${agent}=${artifactOutputIdFor(step, agent)}`).join('; ')}. ` +
851
- `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration.`
878
+ `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration. ${receiptPathClause()}`
852
879
  );
853
880
  }
854
881
 
@@ -857,9 +884,35 @@ function hasGateAfter(agent, humanGates) {
857
884
  }
858
885
 
859
886
  function hasGateAfterStep(step, humanGates) {
887
+ if (!Array.isArray(humanGates) || !step) return false;
888
+ if (typeof step.id === 'string' && step.id.length > 0 && humanGates.includes(`after:${step.id}`)) return true;
860
889
  return getStepAgents(step).some((a) => hasGateAfter(a, humanGates));
861
890
  }
862
891
 
892
+ // A followup loop of the subagent that just finished arrives with no attemptId
893
+ // and no receipt for the attempt this same transition opened. That stop is not
894
+ // the next agent. A stop more than 15s later, still without a receipt, is a
895
+ // real missing receipt and must stall.
896
+ function isSchedulingEcho() {
897
+ if (typeof hookInput.attemptId === 'string' && hookInput.attemptId.length > 0) return false;
898
+ const entries = Object.entries(status.activeAttempts || {});
899
+ if (entries.length !== 1) return false;
900
+ const [attemptId, entry] = entries[0];
901
+ const previous = status.lastCompletedAttempt;
902
+ if (!previous || previous.completedAt !== entry.startedAt) return false;
903
+ const ageMs = Date.parse(now) - Date.parse(entry.startedAt);
904
+ if (!Number.isFinite(ageMs) || ageMs < 0 || ageMs > 15000) return false;
905
+ const previousJoined = Object.values(status.joinedSlots || {}).some((slot) => slot && slot.attemptId === previous.attemptId);
906
+ const linearAdvance = !isGraphMode() && typeof entry.stepIndex === 'number' && entry.stepIndex > 0;
907
+ if (!previousJoined && !linearAdvance) return false;
908
+ try {
909
+ const manifest = JSON.parse(fs.readFileSync(path.join(taskDir, 'artifact-manifest.json'), 'utf8'));
910
+ const artifacts = Array.isArray(manifest.artifacts) ? manifest.artifacts : [];
911
+ if (artifacts.some((item) => item && item.receipt && item.receipt.attemptId === attemptId)) return false;
912
+ } catch {}
913
+ return true;
914
+ }
915
+
863
916
  function legacyFlow() {
864
917
  if (status.phase === 'analysis') {
865
918
  process.stdout.write('{}');
@@ -1077,6 +1130,10 @@ if (pipelineParseError) {
1077
1130
  }
1078
1131
 
1079
1132
  steps = pipeline.steps || [];
1133
+ if (isSchedulingEcho()) {
1134
+ process.stdout.write('{}');
1135
+ process.exit(0);
1136
+ }
1080
1137
  const initialIdx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
1081
1138
  const initialStep = steps[initialIdx];
1082
1139
  const activeAttemptCountBeforeFinish = Object.keys(status.activeAttempts || {}).length;
@@ -75,7 +75,7 @@ Same JSON on Claude, Mavis, or OpenCode: `bash .<tool>/hooks/chain-team-phases.s
75
75
  ## Contracts
76
76
 
77
77
  - **Manifest field name:** receipts go in `artifacts[]`. Anything written under `entries` is ignored — the hook reads only `artifacts` and prints a dual-read warning naming the file. See `agent-team/agent-artifact-contracts.md` § Schema field name.
78
- - **Evidence paths:** `authoritativePaths[]` must be task-relative (`.ai.local/team/tasks/<slug>/…`). Put anything outside the task directory — e.g. `openspec/changes/**` — in `evidencePaths[]`.
78
+ - **Evidence paths:** `authoritativePaths[]` is relative to the task directory (`brief.md`). A repo-root path (`.ai.local/team/tasks/<slug>/brief.md`) is rejected. Put anything outside the task directory — e.g. `openspec/changes/**` — in `evidencePaths[]`.
79
79
  - Manifest schema: shared core `agent-team/agent-artifact-contracts.md`. Read it first; producers upsert only their IDs.
80
80
  - Metrics: append-only allowlisted events — `agent-team/agent-task-metrics.md`. Aggregate: `node node_modules/@bonesofspring/ai-rules/scripts/aggregate-agent-task-metrics.mjs --team-root .ai.local/team`.
81
81
  - Commit `.ai.local/team/` templates (and slugs if you want them in clones).
@@ -131,7 +131,7 @@ Load requestable rule `mcp-usage` when verifying third-party library APIs (Conte
131
131
 
132
132
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the items in `manifest.artifacts[]` for `brief.md`, `decomposition.md`, current scope, and applicable prior findings.
133
133
  - **Owned outputs:** `implementation.md` plus changed implementation/test paths; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `implementation`) and preserve all foreign items in `manifest.artifacts[]`.
134
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
134
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
135
135
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
136
136
 
137
137
  ## Receipt binding
@@ -122,5 +122,5 @@ If the prompt/brief has a tracker URL (Linear/Jira/Notion/…) and that MCP is r
122
122
 
123
123
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume `pipeline.json`, the manifest routing entry, user-approved decisions, and any authoritative architecture/approval entries.
124
124
  - **Owned outputs:** `brief.md` and `decomposition.md`; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `analysis`) and preserve all foreign items in `manifest.artifacts[]`.
125
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
125
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
126
126
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
@@ -170,5 +170,5 @@ Return the routing receipt to the orchestrator. The orchestration runtime/hook e
170
170
 
171
171
  - **Authoritative inputs:** read `.ai.local/team/tasks/<slug>/artifact-manifest.json` first; consume the user request and any existing authoritative task/decision entries.
172
172
  - **Owned outputs:** `pipeline.json` and the routing entry in `manifest.artifacts[]`; upsert only the entry in `manifest.artifacts[]` assigned by handoff (`artifactOutputId`; fallback `routing`) and preserve all foreign items in `manifest.artifacts[]`.
173
- - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
173
+ - **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present. `authoritativePaths` are relative to the task folder (`brief.md`), not the repo root; put external files in `evidencePaths`.
174
174
  - **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
@@ -470,7 +470,21 @@ function endHumanGateIfResumed() {
470
470
  appendMetric({ type: 'human_gate_ended', at: now, gateStartedEventId: status.activeHumanGateEventId, source: 'hook', attributionConfidence: 'high' });
471
471
  delete status.activeHumanGateEventId;
472
472
  }
473
- function completeTaskMetrics() { appendMetric({ type: 'task_completed', at: now, outcome: status.state === 'completed' ? 'completed' : 'unknown', source: 'hook', attributionConfidence: 'high' }); }
473
+ function completeTaskMetrics() {
474
+ // Two hook processes can both enter completion before either writes the
475
+ // event. The metrics lock serializes them; the second sees the first write.
476
+ mutateMetrics((metrics) => {
477
+ if (metrics.events.some((event) => event && event.type === 'task_completed')) return;
478
+ metrics.events.push({
479
+ eventId: `${metrics.task.runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`,
480
+ type: 'task_completed',
481
+ at: now,
482
+ outcome: status.state === 'completed' ? 'completed' : 'unknown',
483
+ source: 'hook',
484
+ attributionConfidence: 'high',
485
+ });
486
+ });
487
+ }
474
488
  function recordSkippedStep(step, stepIndex) {
475
489
  for (const agent of getStepAgents(step)) {
476
490
  const runId = status.metricsRunId || `${slug}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
@@ -658,7 +672,7 @@ function handoffForWave(units, waveId) {
658
672
  `Invoke IN PARALLEL (one message, multiple Task calls): ${labels.join(' AND ')} for slug "${slug}"${waveId ? ` (waveId=${waveId})` : ''}. ` +
659
673
  `Each agent writes its artifact and owned receipt; the hook records slot joins from stops. Do not mutate status.json lifecycle fields. ` +
660
674
  `Artifact inputs: ${inputIds.length > 0 ? inputIds.join(', ') : 'manifest defaults'}; owned output IDs: ${outputIds.join('; ')}. ` +
661
- `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration.`
675
+ `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration. ${receiptPathClause()}`
662
676
  );
663
677
  }
664
678
  function blockedNotice(blockedIndex, agent) {
@@ -674,12 +688,22 @@ function noProgressNotice() {
674
688
  const pending = pendingStepIndexes().map((index) => steps[index].id || `step-${index}`);
675
689
  return `No schedulable step remains for slug "${slug}" (unsatisfied: ${pending.join(', ')}). Resume only via /task-continue ${slug}.`;
676
690
  }
691
+ function deferReason(wave, deferred) {
692
+ const sameAgent = deferred.some((index) => wave.some((chosen) => {
693
+ const left = getStepAgents(steps[chosen]);
694
+ return getStepAgents(steps[index]).some((agent) => left.includes(agent));
695
+ }));
696
+ if (sameAgent) return 'same agent already in the wave';
697
+ const missingScope = [...wave, ...deferred].some((index) => declaredScopes(steps[index]).length === 0);
698
+ if (missingScope) return 'writeScopes undeclared';
699
+ return 'writeScopes overlap';
700
+ }
677
701
  function dispatchReadyWave(prefixMessage) {
678
702
  const ready = computeReadySteps();
679
703
  if (ready.length === 0) return false;
680
704
  const { wave, deferred } = selectWave(ready);
681
705
  if (deferred.length > 0) {
682
- appendMetric({ type: 'parallel_conflict_deferred', at: now, stepIndex: wave[0], deferredStepIndexes: deferred, reason: 'ready set not conflict-free or writeScopes undeclared', source: 'hook', attributionConfidence: 'fallback' });
706
+ appendMetric({ type: 'parallel_conflict_deferred', at: now, stepIndex: wave[0], deferredStepIndexes: deferred, reason: deferReason(wave, deferred), source: 'hook', attributionConfidence: 'fallback' });
683
707
  }
684
708
  // Slot-filtered dispatch: only unsatisfied (stepIndex, agent) slots are invoked.
685
709
  const units = wave.flatMap((stepIndex) => unsatisfiedAgents(stepIndex).map((agent) => ({ stepIndex, agent })));
@@ -823,9 +847,12 @@ function metricsHandoff(agent) {
823
847
  return ' Metrics: use the supplied attemptId when available; for a parallel completion, write a minimal { attemptId, outcome } receipt to .metrics-receipts.json rather than relying on currentAgent. Do not calculate duration.';
824
848
  }
825
849
 
850
+ function receiptPathClause() {
851
+ return 'authoritativePaths are relative to the task folder (brief.md), not the repo root; put external files in evidencePaths.';
852
+ }
826
853
  function artifactHandoff(step, agent) {
827
854
  const inputIds = Array.isArray(step?.artifactInputIds) ? step.artifactInputIds.join(', ') : 'manifest defaults';
828
- return ` Artifact inputs: ${inputIds}; owned output ID: ${artifactOutputIdFor(step, agent)}. Bind the terminal receipt to the supplied attemptId.`;
855
+ return ` Artifact inputs: ${inputIds}; owned output ID: ${artifactOutputIdFor(step, agent)}. Bind the terminal receipt to the supplied attemptId. ${receiptPathClause()}`;
829
856
  }
830
857
 
831
858
  function handoffForAgent(agent, scope, step = null) {
@@ -843,7 +870,7 @@ function handoffForParallelStep(step) {
843
870
  `Invoke IN PARALLEL (one message, multiple Task calls): ${agents.join(' AND ')} for slug "${slug}". ` +
844
871
  `Each agent writes its artifact and owned receipt; the hook records parallelCompleted from stops. Do not mutate status.json lifecycle fields. ` +
845
872
  `Artifact inputs: ${Array.isArray(step.artifactInputIds) ? step.artifactInputIds.join(', ') : 'manifest defaults'}; owned output IDs: ${agents.map((agent) => `${agent}=${artifactOutputIdFor(step, agent)}`).join('; ')}. ` +
846
- `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration.`
873
+ `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration. ${receiptPathClause()}`
847
874
  );
848
875
  }
849
876
 
@@ -852,9 +879,35 @@ function hasGateAfter(agent, humanGates) {
852
879
  }
853
880
 
854
881
  function hasGateAfterStep(step, humanGates) {
882
+ if (!Array.isArray(humanGates) || !step) return false;
883
+ if (typeof step.id === 'string' && step.id.length > 0 && humanGates.includes(`after:${step.id}`)) return true;
855
884
  return getStepAgents(step).some((a) => hasGateAfter(a, humanGates));
856
885
  }
857
886
 
887
+ // A followup loop of the subagent that just finished arrives with no attemptId
888
+ // and no receipt for the attempt this same transition opened. That stop is not
889
+ // the next agent. A stop more than 15s later, still without a receipt, is a
890
+ // real missing receipt and must stall.
891
+ function isSchedulingEcho() {
892
+ if (typeof hookInput.attemptId === 'string' && hookInput.attemptId.length > 0) return false;
893
+ const entries = Object.entries(status.activeAttempts || {});
894
+ if (entries.length !== 1) return false;
895
+ const [attemptId, entry] = entries[0];
896
+ const previous = status.lastCompletedAttempt;
897
+ if (!previous || previous.completedAt !== entry.startedAt) return false;
898
+ const ageMs = Date.parse(now) - Date.parse(entry.startedAt);
899
+ if (!Number.isFinite(ageMs) || ageMs < 0 || ageMs > 15000) return false;
900
+ const previousJoined = Object.values(status.joinedSlots || {}).some((slot) => slot && slot.attemptId === previous.attemptId);
901
+ const linearAdvance = !isGraphMode() && typeof entry.stepIndex === 'number' && entry.stepIndex > 0;
902
+ if (!previousJoined && !linearAdvance) return false;
903
+ try {
904
+ const manifest = JSON.parse(fs.readFileSync(path.join(taskDir, 'artifact-manifest.json'), 'utf8'));
905
+ const artifacts = Array.isArray(manifest.artifacts) ? manifest.artifacts : [];
906
+ if (artifacts.some((item) => item && item.receipt && item.receipt.attemptId === attemptId)) return false;
907
+ } catch {}
908
+ return true;
909
+ }
910
+
858
911
  function legacyFlow() {
859
912
  if (status.phase === 'analysis') {
860
913
  process.stdout.write('{}');
@@ -1072,6 +1125,10 @@ if (pipelineParseError) {
1072
1125
  }
1073
1126
 
1074
1127
  steps = pipeline.steps || [];
1128
+ if (isSchedulingEcho()) {
1129
+ process.stdout.write('{}');
1130
+ process.exit(0);
1131
+ }
1075
1132
  const initialIdx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
1076
1133
  const initialStep = steps[initialIdx];
1077
1134
  const activeAttemptCountBeforeFinish = Object.keys(status.activeAttempts || {}).length;
@@ -75,7 +75,7 @@ Same JSON on Claude, Mavis, or OpenCode: `bash .<tool>/hooks/chain-team-phases.s
75
75
  ## Contracts
76
76
 
77
77
  - **Manifest field name:** receipts go in `artifacts[]`. Anything written under `entries` is ignored — the hook reads only `artifacts` and prints a dual-read warning naming the file. See `agent-team/agent-artifact-contracts.md` § Schema field name.
78
- - **Evidence paths:** `authoritativePaths[]` must be task-relative (`.ai.local/team/tasks/<slug>/…`). Put anything outside the task directory — e.g. `openspec/changes/**` — in `evidencePaths[]`.
78
+ - **Evidence paths:** `authoritativePaths[]` is relative to the task directory (`brief.md`). A repo-root path (`.ai.local/team/tasks/<slug>/brief.md`) is rejected. Put anything outside the task directory — e.g. `openspec/changes/**` — in `evidencePaths[]`.
79
79
  - Manifest schema: shared core `agent-team/agent-artifact-contracts.md`. Read it first; producers upsert only their IDs.
80
80
  - Metrics: append-only allowlisted events — `agent-team/agent-task-metrics.md`. Aggregate: `node node_modules/@bonesofspring/ai-rules/scripts/aggregate-agent-task-metrics.mjs --team-root .ai.local/team`.
81
81
  - Commit `.ai.local/team/` templates (and slugs if you want them in clones).