@sema-agent/server 7.138.0 → 7.140.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 (332) hide show
  1. package/MIGRATION.md +457 -7
  2. package/README.md +7 -4
  3. package/README.zh-CN.md +6 -4
  4. package/USAGE.md +91 -41
  5. package/deploy/sema-up/README.md +1 -1
  6. package/deploy/sema-up/lib/lanes.json +3 -2
  7. package/dist/adoption/runner.js +1 -1
  8. package/dist/adoption/sql.js +1 -1
  9. package/dist/adoption/wire.d.ts +3 -3
  10. package/dist/approval-card.d.ts +26 -26
  11. package/dist/bench/s1/arms.d.ts +1 -1
  12. package/dist/bench/s1/arms.js +1 -3
  13. package/dist/bench/s1/live-deps.js +3 -2
  14. package/dist/bench/s1/row.d.ts +5 -2
  15. package/dist/bench/s1/row.js +2 -22
  16. package/dist/bench/s1/run-firm.js +2 -2
  17. package/dist/boot/adoption.js +1 -1
  18. package/dist/boot/device-lane.d.ts +8 -3
  19. package/dist/boot/device-lane.js +7 -2
  20. package/dist/boot/execution-env.d.ts +4 -2
  21. package/dist/boot/execution-env.js +28 -34
  22. package/dist/boot/execution-lane.d.ts +9 -1
  23. package/dist/boot/execution-lane.js +6 -1
  24. package/dist/boot/governance-seams.d.ts +3 -2
  25. package/dist/boot/governance-seams.js +9 -11
  26. package/dist/boot/memory-boundary.d.ts +14 -51
  27. package/dist/boot/memory-boundary.js +10 -20
  28. package/dist/boot/memory-consolidation.d.ts +15 -11
  29. package/dist/boot/memory-consolidation.js +25 -14
  30. package/dist/boot/resolve-spec.d.ts +4 -6
  31. package/dist/boot/resolve-spec.js +10 -13
  32. package/dist/boot/retention-lane.d.ts +5 -5
  33. package/dist/boot/retention-lane.js +0 -6
  34. package/dist/boot/runner-deps.d.ts +6 -4
  35. package/dist/boot/runner-deps.js +3 -1
  36. package/dist/boot/session-faces.d.ts +0 -3
  37. package/dist/boot/session-faces.js +15 -8
  38. package/dist/boot/stage-02-web-admin-pull.js +2 -2
  39. package/dist/boot/stage-03-store-backend.d.ts +2 -6
  40. package/dist/boot/stage-03-store-backend.js +2 -3
  41. package/dist/boot/stage-04-stores.d.ts +2 -6
  42. package/dist/boot/stage-04-stores.js +5 -5
  43. package/dist/boot/stage-05-execution-env.d.ts +2 -6
  44. package/dist/boot/stage-05-execution-env.js +2 -2
  45. package/dist/boot/stage-06-runners.d.ts +2 -6
  46. package/dist/boot/stage-06-runners.js +2 -3
  47. package/dist/boot/stage-07-capability-layer.d.ts +2 -6
  48. package/dist/boot/stage-08-reapers.d.ts +2 -6
  49. package/dist/boot/stage-09-leader.d.ts +2 -6
  50. package/dist/boot/stage-09-leader.js +1 -2
  51. package/dist/boot/stage-10-http-server.d.ts +2 -6
  52. package/dist/boot/stage-10-http-server.js +7 -6
  53. package/dist/boot/stores.d.ts +3 -6
  54. package/dist/boot/stores.js +27 -40
  55. package/dist/boot/task-list-lane.d.ts +1 -1
  56. package/dist/boot/task-list-lane.js +1 -1
  57. package/dist/boot/web-admin.js +37 -11
  58. package/dist/capabilities/execution-lane.d.ts +2 -2
  59. package/dist/capabilities/mcp-probe.js +1 -1
  60. package/dist/capabilities/scenarios.d.ts +1 -1
  61. package/dist/capability-facts.d.ts +15 -7
  62. package/dist/capability-facts.js +8 -3
  63. package/dist/config-catalog.js +9 -8
  64. package/dist/config-invariants.d.ts +23 -3
  65. package/dist/config-invariants.js +42 -0
  66. package/dist/config-provider.d.ts +33 -37
  67. package/dist/config-provider.js +51 -30
  68. package/dist/config-types.d.ts +21 -7
  69. package/dist/config.d.ts +33 -0
  70. package/dist/config.js +46 -16
  71. package/dist/delegated-session-owner.d.ts +4 -3
  72. package/dist/delegated-session-owner.js +1 -1
  73. package/dist/deployment-shape.d.ts +10 -9
  74. package/dist/deployment-shape.js +4 -4
  75. package/dist/device-enrollment.d.ts +41 -2
  76. package/dist/device-enrollment.js +27 -12
  77. package/dist/device-store.d.ts +58 -85
  78. package/dist/device-store.js +19 -49
  79. package/dist/device-ws-hub.js +2 -1
  80. package/dist/env-name-allowlist-knobs.d.ts +5 -4
  81. package/dist/exec-cut.d.ts +60 -0
  82. package/dist/exec-cut.js +36 -0
  83. package/dist/execution-lane-caps.d.ts +115 -105
  84. package/dist/execution-lane-caps.js +76 -82
  85. package/dist/execution-placement.d.ts +259 -0
  86. package/dist/execution-placement.js +199 -0
  87. package/dist/field-conflict.d.ts +3 -2
  88. package/dist/field-conflict.js +1 -0
  89. package/dist/hosted-posture.d.ts +2 -2
  90. package/dist/http/admission.js +8 -19
  91. package/dist/http/checkpoint-ctx.d.ts +21 -12
  92. package/dist/http/checkpoint-ctx.js +4 -2
  93. package/dist/http/claimed-run.d.ts +1 -1
  94. package/dist/http/durable-run-leg.js +9 -5
  95. package/dist/http/execution-context.d.ts +218 -0
  96. package/dist/http/execution-context.js +330 -0
  97. package/dist/http/memory-compliance-failure-reply.d.ts +3 -1
  98. package/dist/http/memory-compliance-failure-reply.js +5 -0
  99. package/dist/http/memory-layer-reply.d.ts +30 -0
  100. package/dist/http/memory-layer-reply.js +24 -0
  101. package/dist/http/resume-legs.js +63 -36
  102. package/dist/http/retired-service-deps.d.ts +1 -1
  103. package/dist/http/retired-service-deps.js +1 -1
  104. package/dist/http/route-ctx.d.ts +14 -8
  105. package/dist/http/routes/adoption.js +1 -1
  106. package/dist/http/routes/background.d.ts +29 -1
  107. package/dist/http/routes/background.js +29 -2
  108. package/dist/http/routes/devices.d.ts +13 -19
  109. package/dist/http/routes/devices.js +21 -26
  110. package/dist/http/routes/memory-bundle.js +3 -0
  111. package/dist/http/routes/memory-compliance.js +8 -1
  112. package/dist/http/routes/memory-consolidation.js +12 -1
  113. package/dist/http/routes/memory-origin.js +14 -2
  114. package/dist/http/routes/memory-policy.js +5 -0
  115. package/dist/http/routes/session-sync.js +110 -15
  116. package/dist/http/routes/sessions.d.ts +6 -0
  117. package/dist/http/routes/sessions.js +143 -22
  118. package/dist/http/routes/side-query.d.ts +12 -4
  119. package/dist/http/routes/side-query.js +4 -5
  120. package/dist/http/routes/tasks.js +41 -33
  121. package/dist/http/server.d.ts +40 -44
  122. package/dist/http/server.js +13 -2
  123. package/dist/http/session-inherit-env.d.ts +3 -4
  124. package/dist/http/session-inherit-env.js +1 -1
  125. package/dist/http/wire-types.d.ts +8 -12
  126. package/dist/identity-source.d.ts +1 -1
  127. package/dist/identity-source.js +1 -1
  128. package/dist/index.d.ts +1 -0
  129. package/dist/lane-home-probe.d.ts +68 -42
  130. package/dist/lane-home-probe.js +53 -30
  131. package/dist/leader/wire.js +5 -4
  132. package/dist/memory-bundle-engine.d.ts +16 -9
  133. package/dist/memory-bundle-engine.js +29 -6
  134. package/dist/memory-operator-faces.d.ts +85 -30
  135. package/dist/memory-operator-faces.js +136 -30
  136. package/dist/memory-project-layer.d.ts +3 -21
  137. package/dist/memory-project-layer.js +11 -8
  138. package/dist/memory-scope-stores.d.ts +73 -0
  139. package/dist/memory-scope-stores.js +86 -0
  140. package/dist/memory-scope.d.ts +29 -5
  141. package/dist/memory-scope.js +16 -4
  142. package/dist/memory-sync-client.d.ts +70 -18
  143. package/dist/memory-sync-client.js +215 -117
  144. package/dist/memory-sync.d.ts +1 -1
  145. package/dist/memory-sync.js +3 -2
  146. package/dist/observability/cost-taxonomy.d.ts +2 -2
  147. package/dist/observability/fail-open.d.ts +12 -0
  148. package/dist/observability/fail-open.js +12 -0
  149. package/dist/observability/run-terminal.js +0 -1
  150. package/dist/orchestration/workflow-notify-journal.js +4 -4
  151. package/dist/org-memory-admission.d.ts +4 -3
  152. package/dist/org-memory-admission.js +6 -6
  153. package/dist/parked-decide.d.ts +34 -9
  154. package/dist/parked-decide.js +12 -19
  155. package/dist/parked-revive-surface.d.ts +12 -15
  156. package/dist/parked-revive-surface.js +3 -6
  157. package/dist/peer-seat.d.ts +13 -7
  158. package/dist/peer-seat.js +37 -3
  159. package/dist/plugins/adoption-log-sql.js +4 -4
  160. package/dist/plugins/approval-ask-store-file.d.ts +7 -0
  161. package/dist/plugins/approval-ask-store-file.js +11 -0
  162. package/dist/plugins/approval-ask-store-memory.d.ts +6 -0
  163. package/dist/plugins/approval-ask-store-memory.js +12 -0
  164. package/dist/plugins/approval-ask-store-sql.d.ts +22 -5
  165. package/dist/plugins/approval-ask-store-sql.js +44 -26
  166. package/dist/plugins/approval-nonce-store.js +4 -4
  167. package/dist/plugins/blob-backend.d.ts +4 -4
  168. package/dist/plugins/blob-backend.js +7 -7
  169. package/dist/plugins/breaker-state-sql.js +2 -2
  170. package/dist/plugins/caching-session-store.d.ts +6 -2
  171. package/dist/plugins/caching-session-store.js +9 -3
  172. package/dist/plugins/checkpoint-index-columns.js +2 -2
  173. package/dist/plugins/checkpoint-store-sql.d.ts +6 -5
  174. package/dist/plugins/checkpoint-store-sql.js +21 -23
  175. package/dist/plugins/device-store-sql.d.ts +25 -51
  176. package/dist/plugins/device-store-sql.js +68 -122
  177. package/dist/plugins/ensure-index.d.ts +1 -2
  178. package/dist/plugins/execution-placement-sql.d.ts +151 -0
  179. package/dist/plugins/execution-placement-sql.js +223 -0
  180. package/dist/plugins/file-history-store-sql.d.ts +9 -8
  181. package/dist/plugins/file-history-store-sql.js +9 -9
  182. package/dist/plugins/file-run-store.d.ts +6 -1
  183. package/dist/plugins/file-run-store.js +4 -0
  184. package/dist/plugins/fork-routing-session-store.d.ts +6 -0
  185. package/dist/plugins/fork-routing-session-store.js +16 -0
  186. package/dist/plugins/image-bake-store-sql.js +9 -9
  187. package/dist/plugins/image-index-sql.js +11 -11
  188. package/dist/plugins/leader-run-store-sql.js +4 -4
  189. package/dist/plugins/local-session-store.d.ts +149 -50
  190. package/dist/plugins/local-session-store.js +382 -107
  191. package/dist/plugins/mailbox-store-sql.d.ts +2 -1
  192. package/dist/plugins/mailbox-store-sql.js +4 -4
  193. package/dist/plugins/memory-engine-tidb.js +5 -5
  194. package/dist/plugins/memory-key-guards.d.ts +4 -0
  195. package/dist/plugins/memory-key-guards.js +1 -0
  196. package/dist/plugins/memory-optout-grant-store-sql.js +1 -1
  197. package/dist/plugins/memory-run-store.d.ts +1 -1
  198. package/dist/plugins/memory-sync-store-tidb.js +3 -3
  199. package/dist/plugins/one-time-migrations.d.ts +117 -8
  200. package/dist/plugins/one-time-migrations.js +408 -38
  201. package/dist/plugins/org-delivery-quota-store.js +2 -2
  202. package/dist/plugins/outcome-ledger-sql.d.ts +2 -2
  203. package/dist/plugins/outcome-ledger-sql.js +2 -2
  204. package/dist/plugins/permission-rule-store-sql.d.ts +17 -19
  205. package/dist/plugins/permission-rule-store-sql.js +29 -32
  206. package/dist/plugins/pg-pool.d.ts +7 -3
  207. package/dist/plugins/pg-session-storage.d.ts +31 -20
  208. package/dist/plugins/pg-session-storage.js +120 -52
  209. package/dist/plugins/remote-env-adb.d.ts +18 -19
  210. package/dist/plugins/remote-env-adb.js +91 -66
  211. package/dist/plugins/remote-env-device.d.ts +23 -31
  212. package/dist/plugins/remote-env-device.js +19 -17
  213. package/dist/plugins/remote-env-e2b.d.ts +27 -21
  214. package/dist/plugins/remote-env-e2b.js +91 -45
  215. package/dist/plugins/remote-env-file-error.d.ts +3 -1
  216. package/dist/plugins/remote-env-file-error.js +9 -3
  217. package/dist/plugins/remote-env-host.d.ts +31 -34
  218. package/dist/plugins/remote-env-host.js +91 -72
  219. package/dist/plugins/remote-env-k8s.d.ts +13 -29
  220. package/dist/plugins/remote-env-k8s.js +63 -55
  221. package/dist/plugins/remote-env-local-docker.d.ts +24 -12
  222. package/dist/plugins/remote-env-local-docker.js +49 -61
  223. package/dist/plugins/remote-env-ssh.d.ts +11 -19
  224. package/dist/plugins/remote-env-ssh.js +74 -57
  225. package/dist/plugins/remote-shell.d.ts +100 -3
  226. package/dist/plugins/remote-shell.js +166 -2
  227. package/dist/plugins/resume-anchor-store-sql.js +2 -2
  228. package/dist/plugins/retention-lane-store-sql.d.ts +1 -1
  229. package/dist/plugins/retention-lane-store-sql.js +2 -2
  230. package/dist/plugins/retention-store-sql.d.ts +10 -7
  231. package/dist/plugins/retention-store-sql.js +13 -7
  232. package/dist/plugins/run-store-sql.d.ts +13 -3
  233. package/dist/plugins/run-store-sql.js +20 -15
  234. package/dist/plugins/schema-consistency.d.ts +21 -11
  235. package/dist/plugins/schema-consistency.js +15 -9
  236. package/dist/plugins/schema-drift-sentence.d.ts +27 -0
  237. package/dist/plugins/schema-drift-sentence.js +38 -0
  238. package/dist/plugins/schema-ensure-legs.d.ts +2 -3
  239. package/dist/plugins/schema-ensure-legs.js +2 -2
  240. package/dist/plugins/schema-live-columns.d.ts +1 -1
  241. package/dist/plugins/session-capture-record-store-sql.js +1 -1
  242. package/dist/plugins/session-fork.d.ts +54 -0
  243. package/dist/plugins/session-fork.js +38 -1
  244. package/dist/plugins/session-row-sql.d.ts +22 -0
  245. package/dist/plugins/session-row-sql.js +81 -0
  246. package/dist/plugins/session-rules-column.d.ts +1 -1
  247. package/dist/plugins/session-rules-column.js +1 -1
  248. package/dist/plugins/session-store.d.ts +1 -1
  249. package/dist/plugins/session-workspace-cell.d.ts +1 -1
  250. package/dist/plugins/session-workspace-cell.js +1 -1
  251. package/dist/plugins/shared-memory-store-sql.js +2 -2
  252. package/dist/plugins/sql-driver.d.ts +10 -5
  253. package/dist/plugins/sql-driver.js +6 -6
  254. package/dist/plugins/sql-errors.js +1 -1
  255. package/dist/plugins/store-backend.d.ts +5 -7
  256. package/dist/plugins/store-backend.js +23 -11
  257. package/dist/plugins/store-contracts.d.ts +25 -5
  258. package/dist/plugins/task-list-store-sql.js +11 -11
  259. package/dist/plugins/tidb-pool.d.ts +12 -7
  260. package/dist/plugins/tidb-pool.js +13 -7
  261. package/dist/plugins/tidb-session-storage.js +4 -4
  262. package/dist/plugins/tidb-session-store.d.ts +57 -26
  263. package/dist/plugins/tidb-session-store.js +127 -59
  264. package/dist/plugins/tool-result-store-sql.d.ts +5 -4
  265. package/dist/plugins/tool-result-store-sql.js +21 -13
  266. package/dist/plugins/user-input-ledger-sql.js +2 -2
  267. package/dist/plugins/workflow-journal-store-sql.js +5 -5
  268. package/dist/plugins/workflow-run-store-sql.js +19 -19
  269. package/dist/plugins/write-behind-counter.d.ts +2 -3
  270. package/dist/plugins/write-behind-counter.js +5 -5
  271. package/dist/project-memory.d.ts +9 -15
  272. package/dist/project-memory.js +5 -4
  273. package/dist/request-key-closure.js +1 -1
  274. package/dist/request-value-closure.d.ts +6 -7
  275. package/dist/request-value-closure.js +1 -3
  276. package/dist/resource-suspend.d.ts +14 -12
  277. package/dist/resource-suspend.js +1 -1
  278. package/dist/resource-window.d.ts +4 -3
  279. package/dist/run-local.d.ts +6 -0
  280. package/dist/run-local.js +34 -35
  281. package/dist/runs.d.ts +10 -5
  282. package/dist/runs.js +52 -66
  283. package/dist/security.d.ts +38 -12
  284. package/dist/security.js +8 -2
  285. package/dist/server-secret-env.d.ts +9 -5
  286. package/dist/session-children-retire.d.ts +27 -9
  287. package/dist/session-children-retire.js +9 -5
  288. package/dist/session-incarnation.d.ts +20 -10
  289. package/dist/session-incarnation.js +5 -3
  290. package/dist/session-policy-wire.d.ts +1 -1
  291. package/dist/session-row.d.ts +114 -5
  292. package/dist/session-row.js +55 -5
  293. package/dist/session-titler.d.ts +2 -2
  294. package/dist/sql-engine-posture.d.ts +1 -1
  295. package/dist/sql-engine-posture.js +1 -1
  296. package/dist/{plugins → stores-sql}/background-agent-store-sql.d.ts +2 -2
  297. package/dist/{plugins → stores-sql}/background-agent-store-sql.js +8 -8
  298. package/dist/{plugins → stores-sql}/session-policy-store-sql.d.ts +7 -5
  299. package/dist/{plugins → stores-sql}/session-policy-store-sql.js +12 -12
  300. package/dist/{plugins → stores-sql}/usage-window-store-sql.d.ts +1 -1
  301. package/dist/{plugins → stores-sql}/usage-window-store-sql.js +3 -3
  302. package/dist/task-a2a.d.ts +1 -1
  303. package/dist/task-a2a.js +5 -6
  304. package/dist/task-cwd.d.ts +6 -1
  305. package/dist/task-mcp.d.ts +22 -9
  306. package/dist/task-mcp.js +17 -9
  307. package/dist/terminal.d.ts +27 -0
  308. package/dist/terminal.js +6 -0
  309. package/dist/tool-approval.d.ts +6 -0
  310. package/dist/tool-approval.js +8 -1
  311. package/dist/trace/project.d.ts +1 -0
  312. package/dist/trace/project.js +1 -0
  313. package/dist/trace/redact.d.ts +3 -1
  314. package/dist/trace/redact.js +80 -28
  315. package/dist/trace/self-minted-wire.d.ts +169 -2
  316. package/dist/trace/self-minted-wire.js +54 -1
  317. package/dist/url-refusal.d.ts +1 -1
  318. package/dist/web-admin-client/apply-effective.d.ts +17 -3
  319. package/dist/web-admin-client/apply-effective.js +20 -10
  320. package/dist/web-admin-client/candidate-gate.d.ts +11 -7
  321. package/dist/web-admin-client/candidate-gate.js +1 -1
  322. package/dist/web-admin-client/http-client.d.ts +5 -4
  323. package/dist/web-admin-client/http-client.js +2 -2
  324. package/dist/web-admin-client/read-warnings.d.ts +7 -17
  325. package/dist/web-admin-client/read-warnings.js +5 -9
  326. package/dist/web-admin-client/skills-mcp.js +3 -2
  327. package/dist/web-admin-client/types.d.ts +6 -0
  328. package/package.json +3 -3
  329. package/wire-changes/server@7.139.0.json +348 -0
  330. package/wire-changes/server@7.140.0.json +184 -0
  331. package/dist/http/device-placement.d.ts +0 -175
  332. package/dist/http/device-placement.js +0 -145
