@apralabs/apra-fleet 0.3.6 → 0.4.1

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 (826) hide show
  1. package/README.md +378 -252
  2. package/dist/agents/backlog-groomer.md +303 -0
  3. package/dist/agents/ci-watcher.md +13 -1
  4. package/dist/agents/deployer.md +66 -13
  5. package/dist/agents/doer.md +67 -8
  6. package/dist/agents/harvester.md +22 -3
  7. package/dist/agents/integ-test-runner.md +166 -60
  8. package/dist/agents/kb-reconciler.md +216 -0
  9. package/dist/agents/plan-reviewer.md +88 -18
  10. package/dist/agents/planner.md +182 -19
  11. package/dist/agents/regression-test-runner.md +234 -0
  12. package/dist/agents/reviewer.md +125 -9
  13. package/dist/agents/schemas/backlog-groomer-input.json +35 -0
  14. package/dist/agents/schemas/backlog-groomer-output.json +164 -0
  15. package/dist/agents/schemas/doer-output.json +63 -3
  16. package/dist/agents/schemas/harvester-output.json +59 -2
  17. package/dist/agents/schemas/integ-test-runner-output.json +34 -0
  18. package/dist/agents/schemas/kb-reconciler-output.json +87 -0
  19. package/dist/agents/schemas/planner-output.json +65 -0
  20. package/dist/agents/schemas/regression-test-runner-input.json +15 -0
  21. package/dist/agents/schemas/regression-test-runner-output.json +50 -0
  22. package/dist/agents/schemas/reviewer-output.json +108 -7
  23. package/dist/cli/agent-transform.d.ts +1 -0
  24. package/dist/cli/agent-transform.d.ts.map +1 -1
  25. package/dist/cli/agent-transform.js +77 -0
  26. package/dist/cli/agent-transform.js.map +1 -1
  27. package/dist/cli/auth.d.ts +3 -0
  28. package/dist/cli/auth.d.ts.map +1 -1
  29. package/dist/cli/auth.js +181 -5
  30. package/dist/cli/auth.js.map +1 -1
  31. package/dist/cli/config.d.ts +5 -1
  32. package/dist/cli/config.d.ts.map +1 -1
  33. package/dist/cli/config.js +7 -1
  34. package/dist/cli/config.js.map +1 -1
  35. package/dist/cli/dolt-install.d.ts +91 -0
  36. package/dist/cli/dolt-install.d.ts.map +1 -0
  37. package/dist/cli/dolt-install.js +334 -0
  38. package/dist/cli/dolt-install.js.map +1 -0
  39. package/dist/cli/install-guard.d.ts +29 -0
  40. package/dist/cli/install-guard.d.ts.map +1 -0
  41. package/dist/cli/install-guard.js +153 -0
  42. package/dist/cli/install-guard.js.map +1 -0
  43. package/dist/cli/install.d.ts +45 -3
  44. package/dist/cli/install.d.ts.map +1 -1
  45. package/dist/cli/install.js +736 -109
  46. package/dist/cli/install.js.map +1 -1
  47. package/dist/cli/join.d.ts +12 -0
  48. package/dist/cli/join.d.ts.map +1 -0
  49. package/dist/cli/join.js +87 -0
  50. package/dist/cli/join.js.map +1 -0
  51. package/dist/cli/kb-commit.d.ts +12 -0
  52. package/dist/cli/kb-commit.d.ts.map +1 -0
  53. package/dist/cli/kb-commit.js +53 -0
  54. package/dist/cli/kb-commit.js.map +1 -0
  55. package/dist/cli/kb-directives.d.ts +17 -0
  56. package/dist/cli/kb-directives.d.ts.map +1 -0
  57. package/dist/cli/kb-directives.js +146 -0
  58. package/dist/cli/kb-directives.js.map +1 -0
  59. package/dist/cli/kb-import.d.ts +13 -0
  60. package/dist/cli/kb-import.d.ts.map +1 -0
  61. package/dist/cli/kb-import.js +56 -0
  62. package/dist/cli/kb-import.js.map +1 -0
  63. package/dist/cli/register-member.d.ts +2 -0
  64. package/dist/cli/register-member.d.ts.map +1 -0
  65. package/dist/cli/register-member.js +193 -0
  66. package/dist/cli/register-member.js.map +1 -0
  67. package/dist/cli/restart.d.ts +2 -0
  68. package/dist/cli/restart.d.ts.map +1 -0
  69. package/dist/cli/restart.js +7 -0
  70. package/dist/cli/restart.js.map +1 -0
  71. package/dist/cli/spoke.d.ts +35 -0
  72. package/dist/cli/spoke.d.ts.map +1 -0
  73. package/dist/cli/spoke.js +212 -0
  74. package/dist/cli/spoke.js.map +1 -0
  75. package/dist/cli/start.d.ts +2 -0
  76. package/dist/cli/start.d.ts.map +1 -0
  77. package/dist/cli/start.js +92 -0
  78. package/dist/cli/start.js.map +1 -0
  79. package/dist/cli/status.d.ts +2 -0
  80. package/dist/cli/status.d.ts.map +1 -0
  81. package/dist/cli/status.js +83 -0
  82. package/dist/cli/status.js.map +1 -0
  83. package/dist/cli/stop.d.ts +2 -0
  84. package/dist/cli/stop.d.ts.map +1 -0
  85. package/dist/cli/stop.js +51 -0
  86. package/dist/cli/stop.js.map +1 -0
  87. package/dist/cli/uninstall.d.ts.map +1 -1
  88. package/dist/cli/uninstall.js +120 -9
  89. package/dist/cli/uninstall.js.map +1 -1
  90. package/dist/cli/update.d.ts.map +1 -1
  91. package/dist/cli/update.js +10 -1
  92. package/dist/cli/update.js.map +1 -1
  93. package/dist/cli/watch.d.ts +53 -4
  94. package/dist/cli/watch.d.ts.map +1 -1
  95. package/dist/cli/watch.js +118 -17
  96. package/dist/cli/watch.js.map +1 -1
  97. package/dist/cli/workflow-assets.d.ts +37 -0
  98. package/dist/cli/workflow-assets.d.ts.map +1 -0
  99. package/dist/cli/workflow-assets.js +144 -0
  100. package/dist/cli/workflow-assets.js.map +1 -0
  101. package/dist/cli/workflow.d.ts +75 -0
  102. package/dist/cli/workflow.d.ts.map +1 -0
  103. package/dist/cli/workflow.js +397 -0
  104. package/dist/cli/workflow.js.map +1 -0
  105. package/dist/commands/kb-server.d.ts +8 -0
  106. package/dist/commands/kb-server.d.ts.map +1 -0
  107. package/dist/commands/kb-server.js +221 -0
  108. package/dist/commands/kb-server.js.map +1 -0
  109. package/dist/hub-service/activity.d.ts +30 -0
  110. package/dist/hub-service/activity.d.ts.map +1 -0
  111. package/dist/hub-service/activity.js +20 -0
  112. package/dist/hub-service/activity.js.map +1 -0
  113. package/dist/hub-service/audit-log.d.ts +19 -0
  114. package/dist/hub-service/audit-log.d.ts.map +1 -0
  115. package/dist/hub-service/audit-log.js +13 -0
  116. package/dist/hub-service/audit-log.js.map +1 -0
  117. package/dist/hub-service/db/pool.d.ts +19 -0
  118. package/dist/hub-service/db/pool.d.ts.map +1 -0
  119. package/dist/hub-service/db/pool.js +53 -0
  120. package/dist/hub-service/db/pool.js.map +1 -0
  121. package/dist/hub-service/enrollment.d.ts +29 -0
  122. package/dist/hub-service/enrollment.d.ts.map +1 -0
  123. package/dist/hub-service/enrollment.js +48 -0
  124. package/dist/hub-service/enrollment.js.map +1 -0
  125. package/dist/hub-service/envelope-routes.d.ts +46 -0
  126. package/dist/hub-service/envelope-routes.d.ts.map +1 -0
  127. package/dist/hub-service/envelope-routes.js +94 -0
  128. package/dist/hub-service/envelope-routes.js.map +1 -0
  129. package/dist/hub-service/handlers/installers.d.ts +14 -0
  130. package/dist/hub-service/handlers/installers.d.ts.map +1 -0
  131. package/dist/hub-service/handlers/installers.js +8 -0
  132. package/dist/hub-service/handlers/installers.js.map +1 -0
  133. package/dist/hub-service/http-server.d.ts +31 -0
  134. package/dist/hub-service/http-server.d.ts.map +1 -0
  135. package/dist/hub-service/http-server.js +711 -0
  136. package/dist/hub-service/http-server.js.map +1 -0
  137. package/dist/hub-service/hub-jwt.d.ts +30 -0
  138. package/dist/hub-service/hub-jwt.d.ts.map +1 -0
  139. package/dist/hub-service/hub-jwt.js +105 -0
  140. package/dist/hub-service/hub-jwt.js.map +1 -0
  141. package/dist/hub-service/jwt-revocation.d.ts +20 -0
  142. package/dist/hub-service/jwt-revocation.d.ts.map +1 -0
  143. package/dist/hub-service/jwt-revocation.js +18 -0
  144. package/dist/hub-service/jwt-revocation.js.map +1 -0
  145. package/dist/hub-service/machines.d.ts +16 -0
  146. package/dist/hub-service/machines.d.ts.map +1 -0
  147. package/dist/hub-service/machines.js +14 -0
  148. package/dist/hub-service/machines.js.map +1 -0
  149. package/dist/hub-service/main.d.ts +3 -0
  150. package/dist/hub-service/main.d.ts.map +1 -0
  151. package/dist/hub-service/main.js +64 -0
  152. package/dist/hub-service/main.js.map +1 -0
  153. package/dist/hub-service/member-tokens.d.ts +11 -0
  154. package/dist/hub-service/member-tokens.d.ts.map +1 -0
  155. package/dist/hub-service/member-tokens.js +49 -0
  156. package/dist/hub-service/member-tokens.js.map +1 -0
  157. package/dist/hub-service/member-view.d.ts +20 -0
  158. package/dist/hub-service/member-view.d.ts.map +1 -0
  159. package/dist/hub-service/member-view.js +76 -0
  160. package/dist/hub-service/member-view.js.map +1 -0
  161. package/dist/hub-service/members.d.ts +44 -0
  162. package/dist/hub-service/members.d.ts.map +1 -0
  163. package/dist/hub-service/members.js +25 -0
  164. package/dist/hub-service/members.js.map +1 -0
  165. package/dist/hub-service/presence.d.ts +40 -0
  166. package/dist/hub-service/presence.d.ts.map +1 -0
  167. package/dist/hub-service/presence.js +44 -0
  168. package/dist/hub-service/presence.js.map +1 -0
  169. package/dist/hub-service/project-view.d.ts +12 -0
  170. package/dist/hub-service/project-view.d.ts.map +1 -0
  171. package/dist/hub-service/project-view.js +34 -0
  172. package/dist/hub-service/project-view.js.map +1 -0
  173. package/dist/hub-service/projects.d.ts +48 -0
  174. package/dist/hub-service/projects.d.ts.map +1 -0
  175. package/dist/hub-service/projects.js +80 -0
  176. package/dist/hub-service/projects.js.map +1 -0
  177. package/dist/hub-service/relay-queue.d.ts +115 -0
  178. package/dist/hub-service/relay-queue.d.ts.map +1 -0
  179. package/dist/hub-service/relay-queue.js +148 -0
  180. package/dist/hub-service/relay-queue.js.map +1 -0
  181. package/dist/hub-service/session-jwt.d.ts +10 -0
  182. package/dist/hub-service/session-jwt.d.ts.map +1 -0
  183. package/dist/hub-service/session-jwt.js +69 -0
  184. package/dist/hub-service/session-jwt.js.map +1 -0
  185. package/dist/hub-service/usage.d.ts +40 -0
  186. package/dist/hub-service/usage.d.ts.map +1 -0
  187. package/dist/hub-service/usage.js +25 -0
  188. package/dist/hub-service/usage.js.map +1 -0
  189. package/dist/hub-service/users.d.ts +56 -0
  190. package/dist/hub-service/users.d.ts.map +1 -0
  191. package/dist/hub-service/users.js +72 -0
  192. package/dist/hub-service/users.js.map +1 -0
  193. package/dist/hub-service/workspaces.d.ts +20 -0
  194. package/dist/hub-service/workspaces.d.ts.map +1 -0
  195. package/dist/hub-service/workspaces.js +10 -0
  196. package/dist/hub-service/workspaces.js.map +1 -0
  197. package/dist/index.js +254 -132
  198. package/dist/index.js.map +1 -1
  199. package/dist/os/linux.d.ts +14 -0
  200. package/dist/os/linux.d.ts.map +1 -1
  201. package/dist/os/linux.js +80 -4
  202. package/dist/os/linux.js.map +1 -1
  203. package/dist/os/os-commands.d.ts +15 -0
  204. package/dist/os/os-commands.d.ts.map +1 -1
  205. package/dist/os/windows.d.ts +36 -0
  206. package/dist/os/windows.d.ts.map +1 -1
  207. package/dist/os/windows.js +74 -18
  208. package/dist/os/windows.js.map +1 -1
  209. package/dist/paths.d.ts +23 -0
  210. package/dist/paths.d.ts.map +1 -1
  211. package/dist/paths.js +29 -0
  212. package/dist/paths.js.map +1 -1
  213. package/dist/providers/agy.d.ts +20 -2
  214. package/dist/providers/agy.d.ts.map +1 -1
  215. package/dist/providers/agy.js +259 -21
  216. package/dist/providers/agy.js.map +1 -1
  217. package/dist/providers/claude.d.ts +16 -2
  218. package/dist/providers/claude.d.ts.map +1 -1
  219. package/dist/providers/claude.js +283 -16
  220. package/dist/providers/claude.js.map +1 -1
  221. package/dist/providers/codex.d.ts +13 -2
  222. package/dist/providers/codex.d.ts.map +1 -1
  223. package/dist/providers/codex.js +36 -6
  224. package/dist/providers/codex.js.map +1 -1
  225. package/dist/providers/copilot.d.ts +13 -2
  226. package/dist/providers/copilot.d.ts.map +1 -1
  227. package/dist/providers/copilot.js +34 -7
  228. package/dist/providers/copilot.js.map +1 -1
  229. package/dist/providers/email/headers.d.ts +15 -0
  230. package/dist/providers/email/headers.d.ts.map +1 -0
  231. package/dist/providers/email/headers.js +42 -0
  232. package/dist/providers/email/headers.js.map +1 -0
  233. package/dist/providers/email/index.d.ts +18 -0
  234. package/dist/providers/email/index.d.ts.map +1 -0
  235. package/dist/providers/email/index.js +60 -0
  236. package/dist/providers/email/index.js.map +1 -0
  237. package/dist/providers/email/provider.d.ts +49 -0
  238. package/dist/providers/email/provider.d.ts.map +1 -0
  239. package/dist/providers/email/provider.js +2 -0
  240. package/dist/providers/email/provider.js.map +1 -0
  241. package/dist/providers/email/sendgrid.d.ts +12 -0
  242. package/dist/providers/email/sendgrid.d.ts.map +1 -0
  243. package/dist/providers/email/sendgrid.js +67 -0
  244. package/dist/providers/email/sendgrid.js.map +1 -0
  245. package/dist/providers/email/smtp.d.ts +65 -0
  246. package/dist/providers/email/smtp.d.ts.map +1 -0
  247. package/dist/providers/email/smtp.js +373 -0
  248. package/dist/providers/email/smtp.js.map +1 -0
  249. package/dist/providers/gemini.d.ts +13 -2
  250. package/dist/providers/gemini.d.ts.map +1 -1
  251. package/dist/providers/gemini.js +49 -5
  252. package/dist/providers/gemini.js.map +1 -1
  253. package/dist/providers/index.d.ts +1 -0
  254. package/dist/providers/index.d.ts.map +1 -1
  255. package/dist/providers/index.js +3 -0
  256. package/dist/providers/index.js.map +1 -1
  257. package/dist/providers/none.d.ts +61 -0
  258. package/dist/providers/none.d.ts.map +1 -0
  259. package/dist/providers/none.js +124 -0
  260. package/dist/providers/none.js.map +1 -0
  261. package/dist/providers/opencode.d.ts +14 -2
  262. package/dist/providers/opencode.d.ts.map +1 -1
  263. package/dist/providers/opencode.js +104 -4
  264. package/dist/providers/opencode.js.map +1 -1
  265. package/dist/providers/provider.d.ts +156 -1
  266. package/dist/providers/provider.d.ts.map +1 -1
  267. package/dist/providers/provider.js +54 -0
  268. package/dist/providers/provider.js.map +1 -1
  269. package/dist/services/agent-provisioner.d.ts +3 -3
  270. package/dist/services/agent-provisioner.d.ts.map +1 -1
  271. package/dist/services/agent-provisioner.js +11 -7
  272. package/dist/services/agent-provisioner.js.map +1 -1
  273. package/dist/services/auth-socket.d.ts.map +1 -1
  274. package/dist/services/auth-socket.js +2 -0
  275. package/dist/services/auth-socket.js.map +1 -1
  276. package/dist/services/budget-awareness.d.ts +130 -0
  277. package/dist/services/budget-awareness.d.ts.map +1 -0
  278. package/dist/services/budget-awareness.js +129 -0
  279. package/dist/services/budget-awareness.js.map +1 -0
  280. package/dist/services/cloud/lifecycle.d.ts.map +1 -1
  281. package/dist/services/cloud/lifecycle.js +3 -0
  282. package/dist/services/cloud/lifecycle.js.map +1 -1
  283. package/dist/services/cloud/task-wrapper.d.ts +18 -0
  284. package/dist/services/cloud/task-wrapper.d.ts.map +1 -1
  285. package/dist/services/cloud/task-wrapper.js +157 -0
  286. package/dist/services/cloud/task-wrapper.js.map +1 -1
  287. package/dist/services/cloud-sync.d.ts +35 -0
  288. package/dist/services/cloud-sync.d.ts.map +1 -0
  289. package/dist/services/cloud-sync.js +90 -0
  290. package/dist/services/cloud-sync.js.map +1 -0
  291. package/dist/services/context-admission.d.ts +82 -0
  292. package/dist/services/context-admission.d.ts.map +1 -0
  293. package/dist/services/context-admission.js +136 -0
  294. package/dist/services/context-admission.js.map +1 -0
  295. package/dist/services/event-bus.d.ts +27 -0
  296. package/dist/services/event-bus.d.ts.map +1 -0
  297. package/dist/services/event-bus.js +20 -0
  298. package/dist/services/event-bus.js.map +1 -0
  299. package/dist/services/file-chunker.d.ts +38 -0
  300. package/dist/services/file-chunker.d.ts.map +1 -0
  301. package/dist/services/file-chunker.js +63 -0
  302. package/dist/services/file-chunker.js.map +1 -0
  303. package/dist/services/file-transfer-relay.d.ts +55 -0
  304. package/dist/services/file-transfer-relay.d.ts.map +1 -0
  305. package/dist/services/file-transfer-relay.js +115 -0
  306. package/dist/services/file-transfer-relay.js.map +1 -0
  307. package/dist/services/github-app.d.ts.map +1 -1
  308. package/dist/services/github-app.js +12 -2
  309. package/dist/services/github-app.js.map +1 -1
  310. package/dist/services/http-transport.d.ts +25 -0
  311. package/dist/services/http-transport.d.ts.map +1 -0
  312. package/dist/services/http-transport.js +371 -0
  313. package/dist/services/http-transport.js.map +1 -0
  314. package/dist/services/hub-client.d.ts +69 -0
  315. package/dist/services/hub-client.d.ts.map +1 -0
  316. package/dist/services/hub-client.js +217 -0
  317. package/dist/services/hub-client.js.map +1 -0
  318. package/dist/services/jwt.d.ts +17 -0
  319. package/dist/services/jwt.d.ts.map +1 -0
  320. package/dist/services/jwt.js +70 -0
  321. package/dist/services/jwt.js.map +1 -0
  322. package/dist/services/knowledge/audn.d.ts +37 -0
  323. package/dist/services/knowledge/audn.d.ts.map +1 -0
  324. package/dist/services/knowledge/audn.js +219 -0
  325. package/dist/services/knowledge/audn.js.map +1 -0
  326. package/dist/services/knowledge/file-hash.d.ts +11 -0
  327. package/dist/services/knowledge/file-hash.d.ts.map +1 -0
  328. package/dist/services/knowledge/file-hash.js +123 -0
  329. package/dist/services/knowledge/file-hash.js.map +1 -0
  330. package/dist/services/knowledge/http-provider.d.ts +46 -0
  331. package/dist/services/knowledge/http-provider.d.ts.map +1 -0
  332. package/dist/services/knowledge/http-provider.js +254 -0
  333. package/dist/services/knowledge/http-provider.js.map +1 -0
  334. package/dist/services/knowledge/kb-providers.d.ts +15 -0
  335. package/dist/services/knowledge/kb-providers.d.ts.map +1 -0
  336. package/dist/services/knowledge/kb-providers.js +92 -0
  337. package/dist/services/knowledge/kb-providers.js.map +1 -0
  338. package/dist/services/knowledge/kb-scope-input.d.ts +5 -0
  339. package/dist/services/knowledge/kb-scope-input.d.ts.map +1 -0
  340. package/dist/services/knowledge/kb-scope-input.js +11 -0
  341. package/dist/services/knowledge/kb-scope-input.js.map +1 -0
  342. package/dist/services/knowledge/kb-service.d.ts +3 -0
  343. package/dist/services/knowledge/kb-service.d.ts.map +1 -0
  344. package/dist/services/knowledge/kb-service.js +2 -0
  345. package/dist/services/knowledge/kb-service.js.map +1 -0
  346. package/dist/services/knowledge/path-validation.d.ts +2 -0
  347. package/dist/services/knowledge/path-validation.d.ts.map +1 -0
  348. package/dist/services/knowledge/path-validation.js +13 -0
  349. package/dist/services/knowledge/path-validation.js.map +1 -0
  350. package/dist/services/knowledge/pre-init.d.ts +14 -0
  351. package/dist/services/knowledge/pre-init.d.ts.map +1 -0
  352. package/dist/services/knowledge/pre-init.js +147 -0
  353. package/dist/services/knowledge/pre-init.js.map +1 -0
  354. package/dist/services/knowledge/project-slug.d.ts +2 -0
  355. package/dist/services/knowledge/project-slug.d.ts.map +1 -0
  356. package/dist/services/knowledge/project-slug.js +49 -0
  357. package/dist/services/knowledge/project-slug.js.map +1 -0
  358. package/dist/services/knowledge/sqlite-provider.d.ts +147 -0
  359. package/dist/services/knowledge/sqlite-provider.d.ts.map +1 -0
  360. package/dist/services/knowledge/sqlite-provider.js +1646 -0
  361. package/dist/services/knowledge/sqlite-provider.js.map +1 -0
  362. package/dist/services/knowledge/types.d.ts +163 -0
  363. package/dist/services/knowledge/types.d.ts.map +1 -0
  364. package/dist/services/knowledge/types.js +9 -0
  365. package/dist/services/knowledge/types.js.map +1 -0
  366. package/dist/services/known-sessions.d.ts +8 -0
  367. package/dist/services/known-sessions.d.ts.map +1 -0
  368. package/dist/services/known-sessions.js +40 -0
  369. package/dist/services/known-sessions.js.map +1 -0
  370. package/dist/services/member-home.d.ts +89 -0
  371. package/dist/services/member-home.d.ts.map +1 -0
  372. package/dist/services/member-home.js +256 -0
  373. package/dist/services/member-home.js.map +1 -0
  374. package/dist/services/member-remote-url.d.ts +34 -0
  375. package/dist/services/member-remote-url.d.ts.map +1 -0
  376. package/dist/services/member-remote-url.js +39 -0
  377. package/dist/services/member-remote-url.js.map +1 -0
  378. package/dist/services/model-pricing.d.ts +36 -0
  379. package/dist/services/model-pricing.d.ts.map +1 -0
  380. package/dist/services/model-pricing.js +108 -0
  381. package/dist/services/model-pricing.js.map +1 -0
  382. package/dist/services/orphan-recovery.d.ts +59 -0
  383. package/dist/services/orphan-recovery.d.ts.map +1 -0
  384. package/dist/services/orphan-recovery.js +122 -0
  385. package/dist/services/orphan-recovery.js.map +1 -0
  386. package/dist/services/pending-responses.d.ts +23 -0
  387. package/dist/services/pending-responses.d.ts.map +1 -0
  388. package/dist/services/pending-responses.js +52 -0
  389. package/dist/services/pending-responses.js.map +1 -0
  390. package/dist/services/preflight-check.d.ts +56 -0
  391. package/dist/services/preflight-check.d.ts.map +1 -0
  392. package/dist/services/preflight-check.js +277 -0
  393. package/dist/services/preflight-check.js.map +1 -0
  394. package/dist/services/registry.d.ts +4 -1
  395. package/dist/services/registry.d.ts.map +1 -1
  396. package/dist/services/registry.js +3 -0
  397. package/dist/services/registry.js.map +1 -1
  398. package/dist/services/relay-context.d.ts +23 -0
  399. package/dist/services/relay-context.d.ts.map +1 -0
  400. package/dist/services/relay-context.js +8 -0
  401. package/dist/services/relay-context.js.map +1 -0
  402. package/dist/services/relay-executor.d.ts +68 -0
  403. package/dist/services/relay-executor.d.ts.map +1 -0
  404. package/dist/services/relay-executor.js +70 -0
  405. package/dist/services/relay-executor.js.map +1 -0
  406. package/dist/services/relay-request.d.ts +65 -0
  407. package/dist/services/relay-request.d.ts.map +1 -0
  408. package/dist/services/relay-request.js +129 -0
  409. package/dist/services/relay-request.js.map +1 -0
  410. package/dist/services/relay-strategy.d.ts +19 -0
  411. package/dist/services/relay-strategy.d.ts.map +1 -0
  412. package/dist/services/relay-strategy.js +111 -0
  413. package/dist/services/relay-strategy.js.map +1 -0
  414. package/dist/services/service-manager/index.d.ts +5 -0
  415. package/dist/services/service-manager/index.d.ts.map +1 -0
  416. package/dist/services/service-manager/index.js +66 -0
  417. package/dist/services/service-manager/index.js.map +1 -0
  418. package/dist/services/service-manager/linux.d.ts +10 -0
  419. package/dist/services/service-manager/linux.d.ts.map +1 -0
  420. package/dist/services/service-manager/linux.js +97 -0
  421. package/dist/services/service-manager/linux.js.map +1 -0
  422. package/dist/services/service-manager/macos.d.ts +10 -0
  423. package/dist/services/service-manager/macos.d.ts.map +1 -0
  424. package/dist/services/service-manager/macos.js +94 -0
  425. package/dist/services/service-manager/macos.js.map +1 -0
  426. package/dist/services/service-manager/types.d.ts +18 -0
  427. package/dist/services/service-manager/types.d.ts.map +1 -0
  428. package/dist/services/service-manager/types.js +5 -0
  429. package/dist/services/service-manager/types.js.map +1 -0
  430. package/dist/services/service-manager/windows.d.ts +10 -0
  431. package/dist/services/service-manager/windows.d.ts.map +1 -0
  432. package/dist/services/service-manager/windows.js +73 -0
  433. package/dist/services/service-manager/windows.js.map +1 -0
  434. package/dist/services/session-registry.d.ts +70 -0
  435. package/dist/services/session-registry.d.ts.map +1 -0
  436. package/dist/services/session-registry.js +91 -0
  437. package/dist/services/session-registry.js.map +1 -0
  438. package/dist/services/singleton.d.ts +15 -0
  439. package/dist/services/singleton.d.ts.map +1 -0
  440. package/dist/services/singleton.js +98 -0
  441. package/dist/services/singleton.js.map +1 -0
  442. package/dist/services/sprint-coordination.d.ts +168 -0
  443. package/dist/services/sprint-coordination.d.ts.map +1 -0
  444. package/dist/services/sprint-coordination.js +564 -0
  445. package/dist/services/sprint-coordination.js.map +1 -0
  446. package/dist/services/ssh.d.ts.map +1 -1
  447. package/dist/services/ssh.js +70 -3
  448. package/dist/services/ssh.js.map +1 -1
  449. package/dist/services/stall/log-path-resolver.d.ts +11 -8
  450. package/dist/services/stall/log-path-resolver.d.ts.map +1 -1
  451. package/dist/services/stall/log-path-resolver.js +17 -33
  452. package/dist/services/stall/log-path-resolver.js.map +1 -1
  453. package/dist/services/stall/stall-detector.d.ts +32 -0
  454. package/dist/services/stall/stall-detector.d.ts.map +1 -1
  455. package/dist/services/stall/stall-detector.js +187 -12
  456. package/dist/services/stall/stall-detector.js.map +1 -1
  457. package/dist/services/stall/stall-poller.d.ts +50 -0
  458. package/dist/services/stall/stall-poller.d.ts.map +1 -1
  459. package/dist/services/stall/stall-poller.js +268 -18
  460. package/dist/services/stall/stall-poller.js.map +1 -1
  461. package/dist/services/strategy.d.ts.map +1 -1
  462. package/dist/services/strategy.js +57 -7
  463. package/dist/services/strategy.js.map +1 -1
  464. package/dist/services/substitution-engine.d.ts +20 -0
  465. package/dist/services/substitution-engine.d.ts.map +1 -0
  466. package/dist/services/substitution-engine.js +92 -0
  467. package/dist/services/substitution-engine.js.map +1 -0
  468. package/dist/services/task-cleanup.d.ts.map +1 -1
  469. package/dist/services/task-cleanup.js +1 -9
  470. package/dist/services/task-cleanup.js.map +1 -1
  471. package/dist/services/token-issuer.d.ts +47 -0
  472. package/dist/services/token-issuer.d.ts.map +1 -0
  473. package/dist/services/token-issuer.js +63 -0
  474. package/dist/services/token-issuer.js.map +1 -0
  475. package/dist/services/tool-registry.d.ts +3 -0
  476. package/dist/services/tool-registry.d.ts.map +1 -0
  477. package/dist/services/tool-registry.js +225 -0
  478. package/dist/services/tool-registry.js.map +1 -0
  479. package/dist/services/user-config.d.ts +14 -0
  480. package/dist/services/user-config.d.ts.map +1 -1
  481. package/dist/services/user-config.js +55 -0
  482. package/dist/services/user-config.js.map +1 -1
  483. package/dist/services/vcs/github.d.ts.map +1 -1
  484. package/dist/services/vcs/github.js +32 -1
  485. package/dist/services/vcs/github.js.map +1 -1
  486. package/dist/services/vcs/types.d.ts +44 -0
  487. package/dist/services/vcs/types.d.ts.map +1 -1
  488. package/dist/services/version-check.d.ts +22 -0
  489. package/dist/services/version-check.d.ts.map +1 -0
  490. package/dist/services/version-check.js +103 -0
  491. package/dist/services/version-check.js.map +1 -0
  492. package/dist/skills/fleet-sprint-cli/SKILL.md +114 -0
  493. package/dist/skills/pm/beads.md +6 -0
  494. package/dist/skills/pm/cost.md +3 -0
  495. package/dist/skills/pm/doer-reviewer-loop.md +3 -0
  496. package/dist/skills/pm/fleet-addendum.md +6 -0
  497. package/dist/skills/pm/index.md +56 -0
  498. package/dist/skills/pm/kb-reconcile.md +132 -0
  499. package/dist/skills/pm/kb-review.md +109 -0
  500. package/dist/tools/check-status.d.ts +47 -0
  501. package/dist/tools/check-status.d.ts.map +1 -1
  502. package/dist/tools/check-status.js +250 -2
  503. package/dist/tools/check-status.js.map +1 -1
  504. package/dist/tools/child-id-allocator.d.ts +45 -0
  505. package/dist/tools/child-id-allocator.d.ts.map +1 -0
  506. package/dist/tools/child-id-allocator.js +62 -0
  507. package/dist/tools/child-id-allocator.js.map +1 -0
  508. package/dist/tools/cloud-control.d.ts +2 -2
  509. package/dist/tools/code-intelligence-codebase-memory.d.ts +11 -0
  510. package/dist/tools/code-intelligence-codebase-memory.d.ts.map +1 -0
  511. package/dist/tools/code-intelligence-codebase-memory.js +270 -0
  512. package/dist/tools/code-intelligence-codebase-memory.js.map +1 -0
  513. package/dist/tools/code-intelligence-freshness.d.ts +2 -0
  514. package/dist/tools/code-intelligence-freshness.d.ts.map +1 -0
  515. package/dist/tools/code-intelligence-freshness.js +26 -0
  516. package/dist/tools/code-intelligence-freshness.js.map +1 -0
  517. package/dist/tools/code-intelligence-gitnexus.d.ts +14 -0
  518. package/dist/tools/code-intelligence-gitnexus.d.ts.map +1 -0
  519. package/dist/tools/code-intelligence-gitnexus.js +475 -0
  520. package/dist/tools/code-intelligence-gitnexus.js.map +1 -0
  521. package/dist/tools/code-intelligence-kb-enrich.d.ts +2 -0
  522. package/dist/tools/code-intelligence-kb-enrich.d.ts.map +1 -0
  523. package/dist/tools/code-intelligence-kb-enrich.js +65 -0
  524. package/dist/tools/code-intelligence-kb-enrich.js.map +1 -0
  525. package/dist/tools/code-intelligence-reindex.d.ts +7 -0
  526. package/dist/tools/code-intelligence-reindex.d.ts.map +1 -0
  527. package/dist/tools/code-intelligence-reindex.js +106 -0
  528. package/dist/tools/code-intelligence-reindex.js.map +1 -0
  529. package/dist/tools/code-intelligence-telemetry.d.ts +5 -0
  530. package/dist/tools/code-intelligence-telemetry.d.ts.map +1 -0
  531. package/dist/tools/code-intelligence-telemetry.js +52 -0
  532. package/dist/tools/code-intelligence-telemetry.js.map +1 -0
  533. package/dist/tools/code-intelligence-tests.d.ts +2 -0
  534. package/dist/tools/code-intelligence-tests.d.ts.map +1 -0
  535. package/dist/tools/code-intelligence-tests.js +24 -0
  536. package/dist/tools/code-intelligence-tests.js.map +1 -0
  537. package/dist/tools/code-intelligence.d.ts +114 -0
  538. package/dist/tools/code-intelligence.d.ts.map +1 -0
  539. package/dist/tools/code-intelligence.js +124 -0
  540. package/dist/tools/code-intelligence.js.map +1 -0
  541. package/dist/tools/compose-permissions.d.ts +38 -4
  542. package/dist/tools/compose-permissions.d.ts.map +1 -1
  543. package/dist/tools/compose-permissions.js +295 -33
  544. package/dist/tools/compose-permissions.js.map +1 -1
  545. package/dist/tools/dolt-push-mutex.d.ts +44 -0
  546. package/dist/tools/dolt-push-mutex.d.ts.map +1 -0
  547. package/dist/tools/dolt-push-mutex.js +83 -0
  548. package/dist/tools/dolt-push-mutex.js.map +1 -0
  549. package/dist/tools/execute-command.d.ts +13 -1
  550. package/dist/tools/execute-command.d.ts.map +1 -1
  551. package/dist/tools/execute-command.js +108 -21
  552. package/dist/tools/execute-command.js.map +1 -1
  553. package/dist/tools/execute-prompt.d.ts +84 -12
  554. package/dist/tools/execute-prompt.d.ts.map +1 -1
  555. package/dist/tools/execute-prompt.js +1191 -88
  556. package/dist/tools/execute-prompt.js.map +1 -1
  557. package/dist/tools/get-member-model-pricing.d.ts +21 -0
  558. package/dist/tools/get-member-model-pricing.d.ts.map +1 -0
  559. package/dist/tools/get-member-model-pricing.js +29 -0
  560. package/dist/tools/get-member-model-pricing.js.map +1 -0
  561. package/dist/tools/kb-capture.d.ts +53 -0
  562. package/dist/tools/kb-capture.d.ts.map +1 -0
  563. package/dist/tools/kb-capture.js +130 -0
  564. package/dist/tools/kb-capture.js.map +1 -0
  565. package/dist/tools/kb-context.d.ts +17 -0
  566. package/dist/tools/kb-context.d.ts.map +1 -0
  567. package/dist/tools/kb-context.js +29 -0
  568. package/dist/tools/kb-context.js.map +1 -0
  569. package/dist/tools/kb-export.d.ts +19 -0
  570. package/dist/tools/kb-export.d.ts.map +1 -0
  571. package/dist/tools/kb-export.js +344 -0
  572. package/dist/tools/kb-export.js.map +1 -0
  573. package/dist/tools/kb-feedback.d.ts +23 -0
  574. package/dist/tools/kb-feedback.d.ts.map +1 -0
  575. package/dist/tools/kb-feedback.js +43 -0
  576. package/dist/tools/kb-feedback.js.map +1 -0
  577. package/dist/tools/kb-freshness-sweep.d.ts +14 -0
  578. package/dist/tools/kb-freshness-sweep.d.ts.map +1 -0
  579. package/dist/tools/kb-freshness-sweep.js +29 -0
  580. package/dist/tools/kb-freshness-sweep.js.map +1 -0
  581. package/dist/tools/kb-harvest.d.ts +20 -0
  582. package/dist/tools/kb-harvest.d.ts.map +1 -0
  583. package/dist/tools/kb-harvest.js +143 -0
  584. package/dist/tools/kb-harvest.js.map +1 -0
  585. package/dist/tools/kb-import.d.ts +44 -0
  586. package/dist/tools/kb-import.d.ts.map +1 -0
  587. package/dist/tools/kb-import.js +239 -0
  588. package/dist/tools/kb-import.js.map +1 -0
  589. package/dist/tools/kb-invalidate.d.ts +19 -0
  590. package/dist/tools/kb-invalidate.d.ts.map +1 -0
  591. package/dist/tools/kb-invalidate.js +34 -0
  592. package/dist/tools/kb-invalidate.js.map +1 -0
  593. package/dist/tools/kb-list.d.ts +32 -0
  594. package/dist/tools/kb-list.d.ts.map +1 -0
  595. package/dist/tools/kb-list.js +43 -0
  596. package/dist/tools/kb-list.js.map +1 -0
  597. package/dist/tools/kb-promote.d.ts +20 -0
  598. package/dist/tools/kb-promote.d.ts.map +1 -0
  599. package/dist/tools/kb-promote.js +20 -0
  600. package/dist/tools/kb-promote.js.map +1 -0
  601. package/dist/tools/kb-query.d.ts +35 -0
  602. package/dist/tools/kb-query.d.ts.map +1 -0
  603. package/dist/tools/kb-query.js +111 -0
  604. package/dist/tools/kb-query.js.map +1 -0
  605. package/dist/tools/kb-reconcile-prefilter.d.ts +14 -0
  606. package/dist/tools/kb-reconcile-prefilter.d.ts.map +1 -0
  607. package/dist/tools/kb-reconcile-prefilter.js +26 -0
  608. package/dist/tools/kb-reconcile-prefilter.js.map +1 -0
  609. package/dist/tools/kb-resolve-contradiction.d.ts +23 -0
  610. package/dist/tools/kb-resolve-contradiction.d.ts.map +1 -0
  611. package/dist/tools/kb-resolve-contradiction.js +37 -0
  612. package/dist/tools/kb-resolve-contradiction.js.map +1 -0
  613. package/dist/tools/kb-session-prime.d.ts +26 -0
  614. package/dist/tools/kb-session-prime.d.ts.map +1 -0
  615. package/dist/tools/kb-session-prime.js +392 -0
  616. package/dist/tools/kb-session-prime.js.map +1 -0
  617. package/dist/tools/kb-setup.d.ts +20 -0
  618. package/dist/tools/kb-setup.d.ts.map +1 -0
  619. package/dist/tools/kb-setup.js +49 -0
  620. package/dist/tools/kb-setup.js.map +1 -0
  621. package/dist/tools/kb-stats.d.ts +20 -0
  622. package/dist/tools/kb-stats.d.ts.map +1 -0
  623. package/dist/tools/kb-stats.js +115 -0
  624. package/dist/tools/kb-stats.js.map +1 -0
  625. package/dist/tools/list-members.d.ts.map +1 -1
  626. package/dist/tools/list-members.js +39 -7
  627. package/dist/tools/list-members.js.map +1 -1
  628. package/dist/tools/member-detail.d.ts +1 -1
  629. package/dist/tools/member-detail.d.ts.map +1 -1
  630. package/dist/tools/member-detail.js +16 -2
  631. package/dist/tools/member-detail.js.map +1 -1
  632. package/dist/tools/member-reservation.d.ts +29 -0
  633. package/dist/tools/member-reservation.d.ts.map +1 -0
  634. package/dist/tools/member-reservation.js +71 -0
  635. package/dist/tools/member-reservation.js.map +1 -0
  636. package/dist/tools/monitor-task.d.ts.map +1 -1
  637. package/dist/tools/monitor-task.js +21 -3
  638. package/dist/tools/monitor-task.js.map +1 -1
  639. package/dist/tools/provision-auth.d.ts.map +1 -1
  640. package/dist/tools/provision-auth.js +10 -3
  641. package/dist/tools/provision-auth.js.map +1 -1
  642. package/dist/tools/provision-vcs-auth.d.ts +7 -7
  643. package/dist/tools/provision-vcs-auth.js +1 -1
  644. package/dist/tools/provision-vcs-auth.js.map +1 -1
  645. package/dist/tools/register-member.d.ts +20 -5
  646. package/dist/tools/register-member.d.ts.map +1 -1
  647. package/dist/tools/register-member.js +174 -6
  648. package/dist/tools/register-member.js.map +1 -1
  649. package/dist/tools/remove-member.d.ts +1 -1
  650. package/dist/tools/remove-member.d.ts.map +1 -1
  651. package/dist/tools/remove-member.js +17 -3
  652. package/dist/tools/remove-member.js.map +1 -1
  653. package/dist/tools/report-status.d.ts +33 -0
  654. package/dist/tools/report-status.d.ts.map +1 -0
  655. package/dist/tools/report-status.js +45 -0
  656. package/dist/tools/report-status.js.map +1 -0
  657. package/dist/tools/respond-to-message.d.ts +21 -0
  658. package/dist/tools/respond-to-message.d.ts.map +1 -0
  659. package/dist/tools/respond-to-message.js +23 -0
  660. package/dist/tools/respond-to-message.js.map +1 -0
  661. package/dist/tools/send-email.d.ts +69 -0
  662. package/dist/tools/send-email.d.ts.map +1 -0
  663. package/dist/tools/send-email.js +177 -0
  664. package/dist/tools/send-email.js.map +1 -0
  665. package/dist/tools/send-files.d.ts +3 -0
  666. package/dist/tools/send-files.d.ts.map +1 -1
  667. package/dist/tools/send-files.js +88 -8
  668. package/dist/tools/send-files.js.map +1 -1
  669. package/dist/tools/send-message.d.ts +27 -0
  670. package/dist/tools/send-message.d.ts.map +1 -0
  671. package/dist/tools/send-message.js +46 -0
  672. package/dist/tools/send-message.js.map +1 -0
  673. package/dist/tools/setup-ssh-key.d.ts.map +1 -1
  674. package/dist/tools/setup-ssh-key.js +2 -0
  675. package/dist/tools/setup-ssh-key.js.map +1 -1
  676. package/dist/tools/shutdown-server.d.ts +2 -0
  677. package/dist/tools/shutdown-server.d.ts.map +1 -1
  678. package/dist/tools/shutdown-server.js +19 -0
  679. package/dist/tools/shutdown-server.js.map +1 -1
  680. package/dist/tools/update-member.d.ts +11 -8
  681. package/dist/tools/update-member.d.ts.map +1 -1
  682. package/dist/tools/update-member.js +36 -2
  683. package/dist/tools/update-member.js.map +1 -1
  684. package/dist/types.d.ts +16 -3
  685. package/dist/types.d.ts.map +1 -1
  686. package/dist/utils/agent-helpers.d.ts +2 -1
  687. package/dist/utils/agent-helpers.d.ts.map +1 -1
  688. package/dist/utils/agent-helpers.js +7 -2
  689. package/dist/utils/agent-helpers.js.map +1 -1
  690. package/dist/utils/pid-helpers.d.ts +15 -0
  691. package/dist/utils/pid-helpers.d.ts.map +1 -1
  692. package/dist/utils/pid-helpers.js +23 -0
  693. package/dist/utils/pid-helpers.js.map +1 -1
  694. package/dist/utils/process-utils.d.ts +3 -0
  695. package/dist/utils/process-utils.d.ts.map +1 -0
  696. package/dist/utils/process-utils.js +42 -0
  697. package/dist/utils/process-utils.js.map +1 -0
  698. package/dist/utils/prompt-errors.d.ts +2 -1
  699. package/dist/utils/prompt-errors.d.ts.map +1 -1
  700. package/dist/utils/prompt-errors.js +13 -3
  701. package/dist/utils/prompt-errors.js.map +1 -1
  702. package/dist/utils/session-caller.d.ts +28 -0
  703. package/dist/utils/session-caller.d.ts.map +1 -0
  704. package/dist/utils/session-caller.js +24 -0
  705. package/dist/utils/session-caller.js.map +1 -0
  706. package/dist/utils/work-folder-validation.d.ts +39 -0
  707. package/dist/utils/work-folder-validation.d.ts.map +1 -0
  708. package/dist/utils/work-folder-validation.js +60 -0
  709. package/dist/utils/work-folder-validation.js.map +1 -0
  710. package/dist/utils/workspace-trust.d.ts +24 -0
  711. package/dist/utils/workspace-trust.d.ts.map +1 -0
  712. package/dist/utils/workspace-trust.js +35 -0
  713. package/dist/utils/workspace-trust.js.map +1 -0
  714. package/dist/workflows/auto-sprint.js +994 -91
  715. package/package.json +40 -9
  716. package/packages/apra-fleet-client/package.json +26 -0
  717. package/packages/apra-fleet-client/src/client/api.mjs +510 -0
  718. package/packages/apra-fleet-client/src/client/client.mjs +146 -0
  719. package/packages/apra-fleet-client/src/client/errors.mjs +71 -0
  720. package/packages/apra-fleet-client/src/client/factory.mjs +65 -0
  721. package/packages/apra-fleet-client/src/client/server-resolution.mjs +265 -0
  722. package/packages/apra-fleet-client/src/client/transport.mjs +327 -0
  723. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +303 -0
  724. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +101 -0
  725. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +151 -0
  726. package/packages/apra-fleet-se/apra-pm/agents/doer.md +259 -0
  727. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +188 -0
  728. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +332 -0
  729. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +216 -0
  730. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +201 -0
  731. package/packages/apra-fleet-se/apra-pm/agents/planner.md +322 -0
  732. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +234 -0
  733. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +275 -0
  734. package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-input.json +35 -0
  735. package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-output.json +164 -0
  736. package/packages/apra-fleet-se/apra-pm/agents/schemas/ci-watcher-input.json +26 -0
  737. package/packages/apra-fleet-se/apra-pm/agents/schemas/ci-watcher-output.json +18 -0
  738. package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-input.json +19 -0
  739. package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +17 -0
  740. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-input.json +25 -0
  741. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +82 -0
  742. package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-input.json +31 -0
  743. package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-output.json +75 -0
  744. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-input.json +20 -0
  745. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +61 -0
  746. package/packages/apra-fleet-se/apra-pm/agents/schemas/kb-reconciler-output.json +87 -0
  747. package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-input.json +15 -0
  748. package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +30 -0
  749. package/packages/apra-fleet-se/apra-pm/agents/schemas/planner-output.json +65 -0
  750. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-input.json +15 -0
  751. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +50 -0
  752. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-input.json +25 -0
  753. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +135 -0
  754. package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +402 -0
  755. package/packages/apra-fleet-se/apra-pm/skills/pm/beads.md +148 -0
  756. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +157 -0
  757. package/packages/apra-fleet-se/apra-pm/skills/pm/doer-reviewer-loop.md +300 -0
  758. package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +127 -0
  759. package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +56 -0
  760. package/packages/apra-fleet-se/apra-pm/skills/pm/kb-reconcile.md +132 -0
  761. package/packages/apra-fleet-se/apra-pm/skills/pm/kb-review.md +109 -0
  762. package/packages/apra-fleet-se/apra-pm/skills/pm/simple-sprint.md +65 -0
  763. package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +327 -0
  764. package/packages/apra-fleet-se/apra-pm/skills/pm/worktrees.md +92 -0
  765. package/packages/apra-fleet-se/apra-pm/version.json +3 -0
  766. package/packages/apra-fleet-se/bin/cli.mjs +864 -0
  767. package/packages/apra-fleet-se/bin/serve.mjs +395 -0
  768. package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +178 -0
  769. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +940 -0
  770. package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +177 -0
  771. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +191 -0
  772. package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +23 -0
  773. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-manual-recovery-verified.md +256 -0
  774. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +1482 -0
  775. package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +908 -0
  776. package/packages/apra-fleet-se/fleet-sprint/docs/fleet-sprint-diagram.md +94 -0
  777. package/packages/apra-fleet-se/fleet-sprint/docs/shared-orchestrator-reservation-design.md +399 -0
  778. package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +1125 -0
  779. package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +72 -0
  780. package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +972 -0
  781. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +1310 -0
  782. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +616 -0
  783. package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +118 -0
  784. package/packages/apra-fleet-se/fleet-sprint/runner.js +10747 -0
  785. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +114 -0
  786. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +350 -0
  787. package/packages/apra-fleet-se/fleet-sprint/sprint-lock.mjs +140 -0
  788. package/packages/apra-fleet-se/fleet-sprint/sprint-progress.mjs +101 -0
  789. package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +435 -0
  790. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +68 -0
  791. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +53 -0
  792. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +146 -0
  793. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/generic-git.mjs +176 -0
  794. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +235 -0
  795. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +218 -0
  796. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +942 -0
  797. package/packages/apra-fleet-se/package.json +29 -0
  798. package/packages/apra-fleet-se/workflow.json +1 -0
  799. package/packages/apra-fleet-workflow/package.json +30 -0
  800. package/packages/apra-fleet-workflow/src/viewer/command-output-cap.mjs +112 -0
  801. package/packages/apra-fleet-workflow/src/viewer/debounced-writer.mjs +153 -0
  802. package/packages/apra-fleet-workflow/src/viewer/html-utils.mjs +31 -0
  803. package/packages/apra-fleet-workflow/src/viewer/index.mjs +1439 -0
  804. package/packages/apra-fleet-workflow/src/viewer/lean-state.mjs +237 -0
  805. package/packages/apra-fleet-workflow/src/viewer/run-state-paths.mjs +130 -0
  806. package/packages/apra-fleet-workflow/src/viewer/run-title.mjs +60 -0
  807. package/packages/apra-fleet-workflow/src/viewer/sprint-state-paths.mjs +29 -0
  808. package/packages/apra-fleet-workflow/src/workflow/engine.mjs +200 -0
  809. package/packages/apra-fleet-workflow/src/workflow/errors.mjs +146 -0
  810. package/packages/apra-fleet-workflow/src/workflow/index.mjs +1727 -0
  811. package/packages/apra-fleet-workflow/src/workflow/journal.mjs +291 -0
  812. package/packages/apra-fleet-workflow/src/workflow/pricing.mjs +99 -0
  813. package/packages/apra-fleet-workflow/src/workflow/vetting.mjs +111 -0
  814. package/scripts/agy-transcript-reader.js +1 -0
  815. package/scripts/fleet-statusline.sh +17 -13
  816. package/skills/fleet/SKILL.md +37 -2
  817. package/skills/fleet/beads.md +14 -7
  818. package/skills/fleet/knowledge-agent.md +66 -0
  819. package/skills/fleet/permissions.md +76 -2
  820. package/skills/fleet/profiles/base-dev.json +11 -1
  821. package/skills/fleet/profiles/base-reviewer.json +9 -1
  822. package/skills/fleet/profiles/node.json +2 -2
  823. package/skills/fleet/profiles/tag-kb-reconciler.json +20 -0
  824. package/version.json +1 -1
  825. package/scripts/agy-settings-merge.js +0 -27
  826. /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": {
