@cbartens/bkit 6.1.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/.bkit/README.md +14 -12
  2. package/.bkit/core/.agents/docs.md +1 -11
  3. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +30 -9
  4. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +25 -27
  5. package/.bkit/core/.agents/rules.md +22 -9
  6. package/.bkit/core/.bkit/README.md +13 -11
  7. package/.bkit/core/.bkit/authoring.md +58 -13
  8. package/.bkit/core/.bkit/cli.md +43 -33
  9. package/.bkit/core/.bkit/cloud.md +93 -30
  10. package/.bkit/core/.bkit/install.md +55 -16
  11. package/.bkit/core/.bkit/jsonl.md +24 -7
  12. package/.bkit/core/.bkit/pipeline.md +8 -8
  13. package/.bkit/core/.bkit/prompts.md +160 -43
  14. package/.bkit/core/.bkit/providers.md +99 -36
  15. package/.bkit/core/.bkit/templates.md +167 -37
  16. package/.bkit/core/.bkit/trackers.md +39 -6
  17. package/.bkit/core/.bkit/workflows.md +344 -136
  18. package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +50 -27
  19. package/.bkit/core/.claude/hooks/bkit-preflight.sh +11 -11
  20. package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +13 -8
  21. package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +14 -25
  22. package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +20 -9
  23. package/.bkit/core/.cursor/hooks/bkit-preflight.sh +8 -8
  24. package/.bkit/core/.opencode/plugin/bkit-gateguard.js +14 -4
  25. package/.bkit/core/.opencode/plugin/bkit-guardrails.js +114 -0
  26. package/.bkit/core/docs/templates/bkit-audit-accessibility.md +1 -1
  27. package/.bkit/core/docs/templates/bkit-audit-adoption.md +30 -6
  28. package/.bkit/core/docs/templates/bkit-audit-agents.md +1 -1
  29. package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +1 -1
  30. package/.bkit/core/docs/templates/bkit-audit-analytics.md +1 -1
  31. package/.bkit/core/docs/templates/bkit-audit-annotations.md +1 -1
  32. package/.bkit/core/docs/templates/bkit-audit-app-performance.md +1 -1
  33. package/.bkit/core/docs/templates/bkit-audit-app-store.md +1 -1
  34. package/.bkit/core/docs/templates/bkit-audit-architecture.md +1 -1
  35. package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +2 -2
  36. package/.bkit/core/docs/templates/bkit-audit-config.md +3 -2
  37. package/.bkit/core/docs/templates/bkit-audit-cost.md +1 -1
  38. package/.bkit/core/docs/templates/bkit-audit-coverage.md +1 -1
  39. package/.bkit/core/docs/templates/bkit-audit-database.md +3 -3
  40. package/.bkit/core/docs/templates/bkit-audit-dead-code.md +1 -1
  41. package/.bkit/core/docs/templates/bkit-audit-deferrals.md +1 -1
  42. package/.bkit/core/docs/templates/bkit-audit-dependencies.md +3 -3
  43. package/.bkit/core/docs/templates/bkit-audit-documentation.md +32 -2
  44. package/.bkit/core/docs/templates/bkit-audit-duplication.md +1 -1
  45. package/.bkit/core/docs/templates/bkit-audit-failures.md +1 -1
  46. package/.bkit/core/docs/templates/bkit-audit-flakes.md +2 -2
  47. package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -3
  48. package/.bkit/core/docs/templates/bkit-audit-issues.md +1 -1
  49. package/.bkit/core/docs/templates/bkit-audit-llm.md +2 -2
  50. package/.bkit/core/docs/templates/bkit-audit-logs.md +1 -1
  51. package/.bkit/core/docs/templates/bkit-audit-models.md +2 -2
  52. package/.bkit/core/docs/templates/bkit-audit-privacy.md +1 -1
  53. package/.bkit/core/docs/templates/bkit-audit-prompts.md +1 -1
  54. package/.bkit/core/docs/templates/bkit-audit-red-team.md +2 -2
  55. package/.bkit/core/docs/templates/bkit-audit-reliability.md +3 -2
  56. package/.bkit/core/docs/templates/bkit-audit-repo.md +1 -1
  57. package/.bkit/core/docs/templates/bkit-audit-security.md +1 -1
  58. package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
  59. package/.bkit/core/docs/templates/bkit-audit-testing.md +3 -2
  60. package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
  61. package/.bkit/core/docs/templates/bkit-plan.md +38 -8
  62. package/.bkit/core/engine/checks/after/auth.ts +118 -47
  63. package/.bkit/core/engine/checks/after/github.ts +161 -37
  64. package/.bkit/core/engine/checks/after/index.ts +18 -3
  65. package/.bkit/core/engine/checks/after/tools.ts +245 -1
  66. package/.bkit/core/engine/checks/before/files.ts +59 -1
  67. package/.bkit/core/engine/checks/before/index.ts +8 -0
  68. package/.bkit/core/engine/checks/status-holes.ts +20 -26
  69. package/.bkit/core/engine/checks/tips/catalogue.ts +107 -10
  70. package/.bkit/core/engine/checks/tips/detect.ts +36 -3
  71. package/.bkit/core/engine/checks/tips/index.ts +1 -1
  72. package/.bkit/core/engine/cli.ts +13 -13
  73. package/.bkit/core/engine/commands/ci/ci.ts +124 -19
  74. package/.bkit/core/engine/commands/ci/push-gate.ts +101 -43
  75. package/.bkit/core/engine/commands/install/doctor.ts +5 -5
  76. package/.bkit/core/engine/commands/install/install.ts +28 -25
  77. package/.bkit/core/engine/commands/install/uninstall.ts +42 -30
  78. package/.bkit/core/engine/commands/install/upgrade.ts +14 -2
  79. package/.bkit/core/engine/commands/land.ts +2 -3
  80. package/.bkit/core/engine/commands/lib.ts +394 -39
  81. package/.bkit/core/engine/commands/registry.ts +1 -1
  82. package/.bkit/core/engine/commands/workflow/branches.ts +351 -78
  83. package/.bkit/core/engine/commands/workflow/challenge.ts +63 -14
  84. package/.bkit/core/engine/commands/workflow/context.ts +71 -10
  85. package/.bkit/core/engine/commands/workflow/counters.ts +298 -23
  86. package/.bkit/core/engine/commands/workflow/decisions.ts +260 -125
  87. package/.bkit/core/engine/commands/workflow/disk.ts +2 -1
  88. package/.bkit/core/engine/commands/workflow/feature-base.ts +66 -0
  89. package/.bkit/core/engine/commands/workflow/issues.ts +312 -17
  90. package/.bkit/core/engine/commands/workflow/junit.ts +204 -0
  91. package/.bkit/core/engine/commands/workflow/ledgers.ts +904 -99
  92. package/.bkit/core/engine/commands/workflow/locks.ts +186 -29
  93. package/.bkit/core/engine/commands/workflow/loops.ts +87 -0
  94. package/.bkit/core/engine/commands/workflow/open-decision.ts +251 -0
  95. package/.bkit/core/engine/commands/workflow/plan-blocks.ts +8 -0
  96. package/.bkit/core/engine/commands/workflow/plans.ts +1 -1
  97. package/.bkit/core/engine/commands/workflow/prs.ts +311 -16
  98. package/.bkit/core/engine/commands/workflow/repo.ts +1 -1
  99. package/.bkit/core/engine/commands/workflow/run-facts.ts +6 -0
  100. package/.bkit/core/engine/commands/workflow/runs.ts +877 -174
  101. package/.bkit/core/engine/commands/workflow/runtime.ts +12 -4
  102. package/.bkit/core/engine/commands/workflow/status.ts +324 -11
  103. package/.bkit/core/engine/commands/workflow/step-table.ts +41 -15
  104. package/.bkit/core/engine/commands/workflow/steps.ts +604 -29
  105. package/.bkit/core/engine/commands/workflow/summary-findings.ts +1 -1
  106. package/.bkit/core/engine/commands/workflow/summary.ts +314 -8
  107. package/.bkit/core/engine/commands/workflow/tasks.ts +400 -27
  108. package/.bkit/core/engine/commands/workflow/tests-base.ts +319 -0
  109. package/.bkit/core/engine/commands/workflow/tests-changed.ts +138 -74
  110. package/.bkit/core/engine/commands/workflow/tests-jump.ts +93 -0
  111. package/.bkit/core/engine/commands/workflow/tests.ts +815 -182
  112. package/.bkit/core/engine/commands/workflow/tracker.ts +1134 -137
  113. package/.bkit/core/engine/commands/workflow/workflows.ts +100 -72
  114. package/.bkit/core/engine/commands/workflow/worktrees.ts +421 -57
  115. package/.bkit/core/engine/install/cloud-env.ts +38 -10
  116. package/.bkit/core/engine/install/managed-block.ts +105 -0
  117. package/.bkit/core/engine/install/manifest.ts +7 -1
  118. package/.bkit/core/engine/install/modules/claude.ts +6 -2
  119. package/.bkit/core/engine/install/modules/cloud.ts +84 -95
  120. package/.bkit/core/engine/install/modules/codex.ts +10 -2
  121. package/.bkit/core/engine/install/modules/core.ts +202 -26
  122. package/.bkit/core/engine/install/modules/opencode.ts +18 -23
  123. package/.bkit/core/engine/install/network-allowlist.ts +8 -3
  124. package/.bkit/core/engine/install/project-docs.ts +650 -0
  125. package/.bkit/core/engine/install/template-copies.ts +58 -5
  126. package/.bkit/core/engine/install/write.ts +128 -7
  127. package/.bkit/core/engine/ledgers/journal.ts +18 -10
  128. package/.bkit/core/engine/ledgers/migrate.ts +20 -8
  129. package/.bkit/core/engine/ledgers/status.ts +604 -8
  130. package/.bkit/core/engine/ledgers/telemetry.ts +115 -13
  131. package/.bkit/core/engine/render/trackers.ts +46 -11
  132. package/.bkit/core/engine/shared/package-manager.ts +7 -3
  133. package/.bkit/core/engine/shared/settings.ts +12 -1
  134. package/.bkit/core/engine/shared/text.ts +14 -0
  135. package/.bkit/core/engine/tools/instructions-sources.ts +1 -0
  136. package/.bkit/core/engine/tools/instructions.ts +116 -20
  137. package/.bkit/core/hooks/antigravity-hook.js +20 -4
  138. package/.bkit/core/hooks/gateguard-edit-payload.js +8 -5
  139. package/.bkit/core/hooks/gateguard-engine.js +249 -23
  140. package/.bkit/core/hooks/guardrails-deny.js +167 -0
  141. package/.bkit/core/hooks/guardrails-read.js +3 -3
  142. package/.bkit/core/hooks/guardrails-shell.js +1122 -167
  143. package/.bkit/core/hooks/guardrails-tiers.js +247 -176
  144. package/.bkit/core/hooks/preflight-tracker.sh +219 -0
  145. package/.bkit/core/prompts/bkit-audit-generate.md +23 -6
  146. package/.bkit/core/prompts/bkit-build-challenge-1.md +5 -4
  147. package/.bkit/core/prompts/bkit-build-challenge-2.md +6 -5
  148. package/.bkit/core/prompts/bkit-build-install-skills.md +2 -2
  149. package/.bkit/core/prompts/bkit-build-plan-convert.md +21 -7
  150. package/.bkit/core/prompts/bkit-build-plan-current.md +5 -4
  151. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +22 -17
  152. package/.bkit/core/prompts/bkit-build-plan-tasks.md +16 -12
  153. package/.bkit/core/prompts/bkit-build-plan-tests.md +14 -10
  154. package/.bkit/core/prompts/bkit-build-plan-verify.md +21 -8
  155. package/.bkit/core/prompts/bkit-debug-abort-handover.md +10 -5
  156. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +22 -6
  157. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +19 -3
  158. package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +22 -6
  159. package/.bkit/core/prompts/bkit-debug-failure-soak.md +10 -7
  160. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +3 -3
  161. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +4 -4
  162. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +3 -3
  163. package/.bkit/core/prompts/bkit-design-generate.md +6 -4
  164. package/.bkit/core/prompts/bkit-design-organise.md +4 -3
  165. package/.bkit/core/prompts/bkit-design-review-1.md +5 -4
  166. package/.bkit/core/prompts/bkit-design-review-2.md +6 -5
  167. package/.bkit/core/prompts/bkit-design-spike.md +4 -3
  168. package/.bkit/core/prompts/bkit-design-update.md +6 -4
  169. package/.bkit/core/prompts/bkit-plan-generate.md +35 -14
  170. package/.bkit/core/prompts/bkit-plan-review-1.md +9 -7
  171. package/.bkit/core/prompts/bkit-plan-review-2.md +9 -7
  172. package/.bkit/core/prompts/bkit-plan-scope-check.md +8 -6
  173. package/.bkit/core/prompts/bkit-plan-update.md +22 -8
  174. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +11 -8
  175. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +9 -5
  176. package/.bkit/core/prompts/bkit-ship-update-docs.md +26 -4
  177. package/.bkit/core/prompts/bkit-utility-compress-markdown.md +3 -3
  178. package/.bkit/core/prompts/bkit-utility-update-decisions.md +10 -7
  179. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +8 -5
  180. package/.bkit/core/prompts/bkit-utility-update-documentation.md +31 -7
  181. package/.bkit/core/prompts/bkit-utility-update-failures.md +8 -5
  182. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +10 -7
  183. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +4 -4
  184. package/.bkit/core/prompts/bkit-utility-update-tracker.md +4 -4
  185. package/.bkit/core/workflows/bkit-auto.md +23 -11
  186. package/.bkit/core/workflows/bkit-build.md +331 -100
  187. package/.bkit/core/workflows/bkit-debug.md +135 -64
  188. package/.bkit/core/workflows/bkit-design.md +58 -32
  189. package/.bkit/core/workflows/bkit-plan.md +73 -45
  190. package/.bkit/core/workflows/bkit-ship.md +233 -167
  191. package/.bkit/shared/.agents/plugins/bkit/hooks.json +1 -1
  192. package/.bkit/shared/.bkit/.env.example +5 -0
  193. package/.bkit/shared/.claude/bkit-cloud.md +7 -7
  194. package/.bkit/shared/.claude/settings.json +5 -1
  195. package/.bkit/shared/.cursor/bkit-cloud.md +1 -1
  196. package/.bkit/shared/.cursor/hooks.json +1 -1
  197. package/.bkit/shared/.opencode/opencode.json +11 -2
  198. package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +27 -0
  199. package/.bkit/templates/.cursor/Dockerfile +7 -7
  200. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +1 -1
  201. package/.bkit/templates/.github/dependabot.yml +5 -0
  202. package/.bkit/templates/.github/renovate.json5 +5 -3
  203. package/.bkit/templates/.github/workflows/bkit-ci.yml +11 -11
  204. package/.bkit/templates/.github/workflows/bkit-cloud.yml +525 -161
  205. package/.bkit/templates/.github/workflows/bkit-renovate.yml +2 -2
  206. package/.bkit/templates/.husky/pre-push +123 -6
  207. package/.bkit/templates/context/bkit-serena.md +1 -1
  208. package/.bkit/templates/context/bkit-vercel.md +103 -59
  209. package/.bkit/templates/docs/architecture.md +98 -0
  210. package/.bkit/templates/docs/capabilities.md +33 -37
  211. package/.bkit/templates/docs/components.md +142 -0
  212. package/.bkit/templates/docs/data-schema.md +87 -0
  213. package/.bkit/{shared → templates}/docs/deployments.md +128 -142
  214. package/.bkit/templates/docs/design.md +117 -0
  215. package/.bkit/templates/docs/noise.md +54 -0
  216. package/.bkit/templates/docs/observability.md +99 -0
  217. package/.bkit/templates/docs/security.md +137 -0
  218. package/.bkit/templates/docs/setup.md +93 -0
  219. package/.bkit/templates/docs/technology.md +70 -0
  220. package/.bkit/{shared → templates}/docs/testing.md +200 -87
  221. package/.bkit/templates/scripts/ci/bkit-check-accepted-divergences.mjs +1 -6
  222. package/.bkit/templates/scripts/ci/bkit-machine-lock.sh +511 -103
  223. package/.bkit/templates/scripts/ci/bkit-test-awake.mjs +314 -28
  224. package/.bkit/templates/scripts/ci/bkit-test-awake.test.mjs +500 -1
  225. package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +1 -1
  226. package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +91 -62
  227. package/.bkit/templates/scripts/graphify/bkit-graphify.sh +59 -11
  228. package/.bkit/templates/slop-scan.config.json +2 -0
  229. package/CHANGELOG.md +79 -0
  230. package/DETAILS.md +661 -0
  231. package/README.md +73 -604
  232. package/dist/checks/after/auth.js +114 -46
  233. package/dist/checks/after/github.js +138 -35
  234. package/dist/checks/after/index.js +16 -4
  235. package/dist/checks/after/tools.js +224 -1
  236. package/dist/checks/before/files.js +59 -1
  237. package/dist/checks/before/index.js +7 -1
  238. package/dist/checks/status-holes.js +20 -21
  239. package/dist/checks/tips/catalogue.js +99 -10
  240. package/dist/checks/tips/detect.js +35 -3
  241. package/dist/checks/tips/index.js +1 -1
  242. package/dist/cli.js +13 -13
  243. package/dist/commands/ci/ci.js +113 -20
  244. package/dist/commands/ci/push-gate.js +79 -44
  245. package/dist/commands/install/doctor.js +5 -5
  246. package/dist/commands/install/install.js +23 -22
  247. package/dist/commands/install/uninstall.js +36 -30
  248. package/dist/commands/install/upgrade.js +10 -2
  249. package/dist/commands/land.js +2 -3
  250. package/dist/commands/lib.js +323 -25
  251. package/dist/commands/workflow/branches.js +312 -72
  252. package/dist/commands/workflow/challenge.js +66 -13
  253. package/dist/commands/workflow/context.js +46 -10
  254. package/dist/commands/workflow/counters.js +231 -23
  255. package/dist/commands/workflow/decisions.js +221 -106
  256. package/dist/commands/workflow/disk.js +2 -1
  257. package/dist/commands/workflow/feature-base.js +60 -0
  258. package/dist/commands/workflow/issues.js +243 -15
  259. package/dist/commands/workflow/junit.js +137 -0
  260. package/dist/commands/workflow/ledgers.js +726 -112
  261. package/dist/commands/workflow/locks.js +150 -29
  262. package/dist/commands/workflow/loops.js +67 -0
  263. package/dist/commands/workflow/open-decision.js +199 -0
  264. package/dist/commands/workflow/plan-blocks.js +6 -0
  265. package/dist/commands/workflow/plans.js +1 -1
  266. package/dist/commands/workflow/prs.js +272 -16
  267. package/dist/commands/workflow/repo.js +1 -1
  268. package/dist/commands/workflow/run-facts.js +6 -0
  269. package/dist/commands/workflow/runs.js +747 -155
  270. package/dist/commands/workflow/runtime.js +8 -4
  271. package/dist/commands/workflow/status.js +259 -13
  272. package/dist/commands/workflow/step-table.js +41 -15
  273. package/dist/commands/workflow/steps.js +530 -26
  274. package/dist/commands/workflow/summary-findings.js +1 -1
  275. package/dist/commands/workflow/summary.js +289 -8
  276. package/dist/commands/workflow/tasks.js +294 -27
  277. package/dist/commands/workflow/tests-base.js +266 -0
  278. package/dist/commands/workflow/tests-changed.js +130 -56
  279. package/dist/commands/workflow/tests-jump.js +77 -0
  280. package/dist/commands/workflow/tests.js +608 -131
  281. package/dist/commands/workflow/tracker.js +920 -112
  282. package/dist/commands/workflow/workflows.js +80 -59
  283. package/dist/commands/workflow/worktrees.js +387 -58
  284. package/dist/install/cloud-env.js +32 -10
  285. package/dist/install/managed-block.js +101 -0
  286. package/dist/install/manifest.js +7 -1
  287. package/dist/install/modules/claude.js +6 -2
  288. package/dist/install/modules/cloud.js +73 -86
  289. package/dist/install/modules/codex.js +9 -2
  290. package/dist/install/modules/core.js +190 -27
  291. package/dist/install/modules/opencode.js +18 -23
  292. package/dist/install/network-allowlist.js +8 -3
  293. package/dist/install/project-docs.js +551 -0
  294. package/dist/install/template-copies.js +55 -5
  295. package/dist/install/write.js +117 -5
  296. package/dist/ledgers/journal.js +10 -8
  297. package/dist/ledgers/migrate.js +20 -9
  298. package/dist/ledgers/status.js +461 -8
  299. package/dist/ledgers/telemetry.js +71 -13
  300. package/dist/render/trackers.js +21 -12
  301. package/dist/shared/package-manager.js +7 -2
  302. package/dist/shared/settings.js +8 -0
  303. package/dist/shared/text.js +13 -0
  304. package/dist/tools/instructions-sources.js +1 -0
  305. package/dist/tools/instructions.js +97 -24
  306. package/package.json +23 -15
  307. package/.bkit/core/hooks/preflight-linear.sh +0 -73
  308. package/.bkit/shared/docs/architecture.md +0 -16
  309. package/.bkit/shared/docs/data-schema.md +0 -16
  310. package/.bkit/shared/docs/design.md +0 -38
  311. package/.bkit/shared/docs/noise.md +0 -20
  312. package/.bkit/shared/docs/observability.md +0 -22
  313. package/.bkit/shared/docs/security.md +0 -62
  314. package/.bkit/shared/docs/setup.md +0 -52
  315. package/.bkit/shared/docs/technology.md +0 -15
  316. /package/.bkit/templates/{.lintstagedrc.json → lintstagedrc.example.json} +0 -0
  317. /package/.bkit/templates/{.prettierignore → prettierignore.example} +0 -0
