tumwater 0.2.0 → 0.3.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 (446) hide show
  1. package/README.md +27 -13
  2. package/dist/build-info.json +2 -2
  3. package/dist/src/agent/agent-args.js +8 -9
  4. package/dist/src/agent/agent-backend.js +8 -6
  5. package/dist/src/agent/backend-traits.js +42 -25
  6. package/dist/src/agent/claude/claude-account.js +71 -204
  7. package/dist/src/agent/claude/claude-args.js +9 -6
  8. package/dist/src/agent/claude/claude-backend.js +10 -10
  9. package/dist/src/agent/claude/claude-env.js +1 -1
  10. package/dist/src/agent/claude/claude-stream.js +4 -3
  11. package/dist/src/agent/claude/claude-write-guard.js +49 -0
  12. package/dist/src/agent/claude/write-guard-hook.js +13 -0
  13. package/dist/src/agent/codex/codex-account.js +119 -0
  14. package/dist/src/agent/codex/codex-args.js +181 -0
  15. package/dist/src/agent/codex/codex-backend.js +279 -0
  16. package/dist/src/agent/codex/codex-catalog.js +97 -0
  17. package/dist/src/agent/codex/codex-env.js +18 -0
  18. package/dist/src/agent/codex/codex-hook-trust.js +246 -0
  19. package/dist/src/agent/codex/codex-patch-paths.js +36 -0
  20. package/dist/src/agent/codex/codex-rollout.js +179 -0
  21. package/dist/src/agent/codex/codex-stream.js +402 -0
  22. package/dist/src/agent/codex/codex-write-guard.js +86 -0
  23. package/dist/src/agent/codex/write-guard-hook.js +12 -0
  24. package/dist/src/agent/image-input.js +29 -24
  25. package/dist/src/agent/notes-shim.js +11 -12
  26. package/dist/src/agent/opencode/opencode-args.js +0 -1
  27. package/dist/src/agent/opencode/opencode-backend.js +12 -9
  28. package/dist/src/agent/opencode/opencode-catalog.js +55 -29
  29. package/dist/src/agent/opencode/opencode-config.js +19 -14
  30. package/dist/src/agent/opencode/opencode-env.js +0 -1
  31. package/dist/src/agent/opencode/opencode-session-id.js +1 -2
  32. package/dist/src/agent/opencode/opencode-stream.js +1 -1
  33. package/dist/src/agent/opencode/write-guard-plugin/index.js +48 -0
  34. package/dist/src/agent/role-notes-write.js +5 -6
  35. package/dist/src/agent/run-agent.js +465 -448
  36. package/dist/src/agent/run-settle.js +214 -0
  37. package/dist/src/agent/session-ledger.js +86 -16
  38. package/dist/src/agent/subscription-account.js +220 -0
  39. package/dist/src/agent/write-guard.js +148 -0
  40. package/dist/src/backlog/backlog-archive.js +246 -55
  41. package/dist/src/backlog/backlog-cli-view.js +280 -0
  42. package/dist/src/backlog/backlog-cli.js +85 -274
  43. package/dist/src/backlog/backlog-commit.js +4 -5
  44. package/dist/src/backlog/backlog-eligibility.js +175 -242
  45. package/dist/src/backlog/backlog-index.js +149 -0
  46. package/dist/src/backlog/backlog-md.js +54 -6
  47. package/dist/src/backlog/backlog-parts.js +254 -0
  48. package/dist/src/backlog/backlog-release.js +117 -0
  49. package/dist/src/backlog/backlog-render.js +27 -0
  50. package/dist/src/backlog/backlog-structure.js +99 -156
  51. package/dist/src/backlog/backlog-write.js +40 -127
  52. package/dist/src/backlog/backlog.js +21 -6
  53. package/dist/src/backlog/question-answer.js +21 -15
  54. package/dist/src/baseline/main-baseline.js +89 -20
  55. package/dist/src/baseline/main-culprit.js +94 -0
  56. package/dist/src/baseline/main-guardrails.js +209 -0
  57. package/dist/src/baseline/main-red.js +139 -32
  58. package/dist/src/baseline/main-revert.js +133 -0
  59. package/dist/src/baseline/main-watch.js +184 -0
  60. package/dist/src/brief/brief-edit.js +9 -11
  61. package/dist/src/brief/brief.js +31 -51
  62. package/dist/src/budget/budget.js +30 -20
  63. package/dist/src/budget/fallback-breaker.js +26 -27
  64. package/dist/src/build/build-check-detect.js +23 -15
  65. package/dist/src/build/build-check-events.js +25 -6
  66. package/dist/src/build/build-check-report.js +49 -9
  67. package/dist/src/build/build-check-scoped.js +18 -11
  68. package/dist/src/build/build-check.js +2 -1
  69. package/dist/src/build/build-info.js +2 -3
  70. package/dist/src/build/build-stage.js +9 -14
  71. package/dist/src/build/dep-install.js +1 -2
  72. package/dist/src/change/change-data.js +123 -31
  73. package/dist/src/change/change-render.js +46 -5
  74. package/dist/src/cli/brief-command.js +3 -4
  75. package/dist/src/cli/cli-args.js +118 -33
  76. package/dist/src/cli/cli-command-args.js +46 -18
  77. package/dist/src/cli/cli-editor.js +2 -1
  78. package/dist/src/cli/cli-flag-specs.js +150 -45
  79. package/dist/src/cli/cli-init.js +51 -0
  80. package/dist/src/cli/cli-marker-commands.js +4 -4
  81. package/dist/src/cli/cli-query-commands.js +308 -590
  82. package/dist/src/cli/cli-repo-gate.js +11 -1
  83. package/dist/src/cli/cli-role-command.js +420 -0
  84. package/dist/src/cli/cli-start-summary.js +160 -0
  85. package/dist/src/cli/{cli-run.js → cli-start.js} +165 -237
  86. package/dist/src/cli/completion.js +149 -22
  87. package/dist/src/cli/config-commands.js +41 -18
  88. package/dist/src/cli/follow-view.js +75 -0
  89. package/dist/src/cli/help.js +189 -73
  90. package/dist/src/cli/log-commands.js +148 -82
  91. package/dist/src/cli/question-commands.js +205 -10
  92. package/dist/src/cli.js +106 -43
  93. package/dist/src/collections.js +26 -10
  94. package/dist/src/concurrency/check-permit.js +20 -3
  95. package/dist/src/concurrency/lock.js +17 -13
  96. package/dist/src/concurrency/provider-lease.js +44 -8
  97. package/dist/src/concurrency/semaphore.js +102 -26
  98. package/dist/src/config/config-aliases.js +0 -1
  99. package/dist/src/config/config-editable-keys.js +13 -1
  100. package/dist/src/config/config-fallbacks.js +93 -56
  101. package/dist/src/config/config-field-checks.js +40 -10
  102. package/dist/src/config/config-keys.js +30 -8
  103. package/dist/src/config/config-live.js +63 -24
  104. package/dist/src/config/config-request.js +137 -0
  105. package/dist/src/config/config-schema.js +31 -24
  106. package/dist/src/config/config-selector-checks.js +123 -0
  107. package/dist/src/config/config-validation-agents.js +80 -0
  108. package/dist/src/config/config-validation-model.js +116 -0
  109. package/dist/src/config/config-validation.js +141 -199
  110. package/dist/src/config/config-views.js +127 -53
  111. package/dist/src/config/config-write-core.js +135 -0
  112. package/dist/src/config/config-write.js +131 -264
  113. package/dist/src/config/config.js +48 -38
  114. package/dist/src/config/model-selector.js +34 -34
  115. package/dist/src/doctor/doctor-backlog-bugs.js +287 -0
  116. package/dist/src/doctor/doctor-backlog-plans.js +263 -0
  117. package/dist/src/doctor/doctor-backlog.js +100 -496
  118. package/dist/src/doctor/doctor-check-names.js +81 -0
  119. package/dist/src/doctor/doctor-checks.js +52 -579
  120. package/dist/src/doctor/doctor-claude-checks.js +145 -0
  121. package/dist/src/doctor/doctor-codex-checks.js +279 -0
  122. package/dist/src/doctor/doctor-contention-checks.js +380 -0
  123. package/dist/src/doctor/doctor-holds.js +82 -66
  124. package/dist/src/doctor/doctor-install.js +2 -1
  125. package/dist/src/doctor/doctor-model-checks.js +236 -402
  126. package/dist/src/doctor/doctor-notify.js +3 -4
  127. package/dist/src/doctor/doctor-opencode-checks.js +162 -0
  128. package/dist/src/doctor/doctor-orphans.js +182 -63
  129. package/dist/src/doctor/doctor-project-checks.js +303 -0
  130. package/dist/src/doctor/doctor.js +121 -77
  131. package/dist/src/doctor/image-probe.js +21 -8
  132. package/dist/src/doctor/outcome.js +3 -2
  133. package/dist/src/doctor/probe.js +7 -11
  134. package/dist/src/events/event-format.js +181 -86
  135. package/dist/src/events/event-labels.js +12 -5
  136. package/dist/src/events/event-legacy.js +39 -15
  137. package/dist/src/events/event-read.js +39 -39
  138. package/dist/src/events/event-tally.js +16 -0
  139. package/dist/src/events/event-window.js +60 -24
  140. package/dist/src/events/events.js +30 -13
  141. package/dist/src/events/notify.js +7 -7
  142. package/dist/src/failure/failure-cluster.js +12 -12
  143. package/dist/src/failure/failure-data.js +56 -56
  144. package/dist/src/failure/failure-render.js +31 -23
  145. package/dist/src/failure/failure-state-change.js +17 -12
  146. package/dist/src/failure/time-spend.js +99 -35
  147. package/dist/src/files/files.js +111 -35
  148. package/dist/src/files/json-files.js +3 -3
  149. package/dist/src/files/json-object.js +28 -7
  150. package/dist/src/files/stat-cache.js +2 -2
  151. package/dist/src/files/tail.js +1 -1
  152. package/dist/src/gates/bootstrap-gates.js +4 -5
  153. package/dist/src/gates/budget-gates.js +177 -84
  154. package/dist/src/gates/disk-gate.js +1 -1
  155. package/dist/src/gates/gate-polls.js +108 -58
  156. package/dist/src/gates/maintenance-quota.js +10 -13
  157. package/dist/src/gates/pause-gates.js +28 -10
  158. package/dist/src/gates/readiness.js +7 -3
  159. package/dist/src/gates/role-cap-gates.js +8 -8
  160. package/dist/src/gates/startup-gate.js +94 -32
  161. package/dist/src/gates/streak-gate.js +54 -30
  162. package/dist/src/git/commit-message.js +77 -46
  163. package/dist/src/git/git-diff.js +16 -10
  164. package/dist/src/git/git-run.js +79 -38
  165. package/dist/src/git/git.js +36 -34
  166. package/dist/src/git/slot-salvage.js +253 -0
  167. package/dist/src/git/slots-state.js +6 -6
  168. package/dist/src/git/worktree-pool.js +132 -38
  169. package/dist/src/git/worktree-use.js +4 -11
  170. package/dist/src/git/worktree.js +94 -37
  171. package/dist/src/gui/gui-admin-endpoints.js +96 -0
  172. package/dist/src/gui/gui-args.js +79 -8
  173. package/dist/src/gui/gui-backlog-commands.js +42 -18
  174. package/dist/src/gui/gui-backlog-endpoints.js +155 -0
  175. package/dist/src/gui/gui-command.js +8 -13
  176. package/dist/src/gui/gui-config-commands.js +94 -72
  177. package/dist/src/gui/gui-endpoint-commands.js +4 -3
  178. package/dist/src/gui/gui-endpoint-common.js +4 -4
  179. package/dist/src/gui/gui-endpoints.js +11 -380
  180. package/dist/src/gui/gui-history-endpoints.js +301 -0
  181. package/dist/src/gui/gui-operator-commands.js +108 -13
  182. package/dist/src/gui/gui-prompt-commands.js +11 -14
  183. package/dist/src/gui/gui-report-endpoints.js +90 -0
  184. package/dist/src/gui/gui-server.js +11 -4
  185. package/dist/src/gui/gui-team-commands.js +7 -7
  186. package/dist/src/gui/http-body.js +1 -1
  187. package/dist/src/history/history-data.js +122 -234
  188. package/dist/src/history/history-queued.js +147 -0
  189. package/dist/src/history/history-render.js +42 -22
  190. package/dist/src/history/history.js +193 -49
  191. package/dist/src/inbox/inbox-attachments.js +29 -30
  192. package/dist/src/inbox/inbox-cancel.js +10 -11
  193. package/dist/src/inbox/inbox-edit.js +9 -9
  194. package/dist/src/inbox/inbox-submit.js +18 -18
  195. package/dist/src/inbox/inbox-top.js +25 -9
  196. package/dist/src/inbox/inbox.js +42 -43
  197. package/dist/src/inbox/pending-prompt.js +26 -26
  198. package/dist/src/inbox/prompt-commands.js +62 -49
  199. package/dist/src/inbox/prompt-not-before.js +2 -2
  200. package/dist/src/init/init-templates.js +1 -2
  201. package/dist/src/init/init.js +28 -23
  202. package/dist/src/merge/backlog-conflicts.js +215 -35
  203. package/dist/src/merge/merge-batch.js +14 -8
  204. package/dist/src/merge/merge-cancel.js +53 -0
  205. package/dist/src/merge/merge-check-failures.js +44 -22
  206. package/dist/src/merge/merge-core.js +81 -32
  207. package/dist/src/merge/merge-diff.js +5 -4
  208. package/dist/src/merge/merge-drain.js +150 -11
  209. package/dist/src/merge/merge-git.js +177 -38
  210. package/dist/src/merge/merge-pipeline.js +15 -3
  211. package/dist/src/merge/merge-post-review.js +90 -0
  212. package/dist/src/merge/merge-queue-render.js +49 -11
  213. package/dist/src/merge/merge-queue.js +31 -15
  214. package/dist/src/merge/merge-requeue.js +102 -0
  215. package/dist/src/merge/merge-slot.js +61 -16
  216. package/dist/src/merge/merge-stack.js +33 -11
  217. package/dist/src/merge/merge-to-main.js +86 -27
  218. package/dist/src/merge/merge-top.js +69 -0
  219. package/dist/src/merge/merge-verify.js +12 -10
  220. package/dist/src/notes-cli.js +30 -15
  221. package/dist/src/operator/operator-commands.js +192 -81
  222. package/dist/src/operator/operator-intent.js +69 -42
  223. package/dist/src/operator/operator-requests.js +35 -40
  224. package/dist/src/operator/retire.js +5 -6
  225. package/dist/src/operator/revert.js +142 -34
  226. package/dist/src/orchestrator/orchestrator-launch.js +60 -52
  227. package/dist/src/orchestrator/orchestrator-poll.js +320 -0
  228. package/dist/src/orchestrator/orchestrator-scheduling.js +68 -369
  229. package/dist/src/orchestrator/orchestrator.js +128 -369
  230. package/dist/src/orchestrator/retention.js +42 -8
  231. package/dist/src/orchestrator/scheduling-admit.js +116 -0
  232. package/dist/src/orchestrator/scheduling-scope.js +201 -0
  233. package/dist/src/orchestrator/scheduling-skip.js +185 -0
  234. package/dist/src/orchestrator/startup-migration-steps.js +8 -7
  235. package/dist/src/orchestrator/startup-migrations.js +11 -7
  236. package/dist/src/paths.js +116 -49
  237. package/dist/src/pi/command-shape.js +12 -1
  238. package/dist/src/pi/pi-args.js +6 -4
  239. package/dist/src/pi/pi-backend.js +6 -6
  240. package/dist/src/pi/pi-bin.js +54 -63
  241. package/dist/src/pi/pi-listed-models.js +53 -0
  242. package/dist/src/pi/pi-models.js +63 -30
  243. package/dist/src/pi/pi-run-result.js +1 -1
  244. package/dist/src/pi/pi-settings.js +1 -1
  245. package/dist/src/pi/pi-stream.js +6 -6
  246. package/dist/src/pi/pi-watchdogs.js +18 -19
  247. package/dist/src/pi-extension/bounded-output.js +5 -3
  248. package/dist/src/pi-extension/context-budget.js +2 -2
  249. package/dist/src/pi-extension/context-shake.js +1 -1
  250. package/dist/src/pi-extension/context-window.js +0 -1
  251. package/dist/src/pi-extension/full-output.js +3 -10
  252. package/dist/src/pi-extension/strip-thinking.js +0 -1
  253. package/dist/src/pi-extension/trim-system-prompt.js +3 -4
  254. package/dist/src/pi-extension/write-guard.js +37 -0
  255. package/dist/src/process/launch-services.js +1 -2
  256. package/dist/src/process/node-bin.js +16 -0
  257. package/dist/src/process/process-group.js +8 -18
  258. package/dist/src/process/process.js +41 -2
  259. package/dist/src/process/run-marker.js +18 -6
  260. package/dist/src/process/supervisor.js +22 -21
  261. package/dist/src/prompt/dialect.js +17 -2
  262. package/dist/src/prompt/gate-notes.js +203 -0
  263. package/dist/src/prompt/gate-prompts.js +121 -211
  264. package/dist/src/prompt/notes-backlog.js +181 -0
  265. package/dist/src/prompt/principles.js +1 -2
  266. package/dist/src/prompt/prompt-followup.js +19 -14
  267. package/dist/src/prompt/prompt.js +129 -204
  268. package/dist/src/redeploy/redeploy-policy.js +24 -19
  269. package/dist/src/redeploy/redeploy-probes.js +1 -1
  270. package/dist/src/redeploy/redeploy.js +2 -3
  271. package/dist/src/redeploy/redeployer.js +20 -20
  272. package/dist/src/redeploy/self-reload.js +2 -1
  273. package/dist/src/report/report-data.js +161 -77
  274. package/dist/src/report/report-fold.js +129 -52
  275. package/dist/src/report/report-main-red.js +55 -0
  276. package/dist/src/report/report-render.js +133 -64
  277. package/dist/src/report/report-types.js +1 -0
  278. package/dist/src/report/report.js +26 -9
  279. package/dist/src/request-timeouts.js +2 -2
  280. package/dist/src/review/known-flakes.js +100 -1
  281. package/dist/src/review/post-merge-review.js +106 -0
  282. package/dist/src/review/protected-edits.js +4 -5
  283. package/dist/src/review/review-followup.js +8 -8
  284. package/dist/src/review/review-precheck.js +66 -23
  285. package/dist/src/review/review-run.js +395 -0
  286. package/dist/src/review/review-verdict.js +2 -2
  287. package/dist/src/review/review.js +155 -360
  288. package/dist/src/review/secret-leaks.js +36 -16
  289. package/dist/src/review/suite-rerun.js +0 -1
  290. package/dist/src/roles/legacy-role-migration.js +80 -7
  291. package/dist/src/roles/role-catalog.js +69 -12
  292. package/dist/src/roles/role-guidance.js +55 -20
  293. package/dist/src/roles/role-labels.js +1 -2
  294. package/dist/src/roles/role-render.js +67 -50
  295. package/dist/src/roles/role-view.js +59 -47
  296. package/dist/src/roles/roles.js +31 -31
  297. package/dist/src/roles/runner-ids.js +97 -0
  298. package/dist/src/run/acceptance-greps.js +119 -0
  299. package/dist/src/run/feedback-filings.js +51 -0
  300. package/dist/src/{tick → run}/qa-coverage.js +9 -27
  301. package/dist/src/{tick/tick-apply.js → run/run-apply.js} +95 -94
  302. package/dist/src/run/run-detail-data.js +179 -0
  303. package/dist/src/run/run-detail-render.js +98 -0
  304. package/dist/src/run/run-detail.js +168 -0
  305. package/dist/src/{tick/tick-finalize.js → run/run-finalize.js} +72 -60
  306. package/dist/src/{tick/tick-outcome.js → run/run-outcome.js} +6 -7
  307. package/dist/src/{tick/tick-prompt.js → run/run-prompt.js} +108 -73
  308. package/dist/src/{tick/tick-resume.js → run/run-resume.js} +55 -26
  309. package/dist/src/{tick/tick-stage.js → run/run-stage.js} +108 -50
  310. package/dist/src/{tick/tick-timing.js → run/run-timing.js} +43 -41
  311. package/dist/src/{tick/tick-usage.js → run/run-usage.js} +45 -37
  312. package/dist/src/{tick/tick-verdict.js → run/run-verdict.js} +91 -56
  313. package/dist/src/run/selfcheck-digest.js +40 -0
  314. package/dist/src/run/stage-backlog-checks.js +249 -0
  315. package/dist/src/run/stage-check.js +172 -0
  316. package/dist/src/run/stage-path-checks.js +730 -0
  317. package/dist/src/{loop → runner}/leftover.js +80 -25
  318. package/dist/src/{loop → runner}/model-fallback.js +12 -12
  319. package/dist/src/runner/revision.js +202 -0
  320. package/dist/src/{loop/loop-fallback.js → runner/runner-fallback.js} +8 -8
  321. package/dist/src/runner/runner-outcome.js +107 -0
  322. package/dist/src/{loop/loop-pi.js → runner/runner-pi.js} +140 -131
  323. package/dist/src/{loop/loop-recovery.js → runner/runner-recovery.js} +21 -15
  324. package/dist/src/{loop/loop-tick.js → runner/runner-run.js} +218 -240
  325. package/dist/src/{loop/loop-state.js → runner/runner-state-load.js} +61 -114
  326. package/dist/src/runner/runner-state.js +102 -0
  327. package/dist/src/{loop/loop.js → runner/runner.js} +123 -120
  328. package/dist/src/scheduling/backoff.js +38 -38
  329. package/dist/src/scheduling/claims.js +35 -22
  330. package/dist/src/scheduling/once-round.js +22 -22
  331. package/dist/src/scheduling/quiet-hours.js +5 -6
  332. package/dist/src/scheduling/scheduling.js +74 -64
  333. package/dist/src/scheduling/work-merged-cache.js +2 -2
  334. package/dist/src/status/status-budget.js +55 -47
  335. package/dist/src/status/status-data.js +43 -16
  336. package/dist/src/status/status-inbox.js +2 -2
  337. package/dist/src/status/status-install.js +0 -1
  338. package/dist/src/status/status-polls.js +28 -28
  339. package/dist/src/status/status-roles.js +39 -13
  340. package/dist/src/team/error-storm.js +8 -8
  341. package/dist/src/team/failure-spread.js +2 -2
  342. package/dist/src/team/orchestrator-info.js +15 -9
  343. package/dist/src/team/reclaim.js +5 -6
  344. package/dist/src/team/team-hold.js +7 -7
  345. package/dist/src/team/team-polls.js +91 -50
  346. package/dist/src/team/team-state.js +8 -2
  347. package/dist/src/text/datetime.js +63 -17
  348. package/dist/src/text/format.js +48 -11
  349. package/dist/src/text/markdown.js +8 -5
  350. package/dist/src/text/phrases.js +57 -23
  351. package/dist/src/text/suggest.js +1 -1
  352. package/dist/src/text/text.js +67 -13
  353. package/dist/src/ui/badges.js +65 -37
  354. package/dist/src/ui/gui/gui-client-backlog.js +292 -0
  355. package/dist/src/ui/gui/gui-client-boot.js +32 -26
  356. package/dist/src/ui/gui/gui-client-composer.js +8 -9
  357. package/dist/src/ui/gui/gui-client-drawer-config.js +212 -0
  358. package/dist/src/ui/gui/gui-client-drawer.js +126 -285
  359. package/dist/src/ui/gui/gui-client-feed.js +271 -0
  360. package/dist/src/ui/gui/gui-client-history.js +434 -67
  361. package/dist/src/ui/gui/gui-client-labels.js +1 -2
  362. package/dist/src/ui/gui/gui-client-markdown.js +1 -2
  363. package/dist/src/ui/gui/gui-client-model.js +27 -36
  364. package/dist/src/ui/gui/gui-client-operator.js +55 -51
  365. package/dist/src/ui/gui/gui-client-pending.js +227 -23
  366. package/dist/src/ui/gui/gui-client-report-chart.js +464 -0
  367. package/dist/src/ui/gui/gui-client-report.js +87 -427
  368. package/dist/src/ui/gui/{gui-client-loops.js → gui-client-roles.js} +43 -44
  369. package/dist/src/ui/gui/gui-client-settings.js +56 -4
  370. package/dist/src/ui/gui/gui-client-team.js +25 -465
  371. package/dist/src/ui/gui/gui-client.js +27 -25
  372. package/dist/src/ui/gui/gui-icons.js +0 -2
  373. package/dist/src/ui/gui/gui-page.js +9 -7
  374. package/dist/src/ui/gui/gui-styles.js +34 -34
  375. package/dist/src/ui/progress-data.js +9 -11
  376. package/dist/src/ui/{tick-progress-model.js → run-progress-model.js} +31 -31
  377. package/dist/src/ui/status-model.js +133 -125
  378. package/dist/src/ui/status-payload.js +136 -49
  379. package/dist/src/ui/status-render.js +101 -82
  380. package/dist/src/ui/team-alerts.js +248 -57
  381. package/dist/src/ui/tone.js +5 -6
  382. package/dist/src/ui/transcript-run.js +58 -0
  383. package/dist/src/ui/transcript-tail.js +28 -20
  384. package/dist/src/ui/transcript.js +63 -23
  385. package/dist/src/ui/tui/tui-app.js +0 -1
  386. package/dist/src/ui/tui/tui-backlog.js +51 -14
  387. package/dist/src/ui/tui/tui-editor-answer.js +27 -31
  388. package/dist/src/ui/tui/tui-editor-attach.js +3 -5
  389. package/dist/src/ui/tui/tui-editor-backends.js +132 -0
  390. package/dist/src/ui/tui/tui-editor-brief.js +10 -12
  391. package/dist/src/ui/tui/tui-editor-budget.js +35 -31
  392. package/dist/src/ui/tui/tui-editor-claude-reserve.js +24 -0
  393. package/dist/src/ui/tui/tui-editor-concurrency.js +24 -0
  394. package/dist/src/ui/tui/tui-editor-config.js +86 -0
  395. package/dist/src/ui/tui/tui-editor-entry.js +36 -47
  396. package/dist/src/ui/tui/tui-editor-fallback.js +31 -0
  397. package/dist/src/ui/tui/tui-editor-instances.js +37 -0
  398. package/dist/src/ui/tui/tui-editor-instructions.js +136 -0
  399. package/dist/src/ui/tui/tui-editor-interval.js +11 -9
  400. package/dist/src/ui/tui/tui-editor-model.js +29 -0
  401. package/dist/src/ui/tui/tui-editor-notes.js +3 -5
  402. package/dist/src/ui/tui/tui-editor-notify.js +25 -0
  403. package/dist/src/ui/tui/tui-editor-pause.js +48 -59
  404. package/dist/src/ui/tui/tui-editor-prompt.js +11 -16
  405. package/dist/src/ui/tui/tui-editor-provider-caps.js +27 -0
  406. package/dist/src/ui/tui/tui-editor-queued.js +5 -9
  407. package/dist/src/ui/tui/tui-editor-quiet.js +99 -35
  408. package/dist/src/ui/tui/tui-editor-retire.js +4 -6
  409. package/dist/src/ui/tui/tui-editor-role-key.js +76 -0
  410. package/dist/src/ui/tui/tui-editor-role-model.js +28 -0
  411. package/dist/src/ui/tui/tui-editor-search.js +45 -33
  412. package/dist/src/ui/tui/tui-editor-session.js +60 -34
  413. package/dist/src/ui/tui/tui-editor-slots.js +23 -0
  414. package/dist/src/ui/tui/tui-editors.js +35 -2
  415. package/dist/src/ui/tui/tui-frame.js +56 -11
  416. package/dist/src/ui/tui/tui-history.js +8 -9
  417. package/dist/src/ui/tui/tui-input.js +13 -11
  418. package/dist/src/ui/tui/tui-keymap.js +0 -1
  419. package/dist/src/ui/tui/tui-keys.js +24 -9
  420. package/dist/src/ui/tui/tui-pane-activity.js +14 -11
  421. package/dist/src/ui/tui/tui-pane-backlog.js +171 -126
  422. package/dist/src/ui/tui/tui-pane-brief.js +0 -1
  423. package/dist/src/ui/tui/tui-pane-ctx.js +2 -2
  424. package/dist/src/ui/tui/tui-pane-health.js +58 -8
  425. package/dist/src/ui/tui/tui-pane-history.js +402 -82
  426. package/dist/src/ui/tui/tui-pane-pending.js +308 -13
  427. package/dist/src/ui/tui/tui-pane-queued.js +71 -55
  428. package/dist/src/ui/tui/tui-pane-report.js +46 -14
  429. package/dist/src/ui/tui/tui-pane-session.js +25 -6
  430. package/dist/src/ui/tui/tui-pane-transcript.js +111 -37
  431. package/dist/src/ui/tui/tui-pane.js +80 -23
  432. package/dist/src/ui/tui/tui-panes.js +100 -30
  433. package/dist/src/ui/tui/tui.js +14 -14
  434. package/dist/src/verdict/fix-claim.js +82 -32
  435. package/dist/src/verdict/no-change.js +4 -4
  436. package/dist/src/verdict/refusal.js +40 -16
  437. package/dist/src/verdict/reply-contract.js +42 -31
  438. package/dist/src/version.js +0 -1
  439. package/package.json +2 -1
  440. package/dist/src/loop/revision.js +0 -70
  441. package/dist/src/roles/loop-ids.js +0 -77
  442. package/dist/src/tick/stage-check.js +0 -419
  443. package/dist/src/tick/telemetry-digest.js +0 -25
  444. package/dist/src/tick/tick-detail-data.js +0 -108
  445. package/dist/src/tick/tick-detail.js +0 -163
  446. package/dist/src/ui/gui/gui-client-sound.js +0 -53
