@openrig/cli 0.7.17 → 0.7.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (657) hide show
  1. package/README.md +5 -5
  2. package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +1 -1
  3. package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +1 -1
  4. package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
  5. package/daemon/assets/plugins/openrig/plugin.json +1 -1
  6. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  7. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  8. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +5 -0
  9. package/daemon/assets/plugins/openrig-core/skills/messaging-the-human/SKILL.md +23 -0
  10. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +11 -0
  11. package/daemon/assets/plugins/openrig-core/skills/refocusing/scripts/trace-to-root.py +25 -5
  12. package/daemon/assets/skills/rigs/SKILL.md +33 -19
  13. package/daemon/assets/skills/rigs/references/installing-for-someone.md +2 -2
  14. package/daemon/context-packs/help/manifest.yaml +1 -1
  15. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  16. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +42 -8
  17. package/daemon/context-packs/reference/getting-started.md +4 -4
  18. package/daemon/context-packs/reference/manifest.yaml +1 -1
  19. package/daemon/context-packs/reference/rig-spec.md +166 -0
  20. package/daemon/context-packs/reference/whats-new.md +107 -6
  21. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  22. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  23. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  24. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  25. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  26. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  27. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  28. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  29. package/daemon/context-packs/skills/core/messaging-the-human/SKILL.md +23 -0
  30. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  31. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  32. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/openrig-user/SKILL.md +11 -0
  50. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  66. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/refocusing/scripts/trace-to-root.py +25 -5
  73. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  76. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  77. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  78. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  79. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  80. package/daemon/dist/adapters/claude-code-adapter.js +16 -5
  81. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  82. package/daemon/dist/adapters/claude-resume.d.ts +2 -1
  83. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  84. package/daemon/dist/adapters/claude-resume.js +13 -5
  85. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  86. package/daemon/dist/adapters/kernel-authority.d.ts +1 -1
  87. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  88. package/daemon/dist/adapters/kernel-authority.js +22 -10
  89. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  90. package/daemon/dist/adapters/pi-runner-protocol.d.ts +43 -0
  91. package/daemon/dist/adapters/pi-runner-protocol.d.ts.map +1 -1
  92. package/daemon/dist/adapters/pi-runner-protocol.js.map +1 -1
  93. package/daemon/dist/adapters/pi-runner.d.ts +50 -1
  94. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  95. package/daemon/dist/adapters/pi-runner.js +463 -13
  96. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  97. package/daemon/dist/adapters/tmux-credential-env.d.ts +4 -0
  98. package/daemon/dist/adapters/tmux-credential-env.d.ts.map +1 -0
  99. package/daemon/dist/adapters/tmux-credential-env.js +14 -0
  100. package/daemon/dist/adapters/tmux-credential-env.js.map +1 -0
  101. package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
  102. package/daemon/dist/adapters/tmux-exec.js +4 -3
  103. package/daemon/dist/adapters/tmux-exec.js.map +1 -1
  104. package/daemon/dist/adapters/tmux-server.d.ts +2 -2
  105. package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
  106. package/daemon/dist/adapters/tmux-server.js +12 -4
  107. package/daemon/dist/adapters/tmux-server.js.map +1 -1
  108. package/daemon/dist/adapters/tmux.d.ts +220 -12
  109. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  110. package/daemon/dist/adapters/tmux.js +835 -29
  111. package/daemon/dist/adapters/tmux.js.map +1 -1
  112. package/daemon/dist/attention-surface.d.ts +4 -1
  113. package/daemon/dist/attention-surface.d.ts.map +1 -1
  114. package/daemon/dist/attention-surface.js.map +1 -1
  115. package/daemon/dist/build-info.js +3 -3
  116. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  117. package/daemon/dist/db/all-migrations.js +8 -0
  118. package/daemon/dist/db/all-migrations.js.map +1 -1
  119. package/daemon/dist/db/migrations/171_claude_auto_mode.d.ts +4 -0
  120. package/daemon/dist/db/migrations/171_claude_auto_mode.d.ts.map +1 -0
  121. package/daemon/dist/db/migrations/171_claude_auto_mode.js +9 -0
  122. package/daemon/dist/db/migrations/171_claude_auto_mode.js.map +1 -0
  123. package/daemon/dist/db/migrations/171_node_input_route.d.ts +4 -0
  124. package/daemon/dist/db/migrations/171_node_input_route.d.ts.map +1 -0
  125. package/daemon/dist/db/migrations/171_node_input_route.js +6 -0
  126. package/daemon/dist/db/migrations/171_node_input_route.js.map +1 -0
  127. package/daemon/dist/db/migrations/172_queue_return_route.d.ts +3 -0
  128. package/daemon/dist/db/migrations/172_queue_return_route.d.ts.map +1 -0
  129. package/daemon/dist/db/migrations/172_queue_return_route.js +13 -0
  130. package/daemon/dist/db/migrations/172_queue_return_route.js.map +1 -0
  131. package/daemon/dist/db/migrations/173_node_process_limits.d.ts +4 -0
  132. package/daemon/dist/db/migrations/173_node_process_limits.d.ts.map +1 -0
  133. package/daemon/dist/db/migrations/173_node_process_limits.js +6 -0
  134. package/daemon/dist/db/migrations/173_node_process_limits.js.map +1 -0
  135. package/daemon/dist/domain/activity-grants.d.ts.map +1 -1
  136. package/daemon/dist/domain/activity-grants.js +2 -0
  137. package/daemon/dist/domain/activity-grants.js.map +1 -1
  138. package/daemon/dist/domain/agent-activity-store.d.ts +36 -1
  139. package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
  140. package/daemon/dist/domain/agent-activity-store.js +192 -3
  141. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  142. package/daemon/dist/domain/agent-images/resume-token-discovery.d.ts +10 -0
  143. package/daemon/dist/domain/agent-images/resume-token-discovery.d.ts.map +1 -1
  144. package/daemon/dist/domain/agent-images/resume-token-discovery.js +21 -0
  145. package/daemon/dist/domain/agent-images/resume-token-discovery.js.map +1 -1
  146. package/daemon/dist/domain/applied-launch-observation-store.d.ts +5 -0
  147. package/daemon/dist/domain/applied-launch-observation-store.d.ts.map +1 -1
  148. package/daemon/dist/domain/applied-launch-observation-store.js +57 -21
  149. package/daemon/dist/domain/applied-launch-observation-store.js.map +1 -1
  150. package/daemon/dist/domain/builtin-startup-files.d.ts +26 -12
  151. package/daemon/dist/domain/builtin-startup-files.d.ts.map +1 -1
  152. package/daemon/dist/domain/builtin-startup-files.js +73 -34
  153. package/daemon/dist/domain/builtin-startup-files.js.map +1 -1
  154. package/daemon/dist/domain/claude-auto-mode.d.ts +64 -0
  155. package/daemon/dist/domain/claude-auto-mode.d.ts.map +1 -0
  156. package/daemon/dist/domain/claude-auto-mode.js +114 -0
  157. package/daemon/dist/domain/claude-auto-mode.js.map +1 -0
  158. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +2 -0
  159. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  160. package/daemon/dist/domain/claude-compaction-enforcer.js +11 -4
  161. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  162. package/daemon/dist/domain/claude-continuation-launch.d.ts +5 -1
  163. package/daemon/dist/domain/claude-continuation-launch.d.ts.map +1 -1
  164. package/daemon/dist/domain/claude-continuation-launch.js +51 -2
  165. package/daemon/dist/domain/claude-continuation-launch.js.map +1 -1
  166. package/daemon/dist/domain/claude-core-plugin-env.d.ts +7 -3
  167. package/daemon/dist/domain/claude-core-plugin-env.d.ts.map +1 -1
  168. package/daemon/dist/domain/claude-core-plugin-env.js +11 -8
  169. package/daemon/dist/domain/claude-core-plugin-env.js.map +1 -1
  170. package/daemon/dist/domain/codex-daemon-support.d.ts.map +1 -1
  171. package/daemon/dist/domain/codex-daemon-support.js +6 -1
  172. package/daemon/dist/domain/codex-daemon-support.js.map +1 -1
  173. package/daemon/dist/domain/community-harness-launch-result.d.ts +2 -0
  174. package/daemon/dist/domain/community-harness-launch-result.d.ts.map +1 -1
  175. package/daemon/dist/domain/community-harness-launch-result.js +5 -1
  176. package/daemon/dist/domain/community-harness-launch-result.js.map +1 -1
  177. package/daemon/dist/domain/connection-contract.d.ts +91 -0
  178. package/daemon/dist/domain/connection-contract.d.ts.map +1 -1
  179. package/daemon/dist/domain/connection-contract.js +73 -0
  180. package/daemon/dist/domain/connection-contract.js.map +1 -1
  181. package/daemon/dist/domain/context-usage-store.d.ts +5 -0
  182. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  183. package/daemon/dist/domain/context-usage-store.js +37 -2
  184. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  185. package/daemon/dist/domain/current-work.d.ts +6 -1
  186. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  187. package/daemon/dist/domain/current-work.js +41 -8
  188. package/daemon/dist/domain/current-work.js.map +1 -1
  189. package/daemon/dist/domain/cwd-resolution.d.ts +2 -0
  190. package/daemon/dist/domain/cwd-resolution.d.ts.map +1 -1
  191. package/daemon/dist/domain/cwd-resolution.js +7 -2
  192. package/daemon/dist/domain/cwd-resolution.js.map +1 -1
  193. package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
  194. package/daemon/dist/domain/draft-aware-delivery.js +5 -1
  195. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
  196. package/daemon/dist/domain/errors.d.ts +4 -0
  197. package/daemon/dist/domain/errors.d.ts.map +1 -1
  198. package/daemon/dist/domain/errors.js +7 -0
  199. package/daemon/dist/domain/errors.js.map +1 -1
  200. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  201. package/daemon/dist/domain/execution-view.js +8 -1
  202. package/daemon/dist/domain/execution-view.js.map +1 -1
  203. package/daemon/dist/domain/existing-rig-restore.d.ts +2 -0
  204. package/daemon/dist/domain/existing-rig-restore.d.ts.map +1 -1
  205. package/daemon/dist/domain/existing-rig-restore.js +1 -0
  206. package/daemon/dist/domain/existing-rig-restore.js.map +1 -1
  207. package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
  208. package/daemon/dist/domain/gateway/operator-delivery-engine.js +107 -3
  209. package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
  210. package/daemon/dist/domain/gateway/slack/capabilities.d.ts +9 -1
  211. package/daemon/dist/domain/gateway/slack/capabilities.d.ts.map +1 -1
  212. package/daemon/dist/domain/gateway/slack/capabilities.js +6 -1
  213. package/daemon/dist/domain/gateway/slack/capabilities.js.map +1 -1
  214. package/daemon/dist/domain/gateway/slack/inbound-admission.js +1 -1
  215. package/daemon/dist/domain/gateway/slack/inbound-admission.js.map +1 -1
  216. package/daemon/dist/domain/gateway/slack/inbound.d.ts +4 -0
  217. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  218. package/daemon/dist/domain/gateway/slack/inbound.js +15 -1
  219. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  220. package/daemon/dist/domain/gateway/slack/manifest.d.ts +5 -1
  221. package/daemon/dist/domain/gateway/slack/manifest.d.ts.map +1 -1
  222. package/daemon/dist/domain/gateway/slack/manifest.js +12 -3
  223. package/daemon/dist/domain/gateway/slack/manifest.js.map +1 -1
  224. package/daemon/dist/domain/gateway/slack/message.d.ts +1 -0
  225. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  226. package/daemon/dist/domain/gateway/slack/message.js +4 -1
  227. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  228. package/daemon/dist/domain/gateway/slack/queue-access.d.ts +2 -0
  229. package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
  230. package/daemon/dist/domain/gateway/slack/queue-access.js +1 -0
  231. package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
  232. package/daemon/dist/domain/gateway/slack/settled-asks.d.ts.map +1 -1
  233. package/daemon/dist/domain/gateway/slack/settled-asks.js +6 -5
  234. package/daemon/dist/domain/gateway/slack/settled-asks.js.map +1 -1
  235. package/daemon/dist/domain/gateway/slack/slack-api.d.ts +1 -0
  236. package/daemon/dist/domain/gateway/slack/slack-api.d.ts.map +1 -1
  237. package/daemon/dist/domain/gateway/slack/slack-api.js +7 -2
  238. package/daemon/dist/domain/gateway/slack/slack-api.js.map +1 -1
  239. package/daemon/dist/domain/harness-not-started-notice.d.ts +36 -0
  240. package/daemon/dist/domain/harness-not-started-notice.d.ts.map +1 -0
  241. package/daemon/dist/domain/harness-not-started-notice.js +81 -0
  242. package/daemon/dist/domain/harness-not-started-notice.js.map +1 -0
  243. package/daemon/dist/domain/hot-potato-enforcer.d.ts +1 -1
  244. package/daemon/dist/domain/input-read-diagnostic.js +1 -1
  245. package/daemon/dist/domain/input-read-diagnostic.js.map +1 -1
  246. package/daemon/dist/domain/instance-initialization.d.ts +2 -0
  247. package/daemon/dist/domain/instance-initialization.d.ts.map +1 -1
  248. package/daemon/dist/domain/instance-initialization.js +2 -1
  249. package/daemon/dist/domain/instance-initialization.js.map +1 -1
  250. package/daemon/dist/domain/member-connection.d.ts +14 -0
  251. package/daemon/dist/domain/member-connection.d.ts.map +1 -0
  252. package/daemon/dist/domain/member-connection.js +34 -0
  253. package/daemon/dist/domain/member-connection.js.map +1 -0
  254. package/daemon/dist/domain/model-divergence/current-model-reader.d.ts +3 -1
  255. package/daemon/dist/domain/model-divergence/current-model-reader.d.ts.map +1 -1
  256. package/daemon/dist/domain/model-divergence/current-model-reader.js +32 -7
  257. package/daemon/dist/domain/model-divergence/current-model-reader.js.map +1 -1
  258. package/daemon/dist/domain/native-permission-store.d.ts +6 -2
  259. package/daemon/dist/domain/native-permission-store.d.ts.map +1 -1
  260. package/daemon/dist/domain/native-permission-store.js +12 -5
  261. package/daemon/dist/domain/native-permission-store.js.map +1 -1
  262. package/daemon/dist/domain/native-resume-probe.d.ts +5 -0
  263. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  264. package/daemon/dist/domain/native-resume-probe.js +94 -10
  265. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  266. package/daemon/dist/domain/network/network-connector.d.ts.map +1 -1
  267. package/daemon/dist/domain/network/network-connector.js +11 -2
  268. package/daemon/dist/domain/network/network-connector.js.map +1 -1
  269. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  270. package/daemon/dist/domain/node-inventory.js +28 -0
  271. package/daemon/dist/domain/node-inventory.js.map +1 -1
  272. package/daemon/dist/domain/node-launcher.d.ts +8 -0
  273. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  274. package/daemon/dist/domain/node-launcher.js +19 -4
  275. package/daemon/dist/domain/node-launcher.js.map +1 -1
  276. package/daemon/dist/domain/outbox-handler.d.ts +50 -0
  277. package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
  278. package/daemon/dist/domain/outbox-handler.js +255 -1
  279. package/daemon/dist/domain/outbox-handler.js.map +1 -1
  280. package/daemon/dist/domain/parked-query.d.ts.map +1 -1
  281. package/daemon/dist/domain/parked-query.js +3 -1
  282. package/daemon/dist/domain/parked-query.js.map +1 -1
  283. package/daemon/dist/domain/permission-account.d.ts +28 -1
  284. package/daemon/dist/domain/permission-account.d.ts.map +1 -1
  285. package/daemon/dist/domain/permission-account.js +55 -11
  286. package/daemon/dist/domain/permission-account.js.map +1 -1
  287. package/daemon/dist/domain/permission-drift.d.ts +2 -0
  288. package/daemon/dist/domain/permission-drift.d.ts.map +1 -1
  289. package/daemon/dist/domain/permission-drift.js.map +1 -1
  290. package/daemon/dist/domain/pi-compaction-request-store.d.ts +16 -0
  291. package/daemon/dist/domain/pi-compaction-request-store.d.ts.map +1 -0
  292. package/daemon/dist/domain/pi-compaction-request-store.js +40 -0
  293. package/daemon/dist/domain/pi-compaction-request-store.js.map +1 -0
  294. package/daemon/dist/domain/pi-compaction-service.d.ts +82 -0
  295. package/daemon/dist/domain/pi-compaction-service.d.ts.map +1 -0
  296. package/daemon/dist/domain/pi-compaction-service.js +229 -0
  297. package/daemon/dist/domain/pi-compaction-service.js.map +1 -0
  298. package/daemon/dist/domain/process-limits.d.ts +37 -0
  299. package/daemon/dist/domain/process-limits.d.ts.map +1 -0
  300. package/daemon/dist/domain/process-limits.js +69 -0
  301. package/daemon/dist/domain/process-limits.js.map +1 -0
  302. package/daemon/dist/domain/process-table.d.ts +9 -0
  303. package/daemon/dist/domain/process-table.d.ts.map +1 -1
  304. package/daemon/dist/domain/process-table.js +21 -4
  305. package/daemon/dist/domain/process-table.js.map +1 -1
  306. package/daemon/dist/domain/proof/judgments.d.ts +7 -0
  307. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  308. package/daemon/dist/domain/proof/judgments.js +27 -1
  309. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  310. package/daemon/dist/domain/ps-projection.d.ts +2 -1
  311. package/daemon/dist/domain/ps-projection.d.ts.map +1 -1
  312. package/daemon/dist/domain/ps-projection.js +6 -1
  313. package/daemon/dist/domain/ps-projection.js.map +1 -1
  314. package/daemon/dist/domain/queue-erasure.d.ts +11 -6
  315. package/daemon/dist/domain/queue-erasure.d.ts.map +1 -1
  316. package/daemon/dist/domain/queue-erasure.js +44 -21
  317. package/daemon/dist/domain/queue-erasure.js.map +1 -1
  318. package/daemon/dist/domain/queue-repository.d.ts +62 -14
  319. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  320. package/daemon/dist/domain/queue-repository.js +270 -65
  321. package/daemon/dist/domain/queue-repository.js.map +1 -1
  322. package/daemon/dist/domain/queue-stuck-sweep.d.ts +3 -0
  323. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  324. package/daemon/dist/domain/queue-stuck-sweep.js +45 -13
  325. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  326. package/daemon/dist/domain/queue-transition-log.d.ts +5 -3
  327. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  328. package/daemon/dist/domain/queue-transition-log.js +9 -6
  329. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  330. package/daemon/dist/domain/queue-wake-ladder.d.ts +8 -0
  331. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  332. package/daemon/dist/domain/queue-wake-ladder.js +155 -17
  333. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  334. package/daemon/dist/domain/queue-wake-repository.d.ts +2 -1
  335. package/daemon/dist/domain/queue-wake-repository.d.ts.map +1 -1
  336. package/daemon/dist/domain/queue-wake-repository.js +31 -4
  337. package/daemon/dist/domain/queue-wake-repository.js.map +1 -1
  338. package/daemon/dist/domain/restore-check-service.d.ts +10 -0
  339. package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
  340. package/daemon/dist/domain/restore-check-service.js +76 -3
  341. package/daemon/dist/domain/restore-check-service.js.map +1 -1
  342. package/daemon/dist/domain/restore-orchestrator.d.ts +60 -2
  343. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  344. package/daemon/dist/domain/restore-orchestrator.js +241 -50
  345. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  346. package/daemon/dist/domain/restore-plan-preview.d.ts +28 -1
  347. package/daemon/dist/domain/restore-plan-preview.d.ts.map +1 -1
  348. package/daemon/dist/domain/restore-plan-preview.js +17 -5
  349. package/daemon/dist/domain/restore-plan-preview.js.map +1 -1
  350. package/daemon/dist/domain/restore-preconditions.d.ts +24 -0
  351. package/daemon/dist/domain/restore-preconditions.d.ts.map +1 -1
  352. package/daemon/dist/domain/restore-preconditions.js +61 -1
  353. package/daemon/dist/domain/restore-preconditions.js.map +1 -1
  354. package/daemon/dist/domain/resume-token-validation.d.ts +3 -1
  355. package/daemon/dist/domain/resume-token-validation.d.ts.map +1 -1
  356. package/daemon/dist/domain/resume-token-validation.js +6 -3
  357. package/daemon/dist/domain/resume-token-validation.js.map +1 -1
  358. package/daemon/dist/domain/return-route.d.ts +73 -0
  359. package/daemon/dist/domain/return-route.d.ts.map +1 -0
  360. package/daemon/dist/domain/return-route.js +124 -0
  361. package/daemon/dist/domain/return-route.js.map +1 -0
  362. package/daemon/dist/domain/rig-expansion-service.js +1 -1
  363. package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
  364. package/daemon/dist/domain/rig-repository.d.ts +12 -0
  365. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  366. package/daemon/dist/domain/rig-repository.js +73 -0
  367. package/daemon/dist/domain/rig-repository.js.map +1 -1
  368. package/daemon/dist/domain/rig-teardown.d.ts +4 -2
  369. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  370. package/daemon/dist/domain/rig-teardown.js +32 -13
  371. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  372. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  373. package/daemon/dist/domain/rigspec-codec.js +9 -0
  374. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  375. package/daemon/dist/domain/rigspec-exporter.d.ts +6 -0
  376. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  377. package/daemon/dist/domain/rigspec-exporter.js +30 -0
  378. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  379. package/daemon/dist/domain/rigspec-instantiator.d.ts +22 -2
  380. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  381. package/daemon/dist/domain/rigspec-instantiator.js +82 -23
  382. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  383. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  384. package/daemon/dist/domain/rigspec-schema.js +44 -1
  385. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  386. package/daemon/dist/domain/rosters.d.ts +12 -0
  387. package/daemon/dist/domain/rosters.d.ts.map +1 -1
  388. package/daemon/dist/domain/rosters.js +17 -4
  389. package/daemon/dist/domain/rosters.js.map +1 -1
  390. package/daemon/dist/domain/runner-channel.d.ts +33 -0
  391. package/daemon/dist/domain/runner-channel.d.ts.map +1 -0
  392. package/daemon/dist/domain/runner-channel.js +179 -0
  393. package/daemon/dist/domain/runner-channel.js.map +1 -0
  394. package/daemon/dist/domain/runner-grant-launch.js +2 -2
  395. package/daemon/dist/domain/runtime-adapter.d.ts +2 -0
  396. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  397. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  398. package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -1
  399. package/daemon/dist/domain/runtime-switch-materials.js +4 -3
  400. package/daemon/dist/domain/runtime-switch-materials.js.map +1 -1
  401. package/daemon/dist/domain/scope/scope-audit.d.ts.map +1 -1
  402. package/daemon/dist/domain/scope/scope-audit.js +55 -3
  403. package/daemon/dist/domain/scope/scope-audit.js.map +1 -1
  404. package/daemon/dist/domain/seat-attention-reconciler.d.ts +6 -4
  405. package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
  406. package/daemon/dist/domain/seat-attention-reconciler.js +17 -10
  407. package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
  408. package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
  409. package/daemon/dist/domain/seat-delivery-guard.js +2 -1
  410. package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
  411. package/daemon/dist/domain/seat-handover-service.d.ts +27 -4
  412. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  413. package/daemon/dist/domain/seat-handover-service.js +203 -63
  414. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  415. package/daemon/dist/domain/seat-identity-reconciler.d.ts +8 -1
  416. package/daemon/dist/domain/seat-identity-reconciler.d.ts.map +1 -1
  417. package/daemon/dist/domain/seat-identity-reconciler.js +52 -12
  418. package/daemon/dist/domain/seat-identity-reconciler.js.map +1 -1
  419. package/daemon/dist/domain/seat-lifecycle-service.d.ts +21 -4
  420. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  421. package/daemon/dist/domain/seat-lifecycle-service.js +68 -2
  422. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  423. package/daemon/dist/domain/seat-restart-in-place.d.ts +9 -2
  424. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  425. package/daemon/dist/domain/seat-restart-in-place.js +34 -2
  426. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  427. package/daemon/dist/domain/seat-runtime-switch-service.d.ts +4 -0
  428. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  429. package/daemon/dist/domain/seat-runtime-switch-service.js +9 -3
  430. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  431. package/daemon/dist/domain/seat-status-service.d.ts +4 -0
  432. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  433. package/daemon/dist/domain/seat-status-service.js +31 -6
  434. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  435. package/daemon/dist/domain/session-transport.d.ts +16 -3
  436. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  437. package/daemon/dist/domain/session-transport.js +134 -9
  438. package/daemon/dist/domain/session-transport.js.map +1 -1
  439. package/daemon/dist/domain/shared-conversation.d.ts +58 -0
  440. package/daemon/dist/domain/shared-conversation.d.ts.map +1 -0
  441. package/daemon/dist/domain/shared-conversation.js +98 -0
  442. package/daemon/dist/domain/shared-conversation.js.map +1 -0
  443. package/daemon/dist/domain/startup-phase-timing.d.ts +19 -0
  444. package/daemon/dist/domain/startup-phase-timing.d.ts.map +1 -0
  445. package/daemon/dist/domain/startup-phase-timing.js +23 -0
  446. package/daemon/dist/domain/startup-phase-timing.js.map +1 -0
  447. package/daemon/dist/domain/successor-session-launcher.d.ts +9 -0
  448. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  449. package/daemon/dist/domain/successor-session-launcher.js +24 -7
  450. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  451. package/daemon/dist/domain/team-operations.d.ts +6 -6
  452. package/daemon/dist/domain/team-operations.d.ts.map +1 -1
  453. package/daemon/dist/domain/team-operations.js +2 -4
  454. package/daemon/dist/domain/team-operations.js.map +1 -1
  455. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts +6 -0
  456. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts.map +1 -1
  457. package/daemon/dist/domain/terminal/herdr-app-provider.js +23 -1
  458. package/daemon/dist/domain/terminal/herdr-app-provider.js.map +1 -1
  459. package/daemon/dist/domain/terminal-policy.js +1 -1
  460. package/daemon/dist/domain/terminal-policy.js.map +1 -1
  461. package/daemon/dist/domain/types.d.ts +82 -5
  462. package/daemon/dist/domain/types.d.ts.map +1 -1
  463. package/daemon/dist/domain/types.js.map +1 -1
  464. package/daemon/dist/domain/watchdog-delivery.d.ts +1 -1
  465. package/daemon/dist/domain/watchdog-delivery.d.ts.map +1 -1
  466. package/daemon/dist/domain/watchdog-delivery.js +6 -3
  467. package/daemon/dist/domain/watchdog-delivery.js.map +1 -1
  468. package/daemon/dist/domain/watchdog-jobs-repository.d.ts.map +1 -1
  469. package/daemon/dist/domain/watchdog-jobs-repository.js +1 -0
  470. package/daemon/dist/domain/watchdog-jobs-repository.js.map +1 -1
  471. package/daemon/dist/domain/watchdog-policy-engine.d.ts +5 -0
  472. package/daemon/dist/domain/watchdog-policy-engine.d.ts.map +1 -1
  473. package/daemon/dist/domain/watchdog-policy-engine.js +14 -4
  474. package/daemon/dist/domain/watchdog-policy-engine.js.map +1 -1
  475. package/daemon/dist/domain/workflow-runtime.d.ts +1 -1
  476. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  477. package/daemon/dist/domain/workflow-runtime.js +4 -2
  478. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  479. package/daemon/dist/domain/workspace/default-workspace-scaffold.d.ts +7 -1
  480. package/daemon/dist/domain/workspace/default-workspace-scaffold.d.ts.map +1 -1
  481. package/daemon/dist/domain/workspace/default-workspace-scaffold.js +35 -7
  482. package/daemon/dist/domain/workspace/default-workspace-scaffold.js.map +1 -1
  483. package/daemon/dist/gateway-slack-surface.d.ts +2 -2
  484. package/daemon/dist/gateway-slack-surface.d.ts.map +1 -1
  485. package/daemon/dist/gateway-slack-surface.js +1 -1
  486. package/daemon/dist/gateway-slack-surface.js.map +1 -1
  487. package/daemon/dist/index.d.ts.map +1 -1
  488. package/daemon/dist/index.js +13 -2
  489. package/daemon/dist/index.js.map +1 -1
  490. package/daemon/dist/routes/activity.d.ts.map +1 -1
  491. package/daemon/dist/routes/activity.js +105 -2
  492. package/daemon/dist/routes/activity.js.map +1 -1
  493. package/daemon/dist/routes/agent-images.d.ts.map +1 -1
  494. package/daemon/dist/routes/agent-images.js +6 -1
  495. package/daemon/dist/routes/agent-images.js.map +1 -1
  496. package/daemon/dist/routes/attention.d.ts.map +1 -1
  497. package/daemon/dist/routes/attention.js +2 -1
  498. package/daemon/dist/routes/attention.js.map +1 -1
  499. package/daemon/dist/routes/compaction.d.ts.map +1 -1
  500. package/daemon/dist/routes/compaction.js +46 -7
  501. package/daemon/dist/routes/compaction.js.map +1 -1
  502. package/daemon/dist/routes/queue.d.ts +4 -1
  503. package/daemon/dist/routes/queue.d.ts.map +1 -1
  504. package/daemon/dist/routes/queue.js +232 -34
  505. package/daemon/dist/routes/queue.js.map +1 -1
  506. package/daemon/dist/routes/require-sender-identity.d.ts +4 -3
  507. package/daemon/dist/routes/require-sender-identity.d.ts.map +1 -1
  508. package/daemon/dist/routes/require-sender-identity.js.map +1 -1
  509. package/daemon/dist/routes/restore-check.d.ts.map +1 -1
  510. package/daemon/dist/routes/restore-check.js +1 -0
  511. package/daemon/dist/routes/restore-check.js.map +1 -1
  512. package/daemon/dist/routes/rigspec.d.ts.map +1 -1
  513. package/daemon/dist/routes/rigspec.js +24 -4
  514. package/daemon/dist/routes/rigspec.js.map +1 -1
  515. package/daemon/dist/routes/seat.d.ts.map +1 -1
  516. package/daemon/dist/routes/seat.js +107 -6
  517. package/daemon/dist/routes/seat.js.map +1 -1
  518. package/daemon/dist/routes/sessions.js +14 -3
  519. package/daemon/dist/routes/sessions.js.map +1 -1
  520. package/daemon/dist/routes/startup.js +7 -1
  521. package/daemon/dist/routes/startup.js.map +1 -1
  522. package/daemon/dist/routes/up.d.ts.map +1 -1
  523. package/daemon/dist/routes/up.js +14 -4
  524. package/daemon/dist/routes/up.js.map +1 -1
  525. package/daemon/dist/routes/watchdog.d.ts.map +1 -1
  526. package/daemon/dist/routes/watchdog.js +18 -1
  527. package/daemon/dist/routes/watchdog.js.map +1 -1
  528. package/daemon/dist/server.d.ts +3 -0
  529. package/daemon/dist/server.d.ts.map +1 -1
  530. package/daemon/dist/server.js +11 -0
  531. package/daemon/dist/server.js.map +1 -1
  532. package/daemon/dist/startup.d.ts.map +1 -1
  533. package/daemon/dist/startup.js +51 -16
  534. package/daemon/dist/startup.js.map +1 -1
  535. package/daemon/docs/reference/agent-startup-guide.md +2 -1
  536. package/daemon/docs/reference/community-harness-examples/dsh/README.md +8 -0
  537. package/daemon/docs/reference/community-harness-examples/dsh/openrig-dsh-runner.mjs +139 -5
  538. package/daemon/docs/reference/community-harness-presets.md +2 -0
  539. package/daemon/docs/reference/daemon-http-clients.md +61 -12
  540. package/daemon/docs/reference/getting-started.md +4 -4
  541. package/daemon/docs/reference/harness-runner-contract.md +91 -1
  542. package/daemon/docs/reference/herdr-app.md +6 -0
  543. package/daemon/docs/reference/quickstart.md +2 -2
  544. package/daemon/docs/reference/rig-spec.md +166 -0
  545. package/daemon/docs/reference/rosters.md +9 -0
  546. package/daemon/docs/reference/sdlc-conventions.md +5 -1
  547. package/daemon/docs/reference/slack-app-setup.md +39 -21
  548. package/daemon/docs/reference/whats-new.md +107 -6
  549. package/daemon/specs/agents/shared/skills/core/messaging-the-human/SKILL.md +23 -0
  550. package/daemon/specs/rigs/launch/factory/guidance/lead-first-move.md +26 -5
  551. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +19 -5
  552. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/startup/context.md +1 -1
  553. package/daemon/specs/rigs/launch/kernel/culture/CULTURE.md +12 -0
  554. package/daemon/specs/rigs/launch/starter/guidance/lead-first-move.md +26 -5
  555. package/dist/acp/connector.js +1 -1
  556. package/dist/acp/connector.js.map +1 -1
  557. package/dist/build-info.js +3 -3
  558. package/dist/cli-error.d.ts.map +1 -1
  559. package/dist/cli-error.js +7 -1
  560. package/dist/cli-error.js.map +1 -1
  561. package/dist/client.d.ts +2 -1
  562. package/dist/client.d.ts.map +1 -1
  563. package/dist/client.js +3 -2
  564. package/dist/client.js.map +1 -1
  565. package/dist/commands/ask.d.ts.map +1 -1
  566. package/dist/commands/ask.js +92 -11
  567. package/dist/commands/ask.js.map +1 -1
  568. package/dist/commands/broadcast.js +9 -5
  569. package/dist/commands/broadcast.js.map +1 -1
  570. package/dist/commands/compact.d.ts +3 -4
  571. package/dist/commands/compact.d.ts.map +1 -1
  572. package/dist/commands/compact.js +76 -16
  573. package/dist/commands/compact.js.map +1 -1
  574. package/dist/commands/config-init-workspace.d.ts.map +1 -1
  575. package/dist/commands/config-init-workspace.js +3 -0
  576. package/dist/commands/config-init-workspace.js.map +1 -1
  577. package/dist/commands/down.d.ts.map +1 -1
  578. package/dist/commands/down.js +3 -1
  579. package/dist/commands/down.js.map +1 -1
  580. package/dist/commands/export.d.ts.map +1 -1
  581. package/dist/commands/export.js +2 -1
  582. package/dist/commands/export.js.map +1 -1
  583. package/dist/commands/fork.d.ts.map +1 -1
  584. package/dist/commands/fork.js +2 -0
  585. package/dist/commands/fork.js.map +1 -1
  586. package/dist/commands/launch.d.ts.map +1 -1
  587. package/dist/commands/launch.js +11 -3
  588. package/dist/commands/launch.js.map +1 -1
  589. package/dist/commands/ps.d.ts +28 -0
  590. package/dist/commands/ps.d.ts.map +1 -1
  591. package/dist/commands/ps.js +76 -2
  592. package/dist/commands/ps.js.map +1 -1
  593. package/dist/commands/queue.d.ts.map +1 -1
  594. package/dist/commands/queue.js +309 -21
  595. package/dist/commands/queue.js.map +1 -1
  596. package/dist/commands/rig.d.ts +2 -0
  597. package/dist/commands/rig.d.ts.map +1 -1
  598. package/dist/commands/rig.js +36 -2
  599. package/dist/commands/rig.js.map +1 -1
  600. package/dist/commands/roster.d.ts +3 -0
  601. package/dist/commands/roster.d.ts.map +1 -1
  602. package/dist/commands/seat.d.ts.map +1 -1
  603. package/dist/commands/seat.js +126 -7
  604. package/dist/commands/seat.js.map +1 -1
  605. package/dist/commands/send.d.ts.map +1 -1
  606. package/dist/commands/send.js +47 -6
  607. package/dist/commands/send.js.map +1 -1
  608. package/dist/commands/setup.js +2 -2
  609. package/dist/commands/setup.js.map +1 -1
  610. package/dist/commands/slack.d.ts +2 -1
  611. package/dist/commands/slack.d.ts.map +1 -1
  612. package/dist/commands/slack.js +38 -2
  613. package/dist/commands/slack.js.map +1 -1
  614. package/dist/commands/terminal.d.ts.map +1 -1
  615. package/dist/commands/terminal.js +5 -5
  616. package/dist/commands/terminal.js.map +1 -1
  617. package/dist/commands/up.d.ts.map +1 -1
  618. package/dist/commands/up.js +3 -0
  619. package/dist/commands/up.js.map +1 -1
  620. package/dist/commands/workflow.d.ts.map +1 -1
  621. package/dist/commands/workflow.js +4 -0
  622. package/dist/commands/workflow.js.map +1 -1
  623. package/dist/daemon-lifecycle.d.ts.map +1 -1
  624. package/dist/daemon-lifecycle.js +1 -0
  625. package/dist/daemon-lifecycle.js.map +1 -1
  626. package/dist/lib/model-observation.d.ts.map +1 -1
  627. package/dist/lib/model-observation.js +9 -3
  628. package/dist/lib/model-observation.js.map +1 -1
  629. package/dist/lib/scope/scope-audit.d.ts.map +1 -1
  630. package/dist/lib/scope/scope-audit.js +55 -3
  631. package/dist/lib/scope/scope-audit.js.map +1 -1
  632. package/dist/local-db.d.ts +5 -0
  633. package/dist/local-db.d.ts.map +1 -0
  634. package/dist/local-db.js +23 -0
  635. package/dist/local-db.js.map +1 -0
  636. package/dist/local-origin.d.ts.map +1 -1
  637. package/dist/local-origin.js +2 -17
  638. package/dist/local-origin.js.map +1 -1
  639. package/dist/mcp-server.d.ts.map +1 -1
  640. package/dist/mcp-server.js +122 -18
  641. package/dist/mcp-server.js.map +1 -1
  642. package/dist/sender-identity.d.ts +18 -6
  643. package/dist/sender-identity.d.ts.map +1 -1
  644. package/dist/sender-identity.js +67 -7
  645. package/dist/sender-identity.js.map +1 -1
  646. package/dist/terminal-window-rex.d.ts +1 -1
  647. package/dist/terminal-window-rex.d.ts.map +1 -1
  648. package/dist/terminal-window-rex.js +3 -2
  649. package/dist/terminal-window-rex.js.map +1 -1
  650. package/dist/terminal-window.js +3 -3
  651. package/dist/terminal-window.js.map +1 -1
  652. package/package.json +1 -1
  653. package/tui/dist/daemon-client.d.ts.map +1 -1
  654. package/tui/dist/daemon-client.js +2 -1
  655. package/tui/dist/daemon-client.js.map +1 -1
  656. package/ui/dist/assets/{index-BvUEh33d.js → index-1O1f3A7K.js} +55 -55
  657. package/ui/dist/index.html +1 -1
