@sema-agent/server 7.145.0 → 7.147.0

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 (526) hide show
  1. package/MIGRATION.md +876 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/USAGE.md +374 -99
  5. package/deploy/facts/CHANGES.json +25 -0
  6. package/deploy/facts/README.md +57 -0
  7. package/deploy/facts/lanes.json +61 -0
  8. package/deploy/facts/lanes.schema.json +57 -0
  9. package/deploy/facts/sandbox-rbac.json +113 -0
  10. package/deploy/facts/sandbox-rbac.schema.json +74 -0
  11. package/deploy/facts/sealed-key.json +9 -0
  12. package/deploy/facts/sealed-key.schema.json +52 -0
  13. package/deploy/sema-up/README.md +2 -2
  14. package/deploy/sema-up/chart/templates/_helpers.tpl +41 -0
  15. package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +47 -7
  16. package/deploy/sema-up/chart/templates/server-v4pro.yaml +9 -4
  17. package/deploy/sema-up/chart/templates/server.yaml +9 -4
  18. package/deploy/sema-up/chart/values.yaml +8 -1
  19. package/deploy/sema-up/cluster-up.sh +2 -1
  20. package/deploy/sema-up/lib/flagshape.sh +4 -0
  21. package/deploy/sema-up/lib/lanes.json +2 -5
  22. package/deploy/sema-up/sema-up.sh +12 -9
  23. package/deploy/sema-up/stack/compose.yaml +5 -4
  24. package/deploy/sema-up/stack/sema-stack-cluster.yaml +34 -17
  25. package/dist/adoption/import-limits.d.ts +6 -0
  26. package/dist/adoption/import-limits.js +7 -0
  27. package/dist/adoption/import.d.ts +62 -0
  28. package/dist/adoption/import.js +107 -0
  29. package/dist/adoption/wire.d.ts +52 -0
  30. package/dist/adoption/wire.js +9 -0
  31. package/dist/approval-ask-machine.d.ts +2 -2
  32. package/dist/approval-card.d.ts +7 -16
  33. package/dist/approval-card.js +0 -4
  34. package/dist/approval-gate-currency.d.ts +1 -1
  35. package/dist/approval-gate-currency.js +1 -1
  36. package/dist/approval-reconciler.d.ts +1 -1
  37. package/dist/approval.d.ts +3 -3
  38. package/dist/audit.js +2 -2
  39. package/dist/bench/s1/live-deps.js +3 -1
  40. package/dist/boot/crash-last.js +2 -1
  41. package/dist/boot/deployment-mods.d.ts +11 -1
  42. package/dist/boot/deployment-mods.js +15 -2
  43. package/dist/boot/device-lane.js +7 -5
  44. package/dist/boot/engine-lease.d.ts +195 -22
  45. package/dist/boot/engine-lease.js +146 -20
  46. package/dist/boot/execution-env.d.ts +5 -0
  47. package/dist/boot/execution-env.js +57 -33
  48. package/dist/boot/execution-lane.d.ts +37 -9
  49. package/dist/boot/execution-lane.js +74 -20
  50. package/dist/boot/exit-boundary.d.ts +50 -0
  51. package/dist/boot/exit-boundary.js +32 -0
  52. package/dist/boot/exit-last.d.ts +20 -4
  53. package/dist/boot/exit-last.js +23 -5
  54. package/dist/boot/governance-seams.d.ts +2 -2
  55. package/dist/boot/governance-seams.js +1 -0
  56. package/dist/boot/leader.js +1 -1
  57. package/dist/boot/memory-boundary.d.ts +11 -11
  58. package/dist/boot/memory-boundary.js +3 -3
  59. package/dist/boot/memory-consolidation.d.ts +42 -41
  60. package/dist/boot/memory-consolidation.js +26 -28
  61. package/dist/boot/org-memory.js +3 -2
  62. package/dist/boot/parked-revive-gate.d.ts +1 -1
  63. package/dist/boot/parked-revive-gate.js +1 -1
  64. package/dist/boot/reapers.d.ts +12 -4
  65. package/dist/boot/reapers.js +40 -16
  66. package/dist/boot/resolve-spec.d.ts +2 -0
  67. package/dist/boot/resolve-spec.js +126 -123
  68. package/dist/boot/retention-lane.d.ts +4 -42
  69. package/dist/boot/runner-deps.js +1 -1
  70. package/dist/boot/session-faces.d.ts +1 -0
  71. package/dist/boot/session-faces.js +11 -3
  72. package/dist/boot/shutdown.js +27 -9
  73. package/dist/boot/stage-01-config.d.ts +1 -1
  74. package/dist/boot/stage-01-config.js +7 -3
  75. package/dist/boot/stage-02-web-admin-pull.d.ts +1 -1
  76. package/dist/boot/stage-02-web-admin-pull.js +10 -8
  77. package/dist/boot/stage-03-store-backend.d.ts +2 -1
  78. package/dist/boot/stage-03-store-backend.js +2 -2
  79. package/dist/boot/stage-04-stores.d.ts +2 -1
  80. package/dist/boot/stage-05-execution-env.d.ts +4 -1
  81. package/dist/boot/stage-05-execution-env.js +6 -6
  82. package/dist/boot/stage-06-runners.d.ts +5 -2
  83. package/dist/boot/stage-06-runners.js +12 -13
  84. package/dist/boot/stage-07-capability-layer.d.ts +5 -2
  85. package/dist/boot/stage-07-capability-layer.js +7 -7
  86. package/dist/boot/stage-08-reapers.d.ts +5 -2
  87. package/dist/boot/stage-08-reapers.js +3 -3
  88. package/dist/boot/stage-09-leader.d.ts +6 -2
  89. package/dist/boot/stage-10-http-server.d.ts +6 -2
  90. package/dist/boot/stage-10-http-server.js +5 -3
  91. package/dist/boot/stores.d.ts +10 -0
  92. package/dist/boot/stores.js +53 -26
  93. package/dist/boot/web-admin.js +3 -3
  94. package/dist/boot/workflow-orchestration.d.ts +1 -1
  95. package/dist/boot/workflow-orchestration.js +2 -1
  96. package/dist/capabilities/center-plugins.d.ts +2 -0
  97. package/dist/capabilities/center-plugins.js +6 -2
  98. package/dist/capabilities/composite-members.d.ts +4 -1
  99. package/dist/capabilities/composite-members.js +4 -1
  100. package/dist/capabilities/execution-lane.d.ts +7 -7
  101. package/dist/capabilities/execution-lane.js +2 -2
  102. package/dist/capabilities/hands-lane.d.ts +1 -1
  103. package/dist/capabilities/scenarios.d.ts +34 -20
  104. package/dist/capabilities/scenarios.js +13 -9
  105. package/dist/capabilities/settings-contract.d.ts +29 -0
  106. package/dist/capabilities/settings-contract.js +14 -0
  107. package/dist/capabilities/skills.d.ts +5 -5
  108. package/dist/capability-facts.d.ts +56 -1
  109. package/dist/capability-facts.js +59 -8
  110. package/dist/center-credential-renewer.js +3 -2
  111. package/dist/checkpoint-ctx-seal-m28.d.ts +1 -1
  112. package/dist/config-catalog.js +19 -9
  113. package/dist/config-invariants.d.ts +18 -3
  114. package/dist/config-invariants.js +36 -19
  115. package/dist/config-lkg.d.ts +1 -1
  116. package/dist/config-lkg.js +5 -6
  117. package/dist/config-provider.d.ts +2 -2
  118. package/dist/config-provider.js +2 -0
  119. package/dist/config-types.d.ts +228 -185
  120. package/dist/config.d.ts +74 -6
  121. package/dist/config.js +146 -64
  122. package/dist/degenerate-instrument.js +1 -1
  123. package/dist/deleted-session-ids.d.ts +19 -0
  124. package/dist/deleted-session-ids.js +26 -0
  125. package/dist/deploy-facts.d.ts +155 -0
  126. package/dist/deploy-facts.js +95 -0
  127. package/dist/deployment-shape.d.ts +21 -12
  128. package/dist/deployment-shape.js +24 -6
  129. package/dist/device-ws-hub.d.ts +48 -3
  130. package/dist/device-ws-hub.js +48 -2
  131. package/dist/env-facts.d.ts +7 -5
  132. package/dist/env-facts.js +10 -6
  133. package/dist/error-code-family.d.ts +35 -0
  134. package/dist/error-code-family.js +26 -0
  135. package/dist/execution-config-root.d.ts +5 -5
  136. package/dist/execution-config-root.js +5 -5
  137. package/dist/execution-env-purpose.d.ts +14 -0
  138. package/dist/execution-env-purpose.js +29 -0
  139. package/dist/execution-lane-caps.d.ts +49 -86
  140. package/dist/execution-lane-caps.js +52 -62
  141. package/dist/execution-placement.d.ts +18 -2
  142. package/dist/execution-placement.js +19 -0
  143. package/dist/file-history-disclosure.d.ts +2 -2
  144. package/dist/fleet/drain-entry.d.ts +46 -3
  145. package/dist/fleet/drain-entry.js +6 -0
  146. package/dist/fleet/fleet-bus.d.ts +2 -1
  147. package/dist/fleet/serving-lease.js +3 -4
  148. package/dist/history-anchor.d.ts +22 -0
  149. package/dist/history-anchor.js +14 -0
  150. package/dist/hooks/branch-transcript.d.ts +1 -1
  151. package/dist/hooks/branch-transcript.js +1 -0
  152. package/dist/hooks/classic-stations.d.ts +25 -8
  153. package/dist/hooks/classic-stations.js +29 -3
  154. package/dist/hooks/command-spawn.d.ts +1 -4
  155. package/dist/hooks/command-spawn.js +0 -11
  156. package/dist/hooks/hook-runner.d.ts +85 -24
  157. package/dist/hooks/hook-runner.js +326 -109
  158. package/dist/hooks/hook-source.d.ts +14 -2
  159. package/dist/hooks/hook-source.js +8 -0
  160. package/dist/http/active-run-conflict.d.ts +1 -1
  161. package/dist/http/active-run-conflict.js +1 -1
  162. package/dist/http/admission.js +11 -1
  163. package/dist/http/approval-sweeps.d.ts +2 -5
  164. package/dist/http/approval-sweeps.js +3 -2
  165. package/dist/http/checkpoint-ctx.d.ts +76 -71
  166. package/dist/http/checkpoint-ctx.js +40 -40
  167. package/dist/http/claim-latency.d.ts +10 -0
  168. package/dist/http/claim-latency.js +12 -0
  169. package/dist/http/dispatch.js +19 -3
  170. package/dist/http/durable-run-leg.d.ts +5 -0
  171. package/dist/http/durable-run-leg.js +3 -1
  172. package/dist/http/execution-context.d.ts +7 -1
  173. package/dist/http/execution-context.js +13 -0
  174. package/dist/http/health-self-report.d.ts +6 -2
  175. package/dist/http/health-self-report.js +3 -2
  176. package/dist/http/memory-compliance-failure-reply.d.ts +2 -2
  177. package/dist/http/memory-compliance-failure-reply.js +5 -15
  178. package/dist/http/memory-control-plane-corrupt-reply.d.ts +25 -0
  179. package/dist/http/memory-control-plane-corrupt-reply.js +19 -0
  180. package/dist/http/memory-store-refusal-reply.d.ts +3 -3
  181. package/dist/http/memory-store-refusal-reply.js +3 -0
  182. package/dist/http/owner-access.d.ts +11 -0
  183. package/dist/http/owner-access.js +7 -4
  184. package/dist/http/principal-gate.d.ts +28 -16
  185. package/dist/http/principal-gate.js +10 -19
  186. package/dist/http/request-guards.d.ts +2 -2
  187. package/dist/http/request-guards.js +5 -5
  188. package/dist/http/resume-legs.d.ts +29 -10
  189. package/dist/http/resume-legs.js +94 -56
  190. package/dist/http/rewind-files-reply.d.ts +34 -0
  191. package/dist/http/rewind-files-reply.js +36 -0
  192. package/dist/http/route-ctx.d.ts +43 -26
  193. package/dist/http/route-table.js +4 -0
  194. package/dist/http/routes/adoption.d.ts +11 -0
  195. package/dist/http/routes/adoption.js +80 -6
  196. package/dist/http/routes/agents-roster.js +1 -0
  197. package/dist/http/routes/approvals-assistant.js +7 -26
  198. package/dist/http/routes/background.js +1 -0
  199. package/dist/http/routes/capabilities.js +12 -3
  200. package/dist/http/routes/devices.js +1 -1
  201. package/dist/http/routes/diagnostics.d.ts +9 -14
  202. package/dist/http/routes/diagnostics.js +10 -20
  203. package/dist/http/routes/engine.d.ts +31 -0
  204. package/dist/http/routes/engine.js +81 -0
  205. package/dist/http/routes/memory-bundle.js +3 -0
  206. package/dist/http/routes/memory-consolidation.js +3 -5
  207. package/dist/http/routes/memory-origin.d.ts +2 -2
  208. package/dist/http/routes/memory-origin.js +2 -4
  209. package/dist/http/routes/memory-policy.js +5 -1
  210. package/dist/http/routes/notify-wake.js +2 -1
  211. package/dist/http/routes/observability.js +3 -6
  212. package/dist/http/routes/projects.d.ts +70 -0
  213. package/dist/http/routes/projects.js +86 -0
  214. package/dist/http/routes/rules.js +30 -2
  215. package/dist/http/routes/runs.js +15 -11
  216. package/dist/http/routes/session-sync.js +39 -35
  217. package/dist/http/routes/sessions-list.d.ts +1 -1
  218. package/dist/http/routes/sessions.d.ts +7 -1
  219. package/dist/http/routes/sessions.js +108 -2
  220. package/dist/http/routes/tasks.js +32 -8
  221. package/dist/http/routes/trace-usage.js +1 -1
  222. package/dist/http/run-concurrency-cap.d.ts +86 -0
  223. package/dist/http/run-concurrency-cap.js +54 -0
  224. package/dist/http/server.d.ts +31 -14
  225. package/dist/http/server.js +29 -3
  226. package/dist/http/stored-body-replay.d.ts +12 -7
  227. package/dist/http/stored-body-replay.js +28 -5
  228. package/dist/http/wire-types.d.ts +27 -13
  229. package/dist/index.d.ts +2 -2
  230. package/dist/index.js +1 -1
  231. package/dist/instruction-source-notice.d.ts +1 -1
  232. package/dist/json-body-limit.d.ts +8 -0
  233. package/dist/json-body-limit.js +2 -0
  234. package/dist/leader/diffout.d.ts +1 -1
  235. package/dist/local-data-root.d.ts +2 -2
  236. package/dist/memory-embedder-reembed.d.ts +38 -0
  237. package/dist/memory-embedder-reembed.js +20 -0
  238. package/dist/memory-incident-sink.d.ts +0 -28
  239. package/dist/memory-incident-sink.js +5 -0
  240. package/dist/memory-operator-faces.d.ts +9 -4
  241. package/dist/memory-scope-stores.d.ts +9 -7
  242. package/dist/memory-scope-stores.js +3 -14
  243. package/dist/memory-scope.d.ts +38 -2
  244. package/dist/memory-scope.js +33 -2
  245. package/dist/memory-store-refusal.d.ts +17 -4
  246. package/dist/memory-store-refusal.js +1 -1
  247. package/dist/memory-sync-client.d.ts +2 -0
  248. package/dist/memory-sync-client.js +13 -11
  249. package/dist/memory-sync.js +1 -1
  250. package/dist/model-compat.d.ts +35 -21
  251. package/dist/model-compat.js +49 -21
  252. package/dist/model-entry-refusal.d.ts +11 -1
  253. package/dist/model-entry-refusal.js +7 -0
  254. package/dist/namespaced-rule-name.d.ts +18 -1
  255. package/dist/namespaced-rule-name.js +12 -0
  256. package/dist/net-address.d.ts +53 -0
  257. package/dist/net-address.js +111 -0
  258. package/dist/observability/fail-open.d.ts +29 -17
  259. package/dist/observability/fail-open.js +29 -17
  260. package/dist/observability/metrics.d.ts +2 -0
  261. package/dist/observability/metrics.js +2 -0
  262. package/dist/observability/secret-env-scrub.d.ts +30 -4
  263. package/dist/observability/secret-env-scrub.js +15 -3
  264. package/dist/orchestration/workflow-agent-session-index.d.ts +7 -12
  265. package/dist/orchestration/workflow-agent-session-index.js +1 -6
  266. package/dist/orchestration/workflow-completion-inbox.d.ts +26 -6
  267. package/dist/orchestration/workflow-completion-inbox.js +63 -45
  268. package/dist/orchestration/workflow-notify-journal.js +2 -3
  269. package/dist/org-delivery-gate.js +1 -1
  270. package/dist/org-memory-admission.d.ts +5 -2
  271. package/dist/org-memory-admission.js +25 -10
  272. package/dist/parked-decide.d.ts +33 -26
  273. package/dist/parked-decide.js +36 -44
  274. package/dist/peer-directory.d.ts +6 -12
  275. package/dist/peer-directory.js +5 -1
  276. package/dist/plugins/approval-ask-store-file.d.ts +10 -2
  277. package/dist/plugins/approval-ask-store-file.js +37 -4
  278. package/dist/plugins/approval-ask-store-memory.d.ts +5 -3
  279. package/dist/plugins/approval-ask-store-memory.js +11 -2
  280. package/dist/plugins/approval-ask-store-sql.d.ts +3 -0
  281. package/dist/plugins/approval-ask-store-sql.js +3 -1
  282. package/dist/plugins/blob-backend.d.ts +38 -195
  283. package/dist/plugins/blob-backend.js +33 -229
  284. package/dist/plugins/caching-session-store.d.ts +12 -5
  285. package/dist/plugins/caching-session-store.js +3 -0
  286. package/dist/plugins/checkpoint-index-columns.d.ts +1 -1
  287. package/dist/plugins/checkpoint-index-columns.js +3 -2
  288. package/dist/plugins/checkpoint-store-face.d.ts +426 -0
  289. package/dist/plugins/checkpoint-store-face.js +152 -0
  290. package/dist/plugins/device-store-sql.d.ts +2 -2
  291. package/dist/plugins/device-store-sql.js +5 -10
  292. package/dist/plugins/execution-lane-rename-m40.d.ts +20 -0
  293. package/dist/plugins/execution-lane-rename-m40.js +10 -0
  294. package/dist/plugins/execution-placement-sql.d.ts +63 -88
  295. package/dist/plugins/execution-placement-sql.js +94 -54
  296. package/dist/plugins/file-run-store.d.ts +26 -18
  297. package/dist/plugins/file-run-store.js +64 -75
  298. package/dist/plugins/fork-routing-session-store.d.ts +6 -2
  299. package/dist/plugins/fork-routing-session-store.js +2 -2
  300. package/dist/plugins/imported-layer-root-retirement.d.ts +22 -11
  301. package/dist/plugins/imported-layer-root-retirement.js +4 -8
  302. package/dist/plugins/inbox-payload-column.d.ts +14 -0
  303. package/dist/plugins/inbox-payload-column.js +13 -0
  304. package/dist/plugins/local-checkpoint-store.d.ts +7 -2
  305. package/dist/plugins/local-checkpoint-store.js +13 -8
  306. package/dist/plugins/local-data-dir-modes-m39.d.ts +48 -0
  307. package/dist/plugins/local-data-dir-modes-m39.js +182 -0
  308. package/dist/plugins/local-engine-high-water.d.ts +11 -0
  309. package/dist/plugins/local-engine-high-water.js +59 -0
  310. package/dist/plugins/local-session-store.d.ts +119 -30
  311. package/dist/plugins/local-session-store.js +156 -53
  312. package/dist/plugins/local-task-attachment-store.d.ts +2 -0
  313. package/dist/plugins/local-task-attachment-store.js +10 -11
  314. package/dist/plugins/memory-embedder-fingerprint.d.ts +33 -10
  315. package/dist/plugins/memory-embedder-fingerprint.js +52 -12
  316. package/dist/plugins/memory-embedder.d.ts +1 -1
  317. package/dist/plugins/memory-embedder.js +2 -2
  318. package/dist/plugins/memory-engine-pg.d.ts +30 -6
  319. package/dist/plugins/memory-engine-pg.js +96 -214
  320. package/dist/plugins/memory-engine-sql-apply.d.ts +130 -0
  321. package/dist/plugins/memory-engine-sql-apply.js +358 -0
  322. package/dist/plugins/memory-engine-tidb.d.ts +38 -9
  323. package/dist/plugins/memory-engine-tidb.js +99 -230
  324. package/dist/plugins/memory-key-guards.d.ts +1 -1
  325. package/dist/plugins/memory-origin-law.d.ts +3 -3
  326. package/dist/plugins/one-time-migrations.d.ts +169 -83
  327. package/dist/plugins/one-time-migrations.js +295 -235
  328. package/dist/plugins/owner-only-file-mode.d.ts +29 -0
  329. package/dist/plugins/owner-only-file-mode.js +141 -0
  330. package/dist/plugins/permission-rule-store-file.d.ts +17 -3
  331. package/dist/plugins/permission-rule-store-file.js +20 -1
  332. package/dist/plugins/pg-pool.d.ts +2 -1
  333. package/dist/plugins/pg-pool.js +12 -5
  334. package/dist/plugins/release-version.d.ts +20 -0
  335. package/dist/plugins/release-version.js +28 -0
  336. package/dist/plugins/remote-env-adb.d.ts +20 -4
  337. package/dist/plugins/remote-env-adb.js +39 -11
  338. package/dist/plugins/remote-env-e2b.d.ts +12 -3
  339. package/dist/plugins/remote-env-e2b.js +6 -4
  340. package/dist/plugins/remote-env-host.d.ts +9 -1
  341. package/dist/plugins/remote-env-host.js +6 -5
  342. package/dist/plugins/remote-env-k8s.d.ts +5 -2
  343. package/dist/plugins/remote-env-k8s.js +15 -4
  344. package/dist/plugins/remote-env-local-docker.d.ts +4 -1
  345. package/dist/plugins/remote-env-local-docker.js +3 -3
  346. package/dist/plugins/remote-env-ssh.d.ts +8 -2
  347. package/dist/plugins/remote-env-ssh.js +26 -24
  348. package/dist/plugins/remote-shell.d.ts +59 -30
  349. package/dist/plugins/remote-shell.js +175 -62
  350. package/dist/plugins/retention-declaration.d.ts +37 -0
  351. package/dist/plugins/retention-declaration.js +9 -0
  352. package/dist/plugins/retention-deployment.d.ts +126 -0
  353. package/dist/plugins/retention-deployment.js +88 -0
  354. package/dist/plugins/retention-lane-store-sql.d.ts +74 -4
  355. package/dist/plugins/retention-lane-store-sql.js +103 -1
  356. package/dist/plugins/retention-sql.d.ts +29 -0
  357. package/dist/plugins/retention-sql.js +8 -0
  358. package/dist/plugins/run-store-sql.js +2 -2
  359. package/dist/plugins/schema-consistency.d.ts +0 -6
  360. package/dist/plugins/schema-consistency.js +1 -2
  361. package/dist/plugins/schema-ensure-legs.d.ts +1 -1
  362. package/dist/plugins/schema-ensure-legs.js +13 -3
  363. package/dist/plugins/session-ext-table.d.ts +74 -0
  364. package/dist/plugins/session-ext-table.js +121 -0
  365. package/dist/plugins/session-fork.d.ts +31 -9
  366. package/dist/plugins/session-fork.js +3 -2
  367. package/dist/plugins/session-placement.d.ts +4 -2
  368. package/dist/plugins/session-row-sql.d.ts +8 -7
  369. package/dist/plugins/session-row-sql.js +15 -7
  370. package/dist/plugins/session-store-sql.d.ts +131 -0
  371. package/dist/plugins/session-store-sql.js +298 -0
  372. package/dist/plugins/session-workspace-cell.d.ts +2 -2
  373. package/dist/plugins/session-workspace-cell.js +2 -2
  374. package/dist/plugins/shared-memory-store-sql.d.ts +10 -0
  375. package/dist/plugins/shared-memory-store-sql.js +13 -13
  376. package/dist/plugins/snapshot-bucket-presence.js +1 -1
  377. package/dist/plugins/sql-driver.d.ts +23 -7
  378. package/dist/plugins/sql-driver.js +41 -8
  379. package/dist/plugins/sql-errors.d.ts +5 -2
  380. package/dist/plugins/sql-errors.js +4 -0
  381. package/dist/plugins/sql-json-column.d.ts +5 -1
  382. package/dist/plugins/store-backend.d.ts +46 -16
  383. package/dist/plugins/store-backend.js +192 -69
  384. package/dist/plugins/store-contracts.d.ts +10 -13
  385. package/dist/plugins/store-contracts.js +1 -9
  386. package/dist/plugins/store-sweep.d.ts +63 -0
  387. package/dist/plugins/store-sweep.js +48 -0
  388. package/dist/plugins/task-attachment-store.d.ts +6 -8
  389. package/dist/plugins/task-attachment-store.js +15 -10
  390. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  391. package/dist/plugins/text-column-capacity.d.ts +21 -0
  392. package/dist/plugins/text-column-capacity.js +5 -0
  393. package/dist/plugins/tidb-pool.d.ts +3 -2
  394. package/dist/plugins/tidb-pool.js +20 -32
  395. package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
  396. package/dist/prompt-screen.d.ts +6 -9
  397. package/dist/prompt-screen.js +2 -5
  398. package/dist/read-face-posture.d.ts +6 -6
  399. package/dist/read-face-posture.js +2 -2
  400. package/dist/request-value-closure.d.ts +5 -5
  401. package/dist/request-value-closure.js +1 -1
  402. package/dist/rules-consent.d.ts +48 -27
  403. package/dist/rules-consent.js +147 -23
  404. package/dist/run-cancel-context.d.ts +4 -1
  405. package/dist/run-cancel-context.js +2 -1
  406. package/dist/run-local.js +17 -13
  407. package/dist/runs.d.ts +48 -30
  408. package/dist/runs.js +27 -17
  409. package/dist/runtime-caps-resolver.d.ts +15 -8
  410. package/dist/runtime-caps-resolver.js +14 -10
  411. package/dist/sandbox-egress-policy.js +6 -11
  412. package/dist/sandbox-rbac-rules.d.ts +88 -0
  413. package/dist/sandbox-rbac-rules.js +80 -0
  414. package/dist/sealed-key-layout.d.ts +16 -0
  415. package/dist/sealed-key-layout.js +3 -0
  416. package/dist/sealed-key.js +8 -6
  417. package/dist/security.d.ts +43 -9
  418. package/dist/security.js +9 -2
  419. package/dist/sema-config-dir.js +2 -2
  420. package/dist/server-secret-env.d.ts +2 -0
  421. package/dist/service-version.d.ts +2 -1
  422. package/dist/service-version.js +2 -2
  423. package/dist/session-error-wire.d.ts +1 -1
  424. package/dist/session-incarnation.d.ts +8 -5
  425. package/dist/session-notify-door.d.ts +5 -3
  426. package/dist/session-resident-background.d.ts +110 -0
  427. package/dist/session-resident-background.js +88 -0
  428. package/dist/session-row.d.ts +1 -1
  429. package/dist/session-sync-kernel.d.ts +53 -14
  430. package/dist/session-sync-kernel.js +70 -1
  431. package/dist/session-sync.d.ts +5 -3
  432. package/dist/session-workspace.d.ts +12 -2
  433. package/dist/session-workspace.js +6 -0
  434. package/dist/sighup-idle.d.ts +9 -7
  435. package/dist/sighup-idle.js +4 -5
  436. package/dist/spec-fields.d.ts +16 -0
  437. package/dist/spec-fields.js +7 -0
  438. package/dist/store-posture.d.ts +2 -1
  439. package/dist/stored-request-env-credentials-m38.d.ts +3 -0
  440. package/dist/stored-request-env-credentials-m38.js +8 -0
  441. package/dist/stored-request-hooks-m20.d.ts +3 -2
  442. package/dist/stored-request-hooks-m20.js +19 -14
  443. package/dist/stored-request-prompt-profile-m30.d.ts +1 -1
  444. package/dist/stores-sql/blob-index-sql.d.ts +148 -0
  445. package/dist/stores-sql/blob-index-sql.js +154 -0
  446. package/dist/{plugins → stores-sql}/checkpoint-store-sql.d.ts +14 -428
  447. package/dist/{plugins → stores-sql}/checkpoint-store-sql.js +43 -220
  448. package/dist/{plugins → stores-sql}/file-history-store-sql.d.ts +23 -11
  449. package/dist/{plugins → stores-sql}/file-history-store-sql.js +23 -18
  450. package/dist/{plugins → stores-sql}/mailbox-store-sql.d.ts +2 -2
  451. package/dist/{plugins → stores-sql}/mailbox-store-sql.js +4 -4
  452. package/dist/{plugins → stores-sql}/pg-session-storage.d.ts +27 -67
  453. package/dist/{plugins → stores-sql}/pg-session-storage.js +82 -207
  454. package/dist/{plugins → stores-sql}/retention-store-sql.d.ts +123 -217
  455. package/dist/{plugins → stores-sql}/retention-store-sql.js +66 -190
  456. package/dist/{plugins → stores-sql}/roster-store-sql.d.ts +2 -2
  457. package/dist/{plugins → stores-sql}/roster-store-sql.js +1 -1
  458. package/dist/{plugins → stores-sql}/session-event-payload.d.ts +1 -1
  459. package/dist/{plugins → stores-sql}/session-event-payload.js +1 -1
  460. package/dist/stores-sql/session-policy-store-sql.d.ts +1 -1
  461. package/dist/stores-sql/session-write-hooks.d.ts +59 -0
  462. package/dist/stores-sql/session-write-hooks.js +2 -0
  463. package/dist/{plugins → stores-sql}/tidb-session-storage.d.ts +10 -11
  464. package/dist/{plugins → stores-sql}/tidb-session-storage.js +10 -21
  465. package/dist/{plugins → stores-sql}/tidb-session-store.d.ts +35 -112
  466. package/dist/{plugins → stores-sql}/tidb-session-store.js +73 -169
  467. package/dist/{plugins → stores-sql}/tool-result-store-sql.d.ts +3 -3
  468. package/dist/{plugins → stores-sql}/tool-result-store-sql.js +6 -6
  469. package/dist/stores-sql/windowed-session-storage.d.ts +56 -0
  470. package/dist/stores-sql/windowed-session-storage.js +61 -0
  471. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.d.ts +7 -12
  472. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.js +3 -8
  473. package/dist/task-a2a.d.ts +7 -1
  474. package/dist/task-a2a.js +15 -14
  475. package/dist/task-cwd.d.ts +11 -3
  476. package/dist/task-cwd.js +17 -1
  477. package/dist/task-mcp.d.ts +10 -2
  478. package/dist/task-mcp.js +13 -16
  479. package/dist/task-settings.d.ts +68 -8
  480. package/dist/task-settings.js +63 -6
  481. package/dist/tool-approval.d.ts +23 -10
  482. package/dist/tool-approval.js +10 -6
  483. package/dist/trace/core-keyset-guard.d.ts +17 -10
  484. package/dist/trace/engine-notice-wire.d.ts +1 -1
  485. package/dist/trace/engine-notice-wire.js +4 -0
  486. package/dist/trace/exit-seat.d.ts +29 -1
  487. package/dist/trace/exit-seat.js +4 -0
  488. package/dist/trace/project.d.ts +33 -16
  489. package/dist/trace/project.js +21 -9
  490. package/dist/trace/redact.d.ts +13 -2
  491. package/dist/trace/redact.js +347 -78
  492. package/dist/trace/self-minted-wire.d.ts +587 -16
  493. package/dist/trace/self-minted-wire.js +215 -9
  494. package/dist/trace/sema-provenance.d.ts +45 -41
  495. package/dist/trace/sema-provenance.js +81 -10
  496. package/dist/trace/task-notification-facets.d.ts +70 -2
  497. package/dist/trace/task-notification-facets.js +71 -1
  498. package/dist/trace/wire-projection-faces.d.ts +39 -3
  499. package/dist/trace/wire-projection-faces.js +27 -2
  500. package/dist/unread-request-members.d.ts +66 -0
  501. package/dist/unread-request-members.js +41 -0
  502. package/dist/usage-analytics.d.ts +4 -0
  503. package/dist/user-input-ledger.d.ts +2 -2
  504. package/dist/web-admin-client/apply-effective.js +22 -26
  505. package/dist/web-admin-client/candidate-gate.d.ts +35 -3
  506. package/dist/web-admin-client/candidate-gate.js +53 -5
  507. package/dist/web-admin-client/center-request.d.ts +4 -1
  508. package/dist/web-admin-client/center-request.js +2 -1
  509. package/dist/web-admin-client/effective-keys.js +0 -1
  510. package/dist/web-admin-client/facade.d.ts +1 -1
  511. package/dist/web-admin-client/http-client.d.ts +1 -0
  512. package/dist/web-admin-client/http-client.js +17 -9
  513. package/dist/web-admin-client/restart-signal.js +5 -2
  514. package/dist/web-admin-client/skills-mcp.d.ts +20 -6
  515. package/dist/web-admin-client/skills-mcp.js +26 -21
  516. package/dist/web-admin-client/types.d.ts +34 -49
  517. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +2 -2
  518. package/package.json +22 -13
  519. package/scripts/drain-check-local.mjs +8 -55
  520. package/scripts/drain-check.mysql.sql +3 -40
  521. package/scripts/drain-check.pg.sql +3 -40
  522. package/skills/update-config.md +1 -1
  523. package/wire-changes/server@7.146.0.json +3221 -0
  524. package/wire-changes/server@7.147.0.json +813 -0
  525. package/dist/approval-batch-census.d.ts +0 -27
  526. package/dist/approval-batch-census.js +0 -27
