@openrig/cli 0.7.17 → 0.7.19

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 (986) hide show
  1. package/README.md +7 -6
  2. package/daemon/assets/claude-hook-bridge.cjs +146 -0
  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-core/.claude-plugin/plugin.json +1 -1
  8. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  9. package/daemon/assets/plugins/openrig-core/README.md +1 -1
  10. package/daemon/assets/plugins/openrig-core/hooks/claude.json +14 -14
  11. package/daemon/assets/plugins/openrig-core/hooks/scripts/activity-relay.cjs +43 -22
  12. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +6 -0
  13. package/daemon/assets/plugins/openrig-core/skills/messaging-the-human/SKILL.md +23 -0
  14. package/daemon/assets/plugins/openrig-core/skills/mission-slice-sop/SKILL.md +1 -1
  15. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +11 -0
  16. package/daemon/assets/plugins/openrig-core/skills/refocusing/scripts/trace-to-root.py +95 -7
  17. package/daemon/assets/skills/rigs/SKILL.md +68 -33
  18. package/daemon/assets/skills/rigs/references/installing-for-someone.md +2 -2
  19. package/daemon/context-packs/help/manifest.yaml +1 -1
  20. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  21. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +57 -14
  22. package/daemon/context-packs/reference/getting-started.md +9 -4
  23. package/daemon/context-packs/reference/manifest.yaml +1 -1
  24. package/daemon/context-packs/reference/rig-spec.md +197 -1
  25. package/daemon/context-packs/reference/whats-new.md +187 -15
  26. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  27. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  28. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  29. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  30. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  31. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  32. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/core/messaging-the-human/SKILL.md +23 -0
  35. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  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/SKILL.md +1 -1
  53. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/openrig-user/SKILL.md +11 -0
  56. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  66. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  76. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  77. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  78. package/daemon/context-packs/skills/refocusing/scripts/trace-to-root.py +95 -7
  79. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  80. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  81. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  82. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  83. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  84. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  85. package/daemon/dist/adapters/claude-code-adapter.d.ts +9 -0
  86. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  87. package/daemon/dist/adapters/claude-code-adapter.js +57 -9
  88. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  89. package/daemon/dist/adapters/claude-resume.d.ts +4 -1
  90. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  91. package/daemon/dist/adapters/claude-resume.js +15 -5
  92. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  93. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +5 -0
  94. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  95. package/daemon/dist/adapters/codex-runtime-adapter.js +45 -10
  96. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  97. package/daemon/dist/adapters/kernel-authority.d.ts +8 -1
  98. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  99. package/daemon/dist/adapters/kernel-authority.js +45 -10
  100. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  101. package/daemon/dist/adapters/pi-resume.d.ts.map +1 -1
  102. package/daemon/dist/adapters/pi-resume.js +5 -7
  103. package/daemon/dist/adapters/pi-resume.js.map +1 -1
  104. package/daemon/dist/adapters/pi-runner-protocol.d.ts +47 -0
  105. package/daemon/dist/adapters/pi-runner-protocol.d.ts.map +1 -1
  106. package/daemon/dist/adapters/pi-runner-protocol.js.map +1 -1
  107. package/daemon/dist/adapters/pi-runner.d.ts +84 -1
  108. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  109. package/daemon/dist/adapters/pi-runner.js +799 -16
  110. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  111. package/daemon/dist/adapters/pi-runtime-adapter.d.ts +7 -1
  112. package/daemon/dist/adapters/pi-runtime-adapter.d.ts.map +1 -1
  113. package/daemon/dist/adapters/pi-runtime-adapter.js +29 -19
  114. package/daemon/dist/adapters/pi-runtime-adapter.js.map +1 -1
  115. package/daemon/dist/adapters/tmux-credential-env.d.ts +4 -0
  116. package/daemon/dist/adapters/tmux-credential-env.d.ts.map +1 -0
  117. package/daemon/dist/adapters/tmux-credential-env.js +14 -0
  118. package/daemon/dist/adapters/tmux-credential-env.js.map +1 -0
  119. package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
  120. package/daemon/dist/adapters/tmux-exec.js +4 -3
  121. package/daemon/dist/adapters/tmux-exec.js.map +1 -1
  122. package/daemon/dist/adapters/tmux-server.d.ts +2 -2
  123. package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
  124. package/daemon/dist/adapters/tmux-server.js +12 -4
  125. package/daemon/dist/adapters/tmux-server.js.map +1 -1
  126. package/daemon/dist/adapters/tmux.d.ts +242 -14
  127. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  128. package/daemon/dist/adapters/tmux.js +966 -34
  129. package/daemon/dist/adapters/tmux.js.map +1 -1
  130. package/daemon/dist/attention-surface.d.ts +4 -1
  131. package/daemon/dist/attention-surface.d.ts.map +1 -1
  132. package/daemon/dist/attention-surface.js.map +1 -1
  133. package/daemon/dist/build-info.js +3 -3
  134. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  135. package/daemon/dist/db/all-migrations.js +14 -0
  136. package/daemon/dist/db/all-migrations.js.map +1 -1
  137. package/daemon/dist/db/migrations/171_claude_auto_mode.d.ts +4 -0
  138. package/daemon/dist/db/migrations/171_claude_auto_mode.d.ts.map +1 -0
  139. package/daemon/dist/db/migrations/171_claude_auto_mode.js +9 -0
  140. package/daemon/dist/db/migrations/171_claude_auto_mode.js.map +1 -0
  141. package/daemon/dist/db/migrations/171_node_input_route.d.ts +4 -0
  142. package/daemon/dist/db/migrations/171_node_input_route.d.ts.map +1 -0
  143. package/daemon/dist/db/migrations/171_node_input_route.js +6 -0
  144. package/daemon/dist/db/migrations/171_node_input_route.js.map +1 -0
  145. package/daemon/dist/db/migrations/171_seat_hook_bridge.d.ts +5 -0
  146. package/daemon/dist/db/migrations/171_seat_hook_bridge.d.ts.map +1 -0
  147. package/daemon/dist/db/migrations/171_seat_hook_bridge.js +25 -0
  148. package/daemon/dist/db/migrations/171_seat_hook_bridge.js.map +1 -0
  149. package/daemon/dist/db/migrations/172_queue_return_route.d.ts +3 -0
  150. package/daemon/dist/db/migrations/172_queue_return_route.d.ts.map +1 -0
  151. package/daemon/dist/db/migrations/172_queue_return_route.js +13 -0
  152. package/daemon/dist/db/migrations/172_queue_return_route.js.map +1 -0
  153. package/daemon/dist/db/migrations/173_node_process_limits.d.ts +4 -0
  154. package/daemon/dist/db/migrations/173_node_process_limits.d.ts.map +1 -0
  155. package/daemon/dist/db/migrations/173_node_process_limits.js +6 -0
  156. package/daemon/dist/db/migrations/173_node_process_limits.js.map +1 -0
  157. package/daemon/dist/db/migrations/174_session_launched_cwd.d.ts +6 -0
  158. package/daemon/dist/db/migrations/174_session_launched_cwd.d.ts.map +1 -0
  159. package/daemon/dist/db/migrations/174_session_launched_cwd.js +8 -0
  160. package/daemon/dist/db/migrations/174_session_launched_cwd.js.map +1 -0
  161. package/daemon/dist/db/migrations/175_core_app_access.d.ts +3 -0
  162. package/daemon/dist/db/migrations/175_core_app_access.d.ts.map +1 -0
  163. package/daemon/dist/db/migrations/175_core_app_access.js +26 -0
  164. package/daemon/dist/db/migrations/175_core_app_access.js.map +1 -0
  165. package/daemon/dist/domain/activity-grants.d.ts.map +1 -1
  166. package/daemon/dist/domain/activity-grants.js +8 -4
  167. package/daemon/dist/domain/activity-grants.js.map +1 -1
  168. package/daemon/dist/domain/agent-activity-store.d.ts +59 -1
  169. package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
  170. package/daemon/dist/domain/agent-activity-store.js +250 -4
  171. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  172. package/daemon/dist/domain/agent-images/resume-token-discovery.d.ts +10 -0
  173. package/daemon/dist/domain/agent-images/resume-token-discovery.d.ts.map +1 -1
  174. package/daemon/dist/domain/agent-images/resume-token-discovery.js +21 -0
  175. package/daemon/dist/domain/agent-images/resume-token-discovery.js.map +1 -1
  176. package/daemon/dist/domain/applied-launch-observation-store.d.ts +5 -0
  177. package/daemon/dist/domain/applied-launch-observation-store.d.ts.map +1 -1
  178. package/daemon/dist/domain/applied-launch-observation-store.js +57 -21
  179. package/daemon/dist/domain/applied-launch-observation-store.js.map +1 -1
  180. package/daemon/dist/domain/builtin-startup-files.d.ts +26 -12
  181. package/daemon/dist/domain/builtin-startup-files.d.ts.map +1 -1
  182. package/daemon/dist/domain/builtin-startup-files.js +73 -34
  183. package/daemon/dist/domain/builtin-startup-files.js.map +1 -1
  184. package/daemon/dist/domain/claude-activity-hooks.d.ts +4 -2
  185. package/daemon/dist/domain/claude-activity-hooks.d.ts.map +1 -1
  186. package/daemon/dist/domain/claude-activity-hooks.js +5 -3
  187. package/daemon/dist/domain/claude-activity-hooks.js.map +1 -1
  188. package/daemon/dist/domain/claude-auto-mode.d.ts +64 -0
  189. package/daemon/dist/domain/claude-auto-mode.d.ts.map +1 -0
  190. package/daemon/dist/domain/claude-auto-mode.js +114 -0
  191. package/daemon/dist/domain/claude-auto-mode.js.map +1 -0
  192. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +66 -3
  193. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  194. package/daemon/dist/domain/claude-compaction-enforcer.js +214 -10
  195. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  196. package/daemon/dist/domain/claude-continuation-launch.d.ts +5 -1
  197. package/daemon/dist/domain/claude-continuation-launch.d.ts.map +1 -1
  198. package/daemon/dist/domain/claude-continuation-launch.js +51 -2
  199. package/daemon/dist/domain/claude-continuation-launch.js.map +1 -1
  200. package/daemon/dist/domain/claude-core-plugin-env.d.ts +7 -3
  201. package/daemon/dist/domain/claude-core-plugin-env.d.ts.map +1 -1
  202. package/daemon/dist/domain/claude-core-plugin-env.js +11 -8
  203. package/daemon/dist/domain/claude-core-plugin-env.js.map +1 -1
  204. package/daemon/dist/domain/codex-daemon-support.d.ts.map +1 -1
  205. package/daemon/dist/domain/codex-daemon-support.js +6 -1
  206. package/daemon/dist/domain/codex-daemon-support.js.map +1 -1
  207. package/daemon/dist/domain/community-harness-launch-result.d.ts +2 -0
  208. package/daemon/dist/domain/community-harness-launch-result.d.ts.map +1 -1
  209. package/daemon/dist/domain/community-harness-launch-result.js +5 -1
  210. package/daemon/dist/domain/community-harness-launch-result.js.map +1 -1
  211. package/daemon/dist/domain/compaction-restore-notice.d.ts +3 -1
  212. package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -1
  213. package/daemon/dist/domain/compaction-restore-notice.js +22 -3
  214. package/daemon/dist/domain/compaction-restore-notice.js.map +1 -1
  215. package/daemon/dist/domain/configured-account.d.ts +3 -0
  216. package/daemon/dist/domain/configured-account.d.ts.map +1 -0
  217. package/daemon/dist/domain/configured-account.js +10 -0
  218. package/daemon/dist/domain/configured-account.js.map +1 -0
  219. package/daemon/dist/domain/connection-contract.d.ts +91 -0
  220. package/daemon/dist/domain/connection-contract.d.ts.map +1 -1
  221. package/daemon/dist/domain/connection-contract.js +73 -0
  222. package/daemon/dist/domain/connection-contract.js.map +1 -1
  223. package/daemon/dist/domain/context-usage-store.d.ts +5 -0
  224. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  225. package/daemon/dist/domain/context-usage-store.js +37 -2
  226. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  227. package/daemon/dist/domain/core-app-access.d.ts +51 -0
  228. package/daemon/dist/domain/core-app-access.d.ts.map +1 -0
  229. package/daemon/dist/domain/core-app-access.js +107 -0
  230. package/daemon/dist/domain/core-app-access.js.map +1 -0
  231. package/daemon/dist/domain/core-app-job.d.ts +411 -0
  232. package/daemon/dist/domain/core-app-job.d.ts.map +1 -0
  233. package/daemon/dist/domain/core-app-job.js +537 -0
  234. package/daemon/dist/domain/core-app-job.js.map +1 -0
  235. package/daemon/dist/domain/current-park-arm.d.ts +4 -0
  236. package/daemon/dist/domain/current-park-arm.d.ts.map +1 -0
  237. package/daemon/dist/domain/current-park-arm.js +14 -0
  238. package/daemon/dist/domain/current-park-arm.js.map +1 -0
  239. package/daemon/dist/domain/current-work.d.ts +6 -1
  240. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  241. package/daemon/dist/domain/current-work.js +41 -8
  242. package/daemon/dist/domain/current-work.js.map +1 -1
  243. package/daemon/dist/domain/cwd-resolution.d.ts +14 -0
  244. package/daemon/dist/domain/cwd-resolution.d.ts.map +1 -1
  245. package/daemon/dist/domain/cwd-resolution.js +28 -3
  246. package/daemon/dist/domain/cwd-resolution.js.map +1 -1
  247. package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
  248. package/daemon/dist/domain/draft-aware-delivery.js +5 -1
  249. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
  250. package/daemon/dist/domain/errors.d.ts +4 -0
  251. package/daemon/dist/domain/errors.d.ts.map +1 -1
  252. package/daemon/dist/domain/errors.js +7 -0
  253. package/daemon/dist/domain/errors.js.map +1 -1
  254. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  255. package/daemon/dist/domain/execution-view.js +17 -4
  256. package/daemon/dist/domain/execution-view.js.map +1 -1
  257. package/daemon/dist/domain/existing-rig-restore.d.ts +2 -0
  258. package/daemon/dist/domain/existing-rig-restore.d.ts.map +1 -1
  259. package/daemon/dist/domain/existing-rig-restore.js +1 -0
  260. package/daemon/dist/domain/existing-rig-restore.js.map +1 -1
  261. package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
  262. package/daemon/dist/domain/gateway/operator-delivery-engine.js +107 -3
  263. package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
  264. package/daemon/dist/domain/gateway/participants.d.ts +2 -0
  265. package/daemon/dist/domain/gateway/participants.d.ts.map +1 -1
  266. package/daemon/dist/domain/gateway/participants.js +5 -1
  267. package/daemon/dist/domain/gateway/participants.js.map +1 -1
  268. package/daemon/dist/domain/gateway/slack/capabilities.d.ts +9 -1
  269. package/daemon/dist/domain/gateway/slack/capabilities.d.ts.map +1 -1
  270. package/daemon/dist/domain/gateway/slack/capabilities.js +6 -1
  271. package/daemon/dist/domain/gateway/slack/capabilities.js.map +1 -1
  272. package/daemon/dist/domain/gateway/slack/inbound-admission.js +1 -1
  273. package/daemon/dist/domain/gateway/slack/inbound-admission.js.map +1 -1
  274. package/daemon/dist/domain/gateway/slack/inbound.d.ts +4 -0
  275. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  276. package/daemon/dist/domain/gateway/slack/inbound.js +15 -1
  277. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  278. package/daemon/dist/domain/gateway/slack/manifest.d.ts +5 -1
  279. package/daemon/dist/domain/gateway/slack/manifest.d.ts.map +1 -1
  280. package/daemon/dist/domain/gateway/slack/manifest.js +12 -3
  281. package/daemon/dist/domain/gateway/slack/manifest.js.map +1 -1
  282. package/daemon/dist/domain/gateway/slack/message.d.ts +2 -0
  283. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  284. package/daemon/dist/domain/gateway/slack/message.js +41 -18
  285. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  286. package/daemon/dist/domain/gateway/slack/queue-access.d.ts +2 -0
  287. package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
  288. package/daemon/dist/domain/gateway/slack/queue-access.js +1 -0
  289. package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
  290. package/daemon/dist/domain/gateway/slack/settled-asks.d.ts.map +1 -1
  291. package/daemon/dist/domain/gateway/slack/settled-asks.js +6 -5
  292. package/daemon/dist/domain/gateway/slack/settled-asks.js.map +1 -1
  293. package/daemon/dist/domain/gateway/slack/slack-api.d.ts +1 -0
  294. package/daemon/dist/domain/gateway/slack/slack-api.d.ts.map +1 -1
  295. package/daemon/dist/domain/gateway/slack/slack-api.js +7 -2
  296. package/daemon/dist/domain/gateway/slack/slack-api.js.map +1 -1
  297. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts +1 -0
  298. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
  299. package/daemon/dist/domain/gateway/slack/slack-delivery.js +2 -0
  300. package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
  301. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts +4 -0
  302. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
  303. package/daemon/dist/domain/gateway/slack/slack-subsystem.js +26 -2
  304. package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
  305. package/daemon/dist/domain/harness-not-started-notice.d.ts +36 -0
  306. package/daemon/dist/domain/harness-not-started-notice.d.ts.map +1 -0
  307. package/daemon/dist/domain/harness-not-started-notice.js +81 -0
  308. package/daemon/dist/domain/harness-not-started-notice.js.map +1 -0
  309. package/daemon/dist/domain/hook-bridge.d.ts +345 -0
  310. package/daemon/dist/domain/hook-bridge.d.ts.map +1 -0
  311. package/daemon/dist/domain/hook-bridge.js +547 -0
  312. package/daemon/dist/domain/hook-bridge.js.map +1 -0
  313. package/daemon/dist/domain/hosted-wake.d.ts +9 -0
  314. package/daemon/dist/domain/hosted-wake.d.ts.map +1 -1
  315. package/daemon/dist/domain/hosted-wake.js +45 -6
  316. package/daemon/dist/domain/hosted-wake.js.map +1 -1
  317. package/daemon/dist/domain/hot-potato-enforcer.d.ts +1 -1
  318. package/daemon/dist/domain/human-ask-attention.d.ts +10 -0
  319. package/daemon/dist/domain/human-ask-attention.d.ts.map +1 -0
  320. package/daemon/dist/domain/human-ask-attention.js +22 -0
  321. package/daemon/dist/domain/human-ask-attention.js.map +1 -0
  322. package/daemon/dist/domain/input-read-diagnostic.js +1 -1
  323. package/daemon/dist/domain/input-read-diagnostic.js.map +1 -1
  324. package/daemon/dist/domain/instance-initialization.d.ts +2 -0
  325. package/daemon/dist/domain/instance-initialization.d.ts.map +1 -1
  326. package/daemon/dist/domain/instance-initialization.js +2 -1
  327. package/daemon/dist/domain/instance-initialization.js.map +1 -1
  328. package/daemon/dist/domain/member-connection.d.ts +14 -0
  329. package/daemon/dist/domain/member-connection.d.ts.map +1 -0
  330. package/daemon/dist/domain/member-connection.js +34 -0
  331. package/daemon/dist/domain/member-connection.js.map +1 -0
  332. package/daemon/dist/domain/mission-control/mission-control-action-log.d.ts +4 -0
  333. package/daemon/dist/domain/mission-control/mission-control-action-log.d.ts.map +1 -1
  334. package/daemon/dist/domain/mission-control/mission-control-action-log.js +8 -1
  335. package/daemon/dist/domain/mission-control/mission-control-action-log.js.map +1 -1
  336. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +10 -0
  337. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  338. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +64 -12
  339. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  340. package/daemon/dist/domain/model-divergence/current-model-reader.d.ts +3 -1
  341. package/daemon/dist/domain/model-divergence/current-model-reader.d.ts.map +1 -1
  342. package/daemon/dist/domain/model-divergence/current-model-reader.js +32 -7
  343. package/daemon/dist/domain/model-divergence/current-model-reader.js.map +1 -1
  344. package/daemon/dist/domain/native-continuation-notice.d.ts +16 -0
  345. package/daemon/dist/domain/native-continuation-notice.d.ts.map +1 -0
  346. package/daemon/dist/domain/native-continuation-notice.js +79 -0
  347. package/daemon/dist/domain/native-continuation-notice.js.map +1 -0
  348. package/daemon/dist/domain/native-permission-store.d.ts +6 -2
  349. package/daemon/dist/domain/native-permission-store.d.ts.map +1 -1
  350. package/daemon/dist/domain/native-permission-store.js +12 -5
  351. package/daemon/dist/domain/native-permission-store.js.map +1 -1
  352. package/daemon/dist/domain/native-process-lineage.d.ts +16 -0
  353. package/daemon/dist/domain/native-process-lineage.d.ts.map +1 -1
  354. package/daemon/dist/domain/native-process-lineage.js +48 -3
  355. package/daemon/dist/domain/native-process-lineage.js.map +1 -1
  356. package/daemon/dist/domain/native-resume-probe.d.ts +5 -0
  357. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  358. package/daemon/dist/domain/native-resume-probe.js +94 -10
  359. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  360. package/daemon/dist/domain/network/network-connector.d.ts.map +1 -1
  361. package/daemon/dist/domain/network/network-connector.js +11 -2
  362. package/daemon/dist/domain/network/network-connector.js.map +1 -1
  363. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  364. package/daemon/dist/domain/node-inventory.js +55 -6
  365. package/daemon/dist/domain/node-inventory.js.map +1 -1
  366. package/daemon/dist/domain/node-launcher.d.ts +14 -0
  367. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  368. package/daemon/dist/domain/node-launcher.js +35 -6
  369. package/daemon/dist/domain/node-launcher.js.map +1 -1
  370. package/daemon/dist/domain/outbox-handler.d.ts +69 -1
  371. package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
  372. package/daemon/dist/domain/outbox-handler.js +337 -3
  373. package/daemon/dist/domain/outbox-handler.js.map +1 -1
  374. package/daemon/dist/domain/park-wake-text.d.ts +18 -0
  375. package/daemon/dist/domain/park-wake-text.d.ts.map +1 -1
  376. package/daemon/dist/domain/park-wake-text.js +44 -0
  377. package/daemon/dist/domain/park-wake-text.js.map +1 -1
  378. package/daemon/dist/domain/parked-query.d.ts.map +1 -1
  379. package/daemon/dist/domain/parked-query.js +3 -1
  380. package/daemon/dist/domain/parked-query.js.map +1 -1
  381. package/daemon/dist/domain/permission-account.d.ts +28 -1
  382. package/daemon/dist/domain/permission-account.d.ts.map +1 -1
  383. package/daemon/dist/domain/permission-account.js +55 -11
  384. package/daemon/dist/domain/permission-account.js.map +1 -1
  385. package/daemon/dist/domain/permission-drift.d.ts +2 -0
  386. package/daemon/dist/domain/permission-drift.d.ts.map +1 -1
  387. package/daemon/dist/domain/permission-drift.js.map +1 -1
  388. package/daemon/dist/domain/pi-compaction-request-store.d.ts +16 -0
  389. package/daemon/dist/domain/pi-compaction-request-store.d.ts.map +1 -0
  390. package/daemon/dist/domain/pi-compaction-request-store.js +40 -0
  391. package/daemon/dist/domain/pi-compaction-request-store.js.map +1 -0
  392. package/daemon/dist/domain/pi-compaction-service.d.ts +82 -0
  393. package/daemon/dist/domain/pi-compaction-service.d.ts.map +1 -0
  394. package/daemon/dist/domain/pi-compaction-service.js +229 -0
  395. package/daemon/dist/domain/pi-compaction-service.js.map +1 -0
  396. package/daemon/dist/domain/policies/idle-gate-qitem.d.ts +3 -0
  397. package/daemon/dist/domain/policies/idle-gate-qitem.d.ts.map +1 -1
  398. package/daemon/dist/domain/policies/idle-gate-qitem.js +15 -0
  399. package/daemon/dist/domain/policies/idle-gate-qitem.js.map +1 -1
  400. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +6 -1
  401. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
  402. package/daemon/dist/domain/policies/parked-owner-consumer.js +28 -1
  403. package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
  404. package/daemon/dist/domain/process-limits.d.ts +47 -0
  405. package/daemon/dist/domain/process-limits.d.ts.map +1 -0
  406. package/daemon/dist/domain/process-limits.js +123 -0
  407. package/daemon/dist/domain/process-limits.js.map +1 -0
  408. package/daemon/dist/domain/process-table.d.ts +24 -0
  409. package/daemon/dist/domain/process-table.d.ts.map +1 -1
  410. package/daemon/dist/domain/process-table.js +60 -4
  411. package/daemon/dist/domain/process-table.js.map +1 -1
  412. package/daemon/dist/domain/proof/judgments.d.ts +7 -0
  413. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  414. package/daemon/dist/domain/proof/judgments.js +27 -1
  415. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  416. package/daemon/dist/domain/ps-projection.d.ts +2 -1
  417. package/daemon/dist/domain/ps-projection.d.ts.map +1 -1
  418. package/daemon/dist/domain/ps-projection.js +6 -1
  419. package/daemon/dist/domain/ps-projection.js.map +1 -1
  420. package/daemon/dist/domain/queue-erasure.d.ts +11 -6
  421. package/daemon/dist/domain/queue-erasure.d.ts.map +1 -1
  422. package/daemon/dist/domain/queue-erasure.js +47 -21
  423. package/daemon/dist/domain/queue-erasure.js.map +1 -1
  424. package/daemon/dist/domain/queue-repository.d.ts +122 -21
  425. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  426. package/daemon/dist/domain/queue-repository.js +448 -101
  427. package/daemon/dist/domain/queue-repository.js.map +1 -1
  428. package/daemon/dist/domain/queue-stuck-sweep.d.ts +5 -0
  429. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  430. package/daemon/dist/domain/queue-stuck-sweep.js +74 -13
  431. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  432. package/daemon/dist/domain/queue-transition-log.d.ts +5 -3
  433. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  434. package/daemon/dist/domain/queue-transition-log.js +9 -6
  435. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  436. package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
  437. package/daemon/dist/domain/queue-waiting.js +28 -3
  438. package/daemon/dist/domain/queue-waiting.js.map +1 -1
  439. package/daemon/dist/domain/queue-wake-ladder.d.ts +20 -0
  440. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  441. package/daemon/dist/domain/queue-wake-ladder.js +264 -25
  442. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  443. package/daemon/dist/domain/queue-wake-repository.d.ts +10 -1
  444. package/daemon/dist/domain/queue-wake-repository.d.ts.map +1 -1
  445. package/daemon/dist/domain/queue-wake-repository.js +79 -12
  446. package/daemon/dist/domain/queue-wake-repository.js.map +1 -1
  447. package/daemon/dist/domain/reconciler.d.ts +18 -2
  448. package/daemon/dist/domain/reconciler.d.ts.map +1 -1
  449. package/daemon/dist/domain/reconciler.js +40 -0
  450. package/daemon/dist/domain/reconciler.js.map +1 -1
  451. package/daemon/dist/domain/restore-attempt-receipt.d.ts.map +1 -1
  452. package/daemon/dist/domain/restore-attempt-receipt.js +3 -2
  453. package/daemon/dist/domain/restore-attempt-receipt.js.map +1 -1
  454. package/daemon/dist/domain/restore-check-service.d.ts +10 -0
  455. package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
  456. package/daemon/dist/domain/restore-check-service.js +76 -3
  457. package/daemon/dist/domain/restore-check-service.js.map +1 -1
  458. package/daemon/dist/domain/restore-orchestrator.d.ts +65 -3
  459. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  460. package/daemon/dist/domain/restore-orchestrator.js +311 -55
  461. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  462. package/daemon/dist/domain/restore-plan-preview.d.ts +28 -1
  463. package/daemon/dist/domain/restore-plan-preview.d.ts.map +1 -1
  464. package/daemon/dist/domain/restore-plan-preview.js +17 -5
  465. package/daemon/dist/domain/restore-plan-preview.js.map +1 -1
  466. package/daemon/dist/domain/restore-preconditions.d.ts +24 -0
  467. package/daemon/dist/domain/restore-preconditions.d.ts.map +1 -1
  468. package/daemon/dist/domain/restore-preconditions.js +61 -1
  469. package/daemon/dist/domain/restore-preconditions.js.map +1 -1
  470. package/daemon/dist/domain/restore-topology.d.ts +7 -1
  471. package/daemon/dist/domain/restore-topology.d.ts.map +1 -1
  472. package/daemon/dist/domain/restore-topology.js +21 -0
  473. package/daemon/dist/domain/restore-topology.js.map +1 -1
  474. package/daemon/dist/domain/resume-metadata-refresher.d.ts +2 -3
  475. package/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
  476. package/daemon/dist/domain/resume-metadata-refresher.js +6 -25
  477. package/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
  478. package/daemon/dist/domain/resume-token-validation.d.ts +3 -1
  479. package/daemon/dist/domain/resume-token-validation.d.ts.map +1 -1
  480. package/daemon/dist/domain/resume-token-validation.js +6 -3
  481. package/daemon/dist/domain/resume-token-validation.js.map +1 -1
  482. package/daemon/dist/domain/return-route.d.ts +73 -0
  483. package/daemon/dist/domain/return-route.d.ts.map +1 -0
  484. package/daemon/dist/domain/return-route.js +124 -0
  485. package/daemon/dist/domain/return-route.js.map +1 -0
  486. package/daemon/dist/domain/rig-expansion-service.js +1 -1
  487. package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
  488. package/daemon/dist/domain/rig-repository.d.ts +12 -0
  489. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  490. package/daemon/dist/domain/rig-repository.js +74 -0
  491. package/daemon/dist/domain/rig-repository.js.map +1 -1
  492. package/daemon/dist/domain/rig-teardown.d.ts +20 -5
  493. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  494. package/daemon/dist/domain/rig-teardown.js +105 -22
  495. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  496. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  497. package/daemon/dist/domain/rigspec-codec.js +9 -0
  498. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  499. package/daemon/dist/domain/rigspec-exporter.d.ts +6 -0
  500. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  501. package/daemon/dist/domain/rigspec-exporter.js +30 -0
  502. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  503. package/daemon/dist/domain/rigspec-instantiator.d.ts +27 -2
  504. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  505. package/daemon/dist/domain/rigspec-instantiator.js +95 -26
  506. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  507. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  508. package/daemon/dist/domain/rigspec-schema.js +44 -1
  509. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  510. package/daemon/dist/domain/rosters.d.ts +23 -0
  511. package/daemon/dist/domain/rosters.d.ts.map +1 -1
  512. package/daemon/dist/domain/rosters.js +37 -5
  513. package/daemon/dist/domain/rosters.js.map +1 -1
  514. package/daemon/dist/domain/runner-channel.d.ts +65 -0
  515. package/daemon/dist/domain/runner-channel.d.ts.map +1 -0
  516. package/daemon/dist/domain/runner-channel.js +348 -0
  517. package/daemon/dist/domain/runner-channel.js.map +1 -0
  518. package/daemon/dist/domain/runner-grant-launch.js +2 -2
  519. package/daemon/dist/domain/runner-permissions.d.ts +26 -3
  520. package/daemon/dist/domain/runner-permissions.d.ts.map +1 -1
  521. package/daemon/dist/domain/runner-permissions.js +160 -39
  522. package/daemon/dist/domain/runner-permissions.js.map +1 -1
  523. package/daemon/dist/domain/runtime-adapter.d.ts +2 -0
  524. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  525. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  526. package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -1
  527. package/daemon/dist/domain/runtime-switch-materials.js +4 -3
  528. package/daemon/dist/domain/runtime-switch-materials.js.map +1 -1
  529. package/daemon/dist/domain/scope/mission-parent.d.ts +19 -0
  530. package/daemon/dist/domain/scope/mission-parent.d.ts.map +1 -0
  531. package/daemon/dist/domain/scope/mission-parent.js +134 -0
  532. package/daemon/dist/domain/scope/mission-parent.js.map +1 -0
  533. package/daemon/dist/domain/scope/scope-audit.d.ts.map +1 -1
  534. package/daemon/dist/domain/scope/scope-audit.js +63 -3
  535. package/daemon/dist/domain/scope/scope-audit.js.map +1 -1
  536. package/daemon/dist/domain/scope/types.d.ts +3 -1
  537. package/daemon/dist/domain/scope/types.d.ts.map +1 -1
  538. package/daemon/dist/domain/scope/types.js +5 -1
  539. package/daemon/dist/domain/scope/types.js.map +1 -1
  540. package/daemon/dist/domain/seat-attention-reconciler.d.ts +6 -4
  541. package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
  542. package/daemon/dist/domain/seat-attention-reconciler.js +17 -10
  543. package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
  544. package/daemon/dist/domain/seat-delivery-guard.d.ts +14 -2
  545. package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
  546. package/daemon/dist/domain/seat-delivery-guard.js +55 -15
  547. package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
  548. package/daemon/dist/domain/seat-handover-service.d.ts +27 -4
  549. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  550. package/daemon/dist/domain/seat-handover-service.js +210 -65
  551. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  552. package/daemon/dist/domain/seat-identity-reconciler.d.ts +12 -4
  553. package/daemon/dist/domain/seat-identity-reconciler.d.ts.map +1 -1
  554. package/daemon/dist/domain/seat-identity-reconciler.js +92 -17
  555. package/daemon/dist/domain/seat-identity-reconciler.js.map +1 -1
  556. package/daemon/dist/domain/seat-lifecycle-service.d.ts +31 -6
  557. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  558. package/daemon/dist/domain/seat-lifecycle-service.js +172 -24
  559. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  560. package/daemon/dist/domain/seat-restart-in-place.d.ts +9 -2
  561. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  562. package/daemon/dist/domain/seat-restart-in-place.js +38 -3
  563. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  564. package/daemon/dist/domain/seat-runtime-switch-service.d.ts +4 -0
  565. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  566. package/daemon/dist/domain/seat-runtime-switch-service.js +11 -3
  567. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  568. package/daemon/dist/domain/seat-skill-apply.d.ts +1 -1
  569. package/daemon/dist/domain/seat-skill-apply.d.ts.map +1 -1
  570. package/daemon/dist/domain/seat-skill-apply.js +3 -2
  571. package/daemon/dist/domain/seat-skill-apply.js.map +1 -1
  572. package/daemon/dist/domain/seat-status-service.d.ts +4 -0
  573. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  574. package/daemon/dist/domain/seat-status-service.js +31 -6
  575. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  576. package/daemon/dist/domain/session-registry.d.ts +5 -1
  577. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  578. package/daemon/dist/domain/session-registry.js +12 -1
  579. package/daemon/dist/domain/session-registry.js.map +1 -1
  580. package/daemon/dist/domain/session-transport.d.ts +56 -4
  581. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  582. package/daemon/dist/domain/session-transport.js +344 -18
  583. package/daemon/dist/domain/session-transport.js.map +1 -1
  584. package/daemon/dist/domain/shared-conversation.d.ts +58 -0
  585. package/daemon/dist/domain/shared-conversation.d.ts.map +1 -0
  586. package/daemon/dist/domain/shared-conversation.js +98 -0
  587. package/daemon/dist/domain/shared-conversation.js.map +1 -0
  588. package/daemon/dist/domain/shared-history-selection.d.ts.map +1 -1
  589. package/daemon/dist/domain/shared-history-selection.js +9 -5
  590. package/daemon/dist/domain/shared-history-selection.js.map +1 -1
  591. package/daemon/dist/domain/slices/slice-indexer.d.ts +1 -1
  592. package/daemon/dist/domain/slices/slice-indexer.d.ts.map +1 -1
  593. package/daemon/dist/domain/slices/slice-indexer.js +4 -0
  594. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  595. package/daemon/dist/domain/startup-orchestrator.d.ts +1 -0
  596. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  597. package/daemon/dist/domain/startup-orchestrator.js +6 -4
  598. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  599. package/daemon/dist/domain/startup-phase-timing.d.ts +19 -0
  600. package/daemon/dist/domain/startup-phase-timing.d.ts.map +1 -0
  601. package/daemon/dist/domain/startup-phase-timing.js +23 -0
  602. package/daemon/dist/domain/startup-phase-timing.js.map +1 -0
  603. package/daemon/dist/domain/successor-session-launcher.d.ts +9 -0
  604. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  605. package/daemon/dist/domain/successor-session-launcher.js +33 -10
  606. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  607. package/daemon/dist/domain/team-operations.d.ts +6 -6
  608. package/daemon/dist/domain/team-operations.d.ts.map +1 -1
  609. package/daemon/dist/domain/team-operations.js +2 -4
  610. package/daemon/dist/domain/team-operations.js.map +1 -1
  611. package/daemon/dist/domain/terminal/herdr-adapter.d.ts +35 -1
  612. package/daemon/dist/domain/terminal/herdr-adapter.d.ts.map +1 -1
  613. package/daemon/dist/domain/terminal/herdr-adapter.js +231 -33
  614. package/daemon/dist/domain/terminal/herdr-adapter.js.map +1 -1
  615. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts +6 -0
  616. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts.map +1 -1
  617. package/daemon/dist/domain/terminal/herdr-app-provider.js +23 -1
  618. package/daemon/dist/domain/terminal/herdr-app-provider.js.map +1 -1
  619. package/daemon/dist/domain/terminal/herdr-sessions.d.ts.map +1 -1
  620. package/daemon/dist/domain/terminal/herdr-sessions.js +2 -1
  621. package/daemon/dist/domain/terminal/herdr-sessions.js.map +1 -1
  622. package/daemon/dist/domain/terminal/rig-viewer-records.d.ts +59 -0
  623. package/daemon/dist/domain/terminal/rig-viewer-records.d.ts.map +1 -0
  624. package/daemon/dist/domain/terminal/rig-viewer-records.js +210 -0
  625. package/daemon/dist/domain/terminal/rig-viewer-records.js.map +1 -0
  626. package/daemon/dist/domain/terminal/terminal-provider.d.ts +2 -0
  627. package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
  628. package/daemon/dist/domain/terminal/terminal-service.d.ts +99 -4
  629. package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
  630. package/daemon/dist/domain/terminal/terminal-service.js +556 -36
  631. package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
  632. package/daemon/dist/domain/terminal/tile-layout.js +1 -1
  633. package/daemon/dist/domain/terminal/tile-layout.js.map +1 -1
  634. package/daemon/dist/domain/terminal/tmux-viewer-guard.d.ts +25 -0
  635. package/daemon/dist/domain/terminal/tmux-viewer-guard.d.ts.map +1 -0
  636. package/daemon/dist/domain/terminal/tmux-viewer-guard.js +70 -0
  637. package/daemon/dist/domain/terminal/tmux-viewer-guard.js.map +1 -0
  638. package/daemon/dist/domain/terminal-policy.js +1 -1
  639. package/daemon/dist/domain/terminal-policy.js.map +1 -1
  640. package/daemon/dist/domain/transcript-grep-worker.d.ts +2 -0
  641. package/daemon/dist/domain/transcript-grep-worker.d.ts.map +1 -0
  642. package/daemon/dist/domain/transcript-grep-worker.js +108 -0
  643. package/daemon/dist/domain/transcript-grep-worker.js.map +1 -0
  644. package/daemon/dist/domain/transcript-grep.d.ts +26 -0
  645. package/daemon/dist/domain/transcript-grep.d.ts.map +1 -0
  646. package/daemon/dist/domain/transcript-grep.js +90 -0
  647. package/daemon/dist/domain/transcript-grep.js.map +1 -0
  648. package/daemon/dist/domain/transcript-store.d.ts +8 -2
  649. package/daemon/dist/domain/transcript-store.d.ts.map +1 -1
  650. package/daemon/dist/domain/transcript-store.js +10 -60
  651. package/daemon/dist/domain/transcript-store.js.map +1 -1
  652. package/daemon/dist/domain/types.d.ts +149 -5
  653. package/daemon/dist/domain/types.d.ts.map +1 -1
  654. package/daemon/dist/domain/types.js.map +1 -1
  655. package/daemon/dist/domain/watchdog-delivery-receipts.d.ts +4 -0
  656. package/daemon/dist/domain/watchdog-delivery-receipts.d.ts.map +1 -1
  657. package/daemon/dist/domain/watchdog-delivery-receipts.js +35 -2
  658. package/daemon/dist/domain/watchdog-delivery-receipts.js.map +1 -1
  659. package/daemon/dist/domain/watchdog-delivery.d.ts +45 -1
  660. package/daemon/dist/domain/watchdog-delivery.d.ts.map +1 -1
  661. package/daemon/dist/domain/watchdog-delivery.js +66 -5
  662. package/daemon/dist/domain/watchdog-delivery.js.map +1 -1
  663. package/daemon/dist/domain/watchdog-history-log.d.ts +12 -0
  664. package/daemon/dist/domain/watchdog-history-log.d.ts.map +1 -1
  665. package/daemon/dist/domain/watchdog-history-log.js +19 -1
  666. package/daemon/dist/domain/watchdog-history-log.js.map +1 -1
  667. package/daemon/dist/domain/watchdog-jobs-repository.d.ts +32 -0
  668. package/daemon/dist/domain/watchdog-jobs-repository.d.ts.map +1 -1
  669. package/daemon/dist/domain/watchdog-jobs-repository.js +79 -0
  670. package/daemon/dist/domain/watchdog-jobs-repository.js.map +1 -1
  671. package/daemon/dist/domain/watchdog-policy-engine.d.ts +22 -3
  672. package/daemon/dist/domain/watchdog-policy-engine.d.ts.map +1 -1
  673. package/daemon/dist/domain/watchdog-policy-engine.js +33 -9
  674. package/daemon/dist/domain/watchdog-policy-engine.js.map +1 -1
  675. package/daemon/dist/domain/workflow-projector.js +1 -1
  676. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  677. package/daemon/dist/domain/workflow-runtime.d.ts +13 -1
  678. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  679. package/daemon/dist/domain/workflow-runtime.js +68 -9
  680. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  681. package/daemon/dist/domain/workflow-step-trail-log.d.ts +2 -2
  682. package/daemon/dist/domain/workflow-step-trail-log.d.ts.map +1 -1
  683. package/daemon/dist/domain/workflow-step-trail-log.js.map +1 -1
  684. package/daemon/dist/domain/workflow-types.d.ts +3 -1
  685. package/daemon/dist/domain/workflow-types.d.ts.map +1 -1
  686. package/daemon/dist/domain/workflow-types.js.map +1 -1
  687. package/daemon/dist/domain/workspace/default-workspace-scaffold.d.ts +7 -1
  688. package/daemon/dist/domain/workspace/default-workspace-scaffold.d.ts.map +1 -1
  689. package/daemon/dist/domain/workspace/default-workspace-scaffold.js +35 -7
  690. package/daemon/dist/domain/workspace/default-workspace-scaffold.js.map +1 -1
  691. package/daemon/dist/gateway-slack-surface.d.ts +2 -2
  692. package/daemon/dist/gateway-slack-surface.d.ts.map +1 -1
  693. package/daemon/dist/gateway-slack-surface.js +1 -1
  694. package/daemon/dist/gateway-slack-surface.js.map +1 -1
  695. package/daemon/dist/index.d.ts.map +1 -1
  696. package/daemon/dist/index.js +17 -2
  697. package/daemon/dist/index.js.map +1 -1
  698. package/daemon/dist/lib/pane-envelope.d.ts +3 -0
  699. package/daemon/dist/lib/pane-envelope.d.ts.map +1 -1
  700. package/daemon/dist/lib/pane-envelope.js +3 -1
  701. package/daemon/dist/lib/pane-envelope.js.map +1 -1
  702. package/daemon/dist/mission-parent-surface.d.ts +2 -0
  703. package/daemon/dist/mission-parent-surface.d.ts.map +1 -0
  704. package/daemon/dist/mission-parent-surface.js +2 -0
  705. package/daemon/dist/mission-parent-surface.js.map +1 -0
  706. package/daemon/dist/routes/activity.d.ts +18 -1
  707. package/daemon/dist/routes/activity.d.ts.map +1 -1
  708. package/daemon/dist/routes/activity.js +150 -9
  709. package/daemon/dist/routes/activity.js.map +1 -1
  710. package/daemon/dist/routes/agent-images.d.ts.map +1 -1
  711. package/daemon/dist/routes/agent-images.js +6 -1
  712. package/daemon/dist/routes/agent-images.js.map +1 -1
  713. package/daemon/dist/routes/attention.d.ts.map +1 -1
  714. package/daemon/dist/routes/attention.js +194 -176
  715. package/daemon/dist/routes/attention.js.map +1 -1
  716. package/daemon/dist/routes/compaction.d.ts.map +1 -1
  717. package/daemon/dist/routes/compaction.js +46 -7
  718. package/daemon/dist/routes/compaction.js.map +1 -1
  719. package/daemon/dist/routes/core-app.d.ts +10 -0
  720. package/daemon/dist/routes/core-app.d.ts.map +1 -0
  721. package/daemon/dist/routes/core-app.js +175 -0
  722. package/daemon/dist/routes/core-app.js.map +1 -0
  723. package/daemon/dist/routes/hook-bridge.d.ts +3 -0
  724. package/daemon/dist/routes/hook-bridge.d.ts.map +1 -0
  725. package/daemon/dist/routes/hook-bridge.js +158 -0
  726. package/daemon/dist/routes/hook-bridge.js.map +1 -0
  727. package/daemon/dist/routes/missions.d.ts.map +1 -1
  728. package/daemon/dist/routes/missions.js +14 -2
  729. package/daemon/dist/routes/missions.js.map +1 -1
  730. package/daemon/dist/routes/queue.d.ts +4 -1
  731. package/daemon/dist/routes/queue.d.ts.map +1 -1
  732. package/daemon/dist/routes/queue.js +239 -38
  733. package/daemon/dist/routes/queue.js.map +1 -1
  734. package/daemon/dist/routes/require-sender-identity.d.ts +4 -3
  735. package/daemon/dist/routes/require-sender-identity.d.ts.map +1 -1
  736. package/daemon/dist/routes/require-sender-identity.js.map +1 -1
  737. package/daemon/dist/routes/restore-check.d.ts.map +1 -1
  738. package/daemon/dist/routes/restore-check.js +1 -0
  739. package/daemon/dist/routes/restore-check.js.map +1 -1
  740. package/daemon/dist/routes/rigspec.d.ts.map +1 -1
  741. package/daemon/dist/routes/rigspec.js +24 -4
  742. package/daemon/dist/routes/rigspec.js.map +1 -1
  743. package/daemon/dist/routes/scope-audit.d.ts.map +1 -1
  744. package/daemon/dist/routes/scope-audit.js +7 -1
  745. package/daemon/dist/routes/scope-audit.js.map +1 -1
  746. package/daemon/dist/routes/seat.d.ts.map +1 -1
  747. package/daemon/dist/routes/seat.js +133 -6
  748. package/daemon/dist/routes/seat.js.map +1 -1
  749. package/daemon/dist/routes/sessions.js +14 -3
  750. package/daemon/dist/routes/sessions.js.map +1 -1
  751. package/daemon/dist/routes/slices.d.ts.map +1 -1
  752. package/daemon/dist/routes/slices.js +21 -2
  753. package/daemon/dist/routes/slices.js.map +1 -1
  754. package/daemon/dist/routes/startup.js +9 -2
  755. package/daemon/dist/routes/startup.js.map +1 -1
  756. package/daemon/dist/routes/terminal.d.ts.map +1 -1
  757. package/daemon/dist/routes/terminal.js +47 -6
  758. package/daemon/dist/routes/terminal.js.map +1 -1
  759. package/daemon/dist/routes/transcripts.d.ts.map +1 -1
  760. package/daemon/dist/routes/transcripts.js +16 -1
  761. package/daemon/dist/routes/transcripts.js.map +1 -1
  762. package/daemon/dist/routes/up.d.ts.map +1 -1
  763. package/daemon/dist/routes/up.js +14 -4
  764. package/daemon/dist/routes/up.js.map +1 -1
  765. package/daemon/dist/routes/watchdog.d.ts.map +1 -1
  766. package/daemon/dist/routes/watchdog.js +21 -3
  767. package/daemon/dist/routes/watchdog.js.map +1 -1
  768. package/daemon/dist/routes/workflow.d.ts.map +1 -1
  769. package/daemon/dist/routes/workflow.js +5 -0
  770. package/daemon/dist/routes/workflow.js.map +1 -1
  771. package/daemon/dist/server.d.ts +5 -0
  772. package/daemon/dist/server.d.ts.map +1 -1
  773. package/daemon/dist/server.js +22 -0
  774. package/daemon/dist/server.js.map +1 -1
  775. package/daemon/dist/startup.d.ts.map +1 -1
  776. package/daemon/dist/startup.js +140 -48
  777. package/daemon/dist/startup.js.map +1 -1
  778. package/daemon/dist/terminal-viewer-guard-surface.d.ts +2 -0
  779. package/daemon/dist/terminal-viewer-guard-surface.d.ts.map +1 -0
  780. package/daemon/dist/terminal-viewer-guard-surface.js +2 -0
  781. package/daemon/dist/terminal-viewer-guard-surface.js.map +1 -0
  782. package/daemon/docs/reference/agent-startup-guide.md +5 -1
  783. package/daemon/docs/reference/claude-status-line.md +3 -2
  784. package/daemon/docs/reference/community-harness-examples/cursor/openrig-cursor-launch +6 -0
  785. package/daemon/docs/reference/community-harness-examples/dsh/README.md +8 -0
  786. package/daemon/docs/reference/community-harness-examples/dsh/openrig-dsh-runner.mjs +310 -20
  787. package/daemon/docs/reference/community-harness-examples/hermes/openrig-hermes-launch +6 -0
  788. package/daemon/docs/reference/community-harness-examples/openclaw/openrig-openclaw-launch +6 -0
  789. package/daemon/docs/reference/community-harness-examples/openshell/README.md +2 -0
  790. package/daemon/docs/reference/community-harness-examples/pi-tui/openrig-pi-tui-launch +6 -0
  791. package/daemon/docs/reference/community-harness-presets.md +7 -4
  792. package/daemon/docs/reference/core-app.md +212 -0
  793. package/daemon/docs/reference/daemon-http-clients.md +67 -12
  794. package/daemon/docs/reference/getting-started.md +9 -4
  795. package/daemon/docs/reference/harness-runner-contract.md +140 -4
  796. package/daemon/docs/reference/herdr-app.md +6 -0
  797. package/daemon/docs/reference/hosted-members.md +21 -1
  798. package/daemon/docs/reference/quickstart.md +4 -3
  799. package/daemon/docs/reference/rig-spec.md +197 -1
  800. package/daemon/docs/reference/rosters.md +17 -0
  801. package/daemon/docs/reference/sdlc-conventions.md +47 -6
  802. package/daemon/docs/reference/seat-delivery.md +87 -6
  803. package/daemon/docs/reference/slack-app-setup.md +39 -21
  804. package/daemon/docs/reference/terminal-sessions.md +99 -1
  805. package/daemon/docs/reference/whats-new.md +187 -15
  806. package/daemon/specs/agents/shared/skills/core/messaging-the-human/SKILL.md +23 -0
  807. package/daemon/specs/rigs/launch/factory/guidance/lead-first-move.md +27 -5
  808. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +32 -8
  809. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/startup/context.md +1 -1
  810. package/daemon/specs/rigs/launch/kernel/culture/CULTURE.md +12 -0
  811. package/daemon/specs/rigs/launch/starter/guidance/lead-first-move.md +27 -5
  812. package/dist/acp/connector.js +1 -1
  813. package/dist/acp/connector.js.map +1 -1
  814. package/dist/ask-wake.d.ts.map +1 -1
  815. package/dist/ask-wake.js +8 -1
  816. package/dist/ask-wake.js.map +1 -1
  817. package/dist/build-info.js +3 -3
  818. package/dist/cli-error.d.ts.map +1 -1
  819. package/dist/cli-error.js +7 -1
  820. package/dist/cli-error.js.map +1 -1
  821. package/dist/client.d.ts +2 -1
  822. package/dist/client.d.ts.map +1 -1
  823. package/dist/client.js +3 -2
  824. package/dist/client.js.map +1 -1
  825. package/dist/commands/archive.js +1 -1
  826. package/dist/commands/archive.js.map +1 -1
  827. package/dist/commands/ask.d.ts.map +1 -1
  828. package/dist/commands/ask.js +92 -11
  829. package/dist/commands/ask.js.map +1 -1
  830. package/dist/commands/broadcast.js +9 -5
  831. package/dist/commands/broadcast.js.map +1 -1
  832. package/dist/commands/compact.d.ts +3 -4
  833. package/dist/commands/compact.d.ts.map +1 -1
  834. package/dist/commands/compact.js +76 -16
  835. package/dist/commands/compact.js.map +1 -1
  836. package/dist/commands/config-init-workspace.d.ts.map +1 -1
  837. package/dist/commands/config-init-workspace.js +3 -0
  838. package/dist/commands/config-init-workspace.js.map +1 -1
  839. package/dist/commands/daemon.d.ts.map +1 -1
  840. package/dist/commands/daemon.js +7 -0
  841. package/dist/commands/daemon.js.map +1 -1
  842. package/dist/commands/down.d.ts.map +1 -1
  843. package/dist/commands/down.js +8 -1
  844. package/dist/commands/down.js.map +1 -1
  845. package/dist/commands/export.d.ts.map +1 -1
  846. package/dist/commands/export.js +2 -1
  847. package/dist/commands/export.js.map +1 -1
  848. package/dist/commands/fork.d.ts.map +1 -1
  849. package/dist/commands/fork.js +2 -0
  850. package/dist/commands/fork.js.map +1 -1
  851. package/dist/commands/launch.d.ts.map +1 -1
  852. package/dist/commands/launch.js +11 -3
  853. package/dist/commands/launch.js.map +1 -1
  854. package/dist/commands/ps.d.ts +30 -1
  855. package/dist/commands/ps.d.ts.map +1 -1
  856. package/dist/commands/ps.js +85 -6
  857. package/dist/commands/ps.js.map +1 -1
  858. package/dist/commands/queue.d.ts.map +1 -1
  859. package/dist/commands/queue.js +309 -21
  860. package/dist/commands/queue.js.map +1 -1
  861. package/dist/commands/rig.d.ts +2 -0
  862. package/dist/commands/rig.d.ts.map +1 -1
  863. package/dist/commands/rig.js +36 -2
  864. package/dist/commands/rig.js.map +1 -1
  865. package/dist/commands/roster.d.ts +8 -0
  866. package/dist/commands/roster.d.ts.map +1 -1
  867. package/dist/commands/scope.d.ts.map +1 -1
  868. package/dist/commands/scope.js +346 -9
  869. package/dist/commands/scope.js.map +1 -1
  870. package/dist/commands/seat.d.ts.map +1 -1
  871. package/dist/commands/seat.js +213 -12
  872. package/dist/commands/seat.js.map +1 -1
  873. package/dist/commands/send.d.ts +2 -0
  874. package/dist/commands/send.d.ts.map +1 -1
  875. package/dist/commands/send.js +50 -7
  876. package/dist/commands/send.js.map +1 -1
  877. package/dist/commands/setup.js +2 -2
  878. package/dist/commands/setup.js.map +1 -1
  879. package/dist/commands/slack.d.ts +2 -1
  880. package/dist/commands/slack.d.ts.map +1 -1
  881. package/dist/commands/slack.js +38 -2
  882. package/dist/commands/slack.js.map +1 -1
  883. package/dist/commands/terminal.d.ts +56 -0
  884. package/dist/commands/terminal.d.ts.map +1 -1
  885. package/dist/commands/terminal.js +199 -9
  886. package/dist/commands/terminal.js.map +1 -1
  887. package/dist/commands/transcript.js +1 -1
  888. package/dist/commands/transcript.js.map +1 -1
  889. package/dist/commands/unarchive.js +1 -1
  890. package/dist/commands/unarchive.js.map +1 -1
  891. package/dist/commands/up.d.ts.map +1 -1
  892. package/dist/commands/up.js +3 -0
  893. package/dist/commands/up.js.map +1 -1
  894. package/dist/commands/workflow-follow.d.ts +3 -1
  895. package/dist/commands/workflow-follow.d.ts.map +1 -1
  896. package/dist/commands/workflow-follow.js +25 -6
  897. package/dist/commands/workflow-follow.js.map +1 -1
  898. package/dist/commands/workflow-render.d.ts.map +1 -1
  899. package/dist/commands/workflow-render.js +5 -1
  900. package/dist/commands/workflow-render.js.map +1 -1
  901. package/dist/commands/workflow.d.ts.map +1 -1
  902. package/dist/commands/workflow.js +18 -4
  903. package/dist/commands/workflow.js.map +1 -1
  904. package/dist/daemon-lifecycle.d.ts.map +1 -1
  905. package/dist/daemon-lifecycle.js +12 -0
  906. package/dist/daemon-lifecycle.js.map +1 -1
  907. package/dist/lib/model-observation.d.ts.map +1 -1
  908. package/dist/lib/model-observation.js +9 -3
  909. package/dist/lib/model-observation.js.map +1 -1
  910. package/dist/lib/scope/mission-composition.d.ts +1 -0
  911. package/dist/lib/scope/mission-composition.d.ts.map +1 -1
  912. package/dist/lib/scope/mission-composition.js +14 -0
  913. package/dist/lib/scope/mission-composition.js.map +1 -1
  914. package/dist/lib/scope/scope-audit.d.ts.map +1 -1
  915. package/dist/lib/scope/scope-audit.js +63 -3
  916. package/dist/lib/scope/scope-audit.js.map +1 -1
  917. package/dist/lib/scope/scope-fs.d.ts +10 -0
  918. package/dist/lib/scope/scope-fs.d.ts.map +1 -1
  919. package/dist/lib/scope/scope-fs.js +60 -0
  920. package/dist/lib/scope/scope-fs.js.map +1 -1
  921. package/dist/lib/scope/types.d.ts +3 -1
  922. package/dist/lib/scope/types.d.ts.map +1 -1
  923. package/dist/lib/scope/types.js +5 -1
  924. package/dist/lib/scope/types.js.map +1 -1
  925. package/dist/local-db.d.ts +5 -0
  926. package/dist/local-db.d.ts.map +1 -0
  927. package/dist/local-db.js +23 -0
  928. package/dist/local-db.js.map +1 -0
  929. package/dist/local-origin.d.ts.map +1 -1
  930. package/dist/local-origin.js +2 -17
  931. package/dist/local-origin.js.map +1 -1
  932. package/dist/mcp-server.d.ts.map +1 -1
  933. package/dist/mcp-server.js +138 -24
  934. package/dist/mcp-server.js.map +1 -1
  935. package/dist/restore-packet/packet-writer.d.ts.map +1 -1
  936. package/dist/restore-packet/packet-writer.js +8 -5
  937. package/dist/restore-packet/packet-writer.js.map +1 -1
  938. package/dist/sender-identity.d.ts +18 -6
  939. package/dist/sender-identity.d.ts.map +1 -1
  940. package/dist/sender-identity.js +67 -7
  941. package/dist/sender-identity.js.map +1 -1
  942. package/dist/terminal-window-rex.d.ts +1 -1
  943. package/dist/terminal-window-rex.d.ts.map +1 -1
  944. package/dist/terminal-window-rex.js +3 -2
  945. package/dist/terminal-window-rex.js.map +1 -1
  946. package/dist/terminal-window.d.ts +2 -1
  947. package/dist/terminal-window.d.ts.map +1 -1
  948. package/dist/terminal-window.js +570 -44
  949. package/dist/terminal-window.js.map +1 -1
  950. package/package.json +1 -1
  951. package/tui/dist/daemon-client.d.ts +4 -0
  952. package/tui/dist/daemon-client.d.ts.map +1 -1
  953. package/tui/dist/daemon-client.js +2 -1
  954. package/tui/dist/daemon-client.js.map +1 -1
  955. package/tui/dist/execution/execution-model.d.ts.map +1 -1
  956. package/tui/dist/execution/execution-model.js +22 -5
  957. package/tui/dist/execution/execution-model.js.map +1 -1
  958. package/tui/dist/hydrate.d.ts.map +1 -1
  959. package/tui/dist/hydrate.js +6 -3
  960. package/tui/dist/hydrate.js.map +1 -1
  961. package/tui/dist/navigator.d.ts +1 -1
  962. package/tui/dist/navigator.d.ts.map +1 -1
  963. package/tui/dist/navigator.js +4 -2
  964. package/tui/dist/navigator.js.map +1 -1
  965. package/tui/dist/pulse/render-pulse.d.ts.map +1 -1
  966. package/tui/dist/pulse/render-pulse.js +7 -14
  967. package/tui/dist/pulse/render-pulse.js.map +1 -1
  968. package/tui/dist/render.d.ts.map +1 -1
  969. package/tui/dist/render.js +29 -21
  970. package/tui/dist/render.js.map +1 -1
  971. package/tui/dist/stylize.d.ts.map +1 -1
  972. package/tui/dist/stylize.js +3 -3
  973. package/tui/dist/stylize.js.map +1 -1
  974. package/tui/dist/terminals/terminal-model.d.ts +1 -0
  975. package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
  976. package/tui/dist/terminals/terminal-model.js +4 -2
  977. package/tui/dist/terminals/terminal-model.js.map +1 -1
  978. package/tui/dist/types.d.ts +1 -0
  979. package/tui/dist/types.d.ts.map +1 -1
  980. package/tui/dist/visual-layout.d.ts +3 -0
  981. package/tui/dist/visual-layout.d.ts.map +1 -1
  982. package/tui/dist/visual-layout.js +17 -0
  983. package/tui/dist/visual-layout.js.map +1 -1
  984. package/ui/dist/assets/{index-BvUEh33d.js → index-B-sMy02c.js} +116 -116
  985. package/ui/dist/assets/{index-BX8TUZ0E.css → index-DiN7RwWg.css} +1 -1
  986. package/ui/dist/index.html +2 -2
