@sema-agent/server 7.150.0 → 7.152.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 (514) hide show
  1. package/MIGRATION.md +451 -0
  2. package/README.md +15 -3
  3. package/README.zh-CN.md +10 -2
  4. package/USAGE.md +144 -87
  5. package/deploy/sema-up/README.md +11 -4
  6. package/deploy/sema-up/chart/Chart.yaml +1 -1
  7. package/deploy/sema-up/chart/templates/NOTES.txt +5 -0
  8. package/deploy/sema-up/chart/templates/_helpers.tpl +15 -16
  9. package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -3
  10. package/deploy/sema-up/chart/templates/server.yaml +5 -3
  11. package/deploy/sema-up/chart/values-full-single.yaml +3 -1
  12. package/deploy/sema-up/chart/values.yaml +8 -1
  13. package/deploy/sema-up/cluster-up.sh +7 -6
  14. package/deploy/sema-up/kube-up.sh +6 -6
  15. package/deploy/sema-up/lib/flagshape.sh +36 -8
  16. package/deploy/sema-up/lib/helm-values-cluster.py +2 -0
  17. package/deploy/sema-up/lib/helm-values-kube.py +2 -0
  18. package/deploy/sema-up/machines.example.yaml +3 -1
  19. package/deploy/sema-up/sema-up.sh +22 -16
  20. package/dist/adoption/import.js +3 -3
  21. package/dist/approval-ask-audit-store.d.ts +1 -1
  22. package/dist/approval-ask-machine.d.ts +4 -10
  23. package/dist/approval-ask-retention.d.ts +1 -1
  24. package/dist/approval-card.d.ts +12 -14
  25. package/dist/approval-gate-currency.d.ts +9 -9
  26. package/dist/approval-gate-currency.js +3 -4
  27. package/dist/approval-hmac.d.ts +17 -1
  28. package/dist/approval-hmac.js +7 -1
  29. package/dist/approval-queue-kind.d.ts +1 -1
  30. package/dist/approval.d.ts +2 -2
  31. package/dist/approval.js +2 -2
  32. package/dist/auth-bridge.d.ts +20 -0
  33. package/dist/auth-bridge.js +9 -0
  34. package/dist/background-session-reap.d.ts +1 -1
  35. package/dist/bake-runner/main.d.ts +4 -2
  36. package/dist/bind-host.d.ts +3 -6
  37. package/dist/bind-host.js +4 -7
  38. package/dist/boot/budget-tracing.js +1 -1
  39. package/dist/boot/coordinators.d.ts +1 -1
  40. package/dist/boot/coordinators.js +9 -10
  41. package/dist/boot/device-lane.js +2 -0
  42. package/dist/boot/engine-lease.d.ts +5 -0
  43. package/dist/boot/engine-lease.js +1 -0
  44. package/dist/boot/execution-env.d.ts +9 -14
  45. package/dist/boot/execution-env.js +85 -22
  46. package/dist/boot/execution-lane.js +32 -5
  47. package/dist/boot/late-binds.d.ts +8 -4
  48. package/dist/boot/late-binds.js +7 -1
  49. package/dist/boot/leader.d.ts +31 -30
  50. package/dist/boot/leader.js +38 -28
  51. package/dist/boot/leg-path-adjudication.d.ts +40 -0
  52. package/dist/boot/leg-path-adjudication.js +18 -0
  53. package/dist/boot/memory-consolidation.d.ts +3 -2
  54. package/dist/boot/memory-consolidation.js +6 -6
  55. package/dist/boot/parked-revive-gate.js +3 -15
  56. package/dist/boot/reapers.d.ts +6 -1
  57. package/dist/boot/reapers.js +13 -2
  58. package/dist/boot/resolve-spec.d.ts +3 -3
  59. package/dist/boot/resolve-spec.js +43 -48
  60. package/dist/boot/runner-deps.d.ts +46 -35
  61. package/dist/boot/runner-deps.js +94 -91
  62. package/dist/boot/session-age-out.d.ts +36 -0
  63. package/dist/boot/session-age-out.js +101 -0
  64. package/dist/boot/session-faces.d.ts +5 -14
  65. package/dist/boot/session-faces.js +9 -5
  66. package/dist/boot/shutdown.d.ts +6 -0
  67. package/dist/boot/shutdown.js +10 -4
  68. package/dist/boot/stage-01-config.js +2 -0
  69. package/dist/boot/stage-02-web-admin-pull.js +4 -5
  70. package/dist/boot/stage-05-execution-env.d.ts +5 -3
  71. package/dist/boot/stage-05-execution-env.js +3 -2
  72. package/dist/boot/stage-06-runners.d.ts +9 -4
  73. package/dist/boot/stage-06-runners.js +24 -9
  74. package/dist/boot/stage-07-capability-layer.d.ts +8 -4
  75. package/dist/boot/stage-07-capability-layer.js +3 -2
  76. package/dist/boot/stage-08-reapers.d.ts +8 -4
  77. package/dist/boot/stage-08-reapers.js +4 -2
  78. package/dist/boot/stage-09-leader.d.ts +12 -5
  79. package/dist/boot/stage-09-leader.js +14 -5
  80. package/dist/boot/stage-10-http-server.d.ts +19 -5
  81. package/dist/boot/stage-10-http-server.js +14 -21
  82. package/dist/boot/stores.js +7 -4
  83. package/dist/boot/web-admin.js +5 -8
  84. package/dist/boot/workflow-orchestration.d.ts +7 -2
  85. package/dist/boot/workflow-orchestration.js +24 -7
  86. package/dist/bounded-rotation.d.ts +29 -0
  87. package/dist/bounded-rotation.js +24 -0
  88. package/dist/capabilities/approvals-push.d.ts +3 -3
  89. package/dist/capabilities/scenarios.d.ts +28 -13
  90. package/dist/capabilities/scenarios.js +2 -2
  91. package/dist/capability-facts.d.ts +43 -32
  92. package/dist/capability-facts.js +45 -51
  93. package/dist/card-rule-offers.d.ts +32 -0
  94. package/dist/card-rule-offers.js +130 -0
  95. package/dist/center-credential.d.ts +25 -6
  96. package/dist/center-credential.js +25 -5
  97. package/dist/config-catalog.d.ts +26 -7
  98. package/dist/config-catalog.js +26 -22
  99. package/dist/config-dir-trust.js +4 -2
  100. package/dist/config-invariants.d.ts +20 -8
  101. package/dist/config-invariants.js +55 -12
  102. package/dist/config-lkg.d.ts +5 -19
  103. package/dist/config-lkg.js +8 -62
  104. package/dist/config-provider.d.ts +1 -1
  105. package/dist/config-root-migration.d.ts +2 -2
  106. package/dist/config-types.d.ts +38 -42
  107. package/dist/config.d.ts +58 -7
  108. package/dist/config.js +90 -40
  109. package/dist/control-socket.d.ts +51 -0
  110. package/dist/control-socket.js +115 -0
  111. package/dist/deployment-governance.d.ts +2 -1
  112. package/dist/deployment-shape.d.ts +9 -1
  113. package/dist/deployment-shape.js +2 -1
  114. package/dist/device-protocol.d.ts +5 -4
  115. package/dist/device-protocol.js +1 -1
  116. package/dist/device-ws-hub.d.ts +7 -0
  117. package/dist/device-ws-hub.js +10 -3
  118. package/dist/device-ws-protocol.d.ts +63 -10
  119. package/dist/device-ws-protocol.js +56 -25
  120. package/dist/elicitation.js +2 -2
  121. package/dist/engine-identity.d.ts +19 -7
  122. package/dist/engine-identity.js +10 -2
  123. package/dist/entry-mode-clamp-notice.d.ts +2 -1
  124. package/dist/entry-problems.d.ts +40 -3
  125. package/dist/entry-problems.js +3 -1
  126. package/dist/execution-env-refusal.d.ts +29 -0
  127. package/dist/execution-env-refusal.js +8 -0
  128. package/dist/execution-lane-caps.d.ts +3 -1
  129. package/dist/field-conflict.d.ts +1 -1
  130. package/dist/file-history-capture.d.ts +11 -4
  131. package/dist/file-history-capture.js +9 -6
  132. package/dist/file-history-disclosure.d.ts +7 -5
  133. package/dist/file-history-disclosure.js +7 -5
  134. package/dist/fleet/drain-entry.d.ts +4 -0
  135. package/dist/fleet/engine-signal.d.ts +12 -29
  136. package/dist/fleet/engine-signal.js +1 -7
  137. package/dist/fleet-client.js +2 -5
  138. package/dist/gate-settlement.d.ts +1 -8
  139. package/dist/gate-settlement.js +0 -4
  140. package/dist/history-anchor.js +1 -1
  141. package/dist/hitl-delivery.d.ts +2 -3
  142. package/dist/hitl-delivery.js +0 -2
  143. package/dist/hooks/hook-llm.js +4 -2
  144. package/dist/hooks/hook-runner.d.ts +3 -2
  145. package/dist/hooks/hook-runner.js +18 -3
  146. package/dist/host-decision.d.ts +11 -11
  147. package/dist/host-lsp-manager.d.ts +2 -2
  148. package/dist/http/active-run-conflict.d.ts +35 -2
  149. package/dist/http/active-run-conflict.js +48 -19
  150. package/dist/http/admission.js +17 -2
  151. package/dist/http/approval-sweeps.d.ts +1 -1
  152. package/dist/http/approval-sweeps.js +10 -7
  153. package/dist/http/checkpoint-ctx.d.ts +4 -0
  154. package/dist/http/checkpoint-ctx.js +2 -0
  155. package/dist/http/dispatch.d.ts +8 -3
  156. package/dist/http/dispatch.js +59 -32
  157. package/dist/http/durable-run-leg.js +16 -17
  158. package/dist/http/health-reader.d.ts +16 -9
  159. package/dist/http/health-reader.js +2 -1
  160. package/dist/http/health-self-report.d.ts +9 -1
  161. package/dist/http/health-self-report.js +3 -1
  162. package/dist/http/owner-access.d.ts +33 -14
  163. package/dist/http/owner-access.js +40 -10
  164. package/dist/http/principal-gate.d.ts +49 -21
  165. package/dist/http/principal-gate.js +61 -11
  166. package/dist/http/request-channel.d.ts +23 -0
  167. package/dist/http/request-channel.js +9 -0
  168. package/dist/http/request-guards.js +17 -2
  169. package/dist/http/resume-ctx-read.js +42 -3
  170. package/dist/http/resume-legs.d.ts +4 -3
  171. package/dist/http/resume-legs.js +367 -117
  172. package/dist/http/route-ctx.d.ts +91 -15
  173. package/dist/http/route-ctx.js +17 -0
  174. package/dist/http/route-table.d.ts +5 -1
  175. package/dist/http/route-table.js +4 -0
  176. package/dist/http/routes/admin-config-refresh.js +3 -3
  177. package/dist/http/routes/admin-drain.d.ts +3 -0
  178. package/dist/http/routes/admin-drain.js +7 -7
  179. package/dist/http/routes/admin-memory-optout.d.ts +1 -1
  180. package/dist/http/routes/admin-memory-optout.js +3 -3
  181. package/dist/http/routes/adoption.js +3 -5
  182. package/dist/http/routes/agents-roster.js +2 -3
  183. package/dist/http/routes/approvals-assistant.d.ts +2 -1
  184. package/dist/http/routes/approvals-assistant.js +99 -51
  185. package/dist/http/routes/background.d.ts +3 -3
  186. package/dist/http/routes/capabilities.d.ts +4 -0
  187. package/dist/http/routes/capabilities.js +38 -10
  188. package/dist/http/routes/config-catalog.js +2 -2
  189. package/dist/http/routes/devices.js +1 -1
  190. package/dist/http/routes/diagnostics.d.ts +3 -3
  191. package/dist/http/routes/diagnostics.js +19 -7
  192. package/dist/http/routes/fleet.js +10 -8
  193. package/dist/http/routes/images.js +10 -10
  194. package/dist/http/routes/memory-bundle.js +3 -3
  195. package/dist/http/routes/memory-compliance.js +3 -3
  196. package/dist/http/routes/memory-consolidation.js +2 -2
  197. package/dist/http/routes/memory-origin.js +3 -3
  198. package/dist/http/routes/memory-policy.js +2 -2
  199. package/dist/http/routes/observability.js +3 -3
  200. package/dist/http/routes/projects.d.ts +3 -2
  201. package/dist/http/routes/projects.js +4 -5
  202. package/dist/http/routes/retention-ops.js +3 -3
  203. package/dist/http/routes/rules.js +5 -5
  204. package/dist/http/routes/run-permission-mode.d.ts +2 -1
  205. package/dist/http/routes/run-permission-mode.js +2 -2
  206. package/dist/http/routes/runs.d.ts +4 -9
  207. package/dist/http/routes/runs.js +171 -65
  208. package/dist/http/routes/session-sync.d.ts +22 -9
  209. package/dist/http/routes/session-sync.js +204 -107
  210. package/dist/http/routes/sessions-list.js +13 -7
  211. package/dist/http/routes/sessions.js +30 -15
  212. package/dist/http/routes/tasks.js +46 -41
  213. package/dist/http/routes/trace-usage.js +2 -2
  214. package/dist/http/routes/workflows.js +1 -1
  215. package/dist/http/server.d.ts +30 -30
  216. package/dist/http/server.js +16 -4
  217. package/dist/http/submit-ctx.d.ts +1 -1
  218. package/dist/http/submit-ctx.js +7 -4
  219. package/dist/http/wire-types.d.ts +14 -4
  220. package/dist/human-facing-args.d.ts +33 -0
  221. package/dist/human-facing-args.js +33 -0
  222. package/dist/identity-source.d.ts +20 -3
  223. package/dist/identity-source.js +14 -0
  224. package/dist/index.d.ts +5 -1
  225. package/dist/k8s-api-credentials.d.ts +29 -0
  226. package/dist/k8s-api-credentials.js +25 -0
  227. package/dist/lane-home-probe.d.ts +3 -7
  228. package/dist/lane-home-probe.js +2 -2
  229. package/dist/leader/diffup.d.ts +19 -0
  230. package/dist/leader/diffup.js +7 -0
  231. package/dist/leader/leader.d.ts +116 -11
  232. package/dist/leader/leader.js +69 -5
  233. package/dist/leader/repair-wire.js +2 -2
  234. package/dist/leader/run-entry.d.ts +2 -1
  235. package/dist/leader/run-entry.js +1 -1
  236. package/dist/leader/wire.d.ts +42 -132
  237. package/dist/leader/wire.js +81 -67
  238. package/dist/leg-facts.d.ts +13 -5
  239. package/dist/leg-facts.js +2 -1
  240. package/dist/memory-scope.d.ts +23 -11
  241. package/dist/memory-scope.js +18 -6
  242. package/dist/memory-sync-client.d.ts +30 -2
  243. package/dist/memory-sync-client.js +16 -9
  244. package/dist/model-entry-headers.d.ts +9 -10
  245. package/dist/model-entry-headers.js +0 -4
  246. package/dist/model-entry-refusal.d.ts +7 -4
  247. package/dist/model-entry-refusal.js +11 -5
  248. package/dist/model-plane-face.d.ts +1 -1
  249. package/dist/model-plane-face.js +3 -1
  250. package/dist/model-route-endpoint.d.ts +13 -7
  251. package/dist/model-route-endpoint.js +14 -11
  252. package/dist/model-select.d.ts +22 -0
  253. package/dist/model-select.js +9 -0
  254. package/dist/model-unreachable-notice.d.ts +11 -0
  255. package/dist/model-unreachable-notice.js +4 -4
  256. package/dist/object-store-buckets.d.ts +640 -6
  257. package/dist/object-store-buckets.js +166 -0
  258. package/dist/observability/err-text.d.ts +7 -0
  259. package/dist/observability/err-text.js +5 -0
  260. package/dist/observability/fail-open.d.ts +25 -17
  261. package/dist/observability/fail-open.js +25 -17
  262. package/dist/observability/logger.js +3 -1
  263. package/dist/observability/metrics.js +1 -0
  264. package/dist/operator-roster.d.ts +68 -0
  265. package/dist/operator-roster.js +32 -0
  266. package/dist/orchestration/workflow-notify-journal.d.ts +18 -1
  267. package/dist/orchestration/workflow-notify-journal.js +12 -1
  268. package/dist/orchestration/workflow-park-decision.d.ts +70 -18
  269. package/dist/orchestration/workflow-park-decision.js +49 -10
  270. package/dist/orchestration/workflow-park-holder.d.ts +65 -0
  271. package/dist/orchestration/workflow-park-holder.js +98 -0
  272. package/dist/orchestration/workflow-record-fence.d.ts +36 -0
  273. package/dist/orchestration/workflow-record-fence.js +42 -0
  274. package/dist/outbound-dispatcher.d.ts +71 -8
  275. package/dist/outbound-dispatcher.js +48 -7
  276. package/dist/owner-faces.d.ts +2 -2
  277. package/dist/parked-decide.d.ts +106 -55
  278. package/dist/parked-decide.js +153 -117
  279. package/dist/peer-directory.d.ts +2 -2
  280. package/dist/peer-inbound-face.d.ts +2 -6
  281. package/dist/peer-inbound-face.js +0 -3
  282. package/dist/permission-mode-admission.d.ts +74 -5
  283. package/dist/permission-mode-admission.js +56 -3
  284. package/dist/plugins/adoption-log-sql.d.ts +3 -1
  285. package/dist/plugins/adoption-log-sql.js +7 -1
  286. package/dist/plugins/approval-ask-store-file.d.ts +14 -2
  287. package/dist/plugins/approval-ask-store-file.js +11 -0
  288. package/dist/plugins/approval-ask-store-memory.d.ts +10 -1
  289. package/dist/plugins/approval-ask-store-memory.js +35 -10
  290. package/dist/plugins/approval-ask-store-sql.d.ts +69 -4
  291. package/dist/plugins/approval-ask-store-sql.js +45 -5
  292. package/dist/plugins/approval-exemption-store.js +3 -0
  293. package/dist/plugins/approval-nonce-store.js +2 -0
  294. package/dist/plugins/blob-backend.d.ts +83 -7
  295. package/dist/plugins/blob-backend.js +57 -6
  296. package/dist/plugins/breaker-state-sql.js +2 -0
  297. package/dist/plugins/caching-session-store.d.ts +9 -15
  298. package/dist/plugins/caching-session-store.js +6 -0
  299. package/dist/plugins/checkpoint-index-columns.d.ts +20 -16
  300. package/dist/plugins/checkpoint-index-columns.js +3 -6
  301. package/dist/plugins/checkpoint-store-face.d.ts +119 -61
  302. package/dist/plugins/checkpoint-store-face.js +134 -55
  303. package/dist/plugins/device-store-sql.js +6 -0
  304. package/dist/plugins/error-origin.d.ts +18 -0
  305. package/dist/plugins/error-origin.js +10 -0
  306. package/dist/plugins/execution-placement-sql.js +6 -6
  307. package/dist/plugins/image-bake-store-sql.js +6 -0
  308. package/dist/plugins/image-index-sql.js +4 -0
  309. package/dist/plugins/landed-attendants.d.ts +212 -0
  310. package/dist/plugins/landed-attendants.js +161 -0
  311. package/dist/plugins/leader-run-store-sql.js +4 -0
  312. package/dist/plugins/local-checkpoint-store.d.ts +13 -3
  313. package/dist/plugins/local-checkpoint-store.js +38 -49
  314. package/dist/plugins/local-session-live-reference.d.ts +40 -0
  315. package/dist/plugins/local-session-live-reference.js +39 -0
  316. package/dist/plugins/local-session-store.d.ts +71 -33
  317. package/dist/plugins/local-session-store.js +129 -27
  318. package/dist/plugins/memory-engine-pg.js +4 -0
  319. package/dist/plugins/memory-engine-sql-apply.js +5 -2
  320. package/dist/plugins/memory-engine-tidb.js +4 -0
  321. package/dist/plugins/memory-optout-grant-store-sql.js +4 -0
  322. package/dist/plugins/memory-sync-store-pg.js +5 -0
  323. package/dist/plugins/memory-sync-store-tidb.js +5 -0
  324. package/dist/plugins/one-time-migrations.d.ts +104 -80
  325. package/dist/plugins/one-time-migrations.js +226 -132
  326. package/dist/plugins/org-delivery-quota-store.js +4 -1
  327. package/dist/plugins/outcome-ledger-sql.js +2 -0
  328. package/dist/plugins/permission-rule-store-sql.js +11 -4
  329. package/dist/plugins/pg-cost-quota.js +4 -0
  330. package/dist/plugins/pg-pool.js +35 -10
  331. package/dist/plugins/pg-rate-limiter.js +2 -0
  332. package/dist/plugins/posix-shell-fs.d.ts +6 -1
  333. package/dist/plugins/posix-shell-fs.js +4 -1
  334. package/dist/plugins/remote-env-adb.d.ts +19 -15
  335. package/dist/plugins/remote-env-adb.js +41 -15
  336. package/dist/plugins/remote-env-connect-seat.d.ts +105 -0
  337. package/dist/plugins/remote-env-connect-seat.js +72 -0
  338. package/dist/plugins/remote-env-device.d.ts +22 -5
  339. package/dist/plugins/remote-env-device.js +106 -8
  340. package/dist/plugins/remote-env-e2b.d.ts +15 -6
  341. package/dist/plugins/remote-env-e2b.js +42 -32
  342. package/dist/plugins/remote-env-file-error.js +6 -2
  343. package/dist/plugins/remote-env-host.d.ts +46 -10
  344. package/dist/plugins/remote-env-host.js +124 -52
  345. package/dist/plugins/remote-env-k8s.d.ts +109 -41
  346. package/dist/plugins/remote-env-k8s.js +160 -54
  347. package/dist/plugins/remote-env-local-docker.d.ts +13 -8
  348. package/dist/plugins/remote-env-local-docker.js +34 -41
  349. package/dist/plugins/remote-env-ssh.d.ts +18 -12
  350. package/dist/plugins/remote-env-ssh.js +60 -59
  351. package/dist/plugins/remote-shell.d.ts +98 -1
  352. package/dist/plugins/remote-shell.js +218 -0
  353. package/dist/plugins/replica-registration.d.ts +1 -1
  354. package/dist/plugins/replica-registration.js +1 -1
  355. package/dist/plugins/resume-anchor-store-sql.d.ts +11 -2
  356. package/dist/plugins/resume-anchor-store-sql.js +12 -5
  357. package/dist/plugins/retention-lane-store-sql.js +4 -0
  358. package/dist/plugins/retention-sql.d.ts +20 -2
  359. package/dist/plugins/retention-sql.js +11 -0
  360. package/dist/plugins/run-store-sql.d.ts +21 -2
  361. package/dist/plugins/run-store-sql.js +31 -7
  362. package/dist/plugins/s3-presign.d.ts +23 -0
  363. package/dist/plugins/s3-presign.js +37 -3
  364. package/dist/plugins/scenario-prefix-switch-m42.d.ts +1 -1
  365. package/dist/plugins/scenario-prefix-switch-m42.js +2 -2
  366. package/dist/plugins/scheduler-support.d.ts +2 -2
  367. package/dist/plugins/scheduler-support.js +0 -3
  368. package/dist/plugins/schema-consistency.d.ts +4 -2
  369. package/dist/plugins/schema-consistency.js +19 -2
  370. package/dist/plugins/schema-indexes.js +2 -0
  371. package/dist/plugins/send-file-ledger.d.ts +2 -2
  372. package/dist/plugins/send-file-ledger.js +5 -2
  373. package/dist/plugins/send-user-file.d.ts +3 -4
  374. package/dist/plugins/send-user-file.js +56 -52
  375. package/dist/plugins/serving-requirement.d.ts +26 -7
  376. package/dist/plugins/serving-requirement.js +11 -4
  377. package/dist/plugins/session-birth.d.ts +6 -2
  378. package/dist/plugins/session-blob-claim-token.d.ts +15 -0
  379. package/dist/plugins/session-blob-claim-token.js +20 -0
  380. package/dist/plugins/session-blob-namespace.d.ts +46 -0
  381. package/dist/plugins/session-blob-namespace.js +116 -0
  382. package/dist/plugins/session-capture-record-store-sql.js +2 -0
  383. package/dist/plugins/session-ext-table.d.ts +14 -1
  384. package/dist/plugins/session-ext-table.js +5 -1
  385. package/dist/plugins/session-row-sql.d.ts +49 -2
  386. package/dist/plugins/session-row-sql.js +56 -13
  387. package/dist/plugins/session-store-sql.d.ts +34 -18
  388. package/dist/plugins/session-store-sql.js +98 -17
  389. package/dist/plugins/shared-memory-store-sql.d.ts +1 -0
  390. package/dist/plugins/shared-memory-store-sql.js +6 -2
  391. package/dist/plugins/snapshot-bucket-presence.d.ts +25 -2
  392. package/dist/plugins/snapshot-bucket-presence.js +8 -2
  393. package/dist/plugins/sql-driver.d.ts +2 -1
  394. package/dist/plugins/sql-driver.js +18 -3
  395. package/dist/plugins/sql-errors.d.ts +11 -6
  396. package/dist/plugins/sql-errors.js +5 -6
  397. package/dist/plugins/sql-json-column.d.ts +1 -1
  398. package/dist/plugins/stop-then-start-sentence.d.ts +10 -4
  399. package/dist/plugins/stop-then-start-sentence.js +14 -10
  400. package/dist/plugins/stop-then-start.d.ts +109 -0
  401. package/dist/plugins/stop-then-start.js +104 -0
  402. package/dist/plugins/store-backend.d.ts +84 -15
  403. package/dist/plugins/store-backend.js +236 -72
  404. package/dist/plugins/store-boundary.d.ts +57 -0
  405. package/dist/plugins/store-boundary.js +139 -0
  406. package/dist/plugins/store-contracts.d.ts +17 -0
  407. package/dist/plugins/store-fault-sentence-m53.d.ts +7 -0
  408. package/dist/plugins/store-fault-sentence-m53.js +25 -0
  409. package/dist/plugins/store-fault.d.ts +26 -7
  410. package/dist/plugins/store-fault.js +18 -2
  411. package/dist/plugins/task-attachment-store.d.ts +2 -1
  412. package/dist/plugins/task-attachment-store.js +14 -1
  413. package/dist/plugins/task-list-store-sql.d.ts +2 -2
  414. package/dist/plugins/task-list-store-sql.js +10 -8
  415. package/dist/plugins/tidb-cost-quota.js +4 -0
  416. package/dist/plugins/tidb-pool.js +21 -25
  417. package/dist/plugins/tidb-rate-limiter.js +4 -0
  418. package/dist/plugins/user-input-ledger-sql.js +4 -0
  419. package/dist/plugins/workflow-run-store-sql.d.ts +28 -10
  420. package/dist/plugins/workflow-run-store-sql.js +64 -4
  421. package/dist/plugins/workspace-custody.d.ts +4 -3
  422. package/dist/plugins/workspace-fill.d.ts +4 -7
  423. package/dist/plugins/workspace-fill.js +2 -1
  424. package/dist/plugins/write-behind-counter.js +5 -0
  425. package/dist/project-context.d.ts +0 -2
  426. package/dist/project-context.js +4 -8
  427. package/dist/project-registry.d.ts +46 -0
  428. package/dist/project-registry.js +44 -0
  429. package/dist/question.d.ts +2 -1
  430. package/dist/question.js +5 -13
  431. package/dist/request-form.d.ts +6 -1
  432. package/dist/request-form.js +4 -1
  433. package/dist/request-key-closure.js +1 -1
  434. package/dist/request-value-closure.d.ts +4 -0
  435. package/dist/request-value-closure.js +10 -0
  436. package/dist/rule-issue-reading.d.ts +1 -1
  437. package/dist/rules-consent.d.ts +1 -1
  438. package/dist/run-acceptance.d.ts +3 -2
  439. package/dist/run-acceptance.js +4 -6
  440. package/dist/run-local.js +9 -9
  441. package/dist/runs.d.ts +54 -16
  442. package/dist/runs.js +67 -13
  443. package/dist/runtime-governance.d.ts +5 -4
  444. package/dist/security.d.ts +30 -32
  445. package/dist/security.js +41 -7
  446. package/dist/sema-config-dir.d.ts +2 -1
  447. package/dist/server-secret-env.d.ts +12 -10
  448. package/dist/server-secret-env.js +24 -15
  449. package/dist/session-bindings.d.ts +82 -0
  450. package/dist/session-bindings.js +18 -0
  451. package/dist/session-children-retire.d.ts +2 -2
  452. package/dist/session-children-retire.js +2 -6
  453. package/dist/session-deletion.d.ts +16 -1
  454. package/dist/session-error-wire.d.ts +3 -3
  455. package/dist/session-error-wire.js +3 -3
  456. package/dist/session-incarnation.d.ts +10 -0
  457. package/dist/session-incarnation.js +10 -1
  458. package/dist/session-kind.d.ts +57 -0
  459. package/dist/session-kind.js +22 -0
  460. package/dist/session-row.d.ts +21 -1
  461. package/dist/session-row.js +7 -1
  462. package/dist/session-sync-kernel.d.ts +24 -14
  463. package/dist/session-sync-kernel.js +3 -6
  464. package/dist/session-sync.d.ts +25 -103
  465. package/dist/session-sync.js +14 -76
  466. package/dist/session-titler.d.ts +10 -3
  467. package/dist/session-titler.js +19 -6
  468. package/dist/ssh-host-key.d.ts +5 -0
  469. package/dist/ssh-host-key.js +3 -0
  470. package/dist/stores-sql/blob-index-sql.d.ts +30 -9
  471. package/dist/stores-sql/blob-index-sql.js +40 -21
  472. package/dist/stores-sql/checkpoint-store-sql.d.ts +54 -27
  473. package/dist/stores-sql/checkpoint-store-sql.js +70 -146
  474. package/dist/stores-sql/file-history-store-sql.d.ts +113 -15
  475. package/dist/stores-sql/file-history-store-sql.js +205 -95
  476. package/dist/stores-sql/pg-session-storage.d.ts +34 -7
  477. package/dist/stores-sql/pg-session-storage.js +37 -13
  478. package/dist/stores-sql/retention-store-sql.d.ts +1 -9
  479. package/dist/stores-sql/retention-store-sql.js +5 -19
  480. package/dist/stores-sql/session-policy-store-sql.d.ts +30 -7
  481. package/dist/stores-sql/session-policy-store-sql.js +61 -44
  482. package/dist/stores-sql/session-write-hooks.d.ts +11 -0
  483. package/dist/stores-sql/tidb-session-store.d.ts +58 -7
  484. package/dist/stores-sql/tidb-session-store.js +37 -13
  485. package/dist/submission-exit.d.ts +3 -2
  486. package/dist/submission-exit.js +9 -1
  487. package/dist/task-cwd.d.ts +2 -2
  488. package/dist/task-settings.d.ts +7 -5
  489. package/dist/task-settings.js +3 -3
  490. package/dist/terminal.d.ts +33 -2
  491. package/dist/terminal.js +139 -9
  492. package/dist/tool-approval.d.ts +465 -507
  493. package/dist/tool-approval.js +606 -1222
  494. package/dist/trace/core-keyset-guard.d.ts +1 -1
  495. package/dist/trace/ledger-events.d.ts +3 -3
  496. package/dist/trace/project.d.ts +2 -3
  497. package/dist/trace/redact.js +3 -2
  498. package/dist/trace/self-minted-wire.d.ts +571 -178
  499. package/dist/trace/self-minted-wire.js +189 -56
  500. package/dist/web-admin-client/apply-effective.js +2 -2
  501. package/dist/web-admin-client/read-warnings.d.ts +2 -2
  502. package/dist/web-admin-client/read-warnings.js +1 -1
  503. package/dist/web-admin-client/types.d.ts +1 -1
  504. package/dist/workspace-space.d.ts +10 -4
  505. package/dist/workspace-space.js +4 -1
  506. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +79 -28
  507. package/package.json +7 -3
  508. package/scripts/embed-minimal.mjs +3 -3
  509. package/wire-changes/server@7.151.0.json +762 -0
  510. package/wire-changes/server@7.152.0.json +900 -0
  511. package/dist/config-d-migration.d.ts +0 -37
  512. package/dist/config-d-migration.js +0 -60
  513. package/dist/http/session-inherit-env.d.ts +0 -36
  514. package/dist/http/session-inherit-env.js +0 -6