@@ -2,7 +2,9 @@ import { type LaneHomeDeployment } from "../execution-lane-caps.js";
2
2
  import { type MemoryScopeStores } from "../memory-scope-stores.js";
3
3
  import type { RestartSliceCtx } from "../web-admin-client/restart-signal.js";
4
4
  import type { MemoryConsolidationDriverConfig, ServiceConfig } from "../config-types.js";
5
- import { resolveMemoryConsolidationDriver, type ConsolidationWriteJudge, type ConsolidationWriteJudgeInput, type EngineNotice, type ConsolidationDriverRunRow, type ConsolidationRunReceipt, type MemoryConsolidationDriverDeps, type PermissionRuleStoreProvider } from "@sema-agent/core";
5
+ import { resolveMemoryConsolidationDriver, type ConsolidationWriteJudge, type ConsolidationWriteJudgeInput, type EngineNotice, type ConsolidationDriverRunRow, type ConsolidationRunReceipt, type MemoryBackend, type MemoryConsolidationDriverDeps, type MemoryGovernanceDurability, type PermissionRuleStoreProvider, type CompliancePosture, type RunMemoryConsolidationOptions } from "@sema-agent/core";
6
+ /** 合规档位座的型 = 驱动动词 `compliance.postureOf` 收的那一只(core 的座型不在包根导出面上;取动词选项的成员型,形的属主仍是 core)。 */
7
+ type CompliancePostureSeat = NonNullable<NonNullable<RunMemoryConsolidationOptions["compliance"]>["postureOf"]>;
6
8
  /**
7
9
  * 座解析的 options 形 = core 解析器交回的那只(core 7.50.0 起它**不含** `writeJudge`:判官不是模型席的一部分,由调用方在动词上带)。
8
10
  * 取解析器的返回型而不是自己写 `Omit<…>`:形的属主是 core 的解析器,本仓不持第二份。
@@ -11,7 +13,7 @@ type ConsolidationSeatOptions = ReturnType<typeof resolveMemoryConsolidationDriv
11
13
  /** D3 投影的座标签闭集。`role:<name>` 里的 name 只可能是 core 的 role 链两跳之一。 */