@@ -1211,7 +1339,8 @@ const REVIEW_SCHEMA = {
1211
1339
  ],
1212
1340
  "properties": {
1213
1341
  "title": {
1214
- "type": "string"
1342
+ "type": "string",
1343
+ "description": "Plain text only: letters, digits, space, and . , : ; ! ? ( ) ' _ / [ ] - -- nothing else. No backticks, double quotes, $, or backslash (the title is interpolated into a shell command downstream). Do NOT wrap a command/flag/filename in backticks here -- write it plain (e.g. \"Surface the Windows service registration mode in apra-fleet status\") or move the formatted detail into description instead, which has no such restriction. NOT enforced as a hard schema constraint here (deliberately no \"pattern\"): a single out-of-allowlist newTask title must never make ajv reject/retry the WHOLE structured verdict (verdict, notes, reopenIds, and the other newTasks) -- see validateNewTask() in fleet-sprint/runner.js, the actual (per-item, non-fatal) enforcement point, applied after parsing."
1215
1344
  },
1216
1345
  "description": {
1217
1346
  "type": "string"
@@ -1221,6 +1350,80 @@ const REVIEW_SCHEMA = {
1221
1350
  }
1222
1351
  }
1223
1352
  }
1353
+ },
1354
+ "kb_promotions": {
1355
+ "type": "array",
1356
+ "description": "Entries this reviewer VERIFIED against the tree and is promoting to CONFIRMED. Reviewer-only: promotion is the sole path that mints CONFIRMED, and widening capture does not widen promotion. The engine makes the kb_promote calls.",
1357
+ "items": {
1358
+ "type": "object",
1359
+ "required": [
1360
+ "id",
1361
+ "reason"
1362
+ ],
1363
+ "properties": {
1364
+ "id": {
1365
+ "type": "string",
1366
+ "description": "The entry id, copied verbatim from the 'KNOWLEDGE BANK -- promotion candidates' block in your dispatch prompt. That block is the ONLY source of promotable ids -- do not call a kb_* tool to find one, and never invent one.",
1367
+ "minLength": 1
1368
+ },
1369
+ "reason": {
1370
+ "type": "string",
1371
+ "description": "The evidence for this promotion -- what you actually checked. kb_promote refuses a trivial reason.",
1372
+ "minLength": 20
1373
+ }
1374
+ }
1375
+ }
1376
+ },
1377
+ "kb_captures": {
1378
+ "type": "array",
1379
+ "description": "Durable knowledge this role verified during its run. The engine makes the kb_capture calls; the role only decides. Optional -- omit or send [] to capture nothing.",
1380
+ "items": {
1381
+ "type": "object",
1382
+ "required": [
1383
+ "type",
1384
+ "title",
1385
+ "summary",
1386
+ "content",
1387
+ "source_files"
1388
+ ],
1389
+ "properties": {
1390
+ "type": {
1391
+ "type": "string",
1392
+ "enum": [
1393
+ "knowledge",
1394
+ "learning",
1395
+ "runbook"
1396
+ ]
1397
+ },
1398
+ "title": {
1399
+ "type": "string",
1400
+ "minLength": 8
1401
+ },
1402
+ "summary": {
1403
+ "type": "string",
1404
+ "minLength": 20
1405
+ },
1406
+ "content": {
1407
+ "type": "string",
1408
+ "description": "Full detail of the entry. REQUIRED -- kbCaptureSchema declares content as z.string().min(1), so a capture without it is rejected at the MCP boundary and persists nothing (apra-fleet-23c).",
1409
+ "minLength": 40
1410
+ },
1411
+ "source_files": {
1412
+ "type": "array",
1413
+ "description": "Files that make this claim checkable. At least one is REQUIRED -- SqliteProvider.capture() rejects an entry with no basis, because the freshness sweep can never stale it.",
1414
+ "items": {
1415
+ "type": "string"
1416
+ },
1417
+ "minItems": 1
1418
+ },
1419
+ "symbols": {
1420
+ "type": "array",
1421
+ "items": {
1422
+ "type": "string"
1423
+ }
1424
+ }
1425
+ }
1426
+ }
1224
1427
  }