@@ -1,6 +1,7 @@
1
1
  import { homedir } from "node:os";
2
- import { EXECUTION_LANE_WORDS as DECLARABLE_LANE_WORDS, EXECUTION_LANES } from "@sema-agent/settings-schema/execution-lanes";
3
- import { DECLARE_HOME_REMEDY, buildHomeAbsentNote } from "./lane-home-probe.js";
2
+ import { StubExecutionEnv } from "@sema-agent/core";
3
+ import { EXECUTION_LANE_WORDS as DECLARABLE_LANE_WORDS, EXECUTION_LANES, isBlankCoordinate } from "@sema-agent/settings-schema/execution-lanes";
4
+ import { DECLARE_HOME_REMEDY, LANE_HOME_UNDECLARED_EVENT, LANE_HOME_UNMEASURED_EVENT, buildHomeAbsentNote, buildHomeUnmeasuredNote } from "./lane-home-probe.js";
4
5
  const NO = "unsupported";
5
6
  const YES = "supported";
6
7
  const SU = "single-user-only";
@@ -13,15 +14,8 @@ export function executionLaneCaps(lane) {
13
14
  scheduler: NO,
14
15
  lsp: NO,
15
16
  sandboxSendUserFile: NO,
16
- isolation: NO,
17
- suspendable: NO,
18
17
  remoteScratchpad: NO,
19
- sandboxPathAdjudication: NO,
20
18
  worktreeIsolation: NO,
21
- memoryPersistenceCapable: NO,
22
- hostFilePlane: YES,
23
- coreRemoteExecutionEnv: NO,
24
- canonicalPathAuthority: NO,
25
19
  tenantSeparation: YES,
26
20
  };
