@sema-agent/server 7.145.0 → 7.147.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (526) hide show
  1. package/MIGRATION.md +876 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/USAGE.md +374 -99
  5. package/deploy/facts/CHANGES.json +25 -0
  6. package/deploy/facts/README.md +57 -0
  7. package/deploy/facts/lanes.json +61 -0
  8. package/deploy/facts/lanes.schema.json +57 -0
  9. package/deploy/facts/sandbox-rbac.json +113 -0
  10. package/deploy/facts/sandbox-rbac.schema.json +74 -0
  11. package/deploy/facts/sealed-key.json +9 -0
  12. package/deploy/facts/sealed-key.schema.json +52 -0
  13. package/deploy/sema-up/README.md +2 -2
  14. package/deploy/sema-up/chart/templates/_helpers.tpl +41 -0
  15. package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +47 -7
  16. package/deploy/sema-up/chart/templates/server-v4pro.yaml +9 -4
  17. package/deploy/sema-up/chart/templates/server.yaml +9 -4
  18. package/deploy/sema-up/chart/values.yaml +8 -1
  19. package/deploy/sema-up/cluster-up.sh +2 -1
  20. package/deploy/sema-up/lib/flagshape.sh +4 -0
  21. package/deploy/sema-up/lib/lanes.json +2 -5
  22. package/deploy/sema-up/sema-up.sh +12 -9
  23. package/deploy/sema-up/stack/compose.yaml +5 -4
  24. package/deploy/sema-up/stack/sema-stack-cluster.yaml +34 -17
  25. package/dist/adoption/import-limits.d.ts +6 -0
  26. package/dist/adoption/import-limits.js +7 -0
  27. package/dist/adoption/import.d.ts +62 -0
  28. package/dist/adoption/import.js +107 -0
  29. package/dist/adoption/wire.d.ts +52 -0
  30. package/dist/adoption/wire.js +9 -0
  31. package/dist/approval-ask-machine.d.ts +2 -2
  32. package/dist/approval-card.d.ts +7 -16
  33. package/dist/approval-card.js +0 -4
  34. package/dist/approval-gate-currency.d.ts +1 -1
  35. package/dist/approval-gate-currency.js +1 -1
  36. package/dist/approval-reconciler.d.ts +1 -1
  37. package/dist/approval.d.ts +3 -3
  38. package/dist/audit.js +2 -2
  39. package/dist/bench/s1/live-deps.js +3 -1
  40. package/dist/boot/crash-last.js +2 -1
  41. package/dist/boot/deployment-mods.d.ts +11 -1
  42. package/dist/boot/deployment-mods.js +15 -2
  43. package/dist/boot/device-lane.js +7 -5
  44. package/dist/boot/engine-lease.d.ts +195 -22
  45. package/dist/boot/engine-lease.js +146 -20
  46. package/dist/boot/execution-env.d.ts +5 -0
  47. package/dist/boot/execution-env.js +57 -33
  48. package/dist/boot/execution-lane.d.ts +37 -9
  49. package/dist/boot/execution-lane.js +74 -20
  50. package/dist/boot/exit-boundary.d.ts +50 -0
  51. package/dist/boot/exit-boundary.js +32 -0
  52. package/dist/boot/exit-last.d.ts +20 -4
  53. package/dist/boot/exit-last.js +23 -5
  54. package/dist/boot/governance-seams.d.ts +2 -2
  55. package/dist/boot/governance-seams.js +1 -0
  56. package/dist/boot/leader.js +1 -1
  57. package/dist/boot/memory-boundary.d.ts +11 -11
  58. package/dist/boot/memory-boundary.js +3 -3
  59. package/dist/boot/memory-consolidation.d.ts +42 -41
  60. package/dist/boot/memory-consolidation.js +26 -28
  61. package/dist/boot/org-memory.js +3 -2
  62. package/dist/boot/parked-revive-gate.d.ts +1 -1
  63. package/dist/boot/parked-revive-gate.js +1 -1
  64. package/dist/boot/reapers.d.ts +12 -4
  65. package/dist/boot/reapers.js +40 -16
  66. package/dist/boot/resolve-spec.d.ts +2 -0
  67. package/dist/boot/resolve-spec.js +126 -123
  68. package/dist/boot/retention-lane.d.ts +4 -42
  69. package/dist/boot/runner-deps.js +1 -1
  70. package/dist/boot/session-faces.d.ts +1 -0
  71. package/dist/boot/session-faces.js +11 -3
  72. package/dist/boot/shutdown.js +27 -9
  73. package/dist/boot/stage-01-config.d.ts +1 -1
  74. package/dist/boot/stage-01-config.js +7 -3
  75. package/dist/boot/stage-02-web-admin-pull.d.ts +1 -1
  76. package/dist/boot/stage-02-web-admin-pull.js +10 -8
  77. package/dist/boot/stage-03-store-backend.d.ts +2 -1
  78. package/dist/boot/stage-03-store-backend.js +2 -2
  79. package/dist/boot/stage-04-stores.d.ts +2 -1
  80. package/dist/boot/stage-05-execution-env.d.ts +4 -1
  81. package/dist/boot/stage-05-execution-env.js +6 -6
  82. package/dist/boot/stage-06-runners.d.ts +5 -2
  83. package/dist/boot/stage-06-runners.js +12 -13
  84. package/dist/boot/stage-07-capability-layer.d.ts +5 -2
  85. package/dist/boot/stage-07-capability-layer.js +7 -7
  86. package/dist/boot/stage-08-reapers.d.ts +5 -2
  87. package/dist/boot/stage-08-reapers.js +3 -3
  88. package/dist/boot/stage-09-leader.d.ts +6 -2
  89. package/dist/boot/stage-10-http-server.d.ts +6 -2
  90. package/dist/boot/stage-10-http-server.js +5 -3
  91. package/dist/boot/stores.d.ts +10 -0
  92. package/dist/boot/stores.js +53 -26
  93. package/dist/boot/web-admin.js +3 -3
  94. package/dist/boot/workflow-orchestration.d.ts +1 -1
  95. package/dist/boot/workflow-orchestration.js +2 -1
  96. package/dist/capabilities/center-plugins.d.ts +2 -0
  97. package/dist/capabilities/center-plugins.js +6 -2
  98. package/dist/capabilities/composite-members.d.ts +4 -1
  99. package/dist/capabilities/composite-members.js +4 -1
  100. package/dist/capabilities/execution-lane.d.ts +7 -7
  101. package/dist/capabilities/execution-lane.js +2 -2
  102. package/dist/capabilities/hands-lane.d.ts +1 -1
  103. package/dist/capabilities/scenarios.d.ts +34 -20
  104. package/dist/capabilities/scenarios.js +13 -9
  105. package/dist/capabilities/settings-contract.d.ts +29 -0
  106. package/dist/capabilities/settings-contract.js +14 -0
  107. package/dist/capabilities/skills.d.ts +5 -5
  108. package/dist/capability-facts.d.ts +56 -1
  109. package/dist/capability-facts.js +59 -8
  110. package/dist/center-credential-renewer.js +3 -2
  111. package/dist/checkpoint-ctx-seal-m28.d.ts +1 -1
  112. package/dist/config-catalog.js +19 -9
  113. package/dist/config-invariants.d.ts +18 -3
  114. package/dist/config-invariants.js +36 -19
  115. package/dist/config-lkg.d.ts +1 -1
  116. package/dist/config-lkg.js +5 -6
  117. package/dist/config-provider.d.ts +2 -2
  118. package/dist/config-provider.js +2 -0
  119. package/dist/config-types.d.ts +228 -185
  120. package/dist/config.d.ts +74 -6
  121. package/dist/config.js +146 -64
  122. package/dist/degenerate-instrument.js +1 -1
  123. package/dist/deleted-session-ids.d.ts +19 -0
  124. package/dist/deleted-session-ids.js +26 -0
  125. package/dist/deploy-facts.d.ts +155 -0
  126. package/dist/deploy-facts.js +95 -0
  127. package/dist/deployment-shape.d.ts +21 -12
  128. package/dist/deployment-shape.js +24 -6
  129. package/dist/device-ws-hub.d.ts +48 -3
  130. package/dist/device-ws-hub.js +48 -2
  131. package/dist/env-facts.d.ts +7 -5
  132. package/dist/env-facts.js +10 -6
  133. package/dist/error-code-family.d.ts +35 -0
  134. package/dist/error-code-family.js +26 -0
  135. package/dist/execution-config-root.d.ts +5 -5
  136. package/dist/execution-config-root.js +5 -5
  137. package/dist/execution-env-purpose.d.ts +14 -0
  138. package/dist/execution-env-purpose.js +29 -0
  139. package/dist/execution-lane-caps.d.ts +49 -86
  140. package/dist/execution-lane-caps.js +52 -62
  141. package/dist/execution-placement.d.ts +18 -2
  142. package/dist/execution-placement.js +19 -0
  143. package/dist/file-history-disclosure.d.ts +2 -2
  144. package/dist/fleet/drain-entry.d.ts +46 -3
  145. package/dist/fleet/drain-entry.js +6 -0
  146. package/dist/fleet/fleet-bus.d.ts +2 -1
  147. package/dist/fleet/serving-lease.js +3 -4
  148. package/dist/history-anchor.d.ts +22 -0
  149. package/dist/history-anchor.js +14 -0
  150. package/dist/hooks/branch-transcript.d.ts +1 -1
  151. package/dist/hooks/branch-transcript.js +1 -0
  152. package/dist/hooks/classic-stations.d.ts +25 -8
  153. package/dist/hooks/classic-stations.js +29 -3
  154. package/dist/hooks/command-spawn.d.ts +1 -4
  155. package/dist/hooks/command-spawn.js +0 -11
  156. package/dist/hooks/hook-runner.d.ts +85 -24
  157. package/dist/hooks/hook-runner.js +326 -109
  158. package/dist/hooks/hook-source.d.ts +14 -2
  159. package/dist/hooks/hook-source.js +8 -0
  160. package/dist/http/active-run-conflict.d.ts +1 -1
  161. package/dist/http/active-run-conflict.js +1 -1
  162. package/dist/http/admission.js +11 -1
  163. package/dist/http/approval-sweeps.d.ts +2 -5
  164. package/dist/http/approval-sweeps.js +3 -2
  165. package/dist/http/checkpoint-ctx.d.ts +76 -71
  166. package/dist/http/checkpoint-ctx.js +40 -40
  167. package/dist/http/claim-latency.d.ts +10 -0
  168. package/dist/http/claim-latency.js +12 -0
  169. package/dist/http/dispatch.js +19 -3
  170. package/dist/http/durable-run-leg.d.ts +5 -0
  171. package/dist/http/durable-run-leg.js +3 -1
  172. package/dist/http/execution-context.d.ts +7 -1
  173. package/dist/http/execution-context.js +13 -0
  174. package/dist/http/health-self-report.d.ts +6 -2
  175. package/dist/http/health-self-report.js +3 -2
  176. package/dist/http/memory-compliance-failure-reply.d.ts +2 -2
  177. package/dist/http/memory-compliance-failure-reply.js +5 -15
  178. package/dist/http/memory-control-plane-corrupt-reply.d.ts +25 -0
  179. package/dist/http/memory-control-plane-corrupt-reply.js +19 -0
  180. package/dist/http/memory-store-refusal-reply.d.ts +3 -3
  181. package/dist/http/memory-store-refusal-reply.js +3 -0
  182. package/dist/http/owner-access.d.ts +11 -0
  183. package/dist/http/owner-access.js +7 -4
  184. package/dist/http/principal-gate.d.ts +28 -16
  185. package/dist/http/principal-gate.js +10 -19
  186. package/dist/http/request-guards.d.ts +2 -2
  187. package/dist/http/request-guards.js +5 -5
  188. package/dist/http/resume-legs.d.ts +29 -10
  189. package/dist/http/resume-legs.js +94 -56
  190. package/dist/http/rewind-files-reply.d.ts +34 -0
  191. package/dist/http/rewind-files-reply.js +36 -0
  192. package/dist/http/route-ctx.d.ts +43 -26
  193. package/dist/http/route-table.js +4 -0
  194. package/dist/http/routes/adoption.d.ts +11 -0
  195. package/dist/http/routes/adoption.js +80 -6
  196. package/dist/http/routes/agents-roster.js +1 -0
  197. package/dist/http/routes/approvals-assistant.js +7 -26
  198. package/dist/http/routes/background.js +1 -0
  199. package/dist/http/routes/capabilities.js +12 -3
  200. package/dist/http/routes/devices.js +1 -1
  201. package/dist/http/routes/diagnostics.d.ts +9 -14
  202. package/dist/http/routes/diagnostics.js +10 -20
  203. package/dist/http/routes/engine.d.ts +31 -0
  204. package/dist/http/routes/engine.js +81 -0
  205. package/dist/http/routes/memory-bundle.js +3 -0
  206. package/dist/http/routes/memory-consolidation.js +3 -5
  207. package/dist/http/routes/memory-origin.d.ts +2 -2
  208. package/dist/http/routes/memory-origin.js +2 -4
  209. package/dist/http/routes/memory-policy.js +5 -1
  210. package/dist/http/routes/notify-wake.js +2 -1
  211. package/dist/http/routes/observability.js +3 -6
  212. package/dist/http/routes/projects.d.ts +70 -0
  213. package/dist/http/routes/projects.js +86 -0
  214. package/dist/http/routes/rules.js +30 -2
  215. package/dist/http/routes/runs.js +15 -11
  216. package/dist/http/routes/session-sync.js +39 -35
  217. package/dist/http/routes/sessions-list.d.ts +1 -1
  218. package/dist/http/routes/sessions.d.ts +7 -1
  219. package/dist/http/routes/sessions.js +108 -2
  220. package/dist/http/routes/tasks.js +32 -8
  221. package/dist/http/routes/trace-usage.js +1 -1
  222. package/dist/http/run-concurrency-cap.d.ts +86 -0
  223. package/dist/http/run-concurrency-cap.js +54 -0
  224. package/dist/http/server.d.ts +31 -14
  225. package/dist/http/server.js +29 -3
  226. package/dist/http/stored-body-replay.d.ts +12 -7
  227. package/dist/http/stored-body-replay.js +28 -5
  228. package/dist/http/wire-types.d.ts +27 -13
  229. package/dist/index.d.ts +2 -2
  230. package/dist/index.js +1 -1
  231. package/dist/instruction-source-notice.d.ts +1 -1
  232. package/dist/json-body-limit.d.ts +8 -0
  233. package/dist/json-body-limit.js +2 -0
  234. package/dist/leader/diffout.d.ts +1 -1
  235. package/dist/local-data-root.d.ts +2 -2
  236. package/dist/memory-embedder-reembed.d.ts +38 -0
  237. package/dist/memory-embedder-reembed.js +20 -0
  238. package/dist/memory-incident-sink.d.ts +0 -28
  239. package/dist/memory-incident-sink.js +5 -0
  240. package/dist/memory-operator-faces.d.ts +9 -4
  241. package/dist/memory-scope-stores.d.ts +9 -7
  242. package/dist/memory-scope-stores.js +3 -14
  243. package/dist/memory-scope.d.ts +38 -2
  244. package/dist/memory-scope.js +33 -2
  245. package/dist/memory-store-refusal.d.ts +17 -4
  246. package/dist/memory-store-refusal.js +1 -1
  247. package/dist/memory-sync-client.d.ts +2 -0
  248. package/dist/memory-sync-client.js +13 -11
  249. package/dist/memory-sync.js +1 -1
  250. package/dist/model-compat.d.ts +35 -21
  251. package/dist/model-compat.js +49 -21
  252. package/dist/model-entry-refusal.d.ts +11 -1
  253. package/dist/model-entry-refusal.js +7 -0
  254. package/dist/namespaced-rule-name.d.ts +18 -1
  255. package/dist/namespaced-rule-name.js +12 -0
  256. package/dist/net-address.d.ts +53 -0
  257. package/dist/net-address.js +111 -0
  258. package/dist/observability/fail-open.d.ts +29 -17
  259. package/dist/observability/fail-open.js +29 -17
  260. package/dist/observability/metrics.d.ts +2 -0
  261. package/dist/observability/metrics.js +2 -0
  262. package/dist/observability/secret-env-scrub.d.ts +30 -4
  263. package/dist/observability/secret-env-scrub.js +15 -3
  264. package/dist/orchestration/workflow-agent-session-index.d.ts +7 -12
  265. package/dist/orchestration/workflow-agent-session-index.js +1 -6
  266. package/dist/orchestration/workflow-completion-inbox.d.ts +26 -6
  267. package/dist/orchestration/workflow-completion-inbox.js +63 -45
  268. package/dist/orchestration/workflow-notify-journal.js +2 -3
  269. package/dist/org-delivery-gate.js +1 -1
  270. package/dist/org-memory-admission.d.ts +5 -2
  271. package/dist/org-memory-admission.js +25 -10
  272. package/dist/parked-decide.d.ts +33 -26
  273. package/dist/parked-decide.js +36 -44
  274. package/dist/peer-directory.d.ts +6 -12
  275. package/dist/peer-directory.js +5 -1
  276. package/dist/plugins/approval-ask-store-file.d.ts +10 -2
  277. package/dist/plugins/approval-ask-store-file.js +37 -4
  278. package/dist/plugins/approval-ask-store-memory.d.ts +5 -3
  279. package/dist/plugins/approval-ask-store-memory.js +11 -2
  280. package/dist/plugins/approval-ask-store-sql.d.ts +3 -0
  281. package/dist/plugins/approval-ask-store-sql.js +3 -1
  282. package/dist/plugins/blob-backend.d.ts +38 -195
  283. package/dist/plugins/blob-backend.js +33 -229
  284. package/dist/plugins/caching-session-store.d.ts +12 -5
  285. package/dist/plugins/caching-session-store.js +3 -0
  286. package/dist/plugins/checkpoint-index-columns.d.ts +1 -1
  287. package/dist/plugins/checkpoint-index-columns.js +3 -2
  288. package/dist/plugins/checkpoint-store-face.d.ts +426 -0
  289. package/dist/plugins/checkpoint-store-face.js +152 -0
  290. package/dist/plugins/device-store-sql.d.ts +2 -2
  291. package/dist/plugins/device-store-sql.js +5 -10
  292. package/dist/plugins/execution-lane-rename-m40.d.ts +20 -0
  293. package/dist/plugins/execution-lane-rename-m40.js +10 -0
  294. package/dist/plugins/execution-placement-sql.d.ts +63 -88
  295. package/dist/plugins/execution-placement-sql.js +94 -54
  296. package/dist/plugins/file-run-store.d.ts +26 -18
  297. package/dist/plugins/file-run-store.js +64 -75
  298. package/dist/plugins/fork-routing-session-store.d.ts +6 -2
  299. package/dist/plugins/fork-routing-session-store.js +2 -2
  300. package/dist/plugins/imported-layer-root-retirement.d.ts +22 -11
  301. package/dist/plugins/imported-layer-root-retirement.js +4 -8
  302. package/dist/plugins/inbox-payload-column.d.ts +14 -0
  303. package/dist/plugins/inbox-payload-column.js +13 -0
  304. package/dist/plugins/local-checkpoint-store.d.ts +7 -2
  305. package/dist/plugins/local-checkpoint-store.js +13 -8
  306. package/dist/plugins/local-data-dir-modes-m39.d.ts +48 -0
  307. package/dist/plugins/local-data-dir-modes-m39.js +182 -0
  308. package/dist/plugins/local-engine-high-water.d.ts +11 -0
  309. package/dist/plugins/local-engine-high-water.js +59 -0
  310. package/dist/plugins/local-session-store.d.ts +119 -30
  311. package/dist/plugins/local-session-store.js +156 -53
  312. package/dist/plugins/local-task-attachment-store.d.ts +2 -0
  313. package/dist/plugins/local-task-attachment-store.js +10 -11
  314. package/dist/plugins/memory-embedder-fingerprint.d.ts +33 -10
  315. package/dist/plugins/memory-embedder-fingerprint.js +52 -12
  316. package/dist/plugins/memory-embedder.d.ts +1 -1
  317. package/dist/plugins/memory-embedder.js +2 -2
  318. package/dist/plugins/memory-engine-pg.d.ts +30 -6
  319. package/dist/plugins/memory-engine-pg.js +96 -214
  320. package/dist/plugins/memory-engine-sql-apply.d.ts +130 -0
  321. package/dist/plugins/memory-engine-sql-apply.js +358 -0
  322. package/dist/plugins/memory-engine-tidb.d.ts +38 -9
  323. package/dist/plugins/memory-engine-tidb.js +99 -230
  324. package/dist/plugins/memory-key-guards.d.ts +1 -1
  325. package/dist/plugins/memory-origin-law.d.ts +3 -3
  326. package/dist/plugins/one-time-migrations.d.ts +169 -83
  327. package/dist/plugins/one-time-migrations.js +295 -235
  328. package/dist/plugins/owner-only-file-mode.d.ts +29 -0
  329. package/dist/plugins/owner-only-file-mode.js +141 -0
  330. package/dist/plugins/permission-rule-store-file.d.ts +17 -3
  331. package/dist/plugins/permission-rule-store-file.js +20 -1
  332. package/dist/plugins/pg-pool.d.ts +2 -1
  333. package/dist/plugins/pg-pool.js +12 -5
  334. package/dist/plugins/release-version.d.ts +20 -0
  335. package/dist/plugins/release-version.js +28 -0
  336. package/dist/plugins/remote-env-adb.d.ts +20 -4
  337. package/dist/plugins/remote-env-adb.js +39 -11
  338. package/dist/plugins/remote-env-e2b.d.ts +12 -3
  339. package/dist/plugins/remote-env-e2b.js +6 -4
  340. package/dist/plugins/remote-env-host.d.ts +9 -1
  341. package/dist/plugins/remote-env-host.js +6 -5
  342. package/dist/plugins/remote-env-k8s.d.ts +5 -2
  343. package/dist/plugins/remote-env-k8s.js +15 -4
  344. package/dist/plugins/remote-env-local-docker.d.ts +4 -1
  345. package/dist/plugins/remote-env-local-docker.js +3 -3
  346. package/dist/plugins/remote-env-ssh.d.ts +8 -2
  347. package/dist/plugins/remote-env-ssh.js +26 -24
  348. package/dist/plugins/remote-shell.d.ts +59 -30
  349. package/dist/plugins/remote-shell.js +175 -62
  350. package/dist/plugins/retention-declaration.d.ts +37 -0
  351. package/dist/plugins/retention-declaration.js +9 -0
  352. package/dist/plugins/retention-deployment.d.ts +126 -0
  353. package/dist/plugins/retention-deployment.js +88 -0
  354. package/dist/plugins/retention-lane-store-sql.d.ts +74 -4
  355. package/dist/plugins/retention-lane-store-sql.js +103 -1
  356. package/dist/plugins/retention-sql.d.ts +29 -0
  357. package/dist/plugins/retention-sql.js +8 -0
  358. package/dist/plugins/run-store-sql.js +2 -2
  359. package/dist/plugins/schema-consistency.d.ts +0 -6
  360. package/dist/plugins/schema-consistency.js +1 -2
  361. package/dist/plugins/schema-ensure-legs.d.ts +1 -1
  362. package/dist/plugins/schema-ensure-legs.js +13 -3
  363. package/dist/plugins/session-ext-table.d.ts +74 -0
  364. package/dist/plugins/session-ext-table.js +121 -0
  365. package/dist/plugins/session-fork.d.ts +31 -9
  366. package/dist/plugins/session-fork.js +3 -2
  367. package/dist/plugins/session-placement.d.ts +4 -2
  368. package/dist/plugins/session-row-sql.d.ts +8 -7
  369. package/dist/plugins/session-row-sql.js +15 -7
  370. package/dist/plugins/session-store-sql.d.ts +131 -0
  371. package/dist/plugins/session-store-sql.js +298 -0
  372. package/dist/plugins/session-workspace-cell.d.ts +2 -2
  373. package/dist/plugins/session-workspace-cell.js +2 -2
  374. package/dist/plugins/shared-memory-store-sql.d.ts +10 -0
  375. package/dist/plugins/shared-memory-store-sql.js +13 -13
  376. package/dist/plugins/snapshot-bucket-presence.js +1 -1
  377. package/dist/plugins/sql-driver.d.ts +23 -7
  378. package/dist/plugins/sql-driver.js +41 -8
  379. package/dist/plugins/sql-errors.d.ts +5 -2
  380. package/dist/plugins/sql-errors.js +4 -0
  381. package/dist/plugins/sql-json-column.d.ts +5 -1
  382. package/dist/plugins/store-backend.d.ts +46 -16
  383. package/dist/plugins/store-backend.js +192 -69
  384. package/dist/plugins/store-contracts.d.ts +10 -13
  385. package/dist/plugins/store-contracts.js +1 -9
  386. package/dist/plugins/store-sweep.d.ts +63 -0
  387. package/dist/plugins/store-sweep.js +48 -0
  388. package/dist/plugins/task-attachment-store.d.ts +6 -8
  389. package/dist/plugins/task-attachment-store.js +15 -10
  390. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  391. package/dist/plugins/text-column-capacity.d.ts +21 -0
  392. package/dist/plugins/text-column-capacity.js +5 -0
  393. package/dist/plugins/tidb-pool.d.ts +3 -2
  394. package/dist/plugins/tidb-pool.js +20 -32
  395. package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
  396. package/dist/prompt-screen.d.ts +6 -9
  397. package/dist/prompt-screen.js +2 -5
  398. package/dist/read-face-posture.d.ts +6 -6
  399. package/dist/read-face-posture.js +2 -2
  400. package/dist/request-value-closure.d.ts +5 -5
  401. package/dist/request-value-closure.js +1 -1
  402. package/dist/rules-consent.d.ts +48 -27
  403. package/dist/rules-consent.js +147 -23
  404. package/dist/run-cancel-context.d.ts +4 -1
  405. package/dist/run-cancel-context.js +2 -1
  406. package/dist/run-local.js +17 -13
  407. package/dist/runs.d.ts +48 -30
  408. package/dist/runs.js +27 -17
  409. package/dist/runtime-caps-resolver.d.ts +15 -8
  410. package/dist/runtime-caps-resolver.js +14 -10
  411. package/dist/sandbox-egress-policy.js +6 -11
  412. package/dist/sandbox-rbac-rules.d.ts +88 -0
  413. package/dist/sandbox-rbac-rules.js +80 -0
  414. package/dist/sealed-key-layout.d.ts +16 -0
  415. package/dist/sealed-key-layout.js +3 -0
  416. package/dist/sealed-key.js +8 -6
  417. package/dist/security.d.ts +43 -9
  418. package/dist/security.js +9 -2
  419. package/dist/sema-config-dir.js +2 -2
  420. package/dist/server-secret-env.d.ts +2 -0
  421. package/dist/service-version.d.ts +2 -1
  422. package/dist/service-version.js +2 -2
  423. package/dist/session-error-wire.d.ts +1 -1
  424. package/dist/session-incarnation.d.ts +8 -5
  425. package/dist/session-notify-door.d.ts +5 -3
  426. package/dist/session-resident-background.d.ts +110 -0
  427. package/dist/session-resident-background.js +88 -0
  428. package/dist/session-row.d.ts +1 -1
  429. package/dist/session-sync-kernel.d.ts +53 -14
  430. package/dist/session-sync-kernel.js +70 -1
  431. package/dist/session-sync.d.ts +5 -3
  432. package/dist/session-workspace.d.ts +12 -2
  433. package/dist/session-workspace.js +6 -0
  434. package/dist/sighup-idle.d.ts +9 -7
  435. package/dist/sighup-idle.js +4 -5
  436. package/dist/spec-fields.d.ts +16 -0
  437. package/dist/spec-fields.js +7 -0
  438. package/dist/store-posture.d.ts +2 -1
  439. package/dist/stored-request-env-credentials-m38.d.ts +3 -0
  440. package/dist/stored-request-env-credentials-m38.js +8 -0
  441. package/dist/stored-request-hooks-m20.d.ts +3 -2
  442. package/dist/stored-request-hooks-m20.js +19 -14
  443. package/dist/stored-request-prompt-profile-m30.d.ts +1 -1
  444. package/dist/stores-sql/blob-index-sql.d.ts +148 -0
  445. package/dist/stores-sql/blob-index-sql.js +154 -0
  446. package/dist/{plugins → stores-sql}/checkpoint-store-sql.d.ts +14 -428
  447. package/dist/{plugins → stores-sql}/checkpoint-store-sql.js +43 -220
  448. package/dist/{plugins → stores-sql}/file-history-store-sql.d.ts +23 -11
  449. package/dist/{plugins → stores-sql}/file-history-store-sql.js +23 -18
  450. package/dist/{plugins → stores-sql}/mailbox-store-sql.d.ts +2 -2
  451. package/dist/{plugins → stores-sql}/mailbox-store-sql.js +4 -4
  452. package/dist/{plugins → stores-sql}/pg-session-storage.d.ts +27 -67
  453. package/dist/{plugins → stores-sql}/pg-session-storage.js +82 -207
  454. package/dist/{plugins → stores-sql}/retention-store-sql.d.ts +123 -217
  455. package/dist/{plugins → stores-sql}/retention-store-sql.js +66 -190
  456. package/dist/{plugins → stores-sql}/roster-store-sql.d.ts +2 -2
  457. package/dist/{plugins → stores-sql}/roster-store-sql.js +1 -1
  458. package/dist/{plugins → stores-sql}/session-event-payload.d.ts +1 -1
  459. package/dist/{plugins → stores-sql}/session-event-payload.js +1 -1
  460. package/dist/stores-sql/session-policy-store-sql.d.ts +1 -1
  461. package/dist/stores-sql/session-write-hooks.d.ts +59 -0
  462. package/dist/stores-sql/session-write-hooks.js +2 -0
  463. package/dist/{plugins → stores-sql}/tidb-session-storage.d.ts +10 -11
  464. package/dist/{plugins → stores-sql}/tidb-session-storage.js +10 -21
  465. package/dist/{plugins → stores-sql}/tidb-session-store.d.ts +35 -112
  466. package/dist/{plugins → stores-sql}/tidb-session-store.js +73 -169
  467. package/dist/{plugins → stores-sql}/tool-result-store-sql.d.ts +3 -3
  468. package/dist/{plugins → stores-sql}/tool-result-store-sql.js +6 -6
  469. package/dist/stores-sql/windowed-session-storage.d.ts +56 -0
  470. package/dist/stores-sql/windowed-session-storage.js +61 -0
  471. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.d.ts +7 -12
  472. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.js +3 -8
  473. package/dist/task-a2a.d.ts +7 -1
  474. package/dist/task-a2a.js +15 -14
  475. package/dist/task-cwd.d.ts +11 -3
  476. package/dist/task-cwd.js +17 -1
  477. package/dist/task-mcp.d.ts +10 -2
  478. package/dist/task-mcp.js +13 -16
  479. package/dist/task-settings.d.ts +68 -8
  480. package/dist/task-settings.js +63 -6
  481. package/dist/tool-approval.d.ts +23 -10
  482. package/dist/tool-approval.js +10 -6
  483. package/dist/trace/core-keyset-guard.d.ts +17 -10
  484. package/dist/trace/engine-notice-wire.d.ts +1 -1
  485. package/dist/trace/engine-notice-wire.js +4 -0
  486. package/dist/trace/exit-seat.d.ts +29 -1
  487. package/dist/trace/exit-seat.js +4 -0
  488. package/dist/trace/project.d.ts +33 -16
  489. package/dist/trace/project.js +21 -9
  490. package/dist/trace/redact.d.ts +13 -2
  491. package/dist/trace/redact.js +347 -78
  492. package/dist/trace/self-minted-wire.d.ts +587 -16
  493. package/dist/trace/self-minted-wire.js +215 -9
  494. package/dist/trace/sema-provenance.d.ts +45 -41
  495. package/dist/trace/sema-provenance.js +81 -10
  496. package/dist/trace/task-notification-facets.d.ts +70 -2
  497. package/dist/trace/task-notification-facets.js +71 -1
  498. package/dist/trace/wire-projection-faces.d.ts +39 -3
  499. package/dist/trace/wire-projection-faces.js +27 -2
  500. package/dist/unread-request-members.d.ts +66 -0
  501. package/dist/unread-request-members.js +41 -0
  502. package/dist/usage-analytics.d.ts +4 -0
  503. package/dist/user-input-ledger.d.ts +2 -2
  504. package/dist/web-admin-client/apply-effective.js +22 -26
  505. package/dist/web-admin-client/candidate-gate.d.ts +35 -3
  506. package/dist/web-admin-client/candidate-gate.js +53 -5
  507. package/dist/web-admin-client/center-request.d.ts +4 -1
  508. package/dist/web-admin-client/center-request.js +2 -1
  509. package/dist/web-admin-client/effective-keys.js +0 -1
  510. package/dist/web-admin-client/facade.d.ts +1 -1
  511. package/dist/web-admin-client/http-client.d.ts +1 -0
  512. package/dist/web-admin-client/http-client.js +17 -9
  513. package/dist/web-admin-client/restart-signal.js +5 -2
  514. package/dist/web-admin-client/skills-mcp.d.ts +20 -6
  515. package/dist/web-admin-client/skills-mcp.js +26 -21
  516. package/dist/web-admin-client/types.d.ts +34 -49
  517. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +2 -2
  518. package/package.json +22 -13
  519. package/scripts/drain-check-local.mjs +8 -55
  520. package/scripts/drain-check.mysql.sql +3 -40
  521. package/scripts/drain-check.pg.sql +3 -40
  522. package/skills/update-config.md +1 -1
  523. package/wire-changes/server@7.146.0.json +3221 -0
  524. package/wire-changes/server@7.147.0.json +813 -0
  525. package/dist/approval-batch-census.d.ts +0 -27
  526. package/dist/approval-batch-census.js +0 -27
