@apralabs/apra-fleet 0.3.6 → 0.4.0

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 (569) hide show
  1. package/README.md +245 -257
  2. package/dist/agents/backlog-groomer.md +287 -0
  3. package/dist/agents/deployer.md +52 -11
  4. package/dist/agents/doer.md +32 -7
  5. package/dist/agents/integ-test-runner.md +151 -61
  6. package/dist/agents/plan-reviewer.md +74 -17
  7. package/dist/agents/planner.md +94 -14
  8. package/dist/agents/regression-test-runner.md +216 -0
  9. package/dist/agents/reviewer.md +21 -6
  10. package/dist/agents/schemas/backlog-groomer-input.json +35 -0
  11. package/dist/agents/schemas/backlog-groomer-output.json +164 -0
  12. package/dist/agents/schemas/integ-test-runner-output.json +34 -0
  13. package/dist/agents/schemas/regression-test-runner-input.json +15 -0
  14. package/dist/agents/schemas/regression-test-runner-output.json +50 -0
  15. package/dist/agents/schemas/reviewer-output.json +4 -0
  16. package/dist/cli/agent-transform.d.ts +1 -0
  17. package/dist/cli/agent-transform.d.ts.map +1 -1
  18. package/dist/cli/agent-transform.js +77 -0
  19. package/dist/cli/agent-transform.js.map +1 -1
  20. package/dist/cli/auth.d.ts +3 -0
  21. package/dist/cli/auth.d.ts.map +1 -1
  22. package/dist/cli/auth.js +181 -5
  23. package/dist/cli/auth.js.map +1 -1
  24. package/dist/cli/config.d.ts +5 -1
  25. package/dist/cli/config.d.ts.map +1 -1
  26. package/dist/cli/config.js +7 -1
  27. package/dist/cli/config.js.map +1 -1
  28. package/dist/cli/dolt-install.d.ts +91 -0
  29. package/dist/cli/dolt-install.d.ts.map +1 -0
  30. package/dist/cli/dolt-install.js +334 -0
  31. package/dist/cli/dolt-install.js.map +1 -0
  32. package/dist/cli/install-guard.d.ts +29 -0
  33. package/dist/cli/install-guard.d.ts.map +1 -0
  34. package/dist/cli/install-guard.js +153 -0
  35. package/dist/cli/install-guard.js.map +1 -0
  36. package/dist/cli/install.d.ts +44 -3
  37. package/dist/cli/install.d.ts.map +1 -1
  38. package/dist/cli/install.js +604 -108
  39. package/dist/cli/install.js.map +1 -1
  40. package/dist/cli/join.d.ts +12 -0
  41. package/dist/cli/join.d.ts.map +1 -0
  42. package/dist/cli/join.js +87 -0
  43. package/dist/cli/join.js.map +1 -0
  44. package/dist/cli/register-member.d.ts +2 -0
  45. package/dist/cli/register-member.d.ts.map +1 -0
  46. package/dist/cli/register-member.js +193 -0
  47. package/dist/cli/register-member.js.map +1 -0
  48. package/dist/cli/restart.d.ts +2 -0
  49. package/dist/cli/restart.d.ts.map +1 -0
  50. package/dist/cli/restart.js +7 -0
  51. package/dist/cli/restart.js.map +1 -0
  52. package/dist/cli/spoke.d.ts +35 -0
  53. package/dist/cli/spoke.d.ts.map +1 -0
  54. package/dist/cli/spoke.js +212 -0
  55. package/dist/cli/spoke.js.map +1 -0
  56. package/dist/cli/start.d.ts +2 -0
  57. package/dist/cli/start.d.ts.map +1 -0
  58. package/dist/cli/start.js +92 -0
  59. package/dist/cli/start.js.map +1 -0
  60. package/dist/cli/status.d.ts +2 -0
  61. package/dist/cli/status.d.ts.map +1 -0
  62. package/dist/cli/status.js +83 -0
  63. package/dist/cli/status.js.map +1 -0
  64. package/dist/cli/stop.d.ts +2 -0
  65. package/dist/cli/stop.d.ts.map +1 -0
  66. package/dist/cli/stop.js +51 -0
  67. package/dist/cli/stop.js.map +1 -0
  68. package/dist/cli/uninstall.d.ts.map +1 -1
  69. package/dist/cli/uninstall.js +109 -9
  70. package/dist/cli/uninstall.js.map +1 -1
  71. package/dist/cli/update.d.ts.map +1 -1
  72. package/dist/cli/update.js +10 -1
  73. package/dist/cli/update.js.map +1 -1
  74. package/dist/cli/workflow-assets.d.ts +37 -0
  75. package/dist/cli/workflow-assets.d.ts.map +1 -0
  76. package/dist/cli/workflow-assets.js +144 -0
  77. package/dist/cli/workflow-assets.js.map +1 -0
  78. package/dist/cli/workflow.d.ts +75 -0
  79. package/dist/cli/workflow.d.ts.map +1 -0
  80. package/dist/cli/workflow.js +397 -0
  81. package/dist/cli/workflow.js.map +1 -0
  82. package/dist/hub-service/activity.d.ts +30 -0
  83. package/dist/hub-service/activity.d.ts.map +1 -0
  84. package/dist/hub-service/activity.js +20 -0
  85. package/dist/hub-service/activity.js.map +1 -0
  86. package/dist/hub-service/audit-log.d.ts +19 -0
  87. package/dist/hub-service/audit-log.d.ts.map +1 -0
  88. package/dist/hub-service/audit-log.js +13 -0
  89. package/dist/hub-service/audit-log.js.map +1 -0
  90. package/dist/hub-service/db/pool.d.ts +19 -0
  91. package/dist/hub-service/db/pool.d.ts.map +1 -0
  92. package/dist/hub-service/db/pool.js +53 -0
  93. package/dist/hub-service/db/pool.js.map +1 -0
  94. package/dist/hub-service/enrollment.d.ts +29 -0
  95. package/dist/hub-service/enrollment.d.ts.map +1 -0
  96. package/dist/hub-service/enrollment.js +48 -0
  97. package/dist/hub-service/enrollment.js.map +1 -0
  98. package/dist/hub-service/envelope-routes.d.ts +46 -0
  99. package/dist/hub-service/envelope-routes.d.ts.map +1 -0
  100. package/dist/hub-service/envelope-routes.js +94 -0
  101. package/dist/hub-service/envelope-routes.js.map +1 -0
  102. package/dist/hub-service/handlers/installers.d.ts +14 -0
  103. package/dist/hub-service/handlers/installers.d.ts.map +1 -0
  104. package/dist/hub-service/handlers/installers.js +8 -0
  105. package/dist/hub-service/handlers/installers.js.map +1 -0
  106. package/dist/hub-service/http-server.d.ts +31 -0
  107. package/dist/hub-service/http-server.d.ts.map +1 -0
  108. package/dist/hub-service/http-server.js +711 -0
  109. package/dist/hub-service/http-server.js.map +1 -0
  110. package/dist/hub-service/hub-jwt.d.ts +30 -0
  111. package/dist/hub-service/hub-jwt.d.ts.map +1 -0
  112. package/dist/hub-service/hub-jwt.js +105 -0
  113. package/dist/hub-service/hub-jwt.js.map +1 -0
  114. package/dist/hub-service/jwt-revocation.d.ts +20 -0
  115. package/dist/hub-service/jwt-revocation.d.ts.map +1 -0
  116. package/dist/hub-service/jwt-revocation.js +18 -0
  117. package/dist/hub-service/jwt-revocation.js.map +1 -0
  118. package/dist/hub-service/machines.d.ts +16 -0
  119. package/dist/hub-service/machines.d.ts.map +1 -0
  120. package/dist/hub-service/machines.js +14 -0
  121. package/dist/hub-service/machines.js.map +1 -0
  122. package/dist/hub-service/main.d.ts +3 -0
  123. package/dist/hub-service/main.d.ts.map +1 -0
  124. package/dist/hub-service/main.js +64 -0
  125. package/dist/hub-service/main.js.map +1 -0
  126. package/dist/hub-service/member-tokens.d.ts +11 -0
  127. package/dist/hub-service/member-tokens.d.ts.map +1 -0
  128. package/dist/hub-service/member-tokens.js +49 -0
  129. package/dist/hub-service/member-tokens.js.map +1 -0
  130. package/dist/hub-service/member-view.d.ts +20 -0
  131. package/dist/hub-service/member-view.d.ts.map +1 -0
  132. package/dist/hub-service/member-view.js +76 -0
  133. package/dist/hub-service/member-view.js.map +1 -0
  134. package/dist/hub-service/members.d.ts +44 -0
  135. package/dist/hub-service/members.d.ts.map +1 -0
  136. package/dist/hub-service/members.js +25 -0
  137. package/dist/hub-service/members.js.map +1 -0
  138. package/dist/hub-service/presence.d.ts +40 -0
  139. package/dist/hub-service/presence.d.ts.map +1 -0
  140. package/dist/hub-service/presence.js +44 -0
  141. package/dist/hub-service/presence.js.map +1 -0
  142. package/dist/hub-service/project-view.d.ts +12 -0
  143. package/dist/hub-service/project-view.d.ts.map +1 -0
  144. package/dist/hub-service/project-view.js +34 -0
  145. package/dist/hub-service/project-view.js.map +1 -0
  146. package/dist/hub-service/projects.d.ts +48 -0
  147. package/dist/hub-service/projects.d.ts.map +1 -0
  148. package/dist/hub-service/projects.js +80 -0
  149. package/dist/hub-service/projects.js.map +1 -0
  150. package/dist/hub-service/relay-queue.d.ts +115 -0
  151. package/dist/hub-service/relay-queue.d.ts.map +1 -0
  152. package/dist/hub-service/relay-queue.js +148 -0
  153. package/dist/hub-service/relay-queue.js.map +1 -0
  154. package/dist/hub-service/session-jwt.d.ts +10 -0
  155. package/dist/hub-service/session-jwt.d.ts.map +1 -0
  156. package/dist/hub-service/session-jwt.js +69 -0
  157. package/dist/hub-service/session-jwt.js.map +1 -0
  158. package/dist/hub-service/usage.d.ts +40 -0
  159. package/dist/hub-service/usage.d.ts.map +1 -0
  160. package/dist/hub-service/usage.js +25 -0
  161. package/dist/hub-service/usage.js.map +1 -0
  162. package/dist/hub-service/users.d.ts +56 -0
  163. package/dist/hub-service/users.d.ts.map +1 -0
  164. package/dist/hub-service/users.js +72 -0
  165. package/dist/hub-service/users.js.map +1 -0
  166. package/dist/hub-service/workspaces.d.ts +20 -0
  167. package/dist/hub-service/workspaces.d.ts.map +1 -0
  168. package/dist/hub-service/workspaces.js +10 -0
  169. package/dist/hub-service/workspaces.js.map +1 -0
  170. package/dist/index.js +179 -132
  171. package/dist/index.js.map +1 -1
  172. package/dist/os/linux.d.ts +13 -0
  173. package/dist/os/linux.d.ts.map +1 -1
  174. package/dist/os/linux.js +62 -3
  175. package/dist/os/linux.js.map +1 -1
  176. package/dist/os/os-commands.d.ts +10 -0
  177. package/dist/os/os-commands.d.ts.map +1 -1
  178. package/dist/os/windows.d.ts +1 -0
  179. package/dist/os/windows.d.ts.map +1 -1
  180. package/dist/os/windows.js +21 -1
  181. package/dist/os/windows.js.map +1 -1
  182. package/dist/paths.d.ts +23 -0
  183. package/dist/paths.d.ts.map +1 -1
  184. package/dist/paths.js +29 -0
  185. package/dist/paths.js.map +1 -1
  186. package/dist/providers/agy.d.ts +9 -2
  187. package/dist/providers/agy.d.ts.map +1 -1
  188. package/dist/providers/agy.js +127 -14
  189. package/dist/providers/agy.js.map +1 -1
  190. package/dist/providers/claude.d.ts +6 -2
  191. package/dist/providers/claude.d.ts.map +1 -1
  192. package/dist/providers/claude.js +248 -9
  193. package/dist/providers/claude.js.map +1 -1
  194. package/dist/providers/codex.d.ts +3 -2
  195. package/dist/providers/codex.d.ts.map +1 -1
  196. package/dist/providers/codex.js +7 -0
  197. package/dist/providers/codex.js.map +1 -1
  198. package/dist/providers/copilot.d.ts +3 -2
  199. package/dist/providers/copilot.d.ts.map +1 -1
  200. package/dist/providers/copilot.js +8 -1
  201. package/dist/providers/copilot.js.map +1 -1
  202. package/dist/providers/gemini.d.ts +3 -2
  203. package/dist/providers/gemini.d.ts.map +1 -1
  204. package/dist/providers/gemini.js +11 -1
  205. package/dist/providers/gemini.js.map +1 -1
  206. package/dist/providers/index.d.ts +1 -0
  207. package/dist/providers/index.d.ts.map +1 -1
  208. package/dist/providers/index.js +3 -0
  209. package/dist/providers/index.js.map +1 -1
  210. package/dist/providers/none.d.ts +51 -0
  211. package/dist/providers/none.d.ts.map +1 -0
  212. package/dist/providers/none.js +103 -0
  213. package/dist/providers/none.js.map +1 -0
  214. package/dist/providers/opencode.d.ts +4 -2
  215. package/dist/providers/opencode.d.ts.map +1 -1
  216. package/dist/providers/opencode.js +49 -0
  217. package/dist/providers/opencode.js.map +1 -1
  218. package/dist/providers/provider.d.ts +79 -1
  219. package/dist/providers/provider.d.ts.map +1 -1
  220. package/dist/providers/provider.js +10 -0
  221. package/dist/providers/provider.js.map +1 -1
  222. package/dist/services/agent-provisioner.d.ts +3 -3
  223. package/dist/services/agent-provisioner.d.ts.map +1 -1
  224. package/dist/services/agent-provisioner.js +12 -5
  225. package/dist/services/agent-provisioner.js.map +1 -1
  226. package/dist/services/auth-socket.d.ts.map +1 -1
  227. package/dist/services/auth-socket.js +2 -0
  228. package/dist/services/auth-socket.js.map +1 -1
  229. package/dist/services/budget-awareness.d.ts +130 -0
  230. package/dist/services/budget-awareness.d.ts.map +1 -0
  231. package/dist/services/budget-awareness.js +129 -0
  232. package/dist/services/budget-awareness.js.map +1 -0
  233. package/dist/services/cloud-sync.d.ts +35 -0
  234. package/dist/services/cloud-sync.d.ts.map +1 -0
  235. package/dist/services/cloud-sync.js +90 -0
  236. package/dist/services/cloud-sync.js.map +1 -0
  237. package/dist/services/context-admission.d.ts +82 -0
  238. package/dist/services/context-admission.d.ts.map +1 -0
  239. package/dist/services/context-admission.js +136 -0
  240. package/dist/services/context-admission.js.map +1 -0
  241. package/dist/services/event-bus.d.ts +27 -0
  242. package/dist/services/event-bus.d.ts.map +1 -0
  243. package/dist/services/event-bus.js +20 -0
  244. package/dist/services/event-bus.js.map +1 -0
  245. package/dist/services/file-chunker.d.ts +38 -0
  246. package/dist/services/file-chunker.d.ts.map +1 -0
  247. package/dist/services/file-chunker.js +63 -0
  248. package/dist/services/file-chunker.js.map +1 -0
  249. package/dist/services/file-transfer-relay.d.ts +55 -0
  250. package/dist/services/file-transfer-relay.d.ts.map +1 -0
  251. package/dist/services/file-transfer-relay.js +115 -0
  252. package/dist/services/file-transfer-relay.js.map +1 -0
  253. package/dist/services/github-app.d.ts.map +1 -1
  254. package/dist/services/github-app.js +1 -0
  255. package/dist/services/github-app.js.map +1 -1
  256. package/dist/services/http-transport.d.ts +25 -0
  257. package/dist/services/http-transport.d.ts.map +1 -0
  258. package/dist/services/http-transport.js +371 -0
  259. package/dist/services/http-transport.js.map +1 -0
  260. package/dist/services/hub-client.d.ts +69 -0
  261. package/dist/services/hub-client.d.ts.map +1 -0
  262. package/dist/services/hub-client.js +217 -0
  263. package/dist/services/hub-client.js.map +1 -0
  264. package/dist/services/jwt.d.ts +17 -0
  265. package/dist/services/jwt.d.ts.map +1 -0
  266. package/dist/services/jwt.js +70 -0
  267. package/dist/services/jwt.js.map +1 -0
  268. package/dist/services/known-sessions.d.ts +8 -0
  269. package/dist/services/known-sessions.d.ts.map +1 -0
  270. package/dist/services/known-sessions.js +40 -0
  271. package/dist/services/known-sessions.js.map +1 -0
  272. package/dist/services/model-pricing.d.ts +36 -0
  273. package/dist/services/model-pricing.d.ts.map +1 -0
  274. package/dist/services/model-pricing.js +108 -0
  275. package/dist/services/model-pricing.js.map +1 -0
  276. package/dist/services/orphan-recovery.d.ts +56 -0
  277. package/dist/services/orphan-recovery.d.ts.map +1 -0
  278. package/dist/services/orphan-recovery.js +111 -0
  279. package/dist/services/orphan-recovery.js.map +1 -0
  280. package/dist/services/pending-responses.d.ts +23 -0
  281. package/dist/services/pending-responses.d.ts.map +1 -0
  282. package/dist/services/pending-responses.js +52 -0
  283. package/dist/services/pending-responses.js.map +1 -0
  284. package/dist/services/registry.d.ts +4 -1
  285. package/dist/services/registry.d.ts.map +1 -1
  286. package/dist/services/registry.js +3 -0
  287. package/dist/services/registry.js.map +1 -1
  288. package/dist/services/relay-context.d.ts +23 -0
  289. package/dist/services/relay-context.d.ts.map +1 -0
  290. package/dist/services/relay-context.js +8 -0
  291. package/dist/services/relay-context.js.map +1 -0
  292. package/dist/services/relay-executor.d.ts +68 -0
  293. package/dist/services/relay-executor.d.ts.map +1 -0
  294. package/dist/services/relay-executor.js +70 -0
  295. package/dist/services/relay-executor.js.map +1 -0
  296. package/dist/services/relay-request.d.ts +65 -0
  297. package/dist/services/relay-request.d.ts.map +1 -0
  298. package/dist/services/relay-request.js +129 -0
  299. package/dist/services/relay-request.js.map +1 -0
  300. package/dist/services/relay-strategy.d.ts +19 -0
  301. package/dist/services/relay-strategy.d.ts.map +1 -0
  302. package/dist/services/relay-strategy.js +111 -0
  303. package/dist/services/relay-strategy.js.map +1 -0
  304. package/dist/services/service-manager/index.d.ts +5 -0
  305. package/dist/services/service-manager/index.d.ts.map +1 -0
  306. package/dist/services/service-manager/index.js +66 -0
  307. package/dist/services/service-manager/index.js.map +1 -0
  308. package/dist/services/service-manager/linux.d.ts +10 -0
  309. package/dist/services/service-manager/linux.d.ts.map +1 -0
  310. package/dist/services/service-manager/linux.js +97 -0
  311. package/dist/services/service-manager/linux.js.map +1 -0
  312. package/dist/services/service-manager/macos.d.ts +10 -0
  313. package/dist/services/service-manager/macos.d.ts.map +1 -0
  314. package/dist/services/service-manager/macos.js +94 -0
  315. package/dist/services/service-manager/macos.js.map +1 -0
  316. package/dist/services/service-manager/types.d.ts +18 -0
  317. package/dist/services/service-manager/types.d.ts.map +1 -0
  318. package/dist/services/service-manager/types.js +5 -0
  319. package/dist/services/service-manager/types.js.map +1 -0
  320. package/dist/services/service-manager/windows.d.ts +10 -0
  321. package/dist/services/service-manager/windows.d.ts.map +1 -0
  322. package/dist/services/service-manager/windows.js +73 -0
  323. package/dist/services/service-manager/windows.js.map +1 -0
  324. package/dist/services/session-registry.d.ts +70 -0
  325. package/dist/services/session-registry.d.ts.map +1 -0
  326. package/dist/services/session-registry.js +91 -0
  327. package/dist/services/session-registry.js.map +1 -0
  328. package/dist/services/singleton.d.ts +15 -0
  329. package/dist/services/singleton.d.ts.map +1 -0
  330. package/dist/services/singleton.js +98 -0
  331. package/dist/services/singleton.js.map +1 -0
  332. package/dist/services/sprint-coordination.d.ts +168 -0
  333. package/dist/services/sprint-coordination.d.ts.map +1 -0
  334. package/dist/services/sprint-coordination.js +564 -0
  335. package/dist/services/sprint-coordination.js.map +1 -0
  336. package/dist/services/ssh.d.ts.map +1 -1
  337. package/dist/services/ssh.js +70 -3
  338. package/dist/services/ssh.js.map +1 -1
  339. package/dist/services/stall/log-path-resolver.d.ts.map +1 -1
  340. package/dist/services/stall/log-path-resolver.js +8 -1
  341. package/dist/services/stall/log-path-resolver.js.map +1 -1
  342. package/dist/services/stall/stall-detector.d.ts.map +1 -1
  343. package/dist/services/stall/stall-detector.js +39 -7
  344. package/dist/services/stall/stall-detector.js.map +1 -1
  345. package/dist/services/stall/stall-poller.d.ts +16 -0
  346. package/dist/services/stall/stall-poller.d.ts.map +1 -1
  347. package/dist/services/stall/stall-poller.js +136 -18
  348. package/dist/services/stall/stall-poller.js.map +1 -1
  349. package/dist/services/strategy.d.ts.map +1 -1
  350. package/dist/services/strategy.js +55 -5
  351. package/dist/services/strategy.js.map +1 -1
  352. package/dist/services/substitution-engine.d.ts +20 -0
  353. package/dist/services/substitution-engine.d.ts.map +1 -0
  354. package/dist/services/substitution-engine.js +92 -0
  355. package/dist/services/substitution-engine.js.map +1 -0
  356. package/dist/services/task-cleanup.d.ts.map +1 -1
  357. package/dist/services/task-cleanup.js +1 -9
  358. package/dist/services/task-cleanup.js.map +1 -1
  359. package/dist/services/token-issuer.d.ts +47 -0
  360. package/dist/services/token-issuer.d.ts.map +1 -0
  361. package/dist/services/token-issuer.js +63 -0
  362. package/dist/services/token-issuer.js.map +1 -0
  363. package/dist/services/tool-registry.d.ts +3 -0
  364. package/dist/services/tool-registry.d.ts.map +1 -0
  365. package/dist/services/tool-registry.js +139 -0
  366. package/dist/services/tool-registry.js.map +1 -0
  367. package/dist/services/user-config.d.ts +14 -0
  368. package/dist/services/user-config.d.ts.map +1 -1
  369. package/dist/services/user-config.js +55 -0
  370. package/dist/services/user-config.js.map +1 -1
  371. package/dist/services/vcs/types.d.ts +44 -0
  372. package/dist/services/vcs/types.d.ts.map +1 -1
  373. package/dist/skills/fleet-sprint-cli/SKILL.md +103 -0
  374. package/dist/skills/pm/cost.md +3 -0
  375. package/dist/skills/pm/doer-reviewer-loop.md +3 -0
  376. package/dist/tools/check-status.d.ts.map +1 -1
  377. package/dist/tools/check-status.js +8 -2
  378. package/dist/tools/check-status.js.map +1 -1
  379. package/dist/tools/child-id-allocator.d.ts +45 -0
  380. package/dist/tools/child-id-allocator.d.ts.map +1 -0
  381. package/dist/tools/child-id-allocator.js +62 -0
  382. package/dist/tools/child-id-allocator.js.map +1 -0
  383. package/dist/tools/cloud-control.d.ts +2 -2
  384. package/dist/tools/compose-permissions.d.ts +12 -4
  385. package/dist/tools/compose-permissions.d.ts.map +1 -1
  386. package/dist/tools/compose-permissions.js +55 -4
  387. package/dist/tools/compose-permissions.js.map +1 -1
  388. package/dist/tools/dolt-push-mutex.d.ts +44 -0
  389. package/dist/tools/dolt-push-mutex.d.ts.map +1 -0
  390. package/dist/tools/dolt-push-mutex.js +83 -0
  391. package/dist/tools/dolt-push-mutex.js.map +1 -0
  392. package/dist/tools/execute-command.d.ts +11 -1
  393. package/dist/tools/execute-command.d.ts.map +1 -1
  394. package/dist/tools/execute-command.js +22 -5
  395. package/dist/tools/execute-command.js.map +1 -1
  396. package/dist/tools/execute-prompt.d.ts +72 -12
  397. package/dist/tools/execute-prompt.d.ts.map +1 -1
  398. package/dist/tools/execute-prompt.js +962 -71
  399. package/dist/tools/execute-prompt.js.map +1 -1
  400. package/dist/tools/get-member-model-pricing.d.ts +21 -0
  401. package/dist/tools/get-member-model-pricing.d.ts.map +1 -0
  402. package/dist/tools/get-member-model-pricing.js +29 -0
  403. package/dist/tools/get-member-model-pricing.js.map +1 -0
  404. package/dist/tools/list-members.d.ts.map +1 -1
  405. package/dist/tools/list-members.js +39 -7
  406. package/dist/tools/list-members.js.map +1 -1
  407. package/dist/tools/member-detail.d.ts +1 -1
  408. package/dist/tools/member-detail.d.ts.map +1 -1
  409. package/dist/tools/member-detail.js +8 -2
  410. package/dist/tools/member-detail.js.map +1 -1
  411. package/dist/tools/member-reservation.d.ts +29 -0
  412. package/dist/tools/member-reservation.d.ts.map +1 -0
  413. package/dist/tools/member-reservation.js +71 -0
  414. package/dist/tools/member-reservation.js.map +1 -0
  415. package/dist/tools/provision-vcs-auth.d.ts +7 -7
  416. package/dist/tools/provision-vcs-auth.js +1 -1
  417. package/dist/tools/provision-vcs-auth.js.map +1 -1
  418. package/dist/tools/register-member.d.ts +17 -5
  419. package/dist/tools/register-member.d.ts.map +1 -1
  420. package/dist/tools/register-member.js +144 -5
  421. package/dist/tools/register-member.js.map +1 -1
  422. package/dist/tools/remove-member.d.ts +1 -1
  423. package/dist/tools/report-status.d.ts +33 -0
  424. package/dist/tools/report-status.d.ts.map +1 -0
  425. package/dist/tools/report-status.js +44 -0
  426. package/dist/tools/report-status.js.map +1 -0
  427. package/dist/tools/respond-to-message.d.ts +21 -0
  428. package/dist/tools/respond-to-message.d.ts.map +1 -0
  429. package/dist/tools/respond-to-message.js +23 -0
  430. package/dist/tools/respond-to-message.js.map +1 -0
  431. package/dist/tools/send-files.d.ts +3 -0
  432. package/dist/tools/send-files.d.ts.map +1 -1
  433. package/dist/tools/send-files.js +88 -8
  434. package/dist/tools/send-files.js.map +1 -1
  435. package/dist/tools/send-message.d.ts +27 -0
  436. package/dist/tools/send-message.d.ts.map +1 -0
  437. package/dist/tools/send-message.js +46 -0
  438. package/dist/tools/send-message.js.map +1 -0
  439. package/dist/tools/shutdown-server.d.ts +2 -0
  440. package/dist/tools/shutdown-server.d.ts.map +1 -1
  441. package/dist/tools/shutdown-server.js +19 -0
  442. package/dist/tools/shutdown-server.js.map +1 -1
  443. package/dist/tools/update-member.d.ts +8 -8
  444. package/dist/tools/update-member.d.ts.map +1 -1
  445. package/dist/tools/update-member.js +11 -1
  446. package/dist/tools/update-member.js.map +1 -1
  447. package/dist/types.d.ts +15 -3
  448. package/dist/types.d.ts.map +1 -1
  449. package/dist/utils/agent-helpers.d.ts +2 -1
  450. package/dist/utils/agent-helpers.d.ts.map +1 -1
  451. package/dist/utils/agent-helpers.js +7 -2
  452. package/dist/utils/agent-helpers.js.map +1 -1
  453. package/dist/utils/pid-helpers.d.ts +15 -0
  454. package/dist/utils/pid-helpers.d.ts.map +1 -1
  455. package/dist/utils/pid-helpers.js +23 -0
  456. package/dist/utils/pid-helpers.js.map +1 -1
  457. package/dist/utils/process-utils.d.ts +3 -0
  458. package/dist/utils/process-utils.d.ts.map +1 -0
  459. package/dist/utils/process-utils.js +42 -0
  460. package/dist/utils/process-utils.js.map +1 -0
  461. package/dist/utils/prompt-errors.d.ts +2 -1
  462. package/dist/utils/prompt-errors.d.ts.map +1 -1
  463. package/dist/utils/prompt-errors.js +13 -3
  464. package/dist/utils/prompt-errors.js.map +1 -1
  465. package/dist/utils/workspace-trust.d.ts +24 -0
  466. package/dist/utils/workspace-trust.d.ts.map +1 -0
  467. package/dist/utils/workspace-trust.js +35 -0
  468. package/dist/utils/workspace-trust.js.map +1 -0
  469. package/dist/workflows/auto-sprint.js +450 -87
  470. package/package.json +35 -7
  471. package/packages/apra-fleet-client/package.json +26 -0
  472. package/packages/apra-fleet-client/src/client/api.mjs +396 -0
  473. package/packages/apra-fleet-client/src/client/client.mjs +146 -0
  474. package/packages/apra-fleet-client/src/client/errors.mjs +71 -0
  475. package/packages/apra-fleet-client/src/client/factory.mjs +65 -0
  476. package/packages/apra-fleet-client/src/client/server-resolution.mjs +265 -0
  477. package/packages/apra-fleet-client/src/client/transport.mjs +327 -0
  478. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +287 -0
  479. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +89 -0
  480. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +139 -0
  481. package/packages/apra-fleet-se/apra-pm/agents/doer.md +225 -0
  482. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +169 -0
  483. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +316 -0
  484. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +188 -0
  485. package/packages/apra-fleet-se/apra-pm/agents/planner.md +239 -0
  486. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +216 -0
  487. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +174 -0
  488. package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-input.json +35 -0
  489. package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-output.json +164 -0
  490. package/packages/apra-fleet-se/apra-pm/agents/schemas/ci-watcher-input.json +26 -0
  491. package/packages/apra-fleet-se/apra-pm/agents/schemas/ci-watcher-output.json +18 -0
  492. package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-input.json +19 -0
  493. package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +17 -0
  494. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-input.json +25 -0
  495. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +22 -0
  496. package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-input.json +31 -0
  497. package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-output.json +18 -0
  498. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-input.json +20 -0
  499. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +61 -0
  500. package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-input.json +15 -0
  501. package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +30 -0
  502. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-input.json +15 -0
  503. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +50 -0
  504. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-input.json +25 -0
  505. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +38 -0
  506. package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +402 -0
  507. package/packages/apra-fleet-se/apra-pm/skills/pm/beads.md +142 -0
  508. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +157 -0
  509. package/packages/apra-fleet-se/apra-pm/skills/pm/doer-reviewer-loop.md +300 -0
  510. package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +121 -0
  511. package/packages/apra-fleet-se/apra-pm/skills/pm/simple-sprint.md +65 -0
  512. package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +327 -0
  513. package/packages/apra-fleet-se/apra-pm/skills/pm/worktrees.md +92 -0
  514. package/packages/apra-fleet-se/apra-pm/version.json +3 -0
  515. package/packages/apra-fleet-se/bin/cli.mjs +857 -0
  516. package/packages/apra-fleet-se/bin/serve.mjs +383 -0
  517. package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +178 -0
  518. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +914 -0
  519. package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +177 -0
  520. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +191 -0
  521. package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +151 -0
  522. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-tier2-runbook.md +127 -0
  523. package/packages/apra-fleet-se/fleet-sprint/docs/fleet-sprint-diagram.md +94 -0
  524. package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +1125 -0
  525. package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +72 -0
  526. package/packages/apra-fleet-se/fleet-sprint/dolt-recovery-path-b.mjs +339 -0
  527. package/packages/apra-fleet-se/fleet-sprint/dolt-recovery-tier2.mjs +360 -0
  528. package/packages/apra-fleet-se/fleet-sprint/dolt-recovery.mjs +363 -0
  529. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +1244 -0
  530. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +572 -0
  531. package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +118 -0
  532. package/packages/apra-fleet-se/fleet-sprint/runner.js +9447 -0
  533. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +103 -0
  534. package/packages/apra-fleet-se/fleet-sprint/sprint-lock.mjs +140 -0
  535. package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +435 -0
  536. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +68 -0
  537. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +53 -0
  538. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +146 -0
  539. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/generic-git.mjs +176 -0
  540. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +222 -0
  541. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +218 -0
  542. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +882 -0
  543. package/packages/apra-fleet-se/package.json +28 -0
  544. package/packages/apra-fleet-se/workflow.json +1 -0
  545. package/packages/apra-fleet-workflow/package.json +30 -0
  546. package/packages/apra-fleet-workflow/src/viewer/command-output-cap.mjs +112 -0
  547. package/packages/apra-fleet-workflow/src/viewer/debounced-writer.mjs +153 -0
  548. package/packages/apra-fleet-workflow/src/viewer/html-utils.mjs +31 -0
  549. package/packages/apra-fleet-workflow/src/viewer/index.mjs +1325 -0
  550. package/packages/apra-fleet-workflow/src/viewer/lean-state.mjs +237 -0
  551. package/packages/apra-fleet-workflow/src/viewer/run-state-paths.mjs +130 -0
  552. package/packages/apra-fleet-workflow/src/viewer/sprint-state-paths.mjs +29 -0
  553. package/packages/apra-fleet-workflow/src/workflow/engine.mjs +200 -0
  554. package/packages/apra-fleet-workflow/src/workflow/errors.mjs +146 -0
  555. package/packages/apra-fleet-workflow/src/workflow/index.mjs +1723 -0
  556. package/packages/apra-fleet-workflow/src/workflow/journal.mjs +291 -0
  557. package/packages/apra-fleet-workflow/src/workflow/pricing.mjs +99 -0
  558. package/packages/apra-fleet-workflow/src/workflow/vetting.mjs +111 -0
  559. package/scripts/agy-transcript-reader.js +1 -0
  560. package/scripts/fleet-statusline.sh +17 -13
  561. package/skills/fleet/SKILL.md +37 -2
  562. package/skills/fleet/beads.md +14 -7
  563. package/skills/fleet/permissions.md +50 -0
  564. package/skills/fleet/profiles/base-dev.json +1 -0
  565. package/skills/fleet/profiles/base-reviewer.json +1 -0
  566. package/skills/fleet/profiles/node.json +2 -2
  567. package/version.json +1 -1
  568. package/scripts/agy-settings-merge.js +0 -27
  569. /package/{dist → packages/apra-fleet-se/apra-pm}/agents/_shared/GRAPH-SEMANTICS.md +0 -0