12
14
  export type ConsolidationSeatLabel = "explicit" | "role:consolidate" | "role:summarize";
13
15
  /** {@link buildConsolidationValveAudit} 的告警名闭集(事件名进日志 ⇒ 运维可按名过滤/告警)。 */
14
- export type ConsolidationValveWarningTag = "memory_consolidation_valve_unreachable" | "memory_consolidation_run_credential_gated";
16
+ export type ConsolidationValveWarningTag = "memory_consolidation_run_credential_gated";
15
17
  /** {@link resolveConsolidationValve} 的起服提示名闭集([ref] / [ref];事件名进日志 ⇒ 运维可按名过滤/告警)。 */
16
18
  export type ConsolidationValveNoticeTag = "memory_consolidation_default_off_no_cheap_model" | "memory_consolidation_on_main_model";
17
19
  /**
@@ -141,11 +143,12 @@ export declare function createPerScopeSingleFlight<T>(): (scope: string, run: ()
141
143
  *
142
144
  * ① **记忆引擎没接线**(`MEMORY_ENGINE=off`,或多租户形——本仓的记忆引擎只在单用户部署上装配):
143
145
  * 没有引擎就没有库可折叠,阀门是一句空话;
144
- * ② **后端不自带控制面归属**(`controlPlaneRoot`):driver 的 run 账(`distiller-runs.json`)、mint 归档
145
- * 与引擎的 consolidation gate 全住在控制面上。缺它时 core 会把控制面**回落到本进程的本地盘**
146
- * (`deriveControlPlaneDir`),而本仓是 stateless replicas ⇒ 一轮分钟级 run 的续跑账会落在某个随机
147
- * pod 的盘上,pod 重建即失,而 run 是**可续跑**设计的(重跑=整库重新 mint,真金白银)。判据与
148
- * `createMemoryComplianceFaces` 逐字同源(读的是后端的**面**,不看后端方言名);
146
+ * ② **整理状态不随后端走**(引擎对这只后端的答案 `memoryGovernanceDurability` = `"replica-local"`):driver 的 run 账
147
+ * (`distiller-runs.json`)、mint 归档与引擎的 consolidation gate 住在引擎的控制面上;后端不发布控制面时 core 会把它
148
+ * **回落到本进程的本地盘**(`deriveControlPlaneDir`),而本仓是 stateless replicas ⇒ 一轮分钟级 run 的续跑账会落在某个随机
149
+ * pod 的盘上,pod 重建即失,而 run 是**可续跑**设计的(重跑=整库重新 mint,真金白银)。判据**只问引擎的这一个答案**
150
+ * (「整理能不能开」就是它回答的那一问;不自读后端的面、不看后端方言名);部署面(合规 / 外源 / 状态 / 部署对象)问的是
151
+ * 另一件事 —— 后端发不发布控制面 —— 读 `backendOwnsControlPlane`,不读这里;
149
152
  * ③ **`MEMORY_PROVENANCE=off`**:core 的 `screenConsolidationOptions` 明写 consolidation 不能在
150
153
  * `provenance:"off"` 下开(fold law 必须铸得出 origin 标记,否则一个被标记过的输入折出来的产物会
151
154
  * **不带标记**地提交)。这一条本来就会在引擎构造期抛,提前判只为一件事:把**两根**旋钮的名字同时
@@ -164,15 +167,20 @@ export declare function assertConsolidationDriverWirable(input: ConsolidationWir
164
167
  export interface ConsolidationWiringFacts {
165
168
  /** 本部署接了记忆引擎吗(`boot/stores.ts` 的 `memoryEngine !== undefined`)。 */