27
21
  case "host":
@@ -31,15 +25,8 @@ export function executionLaneCaps(lane) {
31
25
  scheduler: SU,
32
26
  lsp: SU,
33
27
  sandboxSendUserFile: NO,
34
- isolation: NO,
35
- suspendable: NO,
36
28
  remoteScratchpad: NO,
37
- sandboxPathAdjudication: NO,
38
29
  worktreeIsolation: YES,
39
- memoryPersistenceCapable: YES,
40
- hostFilePlane: YES,
41
- coreRemoteExecutionEnv: YES,
42
- canonicalPathAuthority: YES,
43
30
  tenantSeparation: executionLaneRow(lane).tenantSeparation,
44
31
  };
45
32
  case "e2b":
@@ -49,15 +36,8 @@ export function executionLaneCaps(lane) {
49
36
  scheduler: NO,
50
37
  lsp: NO,
51
38
  sandboxSendUserFile: YES,
52
- isolation: YES,
53
- suspendable: YES,
54
39
  remoteScratchpad: YES,
55
- sandboxPathAdjudication: YES,
56
40
  worktreeIsolation: NO,
57
- memoryPersistenceCapable: NO,
58
- hostFilePlane: NO,
59
- coreRemoteExecutionEnv: YES,
60
- canonicalPathAuthority: YES,
61
41
  tenantSeparation: executionLaneRow(lane).tenantSeparation,
62
42
  };