1225
1428
  }
1226
1429
  };
@@ -1302,6 +1505,57 @@ const DOER_STATUS_SCHEMA = {
1302
1505
  },
1303
1506
  "notes": {
1304
1507
  "type": "string"
1508
+ },
1509
+ "kb_captures": {
1510
+ "type": "array",
1511
+ "description": "Durable knowledge this role verified during its run. The engine makes the kb_capture calls; the role only decides. Optional -- omit or send [] to capture nothing.",
1512
+ "items": {
1513
+ "type": "object",
1514
+ "required": [
1515
+ "type",
1516
+ "title",
1517
+ "summary",
1518
+ "content",
1519
+ "source_files"
1520
+ ],
1521
+ "properties": {
1522
+ "type": {
1523
+ "type": "string",
1524
+ "enum": [
1525
+ "knowledge",
1526
+ "learning",
1527
+ "runbook"
1528
+ ]
1529
+ },
1530
+ "title": {
1531
+ "type": "string",
1532
+ "minLength": 8
1533
+ },
1534
+ "summary": {
1535
+ "type": "string",
1536
+ "minLength": 20
1537
+ },
1538
+ "content": {
1539
+ "type": "string",
1540
+ "description": "Full detail of the entry. REQUIRED -- kbCaptureSchema declares content as z.string().min(1), so a capture without it is rejected at the MCP boundary and persists nothing (apra-fleet-23c).",
1541
+ "minLength": 40
1542
+ },
1543
+ "source_files": {
1544
+ "type": "array",
1545
+ "description": "Files that make this claim checkable. At least one is REQUIRED -- SqliteProvider.capture() rejects an entry with no basis, because the freshness sweep can never stale it.",
1546
+ "items": {
1547
+ "type": "string"
1548
+ },
1549
+ "minItems": 1
1550
+ },
1551
+ "symbols": {
1552
+ "type": "array",
1553
+ "items": {
1554
+ "type": "string"
1555
+ }
1556
+ }
1557
+ }
1558
+ }
1305
1559
  }
