@telora/daemon 0.24.42 → 0.24.56

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 (359) hide show
  1. package/build-info.json +11 -3
  2. package/dist/completion/completion-event/unfinished-work.d.ts +3 -3
  3. package/dist/completion/review-cycle-budget/review-loop-detection.d.ts.map +1 -1
  4. package/dist/completion/review-cycle-budget/review-loop-detection.js +2 -1
  5. package/dist/completion/review-cycle-budget/review-loop-detection.js.map +1 -1
  6. package/dist/completion/review-exit-holds/review-exit-verdict-gate.d.ts +1 -1
  7. package/dist/completion/review-exit-holds/review-exit-verdict-gate.d.ts.map +1 -1
  8. package/dist/completion/review-exit-holds/review-exit-verdict-gate.js +2 -3
  9. package/dist/completion/review-exit-holds/review-exit-verdict-gate.js.map +1 -1
  10. package/dist/completion/state-cascade/focus-next-step-read.d.ts +38 -0
  11. package/dist/completion/state-cascade/focus-next-step-read.d.ts.map +1 -0
  12. package/dist/completion/state-cascade/focus-next-step-read.js +188 -0
  13. package/dist/completion/state-cascade/focus-next-step-read.js.map +1 -0
  14. package/dist/completion/state-cascade/review-request-gate.d.ts.map +1 -1
  15. package/dist/completion/state-cascade/review-request-gate.js +1 -0
  16. package/dist/completion/state-cascade/review-request-gate.js.map +1 -1
  17. package/dist/completion/state-cascade/review-request-next-step.d.ts +56 -0
  18. package/dist/completion/state-cascade/review-request-next-step.d.ts.map +1 -0
  19. package/dist/completion/state-cascade/review-request-next-step.js +47 -0
  20. package/dist/completion/state-cascade/review-request-next-step.js.map +1 -0
  21. package/dist/completion/state-cascade/review-verify-judgment-gate.d.ts +1 -1
  22. package/dist/completion/state-cascade/review-verify-judgment-gate.d.ts.map +1 -1
  23. package/dist/completion/state-cascade/review-verify-judgment-gate.js +1 -0
  24. package/dist/completion/state-cascade/review-verify-judgment-gate.js.map +1 -1
  25. package/dist/completion/state-cascade/state-cascade.d.ts +12 -7
  26. package/dist/completion/state-cascade/state-cascade.d.ts.map +1 -1
  27. package/dist/completion/state-cascade/state-cascade.js +36 -105
  28. package/dist/completion/state-cascade/state-cascade.js.map +1 -1
  29. package/dist/composition/commit-gate-context.d.ts.map +1 -1
  30. package/dist/composition/commit-gate-context.js +1 -0
  31. package/dist/composition/commit-gate-context.js.map +1 -1
  32. package/dist/composition/daemon-contexts.js +1 -1
  33. package/dist/composition/execution-migrations-context.d.ts.map +1 -1
  34. package/dist/composition/execution-migrations-context.js +3 -1
  35. package/dist/composition/execution-migrations-context.js.map +1 -1
  36. package/dist/composition/execution-process-context.js +1 -1
  37. package/dist/composition/execution-recovery-context.d.ts +4 -3
  38. package/dist/composition/execution-recovery-context.d.ts.map +1 -1
  39. package/dist/composition/execution-recovery-context.js +6 -3
  40. package/dist/composition/execution-recovery-context.js.map +1 -1
  41. package/dist/composition/execution-worktree-context.js +1 -1
  42. package/dist/composition/focus-next-step-context.d.ts +19 -0
  43. package/dist/composition/focus-next-step-context.d.ts.map +1 -0
  44. package/dist/composition/focus-next-step-context.js +51 -0
  45. package/dist/composition/focus-next-step-context.js.map +1 -0
  46. package/dist/composition/runtime-contexts.d.ts.map +1 -1
  47. package/dist/composition/runtime-contexts.js +6 -18
  48. package/dist/composition/runtime-contexts.js.map +1 -1
  49. package/dist/composition/runtime-poll-context.d.ts +8 -53
  50. package/dist/composition/runtime-poll-context.d.ts.map +1 -1
  51. package/dist/composition/runtime-poll-context.js +35 -94
  52. package/dist/composition/runtime-poll-context.js.map +1 -1
  53. package/dist/composition/runtime-prd-context.d.ts +8 -0
  54. package/dist/composition/runtime-prd-context.d.ts.map +1 -1
  55. package/dist/composition/runtime-prd-context.js +32 -0
  56. package/dist/composition/runtime-prd-context.js.map +1 -1
  57. package/dist/composition/runtime-spawn-pass-context.d.ts.map +1 -1
  58. package/dist/composition/runtime-spawn-pass-context.js +2 -3
  59. package/dist/composition/runtime-spawn-pass-context.js.map +1 -1
  60. package/dist/composition/state-cascade-context.d.ts +2 -0
  61. package/dist/composition/state-cascade-context.d.ts.map +1 -1
  62. package/dist/composition/state-cascade-context.js +9 -0
  63. package/dist/composition/state-cascade-context.js.map +1 -1
  64. package/dist/composition/verification-context.d.ts.map +1 -1
  65. package/dist/composition/verification-context.js +15 -3
  66. package/dist/composition/verification-context.js.map +1 -1
  67. package/dist/config/live-daemon-config.js +1 -1
  68. package/dist/daemon-state/branch-removal-record.d.ts +30 -0
  69. package/dist/daemon-state/branch-removal-record.d.ts.map +1 -0
  70. package/dist/daemon-state/branch-removal-record.js +103 -0
  71. package/dist/daemon-state/branch-removal-record.js.map +1 -0
  72. package/dist/delivery/advance-hold.d.ts +8 -19
  73. package/dist/delivery/advance-hold.d.ts.map +1 -1
  74. package/dist/delivery/advance-hold.js +11 -36
  75. package/dist/delivery/advance-hold.js.map +1 -1
  76. package/dist/delivery/commit-verdict-hold.d.ts +1 -1
  77. package/dist/delivery/commit-verdict-hold.js +1 -1
  78. package/dist/delivery/recorded-concerns.d.ts.map +1 -1
  79. package/dist/delivery/recorded-concerns.js +0 -2
  80. package/dist/delivery/recorded-concerns.js.map +1 -1
  81. package/dist/directive/directive-queue.d.ts +4 -16
  82. package/dist/directive/directive-queue.d.ts.map +1 -1
  83. package/dist/directive/directive-queue.js +5 -13
  84. package/dist/directive/directive-queue.js.map +1 -1
  85. package/dist/directive/phase-sync.d.ts +1 -1
  86. package/dist/directive/phase-sync.js +1 -1
  87. package/dist/focus/crash-recovery.d.ts +10 -32
  88. package/dist/focus/crash-recovery.d.ts.map +1 -1
  89. package/dist/focus/crash-recovery.js +55 -150
  90. package/dist/focus/crash-recovery.js.map +1 -1
  91. package/dist/focus/daemon-contexts-runtime.d.ts +3 -3
  92. package/dist/focus/daemon-contexts-runtime.d.ts.map +1 -1
  93. package/dist/focus/daemon-contexts.js +1 -1
  94. package/dist/focus/directive-executor.d.ts.map +1 -1
  95. package/dist/focus/directive-executor.js +3 -7
  96. package/dist/focus/directive-executor.js.map +1 -1
  97. package/dist/focus/failed-head-rework-start.d.ts +61 -0
  98. package/dist/focus/failed-head-rework-start.d.ts.map +1 -0
  99. package/dist/focus/failed-head-rework-start.js +52 -0
  100. package/dist/focus/failed-head-rework-start.js.map +1 -0
  101. package/dist/focus/focus-activity-record.d.ts +4 -2
  102. package/dist/focus/focus-activity-record.d.ts.map +1 -1
  103. package/dist/focus/focus-activity-record.js +4 -2
  104. package/dist/focus/focus-activity-record.js.map +1 -1
  105. package/dist/focus/focus-liveness-pass.d.ts +62 -0
  106. package/dist/focus/focus-liveness-pass.d.ts.map +1 -0
  107. package/dist/focus/focus-liveness-pass.js +197 -0
  108. package/dist/focus/focus-liveness-pass.js.map +1 -0
  109. package/dist/focus/focus-poller-spawn.js +1 -1
  110. package/dist/focus/focus-poller-state.js +1 -1
  111. package/dist/focus/live-branch-preservation.d.ts +123 -0
  112. package/dist/focus/live-branch-preservation.d.ts.map +1 -0
  113. package/dist/focus/live-branch-preservation.js +192 -0
  114. package/dist/focus/live-branch-preservation.js.map +1 -0
  115. package/dist/focus/migration-claim-pass.d.ts +2 -0
  116. package/dist/focus/migration-claim-pass.d.ts.map +1 -1
  117. package/dist/focus/migration-claim-pass.js +57 -22
  118. package/dist/focus/migration-claim-pass.js.map +1 -1
  119. package/dist/focus/migration-held-set-publish.d.ts +28 -2
  120. package/dist/focus/migration-held-set-publish.d.ts.map +1 -1
  121. package/dist/focus/migration-held-set-publish.js +14 -0
  122. package/dist/focus/migration-held-set-publish.js.map +1 -1
  123. package/dist/focus/pending-spawn-review-next-step.d.ts +5 -11
  124. package/dist/focus/pending-spawn-review-next-step.d.ts.map +1 -1
  125. package/dist/focus/pending-spawn-review-next-step.js +26 -72
  126. package/dist/focus/pending-spawn-review-next-step.js.map +1 -1
  127. package/dist/focus/review-refire-gate.d.ts +25 -0
  128. package/dist/focus/review-refire-gate.d.ts.map +1 -0
  129. package/dist/focus/review-refire-gate.js +68 -0
  130. package/dist/focus/review-refire-gate.js.map +1 -0
  131. package/dist/focus/verify-routing-passes.d.ts +8 -11
  132. package/dist/focus/verify-routing-passes.d.ts.map +1 -1
  133. package/dist/focus/verify-routing-passes.js +1 -2
  134. package/dist/focus/verify-routing-passes.js.map +1 -1
  135. package/dist/git/types.js +1 -1
  136. package/dist/prd/arm-refusal-streak.d.ts +102 -0
  137. package/dist/prd/arm-refusal-streak.d.ts.map +1 -0
  138. package/dist/prd/arm-refusal-streak.js +136 -0
  139. package/dist/prd/arm-refusal-streak.js.map +1 -0
  140. package/dist/prd/arm-refusal.d.ts.map +1 -1
  141. package/dist/prd/arm-refusal.js +7 -4
  142. package/dist/prd/arm-refusal.js.map +1 -1
  143. package/dist/prd/controller-shared.d.ts +47 -12
  144. package/dist/prd/controller-shared.d.ts.map +1 -1
  145. package/dist/prd/controller-shared.js +30 -19
  146. package/dist/prd/controller-shared.js.map +1 -1
  147. package/dist/prd/controller.d.ts.map +1 -1
  148. package/dist/prd/controller.js +3 -1
  149. package/dist/prd/controller.js.map +1 -1
  150. package/dist/prd/frontier-arming.d.ts +10 -2
  151. package/dist/prd/frontier-arming.d.ts.map +1 -1
  152. package/dist/prd/frontier-arming.js +91 -7
  153. package/dist/prd/frontier-arming.js.map +1 -1
  154. package/dist/prd/scoping-prompt.d.ts +8 -0
  155. package/dist/prd/scoping-prompt.d.ts.map +1 -1
  156. package/dist/prd/scoping-prompt.js +18 -0
  157. package/dist/prd/scoping-prompt.js.map +1 -1
  158. package/dist/prompt-sections/qa-failure-section.d.ts.map +1 -1
  159. package/dist/prompt-sections/qa-failure-section.js +3 -1
  160. package/dist/prompt-sections/qa-failure-section.js.map +1 -1
  161. package/dist/queries/api-client/shared.js +1 -1
  162. package/dist/queries/deliveries/deliveries.js +1 -1
  163. package/dist/queries/delivery-gate-state/delivery-gate-holds.d.ts +4 -3
  164. package/dist/queries/delivery-gate-state/delivery-gate-holds.d.ts.map +1 -1
  165. package/dist/queries/delivery-gate-state/delivery-gate-state.js +1 -1
  166. package/dist/queries/escalations/escalations.d.ts.map +1 -1
  167. package/dist/queries/escalations/escalations.js +0 -1
  168. package/dist/queries/escalations/escalations.js.map +1 -1
  169. package/dist/queries/escalations/incident-record.d.ts.map +1 -1
  170. package/dist/queries/escalations/incident-record.js +1 -0
  171. package/dist/queries/escalations/incident-record.js.map +1 -1
  172. package/dist/queries/focus-review/review-criterion-verdicts.d.ts.map +1 -1
  173. package/dist/queries/focus-review/review-criterion-verdicts.js +1 -0
  174. package/dist/queries/focus-review/review-criterion-verdicts.js.map +1 -1
  175. package/dist/queries/migrations/live-focus-branches.d.ts +23 -0
  176. package/dist/queries/migrations/live-focus-branches.d.ts.map +1 -1
  177. package/dist/queries/migrations/live-focus-branches.js +32 -1
  178. package/dist/queries/migrations/live-focus-branches.js.map +1 -1
  179. package/dist/queries/prd/prd.d.ts.map +1 -1
  180. package/dist/queries/prd/prd.js +1 -16
  181. package/dist/queries/prd/prd.js.map +1 -1
  182. package/dist/queries/qa-packets/focus-qa-failure.d.ts +18 -0
  183. package/dist/queries/qa-packets/focus-qa-failure.d.ts.map +1 -1
  184. package/dist/queries/qa-packets/focus-qa-failure.js +14 -1
  185. package/dist/queries/qa-packets/focus-qa-failure.js.map +1 -1
  186. package/dist/queries/tower/tower-state.d.ts +2 -0
  187. package/dist/queries/tower/tower-state.d.ts.map +1 -1
  188. package/dist/queries/tower/tower-state.js +6 -0
  189. package/dist/queries/tower/tower-state.js.map +1 -1
  190. package/dist/queries/tower-decisions/tower-decisions.d.ts.map +1 -1
  191. package/dist/queries/tower-decisions/tower-decisions.js +1 -0
  192. package/dist/queries/tower-decisions/tower-decisions.js.map +1 -1
  193. package/dist/queries/verification/verification.d.ts +10 -0
  194. package/dist/queries/verification/verification.d.ts.map +1 -1
  195. package/dist/queries/verification/verification.js +1 -1
  196. package/dist/queries/verification/verification.js.map +1 -1
  197. package/dist/supervision/escalation-suppression.js +1 -1
  198. package/dist/supervision/failed-head-rerun.d.ts +7 -0
  199. package/dist/supervision/failed-head-rerun.d.ts.map +1 -0
  200. package/dist/supervision/failed-head-rerun.js +41 -0
  201. package/dist/supervision/failed-head-rerun.js.map +1 -0
  202. package/dist/supervision/focus-delivery-aggregate-phase.js +1 -1
  203. package/dist/supervision/focus-delivery-aggregate-phase.js.map +1 -1
  204. package/dist/supervision/focus-liveness.d.ts +89 -0
  205. package/dist/supervision/focus-liveness.d.ts.map +1 -0
  206. package/dist/supervision/focus-liveness.js +94 -0
  207. package/dist/supervision/focus-liveness.js.map +1 -0
  208. package/dist/supervision/focus-next-step.d.ts +175 -0
  209. package/dist/supervision/focus-next-step.d.ts.map +1 -0
  210. package/dist/supervision/focus-next-step.js +129 -0
  211. package/dist/supervision/focus-next-step.js.map +1 -0
  212. package/dist/supervision/prd-frontier-rule.d.ts +52 -0
  213. package/dist/supervision/prd-frontier-rule.d.ts.map +1 -0
  214. package/dist/supervision/prd-frontier-rule.js +51 -0
  215. package/dist/supervision/prd-frontier-rule.js.map +1 -0
  216. package/dist/supervision/prt-frontier.d.ts +22 -7
  217. package/dist/supervision/prt-frontier.d.ts.map +1 -1
  218. package/dist/supervision/prt-frontier.js +17 -7
  219. package/dist/supervision/prt-frontier.js.map +1 -1
  220. package/dist/supervision/review-loop-detector.d.ts.map +1 -1
  221. package/dist/supervision/review-loop-detector.js +2 -1
  222. package/dist/supervision/review-loop-detector.js.map +1 -1
  223. package/dist/supervision/spawn-cooldown.js +1 -1
  224. package/dist/supervision/stop-registry.d.ts +1 -0
  225. package/dist/supervision/stop-registry.d.ts.map +1 -1
  226. package/dist/supervision/stop-rows-focus-health.d.ts +14 -0
  227. package/dist/supervision/stop-rows-focus-health.d.ts.map +1 -1
  228. package/dist/supervision/stop-rows-focus-health.js +32 -0
  229. package/dist/supervision/stop-rows-focus-health.js.map +1 -1
  230. package/dist/supervision/stop-rows-spawn.d.ts +3 -2
  231. package/dist/supervision/stop-rows-spawn.d.ts.map +1 -1
  232. package/dist/supervision/stop-rows-spawn.js +9 -6
  233. package/dist/supervision/stop-rows-spawn.js.map +1 -1
  234. package/dist/supervision/team-work.js +1 -1
  235. package/dist/supervision/team-work.js.map +1 -1
  236. package/dist/testing/fixtures/api-client.js +1 -1
  237. package/dist/testing/fixtures/index.js +1 -1
  238. package/dist/testing/fixtures/migration-namespace-repo.d.ts.map +1 -1
  239. package/dist/testing/fixtures/migration-namespace-repo.js +1 -0
  240. package/dist/testing/fixtures/migration-namespace-repo.js.map +1 -1
  241. package/dist/testing/fixtures/pending-spawn-world.d.ts +24 -0
  242. package/dist/testing/fixtures/pending-spawn-world.d.ts.map +1 -1
  243. package/dist/testing/fixtures/pending-spawn-world.js +46 -19
  244. package/dist/testing/fixtures/pending-spawn-world.js.map +1 -1
  245. package/dist/testing/fixtures/recording-api-client.js +1 -1
  246. package/dist/testing/fixtures/verification-deps.d.ts +27 -0
  247. package/dist/testing/fixtures/verification-deps.d.ts.map +1 -1
  248. package/dist/testing/fixtures/verification-deps.js +77 -1
  249. package/dist/testing/fixtures/verification-deps.js.map +1 -1
  250. package/dist/testing/fixtures/vitest-failure-log.d.ts.map +1 -1
  251. package/dist/testing/fixtures/vitest-failure-log.js +1 -0
  252. package/dist/testing/fixtures/vitest-failure-log.js.map +1 -1
  253. package/dist/tower/focus-landed.d.ts +32 -1
  254. package/dist/tower/focus-landed.d.ts.map +1 -1
  255. package/dist/tower/focus-landed.js +67 -12
  256. package/dist/tower/focus-landed.js.map +1 -1
  257. package/dist/tower/tower-graph.d.ts +6 -2
  258. package/dist/tower/tower-graph.d.ts.map +1 -1
  259. package/dist/tower/tower-graph.js +8 -5
  260. package/dist/tower/tower-graph.js.map +1 -1
  261. package/dist/tower/tower-supervisor-history.d.ts.map +1 -1
  262. package/dist/tower/tower-supervisor-history.js +2 -1
  263. package/dist/tower/tower-supervisor-history.js.map +1 -1
  264. package/dist/tower/tower-supervisor-prompt.d.ts.map +1 -1
  265. package/dist/tower/tower-supervisor-prompt.js +40 -8
  266. package/dist/tower/tower-supervisor-prompt.js.map +1 -1
  267. package/dist/tower/tower-supervisor-session.d.ts.map +1 -1
  268. package/dist/tower/tower-supervisor-session.js +1 -0
  269. package/dist/tower/tower-supervisor-session.js.map +1 -1
  270. package/dist/tower/tower-verdicts.d.ts.map +1 -1
  271. package/dist/tower/tower-verdicts.js +2 -1
  272. package/dist/tower/tower-verdicts.js.map +1 -1
  273. package/dist/types/issue-status.d.ts.map +1 -1
  274. package/dist/types/issue-status.js +6 -1
  275. package/dist/types/issue-status.js.map +1 -1
  276. package/dist/verify/attribution/code-failure-evidence.d.ts +77 -0
  277. package/dist/verify/attribution/code-failure-evidence.d.ts.map +1 -0
  278. package/dist/verify/attribution/code-failure-evidence.js +92 -0
  279. package/dist/verify/attribution/code-failure-evidence.js.map +1 -0
  280. package/dist/verify/attribution/verification-attribution.d.ts +18 -0
  281. package/dist/verify/attribution/verification-attribution.d.ts.map +1 -1
  282. package/dist/verify/attribution/verification-attribution.js +49 -2
  283. package/dist/verify/attribution/verification-attribution.js.map +1 -1
  284. package/dist/verify/attribution/verification-baseline.d.ts.map +1 -1
  285. package/dist/verify/attribution/verification-baseline.js +1 -0
  286. package/dist/verify/attribution/verification-baseline.js.map +1 -1
  287. package/dist/verify/attribution/verification-diagnostics.d.ts +10 -0
  288. package/dist/verify/attribution/verification-diagnostics.d.ts.map +1 -1
  289. package/dist/verify/attribution/verification-diagnostics.js +39 -10
  290. package/dist/verify/attribution/verification-diagnostics.js.map +1 -1
  291. package/dist/verify/deterministic-gate/verification-deterministic.d.ts +19 -0
  292. package/dist/verify/deterministic-gate/verification-deterministic.d.ts.map +1 -1
  293. package/dist/verify/deterministic-gate/verification-deterministic.js +1 -1
  294. package/dist/verify/deterministic-gate/verification-deterministic.js.map +1 -1
  295. package/dist/verify/engine/verification-commit-sharing.d.ts.map +1 -1
  296. package/dist/verify/engine/verification-commit-sharing.js +36 -4
  297. package/dist/verify/engine/verification-commit-sharing.js.map +1 -1
  298. package/dist/verify/engine/verification-deps.d.ts +7 -0
  299. package/dist/verify/engine/verification-deps.d.ts.map +1 -1
  300. package/dist/verify/engine/verification-engine.d.ts.map +1 -1
  301. package/dist/verify/engine/verification-engine.js +6 -3
  302. package/dist/verify/engine/verification-engine.js.map +1 -1
  303. package/dist/verify/escaped-tests/escaped-test-run.d.ts +5 -1
  304. package/dist/verify/escaped-tests/escaped-test-run.d.ts.map +1 -1
  305. package/dist/verify/escaped-tests/escaped-test-run.js +24 -2
  306. package/dist/verify/escaped-tests/escaped-test-run.js.map +1 -1
  307. package/dist/verify/failing-test-rerun/failing-test-retry.d.ts +4 -1
  308. package/dist/verify/failing-test-rerun/failing-test-retry.d.ts.map +1 -1
  309. package/dist/verify/failing-test-rerun/failing-test-retry.js.map +1 -1
  310. package/dist/verify/gate-verdicts/commit-verdict-record.js +1 -1
  311. package/dist/verify/gate-verdicts/commit-verdict-record.js.map +1 -1
  312. package/dist/verify/gate-verdicts/no-verdict-record.d.ts +27 -3
  313. package/dist/verify/gate-verdicts/no-verdict-record.d.ts.map +1 -1
  314. package/dist/verify/gate-verdicts/no-verdict-record.js +36 -6
  315. package/dist/verify/gate-verdicts/no-verdict-record.js.map +1 -1
  316. package/dist/verify/outcome-routing/verification-rework-issue.d.ts.map +1 -1
  317. package/dist/verify/outcome-routing/verification-rework-issue.js +5 -4
  318. package/dist/verify/outcome-routing/verification-rework-issue.js.map +1 -1
  319. package/dist/verify/run-selection/default-on-guards.d.ts +15 -4
  320. package/dist/verify/run-selection/default-on-guards.d.ts.map +1 -1
  321. package/dist/verify/run-selection/default-on-guards.js +14 -4
  322. package/dist/verify/run-selection/default-on-guards.js.map +1 -1
  323. package/dist/verify/run-selection/explicit-next-step-gate.d.ts +39 -0
  324. package/dist/verify/run-selection/explicit-next-step-gate.d.ts.map +1 -0
  325. package/dist/verify/run-selection/explicit-next-step-gate.js +70 -0
  326. package/dist/verify/run-selection/explicit-next-step-gate.js.map +1 -0
  327. package/dist/verify/run-selection/pre-review-gate-dispatch.d.ts +0 -9
  328. package/dist/verify/run-selection/pre-review-gate-dispatch.d.ts.map +1 -1
  329. package/dist/verify/run-selection/pre-review-gate-dispatch.js +21 -62
  330. package/dist/verify/run-selection/pre-review-gate-dispatch.js.map +1 -1
  331. package/dist/verify/run-selection/reselection-log-line.d.ts +1 -1
  332. package/dist/verify/run-selection/reselection-log-line.d.ts.map +1 -1
  333. package/dist/verify/run-selection/reselection-log-line.js +2 -0
  334. package/dist/verify/run-selection/reselection-log-line.js.map +1 -1
  335. package/dist/verify/run-selection/verification-default-on.d.ts +32 -4
  336. package/dist/verify/run-selection/verification-default-on.d.ts.map +1 -1
  337. package/dist/verify/run-selection/verification-default-on.js +83 -19
  338. package/dist/verify/run-selection/verification-default-on.js.map +1 -1
  339. package/dist/verify/shortfalls/shortfall-park.js +1 -1
  340. package/dist/worktree/focus-worktree-state.js +1 -1
  341. package/dist/worktree/focus-worktree-state.js.map +1 -1
  342. package/docs/runbook-tower.md +26 -5
  343. package/package.json +3 -3
  344. package/dist/completion/state-cascade/review-next-step.d.ts +0 -107
  345. package/dist/completion/state-cascade/review-next-step.d.ts.map +0 -1
  346. package/dist/completion/state-cascade/review-next-step.js +0 -90
  347. package/dist/completion/state-cascade/review-next-step.js.map +0 -1
  348. package/dist/focus/failed-head-wedge.d.ts +0 -124
  349. package/dist/focus/failed-head-wedge.d.ts.map +0 -1
  350. package/dist/focus/failed-head-wedge.js +0 -120
  351. package/dist/focus/failed-head-wedge.js.map +0 -1
  352. package/dist/focus/stranded-review-reroute.d.ts +0 -70
  353. package/dist/focus/stranded-review-reroute.d.ts.map +0 -1
  354. package/dist/focus/stranded-review-reroute.js +0 -193
  355. package/dist/focus/stranded-review-reroute.js.map +0 -1
  356. package/dist/focus/uncommitted-work-backstop.d.ts +0 -115
  357. package/dist/focus/uncommitted-work-backstop.d.ts.map +0 -1
  358. package/dist/focus/uncommitted-work-backstop.js +0 -259
  359. package/dist/focus/uncommitted-work-backstop.js.map +0 -1
