@openrig/cli 0.7.16 → 0.7.18

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 (817) hide show
  1. package/README.md +9 -9
  2. package/daemon/assets/onboarding/02-self-and-competent-action.md +5 -41
  3. package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +1 -1
  4. package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +1 -1
  5. package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
  6. package/daemon/assets/plugins/openrig/plugin.json +1 -1
  7. package/daemon/assets/plugins/openrig/skills/working-with-an-openrig-team/SKILL.md +22 -6
  8. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  9. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  10. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +5 -0
  11. package/daemon/assets/plugins/openrig-core/skills/messaging-the-human/SKILL.md +23 -0
  12. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +11 -0
  13. package/daemon/assets/plugins/openrig-core/skills/refocusing/scripts/trace-to-root.py +25 -5
  14. package/daemon/assets/skills/rigs/SKILL.md +95 -42
  15. package/daemon/assets/skills/rigs/references/installing-for-someone.md +47 -0
  16. package/daemon/context-packs/help/manifest.yaml +1 -1
  17. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  18. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +123 -35
  19. package/daemon/context-packs/reference/getting-started.md +8 -8
  20. package/daemon/context-packs/reference/manifest.yaml +1 -1
  21. package/daemon/context-packs/reference/rig-spec.md +166 -0
  22. package/daemon/context-packs/reference/whats-new.md +294 -6
  23. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  24. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  25. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  26. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  27. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  28. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  29. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  30. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  31. package/daemon/context-packs/skills/core/messaging-the-human/SKILL.md +23 -0
  32. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/core/openrig-software-factory/references/worked-example.md +1 -1
  39. package/daemon/context-packs/skills/core/openrig-upgrade/SKILL.md +2 -0
  40. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/core/working-with-an-openrig-team/SKILL.md +22 -6
  48. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/openrig-user/SKILL.md +11 -0
  55. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  66. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  76. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  77. package/daemon/context-packs/skills/refocusing/scripts/trace-to-root.py +25 -5
  78. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  79. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  80. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  81. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  82. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  83. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  84. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  85. package/daemon/dist/adapters/claude-code-adapter.js +52 -8
  86. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  87. package/daemon/dist/adapters/claude-resume.d.ts +2 -1
  88. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  89. package/daemon/dist/adapters/claude-resume.js +17 -7
  90. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  91. package/daemon/dist/adapters/kernel-authority.d.ts +1 -1
  92. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  93. package/daemon/dist/adapters/kernel-authority.js +22 -10
  94. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  95. package/daemon/dist/adapters/openshell-driver.d.ts +1 -0
  96. package/daemon/dist/adapters/openshell-driver.d.ts.map +1 -1
  97. package/daemon/dist/adapters/openshell-driver.js +3 -0
  98. package/daemon/dist/adapters/openshell-driver.js.map +1 -1
  99. package/daemon/dist/adapters/openshell-podman-observer.d.ts +9 -7
  100. package/daemon/dist/adapters/openshell-podman-observer.d.ts.map +1 -1
  101. package/daemon/dist/adapters/openshell-podman-observer.js +20 -3
  102. package/daemon/dist/adapters/openshell-podman-observer.js.map +1 -1
  103. package/daemon/dist/adapters/pi-runner-protocol.d.ts +43 -0
  104. package/daemon/dist/adapters/pi-runner-protocol.d.ts.map +1 -1
  105. package/daemon/dist/adapters/pi-runner-protocol.js.map +1 -1
  106. package/daemon/dist/adapters/pi-runner.d.ts +88 -5
  107. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  108. package/daemon/dist/adapters/pi-runner.js +707 -43
  109. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  110. package/daemon/dist/adapters/tmux-credential-env.d.ts +4 -0
  111. package/daemon/dist/adapters/tmux-credential-env.d.ts.map +1 -0
  112. package/daemon/dist/adapters/tmux-credential-env.js +14 -0
  113. package/daemon/dist/adapters/tmux-credential-env.js.map +1 -0
  114. package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
  115. package/daemon/dist/adapters/tmux-exec.js +4 -3
  116. package/daemon/dist/adapters/tmux-exec.js.map +1 -1
  117. package/daemon/dist/adapters/tmux-server.d.ts +2 -2
  118. package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
  119. package/daemon/dist/adapters/tmux-server.js +12 -4
  120. package/daemon/dist/adapters/tmux-server.js.map +1 -1
  121. package/daemon/dist/adapters/tmux.d.ts +223 -12
  122. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  123. package/daemon/dist/adapters/tmux.js +836 -30
  124. package/daemon/dist/adapters/tmux.js.map +1 -1
  125. package/daemon/dist/attention-surface.d.ts +4 -1
  126. package/daemon/dist/attention-surface.d.ts.map +1 -1
  127. package/daemon/dist/attention-surface.js.map +1 -1
  128. package/daemon/dist/build-info.js +3 -3
  129. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  130. package/daemon/dist/db/all-migrations.js +12 -0
  131. package/daemon/dist/db/all-migrations.js.map +1 -1
  132. package/daemon/dist/db/migrations/168_context_usage_occupant_generation.d.ts +6 -0
  133. package/daemon/dist/db/migrations/168_context_usage_occupant_generation.d.ts.map +1 -0
  134. package/daemon/dist/db/migrations/168_context_usage_occupant_generation.js +10 -0
  135. package/daemon/dist/db/migrations/168_context_usage_occupant_generation.js.map +1 -0
  136. package/daemon/dist/db/migrations/170_rig_delivery_drains.d.ts +3 -0
  137. package/daemon/dist/db/migrations/170_rig_delivery_drains.d.ts.map +1 -0
  138. package/daemon/dist/db/migrations/170_rig_delivery_drains.js +21 -0
  139. package/daemon/dist/db/migrations/170_rig_delivery_drains.js.map +1 -0
  140. package/daemon/dist/db/migrations/171_claude_auto_mode.d.ts +4 -0
  141. package/daemon/dist/db/migrations/171_claude_auto_mode.d.ts.map +1 -0
  142. package/daemon/dist/db/migrations/171_claude_auto_mode.js +9 -0
  143. package/daemon/dist/db/migrations/171_claude_auto_mode.js.map +1 -0
  144. package/daemon/dist/db/migrations/171_node_input_route.d.ts +4 -0
  145. package/daemon/dist/db/migrations/171_node_input_route.d.ts.map +1 -0
  146. package/daemon/dist/db/migrations/171_node_input_route.js +6 -0
  147. package/daemon/dist/db/migrations/171_node_input_route.js.map +1 -0
  148. package/daemon/dist/db/migrations/172_queue_return_route.d.ts +3 -0
  149. package/daemon/dist/db/migrations/172_queue_return_route.d.ts.map +1 -0
  150. package/daemon/dist/db/migrations/172_queue_return_route.js +13 -0
  151. package/daemon/dist/db/migrations/172_queue_return_route.js.map +1 -0
  152. package/daemon/dist/db/migrations/173_node_process_limits.d.ts +4 -0
  153. package/daemon/dist/db/migrations/173_node_process_limits.d.ts.map +1 -0
  154. package/daemon/dist/db/migrations/173_node_process_limits.js +6 -0
  155. package/daemon/dist/db/migrations/173_node_process_limits.js.map +1 -0
  156. package/daemon/dist/domain/activity-grants.d.ts.map +1 -1
  157. package/daemon/dist/domain/activity-grants.js +2 -0
  158. package/daemon/dist/domain/activity-grants.js.map +1 -1
  159. package/daemon/dist/domain/agent-activity-store.d.ts +36 -1
  160. package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
  161. package/daemon/dist/domain/agent-activity-store.js +192 -3
  162. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  163. package/daemon/dist/domain/agent-images/resume-token-discovery.d.ts +10 -0
  164. package/daemon/dist/domain/agent-images/resume-token-discovery.d.ts.map +1 -1
  165. package/daemon/dist/domain/agent-images/resume-token-discovery.js +21 -0
  166. package/daemon/dist/domain/agent-images/resume-token-discovery.js.map +1 -1
  167. package/daemon/dist/domain/applied-launch-observation-store.d.ts +5 -0
  168. package/daemon/dist/domain/applied-launch-observation-store.d.ts.map +1 -1
  169. package/daemon/dist/domain/applied-launch-observation-store.js +57 -21
  170. package/daemon/dist/domain/applied-launch-observation-store.js.map +1 -1
  171. package/daemon/dist/domain/builtin-startup-files.d.ts +26 -12
  172. package/daemon/dist/domain/builtin-startup-files.d.ts.map +1 -1
  173. package/daemon/dist/domain/builtin-startup-files.js +73 -34
  174. package/daemon/dist/domain/builtin-startup-files.js.map +1 -1
  175. package/daemon/dist/domain/claude-auto-mode.d.ts +64 -0
  176. package/daemon/dist/domain/claude-auto-mode.d.ts.map +1 -0
  177. package/daemon/dist/domain/claude-auto-mode.js +114 -0
  178. package/daemon/dist/domain/claude-auto-mode.js.map +1 -0
  179. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +2 -0
  180. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  181. package/daemon/dist/domain/claude-compaction-enforcer.js +11 -4
  182. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  183. package/daemon/dist/domain/claude-continuation-launch.d.ts +5 -1
  184. package/daemon/dist/domain/claude-continuation-launch.d.ts.map +1 -1
  185. package/daemon/dist/domain/claude-continuation-launch.js +51 -2
  186. package/daemon/dist/domain/claude-continuation-launch.js.map +1 -1
  187. package/daemon/dist/domain/claude-core-plugin-env.d.ts +7 -3
  188. package/daemon/dist/domain/claude-core-plugin-env.d.ts.map +1 -1
  189. package/daemon/dist/domain/claude-core-plugin-env.js +11 -8
  190. package/daemon/dist/domain/claude-core-plugin-env.js.map +1 -1
  191. package/daemon/dist/domain/codex-daemon-support.d.ts.map +1 -1
  192. package/daemon/dist/domain/codex-daemon-support.js +6 -1
  193. package/daemon/dist/domain/codex-daemon-support.js.map +1 -1
  194. package/daemon/dist/domain/codex-thread-id.d.ts +13 -0
  195. package/daemon/dist/domain/codex-thread-id.d.ts.map +1 -1
  196. package/daemon/dist/domain/codex-thread-id.js +132 -9
  197. package/daemon/dist/domain/codex-thread-id.js.map +1 -1
  198. package/daemon/dist/domain/community-harness-launch-result.d.ts +2 -0
  199. package/daemon/dist/domain/community-harness-launch-result.d.ts.map +1 -1
  200. package/daemon/dist/domain/community-harness-launch-result.js +5 -1
  201. package/daemon/dist/domain/community-harness-launch-result.js.map +1 -1
  202. package/daemon/dist/domain/connection-contract.d.ts +91 -0
  203. package/daemon/dist/domain/connection-contract.d.ts.map +1 -1
  204. package/daemon/dist/domain/connection-contract.js +75 -1
  205. package/daemon/dist/domain/connection-contract.js.map +1 -1
  206. package/daemon/dist/domain/context-usage-store.d.ts +16 -2
  207. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  208. package/daemon/dist/domain/context-usage-store.js +70 -15
  209. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  210. package/daemon/dist/domain/current-work.d.ts +11 -1
  211. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  212. package/daemon/dist/domain/current-work.js +107 -12
  213. package/daemon/dist/domain/current-work.js.map +1 -1
  214. package/daemon/dist/domain/cwd-resolution.d.ts +2 -0
  215. package/daemon/dist/domain/cwd-resolution.d.ts.map +1 -1
  216. package/daemon/dist/domain/cwd-resolution.js +7 -2
  217. package/daemon/dist/domain/cwd-resolution.js.map +1 -1
  218. package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
  219. package/daemon/dist/domain/draft-aware-delivery.js +5 -1
  220. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
  221. package/daemon/dist/domain/environment-lifecycle.d.ts +15 -0
  222. package/daemon/dist/domain/environment-lifecycle.d.ts.map +1 -1
  223. package/daemon/dist/domain/environment-lifecycle.js +22 -4
  224. package/daemon/dist/domain/environment-lifecycle.js.map +1 -1
  225. package/daemon/dist/domain/errors.d.ts +4 -0
  226. package/daemon/dist/domain/errors.d.ts.map +1 -1
  227. package/daemon/dist/domain/errors.js +7 -0
  228. package/daemon/dist/domain/errors.js.map +1 -1
  229. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  230. package/daemon/dist/domain/execution-view.js +8 -1
  231. package/daemon/dist/domain/execution-view.js.map +1 -1
  232. package/daemon/dist/domain/existing-rig-restore.d.ts +2 -0
  233. package/daemon/dist/domain/existing-rig-restore.d.ts.map +1 -1
  234. package/daemon/dist/domain/existing-rig-restore.js +1 -0
  235. package/daemon/dist/domain/existing-rig-restore.js.map +1 -1
  236. package/daemon/dist/domain/expected-conversation.d.ts.map +1 -1
  237. package/daemon/dist/domain/expected-conversation.js +26 -11
  238. package/daemon/dist/domain/expected-conversation.js.map +1 -1
  239. package/daemon/dist/domain/gateway/destination-resolver.d.ts +4 -0
  240. package/daemon/dist/domain/gateway/destination-resolver.d.ts.map +1 -1
  241. package/daemon/dist/domain/gateway/destination-resolver.js +10 -3
  242. package/daemon/dist/domain/gateway/destination-resolver.js.map +1 -1
  243. package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts +3 -1
  244. package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
  245. package/daemon/dist/domain/gateway/operator-delivery-engine.js +120 -6
  246. package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
  247. package/daemon/dist/domain/gateway/slack/capabilities.d.ts +9 -1
  248. package/daemon/dist/domain/gateway/slack/capabilities.d.ts.map +1 -1
  249. package/daemon/dist/domain/gateway/slack/capabilities.js +6 -1
  250. package/daemon/dist/domain/gateway/slack/capabilities.js.map +1 -1
  251. package/daemon/dist/domain/gateway/slack/inbound-admission.js +1 -1
  252. package/daemon/dist/domain/gateway/slack/inbound-admission.js.map +1 -1
  253. package/daemon/dist/domain/gateway/slack/inbound.d.ts +4 -0
  254. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  255. package/daemon/dist/domain/gateway/slack/inbound.js +15 -1
  256. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  257. package/daemon/dist/domain/gateway/slack/manifest.d.ts +5 -1
  258. package/daemon/dist/domain/gateway/slack/manifest.d.ts.map +1 -1
  259. package/daemon/dist/domain/gateway/slack/manifest.js +12 -3
  260. package/daemon/dist/domain/gateway/slack/manifest.js.map +1 -1
  261. package/daemon/dist/domain/gateway/slack/message.d.ts +1 -0
  262. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  263. package/daemon/dist/domain/gateway/slack/message.js +4 -1
  264. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  265. package/daemon/dist/domain/gateway/slack/queue-access.d.ts +2 -0
  266. package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
  267. package/daemon/dist/domain/gateway/slack/queue-access.js +1 -0
  268. package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
  269. package/daemon/dist/domain/gateway/slack/settled-asks.d.ts.map +1 -1
  270. package/daemon/dist/domain/gateway/slack/settled-asks.js +6 -5
  271. package/daemon/dist/domain/gateway/slack/settled-asks.js.map +1 -1
  272. package/daemon/dist/domain/gateway/slack/slack-api.d.ts +1 -0
  273. package/daemon/dist/domain/gateway/slack/slack-api.d.ts.map +1 -1
  274. package/daemon/dist/domain/gateway/slack/slack-api.js +7 -2
  275. package/daemon/dist/domain/gateway/slack/slack-api.js.map +1 -1
  276. package/daemon/dist/domain/harness-not-started-notice.d.ts +36 -0
  277. package/daemon/dist/domain/harness-not-started-notice.d.ts.map +1 -0
  278. package/daemon/dist/domain/harness-not-started-notice.js +81 -0
  279. package/daemon/dist/domain/harness-not-started-notice.js.map +1 -0
  280. package/daemon/dist/domain/health-diagnosis.d.ts.map +1 -1
  281. package/daemon/dist/domain/health-diagnosis.js +4 -0
  282. package/daemon/dist/domain/health-diagnosis.js.map +1 -1
  283. package/daemon/dist/domain/hot-potato-enforcer.d.ts +1 -1
  284. package/daemon/dist/domain/input-read-diagnostic.js +1 -1
  285. package/daemon/dist/domain/input-read-diagnostic.js.map +1 -1
  286. package/daemon/dist/domain/instance-initialization.d.ts +2 -0
  287. package/daemon/dist/domain/instance-initialization.d.ts.map +1 -1
  288. package/daemon/dist/domain/instance-initialization.js +2 -1
  289. package/daemon/dist/domain/instance-initialization.js.map +1 -1
  290. package/daemon/dist/domain/member-connection.d.ts +14 -0
  291. package/daemon/dist/domain/member-connection.d.ts.map +1 -0
  292. package/daemon/dist/domain/member-connection.js +34 -0
  293. package/daemon/dist/domain/member-connection.js.map +1 -0
  294. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  295. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +1 -1
  296. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  297. package/daemon/dist/domain/model-divergence/current-model-reader.d.ts +3 -1
  298. package/daemon/dist/domain/model-divergence/current-model-reader.d.ts.map +1 -1
  299. package/daemon/dist/domain/model-divergence/current-model-reader.js +32 -7
  300. package/daemon/dist/domain/model-divergence/current-model-reader.js.map +1 -1
  301. package/daemon/dist/domain/native-model-picker.d.ts +2 -0
  302. package/daemon/dist/domain/native-model-picker.d.ts.map +1 -1
  303. package/daemon/dist/domain/native-model-picker.js +8 -2
  304. package/daemon/dist/domain/native-model-picker.js.map +1 -1
  305. package/daemon/dist/domain/native-permission-store.d.ts +6 -2
  306. package/daemon/dist/domain/native-permission-store.d.ts.map +1 -1
  307. package/daemon/dist/domain/native-permission-store.js +12 -5
  308. package/daemon/dist/domain/native-permission-store.js.map +1 -1
  309. package/daemon/dist/domain/native-resume-probe.d.ts +5 -0
  310. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  311. package/daemon/dist/domain/native-resume-probe.js +172 -21
  312. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  313. package/daemon/dist/domain/network/network-connector.d.ts.map +1 -1
  314. package/daemon/dist/domain/network/network-connector.js +16 -5
  315. package/daemon/dist/domain/network/network-connector.js.map +1 -1
  316. package/daemon/dist/domain/network/network-installations.d.ts +5 -4
  317. package/daemon/dist/domain/network/network-installations.d.ts.map +1 -1
  318. package/daemon/dist/domain/network/network-installations.js +42 -11
  319. package/daemon/dist/domain/network/network-installations.js.map +1 -1
  320. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  321. package/daemon/dist/domain/node-inventory.js +28 -0
  322. package/daemon/dist/domain/node-inventory.js.map +1 -1
  323. package/daemon/dist/domain/node-launcher.d.ts +11 -0
  324. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  325. package/daemon/dist/domain/node-launcher.js +23 -7
  326. package/daemon/dist/domain/node-launcher.js.map +1 -1
  327. package/daemon/dist/domain/occupant-invalidator.d.ts +4 -1
  328. package/daemon/dist/domain/occupant-invalidator.d.ts.map +1 -1
  329. package/daemon/dist/domain/occupant-invalidator.js +10 -2
  330. package/daemon/dist/domain/occupant-invalidator.js.map +1 -1
  331. package/daemon/dist/domain/operation-correlation.d.ts +1 -1
  332. package/daemon/dist/domain/operation-correlation.d.ts.map +1 -1
  333. package/daemon/dist/domain/operation-correlation.js +1 -1
  334. package/daemon/dist/domain/operation-correlation.js.map +1 -1
  335. package/daemon/dist/domain/outbox-handler.d.ts +50 -0
  336. package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
  337. package/daemon/dist/domain/outbox-handler.js +255 -1
  338. package/daemon/dist/domain/outbox-handler.js.map +1 -1
  339. package/daemon/dist/domain/parked-query.d.ts.map +1 -1
  340. package/daemon/dist/domain/parked-query.js +3 -1
  341. package/daemon/dist/domain/parked-query.js.map +1 -1
  342. package/daemon/dist/domain/permission-account.d.ts +28 -1
  343. package/daemon/dist/domain/permission-account.d.ts.map +1 -1
  344. package/daemon/dist/domain/permission-account.js +55 -11
  345. package/daemon/dist/domain/permission-account.js.map +1 -1
  346. package/daemon/dist/domain/permission-drift.d.ts +2 -0
  347. package/daemon/dist/domain/permission-drift.d.ts.map +1 -1
  348. package/daemon/dist/domain/permission-drift.js.map +1 -1
  349. package/daemon/dist/domain/pi-compaction-request-store.d.ts +16 -0
  350. package/daemon/dist/domain/pi-compaction-request-store.d.ts.map +1 -0
  351. package/daemon/dist/domain/pi-compaction-request-store.js +40 -0
  352. package/daemon/dist/domain/pi-compaction-request-store.js.map +1 -0
  353. package/daemon/dist/domain/pi-compaction-service.d.ts +82 -0
  354. package/daemon/dist/domain/pi-compaction-service.d.ts.map +1 -0
  355. package/daemon/dist/domain/pi-compaction-service.js +229 -0
  356. package/daemon/dist/domain/pi-compaction-service.js.map +1 -0
  357. package/daemon/dist/domain/process-limits.d.ts +37 -0
  358. package/daemon/dist/domain/process-limits.d.ts.map +1 -0
  359. package/daemon/dist/domain/process-limits.js +69 -0
  360. package/daemon/dist/domain/process-limits.js.map +1 -0
  361. package/daemon/dist/domain/process-table.d.ts +9 -0
  362. package/daemon/dist/domain/process-table.d.ts.map +1 -1
  363. package/daemon/dist/domain/process-table.js +21 -4
  364. package/daemon/dist/domain/process-table.js.map +1 -1
  365. package/daemon/dist/domain/proof/judgments.d.ts +7 -0
  366. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  367. package/daemon/dist/domain/proof/judgments.js +27 -1
  368. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  369. package/daemon/dist/domain/ps-projection.d.ts +2 -1
  370. package/daemon/dist/domain/ps-projection.d.ts.map +1 -1
  371. package/daemon/dist/domain/ps-projection.js +6 -1
  372. package/daemon/dist/domain/ps-projection.js.map +1 -1
  373. package/daemon/dist/domain/queue-erasure.d.ts +18 -7
  374. package/daemon/dist/domain/queue-erasure.d.ts.map +1 -1
  375. package/daemon/dist/domain/queue-erasure.js +270 -41
  376. package/daemon/dist/domain/queue-erasure.js.map +1 -1
  377. package/daemon/dist/domain/queue-repository.d.ts +81 -16
  378. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  379. package/daemon/dist/domain/queue-repository.js +325 -76
  380. package/daemon/dist/domain/queue-repository.js.map +1 -1
  381. package/daemon/dist/domain/queue-stuck-sweep.d.ts +3 -0
  382. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  383. package/daemon/dist/domain/queue-stuck-sweep.js +90 -30
  384. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  385. package/daemon/dist/domain/queue-transition-log.d.ts +5 -3
  386. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  387. package/daemon/dist/domain/queue-transition-log.js +9 -6
  388. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  389. package/daemon/dist/domain/queue-wake-ladder.d.ts +8 -0
  390. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  391. package/daemon/dist/domain/queue-wake-ladder.js +245 -41
  392. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  393. package/daemon/dist/domain/queue-wake-repository.d.ts +2 -1
  394. package/daemon/dist/domain/queue-wake-repository.d.ts.map +1 -1
  395. package/daemon/dist/domain/queue-wake-repository.js +31 -4
  396. package/daemon/dist/domain/queue-wake-repository.js.map +1 -1
  397. package/daemon/dist/domain/restore-check-service.d.ts +23 -0
  398. package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
  399. package/daemon/dist/domain/restore-check-service.js +198 -12
  400. package/daemon/dist/domain/restore-check-service.js.map +1 -1
  401. package/daemon/dist/domain/restore-orchestrator.d.ts +64 -3
  402. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  403. package/daemon/dist/domain/restore-orchestrator.js +335 -82
  404. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  405. package/daemon/dist/domain/restore-plan-preview.d.ts +28 -1
  406. package/daemon/dist/domain/restore-plan-preview.d.ts.map +1 -1
  407. package/daemon/dist/domain/restore-plan-preview.js +17 -5
  408. package/daemon/dist/domain/restore-plan-preview.js.map +1 -1
  409. package/daemon/dist/domain/restore-preconditions.d.ts +26 -0
  410. package/daemon/dist/domain/restore-preconditions.d.ts.map +1 -1
  411. package/daemon/dist/domain/restore-preconditions.js +63 -1
  412. package/daemon/dist/domain/restore-preconditions.js.map +1 -1
  413. package/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
  414. package/daemon/dist/domain/resume-metadata-refresher.js +4 -1
  415. package/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
  416. package/daemon/dist/domain/resume-token-validation.d.ts +3 -1
  417. package/daemon/dist/domain/resume-token-validation.d.ts.map +1 -1
  418. package/daemon/dist/domain/resume-token-validation.js +6 -3
  419. package/daemon/dist/domain/resume-token-validation.js.map +1 -1
  420. package/daemon/dist/domain/return-route.d.ts +73 -0
  421. package/daemon/dist/domain/return-route.d.ts.map +1 -0
  422. package/daemon/dist/domain/return-route.js +124 -0
  423. package/daemon/dist/domain/return-route.js.map +1 -0
  424. package/daemon/dist/domain/rig-delivery-drain.d.ts +46 -0
  425. package/daemon/dist/domain/rig-delivery-drain.d.ts.map +1 -0
  426. package/daemon/dist/domain/rig-delivery-drain.js +128 -0
  427. package/daemon/dist/domain/rig-delivery-drain.js.map +1 -0
  428. package/daemon/dist/domain/rig-expansion-service.js +1 -1
  429. package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
  430. package/daemon/dist/domain/rig-lifecycle-service.d.ts.map +1 -1
  431. package/daemon/dist/domain/rig-lifecycle-service.js +4 -1
  432. package/daemon/dist/domain/rig-lifecycle-service.js.map +1 -1
  433. package/daemon/dist/domain/rig-repository.d.ts +12 -0
  434. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  435. package/daemon/dist/domain/rig-repository.js +73 -0
  436. package/daemon/dist/domain/rig-repository.js.map +1 -1
  437. package/daemon/dist/domain/rig-teardown.d.ts +22 -3
  438. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  439. package/daemon/dist/domain/rig-teardown.js +99 -20
  440. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  441. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  442. package/daemon/dist/domain/rigspec-codec.js +9 -0
  443. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  444. package/daemon/dist/domain/rigspec-exporter.d.ts +6 -0
  445. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  446. package/daemon/dist/domain/rigspec-exporter.js +30 -0
  447. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  448. package/daemon/dist/domain/rigspec-instantiator.d.ts +22 -2
  449. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  450. package/daemon/dist/domain/rigspec-instantiator.js +82 -23
  451. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  452. package/daemon/dist/domain/rigspec-preflight.d.ts +1 -1
  453. package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
  454. package/daemon/dist/domain/rigspec-preflight.js +16 -1
  455. package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
  456. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  457. package/daemon/dist/domain/rigspec-schema.js +44 -1
  458. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  459. package/daemon/dist/domain/rosters.d.ts +12 -0
  460. package/daemon/dist/domain/rosters.d.ts.map +1 -1
  461. package/daemon/dist/domain/rosters.js +17 -4
  462. package/daemon/dist/domain/rosters.js.map +1 -1
  463. package/daemon/dist/domain/runner-channel.d.ts +33 -0
  464. package/daemon/dist/domain/runner-channel.d.ts.map +1 -0
  465. package/daemon/dist/domain/runner-channel.js +179 -0
  466. package/daemon/dist/domain/runner-channel.js.map +1 -0
  467. package/daemon/dist/domain/runner-grant-launch.js +2 -2
  468. package/daemon/dist/domain/runtime-adapter.d.ts +2 -0
  469. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  470. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  471. package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -1
  472. package/daemon/dist/domain/runtime-switch-materials.js +4 -3
  473. package/daemon/dist/domain/runtime-switch-materials.js.map +1 -1
  474. package/daemon/dist/domain/scope/scope-audit.d.ts.map +1 -1
  475. package/daemon/dist/domain/scope/scope-audit.js +55 -3
  476. package/daemon/dist/domain/scope/scope-audit.js.map +1 -1
  477. package/daemon/dist/domain/seat-attention-reconciler.d.ts +6 -4
  478. package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
  479. package/daemon/dist/domain/seat-attention-reconciler.js +17 -10
  480. package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
  481. package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
  482. package/daemon/dist/domain/seat-delivery-guard.js +2 -1
  483. package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
  484. package/daemon/dist/domain/seat-handover-service.d.ts +27 -4
  485. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  486. package/daemon/dist/domain/seat-handover-service.js +209 -64
  487. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  488. package/daemon/dist/domain/seat-identity-reconciler.d.ts +8 -1
  489. package/daemon/dist/domain/seat-identity-reconciler.d.ts.map +1 -1
  490. package/daemon/dist/domain/seat-identity-reconciler.js +52 -12
  491. package/daemon/dist/domain/seat-identity-reconciler.js.map +1 -1
  492. package/daemon/dist/domain/seat-launch-environment.d.ts +3 -2
  493. package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
  494. package/daemon/dist/domain/seat-launch-environment.js +16 -4
  495. package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
  496. package/daemon/dist/domain/seat-lifecycle-service.d.ts +21 -4
  497. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  498. package/daemon/dist/domain/seat-lifecycle-service.js +68 -2
  499. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  500. package/daemon/dist/domain/seat-restart-in-place.d.ts +9 -2
  501. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  502. package/daemon/dist/domain/seat-restart-in-place.js +34 -2
  503. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  504. package/daemon/dist/domain/seat-runtime-switch-service.d.ts +4 -0
  505. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  506. package/daemon/dist/domain/seat-runtime-switch-service.js +9 -3
  507. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  508. package/daemon/dist/domain/seat-status-service.d.ts +4 -0
  509. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  510. package/daemon/dist/domain/seat-status-service.js +31 -6
  511. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  512. package/daemon/dist/domain/session-name.d.ts +13 -0
  513. package/daemon/dist/domain/session-name.d.ts.map +1 -1
  514. package/daemon/dist/domain/session-name.js +77 -0
  515. package/daemon/dist/domain/session-name.js.map +1 -1
  516. package/daemon/dist/domain/session-registry.d.ts +7 -1
  517. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  518. package/daemon/dist/domain/session-registry.js +7 -4
  519. package/daemon/dist/domain/session-registry.js.map +1 -1
  520. package/daemon/dist/domain/session-transport.d.ts +16 -3
  521. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  522. package/daemon/dist/domain/session-transport.js +161 -16
  523. package/daemon/dist/domain/session-transport.js.map +1 -1
  524. package/daemon/dist/domain/shared-conversation.d.ts +58 -0
  525. package/daemon/dist/domain/shared-conversation.d.ts.map +1 -0
  526. package/daemon/dist/domain/shared-conversation.js +98 -0
  527. package/daemon/dist/domain/shared-conversation.js.map +1 -0
  528. package/daemon/dist/domain/shared-history-selection.d.ts +1 -0
  529. package/daemon/dist/domain/shared-history-selection.d.ts.map +1 -1
  530. package/daemon/dist/domain/shared-history-selection.js +3 -1
  531. package/daemon/dist/domain/shared-history-selection.js.map +1 -1
  532. package/daemon/dist/domain/snapshot-capture.d.ts +4 -1
  533. package/daemon/dist/domain/snapshot-capture.d.ts.map +1 -1
  534. package/daemon/dist/domain/snapshot-capture.js +19 -12
  535. package/daemon/dist/domain/snapshot-capture.js.map +1 -1
  536. package/daemon/dist/domain/startup-phase-timing.d.ts +19 -0
  537. package/daemon/dist/domain/startup-phase-timing.d.ts.map +1 -0
  538. package/daemon/dist/domain/startup-phase-timing.js +23 -0
  539. package/daemon/dist/domain/startup-phase-timing.js.map +1 -0
  540. package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
  541. package/daemon/dist/domain/startup-submission-evidence.js +3 -2
  542. package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
  543. package/daemon/dist/domain/successor-session-launcher.d.ts +9 -0
  544. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  545. package/daemon/dist/domain/successor-session-launcher.js +24 -7
  546. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  547. package/daemon/dist/domain/team-operations.d.ts +6 -6
  548. package/daemon/dist/domain/team-operations.d.ts.map +1 -1
  549. package/daemon/dist/domain/team-operations.js +2 -4
  550. package/daemon/dist/domain/team-operations.js.map +1 -1
  551. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts +6 -0
  552. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts.map +1 -1
  553. package/daemon/dist/domain/terminal/herdr-app-provider.js +23 -1
  554. package/daemon/dist/domain/terminal/herdr-app-provider.js.map +1 -1
  555. package/daemon/dist/domain/terminal-policy.js +1 -1
  556. package/daemon/dist/domain/terminal-policy.js.map +1 -1
  557. package/daemon/dist/domain/types.d.ts +91 -6
  558. package/daemon/dist/domain/types.d.ts.map +1 -1
  559. package/daemon/dist/domain/types.js.map +1 -1
  560. package/daemon/dist/domain/user-settings/settings-store.d.ts +1 -1
  561. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  562. package/daemon/dist/domain/user-settings/settings-store.js +6 -0
  563. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  564. package/daemon/dist/domain/watchdog-delivery.d.ts +1 -1
  565. package/daemon/dist/domain/watchdog-delivery.d.ts.map +1 -1
  566. package/daemon/dist/domain/watchdog-delivery.js +6 -3
  567. package/daemon/dist/domain/watchdog-delivery.js.map +1 -1
  568. package/daemon/dist/domain/watchdog-jobs-repository.d.ts.map +1 -1
  569. package/daemon/dist/domain/watchdog-jobs-repository.js +1 -0
  570. package/daemon/dist/domain/watchdog-jobs-repository.js.map +1 -1
  571. package/daemon/dist/domain/watchdog-policy-engine.d.ts +9 -0
  572. package/daemon/dist/domain/watchdog-policy-engine.d.ts.map +1 -1
  573. package/daemon/dist/domain/watchdog-policy-engine.js +42 -5
  574. package/daemon/dist/domain/watchdog-policy-engine.js.map +1 -1
  575. package/daemon/dist/domain/workflow-instance-store.d.ts +3 -2
  576. package/daemon/dist/domain/workflow-instance-store.d.ts.map +1 -1
  577. package/daemon/dist/domain/workflow-instance-store.js +6 -4
  578. package/daemon/dist/domain/workflow-instance-store.js.map +1 -1
  579. package/daemon/dist/domain/workflow-projector.d.ts +48 -0
  580. package/daemon/dist/domain/workflow-projector.d.ts.map +1 -1
  581. package/daemon/dist/domain/workflow-projector.js +160 -90
  582. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  583. package/daemon/dist/domain/workflow-reconciliation.d.ts +7 -1
  584. package/daemon/dist/domain/workflow-reconciliation.d.ts.map +1 -1
  585. package/daemon/dist/domain/workflow-reconciliation.js +51 -13
  586. package/daemon/dist/domain/workflow-reconciliation.js.map +1 -1
  587. package/daemon/dist/domain/workflow-runtime.d.ts +5 -3
  588. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  589. package/daemon/dist/domain/workflow-runtime.js +48 -22
  590. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  591. package/daemon/dist/domain/workspace/default-workspace-scaffold.d.ts +7 -1
  592. package/daemon/dist/domain/workspace/default-workspace-scaffold.d.ts.map +1 -1
  593. package/daemon/dist/domain/workspace/default-workspace-scaffold.js +35 -7
  594. package/daemon/dist/domain/workspace/default-workspace-scaffold.js.map +1 -1
  595. package/daemon/dist/gateway-slack-surface.d.ts +2 -2
  596. package/daemon/dist/gateway-slack-surface.d.ts.map +1 -1
  597. package/daemon/dist/gateway-slack-surface.js +1 -1
  598. package/daemon/dist/gateway-slack-surface.js.map +1 -1
  599. package/daemon/dist/index.d.ts.map +1 -1
  600. package/daemon/dist/index.js +13 -2
  601. package/daemon/dist/index.js.map +1 -1
  602. package/daemon/dist/routes/activity.d.ts.map +1 -1
  603. package/daemon/dist/routes/activity.js +105 -2
  604. package/daemon/dist/routes/activity.js.map +1 -1
  605. package/daemon/dist/routes/agent-images.d.ts.map +1 -1
  606. package/daemon/dist/routes/agent-images.js +6 -1
  607. package/daemon/dist/routes/agent-images.js.map +1 -1
  608. package/daemon/dist/routes/attention.d.ts.map +1 -1
  609. package/daemon/dist/routes/attention.js +2 -1
  610. package/daemon/dist/routes/attention.js.map +1 -1
  611. package/daemon/dist/routes/compaction.d.ts.map +1 -1
  612. package/daemon/dist/routes/compaction.js +46 -7
  613. package/daemon/dist/routes/compaction.js.map +1 -1
  614. package/daemon/dist/routes/queue.d.ts +4 -1
  615. package/daemon/dist/routes/queue.d.ts.map +1 -1
  616. package/daemon/dist/routes/queue.js +266 -38
  617. package/daemon/dist/routes/queue.js.map +1 -1
  618. package/daemon/dist/routes/require-sender-identity.d.ts +4 -3
  619. package/daemon/dist/routes/require-sender-identity.d.ts.map +1 -1
  620. package/daemon/dist/routes/require-sender-identity.js.map +1 -1
  621. package/daemon/dist/routes/restore-check.d.ts.map +1 -1
  622. package/daemon/dist/routes/restore-check.js +18 -0
  623. package/daemon/dist/routes/restore-check.js.map +1 -1
  624. package/daemon/dist/routes/rig-delivery-drain.d.ts +3 -0
  625. package/daemon/dist/routes/rig-delivery-drain.d.ts.map +1 -0
  626. package/daemon/dist/routes/rig-delivery-drain.js +46 -0
  627. package/daemon/dist/routes/rig-delivery-drain.js.map +1 -0
  628. package/daemon/dist/routes/rigspec.d.ts.map +1 -1
  629. package/daemon/dist/routes/rigspec.js +24 -4
  630. package/daemon/dist/routes/rigspec.js.map +1 -1
  631. package/daemon/dist/routes/seat.d.ts.map +1 -1
  632. package/daemon/dist/routes/seat.js +107 -6
  633. package/daemon/dist/routes/seat.js.map +1 -1
  634. package/daemon/dist/routes/sessions.js +14 -3
  635. package/daemon/dist/routes/sessions.js.map +1 -1
  636. package/daemon/dist/routes/startup.d.ts.map +1 -1
  637. package/daemon/dist/routes/startup.js +127 -29
  638. package/daemon/dist/routes/startup.js.map +1 -1
  639. package/daemon/dist/routes/up.d.ts.map +1 -1
  640. package/daemon/dist/routes/up.js +16 -4
  641. package/daemon/dist/routes/up.js.map +1 -1
  642. package/daemon/dist/routes/watchdog.d.ts.map +1 -1
  643. package/daemon/dist/routes/watchdog.js +18 -1
  644. package/daemon/dist/routes/watchdog.js.map +1 -1
  645. package/daemon/dist/routes/workflow.js +1 -1
  646. package/daemon/dist/routes/workflow.js.map +1 -1
  647. package/daemon/dist/server.d.ts +3 -0
  648. package/daemon/dist/server.d.ts.map +1 -1
  649. package/daemon/dist/server.js +13 -0
  650. package/daemon/dist/server.js.map +1 -1
  651. package/daemon/dist/startup.d.ts.map +1 -1
  652. package/daemon/dist/startup.js +57 -16
  653. package/daemon/dist/startup.js.map +1 -1
  654. package/daemon/docs/reference/agent-startup-guide.md +5 -3
  655. package/daemon/docs/reference/community-harness-examples/dsh/README.md +8 -0
  656. package/daemon/docs/reference/community-harness-examples/dsh/openrig-dsh-runner.mjs +139 -5
  657. package/daemon/docs/reference/community-harness-presets.md +2 -0
  658. package/daemon/docs/reference/daemon-http-clients.md +123 -6
  659. package/daemon/docs/reference/getting-started.md +8 -8
  660. package/daemon/docs/reference/harness-runner-contract.md +91 -1
  661. package/daemon/docs/reference/herdr-app.md +6 -0
  662. package/daemon/docs/reference/hosted-members.md +4 -2
  663. package/daemon/docs/reference/network-connector.md +4 -3
  664. package/daemon/docs/reference/queue-erasure.md +16 -1
  665. package/daemon/docs/reference/quickstart.md +2 -2
  666. package/daemon/docs/reference/rig-spec.md +166 -0
  667. package/daemon/docs/reference/rosters.md +9 -0
  668. package/daemon/docs/reference/sdlc-conventions.md +5 -1
  669. package/daemon/docs/reference/slack-app-setup.md +39 -21
  670. package/daemon/docs/reference/whats-new.md +294 -6
  671. package/daemon/specs/agents/shared/skills/core/messaging-the-human/SKILL.md +23 -0
  672. package/daemon/specs/agents/shared/skills/core/openrig-software-factory/references/worked-example.md +1 -1
  673. package/daemon/specs/agents/shared/skills/core/openrig-upgrade/SKILL.md +2 -0
  674. package/daemon/specs/agents/shared/skills/core/working-with-an-openrig-team/SKILL.md +22 -6
  675. package/daemon/specs/rigs/launch/factory/guidance/lead-first-move.md +26 -5
  676. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +92 -18
  677. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/startup/context.md +9 -6
  678. package/daemon/specs/rigs/launch/kernel/culture/CULTURE.md +12 -0
  679. package/daemon/specs/rigs/launch/starter/guidance/lead-first-move.md +26 -5
  680. package/dist/acp/connector.js +1 -1
  681. package/dist/acp/connector.js.map +1 -1
  682. package/dist/build-info.js +3 -3
  683. package/dist/cli-error.d.ts.map +1 -1
  684. package/dist/cli-error.js +7 -1
  685. package/dist/cli-error.js.map +1 -1
  686. package/dist/client.d.ts +2 -1
  687. package/dist/client.d.ts.map +1 -1
  688. package/dist/client.js +3 -2
  689. package/dist/client.js.map +1 -1
  690. package/dist/commands/ask.d.ts.map +1 -1
  691. package/dist/commands/ask.js +92 -11
  692. package/dist/commands/ask.js.map +1 -1
  693. package/dist/commands/broadcast.js +9 -5
  694. package/dist/commands/broadcast.js.map +1 -1
  695. package/dist/commands/compact.d.ts +3 -4
  696. package/dist/commands/compact.d.ts.map +1 -1
  697. package/dist/commands/compact.js +76 -16
  698. package/dist/commands/compact.js.map +1 -1
  699. package/dist/commands/config-init-workspace.d.ts.map +1 -1
  700. package/dist/commands/config-init-workspace.js +3 -0
  701. package/dist/commands/config-init-workspace.js.map +1 -1
  702. package/dist/commands/config.d.ts.map +1 -1
  703. package/dist/commands/config.js +2 -0
  704. package/dist/commands/config.js.map +1 -1
  705. package/dist/commands/down.d.ts.map +1 -1
  706. package/dist/commands/down.js +7 -1
  707. package/dist/commands/down.js.map +1 -1
  708. package/dist/commands/environment.js +1 -1
  709. package/dist/commands/environment.js.map +1 -1
  710. package/dist/commands/export.d.ts.map +1 -1
  711. package/dist/commands/export.js +2 -1
  712. package/dist/commands/export.js.map +1 -1
  713. package/dist/commands/fork.d.ts.map +1 -1
  714. package/dist/commands/fork.js +2 -0
  715. package/dist/commands/fork.js.map +1 -1
  716. package/dist/commands/launch.d.ts.map +1 -1
  717. package/dist/commands/launch.js +11 -3
  718. package/dist/commands/launch.js.map +1 -1
  719. package/dist/commands/network.d.ts +2 -0
  720. package/dist/commands/network.d.ts.map +1 -1
  721. package/dist/commands/network.js +14 -1
  722. package/dist/commands/network.js.map +1 -1
  723. package/dist/commands/ps.d.ts +28 -0
  724. package/dist/commands/ps.d.ts.map +1 -1
  725. package/dist/commands/ps.js +76 -2
  726. package/dist/commands/ps.js.map +1 -1
  727. package/dist/commands/queue.d.ts +1 -1
  728. package/dist/commands/queue.d.ts.map +1 -1
  729. package/dist/commands/queue.js +350 -29
  730. package/dist/commands/queue.js.map +1 -1
  731. package/dist/commands/restore.d.ts.map +1 -1
  732. package/dist/commands/restore.js +6 -1
  733. package/dist/commands/restore.js.map +1 -1
  734. package/dist/commands/rig.d.ts +2 -0
  735. package/dist/commands/rig.d.ts.map +1 -1
  736. package/dist/commands/rig.js +36 -2
  737. package/dist/commands/rig.js.map +1 -1
  738. package/dist/commands/roster.d.ts +3 -0
  739. package/dist/commands/roster.d.ts.map +1 -1
  740. package/dist/commands/seat.d.ts.map +1 -1
  741. package/dist/commands/seat.js +128 -9
  742. package/dist/commands/seat.js.map +1 -1
  743. package/dist/commands/send.d.ts.map +1 -1
  744. package/dist/commands/send.js +47 -6
  745. package/dist/commands/send.js.map +1 -1
  746. package/dist/commands/setup.d.ts.map +1 -1
  747. package/dist/commands/setup.js +5 -3
  748. package/dist/commands/setup.js.map +1 -1
  749. package/dist/commands/slack.d.ts +2 -1
  750. package/dist/commands/slack.d.ts.map +1 -1
  751. package/dist/commands/slack.js +38 -2
  752. package/dist/commands/slack.js.map +1 -1
  753. package/dist/commands/terminal.d.ts.map +1 -1
  754. package/dist/commands/terminal.js +5 -5
  755. package/dist/commands/terminal.js.map +1 -1
  756. package/dist/commands/up.d.ts.map +1 -1
  757. package/dist/commands/up.js +10 -0
  758. package/dist/commands/up.js.map +1 -1
  759. package/dist/commands/workflow.d.ts.map +1 -1
  760. package/dist/commands/workflow.js +10 -4
  761. package/dist/commands/workflow.js.map +1 -1
  762. package/dist/config-store.d.ts +3 -1
  763. package/dist/config-store.d.ts.map +1 -1
  764. package/dist/config-store.js +5 -0
  765. package/dist/config-store.js.map +1 -1
  766. package/dist/daemon-lifecycle.d.ts.map +1 -1
  767. package/dist/daemon-lifecycle.js +1 -0
  768. package/dist/daemon-lifecycle.js.map +1 -1
  769. package/dist/lib/bundle-check.d.ts.map +1 -1
  770. package/dist/lib/bundle-check.js +33 -3
  771. package/dist/lib/bundle-check.js.map +1 -1
  772. package/dist/lib/model-observation.d.ts.map +1 -1
  773. package/dist/lib/model-observation.js +9 -3
  774. package/dist/lib/model-observation.js.map +1 -1
  775. package/dist/lib/scope/scope-audit.d.ts.map +1 -1
  776. package/dist/lib/scope/scope-audit.js +55 -3
  777. package/dist/lib/scope/scope-audit.js.map +1 -1
  778. package/dist/local-db.d.ts +5 -0
  779. package/dist/local-db.d.ts.map +1 -0
  780. package/dist/local-db.js +23 -0
  781. package/dist/local-db.js.map +1 -0
  782. package/dist/local-origin.d.ts.map +1 -1
  783. package/dist/local-origin.js +2 -17
  784. package/dist/local-origin.js.map +1 -1
  785. package/dist/mcp-server.d.ts.map +1 -1
  786. package/dist/mcp-server.js +170 -27
  787. package/dist/mcp-server.js.map +1 -1
  788. package/dist/person-registration-offer.d.ts.map +1 -1
  789. package/dist/person-registration-offer.js +2 -1
  790. package/dist/person-registration-offer.js.map +1 -1
  791. package/dist/sender-identity.d.ts +18 -6
  792. package/dist/sender-identity.d.ts.map +1 -1
  793. package/dist/sender-identity.js +67 -7
  794. package/dist/sender-identity.js.map +1 -1
  795. package/dist/terminal-window-rex.d.ts +1 -1
  796. package/dist/terminal-window-rex.d.ts.map +1 -1
  797. package/dist/terminal-window-rex.js +3 -2
  798. package/dist/terminal-window-rex.js.map +1 -1
  799. package/dist/terminal-window.js +3 -3
  800. package/dist/terminal-window.js.map +1 -1
  801. package/package.json +2 -2
  802. package/tui/dist/config/config-model.js +1 -1
  803. package/tui/dist/config/config-model.js.map +1 -1
  804. package/tui/dist/daemon-client.d.ts +3 -1
  805. package/tui/dist/daemon-client.d.ts.map +1 -1
  806. package/tui/dist/daemon-client.js +6 -3
  807. package/tui/dist/daemon-client.js.map +1 -1
  808. package/tui/dist/hydrate.d.ts.map +1 -1
  809. package/tui/dist/hydrate.js +31 -1
  810. package/tui/dist/hydrate.js.map +1 -1
  811. package/tui/dist/render.d.ts.map +1 -1
  812. package/tui/dist/render.js +106 -15
  813. package/tui/dist/render.js.map +1 -1
  814. package/tui/dist/types.d.ts +2 -0
  815. package/tui/dist/types.d.ts.map +1 -1
  816. package/ui/dist/assets/{index-BvUEh33d.js → index-1O1f3A7K.js} +55 -55
  817. package/ui/dist/index.html +1 -1