166
169
  readonly memoryEngineWired: boolean;
167
- /** 记忆后端自带控制面归属吗(`typeof backend.controlPlaneRoot === "string"` 且非空)。 */
168
- readonly controlPlaneOwned: boolean;
170
+ /** 整理读写的状态随不随后端走:引擎对这只后端的答案(`memoryGovernanceDurability`,`"backend"` / `"replica-local"`)。
171
+ * 引擎契约逐字「a host that arms or reports consolidation asks here, never of a backend member it probes itself」——
172
+ * 阀门就是「整理能不能开」这一问,所以只问引擎、不自己读后端的面;部署面(合规 / 外源 / 状态 / 部署对象)问的是另一件事
173
+ * (后端发不发布控制面,`backendOwnsControlPlane`),不问这里。记忆引擎没接 ⇒ `"replica-local"`(判官先答 `no-memory-engine`)。 */
174
+ readonly governanceDurability: MemoryGovernanceDurability;
169
175
  /** 只进文案 —— 让「该去拧哪根旋钮」这句话指向该腿上**真的**有效的那一根。 */
170
176
  readonly memoryEngineBackend: ServiceConfig["memoryEngineBackend"];
171
177
  /** 部署声明的 provenance 姿态(`config.memoryProvenance`;缺席 ≡ core 缺省 `carry`)。 */
172
178
  readonly provenance?: "off" | "carry";
