@openrig/cli 0.7.13 → 0.7.14

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 (413) hide show
  1. package/README.md +5 -5
  2. package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +1 -1
  3. package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +1 -1
  4. package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
  5. package/daemon/assets/plugins/openrig/plugin.json +1 -1
  6. package/daemon/assets/plugins/openrig/skills/working-with-an-openrig-team/SKILL.md +7 -0
  7. package/daemon/assets/skills/rigs/SKILL.md +5 -2
  8. package/daemon/context-packs/help/manifest.yaml +1 -1
  9. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  10. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +65 -21
  11. package/daemon/context-packs/reference/getting-started.md +13 -8
  12. package/daemon/context-packs/reference/manifest.yaml +1 -1
  13. package/daemon/context-packs/reference/rig-spec.md +4 -0
  14. package/daemon/context-packs/reference/tmux-servers.md +8 -2
  15. package/daemon/context-packs/reference/whats-new.md +153 -15
  16. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  17. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  18. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  19. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  20. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  21. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  22. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  23. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  24. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  25. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  26. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  27. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  28. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  29. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  30. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  31. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  32. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/core/working-with-an-openrig-team/SKILL.md +7 -0
  38. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  66. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  70. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  71. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  72. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  73. package/daemon/dist/adapters/claude-code-adapter.js +27 -4
  74. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  75. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +11 -2
  76. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  77. package/daemon/dist/adapters/codex-runtime-adapter.js +32 -9
  78. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  79. package/daemon/dist/adapters/tmux-exec.d.ts +4 -4
  80. package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
  81. package/daemon/dist/adapters/tmux-exec.js +37 -8
  82. package/daemon/dist/adapters/tmux-exec.js.map +1 -1
  83. package/daemon/dist/adapters/tmux.d.ts +9 -0
  84. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  85. package/daemon/dist/adapters/tmux.js +23 -3
  86. package/daemon/dist/adapters/tmux.js.map +1 -1
  87. package/daemon/dist/attention-surface.d.ts +8 -0
  88. package/daemon/dist/attention-surface.d.ts.map +1 -1
  89. package/daemon/dist/attention-surface.js.map +1 -1
  90. package/daemon/dist/build-info.js +3 -3
  91. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  92. package/daemon/dist/db/all-migrations.js +6 -0
  93. package/daemon/dist/db/all-migrations.js.map +1 -1
  94. package/daemon/dist/db/migrations/163_network_installations.d.ts +7 -0
  95. package/daemon/dist/db/migrations/163_network_installations.d.ts.map +1 -0
  96. package/daemon/dist/db/migrations/163_network_installations.js +23 -0
  97. package/daemon/dist/db/migrations/163_network_installations.js.map +1 -0
  98. package/daemon/dist/db/migrations/164_queue_items_reply_to_index.d.ts +5 -0
  99. package/daemon/dist/db/migrations/164_queue_items_reply_to_index.d.ts.map +1 -0
  100. package/daemon/dist/db/migrations/164_queue_items_reply_to_index.js +9 -0
  101. package/daemon/dist/db/migrations/164_queue_items_reply_to_index.js.map +1 -0
  102. package/daemon/dist/db/migrations/166_queue_list_read_indexes.d.ts +4 -0
  103. package/daemon/dist/db/migrations/166_queue_list_read_indexes.d.ts.map +1 -0
  104. package/daemon/dist/db/migrations/166_queue_list_read_indexes.js +17 -0
  105. package/daemon/dist/db/migrations/166_queue_list_read_indexes.js.map +1 -0
  106. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +5 -0
  107. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  108. package/daemon/dist/domain/claude-compaction-enforcer.js +12 -3
  109. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  110. package/daemon/dist/domain/context-monitor.d.ts.map +1 -1
  111. package/daemon/dist/domain/context-monitor.js +8 -3
  112. package/daemon/dist/domain/context-monitor.js.map +1 -1
  113. package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
  114. package/daemon/dist/domain/draft-aware-delivery.js +2 -1
  115. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
  116. package/daemon/dist/domain/hosts/pairing-ask.d.ts +8 -0
  117. package/daemon/dist/domain/hosts/pairing-ask.d.ts.map +1 -1
  118. package/daemon/dist/domain/hosts/pairing-ask.js +20 -0
  119. package/daemon/dist/domain/hosts/pairing-ask.js.map +1 -1
  120. package/daemon/dist/domain/input-read-diagnostic.d.ts +30 -0
  121. package/daemon/dist/domain/input-read-diagnostic.d.ts.map +1 -0
  122. package/daemon/dist/domain/input-read-diagnostic.js +32 -0
  123. package/daemon/dist/domain/input-read-diagnostic.js.map +1 -0
  124. package/daemon/dist/domain/native-model-picker.d.ts +8 -0
  125. package/daemon/dist/domain/native-model-picker.d.ts.map +1 -0
  126. package/daemon/dist/domain/native-model-picker.js +35 -0
  127. package/daemon/dist/domain/native-model-picker.js.map +1 -0
  128. package/daemon/dist/domain/native-process-lineage.d.ts +6 -0
  129. package/daemon/dist/domain/native-process-lineage.d.ts.map +1 -1
  130. package/daemon/dist/domain/native-process-lineage.js +34 -29
  131. package/daemon/dist/domain/native-process-lineage.js.map +1 -1
  132. package/daemon/dist/domain/native-resume-probe.d.ts +6 -0
  133. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  134. package/daemon/dist/domain/native-resume-probe.js +124 -2
  135. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  136. package/daemon/dist/domain/network/network-bindings.d.ts +32 -2
  137. package/daemon/dist/domain/network/network-bindings.d.ts.map +1 -1
  138. package/daemon/dist/domain/network/network-bindings.js +65 -28
  139. package/daemon/dist/domain/network/network-bindings.js.map +1 -1
  140. package/daemon/dist/domain/network/network-installations.d.ts +97 -0
  141. package/daemon/dist/domain/network/network-installations.d.ts.map +1 -0
  142. package/daemon/dist/domain/network/network-installations.js +371 -0
  143. package/daemon/dist/domain/network/network-installations.js.map +1 -0
  144. package/daemon/dist/domain/operation-correlation.d.ts +1 -1
  145. package/daemon/dist/domain/operation-correlation.d.ts.map +1 -1
  146. package/daemon/dist/domain/operation-correlation.js +1 -1
  147. package/daemon/dist/domain/operation-correlation.js.map +1 -1
  148. package/daemon/dist/domain/process-observation-pass.d.ts +20 -0
  149. package/daemon/dist/domain/process-observation-pass.d.ts.map +1 -0
  150. package/daemon/dist/domain/process-observation-pass.js +80 -0
  151. package/daemon/dist/domain/process-observation-pass.js.map +1 -0
  152. package/daemon/dist/domain/queue-erasure.d.ts +10 -6
  153. package/daemon/dist/domain/queue-erasure.d.ts.map +1 -1
  154. package/daemon/dist/domain/queue-erasure.js +31 -18
  155. package/daemon/dist/domain/queue-erasure.js.map +1 -1
  156. package/daemon/dist/domain/queue-recovery.d.ts +10 -1
  157. package/daemon/dist/domain/queue-recovery.d.ts.map +1 -1
  158. package/daemon/dist/domain/queue-recovery.js +25 -3
  159. package/daemon/dist/domain/queue-recovery.js.map +1 -1
  160. package/daemon/dist/domain/queue-repository.d.ts +23 -2
  161. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  162. package/daemon/dist/domain/queue-repository.js +77 -4
  163. package/daemon/dist/domain/queue-repository.js.map +1 -1
  164. package/daemon/dist/domain/queue-retention.d.ts +1 -1
  165. package/daemon/dist/domain/queue-retention.d.ts.map +1 -1
  166. package/daemon/dist/domain/queue-retention.js +1 -0
  167. package/daemon/dist/domain/queue-retention.js.map +1 -1
  168. package/daemon/dist/domain/queue-stuck-sweep.d.ts +5 -0
  169. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  170. package/daemon/dist/domain/queue-stuck-sweep.js +335 -50
  171. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  172. package/daemon/dist/domain/receiver-context.d.ts.map +1 -1
  173. package/daemon/dist/domain/receiver-context.js +3 -2
  174. package/daemon/dist/domain/receiver-context.js.map +1 -1
  175. package/daemon/dist/domain/restore-guidance.d.ts +3 -0
  176. package/daemon/dist/domain/restore-guidance.d.ts.map +1 -1
  177. package/daemon/dist/domain/restore-guidance.js +5 -0
  178. package/daemon/dist/domain/restore-guidance.js.map +1 -1
  179. package/daemon/dist/domain/restore-orchestrator.d.ts +6 -0
  180. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  181. package/daemon/dist/domain/restore-orchestrator.js +69 -5
  182. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  183. package/daemon/dist/domain/restore-preconditions.d.ts.map +1 -1
  184. package/daemon/dist/domain/restore-preconditions.js +2 -1
  185. package/daemon/dist/domain/restore-preconditions.js.map +1 -1
  186. package/daemon/dist/domain/rigspec-instantiator.d.ts +1 -0
  187. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  188. package/daemon/dist/domain/rigspec-instantiator.js +1 -1
  189. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  190. package/daemon/dist/domain/rosters.d.ts +2 -1
  191. package/daemon/dist/domain/rosters.d.ts.map +1 -1
  192. package/daemon/dist/domain/rosters.js.map +1 -1
  193. package/daemon/dist/domain/runtime-adapter.d.ts +9 -0
  194. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  195. package/daemon/dist/domain/runtime-adapter.js +2 -0
  196. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  197. package/daemon/dist/domain/seat-delivery-guard.d.ts +3 -1
  198. package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
  199. package/daemon/dist/domain/seat-delivery-guard.js +8 -5
  200. package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
  201. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  202. package/daemon/dist/domain/seat-handover-service.js +20 -2
  203. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  204. package/daemon/dist/domain/session-transport.d.ts +2 -0
  205. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  206. package/daemon/dist/domain/session-transport.js +37 -6
  207. package/daemon/dist/domain/session-transport.js.map +1 -1
  208. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  209. package/daemon/dist/domain/startup-orchestrator.js +8 -3
  210. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  211. package/daemon/dist/domain/team-operations.d.ts +20 -0
  212. package/daemon/dist/domain/team-operations.d.ts.map +1 -0
  213. package/daemon/dist/domain/team-operations.js +23 -0
  214. package/daemon/dist/domain/team-operations.js.map +1 -0
  215. package/daemon/dist/domain/terminal/herdr-adapter.d.ts +12 -2
  216. package/daemon/dist/domain/terminal/herdr-adapter.d.ts.map +1 -1
  217. package/daemon/dist/domain/terminal/herdr-adapter.js +52 -2
  218. package/daemon/dist/domain/terminal/herdr-adapter.js.map +1 -1
  219. package/daemon/dist/domain/terminal/herdr-live-workspace.d.ts +42 -0
  220. package/daemon/dist/domain/terminal/herdr-live-workspace.d.ts.map +1 -0
  221. package/daemon/dist/domain/terminal/herdr-live-workspace.js +118 -0
  222. package/daemon/dist/domain/terminal/herdr-live-workspace.js.map +1 -0
  223. package/daemon/dist/domain/terminal/herdr-sessions.d.ts.map +1 -1
  224. package/daemon/dist/domain/terminal/herdr-sessions.js +3 -0
  225. package/daemon/dist/domain/terminal/herdr-sessions.js.map +1 -1
  226. package/daemon/dist/domain/terminal/rex-adapter.d.ts +3 -0
  227. package/daemon/dist/domain/terminal/rex-adapter.d.ts.map +1 -1
  228. package/daemon/dist/domain/terminal/rex-adapter.js +10 -1
  229. package/daemon/dist/domain/terminal/rex-adapter.js.map +1 -1
  230. package/daemon/dist/domain/terminal/rex-agent-status.d.ts +76 -0
  231. package/daemon/dist/domain/terminal/rex-agent-status.d.ts.map +1 -0
  232. package/daemon/dist/domain/terminal/rex-agent-status.js +168 -0
  233. package/daemon/dist/domain/terminal/rex-agent-status.js.map +1 -0
  234. package/daemon/dist/domain/terminal/terminal-provider.d.ts +12 -1
  235. package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
  236. package/daemon/dist/domain/terminal/terminal-service.d.ts +2 -0
  237. package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
  238. package/daemon/dist/domain/terminal/terminal-service.js +3 -2
  239. package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
  240. package/daemon/dist/domain/types.d.ts +9 -0
  241. package/daemon/dist/domain/types.d.ts.map +1 -1
  242. package/daemon/dist/domain/types.js.map +1 -1
  243. package/daemon/dist/domain/user-settings/settings-browser.d.ts +8 -2
  244. package/daemon/dist/domain/user-settings/settings-browser.d.ts.map +1 -1
  245. package/daemon/dist/domain/user-settings/settings-browser.js +5 -2
  246. package/daemon/dist/domain/user-settings/settings-browser.js.map +1 -1
  247. package/daemon/dist/domain/user-settings/settings-store.d.ts +15 -1
  248. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  249. package/daemon/dist/domain/user-settings/settings-store.js +108 -44
  250. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  251. package/daemon/dist/domain/workflow-exception-escalation.d.ts.map +1 -1
  252. package/daemon/dist/domain/workflow-exception-escalation.js +4 -2
  253. package/daemon/dist/domain/workflow-exception-escalation.js.map +1 -1
  254. package/daemon/dist/domain/workflow-validator.d.ts.map +1 -1
  255. package/daemon/dist/domain/workflow-validator.js +16 -0
  256. package/daemon/dist/domain/workflow-validator.js.map +1 -1
  257. package/daemon/dist/herdr-live-workspace-surface.d.ts +2 -0
  258. package/daemon/dist/herdr-live-workspace-surface.d.ts.map +1 -0
  259. package/daemon/dist/herdr-live-workspace-surface.js +2 -0
  260. package/daemon/dist/herdr-live-workspace-surface.js.map +1 -0
  261. package/daemon/dist/index.d.ts.map +1 -1
  262. package/daemon/dist/index.js +1 -0
  263. package/daemon/dist/index.js.map +1 -1
  264. package/daemon/dist/routes/attention.d.ts.map +1 -1
  265. package/daemon/dist/routes/attention.js +5 -1
  266. package/daemon/dist/routes/attention.js.map +1 -1
  267. package/daemon/dist/routes/hosts.d.ts.map +1 -1
  268. package/daemon/dist/routes/hosts.js +23 -14
  269. package/daemon/dist/routes/hosts.js.map +1 -1
  270. package/daemon/dist/routes/network.d.ts +7 -3
  271. package/daemon/dist/routes/network.d.ts.map +1 -1
  272. package/daemon/dist/routes/network.js +52 -17
  273. package/daemon/dist/routes/network.js.map +1 -1
  274. package/daemon/dist/routes/queue.d.ts.map +1 -1
  275. package/daemon/dist/routes/queue.js +9 -0
  276. package/daemon/dist/routes/queue.js.map +1 -1
  277. package/daemon/dist/routes/rigspec.js +13 -4
  278. package/daemon/dist/routes/rigspec.js.map +1 -1
  279. package/daemon/dist/routes/sessions.d.ts.map +1 -1
  280. package/daemon/dist/routes/sessions.js +24 -5
  281. package/daemon/dist/routes/sessions.js.map +1 -1
  282. package/daemon/dist/routes/terminal.js +1 -1
  283. package/daemon/dist/routes/terminal.js.map +1 -1
  284. package/daemon/dist/server.d.ts +1 -0
  285. package/daemon/dist/server.d.ts.map +1 -1
  286. package/daemon/dist/server.js +2 -0
  287. package/daemon/dist/server.js.map +1 -1
  288. package/daemon/dist/startup.d.ts.map +1 -1
  289. package/daemon/dist/startup.js +19 -5
  290. package/daemon/dist/startup.js.map +1 -1
  291. package/daemon/dist/tmux-server-start-surface.d.ts +2 -0
  292. package/daemon/dist/tmux-server-start-surface.d.ts.map +1 -0
  293. package/daemon/dist/tmux-server-start-surface.js +2 -0
  294. package/daemon/dist/tmux-server-start-surface.js.map +1 -0
  295. package/daemon/dist/tmux-server-start.d.ts +13 -0
  296. package/daemon/dist/tmux-server-start.d.ts.map +1 -0
  297. package/daemon/dist/tmux-server-start.js +36 -0
  298. package/daemon/dist/tmux-server-start.js.map +1 -0
  299. package/daemon/docs/reference/agent-startup-guide.md +34 -7
  300. package/daemon/docs/reference/agent-state-taxonomy.md +2 -1
  301. package/daemon/docs/reference/daemon-http-clients.md +42 -0
  302. package/daemon/docs/reference/getting-started.md +13 -8
  303. package/daemon/docs/reference/hosted-members.md +29 -3
  304. package/daemon/docs/reference/network-connector.md +76 -5
  305. package/daemon/docs/reference/operation-correlation.md +18 -2
  306. package/daemon/docs/reference/queue-erasure.md +7 -5
  307. package/daemon/docs/reference/quickstart.md +2 -2
  308. package/daemon/docs/reference/rig-spec.md +4 -0
  309. package/daemon/docs/reference/seat-delivery.md +16 -1
  310. package/daemon/docs/reference/terminal-sessions.md +12 -0
  311. package/daemon/docs/reference/tmux-servers.md +8 -2
  312. package/daemon/docs/reference/whats-new.md +153 -15
  313. package/daemon/specs/agents/shared/skills/core/working-with-an-openrig-team/SKILL.md +7 -0
  314. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +27 -11
  315. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/startup/context.md +11 -3
  316. package/dist/build-info.js +3 -3
  317. package/dist/commands/broadcast.js +7 -3
  318. package/dist/commands/broadcast.js.map +1 -1
  319. package/dist/commands/chatroom.d.ts.map +1 -1
  320. package/dist/commands/chatroom.js +8 -3
  321. package/dist/commands/chatroom.js.map +1 -1
  322. package/dist/commands/config.d.ts.map +1 -1
  323. package/dist/commands/config.js +50 -10
  324. package/dist/commands/config.js.map +1 -1
  325. package/dist/commands/daemon.d.ts +0 -4
  326. package/dist/commands/daemon.d.ts.map +1 -1
  327. package/dist/commands/daemon.js +1 -19
  328. package/dist/commands/daemon.js.map +1 -1
  329. package/dist/commands/doctor.js +1 -1
  330. package/dist/commands/doctor.js.map +1 -1
  331. package/dist/commands/down.d.ts.map +1 -1
  332. package/dist/commands/down.js +2 -1
  333. package/dist/commands/down.js.map +1 -1
  334. package/dist/commands/gateway.d.ts.map +1 -1
  335. package/dist/commands/gateway.js +5 -0
  336. package/dist/commands/gateway.js.map +1 -1
  337. package/dist/commands/host.js +2 -2
  338. package/dist/commands/host.js.map +1 -1
  339. package/dist/commands/import.d.ts.map +1 -1
  340. package/dist/commands/import.js +96 -3
  341. package/dist/commands/import.js.map +1 -1
  342. package/dist/commands/network.d.ts.map +1 -1
  343. package/dist/commands/network.js +72 -17
  344. package/dist/commands/network.js.map +1 -1
  345. package/dist/commands/ps.d.ts.map +1 -1
  346. package/dist/commands/ps.js +44 -0
  347. package/dist/commands/ps.js.map +1 -1
  348. package/dist/commands/queue.d.ts.map +1 -1
  349. package/dist/commands/queue.js +61 -3
  350. package/dist/commands/queue.js.map +1 -1
  351. package/dist/commands/roster.d.ts +2 -4
  352. package/dist/commands/roster.d.ts.map +1 -1
  353. package/dist/commands/roster.js +3 -12
  354. package/dist/commands/roster.js.map +1 -1
  355. package/dist/commands/seat.js +2 -2
  356. package/dist/commands/seat.js.map +1 -1
  357. package/dist/commands/send.d.ts +4 -0
  358. package/dist/commands/send.d.ts.map +1 -1
  359. package/dist/commands/send.js +6 -1
  360. package/dist/commands/send.js.map +1 -1
  361. package/dist/commands/setup.js +1 -1
  362. package/dist/commands/setup.js.map +1 -1
  363. package/dist/commands/terminal.d.ts.map +1 -1
  364. package/dist/commands/terminal.js +9 -7
  365. package/dist/commands/terminal.js.map +1 -1
  366. package/dist/config-store.d.ts +14 -1
  367. package/dist/config-store.d.ts.map +1 -1
  368. package/dist/config-store.js +34 -5
  369. package/dist/config-store.js.map +1 -1
  370. package/dist/lib/check-in.d.ts +7 -0
  371. package/dist/lib/check-in.d.ts.map +1 -0
  372. package/dist/lib/check-in.js +13 -0
  373. package/dist/lib/check-in.js.map +1 -0
  374. package/dist/mcp-http.d.ts.map +1 -1
  375. package/dist/mcp-http.js +25 -2
  376. package/dist/mcp-http.js.map +1 -1
  377. package/dist/mcp-server.d.ts +12 -1
  378. package/dist/mcp-server.d.ts.map +1 -1
  379. package/dist/mcp-server.js +185 -57
  380. package/dist/mcp-server.js.map +1 -1
  381. package/dist/person-registration-offer.d.ts +10 -0
  382. package/dist/person-registration-offer.d.ts.map +1 -0
  383. package/dist/person-registration-offer.js +25 -0
  384. package/dist/person-registration-offer.js.map +1 -0
  385. package/dist/terminal-window.d.ts.map +1 -1
  386. package/dist/terminal-window.js +20 -102
  387. package/dist/terminal-window.js.map +1 -1
  388. package/dist/tmux-attachment.d.ts.map +1 -1
  389. package/dist/tmux-attachment.js +3 -1
  390. package/dist/tmux-attachment.js.map +1 -1
  391. package/package.json +1 -1
  392. package/tui/dist/config/pairing.d.ts.map +1 -1
  393. package/tui/dist/config/pairing.js +8 -3
  394. package/tui/dist/config/pairing.js.map +1 -1
  395. package/tui/dist/connected-assistants.d.ts +20 -0
  396. package/tui/dist/connected-assistants.d.ts.map +1 -0
  397. package/tui/dist/connected-assistants.js +51 -0
  398. package/tui/dist/connected-assistants.js.map +1 -0
  399. package/tui/dist/daemon-client.d.ts +8 -0
  400. package/tui/dist/daemon-client.d.ts.map +1 -1
  401. package/tui/dist/daemon-client.js +8 -0
  402. package/tui/dist/daemon-client.js.map +1 -1
  403. package/tui/dist/hydrate.d.ts.map +1 -1
  404. package/tui/dist/hydrate.js +13 -2
  405. package/tui/dist/hydrate.js.map +1 -1
  406. package/tui/dist/render.d.ts.map +1 -1
  407. package/tui/dist/render.js +4 -0
  408. package/tui/dist/render.js.map +1 -1
  409. package/tui/dist/topology/glyphs.d.ts.map +1 -1
  410. package/tui/dist/topology/glyphs.js +4 -0
  411. package/tui/dist/topology/glyphs.js.map +1 -1
  412. package/tui/dist/types.d.ts +11 -0
  413. package/tui/dist/types.d.ts.map +1 -1