@@ -1,90 +1,90 @@
1
- import { hasOutstandingWork } from "../loop/loop-state.js";
1
+ import { hasOutstandingWork } from "../runner/runner-state.js";
2
2
  import { DIRECTOR_ROLE, OBSERVER_ROLES } from "../roles/roles.js";
3
- import { baseRoleOf } from "../roles/loop-ids.js";
3
+ import { baseRoleOf } from "../roles/runner-ids.js";
4
4
  import { ERROR_BACKOFF, pushYieldOutcome, scheduleAtMinInterval, scheduleBackoff, } from "../scheduling/backoff.js";
5
5
  import { firstReason } from "../text/phrases.js";
6
- /** The state machine that applies a finished tick or merge to the loop's state: the
7
- * outcome application (applyTickOutcome — which outcomes count which streaks, when a
6
+ /** The state machine that applies a finished run or merge to the role's state: the
7
+ * outcome application (applyRunOutcome — which outcomes count which streaks, when a
8
8
  * cut-off or quiet-killed session resumes and when it is abandoned), its merge sibling
9
9
  * (applyMergeOutcome), the error-streak thresholds, the resume limits, and the
10
- * review-verdict record the next tick's prompt reads. Split out of tick-outcome.ts — which
11
- * keeps the TickResult/TickOutcome vocabulary the dashboards and call sites share — because
10
+ * review-verdict record the next run's prompt reads. Split out of run-outcome.ts — which
11
+ * keeps the RunResult/RunOutcome vocabulary the dashboards and call sites share — because
12
12
  * "what an outcome is" and "what applying it records" are different concerns that happen to
13
- * touch the same LoopState object. The loop's CLOCK side of the same policy — the wake
13
+ * touch the same RunnerState object. The role's CLOCK side of the same policy — the wake
14
14
  * semantics, the backoff ladders, the yield-scaled clock — lives next door in backoff.ts,
15
15
  * which this module drives. No I/O here: every function mutates the caller's state in place
16
- * (the caller's object is authoritative across an in-flight tick and saves it itself), so
16
+ * (the caller's object is authoritative across an in-flight run and saves it itself), so
17
17
  * the policy is unit-testable without touching a disk. */
