@openrig/cli 0.7.24 → 0.7.26

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 (1037) hide show
  1. package/README.md +7 -7
  2. package/daemon/assets/claude-hook-bridge.cjs +151 -37
  3. package/daemon/assets/claude-hook-bridge.d.cts +9 -2
  4. package/daemon/assets/claude-permission-policies.cjs +22 -1
  5. package/daemon/assets/claude-permission-policies.d.cts +2 -0
  6. package/daemon/assets/claude-statusline-context.cjs +14 -0
  7. package/daemon/assets/claude-team-permissions.cjs +54 -6
  8. package/daemon/assets/guidance/openrig-context-entry.md +4 -5
  9. package/daemon/assets/guidance/openrig-start.md +3 -0
  10. package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +2 -2
  11. package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +1 -1
  12. package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
  13. package/daemon/assets/plugins/openrig/README.md +33 -18
  14. package/daemon/assets/plugins/openrig/hooks/scripts/claude-hook-bridge.cjs +151 -37
  15. package/daemon/assets/plugins/openrig/plugin.json +1 -1
  16. package/daemon/assets/plugins/openrig/scripts/run-rig.cjs +16 -13
  17. package/daemon/assets/plugins/openrig/skills/working-with-an-openrig-team/SKILL.md +32 -19
  18. package/daemon/assets/plugins/openrig-codex/.codex-plugin/plugin.json +1 -1
  19. package/daemon/assets/plugins/openrig-codex/hooks/scripts/claude-hook-bridge.cjs +151 -37
  20. package/daemon/assets/plugins/openrig-codex/skills/working-with-an-openrig-team/SKILL.md +32 -19
  21. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  22. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  23. package/daemon/assets/plugins/openrig-core/hooks/scripts/permission-answer.cjs +3 -2
  24. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +47 -14
  25. package/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore/SKILL.md +5 -2
  26. package/daemon/assets/skills/rigs/SKILL.md +99 -34
  27. package/daemon/assets/skills/rigs/references/installing-for-someone.md +1 -1
  28. package/daemon/context-packs/help/help.md +9 -0
  29. package/daemon/context-packs/help/manifest.yaml +1 -1
  30. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  31. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +179 -25
  32. package/daemon/context-packs/reference/getting-started.md +73 -11
  33. package/daemon/context-packs/reference/manifest.yaml +1 -1
  34. package/daemon/context-packs/reference/rig-spec.md +218 -23
  35. package/daemon/context-packs/reference/whats-new.md +190 -14
  36. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/cross-host-rig-commands/SKILL.md +9 -1
  43. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/core/working-with-an-openrig-team/SKILL.md +32 -19
  59. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/openrig-user/SKILL.md +47 -14
  66. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  76. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  77. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  78. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  79. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  80. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  81. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  82. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  83. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  84. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  85. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  86. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  87. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  88. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  89. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  90. package/daemon/context-packs/skills/session-compaction-and-restore/SKILL.md +5 -2
  91. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  92. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  93. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  94. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  95. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  96. package/daemon/dist/adapters/claude-code-adapter.js +25 -8
  97. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  98. package/daemon/dist/adapters/claude-resume.d.ts +2 -0
  99. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  100. package/daemon/dist/adapters/claude-resume.js +44 -8
  101. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  102. package/daemon/dist/adapters/codex-resume.d.ts +3 -0
  103. package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
  104. package/daemon/dist/adapters/codex-resume.js +7 -3
  105. package/daemon/dist/adapters/codex-resume.js.map +1 -1
  106. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +49 -4
  107. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  108. package/daemon/dist/adapters/codex-runtime-adapter.js +238 -25
  109. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  110. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +12 -5
  111. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
  112. package/daemon/dist/adapters/community-harness-runtime-adapter.js +15 -5
  113. package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
  114. package/daemon/dist/adapters/kernel-authority.d.ts +2 -2
  115. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  116. package/daemon/dist/adapters/kernel-authority.js +5 -3
  117. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  118. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  119. package/daemon/dist/adapters/pi-runner.js +9 -0
  120. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  121. package/daemon/dist/adapters/pi-session-cwd.d.ts +26 -0
  122. package/daemon/dist/adapters/pi-session-cwd.d.ts.map +1 -0
  123. package/daemon/dist/adapters/pi-session-cwd.js +89 -0
  124. package/daemon/dist/adapters/pi-session-cwd.js.map +1 -0
  125. package/daemon/dist/adapters/shell-quote.d.ts +2 -0
  126. package/daemon/dist/adapters/shell-quote.d.ts.map +1 -1
  127. package/daemon/dist/adapters/shell-quote.js +43 -0
  128. package/daemon/dist/adapters/shell-quote.js.map +1 -1
  129. package/daemon/dist/adapters/tmux-credential-env.d.ts +15 -2
  130. package/daemon/dist/adapters/tmux-credential-env.d.ts.map +1 -1
  131. package/daemon/dist/adapters/tmux-credential-env.js +82 -2
  132. package/daemon/dist/adapters/tmux-credential-env.js.map +1 -1
  133. package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
  134. package/daemon/dist/adapters/tmux-exec.js +2 -6
  135. package/daemon/dist/adapters/tmux-exec.js.map +1 -1
  136. package/daemon/dist/adapters/tmux.d.ts +31 -1
  137. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  138. package/daemon/dist/adapters/tmux.js +104 -8
  139. package/daemon/dist/adapters/tmux.js.map +1 -1
  140. package/daemon/dist/attention-surface.d.ts +5 -0
  141. package/daemon/dist/attention-surface.d.ts.map +1 -1
  142. package/daemon/dist/attention-surface.js.map +1 -1
  143. package/daemon/dist/bind-plan-surface.d.ts +3 -0
  144. package/daemon/dist/bind-plan-surface.d.ts.map +1 -0
  145. package/daemon/dist/bind-plan-surface.js +5 -0
  146. package/daemon/dist/bind-plan-surface.js.map +1 -0
  147. package/daemon/dist/build-info.js +3 -3
  148. package/daemon/dist/db/all-migrations.d.ts +4 -1
  149. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  150. package/daemon/dist/db/all-migrations.js +30 -393
  151. package/daemon/dist/db/all-migrations.js.map +1 -1
  152. package/daemon/dist/db/migrations/187_provider_account_refs.d.ts +8 -0
  153. package/daemon/dist/db/migrations/187_provider_account_refs.d.ts.map +1 -0
  154. package/daemon/dist/db/migrations/187_provider_account_refs.js +25 -0
  155. package/daemon/dist/db/migrations/187_provider_account_refs.js.map +1 -0
  156. package/daemon/dist/db/migrations/188_provider_account_assignments.d.ts +14 -0
  157. package/daemon/dist/db/migrations/188_provider_account_assignments.d.ts.map +1 -0
  158. package/daemon/dist/db/migrations/188_provider_account_assignments.js +45 -0
  159. package/daemon/dist/db/migrations/188_provider_account_assignments.js.map +1 -0
  160. package/daemon/dist/db/migrations/191_queue_transfer_activation.d.ts +3 -0
  161. package/daemon/dist/db/migrations/191_queue_transfer_activation.d.ts.map +1 -0
  162. package/daemon/dist/db/migrations/191_queue_transfer_activation.js +49 -0
  163. package/daemon/dist/db/migrations/191_queue_transfer_activation.js.map +1 -0
  164. package/daemon/dist/db/migrations/191_seat_reap_state.d.ts +3 -0
  165. package/daemon/dist/db/migrations/191_seat_reap_state.d.ts.map +1 -0
  166. package/daemon/dist/db/migrations/191_seat_reap_state.js +19 -0
  167. package/daemon/dist/db/migrations/191_seat_reap_state.js.map +1 -0
  168. package/daemon/dist/db/migrations/197_session_agent_activity_hooks.d.ts +3 -0
  169. package/daemon/dist/db/migrations/197_session_agent_activity_hooks.d.ts.map +1 -0
  170. package/daemon/dist/db/migrations/197_session_agent_activity_hooks.js +9 -0
  171. package/daemon/dist/db/migrations/197_session_agent_activity_hooks.js.map +1 -0
  172. package/daemon/dist/db/migrations/200_context_configured_budget.d.ts +3 -0
  173. package/daemon/dist/db/migrations/200_context_configured_budget.d.ts.map +1 -0
  174. package/daemon/dist/db/migrations/200_context_configured_budget.js +5 -0
  175. package/daemon/dist/db/migrations/200_context_configured_budget.js.map +1 -0
  176. package/daemon/dist/db/migrations/200_seat_cold_start_standby_stop.d.ts +3 -0
  177. package/daemon/dist/db/migrations/200_seat_cold_start_standby_stop.d.ts.map +1 -0
  178. package/daemon/dist/db/migrations/200_seat_cold_start_standby_stop.js +5 -0
  179. package/daemon/dist/db/migrations/200_seat_cold_start_standby_stop.js.map +1 -0
  180. package/daemon/dist/db/migrations/200_sessions_earlier_handover_origin.d.ts +11 -0
  181. package/daemon/dist/db/migrations/200_sessions_earlier_handover_origin.d.ts.map +1 -0
  182. package/daemon/dist/db/migrations/200_sessions_earlier_handover_origin.js +34 -0
  183. package/daemon/dist/db/migrations/200_sessions_earlier_handover_origin.js.map +1 -0
  184. package/daemon/dist/db/migrations/201_queue_transitions_archive_actor_index.d.ts +7 -0
  185. package/daemon/dist/db/migrations/201_queue_transitions_archive_actor_index.d.ts.map +1 -0
  186. package/daemon/dist/db/migrations/201_queue_transitions_archive_actor_index.js +12 -0
  187. package/daemon/dist/db/migrations/201_queue_transitions_archive_actor_index.js.map +1 -0
  188. package/daemon/dist/db/migrations/201_roster_event_index.d.ts +4 -0
  189. package/daemon/dist/db/migrations/201_roster_event_index.d.ts.map +1 -0
  190. package/daemon/dist/db/migrations/201_roster_event_index.js +9 -0
  191. package/daemon/dist/db/migrations/201_roster_event_index.js.map +1 -0
  192. package/daemon/dist/db/migrations/202_network_requester_questions.d.ts +4 -0
  193. package/daemon/dist/db/migrations/202_network_requester_questions.d.ts.map +1 -0
  194. package/daemon/dist/db/migrations/202_network_requester_questions.js +10 -0
  195. package/daemon/dist/db/migrations/202_network_requester_questions.js.map +1 -0
  196. package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.d.ts +3 -0
  197. package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.d.ts.map +1 -0
  198. package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.js +22 -0
  199. package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.js.map +1 -0
  200. package/daemon/dist/domain/activity-taxonomy.d.ts +16 -5
  201. package/daemon/dist/domain/activity-taxonomy.d.ts.map +1 -1
  202. package/daemon/dist/domain/activity-taxonomy.js +30 -5
  203. package/daemon/dist/domain/activity-taxonomy.js.map +1 -1
  204. package/daemon/dist/domain/agent-activity-store.d.ts +4 -0
  205. package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
  206. package/daemon/dist/domain/agent-activity-store.js +21 -0
  207. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  208. package/daemon/dist/domain/agent-images/agent-image-destination.d.ts +15 -0
  209. package/daemon/dist/domain/agent-images/agent-image-destination.d.ts.map +1 -0
  210. package/daemon/dist/domain/agent-images/agent-image-destination.js +79 -0
  211. package/daemon/dist/domain/agent-images/agent-image-destination.js.map +1 -0
  212. package/daemon/dist/domain/agent-images/agent-image-library-service.d.ts.map +1 -1
  213. package/daemon/dist/domain/agent-images/agent-image-library-service.js +9 -1
  214. package/daemon/dist/domain/agent-images/agent-image-library-service.js.map +1 -1
  215. package/daemon/dist/domain/bootstrap-orchestrator.d.ts +4 -3
  216. package/daemon/dist/domain/bootstrap-orchestrator.d.ts.map +1 -1
  217. package/daemon/dist/domain/bootstrap-orchestrator.js +55 -11
  218. package/daemon/dist/domain/bootstrap-orchestrator.js.map +1 -1
  219. package/daemon/dist/domain/bundle-content-routing.d.ts +7 -0
  220. package/daemon/dist/domain/bundle-content-routing.d.ts.map +1 -1
  221. package/daemon/dist/domain/bundle-content-routing.js +20 -15
  222. package/daemon/dist/domain/bundle-content-routing.js.map +1 -1
  223. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +40 -1
  224. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  225. package/daemon/dist/domain/claude-compaction-enforcer.js +101 -11
  226. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  227. package/daemon/dist/domain/claude-continuation-launch.d.ts +19 -2
  228. package/daemon/dist/domain/claude-continuation-launch.d.ts.map +1 -1
  229. package/daemon/dist/domain/claude-continuation-launch.js +143 -3
  230. package/daemon/dist/domain/claude-continuation-launch.js.map +1 -1
  231. package/daemon/dist/domain/claude-managed-launch.d.ts +22 -5
  232. package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
  233. package/daemon/dist/domain/claude-managed-launch.js +41 -5
  234. package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
  235. package/daemon/dist/domain/claude-permission-rules.d.ts +3 -1
  236. package/daemon/dist/domain/claude-permission-rules.d.ts.map +1 -1
  237. package/daemon/dist/domain/claude-permission-rules.js +8 -7
  238. package/daemon/dist/domain/claude-permission-rules.js.map +1 -1
  239. package/daemon/dist/domain/claude-seat-token.d.ts +25 -1
  240. package/daemon/dist/domain/claude-seat-token.d.ts.map +1 -1
  241. package/daemon/dist/domain/claude-seat-token.js +56 -9
  242. package/daemon/dist/domain/claude-seat-token.js.map +1 -1
  243. package/daemon/dist/domain/codex-auth.d.ts +34 -0
  244. package/daemon/dist/domain/codex-auth.d.ts.map +1 -1
  245. package/daemon/dist/domain/codex-auth.js +212 -0
  246. package/daemon/dist/domain/codex-auth.js.map +1 -1
  247. package/daemon/dist/domain/codex-member-permissions.d.ts +17 -0
  248. package/daemon/dist/domain/codex-member-permissions.d.ts.map +1 -1
  249. package/daemon/dist/domain/codex-member-permissions.js +80 -0
  250. package/daemon/dist/domain/codex-member-permissions.js.map +1 -1
  251. package/daemon/dist/domain/community-harness-launch-result.d.ts +9 -0
  252. package/daemon/dist/domain/community-harness-launch-result.d.ts.map +1 -1
  253. package/daemon/dist/domain/community-harness-launch-result.js +14 -2
  254. package/daemon/dist/domain/community-harness-launch-result.js.map +1 -1
  255. package/daemon/dist/domain/community-harness-presets.d.ts +15 -0
  256. package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -1
  257. package/daemon/dist/domain/community-harness-presets.js +82 -48
  258. package/daemon/dist/domain/community-harness-presets.js.map +1 -1
  259. package/daemon/dist/domain/compaction-restore-notice.d.ts +33 -5
  260. package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -1
  261. package/daemon/dist/domain/compaction-restore-notice.js +221 -48
  262. package/daemon/dist/domain/compaction-restore-notice.js.map +1 -1
  263. package/daemon/dist/domain/context-usage-store.d.ts +1 -0
  264. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  265. package/daemon/dist/domain/context-usage-store.js +34 -3
  266. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  267. package/daemon/dist/domain/crash-cart-detect.d.ts +7 -0
  268. package/daemon/dist/domain/crash-cart-detect.d.ts.map +1 -1
  269. package/daemon/dist/domain/crash-cart-detect.js +10 -5
  270. package/daemon/dist/domain/crash-cart-detect.js.map +1 -1
  271. package/daemon/dist/domain/crash-cart-discovery.d.ts +9 -16
  272. package/daemon/dist/domain/crash-cart-discovery.d.ts.map +1 -1
  273. package/daemon/dist/domain/crash-cart-discovery.js +22 -40
  274. package/daemon/dist/domain/crash-cart-discovery.js.map +1 -1
  275. package/daemon/dist/domain/crash-cart-emit.d.ts +1 -1
  276. package/daemon/dist/domain/crash-cart-emit.d.ts.map +1 -1
  277. package/daemon/dist/domain/crash-cart-emit.js +4 -0
  278. package/daemon/dist/domain/crash-cart-emit.js.map +1 -1
  279. package/daemon/dist/domain/current-park-arm.d.ts +2 -0
  280. package/daemon/dist/domain/current-park-arm.d.ts.map +1 -1
  281. package/daemon/dist/domain/current-park-arm.js +5 -0
  282. package/daemon/dist/domain/current-park-arm.js.map +1 -1
  283. package/daemon/dist/domain/current-work.d.ts +16 -4
  284. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  285. package/daemon/dist/domain/current-work.js +3 -6
  286. package/daemon/dist/domain/current-work.js.map +1 -1
  287. package/daemon/dist/domain/cwd-resolution.d.ts +12 -1
  288. package/daemon/dist/domain/cwd-resolution.d.ts.map +1 -1
  289. package/daemon/dist/domain/cwd-resolution.js +39 -2
  290. package/daemon/dist/domain/cwd-resolution.js.map +1 -1
  291. package/daemon/dist/domain/draft-aware-delivery.d.ts +17 -2
  292. package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
  293. package/daemon/dist/domain/draft-aware-delivery.js +98 -9
  294. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
  295. package/daemon/dist/domain/draft-held-reoffer.d.ts +61 -0
  296. package/daemon/dist/domain/draft-held-reoffer.d.ts.map +1 -0
  297. package/daemon/dist/domain/draft-held-reoffer.js +143 -0
  298. package/daemon/dist/domain/draft-held-reoffer.js.map +1 -0
  299. package/daemon/dist/domain/execution-view.d.ts +20 -0
  300. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  301. package/daemon/dist/domain/execution-view.js +50 -16
  302. package/daemon/dist/domain/execution-view.js.map +1 -1
  303. package/daemon/dist/domain/gateway/destination-resolver.d.ts +10 -2
  304. package/daemon/dist/domain/gateway/destination-resolver.d.ts.map +1 -1
  305. package/daemon/dist/domain/gateway/destination-resolver.js +26 -3
  306. package/daemon/dist/domain/gateway/destination-resolver.js.map +1 -1
  307. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  308. package/daemon/dist/domain/gateway/slack/inbound.js +5 -4
  309. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  310. package/daemon/dist/domain/gateway/slack/queue-access.js +1 -1
  311. package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
  312. package/daemon/dist/domain/generated-file-hygiene.d.ts.map +1 -1
  313. package/daemon/dist/domain/generated-file-hygiene.js +35 -2
  314. package/daemon/dist/domain/generated-file-hygiene.js.map +1 -1
  315. package/daemon/dist/domain/graph-projection.d.ts +7 -1
  316. package/daemon/dist/domain/graph-projection.d.ts.map +1 -1
  317. package/daemon/dist/domain/graph-projection.js +2 -0
  318. package/daemon/dist/domain/graph-projection.js.map +1 -1
  319. package/daemon/dist/domain/health-context-samples.d.ts +23 -0
  320. package/daemon/dist/domain/health-context-samples.d.ts.map +1 -0
  321. package/daemon/dist/domain/health-context-samples.js +113 -0
  322. package/daemon/dist/domain/health-context-samples.js.map +1 -0
  323. package/daemon/dist/domain/health-detectors.d.ts +3 -0
  324. package/daemon/dist/domain/health-detectors.d.ts.map +1 -1
  325. package/daemon/dist/domain/health-detectors.js +8 -7
  326. package/daemon/dist/domain/health-detectors.js.map +1 -1
  327. package/daemon/dist/domain/home-isolation.d.ts.map +1 -1
  328. package/daemon/dist/domain/home-isolation.js +21 -8
  329. package/daemon/dist/domain/home-isolation.js.map +1 -1
  330. package/daemon/dist/domain/hook-bridge.d.ts +7 -5
  331. package/daemon/dist/domain/hook-bridge.d.ts.map +1 -1
  332. package/daemon/dist/domain/hook-bridge.js +12 -11
  333. package/daemon/dist/domain/hook-bridge.js.map +1 -1
  334. package/daemon/dist/domain/kernel-boot-tracker.d.ts +7 -5
  335. package/daemon/dist/domain/kernel-boot-tracker.d.ts.map +1 -1
  336. package/daemon/dist/domain/kernel-boot-tracker.js +11 -6
  337. package/daemon/dist/domain/kernel-boot-tracker.js.map +1 -1
  338. package/daemon/dist/domain/kernel-boot.d.ts.map +1 -1
  339. package/daemon/dist/domain/kernel-boot.js +6 -2
  340. package/daemon/dist/domain/kernel-boot.js.map +1 -1
  341. package/daemon/dist/domain/kernel-hook-review.d.ts +10 -2
  342. package/daemon/dist/domain/kernel-hook-review.d.ts.map +1 -1
  343. package/daemon/dist/domain/kernel-hook-review.js +18 -4
  344. package/daemon/dist/domain/kernel-hook-review.js.map +1 -1
  345. package/daemon/dist/domain/managed-restore-read-access.d.ts +6 -2
  346. package/daemon/dist/domain/managed-restore-read-access.d.ts.map +1 -1
  347. package/daemon/dist/domain/managed-restore-read-access.js +35 -4
  348. package/daemon/dist/domain/managed-restore-read-access.js.map +1 -1
  349. package/daemon/dist/domain/mission-control/audit-browse.d.ts.map +1 -1
  350. package/daemon/dist/domain/mission-control/audit-browse.js +1 -0
  351. package/daemon/dist/domain/mission-control/audit-browse.js.map +1 -1
  352. package/daemon/dist/domain/mission-control/mission-control-action-log.d.ts +3 -1
  353. package/daemon/dist/domain/mission-control/mission-control-action-log.d.ts.map +1 -1
  354. package/daemon/dist/domain/mission-control/mission-control-action-log.js +7 -0
  355. package/daemon/dist/domain/mission-control/mission-control-action-log.js.map +1 -1
  356. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +3 -0
  357. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  358. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +56 -13
  359. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  360. package/daemon/dist/domain/mission-control/notification-adapter-from-env.d.ts +8 -0
  361. package/daemon/dist/domain/mission-control/notification-adapter-from-env.d.ts.map +1 -0
  362. package/daemon/dist/domain/mission-control/notification-adapter-from-env.js +17 -0
  363. package/daemon/dist/domain/mission-control/notification-adapter-from-env.js.map +1 -0
  364. package/daemon/dist/domain/model-divergence/codex-thread-homes.d.ts +12 -0
  365. package/daemon/dist/domain/model-divergence/codex-thread-homes.d.ts.map +1 -0
  366. package/daemon/dist/domain/model-divergence/codex-thread-homes.js +19 -0
  367. package/daemon/dist/domain/model-divergence/codex-thread-homes.js.map +1 -0
  368. package/daemon/dist/domain/native-process-arguments.d.ts +6 -3
  369. package/daemon/dist/domain/native-process-arguments.d.ts.map +1 -1
  370. package/daemon/dist/domain/native-process-arguments.js +56 -23
  371. package/daemon/dist/domain/native-process-arguments.js.map +1 -1
  372. package/daemon/dist/domain/native-resume-probe.d.ts +9 -0
  373. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  374. package/daemon/dist/domain/native-resume-probe.js +15 -1
  375. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  376. package/daemon/dist/domain/network/hub-client.d.ts +14 -4
  377. package/daemon/dist/domain/network/hub-client.d.ts.map +1 -1
  378. package/daemon/dist/domain/network/hub-client.js +26 -9
  379. package/daemon/dist/domain/network/hub-client.js.map +1 -1
  380. package/daemon/dist/domain/network/network-connector.d.ts +2 -0
  381. package/daemon/dist/domain/network/network-connector.d.ts.map +1 -1
  382. package/daemon/dist/domain/network/network-connector.js +162 -16
  383. package/daemon/dist/domain/network/network-connector.js.map +1 -1
  384. package/daemon/dist/domain/network/network-requests.d.ts +4 -1
  385. package/daemon/dist/domain/network/network-requests.d.ts.map +1 -1
  386. package/daemon/dist/domain/network/network-requests.js +141 -14
  387. package/daemon/dist/domain/network/network-requests.js.map +1 -1
  388. package/daemon/dist/domain/node-inventory.d.ts +47 -0
  389. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  390. package/daemon/dist/domain/node-inventory.js +270 -158
  391. package/daemon/dist/domain/node-inventory.js.map +1 -1
  392. package/daemon/dist/domain/node-launcher.d.ts +1 -0
  393. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  394. package/daemon/dist/domain/node-launcher.js +13 -5
  395. package/daemon/dist/domain/node-launcher.js.map +1 -1
  396. package/daemon/dist/domain/outbox-handler.d.ts +66 -0
  397. package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
  398. package/daemon/dist/domain/outbox-handler.js +117 -8
  399. package/daemon/dist/domain/outbox-handler.js.map +1 -1
  400. package/daemon/dist/domain/pane-cutover.d.ts +6 -2
  401. package/daemon/dist/domain/pane-cutover.d.ts.map +1 -1
  402. package/daemon/dist/domain/pane-cutover.js +14 -4
  403. package/daemon/dist/domain/pane-cutover.js.map +1 -1
  404. package/daemon/dist/domain/parked-owner-escalation.d.ts +1 -0
  405. package/daemon/dist/domain/parked-owner-escalation.d.ts.map +1 -1
  406. package/daemon/dist/domain/parked-owner-escalation.js +3 -1
  407. package/daemon/dist/domain/parked-owner-escalation.js.map +1 -1
  408. package/daemon/dist/domain/parked-query.js +1 -1
  409. package/daemon/dist/domain/parked-query.js.map +1 -1
  410. package/daemon/dist/domain/permission-account.d.ts.map +1 -1
  411. package/daemon/dist/domain/permission-account.js +20 -1
  412. package/daemon/dist/domain/permission-account.js.map +1 -1
  413. package/daemon/dist/domain/policies/idle-gate-qitem.d.ts +1 -0
  414. package/daemon/dist/domain/policies/idle-gate-qitem.d.ts.map +1 -1
  415. package/daemon/dist/domain/policies/idle-gate-qitem.js +1 -0
  416. package/daemon/dist/domain/policies/idle-gate-qitem.js.map +1 -1
  417. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +21 -0
  418. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
  419. package/daemon/dist/domain/policies/parked-owner-consumer.js +185 -26
  420. package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
  421. package/daemon/dist/domain/policies/seat-pool.d.ts +2 -1
  422. package/daemon/dist/domain/policies/seat-pool.d.ts.map +1 -1
  423. package/daemon/dist/domain/policies/seat-pool.js.map +1 -1
  424. package/daemon/dist/domain/policies/workflow-keepalive.d.ts +1 -0
  425. package/daemon/dist/domain/policies/workflow-keepalive.d.ts.map +1 -1
  426. package/daemon/dist/domain/policies/workflow-keepalive.js +4 -1
  427. package/daemon/dist/domain/policies/workflow-keepalive.js.map +1 -1
  428. package/daemon/dist/domain/profile-resolver.d.ts +2 -0
  429. package/daemon/dist/domain/profile-resolver.d.ts.map +1 -1
  430. package/daemon/dist/domain/profile-resolver.js +10 -4
  431. package/daemon/dist/domain/profile-resolver.js.map +1 -1
  432. package/daemon/dist/domain/project-lifecycle-compiler.d.ts.map +1 -1
  433. package/daemon/dist/domain/project-lifecycle-compiler.js +35 -1
  434. package/daemon/dist/domain/project-lifecycle-compiler.js.map +1 -1
  435. package/daemon/dist/domain/proof/judgments.d.ts +7 -0
  436. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  437. package/daemon/dist/domain/proof/judgments.js +18 -10
  438. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  439. package/daemon/dist/domain/provider/assignment-apply.d.ts +85 -0
  440. package/daemon/dist/domain/provider/assignment-apply.d.ts.map +1 -0
  441. package/daemon/dist/domain/provider/assignment-apply.js +270 -0
  442. package/daemon/dist/domain/provider/assignment-apply.js.map +1 -0
  443. package/daemon/dist/domain/provider/assignment-plan.d.ts +150 -0
  444. package/daemon/dist/domain/provider/assignment-plan.d.ts.map +1 -0
  445. package/daemon/dist/domain/provider/assignment-plan.js +218 -0
  446. package/daemon/dist/domain/provider/assignment-plan.js.map +1 -0
  447. package/daemon/dist/domain/provider/claude-seat-switch.d.ts +1 -1
  448. package/daemon/dist/domain/provider/claude-seat-switch.d.ts.map +1 -1
  449. package/daemon/dist/domain/provider/claude-seat-switch.js +37 -6
  450. package/daemon/dist/domain/provider/claude-seat-switch.js.map +1 -1
  451. package/daemon/dist/domain/provider/provider-account-assignments.d.ts +64 -0
  452. package/daemon/dist/domain/provider/provider-account-assignments.d.ts.map +1 -0
  453. package/daemon/dist/domain/provider/provider-account-assignments.js +75 -0
  454. package/daemon/dist/domain/provider/provider-account-assignments.js.map +1 -0
  455. package/daemon/dist/domain/provider/provider-account-refs.d.ts +91 -0
  456. package/daemon/dist/domain/provider/provider-account-refs.d.ts.map +1 -0
  457. package/daemon/dist/domain/provider/provider-account-refs.js +164 -0
  458. package/daemon/dist/domain/provider/provider-account-refs.js.map +1 -0
  459. package/daemon/dist/domain/provider/provider-collect.d.ts +3 -1
  460. package/daemon/dist/domain/provider/provider-collect.d.ts.map +1 -1
  461. package/daemon/dist/domain/provider/provider-collect.js +2 -0
  462. package/daemon/dist/domain/provider/provider-collect.js.map +1 -1
  463. package/daemon/dist/domain/provider/provider-service-impl.d.ts +43 -1
  464. package/daemon/dist/domain/provider/provider-service-impl.d.ts.map +1 -1
  465. package/daemon/dist/domain/provider/provider-service-impl.js +376 -20
  466. package/daemon/dist/domain/provider/provider-service-impl.js.map +1 -1
  467. package/daemon/dist/domain/provider/provider-service.d.ts +82 -6
  468. package/daemon/dist/domain/provider/provider-service.d.ts.map +1 -1
  469. package/daemon/dist/domain/provider/provider-types.d.ts +40 -1
  470. package/daemon/dist/domain/provider/provider-types.d.ts.map +1 -1
  471. package/daemon/dist/domain/provider/usage-across-hosts.d.ts.map +1 -1
  472. package/daemon/dist/domain/provider/usage-across-hosts.js +13 -1
  473. package/daemon/dist/domain/provider/usage-across-hosts.js.map +1 -1
  474. package/daemon/dist/domain/ps-projection.d.ts +5 -3
  475. package/daemon/dist/domain/ps-projection.d.ts.map +1 -1
  476. package/daemon/dist/domain/ps-projection.js +10 -3
  477. package/daemon/dist/domain/ps-projection.js.map +1 -1
  478. package/daemon/dist/domain/queue-display.d.ts +7 -0
  479. package/daemon/dist/domain/queue-display.d.ts.map +1 -0
  480. package/daemon/dist/domain/queue-display.js +20 -0
  481. package/daemon/dist/domain/queue-display.js.map +1 -0
  482. package/daemon/dist/domain/queue-owner.d.ts +4 -2
  483. package/daemon/dist/domain/queue-owner.d.ts.map +1 -1
  484. package/daemon/dist/domain/queue-owner.js +7 -5
  485. package/daemon/dist/domain/queue-owner.js.map +1 -1
  486. package/daemon/dist/domain/queue-repository.d.ts +104 -24
  487. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  488. package/daemon/dist/domain/queue-repository.js +600 -89
  489. package/daemon/dist/domain/queue-repository.js.map +1 -1
  490. package/daemon/dist/domain/queue-stuck-sweep.d.ts +4 -0
  491. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  492. package/daemon/dist/domain/queue-stuck-sweep.js +1890 -1817
  493. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  494. package/daemon/dist/domain/queue-transfer-activation.d.ts +28 -0
  495. package/daemon/dist/domain/queue-transfer-activation.d.ts.map +1 -0
  496. package/daemon/dist/domain/queue-transfer-activation.js +187 -0
  497. package/daemon/dist/domain/queue-transfer-activation.js.map +1 -0
  498. package/daemon/dist/domain/queue-transfer-mapping.d.ts +31 -0
  499. package/daemon/dist/domain/queue-transfer-mapping.d.ts.map +1 -0
  500. package/daemon/dist/domain/queue-transfer-mapping.js +33 -0
  501. package/daemon/dist/domain/queue-transfer-mapping.js.map +1 -0
  502. package/daemon/dist/domain/queue-transfer-operation.d.ts +24 -0
  503. package/daemon/dist/domain/queue-transfer-operation.d.ts.map +1 -0
  504. package/daemon/dist/domain/queue-transfer-operation.js +41 -0
  505. package/daemon/dist/domain/queue-transfer-operation.js.map +1 -0
  506. package/daemon/dist/domain/queue-transfer-parse.d.ts +8 -0
  507. package/daemon/dist/domain/queue-transfer-parse.d.ts.map +1 -1
  508. package/daemon/dist/domain/queue-transfer-parse.js +16 -6
  509. package/daemon/dist/domain/queue-transfer-parse.js.map +1 -1
  510. package/daemon/dist/domain/queue-transfer-records.d.ts +160 -0
  511. package/daemon/dist/domain/queue-transfer-records.d.ts.map +1 -0
  512. package/daemon/dist/domain/queue-transfer-records.js +94 -0
  513. package/daemon/dist/domain/queue-transfer-records.js.map +1 -0
  514. package/daemon/dist/domain/queue-transfer-recovery.d.ts +40 -0
  515. package/daemon/dist/domain/queue-transfer-recovery.d.ts.map +1 -0
  516. package/daemon/dist/domain/queue-transfer-recovery.js +136 -0
  517. package/daemon/dist/domain/queue-transfer-recovery.js.map +1 -0
  518. package/daemon/dist/domain/queue-transfer-relinquish.d.ts +70 -0
  519. package/daemon/dist/domain/queue-transfer-relinquish.d.ts.map +1 -0
  520. package/daemon/dist/domain/queue-transfer-relinquish.js +204 -0
  521. package/daemon/dist/domain/queue-transfer-relinquish.js.map +1 -0
  522. package/daemon/dist/domain/queue-transfer-review.d.ts +1 -0
  523. package/daemon/dist/domain/queue-transfer-review.d.ts.map +1 -1
  524. package/daemon/dist/domain/queue-transfer-review.js +15 -13
  525. package/daemon/dist/domain/queue-transfer-review.js.map +1 -1
  526. package/daemon/dist/domain/queue-transfer-staging.d.ts +14 -0
  527. package/daemon/dist/domain/queue-transfer-staging.d.ts.map +1 -1
  528. package/daemon/dist/domain/queue-transfer-staging.js +9 -1
  529. package/daemon/dist/domain/queue-transfer-staging.js.map +1 -1
  530. package/daemon/dist/domain/queue-transfer-write.d.ts +14 -0
  531. package/daemon/dist/domain/queue-transfer-write.d.ts.map +1 -0
  532. package/daemon/dist/domain/queue-transfer-write.js +42 -0
  533. package/daemon/dist/domain/queue-transfer-write.js.map +1 -0
  534. package/daemon/dist/domain/queue-transition-log.d.ts +8 -0
  535. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  536. package/daemon/dist/domain/queue-transition-log.js +27 -14
  537. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  538. package/daemon/dist/domain/queue-waiting.d.ts +10 -1
  539. package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
  540. package/daemon/dist/domain/queue-waiting.js +20 -14
  541. package/daemon/dist/domain/queue-waiting.js.map +1 -1
  542. package/daemon/dist/domain/queue-wake-ladder.d.ts +10 -3
  543. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  544. package/daemon/dist/domain/queue-wake-ladder.js +60 -23
  545. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  546. package/daemon/dist/domain/queue-wake-repository.d.ts +1 -0
  547. package/daemon/dist/domain/queue-wake-repository.d.ts.map +1 -1
  548. package/daemon/dist/domain/queue-wake-repository.js +21 -19
  549. package/daemon/dist/domain/queue-wake-repository.js.map +1 -1
  550. package/daemon/dist/domain/receiver-context.d.ts +3 -2
  551. package/daemon/dist/domain/receiver-context.d.ts.map +1 -1
  552. package/daemon/dist/domain/receiver-context.js +5 -4
  553. package/daemon/dist/domain/receiver-context.js.map +1 -1
  554. package/daemon/dist/domain/reconciler.d.ts +2 -0
  555. package/daemon/dist/domain/reconciler.d.ts.map +1 -1
  556. package/daemon/dist/domain/reconciler.js +17 -1
  557. package/daemon/dist/domain/reconciler.js.map +1 -1
  558. package/daemon/dist/domain/relayed-answers.d.ts +1 -0
  559. package/daemon/dist/domain/relayed-answers.d.ts.map +1 -1
  560. package/daemon/dist/domain/relayed-answers.js.map +1 -1
  561. package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
  562. package/daemon/dist/domain/restore-check-service.js +9 -3
  563. package/daemon/dist/domain/restore-check-service.js.map +1 -1
  564. package/daemon/dist/domain/restore-orchestrator.d.ts +7 -0
  565. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  566. package/daemon/dist/domain/restore-orchestrator.js +54 -14
  567. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  568. package/daemon/dist/domain/return-route.d.ts +4 -0
  569. package/daemon/dist/domain/return-route.d.ts.map +1 -1
  570. package/daemon/dist/domain/return-route.js +13 -0
  571. package/daemon/dist/domain/return-route.js.map +1 -1
  572. package/daemon/dist/domain/rig-mode/operating-posture.d.ts +3 -0
  573. package/daemon/dist/domain/rig-mode/operating-posture.d.ts.map +1 -1
  574. package/daemon/dist/domain/rig-mode/operating-posture.js +27 -8
  575. package/daemon/dist/domain/rig-mode/operating-posture.js.map +1 -1
  576. package/daemon/dist/domain/rig-status-compose.d.ts +3 -0
  577. package/daemon/dist/domain/rig-status-compose.d.ts.map +1 -1
  578. package/daemon/dist/domain/rig-status-compose.js +4 -1
  579. package/daemon/dist/domain/rig-status-compose.js.map +1 -1
  580. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  581. package/daemon/dist/domain/rig-teardown.js +3 -2
  582. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  583. package/daemon/dist/domain/rigspec-exporter.d.ts +2 -0
  584. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  585. package/daemon/dist/domain/rigspec-exporter.js +38 -2
  586. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  587. package/daemon/dist/domain/rigspec-instantiator.d.ts +4 -1
  588. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  589. package/daemon/dist/domain/rigspec-instantiator.js +32 -13
  590. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  591. package/daemon/dist/domain/rigspec-preflight.d.ts +3 -0
  592. package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
  593. package/daemon/dist/domain/rigspec-preflight.js +25 -7
  594. package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
  595. package/daemon/dist/domain/roster-ready-notice.d.ts +1 -1
  596. package/daemon/dist/domain/roster-ready-notice.d.ts.map +1 -1
  597. package/daemon/dist/domain/roster-ready-notice.js +2 -1
  598. package/daemon/dist/domain/roster-ready-notice.js.map +1 -1
  599. package/daemon/dist/domain/runner-permissions.d.ts +3 -2
  600. package/daemon/dist/domain/runner-permissions.d.ts.map +1 -1
  601. package/daemon/dist/domain/runner-permissions.js +30 -19
  602. package/daemon/dist/domain/runner-permissions.js.map +1 -1
  603. package/daemon/dist/domain/runtime-adapter.d.ts +2 -0
  604. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  605. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  606. package/daemon/dist/domain/scope/manifest-editor.d.ts +35 -0
  607. package/daemon/dist/domain/scope/manifest-editor.d.ts.map +1 -0
  608. package/daemon/dist/domain/scope/manifest-editor.js +197 -0
  609. package/daemon/dist/domain/scope/manifest-editor.js.map +1 -0
  610. package/daemon/dist/domain/scope/mission-frontmatter.d.ts +9 -0
  611. package/daemon/dist/domain/scope/mission-frontmatter.d.ts.map +1 -0
  612. package/daemon/dist/domain/scope/mission-frontmatter.js +36 -0
  613. package/daemon/dist/domain/scope/mission-frontmatter.js.map +1 -0
  614. package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  615. package/daemon/dist/domain/seat-activity-service.js +53 -20
  616. package/daemon/dist/domain/seat-activity-service.js.map +1 -1
  617. package/daemon/dist/domain/seat-cold-start.d.ts +8 -2
  618. package/daemon/dist/domain/seat-cold-start.d.ts.map +1 -1
  619. package/daemon/dist/domain/seat-cold-start.js +75 -19
  620. package/daemon/dist/domain/seat-cold-start.js.map +1 -1
  621. package/daemon/dist/domain/seat-delivery-guard.d.ts +6 -1
  622. package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
  623. package/daemon/dist/domain/seat-delivery-guard.js +23 -2
  624. package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
  625. package/daemon/dist/domain/seat-evidence.d.ts +13 -0
  626. package/daemon/dist/domain/seat-evidence.d.ts.map +1 -0
  627. package/daemon/dist/domain/seat-evidence.js +29 -0
  628. package/daemon/dist/domain/seat-evidence.js.map +1 -0
  629. package/daemon/dist/domain/seat-handover-service.d.ts +5 -1
  630. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  631. package/daemon/dist/domain/seat-handover-service.js +49 -35
  632. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  633. package/daemon/dist/domain/seat-lifecycle-service.d.ts +26 -6
  634. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  635. package/daemon/dist/domain/seat-lifecycle-service.js +108 -17
  636. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  637. package/daemon/dist/domain/seat-pool-dispatch-guard.d.ts +28 -0
  638. package/daemon/dist/domain/seat-pool-dispatch-guard.d.ts.map +1 -0
  639. package/daemon/dist/domain/seat-pool-dispatch-guard.js +123 -0
  640. package/daemon/dist/domain/seat-pool-dispatch-guard.js.map +1 -0
  641. package/daemon/dist/domain/seat-pool-executor.d.ts +64 -3
  642. package/daemon/dist/domain/seat-pool-executor.d.ts.map +1 -1
  643. package/daemon/dist/domain/seat-pool-executor.js +993 -102
  644. package/daemon/dist/domain/seat-pool-executor.js.map +1 -1
  645. package/daemon/dist/domain/seat-pool-slots.d.ts +90 -2
  646. package/daemon/dist/domain/seat-pool-slots.d.ts.map +1 -1
  647. package/daemon/dist/domain/seat-pool-slots.js +88 -3
  648. package/daemon/dist/domain/seat-pool-slots.js.map +1 -1
  649. package/daemon/dist/domain/seat-pool-spec.d.ts +4 -1
  650. package/daemon/dist/domain/seat-pool-spec.d.ts.map +1 -1
  651. package/daemon/dist/domain/seat-pool-spec.js +14 -2
  652. package/daemon/dist/domain/seat-pool-spec.js.map +1 -1
  653. package/daemon/dist/domain/seat-reaper-eligibility.d.ts +34 -0
  654. package/daemon/dist/domain/seat-reaper-eligibility.d.ts.map +1 -0
  655. package/daemon/dist/domain/seat-reaper-eligibility.js +30 -0
  656. package/daemon/dist/domain/seat-reaper-eligibility.js.map +1 -0
  657. package/daemon/dist/domain/seat-reaper-events.d.ts +31 -0
  658. package/daemon/dist/domain/seat-reaper-events.d.ts.map +1 -0
  659. package/daemon/dist/domain/seat-reaper-events.js +2 -0
  660. package/daemon/dist/domain/seat-reaper-events.js.map +1 -0
  661. package/daemon/dist/domain/seat-reaper-service.d.ts +59 -0
  662. package/daemon/dist/domain/seat-reaper-service.d.ts.map +1 -0
  663. package/daemon/dist/domain/seat-reaper-service.js +311 -0
  664. package/daemon/dist/domain/seat-reaper-service.js.map +1 -0
  665. package/daemon/dist/domain/seat-reaper-settings.d.ts +14 -0
  666. package/daemon/dist/domain/seat-reaper-settings.d.ts.map +1 -0
  667. package/daemon/dist/domain/seat-reaper-settings.js +32 -0
  668. package/daemon/dist/domain/seat-reaper-settings.js.map +1 -0
  669. package/daemon/dist/domain/seat-reaper-store.d.ts +19 -0
  670. package/daemon/dist/domain/seat-reaper-store.d.ts.map +1 -0
  671. package/daemon/dist/domain/seat-reaper-store.js +45 -0
  672. package/daemon/dist/domain/seat-reaper-store.js.map +1 -0
  673. package/daemon/dist/domain/seat-reaper-workspace.d.ts +4 -0
  674. package/daemon/dist/domain/seat-reaper-workspace.d.ts.map +1 -0
  675. package/daemon/dist/domain/seat-reaper-workspace.js +43 -0
  676. package/daemon/dist/domain/seat-reaper-workspace.js.map +1 -0
  677. package/daemon/dist/domain/seat-restart-in-place.d.ts +11 -3
  678. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  679. package/daemon/dist/domain/seat-restart-in-place.js +39 -48
  680. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  681. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  682. package/daemon/dist/domain/seat-runtime-switch-service.js +5 -7
  683. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  684. package/daemon/dist/domain/seat-skill-storage.d.ts.map +1 -1
  685. package/daemon/dist/domain/seat-skill-storage.js +27 -5
  686. package/daemon/dist/domain/seat-skill-storage.js.map +1 -1
  687. package/daemon/dist/domain/seat-standby.d.ts +13 -0
  688. package/daemon/dist/domain/seat-standby.d.ts.map +1 -0
  689. package/daemon/dist/domain/seat-standby.js +21 -0
  690. package/daemon/dist/domain/seat-standby.js.map +1 -0
  691. package/daemon/dist/domain/seat-startup-text.d.ts +159 -0
  692. package/daemon/dist/domain/seat-startup-text.d.ts.map +1 -0
  693. package/daemon/dist/domain/seat-startup-text.js +200 -0
  694. package/daemon/dist/domain/seat-startup-text.js.map +1 -0
  695. package/daemon/dist/domain/seat-status-service.d.ts +18 -0
  696. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  697. package/daemon/dist/domain/seat-status-service.js +25 -5
  698. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  699. package/daemon/dist/domain/seat-structural-activity-service.d.ts +7 -0
  700. package/daemon/dist/domain/seat-structural-activity-service.d.ts.map +1 -1
  701. package/daemon/dist/domain/seat-structural-activity-service.js +16 -1
  702. package/daemon/dist/domain/seat-structural-activity-service.js.map +1 -1
  703. package/daemon/dist/domain/session-registry.d.ts +15 -3
  704. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  705. package/daemon/dist/domain/session-registry.js +52 -5
  706. package/daemon/dist/domain/session-registry.js.map +1 -1
  707. package/daemon/dist/domain/session-transport.d.ts +12 -5
  708. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  709. package/daemon/dist/domain/session-transport.js +129 -18
  710. package/daemon/dist/domain/session-transport.js.map +1 -1
  711. package/daemon/dist/domain/shared-conversation.d.ts.map +1 -1
  712. package/daemon/dist/domain/shared-conversation.js +3 -1
  713. package/daemon/dist/domain/shared-conversation.js.map +1 -1
  714. package/daemon/dist/domain/slices/slice-indexer.d.ts +2 -2
  715. package/daemon/dist/domain/slices/slice-indexer.d.ts.map +1 -1
  716. package/daemon/dist/domain/slices/slice-indexer.js +4 -15
  717. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  718. package/daemon/dist/domain/snapshot-capture.d.ts +4 -1
  719. package/daemon/dist/domain/snapshot-capture.d.ts.map +1 -1
  720. package/daemon/dist/domain/snapshot-capture.js +14 -18
  721. package/daemon/dist/domain/snapshot-capture.js.map +1 -1
  722. package/daemon/dist/domain/snapshot-repository.d.ts +37 -0
  723. package/daemon/dist/domain/snapshot-repository.d.ts.map +1 -1
  724. package/daemon/dist/domain/snapshot-repository.js +68 -0
  725. package/daemon/dist/domain/snapshot-repository.js.map +1 -1
  726. package/daemon/dist/domain/startup-orchestrator.d.ts +8 -20
  727. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  728. package/daemon/dist/domain/startup-orchestrator.js +94 -27
  729. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  730. package/daemon/dist/domain/startup-submission-evidence.d.ts +4 -1
  731. package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
  732. package/daemon/dist/domain/startup-submission-evidence.js +12 -1
  733. package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
  734. package/daemon/dist/domain/successor-session-launcher.d.ts +9 -5
  735. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  736. package/daemon/dist/domain/successor-session-launcher.js +17 -6
  737. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  738. package/daemon/dist/domain/terminal/earlier-tile-attach-0724.d.ts +2 -0
  739. package/daemon/dist/domain/terminal/earlier-tile-attach-0724.d.ts.map +1 -0
  740. package/daemon/dist/domain/terminal/earlier-tile-attach-0724.js +54 -0
  741. package/daemon/dist/domain/terminal/earlier-tile-attach-0724.js.map +1 -0
  742. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts +28 -3
  743. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts.map +1 -1
  744. package/daemon/dist/domain/terminal/herdr-app-provider.js +216 -52
  745. package/daemon/dist/domain/terminal/herdr-app-provider.js.map +1 -1
  746. package/daemon/dist/domain/terminal/herdr-app-state.d.ts +7 -2
  747. package/daemon/dist/domain/terminal/herdr-app-state.d.ts.map +1 -1
  748. package/daemon/dist/domain/terminal/herdr-app-state.js.map +1 -1
  749. package/daemon/dist/domain/terminal/terminal-provider.d.ts +17 -0
  750. package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
  751. package/daemon/dist/domain/terminal/tile-attach.d.ts +4 -4
  752. package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -1
  753. package/daemon/dist/domain/terminal/tile-attach.js +14 -8
  754. package/daemon/dist/domain/terminal/tile-attach.js.map +1 -1
  755. package/daemon/dist/domain/types.d.ts +71 -4
  756. package/daemon/dist/domain/types.d.ts.map +1 -1
  757. package/daemon/dist/domain/types.js.map +1 -1
  758. package/daemon/dist/domain/usage-samples-store.d.ts.map +1 -1
  759. package/daemon/dist/domain/usage-samples-store.js.map +1 -1
  760. package/daemon/dist/domain/user-settings/settings-store.d.ts +1 -1
  761. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  762. package/daemon/dist/domain/user-settings/settings-store.js +45 -2
  763. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  764. package/daemon/dist/domain/view-projector.d.ts.map +1 -1
  765. package/daemon/dist/domain/view-projector.js +5 -2
  766. package/daemon/dist/domain/view-projector.js.map +1 -1
  767. package/daemon/dist/domain/watchdog-delivery.d.ts +3 -0
  768. package/daemon/dist/domain/watchdog-delivery.d.ts.map +1 -1
  769. package/daemon/dist/domain/watchdog-delivery.js +26 -4
  770. package/daemon/dist/domain/watchdog-delivery.js.map +1 -1
  771. package/daemon/dist/domain/watchdog-history-log.d.ts +10 -0
  772. package/daemon/dist/domain/watchdog-history-log.d.ts.map +1 -1
  773. package/daemon/dist/domain/watchdog-history-log.js +35 -1
  774. package/daemon/dist/domain/watchdog-history-log.js.map +1 -1
  775. package/daemon/dist/domain/watchdog-job-update.d.ts.map +1 -1
  776. package/daemon/dist/domain/watchdog-job-update.js +29 -4
  777. package/daemon/dist/domain/watchdog-job-update.js.map +1 -1
  778. package/daemon/dist/domain/watchdog-policy-engine.d.ts.map +1 -1
  779. package/daemon/dist/domain/watchdog-policy-engine.js +4 -1
  780. package/daemon/dist/domain/watchdog-policy-engine.js.map +1 -1
  781. package/daemon/dist/domain/watchdog-scheduler.d.ts +4 -0
  782. package/daemon/dist/domain/watchdog-scheduler.d.ts.map +1 -1
  783. package/daemon/dist/domain/watchdog-scheduler.js +14 -0
  784. package/daemon/dist/domain/watchdog-scheduler.js.map +1 -1
  785. package/daemon/dist/domain/workflow-role-context.d.ts.map +1 -1
  786. package/daemon/dist/domain/workflow-role-context.js +1 -0
  787. package/daemon/dist/domain/workflow-role-context.js.map +1 -1
  788. package/daemon/dist/domain/workflow-role-resolver.d.ts +3 -0
  789. package/daemon/dist/domain/workflow-role-resolver.d.ts.map +1 -1
  790. package/daemon/dist/domain/workflow-role-resolver.js +12 -6
  791. package/daemon/dist/domain/workflow-role-resolver.js.map +1 -1
  792. package/daemon/dist/domain/workspace/project-catalog.d.ts +7 -0
  793. package/daemon/dist/domain/workspace/project-catalog.d.ts.map +1 -1
  794. package/daemon/dist/domain/workspace/project-catalog.js +16 -9
  795. package/daemon/dist/domain/workspace/project-catalog.js.map +1 -1
  796. package/daemon/dist/domain/workspace/project-registration.d.ts +5 -1
  797. package/daemon/dist/domain/workspace/project-registration.d.ts.map +1 -1
  798. package/daemon/dist/domain/workspace/project-registration.js +11 -7
  799. package/daemon/dist/domain/workspace/project-registration.js.map +1 -1
  800. package/daemon/dist/index.d.ts +3 -0
  801. package/daemon/dist/index.d.ts.map +1 -1
  802. package/daemon/dist/index.js +14 -4
  803. package/daemon/dist/index.js.map +1 -1
  804. package/daemon/dist/middleware/auth-bearer-token.d.ts +8 -12
  805. package/daemon/dist/middleware/auth-bearer-token.d.ts.map +1 -1
  806. package/daemon/dist/middleware/auth-bearer-token.js +18 -36
  807. package/daemon/dist/middleware/auth-bearer-token.js.map +1 -1
  808. package/daemon/dist/queue-transfer-records-surface.d.ts +6 -0
  809. package/daemon/dist/queue-transfer-records-surface.d.ts.map +1 -0
  810. package/daemon/dist/queue-transfer-records-surface.js +6 -0
  811. package/daemon/dist/queue-transfer-records-surface.js.map +1 -0
  812. package/daemon/dist/rig-lookup-surface.d.ts +2 -0
  813. package/daemon/dist/rig-lookup-surface.d.ts.map +1 -0
  814. package/daemon/dist/rig-lookup-surface.js +5 -0
  815. package/daemon/dist/rig-lookup-surface.js.map +1 -0
  816. package/daemon/dist/routes/activity.d.ts.map +1 -1
  817. package/daemon/dist/routes/activity.js +4 -3
  818. package/daemon/dist/routes/activity.js.map +1 -1
  819. package/daemon/dist/routes/attention.d.ts.map +1 -1
  820. package/daemon/dist/routes/attention.js +3 -1
  821. package/daemon/dist/routes/attention.js.map +1 -1
  822. package/daemon/dist/routes/compaction.d.ts.map +1 -1
  823. package/daemon/dist/routes/compaction.js +2 -0
  824. package/daemon/dist/routes/compaction.js.map +1 -1
  825. package/daemon/dist/routes/mission-control.d.ts.map +1 -1
  826. package/daemon/dist/routes/mission-control.js +2 -1
  827. package/daemon/dist/routes/mission-control.js.map +1 -1
  828. package/daemon/dist/routes/missions.d.ts +3 -6
  829. package/daemon/dist/routes/missions.d.ts.map +1 -1
  830. package/daemon/dist/routes/missions.js +42 -76
  831. package/daemon/dist/routes/missions.js.map +1 -1
  832. package/daemon/dist/routes/network.d.ts.map +1 -1
  833. package/daemon/dist/routes/network.js +19 -1
  834. package/daemon/dist/routes/network.js.map +1 -1
  835. package/daemon/dist/routes/provider.d.ts.map +1 -1
  836. package/daemon/dist/routes/provider.js +156 -5
  837. package/daemon/dist/routes/provider.js.map +1 -1
  838. package/daemon/dist/routes/queue-transfer.d.ts +9 -0
  839. package/daemon/dist/routes/queue-transfer.d.ts.map +1 -0
  840. package/daemon/dist/routes/queue-transfer.js +109 -0
  841. package/daemon/dist/routes/queue-transfer.js.map +1 -0
  842. package/daemon/dist/routes/queue.d.ts.map +1 -1
  843. package/daemon/dist/routes/queue.js +80 -51
  844. package/daemon/dist/routes/queue.js.map +1 -1
  845. package/daemon/dist/routes/rigs.js +3 -0
  846. package/daemon/dist/routes/rigs.js.map +1 -1
  847. package/daemon/dist/routes/rigspec.d.ts.map +1 -1
  848. package/daemon/dist/routes/rigspec.js +4 -0
  849. package/daemon/dist/routes/rigspec.js.map +1 -1
  850. package/daemon/dist/routes/seat.d.ts.map +1 -1
  851. package/daemon/dist/routes/seat.js +19 -3
  852. package/daemon/dist/routes/seat.js.map +1 -1
  853. package/daemon/dist/routes/terminal-ws.d.ts +0 -5
  854. package/daemon/dist/routes/terminal-ws.d.ts.map +1 -1
  855. package/daemon/dist/routes/terminal-ws.js +0 -6
  856. package/daemon/dist/routes/terminal-ws.js.map +1 -1
  857. package/daemon/dist/routes/transport.js +1 -1
  858. package/daemon/dist/routes/transport.js.map +1 -1
  859. package/daemon/dist/scope-manifest-surface.d.ts +4 -0
  860. package/daemon/dist/scope-manifest-surface.d.ts.map +1 -0
  861. package/daemon/dist/scope-manifest-surface.js +4 -0
  862. package/daemon/dist/scope-manifest-surface.js.map +1 -0
  863. package/daemon/dist/server.d.ts +2 -1
  864. package/daemon/dist/server.d.ts.map +1 -1
  865. package/daemon/dist/server.js +6 -6
  866. package/daemon/dist/server.js.map +1 -1
  867. package/daemon/dist/startup.d.ts.map +1 -1
  868. package/daemon/dist/startup.js +126 -61
  869. package/daemon/dist/startup.js.map +1 -1
  870. package/daemon/docs/reference/agent-startup-guide.md +26 -4
  871. package/daemon/docs/reference/agent-state-taxonomy.md +22 -1
  872. package/daemon/docs/reference/claude-status-line.md +28 -0
  873. package/daemon/docs/reference/community-harness-examples/hermes/hermes.yaml +3 -0
  874. package/daemon/docs/reference/community-harness-examples/hermes/openrig-hermes-launch +10 -0
  875. package/daemon/docs/reference/community-harness-presets.md +79 -8
  876. package/daemon/docs/reference/daemon-http-clients.md +49 -2
  877. package/daemon/docs/reference/getting-started.md +73 -11
  878. package/daemon/docs/reference/harness-runner-contract.md +12 -4
  879. package/daemon/docs/reference/help.md +9 -0
  880. package/daemon/docs/reference/herdr-app.md +45 -4
  881. package/daemon/docs/reference/hosted-members.md +1 -1
  882. package/daemon/docs/reference/network-connector.md +66 -1
  883. package/daemon/docs/reference/pi-tool-selection-recovery.md +13 -29
  884. package/daemon/docs/reference/queue-transfer-activation.md +89 -0
  885. package/daemon/docs/reference/queue-transfer-staging.md +1 -1
  886. package/daemon/docs/reference/quickstart.md +4 -4
  887. package/daemon/docs/reference/refocus-channel.md +21 -0
  888. package/daemon/docs/reference/rig-bundle.md +25 -0
  889. package/daemon/docs/reference/rig-spec.md +218 -23
  890. package/daemon/docs/reference/scoped-operating-posture.md +6 -1
  891. package/daemon/docs/reference/sdlc-conventions.md +10 -4
  892. package/daemon/docs/reference/seat-delivery.md +108 -12
  893. package/daemon/docs/reference/seat-node-targeting.md +2 -2
  894. package/daemon/docs/reference/seat-pools.md +181 -18
  895. package/daemon/docs/reference/seat-scaling.md +137 -0
  896. package/daemon/docs/reference/whats-new.md +190 -14
  897. package/daemon/specs/agents/development/implementer/guidance/role.md +11 -0
  898. package/daemon/specs/agents/development/qa/guidance/role.md +5 -0
  899. package/daemon/specs/agents/shared/skills/core/cross-host-rig-commands/SKILL.md +9 -1
  900. package/daemon/specs/agents/shared/skills/core/working-with-an-openrig-team/SKILL.md +32 -19
  901. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +8 -3
  902. package/dist/build-info.js +3 -3
  903. package/dist/cli-error.d.ts +2 -0
  904. package/dist/cli-error.d.ts.map +1 -1
  905. package/dist/cli-error.js +25 -8
  906. package/dist/cli-error.js.map +1 -1
  907. package/dist/client.d.ts +1 -0
  908. package/dist/client.d.ts.map +1 -1
  909. package/dist/client.js +13 -0
  910. package/dist/client.js.map +1 -1
  911. package/dist/commands/auth.d.ts.map +1 -1
  912. package/dist/commands/auth.js +52 -1
  913. package/dist/commands/auth.js.map +1 -1
  914. package/dist/commands/config.d.ts.map +1 -1
  915. package/dist/commands/config.js +3 -0
  916. package/dist/commands/config.js.map +1 -1
  917. package/dist/commands/crash-cart.d.ts.map +1 -1
  918. package/dist/commands/crash-cart.js +65 -17
  919. package/dist/commands/crash-cart.js.map +1 -1
  920. package/dist/commands/daemon.d.ts +7 -20
  921. package/dist/commands/daemon.d.ts.map +1 -1
  922. package/dist/commands/daemon.js +117 -46
  923. package/dist/commands/daemon.js.map +1 -1
  924. package/dist/commands/doctor.d.ts +26 -0
  925. package/dist/commands/doctor.d.ts.map +1 -1
  926. package/dist/commands/doctor.js +148 -2
  927. package/dist/commands/doctor.js.map +1 -1
  928. package/dist/commands/import.d.ts +5 -0
  929. package/dist/commands/import.d.ts.map +1 -1
  930. package/dist/commands/import.js +24 -4
  931. package/dist/commands/import.js.map +1 -1
  932. package/dist/commands/mcp.d.ts.map +1 -1
  933. package/dist/commands/mcp.js +4 -2
  934. package/dist/commands/mcp.js.map +1 -1
  935. package/dist/commands/network.d.ts +4 -0
  936. package/dist/commands/network.d.ts.map +1 -1
  937. package/dist/commands/network.js +78 -10
  938. package/dist/commands/network.js.map +1 -1
  939. package/dist/commands/provider.d.ts +5 -1
  940. package/dist/commands/provider.d.ts.map +1 -1
  941. package/dist/commands/provider.js +427 -17
  942. package/dist/commands/provider.js.map +1 -1
  943. package/dist/commands/ps.d.ts +16 -1
  944. package/dist/commands/ps.d.ts.map +1 -1
  945. package/dist/commands/ps.js +35 -4
  946. package/dist/commands/ps.js.map +1 -1
  947. package/dist/commands/queue-transfer.d.ts +10 -0
  948. package/dist/commands/queue-transfer.d.ts.map +1 -0
  949. package/dist/commands/queue-transfer.js +140 -0
  950. package/dist/commands/queue-transfer.js.map +1 -0
  951. package/dist/commands/queue.d.ts.map +1 -1
  952. package/dist/commands/queue.js +20 -6
  953. package/dist/commands/queue.js.map +1 -1
  954. package/dist/commands/scope.d.ts.map +1 -1
  955. package/dist/commands/scope.js +258 -17
  956. package/dist/commands/scope.js.map +1 -1
  957. package/dist/commands/seat.d.ts.map +1 -1
  958. package/dist/commands/seat.js +132 -23
  959. package/dist/commands/seat.js.map +1 -1
  960. package/dist/commands/setup.d.ts +34 -0
  961. package/dist/commands/setup.d.ts.map +1 -1
  962. package/dist/commands/setup.js +111 -18
  963. package/dist/commands/setup.js.map +1 -1
  964. package/dist/commands/terminal.d.ts +11 -0
  965. package/dist/commands/terminal.d.ts.map +1 -1
  966. package/dist/commands/terminal.js +10 -7
  967. package/dist/commands/terminal.js.map +1 -1
  968. package/dist/config-store.d.ts +9 -1
  969. package/dist/config-store.d.ts.map +1 -1
  970. package/dist/config-store.js +46 -0
  971. package/dist/config-store.js.map +1 -1
  972. package/dist/daemon-lifecycle.d.ts +53 -2
  973. package/dist/daemon-lifecycle.d.ts.map +1 -1
  974. package/dist/daemon-lifecycle.js +500 -192
  975. package/dist/daemon-lifecycle.js.map +1 -1
  976. package/dist/daemon-reachability.js +2 -2
  977. package/dist/daemon-reachability.js.map +1 -1
  978. package/dist/daemon-start-lock.d.ts +28 -0
  979. package/dist/daemon-start-lock.d.ts.map +1 -1
  980. package/dist/daemon-start-lock.js +107 -13
  981. package/dist/daemon-start-lock.js.map +1 -1
  982. package/dist/lib/seat-activity.d.ts +4 -1
  983. package/dist/lib/seat-activity.d.ts.map +1 -1
  984. package/dist/lib/seat-activity.js +4 -3
  985. package/dist/lib/seat-activity.js.map +1 -1
  986. package/dist/mcp-server.d.ts +2 -2
  987. package/dist/mcp-server.d.ts.map +1 -1
  988. package/dist/mcp-server.js +126 -27
  989. package/dist/mcp-server.js.map +1 -1
  990. package/dist/process-liveness.d.ts +21 -0
  991. package/dist/process-liveness.d.ts.map +1 -0
  992. package/dist/process-liveness.js +43 -0
  993. package/dist/process-liveness.js.map +1 -0
  994. package/dist/remote-host-ops.d.ts +1 -1
  995. package/dist/remote-host-ops.d.ts.map +1 -1
  996. package/dist/remote-host-ops.js +3 -14
  997. package/dist/remote-host-ops.js.map +1 -1
  998. package/dist/system-preflight.d.ts +9 -0
  999. package/dist/system-preflight.d.ts.map +1 -1
  1000. package/dist/system-preflight.js +27 -8
  1001. package/dist/system-preflight.js.map +1 -1
  1002. package/dist/tmux-health.d.ts +10 -1
  1003. package/dist/tmux-health.d.ts.map +1 -1
  1004. package/dist/tmux-health.js +31 -2
  1005. package/dist/tmux-health.js.map +1 -1
  1006. package/package.json +4 -2
  1007. package/scripts/check-abi.mjs +18 -2
  1008. package/tui/dist/attention/attention-model.d.ts +1 -1
  1009. package/tui/dist/attention/attention-model.d.ts.map +1 -1
  1010. package/tui/dist/attention/attention-model.js +6 -0
  1011. package/tui/dist/attention/attention-model.js.map +1 -1
  1012. package/tui/dist/daemon-client.d.ts +21 -2
  1013. package/tui/dist/daemon-client.d.ts.map +1 -1
  1014. package/tui/dist/daemon-client.js +36 -5
  1015. package/tui/dist/daemon-client.js.map +1 -1
  1016. package/tui/dist/hydrate.d.ts.map +1 -1
  1017. package/tui/dist/hydrate.js +6 -2
  1018. package/tui/dist/hydrate.js.map +1 -1
  1019. package/tui/dist/main.js +11 -8
  1020. package/tui/dist/main.js.map +1 -1
  1021. package/tui/dist/terminals/open-window.d.ts +9 -3
  1022. package/tui/dist/terminals/open-window.d.ts.map +1 -1
  1023. package/tui/dist/terminals/open-window.js +22 -4
  1024. package/tui/dist/terminals/open-window.js.map +1 -1
  1025. package/tui/dist/terminals/terminal-model.d.ts +3 -0
  1026. package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
  1027. package/tui/dist/terminals/terminal-model.js +6 -1
  1028. package/tui/dist/terminals/terminal-model.js.map +1 -1
  1029. package/tui/dist/topology/glyphs.d.ts.map +1 -1
  1030. package/tui/dist/topology/glyphs.js +11 -1
  1031. package/tui/dist/topology/glyphs.js.map +1 -1
  1032. package/tui/dist/topology/graph-types.d.ts +8 -0
  1033. package/tui/dist/topology/graph-types.d.ts.map +1 -1
  1034. package/tui/dist/types.d.ts +3 -2
  1035. package/tui/dist/types.d.ts.map +1 -1
  1036. package/ui/dist/assets/{index-DG_7XFcL.js → index-D7OUklzs.js} +148 -148
  1037. package/ui/dist/index.html +1 -1