@@ -1,6 +1,8 @@
1
- import { PROMPT_ALERT_TAG, readWakeLadderBackstop } from "./queue-wake-ladder.js";
1
+ import { RigDeliveryDrainStore } from "./rig-delivery-drain.js";
2
+ import { PROMPT_ALERT_TAG, WAKE_ESCALATION_TAG, readWakeLadderBackstop } from "./queue-wake-ladder.js";
2
3
  import { withUrgentLine } from "./urgent-line.js";
3
4
  import { quietCustodyBackstop, quietHoldCustody } from "./quiet-hold-custody.js";
5
+ import { cooperativeReadFile, readRowsCooperatively } from "./execution-candidate-reader.js";
4
6
  import { createHash } from "node:crypto";
5
7
  import { loadHumanRegistry, registeredPeople, resolveRegisteredHumanAddress, slackSubscriptionFor, withHumanAlertTag } from "./gateway/human-registry.js";
6
8
  import { DispatchBuffer } from "./gateway/dispatch-buffer.js";
@@ -10,8 +12,8 @@ import { SeenStore } from "./gateway/slack/state-store.js";
10
12
  import { getOpenRigHome } from "../openrig-compat.js";
11
13
  import { sharedChannelAddresses } from "./gateway/participants.js";
12
14
  import { resolveExternal } from "./gateway/external-admission.js";