18
18
  export function recordReview(s, verdict, reasons, head) {
19
19
  s.lastReview = { verdict, reasons, ...(head === undefined ? {} : { head }), at: Date.now() };
20
20
  }
21
21
  /** Drop a stale review rejection once the change it objected to is superseded (BUGS.md
22
22
  * 2026-10-07): the review-exempt and refusal-note merges record no new verdict, so a reject
23
- * would otherwise ride every later tick prompt as if it were the role's last review outcome.
23
+ * would otherwise ride every later run prompt as if it were the role's last review outcome.
24
24
  * Called from the points a change merges (`applyMergeOutcome`'s changed branch and
25
25
  * `handleRefusal`'s note merge), never while a revision is still owed: a merge that leaves
26
- * `state.revision` set — a per-role user-request tick did not apply the rejected change — did
27
- * not resolve it, and its next revision tick still needs the objections (loop-tick.ts's revision
26
+ * `state.revision` set — a per-role user-request run did not apply the rejected change — did
27
+ * not resolve it, and its next revision run still needs the objections (runner-run.ts's revision
28
28
  * note). A model-reviewed merge already overwrote `lastReview` with its approve; this only
29
29
  * clears a standing `reject`. */
30
30
  export function clearSupersededRejection(s) {
31
- if (s.revision === undefined && s.lastReview?.verdict === "reject")
31
+ if (s.revision === undefined && (s.lastReview?.verdict === "reject" || s.lastReview?.verdict === "reverted"))
32
32
  s.lastReview = undefined;
33
33
  }