@@ -1,6 +1,7 @@
1
1
  import { currentParkedOwnerNoInputFailure } from "./policies/parked-owner-consumer.js";
2
2
  import { resolveEscalationOwner, ESCALATION_HOP_TAG, hasConsumedEscalationHop } from "./escalation-owner.js";
3
- import { createRecoveryLookup, recoveryId, recoveryTag } from "./queue-recovery.js";
3
+ import { BACKLOG_FOLDED_TAG, createRecoveryLookup, findQueueRecovery, freshRecoveryId, recoveryTag } from "./queue-recovery.js";
4
+ export { BACKLOG_FOLDED_TAG };
4
5
  import { quietHoldCustody } from "./quiet-hold-custody.js";
5
6
  import { queueWaitNotice } from "./queue-wait-backoff.js";
6
7
  import { lastMeaningfulTransition, pendingSince } from "./queue-waiting.js";
@@ -98,6 +99,41 @@ export function unclaimedBacklogTag(seat) {
98
99
  }
99
100
  /** How many of a seat's unclaimed rows its standing notice lists by id; the rest are counted. */
100
101
  export const UNCLAIMED_BACKLOG_LISTED_ROWS = 20;
102
+ /** #2988: the key of a notice sent to a seat's delegation parent is `<child seat>=><parent>`; a seat's own notice is keyed
103
+ * by the seat alone. */
104
+ const PARENT_BACKLOG_SEPARATOR = "=>";
105
+ /** Review of #3049: a polling member's notice the sweep filed to the one creator of every row it listed carries this
106
+ * prefix followed by that creator. Only this mark establishes that the notice shows that creator's rows alone; an old
107
+ * recipient the sweep doesn't recognize proves nothing (the operator setting may have changed). It names the creator
108
+ * rather than trusting the notice's destination: a queue handoff copies the tags to a successor elsewhere, and a
109
+ * fallback changes the destination in place. */
110
+ const BACKLOG_TO_CREATOR_PREFIX = "stuck-sweep-backlog-to-creator:";
111
+ const creatorMark = (creator) => `${BACKLOG_TO_CREATOR_PREFIX}${creator}`;
112
+ /** The creator a notice's stored tags name in its mark, or null: no mark, more than one, or tags that don't read as a JSON
113
+ * array name none. */
114
+ function markedCreator(tags) {
115
+ try {
116
+ const parsed = JSON.parse(tags ?? "[]");
117
+ if (!Array.isArray(parsed))
118
+ return null;
119
+ const marks = parsed.filter((t) => typeof t === "string" && t.startsWith(BACKLOG_TO_CREATOR_PREFIX)
120
+ && t.length > BACKLOG_TO_CREATOR_PREFIX.length);
121
+ return marks.length === 1 ? marks[0].slice(BACKLOG_TO_CREATOR_PREFIX.length) : null;
122
+ }
123
+ catch {
124
+ return null;
125
+ }
126
+ }
127
+ /** Idempotency key of the standing unclaimed-backlog notice a delegation parent gets for one child seat's rows: one open
128
+ * notice per (parent, child). */
129
+ export function parentBacklogTag(parent, child) {
130
+ return unclaimedBacklogTag(`${child}${PARENT_BACKLOG_SEPARATOR}${parent}`);
131
+ }
132
+ /** The seat a notice's key stands for and, for a notice sent to its delegation parent, that parent. */
133
+ function backlogKeyParts(key) {
134
+ const at = key.indexOf(PARENT_BACKLOG_SEPARATOR);
135
+ return at < 0 ? { seat: key, parent: null } : { seat: key.slice(0, at), parent: key.slice(at + PARENT_BACKLOG_SEPARATOR.length) };
136
+ }
101
137
  /** The loop's observable heartbeat — surfaced on /healthz so a quiet sweep is cheap but
102
138
  * never invisible, and a failing sweep is loud without needing a row. */