@@ -12,7 +12,7 @@ import { deviceExecutionEnvFactory } from "../plugins/remote-env-device.js";
12
12
  import { e2bExecutionEnvFactory } from "../plugins/remote-env-e2b.js";
13
13
  import { createWorkspaceFill } from "../plugins/workspace-fill.js";
14
14
  import { hostExecutionEnvFactory, RemoteHostExecutionEnv } from "../plugins/remote-env-host.js";
15
- import { boundedStoreCall, checkSandboxEgressPolicy, createSandboxPodApi, createSpaceReclaimer, k8sExecutionEnvFactory, readSandboxSecretSeat, rpcTimeoutMsOf } from "../plugins/remote-env-k8s.js";
15
+ import { boundedStoreCall, checkSandboxEgressPolicy, createSandboxPodApi, createSpaceReclaimer, k8sExecutionEnvFactory, readSandboxApiCredentials, readSandboxSecretSeat, rpcTimeoutMsOf, sandboxApiCredentialFact } from "../plugins/remote-env-k8s.js";
16
16
  import { podSpecPatchBrokerRefusal, SANDBOX_SECRET_SEAT_VERBS } from "../plugins/k8s-exec-protocol.js";
17
17
  import { createSandboxBrokerSeatOf, createSandboxGitPlaneSeat, sandboxGitPlanePremisesOf } from "../sandbox-git-plane.js";
