@sema-agent/server 7.150.0 → 7.151.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 (341) hide show
  1. package/MIGRATION.md +185 -0
  2. package/USAGE.md +53 -25
  3. package/deploy/sema-up/README.md +7 -1
  4. package/deploy/sema-up/chart/Chart.yaml +1 -1
  5. package/deploy/sema-up/chart/templates/NOTES.txt +5 -0
  6. package/deploy/sema-up/chart/templates/_helpers.tpl +15 -16
  7. package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -3
  8. package/deploy/sema-up/chart/templates/server.yaml +5 -3
  9. package/deploy/sema-up/chart/values-full-single.yaml +3 -1
  10. package/deploy/sema-up/chart/values.yaml +8 -1
  11. package/deploy/sema-up/cluster-up.sh +1 -0
  12. package/deploy/sema-up/kube-up.sh +1 -1
  13. package/deploy/sema-up/lib/flagshape.sh +1 -1
  14. package/deploy/sema-up/lib/helm-values-cluster.py +2 -0
  15. package/deploy/sema-up/lib/helm-values-kube.py +2 -0
  16. package/dist/adoption/import.js +3 -3
  17. package/dist/approval-ask-machine.d.ts +1 -1
  18. package/dist/approval-card.d.ts +2 -2
  19. package/dist/approval-gate-currency.d.ts +1 -1
  20. package/dist/auth-bridge.d.ts +20 -0
  21. package/dist/auth-bridge.js +9 -0
  22. package/dist/background-session-reap.d.ts +1 -1
  23. package/dist/bake-runner/main.d.ts +4 -2
  24. package/dist/bind-host.d.ts +2 -3
  25. package/dist/bind-host.js +2 -4
  26. package/dist/boot/budget-tracing.js +1 -1
  27. package/dist/boot/engine-lease.d.ts +5 -0
  28. package/dist/boot/engine-lease.js +1 -0
  29. package/dist/boot/execution-env.d.ts +8 -14
  30. package/dist/boot/execution-env.js +54 -17
  31. package/dist/boot/execution-lane.js +32 -5
  32. package/dist/boot/late-binds.d.ts +8 -4
  33. package/dist/boot/late-binds.js +7 -1
  34. package/dist/boot/memory-consolidation.d.ts +3 -2
  35. package/dist/boot/memory-consolidation.js +6 -6
  36. package/dist/boot/reapers.d.ts +5 -0
  37. package/dist/boot/reapers.js +12 -1
  38. package/dist/boot/resolve-spec.d.ts +3 -3
  39. package/dist/boot/resolve-spec.js +31 -22
  40. package/dist/boot/runner-deps.d.ts +9 -2
  41. package/dist/boot/runner-deps.js +3 -3
  42. package/dist/boot/session-age-out.d.ts +36 -0
  43. package/dist/boot/session-age-out.js +101 -0
  44. package/dist/boot/session-faces.d.ts +5 -14
  45. package/dist/boot/session-faces.js +9 -5
  46. package/dist/boot/stage-01-config.js +2 -0
  47. package/dist/boot/stage-05-execution-env.d.ts +5 -3
  48. package/dist/boot/stage-05-execution-env.js +2 -2
  49. package/dist/boot/stage-06-runners.d.ts +7 -4
  50. package/dist/boot/stage-06-runners.js +15 -6
  51. package/dist/boot/stage-07-capability-layer.d.ts +7 -4
  52. package/dist/boot/stage-07-capability-layer.js +2 -1
  53. package/dist/boot/stage-08-reapers.d.ts +7 -4
  54. package/dist/boot/stage-08-reapers.js +4 -2
  55. package/dist/boot/stage-09-leader.d.ts +11 -5
  56. package/dist/boot/stage-09-leader.js +12 -3
  57. package/dist/boot/stage-10-http-server.d.ts +11 -5
  58. package/dist/boot/stage-10-http-server.js +3 -6
  59. package/dist/boot/web-admin.js +3 -1
  60. package/dist/boot/workflow-orchestration.d.ts +7 -2
  61. package/dist/boot/workflow-orchestration.js +24 -7
  62. package/dist/bounded-rotation.d.ts +29 -0
  63. package/dist/bounded-rotation.js +24 -0
  64. package/dist/capability-facts.d.ts +22 -13
  65. package/dist/capability-facts.js +28 -18
  66. package/dist/center-credential.d.ts +25 -6
  67. package/dist/center-credential.js +25 -5
  68. package/dist/config-catalog.d.ts +26 -7
  69. package/dist/config-catalog.js +14 -11
  70. package/dist/config-invariants.d.ts +2 -1
  71. package/dist/config-invariants.js +4 -4
  72. package/dist/config-types.d.ts +10 -4
  73. package/dist/config.d.ts +51 -2
  74. package/dist/config.js +35 -24
  75. package/dist/deployment-shape.d.ts +9 -1
  76. package/dist/deployment-shape.js +2 -1
  77. package/dist/device-protocol.d.ts +5 -4
  78. package/dist/device-protocol.js +1 -1
  79. package/dist/device-ws-hub.js +3 -2
  80. package/dist/device-ws-protocol.d.ts +63 -10
  81. package/dist/device-ws-protocol.js +56 -25
  82. package/dist/engine-identity.d.ts +19 -7
  83. package/dist/engine-identity.js +10 -2
  84. package/dist/entry-mode-clamp-notice.d.ts +2 -1
  85. package/dist/execution-env-refusal.d.ts +23 -0
  86. package/dist/execution-env-refusal.js +5 -0
  87. package/dist/execution-lane-caps.d.ts +3 -1
  88. package/dist/field-conflict.d.ts +1 -1
  89. package/dist/file-history-capture.d.ts +11 -4
  90. package/dist/file-history-capture.js +9 -6
  91. package/dist/file-history-disclosure.d.ts +7 -5
  92. package/dist/file-history-disclosure.js +7 -5
  93. package/dist/fleet/drain-entry.d.ts +4 -0
  94. package/dist/hooks/hook-runner.js +2 -2
  95. package/dist/host-lsp-manager.d.ts +2 -2
  96. package/dist/http/admission.js +17 -2
  97. package/dist/http/approval-sweeps.js +5 -5
  98. package/dist/http/checkpoint-ctx.d.ts +2 -0
  99. package/dist/http/checkpoint-ctx.js +1 -0
  100. package/dist/http/dispatch.d.ts +2 -1
  101. package/dist/http/dispatch.js +34 -27
  102. package/dist/http/durable-run-leg.js +16 -16
  103. package/dist/http/health-self-report.d.ts +9 -1
  104. package/dist/http/health-self-report.js +2 -0
  105. package/dist/http/owner-access.d.ts +31 -11
  106. package/dist/http/owner-access.js +37 -6
  107. package/dist/http/resume-ctx-read.js +25 -3
  108. package/dist/http/resume-legs.d.ts +2 -1
  109. package/dist/http/resume-legs.js +259 -79
  110. package/dist/http/route-ctx.d.ts +18 -8
  111. package/dist/http/route-table.d.ts +1 -1
  112. package/dist/http/routes/admin-memory-optout.d.ts +1 -1
  113. package/dist/http/routes/agents-roster.js +2 -3
  114. package/dist/http/routes/approvals-assistant.js +4 -3
  115. package/dist/http/routes/background.d.ts +3 -3
  116. package/dist/http/routes/capabilities.js +8 -5
  117. package/dist/http/routes/fleet.js +10 -8
  118. package/dist/http/routes/projects.d.ts +3 -2
  119. package/dist/http/routes/projects.js +4 -5
  120. package/dist/http/routes/runs.js +102 -36
  121. package/dist/http/routes/session-sync.d.ts +4 -3
  122. package/dist/http/routes/session-sync.js +172 -77
  123. package/dist/http/routes/sessions-list.js +13 -7
  124. package/dist/http/routes/sessions.js +10 -6
  125. package/dist/http/routes/tasks.js +30 -16
  126. package/dist/http/routes/trace-usage.js +2 -2
  127. package/dist/http/server.d.ts +21 -27
  128. package/dist/http/server.js +2 -2
  129. package/dist/http/submit-ctx.js +5 -4
  130. package/dist/http/wire-types.d.ts +14 -4
  131. package/dist/identity-source.d.ts +20 -3
  132. package/dist/identity-source.js +14 -0
  133. package/dist/index.d.ts +4 -0
  134. package/dist/lane-home-probe.d.ts +3 -7
  135. package/dist/lane-home-probe.js +0 -1
  136. package/dist/leader/leader.d.ts +2 -1
  137. package/dist/leg-facts.d.ts +13 -5
  138. package/dist/leg-facts.js +2 -1
  139. package/dist/memory-scope.d.ts +5 -4
  140. package/dist/memory-scope.js +4 -4
  141. package/dist/memory-sync-client.d.ts +30 -2
  142. package/dist/memory-sync-client.js +16 -9
  143. package/dist/observability/err-text.d.ts +7 -0
  144. package/dist/observability/err-text.js +5 -0
  145. package/dist/observability/fail-open.d.ts +7 -3
  146. package/dist/observability/fail-open.js +7 -3
  147. package/dist/observability/metrics.js +1 -0
  148. package/dist/orchestration/workflow-notify-journal.d.ts +18 -1
  149. package/dist/orchestration/workflow-notify-journal.js +12 -1
  150. package/dist/orchestration/workflow-park-decision.d.ts +70 -18
  151. package/dist/orchestration/workflow-park-decision.js +49 -10
  152. package/dist/orchestration/workflow-park-holder.d.ts +65 -0
  153. package/dist/orchestration/workflow-park-holder.js +98 -0
  154. package/dist/orchestration/workflow-record-fence.d.ts +36 -0
  155. package/dist/orchestration/workflow-record-fence.js +42 -0
  156. package/dist/owner-faces.d.ts +1 -1
  157. package/dist/parked-decide.d.ts +104 -53
  158. package/dist/parked-decide.js +153 -117
  159. package/dist/peer-directory.d.ts +2 -2
  160. package/dist/peer-inbound-face.d.ts +2 -6
  161. package/dist/peer-inbound-face.js +0 -3
  162. package/dist/permission-mode-admission.d.ts +41 -5
  163. package/dist/permission-mode-admission.js +29 -3
  164. package/dist/plugins/adoption-log-sql.d.ts +3 -1
  165. package/dist/plugins/adoption-log-sql.js +7 -1
  166. package/dist/plugins/approval-ask-store-file.d.ts +10 -2
  167. package/dist/plugins/approval-ask-store-file.js +8 -0
  168. package/dist/plugins/approval-ask-store-memory.d.ts +6 -1
  169. package/dist/plugins/approval-ask-store-memory.js +28 -9
  170. package/dist/plugins/approval-ask-store-sql.d.ts +43 -2
  171. package/dist/plugins/approval-ask-store-sql.js +34 -5
  172. package/dist/plugins/approval-exemption-store.js +3 -0
  173. package/dist/plugins/approval-nonce-store.js +2 -0
  174. package/dist/plugins/breaker-state-sql.js +2 -0
  175. package/dist/plugins/caching-session-store.d.ts +9 -15
  176. package/dist/plugins/caching-session-store.js +6 -0
  177. package/dist/plugins/device-store-sql.js +6 -0
  178. package/dist/plugins/error-origin.d.ts +18 -0
  179. package/dist/plugins/error-origin.js +10 -0
  180. package/dist/plugins/execution-placement-sql.js +6 -6
  181. package/dist/plugins/image-bake-store-sql.js +6 -0
  182. package/dist/plugins/image-index-sql.js +4 -0
  183. package/dist/plugins/landed-attendants.d.ts +212 -0
  184. package/dist/plugins/landed-attendants.js +161 -0
  185. package/dist/plugins/leader-run-store-sql.js +4 -0
  186. package/dist/plugins/local-session-live-reference.d.ts +40 -0
  187. package/dist/plugins/local-session-live-reference.js +39 -0
  188. package/dist/plugins/local-session-store.d.ts +71 -33
  189. package/dist/plugins/local-session-store.js +129 -27
  190. package/dist/plugins/memory-engine-pg.js +4 -0
  191. package/dist/plugins/memory-engine-sql-apply.js +5 -2
  192. package/dist/plugins/memory-engine-tidb.js +4 -0
  193. package/dist/plugins/memory-optout-grant-store-sql.js +4 -0
  194. package/dist/plugins/memory-sync-store-pg.js +5 -0
  195. package/dist/plugins/memory-sync-store-tidb.js +5 -0
  196. package/dist/plugins/one-time-migrations.d.ts +57 -63
  197. package/dist/plugins/one-time-migrations.js +162 -90
  198. package/dist/plugins/org-delivery-quota-store.js +4 -1
  199. package/dist/plugins/outcome-ledger-sql.js +2 -0
  200. package/dist/plugins/permission-rule-store-sql.js +11 -4
  201. package/dist/plugins/pg-cost-quota.js +4 -0
  202. package/dist/plugins/pg-pool.js +24 -1
  203. package/dist/plugins/pg-rate-limiter.js +2 -0
  204. package/dist/plugins/posix-shell-fs.d.ts +6 -1
  205. package/dist/plugins/posix-shell-fs.js +4 -1
  206. package/dist/plugins/remote-env-adb.d.ts +19 -15
  207. package/dist/plugins/remote-env-adb.js +41 -15
  208. package/dist/plugins/remote-env-connect-seat.d.ts +105 -0
  209. package/dist/plugins/remote-env-connect-seat.js +72 -0
  210. package/dist/plugins/remote-env-device.d.ts +22 -5
  211. package/dist/plugins/remote-env-device.js +106 -8
  212. package/dist/plugins/remote-env-e2b.d.ts +15 -6
  213. package/dist/plugins/remote-env-e2b.js +42 -32
  214. package/dist/plugins/remote-env-file-error.js +6 -2
  215. package/dist/plugins/remote-env-host.d.ts +17 -0
  216. package/dist/plugins/remote-env-host.js +30 -38
  217. package/dist/plugins/remote-env-k8s.d.ts +41 -39
  218. package/dist/plugins/remote-env-k8s.js +53 -30
  219. package/dist/plugins/remote-env-local-docker.d.ts +13 -8
  220. package/dist/plugins/remote-env-local-docker.js +34 -41
  221. package/dist/plugins/remote-env-ssh.d.ts +18 -12
  222. package/dist/plugins/remote-env-ssh.js +60 -59
  223. package/dist/plugins/remote-shell.d.ts +98 -1
  224. package/dist/plugins/remote-shell.js +218 -0
  225. package/dist/plugins/resume-anchor-store-sql.d.ts +11 -2
  226. package/dist/plugins/resume-anchor-store-sql.js +12 -5
  227. package/dist/plugins/retention-lane-store-sql.js +4 -0
  228. package/dist/plugins/retention-sql.d.ts +20 -2
  229. package/dist/plugins/retention-sql.js +11 -0
  230. package/dist/plugins/run-store-sql.d.ts +21 -2
  231. package/dist/plugins/run-store-sql.js +31 -7
  232. package/dist/plugins/scenario-prefix-switch-m42.d.ts +1 -1
  233. package/dist/plugins/scenario-prefix-switch-m42.js +2 -2
  234. package/dist/plugins/schema-consistency.d.ts +4 -2
  235. package/dist/plugins/schema-consistency.js +19 -2
  236. package/dist/plugins/send-file-ledger.js +3 -0
  237. package/dist/plugins/serving-requirement.d.ts +26 -7
  238. package/dist/plugins/serving-requirement.js +11 -4
  239. package/dist/plugins/session-birth.d.ts +6 -2
  240. package/dist/plugins/session-capture-record-store-sql.js +2 -0
  241. package/dist/plugins/session-ext-table.d.ts +14 -1
  242. package/dist/plugins/session-ext-table.js +5 -1
  243. package/dist/plugins/session-row-sql.d.ts +49 -2
  244. package/dist/plugins/session-row-sql.js +56 -13
  245. package/dist/plugins/session-store-sql.d.ts +34 -18
  246. package/dist/plugins/session-store-sql.js +98 -17
  247. package/dist/plugins/shared-memory-store-sql.d.ts +1 -0
  248. package/dist/plugins/shared-memory-store-sql.js +6 -2
  249. package/dist/plugins/sql-driver.d.ts +2 -1
  250. package/dist/plugins/sql-driver.js +18 -3
  251. package/dist/plugins/sql-errors.d.ts +11 -6
  252. package/dist/plugins/sql-errors.js +5 -6
  253. package/dist/plugins/stop-then-start-sentence.d.ts +10 -4
  254. package/dist/plugins/stop-then-start-sentence.js +14 -10
  255. package/dist/plugins/stop-then-start.d.ts +109 -0
  256. package/dist/plugins/stop-then-start.js +104 -0
  257. package/dist/plugins/store-backend.d.ts +40 -13
  258. package/dist/plugins/store-backend.js +169 -27
  259. package/dist/plugins/store-boundary.d.ts +57 -0
  260. package/dist/plugins/store-boundary.js +139 -0
  261. package/dist/plugins/store-contracts.d.ts +17 -0
  262. package/dist/plugins/store-fault-sentence-m53.d.ts +7 -0
  263. package/dist/plugins/store-fault-sentence-m53.js +25 -0
  264. package/dist/plugins/store-fault.d.ts +26 -7
  265. package/dist/plugins/store-fault.js +18 -2
  266. package/dist/plugins/task-attachment-store.js +9 -0
  267. package/dist/plugins/task-list-store-sql.d.ts +2 -2
  268. package/dist/plugins/task-list-store-sql.js +10 -8
  269. package/dist/plugins/tidb-cost-quota.js +4 -0
  270. package/dist/plugins/tidb-pool.js +2 -1
  271. package/dist/plugins/tidb-rate-limiter.js +4 -0
  272. package/dist/plugins/user-input-ledger-sql.js +4 -0
  273. package/dist/plugins/workflow-run-store-sql.d.ts +28 -10
  274. package/dist/plugins/workflow-run-store-sql.js +64 -4
  275. package/dist/plugins/workspace-fill.d.ts +4 -7
  276. package/dist/plugins/workspace-fill.js +2 -1
  277. package/dist/plugins/write-behind-counter.js +5 -0
  278. package/dist/project-context.d.ts +0 -2
  279. package/dist/project-context.js +4 -8
  280. package/dist/project-registry.d.ts +46 -0
  281. package/dist/project-registry.js +44 -0
  282. package/dist/request-key-closure.js +1 -1
  283. package/dist/request-value-closure.d.ts +4 -0
  284. package/dist/request-value-closure.js +10 -0
  285. package/dist/run-acceptance.d.ts +3 -2
  286. package/dist/run-acceptance.js +4 -6
  287. package/dist/run-local.js +1 -0
  288. package/dist/runs.d.ts +37 -8
  289. package/dist/runs.js +53 -12
  290. package/dist/runtime-governance.d.ts +5 -4
  291. package/dist/security.d.ts +30 -32
  292. package/dist/security.js +41 -7
  293. package/dist/server-secret-env.d.ts +12 -10
  294. package/dist/server-secret-env.js +24 -15
  295. package/dist/session-bindings.d.ts +82 -0
  296. package/dist/session-bindings.js +18 -0
  297. package/dist/session-children-retire.d.ts +2 -2
  298. package/dist/session-children-retire.js +2 -6
  299. package/dist/session-deletion.d.ts +16 -1
  300. package/dist/session-error-wire.d.ts +3 -3
  301. package/dist/session-error-wire.js +3 -3
  302. package/dist/session-incarnation.d.ts +10 -0
  303. package/dist/session-incarnation.js +10 -1
  304. package/dist/session-kind.d.ts +57 -0
  305. package/dist/session-kind.js +22 -0
  306. package/dist/session-row.d.ts +21 -1
  307. package/dist/session-row.js +7 -1
  308. package/dist/session-sync-kernel.d.ts +24 -14
  309. package/dist/session-sync-kernel.js +3 -6
  310. package/dist/session-sync.d.ts +4 -98
  311. package/dist/session-sync.js +1 -71
  312. package/dist/session-titler.d.ts +10 -3
  313. package/dist/session-titler.js +19 -6
  314. package/dist/ssh-host-key.d.ts +5 -0
  315. package/dist/ssh-host-key.js +3 -0
  316. package/dist/stores-sql/file-history-store-sql.d.ts +52 -2
  317. package/dist/stores-sql/file-history-store-sql.js +108 -70
  318. package/dist/stores-sql/pg-session-storage.d.ts +34 -7
  319. package/dist/stores-sql/pg-session-storage.js +37 -13
  320. package/dist/stores-sql/retention-store-sql.d.ts +1 -9
  321. package/dist/stores-sql/retention-store-sql.js +2 -10
  322. package/dist/stores-sql/session-policy-store-sql.d.ts +30 -7
  323. package/dist/stores-sql/session-policy-store-sql.js +61 -44
  324. package/dist/stores-sql/session-write-hooks.d.ts +11 -0
  325. package/dist/stores-sql/tidb-session-store.d.ts +58 -7
  326. package/dist/stores-sql/tidb-session-store.js +37 -13
  327. package/dist/submission-exit.d.ts +3 -2
  328. package/dist/submission-exit.js +9 -1
  329. package/dist/task-cwd.d.ts +2 -2
  330. package/dist/task-settings.d.ts +6 -5
  331. package/dist/terminal.d.ts +33 -2
  332. package/dist/terminal.js +139 -9
  333. package/dist/tool-approval.d.ts +140 -6
  334. package/dist/tool-approval.js +165 -72
  335. package/dist/trace/self-minted-wire.d.ts +290 -27
  336. package/dist/trace/self-minted-wire.js +101 -13
  337. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +78 -27
  338. package/package.json +2 -2
  339. package/wire-changes/server@7.151.0.json +762 -0
  340. package/dist/http/session-inherit-env.d.ts +0 -36
  341. package/dist/http/session-inherit-env.js +0 -6
