@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
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { isSharedMemoryDocumentPath, isSharedMemoryStoreId, SHARED_MEMORY_READ_CAP_BYTES, SharedMemoryStoreError, } from "@sema-agent/core";
|
|
1
|
+
import { isOrgScopeKey, isSharedMemoryDocumentPath, isSharedMemoryStoreId, SHARED_MEMORY_READ_CAP_BYTES, SharedMemoryStoreError, } from "@sema-agent/core";
|
|
2
2
|
import { mysqlDriver, pgDriver } from "./sql-driver.js";
|
|
3
3
|
import { isDupKeyError } from "./sql-errors.js";
|
|
4
4
|
const isDupKey = isDupKeyError;
|
|
5
5
|
export const SHARED_MEMORY_SCOPE_TABLE = "shared_memory_scope";
|
|
6
6
|
export const SHARED_MEMORY_STORE_TABLE = "shared_memory_store";
|
|
7
7
|
export const SHARED_MEMORY_ENTRY_TABLE = "shared_memory_entry";
|
|
8
|
-
const ORG_SCOPE_RE = /^org:\S{1,185}$/;
|
|
9
8
|
const PATH_MAX_CHARS = 512;
|
|
10
9
|
const DESCRIPTION_MAX_CHARS = 512;
|
|
11
10
|
const DEFAULT_MAX_LIST_LIMIT = 500;
|
|
@@ -15,10 +14,14 @@ export function assertStoreId(storeId) {
|
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
export function assertScopeKey(scopeKey) {
|
|
18
|
-
if (!
|
|
19
|
-
throw new Error(`shared-memory scope key ${JSON.stringify(scopeKey)} is not usable: it
|
|
17
|
+
if (!isOrgScopeKey(scopeKey)) {
|
|
18
|
+
throw new Error(`shared-memory scope key ${JSON.stringify(scopeKey)} is not usable: core's org scope key rule refuses it (spell the org with core's formatOrgScope: "org:" plus the name's percent-encoded segment)`);
|
|
20
19
|
}
|
|
21
20
|
}
|
|
21
|
+
function ownedExactly(rows, scopeKey) {
|
|
22
|
+
const row = rows[0];
|
|
23
|
+
return row !== undefined && String(row.scope_key) === scopeKey;
|
|
24
|
+
}
|
|
22
25
|
export function assertDocumentPath(path) {
|
|
23
26
|
const refuse = (why) => {
|
|
24
27
|
throw new Error(`shared-memory document path ${JSON.stringify(path)} is not usable: ${why}`);
|
|
@@ -267,7 +270,6 @@ export class SqlSharedMemoryStore {
|
|
|
267
270
|
}
|
|
268
271
|
async putDocument(record) {
|
|
269
272
|
assertStoreId(record.storeId);
|
|
270
|
-
assertScopeKey(record.scopeKey);
|
|
271
273
|
assertDocumentPath(record.path);
|
|
272
274
|
const sizeBytes = Buffer.byteLength(record.content, "utf8");
|
|
273
275
|
if (sizeBytes > SHARED_MEMORY_READ_CAP_BYTES) {
|
|
@@ -278,8 +280,8 @@ export class SqlSharedMemoryStore {
|
|
|
278
280
|
const conn = await this.db.connect();
|
|
279
281
|
try {
|
|
280
282
|
await conn.begin();
|
|
281
|
-
const registered = await conn.query(this.q(`SELECT store_id FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = ? AND scope_key = ? FOR UPDATE`, `SELECT store_id FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = $1 AND scope_key = $2 FOR UPDATE`), [record.storeId, record.scopeKey]);
|
|
282
|
-
if (registered.rows.
|
|
283
|
+
const registered = await conn.query(this.q(`SELECT store_id, scope_key FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = ? AND scope_key = ? FOR UPDATE`, `SELECT store_id, scope_key FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = $1 AND scope_key = $2 FOR UPDATE`), [record.storeId, record.scopeKey]);
|
|
284
|
+
if (!ownedExactly(registered.rows, record.scopeKey)) {
|
|
283
285
|
unregistered = true;
|
|
284
286
|
await conn.rollback();
|
|
285
287
|
}
|
|
@@ -303,14 +305,13 @@ export class SqlSharedMemoryStore {
|
|
|
303
305
|
}
|
|
304
306
|
async deleteDocument(storeId, scopeKey, path) {
|
|
305
307
|
assertStoreId(storeId);
|
|
306
|
-
assertScopeKey(scopeKey);
|
|
307
308
|
let unregistered = false;
|
|
308
309
|
let deleted = false;
|
|
309
310
|
const conn = await this.db.connect();
|
|
310
311
|
try {
|
|
311
312
|
await conn.begin();
|
|
312
|
-
const registered = await conn.query(this.q(`SELECT store_id FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = ? AND scope_key = ? FOR UPDATE`, `SELECT store_id FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = $1 AND scope_key = $2 FOR UPDATE`), [storeId, scopeKey]);
|
|
313
|
-
if (registered.rows
|
|
313
|
+
const registered = await conn.query(this.q(`SELECT store_id, scope_key FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = ? AND scope_key = ? FOR UPDATE`, `SELECT store_id, scope_key FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = $1 AND scope_key = $2 FOR UPDATE`), [storeId, scopeKey]);
|
|
314
|
+
if (!ownedExactly(registered.rows, scopeKey)) {
|
|
314
315
|
unregistered = true;
|
|
315
316
|
await conn.rollback();
|
|
316
317
|
}
|
|
@@ -334,13 +335,12 @@ export class SqlSharedMemoryStore {
|
|
|
334
335
|
}
|
|
335
336
|
async deleteStore(storeId, scopeKey) {
|
|
336
337
|
assertStoreId(storeId);
|
|
337
|
-
assertScopeKey(scopeKey);
|
|
338
338
|
let notOwned = false;
|
|
339
339
|
const conn = await this.db.connect();
|
|
340
340
|
try {
|
|
341
341
|
await conn.begin();
|
|
342
|
-
const owned = await conn.query(this.q(`SELECT store_id FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = ? AND scope_key = ? FOR UPDATE`, `SELECT store_id FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = $1 AND scope_key = $2 FOR UPDATE`), [storeId, scopeKey]);
|
|
343
|
-
if (owned.rows
|
|
342
|
+
const owned = await conn.query(this.q(`SELECT store_id, scope_key FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = ? AND scope_key = ? FOR UPDATE`, `SELECT store_id, scope_key FROM ${SHARED_MEMORY_STORE_TABLE} WHERE store_id = $1 AND scope_key = $2 FOR UPDATE`), [storeId, scopeKey]);
|
|
343
|
+
if (!ownedExactly(owned.rows, scopeKey)) {
|
|
344
344
|
notOwned = true;
|
|
345
345
|
await conn.rollback();
|
|
346
346
|
}
|
|
@@ -58,7 +58,7 @@ export async function ensureSnapshotBucket(store, waitMs, logger, clock, role =
|
|
|
58
58
|
export async function ensureSnapshotBuckets(config, logger) {
|
|
59
59
|
const wanted = [
|
|
60
60
|
["session", config.snapshotBlobStore],
|
|
61
|
-
["workspace", config.remoteExec
|
|
61
|
+
["workspace", config.remoteExec.provider === "k8s" ? config.remoteExec.s3Snapshot : undefined],
|
|
62
62
|
];
|
|
63
63
|
for (const [role, store] of wanted) {
|
|
64
64
|
if (store)
|
|
@@ -21,9 +21,13 @@
|
|
|
21
21
|
* ⚠️ The dup-key predicate ITSELF is NOT store-specific and no longer lives at the call sites:
|
|
22
22
|
* `sql-errors.ts` owns it ([ref] P1-①; 7+ hand-rolled copies had drifted into three different
|
|
23
23
|
* recognition sets, so the same driver error got opposite verdicts in different stores).
|
|
24
|
-
* - per-query timeouts: mysql2 takes `{sql, timeout}` while node-pg takes a `QueryConfig`
|
|
25
|
-
* `query_timeout`. The counter family (write-behind-counter.ts) needs those and keeps its own
|
|
26
|
-
* exec; this seam stays on the plain (sql, params) form.
|
|
24
|
+
* - per-query timeouts on the POOL form: mysql2 takes `{sql, timeout}` while node-pg takes a `QueryConfig`
|
|
25
|
+
* with `query_timeout`. The counter family (write-behind-counter.ts) needs those and keeps its own
|
|
26
|
+
* exec; the pool form of this seam stays on the plain (sql, params) form.
|
|
27
|
+
* A LENT connection ({@link SqlTxConn.query}) takes one optional per-statement deadline
|
|
28
|
+
* ({@link SqlStatementOptions}): past it the statement rejects ({@link SqlStatementDeadlineExceeded}) and the lease
|
|
29
|
+
* is destroyed first (its session / transaction state is unknown — it never goes back to the pool; the server
|
|
30
|
+
* rolls the open transaction back when the connection closes). Same rule on both dialects, one implementation.
|
|
27
31
|
*
|
|
28
32
|
* ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
29
33
|
* @contract txn.read-semantics — 本仓「事务里的读看到什么」的**唯一**成文处([ref] / [ref] / [ref])
|
|
@@ -127,8 +131,20 @@ export interface SqlResult {
|
|
|
127
131
|
export interface SqlExec {
|
|
128
132
|
query(sql: string, params?: unknown[]): Promise<SqlResult>;
|
|
129
133
|
}
|
|
134
|
+
/** Per-statement options of a lent connection's {@link SqlTxConn.query}. */
|
|
135
|
+
export interface SqlStatementOptions {
|
|
136
|
+
/** The statement rejects ({@link SqlStatementDeadlineExceeded}) if it has not settled within this many ms; the lease is destroyed first. */
|
|
137
|
+
readonly deadlineMs?: number;
|
|
138
|
+
}
|
|
139
|
+
/** A lent connection's statement did not settle within its deadline: the connection was destroyed (never pooled again), the statement rejected. Typed so callers triage it without reading the message. */
|
|
140
|
+
export declare class SqlStatementDeadlineExceeded extends Error {
|
|
141
|
+
readonly deadlineMs: number;
|
|
142
|
+
constructor(deadlineMs: number);
|
|
143
|
+
}
|
|
130
144
|
/** A pooled connection with transaction control (released by the caller in a `finally`). */
|
|
131
145
|
export interface SqlTxConn extends SqlExec {
|
|
146
|
+
/** {@link SqlExec.query}, with an optional per-statement deadline (see the file header). */
|
|
147
|
+
query(sql: string, params?: unknown[], opts?: SqlStatementOptions): Promise<SqlResult>;
|
|
132
148
|
/**
|
|
133
149
|
* The ONE transaction verb ([ref]). What its reads see is NOT decided here — it is decided once per
|
|
134
150
|
* pooled connection at initialization and reported by {@link SqlDriver.facts}. Read the
|
|
@@ -200,7 +216,7 @@ export interface SqlEngineFacts {
|
|
|
200
216
|
* ({@link PACKET_CAP_UNREAD_LANDING_BYTES}), recorded through `recordFailOpen("server.sql.packet-cap-unread")` (a per-hit
|
|
201
217
|
* count and one warn line naming the reason). Never `null`: on these engines the wall exists, only its size may be unread.
|
|
202
218
|
* · **`null`** — PostgreSQL: the extended protocol has no statement-size wall.
|
|
203
|
-
* Its final judge: the SQL snapshot-blob cap (`
|
|
219
|
+
* Its final judge: the SQL snapshot-blob cap (`stores-sql/blob-index-sql.ts` `SqlBlobIndex.put`, the SQL-kept arm), which borrows the connection
|
|
204
220
|
* it will write on through {@link connectJudged}, reads this off it ({@link sqlConnectionFacts}), judges, and writes on that
|
|
205
221
|
* same connection — and when it refuses on a connection opened before the DBA raised the wall, that stale connection is
|
|
206
222
|
* replaced and the write judged once more ({@link connectJudged}). On {@link SqlDriver.facts} the value is the most recently
|
|
@@ -305,7 +321,7 @@ export interface SqlWallsReading extends SqlWalls {
|
|
|
305
321
|
}
|
|
306
322
|
/**
|
|
307
323
|
* 一只 SQL 池的**引擎读口**:方言(SQL 文本轴,装配事实,恒在)+ 此刻的引擎事实(`null` = 没建立)。墙的方言只从这里来 —— 与事实同出一只驱动
|
|
308
|
-
* ({@link SqlDriver} 结构上就是它;`facts` 是活的,池重连后随之换)。HTTP 面的读口(`ServiceDeps.sqlEngine`)与店的写前帽(`
|
|
324
|
+
* ({@link SqlDriver} 结构上就是它;`facts` 是活的,池重连后随之换)。HTTP 面的读口(`ServiceDeps.sqlEngine`)与店的写前帽(`SqlBlobIndex`)各读本池的这一只。
|
|
309
325
|
*/
|
|
310
326
|
export type SqlEngineReading = Pick<SqlDriver, "dialect" | "facts">;
|
|
311
327
|
/**
|
|
@@ -317,7 +333,7 @@ export type SqlEngineReading = Pick<SqlDriver, "dialect" | "facts">;
|
|
|
317
333
|
export declare const SQL_FACTS_ABSENT_WALLS: SqlWallsReading;
|
|
318
334
|
/**
|
|
319
335
|
* 🔴 **此刻一份写入要装进的墙 —— 唯一判官**。两个读者同调它、不各读 `facts`:提交受理口(`http/request-guards.ts` `refuseSubmitBody`)与 SQL 快照 blob 的缺省帽
|
|
320
|
-
* (`
|
|
336
|
+
* (`stores-sql/blob-index-sql.ts` `sqlBlobCapOf`:店的写前判,读的是**将要执行写入的那条连接**的读口 —— 方言 + 它自己那次初始化的事实;受理口读本池驱动的读口)。输入是一只引擎读口({@link SqlEngineReading}:方言与事实同出),一种读法:
|
|
321
337
|
* · 读口缺席 = 没有 SQL 后端 ⇒ 没有墙(「忘了给」读不成这一臂:后端交出了 SQL 池而没给读口 ⇒ `createHttpServer` 起服拒,见 `ServiceDeps.sqlEngine`);
|
|
322
338
|
* · 事实在场 ⇒ 事实里的两位,出处逐墙取事实里记的那一份({@link SqlEngineFacts.wallSources}:读到的 `reported`,读失败退文档缺省的 `assumed`);
|
|
323
339
|
* · 事实缺席(`null`)⇒ 按读口的方言:PG 没有墙(扩展协议没有这两堵墙 —— 方言事实,不随引擎事实缺席);MySQL 协议 ⇒ {@link SQL_FACTS_ABSENT_WALLS}(两堵都 `assumed`;
|
|
@@ -373,7 +389,7 @@ export interface SqlDriver extends SqlExec {
|
|
|
373
389
|
}
|
|
374
390
|
/**
|
|
375
391
|
* 一条**借出的**连接自己的引擎事实 —— 它的初始化回读到的那一份(包墙 `maxPacketBytes` 是这条连接的会话值)。判一条语句装不装得下的地方
|
|
376
|
-
* 只读这里:借出连接 → 读它的墙 → 判 → 在同一条连接上执行(`
|
|
392
|
+
* 只读这里:借出连接 → 读它的墙 → 判 → 在同一条连接上执行(`stores-sql/blob-index-sql.ts` `SqlBlobIndex.put`)。
|
|
377
393
|
* 只认本模块的 `mysqlDriver` / `pgDriver` 的 `connect()` 借出的连接;别的连接(测试替身、包装体)没有经过初始化,墙没人读过 ⇒ **响亮抛**,不猜一个数。
|
|
378
394
|
*/
|
|
379
395
|
export declare function sqlConnectionFacts(conn: SqlTxConn): SqlEngineFacts;
|
|
@@ -2,6 +2,30 @@ import { pgSafeJsonStringify, pgProtocolJsonStringify } from "./pg-safe-json.js"
|
|
|
2
2
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
3
3
|
import { errorKindOf } from "../observability/err-text.js";
|
|
4
4
|
import { isConnectionUnusableError } from "./sql-errors.js";
|
|
5
|
+
export class SqlStatementDeadlineExceeded extends Error {
|
|
6
|
+
deadlineMs;
|
|
7
|
+
constructor(deadlineMs) {
|
|
8
|
+
super(`SQL statement did not settle within ${deadlineMs}ms — the connection was destroyed (its transaction rolls back when it closes)`);
|
|
9
|
+
this.deadlineMs = deadlineMs;
|
|
10
|
+
this.name = "SqlStatementDeadlineExceeded";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function withStatementDeadline(run, opts, destroy) {
|
|
14
|
+
const deadlineMs = opts?.deadlineMs;
|
|
15
|
+
if (deadlineMs === undefined)
|
|
16
|
+
return run();
|
|
17
|
+
const running = run();
|
|
18
|
+
running.catch(() => undefined);
|
|
19
|
+
let timer;
|
|
20
|
+
const expired = new Promise((_, reject) => {
|
|
21
|
+
timer = setTimeout(() => {
|
|
22
|
+
destroy();
|
|
23
|
+
reject(new SqlStatementDeadlineExceeded(deadlineMs));
|
|
24
|
+
}, deadlineMs);
|
|
25
|
+
timer.unref?.();
|
|
26
|
+
});
|
|
27
|
+
return Promise.race([running, expired]).finally(() => clearTimeout(timer));
|
|
28
|
+
}
|
|
5
29
|
export const TIDB_DEFAULT_TXN_ENTRY_SIZE_LIMIT = 6_291_456;
|
|
6
30
|
export const ROW_WALL_ALLOWANCE_BYTES = { json: 64 * 1024, blob: 1024 };
|
|
7
31
|
export const STATEMENT_ALLOWANCE_BYTES = 1024;
|
|
@@ -299,15 +323,20 @@ function leaseOf(raw) {
|
|
|
299
323
|
if (GUARDED_LEASES.has(raw))
|
|
300
324
|
return raw;
|
|
301
325
|
let destroyed = false;
|
|
326
|
+
let leaveQueue = () => undefined;
|
|
327
|
+
const gone = new Promise((resolve) => {
|
|
328
|
+
leaveQueue = resolve;
|
|
329
|
+
});
|
|
302
330
|
const destroy = () => {
|
|
303
331
|
if (destroyed)
|
|
304
332
|
return;
|
|
305
333
|
destroyed = true;
|
|
334
|
+
leaveQueue();
|
|
306
335
|
raw.destroy();
|
|
307
336
|
};
|
|
308
337
|
let turn = Promise.resolve();
|
|
309
338
|
const guard = (run) => {
|
|
310
|
-
const result = turn.then(async () => {
|
|
339
|
+
const result = Promise.race([turn, gone]).then(async () => {
|
|
311
340
|
try {
|
|
312
341
|
return await run();
|
|
313
342
|
}
|
|
@@ -388,7 +417,7 @@ export function mysqlDriver(pool) {
|
|
|
388
417
|
if (broken !== undefined)
|
|
389
418
|
throw broken.error;
|
|
390
419
|
const conn = {
|
|
391
|
-
query: (sql, params) => mysqlQuery(c, sql, params),
|
|
420
|
+
query: (sql, params, opts) => withStatementDeadline(() => mysqlQuery(c, sql, params), opts, () => c.destroy()),
|
|
392
421
|
begin: () => c.beginTransaction(),
|
|
393
422
|
commit: () => c.commit(),
|
|
394
423
|
rollback: () => c.rollback(),
|
|
@@ -440,8 +469,14 @@ export function pgDriver(pool) {
|
|
|
440
469
|
const c = await pool.connect();
|
|
441
470
|
const { facts, initOrdinal } = await establishSession(session, c, c, initPgSession);
|
|
442
471
|
let destroyed = false;
|
|
472
|
+
const destroy = () => {
|
|
473
|
+
if (destroyed)
|
|
474
|
+
return;
|
|
475
|
+
destroyed = true;
|
|
476
|
+
c.release(true);
|
|
477
|
+
};
|
|
443
478
|
const conn = {
|
|
444
|
-
query: (sql, params) => pgQuery(c, sql, params),
|
|
479
|
+
query: (sql, params, opts) => withStatementDeadline(() => pgQuery(c, sql, params), opts, destroy),
|
|
445
480
|
begin: async () => {
|
|
446
481
|
await c.query("BEGIN");
|
|
447
482
|
},
|
|
@@ -449,7 +484,8 @@ export function pgDriver(pool) {
|
|
|
449
484
|
await c.query("COMMIT");
|
|
450
485
|
},
|
|
451
486
|
rollback: async () => {
|
|
452
|
-
|
|
487
|
+
if (!destroyed)
|
|
488
|
+
await c.query("ROLLBACK");
|
|
453
489
|
},
|
|
454
490
|
release: () => {
|
|
455
491
|
if (!destroyed)
|
|
@@ -461,10 +497,7 @@ export function pgDriver(pool) {
|
|
|
461
497
|
facts,
|
|
462
498
|
initOrdinal,
|
|
463
499
|
id: typeof pid === "number" ? pid : null,
|
|
464
|
-
destroy
|
|
465
|
-
destroyed = true;
|
|
466
|
-
c.release(true);
|
|
467
|
-
},
|
|
500
|
+
destroy,
|
|
468
501
|
readGlobalPacketWall: async () => null,
|
|
469
502
|
});
|
|
470
503
|
return conn;
|
|
@@ -193,12 +193,15 @@ export declare function isConnectionFaultError(err: unknown): boolean;
|
|
|
193
193
|
* **部署错配类故障**的识别表(闭集;逐行登记「为什么」)—— 到库的连接是好的、语句也是对的,是这套库的形与本部署的要求不符:**重试注定失败**,修表 / 授权之前什么都不会变
|
|
194
194
|
* (与连接类互为反面:那一类是「什么都不改稍后再试可能成」)。读者:整仓一只判官 `plugins/store-fault.ts` 的 `storeFaultClassOf` 的 `deployment` 一词 ——
|
|
195
195
|
* 文件历史店的折点与会话同步拉取口(`503 state.file_history_unreadable`)据它判 `permanence: "terminal"`;审批队列读口并入「此刻读不出」的 503;各读者各自表态,**不在自己那里写码**。
|
|
196
|
+
* 起服建表(`session-ext-table.ts` 的 `ensureSessionExtTableMysql`)问的也是这一只:「库确定拒了这条 DDL」= 本表认得 ⇒ 当场拒启;认不出 ⇒ 原样上抛、开库等待窗重试 —— 不自带第二份分类。
|
|
197
|
+
* 外键四码(3780 / 1215 / 1822 / 1005)只可能出在建表 / 改表上,读写路径上的读者见不到它们 —— 加进本表对那几处零变化。
|
|
196
198
|
*
|
|
197
199
|
* 识别集 = 本表一张,按归因键登记:`code`(字符串)与 MySQL 协议的数字 `errno`(两键是同一件事的两种写法,代理 / 序列化往返可能只留一个;同本文件其余谓词的姿势)。
|
|
198
200
|
* **与连接类互斥**:本表的任何一码都不在 {@link CONNECTION_FAULT_ERRORS} / {@link MYSQL_CONNECTION_UNUSABLE_ERRORS} 的识别集里,反之亦然(`test/store-fault-judge.test.ts` 钉两个方向)—— 同一只错只落一个词。
|
|
199
201
|
*
|
|
200
|
-
* **不在表里**(
|
|
201
|
-
* 认证类拒连(MySQL 1045、PG `28xxx`:凭据 / 白名单)、库级与列级的权限拒(MySQL 1044 / 1143)
|
|
202
|
+
* **不在表里**(认不出一律不是;今天收缺表、权限拒与外键建不成三形,其余是登记在案的未收项,不是「已裁定不判」):缺列(1054 / `42703`:升级前置断言 `assert*Schema` 族有自己的判据与出路)、
|
|
203
|
+
* 认证类拒连(MySQL 1045、PG `28xxx`:凭据 / 白名单)、库级与列级的权限拒(MySQL 1044 / 1143)、语法错(1064:多半是我方的语句,不是库的形)、
|
|
204
|
+
* TiDB 自己的忙 / 区域不可用 / 结构变更冲突一族(9001 / 9005 / 8028,同连接类表的登记)、锁等待超时(1205)。
|
|
202
205
|
*/
|
|
203
206
|
export declare const DEPLOYMENT_FAULT_ERRORS: ReadonlyArray<{
|
|
204
207
|
readonly code: string;
|
|
@@ -148,6 +148,10 @@ export const DEPLOYMENT_FAULT_ERRORS = [
|
|
|
148
148
|
{ code: "42501", why: "PG insufficient_privilege(权限拒:库账号缺这张表 / 这类语句的授权 —— 授权之前重试注定失败)" },
|
|
149
149
|
{ code: "ER_NO_SUCH_TABLE", errno: 1146, why: "MySQL 协议(MySQL / MariaDB / TiDB)缺表:同 PG `42P01`" },
|
|
150
150
|
{ code: "ER_TABLEACCESS_DENIED_ERROR", errno: 1142, why: "MySQL 协议表级权限拒:库账号对这张表缺这类语句的授权,同 PG `42501`" },
|
|
151
|
+
{ code: "ER_FK_INCOMPATIBLE_COLUMNS", errno: 3780, why: "MySQL 协议外键两侧列不相容(类型 / 字符集 / 排序规则对不上):被引表的形与外键要求不符,重试同一句仍不相容" },
|
|
152
|
+
{ code: "ER_CANNOT_ADD_FOREIGN", errno: 1215, why: "MySQL 协议加不上外键(如被引表不是 InnoDB):库的形不收这条约束,改表之前重试注定失败" },
|
|
153
|
+
{ code: "ER_FK_NO_INDEX_PARENT", errno: 1822, why: "MySQL 协议外键的被引列上缺索引:被引表的形不符,建索引之前重试注定失败" },
|
|
154
|
+
{ code: "ER_CANT_CREATE_TABLE", errno: 1005, why: "MySQL 协议建表被存储引擎拒(errno 150 外键形不成 / 121 约束名已占 / 28 盘满):修库之前重试同一句仍被拒" },
|
|
151
155
|
];
|
|
152
156
|
const DEPLOYMENT_FAULT_CODES = new Set(DEPLOYMENT_FAULT_ERRORS.map((r) => r.code));
|
|
153
157
|
const DEPLOYMENT_FAULT_ERRNOS = new Set(DEPLOYMENT_FAULT_ERRORS.flatMap((r) => (r.errno === undefined ? [] : [r.errno])));
|
|
@@ -69,7 +69,7 @@ export interface JsonColumnMember {
|
|
|
69
69
|
*
|
|
70
70
|
* 🔴 存在的唯一理由是「别名位在那里不合法」,**不是**给读腿留第二条路:读腿一律用 {@link jsonColumnText}
|
|
71
71
|
* (别名是它的产物的一部分,理由见那只函数)。今天整仓**三处**消费方,各自的「别名位不合法」都是真的:
|
|
72
|
-
* · `one-time-migrations.ts` 的几条改写(
|
|
72
|
+
* · `one-time-migrations.ts` 的几条改写(M17 / M18 / M21 的候选扫描与按原文 CAS 回写)——
|
|
73
73
|
* 它们要在 `WHERE` 里判这一列的**文本**,而 `WHERE` 没有别名位;
|
|
74
74
|
* · `workflow-journal-store-sql.ts` 的 `loadPage`([ref] 车③a)—— 那一列的投影裹在一条
|
|
75
75
|
* `CASE WHEN LENGTH(result) > ? THEN NULL ELSE <expr> END AS result_json` 里:**别名属于整条 CASE**
|
|
@@ -202,6 +202,10 @@ export declare class StoreCorruptError extends Error {
|
|
|
202
202
|
/** 出事的坐标(`<table>.<column> for <identity>`,由 {@link SqlJsonColumnError.where} 原样带过来)——
|
|
203
203
|
* 进 wire 的 `where` 字段,人按它去找那一行。 */
|
|
204
204
|
readonly where: string;
|
|
205
|
+
/** 构造函数交进来的就是这一只列错误(类型面如实:折码只在体问题上产出本类,见 {@link foldJsonColumn});子类想在同一份因由上再带一格事实时按它再构造,不必断言。 */
|
|
206
|
+
readonly cause: SqlJsonColumnError & {
|
|
207
|
+
readonly problem: SqlJsonColumnBodyProblem;
|
|
208
|
+
};
|
|
205
209
|
constructor(cause: SqlJsonColumnError & {
|
|
206
210
|
readonly problem: SqlJsonColumnBodyProblem;
|
|
207
211
|
}, sentence: string);
|
|
@@ -20,7 +20,7 @@ import { TiDBResumeAnchorStore, PgResumeAnchorStore } from "./resume-anchor-stor
|
|
|
20
20
|
import { type SessionPolicyStoreLogger } from "../stores-sql/session-policy-store-sql.js";
|
|
21
21
|
import type { ServiceConfig } from "../config-types.js";
|
|
22
22
|
import { TiDBRunStore, PgRunStore } from "./run-store-sql.js";
|
|
23
|
-
import { TiDBCheckpointStore, PgCheckpointStore } from "
|
|
23
|
+
import { TiDBCheckpointStore, PgCheckpointStore } from "../stores-sql/checkpoint-store-sql.js";
|
|
24
24
|
import { TiDBImageIndex, PgImageIndex } from "./image-index-sql.js";
|
|
25
25
|
import { TiDBImageBake, PgImageBake } from "./image-bake-store-sql.js";
|
|
26
26
|
import { TiDBLeaderRunStore, PgLeaderRunStore } from "./leader-run-store-sql.js";
|
|
@@ -33,9 +33,12 @@ import type { CounterDegradeHook } from "./write-behind-counter.js";
|
|
|
33
33
|
import { PgRateLimiter } from "./pg-rate-limiter.js";
|
|
34
34
|
import { type SqlSharedMemoryStore, type SharedMemoryScopeAuthorizer } from "./shared-memory-store-sql.js";
|
|
35
35
|
import { type AdoptionLogStore } from "./adoption-log-sql.js";
|
|
36
|
-
import { type
|
|
36
|
+
import { type SqlTransactionHooks } from "../stores-sql/retention-store-sql.js";
|
|
37
|
+
import type { EndedSpace } from "../workspace-space.js";
|
|
38
|
+
import { type RetentionDestructiveInput, type RetentionExecutor, type RetentionExecutorOptions } from "./retention-deployment.js";
|
|
37
39
|
import { type RetentionLaneStore } from "./retention-lane-store-sql.js";
|
|
38
40
|
import type { PermissionRuleStoreBundle } from "../rules-consent.js";
|
|
41
|
+
import { type SqlDriver } from "./sql-driver.js";
|
|
39
42
|
import { type StoreDegradedReason } from "../store-posture.js";
|
|
40
43
|
/** boot 期的一条日志座(级别由**座位**决定,不由参数携带):`createStoreBackend` 的 `onWarn` / `onError`
|
|
41
44
|
* 两参与 `LocalBackend` 的同名字段共用此形。装配层把它们分别接到 `logger.warn` / `logger.error` 上。 */
|
|
@@ -65,7 +68,7 @@ export type ServiceSessionPolicyStore = SessionPolicyStore;
|
|
|
65
68
|
* The SQL twins' blob exchange — core's {@link FileHistoryBlobExchange} group (`put` / `get` / `has`, all three or none, read only
|
|
66
69
|
* through `blobExchangeOf` in `session-sync.ts`, which defers to core's judge) with ONE narrowing: a `put` refusal may carry
|
|
67
70
|
* `blobCap`, the SQL blob judge's refusal on the connection that would have written the blob
|
|
68
|
-
* ({@link import("
|
|
71
|
+
* ({@link import("../stores-sql/blob-index-sql.js").BlobTooLargeError}). Present ⟺ that refusal; `PUT /sync/blobs` answers it 413
|
|
69
72
|
* `blob_too_large_for_sql` (the judge's sentence, plus the machine-readable `wallSource` = where the cap came from). The content-address
|
|
70
73
|
* refusal is core's own (`adopt_failed`, `permanence: "terminal"`, nothing stored); every other failure is a write fault the route answers 502.
|
|
71
74
|
*/
|
|
@@ -75,7 +78,7 @@ export type SqlBlobPutResult = {
|
|
|
75
78
|
readonly ok: false;
|
|
76
79
|
readonly error: FileHistoryError & {
|
|
77
80
|
readonly blobCap?: {
|
|
78
|
-
readonly wallSource: import("
|
|
81
|
+
readonly wallSource: import("../stores-sql/blob-index-sql.js").SqlBlobCapReading["source"];
|
|
79
82
|
};
|
|
80
83
|
};
|
|
81
84
|
};
|
|
@@ -92,7 +95,7 @@ export type ServiceFileHistoryStore = FileHistoryStore & {
|
|
|
92
95
|
* protected — never a synchronous external-store delete). Reaper-driven; SQL twins only. */
|
|
93
96
|
sweepOrphanBlobs?(): Promise<number>;
|
|
94
97
|
};
|
|
95
|
-
/** SVC-2 (core CORE-7) WorkflowJournalStore — core's interface PLUS the service
|
|
98
|
+
/** SVC-2 (core CORE-7) WorkflowJournalStore — core's interface PLUS the service read page and age sweep below. tidb/pg =
|
|
96
99
|
* durable SQL twins (cross-replica resume journal); local = the service {@link FileWorkflowJournalStore}
|
|
97
100
|
* (single-box but RESTART-durable crash-safe JSONL, replacing core's InMemory). The shared equivalence suite keeps
|
|
98
101
|
* all three byte-matched (scope guard / idempotent-per-ordinal / oversize **refusal** —— [ref] / core 7.12.0
|
|
@@ -111,11 +114,14 @@ export type ServiceWorkflowJournalStore = WorkflowJournalStore & {
|
|
|
111
114
|
resultJson: string | null;
|
|
112
115
|
resultBytes: number;
|
|
113
116
|
}>>;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*
|
|
117
|
+
/** SVC-2 GC sweep (durable twins only): purge entries older than `maxAgeMs` — the `workflow-journal-expired` leg of the backend sweep verb
|
|
118
|
+
* (`plugins/store-sweep.ts`, composed in `boot/stores.ts`) bounds the TaskResult-bearing table with it; the journal's one delete path (no per-run
|
|
119
|
+
* delete: the engine contract never had one). Local File / InMemory omit it. */
|
|
117
120
|
reapExpired?(now: number, maxAgeMs: number): Promise<number>;
|
|
118
121
|
};
|
|
122
|
+
/** 本部署有没有 workflow journal 店、是哪一只 —— 唯一读法:开了 self-orchestration 且有后端 ⇒ 后端的 journal 店,否则无。
|
|
123
|
+
* 两处读者同读它:workflow 编排段(交 Runner 与 journal HTTP 读面的那只)与持久层组合点(按龄清扫动词的 `workflow-journal-expired` 腿)。 */
|
|
124
|
+
export declare function workflowJournalOf(config: Pick<ServiceConfig, "selfOrchestrationEnabled">, backend: Pick<StoreBackend, "workflowJournal"> | undefined): ServiceWorkflowJournalStore | undefined;
|
|
119
125
|
export type ImageIndex = TiDBImageIndex | PgImageIndex;
|
|
120
126
|
export type ImageBake = TiDBImageBake | PgImageBake;
|
|
121
127
|
/** [ref] 车4 件1:durable leader-run 登记表的双方言孪生(union 同族——TS 私有字段让具体类名义上不同)。 */
|
|
@@ -160,7 +166,8 @@ export interface StoreBackend {
|
|
|
160
166
|
* schema that the one-time migrations of server 7.74.0–7.125.x retired and **refuses** with `RetiredSchemaPresentError`
|
|
161
167
|
* (code `config.schema_mismatch`, exported from the package root) before it issues the first CREATE; only then does it create.
|
|
162
168
|
* The check lives in this method itself, so the public sequence `createStoreBackend()` → `ensureSchema()` → `runOneTimeMigrations()`
|
|
163
|
-
* needs no step of its own. The LOCAL backend has no SQL pool
|
|
169
|
+
* needs no step of its own. The LOCAL backend has no SQL pool: its data root's engine high-water is judged when the backend is opened (before any store is built),
|
|
170
|
+
* and a data root refused there surfaces here, as that refusal; otherwise this runs the local reconciliation (strict sidecars, archive snapshots). */
|
|
164
171
|
ensureSchema(): Promise<void>;
|
|
165
172
|
close(): Promise<void>;
|
|
166
173
|
run(): RunStore;
|
|
@@ -280,9 +287,9 @@ export interface StoreBackend {
|
|
|
280
287
|
* until a 2026-07-25 doc-rot sweep caught it). core 1.145.0 added the seam this comment was waiting for:
|
|
281
288
|
* `RunnerDeps.workflowJournalStore` (now `@sema-agent/core` `dist/core/types.d.ts`) + `journalStore` on the
|
|
282
289
|
* run_workflow tool deps (`dist/orchestration/run-workflow-tool.d.ts`), and the boot chain consumes it
|
|
283
|
-
* end-to-end: built in `boot/workflow-orchestration.ts
|
|
284
|
-
* threaded into RunnerDeps (`boot/runner-deps.ts` 的 `workflowJournalStore`),
|
|
285
|
-
* (`boot/
|
|
290
|
+
* end-to-end: selected by {@link workflowJournalOf} (self-orchestration on ∧ a backend), built in `boot/workflow-orchestration.ts`,
|
|
291
|
+
* threaded into RunnerDeps (`boot/runner-deps.ts` 的 `workflowJournalStore`), aged out by the backend sweep verb's `workflow-journal-expired`
|
|
292
|
+
* leg (`boot/stores.ts`, same selector), and read by `GET /v1/workflows/:id/journal` (`http/routes/workflows.ts`, [ref]). */
|
|
286
293
|
workflowJournal(): ServiceWorkflowJournalStore;
|
|
287
294
|
/** [ref] §1 consumption sink for `RunnerDeps.onTaskOutcome` facts. REQUIRED on all backends:
|
|
288
295
|
* tidb/pg = the outcome-ledger twins (SQL rows, mapped via coreOutcomeToLedgerRow + verbatim core_outcome
|
|
@@ -351,7 +358,7 @@ export interface StoreBackend {
|
|
|
351
358
|
* `local` 刻意省略 —— 与 {@link leaderRun} 逐字同一条理由:config 层已经把「`REMOTE_EXEC=device` 且
|
|
352
359
|
* 无外部 SQL 店」整个组合拒启了(`device-durable-store` 不变量),所以 local 车道上根本不存在一个需要
|
|
353
360
|
* 这四张表的 device worker。消费点按 `backend?.device?.()` 取,缺席 ⇒ `boot/device-lane.ts` 的
|
|
354
|
-
* `assertDeviceLaneWired` 响亮拒启(
|
|
361
|
+
* `assertDeviceLaneWired` 响亮拒启(**不是**静默跑成无手)。
|
|
355
362
|
*/
|
|
356
363
|
device?(): DeviceStore;
|
|
357
364
|
/**
|
|
@@ -361,9 +368,9 @@ export interface StoreBackend {
|
|
|
361
368
|
*
|
|
362
369
|
* `taskAttachmentTable` 必填、无默认值 —— boot 只在配了对象存储时才 ensure 那张表,一条盲发的
|
|
363
370
|
* DELETE 在无 MinIO 的部署上会以 unknown-table 打红整轮 sweep(理由逐字见
|
|
364
|
-
* `retention-
|
|
371
|
+
* `retention-deployment.ts` 的 `RetentionExecutorOptions`)。组合形见 {@link createSqlRetentionExecutor}。
|
|
365
372
|
*/
|
|
366
|
-
retention?(opts:
|
|
373
|
+
retention?(opts: RetentionExecutorOptions): RetentionExecutor;
|
|
367
374
|
/**
|
|
368
375
|
* [ref] 车2 —— 留存执行面的**非破坏性**半场:sweep 租约、legal-hold 的放置/解除、审计表的读与
|
|
369
376
|
* 非破坏行的写。同样 SQL 专有(它写的三张表只在 SQL schema 里)。
|
|
@@ -400,6 +407,23 @@ export interface StoreBackend {
|
|
|
400
407
|
* `new FileUsageWindowStore(root)` 第二只实例、不接座 ⇒ 坏值只拒不披露,运维找不到是哪只文件。SQL 后端省略(它们有自己的 usage-window 双方言店)。 */
|
|
401
408
|
fileUsageWindowStore?(): UsageWindowStore;
|
|
402
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* 托管留存执行器的**组合**:引擎座表那一半(`SqlRetentionStore`,事务属主)+ 部署那一半(hold / 审计 / 认领判 / 十一张部署表,
|
|
412
|
+
* `plugins/retention-deployment.ts`,经 K4 事务内钩参与同一事务)。
|
|
413
|
+
*
|
|
414
|
+
* 破坏性三方法**每次调用**铸一只执行器、钩表绑这一次调用(`createRetentionDeploymentHooks` 的头注:审计行的判定时点三格与
|
|
415
|
+
* `checkpoint_ctx` 属主门的域是这一次调用的事实)。会话树删除的 `endedSpaces` 由部署从 `beforeDelete` 收到的行自算,
|
|
416
|
+
* 只在执行器**提交成功返回之后**挂上回执(回滚 ⇒ 执行器抛,不挂)。非破坏两口(域枚举 / 预览)不经钩。
|
|
417
|
+
*/
|
|
418
|
+
/**
|
|
419
|
+
* 一次破坏性调用的整张事务内钩表:部署的 `retention` 组(按这一次调用铸,`createRetentionDeploymentHooks`)+ 会话座的钩
|
|
420
|
+
* (`createSqlSessionWriteHooks`,会话店用的同一只工厂;留存删除走它的 `retention-delete` 臂)。`endedSpaces` 读部署那一半收到的行。
|
|
421
|
+
*/
|
|
422
|
+
export declare function createSqlRetentionCallHooks(db: SqlDriver, opts: RetentionExecutorOptions, input: RetentionDestructiveInput): {
|
|
423
|
+
readonly hooks: SqlTransactionHooks;
|
|
424
|
+
endedSpaces(): readonly EndedSpace[];
|
|
425
|
+
};
|
|
426
|
+
export declare function createSqlRetentionExecutor(db: SqlDriver, opts: RetentionExecutorOptions): RetentionExecutor;
|
|
403
427
|
/** (c)(clay 拍 a+c,2026-07-27;[ref] 换店后域=file_history_blob,门与旋钮名不变)云形 blob 姿势门——
|
|
404
428
|
* boot 时调用(boot/stores.ts),纯函数可单测。SQL 后端(mysql|pg)把 blob 字节落单行的形已被两役
|
|
405
429
|
* 实证撞 mysql-协议包墙(D-1 附件 → 对象存储裁定):大字节归对象存储。per-file 历史的 blob=单文件
|
|
@@ -468,7 +492,13 @@ export declare function createStoreBackend(config: ServiceConfig, onWarn?: BootL
|
|
|
468
492
|
* 而 LocalBackend 的 `ensureSchema` 是**空实现**,真正会抛的 mkdir + 数据根 BootLock 在构造函数里、
|
|
469
493
|
* 落在 try 之外。于是那条降级臂对 local 形从来没生效过,注释宣称的行为与代码真做的事撕裂。
|
|
470
494
|
*
|
|
471
|
-
* **降级臂只有一条:缺省推导的 local
|
|
495
|
+
* **降级臂只有一条:缺省推导的 local 且数据根上什么都没有**(`dbBackend=local && !dbBackendExplicit`,数据根不存在或是空目录 —— 开店之前判)。
|
|
496
|
+
* 判据看的是**数据根的状态**,不是错误的种类:数据根上已有东西 ⇒ 这台部署有过持久面,开它时的**任何**失败(权限 / 只读挂载 / 子目录建不出 /
|
|
497
|
+
* 另一实例持锁 / adoption 在飞 / 账本重放不了 …)都按显式 `DB_BACKEND=local` 同待遇 —— 原样抛、拒启,不退内存(退了 = 已有的会话 / run 账本 /
|
|
498
|
+
* 问账整片看不见、新写只进内存,而 `/health` 照样 200)。只有「数据根不存在 / 空」那一形是「这台机器存不了盘」的诚实等价物,才许退内存 + 一行 warn。
|
|
499
|
+
* 修前按错误种类逐个豁免(adoption 一条、File 店族拒启一条、再往各店构造器里逐处包),漏一处就是一条 fail-open;按状态判之后,新店的新失败默认落在拒启一侧。
|
|
500
|
+
* 1.292 的口径据此收窄:只读挂载 / 建不出的根**在空 / 不存在时**仍退内存;已有数据的根拒启(出路:修好权限 / 挂载 / 停掉持锁的另一实例;要内存就显式写
|
|
501
|
+
* `DB_BACKEND=memory`;要另起一个空根就把 `LOCAL_DATA_ROOT` 指过去)。🔴 **SQL 族没有降级臂** —— 配了 DSN 就是要这只库:
|
|
472
502
|
* `SESSION_BACKEND=auto` 与显式 `DB_BACKEND=mysql|pg` 同一待遇,库当下打不开 ⇒ 在 `STORE_LOCK_WAIT_MS` 的窗内重试
|
|
473
503
|
* ({@link openWithinWait}),到窗仍打不开 ⇒ 拒启(拒句 {@link buildSqlStoreOpenRefusal} 点名后端与库的显示安全形)。修前 `auto` 在这里
|
|
474
504
|
* 静默落内存(只留一行 warn):会话 / 停驻 / run 账本进进程内存、重启即丢,而 `/health` 照样 200 —— [ref] P 类 fail-open。
|