18
18
  import { createSandboxPodReaper } from "../plugins/k8s-pod-reaper.js";
@@ -32,11 +32,14 @@ import { reapOrphanWorktrees, withWorktreeIsolation } from "../plugins/worktree-
32
32
  import { derivePkgSourceEnv } from "../sandbox-pkg-source.js";
33
33
  import { effectiveHostWorkspace } from "../task-cwd.js";
34
34
  import { taskInheritEnvRefusal } from "../hosted-posture.js";
35
+ import { bindingsOf } from "../session-bindings.js";
35
36
  import { sessionFaceOfHead } from "../session-incarnation.js";
36
37
  import { isCodeToken } from "../terminal.js";
37
38
  import { createCacheMissMemory } from "../workspace-cache.js";
38
39
  import { workspaceSnapshotTimeoutOf } from "../workspace-space.js";
39
40
  import { sayEgressPolicyReading } from "../sandbox-egress-policy.js";
41
+ import { K8sApiCredentialsMissingError, k8sCredentialsMissingBootSentence, k8sCredentialsMissingRunSentence, k8sCredentialsRejectedRunSentence } from "../k8s-api-credentials.js";
42
+ import { executionEnvRefusalError } from "../execution-env-refusal.js";
40
43
  import { sandboxPathEnvSlots, withSandboxPathEnvSlot } from "./deferred-sandbox-path-env.js";