@@ -23,7 +23,7 @@ import type { IncomingMessage, ServerResponse } from "node:http";
23
23
  import type { SessionHead, WorkflowRun, WorkflowRunStore } from "@sema-agent/core";
24
24
  import type { RunStore, StoreBackend } from "../plugins/store-backend.js";
25
25
  import { type Logger } from "../observability/logger.js";
26
- import type { LatestRunRef, RunListQuery, RunRecord } from "../plugins/store-contracts.js";
26
+ import type { LatestRunRef, RunListQuery, RunRecord, SessionListQuery } from "../plugins/store-contracts.js";
27
27
  import type { ServiceConfig } from "../config-types.js";
28
28
  import type { SessionAuditReadOpts } from "../audit.js";
29
29
  import { type DeploymentShapeInput } from "../deployment-shape.js";
@@ -31,7 +31,7 @@ import { type SessionAgent } from "../session-agent.js";
31
31
  import { type SessionFace } from "../session-incarnation.js";
32
32
  import { type Admitted, type Caller, type FaceId, type ListFaceId, type ListFilter, type OwnedReading, type Qual, type RunFaceId, type SessionFaceId, type WorkflowFaceId } from "../owner-faces.js";
33
33
  import { type Person, type Subject } from "../owner-brands.js";
34
- import { type OwnerAwareSessionStore } from "../security.js";
34
+ import { type OwnerAwareSessionStore, type SessionListItem } from "../security.js";
35
35
  import { type OperatorRoster } from "./principal-gate.js";