1306
1560
  }
1307
1561
  };
@@ -1355,6 +1609,116 @@ const INTEG_RUN_SCHEMA = {
1355
1609
  },
1356
1610
  "summary": {
1357
1611
  "type": "string"
1612
+ },
1613
+ "deployedSha": {
1614
+ "type": "string",
1615
+ "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'."
1616
+ },
1617
+ "verifySetClosed": {
1618
+ "type": "array",
1619
+ "items": {
1620
+ "type": "string"
1621
+ },
1622
+ "description": "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."
1623
+ },
1624
+ "verifySetLeftOpen": {
1625
+ "type": "array",
1626
+ "items": {
1627
+ "type": "object",
1628
+ "required": [
1629
+ "id",
1630
+ "reason"
1631
+ ],
1632
+ "properties": {
1633
+ "id": {
1634
+ "type": "string"
1635
+ },
1636
+ "reason": {
1637
+ "type": "string"
1638
+ }
1639
+ }
1640
+ },
1641
+ "description": "Verify-set bead ids (Step 1b) left open this run, with why (gap bug filed, or inconclusive). Optional for backward compatibility."
1642
+ },
1643
+ "observedFailures": {
1644
+ "type": "array",
1645
+ "items": {
1646
+ "type": "object",
1647
+ "required": [
1648
+ "test",
1649
+ "cause",
1650
+ "beadId"
1651
+ ],
1652
+ "properties": {
1653
+ "test": {
1654
+ "type": "string"
1655
+ },
1656
+ "cause": {
1657
+ "type": "string"
1658
+ },
1659
+ "beadId": {
1660
+ "type": "string"
1661
+ }
1662
+ }
1663
+ },
1664
+ "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."
1665
+ }
1666
+ }
1667
+ };
1668
+ const REGRESSION_RUN_SCHEMA = {
1669
+ "$schema": "http://json-schema.org/draft-07/schema#",
1670
+ "$id": "apra-pm/regression-test-runner-output@1",
1671
+ "title": "regression-test-runner output",
1672
+ "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.",
1673
+ "type": "object",
1674
+ "required": [
1675
+ "passed",
1676
+ "suitePassed",
1677
+ "smokePassed",
1678
+ "bugsFiled",
1679
+ "summary"
1680
+ ],
1681
+ "properties": {
1682
+ "passed": {
1683
+ "type": "boolean",
1684
+ "description": "True only if BOTH suitePassed and smokePassed are true AND no carry-over bug was filed this run."
1685
+ },
1686
+ "suitePassed": {
1687
+ "type": "boolean",
1688
+ "description": "Result of playbook Part 1 -- the real-bd functional suite."
1689
+ },
1690
+ "smokePassed": {
1691
+ "type": "boolean",
1692
+ "description": "Result of playbook Part 2 -- the toy-sprint smoke test."
1693
+ },
1694
+ "bugsFiled": {
1695
+ "type": "array",
1696
+ "items": {
1697
+ "type": "string"
1698
+ },
1699
+ "description": "Ids of the standalone, parent-less [regression][carry-over] beads created this run (empty array if none)."
1700
+ },
1701
+ "summary": {
1702
+ "type": "string",
1703
+ "description": "One paragraph describing what was tested, what passed, what failed, and reiterating that the result is informational."
1704
+ },
1705
+ "smokeEvidence": {
1706
+ "type": "object",
1707
+ "description": "Optional structured evidence from Part 2 (the toy-sprint smoke test), so the result is machine-checkable instead of self-reported prose.",
1708
+ "properties": {
1709
+ "versionStdout": {
1710
+ "type": "string",
1711
+ "description": "Verbatim stdout of running the toy CLI's --version on the sprint branch."
1712
+ },
1713
+ "canaryStatus": {
1714
+ "type": "string",
1715
+ "description": "The status field from `bd show gh-toy-4ef` (e.g. \"closed\")."
1716
+ },
1717
+ "toyRepoHeadSha": {
1718
+ "type": "string",
1719
+ "description": "The toy repo's head commit SHA after the toy sprint."
1720
+ }
1721
+ }
1358
1722
  }
1359
1723
  }
1360
1724
  };