@@ -0,0 +1,182 @@
1
+ import { closeSync, constants as FS, fchmodSync, fstatSync, lstatSync, openSync, readdirSync } from "node:fs";
2
+ import { isAbsolute, join, relative, resolve, sep } from "node:path";
3
+ import { physicalPathOf } from "@sema-agent/core";
4
+ import { IS_WIN32 } from "./host-platform.js";
5
+ import { fileRunStoreDirsFor } from "./file-run-store.js";
6
+ import { localCheckpointStoreDirsFor } from "./local-checkpoint-store.js";
7
+ import { attachmentStoreDirFor } from "./local-task-attachment-store.js";
8
+ import { scratchpadRootFor } from "../env-facts.js";
9
+ import { pluginCacheRootFor } from "../capabilities/center-plugins.js";
10
+ import { memorySyncCursorDirFor } from "../memory-sync-client.js";
11
+ const DIR_MODE = 0o700;
12
+ const GROUP_OTHER_BITS = 0o077;
13
+ const TIGHTENED_EXAMPLES = 5;
14
+ const REFUSED_LISTED = 10;
15
+ export const SYMLINK_IN_PATH = "SYMLINK_IN_PATH";
16
+ export function buildDataDirLayout(a) {
17
+ const rel = relative(resolve(a.configuredRoot), resolve(a.memoryEngineRoot));
18
+ const underConfigured = rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
19
+ return { dataRoot: a.physicalRoot, memoryEngineRoot: underConfigured ? join(a.physicalRoot, rel) : a.memoryEngineRoot };
20
+ }
21
+ function rosterFor(layout) {
22
+ const run = fileRunStoreDirsFor(layout.dataRoot);
23
+ const checkpoint = localCheckpointStoreDirsFor(layout.dataRoot);
24
+ return [
25
+ { abs: run.runs, children: 1 },
26
+ { abs: run.tmp, children: 0 },
27
+ { abs: run.spaceCommits, children: 0 },
28
+ { abs: checkpoint.ctx, children: 0 },
29
+ { abs: checkpoint.tmp, children: 0 },
30
+ { abs: attachmentStoreDirFor(layout.dataRoot), children: 0 },
31
+ { abs: scratchpadRootFor(layout.dataRoot), children: 1 },
32
+ { abs: pluginCacheRootFor(layout.dataRoot), children: 2 },
33
+ { abs: memorySyncCursorDirFor(layout.memoryEngineRoot), children: 0 },
34
+ ];
35
+ }
36
+ function segmentsUnder(root, abs) {
37
+ const rel = relative(resolve(root), resolve(abs));
38
+ if (rel === "" || rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel))
39
+ return undefined;
40
+ return rel.split(sep);
41
+ }
42
+ const codeOf = (e) => (typeof e === "object" && e !== null && "code" in e && typeof e.code === "string" ? e.code : "UNKNOWN");
43
+ const emit = (sink, msg, meta) => {
44
+ try {
45
+ sink(msg, meta);
46
+ }
47
+ catch {
48
+ console.warn(msg, meta);
49
+ }
50
+ };
51
+ const sameObject = (a, b) => a.dev === b.dev && a.ino === b.ino;
52
+ function inRootBreak(root, segs, fd) {
53
+ try {
54
+ const held = fstatSync(fd, { bigint: true });
55
+ const physical = physicalPathOf(join(root, ...segs));
56
+ if (segmentsUnder(root, physical) === undefined)
57
+ return SYMLINK_IN_PATH;
58
+ if (!sameObject(lstatSync(physical, { bigint: true }), held))
59
+ return "ESTALE";
60
+ for (let i = 0; i <= segs.length; i += 1) {
61
+ const st = lstatSync(join(root, ...segs.slice(0, i)), { bigint: true });
62
+ if (st.isSymbolicLink())
63
+ return SYMLINK_IN_PATH;
64
+ if (!st.isDirectory())
65
+ return "ESTALE";
66
+ }
67
+ return undefined;
68
+ }
69
+ catch (e) {
70
+ return codeOf(e);
71
+ }
72
+ }
73
+ export function tightenLocalDataDirModes(layout, sinks, seats = {}) {
74
+ if (seats.win32 ?? IS_WIN32)
75
+ return { tightened: [], refused: [] };
76
+ const fchmod = seats.fchmod ?? ((fd, mode) => fchmodSync(fd, mode));
77
+ const root = layout.dataRoot;
78
+ const tightened = [];
79
+ const refused = [];
80
+ const refuse = (rel, code) => {
81
+ if (code !== "ENOENT")
82
+ refused.push({ path: rel, code });
83
+ };
84
+ const tighten = (segs, rel) => {
85
+ let fd;
86
+ try {
87
+ fd = openSync(join(root, ...segs), FS.O_RDONLY | FS.O_DIRECTORY | FS.O_NOFOLLOW);
88
+ }
89
+ catch (e) {
90
+ refuse(rel, codeOf(e));
91
+ return;
92
+ }
93
+ try {
94
+ const broken = inRootBreak(root, segs, fd);
95
+ if (broken !== undefined) {
96
+ refuse(rel, broken);
97
+ return;
98
+ }
99
+ fchmod(fd, DIR_MODE, rel);
100
+ tightened.push(rel);
101
+ }
102
+ catch (e) {
103
+ refuse(rel, codeOf(e));
104
+ }
105
+ finally {
106
+ closeSync(fd);
107
+ }
108
+ };
109
+ const step = (parent, name, more, depth) => {
110
+ const segs = [...parent, name];
111
+ const rel = join(...segs);
112
+ let mode;
113
+ try {
114
+ const st = lstatSync(join(root, ...segs));
115
+ if (st.isSymbolicLink()) {
116
+ refused.push({ path: rel, code: SYMLINK_IN_PATH });
117
+ return;
118
+ }
119
+ if (!st.isDirectory())
120
+ return;
121
+ mode = st.mode;
122
+ }
123
+ catch (e) {
124
+ refuse(rel, codeOf(e));
125
+ return;
126
+ }
127
+ const [next, ...rest] = more;
128
+ if (next !== undefined) {
129
+ step(segs, next, rest, depth);
130
+ return;
131
+ }
132
+ if ((mode & GROUP_OTHER_BITS) !== 0)
133
+ tighten(segs, rel);
134
+ if (depth === 0)
135
+ return;
136
+ let entries;
137
+ try {
138
+ entries = readdirSync(join(root, ...segs), { withFileTypes: true });
139
+ }
140
+ catch (e) {
141
+ refuse(rel, codeOf(e));
142
+ return;
143
+ }
144
+ for (const entry of entries) {
145
+ if (entry.isDirectory() || entry.isSymbolicLink())
146
+ step(segs, entry.name, [], depth - 1);
147
+ }
148
+ };
149
+ let rootIntact = false;
150
+ try {
151
+ if (lstatSync(root).isSymbolicLink())
152
+ refused.push({ path: ".", code: SYMLINK_IN_PATH });
153
+ else
154
+ rootIntact = true;
155
+ }
156
+ catch (e) {
157
+ refuse(".", codeOf(e));
158
+ }
159
+ for (const { abs, children } of rootIntact ? rosterFor(layout) : []) {
160
+ const [first, ...rest] = segmentsUnder(root, abs) ?? [];
161
+ if (first !== undefined)
162
+ step([], first, rest, children);
163
+ }
164
+ if (refused.length > 0) {
165
+ emit(sinks.refused, "local_data_dir_mode_refused", {
166
+ count: refused.length,
167
+ mode: "0700",
168
+ entries: refused.slice(0, REFUSED_LISTED),
169
+ remedy: "these directories (relative to the data root) could not be tightened or read, or are reached through a symbolic link (SYMLINK_IN_PATH: links are never followed, the data root itself included) — as the owner of the real directory run `chmod 700` on it (or chown it to the server's user) and restart; the server keeps serving meanwhile",
170
+ });
171
+ }
172
+ if (tightened.length > 0) {
173
+ emit(sinks.tightened, "local_data_dir_modes_tightened", {
174
+ count: tightened.length,
175
+ mode: "0700",
176
+ examples: tightened.slice(0, TIGHTENED_EXAMPLES),
177
+ note: "store directories created by earlier versions with the default mode were tightened to 0700 once; later boots find them tight",
178
+ });
179
+ }
180
+ return { tightened, refused };
181
+ }
182
+ //# sourceMappingURL=local-data-dir-modes-m39.js.map
@@ -0,0 +1,11 @@
1
+ /** marker 的文件名(数据根顶层;公开契约)。 */
2
+ export declare const ENGINE_HIGH_WATER_FILE = "engine-high-water.json";
3
+ /**
4
+ * **判与抬**(唯一的座;唯一调用点 `openLocalBackend`,数据根锁在手、本仓任何一只店建起之前):
5
+ * ① 本构建版本 `engine` 按发布线读不出({@link buildReleaseTriple})⇒ 抛 {@link StoreBootRefusalError}(marker 不读、不写);
6
+ * ② 读 `<root>/engine-high-water.json`:读不出 / 高水位高于本构建 ⇒ 抛 {@link LocalDataRootSchemaMismatchError}(`boot` 形;文件原地不动,不抬);
7
+ * ③ 缺席或低于本构建 ⇒ 原子写 `{"highWater": <本构建的纯三段>}`(`required`);相等 ⇒ 不写,只过持久化屏障(读到的可能是上一次没证完的那份)。写不进 / 证不了 ⇒ 抛(点名路径与原因)。
8
+ * 同步:它在后端打开的同步段里跑(建店之前),拒在这里就不会有一只店被建起。
9
+ */
10
+ export declare function holdEngineHighWater(root: string, engine: string): void;
11
+ //# sourceMappingURL=local-engine-high-water.d.ts.map
@@ -0,0 +1,59 @@
1
+ import { join, resolve } from "node:path";
2
+ import { z } from "zod";
3
+ import { atomicWriteFileSync, proveDurableSync } from "./owner-only-file-mode.js";
4
+ import { createZodColumnReader, decodeJsonColumn } from "./sql-json-column.js";
5
+ import { LocalDataRootSchemaMismatchError, dataRootMismatchOf, readDataRootFileTextSync } from "./local-session-store.js";
6
+ import { buildReleaseTriple, compareReleaseTriples, releaseText, releaseTriple } from "./release-version.js";
7
+ import { StoreBootRefusalError } from "./store-contracts.js";
8
+ export const ENGINE_HIGH_WATER_FILE = "engine-high-water.json";
9
+ const ENGINE_HIGH_WATER_LABEL = `${ENGINE_HIGH_WATER_FILE} (the local engine high-water marker)`;
10
+ const ENGINE_HIGH_WATER_SHAPE = z
11
+ .object({ highWater: z.string() })
12
+ .strict()
13
+ .transform((v, ctx) => {
14
+ const triple = releaseTriple(v.highWater);
15
+ if (triple === undefined) {
16
+ ctx.addIssue({ code: "custom", message: "highWater is not a plain x.y.z release version" });
17
+ return z.NEVER;
18
+ }
19
+ return { highWater: v.highWater, triple };
20
+ });
21
+ const readEngineHighWater = createZodColumnReader(ENGINE_HIGH_WATER_SHAPE);
22
+ export function holdEngineHighWater(root, engine) {
23
+ const own = buildReleaseTriple(engine);
24
+ if (own === undefined) {
25
+ throw new StoreBootRefusalError(`DB_BACKEND=local: this build's own version (package.json "version": ${JSON.stringify(engine.slice(0, 64))}) is not a release version (x.y.z, optionally with a prerelease or build suffix) — refusing to open the data root ${root}: ` +
26
+ "the engine high-water fence needs this build's release line to show it is not older than the engines that opened this data root, and to record its own. " +
27
+ "Run a build whose package.json carries a release version.");
28
+ }
29
+ const path = resolve(join(root, ENGINE_HIGH_WATER_FILE));
30
+ const raw = readDataRootFileTextSync(path);
31
+ let equal = false;
32
+ if (raw.state === "unreadable")
33
+ throw new LocalDataRootSchemaMismatchError([dataRootMismatchOf(path, ENGINE_HIGH_WATER_LABEL, raw.fault)], "boot");
34
+ if (raw.state === "text") {
35
+ let marker;
36
+ try {
37
+ marker = decodeJsonColumn(raw.text, readEngineHighWater, ENGINE_HIGH_WATER_LABEL);
38
+ }
39
+ catch (e) {
40
+ throw new LocalDataRootSchemaMismatchError([dataRootMismatchOf(path, ENGINE_HIGH_WATER_LABEL, e)], "boot");
41
+ }
42
+ const order = compareReleaseTriples(marker.triple, own);
43
+ if (order > 0) {
44
+ throw new LocalDataRootSchemaMismatchError([{ path, label: ENGINE_HIGH_WATER_LABEL, problem: "newer-engine", unknownFields: [], engineHighWater: { highWater: marker.highWater, engine } }], "boot");
45
+ }
46
+ equal = order === 0;
47
+ }
48
+ try {
49
+ if (equal)
50
+ proveDurableSync(path);
51
+ else
52
+ atomicWriteFileSync(path, `${JSON.stringify({ highWater: releaseText(own) })}\n`, { durability: "required" });
53
+ }
54
+ catch (e) {
55
+ throw new Error(`DB_BACKEND=local cannot record the engine high-water ${path} durably: ${e instanceof Error ? e.message : String(e)} — refusing to open the data root: ` +
56
+ "writing to it without a durable high-water would let an older engine open it later unrefused. Repair write access to the data root and restart.", { cause: e });
57
+ }
58
+ }
59
+ //# sourceMappingURL=local-engine-high-water.js.map
@@ -2,13 +2,13 @@ import { FileSessionRepo, type AcquiredSession, type PlacedSessionRow, type Sess
2
2
  import { type PlacementAcquireOpts } from "./session-placement.js";
3
3
  import { z } from "zod";
4
4
  import { StoreBootRefusalError, type SessionRunClaimSource, type SessionRunRollupSource, type SessionSummary } from "./store-contracts.js";
5
- import { type ClientSessionRowWrite, type ReplaySessionRowWrite, type ReplaySessionRowWriteOutcome, type SessionRowPatch, type SessionRowWriteOutcome } from "../session-row.js";
5
+ import { type ClientSessionRowWrite, type ReplaySessionRowWrite, type ReplaySessionRowWriteOutcome, type SessionRowAnswer, type SessionRowPatch, type SessionRowWriteOutcome } from "../session-row.js";
6
+ import { type SqlJsonColumnProblem } from "./sql-json-column.js";
6
7
  import { type LocalArchiveKeptStamped, type LocalArchiveUnreadable } from "./one-time-migrations.js";
7
8
  import { type Logger } from "../observability/logger.js";
8
9
  import { type SessionFace } from "../session-incarnation.js";
9
- import { type ExecutionLane } from "../execution-lane-caps.js";
10
10
  import { type ExecutionPlacementSeat, type LocalPlacementBackfillSeat } from "../execution-placement.js";
11
- import { type ForkTarget, type ForkToOutcome } from "./session-fork.js";
11
+ import { type ForkPlacement, type ForkTarget, type ForkToOutcome } from "./session-fork.js";
12
12
  import { type InstructionSourceBaseline } from "../instruction-source-notice.js";
13
13
  import type { SessionWorkspace } from "../session-workspace.js";
14
14
  import { type StagedCommitOptions, type StagingHandle, type SyncRelation } from "../session-sync-kernel.js";
@@ -21,7 +21,7 @@ export declare const SESSION_META_CELL_OBJECT: z.ZodObject<{
21
21
  owner: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
22
  execution: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
23
23
  role: z.ZodLiteral<"writer">;
24
- lane: z.ZodCustom<ExecutionLane, ExecutionLane>;
24
+ lane: z.ZodCustom<"host" | "e2b" | "k8s" | "ssh" | "adb" | "local-docker" | "device" | "none", "host" | "e2b" | "k8s" | "ssh" | "adb" | "local-docker" | "device" | "none">;
25
25
  }, z.core.$strict>, z.ZodObject<{
26
26
  role: z.ZodLiteral<"mirror">;
27
27
  }, z.core.$strict>], "role">>;