@@ -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";
@@ -12,8 +12,8 @@ import { SeenStore } from "./gateway/slack/state-store.js";
12
12
  import { getOpenRigHome } from "../openrig-compat.js";
13
13
  import { 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}`;
@@ -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";
@@ -108,6 +109,8 @@ const CLAIM_OVERRIDDEN_WAKE_PREFIX = `${WAKE_INTENT_PREFIX}claim-overridden-`;
108
109
  const CLAIM_OVERRIDDEN_WAKE_END = `${WAKE_INTENT_PREFIX}claim-overridden.`;
109
110
  /** On a wake intent whose ring a hosted member's trigger accepted: recovery doesn't ring that intent again. */
110
111
  const HOSTED_WAKE_ACCEPTED_TAG = "queue:hosted-wake-accepted";
112
+ /** A first failed intent with typed no-input proof permits one return retry; a claim consumes it. */
113
+ const WAKE_PRE_INPUT_FAILURE_TAG = "queue:wake-pre-input-failure";
111
114
  const AUTO_UNPARK_BLOCKER_TAG_PREFIX = "queue:auto-unpark:blocker-ref:";
112
115
  /** The actor on the transition routeToFallback writes; the row's own history is how a later reroute finds the line it wrote. */
113
116
  const FALLBACK_ACTOR = "system:queue-fallback";
@@ -158,6 +161,12 @@ export function classifyNudgeFailure(lastNudgeResult) {
158
161
  return "unknown";
159
162
  }
160
163
  export const QUEUE_PRIORITIES = ["routine", "urgent", "critical"];
164
+ /** The result of one wake attempt: its classification and its recorded result. */
165
+ /** The prompt-clear path owns these definite no-input refusals, even during a running hook. */
166
+ function isPromptOwnedWakeRefusal(result) {
167
+ return result === "failed:target_needs_input"
168
+ || (result?.startsWith("failed:Refused:") === true && result.includes("interactive prompt"));
169
+ }
161
170
  /** `principal:v1` marks only the transitions that record the request's own action. What that action sets off elsewhere
162
171
  * (a successor's wake intent, a parked row released, a blocker moved) carries the seat's stamp, transport:v1. */
163
172
  function sideEffectProvenance(provenance) {
@@ -311,8 +320,12 @@ export function matchesRecordedHandoffTarget(qitemId, handedOffTo, closureTarget
311
320
  * Throws on database/query errors so callers can handle lookup failures with their own policies.
312
321
  */
313
322
  export function hasLinkedSuccessor(db, sourceQitemId, target) {
314
- if (successorScope?.db === db && successorScope.covers(sourceQitemId))
323
+ if (successorScope?.db === db && successorScope.covers(sourceQitemId, target))
315
324
  return successorScope.has(sourceQitemId, target);
325
+ return queryLinkedSuccessor(db, sourceQitemId, target);
326
+ }
327
+ /** hasLinkedSuccessor's own query, for one source and target, through the primary key and the destination index. */
328
+ function queryLinkedSuccessor(db, sourceQitemId, target) {
316
329
  const successor = db
317
330
  .prepare(`SELECT 1 FROM queue_items s
