@openrig/cli 0.7.22 → 0.7.23

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 (821) hide show
  1. package/README.md +7 -7
  2. package/daemon/assets/onboarding/01-world-and-purpose.md +2 -1
  3. package/daemon/assets/onboarding/02-self-and-competent-action.md +6 -0
  4. package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +1 -1
  5. package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +1 -1
  6. package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
  7. package/daemon/assets/plugins/openrig/plugin.json +1 -1
  8. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  9. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  10. package/daemon/assets/plugins/openrig-core/hooks/scripts/activity-relay.cjs +13 -0
  11. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/scripts/precompact-hook.mjs +4 -0
  12. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/scripts/restore-from-jsonl.mjs +31 -5
  13. package/daemon/assets/plugins/openrig-core/skills/messaging-the-human/SKILL.md +1 -1
  14. package/daemon/assets/plugins/openrig-core/skills/refocusing/scripts/trace-to-root.py +32 -6
  15. package/daemon/assets/skills/rigs/SKILL.md +14 -5
  16. package/daemon/context-packs/help/manifest.yaml +1 -1
  17. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  18. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +15 -6
  19. package/daemon/context-packs/reference/acp-agents.md +2 -1
  20. package/daemon/context-packs/reference/getting-started.md +119 -12
  21. package/daemon/context-packs/reference/manifest.yaml +1 -1
  22. package/daemon/context-packs/reference/rig-spec.md +193 -3
  23. package/daemon/context-packs/reference/tmux-servers.md +27 -2
  24. package/daemon/context-packs/reference/whats-new.md +92 -12
  25. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  26. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  27. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  28. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  29. package/daemon/context-packs/skills/claude-compaction-restore/scripts/precompact-hook.mjs +4 -0
  30. package/daemon/context-packs/skills/claude-compaction-restore/scripts/restore-from-jsonl.mjs +31 -5
  31. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  32. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/core/messaging-the-human/SKILL.md +1 -1
  36. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +3 -3
  37. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  66. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  76. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  77. package/daemon/context-packs/skills/refocusing/scripts/trace-to-root.py +32 -6
  78. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  79. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  80. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  81. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  82. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  83. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  84. package/daemon/dist/adapters/claude-code-adapter.d.ts +14 -1
  85. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  86. package/daemon/dist/adapters/claude-code-adapter.js +86 -17
  87. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  88. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  89. package/daemon/dist/adapters/claude-resume.js +8 -4
  90. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  91. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
  92. package/daemon/dist/adapters/community-harness-runtime-adapter.js +19 -4
  93. package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
  94. package/daemon/dist/adapters/seat-slice.d.ts +19 -0
  95. package/daemon/dist/adapters/seat-slice.d.ts.map +1 -0
  96. package/daemon/dist/adapters/seat-slice.js +29 -0
  97. package/daemon/dist/adapters/seat-slice.js.map +1 -0
  98. package/daemon/dist/adapters/shell-quote.d.ts +1 -0
  99. package/daemon/dist/adapters/shell-quote.d.ts.map +1 -1
  100. package/daemon/dist/adapters/shell-quote.js +6 -0
  101. package/daemon/dist/adapters/shell-quote.js.map +1 -1
  102. package/daemon/dist/adapters/tmux.d.ts +32 -8
  103. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  104. package/daemon/dist/adapters/tmux.js +253 -59
  105. package/daemon/dist/adapters/tmux.js.map +1 -1
  106. package/daemon/dist/build-info.js +3 -3
  107. package/daemon/dist/daemon-shutdown.d.ts +5 -0
  108. package/daemon/dist/daemon-shutdown.d.ts.map +1 -1
  109. package/daemon/dist/daemon-shutdown.js +10 -2
  110. package/daemon/dist/daemon-shutdown.js.map +1 -1
  111. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  112. package/daemon/dist/db/all-migrations.js +24 -0
  113. package/daemon/dist/db/all-migrations.js.map +1 -1
  114. package/daemon/dist/db/migrate.d.ts +15 -1
  115. package/daemon/dist/db/migrate.d.ts.map +1 -1
  116. package/daemon/dist/db/migrate.js +41 -6
  117. package/daemon/dist/db/migrate.js.map +1 -1
  118. package/daemon/dist/db/migrations/179_remote_control_observations.d.ts +10 -0
  119. package/daemon/dist/db/migrations/179_remote_control_observations.d.ts.map +1 -0
  120. package/daemon/dist/db/migrations/179_remote_control_observations.js +20 -0
  121. package/daemon/dist/db/migrations/179_remote_control_observations.js.map +1 -0
  122. package/daemon/dist/db/migrations/180_session_stop_attempt.d.ts +5 -0
  123. package/daemon/dist/db/migrations/180_session_stop_attempt.d.ts.map +1 -0
  124. package/daemon/dist/db/migrations/180_session_stop_attempt.js +7 -0
  125. package/daemon/dist/db/migrations/180_session_stop_attempt.js.map +1 -0
  126. package/daemon/dist/db/migrations/181_node_keep_alive.d.ts +8 -0
  127. package/daemon/dist/db/migrations/181_node_keep_alive.d.ts.map +1 -0
  128. package/daemon/dist/db/migrations/181_node_keep_alive.js +26 -0
  129. package/daemon/dist/db/migrations/181_node_keep_alive.js.map +1 -0
  130. package/daemon/dist/db/migrations/182_queue_items_blocked_on_index.d.ts +7 -0
  131. package/daemon/dist/db/migrations/182_queue_items_blocked_on_index.d.ts.map +1 -0
  132. package/daemon/dist/db/migrations/182_queue_items_blocked_on_index.js +11 -0
  133. package/daemon/dist/db/migrations/182_queue_items_blocked_on_index.js.map +1 -0
  134. package/daemon/dist/db/migrations/183_queue_items_scan_indexes.d.ts +8 -0
  135. package/daemon/dist/db/migrations/183_queue_items_scan_indexes.d.ts.map +1 -0
  136. package/daemon/dist/db/migrations/183_queue_items_scan_indexes.js +13 -0
  137. package/daemon/dist/db/migrations/183_queue_items_scan_indexes.js.map +1 -0
  138. package/daemon/dist/db/migrations/184_network_requests.d.ts +11 -0
  139. package/daemon/dist/db/migrations/184_network_requests.d.ts.map +1 -0
  140. package/daemon/dist/db/migrations/184_network_requests.js +32 -0
  141. package/daemon/dist/db/migrations/184_network_requests.js.map +1 -0
  142. package/daemon/dist/db/migrations/185_seat_cold_starts.d.ts +9 -0
  143. package/daemon/dist/db/migrations/185_seat_cold_starts.d.ts.map +1 -0
  144. package/daemon/dist/db/migrations/185_seat_cold_starts.js +19 -0
  145. package/daemon/dist/db/migrations/185_seat_cold_starts.js.map +1 -0
  146. package/daemon/dist/db/migrations/186_queue_relayed_answers.d.ts +3 -0
  147. package/daemon/dist/db/migrations/186_queue_relayed_answers.d.ts.map +1 -0
  148. package/daemon/dist/db/migrations/186_queue_relayed_answers.js +5 -0
  149. package/daemon/dist/db/migrations/186_queue_relayed_answers.js.map +1 -0
  150. package/daemon/dist/db/migrations/189_rig_seat_slice.d.ts +5 -0
  151. package/daemon/dist/db/migrations/189_rig_seat_slice.d.ts.map +1 -0
  152. package/daemon/dist/db/migrations/189_rig_seat_slice.js +7 -0
  153. package/daemon/dist/db/migrations/189_rig_seat_slice.js.map +1 -0
  154. package/daemon/dist/db/migrations/190_queue_transfer_staging.d.ts +3 -0
  155. package/daemon/dist/db/migrations/190_queue_transfer_staging.d.ts.map +1 -0
  156. package/daemon/dist/db/migrations/190_queue_transfer_staging.js +20 -0
  157. package/daemon/dist/db/migrations/190_queue_transfer_staging.js.map +1 -0
  158. package/daemon/dist/db/migrations/191_network_binding_providers.d.ts +3 -0
  159. package/daemon/dist/db/migrations/191_network_binding_providers.d.ts.map +1 -0
  160. package/daemon/dist/db/migrations/191_network_binding_providers.js +27 -0
  161. package/daemon/dist/db/migrations/191_network_binding_providers.js.map +1 -0
  162. package/daemon/dist/db/migrations/194_workflow_run_title.d.ts +4 -0
  163. package/daemon/dist/db/migrations/194_workflow_run_title.d.ts.map +1 -0
  164. package/daemon/dist/db/migrations/194_workflow_run_title.js +6 -0
  165. package/daemon/dist/db/migrations/194_workflow_run_title.js.map +1 -0
  166. package/daemon/dist/domain/activity-taxonomy.d.ts +3 -0
  167. package/daemon/dist/domain/activity-taxonomy.d.ts.map +1 -1
  168. package/daemon/dist/domain/activity-taxonomy.js.map +1 -1
  169. package/daemon/dist/domain/agent-activity-store.d.ts +17 -0
  170. package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
  171. package/daemon/dist/domain/agent-activity-store.js +101 -45
  172. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  173. package/daemon/dist/domain/agent-manifest.d.ts.map +1 -1
  174. package/daemon/dist/domain/agent-manifest.js +6 -0
  175. package/daemon/dist/domain/agent-manifest.js.map +1 -1
  176. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +30 -2
  177. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  178. package/daemon/dist/domain/claude-compaction-enforcer.js +53 -12
  179. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  180. package/daemon/dist/domain/compaction-restore-notice.d.ts +12 -1
  181. package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -1
  182. package/daemon/dist/domain/compaction-restore-notice.js +130 -2
  183. package/daemon/dist/domain/compaction-restore-notice.js.map +1 -1
  184. package/daemon/dist/domain/continuity-policy-materializer.d.ts.map +1 -1
  185. package/daemon/dist/domain/continuity-policy-materializer.js +11 -3
  186. package/daemon/dist/domain/continuity-policy-materializer.js.map +1 -1
  187. package/daemon/dist/domain/core-app-job.d.ts +4 -4
  188. package/daemon/dist/domain/core-app-job.d.ts.map +1 -1
  189. package/daemon/dist/domain/core-app-job.js +4 -59
  190. package/daemon/dist/domain/core-app-job.js.map +1 -1
  191. package/daemon/dist/domain/current-work.d.ts +12 -0
  192. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  193. package/daemon/dist/domain/current-work.js +4 -0
  194. package/daemon/dist/domain/current-work.js.map +1 -1
  195. package/daemon/dist/domain/escalation-owner.d.ts +3 -0
  196. package/daemon/dist/domain/escalation-owner.d.ts.map +1 -1
  197. package/daemon/dist/domain/escalation-owner.js +9 -3
  198. package/daemon/dist/domain/escalation-owner.js.map +1 -1
  199. package/daemon/dist/domain/execution-candidate-reader.d.ts +3 -0
  200. package/daemon/dist/domain/execution-candidate-reader.d.ts.map +1 -1
  201. package/daemon/dist/domain/execution-candidate-reader.js +8 -2
  202. package/daemon/dist/domain/execution-candidate-reader.js.map +1 -1
  203. package/daemon/dist/domain/existing-rig-restore.d.ts +2 -0
  204. package/daemon/dist/domain/existing-rig-restore.d.ts.map +1 -1
  205. package/daemon/dist/domain/existing-rig-restore.js +11 -1
  206. package/daemon/dist/domain/existing-rig-restore.js.map +1 -1
  207. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  208. package/daemon/dist/domain/gateway/slack/inbound.js +49 -8
  209. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  210. package/daemon/dist/domain/gateway/slack/message.d.ts +1 -4
  211. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  212. package/daemon/dist/domain/gateway/slack/message.js +17 -5
  213. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  214. package/daemon/dist/domain/gateway/slack/queue-access.d.ts +7 -1
  215. package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
  216. package/daemon/dist/domain/gateway/slack/queue-access.js +1 -0
  217. package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
  218. package/daemon/dist/domain/gateway/slack/settled-asks.d.ts.map +1 -1
  219. package/daemon/dist/domain/gateway/slack/settled-asks.js +15 -2
  220. package/daemon/dist/domain/gateway/slack/settled-asks.js.map +1 -1
  221. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts +0 -17
  222. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
  223. package/daemon/dist/domain/gateway/slack/slack-delivery.js +10 -40
  224. package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
  225. package/daemon/dist/domain/harness-not-started-notice.d.ts +5 -2
  226. package/daemon/dist/domain/harness-not-started-notice.d.ts.map +1 -1
  227. package/daemon/dist/domain/harness-not-started-notice.js +46 -15
  228. package/daemon/dist/domain/harness-not-started-notice.js.map +1 -1
  229. package/daemon/dist/domain/hosts/read-through.d.ts +1 -1
  230. package/daemon/dist/domain/hosts/read-through.d.ts.map +1 -1
  231. package/daemon/dist/domain/hosts/read-through.js +3 -2
  232. package/daemon/dist/domain/hosts/read-through.js.map +1 -1
  233. package/daemon/dist/domain/hot-potato-enforcer.d.ts +3 -3
  234. package/daemon/dist/domain/hot-potato-enforcer.d.ts.map +1 -1
  235. package/daemon/dist/domain/hot-potato-enforcer.js +2 -2
  236. package/daemon/dist/domain/hot-potato-enforcer.js.map +1 -1
  237. package/daemon/dist/domain/human-questions.d.ts +1 -1
  238. package/daemon/dist/domain/human-questions.d.ts.map +1 -1
  239. package/daemon/dist/domain/human-questions.js +2 -0
  240. package/daemon/dist/domain/human-questions.js.map +1 -1
  241. package/daemon/dist/domain/input-read-diagnostic.js +1 -1
  242. package/daemon/dist/domain/input-read-diagnostic.js.map +1 -1
  243. package/daemon/dist/domain/keep-alive-supervisor.d.ts +178 -0
  244. package/daemon/dist/domain/keep-alive-supervisor.d.ts.map +1 -0
  245. package/daemon/dist/domain/keep-alive-supervisor.js +523 -0
  246. package/daemon/dist/domain/keep-alive-supervisor.js.map +1 -0
  247. package/daemon/dist/domain/mission-control/mission-control-fleet-cli-capability.d.ts +6 -0
  248. package/daemon/dist/domain/mission-control/mission-control-fleet-cli-capability.d.ts.map +1 -1
  249. package/daemon/dist/domain/mission-control/mission-control-fleet-cli-capability.js +38 -9
  250. package/daemon/dist/domain/mission-control/mission-control-fleet-cli-capability.js.map +1 -1
  251. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  252. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +29 -1
  253. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  254. package/daemon/dist/domain/mutation-trace.d.ts +28 -0
  255. package/daemon/dist/domain/mutation-trace.d.ts.map +1 -0
  256. package/daemon/dist/domain/mutation-trace.js +38 -0
  257. package/daemon/dist/domain/mutation-trace.js.map +1 -0
  258. package/daemon/dist/domain/native-resume-probe.d.ts +13 -3
  259. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  260. package/daemon/dist/domain/native-resume-probe.js +54 -17
  261. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  262. package/daemon/dist/domain/network/hub-client.d.ts +30 -1
  263. package/daemon/dist/domain/network/hub-client.d.ts.map +1 -1
  264. package/daemon/dist/domain/network/hub-client.js +62 -9
  265. package/daemon/dist/domain/network/hub-client.js.map +1 -1
  266. package/daemon/dist/domain/network/network-bindings.d.ts +52 -2
  267. package/daemon/dist/domain/network/network-bindings.d.ts.map +1 -1
  268. package/daemon/dist/domain/network/network-bindings.js +217 -23
  269. package/daemon/dist/domain/network/network-bindings.js.map +1 -1
  270. package/daemon/dist/domain/network/network-connector.d.ts +9 -1
  271. package/daemon/dist/domain/network/network-connector.d.ts.map +1 -1
  272. package/daemon/dist/domain/network/network-connector.js +95 -7
  273. package/daemon/dist/domain/network/network-connector.js.map +1 -1
  274. package/daemon/dist/domain/network/network-installations.d.ts.map +1 -1
  275. package/daemon/dist/domain/network/network-installations.js +22 -7
  276. package/daemon/dist/domain/network/network-installations.js.map +1 -1
  277. package/daemon/dist/domain/network/network-provider-removal.d.ts +9 -0
  278. package/daemon/dist/domain/network/network-provider-removal.d.ts.map +1 -0
  279. package/daemon/dist/domain/network/network-provider-removal.js +75 -0
  280. package/daemon/dist/domain/network/network-provider-removal.js.map +1 -0
  281. package/daemon/dist/domain/network/network-requests.d.ts +59 -0
  282. package/daemon/dist/domain/network/network-requests.d.ts.map +1 -0
  283. package/daemon/dist/domain/network/network-requests.js +476 -0
  284. package/daemon/dist/domain/network/network-requests.js.map +1 -0
  285. package/daemon/dist/domain/node-inventory.d.ts +26 -0
  286. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  287. package/daemon/dist/domain/node-inventory.js +87 -7
  288. package/daemon/dist/domain/node-inventory.js.map +1 -1
  289. package/daemon/dist/domain/occupant-invalidator.d.ts +1 -1
  290. package/daemon/dist/domain/occupant-invalidator.d.ts.map +1 -1
  291. package/daemon/dist/domain/occupant-invalidator.js +1 -1
  292. package/daemon/dist/domain/occupant-invalidator.js.map +1 -1
  293. package/daemon/dist/domain/outbox-handler.d.ts +11 -0
  294. package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
  295. package/daemon/dist/domain/outbox-handler.js +20 -0
  296. package/daemon/dist/domain/outbox-handler.js.map +1 -1
  297. package/daemon/dist/domain/parked-query.d.ts +6 -0
  298. package/daemon/dist/domain/parked-query.d.ts.map +1 -1
  299. package/daemon/dist/domain/parked-query.js +14 -4
  300. package/daemon/dist/domain/parked-query.js.map +1 -1
  301. package/daemon/dist/domain/policies/seat-pool.d.ts +13 -0
  302. package/daemon/dist/domain/policies/seat-pool.d.ts.map +1 -1
  303. package/daemon/dist/domain/policies/seat-pool.js +18 -3
  304. package/daemon/dist/domain/policies/seat-pool.js.map +1 -1
  305. package/daemon/dist/domain/profile-resolver.d.ts +7 -1
  306. package/daemon/dist/domain/profile-resolver.d.ts.map +1 -1
  307. package/daemon/dist/domain/profile-resolver.js +7 -0
  308. package/daemon/dist/domain/profile-resolver.js.map +1 -1
  309. package/daemon/dist/domain/progress/progress-indexer.d.ts.map +1 -1
  310. package/daemon/dist/domain/progress/progress-indexer.js +11 -0
  311. package/daemon/dist/domain/progress/progress-indexer.js.map +1 -1
  312. package/daemon/dist/domain/project-lifecycle-compiler.d.ts.map +1 -1
  313. package/daemon/dist/domain/project-lifecycle-compiler.js +4 -1
  314. package/daemon/dist/domain/project-lifecycle-compiler.js.map +1 -1
  315. package/daemon/dist/domain/proof/judgments.d.ts +3 -0
  316. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  317. package/daemon/dist/domain/proof/judgments.js +13 -3
  318. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  319. package/daemon/dist/domain/proof/source-watch.js +4 -4
  320. package/daemon/dist/domain/proof/source-watch.js.map +1 -1
  321. package/daemon/dist/domain/provider/claude-interruption.d.ts +6 -0
  322. package/daemon/dist/domain/provider/claude-interruption.d.ts.map +1 -1
  323. package/daemon/dist/domain/provider/claude-interruption.js +18 -0
  324. package/daemon/dist/domain/provider/claude-interruption.js.map +1 -1
  325. package/daemon/dist/domain/ps-projection.d.ts +8 -1
  326. package/daemon/dist/domain/ps-projection.d.ts.map +1 -1
  327. package/daemon/dist/domain/ps-projection.js +11 -3
  328. package/daemon/dist/domain/ps-projection.js.map +1 -1
  329. package/daemon/dist/domain/queue-erasure.d.ts +3 -0
  330. package/daemon/dist/domain/queue-erasure.d.ts.map +1 -1
  331. package/daemon/dist/domain/queue-erasure.js +2 -2
  332. package/daemon/dist/domain/queue-erasure.js.map +1 -1
  333. package/daemon/dist/domain/queue-owner.d.ts +5 -0
  334. package/daemon/dist/domain/queue-owner.d.ts.map +1 -1
  335. package/daemon/dist/domain/queue-owner.js +16 -8
  336. package/daemon/dist/domain/queue-owner.js.map +1 -1
  337. package/daemon/dist/domain/queue-recorded-graph.d.ts +32 -0
  338. package/daemon/dist/domain/queue-recorded-graph.d.ts.map +1 -0
  339. package/daemon/dist/domain/queue-recorded-graph.js +84 -0
  340. package/daemon/dist/domain/queue-recorded-graph.js.map +1 -0
  341. package/daemon/dist/domain/queue-repository.d.ts +74 -4
  342. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  343. package/daemon/dist/domain/queue-repository.js +398 -25
  344. package/daemon/dist/domain/queue-repository.js.map +1 -1
  345. package/daemon/dist/domain/queue-retention.d.ts +1 -1
  346. package/daemon/dist/domain/queue-retention.d.ts.map +1 -1
  347. package/daemon/dist/domain/queue-retention.js +4 -0
  348. package/daemon/dist/domain/queue-retention.js.map +1 -1
  349. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  350. package/daemon/dist/domain/queue-stuck-sweep.js +43 -9
  351. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  352. package/daemon/dist/domain/queue-transfer-export.d.ts +75 -0
  353. package/daemon/dist/domain/queue-transfer-export.d.ts.map +1 -0
  354. package/daemon/dist/domain/queue-transfer-export.js +156 -0
  355. package/daemon/dist/domain/queue-transfer-export.js.map +1 -0
  356. package/daemon/dist/domain/queue-transfer-format.d.ts +15 -0
  357. package/daemon/dist/domain/queue-transfer-format.d.ts.map +1 -0
  358. package/daemon/dist/domain/queue-transfer-format.js +32 -0
  359. package/daemon/dist/domain/queue-transfer-format.js.map +1 -0
  360. package/daemon/dist/domain/queue-transfer-parse.d.ts +40 -0
  361. package/daemon/dist/domain/queue-transfer-parse.d.ts.map +1 -0
  362. package/daemon/dist/domain/queue-transfer-parse.js +131 -0
  363. package/daemon/dist/domain/queue-transfer-parse.js.map +1 -0
  364. package/daemon/dist/domain/queue-transfer-review.d.ts +22 -0
  365. package/daemon/dist/domain/queue-transfer-review.d.ts.map +1 -0
  366. package/daemon/dist/domain/queue-transfer-review.js +81 -0
  367. package/daemon/dist/domain/queue-transfer-review.js.map +1 -0
  368. package/daemon/dist/domain/queue-transfer-staging.d.ts +79 -0
  369. package/daemon/dist/domain/queue-transfer-staging.d.ts.map +1 -0
  370. package/daemon/dist/domain/queue-transfer-staging.js +67 -0
  371. package/daemon/dist/domain/queue-transfer-staging.js.map +1 -0
  372. package/daemon/dist/domain/queue-wake-ladder.d.ts +4 -0
  373. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  374. package/daemon/dist/domain/queue-wake-ladder.js +161 -20
  375. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  376. package/daemon/dist/domain/reconciler.d.ts +27 -2
  377. package/daemon/dist/domain/reconciler.d.ts.map +1 -1
  378. package/daemon/dist/domain/reconciler.js +184 -16
  379. package/daemon/dist/domain/reconciler.js.map +1 -1
  380. package/daemon/dist/domain/refusal-trace.d.ts +15 -0
  381. package/daemon/dist/domain/refusal-trace.d.ts.map +1 -0
  382. package/daemon/dist/domain/refusal-trace.js +23 -0
  383. package/daemon/dist/domain/refusal-trace.js.map +1 -0
  384. package/daemon/dist/domain/relayed-answers.d.ts +80 -0
  385. package/daemon/dist/domain/relayed-answers.d.ts.map +1 -0
  386. package/daemon/dist/domain/relayed-answers.js +8 -0
  387. package/daemon/dist/domain/relayed-answers.js.map +1 -0
  388. package/daemon/dist/domain/remote-control-observations.d.ts +50 -0
  389. package/daemon/dist/domain/remote-control-observations.d.ts.map +1 -0
  390. package/daemon/dist/domain/remote-control-observations.js +72 -0
  391. package/daemon/dist/domain/remote-control-observations.js.map +1 -0
  392. package/daemon/dist/domain/restore-attempt-receipt.d.ts.map +1 -1
  393. package/daemon/dist/domain/restore-attempt-receipt.js +8 -2
  394. package/daemon/dist/domain/restore-attempt-receipt.js.map +1 -1
  395. package/daemon/dist/domain/restore-orchestrator.d.ts +67 -6
  396. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  397. package/daemon/dist/domain/restore-orchestrator.js +345 -51
  398. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  399. package/daemon/dist/domain/rig-lifecycle-service.d.ts.map +1 -1
  400. package/daemon/dist/domain/rig-lifecycle-service.js +4 -1
  401. package/daemon/dist/domain/rig-lifecycle-service.js.map +1 -1
  402. package/daemon/dist/domain/rig-repository.d.ts +21 -3
  403. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  404. package/daemon/dist/domain/rig-repository.js +67 -2
  405. package/daemon/dist/domain/rig-repository.js.map +1 -1
  406. package/daemon/dist/domain/rig-teardown.d.ts +22 -7
  407. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  408. package/daemon/dist/domain/rig-teardown.js +108 -24
  409. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  410. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  411. package/daemon/dist/domain/rigspec-codec.js +12 -0
  412. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  413. package/daemon/dist/domain/rigspec-exporter.d.ts +14 -0
  414. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  415. package/daemon/dist/domain/rigspec-exporter.js +56 -14
  416. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  417. package/daemon/dist/domain/rigspec-instantiator.d.ts +32 -3
  418. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  419. package/daemon/dist/domain/rigspec-instantiator.js +121 -23
  420. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  421. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  422. package/daemon/dist/domain/rigspec-schema.js +30 -4
  423. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  424. package/daemon/dist/domain/rosters.d.ts +1 -0
  425. package/daemon/dist/domain/rosters.d.ts.map +1 -1
  426. package/daemon/dist/domain/rosters.js +5 -4
  427. package/daemon/dist/domain/rosters.js.map +1 -1
  428. package/daemon/dist/domain/seat-activity-service.d.ts +4 -0
  429. package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  430. package/daemon/dist/domain/seat-activity-service.js +24 -5
  431. package/daemon/dist/domain/seat-activity-service.js.map +1 -1
  432. package/daemon/dist/domain/seat-attention-reconciler.d.ts +7 -0
  433. package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
  434. package/daemon/dist/domain/seat-attention-reconciler.js +149 -65
  435. package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
  436. package/daemon/dist/domain/seat-cold-start.d.ts +150 -0
  437. package/daemon/dist/domain/seat-cold-start.d.ts.map +1 -0
  438. package/daemon/dist/domain/seat-cold-start.js +371 -0
  439. package/daemon/dist/domain/seat-cold-start.js.map +1 -0
  440. package/daemon/dist/domain/seat-delivery-guard.d.ts +11 -2
  441. package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
  442. package/daemon/dist/domain/seat-delivery-guard.js +34 -6
  443. package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
  444. package/daemon/dist/domain/seat-identity-reconciler.d.ts +13 -0
  445. package/daemon/dist/domain/seat-identity-reconciler.d.ts.map +1 -1
  446. package/daemon/dist/domain/seat-identity-reconciler.js +63 -23
  447. package/daemon/dist/domain/seat-identity-reconciler.js.map +1 -1
  448. package/daemon/dist/domain/seat-identity-store.d.ts +5 -3
  449. package/daemon/dist/domain/seat-identity-store.d.ts.map +1 -1
  450. package/daemon/dist/domain/seat-identity-store.js +7 -3
  451. package/daemon/dist/domain/seat-identity-store.js.map +1 -1
  452. package/daemon/dist/domain/seat-launch-environment.d.ts +2 -0
  453. package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
  454. package/daemon/dist/domain/seat-launch-environment.js +9 -1
  455. package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
  456. package/daemon/dist/domain/seat-lifecycle-service.d.ts +17 -0
  457. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  458. package/daemon/dist/domain/seat-lifecycle-service.js +176 -22
  459. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  460. package/daemon/dist/domain/seat-pool-executor.d.ts +116 -0
  461. package/daemon/dist/domain/seat-pool-executor.d.ts.map +1 -0
  462. package/daemon/dist/domain/seat-pool-executor.js +565 -0
  463. package/daemon/dist/domain/seat-pool-executor.js.map +1 -0
  464. package/daemon/dist/domain/seat-pool-registration.d.ts +93 -0
  465. package/daemon/dist/domain/seat-pool-registration.d.ts.map +1 -0
  466. package/daemon/dist/domain/seat-pool-registration.js +149 -0
  467. package/daemon/dist/domain/seat-pool-registration.js.map +1 -0
  468. package/daemon/dist/domain/seat-pool-slots.d.ts +42 -0
  469. package/daemon/dist/domain/seat-pool-slots.d.ts.map +1 -1
  470. package/daemon/dist/domain/seat-pool-slots.js +51 -0
  471. package/daemon/dist/domain/seat-pool-slots.js.map +1 -1
  472. package/daemon/dist/domain/seat-restart-in-place.d.ts +15 -0
  473. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  474. package/daemon/dist/domain/seat-restart-in-place.js +54 -2
  475. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  476. package/daemon/dist/domain/seat-runtime-home-record.d.ts +8 -0
  477. package/daemon/dist/domain/seat-runtime-home-record.d.ts.map +1 -1
  478. package/daemon/dist/domain/seat-runtime-home-record.js +1 -1
  479. package/daemon/dist/domain/seat-runtime-home-record.js.map +1 -1
  480. package/daemon/dist/domain/session-registry.d.ts +22 -3
  481. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  482. package/daemon/dist/domain/session-registry.js +38 -6
  483. package/daemon/dist/domain/session-registry.js.map +1 -1
  484. package/daemon/dist/domain/session-transport.d.ts +18 -2
  485. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  486. package/daemon/dist/domain/session-transport.js +65 -38
  487. package/daemon/dist/domain/session-transport.js.map +1 -1
  488. package/daemon/dist/domain/slices/slice-indexer.d.ts +55 -0
  489. package/daemon/dist/domain/slices/slice-indexer.d.ts.map +1 -1
  490. package/daemon/dist/domain/slices/slice-indexer.js +259 -50
  491. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  492. package/daemon/dist/domain/startup-orchestrator.d.ts +1 -1
  493. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  494. package/daemon/dist/domain/startup-orchestrator.js +75 -23
  495. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  496. package/daemon/dist/domain/startup-proof.d.ts +6 -0
  497. package/daemon/dist/domain/startup-proof.d.ts.map +1 -1
  498. package/daemon/dist/domain/startup-proof.js +11 -0
  499. package/daemon/dist/domain/startup-proof.js.map +1 -1
  500. package/daemon/dist/domain/startup-submission-evidence.d.ts +2 -0
  501. package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
  502. package/daemon/dist/domain/startup-submission-evidence.js +31 -3
  503. package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
  504. package/daemon/dist/domain/terminal/herdr-adapter.d.ts +2 -0
  505. package/daemon/dist/domain/terminal/herdr-adapter.d.ts.map +1 -1
  506. package/daemon/dist/domain/terminal/herdr-adapter.js +2 -0
  507. package/daemon/dist/domain/terminal/herdr-adapter.js.map +1 -1
  508. package/daemon/dist/domain/terminal/scope-task-terminal-view.d.ts +2 -1
  509. package/daemon/dist/domain/terminal/scope-task-terminal-view.d.ts.map +1 -1
  510. package/daemon/dist/domain/terminal/scope-task-terminal-view.js +80 -38
  511. package/daemon/dist/domain/terminal/scope-task-terminal-view.js.map +1 -1
  512. package/daemon/dist/domain/terminal/terminal-provider.d.ts +2 -0
  513. package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
  514. package/daemon/dist/domain/terminal/terminal-service.d.ts +3 -0
  515. package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
  516. package/daemon/dist/domain/terminal/terminal-service.js +30 -26
  517. package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
  518. package/daemon/dist/domain/terminal/tile-attach.d.ts +22 -0
  519. package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -1
  520. package/daemon/dist/domain/terminal/tile-attach.js +71 -0
  521. package/daemon/dist/domain/terminal/tile-attach.js.map +1 -1
  522. package/daemon/dist/domain/terminal/view-composer.d.ts +2 -0
  523. package/daemon/dist/domain/terminal/view-composer.d.ts.map +1 -1
  524. package/daemon/dist/domain/terminal/view-composer.js +4 -2
  525. package/daemon/dist/domain/terminal/view-composer.js.map +1 -1
  526. package/daemon/dist/domain/topology-trace.d.ts +40 -0
  527. package/daemon/dist/domain/topology-trace.d.ts.map +1 -0
  528. package/daemon/dist/domain/topology-trace.js +106 -0
  529. package/daemon/dist/domain/topology-trace.js.map +1 -0
  530. package/daemon/dist/domain/transcript-store.d.ts.map +1 -1
  531. package/daemon/dist/domain/transcript-store.js +12 -1
  532. package/daemon/dist/domain/transcript-store.js.map +1 -1
  533. package/daemon/dist/domain/types.d.ts +104 -8
  534. package/daemon/dist/domain/types.d.ts.map +1 -1
  535. package/daemon/dist/domain/types.js +3 -2
  536. package/daemon/dist/domain/types.js.map +1 -1
  537. package/daemon/dist/domain/user-settings/settings-browser.d.ts.map +1 -1
  538. package/daemon/dist/domain/user-settings/settings-browser.js +2 -0
  539. package/daemon/dist/domain/user-settings/settings-browser.js.map +1 -1
  540. package/daemon/dist/domain/user-settings/settings-store.d.ts +1 -1
  541. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  542. package/daemon/dist/domain/user-settings/settings-store.js +13 -0
  543. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  544. package/daemon/dist/domain/watchdog-jobs-repository.d.ts +5 -3
  545. package/daemon/dist/domain/watchdog-jobs-repository.d.ts.map +1 -1
  546. package/daemon/dist/domain/watchdog-jobs-repository.js +6 -1
  547. package/daemon/dist/domain/watchdog-jobs-repository.js.map +1 -1
  548. package/daemon/dist/domain/watchdog-policy-engine.d.ts +8 -1
  549. package/daemon/dist/domain/watchdog-policy-engine.d.ts.map +1 -1
  550. package/daemon/dist/domain/watchdog-policy-engine.js +6 -2
  551. package/daemon/dist/domain/watchdog-policy-engine.js.map +1 -1
  552. package/daemon/dist/domain/workflow-instance-store.d.ts +2 -0
  553. package/daemon/dist/domain/workflow-instance-store.d.ts.map +1 -1
  554. package/daemon/dist/domain/workflow-instance-store.js +11 -2
  555. package/daemon/dist/domain/workflow-instance-store.js.map +1 -1
  556. package/daemon/dist/domain/workflow-projector.d.ts +3 -1
  557. package/daemon/dist/domain/workflow-projector.d.ts.map +1 -1
  558. package/daemon/dist/domain/workflow-projector.js +58 -10
  559. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  560. package/daemon/dist/domain/workflow-run-title.d.ts +4 -0
  561. package/daemon/dist/domain/workflow-run-title.d.ts.map +1 -0
  562. package/daemon/dist/domain/workflow-run-title.js +5 -0
  563. package/daemon/dist/domain/workflow-run-title.js.map +1 -0
  564. package/daemon/dist/domain/workflow-runtime.d.ts +1 -0
  565. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  566. package/daemon/dist/domain/workflow-runtime.js +3 -1
  567. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  568. package/daemon/dist/domain/workflow-spec-cache.d.ts +2 -2
  569. package/daemon/dist/domain/workflow-spec-cache.d.ts.map +1 -1
  570. package/daemon/dist/domain/workflow-spec-cache.js +20 -1
  571. package/daemon/dist/domain/workflow-spec-cache.js.map +1 -1
  572. package/daemon/dist/domain/workflow-types.d.ts +15 -0
  573. package/daemon/dist/domain/workflow-types.d.ts.map +1 -1
  574. package/daemon/dist/domain/workflow-types.js +4 -0
  575. package/daemon/dist/domain/workflow-types.js.map +1 -1
  576. package/daemon/dist/domain/workspace/project-read.d.ts +10 -0
  577. package/daemon/dist/domain/workspace/project-read.d.ts.map +1 -1
  578. package/daemon/dist/domain/workspace/project-read.js +34 -2
  579. package/daemon/dist/domain/workspace/project-read.js.map +1 -1
  580. package/daemon/dist/index.d.ts.map +1 -1
  581. package/daemon/dist/index.js +7 -1
  582. package/daemon/dist/index.js.map +1 -1
  583. package/daemon/dist/queue-transfer-export-surface.d.ts +33 -0
  584. package/daemon/dist/queue-transfer-export-surface.d.ts.map +1 -0
  585. package/daemon/dist/queue-transfer-export-surface.js +13 -0
  586. package/daemon/dist/queue-transfer-export-surface.js.map +1 -0
  587. package/daemon/dist/queue-transfer-staging-surface.d.ts +86 -0
  588. package/daemon/dist/queue-transfer-staging-surface.d.ts.map +1 -0
  589. package/daemon/dist/queue-transfer-staging-surface.js +91 -0
  590. package/daemon/dist/queue-transfer-staging-surface.js.map +1 -0
  591. package/daemon/dist/routes/activity.d.ts.map +1 -1
  592. package/daemon/dist/routes/activity.js +46 -0
  593. package/daemon/dist/routes/activity.js.map +1 -1
  594. package/daemon/dist/routes/compaction.d.ts.map +1 -1
  595. package/daemon/dist/routes/compaction.js +7 -2
  596. package/daemon/dist/routes/compaction.js.map +1 -1
  597. package/daemon/dist/routes/context-packs.d.ts.map +1 -1
  598. package/daemon/dist/routes/context-packs.js +23 -1
  599. package/daemon/dist/routes/context-packs.js.map +1 -1
  600. package/daemon/dist/routes/events.js +7 -4
  601. package/daemon/dist/routes/events.js.map +1 -1
  602. package/daemon/dist/routes/network.d.ts +2 -0
  603. package/daemon/dist/routes/network.d.ts.map +1 -1
  604. package/daemon/dist/routes/network.js +62 -1
  605. package/daemon/dist/routes/network.js.map +1 -1
  606. package/daemon/dist/routes/ps.js +12 -1
  607. package/daemon/dist/routes/ps.js.map +1 -1
  608. package/daemon/dist/routes/queue.d.ts.map +1 -1
  609. package/daemon/dist/routes/queue.js +155 -52
  610. package/daemon/dist/routes/queue.js.map +1 -1
  611. package/daemon/dist/routes/require-sender-identity.d.ts.map +1 -1
  612. package/daemon/dist/routes/require-sender-identity.js +6 -3
  613. package/daemon/dist/routes/require-sender-identity.js.map +1 -1
  614. package/daemon/dist/routes/rigs.js +2 -0
  615. package/daemon/dist/routes/rigs.js.map +1 -1
  616. package/daemon/dist/routes/seat.d.ts.map +1 -1
  617. package/daemon/dist/routes/seat.js +12 -5
  618. package/daemon/dist/routes/seat.js.map +1 -1
  619. package/daemon/dist/routes/sessions.d.ts.map +1 -1
  620. package/daemon/dist/routes/sessions.js +14 -0
  621. package/daemon/dist/routes/sessions.js.map +1 -1
  622. package/daemon/dist/routes/slices.d.ts.map +1 -1
  623. package/daemon/dist/routes/slices.js +16 -7
  624. package/daemon/dist/routes/slices.js.map +1 -1
  625. package/daemon/dist/routes/startup.d.ts.map +1 -1
  626. package/daemon/dist/routes/startup.js +49 -4
  627. package/daemon/dist/routes/startup.js.map +1 -1
  628. package/daemon/dist/routes/terminal-ws.js +28 -2
  629. package/daemon/dist/routes/terminal-ws.js.map +1 -1
  630. package/daemon/dist/routes/terminal.d.ts.map +1 -1
  631. package/daemon/dist/routes/terminal.js +3 -2
  632. package/daemon/dist/routes/terminal.js.map +1 -1
  633. package/daemon/dist/routes/transport.d.ts.map +1 -1
  634. package/daemon/dist/routes/transport.js +14 -2
  635. package/daemon/dist/routes/transport.js.map +1 -1
  636. package/daemon/dist/routes/up.js +2 -0
  637. package/daemon/dist/routes/up.js.map +1 -1
  638. package/daemon/dist/routes/workflow.d.ts.map +1 -1
  639. package/daemon/dist/routes/workflow.js +9 -3
  640. package/daemon/dist/routes/workflow.js.map +1 -1
  641. package/daemon/dist/server.d.ts +7 -0
  642. package/daemon/dist/server.d.ts.map +1 -1
  643. package/daemon/dist/server.js +8 -0
  644. package/daemon/dist/server.js.map +1 -1
  645. package/daemon/dist/startup.d.ts +3 -0
  646. package/daemon/dist/startup.d.ts.map +1 -1
  647. package/daemon/dist/startup.js +133 -7
  648. package/daemon/dist/startup.js.map +1 -1
  649. package/daemon/dist/terminal/TerminalSessionBroker.d.ts +10 -0
  650. package/daemon/dist/terminal/TerminalSessionBroker.d.ts.map +1 -1
  651. package/daemon/dist/terminal/TerminalSessionBroker.js +63 -4
  652. package/daemon/dist/terminal/TerminalSessionBroker.js.map +1 -1
  653. package/daemon/dist/topology-trace-surface.d.ts +2 -0
  654. package/daemon/dist/topology-trace-surface.d.ts.map +1 -0
  655. package/daemon/dist/topology-trace-surface.js +2 -0
  656. package/daemon/dist/topology-trace-surface.js.map +1 -0
  657. package/daemon/docs/reference/acp-agents.md +2 -1
  658. package/daemon/docs/reference/agent-spec.md +3 -1
  659. package/daemon/docs/reference/agent-startup-guide.md +3 -1
  660. package/daemon/docs/reference/agent-state-taxonomy.md +35 -1
  661. package/daemon/docs/reference/checked-seat-stop.md +11 -1
  662. package/daemon/docs/reference/claude-status-line.md +7 -0
  663. package/daemon/docs/reference/daemon-http-clients.md +120 -18
  664. package/daemon/docs/reference/gateway-participants.md +6 -0
  665. package/daemon/docs/reference/getting-started.md +119 -12
  666. package/daemon/docs/reference/hosted-members.md +114 -0
  667. package/daemon/docs/reference/inventory-request-diagnostics.md +22 -0
  668. package/daemon/docs/reference/network-connector.md +112 -4
  669. package/daemon/docs/reference/project-workspace.md +11 -2
  670. package/daemon/docs/reference/queue-erasure.md +1 -1
  671. package/daemon/docs/reference/queue-transfer-export.md +38 -0
  672. package/daemon/docs/reference/queue-transfer-staging.md +39 -0
  673. package/daemon/docs/reference/quickstart.md +4 -4
  674. package/daemon/docs/reference/refocus-channel.md +5 -2
  675. package/daemon/docs/reference/rig-spec.md +193 -3
  676. package/daemon/docs/reference/rosters.md +18 -3
  677. package/daemon/docs/reference/sdlc-conventions.md +1 -1
  678. package/daemon/docs/reference/seat-delivery.md +21 -4
  679. package/daemon/docs/reference/seat-pools.md +116 -0
  680. package/daemon/docs/reference/terminal-sessions.md +57 -11
  681. package/daemon/docs/reference/tmux-servers.md +27 -2
  682. package/daemon/docs/reference/whats-new.md +92 -12
  683. package/daemon/specs/agents/shared/skills/core/messaging-the-human/SKILL.md +1 -1
  684. package/dist/build-info.js +3 -3
  685. package/dist/client.d.ts +2 -1
  686. package/dist/client.d.ts.map +1 -1
  687. package/dist/commands/broadcast.d.ts.map +1 -1
  688. package/dist/commands/broadcast.js +87 -8
  689. package/dist/commands/broadcast.js.map +1 -1
  690. package/dist/commands/chatroom.d.ts +3 -0
  691. package/dist/commands/chatroom.d.ts.map +1 -1
  692. package/dist/commands/chatroom.js +7 -1
  693. package/dist/commands/chatroom.js.map +1 -1
  694. package/dist/commands/config.d.ts.map +1 -1
  695. package/dist/commands/config.js +2 -1
  696. package/dist/commands/config.js.map +1 -1
  697. package/dist/commands/daemon.d.ts.map +1 -1
  698. package/dist/commands/daemon.js +18 -15
  699. package/dist/commands/daemon.js.map +1 -1
  700. package/dist/commands/exec.d.ts.map +1 -1
  701. package/dist/commands/exec.js +22 -13
  702. package/dist/commands/exec.js.map +1 -1
  703. package/dist/commands/export.d.ts.map +1 -1
  704. package/dist/commands/export.js +5 -1
  705. package/dist/commands/export.js.map +1 -1
  706. package/dist/commands/gateway.d.ts +4 -0
  707. package/dist/commands/gateway.d.ts.map +1 -1
  708. package/dist/commands/gateway.js +37 -0
  709. package/dist/commands/gateway.js.map +1 -1
  710. package/dist/commands/network.d.ts.map +1 -1
  711. package/dist/commands/network.js +54 -1
  712. package/dist/commands/network.js.map +1 -1
  713. package/dist/commands/parked.d.ts.map +1 -1
  714. package/dist/commands/parked.js +12 -6
  715. package/dist/commands/parked.js.map +1 -1
  716. package/dist/commands/provider.d.ts.map +1 -1
  717. package/dist/commands/provider.js +3 -2
  718. package/dist/commands/provider.js.map +1 -1
  719. package/dist/commands/ps.d.ts +12 -1
  720. package/dist/commands/ps.d.ts.map +1 -1
  721. package/dist/commands/ps.js +43 -10
  722. package/dist/commands/ps.js.map +1 -1
  723. package/dist/commands/queue-export.d.ts +3 -0
  724. package/dist/commands/queue-export.d.ts.map +1 -0
  725. package/dist/commands/queue-export.js +67 -0
  726. package/dist/commands/queue-export.js.map +1 -0
  727. package/dist/commands/queue-import.d.ts +4 -0
  728. package/dist/commands/queue-import.d.ts.map +1 -0
  729. package/dist/commands/queue-import.js +47 -0
  730. package/dist/commands/queue-import.js.map +1 -0
  731. package/dist/commands/queue.d.ts +1 -1
  732. package/dist/commands/queue.d.ts.map +1 -1
  733. package/dist/commands/queue.js +50 -1
  734. package/dist/commands/queue.js.map +1 -1
  735. package/dist/commands/roster.js +1 -1
  736. package/dist/commands/roster.js.map +1 -1
  737. package/dist/commands/scope.d.ts.map +1 -1
  738. package/dist/commands/scope.js +30 -18
  739. package/dist/commands/scope.js.map +1 -1
  740. package/dist/commands/seat.d.ts.map +1 -1
  741. package/dist/commands/seat.js +20 -2
  742. package/dist/commands/seat.js.map +1 -1
  743. package/dist/commands/send.d.ts.map +1 -1
  744. package/dist/commands/send.js +15 -3
  745. package/dist/commands/send.js.map +1 -1
  746. package/dist/commands/start.d.ts +14 -0
  747. package/dist/commands/start.d.ts.map +1 -1
  748. package/dist/commands/start.js +54 -5
  749. package/dist/commands/start.js.map +1 -1
  750. package/dist/commands/workflow.d.ts.map +1 -1
  751. package/dist/commands/workflow.js +4 -0
  752. package/dist/commands/workflow.js.map +1 -1
  753. package/dist/config-store.d.ts +2 -1
  754. package/dist/config-store.d.ts.map +1 -1
  755. package/dist/config-store.js +14 -1
  756. package/dist/config-store.js.map +1 -1
  757. package/dist/cross-host-executor.d.ts +3 -0
  758. package/dist/cross-host-executor.d.ts.map +1 -1
  759. package/dist/cross-host-executor.js +5 -0
  760. package/dist/cross-host-executor.js.map +1 -1
  761. package/dist/daemon-auto-start.d.ts.map +1 -1
  762. package/dist/daemon-auto-start.js +1 -0
  763. package/dist/daemon-auto-start.js.map +1 -1
  764. package/dist/daemon-lifecycle.d.ts +6 -1
  765. package/dist/daemon-lifecycle.d.ts.map +1 -1
  766. package/dist/daemon-lifecycle.js +90 -30
  767. package/dist/daemon-lifecycle.js.map +1 -1
  768. package/dist/daemon-start-lock.d.ts +38 -3
  769. package/dist/daemon-start-lock.d.ts.map +1 -1
  770. package/dist/daemon-start-lock.js +201 -48
  771. package/dist/daemon-start-lock.js.map +1 -1
  772. package/dist/lib/scope/progress-edit.d.ts.map +1 -1
  773. package/dist/lib/scope/progress-edit.js +10 -0
  774. package/dist/lib/scope/progress-edit.js.map +1 -1
  775. package/dist/lib/topology-trace.d.ts +3 -34
  776. package/dist/lib/topology-trace.d.ts.map +1 -1
  777. package/dist/lib/topology-trace.js +3 -97
  778. package/dist/lib/topology-trace.js.map +1 -1
  779. package/dist/local-db.d.ts +2 -0
  780. package/dist/local-db.d.ts.map +1 -1
  781. package/dist/local-db.js +14 -11
  782. package/dist/local-db.js.map +1 -1
  783. package/dist/mcp-caller-resolver.d.ts +36 -0
  784. package/dist/mcp-caller-resolver.d.ts.map +1 -0
  785. package/dist/mcp-caller-resolver.js +82 -0
  786. package/dist/mcp-caller-resolver.js.map +1 -0
  787. package/dist/mcp-http.d.ts +43 -2
  788. package/dist/mcp-http.d.ts.map +1 -1
  789. package/dist/mcp-http.js +223 -46
  790. package/dist/mcp-http.js.map +1 -1
  791. package/dist/mcp-server.d.ts +23 -0
  792. package/dist/mcp-server.d.ts.map +1 -1
  793. package/dist/mcp-server.js +108 -39
  794. package/dist/mcp-server.js.map +1 -1
  795. package/dist/mcp-surface.d.ts +3 -2
  796. package/dist/mcp-surface.d.ts.map +1 -1
  797. package/dist/node-support.d.ts.map +1 -1
  798. package/dist/node-support.js +10 -0
  799. package/dist/node-support.js.map +1 -1
  800. package/dist/remote-host-ops.d.ts +3 -0
  801. package/dist/remote-host-ops.d.ts.map +1 -1
  802. package/dist/remote-host-ops.js +15 -1
  803. package/dist/remote-host-ops.js.map +1 -1
  804. package/package.json +3 -3
  805. package/scripts/check-abi.mjs +15 -0
  806. package/tui/dist/attention/attention-model.d.ts.map +1 -1
  807. package/tui/dist/attention/attention-model.js +8 -4
  808. package/tui/dist/attention/attention-model.js.map +1 -1
  809. package/tui/dist/crash-cart/start-daemon.d.ts +20 -0
  810. package/tui/dist/crash-cart/start-daemon.d.ts.map +1 -1
  811. package/tui/dist/crash-cart/start-daemon.js +56 -0
  812. package/tui/dist/crash-cart/start-daemon.js.map +1 -1
  813. package/tui/dist/hydrate.d.ts.map +1 -1
  814. package/tui/dist/hydrate.js +4 -2
  815. package/tui/dist/hydrate.js.map +1 -1
  816. package/tui/dist/main.js +24 -8
  817. package/tui/dist/main.js.map +1 -1
  818. package/tui/dist/render.d.ts +2 -0
  819. package/tui/dist/render.d.ts.map +1 -1
  820. package/tui/dist/render.js +41 -9
  821. package/tui/dist/render.js.map +1 -1