@@ -1403,6 +1767,145 @@ const HARVEST_SCHEMA = {
1403
1767
  },
1404
1768
  "notes": {
1405
1769
  "type": "string"
1770
+ },
1771
+ "kb_captures": {
1772
+ "type": "array",
1773
+ "description": "Durable knowledge this role verified during its run. The engine makes the kb_capture calls; the role only decides. Optional -- omit or send [] to capture nothing.",
1774
+ "items": {
1775
+ "type": "object",
1776
+ "required": [
1777
+ "type",
1778
+ "title",
1779
+ "summary",
1780
+ "content",
1781
+ "source_files"
1782
+ ],
1783
+ "properties": {
1784
+ "type": {
1785
+ "type": "string",
1786
+ "enum": [
1787
+ "knowledge",
1788
+ "learning",
1789
+ "runbook"
1790
+ ]
1791
+ },
1792
+ "title": {
1793
+ "type": "string",
1794
+ "minLength": 8
1795
+ },
1796
+ "summary": {
1797
+ "type": "string",
1798
+ "minLength": 20
1799
+ },
1800
+ "content": {
1801
+ "type": "string",
1802
+ "description": "Full detail of the entry. REQUIRED -- kbCaptureSchema declares content as z.string().min(1), so a capture without it is rejected at the MCP boundary and persists nothing (apra-fleet-23c).",
1803
+ "minLength": 40
1804
+ },
1805
+ "source_files": {
1806
+ "type": "array",
1807
+ "description": "Files that make this claim checkable. At least one is REQUIRED -- SqliteProvider.capture() rejects an entry with no basis, because the freshness sweep can never stale it.",
1808
+ "items": {
1809
+ "type": "string"
1810
+ },
1811
+ "minItems": 1
1812
+ },
1813
+ "symbols": {
1814
+ "type": "array",
1815
+ "items": {
1816
+ "type": "string"
1817
+ }
1818
+ }
1819
+ }
1820
+ }
1821
+ }
1822
+ }
1823
+ };
1824
+ const PLANNER_SCHEMA = {
1825
+ "$schema": "http://json-schema.org/draft-07/schema#",
1826
+ "$id": "apra-pm/planner-output@1",
1827
+ "title": "planner output",
1828
+ "description": "Canonical machine-readable output contract for the planner role. See agents/planner.md Step 4 (Validate your own DAG) and Step 0 (Knowledge Bank) for the prose contract this mirrors. The planner previously had no schema at all -- its dispatch ended 'Confirm with any text when done' -- so this is the contract that makes its output routable rather than free prose.",
1829
+ "type": "object",
1830
+ "required": [
1831
+ "status",
1832
+ "notes"
1833
+ ],
1834
+ "properties": {
1835
+ "status": {
1836
+ "type": "string",
1837
+ "enum": [
1838
+ "OK",
1839
+ "BLOCKED"
1840
+ ]
1841
+ },
1842
+ "notes": {
1843
+ "type": "string"
1844
+ },
1845
+ "featureIds": {
1846
+ "type": "array",
1847
+ "description": "Feature-level bead ids created or updated this round.",
1848
+ "items": {
1849
+ "type": "string"
1850
+ }
1851
+ },
1852
+ "taskIds": {
1853
+ "type": "array",
1854
+ "description": "Task-level bead ids created or updated this round.",
1855
+ "items": {
1856
+ "type": "string"
1857
+ }
1858
+ },
1859
+ "kb_captures": {
1860
+ "type": "array",
1861
+ "description": "Durable knowledge this role verified during its run. The engine makes the kb_capture calls; the role only decides. Optional -- omit or send [] to capture nothing.",
1862
+ "items": {
1863
+ "type": "object",
1864
+ "required": [
1865
+ "type",
1866
+ "title",
1867
+ "summary",
1868
+ "content",
1869
+ "source_files"
1870
+ ],
1871
+ "properties": {
1872
+ "type": {
1873
+ "type": "string",
1874
+ "enum": [
1875
+ "knowledge",
1876
+ "learning",
1877
+ "runbook"
1878
+ ]
1879
+ },
1880
+ "title": {
1881
+ "type": "string",
1882
+ "minLength": 8
1883
+ },
1884
+ "summary": {
1885
+ "type": "string",
1886
+ "minLength": 20
1887
+ },
1888
+ "content": {
1889
+ "type": "string",
1890
+ "description": "Full detail of the entry. REQUIRED -- kbCaptureSchema declares content as z.string().min(1), so a capture without it is rejected at the MCP boundary and persists nothing (apra-fleet-23c).",
1891
+ "minLength": 40
1892
+ },
1893
+ "source_files": {
1894
+ "type": "array",
1895
+ "description": "Files that make this claim checkable. At least one is REQUIRED -- SqliteProvider.capture() rejects an entry with no basis, because the freshness sweep can never stale it.",
1896
+ "items": {
1897
+ "type": "string"
1898
+ },
1899
+ "minItems": 1
1900
+ },
1901
+ "symbols": {
1902
+ "type": "array",
1903
+ "items": {
1904
+ "type": "string"
1905
+ }
1906
+ }
1907
+ }
1908
+ }
1406
1909
  }
1407
1910
  }
1408
1911
  };
@@ -1501,6 +2004,244 @@ async function parallel(tasks) {
1501
2004
  return Promise.all(tasks);
1502
2005
  }
1503
2006
 
2007
+ // -------------------------------------------------------- KB priming
2008
+ //
2009
+ // Dispatches a cheap agent to call kb_session_prime (and kb_import on first
2010
+ // call) and returns the top entries. The workflow injects these entries
2011
+ // directly into agent prompts -- agents never need to call KB tools themselves.
2012
+
2013
+ const KB_PRIMER_SCHEMA = {
2014
+ type: 'object',
2015
+ required: ['entries', 'sessionWarm', 'imported'],
2016
+ properties: {
2017
+ sessionWarm: { type: 'boolean' },
2018
+ imported: { type: 'boolean' },
2019
+ entries: {
2020
+ type: 'array',
2021
+ items: {
2022
+ type: 'object',
2023
+ required: ['title', 'summary'],
2024
+ properties: {
2025
+ title: { type: 'string' },
2026
+ summary: { type: 'string' },
2027
+ confidence: { type: 'string' },
2028
+ symbols: { type: 'array', items: { type: 'string' } },
2029
+ source_files: { type: 'array', items: { type: 'string' } },
2030
+ type: { type: 'string' },
2031
+ },
2032
+ },
2033
+ },
2034
+ },
2035
+ };
2036
+
2037
+ let _kbImported = false;
2038
+
2039
+ async function primeKB(repoPath) {
2040
+ const importStep = _kbImported ? '' :
2041
+ `Step 2: Import the bible into the KB database.\n` +
2042
+ ` a. First check if "${repoPath}/.fleet/kb-canonical.json" exists (use Bash: test -f).\n` +
2043
+ ` b. If it does NOT exist, run: echo $APRA_FLEET_DATA_DIR (using Bash) to get the data dir.\n` +
2044
+ ` Then check if "$APRA_FLEET_DATA_DIR/kb-canonical.json" exists.\n` +
2045
+ ` c. Call mcp__apra-fleet__kb_import with repo set to "${repoPath}".\n` +
2046
+ ` If the bible was found at the data dir path (step b), also pass\n` +
2047
+ ` path set to that full path (e.g. "/tmp/sprint-test/data-b/kb-canonical.json").\n` +
2048
+ ` d. If neither path has the bible, or the tool is unavailable, set imported=false and continue.\n`;
2049
+ const stepNum = _kbImported ? 2 : 3;
2050
+ try {
2051
+ const result = await dispatch(
2052
+ `You are a knowledge-base primer. Your ONLY job is to load KB tools, ` +
2053
+ `optionally import the bible, call kb_session_prime, and return the results.\n\n` +
2054
+ `Step 1: Call ToolSearch with query "select:mcp__apra-fleet__kb_session_prime` +
2055
+ (_kbImported ? `"` : `,mcp__apra-fleet__kb_import"`) +
2056
+ ` to load the tool schema(s).\n` +
2057
+ importStep +
2058
+ `Step ${stepNum}: Call mcp__apra-fleet__kb_session_prime with:\n` +
2059
+ ` repo_path: "${repoPath}"\n` +
2060
+ `Step ${stepNum + 1}: Parse the JSON string result. Extract the top_entries array.\n` +
2061
+ ` For each entry return: title, summary, confidence, symbols, source_files, type.\n` +
2062
+ ` Do NOT return the content field.\n` +
2063
+ ` Set sessionWarm from the result. Set imported to true if you ran kb_import successfully.\n\n` +
2064
+ `If ToolSearch returns no KB tools, return {entries:[], sessionWarm:false, imported:false}.\n` +
2065
+ `Return the structured result. Do not summarize or interpret.`,
2066
+ {
2067
+ model: MODEL_HAIKU,
2068
+ label: 'kb-primer',
2069
+ phase: 'Plan',
2070
+ schema: KB_PRIMER_SCHEMA,
2071
+ maxTurns: 10,
2072
+ }
2073
+ );
2074
+ if (result && result.imported) _kbImported = true;
2075
+ return result;
2076
+ } catch (e) {
2077
+ log(`KB primer failed: ${String(e).slice(0, 120)} -- proceeding without KB`);
2078
+ return null;
2079
+ }
2080
+ }
2081
+
2082
+ // --- Engine-executed KB capture and promote (KB trust pipeline, Phase 2) ---
2083
+ //
2084
+ // Judgment stays with the role agent; EXECUTION moves to the engine. A role
2085
+ // returns kb_captures / kb_promotions in its structured output and never calls
2086
+ // a KB tool itself. Three consequences the old prose-only contract could not
2087
+ // give: promotion no longer depends on an agent remembering Step 5, every
2088
+ // promotion is logged with its stated evidence, and the engine can refuse a
2089
+ // promotion BEFORE it is attempted.
2090
+ //
2091
+ // RUNTIME CONSTRAINT: this workflow is executed by Claude's Workflow tool in a
2092
+ // VM with no filesystem, no require(), and no MCP tool access -- only dispatched
2093
+ // subagents can call tools (see scripts/gen-auto-sprint-schemas.mjs's header for
2094
+ // the same constraint biting a previous revision). fleet-sprint/runner.js runs
2095
+ // under a different engine and DOES get an injected callTool, so it calls the KB
2096
+ // tools directly. Here the engine validates and logs, then hands the vetted
2097
+ // payload to one cheap executor agent whose only job is to make the calls.
2098
+
2099
+ // Promotion is the only path that mints CONFIRMED. Widening capture to four
2100
+ // roles deliberately does NOT widen promotion.
2101
+ const KB_PROMOTER_ROLES = new Set(['reviewer']);
2102
+
2103
+ const KB_MIN_PROMOTE_REASON = 20;
2104
+
2105
+ const KB_EXEC_SCHEMA = {
2106
+ type: 'object',
2107
+ required: ['captured', 'promoted'],
2108
+ properties: {
2109
+ captured: { type: 'number' },
2110
+ promoted: { type: 'number' },
2111
+ failed: { type: 'number' },
2112
+ notes: { type: 'string' },
2113
+ },
2114
+ };
2115
+
2116
+ /**
2117
+ * Validate what a role returned. Anything that would be refused downstream is
2118
+ * dropped HERE, with a reason logged, so a bad payload never becomes a tool call.
2119
+ * Returns { captures, promotions, rejected } -- all plain data.
2120
+ */
2121
+ function vetKbWork(role, result) {
2122
+ const captures = [];
2123
+ const promotions = [];
2124
+ const rejected = [];
2125
+
2126
+ const rawCaptures = (result && Array.isArray(result.kb_captures)) ? result.kb_captures : [];
2127
+ for (const c of rawCaptures) {
2128
+ if (!c || typeof c.title !== 'string' || typeof c.summary !== 'string') {
2129
+ rejected.push(`${role}: capture missing title/summary`);
2130
+ continue;
2131
+ }
2132
+ // Mirrors the Phase 1 provider invariant: an entry with no basis can never
2133
+ // be staled by the freshness sweep, so nothing could ever falsify it.
2134
+ if (!Array.isArray(c.source_files) || c.source_files.length === 0) {
2135
+ rejected.push(`${role}: capture "${c.title}" cites no source files`);
2136
+ continue;
2137
+ }
2138
+ if (!['knowledge', 'learning', 'runbook'].includes(c.type)) {
2139
+ rejected.push(`${role}: capture "${c.title}" has unsupported type ${String(c.type)}`);
2140
+ continue;
2141
+ }
2142
+ // apra-fleet-23c: kbCaptureSchema requires content (z.string().min(1)).
2143
+ // Omitting it meant every kb_capture failed zod validation at the MCP
2144
+ // boundary and persisted nothing. (This block had drifted out of sync with
2145
+ // the canonical copy in lib/vet-kb-work.mjs -- restored to match exactly.)
2146
+ if (typeof c.content !== 'string' || c.content.trim().length === 0) {
2147
+ rejected.push(`${role}: capture "${c.title}" has no content`);
2148
+ continue;
2149
+ }
2150
+ captures.push({
2151
+ type: c.type,
2152
+ title: c.title,
2153
+ summary: c.summary,
2154
+ content: c.content,
2155
+ source_files: c.source_files,
2156
+ symbols: Array.isArray(c.symbols) ? c.symbols : [],
2157
+ });
2158
+ }
2159
+
2160
+ const rawPromotions = (result && Array.isArray(result.kb_promotions)) ? result.kb_promotions : [];
2161
+ if (rawPromotions.length > 0 && !KB_PROMOTER_ROLES.has(role)) {
2162
+ rejected.push(`${role}: kb_promotions refused -- promotion is reviewer-only`);
2163
+ } else {
2164
+ for (const p of rawPromotions) {
2165
+ if (!p || typeof p.id !== 'string' || p.id.length === 0) {
2166
+ rejected.push(`${role}: promotion missing id`);
2167
+ continue;
2168
+ }
2169
+ if (typeof p.reason !== 'string' || p.reason.trim().length < KB_MIN_PROMOTE_REASON) {
2170
+ rejected.push(`${role}: promotion ${p.id} has no recorded evidence`);
2171
+ continue;
2172
+ }
2173
+ promotions.push({ id: p.id, reason: p.reason.trim() });
2174
+ }
2175
+ }
2176
+
2177
+ return { captures, promotions, rejected };
2178
+ }
2179
+
2180
+ /**
2181
+ * Execute vetted KB work. Returns null when there is nothing to do, so the
2182
+ * common case costs no dispatch at all.
2183
+ */
2184
+ async function runKbWork(repoPath, role, result) {
2185
+ const { captures, promotions, rejected } = vetKbWork(role, result);
2186
+
2187
+ for (const r of rejected) log(`KB refused -- ${r}`);
2188
+ // Every promotion is logged with its stated evidence, whether or not the call
2189
+ // later succeeds. This log IS the audit trail the bible never had.
2190
+ for (const p of promotions) log(`KB promote ${p.id} (${role}): ${p.reason}`);
2191
+
2192
+ if (captures.length === 0 && promotions.length === 0) return null;
2193
+
2194
+ try {
2195
+ return await dispatch(
2196
+ `You are a knowledge-base executor. Your ONLY job is to make the KB tool ` +
2197
+ `calls listed below and report counts. Make NO judgment about whether an ` +
2198
+ `entry is correct -- that decision has already been made and validated.\n\n` +
2199
+ `Step 1: Call ToolSearch with query ` +
2200
+ `"select:mcp__apra-fleet__kb_capture,mcp__apra-fleet__kb_promote".\n` +
2201
+ `Step 2: For EACH object in captures below, call mcp__apra-fleet__kb_capture ` +
2202
+ `with repo_path "${repoPath}" and that object's fields verbatim. Do not ` +
2203
+ `reword, merge, split or invent entries.\n` +
2204
+ `Step 3: For EACH object in promotions below, call mcp__apra-fleet__kb_promote ` +
2205
+ `with repo_path "${repoPath}" and that object's id and reason verbatim.\n` +
2206
+ `Step 4: Return the counts. A call refused by the tool counts in failed, ` +
2207
+ `not captured/promoted -- report it, do not retry it with altered fields.\n\n` +
2208
+ `captures: ${JSON.stringify(captures)}\n` +
2209
+ `promotions: ${JSON.stringify(promotions)}\n\n` +
2210
+ `If ToolSearch returns no KB tools, return {captured:0, promoted:0, failed:0}.`,
2211
+ {
2212
+ model: MODEL_HAIKU,
2213
+ label: `kb-exec-${role}`,
2214
+ phase: 'Develop',
2215
+ schema: KB_EXEC_SCHEMA,
2216
+ maxTurns: 20,
2217
+ }
2218
+ );
2219
+ } catch (e) {
2220
+ log(`KB executor failed for ${role}: ${String(e).slice(0, 120)} -- continuing`);
2221
+ return null;
2222
+ }
2223
+ }
2224
+
2225
+ const KB_CHAR_BUDGET = 4000;
2226
+
2227
+ function buildKBContext(kbResult) {
2228
+ if (!kbResult || !Array.isArray(kbResult.entries) || kbResult.entries.length === 0) {
2229
+ return '';
2230
+ }
2231
+ let block = `\n--- Project Knowledge Bank (${kbResult.entries.length} entries) ---\n` +
2232
+ `Trust CONFIRMED entries fully. Use INFERRED entries as hints, not facts.\n\n`;
2233
+ let len = block.length;
2234
+ for (const e of kbResult.entries) {
2235
+ const line = `- [${(e.confidence || 'CONFIRMED').toUpperCase()}] ${e.title}: ${e.summary}` +
2236
+ (e.symbols && e.symbols.length ? ` (symbols: ${e.symbols.join(', ')})` : '') + '\n';
2237
+ if (len + line.length > KB_CHAR_BUDGET) break;
2238
+ block += line;
2239
+ len += line.length;
2240
+ }
2241
+ block += `--- End Project Knowledge ---\n\n`;
2242
+ return block;
2243
+ }
2244
+
1504
2245
  // bd may prepend a `warning: ...` line to its --json stdout (notably bd 1.1.0's