179
+ /** 部署的合规档位(`config.compliancePosture`;缺席 = 无档位)。否决集只经引擎的 `resolveComplianceDenies` 求(与装配三座席同一只)。 */
180
+ readonly compliancePosture?: CompliancePosture;
173
181
  }
174
- /** 「阀门若开,这台部署结构上跑不起来」的三种成因(闭集;加一种 = 下面两只穷举 switch 编译红)。 */
175
- export type ConsolidationUnwirable = "no-memory-engine" | "no-control-plane" | "provenance-off";
182
+ /** 「阀门若开,这台部署结构上跑不起来」的四种成因(闭集;加一种 = 下面两只穷举 switch 编译红)。`"replica-local"` 是引擎 `MemoryGovernanceDurability` 的那个词,逐字。 */
183
+ export type ConsolidationUnwirable = "no-memory-engine" | "replica-local" | "provenance-off" | "compliance-denied";
176
184
  /**
177
185
  * 「阀门若开,这台部署结构上跑不跑得起来」的**判官**(三臂逐条理由见 {@link assertConsolidationDriverWirable} 头注)。
178
186
  * 返回成因词;`undefined` = 跑得起来。两处读它:显式 on 的拒启(句子 = {@link unwirableRefusal}),以及出厂缺省派生
@@ -209,8 +217,8 @@ export declare function consolidationSeatBillingOf(plane: ConsolidationSeatPlane
209
217
  * (结构上跑不起来由下游 D1 三条拒启臂照拒,本判决不吞);开而座落主模型 ⇒ 开 + 一行
210
218
  * `memory_consolidation_on_main_model`(部署方显式承担,但必须知道账按主模型记)。
211
219
  * · **未设 = 出厂缺省派生**([ref] 取代 [ref] ① 的「出厂 off」实况):
212
- * 结构上跑不起来(判官 {@link consolidationDriverUnwirable} 有成因:多租户 / `MEMORY_ENGINE=off` / pg·mysql
213
- * 记忆后端 / `MEMORY_PROVENANCE=off`)⇒ **恒关、零提示、零探针** —— 派生开撞上 D1 拒启臂 = 每台配了便宜模型的
220
+ * 结构上跑不起来(判官 {@link consolidationDriverUnwirable} 有成因 —— 成因表只有 {@link ConsolidationUnwirable} 这一份;
221
+ * 配置目录说明与 USAGE 各列的同一串各有一条钉对着它)⇒ **恒关、零提示、零探针** —— 派生开撞上 D1 拒启臂 = 每台配了便宜模型的
214
222
  * 多租户 worker 升级即起不来;而配不配便宜模型它都开不了,一句指向 `MODEL_CHEAP_ID` 的提示是误导;
215
223
  * 座不落主模型({@link consolidationSeatBillingOf} = `own-model`)⇒ **开**;
216
224
  * 否则(落主模型 / 解不出)⇒ **关** + 一行 `memory_consolidation_default_off_no_cheap_model`(点名 `MODEL_CHEAP_ID`,
@@ -271,10 +279,10 @@ export declare function createConsolidationValve(input: ConsolidationValveInput
271
279
  };
272
280
  /** 阀门判决的两件输入(装配点与纯判共用一只形 —— 两个入口递的是同一组事实)。 */
273
281
  export interface ConsolidationValveInput {
274
- readonly config: Pick<ServiceConfig, "memoryConsolidationDriver" | "memoryEngineBackend" | "memoryProvenance" | "models" | "tiers" | "roles">;
275
- /** 只读两件:在不在(记忆引擎接没接线)、后端有没有控制面归属(`backendOwnsControlPlane` 只问那一个面)。 */
282
+ readonly config: Pick<ServiceConfig, "memoryConsolidationDriver" | "memoryEngineBackend" | "memoryProvenance" | "compliancePosture" | "models" | "tiers" | "roles">;
283
+ /** 只读两件:在不在(记忆引擎接没接线)、整理状态随不随后端走(引擎的 `memoryGovernanceDurability` 答)。 */
276
284
  readonly memoryEngine: {
277
- readonly backend: unknown;
285
+ readonly backend: MemoryBackend;
278
286
  } | undefined;
279
287
  }
280
288
  /**
@@ -293,38 +301,27 @@ export declare function judgeConsolidationValve(input: ConsolidationValveInput):
293
301
  unwirable: Parameters<typeof resolveConsolidationValve>[0]["unwirable"];
294
302
  };
295
303
  /**
296
- * 阀门上了场之后的**可达性**告警两条(自查 + codex 交叉复审;姿态=warn 不拒启)。
304
+ * 阀门上了场之后的**可达性**告警(自查 + codex 交叉复审;姿态=warn 不拒启)。
297
305
  *
298
- * ## 病(结构性,而且**只在**这条阀门够得着的那种部署上成立)
306
+ * ## 「没有运维」那一条为什么不在这里了
299
307
  *
300
- * consolidation 要后端自带引擎控制面归属 ⇒ 今天只有 file 记忆后端满足 ⇒ 本仓只在**单用户**形
301
- * (`REQUIRE_PRINCIPAL !== true`)上装配记忆引擎 —— 而那种部署的 `OPERATOR_PRINCIPALS` 通常是**空的**。
302
- * 没有运维名册(名单空且没有单用户声明 `OPERATOR_SINGLE_USER`)时 `explicitOperatorOk` 对任何身份恒假(「谁是 operator」的唯一读法:空名单绝不等于
303
- * 「人人都是 operator」),于是:阀门开着、启动成功、两口挂着、**每一次调用 501 `capability.operator_principals_required`**(运维面同一只拒发口;403 只留给名单非空而你不在名单上),
304
- * 能力位诚实地报 `false` —— 唯独运维不知道为什么,而他刚刚显式拧了一根写着 "on" 的旋钮。
305
- *
306
- * ## 为什么是 warn 而不是拒启(与 D1 的三条拒启臂**刻意不同档**)
307
- *
308
- * `OPERATOR_PRINCIPALS` 是**跨面共用**的部署级旋钮(adoption / retention-ops / memory-bundle /
309
- * memory-compliance / admin-drain 全在同一张名单上)。为一条阀门拒掉整台机器,比这条阀门本身的价值重;
310
- * 而那三条拒启臂拒的是「这台机器**结构上**跑不了这件事」(没有库 / 账会丢 / 折叠法铸不出标记),
311
- * 本条拒的是「配齐了但没人够得着」——后者是一次**配置遗漏**,补一行 env 即可,不该要一次重启失败来教。
312
- * 同族先例逐字:`permission_rules_lane_unavailable`(旋钮开着却上不了场 ⇒ 打一行,不拒启)。
313
- * 反过来说,**沉默**同样不行:那正是「设了但没生效」病族,而这一形连能力位都是诚实的假,唯一缺的
314
- * 就是一句把因果说清楚的话。
308
+ * 曾经还有一条「阀门够不着」告警(事件名已删,不再出现在日志里):阀门开着、两口挂着,而这台部署没有运维名册 ⇒ 两口对谁都 501。
309
+ * 它的在场条件今天在服务腿上不可达,前提链三环:① 显式开得起来的阀门要 file 记忆后端(SQL 两只孪生不发布控制面 ⇒ 第 4 段的
310
+ * {@link assertConsolidationDriverWirable} 拒启),而 file 记忆引擎只在单用户形上装配(`fileMemoryPlaneFor`);② 单用户形过了起服第 1 段就一定有运维
311
+ * (不变量 `operator-declaration-required`:`OPERATOR_SINGLE_USER=true` 或具名名单,都没有 ⇒ 第 1 段早拒;装运维面的兜底座 `createHttpServer` 同判);
312
+ * ③ 本函数的唯一调用点在服务腿第 6 段。读一个不可能状态的告警是死臂,随那条不变量一起退役(钉:`test/operator-declaration-required.test.ts` ⑥,
313
+ * 前提链每环一格,任何一环将来不成立 ⇒ 那一格红)。
315
314
  *
316
315
  * ## 只审**显式**开的阀门([ref] / [ref] 起)
317
316
  *
318
- * 两条告警的前提都是「运维**显式**拧了 on」(上面那句原话)——它们是一次**表态**够不着的诊断。出厂缺省**派生**开的
319
- * 那台(配了便宜模型的单用户部署)没有表态可审:引擎面的自动整理照跑(不走这两个口),手动口是一件它没要过的东西。
320
- * 照审的后果是每一台这样的部署升级后每次起服多两行 warn,点名一根它从没设过的 `MEMORY_CONSOLIDATION_DRIVER=on`,
321
- * 教它去配一个它不需要的操作面。判据读阀门判决的 `source`,不读表态原词(判决是阀门开关的唯一属主)。
317
+ * 告警的前提是「运维**显式**拧了 on」——它是一次**表态**够不着的诊断。出厂缺省**派生**开的那台(配了便宜模型的单用户部署)
318
+ * 没有表态可审:引擎面的自动整理照跑(不走手动口),手动口是一件它没要过的东西。照审的后果是每一台这样的部署升级后每次起服
319
+ * 多一行 warn,点名一根它从没设过的 `MEMORY_CONSOLIDATION_DRIVER=on`,教它去配一个它不需要的操作面。判据读阀门判决的 `source`,
320
+ * 不读表态原词(判决是阀门开关的唯一属主)。
322
321
  */