63
43
  case "k8s":
@@ -67,15 +47,8 @@ export function executionLaneCaps(lane) {
67
47
  scheduler: NO,
68
48
  lsp: NO,
69
49
  sandboxSendUserFile: YES,
70
- isolation: YES,
71
- suspendable: YES,
72
50
  remoteScratchpad: YES,
73
- sandboxPathAdjudication: YES,
74
51
  worktreeIsolation: NO,
75
- memoryPersistenceCapable: NO,
76
- hostFilePlane: NO,
77
- coreRemoteExecutionEnv: YES,
78
- canonicalPathAuthority: YES,
79
52
  tenantSeparation: executionLaneRow(lane).tenantSeparation,
80
53
  };
81
54
  case "ssh":
@@ -85,15 +58,8 @@ export function executionLaneCaps(lane) {
85
58
  scheduler: NO,
86
59
  lsp: NO,
87
60
  sandboxSendUserFile: SU,
88
- isolation: NO,
89
- suspendable: NO,
90
61
  remoteScratchpad: YES,
91
- sandboxPathAdjudication: YES,
92
62
  worktreeIsolation: NO,
93
- memoryPersistenceCapable: NO,
94
- hostFilePlane: NO,
95
- coreRemoteExecutionEnv: YES,
96
- canonicalPathAuthority: YES,
97
63
  tenantSeparation: executionLaneRow(lane).tenantSeparation,
98
64
  };
99
65
  case "adb":
@@ -103,15 +69,8 @@ export function executionLaneCaps(lane) {
103
69
  scheduler: NO,
104
70
  lsp: NO,
105
71
  sandboxSendUserFile: NO,
106
- isolation: NO,
107
- suspendable: NO,
108
72
  remoteScratchpad: NO,
109
- sandboxPathAdjudication: YES,
110
73
  worktreeIsolation: NO,
111
- memoryPersistenceCapable: NO,
112
- hostFilePlane: NO,
113
- coreRemoteExecutionEnv: YES,
114
- canonicalPathAuthority: YES,
115
74
  tenantSeparation: executionLaneRow(lane).tenantSeparation,
116
75
  };
117
76
  case "local-docker":
@@ -121,15 +80,8 @@ export function executionLaneCaps(lane) {
121
80
  scheduler: NO,
122
81
  lsp: NO,
123
82
  sandboxSendUserFile: NO,
124
- isolation: YES,
125
- suspendable: NO,
126
83
  remoteScratchpad: YES,
127
- sandboxPathAdjudication: YES,
128
84
  worktreeIsolation: NO,
129
- memoryPersistenceCapable: NO,
130
- hostFilePlane: NO,
131
- coreRemoteExecutionEnv: YES,
132
- canonicalPathAuthority: YES,
133
85
  tenantSeparation: executionLaneRow(lane).tenantSeparation,
134
86
  };
135
87
  case "device":
@@ -139,19 +91,47 @@ export function executionLaneCaps(lane) {
139
91
  scheduler: NO,
140
92
  lsp: NO,
141
93
  sandboxSendUserFile: NO,
142
- isolation: NO,
143
- suspendable: NO,
144
94
  remoteScratchpad: YES,
145
- sandboxPathAdjudication: YES,
146
95
  worktreeIsolation: NO,
147
- memoryPersistenceCapable: NO,
148
- hostFilePlane: NO,
149
- coreRemoteExecutionEnv: YES,
150
- canonicalPathAuthority: YES,
151
96
  tenantSeparation: executionLaneRow(lane).tenantSeparation,
152
97
  };
153
98
  }
154
99
  }
100
+ const IN_PROCESS_BLOCK = new StubExecutionEnv().capabilities;
101
+ const HOST_BLOCK = Object.freeze({ isolation: false, suspendable: false, sharesProcessTable: true, canonicalPathAuthoritative: true, hostLocalPaths: true, externalContentTarget: false, io: true, keepsReadFloor: false });
102
+ const E2B_BLOCK = Object.freeze({ isolation: true, suspendable: true, sharesProcessTable: false, canonicalPathAuthoritative: true, hostLocalPaths: false, externalContentTarget: false, io: true, keepsReadFloor: false });
103
+ const K8S_BLOCK = Object.freeze({ isolation: true, suspendable: false, sharesProcessTable: false, canonicalPathAuthoritative: true, hostLocalPaths: false, externalContentTarget: false, io: true, keepsReadFloor: false });
104
+ const K8S_SNAPSHOT_BLOCK = Object.freeze({ ...K8S_BLOCK, suspendable: true });
105
+ const LOCAL_DOCKER_BLOCK = Object.freeze({ isolation: true, suspendable: false, sharesProcessTable: false, canonicalPathAuthoritative: true, hostLocalPaths: false, externalContentTarget: false, io: true, keepsReadFloor: false });
106
+ const SSH_BLOCK = Object.freeze({ isolation: false, suspendable: false, sharesProcessTable: false, canonicalPathAuthoritative: true, hostLocalPaths: false, externalContentTarget: false, io: true, keepsReadFloor: false });
107
+ const ADB_BLOCK = Object.freeze({ isolation: false, suspendable: false, sharesProcessTable: false, canonicalPathAuthoritative: true, hostLocalPaths: false, externalContentTarget: false, io: true, keepsReadFloor: false });
108
+ const DEVICE_BLOCK = Object.freeze({ isolation: false, suspendable: false, sharesProcessTable: false, canonicalPathAuthoritative: true, hostLocalPaths: false, externalContentTarget: true, io: true, keepsReadFloor: false });
109
+ function laneBlock(lane, snapshotStore) {
110
+ switch (lane) {
111
+ case "in-process":
112
+ return IN_PROCESS_BLOCK;
113
+ case "host":
114
+ return HOST_BLOCK;
115
+ case "e2b":
116
+ return E2B_BLOCK;
117
+ case "k8s":
118
+ return snapshotStore ? K8S_SNAPSHOT_BLOCK : K8S_BLOCK;
119
+ case "local-docker":
120
+ return LOCAL_DOCKER_BLOCK;
121
+ case "ssh":
122
+ return SSH_BLOCK;
123
+ case "adb":
124
+ return ADB_BLOCK;
125
+ case "device":
126
+ return DEVICE_BLOCK;
127
+ }
128
+ }
129
+ export function capabilitiesFor(deployment) {
130
+ const lane = executionLaneOf(deployment.remoteExec?.provider);
131
+ if (lane === undefined)
132
+ return undefined;
133
+ return laneBlock(lane, lane === "k8s" && Boolean(deployment.remoteExec?.s3Snapshot));
134
+ }
155
135
  export const ALL_EXECUTION_LANES = Object.freeze(["in-process", ...DECLARABLE_LANE_WORDS]);
