@openrig/cli 0.7.10 → 0.7.12

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 (1131) hide show
  1. package/README.md +9 -6
  2. package/daemon/assets/claude-permission-policies.cjs +41 -0
  3. package/daemon/assets/claude-permission-policies.d.cts +3 -0
  4. package/daemon/assets/claude-team-permissions.cjs +13 -3
  5. package/daemon/assets/guidance/openrig-context-entry.md +8 -0
  6. package/daemon/assets/herdr-app/mods/rig-cell-header/main.js +15 -0
  7. package/daemon/assets/herdr-app/mods/rig-cell-header/mod.json +1 -0
  8. package/daemon/assets/herdr-app/mods/rig-ended/main.js +14 -0
  9. package/daemon/assets/herdr-app/mods/rig-ended/mod.json +1 -0
  10. package/daemon/assets/herdr-app/mods/rig-pad/main.js +10 -0
  11. package/daemon/assets/herdr-app/mods/rig-pad/mod.json +1 -0
  12. package/daemon/assets/herdr-app/mods/rig-strip/main.js +153 -0
  13. package/daemon/assets/herdr-app/mods/rig-strip/mod.json +1 -0
  14. package/daemon/assets/openshell/README.md +1 -1
  15. package/daemon/assets/pi-account-lock.cjs +39 -0
  16. package/daemon/assets/plugins/openrig/.claude-plugin/marketplace.json +15 -0
  17. package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +32 -0
  18. package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +39 -0
  19. package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +6 -0
  20. package/daemon/assets/plugins/openrig/LICENSE +200 -0
  21. package/daemon/assets/plugins/openrig/README.md +106 -0
  22. package/daemon/assets/plugins/openrig/assets/logo.svg +1 -0
  23. package/daemon/assets/plugins/openrig/mcp.json +10 -0
  24. package/daemon/assets/plugins/openrig/plugin.json +14 -0
  25. package/daemon/assets/plugins/openrig/skills/working-with-an-openrig-team/SKILL.md +90 -0
  26. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  27. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  28. package/daemon/assets/plugins/openrig-core/hooks/scripts/activity-relay.cjs +35 -0
  29. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus-state.cjs +103 -0
  30. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +177 -86
  31. package/daemon/assets/plugins/openrig-core/skills/agent-operated-software/SKILL.md +5 -1
  32. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/SKILL.md +3 -2
  33. package/daemon/assets/plugins/openrig-core/skills/openrig-skills/SKILL.md +1 -0
  34. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +25 -9
  35. package/daemon/assets/plugins/openrig-core/skills/refocusing/SKILL.md +5 -0
  36. package/daemon/assets/plugins/openrig-core/skills/refocusing/scripts/trace-to-root.py +26 -4
  37. package/daemon/assets/plugins/openrig-core/skills/retiring-and-inheriting-a-seat/SKILL.md +1 -1
  38. package/daemon/assets/plugins/openrig-core/skills/seat-continuity-and-handover/SKILL.md +10 -6
  39. package/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore/SKILL.md +1 -1
  40. package/daemon/assets/skills/rigs/SKILL.md +37 -2
  41. package/daemon/context-packs/help/help.md +18 -0
  42. package/daemon/context-packs/help/manifest.yaml +1 -1
  43. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  44. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +104 -14
  45. package/daemon/context-packs/reference/acp-agents.md +68 -0
  46. package/daemon/context-packs/reference/getting-started.md +19 -3
  47. package/daemon/context-packs/reference/manifest.yaml +4 -1
  48. package/daemon/context-packs/reference/rig-spec.md +71 -8
  49. package/daemon/context-packs/reference/tmux-servers.md +214 -0
  50. package/daemon/context-packs/reference/whats-new.md +402 -132
  51. package/daemon/context-packs/skills/agent-operated-software/SKILL.md +5 -1
  52. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/claude-compaction-restore/SKILL.md +3 -2
  56. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/core/cross-host-rig-commands/SKILL.md +7 -0
  60. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/core/openrig-herdr/SKILL.md +1 -0
  66. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/core/openrig-skills/SKILL.md +1 -0
  68. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  76. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  77. package/daemon/context-packs/skills/core/working-with-an-openrig-team/SKILL.md +90 -0
  78. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +10 -0
  79. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  80. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  81. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  82. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  83. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  84. package/daemon/context-packs/skills/openrig-user/SKILL.md +25 -9
  85. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  86. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  87. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  88. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  89. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  90. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  91. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  92. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  93. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  94. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  95. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  96. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  97. package/daemon/context-packs/skills/pods/review-team/SKILL.md +2 -0
  98. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  99. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  100. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  101. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  102. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  103. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  104. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  105. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  106. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  107. package/daemon/context-packs/skills/refocusing/SKILL.md +5 -0
  108. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  109. package/daemon/context-packs/skills/refocusing/scripts/trace-to-root.py +26 -4
  110. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/SKILL.md +1 -1
  111. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  112. package/daemon/context-packs/skills/seat-continuity-and-handover/SKILL.md +10 -6
  113. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  114. package/daemon/context-packs/skills/session-compaction-and-restore/SKILL.md +1 -1
  115. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  116. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  117. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  118. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  119. package/daemon/dist/adapters/claude-code-adapter.d.ts +3 -1
  120. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  121. package/daemon/dist/adapters/claude-code-adapter.js +59 -15
  122. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  123. package/daemon/dist/adapters/claude-resume.d.ts +2 -1
  124. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  125. package/daemon/dist/adapters/claude-resume.js +28 -6
  126. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  127. package/daemon/dist/adapters/codex-resume.d.ts +1 -1
  128. package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
  129. package/daemon/dist/adapters/codex-resume.js +6 -2
  130. package/daemon/dist/adapters/codex-resume.js.map +1 -1
  131. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +2 -0
  132. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  133. package/daemon/dist/adapters/codex-runtime-adapter.js +54 -13
  134. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  135. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +10 -6
  136. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
  137. package/daemon/dist/adapters/community-harness-runtime-adapter.js +78 -24
  138. package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
  139. package/daemon/dist/adapters/kernel-authority.d.ts +2 -4
  140. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  141. package/daemon/dist/adapters/kernel-authority.js +10 -41
  142. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  143. package/daemon/dist/adapters/openshell-podman-observer.d.ts.map +1 -1
  144. package/daemon/dist/adapters/openshell-podman-observer.js +5 -3
  145. package/daemon/dist/adapters/openshell-podman-observer.js.map +1 -1
  146. package/daemon/dist/adapters/pi-community-runtime-adapter.d.ts +27 -0
  147. package/daemon/dist/adapters/pi-community-runtime-adapter.d.ts.map +1 -0
  148. package/daemon/dist/adapters/pi-community-runtime-adapter.js +38 -0
  149. package/daemon/dist/adapters/pi-community-runtime-adapter.js.map +1 -0
  150. package/daemon/dist/adapters/pi-resume.d.ts +4 -1
  151. package/daemon/dist/adapters/pi-resume.d.ts.map +1 -1
  152. package/daemon/dist/adapters/pi-resume.js +38 -9
  153. package/daemon/dist/adapters/pi-resume.js.map +1 -1
  154. package/daemon/dist/adapters/pi-runner-protocol.d.ts +9 -3
  155. package/daemon/dist/adapters/pi-runner-protocol.d.ts.map +1 -1
  156. package/daemon/dist/adapters/pi-runner-protocol.js +13 -1
  157. package/daemon/dist/adapters/pi-runner-protocol.js.map +1 -1
  158. package/daemon/dist/adapters/pi-runner.d.ts +14 -4
  159. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  160. package/daemon/dist/adapters/pi-runner.js +174 -29
  161. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  162. package/daemon/dist/adapters/pi-runtime-adapter.d.ts +37 -14
  163. package/daemon/dist/adapters/pi-runtime-adapter.d.ts.map +1 -1
  164. package/daemon/dist/adapters/pi-runtime-adapter.js +97 -31
  165. package/daemon/dist/adapters/pi-runtime-adapter.js.map +1 -1
  166. package/daemon/dist/adapters/tmux-control.d.ts +32 -1
  167. package/daemon/dist/adapters/tmux-control.d.ts.map +1 -1
  168. package/daemon/dist/adapters/tmux-control.js +149 -9
  169. package/daemon/dist/adapters/tmux-control.js.map +1 -1
  170. package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
  171. package/daemon/dist/adapters/tmux-exec.js +13 -4
  172. package/daemon/dist/adapters/tmux-exec.js.map +1 -1
  173. package/daemon/dist/adapters/tmux-server.d.ts +11 -0
  174. package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
  175. package/daemon/dist/adapters/tmux-server.js +13 -1
  176. package/daemon/dist/adapters/tmux-server.js.map +1 -1
  177. package/daemon/dist/adapters/tmux.d.ts +32 -1
  178. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  179. package/daemon/dist/adapters/tmux.js +241 -27
  180. package/daemon/dist/adapters/tmux.js.map +1 -1
  181. package/daemon/dist/attention-surface.d.ts +7 -0
  182. package/daemon/dist/attention-surface.d.ts.map +1 -1
  183. package/daemon/dist/attention-surface.js.map +1 -1
  184. package/daemon/dist/build-info.js +3 -3
  185. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  186. package/daemon/dist/db/all-migrations.js +20 -0
  187. package/daemon/dist/db/all-migrations.js.map +1 -1
  188. package/daemon/dist/db/migrations/150_node_launch_wrapper.d.ts +3 -0
  189. package/daemon/dist/db/migrations/150_node_launch_wrapper.d.ts.map +1 -0
  190. package/daemon/dist/db/migrations/150_node_launch_wrapper.js +5 -0
  191. package/daemon/dist/db/migrations/150_node_launch_wrapper.js.map +1 -0
  192. package/daemon/dist/db/migrations/151_pi_account_switches.d.ts +4 -0
  193. package/daemon/dist/db/migrations/151_pi_account_switches.d.ts.map +1 -0
  194. package/daemon/dist/db/migrations/151_pi_account_switches.js +44 -0
  195. package/daemon/dist/db/migrations/151_pi_account_switches.js.map +1 -0
  196. package/daemon/dist/db/migrations/152_workflow_instance_spec.d.ts +8 -0
  197. package/daemon/dist/db/migrations/152_workflow_instance_spec.d.ts.map +1 -0
  198. package/daemon/dist/db/migrations/152_workflow_instance_spec.js +13 -0
  199. package/daemon/dist/db/migrations/152_workflow_instance_spec.js.map +1 -0
  200. package/daemon/dist/db/migrations/153_events_retention_marks.d.ts +7 -0
  201. package/daemon/dist/db/migrations/153_events_retention_marks.d.ts.map +1 -0
  202. package/daemon/dist/db/migrations/153_events_retention_marks.js +17 -0
  203. package/daemon/dist/db/migrations/153_events_retention_marks.js.map +1 -0
  204. package/daemon/dist/db/migrations/154_workflow_instance_root_objective.d.ts +7 -0
  205. package/daemon/dist/db/migrations/154_workflow_instance_root_objective.d.ts.map +1 -0
  206. package/daemon/dist/db/migrations/154_workflow_instance_root_objective.js +11 -0
  207. package/daemon/dist/db/migrations/154_workflow_instance_root_objective.js.map +1 -0
  208. package/daemon/dist/db/migrations/155_queue_erasure.d.ts +12 -0
  209. package/daemon/dist/db/migrations/155_queue_erasure.d.ts.map +1 -0
  210. package/daemon/dist/db/migrations/155_queue_erasure.js +28 -0
  211. package/daemon/dist/db/migrations/155_queue_erasure.js.map +1 -0
  212. package/daemon/dist/db/migrations/156_queue_erasure_link_indexes.d.ts +4 -0
  213. package/daemon/dist/db/migrations/156_queue_erasure_link_indexes.d.ts.map +1 -0
  214. package/daemon/dist/db/migrations/156_queue_erasure_link_indexes.js +14 -0
  215. package/daemon/dist/db/migrations/156_queue_erasure_link_indexes.js.map +1 -0
  216. package/daemon/dist/db/migrations/157_queue_erasure_batches.d.ts +9 -0
  217. package/daemon/dist/db/migrations/157_queue_erasure_batches.d.ts.map +1 -0
  218. package/daemon/dist/db/migrations/157_queue_erasure_batches.js +18 -0
  219. package/daemon/dist/db/migrations/157_queue_erasure_batches.js.map +1 -0
  220. package/daemon/dist/db/migrations/158_queue_inbox_checkins.d.ts +8 -0
  221. package/daemon/dist/db/migrations/158_queue_inbox_checkins.d.ts.map +1 -0
  222. package/daemon/dist/db/migrations/158_queue_inbox_checkins.js +15 -0
  223. package/daemon/dist/db/migrations/158_queue_inbox_checkins.js.map +1 -0
  224. package/daemon/dist/db/migrations/159_queue_items_handed_off_from_index.d.ts +5 -0
  225. package/daemon/dist/db/migrations/159_queue_items_handed_off_from_index.d.ts.map +1 -0
  226. package/daemon/dist/db/migrations/159_queue_items_handed_off_from_index.js +9 -0
  227. package/daemon/dist/db/migrations/159_queue_items_handed_off_from_index.js.map +1 -0
  228. package/daemon/dist/domain/activity-taxonomy.d.ts +9 -0
  229. package/daemon/dist/domain/activity-taxonomy.d.ts.map +1 -1
  230. package/daemon/dist/domain/activity-taxonomy.js.map +1 -1
  231. package/daemon/dist/domain/agent-activity-store.d.ts +4 -2
  232. package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
  233. package/daemon/dist/domain/agent-activity-store.js +11 -7
  234. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  235. package/daemon/dist/domain/agent-manifest.d.ts.map +1 -1
  236. package/daemon/dist/domain/agent-manifest.js +11 -1
  237. package/daemon/dist/domain/agent-manifest.js.map +1 -1
  238. package/daemon/dist/domain/builtin-startup-files.d.ts +8 -0
  239. package/daemon/dist/domain/builtin-startup-files.d.ts.map +1 -1
  240. package/daemon/dist/domain/builtin-startup-files.js +37 -11
  241. package/daemon/dist/domain/builtin-startup-files.js.map +1 -1
  242. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +73 -20
  243. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  244. package/daemon/dist/domain/claude-compaction-enforcer.js +442 -84
  245. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  246. package/daemon/dist/domain/claude-continuation-launch.d.ts +16 -0
  247. package/daemon/dist/domain/claude-continuation-launch.d.ts.map +1 -0
  248. package/daemon/dist/domain/claude-continuation-launch.js +110 -0
  249. package/daemon/dist/domain/claude-continuation-launch.js.map +1 -0
  250. package/daemon/dist/domain/claude-git-trust-root.d.ts +11 -0
  251. package/daemon/dist/domain/claude-git-trust-root.d.ts.map +1 -0
  252. package/daemon/dist/domain/claude-git-trust-root.js +72 -0
  253. package/daemon/dist/domain/claude-git-trust-root.js.map +1 -0
  254. package/daemon/dist/domain/claude-managed-launch.d.ts +3 -0
  255. package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
  256. package/daemon/dist/domain/claude-managed-launch.js +17 -7
  257. package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
  258. package/daemon/dist/domain/community-harness-presets.d.ts +5 -0
  259. package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -1
  260. package/daemon/dist/domain/community-harness-presets.js +33 -6
  261. package/daemon/dist/domain/community-harness-presets.js.map +1 -1
  262. package/daemon/dist/domain/compaction-restore-notice.d.ts +3 -1
  263. package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -1
  264. package/daemon/dist/domain/compaction-restore-notice.js +37 -6
  265. package/daemon/dist/domain/compaction-restore-notice.js.map +1 -1
  266. package/daemon/dist/domain/context-monitor.d.ts.map +1 -1
  267. package/daemon/dist/domain/context-monitor.js +3 -0
  268. package/daemon/dist/domain/context-monitor.js.map +1 -1
  269. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  270. package/daemon/dist/domain/context-usage-store.js +10 -1
  271. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  272. package/daemon/dist/domain/current-work.d.ts +52 -0
  273. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  274. package/daemon/dist/domain/current-work.js +215 -0
  275. package/daemon/dist/domain/current-work.js.map +1 -1
  276. package/daemon/dist/domain/default-receiver.d.ts +40 -0
  277. package/daemon/dist/domain/default-receiver.d.ts.map +1 -0
  278. package/daemon/dist/domain/default-receiver.js +70 -0
  279. package/daemon/dist/domain/default-receiver.js.map +1 -0
  280. package/daemon/dist/domain/desired-claude-activity-hooks.d.ts +4 -3
  281. package/daemon/dist/domain/desired-claude-activity-hooks.d.ts.map +1 -1
  282. package/daemon/dist/domain/desired-claude-activity-hooks.js +49 -15
  283. package/daemon/dist/domain/desired-claude-activity-hooks.js.map +1 -1
  284. package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
  285. package/daemon/dist/domain/draft-aware-delivery.js +6 -2
  286. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
  287. package/daemon/dist/domain/escalation-owner.d.ts.map +1 -1
  288. package/daemon/dist/domain/escalation-owner.js +8 -3
  289. package/daemon/dist/domain/escalation-owner.js.map +1 -1
  290. package/daemon/dist/domain/event-bus.d.ts +47 -8
  291. package/daemon/dist/domain/event-bus.d.ts.map +1 -1
  292. package/daemon/dist/domain/event-bus.js +137 -17
  293. package/daemon/dist/domain/event-bus.js.map +1 -1
  294. package/daemon/dist/domain/execution-view.d.ts +9 -0
  295. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  296. package/daemon/dist/domain/execution-view.js +41 -3
  297. package/daemon/dist/domain/execution-view.js.map +1 -1
  298. package/daemon/dist/domain/gateway/connections-projection.d.ts +13 -1
  299. package/daemon/dist/domain/gateway/connections-projection.d.ts.map +1 -1
  300. package/daemon/dist/domain/gateway/connections-projection.js +38 -10
  301. package/daemon/dist/domain/gateway/connections-projection.js.map +1 -1
  302. package/daemon/dist/domain/gateway/dispatcher.d.ts +2 -0
  303. package/daemon/dist/domain/gateway/dispatcher.d.ts.map +1 -1
  304. package/daemon/dist/domain/gateway/dispatcher.js +14 -1
  305. package/daemon/dist/domain/gateway/dispatcher.js.map +1 -1
  306. package/daemon/dist/domain/gateway/gateway-subsystem.d.ts +5 -0
  307. package/daemon/dist/domain/gateway/gateway-subsystem.d.ts.map +1 -1
  308. package/daemon/dist/domain/gateway/gateway-subsystem.js +10 -0
  309. package/daemon/dist/domain/gateway/gateway-subsystem.js.map +1 -1
  310. package/daemon/dist/domain/gateway/human-quiet-windows.d.ts +2 -1
  311. package/daemon/dist/domain/gateway/human-quiet-windows.d.ts.map +1 -1
  312. package/daemon/dist/domain/gateway/human-quiet-windows.js +2 -1
  313. package/daemon/dist/domain/gateway/human-quiet-windows.js.map +1 -1
  314. package/daemon/dist/domain/gateway/human-readiness.d.ts +7 -0
  315. package/daemon/dist/domain/gateway/human-readiness.d.ts.map +1 -1
  316. package/daemon/dist/domain/gateway/human-readiness.js +45 -0
  317. package/daemon/dist/domain/gateway/human-readiness.js.map +1 -1
  318. package/daemon/dist/domain/gateway/human-registry.d.ts +35 -4
  319. package/daemon/dist/domain/gateway/human-registry.d.ts.map +1 -1
  320. package/daemon/dist/domain/gateway/human-registry.js +130 -42
  321. package/daemon/dist/domain/gateway/human-registry.js.map +1 -1
  322. package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
  323. package/daemon/dist/domain/gateway/operator-delivery-engine.js +8 -2
  324. package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
  325. package/daemon/dist/domain/gateway/relay-config.d.ts +83 -0
  326. package/daemon/dist/domain/gateway/relay-config.d.ts.map +1 -0
  327. package/daemon/dist/domain/gateway/relay-config.js +321 -0
  328. package/daemon/dist/domain/gateway/relay-config.js.map +1 -0
  329. package/daemon/dist/domain/gateway/relay-inbound.d.ts +85 -0
  330. package/daemon/dist/domain/gateway/relay-inbound.d.ts.map +1 -0
  331. package/daemon/dist/domain/gateway/relay-inbound.js +981 -0
  332. package/daemon/dist/domain/gateway/relay-inbound.js.map +1 -0
  333. package/daemon/dist/domain/gateway/relay-outbound.d.ts +218 -0
  334. package/daemon/dist/domain/gateway/relay-outbound.d.ts.map +1 -0
  335. package/daemon/dist/domain/gateway/relay-outbound.js +801 -0
  336. package/daemon/dist/domain/gateway/relay-outbound.js.map +1 -0
  337. package/daemon/dist/domain/gateway/slack/config.d.ts +21 -0
  338. package/daemon/dist/domain/gateway/slack/config.d.ts.map +1 -1
  339. package/daemon/dist/domain/gateway/slack/config.js +30 -3
  340. package/daemon/dist/domain/gateway/slack/config.js.map +1 -1
  341. package/daemon/dist/domain/gateway/slack/message.d.ts +4 -0
  342. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  343. package/daemon/dist/domain/gateway/slack/message.js +7 -2
  344. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  345. package/daemon/dist/domain/gateway/slack/open-asks.d.ts +13 -1
  346. package/daemon/dist/domain/gateway/slack/open-asks.d.ts.map +1 -1
  347. package/daemon/dist/domain/gateway/slack/open-asks.js +72 -8
  348. package/daemon/dist/domain/gateway/slack/open-asks.js.map +1 -1
  349. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts +9 -0
  350. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts.map +1 -1
  351. package/daemon/dist/domain/gateway/slack/outbound-driver.js.map +1 -1
  352. package/daemon/dist/domain/gateway/slack/settled-asks.d.ts.map +1 -1
  353. package/daemon/dist/domain/gateway/slack/settled-asks.js +19 -1
  354. package/daemon/dist/domain/gateway/slack/settled-asks.js.map +1 -1
  355. package/daemon/dist/domain/gateway/slack/slack-api.d.ts +3 -0
  356. package/daemon/dist/domain/gateway/slack/slack-api.d.ts.map +1 -1
  357. package/daemon/dist/domain/gateway/slack/slack-api.js +12 -4
  358. package/daemon/dist/domain/gateway/slack/slack-api.js.map +1 -1
  359. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts +2 -0
  360. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
  361. package/daemon/dist/domain/gateway/slack/slack-delivery.js +38 -12
  362. package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
  363. package/daemon/dist/domain/gateway/slack/slack-recovery.d.ts +12 -1
  364. package/daemon/dist/domain/gateway/slack/slack-recovery.d.ts.map +1 -1
  365. package/daemon/dist/domain/gateway/slack/slack-recovery.js +68 -10
  366. package/daemon/dist/domain/gateway/slack/slack-recovery.js.map +1 -1
  367. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
  368. package/daemon/dist/domain/gateway/slack/slack-subsystem.js +363 -67
  369. package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
  370. package/daemon/dist/domain/gateway/slack/socket-inbound.d.ts +1 -0
  371. package/daemon/dist/domain/gateway/slack/socket-inbound.d.ts.map +1 -1
  372. package/daemon/dist/domain/gateway/slack/socket-inbound.js +5 -0
  373. package/daemon/dist/domain/gateway/slack/socket-inbound.js.map +1 -1
  374. package/daemon/dist/domain/gateway/slack/state-store.d.ts +4 -0
  375. package/daemon/dist/domain/gateway/slack/state-store.d.ts.map +1 -1
  376. package/daemon/dist/domain/gateway/slack/state-store.js +4 -1
  377. package/daemon/dist/domain/gateway/slack/state-store.js.map +1 -1
  378. package/daemon/dist/domain/gateway/slack/thread-recovery.d.ts +23 -3
  379. package/daemon/dist/domain/gateway/slack/thread-recovery.d.ts.map +1 -1
  380. package/daemon/dist/domain/gateway/slack/thread-recovery.js +52 -10
  381. package/daemon/dist/domain/gateway/slack/thread-recovery.js.map +1 -1
  382. package/daemon/dist/domain/gateway/slack/thread-seat-map.d.ts +4 -1
  383. package/daemon/dist/domain/gateway/slack/thread-seat-map.d.ts.map +1 -1
  384. package/daemon/dist/domain/gateway/slack/thread-seat-map.js +7 -4
  385. package/daemon/dist/domain/gateway/slack/thread-seat-map.js.map +1 -1
  386. package/daemon/dist/domain/guidance-projection.d.ts +39 -0
  387. package/daemon/dist/domain/guidance-projection.d.ts.map +1 -0
  388. package/daemon/dist/domain/guidance-projection.js +91 -0
  389. package/daemon/dist/domain/guidance-projection.js.map +1 -0
  390. package/daemon/dist/domain/health-passive-ceremony.d.ts.map +1 -1
  391. package/daemon/dist/domain/health-passive-ceremony.js +31 -12
  392. package/daemon/dist/domain/health-passive-ceremony.js.map +1 -1
  393. package/daemon/dist/domain/hosted-wake.d.ts +5 -1
  394. package/daemon/dist/domain/hosted-wake.d.ts.map +1 -1
  395. package/daemon/dist/domain/hosted-wake.js +13 -3
  396. package/daemon/dist/domain/hosted-wake.js.map +1 -1
  397. package/daemon/dist/domain/hosts/pairing-ask.d.ts +10 -0
  398. package/daemon/dist/domain/hosts/pairing-ask.d.ts.map +1 -0
  399. package/daemon/dist/domain/hosts/pairing-ask.js +9 -0
  400. package/daemon/dist/domain/hosts/pairing-ask.js.map +1 -0
  401. package/daemon/dist/domain/launch-wrapper.d.ts +29 -0
  402. package/daemon/dist/domain/launch-wrapper.d.ts.map +1 -0
  403. package/daemon/dist/domain/launch-wrapper.js +97 -0
  404. package/daemon/dist/domain/launch-wrapper.js.map +1 -0
  405. package/daemon/dist/domain/managed-blocks.d.ts +3 -0
  406. package/daemon/dist/domain/managed-blocks.d.ts.map +1 -1
  407. package/daemon/dist/domain/managed-blocks.js +5 -0
  408. package/daemon/dist/domain/managed-blocks.js.map +1 -1
  409. package/daemon/dist/domain/markdown-address.d.ts.map +1 -1
  410. package/daemon/dist/domain/markdown-address.js +12 -1
  411. package/daemon/dist/domain/markdown-address.js.map +1 -1
  412. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +1 -1
  413. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  414. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +116 -28
  415. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  416. package/daemon/dist/domain/model-divergence/current-model-reader.d.ts.map +1 -1
  417. package/daemon/dist/domain/model-divergence/current-model-reader.js +14 -3
  418. package/daemon/dist/domain/model-divergence/current-model-reader.js.map +1 -1
  419. package/daemon/dist/domain/native-process-arguments.d.ts +5 -0
  420. package/daemon/dist/domain/native-process-arguments.d.ts.map +1 -1
  421. package/daemon/dist/domain/native-process-arguments.js +60 -5
  422. package/daemon/dist/domain/native-process-arguments.js.map +1 -1
  423. package/daemon/dist/domain/native-process-lineage.d.ts.map +1 -1
  424. package/daemon/dist/domain/native-process-lineage.js +32 -9
  425. package/daemon/dist/domain/native-process-lineage.js.map +1 -1
  426. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  427. package/daemon/dist/domain/node-inventory.js +9 -2
  428. package/daemon/dist/domain/node-inventory.js.map +1 -1
  429. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  430. package/daemon/dist/domain/node-launcher.js +9 -2
  431. package/daemon/dist/domain/node-launcher.js.map +1 -1
  432. package/daemon/dist/domain/outbox-handler.d.ts +53 -3
  433. package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
  434. package/daemon/dist/domain/outbox-handler.js +101 -6
  435. package/daemon/dist/domain/outbox-handler.js.map +1 -1
  436. package/daemon/dist/domain/package-manifest.d.ts.map +1 -1
  437. package/daemon/dist/domain/package-manifest.js +10 -5
  438. package/daemon/dist/domain/package-manifest.js.map +1 -1
  439. package/daemon/dist/domain/parent-session-env.d.ts +2 -1
  440. package/daemon/dist/domain/parent-session-env.d.ts.map +1 -1
  441. package/daemon/dist/domain/parent-session-env.js +9 -1
  442. package/daemon/dist/domain/parent-session-env.js.map +1 -1
  443. package/daemon/dist/domain/parked-query.d.ts +6 -0
  444. package/daemon/dist/domain/parked-query.d.ts.map +1 -1
  445. package/daemon/dist/domain/parked-query.js +1 -0
  446. package/daemon/dist/domain/parked-query.js.map +1 -1
  447. package/daemon/dist/domain/pi-account-state.d.ts +6 -0
  448. package/daemon/dist/domain/pi-account-state.d.ts.map +1 -0
  449. package/daemon/dist/domain/pi-account-state.js +14 -0
  450. package/daemon/dist/domain/pi-account-state.js.map +1 -0
  451. package/daemon/dist/domain/policies/delivery-digest-flush.d.ts.map +1 -1
  452. package/daemon/dist/domain/policies/delivery-digest-flush.js +9 -1
  453. package/daemon/dist/domain/policies/delivery-digest-flush.js.map +1 -1
  454. package/daemon/dist/domain/policies/mode-scheduled-end.d.ts +4 -1
  455. package/daemon/dist/domain/policies/mode-scheduled-end.d.ts.map +1 -1
  456. package/daemon/dist/domain/policies/mode-scheduled-end.js +19 -10
  457. package/daemon/dist/domain/policies/mode-scheduled-end.js.map +1 -1
  458. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +6 -0
  459. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
  460. package/daemon/dist/domain/policies/parked-owner-consumer.js +13 -3
  461. package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
  462. package/daemon/dist/domain/policies/quiet-release.d.ts +19 -6
  463. package/daemon/dist/domain/policies/quiet-release.d.ts.map +1 -1
  464. package/daemon/dist/domain/policies/quiet-release.js +50 -10
  465. package/daemon/dist/domain/policies/quiet-release.js.map +1 -1
  466. package/daemon/dist/domain/projection-planner.d.ts +4 -1
  467. package/daemon/dist/domain/projection-planner.d.ts.map +1 -1
  468. package/daemon/dist/domain/projection-planner.js +3 -0
  469. package/daemon/dist/domain/projection-planner.js.map +1 -1
  470. package/daemon/dist/domain/proof/judgments.d.ts +11 -0
  471. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  472. package/daemon/dist/domain/proof/judgments.js +61 -38
  473. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  474. package/daemon/dist/domain/queue-blocker.d.ts +5 -0
  475. package/daemon/dist/domain/queue-blocker.d.ts.map +1 -0
  476. package/daemon/dist/domain/queue-blocker.js +12 -0
  477. package/daemon/dist/domain/queue-blocker.js.map +1 -0
  478. package/daemon/dist/domain/queue-erasure.d.ts +173 -0
  479. package/daemon/dist/domain/queue-erasure.d.ts.map +1 -0
  480. package/daemon/dist/domain/queue-erasure.js +885 -0
  481. package/daemon/dist/domain/queue-erasure.js.map +1 -0
  482. package/daemon/dist/domain/queue-owner.d.ts +6 -0
  483. package/daemon/dist/domain/queue-owner.d.ts.map +1 -1
  484. package/daemon/dist/domain/queue-owner.js +13 -4
  485. package/daemon/dist/domain/queue-owner.js.map +1 -1
  486. package/daemon/dist/domain/queue-pickup.d.ts +20 -1
  487. package/daemon/dist/domain/queue-pickup.d.ts.map +1 -1
  488. package/daemon/dist/domain/queue-pickup.js +38 -6
  489. package/daemon/dist/domain/queue-pickup.js.map +1 -1
  490. package/daemon/dist/domain/queue-recovery.d.ts +14 -0
  491. package/daemon/dist/domain/queue-recovery.d.ts.map +1 -1
  492. package/daemon/dist/domain/queue-recovery.js +33 -1
  493. package/daemon/dist/domain/queue-recovery.js.map +1 -1
  494. package/daemon/dist/domain/queue-repository.d.ts +226 -20
  495. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  496. package/daemon/dist/domain/queue-repository.js +786 -91
  497. package/daemon/dist/domain/queue-repository.js.map +1 -1
  498. package/daemon/dist/domain/queue-retention.d.ts +82 -0
  499. package/daemon/dist/domain/queue-retention.d.ts.map +1 -1
  500. package/daemon/dist/domain/queue-retention.js +168 -0
  501. package/daemon/dist/domain/queue-retention.js.map +1 -1
  502. package/daemon/dist/domain/queue-stuck-sweep.d.ts +38 -4
  503. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  504. package/daemon/dist/domain/queue-stuck-sweep.js +763 -190
  505. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  506. package/daemon/dist/domain/queue-transition-log.d.ts +52 -1
  507. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  508. package/daemon/dist/domain/queue-transition-log.js +241 -3
  509. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  510. package/daemon/dist/domain/queue-waiting.d.ts +49 -3
  511. package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
  512. package/daemon/dist/domain/queue-waiting.js +73 -13
  513. package/daemon/dist/domain/queue-waiting.js.map +1 -1
  514. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  515. package/daemon/dist/domain/queue-wake-ladder.js +86 -30
  516. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  517. package/daemon/dist/domain/quiet-hold-custody.d.ts.map +1 -1
  518. package/daemon/dist/domain/quiet-hold-custody.js +7 -3
  519. package/daemon/dist/domain/quiet-hold-custody.js.map +1 -1
  520. package/daemon/dist/domain/rebuild-priming-chain.d.ts +3 -1
  521. package/daemon/dist/domain/rebuild-priming-chain.d.ts.map +1 -1
  522. package/daemon/dist/domain/rebuild-priming-chain.js +3 -1
  523. package/daemon/dist/domain/rebuild-priming-chain.js.map +1 -1
  524. package/daemon/dist/domain/refocus-record.d.ts +17 -0
  525. package/daemon/dist/domain/refocus-record.d.ts.map +1 -0
  526. package/daemon/dist/domain/refocus-record.js +94 -0
  527. package/daemon/dist/domain/refocus-record.js.map +1 -0
  528. package/daemon/dist/domain/restore-check-service.js +1 -1
  529. package/daemon/dist/domain/restore-check-service.js.map +1 -1
  530. package/daemon/dist/domain/restore-guidance.d.ts.map +1 -1
  531. package/daemon/dist/domain/restore-guidance.js +5 -6
  532. package/daemon/dist/domain/restore-guidance.js.map +1 -1
  533. package/daemon/dist/domain/restore-orchestrator.d.ts +15 -2
  534. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  535. package/daemon/dist/domain/restore-orchestrator.js +100 -42
  536. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  537. package/daemon/dist/domain/restore-plan-preview.d.ts.map +1 -1
  538. package/daemon/dist/domain/restore-plan-preview.js +2 -1
  539. package/daemon/dist/domain/restore-plan-preview.js.map +1 -1
  540. package/daemon/dist/domain/resume-token-validation.d.ts +7 -0
  541. package/daemon/dist/domain/resume-token-validation.d.ts.map +1 -1
  542. package/daemon/dist/domain/resume-token-validation.js +13 -3
  543. package/daemon/dist/domain/resume-token-validation.js.map +1 -1
  544. package/daemon/dist/domain/rig-repository.d.ts +3 -0
  545. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  546. package/daemon/dist/domain/rig-repository.js +46 -1
  547. package/daemon/dist/domain/rig-repository.js.map +1 -1
  548. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  549. package/daemon/dist/domain/rig-teardown.js +2 -1
  550. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  551. package/daemon/dist/domain/rigs-being-built.d.ts +5 -0
  552. package/daemon/dist/domain/rigs-being-built.d.ts.map +1 -0
  553. package/daemon/dist/domain/rigs-being-built.js +18 -0
  554. package/daemon/dist/domain/rigs-being-built.js.map +1 -0
  555. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  556. package/daemon/dist/domain/rigspec-codec.js +4 -0
  557. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  558. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  559. package/daemon/dist/domain/rigspec-exporter.js +5 -0
  560. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  561. package/daemon/dist/domain/rigspec-instantiator.d.ts +20 -1
  562. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  563. package/daemon/dist/domain/rigspec-instantiator.js +100 -22
  564. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  565. package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
  566. package/daemon/dist/domain/rigspec-preflight.js +13 -0
  567. package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
  568. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  569. package/daemon/dist/domain/rigspec-schema.js +26 -1
  570. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  571. package/daemon/dist/domain/runner-permissions.d.ts +16 -0
  572. package/daemon/dist/domain/runner-permissions.d.ts.map +1 -1
  573. package/daemon/dist/domain/runner-permissions.js +95 -14
  574. package/daemon/dist/domain/runner-permissions.js.map +1 -1
  575. package/daemon/dist/domain/runtime-adapter.d.ts +2 -0
  576. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  577. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  578. package/daemon/dist/domain/runtime-switch-materials.d.ts +1 -1
  579. package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -1
  580. package/daemon/dist/domain/runtime-switch-materials.js +2 -2
  581. package/daemon/dist/domain/runtime-switch-materials.js.map +1 -1
  582. package/daemon/dist/domain/scope/logical-checkbox.d.ts.map +1 -1
  583. package/daemon/dist/domain/scope/logical-checkbox.js +14 -0
  584. package/daemon/dist/domain/scope/logical-checkbox.js.map +1 -1
  585. package/daemon/dist/domain/seat-activity-service.d.ts +50 -1
  586. package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  587. package/daemon/dist/domain/seat-activity-service.js +144 -5
  588. package/daemon/dist/domain/seat-activity-service.js.map +1 -1
  589. package/daemon/dist/domain/seat-attention-reconciler.d.ts +13 -0
  590. package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
  591. package/daemon/dist/domain/seat-attention-reconciler.js +45 -1
  592. package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
  593. package/daemon/dist/domain/seat-handover-service.d.ts +8 -0
  594. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  595. package/daemon/dist/domain/seat-handover-service.js +61 -19
  596. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  597. package/daemon/dist/domain/seat-kinds.d.ts +21 -0
  598. package/daemon/dist/domain/seat-kinds.d.ts.map +1 -0
  599. package/daemon/dist/domain/seat-kinds.js +27 -0
  600. package/daemon/dist/domain/seat-kinds.js.map +1 -0
  601. package/daemon/dist/domain/seat-launch-environment.d.ts +14 -0
  602. package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
  603. package/daemon/dist/domain/seat-launch-environment.js +64 -16
  604. package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
  605. package/daemon/dist/domain/seat-lifecycle-service.d.ts +12 -0
  606. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  607. package/daemon/dist/domain/seat-lifecycle-service.js +59 -14
  608. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  609. package/daemon/dist/domain/seat-restart-in-place.d.ts +2 -1
  610. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  611. package/daemon/dist/domain/seat-restart-in-place.js +19 -1
  612. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  613. package/daemon/dist/domain/seat-runtime-home.d.ts +4 -1
  614. package/daemon/dist/domain/seat-runtime-home.d.ts.map +1 -1
  615. package/daemon/dist/domain/seat-runtime-home.js +6 -4
  616. package/daemon/dist/domain/seat-runtime-home.js.map +1 -1
  617. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  618. package/daemon/dist/domain/seat-runtime-switch-service.js +87 -13
  619. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  620. package/daemon/dist/domain/seat-skill-apply.d.ts +2 -0
  621. package/daemon/dist/domain/seat-skill-apply.d.ts.map +1 -1
  622. package/daemon/dist/domain/seat-skill-apply.js +5 -2
  623. package/daemon/dist/domain/seat-skill-apply.js.map +1 -1
  624. package/daemon/dist/domain/seat-skill-storage.d.ts +57 -4
  625. package/daemon/dist/domain/seat-skill-storage.d.ts.map +1 -1
  626. package/daemon/dist/domain/seat-skill-storage.js +339 -9
  627. package/daemon/dist/domain/seat-skill-storage.js.map +1 -1
  628. package/daemon/dist/domain/seat-status-service.d.ts +12 -2
  629. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  630. package/daemon/dist/domain/seat-status-service.js +39 -4
  631. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  632. package/daemon/dist/domain/seat-structural-activity-service.d.ts +8 -0
  633. package/daemon/dist/domain/seat-structural-activity-service.d.ts.map +1 -1
  634. package/daemon/dist/domain/seat-structural-activity-service.js +8 -2
  635. package/daemon/dist/domain/seat-structural-activity-service.js.map +1 -1
  636. package/daemon/dist/domain/self-attach-service.d.ts.map +1 -1
  637. package/daemon/dist/domain/self-attach-service.js +11 -4
  638. package/daemon/dist/domain/self-attach-service.js.map +1 -1
  639. package/daemon/dist/domain/session-jsonl.d.ts +4 -2
  640. package/daemon/dist/domain/session-jsonl.d.ts.map +1 -1
  641. package/daemon/dist/domain/session-jsonl.js +56 -22
  642. package/daemon/dist/domain/session-jsonl.js.map +1 -1
  643. package/daemon/dist/domain/session-registry.d.ts +20 -3
  644. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  645. package/daemon/dist/domain/session-registry.js +39 -3
  646. package/daemon/dist/domain/session-registry.js.map +1 -1
  647. package/daemon/dist/domain/session-transport.d.ts +52 -5
  648. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  649. package/daemon/dist/domain/session-transport.js +434 -85
  650. package/daemon/dist/domain/session-transport.js.map +1 -1
  651. package/daemon/dist/domain/skill-catalog.d.ts +37 -0
  652. package/daemon/dist/domain/skill-catalog.d.ts.map +1 -1
  653. package/daemon/dist/domain/skill-catalog.js +152 -3
  654. package/daemon/dist/domain/skill-catalog.js.map +1 -1
  655. package/daemon/dist/domain/slices/slice-detail-projector.d.ts +1 -1
  656. package/daemon/dist/domain/slices/slice-detail-projector.d.ts.map +1 -1
  657. package/daemon/dist/domain/slices/slice-detail-projector.js +11 -13
  658. package/daemon/dist/domain/slices/slice-detail-projector.js.map +1 -1
  659. package/daemon/dist/domain/slices/slice-indexer.d.ts +41 -0
  660. package/daemon/dist/domain/slices/slice-indexer.d.ts.map +1 -1
  661. package/daemon/dist/domain/slices/slice-indexer.js +463 -22
  662. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  663. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  664. package/daemon/dist/domain/startup-orchestrator.js +12 -3
  665. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  666. package/daemon/dist/domain/startup-submission-evidence.d.ts +1 -0
  667. package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
  668. package/daemon/dist/domain/startup-submission-evidence.js +18 -4
  669. package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
  670. package/daemon/dist/domain/successor-session-launcher.d.ts +1 -0
  671. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  672. package/daemon/dist/domain/successor-session-launcher.js +1 -0
  673. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  674. package/daemon/dist/domain/terminal/earlier-tile-attach-0711.d.ts +2 -0
  675. package/daemon/dist/domain/terminal/earlier-tile-attach-0711.d.ts.map +1 -0
  676. package/daemon/dist/domain/terminal/earlier-tile-attach-0711.js +146 -0
  677. package/daemon/dist/domain/terminal/earlier-tile-attach-0711.js.map +1 -0
  678. package/daemon/dist/domain/terminal/earlier-tile-attach.d.ts +1 -0
  679. package/daemon/dist/domain/terminal/earlier-tile-attach.d.ts.map +1 -1
  680. package/daemon/dist/domain/terminal/earlier-tile-attach.js +42 -1
  681. package/daemon/dist/domain/terminal/earlier-tile-attach.js.map +1 -1
  682. package/daemon/dist/domain/terminal/herdr-adapter.d.ts.map +1 -1
  683. package/daemon/dist/domain/terminal/herdr-adapter.js +3 -2
  684. package/daemon/dist/domain/terminal/herdr-adapter.js.map +1 -1
  685. package/daemon/dist/domain/terminal/herdr-app-install.d.ts +28 -0
  686. package/daemon/dist/domain/terminal/herdr-app-install.d.ts.map +1 -0
  687. package/daemon/dist/domain/terminal/herdr-app-install.js +170 -0
  688. package/daemon/dist/domain/terminal/herdr-app-install.js.map +1 -0
  689. package/daemon/dist/domain/terminal/herdr-app-layout.d.ts +79 -0
  690. package/daemon/dist/domain/terminal/herdr-app-layout.d.ts.map +1 -0
  691. package/daemon/dist/domain/terminal/herdr-app-layout.js +134 -0
  692. package/daemon/dist/domain/terminal/herdr-app-layout.js.map +1 -0
  693. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts +123 -0
  694. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts.map +1 -0
  695. package/daemon/dist/domain/terminal/herdr-app-provider.js +681 -0
  696. package/daemon/dist/domain/terminal/herdr-app-provider.js.map +1 -0
  697. package/daemon/dist/domain/terminal/herdr-app-state.d.ts +91 -0
  698. package/daemon/dist/domain/terminal/herdr-app-state.d.ts.map +1 -0
  699. package/daemon/dist/domain/terminal/herdr-app-state.js +140 -0
  700. package/daemon/dist/domain/terminal/herdr-app-state.js.map +1 -0
  701. package/daemon/dist/domain/terminal/herdr-app-transport.d.ts +68 -0
  702. package/daemon/dist/domain/terminal/herdr-app-transport.d.ts.map +1 -0
  703. package/daemon/dist/domain/terminal/herdr-app-transport.js +133 -0
  704. package/daemon/dist/domain/terminal/herdr-app-transport.js.map +1 -0
  705. package/daemon/dist/domain/terminal/herdr-follow-view.d.ts.map +1 -1
  706. package/daemon/dist/domain/terminal/herdr-follow-view.js +43 -19
  707. package/daemon/dist/domain/terminal/herdr-follow-view.js.map +1 -1
  708. package/daemon/dist/domain/terminal/herdr-viewer.d.ts +7 -4
  709. package/daemon/dist/domain/terminal/herdr-viewer.d.ts.map +1 -1
  710. package/daemon/dist/domain/terminal/herdr-viewer.js +101 -47
  711. package/daemon/dist/domain/terminal/herdr-viewer.js.map +1 -1
  712. package/daemon/dist/domain/terminal/terminal-following.js +3 -3
  713. package/daemon/dist/domain/terminal/terminal-following.js.map +1 -1
  714. package/daemon/dist/domain/terminal/terminal-provider.d.ts +18 -0
  715. package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
  716. package/daemon/dist/domain/terminal/terminal-service.d.ts +28 -3
  717. package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
  718. package/daemon/dist/domain/terminal/terminal-service.js +56 -8
  719. package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
  720. package/daemon/dist/domain/terminal/tile-attach.d.ts +6 -3
  721. package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -1
  722. package/daemon/dist/domain/terminal/tile-attach.js +11 -46
  723. package/daemon/dist/domain/terminal/tile-attach.js.map +1 -1
  724. package/daemon/dist/domain/terminal/view-composer.d.ts.map +1 -1
  725. package/daemon/dist/domain/terminal/view-composer.js +1 -0
  726. package/daemon/dist/domain/terminal/view-composer.js.map +1 -1
  727. package/daemon/dist/domain/time-bound-advisory.js +3 -3
  728. package/daemon/dist/domain/time-bound-advisory.js.map +1 -1
  729. package/daemon/dist/domain/tmux-server-selection.d.ts.map +1 -1
  730. package/daemon/dist/domain/tmux-server-selection.js +8 -2
  731. package/daemon/dist/domain/tmux-server-selection.js.map +1 -1
  732. package/daemon/dist/domain/types.d.ts +69 -1
  733. package/daemon/dist/domain/types.d.ts.map +1 -1
  734. package/daemon/dist/domain/types.js.map +1 -1
  735. package/daemon/dist/domain/user-settings/settings-browser.d.ts +2 -1
  736. package/daemon/dist/domain/user-settings/settings-browser.d.ts.map +1 -1
  737. package/daemon/dist/domain/user-settings/settings-browser.js +22 -3
  738. package/daemon/dist/domain/user-settings/settings-browser.js.map +1 -1
  739. package/daemon/dist/domain/user-settings/settings-store.d.ts +1 -1
  740. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  741. package/daemon/dist/domain/user-settings/settings-store.js +83 -0
  742. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  743. package/daemon/dist/domain/view-event-bridge.js +1 -1
  744. package/daemon/dist/domain/view-event-bridge.js.map +1 -1
  745. package/daemon/dist/domain/view-projector.d.ts +4 -1
  746. package/daemon/dist/domain/view-projector.d.ts.map +1 -1
  747. package/daemon/dist/domain/view-projector.js +9 -4
  748. package/daemon/dist/domain/view-projector.js.map +1 -1
  749. package/daemon/dist/domain/wake-recovery.d.ts.map +1 -1
  750. package/daemon/dist/domain/wake-recovery.js +10 -2
  751. package/daemon/dist/domain/wake-recovery.js.map +1 -1
  752. package/daemon/dist/domain/whoami-service.d.ts +6 -0
  753. package/daemon/dist/domain/whoami-service.d.ts.map +1 -1
  754. package/daemon/dist/domain/whoami-service.js +9 -1
  755. package/daemon/dist/domain/whoami-service.js.map +1 -1
  756. package/daemon/dist/domain/workflow-exception-escalation.d.ts +3 -2
  757. package/daemon/dist/domain/workflow-exception-escalation.d.ts.map +1 -1
  758. package/daemon/dist/domain/workflow-exception-escalation.js +1 -1
  759. package/daemon/dist/domain/workflow-exception-escalation.js.map +1 -1
  760. package/daemon/dist/domain/workflow-instance-store.d.ts +8 -1
  761. package/daemon/dist/domain/workflow-instance-store.d.ts.map +1 -1
  762. package/daemon/dist/domain/workflow-instance-store.js +21 -3
  763. package/daemon/dist/domain/workflow-instance-store.js.map +1 -1
  764. package/daemon/dist/domain/workflow-projector.js +1 -1
  765. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  766. package/daemon/dist/domain/workflow-reconciliation.d.ts.map +1 -1
  767. package/daemon/dist/domain/workflow-reconciliation.js +2 -1
  768. package/daemon/dist/domain/workflow-reconciliation.js.map +1 -1
  769. package/daemon/dist/domain/workflow-runtime.d.ts +4 -1
  770. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  771. package/daemon/dist/domain/workflow-runtime.js +24 -11
  772. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  773. package/daemon/dist/domain/workflow-spec-cache.d.ts +38 -4
  774. package/daemon/dist/domain/workflow-spec-cache.d.ts.map +1 -1
  775. package/daemon/dist/domain/workflow-spec-cache.js +115 -14
  776. package/daemon/dist/domain/workflow-spec-cache.js.map +1 -1
  777. package/daemon/dist/domain/workflow-spec-unregister.d.ts +36 -0
  778. package/daemon/dist/domain/workflow-spec-unregister.d.ts.map +1 -0
  779. package/daemon/dist/domain/workflow-spec-unregister.js +105 -0
  780. package/daemon/dist/domain/workflow-spec-unregister.js.map +1 -0
  781. package/daemon/dist/domain/workflow-types.d.ts +14 -0
  782. package/daemon/dist/domain/workflow-types.d.ts.map +1 -1
  783. package/daemon/dist/index.d.ts +3 -1
  784. package/daemon/dist/index.d.ts.map +1 -1
  785. package/daemon/dist/index.js +31 -5
  786. package/daemon/dist/index.js.map +1 -1
  787. package/daemon/dist/learned-host-bindings-surface.d.ts +2 -0
  788. package/daemon/dist/learned-host-bindings-surface.d.ts.map +1 -0
  789. package/daemon/dist/learned-host-bindings-surface.js +4 -0
  790. package/daemon/dist/learned-host-bindings-surface.js.map +1 -0
  791. package/daemon/dist/lib/pane-envelope.d.ts +3 -0
  792. package/daemon/dist/lib/pane-envelope.d.ts.map +1 -1
  793. package/daemon/dist/lib/pane-envelope.js +3 -1
  794. package/daemon/dist/lib/pane-envelope.js.map +1 -1
  795. package/daemon/dist/routes/activity.d.ts.map +1 -1
  796. package/daemon/dist/routes/activity.js +147 -25
  797. package/daemon/dist/routes/activity.js.map +1 -1
  798. package/daemon/dist/routes/adapters.d.ts.map +1 -1
  799. package/daemon/dist/routes/adapters.js +4 -0
  800. package/daemon/dist/routes/adapters.js.map +1 -1
  801. package/daemon/dist/routes/attention.d.ts.map +1 -1
  802. package/daemon/dist/routes/attention.js +2 -0
  803. package/daemon/dist/routes/attention.js.map +1 -1
  804. package/daemon/dist/routes/compaction.js +2 -0
  805. package/daemon/dist/routes/compaction.js.map +1 -1
  806. package/daemon/dist/routes/config.d.ts.map +1 -1
  807. package/daemon/dist/routes/config.js +9 -1
  808. package/daemon/dist/routes/config.js.map +1 -1
  809. package/daemon/dist/routes/events.js +11 -2
  810. package/daemon/dist/routes/events.js.map +1 -1
  811. package/daemon/dist/routes/gateway.d.ts +3 -0
  812. package/daemon/dist/routes/gateway.d.ts.map +1 -1
  813. package/daemon/dist/routes/gateway.js +87 -8
  814. package/daemon/dist/routes/gateway.js.map +1 -1
  815. package/daemon/dist/routes/hosts.d.ts.map +1 -1
  816. package/daemon/dist/routes/hosts.js +400 -37
  817. package/daemon/dist/routes/hosts.js.map +1 -1
  818. package/daemon/dist/routes/provider.js +1 -1
  819. package/daemon/dist/routes/provider.js.map +1 -1
  820. package/daemon/dist/routes/queue.d.ts +19 -0
  821. package/daemon/dist/routes/queue.d.ts.map +1 -1
  822. package/daemon/dist/routes/queue.js +242 -46
  823. package/daemon/dist/routes/queue.js.map +1 -1
  824. package/daemon/dist/routes/seat.d.ts.map +1 -1
  825. package/daemon/dist/routes/seat.js +4 -3
  826. package/daemon/dist/routes/seat.js.map +1 -1
  827. package/daemon/dist/routes/skills.d.ts.map +1 -1
  828. package/daemon/dist/routes/skills.js +8 -2
  829. package/daemon/dist/routes/skills.js.map +1 -1
  830. package/daemon/dist/routes/slices.d.ts.map +1 -1
  831. package/daemon/dist/routes/slices.js +156 -28
  832. package/daemon/dist/routes/slices.js.map +1 -1
  833. package/daemon/dist/routes/terminal-ws.d.ts +1 -0
  834. package/daemon/dist/routes/terminal-ws.d.ts.map +1 -1
  835. package/daemon/dist/routes/terminal-ws.js +1 -1
  836. package/daemon/dist/routes/terminal-ws.js.map +1 -1
  837. package/daemon/dist/routes/terminal.d.ts.map +1 -1
  838. package/daemon/dist/routes/terminal.js +40 -3
  839. package/daemon/dist/routes/terminal.js.map +1 -1
  840. package/daemon/dist/routes/transport.d.ts.map +1 -1
  841. package/daemon/dist/routes/transport.js +0 -1
  842. package/daemon/dist/routes/transport.js.map +1 -1
  843. package/daemon/dist/routes/workflow.d.ts.map +1 -1
  844. package/daemon/dist/routes/workflow.js +24 -0
  845. package/daemon/dist/routes/workflow.js.map +1 -1
  846. package/daemon/dist/server.d.ts +2 -0
  847. package/daemon/dist/server.d.ts.map +1 -1
  848. package/daemon/dist/server.js +7 -2
  849. package/daemon/dist/server.js.map +1 -1
  850. package/daemon/dist/startup.d.ts +34 -0
  851. package/daemon/dist/startup.d.ts.map +1 -1
  852. package/daemon/dist/startup.js +255 -25
  853. package/daemon/dist/startup.js.map +1 -1
  854. package/daemon/dist/terminal/TerminalSessionBroker.d.ts +18 -13
  855. package/daemon/dist/terminal/TerminalSessionBroker.d.ts.map +1 -1
  856. package/daemon/dist/terminal/TerminalSessionBroker.js +113 -76
  857. package/daemon/dist/terminal/TerminalSessionBroker.js.map +1 -1
  858. package/daemon/dist/terminal/window-pin.d.ts +3 -3
  859. package/daemon/dist/terminal/window-pin.d.ts.map +1 -1
  860. package/daemon/dist/terminal/window-pin.js +2 -2
  861. package/daemon/dist/terminal/window-pin.js.map +1 -1
  862. package/daemon/docs/reference/acp-agents.md +68 -0
  863. package/daemon/docs/reference/agent-spec.md +51 -1
  864. package/daemon/docs/reference/agent-startup-guide.md +52 -2
  865. package/daemon/docs/reference/agent-state-taxonomy.md +7 -0
  866. package/daemon/docs/reference/community-harness-examples/omo/omo.yaml +14 -0
  867. package/daemon/docs/reference/community-harness-presets.md +56 -2
  868. package/daemon/docs/reference/daemon-http-clients.md +31 -8
  869. package/daemon/docs/reference/edge-types.md +6 -4
  870. package/daemon/docs/reference/gateway-participants.md +23 -1
  871. package/daemon/docs/reference/gateway-relay.md +268 -0
  872. package/daemon/docs/reference/getting-started.md +19 -3
  873. package/daemon/docs/reference/harness-runner-contract.md +61 -12
  874. package/daemon/docs/reference/health-diagnosis.md +5 -1
  875. package/daemon/docs/reference/help.md +18 -0
  876. package/daemon/docs/reference/herdr-app.md +148 -0
  877. package/daemon/docs/reference/hosted-members.md +56 -7
  878. package/daemon/docs/reference/keeping-a-watch.md +3 -1
  879. package/daemon/docs/reference/project-workspace.md +4 -0
  880. package/daemon/docs/reference/queue-erasure.md +161 -0
  881. package/daemon/docs/reference/quickstart.md +1 -1
  882. package/daemon/docs/reference/reconstructions.md +90 -0
  883. package/daemon/docs/reference/rig-spec.md +71 -8
  884. package/daemon/docs/reference/runner-conformance/README.md +3 -0
  885. package/daemon/docs/reference/runner-conformance/check-runner.mjs +27 -6
  886. package/daemon/docs/reference/runner-conformance/fake-acp-agent.mjs +1 -1
  887. package/daemon/docs/reference/sdlc-conventions.md +16 -1
  888. package/daemon/docs/reference/seat-delivery.md +30 -3
  889. package/daemon/docs/reference/slack-app-setup.md +37 -12
  890. package/daemon/docs/reference/terminal-sessions.md +101 -26
  891. package/daemon/docs/reference/tmux-servers.md +50 -2
  892. package/daemon/docs/reference/whats-new.md +402 -132
  893. package/daemon/specs/agents/shared/skills/core/cross-host-rig-commands/SKILL.md +7 -0
  894. package/daemon/specs/agents/shared/skills/core/openrig-herdr/SKILL.md +1 -0
  895. package/daemon/specs/agents/shared/skills/core/openrig-skills/SKILL.md +1 -0
  896. package/daemon/specs/agents/shared/skills/core/working-with-an-openrig-team/SKILL.md +90 -0
  897. package/daemon/specs/agents/shared/skills/pods/review-team/SKILL.md +2 -0
  898. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +24 -0
  899. package/daemon/specs/rigs/launch/kernel/culture/CULTURE.md +7 -4
  900. package/daemon/specs/rigs/launch/kernel/rig.yaml +6 -3
  901. package/daemon/specs/rigs/launch/starter/guidance/lead-first-move.md +3 -1
  902. package/dist/acp/agent-server.d.ts +126 -0
  903. package/dist/acp/agent-server.d.ts.map +1 -0
  904. package/dist/acp/agent-server.js +449 -0
  905. package/dist/acp/agent-server.js.map +1 -0
  906. package/dist/acp/json-rpc-stdio.d.ts +24 -10
  907. package/dist/acp/json-rpc-stdio.d.ts.map +1 -1
  908. package/dist/acp/json-rpc-stdio.js +58 -36
  909. package/dist/acp/json-rpc-stdio.js.map +1 -1
  910. package/dist/bin-wrapper.d.ts.map +1 -1
  911. package/dist/bin-wrapper.js +3 -1
  912. package/dist/bin-wrapper.js.map +1 -1
  913. package/dist/build-info.js +3 -3
  914. package/dist/client.d.ts +4 -0
  915. package/dist/client.d.ts.map +1 -1
  916. package/dist/client.js +9 -2
  917. package/dist/client.js.map +1 -1
  918. package/dist/commands/acp.d.ts +14 -0
  919. package/dist/commands/acp.d.ts.map +1 -1
  920. package/dist/commands/acp.js +189 -2
  921. package/dist/commands/acp.js.map +1 -1
  922. package/dist/commands/attach.js +1 -1
  923. package/dist/commands/attach.js.map +1 -1
  924. package/dist/commands/capture.js +6 -6
  925. package/dist/commands/capture.js.map +1 -1
  926. package/dist/commands/compact.d.ts.map +1 -1
  927. package/dist/commands/compact.js +14 -2
  928. package/dist/commands/compact.js.map +1 -1
  929. package/dist/commands/config.d.ts.map +1 -1
  930. package/dist/commands/config.js +46 -7
  931. package/dist/commands/config.js.map +1 -1
  932. package/dist/commands/context-reconstruction.d.ts +5 -0
  933. package/dist/commands/context-reconstruction.d.ts.map +1 -0
  934. package/dist/commands/context-reconstruction.js +69 -0
  935. package/dist/commands/context-reconstruction.js.map +1 -0
  936. package/dist/commands/context.d.ts.map +1 -1
  937. package/dist/commands/context.js +46 -4
  938. package/dist/commands/context.js.map +1 -1
  939. package/dist/commands/daemon.d.ts.map +1 -1
  940. package/dist/commands/daemon.js +22 -5
  941. package/dist/commands/daemon.js.map +1 -1
  942. package/dist/commands/doctor.d.ts.map +1 -1
  943. package/dist/commands/doctor.js +61 -0
  944. package/dist/commands/doctor.js.map +1 -1
  945. package/dist/commands/gateway.d.ts.map +1 -1
  946. package/dist/commands/gateway.js +36 -11
  947. package/dist/commands/gateway.js.map +1 -1
  948. package/dist/commands/host.d.ts.map +1 -1
  949. package/dist/commands/host.js +68 -12
  950. package/dist/commands/host.js.map +1 -1
  951. package/dist/commands/launch.d.ts +1 -0
  952. package/dist/commands/launch.d.ts.map +1 -1
  953. package/dist/commands/launch.js +1 -1
  954. package/dist/commands/launch.js.map +1 -1
  955. package/dist/commands/mcp.d.ts.map +1 -1
  956. package/dist/commands/mcp.js +29 -5
  957. package/dist/commands/mcp.js.map +1 -1
  958. package/dist/commands/proof.d.ts.map +1 -1
  959. package/dist/commands/proof.js +18 -6
  960. package/dist/commands/proof.js.map +1 -1
  961. package/dist/commands/provider.d.ts.map +1 -1
  962. package/dist/commands/provider.js +4 -1
  963. package/dist/commands/provider.js.map +1 -1
  964. package/dist/commands/ps.d.ts +11 -1
  965. package/dist/commands/ps.d.ts.map +1 -1
  966. package/dist/commands/ps.js +26 -3
  967. package/dist/commands/ps.js.map +1 -1
  968. package/dist/commands/queue.d.ts +3 -0
  969. package/dist/commands/queue.d.ts.map +1 -1
  970. package/dist/commands/queue.js +429 -75
  971. package/dist/commands/queue.js.map +1 -1
  972. package/dist/commands/scope.d.ts +2 -0
  973. package/dist/commands/scope.d.ts.map +1 -1
  974. package/dist/commands/scope.js +15 -0
  975. package/dist/commands/scope.js.map +1 -1
  976. package/dist/commands/seat.d.ts.map +1 -1
  977. package/dist/commands/seat.js +79 -13
  978. package/dist/commands/seat.js.map +1 -1
  979. package/dist/commands/send.d.ts +2 -0
  980. package/dist/commands/send.d.ts.map +1 -1
  981. package/dist/commands/send.js +16 -6
  982. package/dist/commands/send.js.map +1 -1
  983. package/dist/commands/setup.js +1 -1
  984. package/dist/commands/setup.js.map +1 -1
  985. package/dist/commands/skill.d.ts.map +1 -1
  986. package/dist/commands/skill.js +5 -0
  987. package/dist/commands/skill.js.map +1 -1
  988. package/dist/commands/slack.d.ts +1 -1
  989. package/dist/commands/slack.d.ts.map +1 -1
  990. package/dist/commands/slack.js +5 -1
  991. package/dist/commands/slack.js.map +1 -1
  992. package/dist/commands/status.d.ts.map +1 -1
  993. package/dist/commands/status.js +11 -1
  994. package/dist/commands/status.js.map +1 -1
  995. package/dist/commands/stream.d.ts.map +1 -1
  996. package/dist/commands/stream.js +24 -1
  997. package/dist/commands/stream.js.map +1 -1
  998. package/dist/commands/terminal.d.ts +22 -0
  999. package/dist/commands/terminal.d.ts.map +1 -1
  1000. package/dist/commands/terminal.js +117 -8
  1001. package/dist/commands/terminal.js.map +1 -1
  1002. package/dist/commands/up.d.ts.map +1 -1
  1003. package/dist/commands/up.js +22 -0
  1004. package/dist/commands/up.js.map +1 -1
  1005. package/dist/commands/whoami.d.ts.map +1 -1
  1006. package/dist/commands/whoami.js +13 -2
  1007. package/dist/commands/whoami.js.map +1 -1
  1008. package/dist/commands/workflow-errors.js +1 -1
  1009. package/dist/commands/workflow-errors.js.map +1 -1
  1010. package/dist/commands/workflow-render.d.ts +4 -0
  1011. package/dist/commands/workflow-render.d.ts.map +1 -1
  1012. package/dist/commands/workflow-render.js +7 -0
  1013. package/dist/commands/workflow-render.js.map +1 -1
  1014. package/dist/commands/workflow.d.ts.map +1 -1
  1015. package/dist/commands/workflow.js +70 -2
  1016. package/dist/commands/workflow.js.map +1 -1
  1017. package/dist/config-store.d.ts +15 -1
  1018. package/dist/config-store.d.ts.map +1 -1
  1019. package/dist/config-store.js +112 -1
  1020. package/dist/config-store.js.map +1 -1
  1021. package/dist/daemon-lifecycle.d.ts +2 -0
  1022. package/dist/daemon-lifecycle.d.ts.map +1 -1
  1023. package/dist/daemon-lifecycle.js +38 -5
  1024. package/dist/daemon-lifecycle.js.map +1 -1
  1025. package/dist/daemon-reachability.d.ts +1 -1
  1026. package/dist/daemon-reachability.d.ts.map +1 -1
  1027. package/dist/daemon-reachability.js +4 -2
  1028. package/dist/daemon-reachability.js.map +1 -1
  1029. package/dist/daemon-start-lock.d.ts +24 -2
  1030. package/dist/daemon-start-lock.d.ts.map +1 -1
  1031. package/dist/daemon-start-lock.js +125 -4
  1032. package/dist/daemon-start-lock.js.map +1 -1
  1033. package/dist/lib/reconstruction-reader.d.ts +122 -0
  1034. package/dist/lib/reconstruction-reader.d.ts.map +1 -0
  1035. package/dist/lib/reconstruction-reader.js +481 -0
  1036. package/dist/lib/reconstruction-reader.js.map +1 -0
  1037. package/dist/lib/scope/logical-checkbox.d.ts.map +1 -1
  1038. package/dist/lib/scope/logical-checkbox.js +14 -0
  1039. package/dist/lib/scope/logical-checkbox.js.map +1 -1
  1040. package/dist/lib/scope/scope-fs.d.ts.map +1 -1
  1041. package/dist/lib/scope/scope-fs.js +36 -2
  1042. package/dist/lib/scope/scope-fs.js.map +1 -1
  1043. package/dist/lib/work-install.d.ts +28 -0
  1044. package/dist/lib/work-install.d.ts.map +1 -1
  1045. package/dist/lib/work-install.js +80 -20
  1046. package/dist/lib/work-install.js.map +1 -1
  1047. package/dist/mcp-http.d.ts +7 -0
  1048. package/dist/mcp-http.d.ts.map +1 -1
  1049. package/dist/mcp-http.js +30 -6
  1050. package/dist/mcp-http.js.map +1 -1
  1051. package/dist/mcp-server.d.ts +33 -3
  1052. package/dist/mcp-server.d.ts.map +1 -1
  1053. package/dist/mcp-server.js +489 -57
  1054. package/dist/mcp-server.js.map +1 -1
  1055. package/dist/queue-artifact.d.ts +57 -0
  1056. package/dist/queue-artifact.d.ts.map +1 -0
  1057. package/dist/queue-artifact.js +70 -0
  1058. package/dist/queue-artifact.js.map +1 -0
  1059. package/dist/queue-receipt.d.ts.map +1 -1
  1060. package/dist/queue-receipt.js +4 -3
  1061. package/dist/queue-receipt.js.map +1 -1
  1062. package/dist/recap-seat.d.ts +28 -0
  1063. package/dist/recap-seat.d.ts.map +1 -0
  1064. package/dist/recap-seat.js +41 -0
  1065. package/dist/recap-seat.js.map +1 -0
  1066. package/dist/seat-attention.d.ts +24 -0
  1067. package/dist/seat-attention.d.ts.map +1 -0
  1068. package/dist/seat-attention.js +119 -0
  1069. package/dist/seat-attention.js.map +1 -0
  1070. package/dist/system-preflight.d.ts.map +1 -1
  1071. package/dist/system-preflight.js +15 -7
  1072. package/dist/system-preflight.js.map +1 -1
  1073. package/dist/terminal-window.d.ts.map +1 -1
  1074. package/dist/terminal-window.js +16 -13
  1075. package/dist/terminal-window.js.map +1 -1
  1076. package/package.json +1 -1
  1077. package/tui/dist/attention/attention-model.d.ts +2 -1
  1078. package/tui/dist/attention/attention-model.d.ts.map +1 -1
  1079. package/tui/dist/attention/attention-model.js +21 -4
  1080. package/tui/dist/attention/attention-model.js.map +1 -1
  1081. package/tui/dist/config/config-model.d.ts.map +1 -1
  1082. package/tui/dist/config/config-model.js +7 -1
  1083. package/tui/dist/config/config-model.js.map +1 -1
  1084. package/tui/dist/config/pairing.d.ts +49 -0
  1085. package/tui/dist/config/pairing.d.ts.map +1 -0
  1086. package/tui/dist/config/pairing.js +98 -0
  1087. package/tui/dist/config/pairing.js.map +1 -0
  1088. package/tui/dist/daemon-client.d.ts +18 -1
  1089. package/tui/dist/daemon-client.d.ts.map +1 -1
  1090. package/tui/dist/daemon-client.js +33 -9
  1091. package/tui/dist/daemon-client.js.map +1 -1
  1092. package/tui/dist/demo-data.js +2 -2
  1093. package/tui/dist/demo-data.js.map +1 -1
  1094. package/tui/dist/detail.d.ts +3 -0
  1095. package/tui/dist/detail.d.ts.map +1 -1
  1096. package/tui/dist/detail.js +6 -1
  1097. package/tui/dist/detail.js.map +1 -1
  1098. package/tui/dist/execution/execution-model.d.ts +2 -0
  1099. package/tui/dist/execution/execution-model.d.ts.map +1 -1
  1100. package/tui/dist/execution/execution-model.js +10 -3
  1101. package/tui/dist/execution/execution-model.js.map +1 -1
  1102. package/tui/dist/health/health-model.d.ts.map +1 -1
  1103. package/tui/dist/health/health-model.js +27 -11
  1104. package/tui/dist/health/health-model.js.map +1 -1
  1105. package/tui/dist/hydrate.d.ts.map +1 -1
  1106. package/tui/dist/hydrate.js +4 -2
  1107. package/tui/dist/hydrate.js.map +1 -1
  1108. package/tui/dist/main.js +11 -2
  1109. package/tui/dist/main.js.map +1 -1
  1110. package/tui/dist/scopes/scopes-model.d.ts +9 -0
  1111. package/tui/dist/scopes/scopes-model.d.ts.map +1 -1
  1112. package/tui/dist/scopes/scopes-model.js +27 -1
  1113. package/tui/dist/scopes/scopes-model.js.map +1 -1
  1114. package/tui/dist/state.d.ts.map +1 -1
  1115. package/tui/dist/state.js +4 -3
  1116. package/tui/dist/state.js.map +1 -1
  1117. package/tui/dist/terminals/open-window.d.ts +21 -1
  1118. package/tui/dist/terminals/open-window.d.ts.map +1 -1
  1119. package/tui/dist/terminals/open-window.js +46 -9
  1120. package/tui/dist/terminals/open-window.js.map +1 -1
  1121. package/tui/dist/terminals/terminal-model.d.ts +8 -1
  1122. package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
  1123. package/tui/dist/terminals/terminal-model.js +25 -8
  1124. package/tui/dist/terminals/terminal-model.js.map +1 -1
  1125. package/tui/dist/types.d.ts +18 -2
  1126. package/tui/dist/types.d.ts.map +1 -1
  1127. package/ui/dist/assets/index-BOYrLyfQ.js +623 -0
  1128. package/ui/dist/assets/index-DqSRu4OY.css +32 -0
  1129. package/ui/dist/index.html +2 -2
  1130. package/ui/dist/assets/index-BFOs3ejL.css +0 -32
  1131. package/ui/dist/assets/index-CdkFwtld.js +0 -623