@@ -1,9 +1,12 @@
1
+ import { isRosterReadyNotice } from "./roster-ready-notice.js";
2
+ import { queueDisplayText, QUEUE_DISPLAY_PREFIX_UNITS } from "./queue-display.js";
1
3
  import { RigDeliveryDrainStore } from "./rig-delivery-drain.js";
2
- import { PROMPT_ALERT_TAG, WAKE_ESCALATION_TAG, readWakeLadderBackstop, resolveWakeRetryCap } from "./queue-wake-ladder.js";
4
+ import { DRAFT_HELD_WAKE_RESULT, PROMPT_ALERT_TAG, WAKE_ESCALATION_TAG, readWakeLadderBackstop, resolveWakeRetryCap } from "./queue-wake-ladder.js";
3
5
  import { LADDER_ATTEMPT_PREFIX } from "./queue-stuck-sweep.js";
4
6
  import { withUrgentLine } from "./urgent-line.js";
5
7
  import { quietCustodyBackstop, quietHoldCustody } from "./quiet-hold-custody.js";
6
8
  import { cooperativeReadFile, readRowsCooperatively } from "./execution-candidate-reader.js";
9
+ import { AsyncLocalStorage } from "node:async_hooks";
7
10
  import { createHash } from "node:crypto";
8
11
  import { loadHumanRegistry, registeredPeople, resolveRegisteredHumanAddress, slackSubscriptionFor, withHumanAlertTag } from "./gateway/human-registry.js";
