wicked-crew 0.18.20 → 0.18.22

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 (640) hide show
  1. package/dist/api/audit.d.ts +28 -1
  2. package/dist/api/audit.d.ts.map +1 -1
  3. package/dist/api/audit.js +90 -9
  4. package/dist/api/audit.js.map +1 -1
  5. package/dist/api/auth.d.ts +7 -0
  6. package/dist/api/auth.d.ts.map +1 -1
  7. package/dist/api/auth.js +53 -10
  8. package/dist/api/auth.js.map +1 -1
  9. package/dist/api/capture.d.ts +16 -4
  10. package/dist/api/capture.d.ts.map +1 -1
  11. package/dist/api/capture.js +20 -12
  12. package/dist/api/capture.js.map +1 -1
  13. package/dist/api/chat-context.d.ts +17 -0
  14. package/dist/api/chat-context.d.ts.map +1 -1
  15. package/dist/api/chat-context.js +94 -5
  16. package/dist/api/chat-context.js.map +1 -1
  17. package/dist/api/chat-freshness.js +2 -2
  18. package/dist/api/chat-freshness.js.map +1 -1
  19. package/dist/api/chat-jobs.d.ts +54 -0
  20. package/dist/api/chat-jobs.d.ts.map +1 -1
  21. package/dist/api/chat-jobs.js +199 -7
  22. package/dist/api/chat-jobs.js.map +1 -1
  23. package/dist/api/chat-proposals.d.ts +62 -12
  24. package/dist/api/chat-proposals.d.ts.map +1 -1
  25. package/dist/api/chat-proposals.js +257 -52
  26. package/dist/api/chat-proposals.js.map +1 -1
  27. package/dist/api/chat-requirements.d.ts.map +1 -1
  28. package/dist/api/chat-requirements.js +4 -1
  29. package/dist/api/chat-requirements.js.map +1 -1
  30. package/dist/api/chat-scope.d.ts +12 -0
  31. package/dist/api/chat-scope.d.ts.map +1 -1
  32. package/dist/api/chat-scope.js +35 -5
  33. package/dist/api/chat-scope.js.map +1 -1
  34. package/dist/api/cluster-status.d.ts +41 -12
  35. package/dist/api/cluster-status.d.ts.map +1 -1
  36. package/dist/api/cluster-status.js +148 -3
  37. package/dist/api/cluster-status.js.map +1 -1
  38. package/dist/api/codebase-archive.js +2 -2
  39. package/dist/api/codebase-archive.js.map +1 -1
  40. package/dist/api/compose-facts.d.ts +35 -0
  41. package/dist/api/compose-facts.d.ts.map +1 -0
  42. package/dist/api/compose-facts.js +46 -0
  43. package/dist/api/compose-facts.js.map +1 -0
  44. package/dist/api/cut-read.d.ts +62 -0
  45. package/dist/api/cut-read.d.ts.map +1 -0
  46. package/dist/api/cut-read.js +101 -0
  47. package/dist/api/cut-read.js.map +1 -0
  48. package/dist/api/delivery-cache.d.ts +2 -0
  49. package/dist/api/delivery-cache.d.ts.map +1 -1
  50. package/dist/api/delivery-cache.js +1 -2
  51. package/dist/api/delivery-cache.js.map +1 -1
  52. package/dist/api/delivery-index.d.ts +2 -2
  53. package/dist/api/delivery-index.d.ts.map +1 -1
  54. package/dist/api/delivery-index.js +1 -2
  55. package/dist/api/delivery-index.js.map +1 -1
  56. package/dist/api/desk-snoozes.d.ts +54 -0
  57. package/dist/api/desk-snoozes.d.ts.map +1 -0
  58. package/dist/api/desk-snoozes.js +174 -0
  59. package/dist/api/desk-snoozes.js.map +1 -0
  60. package/dist/api/diagnostics.d.ts +4 -0
  61. package/dist/api/diagnostics.d.ts.map +1 -1
  62. package/dist/api/diagnostics.js +15 -7
  63. package/dist/api/diagnostics.js.map +1 -1
  64. package/dist/api/disk-stores.d.ts +66 -0
  65. package/dist/api/disk-stores.d.ts.map +1 -0
  66. package/dist/api/disk-stores.js +206 -0
  67. package/dist/api/disk-stores.js.map +1 -0
  68. package/dist/api/eval-compare.d.ts +1 -1
  69. package/dist/api/eval-compare.js +1 -1
  70. package/dist/api/eval-sample.d.ts +7 -0
  71. package/dist/api/eval-sample.d.ts.map +1 -1
  72. package/dist/api/eval-sample.js +20 -0
  73. package/dist/api/eval-sample.js.map +1 -1
  74. package/dist/api/gate-cache.d.ts +8 -0
  75. package/dist/api/gate-cache.d.ts.map +1 -1
  76. package/dist/api/gate-cache.js +8 -1
  77. package/dist/api/gate-cache.js.map +1 -1
  78. package/dist/api/governance-steering.d.ts +13 -0
  79. package/dist/api/governance-steering.d.ts.map +1 -1
  80. package/dist/api/governance-steering.js +56 -7
  81. package/dist/api/governance-steering.js.map +1 -1
  82. package/dist/api/mcp.d.ts +19 -1
  83. package/dist/api/mcp.d.ts.map +1 -1
  84. package/dist/api/mcp.js +123 -3
  85. package/dist/api/mcp.js.map +1 -1
  86. package/dist/api/needs.d.ts +23 -0
  87. package/dist/api/needs.d.ts.map +1 -1
  88. package/dist/api/needs.js +124 -19
  89. package/dist/api/needs.js.map +1 -1
  90. package/dist/api/onboarding-capture.d.ts +21 -1
  91. package/dist/api/onboarding-capture.d.ts.map +1 -1
  92. package/dist/api/onboarding-capture.js +112 -8
  93. package/dist/api/onboarding-capture.js.map +1 -1
  94. package/dist/api/policy-landing.d.ts +36 -0
  95. package/dist/api/policy-landing.d.ts.map +1 -1
  96. package/dist/api/policy-landing.js +123 -4
  97. package/dist/api/policy-landing.js.map +1 -1
  98. package/dist/api/post-hoc-deliver.d.ts +7 -0
  99. package/dist/api/post-hoc-deliver.d.ts.map +1 -1
  100. package/dist/api/post-hoc-deliver.js +17 -5
  101. package/dist/api/post-hoc-deliver.js.map +1 -1
  102. package/dist/api/product-publish.d.ts +242 -0
  103. package/dist/api/product-publish.d.ts.map +1 -0
  104. package/dist/api/product-publish.js +902 -0
  105. package/dist/api/product-publish.js.map +1 -0
  106. package/dist/api/product.d.ts +5 -6
  107. package/dist/api/product.d.ts.map +1 -1
  108. package/dist/api/product.js +4 -4
  109. package/dist/api/product.js.map +1 -1
  110. package/dist/api/proposal-cut.d.ts +95 -0
  111. package/dist/api/proposal-cut.d.ts.map +1 -0
  112. package/dist/api/proposal-cut.js +231 -0
  113. package/dist/api/proposal-cut.js.map +1 -0
  114. package/dist/api/proposal-decisions.d.ts +44 -0
  115. package/dist/api/proposal-decisions.d.ts.map +1 -0
  116. package/dist/api/proposal-decisions.js +85 -0
  117. package/dist/api/proposal-decisions.js.map +1 -0
  118. package/dist/api/proposal-onboard.d.ts +29 -0
  119. package/dist/api/proposal-onboard.d.ts.map +1 -1
  120. package/dist/api/proposal-onboard.js +162 -11
  121. package/dist/api/proposal-onboard.js.map +1 -1
  122. package/dist/api/recording.d.ts.map +1 -1
  123. package/dist/api/recording.js +4 -5
  124. package/dist/api/recording.js.map +1 -1
  125. package/dist/api/redeliver.d.ts.map +1 -1
  126. package/dist/api/redeliver.js +11 -7
  127. package/dist/api/redeliver.js.map +1 -1
  128. package/dist/api/repo-input.d.ts.map +1 -1
  129. package/dist/api/repo-input.js +5 -2
  130. package/dist/api/repo-input.js.map +1 -1
  131. package/dist/api/repo-origins.d.ts +24 -0
  132. package/dist/api/repo-origins.d.ts.map +1 -0
  133. package/dist/api/repo-origins.js +71 -0
  134. package/dist/api/repo-origins.js.map +1 -0
  135. package/dist/api/requirements.d.ts +39 -4
  136. package/dist/api/requirements.d.ts.map +1 -1
  137. package/dist/api/requirements.js +76 -5
  138. package/dist/api/requirements.js.map +1 -1
  139. package/dist/api/review-change.d.ts +5 -6
  140. package/dist/api/review-change.d.ts.map +1 -1
  141. package/dist/api/review-change.js +45 -8
  142. package/dist/api/review-change.js.map +1 -1
  143. package/dist/api/routes.d.ts +48 -4
  144. package/dist/api/routes.d.ts.map +1 -1
  145. package/dist/api/routes.js +926 -268
  146. package/dist/api/routes.js.map +1 -1
  147. package/dist/api/run-liveness.d.ts.map +1 -1
  148. package/dist/api/run-liveness.js +3 -1
  149. package/dist/api/run-liveness.js.map +1 -1
  150. package/dist/api/run-sources.d.ts +11 -1
  151. package/dist/api/run-sources.d.ts.map +1 -1
  152. package/dist/api/run-sources.js +26 -3
  153. package/dist/api/run-sources.js.map +1 -1
  154. package/dist/api/run-timing-index.d.ts +56 -1
  155. package/dist/api/run-timing-index.d.ts.map +1 -1
  156. package/dist/api/run-timing-index.js +164 -10
  157. package/dist/api/run-timing-index.js.map +1 -1
  158. package/dist/api/runtime-state.d.ts +6 -0
  159. package/dist/api/runtime-state.d.ts.map +1 -1
  160. package/dist/api/runtime-state.js +14 -3
  161. package/dist/api/runtime-state.js.map +1 -1
  162. package/dist/api/seat-agents.d.ts.map +1 -1
  163. package/dist/api/seat-agents.js +3 -3
  164. package/dist/api/seat-agents.js.map +1 -1
  165. package/dist/api/seat-container-login.d.ts +17 -19
  166. package/dist/api/seat-container-login.d.ts.map +1 -1
  167. package/dist/api/seat-container-login.js +51 -76
  168. package/dist/api/seat-container-login.js.map +1 -1
  169. package/dist/api/seat-governance.d.ts +3 -2
  170. package/dist/api/seat-governance.d.ts.map +1 -1
  171. package/dist/api/seat-governance.js +31 -9
  172. package/dist/api/seat-governance.js.map +1 -1
  173. package/dist/api/seat-standing.d.ts +8 -0
  174. package/dist/api/seat-standing.d.ts.map +1 -1
  175. package/dist/api/seat-standing.js +26 -1
  176. package/dist/api/seat-standing.js.map +1 -1
  177. package/dist/api/server.d.ts +7 -0
  178. package/dist/api/server.d.ts.map +1 -1
  179. package/dist/api/server.js +93 -39
  180. package/dist/api/server.js.map +1 -1
  181. package/dist/api/start-on-login.d.ts +4 -0
  182. package/dist/api/start-on-login.d.ts.map +1 -0
  183. package/dist/api/start-on-login.js +35 -0
  184. package/dist/api/start-on-login.js.map +1 -0
  185. package/dist/api/steering-landing.d.ts +33 -8
  186. package/dist/api/steering-landing.d.ts.map +1 -1
  187. package/dist/api/steering-landing.js +235 -51
  188. package/dist/api/steering-landing.js.map +1 -1
  189. package/dist/api/system-snapshot.d.ts +2 -1
  190. package/dist/api/system-snapshot.d.ts.map +1 -1
  191. package/dist/api/system-snapshot.js +22 -9
  192. package/dist/api/system-snapshot.js.map +1 -1
  193. package/dist/api/ui-text.d.ts.map +1 -1
  194. package/dist/api/ui-text.js +3 -1
  195. package/dist/api/ui-text.js.map +1 -1
  196. package/dist/api/worktree-sweep.d.ts +7 -3
  197. package/dist/api/worktree-sweep.d.ts.map +1 -1
  198. package/dist/api/worktree-sweep.js +10 -6
  199. package/dist/api/worktree-sweep.js.map +1 -1
  200. package/dist/apps/exec/recall.d.ts.map +1 -1
  201. package/dist/apps/exec/recall.js +4 -4
  202. package/dist/apps/exec/recall.js.map +1 -1
  203. package/dist/apps/git.js +2 -2
  204. package/dist/apps/git.js.map +1 -1
  205. package/dist/apps/publish/manifest.d.ts +2 -0
  206. package/dist/apps/publish/manifest.d.ts.map +1 -1
  207. package/dist/apps/publish/manifest.js +8 -3
  208. package/dist/apps/publish/manifest.js.map +1 -1
  209. package/dist/apps/publish/run.d.ts +11 -1
  210. package/dist/apps/publish/run.d.ts.map +1 -1
  211. package/dist/apps/publish/run.js +97 -17
  212. package/dist/apps/publish/run.js.map +1 -1
  213. package/dist/apps/routes.d.ts +2 -0
  214. package/dist/apps/routes.d.ts.map +1 -1
  215. package/dist/apps/routes.js +45 -2
  216. package/dist/apps/routes.js.map +1 -1
  217. package/dist/apps/store.d.ts +35 -3
  218. package/dist/apps/store.d.ts.map +1 -1
  219. package/dist/apps/store.js +73 -9
  220. package/dist/apps/store.js.map +1 -1
  221. package/dist/apps/turns.d.ts +25 -2
  222. package/dist/apps/turns.d.ts.map +1 -1
  223. package/dist/apps/turns.js +276 -11
  224. package/dist/apps/turns.js.map +1 -1
  225. package/dist/apps-server/runners/sqlite-runner.mjs +39 -1
  226. package/dist/apps-server/server/lib/bundle/server.mjs +124 -14
  227. package/dist/cli/index.d.ts.map +1 -1
  228. package/dist/cli/index.js +27 -52
  229. package/dist/cli/index.js.map +1 -1
  230. package/dist/cli/start-stand-ins.d.ts +13 -0
  231. package/dist/cli/start-stand-ins.d.ts.map +1 -0
  232. package/dist/cli/start-stand-ins.js +30 -0
  233. package/dist/cli/start-stand-ins.js.map +1 -0
  234. package/dist/core/adapter.d.ts +66 -14
  235. package/dist/core/adapter.d.ts.map +1 -1
  236. package/dist/core/adapter.js +228 -56
  237. package/dist/core/adapter.js.map +1 -1
  238. package/dist/core/ado-deliver-helper.d.ts +2 -1
  239. package/dist/core/ado-deliver-helper.d.ts.map +1 -1
  240. package/dist/core/ado-deliver-helper.js +26 -1
  241. package/dist/core/ado-deliver-helper.js.map +1 -1
  242. package/dist/core/ado-env.d.ts +17 -0
  243. package/dist/core/ado-env.d.ts.map +1 -0
  244. package/dist/core/ado-env.js +34 -0
  245. package/dist/core/ado-env.js.map +1 -0
  246. package/dist/core/assurance.d.ts +10 -0
  247. package/dist/core/assurance.d.ts.map +1 -1
  248. package/dist/core/assurance.js +23 -0
  249. package/dist/core/assurance.js.map +1 -1
  250. package/dist/core/deliver-text.d.ts +19 -0
  251. package/dist/core/deliver-text.d.ts.map +1 -1
  252. package/dist/core/deliver-text.js +77 -1
  253. package/dist/core/deliver-text.js.map +1 -1
  254. package/dist/core/deliver.d.ts +49 -1
  255. package/dist/core/deliver.d.ts.map +1 -1
  256. package/dist/core/deliver.js +142 -6
  257. package/dist/core/deliver.js.map +1 -1
  258. package/dist/core/estate-mcp-client.d.ts.map +1 -1
  259. package/dist/core/estate-mcp-client.js +4 -8
  260. package/dist/core/estate-mcp-client.js.map +1 -1
  261. package/dist/core/exec.d.ts +16 -1
  262. package/dist/core/exec.d.ts.map +1 -1
  263. package/dist/core/exec.js +32 -2
  264. package/dist/core/exec.js.map +1 -1
  265. package/dist/core/governance-store.d.ts +3 -1
  266. package/dist/core/governance-store.d.ts.map +1 -1
  267. package/dist/core/governance-store.js +7 -2
  268. package/dist/core/governance-store.js.map +1 -1
  269. package/dist/core/linked-issues.d.ts +13 -2
  270. package/dist/core/linked-issues.d.ts.map +1 -1
  271. package/dist/core/linked-issues.js +135 -4
  272. package/dist/core/linked-issues.js.map +1 -1
  273. package/dist/core/redeliver.js +2 -2
  274. package/dist/core/redeliver.js.map +1 -1
  275. package/dist/core/repo-clone.d.ts +64 -0
  276. package/dist/core/repo-clone.d.ts.map +1 -0
  277. package/dist/core/repo-clone.js +307 -0
  278. package/dist/core/repo-clone.js.map +1 -0
  279. package/dist/core/run-identity.d.ts.map +1 -1
  280. package/dist/core/run-identity.js +3 -0
  281. package/dist/core/run-identity.js.map +1 -1
  282. package/dist/core/run-log-facts.d.ts +56 -0
  283. package/dist/core/run-log-facts.d.ts.map +1 -0
  284. package/dist/core/run-log-facts.js +230 -0
  285. package/dist/core/run-log-facts.js.map +1 -0
  286. package/dist/core/run-read-lane.d.ts +30 -0
  287. package/dist/core/run-read-lane.d.ts.map +1 -0
  288. package/dist/core/run-read-lane.js +103 -0
  289. package/dist/core/run-read-lane.js.map +1 -0
  290. package/dist/core/shutdown.d.ts +27 -0
  291. package/dist/core/shutdown.d.ts.map +1 -1
  292. package/dist/core/shutdown.js +72 -0
  293. package/dist/core/shutdown.js.map +1 -1
  294. package/dist/core/stand-in.d.ts +40 -0
  295. package/dist/core/stand-in.d.ts.map +1 -0
  296. package/dist/core/stand-in.js +118 -0
  297. package/dist/core/stand-in.js.map +1 -0
  298. package/dist/core/types.d.ts +27 -0
  299. package/dist/core/types.d.ts.map +1 -1
  300. package/dist/core/types.js.map +1 -1
  301. package/dist/core/walkthrough-root.d.ts.map +1 -1
  302. package/dist/core/walkthrough-root.js +3 -5
  303. package/dist/core/walkthrough-root.js.map +1 -1
  304. package/dist/core/wicked-home.d.ts +9 -0
  305. package/dist/core/wicked-home.d.ts.map +1 -0
  306. package/dist/core/wicked-home.js +25 -0
  307. package/dist/core/wicked-home.js.map +1 -0
  308. package/dist/decisions/consider.d.ts +2 -1
  309. package/dist/decisions/consider.d.ts.map +1 -1
  310. package/dist/decisions/consider.js +2 -2
  311. package/dist/decisions/consider.js.map +1 -1
  312. package/dist/decisions/land.d.ts +2 -0
  313. package/dist/decisions/land.d.ts.map +1 -1
  314. package/dist/decisions/land.js +16 -3
  315. package/dist/decisions/land.js.map +1 -1
  316. package/dist/decisions/rules-brief.d.ts +2 -1
  317. package/dist/decisions/rules-brief.d.ts.map +1 -1
  318. package/dist/decisions/rules-brief.js +3 -2
  319. package/dist/decisions/rules-brief.js.map +1 -1
  320. package/dist/editors/conformance-runtime.d.ts +0 -2
  321. package/dist/editors/conformance-runtime.d.ts.map +1 -1
  322. package/dist/editors/conformance-runtime.js +0 -4
  323. package/dist/editors/conformance-runtime.js.map +1 -1
  324. package/dist/editors/pack-extras.d.ts +162 -0
  325. package/dist/editors/pack-extras.d.ts.map +1 -0
  326. package/dist/editors/pack-extras.js +596 -0
  327. package/dist/editors/pack-extras.js.map +1 -0
  328. package/dist/editors/pack-install.d.ts +26 -22
  329. package/dist/editors/pack-install.d.ts.map +1 -1
  330. package/dist/editors/pack-install.js +187 -80
  331. package/dist/editors/pack-install.js.map +1 -1
  332. package/dist/editors/registry.d.ts +66 -13
  333. package/dist/editors/registry.d.ts.map +1 -1
  334. package/dist/editors/registry.js +147 -24
  335. package/dist/editors/registry.js.map +1 -1
  336. package/dist/editors/routes.d.ts +10 -5
  337. package/dist/editors/routes.d.ts.map +1 -1
  338. package/dist/editors/routes.js +45 -11
  339. package/dist/editors/routes.js.map +1 -1
  340. package/dist/editors/visuals.d.ts +4 -3
  341. package/dist/editors/visuals.d.ts.map +1 -1
  342. package/dist/editors/visuals.js +17 -7
  343. package/dist/editors/visuals.js.map +1 -1
  344. package/dist/evals/runner.js +1 -1
  345. package/dist/evals/runner.js.map +1 -1
  346. package/dist/evals/shape.d.ts +7 -1
  347. package/dist/evals/shape.d.ts.map +1 -1
  348. package/dist/evals/shape.js +26 -6
  349. package/dist/evals/shape.js.map +1 -1
  350. package/dist/evals/workflow.d.ts +16 -3
  351. package/dist/evals/workflow.d.ts.map +1 -1
  352. package/dist/evals/workflow.js +31 -6
  353. package/dist/evals/workflow.js.map +1 -1
  354. package/dist/insights/review-service.d.ts +24 -3
  355. package/dist/insights/review-service.d.ts.map +1 -1
  356. package/dist/insights/review-service.js +75 -12
  357. package/dist/insights/review-service.js.map +1 -1
  358. package/dist/insights/routes.d.ts +2 -1
  359. package/dist/insights/routes.d.ts.map +1 -1
  360. package/dist/insights/routes.js +19 -4
  361. package/dist/insights/routes.js.map +1 -1
  362. package/dist/insights/run-facts.d.ts +5 -0
  363. package/dist/insights/run-facts.d.ts.map +1 -1
  364. package/dist/insights/run-facts.js +15 -0
  365. package/dist/insights/run-facts.js.map +1 -1
  366. package/dist/insights/workflow.d.ts +2 -1
  367. package/dist/insights/workflow.d.ts.map +1 -1
  368. package/dist/insights/workflow.js +4 -4
  369. package/dist/insights/workflow.js.map +1 -1
  370. package/dist/inspect/service.d.ts +3 -2
  371. package/dist/inspect/service.d.ts.map +1 -1
  372. package/dist/inspect/service.js +4 -4
  373. package/dist/inspect/service.js.map +1 -1
  374. package/dist/interactive/bridge-pool.d.ts +5 -2
  375. package/dist/interactive/bridge-pool.d.ts.map +1 -1
  376. package/dist/interactive/bridge-pool.js +10 -5
  377. package/dist/interactive/bridge-pool.js.map +1 -1
  378. package/dist/interactive/chat-events.d.ts.map +1 -1
  379. package/dist/interactive/chat-events.js +7 -1
  380. package/dist/interactive/chat-events.js.map +1 -1
  381. package/dist/interactive/draft-events.d.ts +3 -0
  382. package/dist/interactive/draft-events.d.ts.map +1 -1
  383. package/dist/interactive/draft-events.js +5 -8
  384. package/dist/interactive/draft-events.js.map +1 -1
  385. package/dist/interactive/draft-skill.d.ts +56 -3
  386. package/dist/interactive/draft-skill.d.ts.map +1 -1
  387. package/dist/interactive/draft-skill.js +129 -20
  388. package/dist/interactive/draft-skill.js.map +1 -1
  389. package/dist/interactive/landing-guard.d.ts +30 -5
  390. package/dist/interactive/landing-guard.d.ts.map +1 -1
  391. package/dist/interactive/landing-guard.js +196 -6
  392. package/dist/interactive/landing-guard.js.map +1 -1
  393. package/dist/interactive/proposal-create.d.ts.map +1 -1
  394. package/dist/interactive/proposal-create.js +1 -0
  395. package/dist/interactive/proposal-create.js.map +1 -1
  396. package/dist/interactive/proposal-refine.d.ts.map +1 -1
  397. package/dist/interactive/proposal-refine.js +16 -1
  398. package/dist/interactive/proposal-refine.js.map +1 -1
  399. package/dist/interactive/review-events.js +1 -1
  400. package/dist/interactive/review-events.js.map +1 -1
  401. package/dist/interactive/run-units.d.ts.map +1 -1
  402. package/dist/interactive/run-units.js +3 -2
  403. package/dist/interactive/run-units.js.map +1 -1
  404. package/dist/interactive/source-packet.d.ts +8 -0
  405. package/dist/interactive/source-packet.d.ts.map +1 -1
  406. package/dist/interactive/source-packet.js +47 -6
  407. package/dist/interactive/source-packet.js.map +1 -1
  408. package/dist/knowledge/adapters/toolbox/memory.d.ts.map +1 -1
  409. package/dist/knowledge/adapters/toolbox/memory.js +3 -2
  410. package/dist/knowledge/adapters/toolbox/memory.js.map +1 -1
  411. package/dist/knowledge/adapters/toolbox/supervisor.d.ts +21 -1
  412. package/dist/knowledge/adapters/toolbox/supervisor.d.ts.map +1 -1
  413. package/dist/knowledge/adapters/toolbox/supervisor.js +76 -26
  414. package/dist/knowledge/adapters/toolbox/supervisor.js.map +1 -1
  415. package/dist/knowledge/estate-write.d.ts +5 -0
  416. package/dist/knowledge/estate-write.d.ts.map +1 -1
  417. package/dist/knowledge/estate-write.js +7 -0
  418. package/dist/knowledge/estate-write.js.map +1 -1
  419. package/dist/knowledge/projector.d.ts +60 -5
  420. package/dist/knowledge/projector.d.ts.map +1 -1
  421. package/dist/knowledge/projector.js +264 -21
  422. package/dist/knowledge/projector.js.map +1 -1
  423. package/dist/knowledge/shapes/map.d.ts.map +1 -1
  424. package/dist/knowledge/shapes/map.js +12 -2
  425. package/dist/knowledge/shapes/map.js.map +1 -1
  426. package/dist/knowledge/shapes/routes.d.ts +1 -1
  427. package/dist/knowledge/shapes/routes.d.ts.map +1 -1
  428. package/dist/knowledge/shapes/routes.js +42 -16
  429. package/dist/knowledge/shapes/routes.js.map +1 -1
  430. package/dist/knowledge/shapes/shapes.d.ts +60 -13
  431. package/dist/knowledge/shapes/shapes.d.ts.map +1 -1
  432. package/dist/knowledge/shapes/shapes.js +199 -31
  433. package/dist/knowledge/shapes/shapes.js.map +1 -1
  434. package/dist/knowledge/shapes/verified.d.ts.map +1 -1
  435. package/dist/knowledge/shapes/verified.js +3 -2
  436. package/dist/knowledge/shapes/verified.js.map +1 -1
  437. package/dist/knowledge/trackers/addresses.d.ts +27 -3
  438. package/dist/knowledge/trackers/addresses.d.ts.map +1 -1
  439. package/dist/knowledge/trackers/addresses.js +33 -5
  440. package/dist/knowledge/trackers/addresses.js.map +1 -1
  441. package/dist/knowledge/trackers/gate-pm.d.ts.map +1 -1
  442. package/dist/knowledge/trackers/gate-pm.js +4 -2
  443. package/dist/knowledge/trackers/gate-pm.js.map +1 -1
  444. package/dist/knowledge/trackers/projector.d.ts +3 -1
  445. package/dist/knowledge/trackers/projector.d.ts.map +1 -1
  446. package/dist/knowledge/trackers/projector.js +59 -8
  447. package/dist/knowledge/trackers/projector.js.map +1 -1
  448. package/dist/knowledge/trackers/set.d.ts +28 -0
  449. package/dist/knowledge/trackers/set.d.ts.map +1 -1
  450. package/dist/knowledge/trackers/set.js +26 -0
  451. package/dist/knowledge/trackers/set.js.map +1 -1
  452. package/dist/learn/scheduler.d.ts.map +1 -1
  453. package/dist/learn/scheduler.js +11 -2
  454. package/dist/learn/scheduler.js.map +1 -1
  455. package/dist/learnings/extract.d.ts +9 -3
  456. package/dist/learnings/extract.d.ts.map +1 -1
  457. package/dist/learnings/extract.js +62 -4
  458. package/dist/learnings/extract.js.map +1 -1
  459. package/dist/learnings/replacement-lineage.d.ts +3 -2
  460. package/dist/learnings/replacement-lineage.d.ts.map +1 -1
  461. package/dist/learnings/replacement-lineage.js +7 -6
  462. package/dist/learnings/replacement-lineage.js.map +1 -1
  463. package/dist/learnings/service.d.ts +12 -2
  464. package/dist/learnings/service.d.ts.map +1 -1
  465. package/dist/learnings/service.js +30 -5
  466. package/dist/learnings/service.js.map +1 -1
  467. package/dist/mcp/broker.d.ts.map +1 -1
  468. package/dist/mcp/broker.js +18 -4
  469. package/dist/mcp/broker.js.map +1 -1
  470. package/dist/mcp/estate-relay.d.ts +3 -0
  471. package/dist/mcp/estate-relay.d.ts.map +1 -1
  472. package/dist/mcp/estate-relay.js +5 -2
  473. package/dist/mcp/estate-relay.js.map +1 -1
  474. package/dist/mcp/invoke.js +2 -2
  475. package/dist/mcp/invoke.js.map +1 -1
  476. package/dist/mcp/policies.d.ts +35 -0
  477. package/dist/mcp/policies.d.ts.map +1 -1
  478. package/dist/mcp/policies.js +138 -1
  479. package/dist/mcp/policies.js.map +1 -1
  480. package/dist/mcp/redact.d.ts +1 -1
  481. package/dist/mcp/redact.d.ts.map +1 -1
  482. package/dist/mcp/redact.js +61 -4
  483. package/dist/mcp/redact.js.map +1 -1
  484. package/dist/mcp/registry-store.d.ts +35 -0
  485. package/dist/mcp/registry-store.d.ts.map +1 -1
  486. package/dist/mcp/registry-store.js +33 -0
  487. package/dist/mcp/registry-store.js.map +1 -1
  488. package/dist/mcp/registry.d.ts +65 -4
  489. package/dist/mcp/registry.d.ts.map +1 -1
  490. package/dist/mcp/registry.js +295 -21
  491. package/dist/mcp/registry.js.map +1 -1
  492. package/dist/mcp/rest.js +3 -3
  493. package/dist/mcp/rest.js.map +1 -1
  494. package/dist/mcp/run-fence.d.ts +2 -0
  495. package/dist/mcp/run-fence.d.ts.map +1 -1
  496. package/dist/mcp/run-fence.js +9 -0
  497. package/dist/mcp/run-fence.js.map +1 -1
  498. package/dist/mcp/trigger-names.d.ts +32 -0
  499. package/dist/mcp/trigger-names.d.ts.map +1 -0
  500. package/dist/mcp/trigger-names.js +529 -0
  501. package/dist/mcp/trigger-names.js.map +1 -0
  502. package/dist/mcp/upstream-error.d.ts +5 -1
  503. package/dist/mcp/upstream-error.d.ts.map +1 -1
  504. package/dist/mcp/upstream-error.js +5 -1
  505. package/dist/mcp/upstream-error.js.map +1 -1
  506. package/dist/projects/graph.d.ts +6 -4
  507. package/dist/projects/graph.d.ts.map +1 -1
  508. package/dist/projects/graph.js +173 -25
  509. package/dist/projects/graph.js.map +1 -1
  510. package/dist/projects/routes.d.ts +7 -1
  511. package/dist/projects/routes.d.ts.map +1 -1
  512. package/dist/projects/routes.js +13 -5
  513. package/dist/projects/routes.js.map +1 -1
  514. package/dist/projects/state-home-preflight.d.ts +5 -0
  515. package/dist/projects/state-home-preflight.d.ts.map +1 -1
  516. package/dist/projects/state-home-preflight.js +48 -8
  517. package/dist/projects/state-home-preflight.js.map +1 -1
  518. package/dist/projects/state-home-registry.d.ts.map +1 -1
  519. package/dist/projects/state-home-registry.js +6 -0
  520. package/dist/projects/state-home-registry.js.map +1 -1
  521. package/dist/projects/state-home.d.ts +6 -2
  522. package/dist/projects/state-home.d.ts.map +1 -1
  523. package/dist/projects/state-home.js +8 -5
  524. package/dist/projects/state-home.js.map +1 -1
  525. package/dist/qe/test-sets.d.ts +1 -1
  526. package/dist/qe/test-sets.d.ts.map +1 -1
  527. package/dist/qe/test-sets.js +2 -2
  528. package/dist/qe/test-sets.js.map +1 -1
  529. package/dist/schedules/routes.d.ts +5 -0
  530. package/dist/schedules/routes.d.ts.map +1 -1
  531. package/dist/schedules/routes.js +32 -5
  532. package/dist/schedules/routes.js.map +1 -1
  533. package/dist/schedules/scheduler.d.ts +8 -1
  534. package/dist/schedules/scheduler.d.ts.map +1 -1
  535. package/dist/schedules/scheduler.js +10 -1
  536. package/dist/schedules/scheduler.js.map +1 -1
  537. package/dist/schedules/store.d.ts +7 -0
  538. package/dist/schedules/store.d.ts.map +1 -1
  539. package/dist/schedules/store.js +19 -4
  540. package/dist/schedules/store.js.map +1 -1
  541. package/dist/skills/plugin-source.js +4 -4
  542. package/dist/skills/plugin-source.js.map +1 -1
  543. package/dist/skills/store.d.ts +11 -1
  544. package/dist/skills/store.d.ts.map +1 -1
  545. package/dist/skills/store.js +37 -3
  546. package/dist/skills/store.js.map +1 -1
  547. package/dist/sources/drivers/sqlite.d.ts +13 -0
  548. package/dist/sources/drivers/sqlite.d.ts.map +1 -1
  549. package/dist/sources/drivers/sqlite.js +11 -0
  550. package/dist/sources/drivers/sqlite.js.map +1 -1
  551. package/dist/sources/routes.d.ts.map +1 -1
  552. package/dist/sources/routes.js +1 -0
  553. package/dist/sources/routes.js.map +1 -1
  554. package/dist/sources/uploads.d.ts +22 -2
  555. package/dist/sources/uploads.d.ts.map +1 -1
  556. package/dist/sources/uploads.js +108 -10
  557. package/dist/sources/uploads.js.map +1 -1
  558. package/dist/standing-orders/parse.d.ts +8 -0
  559. package/dist/standing-orders/parse.d.ts.map +1 -1
  560. package/dist/standing-orders/parse.js +52 -5
  561. package/dist/standing-orders/parse.js.map +1 -1
  562. package/dist/studio/apps-standalone/fixture.js +3 -3
  563. package/dist/studio/assets/{KnowledgeGraph-dfq7Flyj.js → KnowledgeGraph-D6RRLDnV.js} +1 -1
  564. package/dist/studio/assets/index-BLo9vFQI.js +1128 -0
  565. package/dist/studio/assets/index-xW21Gkam.css +32 -0
  566. package/dist/studio/editors/wicked-apps/editor.json +1 -1
  567. package/dist/studio/editors/wicked-apps/index.html +1 -1
  568. package/dist/studio/editors/wicked-deck/editor.json +1 -1
  569. package/dist/studio/editors/wicked-deck/index.html +1 -1
  570. package/dist/studio/editors/wicked-doc/editor.json +1 -1
  571. package/dist/studio/editors/wicked-doc/index.html +1 -1
  572. package/dist/studio/editors/wicked-insights/editor.json +1 -1
  573. package/dist/studio/editors/wicked-insights/index.html +1 -1
  574. package/dist/studio/editors/wicked-page/editor.json +1 -1
  575. package/dist/studio/editors/wicked-page/index.html +1 -1
  576. package/dist/studio/editors/wicked-video/editor.json +1 -1
  577. package/dist/studio/editors/wicked-video/index.html +1 -1
  578. package/dist/studio/index.html +2 -2
  579. package/dist/studio/testid-inventory.json +1687 -236
  580. package/dist/team/routes.d.ts +4 -1
  581. package/dist/team/routes.d.ts.map +1 -1
  582. package/dist/team/routes.js +3 -2
  583. package/dist/team/routes.js.map +1 -1
  584. package/dist/voice/tts.d.ts +18 -0
  585. package/dist/voice/tts.d.ts.map +1 -1
  586. package/dist/voice/tts.js +134 -29
  587. package/dist/voice/tts.js.map +1 -1
  588. package/dist/workflow-catalog/build-v2.d.ts +34 -0
  589. package/dist/workflow-catalog/build-v2.d.ts.map +1 -1
  590. package/dist/workflow-catalog/build-v2.js +131 -10
  591. package/dist/workflow-catalog/build-v2.js.map +1 -1
  592. package/dist/workflow-catalog/catalog-data.d.ts.map +1 -1
  593. package/dist/workflow-catalog/catalog-data.js +0 -2
  594. package/dist/workflow-catalog/catalog-data.js.map +1 -1
  595. package/dist/workflow-catalog/detect.d.ts +18 -3
  596. package/dist/workflow-catalog/detect.d.ts.map +1 -1
  597. package/dist/workflow-catalog/detect.js +43 -8
  598. package/dist/workflow-catalog/detect.js.map +1 -1
  599. package/dist/working-doc/event-lines.d.ts +5 -2
  600. package/dist/working-doc/event-lines.d.ts.map +1 -1
  601. package/dist/working-doc/event-lines.js +38 -7
  602. package/dist/working-doc/event-lines.js.map +1 -1
  603. package/dist/working-doc/sections.d.ts +3 -0
  604. package/dist/working-doc/sections.d.ts.map +1 -1
  605. package/dist/working-doc/sections.js +5 -0
  606. package/dist/working-doc/sections.js.map +1 -1
  607. package/dist/working-doc/service.d.ts +23 -3
  608. package/dist/working-doc/service.d.ts.map +1 -1
  609. package/dist/working-doc/service.js +93 -54
  610. package/dist/working-doc/service.js.map +1 -1
  611. package/endpoint-manifest.json +144 -8
  612. package/evals/corpora/shape-v1.json +25 -1
  613. package/evals/corpora/shape-v1.seat-fixture.json +25 -1
  614. package/package.json +4 -4
  615. package/runners/sqlite-runner.mjs +39 -1
  616. package/voice-locks/darwin-arm64-cp310.txt +12 -0
  617. package/voice-locks/darwin-arm64-cp311.txt +8 -0
  618. package/voice-locks/darwin-arm64-cp312.txt +8 -0
  619. package/voice-locks/darwin-arm64-cp313.txt +8 -0
  620. package/voice-locks/darwin-arm64-cp314.txt +8 -0
  621. package/voice-locks/darwin-arm64-cp39.txt +12 -0
  622. package/voice-locks/darwin-x64-cp310.txt +12 -0
  623. package/voice-locks/darwin-x64-cp311.txt +12 -0
  624. package/voice-locks/darwin-x64-cp312.txt +12 -0
  625. package/voice-locks/darwin-x64-cp313.txt +12 -0
  626. package/voice-locks/darwin-x64-cp39.txt +12 -0
  627. package/voice-locks/linux-arm64-cp310.txt +12 -0
  628. package/voice-locks/linux-arm64-cp311.txt +8 -0
  629. package/voice-locks/linux-arm64-cp312.txt +8 -0
  630. package/voice-locks/linux-arm64-cp313.txt +8 -0
  631. package/voice-locks/linux-arm64-cp314.txt +8 -0
  632. package/voice-locks/linux-arm64-cp39.txt +12 -0
  633. package/voice-locks/linux-x64-cp310.txt +12 -0
  634. package/voice-locks/linux-x64-cp311.txt +8 -0
  635. package/voice-locks/linux-x64-cp312.txt +8 -0
  636. package/voice-locks/linux-x64-cp313.txt +8 -0
  637. package/voice-locks/linux-x64-cp314.txt +8 -0
  638. package/voice-locks/linux-x64-cp39.txt +12 -0
  639. package/dist/studio/assets/index-Bame65hj.js +0 -1108
  640. package/dist/studio/assets/index-CtB1BJRI.css +0 -32
