@sema-agent/server 7.147.0 → 7.148.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 +1039 -24
- package/README.md +20 -7
- package/README.zh-CN.md +14 -8
- package/USAGE.md +380 -163
- 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/adoption/wire.d.ts +3 -3
- package/dist/approval-card.d.ts +28 -30
- package/dist/approval-gate-currency.js +3 -2
- 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 +0 -14
- package/dist/auth-bridge.js +0 -7
- 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 +37 -31
- 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-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 +55 -67
- 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 +11 -4
- 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.js +9 -1
- package/dist/boot/stage-02-web-admin-pull.d.ts +1 -0
- package/dist/boot/stage-02-web-admin-pull.js +6 -1
- package/dist/boot/stage-03-store-backend.d.ts +3 -0
- package/dist/boot/stage-03-store-backend.js +4 -3
- package/dist/boot/stage-04-stores.d.ts +2 -0
- package/dist/boot/stage-04-stores.js +2 -2
- package/dist/boot/stage-05-execution-env.d.ts +7 -3
- package/dist/boot/stage-05-execution-env.js +2 -2
- package/dist/boot/stage-06-runners.d.ts +10 -12
- package/dist/boot/stage-06-runners.js +23 -15
- package/dist/boot/stage-07-capability-layer.d.ts +11 -8
- package/dist/boot/stage-07-capability-layer.js +5 -3
- package/dist/boot/stage-08-reapers.d.ts +11 -8
- package/dist/boot/stage-08-reapers.js +3 -3
- package/dist/boot/stage-09-leader.d.ts +12 -15
- package/dist/boot/stage-09-leader.js +12 -4
- package/dist/boot/stage-10-http-server.d.ts +12 -15
- 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 +3 -0
- package/dist/boot/stores.js +21 -10
- 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 +38 -11
- package/dist/capability-facts.js +47 -8
- package/dist/card-void.d.ts +4 -4
- package/dist/card-void.js +1 -1
- package/dist/center-credential-renewer.d.ts +6 -2
- package/dist/center-credential-renewer.js +7 -3
- package/dist/config-catalog.d.ts +16 -1
- package/dist/config-catalog.js +62 -56
- package/dist/config-dir-trust.d.ts +37 -4
- package/dist/config-dir-trust.js +88 -44
- package/dist/config-invariants.d.ts +42 -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 +26 -17
- package/dist/config.d.ts +8 -16
- package/dist/config.js +113 -47
- 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 +30 -4
- package/dist/deployment-shape.js +7 -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-witness.d.ts +7 -0
- package/dist/env-witness.js +16 -0
- package/dist/execution-lane-caps.d.ts +5 -18
- package/dist/execution-lane-caps.js +0 -22
- 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/hook-llm.d.ts +5 -1
- package/dist/hooks/hook-llm.js +24 -15
- package/dist/hooks/hook-runner.d.ts +67 -57
- package/dist/hooks/hook-runner.js +260 -186
- 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 +75 -78
- package/dist/http/approval-sweeps.d.ts +3 -3
- package/dist/http/approval-sweeps.js +54 -30
- 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 +4 -3
- package/dist/http/dispatch.d.ts +8 -1
- package/dist/http/dispatch.js +76 -30
- package/dist/http/durable-run-leg.d.ts +3 -3
- package/dist/http/durable-run-leg.js +17 -12
- package/dist/http/execution-context.d.ts +17 -43
- package/dist/http/execution-context.js +7 -5
- 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 +391 -67
- package/dist/http/owner-access.js +371 -35
- package/dist/http/principal-gate.d.ts +24 -81
- package/dist/http/principal-gate.js +24 -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 +35 -12
- package/dist/http/resume-ctx-read.js +25 -6
- package/dist/http/resume-legs.d.ts +21 -18
- package/dist/http/resume-legs.js +189 -129
- package/dist/http/retired-skill-manifest.d.ts +1 -1
- package/dist/http/route-ctx.d.ts +25 -32
- package/dist/http/routes/a2a-serve.d.ts +43 -5
- package/dist/http/routes/a2a-serve.js +58 -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 +70 -65
- 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 +15 -18
- 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 +27 -3
- package/dist/http/routes/diagnostics.js +27 -21
- 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 +1 -1
- package/dist/http/routes/principal-inbox.js +2 -2
- 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 +146 -231
- 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 +4 -2
- package/dist/http/routes/session-sync.js +21 -20
- 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 +136 -120
- 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 +39 -40
- package/dist/http/server.js +36 -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 +16 -8
- package/dist/http/submit-ctx.js +6 -2
- 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 +1 -0
- package/dist/index.js +1 -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/lsp-evict.d.ts +6 -4
- package/dist/lsp-evict.js +2 -3
- package/dist/memory-operator-faces.d.ts +5 -4
- package/dist/memory-operator-faces.js +1 -1
- package/dist/memory-scope.d.ts +29 -2
- package/dist/memory-scope.js +64 -15
- package/dist/memory-store-refusal.d.ts +5 -2
- package/dist/memory-sync-client.d.ts +3 -2
- package/dist/memory-sync-client.js +6 -3
- package/dist/model-compat.d.ts +17 -8
- package/dist/model-compat.js +6 -2
- package/dist/model-context-window.d.ts +18 -0
- package/dist/model-context-window.js +2 -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 +35 -16
- package/dist/model-entry-refusal.js +40 -27
- 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-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 +58 -38
- package/dist/observability/fail-open.js +60 -38
- package/dist/observability/logger.d.ts +22 -1
- package/dist/observability/logger.js +89 -12
- package/dist/observability/metrics.js +3 -4
- 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 +5 -2
- 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 +5 -4
- package/dist/org-delivery-gate.js +7 -6
- 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 +531 -0
- package/dist/owner-faces.js +126 -0
- package/dist/parked-decide.d.ts +67 -5
- package/dist/parked-decide.js +127 -5
- package/dist/parked-revive-surface.d.ts +14 -4
- package/dist/parked-revive-surface.js +5 -4
- package/dist/peer-directory.d.ts +6 -8
- 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 +0 -22
- package/dist/plugins/adoption-log-sql.js +5 -3
- 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 +39 -20
- package/dist/plugins/approval-ask-store-sql.js +41 -10
- package/dist/plugins/approval-exemption-skill-m46.d.ts +20 -0
- package/dist/plugins/approval-exemption-skill-m46.js +25 -0
- package/dist/plugins/approval-exemption-store.d.ts +6 -1
- package/dist/plugins/approval-exemption-store.js +14 -0
- 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 +0 -15
- package/dist/plugins/ensure-schema-lock-policy.js +3 -2
- package/dist/plugins/file-run-store.d.ts +63 -23
- package/dist/plugins/file-run-store.js +138 -83
- 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 +58 -23
- package/dist/plugins/local-checkpoint-store.js +195 -76
- package/dist/plugins/local-data-dir-modes-m39.js +2 -1
- 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 +4 -2
- package/dist/plugins/local-engine-high-water.js +4 -1
- package/dist/plugins/local-session-store.d.ts +358 -125
- package/dist/plugins/local-session-store.js +824 -251
- 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 +39 -27
- package/dist/plugins/memory-run-store.js +72 -70
- package/dist/plugins/one-time-migration-marker.d.ts +10 -0
- package/dist/plugins/one-time-migration-marker.js +7 -0
- package/dist/plugins/one-time-migrations.d.ts +186 -45
- package/dist/plugins/one-time-migrations.js +442 -119
- package/dist/plugins/org-delivery-quota-store.js +2 -1
- package/dist/plugins/permission-rule-store-file.d.ts +3 -3
- package/dist/plugins/permission-rule-store-sql.d.ts +4 -63
- package/dist/plugins/permission-rule-store-sql.js +6 -86
- package/dist/plugins/pg-pool.d.ts +1 -31
- package/dist/plugins/pg-pool.js +16 -7
- package/dist/plugins/remote-env-e2b.d.ts +7 -25
- package/dist/plugins/remote-env-e2b.js +34 -25
- package/dist/plugins/remote-env-host.d.ts +2 -9
- package/dist/plugins/remote-env-host.js +34 -22
- package/dist/plugins/remote-env-k8s.d.ts +40 -45
- package/dist/plugins/remote-env-k8s.js +107 -58
- package/dist/plugins/remote-env-local-docker.d.ts +148 -14
- package/dist/plugins/remote-env-local-docker.js +367 -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 +56 -68
- package/dist/plugins/run-store-sql.js +127 -116
- 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 +54 -0
- package/dist/plugins/scenario-prefix-switch-m42.js +55 -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 +42 -9
- package/dist/plugins/schema-consistency.js +212 -11
- package/dist/plugins/schema-drift-sentence.d.ts +4 -1
- package/dist/plugins/schema-drift-sentence.js +4 -4
- 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 +22 -16
- 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 +20 -0
- package/dist/plugins/shell-sentinel-owner-m48.js +3 -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/store-backend.d.ts +84 -15
- package/dist/plugins/store-backend.js +186 -55
- package/dist/plugins/store-contracts.d.ts +90 -30
- package/dist/plugins/store-contracts.js +22 -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.js +23 -8
- 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/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/question.d.ts +13 -23
- package/dist/question.js +21 -39
- 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-local.d.ts +14 -6
- package/dist/run-local.js +92 -80
- package/dist/run-stale-default.d.ts +7 -0
- package/dist/run-stale-default.js +2 -0
- package/dist/runs.d.ts +26 -15
- package/dist/runs.js +39 -27
- 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 +21 -5
- package/dist/server-secret-env.js +14 -4
- package/dist/session-children-retire.d.ts +7 -5
- package/dist/session-children-retire.js +7 -2
- 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/spec-fields.d.ts +57 -3
- package/dist/spec-fields.js +72 -51
- package/dist/store-posture.d.ts +136 -20
- package/dist/store-posture.js +188 -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 +33 -28
- package/dist/stores-sql/checkpoint-store-sql.js +75 -44
- 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/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 +1 -1
- package/dist/task-a2a.js +3 -3
- package/dist/task-cwd.d.ts +20 -0
- package/dist/task-cwd.js +8 -0
- package/dist/task-mcp.d.ts +1 -1
- package/dist/task-mcp.js +3 -3
- package/dist/task-settings.d.ts +14 -10
- package/dist/task-settings.js +18 -7
- package/dist/terminal.d.ts +25 -43
- package/dist/terminal.js +31 -11
- package/dist/tool-approval.d.ts +131 -129
- package/dist/tool-approval.js +189 -193
- 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/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 +1 -30
- 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 +55 -42
- package/dist/trace/project.js +52 -19
- package/dist/trace/redact.d.ts +123 -27
- package/dist/trace/redact.js +880 -260
- package/dist/trace/self-minted-wire.d.ts +487 -19
- package/dist/trace/self-minted-wire.js +172 -23
- 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 +13 -16
- 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/package.json +6 -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/wire-changes/server@7.148.0.json +1517 -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
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **删净一只会话 —— 一只执行体**(两个决定者共用:`DELETE /v1/sessions/:id` 的删除协调器 `boot/session-faces.ts`,与托管留存的会话树清扫)。
|
|
3
|
+
*
|
|
4
|
+
* ## 律
|
|
5
|
+
* 删净一只会话 = **在这只会话的行锁下**删完它挂靠的全部行,行本身最后删:
|
|
6
|
+
* · SQL 后端:一个事务(执行器 `stores-sql/retention-store-sql.ts` 的 `eraseSession` / `deleteExpiredSessions`,两只入口跑同一段事务体
|
|
7
|
+
* —— 锁行 → 会话座事务内钩判 → 部署行 → 引擎座行 → 行与日志 → 墓碑);
|
|
8
|
+
* · local 后端:{@link createLocalSessionEraser} —— 会话店这只会话的写锁一节(判 → 各店动词按 {@link SESSION_TREE_LEGS} → 删行)。
|
|
9
|
+
* 锁里那一判按决定者:在线删除 = 行的属主是围栏判过的那一位 ∧ `erase`(这一行处于**这一次删除的在删态** —— 令牌比对;会话三态 活 → 在删 → 没了,
|
|
10
|
+
* 律在 `session-deletion.ts`,围栏是删除协调器的事);留存 = `retention-delete`(没有认领、不在删)。令牌只在围栏判过属主之后写下,同 id 的下一位住客是新行、不带它 ⇒
|
|
11
|
+
* 一次陈旧 / 被接管的删除在锁里读到的不是自己的令牌,一行不删(`superseded`)。属主那一比是域键的一致性(SQL 的部署行与墓碑按域写,域在事务开之前就要定)。
|
|
12
|
+
* 会话挂靠的**行**都在锁里(含完成信箱的清除围栏与会话盒):删不掉 ⇒ 行留在删、删除可重试;锁着 ⇒ 碰不到下一位住客。提交之后由**同一只**收尾
|
|
13
|
+
* {@link createSessionEraseSettler} 处理按内容 / 按住客化身寻址的残余(附件字节、住客空间);SQL 组合座另在提交之后按「入队不晚于提交」清一次
|
|
14
|
+
* 事务进行中落下的迟到完成行(`retention-deployment.ts` 的 `sweepLateCompletionRows`)。
|
|
15
|
+
* 不在锁里的:在线删除在围栏之后、执行体之前对这只在删会话做的进程面动作(信箱 retire 围栏、子代结束、scratchpad、后台 shell、删过的 id)——
|
|
16
|
+
* 删除协调器每一步之前核令牌(`boot/session-faces.ts`);一步已经开跑时被接管的那一拍是协调器注里披露的残余(不是行)。
|
|
17
|
+
*
|
|
18
|
+
* ## 决定者之差
|
|
19
|
+
* 在线删除删的是一只**可能还活着**的会话(删前:子代预检 → 围栏 → 信箱 retire 围栏、子代结束、本进程删过的 id;删后:本副本的进程态);留存只删闲到视界外、
|
|
20
|
+
* 无活引用、不在删的会话(hold / 候选 / 活引用 / 审计)。行面唯一的差:规则行的 rev 高水位记号(在线留、留存删;`retention-store-sql.ts` 的 `RuleMarks`)。
|
|
21
|
+
*/
|
|
22
|
+
import { type MailboxStore, type ToolResultStore } from "@sema-agent/core";
|
|
23
|
+
import type { Logger } from "./observability/logger.js";
|
|
24
|
+
import type { WorkflowCompletionInbox } from "./orchestration/workflow-completion-inbox.js";
|
|
25
|
+
import type { SpaceReclaimer } from "./workspace-space.js";
|
|
26
|
+
/** 锁里读到的这一位住客(会话行上的属主 + 化身;存量行没有化身 ⇒ `undefined`)。 */
|
|
27
|
+
export interface SessionOccupant {
|
|
28
|
+
readonly owner: string | null;
|
|
29
|
+
readonly incarnation: string | undefined;
|
|
30
|
+
}
|
|
31
|
+
/** 一次执行体提交之后交收尾的东西:真删掉的会话(id + 删前属主 + 住客)、本次删掉的附件行的字节哈希、全库无出处卸载结果数。 */
|
|
32
|
+
export interface SessionTreesErased {
|
|
33
|
+
readonly sessions: readonly {
|
|
34
|
+
readonly sessionId: string;
|
|
35
|
+
readonly owner: string | null;
|
|
36
|
+
readonly incarnation: string | undefined;
|
|
37
|
+
}[];
|
|
38
|
+
/** 本次删掉的附件行的字节哈希(收尾按「无行引用才删」释放;local 的附件店随行删字节,恒空)。 */
|
|
39
|
+
readonly attachmentShas: readonly string[];
|
|
40
|
+
/** 全库无出处的卸载结果行数(core 口径:这类行任何会话删除都删不到 ⇒ 删除不完整;实体清理归 TTL)。 */
|
|
41
|
+
readonly unattributableToolResults: number;
|
|
42
|
+
}
|
|
43
|
+
/** 执行体的回执(闭集)。 */
|
|
44
|
+
export type SessionEraseReceipt =
|
|
45
|
+
/** 这一行此刻不是这一次删除的在删态 —— 另一次删除接管了它(换了令牌)或已经删完(行不在 / 同 id 的新住客)。一行没删。 */
|
|
46
|
+
{
|
|
47
|
+
readonly outcome: "superseded";
|
|
48
|
+
}
|
|
49
|
+
/** 全部行已删、已提交。 */
|
|
50
|
+
| {
|
|
51
|
+
readonly outcome: "erased";
|
|
52
|
+
readonly trees: SessionTreesErased;
|
|
53
|
+
};
|
|
54
|
+
/** 执行体的入参:哪只会话 + 删除协调器的围栏判过的那一位属主(域键)+ 围栏写下的令牌(判官比的那一只)。 */
|
|
55
|
+
export interface SessionEraseInput {
|
|
56
|
+
readonly sessionId: string;
|
|
57
|
+
readonly owner: string | null;
|
|
58
|
+
readonly token: string;
|
|
59
|
+
}
|
|
60
|
+
/** 删净一只在删会话的执行体(SQL:执行器的组合座交出;local:{@link createLocalSessionEraser})。 */
|
|
61
|
+
export interface SessionEraser {
|
|
62
|
+
erase(input: SessionEraseInput): Promise<SessionEraseReceipt>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 会话树的行腿 —— **闭集,序即执行序**(SQL 事务体的语句序对它:`test/session-erase-single-executor.test.ts` 录制钉按首次出现序比)。
|
|
66
|
+
* `checkpoint` 腿含停驻 ctx 旁表(SQL 上 ctx 在部署段、检查点行在引擎座段,首次出现序落在这里)。`mailbox` 是行删除之前的**最后一腿**:会话盒的 `drop`
|
|
67
|
+
* 同时撤掉投递围栏(墓碑随箱亡),之后除了会话行不许再有别的腿(local 上各店逐个落盘,围栏撤了而行还在的那一段窗只容会话行那一步)。
|
|
68
|
+
*/
|
|
69
|
+
export declare const SESSION_TREE_LEGS: readonly ["runs", "approval", "checkpoint", "anchors", "exemption", "attachment", "user_input", "task_list", "workflow_inbox", "tool_result", "policy", "file_history", "mailbox"];
|
|
70
|
+
export type SessionTreeLeg = (typeof SESSION_TREE_LEGS)[number];
|
|
71
|
+
/** local 执行体的各店(缺席 = 本部署没有这只店 ⇒ 这一腿无行可删)。动词与在线协调器此前逐店调的同一组。 */
|
|
72
|
+
export interface LocalSessionTreeStores {
|
|
73
|
+
readonly runStore: {
|
|
74
|
+
deleteBySession(sessionId: string): Promise<{
|
|
75
|
+
removed: number;
|
|
76
|
+
}>;
|
|
77
|
+
} | undefined;
|
|
78
|
+
readonly approvalAskStore: {
|
|
79
|
+
deleteBySession(sessionId: string): Promise<void>;
|
|
80
|
+
} | undefined;
|
|
81
|
+
readonly checkpointStore: {
|
|
82
|
+
deleteBySession(sessionId: string, owner: string | null): Promise<number>;
|
|
83
|
+
} | undefined;
|
|
84
|
+
readonly resumeAnchorStore: {
|
|
85
|
+
deleteBySession(sessionId: string): Promise<unknown>;
|
|
86
|
+
} | undefined;
|
|
87
|
+
readonly approvalExemptionStore: {
|
|
88
|
+
deleteBySession(sessionId: string): Promise<unknown>;
|
|
89
|
+
} | undefined;
|
|
90
|
+
readonly taskAttachmentStore: {
|
|
91
|
+
deleteBySession(sessionId: string): Promise<number>;
|
|
92
|
+
} | undefined;
|
|
93
|
+
readonly userInputLedgerStore: {
|
|
94
|
+
deleteBySession(sessionId: string): Promise<unknown>;
|
|
95
|
+
} | undefined;
|
|
96
|
+
readonly taskListLane: {
|
|
97
|
+
deleteBySession(sessionId: string): Promise<void>;
|
|
98
|
+
} | undefined;
|
|
99
|
+
readonly workflowCompletionInbox: Pick<WorkflowCompletionInbox, "purge"> | undefined;
|
|
100
|
+
readonly mailboxStore: Pick<MailboxStore, "drop"> | undefined;
|
|
101
|
+
readonly toolResultStore: Pick<ToolResultStore, "deleteBySession"> | undefined;
|
|
102
|
+
readonly sessionPolicyStore: {
|
|
103
|
+
deleteBySession?(sessionId: string): Promise<void>;
|
|
104
|
+
} | undefined;
|
|
105
|
+
readonly fileHistoryErasure: {
|
|
106
|
+
deleteBySession?(scope: string): Promise<unknown>;
|
|
107
|
+
reap(scope: string, keep: readonly string[]): Promise<unknown>;
|
|
108
|
+
} | undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* local 会话店的删除锁节(`plugins/local-session-store.ts` 的 `deleteSession`):这只会话的写锁里 —— 行不在 / 属主不是 `owner` ⇒ `undefined`;
|
|
112
|
+
* `erase` 判(这一行处于 `token` 那一次删除的在删态;不是 ⇒ 抛 `SessionDeletionSupersededError`)—— 两支都一行不删;→ `legs(锁里读到的住客)` → 删行,交回那一位住客。
|
|
113
|
+
*/
|
|
114
|
+
export type LocalSessionDeletionSection = (sessionId: string, owner: string | null, token: string, legs: (occupant: SessionOccupant) => Promise<void>) => Promise<SessionOccupant | undefined>;
|
|
115
|
+
/**
|
|
116
|
+
* local 后端的执行体:会话店写锁一节里按 {@link SESSION_TREE_LEGS} 跑各店动词(闭集 `switch`,漏一腿 = 编译红)。一腿抛 ⇒ 锁节抛、行不删(重发收敛)。
|
|
117
|
+
*/
|
|
118
|
+
export declare function createLocalSessionEraser(deleteSession: LocalSessionDeletionSection, stores: LocalSessionTreeStores, logger: Pick<Logger, "warn">): SessionEraser;
|
|
119
|
+
/** 收尾要的座(缺席 = 本部署没有这一样残余)。 */
|
|
120
|
+
export interface SessionEraseSettleSeats {
|
|
121
|
+
/** 附件字节的释放口(SQL 附件店:无行引用才删对象)。 */
|
|
122
|
+
readonly attachments: {
|
|
123
|
+
releaseBytes(shas: readonly string[]): Promise<{
|
|
124
|
+
readonly failed: readonly string[];
|
|
125
|
+
}>;
|
|
126
|
+
} | undefined;
|
|
127
|
+
readonly spaceReclaimer: SpaceReclaimer | undefined;
|
|
128
|
+
readonly logger: Pick<Logger, "warn">;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 收尾:一次执行体提交之后对真删掉的会话处理库外残余。答出时附件字节那一步已做完;`spaces` = 住客空间回收那一步
|
|
132
|
+
* (对象存储上的一串请求,座按契约不抛、抛了已被这里响亮接住 ⇒ 它永不拒):在线删除不等它(应答不等对象存储),留存清扫等它(一轮在截止上收手)。
|
|
133
|
+
*/
|
|
134
|
+
export type SessionEraseSettler = (trees: SessionTreesErased) => Promise<{
|
|
135
|
+
readonly spaces: Promise<void>;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* 两个决定者共用的**收尾**(行已删、已提交)。只收**按内容寻址 / 按住客化身寻址**的残余 —— 碰不到同 id 重登记的下一位住客;
|
|
139
|
+
* 会话挂靠的行(含完成信箱围栏与行、会话盒)都在执行体的锁里(删不掉 ⇒ 行留着、删除可重试)。每一步失败只记一行 warn,各有兜底:
|
|
140
|
+
* ① 附件字节 —— 本次删掉的附件行的哈希,无行引用才删对象(孤儿 GC 兜底);
|
|
141
|
+
* ② 住客空间 —— 住客化身在的会话交回收座(答案里的 `spaces`:等不等它是决定者的事;座按契约不抛,抛了这里响亮接住;桶的生命周期规则兜底);
|
|
142
|
+
* ③ 全库无出处卸载结果数 > 0 ⇒ 一行 warn(删除不完整的如实告知)。
|
|
143
|
+
*/
|
|
144
|
+
export declare function createSessionEraseSettler(seats: SessionEraseSettleSeats): SessionEraseSettler;
|
|
145
|
+
//# sourceMappingURL=session-erase.d.ts.map
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { peerSessionBoxHandle } from "@sema-agent/core";
|
|
2
|
+
import { recordFailOpen } from "./observability/fail-open.js";
|
|
3
|
+
import { redactIncarnations } from "./session-incarnation.js";
|
|
4
|
+
import { seatText } from "./trace/exit-seat.js";
|
|
5
|
+
import { sessionTenantScope } from "./session-children-retire.js";
|
|
6
|
+
import { SessionDeletionSupersededError } from "./execution-placement.js";
|
|
7
|
+
export const SESSION_TREE_LEGS = ["runs", "approval", "checkpoint", "anchors", "exemption", "attachment", "user_input", "task_list", "workflow_inbox", "tool_result", "policy", "file_history", "mailbox"];
|
|
8
|
+
export function createLocalSessionEraser(deleteSession, stores, logger) {
|
|
9
|
+
return {
|
|
10
|
+
async erase({ sessionId, owner, token }) {
|
|
11
|
+
let unattributable = 0;
|
|
12
|
+
const leg = async (which, occupant) => {
|
|
13
|
+
switch (which) {
|
|
14
|
+
case "runs":
|
|
15
|
+
return void (await stores.runStore?.deleteBySession(sessionId));
|
|
16
|
+
case "approval":
|
|
17
|
+
return void (await stores.approvalAskStore?.deleteBySession(sessionId));
|
|
18
|
+
case "checkpoint":
|
|
19
|
+
return void (await stores.checkpointStore?.deleteBySession(sessionId, occupant.owner));
|
|
20
|
+
case "anchors":
|
|
21
|
+
return void (await stores.resumeAnchorStore?.deleteBySession(sessionId));
|
|
22
|
+
case "exemption":
|
|
23
|
+
return void (await stores.approvalExemptionStore?.deleteBySession(sessionId));
|
|
24
|
+
case "attachment":
|
|
25
|
+
return void (await stores.taskAttachmentStore?.deleteBySession(sessionId));
|
|
26
|
+
case "user_input":
|
|
27
|
+
return void (await stores.userInputLedgerStore?.deleteBySession(sessionId));
|
|
28
|
+
case "task_list":
|
|
29
|
+
return void (await stores.taskListLane?.deleteBySession(sessionId));
|
|
30
|
+
case "workflow_inbox":
|
|
31
|
+
return void (await stores.workflowCompletionInbox?.purge(sessionId, occupant.owner));
|
|
32
|
+
case "tool_result": {
|
|
33
|
+
const report = await stores.toolResultStore?.deleteBySession?.(sessionId);
|
|
34
|
+
if (report !== undefined)
|
|
35
|
+
unattributable = report.unattributable;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
case "policy":
|
|
39
|
+
return void (await stores.sessionPolicyStore?.deleteBySession?.(sessionId));
|
|
40
|
+
case "file_history": {
|
|
41
|
+
const erasure = stores.fileHistoryErasure;
|
|
42
|
+
if (erasure === undefined)
|
|
43
|
+
return;
|
|
44
|
+
if (typeof erasure.deleteBySession === "function")
|
|
45
|
+
return void (await erasure.deleteBySession(sessionId));
|
|
46
|
+
await erasure.reap(sessionId, []);
|
|
47
|
+
logger.warn("session_file_history_baselines_retained", {
|
|
48
|
+
sessionId,
|
|
49
|
+
note: "this file-history store has no whole-scope erase verb (deleteBySession); boundaries were reaped but v1 baselines (original file bytes) remain in the store until it implements that verb — an open deletion-rights gap, not silent",
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
case "mailbox":
|
|
54
|
+
return void (await stores.mailboxStore?.drop(sessionTenantScope(occupant.owner), peerSessionBoxHandle(sessionId)));
|
|
55
|
+
default: {
|
|
56
|
+
const unknownLeg = which;
|
|
57
|
+
throw new Error(`session erase: no arm for leg ${JSON.stringify(unknownLeg)}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
let erased;
|
|
62
|
+
try {
|
|
63
|
+
erased = await deleteSession(sessionId, owner, token, async (occupant) => {
|
|
64
|
+
for (const which of SESSION_TREE_LEGS)
|
|
65
|
+
await leg(which, occupant);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
if (err instanceof SessionDeletionSupersededError)
|
|
70
|
+
return { outcome: "superseded" };
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
if (erased === undefined)
|
|
74
|
+
return { outcome: "superseded" };
|
|
75
|
+
return { outcome: "erased", trees: { sessions: [{ sessionId, ...erased }], attachmentShas: [], unattributableToolResults: unattributable } };
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function createSessionEraseSettler(seats) {
|
|
80
|
+
const { logger } = seats;
|
|
81
|
+
return async (trees) => {
|
|
82
|
+
if (trees.attachmentShas.length > 0 && seats.attachments !== undefined) {
|
|
83
|
+
const released = await seats.attachments.releaseBytes(trees.attachmentShas).catch((err) => ({ failed: trees.attachmentShas, err: seatText("operator-log-text", String(err)) }));
|
|
84
|
+
if (released.failed.length > 0) {
|
|
85
|
+
logger.warn("session_erase_attachment_bytes_release_failed", {
|
|
86
|
+
shas: trees.attachmentShas.length,
|
|
87
|
+
failed: released.failed.length,
|
|
88
|
+
...("err" in released ? { err: released.err } : {}),
|
|
89
|
+
effect: "these objects stay until the orphan-object sweep collects them (its grace applies)",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const spaces = trees.sessions.flatMap((s) => (s.incarnation === undefined ? [] : [{ sessionId: s.sessionId, spaceKey: s.incarnation }]));
|
|
94
|
+
let reclaimed = Promise.resolve();
|
|
95
|
+
if (spaces.length > 0 && seats.spaceReclaimer !== undefined) {
|
|
96
|
+
reclaimed = seats.spaceReclaimer.reclaim(spaces).catch((err) => {
|
|
97
|
+
recordFailOpen("server.workspace-space.reclaim-failed", "stage=seat_threw");
|
|
98
|
+
logger.warn("workspace_space_reclaim_failed", {
|
|
99
|
+
sessions: spaces.length,
|
|
100
|
+
stage: "seat_threw",
|
|
101
|
+
error: seatText("operator-log-text", redactIncarnations(String(err))),
|
|
102
|
+
effect: "the ended space's cache volume and snapshot objects may stay (the reclaim seat threw, which its contract forbids; the session delete went ahead) — the bucket's lifecycle rule is the fallback for objects, the volume is deleted by label sema.space",
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (trees.unattributableToolResults > 0) {
|
|
107
|
+
logger.warn("tool_result_unattributable_rows_survive_session_delete", {
|
|
108
|
+
sessions: trees.sessions.map((s) => s.sessionId),
|
|
109
|
+
unattributable: trees.unattributableToolResults,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return { spaces: reclaimed };
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=session-erase.js.map
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
* (同 `placement_kind` 的先例),不在这里解析句子。
|
|
31
31
|
* · `not_found` —— 留白:每一面各有自己的「不存在」答法(404 `not_found.session` / 同步口的 `resume.session_not_found` /
|
|
32
32
|
* 列表里的缺席),码位各不相同,不由本表统一。
|
|
33
|
-
* · `placement_refused` —— `import` 面 **409 `conflict.session_placed`**(机读位 `
|
|
33
|
+
* · `placement_refused` —— `import` 面 **409 `conflict.session_placed`**(机读位 `placement_kind`,在拒体根上;固定句);`open` 面留白。
|
|
34
34
|
* 同一个词在两面上说的不是同一件事:import 面只有「会话同步往一只**分区会话**(委派子代的转录)上写」一个来源
|
|
35
35
|
* (三只持久会话店的整段换装 / 暂存提交门:目标 id 的 `placement_kind` 在场 ⇒ 不适用),调用方没做错格式、是**目标**不收这种写;
|
|
36
36
|
* open 面上同一个词还含「声明了分区的创建撞上了分区外 / 异组的行」两形(core `TtlSessionStore.assertPlacementAdmission` 的后两条),
|
|
37
37
|
* 那不是「目标是分区会话」。而 run 终局上它是引擎词汇(`terminal.code`),原样随 failed 体走 —— 若在这里分诊成 409,
|
|
38
38
|
* 体上的 `errorCode` 仍是引擎词 `placement_refused`,一个状态两个名字。所以 open 面留白。
|
|
39
39
|
* 409 的语义:目标会话**状态**不收这种写(重试同一个 id 同一结果;换一个会话 id 推)—— 与 `conflict.session_ownerless` / `conflict.session_children_alive` 同族。
|
|
40
|
-
* `
|
|
40
|
+
* `placement_kind` 是**常量**,不是从错误里读的:core 的 `SessionError` 只带 `code` 与句子,不带种类;今天分区种类闭集只有
|
|
41
41
|
* `"subagent"` 一个词,所以常量就是事实。core 给 `SessionPlacementRecord["kind"]` 加第二个词 ⇒ 下面的守卫编译红,由人裁定种类从哪儿读
|
|
42
42
|
* (请求 core 把种类放进错误,而不是在这里解析句子)。
|
|
43
43
|
* · `invalid_entry` / `invalid_fork_target` —— 留白:本仓今天没有一条 wire 口把它们作为自己的
|
|
@@ -76,8 +76,8 @@ export interface SessionErrorWire {
|
|
|
76
76
|
* 点名条目 id / 会话 id / 引擎内部词,wire 上只回一句固定话(各自冻结在 `test/api-error-text-freeze.test.ts` 的常量锚格)。
|
|
77
77
|
*/
|
|
78
78
|
readonly sentence?: string;
|
|
79
|
-
/** 机读事实(
|
|
80
|
-
readonly
|
|
79
|
+
/** 机读事实(摊在拒体根上;缺席 = 没有可机读的事实)。只有 import 面的 `placement_refused` 用它:`{ placement_kind }`(键名随 SQL 列)。 */
|
|
80
|
+
readonly facts?: Readonly<Record<string, string>>;
|
|
81
81
|
}
|
|
82
82
|
/** import 面 `invalid_session` 的固定句(修前 session-sync 暂存导入腿那一行的原文)。 */
|
|
83
83
|
export declare const STAGED_IMPORT_INVALID_SENTENCE = "staged session log failed validation";
|
|
@@ -108,7 +108,7 @@ export declare class StampedSessionArchiveError extends SessionError {
|
|
|
108
108
|
*
|
|
109
109
|
* 码与句子**就是**那只存档故障的(`cause` = 它;码不另铸 —— 只会是 `corrupt_session`,读不出而说不出在不在的 I/O 级故障不换型):
|
|
110
110
|
* 不认识本型的站点看到的与此前逐字相同(`sessionErrorHttp` 按码映射,wire 与运维日志不变)。认识本型的站点 —— 会话读面的属主读
|
|
111
|
-
* (`http/owner-access.ts` 的 `
|
|
111
|
+
* (`http/owner-access.ts` 的 `readOwnerCell`)—— 把它读成「没有这一行」:与对非属主、对不存在的会话同一只 404,原故障进运维日志。
|
|
112
112
|
*/
|
|
113
113
|
export declare class SessionOwnerUnreadableError extends SessionError {
|
|
114
114
|
constructor(fault: SessionError);
|
|
@@ -22,7 +22,7 @@ export class SessionOwnerUnreadableError extends SessionError {
|
|
|
22
22
|
export const STAMPED_SESSION_ARCHIVE_SENTENCE = "this session's stored archive still carries an owner stamp written by an earlier server version, so it cannot be forked or have its log replaced; nothing was written — delete the session and push it again";
|
|
23
23
|
const CORRUPT_SESSION = { status: 500, errorCode: "corrupt_session" };
|
|
24
24
|
const INVALID_ENTRIES = { status: 422, errorCode: "invalid_entries", sentence: STAGED_IMPORT_INVALID_SENTENCE };
|
|
25
|
-
const SESSION_PLACED = { status: 409, errorCode: "conflict.session_placed", sentence: PLACED_SESSION_SENTENCE,
|
|
25
|
+
const SESSION_PLACED = { status: 409, errorCode: "conflict.session_placed", sentence: PLACED_SESSION_SENTENCE, facts: { placement_kind: PLACEMENT_KIND } };
|
|
26
26
|
const STAGED_IMPORT_OWNER_CHANGED = { status: 409, errorCode: "conflict", sentence: STAGED_IMPORT_OWNER_CHANGED_SENTENCE };
|
|
27
27
|
const STAMPED_SESSION_ARCHIVE = { status: 409, errorCode: "conflict.session_archive_stamped", sentence: STAMPED_SESSION_ARCHIVE_SENTENCE };
|
|
28
28
|
export function sessionErrorWireOf(e, face) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ## 规则(全仓唯一处写)
|
|
9
9
|
* · **铸点只在新建行**:会话店的 `register` / 无 id 创建 / fork / session-sync 的导入新行。已存在的行化身一个字节都不动;
|
|
10
|
-
* session-sync 的整段换装(replace / staged commit)换的是**同一位住客**的日志,化身沿用 ——
|
|
10
|
+
* session-sync 的整段换装(replace / staged commit)换的是**同一位住客**的日志,化身沿用 —— 属主却可以被换装重戳为导入者,
|
|
11
11
|
* 所以化身与属主不是同一条律(读法分三种,见下「两读」)。删除随行消失,同 id 重新登记铸新的。
|
|
12
12
|
* · **两读(住客的三种问法,各读各的格,不混用)**:
|
|
13
13
|
* K1 **住客自己的记录**(工作区、记忆、空间分区……按「这一位住客」落的东西)只按化身绑 —— 同一位住客的属主换代(推送重戳 / 认领)不换住客,记录照落;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* (`execution-placement.ts` 的 `sameOccupant`,SQL `incarnation = ? AND owner <=> ?` 的对位)—— 读与写之间属主换了一代 ⇒ 不是判过的那一行;
|
|
16
16
|
* K0 **只问属主的门**(授权门、暂存提交的属主 CAS)只读属主那一格。三种都读会话**行**;local 店的行 = 会话元数据边档那一格(引擎仓里的存档是匿名内容仓,
|
|
17
17
|
* 存档头上的属主不是行事实 —— `plugins/local-session-store.ts` 头注)。
|
|
18
|
-
* · **值是不透明随机串**(`
|
|
18
|
+
* · **值是不透明随机串**(铸法只有 core 的 `incarnationCell(undefined)`,v4:没有时间戳、没有机器信息 —— 刻意不用 uuidv7,那一形带铸造时刻)。只拿来比较。
|
|
19
19
|
* · **一格、一个解码**:住客令牌是会话**行**上的一格 —— SQL `session_meta.incarnation`(两方言)、local 后端的会话元数据边档那一格
|
|
20
20
|
* (`plugins/local-session-store.ts` 的 `session-incarnations.json`)。行上的值只经 {@link incarnationFromCell} 解码。
|
|
21
21
|
* · **按 id 读只有一只:core 的 `SessionStore.headOf(id)`**(core 7.55.0 [ref] S2;`{ owner, incarnation, leafId }`,同一行、同一次读 ——
|
|
@@ -47,10 +47,11 @@
|
|
|
47
47
|
* 认领之后唯一写口按那一读的住客定址判一次(化身 ∧ 属主;不在或不是那一位 ⇒ 回滚认领、答既有的 `409 decide.not_parked`);
|
|
48
48
|
* 赎回面(`parked-revive-surface.ts`)只收写口放行的那一位,属主 = 卡的 principal 时交继承座。
|
|
49
49
|
* · core 的记忆引擎:Runner 读**它取到的那只会话**的 `getMetadata().incarnation`(SQL 两店的 wake 带出这一列;local 店交出的会话
|
|
50
|
-
* 在元数据上答边档那一格),不再有宿主座。
|
|
50
|
+
* 在元数据上答边档那一格),不再有宿主座。local 数据根上两条入口(HTTP 服务的 local 臂、run-local)经**同一只** local 店打开会话
|
|
51
|
+
* (`plugins/store-backend.ts` 的 `openLocalBackend`)⇒ 同一只会话在两条入口上是同一位住客;引擎存档头上另铸的那只令牌不作住客读(只当存档的行代号)。
|
|
51
52
|
* · 没取会话的那一侧(k8s 工作区空间的分区,`boot/execution-env.ts`):会话店的 `headOf`,经 {@link sessionFaceOfHead} 拿令牌;缓存包装层原样转发。
|
|
52
53
|
*/
|
|
53
|
-
import type
|
|
54
|
+
import { type SessionHead, type SessionMetadata } from "@sema-agent/core";
|
|
54
55
|
/** 一位活住客:属主 + 它的令牌(同一行、同一次读;投影自会话店的头,见 {@link sessionFaceOfHead})。 */
|
|
55
56
|
export interface SessionFace {
|
|
56
57
|
/** `null` = 登记为无主的会话。 */
|
|
@@ -60,7 +61,10 @@ export interface SessionFace {
|
|
|
60
61
|
}
|
|
61
62
|
/** 会话店的按 id 读(core `SessionStore.headOf` 的形):`undefined` = 没有这只会话;读抛 = 读故障,不是答案。 */
|
|
62
63
|
export type HeadRead = (sessionId: string) => Promise<SessionHead | undefined>;
|
|
63
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* 铸一只新化身(铸点见头注,只在新建行)。**铸法只有 core 那一只**:`incarnationCell(undefined)` —— 引擎自带仓的唯一铸点(新行一只随机 v4 串,无时间无机器);
|
|
66
|
+
* 本仓不再自带第二份铸法。core 的返回型把这一格写作可选(`existing` 非空时可以无令牌),新行永远有 —— 这里只收窄成 `string`,缺了是响亮的不变量破,不补铸。
|
|
67
|
+
*/
|
|
64
68
|
export declare function mintSessionIncarnation(): string;
|
|
65
69
|
/** 日志里点名一只化身时唯一允许的形:前 8 位。完整令牌不进任何日志正文。 */
|
|
66
70
|
export declare function incarnationLogPrefix(incarnation: string): string;
|
|
@@ -128,6 +132,11 @@ export declare function sessionFaceOfHead(sessionId: string, head: SessionHead |
|
|
|
128
132
|
* 一次性迁移 M23(窗内)的回填读的都是这一只返回值。缺席 = 店没有实装 `headOf`(读不出属主 / 住客 / 叶子,调用方各按自己的 fail-closed 臂处置)。
|
|
129
133
|
*/
|
|
130
134
|
export declare function headReadOf(store: object | undefined): HeadRead | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* 删除门(`DELETE /v1/sessions/:id` 的属主门 + 协调器的化身围栏)的头读 —— **只判这一处**:店交了 `deletionHeadOf`(删除已开始、还没收完的那一行也答得出属主与住客;local)⇒ 它;
|
|
137
|
+
* 否则 ⇒ {@link headReadOf}(删除是一个事务的店,没有删到一半的行)。缺席 = 店没有按 id 读。
|
|
138
|
+
*/
|
|
139
|
+
export declare function deletionHeadReadOf(store: object | undefined): HeadRead | undefined;
|
|
131
140
|
/** 换装沿用的行格(化身 + fork 键):{@link carriedRowCells} 的答案。`forkKey: null` = 没有可沿用的键(新建行 / 行上本来没有)。 */
|
|
132
141
|
export interface CarriedRowCells {
|
|
133
142
|
readonly incarnation: string;
|
|
@@ -158,4 +167,42 @@ export declare const SESSION_META_INCARNATION_COLUMN: {
|
|
|
158
167
|
readonly mysql: "incarnation VARCHAR(64) NOT NULL DEFAULT ''";
|
|
159
168
|
readonly pg: "incarnation VARCHAR(64) COLLATE \"C\" NOT NULL DEFAULT ''";
|
|
160
169
|
};
|
|
170
|
+
/**
|
|
171
|
+
* SQL 两方言 `session_meta` 的 fork 谱系两列(列定义的唯一属主;两方言建表语句各插一处 —— 与上面的化身列同住:谱系的住客那一半就是源行那一刻的化身;
|
|
172
|
+
* 谁写、怎么铸见 `plugins/session-fork.ts`「fork 谱系」)。宽度 = 会话 id 列 / 化身列的宽度(两格存的就是这两种值)。
|
|
173
|
+
* 可空:NULL = 不是 fork 建的行,或谱系落地之前建的 fork(不回填)。存量库缺这两列 ⇒ 起服列册对账拒启,拒句给 ALTER(由本建表语句生成)。
|
|
174
|
+
*/
|
|
175
|
+
export declare const SESSION_META_LINEAGE_COLUMNS: {
|
|
176
|
+
readonly mysql: "forked_from VARCHAR(64) NULL,\n forked_from_incarnation VARCHAR(64) NULL";
|
|
177
|
+
readonly pg: "forked_from VARCHAR(64) COLLATE \"C\",\n forked_from_incarnation VARCHAR(64) COLLATE \"C\"";
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* 行上谱系两格 → 交出的会话元数据的谱系两键(三店的唯一读法:SQL 唤醒读两列、列表读 `forked_from`;local 读那一格的两位)。
|
|
181
|
+
* 非空串 ⇒ 在;NULL / 缺 / 空串 ⇒ 键缺席(omit-when-absent,恒不铸 `null`)。来源住客读法 = 化身的宽读臂(与头读的住客同一只解码);它是谱系的住客那一半 ——
|
|
182
|
+
* 没有源 id 就没有谱系,来源住客也不单独交出。
|
|
183
|
+
*/
|
|
184
|
+
export declare function forkLineageOfRow(sessionId: string, forkedFrom: unknown, forkedFromIncarnation: unknown): Pick<SessionMetadata, "forkedFrom" | "forkedFromIncarnation">;
|
|
185
|
+
/** 一次新建行交回的候选:哪只会话、记下的属主、这一次 INSERT 铸的化身(入参里铸的那一只,不是登记之后的复读)。 */
|
|
186
|
+
export interface SessionBirth {
|
|
187
|
+
readonly sessionId: string;
|
|
188
|
+
readonly owner: string | null;
|
|
189
|
+
readonly incarnation: string;
|
|
190
|
+
}
|
|
191
|
+
/** 登记回执:`minted` 只在这一笔真建了新行时在场。 */
|
|
192
|
+
export interface RegisterReceipt {
|
|
193
|
+
readonly minted?: SessionBirth;
|
|
194
|
+
}
|
|
195
|
+
/** 撤回判下来「留」的店内词(闭集;出口的计数词表在它之上加座内的词,`src/submission-exit.ts`)。`claim` = 这一行被持有:活 run 的认领,或一次删除的在删态(会话三态,`session-deletion.ts`)。 */
|
|
196
|
+
export type StoreKeptWord = "absent" | "incarnation" | "content" | "claim" | "client_writes" | "runs" | "upgrade_pending";
|
|
197
|
+
/** 撤回的结局。 */
|
|
198
|
+
export type WithdrawOutcome = {
|
|
199
|
+
readonly withdrawn: true;
|
|
200
|
+
} | {
|
|
201
|
+
readonly withdrawn: false;
|
|
202
|
+
readonly kept: StoreKeptWord;
|
|
203
|
+
};
|
|
204
|
+
/** 部署判据的答案(店的条件删除在同一事务里问部署):放行(本次 run 的部署行已在同一事务里删掉)或留(部署那一半的哪一条)。 */
|
|
205
|
+
export type WithdrawJudgeVerdict = "proceed" | {
|
|
206
|
+
readonly keep: Extract<StoreKeptWord, "client_writes" | "runs" | "upgrade_pending">;
|
|
207
|
+
};
|
|
161
208
|
//# sourceMappingURL=session-incarnation.d.ts.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { incarnationCell } from "@sema-agent/core";
|
|
2
2
|
export function mintSessionIncarnation() {
|
|
3
|
-
|
|
3
|
+
const { incarnation } = incarnationCell(undefined);
|
|
4
|
+
if (incarnation === undefined)
|
|
5
|
+
throw new Error("core's incarnationCell(undefined) minted no token for a new row — refusing to invent one");
|
|
6
|
+
return incarnation;
|
|
4
7
|
}
|
|
5
8
|
export function incarnationLogPrefix(incarnation) {
|
|
6
9
|
return incarnation.slice(0, 8);
|
|
@@ -67,6 +70,10 @@ export function headReadOf(store) {
|
|
|
67
70
|
const read = store?.headOf;
|
|
68
71
|
return typeof read === "function" ? read.bind(store) : undefined;
|
|
69
72
|
}
|
|
73
|
+
export function deletionHeadReadOf(store) {
|
|
74
|
+
const read = store?.deletionHeadOf;
|
|
75
|
+
return typeof read === "function" ? read.bind(store) : headReadOf(store);
|
|
76
|
+
}
|
|
70
77
|
export function carriedRowCells(sessionId, prior) {
|
|
71
78
|
const held = prior === undefined ? undefined : incarnationFromCell(sessionId, prior.incarnation, "absent");
|
|
72
79
|
if (held === undefined)
|
|
@@ -78,4 +85,14 @@ export const SESSION_META_INCARNATION_COLUMN = {
|
|
|
78
85
|
mysql: "incarnation VARCHAR(64) NOT NULL DEFAULT ''",
|
|
79
86
|
pg: `incarnation VARCHAR(64) COLLATE "C" NOT NULL DEFAULT ''`,
|
|
80
87
|
};
|
|
88
|
+
export const SESSION_META_LINEAGE_COLUMNS = {
|
|
89
|
+
mysql: "forked_from VARCHAR(64) NULL,\n forked_from_incarnation VARCHAR(64) NULL",
|
|
90
|
+
pg: `forked_from VARCHAR(64) COLLATE "C",\n forked_from_incarnation VARCHAR(64) COLLATE "C"`,
|
|
91
|
+
};
|
|
92
|
+
export function forkLineageOfRow(sessionId, forkedFrom, forkedFromIncarnation) {
|
|
93
|
+
if (typeof forkedFrom !== "string" || forkedFrom === "")
|
|
94
|
+
return {};
|
|
95
|
+
const occupant = incarnationFromCell(sessionId, forkedFromIncarnation, "absent");
|
|
96
|
+
return { forkedFrom, ...(occupant !== undefined ? { forkedFromIncarnation: occupant } : {}) };
|
|
97
|
+
}
|
|
81
98
|
//# sourceMappingURL=session-incarnation.js.map
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* · 本仓自己的形读者、桶表与逐键问引擎的那一圈(同一问的第二个读者,[ref])⇒ 读回直接读引擎的形读法。
|
|
22
22
|
*/
|
|
23
23
|
import { SessionPolicyError } from "@sema-agent/core";
|
|
24
|
-
import type { SessionPermissionRules, SessionRuleEntryRefusal,
|
|
24
|
+
import type { SessionPermissionRules, SessionRuleEntryRefusal, SessionRulesRecord } from "@sema-agent/core";
|
|
25
25
|
/** 引擎的两只**内容**拒(规则体自己的问题;`conflict` / `loosen_forbidden` / `corrupt` 是店与这一次写的关系,不在此列)。 */
|
|
26
26
|
export type SessionRulesRefusal = SessionPolicyError & {
|
|
27
27
|
readonly code: "invalid_shape" | "inert_entry";
|
|
@@ -120,8 +120,11 @@ export declare function describeInertEntry(r: SessionRuleEntryRefusal): string;
|
|
|
120
120
|
* 引擎契约破了(`inert_entry` 不带条目读数)⇒ 抛,不编一句。
|
|
121
121
|
*/
|
|
122
122
|
export declare function sessionPolicyErrorSentence(e: SessionPolicyError): string;
|
|
123
|
-
/**
|
|
124
|
-
|
|
123
|
+
/**
|
|
124
|
+
* 一只 `SessionPolicyError` 上 wire 的拒体事实(只在两只内容码上有):引擎的 `detail` 经**闭集映射**进拒体根(对位 `http/refusal-body.ts` 的 `resumeRefusalFacts`)——
|
|
125
|
+
* 按码取那一张键表,逐键过境、值原样;表外的键(引擎多带的成员、句子专用的 `carriedBy`)不过境,值为 `undefined` 的键不铸。
|
|
126
|
+
*/
|
|
127
|
+
export declare function sessionPolicyErrorFacts(e: SessionPolicyError): Readonly<Record<string, unknown>> | undefined;
|
|
125
128
|
/**
|
|
126
129
|
* 🔴 **`SessionPolicyError` 的闭集 → HTTP 的**唯一**映射(core 7.25.0 提货批新建)。**
|
|
127
130
|
*
|
|
@@ -107,8 +107,18 @@ export function sessionPolicyErrorSentence(e) {
|
|
|
107
107
|
throw new Error(`SessionPolicyError inert_entry without the entry reader's detail: ${e.message}`);
|
|
108
108
|
return describeInertEntry(e.detail);
|
|
109
109
|
}
|
|
110
|
+
const SHAPE_REFUSAL_FACT_KEYS = ["field", "got"];
|
|
111
|
+
const ENTRY_REFUSAL_FACT_KEYS = ["field", "entry", "reason", "verdict", "guidance", "currentName", "ambiguous", "valueType"];
|
|
110
112
|
export function sessionPolicyErrorFacts(e) {
|
|
111
|
-
|
|
113
|
+
if (!isSessionRulesRefusal(e) || e.detail === undefined)
|
|
114
|
+
return undefined;
|
|
115
|
+
const detail = { ...e.detail };
|
|
116
|
+
const keys = e.code === "invalid_shape" ? SHAPE_REFUSAL_FACT_KEYS : ENTRY_REFUSAL_FACT_KEYS;
|
|
117
|
+
const facts = {};
|
|
118
|
+
for (const key of keys)
|
|
119
|
+
if (detail[key] !== undefined)
|
|
120
|
+
facts[key] = detail[key];
|
|
121
|
+
return facts;
|
|
112
122
|
}
|
|
113
123
|
export function sessionPolicyErrorHttp(code) {
|
|
114
124
|
switch (code) {
|
|
@@ -1,74 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `/health.inflight` 计法表里**会话驻留的后台行**两类 —— 后台子代理(`backgroundAgents`,进阻断集)与后台 shell / monitor(`sessionResident`,只进总数)。
|
|
3
|
-
*
|
|
4
|
-
* ## 病
|
|
5
|
-
* 引擎在飞数原先只数 HTTP 腿与 leader 腿。模型在会话里起的后台活 —— `run_in_background` 的 shell / monitor、core `backgroundScope:"session"` 下的
|
|
6
|
-
* 后台子代理(Agent / Fork)—— 活过起它的那一条腿:腿一收,三张登记簿里都没有它,而引擎还托管着它。读 `/health` 判「这台引擎是否空闲」的外部判官看不见它们,
|
|
7
|
-
* 只好另拼一条谓词(同一个事实两个读法);附着租约 / 排空 / SIGHUP 空闲窗对还在烧模型的后台子代理同样看不见,把它随引擎的受控退中断。
|
|
8
|
-
*
|
|
9
|
-
* ## 两个事实(本文件产分项里的两项;两个和只在 `fleet/drain-entry.ts` 各写一次)
|
|
10
|
-
* `/health.inflight`(总数,{@link inflightTotal})= 引擎此刻托管着多少活 = `http + leader + backgroundAgents + sessionResident`,可观测事实;
|
|
11
|
-
* `drainState.blockingInflight`(阻断集,{@link blockingInflightOf})= 还有没有必须等完的活 = `http + leader + backgroundAgents`,排空 / 孤儿窗 / 附着租约自退 / SIGHUP 空闲窗判停读它。
|
|
12
|
-
* 两个和读**同一只**分项函数(`http/server.ts` 的 `inflightBreakdown`),本文件的读数在一次走查里同时交出两项 —— 判停与 `/health` 不是两份算法。
|
|
13
|
-
* · `backgroundAgents` **进阻断集**:后台子代理是一条在干活的模型腿,干完自己收尾(在审批 / 问答卡上等人时行仍是 `running`、照计;窗满转成耐久停驻后不再计);
|
|
14
|
-
* 不等它 = 受控退把一条还在干活的子代理中断(账本行落终态,模型工作丢)。与驻留 shell 的分界不是「有没有墙钟上限」—— core [ref] 已退役会话级子代理的
|
|
15
|
-
* 30 min 缺省墙钟,两类都没有 —— 而是「会不会自己结束」:模型腿干完即止,`while true` 的 shell 永不。
|
|
16
|
-
* 上界 = 停滞收割窗 `BG_AGENT_STALL_MS`(下面「停滞收割」一节):任务表行一直是 `running`、却不再有工具活动的子代理 —— 挂死的,或已收尾、但 core 在把行转终态之前
|
|
17
|
-
* await 的那一次委派行写 / 工作树收尾挂住了的(core `agents/subagent.js` 子代收尾链:`await rowSettled` 先于 `settleBackgroundAgent`)—— 静默满窗即被收,不再无界地撑着判停窗。
|
|
18
|
-
* · `sessionResident` **只进总数**:驻留 shell 不是一条腿,等它没有意义;一只不退出的 shell(`while true`)若阻断,崩溃孤儿引擎就永生、排空每次等满窗。
|
|
19
|
-
* 窗到 / 排空完成,退出边界的后台收割收掉它们,retain 行按 retain 既有语义活过受控退。
|
|
20
|
-
*
|
|
21
|
-
* ## 读法(本文件是唯一属主;行判一处写:{@link sessionResidentTermOf})
|
|
22
|
-
* 行集 = core `TaskRegistry.liveTasks(access)` 的投影,按行类型与状态分到两项之一或不计:
|
|
23
|
-
*
|
|
24
|
-
* | 行(`sessionScoped` 为真) | 状态 `pending` / `running` | `parked` | 终态 |
|
|
25
|
-
* |---------------------------------------------------|----------------------------|-------------------|------|
|
|
26
|
-
* | `background_agent`(后台子代理) | `backgroundAgents` | 不计(耐久停驻) | 不计 |
|
|
27
|
-
* | `background_bash` / `monitor`,非 retain | `sessionResident` | 不计 | 不计 |
|
|
28
|
-
* | `background_bash` / `monitor`,retain | 不计(交付的活服务,活过受控退) |||
|
|
29
|
-
* | `workflow` | 不计(见下) |||
|
|
30
|
-
*
|
|
31
|
-
* · **`sessionScoped` 为假的行不计**:挂在 run 腿上的后台行随腿登记在 `http` 项里,数它是第二次(腿一收,core 的拆腿收割把它们一起结掉)。
|
|
32
|
-
* · **`parked` 不计**:与停驻的 run 同一条律 —— 停驻是耐久的(引擎退了不丢,下次起来仍可赎回),不占执行座;算它,一张没人答的审批就让引擎永远退不掉。
|
|
33
|
-
* · **`workflow` 行不计**(计法表成文的一行,不是遗漏):任务表对一条 workflow 只投 `running`,一条腿停在审批门上等人时也还是 `running` ——
|
|
34
|
-
* 这只读法分不出「在干活」与「在等人」。进阻断集 ⇒ 一张没人答的审批让崩溃孤儿引擎永生(与驻留 shell 同一病);只进总数 ⇒ 多一类只报不阻断的项、
|
|
35
|
-
* 判据与停驻律对不上。停驻位(core `runParkedOf`)要由任务表投出来才能按停驻律分(请托 core);到货前 workflow 照旧不进在飞,与 7.146.x 同。
|
|
36
|
-
* · **状态是闭集**(`SemaTaskStatus` 穷举):core 加一个词 ⇒ 这里编译红,不会被静默读成「不计」。
|
|
37
|
-
* · **一行只数一次**:各会话的可见集可以相交(core `canAccess` 对后台子代理还认 `rootSessionId` —— 子会话与根会话都在围栏表时,两次读都看得见同一行)⇒ 整趟走查按 `task_id` 去重。
|
|
38
|
-
* · **选座 `liveTasks`,不读 `list()`**:`list()` 是显示投影,硬帽 500 行(core 注:resolution must NEVER ride the display-capped list());
|
|
39
|
-
* 超过 500 行时 `list()` 会静默少数,方向恰是「以为空闲」。`liveTasks` 无显示帽。
|
|
40
|
-
*
|
|
41
|
-
* ## 枚举源
|
|
42
|
-
* core 的 `canAccess` 要求访问元组带 `scope`(缺 scope 一律拒),`list` / `liveTasks` 因此只读「调用方可达行」,没有进程总数的读口。
|
|
43
|
-
* 进程级的数由本仓自己枚举「本进程有哪些会话」:枚举源 = **围栏表**(`boot/execution-env.ts` 的 `SessionScopedRegistries.sessionOwners`):
|
|
44
|
-
* 每次提交经 resolve-spec 写一笔(会话 id → 属主),删会话的 E21 级联清一笔,LRU 有界。scope 轴 = {@link sessionChildrenScope}(会话属主 `?? "default"`,
|
|
45
|
-
* 删除门 / 换绑门 / 结清口 / 会话后台读面同一个取法,不另取)。会话驻留的后台子代理 `owner` = 会话 id([ref] 纪律),同一只访问元组够得着。
|
|
46
|
-
* 〔待 core:一只进程级、不按访问元组收窄的计数读口(`countRunningBackgroundShells` 的子代理孪生)到货后,子代理一项改读它 —— 下面三条边界随之消失。〕
|
|
47
|
-
*
|
|
48
|
-
* ## 读到的边界(成文,不静默)
|
|
49
|
-
* · 围栏表是 LRU(上界 4096 会话):被挤出表的会话,它的会话驻留行在这里不可见 —— 回到 7.146.x 前的读数(不是新的错),不会多数;
|
|
50
|
-
* · 不经 resolve-spec 的内部车道(服务为自己起的 run)不写围栏表,它们起的会话驻留行同样不可见;
|
|
51
|
-
* · 删会话的级联在 `dropSessionScoped` 之后、后台收割之前失败(会话行因此没删)时,围栏表已先清:该会话还在跑的驻留行在下一次提交重新围栏之前不可见
|
|
52
|
-
* (修法是把 `dropSession` 的「清秘密」与「忘身份」拆开,属围栏表的属主,不在本读法里);
|
|
53
|
-
* · 每次读是 O(围栏表会话数 × 注册表行数)(`liveTasks` 逐会话走一遍注册表);表的上界 4096、注册表行数小,量级是毫秒。
|
|
54
|
-
* 这一读在判停路径上(排空 1 s 拍 / 租约拍 / SIGHUP 拍)每拍付一次 —— 后台子代理进阻断集的代价,与 `/health` 同一份。
|
|
55
|
-
*
|
|
56
|
-
* ## 停滞收割:先收尸,再数活(本文件是收割的唯一调用点)
|
|
57
|
-
* 引擎把会话驻留后台子代理的反僵尸义务交给调用方:`TaskRegistry.reapStaleSessionBackgroundAgents(staleMs)` 把**最后一次工具活动**距今超过 `staleMs` 的
|
|
58
|
-
* `running` 行收成 `killed`(归因 `system`,措辞与耐久 stale-running 清扫同一句)并中止它的 run;停驻行、随腿的行、终态行它不碰。
|
|
59
|
-
* {@link countSessionResidentBackground} 每读一次先调它一次、再走任务表 —— 所以计法表里「在跑的后台子代理」= 引擎任务表此刻说 `running` 的行,
|
|
60
|
-
* 而任务表在被数之前已经按停滞窗结清过一遍。本服务不另判「这一行其实不活」(行说 running、本服务说不活 = 一个事实两种读法):不活的行由引擎收成终态,本文件只数。
|
|
61
|
-
* · **拍**:不另起计时器。读口的读者就是拍 —— 排空 1 s 拍、附着租约拍、SIGHUP 空闲窗 1 s 拍、`/health`、崩溃遗言;每一处判停读数之前都先收过一次。
|
|
62
|
-
* 没有任何读者的进程里没有判据要读这一项,僵尸行只停在任务表的显示面上。
|
|
63
|
-
* · **窗**:`BG_AGENT_STALL_MS`,缺省 = 下限 = 派生值(`config.ts` 的 `backgroundAgentStallFloorMs`:等人的四个窗取大 + 引擎单命令上限)。
|
|
64
|
-
* 子代在审批卡 / 问答卡上等人时行是 `running`、没有工具活动 —— 窗不盖住等人的窗,就会把一只等你回来批的子代当僵尸收掉。
|
|
65
|
-
* · **收割失败**(引擎抛)⇒ 读口照数任务表(没收掉的行照算在跑:宁可等,与收割接线之前同读)并经 `stall.report` 报出;读口不抛。
|
|
66
|
-
*
|
|
67
|
-
* ## 读不出 ⇒ 非空闲(响亮,不替成 0)
|
|
68
|
-
* 本函数在判停路径(排空首读在期限计时器装上之前)、`/health` 应答与崩溃遗言里被调,**不许抛**(判停首读一抛 ⇒ 期限计时器装不上 ⇒ 永不硬停;
|
|
69
|
-
* 崩溃遗言里一抛会吞掉遗言本身)。某个会话的读失败(含行判遇到闭集外的值)⇒ 该会话按 **1 只在跑的后台子代理**计 —— 落在阻断项里,判停也看得见
|
|
70
|
-
* (读不出 ⇒ 非空闲:宁可当有活)—— 并经 `onUnreadable` 报出;调用方必须给报口(装配层一会话一行 `session_resident_background_unreadable`),不存在静默的 0。
|
|
71
|
-
*/
|
|
72
1
|
import { type TaskListRow, type TaskRegistry } from "@sema-agent/core";
|
|
73
2
|
import type { InflightBreakdown } from "./fleet/drain-entry.js";
|
|
74
3
|
/** 枚举源的形:会话 id → 会话属主(`null` = 匿名)。`Map` 满足它。 */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { writeLogText } from "./observability/logger.js";
|
|
1
2
|
import { defaultTaskRegistry } from "@sema-agent/core";
|
|
2
|
-
import {
|
|
3
|
+
import { sessionTenantScope } from "./session-children-retire.js";
|
|
3
4
|
function liveStatus(status) {
|
|
4
5
|
switch (status) {
|
|
5
6
|
case "pending":
|
|
@@ -43,7 +44,7 @@ export function countSessionResidentBackground(sessions, opts) {
|
|
|
43
44
|
for (const [sessionId, owner] of sessions) {
|
|
44
45
|
try {
|
|
45
46
|
const fresh = [];
|
|
46
|
-
for (const row of registry.liveTasks({ owner: sessionId, sessionId, scope:
|
|
47
|
+
for (const row of registry.liveTasks({ owner: sessionId, sessionId, scope: sessionTenantScope(owner) })) {
|
|
47
48
|
const term = sessionResidentTermOf(row);
|
|
48
49
|
if (term !== undefined && !counted.has(row.task_id))
|
|
49
50
|
fresh.push([row.task_id, term]);
|
|
@@ -82,7 +83,7 @@ function reportSafely(fallbackLine, report) {
|
|
|
82
83
|
report();
|
|
83
84
|
}
|
|
84
85
|
catch (reportErr) {
|
|
85
|
-
|
|
86
|
+
writeLogText("stderr", ...fallbackLine, reportErr);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
//# sourceMappingURL=session-resident-background.js.map
|
package/dist/session-row.d.ts
CHANGED
|
@@ -56,7 +56,8 @@ export interface ReplaySessionRowWrite {
|
|
|
56
56
|
export type SessionRowWrite = ClientSessionRowWrite | ReplaySessionRowWrite;
|
|
57
57
|
/**
|
|
58
58
|
* 写原语的结局(闭集四员):`written` / `changed` 带提交(回滚)之后另读的那一行(列表行投影,含新 `rowTag`);`mirror`(客户端写在只读镜像上)/
|
|
59
|
-
* `absent`(行期望不中 / 没有行 /
|
|
59
|
+
* `absent`(行期望不中 / 没有行 / 委派分区行:锁下拒,一个字节没写;或应答行复核已不是判过的那一位住客:判官答 `changed`、回滚之后换人 = 零写,答 `write`、已提交之后换人〔SQL 后端才有这一窗〕= 写已落,
|
|
60
|
+
* 随旧行的外键级联删掉,或留在已换主的行上 —— 三分见 `plugins/session-row-sql.ts` 头注「结局 `absent` 的三种去向」)。
|
|
60
61
|
*/
|
|
61
62
|
export type SessionRowWriteOutcome<Row> = {
|
|
62
63
|
readonly kind: "written";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🔴 **会话规则的引擎席**(场景子命名空间):会话规则桶的键 = (会话号, **会话属主**)—— 会话号定分区,会话行的属主是那一格分区的主体
|
|
3
|
+
* (路由 `GET/PUT /v1/sessions/:id/policy` 按会话属主写,`http/routes/sessions.ts`)。引擎读写会话规则时交的是 `spec.principal` = **人**
|
|
4
|
+
* (引擎交界的身份格,`engine-identity.ts`):带场景的会话,人 ≠ 属主,原样查 = 落到另一只桶(运维在 health 会话上 PUT 的 deny 对引擎不存在 = 安全轴放宽)。
|
|
5
|
+
*
|
|
6
|
+
* 律(一句):引擎交来的人恰是这只会话属主背后的人 ⇒ 键换成会话属主;否则原样(与今天逐字节同 —— 没带场景的会话属主与人字节相同,两种读法同一个键)。
|
|
7
|
+
* 属主只经会话店的头读一处(`headOf(id)?.owner`,会话行是属主的唯一事实);读不到头(会话不在 / 店不交头读)⇒ 原样。读写两腿与祖先会话的规则读同经这一只席。
|
|
8
|
+
*/
|
|
9
|
+
import type { SessionPolicyStore } from "@sema-agent/core";
|
|
10
|
+
import type { HeadRead } from "./session-incarnation.js";
|
|
11
|
+
export declare function createEngineSessionRulesSeat(store: SessionPolicyStore, headOf: HeadRead | undefined): SessionPolicyStore;
|
|
12
|
+
//# sourceMappingURL=session-rules-seat.d.ts.map
|