41
44
  import { createLaneHomeAbsenceReporter } from "../lane-home-probe.js";
42
45
  import { buildLaneHomeBootNote, buildLaneHomeClaim, capabilitiesFor, laneIsolated, laneSandboxReadFloorState } from "../execution-lane-caps.js";
@@ -61,16 +64,40 @@ function sandboxLaneEnvMerged(lane) {
61
64
  return Object.keys(merged).length > 0 ? merged : undefined;
62
65
  }
63
66
  const MAX_CWD_SESSIONS = 4096;
67
+ function withWrites(cells, writes) {
68
+ return bindingsOf(writes.cwd ?? cells.cwd, writes.shellEnv !== undefined ? { ...writes.shellEnv } : cells.shellEnv, writes.inheritEnv);
69
+ }
70
+ function restoreCell(map, sid, value) {
71
+ if (value === undefined)
72
+ map.delete(sid);
73
+ else
74
+ map.set(sid, value);
75
+ }
64
76
  export function createSessionScopedRegistries(maxEntries = MAX_CWD_SESSIONS) {
65
77
  const perSessionCwd = new Map();
66
78
  const perSessionShellEnv = new Map();
67
79
  const perSessionInheritEnv = new Map();
68
80
  const owners = new Map();
69
81
  const occupants = new Map();
82
+ const logs = new Map();
83
+ const cellsOf = (sid) => bindingsOf(perSessionCwd.get(sid), perSessionShellEnv.get(sid), perSessionInheritEnv.get(sid));
84
+ const materialize = (sid, log) => {
85
+ const cells = log.entries.reduce((acc, e) => withWrites(acc, e.writes), log.base);
86
+ restoreCell(perSessionCwd, sid, cells.cwd);
87
+ restoreCell(perSessionShellEnv, sid, cells.shellEnv);
88
+ restoreCell(perSessionInheritEnv, sid, cells.inheritEnv);
89
+ };
90
+ const compact = (sid, log) => {
91
+ while (log.entries[0]?.settled === true)
92
+ log.base = withWrites(log.base, log.entries.shift().writes);
93
+ if (log.entries.length === 0)
94
+ logs.delete(sid);
95
+ };
70
96
  const dropSession = (sid) => {
71
97
  perSessionCwd.delete(sid);
72
98
  perSessionShellEnv.delete(sid);
73
99
  perSessionInheritEnv.delete(sid);
100
+ logs.delete(sid);
74
101
  owners.delete(sid);
75
102
  occupants.delete(sid);
76
103
  };
@@ -85,22 +112,34 @@ export function createSessionScopedRegistries(maxEntries = MAX_CWD_SESSIONS) {
85
112
  perSessionCwd,
86
113
  perSessionShellEnv,
87
114
  sessionOwners: owners,
88
- setSessionCwd: (sid, cwd) => {
89
- perSessionCwd.set(sid, cwd);
115
+ perSessionInheritEnv,
116
+ commitSessionBindings: (sid, bindings) => {
117
+ const log = logs.get(sid) ?? { base: cellsOf(sid), entries: [] };
118
+ logs.set(sid, log);
119
+ const token = Symbol(sid);
120
+ log.entries.push({ token, writes: { ...bindings, ...(bindings.shellEnv !== undefined ? { shellEnv: { ...bindings.shellEnv } } : {}) }, settled: false });
121
+ materialize(sid, log);
90
122
  touch(sid, undefined);
123
+ return { sessionId: sid, token };
91
124
  },
92
- setSessionShellEnv: (sid, env) => {
93
- perSessionShellEnv.set(sid, env);
94
- touch(sid, undefined);
125
+ withdrawSessionBindings: (receipt) => {
126
+ const log = logs.get(receipt.sessionId);
127
+ const at = log?.entries.findIndex((e) => e.token === receipt.token) ?? -1;
128
+ if (log === undefined || at < 0)
129
+ return false;
130
+ log.entries.splice(at, 1);
131
+ materialize(receipt.sessionId, log);
132
+ compact(receipt.sessionId, log);
133
+ return true;
95
134
  },
96
- perSessionInheritEnv,
97
- setSessionInheritEnv: (sid, policy) => {
98
- if (policy === undefined) {
99
- perSessionInheritEnv.delete(sid);
100
- return;
101
- }
102
- perSessionInheritEnv.set(sid, policy);
103
- touch(sid, undefined);
135
+ settleSessionBindings: (receipt) => {
136
+ const log = logs.get(receipt.sessionId);
137
+ const entry = log?.entries.find((e) => e.token === receipt.token);
138
+ if (log === undefined || entry === undefined)
139
+ return false;
140
+ entry.settled = true;
141
+ compact(receipt.sessionId, log);
142
+ return true;
104
143
  },
105
144
  fenceSessionOwner: (sid, owner, incarnation) => {
106
145
  const ownerChanged = owners.has(sid) && owners.get(sid) !== owner;
@@ -113,6 +152,7 @@ export function createSessionScopedRegistries(maxEntries = MAX_CWD_SESSIONS) {
113
152
  perSessionCwd.delete(sid);
114
153
  perSessionShellEnv.delete(sid);
115
154
  perSessionInheritEnv.delete(sid);
155
+ logs.delete(sid);
116
156
  }
117
157
  touch(sid, owner);
118
158
  },
@@ -131,6 +171,22 @@ export function ownsItsWorkspace(ctx) {
131
171
  export function createK8sRunEnvFactory(k8sCfg, seats, deps) {
132
172
  const cacheMisses = createCacheMissMemory();
133
173
  return async (ctx) => {
174
+ const credentials = await readSandboxApiCredentials(k8sCfg, deps);
175
+ switch (credentials.state) {
176
+ case "missing":
177
+ throw executionEnvRefusalError("env.sandbox_refused", k8sCredentialsMissingRunSentence(credentials.fact));
178
+ case "rejected":
179
+ throw executionEnvRefusalError("env.sandbox_refused", k8sCredentialsRejectedRunSentence());
180
+ case "accepted":
181
+ break;
182
+ case "unproven":
183
+ recordFailOpen("server.sandbox-credentials.probe-unanswered", `namespace=${k8sCfg.namespace} ${credentials.detail}`);
184
+ break;
185
+ default: {
186
+ const unreachable = credentials;
187
+ throw new Error(`unhandled api credential reading: ${String(unreachable.state)}`);
188
+ }
189
+ }
134
190
  const onWorkspaceSnapshot = createRunWorkspaceSnapshotSeat(ctx.sessionId);
135
191
  const child = !ownsItsWorkspace(ctx);
136
192
  const s3Snapshot = child && k8sCfg.s3Snapshot !== undefined ? spaceOff(k8sCfg.s3Snapshot) : k8sCfg.s3Snapshot;
@@ -250,15 +306,14 @@ export function createExecutionEnv(ctx) {
250
306
  const perTaskImage = new PerTaskImageRegistry();
251
307
  const sessionEnvSelection = new SessionEnvironmentSelection();
252
308
  const sessionScoped = createSessionScopedRegistries();
253
- const { perSessionCwd, setSessionCwd } = sessionScoped;
254
- const { perSessionShellEnv, setSessionShellEnv } = sessionScoped;
255
- const { perSessionInheritEnv, setSessionInheritEnv } = sessionScoped;
309
+ const { perSessionCwd, perSessionShellEnv, perSessionInheritEnv } = sessionScoped;
256
310
  const lspManager = createLspManager(config, (event, fields) => logger.info(event, fields));
257
311
  if (lspManager)
258
312
  logger.info("lsp_enabled", { provider: config.remoteExec.provider });
259
313
  let executionEnvFactory;
260
314
  let spaceReclaimer;
261
315
  let sandboxSecretSeatGate;
316
+ let sandboxApiCredentialsGate;
262
317
  let sandboxReaper;
263
318
  let sandboxCapacity;
264
319
  let sandboxGitPlane = createSandboxGitPlaneSeat((r) => sandboxGitPlanePremisesOf(config, r), {});
@@ -319,9 +374,16 @@ export function createExecutionEnv(ctx) {
319
374
  spaceReclaimer = createSpaceReclaimer(k8sCfg);
320
375
  sandboxSecretSeatGate = () => ensureSandboxSecretSeat(k8sCfg, logger, undefined, () => readSandboxSecretSeat(k8sCfg, "env"));
321
376
  sandboxReaper = createSandboxPodReaper({ api: createSandboxPodApi(k8sCfg), logger, metrics });
322
- void checkSandboxEgressPolicy(k8sCfg)
323
- .then((gaps) => sayEgressPolicyReading(gaps, logger, k8sCfg.namespace))
324
- .catch((e) => logger.error("sandbox_egress_policy_check_crashed", { error: seatText("operator-log-text", e instanceof Error ? e.message : String(e)), effect: "the sandbox egress self-check did not complete this boot — the lane runs; the egress policy was not read" }));
377
+ const missingApiCredential = sandboxApiCredentialFact(k8sCfg, ctx.laneDeps?.k8s);
378
+ sandboxApiCredentialsGate = () => {
379
+ if (missingApiCredential !== undefined)
380
+ throw new K8sApiCredentialsMissingError(k8sCredentialsMissingBootSentence(missingApiCredential));
381
+ };
382
+ if (missingApiCredential === undefined) {
383
+ void checkSandboxEgressPolicy(k8sCfg, ctx.laneDeps?.k8s)
384
+ .then((gaps) => sayEgressPolicyReading(gaps, logger, k8sCfg.namespace))
385
+ .catch((e) => logger.error("sandbox_egress_policy_check_crashed", { error: seatText("operator-log-text", e instanceof Error ? e.message : String(e)), effect: "the sandbox egress self-check did not complete this boot — the lane runs; the egress policy was not read" }));
386
+ }
325
387
  }
326
388
  else if (config.remoteExec.provider === "ssh") {
327
389
  executionEnvFactory = sshExecutionEnvFactory({
@@ -533,12 +595,13 @@ export function createExecutionEnv(ctx) {
533
595
  },
534
596
  });
535
597
  return {
536
- perTaskImage, sessionEnvSelection, perSessionCwd, setSessionCwd, setSessionShellEnv, setSessionInheritEnv,
598
+ perTaskImage, sessionEnvSelection, perSessionCwd,
599
+ sessionBindings: { commitSessionBindings: sessionScoped.commitSessionBindings, withdrawSessionBindings: sessionScoped.withdrawSessionBindings, settleSessionBindings: sessionScoped.settleSessionBindings },
537
600
  fenceSessionOwner: sessionScoped.fenceSessionOwner,
538
601
  dropSessionScoped: sessionScoped.dropSession,
539
602
  dropSessionScopedOf: sessionScoped.dropSessionOf,
540
603
  sessionResidentBackground,
541
- executionEnvFactory, worktreeReap, sendUserFileTaskEnvs, lspManager, spaceReclaimer, sandboxSecretSeatGate, sandboxReaper, sandboxGitPlane,
604
+ executionEnvFactory, worktreeReap, sendUserFileTaskEnvs, lspManager, spaceReclaimer, sandboxApiCredentialsGate, sandboxSecretSeatGate, sandboxReaper, sandboxGitPlane,
542
605
  sandboxCapacity,
543
606
  };
544
607
  }
@@ -1,7 +1,7 @@
1
1
  import { loadRemoteExec } from "@sema-agent/settings-schema/node";
2
2
  import { assertLocalConfigDirTrusted } from "../config-dir-trust.js";
3
3
  import { crossInvariant } from "../config-invariants.js";
4
- import { entryDeclarableRemoteExec } from "../config.js";
4
+ import { entryDeclarableRemoteExec, FILE_LANE_CELL_ENV, logConfigDiagnostics, parseHostLaneEnv, parseLocalDockerLaneEnv, } from "../config.js";
5
5
  import { ALL_EXECUTION_LANES, buildReadDenyFloorUnkeptNote, laneIsolated, laneWiresExecutionEnv } from "../execution-lane-caps.js";
6
6
  import { installReadDenyFloorDeployment } from "../read-deny-floor-notice.js";
7
7
  import { buildReadFacePostureNotice, settleDerivedReadFace } from "../read-face-posture.js";
@@ -27,6 +27,29 @@ function fileLaneUnresolvableRefusal(entry, lane, envReading, root) {
27
27
  `(file-source name→value resolution is not wired yet), and ${envReading}. The file's declaration ends the lane selection: no other declaration may stand in for it. ` +
28
28
  `Refusing before any task starts: set REMOTE_EXEC=${lane} with that lane's required env, or change the file to the lane you mean.`);
29
29
  }
30
+ function envReadingOfFileLane(minted, read, logger) {
31
+ if (minted !== undefined)
32
+ return minted;
33
+ const reading = read();
34
+ logConfigDiagnostics(logger);
35
+ return reading;
36
+ }
37
+ function discloseFileCellOverrides(lane, envReading, fileCells, logger, root) {
38
+ const cellEnvKeys = FILE_LANE_CELL_ENV[lane];
39
+ const keys = Object.entries(cellEnvKeys)
40
+ .filter(([cell]) => envReading[cell] !== undefined && fileCells[cell] !== undefined && envReading[cell] !== fileCells[cell])
41
+ .map(([, envKey]) => envKey);
42
+ if (keys.length === 0)
43
+ return;
44
+ logger.warn("remote_exec_file_overrides", {
45
+ provider: lane,
46
+ root,
47
+ keys,
48
+ note: `config.d/remote-exec.json (CONFIG_PROVIDER=local, file-wins) gives a different value than env for ${keys.join(", ")} on the "${lane}" lane — the file's value is in effect and ` +
49
+ `the env value for ${keys.length === 1 ? "that key is" : "those keys are"} INERT. The lane's other env parameters are read as usual. ` +
50
+ `Make the two agree: unset the env key if the file's value is the intended one, or change the file's cell (an optional cell can be removed from the file; "image" is mandatory there).`,
51
+ });
52
+ }
30
53
  export async function composeExecutionLane(loaded, ctx) {
31
54
  if (ctx.configSource === "local")
32
55
  await applyRemoteExecFile(loaded, ctx);
@@ -127,25 +150,29 @@ async function applyRemoteExecFile(config, ctx) {
127
150
  };
128
151
  const drives = (lane) => ctx.entry.runs.includes(lane);
129
152
  if (fileRx.provider === "host" && drives("host")) {
130
- config.remoteExec = {
131
- provider: "host",
153
+ const envReading = envReadingOfFileLane(config.remoteExec?.provider === "host" ? config.remoteExec : undefined, parseHostLaneEnv, logger);
154
+ const fileCells = {
132
155
  ...(fileRx.workdir ? { workspaceBase: fileRx.workdir } : {}),
133
156
  ...(fileRx.commandTimeoutMs != null ? { commandTimeoutMs: fileRx.commandTimeoutMs } : {}),
134
157
  };
158
+ config.remoteExec = { provider: "host", ...envReading, ...fileCells };
135
159
  disclosePreemption("host");
160
+ discloseFileCellOverrides("host", envReading, fileCells, logger, localRoot);
136
161
  logger.info("remote_exec_from_file", { provider: "host", root: localRoot });
137
162
  return;
138
163
  }
139
164
  if (fileRx.provider === "local-docker" && drives("local-docker")) {
140
- config.remoteExec = {
141
- provider: "local-docker",
165
+ const envReading = envReadingOfFileLane(config.remoteExec?.provider === "local-docker" ? config.remoteExec : undefined, () => parseLocalDockerLaneEnv(config.requirePrincipal !== true), logger);
166
+ const fileCells = {
142
167
  image: fileRx.image,
143
168
  ...(fileRx.mountPath ? { mountPath: fileRx.mountPath } : fileRx.workdir ? { mountPath: fileRx.workdir } : {}),
144
169
  ...(fileRx.memory ? { memory: fileRx.memory } : {}),
145
170
  ...(fileRx.cpus != null ? { cpus: fileRx.cpus } : {}),
146
171
  ...(fileRx.network ? { network: fileRx.network } : {}),
147
172
  };
173
+ config.remoteExec = { provider: "local-docker", ...envReading, ...fileCells };
148
174
  disclosePreemption("local-docker");
175
+ discloseFileCellOverrides("local-docker", envReading, fileCells, logger, localRoot);
149
176
  logger.info("remote_exec_from_file", { provider: "local-docker", root: localRoot, image: fileRx.image });
150
177
  return;
151
178
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 晚绑席([ref] 十段切分的**唯一**跨段可变面)—— 五只 cell,读点在前段、写点在后段。
2
+ * 晚绑席([ref] 十段切分的**唯一**跨段可变面)—— 六只 cell,读点在前段、写点在后段。
3
3
  *
4
4
  * 为什么是模块级 live binding 而不是 ctx 字段:读点的原文是**裸标识符**(`() => runStore`、
5
5
  * `() => parkedAskRedeem`),而 ctx 字段是**快照** —— 把读点改成 `ctx.runStore` 就是正文改写,
@@ -9,9 +9,10 @@
9
9
  * · `parkedAskRedeem` / `runDenySweep` —— 它们的**声明行本身**就是 `let`(逐字搬进本文件,含缩进),
10
10
  * 赋值点(server 造出来之后那两处)也随之搬进 `bindServerLateSeats` —— 跨模块给 import 赋值是非法的,
11
11
  * 所以 cell 与它的写点必须同居一个模块;
12
- * · `sessionNotifyDoor` —— 同上一形(server 的产物,写点在 `bindServerLateSeats`)。
12
+ * · `sessionNotifyDoor` / `runEndedHandoff` —— 同上一形(server 的产物,写点在 `bindServerLateSeats`);
13
+ * · `sessionAgeOut` —— 会话老化腿(`boot/session-age-out.ts`):读点在第 8 段的维护拍,它要的删除协调器在第 9 段铸 ⇒ 写点 `bindSessionAgeOut` 在第 9 段协调器之后。
13
14
  *
14
- * 时序与修前逐字相同:五只 cell 的读点全是 `() => x` 取值闭包(boot 期不求值,最早的求值发生在
15
+ * 时序与修前逐字相同:六只 cell 的读点全是 `() => x` 取值闭包(boot 期不求值,最早的求值发生在
15
16
  * listen 之后的请求/tick 上),写点仍在各自原来的那一拍。未绑窗内取值得到 `undefined` —— 这正是
16
17
  * 各消费座既有的 fail-closed 臂(device 限速座:`gate()` 取不到就抛,见 boot/device-lane.ts:68)。
17
18
  */
@@ -27,7 +28,10 @@ declare let rateLimiter: RateGate | undefined;
27
28
  declare let parkedAskRedeem: ParkedAskRedeem | undefined;
28
29
  declare let runDenySweep: ((now: number) => Promise<void>) | undefined;
29
30
  declare let sessionNotifyDoor: SessionNotifyDoor | undefined;
30
- export { runStore, rateLimiter, parkedAskRedeem, runDenySweep, sessionNotifyDoor };
31
+ declare let runEndedHandoff: ((runId: string) => Promise<void>) | undefined;
32
+ declare let sessionAgeOut: (() => Promise<unknown>) | undefined;
33
+ export { runStore, rateLimiter, parkedAskRedeem, runDenySweep, sessionNotifyDoor, runEndedHandoff, sessionAgeOut };
34
+ export declare function bindSessionAgeOut(v: (() => Promise<unknown>) | undefined): void;
31
35
  export declare function bindRunStore(v: ReturnType<StoreBackend["run"]> | undefined): void;
32
36
  export declare function bindRateLimiter(v: RateGate): void;
33
37
  export declare function bindServerLateSeats(ctx: {
@@ -3,7 +3,12 @@ let rateLimiter;
3
3
  let parkedAskRedeem;
4
4
  let runDenySweep;
5
5
  let sessionNotifyDoor;
6
- export { runStore, rateLimiter, parkedAskRedeem, runDenySweep, sessionNotifyDoor };
6
+ let runEndedHandoff;
7
+ let sessionAgeOut;
8
+ export { runStore, rateLimiter, parkedAskRedeem, runDenySweep, sessionNotifyDoor, runEndedHandoff, sessionAgeOut };
9
+ export function bindSessionAgeOut(v) {
10
+ sessionAgeOut = v;
11
+ }
7
12
  export function bindRunStore(v) {
8
13
  runStore = v;
9
14
  }
@@ -14,6 +19,7 @@ export function bindServerLateSeats(ctx) {
14
19
  const { config, logger, server } = ctx;
15
20
  runDenySweep = server.denyExpiredApprovals;
16
21
  sessionNotifyDoor = server.sessionNotifyDoor;
22
+ runEndedHandoff = server.handOverRunEndedDecisions;
17
23
  if (!config.directDoorActive)
18
24
  parkedAskRedeem = server.redeemParkedAsk;
19
25
  else
@@ -7,51 +7,35 @@
7
7
  * (工厂模式的 k8s/host 腿以 `executionEnvFactory` 在场为门;durable 子 worker 挂 `checkpointStore`)。
8
8
  */
9
9
  import type { ServiceConfig } from "../config.js";
10
- import type { createBrain } from "../brain.js";
11
- import type { buildPricing } from "../budget.js";
12
10
  import { createLeaderEndpoint } from "../leader/endpoint.js";
11
+ import type { LeaderBirth } from "../leader/leader.js";
13
12
  import type { Logger } from "../observability/logger.js";
14
13
  import type { CheckpointStoreFull, StoreBackend, ToolResultStoreFull } from "../plugins/store-backend.js";
15
14
  import type { createSessionStore } from "../plugins/session-store.js";
16
- import type { RunnerDeps } from "@sema-agent/core";
15
+ import { type RunnerDeps } from "@sema-agent/core";
16
+ import type { DeploymentPlaneDeps, DeploymentPlaneLane } from "./runner-deps.js";
17
+ import { type KeyResolver } from "./side-query-lane.js";
17
18
  export interface LeaderCtx {
18
19
  config: ServiceConfig;
19
20
  logger: Logger;
20
- brain: ReturnType<typeof createBrain>;
21
- pricing: ReturnType<typeof buildPricing>;
21
+ /** 本部署的本地店根(`config.localDataRoot` 缺席时的回落;host 车道上守卫裁决的哨兵目录挂在它下面,与 HTTP 腿同一处)。 */
22
+ localRoot: string;
22
23
  executionEnvFactory: RunnerDeps["executionEnvFactory"];
23
24
  toolResultStore: ToolResultStoreFull | undefined;
24
25
  sessionStore: ReturnType<typeof createSessionStore>;
25
26
  checkpointStore: CheckpointStoreFull | undefined;
26
27
  /** [ref]:停驻行凭据的封签器(与 HTTP 面 `ServiceDeps.checkpointCtxSealing` 同一只;起服第 6 段已对「店在、它不在」拒启)。必填键,值可为 undefined。 */
27
28
  checkpointCtxSealing: import("../http/checkpoint-ctx.js").CheckpointCtxSealing | undefined;
28
- /** [ref] 件B/C/D([ref],codex R2-F1):部署治理三座席 —— leader 车道的每一只 Runner 都要带上它,
29
- * 否则开了 leader 端点的部署就有一条在部署治理**之外**的执行面(合规否决/锁都够不着)。 */
30
- governanceSeams: import("./governance-seams.js").GovernanceSeams;
31
29
  /**
32
- * [ref]([ref])—— 主车道 `boot/budget-tracing.ts` 造的**同一只** tracer。leader 车道的每一只 Runner
33
- * 都要带:tracer 是 `brain.call` 的唯一记账点(costQuota / fleetUsage / fleetLease / 花费计数四个写口),
34
- * 而 `POST /v1/leader` 的准入处**读**的正是它填的那两个桶 —— 缺席 = 门查的桶与花钱的手不是同一只。
35
- *
36
- * 🔴 **必填键**(值可为 undefined):这三席都刻意写成非可选,让「main.ts 铸了却忘了递」变成**编译红**
37
- * 而不是又一次静默漏配([ref]§三族A 病族的机器护栏)。
30
+ * **部署平面层**的铸口(起服第 6 段交出:与主 / 子 Runner 的平面层同一组输入 —— config / brain / 计量 / 治理座 / 按主体准入 resolver / 豁免根 /
31
+ * 错误汇 …)。leader 车道的每一只 Runner 展开它的产物,零逐席搬运;新的部署键进平面层即到达 leader。
38
32
  */
39
- tracer: RunnerDeps["tracer"];
40
- /** [ref]([ref],[ref]-T1)—— 治理窗**账本店**(与 `config.usageWindows` 声明成对;声明直接从
41
- * 本 ctx 的 config 取,leader 不另读)。缺席 = 未配治理窗的部署。必填键,理由同 `tracer`。 */
42
- usageWindowStore: RunnerDeps["usageWindowStore"];
43
- /** [ref]([ref])—— center 发布的 prompt catalog(`webAdmin.promptSource`,与主 runner/subRunner
44
- * 同一只)。缺席 ⇒ leader 的四类顶层任务跑引擎内置提示词,而同部署其余三条腿跑运维发布的那一份,
45
- * 且 core 顶层新任务是**静默**落回(无 notice)。必填键,理由同 `tracer`。 */
46
- promptSource: RunnerDeps["promptSource"];
47
- /** [ref] 披露半件([ref],codex r2-[high])—— 主车道 `createRunnerDeps` 铸的**同一只**错误汇
48
- * (main.ts 直引 `runnerDeps.onError`,与 subRunner 的先例同姿势)。core 对治理窗**最终扣账失败**的
49
- * 唯一出口就是它(`runtask.js` 的 `catch (flushErr) => deps.onError`),所以它与 `usageWindowStore`
50
- * 席同生共死:挂窗不挂汇 = 治理轴上的静默失败面([ref])。必填键,理由同 `tracer`。 */
51
- onError: RunnerDeps["onError"];
52
- /** 部署座 —— 起服第 5 段装配口 `assembleDeploymentMods` 交回的**同一份**(主车道各 Runner 经共享基座吃的就是它)。leader 车道的每一只 Runner 都要带:
53
- * 缺席 = 运维声明的 mod 包管不到 leader 派出的腿。必填键,理由同 `tracer`。 */
54
- deploymentMods: NonNullable<RunnerDeps["mods"]>;
33
+ deploymentPlane: (lane: DeploymentPlaneLane) => DeploymentPlaneDeps;
34
+ /**
35
+ * per-model 凭据的**活引用**(`webAdmin.getKeyResolver`:中心每次 apply 整只重铸 resolver ⇒ 递取值口,不递当时的值;任务面 / side-query / WebFetch 摘要面同一只)。
36
+ * leader 车道每条腿的凭据席由它铸({@link createLeaderLegAuth})。必填:没有 web-admin 的装配递 `() => undefined`(每只模型落网关钥,与不配 per-model 钥匙同)。
37
+ */
38
+ getKeyResolver: () => KeyResolver;
55
39
  /** [ref] 车4 件1:durable store 后端(leader-run 登记表从这里取)。缺席 = 无 DB 的 env-only worker。 */
56
40
  backend?: StoreBackend | undefined;
57
41
  }
@@ -96,5 +80,22 @@ export declare function buildLeaderObjectStore(env?: NodeJS.ProcessEnv): {
96
80
  region?: string;
97
81
  };
98
82
  };
83
+ /**
84
+ * leader 车道每条腿**出生时**的两只部署席({@link LeaderBirth} 的 `govern` / `baseline`)—— 装配处闭包活 config 的唯一铸点:起服 {@link createLeaderFace} 递进
85
+ * wire,部署治理矩阵(`test/operator-knob-client-posture-matrix.test.ts`)的 leader 腿经同一只函数装,矩阵测的就是起服装上的那一份。
86
+ * · `govern` —— 部署治理折叠(R3):每条腿出生时调一次,读活 config(热改的 AUTONOMY / commandPolicy / 守卫集对之后出生的腿生效;续跑腿经 resolveSpec 同读)。
87
+ * 腿的路径裁决经唯一属主:沙盒车道按跑这条腿的会话号取真身;host 车道的 worker 落在工厂才铸的目录里、spec 期不可知 ⇒ 永不创建的哨兵目录
88
+ * (与 HTTP 腿未登记工作目录的形同一处,相对目标解析不出真身 ⇒ 守卫的 fail-closed 臂)。
89
+ * · `baseline` —— 审批基线的两臂(🔴 **函数席**,[ref] 波 2 ①:审批名单会被中心热换 ⇒ 每条腿出生时现调唯一属主 `createApprovalBaselinePolicy`,与 HTTP 腿 /
90
+ * 停驻赎回腿同一只构造):耐久腿取 durable 臂(问答门 + 三张名单),不耐久腿取 live 臂(三张名单,问由无人值守层服 —— 答不了即拒)。
91
+ */
92
+ export declare function createLeaderLegGovernance(config: ServiceConfig, localRoot: string, logger: Logger): Pick<LeaderBirth, "govern" | "baseline">;
93
+ /**
94
+ * leader 车道每条腿的 **per-model 凭据席**({@link LeaderBirth} 的 `auth`)—— 唯一铸点;席本身是 side-query / WebFetch 摘要面同一只工厂 `createPerModelAuthSeat`
95
+ * (spec 自带的席折成 `upstream`:先问它、它没意见才按模型解;不覆盖。声明了钥匙却拿不到 ⇒ 抛,与任务面同一只毒丸,绝不回落网关钥)。
96
+ * 律(与任务面 `resolveSpec` 同读法:spec 出生那一拍从活引用取值):resolver 在**腿出生那一拍**取一次 —— 那一拍与这条腿的 Runner 构造同一同步段,Runner 构造时把模型目录
97
+ * 收成私有副本,所以钥与目录同代;中心 apply 之后出生的腿取到新的那一只。不按调用现取:在飞腿的目录是上一代,现取会把新家的钥配上旧家的端点。
98
+ */
99
+ export declare function createLeaderLegAuth(getKeyResolver: () => KeyResolver): LeaderBirth["auth"];
99
100
  export declare function createLeaderFace(ctx: LeaderCtx): ReturnType<typeof createLeaderEndpoint> | undefined;
100
101
  //# sourceMappingURL=leader.d.ts.map
@@ -2,9 +2,15 @@ import { createLeaderEndpoint } from "../leader/endpoint.js";
2
2
  import { seesRunAs } from "../http/owner-access.js";
3
3
  import { claimCallerOf } from "../security.js";
4
4
  import { createLeaderParkExpirer, createLeaderRunner } from "../leader/wire.js";
5
- import { buildDeploymentPostureSeats, buildHandsBand } from "./runner-deps.js";
5
+ import { join } from "node:path";
6
+ import { NodeExecutionEnv } from "@sema-agent/core";
7
+ import { applyRuntimeGovernance } from "../runtime-governance.js";
8
+ import { createApprovalBaselinePolicy, createDeploymentGovernanceInputs } from "../deployment-governance.js";
6
9
  import { hasApprovalListIntent } from "../approval.js";
10
+ import { createLegPathAdjudication } from "./leg-path-adjudication.js";
11
+ import { sandboxPathEnvSlots } from "./deferred-sandbox-path-env.js";
7
12
  import { WORKSPACE_SNAPSHOT_BUCKET_DEFAULT } from "../object-store-buckets.js";
13
+ import { createPerModelAuthSeat } from "./side-query-lane.js";
8
14
  export function leaderK8sMinioGap(leaderEnabled, leaderProvider, hasS3) {
9
15
  if (!(leaderEnabled && leaderProvider === "k8s" && !hasS3))
10
16
  return null;
@@ -31,8 +37,27 @@ export function buildLeaderObjectStore(env = process.env) {
31
37
  return {};
32
38
  return { s3: { endpoint, bucket: env.MINIO_BUCKET ?? WORKSPACE_SNAPSHOT_BUCKET_DEFAULT, accessKey, secretKey, ...(env.MINIO_REGION ? { region: env.MINIO_REGION } : {}) } };
33
39
  }
40
+ export function createLeaderLegGovernance(config, localRoot, logger) {
41
+ return {
42
+ govern: (spec, legSessionId) => applyRuntimeGovernance(spec, createDeploymentGovernanceInputs(config, createLegPathAdjudication(config, {
43
+ sessionId: legSessionId,
44
+ leg: "leader",
45
+ hostArm: () => {
46
+ const gateCwd = join(config.localDataRoot ?? localRoot, "fs-write-gate-unrooted");
47
+ return { env: new NodeExecutionEnv({ cwd: gateCwd }), cwd: gateCwd };
48
+ },
49
+ }, { slots: sandboxPathEnvSlots, logger }))),
50
+ baseline: (kind) => createApprovalBaselinePolicy(config, { kind }),
51
+ };
52
+ }
53
+ export function createLeaderLegAuth(getKeyResolver) {
54
+ return (upstream) => {
55
+ const resolver = getKeyResolver();
56
+ return createPerModelAuthSeat(() => resolver, upstream !== undefined ? { upstream } : {});
57
+ };
58
+ }
34
59
  export function createLeaderFace(ctx) {
35
- const { config, logger, brain, pricing, executionEnvFactory, toolResultStore, sessionStore, checkpointStore, checkpointCtxSealing, governanceSeams } = ctx;
60
+ const { config, logger, executionEnvFactory, toolResultStore, sessionStore, checkpointStore, checkpointCtxSealing } = ctx;
36
61
  const leaderMinio = buildLeaderObjectStore();
37
62
  const leaderProvider = config.remoteExec.provider;
38
63
  const leaderRunStore = ctx.backend?.leaderRun?.();
@@ -45,22 +70,12 @@ export function createLeaderFace(ctx) {
45
70
  (leaderProvider === "k8s" && "s3" in leaderMinio && executionEnvFactory) ||
46
71
  (leaderProvider === "host" && executionEnvFactory))
47
72
  ? createLeaderEndpoint(createLeaderRunner({
48
- brain, models: config.models, roles: config.roles, tiers: config.tiers, pricing, logger,
49
- governance: {
50
- compliancePostureResolver: governanceSeams.compliancePostureResolver,
51
- lockedConfig: governanceSeams.lockedConfig,
52
- retentionPolicy: governanceSeams.retentionPolicy,
53
- },
54
- deploymentPosture: () => buildDeploymentPostureSeats(config),
73
+ logger,
74
+ plane: () => ctx.deploymentPlane({ commitCoAuthor: undefined }),
75
+ ...createLeaderLegGovernance(config, ctx.localRoot, logger),
76
+ auth: createLeaderLegAuth(ctx.getKeyResolver),
77
+ legSlots: sandboxPathEnvSlots,
55
78
  autonomy: () => config.autonomy,
56
- ...(ctx.tracer ? { tracer: ctx.tracer } : {}),
57
- ...(config.usageWindows && ctx.usageWindowStore
58
- ? { usageWindows: config.usageWindows, usageWindowStore: ctx.usageWindowStore }
59
- : {}),
60
- ...(ctx.promptSource ? { promptSource: ctx.promptSource } : {}),
61
- ...(ctx.onError ? { onError: ctx.onError } : {}),
62
- mods: ctx.deploymentMods,
63
- hands: buildHandsBand(config, undefined),
64
79
  fanoutEnabled: config.leaderFanoutEnabled,
65
80
  ...(process.env.MODEL_ROUTER_ID ? { routerModel: process.env.MODEL_ROUTER_ID } : {}),
66
81
  ...(leaderProvider === "e2b" ? { e2bApiKey: config.remoteExec.apiKey } : {}),
@@ -69,19 +84,14 @@ export function createLeaderFace(ctx) {
69
84
  ...(toolResultStore ? { toolResultStore } : {}),
70
85
  ...(leaderProvider === "k8s" ? { workspace: "/workspace" } : {}),
71
86
  sessionStore,
87
+ approvalListInForce: () => hasApprovalListIntent(config),
72
88
  ...(checkpointStore
73
89
  ? {
74
- durable: () => hasApprovalListIntent(config)
75
- ? {
76
- checkpointStore,
77
- ctxSealer: checkpointCtxSealing,
78
- requireApproval: config.approvalRequire,
79
- deny: config.approvalDeny,
80
- autoBudget: config.approvalAutoBudget,
81
- neverAuto: config.approvalNeverAuto,
82
- ...(config.approvalTimeoutSec > 0 ? { ttlMs: config.approvalTimeoutSec * 1000 } : {}),
83
- }
84
- : undefined,
90
+ durable: () => ({
91
+ checkpointStore,
92
+ ctxSealer: checkpointCtxSealing,
93
+ ...(config.approvalTimeoutSec > 0 ? { ttlMs: config.approvalTimeoutSec * 1000 } : {}),
94
+ }),
85
95
  }
86
96
  : {}),
87
97
  }), {
@@ -0,0 +1,40 @@
1
+ /**
2
+ * **腿的路径裁决**(守卫集 / 写门裁决用的 env 与基准)—— 唯一属主。读者三处同调:HTTP 提交 / 续跑腿(`boot/resolve-spec.ts`)、停驻赎回腿
3
+ * (`boot/parked-revive-gate.ts`)、leader 车道的每一条腿(`boot/leader.ts` 交给出生口的治理折叠)。
4
+ *
5
+ * 律(一句):车道分形只问部署形表一行(`sandboxPathAdjudication`)—— 文件平面不在本进程盘上 ⇒ 代理({@link DeferredSandboxPathEnv})在裁决时刻按
6
+ * **这条腿的会话号**去槽表取那台真沙盒;在本进程盘上 ⇒ 腿自己给的 host 臂(真 fs;cwd / 真任务根是腿的知识,本口不猜)。两臂同带执行环境的 home
7
+ * (`~/` 形规则的基,唯一属主 `executionLaneHomeDir`)。
8
+ *
9
+ * 槽表的写者:部署工厂的装饰器(`withSandboxPathEnvSlot`,工厂铸的 env 按 `ctx.sessionId` 登记),以及**手里握着 env 的腿**自己登记 —— leader 的静态
10
+ * 车道 worker 与集成修复腿的 env 不是部署工厂为那条腿铸的,由 leader 按跑它的会话号登记进**同一只**槽表(`leader/wire.ts`)。没登记 ⇒ 代理取不到真身
11
+ * ⇒ 守卫 fail-closed(每一次结构化写被拒)—— 方向对,但那是把腿瘫痪,所以登记是承重的。
12
+ */
13
+ import type { ServiceConfig } from "../config.js";
14
+ import type { PathAdjudication } from "../deployment-governance.js";
15
+ import { DEPLOYMENT_SHAPE_PREDICATES } from "../deployment-shape.js";
16
+ import { executionLaneHomeDir } from "../execution-lane-caps.js";
17
+ import { type SandboxPathEnvSlots } from "./deferred-sandbox-path-env.js";
18
+ /** 本口读的部署切面:车道形(部署形表行的输入)+ 执行环境 home 的运维声明。 */
19
+ export type LegPathAdjudicationConfigView = Parameters<typeof DEPLOYMENT_SHAPE_PREDICATES.sandboxPathAdjudication.holds>[0] & Parameters<typeof executionLaneHomeDir>[0] & {
20
+ readonly remoteExec: ServiceConfig["remoteExec"];
21
+ };
22
+ /** 一条腿在裁决面上的位置。 */
23
+ export interface LegPathPlace {
24
+ /** 槽表的键 = 跑这条腿的会话号(沙盒车道上代理按它取真身)。缺席 ⇒ 代理恒 fail-closed。 */
25
+ readonly sessionId: string | undefined;
26
+ /** 槽取不到时那一行 warn 上的腿名(缺席 = 不写这个字段)。 */
27
+ readonly leg?: string;
28
+ /** host 语义车道上这条腿的真 fs 裁决(env + 相对基准 + 真任务根):每条腿各有自己的 cwd 知识,本口只在 host 车道调它。 */
29
+ readonly hostArm: () => Pick<PathAdjudication, "env" | "cwd" | "taskRoot">;
30
+ }
31
+ /** 代理的两件(进程内唯一的槽表 + 留痕面)。 */
32
+ export interface LegPathSeat {
33
+ readonly slots: SandboxPathEnvSlots;
34
+ readonly logger: {
35
+ warn: (event: string, fields?: Record<string, unknown>) => void;
36
+ };
37
+ }
38
+ /** 活对象(代理 env)⇒ `create*`。每次调用现铸(读活 config;代理每实例留痕一次)。 */
39
+ export declare function createLegPathAdjudication(config: LegPathAdjudicationConfigView, place: LegPathPlace, seat: LegPathSeat): PathAdjudication;
40
+ //# sourceMappingURL=leg-path-adjudication.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { DEPLOYMENT_SHAPE_PREDICATES } from "../deployment-shape.js";
2
+ import { executionLaneHomeDir } from "../execution-lane-caps.js";
3
+ import { DeferredSandboxPathEnv } from "./deferred-sandbox-path-env.js";
4
+ export function createLegPathAdjudication(config, place, seat) {
5
+ const home = executionLaneHomeDir(config);
6
+ const homeBase = home !== undefined ? { taskHome: home } : {};
7
+ if (!DEPLOYMENT_SHAPE_PREDICATES.sandboxPathAdjudication.holds(config))
8
+ return { ...place.hostArm(), ...homeBase };
9
+ return {
10
+ env: new DeferredSandboxPathEnv({
11
+ sessionId: place.sessionId,
12
+ slots: seat.slots,
13
+ logger: { warn: (event, fields) => seat.logger.warn(event, { ...(fields ?? {}), lane: config.remoteExec.provider, ...(place.leg !== undefined ? { leg: place.leg } : {}) }) },
14
+ }),
15
+ ...homeBase,
16
+ };
17
+ }
18
+ //# sourceMappingURL=leg-path-adjudication.js.map
@@ -326,8 +326,9 @@ export declare function judgeConsolidationValve(input: ConsolidationValveInput):
326
326
  export declare function buildConsolidationValveAudit(input: {
327
327
  /** 阀门判决({@link resolveConsolidationValve} 的 `enabled` + `source`)。 */
328
328
  valve: Pick<ConsolidationValve, "enabled" | "source">;
329
- /** 这台部署配了任何一把 service 凭证吗(`config.authToken` 或 `config.authTokens` 非空)。 */
330
- hasServiceAuth: boolean;
329
+ /** 这台部署接没接任何一类过凭据门的来源(service 凭据 / 鉴权桥;部署形表行 `credentialGateSource`,写门律 5 在部署上的投影)。
330
+ * 没接 ⇒ 没有一次请求过得了写门(逃生口之外)。 */
331
+ credentialGateSource: boolean;
331
332
  /** 本地开发的显式逃生口(`ALLOW_UNAUTHED_WRITES=true`)。 */
332
333
  allowUnauthedWrites: boolean;
333
334
  }): {
@@ -282,17 +282,17 @@ export function buildConsolidationValveAudit(input) {
282
282
  if (!input.valve.enabled || input.valve.source !== "explicit")
283
283
  return { warnings: [] };
284
284
  const warnings = [];
285
- if (!input.hasServiceAuth && !input.allowUnauthedWrites) {
285
+ if (!input.credentialGateSource && !input.allowUnauthedWrites) {
286
286
  warnings.push({
287
287
  tag: "memory_consolidation_run_credential_gated",
288
- detail: "MEMORY_CONSOLIDATION_DRIVER=on armed the consolidation valve, but this worker has NO service credential " +
289
- "(SERVICE_AUTH_TOKEN / per-system tokens are unset) and ALLOW_UNAUTHED_WRITES is not on. POST " +
288
+ detail: "MEMORY_CONSOLIDATION_DRIVER=on armed the consolidation valve, but this worker accepts NO credential on its write face " +
289
+ "(SERVICE_AUTH_TOKEN / per-system tokens are unset and no SSO bridge verifies registry sign-in tokens) and ALLOW_UNAUTHED_WRITES is not on. POST " +
290
290
  "/v1/admin/memory/consolidation/run runs the model, so it rides the billable-submit gate and is refused " +
291
- "with 503 auth.service_token_required BEFORE it reaches the route — while capabilities." +
291
+ "with 503 auth.service_token_required BEFORE it reaches the route for every caller — while capabilities." +
292
292
  "memoryConsolidationDriver still reports true (a family-wide gap this worker shares with adoption / memory " +
293
293
  "bundle / memory compliance; it is documented, not silently accepted). GET /v1/admin/memory/consolidation " +
294
- "is unaffected (it runs no model). Set SERVICE_AUTH_TOKEN, or set ALLOW_UNAUTHED_WRITES=true for local " +
295
- "development only.",
294
+ "is unaffected (it runs no model). Set SERVICE_AUTH_TOKEN (or configure the SSO bridge, AUTH_BRIDGE_ISSUER, so verified " +
295
+ "sign-in tokens pass), or set ALLOW_UNAUTHED_WRITES=true for local development only.",
296
296
  });
297
297
  }
298
298
  return { warnings };