323
322
  export declare function buildConsolidationValveAudit(input: {
324
323
  /** 阀门判决({@link resolveConsolidationValve} 的 `enabled` + `source`)。 */
325
324
  valve: Pick<ConsolidationValve, "enabled" | "source">;
326
- /** 这台部署有没有运维名册(`operatorRosterPresent`:名单非空 ∨ 单用户声明)—— 判据不在本函数里另写一份。 */
327
- operatorRosterPresent: boolean;
328
325
  /** 这台部署配了任何一把 service 凭证吗(`config.authToken` 或 `config.authTokens` 非空)。 */
329
326
  hasServiceAuth: boolean;
330
327
  /** 本地开发的显式逃生口(`ALLOW_UNAUTHED_WRITES=true`)。 */
@@ -459,8 +456,8 @@ export interface MemoryConsolidationFaces {
459
456
  /** 跑(或**续跑**)一轮。core 的 run 行是持久的:同一 scope 上有 pending run 时本调用 CONTINUE 它
460
457
  * (同一 plan 缓存、同一 force requestId、零新 mint)—— 所以这一口对**重试安全**。 */
461
458
  run(scope: string): Promise<ConsolidationRunReceipt>;
462
- /** 该 scope 最近一次 driver run 的账(`undefined` = 从没跑过 —— 诚实缺席,不编一个空壳)。 */
463
- lastRun(scope: string): ConsolidationDriverRunRow | undefined;
459
+ /** 该 scope 最近一次 driver run 的账(`undefined` = 从没跑过 —— 诚实缺席,不编一个空壳)。core 7.63.0([ref])起经引擎的治理店座读、异步。 */
460
+ lastRun(scope: string): Promise<ConsolidationDriverRunRow | undefined>;
464
461
  }
465
462
  /**
466
463
  * 在**记忆作用域店**上建 consolidation 操作面。命名照 CLAUDE.md 工厂律:返回带行为的活对象 ⇒ `create*`。
@@ -506,6 +503,10 @@ export declare function createMemoryConsolidationFaces(stores: MemoryScopeStores
506
503
  * 应用时拒 = 引擎在驱动里铸的 `memory.consolidation_incomplete`;早问拒 = 驱动抛出的拒绝经引擎导出的投递口(`deliverWriteRefusal`)转成的
507
504
  * `memory.consolidation_refused`(本仓不读通告名、不自铸通告形)。 */
508
505
  onNotice?: (notice: EngineNotice) => void;
506
+ /** core 7.63.0([ref]):部署的合规档位座(装配层给 `RunnerDeps.compliancePostureResolver` 那**同一只**;`undefined` = 部署没有档位)。
507
+ * 必填键 —— 缺席不能被读成「没有档位」:驱动动词每一轮先拿它问**层属主**的档位(契约 = {@link memoryScopeContractOf}`([scope])`,
508
+ * 与会话铸 spec 同一只),否决 ⇒ 在写判官、任何读、任何模型调用之前拒 `config.compliance_denied`;自动整理腿读同一只座。 */
509
+ postureOf: CompliancePostureSeat | undefined;
509
510
  }): MemoryConsolidationFaces;
510
511
  export {};
511
512
  //# sourceMappingURL=memory-consolidation.d.ts.map
@@ -1,12 +1,11 @@
1
1
  import { redactSecrets } from "../trace/redact.js";
2
2
  import { recordFailOpen } from "../observability/fail-open.js";
3
- import { buildOperatorRosterWayOut } from "../http/principal-gate.js";
4
- import { memoryMountRootOf } from "../memory-scope.js";
3
+ import { memoryMountRootOf, memoryScopeContractOf } from "../memory-scope.js";
5
4
  import { executionLaneHomeDir } from "../execution-lane-caps.js";
6
5
  import { DEFAULT_MODEL_REF, resolveMainModel } from "../model-select.js";
7
6
  import { captureRecordStoreOf } from "../memory-operator-faces.js";
8
- import { backendOwnsControlPlane, memoryStoreForRequest } from "../memory-scope-stores.js";
9
- import { createConsolidationWriteJudge, deliverWriteRefusal, expandTiers, MemoryEngine, modelOriginOf, readConsolidationDriverRun, resolveMemoryConsolidationDriver, runMemoryConsolidationDriver, } from "@sema-agent/core";
7
+ import { memoryStoreForRequest } from "../memory-scope-stores.js";
8
+ import { createConsolidationWriteJudge, deliverWriteRefusal, expandTiers, MemoryEngine, memoryGovernanceDurability, modelOriginOf, resolveComplianceDenies, resolveMemoryConsolidationDriver, runMemoryConsolidationDriver, } from "@sema-agent/core";
10
9
  import { seatText } from "../trace/exit-seat.js";