@@ -29,33 +29,84 @@ export declare const SESSION_META_CELL_OBJECT: z.ZodObject<{
29
29
  createdAt: z.ZodOptional<z.ZodString>;
30
30
  forkedFrom: z.ZodOptional<z.ZodString>;
31
31
  }, z.core.$strict>;
32
- /** 严格边档清册里一只边档的对账读数(拒句的逐文件一段;{@link LocalDataRootSchemaMismatchError.findings})。 */
33
- export interface LocalSidecarMismatch {
32
+ /**
33
+ * 数据根对账里一只文件的读数(拒句的逐文件一段;{@link LocalDataRootSchemaMismatchError.findings}):严格边档清册里的一只边档,或引擎版本高水位 marker
34
+ * (`local-engine-high-water.ts`)。**判别联合**,判别位 `problem`:`"newer-engine"` ⇒ {@link LocalDataRootNewerEngine}(必带 `engineHighWater`);
35
+ * 别的每一个词 ⇒ {@link LocalDataRootUnreadable}(没有 `engineHighWater`)—— 载荷跟着判别位走,由类型保证,不靠运行时约定。
36
+ */
37
+ export type LocalDataRootMismatch = LocalDataRootUnreadable | LocalDataRootNewerEngine;
38
+ /**
39
+ * 读不出的种别:形 —— `not-json` / `malformed` / `not-text`(形读者的判词),或 I/O 的 errno(`EACCES` / `EISDIR` / 悬空符号链接的 `ENOENT` …,恒以 `E` 起头);
40
+ * 说不出 errno ⇒ `unreadable`。`newer-engine` 不在其中(那是另一支)。
41
+ */
42
+ export type LocalDataRootReadProblem = SqlJsonColumnProblem | `E${string}` | "unreadable";
43
+ /** 一只文件本构建读不出(形或 I/O);形读者不认得的键非空 ⇒ 这只文件是更新的引擎写下的(数据根比本构建新)。 */
44
+ export interface LocalDataRootUnreadable {
34
45
  /** 文件的绝对路径。 */
35
46
  readonly path: string;
36
- /** 角色(`<文件名> (the local <角色> sidecar)`)。 */
47
+ /** 角色(`<文件名> (the local <角色> sidecar)` / `<文件名> (the local engine high-water marker)`)。 */
37
48
  readonly label: string;
38
- /** 读不出的种别:`not-json` / `malformed`(形),或 I/O 的 errno(`EACCES` …;没有 errno ⇒ `unreadable`)。 */
39
- readonly problem: string;
40
- /** 格里本构建不认得的键(非空 ⇒ 这只边档是更新的引擎写下的:数据根比本构建新)。 */
49
+ readonly problem: LocalDataRootReadProblem;
50
+ /** 本构建不认得的键(非空 ⇒ 这只文件是更新的引擎写下的:数据根比本构建新)。 */
41
51
  readonly unknownFields: readonly string[];
42
52
  }
53
+ /** 引擎版本高水位 marker 读得出,而它记的高水位高于本构建:数据根被更新的引擎服务过。 */
54
+ export interface LocalDataRootNewerEngine {
55
+ /** marker 的绝对路径。 */
56
+ readonly path: string;
57
+ /** 角色(`engine-high-water.json (the local engine high-water marker)`)。 */
58
+ readonly label: string;
59
+ readonly problem: "newer-engine";
60
+ readonly unknownFields: readonly [];
61
+ /** marker 记的高水位(纯 `x.y.z`)与本构建的版本串(原样:发布线读得出的 `x.y.z`,可带预发布 / 构建后缀;读不出的构建在判之前就拒了)。 */
62
+ readonly engineHighWater: {
63
+ readonly highWater: string;
64
+ readonly engine: string;
65
+ };
66
+ }
43
67
  /**
44
68
  * **local 数据根的「本构建读不出」拒**(起服对账一族的 local 腿;机读码与 SQL 列册对账同一个 `config.schema_mismatch`,拒句同形)。
45
69
  * 一只严格边档用它那一只严格读者读不出 ⇒ 这一只拒,文件原地不动、一个字节不改。两处触发、一只类:
46
- * · `boot` —— 起服对账({@link LocalSessionStore.assertStrictSidecarsReadable},唯一调用点 `LocalBackend.ensureSchema()`)把清册里每一只读不出的合成一只:拒启;
70
+ * · `boot` —— 两处拒启:local 后端**打开数据根的那一刻**(锁在手之后、本仓任何一只店建起之前;`store-backend.ts` 的 `openLocalBackend`)引擎版本高水位 marker 读不出 / 高于本构建
71
+ * (`local-engine-high-water.ts`,读数种别 `newer-engine` 或读不出的那几种;同一判词「数据根比代码新」的第二种证据 —— 这一拒由公开序列的 `ensureSchema()` 交出);
72
+ * 起服对账(`LocalBackend.ensureSchema()`)里严格边档清册读不出的每一只合成一只({@link LocalSessionStore.assertStrictSidecarsReadable});
47
73
  * · `serving` —— 起服之后这只边档第一次被碰时才读不出(嵌入方跳过了 `ensureSchema()`;或起服后别的写者把它写成本构建读不出的形,在替换之前那一读里看见):
48
74
  * 读不出的是**形**(`not-json` / `malformed`,确定的判词)⇒ 这只边档在本进程里从此每一读每一写都交这一只(重启才重判);碰它的请求失败(把它交给 HTTP 全局兜底的路由:
49
75
  * 500 `internal.error` + 一行 error 级 `request_error` 带本码;自己接住故障的路由按各自的 500 臂答)。I/O 故障(非确定)不粘。
50
76
  * 属 {@link StoreBootRefusalError} 族:起服降级臂不吞它(缺省推导的 local 不会被吃成内存后端)。拒句零原文:只点名文件、种别与不认得的键名,不带任何值。
51
77
  */
52
78
  export declare class LocalDataRootSchemaMismatchError extends StoreBootRefusalError {
53
- readonly findings: readonly LocalSidecarMismatch[];
79
+ readonly findings: readonly LocalDataRootMismatch[];
54
80
  readonly when: "boot" | "serving";
55
81
  /** 机读码(与 SQL 列册对账 / 退役 schema 的拒启同一个)。 */
56
82
  readonly code = "config.schema_mismatch";
57
- constructor(findings: readonly LocalSidecarMismatch[], when: "boot" | "serving");
83
+ constructor(findings: readonly LocalDataRootMismatch[], when: "boot" | "serving");
58
84
  }
85
+ /** 数据根对账文件的一读的读数(两个出口同形)。 */
86
+ export type DataRootFileText = {
87
+ readonly state: "absent";
88
+ } | {
89
+ readonly state: "unreadable";
90
+ readonly fault: unknown;
91
+ } | {
92
+ readonly state: "text";
93
+ readonly text: string;
94
+ };
95
+ /**
96
+ * 数据根对账文件的**字节一读**(唯一的判;异步 {@link readDataRootFileText} 与同步 {@link readDataRootFileTextSync} 两个出口只差 I/O 的同步性,`ENOENT` 之后的判都经 {@link judgedAfterEnoent}):
97
+ * 严格边档的三个触点({@link SidecarMap.readDisk})、一次性迁移 M40 的会话腿走异步出口,引擎版本高水位 marker(`local-engine-high-water.ts`,在后端打开的同步段里判)走同步出口,
98
+ * 所以「缺文件 / 读不出(I/O)/ 读到字节」在各处是同一个判决。形判据不在这里:每个调用点用自己的具名形读者解码([ref] 门③:读者不经参数传递,哪一套键判了这只文件在调用点上看得见)。
99
+ * **缺席 = 目录里没有这一项**(不是读不出):`ENOENT` 而这一项还在(悬空符号链接 —— 链接在、目标不在)⇒ 读不出,不当缺席(与配置根的悬空链接同一条律);
100
+ * 读完 `ENOENT` 到 `lstat` 之间这一项被删 ⇒ 缺席;`lstat` 自己判不了(非 `ENOENT`)⇒ 读不出。
101
+ */
102
+ export declare function readDataRootFileText(path: string): Promise<DataRootFileText>;
103
+ /** {@link readDataRootFileText} 的同步出口(同一判)。 */
104
+ export declare function readDataRootFileTextSync(path: string): DataRootFileText;
105
+ /**
106
+ * 读不出的故障 → 一段读数(唯一一处;严格边档的拒与引擎版本高水位 marker 同经它):形的故障({@link SqlJsonColumnError})带它的种别与形读者不认得的键,
107
+ * I/O 故障带 errno(没有 ⇒ `unreadable`)。
108
+ */
109
+ export declare function dataRootMismatchOf(path: string, label: string, fault: unknown): LocalDataRootUnreadable;
59
110
  /**
60
111
  * local 车道会话存档的**唯一 repo 出口**:本仓里每一只读 `<root>/sessions/*.jsonl` 的 `FileSessionRepo` 都从这里取(`LocalSessionStore` 的底座;会话视图窗不再自开 repo,
61
112
  * 它的元数据与日志都由店交出 —— `local-session-window.ts`),所以坏记录的披露座只有这一份接线。座 = F 类 `server.session-repo.corrupt-record-skipped`(会话存档里读不出的记录丢的是可用性:
@@ -158,27 +209,24 @@ export declare class LocalSessionStore implements SessionStore {
158
209
  /** Set by touch/delete when the map mutated; cleared by a write that captured the change. A write that ran while this
159
210
  * is set re-runs (a touch that landed during an active write isn't dropped). Drives the chain's re-run guard (bug B). */
160
211
  private dirty;
161
- /** Monotonic per-write counter — feeds a UNIQUE tmp filename per write so overlapping writes can't share one tmp path
162
- * and tear each other's bytes (bug B). */
163
- private writeSeq;
164
212
  /** Last time a sidecar-write error was warned (bug D): throttle the best-effort warn so a persistently-failing disk
165
213
  * doesn't spam the log on every debounced flush. 0 ⇒ never warned. */
166
214
  private lastWarnAt;
167
215
  /** Absolute path to the lastActivity JSON sidecar, or undefined when not persisting (in-memory-only deployment). */
168
216
  private readonly sidecarPath?;
169
- /** Title map (`session-titles.json`) — the local twin of the SQL `session_meta.title` column: one cell, two writers
217
+ /** Title map (`session-titles.json`) — the local twin of the SQL `session_ext.title` column: one cell, two writers
170
218
  * (the user's {@link writeSessionRowCells}; the auto-titler's {@link setTitleIfNull}, fills an absent cell
171
219
  * only — writer order: `src/session-row.ts`; both under the session write lock). Separate file from the lastActivity sidecar ON PURPOSE (that format is a
172
220
  * #10 clobber area); ultra-low-rate. Cross-instance sharing: see {@link SidecarMap}. */
173
221
  private readonly titles;
174
- /** Pin map (`session-pinned.json`, {@link readPinnedSidecar}) — the local twin of `session_meta.pinned`. Its own file for
222
+ /** Pin map (`session-pinned.json`, {@link readPinnedSidecar}) — the local twin of `session_ext.pinned`. Its own file for
175
223
  * the same reason titles have theirs (one small map per concern, no format coupling); absent key = not pinned. */
176
224
  private readonly pinned;
177
225
  /** [ref] — instruction-source baselines (`session-instruction-sources.json`): the chain member the session's previous
178
- * run selected, encoded like the SQL twins' `session_meta.instruction_source` column ('' = none; missing key = never
226
+ * run selected, encoded like the SQL twins' `session_ext.instruction_source` column ('' = none; missing key = never
179
227
  * recorded). Its own file for the same reason titles have theirs: one small map per concern, no format coupling. */
180
228
  private readonly instructionSources;
181
- /** 会话行的位置与项目那一格(`session-workspaces.json`)—— SQL 孪生 `session_meta.workspace` 的 local 对位:`{ [sessionId]: 那一格的文本 }`,
229
+ /** 会话行的位置与项目那一格(`session-workspaces.json`)—— SQL 孪生 `session_ext.workspace` 的 local 对位:`{ [sessionId]: 那一格的文本 }`,
182
230
  * 文本与 SQL 列同一只编解码(`session-workspace-cell.ts`,一格读不出 ⇒ 读作没有记录并计一次)。缺键 = 没有记录。一事一档,理由同 titles。 */
183
231
  private readonly workspaces;
184
232
  /**
@@ -212,7 +260,7 @@ export declare class LocalSessionStore implements SessionStore {
212
260
  * 执行席(规则在 `src/execution-placement.ts`):读 = 那一格的 `execution` 位(fork 创建的格而存档不在 ⇒ `forking`);place / markMirror 在这只会话的写锁里判住客
213
261
  * (化身 + 头读投影的属主 `owner ?? null`)再只改 `execution` 那一位 —— 住客换了(删后重建、M10 窗内认领)⇒ `gone`,不写。
214
262
  * 认领(run 店的单活槽,{@link SessionRunClaimSource}):`markMirror` 在同一把写锁里读它、只拦「absent → mirror」这一笔(判序与 SQL 孪生同,见 {@link markMirrorExecution});`place` 是认领持有者自己的初始放置写,不读认领。
215
- * local 的导入三写口不读认领 —— 它们的认领判在路由(第一阶段写前判 + 提交前复判),没有 SQL 孪生那样的写事务内读。
263
+ * 导入三写口(整段 `importEntries` / `replaceEntries` / 暂存提交)同在写锁里读它、交 SQL 事务内钩 `import` 臂的那一只判官 {@link judgeImportWrite}(见 {@link admitImportHeld});路由的认领判(第一阶段写前判 + 提交前复判)是更早的一道,不是唯一一道。
216
264
  */
217
265
  readonly executionPlacement: ExecutionPlacementSeat;
218
266
  /**
@@ -237,6 +285,15 @@ export declare class LocalSessionStore implements SessionStore {
237
285
  constructor(repo: HeadReadingSessionRepo & Partial<PlacementRecordingRepo>, runs: SessionRunRollupSource & SessionRunClaimSource, dataDir?: string, opts?: {
238
286
  log?: Pick<Logger, "info" | "warn">;
239
287
  } & LocalSessionStoreDeclaration);
288
+ /**
289
+ * 🔴 一次性迁移 **M40 的 local 会话腿**(窗口见 `plugins/one-time-migrations.ts` 登记表 M40 行;唯一调用点 `LocalBackend.ensureSchema()` 的**第一步**,
290
+ * 排在 {@link assertStrictSidecarsReadable} 之前 —— 严格读的执行位只认本版车道词,旧词先到那里就整只拒启):会话元数据边档里 `execution` 位记成退役词的
291
+ * writer 格改记新名,整只原子重写一次。只改那一个词,别的字节按 JSON 原样写回。字节经边档的唯一一读({@link readDataRootFileText})。
292
+ * 缺文件 / 读不出(I/O 故障如 EACCES / EISDIR、坏 JSON、不是对象)⇒ 不抛、不改,交给其后的严格对账判 —— 它读同一只文件、以 `config.schema_mismatch`
293
+ * 拒(那是这只拒码在本店的唯一铸点);这里抛了,拒码与具名拒都会丢。读得出而写不进 ⇒ {@link ExecutionLaneRenameWriteRefusedError}(拒启,降级臂不吞)。
294
+ * 内存部署 / 没有旧词 ⇒ 零写。返回改了的格数。词的属主 = `execution-lane-rename-m40.ts`。
295
+ */
296
+ renameRetiredExecutionLaneWordM40(): Promise<number>;
240
297
  /**
241
298
  * [ref] —— **起服对账的 local 腿**(SQL 列册对账的对位;唯一调用点 `LocalBackend.ensureSchema()`,排在 M33 快照消化之前 —— 消化会写会话元数据格):
242
299
  * 严格边档清册里的每一只读一次盘(`SidecarMap.reconcile`:冷 ⇒ 载入那一读;已载入 ⇒ 重读只判);读不出的合成**一只** {@link LocalDataRootSchemaMismatchError}
@@ -428,7 +485,7 @@ export declare class LocalSessionStore implements SessionStore {
428
485
  * 抛 ⇒ 读不出(尾部 I/O 故障之类:行头好、头读照样抛);否则读得出。所以行上的 `unreadable` 与头读、读口对同一只会话的答复同读。
429
486
  */
430
487
  private listedRowOf;
431
- /** [ref] —— 换源通告的基线读(local 孪生;三态读法与 SQL 两孪生的 `session_meta.instruction_source` 同一只编解码)。 */
488
+ /** [ref] —— 换源通告的基线读(local 孪生;三态读法与 SQL 两孪生的 `session_ext.instruction_source` 同一只编解码)。 */
432
489
  readInstructionSource(sessionId: string): Promise<InstructionSourceBaseline>;
433
490
  /**
434
491
  * [ref] —— CAS 覆写基线(契约见 `InstructionSourceStore`:期望值不符 ⇒ 不写;**没落盘 ⇒ 内存不动、抛**,与 SQL 孪生
@@ -584,6 +641,17 @@ export declare class LocalSessionStore implements SessionStore {
584
641
  limit: number;
585
642
  q?: string;
586
643
  }): Promise<SessionSummary[]>;
644
+ /** {@link listSessions} 带每行的住客(属主 + 化身那一格,与行同一刻读)—— `OwnerAwareSessionStore.listSessionRows`;化身不进行本身。 */
645
+ listSessionRows(opts: {
646
+ owner?: string;
647
+ includeUnowned?: boolean;
648
+ cursor?: {
649
+ lastActivityAt: string;
650
+ sessionId: string;
651
+ };
652
+ limit: number;
653
+ q?: string;
654
+ }): Promise<Array<SessionRowAnswer<SessionSummary>>>;
587
655
  /** 列表行要读的边档一次装齐(lastActivity / 标题 / 置顶 / 会话元数据);各自记忆化,只有第一次真读盘。 */
588
656
  private loadRowSidecars;
589
657
  /** 列表行上的属主:那一格的属主(没有格 / 属主从没被记下 ⇒ null —— 与 `headOf(id)?.owner` 同答;列表不补铸缺的格,`headOf` 在第一次读时补)。 */
@@ -611,8 +679,11 @@ export declare class LocalSessionStore implements SessionStore {
611
679
  * 修前把参数原样写进新格:`fork(owned, null)` 铸出一份匿名的有主历史。
612
680
  * 拷**已提交**的叶(契约):在飞的 assistant 轮不进孩子 —— 分叉点只有引擎那一只判官(core 7.55.0 起包根导出的 `settledForkOptions`),本店把唤醒出来的源会话交给它、
613
681
  * 把它的答案原样交给引擎自己的 `repo.fork`(与 core 内存店 `TtlSessionStore.fork` 同一条调用链);两只 SQL 孪生同读它(`session-fork.ts`)。钉:
614
- * core 店契约盒的 `[fork]` 格(`test/session-store-contract-kit.test.ts`)。 */
615
- fork(sourceId: string, owner?: string | null): Promise<string | null>;
682
+ * core 店契约盒的 `[fork]` 格(`test/session-store-contract-kit.test.ts`)。
683
+ * `opts.placement`(后台 fork 子代的转录)= fork 进委派分区:见 {@link forkToHeld} 的建行点。 */
684
+ fork(sourceId: string, owner?: string | null, opts?: {
685
+ placement?: ForkPlacement;
686
+ }): Promise<string | null>;
616
687
  /**
617
688
  * **fork 续写的店契约**(local 一形;规则与结果闭集在 `session-fork.ts`,SQL 孪生同义):
618
689
  * · **两把写锁**:按 id 字典序依次取源与目标的写锁(锁不可重入;同 id 只取一把)—— 同 id 的每个写者(删除 / 登记 / 导入 / 按 id 首建 / 别的 fork)都在目标那把锁里,
@@ -622,11 +693,20 @@ export declare class LocalSessionStore implements SessionStore {
622
693
  * (不交属主 —— 引擎仓匿名;子存档的属主格抄自源存档,源匿名 ⇒ 子匿名)。
623
694
  * 崩在两步之间 = fork 创建的格而存档不在 = `forking`:普通取用一律 {@link SessionForkInProgressError};同键重试在两把锁内补拷存档、答 `replayed`。
624
695
  * 拷贝抛错(不是崩溃)⇒ 撤掉刚写的目标格再上抛(撤不掉 ⇒ 留下的就是 `forking`,与崩在中间同形);
625
- * · **撞已在** ⇒ 按目标格的属主与 fork 键分类({@link classifyForkTarget})。
696
+ * · **fork 进委派分区**(`target.placement`,只在声明了分区的店落;没声明 ⇒ 忽略、照常 fork):元组随引擎 `repo.fork` 落进子存档行头 —— 与带 placement 的建行
697
+ * ({@link createPlacedHeld})同一处、同一形(存档行头,first-write 不可变,`placedAt` 由 repo 铸);行的属主仍是上面那一读(元组不带属主)。建后读回准入同
698
+ * `createPlacedHeld`(镜像方向:repo 交回的行没带这一组元组 ⇒ `placement_refused`):拒了就删掉刚拷的存档、再撤目标格(**存档先删、格后撤** —— 崩在中间留下的是
699
+ * 「格在而存档不在」的惰性残格;反过来会留下一份没有属主格的有主历史拷贝),删不掉 ⇒ 两只故障同句点名、出路随句;
700
+ * · **撞已在** ⇒ 按目标格的属主与 fork 键分类({@link classifyForkTarget});placed 目标永不带键(型面互斥)⇒ 永不 `replayed`。
626
701
  */
627
702
  forkTo(sourceId: string, owner: string | null, target: ForkTarget): Promise<ForkToOutcome | null>;
628
703
  /** {@link forkTo} 的锁内一形(调用方持源与目标两把写锁)。 */
629
704
  private forkToHeld;
705
+ /**
706
+ * fork 进委派分区的建后读回准入(锁内,调用方持目标的写锁、刚拷完存档):判据 = 引擎那一只 `admitSessionPlacement`(镜像方向,读 repo 交回的那一份行头元组,零额外读),
707
+ * 与 {@link createPlacedHeld} 的读回同一判。拒 ⇒ 存档先删、目标格后撤(见 {@link forkToHeld} 注),再原样上抛那只 `placement_refused`;删不掉 ⇒ 同码、两只故障同句点名。
708
+ */
709
+ private admitForkedPlacement;
630
710
  /** 2c session-sync — EXPORT a session's full durable entry log (core `SessionRepo.exportEntries`; the
631
711
  * in-memory/file repo holds the whole log so there is no floor to bypass). null if the source is unknown / the
632
712
  * underlying repo lacks the optional seam. The owner is NOT exported — import re-stamps it. */
@@ -669,9 +749,10 @@ export declare class LocalSessionStore implements SessionStore {
669
749
  private withImportLock;
670
750
  /**
671
751
  * 三个导入写口(`importEntries` / `replaceEntries` / 暂存提交的换装臂)的共用写序(调用方持这只会话的写锁,属主的形已在入口判过):
672
- * ① 只读、零写:引擎闸 `validateEntriesForImport`(坏包 ⇒ `invalid_session`)· 本处写者 ⇒ {@link SessionWriterPresentError} · `forking` ⇒
673
- * {@link SessionForkInProgressError} · 不是这个写口的门判过的行 ⇒ {@link importRowRefused}(判据 {@link importMayLand},按写口带来的 {@link ImportLanding};
674
- * 这条路径上唯一一次判属主);
752
+ * ① 只读、零写:引擎闸 `validateEntriesForImport`(坏包 ⇒ `invalid_session`)· 准入 {@link admitImportHeld}(读 run 认领、交判官 {@link judgeImportWrite}:活 run 认领 ⇒
753
+ * `SessionActiveRunError` · 本处写者 ⇒ `SessionWriterPresentError` · `forking` ⇒ {@link SessionForkInProgressError};SQL 孪生的事务内钩 `import` 臂同一只判官、同序、同拒;
754
+ * `judged` 在 {@link commitStagedImport} 里准入过,不再来一遍)· 不是这个写口的门判过的行 ⇒ {@link importRowRefused}(判据 {@link importMayLand},按写口带来的
755
+ * {@link ImportLanding};这条路径上唯一一次判属主);
675
756
  * ② 行先:{@link landImportCell}(属主重戳为导入者、化身与 fork 键沿用或新铸、执行位 mirror;建档时刻与谱系照带,新行写此刻);
676
757
  * ③ 内容,按写口的动词(唯一读法在下面这一只 switch;这里不读那一格、不判属主,只换**内容**;交给引擎仓的属主恒缺席 —— 规则一):
677
758
  * · `create` / `judged`(导入):原地换锁里读到的那一份存档的日志(没有存档 ⇒ 导入新建一只,匿名),以锁里读到的存档头为 `expect.row`(**行代号**:
@@ -691,6 +772,14 @@ export declare class LocalSessionStore implements SessionStore {
691
772
  * 读法 = {@link isPlacedRow}(行头读不出 ⇒ 按普通行答,坏档照样换得掉;说不出 ⇒ 抛)。
692
773
  */
693
774
  private assertNotPlacedHeld;
775
+ /**
776
+ * 三个导入写口落 mirror 之前的**准入**(调用方持这只会话的写锁;{@link importHeld} ① 与暂存提交「内容相同、日志不动」那一支都经这一处):**取锁 → 读认领 → 判 → 写**,
777
+ * 与 {@link markMirrorExecution} 同序。判官就是 SQL 孪生事务内钩 `import` 臂的那一只 {@link judgeImportWrite}(词、拒码、先认领后写者都在判官里,本店不另写一份):
778
+ * 认领读 run 店的单活槽({@link SessionRunClaimSource})、格读 {@link placementCellOf}(`forking` 按 {@link forkingOf} 判好)—— 读口按需:认领在 ⇒ 不探存档。
779
+ * 拒 ⇒ 抛那只 typed 错,此时导入的任何一笔写(格 / 存档 / 新近)都还没发生(读侧的补铸除外:盘上有会话而格缺时,读它的读口先补铸那一格 —— 与别的读口同,幂等)。
780
+ * 路由的认领判(第一阶段写前判 + 提交前复判)仍在、更早一道,不再是唯一防线。
781
+ */
782
+ private admitImportHeld;
694
783
  /**
695
784
  * ① 的属主 / 住客条件:这一行此刻是不是这个写口的门判过的行({@link ImportLanding};一次读、零写 —— 格缺时「行在不在」只问存档的唯一探针
696
785
  * {@link existsInRepo},不补铸那一格)。属主比的是头读的读法 `owner ?? null`(从没被记下 = 无主;格缺而存档在 = 从没被记下),比较器是删除门的那一只
@@ -700,7 +789,7 @@ export declare class LocalSessionStore implements SessionStore {
700
789
  private importMayLand;
701
790
  /**
702
791
  * ② 推送落下的那一格 —— 三个导入写口与暂存提交「内容相同、日志不动」那一支都经这**一处**(调用方持写锁、① 已判过):属主重戳为导入者;
703
- * 化身与 fork 键经 {@link carriedRowCells}(三只店同一句)读那一格自己 —— 行在 ⇒ 沿用(同一行 = 同一位住客,属主重戳与否不改这一判),刚建 ⇒ 新铸、不带键;
792
+ * 化身与 fork 键经 {@link carriedRowCells}(SQL 两店就地改写同一行、化身与旁表行不动 —— 同一结局)读那一格自己 —— 行在 ⇒ 沿用(同一行 = 同一位住客,属主重戳与否不改这一判),刚建 ⇒ 新铸、不带键;
704
793
  * 执行位 = mirror(导入落下的是「写者在别处」;SQL 孪生的提交点同一句写)。**在 `before` 上改这三位**,别的位(建档时刻、谱系)照带;刚建的行建档时刻 = 此刻。
705
794
  * 只写这一格:四只行边档与新近不在这里。交回写之前的那一格(`undefined` = 原本没有),③ 撤回用。
706
795
  */
@@ -741,7 +830,7 @@ export declare class LocalSessionStore implements SessionStore {
741
830
  * {@link LocalStagingHandle.commit} 的整段 —— **一次持锁**(这只会话的写锁,{@link withSessionWriteLock}):属主 CAS(此刻的属主格 = 这次导入的门判过的那一格,
742
831
  * 否则抛 {@link StagedCommitOwnerChangedError},一个字节不写;在判目的端日志之前判,SQL 孪生同序)→ 分区判 → 提交时重新分类(目的端此刻的日志 vs staged)→
743
832
  * 这一提交要换日志(不是「id 与内容都相同」那一支)⇒ 带戳存档判({@link assertArchiveAnonymous};只有 local 店有带戳存档,SQL 孪生没有这一步)→
744
- * 拒未经同意的 fork / stale / 载荷分叉(带戳判在它们之前:带戳存档上日志换不了,同步冲突与载荷分叉的出路 —— 带同意重来 —— 无从谈起)→ 本处写者拒 → 换装(导入写序 ①②③,落点 `judged` = 上面这一判;化身与 fork 键按换装律沿用)或 identical 且内容相同时日志不动、
833
+ * 拒未经同意的 fork / stale / 载荷分叉(带戳判在它们之前:带戳存档上日志换不了,同步冲突与载荷分叉的出路 —— 带同意重来 —— 无从谈起)→ 准入({@link admitImportHeld}:读认领 → 本处写者 / fork 中间态 → 拒;fork 中间态的拒也在这一处,不再在提交入口另判一遍)→ 换装(导入写序 ①②③,落点 `judged` = 上面这一判;化身与 fork 键按换装律沿用)或 identical 且内容相同时日志不动、
745
834
  * 行照样落(② 那一格:重戳属主 + mirror)→ 两支同记新近(推送即活动)→ **在同一次持锁里**
746
835
  * 读出落定的会话面交回。锁放下之前谁也换不掉这一位住客,所以交回的面就是这次提交落下的那一位(SQL 孪生在提交事务里读同一行,同义);
747
836
  * 提交之后按住客条件写的重放(会话行两位)只认这只面,不再重读。改属主的每一条写腿(登记 / 删除 / 导入 / 换装)都在同一把锁里,所以锁内这一读到锁放下都成立。