@openrig/cli 0.7.15 → 0.7.16

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 (402) hide show
  1. package/README.md +5 -5
  2. package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +1 -1
  3. package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +1 -1
  4. package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
  5. package/daemon/assets/plugins/openrig/README.md +26 -7
  6. package/daemon/assets/plugins/openrig/plugin.json +1 -1
  7. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  8. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  9. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/SKILL.md +4 -1
  10. package/daemon/assets/plugins/openrig-core/skills/seat-continuity-and-handover/SKILL.md +1 -1
  11. package/daemon/assets/skills/rigs/SKILL.md +105 -30
  12. package/daemon/context-packs/help/manifest.yaml +1 -1
  13. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  14. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +92 -17
  15. package/daemon/context-packs/reference/getting-started.md +9 -8
  16. package/daemon/context-packs/reference/manifest.yaml +4 -1
  17. package/daemon/context-packs/reference/product-journey-sdlc.md +348 -0
  18. package/daemon/context-packs/reference/rig-spec.md +92 -4
  19. package/daemon/context-packs/reference/whats-new.md +210 -5
  20. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  21. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  22. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  23. package/daemon/context-packs/skills/claude-compaction-restore/SKILL.md +4 -1
  24. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  25. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  26. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  27. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  28. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  29. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  30. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  31. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  32. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  66. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/seat-continuity-and-handover/SKILL.md +1 -1
  72. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  75. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  76. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  77. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  78. package/daemon/dist/adapters/claude-code-adapter.js +6 -3
  79. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  80. package/daemon/dist/adapters/codex-resume.d.ts +2 -0
  81. package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
  82. package/daemon/dist/adapters/codex-resume.js +28 -11
  83. package/daemon/dist/adapters/codex-resume.js.map +1 -1
  84. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +15 -0
  85. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  86. package/daemon/dist/adapters/codex-runtime-adapter.js +75 -28
  87. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  88. package/daemon/dist/adapters/tmux.d.ts +3 -0
  89. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  90. package/daemon/dist/adapters/tmux.js +16 -2
  91. package/daemon/dist/adapters/tmux.js.map +1 -1
  92. package/daemon/dist/build-info.js +3 -3
  93. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  94. package/daemon/dist/db/all-migrations.js +4 -0
  95. package/daemon/dist/db/all-migrations.js.map +1 -1
  96. package/daemon/dist/db/migrations/167_seat_handover_attempts.d.ts +14 -0
  97. package/daemon/dist/db/migrations/167_seat_handover_attempts.d.ts.map +1 -0
  98. package/daemon/dist/db/migrations/167_seat_handover_attempts.js +54 -0
  99. package/daemon/dist/db/migrations/167_seat_handover_attempts.js.map +1 -0
  100. package/daemon/dist/db/migrations/169_seat_runtime_home_records.d.ts +5 -0
  101. package/daemon/dist/db/migrations/169_seat_runtime_home_records.d.ts.map +1 -0
  102. package/daemon/dist/db/migrations/169_seat_runtime_home_records.js +25 -0
  103. package/daemon/dist/db/migrations/169_seat_runtime_home_records.js.map +1 -0
  104. package/daemon/dist/domain/claim-service.d.ts +1 -3
  105. package/daemon/dist/domain/claim-service.d.ts.map +1 -1
  106. package/daemon/dist/domain/claim-service.js +3 -1
  107. package/daemon/dist/domain/claim-service.js.map +1 -1
  108. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +11 -0
  109. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  110. package/daemon/dist/domain/claude-compaction-enforcer.js +83 -36
  111. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  112. package/daemon/dist/domain/codex-filesystem-preflight.d.ts +33 -0
  113. package/daemon/dist/domain/codex-filesystem-preflight.d.ts.map +1 -0
  114. package/daemon/dist/domain/codex-filesystem-preflight.js +255 -0
  115. package/daemon/dist/domain/codex-filesystem-preflight.js.map +1 -0
  116. package/daemon/dist/domain/codex-member-permissions.d.ts +23 -2
  117. package/daemon/dist/domain/codex-member-permissions.d.ts.map +1 -1
  118. package/daemon/dist/domain/codex-member-permissions.js +55 -9
  119. package/daemon/dist/domain/codex-member-permissions.js.map +1 -1
  120. package/daemon/dist/domain/codex-network-default.d.ts +13 -0
  121. package/daemon/dist/domain/codex-network-default.d.ts.map +1 -1
  122. package/daemon/dist/domain/codex-network-default.js +37 -30
  123. package/daemon/dist/domain/codex-network-default.js.map +1 -1
  124. package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -1
  125. package/daemon/dist/domain/compaction-restore-notice.js +59 -13
  126. package/daemon/dist/domain/compaction-restore-notice.js.map +1 -1
  127. package/daemon/dist/domain/destination-successor.d.ts +3 -0
  128. package/daemon/dist/domain/destination-successor.d.ts.map +1 -0
  129. package/daemon/dist/domain/destination-successor.js +49 -0
  130. package/daemon/dist/domain/destination-successor.js.map +1 -0
  131. package/daemon/dist/domain/health-passive-ceremony.d.ts +3 -0
  132. package/daemon/dist/domain/health-passive-ceremony.d.ts.map +1 -1
  133. package/daemon/dist/domain/health-passive-ceremony.js +45 -4
  134. package/daemon/dist/domain/health-passive-ceremony.js.map +1 -1
  135. package/daemon/dist/domain/hosts/fleet-scopes.d.ts +111 -0
  136. package/daemon/dist/domain/hosts/fleet-scopes.d.ts.map +1 -0
  137. package/daemon/dist/domain/hosts/fleet-scopes.js +231 -0
  138. package/daemon/dist/domain/hosts/fleet-scopes.js.map +1 -0
  139. package/daemon/dist/domain/hosts/read-through.d.ts +1 -1
  140. package/daemon/dist/domain/hosts/read-through.d.ts.map +1 -1
  141. package/daemon/dist/domain/hosts/read-through.js +4 -0
  142. package/daemon/dist/domain/hosts/read-through.js.map +1 -1
  143. package/daemon/dist/domain/native-permission-store.d.ts.map +1 -1
  144. package/daemon/dist/domain/native-permission-store.js +12 -5
  145. package/daemon/dist/domain/native-permission-store.js.map +1 -1
  146. package/daemon/dist/domain/native-process-lineage.d.ts +11 -1
  147. package/daemon/dist/domain/native-process-lineage.d.ts.map +1 -1
  148. package/daemon/dist/domain/native-process-lineage.js +25 -4
  149. package/daemon/dist/domain/native-process-lineage.js.map +1 -1
  150. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  151. package/daemon/dist/domain/native-resume-probe.js +31 -15
  152. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  153. package/daemon/dist/domain/node-launcher.d.ts +3 -0
  154. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  155. package/daemon/dist/domain/node-launcher.js +6 -0
  156. package/daemon/dist/domain/node-launcher.js.map +1 -1
  157. package/daemon/dist/domain/permission-account.d.ts.map +1 -1
  158. package/daemon/dist/domain/permission-account.js +8 -6
  159. package/daemon/dist/domain/permission-account.js.map +1 -1
  160. package/daemon/dist/domain/permission-drift.d.ts.map +1 -1
  161. package/daemon/dist/domain/permission-drift.js +1 -1
  162. package/daemon/dist/domain/permission-drift.js.map +1 -1
  163. package/daemon/dist/domain/queue-destination-check.d.ts +2 -0
  164. package/daemon/dist/domain/queue-destination-check.d.ts.map +1 -1
  165. package/daemon/dist/domain/queue-destination-check.js +8 -11
  166. package/daemon/dist/domain/queue-destination-check.js.map +1 -1
  167. package/daemon/dist/domain/queue-repository.d.ts +20 -15
  168. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  169. package/daemon/dist/domain/queue-repository.js +37 -49
  170. package/daemon/dist/domain/queue-repository.js.map +1 -1
  171. package/daemon/dist/domain/queue-transition-log.d.ts +6 -0
  172. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  173. package/daemon/dist/domain/queue-transition-log.js +9 -0
  174. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  175. package/daemon/dist/domain/queue-waiting.d.ts +4 -4
  176. package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
  177. package/daemon/dist/domain/queue-waiting.js +30 -16
  178. package/daemon/dist/domain/queue-waiting.js.map +1 -1
  179. package/daemon/dist/domain/receiver-context.js +1 -1
  180. package/daemon/dist/domain/receiver-context.js.map +1 -1
  181. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  182. package/daemon/dist/domain/restore-orchestrator.js +40 -18
  183. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  184. package/daemon/dist/domain/resume-metadata-refresher.d.ts +17 -4
  185. package/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
  186. package/daemon/dist/domain/resume-metadata-refresher.js +60 -14
  187. package/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
  188. package/daemon/dist/domain/resume-token-capture.d.ts +6 -0
  189. package/daemon/dist/domain/resume-token-capture.d.ts.map +1 -1
  190. package/daemon/dist/domain/resume-token-capture.js +14 -8
  191. package/daemon/dist/domain/resume-token-capture.js.map +1 -1
  192. package/daemon/dist/domain/rig-edge-ops.js +1 -1
  193. package/daemon/dist/domain/rig-edge-ops.js.map +1 -1
  194. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  195. package/daemon/dist/domain/rigspec-instantiator.js +6 -2
  196. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  197. package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
  198. package/daemon/dist/domain/rigspec-preflight.js +21 -1
  199. package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
  200. package/daemon/dist/domain/rosters.d.ts +19 -0
  201. package/daemon/dist/domain/rosters.d.ts.map +1 -1
  202. package/daemon/dist/domain/rosters.js +69 -12
  203. package/daemon/dist/domain/rosters.js.map +1 -1
  204. package/daemon/dist/domain/runtime-adapter.d.ts +15 -0
  205. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  206. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  207. package/daemon/dist/domain/seat-delivery-guard.d.ts +8 -2
  208. package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
  209. package/daemon/dist/domain/seat-delivery-guard.js +38 -3
  210. package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
  211. package/daemon/dist/domain/seat-handover-attempts.d.ts +50 -0
  212. package/daemon/dist/domain/seat-handover-attempts.d.ts.map +1 -0
  213. package/daemon/dist/domain/seat-handover-attempts.js +75 -0
  214. package/daemon/dist/domain/seat-handover-attempts.js.map +1 -0
  215. package/daemon/dist/domain/seat-handover-service.d.ts +64 -1
  216. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  217. package/daemon/dist/domain/seat-handover-service.js +437 -28
  218. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  219. package/daemon/dist/domain/seat-lifecycle-service.d.ts +47 -2
  220. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  221. package/daemon/dist/domain/seat-lifecycle-service.js +48 -2
  222. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  223. package/daemon/dist/domain/seat-runtime-home-record-types.d.ts +16 -0
  224. package/daemon/dist/domain/seat-runtime-home-record-types.d.ts.map +1 -0
  225. package/daemon/dist/domain/seat-runtime-home-record-types.js +2 -0
  226. package/daemon/dist/domain/seat-runtime-home-record-types.js.map +1 -0
  227. package/daemon/dist/domain/seat-runtime-home-record.d.ts +173 -0
  228. package/daemon/dist/domain/seat-runtime-home-record.d.ts.map +1 -0
  229. package/daemon/dist/domain/seat-runtime-home-record.js +317 -0
  230. package/daemon/dist/domain/seat-runtime-home-record.js.map +1 -0
  231. package/daemon/dist/domain/seat-runtime-switch-service.d.ts +7 -0
  232. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  233. package/daemon/dist/domain/seat-runtime-switch-service.js +47 -2
  234. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  235. package/daemon/dist/domain/seat-skill-storage.d.ts +16 -1
  236. package/daemon/dist/domain/seat-skill-storage.d.ts.map +1 -1
  237. package/daemon/dist/domain/seat-skill-storage.js +178 -1
  238. package/daemon/dist/domain/seat-skill-storage.js.map +1 -1
  239. package/daemon/dist/domain/session-transport.d.ts +1 -0
  240. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  241. package/daemon/dist/domain/session-transport.js +6 -2
  242. package/daemon/dist/domain/session-transport.js.map +1 -1
  243. package/daemon/dist/domain/skill-catalog.d.ts +3 -0
  244. package/daemon/dist/domain/skill-catalog.d.ts.map +1 -1
  245. package/daemon/dist/domain/skill-catalog.js +7 -3
  246. package/daemon/dist/domain/skill-catalog.js.map +1 -1
  247. package/daemon/dist/domain/snapshot-capture.d.ts.map +1 -1
  248. package/daemon/dist/domain/snapshot-capture.js +5 -0
  249. package/daemon/dist/domain/snapshot-capture.js.map +1 -1
  250. package/daemon/dist/domain/successor-session-launcher.d.ts +16 -0
  251. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  252. package/daemon/dist/domain/successor-session-launcher.js +70 -38
  253. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  254. package/daemon/dist/domain/types.d.ts +34 -1
  255. package/daemon/dist/domain/types.d.ts.map +1 -1
  256. package/daemon/dist/domain/types.js.map +1 -1
  257. package/daemon/dist/domain/user-settings/settings-browser.d.ts.map +1 -1
  258. package/daemon/dist/domain/user-settings/settings-browser.js +3 -1
  259. package/daemon/dist/domain/user-settings/settings-browser.js.map +1 -1
  260. package/daemon/dist/domain/workflow-exception-escalation.d.ts.map +1 -1
  261. package/daemon/dist/domain/workflow-exception-escalation.js +13 -8
  262. package/daemon/dist/domain/workflow-exception-escalation.js.map +1 -1
  263. package/daemon/dist/domain/workflow-instance-store.d.ts +11 -0
  264. package/daemon/dist/domain/workflow-instance-store.d.ts.map +1 -1
  265. package/daemon/dist/domain/workflow-instance-store.js +35 -0
  266. package/daemon/dist/domain/workflow-instance-store.js.map +1 -1
  267. package/daemon/dist/domain/workflow-projector.d.ts +7 -0
  268. package/daemon/dist/domain/workflow-projector.d.ts.map +1 -1
  269. package/daemon/dist/domain/workflow-projector.js +202 -91
  270. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  271. package/daemon/dist/domain/workflow-runtime.d.ts +7 -1
  272. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  273. package/daemon/dist/domain/workflow-runtime.js +116 -26
  274. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  275. package/daemon/dist/lib/pane-envelope.d.ts.map +1 -1
  276. package/daemon/dist/lib/pane-envelope.js +12 -7
  277. package/daemon/dist/lib/pane-envelope.js.map +1 -1
  278. package/daemon/dist/routes/compaction.d.ts.map +1 -1
  279. package/daemon/dist/routes/compaction.js +6 -3
  280. package/daemon/dist/routes/compaction.js.map +1 -1
  281. package/daemon/dist/routes/queue.d.ts.map +1 -1
  282. package/daemon/dist/routes/queue.js +44 -27
  283. package/daemon/dist/routes/queue.js.map +1 -1
  284. package/daemon/dist/routes/scopes.d.ts.map +1 -1
  285. package/daemon/dist/routes/scopes.js +102 -19
  286. package/daemon/dist/routes/scopes.js.map +1 -1
  287. package/daemon/dist/routes/seat.d.ts.map +1 -1
  288. package/daemon/dist/routes/seat.js +50 -2
  289. package/daemon/dist/routes/seat.js.map +1 -1
  290. package/daemon/dist/routes/sessions.d.ts.map +1 -1
  291. package/daemon/dist/routes/sessions.js +54 -10
  292. package/daemon/dist/routes/sessions.js.map +1 -1
  293. package/daemon/dist/routes/startup.d.ts.map +1 -1
  294. package/daemon/dist/routes/startup.js +116 -18
  295. package/daemon/dist/routes/startup.js.map +1 -1
  296. package/daemon/dist/routes/transport.d.ts.map +1 -1
  297. package/daemon/dist/routes/transport.js +36 -2
  298. package/daemon/dist/routes/transport.js.map +1 -1
  299. package/daemon/dist/routes/watchdog.d.ts.map +1 -1
  300. package/daemon/dist/routes/watchdog.js +7 -1
  301. package/daemon/dist/routes/watchdog.js.map +1 -1
  302. package/daemon/dist/routes/workflow.d.ts.map +1 -1
  303. package/daemon/dist/routes/workflow.js +22 -4
  304. package/daemon/dist/routes/workflow.js.map +1 -1
  305. package/daemon/dist/startup.d.ts.map +1 -1
  306. package/daemon/dist/startup.js +105 -37
  307. package/daemon/dist/startup.js.map +1 -1
  308. package/daemon/docs/reference/agent-startup-guide.md +87 -0
  309. package/daemon/docs/reference/daemon-http-clients.md +1 -0
  310. package/daemon/docs/reference/developing.md +1 -1
  311. package/daemon/docs/reference/gateway-participants.md +5 -3
  312. package/daemon/docs/reference/getting-started.md +9 -8
  313. package/daemon/docs/reference/quickstart.md +2 -2
  314. package/daemon/docs/reference/rig-spec.md +92 -4
  315. package/daemon/docs/reference/rosters.md +26 -0
  316. package/daemon/docs/reference/seat-delivery.md +7 -1
  317. package/daemon/docs/reference/whats-new.md +210 -5
  318. package/dist/build-info.js +3 -3
  319. package/dist/client.d.ts +7 -3
  320. package/dist/client.d.ts.map +1 -1
  321. package/dist/client.js +11 -2
  322. package/dist/client.js.map +1 -1
  323. package/dist/commands/launch.d.ts.map +1 -1
  324. package/dist/commands/launch.js +8 -0
  325. package/dist/commands/launch.js.map +1 -1
  326. package/dist/commands/mcp.d.ts.map +1 -1
  327. package/dist/commands/mcp.js +18 -1
  328. package/dist/commands/mcp.js.map +1 -1
  329. package/dist/commands/ps.d.ts.map +1 -1
  330. package/dist/commands/ps.js +11 -5
  331. package/dist/commands/ps.js.map +1 -1
  332. package/dist/commands/queue.d.ts.map +1 -1
  333. package/dist/commands/queue.js +6 -2
  334. package/dist/commands/queue.js.map +1 -1
  335. package/dist/commands/roster.d.ts +4 -2
  336. package/dist/commands/roster.d.ts.map +1 -1
  337. package/dist/commands/roster.js +2 -2
  338. package/dist/commands/roster.js.map +1 -1
  339. package/dist/commands/seat.d.ts +2 -0
  340. package/dist/commands/seat.d.ts.map +1 -1
  341. package/dist/commands/seat.js +198 -11
  342. package/dist/commands/seat.js.map +1 -1
  343. package/dist/commands/send.d.ts.map +1 -1
  344. package/dist/commands/send.js +31 -6
  345. package/dist/commands/send.js.map +1 -1
  346. package/dist/commands/walk.d.ts.map +1 -1
  347. package/dist/commands/walk.js +4 -0
  348. package/dist/commands/walk.js.map +1 -1
  349. package/dist/commands/workflow.d.ts.map +1 -1
  350. package/dist/commands/workflow.js +25 -1
  351. package/dist/commands/workflow.js.map +1 -1
  352. package/dist/mcp-http.d.ts +3 -0
  353. package/dist/mcp-http.d.ts.map +1 -1
  354. package/dist/mcp-http.js +13 -0
  355. package/dist/mcp-http.js.map +1 -1
  356. package/dist/mcp-server.d.ts +9 -2
  357. package/dist/mcp-server.d.ts.map +1 -1
  358. package/dist/mcp-server.js +243 -64
  359. package/dist/mcp-server.js.map +1 -1
  360. package/package.json +1 -1
  361. package/tui/dist/commands/registry.d.ts.map +1 -1
  362. package/tui/dist/commands/registry.js +1 -0
  363. package/tui/dist/commands/registry.js.map +1 -1
  364. package/tui/dist/crash-cart/start-daemon.d.ts.map +1 -1
  365. package/tui/dist/crash-cart/start-daemon.js +4 -2
  366. package/tui/dist/crash-cart/start-daemon.js.map +1 -1
  367. package/tui/dist/daemon-client.d.ts +9 -0
  368. package/tui/dist/daemon-client.d.ts.map +1 -1
  369. package/tui/dist/daemon-client.js +40 -0
  370. package/tui/dist/daemon-client.js.map +1 -1
  371. package/tui/dist/hydrate.d.ts +1 -1
  372. package/tui/dist/hydrate.d.ts.map +1 -1
  373. package/tui/dist/hydrate.js +12 -0
  374. package/tui/dist/hydrate.js.map +1 -1
  375. package/tui/dist/main.js +3 -0
  376. package/tui/dist/main.js.map +1 -1
  377. package/tui/dist/page-read.d.ts.map +1 -1
  378. package/tui/dist/page-read.js +2 -1
  379. package/tui/dist/page-read.js.map +1 -1
  380. package/tui/dist/render.d.ts.map +1 -1
  381. package/tui/dist/render.js +4 -1
  382. package/tui/dist/render.js.map +1 -1
  383. package/tui/dist/scopes/fleet-scopes-model.d.ts +73 -0
  384. package/tui/dist/scopes/fleet-scopes-model.d.ts.map +1 -0
  385. package/tui/dist/scopes/fleet-scopes-model.js +102 -0
  386. package/tui/dist/scopes/fleet-scopes-model.js.map +1 -0
  387. package/tui/dist/scopes/scopes-model.d.ts +2 -0
  388. package/tui/dist/scopes/scopes-model.d.ts.map +1 -1
  389. package/tui/dist/scopes/scopes-model.js +7 -4
  390. package/tui/dist/scopes/scopes-model.js.map +1 -1
  391. package/tui/dist/sections.d.ts.map +1 -1
  392. package/tui/dist/sections.js +5 -0
  393. package/tui/dist/sections.js.map +1 -1
  394. package/tui/dist/startup.d.ts +5 -0
  395. package/tui/dist/startup.d.ts.map +1 -1
  396. package/tui/dist/startup.js +12 -0
  397. package/tui/dist/startup.js.map +1 -1
  398. package/tui/dist/state.d.ts.map +1 -1
  399. package/tui/dist/state.js +12 -5
  400. package/tui/dist/state.js.map +1 -1
  401. package/tui/dist/types.d.ts +16 -1
  402. package/tui/dist/types.d.ts.map +1 -1