11
10
  export function resolveConsolidationDriverSeat(deps) {
12
11
  let options;
@@ -97,10 +96,12 @@ export function assertConsolidationDriverWirable(input) {
97
96
  export function consolidationDriverUnwirable(input) {
98
97
  if (!input.memoryEngineWired)
99
98
  return "no-memory-engine";
100
- if (!input.controlPlaneOwned)
101
- return "no-control-plane";
99
+ if (input.governanceDurability !== "backend")
100
+ return input.governanceDurability;
102
101
  if (input.provenance === "off")
103
102
  return "provenance-off";
103
+ if (input.compliancePosture !== undefined && resolveComplianceDenies(input.compliancePosture).has("memory_consolidation"))
104
+ return "compliance-denied";
104
105
  return undefined;
105
106
  }
106
107
  function unwirableRefusal(code, facts) {
@@ -110,18 +111,23 @@ function unwirableRefusal(code, facts) {
110
111
  `— there is no library to fold, and the two admin endpoints would answer over an engine that does not exist. ` +
111
112
  `(The engine is wired only on single-user deployments with MEMORY_ENGINE on; a multi-tenant worker keeps memory ` +
112
113
  `dark by design.) Wire the memory engine, or set MEMORY_CONSOLIDATION_DRIVER=off.`);
113
- case "no-control-plane":
114
- return (`MEMORY_CONSOLIDATION_DRIVER=on arms the memory-consolidation valve, but the wired memory backend ` +
115
- `(MEMORY_ENGINE_BACKEND=${facts.memoryEngineBackend}) does NOT own an engine control plane (controlPlaneRoot) — ` +
116
- `core would derive one on THIS replica's local disk, and a consolidation run's resumable account would die with ` +
117
- `the pod (a lost run re-mints the whole library at full model cost on the next attempt). The file memory backend ` +
118
- `owns a control plane; the pg/mysql memory backends do not. Set MEMORY_ENGINE_BACKEND=file, or set ` +
114
+ case "replica-local":
115
+ return (`MEMORY_CONSOLIDATION_DRIVER=on arms the memory-consolidation valve, but the memory engine answers "replica-local" for the ` +
116
+ `wired memory backend (MEMORY_ENGINE_BACKEND=${facts.memoryEngineBackend}) — a consolidation run's state would live on THIS ` +
117
+ `replica's local disk instead of riding the backend, and its resumable account would die with the pod (a lost run ` +
118
+ `re-mints the whole library at full model cost on the next attempt). The file memory backend keeps that state with the ` +
119
+ `backend (the engine answers "backend"); the pg/mysql memory backends do not. Set MEMORY_ENGINE_BACKEND=file, or set ` +
119
120
  `MEMORY_CONSOLIDATION_DRIVER=off.`);
120
121
  case "provenance-off":
121
122
  return (`MEMORY_CONSOLIDATION_DRIVER=on is incompatible with MEMORY_PROVENANCE=off — core refuses to enable consolidation ` +
122
123
  `under provenance "off" because the fold law must be able to MINT origin markers (a marked input's product would ` +
123
124
  `otherwise commit unmarked, i.e. the fold would launder provenance). Set MEMORY_PROVENANCE=carry (or unset it, ` +
124
125
  `which is the same posture), or set MEMORY_CONSOLIDATION_DRIVER=off.`);
126
+ case "compliance-denied":
127
+ return (`MEMORY_CONSOLIDATION_DRIVER=on arms the memory-consolidation valve, but this deployment's compliance posture ` +
128
+ `(COMPLIANCE_PROFILE=${facts.compliancePosture?.profile ?? "?"}, with COMPLIANCE_ADDITIONAL_DENIES) denies memory_consolidation — the engine ` +
129
+ `refuses every consolidation run before it reads, claims or calls a model (config.compliance_denied), on the admin endpoint and after ` +
130
+ `a settle alike. Set MEMORY_CONSOLIDATION_DRIVER=off, or run a posture that does not deny memory_consolidation.`);
125
131
  default: {
126
132
  const unreachable = code;
127
133
  throw new Error(`unhandled consolidation unwirable code: ${String(unreachable)}`);
@@ -132,10 +138,12 @@ function unwirableClause(code, facts) {
132
138
  switch (code) {
133
139
  case "no-memory-engine":
134
140
  return "no memory engine is wired here (multi-tenant posture, or MEMORY_ENGINE=off), so there is no library to fold";
135
- case "no-control-plane":
136
- return `the memory backend (MEMORY_ENGINE_BACKEND=${facts.memoryEngineBackend}) owns no engine control plane, so a consolidation run could not keep its account`;
141
+ case "replica-local":
142
+ return `the memory engine answers "replica-local" for the memory backend (MEMORY_ENGINE_BACKEND=${facts.memoryEngineBackend}), so a consolidation run's state would not outlive its replica and could not keep its account`;
137
143
  case "provenance-off":
138
144
  return "MEMORY_PROVENANCE=off, and consolidation needs provenance to mint origin markers";
145
+ case "compliance-denied":
146
+ return "the deployment's compliance posture (COMPLIANCE_PROFILE / COMPLIANCE_ADDITIONAL_DENIES) denies memory_consolidation, so the engine refuses every run";
139
147
  default: {
140
148
  const unreachable = code;
141
149
  throw new Error(`unhandled consolidation unwirable code: ${String(unreachable)}`);
@@ -194,9 +202,10 @@ export function judgeConsolidationValve(input) {
194
202
  const { config, memoryEngine } = input;
195
203
  const wiring = {
196
204
  memoryEngineWired: memoryEngine !== undefined,
197
- controlPlaneOwned: backendOwnsControlPlane(memoryEngine?.backend),
205
+ governanceDurability: memoryEngine !== undefined ? memoryGovernanceDurability(memoryEngine.backend) : "replica-local",
198
206
  memoryEngineBackend: config.memoryEngineBackend,
199
207
  ...(config.memoryProvenance !== undefined ? { provenance: config.memoryProvenance } : {}),
208
+ ...(config.compliancePosture !== undefined ? { compliancePosture: config.compliancePosture } : {}),
200
209
  };
201
210
  const code = consolidationDriverUnwirable(wiring);
202
211
  const unwirable = code !== undefined ? { code, facts: wiring } : undefined;
@@ -269,18 +278,6 @@ export function buildConsolidationValveAudit(input) {
269
278
  if (!input.valve.enabled || input.valve.source !== "explicit")
270
279
  return { warnings: [] };
271
280
  const warnings = [];
272
- if (!input.operatorRosterPresent) {
273
- warnings.push({
274
- tag: "memory_consolidation_valve_unreachable",
275
- detail: "MEMORY_CONSOLIDATION_DRIVER=on armed the consolidation valve and both admin endpoints are mounted, but " +
276
- "this worker has no operator: OPERATOR_PRINCIPALS is EMPTY and OPERATOR_SINGLE_USER is not set — an empty operator list means NO ONE " +
277
- "is an operator (it deliberately does not mean 'everyone'), so POST /v1/admin/memory/consolidation/run and GET /v1/admin/memory/consolidation " +
278
- "answer 501 capability.operator_principals_required to every caller and capabilities.memoryConsolidationDriver reports false. " +
279
- `To fix: ${buildOperatorRosterWayOut()}. With OPERATOR_PRINCIPALS, callers must send a listed principal in the configured principal header; a single-user declaration needs no principal. ` +
280
- "(Not a startup refusal: the operator roster is shared by every operator " +
281
- "endpoint on this worker, so one valve must not decide whether the whole worker starts.)",
282
- });
283
- }
284
281
  if (!input.hasServiceAuth && !input.allowUnauthedWrites) {
285
282
  warnings.push({
286
283
  tag: "memory_consolidation_run_credential_gated",
@@ -363,6 +360,7 @@ export function createMemoryConsolidationFaces(stores, input) {
363
360
  const receipt = await runMemoryConsolidationDriver(engineOf(scope), scope, {
364
361
  ...input.seat.options,
365
362
  writeJudge: input.writeJudge,
363
+ compliance: { ...(input.postureOf !== undefined ? { postureOf: input.postureOf } : {}), scopeContract: memoryScopeContractOf([scope]) },
366
364
  ...(input.onNotice !== undefined ? { onNotice: input.onNotice } : {}),
367
365
  }).catch((err) => {
368
366
  deliverWriteRefusal(err, scope, input.onNotice);
@@ -373,7 +371,7 @@ export function createMemoryConsolidationFaces(stores, input) {
373
371
  }
374
372
  return receipt;
375
373
  }),
376
- lastRun: (scope) => readConsolidationDriverRun(engineOf(scope).controlPlaneRoot, scope),
374
+ lastRun: (scope) => engineOf(scope).readConsolidationDriverRun(scope),
377
375
  };
378
376
  }
379
377
  //# sourceMappingURL=memory-consolidation.js.map
@@ -8,7 +8,7 @@ function collectDeploymentOrgScopes(config) {
8
8
  scopes.add(config.memoryScope);
9
9
  if (config.requirePrincipal !== true) {
10
10
  for (const project of Object.values(config.projects)) {
11
- for (const s of project.defaultScopes ?? [])
11
+ for (const s of project.defaultScopes)
12
12
  if (s.startsWith(ORG_PREFIX))
13
13
  scopes.add(s);
14
14
  }
@@ -31,6 +31,7 @@ export function createOrgMemoryAdmissionWiring(opts) {
31
31
  fetchSection: (principal) => fetchPrincipalOrgMemory({ baseUrl: centerLeg.baseUrl, credential }, principal, fetch, centerLeg.worker),
32
32
  grantTtlMs: config.memoryOrgGrantTtlMs,
33
33
  unavailableBackoffMs: config.memoryOrgUnavailableBackoffMs,
34
+ logger,
34
35
  })).now;
35
36
  return { lookup: (principal) => directoryNow().lookup(principal) };
36
37
  })()
@@ -44,7 +45,7 @@ export function createOrgMemoryAdmissionWiring(opts) {
44
45
  const memoryPlaneLive = config.memoryEngineEnabled && config.memoryEngineBackend !== "file";
45
46
  if (directory === undefined && config.requirePrincipal === true && memoryPlaneLive) {
46
47
  const orgProjects = Object.entries(config.projects)
47
- .filter(([, p]) => (p.defaultScopes ?? []).some((s) => s.startsWith(ORG_PREFIX)))
48
+ .filter(([, p]) => p.defaultScopes.some((s) => s.startsWith(ORG_PREFIX)))
48
49
  .map(([id]) => id);
49
50
  if (orgProjects.length > 0) {
50
51
  throw new Error(`multi-tenant deployment has org: keys in projects[${orgProjects.join(", ")}].defaultScopes but NO org-memory directory source ` +
@@ -6,7 +6,7 @@ import { type SandboxPathEnvSlots } from "./deferred-sandbox-path-env.js";
6
6
  import type { ApprovalExemptionStore } from "../plugins/approval-exemption-store.js";
7
7
  /** 本腿读的配置切面(`ServiceConfig` 结构满足)。两个构造口各自的切面 + lane 判别式读的 `remoteExec`。 */
8
8
  export interface ParkedReviveGateConfigView extends DeploymentGovernanceConfigView, ApprovalBaselineConfigView {
9
- readonly remoteExec?: ServiceConfig["remoteExec"];
9
+ readonly remoteExec: ServiceConfig["remoteExec"];
10
10
  /** [ref]④:`executionLaneHomeDir` 读的运维声明(切面必须点名本腿消费的每一个字段,否则窄视图字面量会静默丢掉旋钮)。 */
11
11
  readonly remoteExecHomeDir?: ServiceConfig["remoteExecHomeDir"];
12
12
  /** host 腿裁决 env 的 cwd 占位根(见下方 `hostGateCwd`)。 */
@@ -24,7 +24,7 @@ export function createParkedReviveInheritedGate(deps) {
24
24
  env: new DeferredSandboxPathEnv({
25
25
  sessionId: row.sessionId,
26
26
  slots,
27
- logger: { warn: (event, fields) => logger.warn(event, { ...(fields ?? {}), lane: config.remoteExec?.provider, leg: "parked_revive" }) },
27
+ logger: { warn: (event, fields) => logger.warn(event, { ...(fields ?? {}), lane: config.remoteExec.provider, leg: "parked_revive" }) },
28
28
  }),
29
29
  ...homeBase,
30
30
  }
@@ -22,7 +22,8 @@ import type { Metrics } from "../observability/metrics.js";
22
22
  import type { WorkflowNotifyGate, WorkflowNotifyJournalStore } from "../orchestration/workflow-notify-journal.js";
23
23
  import type { TaskAttachmentStore } from "../plugins/task-attachment-store.js";
24
24
  import type { FileHistoryErasureFace } from "../file-history-capture.js";
25
- import type { ApprovalNonceStore, CheckpointStoreFull, CostQuotaStore, ImageBake, RateLimiterStore, ServiceWorkflowJournalStore, StoreBackend, ToolResultStoreFull } from "../plugins/store-backend.js";
25
+ import type { ApprovalNonceStore, CheckpointStoreFull, CostQuotaStore, ImageBake, RateLimiterStore, StoreBackend } from "../plugins/store-backend.js";
26
+ import { type StoreSweep, type StoreSweepLeg } from "../plugins/store-sweep.js";
26
27
  import type { ToolApprovalCoordinator } from "../tool-approval.js";
27
28
  import type { ParkCommitWatch } from "../plugins/park-commit-watch.js";
28
29
  import { type SandboxPodReaper } from "../plugins/k8s-pod-reaper.js";
@@ -56,6 +57,14 @@ export interface ThrottledReaperCatch {
56
57
  * survives across ticks — a fresh instance per tick would never accumulate past 1.
57
58
  */
58
59
  export declare function createThrottledReaperCatch(name: string, logger: Logger, threshold?: number): ThrottledReaperCatch;
60
+ /**
61
+ * 维护 tick 里调后端按龄清扫动词的那一拍。逐腿上报:失败腿的原因只进那条腿的节流告警;成功腿先计数、再清连败(计数抛也记那条腿的失败)。
62
+ * 动词整只拒(不是 {@link StoreSweepError} 的逐腿形)⇒ 每条腿各记一次失败。永不拒(本拍的失败全由节流告警接住)。
63
+ */
64
+ export declare function runStoreSweepLeg(sweep: StoreSweep, nowMs: number, report: {
65
+ readonly guards: Readonly<Record<StoreSweepLeg, ThrottledReaperCatch>>;
66
+ readonly counted: (leg: StoreSweepLeg, removed: number) => void;
67
+ }): Promise<void>;
59
68
  /** [ref] —— 维护 tick 真正消费的那**一手**(窄口;理由见 `ReapersCtx.permissionRuleStores`)。
60
69
  * 可选成员:File 车道没有这一面(追加日志的压实是另一件事,如实登记在 `rules-consent.ts` 的
61
70
  * `PermissionRuleStoreBundle.reapExpired` 注里),缺席 ⇒ 本腿零调用。 */
@@ -75,7 +84,8 @@ export interface ReapersCtx {
75
84
  parkCommits: ParkCommitWatch | undefined;
76
85
  rateLimiter: RateLimiter | RateLimiterStore | undefined;
77
86
  costQuota: CostQuota | CostQuotaStore | undefined;
78
- toolResultStore: ToolResultStoreFull | undefined;
87
+ /** 本后端的按龄清扫动词(`plugins/store-sweep.ts`;腿 = 工具结果 / 名册,组合点 `boot/stores.ts`,界每次清扫现读)。tick 只调它,不逐店探按龄删的方法。 */
88
+ storeSweep: StoreSweep;
79
89
  /** [ref]:文件历史的**擦除脸**(后端在即在,与 `FILE_HISTORY_CAPTURE` 无关)—— 本段只用它的孤儿 blob GC。 */
80
90
  fileHistoryErasure: FileHistoryErasureFace | undefined;
81
91
  taskAttachmentStore: TaskAttachmentStore | undefined;
@@ -84,10 +94,8 @@ export interface ReapersCtx {
84
94
  workflowNotifyGate: WorkflowNotifyGate | undefined;
85
95
  /** [ref]/[ref] recover 的两半 opts(boot 与周期扫描共用,单点合成在 workflow-orchestration)。 */
86
96
  workflowRecoverOpts: Parameters<WorkflowNotifyGate["recover"]>[0];
87
- workflowJournalStore: ServiceWorkflowJournalStore | undefined;
88
97
  sqlWorkflowRunStore: WorkflowRunStore | undefined;
89
98
  workflowNotifyJournal: WorkflowNotifyJournalStore | undefined;
90
- rosterStore: RunnerDeps["rosterStore"];
91
99
  backgroundAgentStore: RunnerDeps["backgroundAgentStore"];
92
100
  mailboxStore: RunnerDeps["mailboxStore"];
93
101
  /** [ref] 车6:流内审批撤卡帧的投递口(收敛器/孤儿代打腿产出的帧经它反查 broker 的活连接;[ref] 起
@@ -1,6 +1,7 @@
1
1
  import { Runner, defaultTaskRegistry } from "@sema-agent/core";
2
2
  import { sweepStaleScratchpads } from "../env-facts.js";
3
3
  import { CostQuota } from "../observability/cost-quota.js";
4
+ import { STORE_SWEEP_LEGS, StoreSweepError } from "../plugins/store-sweep.js";
4
5
  import { isAdoptionQuiescing, trackMaintenanceLeg } from "../adoption/quiesce.js";
5
6
  import { createApprovalReconciler } from "../approval-reconciler.js";
6
7
  import { createE2bOrphanSandboxProvider, reclaimOrphanE2bSandboxes, E2B_ORPHAN_GRACE_MS } from "../plugins/e2b-orphan-reclaim.js";
@@ -33,6 +34,32 @@ export function createThrottledReaperCatch(name, logger, threshold = REAPER_FAIL
33
34
  },
34
35
  };
35
36
  }
37
+ export function runStoreSweepLeg(sweep, nowMs, report) {
38
+ const settle = (receipt, failed) => {
39
+ for (const leg of STORE_SWEEP_LEGS) {
40
+ if (failed.has(leg)) {
41
+ report.guards[leg].onError(failed.get(leg));
42
+ continue;
43
+ }
44
+ try {
45
+ report.counted(leg, receipt[leg]);
46
+ report.guards[leg].onSuccess();
47
+ }
48
+ catch (err) {
49
+ report.guards[leg].onError(err);
50
+ }
51
+ }
52
+ };
53
+ return Promise.resolve()
54
+ .then(() => sweep.sweep({ nowMs }))
55
+ .then((receipt) => settle(receipt, new Map()), (err) => {
56
+ if (err instanceof StoreSweepError)
57
+ settle(err.receipt, err.failed);
58
+ else
59
+ for (const leg of STORE_SWEEP_LEGS)
60
+ report.guards[leg].onError(err);
61
+ });
62
+ }
36
63
  export function createPlacementAwareReapSessions(deps) {
37
64
  const { host, routed } = deps;
38
65
  const listPlaced = typeof host?.listPlaced === "function" ? host.listPlaced.bind(host) : undefined;
@@ -59,7 +86,7 @@ export function createPlacementAwareReapSessions(deps) {
59
86
  };
60
87
  }
61
88
  export function startReapers(ctx) {
62
- const { config, logger, metrics, localRoot, backend, subRunner, runStore, checkpointStore, parkCommits, rateLimiter, costQuota, toolResultStore, fileHistoryErasure, taskAttachmentStore, imageBakes, worktreeReap, workflowNotifyGate, workflowRecoverOpts, workflowJournalStore, sqlWorkflowRunStore, workflowNotifyJournal, rosterStore, backgroundAgentStore, mailboxStore, toolApproval, permissionRuleStores, approvalNonceStore, getRunDenySweep, userInputLedger, approvalAskAudit, sandboxPodReaper, } = ctx;
89
+ const { config, logger, metrics, localRoot, backend, subRunner, runStore, checkpointStore, parkCommits, rateLimiter, costQuota, storeSweep, fileHistoryErasure, taskAttachmentStore, imageBakes, worktreeReap, workflowNotifyGate, workflowRecoverOpts, sqlWorkflowRunStore, workflowNotifyJournal, backgroundAgentStore, mailboxStore, toolApproval, permissionRuleStores, approvalNonceStore, getRunDenySweep, userInputLedger, approvalAskAudit, sandboxPodReaper, } = ctx;
63
90
  const leg = (p) => {
64
91
  if (p !== undefined)
65
92
  trackMaintenanceLeg(p);
@@ -70,7 +97,7 @@ export function startReapers(ctx) {
70
97
  logger.info("reaper_swept", { metric, ...labels, count: n });
71
98
  }
72
99
  };
73
- const e2bOrphanProvider = config.remoteExec?.provider === "e2b" && config.remoteExec.orphanReclaim !== false
100
+ const e2bOrphanProvider = config.remoteExec.provider === "e2b" && config.remoteExec.orphanReclaim !== false
74
101
  ? createE2bOrphanSandboxProvider({ apiKey: config.remoteExec.apiKey })
75
102
  : undefined;
76
103
  let e2bOrphanLastRunMs = Date.now() - E2B_ORPHAN_GRACE_MS;
@@ -91,7 +118,16 @@ export function startReapers(ctx) {
91
118
  const runDenySweepGuard = createThrottledReaperCatch("run_deny_sweep", logger);
92
119
  const runsReapSuspendedGuard = createThrottledReaperCatch("runs_reap_suspended", logger);
93
120
  const checkpointReapCtxGuard = createThrottledReaperCatch("checkpoint_reap_ctx", logger);
94
- const toolResultReapGuard = createThrottledReaperCatch("tool_result_reap", logger);
121
+ const storeSweepGuards = {
122
+ "roster-aged": createThrottledReaperCatch("roster_reap_older_than", logger),
123
+ "tool-results-aged": createThrottledReaperCatch("tool_result_reap", logger),
124
+ "workflow-journal-expired": createThrottledReaperCatch("workflow_journal_reap_expired", logger),
125
+ };
126
+ const storeSweepCount = {
127
+ "roster-aged": reapCount("roster_rows_reaped_total", {}),
128
+ "tool-results-aged": undefined,
129
+ "workflow-journal-expired": undefined,
130
+ };
95
131
  const fileHistorySweepOrphanBlobsGuard = createThrottledReaperCatch("file_history_sweep_orphan_blobs", logger);
96
132
  const legacySnapshotBlobSweepGuard = createThrottledReaperCatch("legacy_snapshot_blob_sweep", logger);
97
133
  const attachmentReapUnboundGuard = createThrottledReaperCatch("attachment_reap_unbound", logger);
@@ -99,11 +135,9 @@ export function startReapers(ctx) {
99
135
  const imageBakesReapStaleGuard = createThrottledReaperCatch("image_bakes_reap_stale", logger);
100
136
  const worktreeReapGuard = createThrottledReaperCatch("worktree_reap", logger);
101
137
  const workflowNotifyRecoverGuard = createThrottledReaperCatch("workflow_notify_recover", logger);
102
- const workflowJournalReapExpiredGuard = createThrottledReaperCatch("workflow_journal_reap_expired", logger);
103
138
  const workflowRunReapAllScopesGuard = createThrottledReaperCatch("workflow_run_reap_all_scopes", logger);
104
139
  const workflowNotifyJournalReapAckedGuard = createThrottledReaperCatch("workflow_notify_journal_reap_acked", logger);
105
140
  const bgAgentsReapGuard = createThrottledReaperCatch("bg_agents_reap", logger);
106
- const rosterReapOlderThanGuard = createThrottledReaperCatch("roster_reap_older_than", logger);
107
141
  const leaderRunStaleGuard = createThrottledReaperCatch("leader_run_reap_stale", logger);
108
142
  const leaderRunStore = config.leaderEnabled ? backend?.leaderRun?.() : undefined;
109
143
  const scratchpadSweepStaleGuard = createThrottledReaperCatch("scratchpad_sweep_stale", logger);
@@ -244,10 +278,7 @@ export function startReapers(ctx) {
244
278
  rateLimiter?.sweep();
245
279
  if (costQuota instanceof CostQuota)
246
280
  costQuota.reap();
247
- const reapToolResults = toolResultStore?.reap?.bind(toolResultStore);
248
- leg(reapToolResults && Promise.resolve()
249
- .then(() => reapToolResults(Date.now(), { maxAgeMs: config.toolResultTtlSec * 1000 }))
250
- .then(() => toolResultReapGuard.onSuccess(), toolResultReapGuard.onError));
281
+ leg(runStoreSweepLeg(storeSweep, Date.now(), { guards: storeSweepGuards, counted: (l, n) => storeSweepCount[l]?.(n) }));
251
282
  leg(fileHistoryErasure
252
283
  ?.sweepOrphanBlobs?.()
253
284
  .then(() => fileHistorySweepOrphanBlobsGuard.onSuccess(), fileHistorySweepOrphanBlobsGuard.onError));
@@ -290,9 +321,6 @@ export function startReapers(ctx) {
290
321
  leg(workflowNotifyGate
291
322
  ?.recover(workflowRecoverOpts)
292
323
  .then(() => workflowNotifyRecoverGuard.onSuccess(), workflowNotifyRecoverGuard.onError));
293
- leg(workflowJournalStore
294
- ?.reapExpired?.(Date.now(), config.workflowJournalRetentionMs)
295
- .then(() => workflowJournalReapExpiredGuard.onSuccess(), workflowJournalReapExpiredGuard.onError));
296
324
  if (!wfRunReapInFlight) {
297
325
  const sweep = sqlWorkflowRunStore?.reapAllScopes?.(Date.now(), { maxAgeMs: config.workflowRunRetentionMs });
298
326
  if (sweep) {
@@ -311,10 +339,6 @@ export function startReapers(ctx) {
311
339
  .then(() => bgAgentsReapGuard.onSuccess(), bgAgentsReapGuard.onError)
312
340
  .finally(() => (bgAgentReapInFlight = false)));
313
341
  }
314
- leg(rosterStore
315
- ?.reapOlderThan?.(Date.now() - config.rosterRetentionMs)
316
- .then(reapCount("roster_rows_reaped_total", {}))
317
- .then(() => rosterReapOlderThanGuard.onSuccess(), rosterReapOlderThanGuard.onError));
318
342
  leg(leaderRunStore
319
343
  ?.reapStaleRunning(config.leaderRunStaleMs, Date.now())
320
344
  .then(reapCount("leader_runs_stale_reaped_total", {}))
@@ -41,6 +41,8 @@ export interface ResolveSpecCtx {
41
41
  fenceSessionOwner: (sid: string, owner: string | null) => void;
42
42
  hookLlm: ReturnType<typeof createHookLlm>["hookLlm"];
43
43
  hookAgent: HookLlmCall;
44
+ /** 部署座在任务座之下挂了链成员的站点式样(第 5 段装配口从引擎准入记录读出,`boot/deployment-mods.ts` 的 `belowTaskChainPatternsOf`)—— 原样交 hooks 注册上下文(托管车道在这些站上只许收紧)。 */
45
+ belowTaskChainPatterns: readonly string[];
44
46
  fleetBus: FleetEventBus;
45
47
  hookWakeBus: {
46
48
  deliver?: (sessionId: string, text: string) => Promise<boolean>;