318
331
  WHERE (s.qitem_id = ? OR s.destination_session = ?) AND s.qitem_id != ?
@@ -333,38 +346,57 @@ let successorScope = null;
333
346
  * successor is a row whose handed_off_from is the source, or whose chain_of_record is valid JSON with the source among
334
347
  * its json_each values (compared as `value IN (...)` compares, like `value = ?`: a number or a nested value never
335
348
  * 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. */
349
+ * not the source itself. The index covers the targets each source's own row names (its closure_target, each
350
+ * comma-separated part of it, and its handed_off_to), the ones the sweep and the row's handoff advisory ask about, so the
351
+ * chain_of_record arm reads only successors whose id or destination is one of them, through the primary key and the
352
+ * destination index, instead of every row's chain. Any other source or target keeps the per-row query, so every answer is
353
+ * the per-row query's. For a covered source and target, a snapshot from its first has() until invalidate(): the caller
354
+ * invalidates it whenever other code could have run. Any other target is read as it is now. run(fn) lends it, for the synchronous fn only, to the hasLinkedSuccessor calls made inside fn for a
355
+ * covered source and target. builtMs() is how long the build of the index as it is now took (0 while it is not built),
356
+ * so a caller can tell when rebuilding after each invalidate() costs more than it saves. */
341
357
  export function createLinkedSuccessorLookup(db, sourceQitemIds) {
342
358
  const sources = new Set(sourceQitemIds);
343
- let bySource = null;
359
+ let index = null;
344
360
  let buildMs = 0;
345
361
  const build = () => {
346
362
  const startedAt = performance.now();
347
- const map = new Map();
363
+ const bySource = new Map();
364
+ const targetsOf = new Map();
348
365
  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
- }
366
+ runSyncSite("queue.linked_successors.build", () => {
367
+ const named = db.prepare(`SELECT qitem_id, closure_target, handed_off_to FROM queue_items WHERE qitem_id IN (SELECT value FROM json_each(?))`)
368
+ .all(ids);
369
+ for (const r of named) {
370
+ const own = new Set();
371
+ for (const target of [r.closure_target, ...(r.closure_target ?? "").split(",").map((part) => part.trim()), r.handed_off_to])
372
+ if (target)
373
+ own.add(target);
374
+ targetsOf.set(r.qitem_id, own);
375
+ }
376
+ const targets = JSON.stringify([...new Set([...targetsOf.values()].flatMap((own) => [...own]))]);
377
+ const rows = db.prepare(`SELECT s.qitem_id, s.destination_session, s.handed_off_from AS source FROM queue_items s
378
+ WHERE s.handed_off_from IN (SELECT value FROM json_each(?))
379
+ UNION
380
+ SELECT s.qitem_id, s.destination_session, j.value AS source FROM queue_items s, json_each(s.chain_of_record) j
381
+ WHERE (s.qitem_id IN (SELECT value FROM json_each(?)) OR s.destination_session IN (SELECT value FROM json_each(?)))
382
+ AND s.chain_of_record IS NOT NULL AND json_valid(s.chain_of_record)
383
+ AND j.value IN (SELECT value FROM json_each(?))`).all(ids, targets, targets, ids);
384
+ for (const r of rows) {
385
+ const list = bySource.get(r.source);
386
+ const entry = { qitemId: r.qitem_id, destination: r.destination_session };
387
+ if (list)
388
+ list.push(entry);
389
+ else
390
+ bySource.set(r.source, [entry]);
391
+ }
392
+ });
363
393
  buildMs = performance.now() - startedAt;
364
- return map;
394
+ return { bySource, targetsOf };
365
395
  };
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 };
396
+ const covers = (sourceQitemId, target) => sources.has(sourceQitemId) && ((index ??= build()).targetsOf.get(sourceQitemId)?.has(target) ?? false);
397
+ const indexed = (sourceQitemId, target) => (index ??= build()).bySource.get(sourceQitemId)?.some((s) => s.qitemId !== sourceQitemId && (s.qitemId === target || s.destination === target)) ?? false;
398
+ const has = (sourceQitemId, target) => covers(sourceQitemId, target) ? indexed(sourceQitemId, target) : queryLinkedSuccessor(db, sourceQitemId, target);
399
+ const own = { db, covers, has: indexed };
368
400
  return {
369
401
  has,
370
402
  run: (fn) => {
@@ -379,7 +411,7 @@ export function createLinkedSuccessorLookup(db, sourceQitemIds) {
379
411
  successorScope = previous;
380
412
  }
381
413
  },
382
- invalidate: () => { bySource = null; buildMs = 0; },
414
+ invalidate: () => { index = null; buildMs = 0; },
383
415
  builtMs: () => buildMs,
384
416
  };