@@ -28,7 +28,7 @@ import { selectRoleSeat } from "./workflow-role-resolver.js";
28
28
  import { roleResolutionContext, tryResolveRoleByCapability, } from "./workflow-role-context.js";
29
29
  import { packetScopeTags } from "./workflow-scope.js";
30
30
  import { classifyFailureOccurrence, classifyGateTrip, workflowExceptionTags } from "./workflow-exception.js";
31
- import { newQitemId, QueueRepositoryError } from "./queue-repository.js";
31
+ import { isTerminalState, newQitemId, QueueRepositoryError } from "./queue-repository.js";
32
32
  import { resolveExceptionRoute } from "./workflow-exception-router.js";
33
33
  import { workflowHumanDestination } from "./workflow-human-destination.js";
34
34
  import { disarmWorkflowKeepalive, ensureWorkflowKeepaliveArmed, } from "./workflow-keepalive-arming.js";
@@ -106,6 +106,39 @@ export class WorkflowProjectorError extends Error {
106
106
  this.name = "WorkflowProjectorError";
107
107
  }
108
108
  }
109
+ /** The projector's own trail record for a projection whose frontier packet the queue had already closed (an ordinary
110
+ * queue handoff moved the work on): the caller's whole intent, the queue state found and the next packets. The exit and
111
+ * next hop were recorded on the workflow, and the queue row wasn't written. project() never stores a caller's value
112
+ * for this key, so only the projector writes it. */
113
+ const QUEUE_ROW_ALREADY_CLOSED = "queue_row_already_closed";
114
+ function alreadyClosedRecord(input, state, nextQitemIds, nextStepIds) {
115
+ return { state, exit: input.exit, actor: input.actorSession, result_note: input.resultNote ?? null,
116
+ blocked_on: input.blockedOn ?? null, next_owner: input.nextOwnerSession ?? null, evidence: input.closureEvidence ?? null,
117
+ next_qitem_ids: nextQitemIds, next_step_ids: nextStepIds };
118
+ }
119
+ /** The record, when the trail evidence holds a well-formed one; anything else reads as none. */
120
+ function readAlreadyClosedRecord(evidence) {
121
+ const value = evidence?.[QUEUE_ROW_ALREADY_CLOSED];
122
+ if (!value || typeof value !== "object" || Array.isArray(value))
123
+ return null;
124
+ const r = value;
125
+ const text = (v) => typeof v === "string";
126
+ const textOrNull = (v) => v === null || text(v);
127
+ const ids = (v) => Array.isArray(v) && v.every(text);
128
+ const objectOrNull = (v) => v === null || (typeof v === "object" && !Array.isArray(v));
129
+ return text(r.state) && isTerminalState(r.state) && text(r.exit) && text(r.actor) && textOrNull(r.result_note)
130
+ && textOrNull(r.blocked_on) && textOrNull(r.next_owner) && objectOrNull(r.evidence) && ids(r.next_qitem_ids)
131
+ && ids(r.next_step_ids) ? r : null;
132
+ }
133
+ /** The caller repeats the recorded projection exactly: the same exit, actor, result note, blocker, next owner and evidence. */
134
+ function sameIntent(record, input) {
135
+ return record.exit === input.exit && record.actor === input.actorSession && record.result_note === (input.resultNote ?? null)
136
+ && record.blocked_on === (input.blockedOn ?? null) && record.next_owner === (input.nextOwnerSession ?? null)
137
+ && isDeepEqual(record.evidence, input.closureEvidence ?? null);
138
+ }
139
+ function alreadyClosedNotice(packetId, state, exit) {
140
+ return `packet ${packetId} was already ${state} in the queue, so the ${exit} exit was recorded on the workflow without writing its queue row`;
141
+ }
109
142
  export class WorkflowProjector {
110
143
  db;
111
144
  eventBus;
@@ -146,7 +179,21 @@ export class WorkflowProjector {
146
179
  * call site.
147
180
  */
148
181
  async project(input) {
182
+ // The already-closed record's key is the projector's own: a value a caller supplies for it isn't stored or trusted.
183
+ const evidence = input.closureEvidence;
184
+ if (!evidence || !(QUEUE_ROW_ALREADY_CLOSED in evidence))
185
+ return this.projectStep(input);
186
+ const { [QUEUE_ROW_ALREADY_CLOSED]: _reserved, ...callerEvidence } = evidence;
187
+ const result = await this.projectStep({ ...input, closureEvidence: callerEvidence });
188
+ return { ...result, advisories: [...(result.advisories ?? []),
189
+ `closure evidence key ${QUEUE_ROW_ALREADY_CLOSED} is the projector's own, so the value supplied for it wasn't stored`] };
190
+ }
191
+ async projectStep(input) {
149
192
  const instance = this.instanceStore.getByIdOrThrow(input.instanceId);
193
+ // The same whole intent again on a packet that was already closed when it was projected: report that projection.
194
+ const replay = this.alreadyClosedReplay(instance, input);
195
+ if (replay)
196
+ return replay;
150
197
  if (instance.status !== "active" && instance.status !== "waiting") {
151
198
  throw new WorkflowProjectorError("instance_not_active", `workflow instance ${instance.instanceId} has status ${instance.status}; only active|waiting instances accept project`, { instanceId: instance.instanceId, status: instance.status });
152
199
  }
@@ -202,6 +249,9 @@ export class WorkflowProjector {
202
249
  }
203
250
  }
204
251
  validateAcceptance(currentStep, input, instance);
252
+ // A frontier packet an ordinary queue handoff already closed: the queue refuses closing it again, and its history
253
+ // stays as recorded. The exit and next hop are still recorded on the workflow; only this row isn't written.
254
+ const alreadyClosed = isTerminalState(currentPacket.state) ? currentPacket.state : null;
205
255
  const unansweredHumanGate = (input.exit === "done" || input.exit === "handoff") &&
206
256
  currentStep.gate && isHumanSeatSession(currentStep.gate.target) &&
207
257
  currentPacket.state === "blocked" && currentPacket.blockedOn === currentStep.gate.target
@@ -221,6 +271,7 @@ export class WorkflowProjector {
221
271
  packetBinding,
222
272
  currentOwnerSession: currentPacket.destinationSession,
223
273
  unansweredHumanGate,
274
+ alreadyClosed,
224
275
  });
225
276
  }