13
- import { QueueTransitionLog, RELAY_OWNER_NOTIFICATION_ACCEPTED_PREFIX, RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX, formatRelayOwnerNotificationAccepted, formatRelayOwnerNotificationTransportFailed, parseRelayOwnerNotificationAccepted, parseRelayOwnerNotificationTransportFailed, } from "./queue-transition-log.js";
14
- export { RELAY_OWNER_NOTIFICATION_ACCEPTED_PREFIX, RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX, formatRelayOwnerNotificationAccepted, formatRelayOwnerNotificationTransportFailed, parseRelayOwnerNotificationAccepted, parseRelayOwnerNotificationTransportFailed, };
15
+ import { QueueTransitionLog, RELAY_OWNER_NOTIFICATION_ACCEPTED_PREFIX, RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX, formatRelayOwnerNotificationAccepted, formatRelayOwnerNotificationTransportFailed, parseRelayOwnerNotificationAccepted, parseRelayOwnerNotificationTransportFailed, DEFAULT_RECENT_TRANSITIONS_LIMIT, MAX_RECENT_TRANSITIONS_LIMIT, } from "./queue-transition-log.js";
16
+ export { DEFAULT_RECENT_TRANSITIONS_LIMIT, MAX_RECENT_TRANSITIONS_LIMIT, RELAY_OWNER_NOTIFICATION_ACCEPTED_PREFIX, RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX, formatRelayOwnerNotificationAccepted, formatRelayOwnerNotificationTransportFailed, parseRelayOwnerNotificationAccepted, parseRelayOwnerNotificationTransportFailed, };
15
17
  export const MC_OPERATION_TAG_PREFIX = "mc-operation:";