@@ -1,5 +1,5 @@
1
1
  import { RigDeliveryDrainStore } from "./rig-delivery-drain.js";
2
- import { PROMPT_ALERT_TAG, readWakeLadderBackstop } from "./queue-wake-ladder.js";
2
+ import { PROMPT_ALERT_TAG, WAKE_ESCALATION_TAG, readWakeLadderBackstop } from "./queue-wake-ladder.js";
3
3
  import { withUrgentLine } from "./urgent-line.js";
4
4
  import { quietCustodyBackstop, quietHoldCustody } from "./quiet-hold-custody.js";
5
5
  import { cooperativeReadFile, readRowsCooperatively } from "./execution-candidate-reader.js";
@@ -10,16 +10,16 @@ import { loadRelayProfiles } from "./gateway/relay-config.js";
10
10
  import { relayStatePaths, validateRelayOutboundEnvelope } from "./gateway/relay-outbound.js";
11
11
  import { SeenStore } from "./gateway/slack/state-store.js";
12
12
  import { getOpenRigHome } from "../openrig-compat.js";
13
- import { sharedChannelAddresses } from "./gateway/participants.js";
13
+ import { readSharedChannelAddresses, sharedChannelAddresses } from "./gateway/participants.js";
14
14
  import { resolveExternal } from "./gateway/external-admission.js";