@@ -56,7 +56,10 @@ import { seatAdapter } from "../adapters/community-harness-runtime-adapter.js";
56
56
  import { pluginPathsOf } from "./claude-core-plugin-env.js";
57
57
  import { seatLaunchAdditionsForLaunch, systemPromptPendingNoteForNode } from "./seat-launch-additions.js";
58
58
  import { resolveSeatKind, seatProcessOwner } from "./seat-kinds.js";
59
+ import { SeatPoolSlotsRepository } from "./seat-pool-slots.js";
59
60
  export { resolveActiveSnapshotSession } from "./active-occupant.js";
61
+ /** Restore outcomes that leave a session running (or parked on a prompt), the seats whose continuity notice is armed again. */
62
+ const CONTINUITY_ARMED_STATUSES = new Set(["resumed", "rebuilt", "fresh-primed", "attention_required", "operator_recovered"]);
60
63
  export function rollupRestoreRigResult(nodes) {
61
64
  if (nodes.length === 0)
62
65
  return "failed";
@@ -178,6 +181,7 @@ export class RestoreOrchestrator {
178
181
  freshLaunch;
179
182
  freshLaunchAvailable;
180
183
  seatSkillSelection;
184
+ armContinuity;
181
185
  routerLineSettings;
182
186
  getDesiredClaudeActivityHooks;
183
187
  appliedLaunchStore;
@@ -222,6 +226,7 @@ export class RestoreOrchestrator {
222
226
  this.freshLaunch = deps.freshLaunch;
223
227
  this.freshLaunchAvailable = deps.freshLaunchAvailable;
224
228
  this.seatSkillSelection = deps.seatSkillSelection;
229
+ this.armContinuity = deps.armContinuity;
225
230
  this.getDesiredClaudeActivityHooks = deps.getDesiredClaudeActivityHooks;
226
231
  this.harnessNotStartedNotice = deps.harnessNotStartedNotice;
227
232
  this.routerLineSettings = deps.routerLineSettings;
@@ -300,7 +305,32 @@ export class RestoreOrchestrator {
300
305
  // detached is not "running" in one warning and "detached" in the other (the maintainer's 3rd review of #3250).
301
306
  // The sessions the classification above already found stale are named detached, the status this restore gives them.
302
307
  const observed = this.observeConversationRecords(rigId, snapshot.data, opts?.freshLogicalIds, currentRuntimes, classification.stale);
303
- const validation = validatePreRestore(snapshot.data, {
308
+ // #3395: a seat pool agent the pool drained stays down. Restore doesn't start it and names it in `keptDown`, outside
309
+ // the node results, so the rig's result is the rest of the rig's. Restore launches a seat by its logical id, so the
310
+ // match is by logical id: a snapshot that saved the seat under an earlier node id still keeps it down.
311
+ // The pool read runs on every restore, pool or not: a seat whose read fails is restored as an ordinary seat and named
312
+ // in a warning, so that read alone doesn't fail the restore. Every other read here still fails it.
313
+ const slots = new SeatPoolSlotsRepository(this.db);
314
+ const drainedByLogicalId = new Map();
315
+ const poolUnknown = [];
316
+ let poolReadError = "";
317
+ for (const current of this.rigRepo.getRig(rigId)?.nodes ?? []) {
318
+ let drained;
319
+ try {
320
+ drained = slots.isDrainedPoolNode(current.id);
321
+ }
322
+ catch (err) {
323
+ poolUnknown.push(current.logicalId);
324
+ poolReadError = err instanceof Error ? err.message : String(err);
325
+ continue;
326
+ }
327
+ if (drained)
328
+ drainedByLogicalId.set(current.logicalId, current.id);
329
+ }
330
+ const poolWarnings = poolUnknown.length === 0 ? [] : [`Restore: the seat pool read failed for ${poolUnknown.join(", ")} `
331
+ + `(${poolReadError}); restore treats ${poolUnknown.length === 1 ? "it" : "them"} as ordinary seats.`];
332
+ const drainedLogicalIds = [...drainedByLogicalId.keys()];
333
+ const checked = validatePreRestore(snapshot.data, {
304
334
  fsOps: opts?.fsOps,
305
335
  servicesRecord: this.rigRepo.getServicesRecord(rigId),
306
336
  freshLogicalIds: opts?.freshLogicalIds,
@@ -310,8 +340,16 @@ export class RestoreOrchestrator {
310
340
  .map((current) => [current.logicalId, current.codexConfigProfile])),
311
341
  ...(opts?.cwdOverride ? { cwdOverride: opts.cwdOverride } : {}),
312
342
  currentStatuses: observed.currentStatuses,
313
- attachedLogicalIds: observed.attachedLogicalIds,
343
+ // A kept-down agent is not among the seats this restore resumes; it is compared as an agent outside it.
344
+ attachedLogicalIds: [...observed.attachedLogicalIds, ...drainedLogicalIds],
314
345
  });
346
+ // A seat this restore keeps down doesn't block the restore: its blocker is a caveat, as for any seat restore leaves.
347
+ const drainedSaved = new Set(snapshot.data.nodes.filter((node) => drainedByLogicalId.has(node.logicalId)).map((node) => node.id));
348
+ const keptBlocker = (blocker) => (!!blocker.nodeId && drainedSaved.has(blocker.nodeId)) || (!!blocker.logicalId && drainedByLogicalId.has(blocker.logicalId));
349
+ const validation = {
350
+ blockers: checked.blockers.filter((blocker) => !keptBlocker(blocker)),
351
+ warnings: [...poolWarnings, ...checked.warnings, ...checked.blockers.filter(keptBlocker).map((blocker) => `${blocker.code}: ${blocker.message} (restore keeps ${blocker.logicalId ?? "this drained pool agent"} down, so this doesn't block a restore)`)],
352
+ };
315
353
  const topology = resolveSnapshotRestoreTopology(snapshot.data);
316
354
  // A seat that is still a node of this rig but isn't in the snapshot's intended roster isn't started by this restore:
317
355
  // one claimed with rig bind or rig attach after the rig's topology was recorded, or one added or claimed after this
@@ -324,13 +362,24 @@ export class RestoreOrchestrator {
324
362
  const intendedLiveIds = new Set(liveNodes.filter(current => topology.intendedRoster.some(intended => intended.logicalId === current.logicalId))
325
363
  .map(current => current.id));
326
364
  const narrowedRoster = snapshot.data.topologyRoster?.source === "operator_explicit";
327
- const excludedNodes = [
365
+ // A kept-down agent this restore would otherwise name as skipped is kept down the same way.
366
+ const skippedDrained = (excluded) => excluded.reason === "current_seat_not_in_intended_roster" && drainedByLogicalId.get(excluded.logicalId) === excluded.nodeId;
367
+ const notIntended = [
328
368
  ...topology.excludedNodes.map((excluded) => !narrowedRoster && liveNodeIds.has(excluded.nodeId)
329
369
  ? { ...excluded, reason: "current_seat_not_in_intended_roster" } : excluded),
330
370
  ...(narrowedRoster ? [] : liveNodes.filter((current) => !snapshotNodeIds.has(current.id) && !intendedLiveIds.has(current.id)).map((current) => ({
331
371
  nodeId: current.id, logicalId: current.logicalId, reason: "current_seat_not_in_intended_roster",
332
372
  }))),
333
373
  ];
374
+ const excludedNodes = notIntended.filter((excluded) => !skippedDrained(excluded));
375
+ const planned = this.computeRestorePlan(snapshot.data).filter(entry => !replacements.length || selectedIds.has(entry.node.id));
376
+ const keptDownIds = new Set([
377
+ ...notIntended.filter(skippedDrained).map((excluded) => excluded.nodeId),
378
+ ...planned.flatMap((entry) => drainedByLogicalId.get(entry.node.logicalId) ?? []),
379
+ ]);
380
+ const keptDown = liveNodes.filter((current) => keptDownIds.has(current.id))
381
+ .map((current) => ({ nodeId: current.id, logicalId: current.logicalId, reason: "drained pool agent, not started" }));
382
+ const withKeptDown = keptDown.length > 0 ? { keptDown } : {};
334
383
  const skippedSeats = excludedNodes.filter((excluded) => excluded.reason === "current_seat_not_in_intended_roster");
335
384
  // A required startup file that is missing holds only its own seat. That seat isn't launched, because it would start
336
385
  // without its startup content; it's reported failed with the reason, and the rest of the rig restores. Any other
@@ -345,9 +394,12 @@ export class RestoreOrchestrator {
345
394
  const reason = `${blocker.message} ${blocker.remediation}`;
346
395
  heldForStartup.set(blocker.nodeId, heldForStartup.has(blocker.nodeId) ? `${heldForStartup.get(blocker.nodeId)} ${reason}` : reason);
347
396
  }
348
- const planIds = this.computeRestorePlan(snapshot.data).filter(entry => !replacements.length || selectedIds.has(entry.node.id)).map(entry => entry.node.id);
397
+ const planIds = planned.filter(entry => !drainedByLogicalId.has(entry.node.logicalId)).map(entry => entry.node.id);
349
398
  const rigWide = validation.blockers.some((blocker) => !SEAT_STARTUP_BLOCKERS.has(blocker.code) || !blocker.nodeId);
350
- if (rigWide || planIds.every((id) => heldForStartup.has(id))) {
399
+ // A selection whose every seat is kept down has nothing to launch: not a validation failure, but a restore that
400
+ // keeps them down (below). A rig-wide blocker still fails it first.
401
+ const nothingToLaunch = planIds.length === 0 && keptDown.length > 0;
402
+ if (rigWide || (!nothingToLaunch && planIds.every((id) => heldForStartup.has(id)))) {
351
403
  const result = {
352
404
  snapshotId,
353
405
  preRestoreSnapshotId: null,
@@ -358,6 +410,7 @@ export class RestoreOrchestrator {
358
410
  snapshotSelection,
359
411
  intendedRoster: topology.intendedRoster,
360
412
  excludedNodes,
413
+ ...withKeptDown,
361
414
  };
362
415
  return {
363
416
  ok: false,
@@ -413,6 +466,7 @@ export class RestoreOrchestrator {
413
466
  snapshotSelection,
414
467
  intendedRoster: topology.intendedRoster,
415
468
  excludedNodes,
469
+ ...withKeptDown,
416
470
  },
417
471
  });
418
472
  return { ok: false, code: "service_boot_failed", message: `Service boot failed before agent restore: ${bootResult.error}` };
@@ -426,12 +480,14 @@ export class RestoreOrchestrator {
426
480
  const nodeResults = [];
427
481
  const restoreWarnings = [...validation.warnings];
428
482
  const heldLogicalIds = snapshot.data.nodes.filter((node) => heldForStartup.has(node.id)).map((node) => node.logicalId);
429
- restoreWarnings.push(...this.conversationPartners(rigId, snapshot.data, observed, opts?.freshLogicalIds, currentRuntimes, heldLogicalIds));
483
+ restoreWarnings.push(...this.conversationPartners(rigId, snapshot.data, observed, opts?.freshLogicalIds, currentRuntimes, [...heldLogicalIds, ...drainedLogicalIds]));
430
484
  if (this.rigRepo.getRigNonInterruptive(rigId))
431
485
  restoreWarnings.push(nonInterruptiveSummary(true));
432
486
  else if (opts?.nonInterruptive === false)
433
487
  restoreWarnings.push(nonInterruptiveSummary(false));
434
488
  for (const entry of plan) {
489
+ if (drainedByLogicalId.has(entry.node.logicalId))
490
+ continue;
435
491
  const held = heldForStartup.get(entry.node.id);
436
492
  if (held) {
437
493
  nodeResults.push({ nodeId: entry.node.id, logicalId: entry.node.logicalId, status: "failed", error: `Not launched: ${held}` });
@@ -447,7 +503,14 @@ export class RestoreOrchestrator {
447
503
  for (const skipped of skippedSeats) {
448
504
  restoreWarnings.push(`Restore: ${skipped.logicalId} was skipped: it's a seat of this rig but not in this snapshot's intended roster (it was added or claimed after that roster was recorded), so restore didn't start it.`);
449
505
  }
450
- const rolledUp = rollupRestoreRigResult(nodeResults);
506
+ // Nothing launched because every selected seat is kept down: the rig is as the pool wants it, not a failed restore
507
+ // (the empty rollup is `failed`).
508
+ if (nothingToLaunch) {
509
+ restoreWarnings.push(`Restore: nothing to launch: ${keptDown.map((kept) => kept.logicalId).join(", ")} `
510
+ + `${keptDown.length === 1 ? "is a drained seat pool agent" : "are drained seat pool agents"}, kept down until the pool brings `
511
+ + `${keptDown.length === 1 ? "it" : "them"} back.`);
512
+ }
513
+ const rolledUp = nothingToLaunch ? "fully_restored" : rollupRestoreRigResult(nodeResults);
451
514
  const restoreResult = {
452
515
  snapshotId,
453
516
  preRestoreSnapshotId: preRestoreSnapshot.id,
@@ -457,6 +520,7 @@ export class RestoreOrchestrator {
457
520
  snapshotSelection,
458
521
  intendedRoster: topology.intendedRoster,
459
522
  excludedNodes,
523
+ ...withKeptDown,
460
524
  };
461
525
  const notice = await this.noticeBareShells(rigId, `restore attempt ${attemptId}`, nodeResults, restoreWarnings);
462
526
  if (notice)
@@ -528,12 +592,26 @@ export class RestoreOrchestrator {
528
592
  nonTargetEffects,
529
593
  };
530
594
  }
595
+ /** Whether a whole-rig restore of this rig is running in this daemon (#2940: the keep_alive supervisor waits for it). */
596
+ restoreInProgress(rigId) {
597
+ return this.activeRestores.has(rigId);
598
+ }
531
599
  /** `keepPane`: the seat is running and is relaunched in its own pane (its process ended in place, the pane and scrollback
532
600
  * kept) instead of a new session; nothing checks whether it is live first, since that is the point. `keepEffort`, with
533
601
  * `keepPane`: launch with that effort (the running process's own, kept by a provider switch) in place of the seat's
534
602
  * saved one, unless the seat has an explicit choice when the launch reads it; it isn't saved as the seat's choice.
535
603
  * `keepClaudeLaunch`, for a token-only provider switch, captures current arguments/environment before stopping.
536
- * `onLaunchEffort`, with `keepPane`, hears the effort the launch selected and why, whether or not one was kept. */
604
+ * `onLaunchEffort`, with `keepPane`, hears the effort the launch selected and why, whether or not one was kept.
605
+ * `keepAlive` (#2940): the keep_alive supervisor's relaunch of a fallen seat. Under the seat's lifecycle lease and
606
+ * before any effect, it refuses with `stop_requested` when the seat's latest session carries a stop request or the
607
+ * seat no longer declares keep_alive, so a seat stop or a rig down racing the relaunch wins. With `shouldContinue`,
608
+ * also read there, again just before the launch's first effect and its shell, and again just before the native dispatch
609
+ * into that shell, a false answer (the daemon began shutting down while the launch waited for the lease or prepared)
610
+ * refuses with `shutting_down`, so no recovery starts once shutdown has begun. A refusal after the shell exists rolls
611
+ * that shell back. The refusal carries the seat's own result in `launched`: `notStarted` when it stopped before its
612
+ * first effect, `compensated` when every shell it started was stopped (tmux confirmed it) and the seat's prior state
613
+ * was put back. Without either, its shell may still be running: that result names it, left in place with its session
614
+ * record and binding. It asks for nothing fresh: the seat comes back as any launch would bring it back. */
537
615
  async launchSingleNode(rigId, logicalId, opts) {
538
616
  return this.launchNodeTargets(rigId, [logicalId], { ...opts, namedAgent: true, nonTargetMode: "unchanged" });
539
617
  }
@@ -576,6 +654,24 @@ export class RestoreOrchestrator {
576
654
  if (guard && (targetIds.some(id => !guard.ownsLifecycle(id)) || recordedIds.some(id => !guard.ownsCustody(id)))) {
577
655
  return guard.lifecycle(targetIds, () => this.launchNodeTargets(rigId, logicalIds, opts), recordedIds);
578
656
  }
657
+ const shouldContinue = opts.keepAlive && typeof opts.keepAlive === "object" ? opts.keepAlive.shouldContinue : undefined;
658
+ const shuttingDown = { ok: false, code: "shutting_down", message: "The daemon is shutting down; the seat wasn't relaunched." };
659
+ // Read again just before the launch's first effect and its dispatch: the probes and preparation after this gate wait
660
+ // on tmux and the filesystem, and shutdown can begin meanwhile.
661
+ let refusedForShutdown = false;
662
+ const beforeDispatch = shouldContinue
663
+ ? () => { if (shouldContinue())
664
+ return true; refusedForShutdown = true; return false; }
665
+ : undefined;
666
+ if (opts.keepAlive) {
667
+ if (shouldContinue && !shouldContinue())
668
+ return shuttingDown;
669
+ for (const node of targetNodes) {
670
+ const refusal = this.keepAliveRefusal(node.id, node.logicalId);
671
+ if (refusal)
672
+ return { ok: false, code: "stop_requested", message: refusal };
673
+ }
674
+ }
579
675
  // Per-target tmux-liveness classification (runtime truth, fail-closed)
580
676
  const launched = [];
581
677
  const alreadyRunning = [];
@@ -590,7 +686,11 @@ export class RestoreOrchestrator {
590
686
  }
591
687
  if (opts.keepPane) {
592
688
  launched.push(await this.restoreNodeWithCompensation({ node }, rigId, snapshot.id, snapshot.data, { adapters: opts.adapters, fsOps: opts.fsOps, keepPane: true, keepClaudeLaunch: opts.keepClaudeLaunch, resumePeriodicCarry,
593
- ...(opts.keepEffort ? { keepEffort: opts.keepEffort } : {}), ...(opts.onLaunchEffort ? { onLaunchEffort: opts.onLaunchEffort } : {}) }, subsetWarnings));
689
+ ...(opts.keepEffort ? { keepEffort: opts.keepEffort } : {}), ...(opts.onLaunchEffort ? { onLaunchEffort: opts.onLaunchEffort } : {}),
690
+ ...(beforeDispatch ? { beforeDispatch } : {}) }, subsetWarnings));
691
+ // The seat's own result goes with the refusal: it says whether the relaunch left anything behind.
692
+ if (refusedForShutdown)
693
+ return { ...shuttingDown, launched };
594
694
  continue;
595
695
  }
596
696
  // An external CLI's claim has no tmux session to probe; restoreNodeWithCompensation leaves it attached.
@@ -689,8 +789,12 @@ export class RestoreOrchestrator {
689
789
  const currentEffort = liveChoice ? readSeatEffort(this.db, liveChoice.id) : null;
690
790
  const planEntry = { node: liveChoice ? { ...node, cwd: liveChoice.cwd, model: liveChoice.model,
691
791
  effort: currentEffort?.effective ?? null, effortChoice: currentEffort?.choice ?? null } : node };
692
- const result = await this.restoreNodeWithCompensation(planEntry, rigId, snapshot.id, snapshot.data, { adapters: opts?.adapters, fsOps: opts?.fsOps, selectedHistory: opts.selectedHistory, resumePeriodicCarry }, subsetWarnings);
792
+ const result = await this.restoreNodeWithCompensation(planEntry, rigId, snapshot.id, snapshot.data, { adapters: opts?.adapters, fsOps: opts?.fsOps, selectedHistory: opts.selectedHistory, resumePeriodicCarry, requireCurrentOccupant: opts.requireCurrentOccupant,
793
+ ...(beforeDispatch ? { beforeDispatch } : {}) }, subsetWarnings);
693
794
  launched.push(result);
795
+ // The seat's own result goes with the refusal: it says whether the relaunch left anything behind.
796
+ if (refusedForShutdown)
797
+ return { ...shuttingDown, launched };
694
798
  }
695
799
  // Emit restore.subset_completed for launched targets only
696
800
  let harnessNotStarted;
@@ -762,6 +866,19 @@ export class RestoreOrchestrator {
762
866
  },
763
867
  };
764
868
  }
869
+ /** Why a keep_alive relaunch of this seat must not happen now (#2940), read under its lifecycle lease: the latest session
870
+ * records a stop request (a seat stop or a rig down, pending or confirmed), or the seat no longer declares keep_alive.
871
+ * Null when the relaunch may go on. */
872
+ keepAliveRefusal(nodeId, logicalId) {
873
+ const declared = this.db.prepare("SELECT keep_alive FROM nodes WHERE id = ?").get(nodeId)
874
+ ?.keep_alive === 1;
875
+ if (!declared)
876
+ return `'${logicalId}' no longer declares keep_alive; it wasn't relaunched.`;
877
+ const latest = this.db.prepare("SELECT intentionally_stopped AS flag FROM sessions WHERE node_id = ? ORDER BY created_at DESC, id DESC LIMIT 1").get(nodeId);
878
+ if (latest?.flag === 1)
879
+ return `'${logicalId}' was asked to stop; it wasn't relaunched.`;
880
+ return null;
881
+ }
765
882
  captureNodeState(nodeId, rigId) {
766
883
  const binding = this.sessionRegistry.getBindingForNode(nodeId);
767
884
  const sessions = this.sessionRegistry.getSessionsForRig(rigId)
@@ -1042,7 +1159,24 @@ export class RestoreOrchestrator {
1042
1159
  * Restore one planned seat, checking continuity before launching its occupant.
1043
1160
  * Preserve prior state so a failed launch or resume can be compensated.
1044
1161
  */
1045
- async restoreNodeWithCompensation(entry, rigId, snapshotId, data, opts, warnings, preserveStoppedCurrent = false) {
1162
+ /** Restore one seat, then arm its continuity notice when a session is running again. Every restore path (the whole rig, a
1163
+ * subset, a kept pane, a selected history) goes through here, so the notice is armed the same way for all of them. */
1164
+ async restoreNodeWithCompensation(...args) {
1165
+ const result = await this.restoreNodeCore(...args);
1166
+ if (this.armContinuity && CONTINUITY_ARMED_STATUSES.has(result.status)) {
1167
+ try {
1168
+ const problem = await this.armContinuity(args[1], result.nodeId);
1169
+ if (problem)
1170
+ args[5]?.push(problem);
1171
+ }
1172
+ catch (error) {
1173
+ args[5]?.push(`continuity policy was not armed for ${result.logicalId}: ${error.message}`);
1174
+ }
1175
+ }
1176
+ return result;
1177
+ }
1178
+ /** @internal The restore of one seat; call `restoreNodeWithCompensation`, which also arms its continuity notice. */
1179
+ async restoreNodeCore(entry, rigId, snapshotId, data, opts, warnings, preserveStoppedCurrent = false) {
1046
1180
  // `--cwd`: the seat launches, resumes and gets its guidance and checkpoint in the given directory, for this run only.
1047
1181
  if (opts?.cwdOverride)
1048
1182
  entry = { ...entry, node: { ...entry.node, cwd: opts.cwdOverride } };
@@ -1054,6 +1188,9 @@ export class RestoreOrchestrator {
1054
1188
  const liveNode = this.rigRepo.getRig(rigId)?.nodes.find(current => current.logicalId === node.logicalId
1055
1189
  && (!opts?.selectedHistory || current.id === node.id));
1056
1190
  const nodeId = node.id;
1191
+ // The seat's live state (its binding and sessions) is on the node the launcher uses, found by logical id: a seat
1192
+ // recreated after the snapshot runs under a new id. The snapshot's id stays the key for the snapshot's own data.
1193
+ const seatNodeId = liveNode?.id ?? nodeId;
1057
1194
  const selectedHistory = opts?.selectedHistory;
1058
1195
  if (selectedHistory && (!liveNode || selectedHistory.nodeId !== nodeId || !selectedHistory.beforeEffect())) {
1059
1196
  return { nodeId, logicalId: node.logicalId, status: "failed", error: "The selected seat or history changed before launch.", notStarted: true };
@@ -1061,7 +1198,7 @@ export class RestoreOrchestrator {
1061
1198
  // A selected restore that returns before its launch says so, as a known fact for the startup that selected it.
1062
1199
  const notStarted = selectedHistory ? { notStarted: true } : {};
1063
1200
  // A seat joined with `rig attach` as an external CLI keeps its attachment: launching here would replace it.
1064
- const external = this.sessionRegistry.getBindingForNode(nodeId);
1201
+ const external = this.sessionRegistry.getBindingForNode(seatNodeId);
1065
1202
  if (external && seatProcessOwner(resolveSeatKind(external.attachmentType)) === "external") {
1066
1203
  return { nodeId, logicalId: node.logicalId, status: "left_attached", error: leftAttachedReason(external.externalSessionName ?? node.logicalId), ...notStarted };
1067
1204
  }
@@ -1097,6 +1234,19 @@ export class RestoreOrchestrator {
1097
1234
  };
1098
1235
  }
1099
1236
  const freshRequested = opts?.freshLogicalIds?.includes(node.logicalId) ?? false;
1237
+ // R2 (#2829 review): a stale snapshot must never silently replace the seat's current
1238
+ // conversation. If the snapshot's occupant is not the agent's latest session, park for a
1239
+ // decision (an explicit history selection or --fresh deliberately overrides this).
1240
+ if (opts?.requireCurrentOccupant && occupantResolution.kind === "resolved" && !selectedHistory && !freshRequested) {
1241
+ const latestLive = this.sessionRegistry.getSessionsForRig(rigId)
1242
+ .filter(row => row.nodeId === nodeId)
1243
+ .reduce((latest, row) => !latest || row.id > latest.id ? row : latest, null);
1244
+ if (latestLive && latestLive.id !== occupantResolution.session.id) {
1245
+ return { nodeId, logicalId: node.logicalId, status: "awaiting-decision",
1246
+ error: `The snapshot's occupant is no longer ${node.logicalId}'s current session. No session was started. Restore the original session manually, or deliberately start only this seat fresh: ${this.freshSeatCommand(rigId, data, node.logicalId)}.`,
1247
+ ...notStarted };
1248
+ }
1249
+ }
1100
1250
  const carried = opts?.resumePeriodicCarry && !selectedHistory && !freshRequested
1101
1251
  && occupantResolution.kind === "none" && liveNode?.id === nodeId
1102
1252
  ? data.periodicResumeSourcesByNode?.[nodeId] : undefined;
@@ -1112,6 +1262,35 @@ export class RestoreOrchestrator {
1112
1262
  error: "The periodic resume source is no longer this seat's current resumable session. No session was started. Review its history or deliberately start this seat fresh." };
1113
1263
  }
1114
1264
  }
1265
+ // R2b/C (#2829 review): the same protection for a snapshot that has no occupant for
1266
+ // the seat. Two ways a cold start would silently replace a conversation the seat had:
1267
+ // R2b — the seat started after the snapshot was taken, so a live session is newer
1268
+ // than everything the snapshot records; and
1269
+ // C — the snapshot explicitly recorded the occupant absent but retained the seat's
1270
+ // conversation history under resume_if_possible with no token, which the
1271
+ // resume-history guard skips. Both park for a decision instead of fresh-launching;
1272
+ // explicit history selection and --fresh deliberately override. An eligible selected
1273
+ // carry is validated above and resumes below, so both parks give way to it
1274
+ // (round 4: C must not park a valid periodic carry).
1275
+ if (opts?.requireCurrentOccupant && occupantResolution.kind === "none" && !selectedHistory
1276
+ && !freshRequested && !carried) {
1277
+ const seatSessions = data.sessions.filter(row => row.nodeId === nodeId);
1278
+ const latestLive = this.sessionRegistry.getSessionsForRig(rigId)
1279
+ .filter(row => row.nodeId === nodeId)
1280
+ .reduce((latest, row) => !latest || row.id > latest.id ? row : latest, null);
1281
+ const newestSnapshotId = seatSessions.reduce((newest, row) => !newest || row.id > newest ? row.id : newest, null);
1282
+ const ranAfterSnapshot = latestLive !== null && (newestSnapshotId === null || latestLive.id > newestSnapshotId);
1283
+ const newestSnapshotRow = seatSessions.reduce((newest, row) => !newest || row.id > newest.id ? row : newest, null);
1284
+ const retainedResumeHistory = newestSnapshotRow?.restorePolicy === "resume_if_possible";
1285
+ if (ranAfterSnapshot || retainedResumeHistory) {
1286
+ const why = ranAfterSnapshot
1287
+ ? `The seat has a session newer than the snapshot's, and the snapshot records no occupant for it.`
1288
+ : `The snapshot records no active occupant for the seat but retains its conversation history under resume_if_possible.`;
1289
+ return { nodeId, logicalId: node.logicalId, status: "awaiting-decision",
1290
+ error: `${why} No session was started. Restore the original session manually, or deliberately start only this seat fresh: ${this.freshSeatCommand(rigId, data, node.logicalId)}.`,
1291
+ ...notStarted };
1292
+ }
1293
+ }
1115
1294
  const resumeSession = occupantResolution.kind === "resolved" ? occupantResolution.session : carried ?? null;
1116
1295
  if (occupantResolution.kind === "none" && preserveStoppedCurrent && !freshRequested && !carried) {
1117
1296
  return { nodeId, logicalId: node.logicalId, status: "awaiting-decision", error: stoppedSnapshotReason(node.logicalId, data.rig.name) };
@@ -1128,9 +1307,11 @@ export class RestoreOrchestrator {
1128
1307
  if (priorWithToken) {
1129
1308
  return { nodeId, logicalId: node.logicalId, status: "awaiting-decision", error: absentSeatResumeHistoryError(node.logicalId, priorWithToken.resumeType, this.rigRepo.getRig(rigId)?.rig.name ?? data.rig.name) };
1130
1309
  }
1131
- // Consult live continuity state BEFORE clearing stale state
1132
- if (node.podId) {
1133
- const continuityRow = this.db.prepare("SELECT status FROM continuity_state WHERE pod_id = ? AND node_id = ?").get(node.podId, nodeId);
1310
+ // Consult live continuity state BEFORE clearing stale state, keyed on the live seat and its pod: a pod recreated
1311
+ // after the snapshot runs under a new id too.
1312
+ const seatPodId = liveNode?.podId ?? node.podId;
1313
+ if (seatPodId) {
1314
+ const continuityRow = this.db.prepare("SELECT status FROM continuity_state WHERE pod_id = ? AND node_id = ?").get(seatPodId, seatNodeId);
1134
1315
  if (continuityRow) {
1135
1316
  if (continuityRow.status === "restoring") {
1136
1317
  if (selectedHistory)
@@ -1196,13 +1377,13 @@ export class RestoreOrchestrator {
1196
1377
  return { nodeId, logicalId: node.logicalId, status: "failed", error };
1197
1378
  }
1198
1379
  // Capture prior state for compensation, including an exited replacement predecessor.
1199
- const priorState = this.captureNodeState(nodeId, rigId);
1380
+ const priorState = this.captureNodeState(seatNodeId, rigId);
1200
1381
  const keptPane = opts?.keepPane ? priorState.binding?.tmuxPane ?? null : null;
1201
1382
  if (opts?.keepPane && (!keptPane || !priorState.binding?.tmuxSession)) {
1202
1383
  return { nodeId, logicalId: node.logicalId, status: "failed", error: `${node.logicalId} has no bound tmux pane to keep, so nothing was stopped.` };
1203
1384
  }
1204
1385
  // Read before takeover ends the process. An unavailable witness keeps normal launch resolution unchanged.
1205
- const continuation = keptPane && node.runtime === "claude-code" ? await this.claudeContinuationExecutable(keptPane, opts?.keepClaudeLaunch, this.sessionRegistry.getBindingForNode(node.id)?.tmuxSession ?? undefined) : undefined;
1386
+ const continuation = keptPane && node.runtime === "claude-code" ? await this.claudeContinuationExecutable(keptPane, opts?.keepClaudeLaunch, this.sessionRegistry.getBindingForNode(seatNodeId)?.tmuxSession ?? undefined) : undefined;
1206
1387
  const claudeExecutable = continuation?.executable, claudeLaunch = continuation?.launch;
1207
1388
  if (opts?.keepClaudeLaunch && keptPane && node.runtime === "claude-code")
1208
1389
  warnings?.push(...(claudeLaunch?.warnings ?? ["Running Claude launch capture unavailable; using ordinary launch settings."]));
@@ -1211,8 +1392,12 @@ export class RestoreOrchestrator {
1211
1392
  if (selectedHistory && !selectedHistory.beforeEffect()) {
1212
1393
  return { nodeId, logicalId: node.logicalId, status: "failed", error: "The selected seat or history changed before launch.", notStarted: true };
1213
1394
  }
1214
- this.clearStaleState(nodeId, rigId, { keepBinding: keptPane !== null });
1215
- this.tmuxAdapter.deliveryGuard?.rebindLifecycle(nodeId);
1395
+ // `beforeDispatch` (a keep_alive relaunch, #2940): a false answer here, before the first effect, starts nothing.
1396
+ if (opts?.beforeDispatch && !opts.beforeDispatch()) {
1397
+ return { nodeId, logicalId: node.logicalId, status: "failed", error: "The daemon is shutting down; the seat wasn't relaunched.", notStarted: true };
1398
+ }
1399
+ this.clearStaleState(seatNodeId, rigId, { keepBinding: keptPane !== null });
1400
+ this.tmuxAdapter.deliveryGuard?.rebindLifecycle(seatNodeId);
1216
1401
  // Derive canonical session name for pod-aware nodes
1217
1402
  const rig = this.rigRepo.getRig(rigId);
1218
1403
  let launchOpts = node.cwd
@@ -1362,6 +1547,17 @@ export class RestoreOrchestrator {
1362
1547
  // Preserve the snapshot's selected plugins and record the committed session before launch continues.
1363
1548
  const savedStartup = data.nodeStartupContext?.[nodeId];
1364
1549
  const onSessionLaunched = opts?.onSessionLaunched;
1550
+ // Asked again after the skills' preparation, just before dispatch; the stale state cleared above is put back.
1551
+ if (opts?.beforeDispatch && !opts.beforeDispatch()) {
1552
+ this.restoreNodeState(seatNodeId, priorState);
1553
+ return { nodeId, logicalId: node.logicalId, status: "failed", error: "The daemon is shutting down; the seat wasn't relaunched.", notStarted: true };
1554
+ }
1555
+ // And again just before the native dispatch, after the shell exists: a false answer there dispatches nothing.
1556
+ let refusedBeforeNative = false;
1557
+ const beforeNativeDispatch = opts?.beforeDispatch
1558
+ ? () => { if (opts.beforeDispatch())
1559
+ return true; refusedBeforeNative = true; return false; }
1560
+ : undefined;
1365
1561
  // #3395: a launch from stored state reports the seat's stored pool block that can't be used, once for every restore
1366
1562
  // path (resume, fresh, subset and single), read from the live node: a seat recreated after the snapshot launches there.
1367
1563
  warnings?.push(...storedPoolAdvisories(node.logicalId, this.rigRepo.getNodePool(liveNode?.id ?? nodeId)));
@@ -1373,13 +1569,14 @@ export class RestoreOrchestrator {
1373
1569
  ...(selectedHistory ? { expectedNodeId: nodeId, beforeEffect: selectedHistory.beforeNative,
1374
1570
  beforeRegistration: selectedHistory.beforeRegistration } : {}),
1375
1571
  ...(savedStartup ? { pluginPaths: pluginPathsOf(savedStartup.projectionEntries) } : {}),
1376
- ...(onSessionLaunched ? { onSessionRegistered: (sessionId) => onSessionLaunched(nodeId, sessionId) } : {}),
1572
+ // Reported on the node the session registers on: a recreated seat's keep_alive budget is its live node's.
1573
+ ...(onSessionLaunched ? { onSessionRegistered: (sessionId) => onSessionLaunched(seatNodeId, sessionId) } : {}),
1377
1574
  });
1378
1575
  if (!launchResult.ok) {
1379
1576
  // Launch failed — restore prior state (compensating action)
1380
1577
  const compensate = !selectedHistory || (launchResult.code !== "selection_changed_after_creation" && selectedHistory.beforeRegistration());
1381
1578
  if (compensate)
1382
- this.restoreNodeState(nodeId, priorState);
1579
+ this.restoreNodeState(seatNodeId, priorState);
1383
1580
  // Known compensation needs a failure that left no terminal: one before its creation, or tmux reporting none was
1384
1581
  // created. An unconfirmed creation, a failed write or a later failure isn't known to have left nothing.
1385
1582
  const compensated = compensate && NO_TERMINAL_LAUNCH_CODES.has(launchResult.code);
@@ -1413,7 +1610,20 @@ export class RestoreOrchestrator {
1413
1610
  const givenStartedIn = givenMissing ? await this.boundPaneFolder(launchResult.sessionName, launchResult.binding.tmuxPane) : null;
1414
1611
  // A selected launch's own blank rolled back after the shell started (postLaunchRestore has many return points).
1415
1612
  const compensation = { ran: false };
1416
- const restored = await this.postLaunchRestore(entry, rigId, data, launchResult.sessionName, launchResult, { ...opts, ...(claudeExecutable ? { claudeExecutable } : {}), ...(claudeLaunch ? { claudeLaunch } : {}), compensation }, warnings, priorState, seatRehydration, resumeSession, activityHookGaps, restoredSkillCatalog);
1613
+ // A fresh replacement refused for a shutdown undoes its own shells, and says how here.
1614
+ const shutdownRollback = {};
1615
+ const restored = await this.postLaunchRestore(entry, rigId, data, launchResult.sessionName, launchResult, { ...opts, ...(claudeExecutable ? { claudeExecutable } : {}), ...(claudeLaunch ? { claudeLaunch } : {}), compensation,
1616
+ ...(beforeNativeDispatch ? { beforeNativeDispatch, shutdownRollback } : {}) }, warnings, priorState, seatRehydration, resumeSession, activityHookGaps, restoredSkillCatalog);
1617
+ if (refusedBeforeNative) {
1618
+ // Shutdown began after the shell was created: nothing was dispatched into it, so it is rolled back as a blank one
1619
+ // is, and the seat is left as it was. A fresh replacement that retired this shell has already done that.
1620
+ let outcome = shutdownRollback.outcome;
1621
+ if (!outcome) {
1622
+ const { rolledBack, terminalStopped, stopUnconfirmed } = await this.rollbackToZeroSession(launchResult.session.nodeId, launchResult.sessionName, launchResult.session.id, priorState, undefined, keptPane !== null);
1623
+ outcome = { compensated: rolledBack && terminalStopped, ...(stopUnconfirmed ? { unconfirmed: launchResult.sessionName } : {}) };
1624
+ }
1625
+ return this.shutdownRefusal(rigId, data, nodeId, node.logicalId, outcome);
1626
+ }
1417
1627
  // Whether it's still missing is decided once the launch has run: a fresh launch creates it, and a restore doesn't, so the
1418
1628
  // seat's terminal started in tmux's fallback folder.
1419
1629
  if (givenMissing && warnings && !folderPresent(givenMissing)) {
@@ -1682,26 +1892,39 @@ export class RestoreOrchestrator {
1682
1892
  }
1683
1893
  return { rolledBack: true, terminalStopped };
1684
1894
  }
1685
- /** The notice for the seats an attempt positively left as bare shells, each with its own cause. Its warnings join the
1686
- * attempt's, and a failure to send it is a warning too: it never changes or blocks the attempt's own result. Seats not
1687
- * positively left as shells stay in the roll call. */
1895
+ /** #2940: the result of a keep_alive relaunch refused because the daemon began shutting down after its shell existed.
1896
+ * `compensated` only when every shell it started was stopped (tmux confirmed it) and the seat's prior state was put
1897
+ * back. A shell whose stop wasn't confirmed may still be running: the result names it, left in place with its session
1898
+ * record and binding, and says how to check and stop it. */
1899
+ shutdownRefusal(rigId, data, nodeId, logicalId, outcome) {
1900
+ if (outcome.unconfirmed) {
1901
+ const name = outcome.unconfirmed;
1902
+ return { nodeId, logicalId, status: "attention_required",
1903
+ error: `The daemon is shutting down, so the seat wasn't relaunched, but the session '${name}' this launch started couldn't be confirmed stopped: it may still be running, so its session record and binding were left in place. Check it with rig capture ${name}, and stop it with ${this.stopSeatCommand(rigId, data, logicalId)}.` };
1904
+ }
1905
+ return { nodeId, logicalId, status: "failed", error: "The daemon is shutting down; the seat wasn't relaunched.",
1906
+ ...(outcome.compensated ? { compensated: true } : {}) };
1907
+ }
1908
+ /** The notice for the seats an attempt positively left with no agent running, each with its own cause: a bare shell, or
1909
+ * a failed resume whose blank session was rolled back. Its warnings join the attempt's, and a failure to send it is a
1910
+ * warning too: it never changes or blocks the attempt's own result. Other seats stay in the roll call. */
1688
1911
  async noticeBareShells(rigId, attempt, results, warnings) {
1689
- const shells = results.filter((n) => n.stage === "harness_not_started");
1912
+ const shells = results.filter((n) => n.stage === "harness_not_started" || n.stage === "resume_rolled_back");
1690
1913
  if (shells.length === 0 || !this.harnessNotStartedNotice)
1691
1914
  return undefined;
1692
1915
  try {
1693
1916
  // The launcher finds a seat by its logical id in the live rig, so a seat recreated since the snapshot was launched
1694
1917
  // under its live node, while its result keeps the snapshot's node id: the notice reads the node the shell is on.
1695
1918
  const liveNodes = this.rigRepo.getRig(rigId)?.nodes ?? [];
1696
- const seats = shells.map(({ nodeId, logicalId, error }) => ({ nodeId: liveNodes.find((node) => node.logicalId === logicalId)?.id ?? nodeId,
1697
- logicalId, ...(error ? { cause: error } : {}) }));
1919
+ const seats = shells.map(({ nodeId, logicalId, error, stage }) => ({ nodeId: liveNodes.find((node) => node.logicalId === logicalId)?.id ?? nodeId,
1920
+ logicalId, ...(error ? { cause: error } : {}), ...(stage === "resume_rolled_back" ? { rolledBack: true } : {}) }));
1698
1921
  const report = await this.harnessNotStartedNotice({ rigId, attempt, seats });
1699
1922
  for (const warning of report.warnings ?? [])
1700
1923
  warnings.push(`Restore: ${warning}`);
1701
1924
  return report;
1702
1925
  }
1703
1926
  catch (err) {
1704
- warnings.push(`Restore: the notice for the seats left as a bare shell wasn't recorded (${err instanceof Error ? err.message : String(err)}).`);
1927
+ warnings.push(`Restore: the notice for the seats left with no agent running wasn't recorded (${err instanceof Error ? err.message : String(err)}).`);
1705
1928
  return undefined;
1706
1929
  }
1707
1930
  }
@@ -1810,9 +2033,15 @@ export class RestoreOrchestrator {
1810
2033
  // row ordering (cite site 2 of 2; "latest = max id" was the incident's
1811
2034
  // defect: a superseded row with a newer ULID defeated the real occupant).
1812
2035
  const selected = opts?.selectedHistory;
2036
+ // #2940: a keep_alive relaunch asks too, just before each native dispatch, whether the daemon is still running.
2037
+ const nativeAllowed = opts?.beforeNativeDispatch;
2038
+ const beforeNative = selected || nativeAllowed
2039
+ ? (sessionId, bindingId) => (!selected || selected.beforeNative(sessionId, bindingId)) && (!nativeAllowed || nativeAllowed())
2040
+ : undefined;
1813
2041
  /** Rolls this restore's blank session back; null when it did, else the result the restore reports instead. */
1814
2042
  const rollbackOwnBlank = async () => {
1815
- const { rolledBack, terminalStopped, stopUnconfirmed } = await this.rollbackToZeroSession(node.id, sessionName, launchResult?.session.id, priorState, selected ? () => selected.beforeNative(launchResult?.session.id, launchResult?.binding.id) : undefined, opts?.keepPane);
2043
+ // The launched session's node: a seat recreated after the snapshot holds its new binding there.
2044
+ const { rolledBack, terminalStopped, stopUnconfirmed } = await this.rollbackToZeroSession(launchResult?.session.nodeId ?? node.id, sessionName, launchResult?.session.id, priorState, selected ? () => selected.beforeNative(launchResult?.session.id, launchResult?.binding.id) : undefined, opts?.keepPane);
1816
2045
  // Known compensation: tmux confirmed the terminal stopped, and the earlier state was put back.
1817
2046
  if (rolledBack && terminalStopped && priorState && !opts?.keepPane && opts?.compensation)
1818
2047
  opts.compensation.ran = true;
@@ -2047,9 +2276,12 @@ export class RestoreOrchestrator {
2047
2276
  }
2048
2277
  catch { /* best-effort: without it a rotation stays unproved, as before */ }
2049
2278
  }
2050
- if (selected && !selected.beforeNative(launchedSessionId, launchResult?.binding.id))
2279
+ if (beforeNative && !beforeNative(launchedSessionId, launchResult?.binding.id))
2051
2280
  return { nodeId: node.id, logicalId: node.logicalId, status: "attention_required", error: "The selected seat, settings or history changed after shell creation; native resume was not dispatched." };
2052
- const resumeOutcome = await this.attemptResume(node.id, sessionName, resumeType, resumeToken, launchCwd, this.liveCodexProfile(rigId, node, selected?.nodeId), modelForRestore(), this.resolveRestorePosture(node.id, rigId), effortForRestore(), warnings, node.advisor, selected ? () => selected.beforeNative(launchedSessionId, launchResult?.binding.id) : undefined, opts?.claudeExecutable, opts?.claudeLaunch);
2281
+ // The seat's own settings (permissions, envelope, wrapper, homes, tenure) are read from the node the launcher
2282
+ // registered: a seat recreated after the snapshot runs under a new id, which its launch stamps as OPENRIG_NODE_ID.
2283
+ const seatNodeId = launchResult?.session.nodeId ?? node.id;
2284
+ const resumeOutcome = await this.attemptResume(seatNodeId, sessionName, resumeType, resumeToken, launchCwd, this.liveCodexProfile(rigId, node, selected?.nodeId), modelForRestore(), this.resolveRestorePosture(seatNodeId, rigId), effortForRestore(), warnings, node.advisor, beforeNative ? () => beforeNative(launchedSessionId, launchResult?.binding.id) : undefined, opts?.claudeExecutable, opts?.claudeLaunch);
2053
2285
  if (resumeOutcome.kind === "resumed") {
2054
2286
  baseStatus = "resumed";
2055
2287
  if (launchedSessionId && this.claudeResume.canResume(resumeType, resumeToken)) {
@@ -2086,7 +2318,7 @@ export class RestoreOrchestrator {
2086
2318
  if (kept)
2087
2319
  return kept;
2088
2320
  }
2089
- return { nodeId: node.id, logicalId: node.logicalId, status: "awaiting-decision", error: `Original session unresumable: resume attempted but failed. The blank session was rolled back; no session is running. Check the harness state manually, or deliberately start only this seat fresh: ${this.freshSeatCommand(rigId, data, node.logicalId)}.` };
2321
+ return { nodeId: node.id, logicalId: node.logicalId, status: "awaiting-decision", stage: "resume_rolled_back", error: `Original session unresumable: resume attempted but failed. The blank session was rolled back; no session is running. Check the harness state manually, or deliberately start only this seat fresh: ${this.freshSeatCommand(rigId, data, node.logicalId)}.` };
2090
2322
  }
2091
2323
  }
2092
2324
  }
@@ -2195,13 +2427,16 @@ export class RestoreOrchestrator {
2195
2427
  // Keep the usable provisional shell when the callback exists but its
2196
2428
  // recipe/member inputs are unavailable. A callback being present alone
2197
2429
  // is not proof that a fresh launch can actually be attempted.
2198
- if (this.freshLaunchAvailable && !this.freshLaunchAvailable(rigId, node.id)) {
2430
+ if (this.freshLaunchAvailable && !this.freshLaunchAvailable(rigId, launchResult.session.nodeId)) {
2199
2431
  const error = `Harness not started: no usable persisted launch recipe for ${node.logicalId}.`;
2200
2432
  warnings?.push(`Restore: ${error}`);
2201
2433
  this.markHarnessNotStarted(rigId, launchResult.session.nodeId, launchResult.session.id, error);
2202
2434
  return { nodeId: node.id, logicalId: node.logicalId, status: "attention_required", error, stage: "harness_not_started" };
2203
2435
  }
2204
- const retired = await this.retireProvisionalSession(node.id, sessionName, launchResult.session.id);
2436
+ if (nativeAllowed && !nativeAllowed()) {
2437
+ return { nodeId: node.id, logicalId: node.logicalId, status: "failed", error: "The daemon is shutting down; the seat wasn't relaunched." };
2438
+ }
2439
+ const retired = await this.retireProvisionalSession(launchResult.session.nodeId, sessionName, launchResult.session.id);
2205
2440
  if (!retired.ok) {
2206
2441
  warnings?.push(`Restore: ${retired.error}`);
2207
2442
  return { nodeId: node.id, logicalId: node.logicalId, status: "attention_required", error: retired.error };
@@ -2214,14 +2449,57 @@ export class RestoreOrchestrator {
2214
2449
  if (stale >= 0)
2215
2450
  warnings.splice(stale, 1);
2216
2451
  const replacementExists = () => this.sessionRegistry.getSessionsForRig(rigId)
2217
- .some((candidate) => candidate.nodeId === node.id
2452
+ .some((candidate) => candidate.nodeId === launchResult.session.nodeId
2218
2453
  && candidate.status === "running"
2219
2454
  && candidate.id !== launchResult.session.id);
2455
+ // Asked again after the retire's await, right before the replacement's native start: a shutdown that began
2456
+ // meanwhile wins, and the seat goes back to where it was (the retired shell can't be rolled back any more).
2457
+ if (nativeAllowed && !nativeAllowed()) {
2458
+ const putBack = !!priorState && !replacementExists();
2459
+ if (putBack)
2460
+ this.restoreNodeState(launchResult.session.nodeId, priorState);
2461
+ // The retire's stop was confirmed: with the prior state put back, nothing this launch started is left.
2462
+ if (opts?.shutdownRollback)
2463
+ opts.shutdownRollback.outcome = { compensated: putBack };
2464
+ return { nodeId: node.id, logicalId: node.logicalId, status: "failed", error: "The daemon is shutting down; the seat wasn't relaunched." };
2465
+ }
2466
+ // The same read once more inside the replacement launch, just before its native dispatch: configuration, its
2467
+ // shell and its startup preparation are awaited after the read above, and a shutdown that begins meanwhile wins.
2468
+ let refusedInLaunch = false;
2469
+ const replacementNativeAllowed = nativeAllowed
2470
+ ? () => { if (nativeAllowed())
2471
+ return true; refusedInLaunch = true; return false; }
2472
+ : undefined;
2473
+ // Nothing was dispatched into the replacement's shell: it is rolled back as any shell refused before its native
2474
+ // dispatch is, and the seat goes back to where it was. Its stop counts only when tmux confirms it.
2475
+ const rollBackRefusedReplacement = async () => {
2476
+ const replacement = this.sessionRegistry.getSessionsForRig(rigId)
2477
+ .filter((candidate) => candidate.nodeId === launchResult.session.nodeId && candidate.status === "running" && candidate.id !== launchResult.session.id)
2478
+ .at(-1);
2479
+ let outcome;
2480
+ if (replacement) {
2481
+ const { rolledBack, terminalStopped, stopUnconfirmed } = await this.rollbackToZeroSession(launchResult.session.nodeId, replacement.sessionName, replacement.id, priorState);
2482
+ outcome = { compensated: rolledBack && terminalStopped && !!priorState,
2483
+ ...(stopUnconfirmed ? { unconfirmed: replacement.sessionName } : {}) };
2484
+ }
2485
+ else {
2486
+ if (priorState)
2487
+ this.restoreNodeState(launchResult.session.nodeId, priorState);
2488
+ outcome = { compensated: !!priorState };
2489
+ }
2490
+ if (opts?.shutdownRollback)
2491
+ opts.shutdownRollback.outcome = outcome;
2492
+ };
2493
+ // The replacement's own session, when this restore follows the sessions it launches (daemon start's automatic
2494
+ // restore adopts it into a keep_alive incident).
2495
+ const onSessionLaunched = opts?.onSessionLaunched;
2220
2496
  try {
2221
2497
  // #3253: this replaces the provisional shell of a restore, so it is a recovery too: a limit that can't be
2222
2498
  // applied doesn't stop the seat, and its notice is the node's. The replacement launches where the provisional
2223
2499
  // shell did: this run's `--cwd`, else the saved folder.
2224
- const fresh = await this.freshLaunch(rigId, node.id, { processLimitsMode: "recovery", ...(opts?.cwdOverride ? { cwdOverride: opts.cwdOverride } : {}) });
2500
+ const fresh = await this.freshLaunch(rigId, launchResult.session.nodeId, { processLimitsMode: "recovery", ...(opts?.cwdOverride ? { cwdOverride: opts.cwdOverride } : {}),
2501
+ ...(replacementNativeAllowed ? { beforeNativeDispatch: replacementNativeAllowed } : {}),
2502
+ ...(onSessionLaunched ? { onSessionRegistered: (sessionId) => onSessionLaunched(launchResult.session.nodeId, sessionId) } : {}) });
2225
2503
  if (fresh.warnings?.length)
2226
2504
  warnings?.push(...fresh.warnings);
2227
2505
  // The replacement's own outcome, also when it applied the limit (no notice): the retired provisional shell's
@@ -2230,13 +2508,22 @@ export class RestoreOrchestrator {
2230
2508
  if (fresh.status === "launched") {
2231
2509
  return { nodeId: node.id, logicalId: node.logicalId, status: "fresh-primed", ...limits };
2232
2510
  }
2511
+ if (refusedInLaunch) {
2512
+ await rollBackRefusedReplacement();
2513
+ return { nodeId: node.id, logicalId: node.logicalId, status: "failed", error: "The daemon is shutting down; the seat wasn't relaunched.", ...limits };
2514
+ }
2233
2515
  if (priorState && !replacementExists())
2234
- this.restoreNodeState(node.id, priorState);
2516
+ this.restoreNodeState(launchResult.session.nodeId, priorState);
2235
2517
  return { nodeId: node.id, logicalId: node.logicalId, status: fresh.status, error: fresh.error, ...limits };
2236
2518
  }
2237
2519
  catch (err) {
2520
+ if (refusedInLaunch) {
2521
+ await rollBackRefusedReplacement();
2522
+ return { nodeId: node.id, logicalId: node.logicalId, status: "failed", error: "The daemon is shutting down; the seat wasn't relaunched.",
2523
+ processLimits: undefined };
2524
+ }
2238
2525
  if (priorState && !replacementExists())
2239
- this.restoreNodeState(node.id, priorState);
2526
+ this.restoreNodeState(launchResult.session.nodeId, priorState);
2240
2527
  return {
2241
2528
  nodeId: node.id,
2242
2529
  logicalId: node.logicalId,
@@ -2298,7 +2585,7 @@ export class RestoreOrchestrator {
2298
2585
  // it is, an edited one is named, and a missing one whose recorded source is gone or has changed is not put back
2299
2586
  // with today's bytes. Only the rest is projected or installed. Nothing is re-resolved from today's spec. Native
2300
2587
  // resume replays nothing (sourceEntries is empty). The whole selection stays in the saved startup context.
2301
- const seatSkills = (replayCtx.runtime === "claude-code" || replayCtx.runtime === "codex") && !replayContained ? seatSkillPathsForNode(this.db, node.id) : undefined;
2588
+ const seatSkills = (replayCtx.runtime === "claude-code" || replayCtx.runtime === "codex") && !replayContained ? seatSkillPathsForNode(this.db, launchResult.session.nodeId) : undefined;
2302
2589
  let replaySkip;
2303
2590
  if (seatSkills) {
2304
2591
  const replay = seatSkillReplay({ entries: filteredEntries, files: filteredFiles, paths: seatSkills,
@@ -2334,7 +2621,7 @@ export class RestoreOrchestrator {
2334
2621
  codexConfigProfile: this.liveCodexProfile(rigId, node, selected?.nodeId) ?? undefined,
2335
2622
  // OPR.0.4.8.3 Seam B: the pod-aware restore path binds the restored posture too
2336
2623
  // (both restore paths consume persisted provenance — preflight surface 3).
2337
- launchPosture: this.resolveRestorePosture(node.id, rigId),
2624
+ launchPosture: this.resolveRestorePosture(launchResult.session.nodeId, rigId),
2338
2625
  // OPR.0.4.6.PI1 VM leg finding: the restore binding dropped the
2339
2626
  // node's model declaration, so a resumed Pi seat relaunched with
2340
2627
  // no --model — and the runner's provider-key allowlist (keyed off
@@ -2353,7 +2640,8 @@ export class RestoreOrchestrator {
2353
2640
  const shouldLaunchHarness = isPodAware;
2354
2641
  const startupResult = await startupOrch.startNode({
2355
2642
  rigId,
2356
- nodeId: node.id,
2643
+ // The live node, where the launch registered this session; the replay inputs stay the snapshot's.
2644
+ nodeId: launchResult.session.nodeId,
2357
2645
  sessionId: launchResult.session.id,
2358
2646
  binding: binding,
2359
2647
  adapter,
@@ -2368,7 +2656,7 @@ export class RestoreOrchestrator {
2368
2656
  resumeType: (isPodAware && resumeRequested) ? resumeType ?? undefined : undefined,
2369
2657
  sessionName: sessionName,
2370
2658
  allowFreshFallback: !(isPodAware && resumeRequested),
2371
- ...(selected ? { beforeNativeLaunch: () => selected.beforeNative(launchResult.session.id, launchResult.binding.id) } : {}),
2659
+ ...(beforeNative ? { beforeNativeLaunch: () => beforeNative(launchResult.session.id, launchResult.binding.id) } : {}),
2372
2660
  });
2373
2661
  warnings?.push(...(startupResult.warnings ?? []));
2374
2662
  // #3039: the blocks the resumed launch actually sent, by the adapter's own record, are the ones the check after the
@@ -2398,6 +2686,7 @@ export class RestoreOrchestrator {
2398
2686
  nodeId: node.id,
2399
2687
  logicalId: node.logicalId,
2400
2688
  status: "awaiting-decision",
2689
+ stage: "resume_rolled_back",
2401
2690
  error: resumeWithoutContext
2402
2691
  ? `Original session unresumable: resume attempted but the runtime reported fresh continuity. The blank session was rolled back; no session is running. ${noContextFresh}`
2403
2692
  : `Original session unresumable: resume attempted but the runtime reported fresh continuity. The blank session was rolled back; no session is running. If that degradation is acceptable, start only this seat fresh: ${this.freshSeatCommand(rigId, data, node.logicalId)}.`,
@@ -2407,7 +2696,7 @@ export class RestoreOrchestrator {
2407
2696
  ? ((startupResult.continuityOutcome === "resumed" || nativeContinuityProved) ? "resumed" : baseStatus)
2408
2697
  : baseStatus;
2409
2698
  if (finalStatus === "resumed") {
2410
- return this.finishJoinedResume(node, sessionName, resumeToken, launchResult?.session.id, isPodAware && node.runtime === "claude-code", startupResult.resumedProcess, selected ? () => selected.beforeNative(launchResult?.session.id, launchResult?.binding.id) : undefined);
2699
+ return this.finishJoinedResume(node, sessionName, resumeToken, launchResult?.session.id, isPodAware && node.runtime === "claude-code", startupResult.resumedProcess, selected ? () => selected.beforeNative(launchResult?.session.id, launchResult?.binding.id) : undefined, launchResult?.session.nodeId);
2411
2700
  }
2412
2701
  return { nodeId: node.id, logicalId: node.logicalId, status: finalStatus, ...(noConversation && finalStatus === "fresh-primed" ? { noConversation: true } : {}) };
2413
2702
  }
@@ -2448,6 +2737,7 @@ export class RestoreOrchestrator {
2448
2737
  nodeId: node.id,
2449
2738
  logicalId: node.logicalId,
2450
2739
  status: "awaiting-decision",
2740
+ stage: "resume_rolled_back",
2451
2741
  error: resumeWithoutContext
2452
2742
  ? `Original session unresumable: ${startupResult.errors.join("; ")}. The blank session was rolled back; no session is running. ${noContextFresh} Restore the original session manually.`
2453
2743
  : `Original session unresumable: ${startupResult.errors.join("; ")}. The blank session was rolled back; no session is running. OpenRig's records can't tell whether this conversation was ever used. If you know this seat was never used, nothing is lost by starting only this seat fresh, ${steps}. Otherwise restore the original session manually.`,
@@ -2498,7 +2788,7 @@ export class RestoreOrchestrator {
2498
2788
  }
2499
2789
  }
2500
2790
  if (baseStatus === "resumed") {
2501
- return this.finishJoinedResume(node, sessionName, resumeToken, launchResult?.session.id, false, undefined, selected ? () => selected.beforeNative(launchResult?.session.id, launchResult?.binding.id) : undefined);
2791
+ return this.finishJoinedResume(node, sessionName, resumeToken, launchResult?.session.id, false, undefined, selected ? () => selected.beforeNative(launchResult?.session.id, launchResult?.binding.id) : undefined, launchResult?.session.nodeId);
2502
2792
  }
2503
2793
  return { nodeId: node.id, logicalId: node.logicalId, status: baseStatus, ...(noConversation && !startupFailed && baseStatus === "fresh-primed" ? { noConversation: true } : {}) };
2504
2794
  }
@@ -2506,14 +2796,18 @@ export class RestoreOrchestrator {
2506
2796
  * rebound and its process identity agrees with the declared seat runtime. */
2507
2797
  async finishJoinedResume(node, sessionName, resumeToken, sessionId, managedClaudeResume = false,
2508
2798
  /** Codex (#1524): the process the adapter proved the resume on. The join must verify that same process. */
2509
- provenCodexProcess, assertCurrent) {
2799
+ provenCodexProcess, assertCurrent,
2800
+ /** The node the launcher registered the session on; a seat recreated after the snapshot runs under a new id. The live
2801
+ * checks read it; the result keeps the snapshot's node, which the caller maps to the registered one. */
2802
+ liveNodeId) {
2803
+ const seatNodeId = liveNodeId ?? node.id;
2510
2804
  if (assertCurrent && !assertCurrent())
2511
2805
  return { nodeId: node.id, logicalId: node.logicalId, status: "attention_required", error: "Selected seat changed before joined native proof; outcome needs inspection." };
2512
2806
  const identity = await rebindAndVerifyPaneIdentity({
2513
2807
  db: this.db,
2514
2808
  sessionRegistry: this.sessionRegistry,
2515
2809
  tmux: this.tmuxAdapter,
2516
- nodeId: node.id,
2810
+ nodeId: seatNodeId,
2517
2811
  sessionName,
2518
2812
  runtime: node.runtime ?? null,
2519
2813
  expectedResumeToken: resumeToken,
@@ -2528,7 +2822,7 @@ export class RestoreOrchestrator {
2528
2822
  return;
2529
2823
  // The join awaits native observations. Only the exact launched row, still
2530
2824
  // current and running, owns this readiness write after those awaits.
2531
- const current = this.db.prepare("SELECT id, session_name, status FROM sessions WHERE node_id = ? ORDER BY created_at DESC, id DESC LIMIT 1").get(node.id);
2825
+ const current = this.db.prepare("SELECT id, session_name, status FROM sessions WHERE node_id = ? ORDER BY created_at DESC, id DESC LIMIT 1").get(seatNodeId);
2532
2826
  if (current?.id === sessionId && current.session_name === sessionName && current.status === "running") {
2533
2827
  this.sessionRegistry.updateStartupStatus(sessionId, "attention_required");
2534
2828
  }
@@ -2550,7 +2844,7 @@ export class RestoreOrchestrator {
2550
2844
  const joined = identity.nativeProcess;
2551
2845
  if (!joined || joined.pid !== provenCodexProcess.pid || joined.startedAt !== provenCodexProcess.startedAt) {
2552
2846
  const store = new SeatIdentityStore(this.db);
2553
- const proof = store.getForNode(node.id);
2847
+ const proof = store.getForNode(seatNodeId);
2554
2848
  if (proof)
2555
2849
  store.upsert({ ...proof, verdict: "mismatch", reason: "process_identity_mismatch" });
2556
2850
  return { nodeId: node.id, logicalId: node.logicalId, status: "attention_required",
@@ -2561,7 +2855,7 @@ export class RestoreOrchestrator {
2561
2855
  // launched row's empty token after proof; never overwrite a hook/operator.
2562
2856
  if ((node.runtime === "codex" || node.runtime === "claude-code") && sessionId && resumeToken) {
2563
2857
  const current = this.db.prepare("SELECT node_id, session_name, status, resume_token FROM sessions WHERE id = ?").get(sessionId);
2564
- const sameSession = current?.node_id === node.id && current.session_name === sessionName && current.status === "running";
2858
+ const sameSession = current?.node_id === seatNodeId && current.session_name === sessionName && current.status === "running";
2565
2859
  // Startup already retained the managed token. Recheck after the awaited
2566
2860
  // join; a hook/operator may have changed it meanwhile. Never backfill here.
2567
2861
  const retained = sameSession && (managedClaudeResume
@@ -2574,7 +2868,7 @@ export class RestoreOrchestrator {
2574
2868
  if (!retained) {
2575
2869
  markManagedResumeAttention();
2576
2870
  const store = new SeatIdentityStore(this.db);
2577
- const proof = store.getForNode(node.id);
2871
+ const proof = store.getForNode(seatNodeId);
2578
2872
  if (proof)
2579
2873
  store.upsert({ ...proof, verdict: "mismatch", reason: "process_identity_mismatch" });
2580
2874
  return { nodeId: node.id, logicalId: node.logicalId, status: "attention_required",