@sema-agent/server 7.145.0 → 7.146.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 (275) hide show
  1. package/MIGRATION.md +492 -0
  2. package/USAGE.md +218 -47
  3. package/deploy/facts/CHANGES.json +25 -0
  4. package/deploy/facts/README.md +57 -0
  5. package/deploy/facts/lanes.json +54 -0
  6. package/deploy/facts/lanes.schema.json +57 -0
  7. package/deploy/facts/sandbox-rbac.json +113 -0
  8. package/deploy/facts/sandbox-rbac.schema.json +74 -0
  9. package/deploy/facts/sealed-key.json +9 -0
  10. package/deploy/facts/sealed-key.schema.json +52 -0
  11. package/deploy/sema-up/chart/templates/_helpers.tpl +19 -0
  12. package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +47 -7
  13. package/deploy/sema-up/chart/templates/server-v4pro.yaml +4 -0
  14. package/deploy/sema-up/chart/templates/server.yaml +4 -0
  15. package/deploy/sema-up/chart/values.yaml +7 -0
  16. package/deploy/sema-up/stack/sema-stack-cluster.yaml +30 -14
  17. package/dist/adoption/import-limits.d.ts +6 -0
  18. package/dist/adoption/import-limits.js +7 -0
  19. package/dist/adoption/import.d.ts +62 -0
  20. package/dist/adoption/import.js +107 -0
  21. package/dist/adoption/wire.d.ts +52 -0
  22. package/dist/adoption/wire.js +9 -0
  23. package/dist/approval-ask-machine.d.ts +2 -2
  24. package/dist/approval-card.d.ts +3 -12
  25. package/dist/approval-card.js +0 -4
  26. package/dist/approval-gate-currency.d.ts +1 -1
  27. package/dist/approval-gate-currency.js +1 -1
  28. package/dist/approval-reconciler.d.ts +1 -1
  29. package/dist/boot/deployment-mods.d.ts +11 -1
  30. package/dist/boot/deployment-mods.js +15 -2
  31. package/dist/boot/device-lane.js +2 -0
  32. package/dist/boot/engine-lease.d.ts +193 -21
  33. package/dist/boot/engine-lease.js +146 -20
  34. package/dist/boot/execution-env.d.ts +4 -0
  35. package/dist/boot/execution-env.js +12 -0
  36. package/dist/boot/exit-boundary.d.ts +50 -0
  37. package/dist/boot/exit-boundary.js +32 -0
  38. package/dist/boot/exit-last.d.ts +20 -4
  39. package/dist/boot/exit-last.js +21 -4
  40. package/dist/boot/governance-seams.js +1 -0
  41. package/dist/boot/memory-consolidation.d.ts +29 -17
  42. package/dist/boot/memory-consolidation.js +26 -15
  43. package/dist/boot/reapers.d.ts +12 -4
  44. package/dist/boot/reapers.js +39 -15
  45. package/dist/boot/resolve-spec.d.ts +2 -0
  46. package/dist/boot/resolve-spec.js +38 -15
  47. package/dist/boot/runner-deps.js +1 -1
  48. package/dist/boot/session-faces.js +3 -1
  49. package/dist/boot/shutdown.js +27 -9
  50. package/dist/boot/stage-01-config.js +1 -1
  51. package/dist/boot/stage-03-store-backend.d.ts +1 -0
  52. package/dist/boot/stage-03-store-backend.js +2 -2
  53. package/dist/boot/stage-04-stores.d.ts +1 -0
  54. package/dist/boot/stage-05-execution-env.d.ts +3 -0
  55. package/dist/boot/stage-05-execution-env.js +3 -3
  56. package/dist/boot/stage-06-runners.d.ts +3 -0
  57. package/dist/boot/stage-06-runners.js +11 -10
  58. package/dist/boot/stage-07-capability-layer.d.ts +3 -0
  59. package/dist/boot/stage-07-capability-layer.js +7 -2
  60. package/dist/boot/stage-08-reapers.d.ts +3 -0
  61. package/dist/boot/stage-08-reapers.js +3 -3
  62. package/dist/boot/stage-09-leader.d.ts +3 -0
  63. package/dist/boot/stage-10-http-server.d.ts +3 -0
  64. package/dist/boot/stage-10-http-server.js +3 -2
  65. package/dist/boot/stores.d.ts +1 -0
  66. package/dist/boot/stores.js +35 -19
  67. package/dist/boot/workflow-orchestration.d.ts +1 -1
  68. package/dist/boot/workflow-orchestration.js +2 -1
  69. package/dist/capabilities/composite-members.d.ts +3 -1
  70. package/dist/capabilities/composite-members.js +3 -1
  71. package/dist/capabilities/scenarios.d.ts +2 -2
  72. package/dist/capability-facts.d.ts +18 -1
  73. package/dist/capability-facts.js +25 -7
  74. package/dist/checkpoint-ctx-seal-m28.d.ts +1 -1
  75. package/dist/config-catalog.js +13 -4
  76. package/dist/config-provider.d.ts +2 -2
  77. package/dist/config-types.d.ts +43 -4
  78. package/dist/config.d.ts +6 -1
  79. package/dist/config.js +67 -11
  80. package/dist/deleted-session-ids.d.ts +19 -0
  81. package/dist/deleted-session-ids.js +26 -0
  82. package/dist/deploy-facts.d.ts +155 -0
  83. package/dist/deploy-facts.js +94 -0
  84. package/dist/device-ws-hub.d.ts +48 -3
  85. package/dist/device-ws-hub.js +48 -2
  86. package/dist/error-code-family.d.ts +35 -0
  87. package/dist/error-code-family.js +26 -0
  88. package/dist/fleet/drain-entry.d.ts +39 -3
  89. package/dist/fleet/drain-entry.js +6 -0
  90. package/dist/fleet/fleet-bus.d.ts +2 -1
  91. package/dist/hooks/branch-transcript.d.ts +1 -1
  92. package/dist/hooks/branch-transcript.js +1 -0
  93. package/dist/hooks/classic-stations.d.ts +25 -8
  94. package/dist/hooks/classic-stations.js +29 -3
  95. package/dist/hooks/hook-runner.d.ts +33 -16
  96. package/dist/hooks/hook-runner.js +166 -73
  97. package/dist/hooks/hook-source.d.ts +14 -2
  98. package/dist/hooks/hook-source.js +8 -0
  99. package/dist/http/active-run-conflict.d.ts +1 -1
  100. package/dist/http/active-run-conflict.js +1 -1
  101. package/dist/http/admission.js +11 -1
  102. package/dist/http/checkpoint-ctx.d.ts +59 -71
  103. package/dist/http/checkpoint-ctx.js +34 -40
  104. package/dist/http/dispatch.js +18 -2
  105. package/dist/http/durable-run-leg.d.ts +5 -0
  106. package/dist/http/durable-run-leg.js +1 -0
  107. package/dist/http/execution-context.d.ts +4 -0
  108. package/dist/http/execution-context.js +9 -0
  109. package/dist/http/health-self-report.d.ts +6 -2
  110. package/dist/http/health-self-report.js +3 -2
  111. package/dist/http/memory-compliance-failure-reply.d.ts +1 -1
  112. package/dist/http/memory-compliance-failure-reply.js +2 -15
  113. package/dist/http/memory-control-plane-corrupt-reply.d.ts +25 -0
  114. package/dist/http/memory-control-plane-corrupt-reply.js +19 -0
  115. package/dist/http/principal-gate.d.ts +35 -12
  116. package/dist/http/principal-gate.js +16 -12
  117. package/dist/http/request-guards.d.ts +1 -1
  118. package/dist/http/request-guards.js +5 -5
  119. package/dist/http/resume-legs.d.ts +22 -0
  120. package/dist/http/resume-legs.js +26 -17
  121. package/dist/http/route-ctx.d.ts +11 -10
  122. package/dist/http/route-table.js +2 -0
  123. package/dist/http/routes/adoption.d.ts +11 -0
  124. package/dist/http/routes/adoption.js +80 -6
  125. package/dist/http/routes/agents-roster.js +1 -0
  126. package/dist/http/routes/approvals-assistant.js +2 -1
  127. package/dist/http/routes/background.js +1 -0
  128. package/dist/http/routes/capabilities.js +4 -1
  129. package/dist/http/routes/diagnostics.d.ts +9 -14
  130. package/dist/http/routes/diagnostics.js +10 -20
  131. package/dist/http/routes/engine.d.ts +31 -0
  132. package/dist/http/routes/engine.js +81 -0
  133. package/dist/http/routes/memory-bundle.js +3 -0
  134. package/dist/http/routes/memory-consolidation.js +3 -5
  135. package/dist/http/routes/memory-origin.d.ts +1 -1
  136. package/dist/http/routes/memory-origin.js +2 -4
  137. package/dist/http/routes/memory-policy.js +5 -1
  138. package/dist/http/routes/observability.js +3 -6
  139. package/dist/http/routes/runs.js +7 -3
  140. package/dist/http/routes/session-sync.js +12 -25
  141. package/dist/http/routes/sessions-list.d.ts +1 -1
  142. package/dist/http/routes/sessions.js +4 -0
  143. package/dist/http/routes/tasks.js +23 -5
  144. package/dist/http/routes/trace-usage.js +1 -1
  145. package/dist/http/run-concurrency-cap.d.ts +86 -0
  146. package/dist/http/run-concurrency-cap.js +54 -0
  147. package/dist/http/server.d.ts +15 -12
  148. package/dist/http/server.js +18 -3
  149. package/dist/http/stored-body-replay.d.ts +9 -6
  150. package/dist/http/stored-body-replay.js +19 -5
  151. package/dist/http/wire-types.d.ts +8 -3
  152. package/dist/json-body-limit.d.ts +8 -0
  153. package/dist/json-body-limit.js +2 -0
  154. package/dist/leader/diffout.d.ts +1 -1
  155. package/dist/local-data-root.d.ts +2 -2
  156. package/dist/memory-operator-faces.d.ts +9 -4
  157. package/dist/memory-scope-stores.d.ts +9 -7
  158. package/dist/memory-scope-stores.js +3 -14
  159. package/dist/memory-scope.d.ts +36 -0
  160. package/dist/memory-scope.js +32 -1
  161. package/dist/net-address.d.ts +53 -0
  162. package/dist/net-address.js +111 -0
  163. package/dist/observability/fail-open.d.ts +14 -10
  164. package/dist/observability/fail-open.js +14 -10
  165. package/dist/orchestration/workflow-notify-journal.js +2 -3
  166. package/dist/org-delivery-gate.js +1 -1
  167. package/dist/peer-directory.d.ts +6 -12
  168. package/dist/peer-directory.js +5 -1
  169. package/dist/plugins/caching-session-store.d.ts +3 -1
  170. package/dist/plugins/caching-session-store.js +3 -0
  171. package/dist/plugins/checkpoint-store-face.d.ts +426 -0
  172. package/dist/plugins/checkpoint-store-face.js +152 -0
  173. package/dist/plugins/file-run-store.d.ts +0 -6
  174. package/dist/plugins/file-run-store.js +1 -12
  175. package/dist/plugins/fork-routing-session-store.d.ts +6 -2
  176. package/dist/plugins/fork-routing-session-store.js +2 -2
  177. package/dist/plugins/imported-layer-root-retirement.d.ts +10 -8
  178. package/dist/plugins/local-checkpoint-store.d.ts +2 -2
  179. package/dist/plugins/local-checkpoint-store.js +2 -1
  180. package/dist/plugins/local-session-store.d.ts +28 -5
  181. package/dist/plugins/local-session-store.js +32 -8
  182. package/dist/plugins/memory-engine-pg.d.ts +29 -6
  183. package/dist/plugins/memory-engine-pg.js +96 -214
  184. package/dist/plugins/memory-engine-sql-apply.d.ts +121 -0
  185. package/dist/plugins/memory-engine-sql-apply.js +358 -0
  186. package/dist/plugins/memory-engine-tidb.d.ts +35 -9
  187. package/dist/plugins/memory-engine-tidb.js +97 -227
  188. package/dist/plugins/memory-key-guards.d.ts +1 -1
  189. package/dist/plugins/memory-origin-law.d.ts +3 -3
  190. package/dist/plugins/one-time-migrations.d.ts +32 -56
  191. package/dist/plugins/one-time-migrations.js +25 -117
  192. package/dist/plugins/permission-rule-store-file.d.ts +17 -3
  193. package/dist/plugins/permission-rule-store-file.js +8 -1
  194. package/dist/plugins/pg-pool.js +1 -1
  195. package/dist/plugins/pg-session-storage.d.ts +17 -4
  196. package/dist/plugins/pg-session-storage.js +8 -4
  197. package/dist/plugins/run-store-sql.js +2 -2
  198. package/dist/plugins/schema-ensure-legs.js +2 -2
  199. package/dist/plugins/session-fork.d.ts +31 -9
  200. package/dist/plugins/session-fork.js +3 -2
  201. package/dist/plugins/session-placement.d.ts +4 -2
  202. package/dist/plugins/sql-json-column.d.ts +5 -1
  203. package/dist/plugins/store-backend.d.ts +11 -8
  204. package/dist/plugins/store-backend.js +8 -7
  205. package/dist/plugins/store-contracts.d.ts +1 -11
  206. package/dist/plugins/store-contracts.js +0 -9
  207. package/dist/plugins/store-sweep.d.ts +63 -0
  208. package/dist/plugins/store-sweep.js +48 -0
  209. package/dist/plugins/tidb-pool.js +1 -1
  210. package/dist/plugins/tidb-session-store.d.ts +16 -3
  211. package/dist/plugins/tidb-session-store.js +8 -4
  212. package/dist/prompt-screen.d.ts +6 -9
  213. package/dist/prompt-screen.js +2 -5
  214. package/dist/rules-consent.d.ts +20 -27
  215. package/dist/rules-consent.js +82 -6
  216. package/dist/run-cancel-context.d.ts +4 -1
  217. package/dist/run-cancel-context.js +2 -1
  218. package/dist/runs.js +1 -1
  219. package/dist/sandbox-egress-policy.js +6 -11
  220. package/dist/sandbox-rbac-rules.d.ts +88 -0
  221. package/dist/sandbox-rbac-rules.js +80 -0
  222. package/dist/sealed-key-layout.d.ts +17 -0
  223. package/dist/sealed-key-layout.js +4 -0
  224. package/dist/sealed-key.js +5 -5
  225. package/dist/security.d.ts +38 -6
  226. package/dist/security.js +9 -2
  227. package/dist/session-notify-door.d.ts +5 -3
  228. package/dist/session-resident-background.d.ts +57 -0
  229. package/dist/session-resident-background.js +20 -0
  230. package/dist/session-sync-kernel.d.ts +53 -14
  231. package/dist/session-sync-kernel.js +70 -1
  232. package/dist/session-sync.d.ts +5 -3
  233. package/dist/session-workspace.d.ts +1 -0
  234. package/dist/session-workspace.js +1 -0
  235. package/dist/sighup-idle.d.ts +9 -7
  236. package/dist/sighup-idle.js +4 -5
  237. package/dist/spec-fields.d.ts +16 -0
  238. package/dist/spec-fields.js +7 -0
  239. package/dist/stored-request-env-credentials-m38.d.ts +3 -0
  240. package/dist/stored-request-env-credentials-m38.js +8 -0
  241. package/dist/stored-request-prompt-profile-m30.d.ts +1 -1
  242. package/dist/{plugins → stores-sql}/checkpoint-store-sql.d.ts +13 -427
  243. package/dist/{plugins → stores-sql}/checkpoint-store-sql.js +33 -194
  244. package/dist/{plugins → stores-sql}/mailbox-store-sql.d.ts +2 -2
  245. package/dist/{plugins → stores-sql}/mailbox-store-sql.js +4 -4
  246. package/dist/{plugins → stores-sql}/roster-store-sql.d.ts +2 -2
  247. package/dist/{plugins → stores-sql}/roster-store-sql.js +1 -1
  248. package/dist/{plugins → stores-sql}/tool-result-store-sql.d.ts +2 -2
  249. package/dist/{plugins → stores-sql}/tool-result-store-sql.js +6 -6
  250. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.d.ts +7 -12
  251. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.js +3 -8
  252. package/dist/task-settings.d.ts +59 -4
  253. package/dist/task-settings.js +50 -4
  254. package/dist/tool-approval.d.ts +2 -2
  255. package/dist/trace/core-keyset-guard.d.ts +8 -7
  256. package/dist/trace/engine-notice-wire.d.ts +1 -1
  257. package/dist/trace/engine-notice-wire.js +2 -0
  258. package/dist/trace/exit-seat.d.ts +6 -0
  259. package/dist/trace/exit-seat.js +1 -0
  260. package/dist/trace/project.js +9 -0
  261. package/dist/trace/redact.d.ts +13 -2
  262. package/dist/trace/redact.js +305 -24
  263. package/dist/trace/self-minted-wire.d.ts +326 -8
  264. package/dist/trace/self-minted-wire.js +125 -7
  265. package/dist/trace/wire-projection-faces.d.ts +1 -1
  266. package/dist/trace/wire-projection-faces.js +1 -1
  267. package/dist/usage-analytics.d.ts +4 -0
  268. package/package.json +12 -4
  269. package/scripts/drain-check-local.mjs +8 -29
  270. package/scripts/drain-check.mysql.sql +3 -24
  271. package/scripts/drain-check.pg.sql +3 -24
  272. package/skills/update-config.md +1 -1
  273. package/wire-changes/server@7.146.0.json +3221 -0
  274. package/dist/approval-batch-census.d.ts +0 -27
  275. package/dist/approval-batch-census.js +0 -27
