@adhdev/daemon-core 0.9.82-rc.49 → 0.9.82-rc.491

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 (473) hide show
  1. package/dist/boot/daemon-lifecycle.d.ts +9 -0
  2. package/dist/boot/process-hardening.d.ts +50 -0
  3. package/dist/build-info.d.ts +37 -0
  4. package/dist/chat/source-machine.d.ts +166 -0
  5. package/dist/chat/source-resolver.d.ts +104 -0
  6. package/dist/chat/subscription-updates.d.ts +1 -0
  7. package/dist/cli-adapter-types.d.ts +68 -2
  8. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  9. package/dist/cli-adapters/cli-state-engine.d.ts +220 -0
  10. package/dist/cli-adapters/provider-cli-adapter.d.ts +137 -64
  11. package/dist/cli-adapters/provider-cli-parse.d.ts +5 -0
  12. package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
  13. package/dist/cli-adapters/provider-cli-shared.d.ts +74 -0
  14. package/dist/cli-adapters/pty-write-chunking.d.ts +34 -0
  15. package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
  16. package/dist/cli-adapters/resolve-executable.d.ts +69 -0
  17. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
  18. package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
  19. package/dist/cli-adapters/terminal-screen.d.ts +4 -11
  20. package/dist/commands/chat-commands-debug-bundle.d.ts +14 -0
  21. package/dist/commands/chat-commands-read.d.ts +23 -0
  22. package/dist/commands/chat-commands-scope.d.ts +39 -0
  23. package/dist/commands/chat-commands-shared.d.ts +33 -0
  24. package/dist/commands/chat-commands-write.d.ts +14 -0
  25. package/dist/commands/chat-commands.d.ts +10 -23
  26. package/dist/commands/cli-manager.d.ts +71 -1
  27. package/dist/commands/handler.d.ts +125 -0
  28. package/dist/commands/high-family/index.d.ts +3 -0
  29. package/dist/commands/high-family/mesh-coordinator-launch.d.ts +2 -0
  30. package/dist/commands/high-family/mesh-events.d.ts +2 -0
  31. package/dist/commands/high-family/mesh-status.d.ts +2 -0
  32. package/dist/commands/high-family/types.d.ts +64 -0
  33. package/dist/commands/low-family/coordinator-prompt.d.ts +9 -0
  34. package/dist/commands/low-family/daemon-lifecycle.d.ts +2 -0
  35. package/dist/commands/low-family/diagnostics.d.ts +2 -0
  36. package/dist/commands/low-family/index.d.ts +3 -0
  37. package/dist/commands/low-family/mesh-ledger.d.ts +10 -0
  38. package/dist/commands/low-family/mesh-node-logs.d.ts +2 -0
  39. package/dist/commands/low-family/notification.d.ts +2 -0
  40. package/dist/commands/low-family/refine-config.d.ts +2 -0
  41. package/dist/commands/low-family/session-host.d.ts +2 -0
  42. package/dist/commands/low-family/spec-providerdev.d.ts +11 -0
  43. package/dist/commands/low-family/status-meta.d.ts +2 -0
  44. package/dist/commands/low-family/types.d.ts +33 -0
  45. package/dist/commands/med-family/cli-agent.d.ts +2 -0
  46. package/dist/commands/med-family/fast-forward.d.ts +2 -0
  47. package/dist/commands/med-family/ide.d.ts +10 -0
  48. package/dist/commands/med-family/index.d.ts +3 -0
  49. package/dist/commands/med-family/mesh-crud.d.ts +48 -0
  50. package/dist/commands/med-family/mesh-host-pairing.d.ts +2 -0
  51. package/dist/commands/med-family/mesh-queue.d.ts +2 -0
  52. package/dist/commands/med-family/mesh-restart.d.ts +2 -0
  53. package/dist/commands/med-family/types.d.ts +152 -0
  54. package/dist/commands/mesh-coordinator.d.ts +85 -1
  55. package/dist/commands/router-aggregate-status.d.ts +24 -0
  56. package/dist/commands/router-mesh-session-owner.d.ts +59 -0
  57. package/dist/commands/router-refine.d.ts +151 -0
  58. package/dist/commands/router-worktree-cleanup.d.ts +133 -0
  59. package/dist/commands/router.d.ts +203 -15
  60. package/dist/commands/upgrade-helper.d.ts +41 -1
  61. package/dist/config/chat-history.d.ts +11 -0
  62. package/dist/config/config.d.ts +19 -0
  63. package/dist/config/mesh-config.d.ts +66 -0
  64. package/dist/config/mesh-json-config.d.ts +199 -0
  65. package/dist/config/registry-resolver.d.ts +54 -0
  66. package/dist/config/repo-settings.d.ts +77 -0
  67. package/dist/config/state-store.d.ts +30 -0
  68. package/dist/daemon/dev-server.d.ts +0 -2
  69. package/dist/detection/cli-detector.d.ts +17 -0
  70. package/dist/detection/ide-detector.d.ts +13 -0
  71. package/dist/detection/win32-ide-version.d.ts +37 -0
  72. package/dist/git/change-impact-config.d.ts +159 -0
  73. package/dist/git/git-commands.d.ts +26 -2
  74. package/dist/git/git-diff.d.ts +6 -0
  75. package/dist/git/git-executor.d.ts +11 -0
  76. package/dist/git/git-status.d.ts +80 -0
  77. package/dist/git/git-types.d.ts +2 -50
  78. package/dist/git/git-worktree.d.ts +71 -1
  79. package/dist/git/index.d.ts +3 -1
  80. package/dist/index.d.ts +70 -17
  81. package/dist/index.js +53556 -19074
  82. package/dist/index.js.map +1 -1
  83. package/dist/index.mjs +53380 -19063
  84. package/dist/index.mjs.map +1 -1
  85. package/dist/installer.d.ts +1 -4
  86. package/dist/ipc/local-ipc-server.d.ts +91 -0
  87. package/dist/launch.d.ts +1 -1
  88. package/dist/logging/async-batch-writer.d.ts +10 -0
  89. package/dist/logging/debug-config.d.ts +16 -0
  90. package/dist/logging/log-redactor.d.ts +24 -0
  91. package/dist/logging/log-tail-reader.d.ts +81 -0
  92. package/dist/logging/logger.d.ts +1 -1
  93. package/dist/mesh/contracts.d.ts +256 -0
  94. package/dist/mesh/coordinator-prompt.d.ts +76 -0
  95. package/dist/mesh/coordinator-registry.d.ts +59 -0
  96. package/dist/mesh/mesh-active-work.d.ts +203 -0
  97. package/dist/mesh/mesh-clone-grace.d.ts +8 -0
  98. package/dist/mesh/mesh-completion-synthesis.d.ts +4 -0
  99. package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
  100. package/dist/mesh/mesh-delivery-policy.d.ts +104 -0
  101. package/dist/mesh/mesh-event-classify.d.ts +7 -0
  102. package/dist/mesh/mesh-event-forwarding.d.ts +58 -0
  103. package/dist/mesh/mesh-event-trace.d.ts +21 -0
  104. package/dist/mesh/mesh-events-coordinator.d.ts +4 -0
  105. package/dist/mesh/mesh-events-pending.d.ts +258 -0
  106. package/dist/mesh/mesh-events-stale.d.ts +61 -0
  107. package/dist/mesh/mesh-events-utils.d.ts +75 -0
  108. package/dist/mesh/mesh-events.d.ts +6 -49
  109. package/dist/mesh/mesh-fast-forward.d.ts +81 -0
  110. package/dist/mesh/mesh-host-ownership.d.ts +21 -1
  111. package/dist/mesh/mesh-init.d.ts +128 -0
  112. package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -4
  113. package/dist/mesh/mesh-ledger.d.ts +139 -1
  114. package/dist/mesh/mesh-magi-status.d.ts +63 -0
  115. package/dist/mesh/mesh-missions.d.ts +281 -0
  116. package/dist/mesh/mesh-node-identity.d.ts +310 -0
  117. package/dist/mesh/mesh-queue-assignment.d.ts +162 -0
  118. package/dist/mesh/mesh-reconcile-acked-hold.d.ts +17 -0
  119. package/dist/mesh/mesh-reconcile-config.d.ts +6 -0
  120. package/dist/mesh/mesh-reconcile-identity.d.ts +6 -0
  121. package/dist/mesh/mesh-reconcile-loop.d.ts +84 -0
  122. package/dist/mesh/mesh-reconcile-v2-backstop.d.ts +16 -0
  123. package/dist/mesh/mesh-refine-batch.d.ts +68 -0
  124. package/dist/mesh/mesh-refine-gates.d.ts +457 -0
  125. package/dist/mesh/mesh-refine-status.d.ts +62 -0
  126. package/dist/mesh/mesh-remote-event-pull.d.ts +15 -0
  127. package/dist/mesh/mesh-review-inbox.d.ts +90 -0
  128. package/dist/mesh/mesh-routing.d.ts +70 -0
  129. package/dist/mesh/mesh-runtime-store.d.ts +567 -0
  130. package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
  131. package/dist/mesh/mesh-task-inflight.d.ts +46 -0
  132. package/dist/mesh/mesh-task-stats.d.ts +49 -0
  133. package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +34 -0
  134. package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
  135. package/dist/mesh/mesh-work-queue.d.ts +392 -1
  136. package/dist/mesh/preview-freshness.d.ts +28 -0
  137. package/dist/mesh/refine-config.d.ts +97 -0
  138. package/dist/mesh/worktree-bootstrap-config.d.ts +219 -0
  139. package/dist/providers/acp-provider-instance.d.ts +5 -0
  140. package/dist/providers/approval-utils.d.ts +46 -0
  141. package/dist/providers/chat-message-normalization.d.ts +58 -1
  142. package/dist/providers/cli-provider-effect-format.d.ts +30 -0
  143. package/dist/providers/cli-provider-history-dedup.d.ts +17 -0
  144. package/dist/providers/cli-provider-input-prompt.d.ts +12 -0
  145. package/dist/providers/cli-provider-instance-types.d.ts +45 -0
  146. package/dist/providers/cli-provider-instance.d.ts +426 -30
  147. package/dist/providers/cli-provider-status-helpers.d.ts +46 -0
  148. package/dist/providers/cli-provider-transcript-merge.d.ts +7 -0
  149. package/dist/providers/contracts.d.ts +196 -6
  150. package/dist/providers/external-sources.d.ts +71 -0
  151. package/dist/providers/manual-attendance.d.ts +79 -0
  152. package/dist/providers/native-history/antigravity-claim-registry.d.ts +39 -0
  153. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +137 -0
  154. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  155. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  156. package/dist/providers/native-history/constants.d.ts +12 -0
  157. package/dist/providers/native-history/dispatcher.d.ts +44 -0
  158. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  159. package/dist/providers/native-history/index.d.ts +13 -0
  160. package/dist/providers/provider-instance-manager.d.ts +30 -0
  161. package/dist/providers/provider-instance.d.ts +31 -1
  162. package/dist/providers/provider-loader.d.ts +42 -5
  163. package/dist/providers/provider-trust.d.ts +31 -0
  164. package/dist/providers/read-chat-contract.d.ts +29 -0
  165. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  166. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +86 -0
  167. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  168. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  169. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  170. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  171. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  172. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  173. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  174. package/dist/providers/sdk/v1/index.d.ts +30 -0
  175. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  176. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  177. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  178. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  179. package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
  180. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  181. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  182. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  183. package/dist/providers/spec/adapter.d.ts +98 -0
  184. package/dist/providers/spec/cli-adapter.d.ts +223 -0
  185. package/dist/providers/spec/evaluator.d.ts +45 -0
  186. package/dist/providers/spec/fsm-driver.d.ts +449 -0
  187. package/dist/providers/spec/fsm-evaluator.d.ts +93 -0
  188. package/dist/providers/spec/fsm-loader.d.ts +14 -0
  189. package/dist/providers/spec/fsm-types.d.ts +202 -0
  190. package/dist/providers/spec/native-history-executor.d.ts +41 -0
  191. package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
  192. package/dist/providers/spec/route.d.ts +4 -0
  193. package/dist/providers/spec/types.d.ts +244 -0
  194. package/dist/providers/status-monitor.d.ts +7 -7
  195. package/dist/providers/transcript-v2.d.ts +176 -0
  196. package/dist/providers/types/interactive-prompt.d.ts +84 -0
  197. package/dist/providers/working-dir.d.ts +17 -0
  198. package/dist/repo-mesh-types.d.ts +616 -12
  199. package/dist/runtime-defaults.d.ts +2 -0
  200. package/dist/session-host/managed-host.d.ts +64 -0
  201. package/dist/session-host/runtime-surface.d.ts +10 -16
  202. package/dist/sessions/registry.d.ts +26 -0
  203. package/dist/shared-types-extra.d.ts +2 -4
  204. package/dist/shared-types.d.ts +110 -55
  205. package/dist/status/chat-tail-hot-sessions.d.ts +40 -0
  206. package/dist/status/normalize.d.ts +1 -1
  207. package/dist/status/normalize.js +1 -0
  208. package/dist/status/normalize.js.map +1 -1
  209. package/dist/status/normalize.mjs +1 -0
  210. package/dist/status/normalize.mjs.map +1 -1
  211. package/dist/status/reporter.d.ts +2 -0
  212. package/dist/status/snapshot.d.ts +27 -0
  213. package/dist/system/hash.d.ts +8 -0
  214. package/dist/system/load-better-sqlite3.d.ts +21 -0
  215. package/dist/types.d.ts +20 -6
  216. package/package.json +11 -4
  217. package/src/agent-stream/poller.ts +2 -3
  218. package/src/agent-stream/provider-adapter.ts +1 -1
  219. package/src/boot/daemon-lifecycle.ts +80 -14
  220. package/src/boot/process-hardening.ts +89 -0
  221. package/src/build-info.ts +73 -0
  222. package/src/chat/source-machine.ts +534 -0
  223. package/src/chat/source-resolver.ts +0 -0
  224. package/src/chat/subscription-updates.ts +20 -1
  225. package/src/cli-adapter-types.d.ts +3 -1
  226. package/src/cli-adapter-types.ts +68 -2
  227. package/src/cli-adapters/cli-script-runner.ts +421 -0
  228. package/src/cli-adapters/cli-state-engine.ts +1282 -0
  229. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  230. package/src/cli-adapters/provider-cli-adapter.ts +1048 -1143
  231. package/src/cli-adapters/provider-cli-parse.d.ts +2 -0
  232. package/src/cli-adapters/provider-cli-parse.ts +19 -0
  233. package/src/cli-adapters/provider-cli-runtime.ts +56 -7
  234. package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
  235. package/src/cli-adapters/provider-cli-shared.ts +121 -11
  236. package/src/cli-adapters/pty-transport.ts +2 -1
  237. package/src/cli-adapters/pty-write-chunking.ts +106 -0
  238. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  239. package/src/cli-adapters/resolve-executable.ts +204 -0
  240. package/src/cli-adapters/session-host-transport.ts +2 -1
  241. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +63 -29
  242. package/src/cli-adapters/terminal-backends/types.ts +10 -3
  243. package/src/cli-adapters/terminal-screen.ts +16 -81
  244. package/src/commands/chat-commands-debug-bundle.ts +398 -0
  245. package/src/commands/chat-commands-read.ts +2788 -0
  246. package/src/commands/chat-commands-scope.ts +54 -0
  247. package/src/commands/chat-commands-shared.ts +114 -0
  248. package/src/commands/chat-commands-write.ts +891 -0
  249. package/src/commands/chat-commands.ts +19 -1841
  250. package/src/commands/cli-manager.d.ts +2 -0
  251. package/src/commands/cli-manager.ts +724 -27
  252. package/src/commands/handler.ts +865 -2
  253. package/src/commands/high-family/index.ts +28 -0
  254. package/src/commands/high-family/mesh-coordinator-launch.ts +696 -0
  255. package/src/commands/high-family/mesh-events.ts +102 -0
  256. package/src/commands/high-family/mesh-status.ts +857 -0
  257. package/src/commands/high-family/types.ts +80 -0
  258. package/src/commands/low-family/coordinator-prompt.ts +125 -0
  259. package/src/commands/low-family/daemon-lifecycle.ts +120 -0
  260. package/src/commands/low-family/diagnostics.ts +57 -0
  261. package/src/commands/low-family/index.ts +37 -0
  262. package/src/commands/low-family/mesh-ledger.ts +62 -0
  263. package/src/commands/low-family/mesh-node-logs.ts +87 -0
  264. package/src/commands/low-family/notification.ts +116 -0
  265. package/src/commands/low-family/refine-config.ts +106 -0
  266. package/src/commands/low-family/session-host.ts +282 -0
  267. package/src/commands/low-family/spec-providerdev.ts +217 -0
  268. package/src/commands/low-family/status-meta.ts +112 -0
  269. package/src/commands/low-family/types.ts +39 -0
  270. package/src/commands/med-family/cli-agent.ts +270 -0
  271. package/src/commands/med-family/fast-forward.ts +230 -0
  272. package/src/commands/med-family/ide.ts +163 -0
  273. package/src/commands/med-family/index.ts +37 -0
  274. package/src/commands/med-family/mesh-crud.ts +1309 -0
  275. package/src/commands/med-family/mesh-host-pairing.ts +234 -0
  276. package/src/commands/med-family/mesh-queue.ts +167 -0
  277. package/src/commands/med-family/mesh-restart.ts +92 -0
  278. package/src/commands/med-family/types.ts +153 -0
  279. package/src/commands/mesh-coordinator.ts +334 -124
  280. package/src/commands/router-aggregate-status.ts +209 -0
  281. package/src/commands/router-mesh-session-owner.ts +114 -0
  282. package/src/commands/router-refine.ts +1794 -0
  283. package/src/commands/router-worktree-cleanup.ts +870 -0
  284. package/src/commands/router.ts +567 -4149
  285. package/src/commands/stream-commands.ts +8 -0
  286. package/src/commands/upgrade-helper.ts +310 -45
  287. package/src/config/chat-history.ts +517 -24
  288. package/src/config/config.ts +30 -0
  289. package/src/config/mesh-config.ts +300 -24
  290. package/src/config/mesh-json-config.ts +376 -0
  291. package/src/config/recent-activity.ts +8 -2
  292. package/src/config/registry-resolver.ts +100 -0
  293. package/src/config/repo-settings.ts +111 -0
  294. package/src/config/state-store.ts +55 -0
  295. package/src/daemon/dev-auto-implement.ts +3 -2
  296. package/src/daemon/dev-cli-debug.ts +10 -1
  297. package/src/daemon/dev-server.ts +0 -541
  298. package/src/detection/cli-detector.ts +94 -9
  299. package/src/detection/ide-detector.ts +55 -16
  300. package/src/detection/win32-ide-version.ts +106 -0
  301. package/src/git/change-impact-config.ts +354 -0
  302. package/src/git/git-commands.ts +112 -16
  303. package/src/git/git-diff.ts +81 -11
  304. package/src/git/git-executor.ts +12 -0
  305. package/src/git/git-status.ts +822 -48
  306. package/src/git/git-types.ts +14 -62
  307. package/src/git/git-worktree.ts +261 -4
  308. package/src/git/index.ts +17 -0
  309. package/src/index.ts +190 -13
  310. package/src/installer.d.ts +1 -1
  311. package/src/installer.ts +8 -6
  312. package/src/ipc/local-ipc-server.ts +278 -0
  313. package/src/launch.d.ts +1 -1
  314. package/src/launch.ts +37 -28
  315. package/src/logging/async-batch-writer.ts +55 -0
  316. package/src/logging/command-log.ts +7 -5
  317. package/src/logging/debug-config.ts +25 -0
  318. package/src/logging/debug-trace.ts +7 -2
  319. package/src/logging/log-redactor.ts +100 -0
  320. package/src/logging/log-tail-reader.ts +341 -0
  321. package/src/logging/logger.ts +14 -7
  322. package/src/mesh/contracts.ts +510 -0
  323. package/src/mesh/coordinator-prompt.ts +627 -34
  324. package/src/mesh/coordinator-registry.ts +121 -0
  325. package/src/mesh/mesh-active-work.ts +706 -0
  326. package/src/mesh/mesh-clone-grace.ts +68 -0
  327. package/src/mesh/mesh-completion-synthesis.ts +416 -0
  328. package/src/mesh/mesh-coordinator-config.ts +97 -0
  329. package/src/mesh/mesh-delivery-policy.ts +284 -0
  330. package/src/mesh/mesh-event-classify.ts +78 -0
  331. package/src/mesh/mesh-event-forwarding.ts +2030 -0
  332. package/src/mesh/mesh-event-trace.ts +67 -0
  333. package/src/mesh/mesh-events-coordinator.ts +32 -0
  334. package/src/mesh/mesh-events-pending.ts +1548 -0
  335. package/src/mesh/mesh-events-stale.ts +452 -0
  336. package/src/mesh/mesh-events-utils.ts +443 -0
  337. package/src/mesh/mesh-events.ts +43 -1035
  338. package/src/mesh/mesh-fast-forward.ts +856 -0
  339. package/src/mesh/mesh-host-ownership.ts +41 -3
  340. package/src/mesh/mesh-init.ts +350 -0
  341. package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
  342. package/src/mesh/mesh-ledger.ts +897 -102
  343. package/src/mesh/mesh-magi-status.ts +223 -0
  344. package/src/mesh/mesh-missions.ts +695 -0
  345. package/src/mesh/mesh-node-identity.ts +2065 -0
  346. package/src/mesh/mesh-queue-assignment.ts +2498 -0
  347. package/src/mesh/mesh-reconcile-acked-hold.ts +230 -0
  348. package/src/mesh/mesh-reconcile-config.ts +66 -0
  349. package/src/mesh/mesh-reconcile-identity.ts +103 -0
  350. package/src/mesh/mesh-reconcile-loop.ts +1696 -0
  351. package/src/mesh/mesh-reconcile-v2-backstop.ts +62 -0
  352. package/src/mesh/mesh-refine-batch.ts +205 -0
  353. package/src/mesh/mesh-refine-gates.ts +1792 -0
  354. package/src/mesh/mesh-refine-status.ts +231 -0
  355. package/src/mesh/mesh-remote-event-pull.ts +279 -0
  356. package/src/mesh/mesh-review-inbox.ts +308 -0
  357. package/src/mesh/mesh-routing.ts +291 -0
  358. package/src/mesh/mesh-runtime-store.ts +2292 -0
  359. package/src/mesh/mesh-scheduling-runtime.ts +198 -0
  360. package/src/mesh/mesh-task-inflight.ts +70 -0
  361. package/src/mesh/mesh-task-stats.ts +161 -0
  362. package/src/mesh/mesh-unresolved-forward-outbox.ts +215 -0
  363. package/src/mesh/mesh-warmup-deadline.ts +152 -0
  364. package/src/mesh/mesh-work-queue.ts +1489 -145
  365. package/src/mesh/preview-freshness.ts +163 -0
  366. package/src/mesh/refine-config.ts +129 -12
  367. package/src/mesh/worktree-bootstrap-config.ts +599 -0
  368. package/src/providers/acp-provider-instance.ts +43 -10
  369. package/src/providers/approval-utils.d.ts +5 -0
  370. package/src/providers/approval-utils.ts +100 -6
  371. package/src/providers/chat-message-normalization.ts +126 -4
  372. package/src/providers/cli-provider-effect-format.ts +53 -0
  373. package/src/providers/cli-provider-history-dedup.ts +75 -0
  374. package/src/providers/cli-provider-input-prompt.ts +133 -0
  375. package/src/providers/cli-provider-instance-types.ts +131 -0
  376. package/src/providers/cli-provider-instance.ts +2771 -499
  377. package/src/providers/cli-provider-status-helpers.ts +123 -0
  378. package/src/providers/cli-provider-transcript-merge.ts +114 -0
  379. package/src/providers/contracts.d.ts +55 -0
  380. package/src/providers/contracts.ts +207 -6
  381. package/src/providers/extension-provider-instance.ts +12 -7
  382. package/src/providers/external-sources.ts +218 -0
  383. package/src/providers/ide-provider-instance.ts +35 -12
  384. package/src/providers/manual-attendance.ts +105 -0
  385. package/src/providers/native-history/antigravity-claim-registry.ts +138 -0
  386. package/src/providers/native-history/antigravity-cli-transcript.ts +1275 -0
  387. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  388. package/src/providers/native-history/codex-cli-transcript.ts +479 -0
  389. package/src/providers/native-history/constants.ts +19 -0
  390. package/src/providers/native-history/dispatcher.ts +617 -0
  391. package/src/providers/native-history/hermes-cli-transcript.ts +312 -0
  392. package/src/providers/native-history/index.ts +30 -0
  393. package/src/providers/provider-instance-manager.ts +71 -0
  394. package/src/providers/provider-instance.ts +24 -1
  395. package/src/providers/provider-loader.ts +700 -55
  396. package/src/providers/provider-schema.ts +93 -14
  397. package/src/providers/provider-trust.ts +114 -0
  398. package/src/providers/read-chat-contract.ts +76 -16
  399. package/src/providers/sdk/README.md +49 -0
  400. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  401. package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
  402. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  403. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +261 -0
  404. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  405. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  406. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  407. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  408. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  409. package/src/providers/sdk/v1/index.ts +152 -0
  410. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  411. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  412. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  413. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +538 -0
  414. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  415. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  416. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  417. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  418. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  419. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  420. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  421. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  422. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  423. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  424. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  425. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  426. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  427. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  428. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  429. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  430. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  431. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  432. package/src/providers/sdk/v1/validators/index.ts +19 -0
  433. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  434. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  435. package/src/providers/spec/adapter.ts +246 -0
  436. package/src/providers/spec/cli-adapter.ts +1064 -0
  437. package/src/providers/spec/evaluator.ts +407 -0
  438. package/src/providers/spec/fsm-driver.ts +1528 -0
  439. package/src/providers/spec/fsm-evaluator.ts +290 -0
  440. package/src/providers/spec/fsm-loader.ts +128 -0
  441. package/src/providers/spec/fsm-types.ts +301 -0
  442. package/src/providers/spec/native-history-executor.ts +1241 -0
  443. package/src/providers/spec/pre-launch-trust.ts +104 -0
  444. package/src/providers/spec/route.ts +51 -0
  445. package/src/providers/spec/types.ts +284 -0
  446. package/src/providers/status-monitor.d.ts +7 -7
  447. package/src/providers/status-monitor.ts +37 -22
  448. package/src/providers/transcript-v2.ts +567 -0
  449. package/src/providers/types/interactive-prompt.ts +536 -0
  450. package/src/providers/version-archive.ts +64 -24
  451. package/src/providers/working-dir.ts +23 -0
  452. package/src/repo-mesh-types.ts +861 -14
  453. package/src/runtime-defaults.ts +39 -0
  454. package/src/session-host/managed-host.ts +218 -0
  455. package/src/session-host/runtime-surface.ts +20 -80
  456. package/src/sessions/registry.ts +44 -0
  457. package/src/shared-types-extra.ts +2 -4
  458. package/src/shared-types.d.ts +8 -0
  459. package/src/shared-types.ts +148 -55
  460. package/src/status/builders.ts +69 -6
  461. package/src/status/chat-tail-hot-sessions.ts +117 -2
  462. package/src/status/normalize.ts +2 -0
  463. package/src/status/reporter.ts +19 -1
  464. package/src/status/snapshot.ts +100 -27
  465. package/src/system/hash.ts +23 -0
  466. package/src/system/host-memory.ts +29 -12
  467. package/src/system/load-better-sqlite3.ts +68 -0
  468. package/src/types.ts +26 -6
  469. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  470. package/dist/mesh/mesh-sync.d.ts +0 -53
  471. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  472. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  473. package/src/mesh/mesh-sync.ts +0 -111