15
- import { QueueTransitionLog, RELAY_OWNER_NOTIFICATION_ACCEPTED_PREFIX, RELAY_OWNER_NOTIFICATION_TRANSPORT_FAILED_PREFIX, formatRelayOwnerNotificationAccepted, formatRelayOwnerNotificationTransportFailed, parseRelayOwnerNotificationAccepted, parseRelayOwnerNotificationTransportFailed, } from "./queue-transition-log.js";
16
- 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, };
17
17
  export const MC_OPERATION_TAG_PREFIX = "mc-operation:";
18
18
  export function mcOperationTag(operation) {
19
19
  return `${MC_OPERATION_TAG_PREFIX}${operation}`;
20
20
  }
21
21
  import { WAKE_INTENT_PREFIX } from "./outbox-handler.js";
22
- import { physicalSessionName } from "./session-registry.js";
22
+ import { physicalSessionName, SessionRegistry } from "./session-registry.js";
23
23
  import { derivePickup } from "./queue-pickup.js";
24
24
  import { withRecoveryIndex } from "./queue-recovery.js";
25
25
  import { lastMeaningfulTransitionMany, meaningfulFor, readWaitingView, WaitingStatements } from "./queue-waiting.js";
@@ -30,6 +30,7 @@ import { isBoundTerminalSeat } from "./terminal-seat.js";
30
30
  import { renderQueueHandoffNudge } from "./queue-nudge-text.js";
