@sema-agent/server 7.147.0 → 7.149.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 +1468 -24
- package/README.md +35 -7
- package/README.zh-CN.md +18 -8
- package/USAGE.md +444 -193
- package/deploy/sema-up/README.md +16 -5
- package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
- package/deploy/sema-up/chart/templates/_helpers.tpl +20 -4
- package/deploy/sema-up/chart/values.yaml +3 -2
- package/deploy/sema-up/cluster-up.sh +74 -176
- package/deploy/sema-up/kube-up.sh +29 -49
- package/deploy/sema-up/lib/chart-run.sh +23 -0
- package/deploy/sema-up/lib/dataroot.sh +3 -3
- package/deploy/sema-up/lib/health.sh +62 -13
- package/deploy/sema-up/lib/helm-values-cluster.py +18 -0
- package/deploy/sema-up/lib/helm-values-kube.py +35 -0
- package/deploy/sema-up/lib/regcred.py +8 -0
- package/deploy/sema-up/lib/remote/helm-install.sh +3 -0
- package/deploy/sema-up/lib/remote/image-import.sh +6 -0
- package/deploy/sema-up/lib/remote/machine-precheck.sh +11 -0
- package/deploy/sema-up/lib/remote/region-probe.sh +3 -0
- package/deploy/sema-up/lib/remote/stack-ready.sh +26 -0
- package/deploy/sema-up/lib/remote/vxlan-guard.sh +8 -0
- package/deploy/sema-up/lib/render-stack.py +17 -0
- package/deploy/sema-up/lib/shell-text.sh +87 -0
- package/deploy/sema-up/lib/usage-flags.txt +10 -0
- package/deploy/sema-up/lib/usage-head.txt +1 -0
- package/deploy/sema-up/lib/usage-tail.txt +13 -0
- package/deploy/sema-up/preflight.sh +10 -8
- package/deploy/sema-up/sema-up.sh +14 -39
- package/deploy/sema-up/smoke.sh +7 -6
- package/deploy/sema-up/stack/compose.dataroot.yaml +3 -0
- package/deploy/sema-up/stack/compose.yaml +13 -1
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +21 -0
- package/dist/adoption/plan.d.ts +24 -0
- package/dist/adoption/plan.js +53 -1
- package/dist/adoption/runner.d.ts +10 -1
- package/dist/adoption/runner.js +36 -16
- package/dist/approval-card.d.ts +36 -38
- package/dist/approval-gate-currency.js +3 -2
- package/dist/approval-leg-origin.d.ts +33 -0
- package/dist/approval-leg-origin.js +4 -0
- package/dist/approval-reconciler.d.ts +4 -13
- package/dist/approval-reconciler.js +2 -2
- package/dist/approval.d.ts +13 -11
- package/dist/approval.js +3 -3
- package/dist/audit.d.ts +10 -3
- package/dist/audit.js +15 -7
- package/dist/auth-bridge.d.ts +9 -15
- package/dist/auth-bridge.js +4 -11
- package/dist/auth-keys.d.ts +10 -1
- package/dist/auth-keys.js +8 -0
- package/dist/auto-mode-face.d.ts +10 -7
- package/dist/auto-mode-face.js +7 -4
- package/dist/background-agent-name.d.ts +19 -1
- package/dist/background-agent-name.js +12 -2
- package/dist/background-session-reap.d.ts +1 -1
- package/dist/bake-runner/main.js +9 -6
- package/dist/bench/s1/arms.js +6 -5
- package/dist/bench/s1/live-deps.js +5 -2
- package/dist/bench/s1/run-firm.js +6 -5
- package/dist/bind-host.d.ts +25 -0
- package/dist/bind-host.js +25 -0
- package/dist/boot/adoption.d.ts +3 -0
- package/dist/boot/adoption.js +1 -0
- package/dist/boot/deployment-mods.d.ts +1 -1
- package/dist/boot/execution-env.d.ts +17 -7
- package/dist/boot/execution-env.js +47 -42
- package/dist/boot/execution-lane.d.ts +6 -4
- package/dist/boot/execution-lane.js +3 -1
- package/dist/boot/exit-boundary.d.ts +2 -2
- package/dist/boot/exit-boundary.js +6 -5
- package/dist/boot/fatal-exit.d.ts +3 -5
- package/dist/boot/fatal-exit.js +2 -2
- package/dist/boot/leader.d.ts +15 -0
- package/dist/boot/leader.js +17 -15
- package/dist/boot/memory-consolidation.d.ts +37 -29
- package/dist/boot/memory-consolidation.js +11 -5
- package/dist/boot/org-delivery.d.ts +3 -2
- package/dist/boot/org-memory.js +1 -1
- package/dist/boot/parked-revive-gate.js +2 -2
- package/dist/boot/reapers.d.ts +4 -3
- package/dist/boot/reapers.js +19 -16
- package/dist/boot/resolve-spec.d.ts +5 -3
- package/dist/boot/resolve-spec.js +60 -70
- package/dist/boot/retention-lane.d.ts +4 -4
- package/dist/boot/retention-lane.js +2 -2
- package/dist/boot/runner-deps.d.ts +28 -7
- package/dist/boot/runner-deps.js +14 -5
- package/dist/boot/runtime-caps.d.ts +2 -2
- package/dist/boot/runtime-caps.js +16 -2
- package/dist/boot/session-faces.d.ts +16 -7
- package/dist/boot/session-faces.js +114 -94
- package/dist/boot/shutdown.d.ts +5 -4
- package/dist/boot/shutdown.js +6 -4
- package/dist/boot/stage-01-config.d.ts +1 -0
- package/dist/boot/stage-01-config.js +13 -4
- package/dist/boot/stage-02-web-admin-pull.d.ts +2 -0
- package/dist/boot/stage-02-web-admin-pull.js +16 -3
- package/dist/boot/stage-03-store-backend.d.ts +4 -0
- package/dist/boot/stage-03-store-backend.js +4 -3
- package/dist/boot/stage-04-stores.d.ts +3 -0
- package/dist/boot/stage-04-stores.js +2 -2
- package/dist/boot/stage-05-execution-env.d.ts +8 -3
- package/dist/boot/stage-05-execution-env.js +2 -2
- package/dist/boot/stage-06-runners.d.ts +12 -13
- package/dist/boot/stage-06-runners.js +23 -15
- package/dist/boot/stage-07-capability-layer.d.ts +13 -9
- package/dist/boot/stage-07-capability-layer.js +5 -3
- package/dist/boot/stage-08-reapers.d.ts +13 -9
- package/dist/boot/stage-08-reapers.js +3 -3
- package/dist/boot/stage-09-leader.d.ts +14 -16
- package/dist/boot/stage-09-leader.js +12 -4
- package/dist/boot/stage-10-http-server.d.ts +14 -16
- package/dist/boot/stage-10-http-server.js +7 -4
- package/dist/boot/store-evidence.d.ts +20 -0
- package/dist/boot/store-evidence.js +13 -0
- package/dist/boot/stores.d.ts +6 -0
- package/dist/boot/stores.js +41 -27
- package/dist/boot/task-list-lane.d.ts +4 -4
- package/dist/boot/web-admin.d.ts +4 -2
- package/dist/boot/web-admin.js +55 -35
- package/dist/boot/webfetch-summarize-lane.d.ts +1 -1
- package/dist/boot-reclaim.d.ts +3 -1
- package/dist/boot-reclaim.js +1 -1
- package/dist/brain.d.ts +7 -18
- package/dist/brain.js +5 -17
- package/dist/budget.js +6 -6
- package/dist/capabilities/center-plugins.d.ts +7 -1
- package/dist/capabilities/center-plugins.js +32 -10
- package/dist/capabilities/center-wiring.js +1 -1
- package/dist/capabilities/composite-members.d.ts +2 -2
- package/dist/capabilities/composite-members.js +2 -2
- package/dist/capabilities/repo-tools.d.ts +2 -0
- package/dist/capabilities/repo-tools.js +14 -12
- package/dist/capabilities/scenarios.d.ts +6 -15
- package/dist/capabilities/scenarios.js +11 -16
- package/dist/capabilities/skills.d.ts +1 -1
- package/dist/capabilities/tool-defer.d.ts +1 -1
- package/dist/capability-facts.d.ts +39 -11
- package/dist/capability-facts.js +35 -7
- package/dist/card-settle-stored-scope.d.ts +56 -0
- package/dist/card-settle-stored-scope.js +27 -0
- package/dist/card-void.d.ts +8 -13
- package/dist/card-void.js +2 -7
- package/dist/center-credential-renewer.d.ts +6 -2
- package/dist/center-credential-renewer.js +7 -3
- package/dist/config-catalog.d.ts +28 -1
- package/dist/config-catalog.js +95 -85
- package/dist/config-dir-trust.d.ts +37 -4
- package/dist/config-dir-trust.js +88 -44
- package/dist/config-invariants.d.ts +43 -3
- package/dist/config-invariants.js +69 -5
- package/dist/config-lkg.d.ts +23 -1
- package/dist/config-lkg.js +17 -3
- package/dist/config-provider.d.ts +9 -9
- package/dist/config-provider.js +25 -110
- package/dist/config-pull-failure.d.ts +50 -0
- package/dist/config-pull-failure.js +48 -0
- package/dist/config-types.d.ts +62 -21
- package/dist/config.d.ts +14 -21
- package/dist/config.js +141 -64
- package/dist/context-window-notice.d.ts +31 -0
- package/dist/context-window-notice.js +28 -0
- package/dist/delegated-session-owner.d.ts +1 -1
- package/dist/deleted-session-ids.d.ts +3 -2
- package/dist/deployment-governance.d.ts +3 -3
- package/dist/deployment-shape.d.ts +46 -11
- package/dist/deployment-shape.js +8 -0
- package/dist/egress-redirect.d.ts +25 -7
- package/dist/egress-redirect.js +20 -2
- package/dist/elicitation.d.ts +6 -5
- package/dist/elicitation.js +23 -22
- package/dist/engine-identity.d.ts +28 -0
- package/dist/engine-identity.js +10 -0
- package/dist/entry-problems.d.ts +5 -7
- package/dist/entry-problems.js +1 -1
- package/dist/env-facts.js +2 -1
- package/dist/env-name-allowlist-knobs.d.ts +6 -5
- package/dist/env-name-allowlist-knobs.js +5 -0
- package/dist/env-witness.d.ts +7 -0
- package/dist/env-witness.js +16 -0
- package/dist/execution-lane-caps.d.ts +25 -23
- package/dist/execution-lane-caps.js +18 -26
- package/dist/execution-placement.d.ts +58 -18
- package/dist/execution-placement.js +41 -2
- package/dist/field-conflict.d.ts +7 -11
- package/dist/field-conflict.js +3 -3
- package/dist/file-history-capture.d.ts +3 -3
- package/dist/file-history-disclosure.js +1 -0
- package/dist/fleet/fleet-bus.d.ts +21 -3
- package/dist/fleet/fleet-bus.js +35 -25
- package/dist/fleet/fleet-reconciler.js +2 -2
- package/dist/fleet/serving-lease.js +3 -3
- package/dist/fleet-client.js +3 -3
- package/dist/fleet-lease.d.ts +0 -1
- package/dist/fleet-lease.js +4 -5
- package/dist/history-anchor.d.ts +23 -3
- package/dist/history-anchor.js +24 -4
- package/dist/hitl-delivery.d.ts +90 -0
- package/dist/hitl-delivery.js +98 -0
- package/dist/hooks/classic-stations.d.ts +8 -11
- package/dist/hooks/classic-stations.js +0 -7
- package/dist/hooks/command-spawn.d.ts +7 -2
- package/dist/hooks/command-spawn.js +13 -6
- package/dist/hooks/hook-llm.d.ts +5 -1
- package/dist/hooks/hook-llm.js +24 -15
- package/dist/hooks/hook-runner.d.ts +72 -57
- package/dist/hooks/hook-runner.js +271 -193
- package/dist/host-lsp-manager.d.ts +22 -8
- package/dist/host-lsp-manager.js +4 -1
- package/dist/http/active-run-conflict.d.ts +2 -43
- package/dist/http/active-run-conflict.js +3 -7
- package/dist/http/admission.d.ts +4 -18
- package/dist/http/admission.js +76 -79
- package/dist/http/approval-sweeps.d.ts +3 -3
- package/dist/http/approval-sweeps.js +56 -31
- package/dist/http/caller-trust.d.ts +8 -10
- package/dist/http/caller-trust.js +1 -2
- package/dist/http/claim-heartbeat.d.ts +49 -0
- package/dist/http/claim-heartbeat.js +46 -0
- package/dist/http/claimed-run.d.ts +16 -8
- package/dist/http/claimed-run.js +8 -0
- package/dist/http/dispatch.d.ts +8 -1
- package/dist/http/dispatch.js +78 -30
- package/dist/http/durable-run-leg.d.ts +11 -4
- package/dist/http/durable-run-leg.js +45 -21
- package/dist/http/execution-context.d.ts +122 -47
- package/dist/http/execution-context.js +135 -43
- package/dist/http/health-reader.d.ts +36 -0
- package/dist/http/health-reader.js +21 -0
- package/dist/http/health-self-report.d.ts +9 -9
- package/dist/http/health-self-report.js +4 -4
- package/dist/http/idempotency.d.ts +9 -5
- package/dist/http/idempotency.js +4 -4
- package/dist/http/memory-compliance-failure-reply.d.ts +15 -16
- package/dist/http/memory-compliance-failure-reply.js +4 -2
- package/dist/http/memory-face-fault-reply.d.ts +67 -0
- package/dist/http/memory-face-fault-reply.js +71 -0
- package/dist/http/memory-store-refusal-reply.d.ts +1 -1
- package/dist/http/memory-store-refusal-reply.js +3 -0
- package/dist/http/owner-access.d.ts +392 -67
- package/dist/http/owner-access.js +370 -35
- package/dist/http/principal-gate.d.ts +39 -89
- package/dist/http/principal-gate.js +26 -68
- package/dist/http/refusal-body.d.ts +35 -2
- package/dist/http/refusal-body.js +34 -0
- package/dist/http/request-guards.d.ts +9 -13
- package/dist/http/request-guards.js +34 -68
- package/dist/http/resume-composition.d.ts +37 -0
- package/dist/http/resume-composition.js +18 -0
- package/dist/http/resume-ctx-read.d.ts +46 -12
- package/dist/http/resume-ctx-read.js +31 -6
- package/dist/http/resume-legs.d.ts +54 -19
- package/dist/http/resume-legs.js +408 -196
- package/dist/http/retired-skill-manifest.d.ts +1 -1
- package/dist/http/route-ctx.d.ts +31 -32
- package/dist/http/routes/a2a-serve.d.ts +43 -5
- package/dist/http/routes/a2a-serve.js +60 -37
- package/dist/http/routes/admin-config-refresh.js +2 -2
- package/dist/http/routes/admin-drain.js +2 -2
- package/dist/http/routes/admin-memory-optout.js +4 -3
- package/dist/http/routes/adoption.d.ts +3 -0
- package/dist/http/routes/adoption.js +17 -10
- package/dist/http/routes/agents-roster.js +13 -7
- package/dist/http/routes/approvals-assistant.js +73 -67
- package/dist/http/routes/attachments.js +2 -2
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/background.js +9 -17
- package/dist/http/routes/capabilities.js +16 -19
- package/dist/http/routes/config-catalog.js +2 -2
- package/dist/http/routes/devices.d.ts +3 -3
- package/dist/http/routes/devices.js +4 -4
- package/dist/http/routes/diagnostics.d.ts +29 -3
- package/dist/http/routes/diagnostics.js +49 -18
- package/dist/http/routes/engine.js +2 -2
- package/dist/http/routes/fleet.js +5 -3
- package/dist/http/routes/images.js +10 -6
- package/dist/http/routes/leader.d.ts +7 -2
- package/dist/http/routes/leader.js +12 -3
- package/dist/http/routes/mcp-reconnect.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +7 -15
- package/dist/http/routes/memory-bundle.js +4 -7
- package/dist/http/routes/memory-compliance.js +4 -4
- package/dist/http/routes/memory-consolidation.js +6 -9
- package/dist/http/routes/memory-origin.d.ts +2 -0
- package/dist/http/routes/memory-origin.js +7 -8
- package/dist/http/routes/memory-policy.js +17 -12
- package/dist/http/routes/notify-wake.js +10 -19
- package/dist/http/routes/observability.js +3 -3
- package/dist/http/routes/principal-inbox.d.ts +4 -2
- package/dist/http/routes/principal-inbox.js +5 -4
- package/dist/http/routes/projects.d.ts +1 -1
- package/dist/http/routes/projects.js +3 -2
- package/dist/http/routes/retention-ops.js +6 -9
- package/dist/http/routes/rules.js +20 -5
- package/dist/http/routes/run-memory-capture.d.ts +2 -2
- package/dist/http/routes/run-memory-capture.js +6 -12
- package/dist/http/routes/run-permission-mode.d.ts +2 -2
- package/dist/http/routes/run-permission-mode.js +10 -17
- package/dist/http/routes/runs.js +155 -237
- package/dist/http/routes/session-memory-sync.d.ts +2 -2
- package/dist/http/routes/session-memory-sync.js +7 -13
- package/dist/http/routes/session-sync.d.ts +28 -7
- package/dist/http/routes/session-sync.js +63 -50
- package/dist/http/routes/sessions-list.d.ts +3 -3
- package/dist/http/routes/sessions-list.js +9 -9
- package/dist/http/routes/sessions.js +87 -124
- package/dist/http/routes/shared-memory.js +6 -6
- package/dist/http/routes/side-query.js +2 -2
- package/dist/http/routes/tasks.js +237 -187
- package/dist/http/routes/trace-usage.d.ts +0 -12
- package/dist/http/routes/trace-usage.js +40 -46
- package/dist/http/routes/workflows.d.ts +39 -4
- package/dist/http/routes/workflows.js +42 -14
- package/dist/http/run-concurrency-cap.d.ts +20 -12
- package/dist/http/run-concurrency-cap.js +39 -26
- package/dist/http/run-read-face.d.ts +3 -5
- package/dist/http/run-read-face.js +8 -13
- package/dist/http/send.d.ts +12 -3
- package/dist/http/send.js +42 -6
- package/dist/http/server.d.ts +43 -45
- package/dist/http/server.js +61 -11
- package/dist/http/sse-log.d.ts +17 -10
- package/dist/http/sse-log.js +7 -7
- package/dist/http/stored-body-replay.d.ts +12 -0
- package/dist/http/stored-body-replay.js +2 -2
- package/dist/http/submit-ctx.d.ts +17 -8
- package/dist/http/submit-ctx.js +8 -5
- package/dist/http/submit-replay.d.ts +19 -6
- package/dist/http/submit-replay.js +18 -6
- package/dist/http/sync-submit-body.d.ts +3 -4
- package/dist/http/sync-submit-body.js +4 -5
- package/dist/http/wire-types.d.ts +4 -3
- package/dist/identity-source.d.ts +36 -5
- package/dist/identity-source.js +27 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -0
- package/dist/key-resolver.d.ts +32 -0
- package/dist/key-resolver.js +23 -9
- package/dist/leader/diffup.js +2 -1
- package/dist/leader/endpoint.d.ts +26 -5
- package/dist/leader/endpoint.js +154 -14
- package/dist/leader/fanout.d.ts +3 -0
- package/dist/leader/fanout.js +78 -63
- package/dist/leader/leader.d.ts +16 -0
- package/dist/leader/leader.js +43 -3
- package/dist/leader/merge.d.ts +9 -1
- package/dist/leader/merge.js +16 -1
- package/dist/leader/repair-wire.js +1 -1
- package/dist/leader/wire.d.ts +36 -3
- package/dist/leader/wire.js +59 -18
- package/dist/leg-facts.d.ts +7 -2
- package/dist/leg-facts.js +1 -0
- package/dist/local-store-declaration.d.ts +54 -0
- package/dist/local-store-declaration.js +59 -0
- package/dist/lsp-evict.d.ts +6 -4
- package/dist/lsp-evict.js +2 -3
- package/dist/mcp-assertion-header.d.ts +1 -1
- package/dist/mcp-assertion-header.js +1 -1
- package/dist/memory-operator-faces.d.ts +5 -4
- package/dist/memory-operator-faces.js +1 -1
- package/dist/memory-project-layer.js +1 -1
- package/dist/memory-scope.d.ts +33 -6
- package/dist/memory-scope.js +68 -19
- package/dist/memory-store-refusal.d.ts +5 -2
- package/dist/memory-sync-client.d.ts +3 -2
- package/dist/memory-sync-client.js +8 -5
- package/dist/model-compat.d.ts +17 -8
- package/dist/model-compat.js +6 -2
- package/dist/model-context-window.d.ts +57 -0
- package/dist/model-context-window.js +21 -0
- package/dist/model-entry-headers.d.ts +46 -4
- package/dist/model-entry-headers.js +2 -2
- package/dist/model-entry-refusal.d.ts +40 -20
- package/dist/model-entry-refusal.js +57 -30
- package/dist/model-plane-face.d.ts +19 -11
- package/dist/model-plane-face.js +9 -1
- package/dist/model-plane-probe.d.ts +2 -0
- package/dist/model-plane-probe.js +17 -0
- package/dist/model-provider.d.ts +3 -3
- package/dist/model-reach-scope.d.ts +2 -1
- package/dist/model-route-endpoint.d.ts +9 -5
- package/dist/model-route-endpoint.js +29 -7
- package/dist/model-select.d.ts +16 -0
- package/dist/model-select.js +4 -0
- package/dist/mountinfo.d.ts +37 -0
- package/dist/mountinfo.js +47 -0
- package/dist/namespaced-rule-name.d.ts +23 -14
- package/dist/namespaced-rule-name.js +8 -11
- package/dist/net-address.d.ts +1 -1
- package/dist/observability/corrupt-read-seat.d.ts +4 -4
- package/dist/observability/corrupt-read-seat.js +5 -3
- package/dist/observability/fail-open.d.ts +72 -40
- package/dist/observability/fail-open.js +74 -40
- package/dist/observability/logger.d.ts +22 -1
- package/dist/observability/logger.js +89 -12
- package/dist/observability/metrics.js +4 -5
- package/dist/observability/otel-exporter.js +2 -1
- package/dist/observability/principal-context.d.ts +14 -7
- package/dist/observability/principal-context.js +8 -3
- package/dist/observability/run-terminal.d.ts +7 -1
- package/dist/observability/run-terminal.js +6 -2
- package/dist/observability/secret-env-scrub.d.ts +1 -1
- package/dist/observability/secret-env-scrub.js +1 -1
- package/dist/orchestration/hardened-vm-runner.d.ts +1 -0
- package/dist/orchestration/hardened-vm-runner.js +11 -5
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +0 -14
- package/dist/orchestration/hardened-vm-worker-runner.js +5 -0
- package/dist/orchestration/hardened-vm-worker.js +2 -1
- package/dist/orchestration/workflow-completion-inbox.d.ts +3 -3
- package/dist/orchestration/workflow-completion-inbox.js +3 -2
- package/dist/org-delivery-gate.d.ts +36 -10
- package/dist/org-delivery-gate.js +12 -8
- package/dist/outbound-dispatcher.d.ts +1 -1
- package/dist/outbound-dispatcher.js +6 -12
- package/dist/owner-brands.d.ts +81 -0
- package/dist/owner-brands.js +42 -0
- package/dist/owner-faces.d.ts +532 -0
- package/dist/owner-faces.js +126 -0
- package/dist/park-row-commit.d.ts +67 -0
- package/dist/park-row-commit.js +76 -0
- package/dist/parked-decide.d.ts +76 -12
- package/dist/parked-decide.js +152 -11
- package/dist/parked-revive-surface.d.ts +14 -4
- package/dist/parked-revive-surface.js +5 -4
- package/dist/peer-directory.d.ts +7 -9
- package/dist/peer-directory.js +3 -2
- package/dist/permission-rule-vocab.d.ts +53 -8
- package/dist/permission-rule-vocab.js +30 -2
- package/dist/plugins/adoption-log-sql.d.ts +3 -25
- package/dist/plugins/adoption-log-sql.js +23 -21
- package/dist/plugins/approval-ask-retired-delete-by-task-m50.d.ts +7 -0
- package/dist/plugins/approval-ask-retired-delete-by-task-m50.js +17 -0
- package/dist/plugins/approval-ask-store-file.d.ts +18 -7
- package/dist/plugins/approval-ask-store-file.js +37 -14
- package/dist/plugins/approval-ask-store-memory.d.ts +12 -4
- package/dist/plugins/approval-ask-store-memory.js +24 -10
- package/dist/plugins/approval-ask-store-sql.d.ts +40 -21
- package/dist/plugins/approval-ask-store-sql.js +44 -15
- package/dist/plugins/approval-exemption-skill-cutoff.d.ts +64 -0
- package/dist/plugins/approval-exemption-skill-cutoff.js +122 -0
- package/dist/plugins/approval-exemption-skill-m46.d.ts +14 -0
- package/dist/plugins/approval-exemption-skill-m46.js +21 -0
- package/dist/plugins/approval-exemption-store.d.ts +32 -2
- package/dist/plugins/approval-exemption-store.js +42 -19
- package/dist/plugins/approval-nonce-store.d.ts +39 -12
- package/dist/plugins/approval-nonce-store.js +72 -23
- package/dist/plugins/blob-backend.d.ts +2 -0
- package/dist/plugins/blob-backend.js +9 -6
- package/dist/plugins/caching-session-store.d.ts +13 -1
- package/dist/plugins/caching-session-store.js +43 -4
- package/dist/plugins/checkpoint-index-columns.d.ts +32 -5
- package/dist/plugins/checkpoint-index-columns.js +36 -1
- package/dist/plugins/checkpoint-store-face.d.ts +83 -10
- package/dist/plugins/checkpoint-store-face.js +18 -1
- package/dist/plugins/device-store-sql.js +1 -0
- package/dist/plugins/ensure-index.d.ts +13 -1
- package/dist/plugins/ensure-index.js +154 -21
- package/dist/plugins/ensure-schema-lock-policy.d.ts +36 -18
- package/dist/plugins/ensure-schema-lock-policy.js +76 -9
- package/dist/plugins/file-run-store.d.ts +85 -32
- package/dist/plugins/file-run-store.js +177 -94
- package/dist/plugins/host-platform.d.ts +24 -3
- package/dist/plugins/host-platform.js +15 -1
- package/dist/plugins/image-bake-store-sql.js +2 -0
- package/dist/plugins/imported-layer-root-retirement.d.ts +2 -2
- package/dist/plugins/k8s-pod-reaper.d.ts +1 -3
- package/dist/plugins/k8s-pod-reaper.js +0 -1
- package/dist/plugins/leader-run-store-sql.d.ts +22 -0
- package/dist/plugins/leader-run-store-sql.js +34 -4
- package/dist/plugins/local-checkpoint-store.d.ts +62 -23
- package/dist/plugins/local-checkpoint-store.js +197 -77
- package/dist/plugins/local-data-dir-modes-m39.js +2 -1
- package/dist/plugins/local-data-root-admission.d.ts +52 -0
- package/dist/plugins/local-data-root-admission.js +100 -0
- package/dist/plugins/local-docker-capacity.d.ts +93 -0
- package/dist/plugins/local-docker-capacity.js +194 -0
- package/dist/plugins/local-docker-reaper.d.ts +92 -0
- package/dist/plugins/local-docker-reaper.js +102 -0
- package/dist/plugins/local-engine-high-water.d.ts +29 -6
- package/dist/plugins/local-engine-high-water.js +27 -19
- package/dist/plugins/local-session-store.d.ts +458 -140
- package/dist/plugins/local-session-store.js +906 -292
- package/dist/plugins/local-session-window.d.ts +3 -2
- package/dist/plugins/local-session-window.js +3 -2
- package/dist/plugins/local-sidecar-quarantine.js +3 -2
- package/dist/plugins/local-task-attachment-store.d.ts +18 -1
- package/dist/plugins/local-task-attachment-store.js +22 -1
- package/dist/plugins/memory-embedder.js +9 -7
- package/dist/plugins/memory-engine-pg.d.ts +3 -2
- package/dist/plugins/memory-engine-pg.js +14 -5
- package/dist/plugins/memory-engine-sql-apply.d.ts +8 -4
- package/dist/plugins/memory-engine-sql-apply.js +6 -8
- package/dist/plugins/memory-engine-tidb.d.ts +4 -2
- package/dist/plugins/memory-engine-tidb.js +11 -2
- package/dist/plugins/memory-optout-grant-store-sql.d.ts +1 -1
- package/dist/plugins/memory-optout-grant-store-sql.js +3 -3
- package/dist/plugins/memory-run-store.d.ts +53 -36
- package/dist/plugins/memory-run-store.js +116 -88
- package/dist/plugins/one-time-migration-marker.d.ts +26 -0
- package/dist/plugins/one-time-migration-marker.js +13 -0
- package/dist/plugins/one-time-migrations.d.ts +214 -47
- package/dist/plugins/one-time-migrations.js +481 -135
- package/dist/plugins/org-delivery-quota-store.d.ts +34 -11
- package/dist/plugins/org-delivery-quota-store.js +31 -15
- package/dist/plugins/permission-rule-store-file.d.ts +3 -3
- package/dist/plugins/permission-rule-store-sql.d.ts +5 -64
- package/dist/plugins/permission-rule-store-sql.js +11 -95
- package/dist/plugins/pg-pool.d.ts +2 -32
- package/dist/plugins/pg-pool.js +24 -17
- package/dist/plugins/remote-env-device.d.ts +3 -2
- package/dist/plugins/remote-env-e2b.d.ts +8 -32
- package/dist/plugins/remote-env-e2b.js +44 -32
- package/dist/plugins/remote-env-host.d.ts +51 -17
- package/dist/plugins/remote-env-host.js +111 -42
- package/dist/plugins/remote-env-k8s.d.ts +40 -45
- package/dist/plugins/remote-env-k8s.js +111 -60
- package/dist/plugins/remote-env-local-docker.d.ts +152 -15
- package/dist/plugins/remote-env-local-docker.js +352 -72
- package/dist/plugins/remote-scratchpad.js +4 -0
- package/dist/plugins/retention-deployment.d.ts +49 -17
- package/dist/plugins/retention-deployment.js +39 -8
- package/dist/plugins/run-preview-m45.d.ts +11 -0
- package/dist/plugins/run-preview-m45.js +19 -0
- package/dist/plugins/run-store-sql.d.ts +82 -75
- package/dist/plugins/run-store-sql.js +164 -125
- package/dist/plugins/s3-answer.d.ts +2 -1
- package/dist/plugins/sandbox-reaper.d.ts +26 -0
- package/dist/plugins/sandbox-reaper.js +2 -0
- package/dist/plugins/scenario-prefix-switch-m42.d.ts +56 -0
- package/dist/plugins/scenario-prefix-switch-m42.js +56 -0
- package/dist/plugins/scheduler-support.d.ts +16 -1
- package/dist/plugins/scheduler-support.js +22 -2
- package/dist/plugins/schema-consistency.d.ts +131 -14
- package/dist/plugins/schema-consistency.js +388 -18
- package/dist/plugins/schema-drift-sentence.d.ts +10 -6
- package/dist/plugins/schema-drift-sentence.js +15 -7
- package/dist/plugins/schema-ensure-legs.d.ts +9 -0
- package/dist/plugins/schema-ensure-legs.js +1 -1
- package/dist/plugins/schema-indexes.js +3 -0
- package/dist/plugins/schema-live-columns.d.ts +14 -5
- package/dist/plugins/schema-live-columns.js +10 -10
- package/dist/plugins/send-user-file.js +2 -1
- package/dist/plugins/session-birth.d.ts +37 -0
- package/dist/plugins/session-birth.js +38 -0
- package/dist/plugins/session-epoch-anchor.d.ts +40 -12
- package/dist/plugins/session-epoch-anchor.js +33 -11
- package/dist/plugins/session-ext-table.d.ts +27 -3
- package/dist/plugins/session-ext-table.js +19 -6
- package/dist/plugins/session-fork.d.ts +15 -1
- package/dist/plugins/session-fork.js +3 -0
- package/dist/plugins/session-ownership.d.ts +1 -1
- package/dist/plugins/session-placement.d.ts +27 -20
- package/dist/plugins/session-placement.js +15 -12
- package/dist/plugins/session-row-sql.d.ts +12 -0
- package/dist/plugins/session-row-sql.js +3 -3
- package/dist/plugins/session-run-rollup.d.ts +29 -0
- package/dist/plugins/session-run-rollup.js +40 -0
- package/dist/plugins/session-store-sql.d.ts +38 -12
- package/dist/plugins/session-store-sql.js +130 -30
- package/dist/plugins/session-withdraw-sql.d.ts +36 -0
- package/dist/plugins/session-withdraw-sql.js +42 -0
- package/dist/plugins/shared-memory-store-sql.d.ts +0 -69
- package/dist/plugins/shared-memory-store-sql.js +2 -1
- package/dist/plugins/shell-sentinel-owner-m48.d.ts +42 -0
- package/dist/plugins/shell-sentinel-owner-m48.js +9 -0
- package/dist/plugins/snapshot-bucket-presence.d.ts +2 -1
- package/dist/plugins/sql-driver.d.ts +1 -1
- package/dist/plugins/sql-driver.js +2 -1
- package/dist/plugins/sql-errors.d.ts +32 -5
- package/dist/plugins/sql-errors.js +55 -7
- package/dist/plugins/sql-json-column.d.ts +8 -7
- package/dist/plugins/sql-json-column.js +10 -6
- package/dist/plugins/stop-then-start-sentence.d.ts +16 -0
- package/dist/plugins/stop-then-start-sentence.js +7 -0
- package/dist/plugins/store-backend.d.ts +99 -16
- package/dist/plugins/store-backend.js +230 -65
- package/dist/plugins/store-contracts.d.ts +123 -33
- package/dist/plugins/store-contracts.js +38 -1
- package/dist/plugins/store-fault.d.ts +28 -2
- package/dist/plugins/store-fault.js +20 -2
- package/dist/plugins/task-attachment-store.d.ts +15 -3
- package/dist/plugins/task-attachment-store.js +22 -9
- package/dist/plugins/tidb-pool.d.ts +11 -6
- package/dist/plugins/tidb-pool.js +39 -18
- package/dist/plugins/web-search.js +5 -3
- package/dist/plugins/workflow-run-store-sql.d.ts +6 -1
- package/dist/plugins/workflow-run-store-sql.js +11 -5
- package/dist/plugins/workspace-custody.d.ts +44 -0
- package/dist/plugins/workspace-custody.js +47 -0
- package/dist/principal-jwt.d.ts +4 -4
- package/dist/principal-jwt.js +20 -5
- package/dist/principal-shape.d.ts +41 -0
- package/dist/principal-shape.js +19 -0
- package/dist/project-identity.d.ts +8 -7
- package/dist/project-identity.js +40 -17
- package/dist/project-layer-key.d.ts +13 -2
- package/dist/project-layer-key.js +9 -1
- package/dist/question.d.ts +13 -23
- package/dist/question.js +21 -39
- package/dist/read-deny-floor-notice.d.ts +36 -0
- package/dist/read-deny-floor-notice.js +40 -0
- package/dist/{plain-string-record.d.ts → request-declaration-disposition.d.ts} +9 -23
- package/dist/request-declaration-disposition.js +39 -0
- package/dist/request-declaration-refusal.d.ts +35 -12
- package/dist/request-declaration-refusal.js +21 -9
- package/dist/request-form.d.ts +58 -0
- package/dist/request-form.js +72 -0
- package/dist/request-image-urls.d.ts +8 -2
- package/dist/request-image-urls.js +2 -1
- package/dist/request-images.d.ts +20 -0
- package/dist/request-images.js +59 -0
- package/dist/request-key-closure.d.ts +6 -7
- package/dist/request-key-closure.js +15 -2
- package/dist/resource-suspend.d.ts +7 -16
- package/dist/resource-suspend.js +1 -1
- package/dist/retired-name-host-notice.d.ts +21 -0
- package/dist/retired-name-host-notice.js +12 -0
- package/dist/rule-entry-list.d.ts +2 -2
- package/dist/rule-entry-list.js +3 -4
- package/dist/rule-issue-reading.d.ts +58 -0
- package/dist/rule-issue-reading.js +14 -0
- package/dist/rules-consent.d.ts +5 -3
- package/dist/rules-consent.js +1 -0
- package/dist/run-acceptance.d.ts +3 -1
- package/dist/run-acceptance.js +3 -0
- package/dist/run-cancel-card.d.ts +28 -0
- package/dist/run-cancel-card.js +19 -0
- package/dist/run-cancel-context.d.ts +10 -0
- package/dist/run-cancel-context.js +1 -0
- package/dist/run-local.d.ts +14 -6
- package/dist/run-local.js +117 -90
- package/dist/run-stale-default.d.ts +7 -0
- package/dist/run-stale-default.js +2 -0
- package/dist/runs.d.ts +56 -21
- package/dist/runs.js +73 -43
- package/dist/runtime-caps-resolver.d.ts +21 -6
- package/dist/runtime-caps-resolver.js +17 -4
- package/dist/runtime-governance.d.ts +2 -2
- package/dist/runtime-governance.js +5 -3
- package/dist/sealed-key-layout.d.ts +12 -5
- package/dist/sealed-key-layout.js +5 -0
- package/dist/sealed-key.d.ts +12 -2
- package/dist/sealed-key.js +115 -27
- package/dist/security.d.ts +128 -158
- package/dist/security.js +163 -59
- package/dist/sema-config-dir.d.ts +20 -0
- package/dist/sema-config-dir.js +25 -0
- package/dist/server-secret-env.d.ts +55 -25
- package/dist/server-secret-env.js +75 -22
- package/dist/session-agent.d.ts +3 -2
- package/dist/session-children-retire.d.ts +13 -8
- package/dist/session-children-retire.js +9 -7
- package/dist/session-deletion.d.ts +88 -0
- package/dist/session-deletion.js +8 -0
- package/dist/session-erase.d.ts +145 -0
- package/dist/session-erase.js +115 -0
- package/dist/session-error-wire.d.ts +5 -5
- package/dist/session-error-wire.js +1 -1
- package/dist/session-incarnation.d.ts +52 -5
- package/dist/session-incarnation.js +19 -2
- package/dist/session-policy-wire.d.ts +6 -3
- package/dist/session-policy-wire.js +11 -1
- package/dist/session-resident-background.d.ts +0 -71
- package/dist/session-resident-background.js +4 -3
- package/dist/session-row.d.ts +2 -1
- package/dist/session-rules-seat.d.ts +12 -0
- package/dist/session-rules-seat.js +19 -0
- package/dist/session-titler.d.ts +7 -15
- package/dist/session-titler.js +1 -1
- package/dist/session-workspace.d.ts +3 -3
- package/dist/spec-fields.d.ts +57 -3
- package/dist/spec-fields.js +72 -51
- package/dist/store-admission.d.ts +33 -0
- package/dist/store-admission.js +49 -0
- package/dist/store-posture.d.ts +141 -20
- package/dist/store-posture.js +205 -3
- package/dist/stored-request-hooks-m20.js +2 -2
- package/dist/stores-sql/background-agent-store-sql.d.ts +11 -2
- package/dist/stores-sql/background-agent-store-sql.js +73 -20
- package/dist/stores-sql/checkpoint-store-sql.d.ts +34 -29
- package/dist/stores-sql/checkpoint-store-sql.js +78 -49
- package/dist/stores-sql/file-history-store-sql.d.ts +1 -1
- package/dist/stores-sql/file-history-store-sql.js +3 -5
- package/dist/stores-sql/mailbox-store-sql.d.ts +7 -4
- package/dist/stores-sql/mailbox-store-sql.js +31 -32
- package/dist/stores-sql/pg-session-storage.d.ts +7 -5
- package/dist/stores-sql/pg-session-storage.js +54 -46
- package/dist/stores-sql/retention-store-sql.d.ts +87 -19
- package/dist/stores-sql/retention-store-sql.js +92 -27
- package/dist/stores-sql/session-policy-store-sql.d.ts +32 -10
- package/dist/stores-sql/session-policy-store-sql.js +44 -36
- package/dist/stores-sql/session-write-hooks.d.ts +12 -6
- package/dist/stores-sql/tidb-session-storage.d.ts +4 -4
- package/dist/stores-sql/tidb-session-storage.js +13 -8
- package/dist/stores-sql/tidb-session-store.d.ts +36 -17
- package/dist/stores-sql/tidb-session-store.js +69 -39
- package/dist/stores-sql/tool-result-store-sql.d.ts +1 -1
- package/dist/stores-sql/tool-result-store-sql.js +4 -6
- package/dist/stores-sql/windowed-session-storage.d.ts +5 -0
- package/dist/stores-sql/windowed-session-storage.js +9 -0
- package/dist/submission-exit.d.ts +50 -0
- package/dist/submission-exit.js +108 -0
- package/dist/task-a2a.d.ts +3 -8
- package/dist/task-a2a.js +28 -30
- package/dist/task-cwd.d.ts +43 -7
- package/dist/task-cwd.js +11 -0
- package/dist/task-mcp.d.ts +3 -3
- package/dist/task-mcp.js +4 -4
- package/dist/task-settings.d.ts +14 -10
- package/dist/task-settings.js +19 -7
- package/dist/terminal.d.ts +27 -43
- package/dist/terminal.js +49 -14
- package/dist/tool-approval.d.ts +173 -163
- package/dist/tool-approval.js +247 -232
- package/dist/trace/core-keyset-guard.d.ts +13 -6
- package/dist/trace/core-vocab-wire.d.ts +95 -0
- package/dist/trace/core-vocab-wire.js +15 -0
- package/dist/trace/engine-notice-wire.d.ts +24 -21
- package/dist/trace/engine-notice-wire.js +7 -3
- package/dist/trace/exit-seat.d.ts +30 -4
- package/dist/trace/exit-seat.js +40 -36
- package/dist/trace/extension-call-face.d.ts +3 -2
- package/dist/trace/extension-call-face.js +3 -1
- package/dist/trace/ledger-events.d.ts +4 -7
- package/dist/trace/ledger-sink.d.ts +4 -31
- package/dist/trace/ledger-sink.js +0 -11
- package/dist/trace/model-segment.d.ts +5 -5
- package/dist/trace/model-segment.js +5 -5
- package/dist/trace/project.d.ts +59 -44
- package/dist/trace/project.js +60 -26
- package/dist/trace/redact.d.ts +135 -27
- package/dist/trace/redact.js +884 -260
- package/dist/trace/self-minted-wire.d.ts +567 -20
- package/dist/trace/self-minted-wire.js +205 -24
- package/dist/trace/wire-projection-faces.d.ts +5 -6
- package/dist/trace/wire-projection-faces.js +2 -2
- package/dist/upstream-body.d.ts +23 -0
- package/dist/upstream-body.js +16 -0
- package/dist/url-refusal.d.ts +3 -3
- package/dist/url-refusal.js +11 -4
- package/dist/user-authored-text.d.ts +1 -1
- package/dist/user-input-ledger.d.ts +7 -8
- package/dist/user-input-ledger.js +1 -1
- package/dist/web-admin-client/apply-effective.d.ts +6 -3
- package/dist/web-admin-client/apply-effective.js +33 -23
- package/dist/web-admin-client/apply-ledger.d.ts +16 -7
- package/dist/web-admin-client/apply-ledger.js +5 -2
- package/dist/web-admin-client/center-request.d.ts +2 -2
- package/dist/web-admin-client/center-request.js +15 -15
- package/dist/web-admin-client/effective-keys.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.js +1 -1
- package/dist/web-admin-client/entry-metadata.d.ts +8 -0
- package/dist/web-admin-client/entry-metadata.js +13 -0
- package/dist/web-admin-client/http-client.d.ts +1 -1
- package/dist/web-admin-client/http-client.js +23 -4
- package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
- package/dist/web-admin-client/mcp-revocation.js +2 -1
- package/dist/web-admin-client/read-warnings.d.ts +1 -0
- package/dist/web-admin-client/read-warnings.js +1 -0
- package/dist/web-admin-client/restart-signal.js +8 -4
- package/dist/web-admin-client/skills-mcp.d.ts +2 -2
- package/dist/web-admin-client/types.d.ts +1 -2
- package/dist/workspace-space.d.ts +3 -2
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +4 -4
- package/docs/error-text-lexicon.json +317 -0
- package/package.json +8 -3
- package/scripts/drain-check-local.mjs +118 -147
- package/scripts/drain-check.mysql.sql +22 -2
- package/scripts/drain-check.pg.sql +22 -2
- package/scripts/embed-minimal.mjs +183 -0
- package/wire-changes/server@7.148.0.json +1517 -0
- package/wire-changes/server@7.149.0.json +372 -0
- package/dist/http/memory-control-plane-corrupt-reply.d.ts +0 -25
- package/dist/http/memory-control-plane-corrupt-reply.js +0 -19
- package/dist/http/memory-layer-reply.d.ts +0 -30
- package/dist/http/memory-layer-reply.js +0 -24
- package/dist/lsp/e2b-bridge.d.ts +0 -57
- package/dist/lsp/e2b-bridge.js +0 -139
- package/dist/lsp/e2b-manager.d.ts +0 -93
- package/dist/lsp/e2b-manager.js +0 -178
- package/dist/lsp/lsp-frames.d.ts +0 -14
- package/dist/lsp/lsp-frames.js +0 -25
- package/dist/lsp/manager.d.ts +0 -129
- package/dist/lsp/manager.js +0 -127
- package/dist/lsp/types.d.ts +0 -12
- package/dist/lsp/types.js +0 -2
- package/dist/lsp/ws-transport.d.ts +0 -40
- package/dist/lsp/ws-transport.js +0 -210
- package/dist/plain-string-record.js +0 -70
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function readLiveColumns(read, dialect) {
|
|
2
2
|
const live = new Map();
|
|
3
3
|
if (dialect !== "pg") {
|
|
4
|
-
for (const row of await read("SELECT table_name AS t, column_name AS c FROM information_schema.columns WHERE table_schema = DATABASE()")) {
|
|
5
|
-
addColumn(live, row["t"], row["c"], "fold");
|
|
4
|
+
for (const row of await read("SELECT table_name AS t, column_name AS c, is_nullable AS n FROM information_schema.columns WHERE table_schema = DATABASE()")) {
|
|
5
|
+
addColumn(live, row["t"], row["c"], row["n"], "fold");
|
|
6
6
|
}
|
|
7
7
|
return live;
|
|
8
8
|
}
|
|
@@ -13,7 +13,7 @@ export async function readLiveColumns(read, dialect) {
|
|
|
13
13
|
order.set(s, Number(row["ord"]));
|
|
14
14
|
}
|
|
15
15
|
const winner = new Map();
|
|
16
|
-
for (const row of await read("SELECT table_schema AS s, table_name AS t, column_name AS c FROM information_schema.columns WHERE table_schema = ANY (current_schemas(false))")) {
|
|
16
|
+
for (const row of await read("SELECT table_schema AS s, table_name AS t, column_name AS c, is_nullable AS n FROM information_schema.columns WHERE table_schema = ANY (current_schemas(false))")) {
|
|
17
17
|
const t = String(row["t"] ?? "");
|
|
18
18
|
const rank = order.get(String(row["s"] ?? "")) ?? Number.MAX_SAFE_INTEGER;
|
|
19
19
|
const held = winner.get(t);
|
|
@@ -23,20 +23,20 @@ export async function readLiveColumns(read, dialect) {
|
|
|
23
23
|
winner.set(t, rank);
|
|
24
24
|
live.delete(t);
|
|
25
25
|
}
|
|
26
|
-
addColumn(live, t, row["c"], "verbatim");
|
|
26
|
+
addColumn(live, t, row["c"], row["n"], "verbatim");
|
|
27
27
|
}
|
|
28
28
|
return live;
|
|
29
29
|
}
|
|
30
|
-
function addColumn(live, table, column, mode) {
|
|
30
|
+
function addColumn(live, table, column, isNullable, mode) {
|
|
31
31
|
const t = mode === "fold" ? String(table ?? "").toLowerCase() : String(table ?? "");
|
|
32
32
|
const c = mode === "fold" ? String(column ?? "").toLowerCase() : String(column ?? "");
|
|
33
33
|
if (t === "" || c === "")
|
|
34
34
|
return;
|
|
35
|
-
let
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
live.set(t,
|
|
35
|
+
let columns = live.get(t);
|
|
36
|
+
if (columns === undefined) {
|
|
37
|
+
columns = new Map();
|
|
38
|
+
live.set(t, columns);
|
|
39
39
|
}
|
|
40
|
-
set
|
|
40
|
+
columns.set(c, { nullable: String(isNullable ?? "").toUpperCase() === "YES" });
|
|
41
41
|
}
|
|
42
42
|
//# sourceMappingURL=schema-live-columns.js.map
|
|
@@ -3,6 +3,7 @@ import { uuidv7 } from "@sema-agent/core";
|
|
|
3
3
|
import { stripControlAndBidi } from "@sema-agent/settings-schema";
|
|
4
4
|
import { presignS3CopyUrl, presignS3Url } from "./s3-presign.js";
|
|
5
5
|
import { OBJECT_STORE_IO_TIMEOUT_MS } from "./blob-backend.js";
|
|
6
|
+
import { createEgressFetch } from "../egress-redirect.js";
|
|
6
7
|
export const PRESIGN_MAX_TTL_SEC = 604_800;
|
|
7
8
|
export function scopeSegment(secretKey, scope) {
|
|
8
9
|
if (scope === undefined || scope === "")
|
|
@@ -27,7 +28,7 @@ export function sanitizeSendFileName(name) {
|
|
|
27
28
|
return clean.length > 0 ? clean : "file";
|
|
28
29
|
}
|
|
29
30
|
export function createSendUserFileIssuer(cfg, deps) {
|
|
30
|
-
const f = deps?.fetchImpl
|
|
31
|
+
const f = createEgressFetch("declare the final object-store address as MINIO_ENDPOINT / S3_ENDPOINT", deps?.fetchImpl);
|
|
31
32
|
const bounded = () => ({ signal: AbortSignal.timeout(OBJECT_STORE_IO_TIMEOUT_MS) });
|
|
32
33
|
const upload = deps?.upload ??
|
|
33
34
|
(async (bucket, key, bytes) => {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **会话的出生回执与条件撤回** —— 会话店交给提交出口(`src/submission-exit.ts`)的两张窄面。引擎的 `SessionStore` 接口一个字节不动
|
|
3
|
+
* (`register(): Promise<void>` 照旧);本服务的店在它旁边各多一只方法,包装 / 转发层逐个转发。
|
|
4
|
+
*
|
|
5
|
+
* ## 出生回执({@link SessionBirthFace.registerWithReceipt})
|
|
6
|
+
* 与 `register` 同一笔写、同一条首写律;**只有这一笔真建了新行**时交回候选化身({@link SessionBirth}:这一次 INSERT 的入参里铸的那一只,
|
|
7
|
+
* 不是登记之后的复读)。已在的行、并发登记里输的那一只 ⇒ 不交候选。出生事实不在这里判:撤回事务锁住根行之后读到的
|
|
8
|
+
* 化身**等于**候选,才是「这一次提交铸下了这只会话」(两只同属主的并发登记只有赢家的候选进了行)。
|
|
9
|
+
*
|
|
10
|
+
* ## 条件撤回({@link SessionWithdrawFace.withdrawBirth})
|
|
11
|
+
* 一只事务 / 一把根锁里:锁根行 → 行不在 ⇒ `absent`;化身或属主不是候选那一位 ⇒ `incarnation` → 有可撤集合之外的会话条目 ⇒ `content`
|
|
12
|
+
* → 认领在(判官 `judgeSessionWrite` 的 `delete` 臂)⇒ `claim` → 客户端写过(计数 > 0)⇒ `client_writes` → 有本次 run 之外的 run 行 ⇒ `runs`
|
|
13
|
+
* → 撤回出口还没启用(一次性迁移的标记未落)⇒ `upgrade_pending` → 否则删本次 run 的部署行 + 会话行(旁表随外键级联)。每一读都是**锁定读**
|
|
14
|
+
* (TiDB 悲观事务里普通 SELECT 读的是事务开始时的快照,看不到等锁期间提交的写;两方言一律 `FOR UPDATE`)。
|
|
15
|
+
*/
|
|
16
|
+
import type { SessionTreeEntry } from "@sema-agent/core";
|
|
17
|
+
import type { RegisterReceipt, SessionBirth, WithdrawOutcome } from "../session-incarnation.js";
|
|
18
|
+
/** 出生回执面(会话店的窄面;`register` 的同笔写形)。 */
|
|
19
|
+
export interface SessionBirthFace {
|
|
20
|
+
registerWithReceipt(sessionId: string, owner: string | null): Promise<RegisterReceipt>;
|
|
21
|
+
}
|
|
22
|
+
/** 条件撤回面(会话店的窄面;部署装配在店上,一只事务里判完、删完)。`ownTaskId` = 本次提交认领赢的那条 run(没有 ⇒ 缺)。 */
|
|
23
|
+
export interface SessionWithdrawFace {
|
|
24
|
+
withdrawBirth(birth: SessionBirth, ownTaskId: string | undefined): Promise<WithdrawOutcome>;
|
|
25
|
+
}
|
|
26
|
+
/** 店上的出生回执面(没有 ⇒ `undefined`:登记照走 `register`,不交候选 ⇒ 这只会话永不撤回)。 */
|
|
27
|
+
export declare function birthFaceOf(store: unknown): SessionBirthFace | undefined;
|
|
28
|
+
/** 店上的条件撤回面(没有 ⇒ `undefined`:候选不交给出口 ⇒ 永不撤回)。 */
|
|
29
|
+
export declare function withdrawFaceOf(store: unknown): SessionWithdrawFace | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* 可撤集合的 A 组:引擎在受理之前 / 收尾时写下的记账条目(不进模型上下文的那些型)。引擎的条目型闭集逐型判 —— 引擎加一型 ⇒ 这里编译红,
|
|
32
|
+
* 新型归哪一边由人定。`false` 的五型(消息 / 会进上下文的自定义消息 / 压缩 / 标签 / 会话信息)= 内容:有一条 ⇒ 留(`content`)。
|
|
33
|
+
*/
|
|
34
|
+
export declare function entryTypeWithdrawable(type: SessionTreeEntry["type"]): boolean;
|
|
35
|
+
/** A 组的型名单(SQL 锁定读的 `NOT IN` 参数;由 {@link entryTypeWithdrawable} 派生,不手写第二份)。 */
|
|
36
|
+
export declare const WITHDRAWABLE_ENTRY_TYPES: readonly SessionTreeEntry["type"][];
|
|
37
|
+
//# sourceMappingURL=session-birth.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function birthFaceOf(store) {
|
|
2
|
+
const s = store;
|
|
3
|
+
return typeof s?.registerWithReceipt === "function" ? { registerWithReceipt: s.registerWithReceipt.bind(s) } : undefined;
|
|
4
|
+
}
|
|
5
|
+
export function withdrawFaceOf(store) {
|
|
6
|
+
const s = store;
|
|
7
|
+
return typeof s?.withdrawBirth === "function" ? { withdrawBirth: s.withdrawBirth.bind(s) } : undefined;
|
|
8
|
+
}
|
|
9
|
+
export function entryTypeWithdrawable(type) {
|
|
10
|
+
switch (type) {
|
|
11
|
+
case "thinking_level_change":
|
|
12
|
+
case "model_change":
|
|
13
|
+
case "custom":
|
|
14
|
+
case "leaf":
|
|
15
|
+
case "prompt_epoch":
|
|
16
|
+
case "announced_listing":
|
|
17
|
+
case "git_announcement":
|
|
18
|
+
case "workspace_state":
|
|
19
|
+
case "session_checkout":
|
|
20
|
+
case "reminder_mark":
|
|
21
|
+
return true;
|
|
22
|
+
case "message":
|
|
23
|
+
case "custom_message":
|
|
24
|
+
case "compaction":
|
|
25
|
+
case "label":
|
|
26
|
+
case "session_info":
|
|
27
|
+
return false;
|
|
28
|
+
default: {
|
|
29
|
+
const unknownType = type;
|
|
30
|
+
throw new Error(`entryTypeWithdrawable: no entry type ${JSON.stringify(unknownType)}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export const WITHDRAWABLE_ENTRY_TYPES = [
|
|
35
|
+
"message", "thinking_level_change", "model_change", "compaction", "custom", "custom_message", "label", "session_info",
|
|
36
|
+
"leaf", "prompt_epoch", "announced_listing", "git_announcement", "workspace_state", "session_checkout", "reminder_mark",
|
|
37
|
+
].filter(entryTypeWithdrawable);
|
|
38
|
+
//# sourceMappingURL=session-birth.js.map
|
|
@@ -10,30 +10,58 @@
|
|
|
10
10
|
* storage for the nearest carrier BELOW the floor and reads it itself. The storage returns that record **as stored**:
|
|
11
11
|
* · a `prompt_epoch` entry ⇒ the whole entry (the engine's branch walk reads the whole entry too);
|
|
12
12
|
* · a compaction whose `details.promptEpoch` is present ⇒ that restatement;
|
|
13
|
-
* · a compaction without a restatement carries nothing ⇒ the scan
|
|
13
|
+
* · a compaction without a restatement carries nothing ⇒ the scan walks past it, to exhaustion (a session that lived
|
|
14
14
|
* across the release that introduced epochs can hold any number of them between the floor and its pin).
|
|
15
15
|
* The storage never judges the record's shape. The engine answers a current-shape record as a pin and a retired-shape
|
|
16
16
|
* record by name (`legacy`, with whether it pinned a center artifact) — a storage that normalized the record first would
|
|
17
17
|
* turn a session pinned under a retired shape into one with no pin, and the engine would then skip the center source's
|
|
18
18
|
* handling of that pin. A record that is neither is the engine's to read as well (it reads as no record).
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* ## "Below the floor" is the branch, not the log
|
|
21
|
+
* "Nearest below the floor" means nearest on the branch the run reads: the floor entry's parent, its parent, … to the root — the walk the
|
|
22
|
+
* engine's own `getPathToRoot` makes. The log also holds abandoned branches (a resumeAt moves the leaf in place and the next entries hang
|
|
23
|
+
* off an earlier entry): a record on one of them is not the run's, however near it is by position. So the scan follows parent links — a
|
|
24
|
+
* row is read only when it is the next ancestor; every other row is off the branch and passed. A log is append-only, so every ancestor sits
|
|
25
|
+
* at a lower position than its child: one newest-first pass over the positions below the floor meets the ancestors in order, and the scan
|
|
26
|
+
* stops at the first carrier on them (or at the root). The three storages share this walk; what they page differs only in where the rows
|
|
27
|
+
* live — the SQL twins page their `session_event` rows by `seq` (every row below the floor, the payload only on the two carrier types),
|
|
28
|
+
* the local window pages the branch it was cut from.
|
|
22
29
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
30
|
+
* No floor, or a floor at the root (a full load: the walk already reaches the root), or no carrier on the branch below the floor ⇒
|
|
31
|
+
* `undefined` (a session that predates epochs).
|
|
25
32
|
*/
|
|
26
33
|
import type { SessionTreeEntry } from "@sema-agent/core";
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
import type { SqlDialect } from "./sql-driver.js";
|
|
35
|
+
/** One row of a scan: its position (`seq`, the keyset cursor), its entry id, its parent and its type. The entry itself is read out of the row
|
|
36
|
+
* by the storage ({@link scanEpochAnchor}'s `entryOf`) only when the row is an ancestor of the floor and of a carrier type. */
|
|
29
37
|
export interface EpochAnchorRow {
|
|
30
38
|
readonly seq: string | number;
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly parentId: string | null;
|
|
41
|
+
readonly type: string;
|
|
31
42
|
}
|
|
43
|
+
/** Where the walk starts: the floor's position (rows below it have `seq < floor.seq`) and the floor entry's parent (`null` = the floor is the root). */
|
|
44
|
+
export interface EpochFloor {
|
|
45
|
+
readonly seq: number;
|
|
46
|
+
readonly parentId: string | null;
|
|
47
|
+
}
|
|
48
|
+
/** The walk's start, from the window's floor entry and its position (no floor entry = a full load ⇒ no walk) — the one construction all three
|
|
49
|
+
* storages use. */
|
|
50
|
+
export declare function epochFloorOf(seq: number, floorEntry: SessionTreeEntry | undefined): EpochFloor | undefined;
|
|
51
|
+
/** Page the rows `seq < beforeSeq`, newest first (an empty page = no older row). Rows off the branch may be in a page — the scan passes them. */
|
|
52
|
+
export type EpochAnchorPage<R extends EpochAnchorRow> = (beforeSeq: number) => Promise<readonly R[]>;
|
|
53
|
+
/** The nearest epoch carrier on the branch below the floor, as stored; see the file header. */
|
|
54
|
+
export declare function scanEpochAnchor<R extends EpochAnchorRow>(floor: EpochFloor | undefined, page: EpochAnchorPage<R>, entryOf: (row: R) => SessionTreeEntry): Promise<unknown>;
|
|
32
55
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
56
|
+
* The SQL twins' page (one statement, two dialect spellings): every `session_event` row below `?` newest first, 100 a page, keyset on the
|
|
57
|
+
* primary key `(session_id, seq)`; the payload — projected as text, the one reading of a JSON column — only on the two carrier types
|
|
58
|
+
* (`carrier_payload`; `NULL` elsewhere), so the walk carries ids and parents and reads a payload only where a record can be.
|
|
35
59
|
*/
|
|
36
|
-
export
|
|
37
|
-
/**
|
|
38
|
-
export
|
|
60
|
+
export declare function epochAnchorPageSql(dialect: SqlDialect): string;
|
|
61
|
+
/** One row of {@link epochAnchorPageSql}, read by both twins (BIGINT `seq` may arrive as a string). */
|
|
62
|
+
export interface SqlEpochAnchorRow extends EpochAnchorRow {
|
|
63
|
+
readonly payload: unknown;
|
|
64
|
+
}
|
|
65
|
+
/** A driver row of {@link epochAnchorPageSql} → a scan row (the one mapping both twins use). */
|
|
66
|
+
export declare function sqlEpochAnchorRowOf(r: Readonly<Record<string, unknown>>): SqlEpochAnchorRow;
|
|
39
67
|
//# sourceMappingURL=session-epoch-anchor.d.ts.map
|
|
@@ -1,22 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { jsonColumnTextExpr } from "./sql-json-column.js";
|
|
2
|
+
export function epochFloorOf(seq, floorEntry) {
|
|
3
|
+
return floorEntry === undefined ? undefined : { seq, parentId: floorEntry.parentId ?? null };
|
|
4
|
+
}
|
|
5
|
+
const CARRIER_TYPES = new Set(["prompt_epoch", "compaction"]);
|
|
6
|
+
export async function scanEpochAnchor(floor, page, entryOf) {
|
|
7
|
+
if (floor === undefined || floor.seq <= 0)
|
|
3
8
|
return undefined;
|
|
4
|
-
let
|
|
5
|
-
|
|
9
|
+
let want = floor.parentId;
|
|
10
|
+
let cursor = floor.seq;
|
|
11
|
+
while (want !== null) {
|
|
6
12
|
const rows = await page(cursor);
|
|
7
13
|
if (rows.length === 0)
|
|
8
14
|
return undefined;
|
|
9
15
|
for (const row of rows) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
if (row.id !== want)
|
|
17
|
+
continue;
|
|
18
|
+
if (CARRIER_TYPES.has(row.type)) {
|
|
19
|
+
const entry = entryOf(row);
|
|
20
|
+
if (entry.type === "prompt_epoch")
|
|
21
|
+
return entry;
|
|
22
|
+
if (entry.type === "compaction") {
|
|
23
|
+
const details = entry.details;
|
|
24
|
+
if (typeof details === "object" && details !== null && "promptEpoch" in details && details.promptEpoch !== undefined)
|
|
25
|
+
return details.promptEpoch;
|
|
26
|
+
}
|
|
17
27
|
}
|
|
28
|
+
want = row.parentId;
|
|
29
|
+
if (want === null)
|
|
30
|
+
return undefined;
|
|
18
31
|
}
|
|
19
32
|
cursor = Number(rows[rows.length - 1].seq);
|
|
20
33
|
}
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
export function epochAnchorPageSql(dialect) {
|
|
37
|
+
const carrier = `CASE WHEN type IN ('prompt_epoch','compaction') THEN ${jsonColumnTextExpr(dialect, "payload")} END AS carrier_payload`;
|
|
38
|
+
const [sessionParam, seqParam] = dialect === "pg" ? ["$1", "$2"] : ["?", "?"];
|
|
39
|
+
return `SELECT seq, entry_id, parent_id, type, ${carrier} FROM session_event WHERE session_id = ${sessionParam} AND seq < ${seqParam} ORDER BY seq DESC LIMIT 100`;
|
|
40
|
+
}
|
|
41
|
+
export function sqlEpochAnchorRowOf(r) {
|
|
42
|
+
return { seq: r["seq"], id: String(r["entry_id"]), parentId: r["parent_id"] ?? null, type: String(r["type"]), payload: r["carrier_payload"] };
|
|
21
43
|
}
|
|
22
44
|
//# sourceMappingURL=session-epoch-anchor.js.map
|
|
@@ -13,8 +13,24 @@ export interface SessionExtColumn {
|
|
|
13
13
|
* 全部可空:NULL = absent / 非键控 fork。一次性迁移 M32(7.139–7.146 形:这八列在 `session_meta` 上)读同一份定义。
|
|
14
14
|
*/
|
|
15
15
|
export declare const EXECUTION_PLACEMENT_COLUMNS: readonly SessionExtColumn[];
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* 客户端写计数(提交出口的撤回判据,`plugins/session-birth.ts`):**客户端可见会话态**的每一个写者(标题 / 置顶、导入、会话规则、附件绑定)在锁住根行之后、
|
|
18
|
+
* 自己的写之前同一事务 +1。读的是**写过几次**,不是格的当前值 —— 标题改回空、置顶改回 false、规则写了又删,这只会话都已经被人写过。不可空、缺省 0
|
|
19
|
+
* (行不在与行在而零写同读)。存量库缺这一列 ⇒ 起服列册对账拒启并给 `ALTER TABLE … ADD COLUMN`(中央建表句生成)。
|
|
20
|
+
*/
|
|
21
|
+
export declare const CLIENT_WRITES_COLUMN: SessionExtColumn;
|
|
22
|
+
/** 计数 +1 的那一句的 SET 片段(四个写者同读这一份)。 */
|
|
23
|
+
export declare const BUMP_CLIENT_WRITES = "client_writes = client_writes + 1";
|
|
24
|
+
/**
|
|
25
|
+
* **在删令牌** —— 会话行的三态(活 → 在删 → 没了)在 SQL 上的那一格:`NULL` = 活;非空 = 一次删除已经立了围栏、还没删完,值是那一次删除尝试的令牌(uuidv7,36 字符)。
|
|
26
|
+
* 只有删除面写它(`plugins/session-store-sql.ts`:围栏写、接管换写;终刀随根行一起删掉 —— 旁表行走外键级联),读者只比等。
|
|
27
|
+
* 在删对删除门之外的一切读者与写者读作「行不在」(头读 / 列表 / 规则 L 的认领);存量库缺这一列 ⇒ 起服列册对账拒启并给 `ALTER TABLE … ADD COLUMN`。
|
|
28
|
+
*/
|
|
29
|
+
export declare const DELETING_TOKEN_COLUMN: SessionExtColumn;
|
|
30
|
+
/** 本表的全部格(主键之外),按建表句的列序。一次性迁移 M41 逐列从 `session_meta` 搬进来的是产品格与执行放置格(计数格与在删令牌不在 `session_meta` 上出现过,不搬)。 */
|
|
17
31
|
export declare const SESSION_EXT_COLUMNS: readonly SessionExtColumn[];
|
|
32
|
+
/** M41 从 `session_meta` 搬进本表的那一组(计数格之前的全部格)。 */
|
|
33
|
+
export declare const SESSION_EXT_MOVED_COLUMNS: readonly SessionExtColumn[];
|
|
18
34
|
/** 外键约束名(两方言同名;起服探针与迁移的后置条件按名读)。 */
|
|
19
35
|
export declare const SESSION_EXT_FOREIGN_KEY = "fk_session_ext_session";
|
|
20
36
|
/** 被引列 `session_meta.session_id` 的字符集与排序规则(MySQL 协议方言;外键列逐字带上,见顶注「外键列的字符集与排序规则取自被引列」)。 */
|
|
@@ -38,8 +54,8 @@ export declare class SessionExtTableRefusedError extends StoreBootRefusalError {
|
|
|
38
54
|
}
|
|
39
55
|
/**
|
|
40
56
|
* MySQL 协议方言建旁表(中央 `ensureSchema` 在 `session_meta` 建好之后调):读被引列的字符集 / 排序规则 → 按它铸建表句 → 建。`query` = 那条 DDL 连接上的一次查询(交回行)。
|
|
41
|
-
* 读不出被引列 ⇒ {@link SessionExtTableRefusedError};「库确定拒了这条建表句」只按本仓唯一判官的闭集认(`sql-errors.ts` 的 `isDeploymentFaultError
|
|
42
|
-
*
|
|
57
|
+
* 读不出被引列 ⇒ {@link SessionExtTableRefusedError};「库确定拒了这条建表句」只按本仓唯一判官的闭集认(`sql-errors.ts` 的 `isDeploymentFaultError`:建外键被库确定拒的一族 —— 两侧不相容 / 加不上外键 /
|
|
58
|
+
* 被引表缺索引、缺唯一键、缺列、打不开(不是 InnoDB)/ 约束名重复 / 选项不成立 —— 与建表被存储引擎拒 / 表级权限拒 …)⇒ 同一只拒,库答的原句与原码(errno / SQLSTATE)随拒句;认不出的错(连接类故障、TiDB 的瞬时错、锁等待超时 …,带不带 SQL 状态码都一样)原样上抛 —— 开库等待窗重试它。
|
|
43
59
|
* 本模块不自带分类:判官加一码,这里随之。
|
|
44
60
|
*/
|
|
45
61
|
export declare function ensureSessionExtTableMysql(query: (sql: string) => Promise<readonly unknown[]>): Promise<void>;
|
|
@@ -71,4 +87,12 @@ export declare class SessionExtCascadeAbsentError extends StoreBootRefusalError
|
|
|
71
87
|
* 读不到 / 写不进 ⇒ 原样上抛(证不出级联 ≠ 通过)。调用点:起服序列在建表之后、一次性迁移之前(`boot/stores.ts`)。
|
|
72
88
|
*/
|
|
73
89
|
export declare function assertSessionExtCascadeOn(db: Pick<SqlDriver, "dialect" | "connect">): Promise<void>;
|
|
90
|
+
/** 一条连接上的行读口(本事务的语句面:SQL 文本 + 参数 → 行)。 */
|
|
91
|
+
export type SessionExtRowsOn = (text: string, values: readonly unknown[]) => Promise<ReadonlyArray<Readonly<Record<string, unknown>>>>;
|
|
92
|
+
/**
|
|
93
|
+
* 锁定读这一行的在删令牌({@link DELETING_TOKEN_COLUMN};`null` = 活)。只在根 `session_meta` 行已被本事务锁住之后调(写序:根行 → 旁表)。
|
|
94
|
+
* **先补行、再锁定读**(与执行席的 `readCellOn` 同一条理由:InnoDB 可重复读下锁定读一只不在的键拿间隙锁,两只事务随后各自补行即互等);锁定读 = 最新已提交
|
|
95
|
+
* (TiDB 悲观事务的普通读读事务起点快照,读不到在本事务取锁之前刚提交的围栏)。读者:删除面的围栏 / 终刀判官、规则 L 的认领事务。
|
|
96
|
+
*/
|
|
97
|
+
export declare function readDeletingTokenOn(conn: SessionExtRowsOn, dialect: SqlDialect, sessionId: string): Promise<string | null>;
|
|
74
98
|
//# sourceMappingURL=session-ext-table.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SESSION_TITLE_MAX_CHARS } from "../session-row.js";
|
|
2
2
|
import { SESSION_WORKSPACE_COLUMN } from "./session-workspace-cell.js";
|
|
3
3
|
import { SCHEMA_MISMATCH_ERROR_CODE, StoreBootRefusalError } from "./store-contracts.js";
|
|
4
|
-
import { isDeploymentFaultError } from "./sql-errors.js";
|
|
4
|
+
import { databaseAnswerCodesOf, isDeploymentFaultError } from "./sql-errors.js";
|
|
5
5
|
export const SESSION_EXT_TABLE = "session_ext";
|
|
6
6
|
export const EXECUTION_PLACEMENT_COLUMNS = [
|
|
7
7
|
{ name: "execution_role", mysql: "execution_role VARCHAR(16) NULL", pg: `execution_role VARCHAR(16) COLLATE "C"` },
|
|
@@ -19,7 +19,11 @@ const PRODUCT_COLUMNS = [
|
|
|
19
19
|
{ name: "instruction_source", mysql: "instruction_source VARCHAR(64) NULL", pg: `instruction_source VARCHAR(64) COLLATE "C"` },
|
|
20
20
|
SESSION_WORKSPACE_COLUMN,
|
|
21
21
|
];
|
|
22
|
-
export const
|
|
22
|
+
export const CLIENT_WRITES_COLUMN = { name: "client_writes", mysql: "client_writes BIGINT NOT NULL DEFAULT 0", pg: "client_writes BIGINT NOT NULL DEFAULT 0" };
|
|
23
|
+
export const BUMP_CLIENT_WRITES = "client_writes = client_writes + 1";
|
|
24
|
+
export const DELETING_TOKEN_COLUMN = { name: "deleting_token", mysql: "deleting_token VARCHAR(36) NULL", pg: `deleting_token VARCHAR(36) COLLATE "C"` };
|
|
25
|
+
export const SESSION_EXT_COLUMNS = [...PRODUCT_COLUMNS, ...EXECUTION_PLACEMENT_COLUMNS, CLIENT_WRITES_COLUMN, DELETING_TOKEN_COLUMN];
|
|
26
|
+
export const SESSION_EXT_MOVED_COLUMNS = [...PRODUCT_COLUMNS, ...EXECUTION_PLACEMENT_COLUMNS];
|
|
23
27
|
export const SESSION_EXT_FOREIGN_KEY = "fk_session_ext_session";
|
|
24
28
|
export const SESSION_META_KEY_COLLATION_PROBE = "SELECT CHARACTER_SET_NAME AS cs, COLLATION_NAME AS coll FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'session_meta' AND COLUMN_NAME = 'session_id'";
|
|
25
29
|
const COLLATION_NAME_RE = /^[A-Za-z0-9_]{1,64}$/;
|
|
@@ -47,8 +51,9 @@ export class SessionExtTableRefusedError extends StoreBootRefusalError {
|
|
|
47
51
|
constructor(detail) {
|
|
48
52
|
super(`${SCHEMA_MISMATCH_ERROR_CODE}: this MySQL-protocol database cannot create table ${SESSION_EXT_TABLE} — refusing to start. ${detail} ` +
|
|
49
53
|
`The table's foreign key ${SESSION_EXT_FOREIGN_KEY} references session_meta (session_id) with ON DELETE CASCADE; its key column copies the character set and collation of session_meta.session_id. ` +
|
|
50
|
-
"
|
|
51
|
-
"and
|
|
54
|
+
"Next: fix session_meta so that foreign key can be formed — on MySQL it must be an InnoDB table (foreign keys need InnoDB on both sides), and session_id must be a character column " +
|
|
55
|
+
"and its PRIMARY KEY or a UNIQUE key (MySQL 9.x refuses a foreign key to a non-unique column with errno 6125); on TiDB foreign keys need v6.6.0 or later; the account needs the CREATE grant. " +
|
|
56
|
+
"This is the database's definite answer, so waiting or changing the MYSQL_* coordinates will not change it. This check changed nothing in the database.");
|
|
52
57
|
this.name = "SessionExtTableRefusedError";
|
|
53
58
|
}
|
|
54
59
|
}
|
|
@@ -64,9 +69,10 @@ export async function ensureSessionExtTableMysql(query) {
|
|
|
64
69
|
catch (err) {
|
|
65
70
|
if (!isDeploymentFaultError(err))
|
|
66
71
|
throw err;
|
|
67
|
-
const {
|
|
72
|
+
const { sqlMessage: said } = err;
|
|
68
73
|
const sentence = typeof said === "string" ? said : err instanceof Error ? err.message : String(err);
|
|
69
|
-
|
|
74
|
+
const codes = databaseAnswerCodesOf("mysql", err);
|
|
75
|
+
throw new SessionExtTableRefusedError(`The foreign key column was declared CHARACTER SET ${referenced.characterSet} COLLATE ${referenced.collation} (read from session_meta.session_id); the database answered: ${sentence.split(/\r?\n/, 1)[0] ?? ""}${codes !== undefined ? ` (${codes})` : ""}.`);
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
export function ensureSessionExtRowStatement(dialect, sessionId) {
|
|
@@ -118,4 +124,11 @@ export async function assertSessionExtCascadeOn(db) {
|
|
|
118
124
|
conn.release();
|
|
119
125
|
}
|
|
120
126
|
}
|
|
127
|
+
export async function readDeletingTokenOn(conn, dialect, sessionId) {
|
|
128
|
+
const ensure = ensureSessionExtRowStatement(dialect, sessionId);
|
|
129
|
+
await conn(ensure.text, ensure.values);
|
|
130
|
+
const row = (await conn(`SELECT ${DELETING_TOKEN_COLUMN.name} FROM ${SESSION_EXT_TABLE} WHERE session_id = ${dialect === "pg" ? "$1" : "?"} FOR UPDATE`, [sessionId]))[0];
|
|
131
|
+
const token = row?.[DELETING_TOKEN_COLUMN.name];
|
|
132
|
+
return token === null || token === undefined ? null : String(token);
|
|
133
|
+
}
|
|
121
134
|
//# sourceMappingURL=session-ext-table.js.map
|
|
@@ -20,8 +20,22 @@
|
|
|
20
20
|
* fork 的创建那一笔就是一次建行:带元组的 fork 与带 placement 的 acquire 落**同一组**元组(六列 / 存档行头,first-write 不可变,`placedAt` 由店铸),
|
|
21
21
|
* 此后这一行欠 placed 行的每一条义务(不上宿主列表 · claim 形 acquire 拒 · 进分区枚举 · release = 真删除)。元组不带属主:行的属主仍是 fork 的属主参数
|
|
22
22
|
* 按 `forkOwnerOf` 的那一读(core 句:元组没有属主)。没声明分区的店照常 fork、不落元组(core 句:忽略合法,拒 fork 不合法)。
|
|
23
|
+
*
|
|
24
|
+
* ## fork 谱系(三店同一读法)
|
|
25
|
+
* fork 行的谱系两格 = core `forkRowCells` 从**源行**(fork 那一刻,建行之前那一读)铸出的 `forkedFrom`(源 id)与 `forkedFromIncarnation`(源行那一刻的住客令牌;
|
|
26
|
+
* 源行没有令牌 ⇒ 缺)—— 三店的建行都读 `forkRowCells`,本仓不写第二份谱系读法。两格落在**行上**(SQL:`session_meta` 的两列,列定义属主 `session-incarnation.ts` 的 `SESSION_META_LINEAGE_COLUMNS`;
|
|
27
|
+
* local:会话元数据边档那一格的两位),同一笔写;交出的会话元数据与列表行(`forkedFrom`)从行上读回(`session-incarnation.ts` 的 `forkLineageOfRow`)。
|
|
28
|
+
* 缺 = 不是 fork 建的行,或谱系落地之前建的 fork(源已不可知,不回填)。属主不读 `forkRowCells` 那一格:本仓的 fork 属主律是 `forkOwnerOf`(差异见 `test/session-incarnation.test.ts` 的对拍格)。
|
|
29
|
+
* **一只 fork 拷一代源**:谱系的住客那一半说的就是拷贝所读的那一代。源在这一次 fork 的几次读之间换了代(删掉后同 id 重建 —— 令牌永不复现)⇒ 这一次 fork 读到的不是一代源,
|
|
30
|
+
* 与「源不在」同答(`null`,零写):SQL 两孪生在叶 / 属主那一读、唤醒、整日志读之后各问一次住客({@link sameSourceGeneration});local 店的首次拷贝在源的写锁里读(一代),
|
|
31
|
+
* 崩在格与拷贝之间的同键补拷照这一律比格上记下的来源住客与此刻的源。
|
|
23
32
|
*/
|
|
24
33
|
import { type ForkPoint, type ForkRowShape, type SessionStorage, type SessionStore } from "@sema-agent/core";
|
|
34
|
+
/**
|
|
35
|
+
* SQL 两孪生 fork 的「一代源」判(见头注「一只 fork 拷一代源」):唤醒交出的源住客(`woke`)与整日志读之前、之后两次读到的那一格(`before` / `after`,行上原值;行不在 ⇒ `undefined`)
|
|
36
|
+
* 三者相同才是一代 —— 令牌永不复现,首尾两读与唤醒同 ⇒ 夹在中间的整日志读读的也是这一代。不是一代 ⇒ 调用方按「源不在」答。
|
|
37
|
+
*/
|
|
38
|
+
export declare function sameSourceGeneration(woke: string | undefined, before: unknown, after: unknown): boolean;
|
|
25
39
|
/** 问引擎:这只(已唤醒的)源会话从哪里拷。SQL 孪生用它;local 店手里就是引擎的 `Session`,直接调 `settledForkOptions`。 */
|
|
26
40
|
export declare function forkPointOf(storage: SessionStorage): Promise<ForkPoint>;
|
|
27
41
|
/** 两只 SQL 孪生整份日志里的一行(两孪生选同一组列):父链两键交引擎挑行,其余三列原样搬进新会话、不读内容。 */
|
|
@@ -40,7 +54,7 @@ export declare const FORK_LOG_ROW_SHAPE: ForkRowShape<ForkLogRow>;
|
|
|
40
54
|
/**
|
|
41
55
|
* fork 进委派分区时落的元组 —— core `SessionStore.fork` 第三参 `opts.placement` 的那一形,**直接取 core 的型、不复述**(core 当前写作 `SessionPlacement` 去掉属主:行的属主是
|
|
42
56
|
* fork 的属主参数的那一读)。本仓里这个元组型只有这一处定义:三店(local · pg · tidb)、路由店、`forkByFreshId`、引擎面声明的 fork 形参,以及建行绑定值
|
|
43
|
-
* `
|
|
57
|
+
* `placementInsertCells`(`session-placement.ts`)都读它 —— core 再改 `fork` 的第三参,型面在这里一处跟着动(`SessionStore.fork` 是可选成员,所以取参数前先 `NonNullable`)。
|
|
44
58
|
*/
|
|
45
59
|
export type ForkPlacement = NonNullable<NonNullable<Parameters<NonNullable<SessionStore["fork"]>>[2]>["placement"]>;
|
|
46
60
|
/**
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { SessionError, StoredSession, settledForkOptions, uuidv7 } from "@sema-agent/core";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
+
export function sameSourceGeneration(woke, before, after) {
|
|
4
|
+
return woke !== undefined && before === woke && after === woke;
|
|
5
|
+
}
|
|
3
6
|
export async function forkPointOf(storage) {
|
|
4
7
|
return settledForkOptions(new StoredSession(storage));
|
|
5
8
|
}
|
|
@@ -7,7 +7,7 @@ export declare const NOT_A_PRINCIPAL_NAME = "a string that names nobody (empty,
|
|
|
7
7
|
* 「这个值能不能作一只会话行的属主格」—— core 7.56.0 [ref] 起只有一只判官 `principalNameOf`:主体名(有可见内容、不含控制 / 分隔 / 非连接符格式字符,
|
|
8
8
|
* 原样保存不规整)或 `null`(匿名)。空串、空白串、带不可见字符的串与一切非串都不是属主(它们谁也不指 —— 读成匿名会放行每一位主体)。
|
|
9
9
|
*
|
|
10
|
-
* 边界同判官:HTTP 请求带来的主体在鉴权边界已经过同一只 `principalNameOf`(`
|
|
10
|
+
* 边界同判官:HTTP 请求带来的主体在鉴权边界已经过同一只 `principalNameOf`(`principal-shape.ts` `principalShapeProblem` 的 `not_a_name`,7.137.0)⇒
|
|
11
11
|
* 经过边界的请求到不了这里的拒臂;这里是纵深(嵌入方直调店、别的写者),规则只有引擎那一只,不在本仓另写。
|
|
12
12
|
*/
|
|
13
13
|
export declare function isSessionOwnerValue(owner: unknown): owner is string | null;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* 本仓成文教训(`memory-origin-law.ts` 顶注同族、`key-resolver.ts` 顶注「链只有一条」):两支方言各
|
|
24
24
|
* 抄一份准入判据,迟早在某一支上少一个分支——而少掉的那一支**没有任何报错面**,表现只是「这台机器上
|
|
25
|
-
* 一个陌生人可以把自己接到别人子代的转录上」。所以准入判据(两个方向)
|
|
25
|
+
* 一个陌生人可以把自己接到别人子代的转录上」。所以准入判据(两个方向)、列名(读侧投影与写侧建行同一张表)、行→元组的映射都在
|
|
26
26
|
* 这一处;两支后端只负责在自己的 I/O 点上调用它。
|
|
27
27
|
*
|
|
28
28
|
* ## 判据的两个方向(缺一不可,core `TtlSessionStore.assertPlacementAdmission` 的镜像)
|
|
@@ -37,8 +37,9 @@ import { type PlacedSessionRow, type SessionPlacement, type SessionPlacementReco
|
|
|
37
37
|
import type { ForkPlacement } from "./session-fork.js";
|
|
38
38
|
/**
|
|
39
39
|
* 三只持久会话店(SQL 两孪生 + local 后端)的**会话耐久声明**(core `SessionStore.durability`:未 placed 的会话活不活过进程重启)——
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* **单源**:两孪生类上的顶层 `durability` 与委派分区的 {@link SESSION_PLACEMENTS} 引用的都是这一只常量;local 后端交给两半店(会话店顶层、
|
|
41
|
+
* 检查点店)的声明由 `local-store-declaration.ts` 的读者定,它的「店型的设计声明」一臂就是这一只常量(运维声明易失 / 店落在调用方自己那块易失盘上 ⇒ `process-local`)。
|
|
42
|
+
* 源码里不再有第二份 `"durable"` 字面(`test/session-store-durability-declaration.test.ts` 的 AST 钉)。
|
|
42
43
|
*
|
|
43
44
|
* 为什么必须声明:core 的静态装配对**缺席**折 `"process-local"`(它不能替没表态的店猜),接线清单 `session.store` 与起服自检读的就是它 ——
|
|
44
45
|
* 不声明 ⇒ 一个真持久的 SQL 部署读成「重启即丢」,没有任何一处报错。依据同下面分区声明那一段:两孪生的会话史落在 `session_meta` + `session_event` 两张真表,
|
|
@@ -47,8 +48,8 @@ import type { ForkPlacement } from "./session-fork.js";
|
|
|
47
48
|
*/
|
|
48
49
|
export declare const SESSION_DURABILITY: "durable";
|
|
49
50
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
51
|
+
* 两支 SQL 孪生的 placement **声明**(core `SessionStore.placements`,类上的字段)。local 后端装配 `LocalSessionStore` 时交进去的分区声明与它同形,
|
|
52
|
+
* 耐久取 local 店的那一份声明(`local-store-declaration.ts`;设计声明一臂与这里同值,与 core `FileStorageBackend` 对同一种文件 repo 的声明同)。
|
|
52
53
|
*
|
|
53
54
|
* 🔴 声明制,不是鸭子类型:core 的铸造门判「row store ∧ session 店声明」,不声明的店**不收** placed
|
|
54
55
|
* 语义(合法降级:placement 参数被忽略,会话就是普通会话)。所以这一格只有在上面六条义务**全部**在
|
|
@@ -64,20 +65,19 @@ export declare const SESSION_PLACEMENTS: {
|
|
|
64
65
|
};
|
|
65
66
|
};
|
|
66
67
|
/**
|
|
67
|
-
* `session_meta` 上承载 placement 元组的六列,**两方言同名**
|
|
68
|
-
*
|
|
68
|
+
* `session_meta` 上承载 placement 元组的六列,**两方言同名** —— 列名只住这一张表:读侧投影 {@link PLACEMENT_SELECT_COLUMNS}、行形
|
|
69
|
+
* {@link PlacementColumns}、写侧建行的列段与绑定值 {@link placementInsertCells} 都从它派生,源码里没有第二份手写列表
|
|
70
|
+
* (列名手抄一份必漂,而漂掉的那一支只会表现为「这台机器上 placed 行读不出来」—— 静默,不报错)。
|
|
69
71
|
* `placed_at` 是 GC 的年龄锚(core `PlacedSessionRow.placedAt`);其余五列是元组本身。
|
|
70
72
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
placed_at?: unknown;
|
|
80
|
-
}
|
|
73
|
+
declare const PLACEMENT_COLUMN_NAMES: readonly ["placement_kind", "placement_scope", "placement_parent_session_id", "placement_root_session_id", "placement_handle", "placed_at"];
|
|
74
|
+
type PlacementColumnName = (typeof PLACEMENT_COLUMN_NAMES)[number];
|
|
75
|
+
/** 读侧投影:六列按表序逗号拼接(`SELECT …, ${PLACEMENT_SELECT_COLUMNS} FROM session_meta …`)。 */
|
|
76
|
+
export declare const PLACEMENT_SELECT_COLUMNS: string;
|
|
77
|
+
/** 一行 `session_meta` 的 placement 列(两方言的驱动都把列名原样带回,故一份形;键集 = 那张表)。 */
|
|
78
|
+
export type PlacementColumns = {
|
|
79
|
+
[K in PlacementColumnName]?: unknown;
|
|
80
|
+
};
|
|
81
81
|
/**
|
|
82
82
|
* 行 → 持久化的 placement 元组(`undefined` = 这是一只普通会话)。
|
|
83
83
|
*
|
|
@@ -94,9 +94,15 @@ export declare function placementFromRow(row: PlacementColumns | undefined): Ses
|
|
|
94
94
|
* 消费方对它 fail-closed(永不按年龄收割)。一个「无行」与「另一个租户有行」分不清的 join 不许删东西。
|
|
95
95
|
*/
|
|
96
96
|
export declare function placedRowFromRow(sessionId: string, row: PlacementColumns, lastActivityMs?: number): PlacedSessionRow;
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
/** 建行 INSERT 的放置六列:列段与绑定值出自同一张表、同序(调用方把 `columns` 接在自己的列之后、`values` 接在自己的绑定值之后,占位符按方言自写)。 */
|
|
98
|
+
export interface PlacementInsertCells {
|
|
99
|
+
/** 列段(= {@link PLACEMENT_SELECT_COLUMNS}:读写同一张表)。 */
|
|
100
|
+
readonly columns: string;
|
|
101
|
+
/** 与 `columns` 同序的六个绑定值;无 placement ⇒ 六个 NULL。 */
|
|
102
|
+
readonly values: readonly (string | Date | null)[];
|
|
103
|
+
}
|
|
104
|
+
/** 写侧唯一导出:创建时一次落行的放置列与绑定值。两店(PG / MySQL 协议)的两个建行点 —— 带 placement 的 acquire、带元组的 fork —— 同调这一只。 */
|
|
105
|
+
export declare function placementInsertCells(placement: ForkPlacement | undefined, placedAt: Date): PlacementInsertCells;
|
|
100
106
|
/** `acquire` 的 opts 面(core `SessionStore.acquire` 的第二参,窄成本模块要判的两键)。 */
|
|
101
107
|
export interface PlacementAcquireOpts {
|
|
102
108
|
requireExisting?: boolean;
|
|
@@ -123,4 +129,5 @@ export declare function placementCapabilityOf(store: {
|
|
|
123
129
|
* 接着收」,而不是「有些行永远看不见」。判据消费方(core 的分区收割腿)本就是每 tick 重新枚举的。
|
|
124
130
|
*/
|
|
125
131
|
export declare const LIST_PLACED_BATCH = 1000;
|
|
132
|
+
export {};
|
|
126
133
|
//# sourceMappingURL=session-placement.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SessionError } from "@sema-agent/core";
|
|
2
2
|
export const SESSION_DURABILITY = "durable";
|
|
3
3
|
export const SESSION_PLACEMENTS = { subagent: { durability: SESSION_DURABILITY } };
|
|
4
|
-
|
|
4
|
+
const PLACEMENT_COLUMN_NAMES = ["placement_kind", "placement_scope", "placement_parent_session_id", "placement_root_session_id", "placement_handle", "placed_at"];
|
|
5
|
+
export const PLACEMENT_SELECT_COLUMNS = PLACEMENT_COLUMN_NAMES.join(", ");
|
|
5
6
|
function toEpochMs(v) {
|
|
6
7
|
if (v == null)
|
|
7
8
|
return undefined;
|
|
@@ -34,17 +35,19 @@ export function placedRowFromRow(sessionId, row, lastActivityMs) {
|
|
|
34
35
|
? { sessionId, placedAt, scope, handle }
|
|
35
36
|
: { sessionId, placedAt, tupleIncomplete: true };
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
const PLACEMENT_CELL_OF = {
|
|
39
|
+
placement_kind: (p) => p.kind,
|
|
40
|
+
placement_scope: (p) => p.scope ?? null,
|
|
41
|
+
placement_parent_session_id: (p) => p.parentSessionId ?? null,
|
|
42
|
+
placement_root_session_id: (p) => p.rootSessionId ?? null,
|
|
43
|
+
placement_handle: (p) => p.handle ?? null,
|
|
44
|
+
placed_at: (_p, placedAt) => placedAt,
|
|
45
|
+
};
|
|
46
|
+
export function placementInsertCells(placement, placedAt) {
|
|
47
|
+
return {
|
|
48
|
+
columns: PLACEMENT_SELECT_COLUMNS,
|
|
49
|
+
values: PLACEMENT_COLUMN_NAMES.map((column) => (placement === undefined ? null : PLACEMENT_CELL_OF[column](placement, placedAt))),
|
|
50
|
+
};
|
|
48
51
|
}
|
|
49
52
|
export function placementCapabilityOf(store) {
|
|
50
53
|
return { subagentPlacement: store.placements?.subagent !== undefined };
|
|
@@ -11,6 +11,17 @@
|
|
|
11
11
|
* ③ `write` ⇒ 补旁表行(行在不动)、按 `session_id` 写格(根行已被本事务锁住)→ 提交。`updated_at` 不动(改名不是活动 —— 列表的新近序不变)。
|
|
12
12
|
* 应答行在**提交 / 回滚之后**由调用方的列表行读另读(新语句、新快照 —— 不在事务内用普通 `SELECT` 读:TiDB 悲观事务的普通读钉 `start_ts`,
|
|
13
13
|
* 等锁之后会读回判定之前的旧值),再交 `settleSessionRowWrite` 复核住客。
|
|
14
|
+
*
|
|
15
|
+
* ## 结局 `absent` 的三种去向(一个词不说「写没写」)
|
|
16
|
+
* 调用方把 `absent` 答成「无此会话」(PATCH = 404),但**写落没落**按住客是在哪一刻对不上的分三种(契约「会话行可写位」一节 `PATCH` 一行同表):
|
|
17
|
+
* ① 判官在锁下答 `absent`(行期望不中 / 没有行 / 委派分区行):回滚,一个字节没写;
|
|
18
|
+
* ② 判官答 `changed`(行标签不中,回滚,一个字节没写),回滚之后另读应答行时那一行已换了住客、或读不到:仍是 `absent` 而不是 `changed`
|
|
19
|
+
* (应答行属于另一位住客,不交给这位调用方),写同样一个字节没落;
|
|
20
|
+
* ③ 判官答 `write`、事务**已提交**,提交之后另读应答行时那一行才换了住客:
|
|
21
|
+
* · 会话被删(之后同一 id 被重新登记与否)⇒ 这一笔写随旧行的 `ON DELETE CASCADE` 一并删掉(级联是旁表的承重前提:`session-ext-table.ts` 头注、起服级联探针),重新登记的新住客的标题 / 置顶是缺省;
|
|
22
|
+
* · 只换了属主、化身没变(同一化身被认领 / 同步重戳)⇒ 这一笔写**留在那一行上**:写落下那一刻判官判过的那位住客仍是行主(两笔都先锁根行、串行),
|
|
23
|
+
* 之后这一行连同标题换了主 —— 是行的历史,不是越权写。
|
|
24
|
+
* 应答不在事务内读(理由见上),所以③这一窗在;不取「事务内应答」。
|
|
14
25
|
* 全局锁序:根 `session_meta` 一行 → 它的旁表行(→ 读日志 mark 时它的末条事件),不碰 `task_*`(与旁表的每个写者同序:根行先)。
|
|
15
26
|
*/
|
|
16
27
|
import type { SqlDriver } from "./sql-driver.js";
|
|
@@ -18,6 +29,7 @@ import { type SessionRowAnswer, type SessionRowPatch, type SessionRowWrite, type
|
|
|
18
29
|
/**
|
|
19
30
|
* 写原语(头注):一只事务里锁根行 → 判官 → 写 / 不写;提交 / 回滚之后经 `readAnswer`(调用方店的列表行读 + 行上的住客)另读应答行。
|
|
20
31
|
* `db` = 店自己的池包成的 SqlDriver(连接经它的初始化);`readAnswer` 只在判官答 `write` / `changed` 时被调。
|
|
32
|
+
* 结局 `absent` 并不都是「一个字节没写」:判官在锁下答 `absent` / 答 `changed` 之后应答复核对不上,都是零写;答 `write` 且已提交之后应答复核对不上,写已落(去向见头注)。
|
|
21
33
|
*/
|
|
22
34
|
export declare function writeSessionRowCellsSql<Row>(db: Pick<SqlDriver, "dialect" | "connect">, sessionId: string, cells: SessionRowPatch, how: SessionRowWrite, readAnswer: (sessionId: string) => Promise<SessionRowAnswer<Row> | undefined>): Promise<SessionRowWriteOutcome<Row>>;
|
|
23
35
|
//# sourceMappingURL=session-row-sql.d.ts.map
|