1505
2246
  // "warning: beads.role not configured (GH#2950)"). In a normal terminal that goes to
1506
2247
  // stderr, but inside the workflow's sandboxed shell-dispatch subagents stderr merges
@@ -1543,16 +2284,18 @@ function bdSubtreeSnippet(rootsArr) {
1543
2284
  `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
2285
  }
1545
2286
 
1546
- async function countBeadsBlockers(thr, roots) {
2287
+ async function countBeadsBlockers(thr, roots, includeFeatures) {
1547
2288
  // Extract only IDs from bd graph to keep output small (avoids $(cat ...) file-reference issue).
1548
2289
  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('[]')}"`;
2290
+ 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
2291
  const cmds = [
1551
2292
  ...roots.map(id => `bd graph --json ${id} | ${idExtract}`),
1552
2293
  `bd list --status=open --json | ${openExtract}`,
1553
2294
  ];
1554
2295
  const r = await dispatchShell(cmds, { model: MODEL_HAIKU, label: 'check-blockers', phase: 'Develop' });
1555
- return parseBlockers(r?.outputs, roots.length, roots.length, thr, roots);
2296
+ // Leaf-scoped done-condition: open non-root type=task at priority<=thr, plus type=feature
2297
+ // only when includeFeatures (integ tests close features in-loop). See parseBlockers opts.
2298
+ return parseBlockers(r?.outputs, roots.length, roots.length, thr, { rootIds: roots, leaf: true, includeFeatures });
1556
2299
  }
1557
2300
 