31
31
  import { getSelfHostId } from "./hosts/fanout-contract.js";
32
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";
33
34
  import { runnerPermissionOrigin } from "./runner-permissions.js";
34
35
  import { isHostPairingAsk } from "./hosts/pairing-ask.js";
35
36
  import { parseReplyToChoice, parseArrivalThread, parseReplyToThreadMissing, formatReplyToChoice, describeReplyToFallback, REPLY_TO_CHOICE_ACTOR } from "./reply-to-choice.js";
@@ -44,6 +45,8 @@ import { computeClosureRequiredAt, validateClosure, } from "./hot-potato-enforce
44
45
  import { validateHumanPark, validateHumanRoute } from "./human-route-enforcer.js";
45
46
  import { QueueWakeRepository, USAGE_LIMIT_BLOCKER_TAG, } from "./queue-wake-repository.js";
46
47
  import { WatchdogJobsRepository } from "./watchdog-jobs-repository.js";
48
+ import { NOTED_ON_QUEUED_ROW, QUEUED_AS_ROW, isQueueOnlyDeliveryCode } from "./watchdog-history-log.js";
49
+ import { parkedRowNotePrefix, queuedAsRowNote } from "./park-wake-text.js";
47
50
  import { armQueueWait, backOffQueueWait, refreshQueueWaits, evaluateQueueWait, retargetQueueWait, isQueueWait } from "./queue-wait-backoff.js";
48
51
  import { parseHumanQuestions, unansweredQuestions, describeTypedReplyPlacement, formatHumanAnswers, humanAnswerText } from "./human-questions.js";
49
52
  import { slackMicros } from "./gateway/slack/state-store.js";
@@ -108,6 +111,8 @@ const CLAIM_OVERRIDDEN_WAKE_PREFIX = `${WAKE_INTENT_PREFIX}claim-overridden-`;
108
111
  const CLAIM_OVERRIDDEN_WAKE_END = `${WAKE_INTENT_PREFIX}claim-overridden.`;
109
112
  /** On a wake intent whose ring a hosted member's trigger accepted: recovery doesn't ring that intent again. */
110
113
  const HOSTED_WAKE_ACCEPTED_TAG = "queue:hosted-wake-accepted";
114
+ /** A first failed intent with typed no-input proof permits one return retry; a claim consumes it. */
115
+ const WAKE_PRE_INPUT_FAILURE_TAG = "queue:wake-pre-input-failure";
111
116
  const AUTO_UNPARK_BLOCKER_TAG_PREFIX = "queue:auto-unpark:blocker-ref:";
112
117
  /** The actor on the transition routeToFallback writes; the row's own history is how a later reroute finds the line it wrote. */
113
118
  const FALLBACK_ACTOR = "system:queue-fallback";
@@ -158,6 +163,12 @@ export function classifyNudgeFailure(lastNudgeResult) {
158
163
  return "unknown";
159
164
  }
160
165
  export const QUEUE_PRIORITIES = ["routine", "urgent", "critical"];
166
+ /** The result of one wake attempt: its classification and its recorded result. */
167
+ /** The prompt-clear path owns these definite no-input refusals, even during a running hook. */
168
+ function isPromptOwnedWakeRefusal(result) {
169
+ return result === "failed:target_needs_input"
170
+ || (result?.startsWith("failed:Refused:") === true && result.includes("interactive prompt"));
171
+ }
161
172
  /** `principal:v1` marks only the transitions that record the request's own action. What that action sets off elsewhere
162
173
  * (a successor's wake intent, a parked row released, a blocker moved) carries the seat's stamp, transport:v1. */