@@ -1,193 +0,0 @@
1
- // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
- // Pinned by: packages/daemon/src/focus/held-review-window-not-stranded.test.ts,
3
- // packages/daemon/src/focus/stranded-review-refire-bound.test.ts,
4
- // packages/daemon/src/focus/stranded-review-reroute.test.ts,
5
- // packages/daemon/src/integration/failed-verdict-review-exit-respawn-regression.test.ts,
6
- // packages/daemon/src/integration/failed-verdict-review-loop-regression.test.ts
7
- // PINNED-BY-END
8
- /**
9
- * The stranded-review re-fire is bounded per unchanged (focus, review window, HEAD,
10
- * gate verdict), and at the bound it takes a different route instead of queuing
11
- * the same review again.
12
- *
13
- * shouldRefireStrandedReview (directive/phase-sync.ts) re-queues the review
14
- * directive for a focus stuck in review with a pending request and no team. That
15
- * recovers a review a crash or teardown dropped. It does not recover a review that
16
- * RAN and could route nothing -- an exit held on a failed gate verdict leaves the
17
- * window set on purpose, and every re-fire would spawn another review of the same
18
- * range that stamps the same result and exits held again.
19
- * The review spawn gate declines such a range when it can read it
20
- * (focus/unchanged-reviewed-head.ts); this bound is the backstop for when it
21
- * cannot (no census, no recorded verdict, an unreadable read that failed open).
22
- *
23
- * Counting: each re-fire of a focus is counted under the key of what a review
24
- * would see -- the review window (review_requested_at), the judged commit (focus
25
- * worktree HEAD) and that commit's recorded gate verdict. A new window, a new
26
- * commit or a new verdict is a new key and starts over, so a review that has
27
- * something new to judge is never held back. In memory: a restart re-arms the
28
- * bound, which costs at most STRANDED_REVIEW_REFIRE_BOUND more re-fires.
29
- *
30
- * At the bound (reroute): logged with the focus, HEAD, verdict and bound, then
31
- * - a FAILED verdict: every verify delivery gets the rework Bug naming the
32
- * failure (verify/outcome-routing/verification-rework-issue.ts; deduped per commit, skipped
33
- * beside open work), so the live open-work pass routes it verify ->
34
- * verify_failed and a coding pass fixes it;
35
- * - otherwise (passed, or no verdict): one agent_resolvable observation
36
- * (stranded_review_rerouted) names the stuck window for a routing decider --
37
- * re-reviewing an unchanged range cannot answer it;
38
- * - either way the queued directive is dropped and the review window closed, so
39
- * the re-fire has nothing left to re-fire.
40
- * Best-effort throughout: a failed step is logged; the window stays set only when
41
- * its clear fails, and the next poll re-reaches the bound and retries.
42
- *
43
- * Not a strand at all: a window the review exit HELD for a gate verdict
44
- * (strandedReviewAwaitsGateVerdict -- an unreadable hold counts as held). The
45
- * release pass routes it when the verdict lands, so the re-fire
46
- * (strandedReviewMayRefire) leaves it alone and nothing is counted.
47
- *
48
- * Every read and write is a REQUIRED collaborator (StrandedReviewRerouteDeps),
49
- * handed in by the directive executor from the composition root's
50
- * `strandedReviewReroute` context (composition/runtime-contexts.ts): the
51
- * failed-verdict rework filing and this bound's own reads and writes.
52
- *
53
- * History: docs/daemon/history-platform.md (focus/stranded-review-reroute.ts).
54
- *
55
- * @module focus/stranded-review-reroute
56
- */
57
- import { ESCALATION_REASONS } from '@telora/daemon-core';
58
- import { DISPOSITION_AGENT_RESOLVABLE } from '../queries/escalations/escalation-dispositions.js';
59
- import { describeFailedVerdictRework, fileReworkForFailedVerdict } from '../verify/outcome-routing/verification-rework-issue.js';
60
- import { commitVerdictHeldDeliveryIds } from '../delivery/commit-verdict-hold.js';
61
- import { shouldRefireStrandedReview } from '../directive/phase-sync.js';
62
- import { createLogger } from '../log/daemon-log.js';
63
- const log = createLogger({ module: 'directive-executor' });
64
- /** Re-fires of one unchanged (window, HEAD, verdict) before the reroute. */
65
- export const STRANDED_REVIEW_REFIRE_BOUND = 3;
66
- /** escalation_kind of the observation a non-failed reroute files. */
67
- export const STRANDED_REVIEW_REROUTED_KIND = 'stranded_review_rerouted';
68
- /** focusId -> the key re-fires are being counted under, and how many. */
69
- const refires = new Map();
70
- /** Test seam: forget every count. */
71
- export function __resetStrandedReviewRefiresForTests() {
72
- refires.clear();
73
- }
74
- function subjectOf(focus, productId, deps) {
75
- const head = deps.resolveJudgedCommit(focus.focus_id);
76
- const verdict = head && productId ? deps.readCommitVerdict(productId, focus.focus_id, head) : null;
77
- const verdictKey = verdict ? `${verdict.outcome}@${verdict.recordedAt}` : 'none';
78
- return { key: `${focus.review_requested_at ?? ''}|${head ?? '?'}|${verdictKey}`, head, verdict };
79
- }
80
- /**
81
- * The gate-verdict hold read, tri-state: 'held' when some verify delivery carries
82
- * the commit-verdict hold marker the review exit wrote (delivery/commit-verdict-hold.ts,
83
- * the same read the review park uses), 'clear' when the deliveries read and none
84
- * does, 'unreadable' when the read failed.
85
- */
86
- export async function readStrandedReviewGateHold(focus, deps) {
87
- try {
88
- return commitVerdictHeldDeliveryIds(await deps.getFocusDeliveries(focus.focus_id)).size > 0 ? 'held' : 'clear';
89
- }
90
- catch (err) {
91
- log.debug(`[directive-executor] gate-verdict hold unreadable for "${focus.focus_name}": ${err.message}`);
92
- return 'unreadable';
93
- }
94
- }
95
- /**
96
- * Whether the stranded-review re-fire must leave this window alone because it may
97
- * be held open for a gate verdict. Such a window is the release pass's to route,
98
- * not a strand to re-fire (directive/phase-sync.ts shouldRefireStrandedReview).
99
- * FAIL-CLOSED: an unreadable hold answers true -- re-firing on a guess queued the
100
- * review that re-judged the held commit -- so the re-fire waits a poll and re-reads;
101
- * a readable window with no hold is a genuine strand and answers false.
102
- */
103
- export async function strandedReviewAwaitsGateVerdict(focus, deps) {
104
- return (await readStrandedReviewGateHold(focus, deps)) !== 'clear';
105
- }
106
- /**
107
- * The stranded-review re-fire decision checkDirectives (focus/directive-executor.ts)
108
- * takes for a focus whose current stage was already processed: the pure
109
- * shouldRefireStrandedReview over the live team / operator-stop facts and the
110
- * fail-closed gate-verdict hold read above. True = re-fire the review directive.
111
- */
112
- export async function strandedReviewMayRefire(focus, stageName, hasActiveTeam, deps) {
113
- return shouldRefireStrandedReview({
114
- stageName,
115
- reviewRequestedAt: focus.review_requested_at,
116
- hasActiveTeam,
117
- operatorStopped: !!focus.operator_stopped_at,
118
- awaitingGateVerdict: await strandedReviewAwaitsGateVerdict(focus, deps),
119
- });
120
- }
121
- /**
122
- * Count a stranded-review re-fire the caller is about to make, or -- once the
123
- * same key has been re-fired STRANDED_REVIEW_REFIRE_BOUND times -- reroute instead
124
- * (module header). Never throws.
125
- */
126
- export async function boundStrandedReviewRefire(focus, ctx, deps) {
127
- let subject;
128
- try {
129
- subject = subjectOf(focus, ctx.productId, deps);
130
- }
131
- catch (err) {
132
- log.warn(`[directive-executor] stranded-review bound unreadable for "${focus.focus_name}" -- re-firing: ${err.message}`);
133
- return 'refire';
134
- }
135
- const prior = refires.get(focus.focus_id);
136
- const count = prior?.key === subject.key ? prior.count : 0;
137
- if (count < STRANDED_REVIEW_REFIRE_BOUND) {
138
- refires.set(focus.focus_id, { key: subject.key, count: count + 1 });
139
- return 'refire';
140
- }
141
- await reroute(focus, ctx, subject, deps);
142
- return 'rerouted';
143
- }
144
- async function reroute(focus, ctx, { head, verdict }, deps) {
145
- const at = head ? head.slice(0, 12) : '<unreadable HEAD>';
146
- const failed = verdict?.outcome === 'failed' && head !== null;
147
- log.warn(`[directive-executor] Stranded-review re-fire bound (${STRANDED_REVIEW_REFIRE_BOUND}) reached for "${focus.focus_name}" ` +
148
- `at HEAD ${at} (gate verdict: ${verdict?.outcome ?? 'none recorded'}): the same review was re-fired ` +
149
- `${STRANDED_REVIEW_REFIRE_BOUND} times with nothing changed -- not queuing another identical review; ` +
150
- (failed
151
- ? 'routing the failed verdict to rework (a Bug naming the failure on the verify delivery whose commits caused it) and closing the review window'
152
- : `closing the review window and filing a ${STRANDED_REVIEW_REROUTED_KIND} observation`));
153
- if (failed) {
154
- const result = await fileReworkForFailedVerdict(focus.focus_id, verdict, deps);
155
- log.info(`[directive-executor] "${focus.focus_name}": failed verdict at ${at} -- ${describeFailedVerdictRework(result)}`);
156
- }
157
- else
158
- await reportStuckWindow(focus, ctx, head, verdict, deps);
159
- deps.clearPendingSpawnDirective(focus.focus_id);
160
- try {
161
- await deps.clearReviewRequestedAt(focus.focus_id);
162
- refires.delete(focus.focus_id);
163
- }
164
- catch (err) {
165
- log.warn(`[directive-executor] "${focus.focus_name}": could not close the stranded review window (retried next poll): ${err.message}`);
166
- }
167
- }
168
- async function reportStuckWindow(focus, ctx, head, verdict, deps) {
169
- try {
170
- if (await deps.hasOpenFocusEscalation(focus.focus_id, STRANDED_REVIEW_REROUTED_KIND))
171
- return;
172
- await deps.createEscalation({
173
- organizationId: ctx.organizationId,
174
- issueId: null,
175
- reasonType: ESCALATION_REASONS.ERROR_ENCOUNTERED,
176
- disposition: DISPOSITION_AGENT_RESOLVABLE,
177
- escalationKind: STRANDED_REVIEW_REROUTED_KIND,
178
- anchor: { focusId: focus.focus_id },
179
- description: `Focus "${focus.focus_name}" re-fired the same stranded review ${STRANDED_REVIEW_REFIRE_BOUND} times at HEAD ` +
180
- `${head ?? '<unreadable>'} (gate verdict: ${verdict?.outcome ?? 'none recorded'}) with no active team and nothing ` +
181
- 'changed, so its review window was closed instead of queuing the review again.',
182
- whatWasTried: 'Each re-fire queued the review directive because review_requested_at stayed set; no review exit routed the ' +
183
- 'focus\'s verify deliveries at this commit.',
184
- helpNeeded: 'Find why the review of this commit cannot route its verify deliveries (daemon log: [focus-executor] review exit ' +
185
- 'lines, [commit-verdict-release], gate_state on the verify deliveries) and fix that; a new commit re-arms review.',
186
- metadata: { head, verdict: verdict?.outcome ?? null, bound: STRANDED_REVIEW_REFIRE_BOUND },
187
- });
188
- }
189
- catch (err) {
190
- log.warn(`[directive-executor] "${focus.focus_name}": failed to file the ${STRANDED_REVIEW_REROUTED_KIND} observation: ${err.message}`);
191
- }
192
- }
193
- //# sourceMappingURL=stranded-review-reroute.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stranded-review-reroute.js","sourceRoot":"","sources":["../../src/focus/stranded-review-reroute.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,gFAAgF;AAChF,oEAAoE;AACpE,+DAA+D;AAC/D,2FAA2F;AAC3F,kFAAkF;AAClF,gBAAgB;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mD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AC,QAAQ,EAAE;YACnC,WAAW,EACT,UAAU,KAAK,CAAC,UAAU,uCAAuC,4BAA4B,iBAAiB;gBAC9G,GAAG,IAAI,IAAI,cAAc,mBAAmB,OAAO,EAAE,OAAO,IAAI,eAAe,oCAAoC;gBACnH,+EAA+E;YACjF,YAAY,EACV,6GAA6G;gBAC7G,4CAA4C;YAC9C,UAAU,EACR,kHAAkH;gBAClH,kHAAkH;YACpH,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,KAAK,EAAE,4BAA4B,EAAE;SAC3F,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,yBAAyB,KAAK,CAAC,UAAU,yBAAyB,6BAA6B,iBAAkB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACrJ,CAAC;AACH,CAAC"}
@@ -1,115 +0,0 @@
1
- import type { PipelineConfig } from '../types/index.js';
2
- import type { CreateEscalationParams } from '../supervision/escalation-filing.js';
3
- import type { DeliveryGateRowIo } from '../queries/deliveries/deliveries.js';
4
- /** How long the state must stand, teamless, before the pass acts (and again before it records). */
5
- export declare const UNCOMMITTED_WORK_GRACE_MS: number;
6
- /** How long a queued respawn may wait to spawn (cooldown, a parked guard) before the record is filed anyway. */
7
- export declare const UNCOMMITTED_WORK_RESPAWN_WAIT_MS: number;
8
- /** At most this many paths are named in the respawn prompt and the record; the count carries the rest. */
9
- export declare const UNCOMMITTED_WORK_PATH_CAP = 20;
10
- /** The focus slice the pass reads (queries/focuses/focus-discovery.ts ActiveFocusRow). */
11
- export interface UncommittedWorkFocusRow {
12
- focus_id: string;
13
- focus_name: string;
14
- assigned_agent_role_id: string | null;
15
- operator_stopped_at?: string | null;
16
- read_only?: boolean | null;
17
- pipeline_config?: PipelineConfig | null;
18
- }
19
- /** The coding respawn the pass queues (directive/directive-queue.ts queueDaemonCodingRespawn). */
20
- export interface CodingRespawnRequest {
21
- focusId: string;
22
- message: string;
23
- contentHash: string;
24
- focusOverrideModel: string | null;
25
- }
26
- /** What the record names. */
27
- export interface UncommittedWorkRecord {
28
- organizationId: string;
29
- focusId: string;
30
- focusName: string;
31
- worktreePath: string;
32
- paths: readonly string[];
33
- }
34
- /** The pass's collaborators, every one REQUIRED (composition/runtime-poll-context.ts binds them). */
35
- export interface UncommittedWorkBackstopDeps {
36
- getActiveFocuses: (organizationId: string, productId: string) => Promise<readonly UncommittedWorkFocusRow[]>;
37
- /** Whether a team process is live for the focus on this host. */
38
- hasLiveTeam: (focusId: string) => boolean;
39
- /** The focus worktree, or null when the daemon holds none. */
40
- resolveWorktreePath: (focusId: string) => string | null;
41
- listUncommittedPaths: (worktreePath: string) => readonly string[];
42
- /** Queue the respawn unless a spawn directive is already queued; true when this call queued it. */
43
- queueCodingRespawn: (request: CodingRespawnRequest) => boolean;
44
- /** Whether a spawn directive is still queued for the focus (the respawn has not spawned yet). */
45
- hasQueuedSpawn: (focusId: string) => boolean;
46
- /** Withdraw this pass's own queued respawn (and nothing else); true when one was withdrawn. */
47
- withdrawCodingRespawn: (focusId: string) => boolean;
48
- /** File the record (deduped per focus by the caller's binding); never throws past its own logging. */
49
- recordUncommittedWork: (record: UncommittedWorkRecord) => Promise<void>;
50
- /** Close the record once the worktree is clean; the count closed. */
51
- resolveRecord: (focusId: string) => Promise<number>;
52
- now: () => number;
53
- }
54
- /** Test seam: forget every episode. */
55
- export declare function __resetUncommittedWorkBackstopForTests(): void;
56
- /** What the pass did for one focus. */
57
- export type UncommittedWorkAction = {
58
- kind: 'respawned';
59
- paths: readonly string[];
60
- queued: boolean;
61
- } | {
62
- kind: 'recorded';
63
- paths: readonly string[];
64
- } | {
65
- kind: 'cleared';
66
- resolved: number;
67
- };
68
- /** The respawned team's directive: what is uncommitted and what finishes it. Pure. */
69
- export declare function buildUncommittedWorkRespawnMessage(focusName: string, paths: readonly string[]): string;
70
- /** The pass for one focus (module header). Never throws. */
71
- export declare function checkUncommittedWork(focus: UncommittedWorkFocusRow, organizationId: string, deps: UncommittedWorkBackstopDeps): Promise<UncommittedWorkAction | null>;
72
- /** The seams the operator-visible record goes through. */
73
- export interface StrandedWorkRecordDeps {
74
- getFocusDeliveries: (focusId: string) => Promise<ReadonlyArray<{
75
- id: string;
76
- executionStatus?: string | null;
77
- }>>;
78
- gateRowIo: DeliveryGateRowIo;
79
- now: () => number;
80
- }
81
- /**
82
- * Write the OPERATOR-VISIBLE record (module header, step 2) on every cycling
83
- * delivery of the focus: gate_state.advanceHold, reason worktree_uncommitted_no_team,
84
- * naming the worktree and the paths. Returns how many rows carry it. Throws what a
85
- * read or write throws (the pass retries).
86
- */
87
- export declare function recordStrandedWorkOnFocus(record: UncommittedWorkRecord, deps: StrandedWorkRecordDeps): Promise<number>;
88
- /** Clear the record from every delivery of the focus that carries it. Throws what a read or write throws. */
89
- export declare function clearStrandedWorkOnFocus(focusId: string, deps: StrandedWorkRecordDeps): Promise<void>;
90
- /** The filing seams the record goes through. */
91
- export interface UncommittedWorkRecordDeps {
92
- createEscalation: (params: CreateEscalationParams) => Promise<unknown>;
93
- /** Whether a sibling worktree-dirty escalation is already open for the focus (one dirty tree, one row). */
94
- hasOpenWorktreeDirtyEscalation: (focusId: string) => Promise<boolean>;
95
- }
96
- /**
97
- * File the record (module header, step 2): ONE agent-resolvable worktree-dirty
98
- * observation naming the uncommitted paths, unless a sibling worktree-dirty row
99
- * is already open for the focus. Committing or discarding the work is git work an
100
- * agent session can do, so it proposes no human act. A failed dedupe read files
101
- * (a genuine first record is not swallowed); a failed create throws to the caller.
102
- */
103
- export declare function fileUncommittedWorkRecord(record: UncommittedWorkRecord, deps: UncommittedWorkRecordDeps): Promise<void>;
104
- /**
105
- * The backstop pass over one product's active focuses (module header). Returns
106
- * what it did per focus it acted on. Never throws.
107
- */
108
- export declare function recoverUncommittedWork(config: {
109
- organizationId: string;
110
- productId: string;
111
- }, deps: UncommittedWorkBackstopDeps): Promise<Array<{
112
- focusId: string;
113
- action: UncommittedWorkAction;
114
- }>>;
115
- //# sourceMappingURL=uncommitted-work-backstop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uncommitted-work-backstop.d.ts","sourceRoot":"","sources":["../../src/focus/uncommitted-work-backstop.ts"],"names":[],"mappings":"AA0DA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAElF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAK7E,mGAAmG;AACnG,eAAO,MAAM,yBAAyB,QAAa,CAAC;AAEpD,gHAAgH;AAChH,eAAO,MAAM,gCAAgC,QAAc,CAAC;AAE5D,0GAA0G;AAC1G,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C,0FAA0F;AAC1F,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,eAAe,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CACzC;AAED,kGAAkG;AAClG,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,6BAA6B;AAC7B,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED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sB,CAC1C,MAAM,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EACrD,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,qBAAqB,CAAA;CAAE,CAAC,CAAC,CAkBpE"}
@@ -1,259 +0,0 @@
1
- // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
- // Pinned by: packages/daemon/src/focus/uncommitted-work-backstop.test.ts
3
- // PINNED-BY-END
4
- /**
5
- * Uncommitted work in an armed focus's worktree never sits there with nobody to
6
- * finish it.
7
- *
8
- * THE STATE. An armed focus (assigned_agent_role_id set, not operator-stopped,
9
- * not read-only) with NO live team on this host, whose worktree holds
10
- * uncommitted paths (`git status --porcelain`, the reading the coding -> verify
11
- * advance hold names: delivery/advance-hold.ts). Nothing else moves it: the gate
12
- * judges commits, so it never sees the work; merge-back skips a dirty worktree
13
- * every tick; the HEAD does not move, so a failed verdict at it stands; and when
14
- * every delivery is in verify no team spawns. A team torn down with its fix
15
- * staged leaves exactly this (the completion hold,
16
- * completion/completion-event/unfinished-work.ts, bounds how long a live team is
17
- * kept for it -- it does not make a torn-down team's work commit itself).
18
- *
19
- * WHAT IT DOES, once the state has stood for UNCOMMITTED_WORK_GRACE_MS (so a team
20
- * mid-exit, whose own close path may still capture its work, is not raced):
21
- * 1. RESPAWN, once per dirty episode: queue a coding respawn of the focus's own
22
- * lineage (the team that wrote the work resumes with its context), naming
23
- * the paths. A spawn directive already queued is left alone -- it spawns a
24
- * team too. The respawn is marked (purpose 'uncommitted_work') so the
25
- * pending-spawn pass never drops it for a review that would be "next" on a
26
- * verify-only focus (focus/pending-spawn-review-next-step.ts): a review judges a
27
- * HEAD the work is not in. The respawned team, its deliveries all in verify, is
28
- * held by the completion hold and re-prompted to commit until it does.
29
- * 2. RECORD, if the respawn did not finish it: the state stands again for the
30
- * grace with no live team and no respawn still queued (or the queued one has
31
- * waited UNCOMMITTED_WORK_RESPAWN_WAIT_MS). The OPERATOR-VISIBLE record is
32
- * state on the focus's cycling deliveries: gate_state.advanceHold with reason
33
- * worktree_uncommitted_no_team, naming the worktree and the paths, which the
34
- * dashboard's Waiting-on line renders (delivery/advance-hold.ts
35
- * recordStrandedWork; it carries no `blocking` entry, so it decides nothing).
36
- * Beside it, ONE agent-resolvable worktree-dirty observation (escalation kind
37
- * merge_refused_dirty, deduped across its sibling classes per focus) puts the
38
- * condition in the machine lane, where the routing deciders read it -- the
39
- * daemon files no human-facing row of its own.
40
- * An episode ends when the worktree is clean (the record is cleared and the
41
- * observation auto-resolved -- the condition they name is gone -- and a respawn
42
- * still queued is withdrawn) or the focus is no longer armed (the record, if any,
43
- * stands: the work is still uncommitted).
44
- *
45
- * WHAT IT NEVER DOES. Commit, discard or stash the work itself (it is the team's,
46
- * and an operator stop hands the worktree to the operator: an operator-stopped
47
- * focus is not armed here); act while a team is live; act on a read-only focus.
48
- *
49
- * In memory: a restart re-arms one respawn per dirty worktree, and the per-focus
50
- * observation dedupe holds across it. Best-effort: every failure is logged and
51
- * the next poll retries.
52
- *
53
- * @module focus/uncommitted-work-backstop
54
- */
55
- import { createHash } from 'node:crypto';
56
- import { DELIVERY_STATUS, ESCALATION_DISPOSITIONS, ESCALATION_REASONS } from '@telora/daemon-core';
57
- import { focusPipelineModelForPass } from '../config/model-resolution.js';
58
- import { MERGE_REFUSED_DIRTY_ESCALATION_KIND } from '../queries/escalations/escalations.js';
59
- import { NO_HUMAN_ACT } from '../queries/escalations/filing-observation.js';
60
- import { clearStrandedWork, recordStrandedWork } from '../delivery/advance-hold.js';
61
- import { createLogger } from '../log/daemon-log.js';
62
- const log = createLogger({ module: 'focus-poller' });
63
- /** How long the state must stand, teamless, before the pass acts (and again before it records). */
64
- export const UNCOMMITTED_WORK_GRACE_MS = 2 * 60_000;
65
- /** How long a queued respawn may wait to spawn (cooldown, a parked guard) before the record is filed anyway. */
66
- export const UNCOMMITTED_WORK_RESPAWN_WAIT_MS = 30 * 60_000;
67
- /** At most this many paths are named in the respawn prompt and the record; the count carries the rest. */
68
- export const UNCOMMITTED_WORK_PATH_CAP = 20;
69
- const episodes = new Map();
70
- /** Test seam: forget every episode. */
71
- export function __resetUncommittedWorkBackstopForTests() {
72
- episodes.clear();
73
- }
74
- function namedPaths(paths) {
75
- const shown = paths.slice(0, UNCOMMITTED_WORK_PATH_CAP).map((p) => `- ${p}`);
76
- return paths.length > UNCOMMITTED_WORK_PATH_CAP ? [...shown, `- ... and ${paths.length - UNCOMMITTED_WORK_PATH_CAP} more`] : shown;
77
- }
78
- /** The respawned team's directive: what is uncommitted and what finishes it. Pure. */
79
- export function buildUncommittedWorkRespawnMessage(focusName, paths) {
80
- return [
81
- `## Finish the uncommitted work in "${focusName}"`,
82
- '',
83
- `The previous team on this focus ended with ${paths.length} uncommitted path(s) in the focus worktree:`,
84
- ...namedPaths(paths),
85
- '',
86
- 'Nothing else moves this focus while they stay uncommitted: the gate judges commits, so it never sees them, and '
87
- + 'merge-back skips a dirty worktree. Inspect them, commit what is this focus\'s work -- each commit carrying the '
88
- + '`Telora-Delivery: <deliveryId>` trailer of the delivery it belongs to -- and discard what is not.',
89
- '',
90
- 'Do NOT replay the gate by hand: the daemon verifies the new HEAD once you commit.',
91
- ].join('\n');
92
- }
93
- function armed(focus) {
94
- return !!focus.assigned_agent_role_id && !focus.operator_stopped_at && focus.read_only !== true;
95
- }
96
- /**
97
- * End a focus's episode. When it ended because the worktree is CLEAN, a recorded
98
- * one has its record closed; any other end leaves the record standing. Never throws.
99
- */
100
- async function endEpisode(focus, deps, clean) {
101
- const episode = episodes.get(focus.focus_id);
102
- episodes.delete(focus.focus_id);
103
- if (clean && episode && deps.withdrawCodingRespawn(focus.focus_id)) {
104
- log.info(`[uncommitted-work] "${focus.focus_name}": the worktree is clean -- withdrew the queued respawn`);
105
- }
106
- if (!clean || !episode?.recorded)
107
- return null;
108
- try {
109
- return { kind: 'cleared', resolved: await deps.resolveRecord(focus.focus_id) };
110
- }
111
- catch (err) {
112
- log.warn(`[uncommitted-work] "${focus.focus_name}": closing the record failed: ${err.message}`);
113
- return null;
114
- }
115
- }
116
- /** The pass for one focus (module header). Never throws. */
117
- export async function checkUncommittedWork(focus, organizationId, deps) {
118
- if (!armed(focus))
119
- return endEpisode(focus, deps, false);
120
- const worktreePath = deps.resolveWorktreePath(focus.focus_id);
121
- if (!worktreePath)
122
- return endEpisode(focus, deps, false);
123
- const now = deps.now();
124
- const prior = episodes.get(focus.focus_id);
125
- if (deps.hasLiveTeam(focus.focus_id)) {
126
- // The team owns its worktree. Its teamless stretch starts over when it is gone.
127
- if (prior)
128
- prior.teamlessSince = Number.POSITIVE_INFINITY;
129
- return null;
130
- }
131
- const paths = [...deps.listUncommittedPaths(worktreePath)].sort();
132
- if (paths.length === 0)
133
- return endEpisode(focus, deps, true);
134
- const episode = prior ?? { fingerprint: paths.join('\n'), teamlessSince: now, respawnedAt: null, recorded: false };
135
- if (episode.teamlessSince === Number.POSITIVE_INFINITY)
136
- episode.teamlessSince = now;
137
- episode.fingerprint = paths.join('\n');
138
- episodes.set(focus.focus_id, episode);
139
- if (now - episode.teamlessSince < UNCOMMITTED_WORK_GRACE_MS)
140
- return null;
141
- if (episode.respawnedAt === null) {
142
- episode.respawnedAt = now;
143
- episode.teamlessSince = now;
144
- const queued = deps.queueCodingRespawn({
145
- focusId: focus.focus_id,
146
- message: buildUncommittedWorkRespawnMessage(focus.focus_name, paths),
147
- contentHash: createHash('sha256').update(`uncommitted-work\n${focus.focus_id}\n${episode.fingerprint}`).digest('hex'),
148
- focusOverrideModel: focusPipelineModelForPass(focus.pipeline_config, 'coding'),
149
- });
150
- log.warn(`[uncommitted-work] "${focus.focus_name}" is armed with NO live team and ${paths.length} uncommitted path(s) in its ` +
151
- `worktree (${paths.slice(0, 5).join(', ')}${paths.length > 5 ? ', ...' : ''}) -- ` +
152
- (queued ? 'queued a coding respawn to finish and commit them' : 'a spawn directive is already queued; it will spawn the team'));
153
- return { kind: 'respawned', paths, queued };
154
- }
155
- if (episode.recorded)
156
- return null;
157
- // The respawn is still queued (a cooldown, a parked guard): give it its bounded wait.
158
- if (deps.hasQueuedSpawn(focus.focus_id) && now - episode.respawnedAt < UNCOMMITTED_WORK_RESPAWN_WAIT_MS)
159
- return null;
160
- episode.recorded = true;
161
- try {
162
- await deps.recordUncommittedWork({ organizationId, focusId: focus.focus_id, focusName: focus.focus_name, worktreePath, paths });
163
- }
164
- catch (err) {
165
- episode.recorded = false;
166
- log.warn(`[uncommitted-work] "${focus.focus_name}": recording the uncommitted work failed (retried): ${err.message}`);
167
- return null;
168
- }
169
- log.warn(`[uncommitted-work] "${focus.focus_name}": the respawn did not finish it -- still ${paths.length} uncommitted path(s) ` +
170
- 'and no live team; recorded it, naming them, on the focus deliveries (the dashboard Waiting-on line) and as a worktree-dirty observation');
171
- return { kind: 'recorded', paths };
172
- }
173
- /** Statuses whose rows never carry the stranded-work record: settled, or intent the team cannot see. */
174
- const NO_RECORD_STATUSES = new Set([
175
- DELIVERY_STATUS.DONE, DELIVERY_STATUS.CANCELLED, DELIVERY_STATUS.DRAFT, DELIVERY_STATUS.PLANNING,
176
- ]);
177
- /**
178
- * Write the OPERATOR-VISIBLE record (module header, step 2) on every cycling
179
- * delivery of the focus: gate_state.advanceHold, reason worktree_uncommitted_no_team,
180
- * naming the worktree and the paths. Returns how many rows carry it. Throws what a
181
- * read or write throws (the pass retries).
182
- */
183
- export async function recordStrandedWorkOnFocus(record, deps) {
184
- const rows = (await deps.getFocusDeliveries(record.focusId)).filter((d) => !NO_RECORD_STATUSES.has(d.executionStatus ?? ''));
185
- for (const d of rows) {
186
- await recordStrandedWork(d.id, { worktreePath: record.worktreePath, paths: record.paths }, {
187
- io: deps.gateRowIo, now: () => new Date(deps.now()).toISOString(),
188
- });
189
- }
190
- return rows.length;
191
- }
192
- /** Clear the record from every delivery of the focus that carries it. Throws what a read or write throws. */
193
- export async function clearStrandedWorkOnFocus(focusId, deps) {
194
- for (const d of await deps.getFocusDeliveries(focusId)) {
195
- await clearStrandedWork(d.id, { io: deps.gateRowIo });
196
- }
197
- }
198
- /**
199
- * File the record (module header, step 2): ONE agent-resolvable worktree-dirty
200
- * observation naming the uncommitted paths, unless a sibling worktree-dirty row
201
- * is already open for the focus. Committing or discarding the work is git work an
202
- * agent session can do, so it proposes no human act. A failed dedupe read files
203
- * (a genuine first record is not swallowed); a failed create throws to the caller.
204
- */
205
- export async function fileUncommittedWorkRecord(record, deps) {
206
- let alreadyOpen = false;
207
- try {
208
- alreadyOpen = await deps.hasOpenWorktreeDirtyEscalation(record.focusId);
209
- }
210
- catch (err) {
211
- log.warn(`[uncommitted-work] open worktree-dirty lookup failed for "${record.focusName}", filing: ${err.message}`);
212
- }
213
- if (alreadyOpen)
214
- return;
215
- await deps.createEscalation({
216
- organizationId: record.organizationId,
217
- issueId: null,
218
- reasonType: ESCALATION_REASONS.ERROR_ENCOUNTERED,
219
- disposition: ESCALATION_DISPOSITIONS.NEEDS_OPERATOR,
220
- humanAct: NO_HUMAN_ACT,
221
- escalationKind: MERGE_REFUSED_DIRTY_ESCALATION_KIND,
222
- anchor: { focusId: record.focusId },
223
- description: `Uncommitted work is stranded in the worktree of armed focus "${record.focusName}": no team is live, and a ` +
224
- `respawn to finish it did not.\n\n**Worktree:** ${record.worktreePath}\n**Uncommitted paths (${record.paths.length}):**\n` +
225
- namedPaths(record.paths).join('\n') +
226
- '\n\nUntil they are committed or discarded the gate never sees them, merge-back skips the worktree, and the focus HEAD does not move.',
227
- whatWasTried: 'The uncommitted-work backstop found the focus armed and teamless with these paths uncommitted, and queued a coding ' +
228
- 'respawn of the focus\'s lineage to commit them; the worktree is still dirty with no live team.',
229
- helpNeeded: `Inspect ${record.worktreePath}: commit what is the focus's work (with the Telora-Delivery trailer of the delivery it ` +
230
- 'belongs to) and discard what is not. This record closes itself once the worktree is clean.',
231
- });
232
- }
233
- /**
234
- * The backstop pass over one product's active focuses (module header). Returns
235
- * what it did per focus it acted on. Never throws.
236
- */
237
- export async function recoverUncommittedWork(config, deps) {
238
- const acted = [];
239
- let focuses;
240
- try {
241
- focuses = await deps.getActiveFocuses(config.organizationId, config.productId);
242
- }
243
- catch (err) {
244
- log.warn(`[uncommitted-work] pass: active focuses unreadable (retried next poll): ${err.message}`);
245
- return acted;
246
- }
247
- for (const focus of focuses) {
248
- try {
249
- const action = await checkUncommittedWork(focus, config.organizationId, deps);
250
- if (action)
251
- acted.push({ focusId: focus.focus_id, action });
252
- }
253
- catch (err) {
254
- log.warn(`[uncommitted-work] "${focus.focus_name}": check failed (retried next poll): ${err.message}`);
255
- }
256
- }
257
- return acted;
258
- }
259
- //# sourceMappingURL=uncommitted-work-backstop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uncommitted-work-backstop.js","sourceRoot":"","sources":["../../src/focus/uncommitted-work-backstop.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,yEAAyE;AACzE,gBAAgB;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEnG,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEpF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,GAAG,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;AAErD,mGAAmG;AACnG,MAA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