16
18
  export function mcOperationTag(operation) {
17
19
  return `${MC_OPERATION_TAG_PREFIX}${operation}`;
@@ -28,10 +30,11 @@ import { isBoundTerminalSeat } from "./terminal-seat.js";
28
30
  import { renderQueueHandoffNudge } from "./queue-nudge-text.js";
29
31
  import { getSelfHostId } from "./hosts/fanout-contract.js";
30
32
  import { parseSessionName, isHumanSeatSessionRef } from "./session-name.js";
33
+ import { isEpisodeRelay, RELAY_CLAIMED_PREFIX, RELAY_FOR_PREFIX, RELAY_KEY_PREFIX, RELAY_TAG } from "./return-route.js";
31
34
  import { runnerPermissionOrigin } from "./runner-permissions.js";
32
35
  import { isHostPairingAsk } from "./hosts/pairing-ask.js";
33
36
  import { parseReplyToChoice, parseArrivalThread, parseReplyToThreadMissing, formatReplyToChoice, describeReplyToFallback, REPLY_TO_CHOICE_ACTOR } from "./reply-to-choice.js";
34
- import { classifyDestination } from "./gateway/destination-resolver.js";
37
+ import { classifyDestination, recordsNoWakeRoute } from "./gateway/destination-resolver.js";
35
38
  import { join } from "node:path";
36
39
  import { SettingsStore } from "./user-settings/settings-store.js";
37
40
  import { hostedMembersAt, hostedWakeFor, isHostedMemberAt } from "./rosters.js";
@@ -106,6 +109,8 @@ const CLAIM_OVERRIDDEN_WAKE_PREFIX = `${WAKE_INTENT_PREFIX}claim-overridden-`;
106
109
  const CLAIM_OVERRIDDEN_WAKE_END = `${WAKE_INTENT_PREFIX}claim-overridden.`;
107
110
  /** On a wake intent whose ring a hosted member's trigger accepted: recovery doesn't ring that intent again. */
108
111
  const HOSTED_WAKE_ACCEPTED_TAG = "queue:hosted-wake-accepted";
112
+ /** A first failed intent with typed no-input proof permits one return retry; a claim consumes it. */
113
+ const WAKE_PRE_INPUT_FAILURE_TAG = "queue:wake-pre-input-failure";
109
114
  const AUTO_UNPARK_BLOCKER_TAG_PREFIX = "queue:auto-unpark:blocker-ref:";
110
115
  /** The actor on the transition routeToFallback writes; the row's own history is how a later reroute finds the line it wrote. */
111
116
  const FALLBACK_ACTOR = "system:queue-fallback";
@@ -156,6 +161,12 @@ export function classifyNudgeFailure(lastNudgeResult) {
156
161
  return "unknown";
157
162
  }
158
163
  export const QUEUE_PRIORITIES = ["routine", "urgent", "critical"];
164
+ /** The result of one wake attempt: its classification and its recorded result. */
165
+ /** The prompt-clear path owns these definite no-input refusals, even during a running hook. */
166
+ function isPromptOwnedWakeRefusal(result) {
167
+ return result === "failed:target_needs_input"
168
+ || (result?.startsWith("failed:Refused:") === true && result.includes("interactive prompt"));
169
+ }
159
170
  /** `principal:v1` marks only the transitions that record the request's own action. What that action sets off elsewhere
160
171
  * (a successor's wake intent, a parked row released, a blocker moved) carries the seat's stamp, transport:v1. */
161
172
  function sideEffectProvenance(provenance) {
@@ -309,8 +320,12 @@ export function matchesRecordedHandoffTarget(qitemId, handedOffTo, closureTarget
309
320
  * Throws on database/query errors so callers can handle lookup failures with their own policies.
310
321
  */
311
322
  export function hasLinkedSuccessor(db, sourceQitemId, target) {
312
- if (successorScope?.db === db && successorScope.covers(sourceQitemId))
323
+ if (successorScope?.db === db && successorScope.covers(sourceQitemId, target))
313
324
  return successorScope.has(sourceQitemId, target);
325
+ return queryLinkedSuccessor(db, sourceQitemId, target);
326
+ }
327
+ /** hasLinkedSuccessor's own query, for one source and target, through the primary key and the destination index. */
328
+ function queryLinkedSuccessor(db, sourceQitemId, target) {
314
329
  const successor = db
315
330
  .prepare(`SELECT 1 FROM queue_items s
316
331
  WHERE (s.qitem_id = ? OR s.destination_session = ?) AND s.qitem_id != ?
@@ -331,38 +346,57 @@ let successorScope = null;
331
346
  * successor is a row whose handed_off_from is the source, or whose chain_of_record is valid JSON with the source among
332
347
  * its json_each values (compared as `value IN (...)` compares, like `value = ?`: a number or a nested value never
333
348
  * equals a text id); has() then checks qitem_id or destination_session against the target and that the successor is
334
- * not the source itself. A snapshot from its first has() until invalidate(): the caller invalidates it whenever other
335
- * code could have run. run(fn) lends it, for the synchronous fn only, to the hasLinkedSuccessor calls made inside fn
336
- * for a covered source; any other source keeps the per-row query. builtMs() is how long the build of the index as it
337
- * is now took (0 while it is not built), so a caller can tell when rebuilding after each invalidate() costs more than
338
- * it saves. */
349
+ * not the source itself. The index covers the targets each source's own row names (its closure_target, each
350
+ * comma-separated part of it, and its handed_off_to), the ones the sweep and the row's handoff advisory ask about, so the
351
+ * chain_of_record arm reads only successors whose id or destination is one of them, through the primary key and the
352
+ * destination index, instead of every row's chain. Any other source or target keeps the per-row query, so every answer is
353
+ * the per-row query's. For a covered source and target, a snapshot from its first has() until invalidate(): the caller
354
+ * invalidates it whenever other code could have run. Any other target is read as it is now. run(fn) lends it, for the synchronous fn only, to the hasLinkedSuccessor calls made inside fn for a
355
+ * covered source and target. builtMs() is how long the build of the index as it is now took (0 while it is not built),
356
+ * so a caller can tell when rebuilding after each invalidate() costs more than it saves. */
339
357
  export function createLinkedSuccessorLookup(db, sourceQitemIds) {
340
358
  const sources = new Set(sourceQitemIds);
341
- let bySource = null;
359
+ let index = null;
342
360
  let buildMs = 0;
343
361
  const build = () => {
344
362
  const startedAt = performance.now();
345
- const map = new Map();
363
+ const bySource = new Map();
364
+ const targetsOf = new Map();
346
365
  const ids = JSON.stringify([...sources]);
347
- const rows = runSyncSite("queue.linked_successors.build", () => db.prepare(`SELECT s.qitem_id, s.destination_session, s.handed_off_from AS source FROM queue_items s
348
- WHERE s.handed_off_from IN (SELECT value FROM json_each(?))
349
- UNION
350
- SELECT s.qitem_id, s.destination_session, j.value AS source FROM queue_items s, json_each(s.chain_of_record) j
351
- WHERE s.chain_of_record IS NOT NULL AND json_valid(s.chain_of_record)
352
- AND j.value IN (SELECT value FROM json_each(?))`).all(ids, ids));
353
- for (const r of rows) {
354
- const list = map.get(r.source);
355
- const entry = { qitemId: r.qitem_id, destination: r.destination_session };
356
- if (list)
357
- list.push(entry);
358
- else
359
- map.set(r.source, [entry]);
360
- }
366
+ runSyncSite("queue.linked_successors.build", () => {
367
+ const named = db.prepare(`SELECT qitem_id, closure_target, handed_off_to FROM queue_items WHERE qitem_id IN (SELECT value FROM json_each(?))`)
368
+ .all(ids);
369
+ for (const r of named) {
370
+ const own = new Set();
371
+ for (const target of [r.closure_target, ...(r.closure_target ?? "").split(",").map((part) => part.trim()), r.handed_off_to])
372
+ if (target)
373
+ own.add(target);
374
+ targetsOf.set(r.qitem_id, own);
375
+ }
376
+ const targets = JSON.stringify([...new Set([...targetsOf.values()].flatMap((own) => [...own]))]);
377
+ const rows = db.prepare(`SELECT s.qitem_id, s.destination_session, s.handed_off_from AS source FROM queue_items s
378
+ WHERE s.handed_off_from IN (SELECT value FROM json_each(?))
379
+ UNION
380
+ SELECT s.qitem_id, s.destination_session, j.value AS source FROM queue_items s, json_each(s.chain_of_record) j
381
+ WHERE (s.qitem_id IN (SELECT value FROM json_each(?)) OR s.destination_session IN (SELECT value FROM json_each(?)))
382
+ AND s.chain_of_record IS NOT NULL AND json_valid(s.chain_of_record)
383
+ AND j.value IN (SELECT value FROM json_each(?))`).all(ids, targets, targets, ids);
384
+ for (const r of rows) {
385
+ const list = bySource.get(r.source);
386
+ const entry = { qitemId: r.qitem_id, destination: r.destination_session };
387
+ if (list)
388
+ list.push(entry);
389
+ else
390
+ bySource.set(r.source, [entry]);
391
+ }
392
+ });
361
393
  buildMs = performance.now() - startedAt;
362
- return map;
394
+ return { bySource, targetsOf };
363
395
  };
364
- const has = (sourceQitemId, target) => (bySource ??= build()).get(sourceQitemId)?.some((s) => s.qitemId !== sourceQitemId && (s.qitemId === target || s.destination === target)) ?? false;
365
- const own = { db, covers: (source) => sources.has(source), has };
396
+ const covers = (sourceQitemId, target) => sources.has(sourceQitemId) && ((index ??= build()).targetsOf.get(sourceQitemId)?.has(target) ?? false);
397
+ const indexed = (sourceQitemId, target) => (index ??= build()).bySource.get(sourceQitemId)?.some((s) => s.qitemId !== sourceQitemId && (s.qitemId === target || s.destination === target)) ?? false;
398
+ const has = (sourceQitemId, target) => covers(sourceQitemId, target) ? indexed(sourceQitemId, target) : queryLinkedSuccessor(db, sourceQitemId, target);
399
+ const own = { db, covers, has: indexed };
366
400
  return {
367
401
  has,
368
402
  run: (fn) => {
@@ -377,7 +411,7 @@ export function createLinkedSuccessorLookup(db, sourceQitemIds) {
377
411
  successorScope = previous;
378
412
  }
379
413
  },
380
- invalidate: () => { bySource = null; buildMs = 0; },
414
+ invalidate: () => { index = null; buildMs = 0; },
381
415
  builtMs: () => buildMs,
382
416
  };
383
417
  }
@@ -539,6 +573,7 @@ function isWakeTimeoutSignal(s) {
539
573
  }
540
574
  export class QueueRepository {
541
575
  db;
576
+ deliveryDrains;
542
577
  transitionLog;
543
578
  eventBus;
544
579
  destinationAdvisory;
@@ -580,6 +615,7 @@ export class QueueRepository {
580
615
  hasSummaryColumn;
581
616
  hasHumanIntentColumn;
582
617
  hasReplyToColumn;
618
+ hasReturnRouteColumn;
583
619
  hasHumanQuestionsColumn;
584
620
  hasDelegatedDecisionColumn;
585
621
  hasEvidenceRefColumn;
@@ -607,9 +643,10 @@ export class QueueRepository {
607
643
  workflowFrontierPredicate;
608
644
  constructor(db, eventBus, opts) {
609
645
  this.db = db;
646
+ this.deliveryDrains = new RigDeliveryDrainStore(db);
610
647
  this.eventBus = eventBus;
611
648
  this.transitionLog = new QueueTransitionLog(db);
612
- this.wakeRepo = new QueueWakeRepository(db);
649
+ this.wakeRepo = new QueueWakeRepository(db, (value) => this.isPersonAddress(value));
613
650
  this.validateRig = opts?.validateRig ?? (() => true);
614
651
  this.canRecordDestination = opts?.canRecordDestination ?? this.validateRig;
615
652
  this.destinationAdvisory = opts?.destinationAdvisory ?? (() => null);
@@ -631,6 +668,7 @@ export class QueueRepository {
631
668
  this.hasSummaryColumn = detectQueueColumn(db, "summary");
632
669
  this.hasHumanIntentColumn = detectQueueColumn(db, "human_intent");
633
670
  this.hasReplyToColumn = detectQueueColumn(db, "reply_to");
671
+ this.hasReturnRouteColumn = detectQueueColumn(db, "return_route");
634
672
  this.hasHumanQuestionsColumn = detectQueueColumn(db, "human_questions");
635
673
  this.hasDelegatedDecisionColumn = detectQueueColumn(db, "delegated_decision");
636
674
  this.hasEvidenceRefColumn = detectQueueColumn(db, "evidence_ref");
@@ -754,7 +792,7 @@ export class QueueRepository {
754
792
  if (inputUncertain || isWakeTimeoutSignal(res.reason) || isWakeTimeoutSignal(res.error)) {
755
793
  return { classified: "indeterminate", nudgeResult: `indeterminate:${detail}` };
756
794
  }
757
- return { classified: "failed", nudgeResult: `failed:${detail}` };
795
+ return { classified: "failed", nudgeResult: `failed:${detail}`, preInputFailure: res.inputPhase === "not_reached" && res.sent !== true };
758
796
  }
759
797
  /**
760
798
  * W1 (transactional closure): attach the durable wake-intent store AFTER
@@ -966,8 +1004,8 @@ export class QueueRepository {
966
1004
  /** #2789: a wake committed while its seat had no pane froze a binding that can never match once the seat is bound, so
967
1005
  * the delivery guard refused it on every retry. Such an intent takes its first live binding, on the same node and
968
1006
  * canonical session, only when it is known to have written no input (pending, or failed, which a send records only
969
- * without a write) and carries no expected identity of its own. A binding that ever named a pane is never replaced,
970
- * so a wake can't move to another occupant; the guard's write-time check against this binding still holds.
1007
+ * without a write) and carries no expected identity of its own. Previously pane-bound intents use the separate,
1008
+ * proof-only reconciliation at claim below; the guard's write-time check against the selected binding still holds.
971
1009
  * `entry` is the intent as read before its claim. Called inside the claim's transaction. */
972
1010
  bindFirstTarget(entry) {
973
1011
  const frozen = entry.guardBinding;
@@ -980,6 +1018,15 @@ export class QueueRepository {
980
1018
  return;
981
1019
  this.db.prepare("UPDATE outbox_entries SET guard_binding = ? WHERE outbox_id = ?").run(JSON.stringify(live), entry.outboxId);
982
1020
  }
1021
+ setWakePreInputFailure(outboxId, proved) {
1022
+ const entry = this.outbox.getById(outboxId);
1023
+ if (!entry || (!proved && !entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG)))
1024
+ return;
1025
+ const tags = (entry.tags ?? []).filter(tag => tag !== WAKE_PRE_INPUT_FAILURE_TAG);
1026
+ if (proved)
1027
+ tags.push(WAKE_PRE_INPUT_FAILURE_TAG);
1028
+ this.db.prepare("UPDATE outbox_entries SET tags = ? WHERE outbox_id = ?").run(JSON.stringify(tags), outboxId);
1029
+ }
983
1030
  async deliverWakeIntent(outboxId, attempted = new Set(), // this pass's attempt history, inherited by any release it delivers
984
1031
  eligible = () => true) {
985
1032
  if (!this.outbox)
@@ -990,21 +1037,52 @@ export class QueueRepository {
990
1037
  return "skipped";
991
1038
  const alreadyHeld = this.outbox.getById(outboxId);
992
1039
  if (alreadyHeld?.deliveryState === "retained" || alreadyHeld?.deliveryState === "retired") {
1040
+ if (this.deliveryDrains.holds(alreadyHeld.destinationSession))
1041
+ return "retained";
993
1042
  if (alreadyHeld.auditPointer)
994
1043
  this.recordNudgeAttempt(alreadyHeld.auditPointer, "retained:typing_guard");
995
1044
  return "retained";
996
1045
  }
997
- let recovering = false;
998
1046
  const claim = (entry) => {
999
- if (!eligible(entry) || attempted.has(entry.outboxId) || !this.outbox.claimForDelivery(entry.outboxId))
1047
+ if (this.deliveryDrains.holds(entry.destinationSession) || !eligible(entry) || attempted.has(entry.outboxId))
1000
1048
  return false;
1049
+ let rebound;
1050
+ const frozen = entry.guardBinding;
1051
+ if (entry.deliveryState === "failed" && entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG) && frozen?.pane) {
1052
+ const live = this.transport?.deliveryTarget?.(entry.destinationSession);
1053
+ if (!live || live.nodeId !== frozen.nodeId || live.session !== frozen.session
1054
+ || live.occupant !== frozen.occupant || live.pane !== frozen.pane) {
1055
+ const row = entry.auditPointer ? this.getById(entry.auditPointer) : undefined;
1056
+ // A proved-unsent queue notification follows its existing seat's current binding. Startup draining shares
1057
+ // this claim, so check current work and restore custody before consuming the failed attempt's proof.
1058
+ if (!entry.outboxId.startsWith(WAKE_INTENT_PREFIX) || !live?.pane || live.nodeId !== frozen.nodeId
1059
+ || this.outbox.expectedIdentity(entry.outboxId) || !row || row.state !== "pending" || row.handedOffFrom
1060
+ || !this.currentWakeIntent(entry) || !this.reachableWakeRetryable(row, new Date())
1061
+ || [entry.destinationSession, ...this.resolveSessionAddresses(entry.destinationSession), live.session]
1062
+ .some(address => this.hasPendingPostCompactStage?.(address)))
1063
+ return false;
1064
+ rebound = live;
1065
+ }
1066
+ }
1067
+ if (!this.outbox.claimForDelivery(entry.outboxId))
1068
+ return false;
1069
+ if (rebound) {
1070
+ this.db.prepare("UPDATE outbox_entries SET guard_binding = ? WHERE outbox_id = ?").run(JSON.stringify(rebound), entry.outboxId);
1071
+ this.transitionLog.append({
1072
+ qitemId: entry.auditPointer, state: "pending", actorSession: "queue@system",
1073
+ transitionNote: `queue wake binding reconciled ${JSON.stringify({ outboxId: entry.outboxId, from: frozen, to: rebound })}`,
1074
+ });
1075
+ }
1076
+ if (entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG))
1077
+ this.setWakePreInputFailure(entry.outboxId, false);
1001
1078
  this.bindFirstTarget(entry);
1002
1079
  attempted.add(entry.outboxId);
1003
- recovering ||= entry.deliveryState !== "pending";
1004
1080
  return true;
1005
1081
  };
1006
1082
  let superseded = false;
1007
1083
  const actionable = (entry) => {
1084
+ if (!eligible(entry))
1085
+ return false;
1008
1086
  const current = this.currentWakeIntent(entry);
1009
1087
  if (!current) {
1010
1088
  // Existing failed state means the requested old delivery was refused;
@@ -1063,7 +1141,14 @@ export class QueueRepository {
1063
1141
  }
1064
1142
  const qitemId = intent.auditPointer ?? outboxId;
1065
1143
  // Preserve the original envelope/source generation; add context without rewriting its stored bytes.
1066
- const recoveryNotice = recovering ? "Recovered queue notification: delivery may repeat after an earlier unconfirmed attempt.\n" : "";
1144
+ const recoveryNotice = (members) => {
1145
+ const recovered = members.filter(entry => entry.deliveryState !== "pending");
1146
+ if (!recovered.length)
1147
+ return "";
1148
+ return recovered.every(entry => entry.deliveryState === "failed" && entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG))
1149
+ ? "Recovered queue notification: a wake that failed before input is retried once when the current binding is reachable again.\n"
1150
+ : "Recovered queue notification: delivery may repeat after an earlier unconfirmed attempt.\n";
1151
+ };
1067
1152
  // The group was formed on the first member's outcome, so its own source and urgency reach that same outcome at the
1068
1153
  // send; the other members' bodies keep their own frozen urgent lines.
1069
1154
  const trigger = group[0].tags?.includes(WAKE_TRIGGER_OPENRIG_TAG) ? "openrig" : "agent";
@@ -1089,12 +1174,17 @@ export class QueueRepository {
1089
1174
  for (const entry of group) {
1090
1175
  if (keep.includes(entry))
1091
1176
  continue;
1092
- this.db.prepare("UPDATE outbox_entries SET delivery_state = ? WHERE outbox_id = ? AND delivery_state = 'sending'").run(entry.deliveryState, entry.outboxId);
1177
+ this.db.transaction(() => {
1178
+ const restored = this.db.prepare("UPDATE outbox_entries SET delivery_state = ? WHERE outbox_id = ? AND delivery_state = 'sending'").run(entry.deliveryState, entry.outboxId);
1179
+ // This member never reached transport input, so its earlier failed-attempt proof still applies.
1180
+ if (restored.changes && entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG))
1181
+ this.setWakePreInputFailure(entry.outboxId, true);
1182
+ })();
1093
1183
  released.push(entry);
1094
1184
  }
1095
- return { text: recoveryNotice + keep.map(entry => entry.body).join("\n"), outboxIds: keep.map(entry => entry.outboxId) };
1185
+ return { text: recoveryNotice(keep) + keep.map(entry => entry.body).join("\n"), outboxIds: keep.map(entry => entry.outboxId) };
1096
1186
  };
1097
- const outcome = await this.performWakeSend(qitemId, intent.destinationSession, intent.senderSession, undefined, recoveryNotice + group.map(entry => entry.body).join("\n"), group.map(entry => entry.outboxId), trigger, recheckMembers);
1187
+ const outcome = await this.performWakeSend(qitemId, intent.destinationSession, intent.senderSession, undefined, recoveryNotice(group) + group.map(entry => entry.body).join("\n"), group.map(entry => entry.outboxId), trigger, recheckMembers);
1098
1188
  let reportedState = outcome.classified === "verified" ? "delivered" : outcome.classified;
1099
1189
  for (const intent of group) {
1100
1190
  if (released.includes(intent))
@@ -1114,6 +1204,10 @@ export class QueueRepository {
1114
1204
  const wakeEvent = this.db.transaction(() => {
1115
1205
  this.recordNudgeAttempt(qitemId, nudgeResult);
1116
1206
  this.outbox.finalizeDelivery(intent.outboxId, finalState);
1207
+ // Only a first attempt creates proof: an actual retry consumes it even if it again fails before input.
1208
+ if (intent.deliveryState === "pending" && finalState === "failed" && outcome.preInputFailure === true) {
1209
+ this.setWakePreInputFailure(intent.outboxId, true);
1210
+ }
1117
1211
  // The acceptance (or a ring that may have arrived) belongs to this intent, so recovery can tell this wake already rang.
1118
1212
  if (hostedRingMayHaveArrived(outcome.nudgeResult)) {
1119
1213
  this.db.prepare(`UPDATE outbox_entries SET tags = json_insert(COALESCE(tags, '[]'), '$[#]', ?)
@@ -1208,18 +1302,19 @@ export class QueueRepository {
1208
1302
  const BATCH = 200;
1209
1303
  const horizon = this.db.prepare("SELECT COALESCE(MAX(rowid),0) AS id FROM outbox_entries").get().id;
1210
1304
  // Retire never-attempted obsolete notifications without materializing historical intents.
1211
- tally.failed += this.db.prepare(`UPDATE outbox_entries AS o SET delivery_state = 'failed',
1305
+ if (!opts?.eligible)
1306
+ tally.failed += this.db.prepare(`UPDATE outbox_entries AS o SET delivery_state = 'failed',
1212
1307
  tags = json_insert(COALESCE(tags, '[]'), '$[#]', 'queue:wake-superseded')
1213
1308
  WHERE delivery_state = 'pending' AND rowid <= ? AND substr(outbox_id, 1, ?) = ?
1214
1309
  AND substr(outbox_id, 1, ?) != ?
1215
1310
  AND NOT EXISTS (SELECT 1 FROM queue_items q WHERE q.qitem_id = o.audit_pointer
1216
1311
  AND q.state = 'pending' AND q.destination_session = o.destination_session)`)
1217
- .run(horizon, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, CLAIM_OVERRIDDEN_WAKE_PREFIX.length, CLAIM_OVERRIDDEN_WAKE_PREFIX).changes;
1312
+ .run(horizon, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, CLAIM_OVERRIDDEN_WAKE_PREFIX.length, CLAIM_OVERRIDDEN_WAKE_PREFIX).changes;
1218
1313
  // A stop also refuses every later claim inside a delivery: coalesced peers and members it releases for their own send.
1219
1314
  // So does a missing receiver, for a notification already tried. One never tried still gets its attempt, so its row
1220
1315
  // records why it didn't land.
1221
1316
  const eligible = (entry) => {
1222
- if (opts?.stopRequested?.())
1317
+ if (opts?.stopRequested?.() || opts?.eligible && !opts.eligible(entry))
1223
1318
  return false;
1224
1319
  if (entry.deliveryState === "pending" || !this.wakeHasNoReceiver(entry.destinationSession))
1225
1320
  return true;
@@ -1232,7 +1327,8 @@ export class QueueRepository {
1232
1327
  JOIN queue_items q ON q.qitem_id = o.audit_pointer AND (q.state = 'pending' OR substr(o.outbox_id, 1, ?) = ?)
1233
1328
  AND q.destination_session = o.destination_session
1234
1329
  WHERE o.rowid > ? AND o.rowid <= ? AND substr(o.outbox_id, 1, ?) = ?
1235
- AND o.delivery_state IN ('pending','failed','indeterminate') ORDER BY o.rowid LIMIT ?`)
1330
+ AND o.delivery_state IN ('pending','failed','indeterminate')
1331
+ AND json_extract(o.guard_delivery,'$.runner') IS NULL AND json_extract(o.guard_delivery,'$.nativeRequestId') IS NULL ORDER BY o.rowid LIMIT ?`)
1236
1332
  .all(CLAIM_OVERRIDDEN_WAKE_PREFIX.length, CLAIM_OVERRIDDEN_WAKE_PREFIX, cursor, horizon, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, BATCH);
1237
1333
  if (pending.length === 0)
1238
1334
  break;
@@ -1294,9 +1390,11 @@ export class QueueRepository {
1294
1390
  * copies were deleted, refused at the seat boundary instead); this
1295
1391
  * site holds no copy of its own.
1296
1392
  */
1297
- async maybeNudge(qitemId, destinationSession, nudgeOpt, sourceSession, bodyOverride, trigger = "agent") {
1393
+ async maybeNudge(qitemId, destinationSession, nudgeOpt, sourceSession, bodyOverride, trigger = "agent", opts) {
1298
1394
  if (nudgeOpt === false)
1299
1395
  return;
1396
+ if (!opts?.explicit && this.deliveryDrains.holds(destinationSession))
1397
+ return;
1300
1398
  if (!this.transport)
1301
1399
  return;
1302
1400
  const outcome = await this.performWakeSend(qitemId, destinationSession, sourceSession, bodyOverride, undefined, undefined, trigger);
@@ -1304,6 +1402,7 @@ export class QueueRepository {
1304
1402
  }
1305
1403
  /** The following startup intent drain owns durable pending wakes. Legacy packets
1306
1404
  * and overdue claimed work (not eligible for that drain) still use the nudge path. */
1405
+ // Held workflow boot packets remain owed: their keepalive resumes after END; the sweep reports unclaimed work.
1307
1406
  async recoverLostNudge(qitemId, destinationSession, sourceSession) {
1308
1407
  const outboxId = `${WAKE_INTENT_PREFIX}${qitemId}`;
1309
1408
  if (this.outbox?.getById(outboxId) && this.getById(qitemId)?.state === "pending")
@@ -1325,6 +1424,8 @@ export class QueueRepository {
1325
1424
  }
1326
1425
  if (state !== "running" && state !== "idle")
1327
1426
  return;
1427
+ if (addresses.some(address => this.deliveryDrains.holds(address)))
1428
+ return;
1328
1429
  if (addresses.every(address => this.promptRecoveryState.get(address) === false))
1329
1430
  return;
1330
1431
  // A compaction's "Compacted" is also a clear. While its turn boundary, restore or audit is still owed, a retried wake
@@ -1341,7 +1442,7 @@ export class QueueRepository {
1341
1442
  const current = this.getById(entry.auditPointer), refusal = current?.lastNudgeWireResult;
1342
1443
  const notice = entry.outboxId.startsWith(CLAIM_OVERRIDDEN_WAKE_PREFIX);
1343
1444
  return (current?.state === "pending" || notice) && addresses.includes(current?.destinationSession ?? "")
1344
- && (refusal === "failed:target_needs_input" || (refusal?.startsWith("failed:Refused:") === true && refusal.includes("interactive prompt")));
1445
+ && isPromptOwnedWakeRefusal(refusal);
1345
1446
  };
1346
1447
  const seats = addresses.map(() => "?").join(",");
1347
1448
  const refused = (q) => `(${q}last_nudge_result LIKE 'failed:Refused:%interactive prompt%' OR ${q}last_nudge_result = 'failed:target_needs_input')`;
@@ -1391,29 +1492,39 @@ export class QueueRepository {
1391
1492
  * gateway, not held or released for quiet hours, and its seat now pane-bound. A handoff's retry ladder is the
1392
1493
  * caller's to check: the sweep defers to a live ladder, the reachable-seat retry leaves every handed-off row to it. */
1393
1494
  unroutableWakeRetryable(row, now = new Date()) {
1394
- return row.lastNudgeResult?.startsWith("unroutable:") === true
1395
- && !row.claimedAt
1495
+ return recordsNoWakeRoute(row.lastNudgeResult) && this.reachableWakeRetryable(row, now);
1496
+ }
1497
+ reachableWakeRetryable(row, now) {
1498
+ return !row.claimedAt
1499
+ && !isPromptOwnedWakeRefusal(row.lastNudgeResult)
1396
1500
  && row.deliveryOutcome !== "never-posted" && row.deliveryOutcome !== "transport-failed"
1397
1501
  && !this.isLocalHumanDecisionWithoutGateway(row)
1398
1502
  && !["held", "released"].includes(quietHoldCustody(this.db, row.qitemId, now)?.state ?? "")
1399
1503
  && this.classifyDestinationOf(row.destinationSession).class === "pane-bound";
1400
1504
  }
1401
- /** A wake recorded unroutable because its seat wasn't bound yet, as just after a restart (#2789), is re-sent as soon
1402
- * as the seat is seen running or idle, rather than at the stuck sweep's next tick; the sweep remains the backstop.
1403
- * Only this seat's own pending rows, oldest first, that {@link unroutableWakeRetryable} admits. */
1505
+ /** Re-send an unroutable wake, or the same failed intent with typed proof that its latest attempt never reached input,
1506
+ * when its seat returns running/idle. Unknown delivery stays unknown; deliberate quiet and compaction keep custody. */
1404
1507
  async retryUnroutableWakesOnReachable(sessionName, state) {
1405
1508
  if (state !== "running" && state !== "idle")
1406
1509
  return;
1407
1510
  const addresses = this.resolveSessionAddresses(sessionName);
1408
1511
  if (!addresses.length)
1409
1512
  return;
1513
+ if (addresses.some(address => this.deliveryDrains.holds(address)))
1514
+ return;
1410
1515
  // As for a prompt clear (#2575): while a compaction's restore is owed, the wake would reach the agent before it.
1411
1516
  if ([sessionName, ...addresses].some(address => this.hasPendingPostCompactStage?.(address)))
1412
1517
  return;
1413
- const rows = this.db.prepare(`SELECT qitem_id FROM queue_items
1414
- WHERE destination_session IN (${addresses.map(() => "?").join(",")}) AND state = 'pending'
1415
- AND handed_off_from IS NULL AND last_nudge_result LIKE 'unroutable:%' ORDER BY ts_created, qitem_id`)
1416
- .all(...addresses);
1518
+ const provedFailure = this.outbox ? `OR EXISTS (
1519
+ SELECT 1 FROM outbox_entries o WHERE o.audit_pointer = q.qitem_id
1520
+ AND substr(o.outbox_id, 1, ?) = ? AND o.delivery_state = 'failed'
1521
+ AND EXISTS (SELECT 1 FROM json_each(o.tags) WHERE value = ?)
1522
+ )` : "";
1523
+ const rows = this.db.prepare(`SELECT q.qitem_id FROM queue_items q
1524
+ WHERE q.destination_session IN (${addresses.map(() => "?").join(",")}) AND q.state = 'pending'
1525
+ AND q.handed_off_from IS NULL AND (q.last_nudge_result LIKE 'unroutable:%' OR q.last_nudge_result LIKE 'awaiting-pickup:%' ${provedFailure})
1526
+ ORDER BY q.ts_created, q.qitem_id`)
1527
+ .all(...addresses, ...(this.outbox ? [WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, WAKE_PRE_INPUT_FAILURE_TAG] : []));
1417
1528
  const now = new Date();
1418
1529
  // One attempt per intent for the pass: a returned result and its resume go as one send, so the second row's turn
1419
1530
  // mustn't send them again after a refusal.
@@ -1424,13 +1535,17 @@ export class QueueRepository {
1424
1535
  const eligible = (entry) => {
1425
1536
  if (entry.deliveryState !== "failed" || !entry.auditPointer)
1426
1537
  return false;
1538
+ // An earlier member's awaited send may have started restore custody before this claim.
1539
+ if ([sessionName, ...addresses].some(address => this.hasPendingPostCompactStage?.(address)))
1540
+ return false;
1427
1541
  const current = this.getById(entry.auditPointer);
1428
1542
  return current?.state === "pending" && addresses.includes(current.destinationSession) && !current.handedOffFrom
1429
- && this.unroutableWakeRetryable(current, now);
1543
+ && this.reachableWakeRetryable(current, now)
1544
+ && (this.unroutableWakeRetryable(current, now) || entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG) === true);
1430
1545
  };
1431
1546
  for (const { qitem_id } of rows) {
1432
1547
  const row = this.getById(qitem_id);
1433
- if (!row || row.state !== "pending" || !this.unroutableWakeRetryable(row, now))
1548
+ if (!row || row.state !== "pending" || !this.reachableWakeRetryable(row, now))
1434
1549
  continue;
1435
1550
  // The failed wake may be the row's own intent or an un-park's blocker intent: re-send whichever failed.
1436
1551
  // One in flight or delivered is never sent again; only a row with no intent at all takes the plain nudge.
@@ -1442,7 +1557,7 @@ export class QueueRepository {
1442
1557
  if (intent.delivery_state === "failed")
1443
1558
  await this.deliverWakeIntent(intent.outbox_id, attempted, eligible);
1444
1559
  }
1445
- else
1560
+ else if (this.unroutableWakeRetryable(row, now))
1446
1561
  await this.maybeNudge(qitem_id, row.destinationSession, undefined, row.sourceSession);
1447
1562
  }
1448
1563
  }
@@ -1877,6 +1992,8 @@ export class QueueRepository {
1877
1992
  if (humanQuestions) {
1878
1993
  this.db.prepare("UPDATE queue_items SET human_questions = ? WHERE qitem_id = ?").run(JSON.stringify(humanQuestions), id);
1879
1994
  }
1995
+ const replaced = input.returnRoute == null && handedOffFrom ? this.getById(handedOffFrom) : null;
1996
+ this.persistReturnRoute(id, input.returnRoute ?? replaced?.returnRoute ?? null, input.returnRoute ? input.returnRouteBasis ?? null : replaced?.returnRouteBasis ?? null);
1880
1997
  this.persistMintingGeneration(id, input.sourceSession);
1881
1998
  const notification = this.classifyOwnerNotification({
1882
1999
  action: "create",
@@ -1946,6 +2063,8 @@ export class QueueRepository {
1946
2063
  return true;
1947
2064
  }
1948
2065
  isPersonAddress(destination) {
2066
+ if (!destination.includes("@"))
2067
+ return false;
1949
2068
  if (isHumanSeatSessionRef(destination))
1950
2069
  return true;
1951
2070
  const registry = this.loadHumanRegistryFn();
@@ -2090,6 +2209,8 @@ export class QueueRepository {
2090
2209
  }
2091
2210
  this.persistSummary(newId, input.summary ?? null);
2092
2211
  this.persistEvidenceRef(newId, input.evidenceRef ?? null);
2212
+ // The goal's return route goes with the work, as its body does.
2213
+ this.persistReturnRoute(newId, source.returnRoute ?? null, source.returnRouteBasis ?? null);
2093
2214
  this.persistMintingGeneration(newId, input.fromSession);
2094
2215
  const carried = this.carryPermissionQuestion(source, newId, input.toSession);
2095
2216
  const successorNotification = this.classifyOwnerNotification({
@@ -2246,6 +2367,8 @@ export class QueueRepository {
2246
2367
  }
2247
2368
  this.persistSummary(newId, input.summary ?? null);
2248
2369
  this.persistEvidenceRef(newId, input.evidenceRef ?? null);
2370
+ // The goal's return route goes with the work, as its body does.
2371
+ this.persistReturnRoute(newId, source.returnRoute ?? null, source.returnRouteBasis ?? null);
2249
2372
  this.persistMintingGeneration(newId, input.fromSession);
2250
2373
  const carried = this.carryPermissionQuestion(source, newId, input.toSession);
2251
2374
  const successorNotification = this.classifyOwnerNotification({
@@ -2541,6 +2664,7 @@ export class QueueRepository {
2541
2664
  identityProvenance: input.identityProvenance ?? null, // P21 §4 era-stamp
2542
2665
  identityPrincipal: input.identityPrincipal ?? null,
2543
2666
  });
2667
+ this.recordRelayPickup(qitem, input.destinationSession);
2544
2668
  // OPR.0.5.8.1 S1b — CLAIM-RESUME. A blocked row is claimable ("only
2545
2669
  // pending/blocked are claimable"), so claiming is a real exit from a park
2546
2670
  // and it writes state directly rather than through update(). This is the
@@ -2646,6 +2770,50 @@ export class QueueRepository {
2646
2770
  const result = this.updateInTransactionalContext(input);
2647
2771
  return { qitemId: input.qitemId, ...result };
2648
2772
  }
2773
+ /**
2774
+ * Add tags to a row in any state, and change nothing else: its existing tags stay, its state, claim and closure are
2775
+ * untouched, and a closed row isn't reopened. A tag the row already has adds nothing. The tags added are recorded as a
2776
+ * transition naming the actor, like a note; when every tag is already there, nothing is written. Tags are never
2777
+ * removed or rewritten here.
2778
+ */
2779
+ addTags(input) {
2780
+ const txn = this.db.transaction(() => {
2781
+ const qitem = this.getById(input.qitemId);
2782
+ if (!qitem)
2783
+ throw new QueueRepositoryError("qitem_not_found", `qitem ${input.qitemId} not found`);
2784
+ const existing = qitem.tags ?? [];
2785
+ const added = [...new Set(input.tags)].filter((tag) => !existing.includes(tag));
2786
+ if (added.length === 0)
2787
+ return { added, persistedEvents: [] };
2788
+ this.db.prepare("UPDATE queue_items SET tags = ? WHERE qitem_id = ?").run(JSON.stringify([...existing, ...added]), input.qitemId);
2789
+ this.transitionLog.append({
2790
+ qitemId: input.qitemId,
2791
+ state: qitem.state,
2792
+ actorSession: input.actorSession,
2793
+ // The values as a JSON array, so a tag holding a comma reads apart from two tags.
2794
+ transitionNote: `tags added: ${JSON.stringify(added)}`,
2795
+ // Like a note append, this keeps a claim's retained park gate for a later state write to end.
2796
+ closureTarget: qitem.state === "in-progress" ? this.retainedClaimBlocker(input.qitemId) : undefined,
2797
+ identityProvenance: input.identityProvenance ?? null,
2798
+ identityPrincipal: input.identityPrincipal ?? null,
2799
+ });
2800
+ const persistedEvent = this.eventBus.persistWithinTransaction({
2801
+ type: "queue.updated",
2802
+ qitemId: input.qitemId,
2803
+ fromState: qitem.state,
2804
+ toState: qitem.state,
2805
+ closureReason: null,
2806
+ closureTarget: null,
2807
+ actorSession: input.actorSession,
2808
+ summary: qitem.summary ?? null,
2809
+ });
2810
+ return { added, persistedEvents: [persistedEvent] };
2811
+ });
2812
+ const result = txn();
2813
+ for (const event of result.persistedEvents)
2814
+ this.eventBus.notifySubscribers(event);
2815
+ return { item: this.getByIdOrThrow(input.qitemId), added: result.added };
2816
+ }
2649
2817
  /** Notify subscribers of events persisted inside a caller's own transaction (updateWithinTransaction), after it commits. */
2650
2818
  notifyCommitted(events) {
2651
2819
  for (const event of events)
@@ -2969,7 +3137,8 @@ export class QueueRepository {
2969
3137
  jobsRepo.recordEvaluation(job.jobId, job.registeredAt, false);
2970
3138
  parkWake = { kind: "timer", ref: job.jobId };
2971
3139
  }
2972
- else if (input.state === "blocked" && effectiveBlockedOn?.startsWith("qitem-")) {
3140
+ else if (input.state === "blocked" && effectiveBlockedOn && effectiveBlockedOn !== input.qitemId && !isHumanPark && !isTypedGateBlocker(effectiveBlockedOn)
3141
+ && (effectiveBlockedOn.startsWith("qitem-") || isBlockerLive(this.getById(effectiveBlockedOn)?.state ?? ""))) {
2973
3142
  parkWake = { kind: "blocker", ref: effectiveBlockedOn };
2974
3143
  }
2975
3144
  const ts = new Date().toISOString();
@@ -3144,6 +3313,9 @@ export class QueueRepository {
3144
3313
  const blockedRows = this.db
3145
3314
  .prepare("SELECT qitem_id, destination_session FROM queue_items WHERE blocked_on = ? AND state = 'blocked'")
3146
3315
  .all(input.qitemId);
3316
+ // Typed gates and people own their own resolution even when a custom row ID collides.
3317
+ if (blockedRows.length === 0 || isTypedGateBlocker(input.qitemId) || this.isPersonAddress(input.qitemId))
3318
+ return dependentEvents;
3147
3319
  for (const r of blockedRows) {
3148
3320
  const closed = this.getById(input.qitemId);
3149
3321
  const successors = input.terminalState === "handed-off" ? this.db.prepare("SELECT qitem_id FROM queue_items WHERE handed_off_from = ? AND destination_session = ?").all(input.qitemId, closed?.handedOffTo ?? "") : [];
@@ -3256,7 +3428,7 @@ export class QueueRepository {
3256
3428
  /** Read-only scope-aware RECENT projection. Normalization and its hard cap
3257
3429
  * live with the append-only transition log; the repository owns the public
3258
3430
  * queue-domain door. */
3259
- listRecentTransitions(scope, limit = 20) {
3431
+ listRecentTransitions(scope, limit = DEFAULT_RECENT_TRANSITIONS_LIMIT) {
3260
3432
  return this.transitionLog.listRecent(typeof scope === "string" ? { kind: "rig", rig: scope } : scope, limit);
3261
3433
  }
3262
3434
  /** The parked row an ordinary due park timer reminds about, when its reminder may share one message with other
@@ -3628,6 +3800,15 @@ export class QueueRepository {
3628
3800
  if (!question?.options.some((o) => o.id === input.optionId))
3629
3801
  return { status: "not-applicable", reason: "unknown-option" };
3630
3802
  const recorded = item.humanAnswers ?? {};
3803
+ // A retained click fills a missing answer; it never replaces a committed choice in this ask or park.
3804
+ // A previous park's saved values do not count as answers to the current park.
3805
+ const recordedInCurrentPark = episodeKey && this.transitionLog.listForQitem(item.qitemId).some((transition) => transition.transitionId > Number(episodeKey.slice(episodeKey.lastIndexOf(":") + 1))
3806
+ && transition.transitionNote === `human-answer-recorded: ${JSON.stringify({ questionId: input.questionId, optionId: recorded[input.questionId] })}`);
3807
+ if (input.onlyIfUnanswered && Object.prototype.hasOwnProperty.call(recorded, input.questionId)
3808
+ && (item.state === "pending" || recordedInCurrentPark)) {
3809
+ return { status: "recorded", answers: recorded,
3810
+ complete: unansweredQuestions(item.humanQuestions, recorded).length === 0, questions: item.humanQuestions };
3811
+ }
3631
3812
  // A park's set is final once this park has its answer: until then a complete set is an earlier park's, and a click
3632
3813
  // on the re-park records over it.
3633
3814
  if (unansweredQuestions(item.humanQuestions, recorded).length === 0
@@ -3635,9 +3816,13 @@ export class QueueRepository {
3635
3816
  return { status: "recorded", answers: recorded, complete: true, questions: item.humanQuestions };
3636
3817
  }
3637
3818
  const answers = { ...(item.humanAnswers ?? {}), [input.questionId]: input.optionId };
3638
- this.db.prepare("UPDATE queue_items SET human_answers = ? WHERE qitem_id = ?").run(JSON.stringify(answers), input.qitemId);
3639
3819
  const complete = unansweredQuestions(item.humanQuestions, answers).length === 0;
3640
- if (item.humanAnswers?.[input.questionId] !== input.optionId) {
3820
+ if (item.humanAnswers?.[input.questionId] !== input.optionId || (episodeKey && !recordedInCurrentPark)) {
3821
+ const transition = this.transitionLog.append({ qitemId: input.qitemId, state: item.state, actorSession: input.actorSession,
3822
+ transitionNote: `human-answer-recorded: ${JSON.stringify({ questionId: input.questionId, optionId: input.optionId })}`,
3823
+ identityProvenance: input.identityProvenance, identityPrincipal: input.identityPrincipal });
3824
+ this.db.prepare("UPDATE queue_items SET human_answers = ?, ts_updated = ? WHERE qitem_id = ?")
3825
+ .run(JSON.stringify(answers), transition.ts, input.qitemId);
3641
3826
  changed = { summary: item.summary ?? null, answered: item.humanQuestions.length - unansweredQuestions(item.humanQuestions, answers).length };
3642
3827
  }
3643
3828
  return { status: "recorded", answers, complete, questions: item.humanQuestions };
@@ -3970,13 +4155,22 @@ export class QueueRepository {
3970
4155
  return null;
3971
4156
  }
3972
4157
  /** The parked query's obligation face: open rows to one destination, newest first, without the per-row
3973
- * projections list() derives (pickup, waiting view, delivery ledger), which this read never uses. */
4158
+ * projections list() derives (pickup, waiting view, delivery ledger), which this read never uses. A wake escalation
4159
+ * about this seat's own prompt that nobody holds is left out: with no operator seat to carry it, the alert falls back
4160
+ * to the seat itself, and the escalation is the wake, not the content, so it is never that seat's work. One its owner
4161
+ * explicitly holds (blocked) stays, so that hold and its wake are diagnosed as before; so does a row whose tags aren't
4162
+ * a JSON array. */
3974
4163
  listOpenObligations(destinationSession, limit) {
3975
4164
  const addresses = this.resolveSessionAddresses(destinationSession);
3976
4165
  const slots = addresses.map(() => "?").join(",");
4166
+ const ownPrompt = addresses.flatMap((address) => [`prompt-destination:${address}`, `consumed-prompt-destination:${address}`]);
3977
4167
  const rows = this.db.prepare(`SELECT qitem_id, state${this.hasSummaryColumn ? ", summary" : ""} FROM queue_items
3978
4168
  WHERE destination_session IN (${slots}) AND state IN ('pending', 'in-progress', 'blocked')
3979
- ORDER BY ts_created DESC LIMIT ?`).all(...addresses, limit);
4169
+ AND NOT CASE WHEN state != 'blocked' AND json_valid(tags) THEN CASE WHEN json_type(tags) = 'array' THEN
4170
+ EXISTS (SELECT 1 FROM json_each(queue_items.tags) WHERE value = ?)
4171
+ AND EXISTS (SELECT 1 FROM json_each(queue_items.tags) WHERE value IN (${ownPrompt.map(() => "?").join(",")}))
4172
+ ELSE 0 END ELSE 0 END
4173
+ ORDER BY ts_created DESC LIMIT ?`).all(...addresses, WAKE_ESCALATION_TAG, ...ownPrompt, limit);
3980
4174
  return rows.map((r) => ({ qitemId: r.qitem_id, state: r.state, summary: r.summary ?? null }));
3981
4175
  }
3982
4176
  list(opts) {
@@ -4193,9 +4387,11 @@ export class QueueRepository {
4193
4387
  const rows = this.db.prepare(sql).all(...params);
4194
4388
  return rows.map((r) => this.rowToItem(r));
4195
4389
  }
4196
- /** The compact listings' columns: the shared set plus the summary, which is short and is what people search for. */
4390
+ /** The compact listings' columns: the shared set plus the summary, which is short and is what people search for, and a
4391
+ * routed row's return route, which isn't elided, so a routed row never lists as unrouted. */
4197
4392
  compactColumns() {
4198
- return COMPACT_QUEUE_COLUMNS + (this.hasSummaryColumn ? ", summary" : "") + (this.hasHumanIntentColumn ? ", human_intent" : "");
4393
+ return COMPACT_QUEUE_COLUMNS + (this.hasSummaryColumn ? ", summary" : "") + (this.hasHumanIntentColumn ? ", human_intent" : "")
4394
+ + (this.hasReturnRouteColumn ? ", return_route, return_route_basis" : "");
4199
4395
  }
4200
4396
  findOverdue(opts) {
4201
4397
  const cutoff = opts?.now ?? new Date().toISOString();
@@ -4272,12 +4468,9 @@ export class QueueRepository {
4272
4468
  this.eventBus.notifySubscribers(persisted);
4273
4469
  return persisted;
4274
4470
  }
4275
- findUndelivered(opts) {
4276
- // OPR.0.5.6.14 — delivery truth belongs to the CURRENT human-notification
4277
- // episode, not to the row's whole history. Pull every active row that can
4278
- // carry a current episode or a legacy nudge/receipt, then derive/filter in
4279
- // JS. LIMIT is applied after that filtering so historical POSTED episodes
4280
- // cannot consume the window and hide a later failure.
4471
+ /** The active rows findUndelivered considers: each can carry a current owner episode, a legacy nudge failure or a
4472
+ * delivery receipt. Which of them is undelivered is derived per row afterwards. */
4473
+ undeliveredCandidateFilter(opts) {
4281
4474
  const ownerEpisodeCandidate = this.hasOwnerNotificationColumns
4282
4475
  ? `EXISTS (SELECT 1 FROM queue_transitions owner_episode
4283
4476
  WHERE owner_episode.qitem_id = queue_items.qitem_id
@@ -4287,6 +4480,7 @@ export class QueueRepository {
4287
4480
  "state IN ('pending', 'in-progress', 'blocked')",
4288
4481
  `((state = 'pending' AND (last_nudge_result LIKE 'failed:%'
4289
4482
  OR last_nudge_result LIKE 'unroutable:%'
4483
+ OR last_nudge_result LIKE 'awaiting-pickup:%'
4290
4484
  OR last_nudge_result LIKE 'gateway-owned%'))
4291
4485
  OR ${ownerEpisodeCandidate}
4292
4486
  OR EXISTS (SELECT 1 FROM queue_transitions receipt
@@ -4306,6 +4500,35 @@ export class QueueRepository {
4306
4500
  conditions.push("(destination_session LIKE ? ESCAPE '\\' OR source_session LIKE ? ESCAPE '\\')");
4307
4501
  params.push(`%@${escaped}`, `%@${escaped}`);
4308
4502
  }
4503
+ return { conditions, params };
4504
+ }
4505
+ /**
4506
+ * The ids of the rows findUndelivered considers, oldest first, with no row's delivery outcome derived: a caller that
4507
+ * must stay responsive (the stuck sweep) derives each one by id, `findUndelivered({ qitemId })`, between its own
4508
+ * yields, so a long candidate set never runs as one synchronous read. On a WAL file database outside a transaction the
4509
+ * read runs in rowid windows on its own readonly connection and yields between windows (readRowsCooperatively, one
4510
+ * snapshot for the whole read); otherwise it is one id-only read on this handle. Every candidate is returned: nothing
4511
+ * is capped, and rows that change after the read are judged on that fresh read by id.
4512
+ */
4513
+ async undeliveredCandidateIds(opts) {
4514
+ const { conditions, params } = this.undeliveredCandidateFilter(opts);
4515
+ const where = conditions.join(" AND ");
4516
+ const columns = "qitem_id, ts_created, queue_items.rowid AS rid";
4517
+ const file = cooperativeReadFile(this.db);
4518
+ const rows = file
4519
+ ? (await readRowsCooperatively(file, "queue_items", `SELECT ${columns} FROM queue_items WHERE queue_items.rowid > ? AND queue_items.rowid <= ? AND ${where}`, params)).rows
4520
+ : this.db.prepare(`SELECT ${columns} FROM queue_items WHERE ${where}`).all(...params);
4521
+ // findUndelivered's order: oldest first, ties in rowid order.
4522
+ rows.sort((a, b) => (a.ts_created < b.ts_created ? -1 : a.ts_created > b.ts_created ? 1 : a.rid - b.rid));
4523
+ return rows.map((row) => row.qitem_id);
4524
+ }
4525
+ findUndelivered(opts) {
4526
+ // OPR.0.5.6.14 — delivery truth belongs to the CURRENT human-notification
4527
+ // episode, not to the row's whole history. Pull every active row that can
4528
+ // carry a current episode or a legacy nudge/receipt, then derive/filter in
4529
+ // JS. LIMIT is applied after that filtering so historical POSTED episodes
4530
+ // cannot consume the window and hide a later failure.
4531
+ const { conditions, params } = this.undeliveredCandidateFilter(opts);
4309
4532
  const columns = opts?.compact ? this.compactColumns() : "*";
4310
4533
  const sql = `SELECT ${columns} FROM queue_items WHERE ${conditions.join(" AND ")} ORDER BY ts_created ASC`;
4311
4534
  const rows = this.db.prepare(sql).all(...params);
@@ -4336,7 +4559,7 @@ export class QueueRepository {
4336
4559
  // undelivered. An active non-human row can still have an old OWNER
4337
4560
  // transition; that historical episode is not a current obligation.
4338
4561
  const lastNudge = item.lastNudgeResult ?? "";
4339
- if (item.state === "pending" && (lastNudge.startsWith("failed:") || lastNudge.startsWith("unroutable:"))) {
4562
+ if (item.state === "pending" && (lastNudge.startsWith("failed:") || recordsNoWakeRoute(lastNudge))) {
4340
4563
  out.push(item);
4341
4564
  }
4342
4565
  }
@@ -4743,8 +4966,7 @@ export class QueueRepository {
4743
4966
  .run(ts, result, qitemId);
4744
4967
  // The transport's definite no-write refusal establishes the episode even when a
4745
4968
  // fresh hook hid needs_input. Uncertain delivery never arms clear-triggered replay.
4746
- if (!this.promptClearRetries.has(qitemId) && (result === "failed:target_needs_input"
4747
- || (result.startsWith("failed:Refused:") && result.includes("interactive prompt")))) {
4969
+ if (!this.promptClearRetries.has(qitemId) && isPromptOwnedWakeRefusal(result)) {
4748
4970
  const row = this.getById(qitemId);
4749
4971
  if (row?.state === "pending")
4750
4972
  this.promptRecoveryState.set(row.destinationSession, true);
@@ -4902,6 +5124,32 @@ export class QueueRepository {
4902
5124
  this.db.prepare("UPDATE queue_items SET evidence_ref = ? WHERE qitem_id = ?").run(evidenceRef, qitemId);
4903
5125
  }
4904
5126
  }
5127
+ /** A relay task's claim is pickup at its return route. It's recorded on the escalation the task carries, keyed by that
5128
+ * delivery episode, so the episode resolves. Pickup only: not the person's answer or approval, and nothing about the
5129
+ * seat's prompt. */
5130
+ recordRelayPickup(relay, actor) {
5131
+ if (!relay.tags?.includes(RELAY_TAG))
5132
+ return;
5133
+ const escalationId = relay.tags.find(t => t.startsWith(RELAY_FOR_PREFIX))?.slice(RELAY_FOR_PREFIX.length);
5134
+ const key = relay.tags.find(t => t.startsWith(RELAY_KEY_PREFIX))?.slice(RELAY_KEY_PREFIX.length);
5135
+ // Only the episode's own relay (its id, OpenRig as source, its tags) records pickup; a row that only carries the tags doesn't.
5136
+ if (!escalationId || !key || !isEpisodeRelay(relay, escalationId, key, OPENRIG_SENDER))
5137
+ return;
5138
+ const escalation = this.getById(escalationId);
5139
+ if (!escalation)
5140
+ return;
5141
+ this.transitionLog.append({
5142
+ qitemId: escalation.qitemId, state: escalation.state, actorSession: "wake-ladder@system",
5143
+ transitionNote: `${RELAY_CLAIMED_PREFIX} notification_key=${key} relay=${relay.qitemId} by=${actor}: picked up at the return route; not the person's answer or approval`,
5144
+ closureTarget: escalation.state === "in-progress" ? this.retainedClaimBlocker(escalation.qitemId) : undefined,
5145
+ });
5146
+ }
5147
+ /** A row's return route (return-route.ts), when it has one; a schema without the column keeps the row without it. */
5148
+ persistReturnRoute(qitemId, route, basis) {
5149
+ if (!this.hasReturnRouteColumn || !route)
5150
+ return;
5151
+ this.db.prepare("UPDATE queue_items SET return_route = ?, return_route_basis = ? WHERE qitem_id = ?").run(route, basis, qitemId);
5152
+ }
4905
5153
  /** GHOST-STAGE (e/Class-B) — persist the MINTING occupant-generation additively (same degrade
4906
5154
  * contract as persistSummary; NULL when unresolved/pre-063). Forensic provenance of the creator;
4907
5155
  * the RELEASE discriminator is claimed_by_generation_uuid (stamped at claim), not this. */
@@ -5188,6 +5436,7 @@ export class QueueRepository {
5188
5436
  // older test fixtures supply legacy rows where target_repo is undefined.
5189
5437
  targetRepo: row.target_repo ?? null,
5190
5438
  ...(row.content_erased_at ? { contentErasedAt: row.content_erased_at } : {}),
5439
+ ...(row.return_route ? { returnRoute: row.return_route, returnRouteBasis: row.return_route_basis ?? null } : {}),
5191
5440
  };
5192
5441
  }
5193
5442
  }