226
277
  // Determine next step (one-hop default; multi-hop is graduation).
@@ -366,40 +417,44 @@ export class WorkflowProjector {
366
417
  resolvedNextOwner = owner;
367
418
  }
368
419
  }
420
+ if (resolvedNextOwner)
421
+ assertBoundWorkflowTarget(resolvedNextOwner, this.queueRepo);
369
422
  // 2. R1 fix (guard blocker 1): close the current packet via Phase A's
370
423
  // QueueRepository.updateWithinTransaction. This validates closure
371
424
  // (Phase A hot-potato strict-rejection invariants), persists closure
372
425
  // metadata (closure_reason, closure_target, handed_off_to / blocked_on),
373
426
  // appends queue_transitions, and emits queue.updated — all inside this
374
427
  // outer transaction. The Phase A closure authority is preserved.
375
- const closure = workflowExitToQueueClosure({ ...input, exit: effectiveExit, resultNote: effectiveResultNote }, resolvedNextOwner);
376
- const queueUpdate = this.queueRepo.updateWithinTransaction({
377
- qitemId: input.currentPacketId,
378
- actorSession: input.actorSession,
379
- identityProvenance: input.identityProvenance ?? null,
380
- viaWorkflowVerb: true,
381
- state: closure.state,
382
- closureReason: closure.closureReason,
383
- closureTarget: closure.closureTarget ?? undefined,
384
- handedOffTo: closure.handedOffTo,
385
- blockedOn: closure.blockedOn,
386
- transitionNote: [closure.transitionNote, unansweredHumanGate].filter(Boolean).join("; "),
387
- wakeMaxSeconds: effectiveExit === "waiting" && !routes ? currentStep.re_present_max_seconds : undefined,
388
- wakeProgressEvidence: input.closureEvidence,
389
- wakeAfterSeconds: effectiveExit === "waiting" && !routes
390
- ? currentStep.re_present_after_seconds
391
- : undefined,
392
- wakeMessage: effectiveExit === "waiting" && !routes && currentStep.re_present_after_seconds !== undefined
393
- ? workflowWaitWakeMessage({
394
- spec,
395
- instance,
396
- step: currentStep,
397
- packetId: input.currentPacketId,
398
- ownerSession: currentPacket.destinationSession,
399
- })
400
- : undefined,
401
- });
402
- registerEvent(queueUpdate.persistedEvent);
428
+ if (!alreadyClosed) {
429
+ const closure = workflowExitToQueueClosure({ ...input, exit: effectiveExit, resultNote: effectiveResultNote }, resolvedNextOwner);
430
+ const queueUpdate = this.queueRepo.updateWithinTransaction({
431
+ qitemId: input.currentPacketId,
432
+ actorSession: input.actorSession,
433
+ identityProvenance: input.identityProvenance ?? null,
434
+ viaWorkflowVerb: true,
435
+ state: closure.state,
436
+ closureReason: closure.closureReason,
437
+ closureTarget: closure.closureTarget ?? undefined,
438
+ handedOffTo: closure.handedOffTo,
439
+ blockedOn: closure.blockedOn,
440
+ transitionNote: [closure.transitionNote, unansweredHumanGate].filter(Boolean).join("; "),
441
+ wakeMaxSeconds: effectiveExit === "waiting" && !routes ? currentStep.re_present_max_seconds : undefined,
442
+ wakeProgressEvidence: input.closureEvidence,
443
+ wakeAfterSeconds: effectiveExit === "waiting" && !routes
444
+ ? currentStep.re_present_after_seconds
445
+ : undefined,
446
+ wakeMessage: effectiveExit === "waiting" && !routes && currentStep.re_present_after_seconds !== undefined
447
+ ? workflowWaitWakeMessage({
448
+ spec,
449
+ instance,
450
+ step: currentStep,
451
+ packetId: input.currentPacketId,
452
+ ownerSession: currentPacket.destinationSession,
453
+ })
454
+ : undefined,
455
+ });
456
+ registerEvent(queueUpdate.persistedEvent);
457
+ }
403
458
  // 3. If this close routes (structural handoff OR branch-mapped