163
174
  function sideEffectProvenance(provenance) {
@@ -311,8 +322,12 @@ export function matchesRecordedHandoffTarget(qitemId, handedOffTo, closureTarget
311
322
  * Throws on database/query errors so callers can handle lookup failures with their own policies.
312
323
  */
313
324
  export function hasLinkedSuccessor(db, sourceQitemId, target) {
314
- if (successorScope?.db === db && successorScope.covers(sourceQitemId))
325
+ if (successorScope?.db === db && successorScope.covers(sourceQitemId, target))
315
326
  return successorScope.has(sourceQitemId, target);
327
+ return queryLinkedSuccessor(db, sourceQitemId, target);
328
+ }
329
+ /** hasLinkedSuccessor's own query, for one source and target, through the primary key and the destination index. */
330
+ function queryLinkedSuccessor(db, sourceQitemId, target) {
316
331
  const successor = db
317
332
  .prepare(`SELECT 1 FROM queue_items s
318
333
  WHERE (s.qitem_id = ? OR s.destination_session = ?) AND s.qitem_id != ?
@@ -333,38 +348,57 @@ let successorScope = null;
333
348
  * successor is a row whose handed_off_from is the source, or whose chain_of_record is valid JSON with the source among
334
349
  * its json_each values (compared as `value IN (...)` compares, like `value = ?`: a number or a nested value never
335
350
  * equals a text id); has() then checks qitem_id or destination_session against the target and that the successor is
336
- * not the source itself. A snapshot from its first has() until invalidate(): the caller invalidates it whenever other
337
- * code could have run. run(fn) lends it, for the synchronous fn only, to the hasLinkedSuccessor calls made inside fn
338
- * for a covered source; any other source keeps the per-row query. builtMs() is how long the build of the index as it
339
- * is now took (0 while it is not built), so a caller can tell when rebuilding after each invalidate() costs more than
340
- * it saves. */
351
+ * not the source itself. The index covers the targets each source's own row names (its closure_target, each
352
+ * comma-separated part of it, and its handed_off_to), the ones the sweep and the row's handoff advisory ask about, so the
353
+ * chain_of_record arm reads only successors whose id or destination is one of them, through the primary key and the
354
+ * destination index, instead of every row's chain. Any other source or target keeps the per-row query, so every answer is
355
+ * the per-row query's. For a covered source and target, a snapshot from its first has() until invalidate(): the caller
356
+ * 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
357
+ * covered source and target. builtMs() is how long the build of the index as it is now took (0 while it is not built),
358
+ * so a caller can tell when rebuilding after each invalidate() costs more than it saves. */
341
359
  export function createLinkedSuccessorLookup(db, sourceQitemIds) {
342
360
  const sources = new Set(sourceQitemIds);
343
- let bySource = null;
361
+ let index = null;
344
362
  let buildMs = 0;
345
363
  const build = () => {
346
364
  const startedAt = performance.now();
347
- const map = new Map();
365
+ const bySource = new Map();
366
+ const targetsOf = new Map();
348
367
  const ids = JSON.stringify([...sources]);
349
- 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
350
- WHERE s.handed_off_from IN (SELECT value FROM json_each(?))
351
- UNION
352
- SELECT s.qitem_id, s.destination_session, j.value AS source FROM queue_items s, json_each(s.chain_of_record) j
353
- WHERE s.chain_of_record IS NOT NULL AND json_valid(s.chain_of_record)
354
- AND j.value IN (SELECT value FROM json_each(?))`).all(ids, ids));
355
- for (const r of rows) {
356
- const list = map.get(r.source);
357
- const entry = { qitemId: r.qitem_id, destination: r.destination_session };
358
- if (list)
359
- list.push(entry);
360
- else
361
- map.set(r.source, [entry]);
362
- }
368
+ runSyncSite("queue.linked_successors.build", () => {
369
+ const named = db.prepare(`SELECT qitem_id, closure_target, handed_off_to FROM queue_items WHERE qitem_id IN (SELECT value FROM json_each(?))`)
370
+ .all(ids);
371
+ for (const r of named) {
372
+ const own = new Set();
373
+ for (const target of [r.closure_target, ...(r.closure_target ?? "").split(",").map((part) => part.trim()), r.handed_off_to])
374
+ if (target)
375
+ own.add(target);
376
+ targetsOf.set(r.qitem_id, own);
377
+ }
378
+ const targets = JSON.stringify([...new Set([...targetsOf.values()].flatMap((own) => [...own]))]);
379
+ const rows = db.prepare(`SELECT s.qitem_id, s.destination_session, s.handed_off_from AS source FROM queue_items s
380
+ WHERE s.handed_off_from IN (SELECT value FROM json_each(?))
381
+ UNION
382
+ SELECT s.qitem_id, s.destination_session, j.value AS source FROM queue_items s, json_each(s.chain_of_record) j
383
+ WHERE (s.qitem_id IN (SELECT value FROM json_each(?)) OR s.destination_session IN (SELECT value FROM json_each(?)))
384
+ AND s.chain_of_record IS NOT NULL AND json_valid(s.chain_of_record)
385
+ AND j.value IN (SELECT value FROM json_each(?))`).all(ids, targets, targets, ids);
386
+ for (const r of rows) {
387
+ const list = bySource.get(r.source);
388
+ const entry = { qitemId: r.qitem_id, destination: r.destination_session };
389
+ if (list)
390
+ list.push(entry);
391
+ else
392
+ bySource.set(r.source, [entry]);
393
+ }
394
+ });
363
395
  buildMs = performance.now() - startedAt;
364
- return map;
396
+ return { bySource, targetsOf };
365
397
  };
366
- const has = (sourceQitemId, target) => (bySource ??= build()).get(sourceQitemId)?.some((s) => s.qitemId !== sourceQitemId && (s.qitemId === target || s.destination === target)) ?? false;
367
- const own = { db, covers: (source) => sources.has(source), has };
398
+ const covers = (sourceQitemId, target) => sources.has(sourceQitemId) && ((index ??= build()).targetsOf.get(sourceQitemId)?.has(target) ?? false);
399
+ const indexed = (sourceQitemId, target) => (index ??= build()).bySource.get(sourceQitemId)?.some((s) => s.qitemId !== sourceQitemId && (s.qitemId === target || s.destination === target)) ?? false;
400
+ const has = (sourceQitemId, target) => covers(sourceQitemId, target) ? indexed(sourceQitemId, target) : queryLinkedSuccessor(db, sourceQitemId, target);
401
+ const own = { db, covers, has: indexed };
368
402
  return {
369
403
  has,
370
404
  run: (fn) => {
@@ -379,7 +413,7 @@ export function createLinkedSuccessorLookup(db, sourceQitemIds) {
379
413
  successorScope = previous;
380
414
  }
381
415
  },
382
- invalidate: () => { bySource = null; buildMs = 0; },
416
+ invalidate: () => { index = null; buildMs = 0; },
383
417
  builtMs: () => buildMs,
384
418
  };
385
419
  }