9
12
  import { DispatchBuffer } from "./gateway/dispatch-buffer.js";
@@ -19,7 +22,10 @@ export const MC_OPERATION_TAG_PREFIX = "mc-operation:";
19
22
  export function mcOperationTag(operation) {
20
23
  return `${MC_OPERATION_TAG_PREFIX}${operation}`;
21
24
  }
22
- import { HELD_SENDER_NOTICE_PREFIX, WAKE_INTENT_PREFIX } from "./outbox-handler.js";
25
+ import { DRAFT_HELD_ELIGIBLE_TAG, HELD_RETRY_NOT_ADMITTED, HELD_SENDER_NOTICE_PREFIX, WAKE_INTENT_PREFIX } from "./outbox-handler.js";
26
+ import { readStandbyStop } from "./seat-standby.js";
27
+ import { DRAFT_HELD_REOFFER_MS } from "./draft-held-reoffer.js";
28
+ /** A queue wake the draft-aware guard held for a draft in the input (#48). */
23
29
  import { physicalSessionName, SessionRegistry } from "./session-registry.js";
24
30
  import { derivePickup } from "./queue-pickup.js";
25
31
  import { withRecoveryIndex } from "./queue-recovery.js";
@@ -31,7 +37,7 @@ import { isBoundTerminalSeat } from "./terminal-seat.js";
31
37
  import { renderQueueHandoffNudge } from "./queue-nudge-text.js";