404
459
  // exit): create the next-step qitem in the same txn. A gated
405
460
  // target compiles to the gate item (FR-5) — the SHIPPED write
@@ -519,6 +574,9 @@ export class WorkflowProjector {
519
574
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, holdMs);
520
575
  }
521
576
  // 4. Append step trail entry (prior + next ids).
577
+ if (alreadyClosed) {
578
+ effectiveClosureEvidence = { ...(effectiveClosureEvidence ?? {}), [QUEUE_ROW_ALREADY_CLOSED]: alreadyClosedRecord(input, alreadyClosed, nextQitemId ? [nextQitemId] : [], nextStepId ? [nextStepId] : []) };
579
+ }
522
580
  this.trailLog.record({
523
581
  instanceId: instance.instanceId,
524
582
  stepId: currentStep.id,
@@ -716,7 +774,33 @@ export class WorkflowProjector {
716
774
  nextOwnerSession,
717
775
  nextStepId,
718
776
  emittedEventTypes: persistedEvents.map((e) => e.type),
719
- ...(unansweredHumanGate ? { advisories: [unansweredHumanGate] } : {}),
777
+ ...withAdvisories([unansweredHumanGate, alreadyClosed ? alreadyClosedNotice(input.currentPacketId, alreadyClosed, input.exit) : undefined]),
778
+ };
779
+ }
780
+ /** A repeat, with the same whole intent, of the latest projection recorded on a packet the queue had already closed
781
+ * (and still has): the same result, read from that projection's trail record, with nothing written. Otherwise null. */
782
+ alreadyClosedReplay(instance, input) {
783
+ const packet = this.queueRepo.getById(input.currentPacketId);
784
+ if (!packet || !isTerminalState(packet.state))
785
+ return null;
786
+ const entry = this.trailLog.listForInstanceInAppendOrder(instance.instanceId)
787
+ .filter((candidate) => candidate.priorQitemId === input.currentPacketId).at(-1);
788
+ const recorded = readAlreadyClosedRecord(entry?.closureEvidence);
789
+ if (!entry || !recorded || !sameIntent(recorded, input))
790
+ return null;
791
+ const nextQitemId = recorded.next_qitem_ids[0] ?? null;
792
+ return {
793
+ instance,
794
+ closurePriorPacketId: input.currentPacketId,
795
+ closureReason: entry.closureReason,
796
+ nextQitemId,
797
+ nextOwnerSession: nextQitemId ? this.queueRepo.getById(nextQitemId)?.destinationSession ?? null : null,
798
+ nextStepId: recorded.next_step_ids[0] ?? null,
799
+ nextQitemIds: recorded.next_qitem_ids,
800
+ nextStepIds: recorded.next_step_ids,
801
+ emittedEventTypes: [],
802
+ absorbedReplay: true,
803
+ advisories: [alreadyClosedNotice(input.currentPacketId, recorded.state, input.exit)],
720
804
  };
721
805
  }
722
806
  /** Failure, owning task and wake commit together on both executor paths.
@@ -750,37 +834,45 @@ export class WorkflowProjector {
750
834
  `evidence: ${evidenceRef}\n` +
751
835
  `resolve: diagnose via the trace above, then \`rig workflow resume ${instance.instanceId}${occurrenceId ? ` --occurrence ${occurrenceId}` : ""} [--decision <text>]\` re-drives from this step (completed steps never re-run).`;
752
836
  // Routed to the person, a failed workflow step is an approval whose wait costs now: alert them.
753
- const createExceptionItem = (destination, tier, toPerson) => this.queueRepo.createWithinTransaction({
754
- sourceSession: input.actorSession,
755
- identityProvenance: input.identityProvenance ?? null,
756
- destinationSession: destination,
757
- body: itemBody,
758
- priority: "urgent",
759
- tier,
760
- tags: [...workflowExceptionTags(exception.identity), ...packetScopeTags(instance, currentStep.id)],
761
- summary: exception.reason,
762
- evidenceRef,
763
- chainOfRecord: [input.currentPacketId],
764
- ...(toPerson ? { humanAlert: true } : {}),
765
- });
837
+ const createExceptionItem = (destination, tier, toPerson) => {
838
+ assertBoundWorkflowTarget(destination, this.queueRepo);
839
+ return this.queueRepo.createWithinTransaction({
840
+ sourceSession: input.actorSession,
841
+ identityProvenance: input.identityProvenance ?? null,
842
+ destinationSession: destination,
843
+ body: itemBody,
844
+ priority: "urgent",
845
+ tier,
846
+ tags: [...workflowExceptionTags(exception.identity), ...packetScopeTags(instance, currentStep.id)],
847
+ summary: exception.reason,
848
+ evidenceRef,
849
+ chainOfRecord: [input.currentPacketId],
850
+ ...(toPerson ? { humanAlert: true } : {}),
851
+ });
852
+ };
766
853
  let createdException;
767
- try {
768
- createdException = createExceptionItem(route.destinationSession, route.tier, route.humanRouted === true);
769
- }
770
- catch (error) {
771
- if (!(error instanceof QueueRepositoryError) || error.code !== "unknown_destination_rig" || route.humanRouted)
772
- throw error;
773
- // Only an unavailable agent rig invokes human selection. Other
774
- // admission/storage failures propagate unchanged and roll back the
775
- // close, retaining the failure+attention-item atomic contract.
854
+ if (!route.humanRouted && !this.queueRepo.acceptsDestination(route.destinationSession)) {
776
855
  createdException = createExceptionItem(workflowHumanDestination(this.exceptionDial?.humanFallbackSeat), "human-gate", true);
777
856
  }
857
+ else {
858
+ try {
859
+ createdException = createExceptionItem(route.destinationSession, route.tier, route.humanRouted === true);
860
+ }
861
+ catch (error) {
862
+ if (!(error instanceof QueueRepositoryError) || error.code !== "unknown_destination_rig" || route.humanRouted)
863
+ throw error;
864
+ // Only an unavailable agent rig invokes human selection. Other
865
+ // admission/storage failures propagate unchanged and roll back the
866
+ // close, retaining the failure+attention-item atomic contract.
867
+ createdException = createExceptionItem(workflowHumanDestination(this.exceptionDial?.humanFallbackSeat), "human-gate", true);
868
+ }
869
+ }
778
870
  registerEvent(createdException.persistedEvent);
779
871
  this.queueRepo.stageHandoffWake(createdException.qitemId, input.actorSession, createdException.destinationSession, input.identityProvenance ?? null, createdException.nudge);
780
872
  return { qitemId: createdException.qitemId, destinationSession: createdException.destinationSession, nudge: createdException.nudge };
781
873
  }
782
874
  async projectDependencyGraph(args) {
783
- const { input, instance, spec, currentStep, packetBinding, currentOwnerSession, unansweredHumanGate } = args;
875
+ const { input, instance, spec, currentStep, packetBinding, currentOwnerSession, unansweredHumanGate, alreadyClosed } = args;
784
876
  if (input.exit === "waiting" && instance.status === "waiting" && matchesStoredWaitingDecision(instance, input, currentStep.id, this.trailLog)) {
785
877
  return {
786
878
  instance,
@@ -880,44 +972,47 @@ export class WorkflowProjector {
880
972
  if (!owner) {
881
973
  throw new WorkflowProjectorError("next_owner_unresolved", `cannot resolve next owner for dependency step "${step.id}"`, { instanceId: instance.instanceId, stepId: step.id });
882
974
  }
975
+ assertBoundWorkflowTarget(owner, this.queueRepo);
883
976
  return { step, gate, owner, packetId: newQitemId() };
884
977
  });
885
- const closureOwner = ownerPlans.length === 1 ? ownerPlans[0].owner : null;
886
- const closure = effectiveExit === "handoff" && ownerPlans.length !== 1
887
- ? {
888
- state: "done",
889
- closureReason: "no-follow-on",
890
- closureTarget: null,
891
- transitionNote: `workflow graph: ${input.actorSession} completed ${currentStep.id}; ${ownerPlans.length} successors projected transactionally`,
892
- }
893
- : workflowExitToQueueClosure({ ...input, exit: effectiveExit, resultNote: effectiveResultNote }, closureOwner);
894
- const updated = this.queueRepo.updateWithinTransaction({
895
- qitemId: input.currentPacketId,
896
- actorSession: input.actorSession,
897
- identityProvenance: input.identityProvenance ?? null,
898
- viaWorkflowVerb: true,
899
- state: closure.state,
900
- closureReason: closure.closureReason,
901
- closureTarget: closure.closureTarget ?? undefined,
902
- handedOffTo: closure.handedOffTo,
903
- blockedOn: closure.blockedOn,
904
- transitionNote: [closure.transitionNote, unansweredHumanGate].filter(Boolean).join("; "),
905
- wakeMaxSeconds: effectiveExit === "waiting" && ownerPlans.length === 0 ? currentStep.re_present_max_seconds : undefined,
906
- wakeProgressEvidence: input.closureEvidence,
907
- wakeAfterSeconds: effectiveExit === "waiting" && ownerPlans.length === 0
908
- ? currentStep.re_present_after_seconds
909
- : undefined,
910
- wakeMessage: effectiveExit === "waiting" && ownerPlans.length === 0 && currentStep.re_present_after_seconds !== undefined
911
- ? workflowWaitWakeMessage({
912
- spec,
913
- instance,
914
- step: currentStep,
915
- packetId: input.currentPacketId,
916
- ownerSession: currentOwnerSession,
917
- })
918
- : undefined,
919
- });
920
- addEvent(updated.persistedEvent);
978
+ if (!alreadyClosed) {
979
+ const closureOwner = ownerPlans.length === 1 ? ownerPlans[0].owner : null;
980
+ const closure = effectiveExit === "handoff" && ownerPlans.length !== 1
981
+ ? {
982
+ state: "done",
983
+ closureReason: "no-follow-on",
984
+ closureTarget: null,
985
+ transitionNote: `workflow graph: ${input.actorSession} completed ${currentStep.id}; ${ownerPlans.length} successors projected transactionally`,
986
+ }
987
+ : workflowExitToQueueClosure({ ...input, exit: effectiveExit, resultNote: effectiveResultNote }, closureOwner);
988
+ const updated = this.queueRepo.updateWithinTransaction({
989
+ qitemId: input.currentPacketId,
990
+ actorSession: input.actorSession,
991
+ identityProvenance: input.identityProvenance ?? null,
992
+ viaWorkflowVerb: true,
993
+ state: closure.state,
994
+ closureReason: closure.closureReason,
995
+ closureTarget: closure.closureTarget ?? undefined,
996
+ handedOffTo: closure.handedOffTo,
997
+ blockedOn: closure.blockedOn,
998
+ transitionNote: [closure.transitionNote, unansweredHumanGate].filter(Boolean).join("; "),
999
+ wakeMaxSeconds: effectiveExit === "waiting" && ownerPlans.length === 0 ? currentStep.re_present_max_seconds : undefined,
1000
+ wakeProgressEvidence: input.closureEvidence,
1001
+ wakeAfterSeconds: effectiveExit === "waiting" && ownerPlans.length === 0
1002
+ ? currentStep.re_present_after_seconds
1003
+ : undefined,
1004
+ wakeMessage: effectiveExit === "waiting" && ownerPlans.length === 0 && currentStep.re_present_after_seconds !== undefined
1005
+ ? workflowWaitWakeMessage({
1006
+ spec,
1007
+ instance,
1008
+ step: currentStep,
1009
+ packetId: input.currentPacketId,
1010
+ ownerSession: currentOwnerSession,
1011
+ })
1012
+ : undefined,
1013
+ });
1014
+ addEvent(updated.persistedEvent);
1015
+ }
921
1016
  if (effectiveExit !== "waiting") {
922
1017
  this.instanceStore.removeFrontierBinding(instance.instanceId, input.currentPacketId);
923
1018
  if (this.watchdogJobsRepo) {
@@ -1025,7 +1120,11 @@ export class WorkflowProjector {
1025
1120
  stepRole: currentStep.actor_role,
1026
1121
  closedAt: evaluatedAt,
1027
1122
  closureReason: effectiveExit,
1028
- closureEvidence: { ...(effectiveClosureEvidence ?? {}), next_qitem_ids: createdPackets.map((packet) => packet.qitemId) },
1123
+ closureEvidence: {
1124
+ ...(effectiveClosureEvidence ?? {}),
1125
+ next_qitem_ids: createdPackets.map((packet) => packet.qitemId),
1126
+ ...(alreadyClosed ? { [QUEUE_ROW_ALREADY_CLOSED]: alreadyClosedRecord(input, alreadyClosed, createdPackets.map((packet) => packet.qitemId), createdPackets.map((packet) => packet.step.id)) } : {}),
1127
+ },
1029
1128
  actorSession: input.actorSession,
1030
1129
  nextQitemId: createdPackets[0]?.qitemId ?? null,
1031
1130
  priorQitemId: input.currentPacketId,
@@ -1056,7 +1155,7 @@ export class WorkflowProjector {
1056
1155
  nextQitemIds: createdPackets.map((packet) => packet.qitemId),
1057
1156
  nextStepIds: createdPackets.map((packet) => packet.step.id),
1058
1157
  emittedEventTypes: emitted.map((event) => event.type),
1059
- ...(unansweredHumanGate ? { advisories: [unansweredHumanGate] } : {}),
1158
+ ...withAdvisories([unansweredHumanGate, alreadyClosed ? alreadyClosedNotice(input.currentPacketId, alreadyClosed, input.exit) : undefined]),
1060
1159
  };
1061
1160
  }
1062
1161
  }
@@ -1101,6 +1200,10 @@ function matchesStoredWaitingDecision(instance, input, currentStepId, trailLog)
1101
1200
  return false;
1102
1201
  return isDeepEqual(storedRow.closureEvidence ?? null, input.closureEvidence ?? null);
1103
1202
  }
1203
+ function withAdvisories(notices) {
1204
+ const advisories = notices.filter((notice) => Boolean(notice));
1205
+ return advisories.length ? { advisories } : {};
1206
+ }
1104
1207
  function isDeepEqual(a, b) {
1105
1208
  if (a === b)
1106
1209
  return true;
@@ -1213,6 +1316,14 @@ function resolveRoleOnBoundRig(roleName, harness, roleCtx, stepId) {
1213
1316
  candidates: result.disqualified,
1214
1317
  });
1215
1318
  }
1319
+ /** Preserve the old topology gate for template-looking rig names. Registered
1320
+ * literal names, including archived rigs, remain recordable as on main. */
1321
+ export function assertBoundWorkflowTarget(target, queue) {
1322
+ const at = target.indexOf("@");
1323
+ if (at >= 0 && target.slice(at + 1).includes("{rig}") && !queue.acceptsDestination(target)) {
1324
+ throw new QueueRepositoryError("unknown_destination_rig", `Workflow target ${target} has an unregistered rig name containing {rig}. Bind a rig with --rig <name>, or use a concrete registered destination.`, { destinationSession: target });
1325
+ }
1326
+ }
1216
1327
  /**
1217
1328
  * Resolve a default owner for a step. v1 picks the first declared
1218
1329
  * preferred_target. OPR.0.4.6.WF2 FR-2: a step with a `harness:` pin