@@ -0,0 +1,457 @@
1
+ /**
2
+ * Mesh refine validation gates & gitlink fast-forward evaluation
3
+ *
4
+ * Extracted from commands/router.ts (behavior-preserving move). Contains:
5
+ * - the MeshCoordinator config-format type
6
+ * - refine validation / patch-equivalence / effective-diff / submodule
7
+ * reachability gates and their summary types + job handles
8
+ * - gitlink trivial-fast-forward evaluation and submodule alignment helpers
9
+ *
10
+ * router.ts re-exports every public symbol from here so existing import paths
11
+ * keep working. `CommandRouterResult` is imported type-only from router.ts
12
+ * (erased at compile time — no runtime import cycle).
13
+ */
14
+ import type { ChangedPackageClassification } from '../git/git-status.js';
15
+ import type { WorktreeBootstrapState } from '../mesh/worktree-bootstrap-config.js';
16
+ import type { CommandRouterResult } from '../commands/router.js';
17
+ export type MeshCoordinatorConfigFormat = 'claude_mcp_json' | 'hermes_config_yaml';
18
+ type MeshRefineValidationStatus = 'passed' | 'failed' | 'skipped';
19
+ type MeshRefineValidationSummary = {
20
+ status: MeshRefineValidationStatus;
21
+ required: true;
22
+ commandsRun: Array<Record<string, unknown>>;
23
+ bootstrapCommandsRun: Array<Record<string, unknown>>;
24
+ rejectedCommands: Array<Record<string, unknown>>;
25
+ skippedReason?: string;
26
+ failureKind?: string;
27
+ failureCode?: string;
28
+ /** Human-readable cause when failureKind === 'spawn_resolution_failed' (win32 .cmd shim, etc). */
29
+ spawnResolutionError?: string;
30
+ timeoutMs: number;
31
+ outputLimitBytes: number;
32
+ configSource?: string;
33
+ configSourceType?: string;
34
+ suggestions?: unknown[];
35
+ suggestedConfig?: unknown;
36
+ /**
37
+ * M2-3: the bootstrap stage recorded separately from validation so review
38
+ * surfaces can distinguish environment failures from validation failures.
39
+ * cached — worktree_bootstrap was 'ready' (staleInputs unchanged), skipped
40
+ * ran — worktree_bootstrap was stale/never-ran and re-ran successfully
41
+ * failed — bootstrap run failed (refine stops before validation)
42
+ * skipped — refine config validation.bootstrap === 'skip'
43
+ * legacy — deprecated validation.bootstrapCommands path was used
44
+ * not_configured — no bootstrap definition anywhere
45
+ */
46
+ bootstrap?: {
47
+ stage: 'cached' | 'ran' | 'failed' | 'skipped' | 'legacy' | 'not_configured';
48
+ status?: string;
49
+ skipped?: boolean;
50
+ configSource?: string;
51
+ staleReason?: string;
52
+ error?: string;
53
+ commandsRun?: Array<Record<string, unknown>>;
54
+ };
55
+ /** M2-2: deprecation notices from the refine config (e.g. bootstrapCommands). */
56
+ deprecationWarnings?: string[];
57
+ /**
58
+ * Coarse daemon-vs-web change-impact used to scope the validation command set.
59
+ * When `isDaemonAffecting === false`, daemon-scoped commands are recorded in
60
+ * `commandsRun` with `skipped: true, skipReason: 'unaffected_daemon_scope'`
61
+ * rather than executed; web + typecheck commands always run. Absent when no
62
+ * change-impact was threaded in (legacy: full command set runs).
63
+ */
64
+ changeImpact?: {
65
+ isDaemonAffecting: boolean;
66
+ affectedPackages: string[];
67
+ /** displayCommands skipped because the daemon scope is unaffected. */
68
+ skippedDaemonCommands?: string[];
69
+ };
70
+ };
71
+ type MeshRefineStageStatus = 'passed' | 'failed' | 'skipped';
72
+ type MeshRefinePatchEquivalenceSummary = {
73
+ status: MeshRefineStageStatus;
74
+ equivalent: boolean;
75
+ baseHead: string;
76
+ branchHead: string;
77
+ mergeBase?: string;
78
+ mergedTree?: string;
79
+ expectedPatchId?: string;
80
+ actualPatchId?: string;
81
+ durationMs: number;
82
+ error?: string;
83
+ stdout?: string;
84
+ stderr?: string;
85
+ actionableHint?: MeshRefineSubmoduleConflictHint;
86
+ /**
87
+ * Set when a `merge-tree` submodule conflict was reclassified as a trivial
88
+ * gitlink fast-forward and the gate passed via a synthesized merge tree.
89
+ */
90
+ gitlinkTrivialFastForward?: {
91
+ resolved: boolean;
92
+ gitlinks: Array<{
93
+ path: string;
94
+ baseCommit?: string;
95
+ branchCommit?: string;
96
+ fastForward: boolean;
97
+ }>;
98
+ reason?: string;
99
+ };
100
+ };
101
+ type MeshRefineEffectiveDiffSummary = {
102
+ status: MeshRefineStageStatus;
103
+ /** True when there is at least one root-tree change between base and branch (incl. gitlink bumps). */
104
+ hasEffectiveDiff: boolean;
105
+ baseHead: string;
106
+ branchHead: string;
107
+ /** Root-level paths that differ between base and branch (capped). */
108
+ changedPaths?: string[];
109
+ /** Submodule paths with uncommitted/divergent commits but NO committed gitlink bump in the root tree. */
110
+ submoduleHints?: Array<{
111
+ path: string;
112
+ reason: string;
113
+ }>;
114
+ durationMs: number;
115
+ error?: string;
116
+ stdout?: string;
117
+ stderr?: string;
118
+ };
119
+ type MeshRefineSubmoduleConflictHint = {
120
+ kind: 'submodule_conflict';
121
+ message: string;
122
+ conflicts: Array<{
123
+ path: string;
124
+ baseCommit?: string;
125
+ branchCommit?: string;
126
+ }>;
127
+ nextSteps: string[];
128
+ };
129
+ type MeshRefineSubmoduleAlignmentSummary = {
130
+ status: 'passed' | 'failed' | 'skipped';
131
+ changedGitlinkPaths: string[];
132
+ outOfSyncPaths: string[];
133
+ updatedPaths: string[];
134
+ verifiedPaths: string[];
135
+ durationMs: number;
136
+ reason?: string;
137
+ command?: string;
138
+ error?: string;
139
+ stdout?: string;
140
+ stderr?: string;
141
+ };
142
+ type MeshRefineSubmoduleReachabilityEntry = {
143
+ path: string;
144
+ commit: string;
145
+ reachable: boolean;
146
+ publishRequired?: boolean;
147
+ autoPublishAllowed?: boolean;
148
+ autoPublishAttempted?: boolean;
149
+ autoPublishSucceeded?: boolean;
150
+ autoPublishVerified?: boolean;
151
+ autoPublishRefspec?: string;
152
+ autoPublishSkippedReason?: string;
153
+ importedFromWorktree?: boolean;
154
+ checkedLocal?: boolean;
155
+ localReachable?: boolean;
156
+ remote?: string;
157
+ remoteUrl?: string;
158
+ remoteReachable?: boolean;
159
+ remoteMainBranch?: string;
160
+ remoteMainReachable?: boolean;
161
+ fetchedFromOrigin?: boolean;
162
+ error?: string;
163
+ publishStdout?: string;
164
+ publishStderr?: string;
165
+ };
166
+ type MeshRefineSubmoduleReachabilitySummary = {
167
+ status: MeshRefineStageStatus;
168
+ checked: number;
169
+ unreachable: MeshRefineSubmoduleReachabilityEntry[];
170
+ entries: MeshRefineSubmoduleReachabilityEntry[];
171
+ durationMs: number;
172
+ autoPublishAllowed?: boolean;
173
+ autoPublishPolicySource?: string;
174
+ error?: string;
175
+ };
176
+ export type MeshRefineAsyncJobStatus = 'accepted' | 'completed' | 'failed';
177
+ export type MeshRefineJobHandle = {
178
+ success: true;
179
+ async: true;
180
+ status: MeshRefineAsyncJobStatus;
181
+ jobId: string;
182
+ interactionId: string;
183
+ meshId: string;
184
+ nodeId: string;
185
+ targetNodeId: string;
186
+ targetDaemonId?: string;
187
+ workspace?: string;
188
+ startedAt: string;
189
+ completedAt?: string;
190
+ duplicate?: boolean;
191
+ retryOfJobId?: string;
192
+ /**
193
+ * The coordinator daemon ID that initiated this refine job.
194
+ * When set, events for this job are scoped to that coordinator's
195
+ * pending-events queue instead of the shared broadcast queue.
196
+ */
197
+ targetCoordinatorDaemonId?: string;
198
+ eventDelivery: {
199
+ pendingEvents: true;
200
+ ledger: true;
201
+ };
202
+ evidence: {
203
+ pendingEventsCommand: 'get_pending_mesh_events';
204
+ ledgerCommand: 'get_mesh_ledger_slice';
205
+ taskHistoryKind: 'task_dispatched' | 'task_completed' | 'task_failed';
206
+ };
207
+ };
208
+ export type MeshRefineTerminalJob = MeshRefineJobHandle & {
209
+ result?: Record<string, unknown>;
210
+ };
211
+ export type MeshRefineBatchJobStatus = 'accepted' | 'completed' | 'failed';
212
+ /**
213
+ * Async handle returned by the batch Refinery the instant a convergence run is
214
+ * accepted. Mirrors {@link MeshRefineJobHandle} (async:true / status:'accepted' +
215
+ * terminal pending-event + ledger delivery) but scopes a whole batch of sibling
216
+ * nodes rather than a single node. The synthetic `batchLabel` is used as the
217
+ * `nodeLabel` for the shared refine event/message renderer.
218
+ */
219
+ export type MeshRefineBatchJobHandle = {
220
+ success: true;
221
+ async: true;
222
+ batch: true;
223
+ status: MeshRefineBatchJobStatus;
224
+ jobId: string;
225
+ interactionId: string;
226
+ meshId: string;
227
+ batchLabel: string;
228
+ nodeIds: string[];
229
+ nodeCount: number;
230
+ order: string[];
231
+ startedAt: string;
232
+ completedAt?: string;
233
+ duplicate?: boolean;
234
+ targetCoordinatorDaemonId?: string;
235
+ eventDelivery: {
236
+ pendingEvents: true;
237
+ ledger: true;
238
+ };
239
+ evidence: {
240
+ pendingEventsCommand: 'get_pending_mesh_events';
241
+ ledgerCommand: 'get_mesh_ledger_slice';
242
+ taskHistoryKind: 'task_dispatched' | 'task_completed' | 'task_failed';
243
+ };
244
+ };
245
+ export type MeshRefineBatchTerminalJob = MeshRefineBatchJobHandle & {
246
+ result?: Record<string, unknown>;
247
+ };
248
+ export declare function truncateValidationOutput(value: unknown): string;
249
+ /**
250
+ * A spawn-resolution failure is when the executable itself could not be found by
251
+ * the OS spawn boundary — `spawn <cmd> ENOENT` — as opposed to the command
252
+ * running and exiting non-zero. On win32 this is the .cmd-shim case: libuv's
253
+ * spawn search appends only .com/.exe, so a bare `npm`/`npx`/`tsc` (which are
254
+ * .cmd shims) ENOENTs even though it is installed. It carries no stderr, so it
255
+ * must be detected by error.code/syscall, not by string-matching output.
256
+ */
257
+ export declare function isSpawnResolutionError(error: any): boolean;
258
+ export declare function describeSpawnError(error: any, command: string, spawnResolutionFailed: boolean): string;
259
+ export declare function recordMeshRefineStage(stages: Array<Record<string, unknown>>, stage: string, status: MeshRefineStageStatus, startedAt: number, details?: Record<string, unknown>): void;
260
+ export declare function buildSubmodulePublishRequiredNextStep(entries: MeshRefineSubmoduleReachabilityEntry[]): string;
261
+ /**
262
+ * Async git exec helper used across the synchronous-refine stage pipeline. Bound
263
+ * once in the orchestrator and threaded through RefineContext so every stage runs
264
+ * git the same way (execFile + promisify, utf8). Returns the child's stdout/stderr.
265
+ */
266
+ export type RefineExecFileAsync = (file: string, args: string[], options: {
267
+ cwd: string;
268
+ encoding: 'utf8';
269
+ }) => Promise<{
270
+ stdout: string;
271
+ stderr: string;
272
+ }>;
273
+ /**
274
+ * Accumulated state shared by the synchronous-refine stages. The orchestrator
275
+ * (executeMeshRefineNodeSynchronously) seeds this in the resolve_refs stage and
276
+ * each later stage reads / extends it. `branchHead` and `patchEquivalence` are the
277
+ * only fields a stage mutates after creation (auto-rebase updates both), so they
278
+ * are carried on the mutable context rather than re-threaded through return types.
279
+ */
280
+ export interface RefineContext {
281
+ meshId: string;
282
+ nodeId: string;
283
+ args: any;
284
+ refineStages: Array<Record<string, unknown>>;
285
+ execFileAsync: RefineExecFileAsync;
286
+ mesh: any;
287
+ node: any;
288
+ sourceNode: any;
289
+ repoRoot: string;
290
+ branch: string;
291
+ baseBranch: string;
292
+ baseHead: string;
293
+ branchHead: string;
294
+ /**
295
+ * Coarse daemon-vs-web change-impact for baseHead..branchHead, resolved in the
296
+ * resolve_refs stage and threaded into the validation gate to scope its command
297
+ * set. `undefined` means "could not classify" → the gate fails open and runs ALL
298
+ * commands (never skip on uncertainty).
299
+ */
300
+ changeImpact?: ChangedPackageClassification;
301
+ validationSummary: Awaited<ReturnType<typeof runMeshRefineValidationGate>>;
302
+ patchEquivalence: Awaited<ReturnType<typeof runMeshRefinePatchEquivalenceGate>>;
303
+ submoduleReachability: Awaited<ReturnType<typeof runMeshRefineSubmoduleReachabilityGate>>;
304
+ }
305
+ /**
306
+ * Stage outcome for the synchronous-refine pipeline. A stage either produces a
307
+ * terminal CommandRouterResult (an early-exit gate failure, or a successful
308
+ * already-merged short-circuit), in which case the orchestrator returns it
309
+ * immediately, or it returns `continue` with the (possibly extended) context for
310
+ * the next stage. This makes the orchestrator a flat sequence of stage calls
311
+ * while preserving the original body's exact early-return control flow.
312
+ */
313
+ export type RefineStageOutcome = {
314
+ kind: 'terminal';
315
+ result: CommandRouterResult;
316
+ } | {
317
+ kind: 'continue';
318
+ ctx: RefineContext;
319
+ };
320
+ export declare function resolveRefineryAutoPublishSubmoduleMainCommits(mesh: any, workspace: string): {
321
+ enabled: boolean;
322
+ source?: string;
323
+ };
324
+ export declare function runMeshRefinePatchEquivalenceGate(repoRoot: string, baseHead: string, branchHead: string): Promise<MeshRefinePatchEquivalenceSummary>;
325
+ export type MeshWorktreePatchContainmentSummary = {
326
+ /** True only when merging worktreeHead into ref introduces no new patch. */
327
+ contained: boolean;
328
+ ref: string;
329
+ worktreeHead: string;
330
+ mergeBase?: string;
331
+ mergedTree?: string;
332
+ /** patch-id of (ref -> synthesized merge tree); empty string when nothing new is added. */
333
+ residualPatchId?: string;
334
+ durationMs: number;
335
+ /** Set when the check could not run (treated conservatively as NOT contained). */
336
+ error?: string;
337
+ };
338
+ /**
339
+ * Patch-equivalence containment check for the worktree force-cleanup convergence
340
+ * guard. Answers a narrower question than {@link runMeshRefinePatchEquivalenceGate}:
341
+ * "are the worktree branch's changes ALREADY present in `ref` (e.g. origin/main),
342
+ * even though the worktree HEAD's commit SHA is not an ancestor of ref?"
343
+ *
344
+ * This is the cherry-pick / squash / rebase case: the same content landed on the
345
+ * default ref under a different commit SHA, so `merge-base --is-ancestor` (the
346
+ * primary cleanup guard) reports the worktree as un-converged and refuses to
347
+ * remove it. Refinery already accepts patch-equivalent landings via merge-tree +
348
+ * patch-id; this brings the same notion of "convergence" to the cleanup guard.
349
+ *
350
+ * Mechanism: synthesize the merge of `worktreeHead` into `ref` (reusing the same
351
+ * trivial-gitlink-fast-forward handling as the refine gate) and compute the
352
+ * patch-id of (ref -> mergedTree). If that residual diff is EMPTY, merging the
353
+ * worktree adds nothing new on top of ref — its changes are already present there
354
+ * and the worktree is safe to remove. A non-empty residual means the worktree
355
+ * still carries content not in ref, so it is NOT contained and must stay blocked.
356
+ *
357
+ * Conservative by construction: any merge-tree / patch-id failure, a genuine
358
+ * (non-trivial) submodule conflict, or any thrown error yields `contained: false`
359
+ * so an exception can never widen the cleanup allow-list.
360
+ */
361
+ export declare function checkWorktreeChangesPatchEquivalentInRef(repoRoot: string, ref: string, worktreeHead: string): Promise<MeshWorktreePatchContainmentSummary>;
362
+ /**
363
+ * No-op guard: detect a "silent no-op" merge before the Refinery merge runs.
364
+ *
365
+ * A silent no-op occurs when the refine target branch's ROOT tree is byte-identical
366
+ * to the merge base (origin/main). This is the trap where a submodule (e.g. oss) has
367
+ * real commits but the root branch never committed the gitlink (oss-pointer) bump, so
368
+ * the root diff Refinery would merge is empty. Merging that produces a merge commit with
369
+ * no content change — reported as "success" while the actual work never reaches main.
370
+ *
371
+ * A committed gitlink bump (the legitimate oss-pointer bump) DOES show up in the root
372
+ * tree diff (as a 160000-mode entry), so this guard does NOT block legitimate refines —
373
+ * it only fires when the root tree diff vs base is COMPLETELY empty.
374
+ *
375
+ * Runs after the patch-equivalence gate; the "already merged via other path" case
376
+ * (branch has real changes already present in base) is handled upstream and never
377
+ * reaches here, so an empty root diff at this point is genuinely a no-op.
378
+ */
379
+ export declare function runMeshRefineEffectiveDiffGate(repoRoot: string, baseHead: string, branchHead: string): Promise<MeshRefineEffectiveDiffSummary>;
380
+ /**
381
+ * Result of evaluating whether a `git merge-tree --write-tree` submodule
382
+ * conflict is in fact a trivial gitlink fast-forward that should pass the
383
+ * patch-equivalence gate.
384
+ *
385
+ * `git merge-tree` (and `git merge` with the default recursive strategy)
386
+ * refuses to 3-way merge gitlinks unless the case is "trivial" — and it
387
+ * treats *any* gitlink that differs across merge-base/base/branch as
388
+ * non-trivial, even when the branch-side commit is a strict descendant of the
389
+ * base-side commit (i.e. a real fast-forward). Refinery only ever wants to
390
+ * accept the branch's recorded gitlink, so a fast-forwardable bump is safe to
391
+ * resolve to the branch side without any conflict.
392
+ */
393
+ type GitlinkTrivialFastForwardEvaluation = {
394
+ /** True only when the merge-tree conflict is *fully* explained by trivial-ff gitlinks. */
395
+ trivial: boolean;
396
+ /** Why the evaluation declined to treat the conflict as trivial (set when trivial=false). */
397
+ reason?: string;
398
+ /** Per-path detail for the changed gitlinks that were inspected. */
399
+ gitlinks: Array<{
400
+ path: string;
401
+ baseCommit?: string;
402
+ branchCommit?: string;
403
+ fastForward: boolean;
404
+ }>;
405
+ };
406
+ /**
407
+ * Return the changed gitlink paths between base and branch whose advance is a
408
+ * strict fast-forward (the base-side commit is an ancestor of the branch-side
409
+ * commit inside that submodule's repo). These are the paths whose patch-id hunk
410
+ * may legitimately differ when base has advanced the same submodule, so they
411
+ * are safe to exclude from the patch-equivalence comparison. A non-ff (genuinely
412
+ * diverged) gitlink is deliberately excluded from this set so it still fails the
413
+ * gate.
414
+ */
415
+ export declare function collectFastForwardGitlinkPaths(repoRoot: string, baseHead: string, branchHead: string): string[];
416
+ /**
417
+ * Decide whether a merge-tree submodule conflict between base and branch is a
418
+ * trivial gitlink fast-forward (and nothing else).
419
+ *
420
+ * The conflict is treated as trivial ONLY when:
421
+ * 1. at least one changed gitlink exists,
422
+ * 2. every changed gitlink fast-forwards (base-commit is an ancestor of the
423
+ * branch-commit inside that submodule's repo), and
424
+ * 3. the *only* paths that changed on both sides of the merge (i.e. the paths
425
+ * that could possibly produce a 3-way conflict — the intersection of
426
+ * mergeBase→base and mergeBase→branch changes) are gitlinks. Any
427
+ * overlapping non-gitlink path means a genuine content conflict could be
428
+ * hiding behind the submodule failure, so we keep the block.
429
+ *
430
+ * If any of these fail, the conflict is left as a genuine block. This never
431
+ * passes a regular-file conflict or a diverged (non-ff) gitlink.
432
+ */
433
+ export declare function evaluateGitlinkTrivialFastForward(repoRoot: string, baseHead: string, branchHead: string): GitlinkTrivialFastForwardEvaluation;
434
+ export declare function alignRefinerySubmodulesAfterMerge(repoRoot: string, previousBaseHead: string, currentHead: string, options?: {
435
+ submoduleIgnorePaths?: string[];
436
+ }): Promise<MeshRefineSubmoduleAlignmentSummary>;
437
+ export declare function runMeshRefineSubmoduleReachabilityGate(repoRoot: string, mergedTree: string, options?: {
438
+ allowAutoPublishSubmoduleMainCommits?: boolean;
439
+ autoPublishPolicySource?: string;
440
+ worktreeRoot?: string;
441
+ }): Promise<MeshRefineSubmoduleReachabilitySummary>;
442
+ export declare function buildMeshRefineValidationPlan(mesh: any, workspace: string): Record<string, unknown>;
443
+ export declare function runMeshRefineValidationGate(mesh: any, workspace: string, opts?: {
444
+ /** M2-2: persisted node bootstrap state for staleness evaluation. */
445
+ persistedBootstrapState?: WorktreeBootstrapState | null;
446
+ /** M2-2: called after an inherit-mode bootstrap run so the caller can persist the new state. */
447
+ onBootstrapStateChange?: (state: WorktreeBootstrapState) => void;
448
+ /**
449
+ * Coarse daemon-vs-web change-impact for the branch (resolve_refs computes it
450
+ * over baseHead..branchHead). When provided and `isDaemonAffecting === false`,
451
+ * daemon-scoped validation commands are skipped (web + typecheck still run).
452
+ * When omitted or `isDaemonAffecting === true`, the full command set runs —
453
+ * fail-open to full validation on any uncertainty.
454
+ */
455
+ changeImpact?: ChangedPackageClassification;
456
+ }): Promise<MeshRefineValidationSummary>;
457
+ export {};
@@ -0,0 +1,62 @@
1
+ import type { MeshLedgerEntry } from './mesh-ledger.js';
2
+ import type { PendingMeshCoordinatorEvent } from './mesh-events.js';
3
+ import type { MeshAsyncJobLifecycle } from '../repo-mesh-types.js';
4
+ export type MeshAsyncRefineJobStatus = 'accepted' | 'running' | 'completed' | 'failed';
5
+ export interface MeshAsyncRefineJobSummary extends MeshAsyncJobLifecycle {
6
+ jobId: string;
7
+ interactionId?: string;
8
+ status: MeshAsyncRefineJobStatus;
9
+ meshId?: string;
10
+ nodeId?: string;
11
+ targetNodeId?: string;
12
+ targetDaemonId?: string;
13
+ workspace?: string;
14
+ branch?: string;
15
+ into?: string;
16
+ retryOfJobId?: string;
17
+ lastEvent?: string;
18
+ lastLedgerKind?: string;
19
+ lastUpdatedAt?: string;
20
+ instruction: string;
21
+ }
22
+ export declare function buildMeshAsyncRefineJobs(args: {
23
+ meshId?: string;
24
+ ledgerEntries?: MeshLedgerEntry[];
25
+ pendingEvents?: PendingMeshCoordinatorEvent[];
26
+ }): MeshAsyncRefineJobSummary[];
27
+ /** Terminal refine jobs older than this (relative to the newest job in the set) are
28
+ * "stale" — already-resolved historical refinery rejections/successes that should not
29
+ * keep inflating the status counts in mesh_status. 6h covers a long working session
30
+ * while still folding multi-day-old residue. */
31
+ export declare const STALE_TERMINAL_REFINE_WINDOW_MS: number;
32
+ /** Cap on how many recent terminal jobs are counted even if all fall inside the freshness
33
+ * window — prevents a burst of refines from dominating the summary. */
34
+ export declare const RECENT_TERMINAL_REFINE_CAP = 8;
35
+ export interface MeshAsyncRefineJobsSummary {
36
+ /** Count of jobs reflected in `byStatus` (active jobs + recent terminal jobs). */
37
+ total: number;
38
+ byStatus: Record<string, number>;
39
+ /** Terminal jobs dropped from the counts because they are stale residue. */
40
+ staleTerminal: number;
41
+ /** Non-terminal (accepted/running) jobs still in flight. */
42
+ activeJobs: MeshAsyncRefineJobSummary[];
43
+ }
44
+ /**
45
+ * Build a compact summary of refine jobs that folds stale terminal jobs.
46
+ *
47
+ * The full job list (from `buildMeshAsyncRefineJobs`) is derived from a recent ledger
48
+ * window and deduped by jobId, but it still includes every terminal (completed/failed)
49
+ * job that happens to fall in that window — including multi-day-old refinery rejections
50
+ * that have long since been resolved. Those stale terminals inflate `byStatus.failed`
51
+ * and read as "current breakage" when they are historical noise.
52
+ *
53
+ * Active (accepted/running) jobs are always counted. Terminal jobs are counted only when
54
+ * they are recent: within `STALE_TERMINAL_REFINE_WINDOW_MS` of the newest job's activity
55
+ * time AND among the `RECENT_TERMINAL_REFINE_CAP` most-recent terminals. Everything else
56
+ * is folded into `staleTerminal` and excluded from `byStatus`.
57
+ *
58
+ * Freshness is measured relative to the newest job in the set (not wall-clock), so the
59
+ * result is deterministic for a given input — important for tests and for stale-clock
60
+ * environments.
61
+ */
62
+ export declare function summarizeMeshAsyncRefineJobs(jobs: MeshAsyncRefineJobSummary[]): MeshAsyncRefineJobsSummary;
@@ -0,0 +1,15 @@
1
+ import type { DaemonComponents } from '../boot/daemon-lifecycle.js';
2
+ import type { LocalMeshEntry } from '../repo-mesh-types.js';
3
+ export declare function pullRemoteNodeQueues(components: DaemonComponents, mesh: LocalMeshEntry, localDaemonId: string | undefined, candidateDaemonIds: string[]): Promise<void>;
4
+ export declare function unwrapReadChatPayload(raw: unknown): Record<string, unknown> | null;
5
+ export declare function readChatPayloadStatus(payload: Record<string, unknown> | null): string;
6
+ export declare function realTerminalEmitPendingForTask(meshId: string, taskId: string): boolean;
7
+ export declare function reprobeWorkerStatus(components: DaemonComponents, args: {
8
+ isLocalNode: boolean;
9
+ nodeDaemonId: string;
10
+ readArgs: Record<string, unknown>;
11
+ }): Promise<string | null>;
12
+ export declare function collectLiveNodesWithSessions(components: DaemonComponents, mesh: LocalMeshEntry, selfIds: string[], localDaemonId: string | undefined): Promise<any[]>;
13
+ export declare function extractStatusMetadataSessions(raw: unknown): any[];
14
+ export declare function extractPendingEvents(raw: unknown): any[];
15
+ export declare function buildForwardPayloadFromPending(event: any): Record<string, unknown>;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * M4.0: Review inbox — derive review items from existing truth.
3
+ *
4
+ * No new store: review items are a query-time projection of
5
+ * - mesh_status node statuses (daemon-owned branchConvergence), and
6
+ * - the task ledger (completion evidence envelopes + refine job results).
7
+ *
8
+ * Scope (M4.0): host-daemon-local nodes only. Remote nodes are excluded and
9
+ * surfaced via remoteNodesExcluded/excludedRemoteNodeIds until the
10
+ * daemon↔daemon P2P relay path is live-verified (M4.2).
11
+ */
12
+ import type { MeshLedgerEntry } from './mesh-ledger.js';
13
+ export type MeshReviewInboxReason = 'merge_candidate' | 'refine_blocked_review';
14
+ export interface MeshReviewInboxConvergence {
15
+ status: string;
16
+ reason: string | null;
17
+ nextStep: string | null;
18
+ needsConvergence: boolean;
19
+ }
20
+ export interface MeshReviewInboxEvidence {
21
+ available: boolean;
22
+ /** Ledger kind of the entry the evidence came from. */
23
+ kind?: 'task_completed' | 'task_failed';
24
+ /** 'task_completion' = ordinary worker completion envelope; 'refine_job' = Refinery result. */
25
+ source?: 'task_completion' | 'refine_job';
26
+ timestamp?: string;
27
+ taskId?: string;
28
+ sessionId?: string;
29
+ /** M2-3 bootstrap stage from the refine validation gate: cached|ran|failed|skipped|legacy|not_configured. */
30
+ bootstrap?: Record<string, unknown> | null;
31
+ validation?: Record<string, unknown> | null;
32
+ checkpoint?: Record<string, unknown> | null;
33
+ worker?: {
34
+ status: string;
35
+ classification?: string;
36
+ changedFiles: string[];
37
+ changedFilesTruncated?: true;
38
+ validationResults: Array<Record<string, unknown>>;
39
+ errors: string[];
40
+ requiresUserAction: boolean;
41
+ } | null;
42
+ finalBranchConvergenceState?: Record<string, unknown>;
43
+ refineJob?: Record<string, unknown>;
44
+ }
45
+ export interface MeshReviewInboxDiffFile {
46
+ path: string;
47
+ status?: string;
48
+ insertions?: number;
49
+ deletions?: number;
50
+ binary?: boolean;
51
+ oldPath?: string;
52
+ }
53
+ export interface MeshReviewInboxDiffSummary {
54
+ baseRef: string;
55
+ files: MeshReviewInboxDiffFile[];
56
+ totalFiles: number;
57
+ totalInsertions: number;
58
+ totalDeletions: number;
59
+ truncated: boolean;
60
+ error?: string;
61
+ }
62
+ export interface MeshReviewInboxItem {
63
+ nodeId: string;
64
+ workspace: string | null;
65
+ branch: string | null;
66
+ defaultBranch: string | null;
67
+ isLocalWorktree: boolean;
68
+ reviewReason: MeshReviewInboxReason;
69
+ convergence: MeshReviewInboxConvergence;
70
+ evidence: MeshReviewInboxEvidence;
71
+ transcriptHandle: Record<string, unknown> | null;
72
+ /** Latest non-terminal Refinery job for this node (accepted/running), if any. */
73
+ activeRefineJob: Record<string, unknown> | null;
74
+ lastActivityAt: string | null;
75
+ /** Filled by the daemon command with a bounded base-branch diff probe; null when the workspace is not locally readable. */
76
+ diffSummary?: MeshReviewInboxDiffSummary | null;
77
+ }
78
+ export interface MeshReviewInboxDerivation {
79
+ items: MeshReviewInboxItem[];
80
+ remoteNodesExcluded: boolean;
81
+ excludedRemoteNodeIds: string[];
82
+ }
83
+ /**
84
+ * Derive review inbox items from mesh_status node statuses and a bounded
85
+ * ledger tail. Pure and read-only; the caller attaches diffSummary separately.
86
+ */
87
+ export declare function deriveMeshReviewInboxItems(args: {
88
+ nodes: Array<Record<string, unknown>>;
89
+ ledgerEntries: MeshLedgerEntry[];
90
+ }): MeshReviewInboxDerivation;