385
417
  }
@@ -583,6 +615,7 @@ export class QueueRepository {
583
615
  hasSummaryColumn;
584
616
  hasHumanIntentColumn;
585
617
  hasReplyToColumn;
618
+ hasReturnRouteColumn;
586
619
  hasHumanQuestionsColumn;
587
620
  hasDelegatedDecisionColumn;
588
621
  hasEvidenceRefColumn;
@@ -613,7 +646,7 @@ export class QueueRepository {
613
646
  this.deliveryDrains = new RigDeliveryDrainStore(db);
614
647
  this.eventBus = eventBus;
615
648
  this.transitionLog = new QueueTransitionLog(db);
616
- this.wakeRepo = new QueueWakeRepository(db);
649
+ this.wakeRepo = new QueueWakeRepository(db, (value) => this.isPersonAddress(value));
617
650
  this.validateRig = opts?.validateRig ?? (() => true);
618
651
  this.canRecordDestination = opts?.canRecordDestination ?? this.validateRig;
619
652
  this.destinationAdvisory = opts?.destinationAdvisory ?? (() => null);
@@ -635,6 +668,7 @@ export class QueueRepository {
635
668
  this.hasSummaryColumn = detectQueueColumn(db, "summary");
636
669
  this.hasHumanIntentColumn = detectQueueColumn(db, "human_intent");
637
670
  this.hasReplyToColumn = detectQueueColumn(db, "reply_to");
671
+ this.hasReturnRouteColumn = detectQueueColumn(db, "return_route");
638
672
  this.hasHumanQuestionsColumn = detectQueueColumn(db, "human_questions");
639
673
  this.hasDelegatedDecisionColumn = detectQueueColumn(db, "delegated_decision");
640
674
  this.hasEvidenceRefColumn = detectQueueColumn(db, "evidence_ref");
@@ -758,7 +792,7 @@ export class QueueRepository {
758
792
  if (inputUncertain || isWakeTimeoutSignal(res.reason) || isWakeTimeoutSignal(res.error)) {
759
793
  return { classified: "indeterminate", nudgeResult: `indeterminate:${detail}` };
760
794
  }
761
- return { classified: "failed", nudgeResult: `failed:${detail}` };
795
+ return { classified: "failed", nudgeResult: `failed:${detail}`, preInputFailure: res.inputPhase === "not_reached" && res.sent !== true };
762
796
  }
763
797
  /**
764
798
  * W1 (transactional closure): attach the durable wake-intent store AFTER
@@ -970,8 +1004,8 @@ export class QueueRepository {
970
1004
  /** #2789: a wake committed while its seat had no pane froze a binding that can never match once the seat is bound, so
971
1005
  * the delivery guard refused it on every retry. Such an intent takes its first live binding, on the same node and
972
1006
  * 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.
1007
+ * without a write) and carries no expected identity of its own. Previously pane-bound intents use the separate,
1008
+ * proof-only reconciliation at claim below; the guard's write-time check against the selected binding still holds.
975
1009
  * `entry` is the intent as read before its claim. Called inside the claim's transaction. */
976
1010
  bindFirstTarget(entry) {
977
1011
  const frozen = entry.guardBinding;
@@ -984,6 +1018,15 @@ export class QueueRepository {
984
1018
  return;
985
1019
  this.db.prepare("UPDATE outbox_entries SET guard_binding = ? WHERE outbox_id = ?").run(JSON.stringify(live), entry.outboxId);
986
1020
  }
1021
+ setWakePreInputFailure(outboxId, proved) {
1022
+ const entry = this.outbox.getById(outboxId);
1023
+ if (!entry || (!proved && !entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG)))
1024
+ return;
1025
+ const tags = (entry.tags ?? []).filter(tag => tag !== WAKE_PRE_INPUT_FAILURE_TAG);
1026
+ if (proved)
1027
+ tags.push(WAKE_PRE_INPUT_FAILURE_TAG);
1028
+ this.db.prepare("UPDATE outbox_entries SET tags = ? WHERE outbox_id = ?").run(JSON.stringify(tags), outboxId);
1029
+ }
987
1030
  async deliverWakeIntent(outboxId, attempted = new Set(), // this pass's attempt history, inherited by any release it delivers
988
1031
  eligible = () => true) {
989
1032
  if (!this.outbox)
@@ -1000,13 +1043,40 @@ export class QueueRepository {
1000
1043
  this.recordNudgeAttempt(alreadyHeld.auditPointer, "retained:typing_guard");
1001
1044
  return "retained";
1002
1045
  }
1003
- let recovering = false;
1004
1046
  const claim = (entry) => {
1005
- if (this.deliveryDrains.holds(entry.destinationSession) || !eligible(entry) || attempted.has(entry.outboxId) || !this.outbox.claimForDelivery(entry.outboxId))
1047
+ if (this.deliveryDrains.holds(entry.destinationSession) || !eligible(entry) || attempted.has(entry.outboxId))
1006
1048
  return false;
1049
+ let rebound;
1050
+ const frozen = entry.guardBinding;
1051
+ if (entry.deliveryState === "failed" && entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG) && frozen?.pane) {
1052
+ const live = this.transport?.deliveryTarget?.(entry.destinationSession);
1053
+ if (!live || live.nodeId !== frozen.nodeId || live.session !== frozen.session
1054
+ || live.occupant !== frozen.occupant || live.pane !== frozen.pane) {
1055
+ const row = entry.auditPointer ? this.getById(entry.auditPointer) : undefined;
1056
+ // A proved-unsent queue notification follows its existing seat's current binding. Startup draining shares
1057
+ // this claim, so check current work and restore custody before consuming the failed attempt's proof.
1058
+ if (!entry.outboxId.startsWith(WAKE_INTENT_PREFIX) || !live?.pane || live.nodeId !== frozen.nodeId
1059
+ || this.outbox.expectedIdentity(entry.outboxId) || !row || row.state !== "pending" || row.handedOffFrom
1060
+ || !this.currentWakeIntent(entry) || !this.reachableWakeRetryable(row, new Date())
1061
+ || [entry.destinationSession, ...this.resolveSessionAddresses(entry.destinationSession), live.session]
1062
+ .some(address => this.hasPendingPostCompactStage?.(address)))
1063
+ return false;
1064
+ rebound = live;
1065
+ }
1066
+ }
1067
+ if (!this.outbox.claimForDelivery(entry.outboxId))
1068
+ return false;
1069
+ if (rebound) {
1070
+ this.db.prepare("UPDATE outbox_entries SET guard_binding = ? WHERE outbox_id = ?").run(JSON.stringify(rebound), entry.outboxId);
1071
+ this.transitionLog.append({
1072
+ qitemId: entry.auditPointer, state: "pending", actorSession: "queue@system",
1073
+ transitionNote: `queue wake binding reconciled ${JSON.stringify({ outboxId: entry.outboxId, from: frozen, to: rebound })}`,
1074
+ });
1075
+ }
1076
+ if (entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG))
1077
+ this.setWakePreInputFailure(entry.outboxId, false);
1007
1078
  this.bindFirstTarget(entry);
1008
1079
  attempted.add(entry.outboxId);
1009
- recovering ||= entry.deliveryState !== "pending";
1010
1080
  return true;
1011
1081
  };
1012
1082
  let superseded = false;
@@ -1071,7 +1141,14 @@ export class QueueRepository {
1071
1141
  }
1072
1142
  const qitemId = intent.auditPointer ?? outboxId;
1073
1143
  // 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" : "";
1144
+ const recoveryNotice = (members) => {
1145
+ const recovered = members.filter(entry => entry.deliveryState !== "pending");
1146
+ if (!recovered.length)
1147
+ return "";
1148
+ return recovered.every(entry => entry.deliveryState === "failed" && entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG))
1149
+ ? "Recovered queue notification: a wake that failed before input is retried once when the current binding is reachable again.\n"
1150
+ : "Recovered queue notification: delivery may repeat after an earlier unconfirmed attempt.\n";
1151
+ };
1075
1152
  // The group was formed on the first member's outcome, so its own source and urgency reach that same outcome at the
1076
1153
  // send; the other members' bodies keep their own frozen urgent lines.
1077
1154
  const trigger = group[0].tags?.includes(WAKE_TRIGGER_OPENRIG_TAG) ? "openrig" : "agent";
@@ -1097,12 +1174,17 @@ export class QueueRepository {
1097
1174
  for (const entry of group) {
1098
1175
  if (keep.includes(entry))
1099
1176
  continue;
1100
- this.db.prepare("UPDATE outbox_entries SET delivery_state = ? WHERE outbox_id = ? AND delivery_state = 'sending'").run(entry.deliveryState, entry.outboxId);
1177
+ this.db.transaction(() => {
1178
+ const restored = this.db.prepare("UPDATE outbox_entries SET delivery_state = ? WHERE outbox_id = ? AND delivery_state = 'sending'").run(entry.deliveryState, entry.outboxId);
1179
+ // This member never reached transport input, so its earlier failed-attempt proof still applies.
1180
+ if (restored.changes && entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG))
1181
+ this.setWakePreInputFailure(entry.outboxId, true);
1182
+ })();
1101
1183
  released.push(entry);
1102
1184
  }
1103
- return { text: recoveryNotice + keep.map(entry => entry.body).join("\n"), outboxIds: keep.map(entry => entry.outboxId) };
1185
+ return { text: recoveryNotice(keep) + keep.map(entry => entry.body).join("\n"), outboxIds: keep.map(entry => entry.outboxId) };
1104
1186
  };
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);
1187
+ const outcome = await this.performWakeSend(qitemId, intent.destinationSession, intent.senderSession, undefined, recoveryNotice(group) + group.map(entry => entry.body).join("\n"), group.map(entry => entry.outboxId), trigger, recheckMembers);
1106
1188
  let reportedState = outcome.classified === "verified" ? "delivered" : outcome.classified;