@@ -1,6 +1,6 @@
1
1
  import { currentParkedOwnerNoInputFailure } from "./policies/parked-owner-consumer.js";
2
2
  import { resolveEscalationOwner, ESCALATION_HOP_TAG, hasConsumedEscalationHop } from "./escalation-owner.js";
3
- import { findQueueRecovery, recoveryId, recoveryTag } from "./queue-recovery.js";
3
+ import { createRecoveryLookup, recoveryId, recoveryTag } from "./queue-recovery.js";
4
4
  import { quietHoldCustody } from "./quiet-hold-custody.js";
5
5
  import { queueWaitNotice } from "./queue-wait-backoff.js";
6
6
  import { lastMeaningfulTransition, pendingSince } from "./queue-waiting.js";
@@ -28,7 +28,7 @@ import { resolvePickupThresholdMinutes } from "./queue-pickup.js";
28
28
  import { resolveOperatorSeat, resolveRecoveryAgentSeat, resolveSessionNodeId } from "./queue-owner.js";
29
29
  import { nodeExecutorStoppedReason } from "./node-inventory.js";
30
30
  import { isBoundTerminalSeat } from "./terminal-seat.js";
31
- import { deriveCrossHostSuccessorId, hasLinkedSuccessor, matchesRecordedHandoffTarget, QueueRepositoryError } from "./queue-repository.js";
31
+ import { createLinkedSuccessorLookup, deriveCrossHostSuccessorId, hasLinkedSuccessor, matchesRecordedHandoffTarget, QueueRepositoryError } from "./queue-repository.js";
32
32
  import { stalledPickupFinding } from "./queue-pickup.js";