1558
2301
  async function getReadyStreaks(rootIds) {
@@ -1675,7 +2418,7 @@ phase('Plan');
1675
2418
  // Phase 1: deterministic setup steps -- run via dispatchShell so each command
1676
2419
  // executes exactly once with a bounded turn cap (no LLM looping on simple checks).
1677
2420
  //
1678
- // Fixed output indices (always 8 elements regardless of branch/no-branch):
2421
+ // Fixed output indices (always 9 elements regardless of branch/no-branch):
1679
2422
  // 0: repo root (git rev-parse --show-toplevel)
1680
2423
  // 1: fetch result (FETCHED / FETCH_FAIL) -- run BEFORE checkout so a new sprint
1681
2424
  // branch is cut from the freshest origin/<base_branch> (guards stale-main branching).
@@ -1687,12 +2430,14 @@ phase('Plan');
1687
2430
  // 4: startedAt timestamp (date +%Y%m%d_%H%M%S)
1688
2431
  // 5: deploy.md exists (YES/NO)
1689
2432
  // 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).
2433
+ // 7: regression-test-playbook.md exists (YES/NO) -- gates the once-per-sprint
2434
+ // regression pass (regression-test-runner) in the Finalization stage
2435
+ // 8: newline-joined list of permission entries declared in deploy.md /
2436
+ // integ-test-playbook.md / regression-test-playbook.md's "## Permissions"
2437
+ // sections that are NOT yet in .claude/settings.json's permissions.allow
2438
+ // (empty string if none -- computed deterministically here so Step 5's
2439
+ // prompt to the agent never has to say "you may grant yourself
2440
+ // permissions" when there's nothing to grant).
1696
2441
  const setupShellCmds = [
1697
2442
  `git rev-parse --show-toplevel`,
1698
2443
  // Fetch first so branch creation below can base a NEW sprint branch on the freshest
@@ -1715,6 +2460,7 @@ const setupShellCmds = [
1715
2460
  `date +%Y%m%d_%H%M%S`,
1716
2461
  `test -f deploy.md && echo YES || echo NO`,
1717
2462
  `test -f integ-test-playbook.md && echo YES || echo NO`,
2463
+ `test -f regression-test-playbook.md && echo YES || echo NO`,
1718
2464
  `node -e "` +
1719
2465
  `const fs=require('fs');` +
1720
2466
  `function permsFrom(file){` +
@@ -1729,7 +2475,7 @@ const setupShellCmds = [
1729
2475
  `return(section.match(/^[ \\t]*[-*]?[ \\t]*[A-Za-z_][A-Za-z0-9_]*\\([^\\n]*\\)[ \\t]*$/gm)||[])` +
1730
2476
  `.map(s=>s.replace(/^[ \\t]*[-*]?[ \\t]*/,'').trim());` +
1731
2477
  `}` +
1732
- `const declared=[...new Set([...permsFrom('deploy.md'),...permsFrom('integ-test-playbook.md')])];` +
2478
+ `const declared=[...new Set([...permsFrom('deploy.md'),...permsFrom('integ-test-playbook.md'),...permsFrom('regression-test-playbook.md')])];` +
1733
2479
  `let existing=[];` +
1734
2480
  `try{existing=(JSON.parse(fs.readFileSync('.claude/settings.json','utf8')).permissions||{}).allow||[];}catch(e){}` +
1735
2481
  `const missing=declared.filter(p=>!existing.includes(p));` +
@@ -1748,7 +2494,8 @@ const _detectedBranch = (_outs[3] || '').trim();
1748
2494
  const _detectedTs = (_outs[4] || '').trim();
1749
2495
  const _deployExists = (_outs[5] || '').trim() === 'YES';
1750
2496
  const _playbookExists = (_outs[6] || '').trim() === 'YES';
1751
- const _missingPerms = (_outs[7] || '').trim().split(/\r?\n/).map(s => s.trim()).filter(Boolean);
2497
+ const _regressionPlaybookExists = (_outs[7] || '').trim() === 'YES';
2498
+ const _missingPerms = (_outs[8] || '').trim().split(/\r?\n/).map(s => s.trim()).filter(Boolean);
1752
2499
 
1753
2500
  if (!_detectedRepo || !_detectedBranch) {
1754
2501
  log('ERROR: setup-shell failed -- could not detect repo root or branch');
@@ -1771,8 +2518,9 @@ const step5Block = _missingPerms.length > 0
1771
2518
  ` nothing else, and do not remove or modify anything else in the file:\n` +
1772
2519
  _missingPerms.map(p => ` - ${p}`).join('\n') + `\n\n`
1773
2520
  )
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`;
2521
+ : `Step 5: Already satisfied -- every permission declared in deploy.md /\n` +
2522
+ ` integ-test-playbook.md / regression-test-playbook.md is already present in\n` +
2523
+ ` .claude/settings.json. Do nothing for this step.\n\n`;
1776
2524
  const setup = await dispatch(
1777
2525
  `Sprint workspace setup (Phase 2 -- deterministic steps already done).\n\n` +
1778
2526
  `Pre-known values (do NOT re-run these commands):\n` +
@@ -1780,7 +2528,8 @@ const setup = await dispatch(
1780
2528
  ` branch: ${_detectedBranch}\n` +
1781
2529
  ` startedAt: ${_detectedTs}\n` +
1782
2530
  ` deployMdExists: ${_deployExists}\n` +
1783
- ` playbookExists: ${_playbookExists}\n\n` +
2531
+ ` playbookExists: ${_playbookExists}\n` +
2532
+ ` regressionPlaybookExists: ${_regressionPlaybookExists}\n\n` +
1784
2533
  `Your job is only Steps 5-7 below. Return ALL fields in your schema response,\n` +
1785
2534
  `including the pre-known values above.\n\n` +
1786
2535
  step5Block +
@@ -1801,7 +2550,7 @@ const setup = await dispatch(
1801
2550
  ` Run: ls "$HOME/.claude/projects/" 2>/dev/null\n` +
1802
2551
  ` Find the entry whose slug matches the repo path (e.g. repo=/c/foo/bar -> C--foo-bar).\n` +
1803
2552
  ` 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.`,
2553
+ `Return repo (absolute path), branch (confirmed), deployMdExists, playbookExists, regressionPlaybookExists, startedAt, calibrationRaw, transcriptDir.`,
1805
2554
  { model: MODEL_HAIKU, label: 'setup', phase: 'Plan', schema: SETUP_SCHEMA, maxTurns: 20 }
1806
2555
  );
1807
2556
 
@@ -1907,6 +2656,10 @@ let taskAssignments = [];
1907
2656
  const sprintLogBranch = branch.replace(/[^a-zA-Z0-9._-]/g, '-').replace(/-{2,}/g, '-').replace(/^-|-$/g, '') || 'default';
1908
2657
  const sprintLogFile = `sprint-logs/${sprintLogBranch}-${effectiveStartedAt}.jsonl`;
1909
2658
  const integTestEnabled = setup.deployMdExists && setup.playbookExists;
2659
+ // The once-per-sprint regression pass is independent of the per-cycle Test phase: it needs
2660
+ // only its own playbook (it provisions its own sandbox and runs against branch HEAD), so it
2661
+ // is NOT gated on deploy.md or on integTestEnabled.
2662
+ const regressionTestEnabled = !!setup.regressionPlaybookExists;
1910
2663
  // startedAt "20260622_020952" -> ISO "2026-06-22T02:09:52Z" (pure string, no Date.now())
1911
2664
  const sprintTs = effectiveStartedAt.replace(/^(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})$/, '$1-$2-$3T$4:$5:$6Z');
1912
2665
  let flushedCount = 0; // how many dispatchLedger entries have been appended to sprintLogFile
@@ -1952,10 +2705,11 @@ async function appendNewEntries(label, phase) {
1952
2705
  }
1953
2706
 
1954
2707
  log(`Repo: ${repo} | Branch: ${setup.branch}`);
1955
- log(`deploy.md: ${setup.deployMdExists} | integ-test-playbook.md: ${setup.playbookExists}`);
2708
+ log(`deploy.md: ${setup.deployMdExists} | integ-test-playbook.md: ${setup.playbookExists} | regression-test-playbook.md: ${setup.regressionPlaybookExists}`);
1956
2709
  if (!setup.deployMdExists) log('WARNING: deploy.md not found -- integration test phase will be skipped');
1957
2710
  if (!setup.playbookExists) log('WARNING: integ-test-playbook.md not found -- integration test phase will be skipped');
1958
2711
  if (!integTestEnabled) log('Integration testing disabled for this sprint. Harvest will run after Develop.');
2712
+ if (!regressionTestEnabled) log('WARNING: regression-test-playbook.md not found -- the once-per-sprint regression pass will be skipped');
1959
2713
 
1960
2714
  const rootSummary = rootIds.join(', ');
1961
2715
  log(`Sprint goals: ${rootSummary} | Goal: ${goal} (P<=${threshold}) | Max cycles: ${maxCycles}`);
@@ -2009,11 +2763,32 @@ const stamp = async (name) => {
2009
2763
  };
2010
2764
  await stamp('setup');
2011
2765
 
2766
+ // ---- KB PRIMING (once at sprint start; refreshed per cycle) ----
2767
+ let kbContext = '';
2768
+ {
2769
+ const kbResult = await primeKB(repo);
2770
+ if (kbResult) {
2771
+ kbContext = buildKBContext(kbResult);
2772
+ log(`KB primed: ${(kbResult.entries || []).length} entries, imported=${kbResult.imported}`);
2773
+ } else {
2774
+ log('KB priming unavailable -- proceeding without KB context');
2775
+ }
2776
+ }
2777
+
2012
2778
  while (cycleCount < maxCycles) {
2013
2779
  cycleCount++;
2014
2780
  cycleCostUsd = 0;
2015
2781
  log(`\n=== Cycle ${cycleCount}/${maxCycles} | goal: ${goal} ===`);
2016
2782
 
2783
+ // ---- KB REFRESH (per cycle -- picks up entries captured in previous cycles) ----
2784
+ if (cycleCount > 1) {
2785
+ const kbRefresh = await primeKB(repo);
2786
+ if (kbRefresh) {
2787
+ kbContext = buildKBContext(kbRefresh);
2788
+ log(`KB refreshed: ${(kbRefresh.entries || []).length} entries`);
2789
+ }
2790
+ }
2791
+
2017
2792
  // ---------------------------------------------------------------- RESUME CHECK + CYCLE CHECKPOINT
2018
2793
 
2019
2794
  phase('Plan');
@@ -2054,18 +2829,29 @@ while (cycleCount < maxCycles) {
2054
2829
 
2055
2830
  // ---------------------------------------------------------------- PLAN
2056
2831
 
2057
- let planApproved = cycleState.planDone;
2832
+ let planApproved = false;
2058
2833
  let planFeedback = '';
2834
+ const priorVerdicts = [];
2059
2835
  const MAX_PLAN_ITER = 3;
2060
2836
 
2061
- if (planApproved) {
2062
- log(`Plan already complete -- skipping plan loop for cycle ${cycleCount}`);
2837
+ if (cycleState.planDone) {
2838
+ // F6: a planDone/resumed cycle still runs one plan-reviewer pass -- we only skip the
2839
+ // expensive PLANNER dispatch on round 0. The reviewer still routes through
2840
+ // approved(planReview), so taskAssignments/sprintQuote populate and the quality gate
2841
+ // is enforced; a CHANGES_NEEDED verdict re-enables the planner on later rounds.
2842
+ log(`Plan already complete for cycle ${cycleCount} -- skipping the planner dispatch on round 0, still running the plan-reviewer`);
2063
2843
  }
2064
2844
 
2065
2845
  for (let pi = 0; pi < MAX_PLAN_ITER && !planApproved; pi++) {
2066
2846
  const plannerLabel = `planner-c${cycleCount}-r${pi}`;
2067
2847
 
2068
- const plannerResult = await dispatch(
2848
+ // F6: skip the planner only on the first round of a planDone cycle; always run it on
2849
+ // later rounds (a rejection re-enables planning). Fall straight through to the reviewer.
2850
+ const skipPlanner = pi === 0 && cycleState.planDone;
2851
+ let plannerResult = null;
2852
+ if (!skipPlanner) {
2853
+ plannerResult = await dispatch(
2854
+ kbContext +
2069
2855
  `Repo: ${repo}\nBranch: ${branch}\nBase branch: ${base_branch}\n` +
2070
2856
  `Sprint goals: ${rootSummary}\n` +
2071
2857
  (requirementsFile ? `Additional context: ${requirementsFile}\n` : '') +
@@ -2097,10 +2883,14 @@ while (cycleCount < maxCycles) {
2097
2883
  ` until the impl task closes -- correct: they are siblings). Same pattern for any\n` +
2098
2884
  ` later sibling task that depends on an earlier one.\n` +
2099
2885
  `\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` +
2886
+ ` VERIFY after wiring: run "bd list --parent <goal-id> --ready --type=task --json" for\n` +
2887
+ ` EACH sprint goal and reason over the COMBINED result. The union of ready work across\n` +
2888
+ ` all goals must be non-empty while open work remains anywhere in scope. A single goal\n` +
2889
+ ` with an empty ready-list is FINE when its tasks are legitimately blocked by an open\n` +
2890
+ ` task in ANOTHER goal (a cross-goal ordering edge) -- do NOT remove that edge. Only if\n` +
2891
+ ` the UNION is empty while open work remains, or a goal's task blocks via an edge to its\n` +
2892
+ ` own --parent ancestor/descendant, is there a real cycle: find that parent/descendant\n` +
2893
+ ` blocks edge and remove it with bd dep remove.\n` +
2104
2894
  `\n` +
2105
2895
  ` IMPORTANT: Each task belongs to exactly ONE feature. Never share a task across features.\n` +
2106
2896
  `\n` +
@@ -2124,14 +2914,18 @@ while (cycleCount < maxCycles) {
2124
2914
  `Do NOT add new scope beyond the original sprint goals and open bugs/enhancements.\n` +
2125
2915
  `Do NOT re-create tasks that are already closed.\n`
2126
2916
  : '') +
2127
- `Confirm with any text when done.`,
2128
- { model: MODEL_OPUS, label: plannerLabel, phase: 'Plan', agentType: 'planner',
2917
+ `Return status "OK" when the DAG is in place, or "BLOCKED" with notes if you\n` +
2918
+ `could not create it. List the feature and task ids you created in featureIds\n` +
2919
+ `and taskIds.`,
2920
+ { model: MODEL_OPUS, label: plannerLabel, phase: 'Plan', schema: PLANNER_SCHEMA, agentType: 'planner',
2129
2921
  context: `planning sprint goals ${rootSummary}` }
2130
2922
  );
2131
2923
 
2132
- if (!plannerResult) {
2133
- log(`Planner returned null on cycle ${cycleCount} round ${pi} -- retrying`);
2134
- continue;
2924
+ if (!plannerResult) {
2925
+ log(`Planner returned null on cycle ${cycleCount} round ${pi} -- retrying`);
2926
+ continue;
2927
+ }
2928
+ await runKbWork(repo, 'planner', plannerResult);
2135
2929
  }
2136
2930
 
2137
2931
  const planReviewerLabel = `plan-reviewer-c${cycleCount}-r${pi}`;
@@ -2139,10 +2933,19 @@ while (cycleCount < maxCycles) {
2139
2933
  `Repo: ${repo}\nBranch: ${branch}\nSprint goals: ${rootSummary}\n` +
2140
2934
  `Calibration file: ${repo}/sprint-logs/calibration.json (read this first if it exists)\n\n` +
2141
2935
  `Review the beads DAG for these sprint goals ONLY: ${rootSummary}\n` +
2936
+ (priorVerdicts.length > 0
2937
+ ? `Prior-round verdicts for THIS review cycle (most recent last) -- these BIND per your ` +
2938
+ `No-goalpost-moving rule; do not re-litigate a criterion an earlier round already ` +
2939
+ `accepted unless you cite NEW evidence:\n` +
2940
+ priorVerdicts.map(v => ` Round ${v.round}: ${v.verdict} -- ${v.notes}\n`).join('') +
2941
+ `\n`
2942
+ : '') +
2142
2943
  `Run: ${rootIds.map(id => `bd show ${id}`).join(' && ')} to inspect each sprint goal.\n` +
2143
2944
  `Run: ${rootIds.map(id => `bd graph --compact ${id}`).join(' && ')} for the full dependency subtree.\n` +
2144
2945
  `Run: bd show <id> to inspect individual issues in depth.\n` +
2145
- `Run: bd ready -- this is your FIRST correctness check.\n` +
2946
+ `Ready-work check (your FIRST correctness check, per runbook Criterion 9): run\n` +
2947
+ `"bd list --parent <root> --ready --type=task --json" for EACH sprint goal and reason\n` +
2948
+ `over the UNION -- do NOT use bare "bd ready" (project-wide, not a signal about this DAG).\n` +
2146
2949
  `Do NOT review or comment on issues outside these sprint goals.\n\n` +
2147
2950
  `Follow your runbook (agents/plan-reviewer.md) step by step:\n` +
2148
2951
  ` Steps 1-2: inspect the DAG and check all quality criteria.\n` +
@@ -2157,6 +2960,15 @@ while (cycleCount < maxCycles) {
2157
2960
  context: `reviewing plan for sprint goals ${rootSummary}` }
2158
2961
  );
2159
2962
 
2963
+ // F2: record this round's verdict so the NEXT round's plan-reviewer receives it as a
2964
+ // binding prior-round input (No-goalpost-moving rule). Null-guarded: a null planReview
2965
+ // records a CHANGES_NEEDED entry rather than crashing.
2966
+ priorVerdicts.push({
2967
+ round: pi,
2968
+ verdict: (planReview && planReview.verdict) || 'CHANGES_NEEDED',
2969
+ notes: (planReview && planReview.notes) || '',
2970
+ });
2971
+
2160
2972
  if (approved(planReview)) {
2161
2973
  planApproved = true;
2162
2974
  log(`Plan APPROVED on cycle ${cycleCount} round ${pi + 1}`);
@@ -2353,6 +3165,7 @@ while (cycleCount < maxCycles) {
2353
3165
 
2354
3166
  const doerOutcomes = await parallel(okWt.map(w =>
2355
3167
  dispatch(
3168
+ kbContext +
2356
3169
  `You are working in an ISOLATED git worktree -- other doers run concurrently in their own worktrees.\n` +
2357
3170
  `Worktree path: ${repo}/${w.path} (cd into it first; you are on temp branch ${w.branch})\n` +
2358
3171
  `Work ONLY task ${w.id}. Do NOT work any other task.\n\n` +
@@ -2367,7 +3180,10 @@ while (cycleCount < maxCycles) {
2367
3180
  `Return status "VERIFY" when done. Return status "BLOCKED" only for your runbook's blocked cases (missing secret) -- never any other status.`,
2368
3181
  { model: w.model, label: `doer-c${cycleCount}-i${devIter}-${w.id}`, phase: 'Develop', schema: DOER_STATUS_SCHEMA,
2369
3182
  agentType: 'doer', context: `task ${w.id} (worktree)` }
2370
- ).then(r => ({ w, ok: !!r && r.status === 'VERIFY' })).catch(() => ({ w, ok: false }))
3183
+ ).then(async r => {
3184
+ await runKbWork(repo, 'doer', r);
3185
+ return { w, ok: !!r && r.status === 'VERIFY' };
3186
+ }).catch(() => ({ w, ok: false }))
2371
3187
  ));
2372
3188
 
2373
3189
  // Merge sequentially into the sprint branch (deterministic id order from computeDoerBatch).
@@ -2442,6 +3258,7 @@ while (cycleCount < maxCycles) {
2442
3258
  log(`Doer c${cycleCount}-i${devIter}: ${labelTaskIds(fittedIds)} [model=${streak.model}${streakEstUsd != null ? ` est=$${streakEstUsd.toFixed(4)}` : ''}]`);
2443
3259
 
2444
3260
  const doerResult = await dispatch(
3261
+ kbContext +
2445
3262
  `Repo: ${repo}\nBranch: ${branch}\n\n` +
2446
3263
  (devFeedback
2447
3264
  ? `Reviewer feedback from the previous iteration (read feedback.md in ${repo} for full details):\n${devFeedback}\nAddress every finding before closing tasks.\n\n`
@@ -2460,6 +3277,7 @@ while (cycleCount < maxCycles) {
2460
3277
  { model: streak.model, label: doerLabel, phase: 'Develop', schema: DOER_STATUS_SCHEMA, agentType: 'doer',
2461
3278
  context: `tasks ${fittedIds.join(', ')}` }
2462
3279
  );
3280
+ await runKbWork(repo, 'doer', doerResult);
2463
3281
 
2464
3282
  if (!doerResult) {
2465
3283
  log(`Doer returned null (streak ${streak.model}) -- resetting orphaned in_progress tasks and retrying`);
@@ -2515,6 +3333,7 @@ while (cycleCount < maxCycles) {
2515
3333
  // One reviewer pass covering all streaks worked this iteration.
2516
3334
  const reviewerLabel = `reviewer-c${cycleCount}-i${devIter}: ${labelTaskIds(workedIds)}`;
2517
3335
  const review = await dispatch(
3336
+ kbContext +
2518
3337
  `Repo: ${repo}\nBranch: ${branch}\nBase branch: ${base_branch}\n` +
2519
3338
  `Sprint goals: ${rootSummary}\nTasks worked this iteration: ${workedIds.join(', ')}\n\n` +
2520
3339
  `Review ONLY the work done for the tasks listed above.\n` +
@@ -2531,6 +3350,7 @@ while (cycleCount < maxCycles) {
2531
3350
  context: `reviewing tasks ${workedIds.join(', ')}` }
2532
3351
  );
2533
3352
  log(`Reviewer c${cycleCount}-i${devIter}: ${(review && review.verdict) || 'null'} -- ${labelTaskIds(workedIds)}`);
3353
+ await runKbWork(repo, 'reviewer', review);
2534
3354
 
2535
3355
  if (!approved(review)) {
2536
3356
  devFeedback = (review && review.notes) || '';
@@ -2605,15 +3425,18 @@ while (cycleCount < maxCycles) {
2605
3425
 
2606
3426
  // -- Deploy --
2607
3427
  // 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.
3428
+ // deploy.md ONLY (deploy + smoke test). The sandbox lifecycle (Setup/Reset/Teardown)
3429
+ // lives in regression-test-playbook.md and belongs to regression-test-runner, which
3430
+ // runs once per sprint in Finalization -- not to the deployer and not to this cycle's
3431
+ // integ-test-runner. The deployer refuses playbook operations by contract, so never
3432
+ // dispatch them to it.
2611
3433
  const deployLabel = `deployer-c${cycleCount}`;
2612
3434
  const deployResult = await dispatch(
2613
3435
  `Repo: ${repo}\nBranch: ${branch}\nCycle: ${cycleCount}\n` +
2614
3436
  `operation: deploy\n\n` +
2615
3437
  `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` +
3438
+ `integ-test-playbook.md or regression-test-playbook.md (the sandbox lifecycle --\n` +
3439
+ `## Setup / ## Reset / ## Teardown -- belongs to regression-test-runner):\n` +
2617
3440
  `1. Read deploy.md (Deploy, Smoke test, and CI sections).\n` +
2618
3441
  `2. Execute every command in the '## Deploy' section in order.\n` +
2619
3442
  `3. Run the command in '## Smoke test'.\n` +
@@ -2626,39 +3449,43 @@ while (cycleCount < maxCycles) {
2626
3449
  if (!deployResult || !deployResult.deployed) {
2627
3450
  const msg = (deployResult && deployResult.notes) || 'no details';
2628
3451
  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');
3452
+ log('Skipping feature-closure tests this cycle -- the deploy failed, so there is nothing verified to test against');
2630
3453
  } else {
2631
- // -- Integration test run (scoped to THIS sprint's open features) --
3454
+ // -- Feature-closure test run (scoped to THIS sprint's open features) --
2632
3455
  // Scope the tester to the sprint subtree's open features. Do NOT let it `bd list
2633
3456
  // --type=feature --status=open` (every open feature in the whole DB) -- that would
2634
3457
  // 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).
3458
+ // An EMPTY feature list is simply a normal no-op cycle (nothing to close); the
3459
+ // runner is still dispatched and reports zero closed. The sprint's standing
3460
+ // confidence check lives in the once-per-sprint regression pass, not here.
2637
3461
  const _sprintFeatures = await getSprintOpenFeatures(rootIds);
2638
3462
  const integLabel = `integ-runner-c${cycleCount}`;
2639
3463
  const _featList = _sprintFeatures.length > 0
2640
3464
  ? _sprintFeatures.map(f => ` ${f.id} -- ${f.title}`).join('\n')
2641
- : ` (none -- zero open features this cycle; a normal outcome, run the playbook parts only)`;
3465
+ : ` (none -- zero open features this cycle; a normal no-op outcome, report zero closed)`;
2642
3466
  log(`Integration scope: ${_sprintFeatures.length} sprint feature(s)${_sprintFeatures.length ? ` [${labelTaskIds(_sprintFeatures.map(f => f.id))}]` : ''}`);
2643
3467
 
2644
3468
  const integResult = await dispatch(
2645
3469
  `Repo: ${repo}\nBranch: ${branch}\nCycle: ${cycleCount}\n` +
2646
3470
  `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, ` +
3471
+ `Follow your runbook (agents/integ-test-runner.md) and integ-test-playbook.md.\n` +
3472
+ `This phase is FEATURE CLOSURE ONLY: repo-local, per-feature test execution against\n` +
3473
+ `the sprint branch working tree. There is no sandbox, no ## Setup / ## Reset /\n` +
3474
+ `## Teardown, and no full suite here -- those live in regression-test-playbook.md and\n` +
3475
+ `run once per sprint under a different role. The product deploy (deploy.md) has\n` +
3476
+ `already been done by the deployer.\n\n` +
3477
+ `Test ONLY these open features from THIS sprint. Do NOT list, test, close, ` +
2653
3478
  `or file bugs against any beads issue that is not in this list (do NOT run ` +
2654
3479
  `"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` +
3480
+ `For each feature: bd show <feature> to read its acceptance criteria, bd dep list ` +
3481
+ `<feature> to find its [test] task(s), run exactly those tests, then bd close on a ` +
3482
+ `full pass; on failure leave it open and file an [integ] bug; if the result is ` +
3483
+ `inconclusive leave it open and record a note saying why. Priority rules and ` +
3484
+ `duplicate checks (bd search "[integ]") are in your runbook -- follow it. Parent ` +
3485
+ `every new [integ] bug under sprint root ${rootIds[0]} (the scope for this dispatch).\n\n` +
2659
3486
  `Return the full contract: featuresClosed (count), issuesCreated (count), ` +
2660
3487
  `passed (boolean), bugsFiled (array of created bug ids, [] if none), ` +
2661
- `summary (one paragraph, including the part 1 result line).`,
3488
+ `summary (one paragraph).`,
2662
3489
  { model: MODEL_SONNET, label: integLabel, phase: 'Test', schema: INTEG_RUN_SCHEMA, agentType: 'integ-test-runner' }
2663
3490
  );
2664
3491
  if (integResult) {
@@ -2667,8 +3494,8 @@ while (cycleCount < maxCycles) {
2667
3494
  }
2668
3495
 
2669
3496
  // 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).
3497
+ // Nothing to tear down here: feature closure is repo-local and provisions no
3498
+ // sandbox (agents/integ-test-runner.md).
2672
3499
  await appendNewEntries(`test-c${cycleCount}`, 'Test');
2673
3500
  }
2674
3501
  }
@@ -2684,7 +3511,7 @@ while (cycleCount < maxCycles) {
2684
3511
  let blockers;
2685
3512
  {
2686
3513
  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('[]')}"`;
3514
+ 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
3515
  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
3516
  const exitCmds = [
2690
3517
  ...rootIds.map(id => `bd graph --json ${id} | ${_idExtract}`),
@@ -2693,14 +3520,14 @@ while (cycleCount < maxCycles) {
2693
3520
  ];
2694
3521
  const exitResult = await dispatchShell(exitCmds, { model: MODEL_HAIKU, label: 'exit-check', phase: 'Develop' });
2695
3522
  if (exitResult?.outputs && exitResult.outputs.length >= rootIds.length + 2) {
2696
- blockers = parseBlockers(exitResult.outputs, rootIds.length, rootIds.length, threshold, rootIds);
3523
+ blockers = parseBlockers(exitResult.outputs, rootIds.length, rootIds.length, threshold, { rootIds, leaf: true, includeFeatures: integTestEnabled });
2697
3524
  // Ready streaks prefetched but not used: develop loop already determined no ready tasks.
2698
3525
  // Parsed here to validate the merged output; result discarded at cycle end.
2699
3526
  parseReadyStreaks(exitResult.outputs, rootIds.length, rootIds.length + 1, TIER_STANDARD, rootIds);
2700
3527
  } else {
2701
3528
  // Fallback: outputs too short (agent returned partial results) -- use separate dispatches.
2702
3529
  log('exit-check: outputs.length < rootCount+2 -- falling back to separate dispatches');
2703
- blockers = await countBeadsBlockers(threshold, rootIds);
3530
+ blockers = await countBeadsBlockers(threshold, rootIds, integTestEnabled);
2704
3531
  }
2705
3532
  }
2706
3533
  const currentOpenIds = (blockers.ids || []).slice().sort();
@@ -2758,6 +3585,7 @@ await dispatchShell(
2758
3585
 
2759
3586
  const finalReviewLabel = 'final-reviewer';
2760
3587
  const finalReview = await dispatch(
3588
+ kbContext +
2761
3589
  `Repo: ${repo}\nBranch: ${branch}\nBase branch: ${base_branch}\n` +
2762
3590
  `Sprint goals: ${rootSummary}\nGoal: ${goal}\n` +
2763
3591
  (abortReason ? `Sprint ended early: ${abortReason}. Review what was completed.\n` : '') +
@@ -2771,6 +3599,7 @@ const finalReview = await dispatch(
2771
3599
  { model: MODEL_OPUS, label: finalReviewLabel, phase: 'Harvest', schema: REVIEW_SCHEMA, agentType: 'reviewer' }
2772
3600
  );
2773
3601
  log(`Final review: ${finalReview && finalReview.verdict || 'null'}`);
3602
+ await runKbWork(repo, 'reviewer', finalReview);
2774
3603
 
2775
3604
  if (!approved(finalReview)) {
2776
3605
  const notes = (finalReview && finalReview.notes) || '';
@@ -2779,6 +3608,69 @@ if (!approved(finalReview)) {
2779
3608
  return { cycles: cycleCount, goalMet, goal, abortReason: abortReason || 'final review rejected', finalReviewNotes: notes };
2780
3609
  }
2781
3610
 
3611
+ // ------------------------------------------------------------------ REGRESSION TEST (once per sprint)
3612
+ // Placed deliberately AFTER the final-review verdict is decided (and after its early
3613
+ // return) and BEFORE harvest: the verdict is already computed, so a regression result
3614
+ // structurally CANNOT perturb the sprint's PASS/FAIL, and running it before harvest lets
3615
+ // the harvester mention it in the CHANGELOG. This is the ONLY dispatch of this role in a
3616
+ // sprint -- the per-cycle Test phase does feature closure only.
3617
+ //
3618
+ // SOFT FAIL, ALWAYS: a null / failed / schema-invalid / thrown result is logged and
3619
+ // swallowed. It never aborts, never touches goalMet, never changes the return value, and
3620
+ // never blocks harvest. Failures the runner finds are filed by IT as standalone,
3621
+ // parent-less [regression][carry-over] beads, which the sprint's parent-edge-walking
3622
+ // completion gate cannot see -- that is what makes them carry over to a future sprint.
3623
+ let regressionSummaryLine = '(not run)';
3624
+ if (regressionTestEnabled) {
3625
+ let regressionResult = null;
3626
+ try {
3627
+ regressionResult = await dispatch(
3628
+ `Repo: ${repo}\nBranch: ${branch}\nCycles completed: ${cycleCount}\n` +
3629
+ `Sprint goals: ${rootSummary}\n\n` +
3630
+ `Follow your runbook (agents/regression-test-runner.md) and regression-test-playbook.md.\n` +
3631
+ `This is the ONCE-PER-SPRINT regression pass. Run BOTH parts:\n` +
3632
+ ` Part 1: the full functional suite against the real bd CLI, at branch HEAD.\n` +
3633
+ ` Part 2: the toy-sprint smoke test -- bring the sandbox up with the playbook's\n` +
3634
+ ` ## Setup section, run its ## Test scenario, and ALWAYS run the playbook's\n` +
3635
+ ` ## Teardown before returning, pass or fail.\n\n` +
3636
+ `File EVERY failure from either part as a STANDALONE bead: "bd create" with NO\n` +
3637
+ `--parent flag, and do NOT "bd dep add" it to sprint root ${rootIds[0]}, to any\n` +
3638
+ `feature, or to any other bead in this sprint. Title each one\n` +
3639
+ `"[regression][carry-over] <short description>". The parent-less shape is the point:\n` +
3640
+ `this sprint's completion gate walks parent edges, so a bead with no parent edge is\n` +
3641
+ `structurally invisible to it and carries over to a FUTURE sprint instead of blocking\n` +
3642
+ `this one. Dedupe first with: bd search "[carry-over]" -- update an existing\n` +
3643
+ `carry-over bug rather than filing a second one for the same failure.\n\n` +
3644
+ `This sprint's verdict is ALREADY DECIDED (final review: APPROVED). Your result is\n` +
3645
+ `INFORMATIONAL and does not gate it -- do not present it as a gate.\n\n` +
3646
+ `Return the full contract: passed (boolean), suitePassed (boolean), smokePassed\n` +
3647
+ `(boolean), bugsFiled (array of the parent-less carry-over bead ids, [] if none),\n` +
3648
+ `summary (one paragraph).`,
3649
+ { model: MODEL_SONNET, label: 'regression-test-runner', phase: 'Harvest',
3650
+ schema: REGRESSION_RUN_SCHEMA, agentType: 'regression-test-runner' }
3651
+ );
3652
+ } catch (e) {
3653
+ // Swallowed on purpose -- see SOFT FAIL above.
3654
+ log(`Regression pass threw and was ignored (informational only): ${String(e && e.message || e).slice(0, 200)}`);
3655
+ regressionResult = null;
3656
+ }
3657
+ if (regressionResult && typeof regressionResult.passed === 'boolean') {
3658
+ const _bugs = Array.isArray(regressionResult.bugsFiled) ? regressionResult.bugsFiled : [];
3659
+ log(`Regression: suitePassed=${regressionResult.suitePassed}, smokePassed=${regressionResult.smokePassed}, passed=${regressionResult.passed}, carry-over bugs filed: ${_bugs.length}${_bugs.length ? ` [${_bugs.join(', ')}]` : ''}`);
3660
+ log(`Regression summary: ${regressionResult.summary}`);
3661
+ regressionSummaryLine =
3662
+ `passed=${regressionResult.passed} (suite=${regressionResult.suitePassed}, smoke=${regressionResult.smokePassed})` +
3663
+ `${_bugs.length ? `; carry-over beads filed: ${_bugs.join(', ')}` : '; no carry-over beads filed'}`;
3664
+ } else {
3665
+ log('Regression pass returned no usable result -- ignored (informational only; the sprint is unaffected)');
3666
+ regressionSummaryLine = '(not run -- the regression dispatch returned no usable result)';
3667
+ }
3668
+ await appendNewEntries('regression', 'Harvest');
3669
+ } else {
3670
+ log('Regression pass skipped -- no regression-test-playbook.md in the repo root');
3671
+ regressionSummaryLine = '(skipped -- no regression-test-playbook.md)';
3672
+ }
3673
+
2782
3674
  // ------------------------------------------------------------------ HARVEST
2783
3675
 
2784
3676
  const logEntries = dispatchLedger;
@@ -2805,6 +3697,7 @@ const analysisArtifactFile = `sprint-logs/${sprintLogBranch}-${effectiveStartedA
2805
3697
 
2806
3698
  const harvestLabel = 'harvester';
2807
3699
  const harvestResult = await dispatch(
3700
+ kbContext +
2808
3701
  `Repo: ${repo}\nBranch: ${branch}\nBase branch: ${base_branch}\n` +
2809
3702
  `Sprint goals: ${rootSummary}\nCycles completed: ${cycleCount}\nGoal met: ${goalMet}\n` +
2810
3703
  `sprintLogFile: ${sprintLogFile}\n` +
@@ -2819,9 +3712,12 @@ const harvestResult = await dispatch(
2819
3712
  `${sprintAnalysis.analysisText}\n` +
2820
3713
  `Final review notes to include in CHANGELOG:\n` +
2821
3714
  `${(finalReview && finalReview.notes) || '(none)'}\n\n` +
3715
+ `Regression pass (once-per-sprint, informational -- does not gate this sprint):\n` +
3716
+ `${regressionSummaryLine}\n\n` +
2822
3717
  `Return status "OK" if successful, "FAILED" with notes otherwise.`,
2823
3718
  { model: MODEL_SONNET, label: harvestLabel, phase: 'Harvest', schema: HARVEST_SCHEMA, agentType: 'harvester' }
2824
3719
  );
3720
+ await runKbWork(repo, 'harvester', harvestResult);
2825
3721
 
2826
3722
  if (!harvestResult || harvestResult.status !== 'OK') {
2827
3723
  log(`Harvest failed: ${(harvestResult && harvestResult.notes) || 'null'} -- writing analysis fallback`);
@@ -2851,6 +3747,11 @@ if (!harvestResult || harvestResult.status !== 'OK') {
2851
3747
  const updatedCalibration = computeUpdatedCalibration(calibration, sprintAnalysis, effectiveStartedAt, taskAssignments, logEntries);
2852
3748
  const calibrationJson = JSON.stringify(updatedCalibration, null, 2);
2853
3749
 
3750
+ const tokenEstimates = {
3751
+ averages: Object.values(updatedCalibration.historical?.tuple_averages || {})
3752
+ };
3753
+ const tokenEstimatesJson = JSON.stringify(tokenEstimates).replace(/"/g, '\\"');
3754
+
2854
3755
  await parallel([
2855
3756
  dispatch(
2856
3757
  `Write updated calibration file and commit.\n\n` +
@@ -2860,6 +3761,8 @@ await parallel([
2860
3761
  `Step 3: Commit the file:\n` +
2861
3762
  ` git -C "${repo}" add sprint-logs/calibration.json\n` +
2862
3763
  ` git -C "${repo}" commit -m "chore: update sprint calibration after ${cycleCount} cycle(s) on ${branch}"\n\n` +
3764
+ `Step 4: Update token estimates memory:\n` +
3765
+ ` bd remember "${tokenEstimatesJson}" --key token-estimates-json\n\n` +
2863
3766
  `If the file content is unchanged, the commit may be a no-op -- that is fine.\n` +
2864
3767
  `Return "OK" when done.`,
2865
3768
  { model: MODEL_HAIKU, label: 'calibration-update', phase: 'Harvest' }
@@ -2944,7 +3847,7 @@ const harvestPr = await dispatch(
2944
3847
  ` - Cycles run: ${cycleCount}\n` +
2945
3848
  ` - Open items carried forward (if any): bd list --status=open and summarise\n` +
2946
3849
  ` - Final review notes: ${(finalReview && finalReview.notes) || '(none)'}\n` +
2947
- ` - Token cost summary from: bd memories auto-sprint\n\n` +
3850
+ ` - Token cost summary from: bd recall token-estimates-json\n\n` +
2948
3851
  `After creating the PR, return its number as prNumber (integer).`,
2949
3852
  { model: MODEL_SONNET, label: 'harvest-pr', phase: 'Harvest',
2950
3853
  schema: { type: 'object', required: ['prNumber'], properties: { prNumber: { type: 'number' }, prUrl: { type: 'string' } } } }