1107
1189
  for (const intent of group) {
1108
1190
  if (released.includes(intent))
@@ -1122,6 +1204,10 @@ export class QueueRepository {
1122
1204
  const wakeEvent = this.db.transaction(() => {
1123
1205
  this.recordNudgeAttempt(qitemId, nudgeResult);
1124
1206
  this.outbox.finalizeDelivery(intent.outboxId, finalState);
1207
+ // Only a first attempt creates proof: an actual retry consumes it even if it again fails before input.
1208
+ if (intent.deliveryState === "pending" && finalState === "failed" && outcome.preInputFailure === true) {
1209
+ this.setWakePreInputFailure(intent.outboxId, true);
1210
+ }
1125
1211
  // The acceptance (or a ring that may have arrived) belongs to this intent, so recovery can tell this wake already rang.
1126
1212
  if (hostedRingMayHaveArrived(outcome.nudgeResult)) {
1127
1213
  this.db.prepare(`UPDATE outbox_entries SET tags = json_insert(COALESCE(tags, '[]'), '$[#]', ?)
@@ -1241,7 +1327,8 @@ export class QueueRepository {
1241
1327
  JOIN queue_items q ON q.qitem_id = o.audit_pointer AND (q.state = 'pending' OR substr(o.outbox_id, 1, ?) = ?)
1242
1328
  AND q.destination_session = o.destination_session
1243
1329
  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 ?`)
1330
+ AND o.delivery_state IN ('pending','failed','indeterminate')
1331
+ AND json_extract(o.guard_delivery,'$.runner') IS NULL AND json_extract(o.guard_delivery,'$.nativeRequestId') IS NULL ORDER BY o.rowid LIMIT ?`)
1245
1332
  .all(CLAIM_OVERRIDDEN_WAKE_PREFIX.length, CLAIM_OVERRIDDEN_WAKE_PREFIX, cursor, horizon, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, BATCH);
1246
1333
  if (pending.length === 0)
1247
1334
  break;
@@ -1355,7 +1442,7 @@ export class QueueRepository {
1355
1442
  const current = this.getById(entry.auditPointer), refusal = current?.lastNudgeWireResult;
1356
1443
  const notice = entry.outboxId.startsWith(CLAIM_OVERRIDDEN_WAKE_PREFIX);
1357
1444
  return (current?.state === "pending" || notice) && addresses.includes(current?.destinationSession ?? "")
1358
- && (refusal === "failed:target_needs_input" || (refusal?.startsWith("failed:Refused:") === true && refusal.includes("interactive prompt")));
1445
+ && isPromptOwnedWakeRefusal(refusal);
1359
1446
  };
1360
1447
  const seats = addresses.map(() => "?").join(",");
1361
1448
  const refused = (q) => `(${q}last_nudge_result LIKE 'failed:Refused:%interactive prompt%' OR ${q}last_nudge_result = 'failed:target_needs_input')`;
@@ -1405,16 +1492,18 @@ export class QueueRepository {
1405
1492
  * gateway, not held or released for quiet hours, and its seat now pane-bound. A handoff's retry ladder is the
1406
1493
  * caller's to check: the sweep defers to a live ladder, the reachable-seat retry leaves every handed-off row to it. */
1407
1494
  unroutableWakeRetryable(row, now = new Date()) {
1408
- return recordsNoWakeRoute(row.lastNudgeResult)
1409
- && !row.claimedAt
1495
+ return recordsNoWakeRoute(row.lastNudgeResult) && this.reachableWakeRetryable(row, now);
1496
+ }
1497
+ reachableWakeRetryable(row, now) {
1498
+ return !row.claimedAt
1499
+ && !isPromptOwnedWakeRefusal(row.lastNudgeResult)
1410
1500
  && row.deliveryOutcome !== "never-posted" && row.deliveryOutcome !== "transport-failed"
1411
1501
  && !this.isLocalHumanDecisionWithoutGateway(row)
1412
1502
  && !["held", "released"].includes(quietHoldCustody(this.db, row.qitemId, now)?.state ?? "")
1413
1503
  && this.classifyDestinationOf(row.destinationSession).class === "pane-bound";
1414
1504
  }
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. */
1505
+ /** Re-send an unroutable wake, or the same failed intent with typed proof that its latest attempt never reached input,
1506
+ * when its seat returns running/idle. Unknown delivery stays unknown; deliberate quiet and compaction keep custody. */
1418
1507
  async retryUnroutableWakesOnReachable(sessionName, state) {
1419
1508
  if (state !== "running" && state !== "idle")
1420
1509
  return;
@@ -1426,11 +1515,16 @@ export class QueueRepository {
1426
1515
  // As for a prompt clear (#2575): while a compaction's restore is owed, the wake would reach the agent before it.
1427
1516
  if ([sessionName, ...addresses].some(address => this.hasPendingPostCompactStage?.(address)))
1428
1517
  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);
1518
+ const provedFailure = this.outbox ? `OR EXISTS (
1519
+ SELECT 1 FROM outbox_entries o WHERE o.audit_pointer = q.qitem_id
1520
+ AND substr(o.outbox_id, 1, ?) = ? AND o.delivery_state = 'failed'
1521
+ AND EXISTS (SELECT 1 FROM json_each(o.tags) WHERE value = ?)
1522
+ )` : "";
1523
+ const rows = this.db.prepare(`SELECT q.qitem_id FROM queue_items q
1524
+ WHERE q.destination_session IN (${addresses.map(() => "?").join(",")}) AND q.state = 'pending'
1525
+ AND q.handed_off_from IS NULL AND (q.last_nudge_result LIKE 'unroutable:%' OR q.last_nudge_result LIKE 'awaiting-pickup:%' ${provedFailure})
1526
+ ORDER BY q.ts_created, q.qitem_id`)
1527
+ .all(...addresses, ...(this.outbox ? [WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX, WAKE_PRE_INPUT_FAILURE_TAG] : []));
1434
1528
  const now = new Date();
1435
1529
  // One attempt per intent for the pass: a returned result and its resume go as one send, so the second row's turn
1436
1530
  // mustn't send them again after a refusal.
@@ -1441,13 +1535,17 @@ export class QueueRepository {
1441
1535
  const eligible = (entry) => {
1442
1536
  if (entry.deliveryState !== "failed" || !entry.auditPointer)
1443
1537
  return false;
1538
+ // An earlier member's awaited send may have started restore custody before this claim.
1539
+ if ([sessionName, ...addresses].some(address => this.hasPendingPostCompactStage?.(address)))
1540
+ return false;
1444
1541
  const current = this.getById(entry.auditPointer);
1445
1542
  return current?.state === "pending" && addresses.includes(current.destinationSession) && !current.handedOffFrom
1446
- && this.unroutableWakeRetryable(current, now);
1543
+ && this.reachableWakeRetryable(current, now)
1544
+ && (this.unroutableWakeRetryable(current, now) || entry.tags?.includes(WAKE_PRE_INPUT_FAILURE_TAG) === true);
1447
1545
  };
1448
1546
  for (const { qitem_id } of rows) {
1449
1547
  const row = this.getById(qitem_id);
1450
- if (!row || row.state !== "pending" || !this.unroutableWakeRetryable(row, now))
1548
+ if (!row || row.state !== "pending" || !this.reachableWakeRetryable(row, now))
1451
1549
  continue;
1452
1550
  // The failed wake may be the row's own intent or an un-park's blocker intent: re-send whichever failed.
1453
1551
  // One in flight or delivered is never sent again; only a row with no intent at all takes the plain nudge.
@@ -1459,7 +1557,7 @@ export class QueueRepository {
1459
1557
  if (intent.delivery_state === "failed")
1460
1558
  await this.deliverWakeIntent(intent.outbox_id, attempted, eligible);
1461
1559
  }
1462
- else
1560
+ else if (this.unroutableWakeRetryable(row, now))
1463
1561
  await this.maybeNudge(qitem_id, row.destinationSession, undefined, row.sourceSession);
1464
1562
  }
1465
1563
  }
@@ -1894,6 +1992,8 @@ export class QueueRepository {
1894
1992
  if (humanQuestions) {
1895
1993
  this.db.prepare("UPDATE queue_items SET human_questions = ? WHERE qitem_id = ?").run(JSON.stringify(humanQuestions), id);
1896
1994
  }
1995
+ const replaced = input.returnRoute == null && handedOffFrom ? this.getById(handedOffFrom) : null;
1996
+ this.persistReturnRoute(id, input.returnRoute ?? replaced?.returnRoute ?? null, input.returnRoute ? input.returnRouteBasis ?? null : replaced?.returnRouteBasis ?? null);
1897
1997
  this.persistMintingGeneration(id, input.sourceSession);
1898
1998
  const notification = this.classifyOwnerNotification({
1899
1999
  action: "create",
@@ -1963,6 +2063,8 @@ export class QueueRepository {
1963
2063
  return true;
1964
2064
  }
1965
2065
  isPersonAddress(destination) {
2066
+ if (!destination.includes("@"))
2067
+ return false;
1966
2068
  if (isHumanSeatSessionRef(destination))
1967
2069
  return true;
1968
2070
  const registry = this.loadHumanRegistryFn();
@@ -2107,6 +2209,8 @@ export class QueueRepository {
2107
2209
  }
2108
2210
  this.persistSummary(newId, input.summary ?? null);
2109
2211
  this.persistEvidenceRef(newId, input.evidenceRef ?? null);
2212
+ // The goal's return route goes with the work, as its body does.
2213
+ this.persistReturnRoute(newId, source.returnRoute ?? null, source.returnRouteBasis ?? null);
2110
2214
  this.persistMintingGeneration(newId, input.fromSession);
2111
2215
  const carried = this.carryPermissionQuestion(source, newId, input.toSession);
2112
2216
  const successorNotification = this.classifyOwnerNotification({
@@ -2263,6 +2367,8 @@ export class QueueRepository {
2263
2367
  }
2264
2368
  this.persistSummary(newId, input.summary ?? null);
2265
2369
  this.persistEvidenceRef(newId, input.evidenceRef ?? null);
2370
+ // The goal's return route goes with the work, as its body does.
2371
+ this.persistReturnRoute(newId, source.returnRoute ?? null, source.returnRouteBasis ?? null);
2266
2372
  this.persistMintingGeneration(newId, input.fromSession);
2267
2373
  const carried = this.carryPermissionQuestion(source, newId, input.toSession);
2268
2374
  const successorNotification = this.classifyOwnerNotification({
@@ -2558,6 +2664,7 @@ export class QueueRepository {
2558
2664
  identityProvenance: input.identityProvenance ?? null, // P21 §4 era-stamp
2559
2665
  identityPrincipal: input.identityPrincipal ?? null,
2560
2666
  });
2667
+ this.recordRelayPickup(qitem, input.destinationSession);
2561
2668
  // OPR.0.5.8.1 S1b — CLAIM-RESUME. A blocked row is claimable ("only
2562
2669
  // pending/blocked are claimable"), so claiming is a real exit from a park
2563
2670
  // and it writes state directly rather than through update(). This is the
@@ -2663,6 +2770,50 @@ export class QueueRepository {
2663
2770
  const result = this.updateInTransactionalContext(input);
2664
2771
  return { qitemId: input.qitemId, ...result };
2665
2772
  }
2773
+ /**
2774
+ * Add tags to a row in any state, and change nothing else: its existing tags stay, its state, claim and closure are
2775
+ * untouched, and a closed row isn't reopened. A tag the row already has adds nothing. The tags added are recorded as a
2776
+ * transition naming the actor, like a note; when every tag is already there, nothing is written. Tags are never
2777
+ * removed or rewritten here.
2778
+ */
2779
+ addTags(input) {
2780
+ const txn = this.db.transaction(() => {
2781
+ const qitem = this.getById(input.qitemId);
2782
+ if (!qitem)
2783
+ throw new QueueRepositoryError("qitem_not_found", `qitem ${input.qitemId} not found`);
2784
+ const existing = qitem.tags ?? [];
2785
+ const added = [...new Set(input.tags)].filter((tag) => !existing.includes(tag));
2786
+ if (added.length === 0)
2787
+ return { added, persistedEvents: [] };
2788
+ this.db.prepare("UPDATE queue_items SET tags = ? WHERE qitem_id = ?").run(JSON.stringify([...existing, ...added]), input.qitemId);
2789
+ this.transitionLog.append({
2790
+ qitemId: input.qitemId,
2791
+ state: qitem.state,
2792
+ actorSession: input.actorSession,
2793
+ // The values as a JSON array, so a tag holding a comma reads apart from two tags.
2794
+ transitionNote: `tags added: ${JSON.stringify(added)}`,
2795
+ // Like a note append, this keeps a claim's retained park gate for a later state write to end.
2796
+ closureTarget: qitem.state === "in-progress" ? this.retainedClaimBlocker(input.qitemId) : undefined,
2797
+ identityProvenance: input.identityProvenance ?? null,
2798
+ identityPrincipal: input.identityPrincipal ?? null,
2799
+ });
2800
+ const persistedEvent = this.eventBus.persistWithinTransaction({
2801
+ type: "queue.updated",
2802
+ qitemId: input.qitemId,
2803
+ fromState: qitem.state,
2804
+ toState: qitem.state,
2805
+ closureReason: null,
2806
+ closureTarget: null,
2807
+ actorSession: input.actorSession,
2808
+ summary: qitem.summary ?? null,
2809
+ });
2810
+ return { added, persistedEvents: [persistedEvent] };
2811
+ });
2812
+ const result = txn();
2813
+ for (const event of result.persistedEvents)
2814
+ this.eventBus.notifySubscribers(event);
2815
+ return { item: this.getByIdOrThrow(input.qitemId), added: result.added };
2816
+ }
2666
2817
  /** Notify subscribers of events persisted inside a caller's own transaction (updateWithinTransaction), after it commits. */
2667
2818
  notifyCommitted(events) {
2668
2819
  for (const event of events)
@@ -2986,7 +3137,8 @@ export class QueueRepository {
2986
3137
  jobsRepo.recordEvaluation(job.jobId, job.registeredAt, false);
2987
3138
  parkWake = { kind: "timer", ref: job.jobId };
2988
3139
  }
2989
- else if (input.state === "blocked" && effectiveBlockedOn?.startsWith("qitem-")) {
3140
+ else if (input.state === "blocked" && effectiveBlockedOn && effectiveBlockedOn !== input.qitemId && !isHumanPark && !isTypedGateBlocker(effectiveBlockedOn)
3141
+ && (effectiveBlockedOn.startsWith("qitem-") || isBlockerLive(this.getById(effectiveBlockedOn)?.state ?? ""))) {
2990
3142
  parkWake = { kind: "blocker", ref: effectiveBlockedOn };
2991
3143
  }
2992
3144
  const ts = new Date().toISOString();
@@ -3161,6 +3313,9 @@ export class QueueRepository {
3161
3313
  const blockedRows = this.db
3162
3314
  .prepare("SELECT qitem_id, destination_session FROM queue_items WHERE blocked_on = ? AND state = 'blocked'")
3163
3315
  .all(input.qitemId);
3316
+ // Typed gates and people own their own resolution even when a custom row ID collides.
3317
+ if (blockedRows.length === 0 || isTypedGateBlocker(input.qitemId) || this.isPersonAddress(input.qitemId))
3318
+ return dependentEvents;
3164
3319
  for (const r of blockedRows) {
3165
3320
  const closed = this.getById(input.qitemId);
3166
3321
  const successors = input.terminalState === "handed-off" ? this.db.prepare("SELECT qitem_id FROM queue_items WHERE handed_off_from = ? AND destination_session = ?").all(input.qitemId, closed?.handedOffTo ?? "") : [];
@@ -3273,7 +3428,7 @@ export class QueueRepository {
3273
3428
  /** Read-only scope-aware RECENT projection. Normalization and its hard cap
3274
3429
  * live with the append-only transition log; the repository owns the public
3275
3430
  * queue-domain door. */
3276
- listRecentTransitions(scope, limit = 20) {
3431
+ listRecentTransitions(scope, limit = DEFAULT_RECENT_TRANSITIONS_LIMIT) {
3277
3432
  return this.transitionLog.listRecent(typeof scope === "string" ? { kind: "rig", rig: scope } : scope, limit);
3278
3433
  }
3279
3434
  /** The parked row an ordinary due park timer reminds about, when its reminder may share one message with other
@@ -3645,6 +3800,15 @@ export class QueueRepository {
3645
3800
  if (!question?.options.some((o) => o.id === input.optionId))
3646
3801
  return { status: "not-applicable", reason: "unknown-option" };
3647
3802
  const recorded = item.humanAnswers ?? {};
3803
+ // A retained click fills a missing answer; it never replaces a committed choice in this ask or park.
3804
+ // A previous park's saved values do not count as answers to the current park.
3805
+ const recordedInCurrentPark = episodeKey && this.transitionLog.listForQitem(item.qitemId).some((transition) => transition.transitionId > Number(episodeKey.slice(episodeKey.lastIndexOf(":") + 1))
3806
+ && transition.transitionNote === `human-answer-recorded: ${JSON.stringify({ questionId: input.questionId, optionId: recorded[input.questionId] })}`);
3807
+ if (input.onlyIfUnanswered && Object.prototype.hasOwnProperty.call(recorded, input.questionId)
3808
+ && (item.state === "pending" || recordedInCurrentPark)) {
3809
+ return { status: "recorded", answers: recorded,
3810
+ complete: unansweredQuestions(item.humanQuestions, recorded).length === 0, questions: item.humanQuestions };
3811
+ }
3648
3812
  // A park's set is final once this park has its answer: until then a complete set is an earlier park's, and a click
3649
3813
  // on the re-park records over it.
3650
3814
  if (unansweredQuestions(item.humanQuestions, recorded).length === 0
@@ -3652,9 +3816,13 @@ export class QueueRepository {
3652
3816
  return { status: "recorded", answers: recorded, complete: true, questions: item.humanQuestions };
3653
3817
  }
3654
3818
  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
3819
  const complete = unansweredQuestions(item.humanQuestions, answers).length === 0;
3657
- if (item.humanAnswers?.[input.questionId] !== input.optionId) {
3820
+ if (item.humanAnswers?.[input.questionId] !== input.optionId || (episodeKey && !recordedInCurrentPark)) {
3821
+ const transition = this.transitionLog.append({ qitemId: input.qitemId, state: item.state, actorSession: input.actorSession,
3822
+ transitionNote: `human-answer-recorded: ${JSON.stringify({ questionId: input.questionId, optionId: input.optionId })}`,
3823
+ identityProvenance: input.identityProvenance, identityPrincipal: input.identityPrincipal });
3824
+ this.db.prepare("UPDATE queue_items SET human_answers = ?, ts_updated = ? WHERE qitem_id = ?")
3825
+ .run(JSON.stringify(answers), transition.ts, input.qitemId);
3658
3826
  changed = { summary: item.summary ?? null, answered: item.humanQuestions.length - unansweredQuestions(item.humanQuestions, answers).length };
3659
3827
  }
3660
3828
  return { status: "recorded", answers, complete, questions: item.humanQuestions };
@@ -3987,13 +4155,22 @@ export class QueueRepository {
3987
4155
  return null;
3988
4156
  }
3989
4157
  /** 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. */
4158
+ * projections list() derives (pickup, waiting view, delivery ledger), which this read never uses. A wake escalation
4159
+ * about this seat's own prompt that nobody holds is left out: with no operator seat to carry it, the alert falls back
4160
+ * to the seat itself, and the escalation is the wake, not the content, so it is never that seat's work. One its owner
4161
+ * explicitly holds (blocked) stays, so that hold and its wake are diagnosed as before; so does a row whose tags aren't
4162
+ * a JSON array. */
3991
4163
  listOpenObligations(destinationSession, limit) {
3992
4164
  const addresses = this.resolveSessionAddresses(destinationSession);
3993
4165
  const slots = addresses.map(() => "?").join(",");
4166
+ const ownPrompt = addresses.flatMap((address) => [`prompt-destination:${address}`, `consumed-prompt-destination:${address}`]);
3994
4167
  const rows = this.db.prepare(`SELECT qitem_id, state${this.hasSummaryColumn ? ", summary" : ""} FROM queue_items
3995
4168
  WHERE destination_session IN (${slots}) AND state IN ('pending', 'in-progress', 'blocked')
3996
- ORDER BY ts_created DESC LIMIT ?`).all(...addresses, limit);
4169
+ AND NOT CASE WHEN state != 'blocked' AND json_valid(tags) THEN CASE WHEN json_type(tags) = 'array' THEN
4170
+ EXISTS (SELECT 1 FROM json_each(queue_items.tags) WHERE value = ?)
4171
+ AND EXISTS (SELECT 1 FROM json_each(queue_items.tags) WHERE value IN (${ownPrompt.map(() => "?").join(",")}))
4172
+ ELSE 0 END ELSE 0 END
4173
+ ORDER BY ts_created DESC LIMIT ?`).all(...addresses, WAKE_ESCALATION_TAG, ...ownPrompt, limit);
3997
4174
  return rows.map((r) => ({ qitemId: r.qitem_id, state: r.state, summary: r.summary ?? null }));
3998
4175
  }
3999
4176
  list(opts) {
@@ -4210,9 +4387,11 @@ export class QueueRepository {
4210
4387
  const rows = this.db.prepare(sql).all(...params);
4211
4388
  return rows.map((r) => this.rowToItem(r));
4212
4389
  }
4213
- /** The compact listings' columns: the shared set plus the summary, which is short and is what people search for. */
4390
+ /** The compact listings' columns: the shared set plus the summary, which is short and is what people search for, and a
4391
+ * routed row's return route, which isn't elided, so a routed row never lists as unrouted. */
4214
4392
  compactColumns() {
4215
- return COMPACT_QUEUE_COLUMNS + (this.hasSummaryColumn ? ", summary" : "") + (this.hasHumanIntentColumn ? ", human_intent" : "");
4393
+ return COMPACT_QUEUE_COLUMNS + (this.hasSummaryColumn ? ", summary" : "") + (this.hasHumanIntentColumn ? ", human_intent" : "")
4394
+ + (this.hasReturnRouteColumn ? ", return_route, return_route_basis" : "");
4216
4395
  }
4217
4396
  findOverdue(opts) {
4218
4397
  const cutoff = opts?.now ?? new Date().toISOString();
@@ -4787,8 +4966,7 @@ export class QueueRepository {
4787
4966
  .run(ts, result, qitemId);
4788
4967
  // The transport's definite no-write refusal establishes the episode even when a
4789
4968
  // 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")))) {
4969
+ if (!this.promptClearRetries.has(qitemId) && isPromptOwnedWakeRefusal(result)) {
4792
4970
  const row = this.getById(qitemId);
4793
4971
  if (row?.state === "pending")
4794
4972
  this.promptRecoveryState.set(row.destinationSession, true);
@@ -4946,6 +5124,32 @@ export class QueueRepository {
4946
5124
  this.db.prepare("UPDATE queue_items SET evidence_ref = ? WHERE qitem_id = ?").run(evidenceRef, qitemId);
4947
5125
  }
4948
5126
  }
5127
+ /** A relay task's claim is pickup at its return route. It's recorded on the escalation the task carries, keyed by that
5128
+ * delivery episode, so the episode resolves. Pickup only: not the person's answer or approval, and nothing about the
5129
+ * seat's prompt. */
5130
+ recordRelayPickup(relay, actor) {
5131
+ if (!relay.tags?.includes(RELAY_TAG))
5132
+ return;
5133
+ const escalationId = relay.tags.find(t => t.startsWith(RELAY_FOR_PREFIX))?.slice(RELAY_FOR_PREFIX.length);
5134
+ const key = relay.tags.find(t => t.startsWith(RELAY_KEY_PREFIX))?.slice(RELAY_KEY_PREFIX.length);
5135
+ // Only the episode's own relay (its id, OpenRig as source, its tags) records pickup; a row that only carries the tags doesn't.
5136
+ if (!escalationId || !key || !isEpisodeRelay(relay, escalationId, key, OPENRIG_SENDER))
5137
+ return;
5138
+ const escalation = this.getById(escalationId);
5139
+ if (!escalation)
5140
+ return;
5141
+ this.transitionLog.append({
5142
+ qitemId: escalation.qitemId, state: escalation.state, actorSession: "wake-ladder@system",
5143
+ transitionNote: `${RELAY_CLAIMED_PREFIX} notification_key=${key} relay=${relay.qitemId} by=${actor}: picked up at the return route; not the person's answer or approval`,
5144
+ closureTarget: escalation.state === "in-progress" ? this.retainedClaimBlocker(escalation.qitemId) : undefined,
5145
+ });
5146
+ }
5147
+ /** A row's return route (return-route.ts), when it has one; a schema without the column keeps the row without it. */
5148
+ persistReturnRoute(qitemId, route, basis) {
5149
+ if (!this.hasReturnRouteColumn || !route)
5150
+ return;
5151
+ this.db.prepare("UPDATE queue_items SET return_route = ?, return_route_basis = ? WHERE qitem_id = ?").run(route, basis, qitemId);
5152
+ }
4949
5153
  /** GHOST-STAGE (e/Class-B) — persist the MINTING occupant-generation additively (same degrade
4950
5154
  * contract as persistSummary; NULL when unresolved/pre-063). Forensic provenance of the creator;
4951
5155
  * the RELEASE discriminator is claimed_by_generation_uuid (stamped at claim), not this. */
@@ -5232,6 +5436,7 @@ export class QueueRepository {
5232
5436
  // older test fixtures supply legacy rows where target_repo is undefined.
5233
5437
  targetRepo: row.target_repo ?? null,
5234
5438
  ...(row.content_erased_at ? { contentErasedAt: row.content_erased_at } : {}),
5439
+ ...(row.return_route ? { returnRoute: row.return_route, returnRouteBasis: row.return_route_basis ?? null } : {}),
5235
5440
  };
5236
5441
  }
5237
5442
  }