33
33
  import { SettingsStore } from "./user-settings/settings-store.js";
34
34
  import { loadHostRegistry } from "./hosts/hosts-registry-reader.js";
@@ -86,6 +86,12 @@ export function resolveLadderSuppressionMinutes() {
86
86
  export function findingDedupTag(kind, qitemId) {
87
87
  return `stuck-sweep:${kind}:${qitemId}`;
88
88
  }
89
+ /** Idempotency key of a seat's standing unclaimed-backlog notice: one open notice per seat. */
90
+ export function unclaimedBacklogTag(seat) {
91
+ return `stuck-sweep:unclaimed-backlog:${seat}`;
92
+ }
93
+ /** How many of a seat's unclaimed rows its standing notice lists by id; the rest are counted. */
94
+ export const UNCLAIMED_BACKLOG_LISTED_ROWS = 20;
89
95
  /** The loop's observable heartbeat — surfaced on /healthz so a quiet sweep is cheap but
90
96
  * never invisible, and a failing sweep is loud without needing a row. */
91
97
  export function createStuckSweepStatus() {
@@ -95,6 +101,9 @@ export function createStuckSweepStatus() {
95
101
  lastError: null,
96
102
  consecutiveFailures: 0,
97
103
  findingsRouted: 0,
104
+ findingsOpen: 0,
105
+ runningSince: null,
106
+ skippedTicks: 0,
98
107
  };
99
108
  return {
100
109
  record(outcome, detail) {
@@ -102,8 +111,14 @@ export function createStuckSweepStatus() {
102
111
  state.lastOutcome = outcome;
103
112
  state.lastError = outcome === "failed" ? (detail?.error ?? "unknown error") : null;
104
113
  state.consecutiveFailures = outcome === "failed" ? state.consecutiveFailures + 1 : 0;
105
- if (detail?.findings)
106
- state.findingsRouted += detail.findings;
114
+ if (detail?.created)
115
+ state.findingsRouted += detail.created;
116
+ if (detail?.open !== undefined)
117
+ state.findingsOpen = detail.open;
118
+ },
119
+ pass(pass) {
120
+ state.runningSince = pass.runningSince;
121
+ state.skippedTicks = pass.skippedTicks;
107
122
  },
108
123
  snapshot() {
109
124
  return { ...state };
@@ -137,8 +152,10 @@ export { resolveSessionNodeId, defaultResolveOrchestrator, resolveOperatorSeat }
137
152
  * ladder live again. Unrelated transitions do not change the latest marker. */
138
153
  /** Durable custody-verification disposition: a transition note on the CLOSED source row,
139
154
  * written by whoever performed the registered-host read (never by this detector),
140
- * `custody-verified: <exact-target> <free-form how/where>`. Prefix-anchored parse; the
141
- * target is the first whitespace-delimited token after the prefix, matched exactly.
155
+ * `custody-verified: <exact-target> <free-form how/where>`. Prefix-anchored parse; per note,
156
+ * the first whitespace-delimited word after the prefix that names one of the row's targets
157
+ * (itself or a comma member, matched exactly) is what that note verifies, so prose naming the
158
+ * successor later still verifies it while a later mention of another target doesn't (#2841).
142
159
  * Read from the ACTIVE table AND the retention archive: the daily archiver MOVES every
143
160
  * transition of an aged terminal qitem into `queue_transitions_archive` (the exact class
144
161
  * custody rows belong to) while the row itself keeps participating in this sweep, so an
@@ -146,7 +163,7 @@ export { resolveSessionNodeId, defaultResolveOrchestrator, resolveOperatorSeat }
146
163
  * the very finding the verifier already answered. The archive is never deleted, so the
147
164
  * union is the complete audit history. */
148
165
  export const CUSTODY_VERIFIED_PREFIX = "custody-verified:";
149
- function custodyVerifiedTargets(db, qitemId) {
166
+ function custodyVerifiedTargets(db, qitemId, targets) {
150
167
  const notes = db
151
168
  .prepare(`SELECT transition_note FROM queue_transitions WHERE qitem_id = ? AND transition_note LIKE ?
152
169
  UNION ALL
@@ -156,13 +173,13 @@ function custodyVerifiedTargets(db, qitemId) {
156
173
  for (const { transition_note: note } of notes) {
157
174
  if (!note)
158
175
  continue;
159
- const token = note.slice(CUSTODY_VERIFIED_PREFIX.length).trim().split(/\s+/)[0];
160
- if (token) {
161
- verified.add(token);
162
- for (const t of token.split(",")) {
163
- if (t.trim())
164
- verified.add(t.trim());
165
- }
176
+ for (const token of note.slice(CUSTODY_VERIFIED_PREFIX.length).trim().split(/\s+/)) {
177
+ const named = [token, ...token.split(",").map((t) => t.trim())].filter(Boolean);
178
+ if (!named.some((t) => targets.includes(t)))
179
+ continue;
180
+ for (const t of named)
181
+ verified.add(t);
182
+ break;
166
183
  }
167
184
  }
168
185
  return verified;
@@ -295,7 +312,7 @@ function legacyHumanRecipientRetained(deps, row) {
295
312
  * source's receipts and dispositions before closing an existing finding; an
296
313
  * unavailable source or an unconfirmed send supplies no resolution evidence. */
297
314
  function deliveryResolutionEvidence(deps, kind, qitemId, now) {
298
- const row = deps.queueRepo.getById(qitemId);
315
+ const row = deps.queueRepo.getById(qitemId, { waiting: false });
299
316
  if (!row)
300
317
  return null;
301
318
  if (["done", "failed", "denied", "canceled", "handed-off"].includes(row.state)) {
@@ -389,7 +406,8 @@ export function custodyHeadline(rowId, targets, ageMinutes) {
389
406
  function evidenceBody(db, c) {
390
407
  if (c.verificationTargets?.length) {
391
408
  const checks = c.verificationTargets
392
- .map((target) => `- ${target}\n ${verificationCommand(target)}`)
409
+ .map((target) => `- ${target}\n ${verificationCommand(target)}\n` +
410
+ ` rig queue update ${c.row.qitemId} --note "custody-verified: ${target} <how verified>"`)
393
411
  .join("\n");
394
412
  return (`STUCK SWEEP FINDING (successor-verification-required)\n` +
395
413
  `row: ${c.row.qitemId}\n` +
@@ -397,10 +415,11 @@ function evidenceBody(db, c) {
397
415
  `age: ${c.ageMinutes} min\n` +
398
416
  `last transition: ${lastTransitionLine(db, c.row.qitemId)}\n` +
399
417
  `why: ${c.why}\n` +
400
- `verification targets (indeterminate until checked on the registered host):\n${checks}\n` +
401
- `After a registered-host read confirms a target, record it durably on the closed row so the sweep stops asking:\n` +
402
- ` rig queue update ${c.row.qitemId} --note "custody-verified: <target> <how verified>"\n` +
403
- `Do not rewrite historical custody from this local observation; record the verification result separately.`);
418
+ `verification targets (indeterminate until checked on the registered host), each with its check and its note:\n${checks}\n` +
419
+ `After a registered-host read confirms a target, record its note on the closed row so the sweep stops asking. ` +
420
+ `The note starts with "custody-verified:"; its first word that names one of these targets exactly is what it verifies. ` +
421
+ `Name several in one comma-list word (a,b), or write one note each.\n` +
422
+ `Do not rewrite historical custody from this local observation; the note is the separate record of the verification.`);
404
423
  }
405
424
  return (`STUCK SWEEP FINDING (${c.kind})\n` +
406
425
  `row: ${c.row.qitemId}\n` +
@@ -410,17 +429,139 @@ function evidenceBody(db, c) {
410
429
  `why: ${c.why}\n` +
411
430
  `Resolve the underlying row; the sweep closes this finding itself once the row is no longer stuck.`);
412
431
  }
432
+ /** The last line of a standing notice's body: every row it stands for, so the sweep knows what it covered. */
433
+ const BACKLOG_ROWS_PREFIX = "Every row this notice stands for: ";
434
+ /** A standing notice's row lines: oldest first, the first ones by id, the rest counted. */
435
+ function backlogListing(rows) {
436
+ const sorted = [...rows].sort((a, b) => a.since.localeCompare(b.since) || a.qitemId.localeCompare(b.qitemId));
437
+ const listed = sorted.slice(0, UNCLAIMED_BACKLOG_LISTED_ROWS).map((r) => {
438
+ const about = r.summary ? `: ${r.summary.replace(/\s+/g, " ").trim().slice(0, 120)}` : "";
439
+ return `- ${r.qitemId}, unclaimed since ${r.since}, from ${r.from}${about}`;
440
+ });
441
+ if (sorted.length > listed.length)
442
+ listed.push(`- and ${sorted.length - listed.length} more`);
443
+ return { sorted, listed, count: `${rows.length} ${rows.length === 1 ? "row" : "rows"}` };
444
+ }
445
+ /** A seat's standing unclaimed-backlog notice: its rows by id, how to list them, and how to send their findings to a seat
446
+ * that watches this one. Built only from the rows' fixed facts, so a pass rewrites it only when the rows change. */
447
+ function unclaimedBacklogText(seat, rows, thresholdMinutes, node) {
448
+ const { sorted, listed, count } = backlogListing(rows);
449
+ const edge = node ? `rig edge add ${node.rig} ${node.logicalId} <watching seat> --kind escalates_to` : "an escalates_to edge from this seat";
450
+ return {
451
+ summary: `Stuck sweep: unclaimed-backlog on ${seat} (${count})`,
452
+ body: `STUCK SWEEP FINDING (unclaimed-backlog)\n` +
453
+ `seat: ${seat}\n` +
454
+ `unclaimed: ${count} (the threshold is ${thresholdMinutes} min)\n` +
455
+ `${listed.join("\n")}\n` +
456
+ `why: nobody has claimed these rows, and this seat has no delegation parent and no escalates_to route, so this one ` +
457
+ `notice stands for them instead of a finding per row. It follows the rows as they come and go.\n` +
458
+ `List them: rig queue list --destination ${seat} --state pending\n` +
459
+ `To send these findings to a seat that watches this one, one finding per row: ${edge}\n` +
460
+ `The sweep closes this notice itself once every row it stands for is claimed, parked or closed.\n` +
461
+ `${BACKLOG_ROWS_PREFIX}${JSON.stringify(sorted.map((r) => r.qitemId))}`,
462
+ };
463
+ }
464
+ /** A polling hosted member's standing notice: whether it's checking in (its own inbox reads), the rows it hasn't claimed,
465
+ * and what to do. Its work's age runs from each row's own time, which a check-in never resets. Built from the rows' fixed
466
+ * facts and the member's check-in state, never a current check-in's exact time, so a pass rewrites it only when the rows
467
+ * or that state change. */
468
+ function polledBacklogText(member, rows, thresholdMinutes, checkIn, now) {
469
+ const { sorted, listed, count } = backlogListing(rows);
470
+ const recent = checkIn.state === "seen" && now.getTime() - Date.parse(checkIn.at) <= thresholdMinutes * 60_000;
471
+ const checkIns = recent
472
+ ? `checking in: it read its own inbox within the last ${thresholdMinutes} min`
473
+ : checkIn.state === "seen"
474
+ ? `no check-in observed since ${checkIn.at}`
475
+ : checkIn.state === "never" ? "no check-in observed yet" : "unknown: its check-ins couldn't be read";
476
+ const why = recent
477
+ ? "it's checking in, but this work is still unclaimed. Check whether it can do this work, or route it to another seat"
478
+ : checkIn.state === "unknown"
479
+ ? "nobody has claimed these rows, and whether it's reading its queue isn't known. Ask its owner, or route the work to another seat"
480
+ : "nobody has claimed these rows, and no read of its own inbox has been observed in that time. Ask its owner to check it's running, or route the work to another seat";
481
+ return {
482
+ summary: `Stuck sweep: unclaimed-backlog on ${member} (${count})`,
483
+ body: `STUCK SWEEP FINDING (unclaimed-backlog)\n` +
484
+ `member: ${member} (a hosted member with no wake trigger: it picks up work when it reads its own queue)\n` +
485
+ `check-ins: ${checkIns}\n` +
486
+ `unclaimed: ${count} (the threshold is ${thresholdMinutes} min)\n` +
487
+ `${listed.join("\n")}\n` +
488
+ `why: ${why}. This one notice stands for these rows instead of a finding per row, and follows them as they come and go.\n` +
489
+ `List them: rig queue list --destination ${member} --state pending\n` +
490
+ `The sweep closes this notice itself once every row it stands for is claimed, parked or closed.\n` +
491
+ `${BACKLOG_ROWS_PREFIX}${JSON.stringify(sorted.map((r) => r.qitemId))}`,
492
+ };
493
+ }
494
+ /** The rows a standing notice's body says it stands for, or null when the line is missing or unreadable: unknown, which is
495
+ * never read as "none". */
496
+ function backlogRowsOf(body) {
497
+ const line = body.split("\n").reverse().find((l) => l.startsWith(BACKLOG_ROWS_PREFIX));
498
+ if (!line)
499
+ return null;
500
+ try {
501
+ const ids = JSON.parse(line.slice(BACKLOG_ROWS_PREFIX.length));
502
+ return Array.isArray(ids) ? new Set(ids.filter((id) => typeof id === "string")) : null;
503
+ }
504
+ catch {
505
+ return null;
506
+ }
507
+ }
508
+ /** What a pass hands the status: the findings it created (the routed total grows only by these), and the finding
509
+ * rows still open after it. Open is read from the queue, not from the pass's actions: a finding kept open without an
510
+ * action (a live ladder suppresses its reporting, a grace holds it) is still open. */
511
+ function findingCounts(db, findings) {
512
+ const open = db.prepare(`SELECT COUNT(*) AS n FROM queue_items WHERE state IN ('pending', 'in-progress', 'blocked')
513
+ AND tags LIKE ?`).get(`%"${STUCK_SWEEP_FINDING_TAG}"%`);
514
+ return { created: findings.filter((f) => f.action === "created").length, open: open.n };
515
+ }
413
516
  /**
414
517
  * One sweep pass. Instance-wide (no rig scope — the loop is the net for every rig the
415
518
  * daemon carries). Never throws: a sweep that cannot run reports outcome=failed loudly
416
519
  * on the status surface and the log, because a silent skip is exactly the class this
417
520
  * slice exists to kill.
418
521
  */
522
+ /** Rows a sweep pass handles between two yields of the event loop. A pass over a large queue used to hold the loop
523
+ * for its whole length (seconds on a queue of tens of thousands of rows, with healthz and every request waiting);
524
+ * every this many rows it now lets timers and requests run. */
525
+ export const STUCK_SWEEP_YIELD_EVERY_ROWS = 50;
526
+ /** ...or after this many milliseconds of work since the last yield, whichever comes first: a stretch of slow rows (or
527
+ * of awaited writes that resolve by microtasks alone) holds the loop no longer than this. The clock restarts after the
528
+ * yield, so the time others run during it does not count against the next stretch. */
529
+ export const STUCK_SWEEP_YIELD_AFTER_MS = 50;
419
530
  export async function runStuckSweep(deps) {
420
531
  const log = deps.log ?? ((line) => console.error(line));
421
532
  const status = deps.status;
422
533
  try {
423
534
  const now = deps.now ?? new Date();
535
+ // One recovery index and one linked-successor read per stretch of the pass, instead of one json_each scan per
536
+ // candidate and per custody row. Each is a snapshot that is only valid while no other code runs, so both are
537
+ // dropped (and rebuilt on the next lookup) after every yield and every awaited write.
538
+ const recoveries = createRecoveryLookup(deps.db);
539
+ let successors = null;
540
+ // Every yield and every awaited write lets other code run: indexes read before it are dropped, and `othersRan`
541
+ // tells a list read before it that its rows need a fresh read.
542
+ let othersRan = 0;
543
+ const othersMayHaveRun = () => { othersRan++; recoveries.invalidate(); successors?.invalidate(); };
544
+ // A successor index whose build took at least half of a stretch that yielded by elapsed time is not rebuilt for
545
+ // the rest of the pass: the yield drops it, the next stretch would pay the build again and end the same way after a
546
+ // few rows, so the rows would pay about one build each instead of one per STUCK_SWEEP_YIELD_EVERY_ROWS. Those rows
547
+ // ask their own narrow query (hasLinkedSuccessor), which costs less than a rebuilt index.
548
+ let successorsPerRow = false;
549
+ // A synchronous read with both indexes lent to what it calls deep inside (a getById's waiting view and handoff
550
+ // advisory ask the same questions per row). Never spans an await: the lend ends when fn returns.
551
+ const indexed = (fn) => recoveries.run(() => (successors && !successorsPerRow ? successors.run(fn) : fn()));
552
+ // `if (dueToYield()) await yieldLoop();` and never a bare await per row: even an await that does not yield lets
553
+ // queued microtasks (other requests' continuations) run and write between two rows the snapshot still covers.
554
+ let rowsSinceYield = 0;
555
+ let lastYieldAt = performance.now();
556
+ const dueToYield = () => ++rowsSinceYield >= STUCK_SWEEP_YIELD_EVERY_ROWS || performance.now() - lastYieldAt >= STUCK_SWEEP_YIELD_AFTER_MS;
557
+ const yieldLoop = async () => {
558
+ const stretchMs = performance.now() - lastYieldAt;
559
+ successorsPerRow ||= successors !== null && stretchMs >= STUCK_SWEEP_YIELD_AFTER_MS && 2 * successors.builtMs() >= stretchMs;
560
+ rowsSinceYield = 0;
561
+ await new Promise((resolve) => setImmediate(resolve));
562
+ lastYieldAt = performance.now();
563
+ othersMayHaveRun();
564
+ };
424
565
  const suppressionMinutes = deps.ladderSuppressionMinutes ?? resolveLadderSuppressionMinutes();
425
566
  /** The dedup tags of the candidates the LADDER suppressed in this pass, and only those:
426
567
  * a row the ladder alone would have stopped. A finding for such a row stays open,
@@ -446,42 +587,42 @@ export async function runStuckSweep(deps) {
446
587
  };
447
588
  const isRegisteredHost = deps.isRegisteredHost ?? defaultIsRegisteredHost(log);
448
589
  const candidates = [];
590
+ const nowIso = now.toISOString();
591
+ // SQLite's LIKE ignores ASCII case; the per-row rules below match the queries they stand in for.
592
+ const startsWithCI = (value, prefix) => (value ?? "").toLowerCase().startsWith(prefix);
593
+ // Each kind's rule for ONE row, applied to the row as it is now. The loops below enumerate the rows; the same
594
+ // rules run again on a fresh read right before a finding is created (stillStuck), because a pass that yields
595
+ // cannot trust what it read before the yield: a claim, a delivered wake, a moved deadline, a note or a new
596
+ // successor may have landed since.
449
597
  // Half 1 — claimed-never-closed. The claimant holds the obligation; the finding
450
598
  // routes to them.
451
- for (const row of deps.queueRepo.findOverdue({ now: now.toISOString() })) {
599
+ const overdueCandidate = (row) => {
452
600
  if (isFindingRow(row))
453
- continue;
454
- candidates.push({
601
+ return null;
602
+ return {
455
603
  kind: "overdue-claim",
456
604
  row,
457
605
  route: row.destinationSession,
458
606
  ageMinutes: minutesSince(row.closureRequiredAt ?? row.claimedAt, now),
459
607
  evidenceAt: latestIso(lastMeaningfulTransition(deps.db, row.qitemId)?.at, row.closureRequiredAt, row.claimedAt),
460
608
  why: "claimed and past closure_required_at with no closure",
461
- });
462
- try {
463
- deps.queueRepo.recordClosureOverdue(row.qitemId, { now: now.toISOString() });
464
- }
465
- catch (err) {
466
- log(`[stuck-sweep] failed to record closure-overdue for ${row.qitemId}: ${err instanceof Error ? err.message : String(err)}`);
467
- }
468
- }
609
+ };
610
+ };
469
611
  // S04 seam — a claimed row with no later motion past the pickup threshold. The
470
- // pickup module remains the ONE derivation rule; this loop only enumerates and routes.
471
- const claimedRows = deps.db
472
- .prepare("SELECT qitem_id FROM queue_items WHERE state IN ('pending', 'in-progress') AND claimed_at IS NOT NULL")
473
- .all();
474
- for (const { qitem_id } of claimedRows) {
475
- const row = deps.queueRepo.getById(qitem_id);
612
+ // pickup module remains the ONE derivation rule; this only enumerates and routes.
613
+ const stalledCandidate = (qitemId) => {
614
+ const row = indexed(() => deps.queueRepo.getById(qitemId, { waiting: false }));
476
615
  if (!row || isFindingRow(row))
477
- continue;
616
+ return null;
617
+ if ((row.state !== "pending" && row.state !== "in-progress") || !row.claimedAt)
618
+ return null;
478
619
  const stalled = stalledPickupFinding(row);
479
620
  if (!stalled)
480
- continue;
621
+ return null;
481
622
  // Keep this null arm for the 0.5.7 mechanized-pull turn-end hook that knows the in-flight row;
482
623
  // it is the first honest row-scoped writer, and wiring reopens only in that slice.
483
624
  const evidenceAt = latestIso(lastMeaningfulTransition(deps.db, row.qitemId)?.at, row.lastHeartbeat, row.claimedAt);
484
- candidates.push({
625
+ return {
485
626
  kind: stalled.kind,
486
627
  row,
487
628
  route: resolveOrch(stalled.target, row) ?? stalled.target,
@@ -490,102 +631,122 @@ export async function runStuckSweep(deps) {
490
631
  ageMinutes: wholeMinutesSince(evidenceAt, now),
491
632
  evidenceAt,
492
633
  why: stalled.evidence,
493
- });
494
- }
634
+ };
635
+ };
495
636
  // The timer delivered one transition-specific notice (or recorded a failed
496
637
  // attempt). This existing sweep owns its bounded recovery, not another full
497
638
  // packet or a parked-owner replay. A real owner response ends the occurrence.
498
- const waitJobs = deps.db.prepare("SELECT job_id, spec_yaml FROM watchdog_jobs WHERE state = 'active' AND policy = 'periodic-reminder'").all();
499
- for (const job of waitJobs) {
500
- const notice = queueWaitNotice(job.spec_yaml);
639
+ const waitCandidate = (jobId) => {
640
+ const job = deps.db.prepare("SELECT spec_yaml FROM watchdog_jobs WHERE job_id = ? AND state = 'active' AND policy = 'periodic-reminder'")
641
+ .get(jobId);
642
+ const notice = job ? queueWaitNotice(job.spec_yaml) : null;
501
643
  if (!notice || now.getTime() - Date.parse(notice.at) <= resolvePickupThresholdMinutes() * 60_000)
502
- continue;
503
- const binding = deps.db.prepare("SELECT qitem_id FROM queue_transition_wakes WHERE wake_ref = ? AND phase = 'armed' ORDER BY transition_id DESC LIMIT 1").get(job.job_id);
504
- const row = binding ? deps.queueRepo.getById(binding.qitem_id) : null;
505
- if (!row || row.state !== "blocked" || deps.queueRepo.getParkWakeStatus(row.qitemId)?.ref !== job.job_id)
506
- continue;
644
+ return null;
645
+ const binding = deps.db.prepare("SELECT qitem_id FROM queue_transition_wakes WHERE wake_ref = ? AND phase = 'armed' ORDER BY transition_id DESC LIMIT 1").get(jobId);
646
+ const row = binding ? indexed(() => deps.queueRepo.getById(binding.qitem_id, { waiting: false })) : null;
647
+ if (!row || row.state !== "blocked" || deps.queueRepo.getParkWakeStatus(row.qitemId)?.ref !== jobId)
648
+ return null;
507
649
  const response = lastMeaningfulTransition(deps.db, row.qitemId);
508
650
  if (response && Date.parse(response.at) > Date.parse(notice.at))
509
- continue;
651
+ return null;
510
652
  const ownerActivity = deps.queueRepo.ownerActivity(row.destinationSession);
511
653
  if (ownerActivity?.activity === "working" && !ownerActivity.needsInput.count && notice.deliveryStatus === "ok")
512
- continue;
513
- candidates.push({ kind: "unconsumed-wait", row, route: resolveOrch(row.destinationSession, row) ?? row.sourceSession,
514
- ageMinutes: minutesSince(notice.at, now), evidenceAt: notice.at,
515
- why: `wait notice delivery=${notice.deliveryStatus}; no later owner response; activity=${ownerActivity?.activity ?? "unknown"}; inspect exact blocker ${row.blockedOn}` });
516
- }
654
+ return null;
655
+ return { kind: "unconsumed-wait", row, route: resolveOrch(row.destinationSession, row) ?? row.sourceSession,
656
+ ageMinutes: minutesSince(notice.at, now), evidenceAt: notice.at, jobId,
657
+ why: `wait notice delivery=${notice.deliveryStatus}; no later owner response; activity=${ownerActivity?.activity ?? "unknown"}; inspect exact blocker ${row.blockedOn}` };
658
+ };
517
659
  // The parked policy stops repeating a positively no-input failure. Unhealthy blocked rows
518
660
  // have no retry ladder: the same sweep/recovery route owns their actionable disposition.
519
- const blockedFailures = deps.db.prepare("SELECT qitem_id FROM queue_items WHERE state='blocked' AND last_nudge_result LIKE 'failed:%'").all();
520
- for (const { qitem_id } of blockedFailures) {
521
- const row = deps.queueRepo.getById(qitem_id);
661
+ const parkedCandidate = (qitemId) => {
662
+ const row = indexed(() => deps.queueRepo.getById(qitemId, { waiting: false }));
522
663
  if (!row || isFindingRow(row))
523
- continue;
524
- const wake = deps.queueRepo.getParkWakeStatus(qitem_id);
664
+ return null;
665
+ if (row.state !== "blocked" || !startsWithCI(row.lastNudgeResult, "failed:"))
666
+ return null;
667
+ const wake = deps.queueRepo.getParkWakeStatus(qitemId);
525
668
  if ((wake?.live === true && (!wake.unconsumed || wake.recoveryOwner === "queue-stuck-sweep"))
526
- || deps.queueRepo.parkWakeServedByOwnReminder(qitem_id))
527
- continue;
528
- const transitions = deps.queueRepo.listTransitions(qitem_id);
669
+ || deps.queueRepo.parkWakeServedByOwnReminder(qitemId))
670
+ return null;
671
+ const transitions = deps.queueRepo.listTransitions(qitemId);
529
672
  const failure = currentParkedOwnerNoInputFailure(transitions);
530
673
  if (!failure)
531
- continue;
674
+ return null;
532
675
  // Another seat's incidental note is not the owner's response. This kind follows
533
676
  // the parked policy's owner-or-state-change rule, leaving other sweep kinds alone.
534
677
  if (transitions.some((t, i) => t.transitionId > (failure.transitionId ?? Number.POSITIVE_INFINITY)
535
678
  && (t.actorSession === row.destinationSession || t.state !== transitions[i - 1]?.state)))
536
- continue;
537
- candidates.push({ kind: "parked-owner-no-input", row, route: resolveOrch(row.destinationSession, row) ?? row.sourceSession,
679
+ return null;
680
+ return { kind: "parked-owner-no-input", row, route: resolveOrch(row.destinationSession, row) ?? row.sourceSession,
538
681
  ageMinutes: minutesSince(failure.ts, now), evidenceAt: failure.ts,
539
- why: `Automated parked-owner reminder refused before input (${failure.code}); repeated input stopped. Inspect the retained quota/guard or route terminal work to an agent. Original blocker remains ${row.blockedOn}` });
540
- }
682
+ why: `Automated parked-owner reminder refused before input (${failure.code}); repeated input stopped. Inspect the retained quota/guard or route terminal work to an agent. Original blocker remains ${row.blockedOn}` };
683
+ };
541
684
  // Half 2 — sender-believed-delivered-never-woken. Nobody holds it (the wake failed),
542
685
  // so it routes to the destination's orchestrator when one is derivable. Rows with a
543
686
  // live S01 ladder are S01's territory; an exhausted ladder is the handback and lands
544
687
  // here exactly once (the dedup tag keeps it to one finding).
545
- for (const row of deps.queueRepo.findUndelivered()) {
688
+ // A wake recorded unroutable because the seat's pane wasn't bound yet (#2151). Once its binding exists, deliver the
689
+ // row's own wake intent instead of reporting it: the intent is claimed and settled, so a startup drain doesn't send it
690
+ // again, and one already in flight or settled isn't sent twice. The next tick reads the new result, so a failed send
691
+ // is reported then. A row with a live retry ladder is left to the ladder.
692
+ // The rule is shared with the reachable-seat retry; a live retry ladder is this sweep's own check.
693
+ const wakeToRetry = (row) => deps.queueRepo.unroutableWakeRetryable(row, now)
694
+ && !hasLiveLadder(deps.db, row.qitemId, now, suppressionMinutes);
695
+ const isHumanNotice = (row) => row.deliveryOutcome === "never-posted" || row.deliveryOutcome === "transport-failed";
696
+ // A hosted member with no wake trigger picks up its work by reading the queue: nothing can push work to it, by design.
697
+ // Its rows' unroutable wakes aren't failed deliveries, so they get no finding each; work it leaves unclaimed past the
698
+ // unclaimed age is listed in the member's one standing notice instead. Read once per member per pass.
699
+ const pollingMembers = new Map();
700
+ const pollsForWork = (session) => {
701
+ let polls = pollingMembers.get(session);
702
+ if (polls === undefined) {
703
+ polls = deps.queueRepo.isHostedMember(session) && deps.queueRepo.classifyDestinationOf(session).class === "unroutable";
704
+ pollingMembers.set(session, polls);
705
+ }
706
+ return polls;
707
+ };
708
+ const polledRow = (row) => !!row.lastNudgeResult?.startsWith("unroutable:") && pollsForWork(row.destinationSession);
709
+ /** `row` comes from findUndelivered (it carries the delivery verdict). Call it after any wake retry the row needs. */
710
+ const undeliveredCandidate = (row, recordSuppression) => {
546
711
  if (isFindingRow(row))
547
- continue;
548
- const humanNotice = row.deliveryOutcome === "never-posted" || row.deliveryOutcome === "transport-failed";
712
+ return null;
713
+ const humanNotice = isHumanNotice(row);
549
714
  // A claim supersedes a retained failed wake, including on a row returned to
550
715
  // pending. Its pickup finding must not be replaced by that historical failure;
551
716
  // a separate human notification still needs its own delivery evidence.
552
717
  if (!humanNotice && row.claimedAt)
553
- continue;
718
+ return null;
554
719
  if (!humanNotice && deps.queueRepo.isLocalHumanDecisionWithoutGateway(row))
555
- continue;
720
+ return null;
721
+ if (!humanNotice && polledRow(row))
722
+ return null;
556
723
  const notification = humanNotice ? deps.queueRepo.transitionLog.latestOwnerNotificationForQitem(row.qitemId) : null;
557
724
  const resolutionNotice = notification?.ownerNotificationKind === "human-decision-resolved";
558
725
  // Match the notification source in slack/queue-access.ts, not the agent wake's escalator.
559
726
  const noticeOwner = row.state === "blocked" || resolutionNotice ? row.destinationSession : row.sourceSession;
560
727
  const noticeRecipient = resolutionNotice ? notification.actorSession : row.state === "blocked" ? row.blockedOn : row.destinationSession;
561
- const failure = humanNotice
562
- ? `human notice ${row.deliveryOutcome} to ${noticeRecipient}: ${row.deliveryFailureDetail}`
563
- : `wake failed (${row.lastNudgeResult ?? "failed"})`;
728
+ // Slack answered 2xx but its body couldn't be read (slack-delivery's POSSIBLY_POSTED_CLASS): it may be in Slack.
729
+ const possiblyPosted = humanNotice && /\bclass=possibly-posted\b/.test(row.deliveryFailureDetail ?? "");
730
+ const failure = possiblyPosted
731
+ ? `human notice may have posted to ${noticeRecipient}: Slack answered but its reply couldn't be read (${row.deliveryFailureDetail}); the gateway checks Slack for its marker before any resend`
732
+ : humanNotice
733
+ ? `human notice ${row.deliveryOutcome} to ${noticeRecipient}: ${row.deliveryFailureDetail}`
734
+ : `wake failed (${row.lastNudgeResult ?? "failed"})`;
564
735
  // Quiet hours: a held, turned-back or released ask belongs to its window's release job, so a failed wake, or a post
565
736
  // not yet made, isn't "nothing retried it". A release whose post failed is a failed delivery, and a hold with no
566
737
  // live release job is orphaned: both stay findings, with their own reason.
567
738
  const quiet = quietHoldCustody(deps.db, row.qitemId, now);
568
739
  if (quiet && (quiet.state === "held" || quiet.state === "released"))
569
- continue;
570
- // A wake recorded unroutable because the seat's pane wasn't bound yet (#2151). Once its binding exists, deliver the
571
- // row's own wake intent instead of reporting it: the intent is claimed and settled, so a startup drain doesn't send it
572
- // again, and one already in flight or settled isn't sent twice. The next tick reads the new result, so a failed send
573
- // is reported then. A row with a live retry ladder is left to the ladder.
574
- if (!humanNotice && row.lastNudgeResult?.startsWith("unroutable:")
575
- && !hasLiveLadder(deps.db, row.qitemId, now, suppressionMinutes)
576
- && deps.queueRepo.classifyDestinationOf(row.destinationSession).class === "pane-bound") {
577
- await deps.queueRepo.deliverWakeForSuccessor(row.qitemId, row.destinationSession, true, row.sourceSession);
578
- if (!deps.queueRepo.getById(row.qitemId)?.lastNudgeResult?.startsWith("unroutable:"))
579
- continue;
580
- }
740
+ return null;
581
741
  // The ladder check runs LAST, so only a row the ladder ALONE would have stopped counts
582
742
  // as ladder-suppressed (#1419). Agent wake retries do not own the separate notice to a
583
743
  // person: a human notice is never the ladder's to suppress.
584
744
  if (!humanNotice && hasLiveLadder(deps.db, row.qitemId, now, suppressionMinutes)) {
585
- suppressedTags.add(findingDedupTag("undelivered-wake", row.qitemId));
586
- continue;
745
+ if (recordSuppression)
746
+ suppressedTags.add(findingDedupTag("undelivered-wake", row.qitemId));
747
+ return null;
587
748
  }
588
- candidates.push({
749
+ return {
589
750
  kind: humanNotice ? "undelivered-human-notice" : "undelivered-wake",
590
751
  row,
591
752
  route: humanNotice ? noticeOwner : resolveOrch(row.destinationSession, row) ?? row.destinationSession,
@@ -598,58 +759,56 @@ export async function runStuckSweep(deps) {
598
759
  : humanNotice
599
760
  ? `${failure}; check human-notification delivery rather than retrying the agent wake`
600
761
  : `${failure} and nothing retried it`,
601
- });
602
- }
762
+ };
763
+ };
764
+ const undeliveredNow = (qitemId) => indexed(() => deps.queueRepo.findUndelivered({ qitemId, waiting: false }))[0];
603
765
  // The A1 net — created-with-destination rows carrying real obligations, unclaimed past
604
766
  // the config-keyed age. Parks (state=blocked) legitimately wait and never appear here;
605
767
  // failed-nudge rows already surfaced in half 2; laddered rows are S01's.
606
768
  const cutoff = new Date(now.getTime() - ageMinutes * 60_000).toISOString();
607
- const unclaimedRows = deps.db
608
- .prepare(`SELECT qitem_id FROM queue_items
609
- WHERE state = 'pending'
610
- AND claimed_at IS NULL
611
- AND destination_session IS NOT NULL AND destination_session != ''
612
- AND ts_created <= ?
613
- AND (last_nudge_result IS NULL OR last_nudge_result NOT LIKE 'failed:%')`)
614
- .all(cutoff);
615
- for (const { qitem_id } of unclaimedRows) {
616
- const row = deps.queueRepo.getById(qitem_id);
769
+ const unclaimedCandidate = (qitemId, recordSuppression) => {
770
+ const row = indexed(() => deps.queueRepo.getById(qitemId, { waiting: false }));
617
771
  if (!row || isFindingRow(row))
618
- continue;
772
+ return null;
773
+ // The query's own predicate, on the row as it is now.
774
+ if (row.state !== "pending" || row.claimedAt || !row.destinationSession || row.tsCreated > cutoff
775
+ || startsWithCI(row.lastNudgeResult, "failed:"))
776
+ return null;
619
777
  if (deps.queueRepo.isLocalHumanDecisionWithoutGateway(row))
620
- continue;
778
+ return null;
621
779
  const actionableAt = pendingSince(deps.db, row.qitemId) ?? row.tsCreated;
622
780
  if (actionableAt > cutoff)
623
- continue;
781
+ return null;
624
782
  // #514 — an ask already posted to its registered human in the current delivery episode waits on
625
783
  // that human; it is not stuck, and a finding would post the human again. Unposted, failed,
626
784
  // legacy and non-human rows keep this net.
627
785
  if (deps.queueRepo.humanNotificationPostedThisEpisode(row.qitemId))
628
- continue;
786
+ return null;
629
787
  // An ask placed on Steering without an alert waits on its person there by design; a finding would alert them.
630
788
  if (deps.queueRepo.humanAskWithoutAlert(row.qitemId))
631
- continue;
789
+ return null;
632
790
  // Quiet hours: a held ask whose window's release job is live waits on that job, and one already released waits on
633
791
  // its post; neither is stuck. A release whose post failed is reported once, by the undelivered-wake loop above. A
634
792
  // hold with no live release job is stuck: nothing will ever release it.
635
793
  const quiet = quietHoldCustody(deps.db, row.qitemId, now);
636
794
  if (quiet && quiet.state !== "orphaned")
637
- continue;
795
+ return null;
638
796
  // An explicit informational update to a currently registered human is for reading, not an obligation to claim,
639
797
  // unless its quiet-hours hold has been orphaned before release.
640
798
  if (!quiet && deps.queueRepo.isRegisteredHumanUpdate(row))
641
- continue;
799
+ return null;
642
800
  // The seat's typing guard or interruption level held its wake on purpose: it's held and readable at the seat, not
643
801
  // stuck. (A handed-off baton's one held notice is the wake ladder's.)
644
802
  if (row.lastNudgeResult === "retained:typing_guard")
645
- continue;
803
+ return null;
646
804
  // The ladder check runs LAST here too: a row the ladder alone would have stopped is
647
805
  // ladder-suppressed, and its finding stays open (#1419).
648
806
  if (hasLiveLadder(deps.db, row.qitemId, now, suppressionMinutes)) {
649
- suppressedTags.add(findingDedupTag("unclaimed-obligation", row.qitemId));
650
- continue;
807
+ if (recordSuppression)
808
+ suppressedTags.add(findingDedupTag("unclaimed-obligation", row.qitemId));
809
+ return null;
651
810
  }
652
- candidates.push({
811
+ return {
653
812
  kind: "unclaimed-obligation",
654
813
  row,
655
814
  route: resolveOrch(row.destinationSession, row) ?? row.destinationSession,
@@ -657,8 +816,23 @@ export async function runStuckSweep(deps) {
657
816
  evidenceAt: actionableAt,
658
817
  why: quiet?.state === "orphaned"
659
818
  ? `held for quiet hours (window ${quiet.windowId}) for ${minutesSince(actionableAt, now)} min, but no release job is live for that window: nothing will release it`
660
- : `actionable with a destination and unclaimed for ${minutesSince(actionableAt, now)} min (threshold ${ageMinutes})`,
661
- });
819
+ : `actionable with a destination and unclaimed for ${minutesSince(actionableAt, now)} min (threshold ${ageMinutes})${unreadableOwner(row.destinationSession) ? "; owner activity unknown (can't read the seat)" : ""}`,
820
+ };
821
+ };
822
+ /** The seat's activity can't be read (no reading, or one that reads unknown): said in the finding, so an unreadable
823
+ * seat isn't taken for one ignoring its work. The stalled finding says the same (`queue-pickup.ts`). A person has no
824
+ * seat to read, so their row never says so; nor does a row whose destination can't be classified, since it may be a
825
+ * person's. A classification fault never stops the sweep. */
826
+ function unreadableOwner(session) {
827
+ try {
828
+ if (deps.queueRepo.isHumanDestination(session))
829
+ return false;
830
+ }
831
+ catch {
832
+ return false;
833
+ }
834
+ const activity = deps.queueRepo.ownerActivity(session)?.activity;
835
+ return !activity || activity === "unknown";
662
836
  }
663
837
  // The custody class — a terminal row whose closure names one or more successor
664
838
  // qitems or seat-address targets (closure_reason = 'handed_off_to'). A local miss is
@@ -682,48 +856,21 @@ export async function runStuckSweep(deps) {
682
856
  // owner, so skip only recorded handoffs whose current target still matches (#341).
683
857
  // Closures outside the recent 24-hour window without open findings are skipped so upgrading
684
858
  // a real queue history does not raise a flood of historical findings.
685
- const custodyHours = deps.custodyWindowHours ?? STUCK_SWEEP_CUSTODY_WINDOW_HOURS;
686
- const custodyCutoff = new Date(now.getTime() - custodyHours * 3_600_000).toISOString();
687
- const openDanglingIds = [];
688
- const danglingPrefix = "stuck-sweep:dangling-closure:";
689
- for (const { tags } of deps.db
690
- .prepare(`SELECT tags FROM queue_items WHERE state IN ('pending', 'in-progress', 'blocked') AND tags LIKE ?`)
691
- .all(`%"${danglingPrefix}%`)) {
692
- try {
693
- for (const tag of JSON.parse(tags)) {
694
- if (tag.startsWith(danglingPrefix)) {
695
- openDanglingIds.push(tag.slice(danglingPrefix.length));
696
- }
697
- }
698
- }
699
- catch {
700
- // Skip malformed tags
701
- }
702
- }
703
- const custodyRows = deps.db
704
- .prepare(
705
- // Bound candidates before checking state: including handed-off in the
706
- // state index scan would otherwise revisit all historical atomic handoffs.
707
- `WITH custody_candidates AS MATERIALIZED (
708
- SELECT qitem_id, state, handed_off_to, closure_target, closure_reason
709
- FROM queue_items WHERE ts_updated >= ?
710
- UNION
711
- SELECT qitem_id, state, handed_off_to, closure_target, closure_reason
712
- FROM queue_items WHERE qitem_id IN (SELECT value FROM json_each(?))
713
- )
714
- SELECT q.qitem_id FROM custody_candidates q
715
- WHERE (q.state IN ('done', 'canceled') OR (q.state = 'handed-off'
716
- AND (q.handed_off_to IS NULL OR q.closure_target IS NOT q.handed_off_to)))
717
- AND (q.closure_target LIKE 'qitem-%' OR q.closure_reason = 'handed_off_to')`)
718
- .all(custodyCutoff, JSON.stringify(openDanglingIds));
719
- for (const { qitem_id } of custodyRows) {
720
- const row = deps.queueRepo.getById(qitem_id);
859
+ /** `recheck`: read live without the lent indexes, and don't log the registry fallback a second time. */
860
+ const custodyCandidate = (qitemId, hasSuccessor, recheck = false) => {
861
+ // A recheck reads live, without the lent indexes: one row's own queries cost less than a rebuilt successor index.
862
+ const row = recheck ? deps.queueRepo.getById(qitemId, { waiting: false }) : indexed(() => deps.queueRepo.getById(qitemId, { waiting: false }));
721
863
  if (!row || isFindingRow(row))
722
- continue;
864
+ return null;
865
+ // The query's own predicate, on the row as it is now.
866
+ const closed = row.state === "done" || row.state === "canceled"
867
+ || (row.state === "handed-off" && (row.handedOffTo == null || (row.closureTarget ?? null) !== row.handedOffTo));
868
+ if (!closed || !(startsWithCI(row.closureTarget, "qitem-") || row.closureReason === "handed_off_to"))
869
+ return null;
723
870
  // Local recorded targets were filtered in SQL; remote keys use the same
724
871
  // derivation as the cross-host close, without reading successor history.
725
872
  if (row.state === "handed-off" && matchesRecordedHandoffTarget(row.qitemId, row.handedOffTo, row.closureTarget))
726
- continue;
873
+ return null;
727
874
  const targets = (row.closureTarget ?? row.handedOffTo ?? "")
728
875
  .split(",")
729
876
  .map((target) => target.trim())
@@ -731,7 +878,7 @@ export async function runStuckSweep(deps) {
731
878
  if (targets.length === 0 && row.closureReason === "handed_off_to") {
732
879
  targets.push("(unspecified)");
733
880
  }
734
- const verified = custodyVerifiedTargets(deps.db, row.qitemId);
881
+ const verified = custodyVerifiedTargets(deps.db, row.qitemId, targets);
735
882
  const verificationTargets = targets.filter((target) => {
736
883
  if (verified.has(target))
737
884
  return false;
@@ -746,17 +893,17 @@ export async function runStuckSweep(deps) {
746
893
  }
747
894
  if (target === row.qitemId)
748
895
  return true;
749
- return !deps.queueRepo.getById(target);
896
+ return !indexed(() => deps.queueRepo.getById(target, { waiting: false }));
750
897
  }
751
898
  try {
752
- return !hasLinkedSuccessor(deps.db, row.qitemId, target);
899
+ return !hasSuccessor(row.qitemId, target);
753
900
  }
754
901
  catch {
755
902
  return true;
756
903
  }
757
904
  });
758
905
  if (verificationTargets.length === 0)
759
- continue;
906
+ return null;
760
907
  let route = row.destinationSession;
761
908
  try {
762
909
  route = custodyFindingRoute(deps.db, deps.queueRepo, row);
@@ -766,9 +913,10 @@ export async function runStuckSweep(deps) {
766
913
  throw err;
767
914
  // The registry may not exist before the first human is registered. Losing
768
915
  // owner refinement must not stop unrelated findings or their resolution.
769
- log(`[stuck-sweep] keeping custody route for ${row.qitemId} at ${row.destinationSession}: ${err.message}`);
916
+ if (!recheck)
917
+ log(`[stuck-sweep] keeping custody route for ${row.qitemId} at ${row.destinationSession}: ${err.message}`);
770
918
  }
771
- candidates.push({
919
+ return {
772
920
  kind: "dangling-closure",
773
921
  row,
774
922
  route,
@@ -776,7 +924,176 @@ export async function runStuckSweep(deps) {
776
924
  evidenceAt: latestIso(row.tsUpdated),
777
925
  why: `closed (${row.closureReason ?? "?"}) with successor custody that this local store cannot fully verify`,
778
926
  verificationTargets,
779
- });
927
+ };
928
+ };
929
+ const armedJobOf = (qitemId) => deps.db.prepare("SELECT wake_ref FROM queue_transition_wakes WHERE qitem_id = ? AND phase = 'armed' ORDER BY transition_id DESC LIMIT 1").get(qitemId)?.wake_ref;
930
+ /** A kind's rule, again, on the row as it is now (read live, without the lent indexes): the candidate it makes now,
931
+ * with its current route, reason and targets, or null when it no longer holds. */
932
+ const freshCandidate = (kind, id, jobId) => {
933
+ switch (kind) {
934
+ case "overdue-claim": {
935
+ const row = deps.queueRepo.findOverdue({ now: nowIso, qitemId: id, waiting: false })[0];
936
+ return row ? overdueCandidate(row) : null;
937
+ }
938
+ case "stalled-after-claim": return stalledCandidate(id);
939
+ case "unconsumed-wait": {
940
+ const job = jobId ?? armedJobOf(id);
941
+ const c = job ? waitCandidate(job) : null;
942
+ return c?.row.qitemId === id ? c : null;
943
+ }
944
+ case "parked-owner-no-input": return parkedCandidate(id);
945
+ case "undelivered-wake":
946
+ case "undelivered-human-notice": {
947
+ const row = undeliveredNow(id);
948
+ // the wake retry already ran in this pass; a row that still needs it now was not woken by it
949
+ const c = row ? undeliveredCandidate(row, false) : null;
950
+ return c?.kind === kind ? c : null;
951
+ }
952
+ case "unclaimed-obligation": return unclaimedCandidate(id, false);
953
+ case "dangling-closure": return custodyCandidate(id, (source, target) => hasLinkedSuccessor(deps.db, source, target), true);
954
+ default: return null;
955
+ }
956
+ };
957
+ /** Whether a kind's rule still holds now, leaving the routing notes (routeNotes, routed) as they were. */
958
+ const ruleHolds = (kind, id, jobId) => {
959
+ const notes = new Map(routeNotes);
960
+ const wasRouted = new Set(routed);
961
+ try {
962
+ return !!freshCandidate(kind, id, jobId);
963
+ }
964
+ finally {
965
+ routeNotes.clear();
966
+ for (const [k, v] of notes)
967
+ routeNotes.set(k, v);
968
+ routed.clear();
969
+ for (const k of wasRouted)
970
+ routed.add(k);
971
+ }
972
+ };
973
+ const stillStuck = (c) => ruleHolds(c.kind, c.row.qitemId, c.jobId);
974
+ /** The kinds the resolution closes on "no longer detected" alone (the others need source evidence). */
975
+ const resolvedByRule = new Set(["overdue-claim", "stalled-after-claim", "unconsumed-wait", "parked-owner-no-input", "dangling-closure"]);
976
+ // The rows each rule looks at. The id lists are judged on a fresh getById per row; the two finders return whole
977
+ // rows, which are read again by id once other code may have run since the list was read.
978
+ let listedAt = othersRan;
979
+ for (const listed of indexed(() => deps.queueRepo.findOverdue({ now: nowIso, waiting: false }))) {
980
+ if (dueToYield())
981
+ await yieldLoop();
982
+ const row = listedAt !== othersRan ? indexed(() => deps.queueRepo.findOverdue({ now: nowIso, qitemId: listed.qitemId, waiting: false }))[0] : listed;
983
+ const c = row ? overdueCandidate(row) : null;
984
+ if (!c)
985
+ continue;
986
+ candidates.push(c);
987
+ try {
988
+ // Only a transition and an event: no index or listed row changes.
989
+ deps.queueRepo.recordClosureOverdue(row.qitemId, { now: nowIso });
990
+ }
991
+ catch (err) {
992
+ log(`[stuck-sweep] failed to record closure-overdue for ${row.qitemId}: ${err instanceof Error ? err.message : String(err)}`);
993
+ }
994
+ }
995
+ for (const { qitem_id } of deps.db
996
+ .prepare("SELECT qitem_id FROM queue_items WHERE state IN ('pending', 'in-progress') AND claimed_at IS NOT NULL")
997
+ .all()) {
998
+ if (dueToYield())
999
+ await yieldLoop();
1000
+ const c = stalledCandidate(qitem_id);
1001
+ if (c)
1002
+ candidates.push(c);
1003
+ }
1004
+ for (const { job_id } of deps.db.prepare("SELECT job_id FROM watchdog_jobs WHERE state = 'active' AND policy = 'periodic-reminder'")
1005
+ .all()) {
1006
+ if (dueToYield())
1007
+ await yieldLoop();
1008
+ const c = waitCandidate(job_id);
1009
+ if (c)
1010
+ candidates.push(c);
1011
+ }
1012
+ for (const { qitem_id } of deps.db.prepare("SELECT qitem_id FROM queue_items WHERE state='blocked' AND last_nudge_result LIKE 'failed:%'")
1013
+ .all()) {
1014
+ if (dueToYield())
1015
+ await yieldLoop();
1016
+ const c = parkedCandidate(qitem_id);
1017
+ if (c)
1018
+ candidates.push(c);
1019
+ }
1020
+ listedAt = othersRan;
1021
+ for (const listed of indexed(() => deps.queueRepo.findUndelivered({ waiting: false }))) {
1022
+ if (dueToYield())
1023
+ await yieldLoop();
1024
+ let row = listedAt !== othersRan ? undeliveredNow(listed.qitemId) : listed;
1025
+ if (!row || isFindingRow(row))
1026
+ continue;
1027
+ if (wakeToRetry(row)) {
1028
+ await deps.queueRepo.deliverWakeForSuccessor(row.qitemId, row.destinationSession, true, row.sourceSession);
1029
+ othersMayHaveRun();
1030
+ // judged again on the row as the send (and anyone else during it) left it
1031
+ row = undeliveredNow(row.qitemId);
1032
+ if (!row?.lastNudgeResult?.startsWith("unroutable:"))
1033
+ continue;
1034
+ }
1035
+ const c = undeliveredCandidate(row, true);
1036
+ if (c)
1037
+ candidates.push(c);
1038
+ }
1039
+ for (const { qitem_id } of deps.db
1040
+ .prepare(`SELECT qitem_id FROM queue_items
1041
+ WHERE state = 'pending'
1042
+ AND claimed_at IS NULL
1043
+ AND destination_session IS NOT NULL AND destination_session != ''
1044
+ AND ts_created <= ?
1045
+ AND (last_nudge_result IS NULL OR last_nudge_result NOT LIKE 'failed:%')`)
1046
+ .all(cutoff)) {
1047
+ if (dueToYield())
1048
+ await yieldLoop();
1049
+ const c = unclaimedCandidate(qitem_id, true);
1050
+ if (c)
1051
+ candidates.push(c);
1052
+ }
1053
+ const custodyHours = deps.custodyWindowHours ?? STUCK_SWEEP_CUSTODY_WINDOW_HOURS;
1054
+ const custodyCutoff = new Date(now.getTime() - custodyHours * 3_600_000).toISOString();
1055
+ const openDanglingIds = [];
1056
+ const danglingPrefix = "stuck-sweep:dangling-closure:";
1057
+ for (const { tags } of deps.db
1058
+ .prepare(`SELECT tags FROM queue_items WHERE state IN ('pending', 'in-progress', 'blocked') AND tags LIKE ?`)
1059
+ .all(`%"${danglingPrefix}%`)) {
1060
+ try {
1061
+ for (const tag of JSON.parse(tags)) {
1062
+ if (tag.startsWith(danglingPrefix)) {
1063
+ openDanglingIds.push(tag.slice(danglingPrefix.length));
1064
+ }
1065
+ }
1066
+ }
1067
+ catch {
1068
+ // Skip malformed tags
1069
+ }
1070
+ }
1071
+ const custodyRows = deps.db
1072
+ .prepare(
1073
+ // Bound candidates before checking state: including handed-off in the
1074
+ // state index scan would otherwise revisit all historical atomic handoffs.
1075
+ `WITH custody_candidates AS MATERIALIZED (
1076
+ SELECT qitem_id, state, handed_off_to, closure_target, closure_reason
1077
+ FROM queue_items WHERE ts_updated >= ?
1078
+ UNION
1079
+ SELECT qitem_id, state, handed_off_to, closure_target, closure_reason
1080
+ FROM queue_items WHERE qitem_id IN (SELECT value FROM json_each(?))
1081
+ )
1082
+ SELECT q.qitem_id FROM custody_candidates q
1083
+ WHERE (q.state IN ('done', 'canceled') OR (q.state = 'handed-off'
1084
+ AND (q.handed_off_to IS NULL OR q.closure_target IS NOT q.handed_off_to)))
1085
+ AND (q.closure_target LIKE 'qitem-%' OR q.closure_reason = 'handed_off_to')`)
1086
+ .all(custodyCutoff, JSON.stringify(openDanglingIds));
1087
+ successors = createLinkedSuccessorLookup(deps.db, custodyRows.map((r) => r.qitem_id));
1088
+ const lookup = successors;
1089
+ for (const { qitem_id } of custodyRows) {
1090
+ if (dueToYield())
1091
+ await yieldLoop();
1092
+ const c = custodyCandidate(qitem_id, successorsPerRow
1093
+ ? (source, target) => hasLinkedSuccessor(deps.db, source, target)
1094
+ : (source, target) => lookup.has(source, target));
1095
+ if (c)
1096
+ candidates.push(c);
780
1097
  }
781
1098
  // A finding for a confirmed-missing session goes to a live recovery seat when one is available,
782
1099
  // since nothing would ever wake the missing one (the ladder covers handed-off batons only): the
@@ -790,9 +1107,9 @@ export async function runStuckSweep(deps) {
790
1107
  };
791
1108
  const sessionMissing = deps.sessionConfirmedMissing ?? ((session) => stoppedReason(session) !== null);
792
1109
  let recoverySeats;
793
- for (const c of candidates) {
1110
+ const routeAroundMissing = (c) => {
794
1111
  if (!sessionMissing(c.route))
795
- continue;
1112
+ return;
796
1113
  const stoppedDescription = stoppedReason(c.route) === "pane_exited"
797
1114
  ? "has a confirmed exited pane (pane_exited)" : "is confirmed missing (session_missing)";
798
1115
  recoverySeats ??= [(deps.resolveRecoveryAgentSeat ?? resolveRecoveryAgentSeat)(), (deps.resolveOperatorSeat ?? resolveOperatorSeat)()];
@@ -801,12 +1118,12 @@ export async function runStuckSweep(deps) {
801
1118
  const floor = chosen < 0 ? null : choices[chosen];
802
1119
  if (!floor) {
803
1120
  c.why += `; ${c.route} ${stoppedDescription} and no live recovery seat is available (operator agent, operator seat and creator are each unset, missing or this seat; an operator agent setting that's unreadable or isn't an agent's session counts as unset), so this finding stays addressed to it`;
804
- continue;
1121
+ return;
805
1122
  }
806
1123
  // Name the rule that chose it, so whoever receives the finding knows why, and which setting to change.
807
1124
  c.why += `; ${c.route} ${stoppedDescription}, so this finding goes to ${floor}, ${RECOVERY_SEAT_RULES[chosen]}`;
808
1125
  c.route = floor;
809
- }
1126
+ };
810
1127
  // A destination its own wake found unroutable, and still is (no terminal, not a person: a hosted member, or a
811
1128
  // mistyped address), can't hear its finding either; a seat launched since its wake keeps its own. A hosted member
812
1129
  // OpenRig rings, whose work is still unclaimed (its ring failed, or it didn't pick the work up by the unclaimed
@@ -816,42 +1133,117 @@ export async function runStuckSweep(deps) {
816
1133
  // unroutable or a terminal seat itself. A bound terminal seat goes the same way: the queue wake types nothing into
817
1134
  // it, and nothing there can claim work.
818
1135
  const classOf = (seat) => deps.queueRepo.classifyDestinationOf(seat).class;
819
- for (const c of candidates) {
1136
+ /** Who hears about work for a destination that can't hear it: the index into NO_WAKE_ROUTE_RULES and the seat, or -1. */
1137
+ const noWakeRecipient = (destination, creator) => {
1138
+ const operatorSeat = (deps.resolveOperatorSeat ?? resolveOperatorSeat)();
1139
+ const person = operatorSeat && classOf(operatorSeat) === "gateway-routable" ? operatorSeat : null;
1140
+ const choices = [person, creator, (deps.resolveRecoveryAgentSeat ?? resolveRecoveryAgentSeat)()];
1141
+ const chosen = choices.findIndex((seat) => !!seat && seat !== destination && !sessionMissing(seat) && classOf(seat) !== "unroutable"
1142
+ && !isBoundTerminalSeat(deps.db, seat));
1143
+ return { chosen, seat: chosen < 0 ? null : choices[chosen] };
1144
+ };
1145
+ /** The person (the operator seat when it's a person's address) or the operator agent: recipients that may see any row. */
1146
+ const seesAnyRow = (seat) => {
1147
+ const operatorSeat = (deps.resolveOperatorSeat ?? resolveOperatorSeat)();
1148
+ if (operatorSeat === seat && classOf(seat) === "gateway-routable")
1149
+ return true;
1150
+ return (deps.resolveRecoveryAgentSeat ?? resolveRecoveryAgentSeat)() === seat;
1151
+ };
1152
+ const routeAroundNoWake = (c) => {
820
1153
  if (c.route !== c.row.destinationSession)
821
- continue;
1154
+ return;
822
1155
  const destination = classOf(c.row.destinationSession);
823
1156
  const noRoute = destination === "unroutable" && !!c.row.lastNudgeResult?.startsWith("unroutable:");
824
1157
  const terminalSeat = destination === "pane-bound" && isBoundTerminalSeat(deps.db, c.row.destinationSession);
825
1158
  if (!noRoute && !terminalSeat && !(destination === "hosted" && !c.row.claimedAt))
826
- continue;
827
- const operatorSeat = (deps.resolveOperatorSeat ?? resolveOperatorSeat)();
828
- const person = operatorSeat && classOf(operatorSeat) === "gateway-routable" ? operatorSeat : null;
829
- const choices = [person, c.row.sourceSession, (deps.resolveRecoveryAgentSeat ?? resolveRecoveryAgentSeat)()];
830
- const chosen = choices.findIndex((seat) => !!seat && seat !== c.route && !sessionMissing(seat) && classOf(seat) !== "unroutable"
831
- && !isBoundTerminalSeat(deps.db, seat));
1159
+ return;
1160
+ c.noWake = true;
1161
+ const recipient = noWakeRecipient(c.route, c.row.sourceSession);
832
1162
  c.why += noRoute
833
1163
  ? `; ${c.route} has no wake route on this daemon (no terminal, not a person). If it's a hosted member, it sees this work only when it next checks, so ask it to; otherwise fix the address`
834
1164
  : terminalSeat
835
1165
  ? `; ${c.route} is a terminal seat; nothing there can claim this work, and no wake is typed into it. Route the work to an agent seat`
836
1166
  : `; ${c.route} is a hosted member. OpenRig rang its trigger (${c.row.lastNudgeResult ?? "no ring recorded"}), and it hasn't claimed this work. It sees work only when it checks, so ask it to`;
837
- if (chosen < 0) {
1167
+ if (!recipient.seat) {
838
1168
  c.why += `. No person, creator or operator agent that can be reached is available, so this finding stays addressed to it`;
839
- continue;
1169
+ return;
840
1170
  }
841
- c.why += `. This finding goes to ${choices[chosen]}, ${NO_WAKE_ROUTE_RULES[chosen]}`;
842
- c.route = choices[chosen];
1171
+ c.why += `. This finding goes to ${recipient.seat}, ${NO_WAKE_ROUTE_RULES[recipient.chosen]}`;
1172
+ c.route = recipient.seat;
1173
+ };
1174
+ /** The two re-routes, in order, for one candidate. */
1175
+ const routeCandidate = (c) => { routeAroundMissing(c); routeAroundNoWake(c); };
1176
+ for (const c of candidates) {
1177
+ if (dueToYield())
1178
+ await yieldLoop();
1179
+ routeAroundMissing(c);
1180
+ }
1181
+ for (const c of candidates) {
1182
+ if (dueToYield())
1183
+ await yieldLoop();
1184
+ routeAroundNoWake(c);
843
1185
  }
844
1186
  // Route: idempotent per (row, kind). An existing open finding refreshes its age; a
845
1187
  // new one is created durable + waking (the create path's default nudge).
846
1188
  const findings = [];
847
1189
  const liveDedupTags = new Set();
1190
+ const candidateIds = new Set(candidates.map((c) => c.row.qitemId));
848
1191
  // A finding that could not be created (a row whose destination no longer resolves, say) must not
849
1192
  // stop the others: it is reported, its row stays detected, and the pass is still a failure.
850
1193
  const failedCreates = [];
1194
+ // #2430: an unclaimed row whose finding would go back to its own agent seat (no delegation parent and no escalates_to
1195
+ // route declared) tells that seat nothing: it already holds the row. A seat that reads its rows without claiming
1196
+ // them, a person's front door, got one such finding per row. Those rows share one standing notice per seat instead
1197
+ // (below). A finding per row stays for a person's address or a terminal seat, for a declared route that failed (its
1198
+ // finding names why, and a declared delegation parent with no session is one), and for a row that already has a
1199
+ // recovery.
1200
+ const agentSeats = new Map();
1201
+ /** An agent seat's node: one whose runtime isn't a terminal, with no declared delegation parent, at an address that
1202
+ * isn't a person's. An address the human registry can't classify counts as a person's. null for anything else. Read
1203
+ * once per seat per pass. */
1204
+ const agentSeatNode = (session) => {
1205
+ if (agentSeats.has(session))
1206
+ return agentSeats.get(session);
1207
+ const nodeId = resolveSessionNodeId(deps.db, session);
1208
+ const node = nodeId ? deps.db.prepare(`SELECT n.logical_id AS logicalId, n.runtime AS runtime, r.name AS rig,
1209
+ EXISTS (SELECT 1 FROM edges e WHERE e.target_id = n.id AND e.kind = 'delegates_to') AS parent
1210
+ FROM nodes n JOIN rigs r ON r.id = n.rig_id WHERE n.id = ?`)
1211
+ .get(nodeId) : undefined;
1212
+ let agent = null;
1213
+ try {
1214
+ if (node && node.runtime !== "terminal" && !node.parent && !deps.queueRepo.isHumanDestination(session)) {
1215
+ agent = { logicalId: node.logicalId, rig: node.rig };
1216
+ }
1217
+ }
1218
+ catch { /* unclassifiable: a person's, as above */ }
1219
+ agentSeats.set(session, agent);
1220
+ return agent;
1221
+ };
1222
+ const selfRoutedUnclaimed = (c) => c.kind === "unclaimed-obligation"
1223
+ && c.route === c.row.destinationSession && !routeNotes.has(c.row.qitemId) && agentSeatNode(c.route) !== null;
1224
+ // A hosted member that polls for its work (no wake trigger) can't hear a finding, so each unclaimed row went to a
1225
+ // person as a finding of its own. Those rows share one standing notice per member instead, unless a route the member
1226
+ // declares (a delegation parent or escalates_to) takes them.
1227
+ const polledUnclaimed = (c) => c.kind === "unclaimed-obligation" && c.noWake === true
1228
+ && !routeNotes.has(c.row.qitemId) && polledRow(c.row);
1229
+ /** The standing notice a candidate belongs to (the seat or member it stands for), or null for a finding of its own. */
1230
+ const backlogKeyOf = (c) => polledUnclaimed(c) ? c.row.destinationSession : selfRoutedUnclaimed(c) ? c.route : null;
1231
+ const unclaimedBacklog = new Map();
851
1232
  for (const c of [...new Map(candidates.map(c => [c.row.qitemId, c])).values()]) {
1233
+ if (dueToYield())
1234
+ await yieldLoop();
852
1235
  const dedupTag = findingDedupTag(c.kind, c.row.qitemId);
853
- const shared = findQueueRecovery(deps.db, c.row.qitemId);
854
- const sharedRow = shared ? deps.queueRepo.getById(shared.qitemId) : null;
1236
+ const shared = recoveries.find(c.row.qitemId);
1237
+ const backlogKey = shared ? null : backlogKeyOf(c);
1238
+ if (backlogKey) {
1239
+ const rows = unclaimedBacklog.get(backlogKey);
1240
+ if (rows)
1241
+ rows.push(c);
1242
+ else
1243
+ unclaimedBacklog.set(backlogKey, [c]);
1244
+ continue;
1245
+ }
1246
+ const sharedRow = shared ? indexed(() => deps.queueRepo.getById(shared.qitemId, { waiting: false })) : null;
855
1247
  // A later accepted deadline can expire after the previous finding closed.
856
1248
  // Its newer time is fresh evidence even when the pickup candidate wins this row.
857
1249
  // An OPEN recovery still owns custody.
@@ -874,7 +1266,8 @@ export async function runStuckSweep(deps) {
874
1266
  const humanUpdateNotice = currentKind === "unclaimed-obligation"
875
1267
  && c.kind === "undelivered-human-notice"
876
1268
  && deps.queueRepo.isRegisteredHumanUpdate(c.row);
877
- if (currentKind && currentKind !== c.kind && ((pickupOrDeadline(currentKind) && pickupOrDeadline(c.kind)) || humanUpdateNotice)) {
1269
+ if (currentKind && currentKind !== c.kind && ((pickupOrDeadline(currentKind) && pickupOrDeadline(c.kind)) || humanUpdateNotice)
1270
+ && stillStuck(c)) { // the new reason must still hold on the row as it is now
878
1271
  const marker = "\n\n--- Original finding (historical) ---\n";
879
1272
  const original = sharedRow.body.includes(marker) ? sharedRow.body.split(marker, 2)[1] : sharedRow.body;
880
1273
  const body = evidenceBody(deps.db, c) + marker + original;
@@ -904,33 +1297,195 @@ export async function runStuckSweep(deps) {
904
1297
  findings.push({ kind: c.kind, qitemId: c.row.qitemId, findingQitemId: existing.qitem_id, action: "refreshed" });
905
1298
  }
906
1299
  else if (renewedDeadline || !existing || evidenceIsNewer(c.evidenceAt, existing.ts_updated)) {
1300
+ // The row was found stuck before the pass's later yields and awaited writes: its rule runs again on the row as
1301
+ // it is now, and a row that no longer qualifies gets no new finding (its dedup tag stays live this pass).
1302
+ // the escalation note and hop recorded at listing belong to that route; keep only what this run records
1303
+ routeNotes.delete(c.row.qitemId);
1304
+ routed.delete(c.row.qitemId);
1305
+ const now_ = freshCandidate(c.kind, c.row.qitemId, c.jobId);
1306
+ if (!now_)
1307
+ continue;
1308
+ routeCandidate(now_); // its destination, reason and targets as they are now
907
1309
  const input = {
908
1310
  qitemId: recoveryId(deps.db, c.row.qitemId, renewedDeadline ? c.row.closureRequiredAt : undefined),
909
1311
  // The detector is machinery, not a seat: the obligation's own creator is the
910
1312
  // finding's source (the workflow-exception precedent).
911
1313
  sourceSession: c.row.sourceSession,
912
- destinationSession: c.route,
913
- body: evidenceBody(deps.db, c) + (routeNotes.has(c.row.qitemId) ? `\nescalation route: ${routeNotes.get(c.row.qitemId)}` : ""),
914
- summary: c.verificationTargets
915
- ? custodyHeadline(c.row.qitemId, c.verificationTargets, c.ageMinutes)
916
- : `Stuck sweep: ${c.kind} on ${c.row.qitemId} (${c.ageMinutes} min)`,
1314
+ destinationSession: now_.route,
1315
+ body: evidenceBody(deps.db, now_) + (routeNotes.has(c.row.qitemId) ? `\nescalation route: ${routeNotes.get(c.row.qitemId)}` : ""),
1316
+ summary: now_.verificationTargets
1317
+ ? custodyHeadline(c.row.qitemId, now_.verificationTargets, now_.ageMinutes)
1318
+ : `Stuck sweep: ${c.kind} on ${c.row.qitemId} (${now_.ageMinutes} min)`,
917
1319
  evidenceRef: `rig queue show ${c.row.qitemId}`,
918
1320
  tags: [STUCK_SWEEP_FINDING_TAG, dedupTag, recoveryTag(c.row.qitemId),
919
- ...(routed.has(c.row.qitemId) || c.row.tags?.includes(ESCALATION_HOP_TAG) ? [ESCALATION_HOP_TAG] : [])],
1321
+ ...(routed.has(c.row.qitemId) || now_.row.tags?.includes(ESCALATION_HOP_TAG) ? [ESCALATION_HOP_TAG] : []),
1322
+ ...(now_.row.tags ?? []).filter((tag) => /^(project|mission|slice):/.test(tag))],
920
1323
  // OpenRig's own finding, whoever created the stuck row.
921
1324
  wakeTrigger: "openrig",
922
1325
  };
923
1326
  try {
924
1327
  const created = await deps.queueRepo.create(input);
1328
+ othersMayHaveRun();
925
1329
  findings.push({ kind: c.kind, qitemId: c.row.qitemId, findingQitemId: created.qitemId, action: "created" });
926
1330
  }
927
1331
  catch (err) {
928
- const message = `${c.kind} finding for ${c.row.qitemId} to ${c.route} not created: ${err instanceof Error ? err.message : String(err)}`;
1332
+ const message = `${c.kind} finding for ${c.row.qitemId} to ${now_.route} not created: ${err instanceof Error ? err.message : String(err)}`;
1333
+ othersMayHaveRun();
929
1334
  log(`[stuck-sweep] ${message}`);
930
1335
  failedCreates.push(message);
931
1336
  }
932
1337
  }
933
1338
  }
1339
+ // A seat's standing notice for those rows. It stands for every row it has listed until that row is resolved at its
1340
+ // source (the evidence a finding per row needs to close: claimed, parked, closed) or gets a finding of its own, so a
1341
+ // detection filter (a raised threshold, the wake ladder) never reads as done. While any is left it stays open and is
1342
+ // rewritten in place; once none is, the sweep closes it. A closed notice, dismissed or resolved, holds back only the
1343
+ // rows it stood for, each only until it has newer evidence than the close: any other row files a new notice. It wakes
1344
+ // the seat once, when it's filed.
1345
+ const backlogRow = (c) => ({ qitemId: c.row.qitemId, since: c.evidenceAt, from: c.row.sourceSession, summary: c.row.summary });
1346
+ const backlogPrefix = unclaimedBacklogTag("");
1347
+ const backlogSeats = new Set(unclaimedBacklog.keys());
1348
+ for (const { tags } of deps.db.prepare(`SELECT tags FROM queue_items WHERE state IN ('pending', 'in-progress', 'blocked')
1349
+ AND (tags LIKE '%"stuck-sweep:%') AND tags LIKE ?`).all(`%"${backlogPrefix}%`)) {
1350
+ try {
1351
+ for (const tag of JSON.parse(tags))
1352
+ if (tag.startsWith(backlogPrefix))
1353
+ backlogSeats.add(tag.slice(backlogPrefix.length));
1354
+ }
1355
+ catch { /* Skip malformed tags */ }
1356
+ }
1357
+ for (const seat of backlogSeats) {
1358
+ if (dueToYield())
1359
+ await yieldLoop();
1360
+ const rows = unclaimedBacklog.get(seat) ?? [];
1361
+ const tag = unclaimedBacklogTag(seat);
1362
+ liveDedupTags.add(tag);
1363
+ const node = agentSeatNode(seat);
1364
+ // A polling member's notice says whether it's checking in; an agent seat's names the route to add instead.
1365
+ const polled = rows.length > 0 ? rows.some(polledUnclaimed) : pollsForWork(seat);
1366
+ const backlogText = (standsFor) => polled
1367
+ ? polledBacklogText(seat, standsFor, ageMinutes, deps.queueRepo.lastInboxCheckIn(seat), now)
1368
+ : unclaimedBacklogText(seat, standsFor, ageMinutes, node);
1369
+ // A polling member's notice goes where its rows' findings went: the person, else their creator when they share one,
1370
+ // else the operator agent. With none, it stays with the member, which reads it when it next checks.
1371
+ const recipientFor = (creators) => {
1372
+ if (!polled)
1373
+ return seat;
1374
+ const distinct = [...new Set(creators)];
1375
+ return noWakeRecipient(seat, distinct.length === 1 ? distinct[0] : null).seat ?? seat;
1376
+ };
1377
+ /** Files a notice and wakes its recipient; false when the create failed (reported in failedCreates). */
1378
+ const fileNotice = async (text, recipient) => {
1379
+ try {
1380
+ const created = await deps.queueRepo.create({
1381
+ // A notice about a seat's own rows comes from that seat, as a restore notice does; OpenRig wakes its recipient.
1382
+ sourceSession: seat,
1383
+ destinationSession: recipient,
1384
+ body: text.body,
1385
+ summary: text.summary,
1386
+ evidenceRef: `rig queue list --destination ${seat} --state pending`,
1387
+ tags: [STUCK_SWEEP_FINDING_TAG, tag],
1388
+ wakeTrigger: "openrig",
1389
+ });
1390
+ othersMayHaveRun();
1391
+ findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: created.qitemId, action: "created" });
1392
+ return true;
1393
+ }
1394
+ catch (err) {
1395
+ const message = `unclaimed-backlog notice for ${seat} not created: ${err instanceof Error ? err.message : String(err)}`;
1396
+ othersMayHaveRun();
1397
+ log(`[stuck-sweep] ${message}`);
1398
+ failedCreates.push(message);
1399
+ return false;
1400
+ }
1401
+ };
1402
+ const last = deps.db
1403
+ .prepare(
1404
+ // The first term lets the planner use idx_queue_items_recovery_tags, as the finding lookup above does.
1405
+ `SELECT qitem_id, state, ts_updated, summary, body, destination_session FROM queue_items
1406
+ WHERE (tags LIKE '%"stuck-sweep:%') AND tags LIKE ? ESCAPE '\\'
1407
+ ORDER BY CASE WHEN state IN ('pending', 'in-progress', 'blocked') THEN 0 ELSE 1 END,
1408
+ ts_updated DESC, ts_created DESC, qitem_id DESC
1409
+ LIMIT 1`)
1410
+ .get(`%"${tag.replace(/[\\%_]/g, (ch) => `\\${ch}`)}"%`);
1411
+ if (last && ["pending", "in-progress", "blocked"].includes(last.state)) {
1412
+ const listedNow = new Set(rows.map((c) => c.row.qitemId));
1413
+ const stoodFor = backlogRowsOf(last.body);
1414
+ const still = [...(stoodFor ?? [])].filter((id) => !listedNow.has(id)).flatMap((id) => {
1415
+ const row = indexed(() => deps.queueRepo.getById(id, { waiting: false }));
1416
+ // Gone, someone else's now, resolved at its source, or held by a finding or recovery of its own: one actually
1417
+ // written, so a create that failed this pass leaves the row here.
1418
+ if (!row || row.destinationSession !== seat || recoveries.find(id)
1419
+ || deliveryResolutionEvidence(deps, "unclaimed-obligation", id, now))
1420
+ return [];
1421
+ return [{ qitemId: id, since: pendingSince(deps.db, id) ?? row.tsCreated, from: row.sourceSession, summary: row.summary }];
1422
+ });
1423
+ const standsFor = [...rows.map(backlogRow), ...still];
1424
+ // With its list unreadable, the notice may still stand for rows: it's left as it is, never closed.
1425
+ if (standsFor.length === 0 && !stoodFor) {
1426
+ findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "refreshed" });
1427
+ continue;
1428
+ }
1429
+ if (standsFor.length === 0) {
1430
+ await deps.queueRepo.update({
1431
+ qitemId: last.qitem_id,
1432
+ actorSession: "stuck-sweep@system",
1433
+ state: "done",
1434
+ closureReason: "no-follow-on",
1435
+ transitionNote: `stuck-sweep resolved: unclaimed-backlog on ${seat}: every row it stood for is claimed, parked, closed or has its own finding`,
1436
+ });
1437
+ othersMayHaveRun();
1438
+ findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "closed" });
1439
+ continue;
1440
+ }
1441
+ // A notice that went to one of its rows' creators (no person reachable) shows that creator only rows it sent. When a
1442
+ // row from anyone else would join it, one notice for every row it stands for goes where a new notice would go now,
1443
+ // which wakes that recipient, and only then does this one close: a notice the sweep closed holds its rows back, so a
1444
+ // failed create leaves it open as it was (not rewritten), and the next pass tries again. A person, the operator
1445
+ // agent and the member see any of the rows.
1446
+ if (polled && last.destination_session !== seat && !seesAnyRow(last.destination_session)
1447
+ && standsFor.some((r) => r.from !== last.destination_session)) {
1448
+ const recipient = recipientFor(standsFor.map((r) => r.from));
1449
+ if (!(await fileNotice(backlogText(standsFor), recipient)))
1450
+ continue;
1451
+ await deps.queueRepo.update({
1452
+ qitemId: last.qitem_id,
1453
+ actorSession: "stuck-sweep@system",
1454
+ state: "done",
1455
+ closureReason: "no-follow-on",
1456
+ transitionNote: `stuck-sweep re-filed: unclaimed-backlog on ${seat}: a row it stands for didn't come from ${last.destination_session}, the creator it went to; one notice for every row went to ${recipient}`,
1457
+ });
1458
+ othersMayHaveRun();
1459
+ findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "closed" });
1460
+ continue;
1461
+ }
1462
+ const text = backlogText(standsFor);
1463
+ if (text.summary !== last.summary || text.body !== last.body) {
1464
+ deps.db.prepare("UPDATE queue_items SET body = ?, summary = ? WHERE qitem_id = ? AND body = ? AND summary IS ? AND state IN ('pending', 'in-progress', 'blocked')")
1465
+ .run(text.body, text.summary, last.qitem_id, last.body, last.summary);
1466
+ }
1467
+ findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "refreshed" });
1468
+ continue;
1469
+ }
1470
+ if (rows.length === 0)
1471
+ continue;
1472
+ // Each row's rule again, on the row as it is now, as a finding per row is checked right before it's created.
1473
+ const current = rows.flatMap((c) => {
1474
+ routeNotes.delete(c.row.qitemId);
1475
+ routed.delete(c.row.qitemId);
1476
+ const now_ = freshCandidate(c.kind, c.row.qitemId);
1477
+ if (now_)
1478
+ routeCandidate(now_);
1479
+ return now_ && backlogKeyOf(now_) === seat && !recoveries.find(now_.row.qitemId) ? [now_] : [];
1480
+ });
1481
+ if (current.length === 0)
1482
+ continue;
1483
+ // A closed notice whose list is unreadable holds back every row, each until it has newer evidence than the close.
1484
+ const covered = last ? backlogRowsOf(last.body) : null;
1485
+ if (last && !current.some((c) => (covered !== null && !covered.has(c.row.qitemId)) || evidenceIsNewer(c.evidenceAt, last.ts_updated)))
1486
+ continue;
1487
+ await fileNotice(backlogText(current.map(backlogRow)), recipientFor(current.map((c) => c.row.sourceSession)));
1488
+ }
934
1489
  // Resolution: an open finding whose underlying condition is no longer detected closes
935
1490
  // with its reason — the sweep cleans up after itself, no human unwind.
936
1491
  const openFindings = deps.db
@@ -939,6 +1494,8 @@ export async function runStuckSweep(deps) {
939
1494
  AND tags LIKE ?`)
940
1495
  .all(`%"${STUCK_SWEEP_FINDING_TAG}"%`);
941
1496
  for (const f of openFindings) {
1497
+ if (dueToYield())
1498
+ await yieldLoop();
942
1499
  let tags = [];
943
1500
  try {
944
1501
  tags = JSON.parse(f.tags);
@@ -955,6 +1512,10 @@ export async function runStuckSweep(deps) {
955
1512
  // prove resolution either: delivery/pickup findings need source evidence.
956
1513
  if (suppressedTags.has(dedupTag))
957
1514
  continue;
1515
+ // #2661: a claim working only on a grace (a background shell, a pending managed restore) is not resolved: the
1516
+ // grace stops new detection, and an open stall recovery stays open, so the ceiling's expiry stays actionable.
1517
+ if (kind === "stalled-after-claim" && stuckId && deps.queueRepo.getById(stuckId, { waiting: false })?.pickup?.grace)
1518
+ continue;
958
1519
  let resolution = "no longer detected";
959
1520
  if (stuckId && (kind === "undelivered-wake" || kind === "undelivered-human-notice" || kind === "unclaimed-obligation")) {
960
1521
  const evidence = deliveryResolutionEvidence(deps, kind, stuckId, now);
@@ -962,6 +1523,17 @@ export async function runStuckSweep(deps) {
962
1523
  continue;
963
1524
  resolution = evidence;
964
1525
  }
1526
+ // The list was read before this loop's yields: the finding's owner may have closed it since (done -> done is
1527
+ // refused, and would fail the whole pass).
1528
+ const current = deps.db.prepare("SELECT state FROM queue_items WHERE qitem_id = ?").get(f.qitem_id);
1529
+ if (!current || !["pending", "in-progress", "blocked"].includes(current.state))
1530
+ continue;
1531
+ // "No longer detected" rests on lists read before this loop's yields: a row that came back (blocked, then
1532
+ // in-progress past its deadline) during the pass still holds, so its rule runs again on the row as it is now.
1533
+ // (A row this pass did find, whose finding isn't live because another recovery now holds its custody, closes as
1534
+ // the base closed it.)
1535
+ if (kind && stuckId && resolvedByRule.has(kind) && !candidateIds.has(stuckId) && ruleHolds(kind, stuckId))
1536
+ continue;
965
1537
  await deps.queueRepo.update({
966
1538
  qitemId: f.qitem_id,
967
1539
  // The sweep performed this transition; ownership stays on the existing row.
@@ -970,6 +1542,7 @@ export async function runStuckSweep(deps) {
970
1542
  closureReason: "no-follow-on",
971
1543
  transitionNote: `stuck-sweep resolved: ${kind ?? "finding"} on ${stuckId ?? "row"} ${resolution}`,
972
1544
  });
1545
+ othersMayHaveRun();
973
1546
  if (kind && stuckId) {
974
1547
  findings.push({
975
1548
  kind: kind,
@@ -982,11 +1555,11 @@ export async function runStuckSweep(deps) {
982
1555
  if (failedCreates.length > 0) {
983
1556
  // Not a clean or complete pass: say so, while keeping the findings that were made.
984
1557
  const error = failedCreates.join("; ");
985
- status?.record("failed", { error, findings: findings.filter((f) => f.action !== "closed").length });
1558
+ status?.record("failed", { error, ...findingCounts(deps.db, findings) });
986
1559
  return { outcome: "failed", findings, error };
987
1560
  }
988
1561
  const outcome = findings.length > 0 ? "findings" : "clean";
989
- status?.record(outcome, { findings: findings.filter((f) => f.action !== "closed").length });
1562
+ status?.record(outcome, findingCounts(deps.db, findings));
990
1563
  return { outcome, findings };
991
1564
  }
992
1565
  catch (err) {