@@ -583,6 +617,7 @@ export class QueueRepository {
583
617
  hasSummaryColumn;
584
618
  hasHumanIntentColumn;
585
619
  hasReplyToColumn;
620
+ hasReturnRouteColumn;
586
621
  hasHumanQuestionsColumn;
587
622
  hasDelegatedDecisionColumn;
588
623
  hasEvidenceRefColumn;
@@ -595,6 +630,7 @@ export class QueueRepository {
595
630
  loadHumanRegistryFn;
596
631
  /** Registered shared channels (0.7.3): `<id>@external` participants whose rows post to their Slack channel. */
597
632
  sharedChannelsFn;
633
+ readSharedChannelsFn;
598
634
  /** A hosted member's trigger, from the authored rosters on this host. */
599
635
  hostedWakeFn;
600
636
  /** Whether the rosters list an address as a hosted member, trigger or not. */
@@ -613,7 +649,7 @@ export class QueueRepository {
613
649
  this.deliveryDrains = new RigDeliveryDrainStore(db);
614
650
  this.eventBus = eventBus;
615
651
  this.transitionLog = new QueueTransitionLog(db);
616
- this.wakeRepo = new QueueWakeRepository(db);
652
+ this.wakeRepo = new QueueWakeRepository(db, (value) => this.isPersonAddress(value));
617
653
  this.validateRig = opts?.validateRig ?? (() => true);
618
654
  this.canRecordDestination = opts?.canRecordDestination ?? this.validateRig;
619
655
  this.destinationAdvisory = opts?.destinationAdvisory ?? (() => null);
@@ -626,6 +662,7 @@ export class QueueRepository {
626
662
  this.hasPendingPostCompactStage = opts?.hasPendingPostCompactStage;
627
663
  this.loadHumanRegistryFn = opts?.loadHumanRegistry ?? (() => loadHumanRegistry());
628
664
  this.sharedChannelsFn = opts?.sharedChannels ?? (() => sharedChannelAddresses());
665
+ this.readSharedChannelsFn = opts?.readSharedChannels ?? (() => readSharedChannelAddresses());
629
666
  this.hostedWakeFn = opts?.hostedWake ?? defaultHostedWake;
630
667
  this.hostedMemberFn = opts?.isHostedMember ?? defaultIsHostedMember;
631
668
  this.hostedMembersFn = opts?.hostedMembers ?? defaultHostedMembers;
@@ -635,6 +672,7 @@ export class QueueRepository {
635
672
  this.hasSummaryColumn = detectQueueColumn(db, "summary");
636
673
  this.hasHumanIntentColumn = detectQueueColumn(db, "human_intent");
637
674
  this.hasReplyToColumn = detectQueueColumn(db, "reply_to");
675
+ this.hasReturnRouteColumn = detectQueueColumn(db, "return_route");
638
676
  this.hasHumanQuestionsColumn = detectQueueColumn(db, "human_questions");
639
677
  this.hasDelegatedDecisionColumn = detectQueueColumn(db, "delegated_decision");
640
678
  this.hasEvidenceRefColumn = detectQueueColumn(db, "evidence_ref");
@@ -749,6 +787,10 @@ export class QueueRepository {
749
787
  if (res.outcome === "retained")
750
788
  return { classified: "retained", nudgeResult: res.reason === "typing_guard_enabled"
751
789
  ? "retained:typing_guard" : "retained:draft_aware" };
790
+ // Queued for the seat's hook bridge: it reaches the seat's context at the next turn boundary, which isn't a claim.
791
+ // The bridge owns the row now (handed to the hook, typed by its fallback, or named uncertain), so it isn't finalized.
792
+ if (res.outcome === "bridged")
793
+ return { classified: "bridged", nudgeResult: "bridged:queued" };
752
794
  if (res.ok)
753
795
  return res.verified ? { classified: "verified", nudgeResult: "verified" } : { classified: "indeterminate", nudgeResult: "delivered-ack-pending" };
754
796
  const detail = res.error ?? res.reason ?? "unknown";
@@ -758,7 +800,7 @@ export class QueueRepository {
758
800
  if (inputUncertain || isWakeTimeoutSignal(res.reason) || isWakeTimeoutSignal(res.error)) {
759
801
  return { classified: "indeterminate", nudgeResult: `indeterminate:${detail}` };
760
802
  }
761
- return { classified: "failed", nudgeResult: `failed:${detail}` };
803
+ return { classified: "failed", nudgeResult: `failed:${detail}`, preInputFailure: res.inputPhase === "not_reached" && res.sent !== true };
762
804
  }
763
805
  /**
764
806
  * W1 (transactional closure): attach the durable wake-intent store AFTER
@@ -873,8 +915,33 @@ export class QueueRepository {
873
915
  }
874
916
  /** #2895 (a): the envelope meta for a sender `rig send` can't reach; empty (today's bytes) otherwise or when unwired. */
875
917
  senderReach(sender) {
918
+ // #3268: an @external sender's reply is a queue row to it, so name that command only when the queue would accept it.
919
+ if (sender?.endsWith("@external") && this.knownUnregistered(sender))
920
+ return { senderRegistered: false };
876
921
  return sender && this.isSenderSendable && !this.isSenderSendable(sender) ? { senderReachable: false } : {};
877
922
  }
923
+ /** #3268: true only when one read of the person registry and one of the participant file both succeeded, that
924
+ * snapshot names no such @external address, and the queue's admission refuses it too. Absence comes from that
925
+ * snapshot, so admission's own later read collapsing to an empty list can't turn "unknown" into "absent". A read
926
+ * that fails or throws proves nothing, so the caller keeps today's reply line and the notification still goes out. */
927
+ knownUnregistered(sender) {
928
+ try {
929
+ const parsed = parseSessionName(sender);
930
+ if (parsed.kind !== "external")
931
+ return false;
932
+ const people = registeredPeople(this.loadHumanRegistryFn());
933
+ if (people === null)
934
+ return false;
935
+ const channels = this.readSharedChannelsFn();
936
+ if (channels === null)
937
+ return false;
938
+ const entities = [...people.map((p) => ({ entityId: p.entityId, address: p.address })), ...channels];
939
+ return resolveExternal(parsed.local, entities).kind === "unregistered" && !this.canRecordDestination(sender);
940
+ }
941
+ catch {
942
+ return false;
943
+ }
944
+ }
878
945
  recordWakeIntent(input) {
879
946
  if (!this.outbox)
880
947
  return null;
@@ -970,8 +1037,8 @@ export class QueueRepository {
970
1037
  /** #2789: a wake committed while its seat had no pane froze a binding that can never match once the seat is bound, so
971
1038
  * the delivery guard refused it on every retry. Such an intent takes its first live binding, on the same node and
972
1039
  * canonical session, only when it is known to have written no input (pending, or failed, which a send records only
973
- * without a write) and carries no expected identity of its own. A binding that ever named a pane is never replaced,
974
- * so a wake can't move to another occupant; the guard's write-time check against this binding still holds.
1040
+ * without a write) and carries no expected identity of its own. Previously pane-bound intents use the separate,
1041
+ * proof-only reconciliation at claim below; the guard's write-time check against the selected binding still holds.
975
1042
  * `entry` is the intent as read before its claim. Called inside the claim's transaction. */
976
1043
  bindFirstTarget(entry) {
977
1044
  const frozen = entry.guardBinding;
@@ -984,6 +1051,15 @@ export class QueueRepository {
984
1051
  return;
985
1052
  this.db.prepare("UPDATE outbox_entries SET guard_binding = ? WHERE outbox_id = ?").run(JSON.stringify(live), entry.outboxId);
986
1053
  }
1054
+ setWakePreInputFailure(outboxId, proved) {
1055
+ const entry = this.outbox.getById(outboxId);
1056
+ if (!entry || (!proved && !entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG)))
1057
+ return;
1058
+ const tags = (entry.tags ?? []).filter(tag => tag !== WAKE_PRE_INPUT_FAILURE_TAG);
1059
+ if (proved)
1060
+ tags.push(WAKE_PRE_INPUT_FAILURE_TAG);
1061
+ this.db.prepare("UPDATE outbox_entries SET tags = ? WHERE outbox_id = ?").run(JSON.stringify(tags), outboxId);
1062
+ }
987
1063
  async deliverWakeIntent(outboxId, attempted = new Set(), // this pass's attempt history, inherited by any release it delivers
988
1064
  eligible = () => true) {
989
1065
  if (!this.outbox)
@@ -1000,13 +1076,40 @@ export class QueueRepository {
1000
1076
  this.recordNudgeAttempt(alreadyHeld.auditPointer, "retained:typing_guard");
1001
1077
  return "retained";
1002
1078
  }
1003
- let recovering = false;
1004
1079
  const claim = (entry) => {
1005
- if (this.deliveryDrains.holds(entry.destinationSession) || !eligible(entry) || attempted.has(entry.outboxId) || !this.outbox.claimForDelivery(entry.outboxId))
1080
+ if (this.deliveryDrains.holds(entry.destinationSession) || !eligible(entry) || attempted.has(entry.outboxId))
1081
+ return false;
1082
+ let rebound;
1083
+ const frozen = entry.guardBinding;
1084
+ if (entry.deliveryState === "failed" && entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG) && frozen?.pane) {
1085
+ const live = this.transport?.deliveryTarget?.(entry.destinationSession);
1086
+ if (!live || live.nodeId !== frozen.nodeId || live.session !== frozen.session
1087
+ || live.occupant !== frozen.occupant || live.pane !== frozen.pane) {
1088
+ const row = entry.auditPointer ? this.getById(entry.auditPointer) : undefined;
1089
+ // A proved-unsent queue notification follows its existing seat's current binding. Startup draining shares
1090
+ // this claim, so check current work and restore custody before consuming the failed attempt's proof.
1091
+ if (!entry.outboxId.startsWith(WAKE_INTENT_PREFIX) || !live?.pane || live.nodeId !== frozen.nodeId
1092
+ || this.outbox.expectedIdentity(entry.outboxId) || !row || row.state !== "pending" || row.handedOffFrom
1093
+ || !this.currentWakeIntent(entry) || !this.reachableWakeRetryable(row, new Date())
1094
+ || [entry.destinationSession, ...this.resolveSessionAddresses(entry.destinationSession), live.session]
1095
+ .some(address => this.hasPendingPostCompactStage?.(address)))
1096
+ return false;
1097
+ rebound = live;
1098
+ }
1099
+ }
1100
+ if (!this.outbox.claimForDelivery(entry.outboxId))
1006
1101
  return false;
1102
+ if (rebound) {
1103
+ this.db.prepare("UPDATE outbox_entries SET guard_binding = ? WHERE outbox_id = ?").run(JSON.stringify(rebound), entry.outboxId);
1104
+ this.transitionLog.append({
1105
+ qitemId: entry.auditPointer, state: "pending", actorSession: "queue@system",
1106
+ transitionNote: `queue wake binding reconciled ${JSON.stringify({ outboxId: entry.outboxId, from: frozen, to: rebound })}`,
1107
+ });
1108
+ }
1109
+ if (entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG))
1110
+ this.setWakePreInputFailure(entry.outboxId, false);
1007
1111
  this.bindFirstTarget(entry);
1008
1112
  attempted.add(entry.outboxId);
1009
- recovering ||= entry.deliveryState !== "pending";
1010
1113
  return true;
1011
1114
  };
1012
1115
  let superseded = false;
@@ -1071,7 +1174,14 @@ export class QueueRepository {
1071
1174
  }
1072
1175
  const qitemId = intent.auditPointer ?? outboxId;
1073
1176
  // Preserve the original envelope/source generation; add context without rewriting its stored bytes.
1074
- const recoveryNotice = recovering ? "Recovered queue notification: delivery may repeat after an earlier unconfirmed attempt.\n" : "";
1177
+ const recoveryNotice = (members) => {
1178
+ const recovered = members.filter(entry => entry.deliveryState !== "pending");
1179
+ if (!recovered.length)
1180
+ return "";
1181
+ return recovered.every(entry => entry.deliveryState === "failed" && entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG))
1182
+ ? "Recovered queue notification: a wake that failed before input is retried once when the current binding is reachable again.\n"
1183
+ : "Recovered queue notification: delivery may repeat after an earlier unconfirmed attempt.\n";
1184
+ };
1075
1185
  // The group was formed on the first member's outcome, so its own source and urgency reach that same outcome at the
1076
1186
  // send; the other members' bodies keep their own frozen urgent lines.
1077
1187
  const trigger = group[0].tags?.includes(WAKE_TRIGGER_OPENRIG_TAG) ? "openrig" : "agent";
@@ -1097,19 +1207,26 @@ export class QueueRepository {
1097
1207
  for (const entry of group) {
1098
1208
  if (keep.includes(entry))
1099
1209
  continue;
1100
- this.db.prepare("UPDATE outbox_entries SET delivery_state = ? WHERE outbox_id = ? AND delivery_state = 'sending'").run(entry.deliveryState, entry.outboxId);
1210
+ this.db.transaction(() => {
1211
+ const restored = this.db.prepare("UPDATE outbox_entries SET delivery_state = ? WHERE outbox_id = ? AND delivery_state = 'sending'").run(entry.deliveryState, entry.outboxId);
1212
+ // This member never reached transport input, so its earlier failed-attempt proof still applies.
1213
+ if (restored.changes && entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG))
1214
+ this.setWakePreInputFailure(entry.outboxId, true);
1215
+ })();
1101
1216
  released.push(entry);
1102
1217
  }
1103
- return { text: recoveryNotice + keep.map(entry => entry.body).join("\n"), outboxIds: keep.map(entry => entry.outboxId) };
1218
+ return { text: recoveryNotice(keep) + keep.map(entry => entry.body).join("\n"), outboxIds: keep.map(entry => entry.outboxId) };
1104
1219
  };
1105
- 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);
1106
- let reportedState = outcome.classified === "verified" ? "delivered" : outcome.classified;
1220
+ 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);
1221
+ // A bridged wake isn't confirmed, so the pass counts it as unconfirmed; its row is the bridge's to settle.
1222
+ let reportedState = outcome.classified === "verified" ? "delivered"
1223
+ : outcome.classified === "bridged" ? "indeterminate" : outcome.classified;
1107
1224
  for (const intent of group) {
1108
1225
  if (released.includes(intent))
1109
1226
  continue;
1110
1227
  // A no-write retry cannot settle whether an earlier attempt landed.
1111
1228
  const earlierUnknown = intent.deliveryState === "indeterminate" && outcome.classified === "failed";
1112
- const finalState = earlierUnknown ? "indeterminate" : outcome.classified === "verified" ? "delivered" : outcome.classified;
1229
+ const finalState = earlierUnknown ? "indeterminate" : outcome.classified === "verified" ? "delivered" : outcome.classified === "bridged" ? null : outcome.classified;
1113
1230
  const nudgeResult = earlierUnknown ? `indeterminate:earlier delivery unconfirmed; retry ${outcome.nudgeResult}` : outcome.nudgeResult;
1114
1231
  if (earlierUnknown)
1115
1232
  reportedState = "indeterminate";
@@ -1121,7 +1238,12 @@ export class QueueRepository {
1121
1238
  : undefined;
1122
1239
  const wakeEvent = this.db.transaction(() => {
1123
1240
  this.recordNudgeAttempt(qitemId, nudgeResult);
1124
- this.outbox.finalizeDelivery(intent.outboxId, finalState);
1241
+ if (finalState)
1242
+ this.outbox.finalizeDelivery(intent.outboxId, finalState);
1243
+ // Only a first attempt creates proof: an actual retry consumes it even if it again fails before input.
1244
+ if (intent.deliveryState === "pending" && finalState === "failed" && outcome.preInputFailure === true) {
1245
+ this.setWakePreInputFailure(intent.outboxId, true);
1246
+ }
1125
1247
  // The acceptance (or a ring that may have arrived) belongs to this intent, so recovery can tell this wake already rang.
1126
1248
  if (hostedRingMayHaveArrived(outcome.nudgeResult)) {
1127
1249
  this.db.prepare(`UPDATE outbox_entries SET tags = json_insert(COALESCE(tags, '[]'), '$[#]', ?)
@@ -1241,7 +1363,8 @@ export class QueueRepository {
1241
1363
  JOIN queue_items q ON q.qitem_id = o.audit_pointer AND (q.state = 'pending' OR substr(o.outbox_id, 1, ?) = ?)
1242
1364
  AND q.destination_session = o.destination_session
1243
1365
  WHERE o.rowid > ? AND o.rowid <= ? AND substr(o.outbox_id, 1, ?) = ?
1244
- AND o.delivery_state IN ('pending','failed','indeterminate') ORDER BY o.rowid LIMIT ?`)
1366
+ AND o.delivery_state IN ('pending','failed','indeterminate')
1367
+ AND json_extract(o.guard_delivery,'$.runner') IS NULL AND json_extract(o.guard_delivery,'$.nativeRequestId') IS NULL ORDER BY o.rowid LIMIT ?`)
1245
1368
  .all(CLAIM_OVERRIDDEN_WAKE_PREFIX.length, CLAIM_OVERRIDDEN_WAKE_PREFIX, cursor, horizon, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, BATCH);
1246
1369
  if (pending.length === 0)
1247
1370
  break;
@@ -1310,7 +1433,7 @@ export class QueueRepository {
1310
1433
  return;
1311
1434
  if (!this.transport)
1312
1435
  return;
1313
- const outcome = await this.performWakeSend(qitemId, destinationSession, sourceSession, bodyOverride, undefined, undefined, trigger);
1436
+ const outcome = await this.performWakeSend(qitemId, destinationSession, sourceSession, bodyOverride, undefined, undefined, trigger, undefined, opts?.explicit === true);
1314
1437
  this.recordNudgeAttempt(qitemId, outcome.nudgeResult);
1315
1438
  }
1316
1439
  /** The following startup intent drain owns durable pending wakes. Legacy packets
@@ -1355,7 +1478,7 @@ export class QueueRepository {
1355
1478
  const current = this.getById(entry.auditPointer), refusal = current?.lastNudgeWireResult;
1356
1479
  const notice = entry.outboxId.startsWith(CLAIM_OVERRIDDEN_WAKE_PREFIX);
1357
1480
  return (current?.state === "pending" || notice) && addresses.includes(current?.destinationSession ?? "")
1358
- && (refusal === "failed:target_needs_input" || (refusal?.startsWith("failed:Refused:") === true && refusal.includes("interactive prompt")));
1481
+ && isPromptOwnedWakeRefusal(refusal);
1359
1482
  };
1360
1483
  const seats = addresses.map(() => "?").join(",");
1361
1484
  const refused = (q) => `(${q}last_nudge_result LIKE 'failed:Refused:%interactive prompt%' OR ${q}last_nudge_result = 'failed:target_needs_input')`;
@@ -1405,16 +1528,18 @@ export class QueueRepository {
1405
1528
  * gateway, not held or released for quiet hours, and its seat now pane-bound. A handoff's retry ladder is the
1406
1529
  * caller's to check: the sweep defers to a live ladder, the reachable-seat retry leaves every handed-off row to it. */
1407
1530
  unroutableWakeRetryable(row, now = new Date()) {
1408
- return recordsNoWakeRoute(row.lastNudgeResult)
1409
- && !row.claimedAt
1531
+ return recordsNoWakeRoute(row.lastNudgeResult) && this.reachableWakeRetryable(row, now);
1532
+ }
1533
+ reachableWakeRetryable(row, now) {
1534
+ return !row.claimedAt
1535
+ && !isPromptOwnedWakeRefusal(row.lastNudgeResult)
1410
1536
  && row.deliveryOutcome !== "never-posted" && row.deliveryOutcome !== "transport-failed"
1411
1537
  && !this.isLocalHumanDecisionWithoutGateway(row)
1412
1538
  && !["held", "released"].includes(quietHoldCustody(this.db, row.qitemId, now)?.state ?? "")
1413
1539
  && this.classifyDestinationOf(row.destinationSession).class === "pane-bound";
1414
1540
  }
1415
- /** A wake recorded unroutable because its seat wasn't bound yet, as just after a restart (#2789), is re-sent as soon
1416
- * as the seat is seen running or idle, rather than at the stuck sweep's next tick; the sweep remains the backstop.
1417
- * Only this seat's own pending rows, oldest first, that {@link unroutableWakeRetryable} admits. */
1541
+ /** Re-send an unroutable wake, or the same failed intent with typed proof that its latest attempt never reached input,
1542
+ * when its seat returns running/idle. Unknown delivery stays unknown; deliberate quiet and compaction keep custody. */
1418
1543
  async retryUnroutableWakesOnReachable(sessionName, state) {
1419
1544
  if (state !== "running" && state !== "idle")
1420
1545
  return;
@@ -1426,11 +1551,16 @@ export class QueueRepository {
1426
1551
  // As for a prompt clear (#2575): while a compaction's restore is owed, the wake would reach the agent before it.
1427
1552
  if ([sessionName, ...addresses].some(address => this.hasPendingPostCompactStage?.(address)))
1428
1553
  return;
1429
- const rows = this.db.prepare(`SELECT qitem_id FROM queue_items
1430
- WHERE destination_session IN (${addresses.map(() => "?").join(",")}) AND state = 'pending'
1431
- AND handed_off_from IS NULL AND (last_nudge_result LIKE 'unroutable:%' OR last_nudge_result LIKE 'awaiting-pickup:%')
1432
- ORDER BY ts_created, qitem_id`)
1433
- .all(...addresses);
1554
+ const provedFailure = this.outbox ? `OR EXISTS (
1555
+ SELECT 1 FROM outbox_entries o WHERE o.audit_pointer = q.qitem_id
1556
+ AND substr(o.outbox_id, 1, ?) = ? AND o.delivery_state = 'failed'
1557
+ AND EXISTS (SELECT 1 FROM json_each(o.tags) WHERE value = ?)
1558
+ )` : "";
1559
+ const rows = this.db.prepare(`SELECT q.qitem_id FROM queue_items q
1560
+ WHERE q.destination_session IN (${addresses.map(() => "?").join(",")}) AND q.state = 'pending'
1561
+ AND q.handed_off_from IS NULL AND (q.last_nudge_result LIKE 'unroutable:%' OR q.last_nudge_result LIKE 'awaiting-pickup:%' ${provedFailure})
1562
+ ORDER BY q.ts_created, q.qitem_id`)
1563
+ .all(...addresses, ...(this.outbox ? [WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, WAKE_PRE_INPUT_FAILURE_TAG] : []));
1434
1564
  const now = new Date();
1435
1565
  // One attempt per intent for the pass: a returned result and its resume go as one send, so the second row's turn
1436
1566
  // mustn't send them again after a refusal.
@@ -1441,13 +1571,17 @@ export class QueueRepository {
1441
1571
  const eligible = (entry) => {
1442
1572
  if (entry.deliveryState !== "failed" || !entry.auditPointer)
1443
1573
  return false;
1574
+ // An earlier member's awaited send may have started restore custody before this claim.
1575
+ if ([sessionName, ...addresses].some(address => this.hasPendingPostCompactStage?.(address)))
1576
+ return false;
1444
1577
  const current = this.getById(entry.auditPointer);
1445
1578
  return current?.state === "pending" && addresses.includes(current.destinationSession) && !current.handedOffFrom
1446
- && this.unroutableWakeRetryable(current, now);
1579
+ && this.reachableWakeRetryable(current, now)
1580
+ && (this.unroutableWakeRetryable(current, now) || entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG) === true);
1447
1581
  };
1448
1582
  for (const { qitem_id } of rows) {
1449
1583
  const row = this.getById(qitem_id);
1450
- if (!row || row.state !== "pending" || !this.unroutableWakeRetryable(row, now))
1584
+ if (!row || row.state !== "pending" || !this.reachableWakeRetryable(row, now))
1451
1585
  continue;
1452
1586
  // The failed wake may be the row's own intent or an un-park's blocker intent: re-send whichever failed.
1453
1587
  // One in flight or delivered is never sent again; only a row with no intent at all takes the plain nudge.
@@ -1459,7 +1593,7 @@ export class QueueRepository {
1459
1593
  if (intent.delivery_state === "failed")
1460
1594
  await this.deliverWakeIntent(intent.outbox_id, attempted, eligible);
1461
1595
  }
1462
- else
1596
+ else if (this.unroutableWakeRetryable(row, now))
1463
1597
  await this.maybeNudge(qitem_id, row.destinationSession, undefined, row.sourceSession);
1464
1598
  }
1465
1599
  }
@@ -1476,7 +1610,9 @@ export class QueueRepository {
1476
1610
  * (the "delivered-ack-pending" nudge literal). It is never promoted to
1477
1611
  * delivered nor demoted to failed.
1478
1612
  */
1479
- async performWakeSend(qitemId, destinationSession, sourceSession, bodyOverride, prebuiltText, committedOutboxIds, trigger = "agent", recheckMembers) {
1613
+ async performWakeSend(qitemId, destinationSession, sourceSession, bodyOverride, prebuiltText, committedOutboxIds, trigger = "agent", recheckMembers,
1614
+ /** An explicit notification, which passes a rig's delivery drain (here, and if a hook bridge queues it). */
1615
+ explicit = false) {
1480
1616
  // DEFECT FIX (S1-class, 3 live specimens): a virtual
1481
1617
  // @external destination has NO pane — the queue row ITSELF is the gateway
1482
1618
  // subsystem's input (the Slack connector polls human-destined rows and its own
@@ -1554,7 +1690,7 @@ export class QueueRepository {
1554
1690
  const res = await this.transport.send(destinationSession, text, { verify: true, stampISO, actorSession: sourceSession, committedOutboxIds,
1555
1691
  deliveryId: committedOutboxIds ? undefined : deliveryId, auditPointer: qitemId, queueWake: true,
1556
1692
  ...(trigger === "openrig" ? { openrigNotice: true } : {}), ...(admission.urgentBy ? { urgent: { by: admission.urgentBy } } : {}),
1557
- ...(recheckMembers ? { recheckMembers } : {}) });
1693
+ ...(recheckMembers ? { recheckMembers } : {}), ...(explicit ? { drainExempt: true } : {}) });
1558
1694
  // OPR.0.3.2.21.FR-4(c) — wording rename: the prior literal
1559
1695
  // "sent-unverified" read as a failure even in the common case
1560
1696
  // (delivery confirmed but the synchronous ack window expired,
@@ -1595,7 +1731,7 @@ export class QueueRepository {
1595
1731
  * Every new surface uses the same ID; old IDs and their original bodies remain intact. An answer to a decision parked
1596
1732
  * on the person it asked belongs to that park's question (`episodeKey`): its ID includes it, and only that ID counts. */
1597
1733
  async createHumanAnswer(input) {
1598
- const { episodeKey, ...create } = input;
1734
+ const { episodeKey, verifyBeforeCreate, ...create } = input;
1599
1735
  // A runner's permission request is answered in its ask, and the runner reads the answer back. No reply row: it
1600
1736
  // would wake the runner's terminal, where typed text reads as a prompt to its agent. A host pairing request is
1601
1737
  // answered in its ask too: the pairing poll reads it there, and nothing reads a reply.
@@ -1610,7 +1746,7 @@ export class QueueRepository {
1610
1746
  const answered = this.getById(qitemId);
1611
1747
  if (answered)
1612
1748
  return answered;
1613
- return this.create({ ...create, qitemId, tags: [...new Set([...(input.tags ?? []), "human-answer"])] });
1749
+ return this.create({ ...create, qitemId, tags: [...new Set([...(input.tags ?? []), "human-answer"])] }, verifyBeforeCreate);
1614
1750
  }
1615
1751
  /** Every answer this person returned to the ask (one per park), oldest first: after close, a replay finds the one its
1616
1752
  * event returned or was absorbed into, whichever park it answered. */
@@ -1676,7 +1812,7 @@ export class QueueRepository {
1676
1812
  const row = episode ? this.getById(humanAnswerId(qitemId, episode.key)) : null;
1677
1813
  return row?.sourceSession === actorSession ? row : null;
1678
1814
  }
1679
- async create(input) {
1815
+ async create(input, verifyBeforeCreate) {
1680
1816
  // FOUNDER ROOT INVARIANT (2026-08-27, supersedes 51-09 incr 4 / ruling cb19867f Q2):
1681
1817
  // a LOCAL write stores the bare transport identity — no self-host suffix inside one
1682
1818
  // instance. Host identity is added only at the cross-host forwarding boundary
@@ -1690,6 +1826,7 @@ export class QueueRepository {
1690
1826
  // record, but its wake comes from OpenRig: the seat named as source didn't send it.
1691
1827
  const wakeFrom = input.wakeTrigger === "openrig" && !isOpenRigSender(input.sourceSession) ? OPENRIG_SENDER : input.sourceSession;
1692
1828
  const txn = this.db.transaction(() => {
1829
+ verifyBeforeCreate?.();
1693
1830
  const created = this.createInTransactionalContext(input);
1694
1831
  if (this.outbox && input.nudge !== false) {
1695
1832
  try {
@@ -1894,6 +2031,8 @@ export class QueueRepository {
1894
2031
  if (humanQuestions) {
1895
2032
  this.db.prepare("UPDATE queue_items SET human_questions = ? WHERE qitem_id = ?").run(JSON.stringify(humanQuestions), id);
1896
2033
  }
2034
+ const replaced = input.returnRoute == null && handedOffFrom ? this.getById(handedOffFrom) : null;
2035
+ this.persistReturnRoute(id, input.returnRoute ?? replaced?.returnRoute ?? null, input.returnRoute ? input.returnRouteBasis ?? null : replaced?.returnRouteBasis ?? null);
1897
2036
  this.persistMintingGeneration(id, input.sourceSession);
1898
2037
  const notification = this.classifyOwnerNotification({
1899
2038
  action: "create",
@@ -1939,30 +2078,40 @@ export class QueueRepository {
1939
2078
  throw new QueueRepositoryError("invalid_human_notification", "humanAlert marks an ask to a person as alert-worthy, and an update isn't an ask: send it without --alert; updates are notices; delivery depends on the person's connector and settings.");
1940
2079
  }
1941
2080
  }
1942
- /** A person by address or by the registry: a registered person may be addressed as their seat or an alias. */
1943
- /** A runner's permission ask whose seat has since been relaunched can't be answered: its request died with the
1944
- * occupant. Close it (canceled), so the person sees it isn't waiting, and return true. An unreadable ledger
1945
- * closes nothing. */
2081
+ /** Where a runner permission ask's seat stands, read once from the live tenure ledger. Only `replaced` (a later occupant holds
2082
+ * the seat) and `absent` (the node itself is gone) are positive evidence that the ask can never be answered. `no-tenure`
2083
+ * (the node exists but its ledger has no tenure) and `unreadable` (the read threw) prove neither that the ask is current
2084
+ * nor that it is stale: they are unknown. */
2085
+ runnerPermissionAuthority(origin) {
2086
+ try {
2087
+ const tenure = new SessionRegistry(this.db).currentOccupantTenure(origin.nodeId);
2088
+ if (tenure)
2089
+ return tenure.generationUuid === origin.generation ? "current" : "replaced";
2090
+ return this.db.prepare("SELECT 1 FROM nodes WHERE id = ?").get(origin.nodeId) ? "no-tenure" : "absent";
2091
+ }
2092
+ catch {
2093
+ return "unreadable";
2094
+ }
2095
+ }
2096
+ /** A runner's permission ask whose seat has since been relaunched (or gone) can't be answered: its request died with the
2097
+ * occupant. Close it (canceled), so the person sees it isn't waiting, and return true. Authority that is merely unknown
2098
+ * (no tenure yet, or an unreadable ledger) closes nothing. */
1946
2099
  closeStaleRunnerPermission(qitemId) {
1947
2100
  const item = this.getById(qitemId);
1948
2101
  const origin = item?.state === "pending" ? runnerPermissionOrigin(item) : null;
1949
2102
  if (!item || !origin)
1950
2103
  return false;
1951
- let current;
1952
- try {
1953
- current = this.db.prepare("SELECT generation_uuid FROM occupant_tenures WHERE node_id = ? ORDER BY generation_ordinal DESC LIMIT 1")
1954
- .get(origin.nodeId)?.generation_uuid ?? null;
1955
- }
1956
- catch {
1957
- return false;
1958
- }
1959
- if (current === origin.generation)
2104
+ const authority = this.runnerPermissionAuthority(origin);
2105
+ if (authority !== "replaced" && authority !== "absent")
1960
2106
  return false;
1961
2107
  this.update({ qitemId, actorSession: item.sourceSession, state: "canceled",
1962
2108
  transitionNote: "runner-permission-stale reason=relaunched: a later occupant holds this seat, so any answer here is not sent." });
1963
2109
  return true;
1964
2110
  }
2111
+ /** A person by address or by the registry: a registered person may be addressed as their seat or an alias. */
1965
2112
  isPersonAddress(destination) {
2113
+ if (!destination.includes("@"))
2114
+ return false;
1966
2115
  if (isHumanSeatSessionRef(destination))
1967
2116
  return true;
1968
2117
  const registry = this.loadHumanRegistryFn();
@@ -2107,6 +2256,8 @@ export class QueueRepository {
2107
2256
  }
2108
2257
  this.persistSummary(newId, input.summary ?? null);
2109
2258
  this.persistEvidenceRef(newId, input.evidenceRef ?? null);
2259
+ // The goal's return route goes with the work, as its body does.
2260
+ this.persistReturnRoute(newId, source.returnRoute ?? null, source.returnRouteBasis ?? null);
2110
2261
  this.persistMintingGeneration(newId, input.fromSession);
2111
2262
  const carried = this.carryPermissionQuestion(source, newId, input.toSession);
2112
2263
  const successorNotification = this.classifyOwnerNotification({
@@ -2263,6 +2414,8 @@ export class QueueRepository {
2263
2414
  }
2264
2415
  this.persistSummary(newId, input.summary ?? null);
2265
2416
  this.persistEvidenceRef(newId, input.evidenceRef ?? null);
2417
+ // The goal's return route goes with the work, as its body does.
2418
+ this.persistReturnRoute(newId, source.returnRoute ?? null, source.returnRouteBasis ?? null);
2266
2419
  this.persistMintingGeneration(newId, input.fromSession);
2267
2420
  const carried = this.carryPermissionQuestion(source, newId, input.toSession);
2268
2421
  const successorNotification = this.classifyOwnerNotification({
@@ -2558,6 +2711,7 @@ export class QueueRepository {
2558
2711
  identityProvenance: input.identityProvenance ?? null, // P21 §4 era-stamp
2559
2712
  identityPrincipal: input.identityPrincipal ?? null,
2560
2713
  });
2714
+ this.recordRelayPickup(qitem, input.destinationSession);
2561
2715
  // OPR.0.5.8.1 S1b — CLAIM-RESUME. A blocked row is claimable ("only
2562
2716
  // pending/blocked are claimable"), so claiming is a real exit from a park
2563
2717
  // and it writes state directly rather than through update(). This is the
@@ -2663,6 +2817,50 @@ export class QueueRepository {
2663
2817
  const result = this.updateInTransactionalContext(input);
2664
2818
  return { qitemId: input.qitemId, ...result };
2665
2819
  }
2820
+ /**
2821
+ * Add tags to a row in any state, and change nothing else: its existing tags stay, its state, claim and closure are
2822
+ * untouched, and a closed row isn't reopened. A tag the row already has adds nothing. The tags added are recorded as a
2823
+ * transition naming the actor, like a note; when every tag is already there, nothing is written. Tags are never
2824
+ * removed or rewritten here.
2825
+ */
2826
+ addTags(input) {
2827
+ const txn = this.db.transaction(() => {
2828
+ const qitem = this.getById(input.qitemId);
2829
+ if (!qitem)
2830
+ throw new QueueRepositoryError("qitem_not_found", `qitem ${input.qitemId} not found`);
2831
+ const existing = qitem.tags ?? [];
2832
+ const added = [...new Set(input.tags)].filter((tag) => !existing.includes(tag));
2833
+ if (added.length === 0)
2834
+ return { added, persistedEvents: [] };
2835
+ this.db.prepare("UPDATE queue_items SET tags = ? WHERE qitem_id = ?").run(JSON.stringify([...existing, ...added]), input.qitemId);
2836
+ this.transitionLog.append({
2837
+ qitemId: input.qitemId,
2838
+ state: qitem.state,
2839
+ actorSession: input.actorSession,
2840
+ // The values as a JSON array, so a tag holding a comma reads apart from two tags.
2841
+ transitionNote: `tags added: ${JSON.stringify(added)}`,
2842
+ // Like a note append, this keeps a claim's retained park gate for a later state write to end.
2843
+ closureTarget: qitem.state === "in-progress" ? this.retainedClaimBlocker(input.qitemId) : undefined,
2844
+ identityProvenance: input.identityProvenance ?? null,
2845
+ identityPrincipal: input.identityPrincipal ?? null,
2846
+ });
2847
+ const persistedEvent = this.eventBus.persistWithinTransaction({
2848
+ type: "queue.updated",
2849
+ qitemId: input.qitemId,
2850
+ fromState: qitem.state,
2851
+ toState: qitem.state,
2852
+ closureReason: null,
2853
+ closureTarget: null,
2854
+ actorSession: input.actorSession,
2855
+ summary: qitem.summary ?? null,
2856
+ });
2857
+ return { added, persistedEvents: [persistedEvent] };
2858
+ });
2859
+ const result = txn();
2860
+ for (const event of result.persistedEvents)
2861
+ this.eventBus.notifySubscribers(event);
2862
+ return { item: this.getByIdOrThrow(input.qitemId), added: result.added };
2863
+ }
2666
2864
  /** Notify subscribers of events persisted inside a caller's own transaction (updateWithinTransaction), after it commits. */
2667
2865
  notifyCommitted(events) {
2668
2866
  for (const event of events)
@@ -2986,7 +3184,8 @@ export class QueueRepository {
2986
3184
  jobsRepo.recordEvaluation(job.jobId, job.registeredAt, false);
2987
3185
  parkWake = { kind: "timer", ref: job.jobId };
2988
3186
  }
2989
- else if (input.state === "blocked" && effectiveBlockedOn?.startsWith("qitem-")) {
3187
+ else if (input.state === "blocked" && effectiveBlockedOn && effectiveBlockedOn !== input.qitemId && !isHumanPark && !isTypedGateBlocker(effectiveBlockedOn)
3188
+ && (effectiveBlockedOn.startsWith("qitem-") || isBlockerLive(this.getById(effectiveBlockedOn)?.state ?? ""))) {
2990
3189
  parkWake = { kind: "blocker", ref: effectiveBlockedOn };
2991
3190
  }
2992
3191
  const ts = new Date().toISOString();
@@ -3161,6 +3360,9 @@ export class QueueRepository {
3161
3360
  const blockedRows = this.db
3162
3361
  .prepare("SELECT qitem_id, destination_session FROM queue_items WHERE blocked_on = ? AND state = 'blocked'")
3163
3362
  .all(input.qitemId);
3363
+ // Typed gates and people own their own resolution even when a custom row ID collides.
3364
+ if (blockedRows.length === 0 || isTypedGateBlocker(input.qitemId) || this.isPersonAddress(input.qitemId))
3365
+ return dependentEvents;
3164
3366
  for (const r of blockedRows) {
3165
3367
  const closed = this.getById(input.qitemId);
3166
3368
  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 ?? "") : [];
@@ -3273,7 +3475,7 @@ export class QueueRepository {
3273
3475
  /** Read-only scope-aware RECENT projection. Normalization and its hard cap
3274
3476
  * live with the append-only transition log; the repository owns the public
3275
3477
  * queue-domain door. */
3276
- listRecentTransitions(scope, limit = 20) {
3478
+ listRecentTransitions(scope, limit = DEFAULT_RECENT_TRANSITIONS_LIMIT) {
3277
3479
  return this.transitionLog.listRecent(typeof scope === "string" ? { kind: "rig", rig: scope } : scope, limit);
3278
3480
  }
3279
3481
  /** The parked row an ordinary due park timer reminds about, when its reminder may share one message with other
@@ -3296,23 +3498,80 @@ export class QueueRepository {
3296
3498
  return null;
3297
3499
  return { qitemId: row.qitemId, summary: row.summary ?? null, continuation: this.currentParkContinuation(row.qitemId) };
3298
3500
  }
3501
+ /** The parked rows of `owner` whose current park this job wakes (QueueWakeRepository.findCurrentParkRowsByWatchdog):
3502
+ * at a queue-only seat the reminder is noted on them, never another row (#3076). */
3503
+ parkedRowsOwnedBy(jobId, owner) {
3504
+ return this.wakeRepo.findCurrentParkRowsByWatchdog(jobId, owner);
3505
+ }
3506
+ /** Notes a queue-only seat's park wake on each parked row it is about (#3076), in one transaction, each only while
3507
+ * the row is still `owner`'s and its current park is still the job's; nothing is typed. Returns the rows noted. */
3508
+ noteParkedRows(owner, notes) {
3509
+ const written = this.db.transaction(() => notes.flatMap(({ qitemId, jobId, note }) => {
3510
+ if (!this.wakeRepo.findCurrentParkRowsByWatchdog(jobId, owner).includes(qitemId))
3511
+ return [];
3512
+ this.transitionLog.append({ qitemId, state: "blocked", actorSession: "watchdog@system", transitionNote: note });
3513
+ return [{ qitemId, event: this.eventBus.persistWithinTransaction({ type: "queue.updated", qitemId, fromState: "blocked", toState: "blocked",
3514
+ closureReason: null, closureTarget: null, actorSession: "watchdog@system", summary: this.getById(qitemId)?.summary ?? null }) }];
3515
+ })).immediate();
3516
+ for (const { event } of written)
3517
+ this.eventBus.notifySubscribers(event);
3518
+ return written.map(({ qitemId }) => qitemId);
3519
+ }
3520
+ /** Notes a later occurrence of a watchdog job on its earlier cold row at a queue-only seat (#3076), while that row is
3521
+ * open (pending, in progress or blocked, claimed or not): the reminder is already in the queue, so no second row. The
3522
+ * row is chosen and noted in one write transaction, so a close can't land between them. Returns the row's id, or null. */
3523
+ noteOpenWatchdogRow(jobId, destinationSession, note) {
3524
+ const noted = this.db.transaction(() => {
3525
+ const row = this.db.prepare(`SELECT qitem_id FROM queue_items
3526
+ WHERE destination_session = ? AND state IN ('pending', 'in-progress', 'blocked') AND source_session = 'watchdog@system'
3527
+ AND tags IS NOT NULL AND json_valid(tags)
3528
+ AND EXISTS (SELECT 1 FROM json_each(queue_items.tags) WHERE value = 'queue-only')
3529
+ AND EXISTS (SELECT 1 FROM json_each(queue_items.tags) WHERE value = ?)
3530
+ ORDER BY ts_created DESC, rowid DESC LIMIT 1`).get(destinationSession, `watchdog-job:${jobId}`);
3531
+ if (!row)
3532
+ return null;
3533
+ return { qitemId: row.qitem_id, ...this.updateInTransactionalContext({ qitemId: row.qitem_id, actorSession: "watchdog@system", transitionNote: note }) };
3534
+ }).immediate();
3535
+ if (!noted)
3536
+ return null;
3537
+ for (const event of noted.persistedEvents)
3538
+ this.eventBus.notifySubscribers(event);
3539
+ return noted.qitemId;
3540
+ }
3299
3541
  /** Called by the watchdog engine after the delivery attempt is durably
3300
3542
  * audited. The queue transition records that attempt independently of
3301
- * whether the HELD row's owner consumed it. */
3302
- recordWatchdogWakeAttempt(jobId, deliveryStatus, retryAt) {
3543
+ * whether the HELD row's owner consumed it. At a queue-only seat (#3076), `receipt.targetSession`, nothing is
3544
+ * written on that seat's rows here: the delivery already noted the rows its reminder was about, and their fire is
3545
+ * recorded on that note; a row of the seat it didn't note (parked again with no wake of its own) wasn't that
3546
+ * reminder's. Another owner's row bound to the job says what the reminder became (`receipt.queuedQitemId`). */
3547
+ recordWatchdogWakeAttempt(jobId, deliveryStatus, retryAt, receipt) {
3303
3548
  const bindings = this.wakeRepo.findBlockedQitemsByWatchdog(jobId);
3304
3549
  if (bindings.length === 0)
3305
3550
  return;
3306
3551
  // Both receipt ownership and timer lifecycle follow the current park.
3307
3552
  const targets = this.wakeRepo.findBlockedQitemsByWatchdog(jobId, true);
3553
+ const queueOnlySeat = !retryAt && isQueueOnlyDeliveryCode(deliveryStatus) ? receipt?.targetSession : undefined;
3554
+ const noteOfDelivery = queueOnlySeat === undefined ? null : this.db.prepare(`SELECT t.transition_id FROM queue_transitions t
3555
+ WHERE t.qitem_id = ? AND t.actor_session = 'watchdog@system' AND substr(t.transition_note, 1, length(?)) = ?
3556
+ AND t.transition_id > (SELECT MAX(a.transition_id) FROM queue_transition_wakes a WHERE a.qitem_id = t.qitem_id AND a.phase = 'armed')
3557
+ AND NOT EXISTS (SELECT 1 FROM queue_transition_wakes w WHERE w.transition_id = t.transition_id)
3558
+ ORDER BY t.transition_id DESC LIMIT 1`);
3308
3559
  const recordFired = ({ qitemId, kind }) => {
3560
+ if (noteOfDelivery && this.getById(qitemId)?.destinationSession === queueOnlySeat) {
3561
+ const noted = noteOfDelivery.get(qitemId, parkedRowNotePrefix(jobId), parkedRowNotePrefix(jobId));
3562
+ if (noted)
3563
+ this.wakeRepo.record({ transitionId: noted.transition_id, qitemId, phase: "fired", kind, ref: jobId, deliveryStatus });
3564
+ return null;
3565
+ }
3309
3566
  const transition = this.transitionLog.append({
3310
3567
  qitemId,
3311
3568
  state: "blocked",
3312
3569
  actorSession: "watchdog@system",
3313
3570
  transitionNote: retryAt ? `park wake failed: watchdog ${jobId}; delivery=${deliveryStatus}; occurrence remains owed; retry at ${retryAt}` : deliveryStatus === "retained"
3314
3571
  ? `park wake retained: watchdog ${jobId}; not delivered; blocked work unchanged`
3315
- : `park wake fired: watchdog ${jobId}; delivery=${deliveryStatus}; awaiting owner consumption`,
3572
+ : deliveryStatus === QUEUED_AS_ROW || deliveryStatus === NOTED_ON_QUEUED_ROW
3573
+ ? queuedAsRowNote(jobId, deliveryStatus, receipt?.queuedQitemId)
3574
+ : `park wake fired: watchdog ${jobId}; delivery=${deliveryStatus}; awaiting owner consumption`,
3316
3575
  });
3317
3576
  if (!retryAt)
3318
3577
  this.wakeRepo.record({
@@ -3345,7 +3604,7 @@ export class QueueRepository {
3345
3604
  // resolving the blocker is a provider-limit outcome, not a timer one.
3346
3605
  const parkGeneratedTimer = this.wakeRepo.findCurrentQitemsByGeneratedTimer(jobId).length > 0;
3347
3606
  const events = this.db.transaction(() => {
3348
- const firedEvents = targets.map(recordFired);
3607
+ const firedEvents = targets.map(recordFired).filter((event) => event !== null);
3349
3608
  if (retryAt || deliveryStatus === "retained")
3350
3609
  return firedEvents;
3351
3610
  if (usageLimitBlockers.length === 0) {
@@ -3645,6 +3904,15 @@ export class QueueRepository {
3645
3904
  if (!question?.options.some((o) => o.id === input.optionId))
3646
3905
  return { status: "not-applicable", reason: "unknown-option" };
3647
3906
  const recorded = item.humanAnswers ?? {};
3907
+ // A retained click fills a missing answer; it never replaces a committed choice in this ask or park.
3908
+ // A previous park's saved values do not count as answers to the current park.
3909
+ const recordedInCurrentPark = episodeKey && this.transitionLog.listForQitem(item.qitemId).some((transition) => transition.transitionId > Number(episodeKey.slice(episodeKey.lastIndexOf(":") + 1))
3910
+ && transition.transitionNote === `human-answer-recorded: ${JSON.stringify({ questionId: input.questionId, optionId: recorded[input.questionId] })}`);
3911
+ if (input.onlyIfUnanswered && Object.prototype.hasOwnProperty.call(recorded, input.questionId)
3912
+ && (item.state === "pending" || recordedInCurrentPark)) {
3913
+ return { status: "recorded", answers: recorded,
3914
+ complete: unansweredQuestions(item.humanQuestions, recorded).length === 0, questions: item.humanQuestions };
3915
+ }
3648
3916
  // 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
3649
3917
  // on the re-park records over it.
3650
3918
  if (unansweredQuestions(item.humanQuestions, recorded).length === 0
@@ -3652,9 +3920,13 @@ export class QueueRepository {
3652
3920
  return { status: "recorded", answers: recorded, complete: true, questions: item.humanQuestions };
3653
3921
  }
3654
3922
  const answers = { ...(item.humanAnswers ?? {}), [input.questionId]: input.optionId };
3655
- this.db.prepare("UPDATE queue_items SET human_answers = ? WHERE qitem_id = ?").run(JSON.stringify(answers), input.qitemId);
3656
3923
  const complete = unansweredQuestions(item.humanQuestions, answers).length === 0;
3657
- if (item.humanAnswers?.[input.questionId] !== input.optionId) {
3924
+ if (item.humanAnswers?.[input.questionId] !== input.optionId || (episodeKey && !recordedInCurrentPark)) {
3925
+ const transition = this.transitionLog.append({ qitemId: input.qitemId, state: item.state, actorSession: input.actorSession,
3926
+ transitionNote: `human-answer-recorded: ${JSON.stringify({ questionId: input.questionId, optionId: input.optionId })}`,
3927
+ identityProvenance: input.identityProvenance, identityPrincipal: input.identityPrincipal });
3928
+ this.db.prepare("UPDATE queue_items SET human_answers = ?, ts_updated = ? WHERE qitem_id = ?")
3929
+ .run(JSON.stringify(answers), transition.ts, input.qitemId);
3658
3930
  changed = { summary: item.summary ?? null, answered: item.humanQuestions.length - unansweredQuestions(item.humanQuestions, answers).length };
3659
3931
  }
3660
3932
  return { status: "recorded", answers, complete, questions: item.humanQuestions };
@@ -3662,9 +3934,11 @@ export class QueueRepository {
3662
3934
  // The click is on the ask before anyone hears of it; a failed event never takes it back or holds up its return.
3663
3935
  if (changed && result.status === "recorded") {
3664
3936
  try {
3665
- this.eventBus.emit({ type: "queue.answer_recorded", qitemId: input.qitemId, actorSession: input.actorSession,
3937
+ const event = this.eventBus.persistWithinTransaction({ type: "queue.answer_recorded", qitemId: input.qitemId, actorSession: input.actorSession,
3666
3938
  questionId: input.questionId, answered: changed.answered, questions: result.questions.length,
3667
3939
  complete: result.complete, summary: changed.summary });
3940
+ if (!this.eventBus.registerPersistedWithinActiveEnvelope(event))
3941
+ this.eventBus.notifySubscribers(event);
3668
3942
  }
3669
3943
  catch (error) {
3670
3944
  console.warn(`[queue] ${input.qitemId}'s recorded answer has no event`, error);
@@ -3689,6 +3963,25 @@ export class QueueRepository {
3689
3963
  return posted !== null && answered !== null && answered > posted;
3690
3964
  }
3691
3965
  /** A park's current question: its latest human-required transition, and that notification's final post receipt, if any. */
3966
+ /** Bounded recorded relations for an opened request/result. No inference from seats, summaries or timestamps. */
3967
+ relatedTo(qitemId, limit = 101) {
3968
+ const rows = this.db.prepare(`SELECT qitem_id, reply_to, handed_off_from, blocked_on FROM queue_items
3969
+ WHERE reply_to = ? OR handed_off_from = ? OR blocked_on = ? ORDER BY rowid LIMIT ?`)
3970
+ .all(qitemId, qitemId, qitemId, Math.min(101, Math.max(1, limit)));
3971
+ return rows.flatMap(row => {
3972
+ const item = this.getById(row.qitem_id);
3973
+ if (!item)
3974
+ return [];
3975
+ const relations = [];
3976
+ if (row.reply_to === qitemId)
3977
+ relations.push("reply-to");
3978
+ if (row.handed_off_from === qitemId)
3979
+ relations.push("handed-off-from");
3980
+ if (row.blocked_on === qitemId)
3981
+ relations.push("blocked-on");
3982
+ return relations.map(relation => ({ item, relation }));
3983
+ });
3984
+ }
3692
3985
  /** The opaque revision of what a person decides on (#2446): the question (body, intent, questions, and the evidence it
3693
3986
  * points to, when it has any) and its decision state (open, blocked or terminal; who it's addressed to or parked on; its
3694
3987
  * answers, a decision made for them, the current park, and the replies returned). A label, a wake, a claim or a note on a
@@ -3987,13 +4280,22 @@ export class QueueRepository {
3987
4280
  return null;
3988
4281
  }
3989
4282
  /** The parked query's obligation face: open rows to one destination, newest first, without the per-row
3990
- * projections list() derives (pickup, waiting view, delivery ledger), which this read never uses. */
4283
+ * projections list() derives (pickup, waiting view, delivery ledger), which this read never uses. A wake escalation
4284
+ * about this seat's own prompt that nobody holds is left out: with no operator seat to carry it, the alert falls back
4285
+ * to the seat itself, and the escalation is the wake, not the content, so it is never that seat's work. One its owner
4286
+ * explicitly holds (blocked) stays, so that hold and its wake are diagnosed as before; so does a row whose tags aren't
4287
+ * a JSON array. */
3991
4288
  listOpenObligations(destinationSession, limit) {
3992
4289
  const addresses = this.resolveSessionAddresses(destinationSession);
3993
4290
  const slots = addresses.map(() => "?").join(",");
4291
+ const ownPrompt = addresses.flatMap((address) => [`prompt-destination:${address}`, `consumed-prompt-destination:${address}`]);
3994
4292
  const rows = this.db.prepare(`SELECT qitem_id, state${this.hasSummaryColumn ? ", summary" : ""} FROM queue_items
3995
4293
  WHERE destination_session IN (${slots}) AND state IN ('pending', 'in-progress', 'blocked')
3996
- ORDER BY ts_created DESC LIMIT ?`).all(...addresses, limit);
4294
+ AND NOT CASE WHEN state != 'blocked' AND json_valid(tags) THEN CASE WHEN json_type(tags) = 'array' THEN
4295
+ EXISTS (SELECT 1 FROM json_each(queue_items.tags) WHERE value = ?)
4296
+ AND EXISTS (SELECT 1 FROM json_each(queue_items.tags) WHERE value IN (${ownPrompt.map(() => "?").join(",")}))
4297
+ ELSE 0 END ELSE 0 END
4298
+ ORDER BY ts_created DESC LIMIT ?`).all(...addresses, WAKE_ESCALATION_TAG, ...ownPrompt, limit);
3997
4299
  return rows.map((r) => ({ qitemId: r.qitem_id, state: r.state, summary: r.summary ?? null }));
3998
4300
  }
3999
4301
  list(opts) {
@@ -4208,11 +4510,13 @@ export class QueueRepository {
4208
4510
  LIMIT ?
4209
4511
  `;
4210
4512
  const rows = this.db.prepare(sql).all(...params);
4211
- return rows.map((r) => this.rowToItem(r));
4513
+ return rows.map((r) => this.rowToItem(r, opts?.includeWaiting ?? true));
4212
4514
  }
4213
- /** The compact listings' columns: the shared set plus the summary, which is short and is what people search for. */
4515
+ /** The compact listings' columns: the shared set plus the summary, which is short and is what people search for, and a
4516
+ * routed row's return route, which isn't elided, so a routed row never lists as unrouted. */
4214
4517
  compactColumns() {
4215
- return COMPACT_QUEUE_COLUMNS + (this.hasSummaryColumn ? ", summary" : "") + (this.hasHumanIntentColumn ? ", human_intent" : "");
4518
+ return COMPACT_QUEUE_COLUMNS + (this.hasSummaryColumn ? ", summary" : "") + (this.hasHumanIntentColumn ? ", human_intent" : "")
4519
+ + (this.hasReturnRouteColumn ? ", return_route, return_route_basis" : "");
4216
4520
  }
4217
4521
  findOverdue(opts) {
4218
4522
  const cutoff = opts?.now ?? new Date().toISOString();
@@ -4778,6 +5082,16 @@ export class QueueRepository {
4778
5082
  * (#2742). */
4779
5083
  static PULL_OUTBOX_NEVER_POSTED_WINDOW_MS = 24 * 60 * 60 * 1000;
4780
5084
  /** Record one wake attempt. */
5085
+ /** How a wake queued for the seat's hook bridge ended there, on the row's nudge record, so the queue's own rules (such
5086
+ * as prompt-clear recovery of a refused wake) read the real end and not `bridged:queued` (#3270). A typed fallback's
5087
+ * result is recorded as a typed wake's is. */
5088
+ recordBridgedWakeEnd(qitemId, end) {
5089
+ const result = end.kind === "typed" && end.result ? this.classifyWakeResult(end.result).nudgeResult
5090
+ : end.kind === "handed-to-hook" ? "bridged:handed-to-hook"
5091
+ : end.kind === "not-delivered" ? "failed:hook_bridge_not_delivered"
5092
+ : "indeterminate:hook_bridge_claimed_unacked";
5093
+ this.recordNudgeAttempt(qitemId, result);
5094
+ }
4781
5095
  recordNudgeAttempt(qitemId, result) {
4782
5096
  const ts = new Date().toISOString();
4783
5097
  this.db
@@ -4787,8 +5101,7 @@ export class QueueRepository {
4787
5101
  .run(ts, result, qitemId);
4788
5102
  // The transport's definite no-write refusal establishes the episode even when a
4789
5103
  // fresh hook hid needs_input. Uncertain delivery never arms clear-triggered replay.
4790
- if (!this.promptClearRetries.has(qitemId) && (result === "failed:target_needs_input"
4791
- || (result.startsWith("failed:Refused:") && result.includes("interactive prompt")))) {
5104
+ if (!this.promptClearRetries.has(qitemId) && isPromptOwnedWakeRefusal(result)) {
4792
5105
  const row = this.getById(qitemId);
4793
5106
  if (row?.state === "pending")
4794
5107
  this.promptRecoveryState.set(row.destinationSession, true);
@@ -4946,6 +5259,32 @@ export class QueueRepository {
4946
5259
  this.db.prepare("UPDATE queue_items SET evidence_ref = ? WHERE qitem_id = ?").run(evidenceRef, qitemId);
4947
5260
  }
4948
5261
  }
5262
+ /** A relay task's claim is pickup at its return route. It's recorded on the escalation the task carries, keyed by that
5263
+ * delivery episode, so the episode resolves. Pickup only: not the person's answer or approval, and nothing about the
5264
+ * seat's prompt. */
5265
+ recordRelayPickup(relay, actor) {
5266
+ if (!relay.tags?.includes(RELAY_TAG))
5267
+ return;
5268
+ const escalationId = relay.tags.find(t => t.startsWith(RELAY_FOR_PREFIX))?.slice(RELAY_FOR_PREFIX.length);
5269
+ const key = relay.tags.find(t => t.startsWith(RELAY_KEY_PREFIX))?.slice(RELAY_KEY_PREFIX.length);
5270
+ // Only the episode's own relay (its id, OpenRig as source, its tags) records pickup; a row that only carries the tags doesn't.
5271
+ if (!escalationId || !key || !isEpisodeRelay(relay, escalationId, key, OPENRIG_SENDER))
5272
+ return;
5273
+ const escalation = this.getById(escalationId);
5274
+ if (!escalation)
5275
+ return;
5276
+ this.transitionLog.append({
5277
+ qitemId: escalation.qitemId, state: escalation.state, actorSession: "wake-ladder@system",
5278
+ 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`,
5279
+ closureTarget: escalation.state === "in-progress" ? this.retainedClaimBlocker(escalation.qitemId) : undefined,
5280
+ });
5281
+ }
5282
+ /** A row's return route (return-route.ts), when it has one; a schema without the column keeps the row without it. */
5283
+ persistReturnRoute(qitemId, route, basis) {
5284
+ if (!this.hasReturnRouteColumn || !route)
5285
+ return;
5286
+ this.db.prepare("UPDATE queue_items SET return_route = ?, return_route_basis = ? WHERE qitem_id = ?").run(route, basis, qitemId);
5287
+ }
4949
5288
  /** GHOST-STAGE (e/Class-B) — persist the MINTING occupant-generation additively (same degrade
4950
5289
  * contract as persistSummary; NULL when unresolved/pre-063). Forensic provenance of the creator;
4951
5290
  * the RELEASE discriminator is claimed_by_generation_uuid (stamped at claim), not this. */
@@ -5144,12 +5483,15 @@ export class QueueRepository {
5144
5483
  handoffAdvisory(row) {
5145
5484
  // Generic updates can write handed-off and retain a previous handoff's owner
5146
5485
  // after reopening. Skip only when that owner still matches this closure.
5147
- if ((row.state === "handed-off" && matchesRecordedHandoffTarget(row.qitem_id, row.handed_off_to, row.closure_target)) || !isTerminalState(row.state)
5148
- || row.closure_reason !== "handed_off_to" || !row.closure_target)
5486
+ if ((row.state === "handed-off" && matchesRecordedHandoffTarget(row.qitem_id, row.handed_off_to, row.closure_target)) || (!isTerminalState(row.state) && !(row.state === "canceled" && row.closure_reason === "superseded"))
5487
+ || !row.closure_target || (row.closure_reason !== "handed_off_to"
5488
+ && !(row.closure_reason === "superseded" && row.closure_target.startsWith("qitem-"))))
5149
5489
  return undefined;
5150
5490
  const target = row.closure_target;
5151
5491
  try {
5152
- if (hasLinkedSuccessor(this.db, row.qitem_id, target))
5492
+ if (row.closure_reason === "superseded"
5493
+ ? this.db.prepare("SELECT 1 FROM queue_items WHERE qitem_id = ?").get(target)
5494
+ : hasLinkedSuccessor(this.db, row.qitem_id, target))
5153
5495
  return undefined;
5154
5496
  }
5155
5497
  catch {
@@ -5162,9 +5504,13 @@ export class QueueRepository {
5162
5504
  status: "unverified",
5163
5505
  target,
5164
5506
  reason: "no-live-local-successor",
5165
- message: foreignTarget
5166
- ? `Successor custody for '${target}' is unverified on this daemon: the successor is named on that host, and this daemon cannot read its custody. This closure records a handoff claim, not proof of transfer or pickup. Use 'rig queue handoff' or 'handoff-and-complete' with '--to <seat@rig>'; add '--host <registered-host>' for another host instead of manually closing to the successor ID; a local handoff is atomic, across hosts the successor is created first and the source closed after, and an uncertain result is reconciled by its exact id, since re-running the same handoff is idempotent.`
5167
- : `Successor custody for '${target}' is unverified on this daemon: no local row with this source's lineage was found. A successor may exist on another host. This closure records a handoff claim, not proof of transfer or pickup; reconcile the successor by ID. Use 'rig queue handoff' or 'handoff-and-complete' with '--to <seat@rig>'; add '--host <registered-host>' for another host instead of manually closing to the successor ID; a local handoff is atomic, across hosts the successor is created first and the source closed after, and an uncertain result is reconciled by its exact id, since re-running the same handoff is idempotent.`,
5507
+ message: row.closure_reason === "superseded"
5508
+ ? `Successor custody for '${target}' is unverified on this daemon: ${foreignTarget
5509
+ ? "the recorded successor is on another host; read it there"
5510
+ : "no local row with this ID was found; reconcile the recorded successor by ID"}. This row records supersession, not proof of transfer or pickup.`
5511
+ : foreignTarget
5512
+ ? `Successor custody for '${target}' is unverified on this daemon: the successor is named on that host, and this daemon cannot read its custody. This closure records a handoff claim, not proof of transfer or pickup. Use 'rig queue handoff' or 'handoff-and-complete' with '--to <seat@rig>'; add '--host <registered-host>' for another host instead of manually closing to the successor ID; a local handoff is atomic, across hosts the successor is created first and the source closed after, and an uncertain result is reconciled by its exact id, since re-running the same handoff is idempotent.`
5513
+ : `Successor custody for '${target}' is unverified on this daemon: no local row with this source's lineage was found. A successor may exist on another host. This closure records a handoff claim, not proof of transfer or pickup; reconcile the successor by ID. Use 'rig queue handoff' or 'handoff-and-complete' with '--to <seat@rig>'; add '--host <registered-host>' for another host instead of manually closing to the successor ID; a local handoff is atomic, across hosts the successor is created first and the source closed after, and an uncertain result is reconciled by its exact id, since re-running the same handoff is idempotent.`,
5168
5514
  };
5169
5515
  }
5170
5516
  rowToItem(row, includeWaiting = true, listed) {
@@ -5232,6 +5578,7 @@ export class QueueRepository {
5232
5578
  // older test fixtures supply legacy rows where target_repo is undefined.
5233
5579
  targetRepo: row.target_repo ?? null,
5234
5580
  ...(row.content_erased_at ? { contentErasedAt: row.content_erased_at } : {}),
5581
+ ...(row.return_route ? { returnRoute: row.return_route, returnRouteBasis: row.return_route_basis ?? null } : {}),
5235
5582
  };
5236
5583
  }
5237
5584
  }