@@ -2,12 +2,13 @@ import { RuleChangedError, ruleRevision } from '../governance/rule-revision.js';
2
2
  import { registerRedeliverRoutes } from './redeliver.js';
3
3
  import { REVIEW_WORKFLOW } from '../insights/workflow.js';
4
4
  import { runUsageCost } from '../insights/run-facts.js';
5
+ import { NoIndependentReviewer } from '../insights/review-service.js';
5
6
  import { appsRuntimeDir, appsServerArtifact, containerEngineKnown } from '../apps/publish/artifacts.js';
6
7
  import { busSeamsOffWarning, busUnavailableWarning } from '../core/bus-notice.js';
7
8
  import { vaultBinWarning, vaultDiagnostics } from '../core/vault-bin.js';
8
9
  import { PlanSchema, toLaunchPlan } from './plan-schema.js';
9
10
  import { record, z } from '../zod.js';
10
- import { listRequirementsRead, setRepoMinimum, getRequirement, patchRequirement, readRequirementsGraph, REQUIREMENTS_NOT_GENERATED, } from './requirements.js';
11
+ import { listRequirementsRead, setRepoMinimum, getRequirement, patchRequirement, retireRequirement, readRequirementsGraph, REQUIREMENTS_NOT_GENERATED, } from './requirements.js';
11
12
  import { randomUUID } from 'node:crypto';
12
13
  import { homedir } from 'node:os';
13
14
  import { readFileSync, existsSync, mkdirSync, realpathSync } from 'node:fs';
@@ -49,7 +50,7 @@ function turnReadRoots(scratchRoot) {
49
50
  }
50
51
  return roots;
51
52
  }
52
- import { detectRefusal, isOpenGate, offeredChoices, replayOpenGate } from './gate-cache.js';
53
+ import { detectRefusal, gateSeqOf, isOpenGate, offeredChoices, replayOpenGate } from './gate-cache.js';
53
54
  import { acceptanceRequirementOf, buildAcceptanceView } from '../qe/acceptance.js';
54
55
  import { runIdentityOf, wireIdentity } from '../core/run-identity.js';
55
56
  import { buildWorkflowCatalog } from '../workflow-catalog/build.js';