36
36
  import { type RouteDeps } from "./route-ctx.js";
37
37
  import type { FlatServiceDeps } from "./server.js";
@@ -427,10 +427,15 @@ export declare function admitSessionById(entry: Entry, res: ServerResponse, stor
427
427
  */
428
428
  export declare function readVisibleSession(entry: Entry, store: SessionGateStore, sessionId: string): Promise<Admitted<SessionHead> | undefined>;
429
429
  /**
430
- * 承认之后的**世代围栏**(会话事件流的心跳拍):这只会话此刻的属主还是承认时读到的那一格吗 —— 删了(没有这一行 / 读不出按面折)或换主 ⇒ 否。
431
- * 与 {@link readVisibleSession} 的「再判可见」不同:比的是同一行前后两次读到的属主(删建 / 易主 ⇒ 作废),两侧都是行上的属主,不是调用方身份。
430
+ * 承认之后的**世代围栏**(会话事件流的心跳拍):这只会话此刻的住客还是承认时读到的那一位吗 —— 删了(没有这一行 / 读不出按面折)、删后同 id 重建(包括同一属主)
431
+ * 或换主 ⇒ 否。比较器 = 住客复核的唯一判 `sameOccupant`(属主 ∧ 化身);与 {@link readVisibleSession} 的「再判可见」不同:两侧都是同一行前后两次的住客读数,不是调用方身份。
432
432
  */
433
- export declare function sessionOwnerUnchanged(entry: Entry, store: SessionGateStore, sessionId: string, admittedOwner: string | null): Promise<boolean>;
433
+ export declare function sessionOccupantUnchanged(entry: Entry, store: SessionGateStore, sessionId: string, admitted: Pick<SessionHead, "owner" | "incarnation">): Promise<boolean>;
434
+ /**
435
+ * 同步族门读之后的**住客复判**(律在 `routes/session-sync.ts` 门注「门后读」):门承认过的那一位此刻还占着这只 id 吗 —— 同一只比较器 `sameOccupant`,读法是门的两种读法之一:
436
+ * `pull` = 活行头(拉取口只认活行);`push` = 占位头(活行 ∪ 在删行,与门同一只 `deletionHeadReadOf`)。此刻无行 ⇒ 不是。只在门判**有住客**时调(门判空闲的口门后不读会话数据)。
437
+ */
438
+ export declare function recheckSyncGate(store: DeletionGateStore, sessionId: string, admitted: SessionFace, port: "pull" | "push"): Promise<boolean>;
434
439
  /** 会话行的完整判(不下发,交回承认 / `undefined`):两读之间要再判一次的口(同步导入的提交前复判)与「看不见按自己的形答」的口用。 */
435
440
  export declare function judgeSession<T extends OwnedReading>(entry: Entry, store: PlacementReadingStore | undefined, sessionId: string, reading: T): Promise<Admitted<T> | undefined>;
436
441
  /** 这一份承认里的调用方是 fleet 吗(本口 `fleet` 列里的一格成立):fork 新属主「继承源属主」那一支读它。 */
@@ -489,6 +494,11 @@ export interface SessionFacts {
489
494
  * 读者:回退锚的逐轮捕获(两条起跑腿读叶子)、失认领答复的「会话在不在」(不碰叶子)、同步拉取清单的当前叶子。
490
495
  */
491
496
  export declare function sessionFactsReadOf(store: Pick<OwnerAwareSessionStore, "headOf"> | undefined): ((sessionId: string) => Promise<SessionFacts | undefined>) | undefined;
497
+ /**
498
+ * 会话此刻的住客(属主 + 化身,同一行同一次头读,经 {@link sessionFaceOfHead} 投影 —— 活行上读到空化身响亮拒)。读者:运行腿的回退锚写座在见证里还没有化身时
499
+ * 钉住这条 run 自己的那一位(`runs.ts` 的 `createRunAnchorWriter`;调用发生在 run 在跑、认领在手的时刻)。店不交头读 ⇒ `undefined`。
500
+ */
501
+ export declare function sessionOccupantReadOf(store: Pick<OwnerAwareSessionStore, "headOf"> | undefined): ((sessionId: string) => Promise<SessionFace | undefined>) | undefined;
492
502
  /**
493
503
  * 会话在委派树里的位置(wire 键 `agent` 的值;唯一读口):店的 placed 位一读 → `session-agent.ts` 的 `sessionAgentOf`(元组不带属主)。店不交这一面 ⇒ `undefined`
494
504
  * (这台部署不存元组,不探)。探针抛 ⇒ 原样上抛 —— 读不出怎么说归读者(视图读响亮失败;队列只缺那一行的键并计数),本函数不替任何一面把故障说成「不是子代」。
@@ -509,10 +519,16 @@ export declare function engineRulesKeyOf(store: Pick<OwnerAwareSessionStore, "he
509
519
  * 读者:会话面板的上一腿(面 `run.panel`,看不见 = 不投那个键)。
510
520
  */
511
521
  export declare function readVisibleLatestRun(entry: Entry, store: Pick<RunStore, "latestRunForSession">, sessionId: string): Promise<LatestRunRef | undefined>;
512
- /** run 列表的属主过滤参数(一只派生,读与游标指纹同读):视域钉住一位主体 ⇒ 强制那一位(调用方点名的 `owner` 不算);不钉人(fleet)⇒ 点名的照用(运维视图)。 */
513
- export declare function runListOwnerOf(filter: ListFilter, named: string | undefined): string | undefined;
514
- /** run 列表的读口(列表面 `list.read`):过滤参数由 {@link runListOwnerOf} 从视域派生,只在这里落成店的过滤参数。 */
522
+ /** 列表的属主过滤参数(run 列表与会话列表同一只派生,读与游标指纹同读):视域钉住一位主体 ⇒ 强制那一位(调用方点名的 `owner` 不算);不钉人(fleet)⇒ 点名的照用(运维视图)。 */
523
+ export declare function listOwnerOf(filter: ListFilter, named: string | undefined): string | undefined;
524
+ /** run 列表的读口(列表面 `list.read`):过滤参数由 {@link listOwnerOf} 从视域派生,只在这里落成店的过滤参数。 */
515
525
  export declare function listVisibleRuns(store: Pick<RunStore, "listRuns">, filter: ListFilter, named: string | undefined, query: Omit<RunListQuery, "owner">): Promise<RunRecord[]>;
526
+ /**
527
+ * 会话列表的读口(列表面 `session.list`;`GET /v1/sessions`):「读 + 过滤」只在这里落成店的过滤参数 —— 属主(由 {@link listOwnerOf} 从视域派生;`""` 是合法的精确属主,
528
+ * 只有「没给」才不过滤)、无主行的并入(视域的 `includeUnowned`)、视图(`sessionKind`,律 `session-kind.ts`:缺席 = 缺省视图)。谓词都打在店里(同一条 SELECT),
529
+ * 路由层不另滤行。peer 目录读同一只 lister 的缺省视图(`peer-directory.ts`)。
530
+ */
531
+ export declare function listVisibleSessions(lister: (opts: SessionListQuery) => Promise<SessionListItem[]>, filter: ListFilter, named: string | undefined, query: Omit<SessionListQuery, "owner" | "includeUnowned">): Promise<SessionListItem[]>;
516
532
  /** 审批 / 助手面按停驻 scope 列 run:属主过滤 = scope 的属主键(公共 scope `_` ⇒ 属主为 null 的 run,主体 ⇒ 恰它的;`security.ts` 的唯一编解码),只在这里落成店的过滤参数。 */
517
533
  export declare function listRunsOfScope(store: Pick<RunStore, "listRuns">, scope: string, limit: number): Promise<RunRecord[]>;
518
534
  /** 一把提交钥匙命中的行对这位调用方算什么:`visible` = 读得到的那一行;`occupied` = 有行但不是这次提交拿得到的(看不见 / 自带 taskId 而键指着别的行)—— 回执 409,不回显那一行。 */
@@ -602,14 +618,18 @@ export interface WorkflowAdmission {
602
618
  /** 工作流门的一次判(不下发):承认,或拒因(没有 / 前门 / 看不见 / 会话断言不符)。 */
603
619
  export type WorkflowVerdict = WorkflowAdmission | "missing" | "door" | "not_visible" | "session_mismatch";
604
620
  /**
605
- * 工作流列表(`GET /v1/workflows`)—— 属主过滤只在这里落成店参数:调用方换成它的引擎身份(与 {@link judgeWorkflowRun} 同一只换算),店按 `scope` 列筛。
621
+ * 🔴 **一位调用方的工作流行住在 `scope` 列的哪一格**(唯一读法):调用方的主体换成它的引擎身份(`engine-identity.ts` 的 `engineScopeOf` —— 引擎按它写 scope:
622
+ * 带场景的请求今天是那个人,匿名是 `"default"`)。列表({@link listVisibleWorkflows})、按 id 的门({@link judgeWorkflowRun})与舰队流的工作流行 / 终态窗(`routes/fleet.ts`)同读这一只。
623
+ */
624
+ export declare function workflowScopeOf(subject: Subject | undefined): string;
625
+ /**
626
+ * 工作流列表(`GET /v1/workflows`)—— 属主过滤只在这里落成店参数:{@link workflowScopeOf},店按 `scope` 列筛。
606
627
  * 面表 `workflow.read` 只给属主(不放 fleet / 运维)⇒ 列表 = 调用方自己那一格的行。
607
628
  */
608
629
  export declare function listVisibleWorkflows(entry: Entry, store: Pick<WorkflowRunStore, "listByScope">, opts: Parameters<WorkflowRunStore["listByScope"]>[1]): ReturnType<WorkflowRunStore["listByScope"]>;
609
630
  /**
610
631
  * 🔴 **工作流行的判(唯一一处;[ref] 第二阶段)**:按 id 读一行(店的 `get`,不带 scope —— 修前是 core 按 scope 读 + 路由再比一次 scope,两读答同一问),
611
- * 行格 = `scope` 列的属主键(引擎写下的引擎身份,恒有主);调用方一侧换成它的引擎身份(`engine-identity.ts` 的 `engineScopeOf`:引擎按它写 scope ——
612
- * 带场景的请求是那个人,匿名是 `"default"`)再过事实函数 {@link qualsOf} + 面表;前门按这次请求的调用方判。承认之后按 {@link WORKFLOW_SESSION_ASSERTION} 判会话断言。
632
+ * 行格 = `scope` 列的属主键(引擎写下的引擎身份,恒有主);调用方一侧换成它的引擎身份({@link workflowScopeOf})再过事实函数 {@link qualsOf} + 面表;前门按这次请求的调用方判。承认之后按 {@link WORKFLOW_SESSION_ASSERTION} 判会话断言。
613
633
  */
614
634
  export declare function judgeWorkflowRun(entry: Entry, store: Pick<WorkflowRunStore, "get">, runId: string): Promise<WorkflowVerdict>;
615
635
  /** 工作流按 id 读面的门:没有 / 看不见 / 会话断言不符同一只投影(`workflow_missing`),前门经它的下发口。交回承认或 `undefined`(已应答)。 */
@@ -410,9 +410,24 @@ export async function readVisibleSession(entry, store, sessionId) {
410
410
  const verdict = await judgeSessionById(entry, store, sessionId);
411
411
  return verdict === undefined || verdict === "door" || verdict === "not_visible" ? undefined : verdict;
412
412
  }
413
- export async function sessionOwnerUnchanged(entry, store, sessionId, admittedOwner) {
413
+ export async function sessionOccupantUnchanged(entry, store, sessionId, admitted) {
414
414
  const head = await readOwnerCell(entry, sessionId, () => store.headOf(sessionId));
415
- return sessionRowPresent(head) && head.owner === admittedOwner;
415
+ return sessionRowPresent(head) && sameOccupant(admitted, head);
416
+ }
417
+ export async function recheckSyncGate(store, sessionId, admitted, port) {
418
+ const live = await store.headOf(sessionId);
419
+ switch (port) {
420
+ case "pull":
421
+ return rowRead(live) && sameOccupant(admitted, live);
422
+ case "push": {
423
+ const held = rowRead(live) ? live : await deletionHeadReadOf(store)(sessionId);
424
+ return rowRead(held) && sameOccupant(admitted, held);
425
+ }
426
+ default: {
427
+ const unknownPort = port;
428
+ throw new Error(`recheckSyncGate: no port ${JSON.stringify(unknownPort)}`);
429
+ }
430
+ }
416
431
  }
417
432
  export async function judgeSession(entry, store, sessionId, reading) {
418
433
  if (!sessionRowPresent(reading))
@@ -448,6 +463,15 @@ export function sessionFactsReadOf(store) {
448
463
  return rowRead(head) ? { get leafId() { return head.leafId; } } : undefined;
449
464
  };
450
465
  }
466
+ export function sessionOccupantReadOf(store) {
467
+ const headOf = store?.headOf;
468
+ if (typeof headOf !== "function")
469
+ return undefined;
470
+ return async (sessionId) => {
471
+ const head = await headOf.call(store, sessionId);
472
+ return rowRead(head) ? sessionFaceOfHead(sessionId, head) : undefined;
473
+ };
474
+ }
451
475
  export async function readSessionAgent(store, sessionId) {
452
476
  const placementOf = store?.placementOf;
453
477
  if (placementOf === undefined)
@@ -477,13 +501,17 @@ export async function readVisibleLatestRun(entry, store, sessionId) {
477
501
  const latest = await store.latestRunForSession(sessionId);
478
502
  return rowRead(latest) && seesRun(entry, latest.owner) ? latest : undefined;
479
503
  }
480
- export function runListOwnerOf(filter, named) {
504
+ export function listOwnerOf(filter, named) {
481
505
  return filter.gateOwner ?? named;
482
506
  }
483
507
  export function listVisibleRuns(store, filter, named, query) {
484
- const owner = runListOwnerOf(filter, named);
508
+ const owner = listOwnerOf(filter, named);
485
509
  return store.listRuns({ ...query, ...(owner ? { owner } : {}) });
486
510
  }
511
+ export function listVisibleSessions(lister, filter, named, query) {
512
+ const owner = listOwnerOf(filter, named);
513
+ return lister({ ...query, ...(owner !== undefined ? { owner } : {}), ...(filter.includeUnowned ? { includeUnowned: true } : {}) });
514
+ }
487
515
  export function listRunsOfScope(store, scope, limit) {
488
516
  return store.listRuns({ owner: ownerOfCheckpointScope(scope), limit });
489
517
  }
@@ -534,14 +562,17 @@ export const WORKFLOW_SESSION_ASSERTION = {
534
562
  "workflow-stream": { phase: "accept", label: "workflow.stream" },
535
563
  "workflow-agent-steer": { phase: "accept", label: "workflow.agent-steer" },
536
564
  };
565
+ export function workflowScopeOf(subject) {
566
+ return engineScopeOf(subject);
567
+ }
537
568
  export function listVisibleWorkflows(entry, store, opts) {
538
- return store.listByScope(engineScopeOf(entry.caller.subject), opts);
569
+ return store.listByScope(workflowScopeOf(entry.caller.subject), opts);
539
570
  }
540
571
  export async function judgeWorkflowRun(entry, store, runId) {
541
572
  const row = await store.get(runId);
542
573
  if (!rowRead(row))
543
574
  return "missing";
544
- const engineCaller = { ...entry.caller, subject: recoveredSubject(engineScopeOf(entry.caller.subject)) };
575
+ const engineCaller = { ...entry.caller, subject: recoveredSubject(workflowScopeOf(entry.caller.subject)) };
545
576
  const verdict = verdictOnQuals(entry, qualsOf(engineCaller, ownerCellOf(row.scope)));
546
577
  if (verdict === "door" || verdict === "not_visible")
547
578
  return verdict;
@@ -2,6 +2,7 @@ import { openCheckpointCtx } from "./checkpoint-ctx.js";
2
2
  import { storeFaultClassOf } from "../plugins/store-fault.js";
3
3
  import { refusalBody } from "./refusal-body.js";
4
4
  import { frozenProjectContextOf } from "../project-context.js";
5
+ import { frozenMemorySeedOf } from "../project-registry.js";
5
6
  export async function readResumeCtx(load, opening) {
6
7
  const read = await readStoredCtx(load);
7
8
  if (read.kind !== "ok")
@@ -9,14 +10,35 @@ export async function readResumeCtx(load, opening) {
9
10
  const opened = openCheckpointCtx(read.ctx, opening.opener, opening.sessionId);
10
11
  if (opened.kind !== "ok")
11
12
  return { kind: "unsealable", field: opened.field, reason: opened.reason };
13
+ const where = (key) => ({ kind: "corrupt", where: `checkpoint ctx for session ${JSON.stringify(opening.sessionId)}: ${key}` });
14
+ const { memorySeed: _storedSeed, projectContext: _storedContext, ...rest } = opened.ctx;
15
+ const seed = frozenMemorySeedOf(opened.ctx.memorySeed);
12
16
  const frozen = frozenProjectContextOf(opened.ctx.projectContext);
17
+ let seedPart;
18
+ switch (seed.kind) {
19
+ case "absent":
20
+ seedPart = {};
21
+ break;
22
+ case "none":
23
+ seedPart = { memorySeed: null };
24
+ break;
25
+ case "malformed":
26
+ return where("memorySeed");
27
+ case "ok":
28
+ seedPart = { memorySeed: seed.seed };
29
+ break;
30
+ default: {
31
+ const unhandled = seed;
32
+ throw new Error(`resume-ctx-read: unplaced frozen memory seed reading ${JSON.stringify(unhandled)}`);
33
+ }
34
+ }
13
35
  switch (frozen.kind) {
14
36
  case "absent":
15
- return { kind: "ok", ctx: opened.ctx };
37
+ return { kind: "ok", ctx: { ...rest, ...seedPart } };
16
38
  case "malformed":
17
- return { kind: "corrupt", where: `checkpoint ctx for session ${JSON.stringify(opening.sessionId)}: projectContext` };
39
+ return where("projectContext");
18
40
  case "ok":
19
- return { kind: "ok", ctx: { ...opened.ctx, projectContext: frozen.context } };
41
+ return { kind: "ok", ctx: { ...rest, ...seedPart, projectContext: frozen.context } };
20
42
  default: {
21
43
  const unhandled = frozen;
22
44
  throw new Error(`resume-ctx-read: unplaced frozen project context reading ${JSON.stringify(unhandled)}`);
@@ -129,7 +129,7 @@ export declare function createResumeLegs(ctx: {
129
129
  }) => void) => Promise<ResumeLegOutcome>;
130
130
  decisionRowAdmits: (cs: CheckpointStoreFull, token: CheckpointToken, who: KeyCaller | undefined, bodyScope: string | undefined) => Promise<boolean>;
131
131
  resumePreempted: (sessionId: string, req: IncomingMessage | undefined, acceptEarly?: boolean, decider?: KeyCaller, restatement?: ResumeRestatement) => Promise<ResumeLegOutcome>;
132
- startFreshHostTurn: (sessionId: string, objective: string, subject: string | undefined, req: IncomingMessage, workflowDecision: WorkflowDecisionDelivery, runId: string, restatement?: ResumeRestatement) => Promise<ResumeLegOutcome>;
132
+ startFreshHostTurn: (sessionId: string, objective: string, subject: string | undefined, req: IncomingMessage | undefined, workflowDecision: WorkflowDecisionDelivery, runId: string, restatement?: ResumeRestatement) => Promise<ResumeLegOutcome>;
133
133
  resumeWake: (sessionId: string, message: PendingSteerInput | undefined, caller: Subject | undefined, req: IncomingMessage | undefined, acceptEarly?: boolean, workflowDecision?: WorkflowDecisionDelivery, ownerLeaseAdmittedFor?: string, restatement?: ResumeRestatement) => Promise<ResumeLegOutcome>;
134
134
  preparePlanReview: (sessionId: string, log?: {
135
135
  taskId?: string;
@@ -146,6 +146,7 @@ export declare function createResumeLegs(ctx: {
146
146
  }>;
147
147
  drivePlanReview: (prepared: PreparedPlanReview, decision: "approve" | "edit" | "reject", editedPlan: string | undefined, reason: string | undefined, hostDecision: HostDecision, req: IncomingMessage | undefined, acceptEarly?: boolean, permissionModeAfter?: PlanApprovePermissionModeAfter) => Promise<ResumeLegOutcome>;
148
148
  sessionNotifyDoor: import("../session-notify-door.js").SessionNotifyDoor;
149
+ handOverRunEndedDecisions: (runId: string) => Promise<void>;
149
150
  };
150
151
  export {};
151
152
  //# sourceMappingURL=resume-legs.d.ts.map