@@ -43,5 +43,6 @@ export declare function openStores(ctx: OpenStoresCtx): Promise<{
43
43
  taskListLane: import("./task-list-lane.js").TaskListLane;
44
44
  sqlEngine: import("../plugins/sql-driver.js").SqlEngineReading | undefined;
45
45
  sessionCaptureRecords: import("../plugins/store-backend.js").SessionCaptureRecordSource | undefined;
46
+ storeSweep: import("../plugins/store-sweep.js").StoreSweep;
46
47
  }>;
47
48
  //# sourceMappingURL=stores.d.ts.map
@@ -2,6 +2,7 @@ import { join } from "node:path";
2
2
  import { FileBackgroundAgentStore, FileMailboxStore, FileRosterStore, InMemoryUsageWindowStore, mailboxCrossProcessMountVerdict } from "@sema-agent/core";
3
3
  import { createCorruptReadFailOpenSeat } from "../observability/corrupt-read-seat.js";
4
4
  import { startMemorySyncRunner } from "../memory-sync-client.js";
5
+ import { errorCodeOf, errorKindOf } from "../observability/err-text.js";
5
6
  import { memoryEmbedderFor } from "../plugins/memory-embedder.js";
6
7
  import { ensurePgMemoryEmbedderMetaSchema, reconcileEmbedderFingerprint } from "../plugins/memory-embedder-fingerprint.js";
7
8
  import { PgMemoryEngineBackend, ensurePgMemoryEngineSchema } from "../plugins/memory-engine-pg.js";