103
139
  export function createStuckSweepStatus() {
@@ -379,7 +415,8 @@ function deliveryResolutionEvidence(deps, kind, qitemId, now) {
379
415
  if (kind === "unclaimed-obligation" && !quiet && deps.queueRepo.isRegisteredHumanUpdate(row) && !deps.queueRepo.deliveryOutcomeFor(qitemId)) {
380
416
  return "informational update to a registered human requires no claim";
381
417
  }
382
- if (kind !== "undelivered-human-notice" && row.lastNudgeResult === "retained:typing_guard") {
418
+ // A temporary hold resolves a failed wake, but unclaimed work still needs its existing standing finding.
419
+ if (kind === "undelivered-wake" && row.lastNudgeResult === "retained:typing_guard") {
383
420
  return "source wake held by the seat typing guard";
384
421
  }
385
422
  return null;
@@ -475,6 +512,30 @@ function unclaimedBacklogText(seat, rows, thresholdMinutes, node) {
475
512
  `${BACKLOG_ROWS_PREFIX}${JSON.stringify(sorted.map((r) => r.qitemId))}`,
476
513
  };
477
514
  }
515
+ /** #2988: the standing notice a delegation parent gets for one child seat's unclaimed rows. It tells the parent about the
516
+ * child's backlog; it claims, moves and completes none of it. Built from the rows' fixed facts, as the seat's own notice
517
+ * is, so a pass rewrites it only when the rows change. */
518
+ function parentBacklogText(child, parent, rows, thresholdMinutes, routedHere) {
519
+ const { sorted, listed, count } = backlogListing(rows);
520
+ return {
521
+ summary: `Stuck sweep: unclaimed-backlog on ${child}, for its delegation parent ${parent} (${count})`,
522
+ body: `STUCK SWEEP FINDING (unclaimed-backlog)\n` +
523
+ `parent: ${parent}\n` +
524
+ `child seat: ${child}\n` +
525
+ `unclaimed: ${count} (the threshold is ${thresholdMinutes} min)\n` +
526
+ `${listed.join("\n")}\n` +
527
+ `why: this is the backlog of ${child}, a seat ${parent} delegates to. Nobody has claimed these rows there, so ` +
528
+ `${parent} is told about them in this one notice instead of a finding per row. It follows the rows as they come and ` +
529
+ `go, and is rewritten in place without a new wake. This notice doesn't claim, move or complete any of them: they ` +
530
+ `stay with ${child} until someone claims, reroutes or closes them.\n` +
531
+ (routedHere ? "" : `note: ${child}'s rows no longer go to ${parent}. This notice keeps standing for them until the sweep ` +
532
+ `finds them stuck again and they go where ${child}'s rows go now.\n`) +
533
+ `List them: rig queue list --destination ${child} --state pending\n` +
534
+ `The sweep closes this notice itself once every row it stands for is claimed, parked or closed, or no longer goes ` +
535
+ `to ${parent}.\n` +
536
+ `${BACKLOG_ROWS_PREFIX}${JSON.stringify(sorted.map((r) => r.qitemId))}`,
537
+ };
538
+ }
478
539
  /** A polling hosted member's standing notice: whether it's checking in (its own inbox reads), the rows it hasn't claimed,
479
540
  * 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
480
541
  * 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
@@ -573,7 +634,9 @@ export async function runStuckSweep(deps) {
573
634
  /** Each seat's agent-seat reading (agentSeatNode, below), dropped with the indexes: another writer can declare a
574
635
  * seat's delegation parent while the pass yields or awaits a write. */
575
636
  const agentSeats = new Map();
576
- const othersMayHaveRun = () => { othersRan++; recoveries.invalidate(); successors?.invalidate(); agentSeats.clear(); };
637
+ /** #2988: each seat's one declared delegation parent (parentNow, below), dropped with agentSeats. */
638
+ const parentsNow = new Map();
639
+ const othersMayHaveRun = () => { othersRan++; recoveries.invalidate(); successors?.invalidate(); agentSeats.clear(); parentsNow.clear(); };
577
640
  // A successor index whose build took at least half of a stretch that yielded by elapsed time is not rebuilt for
578
641
  // the rest of the pass: the yield drops it, the next stretch would pay the build again and end the same way after a
579
642
  // few rows, so the rows would pay about one build each instead of one per STUCK_SWEEP_YIELD_EVERY_ROWS. Those rows
@@ -604,6 +667,8 @@ export async function runStuckSweep(deps) {
604
667
  const ageMinutes = deps.unclaimedAgeMinutes ?? resolveStuckSweepUnclaimedAgeMinutes();
605
668
  const routeNotes = new Map();
606
669
  const routed = new Set();
670
+ /** #2988: the row's route was its seat's one declared delegation parent (resolveEscalationOwner outcome "parent"). */
671
+ const delegationParent = new Map();
607
672
  const resolveOrch = (session, row) => {
608
673
  if (hasConsumedEscalationHop(deps.db, row.qitemId)) {
609
674
  routeNotes.set(row.qitemId, "escalates_to one-hop delivery already used; existing fallback retained");
@@ -616,6 +681,10 @@ export async function runStuckSweep(deps) {
616
681
  routeNotes.set(row.qitemId, route.reason);
617
682
  if (route.outcome === "routed")
618
683
  routed.add(row.qitemId);
684
+ if (route.outcome === "parent" && route.owner)
685
+ delegationParent.set(row.qitemId, route.owner);
686
+ else
687
+ delegationParent.delete(row.qitemId);
619
688
  return route.owner;
620
689
  };
621
690
  const isRegisteredHost = deps.isRegisteredHost ?? defaultIsRegisteredHost(log);
@@ -1281,16 +1350,43 @@ export async function runStuckSweep(deps) {
1281
1350
  // declares (a delegation parent or escalates_to) takes them.
1282
1351
  const polledUnclaimed = (c) => c.kind === "unclaimed-obligation" && c.noWake === true
1283
1352
  && !routeNotes.has(c.row.qitemId) && polledRow(c.row);
1284
- /** The standing notice a candidate belongs to (the seat or member it stands for), or null for a finding of its own. */
1285
- const backlogKeyOf = (c) => polledUnclaimed(c) ? c.row.destinationSession : selfRoutedUnclaimed(c) ? c.route : null;
1353
+ // #2988: an unclaimed row whose finding goes to its seat's one declared delegation parent (a live seat the re-routes
1354
+ // left in place) shares one standing notice per (parent, child seat) instead of a finding per row, each waking the
1355
+ // parent. A route the row's seat declares otherwise (escalates_to, a consumed hop, a re-route) keeps a finding per row.
1356
+ const parentRoutedUnclaimed = (c) => c.kind === "unclaimed-obligation" && c.noWake !== true
1357
+ && c.route !== c.row.destinationSession && delegationParent.get(c.row.qitemId) === c.route
1358
+ && !routeNotes.has(c.row.qitemId) && !routed.has(c.row.qitemId);
1359
+ /** The standing notice a candidate belongs to (the seat or member it stands for, or the parent and child seat), or null
1360
+ * for a finding of its own. */
1361
+ const backlogKeyOf = (c) => polledUnclaimed(c) ? c.row.destinationSession : selfRoutedUnclaimed(c) ? c.route
1362
+ : parentRoutedUnclaimed(c) ? `${c.row.destinationSession}${PARENT_BACKLOG_SEPARATOR}${c.route}` : null;
1363
+ /** #2988's transition: an open per-row unclaimed finding the sweep filed to the parent before, for a row that now joins
1364
+ * that parent's notice. It's folded in (closed, once the notice that takes its row is written) rather than kept
1365
+ * beside the notice. Keyed by the row; the value is the per-row finding. */
1366
+ const foldFrom = new Map();
1367
+ /** The per-row finding this candidate's row would fold into a parent's notice, or null. */
1368
+ const foldable = (c, shared) => {
1369
+ // Only one nobody has taken up: a finding the parent claimed or parked is its work now, and stays as it is.
1370
+ if (!shared || shared.state !== "pending" || !parentRoutedUnclaimed(c))
1371
+ return null;
1372
+ const finding = indexed(() => deps.queueRepo.getById(shared.qitemId, { waiting: false }));
1373
+ return finding && isFindingRow(finding) && finding.state === "pending" && !finding.claimedAt
1374
+ && finding.destinationSession === c.route
1375
+ && (finding.tags ?? []).includes(findingDedupTag("unclaimed-obligation", c.row.qitemId)) ? finding.qitemId : null;
1376
+ };
1286
1377
  const unclaimedBacklog = new Map();
1287
1378
  for (const c of [...new Map(candidates.map(c => [c.row.qitemId, c])).values()]) {
1288
1379
  if (dueToYield())
1289
1380
  await yieldLoop();
1290
1381
  const dedupTag = findingDedupTag(c.kind, c.row.qitemId);
1291
1382
  const shared = recoveries.find(c.row.qitemId);
1292
- const backlogKey = shared ? null : backlogKeyOf(c);
1383
+ const fold = foldable(c, shared);
1384
+ const backlogKey = shared && !fold ? null : backlogKeyOf(c);
1293
1385
  if (backlogKey) {
1386
+ if (fold)
1387
+ foldFrom.set(c.row.qitemId, fold);
1388
+ else
1389
+ foldFrom.delete(c.row.qitemId);
1294
1390
  const rows = unclaimedBacklog.get(backlogKey);
1295
1391
  if (rows)
1296
1392
  rows.push(c);
@@ -1341,7 +1437,7 @@ export async function runStuckSweep(deps) {
1341
1437
  // The first term is implied by the second (its pattern starts with that literal); it lets
1342
1438
  // the planner use idx_queue_items_recovery_tags (migration 099) instead of a full scan.
1343
1439
  `SELECT qitem_id, source_session, state, ts_updated FROM queue_items
1344
- WHERE (tags LIKE '%"stuck-sweep:%') AND tags LIKE ?
1440
+ WHERE (tags LIKE '%"stuck-sweep:%') AND tags LIKE ? AND tags NOT LIKE '%"${BACKLOG_FOLDED_TAG}"%'
1345
1441
  ORDER BY CASE WHEN state IN ('pending', 'in-progress', 'blocked') THEN 0 ELSE 1 END,
1346
1442
  ts_updated DESC, ts_created DESC, qitem_id DESC
1347
1443
  LIMIT 1`)
@@ -1362,7 +1458,8 @@ export async function runStuckSweep(deps) {
1362
1458
  continue;
1363
1459
  routeCandidate(now_); // its destination, reason and targets as they are now
1364
1460
  const input = {
1365
- qitemId: recoveryId(deps.db, c.row.qitemId, renewedDeadline ? c.row.closureRequiredAt : undefined),
1461
+ // A finding folded into a parent's notice (#2988) holds its id without owning the row: a new one gets its own.
1462
+ qitemId: freshRecoveryId(deps.db, c.row.qitemId, renewedDeadline ? c.row.closureRequiredAt : undefined),
1366
1463
  // The detector is machinery, not a seat: the obligation's own creator is the
1367
1464
  // finding's source (the workflow-exception precedent).
1368
1465
  sourceSession: c.row.sourceSession,
@@ -1381,6 +1478,11 @@ export async function runStuckSweep(deps) {
1381
1478
  try {
1382
1479
  const created = await deps.queueRepo.create(input);
1383
1480
  othersMayHaveRun();
1481
+ // An existing row with this id, same source and destination, comes back as an idempotent retry: a closed one is
1482
+ // no finding for the row now, so it's reported, never counted as created.
1483
+ if (!["pending", "in-progress", "blocked"].includes(created.state)) {
1484
+ throw new Error(`${created.qitemId} already exists and is ${created.state}`);
1485
+ }
1384
1486
  findings.push({ kind: c.kind, qitemId: c.row.qitemId, findingQitemId: created.qitemId, action: "created" });
1385
1487
  }
1386
1488
  catch (err) {
@@ -1409,28 +1511,134 @@ export async function runStuckSweep(deps) {
1409
1511
  }
1410
1512
  catch { /* Skip malformed tags */ }
1411
1513
  }
1412
- for (const seat of backlogSeats) {
1514
+ /** #2988: the one declared delegation parent a seat's rows go to now, or null (none, several, another route, or a
1515
+ * resolver the caller supplied, whose outcome isn't known). Read once per seat until other code may have run. */
1516
+ const parentNow = (seat) => {
1517
+ if (deps.resolveOrchestrator)
1518
+ return null;
1519
+ if (!parentsNow.has(seat)) {
1520
+ const route = resolveEscalationOwner(deps.db, seat, target => deps.queueRepo.acceptsDestination(target));
1521
+ parentsNow.set(seat, route.outcome === "parent" ? route.owner : null);
1522
+ }
1523
+ return parentsNow.get(seat);
1524
+ };
1525
+ /** #2988: the open notice with this key lists the row (one actually written: a create that failed leaves the row
1526
+ * where it was). */
1527
+ const openNoticeLists = (tag, id) => {
1528
+ const open = deps.db.prepare(`SELECT body FROM queue_items WHERE state IN ('pending', 'in-progress', 'blocked')
1529
+ AND (tags LIKE '%"stuck-sweep:%') AND tags LIKE ? ESCAPE '\\' LIMIT 1`)
1530
+ .get(`%"${tag.replace(/[\\%_]/g, (ch) => `\\${ch}`)}"%`);
1531
+ return open ? backlogRowsOf(open.body)?.has(id) === true : false;
1532
+ };
1533
+ /** #2988: an open notice to this seat's delegation parent lists the row. */
1534
+ const parentNoticeStandsFor = (seat, id) => {
1535
+ const parent = parentNow(seat);
1536
+ return parent ? openNoticeLists(parentBacklogTag(parent, seat), id) : false;
1537
+ };
1538
+ /** #2988: a row a parent's notice stands for no longer goes to that parent (another parent, none, or a used hop). The
1539
+ * notice lets go of it only once something written stands for it where it goes now: the open notice it goes to lists
1540
+ * it, or a closed one there holds it back this pass (a finding of its own lets go of it before this). Under a detection
1541
+ * filter (a raised threshold, the wake ladder), or while that notice can't be written, nothing does, and the old notice
1542
+ * keeps standing for it: a detection filter never reads as done. A pass files a seat's rows before it reads the notices no row goes to, so a
1543
+ * row usually moves in one pass; at worst it is in both notices for one more. */
1544
+ /** #2988: per notice key, the rows a closed notice held back this pass (below), so a notice a row leaves can tell. */
1545
+ const heldBack = new Map();
1546
+ const coveredElsewhere = (seat, id) => {
1547
+ if (hasConsumedEscalationHop(deps.db, id))
1548
+ return false;
1549
+ const next = parentNow(seat);
1550
+ const tag = next ? parentBacklogTag(next, seat) : unclaimedBacklogTag(seat);
1551
+ // A closed notice there that holds the row back (dismissed by where it goes now) stands for it too.
1552
+ return openNoticeLists(tag, id) || heldBack.get(tag)?.has(id) === true;
1553
+ };
1554
+ /** Closes the per-row findings a parent's notice now stands for (#2988's transition), once that notice is written. The
1555
+ * rows and their findings were read before the pass yielded and awaited writes, so each fold rechecks, right before
1556
+ * it writes and with nothing awaited in between, everything it rests on: the row still waits unclaimed at the
1557
+ * seat, the seat's one declared delegation parent is still this parent (and the row's one hop unused), the
1558
+ * finding is still the row's open recovery, nobody's taken it up, and the written notice is open and lists the
1559
+ * row. Anything else, or anything it can't read, leaves the finding open and unmarked. */
1560
+ const foldInto = async (noticeId, seat, parent, rowIds) => {
1561
+ for (const id of rowIds) {
1562
+ const findingId = foldFrom.get(id);
1563
+ if (!findingId)
1564
+ continue;
1565
+ foldFrom.delete(id);
1566
+ if (dueToYield())
1567
+ await yieldLoop();
1568
+ const row = deps.queueRepo.getById(id, { waiting: false });
1569
+ if (!row || row.state !== "pending" || row.claimedAt || row.destinationSession !== seat)
1570
+ continue;
1571
+ if (deps.resolveOrchestrator || hasConsumedEscalationHop(deps.db, id))
1572
+ continue;
1573
+ // The whole rule that made the row's finding, on the row as it is now (a wake that failed meanwhile, a person's
1574
+ // ask, a live ladder), not only its state.
1575
+ if (!unclaimedCandidate(id, false))
1576
+ continue;
1577
+ const route = resolveEscalationOwner(deps.db, seat, target => deps.queueRepo.acceptsDestination(target));
1578
+ if (route.outcome !== "parent" || route.owner !== parent)
1579
+ continue;
1580
+ const finding = deps.db.prepare("SELECT state, claimed_at, destination_session FROM queue_items WHERE qitem_id = ?").get(findingId);
1581
+ if (!finding || finding.state !== "pending" || finding.claimed_at || finding.destination_session !== parent)
1582
+ continue;
1583
+ if (findQueueRecovery(deps.db, id)?.qitemId !== findingId)
1584
+ continue;
1585
+ // The notice still reaches the parent: one that changed hands (a handoff, a fallback) isn't the parent's signal.
1586
+ const notice = deps.db.prepare("SELECT state, body, destination_session FROM queue_items WHERE qitem_id = ?").get(noticeId);
1587
+ if (!notice || !["pending", "in-progress", "blocked"].includes(notice.state) || notice.destination_session !== parent
1588
+ || backlogRowsOf(notice.body)?.has(id) !== true)
1589
+ continue;
1590
+ try {
1591
+ // The mark and the close together: a close that fails leaves the finding open and unmarked, as it was.
1592
+ deps.db.transaction(() => {
1593
+ deps.db.prepare(`UPDATE queue_items SET tags = json_insert(tags, '$[#]', ?) WHERE qitem_id = ? AND json_valid(tags)
1594
+ AND NOT EXISTS (SELECT 1 FROM json_each(tags) WHERE value = ?)`).run(BACKLOG_FOLDED_TAG, findingId, BACKLOG_FOLDED_TAG);
1595
+ deps.queueRepo.update({
1596
+ qitemId: findingId,
1597
+ actorSession: "stuck-sweep@system",
1598
+ state: "done",
1599
+ closureReason: "no-follow-on",
1600
+ transitionNote: `stuck-sweep folded: unclaimed-obligation on ${id} into the standing unclaimed-backlog notice ${noticeId} for ${parent}, which now stands for this row`,
1601
+ });
1602
+ })();
1603
+ findings.push({ kind: "unclaimed-obligation", qitemId: id, findingQitemId: findingId, action: "closed" });
1604
+ }
1605
+ catch (err) {
1606
+ const message = `unclaimed-obligation finding ${findingId} for ${id} not folded into ${noticeId}: ${err instanceof Error ? err.message : String(err)}`;
1607
+ log(`[stuck-sweep] ${message}`);
1608
+ failedCreates.push(message);
1609
+ }
1610
+ othersMayHaveRun();
1611
+ }
1612
+ };
1613
+ for (const key of backlogSeats) {
1413
1614
  if (dueToYield())
1414
1615
  await yieldLoop();
1415
- const rows = unclaimedBacklog.get(seat) ?? [];
1416
- const tag = unclaimedBacklogTag(seat);
1616
+ const rows = unclaimedBacklog.get(key) ?? [];
1617
+ const { seat, parent } = backlogKeyParts(key);
1618
+ const tag = parent ? parentBacklogTag(parent, seat) : unclaimedBacklogTag(seat);
1417
1619
  liveDedupTags.add(tag);
1418
1620
  const node = agentSeatNode(seat);
1419
- // A polling member's notice says whether it's checking in; an agent seat's names the route to add instead.
1420
- const polled = rows.length > 0 ? rows.some(polledUnclaimed) : pollsForWork(seat);
1421
- const backlogText = (standsFor) => polled
1422
- ? polledBacklogText(seat, standsFor, ageMinutes, deps.queueRepo.hostedMemberCheckIn(seat, now), now)
1423
- : unclaimedBacklogText(seat, standsFor, ageMinutes, node);
1621
+ // A polling member's notice says whether it's checking in; an agent seat's names the route to add instead; a
1622
+ // parent's says whose backlog it is.
1623
+ const polled = !parent && (rows.length > 0 ? rows.some(polledUnclaimed) : pollsForWork(seat));
1624
+ const backlogText = (standsFor) => parent
1625
+ ? parentBacklogText(seat, parent, standsFor, ageMinutes, parentNow(seat) === parent)
1626
+ : polled
1627
+ ? polledBacklogText(seat, standsFor, ageMinutes, deps.queueRepo.hostedMemberCheckIn(seat, now), now)
1628
+ : unclaimedBacklogText(seat, standsFor, ageMinutes, node);
1424
1629
  // A polling member's notice goes where its rows' findings went: the person, else their creator when they share one,
1425
- // else the operator agent. With none, it stays with the member, which reads it when it next checks.
1630
+ // else the operator agent. With none, it stays with the member, which reads it when it next checks. A parent's
1631
+ // notice goes to the parent.
1426
1632
  const recipientFor = (creators) => {
1633
+ if (parent)
1634
+ return parent;
1427
1635
  if (!polled)
1428
1636
  return seat;
1429
1637
  const distinct = [...new Set(creators)];
1430
1638
  return noWakeRecipient(seat, distinct.length === 1 ? distinct[0] : null).seat ?? seat;
1431
1639
  };
1432
- /** Files a notice and wakes its recipient; false when the create failed (reported in failedCreates). */
1433
- const fileNotice = async (text, recipient) => {
1640
+ /** Files a notice and wakes its recipient; its id, or null when the create failed (reported in failedCreates). */
1641
+ const fileNotice = async (text, recipient, creators = []) => {
1434
1642
  try {
1435
1643
  const created = await deps.queueRepo.create({
1436
1644
  // A notice about a seat's own rows comes from that seat, as a restore notice does; OpenRig wakes its recipient.
@@ -1439,25 +1647,27 @@ export async function runStuckSweep(deps) {
1439
1647
  body: text.body,
1440
1648
  summary: text.summary,
1441
1649
  evidenceRef: `rig queue list --destination ${seat} --state pending`,
1442
- tags: [STUCK_SWEEP_FINDING_TAG, tag],
1650
+ tags: [STUCK_SWEEP_FINDING_TAG, tag,
1651
+ ...(polled && recipient !== seat && creators.length > 0 && creators.every((c) => c === recipient)
1652
+ ? [creatorMark(recipient)] : [])],
1443
1653
  wakeTrigger: "openrig",
1444
1654
  });
1445
1655
  othersMayHaveRun();
1446
- findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: created.qitemId, action: "created" });
1447
- return true;
1656
+ findings.push({ kind: "unclaimed-backlog", qitemId: key, findingQitemId: created.qitemId, action: "created" });
1657
+ return created.qitemId;
1448
1658
  }
1449
1659
  catch (err) {
1450
- const message = `unclaimed-backlog notice for ${seat} not created: ${err instanceof Error ? err.message : String(err)}`;
1660
+ const message = `unclaimed-backlog notice for ${parent ? `${seat}, to its delegation parent ${parent},` : seat} not created: ${err instanceof Error ? err.message : String(err)}`;
1451
1661
  othersMayHaveRun();
1452
1662
  log(`[stuck-sweep] ${message}`);
1453
1663
  failedCreates.push(message);
1454
- return false;
1664
+ return null;
1455
1665
  }
1456
1666
  };
1457
1667
  const last = deps.db
1458
1668
  .prepare(
1459
1669
  // The first term lets the planner use idx_queue_items_recovery_tags, as the finding lookup above does.
1460
- `SELECT qitem_id, state, ts_updated, summary, body, destination_session FROM queue_items
1670
+ `SELECT qitem_id, state, ts_updated, summary, body, destination_session, tags FROM queue_items
1461
1671
  WHERE (tags LIKE '%"stuck-sweep:%') AND tags LIKE ? ESCAPE '\\'
1462
1672
  ORDER BY CASE WHEN state IN ('pending', 'in-progress', 'blocked') THEN 0 ELSE 1 END,
1463
1673
  ts_updated DESC, ts_created DESC, qitem_id DESC
@@ -1465,32 +1675,90 @@ export async function runStuckSweep(deps) {
1465
1675
  .get(`%"${tag.replace(/[\\%_]/g, (ch) => `\\${ch}`)}"%`);
1466
1676
  if (last && ["pending", "in-progress", "blocked"].includes(last.state)) {
1467
1677
  const listedNow = new Set(rows.map((c) => c.row.qitemId));
1468
- const stoodFor = backlogRowsOf(last.body);
1469
- const still = [...(stoodFor ?? [])].filter((id) => !listedNow.has(id)).flatMap((id) => {
1678
+ // An unreadable list is rebuilt as every row still waiting unclaimed at the seat: all it could have stood for that
1679
+ // nothing has resolved yet, and maybe more, never just the rows that qualify on this pass (review of #3049). From
1680
+ // there the notice follows its rows as any other: it lets go of each one only as it's resolved or covered elsewhere.
1681
+ // A member's notice the sweep marked as filed to the one creator of its rows only ever listed that creator's rows:
1682
+ // the mark alone proves it, and it names that creator, whoever holds the notice now (any rewrite that brings in
1683
+ // another creator's row drops it). Without the mark (an operator that is no longer recognized, an older notice,
1684
+ // unreadable tags), it carries every unresolved row.
1685
+ const readable = backlogRowsOf(last.body);
1686
+ const onlyFrom = markedCreator(last.tags);
1687
+ const stoodFor = readable ?? new Set(deps.db.prepare(`SELECT qitem_id FROM queue_items WHERE destination_session = ?
1688
+ AND state = 'pending' AND claimed_at IS NULL AND (? IS NULL OR source_session = ?)
1689
+ AND NOT (json_valid(tags) AND EXISTS (SELECT 1 FROM json_each(tags) WHERE value = ?))`)
1690
+ .all(seat, onlyFrom, onlyFrom, STUCK_SWEEP_FINDING_TAG).map((r) => r.qitem_id));
1691
+ // #2988: rows this notice lets go of only because something else stands for them now (a finding of their own,
1692
+ // another parent's or the seat's own notice, a temporary typing hold, or this pass's route for them). Nothing resolved them, so a notice the
1693
+ // sweep closes doesn't hold them back: they leave its list before it closes.
1694
+ const routedAway = new Set();
1695
+ // Read within the sweep's bounded yield (a rebuilt list can be long); a notice changed meanwhile is left for the next pass.
1696
+ const still = [];
1697
+ let yielded = false;
1698
+ for (const id of [...stoodFor].filter((x) => !listedNow.has(x))) {
1699
+ if (dueToYield()) {
1700
+ await yieldLoop();
1701
+ yielded = true;
1702
+ }
1470
1703
  const row = indexed(() => deps.queueRepo.getById(id, { waiting: false }));
1471
- // Gone, someone else's now, resolved at its source, or held by a finding or recovery of its own: one actually
1472
- // written, so a create that failed this pass leaves the row here.
1473
- if (!row || row.destinationSession !== seat || recoveries.find(id)
1474
- || deliveryResolutionEvidence(deps, "unclaimed-obligation", id, now))
1475
- return [];
1476
- return [{ qitemId: id, since: pendingSince(deps.db, id) ?? row.tsCreated, from: row.sourceSession, summary: row.summary }];
1477
- });
1478
- const standsFor = [...rows.map(backlogRow), ...still];
1479
- // With its list unreadable, the notice may still stand for rows: it's left as it is, never closed.
1480
- if (standsFor.length === 0 && !stoodFor) {
1481
- findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "refreshed" });
1482
- continue;
1704
+ // Gone, someone else's now, or resolved at its source.
1705
+ if (!row || row.destinationSession !== seat)
1706
+ continue;
1707
+ // A typing hold is temporary custody, not a dismissal of this work. Let the closed notice release the row:
1708
+ // when the hold clears, it can qualify again even without a newer pending timestamp or wake attempt.
1709
+ if (row.state === "pending" && !row.claimedAt && row.lastNudgeResult === "retained:typing_guard") {
1710
+ routedAway.add(id);
1711
+ continue;
1712
+ }
1713
+ if (deliveryResolutionEvidence(deps, "unclaimed-obligation", id, now))
1714
+ continue;
1715
+ // Held by a finding or recovery of its own (one actually written, so a create that failed this pass leaves the row
1716
+ // here): that finding holds it back from now on, a dismissed one too. The notice lets go of it rather than also
1717
+ // holding it once closed: a fold into a parent's notice (#2988) can release that finding's custody, and the row
1718
+ // must then be able to reach a notice again.
1719
+ if (recoveries.find(id)) {
1720
+ routedAway.add(id);
1721
+ continue;
1722
+ }
1723
+ // A parent's notice lets go of a row whose seat's delegation parent is now another seat (or none), or whose one
1724
+ // escalation hop is used; a seat's own notice, of a row its new parent's notice already stands for (#2988).
1725
+ if (parent
1726
+ ? (parentNow(seat) !== parent || hasConsumedEscalationHop(deps.db, id)) && coveredElsewhere(seat, id)
1727
+ : parentNoticeStandsFor(seat, id)) {
1728
+ routedAway.add(id);
1729
+ continue;
1730
+ }
1731
+ still.push({ qitemId: id, since: pendingSince(deps.db, id) ?? row.tsCreated, from: row.sourceSession, summary: row.summary });
1732
+ }
1733
+ if (yielded) {
1734
+ const noticeNow = deps.db.prepare("SELECT state, body FROM queue_items WHERE qitem_id = ?").get(last.qitem_id);
1735
+ if (!noticeNow || !["pending", "in-progress", "blocked"].includes(noticeNow.state) || noticeNow.body !== last.body) {
1736
+ findings.push({ kind: "unclaimed-backlog", qitemId: key, findingQitemId: last.qitem_id, action: "refreshed" });
1737
+ continue;
1738
+ }
1483
1739
  }
1740
+ const standsFor = [...rows.map(backlogRow), ...still];
1484
1741
  if (standsFor.length === 0) {
1742
+ if (routedAway.size > 0 || !readable) {
1743
+ // Only the rows something resolved stay in the list the closed notice holds back. A notice whose list was
1744
+ // unreadable never knew its rows, so it holds none back.
1745
+ const kept = readable ? [...readable].filter((id) => !routedAway.has(id)) : [];
1746
+ const body = last.body.split("\n").filter((l) => !l.startsWith(BACKLOG_ROWS_PREFIX)).join("\n")
1747
+ + `\n${BACKLOG_ROWS_PREFIX}${JSON.stringify(kept)}`;
1748
+ deps.db.prepare("UPDATE queue_items SET body = ? WHERE qitem_id = ? AND body = ? AND state IN ('pending', 'in-progress', 'blocked')")
1749
+ .run(body, last.qitem_id, last.body);
1750
+ }
1485
1751
  await deps.queueRepo.update({
1486
1752
  qitemId: last.qitem_id,
1487
1753
  actorSession: "stuck-sweep@system",
1488
1754
  state: "done",
1489
1755
  closureReason: "no-follow-on",
1490
- transitionNote: `stuck-sweep resolved: unclaimed-backlog on ${seat}: every row it stood for is claimed, parked, closed or has its own finding`,
1756
+ transitionNote: parent
1757
+ ? `stuck-sweep resolved: unclaimed-backlog on ${seat} for ${parent}: every row it stood for is claimed, parked, closed, temporarily held, has its own finding or no longer goes to ${parent}`
1758
+ : `stuck-sweep resolved: unclaimed-backlog on ${seat}: every row it stood for is claimed, parked, closed, temporarily held, has its own finding or is in its delegation parent's notice`,
1491
1759
  });
1492
1760
  othersMayHaveRun();
1493
- findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "closed" });
1761
+ findings.push({ kind: "unclaimed-backlog", qitemId: key, findingQitemId: last.qitem_id, action: "closed" });
1494
1762
  continue;
1495
1763
  }
1496
1764
  // A notice that went to one of its rows' creators (no person reachable) shows that creator only rows it sent. When a
@@ -1501,7 +1769,7 @@ export async function runStuckSweep(deps) {
1501
1769
  if (polled && last.destination_session !== seat && !seesAnyRow(last.destination_session)
1502
1770
  && standsFor.some((r) => r.from !== last.destination_session)) {
1503
1771
  const recipient = recipientFor(standsFor.map((r) => r.from));
1504
- if (!(await fileNotice(backlogText(standsFor), recipient)))
1772
+ if (!(await fileNotice(backlogText(standsFor), recipient, standsFor.map((r) => r.from))))
1505
1773
  continue;
1506
1774
  await deps.queueRepo.update({
1507
1775
  qitemId: last.qitem_id,
@@ -1511,15 +1779,24 @@ export async function runStuckSweep(deps) {
1511
1779
  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}`,
1512
1780
  });
1513
1781
  othersMayHaveRun();
1514
- findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "closed" });
1782
+ findings.push({ kind: "unclaimed-backlog", qitemId: key, findingQitemId: last.qitem_id, action: "closed" });
1515
1783
  continue;
1516
1784
  }
1785
+ // A creator's notice that now stands for another creator's row (its recipient sees any row) is no longer creator-only.
1786
+ if (onlyFrom !== null && standsFor.some((r) => r.from !== onlyFrom)) {
1787
+ deps.db.prepare(`UPDATE queue_items SET tags = (SELECT json_group_array(value) FROM json_each(tags)
1788
+ WHERE NOT (type = 'text' AND substr(value, 1, length(?)) = ?))
1789
+ WHERE qitem_id = ? AND json_valid(tags)`).run(BACKLOG_TO_CREATOR_PREFIX, BACKLOG_TO_CREATOR_PREFIX, last.qitem_id);
1790
+ }
1517
1791
  const text = backlogText(standsFor);
1518
- if (text.summary !== last.summary || text.body !== last.body) {
1519
- deps.db.prepare("UPDATE queue_items SET body = ?, summary = ? WHERE qitem_id = ? AND body = ? AND summary IS ? AND state IN ('pending', 'in-progress', 'blocked')")
1520
- .run(text.body, text.summary, last.qitem_id, last.body, last.summary);
1792
+ let written = text.summary === last.summary && text.body === last.body;
1793
+ if (!written) {
1794
+ written = deps.db.prepare("UPDATE queue_items SET body = ?, summary = ? WHERE qitem_id = ? AND body = ? AND summary IS ? AND state IN ('pending', 'in-progress', 'blocked')")
1795
+ .run(text.body, text.summary, last.qitem_id, last.body, last.summary).changes === 1;
1521
1796
  }
1522
- findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "refreshed" });
1797
+ findings.push({ kind: "unclaimed-backlog", qitemId: key, findingQitemId: last.qitem_id, action: "refreshed" });
1798
+ if (parent && written)
1799
+ await foldInto(last.qitem_id, seat, parent, standsFor.map((r) => r.qitemId));
1523
1800
  continue;
1524
1801
  }
1525
1802
  if (rows.length === 0)
@@ -1531,15 +1808,23 @@ export async function runStuckSweep(deps) {
1531
1808
  const now_ = freshCandidate(c.kind, c.row.qitemId);
1532
1809
  if (now_)
1533
1810
  routeCandidate(now_);
1534
- return now_ && backlogKeyOf(now_) === seat && !recoveries.find(now_.row.qitemId) ? [now_] : [];
1811
+ if (!now_ || backlogKeyOf(now_) !== key)
1812
+ return [];
1813
+ // A row held by a recovery stays out, unless that recovery is the per-row finding this notice folds in.
1814
+ const held = recoveries.find(now_.row.qitemId);
1815
+ return !held || (parent && foldFrom.get(now_.row.qitemId) === held.qitemId) ? [now_] : [];
1535
1816
  });
1536
1817
  if (current.length === 0)
1537
1818
  continue;
1538
1819
  // A closed notice whose list is unreadable holds back every row, each until it has newer evidence than the close.
1539
1820
  const covered = last ? backlogRowsOf(last.body) : null;
1540
- if (last && !current.some((c) => (covered !== null && !covered.has(c.row.qitemId)) || evidenceIsNewer(c.evidenceAt, last.ts_updated)))
1821
+ if (last && !current.some((c) => (covered !== null && !covered.has(c.row.qitemId)) || evidenceIsNewer(c.evidenceAt, last.ts_updated))) {
1822
+ heldBack.set(tag, new Set(current.map((c) => c.row.qitemId)));
1541
1823
  continue;
1542
- await fileNotice(backlogText(current.map(backlogRow)), recipientFor(current.map((c) => c.row.sourceSession)));
1824
+ }
1825
+ const filed = await fileNotice(backlogText(current.map(backlogRow)), recipientFor(current.map((c) => c.row.sourceSession)), current.map((c) => c.row.sourceSession));
1826
+ if (filed && parent)
1827
+ await foldInto(filed, seat, parent, current.map((c) => c.row.qitemId));
1543
1828
  }
1544
1829
  // Resolution: an open finding whose underlying condition is no longer detected closes
1545
1830
  // with its reason — the sweep cleans up after itself, no human unwind.