34
- /** Consecutive failed ticks after which the loop raises a harness warning and its state
35
- * cell reads "failing" (BUGS.md 2026-09-15: every loop failing identically looked like a
34
+ /** Consecutive failed runs after which the role raises a harness warning and its state
35
+ * cell reads "failing" (BUGS.md 2026-09-15: every role failing identically looked like a
36
36
  * quiet team). Small on purpose — at 3 the error ladder has already doubled twice and
37
37
  * the failure is clearly not transient. */
38
38
  export const ERROR_STREAK_WARN = 3;
39
- /** Consecutive failed ticks after which the error-streak circuit breaker (src/gates/streak-gate.ts)
39
+ /** Consecutive failed runs after which the error-streak circuit breaker (src/gates/streak-gate.ts)
40
40
  * auto-pauses the role through the per-role pause marker — the same act-on-it escalation the
41
41
  * budget gate and the pause gates perform, applied to a role failing on its own cause. Ten,
42
- * not the warn bar: at 3 the failure is diagnosed but possibly transient, and by tick 4 the
42
+ * not the warn bar: at 3 the failure is diagnosed but possibly transient, and by run 4 the
43
43
  * error ladder has already doubled to its 10-minute rung, so 10 consecutive failures is 45+
44
44
  * minutes of a role failing on the slowest rung — long enough to ride out genuine transience,
45
45
  * short enough to stop the burn well before an all-day failure. One sensible default, no knob. */
46
46
  export const ERROR_STREAK_BREAKER = 10;