@@ -295,10 +295,7 @@ export const runtimeCommand: CommandSpec = {
295
295
  run: (ctx) => {
296
296
  const workflow = str(ctx.flags.workflow);
297
297
  const events: ReadonlyArray<Record<string, unknown>> = readStatusEvents(statusFile(ctx));
298
- const rows = events
299
- .filter((r) => r.type === "runtime-resolved")
300
- .filter((r) => workflow === undefined || r.workflow === workflow);
301
- const row = rows[rows.length - 1];
298
+ const row = latestRuntimeRow(events, workflow);
302
299
  if (!row) {
303
300
  ctx.log(
304
301
  `no runtime-resolved row${workflow ? ` for ${workflow}` : ""} — Step 1 never recorded the runtime`,
@@ -333,3 +330,14 @@ export const runtimeCommand: CommandSpec = {
333
330
  },
334
331
  },
335
332
  };
333
+
334
+ /** The latest `runtime-resolved` row, limited to `workflow` when given; undefined with none. */
335
+ export function latestRuntimeRow(
336
+ events: ReadonlyArray<Record<string, unknown>>,
337
+ workflow?: string,
338
+ ): Record<string, unknown> | undefined {
339
+ const rows = events
340
+ .filter((r) => r.type === "runtime-resolved")
341
+ .filter((r) => workflow === undefined || r.workflow === workflow);
342
+ return rows[rows.length - 1];
343
+ }
@@ -1,5 +1,6 @@
1
1
  // bkit status route|resume|meta|path|row — read and annotate a workflow's `status.jsonl`.
2
2
 
3
+ import { randomBytes } from "node:crypto";
3
4
  import * as fs from "node:fs";
4
5
  import * as path from "node:path";
5
6
 
@@ -13,10 +14,11 @@ import {
13
14
  ciSelectionIdentity,
14
15
  allRunsDoneSteps,
15
16
  appendLine,
17
+ type InvocationEvent,
16
18
  fold,
17
19
  lastDoneStepAllRuns,
18
20
  lastRun,
19
- nextStrategy,
21
+ repeatStrategy,
20
22
  runNumber,
21
23
  runOrStepField,
22
24
  statusTimestamp,
@@ -31,11 +33,16 @@ import {
31
33
  parseJson,
32
34
  resolveActiveRun,
33
35
  statusLocation,
36
+ worktreeFingerprint,
37
+ writeInvocation,
34
38
  type CommandSpec,
39
+ type Invocation,
35
40
  type FlagSpec,
36
41
  type FlagValue,
37
42
  type RunContext,
38
43
  } from "../lib.js";
44
+ import { fixTestStep, gatedCheckStep } from "./loops.js";
45
+ import { gateRerun, openDecision } from "./open-decision.js";
39
46
  import { WORKFLOW_STEPS, isResumable, resumePoint } from "./step-table.js";
40
47
 
41
48
  // ---------------------------------------------------------------------------
@@ -196,24 +203,45 @@ type RouteField = (typeof ROUTE_FIELDS)[number];
196
203
  /** Exit code: a `--require`d field is missing or holds a value outside its set. */
197
204
  export const EXIT_ROUTE_MISSING = 4;
198
205
 
199
- function route(runs: WorkflowRun[], workflow: string, step: string | undefined, group?: number) {
206
+ /** Debug's Step 3 test round, as `counters derive --position=current` and `status route --require=verdict` read it. */
207
+ function debugTestRound(runs: WorkflowRun[], workflow: string) {
208
+ const rows =
209
+ workflow === "debug" ? activeDoneSteps(runs, workflow, { step: "debug-run-tests" }) : [];
210
+ const last = rows.at(-1);
211
+ return {
212
+ testVerdict: VERDICTS.includes(String(last?.verdict)) ? (last!.verdict as string) : null,
213
+ testSource: typeof last?.source === "string" ? last.source : null,
214
+ normalAttempt: rows.length === 0 ? null : rows.length,
215
+ };
216
+ }
217
+
218
+ function route(
219
+ runs: WorkflowRun[],
220
+ rows: readonly StatusRow[],
221
+ workflow: string,
222
+ step: string | undefined,
223
+ group?: number,
224
+ ) {
200
225
  const out: Record<string, unknown> = {
201
226
  verdict: null,
202
227
  failures: null,
203
228
  strategy: null,
204
229
  nextStrategy: null,
230
+ repeatTests: [],
205
231
  debugMode: null,
206
232
  pushMode: null,
207
233
  publish: null,
208
234
  publishSource: null,
209
235
  debugAttempt: 0,
210
236
  parentSha: null,
237
+ source: null,
211
238
  };
212
239
  const problems: Partial<Record<RouteField, string>> = {};
213
240
 
214
241
  if (step !== undefined) {
215
242
  const last = activeDoneSteps(runs, workflow, { step, group }).at(-1);
216
243
  if (typeof last?.parentSha === "string") out.parentSha = last.parentSha;
244
+ if (typeof last?.source === "string") out.source = last.source;
217
245
  if (!last) {
218
246
  problems.verdict = `no DONE ${step} row in the active ${workflow} run`;
219
247
  problems.failures = problems.verdict;
@@ -233,7 +261,19 @@ function route(runs: WorkflowRun[], workflow: string, step: string | undefined,
233
261
  const prior = lastDoneStepAllRuns(runs, workflow, { step, group })?.strategy;
234
262
  if (prior === undefined || STRATEGIES.includes(prior)) {
235
263
  out.strategy = prior ?? null;
236
- out.nextStrategy = nextStrategy(prior);
264
+ // The next label comes from the tests failing now, not from the previous label.
265
+ const testStep = fixTestStep(step, group);
266
+ const check = gatedCheckStep(step);
267
+ const current =
268
+ check === undefined
269
+ ? undefined
270
+ : activeDoneSteps(runs, workflow, { step: check, group }).length;
271
+ const next =
272
+ testStep === undefined
273
+ ? { strategy: "STANDARD", repeatTests: [] }
274
+ : repeatStrategy(rows, workflow, testStep, current);
275
+ out.nextStrategy = next.strategy;
276
+ out.repeatTests = next.repeatTests;
237
277
  } else {
238
278
  problems.strategy = `${step} strategy "${String(prior)}" is not STANDARD|PIVOT|FINAL`;
239
279
  }
@@ -417,7 +457,7 @@ export const statusCommand: CommandSpec = {
417
457
  },
418
458
  route: {
419
459
  summary:
420
- "Routing state: last verdict / failures / strategy of a step, debug and push mode; with --prompt-file, debug's start decisions.",
460
+ "Routing state: last verdict / failures / strategy of a step, debug and push mode; with --step, nextStrategy and repeatTests (the next fix round's label, from the tests failing again); with --prompt-file, debug's start decisions.",
421
461
  use: "workflow",
422
462
  flags: [
423
463
  { ...FILE_FLAG, required: false, help: `${FILE_FLAG.help}; or --fid and --month` },
@@ -459,7 +499,10 @@ export const statusCommand: CommandSpec = {
459
499
  failures:
460
500
  "its failures (absent on PASS|CONCERNS = 0, absent on FAIL = null: count unknown), or null",
461
501
  strategy: "the step's last strategy across ALL runs, or null",
462
- nextStrategy: "next rung: STANDARD, PIVOT, FINAL (null without --step)",
502
+ nextStrategy:
503
+ "the next fix round's label, from the tests failing now on the fix step's test step: STANDARD when none failed in an earlier attempt, PIVOT when one did in 1, FINAL in 2 or more (null without --step)",
504
+ repeatTests:
505
+ "the tests failing now that also failed in an earlier attempt, across every run (empty without --step)",
463
506
  debugMode:
464
507
  "NORMAL|SOAK of the active run, or null; with --prompt-file, the mode this invocation runs in (SOAK on [soak] in the prompt, an open run already in SOAK, or bkit.workflows.debug.fix.maxAttempts fix rounds already run across every debug run; else NORMAL)",
465
508
  pushMode: "PR|LOCAL of the active run, or null",
@@ -474,6 +517,8 @@ export const statusCommand: CommandSpec = {
474
517
  "with publish: token | local | remote | coerced (a non-LOCAL false forced to true), else null",
475
518
  parentSha:
476
519
  "HEAD when the step's last DONE row in the active run was written — a build-group-start row's is the group's start commit, the base for `context diff` — or null",
520
+ source:
521
+ "the `source` field of the step's last DONE row in the active run (debug-run-tests: local|ci), or null",
477
522
  },
478
523
  exitCodes: {
479
524
  [EXIT_NO_STATUS]: "status.jsonl missing, unreadable, or not valid NDJSON",
@@ -519,9 +564,12 @@ export const statusCommand: CommandSpec = {
519
564
  throw new CommandError(EXIT.USAGE, `--prompt-file ${abs} does not exist`);
520
565
  promptText = fs.readFileSync(abs, "utf-8");
521
566
  }
522
- const runs = promptFile !== undefined && !fs.existsSync(file) ? [] : readRuns(file);
567
+ const statusRows =
568
+ promptFile !== undefined && !fs.existsSync(file) ? [] : readStatusRows(file);
569
+ const runs = fold(statusRows as StatusEvent[]);
523
570
  const { out, problems } = route(
524
571
  runs,
572
+ statusRows,
525
573
  String(ctx.flags.workflow),
526
574
  step,
527
575
  positiveInt(ctx.flags.group, "group"),
@@ -533,8 +581,7 @@ export const statusCommand: CommandSpec = {
533
581
  Object.assign(out, debugStart(runs, promptText, config.asks["debug.fix"].max));
534
582
  delete problems.debugMode;
535
583
  } else {
536
- const rows = fs.existsSync(file) ? readStatusRows(file) : [];
537
- Object.assign(out, publishRoute(rows, promptText, config.buildPublish));
584
+ Object.assign(out, publishRoute(statusRows, promptText, config.buildPublish));
538
585
  delete problems.publish;
539
586
  }
540
587
  }
@@ -551,9 +598,235 @@ export const statusCommand: CommandSpec = {
551
598
  return failed.length === 0 && differ.length === 0 ? EXIT.OK : EXIT_ROUTE_MISSING;
552
599
  },
553
600
  },
601
+ invocation: {
602
+ summary:
603
+ "Issue an engine-bound invocation: a run's step (and agent), or a runless audit or utility call.",
604
+ use: "workflow",
605
+ flags: [
606
+ { ...WORKFLOW_FLAG, required: false, help: "workflow name, with --step and --file" },
607
+ { ...STEP_FLAG, required: false, help: "registered step of the workflow" },
608
+ { ...FILE_FLAG, required: false, help: "the run's status.jsonl, relative to the cwd" },
609
+ { name: "group", type: "string", help: "the task group a group-scoped step runs for" },
610
+ { name: "attempt", type: "string", help: "the attempt of that group or remediation round" },
611
+ { name: "agent", type: "string", help: "the subagent this invocation is for" },
612
+ { name: "host", type: "string", help: "the host running the agent" },
613
+ {
614
+ name: "configured-model",
615
+ type: "string",
616
+ help: "the pin the agent was launched with; kept apart from the observed model",
617
+ },
618
+ {
619
+ name: "observed-model",
620
+ type: "string",
621
+ help: "the model the host reported, or `unavailable`",
622
+ },
623
+ { name: "standalone", type: "string", help: "audit|utility: a call with no run" },
624
+ { name: "name", type: "string", help: "with --standalone: the audit or utility name" },
625
+ ],
626
+ output: {
627
+ invocation: "the id to pass as --invocation to later commands",
628
+ receipt: "the outbox file holding the issued context",
629
+ scope: "run (bound to a status.jsonl) or outbox (runless audit or utility)",
630
+ workflow: "the workflow, or null",
631
+ step: "the registered step, or null",
632
+ number: "the step's registered number, or null",
633
+ title: "the step's registered title, or null",
634
+ run: "the workflow's run number, or null without a run",
635
+ statusPath: "absolute path to the run's status.jsonl, or null",
636
+ bookRoot: "root the run's books live under, or null",
637
+ group: "the task group, or null",
638
+ attempt: "the attempt, or null",
639
+ declaredStep: "audit|utility:<name> for a runless call, or null",
640
+ allowedAgent: "the one agent a runless call may write as, or null",
641
+ agent: "the agent, or null",
642
+ host: "the host, or null",
643
+ configuredModel: "the launch pin, or null",
644
+ observedModel: "the reported model or `unavailable`, or null",
645
+ },
646
+ exitCodes: { [EXIT_NO_STATUS]: "status.jsonl missing, unreadable, or not valid NDJSON" },
647
+ run: (ctx) => {
648
+ const top = git(ctx.cwd, ["rev-parse", "--show-toplevel"]);
649
+ if (top === null) throw new CommandError(EXIT.USAGE, "not inside a git repository");
650
+ const standalone = str(ctx.flags.standalone);
651
+ const workflow = str(ctx.flags.workflow);
652
+ const step = str(ctx.flags.step);
653
+ const file = str(ctx.flags.file);
654
+ const agent = str(ctx.flags.agent) ?? null;
655
+ if (agent !== null && !/^[a-z0-9][a-z0-9._-]*$/.test(agent))
656
+ throw new CommandError(EXIT.USAGE, `--agent "${agent}" is not an agent name`);
657
+ const group = str(ctx.flags.group);
658
+ const attempt = str(ctx.flags.attempt);
659
+ for (const [flag, v] of [
660
+ ["group", group],
661
+ ["attempt", attempt],
662
+ ] as const)
663
+ if (v !== undefined && !/^[A-Za-z0-9._-]+$/.test(v))
664
+ throw new CommandError(EXIT.USAGE, `--${flag} "${v}" is not a ${flag} id`);
665
+ const base = {
666
+ group: group ?? null,
667
+ attempt: attempt ?? null,
668
+ agent,
669
+ host: str(ctx.flags.host) ?? null,
670
+ configuredModel: str(ctx.flags.configuredModel) ?? null,
671
+ // An agent whose host reported no model is recorded `unavailable`, so its rows stay writable.
672
+ observedModel: str(ctx.flags.observedModel) ?? (agent !== null ? "unavailable" : null),
673
+ };
674
+ let inv: Omit<Invocation, "id" | "issuedAt" | "version" | "worktree">;
675
+ if (standalone !== undefined) {
676
+ oneOf(standalone, ["audit", "utility"], "--standalone");
677
+ if ([workflow, step, file].some((v) => v !== undefined))
678
+ throw new CommandError(
679
+ EXIT.USAGE,
680
+ "--standalone has no run: drop --workflow, --step and --file",
681
+ );
682
+ const name = str(ctx.flags.name);
683
+ if (name === undefined || name === "")
684
+ throw new CommandError(EXIT.USAGE, "--standalone needs --name");
685
+ if (!/^[a-z0-9][a-z0-9._-]*$/.test(name))
686
+ throw new CommandError(EXIT.USAGE, `--name "${name}" is not an audit or utility name`);
687
+ if (group !== undefined || attempt !== undefined)
688
+ throw new CommandError(EXIT.USAGE, "--standalone has no group or attempt");
689
+ inv = {
690
+ scope: "outbox",
691
+ workflow: null,
692
+ step: null,
693
+ number: null,
694
+ title: null,
695
+ run: null,
696
+ statusPath: null,
697
+ bookRoot: null,
698
+ standalone,
699
+ name,
700
+ declaredStep: `${standalone}:${name}`,
701
+ allowedAgent: agent,
702
+ ...base,
703
+ };
704
+ } else {
705
+ if (workflow === undefined || step === undefined || file === undefined)
706
+ throw new CommandError(
707
+ EXIT.USAGE,
708
+ "give --workflow, --step and --file, or --standalone=audit|utility with --name",
709
+ );
710
+ if (ctx.flags.name !== undefined)
711
+ throw new CommandError(EXIT.USAGE, "--name is for --standalone");
712
+ if (!isResumable(workflow))
713
+ throw new CommandError(
714
+ EXIT.USAGE,
715
+ `--workflow must be ${Object.keys(WORKFLOW_STEPS).join("|")}, got "${workflow}"`,
716
+ );
717
+ const registered = WORKFLOW_STEPS[workflow].find((s) => s.step === step);
718
+ if (registered === undefined)
719
+ throw new CommandError(
720
+ EXIT.USAGE,
721
+ `--step ${step} is not a registered ${workflow} step`,
722
+ );
723
+ const statusPath = path.resolve(ctx.cwd, file);
724
+ const realFile = (() => {
725
+ let dir = path.dirname(statusPath);
726
+ const tail: string[] = [path.basename(statusPath)];
727
+ while (!fs.existsSync(dir) && path.dirname(dir) !== dir) {
728
+ tail.unshift(path.basename(dir));
729
+ dir = path.dirname(dir);
730
+ }
731
+ return path.join(fs.realpathSync(dir), ...tail);
732
+ })();
733
+ const realTop = fs.realpathSync(top);
734
+ // A status file that is itself a symlink resolves wherever it points; the parent
735
+ // directory alone says nothing about where appends land.
736
+ if (fs.lstatSync(statusPath, { throwIfNoEntry: false })?.isSymbolicLink() === true)
737
+ throw new CommandError(
738
+ EXIT.USAGE,
739
+ `--file ${file} is a symbolic link; issue the invocation for the status file itself`,
740
+ );
741
+ // The checkout that owns the file: a worktree nested under this one has its own top
742
+ // folder, so a plain path-prefix test would accept it.
743
+ let ownerDir = path.dirname(realFile);
744
+ while (!fs.existsSync(ownerDir) && path.dirname(ownerDir) !== ownerDir)
745
+ ownerDir = path.dirname(ownerDir);
746
+ const fileTop = git(ownerDir, ["rev-parse", "--show-toplevel"]);
747
+ const ownerTop = fileTop === null ? null : fs.realpathSync(fileTop);
748
+ if (
749
+ (realFile !== realTop && !realFile.startsWith(realTop + path.sep)) ||
750
+ (ownerTop !== null && ownerTop !== realTop)
751
+ )
752
+ throw new CommandError(
753
+ EXIT.USAGE,
754
+ `--file ${file} is outside this checkout (${top}); issue the invocation from the checkout that owns the run`,
755
+ );
756
+ const logs = path.dirname(path.dirname(statusPath));
757
+ if (
758
+ path.basename(statusPath) !== "status.jsonl" ||
759
+ path.basename(logs) !== "logs" ||
760
+ path.basename(path.dirname(path.dirname(logs))) !== "plans"
761
+ )
762
+ throw new CommandError(
763
+ EXIT.USAGE,
764
+ `--file ${file} is not a docs/plans/<month>/logs/<fid>/status.jsonl`,
765
+ );
766
+ inv = {
767
+ scope: "run",
768
+ workflow,
769
+ step,
770
+ number: registered.number,
771
+ title: registered.title,
772
+ run: runNumber(readRuns(statusPath), workflow),
773
+ statusPath,
774
+ bookRoot: path.dirname(path.dirname(path.dirname(path.dirname(logs)))),
775
+ standalone: null,
776
+ name: null,
777
+ declaredStep: null,
778
+ allowedAgent: null,
779
+ ...base,
780
+ };
781
+ }
782
+ const id = `inv-${randomBytes(16).toString("hex")}`;
783
+ const issued: Invocation = {
784
+ id,
785
+ version: 1,
786
+ ...inv,
787
+ worktree: top,
788
+ issuedAt: statusTimestamp(),
789
+ };
790
+ if (issued.scope === "run" && fs.existsSync(issued.statusPath!)) {
791
+ // The run's status log is the authority; the receipt is an index rebuilt from it.
792
+ const event: InvocationEvent = {
793
+ type: "invocation",
794
+ workflow: issued.workflow!,
795
+ at: issued.issuedAt,
796
+ id,
797
+ step: issued.step!,
798
+ number: issued.number!,
799
+ title: issued.title!,
800
+ run: issued.run!,
801
+ statusPath: path.relative(top, issued.statusPath!),
802
+ bookRoot: path.relative(top, issued.bookRoot!) || ".",
803
+ group: issued.group,
804
+ attempt: issued.attempt,
805
+ agent: issued.agent,
806
+ host: issued.host,
807
+ configuredModel: issued.configuredModel,
808
+ observedModel: issued.observedModel,
809
+ worktree: worktreeFingerprint(top),
810
+ };
811
+ fs.appendFileSync(issued.statusPath!, appendLine(event));
812
+ }
813
+ const receipt = writeInvocation(ctx.cwd, issued);
814
+ const {
815
+ id: _id,
816
+ version: _v,
817
+ worktree: _w,
818
+ issuedAt: _at,
819
+ standalone: _s,
820
+ name: _n,
821
+ ...out
822
+ } = issued;
823
+ ctx.emit({ invocation: id, receipt, ...out });
824
+ return EXIT.OK;
825
+ },
826
+ },
554
827
  resume: {
555
828
  summary:
556
- "The step a stopped run continues at: after its last DONE step, setup steps and retired rows aside.",
829
+ "The step a stopped run continues at: after its last DONE step, setup steps and retired rows aside; gateRerun and rerunFrom say whether an open red-gate pause re-runs its gate first, and which.",
557
830
  use: "by-hand",
558
831
  flags: [
559
832
  { ...FILE_FLAG, help: "path to status.jsonl; a missing file is a run with no rows" },
@@ -570,8 +843,21 @@ export const statusCommand: CommandSpec = {
570
843
  "build: the round Step 11's challenge runs as (1 up to bkit.workflows.build.challenge.maxAttempts), from the build-challenge rows' round field; null for other workflows",
571
844
  challengeDone:
572
845
  "build: true once the last allowed challenge round has merged, so Step 11 goes on to Step 12; null for other workflows",
846
+ gateRerun:
847
+ "true when the active run's open decision file (as `workflows start` prints it in openDecision) has a Gate: FAIL header, Status: OPEN, From verify, holistic or tests, and the loop question as its only undecided question: re-run that gate instead of asking again; else false",
848
+ rerunFrom:
849
+ "verify | holistic | tests: the open decision file's From header, the check whose gate re-runs; null when gateRerun is false",
850
+ testVerdict:
851
+ "debug: the verdict of the active run's last DONE debug-run-tests row (PASS|CONCERNS|FAIL), or null; other workflows null",
852
+ testSource: "debug: that row's source (local|ci), or null; other workflows null",
853
+ normalAttempt:
854
+ "debug: the active run's DONE debug-run-tests rows (the round Steps 4-11 name their artifacts by), or null when there is none; other workflows null",
855
+ },
856
+ exitCodes: {
857
+ [EXIT_NO_STATUS]: "status.jsonl unreadable or not valid NDJSON",
858
+ [EXIT_ROUTE_MISSING]:
859
+ "debug: the run continues after Step 3 and Step 3's test round has no DONE row or no PASS|CONCERNS|FAIL verdict",
573
860
  },
574
- exitCodes: { [EXIT_NO_STATUS]: "status.jsonl unreadable or not valid NDJSON" },
575
861
  run: (ctx) => {
576
862
  const workflow = String(ctx.flags.workflow);
577
863
  if (!isResumable(workflow))
@@ -582,9 +868,36 @@ export const statusCommand: CommandSpec = {
582
868
  const file = statusFile(ctx);
583
869
  const root = git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? ctx.cwd;
584
870
  const challengeMax = readBkitConfig(root).asks["build.challenge"].max;
871
+ const runs = fs.existsSync(file) ? readRuns(file) : [];
872
+ const point = resumePoint(runs, workflow, challengeMax);
873
+ const current = point.active ? lastRun(runs, workflow) : undefined;
874
+ const open =
875
+ current === undefined
876
+ ? null
877
+ : openDecision(
878
+ path.dirname(file),
879
+ root,
880
+ workflow,
881
+ runNumber(runs, workflow),
882
+ current.steps
883
+ .filter((s) => s.step === `${workflow}-decision`)
884
+ .flatMap((s) => s.artifacts),
885
+ );
886
+ const round = debugTestRound(runs, workflow);
585
887
  ctx.emit({
586
- ...resumePoint(fs.existsSync(file) ? readRuns(file) : [], workflow, challengeMax),
888
+ ...point,
889
+ ...gateRerun(
890
+ open,
891
+ open === null ? "" : fs.readFileSync(path.resolve(root, open.file), "utf-8"),
892
+ ),
893
+ ...round,
587
894
  });
895
+ if (workflow === "debug" && point.number > 3 && round.testVerdict === null) {
896
+ ctx.log(
897
+ "debug resumes after Step 3, but no DONE debug-run-tests row with a verdict is in the active run",
898
+ );
899
+ return EXIT_ROUTE_MISSING;
900
+ }
588
901
  return EXIT.OK;
589
902
  },
590
903
  },
@@ -92,7 +92,29 @@ export const WORKFLOW_STEPS: Readonly<Record<ResumableWorkflow, readonly Workflo
92
92
  title: "Plan Gaps Remediate",
93
93
  resumeAt: "build-plan-verify",
94
94
  },
95
- { step: "build-plan-verify-holistic", number: 10, title: "Plan Verify Holistic" },
95
+ // Holistic verify never passes on alone: its gate runs after every verdict, so a run
96
+ // stopped between the two runs the round again. Step 10 again.
97
+ {
98
+ step: "build-plan-verify-holistic",
99
+ number: 10,
100
+ title: "Plan Verify Holistic",
101
+ resumeAt: "build-plan-verify-holistic",
102
+ },
103
+ // The holistic gate routes with its verify: Step 10 again.
104
+ {
105
+ step: "build-holistic-gate",
106
+ number: 10,
107
+ title: "Plan Verify Holistic",
108
+ resumeAt: "build-plan-verify-holistic",
109
+ },
110
+ // A holistic fix can add a takeover group: Step 7 runs it, and goes straight on to
111
+ // Step 10 when no group is open.
112
+ {
113
+ step: "build-plan-gaps-remediate-holistic",
114
+ number: 10,
115
+ title: "Plan Verify Holistic",
116
+ resumeAt: "build-plan-tasks",
117
+ },
96
118
  // The reports are written: Step 11 continues at `bkit challenge merge`.
97
119
  { step: "build-challenge", number: 11, title: "Build Challenge", resumeAt: "build-challenge" },
98
120
  // Run Tests routes on its own verdict, and a fix loops back to it.
@@ -161,25 +183,15 @@ export const WORKFLOW_STEPS: Readonly<Record<ResumableWorkflow, readonly Workflo
161
183
  { step: "ship-prune-skills", number: 7, title: "Prune Skills" },
162
184
  { step: "ship-bookkeeping-push", number: 8, title: "Commit + Push Bookkeeping" },
163
185
  { number: 9, title: "Re-validate" },
164
- // The merge gate reads the PR state again: a merged PR goes on to Step 13.
186
+ // The merge gate reads the PR state again: a merged PR goes on to Step 11.
165
187
  {
166
188
  step: "ship-merge-pr",
167
189
  number: 10,
168
190
  title: "Merge Gate + Merge PR",
169
191
  resumeAt: "ship-merge-pr",
170
192
  },
171
- { step: "ship-failure-diagnose", number: 11, title: "Failure Diagnose" },
172
- // A PASS fix is committed and pushed at Step 12 sub-step 4 (a re-run commits nothing
173
- // new), then re-validated at Step 9; any other verdict re-reads the PR at Step 10.
174
- {
175
- step: "ship-failure-remediate",
176
- number: 12,
177
- title: "Failure Remediate",
178
- resumeAt: "ship-merge-pr",
179
- resumeOnVerdict: { PASS: "ship-failure-remediate" },
180
- },
181
- { step: "ship-switch-to-dev", number: 13, title: "Update Local Dev" },
182
- { step: "ship-close-workflow", number: 14, title: "Close Workflow" },
193
+ { step: "ship-switch-to-dev", number: 11, title: "Update Local Dev" },
194
+ { step: "ship-close-workflow", number: 12, title: "Close Workflow" },
183
195
  ],
184
196
  };
185
197
 
@@ -215,13 +227,27 @@ export const DECISION_ROUTES: Readonly<
215
227
  routes: {
216
228
  fix: "build-plan-tasks",
217
229
  verify: "build-plan-verify",
230
+ holistic: "build-plan-verify-holistic",
218
231
  tests: "build-run-tests",
219
- // Try again: a verify loop goes on to its gaps fix (Step 9), a tests loop to Step 13.
232
+ // Try again: a verify loop goes on to its gaps fix (Step 9 or Step 10's), a tests loop to Step 13.
220
233
  retry: {
221
234
  "build-plan-verify": "build-plan-gaps-remediate",
222
235
  "build-group-gate": "build-plan-gaps-remediate",
236
+ "build-plan-verify-holistic": "build-plan-gaps-remediate-holistic",
237
+ "build-holistic-gate": "build-plan-gaps-remediate-holistic",
238
+ "build-plan-gaps-remediate-holistic": "build-plan-gaps-remediate-holistic",
223
239
  "build-run-tests": "build-failure-diagnose",
224
240
  },
241
+ // Continue: every gap accepted, so the loop is settled. A group verify goes on to the next
242
+ // group's Plan Execute, a holistic round to Build Challenge.
243
+ continue: {
244
+ "build-plan-verify": "build-plan-tasks",
245
+ "build-group-gate": "build-plan-tasks",
246
+ "build-plan-gaps-remediate": "build-plan-tasks",
247
+ "build-plan-verify-holistic": "build-challenge",
248
+ "build-holistic-gate": "build-challenge",
249
+ "build-plan-gaps-remediate-holistic": "build-challenge",
250
+ },
225
251
  },
226
252
  },
227
253
  };