@@ -11,31 +12,30 @@ import { TiDBMemoryHistoryStore, TiDBMemorySyncStore, ensureTiDBMemoryHistorySch
11
12
  import { MinioBlobBackend } from "../plugins/blob-backend.js";
12
13
  import { ensureSnapshotBuckets } from "../plugins/snapshot-bucket-presence.js";
13
14
  import { PgBackgroundAgentStore, TiDBBackgroundAgentStore, ensurePgBackgroundAgentSchema, ensureTiDBBackgroundAgentSchema } from "../stores-sql/background-agent-store-sql.js";
14
- import { PgMailboxStore, TiDBMailboxStore, ensurePgMailboxSchema, ensureTiDBMailboxSchema } from "../plugins/mailbox-store-sql.js";
15
+ import { PgMailboxStore, TiDBMailboxStore, ensurePgMailboxSchema, ensureTiDBMailboxSchema } from "../stores-sql/mailbox-store-sql.js";
15
16
  import { recipientLifecycleOf } from "../plugins/mailbox-recipient-lifecycle.js";
16
17
  import { PgUsageWindowStore, TiDBUsageWindowStore, ensurePgUsageWindowSchema, ensureTiDBUsageWindowSchema } from "../stores-sql/usage-window-store-sql.js";
17
- import { PgRosterStore, TiDBRosterStore, ensurePgRosterSchema, ensureTiDBRosterSchema } from "../plugins/roster-store-sql.js";
18
+ import { PgRosterStore, TiDBRosterStore, ensurePgRosterSchema, ensureTiDBRosterSchema } from "../stores-sql/roster-store-sql.js";
18
19
  import { LocalTaskAttachmentStore } from "../plugins/local-task-attachment-store.js";
19
20
  import { PgTaskAttachmentStore, TiDBTaskAttachmentStore, ensurePgTaskAttachmentSchema, ensureTiDBTaskAttachmentSchema } from "../plugins/task-attachment-store.js";
20
21
  import { createSessionStore } from "../plugins/session-store.js";
21
22
  import { buildSqlPoolMissingRefusal, missingSqlCoordinateKeys } from "../sql-engine-coordinates.js";
22
- import { runApprovalBatchKindlessCensus } from "../approval-batch-census.js";
23
23
  import { runAndLogOneTimeMigrations } from "../plugins/one-time-migrations.js";
24
24
  import { createTaskListLane } from "./task-list-lane.js";
25
25
  import { ensurePgTaskListSchema, ensureTiDBTaskListSchema } from "../plugins/task-list-store-sql.js";
26
26
  import { assertDeviceAuditRebindEventSchema, ensurePgDeviceSchema, ensureTiDBDeviceSchema } from "../plugins/device-store-sql.js";
27
27
  import { mysqlDriver, pgDriver } from "../plugins/sql-driver.js";
28
- import { assertCloudSnapshotBlobPosture, openStoreBackendWithFallback } from "../plugins/store-backend.js";
28
+ import { assertCloudSnapshotBlobPosture, openStoreBackendWithFallback, workflowJournalOf } from "../plugins/store-backend.js";
29
29
  import { createMemoryEngineIncidentSink } from "../memory-incident-sink.js";
30
30
  import { announceLockedLegacyMemoryLayers } from "../memory-layer-legacy-lock.js";
31
31
  import { createEngineNoticeForwarder } from "./runner-deps.js";
32
- import { buildMemoryRemoteLaneWarn, memoryEngineBackendFor, memoryEngineRemoteLanePosture, memoryEngineRootFor, memoryMountRootOf } from "../memory-scope.js";
32
+ import { buildMemoryRemoteLaneWarn, canonicalPathOf, judgeMemoryRootOutsideDataRoot, memoryEngineBackendFor, memoryEngineRemoteLanePosture, memoryEngineRootFor, memoryMountRootOf } from "../memory-scope.js";
33
33
  import { createMemoryScopeStores } from "../memory-scope-stores.js";
34
- import { assertToolResultProvenanceSchema } from "../plugins/tool-result-store-sql.js";
34
+ import { assertToolResultProvenanceSchema } from "../stores-sql/tool-result-store-sql.js";
35
35
  import { assertPermissionRuleApprovalSchema, assertPermissionRuleTicketSchema } from "../plugins/permission-rule-store-sql.js";
36
36
  import { assertApprovalAskRuleMaterialSchema } from "../plugins/approval-ask-store-sql.js";
37
37
  import { assertSchemaMatchesCode } from "../plugins/schema-consistency.js";
38
- import { SqlCheckpointStore, assertCheckpointColumnSchema } from "../plugins/checkpoint-store-sql.js";
38
+ import { SqlCheckpointStore, assertCheckpointColumnSchema } from "../stores-sql/checkpoint-store-sql.js";
39
39
  import { assertFileHistorySchema } from "../plugins/file-history-store-sql.js";
40
40
  import { buildMemoryBoundaryLaneFacts, buildMemoryWriteBoundaryAudit } from "./memory-boundary.js";
41
41
  import { buildMemoryPosture } from "../memory-posture.js";
@@ -43,6 +43,7 @@ import { headReadOf } from "../session-incarnation.js";
43
43
  import { establishSqlEnginePosture, sqlPoolsOf } from "../sql-engine-posture.js";
44
44
  import { buildStorePosture } from "../store-posture.js";
45
45
  import { seatText } from "../trace/exit-seat.js";
46
+ import { buildStoreSweepBounds, createJournalSweepLeg, createStoreSweep } from "../plugins/store-sweep.js";
46
47
  const DARK_REASON_PROSE = {
47
48
  engine_off: () => "MEMORY_ENGINE=off",
48
49
  multi_tenant_file_backend: () => "multi-tenant on the FILE backend (no tenant isolation; set MEMORY_ENGINE_BACKEND=pg|mysql to light up)",
@@ -100,10 +101,6 @@ export async function openStores(ctx) {
100
101
  }
101
102
  if (backend)
102
103
  await runAndLogOneTimeMigrations(logger, backend);
103
- {
104
- const censusStore = backend !== undefined && backend.kind !== "local" ? backend.checkpoint?.() : undefined;
105
- void runApprovalBatchKindlessCensus(censusStore instanceof SqlCheckpointStore ? censusStore : undefined, logger);
106
- }
107
104
  if ((process.env.REWIND_SNAPSHOT_MAX_MB ?? "") !== "") {
108
105
  logger.warn("rewind_snapshot_max_mb_retired", {
109
106
  note: "REWIND_SNAPSHOT_MAX_MB no longer has an effect: the whole-tree snapshot epoch is retired (S-15); per-edited-file history captures only files the agent touches, with no tree walk and no size gate. Remove the env var. Per-blob SQL sizing is governed by SNAPSHOT_BLOB_SQL_MAX_BYTES / object storage as before.",
@@ -204,11 +201,15 @@ export async function openStores(ctx) {
204
201
  memoryEngine = fileEngine !== undefined ? scopeStoresOver(fileEngine.backend) : undefined;
205
202
  if (memoryEngine)
206
203
  announceLockedLegacyMemoryLayers(memoryMountRootOf(memoryEngine.backend, memoryEngine.root), createEngineNoticeForwarder(logger));
207
- if (memoryEngine && process.env.LOCAL_DATA_ROOT && !config.memoryEngineDir) {
208
- logger.warn("memory_engine_dir_defaulted", {
209
- root: memoryEngine.root,
210
- hint: "LOCAL_DATA_ROOT is set but MEMORY_ENGINE_DIR is not — the memory engine is sharing the machine-wide default; set MEMORY_ENGINE_DIR to isolate it under your data root",
211
- });
204
+ if (memoryEngine) {
205
+ try {
206
+ const outside = judgeMemoryRootOutsideDataRoot({ memoryRoot: memoryEngine.root, dataRoot: config.localDataRoot, canonical: canonicalPathOf });
207
+ if (outside)
208
+ logger.warn("memory_engine_dir_outside_data_root", outside);
209
+ }
210
+ catch (err) {
211
+ logger.warn("memory_engine_dir_check_unavailable", { root: memoryEngine.root, dataRoot: config.localDataRoot, errorKind: errorKindOf(err), errorCode: errorCodeOf(err) });
212
+ }
212
213
  }
213
214
  }
214
215
  {
@@ -224,17 +225,22 @@ export async function openStores(ctx) {
224
225
  logger.warn(w.tag, { detail: w.detail, lane: laneFacts.lane, root: memoryMountRoot ?? null });
225
226
  }
226
227
  let rosterStore;
228
+ let rosterAged;
227
229
  {
228
230
  const mysqlPool = backend?.mysqlPool?.();
229
231
  const pgPool = backend?.pgPool?.();
230
232
  if (pgPool) {
231
233
  const q = async (text, params) => { const r = await pgPool.query(text, params); return { rows: r.rows }; };
232
234
  await ensurePgRosterSchema(q);
233
- rosterStore = new PgRosterStore(q);
235
+ const store = new PgRosterStore(q);
236
+ rosterStore = store;
237
+ rosterAged = (nowMs, { maxAgeMs }) => store.reapOlderThan(nowMs - maxAgeMs);
234
238
  }
235
239
  else if (mysqlPool) {
236
240
  await ensureTiDBRosterSchema(mysqlPool);
237
- rosterStore = new TiDBRosterStore(mysqlPool);
241
+ const store = new TiDBRosterStore(mysqlPool);
242
+ rosterStore = store;
243
+ rosterAged = (nowMs, { maxAgeMs }) => store.reapOlderThan(nowMs - maxAgeMs);
238
244
  }
239
245
  else if (backend?.kind === "local") {
240
246
  rosterStore = new FileRosterStore(join(config.localDataRoot ?? localRoot, "roster.json"), {
@@ -436,10 +442,20 @@ export async function openStores(ctx) {
436
442
  })
437
443
  .startRefresh()
438
444
  : undefined;
445
+ const toolResultsForSweep = backend?.toolResult?.();
446
+ const journalForSweep = workflowJournalOf(config, backend);
447
+ const storeSweep = createStoreSweep({
448
+ legs: {
449
+ "roster-aged": rosterAged,
450
+ "tool-results-aged": toolResultsForSweep?.reap?.bind(toolResultsForSweep),
451
+ "workflow-journal-expired": createJournalSweepLeg(journalForSweep),
452
+ },
453
+ bounds: () => buildStoreSweepBounds(config),
454
+ });
439
455
  return {
440
456
  backend, storePosture, memoryEngine, engineDataRoot, memorySyncCursors, rosterStore, backgroundAgentStore, mailboxRecipientLifecycle,
441
457
  taskAttachmentStore, mailboxStore, memoryExportStores, memorySyncRunner, sessionStore, breakerState,
442
- usageWindowStore, memoryPosture, taskListLane, sqlEngine, sessionCaptureRecords,
458
+ usageWindowStore, memoryPosture, taskListLane, sqlEngine, sessionCaptureRecords, storeSweep,
443
459
  };
444
460
  }
445
461
  //# sourceMappingURL=stores.js.map
@@ -22,7 +22,7 @@ import { type WorkflowCompletionInbox } from "../orchestration/workflow-completi
22
22
  import { JournalingWorkflowRunStore, WorkflowNotifyGate, type WorkflowCompletionPayload } from "../orchestration/workflow-notify-journal.js";
23
23
  import { SubagentSteerRegistry } from "../orchestration/subagent-steer.js";
24
24
  import { WorkflowAgentRegistry } from "../orchestration/workflow-agent-steer.js";
25
- import type { StoreBackend } from "../plugins/store-backend.js";
25
+ import { type StoreBackend } from "../plugins/store-backend.js";
26
26
  export interface WorkflowOrchestrationCtx {
27
27
  config: ServiceConfig;
28
28
  logger: Logger;
@@ -7,6 +7,7 @@ import { FileWorkflowCompletionInbox, InMemoryWorkflowCompletionInbox, buildWork
7
7
  import { FileWorkflowNotifyJournalStore, JournalingWorkflowRunStore, WorkflowNotifyGate } from "../orchestration/workflow-notify-journal.js";
8
8
  import { SubagentSteerRegistry } from "../orchestration/subagent-steer.js";
9
9
  import { WorkflowAgentRegistry } from "../orchestration/workflow-agent-steer.js";
10
+ import { workflowJournalOf } from "../plugins/store-backend.js";
10
11
  import { seatText } from "../trace/exit-seat.js";
11
12
  export function createWorkflowOrchestration(ctx) {
12
13
  const { config, logger, metrics, localRoot, backend, getRunStore } = ctx;
@@ -70,7 +71,7 @@ export function createWorkflowOrchestration(ctx) {
70
71
  ...(replicaLocalNotifyJournal ? { finalizeStartedBeforeMs: workflowBootAtMs } : {}),
71
72
  ...(workflowRunStore ? { publishTerminalFleetRow: (id, run) => workflowRunStore.republishFleet(id, run) } : {}),
72
73
  };
73
- const workflowJournalStore = config.selfOrchestrationEnabled && backend ? backend.workflowJournal() : undefined;
74
+ const workflowJournalStore = workflowJournalOf(config, backend);
74
75
  const outcomeSink = backend?.outcomeSink();
75
76
  const workflowAgentRegistry = config.selfOrchestrationEnabled ? new WorkflowAgentRegistry() : undefined;
76
77
  const subagentSteerRegistry = new SubagentSteerRegistry();
@@ -45,7 +45,7 @@ export declare const COMPOSITE_CAPABILITY_MEMBERS: {
45
45
  readonly centerWiring: readonly ["effectivePull", "effectiveRevision", "lease", "leaseHealth", "failMode", "usageReport", "issuer", "worker", "caller"];
46
46
  readonly webSearch: readonly ["backend"];
47
47
  readonly background: readonly ["listFace", "exitFaces"];
48
- readonly taskSettings: readonly ["permissions", "permissionMode", "model", "outputStyle", "env", "hooks", "pluginHooks", "managedHookGroups", "httpHookAllowlists", "tightenOnlySeats", "approvalFrameFamilies"];
48
+ readonly taskSettings: readonly ["permissions", "permissionMode", "model", "outputStyle", "env", "hooks", "pluginHooks", "managedHookGroups", "httpHookAllowlists", "tightenOnlySeats", "approvalFrameFamilies", "autoCompactEnabled"];
49
49
  readonly settings: readonly ["permissions"];
50
50
  readonly permissionModeAuto: readonly ["accepted", "classifierSeat", "entitlementSource", "armed", "reason", "model"];
51
51
  readonly writeProtection: readonly ["armed", "rows", "replaced"];
@@ -57,6 +57,8 @@ export declare const COMPOSITE_CAPABILITY_MEMBERS: {
57
57
  readonly userAttachments: readonly ["entries", "kinds", "supplies", "limits"];
58
58
  readonly credentialPlane: readonly ["sandboxGit"];
59
59
  readonly memorySyncServe: readonly ["identity"];
60
+ readonly adoptionImport: readonly ["adoptionId", "maxSessions", "maxSessionBytes"];
61
+ readonly engine: readonly ["handover"];
60
62
  };
61
63
  type CompositeTable = typeof COMPOSITE_CAPABILITY_MEMBERS;
62
64
  /** 值的**具名成员对象臂**(标量 / 字面词 / `false` / `null` / `undefined` / 数组 / 函数臂剥掉)。 */
@@ -6,7 +6,7 @@ export const COMPOSITE_CAPABILITY_MEMBERS = {
6
6
  centerWiring: ["effectivePull", "effectiveRevision", "lease", "leaseHealth", "failMode", "usageReport", "issuer", "worker", "caller"],
7
7
  webSearch: ["backend"],
8
8
  background: ["listFace", "exitFaces"],
9
- taskSettings: ["permissions", "permissionMode", "model", "outputStyle", "env", "hooks", "pluginHooks", "managedHookGroups", "httpHookAllowlists", "tightenOnlySeats", "approvalFrameFamilies"],
9
+ taskSettings: ["permissions", "permissionMode", "model", "outputStyle", "env", "hooks", "pluginHooks", "managedHookGroups", "httpHookAllowlists", "tightenOnlySeats", "approvalFrameFamilies", "autoCompactEnabled"],
10
10
  settings: ["permissions"],
11
11
  permissionModeAuto: ["accepted", "classifierSeat", "entitlementSource", "armed", "reason", "model"],
12
12
  writeProtection: ["armed", "rows", "replaced"],
@@ -18,6 +18,8 @@ export const COMPOSITE_CAPABILITY_MEMBERS = {
18
18
  userAttachments: ["entries", "kinds", "supplies", "limits"],
19
19
  credentialPlane: ["sandboxGit"],
20
20
  memorySyncServe: ["identity"],
21
+ adoptionImport: ["adoptionId", "maxSessions", "maxSessionBytes"],
22
+ engine: ["handover"],
21
23
  };
22
24
  export function gateCompositeMembers(body) {
23
25
  return body;
@@ -157,8 +157,8 @@ export interface ScenarioDeps {
157
157
  }) => Promise<void>;
158
158
  /**
159
159
  * **Runner 之外的后台子代完成**交给哪里 —— 按委派树根见证({@link ScenarioContext.delegationRoot})造委派工具挂载期的 `background.notify`。
160
- * 停驻赎回腿的复活、操作员 `handle.resume` 都不是哪一次 run 内的调用,没有调用车道;引擎只在能解出一只完成 sink(调用 ?? 挂载)时才起后台续跑,
161
- * 解不出 ⇒ 拒(`revive.no_background`)。sink = 委派树根会话的会话通知门(`session-notify-door.ts` 的 `createBackgroundCompletionRelay`;律与地址、
160
+ * 操作员 `handle.resume` 与停驻落在别的进程的停驻赎回腿复活都不是哪一次 run 内的调用,本进程也没有它们欠账的车道;引擎只在能解出一只完成 sink
161
+ * (调用 ?? 停驻车道 ?? 挂载)时才起后台续跑,解不出 ⇒ 拒(`revive.no_background`)。本进程持有停驻的赎回(core 7.63.0)完成回停驻车道,不调这只 sink。sink = 委派树根会话的会话通知门(`session-notify-door.ts` 的 `createBackgroundCompletionRelay`;律与地址、
162
162
  * 竞态、条目形都写在那里)。Runner 之内的调用照旧走调用车道,这只 sink 不被调。缺席(没有门的装配:run-local)⇒ 不接 ——
163
163
  * 不接一只空 sink(接了 = 引擎起续跑、完成没人收)。
164
164
  */
@@ -25,6 +25,7 @@ import type { ServiceBlobExchange, ServiceFileHistoryStore } from "./plugins/sto
25
25
  import { resolveStreamApprovalGate, type ApprovalFrameFamily } from "./tool-approval.js";
26
26
  import { type WorkspaceSyncCapability } from "./workspace-space.js";
27
27
  import type { WorkspaceCacheCapability } from "./workspace-cache.js";
28
+ import type { EngineHandoverDoor } from "./boot/engine-lease.js";
28
29
  /** why 闭集:词 → 给运维看的一句义(诊断 / 测试读它;wire 上的拒句由各门自写)。 */
29
30
  export declare const CAPABILITY_FACT_WHY: {
30
31
  readonly run_store_absent: "no durable run store is wired (DB_BACKEND=mysql|pg|local)";
@@ -91,6 +92,8 @@ export declare const CAPABILITY_FACT_WHY: {
91
92
  readonly workspace_snapshot_store_absent: "no workspace snapshot store is configured (MINIO_ENDPOINT / MINIO_ACCESS_KEY / MINIO_SECRET_KEY)";
92
93
  readonly workspace_cache_off: "the build-cache volume per workspace space is off (WORKSPACE_CACHE=off, the default)";
93
94
  readonly deployment_mod_packages_absent: "no operator-declared mod package was loaded at boot (MODS_ROOT / MODS_PACKAGES)";
95
+ readonly engine_handover_lane_absent: "the attachment lease has no handover lane here: the lease is not armed (neither ENGINE_AUTO_EXIT nor SEMA_PARENT_PID), or the deployment is multi-tenant (REQUIRE_PRINCIPAL=true)";
96
+ readonly engine_lease_stopped: "the attachment lease has stopped observing (this engine is shutting down)";
94
97
  };
95
98
  export type CapabilityFactWhy = keyof typeof CAPABILITY_FACT_WHY;
96
99
  /** 不可用臂。 */
@@ -302,6 +305,11 @@ export declare function sessionMemorySync(d: Pick<Deps, "memorySyncLeg" | "runSt
302
305
  export declare function principalInboxDelivery(d: Pick<Deps, "orgDeliveryGate">): Fact<"org_delivery_gate_absent", {
303
306
  gate: Store<"orgDeliveryGate">;
304
307
  }>;
308
+ /** [ref]([ref] v3):附着租约的交接车道在场且腿还在观察 —— `POST /v1/engine/handover` · `POST /v1/engine/attach` 的 501 与能力位 `engine.handover`
309
+ * 同读这一只。交接门只在「租约腿已装配 ∧ 非多租户」时进盒子(`boot/shutdown.ts`);腿停了(停机中)⇒ 门还在但不再观察。 */
310
+ export declare function engineHandover(d: Pick<Deps, "drainState">): Fact<"engine_handover_lane_absent" | "engine_lease_stopped", {
311
+ door: EngineHandoverDoor;
312
+ }>;
305
313
  /** 这台部署有运维名册(名单非空 ∨ 单用户声明 `OPERATOR_SINGLE_USER`;唯一读法 `operatorRosterPresent`)。没有时 `explicitOperatorOk` 对任何身份恒假
306
314
  * ⇒ 这一族的口对谁都打不通 = 部署不可用(不是鉴权拒)。
307
315
  *
@@ -316,6 +324,15 @@ type AdoptionCapableBackend = Store<"backend"> & {
316
324
  export declare function adoption(d: Pick<Deps, "config" | "backend">): Fact<"operator_principals_empty" | "adoption_store_absent", {
317
325
  backend: AdoptionCapableBackend;
318
326
  }>;
327
+ type AdoptionImportSessionStore = WithMethods<OwnerAwareSessionStore, "beginImportStaging">;
328
+ /**
329
+ * 收编批量导入(`POST /v1/adoption/:id/sessions`)与能力位 `adoptionImport` 的部署半:收编日志 ∧ 会话店的暂存导入面(派生 id 那一格占没占由提交的属主判答,不另要头读面)。
330
+ * **不判运维名册**:这扇门不是 operator 面 —— 调用者是那条收编行的源主体本人(名单空了,已收编的行照样在)。
331
+ */
332
+ export declare function adoptionSessionImport(d: Pick<Deps, "backend" | "sessionStorage">): Fact<"adoption_store_absent" | "session_import_staging_absent", {
333
+ backend: AdoptionCapableBackend;
334
+ sessionStorage: AdoptionImportSessionStore;
335
+ }>;
319
336
  export declare function memoryBundle(d: Pick<Deps, "config" | "memoryBundleExport" | "memoryBundleImport">): Fact<"operator_principals_empty" | "memory_bundle_faces_absent", {
320
337
  exportScopes: Store<"memoryBundleExport">;
321
338
  importBundle: Store<"memoryBundleImport">;
@@ -334,7 +351,7 @@ export declare function memoryOptOutGrant(d: Pick<Deps, "config" | "memoryOptOut
334
351
  store: Store<"memoryOptOutGrant">;
335
352
  }>;
336
353
  type QueryableOutcomeSink = WithMethods<Store<"outcomeSink">, "summary">;
337
- /** 可查询的 outcome 账面 ∧(单用户 ∨ operator 名单非空)—— 单用户形唯一的用户就是 operator,这一口不判名单。 */
354
+ /** 有运维名册(`operatorLane`)∧ 可查询的 outcome 账面。operator 族同序:先判名册、再判设施;部署形不进判据(单用户形要当运维显式声明)。 */
338
355
  export declare function outcomeLedger(d: Pick<Deps, "config" | "outcomeSink">): Fact<"operator_principals_empty" | "outcome_ledger_unqueryable", {
339
356
  sink: QueryableOutcomeSink;
340
357
  }>;
@@ -72,6 +72,8 @@ export const CAPABILITY_FACT_WHY = {
72
72
  workspace_snapshot_store_absent: "no workspace snapshot store is configured (MINIO_ENDPOINT / MINIO_ACCESS_KEY / MINIO_SECRET_KEY)",
73
73
  workspace_cache_off: "the build-cache volume per workspace space is off (WORKSPACE_CACHE=off, the default)",
74
74
  deployment_mod_packages_absent: "no operator-declared mod package was loaded at boot (MODS_ROOT / MODS_PACKAGES)",
75
+ engine_handover_lane_absent: "the attachment lease has no handover lane here: the lease is not armed (neither ENGINE_AUTO_EXIT nor SEMA_PARENT_PID), or the deployment is multi-tenant (REQUIRE_PRINCIPAL=true)",
76
+ engine_lease_stopped: "the attachment lease has stopped observing (this engine is shutting down)",
75
77
  };
76
78
  const no = (why) => ({ available: false, why });
77
79
  const yes = (w) => ({ available: true, ...w });
@@ -312,15 +314,33 @@ export function sessionMemorySync(d) {
312
314
  export function principalInboxDelivery(d) {
313
315
  return d.orgDeliveryGate !== undefined ? yes({ gate: d.orgDeliveryGate }) : no("org_delivery_gate_absent");
314
316
  }
317
+ export function engineHandover(d) {
318
+ const door = d.drainState?.engineHandover;
319
+ if (door === undefined)
320
+ return no("engine_handover_lane_absent");
321
+ return door.observing ? yes({ door }) : no("engine_lease_stopped");
322
+ }
315
323
  export function operatorLane(d) {
316
324
  return operatorRosterPresent(d.config) ? YES : no("operator_principals_empty");
317
325
  }
326
+ function adoptionLogStore(d) {
327
+ const b = d.backend;
328
+ return b !== undefined && typeof b.adoptionLog === "function" ? yes({ backend: b }) : no("adoption_store_absent");
329
+ }
318
330
  export function adoption(d) {
319
331
  const lane = operatorLane(d);
320
332
  if (!lane.available)
321
333
  return lane;
322
- const b = d.backend;
323
- return b !== undefined && typeof b.adoptionLog === "function" ? yes({ backend: b }) : no("adoption_store_absent");
334
+ return adoptionLogStore(d);
335
+ }
336
+ export function adoptionSessionImport(d) {
337
+ const log = adoptionLogStore(d);
338
+ if (!log.available)
339
+ return log;
340
+ const s = d.sessionStorage;
341
+ if (s?.beginImportStaging === undefined)
342
+ return no("session_import_staging_absent");
343
+ return yes({ backend: log.backend, sessionStorage: s });
324
344
  }
325
345
  export function memoryBundle(d) {
326
346
  const lane = operatorLane(d);
@@ -355,11 +375,9 @@ export function memoryOptOutGrant(d) {
355
375
  return d.memoryOptOutGrant !== undefined ? yes({ store: d.memoryOptOutGrant }) : no("memory_optout_grant_absent");
356
376
  }
357
377
  export function outcomeLedger(d) {
358
- if (d.config.requirePrincipal === true) {
359
- const lane = operatorLane(d);
360
- if (!lane.available)
361
- return lane;
362
- }
378
+ const lane = operatorLane(d);
379
+ if (!lane.available)
380
+ return lane;
363
381
  const sink = d.outcomeSink;
364
382
  return sink?.summary !== undefined ? yes({ sink: sink }) : no("outcome_ledger_unqueryable");
365
383
  }
@@ -14,7 +14,7 @@
14
14
  */
15
15
  import { type CheckpointCtxSealer } from "./http/checkpoint-ctx.js";
16
16
  import { type OneTimeMigrationWindow } from "./plugins/one-time-migrations.js";
17
- import type { CheckpointCtxRowsRewriter } from "./plugins/checkpoint-store-sql.js";
17
+ import type { CheckpointCtxRowsRewriter } from "./plugins/checkpoint-store-face.js";
18
18
  /** M28 一次起服的读数(起服 info 行逐键打出;测试按它断言)。`window: "closed"` ⇒ 一行都没读(其余全 0)。 */
19
19
  export interface CheckpointCtxSealM28Report {
20
20
  readonly window: "open" | "closed";
@@ -8,6 +8,7 @@ import { SESSION_SNAPSHOT_BUCKET_DEFAULT, WORKSPACE_SNAPSHOT_BUCKET_DEFAULT } fr
8
8
  import { WORKSPACE_PERSIST_DEFAULT, WORKSPACE_PERSIST_WORDS, WORKSPACE_SNAPSHOT_KEEP_DEFAULT, WORKSPACE_SNAPSHOT_KEEP_RANGE, WORKSPACE_SNAPSHOT_PREFIX_DEFAULT, WORKSPACE_SNAPSHOT_TIMEOUT_MS_DEFAULT, WORKSPACE_SNAPSHOT_TIMEOUT_MS_RANGE } from "./workspace-space.js";
9
9
  import { APPROVAL_ASK_RETENTION_DEFAULT_MS, APPROVAL_ASK_RETENTION_FLOOR_MS } from "./approval-ask-retention.js";
10
10
  import { SANDBOX_SECRET_SEAT_VERBS } from "./plugins/k8s-exec-protocol.js";
11
+ import { ADOPTION_IMPORT_MAX_SESSIONS_DEFAULT, ADOPTION_IMPORT_MAX_SESSIONS_FLOOR, ADOPTION_IMPORT_MAX_SESSION_BYTES_CEILING, ADOPTION_IMPORT_MAX_SESSION_BYTES_DEFAULT, ADOPTION_IMPORT_MAX_SESSION_BYTES_FLOOR } from "./adoption/import-limits.js";
11
12
  import { LIVENESS_MS_DEFAULT } from "./exec-bounds.js";
12
13
  import { THINKING_FORMATS } from "./model-compat.js";
13
14
  import { AUTO_MODE_CLASSIFIER_TIMEOUT_BOUNDS, CENTER_BASE_URL_RULE, CONFIG_PROVIDER_WORDS, DRAIN_SECOND_SIGNAL_MIN_GAP_BOUNDS, DRAIN_SECOND_SIGNAL_MIN_GAP_DEFAULT_MS, DEVICE_DELIVERY_TIMEOUT_BOUNDS, DEVICE_EXEC_TIMEOUT_BOUNDS, FIRST_BYTE_TIMEOUT_BOUNDS, FLEET_LEASE_OUTAGE_MAX_DEFAULT_MS, RESILIENCE_DEFAULTS, TASK_WRITE_FACE_ESCALATIONS } from "./config-types.js";
@@ -60,6 +61,8 @@ export const CONFIG_CATALOG = [
60
61
  r("ADB_MOUNT_PATH", "orchestration", "path", "adb 车道工作区挂载路径(缺省由 adapter 定)"),
61
62
  r("ADB_PATH", "orchestration", "path", "adb 二进制路径(缺省 PATH 上的 adb)"),
62
63
  r("ADB_SERIAL", "orchestration", "string", "adb 车道目标设备 serial(REMOTE_EXEC=adb 的必需件,缺 ⇒ 拒启)"),
64
+ r("ADOPTION_IMPORT_MAX_SESSIONS", "limitsHttp", "number", `收编批量导入 POST /v1/adoption/:id/sessions 每请求最多几个会话信封(超了整请求 400 request.field_invalid,句子点名本旋钮;地板 ${ADOPTION_IMPORT_MAX_SESSIONS_FLOOR},越界夹取 + 点名,小数拒启);当前值经能力位 adoptionImport.maxSessions 交给已收编的源主体`, { staticDefault: String(ADOPTION_IMPORT_MAX_SESSIONS_DEFAULT), configKey: "adoptionImportMaxSessions" }),
65
+ r("ADOPTION_IMPORT_MAX_SESSION_BYTES", "limitsHttp", "number", `收编批量导入每个会话信封最多多少字节(信封 JSON 的 UTF-8 字节;超了只拒那一个元素 rejected/too_large,带 count 与 cap;合法域 [${ADOPTION_IMPORT_MAX_SESSION_BYTES_FLOOR}, ${ADOPTION_IMPORT_MAX_SESSION_BYTES_CEILING}] —— 上帽 = JSON 体上限减空批包络,再大的值够不着,越界夹取 + 点名,小数拒启);当前值经能力位 adoptionImport.maxSessionBytes 交给已收编的源主体`, { staticDefault: String(ADOPTION_IMPORT_MAX_SESSION_BYTES_DEFAULT), configKey: "adoptionImportMaxSessionBytes" }),
63
66
  r("AGENT_DATA_DIR", "store", "path", "本机数据根回落链一环(LOCAL_DATA_ROOT → CONFIG_LOCAL_DIR → AGENT_DATA_DIR → ~/.ai-agent);记忆引擎缺省根同链", { danger: DATA, derivedDefaultNote: "缺席 ⇒ 链上下一环,最终 ~/.ai-agent" }),
64
67
  r("ALLOW_UNAUTHED_WRITES", "auth", "boolean", "无 service token 时仍接受任务提交(本地开发逃生口;缺省 fail-closed 拒提交)", { staticDefault: "false", danger: SEC, configKey: "allowUnauthedWrites" }),
65
68
  r("ANTHROPIC_API_KEY", "modelPlane", "secret", "Anthropic 协议路线的 x-api-key 凭据(只发 x-api-key 头;与 ANTHROPIC_AUTH_TOKEN 互斥 —— 同设拒启,机读码 `config.anthropic_credential_conflict`;与 BASE_URL 同在时可推断 provider)", { danger: [...SEC, ...BILL] }),
@@ -128,6 +131,7 @@ export const CONFIG_CATALOG = [
128
131
  r("DEVICE_RECONNECT_GRACE_MS", "orchestration", "number", `device 断连后在途不判丢的窗(ms;同 epoch 重连续接;原值进 helloAck.reconnectGraceMs;须为 [${DEVICE_HELLO_ACK_BOUNDS.reconnectGraceMs.min}, ${DEVICE_HELLO_ACK_BOUNDS.reconnectGraceMs.max}] 内规范十进制整数,其余拒启)`, { derivedDefaultNote: "缺席 ⇒ adapter 默认 120s" }),
129
132
  r("DEVICE_RELAY_URL", "orchestration", "url", "设备入口(REMOTE_EXEC=device 必填):设备连不到本引擎自己的地址(引擎在中继 / 网关之后)时拨的那一个 ws(s) URL,逐字上 /v1/capabilities 的 deviceExecutor.relayUrl;或字面 none = 没有中继,设备按引擎地址 + deviceExecutor.wsPath 拨号(能力面不带 relayUrl;有设备绑定时起服 warn 点名绑定数)。URL 须为无 userinfo / query / fragment、不带凭据形的 ws:// 或 wss:// 绝对地址,其余拒启。不从 FLEET_ADVERTISE_ADDRESS 派生(那是对中心公告的地址,受众不是设备)", { enumValues: [DEVICE_RELAY_NONE], derivedDefaultNote: "无缺省:device 车道的必需键 —— 缺席 / 空串 / 只含空白拒起(撤中继声明的回滚序 = 先恢复引擎自己的入口,再写 none)" }),
130
133
  r("DEVICE_SUPERSEDE", "orchestration", "enum", "同 deviceId 二连的顶替策略", { enumValues: ["stale_only", "deny"], staticDefault: "stale_only", danger: SEC }),
134
+ r("DEVICE_TRUSTED_PROXY_CIDRS", "orchestration", "csv", "设备 WS 未鉴权握手 per-remote 帽键的可信代理名单(逗号分隔,每项 = IP 地址或 CIDR,裸地址 = 单台;只放自己的反代):socket 对端落在名单内才读 X-Forwarded-For,取自右向左第一个不在名单内的地址作帽键;名单外的对端一律不采代理头;头行数到顶 / 头缺席 / 坏形 / 全在名单内 ⇒ 键退回 socket 对端 + warn。不是 IP 地址或 CIDR 的项 / zone id / 主机位非零 / 前缀 0 / 空项拒启", { danger: SEC, derivedDefaultNote: "缺席 ⇒ 空 = 不读任何代理头(帽键 = socket 对端)" }),
131
135
  r("DIRECT_APPROVAL_DOOR", "approval", "boolean", "直连 /decide 门(无 BFF 的桌面/CLI 客户端;开 ⇒ 要求签名 JWT+HMAC 信封,principal 头降级不可信)", { staticDefault: "false", danger: SEC, configKey: "directApprovalDoor" }),
132
136
  r("DOCKER_COMMAND_TIMEOUT_MS", "orchestration", "number", "local-docker 车道单命令超时(ms)"),
133
137
  r("DOCKER_CPUS", "orchestration", "number", "local-docker 容器 CPU 限额"),
@@ -140,7 +144,7 @@ export const CONFIG_CATALOG = [
140
144
  r("DOCKER_PATH", "orchestration", "path", "docker 二进制路径"),
141
145
  r("DOCKER_PIDS_LIMIT", "orchestration", "number", "local-docker fork-bomb 背栓(--pids-limit;非法值回 adapter 默认 512+warn)", { danger: SEC, derivedDefaultNote: "缺席 ⇒ adapter 默认 512" }),
142
146
  r("DOCKER_SANDBOX_ENV", "orchestration", "secret", "local-docker 车道每条 docker exec 以 -e 注入的本进程 env 点名表(NAME,NAME;点到的键从 worker env 原样取,值不进 spec/center/日志;与 LSP_ENV_ALLOW / E2B_SANDBOX_ENV 同一只解析器与「点名放行」谓词:形错 / 点名名单型旋钮 / 点名本服务自有凭据名(会把本服务的凭据装进模型读得到的沙箱;判官 = 引擎拒白名单的同一只)拒启且不回显值;本进程环境里没有的名按序号 warn、不转发;只在本车道被选中时求值;原文按凭据类对待:只回在场位、不进任何子进程)", { danger: SEC }),
143
- r("DRAIN_GRACE_MS", "limitsHttp", "number", "SIGTERM 优雅排空窗(ms;期间新计费提交 503+Retry-After)。出厂默认是**服务器部署**的取值;壳自 spawn 的引擎会被壳注入更短的窗 ⇒ 排壳形关机预算时以本行的 effectiveValue(= 本进程实际生效值)为准,不照抄 staticDefault", { staticDefault: String(10 * 60 * 1000), configKey: "drainGraceMs", center: cLimits("drainGraceMs") }),
147
+ r("DRAIN_GRACE_MS", "limitsHttp", "number", "SIGTERM 优雅排空窗(ms;期间新计费提交 503+Retry-After)。出厂默认是**服务器部署**的取值;壳自 spawn 的引擎会被壳注入更短的窗 ⇒ 排壳形关机预算时按壳自己注入的值算(壳读不到本目录:它是 operator-only),排空开始后本次排空定死的到期点读 GET /health 的 engineSignal.draining.deadlineAt,从信号到进程退出的上界见 USAGE 的「停机上界(契约句)」;不照抄 staticDefault", { staticDefault: String(10 * 60 * 1000), configKey: "drainGraceMs", center: cLimits("drainGraceMs") }),
144
148
  r("DRAIN_SECOND_SIGNAL_MIN_GAP_MS", "limitsHttp", "number", `排空期「第二发信号 = 硬停」的最小间隔(ms;锚 = 本次排空的第一发停止信号 —— SIGTERM / SIGHUP 升级进的排空,入口那一发就是它;排空口 / 租约被拒 / 附着租约自退进的排空,到达的第一发被吸收、不缩短期限。SIGTERM / SIGINT 与锚相隔不足 ⇒ 同一拍的重复投递,一行 drain_duplicate_signal_ignored 后忽略、排空继续;0 = 关,恒按第二发硬停;须为 [${DRAIN_SECOND_SIGNAL_MIN_GAP_BOUNDS.minMs}, ${DRAIN_SECOND_SIGNAL_MIN_GAP_BOUNDS.maxMs}] 内十进制整数(上界 = DRAIN_GRACE_MS 地板),小数 / 负数 / 越界拒启)`, { staticDefault: String(DRAIN_SECOND_SIGNAL_MIN_GAP_DEFAULT_MS), configKey: "drainSecondSignalMinGapMs" }),
145
149
  r("DURABLE_APPROVAL", "approval", "boolean", "durable suspend/resume HITL(需 SQL 店;决定 checkpointStore 与 /v1/approvals 面的存在性)", { danger: SEC, derivedDefaultNote: "posture 三态(S-178):显式词恒赢,缺席 = 单用户(REQUIRE_PRINCIPAL≠true)且有耐久店 ⇒ on / 多租户或无耐久店 ⇒ off;生效来源见 GET /v1/diagnostics/wiring 的 serverGates.durableApproval.source", configKey: "durableApproval" }),
146
150
  r("E2B_ALLOW_NET", "orchestration", "boolean", "e2b 沙箱出网许可", { danger: SEC, derivedDefaultNote: "缺席 ⇒ 不铸键(adapter 默认允许)" }),
@@ -156,6 +160,8 @@ export const CONFIG_CATALOG = [
156
160
  r("E2B_TEMPLATE", "orchestration", "string", "e2b 模板名(缺省 adapter 基础模板)"),
157
161
  r("E2B_TIMEOUT_MS", "orchestration", "number", "e2b 单命令总超时(ms)"),
158
162
  r("ENGINE_AUTO_EXIT", "limitsHttp", "boolean", "引擎附着租约自退总开关(壳 spawn 形注 true;三合取持续 linger 窗才自退,走 SIGTERM 同一条 drain 腿)", { staticDefault: "false", configKey: "engineAutoExit" }),
163
+ r("ENGINE_FIRST_ATTACH_MS", "limitsHttp", "number", "首次附着前的宽限窗(ms):起服以来还没有过非探针请求时,自退的生效窗 = max(ENGINE_LINGER_MS, 本值);首个非探针请求后回到 ENGINE_LINGER_MS;父死后孤儿窗优先;0 = 不给额外宽限;其余 [1000,24h] 拒启带界", { staticDefault: "180000", configKey: "engineFirstAttachMs" }),
164
+ r("ENGINE_HANDOVER_LINGER_MS", "limitsHttp", "number", "交接车道的静默窗(ms):壳经 POST /v1/engine/handover 把引擎交给后台之后,无附着 ∧ 无在飞 ∧ 无运行中后台 shell ∧ 无 HTTP 触点要持续这么久才自退;下一只壳 POST /v1/engine/attach 即离开交接车道;[60000,24h] 外拒启带界(解析无条件)", { staticDefault: "1800000", configKey: "engineHandoverLingerMs" }),
159
165
  r("ENGINE_LINGER_MS", "limitsHttp", "number", "父还活着时自退前三合取须持续成立的静默窗(ms;[1000,24h] 拒启带界)", { staticDefault: "60000", configKey: "engineLingerMs" }),
160
166
  r("ENGINE_ORPHAN_LINGER_MS", "limitsHttp", "number", "父进程已不在(孤儿)时的静默窗(ms;[1000,24h] 拒启带界;SEMA_PARENT_PID 缺席则不生效)", { staticDefault: "2000", configKey: "engineOrphanLingerMs" }),
161
167
  r("EXPERIMENTAL_OBSERVER_AGENTS", "orchestration", "boolean", "observer 开闸线(实验面 ship-dark;多租户只认 center caps,env 被忽略)", { staticDefault: "false", configKey: "experimentalObserverAgents" }),
@@ -175,7 +181,7 @@ export const CONFIG_CATALOG = [
175
181
  r("GIT_API_BASEURL", "integrations", "url", "repo 工具的 Git host API base", { configKey: "gitApiBaseUrl" }),
176
182
  r("GIT_API_KIND", "integrations", "enum", "Git host API 方言", { enumValues: ["gitea", "github"], staticDefault: "gitea", configKey: "gitApiKind" }),
177
183
  r("GIT_API_TOKEN", "integrations", "secret", "repo 工具的 Git host 凭据", { danger: SEC }),
178
- r("HOOKS_TIMEOUT_MS", "orchestration", "number", "请求 settings.hooks 注册每个 handler 的时间预算(ms;0=零预算是合法值)", { derivedDefaultNote: "缺席 ⇒ 不铸键,读法 settingsHooksBudgetMs 取 600000" }),
184
+ r("HOOKS_TIMEOUT_MS", "orchestration", "number", "请求 hooks 的每张车道注册(settings.hooks / settings.hooks.managed,各一份同值)每个 handler 的时间预算(ms;0=零预算是合法值)", { derivedDefaultNote: "缺席 ⇒ 不铸键,读法 settingsHooksBudgetMs 取 600000" }),
179
185
  r("HOST_BG_DEFAULT_TIMEOUT_SEC", "orchestration", "number", "host 后台 shell 缺省超时(秒)", { staticDefault: "300" }),
180
186
  r("HOST_BG_ENABLED", "orchestration", "boolean", "host 车道后台 shell 开关", { staticDefault: "true" }),
181
187
  r("HOST_BG_FILE_CAP", "orchestration", "number", "host 后台 shell 磁盘护栏(字节;失控输出被 reap)", { staticDefault: String(64 * 1024 * 1024) }),
@@ -233,7 +239,7 @@ export const CONFIG_CATALOG = [
233
239
  r("LEADER_WORKER_BUDGET_USD", "orchestration", "number", "leader 每 worker 花费帽(USD)", { staticDefault: "100", danger: BILL }),
234
240
  r("LEADER_WORKER_MAX_TURNS", "orchestration", "number", "leader 每 worker 轮数帽", { staticDefault: "10000", danger: BILL }),
235
241
  r("LEADER_WORKER_SLICE_BUDGET_USD", "orchestration", "number", "leader worker 单分片花费帽(USD)", { danger: BILL, derivedDefaultNote: "缺席 ⇒ max(1, workerBudgetUsd/4)" }),
236
- r("LOCAL_DATA_ROOT", "store", "path", "file 店数据根的最高优先覆写(设了则与配置根分家,boot 出声)", { danger: DATA }),
242
+ r("LOCAL_DATA_ROOT", "store", "path", "file 店数据根的最高优先覆写(配置根不跟着走;`CONFIG_LOCAL_DIR` 没设而数据根 ≠ 推导出的配置根时,boot 出一行 `local_roots_split`;给了 `CONFIG_LOCAL_DIR` 即视作表过态,不出声)", { danger: DATA }),
237
243
  r("LOCKED_CONFIG_KEYS", "auth", "csv", "管理员锁定层声明(词表=core 闭集注册表,未知键拒启)", { danger: SEC, configKey: "lockedConfigKeys" }),
238
244
  r("LOG_LEVEL", "observability", "string", "日志档位", { staticDefault: "info", configKey: "logLevel" }),
239
245
  r("LSP_ENABLED", "orchestration", "boolean", "LSP 沙箱腿 opt-in —— 本版 e2b / k8s 执行环境不实现绑定读,开了也不挂(起服一行 lsp_not_mounted);host 腿另有 LSP_HOST_ENABLED", { staticDefault: "false", configKey: "lspEnabled" }),
@@ -250,7 +256,7 @@ export const CONFIG_CATALOG = [
250
256
  r("MCP_ELICITATION_TTL_MS", "approval", "number", "elicitation 无人应答释放窗(ms)", { derivedDefaultNote: "缺席 ⇒ 本服务出厂窗(DEFAULT_ELICITATION_THROTTLE)" }),
251
257
  r("MEMORY_AUTO_CONSOLIDATION", "memory", "enum", "记忆自动整理部署席(on=每个建议任务后整库整理跑,记忆内容自动外流到整理模型;off=显式关,胜过引擎缺省;未设=读引擎具名缺省)", { enumValues: ["on", "off"], derivedDefaultNote: "缺席 ⇒ 引擎具名缺省(**本版装的引擎是开**)——不配不等于关;前置=整理阀门开着(MEMORY_CONSOLIDATION_DRIVER=on,或未设而出厂缺省派生成开)", danger: SEC, resolve: (c) => c.memoryConsolidationDriver.autoRunOnRecommendation, booleanEnum: { true: "on", false: "off" } }),
252
258
  r("MEMORY_CAPTURE_POLICY", "memory", "enum", "记忆 capture 姿态(open=声明按面值;governed=按 per-principal verdict;capture-required=恒采)", { enumValues: ["open", "governed", "capture-required"], staticDefault: "open", danger: SEC, configKey: "memoryCapturePolicy" }),
253
- r("MEMORY_CONSOLIDATION_DRIVER", "memory", "enum", "记忆折叠阀门(off=零装配零探针,两 admin 口 404 族;on=座解析 + 两 admin 口 + 引擎面整理两席)", { enumValues: ["on", "off"], derivedDefaultNote: "缺席 ⇒ 起服时派生:整理座不落主模型(MODEL_CHEAP_ID 在场且异于 MODEL_ID,或目录给 consolidate / summarize / flash 档位绑了别的模型)⇒ on;落主模型 ⇒ off + 起服 warn memory_consolidation_default_off_no_cheap_model;结构上跑不起来(无记忆引擎 / pg·mysql 记忆后端 / MEMORY_PROVENANCE=off)⇒ 恒 off 零提示。显式 on 而落主模型 ⇒ 照开 + warn memory_consolidation_on_main_model(按主模型计费)", danger: BILL, resolve: (_c, _env, boot) => (boot.memoryConsolidationValve === undefined ? undefined : boot.memoryConsolidationValve.enabled ? "on" : "off") }),
259
+ r("MEMORY_CONSOLIDATION_DRIVER", "memory", "enum", "记忆折叠阀门(off=零装配零探针,两 admin 口 404 族;on=座解析 + 两 admin 口 + 引擎面整理两席)", { enumValues: ["on", "off"], derivedDefaultNote: "缺席 ⇒ 起服时派生:整理座不落主模型(MODEL_CHEAP_ID 在场且异于 MODEL_ID,或目录给 consolidate / summarize / flash 档位绑了别的模型)⇒ on;落主模型 ⇒ off + 起服 warn memory_consolidation_default_off_no_cheap_model;结构上跑不起来(多租户 / MEMORY_ENGINE=off / pg·mysql 记忆后端 / MEMORY_PROVENANCE=off / 合规档否决整理)⇒ 恒 off 零提示。显式 on 而落主模型 ⇒ 照开 + warn memory_consolidation_on_main_model(按主模型计费)", danger: BILL, resolve: (_c, _env, boot) => (boot.memoryConsolidationValve === undefined ? undefined : boot.memoryConsolidationValve.enabled ? "on" : "off") }),
254
260
  r("MEMORY_CONSOLIDATION_INTERVAL_SEC", "memory", "number", "折叠周期腿节律(秒;本 build 任何正值拒启 —— 周期腿未落地,恒 0)", { staticDefault: "0" }),
255
261
  r("MEMORY_CONSOLIDATION_SCOPES", "memory", "csv", "折叠阀门 scope 表(恰一条时=admin 口缺省;不是授权边界)"),
256
262
  r("MEMORY_DELEGATION_EVIDENCE", "memory", "enum", "委派臂污染标记的证据标准", { enumValues: ["static-face", "attested-only"], staticDefault: "static-face", danger: SEC, configKey: "memoryDelegationEvidence" }),
@@ -416,6 +422,8 @@ export const CONFIG_CATALOG = [
416
422
  r("REWIND_SNAPSHOT_MAX_MB", "store", "number", "已退役(S-15 整树快照纪元退役):设了只 boot warn 一次,零行为", { envTiming: "inert" }),
417
423
  r("ROSTER_RETENTION_MS", "orchestration", "number", "agent_roster 行 TTL(ms;SQL twins 扩展面)", { staticDefault: String(30 * 24 * 60 * 60 * 1000), danger: DATA, configKey: "rosterRetentionMs" }),
418
424
  r("ROUTER_ENABLED", "orchestration", "boolean", "A 价值路由(per-task 编排自动决策;ship-dark)", { staticDefault: "false", configKey: "routerEnabled" }),
425
+ r("RUN_MAX_CONCURRENT", "orchestration", "number", "本副本在飞 run 的全局并发帽(0 = 关;整数,坏值拒启):提交门(POST /v1/runs · A2A message/send · POST /v1/tasks · POST /v1/tasks/stream)在幂等重放之后判在飞数,已到帽 ⇒ 429 limit.rate_exceeded + reason run_concurrency_cap + Retry-After: 5;续跑 / 唤醒 / 审批作答不判", { staticDefault: "0", configKey: "runMaxConcurrent" }),
426
+ r("RUN_MAX_CONCURRENT_PER_PRINCIPAL", "orchestration", "number", "同一已验提交主体在本副本的在飞 run 并发帽(0 = 关;整数,坏值拒启;无主体请求不判这一帽,只受 RUN_MAX_CONCURRENT)", { staticDefault: "0", configKey: "runMaxConcurrentPerPrincipal" }),
419
427
  r("RUN_STORE_STRICT_HYDRATE", "store", "enum", "file run-store 列不出 runs/ 时拒启的 fail-closed 门(缺省带病起动+响亮披露)", { enumValues: ["on", "off"], staticDefault: "off", danger: DATA, configKey: "runStoreStrictHydrate", booleanEnum: { true: "on", false: "off" } }),
420
428
  r("S3_ENDPOINT", "store", "url", "外接 S3 兼容位(单独在场即开公链签发,兼作公网面)", { danger: DATA }),
421
429
  r("S3_PUBLIC_BUCKET", "store", "string", "SendUserFile 公链桶", { derivedDefaultNote: "缺席 ⇒ sema-public" }),
@@ -456,6 +464,7 @@ export const CONFIG_CATALOG = [
456
464
  r("SENSITIVE_WRITE_PATTERNS", "approval", "csv", "敏感路径写 deny 集(unset=core 推荐集;显式值整表替换;off/空=关 —— 真放松杆)。拒的是文件工具(Write / Edit / NotebookEdit,按路径);shell 命令写同一路径(重定向 / tee / cp …)不被这个集拒绝,走普通审批问", { danger: SEC, derivedDefaultNote: "缺席 ⇒ core RECOMMENDED_SENSITIVE_PATTERNS", configKey: "sensitiveWritePatterns" }),
457
465
  r("SERVICE_AUTH_TOKEN", "auth", "secret", "共享 service token(写面门;缺席且未开 ALLOW_UNAUTHED_WRITES ⇒ 拒提交)", { danger: SEC }),
458
466
  r("SERVICE_AUTH_TOKENS", "auth", "secret", "per-system 凭据表(tok=system CSV;source 从凭据派生,绝不自报)", { danger: SEC }),
467
+ r("SERVICE_TOKEN_ACTS_FOR_DEPLOYMENT", "auth", "boolean", "出示 service 凭据、不报主体的调用方代不代部署本人(true ⇒ 代:fleet 读面看全舰队、运维聚合口照放;false ⇒ 它是无身份调用方:fleet 读面 401、运维聚合口只认只读令牌、写档 401;带主体头的请求两形都是那位主体;GET /health 的 auth.serviceTokenActsForDeployment 自报;词表外拒启;起服冻结)", { staticDefault: "true", danger: SEC, configKey: "serviceTokenActsForDeployment" }),
459
468
  r("SESSION_AUTO_TITLE", "orchestration", "boolean", "首次提交自动铸 session 标题(一次 cheap 调用)", { staticDefault: "true", danger: BILL, configKey: "sessionAutoTitle" }),
460
469
  r("SESSION_BACKEND", "store", "enum", "session 店引擎(auto=配了该引擎的坐标就用那只库、没配就是内存;配了而此刻连不上 ⇒ 在 STORE_LOCK_WAIT_MS 窗内重试、到窗拒启,绝不落内存;回显=boot 解析后的真引擎)", { enumValues: SESSION_BACKENDS, danger: DATA, derivedDefaultNote: "缺席:显式 DB_BACKEND=mysql|pg ⇒ mysql,否则 memory", configKey: "sessionBackend", resolve: (c) => (c.sessionBackend === "tidb" ? "mysql" : c.sessionBackend) }),
461
470
  r("SESSION_CACHE_TTL_SEC", "store", "number", "session 读缓存 TTL(秒;0=关)", { staticDefault: "300", configKey: "sessionCacheTtlSec" }),
@@ -210,8 +210,8 @@ export declare function createConfigProvider(input: ConfigProviderInput): Config
210
210
  * (`composeExecutionLane` 的 `localRoot`)—— 修前两个入口各写一份这条链(run-local 还多一个与之等价的三元),工厂又在
211
211
  * 字面 `"local"` 之外回落 `process.cwd()`。
212
212
  *
213
- * ⚠️ 与**数据根**(`config.localDataRoot`,多一节 `LOCAL_DATA_ROOT`)不是同一条链:两根分家的那一形由第 1 段的
214
- * `local_roots_split` 告警说出来(`splitLocalRoots`),合一旋钮 = `CONFIG_LOCAL_DIR`。
213
+ * ⚠️ 与**数据根**(`config.localDataRoot`,多一节 `LOCAL_DATA_ROOT`)不是同一条链:两根一声不响分家的那一形(没给 `CONFIG_LOCAL_DIR`)由第 1 段的
214
+ * `local_roots_split` 告警说出来(`splitLocalRoots`),合一旋钮 = `CONFIG_LOCAL_DIR`(给出即是表态,等 = 合一,不等 = 有意分家,都不响)。
215
215
  */
216
216
  export declare function configLocalRoot(config: {
217
217
  readonly configLocalDir?: string | undefined;
@@ -1042,6 +1042,10 @@ export interface ServiceConfigFlat {
1042
1042
  * 形会把全员折叠成单键,per-remote 层退化成共享预算而非公平层,`off` + 全局帽 64 是诚实形)。
1043
1043
  * 坏值拒启([ref] A 档),词表与拒因见 config.ts `parseDevicePreAuthPerRemoteEnv`。 */
1044
1044
  maxPreAuthPerRemote?: number | "off";
1045
+ /** `DEVICE_TRUSTED_PROXY_CIDRS`([ref];缺席 = 名单空 = 不读任何代理头,帽键 = socket 对端)= per-remote 帽键的可信代理
1046
+ * 名单(规范 CIDR 文本)。socket 对端落在名单内,汇聚端才读 `X-Forwarded-For`、取自右向左第一个名单外地址作帽键。
1047
+ * 坏项拒启([ref] A 档),拒因见 config.ts `parseDeviceTrustedProxyCidrsEnv`;唯一消费点 = `boot/device-lane.ts` 透传汇聚端。 */
1048
+ trustedProxyCidrs?: readonly string[];
1045
1049
  /** `DEVICE_ENROLL_TOKEN_TTL_SEC`(§4.7 第五个旋钮;默认 900 = §7-T5 ① 的 15min)= enrollment
1046
1050
  * token 的有效期**时长**(整秒,自 **DB now** 起算 —— 时间权威是库,不是副本墙钟)。唯一消费点 =
1047
1051
  * 签发动词 `POST /v1/devices/enroll-tokens`(`http/routes/devices.ts`);[ref] 之前它刻意未铸
@@ -1299,6 +1303,10 @@ export interface ServiceConfigFlat {
1299
1303
  attachmentMimeAllowlist?: string[];
1300
1304
  /** D-1 未绑定附件 TTL(上传后从未被任何 task 引用的行,过期由 reaper 收割;缺省 24h)。 */
1301
1305
  attachmentUnboundTtlMs: number;
1306
+ /** 收编批量导入 `POST /v1/adoption/:id/sessions`:每请求最多几个会话信封(`ADOPTION_IMPORT_MAX_SESSIONS`;缺省 / 地板见 `adoption/import-limits.ts`)。 */
1307
+ adoptionImportMaxSessions: number;
1308
+ /** 收编批量导入:每个会话信封最多多少字节(信封 JSON 的 UTF-8 字节;`ADOPTION_IMPORT_MAX_SESSION_BYTES`;缺省 / 地板 / 上帽见 `adoption/import-limits.ts`)。 */
1309
+ adoptionImportMaxSessionBytes: number;
1302
1310
  /** Header carrying the authenticated principal (S6). Identity never comes from the body. */
1303
1311
  principalHeader: string;
1304
1312
  /** Require the principal header on task requests (set true in multi-tenant production). */
@@ -1365,6 +1373,15 @@ export interface ServiceConfigFlat {
1365
1373
  * 只在单用户形(`REQUIRE_PRINCIPAL` 未开)且名单为空时成立 —— 否则拒启(`config-invariants.ts` 的 `operator-single-user`:一个事实一个来源)。
1366
1374
  * env 独有(没有中心写位),起服冻结。读法只有 `explicitOperatorOk` / `operatorRosterPresent` 两只。 */
1367
1375
  operatorSingleUser?: boolean;
1376
+ /**
1377
+ * `SERVICE_TOKEN_ACTS_FOR_DEPLOYMENT` —— 「出示这台部署的 service 凭据、不报主体的调用方是谁」的**唯一声明座**。缺省 `true`(不设 = 今天的读法):
1378
+ * 它代部署本人说话(fleet 调用方,运维聚合口的 service 臂);`false` ⇒ 它是**无身份调用方**,各面按既有的「过了凭据门、没有主体」那一臂答
1379
+ * (fleet 读面 401 identity、运维聚合口 401 operator、舰队流多租 401 principal_required / 单用户落 `default`、写档 401 identity、无主 placed 子代 404)。
1380
+ * 只改一处:`http/principal-gate.ts` 的 `actsForDeployment` 多这一个合取项 —— 它的两个读者(fleet 调用方的凭据臂、`/metrics*` 的 service 臂)一次继承,
1381
+ * 零新拒码、零新闸点;自报位 `/health.auth.serviceTokenActsForDeployment` = 配了 service 凭据 ∧ 本位。没配 service 凭据的部署上声明 `false` 是空真(那一臂本来就够不着)。
1382
+ * env 独有(词表布尔,词表外拒启;没有 `config.d` 文件形、没有中心写位),起服读一次、热路径够不着(不是热键)。
1383
+ */
1384
+ serviceTokenActsForDeployment: boolean;
1368
1385
  /**
1369
1386
  * DESIGN-278 §5 S2([ref])—— `GET /v1/config/catalog`(配置目录自描述端点)的显式旋钮。
1370
1387
  * 默认 **ON**(设计稿 §0.5:合规部署可关)。端点本身已是 operator-only(`explicitOperatorOk`,
@@ -1615,7 +1632,7 @@ export interface ServiceConfigFlat {
1615
1632
  * tools for a declared `plan` itself, and no plan entry clamps the hands (only `AUTONOMY=read-only` does). */
1616
1633
  planModeEnabled: boolean;
1617
1634
  /**
1618
- * `HOOKS_TIMEOUT_MS` —— 请求 `settings.hooks` 那张 mods 注册(`settings.hooks`)每个 handler 的时间预算(ms;一个事件跑一遍本请求的钩子条目)。
1635
+ * `HOOKS_TIMEOUT_MS` —— 请求 hooks 的每张车道注册(`settings.hooks` / `settings.hooks.managed`,各一份同值)每个 handler 的时间预算(ms;一个事件跑一遍这条车道的钩子条目)。
1619
1636
  * **缺席 = 不铸键**;唯一读法 = `hooks/hook-runner.ts` 的 `settingsHooksBudgetMs`(未设 ⇒ 600000,单条命令超时的上限;这只数是引擎的钟,不是钩子子进程的墙钟)。
1620
1637
  *
1621
1638
  * 🔴 `0` 是有效值(引擎按字面:零预算,下一个定时器拍就到期),不是「未设」;
@@ -1891,7 +1908,7 @@ export interface ServiceConfigFlat {
1891
1908
  * under the shared-engine shape (several shell sessions on one config, engine rides the FIRST shell's process
1892
1909
  * group per the T11 anti-orphan call) other live sessions may still be using this engine, so an unconditional
1893
1910
  * drain kills a peer mid-turn (499) and 503s new submits. Instead SIGHUP arms an idle watch: shut down only
1894
- * after `inflight()` (bg/resume legs + live streams) has been 0 for this long, WITHOUT flipping `draining`
1911
+ * after `inflight()` (bg/resume legs + live streams — the blocking set `http + leader`; session-resident background shells/monitors are in the `/health.inflight` total but do not block) has been 0 for this long, WITHOUT flipping `draining`
1895
1912
  * (peers stay fully served). A true orphan (last window closed) self-terminates when the window expires —
1896
1913
  * T11 stands, just bounded instead of immediate. A SECOND SIGHUP (or SIGTERM) escalates to the normal drain
1897
1914
  * path. Default 120s, floor 5s. Env: SIGHUP_IDLE_GRACE_MS. */
@@ -1940,6 +1957,20 @@ export interface ServiceConfigFlat {
1940
1957
  * `SEMA_PARENT_PID` 在不在场(operator-knob 铁律)。 Env: `ENGINE_ORPHAN_LINGER_MS`(默认 2000,闭区间
1941
1958
  * [1000, 86400000])。 */
1942
1959
  engineOrphanLingerMs: number;
1960
+ /** [ref]:**首次附着前**的宽限窗 —— 引擎起服以来还没有过任何非探针 HTTP 请求(态「候首触」)时,三合取要**持续**成立多久才自退;
1961
+ * 生效窗 = `max(`{@link engineLingerMs}`, 本值)`(宽限只拉长不缩短;`ENGINE_AUTO_EXIT` 关着 ⇒ owned 窗 = ∞ ⇒ 它也是 ∞)。首个非探针请求
1962
+ * 到达之后回到 {@link engineLingerMs}、单向;父死之后一律 {@link engineOrphanLingerMs}(孤儿压过候首触)。默认 **180000**:防的是一次性
1963
+ * `-p` 壳在 spawn 与首次接触之间被饿住(高载宿主 / CI)超过 owned 窗 —— 从没被碰过的引擎此前按 owned 窗自退,壳醒来起步失败。
1964
+ * `0` = 不给额外宽限(逐字回到本键之前的行为);小于 owned 窗的值同样落成 owned 窗。与两只静默窗**同一只校验器、同一对上下界**,
1965
+ * 多放行字面 `0`(别的零形照常拒);`1..999`(秒当毫秒)与其余坏值**拒启**;解析**无条件**(operator-knob 铁律)。 Env: `ENGINE_FIRST_ATTACH_MS`(默认 180000,
1966
+ * 取值 `0` 或闭区间 [1000, 86400000])。 */
1967
+ engineFirstAttachMs: number;
1968
+ /** [ref]([ref] v3):**交接车道**的静默窗 —— 壳经 `POST /v1/engine/handover` 把引擎交给后台、自己退出之后,三合取(无附着 ∧ 无在飞 ∧
1969
+ * 无运行中、引擎一退就会被收掉的后台 shell)要**持续**成立多久才自退。下一只壳 `POST /v1/engine/attach` 即离开本车道。默认 **1800000**(30 min):
1970
+ * 防的是「用户忘了后台引擎」,不是上限 —— 后台 shell 在跑时本窗不起算(那正是选「后台继续」的意思)。与其余三只窗**同一只校验器**,下界单独是
1971
+ * 60000(交接后的窗比壳重启窗还短没有意义);坏值**拒启**;解析**无条件**(operator-knob 铁律,不看 `ENGINE_AUTO_EXIT` / `SEMA_PARENT_PID`)。
1972
+ * Env: `ENGINE_HANDOVER_LINGER_MS`(默认 1800000,闭区间 [60000, 86400000])。 */
1973
+ engineHandoverLingerMs: number;
1943
1974
  /** E23 (shell-host contract): inbound MCP elicitation HITL. When enabled, the service mounts `RunnerDeps.onElicit` + the
1944
1975
  * `POST /v1/elicitations/:id/respond` route so an opted-in MCP server (`McpServerSpec.elicitation`, itself default
1945
1976
  * OFF) can ask the END USER for input mid-tool-call. LIVE-ONLY (no durable suspend; lost on crash/replica-change).
@@ -2170,6 +2201,14 @@ export interface ServiceConfigFlat {
2170
2201
  logLevel: "debug" | "info" | "warn" | "error";
2171
2202
  /** Per-principal request cap per minute on task/run endpoints. 0 disables. */
2172
2203
  rateLimitPerMin: number;
2204
+ /** `RUN_MAX_CONCURRENT`:本副本**在飞 run 的全局上限**(整数,0 / 缺省 = 不设)。一条新提交要起 run 时,在飞数已到帽 ⇒ 429 `limit.rate_exceeded`
2205
+ * + 机读 `reason: "run_concurrency_cap"` + `retryAfterSec: 5`(同值 `Retry-After` 头)。数的是 `inflightRuns ∪ steerableRuns`(与 `drainState.inflight` 同源);
2206
+ * 判点在三个提交门(`POST /v1/runs` 与 A2A `message/send`、`POST /v1/tasks`、`POST /v1/tasks/stream`)的幂等重放之后;续跑 / 唤醒 / 审批作答不判。
2207
+ * 属主 `http/run-concurrency-cap.ts`。 */
2208
+ runMaxConcurrent: number;
2209
+ /** `RUN_MAX_CONCURRENT_PER_PRINCIPAL`:同一**已验提交主体**(`gatedPrincipal`,与成本配额门同键)在本副本的在飞 run 上限(整数,0 / 缺省 = 不设)。
2210
+ * 无主体请求(无头 service 凭据)不判这一帽,只受 {@link ServiceConfigFlat.runMaxConcurrent}。 */
2211
+ runMaxConcurrentPerPrincipal: number;
2173
2212
  /** Operator CEILING on per-task cost (USD) / tokens (1.37 budget gate). A request may ask for a
2174
2213
  * LOWER limit but is capped to this; 0/unset = no ceiling. The review gateway sets these to stop a
2175
2214
  * single task from burning the shared cloud key. Enforced by core (failed + errorCode budget.*). */
@@ -2337,11 +2376,11 @@ export type ServiceMemoryConfig = Pick<ServiceConfigFlat, "memoryEngineEnabled"
2337
2376
  * 三者都是 operator 在配置面写下的**治理声明**(与 autonomy/commandPolicy 同族),不是存储旋钮
2338
2377
  * ——`retentionPolicy` 尤其容易被误归 store 组:它的消费点是 core 的启动期能力校验与将来的调度面,
2339
2378
  * config 这一层它只是一句声明。 */
2340
- export type ServiceAuthConfig = Pick<ServiceConfigFlat, "authToken" | "authTokens" | "allowUnauthedWrites" | "corsOrigins" | "principalHeader" | "requirePrincipal" | "autonomy" | "commandPolicy" | "compliancePosture" | "lockedConfigKeys" | "configCatalogEnabled" | "retentionPolicy" | "retentionSweep" | "operatorPrincipals" | "operatorSingleUser" | "principalJwtPubkeys" | "principalJwtIss" | "principalJwtAud" | "authBridgeIssuer" | "principalJwtMaxTtlSec" | "bindHost" | "bindHostSource">;
2379
+ export type ServiceAuthConfig = Pick<ServiceConfigFlat, "authToken" | "authTokens" | "allowUnauthedWrites" | "corsOrigins" | "principalHeader" | "requirePrincipal" | "autonomy" | "commandPolicy" | "compliancePosture" | "lockedConfigKeys" | "configCatalogEnabled" | "retentionPolicy" | "retentionSweep" | "operatorPrincipals" | "operatorSingleUser" | "serviceTokenActsForDeployment" | "principalJwtPubkeys" | "principalJwtIss" | "principalJwtAud" | "authBridgeIssuer" | "principalJwtMaxTtlSec" | "bindHost" | "bindHostSource">;
2341
2380
  /** 组:orchestration(编排 + 执行车道 + 沙箱面 + workflow/后台 agent 存留)。 */
2342
2381
  export type ServiceOrchestrationConfig = Pick<ServiceConfigFlat, "sandboxGit" | "remoteExec" | "remoteExecHomeDir" | "requireExecutionLane" | "worktreeIsolation" | "leaderEnabled" | "leaderFanoutEnabled" | "routerEnabled" | "selfOrchestrationEnabled" | "selfOrchestrationModels" | "selfOrchestrationWorkerIsolation" | "forkEnabled" | "experimentalObserverAgents" | "schedulerEnabled" | "schedulerSessionWakeup" | "schedulerSessionLifetime" | "schedulerStorePath" | "planModeEnabled" | "hooksTimeoutMs" | "workflowRunStoreBackend" | "workflowOrphanGraceMs" | "workflowJournalRetentionMs" | "workflowRunRetentionMs" | "usageWindows" | "workflowAgentsReadOnly" | "workflowSizeGuideline" | "backgroundAgentRetentionMs" | "backgroundAgentStaleRunningMs" | "backgroundAgentParkClaimStaleMs" | "delegationEntryCaps" | "rosterRetentionMs" | "leaderRunStaleMs" | "scratchpadSweepTtlMs" | "sandboxPkgSource" | "sandboxPkgSourceCustom" | "sessionAutoTitle" | "sessionAutoTitleSource" | "selectEnvironmentTool" | "envFactsEnabled" | "toolDeferLongtail" | "lspEnabled" | "lspHostEnabled" | "lspEnvAllow" | "imageBakes" | "readFace" | "readFaceSource" | "taskWriteFaceEscalation" | "readDenyPatterns" | "readDenyBuiltinTiers" | "readDenyBuiltinExclude" | "readDenyFloorRequired" | "sandboxReadFloor" | "agentConfigDir" | "configLkgPath" | "configLkgEnabled">;
2343
2382
  /** 组:limitsHttp(HTTP 面 + 各类上限/配额/回收窗)。 */
2344
- export type ServiceLimitsHttpConfig = Pick<ServiceConfigFlat, "port" | "attachmentOrphanGraceMs" | "workspaceFileMaxBytes" | "attachmentMaxBytes" | "attachmentMimeAllowlist" | "attachmentUnboundTtlMs" | "infraCostRates" | "drainGraceMs" | "drainSecondSignalMinGapMs" | "sighupIdleGraceMs" | "parentPid" | "engineAutoExit" | "engineLingerMs" | "engineOrphanLingerMs" | "rateLimitPerMin" | "maxTaskCostUsd" | "maxTaskTokens" | "maxPrincipalCostUsd" | "costQuotaWindowSec" | "reapIntervalSec" | "runStaleSec" | "toolResultTtlSec">;
2383
+ export type ServiceLimitsHttpConfig = Pick<ServiceConfigFlat, "port" | "attachmentOrphanGraceMs" | "workspaceFileMaxBytes" | "attachmentMaxBytes" | "attachmentMimeAllowlist" | "attachmentUnboundTtlMs" | "adoptionImportMaxSessions" | "adoptionImportMaxSessionBytes" | "infraCostRates" | "drainGraceMs" | "drainSecondSignalMinGapMs" | "sighupIdleGraceMs" | "parentPid" | "engineAutoExit" | "engineLingerMs" | "engineOrphanLingerMs" | "engineFirstAttachMs" | "engineHandoverLingerMs" | "rateLimitPerMin" | "runMaxConcurrent" | "runMaxConcurrentPerPrincipal" | "maxTaskCostUsd" | "maxTaskTokens" | "maxPrincipalCostUsd" | "costQuotaWindowSec" | "reapIntervalSec" | "runStaleSec" | "toolResultTtlSec">;
2345
2384
  /** 组:observability(可观测)。 */
2346
2385
  export type ServiceObservabilityConfig = Pick<ServiceConfigFlat, "metricsToken" | "traceToken" | "toolTrace" | "traceThinking" | "logLevel" | "otel">;
2347
2386
  /** 组:integrations(外部集成)。`mcpServers` / `a2aPeers` 由 web-admin 适配器填(无 env 腿),归本组。 */