156
136
  const EXECUTION_LANE_SET = new Set(ALL_EXECUTION_LANES);
157
137
  export function isExecutionLane(word) {
@@ -180,6 +160,12 @@ export function laneRequiredEnv(lane) {
180
160
  const row = executionLaneRow(lane);
181
161
  return [...row.requiredEnv, ...row.requiredSecretEnv];
182
162
  }
163
+ export function isBlankRequiredEnvValue(value) {
164
+ return value === undefined || isBlankCoordinate(value);
165
+ }
166
+ export function laneMissingEnv(lane, env) {
167
+ return laneRequiredEnv(lane).filter((name) => isBlankRequiredEnvValue(env[name]));
168
+ }
183
169
  export function executionLaneRequiredRefusal(deployment) {
184
170
  if (!deployment.requireExecutionLane || executionLaneOf(deployment.remoteExec?.provider) !== "in-process")
185
171
  return undefined;
@@ -199,9 +185,12 @@ export function executionLaneOf(provider) {
199
185
  return "in-process";
200
186
  return isExecutionLane(provider) ? provider : undefined;
201
187
  }
188
+ export function deployedExecutionLanes(config) {
189
+ return [executionLaneOf(config.remoteExec?.provider)];
190
+ }
202
191
  export function handsOnWorkerFilePlane(lane) {
203
- const caps = executionLaneCaps(lane);
204
- return caps.hostFilePlane === "supported" && caps.coreRemoteExecutionEnv === "supported";
192
+ const block = laneBlock(lane, false);
193
+ return block.io && block.hostLocalPaths;
205
194
  }
206
195
  export function laneBindsReads(lane) {
207
196
  switch (lane) {
@@ -223,11 +212,11 @@ export function laneMeasuresHome(lane) {
223
212
  case "local-docker":
224
213
  case "ssh":
225
214
  case "adb":
215
+ case "e2b":
216
+ case "host":
226
217
  return true;
227
218
  case "device":
228
- case "host":
229
219
  case "in-process":
230
- case "e2b":
231
220
  return false;
232
221
  }
233
222
  }
@@ -247,23 +236,10 @@ export function laneReadFaceDefault(lane) {
247
236
  }
248
237
  export const LANE_OPEN_READ_FACE_CAUTION = "a deployment that mounts host paths or shared volumes into the sandbox (hostPath, bind mount) exposes those host files to reads on an open face — pin READ_FACE=roots or add read-deny rows (READ_DENY_PATTERNS) for them";
249
238
  export function laneIsolated(lane) {
250
- const isolation = executionLaneCaps(lane).isolation;
251
- switch (isolation) {
252
- case "supported":
253
- return true;
254
- case "unsupported":
255
- return false;
256
- }
239
+ return laneBlock(lane, false).isolation;
257
240
  }
258
241
  export function laneWiresExecutionEnv(lane) {
259
- const wired = executionLaneCaps(lane).coreRemoteExecutionEnv;
260
- switch (wired) {
261
- case "supported":
262
- return true;
263
- case "unsupported":
264
- case "single-user-only":
265
- return false;
266
- }
242
+ return laneBlock(lane, false).io;
267
243
  }
268
244
  export const PLANNED_LANE_DIVERGENCES = Object.freeze([]);
269
245
  export const E2B_SANDBOX_HOME = "/home/user";
@@ -288,14 +264,32 @@ export function executionLaneHomeDir(deployment) {
288
264
  return undefined;
289
265
  }
290
266
  }
291
- export function buildUndeclaredHomeNote(deployment) {
292
- if (executionLaneHomeDir(deployment) !== undefined)
293
- return undefined;
267
+ export function buildLaneHomeClaim(deployment) {
268
+ const home = executionLaneHomeDir(deployment);
269
+ if (home === undefined)
270
+ return {};
271
+ return { homeDir: home, homeDirSource: deployment.remoteExecHomeDir !== undefined ? "declared" : "lane" };
272
+ }
273
+ export function buildLaneHomeBootNote(deployment) {
294
274
  const lane = executionLaneOf(deployment.remoteExec?.provider);
295
- if (lane === undefined || executionLaneCaps(lane).coreRemoteExecutionEnv !== "supported")
275
+ if (lane === undefined || !laneWiresExecutionEnv(lane))
296
276
  return undefined;
297
277
  if (laneMeasuresHome(lane))
298
278
  return undefined;
299
- return buildHomeAbsentNote(lane, "REMOTE_EXEC_HOME_DIR is unset, and this lane cannot read its execution environment's home", DECLARE_HOME_REMEDY);
279
+ const home = executionLaneHomeDir(deployment);
280
+ if (home === undefined)
281
+ return { event: LANE_HOME_UNDECLARED_EVENT, note: buildHomeAbsentNote(lane, "REMOTE_EXEC_HOME_DIR is unset, and this lane cannot read its execution environment's home", DECLARE_HOME_REMEDY) };
282
+ return { event: LANE_HOME_UNMEASURED_EVENT, note: buildHomeUnmeasuredNote(lane, home) };
283
+ }
284
+ export function buildReadDenyFloorUnkeptNote(deployment) {
285
+ if (!deployment.readDenyFloorRequired)
286
+ return undefined;
287
+ if (capabilitiesFor(deployment)?.keepsReadFloor === true)
288
+ return undefined;
289
+ const lane = executionLaneOf(deployment.remoteExec?.provider) ?? String(deployment.remoteExec?.provider);
290
+ return (`READ_DENY_FLOOR_REQUIRED=true, but the "${lane}" execution lane does not keep the read-deny byte floor (a program its commands run can open a path ` +
291
+ `the read-deny table refuses). Every run whose read-deny table has rows — the shipped default tiers put rows there unless READ_DENY_BUILTIN_TIERS=none — ` +
292
+ `is refused before any command starts (config.read_deny_floor_unkept; a synchronous submit answers 409). ` +
293
+ `Either run on a lane that keeps the floor, or unset READ_DENY_FLOOR_REQUIRED to run with one operator notice per run instead.`);
300
294
  }
301
295
  //# sourceMappingURL=execution-lane-caps.js.map
@@ -0,0 +1,259 @@
1
+ /**
2
+ * **执行放置** —— 根会话行上「这一位住客」的一格(叶模块:型 + 纯函数 + 测试走廊的内存参照实现;运行期只依赖 core 的住客判官)。
3
+ *
4
+ * ## 规则(全仓唯一处写)
5
+ * · **一格四态**:`absent`(这一位住客还没有放置)| `writer(L[, D])`(本引擎声明在车道 L 上写;device 车道带设备 D,D 缺 = 迁移回填的
6
+ * 「有 run、设备未知」)| `mirror`(写者在别处,本处只读)| `forking`(只 local:fork 的目标格已写、存档未落 —— 崩溃中间态,SQL 单事务不可达)。
7
+ * 载体:SQL `session_meta` 的 `execution_*` 七列(列定义与语句的唯一属主 = `plugins/execution-placement-sql.ts`);local = 会话元数据边档那一格的
8
+ * `execution` 位(`plugins/local-session-store.ts`)。处处 `execution` 限定,与同行 `placement_*`(委派分区)不同义;执行格只在 `placement_kind IS NULL` 的行上 ——
9
+ * 委派分区行读作「不在」。
10
+ * · **读只有一只**:会话店的执行席 {@link ExecutionPlacementSeat.read}(一次行读:住客 + 格;行不在 / 委派分区行 ⇒ `undefined`;读故障抛,不吞成 `absent`)。
11
+ * · **写只按住客谓词** `(root, incarnation, owner) ∧ placement_kind IS NULL`:住客换了(删后重建,哪怕同一属主;local M10 窗内的认领)= 这一格不在 ⇒ 落空;
12
+ * 0 行一律按住客复读分类({@link settledPlaceOutcome} / {@link settledMirrorOutcome} / {@link settledDeviceBindOutcome}),**永不对现住客重试**。
13
+ * · **没有的转换**:writer ↔ mirror、writer(L) → writer(L')(device 车道的换绑 writer(device, D) → writer(device, D') 除外,它有自己的语句与门)。
14
+ * · **放置存在 ⇒ 住客存在**:放置是行的列 / 格,删会话即删放置;建行恒 absent(SQL 建行 INSERT 列名显式;local 新格整格新铸),导入新建的行同锁落 mirror。
15
+ *
16
+ * ## 测试走廊的会话行(不是第二只生产店)
17
+ * {@link InMemoryExecutionPlacementSeat} 是**语义参照实现**(与 `InMemoryDeviceStore` 同一身份):持「会话行」(root → 住客 + 格),给只用 `Map` 会话店的
18
+ * 测试走廊与 `InMemoryDeviceStore` 共用。**生产装配零引用** —— `src/` 非测试路径里只许 `device-store.ts` 与本模块提到它。
19
+ */
20
+ import { type SessionHead } from "@sema-agent/core";
21
+ import type { DeviceOwner } from "./device-store.js";
22
+ import type { ExecutionLane } from "./execution-lane-caps.js";
23
+ import type { SessionFace } from "./session-incarnation.js";
24
+ /** writer(device, D) 的 D:设备、绑定属主(= 设备属主)、换绑序号、放下时刻(ISO)。 */
25
+ export interface ExecutionDeviceCell {
26
+ readonly id: string;
27
+ readonly owner: DeviceOwner;
28
+ readonly rev: number;
29
+ readonly placedAt: string;
30
+ }
31
+ /** `lane = "device"` ∧ `device` 缺 = writer(device, ∅)(只来自迁移回填:有 run 而设备未知)。 */
32
+ export type ExecutionWriterCell = {
33
+ readonly role: "writer";
34
+ readonly lane: ExecutionLane;
35
+ readonly device?: ExecutionDeviceCell;
36
+ };
37
+ export type ExecutionPlacementCell = {
38
+ readonly role: "absent";
39
+ } | ExecutionWriterCell | {
40
+ readonly role: "mirror";
41
+ } | {
42
+ readonly role: "forking";
43
+ };
44
+ /** 一次行读的答案:这一位住客 + 它的格(同一行、同一次读)。 */
45
+ export interface ExecutionPlacementReading {
46
+ readonly occupant: SessionFace;
47
+ readonly cell: ExecutionPlacementCell;
48
+ }
49
+ /** place 的结果(0 行按住客复读分类;`gone` = 行不在或住客不是判过的那一位)。 */
50
+ export type PlaceOutcome = {
51
+ readonly outcome: "placed";
52
+ } | {
53
+ readonly outcome: "same";
54
+ } | {
55
+ readonly outcome: "tree_bound";
56
+ readonly boundLane: ExecutionLane;
57
+ } | {
58
+ readonly outcome: "mirror";
59
+ } | {
60
+ readonly outcome: "gone";
61
+ };
62
+ /** identical 臂补 mirror 的结果(`active` = 写事务内(SQL)/ 写锁内(local)读到认领,带那只认领的 task id;判官的答案先于它,只拦「absent → mirror」这一笔写)。 */
63
+ export type MarkMirrorOutcome = {
64
+ readonly outcome: "mirrored";
65
+ } | {
66
+ readonly outcome: "writer";
67
+ } | {
68
+ readonly outcome: "gone";
69
+ } | {
70
+ readonly outcome: "active";
71
+ readonly activeTaskId: string;
72
+ };
73
+ /**
74
+ * 「谁带执行席」的唯一一句(要求会话店带席的装配拒句引它,不另抄):三店都带(SQL 两孪生 + local,即 `StoreBackend` 交出的会话店),两只包装原样转发;
75
+ * 只用 `Map` 会话店的测试走廊 / 内存嵌入给参照实现。
76
+ */
77
+ export declare const EXECUTION_PLACEMENT_SEAT_CARRIERS = "every built-in session store carries one (the MySQL-protocol and PostgreSQL stores and the local store, i.e. the session store a StoreBackend hands out; the caching and fork-routing wrappers forward it), and an in-memory test or embedding passes InMemoryExecutionPlacementSeat";
78
+ /** 会话店的执行席(三店 + 两只包装原样转发)。 */
79
+ export interface ExecutionPlacementSeat {
80
+ /** 一次行读:行不在 / 委派分区行 ⇒ `undefined`;读故障抛(不吞成 absent)。 */
81
+ read(root: string): Promise<ExecutionPlacementReading | undefined>;
82
+ /** absent → writer(L)(非 device 车道;device 车道的首绑走设备店,同一只 SQL 语句模块)。传 device 车道 ⇒ 响亮抛(装配缝)。 */
83
+ place(root: string, occupant: SessionFace, cell: ExecutionWriterCell): Promise<PlaceOutcome>;
84
+ /** identical 臂补 mirror:WHERE 住客谓词 ∧ 不是 writer;写事务内先锁根行读认领(SQL),local 在这只会话的写锁里读同一个认领。 */
85
+ markMirror(root: string, occupant: SessionFace): Promise<MarkMirrorOutcome>;
86
+ }
87
+ /**
88
+ * 读不出的存档的故障词(闭集;一次性迁移 M32 的 local 腿点名用 —— 随 M32 · 窗口见 `plugins/one-time-migrations.ts` 登记表,窗关后随迁移码删):
89
+ * · `corrupt_session` —— 存档在,会话头读不出 / 截断;`invalid_session` —— 读得出而日志结构走不通(两个都是 core 的 `SessionError` 词,原样);
90
+ * · `storage` —— 读的时候抛了**别的**故障(I/O 级:权限 / 磁盘 I/O / 超大 —— core 的 `readJsonlRecords` 只吞 ENOENT,其余 errno 原样抛,不是 `SessionError`),
91
+ * 说不出在不在也说不出内容;{@link UnusableArchive.errno} 带那只故障的 `code`。
92
+ */
93
+ export type UnusableArchiveWord = "corrupt_session" | "invalid_session" | "storage";
94
+ /**
95
+ * local 的会话存档**读不出**(会话头读不出 / 日志结构走不通 / 读的时候抛了别的故障):盘上有这只会话的存档,只是读不出它 —— 与「不在」是两件事。
96
+ * (本型与 {@link isUnusableArchive} 随 M32 · 窗口见 `plugins/one-time-migrations.ts` 登记表。)
97
+ * local 店对存档的**唯一探针**答三态(不在 · 在而读得出 · 本型),要对存档动手的读者看到本型就把 {@link UnusableArchive.fault}(抛出来的那只故障,**原样**)上抛,
98
+ * 只问「有没有」的读者不上抛(见 `plugins/local-session-store.ts` 的 `probeArchive`)。
99
+ */
100
+ export interface UnusableArchive {
101
+ readonly state: "unusable";
102
+ readonly word: UnusableArchiveWord;
103
+ /** `word === "storage"` 且那只故障带字符串 `code` 时:该 `code`(`EACCES` / `EIO` / `ERR_STRING_TOO_LONG` ……);其余缺席。盘上路径与故障句不进这一格。 */
104
+ readonly errno?: string;
105
+ /** 探针抛出来的那只故障,原样(上抛的读者抛的就是它)。 */
106
+ readonly fault: unknown;
107
+ }
108
+ export declare function isUnusableArchive(x: object | undefined): x is UnusableArchive;
109
+ /**
110
+ * 一次性迁移 M32 **local 腿**的席(随 M32 · 窗口见 `plugins/one-time-migrations.ts` 登记表;只 local 有:SQL 的行就是会话,没有「会话元数据格缺 ∧ 存档读不出」这一形)。`read` 与 {@link ExecutionPlacementSeat.read} 是
111
+ * **同一读**(同一只实现的本体),只差一点:这只会话的存档读不出(格缺而探针读不出,或 fork 创建的格而探针读不出)⇒ **答 {@link UnusableArchive} 而不抛** —— 开机回填不动存档、
112
+ * 只补一格放置,读不出的会话由它点名跳过(该会话的请求照旧答存档的故障);席的 `read` 对同一形照旧抛。`place` 就是席的 `place`。
113
+ */
114
+ export interface LocalPlacementBackfillSeat extends Pick<ExecutionPlacementSeat, "place"> {
115
+ read(root: string): Promise<ExecutionPlacementReading | UnusableArchive | undefined>;
116
+ }
117
+ /** wire 投影(新读面 + 受理回声共用)。 */
118
+ export type ExecutionPlacementView = {
119
+ readonly role: "absent";
120
+ } | {
121
+ readonly role: "writer";
122
+ readonly lane: ExecutionLane;
123
+ readonly device?: {
124
+ readonly deviceId: string;
125
+ readonly rev: number;
126
+ };
127
+ } | {
128
+ readonly role: "mirror";
129
+ } | {
130
+ readonly role: "forking";
131
+ };
132
+ /** 格 → wire 投影(唯一一只;设备只投 id 与 rev,属主与时刻不上 wire)。 */
133
+ export declare function executionPlacementView(cell: ExecutionPlacementCell): ExecutionPlacementView;
134
+ /**
135
+ * 住客谓词的 JS 读法(SQL `incarnation = ? AND owner <=> ?` 的对位)= core 的行期望判官 `sessionRowMatches`(会话行格写原语锁内判的也是它,
136
+ * `session-row.ts` 的 `judgeSessionRowWrite`):属主与化身两样都没变才是判过的那一位 —— 同一化身的属主会变(local M10 认领、identical 重戳、
137
+ * SQL 导入提交点改属主)。两侧收「属主 + 化身」那一读:活住客(`SessionFace`)与店的头(`SessionHead`,门判过的那一读);调用方一侧恒是执行席的读数
138
+ * (住客经 `sessionFaceFromRow` 解码,令牌非空),所以「两侧都没有令牌」这一形在这里不可达。写口的判官与执行上下文解析器步 ① 的 `judged` 复核都经它。
139
+ */
140
+ export declare function sameOccupant(a: Pick<SessionHead, "owner" | "incarnation">, b: Pick<SessionHead, "owner" | "incarnation">): boolean;
141
+ /**
142
+ * 写口撞上本处写者 —— 三个导入写口(staged 提交点 / 整段 `importEntries` / `replaceEntries`)在写事务内(local:写锁内、写格之前)复读到 `writer`
143
+ * ⇒ 回滚、目的端零字节、抛它。具名类型:会话同步路由按类型把它答 409 `conflict.session_writer`;不是 core `SessionError`(那张闭集的 `conflict` 在导入面另有固定答复)。
144
+ */
145
+ export declare class SessionWriterPresentError extends Error {
146
+ readonly sessionId: string;
147
+ readonly lane: ExecutionLane;
148
+ readonly code = "conflict.session_writer";
149
+ constructor(sessionId: string, lane: ExecutionLane);
150
+ }
151
+ /**
152
+ * local 的 `forking` 中间态(fork 创建的格 —— 带 fork 键、执行位没人写过 —— 而存档不在)上的普通取用 —— 引擎 acquire 的缺档新建臂、登记、三个导入写口、执行席的写一律抛它;
153
+ * 只有同键的 `forkTo` 重试在两把写锁内补拷存档。具名类型:路由层按类型答 409 `conflict.fork_in_progress`。
154
+ */
155
+ export declare class SessionForkInProgressError extends Error {
156
+ readonly sessionId: string;
157
+ readonly code = "conflict.fork_in_progress";
158
+ constructor(sessionId: string);
159
+ }
160
+ /**
161
+ * 写事务内的认领读命中(读写序律,`plugins/execution-placement-sql.ts` 的 `lockRootAndReadClaim`):改根住客 / 放置的写者在自己的事务里先锁根
162
+ * `session_meta` 行、再锁定读 `task_active(root)`,读到认领 ⇒ 回滚、一个字节不写、抛它。只 SQL 后端(local 不立此律:没有 device 工厂)。
163
+ * 具名类型、**不带 wire 码**:各门按自己的既有码答(导入 409 `session_active`、删除 409 `conflict.session_active_run`),体带 `activeTaskId`。
164
+ */
165
+ export declare class SessionActiveRunError extends Error {
166
+ readonly sessionId: string;
167
+ readonly activeTaskId: string;
168
+ constructor(sessionId: string, activeTaskId: string);
169
+ }
170
+ /** 0 行分类的「这一格此刻可写」答案(只给锁内读写的实现用:local 与内存参照实现写它;SQL 在 0 行之后读到它 = 不变量破,响亮抛)。 */
171
+ export declare const WRITABLE: "writable";
172
+ /**
173
+ * place 的唯一判官(三店 + 内存参照实现同调):对一次按根的读数判「判过的住客 + 想要的格」此刻是什么结果。
174
+ * 行不在 / 住客不同 ⇒ `gone`;writer 同车道 ⇒ `same`;writer 异车道 ⇒ `tree_bound`;mirror ⇒ `mirror`;absent ⇒ {@link WRITABLE};forking ⇒ 抛 {@link SessionForkInProgressError}。
175
+ * 想要的格只认非 device 车道(device 首绑的判官是 {@link settledDeviceBindOutcome})。
176
+ */
177
+ export declare function settledPlaceOutcome(root: string, reading: ExecutionPlacementReading | undefined, occupant: SessionFace, wanted: ExecutionWriterCell): PlaceOutcome | typeof WRITABLE;
178
+ /** markMirror 的唯一判官(认领那一半在本判官之后,SQL 与 local 各在自己的写事务 / 写锁内判):行不在 / 住客不同 ⇒ `gone`;writer ⇒ `writer`;mirror ⇒ `mirrored`(幂等,零写);absent ⇒ {@link WRITABLE};forking ⇒ 抛。 */
179
+ export declare function settledMirrorOutcome(root: string, reading: ExecutionPlacementReading | undefined, occupant: SessionFace): MarkMirrorOutcome | typeof WRITABLE;
180
+ /** device 车道首绑(absent → writer(device, D) 或 writer(device, ∅) → writer(device, D))的结果(设备店的事务 / 内存参照实现同调)。 */
181
+ export type DeviceBindOutcome = {
182
+ readonly outcome: "bound";
183
+ readonly device: ExecutionDeviceCell;
184
+ } | {
185
+ readonly outcome: "same";
186
+ readonly device: ExecutionDeviceCell;
187
+ } | {
188
+ readonly outcome: "device_conflict";
189
+ readonly device: ExecutionDeviceCell;
190
+ } | {
191
+ readonly outcome: "tree_bound";
192
+ readonly boundLane: ExecutionLane;
193
+ } | {
194
+ readonly outcome: "mirror";
195
+ } | {
196
+ readonly outcome: "gone";
197
+ };
198
+ /**
199
+ * device 首绑的唯一判官:行不在 / 住客不同 ⇒ `gone`;absent 或 writer(device, ∅) ⇒ {@link WRITABLE};writer(device, D):D = 想要的设备 ⇒ `same`、否则 `device_conflict`;
200
+ * writer 异车道 ⇒ `tree_bound`;mirror ⇒ `mirror`;forking ⇒ 抛。
201
+ */
202
+ export declare function settledDeviceBindOutcome(root: string, reading: ExecutionPlacementReading | undefined, occupant: SessionFace, deviceId: string): Exclude<DeviceBindOutcome, {
203
+ outcome: "bound";
204
+ }> | typeof WRITABLE;
205
+ /**
206
+ * device 换绑 writer(device, D) → writer(device, D') 的结果(按住客 ∧ 两属主列 ∧ rev 定址;0 行按住客复读分 `rev_conflict` / `gone`)。
207
+ * `rebound` 带被换下的那台(`from`,审计行 `session_rebound` 的 detail 要它);`idempotent` = 目标就是格上那台且前态 rev 对得上 ⇒ 零写、rev 不加、不写审计。
208
+ */
209
+ export type DeviceRebindOutcome = {
210
+ readonly outcome: "rebound";
211
+ readonly device: ExecutionDeviceCell;
212
+ readonly from: string;
213
+ } | {
214
+ readonly outcome: "idempotent";
215
+ readonly device: ExecutionDeviceCell;
216
+ } | {
217
+ readonly outcome: "rev_conflict";
218
+ readonly device: ExecutionDeviceCell;
219
+ } | {
220
+ readonly outcome: "gone";
221
+ };
222
+ /**
223
+ * device 换绑的唯一判官(设备店的事务 / 内存参照实现同调,在锁住的那一读上判):行不在 / 住客不同 / 不是 writer(device, D) / 绑定属主不是判过的那一位 ⇒ `gone`;
224
+ * rev 不等 ⇒ `rev_conflict`;rev 对得上而目标就是格上那台 ⇒ `idempotent`(必须先于写判 —— `execution_rev + 1` 恒变列会把一次无操作也推进一格);否则 {@link WRITABLE}。
225
+ */
226
+ export declare function settledDeviceRebindOutcome(reading: ExecutionPlacementReading | undefined, occupant: SessionFace, owner: DeviceOwner, expectedRev: number, targetDeviceId: string): Exclude<DeviceRebindOutcome, {
227
+ outcome: "rebound";
228
+ }> | typeof WRITABLE;
229
+ /**
230
+ * 「这一格把这棵树放在哪台设备上」的**唯一读法**(准入链、device 工厂、换绑门与上面的换绑判官同调):writer(device, D) ⇒ D;其余一律 `undefined` ——
231
+ * absent(还没放)、mirror(写者在别处)、forking(local 中间态)、writer(device, ∅)(迁移回填的「有 run、设备未知」)、writer(别的车道)。
232
+ * 读者把 `undefined` 答成各自的「没有设备绑定」(`device.not_bound` / 设备 404);穷举 switch,新角色 = 编译红。
233
+ */
234
+ export declare function boundDeviceOf(cell: ExecutionPlacementCell): ExecutionDeviceCell | undefined;
235
+ /** seat.place 只认非 device 车道(device 首绑走设备店);传 device ⇒ 响亮抛 —— 这是装配缝,不是一个答案。 */
236
+ export declare function assertPlaceableLane(root: string, cell: ExecutionWriterCell): void;
237
+ /**
238
+ * **测试走廊的会话行**(语义参照实现,与 `InMemoryDeviceStore` 同一身份 —— 生产装配零引用,见头注):root → 住客 + 格。
239
+ * 只用 `Map` 会话店的测试走廊经 {@link seatRow} / {@link dropRow} 模拟会话行的生灭(= SQL 店的建行 / 删行),`InMemoryDeviceStore` 在它上面做设备首绑 / 换绑。
240
+ * 语义与 SQL 语句模块逐格同:同一组判官({@link settledPlaceOutcome} 等),写只按住客谓词。
241
+ */
242
+ export declare class InMemoryExecutionPlacementSeat implements ExecutionPlacementSeat {
243
+ private readonly rows;
244
+ /** 建行(会话店建行的对位):行不在 ⇒ 建一只 absent 行;在 ⇒ 不动(与 SQL `ON CONFLICT DO NOTHING` 同一条 first-write 律)。 */
245
+ seatRow(root: string, occupant: SessionFace): void;
246
+ /** 删行(删会话的对位):放置随行消失。 */
247
+ dropRow(root: string): void;
248
+ read(root: string): Promise<ExecutionPlacementReading | undefined>;
249
+ place(root: string, occupant: SessionFace, cell: ExecutionWriterCell): Promise<PlaceOutcome>;
250
+ markMirror(root: string, occupant: SessionFace): Promise<MarkMirrorOutcome>;
251
+ /** device 首绑(SQL `placeDeviceStatement` / `bindDeviceStatement` 的对位):absent 或 writer(device, ∅) ⇒ writer(device, D)、rev 0。 */
252
+ bindDevice(root: string, occupant: SessionFace, device: {
253
+ readonly id: string;
254
+ readonly owner: DeviceOwner;
255
+ }, placedAt: string): DeviceBindOutcome;
256
+ /** device 换绑(SQL `rebindDeviceStatement` 的对位):按住客 ∧ 两属主列 ∧ rev 定址,rev + 1;目标就是格上那台 ⇒ `idempotent` 零写。 */
257
+ rebindDevice(root: string, occupant: SessionFace, owner: DeviceOwner, expectedRev: number, targetDeviceId: string, placedAt: string): DeviceRebindOutcome;
258
+ }
259
+ //# sourceMappingURL=execution-placement.d.ts.map