@@ -82,11 +83,13 @@ import { InvalidDiffBaseError, MERGE_BASE_LITERAL, NotARegularFileError, Unresol
82
83
  import { DocRunIndex } from '../interactive/doc-run-index.js';
83
84
  import { listInteractiveDocs } from '../interactive/docs-index.js';
84
85
  import { SearchService, registerSearchRoutes } from './search-routes.js';
86
+ import { RepoOrigins, originOf } from './repo-origins.js';
85
87
  import { TestSetIndex } from '../qe/test-sets.js';
86
88
  import { estateExe, parseEstateTotals, projectGraphRefreshDiagnostics, readBlastRadiusPages, resolveProjectGraphBinding } from '../projects/graph.js';
87
- import { attachRepoToProject, registerProjectRoutes } from '../projects/routes.js';
89
+ import { attachRepoToProject, createProjectRecorded, registerProjectRoutes } from '../projects/routes.js';
88
90
  import { registerProjectAggregateRoutes } from './project-aggregates.js';
89
91
  import { composeLaunch, composePreflight, registerProductRoutes } from './product.js';
92
+ import { registerProductPublishRoutes } from './product-publish.js';
90
93
  import { buildWorkflowCatalogV2, parseCommand, resolveOption } from '../workflow-catalog/build-v2.js';
91
94
  import { DEFAULT_PROJECT_ID } from '../projects/default-project.js';
92
95
  import { DETECT_MAX_CHARS, DETECT_TIMEOUT_MS, DetectService, shadowCheck } from '../workflow-catalog/detect-service.js';
@@ -101,7 +104,7 @@ import { inventoryComplete, parseInventoryClaims } from '../core/inventory-claim
101
104
  import { ApproveEditSchema, approveEdited, captureLaunchRoots, editInFlight, FileProposalSchema, registerCaptureRoutes } from './capture.js';
102
105
  import { registerTestingRoutes } from './testing.js';
103
106
  import { registerDefaultEvalRoutes, runAndRecord } from '../evals/routes.js';
104
- import { prepareRunEvalsLaunch, RUN_EVALS_WORKFLOW } from '../evals/workflow.js';
107
+ import { prepareRunEvalsLaunch, RUN_EVALS_WORKFLOW, runEvalsScopeOf } from '../evals/workflow.js';
105
108
  import { DOMAIN_MAPPING } from '../projects/repo-watch.js';
106
109
  import { defaultReplaySet } from '../evals/replay.js';
107
110
  import { gardenRootFor } from '../learn/scheduler.js';
@@ -125,6 +128,7 @@ import { REQUIRED_GARDEN_VERSION } from '../skills/plugin-source.js';
125
128
  import { isSeatKeyList } from '../core/job-seats.js';
126
129
  import { engineRosterJson, noEligibleSeatBody, parseNoEligibleSeat, toEngineSeat } from '../core/engine-roster.js';
127
130
  import { launchAssuranceNotice, readJudgeCoverage } from '../core/assurance.js';
131
+ import { STAND_IN_NEEDED_GATE, USE_STAND_INS_ACTION, consentFor, isStandInReview, preflightRefusal, readPreflight } from '../core/stand-in.js';
128
132
  import { launchPosture } from '../core/launch-posture.js';
129
133
  import { launchRequiresQe, mayRequireQe, qeAcceptanceMode, qeSettingSkipReason } from '../core/qe-acceptance-setting.js';
130
134
  import { aggregateReceipt, postHocDeliveryAssurance, qeAcceptanceFromView, qeAcceptanceRefusal, QE_ACCEPTANCE_REQUIRED_CODE, receiptOf, qeAcceptanceNotRequired, qeDecisionBypasses, qeDecisionOf, qeAcceptanceSkippedAtGate, unreadableQeAcceptance, } from './delivery-assurance.js';
@@ -133,7 +137,7 @@ import { isHumanOperator } from './watch-routes.js';
133
137
  import { boundOrigin, InteractiveBridgePool } from '../interactive/bridge-pool.js';
134
138
  import { defaultInteractiveRoot } from '../interactive/bridge-root.js';
135
139
  import { composeDeliverText, configuredPublicOrigin, extractFollowUps, factsFromRun, reportsFromOutputs, FOLLOW_UPS_MAX, framedDeliverText, runUrlFor, } from '../core/deliver-text.js';
136
- import { deliverAuthorOf, deliverIdentityFor, defaultGhExec, deliverRepoFor, deliverTargetView, isGitHubLogin, pushIdentityOf, readDeliverOriginUrl, resolvePullRequest as resolvePullRequestViaGh, unverifiedTreesFrom, } from '../core/deliver.js';
140
+ import { deliverAuthorOf, deliverIdentityFor, defaultGhExec, deliverRepoFor, deliverTargetView, isGitHubLogin, pinnedGhExec, pinnedGitExec, pushIdentityOf, readDeliverOriginUrl, resolvePullRequest as resolvePullRequestViaGh, unverifiedTreesFrom, } from '../core/deliver.js';
137
141
  import { credentialsMissingIn, deliverCredentialsProbe, missingCredentials } from '../core/deliver-credentials.js';
138
142
  import { codebaseArchiveUrl } from './codebase-archive.js';
139
143
  import { projectRepoCandidates } from '../interactive/doc-grounding.js';
@@ -141,7 +145,8 @@ import { artifactStatus, beneathSupported, buildTurnContext, chatMount, ChatMess
141
145
  import { createDocInProcess, registerInteractiveProxy } from '../interactive/proxy-routes.js';
142
146
  import { CreateLauncher } from '../interactive/proposal-create.js';
143
147
  import { ThemeLauncher } from './proposal-theme.js';
144
- import { CHAT_GIT_PROTOCOLS, OnboardLauncher, probeGitUrl, shownGitUrl, withoutCredentials } from './proposal-onboard.js';
148
+ import { CHAT_GIT_PROTOCOLS, OnboardLauncher, probeGitUrl, withoutCredentials } from './proposal-onboard.js';
149
+ import { CutLauncher } from './proposal-cut.js';
145
150
  import { RefineLauncher } from '../interactive/proposal-refine.js';
146
151
  import { lineageSteps, protectedEdits } from '../interactive/protected-edits.js';
147
152
  import { buildRunBrief } from './run-brief.js';
@@ -151,11 +156,11 @@ const BRIEF_COPY_MAX = 512 * 1024;
151
156
  import { registerInteractiveDocDelete } from '../interactive/doc-delete-routes.js';
152
157
  import { registerInteractiveDocChecks } from '../interactive/doc-checks-routes.js';
153
158
  import { crewStateHome, stateHomeOfDb, wickedWorkRoot } from '../projects/state-home.js';
154
- import { demoShowOf, factsOf, inputLines, jobInputsOfProposal, jobLaunchCommon, jobLaunchRoster, personPid, requestDigest, SELF_SEATED } from './chat-jobs.js';
159
+ import { demoShowOf, factsOf, inputLines, jobInputsOfProposal, jobLaunchCommon, jobLaunchRoster, jobRevisionLaunch, personPid, requestDigest, SELF_SEATED } from './chat-jobs.js';
155
160
  import { DocumentsRefused, documentsClause, RUN_DOCS_TOKENS_MAX, removeStagedDocuments, stagedDocumentsRemoved, stagedDocumentsOf, stageRunDocuments } from './run-documents.js';
156
161
  import { checkSourcePick, projectSources, RUN_SOURCES_MAX, runSourcesDeps, webScopeReason } from './run-sources.js';
157
162
  import { CATALOG_V2_CARDS } from '../workflow-catalog/catalog-data-v2.js';
158
- import { LaunchRefusal, ChatProposals, LaunchOnceRegistry, proposalRunId, RecordingStubDispatcher, RevisionEditsSchema, runCostFromEvents } from './chat-proposals.js';
163
+ import { CHAT_ENDED, LaunchRefusal, ChatProposals, LaunchOnceRegistry, liveInRuns, proposalRunId, RecordingStubDispatcher, RevisionEditsSchema, runCostFromEvents } from './chat-proposals.js';
159
164
  import { CATALOG_SEEDS } from '../workflow-catalog/catalog-data.js';
160
165
  import { registerInteractiveDocList } from '../interactive/doc-list-routes.js';
161
166
  import { REVIEWS_DIRNAME } from '../interactive/review-ledger.js';
@@ -168,7 +173,9 @@ import { pmRegistered, readPmIssues } from '../knowledge/trackers/issues.js';
168
173
  import { registerTrackerRoutes } from '../knowledge/trackers/routes.js';
169
174
  import { AuditLog } from './audit.js';
170
175
  import { auditFor } from './audit-view.js';
176
+ import { ProposalDecisionIndex, recordProposalDecision } from './proposal-decisions.js';
171
177
  import { AcpFoldCache, EngineVersionCache, FloorCacheCache, eventsDirOf, installedPackageVersion, hostSandboxLauncher, seatRosterFile, listStoreFiles, readStudioBundleVersion, } from './diagnostics.js';
178
+ import { DiskStoreCache, readDiskStores } from './disk-stores.js';
172
179
  import { GovernanceDiagnostics } from './governance-health.js';
173
180
  import { ATTACHMENT_LIMITS, ATTACHMENT_MAX_MESSAGE_BYTES, AttachmentError, ChatAttachmentStore, attachmentWire, attachmentsBlock, boundaryOf, parseMultipart, stageForSeat } from './chat-attachments.js';
174
181
  import { CHAT_HISTORY_MAX_LIMIT, ChatHistoryStore, SeedRequestStore, decodeCursor } from './chat-history.js';
@@ -179,6 +186,8 @@ import { idleClis, probeSeatImages, SeatImageRebuilder, seatImageStatusVia } fro
179
186
  import { RunCostCache } from './needs.js';
180
187
  import { governanceStoreFix, legacyHomeOutboxPath } from '../core/governance-store.js';
181
188
  import { UsageError, replayOutboxInto } from '../cli/governance.js';
189
+ import { DEFAULT_DAEMON_PORT } from '../cli/port.js';
190
+ import { startOnLoginStatus } from './start-on-login.js';
182
191
  import { foldDeadletters } from './governance-health.js';
183
192
  import { RetryIndex } from './retry-index.js';
184
193
  import { SEAT_RECORD_DEFAULT_DAYS, SEAT_RECORD_MAX_DAYS, seatRecord } from './seat-record.js';
@@ -188,6 +197,7 @@ import { VoiceService, defaultVoiceDir } from '../voice/service.js';
188
197
  import { TtsService } from '../voice/tts.js';
189
198
  import { VoiceDashboardStore } from '../voice/dashboard.js';
190
199
  import { registerVoiceRoutes } from '../voice/routes.js';
200
+ import { DeskSnoozes, registerDeskSnoozeRoutes } from './desk-snoozes.js';
191
201
  import { VoiceInjectInputs } from '../voice/inject-input.js';
192
202
  import { GroupIndex } from './group-index.js';
193
203
  import { RunTimingIndex, recordRunLaunched } from './run-timing-index.js';
@@ -208,9 +218,10 @@ import { ingestDecision } from '../decisions/ingest.js';
208
218
  import { registerDecisionRoutes } from '../decisions/routes.js';
209
219
  import { ChatDecisionRecorder } from '../decisions/chat-recorder.js';
210
220
  import { ConsiderationService } from '../decisions/consider.js';
211
- import { gardenConformance, gardenPackCheck } from '../editors/pack-install.js';
221
+ import { engineConformance, gardenPackCheck } from '../editors/pack-install.js';
212
222
  import { conformanceProvisioner, conformanceRuntimeReady, conformanceRuntimeRoot, conformanceVenvDir, editorPluginLaunchListener, venvPython } from '../editors/conformance-runtime.js';
213
223
  import { EditorRegistry } from '../editors/registry.js';
224
+ import { packSkillsPort } from '../editors/pack-extras.js';
214
225
  import { registerEditorRoutes, unitTokenProbe } from '../editors/routes.js';
215
226
  import { broadcast } from '../events/bus.js';
216
227
  import { AppWritePath } from '../apps/actions/write-path.js';
@@ -290,6 +301,19 @@ export class LaunchReply {
290
301
  }
291
302
  }
292
303
  /** Keep correctable launch refusals typed, and preserve error codes in other launch failures. */
304
+ /**
305
+ * (crew#1442, coord on #1734) A held run's source pick, for a reshape that keeps it. A pick that can't be read (its
306
+ * store entry gone and the launch trail not read at boot) refuses the launch, 409 `sources_unavailable`, rather than
307
+ * launch it as if the held run had no pick.
308
+ */
309
+ export function heldSourcePick(picks, runId) {
310
+ try {
311
+ return picks.get(runId);
312
+ }
313
+ catch (err) {
314
+ throw jobRefusal(409, { code: 'sources_unavailable', error: `the held run's source pick could not be read: ${message(err)}` });
315
+ }
316
+ }
293
317
  export function jobRefusal(status, payload) {
294
318
  const b = payload;
295
319
  if (status >= 400 && status < 500 && typeof b?.code === 'string') {
@@ -409,6 +433,9 @@ function shapeMemoryItem(raw) {
409
433
  // the surface date-filters on. Absent on an item the store did not stamp; never fabricated.
410
434
  if (typeof r['created_at'] === 'number')
411
435
  item.created_at = r['created_at'];
436
+ // crew#1697: a retired row (`memory.list {retired: true}`) carries when it was retired.
437
+ if (typeof r['retired_at'] === 'number')
438
+ item.retired_at = r['retired_at'];
412
439
  return item;
413
440
  }
414
441
  /** Shape the estate `memory.coverage` result (`{ total, by_tier, by_kind }`) into the wire
@@ -625,6 +652,9 @@ export const LaunchSchema = z.strictObject({
625
652
  * "full assurance", the same as omitting it: the launcher never chooses for the caller, and a
626
653
  * full-assurance launch on a one-CLI roster is answered with `assuranceNotice` (`core/assurance.ts`). */
627
654
  reducedAssurance: z.boolean().optional(),
655
+ /** (api-types 0.231.0, DES-STANDIN-001 §4) A PERSON's consent to stand-in checks for this job: the answer to a
656
+ * `409 stand_in_choice` (its `retryWith`). A worker's bearer gets 403; never with `reducedAssurance`. */
657
+ standIns: z.literal(true).optional(),
628
658
  /** (api-types 0.149.0, program DES-POWER-MODE) Power mode for this launch. Omitted: the daemon's
629
659
  * `powerModeDefault` setting (on when unset). Applies to a repo-scoped plan or preset launch only. */
630
660
  power: z.boolean().optional(),
@@ -644,6 +674,9 @@ export const LaunchSchema = z.strictObject({
644
674
  }).refine((b) => b.documents === undefined || b.documents.length === 0 || b.chatId !== undefined, {
645
675
  path: ['documents'],
646
676
  error: 'documents are chat tokens: send the chatId they were named in',
677
+ }).refine((b) => b.standIns !== true || b.reducedAssurance !== true, {
678
+ path: ['standIns'],
679
+ error: 'standIns and reducedAssurance are mutually exclusive: stand-in checks are labelled checks, reduced assurance skips them',
647
680
  }).refine((b) => b.skipQeAcceptance === undefined || b.forceQeAcceptance !== true, {
648
681
  path: ['forceQeAcceptance'],
649
682
  error: 'skipQeAcceptance and forceQeAcceptance are mutually exclusive — skip it with a reason, or force it',
@@ -741,16 +774,22 @@ export const GateSchema = z.strictObject({
741
774
  amend: z.string().optional(),
742
775
  action: z
743
776
  .union([
744
- z.enum(['approve', 'request_changes', 'reject', 'edit_plan', 'amend_intent', OPERATOR_JUDGMENT_ACTION, SKIP_QE_ACTION, SKIP_RULES_ACTION, ...ESCALATION_ACTIONS]),
777
+ z.enum(['approve', 'request_changes', 'reject', 'edit_plan', 'amend_intent', OPERATOR_JUDGMENT_ACTION, SKIP_QE_ACTION, SKIP_RULES_ACTION, USE_STAND_INS_ACTION, ...ESCALATION_ACTIONS]),
745
778
  z.string().regex(CONSENT_CHOICE_ACTION, 'a consent choice is `consent:<choice id>`'),
746
779
  ])
747
780
  .optional(),
748
781
  amendScope: z.enum(['cursor', 'creator']).optional(),
782
+ /** (api-types 0.231.0, DES-STANDIN-001 §3.10) With `action: 'use_stand_ins'`: this job only, or every job (also
783
+ * saves the `standInReview: 'always'` setting). */
784
+ scope: z.enum(['job', 'always']).optional(),
749
785
  /** DES-TEAMING-002 T3 — approve a `plan_approval` gate WITH AN EDIT (`GateDecision.plan`). */
750
786
  plan: PlanSchema.optional(),
751
787
  /** api-types 0.44.0 — the gate this decision answers (its unit `ord`). A mismatch with the run's
752
788
  * open gate is a 409 `gate_changed`: the decision was made on a gate that is no longer open. */
753
789
  ord: z.int().nonnegative().optional(),
790
+ /** (crew#1698, api-types 0.231.0) The OPENING of the gate this decision answers (`awaitingHuman.gateSeq`): a gate that
791
+ * closed and re-opened since, at the same ord too, is a 409 `gate_changed`. */
792
+ gateSeq: z.int().positive().optional(),
754
793
  /** (api-types 0.192.0, DES-CATALOG-002 §4.6) At a `plan_approval` gate: the plan revision this answer was made on.
755
794
  * Passed with `ord` into the engine's own serialized decision, which refuses a stale one (`gate_changed`). */
756
795
  planRev: z.int().nonnegative().optional(),
@@ -769,8 +808,8 @@ export const GateSchema = z.strictObject({
769
808
  .min(1)
770
809
  .max(500)
771
810
  .optional(),
772
- }).refine((b) => (b.action === SKIP_RULES_ACTION) === (b.skipRules !== undefined), { path: ['skipRules'], error: 'skip_rules needs `skipRules`: [{id, reason}] for each rule you skip (unchecked, waived or disputed), each with your written reason; skipRules goes with skip_rules only' }).refine((b) => b.action !== SKIP_RULES_ACTION || (b.approve && b.amend === undefined && b.amendScope === undefined && b.plan === undefined), { path: ['action'], error: 'skip_rules takes approve: true and no amend, amendScope or plan — the reasons ride skipRules' }).refine((b) => b.skipRules === undefined || new Set(b.skipRules.map((r) => r.id)).size === b.skipRules.length, { path: ['skipRules'], error: 'skipRules names a rule twice' }).refine((b) => b.keepRules === undefined || (b.approve && (b.action === undefined || b.action === 'approve') && b.plan === undefined), { path: ['keepRules'], error: 'keepRules goes with a plain approve (no action other than approve, no plan) of a steering-author propose gate' }).refine((b) => b.action === undefined
773
- || (b.action === 'approve' || b.action === 'edit_plan' || b.action === 'amend_intent' || b.action === OPERATOR_JUDGMENT_ACTION || b.action === SKIP_QE_ACTION || b.action === SKIP_RULES_ACTION || isEscalationAction(b.action)) === b.approve, { path: ['action'], error: '`action` disagrees with `approve`: request_changes and reject require approve: false; approve, edit_plan, amend_intent, operator_judgment, skip_qe, skip_rules, extend, targeted, accept_partial, accept_suggestion, rejudge, retry_rules, retry_qe and consent:<id> require approve: true' }).refine(
811
+ }).refine((b) => (b.action === SKIP_RULES_ACTION) === (b.skipRules !== undefined), { path: ['skipRules'], error: 'skip_rules needs `skipRules`: [{id, reason}] for each rule you skip (unchecked, waived or disputed), each with your written reason; skipRules goes with skip_rules only' }).refine((b) => (b.action === USE_STAND_INS_ACTION) === (b.scope !== undefined), { path: ['scope'], error: "use_stand_ins needs `scope`: 'job' (this job) or 'always' (every job); scope goes with use_stand_ins only" }).refine((b) => b.action !== USE_STAND_INS_ACTION || (b.approve && b.amend === undefined && b.amendScope === undefined && b.plan === undefined), { path: ['action'], error: 'use_stand_ins takes approve: true and no amend, amendScope or plan' }).refine((b) => b.action !== SKIP_RULES_ACTION || (b.approve && b.amend === undefined && b.amendScope === undefined && b.plan === undefined), { path: ['action'], error: 'skip_rules takes approve: true and no amend, amendScope or plan — the reasons ride skipRules' }).refine((b) => b.skipRules === undefined || new Set(b.skipRules.map((r) => r.id)).size === b.skipRules.length, { path: ['skipRules'], error: 'skipRules names a rule twice' }).refine((b) => b.keepRules === undefined || (b.approve && (b.action === undefined || b.action === 'approve') && b.plan === undefined), { path: ['keepRules'], error: 'keepRules goes with a plain approve (no action other than approve, no plan) of a steering-author propose gate' }).refine((b) => b.action === undefined
812
+ || (b.action === 'approve' || b.action === 'edit_plan' || b.action === 'amend_intent' || b.action === OPERATOR_JUDGMENT_ACTION || b.action === SKIP_QE_ACTION || b.action === SKIP_RULES_ACTION || b.action === USE_STAND_INS_ACTION || isEscalationAction(b.action)) === b.approve, { path: ['action'], error: '`action` disagrees with `approve`: request_changes and reject require approve: false; approve, edit_plan, amend_intent, operator_judgment, skip_qe, skip_rules, extend, targeted, accept_partial, accept_suggestion, rejudge, retry_rules, retry_qe, use_stand_ins and consent:<id> require approve: true' }).refine(
774
813
  // (operator ruling 2026-10-21) The override's rationale IS its record: a blank one is a 400 here,
775
814
  // before the engine is asked.
776
815
  (b) => b.action !== OPERATOR_JUDGMENT_ACTION || (b.amend !== undefined && b.amend.trim() !== ''), { path: ['amend'], error: 'operator_judgment needs `amend`: your written rationale — why the failed floor is not the work\'s (an empty one is refused)' }).refine((b) => b.action !== OPERATOR_JUDGMENT_ACTION || (b.amendScope === undefined && b.plan === undefined), { path: ['amendScope'], error: 'operator_judgment takes no amendScope or plan — it answers the failed floor of the gated unit' }).refine(
@@ -805,11 +844,29 @@ const InjectSchema = z.strictObject({
805
844
  * thread says "You (by voice)". It grants nothing a typed note does not. */
806
845
  input: z.literal('voice').optional(),
807
846
  });
808
- export const ResumeSchema = z.strictObject({ ord: z.int().nonnegative().optional() });
847
+ /** (crew#1392) Most characters of a dock steer's words its `run.injected` audit line keeps. */
848
+ export const INJECT_WORDS_MAX = 2_000;
849
+ /** A dock steer's words as the audit line keeps them: at most {@link INJECT_WORDS_MAX} characters, never half a pair. */
850
+ export function injectWords(message) {
851
+ if (message.length <= INJECT_WORDS_MAX)
852
+ return message;
853
+ let end = INJECT_WORDS_MAX;
854
+ const last = message.charCodeAt(end - 1);
855
+ if (last >= 0xd800 && last <= 0xdbff)
856
+ end -= 1;
857
+ return message.slice(0, end);
858
+ }
859
+ /** (crew#1698, api-types 0.231.0) `gateSeq`: which OPENING of the gate an answer was made on (`awaitingHuman.gateSeq`,
860
+ * `GET /runs/:id/gate`'s `gateSeq`). A gate that closed and re-opened since, at the same ord too, is another opening:
861
+ * 409 `gate_changed`. Optional; the ord check stands as before without it. */
862
+ const GateSeqSchema = z.int().positive().optional();
863
+ export const ResumeSchema = z.strictObject({ ord: z.int().nonnegative().optional(), gateSeq: GateSeqSchema });
809
864
  // The manual reassign lever (crew#442): `cli` omitted lets the engine's council re-pick, the
810
865
  // same shape the automatic stall-watchdog escalation uses for an unknown failover target.
811
866
  const ReassignSchema = z.strictObject({
812
867
  ord: z.int().nonnegative().optional(),
868
+ /** (crew#1698) The gate opening a gated reassign answers (see `ResumeSchema`). */
869
+ gateSeq: GateSeqSchema,
813
870
  cli: z.string().min(1).optional(),
814
871
  /** crew#1153: an operator note that rides a GATED reassign as the approve's amendment. Trimmed in
815
872
  * the route; blank counts as absent. The byte cap (on the raw note) is checked there too so the 400 names the limit. */
@@ -846,10 +903,19 @@ export const RetireMemorySchema = z.strictObject({
846
903
  scope_prefix: z.string(),
847
904
  });
848
905
  /** `POST /memory/retire-item` body (studio#206): ONE memory, by its `memory_id` from `GET /memory`.
849
- * `.strict()`: a stray `scope_prefix` is a 400, never read as a wider erase than one row. */
906
+ * `.strict()`: a stray `scope_prefix` is a 400, never read as a wider erase than one row. The same body
907
+ * names the one memory for `POST /memory/erase-item` and `POST /memory/unretire` (crew#1697). */
850
908
  export const RetireMemoryItemSchema = z.strictObject({
851
909
  memory_id: z.string().min(1).max(512),
852
910
  });
911
+ /** `POST /knowledge/forget` body (crew#1697): estate `knowledge.forget`'s own arguments. Exactly one target is
912
+ * checked at the route (a 400 before any spawn); `.strict()`: an unknown field is a 400. */
913
+ export const ForgetKnowledgeSchema = z.strictObject({
914
+ id: z.string().optional(),
915
+ source: z.string().optional(),
916
+ scope_prefix: z.string().optional(),
917
+ confirm_erase_all: z.boolean().optional(),
918
+ });
853
919
  /** `POST /memory/edit` body (wicked-studio's Memory page): ONE memory's new words. `.strict()`: an
854
920
  * unknown field is a 400, never read as something wider than one memory. */
855
921
  export const EditMemorySchema = z.strictObject({
@@ -869,6 +935,30 @@ const memoryEditsInFlight = new Set();
869
935
  /** The error an estate from before wicked-estate#188 answers to `memory.erase {id}`: it knows only the
870
936
  * subtree erase, so it refuses the call (deleting nothing) for want of a `scope_prefix`. */
871
937
  const ESTATE_NO_ERASE_BY_ID = /scope_prefix \(non-empty\) required/i;
938
+ /** crew#1697: how an estate without a tool refuses it. Before wicked-estate#552/#553 `memory.retire`,
939
+ * `memory.unretire` and `knowledge.forget` are unknown tools (-32602 "unknown tool: …"); a memory implementer
940
+ * without retirement answers -32601 "… does not support retirement" / "… retirement is unsupported". Either way
941
+ * nothing was changed. A domain whose store did not open (-32601 "memory domain not available: <why>") is NOT
942
+ * this: it stays a 502 with its own words (codex review). */
943
+ const estateLacksTool = (err) => err instanceof EstateMcpError &&
944
+ ((err.code === -32602 && /unknown tool/i.test(err.message)) ||
945
+ (err.code === -32601 && /does not support retirement|retirement is unsupported/i.test(err.message)));
946
+ /** crew#1697: the count a one-memory estate tool answered (`deleted_count`, `retired_count`, `restored_count`):
947
+ * 0 or 1. Any other answer is estate misbehaving, thrown as an upstream fault (502). */
948
+ function oneMemoryCount(raw, tool, key) {
949
+ const n = typeof raw === 'object' && raw !== null ? raw[key] : undefined;
950
+ if (typeof n !== 'number')
951
+ throw new EstateMcpError(`${tool} returned an unexpected shape`);
952
+ if (n !== 0 && n !== 1)
953
+ throw new EstateMcpError(`${tool} {id} changed ${n} memories, expected 1`);
954
+ return n;
955
+ }
956
+ /** crew#1697: the 501 body for an estate that lacks a tool. */
957
+ function estateUpgrade(what, estatePr, unchanged) {
958
+ return { error: `this wicked-estate ${what} (it needs wicked-estate${estatePr}); upgrade wicked-estate-mcp — ${unchanged}`, code: 'estate_upgrade_required' };
959
+ }
960
+ /** crew#1697: estate's `knowledge.forget` refusing a target (live-source structure named by id): a conflict, not a fault. */
961
+ const ESTATE_FORGET_REFUSED = /knowledge\.forget refused/i;
872
962
  /**
873
963
  * A SKIN-OWNED settings key (crew#323): one lowercase segment under the `studio.` namespace,
874
964
  * e.g. `studio.appearance`, `studio.notifications`. The daemon never interprets these values —
@@ -949,7 +1039,7 @@ export const ChatOpenSchema = z.strictObject({
949
1039
  }).optional(),
950
1040
  requestId: z.string().trim().min(1).max(128).optional(),
951
1041
  /** (api-types 0.192.0) What the client renders (`['job']`). */
952
- accepts: z.array(z.enum(['job', 'onboard'])).max(4).optional(),
1042
+ accepts: z.array(z.enum(['job', 'onboard', 'cut'])).max(4).optional(),
953
1043
  }).refine((b) => b.seed === undefined || (b.requestId !== undefined && b.chatId === undefined), {
954
1044
  path: ['seed'],
955
1045
  error: 'seed needs requestId and no chatId: the chat id derives from you and the request',
@@ -1093,6 +1183,8 @@ runtime = {}) {
1093
1183
  : {}),
1094
1184
  };
1095
1185
  const { audit } = security;
1186
+ // crew#1261: who rejected a proposal and why, as crew recorded it (`GET /proposals` returns it on the row).
1187
+ const proposalDecisions = new ProposalDecisionIndex(audit, (m) => app.log.warn(m));
1096
1188
  const seatHealth = runtime.seatHealth ?? new SeatHealthTracker();
1097
1189
  const deliveryFreeze = runtime.deliveryFreeze ?? new DeliveryFreeze();
1098
1190
  registerDeliveryFreezeRoutes(app, { freeze: deliveryFreeze, audit });
@@ -1105,6 +1197,7 @@ runtime = {}) {
1105
1197
  return null;
1106
1198
  } })(),
1107
1199
  };
1200
+ registerDeskSnoozeRoutes(app, { snoozes: new DeskSnoozes(audit) });
1108
1201
  registerVoiceRoutes(app, { voice: voice.service, tts: voice.tts ?? new TtsService({ dir: defaultVoiceDir() }), dashboard: voice.dashboard, audit });
1109
1202
  const voiceInputs = runtime.voiceInputs ?? new VoiceInjectInputs();
1110
1203
  const openWithOs = runtime.openWithOs ?? openWithSystemDefault;
@@ -1144,21 +1237,18 @@ runtime = {}) {
1144
1237
  'demo',
1145
1238
  ];
1146
1239
  const chatArtifactFlags = chatArtifactsStub
1147
- ? { context: true, instructions: true, proposals: true, create: true, refine: true, theme: true, demo: true, stub: true, stubOps, onboard: true }
1148
- : { context: true, instructions: true, proposals: true, create: realCreate, refine: realRefine, theme: true, demo: false, onboard: true };
1240
+ ? { context: true, instructions: true, proposals: true, create: true, refine: true, theme: true, demo: true, stub: true, stubOps, onboard: true, cutInView: true, cut: true }
1241
+ : { context: true, instructions: true, proposals: true, create: realCreate, refine: realRefine, theme: true, demo: false, onboard: true, cutInView: true, cut: true };
1149
1242
  const proposalLaunchers = new LaunchOnceRegistry();
1150
1243
  proposalLaunchers.register('theme', new ThemeLauncher());
1244
+ // studio#1140 (a): Go on a cut card posts its frozen ops to the video tool's recut (real in the test configuration
1245
+ // too: it starts no run, and the video tool is the authority on every change).
1246
+ proposalLaunchers.register('cut', new CutLauncher({ bridgeFor: (projectId) => cutBridgeFor(projectId) }));
1151
1247
  // crew-0182: what an onboard card is resolved and its Go is checked against (one set of reads for both).
1152
- const originOf = async (rootPath) => {
1153
- try {
1154
- const out = await execCapped('git', ['-C', rootPath, 'remote', 'get-url', 'origin'], { timeout: 5_000 });
1155
- return out.stdout.trim() || null;
1156
- }
1157
- catch {
1158
- return null;
1159
- }
1160
- };
1248
+ // crew#1744: the one `git_url` reader (GET /repos, the repo search; the daemon hands the review service the same).
1249
+ const repoOrigins = runtime.repoOrigins ?? new RepoOrigins();
1161
1250
  const onboardReads = {
1251
+ projects: async () => (await adapter.projectList()).filter((p) => p.id !== DEFAULT_PROJECT_ID && p.status !== 'archived').map((p) => ({ id: p.id, name: p.name })),
1162
1252
  repos: () => adapter.listRepos(),
1163
1253
  projectRepoRefs: async (projectId) => (await adapter.projectMembers(projectId)).filter((m) => m.member_kind === 'crew.repo').map((m) => m.member_ref),
1164
1254
  checkoutOf: (name) => homeless(join(wickedWorkRoot('repos'), name)),
@@ -1174,6 +1264,8 @@ runtime = {}) {
1174
1264
  proposalLaunchers.register('onboard', new OnboardLauncher({
1175
1265
  ...onboardReads,
1176
1266
  sessions: () => adapter.sessions(),
1267
+ // crew#1694: the one project create, as `POST /projects` makes it (bus event, audit line, charter).
1268
+ createProject: async (name, actor) => createProjectRecorded(adapter, projects, audit, actor, { name }),
1177
1269
  register: (data, ctx) => registerAndOnboard(data, { actor: ctx.actor, runId: ctx.runId, gitProtocols: CHAT_GIT_PROTOCOLS, log: { warn: (o, m) => app.log.warn(o, m) } }),
1178
1270
  attach: async (projectId, repoId, actor) => {
1179
1271
  await attachRepoToProject(adapter, projects, { projectId, repoId, actor, attachedBy: 'studio' });
@@ -1230,8 +1322,13 @@ runtime = {}) {
1230
1322
  await deliveryResolver.settle(views, runtime.deliverySettleMs);
1231
1323
  };
1232
1324
  // crew#985: terminal runs with no `run.ended` entry are dated from the engine's event log before
1233
- // the DTO is assembled (read-only, once per run per process; see `backfillEndedFromEvents`).
1325
+ // the DTO is assembled (read-only; once per run, kept across starts: crew#1880, `backfillEnded`).
1234
1326
  const backfillEndedAt = async (views) => {
1327
+ // crew#1880: the adapter answers from facts kept across starts and one log read shared with the identity.
1328
+ if (typeof adapter.runEndedFact === 'function') {
1329
+ await runTimingIndex.backfillEnded(views, (view) => adapter.runEndedFact(view));
1330
+ return;
1331
+ }
1235
1332
  if (typeof adapter.runEvents !== 'function')
1236
1333
  return;
1237
1334
  await runTimingIndex.backfillEndedFromEvents(views, (id) => adapter.runEvents(id));
@@ -1239,6 +1336,7 @@ runtime = {}) {
1239
1336
  const deliveryCache = runtime.deliveryCache ??
1240
1337
  new DeliveryDerivationCache({
1241
1338
  listViews: () => adapter.sessionsDetail(),
1339
+ viewOf: (id) => adapter.runView(id),
1242
1340
  probes: vacuityProbes,
1243
1341
  isDelivered: (runId) => deliveryIndex.isDelivered(runId),
1244
1342
  canDeliver,
@@ -1319,8 +1417,12 @@ runtime = {}) {
1319
1417
  registry: editorRegistry,
1320
1418
  adapter,
1321
1419
  broadcast,
1420
+ // crew#1703: a pack's skills join the daemon skills root and are published as POST /skills/publish does; its
1421
+ // blocks become presets in the engine's store, checked against its phase catalog.
1422
+ skills: runtime.skills === undefined ? null : packSkillsPort(runtime.skills),
1423
+ presets: adapter,
1322
1424
  packCheck: runtime.packCheck ?? gardenPackCheck(discoverLivePlugin()?.path ?? null),
1323
- conformance: runtime.editorConformance ?? gardenConformance(discoverLivePlugin()?.path ?? null, () => process.env['WICKED_CREW_URL'] ?? null, { provision: editorConformanceRuntime }),
1425
+ conformance: runtime.editorConformance ?? engineConformance({ provision: editorConformanceRuntime }),
1324
1426
  // F37: the grant write's §6.4 tripwire asks the engine whether a bearer is a governed unit's token.
1325
1427
  ...(() => {
1326
1428
  const probe = runtime.editorUnitTokenProbe !== undefined ? runtime.editorUnitTokenProbe : unitTokenProbe(CoreAdapter.estateScopeResolver());
@@ -1403,6 +1505,18 @@ runtime = {}) {
1403
1505
  : null;
1404
1506
  /** Repo root for a repo ref, from the registry — shared by the reprovision path below. */
1405
1507
  const repoRootOf = async (repoRef) => (await adapter.listRepos()).find((r) => r.id === repoRef)?.root_path;
1508
+ /** (crew#1792) The push identity a repository's PR reads run as: its pin or the setting, else `GH_ACCOUNT` (the
1509
+ * deliver-target route's own resolution). Settings that cannot be read leave it to `GH_ACCOUNT`. */
1510
+ const readIdentityOf = (repoRef) => async () => {
1511
+ let configured = '';
1512
+ try {
1513
+ configured = deliverIdentityFor(await adapter.getSettings(), repoRef).login;
1514
+ }
1515
+ catch {
1516
+ configured = '';
1517
+ }
1518
+ return pushIdentityOf(configured);
1519
+ };
1406
1520
  /** The lookups a review-change exclusion reads (the launch and the job proposal read the same ones, CJ13). */
1407
1521
  const reviewChangeDeps = (repoRef, repoRoot) => ({
1408
1522
  repoRef,
@@ -1412,20 +1526,24 @@ runtime = {}) {
1412
1526
  pushed: (id) => deliveryIndex.pushedFor(id),
1413
1527
  deliveredCommit: (id) => deliveryIndex.commitFor(id),
1414
1528
  revisesPr: (id) => retryIndex.revisesPrFor(id),
1415
- gh: runtime.reviewChange?.gh ?? defaultGhExec,
1416
- git: runtime.reviewChange?.git ?? (async (args, cwd) => {
1529
+ gh: pinnedGhExec(readIdentityOf(repoRef), runtime.reviewChange?.gh ?? defaultGhExec),
1530
+ // crew#1804: a branch or commit target's fetch runs as the deliver identity too, like the deliver script's `_gnet`.
1531
+ git: pinnedGitExec(readIdentityOf(repoRef), runtime.reviewChange?.git ?? (async (args, cwd, env) => {
1417
1532
  try {
1418
- return { ...(await execCapped('git', args, { cwd, timeout: 5_000 })), code: 0 };
1533
+ return { ...(await execCapped('git', args, { cwd, timeout: 5_000, ...(env !== undefined ? { env: { ...process.env, ...env } } : {}) })), code: 0 };
1419
1534
  }
1420
1535
  catch (err) {
1421
1536
  // Only exit 1 proves non-membership; preserve it separately from lookup failures.
1422
1537
  const code = err.code;
1423
1538
  return { code: typeof code === 'number' ? code : null, stdout: '', stderr: message(err) };
1424
1539
  }
1425
- }),
1540
+ }), runtime.reviewChange?.gh ?? defaultGhExec),
1426
1541
  });
1427
- /** DES-L9: PR number → head branch, through `gh pr view` unless the runtime injected an answerer. */
1428
- const resolvePullRequest = runtime.resolvePullRequest ?? resolvePullRequestViaGh;
1542
+ /** DES-L9: PR number → head branch, through `gh pr view` as the repository's push identity (crew#1792) unless the
1543
+ * runtime injected an answerer. */
1544
+ const resolvePullRequest = (repoRoot, number, repoRef) => runtime.resolvePullRequest !== undefined
1545
+ ? runtime.resolvePullRequest(repoRoot, number)
1546
+ : resolvePullRequestViaGh(repoRoot, number, pinnedGhExec(readIdentityOf(repoRef)));
1429
1547
  /** crew#627: the intent's linked issues, read under the daemon's identity at launch. */
1430
1548
  /** (DES-PM-001 §3.2) A project's live `crew.repo` members, for a tracker set. */
1431
1549
  const repoMembersOf = async (projectId) => (await adapter.projectMembers(projectId)).filter((m) => m.member_kind === 'crew.repo').map((m) => m.member_ref);
@@ -1761,23 +1879,39 @@ runtime = {}) {
1761
1879
  ...[adapter.vaultBin != null ? vaultBinWarning(adapter.vaultBin) : null].filter((w) => w !== null),
1762
1880
  ];
1763
1881
  // crew#1157: the engine's built-in presets are compiled in, so the chat workflows it carries are
1764
- // read once (on the first probe that can read them) and held until restart.
1882
+ // read once and held until restart. crew#1767: the read is an actor round trip, so it starts here,
1883
+ // at registration (the first probe usually finds it held), at most one is in flight, and `/health`
1884
+ // waits for it only inside the ping's own bound: a probe while the actor is busy answers `[]` (the
1885
+ // engine's answer is not known yet) and a later probe answers the held list. A failed read is
1886
+ // dropped, so the next probe reads again.
1765
1887
  let chatWorkflowsHeld = null;
1766
- const chatWorkflowsNow = async () => {
1888
+ let chatWorkflowsRead = null;
1889
+ const chatWorkflowsLoad = () => {
1767
1890
  if (chatWorkflowsHeld !== null)
1768
- return chatWorkflowsHeld;
1891
+ return Promise.resolve(chatWorkflowsHeld);
1769
1892
  if (typeof adapter.listPresets !== 'function')
1770
- return [];
1771
- try {
1772
- chatWorkflowsHeld = servedChatWorkflows(await adapter.listPresets());
1773
- return chatWorkflowsHeld;
1774
- }
1775
- catch {
1776
- return [];
1777
- }
1893
+ return Promise.resolve([]);
1894
+ chatWorkflowsRead ??= Promise.resolve()
1895
+ .then(() => adapter.listPresets())
1896
+ .then((presets) => (chatWorkflowsHeld = servedChatWorkflows(presets)))
1897
+ .catch(() => [])
1898
+ .finally(() => {
1899
+ chatWorkflowsRead = null;
1900
+ });
1901
+ return chatWorkflowsRead;
1778
1902
  };
1903
+ void chatWorkflowsLoad();
1779
1904
  app.get(`${V}/health`, { config: { manifest: { statusCodes: [200] } } }, async () => {
1905
+ const deadline = performance.now() + HEALTH_PING_WAIT_MS;
1906
+ const workflowsRead = chatWorkflowsLoad();
1780
1907
  const ping = await enginePing();
1908
+ let chatWorkflowsTimer;
1909
+ const chatWorkflows = await Promise.race([
1910
+ workflowsRead,
1911
+ new Promise((resolve) => {
1912
+ chatWorkflowsTimer = setTimeout(() => resolve([]), Math.max(0, deadline - performance.now()));
1913
+ }),
1914
+ ]).finally(() => clearTimeout(chatWorkflowsTimer));
1781
1915
  // F-E2E-030: what this deployment can keep. A composer reads `capabilities.deliverGate`
1782
1916
  // before it promises "pauses at the deliver gate"; a stub-driven route set without the
1783
1917
  // probe honestly reports no gate.
@@ -1801,6 +1935,9 @@ runtime = {}) {
1801
1935
  // assurance contract); a one-CLI full-assurance launch answers `assuranceNotice`. A route set
1802
1936
  // that cannot probe the addon reports no capability — never an invented one.
1803
1937
  reducedAssurance: typeof adapter.engineCapabilities === 'function' && addonSupportsReducedAssurance(),
1938
+ // (DES-STANDIN-001 §4, K2a) `POST /runs` asks the stand-in question (409 `stand_in_choice`), takes
1939
+ // `standIns: true`, the `standInReview` setting and the `use_stand_ins` gate answer: the linked engine carries them.
1940
+ standIns: typeof adapter.supportsStandIns === 'function' && adapter.supportsStandIns(),
1804
1941
  // QE-IN-APP-WORKFLOWS: `LaunchRunBody.skipQeAcceptance` / `forceQeAcceptance` reach an addon
1805
1942
  // that carries the QE decision; never an invented capability.
1806
1943
  qeAcceptanceOverride: typeof adapter.engineCapabilities === 'function' && addonSupportsQeOverride(),
@@ -1818,7 +1955,7 @@ runtime = {}) {
1818
1955
  chatAttachments: true,
1819
1956
  // api-types 0.141.0 (crew#1157): the read-only workflows `POST /chats {workflow}` runs on THIS
1820
1957
  // engine (`analyze` on a core-ts that carries it); `[]` = plain chats only.
1821
- chatWorkflows: await chatWorkflowsNow(),
1958
+ chatWorkflows,
1822
1959
  // api-types 0.145.0: the evals, insights and schedules surfaces, read off the route table this
1823
1960
  // daemon serves, so a route set booted without one says false rather than an invented true.
1824
1961
  defaultEvals: app.hasRoute({ method: 'GET', url: `${V}/testing/default-evals/suites` }),
@@ -1847,6 +1984,9 @@ runtime = {}) {
1847
1984
  chatJobProposals: chatJobProposalsOn,
1848
1985
  chatJobPower: chatJobProposalsOn,
1849
1986
  reshapeRun: chatJobProposalsOn,
1987
+ // crew#1697: soft retire + restore on the Memory page, forget on the Knowledge page.
1988
+ memoryRestore: app.hasRoute({ method: 'POST', url: `${V}/memory/unretire` }),
1989
+ knowledgeForget: app.hasRoute({ method: 'POST', url: `${V}/knowledge/forget` }),
1850
1990
  // (api-types 0.169.0, DES-CHAT-ARTIFACTS-001 §14) Per operation: A1 serves `context` (the chat sees the open
1851
1991
  // artifact and the runs the person names; `seedFromArtifact`); A2 (0.170.0) `proposals`. The operations are later
1852
1992
  // slices (all on, with `stub`, in the test configuration).
@@ -1900,6 +2040,8 @@ runtime = {}) {
1900
2040
  const acpFoldCache = new AcpFoldCache();
1901
2041
  const engineVersionCache = new EngineVersionCache();
1902
2042
  const floorCacheCache = new FloorCacheCache();
2043
+ // crew#1126: what wicked holds on the state-home volume, read only when the disk row is low (60 s cache).
2044
+ const diskStoresCache = new DiskStoreCache(async (volumePath, deadline) => readDiskStores({ volumePath, deadline, floorCache: () => floorCacheCache.getRaw(), repos: await adapter.listRepos() }));
1903
2045
  // The governance block (crew#495): the store the engine's emit seam writes to (as the adapter
1904
2046
  // exported it — `null` on a boot that resolved none), its record count through the engine
1905
2047
  // binding when the addon has one, and the dead-letter outbox folded on change. Built at boot so
@@ -2494,54 +2636,9 @@ runtime = {}) {
2494
2636
  return adapter.maintenanceState();
2495
2637
  });
2496
2638
  // Registered repos → target-repo picker. Each carries `git_url` (studio#1012: the repo page's "This repository"
2497
- // tracker row reads it): the address the engine recorded, else — it records none for its own clones — the checkout's
2498
- // `origin` through `originOf` (the onboard card's own read), held a minute per checkout and read at most eight at a
2499
- // time across every list, so a list never runs a `git` per repository per request. Shown through `shownGitUrl`
2500
- // (credentials and query removed, an address it can't vouch for dropped); none = no field.
2501
- const originCache = new Map();
2502
- let originReads = 0;
2503
- const originQueue = [];
2504
- const limitedOrigin = async (rootPath) => {
2505
- if (originReads < 8)
2506
- originReads += 1;
2507
- else
2508
- await new Promise((go) => originQueue.push(go));
2509
- try {
2510
- return await originOf(rootPath);
2511
- }
2512
- finally {
2513
- // The slot passes straight to the next waiter, so no new read can take it in between.
2514
- const next = originQueue.shift();
2515
- if (next !== undefined)
2516
- next();
2517
- else
2518
- originReads -= 1;
2519
- }
2520
- };
2521
- const listedOrigin = (rootPath) => {
2522
- const now = Date.now();
2523
- const hit = originCache.get(rootPath);
2524
- if (hit !== undefined && now - hit.at < 60_000)
2525
- return hit.url;
2526
- const url = limitedOrigin(rootPath);
2527
- originCache.set(rootPath, { at: now, url });
2528
- return url;
2529
- };
2530
- const withGitUrl = async (r) => {
2531
- const { git_url: recorded, ...rest } = r;
2532
- const raw = typeof recorded === 'string' && recorded.trim() !== '' ? recorded : await listedOrigin(r.root_path);
2533
- const shown = raw === null ? null : shownGitUrl(raw);
2534
- return shown === null ? rest : { ...rest, git_url: shown };
2535
- };
2536
- app.get(`${V}/repos`, async () => {
2537
- const listed = await adapter.listRepos();
2538
- // A checkout no longer registered leaves the cache.
2539
- const roots = new Set(listed.map((r) => r.root_path));
2540
- for (const root of originCache.keys())
2541
- if (!roots.has(root))
2542
- originCache.delete(root);
2543
- return { repos: await Promise.all(listed.map(withGitUrl)) };
2544
- });
2639
+ // tracker row reads it), through the daemon's one origin reader (repo-origins.ts, crew#1744): the review's issue
2640
+ // link and the repo search read the same.
2641
+ app.get(`${V}/repos`, async () => ({ repos: await repoOrigins.list(() => adapter.listRepos()) }));
2545
2642
  app.delete(`${V}/repos/:id`, { config: { manifest: { responseType: 'UnregisterRepoResponse', statusCodes: [200, 404, 409, 501] } } }, async (req, reply) => {
2546
2643
  const { id } = req.params;
2547
2644
  const runIds = (await adapter.sessionsDetail())
@@ -2840,6 +2937,11 @@ runtime = {}) {
2840
2937
  return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
2841
2938
  }
2842
2939
  const b = { ...parsed.data };
2940
+ // (DES-STANDIN-001 §3.8) Consent to stand-ins is a person's: a worker's or agent's bearer may only inherit the
2941
+ // consent a person already gave (the `standInReview` setting), never send its own.
2942
+ if (b.standIns === true && !isHumanOperator(req.actor)) {
2943
+ return reply.code(403).send({ code: 'human_operator_only', error: `only a person can consent to stand-in checks (standIns); you are ${req.actor.kind}/${req.actor.trust}` });
2944
+ }
2843
2945
  // DES-CATALOG-002 §4.4: the words as the person gave them, before crew's framing line (the envelope's `words`, which
2844
2946
  // a reshape relaunches from), with any block an earlier launch appended taken out.
2845
2947
  const envelopeWords = stripLinkedIssues(stripRulesBrief(b.problem));
@@ -3098,6 +3200,52 @@ runtime = {}) {
3098
3200
  input.baseRef = ex.baseRef;
3099
3201
  reviewChange = { target: ex.target, provenance: ex.provenance, runs: ex.runs, excluded, headSha: ex.headSha };
3100
3202
  }
3203
+ // (DES-STANDIN-001 §4, K2a) THE STAND-IN CHOICE, before anything is written: the engine's preflight says which
3204
+ // independent roles this launch's roster is short of, on the shape it would take. Short with no consent → the 409
3205
+ // the launcher's caller draws as the choice; with consent (the person's `standIns`, or the `standInReview:
3206
+ // 'always'` setting) the run launches stand-in-aware and fills a short role with a labelled stand-in. A review
3207
+ // (review-change, the prepared reviews, run-evals), a demo and a reduced launch keep today's path (K2a scope).
3208
+ const standInEligible = b.reducedAssurance !== true && reviewChange === undefined
3209
+ && !(b.workflow !== undefined && (reviewPrepared(b.workflow) || b.workflow === RUN_EVALS_WORKFLOW || DEMO_PRESETS.includes(b.workflow)));
3210
+ const standInsSupported = typeof adapter.supportsStandIns === 'function' && adapter.supportsStandIns();
3211
+ if (b.standIns === true && !standInEligible) {
3212
+ return reply.code(400).send({ code: 'stand_ins_refused', error: 'this launch does not take stand-ins (standIns): a review, a demo or a reduced launch keeps its own checks' });
3213
+ }
3214
+ if (b.standIns === true && !standInsSupported) {
3215
+ return reply.code(501).send({ error: 'stand-in checks need a wicked-core-ts that carries them (Core.independencePreflight and grantStandIns); upgrade the engine' });
3216
+ }
3217
+ // A draining daemon refuses the launch before it asks anything (the choice would only lead to the 503).
3218
+ if (typeof adapter.isDraining === 'function' && adapter.isDraining())
3219
+ return reply.code(503).send(maintenanceDrainBody(new MaintenanceDrainError()));
3220
+ if (standInEligible && standInsSupported) {
3221
+ const setting = await Promise.resolve().then(() => adapter.getSettings()).then((s) => s.standInReview).catch(() => undefined);
3222
+ const consent = consentFor(b.standIns === true, setting, `${req.actor.id} (${req.actor.kind})`);
3223
+ // The launcher that can show the choice asks the preflight with or without consent (codex r1 on b7-standin):
3224
+ // consent answers only the choice; a role no signed-in helper can stand in for is no_usable_helper either way.
3225
+ let preflight = null;
3226
+ if (ctx.standInChoice === true) {
3227
+ try {
3228
+ preflight = readPreflight(await adapter.independencePreflight(input));
3229
+ }
3230
+ catch (err) {
3231
+ // The engine refuses the shape as the launch would: the launch's own refusal, before anything is written.
3232
+ return reply.code(400).send({ error: `the launch was refused: ${message(err)}` });
3233
+ }
3234
+ // No helper signed in at all: the engine's own launch refusal (`no_eligible_seat`) names each benched seat, its
3235
+ // cause and the remedy; there is nothing a stand-in could stand in from.
3236
+ const refusal = preflight === null || preflight.signedIn.length === 0 ? null : preflightRefusal(preflight);
3237
+ if (refusal !== null && (consent === null || refusal.code === 'no_usable_helper'))
3238
+ return reply.code(409).send(refusal);
3239
+ }
3240
+ if (consent !== null) {
3241
+ input.standInAware = true;
3242
+ input.standIn = consent;
3243
+ }
3244
+ else if (preflight !== null) {
3245
+ // Not short: launched aware, so a seat lost mid-run holds at the stand-in gate instead of failing.
3246
+ input.standInAware = true;
3247
+ }
3248
+ }
3101
3249
  // DES-L9 / crew#550 — REVISION: `revisesPr` names an OPEN same-repository pull request whose
3102
3250
  // head branch becomes the run's base (`baseRef`, crew-internal → the engine's
3103
3251
  // `LaunchSpec.base_ref`) and the push target of the composed deliver phase — the PR gains
@@ -3121,7 +3269,7 @@ runtime = {}) {
3121
3269
  if (root === undefined) {
3122
3270
  return reply.code(404).send({ error: `repoRef names an unknown repo: ${revisedRepo}` });
3123
3271
  }
3124
- const resolved = await resolvePullRequest(root, b.revisesPr);
3272
+ const resolved = await resolvePullRequest(root, b.revisesPr, revisedRepo);
3125
3273
  if (!resolved.ok)
3126
3274
  return reply.code(409).send({ error: resolved.error });
3127
3275
  revisesPr = { number: b.revisesPr, headRef: resolved.pr.headRef, url: resolved.pr.url };
@@ -3144,7 +3292,15 @@ runtime = {}) {
3144
3292
  // retry or reshape that sends none keeps the earlier run's pick; a run without a pick reads what the switches allow.
3145
3293
  let sourcePick = null;
3146
3294
  // An inherited pick is checked like a sent one (the switches may have changed since the earlier run).
3147
- const wantedPick = b.sources ?? (b.retryOf !== undefined ? (runtime.runSourcePicks?.get(b.retryOf) ?? undefined) : undefined);
3295
+ let wantedPick;
3296
+ try {
3297
+ wantedPick = b.sources ?? (b.retryOf !== undefined ? (runtime.runSourcePicks?.get(b.retryOf) ?? undefined) : undefined);
3298
+ }
3299
+ catch (err) {
3300
+ // (crew#1442, coord on #1734) The earlier run's pick can't be read (its store entry is gone and the launch trail
3301
+ // was not read at boot): refused, never launched as if it had no pick.
3302
+ return reply.code(409).send({ code: 'sources_unavailable', error: `the earlier run's source pick could not be read: ${message(err)}` });
3303
+ }
3148
3304
  if (wantedPick !== undefined) {
3149
3305
  if (runtime.runSourcePicks === undefined || runtime.dataGate === undefined) {
3150
3306
  return reply.code(400).send({ code: 'sources_refused', error: 'this daemon cannot limit a run to picked sources' });
@@ -3238,8 +3394,11 @@ runtime = {}) {
3238
3394
  // crew#825: an all-excluded intent appends nothing but still answers what it left out.
3239
3395
  if (linked.issues.length > 0)
3240
3396
  linkedIssues = linked.issues;
3241
- if (linked.addresses !== undefined && linked.addresses.length > 0)
3397
+ if (linked.addresses !== undefined && linked.addresses.length > 0) {
3242
3398
  linkedAddresses = linked.addresses;
3399
+ // crew#1352: known before the engine is called, so the deliver script's embedded fallback links them back.
3400
+ input.trackerRefs = linked.addresses.map((a) => ({ system: a.system, ref: a.ref, ...(a.asked !== undefined ? { asked: a.asked } : {}) }));
3401
+ }
3243
3402
  }
3244
3403
  catch (err) {
3245
3404
  req.log.warn(`linked-issue resolution failed; launching on the intent alone: ${message(err)}`);
@@ -3272,7 +3431,10 @@ runtime = {}) {
3272
3431
  // the evals in-process and writes the report copy its Tool step reads; it delivers nothing.
3273
3432
  if (b.workflow === RUN_EVALS_WORKFLOW) {
3274
3433
  try {
3275
- await runEvalsPrepare(input);
3434
+ // (crew#1375) A card launch scores what its card asks for: Evaluate rules the steering suite, and a card that takes
3435
+ // a project input (Evaluate rules, Analyze runs) the project the launch is filed in. A launch with no shape (a
3436
+ // schedule, `/workflow-run-evals`) scores every suite and project.
3437
+ await runEvalsPrepare(input, runEvalsScopeOf(shapeChecked?.shape.card ?? null, b.projectId ?? null));
3276
3438
  }
3277
3439
  catch (err) {
3278
3440
  return reply.code(409).send({ error: `the default evals could not be prepared: ${message(err)}` });
@@ -3284,9 +3446,21 @@ runtime = {}) {
3284
3446
  await runtime.reviewLaunch(input);
3285
3447
  }
3286
3448
  catch (err) {
3449
+ // (crew#1375) No seat that ran none of the reviewed work: the review-change refusal's shape, so a chat job's Start
3450
+ // offers reduced assurance.
3451
+ if (err instanceof NoIndependentReviewer) {
3452
+ return reply.code(409).send({ code: err.code, error: `the review could not be prepared: ${err.message}`, excluded: err.excluded, retryWith: { reducedAssurance: true } });
3453
+ }
3287
3454
  return reply.code(409).send({ error: `the review could not be prepared: ${message(err)}` });
3288
3455
  }
3289
3456
  }
3457
+ // (crew#1375) Every refusal from here to the engine call leaves a prepared review that never ran: it is recorded as
3458
+ // refused, so a retry under the same run id (a chat job's Go) prepares it again instead of being refused.
3459
+ const refuse = (code, body) => {
3460
+ if (isReview)
3461
+ runtime.reviewLaunchRefused?.(input.sessionId, body.error);
3462
+ return reply.code(code).send(body);
3463
+ };
3290
3464
  if (b.workflow !== undefined && postureFacts.preparationDropsDelivery(b.workflow)) {
3291
3465
  deliver = 'none';
3292
3466
  delete input.deliver;
@@ -3296,7 +3470,7 @@ runtime = {}) {
3296
3470
  if (b.chatId !== undefined && chatArtifactFlags.proposals) {
3297
3471
  const live = await chatProposals.liveJobOf(b.chatId).catch(() => null);
3298
3472
  if (live !== null)
3299
- return reply.code(409).send({ code: 'chat_busy', error: `This chat already has a job running (${live}). Wait, or stop that run.` });
3473
+ return refuse(409, { code: 'chat_busy', error: `This chat already has a job running (${live}). Wait, or stop that run.` });
3300
3474
  }
3301
3475
  // DES-CATALOG-002 §4.4 (codex r1): the effective resolution a shape was judged by is read again right before the
3302
3476
  // engine resolves the preset, so a preset saved during this launch's awaits refuses it rather than running a shape
@@ -3305,11 +3479,11 @@ runtime = {}) {
3305
3479
  try {
3306
3480
  const again = checkLaunchShape(shapeChecked.shape, shapeChecked.target, await servedFor(shapeReads, b.projectId));
3307
3481
  if (!again.ok || again.resolved.resolved.resolution !== shapeChecked.resolution) {
3308
- return reply.code(409).send({ code: 'catalog_changed', error: 'the catalog changed while this was starting; check the job again' });
3482
+ return refuse(409, { code: 'catalog_changed', error: 'the catalog changed while this was starting; check the job again' });
3309
3483
  }
3310
3484
  }
3311
3485
  catch (err) {
3312
- return reply.code(409).send({ code: 'catalog_unavailable', error: message(err) });
3486
+ return refuse(409, { code: 'catalog_unavailable', error: message(err) });
3313
3487
  }
3314
3488
  }
3315
3489
  // (CS4) The pick is recorded before anything is staged and before the engine is called, so no unit of the run ever
@@ -3319,7 +3493,7 @@ runtime = {}) {
3319
3493
  runtime.runSourcePicks.set(input.sessionId, sourcePick);
3320
3494
  }
3321
3495
  catch (err) {
3322
- return reply.code(409).send({ code: 'sources_unavailable', error: `the source pick could not be recorded: ${message(err)}` });
3496
+ return refuse(409, { code: 'sources_unavailable', error: `the source pick could not be recorded: ${message(err)}` });
3323
3497
  }
3324
3498
  }
3325
3499
  // (DES-CATALOG-002 §2.d piece 2, CS4) The documents: every token authorised again with the chat's own rules (this
@@ -3337,10 +3511,10 @@ runtime = {}) {
3337
3511
  else if (b.retryOf !== undefined && runtime.runDocumentsRoot !== undefined) {
3338
3512
  const earlier = stagedTokensOf(b.retryOf, runtime.runDocumentsRoot);
3339
3513
  if (earlier === 'removed') {
3340
- return reply.code(409).send({ code: 'documents_unavailable', error: `the documents of run ${b.retryOf} were removed when it was archived; start the job again from its chat` });
3514
+ return refuse(409, { code: 'documents_unavailable', error: `the documents of run ${b.retryOf} were removed when it was archived; start the job again from its chat` });
3341
3515
  }
3342
3516
  if (earlier === 'unreadable') {
3343
- return reply.code(409).send({ code: 'documents_unavailable', error: `the documents of run ${b.retryOf} can't be read again; start the job again from its chat` });
3517
+ return refuse(409, { code: 'documents_unavailable', error: `the documents of run ${b.retryOf} can't be read again; start the job again from its chat` });
3344
3518
  }
3345
3519
  if (earlier !== null)
3346
3520
  docTokens = earlier;
@@ -3351,7 +3525,7 @@ runtime = {}) {
3351
3525
  const runProject = b.projectId !== undefined && b.projectId !== DEFAULT_PROJECT_ID ? b.projectId : null;
3352
3526
  if ((chatProject ?? null) !== runProject) {
3353
3527
  // A bare retry sends no projectId: it is filed Unfiled, so it is told where its documents belong (fail closed).
3354
- return reply.code(400).send({
3528
+ return refuse(400, {
3355
3529
  code: 'documents_refused',
3356
3530
  error: chatProject !== null && runProject === null
3357
3531
  ? `the documents belong to project ${chatProject}: file this run there (send projectId)`
@@ -3377,13 +3551,13 @@ runtime = {}) {
3377
3551
  }
3378
3552
  catch (err) {
3379
3553
  if (err instanceof DocumentsRefused) {
3380
- return reply.code(400).send({
3554
+ return refuse(400, {
3381
3555
  code: 'documents_refused',
3382
3556
  error: `can't read ${err.refused.map((r) => `${r.token} (${r.reason})`).join(', ')}`,
3383
3557
  refused: err.refused,
3384
3558
  });
3385
3559
  }
3386
- return reply.code(409).send({ code: 'documents_unavailable', error: `the documents could not be staged: ${message(err)}` });
3560
+ return refuse(409, { code: 'documents_unavailable', error: `the documents could not be staged: ${message(err)}` });
3387
3561
  }
3388
3562
  }
3389
3563
  if (staged !== null) {
@@ -3461,9 +3635,17 @@ runtime = {}) {
3461
3635
  ...(b.actor !== undefined ? { actor: b.actor } : {}),
3462
3636
  // crew#627: which linked issues the daemon read into the problem, and which it could not.
3463
3637
  ...(linkedIssues !== undefined ? { linkedIssues } : {}),
3638
+ // crew#1352: the issues the run addresses, as its tracker set resolved them. The trail is the durable record for
3639
+ // the run's lifetime (the tracker-addresses store is a bounded cache, and its write may fail); the run-timing
3640
+ // index reads them back, live and after a restart.
3641
+ ...(linkedAddresses !== undefined ? { trackerAddresses: linkedAddresses } : {}),
3642
+ // crew#1442: the run's source pick, so a pick store that loses the run still narrows it (fail closed).
3643
+ ...(sourcePick !== null ? { sourcePick } : {}),
3464
3644
  // DES-CATALOG-002 §4.4: the shape it was launched as, what it was launched with, and the proposal behind it.
3465
3645
  ...(b.shape !== undefined ? { shape: launchShapeOf(b.shape) } : {}),
3466
3646
  ...(ctx.fromProposal !== undefined ? { fromProposal: ctx.fromProposal } : {}),
3647
+ // crew#372: what a compose launched with (its requirements, level and steps), the only source publish trusts.
3648
+ ...(ctx.target === 'compose' && ctx.compose !== undefined ? { compose: ctx.compose } : {}),
3467
3649
  envelope: {
3468
3650
  words: envelopeWords,
3469
3651
  ...(b.repoRef !== undefined ? { repoRef: b.repoRef } : {}),
@@ -3538,7 +3720,10 @@ runtime = {}) {
3538
3720
  const skillsWarning = skillsAhead === null ? {} : { skillsWarning: { kind: skillsAhead.kind, severity: skillsAhead.severity, message: skillsAhead.message } };
3539
3721
  // wicked-core#850: a full-assurance run on a one-CLI roster will wait at a gate for a seat that
3540
3722
  // can evaluate or judge it; the answer names the explicit opt-in to relaunch with.
3541
- const notice = launchAssuranceNotice({ runId, reducedAssurance: b.reducedAssurance, coverage: readJudgeCoverage(engineRosterJson(input.clisJson), input.repoRef !== undefined, runtime.judgeCoverage ?? CoreAdapter.judgeCoverage) });
3723
+ // (DES-STANDIN-001 §7.3) A stand-in-aware run asked its question before launching: no reduced-assurance offer.
3724
+ const notice = input.standInAware === true
3725
+ ? null
3726
+ : launchAssuranceNotice({ runId, reducedAssurance: b.reducedAssurance, coverage: readJudgeCoverage(engineRosterJson(input.clisJson), input.repoRef !== undefined, runtime.judgeCoverage ?? CoreAdapter.judgeCoverage) });
3542
3727
  const assuranceNotice = notice === null ? {} : { assuranceNotice: notice };
3543
3728
  // (program DES-POWER-MODE) Whether the run is in power mode, and why not when it was wanted.
3544
3729
  const power = { ...(input.power === true ? { power: true } : {}), ...(powerNotice !== null ? { powerNotice } : {}), ...(humanConfirmNotice !== null ? { humanConfirmNotice } : {}) };
@@ -3548,7 +3733,9 @@ runtime = {}) {
3548
3733
  if (!launched && staged?.published === true)
3549
3734
  freeStagedDocuments(input.sessionId, false);
3550
3735
  const msg = message(err);
3551
- if (isReview)
3736
+ // (crew#1375, xreview r1) Only a launch the engine never took is a refused review: a failure after launchRun
3737
+ // resolved leaves the review running, so a retry under its run id can never clear a real review.
3738
+ if (isReview && !launched)
3552
3739
  runtime.reviewLaunchRefused?.(input.sessionId, msg);
3553
3740
  if (err instanceof MaintenanceDrainError)
3554
3741
  return reply.code(503).send(maintenanceDrainBody(err));
@@ -3620,12 +3807,13 @@ runtime = {}) {
3620
3807
  // wicked-core#461 — see the catch below); 400: zod reject or a retryOf naming no
3621
3808
  // existing run; 422: the base-skill intake refusal (`base_skill_refused`, crew#554);
3622
3809
  // 501: campaignId attach on an engine addon without the campaign bindings ("upgrade
3623
- // the engine").
3624
- statusCodes: [201, 400, 404, 409, 422, 501, 503],
3810
+ // the engine"); 403: `standIns` from a worker's bearer; 409 `stand_in_choice` / `no_usable_helper`: the
3811
+ // stand-in question (DES-STANDIN-001 §4).
3812
+ statusCodes: [201, 400, 403, 404, 409, 422, 501, 503],
3625
3813
  },
3626
3814
  },
3627
3815
  }, async (req, reply) => {
3628
- const launch = () => launchRun(req.body, { actor: actorOf(req), log: req.log });
3816
+ const launch = () => launchRun(req.body, { actor: actorOf(req), log: req.log, standInChoice: true });
3629
3817
  const parsed = LaunchSchema.safeParse(req.body);
3630
3818
  const out = parsed.success && parsed.data.chatId !== undefined
3631
3819
  ? await chatProposals.admitChat(parsed.data.chatId, launch)
@@ -3713,10 +3901,8 @@ runtime = {}) {
3713
3901
  */
3714
3902
  proposalLaunchers.register('job', {
3715
3903
  find: async (identity) => (await adapter.sessions()).includes(identity.runId),
3716
- live: async (runId) => {
3717
- const v = await adapter.runView(runId);
3718
- return v !== undefined && !['completed', 'cancelled', 'failed'].includes(String(v.session.status));
3719
- },
3904
+ // crew#1779: read off the check's one run list, never one engine read per job.
3905
+ live: liveInRuns,
3720
3906
  launch: async (d) => {
3721
3907
  const p = d.resolution;
3722
3908
  if (p.shape === undefined || p.catalogRev === undefined)
@@ -3758,7 +3944,7 @@ runtime = {}) {
3758
3944
  ...(projectId !== null && projectId !== DEFAULT_PROJECT_ID ? { projectId } : {}),
3759
3945
  ...common,
3760
3946
  // (CS4) The documents and the source pick, as tokens and names (never flattened into the brief's prose).
3761
- ...jobInputsOfProposal(p, runtime.runSourcePicks !== undefined ? (runId) => runtime.runSourcePicks.get(runId) : undefined),
3947
+ ...jobInputsOfProposal(p, runtime.runSourcePicks !== undefined ? (runId) => heldSourcePick(runtime.runSourcePicks, runId) : undefined),
3762
3948
  // A power run when the person's Start chose one (checked against this daemon just now); otherwise it
3763
3949
  // stops at its first plan, as every chat job did before (operator ruling 2026-11-06).
3764
3950
  // (A power launch overrides the plan hold; launchRun refuses rather than run it phased, `powerRequired`.)
@@ -3769,6 +3955,8 @@ runtime = {}) {
3769
3955
  ...(p.relaunch?.deliver !== undefined ? { deliver: p.relaunch.deliver } : {}),
3770
3956
  ...(p.relaunch?.deliverGate !== undefined && p.relaunch.deliver !== 'none' ? { deliverGate: p.relaunch.deliverGate } : {}),
3771
3957
  ...(p.relaunch?.revisesPr !== undefined && p.relaunch.deliver === 'pr' && p.repoRefs?.[0] !== undefined ? { revisesPr: p.relaunch.revisesPr } : {}),
3958
+ // (crew#1840) A job asked to change a pull request this chat delivered updates it: no second PR.
3959
+ ...jobRevisionLaunch(p),
3772
3960
  }, { ...ctx, fromProposal: d.pid, ...(d.power === true ? { powerRequired: true } : {}) });
3773
3961
  if (out.statusCode !== 201)
3774
3962
  throw jobRefusal(out.statusCode, out.payload);
@@ -4285,7 +4473,7 @@ runtime = {}) {
4285
4473
  const revisedRoot = await repoRootOf(repoRef);
4286
4474
  const again = revisedRoot === undefined
4287
4475
  ? { ok: false, error: `repo ${repoRef} is no longer registered — cannot re-check pull request #${revising.number}` }
4288
- : await resolvePullRequest(revisedRoot, revising.number);
4476
+ : await resolvePullRequest(revisedRoot, revising.number, repoRef);
4289
4477
  if (!again.ok) {
4290
4478
  revisionRefused = again.error;
4291
4479
  return;
@@ -4473,6 +4661,8 @@ runtime = {}) {
4473
4661
  const chatAccepts = new Map();
4474
4662
  /** (crew-0182) Chats whose client draws onboard cards (`accepts: ['onboard']`), by its newest declaration. */
4475
4663
  const chatAcceptsOnboard = new Map();
4664
+ /** (studio#1140 (a)) Chats whose client draws cut cards (`accepts: ['cut']`), by its newest declaration. */
4665
+ const chatAcceptsCut = new Map();
4476
4666
  /** (crew-0182) What a chat seat is told exists here: every project with its repositories, every registered repository. */
4477
4667
  const readDaemonGrounding = async (chatId, accepts) => {
4478
4668
  try {
@@ -4720,6 +4910,7 @@ runtime = {}) {
4720
4910
  // A refused open (409 above) never touched the live chat's (codex r3).
4721
4911
  chatAccepts.set(chatId, openAccepts);
4722
4912
  chatAcceptsOnboard.set(chatId, b.accepts?.includes('onboard') === true);
4913
+ chatAcceptsCut.set(chatId, b.accepts?.includes('cut') === true);
4723
4914
  // DC-S7: the in-force rules the statement lists; recorded as "told" only once the open succeeds.
4724
4915
  let inForceAtOpen = [];
4725
4916
  // Everything below either ends in `chatScopes.set(chatId, …, token)` or releases the reservation.
@@ -5001,7 +5192,7 @@ runtime = {}) {
5001
5192
  /** (api-types 0.169.0, DES-CHAT-ARTIFACTS-001 §5.1) What studio shows beside the message. */
5002
5193
  context: ChatMessageContextSchema.optional(),
5003
5194
  /** (api-types 0.192.0, DES-CATALOG-002 §4.6) What the client renders (`['job']`): the newest declaration wins. */
5004
- accepts: z.array(z.enum(['job', 'onboard'])).max(4).optional(),
5195
+ accepts: z.array(z.enum(['job', 'onboard', 'cut'])).max(4).optional(),
5005
5196
  });
5006
5197
  // DES-CHAT-ARTIFACTS-001 §5.1 (A1): what a turn's block reads — the docs roots, the decorated runs (project,
5007
5198
  // document and chat ids), unit outputs and the acceptance line. One set of deps, so the block and the run pages
@@ -5015,6 +5206,7 @@ runtime = {}) {
5015
5206
  const g = readGroundingBeneath(root, doc);
5016
5207
  return g !== null && 'style' in g ? g.style : undefined;
5017
5208
  },
5209
+ cutBridge: (projectId) => cutBridgeFor(projectId),
5018
5210
  };
5019
5211
  // DES-CHAT-ARTIFACTS-001 §4 (A2): proposals. Resolved from crew's own records (the same reads the turn block uses);
5020
5212
  // records go to the live transcript, or the kept history copy once the chat has ended.
@@ -5106,7 +5298,7 @@ runtime = {}) {
5106
5298
  pickFirstRepo: async (chatId, repoRef, actor, pid) => {
5107
5299
  const previous = chatScopes.get(chatId);
5108
5300
  if (previous === undefined)
5109
- return { ok: false, status: 409, error: `chat ${chatId} has ended; start a new one` };
5301
+ return { ok: false, status: 409, error: CHAT_ENDED };
5110
5302
  if (previous.repos.length > 0)
5111
5303
  return { ok: false, status: 409, error: `chat ${chatId} already has a repository in scope` };
5112
5304
  if (previous.kind === 'everything')
@@ -5236,7 +5428,7 @@ runtime = {}) {
5236
5428
  if (root === undefined)
5237
5429
  return null;
5238
5430
  const ex = await reviewChangeExclusion(words, reviewChangeDeps(repoRef, root));
5239
- return ex.ok ? ex.excludeSeats : null;
5431
+ return ex.ok ? { seats: ex.excludeSeats, ...(ex.provenance === 'unknown' && ex.why !== undefined ? { unknown: ex.why } : {}) } : null;
5240
5432
  },
5241
5433
  powerPresets: async (projectId) => {
5242
5434
  if (!powerSupported() || ((await adapter.getSettings()).powerModeDefault ?? true) === false || typeof adapter.listPresets !== 'function')
@@ -5246,9 +5438,10 @@ runtime = {}) {
5246
5438
  },
5247
5439
  acceptsJobs: (chatId) => chatAccepts.get(chatId) === true,
5248
5440
  acceptsOnboard: (chatId) => chatAcceptsOnboard.get(chatId) === true,
5441
+ acceptsCut: (chatId) => chatArtifactFlags.cut === true && chatAcceptsCut.get(chatId) === true,
5442
+ cut: { bridgeFor: (projectId) => cutBridgeFor(projectId) },
5249
5443
  onboard: {
5250
5444
  ...onboardReads,
5251
- projects: async () => (await adapter.projectList()).filter((p) => p.id !== DEFAULT_PROJECT_ID && p.status !== 'archived').map((p) => ({ id: p.id, name: p.name })),
5252
5445
  originOf,
5253
5446
  probe: (url) => probeGitUrl(url),
5254
5447
  // POST /repos's own intake refusal (no garden, an old one, the state home): the card says it before anyone presses.
@@ -5381,6 +5574,7 @@ runtime = {}) {
5381
5574
  if (parsed.data.accepts !== undefined) {
5382
5575
  chatAccepts.set(id, parsed.data.accepts.includes('job'));
5383
5576
  chatAcceptsOnboard.set(id, parsed.data.accepts.includes('onboard'));
5577
+ chatAcceptsCut.set(id, parsed.data.accepts.includes('cut'));
5384
5578
  }
5385
5579
  after();
5386
5580
  if (preface !== null)
@@ -5495,7 +5689,7 @@ runtime = {}) {
5495
5689
  // A7: a seat is told it can propose a studio theme only when this message carried the tab's appearance (a client
5496
5690
  // that can preview and apply one sends it).
5497
5691
  // crew-0182: this message's own onboard declaration (the chat's stored one changes once the message is accepted).
5498
- const themeClient = { appearance: msgContext?.appearance !== undefined, onboard: parsed.data.accepts !== undefined ? parsed.data.accepts.includes('onboard') : chatAcceptsOnboard.get(id) === true };
5692
+ const themeClient = { appearance: msgContext?.appearance !== undefined, onboard: parsed.data.accepts !== undefined ? parsed.data.accepts.includes('onboard') : chatAcceptsOnboard.get(id) === true, cut: parsed.data.accepts !== undefined ? parsed.data.accepts.includes('cut') : chatAcceptsCut.get(id) === true };
5499
5693
  // DES-CATALOG-002 §2.3, §4.6: the per-message job lines (the chat catalog digest, the open proposal, the held plan),
5500
5694
  // read here, before the last check (no await after it). Never in an analysis.
5501
5695
  // The declaration this message's instructions are written for: its own, else the chat's (applied to the chat only
@@ -5517,6 +5711,8 @@ runtime = {}) {
5517
5711
  context: msgContext,
5518
5712
  records: chatTranscripts?.read(id) ?? [],
5519
5713
  attachmentIds: chatAttachments.list(id).map((a) => a.id),
5714
+ // This message's own declaration, else the chat's (the reply to this turn is resolved the same way).
5715
+ acceptsCut: chatArtifactFlags.cut === true && (parsed.data.accepts !== undefined ? parsed.data.accepts.includes('cut') : chatAcceptsCut.get(id) === true),
5520
5716
  }, chatContextDeps);
5521
5717
  contextBlock = built.block;
5522
5718
  turnBinding = built.binding;
@@ -5638,6 +5834,11 @@ runtime = {}) {
5638
5834
  ],
5639
5835
  }
5640
5836
  : {}),
5837
+ // wicked-core#1463: an "All repos" chat reads every registered repository; a unit whose
5838
+ // repositories pass the container copy-in's cap leaves out those that do not fit (each
5839
+ // with a note in its place) instead of failing every turn. A repo or project scope names
5840
+ // what the person asked about, so its repositories stay required.
5841
+ ...(scope?.kind === 'everything' && readRoots.length > 0 ? { optionalReadRoots: [...readRoots] } : {}),
5641
5842
  };
5642
5843
  const runId = await adapter.launchRun(input);
5643
5844
  // The scope's roots (not the attachments directory) are what a later turn compares against.
@@ -6580,6 +6781,12 @@ runtime = {}) {
6580
6781
  ...(refusal !== undefined ? { refusal } : {}),
6581
6782
  ...(gateKind !== undefined ? { gateKind } : {}),
6582
6783
  ...(frame !== undefined ? offeredChoices(frame) : {}),
6784
+ // (crew#1698) The opening the record shows: the row's `gate_seq` only, the one an answer is checked
6785
+ // against (a frame's beside an unnumbered row would be an opening no answer could name).
6786
+ ...(() => {
6787
+ const seq = gateSeqOf(durableGate['gate_seq']);
6788
+ return seq !== undefined ? { gateSeq: seq } : {};
6789
+ })(),
6583
6790
  };
6584
6791
  }
6585
6792
  const events = await adapter.runEvents(id);
@@ -6629,7 +6836,7 @@ runtime = {}) {
6629
6836
  * cursor unit) — an engine, or a run, older than the table.
6630
6837
  */
6631
6838
  async function gateForDecision(run, namedOrd, opts = {}) {
6632
- const decided = await gateOfRecord(run, namedOrd);
6839
+ const decided = await gateOfRecord(run, namedOrd, opts.gateSeq);
6633
6840
  // DES-CATALOG-002 §4.6 (codex r1): a plan held for a run launched from a chat proposal is approved only by an
6634
6841
  // answer bound to its version (`POST /runs/:id/gate` with `planRev`); every other approving path (a gated resume or
6635
6842
  // reassign, a plan edit at the gate, a standing order) is refused there. Declining stays open.
@@ -6651,7 +6858,7 @@ runtime = {}) {
6651
6858
  }
6652
6859
  return decided;
6653
6860
  }
6654
- async function gateOfRecord(run, namedOrd) {
6861
+ async function gateOfRecord(run, namedOrd, namedSeq) {
6655
6862
  const id = run.session.id;
6656
6863
  const unitAt = (ord) => (run.units ?? []).find((u) => u.ord === ord);
6657
6864
  const unknown = (why) => ({ refusal: { code: 409, body: { error: `Gate unknown: ${why} — refresh and decide again.`, code: 'gate_unknown' } } });
@@ -6669,15 +6876,38 @@ runtime = {}) {
6669
6876
  } } };
6670
6877
  }
6671
6878
  const kind = recorded.row['gate_kind'];
6672
- return { ord: recorded.ord, gated: unitAt(recorded.ord), prompt: recorded.row.prompt, gateKind: typeof kind === 'string' && kind !== '' ? kind : undefined };
6879
+ // (core#1808) Which opening of the gate the record shows: a `use_stand_ins` answer names it to the engine.
6880
+ const seq = recorded.row['gate_seq'];
6881
+ const openSeq = typeof seq === 'number' && Number.isInteger(seq) && seq > 0 ? seq : undefined;
6882
+ // (crew#1698) An answer naming another opening of this gate (closed and re-opened since, same ord too).
6883
+ if (namedSeq !== undefined && namedSeq !== openSeq) {
6884
+ return openSeq === undefined
6885
+ ? unknown(`this decision names opening ${namedSeq} of the gate before unit ${recorded.ord}, but the engine's record does not number its openings`)
6886
+ : { refusal: { code: 409, body: {
6887
+ error: `Gate changed: this decision was made on an earlier opening of the gate before unit ${recorded.ord} (opening ${namedSeq}; open now: ${openSeq}). Read the open gate before deciding.`,
6888
+ code: 'gate_changed',
6889
+ openOrd: recorded.ord,
6890
+ openGateSeq: openSeq,
6891
+ } } };
6892
+ }
6893
+ return {
6894
+ ord: recorded.ord,
6895
+ gated: unitAt(recorded.ord),
6896
+ prompt: recorded.row.prompt,
6897
+ gateKind: typeof kind === 'string' && kind !== '' ? kind : undefined,
6898
+ ...(openSeq !== undefined ? { gateSeq: openSeq } : {}),
6899
+ };
6673
6900
  }
6674
- if (namedOrd !== undefined) {
6675
- return unknown(`this decision names the gate before unit ${namedOrd}, but the engine's record `
6901
+ if (namedOrd !== undefined || namedSeq !== undefined) {
6902
+ return unknown(`this decision names the gate${namedOrd !== undefined ? ` before unit ${namedOrd}` : ` opening ${namedSeq ?? ''}`}, but the engine's record `
6676
6903
  + `${recorded === null ? 'keeps no durable gate row' : 'shows no open gate'} for this run, so the daemon cannot confirm the named one`);
6677
6904
  }
6678
6905
  const open = await resolveOpenGate(id).catch(() => null);
6679
- if (isOpenGate(open))
6906
+ if (isOpenGate(open)) {
6907
+ // (crew#1698, codex delta) No open durable row: no opening is bound (only a row the addon wrote numbers one, and
6908
+ // only an addon that writes `gate_seq` takes the expectation), whatever a cached or logged frame says.
6680
6909
  return { ord: open.ord, gated: unitAt(open.ord), prompt: open.prompt, gateKind: open.gateKind };
6910
+ }
6681
6911
  const gated = [...(run.units ?? [])].sort((a, b) => a.ord - b.ord)[run.session.unit_ix];
6682
6912
  return { ord: undefined, gated, prompt: undefined, gateKind: undefined };
6683
6913
  }
@@ -6802,6 +7032,17 @@ runtime = {}) {
6802
7032
  },
6803
7033
  };
6804
7034
  }
7035
+ // (DES-STANDIN-001 §3.8) Consent to stand-ins is a person's: a seat's token or a standing order is refused.
7036
+ if (parsed.data.action === USE_STAND_INS_ACTION && !isHumanOperator(actor)) {
7037
+ audit.record('gate.stand_ins_refused', actor, {
7038
+ runId: id,
7039
+ detail: { reason: 'human_operator_only', ...(parsed.data.ord !== undefined ? { ord: parsed.data.ord } : {}) },
7040
+ });
7041
+ return {
7042
+ code: 403,
7043
+ body: { error: `only a person can consent to stand-in checks (you are ${actor.kind}/${actor.trust})`, code: 'human_operator_only' },
7044
+ };
7045
+ }
6805
7046
  if (parsed.data.action === SKIP_QE_ACTION && !isHumanOperator(actor)) {
6806
7047
  audit.record('gate.skip_qe_refused', actor, {
6807
7048
  runId: id,
@@ -6825,11 +7066,14 @@ runtime = {}) {
6825
7066
  // Decision integrity (api-types 0.44.0; crew#1083 rounds 3–5): the gate this decision answers
6826
7067
  // is the RECORD's — read first thing inside the lock, so the gated unit and its delivery
6827
7068
  // checks below are the ones the record confirms ({@link gateForDecision}).
6828
- const decided = await gateForDecision(run, parsed.data.ord, { declining: !parsed.data.approve, versioned: true });
7069
+ const decided = await gateForDecision(run, parsed.data.ord, { declining: !parsed.data.approve, versioned: true, ...(parsed.data.gateSeq !== undefined ? { gateSeq: parsed.data.gateSeq } : {}) });
6829
7070
  if ('refusal' in decided) {
6830
7071
  const r = decided.refusal.body;
6831
7072
  return r?.code === 'gate_changed' ? { code: decided.refusal.code, body: { ...(await currentPlanOf(id, false)), ...r } } : decided.refusal;
6832
7073
  }
7074
+ if (parsed.data.action === USE_STAND_INS_ACTION) {
7075
+ return useStandInsAtGate(id, decided, parsed.data.scope ?? 'job', actor, parsed.data.input, extraDetail);
7076
+ }
6833
7077
  // (wicked-core#1683) A noted Land that skips open steering rules is the same human-only
6834
7078
  // decision as skip_rules. Read its rules under the decision lock and keep them for the audit.
6835
7079
  const landNote = parsed.data.amend?.trim() ?? '';
@@ -6927,8 +7171,8 @@ runtime = {}) {
6927
7171
  // gate ("judged by operator").
6928
7172
  adapter.recordGateActor?.(id, `${actor.id} (${actor.kind})`);
6929
7173
  const expect = parsed.data.planRev !== undefined
6930
- ? { ...expectFor(decided.ord), planRev: parsed.data.planRev }
6931
- : expectFor(decided.ord);
7174
+ ? { ...expectFor(decided.ord, decided.gateSeq), planRev: parsed.data.planRev }
7175
+ : expectFor(decided.ord, decided.gateSeq);
6932
7176
  const confirmArgs = [
6933
7177
  id,
6934
7178
  parsed.data.approve,
@@ -7031,13 +7275,81 @@ runtime = {}) {
7031
7275
  }
7032
7276
  });
7033
7277
  }
7278
+ /**
7279
+ * (DES-STANDIN-001 §3.10, crew#1856) `{approve: true, action: 'use_stand_ins', scope}` at a `stand_in_needed` gate:
7280
+ * the engine's `grantStandIns` with the open gate's opening (`gateSeq`, from the record) and the person as `actor`,
7281
+ * so a gate that closed and re-opened since is refused `gate_changed`. `always` also saves `standInReview:
7282
+ * 'always'` (after the grant took: a refused grant changes nothing). Runs inside {@link decideExclusively}.
7283
+ */
7284
+ async function useStandInsAtGate(id, decided, scope, actor, input, extraDetail) {
7285
+ if (decided.gateKind !== STAND_IN_NEEDED_GATE) {
7286
+ return { code: 409, body: {
7287
+ code: 'gate_changed',
7288
+ error: `Gate changed: use_stand_ins answers a stand-in gate (stand_in_needed), but the open gate is ${decided.gateKind ?? 'not one'}. Read the gate again.`,
7289
+ ...(decided.ord !== undefined ? { openOrd: decided.ord } : {}),
7290
+ } };
7291
+ }
7292
+ if (decided.gateSeq === undefined) {
7293
+ return { code: 409, body: { code: 'gate_unknown', error: 'Gate unknown: the engine\'s record does not say which opening of this gate is open, so stand-ins cannot be granted for it — refresh and decide again.' } };
7294
+ }
7295
+ if (typeof adapter.grantStandIns !== 'function' || typeof adapter.supportsStandIns !== 'function' || !adapter.supportsStandIns()) {
7296
+ return { code: 501, body: { error: 'Using stand-ins at a gate needs a wicked-core-ts with Core.grantStandIns; upgrade the engine' } };
7297
+ }
7298
+ const who = `${actor.id} (${actor.kind})`;
7299
+ let status;
7300
+ try {
7301
+ status = await adapter.grantStandIns(id, scope, decided.gateSeq, who, decided.ord);
7302
+ }
7303
+ catch (err) {
7304
+ if (err instanceof MaintenanceDrainError)
7305
+ return { code: 503, body: maintenanceDrainBody(err) };
7306
+ const changed = await gateChangedRefusal(id, err);
7307
+ if (changed !== null)
7308
+ return changed;
7309
+ return { code: 409, body: { error: message(err) } };
7310
+ }
7311
+ let setting;
7312
+ if (scope === 'always') {
7313
+ try {
7314
+ await adapter.updateSettings({ standInReview: 'always' });
7315
+ audit.record('settings.updated', actor, { detail: { changed: ['standInReview'], via: 'gate', runId: id } });
7316
+ setting = 'saved';
7317
+ }
7318
+ catch (err) {
7319
+ // The grant took (this run goes on with stand-ins); only the standing choice failed to save, and the answer says so.
7320
+ setting = 'failed';
7321
+ audit.record('settings.update_failed', actor, { detail: { key: 'standInReview', via: 'gate', runId: id, error: message(err) } });
7322
+ }
7323
+ }
7324
+ audit.record('gate.decided', actor, {
7325
+ runId: id,
7326
+ detail: {
7327
+ approve: true,
7328
+ choice: USE_STAND_INS_ACTION,
7329
+ action: USE_STAND_INS_ACTION,
7330
+ scope,
7331
+ gateSeq: decided.gateSeq,
7332
+ ...(decided.ord !== undefined ? { ord: decided.ord } : {}),
7333
+ ...(input !== undefined ? { input } : {}),
7334
+ ...extraDetail,
7335
+ status,
7336
+ },
7337
+ });
7338
+ return { code: 200, body: { status, ...(setting !== undefined ? { standInReview: setting } : {}) } };
7339
+ }
7034
7340
  /** (DES-CATALOG-002 §4.6) The plan a gate holds now, for a `gate_changed` answer: its ord and revision, best-effort. */
7035
7341
  async function currentPlanOf(runId, readGate = true) {
7036
7342
  try {
7037
7343
  // The caller that already read the open gate (and names its ord) asks for the plan revision only.
7038
7344
  const recorded = readGate ? await recordedOpenGate(runId) : null;
7039
7345
  const rev = openPlanGateRev(await busRows(adapter.busDbPath, runId));
7040
- return { ...(recorded?.state === 'open' ? { openOrd: recorded.ord } : {}), ...(rev !== undefined ? { planRev: rev } : {}) };
7346
+ // (crew#1698) …and the opening open now, as the daemon's own gate_changed says it.
7347
+ const openSeq = recorded?.state === 'open' ? gateSeqOf(recorded.row['gate_seq']) : undefined;
7348
+ return {
7349
+ ...(recorded?.state === 'open' ? { openOrd: recorded.ord } : {}),
7350
+ ...(openSeq !== undefined ? { openGateSeq: openSeq } : {}),
7351
+ ...(rev !== undefined ? { planRev: rev } : {}),
7352
+ };
7041
7353
  }
7042
7354
  catch {
7043
7355
  return {};
@@ -7047,8 +7359,12 @@ runtime = {}) {
7047
7359
  function adapterSupportsPlanSendBack() {
7048
7360
  return typeof adapter.supportsPlanSendBack === 'function' && adapter.supportsPlanSendBack();
7049
7361
  }
7050
- function expectFor(decidedOrd) {
7051
- return decidedOrd !== undefined && adapterSupportsPlanSendBack() ? { ord: decidedOrd } : undefined;
7362
+ /** What a confirm expects the open gate to be: its ord and (crew#1698, core#1808) the opening the record showed, which
7363
+ * the engine compares inside its serialized decision, so a gate that re-opened after this read still loses. */
7364
+ function expectFor(decidedOrd, gateSeq) {
7365
+ return decidedOrd !== undefined && adapterSupportsPlanSendBack()
7366
+ ? { ord: decidedOrd, ...(gateSeq !== undefined ? { gateSeq } : {}) }
7367
+ : undefined;
7052
7368
  }
7053
7369
  async function gateChangedRefusal(id, err) {
7054
7370
  if (!/^gate_changed\b/u.test(message(err)))
@@ -7244,13 +7560,21 @@ runtime = {}) {
7244
7560
  }
7245
7561
  try {
7246
7562
  const gated = run.session.status === 'awaiting_human';
7563
+ // (crew#1698, codex r1 on b7-standin) A resume naming a gate OPENING answers that gate: once it has closed,
7564
+ // nothing is resumed on its word.
7565
+ if (!gated && parsed.data.gateSeq !== undefined) {
7566
+ return reply.code(409).send({
7567
+ code: 'gate_changed',
7568
+ error: `Gate changed: this decision was made on opening ${parsed.data.gateSeq} of a gate, but run ${id} is ${run.session.status}, not parked at a gate — it was answered. Nothing was resumed.`,
7569
+ });
7570
+ }
7247
7571
  // A gated resume IS a gate approval, so it lands a steering-author proposal exactly like
7248
7572
  // POST /runs/:id/gate would — the "no side door" rule (task #88) holds for the landing
7249
7573
  // write too (crew#388). Prompt captured pre-confirm; see the gate route.
7250
7574
  // A gated resume IS an approve, so it is judged by the record like every decision, passes the
7251
7575
  // same delivery checks (freeze, EX-03) — no side door around the deliver gate — and answers
7252
7576
  // with the gated unit's receipt.
7253
- const decided = gated ? await gateForDecision(run, parsed.data.ord) : undefined;
7577
+ const decided = gated ? await gateForDecision(run, parsed.data.ord, parsed.data.gateSeq !== undefined ? { gateSeq: parsed.data.gateSeq } : {}) : undefined;
7254
7578
  if (decided !== undefined && 'refusal' in decided)
7255
7579
  return reply.code(decided.refusal.code).send(decided.refusal.body);
7256
7580
  const steeringPropose = gated && isSteeringAuthorRun(run);
@@ -7267,7 +7591,7 @@ runtime = {}) {
7267
7591
  const who = actorOf(req);
7268
7592
  adapter.recordGateActor?.(id, `${who.id} (${who.kind})`);
7269
7593
  }
7270
- const status = gated ? await adapter.confirmGate(id, true, undefined, undefined, undefined, undefined, expectFor(decided?.ord)) : await adapter.resumeRun(id);
7594
+ const status = gated ? await adapter.confirmGate(id, true, undefined, undefined, undefined, undefined, expectFor(decided?.ord, decided !== undefined && !('refusal' in decided) ? decided.gateSeq : undefined)) : await adapter.resumeRun(id);
7271
7595
  // A resume of a gated run IS a gate approval — audit it as one, so the
7272
7596
  // "who approved" trail has no side door (task #88).
7273
7597
  audit.record(gated ? 'gate.decided' : 'run.resumed', actorOf(req), {
@@ -7321,7 +7645,11 @@ runtime = {}) {
7321
7645
  }
7322
7646
  if (token !== null)
7323
7647
  voiceInputs.settle(id);
7324
- audit.record('run.injected', actorOf(req), { runId: id, detail: { target: parsed.data.target, ...(spoken ? { input: 'voice' } : {}) } });
7648
+ // (crew#1392) The words too, capped: the run's context document shows a person's steer under Decisions.
7649
+ audit.record('run.injected', actorOf(req), {
7650
+ runId: id,
7651
+ detail: { target: parsed.data.target, words: injectWords(parsed.data.message), ...(spoken ? { input: 'voice' } : {}) },
7652
+ });
7325
7653
  // DC-S4a host: the operator's mid-run steering text (review S9).
7326
7654
  if (decisions !== null) {
7327
7655
  decisions.track(ingestDecision(decisions, {
@@ -7403,7 +7731,28 @@ runtime = {}) {
7403
7731
  const textOrNull = (v) => (v === undefined || v === null || v.trim() === '' ? null : v.trim());
7404
7732
  const PowerToggleSchema = z.strictObject({ on: z.boolean(), reason: z.string().trim().max(2000).nullish() });
7405
7733
  const RigorRaiseSchema = z.strictObject({ atLeast: z.enum(RIGORS), reason: z.string().trim().min(1).max(2000) });
7406
- const PowerPauseSchema = z.strictObject({ decision: z.enum(['continue_high', 'continue', 'switch_phased', 'stop']), note: z.string().trim().max(8000).nullish() });
7734
+ const PowerPauseSchema = z.strictObject({
7735
+ decision: z.enum(['continue_high', 'continue', 'switch_phased', 'stop']),
7736
+ note: z.string().trim().max(8000).nullish(),
7737
+ // (crew#1739) The pause the person answered, as the card showed it (`PowerPause.checkpoint` / `.at`).
7738
+ checkpoint: z.number().int().positive().optional(),
7739
+ at: z.number().int().nonnegative().optional(),
7740
+ });
7741
+ /** (crew#1739) Each run's pause answers, one at a time (`onePauseAnswer`). */
7742
+ const pauseAnswers = new Map();
7743
+ const onePauseAnswer = (runId, op) => {
7744
+ const next = (pauseAnswers.get(runId) ?? Promise.resolve()).then(op, op);
7745
+ const settled = next.then(() => undefined, () => undefined);
7746
+ pauseAnswers.set(runId, settled);
7747
+ void settled.then(() => { if (pauseAnswers.get(runId) === settled)
7748
+ pauseAnswers.delete(runId); });
7749
+ return next;
7750
+ };
7751
+ /** A power pause's identity: its checkpoint and when it opened (`PowerPause`), or null when none is open. */
7752
+ const pauseIdentity = (view) => {
7753
+ const pause = view?.['pause'];
7754
+ return pause && typeof pause.checkpoint === 'number' && typeof pause.at === 'number' ? { checkpoint: pause.checkpoint, at: pause.at } : null;
7755
+ };
7407
7756
  /** An engine refusal as HTTP: `not_found:` 404, `conflict:` 409, `refused:` / `bad_request:` 409 / 400. */
7408
7757
  const powerError = (reply, err) => {
7409
7758
  const msg = message(err);
@@ -7484,22 +7833,42 @@ runtime = {}) {
7484
7833
  return reply.code(403).send({ error: 'Only a person can answer a power-mode pause' });
7485
7834
  if (!powerSupported())
7486
7835
  return reply.code(501).send({ error: 'This engine has no power mode' });
7487
- try {
7488
- const note = textOrNull(parsed.data.note);
7489
- const st = await adapter.answerPowerPause(id, parsed.data.decision, note, actor.id);
7490
- audit.record('run.power_mode.paused', actor, { runId: id, detail: { decision: parsed.data.decision } });
7491
- if (decisions !== null && note !== null) {
7492
- decisions.track(ingestDecision(decisions, {
7493
- host: 'inject', actor, words: note, projectId: projects.index.projectOf(id) ?? null, runId: id,
7494
- }));
7836
+ // (crew#1739) One answer per run at a time: the read of the open pause and the engine's answer are one step, so a
7837
+ // second answer reads what the first left (a newer pause, or none) and is refused if it named the old one. Every
7838
+ // pause answer goes through this route.
7839
+ return onePauseAnswer(id, async () => {
7840
+ try {
7841
+ // (crew#1739) Which pause this answer is for. One that names a pause no longer open is refused, so a queued
7842
+ // answer (studio's undo window) never lands on a newer pause the person never saw.
7843
+ const view = await powerView(id);
7844
+ const open = pauseIdentity(view);
7845
+ const { checkpoint, at } = parsed.data;
7846
+ if (view !== null && (checkpoint !== undefined || at !== undefined) &&
7847
+ (open === null || (checkpoint !== undefined && checkpoint !== open.checkpoint) || (at !== undefined && at !== open.at))) {
7848
+ return reply.code(409).send({
7849
+ error: 'Pause changed',
7850
+ reason: open === null
7851
+ ? 'This pause was already answered, and the run is not paused now. Nothing was changed.'
7852
+ : `This answer was for an earlier pause; the run is now paused at checkpoint ${open.checkpoint}. Read the pause again. Nothing was changed.`,
7853
+ open,
7854
+ });
7855
+ }
7856
+ const note = textOrNull(parsed.data.note);
7857
+ const st = await adapter.answerPowerPause(id, parsed.data.decision, note, actor.id);
7858
+ audit.record('run.power_mode.paused', actor, { runId: id, detail: { decision: parsed.data.decision } });
7859
+ if (decisions !== null && note !== null) {
7860
+ decisions.track(ingestDecision(decisions, {
7861
+ host: 'inject', actor, words: note, projectId: projects.index.projectOf(id) ?? null, runId: id,
7862
+ }));
7863
+ }
7864
+ return reply.send({ runId: id, ...st, answered: open });
7495
7865
  }
7496
- return reply.send({ runId: id, ...st });
7497
- }
7498
- catch (err) {
7499
- if (err instanceof MaintenanceDrainError)
7500
- return reply.code(503).send(maintenanceDrainBody(err));
7501
- return powerError(reply, err);
7502
- }
7866
+ catch (err) {
7867
+ if (err instanceof MaintenanceDrainError)
7868
+ return reply.code(503).send(maintenanceDrainBody(err));
7869
+ return powerError(reply, err);
7870
+ }
7871
+ });
7503
7872
  });
7504
7873
  /** The run's `wicked.run.*` bus mirror after a cursor (`RunBusPage`). Read through the engine's own bus
7505
7874
  * read and filtered to this run; a page scans at most 1000 bus rows past the cursor. */
@@ -7576,7 +7945,8 @@ runtime = {}) {
7576
7945
  return actions
7577
7946
  .filter((a) => declines(a) || !(a.action === SKIP_QE_ACTION ? skipRefused : approveRefused))
7578
7947
  .filter((a) => !(steering && a.action === 'reassign'))
7579
- .map((a) => (a.action === SKIP_QE_ACTION || a.action === SKIP_RULES_ACTION || (a.action === 'approve' && a.noteIntent === 'skip_rules')
7948
+ .map((a) => (a.action === SKIP_QE_ACTION || a.action === SKIP_RULES_ACTION || a.action === USE_STAND_INS_ACTION
7949
+ || (a.action === 'approve' && a.noteIntent === 'skip_rules')
7580
7950
  ? { ...a, humanOnly: true } : a));
7581
7951
  }
7582
7952
  /**
@@ -7665,6 +8035,14 @@ runtime = {}) {
7665
8035
  error: `run ${id} is executing, not parked at a gate — a note rides only a gated reassign (it is the approve's amendment). Nothing was reassigned.`,
7666
8036
  });
7667
8037
  }
8038
+ // (crew#1698, codex r1 on b7-standin) An answer naming a gate OPENING was made on a gate: once that gate has
8039
+ // closed (another decision released it before this one got the lock), it changes no running work.
8040
+ if (!gated && parsed.data.gateSeq !== undefined) {
8041
+ return reply.code(409).send({
8042
+ code: 'gate_changed',
8043
+ error: `Gate changed: this decision was made on opening ${parsed.data.gateSeq} of a gate, but run ${id} is ${run.session.status}, not parked at a gate — it was answered. Nothing was reassigned.`,
8044
+ });
8045
+ }
7668
8046
  const requestedCli = parsed.data.cli;
7669
8047
  if (requestedCli !== undefined) {
7670
8048
  const pool = Array.isArray(run.session.clis) ? run.session.clis : [];
@@ -7677,7 +8055,7 @@ runtime = {}) {
7677
8055
  // A gated reassign APPROVES the gate, so it is judged by the record like every decision and passes
7678
8056
  // the same delivery checks (freeze, wicked-core#850 EX-03) when the gate holds the deliver unit
7679
8057
  // (codex r1 on the EX-03 PR).
7680
- const decided = gated ? await gateForDecision(run, parsed.data.ord) : undefined;
8058
+ const decided = gated ? await gateForDecision(run, parsed.data.ord, parsed.data.gateSeq !== undefined ? { gateSeq: parsed.data.gateSeq } : {}) : undefined;
7681
8059
  if (decided !== undefined && 'refusal' in decided)
7682
8060
  return reply.code(decided.refusal.code).send(decided.refusal.body);
7683
8061
  if (decided !== undefined) {
@@ -7725,7 +8103,7 @@ runtime = {}) {
7725
8103
  return; // refused above for a gated run
7726
8104
  const who = actorOf(req);
7727
8105
  adapter.recordGateActor?.(id, `${who.id} (${who.kind})`);
7728
- const status = await adapter.confirmGate(id, true, note, undefined, undefined, undefined, expectFor(decided?.ord));
8106
+ const status = await adapter.confirmGate(id, true, note, undefined, undefined, undefined, expectFor(decided?.ord, decided !== undefined && !('refusal' in decided) ? decided.gateSeq : undefined));
7729
8107
  noteRode = note !== undefined;
7730
8108
  audit.record('gate.decided', actorOf(req), {
7731
8109
  runId: id,
@@ -7802,11 +8180,11 @@ runtime = {}) {
7802
8180
  // read it. A restart is routine: deploy, crash, laptop sleep.
7803
8181
  app.get(`${V}/runs/:id/gate`, async (req, reply) => {
7804
8182
  const { id } = req.params;
7805
- // F35: this run's view only, never every run's (studio polls this route for every parked run, from
7806
- // every open tab). Each read is a copy of one run from the shared snapshot, so a read after an
7807
- // await sees a change the adapter learned of during it (a frame, or a write it made); any other
7808
- // change is at most the snapshot's age bound old.
7809
- const runOf = () => adapter.runView(id);
8183
+ // F35, crew#1775: this run's view only, never every run's (studio reads this route for parked runs,
8184
+ // from every open tab): one engine read of this run, off the actor, as the store is when it starts.
8185
+ // Read once per request: the cached-but-not-servable path and the miss path share it (coord review C6).
8186
+ let viewRead;
8187
+ const runOf = () => (viewRead ??= adapter.runView(id));
7810
8188
  // (rejudge, api-types 0.134.0) A gate whose unit no judge could rule on says whether its judge
7811
8189
  // can be re-run now, and from which seats — the engine's own selection, read each time (a seat
7812
8190
  // signed in since the pause counts). Absent on every other gate and on an addon without the read.
@@ -7924,14 +8302,23 @@ runtime = {}) {
7924
8302
  }
7925
8303
  const cached = gateCache.get(id);
7926
8304
  if (cached) {
8305
+ const run = await runOf();
7927
8306
  const servable = recorded === null
7928
- || (recorded.state === 'open' && cached.ord === recorded.ord)
7929
- || (recorded.state === 'none' && (await runOf())?.session.status === 'awaiting_human');
8307
+ // (crew#1698) …and of the record's opening, when the row numbers it: a gate that re-opened at the
8308
+ // same ord while the pump was behind is not the cached one.
8309
+ || (recorded.state === 'open' && cached.ord === recorded.ord
8310
+ && (gateSeqOf(recorded.row['gate_seq']) === undefined || cached.gateSeq === gateSeqOf(recorded.row['gate_seq'])))
8311
+ || (recorded.state === 'none' && run?.session.status === 'awaiting_human');
7930
8312
  if (servable) {
7931
- const offers = await offersAt(cached.ord, await runOf());
8313
+ const offers = await offersAt(cached.ord, run);
7932
8314
  if (offers === null)
7933
8315
  return unavailable503();
7934
- return { runId: id, ...cached, ...offers };
8316
+ // (crew#1698, codex delta) Beside an open durable row the opening is the ROW's only: a frame's number beside
8317
+ // an unnumbered row is one no answer could name (POST checks the row).
8318
+ const entry = { ...cached };
8319
+ delete entry.gateSeq;
8320
+ const rowSeq = recorded?.state === 'open' ? gateSeqOf(recorded.row['gate_seq']) : cached.gateSeq;
8321
+ return { runId: id, ...entry, ...(rowSeq !== undefined ? { gateSeq: rowSeq } : {}), ...offers };
7935
8322
  }
7936
8323
  gateCache.forget(id);
7937
8324
  }
@@ -7944,13 +8331,9 @@ runtime = {}) {
7944
8331
  // cut of this assumed: it trades one read of the run's view for replaying an entire event history,
7945
8332
  // and it was that skipped check which made a completed run answer 503 on any build without the
7946
8333
  // binding (CI caught it) — an error where the honest, knowable answer was "no gate".
7947
- let run = await runOf();
7948
- // F35: the engine's gate record was read before the view and outranks it. A record showing a gate
7949
- // open beside no view of the run, or a view of it still moving, means the shared snapshot predates
7950
- // the pause (its frame has not landed yet): read the run from a fold that starts now.
7951
- if (recorded?.state === 'open' && run?.session.status !== 'awaiting_human') {
7952
- run = await adapter.runView(id, { fresh: true });
7953
- }
8334
+ // The view is read after the record, from the store as it is now (crew#1775), so a gate row the
8335
+ // record shows open is never beside an older view of its run: the engine writes both in one commit.
8336
+ const run = await runOf();
7954
8337
  if (!run)
7955
8338
  return reply.code(404).send({ error: 'Run not found' });
7956
8339
  if (run.session.status !== 'awaiting_human') {
@@ -7968,9 +8351,15 @@ runtime = {}) {
7968
8351
  // that read, the record is read once more (it may have moved on, legitimately, meanwhile): an
7969
8352
  // answer that matches it is served; otherwise the entry is dropped and the gate resolved once
7970
8353
  // more from the record, and if that still disagrees nothing verified is served.
7971
- if (recorded?.state === 'open' && isOpenGate(open) && open.ord !== recorded.ord) {
8354
+ // (crew#1698, codex delta) The opening too, when the row numbers it: a stale frame of an earlier opening at the
8355
+ // same ord is the same disagreement.
8356
+ const sameOpening = (o, r) => isOpenGate(o) && r?.state === 'open' && o.ord === r.ord
8357
+ && (gateSeqOf(r.row['gate_seq']) === undefined || o.gateSeq === gateSeqOf(r.row['gate_seq']));
8358
+ let record = recorded;
8359
+ if (recorded?.state === 'open' && isOpenGate(open) && !sameOpening(open, recorded)) {
7972
8360
  const now = await recordedOpenGate(id);
7973
- const matchesNow = (o) => isOpenGate(o) && now?.state === 'open' && o.ord === now.ord;
8361
+ record = now;
8362
+ const matchesNow = (o) => sameOpening(o, now);
7974
8363
  if (!matchesNow(open)) {
7975
8364
  gateCache.forget(id);
7976
8365
  open = await resolveOpenGate(id);
@@ -8010,11 +8399,21 @@ runtime = {}) {
8010
8399
  const offers = await offersAt(open.ord, run);
8011
8400
  if (offers === null)
8012
8401
  return unavailable503();
8402
+ // (crew#1698, codex delta) Beside an open durable row, its opening only (see the cache-hit path above).
8403
+ if (record?.state === 'open') {
8404
+ const entry = { ...open };
8405
+ delete entry.gateSeq;
8406
+ const rowSeq = gateSeqOf(record.row['gate_seq']);
8407
+ return { runId: id, ...entry, ...(rowSeq !== undefined ? { gateSeq: rowSeq } : {}), ...offers };
8408
+ }
8013
8409
  return { runId: id, ...open, ...offers };
8014
8410
  });
8015
8411
  // ── Elicitation (DES-002) ────────────────────────────────────────────────────
8016
8412
  //
8017
- // GET returns the current pending elicitation prompt for a run (display-store read).
8413
+ // GET returns the current pending elicitation prompt for a run (display-store read), or `null`
8414
+ // (a 200) when the run exists and has none open: "nothing open" is the normal answer for every
8415
+ // parked run a client polls, not an error (studio#984 logged one 404 per parked run per page load).
8416
+ // 404 stays for a run that does not exist. Every studio already reads "nothing open" as `null`.
8018
8417
  // POST resolves it: the body carries the elicitationId to guard against stale tabs,
8019
8418
  // the action (accept|decline|cancel), and — for accept — the operator's response.
8020
8419
  app.get(`${V}/runs/:id/elicitation`, async (req, reply) => {
@@ -8024,7 +8423,7 @@ runtime = {}) {
8024
8423
  // ("runId is specified more than once") from a redundant spread.
8025
8424
  if (entry)
8026
8425
  return entry;
8027
- // Cache miss: check existence before returning 404.
8426
+ // Cache miss: check existence first — an unknown run is the only 404.
8028
8427
  // Use sessions() (IDs only) — cheaper than sessionsDetail() on this read path.
8029
8428
  const ids = await adapter.sessions();
8030
8429
  if (!ids.includes(id))
@@ -8050,7 +8449,7 @@ runtime = {}) {
8050
8449
  receivedAt: new Date(pending.created_at).toISOString(),
8051
8450
  };
8052
8451
  }
8053
- return reply.code(404).send({ error: 'No pending elicitation for this run' });
8452
+ return reply.code(200).type('application/json').send('null');
8054
8453
  });
8055
8454
  const ElicitationRespondSchema = z.strictObject({
8056
8455
  /** Guards against stale-tab submissions: must match the current elicitation's id. */
@@ -8435,13 +8834,16 @@ runtime = {}) {
8435
8834
  return err?.code === 'ENOENT';
8436
8835
  }
8437
8836
  };
8837
+ const NOT_INDEXED = { error: 'this repository has no code graph yet: index it first', code: 'not_indexed' };
8838
+ // studio#1402 (codex r1): "not indexed" needs BOTH the engine's own open failure (it reads `open graph <db>: open
8839
+ // estate store read-only at "<db>": storage error: unable to open database file: <db>`) and a confirmed missing graph
8840
+ // file. Any other failure on such a repo (a binding drift, a bad answer) stays a server error, never "not indexed".
8841
+ const notIndexedFailure = async (repo, msg) => repoReadStatus(msg) === 500 && /unable to open database file/i.test(msg) && (await repoNotIndexed(repo));
8438
8842
  const repoReadFailure = async (reply, repo, err) => {
8439
8843
  const msg = message(err);
8440
- const status = repoReadStatus(msg);
8441
- if (status === 500 && (await repoNotIndexed(repo))) {
8442
- return reply.code(404).send({ error: 'this repository has no code graph yet: index it first', code: 'not_indexed' });
8443
- }
8444
- return reply.code(status).send({ error: msg });
8844
+ if (await notIndexedFailure(repo, msg))
8845
+ return reply.code(404).send(NOT_INDEXED);
8846
+ return reply.code(repoReadStatus(msg)).send({ error: msg });
8445
8847
  };
8446
8848
  app.get(`${V}/governance/coverage`, async (req, reply) => {
8447
8849
  // FINDING-009: with `?repo=<ref>`, report coverage over THAT repo's own code graph. The bare
@@ -8463,8 +8865,8 @@ runtime = {}) {
8463
8865
  app.get(`${V}/governance/graph`, async (req, reply) => {
8464
8866
  // #122: node-count-by-kind summary of a repo's OWN code graph. Repo-scoped ONLY — there is no
8465
8867
  // meaningful daemon-wide graph view (the daemon store holds run/governance nodes, not a repo's
8466
- // code graph), so a missing `?repo=` is a 400, an unknown repo a 404, and an engine/binding
8467
- // failure a 500 (not masked as 404).
8868
+ // code graph), so a missing `?repo=` is a 400, an unknown repo a 404, a repo not indexed yet a 200 with no
8869
+ // kinds (studio#1402), and an engine/binding failure a 500 (not masked as 404).
8468
8870
  const repo = repoParam(req);
8469
8871
  if (!repo) {
8470
8872
  return reply.code(400).send({ error: 'governance/graph requires a ?repo=<ref>' });
@@ -8474,6 +8876,11 @@ runtime = {}) {
8474
8876
  return { kinds };
8475
8877
  }
8476
8878
  catch (err) {
8879
+ // studio#1402: a known repo with no code graph yet is a state, not an error. The summary answers 200 with no
8880
+ // kinds and the reason (`code: 'not_indexed'`), so Repositories, Understand and a repository's page make no 404
8881
+ // per repo not indexed yet; every reader of `{ kinds }` draws "not built". An unknown id stays a plain 404.
8882
+ if (await notIndexedFailure(repo, message(err)))
8883
+ return { kinds: [], ...NOT_INDEXED };
8477
8884
  return repoReadFailure(reply, repo, err);
8478
8885
  }
8479
8886
  });
@@ -8920,7 +9327,10 @@ runtime = {}) {
8920
9327
  // Not generated yet is a state, typed by `code`, not a refusal (lane repo-page). It says how
8921
9328
  // far the repository is ("23% real requirements · 4397 placeholders · target 80%";
8922
9329
  // wicked-core#1233), from the very engine read the page used, when it has a store to count.
8923
- return reply.code(404).send({
9330
+ // A 200, not a 404 (studio#986): a repository nobody has generated requirements for is a normal
9331
+ // answer, and studio reads it for every such repository on each page. `code` is the discriminator;
9332
+ // the 404 stays only for a repository that is not registered (no `code`).
9333
+ return reply.code(200).send({
8924
9334
  ...REQUIREMENTS_NOT_GENERATED,
8925
9335
  ...(coverage === null ? {} : { coverage }),
8926
9336
  ...(minimum === null ? {} : { minimum }),
@@ -9032,6 +9442,45 @@ runtime = {}) {
9032
9442
  return reply.code(404).send({ error: 'Requirement not found' });
9033
9443
  return { requirement: detail };
9034
9444
  });
9445
+ // wicked-core#1698: retire a requirement whose code was deleted (the engine flags it `unindexed`), so a re-map
9446
+ // stops listing it. The engine's own command does the write; the id is never reused.
9447
+ app.post(`${V}/repos/:id/requirements/:key/retire`, async (req, reply) => {
9448
+ const { id, key } = req.params;
9449
+ const repos = await adapter.listRepos();
9450
+ const repo = repos.find((r) => r.id === id);
9451
+ if (!repo)
9452
+ return reply.code(404).send({ error: `Repo ${id} not found` });
9453
+ let decodedKey;
9454
+ try {
9455
+ decodedKey = decodeURIComponent(key);
9456
+ }
9457
+ catch {
9458
+ return reply.code(400).send({ error: 'Malformed requirement key encoding' });
9459
+ }
9460
+ let outcome;
9461
+ try {
9462
+ outcome = await retireRequirement(repo, decodedKey, adapter);
9463
+ }
9464
+ catch (err) {
9465
+ const status = codeGraphErrorStatus(err);
9466
+ if (status !== null)
9467
+ return reply.code(status).send({ error: message(err) });
9468
+ return reply.code(500).send({ error: `${decodedKey} could not be retired: ${message(err)}` });
9469
+ }
9470
+ if (outcome === 'not_found')
9471
+ return reply.code(404).send({ error: 'Requirement not found' });
9472
+ if (outcome === 'not_unindexed') {
9473
+ return reply.code(409).send({
9474
+ error: `${decodedKey} is not listed as no longer in the code, so it cannot be retired. Only a requirement whose code was deleted can be. If its code was deleted, map ${repo.name} again, then retire it.`,
9475
+ });
9476
+ }
9477
+ if (outcome === 'engine_too_old') {
9478
+ return reply.code(409).send({
9479
+ error: 'The installed wicked-core cannot retire requirements yet. Update wicked-core, then try again.',
9480
+ });
9481
+ }
9482
+ return { retired: decodedKey };
9483
+ });
9035
9484
  app.get(`${V}/repos/:id/graph`, { config: { manifest: { responseType: 'RepoGraphResponse', statusCodes: [200, 404, 409, 500, 503] } } }, async (req, reply) => {
9036
9485
  const { id } = req.params;
9037
9486
  const repos = await adapter.listRepos();
@@ -9345,6 +9794,12 @@ runtime = {}) {
9345
9794
  // additive `path` (api-types 0.38.0 `SettingsResponse.path?`; adjudicated §4.6 — `path`, not
9346
9795
  // `settings_path`).
9347
9796
  app.get(`${V}/settings`, async () => ({ settings: await adapter.getSettings(), path: settingsFilePath() }));
9797
+ // studio#1324: whether this daemon's port starts at login (`serve --install-service`), for Settings' status row. The
9798
+ // port is the one this daemon listens on (the default when it is not listening, as under inject).
9799
+ app.get(`${V}/settings/start-on-login`, { config: { manifest: { responseType: 'StartOnLoginStatus', statusCodes: [200] } } }, async () => {
9800
+ const bound = app.server.address();
9801
+ return startOnLoginStatus(bound !== null && typeof bound === 'object' ? bound.port : DEFAULT_DAEMON_PORT, runtime.startOnLogin?.platform, runtime.startOnLogin?.home);
9802
+ });
9348
9803
  // The demo video's palette from the studio skin (operator 2026-10-14): read-only, derived from `studio.appearance`;
9349
9804
  // garden's demo stage and interactive's re-cuts read it as their default colours.
9350
9805
  app.get(`${V}/appearance/video-palette`, { config: { manifest: { responseType: 'VideoPaletteResponse', statusCodes: [200] } } }, async () => videoPalette((await adapter.getSettings())['studio.appearance']));
@@ -9491,6 +9946,17 @@ runtime = {}) {
9491
9946
  return reply.code(403).send({ error: 'Only a person can change the power mode default (powerModeDefault)' });
9492
9947
  }
9493
9948
  }
9949
+ // standInReview (DES-STANDIN-001 §4, K2a): 'ask' | 'always'. 'always' is a person's standing consent to stand-in
9950
+ // checks on every later job (labelled everywhere, never independent), so a typo is a 400 and only a PERSON may
9951
+ // change it (a worker's bearer gets 403): a worker may only inherit the consent a person gave.
9952
+ if (Object.hasOwn(patch, 'standInReview')) {
9953
+ if (!isStandInReview(patch.standInReview)) {
9954
+ return reply.code(400).send({ error: "standInReview must be 'ask' or 'always'" });
9955
+ }
9956
+ if (!isHumanOperator(actorOf(req))) {
9957
+ return reply.code(403).send({ error: 'Only a person can change stand-in review (standInReview)' });
9958
+ }
9959
+ }
9494
9960
  // newWorkSeats (F1/F2): which seats new chats and jobs are drawn from (`core/job-seats.ts`). A list of seat keys,
9495
9961
  // or null for the default rule; a person's choice only (a worker's bearer gets 403).
9496
9962
  if (Object.hasOwn(patch, 'newWorkSeats')) {
@@ -9605,6 +10071,7 @@ runtime = {}) {
9605
10071
  'deliverDefault',
9606
10072
  'qeAcceptance',
9607
10073
  'powerModeDefault',
10074
+ 'standInReview',
9608
10075
  'newWorkSeats',
9609
10076
  'onboardingAutoCapture',
9610
10077
  'deliverIdentityLogin',
@@ -9711,30 +10178,56 @@ runtime = {}) {
9711
10178
  args.kind_type = kindType;
9712
10179
  if (state !== undefined)
9713
10180
  args.state = state;
10181
+ let listed;
9714
10182
  try {
9715
- return (await estateTool('proposal.list', args));
10183
+ listed = (await estateTool('proposal.list', args));
9716
10184
  }
9717
10185
  catch (err) {
9718
10186
  return estateUpstreamError(reply, err);
9719
10187
  }
10188
+ // crew#1261: a rejected row says who rejected it and why, when crew made that decision.
10189
+ const decided = await proposalDecisions.decisions();
10190
+ if (decided.size === 0 || !Array.isArray(listed?.proposals))
10191
+ return listed;
10192
+ return {
10193
+ ...listed,
10194
+ proposals: listed.proposals.map((p) => {
10195
+ const decision = p.state === 'rejected' ? decided.get(p.id) : undefined;
10196
+ return decision !== undefined ? { ...p, decision } : p;
10197
+ }),
10198
+ };
9720
10199
  });
9721
- // POST /proposals {content, project?, source?} → proposal.submit → 201 { id } (api-types 0.54.0).
9722
- // A skin files ONE preference into the same review queue — studio's "takes": the person picks one
9723
- // of two candidate outputs, and the pick becomes "prefers takes like X", learned only once they
9724
- // accept it here. The kind (`memory`), tier and `capture: "preference"` marker are the daemon's; a
9725
- // caller cannot file a policy through this door (the schema is strict). `project` becomes the
9726
- // `project` facet, so the preference is recalled on that project only.
10200
+ // POST /proposals {content, project?, repo?, tier?, source?} → proposal.submit → 201 { id } (api-types 0.54.0;
10201
+ // tier and repo 0.228.0, studio#1095). A skin files ONE memory into the same review queue — studio's "takes" (the
10202
+ // person picks one of two candidate outputs, and the pick becomes "prefers takes like X") and the Memory page's
10203
+ // add — learned only once they accept it here. The kind (`memory`) and `capture: "preference"` marker are the
10204
+ // daemon's; a caller cannot file a policy through this door (the schema is strict). The tier is the person's
10205
+ // choice of three (a fact by default); `project` and `repo` become those facets, so it is recalled there only.
10206
+ // `repo` is a registered repository's id (a run's `repo_ref`, which recall matches): one no registry row carries is
10207
+ // a 400 `repo_unknown`, since a memory on it would never be recalled; a registry that cannot be read is a 503.
9727
10208
  app.post(`${V}/proposals`, {
9728
10209
  config: {
9729
- manifest: { requestType: 'FileProposalBody', responseType: 'FileProposalResponse', statusCodes: [201, 400, 502] },
10210
+ manifest: { requestType: 'FileProposalBody', responseType: 'FileProposalResponse', statusCodes: [201, 400, 502, 503] },
9730
10211
  },
9731
10212
  }, async (req, reply) => {
9732
10213
  const parsed = FileProposalSchema.safeParse(req.body ?? {});
9733
10214
  if (!parsed.success) {
9734
10215
  return reply.code(400).send(invalidBody(parsed.error, 'Invalid proposal body'));
9735
10216
  }
9736
- const { content, project, source } = parsed.data;
9737
- const payload = { content, tier: 'semantic', capture: 'preference' };
10217
+ const { content, project, repo, tier, source } = parsed.data;
10218
+ if (repo !== undefined) {
10219
+ let known;
10220
+ try {
10221
+ known = (await adapter.listRepos()).some((r) => r.id === repo);
10222
+ }
10223
+ catch (err) {
10224
+ return reply.code(503).send({ error: `the repository list could not be read (${err instanceof Error ? err.message : String(err)}); nothing was filed, try again` });
10225
+ }
10226
+ if (!known) {
10227
+ return reply.code(400).send({ error: `no registered repository has the id '${repo}', so a memory on it would never be recalled; pick one from GET /repos`, code: 'repo_unknown' });
10228
+ }
10229
+ }
10230
+ const payload = { content, tier: tier ?? 'semantic', capture: 'preference' };
9738
10231
  if (source !== undefined)
9739
10232
  payload.source = source;
9740
10233
  let submitted;
@@ -9742,7 +10235,7 @@ runtime = {}) {
9742
10235
  submitted = (await estateTool('proposal.submit', {
9743
10236
  kind_type: 'memory',
9744
10237
  payload,
9745
- facets: project !== undefined ? { project } : {},
10238
+ facets: { ...(project !== undefined ? { project } : {}), ...(repo !== undefined ? { repo } : {}) },
9746
10239
  }));
9747
10240
  }
9748
10241
  catch (err) {
@@ -9839,7 +10332,9 @@ runtime = {}) {
9839
10332
  }
9840
10333
  if (policyReach === undefined && (edit.data.content !== undefined || edit.data.reach !== undefined)) {
9841
10334
  try {
9842
- const done = await approveEdited(editTool, id, edit.data, (runId) => projects.index.projectOf(runId));
10335
+ const done = await approveEdited(editTool, id, edit.data, (runId) => projects.index.projectOf(runId),
10336
+ // crew#1261: the original replaced by the copy, or a copy withdrawn, is crew's decision on the person's behalf.
10337
+ (pid, reason, copy) => recordProposalDecision(audit, actorOf(req), pid, reason, copy));
9843
10338
  return reply.code(done.status).send(done.body);
9844
10339
  }
9845
10340
  catch (err) {
@@ -9864,7 +10359,9 @@ runtime = {}) {
9864
10359
  // crew#1546: an edited learning's replacement whose learning is gone is stale: refused and rejected, never approved,
9865
10360
  // so no crash window can bring retired words back (accept-with-edit checks the same in `approveEdited`).
9866
10361
  try {
9867
- const stale = row?.kind_type === 'memory' ? await refuseStaleReplacement(estateTool, id, row.payload) : null;
10362
+ const stale = row?.kind_type === 'memory'
10363
+ ? await refuseStaleReplacement(estateTool, id, row.payload, (pid) => recordProposalDecision(audit, actorOf(req), pid, 'stale'))
10364
+ : null;
9868
10365
  if (stale !== null)
9869
10366
  return reply.code(409).send({ error: stale, code: 'stale_replacement' });
9870
10367
  }
@@ -9949,10 +10446,18 @@ runtime = {}) {
9949
10446
  return landFailed(`${new SteeringUnsupportedError('Landing an approved policy proposal').message} — the ` +
9950
10447
  `installed engine would silently drop the rule's steering fields; upgrade wicked-core-ts (>= 0.7.5)`);
9951
10448
  }
9952
- // A proposal with no `project` facet keeps the project of the run that filed it.
10449
+ // A proposal's `project` facet resolves to a known project (crew#1774); one that names none keeps the project of
10450
+ // the run that filed it.
9953
10451
  const runId = policyRow.provenance?.['run_id'];
9954
10452
  const runProject = typeof runId === 'string' && runId !== '' ? projects.index.projectOf(runId) : undefined;
9955
- const built = policyProposalToRule(id, policyRow.kind_type, policyRow.payload, isStringRecord(policyRow.facets) ? policyRow.facets : undefined, { ...(runProject !== undefined ? { runProject } : {}), ...(policyReach !== undefined ? { reach: policyReach } : {}) });
10453
+ let knownProjects;
10454
+ try {
10455
+ knownProjects = await adapter.projectList();
10456
+ }
10457
+ catch (err) {
10458
+ return landFailed(`the projects could not be read to resolve the rule's project (${message(err)})`);
10459
+ }
10460
+ const built = policyProposalToRule(id, policyRow.kind_type, policyRow.payload, isStringRecord(policyRow.facets) ? policyRow.facets : undefined, { ...(runProject !== undefined ? { runProject } : {}), ...(policyReach !== undefined ? { reach: policyReach } : {}), projects: knownProjects });
9956
10461
  if ('error' in built) {
9957
10462
  return landFailed(built.error);
9958
10463
  }
@@ -10019,6 +10524,8 @@ runtime = {}) {
10019
10524
  catch (err) {
10020
10525
  return estateUpstreamError(reply, err);
10021
10526
  }
10527
+ // crew#1261: turned down by this caller (a person's rejection when it is a person).
10528
+ recordProposalDecision(audit, actorOf(req), id.trim(), 'rejected');
10022
10529
  // A policy proposal's rule lands before its approval, so a still-pending proposal may already
10023
10530
  // have a live rule (a crash or an unconfirmed approve in between): rejecting it withdraws it.
10024
10531
  const withdrawn = await withdrawLandedRule(adapter, id.trim());
@@ -10047,11 +10554,14 @@ runtime = {}) {
10047
10554
  // • RETIRE comes in two widths. `POST /memory/retire { scope_prefix }` is SUBTREE-scoped:
10048
10555
  // `memory.erase {scope_prefix}` hard-deletes EVERY memory whose scope equals or descends from
10049
10556
  // the prefix, and refuses an empty prefix (a total-wipe guard) — the UI must show the operator
10050
- // the subtree. `POST /memory/retire-item { memory_id }` (studio#206) removes exactly ONE memory
10051
- // through `memory.erase {id}` (wicked-estate#188); an older estate refuses that call without
10052
- // deleting anything, and the route answers 501 naming the upgrade — never a subtree fallback.
10557
+ // the subtree. `POST /memory/retire-item { memory_id }` (studio#206) SOFT-retires exactly ONE
10558
+ // memory through `memory.retire {id}` (crew#1697, wicked-estate#552): hidden from recall and the
10559
+ // browse, kept with its id, listed by `GET /memory?retired=1`, restored by `POST /memory/unretire`.
10560
+ // `POST /memory/erase-item { memory_id }` deletes one for good (`memory.erase {id}`,
10561
+ // wicked-estate#188), the right-to-erasure path. An estate without the tool refuses the call
10562
+ // without changing anything, and the route answers 501 naming the upgrade — never a fallback.
10053
10563
  // GET /memory?query=&scope_prefix=&facets=<json>&limit= → memory.list + post-filter → { memories }.
10054
- app.get(`${V}/memory`, { config: { manifest: { responseType: 'ListMemoriesResponse', statusCodes: [200, 400, 502] } } }, async (req, reply) => {
10564
+ app.get(`${V}/memory`, { config: { manifest: { responseType: 'ListMemoriesResponse', statusCodes: [200, 400, 501, 502] } } }, async (req, reply) => {
10055
10565
  const q = req.query;
10056
10566
  // `scope_prefix` is the ONLY estate-side argument to memory.list (a subtree filter; blank /
10057
10567
  // omitted = every memory). Forward verbatim WHEN PRESENT — a blank value is meaningful
@@ -10060,6 +10570,14 @@ runtime = {}) {
10060
10570
  const scopePrefix = firstQueryValue(q.scope_prefix);
10061
10571
  if (scopePrefix !== undefined)
10062
10572
  args.scope_prefix = scopePrefix;
10573
+ // crew#1697: `retired=1` lists the soft-retired memories (`memory.list {retired: true}`) instead.
10574
+ const rawRetired = firstQueryValue(q.retired)?.trim().toLowerCase();
10575
+ if (rawRetired !== undefined && !['1', 'true', '0', 'false'].includes(rawRetired)) {
10576
+ return reply.code(400).send({ error: '`retired` must be 1, true, 0 or false' });
10577
+ }
10578
+ const retired = rawRetired === '1' || rawRetired === 'true';
10579
+ if (retired)
10580
+ args.retired = true;
10063
10581
  // `facets` narrows the COMPLETE list crew-side (after the estate fetch) to memories carrying
10064
10582
  // every given axis:value (a management filter, NOT a recall intent). Present-but-blank is a
10065
10583
  // client error
@@ -10120,6 +10638,14 @@ runtime = {}) {
10120
10638
  throw new EstateMcpError('memory.list returned an unexpected shape');
10121
10639
  }
10122
10640
  let memories = items.map(shapeMemoryItem);
10641
+ // An estate before wicked-estate#552 ignores `retired` and lists the LIVE memories: a row without
10642
+ // `retired_at` in a retired list is that, never shown as retired.
10643
+ if (retired && memories.some((m) => m.retired_at === undefined)) {
10644
+ return reply.code(501).send({
10645
+ error: 'this wicked-estate cannot list retired memories (it needs wicked-estate#552); upgrade wicked-estate-mcp',
10646
+ code: 'estate_upgrade_required',
10647
+ });
10648
+ }
10123
10649
  if (query !== '')
10124
10650
  memories = memories.filter((m) => m.content.toLowerCase().includes(query));
10125
10651
  if (facetFilter !== undefined) {
@@ -10136,6 +10662,9 @@ runtime = {}) {
10136
10662
  return body;
10137
10663
  }
10138
10664
  catch (err) {
10665
+ if (retired && estateLacksTool(err)) {
10666
+ return reply.code(501).send(estateUpgrade('cannot list retired memories', '#552', 'nothing was changed'));
10667
+ }
10139
10668
  return estateUpstreamError(reply, err);
10140
10669
  }
10141
10670
  });
@@ -10188,15 +10717,15 @@ runtime = {}) {
10188
10717
  return estateUpstreamError(reply, err);
10189
10718
  }
10190
10719
  });
10191
- // POST /memory/retire-item { memory_id } → memory.erase { id } → { erased: 1 } (studio#206). Removes
10192
- // exactly ONE memory: the id is the only target sent, so no reading of it can widen to a subtree.
10193
- // 404 when estate holds no memory with that id (it erased 0). 501 when the estate predates
10194
- // wicked-estate#188: it refuses an id-only erase for want of `scope_prefix`, deleting nothing.
10720
+ // POST /memory/retire-item { memory_id } → memory.retire { id } → { retired: 1 } (studio#206; soft since
10721
+ // crew#1697). Hides exactly ONE memory, kept with its id: the id is the only target sent, so no reading of it can
10722
+ // widen to a subtree. 404 when estate holds no live memory with that id (it retired 0). 501 when the estate
10723
+ // predates soft retire (wicked-estate#552): it refuses the unknown tool, changing nothing — never an erase instead.
10195
10724
  app.post(`${V}/memory/retire-item`, {
10196
10725
  config: {
10197
10726
  manifest: {
10198
10727
  requestType: 'RetireMemoryItemBody',
10199
- responseType: 'RetireMemoryResponse',
10728
+ responseType: 'RetireMemoryItemResponse',
10200
10729
  statusCodes: [200, 400, 404, 501, 502],
10201
10730
  },
10202
10731
  },
@@ -10208,27 +10737,132 @@ runtime = {}) {
10208
10737
  const memoryId = parsed.data.memory_id.trim();
10209
10738
  if (memoryId === '')
10210
10739
  return reply.code(400).send({ error: '`memory_id` must not be empty' });
10740
+ // An edit in flight ends by erasing the memory it replaces (retired or not), so a retire that slipped in
10741
+ // between would be erased for good: the two take turns on one memory (codex review).
10742
+ if (memoryEditsInFlight.has(memoryId)) {
10743
+ return reply.code(409).send({ error: `memory ${memoryId} is being edited; retire it once the edit is done` });
10744
+ }
10745
+ memoryEditsInFlight.add(memoryId);
10211
10746
  try {
10212
- const raw = await estateTool('memory.erase', { id: memoryId });
10213
- const deleted = typeof raw === 'object' && raw !== null ? raw['deleted_count'] : undefined;
10214
- if (typeof deleted !== 'number') {
10215
- throw new EstateMcpError('memory.erase returned an unexpected shape');
10216
- }
10217
- if (deleted === 0)
10747
+ const count = oneMemoryCount(await estateTool('memory.retire', { id: memoryId }), 'memory.retire', 'retired_count');
10748
+ if (count === 0)
10749
+ return reply.code(404).send({ error: `no live memory ${memoryId}` });
10750
+ const body = { retired: 1 };
10751
+ return body;
10752
+ }
10753
+ catch (err) {
10754
+ if (estateLacksTool(err))
10755
+ return reply.code(501).send(estateUpgrade('cannot retire a memory and restore it later', '#552', 'nothing was changed'));
10756
+ return estateUpstreamError(reply, err);
10757
+ }
10758
+ finally {
10759
+ memoryEditsInFlight.delete(memoryId);
10760
+ }
10761
+ });
10762
+ // POST /memory/unretire { memory_id } → memory.unretire { id } → { restored: 1 } (crew#1697). Restores ONE
10763
+ // retired memory with the same id. 404 when no retired memory has that id; 501 on an estate before #552.
10764
+ app.post(`${V}/memory/unretire`, {
10765
+ config: {
10766
+ manifest: {
10767
+ requestType: 'UnretireMemoryBody',
10768
+ responseType: 'UnretireMemoryResponse',
10769
+ statusCodes: [200, 400, 404, 501, 502],
10770
+ },
10771
+ },
10772
+ }, async (req, reply) => {
10773
+ const parsed = RetireMemoryItemSchema.safeParse(req.body);
10774
+ if (!parsed.success) {
10775
+ return reply.code(400).send(invalidBody(parsed.error, 'Invalid restore request'));
10776
+ }
10777
+ const memoryId = parsed.data.memory_id.trim();
10778
+ if (memoryId === '')
10779
+ return reply.code(400).send({ error: '`memory_id` must not be empty' });
10780
+ try {
10781
+ const count = oneMemoryCount(await estateTool('memory.unretire', { id: memoryId }), 'memory.unretire', 'restored_count');
10782
+ if (count === 0)
10783
+ return reply.code(404).send({ error: `no retired memory ${memoryId}` });
10784
+ const body = { restored: 1 };
10785
+ return body;
10786
+ }
10787
+ catch (err) {
10788
+ if (estateLacksTool(err))
10789
+ return reply.code(501).send(estateUpgrade('cannot restore a retired memory', '#552', 'nothing was changed'));
10790
+ return estateUpstreamError(reply, err);
10791
+ }
10792
+ });
10793
+ // POST /memory/erase-item { memory_id } → memory.erase { id } → { erased: 1 } (crew#1697; the hard delete
10794
+ // `retire-item` was before it went soft). Deletes ONE memory for good, live or retired. 404 when estate holds no
10795
+ // memory with that id; 501 when the estate predates wicked-estate#188 (it refuses an id-only erase, deleting nothing).
10796
+ app.post(`${V}/memory/erase-item`, {
10797
+ config: {
10798
+ manifest: {
10799
+ requestType: 'EraseMemoryItemBody',
10800
+ responseType: 'RetireMemoryResponse',
10801
+ statusCodes: [200, 400, 404, 501, 502],
10802
+ },
10803
+ },
10804
+ }, async (req, reply) => {
10805
+ const parsed = RetireMemoryItemSchema.safeParse(req.body);
10806
+ if (!parsed.success) {
10807
+ return reply.code(400).send(invalidBody(parsed.error, 'Invalid erase request'));
10808
+ }
10809
+ const memoryId = parsed.data.memory_id.trim();
10810
+ if (memoryId === '')
10811
+ return reply.code(400).send({ error: '`memory_id` must not be empty' });
10812
+ try {
10813
+ const count = oneMemoryCount(await estateTool('memory.erase', { id: memoryId }), 'memory.erase', 'deleted_count');
10814
+ if (count === 0)
10218
10815
  return reply.code(404).send({ error: `no memory ${memoryId}` });
10219
- if (deleted !== 1) {
10220
- // An id names one memory; any other count is estate misbehaving, and it is reported as such.
10221
- return reply.code(502).send({ error: `memory.erase {id} removed ${deleted} memories, expected 1` });
10222
- }
10223
10816
  const body = { erased: 1 };
10224
10817
  return body;
10225
10818
  }
10226
10819
  catch (err) {
10227
10820
  if (err instanceof EstateMcpError && err.code === -32602 && ESTATE_NO_ERASE_BY_ID.test(err.message)) {
10228
- return reply.code(501).send({
10229
- error: 'this wicked-estate cannot erase one memory by id (it needs wicked-estate#188); upgrade wicked-estate-mcp — nothing was deleted',
10230
- code: 'estate_upgrade_required',
10231
- });
10821
+ return reply.code(501).send(estateUpgrade('cannot erase one memory by id', '#188', 'nothing was deleted'));
10822
+ }
10823
+ return estateUpstreamError(reply, err);
10824
+ }
10825
+ });
10826
+ // POST /knowledge/forget { id | source | scope_prefix, confirm_erase_all? } → knowledge.forget →
10827
+ // { forgotten, skipped_live_source } (crew#1697, wicked-estate#553). Hard-deletes document knowledge only. Exactly
10828
+ // one target, checked here (400 before any spawn); estate's own -32602 is a 400 too. A live source's structure
10829
+ // named by id is refused by estate (409: it is refreshed through its source); an estate before #553 is a 501.
10830
+ app.post(`${V}/knowledge/forget`, {
10831
+ config: {
10832
+ manifest: {
10833
+ requestType: 'ForgetKnowledgeBody',
10834
+ responseType: 'ForgetKnowledgeResponse',
10835
+ statusCodes: [200, 400, 409, 501, 502],
10836
+ },
10837
+ },
10838
+ }, async (req, reply) => {
10839
+ const parsed = ForgetKnowledgeSchema.safeParse(req.body);
10840
+ if (!parsed.success) {
10841
+ return reply.code(400).send(invalidBody(parsed.error, 'Invalid forget request'));
10842
+ }
10843
+ const { confirm_erase_all: confirm, ...targets } = parsed.data;
10844
+ const named = Object.entries(targets).filter(([, v]) => v !== undefined);
10845
+ if (named.length !== 1) {
10846
+ return reply.code(400).send({ error: 'give exactly one of `id`, `source` or `scope_prefix`' });
10847
+ }
10848
+ const [field, value] = named[0];
10849
+ if (value.trim() === '' && !(field === 'scope_prefix' && value === '' && confirm === true)) {
10850
+ return reply.code(400).send({ error: `\`${field}\` must not be empty (forgetting everything is \`scope_prefix: ""\` with \`confirm_erase_all: true\`)` });
10851
+ }
10852
+ try {
10853
+ const raw = await estateTool('knowledge.forget', { [field]: value, ...(confirm !== undefined ? { confirm_erase_all: confirm } : {}) });
10854
+ const r = typeof raw === 'object' && raw !== null ? raw : {};
10855
+ if (typeof r['forgotten'] !== 'number' || typeof r['skipped_live_source'] !== 'number') {
10856
+ throw new EstateMcpError('knowledge.forget returned an unexpected shape');
10857
+ }
10858
+ const body = { forgotten: r['forgotten'], skipped_live_source: r['skipped_live_source'] };
10859
+ return body;
10860
+ }
10861
+ catch (err) {
10862
+ if (estateLacksTool(err))
10863
+ return reply.code(501).send(estateUpgrade('cannot forget knowledge', '#553', 'nothing was deleted'));
10864
+ if (err instanceof EstateMcpError && ESTATE_FORGET_REFUSED.test(err.message)) {
10865
+ return reply.code(409).send({ error: err.message });
10232
10866
  }
10233
10867
  return estateUpstreamError(reply, err);
10234
10868
  }
@@ -10261,7 +10895,7 @@ runtime = {}) {
10261
10895
  if (content === '')
10262
10896
  return reply.code(400).send({ error: '`content` must not be empty' });
10263
10897
  if (memoryEditsInFlight.has(memoryId)) {
10264
- return reply.code(409).send({ error: `memory ${memoryId} is already being edited` });
10898
+ return reply.code(409).send({ error: `memory ${memoryId} is already being edited or retired` });
10265
10899
  }
10266
10900
  memoryEditsInFlight.add(memoryId);
10267
10901
  // Every estate call here is crew's own (no client argument reaches estate unchecked), so an
@@ -10289,10 +10923,14 @@ runtime = {}) {
10289
10923
  : [];
10290
10924
  });
10291
10925
  };
10292
- /** Reject these proposals; true only when the queue is read back with none of them pending. */
10293
- const withdraw = async (ids) => {
10294
- for (const id of ids)
10295
- await estateTool('proposal.reject', { id }).catch(() => undefined);
10926
+ /** Reject these proposals; true only when the queue is read back with none of them pending. Each rejection
10927
+ * that happened is recorded as crew's (crew#1261): `stale` for a superseded replacement, `withdrawn` for one
10928
+ * this edit filed itself and is taking back. */
10929
+ const withdraw = async (ids, reason = 'withdrawn') => {
10930
+ for (const id of ids) {
10931
+ if (await estateTool('proposal.reject', { id }).then(() => true, () => false))
10932
+ recordProposalDecision(audit, actorOf(req), id, reason);
10933
+ }
10296
10934
  try {
10297
10935
  const still = new Set((await pendingMemoryProposals()).map((q) => q.id));
10298
10936
  return ids.every((id) => !still.has(id));
@@ -10344,7 +10982,7 @@ runtime = {}) {
10344
10982
  catch (err) {
10345
10983
  return { status: 502, error: `reading the approve queue failed (${message(err)}); nothing changed` };
10346
10984
  }
10347
- if (superseded.length > 0 && !(await withdraw(superseded))) {
10985
+ if (superseded.length > 0 && !(await withdraw(superseded, 'stale'))) {
10348
10986
  return { status: 502, error: `an earlier replacement of ${old.id} (${superseded.join(', ')}) is still pending and could not be rejected; reject it on the approve page first. Nothing changed` };
10349
10987
  }
10350
10988
  let pid = null;
@@ -10726,6 +11364,8 @@ runtime = {}) {
10726
11364
  ...(runtime.dataGate !== undefined ? { gate: runtime.dataGate } : {}),
10727
11365
  ...(mcpPolicies !== undefined ? { policies: mcpPolicies } : {}),
10728
11366
  ...(runtime.mcpCalls !== undefined ? { usage: runtime.mcpCalls } : {}),
11367
+ // (crew#1514) A rename lists the apps that use the source.
11368
+ ...(runtime.apps !== undefined ? { appsUsing: (name) => runtime.apps.appsUsing(name) } : {}),
10729
11369
  audit,
10730
11370
  actorOf,
10731
11371
  });
@@ -10778,6 +11418,17 @@ runtime = {}) {
10778
11418
  audit,
10779
11419
  actorOf,
10780
11420
  });
11421
+ // crew#372: publish a finished compose's plan as GitHub issues of a project-linked tracker (human-only, card first).
11422
+ registerProductPublishRoutes(app, {
11423
+ ...(runtime.mcpRegistryStore !== undefined ? { store: runtime.mcpRegistryStore } : {}),
11424
+ ...(runtime.dataGate !== undefined ? { pm: runtime.dataGate.pm } : {}),
11425
+ projectExists: async (id) => (await adapter.projectGet(id).catch(() => null)) !== null,
11426
+ composeOf: (runId) => runTimingIndex.composeOf(runId),
11427
+ runView: (runId) => adapter.runView(runId),
11428
+ workOutput: (unitId) => adapter.workOutput(unitId),
11429
+ audit,
11430
+ actorOf,
11431
+ });
10781
11432
  // DES-KNOWLEDGE-DATA-001 §10 (B4): profile a source into data-shape proposals, and the Knowledge map (both human-only).
10782
11433
  registerShapeRoutes(app, {
10783
11434
  ...(runtime.mcp !== undefined ? { registry: runtime.mcp } : {}),
@@ -10794,11 +11445,42 @@ runtime = {}) {
10794
11445
  : {}),
10795
11446
  ...(appsKnowledge !== undefined ? { knowledge: appsKnowledge } : {}),
10796
11447
  });
10797
- // ── The wicked-interactive bridge, reverse-proxied (DES-MERGE-001 §5.3/§7.2) ──
10798
- // Mounted BESIDE the routes above and under the same `${V}` prefix, so it inherits one
10799
- // origin, one auth hook, and one CORS posture — the whole point of slice 1.
10800
- // ONE pool, shared with the governed doc-delete route below: two pools over one root would
10801
- // race each other into starting duplicate bridges.
11448
+ const bridgeCallFor = async (projectId) => {
11449
+ const root = await projectDocsRoot(adapter, projectSettings, projectId);
11450
+ if (root === null)
11451
+ return null;
11452
+ const bridge = await interactiveBridges.ensure(root);
11453
+ return async (method, path, body, opts) => {
11454
+ const raw = Buffer.isBuffer(body);
11455
+ const res = await fetch(`http://${bridge.host}:${bridge.port}${path}`, {
11456
+ method,
11457
+ ...(body === undefined ? {} : {
11458
+ headers: { 'content-type': raw ? 'application/octet-stream' : 'application/json' },
11459
+ body: raw ? new Uint8Array(body) : JSON.stringify(body),
11460
+ }),
11461
+ // A segment upload or a render (ffmpeg) can take minutes on a loaded host.
11462
+ signal: AbortSignal.timeout(opts?.timeoutMs ?? 600_000),
11463
+ });
11464
+ let parsed = {};
11465
+ try {
11466
+ const j = await res.json();
11467
+ if (j !== null && typeof j === 'object' && !Array.isArray(j))
11468
+ parsed = j;
11469
+ }
11470
+ catch {
11471
+ parsed = {};
11472
+ }
11473
+ return { status: res.status, body: parsed };
11474
+ };
11475
+ };
11476
+ /** (studio#1140 (a)) The video tool as the chat's cut reads and Go call it: a read is quick, a recut renders (up to
11477
+ * two ffmpeg passes of 180 s each, plus the probe and writes). */
11478
+ const cutBridgeFor = async (projectId) => {
11479
+ const call = await bridgeCallFor(projectId);
11480
+ if (call === null)
11481
+ return null;
11482
+ return (method, path, body) => call(method, path, body, { timeoutMs: method === 'GET' ? 30_000 : 900_000 });
11483
+ };
10802
11484
  const interactiveBridges = runtime.interactiveBridges ??
10803
11485
  new InteractiveBridgePool({
10804
11486
  log: (m) => app.log.warn(m),
@@ -10954,7 +11636,7 @@ runtime = {}) {
10954
11636
  // Bounded by what is left of the snapshot's budget too (a slow start must not push it past 8 s):
10955
11637
  // the assembly after the infra probes keeps about 1.5 s.
10956
11638
  const clusterP = (containerFloor ? clusterReader.read(Math.min(CLUSTER_TIMEOUT_MS, left() - 1_500)) : Promise.resolve(null))
10957
- .then((read) => clusterRows(read, containerFloor, clusterStarted));
11639
+ .then((read) => clusterRows(read, containerFloor, clusterStarted, clusterReader.engine()));
10958
11640
  const infraP = Promise.all([
10959
11641
  clusterP.then((rows) => rows.gateway),
10960
11642
  brokerP,
@@ -10972,7 +11654,7 @@ runtime = {}) {
10972
11654
  tailLagMs: watchHealth?.tail_lag_ms ?? null,
10973
11655
  }),
10974
11656
  probeVault({ vault: adapter.vaultBin != null ? vaultDiagnostics(adapter.vaultBin) : null, exec: systemExec }),
10975
- diskRow(stateHome),
11657
+ diskRow(stateHome, undefined, undefined, undefined, stateHome === null ? null : (deadline) => diskStoresCache.get(stateHome, deadline)),
10976
11658
  probeSeatImages({
10977
11659
  containerFloor,
10978
11660
  clis: rosterSeatClis(),
@@ -11158,6 +11840,7 @@ runtime = {}) {
11158
11840
  gaps,
11159
11841
  infraHoldsLive: (key) => (key === 'gateway' || key === 'broker' || key === 'cluster' ? containerFloor : key === 'skills' || key === 'state_home' || key === 'disk' || key === 'daemon'),
11160
11842
  costOf: (id) => runCosts.get(id),
11843
+ engine: clusterReader.engine(),
11161
11844
  });
11162
11845
  if (typeof adapter.runEvents === 'function' && first.unresolved.length > 0) {
11163
11846
  const byId = new Map(allViews.map((v) => [v.session.id, v]));
@@ -11175,6 +11858,7 @@ runtime = {}) {
11175
11858
  gaps,
11176
11859
  infraHoldsLive: (key) => (key === 'gateway' || key === 'broker' || key === 'cluster' ? containerFloor : key === 'skills' || key === 'state_home' || key === 'disk' || key === 'daemon'),
11177
11860
  costOf: (id) => runCosts.get(id),
11861
+ engine: clusterReader.engine(),
11178
11862
  });
11179
11863
  const toReview = await toReviewP;
11180
11864
  // A run list that could not be read never reads green: the daemon row (degraded, "did not list
@@ -11312,34 +11996,7 @@ runtime = {}) {
11312
11996
  log: (m) => app.log.warn(m),
11313
11997
  });
11314
11998
  // ── A demo run's video as an editable document (the video editor re-cuts it through E1's per-doc API) ──
11315
- registerDemoDocumentRoute(app, adapter, {
11316
- bridgeFor: async (projectId) => {
11317
- const root = await projectDocsRoot(adapter, projectSettings, projectId);
11318
- if (root === null)
11319
- return null;
11320
- const bridge = await interactiveBridges.ensure(root);
11321
- return async (method, path, body) => {
11322
- const raw = Buffer.isBuffer(body);
11323
- const res = await fetch(`http://${bridge.host}:${bridge.port}${path}`, {
11324
- method,
11325
- headers: { 'content-type': raw ? 'application/octet-stream' : 'application/json' },
11326
- body: raw ? new Uint8Array(body) : JSON.stringify(body),
11327
- // A segment upload or the import's render (ffmpeg) can take minutes on a loaded host.
11328
- signal: AbortSignal.timeout(600_000),
11329
- });
11330
- let parsed = {};
11331
- try {
11332
- const j = await res.json();
11333
- if (j !== null && typeof j === 'object' && !Array.isArray(j))
11334
- parsed = j;
11335
- }
11336
- catch {
11337
- parsed = {};
11338
- }
11339
- return { status: res.status, body: parsed };
11340
- };
11341
- },
11342
- });
11999
+ registerDemoDocumentRoute(app, adapter, { bridgeFor: bridgeCallFor });
11343
12000
  // ── Project-attributed docs list (crew#472) ──
11344
12001
  // `GET /projects/:id/interactive/api/docs` relays the bridge's list and stamps each row with
11345
12002
  // the mount's `projectId` — the attribution the bridge cannot know. Same static-over-wildcard
@@ -11365,7 +12022,8 @@ runtime = {}) {
11365
12022
  sessionsDetail: () => adapter.sessionsDetail(),
11366
12023
  workOutput: (unitId) => adapter.workOutput(unitId),
11367
12024
  projectList: () => adapter.projectList(),
11368
- listRepos: () => adapter.listRepos(),
12025
+ // crew#1744: the repo search indexes each repo's remote, so it reads the same `git_url` GET /repos shows.
12026
+ listRepos: () => repoOrigins.list(() => adapter.listRepos()),
11369
12027
  listRules: () => adapter.listConformanceRules(),
11370
12028
  projectOf: (id) => projects.index.projectOf(id),
11371
12029
  runFacts: runTimingIndex,
@@ -11386,8 +12044,8 @@ runtime = {}) {
11386
12044
  log: (m) => app.log.warn(m),
11387
12045
  });
11388
12046
  registerSearchRoutes(app, search);
11389
- const runEvalsPrepare = async (input) => {
11390
- await prepareRunEvalsLaunch(input, () => runAndRecord(defaultEvalDeps, { project: null, baseline: false, id: randomUUID(), now: new Date() }), runtime.evalRunsDir);
12047
+ const runEvalsPrepare = async (input, scope = { project: null }) => {
12048
+ await prepareRunEvalsLaunch(input, () => runAndRecord(defaultEvalDeps, { project: scope.project, baseline: false, ...(scope.suites !== undefined ? { suites: scope.suites } : {}), id: randomUUID(), now: new Date() }), runtime.evalRunsDir, scope);
11391
12049
  };
11392
12050
  return { exclusive: decideExclusively, decideGate, decisions, chatRecorder, considerations, search, decorateRun, runEvalsPrepare, chatProposals, proposalLaunchers };
11393
12051
  }