47
- /** Resumes granted to one context-ceiling cut-off streak before the loop stops resuming the
48
- * task and falls back to a fresh tick: a task that outruns the ceiling on every attempt (even
47
+ /** Resumes granted to one context-ceiling cut-off streak before the role stops resuming the
48
+ * task and falls back to a fresh run: a task that outruns the ceiling on every attempt (even
49
49
  * from a freshly compacted context) is too big to converge, and each cycle costs an hour-plus
50
- * of model time on local hardware. The streak itself keeps counting (LoopState.cutOffStreak). */
50
+ * of model time on local hardware. The streak itself keeps counting (RunnerState.cutOffStreak). */
51
51
  const CUT_OFF_RESUME_LIMIT = 3;
52
- /** Resumes granted to one quiet-kill streak before the loop abandons the starved pi session
53
- * and takes a fresh tick on the idle ladder. A session the backend defers past the quiet
52
+ /** Resumes granted to one quiet-kill streak before the role abandons the starved pi session
53
+ * and takes a fresh run on the idle ladder. A session the backend defers past the quiet
54
54
  * watchdog every attempt would otherwise re-send the same input immediately and forever,
55
55
  * burning an hour of slot time per retry with no output (BUGS.md 2026-09-18: 41 quiet kills
56
56
  * consumed 44% of the team over two days). Mirrors CUT_OFF_RESUME_LIMIT; the streak itself
57
- * keeps counting (LoopState.quietKillStreak) so one warning per episode can be raised. */
57
+ * keeps counting (RunnerState.quietKillStreak) so one warning per episode can be raised. */
58
58
  export const QUIET_KILL_RESUME_LIMIT = 3;
59
- /** Record a finished tick on the loop's state and schedule its next run from the outcome.
60
- * Split out of LoopRunner.tick() (loop.ts) so the scheduling policy — which outcomes retry
59
+ /** Record a finished run on the role's state and schedule its next run from the outcome.
60
+ * Split out of RoleRunner.run() (runner.ts) so the scheduling policy — which outcomes retry
61
61
  * promptly, which back off and on which ladder, how cut-off resumes are bounded — sits with
62
- * the other scheduling helpers here instead of inline in the tick lifecycle. Mutates `s` in place:
63
- * the caller's state object is authoritative across an in-flight tick (see resetCounters).
62
+ * the other scheduling helpers here instead of inline in the run lifecycle. Mutates `s` in place:
63
+ * the caller's state object is authoritative across an in-flight run (see resetCounters).
64
64
  * `cfg` is the role-resolved config (configForRole): its minRunIntervalSeconds carries any
65
65
  * per-role slow clock, and idleBackoff passes through it unchanged from the top level. */