32
38
  import { getSelfHostId } from "./hosts/fanout-contract.js";
33
39
  import { parseSessionName, isHumanSeatSessionRef } from "./session-name.js";
34
- import { isEpisodeRelay, RELAY_CLAIMED_PREFIX, RELAY_FOR_PREFIX, RELAY_KEY_PREFIX, RELAY_TAG } from "./return-route.js";
40
+ import { isEpisodeRelay, isIssuedConversationAddress, RELAY_CLAIMED_PREFIX, RELAY_FOR_PREFIX, RELAY_KEY_PREFIX, RELAY_TAG } from "./return-route.js";
35
41
  import { nativeAskPastWindow, nativePermissionHook, nativeWindowEndedNote, plainYesOrNo, runnerPermissionOrigin } from "./runner-permissions.js";
36
42
  import { isHostPairingAsk } from "./hosts/pairing-ask.js";
37
43
  import { renderRelayedAnswers } from "./relayed-answers.js";
@@ -54,6 +60,7 @@ import { parseHumanQuestions, unansweredQuestions, describeTypedReplyPlacement,
54
60
  import { slackMicros } from "./gateway/slack/state-store.js";
55
61
  import { askBackRoute, RUNNER_CLOSE_WAITS, terminalAnswerMeaning } from "./receiver-context.js";
56
62
  import { runSyncSite, runSyncSiteWhenSlow } from "./sync-site-wrap.js";
63
+ import { resolveSeatKind, seatProcessOwner } from "./seat-kinds.js";
57
64
  /** A direct ask's answer row ID: from the ask, or from the ask and the park episode its answer belongs to. */
58
65
  function humanAnswerId(askId, episodeKey) {
59
66
  return `qitem-human-answer-${createHash("sha256").update(episodeKey ? `${askId}\n${episodeKey}` : askId).digest("hex").slice(0, 20)}`;
@@ -78,6 +85,11 @@ export const QUEUE_STATES = [
78
85
  * `handoff -> state=handed-off`, the highest-volume terminal class. The `satisfies`
79
86
  * clause is the compile guard: removing a state from QUEUE_STATES fails here. */
80
87
  export const TERMINAL_QUEUE_STATES = ["done", "handed-off"];
88
+ function appendClosingResolution(previous, outcome) {
89
+ if (typeof outcome !== "string" || !outcome.trim())
90
+ return previous;
91
+ return previous ? `${previous}\n${outcome}` : outcome;
92
+ }
81
93
  export function isTerminalState(state) {
82
94
  return TERMINAL_QUEUE_STATES.includes(state);
83
95
  }
@@ -168,6 +180,10 @@ function joinWakeBodies(members) {
168
180
  const FALLBACK_ACTOR = "system:queue-fallback";
169
181
  /** The actor a terminal act is recorded as when it names no responder: explicitly unattributed, never a person. */
170
182
  export const UNATTRIBUTED_ACTOR = "human@host";
183
+ /** Recorded on an ask whose answer is kept on it because its source's rig isn't known here (createHumanAnswer). */
184
+ export const ANSWER_NOT_RETURNED_PREFIX = "human-answer not returned:";
185
+ /** The second line of that note: who gave the kept answer. Their words follow it. */
186
+ const KEPT_ANSWER_FROM = "answered by: ";
171
187
  /**
172
188
  * #165: a claim is the destination acting on the row, which is stronger evidence than
173
189
  * the wake send could get. While the row is claimed, an unconfirmed wire result
@@ -546,15 +562,15 @@ export function detectTable(db, tableName) {
546
562
  * Phase A wires no-op; Phase B can plug in the rig registry to reject
547
563
  * phantom-rig destinations. POC compatibility: `qitem_id` shape preserved.
548
564
  */
549
- // Reduced column set for compact rows. `list`, `findOverdue` and `findUndelivered` all select it
550
- // (plus summary, through QueueRepository.compactColumns) and pass each row through compactRow, so
565
+ // Reduced column set for compact rows. `list`, `findOverdue` and `findUndelivered` select it plus
566
+ // the authored summary and a bounded body prefix (compactColumns), then pass each row through compactRow, so
551
567
  // the compact projection is one thing: present text is shown, and what isn't selected is left out
552
568
  // and named in fieldsElided, never backfilled as empty.
553
569
  const COMPACT_ELIDED_FIELDS = [
554
570
  "body", "evidenceRef", "humanDetail", "waiting", "chainOfRecord", "replyTo", "humanQuestions", "humanAnswers", "delegatedDecision",
555
571
  ];
556
572
  function compactRow(item) {
557
- const row = { ...item, fieldsElided: [...COMPACT_ELIDED_FIELDS] };
573
+ const row = { ...item, displayText: queueDisplayText(item.summary, item.body, item.qitemId), fieldsElided: [...COMPACT_ELIDED_FIELDS] };
558
574
  for (const field of COMPACT_ELIDED_FIELDS)
559
575
  delete row[field];
560
576
  return row;
@@ -699,8 +715,10 @@ export class QueueRepository {
699
715
  * best-effort {@link maybeNudge} when no store is attached (P34 made that
700
716
  * fallback real code rather than a promise in a comment). */
701
717
  outbox;
718
+ hasTransferFence;
702
719
  /** #2829 slice 1 — cold-start notifier, late-wired by startup after the restore orchestrator exists. */
703
720
  wakeWithoutReceiverNotifier;
721
+ standbyWake;
704
722
  // A first clear may recover durable refusals observed before startup. Later clears need
705
723
  // a new positive refusal/attention episode, so a returning prompt cannot spin retries.
706
724
  promptRecoveryState = new Map();
@@ -720,6 +738,7 @@ export class QueueRepository {
720
738
  hasSummaryColumn;
721
739
  hasHumanIntentColumn;
722
740
  hasReplyToColumn;
741
+ hasNetworkWaitColumn;
723
742
  hasReturnRouteColumn;
724
743
  hasHumanQuestionsColumn;
725
744
  hasDelegatedDecisionColumn;
@@ -732,6 +751,7 @@ export class QueueRepository {
732
751
  hasTransitionProvenanceColumn;
733
752
  hasOwnerNotificationColumns;
734
753
  loadHumanRegistryFn;
754
+ humanRegistryMemo = new AsyncLocalStorage();
735
755
  /** Registered shared channels (0.7.3): `<id>@external` participants whose rows post to their Slack channel. */
736
756
  sharedChannelsFn;
737
757
  readSharedChannelsFn;
@@ -750,6 +770,7 @@ export class QueueRepository {
750
770
  workflowFrontierPredicate;
751
771
  constructor(db, eventBus, opts) {
752
772
  this.db = db;
773
+ this.hasTransferFence = detectTable(db, "queue_transfer_relinquished");
753
774
  this.deliveryDrains = new RigDeliveryDrainStore(db);
754
775
  this.eventBus = eventBus;
755
776
  this.transitionLog = new QueueTransitionLog(db);
@@ -776,6 +797,7 @@ export class QueueRepository {
776
797
  this.hasSummaryColumn = detectQueueColumn(db, "summary");
777
798
  this.hasHumanIntentColumn = detectQueueColumn(db, "human_intent");
778
799
  this.hasReplyToColumn = detectQueueColumn(db, "reply_to");
800
+ this.hasNetworkWaitColumn = !!db.prepare("SELECT 1 FROM pragma_table_info('network_requests') WHERE name = 'remote_wait'").get();
779
801
  this.hasReturnRouteColumn = detectQueueColumn(db, "return_route");
780
802
  this.hasHumanQuestionsColumn = detectQueueColumn(db, "human_questions");
781
803
  this.hasDelegatedDecisionColumn = detectQueueColumn(db, "delegated_decision");
@@ -845,10 +867,13 @@ export class QueueRepository {
845
867
  this.transport = transport;
846
868
  transport.configureGuardedWakes?.(entries => entries.every(entry => {
847
869
  const row = entry.auditPointer ? this.getById(entry.auditPointer) : null;
848
- if (!row || row.destinationSession !== entry.destinationSession)
870
+ if (!row || this.transferFence(row.qitemId) || row.destinationSession !== entry.destinationSession)
849
871
  return false;
850
872
  return entry.outboxId.startsWith(WAKE_INTENT_PREFIX) ? this.currentWakeIntent(entry) : isBlockerLive(row.state);
851
- }));
873
+ }), qitemId => !!this.transferFence(qitemId));
874
+ // A retry the bridge already has was admitted by its pass, so only a drain or a restore holds it now, as the bridge's
875
+ // own waiter would; the pass's own admission (draft-aware mode too) is in deliverDraftHeldMessagesOnIdle.
876
+ transport.configureHeldRetryAdmission?.(sessionName => !this.draftHeldPaused(sessionName));
852
877
  }
853
878
  currentWakeIntent(entry) {
854
879
  const row = entry.auditPointer ? this.db.prepare("SELECT state, destination_session FROM queue_items WHERE qitem_id=?").get(entry.auditPointer) : undefined;
@@ -1008,13 +1033,16 @@ export class QueueRepository {
1008
1033
  attachWakeWithoutReceiverNotifier(notifier) {
1009
1034
  this.wakeWithoutReceiverNotifier = notifier;
1010
1035
  }
1036
+ attachStandbyWake(wake) {
1037
+ this.standbyWake = wake;
1038
+ }
1011
1039
  /** The one transition-write classifier. It consumes structured state/action facts only. */
1012
1040
  classifyOwnerNotification(input) {
1013
1041
  if (input.explicitKind === "human-decision-resolved") {
1014
1042
  return { kind: input.explicitKind, level: "NOTICE" };
1015
1043
  }
1016
1044
  // Nobody registered yet isn't a broken registry: a row to a registered shared channel still posts (0.7.3).
1017
- const people = registeredPeople(this.loadHumanRegistryFn());
1045
+ const people = registeredPeople(this.readHumanRegistry());
1018
1046
  if (!people)
1019
1047
  return null;
1020
1048
  const blockedHuman = resolveRegisteredHumanAddress(input.nextBlockedOn, people);
@@ -1119,7 +1147,7 @@ export class QueueRepository {
1119
1147
  const parsed = parseSessionName(sender);
1120
1148
  if (parsed.kind !== "external")
1121
1149
  return false;
1122
- const people = registeredPeople(this.loadHumanRegistryFn());
1150
+ const people = registeredPeople(this.readHumanRegistry());
1123
1151
  if (people === null)
1124
1152
  return false;
1125
1153
  const channels = this.readSharedChannelsFn();
@@ -1161,9 +1189,13 @@ export class QueueRepository {
1161
1189
  this.outbox.assertRetentionCapacity(draftTarget.nodeId, frozenEnvelope, input.fromSession, [input.outboxId]);
1162
1190
  this.outbox.record(record);
1163
1191
  const binding = this.transport?.deliveryTarget?.(input.toSession);
1164
- if (binding)
1192
+ if (binding) {
1193
+ const standby = readStandbyStop(this.db, binding.nodeId);
1194
+ const bindingHasReceiver = standby?.session !== binding.session || standby.pane !== binding.pane;
1195
+ const target = bindingHasReceiver ? binding : { ...binding, pane: null };
1165
1196
  this.db.prepare("UPDATE outbox_entries SET guard_binding=? WHERE outbox_id=? AND guard_binding IS NULL")
1166
- .run(JSON.stringify(binding), input.outboxId);
1197
+ .run(JSON.stringify(target), input.outboxId);
1198
+ }
1167
1199
  }
1168
1200
  return input.outboxId;
1169
1201
  }
@@ -1178,12 +1210,34 @@ export class QueueRepository {
1178
1210
  tags: [AUTO_UNPARK_WAKE_TAG, WAKE_TRIGGER_OPENRIG_TAG, `${AUTO_UNPARK_BLOCKER_TAG_PREFIX}${input.blockerQitemId}`, `queue:return:${input.blockerQitemId}`],
1179
1211
  });
1180
1212
  }
1213
+ get hasWakeIntentStore() {
1214
+ return this.outbox !== undefined;
1215
+ }
1216
+ transferFence(qitemId) {
1217
+ if (!this.hasTransferFence)
1218
+ return undefined;
1219
+ const fence = this.db.prepare(`SELECT destination_host_id AS destinationHostId,
1220
+ archive_digest AS archiveDigest, reconciled_at AS reconciledAt FROM queue_transfer_relinquished WHERE qitem_id = ?`).get(qitemId);
1221
+ return fence && { fenced: true, ...fence };
1222
+ }
1223
+ assertNotFenced(qitemId) {
1224
+ const fence = this.transferFence(qitemId);
1225
+ if (fence)
1226
+ throw new QueueRepositoryError("qitem_fenced", `fenced: ${fence.reconciledAt ? "retained after reconciliation" : "awaiting reconciliation"} (transfer ${fence.archiveDigest.slice(0, 12)})`, fence);
1227
+ }
1228
+ dispatchableTransferRow() {
1229
+ return this.hasTransferFence ? "queue_items.qitem_id NOT IN (SELECT qitem_id FROM queue_transfer_relinquished)" : "1";
1230
+ }
1231
+ deliverWakeIntentsAfterCommit(ids) {
1232
+ for (const id of ids)
1233
+ this.deliverWakeIntentAfterCommit(id);
1234
+ }
1181
1235
  deliverWakeIntentAfterCommit(outboxId) {
1182
- queueMicrotask(() => {
1236
+ queueMicrotask(() => this.humanRegistryMemo.exit(() => {
1183
1237
  void this.deliverWakeIntent(outboxId).catch((err) => {
1184
1238
  console.error(`Queue wake delivery failed for ${outboxId}:`, err);
1185
1239
  });
1186
- });
1240
+ }));
1187
1241
  }
1188
1242
  /**
1189
1243
  * W1-c (transactional closure): the runtime SEAM GUARD. Called as the LAST
@@ -1251,7 +1305,7 @@ export class QueueRepository {
1251
1305
  this.db.prepare("UPDATE outbox_entries SET tags = ? WHERE outbox_id = ?").run(JSON.stringify(tags), outboxId);
1252
1306
  }
1253
1307
  async deliverWakeIntent(outboxId, attempted = new Set(), // this pass's attempt history, inherited by any release it delivers
1254
- eligible = () => true) {
1308
+ eligible = () => true, mayWake = eligible) {
1255
1309
  if (!this.outbox)
1256
1310
  return "skipped";
1257
1311
  if (!this.transport)
@@ -1259,6 +1313,8 @@ export class QueueRepository {
1259
1313
  if (attempted.has(outboxId))
1260
1314
  return "skipped";
1261
1315
  const alreadyHeld = this.outbox.getById(outboxId);
1316
+ if (alreadyHeld?.auditPointer && this.transferFence(alreadyHeld.auditPointer))
1317
+ return "skipped";
1262
1318
  if (alreadyHeld?.deliveryState === "retained" || alreadyHeld?.deliveryState === "retired") {
1263
1319
  if (this.deliveryDrains.holds(alreadyHeld.destinationSession))
1264
1320
  return "retained";
@@ -1266,7 +1322,22 @@ export class QueueRepository {
1266
1322
  this.recordNudgeAttempt(alreadyHeld.auditPointer, "retained:typing_guard");
1267
1323
  return "retained";
1268
1324
  }
1325
+ const standbyWorkId = alreadyHeld?.auditPointer;
1326
+ if (standbyWorkId && (alreadyHeld.deliveryState === "pending" || alreadyHeld.deliveryState === "failed")) {
1327
+ const owed = () => {
1328
+ const entry = this.outbox?.getById(outboxId);
1329
+ const row = this.getById(standbyWorkId);
1330
+ return !!entry && entry.deliveryState === alreadyHeld.deliveryState && !!row && isBlockerLive(row.state)
1331
+ && row.destinationSession === entry.destinationSession && !this.deliveryDrains.holds(entry.destinationSession)
1332
+ && this.currentWakeIntent(entry) && mayWake(entry);
1333
+ };
1334
+ const starting = this.standbyWake?.(alreadyHeld.destinationSession, owed);
1335
+ if (starting && (!await starting || !owed()))
1336
+ return "skipped";
1337
+ }
1269
1338
  const claim = (entry) => {
1339
+ if (entry.auditPointer && this.transferFence(entry.auditPointer))
1340
+ return false;
1270
1341
  if (this.deliveryDrains.holds(entry.destinationSession) || !eligible(entry) || attempted.has(entry.outboxId))
1271
1342
  return false;
1272
1343
  let rebound;
@@ -1386,10 +1457,16 @@ export class QueueRepository {
1386
1457
  return "indeterminate";
1387
1458
  }
1388
1459
  const released = [];
1460
+ // Splitting members by level is the recheck's job; a single member has no peer to split from and already
1461
+ // carries its own source. The send's notificationCurrent checks its fence and intent after waiting for the seat.
1389
1462
  const recheckMembers = group.length < 2 ? undefined : (holds, held) => {
1390
- const keep = group.filter((entry, i) => {
1463
+ const current = (entry) => entry.auditPointer && !this.transferFence(entry.auditPointer) && this.currentWakeIntent(entry);
1464
+ // Without the lead, let surviving members retry under their own admission instead of borrowing the lead's.
1465
+ const keep = !current(intent) ? [] : group.filter((entry, i) => {
1391
1466
  if (i === 0)
1392
1467
  return true;
1468
+ if (!current(entry) || !entry.auditPointer)
1469
+ return false;
1393
1470
  const memberTrigger = entry.tags?.includes(WAKE_TRIGGER_OPENRIG_TAG) ? "openrig" : "agent";
1394
1471
  const admission = this.wakeAdmission(entry.auditPointer, memberTrigger);
1395
1472
  return holds({ source: admission.source, urgent: admission.urgent }) === held;
@@ -1405,9 +1482,19 @@ export class QueueRepository {
1405
1482
  })();
1406
1483
  released.push(entry);
1407
1484
  }
1408
- return { text: recoveryNotice(keep) + joinWakeBodies(keep), outboxIds: keep.map(entry => entry.outboxId) };
1485
+ return keep.length > 0 && { text: recoveryNotice(keep) + joinWakeBodies(keep), outboxIds: keep.map(entry => entry.outboxId) };
1409
1486
  };
1410
1487
  const outcome = await this.performWakeSend(qitemId, intent.destinationSession, intent.senderSession, undefined, recoveryNotice(group) + joinWakeBodies(group), group.map(entry => entry.outboxId), trigger, recheckMembers);
1488
+ // A lone member whose row was fenced while it waited for the seat: the transport wrote nothing (its
1489
+ // notificationCurrent check refused), so the entry goes back exactly as it was for the transfer to settle.
1490
+ // That is not a refusal to record — only a closed or transferred row ends a wake, never a park that moved.
1491
+ if (group.length === 1 && outcome.preInputFailure === true && intent.auditPointer && this.transferFence(intent.auditPointer)) {
1492
+ for (const entry of group) {
1493
+ this.db.prepare("UPDATE outbox_entries SET delivery_state = ? WHERE outbox_id = ? AND delivery_state = 'sending'")
1494
+ .run(entry.deliveryState, entry.outboxId);
1495
+ }
1496
+ return "skipped";
1497
+ }
1411
1498
  // A bridged wake isn't confirmed, so the pass counts it as unconfirmed; its row is the bridge's to settle.
1412
1499
  let reportedState = outcome.classified === "verified" ? "delivered"
1413
1500
  : outcome.classified === "bridged" ? "indeterminate" : outcome.classified;
@@ -1480,7 +1567,7 @@ export class QueueRepository {
1480
1567
  for (const entry of released) {
1481
1568
  await this.deliverWakeIntent(entry.outboxId, attempted, eligible).catch((err) => console.error(`Queue wake delivery failed for ${entry.outboxId}:`, err));
1482
1569
  }
1483
- return reportedState;
1570
+ return released.length === group.length ? "skipped" : reportedState;
1484
1571
  }
1485
1572
  /** Deliver after the queue transaction commits, never from inside it. The shared
1486
1573
  * intent path owns claims and outcomes; without an intent store use the legacy nudge. */
@@ -1541,8 +1628,9 @@ export class QueueRepository {
1541
1628
  // A stop also refuses every later claim inside a delivery: coalesced peers and members it releases for their own send.
1542
1629
  // So does a missing receiver, for a notification already tried. One never tried still gets its attempt, so its row
1543
1630
  // records why it didn't land.
1631
+ const mayWake = (entry) => !opts?.stopRequested?.() && (!opts?.eligible || opts.eligible(entry));
1544
1632
  const eligible = (entry) => {
1545
- if (opts?.stopRequested?.() || opts?.eligible && !opts.eligible(entry))
1633
+ if (!mayWake(entry))
1546
1634
  return false;
1547
1635
  if (entry.deliveryState === "pending" || !this.wakeHasNoReceiver(entry.destinationSession, coldStartPass))
1548
1636
  return true;
@@ -1564,7 +1652,7 @@ export class QueueRepository {
1564
1652
  if (opts?.stopRequested?.())
1565
1653
  return result();
1566
1654
  cursor = intent.id;
1567
- const outcome = await this.deliverWakeIntent(intent.outbox_id, attempted, eligible);
1655
+ const outcome = await this.deliverWakeIntent(intent.outbox_id, attempted, eligible, mayWake);
1568
1656
  if (outcome !== "skipped")
1569
1657
  tally[outcome]++;
1570
1658
  }
@@ -1632,11 +1720,17 @@ export class QueueRepository {
1632
1720
  async maybeNudge(qitemId, destinationSession, nudgeOpt, sourceSession, bodyOverride, trigger = "agent", opts) {
1633
1721
  if (nudgeOpt === false)
1634
1722
  return;
1723
+ // A relinquished row's ownership moved to the destination; its fence stops this legacy
1724
+ // dispatch path too, not only the durable wake-intent drain that checks it at claim.
1725
+ if (this.transferFence(qitemId))
1726
+ return;
1635
1727
  if (!opts?.explicit && this.deliveryDrains.holds(destinationSession))
1636
1728
  return;
1637
1729
  if (!this.transport)
1638
1730
  return;
1639
1731
  const outcome = await this.performWakeSend(qitemId, destinationSession, sourceSession, bodyOverride, undefined, undefined, trigger, undefined, opts?.explicit === true);
1732
+ if (this.transferFence(qitemId))
1733
+ return;
1640
1734
  // #2829 slice 1 — `preInputFailure` is the honest no-receiver shape: the input phase
1641
1735
  // was never reached and nothing was sent, meaning the seat was gone before the wake
1642
1736
  // could be typed. The positive-evidence check itself rides the shared send path
@@ -1806,35 +1900,212 @@ export class QueueRepository {
1806
1900
  }
1807
1901
  /** #48: a queue wake the draft-aware guard held is tried again when its seat reports idle, through the same guarded
1808
1902
  * delivery, which re-checks the input and holds it again if it still can't go. Only while the seat is still in
1809
- * draft-aware mode: switching modes alone replays nothing, and a retry already admitted goes once. Only rows created
1810
- * straight to the seat: a handed-off row's retries are the wake ladder's. A hold-mode wake is never retried. Each try
1811
- * is one of the ladder's attempts, so the existing wake retry cap bounds them; the ladder's one held notice comes past
1812
- * that cap or the unconfirmed window. */
1903
+ * draft-aware mode: switching modes alone replays nothing, and a retry already admitted goes once. A row created to
1904
+ * the seat and a `rig queue handoff` successor alike (#4041): the wake ladder doesn't retry these on its timer
1905
+ * (idleRetriedDraftHold), so each has one retry owner. A hold-mode wake is never retried. Each try is one of the
1906
+ * ladder's attempts, so the existing wake retry cap bounds them; the ladder's one held notice comes past that cap or
1907
+ * the unconfirmed window. */
1813
1908
  async retryDraftHeldWakesOnIdle(sessionName, state) {
1814
1909
  if (state !== "idle" || !this.outbox || !this.transport?.draftAwareTarget?.(sessionName))
1815
- return;
1910
+ return "skipped";
1816
1911
  const addresses = this.resolveSessionAddresses(sessionName);
1817
- if (!addresses.length || addresses.some(address => this.deliveryDrains.holds(address)))
1818
- return;
1912
+ if (!addresses.length)
1913
+ return "skipped";
1914
+ if (addresses.some(address => this.deliveryDrains.holds(address)))
1915
+ return "paused";
1819
1916
  // As for a prompt clear (#2575): while a compaction's restore is owed, the wake would reach the agent before it.
1820
1917
  if ([sessionName, ...addresses].some(address => this.hasPendingPostCompactStage?.(address)))
1821
- return;
1918
+ return "paused";
1822
1919
  const rows = this.db.prepare(`SELECT qitem_id FROM queue_items WHERE state = 'pending' AND claimed_at IS NULL
1823
- AND handed_off_from IS NULL AND destination_session IN (${addresses.map(() => "?").join(",")})
1824
- AND last_nudge_result = 'retained:draft_aware' ORDER BY ts_created, qitem_id`).all(...addresses);
1920
+ AND destination_session IN (${addresses.map(() => "?").join(",")})
1921
+ AND last_nudge_result = ? ORDER BY ts_created, qitem_id`).all(...addresses, DRAFT_HELD_WAKE_RESULT);
1825
1922
  const cap = resolveWakeRetryCap();
1826
- for (const { qitem_id } of rows) {
1827
- const intent = `${WAKE_INTENT_PREFIX}${qitem_id}`;
1923
+ let held = false;
1924
+ let paused = false;
1925
+ rowsLoop: for (const { qitem_id } of rows) {
1926
+ if (this.transferFence(qitem_id))
1927
+ continue;
1928
+ // A drain or a restore that started while an earlier row's delivery awaited stops the pass before this row is
1929
+ // reopened: no try, and the offer is kept.
1930
+ if (this.draftHeldPaused(sessionName, addresses)) {
1931
+ paused = true;
1932
+ break;
1933
+ }
1828
1934
  const after = lastMeaningfulTransition(this.db, qitem_id)?.id ?? 0;
1829
1935
  const tries = this.db.prepare(`SELECT COUNT(*) AS n FROM queue_transitions WHERE qitem_id = ? AND transition_id > ?
1830
1936
  AND transition_note LIKE '${LADDER_ATTEMPT_PREFIX}%'`).get(qitem_id, after).n;
1831
- if (tries >= cap || !this.outbox.reopenHeld(intent))
1937
+ if (tries >= cap) {
1938
+ held = true;
1832
1939
  continue;
1833
- const outcome = await this.deliverWakeIntent(intent);
1834
- const row = this.getById(qitem_id);
1835
- if (row)
1940
+ }
1941
+ // The row's held wake, whichever intent holds it: its own, an unpark's or a reroute's, as the ladder's retry selects.
1942
+ const intents = this.db.prepare(`SELECT outbox_id FROM outbox_entries WHERE audit_pointer = ? AND substr(outbox_id, 1, ?) = ?
1943
+ AND delivery_state = 'retained' ORDER BY rowid`).all(qitem_id, WAKE_INTENT_PREFIX.length, WAKE_INTENT_PREFIX);
1944
+ for (const { outbox_id: intent } of intents) {
1945
+ if (!this.outbox.reopenHeld(intent))
1946
+ continue;
1947
+ const outcome = await this.deliverWakeIntent(intent);
1948
+ // Not sent: a drain or a restore met it at its claim. No try is recorded, and the offer is kept. The entry stays
1949
+ // owed as pending, which the drain's end (or wake recovery) sends again.
1950
+ if (outcome === "skipped") {
1951
+ paused = true;
1952
+ continue;
1953
+ }
1954
+ const row = this.getById(qitem_id);
1955
+ if (!row)
1956
+ continue rowsLoop;
1957
+ const result = row.lastNudgeResult ?? outcome;
1958
+ if (result === DRAFT_HELD_WAKE_RESULT) {
1959
+ held = true;
1960
+ // One burst of observations is one try: the observations around a single Enter (the agent's Stop, a pane change)
1961
+ // can arrive inside the guard's quiet window together. A hold within that window of this row's previous held try
1962
+ // records nothing, so it doesn't spend the cap that #48's escalation counts.
1963
+ const last = this.db.prepare(`SELECT ts, transition_note AS note FROM queue_transitions WHERE qitem_id = ? AND transition_id > ?
1964
+ AND transition_note LIKE '${LADDER_ATTEMPT_PREFIX}%' ORDER BY transition_id DESC LIMIT 1`).get(qitem_id, after);
1965
+ if (last && last.note.includes(`outcome=${DRAFT_HELD_WAKE_RESULT}`) && Date.now() - Date.parse(last.ts) < DRAFT_HELD_REOFFER_MS)
1966
+ continue;
1967
+ }
1836
1968
  this.transitionLog.append({ qitemId: qitem_id, state: row.state, actorSession: "wake-ladder@system",
1837
- transitionNote: `${LADDER_ATTEMPT_PREFIX} ${tries + 1}/${cap} outcome=${row.lastNudgeResult ?? outcome} trigger=seat-idle` });
1969
+ transitionNote: `${LADDER_ATTEMPT_PREFIX} ${tries + 1}/${cap} outcome=${result} trigger=seat-idle` });
1970
+ }
1971
+ }
1972
+ return paused ? "paused" : held ? "draft" : "done";
1973
+ }
1974
+ /** Whether this seat's idle report and the periodic offer can retry its draft-held queue wakes: it's in draft-aware
1975
+ * mode. While it is, a draft-held handoff successor's retries are theirs; otherwise the wake ladder keeps them (#344). */
1976
+ draftHeldIdleRetryOwns(sessionName) {
1977
+ return !!this.outbox && !!this.transport?.draftAwareTarget?.(sessionName);
1978
+ }
1979
+ /** Seats with draft-held queue wakes, each with its newest try's time, or for a wake not tried yet the time it was held:
1980
+ * the periodic offer gives each such time one offer after the quiet interval (createDraftHeldReoffer). So a held wake
1981
+ * whose draft is cleared with no activity report is still tried. Reads pending rows by state. */
1982
+ draftHeldWakeSeats() {
1983
+ const rows = this.db.prepare(`SELECT qitem_id AS qitemId, destination_session AS session, last_nudge_attempt AS heldAt
1984
+ FROM queue_items WHERE state = 'pending' AND claimed_at IS NULL AND last_nudge_result = ?`)
1985
+ .all(DRAFT_HELD_WAKE_RESULT);
1986
+ // Only this wake's tries count, those after the row's last meaningful transition, as the pass counts them: a try from
1987
+ // an earlier wake of the same row doesn't stand for a new hold that has had none.
1988
+ const since = lastMeaningfulTransitionMany(this.db, rows.map(row => row.qitemId));
1989
+ const lastTry = new Map();
1990
+ for (const row of rows) {
1991
+ const tried = this.db.prepare(`SELECT MAX(ts) AS ts FROM queue_transitions WHERE qitem_id = ? AND transition_id > ?
1992
+ AND transition_note LIKE '${LADDER_ATTEMPT_PREFIX}%'`).get(row.qitemId, since.get(row.qitemId)?.id ?? 0).ts;
1993
+ const at = tried ?? row.heldAt;
1994
+ if (at !== null && at > (lastTry.get(row.session) ?? ""))
1995
+ lastTry.set(row.session, at);
1996
+ }
1997
+ return [...lastTry].map(([session, at]) => ({ session, lastTry: at }));
1998
+ }
1999
+ /** Seats with a draft-held delivery pass running, so overlapping idle observations don't race each other. */
2000
+ draftHeldPasses = new Set();
2001
+ /** Whether a drain or a pending restore stops draft-held delivery to this seat now, at any of its addresses (#3991). */
2002
+ draftHeldPaused(sessionName, addresses = this.resolveSessionAddresses(sessionName)) {
2003
+ return addresses.some(address => this.deliveryDrains.holds(address))
2004
+ || [sessionName, ...addresses].some(address => this.hasPendingPostCompactStage?.(address));
2005
+ }
2006
+ /** The seats holding draft-held messages, for the periodic offer (createDraftHeldReoffer); none without an outbox. */
2007
+ draftHeldSeats() {
2008
+ return this.outbox?.draftHeldSeats() ?? [];
2009
+ }
2010
+ /** Messages held only for a draft in the seat's input (tagged {@link DRAFT_HELD_ELIGIBLE_TAG} when first held) go once the
2011
+ * seat is idle under the draft-aware guard, oldest first, each through the existing guarded delivery: it reads the
2012
+ * input again and holds the message again if the input still isn't clear, and every other delivery condition applies.
2013
+ * Each message keeps its own outcome, and the pass stops at the first that isn't delivered, so order holds; one whose own
2014
+ * paste was refused is withdrawn and no longer holds the rest, so the pass goes on past it. Only a held
2015
+ * entry is reopened (compare-and-set), so a delivered, in-flight or uncertain one is never sent again. Messages held
2016
+ * before this behaviour, hold-mode messages and other held reasons carry no tag and stay held.
2017
+ *
2018
+ * The list is read again before each message, so one held while the pass runs (a later message behind an earlier one
2019
+ * from its sender) goes in its turn. Each send re-reads the pass's own conditions (draft-aware mode, drain, restore)
2020
+ * under its delivery lease (`retryAdmission`), so a change that took effect while it waited keeps it held. The result
2021
+ * says how the pass ended, for the periodic offer (DraftHeldReoffer). */
2022
+ async deliverDraftHeldMessagesOnIdle(sessionName, state) {
2023
+ if (state !== "idle" || !this.outbox || !this.transport?.draftAwareTarget?.(sessionName))
2024
+ return "skipped";
2025
+ const addresses = this.resolveSessionAddresses(sessionName);
2026
+ if (!addresses.length)
2027
+ return "skipped";
2028
+ const paused = () => this.draftHeldPaused(sessionName, addresses);
2029
+ if (paused())
2030
+ return "paused";
2031
+ const key = addresses[0];
2032
+ if (this.draftHeldPasses.has(key))
2033
+ return "skipped";
2034
+ this.draftHeldPasses.add(key);
2035
+ // Entries this pass has already taken or left (another occupant's custody), so a re-read never takes one twice.
2036
+ const seen = new Set();
2037
+ try {
2038
+ for (;;) {
2039
+ const next = this.db.prepare(`SELECT outbox_id FROM outbox_entries WHERE delivery_state = 'retained'
2040
+ AND destination_session IN (${addresses.map(() => "?").join(",")})
2041
+ AND EXISTS (SELECT 1 FROM json_each(COALESCE(outbox_entries.tags,'[]')) WHERE value = ?)
2042
+ ORDER BY ts_dispatched, rowid`).all(...addresses, DRAFT_HELD_ELIGIBLE_TAG)
2043
+ .find(row => !seen.has(row.outbox_id));
2044
+ if (!next)
2045
+ return "done";
2046
+ const { outbox_id } = next;
2047
+ seen.add(outbox_id);
2048
+ // A restore or drain can start while the preceding send awaited its delivery lease.
2049
+ if (paused())
2050
+ return "paused";
2051
+ const target = this.transport.draftAwareTarget?.(sessionName);
2052
+ if (!target)
2053
+ return "paused";
2054
+ const entry = this.outbox.getById(outbox_id);
2055
+ // Match the same complete binding as the transport guard. Earlier-occupant custody remains held and listed,
2056
+ // without being claimed or preventing a later message for the current occupant from going.
2057
+ if (!entry?.guardBinding || JSON.stringify(entry.guardBinding) !== JSON.stringify(target))
2058
+ continue;
2059
+ if (!this.outbox.reopenHeld(outbox_id))
2060
+ return "done";
2061
+ if (!this.outbox.claimForDelivery(outbox_id))
2062
+ return "done";
2063
+ let heldFor;
2064
+ try {
2065
+ const result = await this.transport.send(entry.destinationSession, entry.body, {
2066
+ committedOutboxIds: [outbox_id], actorSession: entry.senderSession,
2067
+ ...(entry.auditPointer ? { auditPointer: entry.auditPointer } : {}),
2068
+ retryAdmission: () => !paused() && !!this.transport?.draftAwareTarget?.(sessionName),
2069
+ });
2070
+ heldFor = result.reason;
2071
+ if ((result.reason === "guard_target_changed" || result.reason === HELD_RETRY_NOT_ADMITTED) && result.sent !== true
2072
+ && (result.sent === false || result.inputPhase === "not_reached")
2073
+ && result.inputPhase !== "attempted" && result.inputPhase !== "written") {
2074
+ // Custody, the mode, a drain or a restore can change while the transport waits for the lease. This positive
2075
+ // no-write result returns the already-held message to its list, even if a conditional transport finalized its
2076
+ // refusal first. A changed occupant leaves later messages for the current one free to go; the others stop.
2077
+ this.outbox.retainUnwritten(outbox_id);
2078
+ if (result.reason === HELD_RETRY_NOT_ADMITTED)
2079
+ return "paused";
2080
+ continue;
2081
+ }
2082
+ if (this.outbox.getById(outbox_id)?.deliveryState === "sending") {
2083
+ // An early guard refusal can precede the transport's receipt handling. Settle this claim by the existing
2084
+ // outcome rules, without a destination: a plain message must never tell cold start to start its seat.
2085
+ const outcome = this.classifyWakeResult(result);
2086
+ if (outcome.classified !== "bridged")
2087
+ this.outbox.finalizeDelivery(outbox_id, outcome.classified === "verified" ? "delivered" : outcome.classified);
2088
+ }
2089
+ }
2090
+ catch (error) {
2091
+ // A thrown send has no positive no-write result. Keep its uncertainty, never an in-flight or retryable claim.
2092
+ this.outbox.finalizeDelivery(outbox_id, "indeterminate");
2093
+ throw error;
2094
+ }
2095
+ const settled = this.outbox.getById(outbox_id);
2096
+ const after = settled?.deliveryState;
2097
+ // Its own paste was refused before anything was written, which withdrew it from automatic retry (it stays held,
2098
+ // with its result). It no longer holds later messages back, so the pass goes on to them rather than ending as a draft.
2099
+ if (after === "retained" && !settled?.tags?.includes(DRAFT_HELD_ELIGIBLE_TAG))
2100
+ continue;
2101
+ // Held again because the guard couldn't read the input or its clients' activity: uncertainty, not a draft seen,
2102
+ // so the periodic offer keeps trying (DraftHeldReoffer) while the guard still decides each delivery.
2103
+ if (after !== "delivered")
2104
+ return after === "retained" ? heldFor === "draft_input_unknown" ? "unknown" : "draft" : "done";
2105
+ }
2106
+ }
2107
+ finally {
2108
+ this.draftHeldPasses.delete(key);
1838
2109
  }
1839
2110
  }
1840
2111
  /** #48: the wake ladder's one notice to a held row's sender in one held episode, recorded in the outbox before the ladder
@@ -1857,11 +2128,20 @@ export class QueueRepository {
1857
2128
  const entry = this.outbox.getById(outboxId);
1858
2129
  if (!entry)
1859
2130
  return "skipped:no notice";
2131
+ const notificationCurrent = () => !entry.auditPointer || !this.transferFence(entry.auditPointer);
2132
+ if (!notificationCurrent())
2133
+ return "skipped:transfer fence";
1860
2134
  if (!this.outbox.claimUnsent(outboxId))
1861
2135
  return `skipped:${entry.deliveryState}`;
1862
2136
  let outcome;
1863
2137
  try {
1864
- outcome = this.classifyWakeResult(await this.transport.send(entry.destinationSession, wrapPaneEnvelope(OPENRIG_SENDER, entry.destinationSession, entry.body), { verify: true, actorSession: OPENRIG_SENDER, openrigNotice: true }));
2138
+ const result = await this.transport.send(entry.destinationSession, wrapPaneEnvelope(OPENRIG_SENDER, entry.destinationSession, entry.body), { verify: true, actorSession: OPENRIG_SENDER, openrigNotice: true, auditPointer: entry.auditPointer ?? undefined, notificationCurrent });
2139
+ if (result.reason === "draft_wake_superseded" && !notificationCurrent()) {
2140
+ this.db.prepare("UPDATE outbox_entries SET delivery_state = ? WHERE outbox_id = ? AND delivery_state = 'sending'")
2141
+ .run(entry.deliveryState, outboxId);
2142
+ return "skipped:transfer fence";
2143
+ }
2144
+ outcome = this.classifyWakeResult(result);
1865
2145
  }
1866
2146
  catch (error) {
1867
2147
  const message = error instanceof Error ? error.message : String(error);
@@ -1894,11 +2174,16 @@ export class QueueRepository {
1894
2174
  /** #48: the wake ladder's one notice to a held row's sender, sent as OpenRig through the same guarded transport (the
1895
2175
  * sender's own guard applies), with no custody: the path for a repository with no outbox. Returns the outcome for the
1896
2176
  * ladder's record. */
1897
- async noticeHeldSender(sender, body) {
2177
+ async noticeHeldSender(sender, body, qitemId) {
1898
2178
  if (!this.transport)
1899
2179
  return "skipped:no transport";
2180
+ const notificationCurrent = () => !this.transferFence(qitemId);
2181
+ if (!notificationCurrent())
2182
+ return "skipped:transfer fence";
1900
2183
  try {
1901
- const res = await this.transport.send(sender, wrapPaneEnvelope(OPENRIG_SENDER, sender, body), { verify: true, actorSession: OPENRIG_SENDER, openrigNotice: true });
2184
+ const res = await this.transport.send(sender, wrapPaneEnvelope(OPENRIG_SENDER, sender, body), { verify: true, actorSession: OPENRIG_SENDER, openrigNotice: true, auditPointer: qitemId, notificationCurrent });
2185
+ if (res.reason === "draft_wake_superseded" && !notificationCurrent())
2186
+ return "skipped:transfer fence";
1902
2187
  return res.verified ? "verified" : !res.ok ? `failed:${res.reason ?? res.error ?? "unknown"}` : res.outcome ?? "sent-unverified";
1903
2188
  }
1904
2189
  catch (error) {
@@ -1921,6 +2206,17 @@ export class QueueRepository {
1921
2206
  async performWakeSend(qitemId, destinationSession, sourceSession, bodyOverride, prebuiltText, committedOutboxIds, trigger = "agent", recheckMembers,
1922
2207
  /** An explicit notification, which passes a rig's delivery drain (here, and if a hook bridge queues it). */
1923
2208
  explicit = false) {
2209
+ const owed = () => {
2210
+ const row = this.getById(qitemId);
2211
+ return !!row && isBlockerLive(row.state) && row.destinationSession === destinationSession;
2212
+ };
2213
+ const starting = committedOutboxIds ? undefined : this.standbyWake?.(destinationSession, owed);
2214
+ if (starting) {
2215
+ if (!await starting)
2216
+ return { classified: "failed", nudgeResult: "failed:standby-resume-not-confirmed" };
2217
+ if (!owed())
2218
+ return { classified: "failed", nudgeResult: "failed:queue-work-no-longer-owed" };
2219
+ }
1924
2220
  // DEFECT FIX (S1-class, 3 live specimens): a virtual
1925
2221
  // @external destination has NO pane — the queue row ITSELF is the gateway
1926
2222
  // subsystem's input (the Slack connector polls human-destined rows and its own
@@ -1998,10 +2294,13 @@ export class QueueRepository {
1998
2294
  }
1999
2295
  try {
2000
2296
  const admission = this.wakeAdmission(qitemId, trigger);
2297
+ const intentId = committedOutboxIds?.[0];
2001
2298
  const res = await this.transport.send(destinationSession, text, { verify: true, stampISO, actorSession: sourceSession, committedOutboxIds,
2002
2299
  deliveryId: committedOutboxIds ? undefined : deliveryId, auditPointer: qitemId, queueWake: true,
2003
2300
  ...(trigger === "openrig" ? { openrigNotice: true } : {}), ...(admission.urgentBy ? { urgent: { by: admission.urgentBy } } : {}),
2004
- ...(recheckMembers ? { recheckMembers } : {}), ...(explicit ? { drainExempt: true } : {}) });
2301
+ ...(recheckMembers ? { recheckMembers } : { notificationCurrent: () => !this.transferFence(qitemId)
2302
+ && (intentId === undefined || this.currentWakeIntent({ outboxId: intentId, auditPointer: qitemId, destinationSession })) }),
2303
+ ...(explicit ? { drainExempt: true } : {}) });
2005
2304
  // OPR.0.3.2.21.FR-4(c) — wording rename: the prior literal
2006
2305
  // "sent-unverified" read as a failure even in the common case
2007
2306
  // (delivery confirmed but the synchronous ack window expired,
@@ -2055,6 +2354,9 @@ export class QueueRepository {
2055
2354
  const ask = this.getById(input.inboundReplyTo);
2056
2355
  if (ask && (runnerPermissionOrigin(ask) || isHostPairingAsk(ask)))
2057
2356
  return ask;
2357
+ // A kept answer is already committed, even if its source rig has become known since the interrupted close.
2358
+ if (ask && this.keptAnswer(ask.qitemId))
2359
+ return ask;
2058
2360
  const qitemId = humanAnswerId(input.inboundReplyTo, episodeKey);
2059
2361
  const existing = episodeKey ? this.getById(qitemId) : this.getHumanAnswer(input.inboundReplyTo, input.sourceSession);
2060
2362
  if (existing)
@@ -2063,7 +2365,42 @@ export class QueueRepository {
2063
2365
  const answered = this.getById(qitemId);
2064
2366
  if (answered)
2065
2367
  return answered;
2066
- return this.create({ ...create, qitemId, tags: [...new Set([...(input.tags ?? []), "human-answer"])] }, verifyBeforeCreate);
2368
+ try {
2369
+ return await this.create({ ...create, qitemId, tags: [...new Set([...(input.tags ?? []), "human-answer"])] }, verifyBeforeCreate);
2370
+ }
2371
+ catch (error) {
2372
+ // `rig queue create --source` takes any source, so an ask can name a rig this daemon doesn't know, with no queue
2373
+ // here for the answer to go back to. The person's answer still counts: it's kept on the ask, as a runner's or a
2374
+ // pairing ask's is, and the ask's history says once why it didn't go back.
2375
+ if (!ask || !(error instanceof QueueRepositoryError) || error.code !== "unknown_destination_rig")
2376
+ throw error;
2377
+ // The answer itself, with who gave it, is written here before anything says it's kept. Only the first is: a retry
2378
+ // or another person's answer then consumes it, as they would a returned answer's row (keptAnswer).
2379
+ const note = `${ANSWER_NOT_RETURNED_PREFIX} ${create.destinationSession} references an unknown rig, so the answer is kept on ${ask.qitemId}`
2380
+ + `\n${KEPT_ANSWER_FROM}${create.sourceSession}\n${humanAnswerText(create.body)}`;
2381
+ this.db.transaction(() => {
2382
+ verifyBeforeCreate?.();
2383
+ if (!this.answerNotReturned(ask.qitemId)) {
2384
+ this.transitionLog.append({ qitemId: ask.qitemId, state: this.getById(ask.qitemId)?.state ?? ask.state, actorSession: "daemon@system", transitionNote: note });
2385
+ }
2386
+ })();
2387
+ return ask;
2388
+ }
2389
+ }
2390
+ /** Why an ask's answer was kept on it instead of going back to its source (createHumanAnswer), or null. Only the daemon's
2391
+ * own in-process note counts, with the same trust rule as replyToChoiceFor: a queue note anyone adds can carry the same
2392
+ * words, and it isn't a person's answer. */
2393
+ answerNotReturned(qitemId) {
2394
+ return this.transitionLog.listForQitem(qitemId).find((t) => t.actorSession === "daemon@system" && t.identityProvenance === null
2395
+ && t.transitionNote?.startsWith(ANSWER_NOT_RETURNED_PREFIX))?.transitionNote ?? null;
2396
+ }
2397
+ /** The answer kept on an ask whose source's rig isn't known here: who gave it and their words. It's the ask's committed
2398
+ * answer, as a returned answer's row is for a known source. Null when none is kept. */
2399
+ keptAnswer(qitemId) {
2400
+ const lines = this.answerNotReturned(qitemId)?.split("\n");
2401
+ if (!lines?.[1]?.startsWith(KEPT_ANSWER_FROM))
2402
+ return null;
2403
+ return { actorSession: lines[1].slice(KEPT_ANSWER_FROM.length), words: lines.slice(2).join("\n") };
2067
2404
  }
2068
2405
  /** Every answer this person returned to the ask (one per park), oldest first: after close, a replay finds the one its
2069
2406
  * event returned or was absorbed into, whichever park it answered. */
@@ -2145,6 +2482,7 @@ export class QueueRepository {
2145
2482
  || isHostPairingAsk(ask) || ask.tags?.includes("runner-permission") || ask.tags?.includes(PROMPT_ALERT_TAG)) {
2146
2483
  refuse("Only ordinary asks to a person take relayed answers, not permission requests or host pairing.");
2147
2484
  }
2485
+ const fenced = !!this.transferFence(ask.qitemId);
2148
2486
  const questions = ask.humanQuestions ?? [];
2149
2487
  const submission = "relay" in input ? input.relay : input.direct;
2150
2488
  const named = questions.find(q => q.id === submission.questionId);
@@ -2160,11 +2498,14 @@ export class QueueRepository {
2160
2498
  const openQuestions = () => unansweredQuestions(questions.filter(q => !journal.relays.some(r => r.questionId === q.id)), direct);
2161
2499
  const unanswered = () => ask.state === "pending" ? openQuestions().map(q => q.id) : [];
2162
2500
  const receipt = (replyQitemId = journal.returnId, disposition) => ({
2163
- item: this.getByIdOrThrow(input.qitemId), replyQitemId, unanswered: unanswered(), ...(disposition ? { [disposition]: true } : {}),
2501
+ item: this.getByIdOrThrow(input.qitemId), replyQitemId: fenced ? null : replyQitemId, unanswered: unanswered(),
2502
+ ...(fenced ? { historyOnly: true } : disposition ? { [disposition]: true } : {}),
2164
2503
  });
2165
2504
  const at = new Date().toISOString();
2166
2505
  const identity = { identityProvenance: input.identityProvenance, identityPrincipal: input.identityPrincipal };
2167
2506
  const deliver = (qitemId, summary, body, tag) => {
2507
+ if (fenced)
2508
+ return;
2168
2509
  const create = { qitemId, sourceSession: input.actorSession, destinationSession: ask.sourceSession, summary, body,
2169
2510
  tags: [tag, ...(ask.tags ?? []).filter(t => /^(project|mission|slice):/.test(t))], inboundReplyTo: ask.qitemId,
2170
2511
  nudge: input.nudge, ...identity };
@@ -2189,8 +2530,10 @@ export class QueueRepository {
2189
2530
  return receipt();
2190
2531
  refuse("This question already has a relay; a direct answer can correct it.");
2191
2532
  }
2192
- if (ask.state !== "pending" || ask.blockedOn || (named && Object.hasOwn(direct, named.id))
2193
- || this.getById(humanAnswerId(ask.qitemId)) || (!ask.relayedAnswers && this.answersForAsk(ask.qitemId).length > 0)) {
2533
+ // A kept answer (its source's rig wasn't known) is the ask's committed answer, as a returned answer's row is.
2534
+ if (!fenced && (ask.state !== "pending" || ask.blockedOn || (named && Object.hasOwn(direct, named.id))
2535
+ || this.getById(humanAnswerId(ask.qitemId)) || (!ask.relayedAnswers && this.answersForAsk(ask.qitemId).length > 0)
2536
+ || this.keptAnswer(ask.qitemId))) {
2194
2537
  refuse("This question is not waiting for a relayed answer.");
2195
2538
  }
2196
2539
  if (!ask.relayedAnswers && Object.keys(direct).length) {
@@ -2269,7 +2612,7 @@ export class QueueRepository {
2269
2612
  deliver(humanAnswerId(ask.qitemId, `relay-attachments:${eventId}`), `Attachments to a direct answer on ${ask.qitemId}`, attachments.body, attachments.tag);
2270
2613
  }
2271
2614
  }
2272
- const completed = !unplacedId && ask.state === "pending" && unanswered().length === 0;
2615
+ const completed = !fenced && !unplacedId && ask.state === "pending" && unanswered().length === 0;
2273
2616
  if (completed) {
2274
2617
  if (!journal.returnId) {
2275
2618
  // First completion only. After a deliberate reopen, the journal still names the
@@ -2294,9 +2637,10 @@ export class QueueRepository {
2294
2637
  this.db.prepare("UPDATE queue_items SET relayed_answers = ?, human_answers = ?, ts_updated = ? WHERE qitem_id = ?")
2295
2638
  .run(JSON.stringify(journal), Object.keys(direct).length ? JSON.stringify(direct) : null, at, ask.qitemId);
2296
2639
  events.push(...this.updateInTransactionalContext({ qitemId: ask.qitemId, actorSession: input.actorSession, ...identity,
2297
- transitionNote: completed ? "RELAYED answer set returned to the asking seat" : correctionId ? "Direct correction to a RELAYED answer" : unplacedId ? "Direct reply returned without placing it" : "relay" in input ? "RELAYED answer recorded" : "Direct answer recorded",
2640
+ transitionNote: fenced ? `Late ${"relay" in input ? `relay attributed to ${input.relay.attributedTo}` : "direct answer"}${named ? ` (${named.id})` : ""}: ${submission.text ?? option?.label ?? ""}`
2641
+ : completed ? "RELAYED answer set returned to the asking seat" : correctionId ? "Direct correction to a RELAYED answer" : unplacedId ? "Direct reply returned without placing it" : "relay" in input ? "RELAYED answer recorded" : "Direct answer recorded",
2298
2642
  ...(completed ? { state: "done", closureReason: "relayed-answer", resolution: renderRelayedAnswers(journal, questions, direct) } : {}),
2299
- }, completed).persistedEvents);
2643
+ }, completed ? "complete" : "record").persistedEvents);
2300
2644
  return unplacedId ? receipt(unplacedId, "unplaced") : correctionId ? receipt(correctionId, "corrected") : receipt();
2301
2645
  })();
2302
2646
  const deliverWakes = () => {
@@ -2329,7 +2673,7 @@ export class QueueRepository {
2329
2673
  // (routes/queue.ts stamp-at-FORWARD), and a genuine origin triple arriving from a
2330
2674
  // forward is stored verbatim (never re-stamped, never stripped).
2331
2675
  if (!this.canRecordDestination(input.destinationSession)) {
2332
- throw destinationValidationError("destination_session", input.destinationSession, this.loadHumanRegistryFn);
2676
+ throw destinationValidationError("destination_session", input.destinationSession, () => this.readHumanRegistry());
2333
2677
  }
2334
2678
  let wakeStaged = false;
2335
2679
  // A row OpenRig creates itself (a sweep finding, an escalation, a health or mode notice) keeps its source for the
@@ -2432,7 +2776,7 @@ export class QueueRepository {
2432
2776
  */
2433
2777
  createWithinTransaction(input) {
2434
2778
  if (!this.canRecordDestination(input.destinationSession)) {
2435
- throw destinationValidationError("destination_session", input.destinationSession, this.loadHumanRegistryFn);
2779
+ throw destinationValidationError("destination_session", input.destinationSession, () => this.readHumanRegistry());
2436
2780
  }
2437
2781
  const result = this.createInTransactionalContext(input);
2438
2782
  return {
@@ -2623,13 +2967,42 @@ export class QueueRepository {
2623
2967
  transitionNote: "runner-permission-stale reason=relaunched: a later occupant holds this seat, so any answer here is not sent." });
2624
2968
  return true;
2625
2969
  }
2970
+ readHumanRegistry() {
2971
+ const store = this.humanRegistryMemo.getStore();
2972
+ if (!store || store.closed)
2973
+ return this.loadHumanRegistryFn();
2974
+ if (!store.loaded) {
2975
+ try {
2976
+ store.loaded = { ok: true, result: this.loadHumanRegistryFn() };
2977
+ }
2978
+ catch (error) {
2979
+ store.loaded = { ok: false, error };
2980
+ }
2981
+ }
2982
+ if (!store.loaded.ok)
2983
+ throw store.loaded.error;
2984
+ return store.loaded.result;
2985
+ }
2986
+ /** Run `fn` with the human registry read at most once on this repository for that async execution context. */
2987
+ async withMemoizedHumanRegistry(fn) {
2988
+ const current = this.humanRegistryMemo.getStore();
2989
+ if (current && !current.closed)
2990
+ return fn();
2991
+ const store = { closed: false };
2992
+ try {
2993
+ return await this.humanRegistryMemo.run(store, fn);
2994
+ }
2995
+ finally {
2996
+ store.closed = true;
2997
+ }
2998
+ }
2626
2999
  /** A person by address or by the registry: a registered person may be addressed as their seat or an alias. */
2627
3000
  isPersonAddress(destination) {
2628
3001
  if (!destination.includes("@"))
2629
3002
  return false;
2630
3003
  if (isHumanSeatSessionRef(destination))
2631
3004
  return true;
2632
- const registry = this.loadHumanRegistryFn();
3005
+ const registry = this.readHumanRegistry();
2633
3006
  return registry.ok && resolveRegisteredHumanAddress(destination, registry.entities) !== null;
2634
3007
  }
2635
3008
  /** The registered person an address names, so an ask back reaches them; null for anyone else, the unattributed
@@ -2637,7 +3010,7 @@ export class QueueRepository {
2637
3010
  reachablePerson(address) {
2638
3011
  if (!address || address === UNATTRIBUTED_ACTOR)
2639
3012
  return null;
2640
- const registry = this.loadHumanRegistryFn();
3013
+ const registry = this.readHumanRegistry();
2641
3014
  return registry.ok ? resolveRegisteredHumanAddress(address, registry.entities) : null;
2642
3015
  }
2643
3016
  /** Who may answer an ask: the asked person, and any other registered person in this workspace, who's recorded as
@@ -2647,7 +3020,7 @@ export class QueueRepository {
2647
3020
  return true;
2648
3021
  if (this.isSharedChannel(actorSession))
2649
3022
  return false;
2650
- const registry = this.loadHumanRegistryFn();
3023
+ const registry = this.readHumanRegistry();
2651
3024
  return registry.ok && resolveRegisteredHumanAddress(actorSession, registry.entities) !== null;
2652
3025
  }
2653
3026
  /** A registered shared channel. It takes correspondence, so it never answers, approves, resolves or denies (0.7.3). */
@@ -2656,12 +3029,12 @@ export class QueueRepository {
2656
3029
  }
2657
3030
  /** The registered people this queue resolves addresses against. */
2658
3031
  humanRegistry() {
2659
- return this.loadHumanRegistryFn();
3032
+ return this.readHumanRegistry();
2660
3033
  }
2661
3034
  /** The asked person, when a different registered person is acting on what was asked of them, so the record names both;
2662
3035
  * else null. An agent, the asked person under another spelling, and an ask to no registered person aren't someone else. */
2663
3036
  askedSomeoneElse(actorSession, askedSession) {
2664
- const registry = this.loadHumanRegistryFn();
3037
+ const registry = this.readHumanRegistry();
2665
3038
  if (!registry.ok)
2666
3039
  return null;
2667
3040
  const asked = resolveRegisteredHumanAddress(askedSession, registry.entities);
@@ -2694,6 +3067,7 @@ export class QueueRepository {
2694
3067
  return runSyncSite("queue.handoff", () => this.handoffWithin(input));
2695
3068
  }
2696
3069
  handoffWithin(input) {
3070
+ this.assertNotFenced(input.qitemId);
2697
3071
  const source = this.getById(input.qitemId);
2698
3072
  if (!source) {
2699
3073
  throw new QueueRepositoryError("qitem_not_found", `qitem ${input.qitemId} not found`);
@@ -2702,7 +3076,7 @@ export class QueueRepository {
2702
3076
  throw new QueueRepositoryError("qitem_already_terminal", `qitem ${input.qitemId} is already in terminal state ${source.state}`);
2703
3077
  }
2704
3078
  if (!this.canRecordDestination(input.toSession)) {
2705
- throw destinationValidationError("to_session", input.toSession, this.loadHumanRegistryFn);
3079
+ throw destinationValidationError("to_session", input.toSession, () => this.readHumanRegistry());
2706
3080
  }
2707
3081
  this.assertHumanAlert(input.humanAlert, input.toSession);
2708
3082
  const newId = newQitemId();
@@ -2855,6 +3229,7 @@ export class QueueRepository {
2855
3229
  * tracking needed against the source qitem.
2856
3230
  */
2857
3231
  async handoffAndComplete(input) {
3232
+ this.assertNotFenced(input.qitemId);
2858
3233
  const source = this.getById(input.qitemId);
2859
3234
  if (!source) {
2860
3235
  throw new QueueRepositoryError("qitem_not_found", `qitem ${input.qitemId} not found`);
@@ -2863,7 +3238,7 @@ export class QueueRepository {
2863
3238
  throw new QueueRepositoryError("qitem_already_terminal", `qitem ${input.qitemId} is already in terminal state ${source.state}`);
2864
3239
  }
2865
3240
  if (!this.canRecordDestination(input.toSession)) {
2866
- throw destinationValidationError("to_session", input.toSession, this.loadHumanRegistryFn);
3241
+ throw destinationValidationError("to_session", input.toSession, () => this.readHumanRegistry());
2867
3242
  }
2868
3243
  this.assertHumanAlert(input.humanAlert, input.toSession);
2869
3244
  const newId = newQitemId();
@@ -2895,9 +3270,10 @@ export class QueueRepository {
2895
3270
  ts_updated = ?,
2896
3271
  handed_off_to = ?,
2897
3272
  closure_reason = 'handed_off_to',
2898
- closure_target = ?
3273
+ closure_target = ?,
3274
+ resolution = ?
2899
3275
  WHERE qitem_id = ?`)
2900
- .run(ts, input.toSession, input.toSession, source.qitemId);
3276
+ .run(ts, input.toSession, input.toSession, this.handoffClosingResolution(source, input.resolution), source.qitemId);
2901
3277
  this.transitionLog.append({
2902
3278
  qitemId: source.qitemId,
2903
3279
  state: "done",
@@ -3048,9 +3424,10 @@ export class QueueRepository {
3048
3424
  ts_updated = ?,
3049
3425
  handed_off_to = ?,
3050
3426
  closure_reason = 'handed_off_to',
3051
- closure_target = ?
3427
+ closure_target = ?,
3428
+ resolution = ?
3052
3429
  WHERE qitem_id = ?`)
3053
- .run(input.terminalState, ts, input.toSession, input.closureTarget, input.qitemId);
3430
+ .run(input.terminalState, ts, input.toSession, input.closureTarget, this.handoffClosingResolution(source, input.resolution), input.qitemId);
3054
3431
  const note = input.transitionNote ?? `cross-host handoff to ${input.toSession}`;
3055
3432
  const closeTransition = this.transitionLog.append({
3056
3433
  qitemId: input.qitemId,
@@ -3181,6 +3558,7 @@ export class QueueRepository {
3181
3558
  * Mark a qitem `in-progress` (claim). Computes closure_required_at from tier.
3182
3559
  */
3183
3560
  claim(input) {
3561
+ this.assertNotFenced(input.qitemId);
3184
3562
  const qitem = this.getById(input.qitemId);
3185
3563
  if (!qitem) {
3186
3564
  throw new QueueRepositoryError("qitem_not_found", `qitem ${input.qitemId} not found`);
@@ -3248,6 +3626,7 @@ export class QueueRepository {
3248
3626
  return this.getByIdOrThrow(input.qitemId);
3249
3627
  }
3250
3628
  unclaim(qitemId, destinationSession, reason, identityProvenance, identityPrincipal) {
3629
+ this.assertNotFenced(qitemId);
3251
3630
  const qitem = this.getById(qitemId);
3252
3631
  if (!qitem) {
3253
3632
  throw new QueueRepositoryError("qitem_not_found", `qitem ${qitemId} not found`);
@@ -3339,6 +3718,7 @@ export class QueueRepository {
3339
3718
  * removed or rewritten here.
3340
3719
  */
3341
3720
  addTags(input) {
3721
+ this.assertNotFenced(input.qitemId);
3342
3722
  const txn = this.db.transaction(() => {
3343
3723
  const qitem = this.getById(input.qitemId);
3344
3724
  if (!qitem)
@@ -3396,7 +3776,12 @@ export class QueueRepository {
3396
3776
  * (the public update() wraps; the public updateWithinTransaction()
3397
3777
  * composes inside the caller's outer transaction).
3398
3778
  */
3399
- updateInTransactionalContext(input, completingRelay = false) {
3779
+ updateInTransactionalContext(input, relayWrite) {
3780
+ const completingRelay = relayWrite === "complete";
3781
+ const historyNote = input.state === undefined && typeof input.transitionNote === "string" && !!input.transitionNote.trim() &&
3782
+ input.summary === undefined && input.closureRequiredAt === undefined;
3783
+ if (!historyNote && !["done", "failed", "denied", "canceled"].some(state => state === input.state))
3784
+ this.assertNotFenced(input.qitemId);
3400
3785
  if (input.closureReason === "relayed-answer" && !completingRelay) {
3401
3786
  throw new QueueRepositoryError("invalid_closure_reason", "Use the relay-answer operation to record a relayed answer.");
3402
3787
  }
@@ -3729,12 +4114,9 @@ export class QueueRepository {
3729
4114
  // The outcome is used only as non-blank text on the update that closes an open row; on any other
3730
4115
  // update the field is ignored and the row answers as it would without it. It goes after what the row
3731
4116
  // already carries (a pod-fallback line, or an earlier close's outcome) on its own line, text as sent.
3732
- const closingResolution = typeof input.resolution === "string" && input.resolution.trim().length > 0
3733
- && isBlockerLive(qitem.state) && !isBlockerLive(input.state)
3734
- ? input.resolution : null;
3735
- const nextResolution = closingResolution === null
3736
- ? qitem.resolution
3737
- : qitem.resolution ? `${qitem.resolution}\n${closingResolution}` : closingResolution;
4117
+ const nextResolution = isBlockerLive(qitem.state) && !isBlockerLive(input.state)
4118
+ ? appendClosingResolution(qitem.resolution, input.resolution)
4119
+ : qitem.resolution;
3738
4120
  const notification = this.classifyOwnerNotification({
3739
4121
  action: "update",
3740
4122
  destinationSession: qitem.destinationSession,
@@ -3985,18 +4367,42 @@ export class QueueRepository {
3985
4367
  * attachment still owns them. Standalone operator jobs keep their lifecycle. */
3986
4368
  resolveWatchdogPreDeliveryTerminalReason(jobId) {
3987
4369
  const targets = this.wakeRepo.findQitemsByGeneratedTimer(jobId);
3988
- if (targets.length === 0 || this.wakeRepo.findCurrentQitemsByGeneratedTimer(jobId).length > 0)
4370
+ if (targets.length === 0)
3989
4371
  return null;
3990
- if (this.wakeRepo.findLiveQitemsByAttachedWatchdog(jobId).length > 0)
4372
+ if (this.wakeRepo.findCurrentQitemsByGeneratedTimer(jobId).some(({ qitemId }) => !this.transferFence(qitemId)))
4373
+ return null;
4374
+ if (this.wakeRepo.findLiveQitemsByAttachedWatchdog(jobId).some(({ qitemId }) => !this.transferFence(qitemId)))
3991
4375
  return null;
3992
4376
  return "park_timer_target_terminal";
3993
4377
  }
4378
+ /** Delivery-time companion to {@link resolveWatchdogPreDeliveryTerminalReason}: true only when every row this
4379
+ * generated timer was armed for has left its park for good — closed, or fenced by a transfer. A row that is
4380
+ * still open is live work even when its wait moved to a different timer, so a reminder already under way that
4381
+ * names it was not refused for the park's sake and must not be recorded as a failure. */
4382
+ watchdogReminderSuperseded(jobId) {
4383
+ const targets = this.wakeRepo.findQitemsByGeneratedTimer(jobId);
4384
+ if (targets.length === 0)
4385
+ return false;
4386
+ // A live attachment keeps the reminder legitimate even when the timer's origin moved on (its text is rewritten).
4387
+ if (this.wakeRepo.findLiveQitemsByAttachedWatchdog(jobId).some(({ qitemId }) => !this.transferFence(qitemId)))
4388
+ return false;
4389
+ return targets.every(({ qitemId, state }) => !!this.transferFence(qitemId) || !isBlockerLive(state));
4390
+ }
4391
+ /** A shared timer can outlive its fenced origin, but its original message belongs to that row. */
4392
+ resolveSharedParkReminder(jobId) {
4393
+ if (!this.wakeRepo.findQitemsByGeneratedTimer(jobId).some(({ qitemId }) => this.transferFence(qitemId)))
4394
+ return null;
4395
+ const local = this.wakeRepo.findLiveQitemsByAttachedWatchdog(jobId)
4396
+ .filter(({ qitemId }) => !this.transferFence(qitemId))
4397
+ .map(({ qitemId }) => qitemId).sort();
4398
+ return `Shared wake timer fired for parked work:\n${local.map(id => `- ${id}`).join("\n")}`;
4399
+ }
3994
4400
  /** A usage-limit blocker's timer is a time event with no recipient: the blocker is addressed to `wake-ladder@<rig>`,
3995
4401
  * which no seat carries, so an input delivery can never succeed (#3704). When every row this job currently wakes is
3996
4402
  * such a blocker, its due fire is recorded here, before transport: the blocker resolves once and its dependents are
3997
4403
  * released. Returns the job's terminal reason, or null to keep the send path. */
3998
4404
  fireUsageLimitTimerWithoutDelivery(jobId) {
3999
- const targets = this.wakeRepo.findBlockedQitemsByWatchdog(jobId, true);
4405
+ const targets = this.wakeRepo.findBlockedQitemsByWatchdog(jobId, true).filter(({ qitemId }) => !this.transferFence(qitemId));
4000
4406
  if (targets.length === 0
4001
4407
  || !targets.every(({ qitemId }) => this.getById(qitemId)?.tags?.includes(USAGE_LIMIT_BLOCKER_TAG)))
4002
4408
  return null;
@@ -4042,7 +4448,7 @@ export class QueueRepository {
4042
4448
  if (generated.length !== 1 || bound.length !== 1 || bound[0].qitemId !== generated[0].qitemId)
4043
4449
  return null;
4044
4450
  const row = this.getById(generated[0].qitemId);
4045
- if (!row || row.state !== "blocked" || row.tags?.includes(USAGE_LIMIT_BLOCKER_TAG))
4451
+ if (!row || this.transferFence(row.qitemId) || row.state !== "blocked" || row.tags?.includes(USAGE_LIMIT_BLOCKER_TAG))
4046
4452
  return null;
4047
4453
  const job = (this.watchdogJobsRepo ?? new WatchdogJobsRepository(this.db)).getById(jobId);
4048
4454
  if (!job || job.policy !== "periodic-reminder" || isQueueWait(job.specYaml))
@@ -4054,7 +4460,7 @@ export class QueueRepository {
4054
4460
  /** The parked rows of `owner` whose current park this job wakes (QueueWakeRepository.findCurrentParkRowsByWatchdog):
4055
4461
  * at a queue-only seat the reminder is noted on them, never another row (#3076). */
4056
4462
  parkedRowsOwnedBy(jobId, owner) {
4057
- return this.wakeRepo.findCurrentParkRowsByWatchdog(jobId, owner);
4463
+ return this.wakeRepo.findCurrentParkRowsByWatchdog(jobId, owner).filter(id => !this.transferFence(id));
4058
4464
  }
4059
4465
  /** Notes a queue-only seat's park wake on each parked row it is about (#3076), in one transaction, each only while
4060
4466
  * the row is still `owner`'s and its current park is still the job's; nothing is typed. Returns the rows noted. */
@@ -4065,7 +4471,7 @@ export class QueueRepository {
4065
4471
  const parkedBy = (jobId) => {
4066
4472
  let rows = eligible.get(jobId);
4067
4473
  if (!rows)
4068
- eligible.set(jobId, rows = new Set(this.wakeRepo.findCurrentParkRowsByWatchdog(jobId, owner)));
4474
+ eligible.set(jobId, rows = new Set(this.parkedRowsOwnedBy(jobId, owner)));
4069
4475
  return rows;
4070
4476
  };
4071
4477
  const written = this.db.transaction(() => notes.flatMap(({ qitemId, jobId, note }) => {
@@ -4111,7 +4517,7 @@ export class QueueRepository {
4111
4517
  if (bindings.length === 0)
4112
4518
  return;
4113
4519
  // Both receipt ownership and timer lifecycle follow the current park.
4114
- const targets = this.wakeRepo.findBlockedQitemsByWatchdog(jobId, true);
4520
+ const targets = this.wakeRepo.findBlockedQitemsByWatchdog(jobId, true).filter(({ qitemId }) => !this.transferFence(qitemId));
4115
4521
  const queueOnlySeat = !retryAt && isQueueOnlyDeliveryCode(deliveryStatus) ? receipt?.targetSession : undefined;
4116
4522
  const noteOfDelivery = queueOnlySeat === undefined ? null : this.db.prepare(`SELECT t.transition_id FROM queue_transitions t
4117
4523
  WHERE t.qitem_id = ? AND t.actor_session = 'watchdog@system' AND substr(t.transition_note, 1, length(?)) = ?
@@ -4228,6 +4634,16 @@ export class QueueRepository {
4228
4634
  ? formatHumanAnswers(questions, item.humanAnswers ?? {}).join("; ") : humanAnswerText(winner.body);
4229
4635
  return this.closeDirectAsk(item, winner.sourceSession, decision, !this.answersAsk(item, winner.sourceSession), this.answerIdentity(winner.qitemId));
4230
4636
  }
4637
+ // An answer kept on the ask (its source's rig isn't known here) is its committed answer the same way: the ask closes
4638
+ // as that person's, with their words, whoever completes it, and false tells another caller theirs didn't settle it.
4639
+ const kept = this.keptAnswer(item.qitemId);
4640
+ if (kept) {
4641
+ mine = kept.actorSession === input.actorSession;
4642
+ const questions = item.humanQuestions ?? [];
4643
+ const decision = questions.length && unansweredQuestions(questions, item.humanAnswers ?? {}).length === 0
4644
+ ? formatHumanAnswers(questions, item.humanAnswers ?? {}).join("; ") : kept.words;
4645
+ return this.closeDirectAsk(item, kept.actorSession, decision, mine ? input.primaryUser === true : !this.answersAsk(item, kept.actorSession), mine ? { provenance: input.identityProvenance ?? null, principal: input.identityPrincipal ?? null } : { provenance: null, principal: null });
4646
+ }
4231
4647
  // A close that consumes this caller's own committed answer carries that answer's identity too, so attribution doesn't
4232
4648
  // depend on who completes it. Only a close with no committed answer takes the caller's.
4233
4649
  const own = this.getHumanAnswer(item.qitemId, input.actorSession, { primaryUser: input.primaryUser === true });
@@ -4308,7 +4724,8 @@ export class QueueRepository {
4308
4724
  `- **Who's who:** ${root.sourceSession} is the agent asking to run the tool; ${item.destinationSession} is the person it asked; ${person} answered.`,
4309
4725
  ...(unattributed ? [terminalAnswerMeaning(UNATTRIBUTED_ACTOR)] : []),
4310
4726
  "Act on a clear answer at once: a clear yes or an allow click is the allow option, a clear no or a reject click the reject option. Don't ask them to confirm a clear answer.",
4311
- `${askBackRoute(askBack, UNATTRIBUTED_ACTOR, `request ${item.qitemId}`)} Then decide on what they answer.`,
4727
+ "A condition is theirs to set and yours to judge: when this exact action plainly meets it, allow it; when it plainly doesn't, take the reject option with their words in your reason. Don't ask them to confirm a condition you can judge.",
4728
+ `${askBackRoute(askBack, UNATTRIBUTED_ACTOR, `request ${item.qitemId}`, "you can't tell what they meant, or whether this exact action meets their condition")} Then decide on what they answer.`,
4312
4729
  "Until it's decided (by you, or by anyone with that command), the runner keeps waiting, with no timeout that refuses it; if its turn ends first, nothing is sent.",
4313
4730
  RUNNER_CLOSE_WAITS,
4314
4731
  ].join("\n"),
@@ -4415,11 +4832,14 @@ export class QueueRepository {
4415
4832
  const placed = this.placeTypedReply(item, decision);
4416
4833
  if (placed)
4417
4834
  transitionNote += `; ${placed}`;
4835
+ // An answer kept on the ask (its source's rig isn't known here) has no reply row to carry it, so the ask keeps it.
4836
+ const kept = this.answerNotReturned(item.qitemId) !== null;
4418
4837
  return this.updateInTransactionalContext({
4419
4838
  qitemId: item.qitemId,
4420
4839
  actorSession: actor,
4421
4840
  state: "done",
4422
4841
  closureReason: "no-follow-on",
4842
+ ...(kept ? { resolution: decision } : {}),
4423
4843
  transitionNote,
4424
4844
  ownerNotificationKind: "human-decision-resolved",
4425
4845
  identityProvenance: identity.provenance,
@@ -4485,6 +4905,10 @@ export class QueueRepository {
4485
4905
  const winner = item.state === "pending" || episodeKey ? this.committedAnswerFromAnother(item.qitemId, input.actorSession, episodeKey) : null;
4486
4906
  if (winner)
4487
4907
  return { status: "not-applicable", reason: "answered", answeredBy: winner.sourceSession };
4908
+ const keptBy = item.state === "pending" ? this.keptAnswer(item.qitemId) : null;
4909
+ // A click cannot replace a committed typed answer, including one from the same person. The continuation below closes with it.
4910
+ if (keptBy)
4911
+ return { status: "not-applicable", reason: "answered", answeredBy: keptBy.actorSession };
4488
4912
  const question = item.humanQuestions.find((q) => q.id === input.questionId);
4489
4913
  if (!question?.options.some((o) => o.id === input.optionId))
4490
4914
  return { status: "not-applicable", reason: "unknown-option" };
@@ -4708,7 +5132,8 @@ export class QueueRepository {
4708
5132
  return refuse("permission-prompt", "a permission prompt or approval gate is never decided on the person's behalf");
4709
5133
  }
4710
5134
  // A click keeps a multi-question ask pending until every question is answered: once the person has started, it's theirs.
4711
- if (item.relayedAnswers || (item.humanAnswers && Object.keys(item.humanAnswers).length > 0)) {
5135
+ // So is an answer kept on the ask (its source's rig wasn't known), even when its close was interrupted.
5136
+ if (item.relayedAnswers || (item.humanAnswers && Object.keys(item.humanAnswers).length > 0) || this.keptAnswer(item.qitemId)) {
4712
5137
  return refuse("person-answering", "they've started answering; their answer stands");
4713
5138
  }
4714
5139
  if (item.sourceSession !== input.actorSession) {
@@ -4900,19 +5325,31 @@ export class QueueRepository {
4900
5325
  * about this seat's own prompt that nobody holds is left out: with no operator seat to carry it, the alert falls back
4901
5326
  * to the seat itself, and the escalation is the wake, not the content, so it is never that seat's work. One its owner
4902
5327
  * explicitly holds (blocked) stays, so that hold and its wake are diagnosed as before; so does a row whose tags aren't
4903
- * a JSON array. Each row carries its blocker and last update, so a hold is shown with what it waits on and its age. */
5328
+ * a JSON array. OpenRig's roster-ready notice (isRosterReadyNotice) is also left out: information, not an obligation.
5329
+ * Each row carries its blocker and last update, so a hold is shown with what it waits on and its age. */
4904
5330
  listOpenObligations(destinationSession, limit) {
5331
+ if (limit === 0)
5332
+ return [];
4905
5333
  const addresses = this.resolveSessionAddresses(destinationSession);
4906
5334
  const slots = addresses.map(() => "?").join(",");
4907
5335
  const ownPrompt = addresses.flatMap((address) => [`prompt-destination:${address}`, `consumed-prompt-destination:${address}`]);
4908
- const rows = this.db.prepare(`SELECT qitem_id, state, blocked_on, ts_updated${this.hasSummaryColumn ? ", summary" : ""} FROM queue_items
5336
+ const rows = this.db.prepare(`SELECT qitem_id, source_session, state, blocked_on, ts_updated${this.hasSummaryColumn ? ", summary" : ""} FROM queue_items
4909
5337
  WHERE destination_session IN (${slots}) AND state IN ('pending', 'in-progress', 'blocked')
5338
+ AND ${this.dispatchableTransferRow()}
4910
5339
  AND NOT CASE WHEN state != 'blocked' AND json_valid(tags) THEN CASE WHEN json_type(tags) = 'array' THEN
4911
5340
  EXISTS (SELECT 1 FROM json_each(queue_items.tags) WHERE value = ?)
4912
5341
  AND EXISTS (SELECT 1 FROM json_each(queue_items.tags) WHERE value IN (${ownPrompt.map(() => "?").join(",")}))
4913
5342
  ELSE 0 END ELSE 0 END
4914
- ORDER BY ts_created DESC LIMIT ?`).all(...addresses, WAKE_ESCALATION_TAG, ...ownPrompt, limit);
4915
- return rows.map((r) => ({ qitemId: r.qitem_id, state: r.state, summary: r.summary ?? null, blockedOn: r.blocked_on, updatedAt: r.ts_updated }));
5343
+ ORDER BY ts_created DESC`).iterate(...addresses, WAKE_ESCALATION_TAG, ...ownPrompt);
5344
+ const result = [];
5345
+ for (const row of rows) {
5346
+ if (isRosterReadyNotice(row))
5347
+ continue;
5348
+ result.push({ qitemId: row.qitem_id, state: row.state, summary: row.summary ?? null, blockedOn: row.blocked_on, updatedAt: row.ts_updated });
5349
+ if (limit > 0 && result.length >= limit)
5350
+ break;
5351
+ }
5352
+ return result;
4916
5353
  }
4917
5354
  list(opts) {
4918
5355
  // one recovery index for the whole listing (built on first use) instead of one json_each scan per row
@@ -5128,10 +5565,12 @@ export class QueueRepository {
5128
5565
  const rows = this.db.prepare(sql).all(...params);
5129
5566
  return rows.map((r) => this.rowToItem(r, opts?.includeWaiting ?? true));
5130
5567
  }
5131
- /** The compact listings' columns: the shared set plus the summary, which is short and is what people search for, and a
5568
+ /** The compact listings' columns: the shared set plus the summary, as authored, a bounded prefix for display, and a
5132
5569
  * routed row's return route, which isn't elided, so a routed row never lists as unrouted. */
5133
5570
  compactColumns() {
5134
- return COMPACT_QUEUE_COLUMNS + (this.hasSummaryColumn ? ", summary" : "") + (this.hasHumanIntentColumn ? ", human_intent" : "")
5571
+ // Byte slicing preserves embedded NULs (TEXT substr stops there). Four UTF-8 bytes per UTF-16 unit
5572
+ // supply the helper's entire prefix; any partial code point at the SQL edge is beyond its bound.
5573
+ return COMPACT_QUEUE_COLUMNS + `, CAST(substr(CAST(body AS BLOB), 1, ${QUEUE_DISPLAY_PREFIX_UNITS * 4}) AS TEXT) AS body` + (this.hasSummaryColumn ? ", summary" : "") + (this.hasHumanIntentColumn ? ", human_intent" : "")
5135
5574
  + (this.hasReturnRouteColumn ? ", return_route, return_route_basis" : "");
5136
5575
  }
5137
5576
  findOverdue(opts) {
@@ -5219,6 +5658,7 @@ export class QueueRepository {
5219
5658
  : "0";
5220
5659
  const conditions = [
5221
5660
  "state IN ('pending', 'in-progress', 'blocked')",
5661
+ this.dispatchableTransferRow(),
5222
5662
  `((state = 'pending' AND (last_nudge_result LIKE 'failed:%'
5223
5663
  OR last_nudge_result LIKE 'unroutable:%'
5224
5664
  OR last_nudge_result LIKE 'awaiting-pickup:%'
@@ -5323,7 +5763,7 @@ export class QueueRepository {
5323
5763
  return true;
5324
5764
  if (parseSessionName(destinationSession).kind !== "canonical")
5325
5765
  return false;
5326
- const registry = this.loadHumanRegistryFn();
5766
+ const registry = this.readHumanRegistry();
5327
5767
  if (!registry.ok) {
5328
5768
  throw new QueueRepositoryError("human_registry_unavailable", `Cannot classify '${destinationSession}' as human or agent: human registry unavailable (${registry.error}).`);
5329
5769
  }
@@ -5338,7 +5778,7 @@ export class QueueRepository {
5338
5778
  || !row.lastNudgeResult?.startsWith("unroutable:"))
5339
5779
  return false;
5340
5780
  try {
5341
- const registry = this.loadHumanRegistryFn();
5781
+ const registry = this.readHumanRegistry();
5342
5782
  if (registry.ok ? registry.entities.length !== 0 : registry.noHumans !== true)
5343
5783
  return false;
5344
5784
  return this.classifyDestinationOf(row.destinationSession).class === "unroutable";
@@ -5354,7 +5794,7 @@ export class QueueRepository {
5354
5794
  if (row.state !== "pending" || row.humanIntent !== "update")
5355
5795
  return false;
5356
5796
  try {
5357
- const registry = this.loadHumanRegistryFn();
5797
+ const registry = this.readHumanRegistry();
5358
5798
  return registry.ok && resolveRegisteredHumanAddress(row.destinationSession, registry.entities) !== null;
5359
5799
  }
5360
5800
  catch {
@@ -5438,15 +5878,44 @@ export class QueueRepository {
5438
5878
  classifyDestinationOf(destinationSession) {
5439
5879
  return classifyDestination(destinationSession, {
5440
5880
  entities: (() => {
5441
- const loaded = this.loadHumanRegistryFn();
5881
+ const loaded = this.readHumanRegistry();
5442
5882
  return loaded.ok ? loaded.entities : null;
5443
5883
  })(),
5444
5884
  hasTerminalTransport: (dest) => this.hasTerminalTransport(dest),
5445
5885
  hostedWake: (dest) => this.hostedWakeFn(dest),
5446
5886
  isHostedMember: (dest) => this.hostedMemberFn(dest),
5447
5887
  hostedCheckIn: (dest) => this.hostedMemberCheckIn(dest),
5888
+ isIssuedConversation: (dest) => this.isIssuedConversation(dest),
5889
+ isExternalCliSeat: (dest) => this.isExternalCliSeat(dest),
5448
5890
  });
5449
5891
  }
5892
+ /** Whether this address is a seat joined with `rig attach` as an external CLI, in an active rig: by its session or its
5893
+ * binding's external name, or as the canonical `<pod>-<member>@<rig>` of such a node. OpenRig can't type into it
5894
+ * (seat-kinds: no inbound transport), so its work waits for that program's own read. An unreadable record reads false. */
5895
+ isExternalCliSeat(destination) {
5896
+ try {
5897
+ const external = (rows) => rows.some((row) => seatProcessOwner(resolveSeatKind(row.attachment_type)) === "external");
5898
+ if (external(this.db.prepare(`SELECT b.attachment_type FROM bindings b JOIN nodes n ON n.id = b.node_id JOIN rigs r ON r.id = n.rig_id
5899
+ WHERE r.archived_at IS NULL
5900
+ AND (b.external_session_name = ? OR EXISTS (SELECT 1 FROM sessions s WHERE s.node_id = n.id AND s.session_name = ?))`)
5901
+ .all(destination, destination)))
5902
+ return true;
5903
+ const at = destination.lastIndexOf("@");
5904
+ if (at <= 0)
5905
+ return false;
5906
+ return external(this.db.prepare(`SELECT b.attachment_type FROM bindings b JOIN nodes n ON n.id = b.node_id JOIN rigs r ON r.id = n.rig_id
5907
+ WHERE r.archived_at IS NULL AND r.name = ? AND REPLACE(n.logical_id, '.', '-') = ?`)
5908
+ .all(destination.slice(at + 1), destination.slice(0, at)));
5909
+ }
5910
+ catch {
5911
+ return false;
5912
+ }
5913
+ }
5914
+ /** Whether OpenRig issued this address to a person's own conversation here (#3964): its work waits for that conversation
5915
+ * to read it, as a polling hosted member's does. An unreadable record reads false, so the address stays reported. */
5916
+ isIssuedConversation(destination) {
5917
+ return this.hasReturnRouteColumn && isIssuedConversationAddress(this.db, destination);
5918
+ }
5450
5919
  /** OPR.0.5.6.14 — terminal transport is a CAPABILITY, not topology presence.
5451
5920
  * An exact session or composed canonical seat is pane-bound only when its
5452
5921
  * node carries an explicit tmux binding. external_cli is paneless and must
@@ -5626,7 +6095,7 @@ export class QueueRepository {
5626
6095
  const owners = knownOwners ?? this.transitionLog.ownerNotificationsForQitems(qitemIds);
5627
6096
  let notes = receiptsAfterEpisodes ? undefined : this.receiptNotesFor(qitemIds);
5628
6097
  let registry;
5629
- const loadRegistry = () => (registry ??= this.loadHumanRegistryFn());
6098
+ const loadRegistry = () => (registry ??= this.readHumanRegistry());
5630
6099
  let relayProfiles;
5631
6100
  const loadProfiles = (entities) => (relayProfiles ??= loadRelayProfiles(undefined, { entities }));
5632
6101
  let pullOutboxKeys;
@@ -5703,6 +6172,8 @@ export class QueueRepository {
5703
6172
  * as prompt-clear recovery of a refused wake) read the real end and not `bridged:queued` (#3270). A typed fallback's
5704
6173
  * result is recorded as a typed wake's is. */
5705
6174
  recordBridgedWakeEnd(qitemId, end) {
6175
+ if (this.transferFence(qitemId))
6176
+ return;
5706
6177
  const typed = end.kind === "typed" && end.result ? this.classifyWakeResult(end.result) : null;
5707
6178
  const result = typed ? typed.nudgeResult
5708
6179
  : end.kind === "handed-to-hook" ? "bridged:handed-to-hook"
@@ -5740,6 +6211,19 @@ export class QueueRepository {
5740
6211
  this.promptRecoveryState.set(row.destinationSession, true);
5741
6212
  }
5742
6213
  }
6214
+ handoffClosingResolution(source, outcome) {
6215
+ const previous = source.resolution;
6216
+ if (previous && typeof outcome === "string" && outcome.trim() && !isBlockerLive(source.state)) {
6217
+ // A non-live handoff does not leave the live-to-closed transition that signals an appended outcome.
6218
+ // Keep any identifiable fallback line last, where a later reroute can replace it without touching the outcome.
6219
+ const fallbackStart = this.fallbackLineStart(source.qitemId, previous);
6220
+ if (fallbackStart !== null) {
6221
+ const earlierOutcomes = previous.slice(0, Math.max(0, fallbackStart - 1));
6222
+ return `${appendClosingResolution(earlierOutcomes, outcome)}\n${previous.slice(fallbackStart)}`;
6223
+ }
6224
+ }
6225
+ return appendClosingResolution(previous, outcome);
6226
+ }
5743
6227
  /**
5744
6228
  * Where, in the row's `resolution`, the fallback line `routeToFallback` last wrote begins; null when it cannot be
5745
6229
  * told, and the field is then left whole. The row's own transitions say what that reroute printed: a newest-first
@@ -5803,6 +6287,7 @@ export class QueueRepository {
5803
6287
  * always got.
5804
6288
  */
5805
6289
  routeToFallback(qitemId, fallbackDestination, reason, opts = {}) {
6290
+ this.assertNotFenced(qitemId);
5806
6291
  if (opts.expectState !== undefined && !isQueueState(opts.expectState)) {
5807
6292
  throw new QueueRepositoryError("invalid_state", `expectState=${opts.expectState} not valid; valid: ${QUEUE_STATES.join(", ")}`);
5808
6293
  }
@@ -6090,6 +6575,8 @@ export class QueueRepository {
6090
6575
  workflowGuidance;
6091
6576
  attachWorkflowGuidance(reader) { this.workflowGuidance = reader; }
6092
6577
  evaluateWaitReminder(input) {
6578
+ if (this.resolveWatchdogPreDeliveryTerminalReason(input.jobId))
6579
+ return { action: "terminal", reason: "park_timer_target_terminal" };
6093
6580
  const binding = this.wakeRepo.findCurrentQitemsByGeneratedTimer(input.jobId)[0];
6094
6581
  if (!binding && this.wakeRepo.findLiveQitemsByAttachedWatchdog(input.jobId).length > 0)
6095
6582
  return null;
@@ -6133,11 +6620,33 @@ export class QueueRepository {
6133
6620
  return { meaningful: lastMeaningfulTransitionMany(this.db, ids), statements: new WaitingStatements(this.db), activity };
6134
6621
  }
6135
6622
  /** listed: the row's owner notifications and ledger, when a listing read them for all its rows. */
6623
+ networkWaitFor(qitemId) {
6624
+ if (!this.hasNetworkWaitColumn)
6625
+ return null;
6626
+ const row = this.db.prepare("SELECT remote_wait FROM network_requests WHERE local_qitem_id = ? AND settled_at IS NULL").get(qitemId);
6627
+ if (!row?.remote_wait)
6628
+ return null;
6629
+ try {
6630
+ const wait = JSON.parse(row.remote_wait);
6631
+ if (!wait || typeof wait !== "object")
6632
+ return null;
6633
+ const value = wait;
6634
+ return ["requester-question", "another-request"].includes(value.kind) && typeof value.observedAt === "string" ? value : null;
6635
+ }
6636
+ catch {
6637
+ return null;
6638
+ }
6639
+ }
6136
6640
  waitingView(qitemId, listed) {
6137
6641
  // The row in hand, when the listing passed it: its later re-reads below are served by it too.
6138
6642
  const inHand = listed?.row && listed.row.qitem_id === qitemId ? listed.row : undefined;
6139
6643
  const reads = listed?.reads && inHand ? { ...listed.reads, row: inHand } : listed?.reads;
6140
6644
  const view = readWaitingView(this.db, qitemId, listed?.reads?.activity ?? this.activityReader, target => this.acceptsDestination(target), reads);
6645
+ if (view?.blocker?.owner === OPENRIG_SENDER) {
6646
+ const networkWait = this.networkWaitFor(view.blocker.ref);
6647
+ if (networkWait)
6648
+ view.blocker.networkWait = networkWait;
6649
+ }
6141
6650
  if (view && ["pending", "in-progress"].includes(view.state)) {
6142
6651
  // #514 — the unclaimed sweep skips a pending ask already posted to its human in the current
6143
6652
  // episode (same predicate as runStuckSweep), so the view must not promise that sweep.
@@ -6170,7 +6679,7 @@ export class QueueRepository {
6170
6679
  view.nextBackstop = quiet;
6171
6680
  return view;
6172
6681
  }
6173
- const recovery = readWakeLadderBackstop(this.db, qitemId, target => this.acceptsDestination(target));
6682
+ const recovery = readWakeLadderBackstop(this.db, qitemId, target => this.acceptsDestination(target), session => this.draftHeldIdleRetryOwns(session));
6174
6683
  if (recovery && !localOnly) {
6175
6684
  if (!awaitingHuman && !humanUpdate)
6176
6685
  view.laterBackstop = { ...view.nextBackstop, note: "Conditional safety net; current delivery/recovery ownership is evaluated first." };
@@ -6235,6 +6744,7 @@ export class QueueRepository {
6235
6744
  const meaningful = meaningfulFor(this.db, row.qitem_id, listed?.reads);
6236
6745
  // A listing's rows are its own SELECT *: the waiting view reads the row in hand instead of reading it again.
6237
6746
  const waiting = includeWaiting ? this.waitingView(row.qitem_id, listed?.reads ? { ...listed, row } : listed) : null;
6747
+ const networkWait = row.destination_session === OPENRIG_SENDER ? this.networkWaitFor(row.qitem_id) : null;
6238
6748
  const listedActivity = listed?.reads?.activity;
6239
6749
  const activity = listedActivity ? listedActivity(row.destination_session) : this.ownerActivity(row.destination_session);
6240
6750
  const pickup = derivePickup({
@@ -6254,6 +6764,7 @@ export class QueueRepository {
6254
6764
  ...(handoffAdvisory ? { handoffAdvisory } : {}),
6255
6765
  pickup,
6256
6766
  ...(waiting ? { waiting } : {}),
6767
+ ...(networkWait ? { networkWait } : {}),
6257
6768
  qitemId: row.qitem_id,
6258
6769
  tsCreated: row.ts_created,
6259
6770
  tsUpdated: row.ts_updated,