@sema-agent/server 7.145.0 → 7.147.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION.md +876 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +374 -99
- package/deploy/facts/CHANGES.json +25 -0
- package/deploy/facts/README.md +57 -0
- package/deploy/facts/lanes.json +61 -0
- package/deploy/facts/lanes.schema.json +57 -0
- package/deploy/facts/sandbox-rbac.json +113 -0
- package/deploy/facts/sandbox-rbac.schema.json +74 -0
- package/deploy/facts/sealed-key.json +9 -0
- package/deploy/facts/sealed-key.schema.json +52 -0
- package/deploy/sema-up/README.md +2 -2
- package/deploy/sema-up/chart/templates/_helpers.tpl +41 -0
- package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +47 -7
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +9 -4
- package/deploy/sema-up/chart/templates/server.yaml +9 -4
- package/deploy/sema-up/chart/values.yaml +8 -1
- package/deploy/sema-up/cluster-up.sh +2 -1
- package/deploy/sema-up/lib/flagshape.sh +4 -0
- package/deploy/sema-up/lib/lanes.json +2 -5
- package/deploy/sema-up/sema-up.sh +12 -9
- package/deploy/sema-up/stack/compose.yaml +5 -4
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +34 -17
- package/dist/adoption/import-limits.d.ts +6 -0
- package/dist/adoption/import-limits.js +7 -0
- package/dist/adoption/import.d.ts +62 -0
- package/dist/adoption/import.js +107 -0
- package/dist/adoption/wire.d.ts +52 -0
- package/dist/adoption/wire.js +9 -0
- package/dist/approval-ask-machine.d.ts +2 -2
- package/dist/approval-card.d.ts +7 -16
- package/dist/approval-card.js +0 -4
- package/dist/approval-gate-currency.d.ts +1 -1
- package/dist/approval-gate-currency.js +1 -1
- package/dist/approval-reconciler.d.ts +1 -1
- package/dist/approval.d.ts +3 -3
- package/dist/audit.js +2 -2
- package/dist/bench/s1/live-deps.js +3 -1
- package/dist/boot/crash-last.js +2 -1
- package/dist/boot/deployment-mods.d.ts +11 -1
- package/dist/boot/deployment-mods.js +15 -2
- package/dist/boot/device-lane.js +7 -5
- package/dist/boot/engine-lease.d.ts +195 -22
- package/dist/boot/engine-lease.js +146 -20
- package/dist/boot/execution-env.d.ts +5 -0
- package/dist/boot/execution-env.js +57 -33
- package/dist/boot/execution-lane.d.ts +37 -9
- package/dist/boot/execution-lane.js +74 -20
- package/dist/boot/exit-boundary.d.ts +50 -0
- package/dist/boot/exit-boundary.js +32 -0
- package/dist/boot/exit-last.d.ts +20 -4
- package/dist/boot/exit-last.js +23 -5
- package/dist/boot/governance-seams.d.ts +2 -2
- package/dist/boot/governance-seams.js +1 -0
- package/dist/boot/leader.js +1 -1
- package/dist/boot/memory-boundary.d.ts +11 -11
- package/dist/boot/memory-boundary.js +3 -3
- package/dist/boot/memory-consolidation.d.ts +42 -41
- package/dist/boot/memory-consolidation.js +26 -28
- package/dist/boot/org-memory.js +3 -2
- package/dist/boot/parked-revive-gate.d.ts +1 -1
- package/dist/boot/parked-revive-gate.js +1 -1
- package/dist/boot/reapers.d.ts +12 -4
- package/dist/boot/reapers.js +40 -16
- package/dist/boot/resolve-spec.d.ts +2 -0
- package/dist/boot/resolve-spec.js +126 -123
- package/dist/boot/retention-lane.d.ts +4 -42
- package/dist/boot/runner-deps.js +1 -1
- package/dist/boot/session-faces.d.ts +1 -0
- package/dist/boot/session-faces.js +11 -3
- package/dist/boot/shutdown.js +27 -9
- package/dist/boot/stage-01-config.d.ts +1 -1
- package/dist/boot/stage-01-config.js +7 -3
- package/dist/boot/stage-02-web-admin-pull.d.ts +1 -1
- package/dist/boot/stage-02-web-admin-pull.js +10 -8
- package/dist/boot/stage-03-store-backend.d.ts +2 -1
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +2 -1
- package/dist/boot/stage-05-execution-env.d.ts +4 -1
- package/dist/boot/stage-05-execution-env.js +6 -6
- package/dist/boot/stage-06-runners.d.ts +5 -2
- package/dist/boot/stage-06-runners.js +12 -13
- package/dist/boot/stage-07-capability-layer.d.ts +5 -2
- package/dist/boot/stage-07-capability-layer.js +7 -7
- package/dist/boot/stage-08-reapers.d.ts +5 -2
- package/dist/boot/stage-08-reapers.js +3 -3
- package/dist/boot/stage-09-leader.d.ts +6 -2
- package/dist/boot/stage-10-http-server.d.ts +6 -2
- package/dist/boot/stage-10-http-server.js +5 -3
- package/dist/boot/stores.d.ts +10 -0
- package/dist/boot/stores.js +53 -26
- package/dist/boot/web-admin.js +3 -3
- package/dist/boot/workflow-orchestration.d.ts +1 -1
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/capabilities/center-plugins.d.ts +2 -0
- package/dist/capabilities/center-plugins.js +6 -2
- package/dist/capabilities/composite-members.d.ts +4 -1
- package/dist/capabilities/composite-members.js +4 -1
- package/dist/capabilities/execution-lane.d.ts +7 -7
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +1 -1
- package/dist/capabilities/scenarios.d.ts +34 -20
- package/dist/capabilities/scenarios.js +13 -9
- package/dist/capabilities/settings-contract.d.ts +29 -0
- package/dist/capabilities/settings-contract.js +14 -0
- package/dist/capabilities/skills.d.ts +5 -5
- package/dist/capability-facts.d.ts +56 -1
- package/dist/capability-facts.js +59 -8
- package/dist/center-credential-renewer.js +3 -2
- package/dist/checkpoint-ctx-seal-m28.d.ts +1 -1
- package/dist/config-catalog.js +19 -9
- package/dist/config-invariants.d.ts +18 -3
- package/dist/config-invariants.js +36 -19
- package/dist/config-lkg.d.ts +1 -1
- package/dist/config-lkg.js +5 -6
- package/dist/config-provider.d.ts +2 -2
- package/dist/config-provider.js +2 -0
- package/dist/config-types.d.ts +228 -185
- package/dist/config.d.ts +74 -6
- package/dist/config.js +146 -64
- package/dist/degenerate-instrument.js +1 -1
- package/dist/deleted-session-ids.d.ts +19 -0
- package/dist/deleted-session-ids.js +26 -0
- package/dist/deploy-facts.d.ts +155 -0
- package/dist/deploy-facts.js +95 -0
- package/dist/deployment-shape.d.ts +21 -12
- package/dist/deployment-shape.js +24 -6
- package/dist/device-ws-hub.d.ts +48 -3
- package/dist/device-ws-hub.js +48 -2
- package/dist/env-facts.d.ts +7 -5
- package/dist/env-facts.js +10 -6
- package/dist/error-code-family.d.ts +35 -0
- package/dist/error-code-family.js +26 -0
- package/dist/execution-config-root.d.ts +5 -5
- package/dist/execution-config-root.js +5 -5
- package/dist/execution-env-purpose.d.ts +14 -0
- package/dist/execution-env-purpose.js +29 -0
- package/dist/execution-lane-caps.d.ts +49 -86
- package/dist/execution-lane-caps.js +52 -62
- package/dist/execution-placement.d.ts +18 -2
- package/dist/execution-placement.js +19 -0
- package/dist/file-history-disclosure.d.ts +2 -2
- package/dist/fleet/drain-entry.d.ts +46 -3
- package/dist/fleet/drain-entry.js +6 -0
- package/dist/fleet/fleet-bus.d.ts +2 -1
- package/dist/fleet/serving-lease.js +3 -4
- package/dist/history-anchor.d.ts +22 -0
- package/dist/history-anchor.js +14 -0
- package/dist/hooks/branch-transcript.d.ts +1 -1
- package/dist/hooks/branch-transcript.js +1 -0
- package/dist/hooks/classic-stations.d.ts +25 -8
- package/dist/hooks/classic-stations.js +29 -3
- package/dist/hooks/command-spawn.d.ts +1 -4
- package/dist/hooks/command-spawn.js +0 -11
- package/dist/hooks/hook-runner.d.ts +85 -24
- package/dist/hooks/hook-runner.js +326 -109
- package/dist/hooks/hook-source.d.ts +14 -2
- package/dist/hooks/hook-source.js +8 -0
- package/dist/http/active-run-conflict.d.ts +1 -1
- package/dist/http/active-run-conflict.js +1 -1
- package/dist/http/admission.js +11 -1
- package/dist/http/approval-sweeps.d.ts +2 -5
- package/dist/http/approval-sweeps.js +3 -2
- package/dist/http/checkpoint-ctx.d.ts +76 -71
- package/dist/http/checkpoint-ctx.js +40 -40
- package/dist/http/claim-latency.d.ts +10 -0
- package/dist/http/claim-latency.js +12 -0
- package/dist/http/dispatch.js +19 -3
- package/dist/http/durable-run-leg.d.ts +5 -0
- package/dist/http/durable-run-leg.js +3 -1
- package/dist/http/execution-context.d.ts +7 -1
- package/dist/http/execution-context.js +13 -0
- package/dist/http/health-self-report.d.ts +6 -2
- package/dist/http/health-self-report.js +3 -2
- package/dist/http/memory-compliance-failure-reply.d.ts +2 -2
- package/dist/http/memory-compliance-failure-reply.js +5 -15
- package/dist/http/memory-control-plane-corrupt-reply.d.ts +25 -0
- package/dist/http/memory-control-plane-corrupt-reply.js +19 -0
- package/dist/http/memory-store-refusal-reply.d.ts +3 -3
- package/dist/http/memory-store-refusal-reply.js +3 -0
- package/dist/http/owner-access.d.ts +11 -0
- package/dist/http/owner-access.js +7 -4
- package/dist/http/principal-gate.d.ts +28 -16
- package/dist/http/principal-gate.js +10 -19
- package/dist/http/request-guards.d.ts +2 -2
- package/dist/http/request-guards.js +5 -5
- package/dist/http/resume-legs.d.ts +29 -10
- package/dist/http/resume-legs.js +94 -56
- package/dist/http/rewind-files-reply.d.ts +34 -0
- package/dist/http/rewind-files-reply.js +36 -0
- package/dist/http/route-ctx.d.ts +43 -26
- package/dist/http/route-table.js +4 -0
- package/dist/http/routes/adoption.d.ts +11 -0
- package/dist/http/routes/adoption.js +80 -6
- package/dist/http/routes/agents-roster.js +1 -0
- package/dist/http/routes/approvals-assistant.js +7 -26
- package/dist/http/routes/background.js +1 -0
- package/dist/http/routes/capabilities.js +12 -3
- package/dist/http/routes/devices.js +1 -1
- package/dist/http/routes/diagnostics.d.ts +9 -14
- package/dist/http/routes/diagnostics.js +10 -20
- package/dist/http/routes/engine.d.ts +31 -0
- package/dist/http/routes/engine.js +81 -0
- package/dist/http/routes/memory-bundle.js +3 -0
- package/dist/http/routes/memory-consolidation.js +3 -5
- package/dist/http/routes/memory-origin.d.ts +2 -2
- package/dist/http/routes/memory-origin.js +2 -4
- package/dist/http/routes/memory-policy.js +5 -1
- package/dist/http/routes/notify-wake.js +2 -1
- package/dist/http/routes/observability.js +3 -6
- package/dist/http/routes/projects.d.ts +70 -0
- package/dist/http/routes/projects.js +86 -0
- package/dist/http/routes/rules.js +30 -2
- package/dist/http/routes/runs.js +15 -11
- package/dist/http/routes/session-sync.js +39 -35
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions.d.ts +7 -1
- package/dist/http/routes/sessions.js +108 -2
- package/dist/http/routes/tasks.js +32 -8
- package/dist/http/routes/trace-usage.js +1 -1
- package/dist/http/run-concurrency-cap.d.ts +86 -0
- package/dist/http/run-concurrency-cap.js +54 -0
- package/dist/http/server.d.ts +31 -14
- package/dist/http/server.js +29 -3
- package/dist/http/stored-body-replay.d.ts +12 -7
- package/dist/http/stored-body-replay.js +28 -5
- package/dist/http/wire-types.d.ts +27 -13
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/instruction-source-notice.d.ts +1 -1
- package/dist/json-body-limit.d.ts +8 -0
- package/dist/json-body-limit.js +2 -0
- package/dist/leader/diffout.d.ts +1 -1
- package/dist/local-data-root.d.ts +2 -2
- package/dist/memory-embedder-reembed.d.ts +38 -0
- package/dist/memory-embedder-reembed.js +20 -0
- package/dist/memory-incident-sink.d.ts +0 -28
- package/dist/memory-incident-sink.js +5 -0
- package/dist/memory-operator-faces.d.ts +9 -4
- package/dist/memory-scope-stores.d.ts +9 -7
- package/dist/memory-scope-stores.js +3 -14
- package/dist/memory-scope.d.ts +38 -2
- package/dist/memory-scope.js +33 -2
- package/dist/memory-store-refusal.d.ts +17 -4
- package/dist/memory-store-refusal.js +1 -1
- package/dist/memory-sync-client.d.ts +2 -0
- package/dist/memory-sync-client.js +13 -11
- package/dist/memory-sync.js +1 -1
- package/dist/model-compat.d.ts +35 -21
- package/dist/model-compat.js +49 -21
- package/dist/model-entry-refusal.d.ts +11 -1
- package/dist/model-entry-refusal.js +7 -0
- package/dist/namespaced-rule-name.d.ts +18 -1
- package/dist/namespaced-rule-name.js +12 -0
- package/dist/net-address.d.ts +53 -0
- package/dist/net-address.js +111 -0
- package/dist/observability/fail-open.d.ts +29 -17
- package/dist/observability/fail-open.js +29 -17
- package/dist/observability/metrics.d.ts +2 -0
- package/dist/observability/metrics.js +2 -0
- package/dist/observability/secret-env-scrub.d.ts +30 -4
- package/dist/observability/secret-env-scrub.js +15 -3
- package/dist/orchestration/workflow-agent-session-index.d.ts +7 -12
- package/dist/orchestration/workflow-agent-session-index.js +1 -6
- package/dist/orchestration/workflow-completion-inbox.d.ts +26 -6
- package/dist/orchestration/workflow-completion-inbox.js +63 -45
- package/dist/orchestration/workflow-notify-journal.js +2 -3
- package/dist/org-delivery-gate.js +1 -1
- package/dist/org-memory-admission.d.ts +5 -2
- package/dist/org-memory-admission.js +25 -10
- package/dist/parked-decide.d.ts +33 -26
- package/dist/parked-decide.js +36 -44
- package/dist/peer-directory.d.ts +6 -12
- package/dist/peer-directory.js +5 -1
- package/dist/plugins/approval-ask-store-file.d.ts +10 -2
- package/dist/plugins/approval-ask-store-file.js +37 -4
- package/dist/plugins/approval-ask-store-memory.d.ts +5 -3
- package/dist/plugins/approval-ask-store-memory.js +11 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +3 -0
- package/dist/plugins/approval-ask-store-sql.js +3 -1
- package/dist/plugins/blob-backend.d.ts +38 -195
- package/dist/plugins/blob-backend.js +33 -229
- package/dist/plugins/caching-session-store.d.ts +12 -5
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-index-columns.d.ts +1 -1
- package/dist/plugins/checkpoint-index-columns.js +3 -2
- package/dist/plugins/checkpoint-store-face.d.ts +426 -0
- package/dist/plugins/checkpoint-store-face.js +152 -0
- package/dist/plugins/device-store-sql.d.ts +2 -2
- package/dist/plugins/device-store-sql.js +5 -10
- package/dist/plugins/execution-lane-rename-m40.d.ts +20 -0
- package/dist/plugins/execution-lane-rename-m40.js +10 -0
- package/dist/plugins/execution-placement-sql.d.ts +63 -88
- package/dist/plugins/execution-placement-sql.js +94 -54
- package/dist/plugins/file-run-store.d.ts +26 -18
- package/dist/plugins/file-run-store.js +64 -75
- package/dist/plugins/fork-routing-session-store.d.ts +6 -2
- package/dist/plugins/fork-routing-session-store.js +2 -2
- package/dist/plugins/imported-layer-root-retirement.d.ts +22 -11
- package/dist/plugins/imported-layer-root-retirement.js +4 -8
- package/dist/plugins/inbox-payload-column.d.ts +14 -0
- package/dist/plugins/inbox-payload-column.js +13 -0
- package/dist/plugins/local-checkpoint-store.d.ts +7 -2
- package/dist/plugins/local-checkpoint-store.js +13 -8
- package/dist/plugins/local-data-dir-modes-m39.d.ts +48 -0
- package/dist/plugins/local-data-dir-modes-m39.js +182 -0
- package/dist/plugins/local-engine-high-water.d.ts +11 -0
- package/dist/plugins/local-engine-high-water.js +59 -0
- package/dist/plugins/local-session-store.d.ts +119 -30
- package/dist/plugins/local-session-store.js +156 -53
- package/dist/plugins/local-task-attachment-store.d.ts +2 -0
- package/dist/plugins/local-task-attachment-store.js +10 -11
- package/dist/plugins/memory-embedder-fingerprint.d.ts +33 -10
- package/dist/plugins/memory-embedder-fingerprint.js +52 -12
- package/dist/plugins/memory-embedder.d.ts +1 -1
- package/dist/plugins/memory-embedder.js +2 -2
- package/dist/plugins/memory-engine-pg.d.ts +30 -6
- package/dist/plugins/memory-engine-pg.js +96 -214
- package/dist/plugins/memory-engine-sql-apply.d.ts +130 -0
- package/dist/plugins/memory-engine-sql-apply.js +358 -0
- package/dist/plugins/memory-engine-tidb.d.ts +38 -9
- package/dist/plugins/memory-engine-tidb.js +99 -230
- package/dist/plugins/memory-key-guards.d.ts +1 -1
- package/dist/plugins/memory-origin-law.d.ts +3 -3
- package/dist/plugins/one-time-migrations.d.ts +169 -83
- package/dist/plugins/one-time-migrations.js +295 -235
- package/dist/plugins/owner-only-file-mode.d.ts +29 -0
- package/dist/plugins/owner-only-file-mode.js +141 -0
- package/dist/plugins/permission-rule-store-file.d.ts +17 -3
- package/dist/plugins/permission-rule-store-file.js +20 -1
- package/dist/plugins/pg-pool.d.ts +2 -1
- package/dist/plugins/pg-pool.js +12 -5
- package/dist/plugins/release-version.d.ts +20 -0
- package/dist/plugins/release-version.js +28 -0
- package/dist/plugins/remote-env-adb.d.ts +20 -4
- package/dist/plugins/remote-env-adb.js +39 -11
- package/dist/plugins/remote-env-e2b.d.ts +12 -3
- package/dist/plugins/remote-env-e2b.js +6 -4
- package/dist/plugins/remote-env-host.d.ts +9 -1
- package/dist/plugins/remote-env-host.js +6 -5
- package/dist/plugins/remote-env-k8s.d.ts +5 -2
- package/dist/plugins/remote-env-k8s.js +15 -4
- package/dist/plugins/remote-env-local-docker.d.ts +4 -1
- package/dist/plugins/remote-env-local-docker.js +3 -3
- package/dist/plugins/remote-env-ssh.d.ts +8 -2
- package/dist/plugins/remote-env-ssh.js +26 -24
- package/dist/plugins/remote-shell.d.ts +59 -30
- package/dist/plugins/remote-shell.js +175 -62
- package/dist/plugins/retention-declaration.d.ts +37 -0
- package/dist/plugins/retention-declaration.js +9 -0
- package/dist/plugins/retention-deployment.d.ts +126 -0
- package/dist/plugins/retention-deployment.js +88 -0
- package/dist/plugins/retention-lane-store-sql.d.ts +74 -4
- package/dist/plugins/retention-lane-store-sql.js +103 -1
- package/dist/plugins/retention-sql.d.ts +29 -0
- package/dist/plugins/retention-sql.js +8 -0
- package/dist/plugins/run-store-sql.js +2 -2
- package/dist/plugins/schema-consistency.d.ts +0 -6
- package/dist/plugins/schema-consistency.js +1 -2
- package/dist/plugins/schema-ensure-legs.d.ts +1 -1
- package/dist/plugins/schema-ensure-legs.js +13 -3
- package/dist/plugins/session-ext-table.d.ts +74 -0
- package/dist/plugins/session-ext-table.js +121 -0
- package/dist/plugins/session-fork.d.ts +31 -9
- package/dist/plugins/session-fork.js +3 -2
- package/dist/plugins/session-placement.d.ts +4 -2
- package/dist/plugins/session-row-sql.d.ts +8 -7
- package/dist/plugins/session-row-sql.js +15 -7
- package/dist/plugins/session-store-sql.d.ts +131 -0
- package/dist/plugins/session-store-sql.js +298 -0
- package/dist/plugins/session-workspace-cell.d.ts +2 -2
- package/dist/plugins/session-workspace-cell.js +2 -2
- package/dist/plugins/shared-memory-store-sql.d.ts +10 -0
- package/dist/plugins/shared-memory-store-sql.js +13 -13
- package/dist/plugins/snapshot-bucket-presence.js +1 -1
- package/dist/plugins/sql-driver.d.ts +23 -7
- package/dist/plugins/sql-driver.js +41 -8
- package/dist/plugins/sql-errors.d.ts +5 -2
- package/dist/plugins/sql-errors.js +4 -0
- package/dist/plugins/sql-json-column.d.ts +5 -1
- package/dist/plugins/store-backend.d.ts +46 -16
- package/dist/plugins/store-backend.js +192 -69
- package/dist/plugins/store-contracts.d.ts +10 -13
- package/dist/plugins/store-contracts.js +1 -9
- package/dist/plugins/store-sweep.d.ts +63 -0
- package/dist/plugins/store-sweep.js +48 -0
- package/dist/plugins/task-attachment-store.d.ts +6 -8
- package/dist/plugins/task-attachment-store.js +15 -10
- package/dist/plugins/task-list-store-sql.d.ts +1 -1
- package/dist/plugins/text-column-capacity.d.ts +21 -0
- package/dist/plugins/text-column-capacity.js +5 -0
- package/dist/plugins/tidb-pool.d.ts +3 -2
- package/dist/plugins/tidb-pool.js +20 -32
- package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
- package/dist/prompt-screen.d.ts +6 -9
- package/dist/prompt-screen.js +2 -5
- package/dist/read-face-posture.d.ts +6 -6
- package/dist/read-face-posture.js +2 -2
- package/dist/request-value-closure.d.ts +5 -5
- package/dist/request-value-closure.js +1 -1
- package/dist/rules-consent.d.ts +48 -27
- package/dist/rules-consent.js +147 -23
- package/dist/run-cancel-context.d.ts +4 -1
- package/dist/run-cancel-context.js +2 -1
- package/dist/run-local.js +17 -13
- package/dist/runs.d.ts +48 -30
- package/dist/runs.js +27 -17
- package/dist/runtime-caps-resolver.d.ts +15 -8
- package/dist/runtime-caps-resolver.js +14 -10
- package/dist/sandbox-egress-policy.js +6 -11
- package/dist/sandbox-rbac-rules.d.ts +88 -0
- package/dist/sandbox-rbac-rules.js +80 -0
- package/dist/sealed-key-layout.d.ts +16 -0
- package/dist/sealed-key-layout.js +3 -0
- package/dist/sealed-key.js +8 -6
- package/dist/security.d.ts +43 -9
- package/dist/security.js +9 -2
- package/dist/sema-config-dir.js +2 -2
- package/dist/server-secret-env.d.ts +2 -0
- package/dist/service-version.d.ts +2 -1
- package/dist/service-version.js +2 -2
- package/dist/session-error-wire.d.ts +1 -1
- package/dist/session-incarnation.d.ts +8 -5
- package/dist/session-notify-door.d.ts +5 -3
- package/dist/session-resident-background.d.ts +110 -0
- package/dist/session-resident-background.js +88 -0
- package/dist/session-row.d.ts +1 -1
- package/dist/session-sync-kernel.d.ts +53 -14
- package/dist/session-sync-kernel.js +70 -1
- package/dist/session-sync.d.ts +5 -3
- package/dist/session-workspace.d.ts +12 -2
- package/dist/session-workspace.js +6 -0
- package/dist/sighup-idle.d.ts +9 -7
- package/dist/sighup-idle.js +4 -5
- package/dist/spec-fields.d.ts +16 -0
- package/dist/spec-fields.js +7 -0
- package/dist/store-posture.d.ts +2 -1
- package/dist/stored-request-env-credentials-m38.d.ts +3 -0
- package/dist/stored-request-env-credentials-m38.js +8 -0
- package/dist/stored-request-hooks-m20.d.ts +3 -2
- package/dist/stored-request-hooks-m20.js +19 -14
- package/dist/stored-request-prompt-profile-m30.d.ts +1 -1
- package/dist/stores-sql/blob-index-sql.d.ts +148 -0
- package/dist/stores-sql/blob-index-sql.js +154 -0
- package/dist/{plugins → stores-sql}/checkpoint-store-sql.d.ts +14 -428
- package/dist/{plugins → stores-sql}/checkpoint-store-sql.js +43 -220
- package/dist/{plugins → stores-sql}/file-history-store-sql.d.ts +23 -11
- package/dist/{plugins → stores-sql}/file-history-store-sql.js +23 -18
- package/dist/{plugins → stores-sql}/mailbox-store-sql.d.ts +2 -2
- package/dist/{plugins → stores-sql}/mailbox-store-sql.js +4 -4
- package/dist/{plugins → stores-sql}/pg-session-storage.d.ts +27 -67
- package/dist/{plugins → stores-sql}/pg-session-storage.js +82 -207
- package/dist/{plugins → stores-sql}/retention-store-sql.d.ts +123 -217
- package/dist/{plugins → stores-sql}/retention-store-sql.js +66 -190
- package/dist/{plugins → stores-sql}/roster-store-sql.d.ts +2 -2
- package/dist/{plugins → stores-sql}/roster-store-sql.js +1 -1
- package/dist/{plugins → stores-sql}/session-event-payload.d.ts +1 -1
- package/dist/{plugins → stores-sql}/session-event-payload.js +1 -1
- package/dist/stores-sql/session-policy-store-sql.d.ts +1 -1
- package/dist/stores-sql/session-write-hooks.d.ts +59 -0
- package/dist/stores-sql/session-write-hooks.js +2 -0
- package/dist/{plugins → stores-sql}/tidb-session-storage.d.ts +10 -11
- package/dist/{plugins → stores-sql}/tidb-session-storage.js +10 -21
- package/dist/{plugins → stores-sql}/tidb-session-store.d.ts +35 -112
- package/dist/{plugins → stores-sql}/tidb-session-store.js +73 -169
- package/dist/{plugins → stores-sql}/tool-result-store-sql.d.ts +3 -3
- package/dist/{plugins → stores-sql}/tool-result-store-sql.js +6 -6
- package/dist/stores-sql/windowed-session-storage.d.ts +56 -0
- package/dist/stores-sql/windowed-session-storage.js +61 -0
- package/dist/{plugins → stores-sql}/workflow-journal-store-sql.d.ts +7 -12
- package/dist/{plugins → stores-sql}/workflow-journal-store-sql.js +3 -8
- package/dist/task-a2a.d.ts +7 -1
- package/dist/task-a2a.js +15 -14
- package/dist/task-cwd.d.ts +11 -3
- package/dist/task-cwd.js +17 -1
- package/dist/task-mcp.d.ts +10 -2
- package/dist/task-mcp.js +13 -16
- package/dist/task-settings.d.ts +68 -8
- package/dist/task-settings.js +63 -6
- package/dist/tool-approval.d.ts +23 -10
- package/dist/tool-approval.js +10 -6
- package/dist/trace/core-keyset-guard.d.ts +17 -10
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +4 -0
- package/dist/trace/exit-seat.d.ts +29 -1
- package/dist/trace/exit-seat.js +4 -0
- package/dist/trace/project.d.ts +33 -16
- package/dist/trace/project.js +21 -9
- package/dist/trace/redact.d.ts +13 -2
- package/dist/trace/redact.js +347 -78
- package/dist/trace/self-minted-wire.d.ts +587 -16
- package/dist/trace/self-minted-wire.js +215 -9
- package/dist/trace/sema-provenance.d.ts +45 -41
- package/dist/trace/sema-provenance.js +81 -10
- package/dist/trace/task-notification-facets.d.ts +70 -2
- package/dist/trace/task-notification-facets.js +71 -1
- package/dist/trace/wire-projection-faces.d.ts +39 -3
- package/dist/trace/wire-projection-faces.js +27 -2
- package/dist/unread-request-members.d.ts +66 -0
- package/dist/unread-request-members.js +41 -0
- package/dist/usage-analytics.d.ts +4 -0
- package/dist/user-input-ledger.d.ts +2 -2
- package/dist/web-admin-client/apply-effective.js +22 -26
- package/dist/web-admin-client/candidate-gate.d.ts +35 -3
- package/dist/web-admin-client/candidate-gate.js +53 -5
- package/dist/web-admin-client/center-request.d.ts +4 -1
- package/dist/web-admin-client/center-request.js +2 -1
- package/dist/web-admin-client/effective-keys.js +0 -1
- package/dist/web-admin-client/facade.d.ts +1 -1
- package/dist/web-admin-client/http-client.d.ts +1 -0
- package/dist/web-admin-client/http-client.js +17 -9
- package/dist/web-admin-client/restart-signal.js +5 -2
- package/dist/web-admin-client/skills-mcp.d.ts +20 -6
- package/dist/web-admin-client/skills-mcp.js +26 -21
- package/dist/web-admin-client/types.d.ts +34 -49
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +2 -2
- package/package.json +22 -13
- package/scripts/drain-check-local.mjs +8 -55
- package/scripts/drain-check.mysql.sql +3 -40
- package/scripts/drain-check.pg.sql +3 -40
- package/skills/update-config.md +1 -1
- package/wire-changes/server@7.146.0.json +3221 -0
- package/wire-changes/server@7.147.0.json +813 -0
- package/dist/approval-batch-census.d.ts +0 -27
- package/dist/approval-batch-census.js +0 -27
|
@@ -2,7 +2,9 @@ import { type LaneHomeDeployment } from "../execution-lane-caps.js";
|
|
|
2
2
|
import { type MemoryScopeStores } from "../memory-scope-stores.js";
|
|
3
3
|
import type { RestartSliceCtx } from "../web-admin-client/restart-signal.js";
|
|
4
4
|
import type { MemoryConsolidationDriverConfig, ServiceConfig } from "../config-types.js";
|
|
5
|
-
import { resolveMemoryConsolidationDriver, type ConsolidationWriteJudge, type ConsolidationWriteJudgeInput, type EngineNotice, type ConsolidationDriverRunRow, type ConsolidationRunReceipt, type MemoryConsolidationDriverDeps, type PermissionRuleStoreProvider } from "@sema-agent/core";
|
|
5
|
+
import { resolveMemoryConsolidationDriver, type ConsolidationWriteJudge, type ConsolidationWriteJudgeInput, type EngineNotice, type ConsolidationDriverRunRow, type ConsolidationRunReceipt, type MemoryBackend, type MemoryConsolidationDriverDeps, type MemoryGovernanceDurability, type PermissionRuleStoreProvider, type CompliancePosture, type RunMemoryConsolidationOptions } from "@sema-agent/core";
|
|
6
|
+
/** 合规档位座的型 = 驱动动词 `compliance.postureOf` 收的那一只(core 的座型不在包根导出面上;取动词选项的成员型,形的属主仍是 core)。 */
|
|
7
|
+
type CompliancePostureSeat = NonNullable<NonNullable<RunMemoryConsolidationOptions["compliance"]>["postureOf"]>;
|
|
6
8
|
/**
|
|
7
9
|
* 座解析的 options 形 = core 解析器交回的那只(core 7.50.0 起它**不含** `writeJudge`:判官不是模型席的一部分,由调用方在动词上带)。
|
|
8
10
|
* 取解析器的返回型而不是自己写 `Omit<…>`:形的属主是 core 的解析器,本仓不持第二份。
|
|
@@ -11,7 +13,7 @@ type ConsolidationSeatOptions = ReturnType<typeof resolveMemoryConsolidationDriv
|
|
|
11
13
|
/** D3 投影的座标签闭集。`role:<name>` 里的 name 只可能是 core 的 role 链两跳之一。 */
|
|
12
14
|
export type ConsolidationSeatLabel = "explicit" | "role:consolidate" | "role:summarize";
|
|
13
15
|
/** {@link buildConsolidationValveAudit} 的告警名闭集(事件名进日志 ⇒ 运维可按名过滤/告警)。 */
|
|
14
|
-
export type ConsolidationValveWarningTag = "
|
|
16
|
+
export type ConsolidationValveWarningTag = "memory_consolidation_run_credential_gated";
|
|
15
17
|
/** {@link resolveConsolidationValve} 的起服提示名闭集([ref] / [ref];事件名进日志 ⇒ 运维可按名过滤/告警)。 */
|
|
16
18
|
export type ConsolidationValveNoticeTag = "memory_consolidation_default_off_no_cheap_model" | "memory_consolidation_on_main_model";
|
|
17
19
|
/**
|
|
@@ -141,11 +143,12 @@ export declare function createPerScopeSingleFlight<T>(): (scope: string, run: ()
|
|
|
141
143
|
*
|
|
142
144
|
* ① **记忆引擎没接线**(`MEMORY_ENGINE=off`,或多租户形——本仓的记忆引擎只在单用户部署上装配):
|
|
143
145
|
* 没有引擎就没有库可折叠,阀门是一句空话;
|
|
144
|
-
* ②
|
|
145
|
-
*
|
|
146
|
-
* (`deriveControlPlaneDir`),而本仓是 stateless replicas ⇒ 一轮分钟级 run 的续跑账会落在某个随机
|
|
147
|
-
* pod 的盘上,pod 重建即失,而 run 是**可续跑**设计的(重跑=整库重新 mint,真金白银)
|
|
148
|
-
*
|
|
146
|
+
* ② **整理状态不随后端走**(引擎对这只后端的答案 `memoryGovernanceDurability` = `"replica-local"`):driver 的 run 账
|
|
147
|
+
* (`distiller-runs.json`)、mint 归档与引擎的 consolidation gate 住在引擎的控制面上;后端不发布控制面时 core 会把它
|
|
148
|
+
* **回落到本进程的本地盘**(`deriveControlPlaneDir`),而本仓是 stateless replicas ⇒ 一轮分钟级 run 的续跑账会落在某个随机
|
|
149
|
+
* pod 的盘上,pod 重建即失,而 run 是**可续跑**设计的(重跑=整库重新 mint,真金白银)。判据**只问引擎的这一个答案**
|
|
150
|
+
* (「整理能不能开」就是它回答的那一问;不自读后端的面、不看后端方言名);部署面(合规 / 外源 / 状态 / 部署对象)问的是
|
|
151
|
+
* 另一件事 —— 后端发不发布控制面 —— 读 `backendOwnsControlPlane`,不读这里;
|
|
149
152
|
* ③ **`MEMORY_PROVENANCE=off`**:core 的 `screenConsolidationOptions` 明写 consolidation 不能在
|
|
150
153
|
* `provenance:"off"` 下开(fold law 必须铸得出 origin 标记,否则一个被标记过的输入折出来的产物会
|
|
151
154
|
* **不带标记**地提交)。这一条本来就会在引擎构造期抛,提前判只为一件事:把**两根**旋钮的名字同时
|
|
@@ -164,15 +167,20 @@ export declare function assertConsolidationDriverWirable(input: ConsolidationWir
|
|
|
164
167
|
export interface ConsolidationWiringFacts {
|
|
165
168
|
/** 本部署接了记忆引擎吗(`boot/stores.ts` 的 `memoryEngine !== undefined`)。 */
|
|
166
169
|
readonly memoryEngineWired: boolean;
|
|
167
|
-
/**
|
|
168
|
-
|
|
170
|
+
/** 整理读写的状态随不随后端走:引擎对这只后端的答案(`memoryGovernanceDurability`,`"backend"` / `"replica-local"`)。
|
|
171
|
+
* 引擎契约逐字「a host that arms or reports consolidation asks here, never of a backend member it probes itself」——
|
|
172
|
+
* 阀门就是「整理能不能开」这一问,所以只问引擎、不自己读后端的面;部署面(合规 / 外源 / 状态 / 部署对象)问的是另一件事
|
|
173
|
+
* (后端发不发布控制面,`backendOwnsControlPlane`),不问这里。记忆引擎没接 ⇒ `"replica-local"`(判官先答 `no-memory-engine`)。 */
|
|
174
|
+
readonly governanceDurability: MemoryGovernanceDurability;
|
|
169
175
|
/** 只进文案 —— 让「该去拧哪根旋钮」这句话指向该腿上**真的**有效的那一根。 */
|
|
170
176
|
readonly memoryEngineBackend: ServiceConfig["memoryEngineBackend"];
|
|
171
177
|
/** 部署声明的 provenance 姿态(`config.memoryProvenance`;缺席 ≡ core 缺省 `carry`)。 */
|
|
172
178
|
readonly provenance?: "off" | "carry";
|
|
179
|
+
/** 部署的合规档位(`config.compliancePosture`;缺席 = 无档位)。否决集只经引擎的 `resolveComplianceDenies` 求(与装配三座席同一只)。 */
|
|
180
|
+
readonly compliancePosture?: CompliancePosture;
|
|
173
181
|
}
|
|
174
|
-
/**
|
|
175
|
-
export type ConsolidationUnwirable = "no-memory-engine" | "
|
|
182
|
+
/** 「阀门若开,这台部署结构上跑不起来」的四种成因(闭集;加一种 = 下面两只穷举 switch 编译红)。`"replica-local"` 是引擎 `MemoryGovernanceDurability` 的那个词,逐字。 */
|
|
183
|
+
export type ConsolidationUnwirable = "no-memory-engine" | "replica-local" | "provenance-off" | "compliance-denied";
|
|
176
184
|
/**
|
|
177
185
|
* 「阀门若开,这台部署结构上跑不跑得起来」的**判官**(三臂逐条理由见 {@link assertConsolidationDriverWirable} 头注)。
|
|
178
186
|
* 返回成因词;`undefined` = 跑得起来。两处读它:显式 on 的拒启(句子 = {@link unwirableRefusal}),以及出厂缺省派生
|
|
@@ -209,8 +217,8 @@ export declare function consolidationSeatBillingOf(plane: ConsolidationSeatPlane
|
|
|
209
217
|
* (结构上跑不起来由下游 D1 三条拒启臂照拒,本判决不吞);开而座落主模型 ⇒ 开 + 一行
|
|
210
218
|
* `memory_consolidation_on_main_model`(部署方显式承担,但必须知道账按主模型记)。
|
|
211
219
|
* · **未设 = 出厂缺省派生**([ref] 取代 [ref] ① 的「出厂 off」实况):
|
|
212
|
-
* 结构上跑不起来(判官 {@link consolidationDriverUnwirable}
|
|
213
|
-
*
|
|
220
|
+
* 结构上跑不起来(判官 {@link consolidationDriverUnwirable} 有成因 —— 成因表只有 {@link ConsolidationUnwirable} 这一份;
|
|
221
|
+
* 配置目录说明与 USAGE 各列的同一串各有一条钉对着它)⇒ **恒关、零提示、零探针** —— 派生开撞上 D1 拒启臂 = 每台配了便宜模型的
|
|
214
222
|
* 多租户 worker 升级即起不来;而配不配便宜模型它都开不了,一句指向 `MODEL_CHEAP_ID` 的提示是误导;
|
|
215
223
|
* 座不落主模型({@link consolidationSeatBillingOf} = `own-model`)⇒ **开**;
|
|
216
224
|
* 否则(落主模型 / 解不出)⇒ **关** + 一行 `memory_consolidation_default_off_no_cheap_model`(点名 `MODEL_CHEAP_ID`,
|
|
@@ -271,10 +279,10 @@ export declare function createConsolidationValve(input: ConsolidationValveInput
|
|
|
271
279
|
};
|
|
272
280
|
/** 阀门判决的两件输入(装配点与纯判共用一只形 —— 两个入口递的是同一组事实)。 */
|
|
273
281
|
export interface ConsolidationValveInput {
|
|
274
|
-
readonly config: Pick<ServiceConfig, "memoryConsolidationDriver" | "memoryEngineBackend" | "memoryProvenance" | "models" | "tiers" | "roles">;
|
|
275
|
-
/** 只读两件:在不在(记忆引擎接没接线)
|
|
282
|
+
readonly config: Pick<ServiceConfig, "memoryConsolidationDriver" | "memoryEngineBackend" | "memoryProvenance" | "compliancePosture" | "models" | "tiers" | "roles">;
|
|
283
|
+
/** 只读两件:在不在(记忆引擎接没接线)、整理状态随不随后端走(引擎的 `memoryGovernanceDurability` 答)。 */
|
|
276
284
|
readonly memoryEngine: {
|
|
277
|
-
readonly backend:
|
|
285
|
+
readonly backend: MemoryBackend;
|
|
278
286
|
} | undefined;
|
|
279
287
|
}
|
|
280
288
|
/**
|
|
@@ -293,38 +301,27 @@ export declare function judgeConsolidationValve(input: ConsolidationValveInput):
|
|
|
293
301
|
unwirable: Parameters<typeof resolveConsolidationValve>[0]["unwirable"];
|
|
294
302
|
};
|
|
295
303
|
/**
|
|
296
|
-
*
|
|
304
|
+
* 阀门上了场之后的**可达性**告警(自查 + codex 交叉复审;姿态=warn 不拒启)。
|
|
297
305
|
*
|
|
298
|
-
* ##
|
|
306
|
+
* ## 「没有运维」那一条为什么不在这里了
|
|
299
307
|
*
|
|
300
|
-
*
|
|
301
|
-
* (
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* ## 为什么是 warn 而不是拒启(与 D1 的三条拒启臂**刻意不同档**)
|
|
307
|
-
*
|
|
308
|
-
* `OPERATOR_PRINCIPALS` 是**跨面共用**的部署级旋钮(adoption / retention-ops / memory-bundle /
|
|
309
|
-
* memory-compliance / admin-drain 全在同一张名单上)。为一条阀门拒掉整台机器,比这条阀门本身的价值重;
|
|
310
|
-
* 而那三条拒启臂拒的是「这台机器**结构上**跑不了这件事」(没有库 / 账会丢 / 折叠法铸不出标记),
|
|
311
|
-
* 本条拒的是「配齐了但没人够得着」——后者是一次**配置遗漏**,补一行 env 即可,不该要一次重启失败来教。
|
|
312
|
-
* 同族先例逐字:`permission_rules_lane_unavailable`(旋钮开着却上不了场 ⇒ 打一行,不拒启)。
|
|
313
|
-
* 反过来说,**沉默**同样不行:那正是「设了但没生效」病族,而这一形连能力位都是诚实的假,唯一缺的
|
|
314
|
-
* 就是一句把因果说清楚的话。
|
|
308
|
+
* 曾经还有一条「阀门够不着」告警(事件名已删,不再出现在日志里):阀门开着、两口挂着,而这台部署没有运维名册 ⇒ 两口对谁都 501。
|
|
309
|
+
* 它的在场条件今天在服务腿上不可达,前提链三环:① 显式开得起来的阀门要 file 记忆后端(SQL 两只孪生不发布控制面 ⇒ 第 4 段的
|
|
310
|
+
* {@link assertConsolidationDriverWirable} 拒启),而 file 记忆引擎只在单用户形上装配(`fileMemoryPlaneFor`);② 单用户形过了起服第 1 段就一定有运维
|
|
311
|
+
* (不变量 `operator-declaration-required`:`OPERATOR_SINGLE_USER=true` 或具名名单,都没有 ⇒ 第 1 段早拒;装运维面的兜底座 `createHttpServer` 同判);
|
|
312
|
+
* ③ 本函数的唯一调用点在服务腿第 6 段。读一个不可能状态的告警是死臂,随那条不变量一起退役(钉:`test/operator-declaration-required.test.ts` ⑥,
|
|
313
|
+
* 前提链每环一格,任何一环将来不成立 ⇒ 那一格红)。
|
|
315
314
|
*
|
|
316
315
|
* ## 只审**显式**开的阀门([ref] / [ref] 起)
|
|
317
316
|
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
317
|
+
* 告警的前提是「运维**显式**拧了 on」——它是一次**表态**够不着的诊断。出厂缺省**派生**开的那台(配了便宜模型的单用户部署)
|
|
318
|
+
* 没有表态可审:引擎面的自动整理照跑(不走手动口),手动口是一件它没要过的东西。照审的后果是每一台这样的部署升级后每次起服
|
|
319
|
+
* 多一行 warn,点名一根它从没设过的 `MEMORY_CONSOLIDATION_DRIVER=on`,教它去配一个它不需要的操作面。判据读阀门判决的 `source`,
|
|
320
|
+
* 不读表态原词(判决是阀门开关的唯一属主)。
|
|
322
321
|
*/
|
|
323
322
|
export declare function buildConsolidationValveAudit(input: {
|
|
324
323
|
/** 阀门判决({@link resolveConsolidationValve} 的 `enabled` + `source`)。 */
|
|
325
324
|
valve: Pick<ConsolidationValve, "enabled" | "source">;
|
|
326
|
-
/** 这台部署有没有运维名册(`operatorRosterPresent`:名单非空 ∨ 单用户声明)—— 判据不在本函数里另写一份。 */
|
|
327
|
-
operatorRosterPresent: boolean;
|
|
328
325
|
/** 这台部署配了任何一把 service 凭证吗(`config.authToken` 或 `config.authTokens` 非空)。 */
|
|
329
326
|
hasServiceAuth: boolean;
|
|
330
327
|
/** 本地开发的显式逃生口(`ALLOW_UNAUTHED_WRITES=true`)。 */
|
|
@@ -459,8 +456,8 @@ export interface MemoryConsolidationFaces {
|
|
|
459
456
|
/** 跑(或**续跑**)一轮。core 的 run 行是持久的:同一 scope 上有 pending run 时本调用 CONTINUE 它
|
|
460
457
|
* (同一 plan 缓存、同一 force requestId、零新 mint)—— 所以这一口对**重试安全**。 */
|
|
461
458
|
run(scope: string): Promise<ConsolidationRunReceipt>;
|
|
462
|
-
/** 该 scope 最近一次 driver run 的账(`undefined` = 从没跑过 —— 诚实缺席,不编一个空壳)。 */
|
|
463
|
-
lastRun(scope: string): ConsolidationDriverRunRow | undefined
|
|
459
|
+
/** 该 scope 最近一次 driver run 的账(`undefined` = 从没跑过 —— 诚实缺席,不编一个空壳)。core 7.63.0([ref])起经引擎的治理店座读、异步。 */
|
|
460
|
+
lastRun(scope: string): Promise<ConsolidationDriverRunRow | undefined>;
|
|
464
461
|
}
|
|
465
462
|
/**
|
|
466
463
|
* 在**记忆作用域店**上建 consolidation 操作面。命名照 CLAUDE.md 工厂律:返回带行为的活对象 ⇒ `create*`。
|
|
@@ -506,6 +503,10 @@ export declare function createMemoryConsolidationFaces(stores: MemoryScopeStores
|
|
|
506
503
|
* 应用时拒 = 引擎在驱动里铸的 `memory.consolidation_incomplete`;早问拒 = 驱动抛出的拒绝经引擎导出的投递口(`deliverWriteRefusal`)转成的
|
|
507
504
|
* `memory.consolidation_refused`(本仓不读通告名、不自铸通告形)。 */
|
|
508
505
|
onNotice?: (notice: EngineNotice) => void;
|
|
506
|
+
/** core 7.63.0([ref]):部署的合规档位座(装配层给 `RunnerDeps.compliancePostureResolver` 那**同一只**;`undefined` = 部署没有档位)。
|
|
507
|
+
* 必填键 —— 缺席不能被读成「没有档位」:驱动动词每一轮先拿它问**层属主**的档位(契约 = {@link memoryScopeContractOf}`([scope])`,
|
|
508
|
+
* 与会话铸 spec 同一只),否决 ⇒ 在写判官、任何读、任何模型调用之前拒 `config.compliance_denied`;自动整理腿读同一只座。 */
|
|
509
|
+
postureOf: CompliancePostureSeat | undefined;
|
|
509
510
|
}): MemoryConsolidationFaces;
|
|
510
511
|
export {};
|
|
511
512
|
//# sourceMappingURL=memory-consolidation.d.ts.map
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { redactSecrets } from "../trace/redact.js";
|
|
2
2
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
3
|
-
import {
|
|
4
|
-
import { memoryMountRootOf } from "../memory-scope.js";
|
|
3
|
+
import { memoryMountRootOf, memoryScopeContractOf } from "../memory-scope.js";
|
|
5
4
|
import { executionLaneHomeDir } from "../execution-lane-caps.js";
|
|
6
5
|
import { DEFAULT_MODEL_REF, resolveMainModel } from "../model-select.js";
|
|
7
6
|
import { captureRecordStoreOf } from "../memory-operator-faces.js";
|
|
8
|
-
import {
|
|
9
|
-
import { createConsolidationWriteJudge, deliverWriteRefusal, expandTiers, MemoryEngine, modelOriginOf,
|
|
7
|
+
import { memoryStoreForRequest } from "../memory-scope-stores.js";
|
|
8
|
+
import { createConsolidationWriteJudge, deliverWriteRefusal, expandTiers, MemoryEngine, memoryGovernanceDurability, modelOriginOf, resolveComplianceDenies, resolveMemoryConsolidationDriver, runMemoryConsolidationDriver, } from "@sema-agent/core";
|
|
10
9
|
import { seatText } from "../trace/exit-seat.js";
|
|
11
10
|
export function resolveConsolidationDriverSeat(deps) {
|
|
12
11
|
let options;
|
|
@@ -97,10 +96,12 @@ export function assertConsolidationDriverWirable(input) {
|
|
|
97
96
|
export function consolidationDriverUnwirable(input) {
|
|
98
97
|
if (!input.memoryEngineWired)
|
|
99
98
|
return "no-memory-engine";
|
|
100
|
-
if (
|
|
101
|
-
return
|
|
99
|
+
if (input.governanceDurability !== "backend")
|
|
100
|
+
return input.governanceDurability;
|
|
102
101
|
if (input.provenance === "off")
|
|
103
102
|
return "provenance-off";
|
|
103
|
+
if (input.compliancePosture !== undefined && resolveComplianceDenies(input.compliancePosture).has("memory_consolidation"))
|
|
104
|
+
return "compliance-denied";
|
|
104
105
|
return undefined;
|
|
105
106
|
}
|
|
106
107
|
function unwirableRefusal(code, facts) {
|
|
@@ -110,18 +111,23 @@ function unwirableRefusal(code, facts) {
|
|
|
110
111
|
`— there is no library to fold, and the two admin endpoints would answer over an engine that does not exist. ` +
|
|
111
112
|
`(The engine is wired only on single-user deployments with MEMORY_ENGINE on; a multi-tenant worker keeps memory ` +
|
|
112
113
|
`dark by design.) Wire the memory engine, or set MEMORY_CONSOLIDATION_DRIVER=off.`);
|
|
113
|
-
case "
|
|
114
|
-
return (`MEMORY_CONSOLIDATION_DRIVER=on arms the memory-consolidation valve, but the
|
|
115
|
-
`(MEMORY_ENGINE_BACKEND=${facts.memoryEngineBackend})
|
|
116
|
-
`
|
|
117
|
-
`
|
|
118
|
-
`
|
|
114
|
+
case "replica-local":
|
|
115
|
+
return (`MEMORY_CONSOLIDATION_DRIVER=on arms the memory-consolidation valve, but the memory engine answers "replica-local" for the ` +
|
|
116
|
+
`wired memory backend (MEMORY_ENGINE_BACKEND=${facts.memoryEngineBackend}) — a consolidation run's state would live on THIS ` +
|
|
117
|
+
`replica's local disk instead of riding the backend, and its resumable account would die with the pod (a lost run ` +
|
|
118
|
+
`re-mints the whole library at full model cost on the next attempt). The file memory backend keeps that state with the ` +
|
|
119
|
+
`backend (the engine answers "backend"); the pg/mysql memory backends do not. Set MEMORY_ENGINE_BACKEND=file, or set ` +
|
|
119
120
|
`MEMORY_CONSOLIDATION_DRIVER=off.`);
|
|
120
121
|
case "provenance-off":
|
|
121
122
|
return (`MEMORY_CONSOLIDATION_DRIVER=on is incompatible with MEMORY_PROVENANCE=off — core refuses to enable consolidation ` +
|
|
122
123
|
`under provenance "off" because the fold law must be able to MINT origin markers (a marked input's product would ` +
|
|
123
124
|
`otherwise commit unmarked, i.e. the fold would launder provenance). Set MEMORY_PROVENANCE=carry (or unset it, ` +
|
|
124
125
|
`which is the same posture), or set MEMORY_CONSOLIDATION_DRIVER=off.`);
|
|
126
|
+
case "compliance-denied":
|
|
127
|
+
return (`MEMORY_CONSOLIDATION_DRIVER=on arms the memory-consolidation valve, but this deployment's compliance posture ` +
|
|
128
|
+
`(COMPLIANCE_PROFILE=${facts.compliancePosture?.profile ?? "?"}, with COMPLIANCE_ADDITIONAL_DENIES) denies memory_consolidation — the engine ` +
|
|
129
|
+
`refuses every consolidation run before it reads, claims or calls a model (config.compliance_denied), on the admin endpoint and after ` +
|
|
130
|
+
`a settle alike. Set MEMORY_CONSOLIDATION_DRIVER=off, or run a posture that does not deny memory_consolidation.`);
|
|
125
131
|
default: {
|
|
126
132
|
const unreachable = code;
|
|
127
133
|
throw new Error(`unhandled consolidation unwirable code: ${String(unreachable)}`);
|
|
@@ -132,10 +138,12 @@ function unwirableClause(code, facts) {
|
|
|
132
138
|
switch (code) {
|
|
133
139
|
case "no-memory-engine":
|
|
134
140
|
return "no memory engine is wired here (multi-tenant posture, or MEMORY_ENGINE=off), so there is no library to fold";
|
|
135
|
-
case "
|
|
136
|
-
return `the memory backend (MEMORY_ENGINE_BACKEND=${facts.memoryEngineBackend})
|
|
141
|
+
case "replica-local":
|
|
142
|
+
return `the memory engine answers "replica-local" for the memory backend (MEMORY_ENGINE_BACKEND=${facts.memoryEngineBackend}), so a consolidation run's state would not outlive its replica and could not keep its account`;
|
|
137
143
|
case "provenance-off":
|
|
138
144
|
return "MEMORY_PROVENANCE=off, and consolidation needs provenance to mint origin markers";
|
|
145
|
+
case "compliance-denied":
|
|
146
|
+
return "the deployment's compliance posture (COMPLIANCE_PROFILE / COMPLIANCE_ADDITIONAL_DENIES) denies memory_consolidation, so the engine refuses every run";
|
|
139
147
|
default: {
|
|
140
148
|
const unreachable = code;
|
|
141
149
|
throw new Error(`unhandled consolidation unwirable code: ${String(unreachable)}`);
|
|
@@ -194,9 +202,10 @@ export function judgeConsolidationValve(input) {
|
|
|
194
202
|
const { config, memoryEngine } = input;
|
|
195
203
|
const wiring = {
|
|
196
204
|
memoryEngineWired: memoryEngine !== undefined,
|
|
197
|
-
|
|
205
|
+
governanceDurability: memoryEngine !== undefined ? memoryGovernanceDurability(memoryEngine.backend) : "replica-local",
|
|
198
206
|
memoryEngineBackend: config.memoryEngineBackend,
|
|
199
207
|
...(config.memoryProvenance !== undefined ? { provenance: config.memoryProvenance } : {}),
|
|
208
|
+
...(config.compliancePosture !== undefined ? { compliancePosture: config.compliancePosture } : {}),
|
|
200
209
|
};
|
|
201
210
|
const code = consolidationDriverUnwirable(wiring);
|
|
202
211
|
const unwirable = code !== undefined ? { code, facts: wiring } : undefined;
|
|
@@ -269,18 +278,6 @@ export function buildConsolidationValveAudit(input) {
|
|
|
269
278
|
if (!input.valve.enabled || input.valve.source !== "explicit")
|
|
270
279
|
return { warnings: [] };
|
|
271
280
|
const warnings = [];
|
|
272
|
-
if (!input.operatorRosterPresent) {
|
|
273
|
-
warnings.push({
|
|
274
|
-
tag: "memory_consolidation_valve_unreachable",
|
|
275
|
-
detail: "MEMORY_CONSOLIDATION_DRIVER=on armed the consolidation valve and both admin endpoints are mounted, but " +
|
|
276
|
-
"this worker has no operator: OPERATOR_PRINCIPALS is EMPTY and OPERATOR_SINGLE_USER is not set — an empty operator list means NO ONE " +
|
|
277
|
-
"is an operator (it deliberately does not mean 'everyone'), so POST /v1/admin/memory/consolidation/run and GET /v1/admin/memory/consolidation " +
|
|
278
|
-
"answer 501 capability.operator_principals_required to every caller and capabilities.memoryConsolidationDriver reports false. " +
|
|
279
|
-
`To fix: ${buildOperatorRosterWayOut()}. With OPERATOR_PRINCIPALS, callers must send a listed principal in the configured principal header; a single-user declaration needs no principal. ` +
|
|
280
|
-
"(Not a startup refusal: the operator roster is shared by every operator " +
|
|
281
|
-
"endpoint on this worker, so one valve must not decide whether the whole worker starts.)",
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
281
|
if (!input.hasServiceAuth && !input.allowUnauthedWrites) {
|
|
285
282
|
warnings.push({
|
|
286
283
|
tag: "memory_consolidation_run_credential_gated",
|
|
@@ -363,6 +360,7 @@ export function createMemoryConsolidationFaces(stores, input) {
|
|
|
363
360
|
const receipt = await runMemoryConsolidationDriver(engineOf(scope), scope, {
|
|
364
361
|
...input.seat.options,
|
|
365
362
|
writeJudge: input.writeJudge,
|
|
363
|
+
compliance: { ...(input.postureOf !== undefined ? { postureOf: input.postureOf } : {}), scopeContract: memoryScopeContractOf([scope]) },
|
|
366
364
|
...(input.onNotice !== undefined ? { onNotice: input.onNotice } : {}),
|
|
367
365
|
}).catch((err) => {
|
|
368
366
|
deliverWriteRefusal(err, scope, input.onNotice);
|
|
@@ -373,7 +371,7 @@ export function createMemoryConsolidationFaces(stores, input) {
|
|
|
373
371
|
}
|
|
374
372
|
return receipt;
|
|
375
373
|
}),
|
|
376
|
-
lastRun: (scope) =>
|
|
374
|
+
lastRun: (scope) => engineOf(scope).readConsolidationDriverRun(scope),
|
|
377
375
|
};
|
|
378
376
|
}
|
|
379
377
|
//# sourceMappingURL=memory-consolidation.js.map
|
package/dist/boot/org-memory.js
CHANGED
|
@@ -8,7 +8,7 @@ function collectDeploymentOrgScopes(config) {
|
|
|
8
8
|
scopes.add(config.memoryScope);
|
|
9
9
|
if (config.requirePrincipal !== true) {
|
|
10
10
|
for (const project of Object.values(config.projects)) {
|
|
11
|
-
for (const s of project.defaultScopes
|
|
11
|
+
for (const s of project.defaultScopes)
|
|
12
12
|
if (s.startsWith(ORG_PREFIX))
|
|
13
13
|
scopes.add(s);
|
|
14
14
|
}
|
|
@@ -31,6 +31,7 @@ export function createOrgMemoryAdmissionWiring(opts) {
|
|
|
31
31
|
fetchSection: (principal) => fetchPrincipalOrgMemory({ baseUrl: centerLeg.baseUrl, credential }, principal, fetch, centerLeg.worker),
|
|
32
32
|
grantTtlMs: config.memoryOrgGrantTtlMs,
|
|
33
33
|
unavailableBackoffMs: config.memoryOrgUnavailableBackoffMs,
|
|
34
|
+
logger,
|
|
34
35
|
})).now;
|
|
35
36
|
return { lookup: (principal) => directoryNow().lookup(principal) };
|
|
36
37
|
})()
|
|
@@ -44,7 +45,7 @@ export function createOrgMemoryAdmissionWiring(opts) {
|
|
|
44
45
|
const memoryPlaneLive = config.memoryEngineEnabled && config.memoryEngineBackend !== "file";
|
|
45
46
|
if (directory === undefined && config.requirePrincipal === true && memoryPlaneLive) {
|
|
46
47
|
const orgProjects = Object.entries(config.projects)
|
|
47
|
-
.filter(([, p]) =>
|
|
48
|
+
.filter(([, p]) => p.defaultScopes.some((s) => s.startsWith(ORG_PREFIX)))
|
|
48
49
|
.map(([id]) => id);
|
|
49
50
|
if (orgProjects.length > 0) {
|
|
50
51
|
throw new Error(`multi-tenant deployment has org: keys in projects[${orgProjects.join(", ")}].defaultScopes but NO org-memory directory source ` +
|
|
@@ -6,7 +6,7 @@ import { type SandboxPathEnvSlots } from "./deferred-sandbox-path-env.js";
|
|
|
6
6
|
import type { ApprovalExemptionStore } from "../plugins/approval-exemption-store.js";
|
|
7
7
|
/** 本腿读的配置切面(`ServiceConfig` 结构满足)。两个构造口各自的切面 + lane 判别式读的 `remoteExec`。 */
|
|
8
8
|
export interface ParkedReviveGateConfigView extends DeploymentGovernanceConfigView, ApprovalBaselineConfigView {
|
|
9
|
-
readonly remoteExec
|
|
9
|
+
readonly remoteExec: ServiceConfig["remoteExec"];
|
|
10
10
|
/** [ref]④:`executionLaneHomeDir` 读的运维声明(切面必须点名本腿消费的每一个字段,否则窄视图字面量会静默丢掉旋钮)。 */
|
|
11
11
|
readonly remoteExecHomeDir?: ServiceConfig["remoteExecHomeDir"];
|
|
12
12
|
/** host 腿裁决 env 的 cwd 占位根(见下方 `hostGateCwd`)。 */
|
|
@@ -24,7 +24,7 @@ export function createParkedReviveInheritedGate(deps) {
|
|
|
24
24
|
env: new DeferredSandboxPathEnv({
|
|
25
25
|
sessionId: row.sessionId,
|
|
26
26
|
slots,
|
|
27
|
-
logger: { warn: (event, fields) => logger.warn(event, { ...(fields ?? {}), lane: config.remoteExec
|
|
27
|
+
logger: { warn: (event, fields) => logger.warn(event, { ...(fields ?? {}), lane: config.remoteExec.provider, leg: "parked_revive" }) },
|
|
28
28
|
}),
|
|
29
29
|
...homeBase,
|
|
30
30
|
}
|
package/dist/boot/reapers.d.ts
CHANGED
|
@@ -22,7 +22,8 @@ import type { Metrics } from "../observability/metrics.js";
|
|
|
22
22
|
import type { WorkflowNotifyGate, WorkflowNotifyJournalStore } from "../orchestration/workflow-notify-journal.js";
|
|
23
23
|
import type { TaskAttachmentStore } from "../plugins/task-attachment-store.js";
|
|
24
24
|
import type { FileHistoryErasureFace } from "../file-history-capture.js";
|
|
25
|
-
import type { ApprovalNonceStore, CheckpointStoreFull, CostQuotaStore, ImageBake, RateLimiterStore,
|
|
25
|
+
import type { ApprovalNonceStore, CheckpointStoreFull, CostQuotaStore, ImageBake, RateLimiterStore, StoreBackend } from "../plugins/store-backend.js";
|
|
26
|
+
import { type StoreSweep, type StoreSweepLeg } from "../plugins/store-sweep.js";
|
|
26
27
|
import type { ToolApprovalCoordinator } from "../tool-approval.js";
|
|
27
28
|
import type { ParkCommitWatch } from "../plugins/park-commit-watch.js";
|
|
28
29
|
import { type SandboxPodReaper } from "../plugins/k8s-pod-reaper.js";
|
|
@@ -56,6 +57,14 @@ export interface ThrottledReaperCatch {
|
|
|
56
57
|
* survives across ticks — a fresh instance per tick would never accumulate past 1.
|
|
57
58
|
*/
|
|
58
59
|
export declare function createThrottledReaperCatch(name: string, logger: Logger, threshold?: number): ThrottledReaperCatch;
|
|
60
|
+
/**
|
|
61
|
+
* 维护 tick 里调后端按龄清扫动词的那一拍。逐腿上报:失败腿的原因只进那条腿的节流告警;成功腿先计数、再清连败(计数抛也记那条腿的失败)。
|
|
62
|
+
* 动词整只拒(不是 {@link StoreSweepError} 的逐腿形)⇒ 每条腿各记一次失败。永不拒(本拍的失败全由节流告警接住)。
|
|
63
|
+
*/
|
|
64
|
+
export declare function runStoreSweepLeg(sweep: StoreSweep, nowMs: number, report: {
|
|
65
|
+
readonly guards: Readonly<Record<StoreSweepLeg, ThrottledReaperCatch>>;
|
|
66
|
+
readonly counted: (leg: StoreSweepLeg, removed: number) => void;
|
|
67
|
+
}): Promise<void>;
|
|
59
68
|
/** [ref] —— 维护 tick 真正消费的那**一手**(窄口;理由见 `ReapersCtx.permissionRuleStores`)。
|
|
60
69
|
* 可选成员:File 车道没有这一面(追加日志的压实是另一件事,如实登记在 `rules-consent.ts` 的
|
|
61
70
|
* `PermissionRuleStoreBundle.reapExpired` 注里),缺席 ⇒ 本腿零调用。 */
|
|
@@ -75,7 +84,8 @@ export interface ReapersCtx {
|
|
|
75
84
|
parkCommits: ParkCommitWatch | undefined;
|
|
76
85
|
rateLimiter: RateLimiter | RateLimiterStore | undefined;
|
|
77
86
|
costQuota: CostQuota | CostQuotaStore | undefined;
|
|
78
|
-
|
|
87
|
+
/** 本后端的按龄清扫动词(`plugins/store-sweep.ts`;腿 = 工具结果 / 名册,组合点 `boot/stores.ts`,界每次清扫现读)。tick 只调它,不逐店探按龄删的方法。 */
|
|
88
|
+
storeSweep: StoreSweep;
|
|
79
89
|
/** [ref]:文件历史的**擦除脸**(后端在即在,与 `FILE_HISTORY_CAPTURE` 无关)—— 本段只用它的孤儿 blob GC。 */
|
|
80
90
|
fileHistoryErasure: FileHistoryErasureFace | undefined;
|
|
81
91
|
taskAttachmentStore: TaskAttachmentStore | undefined;
|
|
@@ -84,10 +94,8 @@ export interface ReapersCtx {
|
|
|
84
94
|
workflowNotifyGate: WorkflowNotifyGate | undefined;
|
|
85
95
|
/** [ref]/[ref] recover 的两半 opts(boot 与周期扫描共用,单点合成在 workflow-orchestration)。 */
|
|
86
96
|
workflowRecoverOpts: Parameters<WorkflowNotifyGate["recover"]>[0];
|
|
87
|
-
workflowJournalStore: ServiceWorkflowJournalStore | undefined;
|
|
88
97
|
sqlWorkflowRunStore: WorkflowRunStore | undefined;
|
|
89
98
|
workflowNotifyJournal: WorkflowNotifyJournalStore | undefined;
|
|
90
|
-
rosterStore: RunnerDeps["rosterStore"];
|
|
91
99
|
backgroundAgentStore: RunnerDeps["backgroundAgentStore"];
|
|
92
100
|
mailboxStore: RunnerDeps["mailboxStore"];
|
|
93
101
|
/** [ref] 车6:流内审批撤卡帧的投递口(收敛器/孤儿代打腿产出的帧经它反查 broker 的活连接;[ref] 起
|
package/dist/boot/reapers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Runner, defaultTaskRegistry } from "@sema-agent/core";
|
|
2
2
|
import { sweepStaleScratchpads } from "../env-facts.js";
|
|
3
3
|
import { CostQuota } from "../observability/cost-quota.js";
|
|
4
|
+
import { STORE_SWEEP_LEGS, StoreSweepError } from "../plugins/store-sweep.js";
|
|
4
5
|
import { isAdoptionQuiescing, trackMaintenanceLeg } from "../adoption/quiesce.js";
|
|
5
6
|
import { createApprovalReconciler } from "../approval-reconciler.js";
|
|
6
7
|
import { createE2bOrphanSandboxProvider, reclaimOrphanE2bSandboxes, E2B_ORPHAN_GRACE_MS } from "../plugins/e2b-orphan-reclaim.js";
|
|
@@ -33,6 +34,32 @@ export function createThrottledReaperCatch(name, logger, threshold = REAPER_FAIL
|
|
|
33
34
|
},
|
|
34
35
|
};
|
|
35
36
|
}
|
|
37
|
+
export function runStoreSweepLeg(sweep, nowMs, report) {
|
|
38
|
+
const settle = (receipt, failed) => {
|
|
39
|
+
for (const leg of STORE_SWEEP_LEGS) {
|
|
40
|
+
if (failed.has(leg)) {
|
|
41
|
+
report.guards[leg].onError(failed.get(leg));
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
report.counted(leg, receipt[leg]);
|
|
46
|
+
report.guards[leg].onSuccess();
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
report.guards[leg].onError(err);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return Promise.resolve()
|
|
54
|
+
.then(() => sweep.sweep({ nowMs }))
|
|
55
|
+
.then((receipt) => settle(receipt, new Map()), (err) => {
|
|
56
|
+
if (err instanceof StoreSweepError)
|
|
57
|
+
settle(err.receipt, err.failed);
|
|
58
|
+
else
|
|
59
|
+
for (const leg of STORE_SWEEP_LEGS)
|
|
60
|
+
report.guards[leg].onError(err);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
36
63
|
export function createPlacementAwareReapSessions(deps) {
|
|
37
64
|
const { host, routed } = deps;
|
|
38
65
|
const listPlaced = typeof host?.listPlaced === "function" ? host.listPlaced.bind(host) : undefined;
|
|
@@ -59,7 +86,7 @@ export function createPlacementAwareReapSessions(deps) {
|
|
|
59
86
|
};
|
|
60
87
|
}
|
|
61
88
|
export function startReapers(ctx) {
|
|
62
|
-
const { config, logger, metrics, localRoot, backend, subRunner, runStore, checkpointStore, parkCommits, rateLimiter, costQuota,
|
|
89
|
+
const { config, logger, metrics, localRoot, backend, subRunner, runStore, checkpointStore, parkCommits, rateLimiter, costQuota, storeSweep, fileHistoryErasure, taskAttachmentStore, imageBakes, worktreeReap, workflowNotifyGate, workflowRecoverOpts, sqlWorkflowRunStore, workflowNotifyJournal, backgroundAgentStore, mailboxStore, toolApproval, permissionRuleStores, approvalNonceStore, getRunDenySweep, userInputLedger, approvalAskAudit, sandboxPodReaper, } = ctx;
|
|
63
90
|
const leg = (p) => {
|
|
64
91
|
if (p !== undefined)
|
|
65
92
|
trackMaintenanceLeg(p);
|
|
@@ -70,7 +97,7 @@ export function startReapers(ctx) {
|
|
|
70
97
|
logger.info("reaper_swept", { metric, ...labels, count: n });
|
|
71
98
|
}
|
|
72
99
|
};
|
|
73
|
-
const e2bOrphanProvider = config.remoteExec
|
|
100
|
+
const e2bOrphanProvider = config.remoteExec.provider === "e2b" && config.remoteExec.orphanReclaim !== false
|
|
74
101
|
? createE2bOrphanSandboxProvider({ apiKey: config.remoteExec.apiKey })
|
|
75
102
|
: undefined;
|
|
76
103
|
let e2bOrphanLastRunMs = Date.now() - E2B_ORPHAN_GRACE_MS;
|
|
@@ -91,7 +118,16 @@ export function startReapers(ctx) {
|
|
|
91
118
|
const runDenySweepGuard = createThrottledReaperCatch("run_deny_sweep", logger);
|
|
92
119
|
const runsReapSuspendedGuard = createThrottledReaperCatch("runs_reap_suspended", logger);
|
|
93
120
|
const checkpointReapCtxGuard = createThrottledReaperCatch("checkpoint_reap_ctx", logger);
|
|
94
|
-
const
|
|
121
|
+
const storeSweepGuards = {
|
|
122
|
+
"roster-aged": createThrottledReaperCatch("roster_reap_older_than", logger),
|
|
123
|
+
"tool-results-aged": createThrottledReaperCatch("tool_result_reap", logger),
|
|
124
|
+
"workflow-journal-expired": createThrottledReaperCatch("workflow_journal_reap_expired", logger),
|
|
125
|
+
};
|
|
126
|
+
const storeSweepCount = {
|
|
127
|
+
"roster-aged": reapCount("roster_rows_reaped_total", {}),
|
|
128
|
+
"tool-results-aged": undefined,
|
|
129
|
+
"workflow-journal-expired": undefined,
|
|
130
|
+
};
|
|
95
131
|
const fileHistorySweepOrphanBlobsGuard = createThrottledReaperCatch("file_history_sweep_orphan_blobs", logger);
|
|
96
132
|
const legacySnapshotBlobSweepGuard = createThrottledReaperCatch("legacy_snapshot_blob_sweep", logger);
|
|
97
133
|
const attachmentReapUnboundGuard = createThrottledReaperCatch("attachment_reap_unbound", logger);
|
|
@@ -99,11 +135,9 @@ export function startReapers(ctx) {
|
|
|
99
135
|
const imageBakesReapStaleGuard = createThrottledReaperCatch("image_bakes_reap_stale", logger);
|
|
100
136
|
const worktreeReapGuard = createThrottledReaperCatch("worktree_reap", logger);
|
|
101
137
|
const workflowNotifyRecoverGuard = createThrottledReaperCatch("workflow_notify_recover", logger);
|
|
102
|
-
const workflowJournalReapExpiredGuard = createThrottledReaperCatch("workflow_journal_reap_expired", logger);
|
|
103
138
|
const workflowRunReapAllScopesGuard = createThrottledReaperCatch("workflow_run_reap_all_scopes", logger);
|
|
104
139
|
const workflowNotifyJournalReapAckedGuard = createThrottledReaperCatch("workflow_notify_journal_reap_acked", logger);
|
|
105
140
|
const bgAgentsReapGuard = createThrottledReaperCatch("bg_agents_reap", logger);
|
|
106
|
-
const rosterReapOlderThanGuard = createThrottledReaperCatch("roster_reap_older_than", logger);
|
|
107
141
|
const leaderRunStaleGuard = createThrottledReaperCatch("leader_run_reap_stale", logger);
|
|
108
142
|
const leaderRunStore = config.leaderEnabled ? backend?.leaderRun?.() : undefined;
|
|
109
143
|
const scratchpadSweepStaleGuard = createThrottledReaperCatch("scratchpad_sweep_stale", logger);
|
|
@@ -244,10 +278,7 @@ export function startReapers(ctx) {
|
|
|
244
278
|
rateLimiter?.sweep();
|
|
245
279
|
if (costQuota instanceof CostQuota)
|
|
246
280
|
costQuota.reap();
|
|
247
|
-
|
|
248
|
-
leg(reapToolResults && Promise.resolve()
|
|
249
|
-
.then(() => reapToolResults(Date.now(), { maxAgeMs: config.toolResultTtlSec * 1000 }))
|
|
250
|
-
.then(() => toolResultReapGuard.onSuccess(), toolResultReapGuard.onError));
|
|
281
|
+
leg(runStoreSweepLeg(storeSweep, Date.now(), { guards: storeSweepGuards, counted: (l, n) => storeSweepCount[l]?.(n) }));
|
|
251
282
|
leg(fileHistoryErasure
|
|
252
283
|
?.sweepOrphanBlobs?.()
|
|
253
284
|
.then(() => fileHistorySweepOrphanBlobsGuard.onSuccess(), fileHistorySweepOrphanBlobsGuard.onError));
|
|
@@ -290,9 +321,6 @@ export function startReapers(ctx) {
|
|
|
290
321
|
leg(workflowNotifyGate
|
|
291
322
|
?.recover(workflowRecoverOpts)
|
|
292
323
|
.then(() => workflowNotifyRecoverGuard.onSuccess(), workflowNotifyRecoverGuard.onError));
|
|
293
|
-
leg(workflowJournalStore
|
|
294
|
-
?.reapExpired?.(Date.now(), config.workflowJournalRetentionMs)
|
|
295
|
-
.then(() => workflowJournalReapExpiredGuard.onSuccess(), workflowJournalReapExpiredGuard.onError));
|
|
296
324
|
if (!wfRunReapInFlight) {
|
|
297
325
|
const sweep = sqlWorkflowRunStore?.reapAllScopes?.(Date.now(), { maxAgeMs: config.workflowRunRetentionMs });
|
|
298
326
|
if (sweep) {
|
|
@@ -311,10 +339,6 @@ export function startReapers(ctx) {
|
|
|
311
339
|
.then(() => bgAgentsReapGuard.onSuccess(), bgAgentsReapGuard.onError)
|
|
312
340
|
.finally(() => (bgAgentReapInFlight = false)));
|
|
313
341
|
}
|
|
314
|
-
leg(rosterStore
|
|
315
|
-
?.reapOlderThan?.(Date.now() - config.rosterRetentionMs)
|
|
316
|
-
.then(reapCount("roster_rows_reaped_total", {}))
|
|
317
|
-
.then(() => rosterReapOlderThanGuard.onSuccess(), rosterReapOlderThanGuard.onError));
|
|
318
342
|
leg(leaderRunStore
|
|
319
343
|
?.reapStaleRunning(config.leaderRunStaleMs, Date.now())
|
|
320
344
|
.then(reapCount("leader_runs_stale_reaped_total", {}))
|
|
@@ -41,6 +41,8 @@ export interface ResolveSpecCtx {
|
|
|
41
41
|
fenceSessionOwner: (sid: string, owner: string | null) => void;
|
|
42
42
|
hookLlm: ReturnType<typeof createHookLlm>["hookLlm"];
|
|
43
43
|
hookAgent: HookLlmCall;
|
|
44
|
+
/** 部署座在任务座之下挂了链成员的站点式样(第 5 段装配口从引擎准入记录读出,`boot/deployment-mods.ts` 的 `belowTaskChainPatternsOf`)—— 原样交 hooks 注册上下文(托管车道在这些站上只许收紧)。 */
|
|
45
|
+
belowTaskChainPatterns: readonly string[];
|
|
44
46
|
fleetBus: FleetEventBus;
|
|
45
47
|
hookWakeBus: {
|
|
46
48
|
deliver?: (sessionId: string, text: string) => Promise<boolean>;
|