66
- export function applyTickOutcome(s, cfg, role, outcome) {
66
+ export function applyRunOutcome(s, cfg, role, outcome) {
67
67
  s.running = false;
68
68
  s.parkedSince = undefined;
69
69
  s.parkedOn = undefined;
70
- // The cut-off streak counts EVERY consecutive tick truncated at the context ceiling, past the
71
- // resume limit too: the next fresh tick's prompt names how many attempts the window has eaten
70
+ // The cut-off streak counts EVERY consecutive run truncated at the context ceiling, past the
71
+ // resume limit too: the next fresh run's prompt names how many attempts the window has eaten
72
72
  // (buildCutOffNote), so the count must not freeze at the limit. Any other outcome resets it.
73
73
  s.cutOffStreak = outcome.cutOff ? (s.cutOffStreak ?? 0) + 1 : 0;
74
- // The error streak counts consecutive failed ticks; any other result resets it
75
- // (BUGS.md 2026-09-15: 44 identical failures raised no alarm). A tick whose leftover
76
- // recovery re-queued a pin its last merge failed counts too, even though the tick
74
+ // The error streak counts consecutive failed runs; any other result resets it
75
+ // (BUGS.md 2026-09-15: 44 identical failures raised no alarm). A run whose leftover
76
+ // recovery re-queued a pin its last merge failed counts too, even though the run
77
77
  // itself ends `queued` (outcome.recoveryFailure): a dead reviewer backend would otherwise
78
- // reset the streak every tick and never raise the alarm (BUGS.md 2026-09-21).
79
- // tick-finalize.ts emits one warning when the streak crosses ERROR_STREAK_WARN — once per
78
+ // reset the streak every run and never raise the alarm (BUGS.md 2026-09-21).
79
+ // run-finalize.ts emits one warning when the streak crosses ERROR_STREAK_WARN — once per
80
80
  // episode, since the reset re-arms it — and the dashboards read "failing" from the same field.
81
- // A plain `queued` tick is not yet a verdict about anything: it committed and enqueued, and
81
+ // A plain `queued` run is not yet a verdict about anything: it committed and enqueued, and
82
82
  // its MERGE resolves the streak — applyMergeOutcome resets it when the change merges and
83
83
  // counts a review rejection into it (BUGS.md 2026-09-30: review-rejected authoring, the
84
- // digest's #1 loss cause, fell straight through — the tick's `queued` reset and the merge's
84
+ // digest's #1 loss cause, fell straight through — the run's `queued` reset and the merge's
85
85
  // `rejected` increment met nowhere, so the streak read 0 through the whole episode and the
86
86
  // re-author ran at min interval, warning-free and pause-proof). Resetting here would pin a
87
- // rejection streak at 1 forever, since every authoring tick in a rejection episode ends
87
+ // rejection streak at 1 forever, since every authoring run in a rejection episode ends
88
88
  // `queued` before its merge is decided.
89
89
  const failed = outcome.result === "error" || outcome.recoveryFailure !== undefined;
90
90
  if (failed)
@@ -92,24 +92,24 @@ export function applyTickOutcome(s, cfg, role, outcome) {
92
92
  else if (outcome.result !== "queued")
93
93
  s.consecutiveErrors = 0;
94
94
  // The quiet-kill streak counts consecutive watchdog kills; any other result resets it.
95
- // tick-finalize.ts warns once when it crosses QUIET_KILL_RESUME_LIMIT, and the branch below uses
95
+ // run-finalize.ts warns once when it crosses QUIET_KILL_RESUME_LIMIT, and the branch below uses
96
96
  // it to bound how many times a starved session is resumed (BUGS.md 2026-09-18).
97
97
  s.quietKillStreak = outcome.result === "quiet_killed" ? (s.quietKillStreak ?? 0) + 1 : 0;
98
- // The no-change streak counts consecutive completed ticks that ended `no_change` (the
99
- // resting state cell's ` · no change ×N` suffix — status-model.ts loopPhase). Any other
100
- // completed result resets it, so a loop that merges between no-ops never shows a stale
101
- // streak. Every completed result reaches this block (tick-finalize.ts calls
102
- // applyTickOutcome for every outcome), so `changed`/`queued`/`error`/`aborted`/
103
- // `quiet_killed`/`user_aborted` all reset it and only a `no_change` tick grows it.
98
+ // The no-change streak counts consecutive completed runs that ended `no_change` (the
99
+ // resting state cell's ` · no change ×N` suffix — status-model.ts rolePhase). Any other
100
+ // completed result resets it, so a role that merges between no-ops never shows a stale
101
+ // streak. Every completed result reaches this block (run-finalize.ts calls
102
+ // applyRunOutcome for every outcome), so `changed`/`queued`/`error`/`aborted`/
103
+ // `quiet_killed`/`user_aborted` all reset it and only a `no_change` run grows it.
104
104
  // Observational only — never warns, unlike the error/quiet-kill streaks: a legitimately
105
- // idle maintenance loop with an empty backlog can hold a long streak and that is expected.
105
+ // idle maintenance role with an empty backlog can hold a long streak and that is expected.
106
106
  s.noChangeStreak = outcome.result === "no_change" ? (s.noChangeStreak ?? 0) + 1 : 0;
107
107
  // The yield ring records the result beside the streaks: a merge or a counted empty
108
- // stretches the role's min-tick gap (yieldMultiplier, read by isEligible), an error-class
108
+ // stretches the role's min-run gap (yieldMultiplier, read by isEligible), an error-class
109
109
  // result is skipped entirely — no evidence either way (yield-scaled clocks, PLANS.md).
110
110
  pushYieldOutcome(s, outcome.result);
111
111
  // The review gate persists phase="review" around its run so a dashboard mid-review shows
112
- // "reviewing". A completed tick clears it so the label never lingers — except an aborted
112
+ // "reviewing". A completed run clears it so the label never lingers — except an aborted
113
113
  // one: there the interruption hit mid-review, and the next launch must recover (and
114
114
  // re-review) the committed work fresh instead of resuming an author session whose task is
115
115
  // already committed.
@@ -117,17 +117,17 @@ export function applyTickOutcome(s, cfg, role, outcome) {
117
117
  s.phase = undefined;
118
118
  s.lastRunEndedAt = Date.now();
119
119
  // `lastResult`/`lastSummary` are the last COMPLETED result, the pair the dashboards' "last
120
- // result" cell renders, and they must describe ONE tick: a completed outcome without a
120
+ // result" cell renders, and they must describe ONE run: a completed outcome without a
121
121
  // summary CLEARS `lastSummary`, so a summary-less result never renders beside another
122
- // tick's work description (BUGS.md 2026-09-30: a no_change tick read "No change — Implement
122
+ // run's work description (BUGS.md 2026-09-30: a no_change run read "No change — Implement
123
123
  // the … plan" beside work that had merged, because the prior summary was retained).
124
- // A `queued` tick is not a completed result: its change is committed but in flight —
124
+ // A `queued` run is not a completed result: its change is committed but in flight —
125
125
  // the state column shows that (`merge <elapsed>`, the merge-queue badge) — so the pair
126
126
  // keeps the prior outcome WITH its own summary while the change waits (BUGS.md 2026-09-23),
127
- // and the tick's summary is stashed under the pinned sha for applyMergeOutcome to pair with
127
+ // and the run's summary is stashed under the pinned sha for applyMergeOutcome to pair with
128
128
  // the merge's result. Every other outcome is completed and clears the stash: a role with a
129
- // queued or in-flight merge never ticks (the orchestrator's interlock), so a stash that
130
- // survives to a later tick names a change that is no longer waiting.
129
+ // queued or in-flight merge never runs (the orchestrator's interlock), so a stash that
130
+ // survives to a later run names a change that is no longer waiting.
131
131
  if (outcome.result === "queued") {
132
132
  s.queuedSummary =
133
133
  outcome.commit && outcome.summary ? { sha: outcome.commit, summary: outcome.summary } : undefined;
@@ -135,10 +135,10 @@ export function applyTickOutcome(s, cfg, role, outcome) {
135
135
  else {
136
136
  s.queuedSummary = undefined;
137
137
  s.lastResult = outcome.result;
138
- s.lastSummary = outcome.summary; // a summary-less outcome wipes the prior tick's text
138
+ s.lastSummary = outcome.summary; // a summary-less outcome wipes the prior run's text
139
139
  }
140
140
  if (outcome.result === "changed" || outcome.result === "queued") {
141
- // "queued" schedules exactly like "changed" — the tick committed and enqueued — but the
141
+ // "queued" schedules exactly like "changed" — the run committed and enqueued — but the
142
142
  // commit count waits for the merge: `commits` keeps meaning "merged to main", and
143
143
  // applyMergeOutcome increments it when the change actually merges. The phase-clear above
144
144
  // (`result !== "aborted"`) covers both.
@@ -147,7 +147,7 @@ export function applyTickOutcome(s, cfg, role, outcome) {
147
147
  // A merged change's patch-id approval has done its job: the same patch authored again
148
148
  // later (after a revert, say) is a new change and gets its own review.
149
149
  if (outcome.result === "changed")
150
- s.lastApprovedPatchId = undefined;
150
+ s.approvedPatchIds = undefined;
151
151
  // The role committed new work, so the note about its discarded change has been delivered.
152
152
  s.conflictDiscard = undefined;
153
153
  s.backoffSeconds = 0;
@@ -155,7 +155,7 @@ export function applyTickOutcome(s, cfg, role, outcome) {
155
155
  }
156
156
  else if (outcome.result === "rejected") {
157
157
  // The reviewer objected and the gate already reset the branch: the author should address
158
- // the recorded reasons on its next eligible tick, not sleep through them — schedule like
158
+ // the recorded reasons on its next eligible run, not sleep through them — schedule like
159
159
  // a change without counting a commit (nothing merged).
160
160
  s.backoffSeconds = 0;
161
161
  scheduleAtMinInterval(s, cfg);
@@ -166,8 +166,8 @@ export function applyTickOutcome(s, cfg, role, outcome) {
166
166
  }
167
167
  else if (outcome.result === "aborted") {
168
168
  // Shutdown, not a verdict about the project: resume promptly on restart. The pi
169
- // session and the worktree's uncommitted edits were left in place, so the next tick
170
- // picks up exactly where this one was interrupted (director ticks instead re-queue
169
+ // session and the worktree's uncommitted edits were left in place, so the next run
170
+ // picks up exactly where this one was interrupted (director runs instead re-queue
171
171
  // their user prompt, which runs fresh).
172
172
  if (role !== DIRECTOR_ROLE) {
173
173
  s.resumePending = true;
@@ -182,10 +182,10 @@ export function applyTickOutcome(s, cfg, role, outcome) {
182
182
  // A hung tool call, not an idle verdict or a shutdown: the kill left the pi session and
183
183
  // the worktree's uncommitted edits intact, so resume them promptly like an interruption.
184
184
  // The cause is named in state so the bridge prompt tells the resumed session its run died
185
- // on a stalled tool call (director ticks never resume — their prompt was re-queued fresh).
185
+ // on a stalled tool call (director runs never resume — their prompt was re-queued fresh).
186
186
  // Bounded like a cut-off streak: past QUIET_KILL_RESUME_LIMIT the session is
187
187
  // abandoned — the backend has refused to schedule it every attempt, so re-sending it only
188
- // starves the slot again — and the loop takes a fresh tick on the idle ladder instead
188
+ // starves the slot again — and the role takes a fresh run on the idle ladder instead
189
189
  // (BUGS.md 2026-09-18).
190
190
  if (role !== DIRECTOR_ROLE && s.quietKillStreak <= QUIET_KILL_RESUME_LIMIT) {
191
191
  s.resumePending = true;
@@ -204,18 +204,18 @@ export function applyTickOutcome(s, cfg, role, outcome) {
204
204
  else if (outcome.result === "user_aborted") {
205
205
  // A deliberate stop, not an interruption: the worktree was already reset to main and a
206
206
  // director prompt deliberately dropped, so there is nothing to resume — schedule like an
207
- // unproductive tick (idle backoff) instead of resuming promptly. phase is cleared by the
207
+ // unproductive run (idle backoff) instead of resuming promptly. phase is cleared by the
208
208
  // `result !== "aborted"` check above.
209
209
  scheduleBackoff(s, cfg.idleBackoff);
210
210
  }
211
211
  else if (outcome.result === "error") {
212
- // A failed tick, not an idle verdict: it often never reached the model, so it retries on
212
+ // A failed run, not an idle verdict: it often never reached the model, so it retries on
213
213
  // the short error ladder (capped in minutes) instead of the idle ladder, whose cap prices
214
214
  // hour-long model runs. backoffSeconds is shared: each ladder advances from the current
215
- // value, so an error streak capped at the error ceiling never sleeps LESS than the loop
215
+ // value, so an error streak capped at the error ceiling never sleeps LESS than the role
216
216
  // already was sleeping, and the idle ladder picks up from there if the failures stop.
217
217
  // A subscription claude usage-window rejection is a transient hold, not a failure of the
218
- // session: the team hold keeps ticks from starting until `resetsAt` (plans/agent-backends.md
218
+ // session: the team hold keeps runs from starting until `resetsAt` (plans/agent-backends.md
219
219
  // §8, part 6c), and the kept session and worktree edits resume when it lifts (part 6e).
220
220
  // The named cause is what the bridge prompt reads, so it does not tell the session the
221
221
  // harness merely restarted.
@@ -230,8 +230,8 @@ export function applyTickOutcome(s, cfg, role, outcome) {
230
230
  // session pi just compacted, so resume it promptly instead of idle-backing-off.
231
231
  // Each resume restarts from the compacted (small) context, so repeated cut-offs on
232
232
  // one task still converge — but a task that outruns the ceiling every single time
233
- // would cycle forever, so after CUT_OFF_RESUME_LIMIT resumes the loop gives up on it
234
- // and falls back to a fresh tick with normal backoff (its prompt carrying the streak).
233
+ // would cycle forever, so after CUT_OFF_RESUME_LIMIT resumes the role gives up on it
234
+ // and falls back to a fresh run with normal backoff (its prompt carrying the streak).
235
235
  s.resumePending = true;
236
236
  scheduleAtMinInterval(s, cfg);
237
237
  }
@@ -248,12 +248,12 @@ export function applyTickOutcome(s, cfg, role, outcome) {
248
248
  scheduleBackoff(s, cfg.idleBackoff);
249
249
  }
250
250
  // A hand-back's marker-bearing edits ARE the resolution its author owes, so the record lives
251
- // only while that resolution is still in play: a `queued` tick committed it, a pending
251
+ // only while that resolution is still in play: a `queued` run committed it, a pending
252
252
  // `revision` still owes it, and a resumable session still holds the edits. Every other
253
- // outcome abandons them (the next fresh tick resets the worktree to main), so the hand-back
253
+ // outcome abandons them (the next fresh run resets the worktree to main), so the hand-back
254
254
  // is spent: clear the record, or it would make a later change's cap conflict discard the
255
255
  // pin instead of handing it back (PLANS.md "Robust conflict landing, part 2/2"). `changed`
256
- // clears too — the resolved change merged in-tick, so its life is over. This runs after the
256
+ // clears too — the resolved change merged in-run, so its life is over. This runs after the
257
257
  // resume branches above have set `resumePending`.
258
258
  if (s.conflictHandback &&
259
259
  outcome.result !== "queued" &&
@@ -261,25 +261,25 @@ export function applyTickOutcome(s, cfg, role, outcome) {
261
261
  s.conflictHandback = undefined;
262
262
  }
263
263
  }
264
- /** Record a completed MERGE on the authoring loop's state (plans/merge-queue.md 3/5):
264
+ /** Record a completed MERGE on the authoring role's state (plans/merge-queue.md 3/5):
265
265
  * the orchestrator calls this on the state object the merge ran against — the runner's live
266
266
  * copy when one exists, a disk load otherwise — then saves it, the same in-place discipline
267
- * applyTickOutcome has (the caller's state object is authoritative; a role with a queued or
268
- * in-flight merge never ticks, so no other writer holds it meanwhile). Sets `lastResult`
267
+ * applyRunOutcome has (the caller's state object is authoritative; a role with a queued or
268
+ * in-flight merge never runs, so no other writer holds it meanwhile). Sets `lastResult`
269
269
  * to the merger's outcome, increments `commits` only on a success (the "merged to main"
270
- * counter applyTickOutcome's "queued" branch left to the merge), and clears `phase` — the
270
+ * counter applyRunOutcome's "queued" branch left to the merge), and clears `phase` — the
271
271
  * gate persisted `phase = "review"` on this same state object during the run, exactly as it
272
- * did inside a tick, so the label must not linger past the merge (mirroring
273
- * applyTickOutcome's rule: every outcome except "aborted" clears it — an aborted merge
272
+ * did inside a run, so the label must not linger past the merge (mirroring
273
+ * applyRunOutcome's rule: every outcome except "aborted" clears it — an aborted merge
274
274
  * keeps it, because the interruption hit mid-review and the next launch must recover and
275
275
  * re-review the pinned work). `lastSummary` becomes the summary of the change this merge
276
276
  * resolved — `change` is its merge-queue entry — so the merge's result, success or failure,
277
- * reads beside the work it names (BUGS.md 2026-09-23: the queued tick held its summary back
278
- * rather than pair it with the prior result). The tick's stashed `queuedSummary` wins when it
279
- * names this sha: it is the text the tick reported, high-friction annotation included. The
277
+ * reads beside the work it names (BUGS.md 2026-09-23: the queued run held its summary back
278
+ * rather than pair it with the prior result). The run's stashed `queuedSummary` wins when it
279
+ * names this sha: it is the text the run reported, high-friction annotation included. The
280
280
  * entry's own summary (the commit subject) covers a stash that is missing or names another
281
- * change — a crash between enqueue and the tick's state save, or a merge that finished before
282
- * its tick's outcome was applied. Either way the stash is consumed. The failure detail rides
281
+ * change — a crash between enqueue and the run's state save, or a merge that finished before
282
+ * its run's outcome was applied. Either way the stash is consumed. The failure detail rides
283
283
  * in `lastReview` and the merge_done/merge_failed events. */
284
284
  export function applyMergeOutcome(s, result, change) {
285
285
  s.lastResult = result;
@@ -288,18 +288,18 @@ export function applyMergeOutcome(s, result, change) {
288
288
  if (result === "changed") {
289
289
  s.commits += 1;
290
290
  // The last-merged timestamp: set only on a successful merge, so the rendered age means
291
- // "time since the loop last actually merged to main" — a rejected/merge_conflict/aborted
292
- // merge, like a no_change tick, leaves the prior value standing (PLANS.md "Each loop's
291
+ // "time since the role last actually merged to main" — a rejected/merge_conflict/aborted
292
+ // merge, like a no_change run, leaves the prior value standing (PLANS.md "Each loop's
293
293
  // last-landed age").
294
294
  s.lastMergedAt = Date.now();
295
- s.lastApprovedPatchId = undefined; // see applyTickOutcome
295
+ s.approvedPatchIds = undefined; // see applyRunOutcome
296
296
  // A merge supersedes a stale rejection: a model-reviewed merge has already overwritten
297
297
  // lastReview with its approve, but a review-exempt (or review-disabled) merge records no
298
- // verdict, so a stale reject would otherwise ride every later tick prompt (BUGS.md
298
+ // verdict, so a stale reject would otherwise ride every later run prompt (BUGS.md
299
299
  // 2026-10-07). Cleared only with no revision pending — see clearSupersededRejection.
300
300
  clearSupersededRejection(s);
301
- // A merged change resets the error streak exactly as an error-free tick does (BUGS.md
302
- // 2026-09-30): the queued tick that authored it preserved the streak — a rejection counts
301
+ // A merged change resets the error streak exactly as an error-free run does (BUGS.md
302
+ // 2026-09-30): the queued run that authored it preserved the streak — a rejection counts
303
303
  // into it below — so the merge, the episode's only clean verdict, ends it.
304
304
  s.consecutiveErrors = 0;
305
305
  }
@@ -310,25 +310,26 @@ export function applyMergeOutcome(s, result, change) {
310
310
  // round and clears it when the chain is exhausted (or never sets it for a role that cannot
311
311
  // revise, the director). A rejection that leaves a revision to work on is not a verdict
312
312
  // about the author yet: counting every round of ONE change made an exhausted chain's third
313
- // round cross the warn bar and flash a red "failing tick after tick" alert that needed
313
+ // round cross the warn bar and flash a red "failing run after run" alert that needed
314
314
  // nothing from the operator and was gone before it could be read (0–30 s). Counting only
315
315
  // final rejections makes a streak of 3 mean three changes ended rejected (or errored) —
316
316
  // the non-converging author the 2026-09-30 fix meant to catch — while a chain's rounds
317
- // leave the streak unchanged and keep the fast minimum-interval retry the queued tick
318
- // scheduled. This merge outcome is the accumulation point (the authoring tick ends
319
- // `queued`, which no longer resets the streak, see applyTickOutcome) — the same field the
317
+ // leave the streak unchanged and keep the fast minimum-interval retry the queued run
318
+ // scheduled. This merge outcome is the accumulation point (the authoring run ends
319
+ // `queued`, which no longer resets the streak, see applyRunOutcome) — the same field the
320
320
  // warn, the breaker (src/gates/streak-gate.ts), and the error-storm observation
321
321
  // (src/team/team-polls.ts) already read. No new machinery, no new constants: the warn
322
322
  // bar and the breaker bar are ERROR_STREAK_WARN and ERROR_STREAK_BREAKER themselves.
323
323
  if (s.revision === undefined) {
324
+ s.approvedPatchIds = undefined; // the chain ended: nothing queued is still approved
324
325
  s.consecutiveErrors = (s.consecutiveErrors ?? 0) + 1;
325
- const lastReasons = s.lastReview?.verdict === "reject" ? s.lastReview.reasons : undefined;
326
+ const lastReasons = s.lastReview?.verdict === "reject" || s.lastReview?.verdict === "reverted" ? s.lastReview.reasons : undefined;
326
327
  s.lastError = `review rejected: ${firstReason(lastReasons).slice(0, 200)}`;
327
328
  // Past the warn bar the re-author backs off on the error ladder instead of the minimum
328
- // interval the queued tick scheduled: the fast first retries stay — the rejected branch's
329
+ // interval the queued run scheduled: the fast first retries stay — the rejected branch's
329
330
  // design intent, letting the author address the recorded reasons at once — but a
330
331
  // non-converging author slows down instead of re-authoring at full price all day. The
331
- // rung derives from the streak (not from backoffSeconds, which every queued tick zeroes
332
+ // rung derives from the streak (not from backoffSeconds, which every queued run zeroes
332
333
  // on its way out, pinning a state-derived ladder at its first rung), and never pulls
333
334
  // nextRunAt earlier than the already-scheduled minimum interval.
334
335
  const streak = s.consecutiveErrors;
@@ -0,0 +1,179 @@
1
+ /** Collection half of `tumwater history <role> <n>`: one completed run's full event block,
2
+ * distilled from the event log into a RunDetail payload. The collector-in-core convention
3
+ * beside history-data.ts and src/report/report-data.ts — a pure read over root, so core
4
+ * modules can serve the same payload without reaching into ui/, and the CLI
5
+ * (`run-detail.ts`) and the GUI History drill-down (`src/gui/gui-history-endpoints.ts`) cannot
6
+ * drift on what one run's block contains.
7
+ * Every datum rides the events the harness already writes, so this is a distillation of the
8
+ * existing record, not a new one. The derived shas a run's block names (runCommitSha /
9
+ * runMergedSha) live here beside the payload they describe; the rendering half — the summary
10
+ * header, formatEvent, the stat/patch and transcript text — lives in run-detail-render.ts,
11
+ * and the CLI command in run-detail.ts. */
12
+ import { HISTORY_SCAN_MAX_EVENTS } from "../history/history-data.js";
13
+ import { bucketMergeEvents, resolveQueuedResult } from "../history/history-queued.js";
14
+ import { eventUsage, readEvents, runSpanMs, runStartMap } from "../events/event-read.js";
15
+ import { outcomeText, usageText } from "../events/event-format.js";
16
+ import { baseRoleOf } from "../roles/runner-ids.js";
17
+ /** The commit a run pinned: the `commit` of the first `merge_queued`/`merge_done` event in its
18
+ * block carrying a non-empty one, else null. The one rule both the header's sha and --stat use. */
19
+ export function runCommitSha(d) {
20
+ const queued = d.events.find((e) => (e.type === "merge_queued" || e.type === "merge_done") && typeof e.commit === "string" && e.commit !== "");
21
+ return queued === undefined ? null : queued.commit;
22
+ }
23
+ /** The sha a run's change merged under on main: the `merged` sha when the merge logged one, else
24
+ * the pinned commit — a no-op fast-forward logs no `merged` event, so its pinned commit is what
25
+ * merged. Null when the run pinned no commit. */
26
+ export function runMergedSha(d) {
27
+ return d.mergedSha ?? runCommitSha(d);
28
+ }
29
+ /** The event block of `role`'s run `n`, or null when the scanned window holds no such run.
30
+ * The newest `run_start` the log retains for `${role}#${n}` wins (a counter reset can make an
31
+ * old run number recur; the operator asking by number means the most recent one), and the
32
+ * block closes at the first `run_end` for that run after the start — or, when that end is
33
+ * missing (in flight, or its tail lost to rotation), at the role's next `run_start`, so a
34
+ * rotation-cut block never leaks the following run's events into this one. When even the
35
+ * start is gone but a matching `run_end` survives, the end-alone block still answers with
36
+ * `startTs` null and a null duration (the unpaired rule); nothing at all in the scan is the
37
+ * not-found case the caller renders as a not-found line. */
38
+ export function readRunDetail(root, role, runNumber) {
39
+ // The scan rides history-data.ts's shared one-ask ceiling (HISTORY_SCAN_MAX_EVENTS): one
40
+ // run's block is small, but it can sit arbitrarily far back in a long-lived team's log,
41
+ // and readTailText reads bytes proportional to the limit's line count — so the cap is also
42
+ // the largest byte read one command can cost, and every read-only view scans under the
43
+ // same bound.
44
+ const all = readEvents(root, HISTORY_SCAN_MAX_EVENTS);
45
+ const events = all.filter((e) => e.source === role);
46
+ // Newest run_start for this role+run: the block's lower bound.
47
+ let startIdx = -1;
48
+ for (let i = events.length - 1; i >= 0; i--) {
49
+ const e = events[i];
50
+ if (e.type === "run_start" && e.run === runNumber) {
51
+ startIdx = i;
52
+ break;
53
+ }
54
+ }
55
+ if (startIdx < 0) {
56
+ // The start is gone (rotation) or the run never ran. A surviving run_end for the same
57
+ // number still answers — unpaired, undated at the front — else there is no such run here.
58
+ for (let i = events.length - 1; i >= 0; i--) {
59
+ const e = events[i];
60
+ if (e.type === "run_end" && e.run === runNumber)
61
+ return detailFrom(role, runNumber, all, events, [e], e, null);
62
+ }
63
+ return null;
64
+ }
65
+ const start = events[startIdx];
66
+ // The block's upper bound: the first run_end for this run after the start ends it; a
67
+ // later run_start (this run's end lost to rotation) closes the block exclusive — the
68
+ // events after it belong to the next run, not this one. No end and no next start reads as
69
+ // in flight: everything since the start belongs to the open run.
70
+ let end = null;
71
+ let nextStart = null;
72
+ for (let i = startIdx + 1; i < events.length; i++) {
73
+ const e = events[i];
74
+ if (e.type === "run_end" && e.run === runNumber) {
75
+ end = e;
76
+ break;
77
+ }
78
+ if (e.type === "run_start") {
79
+ nextStart = e;
80
+ break;
81
+ }
82
+ }
83
+ // The block itself: the start event plus everything this role logged up to the bound —
84
+ // inclusive at a paired end, exclusive at a next run's start.
85
+ const block = [];
86
+ for (let i = startIdx; i < events.length; i++) {
87
+ const e = events[i];
88
+ if (end !== null ? e.ts > end.ts : nextStart !== null && e.ts >= nextStart.ts)
89
+ break;
90
+ block.push(e);
91
+ }
92
+ return detailFrom(role, runNumber, all, events, block, end, start);
93
+ }
94
+ /** Fill the payload around a collected block: usage from the run_end via eventUsage/usageText,
95
+ * duration via runSpanMs against the role's own start map (the shared pairing helper, so this
96
+ * view and the history rows cannot drift on what a span is), events oldest-first. */
97
+ function detailFrom(role, runNumber, all, scoped, block, end, start) {
98
+ const usageNums = end === null ? { tokens: 0, costUsd: 0 } : eventUsage(end);
99
+ let result = end === null ? null : outcomeText(end);
100
+ let merge = null;
101
+ if (end !== null && result === "queued") {
102
+ // A fresh claim cursor suits one run: the walk starts at the newest pin at or before this
103
+ // run's end, which is its own pin, since later runs' pins sit after it.
104
+ const { mergeQueuedByRunner, outcomeByRunner } = bucketMergeEvents(scoped);
105
+ const resolved = resolveQueuedResult(end, mergeQueuedByRunner, outcomeByRunner, new Map(), runStartMap(scoped), null);
106
+ if (resolved !== null) {
107
+ result = resolved.result;
108
+ merge = resolved.outcome;
109
+ }
110
+ }
111
+ const detail = {
112
+ role,
113
+ run: runNumber,
114
+ startTs: start === null ? null : start.ts,
115
+ model: typeof start?.model === "string" && start.model.length > 0 ? start.model : null,
116
+ endTs: end === null ? null : end.ts,
117
+ durationMs: end === null ? null : runSpanMs(end, runStartMap(scoped)),
118
+ result,
119
+ tokens: usageNums.tokens,
120
+ costUsd: usageNums.costUsd,
121
+ usage: end === null ? "" : usageText(end),
122
+ events: block,
123
+ merge,
124
+ mergedSha: mergedShaOf(result, merge, scoped, block),
125
+ reverted: null,
126
+ };
127
+ detail.reverted = revertedOf(detail, all);
128
+ return detail;
129
+ }
130
+ /** The revert of a run's landed change, matched from the unfiltered event list (the revert events
131
+ * are logged under `tumwater`, not the run's role): the newest `main_revert` or `operator_revert`
132
+ * whose `runner` is this role (an instance run's base role — it commits `tumwater(feature): …`)
133
+ * and whose `commit` is the run's landed (`mergedSha`) or pinned
134
+ * (`runCommitSha`) sha — the latter catching a no-op fast-forward that logs no `merged` event.
135
+ * `kind` names which sort of revert it is; `revert` names the inverse commit (empty when the
136
+ * source logged none) and `failingTests` the tests an automatic `main_revert` named (empty when
137
+ * absent); null when nothing matches. */
138
+ function revertedOf(d, all) {
139
+ const targetSha = d.mergedSha ?? runCommitSha(d);
140
+ for (let i = all.length - 1; i >= 0; i--) {
141
+ const e = all[i];
142
+ if (e.type !== "main_revert" && e.type !== "operator_revert")
143
+ continue;
144
+ // An instance run (`feature-2`) commits under its base role (`tumwater(feature): …`), so
145
+ // an operator_revert's runner is the base role; a main_revert's runner is the instance id
146
+ // the merged event logged. Match either. The commit-sha check below still disambiguates.
147
+ if (typeof e.runner !== "string" || (e.runner !== d.role && e.runner !== baseRoleOf(d.role)))
148
+ continue;
149
+ if (typeof e.commit !== "string" || e.commit !== targetSha)
150
+ continue;
151
+ return {
152
+ kind: e.type === "main_revert" ? "main" : "operator", // vocabulary-ok: the deliberate-revert kind value names the operator role
153
+ sha: e.commit,
154
+ revert: typeof e.revert === "string" ? e.revert : "",
155
+ failingTests: Array.isArray(e.failingTests) ? e.failingTests : [],
156
+ };
157
+ }
158
+ return null;
159
+ }
160
+ /** The commit of the newest `merged` event in `pool` (oldest-first) inside [from, to]. */
161
+ function newestMergedCommit(pool, from, to) {
162
+ for (let i = pool.length - 1; i >= 0; i--) {
163
+ const e = pool[i];
164
+ if (e.type === "merged" && e.ts >= from && e.ts <= to && typeof e.commit === "string" && e.commit !== "") {
165
+ return e.commit;
166
+ }
167
+ }
168
+ return null;
169
+ }
170
+ /** The landed sha for a detail: see RunDetail.mergedSha. */
171
+ function mergedShaOf(result, merge, scoped, block) {
172
+ if (merge === null) {
173
+ return result === "changed" ? newestMergedCommit(block, -Infinity, Infinity) : null;
174
+ }
175
+ if (merge.type !== "merge_done" || typeof merge.durationMs !== "number" || !Number.isFinite(merge.durationMs)) {
176
+ return null;
177
+ }
178
+ return newestMergedCommit(scoped, merge.ts - merge.durationMs, merge.ts);
179
+ }