@@ -9,7 +9,7 @@ export const meta = {
9
9
  ],
10
10
  };
11
11
 
12
- // Multi-cycle sprint workflow. Drives 8 agents against a beads backlog until a
12
+ // Multi-cycle sprint workflow. Drives 9 agents against a beads backlog until a
13
13
  // priority-based quality goal is met or the cycle ceiling is reached.
14
14
  //
15
15
  // Agent roster:
@@ -18,8 +18,11 @@ export const meta = {
18
18
  // doer -- works bd-ready tasks (impl and test-dev), VERIFY checkpoint
19
19
  // reviewer -- reviews doer output, can reopen tasks
20
20
  // deployer -- follows deploy.md ONLY (deploy + smoke test); never the playbook
21
- // integ-test-runner -- owns integ-test-playbook.md end to end (setup/reset/teardown),
22
- // executes tests, closes features, files bugs/enhancements
21
+ // integ-test-runner -- per-cycle feature closure via integ-test-playbook.md: runs each
22
+ // handed feature's [test] tasks, closes on pass, files [integ] bugs
23
+ // regression-test-runner -- ONCE PER SPRINT owner of regression-test-playbook.md (real-bd
24
+ // suite + toy-sprint smoke test, sandbox setup/reset/teardown);
25
+ // informational only, files parent-less [regression][carry-over] bugs
23
26
  // ci-watcher -- polls CI; creates beads task if not configured
24
27
  // harvester -- docs, CHANGELOG, token summary, PR
25
28
  //
@@ -86,7 +89,9 @@ if (rootIds.length === 0) {
86
89
  }
87
90
 
88
91
  // Goal -> numeric priority threshold.
89
- // Exit when open issues in sprint-goal subtree at priority <= threshold reaches zero.
92
+ // Exit when open LEAF work in the sprint-goal subtree at priority <= threshold reaches
93
+ // zero -- open type=task (plus type=feature when integ tests run), excluding the roots
94
+ // themselves (roots close only at Harvest, so counting them would make goalMet unreachable).
90
95
  const GOAL_THRESHOLD = { 'P1': 1, 'P1/P2': 2, 'P1/P2/P3': 3 };
91
96
  const threshold = GOAL_THRESHOLD[goal] || 2;
92
97
 
@@ -140,12 +145,13 @@ const SHELL_OUTPUTS_SCHEMA = {
140
145
  };
141
146
 
142
147
  const SETUP_SCHEMA = {
143
- type: 'object', required: ['repo', 'branch', 'deployMdExists', 'playbookExists', 'startedAt'],
148
+ type: 'object', required: ['repo', 'branch', 'deployMdExists', 'playbookExists', 'regressionPlaybookExists', 'startedAt'],
144
149
  properties: {
145
150
  repo: { type: 'string' },
146
151
  branch: { type: 'string' },
147
152
  deployMdExists: { type: 'boolean' },
148
153
  playbookExists: { type: 'boolean' },
154
+ regressionPlaybookExists: { type: 'boolean', description: 'regression-test-playbook.md exists -- gates the once-per-sprint regression pass' },
149
155
  startedAt: { type: 'string', description: 'yyyymmdd_hhmmss from date +%Y%m%d_%H%M%S' },
150
156
  calibrationRaw: { type: 'string' }, // verbatim stdout of cat calibration.json; JS parses it
151
157
  transcriptDir: { type: 'string', description: 'Directory where subagent JSONL conversation logs are written (best-effort; may be empty string if not resolvable)' },
@@ -225,6 +231,7 @@ const DEFAULT_CALIBRATION = {
225
231
  'plan-reviewer': TIER_STANDARD,
226
232
  'deployer': TIER_STANDARD,
227
233
  'integ-test-runner': TIER_STANDARD,
234
+ 'regression-test-runner': TIER_STANDARD,
228
235
  'ci-watcher': TIER_CHEAP,
229
236
  'harvester': TIER_STANDARD,
230
237
  'log-flush': TIER_CHEAP,
@@ -259,6 +266,16 @@ const DEFAULT_CALIBRATION = {
259
266
  planner: 2000,
260
267
  plan_reviewer: 1500,
261
268
  harvester: 3000,
269
+ // regression-test-runner runs ONCE PER SPRINT (Finalization, after Final Review),
270
+ // so it belongs here rather than in the per-cycle costing. integ-test-runner has no
271
+ // entry here on purpose -- it runs every cycle, not once per sprint.
272
+ // NOTE: this key is joined to actuals by computeSprintAnalysis's roleOf(), which
273
+ // derives the role from the DISPATCH LABEL. The regression dispatch below must
274
+ // therefore keep label: 'regression-test-runner' -- underscores here, dashes there.
275
+ // An earlier cut labelled it 'regression-runner', which mapped to a nonexistent
276
+ // 'regression_runner' key and silently dropped this role from the calibration
277
+ // outlier/suggestion pass.
278
+ regression_test_runner: 3000,
262
279
  ci_watcher: 300,
263
280
  log_flush_per_cycle: 100,
264
281
  },
@@ -327,7 +344,9 @@ function computeSprintQuote(taskAssignments, calibration) {
327
344
 
328
345
  const tasks = (taskAssignments || []).map(t => {
329
346
  const model = t.model || fallback;
330
- const histToks = (hist.bucket_avg_tokens || {})[t.bucket];
347
+ const tupleKey = `doer|${t.bucket}|${model}`;
348
+ const tupleData = (hist.tuple_averages || {})[tupleKey];
349
+ const histToks = tupleData ? tupleData.avg_output_tokens : (hist.bucket_avg_tokens || {})[t.bucket];
331
350
  const doerTokens = (hist.sprints_sampled >= 1 && histToks != null)
332
351
  ? Math.round(histToks) : (buckets[t.bucket] || buckets.M).doer_tokens;
333
352
  const reviewerTokens = Math.round(doerTokens * revRatio);
@@ -494,44 +513,126 @@ function accumulateBucketTokens(logEntries, taskAssignments) {
494
513
  return acc;
495
514
  }
496
515
 
516
+ function accumulateTupleTokens(logEntries, taskAssignments) {
517
+ const bucketOf = {};
518
+ for (const t of (taskAssignments || [])) {
519
+ if (t && t.id != null && t.bucket != null) bucketOf[String(t.id)] = t.bucket;
520
+ }
521
+ const acc = {}; // key: "role|size|model"
522
+ for (const e of (logEntries || [])) {
523
+ let role = e.label || '';
524
+ role = role.replace(/-c\d.*$/, '');
525
+
526
+ // Map tier names to actual model family names
527
+ let tier = (e.model || 'standard').toLowerCase();
528
+ let model = 'sonnet'; // default
529
+ if (tier === 'premium' || tier === 'opus') model = 'opus';
530
+ else if (tier === 'cheap' || tier === 'haiku') model = 'haiku';
531
+
532
+ const tokens = e.outTokens || 0;
533
+ if (tokens <= 0) continue;
534
+
535
+ let size = 'N/A';
536
+ let share = tokens;
537
+
538
+ if (role === 'doer') {
539
+ const ctx = String(e.context || '');
540
+ const m = ctx.match(/tasks\s+(.+)$/i);
541
+ if (m) {
542
+ const ids = m[1].split(',').map(s => s.trim()).filter(Boolean);
543
+ const buckets = ids.map(id => bucketOf[id]).filter(b => b != null);
544
+ if (buckets.length > 0) {
545
+ share = tokens / buckets.length;
546
+ for (const b of buckets) {
547
+ const key = `${role}|${b}|${model}`;
548
+ if (!acc[key]) acc[key] = { role, size: b, model, tokens: 0, n: 0 };
549
+ acc[key].tokens += share;
550
+ acc[key].n += 1;
551
+ }
552
+ continue;
553
+ }
554
+ }
555
+ }
556
+
557
+ // For non-doer or doer without bucket
558
+ const key = `${role}|${size}|${model}`;
559
+ if (!acc[key]) acc[key] = { role, size, model, tokens: 0, n: 0 };
560
+ acc[key].tokens += share;
561
+ acc[key].n += 1;
562
+ }
563
+ return acc;
564
+ }
565
+
497
566
  function computeUpdatedCalibration(calibration, analysis, startedAt, taskAssignments, logEntries) {
498
567
  const hist = JSON.parse(JSON.stringify(calibration.historical || {}));
499
- const max = hist.max_sprints_in_sample || 5;
500
- const prev = Math.min(hist.sprints_sampled || 0, max - 1);
501
- const n = prev + 1;
502
- const blend = (old, val) => old == null ? val : (old * prev + val) / n;
568
+ const max = hist.max_samples_in_average || 50;
569
+
570
+ const blend_multi = (oldAvg, oldN, sumM, m, maxN) => {
571
+ if (oldAvg == null || oldN == null || oldN === 0) return { avg: sumM / m, n: Math.min(m, maxN) };
572
+ const nextN = oldN + m;
573
+ const avg = (oldN * oldAvg + sumM) / nextN;
574
+ return { avg, n: Math.min(nextN, maxN) };
575
+ };
503
576
 
504
- hist.sprints_sampled = n;
577
+ hist.sprints_sampled = (hist.sprints_sampled || 0) + 1;
505
578
  hist.last_updated = startedAt.replace(/^(\d{4})(\d{2})(\d{2}).*/, '$1-$2-$3');
506
- hist.cycle_avg = blend(hist.cycle_avg, analysis.actualCycles);
507
- hist.roles = hist.roles || {};
579
+
580
+ const b_cycle = blend_multi(hist.cycle_avg, hist.cycle_sample_n || 0, analysis.actualCycles, 1, max);
581
+ hist.cycle_avg = b_cycle.avg;
582
+ hist.cycle_sample_n = b_cycle.n;
583
+
584
+ hist.roles = hist.roles || {};
508
585
 
509
586
  for (const [role, data] of Object.entries(analysis.byRole)) {
510
587
  if (data.tokens === 0) continue;
511
- const avg = data.tokens / data.dispatches;
512
588
  const prev_r = hist.roles[role] || { avg_output_tokens: null, sample_n: 0 };
589
+ const b = blend_multi(prev_r.avg_output_tokens, prev_r.sample_n, data.tokens, data.dispatches, max);
513
590
  hist.roles[role] = {
514
- avg_output_tokens: blend(prev_r.avg_output_tokens, avg),
515
- sample_n: prev_r.sample_n + data.dispatches,
591
+ avg_output_tokens: b.avg,
592
+ sample_n: b.n,
516
593
  };
517
594
  }
518
595
 
519
596
  const doerTok = analysis.byRole['doer']?.tokens || 0;
520
597
  const revTok = analysis.byRole['reviewer']?.tokens || 0;
521
- if (doerTok > 0) hist.reviewer_ratio_avg = blend(hist.reviewer_ratio_avg, revTok / doerTok);
598
+ if (doerTok > 0) {
599
+ const b_ratio = blend_multi(hist.reviewer_ratio_avg, hist.reviewer_ratio_sample_n || 0, revTok / doerTok, 1, max);
600
+ hist.reviewer_ratio_avg = b_ratio.avg;
601
+ hist.reviewer_ratio_sample_n = b_ratio.n;
602
+ }
522
603
 
523
604
  // bucket_avg_tokens join: attribute each doer log entry's outTokens to the
524
605
  // S/M/L bucket(s) of the task IDs in its context string, then blend the
525
- // per-bucket average into hist.bucket_avg_tokens using the same sprints_sampled
526
- // accounting as roles above. Buckets with no data this sprint keep their prior
527
- // value untouched (and unexercised buckets stay absent), so computeSprintQuote
528
- // defaults still apply where we have no history.
606
+ // per-bucket average into hist.bucket_avg_tokens using the sample count.
529
607
  hist.bucket_avg_tokens = hist.bucket_avg_tokens || {};
608
+ hist.bucket_sample_n = hist.bucket_sample_n || {};
609
+
530
610
  const bucketAcc = accumulateBucketTokens(logEntries, taskAssignments);
531
611
  for (const [bucket, data] of Object.entries(bucketAcc)) {
532
612
  if (data.n === 0) continue;
533
- const avg = data.tokens / data.n;
534
- hist.bucket_avg_tokens[bucket] = blend(hist.bucket_avg_tokens[bucket], avg);
613
+ const prevAvg = hist.bucket_avg_tokens[bucket];
614
+ const prevN = hist.bucket_sample_n[bucket] || 0;
615
+
616
+ const b_bucket = blend_multi(prevAvg, prevN, data.tokens, data.n, max);
617
+ hist.bucket_avg_tokens[bucket] = b_bucket.avg;
618
+ hist.bucket_sample_n[bucket] = b_bucket.n;
619
+ }
620
+
621
+ // tuple_averages join: track averages per (role, size, model)
622
+ hist.tuple_averages = hist.tuple_averages || {};
623
+ const tupleAcc = accumulateTupleTokens(logEntries, taskAssignments);
624
+ for (const [key, data] of Object.entries(tupleAcc)) {
625
+ if (data.n === 0) continue;
626
+ const prev = hist.tuple_averages[key] || { avg_output_tokens: null, sample_n: 0, role: data.role, size: data.size, model: data.model };
627
+
628
+ const b_tuple = blend_multi(prev.avg_output_tokens, prev.sample_n, data.tokens, data.n, max);
629
+ hist.tuple_averages[key] = {
630
+ role: data.role,
631
+ size: data.size,
632
+ model: data.model,
633
+ avg_output_tokens: b_tuple.avg,
634
+ sample_n: b_tuple.n
635
+ };
535
636
  }
536
637
 
537
638
  return { ...calibration, historical: hist };
@@ -562,18 +663,38 @@ function collectSubtreeIds(outputs, rootCount) {
562
663
  // the sprint-goal subtree. Missing/short outputs => sentinel {count: 999, ids: []} so the
563
664
  // caller treats blockers as present (fail-safe, never exits the sprint early).
564
665
  // openListIdx is the explicit index of the open-issues JSON command in outputs[].
565
- // rootIds (optional): when provided, only open issues whose ID is in this array are counted
566
- // as blockers (exit-check is scoped to sprint roots, not the whole subtree).
567
- function parseBlockers(outputs, rootCount, openListIdx, threshold, rootIds) {
666
+ //
667
+ // opts (optional object) selects the counting mode:
668
+ // - omitted (4-arg form): counts EVERY open subtree issue at priority<=threshold
669
+ // (subtree-scoped; the historical default, exercised by shell-dispatch /
670
+ // merged-parser-index).
671
+ // - { leaf: true, rootIds, includeFeatures }: SUBTREE LEAF done-condition. Counts open
672
+ // type=task at priority<=threshold EXCLUDING rootIds, PLUS open type=feature EXCLUDING
673
+ // rootIds ONLY when includeFeatures is true. Roots close only at Harvest and features
674
+ // close in-loop only when integ tests run, so counting either otherwise would make the
675
+ // goalMet exit unreachable in-loop. Open issues missing an issue_type (t) are treated as
676
+ // neither task nor feature -> not counted (safe).
677
+ // - { rootIds } (no leaf): legacy roots-only scoping, kept for back-compat callers.
678
+ function parseBlockers(outputs, rootCount, openListIdx, threshold, opts) {
568
679
  if (!Array.isArray(outputs) || outputs.length < openListIdx + 1) return { count: 999, ids: [] };
680
+ const { rootIds, leaf, includeFeatures } = (opts && typeof opts === 'object') ? opts : {};
569
681
  const subtree = collectSubtreeIds(outputs, rootCount);
570
- const rootSet = Array.isArray(rootIds) && rootIds.length > 0 ? new Set(rootIds) : null;
682
+ const rootSet = new Set(Array.isArray(rootIds) ? rootIds : []);
571
683
  let ids = [];
572
684
  try {
573
685
  const open = JSON.parse(outputs[openListIdx]);
574
- ids = Array.isArray(open)
575
- ? open.filter(x => subtree.has(x.id) && (!rootSet || rootSet.has(x.id)) && x.p <= threshold).map(x => x.id)
576
- : [];
686
+ if (!Array.isArray(open)) {
687
+ ids = [];
688
+ } else if (leaf) {
689
+ ids = open.filter(x =>
690
+ subtree.has(x.id) && !rootSet.has(x.id) && x.p <= threshold &&
691
+ (x.t === 'task' || (includeFeatures && x.t === 'feature'))
692
+ ).map(x => x.id);
693
+ } else {
694
+ ids = open.filter(x =>
695
+ subtree.has(x.id) && (rootSet.size === 0 || rootSet.has(x.id)) && x.p <= threshold
696
+ ).map(x => x.id);
697
+ }
577
698
  } catch { ids = []; }
578
699
  return { count: ids.length, ids };
579
700
  }
@@ -1021,6 +1142,7 @@ function assertCalibrationComplete(calibration, defaults) {
1021
1142
  'fixed_overhead_tokens.planner',
1022
1143
  'fixed_overhead_tokens.plan_reviewer',
1023
1144
  'fixed_overhead_tokens.harvester',
1145
+ 'fixed_overhead_tokens.regression_test_runner',
1024
1146
  'fixed_overhead_tokens.ci_watcher',
1025
1147
  'fixed_overhead_tokens.log_flush_per_cycle',
1026
1148
  'input_cost_multiplier.value',
@@ -1160,10 +1282,10 @@ function worktreeNamesFor(sprintBranch, taskId, worktreeRoot) {
1160
1282
  // ROLE_SCHEMAS_GENERATED_BEGIN -- do not hand-edit; run `node scripts/gen-auto-sprint-schemas.mjs` to regenerate from agents/schemas/*.json
1161
1283
  //
1162
1284
  // apra-fleet-unw.21 / apra-fleet e2e s10 (2026-07-17): the role-contract schemas
1163
- // below are generated from vendor/apra-pm's own canonical, machine-readable role
1285
+ // below are generated from packages/apra-fleet-se/apra-pm's own canonical, machine-readable role
1164
1286
  // contracts at agents/schemas/<role>-output.json, instead of being hand-copied
1165
1287
  // inline literals -- this closes the drift this file used to have from the
1166
- // vendored agents/*.md prose and from packages/apra-fleet-se/auto-sprint/contracts.mjs.
1288
+ // agents/*.md prose and from packages/apra-fleet-se/fleet-sprint/contracts.mjs.
1167
1289
  // The "version" key present in each source file is dropped: it is a non-standard
1168
1290
  // JSON-Schema keyword the agent tool's strict schema validator rejects.
1169
1291
  //
@@ -1200,6 +1322,12 @@ const REVIEW_SCHEMA = {
1200
1322
  "type": "string"
1201
1323
  }
1202
1324
  },
1325
+ "replanIds": {
1326
+ "type": "array",
1327
+ "items": {
1328
+ "type": "string"
1329
+ }
1330
+ },
1203
1331
  "newTasks": {
1204
1332
  "type": "array",
1205
1333
  "items": {
@@ -1355,6 +1483,116 @@ const INTEG_RUN_SCHEMA = {
1355
1483
  },
1356
1484
  "summary": {
1357
1485
  "type": "string"
1486
+ },
1487
+ "deployedSha": {
1488
+ "type": "string",
1489
+ "description": "The deploy-verified git commit part 2 (smoke test) actually ran against. Optional for backward compatibility, but an orchestrator that supplied a deployed SHA in the dispatch prompt treats a missing or mismatching value as INCONCLUSIVE evidence (never a pass). See integ-test-runner.md 'Part-2 evidence freshness'."
1490
+ },
1491
+ "verifySetClosed": {
1492
+ "type": "array",
1493
+ "items": {
1494
+ "type": "string"
1495
+ },
1496
+ "description": "apra-fleet-jfo: verify-set bead ids (any issue_type, Step 1b) closed this run. Optional for backward compatibility -- absent/omitted on a dispatch that named no verify-set ids."
1497
+ },
1498
+ "verifySetLeftOpen": {
1499
+ "type": "array",
1500
+ "items": {
1501
+ "type": "object",
1502
+ "required": [
1503
+ "id",
1504
+ "reason"
1505
+ ],
1506
+ "properties": {
1507
+ "id": {
1508
+ "type": "string"
1509
+ },
1510
+ "reason": {
1511
+ "type": "string"
1512
+ }
1513
+ }
1514
+ },
1515
+ "description": "apra-fleet-jfo: verify-set bead ids (Step 1b) left open this run, with why (gap bug filed, or inconclusive). Optional for backward compatibility."
1516
+ },
1517
+ "observedFailures": {
1518
+ "type": "array",
1519
+ "items": {
1520
+ "type": "object",
1521
+ "required": [
1522
+ "test",
1523
+ "cause",
1524
+ "beadId"
1525
+ ],
1526
+ "properties": {
1527
+ "test": {
1528
+ "type": "string"
1529
+ },
1530
+ "cause": {
1531
+ "type": "string"
1532
+ },
1533
+ "beadId": {
1534
+ "type": "string"
1535
+ }
1536
+ }
1537
+ },
1538
+ "description": "Out-of-scope test failures observed per integ-test-runner.md Step 1c, each cross-linked to an existing bead or a newly filed one. Optional for backward compatibility -- absent/omitted when no out-of-scope failures were observed."
1539
+ }
1540
+ }
1541
+ };
1542
+ const REGRESSION_RUN_SCHEMA = {
1543
+ "$schema": "http://json-schema.org/draft-07/schema#",
1544
+ "$id": "apra-pm/regression-test-runner-output@1",
1545
+ "title": "regression-test-runner output",
1546
+ "description": "Canonical machine-readable output contract for the regression-test-runner role. See agents/regression-test-runner.md Step 4 for the prose contract this mirrors. This result is informational: it never gates the current sprint's PASS/FAIL verdict -- failures carry over to a future sprint as parent-less [regression][carry-over] beads.",
1547
+ "type": "object",
1548
+ "required": [
1549
+ "passed",
1550
+ "suitePassed",
1551
+ "smokePassed",
1552
+ "bugsFiled",
1553
+ "summary"
1554
+ ],
1555
+ "properties": {
1556
+ "passed": {
1557
+ "type": "boolean",
1558
+ "description": "True only if BOTH suitePassed and smokePassed are true AND no carry-over bug was filed this run."
1559
+ },
1560
+ "suitePassed": {
1561
+ "type": "boolean",
1562
+ "description": "Result of playbook Part 1 -- the real-bd functional suite."
1563
+ },
1564
+ "smokePassed": {
1565
+ "type": "boolean",
1566
+ "description": "Result of playbook Part 2 -- the toy-sprint smoke test."
1567
+ },
1568
+ "bugsFiled": {
1569
+ "type": "array",
1570
+ "items": {
1571
+ "type": "string"
1572
+ },
1573
+ "description": "Ids of the standalone, parent-less [regression][carry-over] beads created this run (empty array if none)."
1574
+ },
1575
+ "summary": {
1576
+ "type": "string",
1577
+ "description": "One paragraph describing what was tested, what passed, what failed, and reiterating that the result is informational."
1578
+ },
1579
+ "smokeEvidence": {
1580
+ "type": "object",
1581
+ "description": "Optional structured evidence from Part 2 (the toy-sprint smoke test), so the result is machine-checkable instead of self-reported prose.",
1582
+ "properties": {
1583
+ "versionStdout": {
1584
+ "type": "string",
1585
+ "description": "Verbatim stdout of running the toy CLI's --version on the sprint branch."
1586
+ },
1587
+ "canaryStatus": {
1588
+ "type": "string",
1589
+ "description": "The status field from `bd show gh-toy-4ef` (e.g. \"closed\")."
1590
+ },
1591
+ "toyRepoHeadSha": {
1592
+ "type": "string",
1593
+ "description": "The toy repo's head commit SHA after the toy sprint."
1594
+ }
1595
+ }
1358
1596
  }
1359
1597
  }
1360
1598
  };
@@ -1543,16 +1781,18 @@ function bdSubtreeSnippet(rootsArr) {
1543
1781
  `while(_q.length>0){const _c=_q.shift();const _n=_nodes[_c];if(_n&&_n.DependsOn){for(const _dd of _n.DependsOn){if(!subtree.has(_dd)){subtree.add(_dd);_q.push(_dd);}}}}`;
1544
1782
  }
1545
1783
 
1546
- async function countBeadsBlockers(thr, roots) {
1784
+ async function countBeadsBlockers(thr, roots, includeFeatures) {
1547
1785
  // Extract only IDs from bd graph to keep output small (avoids $(cat ...) file-reference issue).
1548
1786
  const idExtract = `node -e "const d=require('fs').readFileSync(0,'utf8');try{const g=JSON.parse(${BD_JSON});${bdSubtreeSnippet(roots)}console.log(Array.from(subtree).join(' '))}catch{}"`;
1549
- const openExtract = `node -e "const d=require('fs').readFileSync(0,'utf8');try{console.log(JSON.stringify(JSON.parse(${BD_JSON}).map(i=>({id:i.id,p:i.priority}))))}catch{console.log('[]')}"`;
1787
+ const openExtract = `node -e "const d=require('fs').readFileSync(0,'utf8');try{console.log(JSON.stringify(JSON.parse(${BD_JSON}).map(i=>({id:i.id,p:i.priority,t:i.issue_type}))))}catch{console.log('[]')}"`;
1550
1788
  const cmds = [
1551
1789
  ...roots.map(id => `bd graph --json ${id} | ${idExtract}`),
1552
1790
  `bd list --status=open --json | ${openExtract}`,
1553
1791
  ];
1554
1792
  const r = await dispatchShell(cmds, { model: MODEL_HAIKU, label: 'check-blockers', phase: 'Develop' });
1555
- return parseBlockers(r?.outputs, roots.length, roots.length, thr, roots);
1793
+ // Leaf-scoped done-condition: open non-root type=task at priority<=thr, plus type=feature
1794
+ // only when includeFeatures (integ tests close features in-loop). See parseBlockers opts.
1795
+ return parseBlockers(r?.outputs, roots.length, roots.length, thr, { rootIds: roots, leaf: true, includeFeatures });
1556
1796
  }
1557
1797
 
1558
1798
  async function getReadyStreaks(rootIds) {
@@ -1675,7 +1915,7 @@ phase('Plan');
1675
1915
  // Phase 1: deterministic setup steps -- run via dispatchShell so each command
1676
1916
  // executes exactly once with a bounded turn cap (no LLM looping on simple checks).
1677
1917
  //
1678
- // Fixed output indices (always 8 elements regardless of branch/no-branch):
1918
+ // Fixed output indices (always 9 elements regardless of branch/no-branch):
1679
1919
  // 0: repo root (git rev-parse --show-toplevel)
1680
1920
  // 1: fetch result (FETCHED / FETCH_FAIL) -- run BEFORE checkout so a new sprint
1681
1921
  // branch is cut from the freshest origin/<base_branch> (guards stale-main branching).
@@ -1687,12 +1927,14 @@ phase('Plan');
1687
1927
  // 4: startedAt timestamp (date +%Y%m%d_%H%M%S)
1688
1928
  // 5: deploy.md exists (YES/NO)
1689
1929
  // 6: integ-test-playbook.md exists (YES/NO)
1690
- // 7: newline-joined list of permission entries declared in deploy.md /
1691
- // integ-test-playbook.md's "## Permissions" sections that are NOT yet
1692
- // in .claude/settings.json's permissions.allow (empty string if none --
1693
- // computed deterministically here so Step 5's prompt to the agent never
1694
- // has to say "you may grant yourself permissions" when there's nothing
1695
- // to grant).
1930
+ // 7: regression-test-playbook.md exists (YES/NO) -- gates the once-per-sprint
1931
+ // regression pass (regression-test-runner) in the Finalization stage
1932
+ // 8: newline-joined list of permission entries declared in deploy.md /
1933
+ // integ-test-playbook.md / regression-test-playbook.md's "## Permissions"
1934
+ // sections that are NOT yet in .claude/settings.json's permissions.allow
1935
+ // (empty string if none -- computed deterministically here so Step 5's
1936
+ // prompt to the agent never has to say "you may grant yourself
1937
+ // permissions" when there's nothing to grant).
1696
1938
  const setupShellCmds = [
1697
1939
  `git rev-parse --show-toplevel`,
1698
1940
  // Fetch first so branch creation below can base a NEW sprint branch on the freshest
@@ -1715,6 +1957,7 @@ const setupShellCmds = [
1715
1957
  `date +%Y%m%d_%H%M%S`,
1716
1958
  `test -f deploy.md && echo YES || echo NO`,
1717
1959
  `test -f integ-test-playbook.md && echo YES || echo NO`,
1960
+ `test -f regression-test-playbook.md && echo YES || echo NO`,
1718
1961
  `node -e "` +
1719
1962
  `const fs=require('fs');` +
1720
1963
  `function permsFrom(file){` +
@@ -1729,7 +1972,7 @@ const setupShellCmds = [
1729
1972
  `return(section.match(/^[ \\t]*[-*]?[ \\t]*[A-Za-z_][A-Za-z0-9_]*\\([^\\n]*\\)[ \\t]*$/gm)||[])` +
1730
1973
  `.map(s=>s.replace(/^[ \\t]*[-*]?[ \\t]*/,'').trim());` +
1731
1974
  `}` +
1732
- `const declared=[...new Set([...permsFrom('deploy.md'),...permsFrom('integ-test-playbook.md')])];` +
1975
+ `const declared=[...new Set([...permsFrom('deploy.md'),...permsFrom('integ-test-playbook.md'),...permsFrom('regression-test-playbook.md')])];` +
1733
1976
  `let existing=[];` +
1734
1977
  `try{existing=(JSON.parse(fs.readFileSync('.claude/settings.json','utf8')).permissions||{}).allow||[];}catch(e){}` +
1735
1978
  `const missing=declared.filter(p=>!existing.includes(p));` +
@@ -1748,7 +1991,8 @@ const _detectedBranch = (_outs[3] || '').trim();
1748
1991
  const _detectedTs = (_outs[4] || '').trim();
1749
1992
  const _deployExists = (_outs[5] || '').trim() === 'YES';
1750
1993
  const _playbookExists = (_outs[6] || '').trim() === 'YES';
1751
- const _missingPerms = (_outs[7] || '').trim().split(/\r?\n/).map(s => s.trim()).filter(Boolean);
1994
+ const _regressionPlaybookExists = (_outs[7] || '').trim() === 'YES';
1995
+ const _missingPerms = (_outs[8] || '').trim().split(/\r?\n/).map(s => s.trim()).filter(Boolean);
1752
1996
 
1753
1997
  if (!_detectedRepo || !_detectedBranch) {
1754
1998
  log('ERROR: setup-shell failed -- could not detect repo root or branch');
@@ -1771,8 +2015,9 @@ const step5Block = _missingPerms.length > 0
1771
2015
  ` nothing else, and do not remove or modify anything else in the file:\n` +
1772
2016
  _missingPerms.map(p => ` - ${p}`).join('\n') + `\n\n`
1773
2017
  )
1774
- : `Step 5: Already satisfied -- every permission declared in deploy.md / integ-test-playbook.md\n` +
1775
- ` is already present in .claude/settings.json. Do nothing for this step.\n\n`;
2018
+ : `Step 5: Already satisfied -- every permission declared in deploy.md /\n` +
2019
+ ` integ-test-playbook.md / regression-test-playbook.md is already present in\n` +
2020
+ ` .claude/settings.json. Do nothing for this step.\n\n`;
1776
2021
  const setup = await dispatch(
1777
2022
  `Sprint workspace setup (Phase 2 -- deterministic steps already done).\n\n` +
1778
2023
  `Pre-known values (do NOT re-run these commands):\n` +
@@ -1780,7 +2025,8 @@ const setup = await dispatch(
1780
2025
  ` branch: ${_detectedBranch}\n` +
1781
2026
  ` startedAt: ${_detectedTs}\n` +
1782
2027
  ` deployMdExists: ${_deployExists}\n` +
1783
- ` playbookExists: ${_playbookExists}\n\n` +
2028
+ ` playbookExists: ${_playbookExists}\n` +
2029
+ ` regressionPlaybookExists: ${_regressionPlaybookExists}\n\n` +
1784
2030
  `Your job is only Steps 5-7 below. Return ALL fields in your schema response,\n` +
1785
2031
  `including the pre-known values above.\n\n` +
1786
2032
  step5Block +
@@ -1801,7 +2047,7 @@ const setup = await dispatch(
1801
2047
  ` Run: ls "$HOME/.claude/projects/" 2>/dev/null\n` +
1802
2048
  ` Find the entry whose slug matches the repo path (e.g. repo=/c/foo/bar -> C--foo-bar).\n` +
1803
2049
  ` If found, return the full path as transcriptDir. If not found, return an empty string.\n\n` +
1804
- `Return repo (absolute path), branch (confirmed), deployMdExists, playbookExists, startedAt, calibrationRaw, transcriptDir.`,
2050
+ `Return repo (absolute path), branch (confirmed), deployMdExists, playbookExists, regressionPlaybookExists, startedAt, calibrationRaw, transcriptDir.`,
1805
2051
  { model: MODEL_HAIKU, label: 'setup', phase: 'Plan', schema: SETUP_SCHEMA, maxTurns: 20 }
1806
2052
  );
1807
2053
 
@@ -1907,6 +2153,10 @@ let taskAssignments = [];
1907
2153
  const sprintLogBranch = branch.replace(/[^a-zA-Z0-9._-]/g, '-').replace(/-{2,}/g, '-').replace(/^-|-$/g, '') || 'default';
1908
2154
  const sprintLogFile = `sprint-logs/${sprintLogBranch}-${effectiveStartedAt}.jsonl`;
1909
2155
  const integTestEnabled = setup.deployMdExists && setup.playbookExists;
2156
+ // The once-per-sprint regression pass is independent of the per-cycle Test phase: it needs
2157
+ // only its own playbook (it provisions its own sandbox and runs against branch HEAD), so it
2158
+ // is NOT gated on deploy.md or on integTestEnabled.
2159
+ const regressionTestEnabled = !!setup.regressionPlaybookExists;
1910
2160
  // startedAt "20260622_020952" -> ISO "2026-06-22T02:09:52Z" (pure string, no Date.now())
1911
2161
  const sprintTs = effectiveStartedAt.replace(/^(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})$/, '$1-$2-$3T$4:$5:$6Z');
1912
2162
  let flushedCount = 0; // how many dispatchLedger entries have been appended to sprintLogFile
@@ -1952,10 +2202,11 @@ async function appendNewEntries(label, phase) {
1952
2202
  }
1953
2203
 
1954
2204
  log(`Repo: ${repo} | Branch: ${setup.branch}`);
1955
- log(`deploy.md: ${setup.deployMdExists} | integ-test-playbook.md: ${setup.playbookExists}`);
2205
+ log(`deploy.md: ${setup.deployMdExists} | integ-test-playbook.md: ${setup.playbookExists} | regression-test-playbook.md: ${setup.regressionPlaybookExists}`);
1956
2206
  if (!setup.deployMdExists) log('WARNING: deploy.md not found -- integration test phase will be skipped');
1957
2207
  if (!setup.playbookExists) log('WARNING: integ-test-playbook.md not found -- integration test phase will be skipped');
1958
2208
  if (!integTestEnabled) log('Integration testing disabled for this sprint. Harvest will run after Develop.');
2209
+ if (!regressionTestEnabled) log('WARNING: regression-test-playbook.md not found -- the once-per-sprint regression pass will be skipped');
1959
2210
 
1960
2211
  const rootSummary = rootIds.join(', ');
1961
2212
  log(`Sprint goals: ${rootSummary} | Goal: ${goal} (P<=${threshold}) | Max cycles: ${maxCycles}`);
@@ -2054,18 +2305,28 @@ while (cycleCount < maxCycles) {
2054
2305
 
2055
2306
  // ---------------------------------------------------------------- PLAN
2056
2307
 
2057
- let planApproved = cycleState.planDone;
2308
+ let planApproved = false;
2058
2309
  let planFeedback = '';
2310
+ const priorVerdicts = [];
2059
2311
  const MAX_PLAN_ITER = 3;
2060
2312
 
2061
- if (planApproved) {
2062
- log(`Plan already complete -- skipping plan loop for cycle ${cycleCount}`);
2313
+ if (cycleState.planDone) {
2314
+ // F6: a planDone/resumed cycle still runs one plan-reviewer pass -- we only skip the
2315
+ // expensive PLANNER dispatch on round 0. The reviewer still routes through
2316
+ // approved(planReview), so taskAssignments/sprintQuote populate and the quality gate
2317
+ // is enforced; a CHANGES_NEEDED verdict re-enables the planner on later rounds.
2318
+ log(`Plan already complete for cycle ${cycleCount} -- skipping the planner dispatch on round 0, still running the plan-reviewer`);
2063
2319
  }
2064
2320
 
2065
2321
  for (let pi = 0; pi < MAX_PLAN_ITER && !planApproved; pi++) {
2066
2322
  const plannerLabel = `planner-c${cycleCount}-r${pi}`;
2067
2323
 
2068
- const plannerResult = await dispatch(
2324
+ // F6: skip the planner only on the first round of a planDone cycle; always run it on
2325
+ // later rounds (a rejection re-enables planning). Fall straight through to the reviewer.
2326
+ const skipPlanner = pi === 0 && cycleState.planDone;
2327
+ let plannerResult = null;
2328
+ if (!skipPlanner) {
2329
+ plannerResult = await dispatch(
2069
2330
  `Repo: ${repo}\nBranch: ${branch}\nBase branch: ${base_branch}\n` +
2070
2331
  `Sprint goals: ${rootSummary}\n` +
2071
2332
  (requirementsFile ? `Additional context: ${requirementsFile}\n` : '') +
@@ -2097,10 +2358,14 @@ while (cycleCount < maxCycles) {
2097
2358
  ` until the impl task closes -- correct: they are siblings). Same pattern for any\n` +
2098
2359
  ` later sibling task that depends on an earlier one.\n` +
2099
2360
  `\n` +
2100
- ` VERIFY after wiring: run "bd list --parent <goal-id> --ready --json" for each sprint\n` +
2101
- ` goal -- it must be non-empty while open work exists under that goal. If it is empty,\n` +
2102
- ` there is a cycle: find the blocks edge pointing at a --parent ancestor/descendant\n` +
2103
- ` and remove it with bd dep remove.\n` +
2361
+ ` VERIFY after wiring: run "bd list --parent <goal-id> --ready --type=task --json" for\n` +
2362
+ ` EACH sprint goal and reason over the COMBINED result. The union of ready work across\n` +
2363
+ ` all goals must be non-empty while open work remains anywhere in scope. A single goal\n` +
2364
+ ` with an empty ready-list is FINE when its tasks are legitimately blocked by an open\n` +
2365
+ ` task in ANOTHER goal (a cross-goal ordering edge) -- do NOT remove that edge. Only if\n` +
2366
+ ` the UNION is empty while open work remains, or a goal's task blocks via an edge to its\n` +
2367
+ ` own --parent ancestor/descendant, is there a real cycle: find that parent/descendant\n` +
2368
+ ` blocks edge and remove it with bd dep remove.\n` +
2104
2369
  `\n` +
2105
2370
  ` IMPORTANT: Each task belongs to exactly ONE feature. Never share a task across features.\n` +
2106
2371
  `\n` +
@@ -2129,9 +2394,10 @@ while (cycleCount < maxCycles) {
2129
2394
  context: `planning sprint goals ${rootSummary}` }
2130
2395
  );
2131
2396
 
2132
- if (!plannerResult) {
2133
- log(`Planner returned null on cycle ${cycleCount} round ${pi} -- retrying`);
2134
- continue;
2397
+ if (!plannerResult) {
2398
+ log(`Planner returned null on cycle ${cycleCount} round ${pi} -- retrying`);
2399
+ continue;
2400
+ }
2135
2401
  }
2136
2402
 
2137
2403
  const planReviewerLabel = `plan-reviewer-c${cycleCount}-r${pi}`;
@@ -2139,10 +2405,19 @@ while (cycleCount < maxCycles) {
2139
2405
  `Repo: ${repo}\nBranch: ${branch}\nSprint goals: ${rootSummary}\n` +
2140
2406
  `Calibration file: ${repo}/sprint-logs/calibration.json (read this first if it exists)\n\n` +
2141
2407
  `Review the beads DAG for these sprint goals ONLY: ${rootSummary}\n` +
2408
+ (priorVerdicts.length > 0
2409
+ ? `Prior-round verdicts for THIS review cycle (most recent last) -- these BIND per your ` +
2410
+ `No-goalpost-moving rule; do not re-litigate a criterion an earlier round already ` +
2411
+ `accepted unless you cite NEW evidence:\n` +
2412
+ priorVerdicts.map(v => ` Round ${v.round}: ${v.verdict} -- ${v.notes}\n`).join('') +
2413
+ `\n`
2414
+ : '') +
2142
2415
  `Run: ${rootIds.map(id => `bd show ${id}`).join(' && ')} to inspect each sprint goal.\n` +
2143
2416
  `Run: ${rootIds.map(id => `bd graph --compact ${id}`).join(' && ')} for the full dependency subtree.\n` +
2144
2417
  `Run: bd show <id> to inspect individual issues in depth.\n` +
2145
- `Run: bd ready -- this is your FIRST correctness check.\n` +
2418
+ `Ready-work check (your FIRST correctness check, per runbook Criterion 9): run\n` +
2419
+ `"bd list --parent <root> --ready --type=task --json" for EACH sprint goal and reason\n` +
2420
+ `over the UNION -- do NOT use bare "bd ready" (project-wide, not a signal about this DAG).\n` +
2146
2421
  `Do NOT review or comment on issues outside these sprint goals.\n\n` +
2147
2422
  `Follow your runbook (agents/plan-reviewer.md) step by step:\n` +
2148
2423
  ` Steps 1-2: inspect the DAG and check all quality criteria.\n` +
@@ -2157,6 +2432,15 @@ while (cycleCount < maxCycles) {
2157
2432
  context: `reviewing plan for sprint goals ${rootSummary}` }
2158
2433
  );
2159
2434
 
2435
+ // F2: record this round's verdict so the NEXT round's plan-reviewer receives it as a
2436
+ // binding prior-round input (No-goalpost-moving rule). Null-guarded: a null planReview
2437
+ // records a CHANGES_NEEDED entry rather than crashing.
2438
+ priorVerdicts.push({
2439
+ round: pi,
2440
+ verdict: (planReview && planReview.verdict) || 'CHANGES_NEEDED',
2441
+ notes: (planReview && planReview.notes) || '',
2442
+ });
2443
+
2160
2444
  if (approved(planReview)) {
2161
2445
  planApproved = true;
2162
2446
  log(`Plan APPROVED on cycle ${cycleCount} round ${pi + 1}`);
@@ -2605,15 +2889,18 @@ while (cycleCount < maxCycles) {
2605
2889
 
2606
2890
  // -- Deploy --
2607
2891
  // Role split (agents/deployer.md, agents/integ-test-runner.md): the deployer follows
2608
- // deploy.md ONLY (deploy + smoke test) -- the playbook's Setup/Reset/Teardown belong
2609
- // to integ-test-runner, which owns integ-test-playbook.md end to end. The deployer
2610
- // refuses playbook operations by contract, so never dispatch them to it.
2892
+ // deploy.md ONLY (deploy + smoke test). The sandbox lifecycle (Setup/Reset/Teardown)
2893
+ // lives in regression-test-playbook.md and belongs to regression-test-runner, which
2894
+ // runs once per sprint in Finalization -- not to the deployer and not to this cycle's
2895
+ // integ-test-runner. The deployer refuses playbook operations by contract, so never
2896
+ // dispatch them to it.
2611
2897
  const deployLabel = `deployer-c${cycleCount}`;
2612
2898
  const deployResult = await dispatch(
2613
2899
  `Repo: ${repo}\nBranch: ${branch}\nCycle: ${cycleCount}\n` +
2614
2900
  `operation: deploy\n\n` +
2615
2901
  `Follow your runbook (agents/deployer.md) -- deploy.md ONLY; you do not touch\n` +
2616
- `integ-test-playbook.md (its Setup/Reset/Teardown belong to integ-test-runner):\n` +
2902
+ `integ-test-playbook.md or regression-test-playbook.md (the sandbox lifecycle --\n` +
2903
+ `## Setup / ## Reset / ## Teardown -- belongs to regression-test-runner):\n` +
2617
2904
  `1. Read deploy.md (Deploy, Smoke test, and CI sections).\n` +
2618
2905
  `2. Execute every command in the '## Deploy' section in order.\n` +
2619
2906
  `3. Run the command in '## Smoke test'.\n` +
@@ -2626,39 +2913,43 @@ while (cycleCount < maxCycles) {
2626
2913
  if (!deployResult || !deployResult.deployed) {
2627
2914
  const msg = (deployResult && deployResult.notes) || 'no details';
2628
2915
  log(`Deploy failed on cycle ${cycleCount}: ${msg.slice(0, 200)}`);
2629
- log('Skipping integration tests this cycle -- the test sandbox was never brought up (integ-test-runner owns it), nothing to tear down');
2916
+ log('Skipping feature-closure tests this cycle -- the deploy failed, so there is nothing verified to test against');
2630
2917
  } else {
2631
- // -- Integration test run (scoped to THIS sprint's open features) --
2918
+ // -- Feature-closure test run (scoped to THIS sprint's open features) --
2632
2919
  // Scope the tester to the sprint subtree's open features. Do NOT let it `bd list
2633
2920
  // --type=feature --status=open` (every open feature in the whole DB) -- that would
2634
2921
  // test/close/file-bugs against unrelated features from other epics/sprints.
2635
- // An EMPTY feature list still dispatches the runner: the playbook's two parts are
2636
- // the sprint's standing confidence check (integ-test-runner.md Step 1).
2922
+ // An EMPTY feature list is simply a normal no-op cycle (nothing to close); the
2923
+ // runner is still dispatched and reports zero closed. The sprint's standing
2924
+ // confidence check lives in the once-per-sprint regression pass, not here.
2637
2925
  const _sprintFeatures = await getSprintOpenFeatures(rootIds);
2638
2926
  const integLabel = `integ-runner-c${cycleCount}`;
2639
2927
  const _featList = _sprintFeatures.length > 0
2640
2928
  ? _sprintFeatures.map(f => ` ${f.id} -- ${f.title}`).join('\n')
2641
- : ` (none -- zero open features this cycle; a normal outcome, run the playbook parts only)`;
2929
+ : ` (none -- zero open features this cycle; a normal no-op outcome, report zero closed)`;
2642
2930
  log(`Integration scope: ${_sprintFeatures.length} sprint feature(s)${_sprintFeatures.length ? ` [${labelTaskIds(_sprintFeatures.map(f => f.id))}]` : ''}`);
2643
2931
 
2644
2932
  const integResult = await dispatch(
2645
2933
  `Repo: ${repo}\nBranch: ${branch}\nCycle: ${cycleCount}\n` +
2646
2934
  `Sprint goals: ${rootSummary}\n\n` +
2647
- `Follow your runbook (agents/integ-test-runner.md). You own integ-test-playbook.md\n` +
2648
- `end to end: run part 1 (the real functional suite), bring the sandbox up with the\n` +
2649
- `playbook's ${cycleCount === 1 ? '## Setup' : '## Reset'} section, run the smoke scenario and the per-feature\n` +
2650
- `tests inside it, and ALWAYS run the playbook's ## Teardown before returning --\n` +
2651
- `pass or fail. The product deploy (deploy.md) has already been done by the deployer.\n\n` +
2652
- `Integration-test ONLY these open features from THIS sprint. Do NOT list, test, close, ` +
2935
+ `Follow your runbook (agents/integ-test-runner.md) and integ-test-playbook.md.\n` +
2936
+ `This phase is FEATURE CLOSURE ONLY: repo-local, per-feature test execution against\n` +
2937
+ `the sprint branch working tree. There is no sandbox, no ## Setup / ## Reset /\n` +
2938
+ `## Teardown, and no full suite here -- those live in regression-test-playbook.md and\n` +
2939
+ `run once per sprint under a different role. The product deploy (deploy.md) has\n` +
2940
+ `already been done by the deployer.\n\n` +
2941
+ `Test ONLY these open features from THIS sprint. Do NOT list, test, close, ` +
2653
2942
  `or file bugs against any beads issue that is not in this list (do NOT run ` +
2654
2943
  `"bd list --type=feature"):\n${_featList}\n\n` +
2655
- `Per-feature testing (bd show -> run its tests -> bd close on pass, keep open on ` +
2656
- `failure/inconclusive), [integ] bug filing, priority rules, and duplicate checks ` +
2657
- `(bd search "[integ]") are all in your runbook -- follow it. Parent every new ` +
2658
- `[integ] bug under sprint root ${rootIds[0]} (the scope for this dispatch).\n\n` +
2944
+ `For each feature: bd show <feature> to read its acceptance criteria, bd dep list ` +
2945
+ `<feature> to find its [test] task(s), run exactly those tests, then bd close on a ` +
2946
+ `full pass; on failure leave it open and file an [integ] bug; if the result is ` +
2947
+ `inconclusive leave it open and record a note saying why. Priority rules and ` +
2948
+ `duplicate checks (bd search "[integ]") are in your runbook -- follow it. Parent ` +
2949
+ `every new [integ] bug under sprint root ${rootIds[0]} (the scope for this dispatch).\n\n` +
2659
2950
  `Return the full contract: featuresClosed (count), issuesCreated (count), ` +
2660
2951
  `passed (boolean), bugsFiled (array of created bug ids, [] if none), ` +
2661
- `summary (one paragraph, including the part 1 result line).`,
2952
+ `summary (one paragraph).`,
2662
2953
  { model: MODEL_SONNET, label: integLabel, phase: 'Test', schema: INTEG_RUN_SCHEMA, agentType: 'integ-test-runner' }
2663
2954
  );
2664
2955
  if (integResult) {
@@ -2667,8 +2958,8 @@ while (cycleCount < maxCycles) {
2667
2958
  }
2668
2959
 
2669
2960
  // JIT flush: append test-phase entries (deployer, integ-runner) immediately.
2670
- // No separate teardown dispatch: the runner runs the playbook's Teardown itself,
2671
- // always, before returning (agents/integ-test-runner.md Step 4).
2961
+ // Nothing to tear down here: feature closure is repo-local and provisions no
2962
+ // sandbox (agents/integ-test-runner.md).
2672
2963
  await appendNewEntries(`test-c${cycleCount}`, 'Test');
2673
2964
  }
2674
2965
  }
@@ -2684,7 +2975,7 @@ while (cycleCount < maxCycles) {
2684
2975
  let blockers;
2685
2976
  {
2686
2977
  const _idExtract = `node -e "const d=require('fs').readFileSync(0,'utf8');try{const g=JSON.parse(${BD_JSON});${bdSubtreeSnippet(rootIds)}console.log(Array.from(subtree).join(' '))}catch{}"`;
2687
- const _openExtract = `node -e "const d=require('fs').readFileSync(0,'utf8');try{console.log(JSON.stringify(JSON.parse(${BD_JSON}).map(i=>({id:i.id,p:i.priority}))))}catch{console.log('[]')}"`;
2978
+ const _openExtract = `node -e "const d=require('fs').readFileSync(0,'utf8');try{console.log(JSON.stringify(JSON.parse(${BD_JSON}).map(i=>({id:i.id,p:i.priority,t:i.issue_type}))))}catch{console.log('[]')}"`;
2688
2979
  const _taskExtract = `node -e "const d=require('fs').readFileSync(0,'utf8');try{console.log(JSON.stringify(JSON.parse(${BD_JSON}).map(i=>({id:i.id,p:i.priority,m:(i.metadata||{}).model}))))}catch{console.log('[]')}"`;
2689
2980
  const exitCmds = [
2690
2981
  ...rootIds.map(id => `bd graph --json ${id} | ${_idExtract}`),
@@ -2693,14 +2984,14 @@ while (cycleCount < maxCycles) {
2693
2984
  ];
2694
2985
  const exitResult = await dispatchShell(exitCmds, { model: MODEL_HAIKU, label: 'exit-check', phase: 'Develop' });
2695
2986
  if (exitResult?.outputs && exitResult.outputs.length >= rootIds.length + 2) {
2696
- blockers = parseBlockers(exitResult.outputs, rootIds.length, rootIds.length, threshold, rootIds);
2987
+ blockers = parseBlockers(exitResult.outputs, rootIds.length, rootIds.length, threshold, { rootIds, leaf: true, includeFeatures: integTestEnabled });
2697
2988
  // Ready streaks prefetched but not used: develop loop already determined no ready tasks.
2698
2989
  // Parsed here to validate the merged output; result discarded at cycle end.
2699
2990
  parseReadyStreaks(exitResult.outputs, rootIds.length, rootIds.length + 1, TIER_STANDARD, rootIds);
2700
2991
  } else {
2701
2992
  // Fallback: outputs too short (agent returned partial results) -- use separate dispatches.
2702
2993
  log('exit-check: outputs.length < rootCount+2 -- falling back to separate dispatches');
2703
- blockers = await countBeadsBlockers(threshold, rootIds);
2994
+ blockers = await countBeadsBlockers(threshold, rootIds, integTestEnabled);
2704
2995
  }
2705
2996
  }
2706
2997
  const currentOpenIds = (blockers.ids || []).slice().sort();
@@ -2779,6 +3070,69 @@ if (!approved(finalReview)) {
2779
3070
  return { cycles: cycleCount, goalMet, goal, abortReason: abortReason || 'final review rejected', finalReviewNotes: notes };
2780
3071
  }
2781
3072
 
3073
+ // ------------------------------------------------------------------ REGRESSION TEST (once per sprint)
3074
+ // Placed deliberately AFTER the final-review verdict is decided (and after its early
3075
+ // return) and BEFORE harvest: the verdict is already computed, so a regression result
3076
+ // structurally CANNOT perturb the sprint's PASS/FAIL, and running it before harvest lets
3077
+ // the harvester mention it in the CHANGELOG. This is the ONLY dispatch of this role in a
3078
+ // sprint -- the per-cycle Test phase does feature closure only.
3079
+ //
3080
+ // SOFT FAIL, ALWAYS: a null / failed / schema-invalid / thrown result is logged and
3081
+ // swallowed. It never aborts, never touches goalMet, never changes the return value, and
3082
+ // never blocks harvest. Failures the runner finds are filed by IT as standalone,
3083
+ // parent-less [regression][carry-over] beads, which the sprint's parent-edge-walking
3084
+ // completion gate cannot see -- that is what makes them carry over to a future sprint.
3085
+ let regressionSummaryLine = '(not run)';
3086
+ if (regressionTestEnabled) {
3087
+ let regressionResult = null;
3088
+ try {
3089
+ regressionResult = await dispatch(
3090
+ `Repo: ${repo}\nBranch: ${branch}\nCycles completed: ${cycleCount}\n` +
3091
+ `Sprint goals: ${rootSummary}\n\n` +
3092
+ `Follow your runbook (agents/regression-test-runner.md) and regression-test-playbook.md.\n` +
3093
+ `This is the ONCE-PER-SPRINT regression pass. Run BOTH parts:\n` +
3094
+ ` Part 1: the full functional suite against the real bd CLI, at branch HEAD.\n` +
3095
+ ` Part 2: the toy-sprint smoke test -- bring the sandbox up with the playbook's\n` +
3096
+ ` ## Setup section, run its ## Test scenario, and ALWAYS run the playbook's\n` +
3097
+ ` ## Teardown before returning, pass or fail.\n\n` +
3098
+ `File EVERY failure from either part as a STANDALONE bead: "bd create" with NO\n` +
3099
+ `--parent flag, and do NOT "bd dep add" it to sprint root ${rootIds[0]}, to any\n` +
3100
+ `feature, or to any other bead in this sprint. Title each one\n` +
3101
+ `"[regression][carry-over] <short description>". The parent-less shape is the point:\n` +
3102
+ `this sprint's completion gate walks parent edges, so a bead with no parent edge is\n` +
3103
+ `structurally invisible to it and carries over to a FUTURE sprint instead of blocking\n` +
3104
+ `this one. Dedupe first with: bd search "[carry-over]" -- update an existing\n` +
3105
+ `carry-over bug rather than filing a second one for the same failure.\n\n` +
3106
+ `This sprint's verdict is ALREADY DECIDED (final review: APPROVED). Your result is\n` +
3107
+ `INFORMATIONAL and does not gate it -- do not present it as a gate.\n\n` +
3108
+ `Return the full contract: passed (boolean), suitePassed (boolean), smokePassed\n` +
3109
+ `(boolean), bugsFiled (array of the parent-less carry-over bead ids, [] if none),\n` +
3110
+ `summary (one paragraph).`,
3111
+ { model: MODEL_SONNET, label: 'regression-test-runner', phase: 'Harvest',
3112
+ schema: REGRESSION_RUN_SCHEMA, agentType: 'regression-test-runner' }
3113
+ );
3114
+ } catch (e) {
3115
+ // Swallowed on purpose -- see SOFT FAIL above.
3116
+ log(`Regression pass threw and was ignored (informational only): ${String(e && e.message || e).slice(0, 200)}`);
3117
+ regressionResult = null;
3118
+ }
3119
+ if (regressionResult && typeof regressionResult.passed === 'boolean') {
3120
+ const _bugs = Array.isArray(regressionResult.bugsFiled) ? regressionResult.bugsFiled : [];
3121
+ log(`Regression: suitePassed=${regressionResult.suitePassed}, smokePassed=${regressionResult.smokePassed}, passed=${regressionResult.passed}, carry-over bugs filed: ${_bugs.length}${_bugs.length ? ` [${_bugs.join(', ')}]` : ''}`);
3122
+ log(`Regression summary: ${regressionResult.summary}`);
3123
+ regressionSummaryLine =
3124
+ `passed=${regressionResult.passed} (suite=${regressionResult.suitePassed}, smoke=${regressionResult.smokePassed})` +
3125
+ `${_bugs.length ? `; carry-over beads filed: ${_bugs.join(', ')}` : '; no carry-over beads filed'}`;
3126
+ } else {
3127
+ log('Regression pass returned no usable result -- ignored (informational only; the sprint is unaffected)');
3128
+ regressionSummaryLine = '(not run -- the regression dispatch returned no usable result)';
3129
+ }
3130
+ await appendNewEntries('regression', 'Harvest');
3131
+ } else {
3132
+ log('Regression pass skipped -- no regression-test-playbook.md in the repo root');
3133
+ regressionSummaryLine = '(skipped -- no regression-test-playbook.md)';
3134
+ }
3135
+
2782
3136
  // ------------------------------------------------------------------ HARVEST
2783
3137
 
2784
3138
  const logEntries = dispatchLedger;
@@ -2819,6 +3173,8 @@ const harvestResult = await dispatch(
2819
3173
  `${sprintAnalysis.analysisText}\n` +
2820
3174
  `Final review notes to include in CHANGELOG:\n` +
2821
3175
  `${(finalReview && finalReview.notes) || '(none)'}\n\n` +
3176
+ `Regression pass (once-per-sprint, informational -- does not gate this sprint):\n` +
3177
+ `${regressionSummaryLine}\n\n` +
2822
3178
  `Return status "OK" if successful, "FAILED" with notes otherwise.`,
2823
3179
  { model: MODEL_SONNET, label: harvestLabel, phase: 'Harvest', schema: HARVEST_SCHEMA, agentType: 'harvester' }
2824
3180
  );
@@ -2851,6 +3207,11 @@ if (!harvestResult || harvestResult.status !== 'OK') {
2851
3207
  const updatedCalibration = computeUpdatedCalibration(calibration, sprintAnalysis, effectiveStartedAt, taskAssignments, logEntries);
2852
3208
  const calibrationJson = JSON.stringify(updatedCalibration, null, 2);
2853
3209
 
3210
+ const tokenEstimates = {
3211
+ averages: Object.values(updatedCalibration.historical?.tuple_averages || {})
3212
+ };
3213
+ const tokenEstimatesJson = JSON.stringify(tokenEstimates).replace(/"/g, '\\"');
3214
+
2854
3215
  await parallel([
2855
3216
  dispatch(
2856
3217
  `Write updated calibration file and commit.\n\n` +
@@ -2860,6 +3221,8 @@ await parallel([
2860
3221
  `Step 3: Commit the file:\n` +
2861
3222
  ` git -C "${repo}" add sprint-logs/calibration.json\n` +
2862
3223
  ` git -C "${repo}" commit -m "chore: update sprint calibration after ${cycleCount} cycle(s) on ${branch}"\n\n` +
3224
+ `Step 4: Update token estimates memory:\n` +
3225
+ ` bd remember "${tokenEstimatesJson}" --key token-estimates-json\n\n` +
2863
3226
  `If the file content is unchanged, the commit may be a no-op -- that is fine.\n` +
2864
3227
  `Return "OK" when done.`,
2865
3228
  { model: MODEL_HAIKU, label: 'calibration-update', phase: 'Harvest' }
@@ -2944,7 +3307,7 @@ const harvestPr = await dispatch(
2944
3307
  ` - Cycles run: ${cycleCount}\n` +
2945
3308
  ` - Open items carried forward (if any): bd list --status=open and summarise\n` +
2946
3309
  ` - Final review notes: ${(finalReview && finalReview.notes) || '(none)'}\n` +
2947
- ` - Token cost summary from: bd memories auto-sprint\n\n` +
3310
+ ` - Token cost summary from: bd recall token-estimates-json\n\n` +
2948
3311
  `After creating the PR, return its number as prNumber (integer).`,
2949
3312
  { model: MODEL_SONNET, label: 'harvest-pr', phase: 'Harvest',
2950
3313
  schema: { type: 'object', required: ['prNumber'], properties: { prNumber: { type: 'number' }, prUrl: { type: 'string' } } } }