@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
package/dist/leader/leader.js
CHANGED
|
@@ -22,14 +22,25 @@ export function withLeaderLeg(spec, entry) {
|
|
|
22
22
|
const word = entryPermissionMode(spec.permissionMode, entry.permissionMode).effective;
|
|
23
23
|
return withUnattendedLeg(word === undefined ? spec : { ...spec, permissionMode: word });
|
|
24
24
|
}
|
|
25
|
+
export const LEADER_RUN_STOPPED = "leader run stopped at an abort checkpoint (cancel): no further work was started and nothing was pushed after the stop";
|
|
26
|
+
export function stoppedResult(reports, route) {
|
|
27
|
+
const sus = reports.filter((r) => r.status === "suspended").map((r) => ({ workerId: r.workerId, sessionId: r.sessionId }));
|
|
28
|
+
return { ok: false, reports, cancelled: true, stopped: true, error: LEADER_RUN_STOPPED, ...(route ? { route } : {}), ...(sus.length > 0 ? { suspended: sus } : {}) };
|
|
29
|
+
}
|
|
25
30
|
export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
31
|
+
const signal = deps.signal;
|
|
32
|
+
const aborted = () => signal?.aborted === true;
|
|
26
33
|
let subs;
|
|
27
34
|
try {
|
|
28
35
|
subs = await deps.plan(task);
|
|
29
36
|
}
|
|
30
37
|
catch (e) {
|
|
38
|
+
if (aborted())
|
|
39
|
+
return stoppedResult([], undefined);
|
|
31
40
|
return { ok: false, reports: [], cancelled: false, error: `plan failed: ${e instanceof Error ? e.message : String(e)}` };
|
|
32
41
|
}
|
|
42
|
+
if (aborted())
|
|
43
|
+
return stoppedResult([], undefined);
|
|
33
44
|
if (subs.length === 0)
|
|
34
45
|
return { ok: false, reports: [], cancelled: false, error: "planner produced no sub-tasks" };
|
|
35
46
|
const route = subs.length === 1 ? "single" : "fanout";
|
|
@@ -37,6 +48,8 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
37
48
|
let finalReports = [];
|
|
38
49
|
try {
|
|
39
50
|
for (const sub of subs) {
|
|
51
|
+
if (aborted())
|
|
52
|
+
return stoppedResult([], route);
|
|
40
53
|
try {
|
|
41
54
|
workers.push(await deps.provisionWorker(sub));
|
|
42
55
|
}
|
|
@@ -52,7 +65,7 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
52
65
|
const toSubtask = (w) => ({
|
|
53
66
|
workerId: w.workerId, sessionId: w.sessionId, branch: w.branch, baseSha: w.baseSha, spec: w.spec,
|
|
54
67
|
});
|
|
55
|
-
const foBase = { runner, timeoutMs: deps.timeoutMs, maxConcurrency: deps.maxConcurrency, cancelOnSuspend: true, ...(deps.logger ? { logger: deps.logger } : {}) };
|
|
68
|
+
const foBase = { runner, timeoutMs: deps.timeoutMs, maxConcurrency: deps.maxConcurrency, cancelOnSuspend: true, ...(signal ? { signal } : {}), ...(deps.logger ? { logger: deps.logger } : {}) };
|
|
56
69
|
const runWave = async (sts) => {
|
|
57
70
|
if (!deps.verifyWorker) {
|
|
58
71
|
return fanOut(sts, {
|
|
@@ -149,12 +162,16 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
149
162
|
return runWave([toSubtask(solo)]);
|
|
150
163
|
}
|
|
151
164
|
};
|
|
165
|
+
if (aborted())
|
|
166
|
+
return stoppedResult([], route);
|
|
152
167
|
const fo1 = route === "single" && workers.length === 1
|
|
153
168
|
? await runSolo(workers[0], subs[0])
|
|
154
169
|
: await runWave(workers.map(toSubtask));
|
|
155
170
|
let reports = fo1.reports;
|
|
156
171
|
let cancelled = fo1.cancelled;
|
|
157
172
|
finalReports = reports;
|
|
173
|
+
if (aborted())
|
|
174
|
+
return stoppedResult(finalReports, route);
|
|
158
175
|
const workerRepoDir = deps.workerRepoDir ?? deps.repoDir;
|
|
159
176
|
const workerDiff = (w) => w.fetchDiff
|
|
160
177
|
? w.fetchDiff()
|
|
@@ -193,6 +210,8 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
193
210
|
const w = byId.get(r.workerId);
|
|
194
211
|
const sub = subById.get(r.workerId);
|
|
195
212
|
for (let attempt = 0; attempt <= maxR; attempt++) {
|
|
213
|
+
if (aborted())
|
|
214
|
+
return;
|
|
196
215
|
const d = await workerDiff(w);
|
|
197
216
|
if (!d.ok)
|
|
198
217
|
return;
|
|
@@ -201,6 +220,8 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
201
220
|
r.repairs = attempt;
|
|
202
221
|
if (verdict.ok)
|
|
203
222
|
return;
|
|
223
|
+
if (aborted())
|
|
224
|
+
return;
|
|
204
225
|
const safeVerdictReason = redactErrorMessage(verdict.reason ?? "behaviorally incorrect") ?? "";
|
|
205
226
|
if (attempt === maxR) {
|
|
206
227
|
r.status = "failed";
|
|
@@ -209,7 +230,7 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
209
230
|
}
|
|
210
231
|
deps.logger?.info?.("module_repair", { workerId: r.workerId, attempt: attempt + 1, reason: redactHead(verdict.reason ?? "", 500) });
|
|
211
232
|
try {
|
|
212
|
-
const rr = await w.runner.runTaskStream(withLeaderLeg({ ...sub.spec, objective: deps.moduleGate.repairObjective(sub, safeVerdictReason), sessionId: `${w.sessionId}-r${attempt + 1}
|
|
233
|
+
const rr = await w.runner.runTaskStream(withLeaderLeg({ ...sub.spec, objective: deps.moduleGate.repairObjective(sub, safeVerdictReason), sessionId: `${w.sessionId}-r${attempt + 1}`, ...(signal ? { signal } : {}) }, deps.entry)).result();
|
|
213
234
|
if (r.stats && rr?.stats)
|
|
214
235
|
r.stats = { ...r.stats, tokens: (r.stats.tokens ?? 0) + (rr.stats.tokens ?? 0), costMicroUsd: (r.stats.costMicroUsd ?? 0) + (rr.stats.costMicroUsd ?? 0) };
|
|
215
236
|
}
|
|
@@ -222,6 +243,8 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
222
243
|
}));
|
|
223
244
|
};
|
|
224
245
|
await runModuleGate();
|
|
246
|
+
if (aborted())
|
|
247
|
+
return stoppedResult(finalReports, route);
|
|
225
248
|
const mergeDeps = {
|
|
226
249
|
pullWorkerDiff: async (r) => workerDiff(byId.get(r.workerId)),
|
|
227
250
|
provisionIntegrationSandbox: deps.provisionIntegrationSandbox,
|
|
@@ -232,6 +255,7 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
232
255
|
...(deps.mergeGates?.measureGates ? { measureGates: true } : {}),
|
|
233
256
|
...(deps.mergeGates?.strongOracleSeeded ? { strongOracleSeeded: true } : {}),
|
|
234
257
|
...(deps.mergeGates?.measureDrivesRepair ? { measureDrivesRepair: deps.mergeGates.measureDrivesRepair } : {}),
|
|
258
|
+
...(signal ? { signal } : {}),
|
|
235
259
|
...(deps.logger ? { logger: deps.logger } : {}),
|
|
236
260
|
};
|
|
237
261
|
let redispatched;
|
|
@@ -260,8 +284,10 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
260
284
|
});
|
|
261
285
|
const collapseToSingle = async (trigger, reason) => {
|
|
262
286
|
const safeReason = redactHead(reason, 300);
|
|
263
|
-
deps.logger?.warn?.("replan_collapse_to_single", { trigger, reason: safeReason });
|
|
264
287
|
const replan = { trigger, collapsed: safeReason, ...(redispatched ? { redispatched } : {}) };
|
|
288
|
+
if (aborted())
|
|
289
|
+
return { ...stoppedResult(finalReports, route), replan };
|
|
290
|
+
deps.logger?.warn?.("replan_collapse_to_single", { trigger, reason: safeReason });
|
|
265
291
|
const soloSub = { workerId: "collapse-solo", branch: "worker/collapse-solo", files: ["."], spec: { objective: task } };
|
|
266
292
|
let solo;
|
|
267
293
|
try {
|
|
@@ -274,12 +300,18 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
274
300
|
workers.push(solo);
|
|
275
301
|
byId.set(solo.workerId, solo);
|
|
276
302
|
bySession.set(solo.sessionId, solo);
|
|
303
|
+
if (aborted())
|
|
304
|
+
return { ...stoppedResult(finalReports, route), replan };
|
|
277
305
|
const fo = await runSolo(solo, soloSub);
|
|
278
306
|
finalReports = [...reports, ...fo.reports];
|
|
307
|
+
if (aborted())
|
|
308
|
+
return { ...stoppedResult(finalReports, route), replan };
|
|
279
309
|
const sus = await surfaceSuspended(finalReports, fo.reports);
|
|
280
310
|
if (sus)
|
|
281
311
|
return { ...sus, replan: { ...replan, trigger: "suspended" }, ...(repairTerminal ? { repairTerminal } : {}), ...(candidatePatch ? { candidatePatch } : {}) };
|
|
282
312
|
const m = await mergeBranches(fo.reports, durableBaseSha, mergeDeps);
|
|
313
|
+
if (!m.ok && m.stopped)
|
|
314
|
+
return { ...stoppedResult(finalReports, route), merge: m, replan };
|
|
283
315
|
if (!m.ok && m.conflict) {
|
|
284
316
|
const cc = m.conflict;
|
|
285
317
|
deps.logger?.warn?.("merge_conflict_to_user", { conflicted: cc.conflicted, applied: cc.applied, files: cc.files.slice(0, 20) });
|
|
@@ -325,6 +357,8 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
325
357
|
const fresh = [];
|
|
326
358
|
try {
|
|
327
359
|
for (const id of failedIds) {
|
|
360
|
+
if (aborted())
|
|
361
|
+
return stoppedResult(finalReports, route);
|
|
328
362
|
const w = await deps.provisionWorker(subById.get(id));
|
|
329
363
|
fresh.push(w);
|
|
330
364
|
workers.push(w);
|
|
@@ -342,6 +376,8 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
342
376
|
const retryById = new Map(fo2.reports.map((r) => [r.workerId, r]));
|
|
343
377
|
reports = reports.map((r) => retryById.get(r.workerId) ?? r);
|
|
344
378
|
finalReports = reports;
|
|
379
|
+
if (aborted())
|
|
380
|
+
return stoppedResult(finalReports, route);
|
|
345
381
|
const sus2 = await surfaceSuspended(reports, fo2.reports);
|
|
346
382
|
if (sus2)
|
|
347
383
|
return sus2;
|
|
@@ -351,7 +387,11 @@ export async function runLeaderTask(task, durableBaseSha, deps) {
|
|
|
351
387
|
}
|
|
352
388
|
}
|
|
353
389
|
}
|
|
390
|
+
if (aborted())
|
|
391
|
+
return stoppedResult(finalReports, route);
|
|
354
392
|
const merge = await mergeBranches(reports, durableBaseSha, mergeDeps);
|
|
393
|
+
if (!merge.ok && merge.stopped)
|
|
394
|
+
return { ...stoppedResult(finalReports, route), merge };
|
|
355
395
|
if (!merge.ok && merge.conflict) {
|
|
356
396
|
const c = merge.conflict;
|
|
357
397
|
deps.logger?.warn?.("merge_conflict_to_user", { conflicted: c.conflicted, applied: c.applied, files: c.files.slice(0, 20) });
|
package/dist/leader/merge.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export interface IntegrationRepair {
|
|
|
52
52
|
errorText: string;
|
|
53
53
|
testCmd: string;
|
|
54
54
|
repoDir: string;
|
|
55
|
+
signal?: AbortSignal;
|
|
55
56
|
}): Promise<{
|
|
56
57
|
costUsd?: number;
|
|
57
58
|
note?: string;
|
|
@@ -154,11 +155,17 @@ export interface MergeDeps {
|
|
|
154
155
|
/** Parse the integrated patch into a changed-file list (the wire binds `git apply --numstat` / name-only). */
|
|
155
156
|
changedFiles: (integratedPatch: string) => Promise<string[]>;
|
|
156
157
|
};
|
|
158
|
+
/** 这条 leader run 的中止信号(与 core `TaskSpec.signal` 同一约定:缺席 = 不可外部取消)。核点同一只判(`stopAt`):建集成沙箱前、
|
|
159
|
+
* 每一轮集成修复前、测试判决处、**push 咽喉**(下面唯一一处 `deps.push` 调用的正上方)。全部 push 路径都过那一处调用 ⇒ 中止被看见之后零 push;
|
|
160
|
+
* 已经发出的 push 不撤(同步 git,发出之后本进程看不见中止),它的结局照实回。 */
|
|
161
|
+
signal?: AbortSignal;
|
|
157
162
|
logger?: {
|
|
158
163
|
warn?: (m: string, x?: Record<string, unknown>) => void;
|
|
159
164
|
info?: (m: string, x?: Record<string, unknown>) => void;
|
|
160
165
|
};
|
|
161
166
|
}
|
|
167
|
+
/** 中止被看见时合并停下的那一句(人读;机读位是 `stopped`)。 */
|
|
168
|
+
export declare const MERGE_STOPPED_REASON = "cancelled before push \u2014 the leader run was stopped, nothing was pushed";
|
|
162
169
|
/** Integration-repair outcome (when `MergeDeps.provisionIntegrationSandbox` supplied a `repair`): how many
|
|
163
170
|
* rounds ran, whether the post-repair `testCmd` finally passed, and the repair spend. `outsidePlannedFiles`
|
|
164
171
|
* is honest accounting — repaired files are NOT attributed to the original disjoint workers. */
|
|
@@ -193,7 +200,8 @@ export type MergeResult = {
|
|
|
193
200
|
measure?: {
|
|
194
201
|
pass: boolean;
|
|
195
202
|
reason?: string;
|
|
196
|
-
};
|
|
203
|
+
}; /** 只在中止信号被看见、合并在 push 之前停下时在场(恒 `true`):这一趟零 push。 */
|
|
204
|
+
stopped?: true;
|
|
197
205
|
};
|
|
198
206
|
/** Integrate completed workers' branches. Never throws — failures are typed MergeResult. */
|
|
199
207
|
export declare function mergeBranches(reports: WorkerReport[], baseSha: string, deps: MergeDeps): Promise<MergeResult>;
|
package/dist/leader/merge.js
CHANGED
|
@@ -4,6 +4,7 @@ import { applyAndGrade, changedFilesOutOfAllowlist } from "./grader-env-factory.
|
|
|
4
4
|
import { shellQuote as Q } from "../plugins/remote-shell.js";
|
|
5
5
|
const CONFLICT_FILES_MAX = 200;
|
|
6
6
|
const CONFLICT_REJ_HEAD_MAX = 2048;
|
|
7
|
+
export const MERGE_STOPPED_REASON = "cancelled before push — the leader run was stopped, nothing was pushed";
|
|
7
8
|
export async function mergeBranches(reports, baseSha, deps) {
|
|
8
9
|
const repo = deps.repoDir ?? "/repo";
|
|
9
10
|
const mergeable = reports.filter((r) => r.status === "completed");
|
|
@@ -14,6 +15,9 @@ export async function mergeBranches(reports, baseSha, deps) {
|
|
|
14
15
|
let phase = "diff-out";
|
|
15
16
|
let repairMeta;
|
|
16
17
|
let measure;
|
|
18
|
+
const stopAt = (at) => deps.signal?.aborted
|
|
19
|
+
? { ok: false, phase: at, reason: MERGE_STOPPED_REASON, stopped: true, ...(measure ? { measure } : {}), ...(repairMeta ? { repair: repairMeta } : {}) }
|
|
20
|
+
: undefined;
|
|
17
21
|
try {
|
|
18
22
|
const patches = [];
|
|
19
23
|
for (const r of mergeable) {
|
|
@@ -24,6 +28,9 @@ export async function mergeBranches(reports, baseSha, deps) {
|
|
|
24
28
|
patches.push({ workerId: r.workerId, patch: d.patch });
|
|
25
29
|
}
|
|
26
30
|
phase = "provision";
|
|
31
|
+
const stoppedBeforeSandbox = stopAt("provision");
|
|
32
|
+
if (stoppedBeforeSandbox)
|
|
33
|
+
return stoppedBeforeSandbox;
|
|
27
34
|
const integ = await deps.provisionIntegrationSandbox();
|
|
28
35
|
destroy = integ.destroy;
|
|
29
36
|
const { env } = integ;
|
|
@@ -59,6 +66,8 @@ export async function mergeBranches(reports, baseSha, deps) {
|
|
|
59
66
|
let cost = 0;
|
|
60
67
|
let round = 0;
|
|
61
68
|
for (; round < integ.repair.maxRounds && test.exitCode !== 0; round++) {
|
|
69
|
+
if (deps.signal?.aborted)
|
|
70
|
+
break;
|
|
62
71
|
const errorText = redactTail(test.stdout + "\n" + test.stderr, 4000);
|
|
63
72
|
if (errorText.startsWith(OVERSIZED_DIAG_PLACEHOLDER)) {
|
|
64
73
|
deps.logger?.warn?.("integration_repair_skipped_oversized_output", { round: round + 1, outputChars: test.stdout.length + test.stderr.length });
|
|
@@ -66,7 +75,7 @@ export async function mergeBranches(reports, baseSha, deps) {
|
|
|
66
75
|
}
|
|
67
76
|
deps.logger?.warn?.("integration_repair_round", { round: round + 1, maxRounds: integ.repair.maxRounds });
|
|
68
77
|
try {
|
|
69
|
-
const r = await integ.repair.run({ round: round + 1, errorText, testCmd: deps.testCmd, repoDir: repo });
|
|
78
|
+
const r = await integ.repair.run({ round: round + 1, errorText, testCmd: deps.testCmd, repoDir: repo, signal: deps.signal });
|
|
70
79
|
cost += r.costUsd ?? 0;
|
|
71
80
|
}
|
|
72
81
|
catch (e) {
|
|
@@ -80,6 +89,9 @@ export async function mergeBranches(reports, baseSha, deps) {
|
|
|
80
89
|
repairMeta = { rounds: round, fixed: test.exitCode === 0, costUsd: cost };
|
|
81
90
|
deps.logger?.info?.("integration_repair_done", { ...repairMeta });
|
|
82
91
|
}
|
|
92
|
+
const stoppedAtTest = stopAt("test");
|
|
93
|
+
if (stoppedAtTest)
|
|
94
|
+
return stoppedAtTest;
|
|
83
95
|
if (test.exitCode !== 0) {
|
|
84
96
|
return { ok: false, phase: "test", reason: `integration test failed (exit ${test.exitCode})`, details: redactTail(test.stdout + "\n" + test.stderr, 2000), ...(repairMeta ? { repair: repairMeta } : {}) };
|
|
85
97
|
}
|
|
@@ -116,6 +128,9 @@ export async function mergeBranches(reports, baseSha, deps) {
|
|
|
116
128
|
...(repairMeta ? { repair: repairMeta } : {}),
|
|
117
129
|
};
|
|
118
130
|
}
|
|
131
|
+
const stoppedBeforePush = stopAt("push");
|
|
132
|
+
if (stoppedBeforePush)
|
|
133
|
+
return stoppedBeforePush;
|
|
119
134
|
const push = await deps.push(integrated.stdout, baseSha);
|
|
120
135
|
if (!push.ok) {
|
|
121
136
|
if (push.raced)
|
|
@@ -87,7 +87,7 @@ export function attachRepairLoopDeps(deps, resolve) {
|
|
|
87
87
|
deps.repairLoop = {
|
|
88
88
|
run: async (solo, sub) => {
|
|
89
89
|
const cfg = await resolve(solo, sub);
|
|
90
|
-
const implSpec = withLeaderLeg({ ...sub.spec, sessionId: solo.sessionId }, deps.entry);
|
|
90
|
+
const implSpec = withLeaderLeg({ ...sub.spec, sessionId: solo.sessionId, ...(deps.signal ? { signal: deps.signal } : {}) }, deps.entry);
|
|
91
91
|
return runRepairLoopForLeader(solo, implSpec, cfg);
|
|
92
92
|
},
|
|
93
93
|
};
|
package/dist/leader/wire.d.ts
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
|
-
import { type Brain, type Model, type ModelRoles, type ModelPricing, type TaskSpec, type ExecutionEnvFactory, type RemoteExecutionEnv, type ToolResultStore, type SessionStore, type ExecutionEnv, type RunnerDeps } from "@sema-agent/core";
|
|
1
|
+
import { type Brain, type Model, type ModelRoles, type ModelPricing, type TaskSpec, type ExecutionEnvFactory, type RemoteExecutionEnv, type ToolResultStore, type SessionStore, type ExecutionEnv, type RunnerDeps, type CheckpointToken } from "@sema-agent/core";
|
|
2
2
|
import type { Autonomy } from "../runtime-governance.js";
|
|
3
3
|
import { type CheckpointCtxSealer } from "../http/checkpoint-ctx.js";
|
|
4
4
|
import type { CheckpointStoreFull } from "../plugins/store-backend.js";
|
|
5
5
|
import { type LeaderDeps, type LeaderResult } from "./leader.js";
|
|
6
6
|
import { type DeploymentPostureSeats } from "../boot/runner-deps.js";
|
|
7
7
|
import type { LeaderRequestBody } from "./endpoint.js";
|
|
8
|
+
/**
|
|
9
|
+
* leader worker 停驻行的两只 scope —— **唯一属主**(审批停驻 / 资源分片停驻各一只;保留标识见 `principal-shape.ts` 的 `RESERVED_PRINCIPALS` /
|
|
10
|
+
* `RESERVED_PRINCIPAL_PREFIXES`)。worker 的 durable spec 与取消时的残留过期({@link createLeaderParkExpirer})读这同一对。
|
|
11
|
+
*/
|
|
12
|
+
export declare const LEADER_APPROVAL_SCOPE = "_leader";
|
|
13
|
+
export declare function leaderResourceScope(workerId: string): string;
|
|
14
|
+
/** 过期残留停驻要的那两口(SQL 两方言与 local 店都有;结构型,单测用假件)。 */
|
|
15
|
+
export interface LeaderParkStore {
|
|
16
|
+
findPendingTokenBySession(sessionId: string, scope?: string): Promise<CheckpointToken | null | undefined>;
|
|
17
|
+
expire(token: CheckpointToken, scope: string): Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
/** 一次过期的回执:`expired` = CAS 赢的行数;`lost` = 找到了却没过期掉的行数(并发的 `/decide` 或 reaper 先结算了它 —— 被决的那一张会作为它自己的续跑接着走)。 */
|
|
20
|
+
export interface LeaderParkExpiry {
|
|
21
|
+
readonly expired: number;
|
|
22
|
+
readonly lost: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 取消落定时把这条 leader run 的子 worker 残留停驻按 CAS 过期(与 reaper 同一口 `expire`:同一张停驻**永不**既被过期又被续跑)。
|
|
26
|
+
* 对每个 `{ workerId, sessionId }`,在两只 scope 上逐张排空(读口一次只交一张)。回执见 {@link LeaderParkExpiry}。
|
|
27
|
+
* 已经被决过的停驻不在待决集里 ⇒ 不碰(它的续跑是一条独立的 run,停它走 `POST /v1/runs/:id/cancel`)。
|
|
28
|
+
*/
|
|
29
|
+
export declare function createLeaderParkExpirer(store: LeaderParkStore): (workers: ReadonlyArray<{
|
|
30
|
+
readonly workerId: string;
|
|
31
|
+
readonly sessionId: string;
|
|
32
|
+
}>) => Promise<LeaderParkExpiry>;
|
|
8
33
|
/** leader worker 的 durable 审批座(`LeaderWireConfig.durable` 函数席每次产出的一份)。 */
|
|
9
34
|
export interface LeaderDurableSeat {
|
|
10
35
|
readonly checkpointStore: CheckpointStoreFull;
|
|
@@ -87,7 +112,7 @@ export interface LeaderWireConfig {
|
|
|
87
112
|
* 全在那里(`createBrain` 自己不记账)。而 `POST /v1/leader` 的准入处**读**的正是 costQuota / fleetLease
|
|
88
113
|
* 这两个桶。缺席 ⇒ 门查的桶与花钱的手不是同一只:`MAX_PRINCIPAL_COST_USD` 与 fleet 租约对这条腿结构性
|
|
89
114
|
* 失效,而一条 leader run 扇出 ≤6 个带手 worker + planner + repair/conflict 环,全是实钱。
|
|
90
|
-
* 归因的另一半在 `leader/endpoint.ts` 的 `drive()`(ALS `
|
|
115
|
+
* 归因的另一半在 `leader/endpoint.ts` 的 `drive()`(ALS `withSubject`)—— 记账臂按 `currentPerson()`
|
|
91
116
|
* 分租户,只补席不包裹 = 归因恒 undefined = 假绿。缺席 ⇒ 展开空对象(与接线前逐字相同)。
|
|
92
117
|
*/
|
|
93
118
|
tracer?: RunnerDeps["tracer"];
|
|
@@ -98,6 +123,11 @@ export interface LeaderWireConfig {
|
|
|
98
123
|
* 管不到 leader 派出的腿,拒绝计量 / 工具追踪也漏这条腿。缺席 ⇒ 展开空对象。
|
|
99
124
|
*/
|
|
100
125
|
mods?: RunnerDeps["mods"];
|
|
126
|
+
/**
|
|
127
|
+
* **手带**(`RunnerDeps.hands`),原样递给本车道的每一只 Runner。唯一铸点 = `boot/runner-deps.ts` 的 `buildHandsBand`(共享基座调的同一只):
|
|
128
|
+
* 前台命令超时转后台读部署旋钮 `AUTO_BACKGROUND_ON_TIMEOUT`,本车道不署名。缺失时本车道的 Runner 没有手带(超时即杀、不署名)。缺席 ⇒ 展开空对象。
|
|
129
|
+
*/
|
|
130
|
+
hands?: RunnerDeps["hands"];
|
|
101
131
|
/**
|
|
102
132
|
* [ref]([ref],[ref]-T1)—— **部署级 token 治理窗**两键,**成对**递给本车道的每一只 Runner。
|
|
103
133
|
* 属主 = `config.usageWindows`(声明)+ `boot/stores.ts` 造的账本店(两者同真同假,与
|
|
@@ -293,6 +323,8 @@ export declare const LEADER_PUSH_LOCAL_TIMEOUT_MS = 30000;
|
|
|
293
323
|
* 仅依赖 durableRemote/targetRef/git 身份(不依赖 wire 内其余状态),因此可以脱离完整的
|
|
294
324
|
* plan→provision→fan-out→merge 管线单测(那条管线需要真 brain + E2B/k8s env)。行为与抽出前逐字相同,
|
|
295
325
|
* 唯一新增是六条 execFileSync 各自的 `timeout`。
|
|
326
|
+
* 每条都显式交 `stdio: "pipe"`:不交 `stdio` 时 Node 把子进程的 stderr 原样转写到本进程 stderr(git / credential helper 的诊断直通、绕过日志出口接缝);
|
|
327
|
+
* 交了之后它只进错误对象,失败句经返回值的 `error` 交给调用方、由调用方的日志行过座(`test/log-exit-single-source-gate.test.ts` 钉「同步子进程必须显式交 stdio」)。
|
|
296
328
|
*
|
|
297
329
|
* 7.103.0([ref] 残余):六条 git 子进程的 env 一律 = `gitSubprocessEnv({ isolateConfig: false })` + `LC_ALL=C`(修前:
|
|
298
330
|
* `{ ...process.env, LC_ALL: "C" }`,两条 `git config` 连 env 都不交 ⇒ 整份服务 env 进 git 与它拉起的 helper / hook)。
|
|
@@ -304,6 +336,7 @@ export declare function createCoordinatorPush(durableRemote: string, targetRef:
|
|
|
304
336
|
name: string;
|
|
305
337
|
email: string;
|
|
306
338
|
}): LeaderDeps["push"];
|
|
307
|
-
|
|
339
|
+
/** 返回的函数收本 run 的中止信号(`createLeaderEndpoint` 的驱动腿恒交一根;与 core `TaskSpec.signal?` 同约定可选 —— 不交 = 这次调用停不下)。 */
|
|
340
|
+
export declare function createLeaderRunner(cfg: LeaderWireConfig): (body: LeaderRequestBody, signal?: AbortSignal) => Promise<LeaderResult>;
|
|
308
341
|
export {};
|
|
309
342
|
//# sourceMappingURL=wire.d.ts.map
|
package/dist/leader/wire.js
CHANGED
|
@@ -21,9 +21,46 @@ import { attachRepairLoopDeps } from "./repair-wire.js";
|
|
|
21
21
|
import { routePlanWithFallback, validateSubtasks } from "./planner.js";
|
|
22
22
|
import { createEngineNoticeSeat } from "../boot/runner-deps.js";
|
|
23
23
|
import { buildInternalRunCtx } from "../internal-run-env.js";
|
|
24
|
-
import {
|
|
24
|
+
import { currentSubject } from "../observability/principal-context.js";
|
|
25
|
+
import { partsOf } from "../owner-brands.js";
|
|
26
|
+
import { taskSpecIdentityOf } from "../engine-identity.js";
|
|
25
27
|
import { redactHead } from "../observability/run-terminal.js";
|
|
26
28
|
const REPAIR_LOOP_WIRED = true;
|
|
29
|
+
export const LEADER_APPROVAL_SCOPE = "_leader";
|
|
30
|
+
export function leaderResourceScope(workerId) {
|
|
31
|
+
return `_leader-resource-${workerId}`;
|
|
32
|
+
}
|
|
33
|
+
const PARK_DRAIN_MAX = 64;
|
|
34
|
+
export function createLeaderParkExpirer(store) {
|
|
35
|
+
return async (workers) => {
|
|
36
|
+
let expired = 0;
|
|
37
|
+
let lost = 0;
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
for (const w of workers) {
|
|
40
|
+
for (const scope of [LEADER_APPROVAL_SCOPE, leaderResourceScope(w.workerId)]) {
|
|
41
|
+
const key = `${w.sessionId}\u0000${scope}`;
|
|
42
|
+
if (seen.has(key))
|
|
43
|
+
continue;
|
|
44
|
+
seen.add(key);
|
|
45
|
+
const tried = new Set();
|
|
46
|
+
for (let i = 0;; i++) {
|
|
47
|
+
const token = await store.findPendingTokenBySession(w.sessionId, scope);
|
|
48
|
+
if (token === null || token === undefined)
|
|
49
|
+
break;
|
|
50
|
+
if (tried.has(token) || i >= PARK_DRAIN_MAX) {
|
|
51
|
+
throw new Error(`leader park expiry: the checkpoint store kept answering pending token for session ${w.sessionId} in scope ${scope} after expiring it — refusing to spin (expired=${expired}, lost=${lost})`);
|
|
52
|
+
}
|
|
53
|
+
tried.add(token);
|
|
54
|
+
if (await store.expire(token, scope))
|
|
55
|
+
expired++;
|
|
56
|
+
else
|
|
57
|
+
lost++;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { expired, lost };
|
|
62
|
+
};
|
|
63
|
+
}
|
|
27
64
|
const sh = (env) => async (cmd) => {
|
|
28
65
|
const r = await env.exec(`bash -lc ${JSON.stringify(cmd)}`);
|
|
29
66
|
if (!r.ok)
|
|
@@ -111,20 +148,20 @@ export function createCoordinatorPush(durableRemote, targetRef, ident) {
|
|
|
111
148
|
const dir = mkdtempSync(join(tmpdir(), "leader-coord-"));
|
|
112
149
|
const gitEnv = { ...gitSubprocessEnv({ site: "server.leader.git-push", isolateConfig: false }), LC_ALL: "C" };
|
|
113
150
|
try {
|
|
114
|
-
execFileSync("git", ["clone", "-q", durableRemote, dir], { env: gitEnv, timeout: LEADER_PUSH_NETWORK_TIMEOUT_MS });
|
|
115
|
-
execFileSync("git", ["-C", dir, "config", "user.name", ident.name], { env: gitEnv, timeout: LEADER_PUSH_LOCAL_TIMEOUT_MS });
|
|
116
|
-
execFileSync("git", ["-C", dir, "config", "user.email", ident.email], { env: gitEnv, timeout: LEADER_PUSH_LOCAL_TIMEOUT_MS });
|
|
151
|
+
execFileSync("git", ["clone", "-q", durableRemote, dir], { stdio: "pipe", env: gitEnv, timeout: LEADER_PUSH_NETWORK_TIMEOUT_MS });
|
|
152
|
+
execFileSync("git", ["-C", dir, "config", "user.name", ident.name], { stdio: "pipe", env: gitEnv, timeout: LEADER_PUSH_LOCAL_TIMEOUT_MS });
|
|
153
|
+
execFileSync("git", ["-C", dir, "config", "user.email", ident.email], { stdio: "pipe", env: gitEnv, timeout: LEADER_PUSH_LOCAL_TIMEOUT_MS });
|
|
117
154
|
writeFileSync(join(dir, ".leader.patch"), integratedPatch);
|
|
118
|
-
execFileSync("git", ["-C", dir, "am", "--3way", ".leader.patch"], { env: gitEnv, timeout: LEADER_PUSH_LOCAL_TIMEOUT_MS });
|
|
155
|
+
execFileSync("git", ["-C", dir, "am", "--3way", ".leader.patch"], { stdio: "pipe", env: gitEnv, timeout: LEADER_PUSH_LOCAL_TIMEOUT_MS });
|
|
119
156
|
rmSync(join(dir, ".leader.patch"));
|
|
120
157
|
const ref = targetRef ?? "refs/heads/main";
|
|
121
|
-
const ls = execFileSync("git", ["-C", dir, "ls-remote", "--refs", "origin", ref], { encoding: "utf8", env: gitEnv, timeout: LEADER_PUSH_NETWORK_TIMEOUT_MS });
|
|
158
|
+
const ls = execFileSync("git", ["-C", dir, "ls-remote", "--refs", "origin", ref], { stdio: "pipe", encoding: "utf8", env: gitEnv, timeout: LEADER_PUSH_NETWORK_TIMEOUT_MS });
|
|
122
159
|
const exists = ls.split("\n").some((l) => l.split("\t")[1] === ref);
|
|
123
160
|
if (exists) {
|
|
124
|
-
execFileSync("git", ["-C", dir, "push", `--force-with-lease=${ref}:${baseSha}`, "origin", `HEAD:${ref}`], { env: gitEnv, timeout: LEADER_PUSH_NETWORK_TIMEOUT_MS });
|
|
161
|
+
execFileSync("git", ["-C", dir, "push", `--force-with-lease=${ref}:${baseSha}`, "origin", `HEAD:${ref}`], { stdio: "pipe", env: gitEnv, timeout: LEADER_PUSH_NETWORK_TIMEOUT_MS });
|
|
125
162
|
}
|
|
126
163
|
else {
|
|
127
|
-
execFileSync("git", ["-C", dir, "push", `--force-with-lease=${ref}:`, "origin", `HEAD:${ref}`], { env: gitEnv, timeout: LEADER_PUSH_NETWORK_TIMEOUT_MS });
|
|
164
|
+
execFileSync("git", ["-C", dir, "push", `--force-with-lease=${ref}:`, "origin", `HEAD:${ref}`], { stdio: "pipe", env: gitEnv, timeout: LEADER_PUSH_NETWORK_TIMEOUT_MS });
|
|
128
165
|
}
|
|
129
166
|
return { ok: true, ref };
|
|
130
167
|
}
|
|
@@ -168,20 +205,21 @@ export function createLeaderRunner(cfg) {
|
|
|
168
205
|
const deploymentPostureSeat = () => cfg.deploymentPosture?.() ?? {};
|
|
169
206
|
const tracerSeat = cfg.tracer ? { tracer: cfg.tracer } : {};
|
|
170
207
|
const modsSeat = cfg.mods ? { mods: cfg.mods } : {};
|
|
208
|
+
const handsSeat = cfg.hands ? { hands: cfg.hands } : {};
|
|
171
209
|
const servedTableSeat = { models: cfg.models, roles: cfg.roles, ...(cfg.tiers ? { tiers: cfg.tiers } : {}) };
|
|
172
210
|
const usageWindowSeat = cfg.usageWindows && cfg.usageWindowStore ? { usageWindows: cfg.usageWindows, usageWindowStore: cfg.usageWindowStore } : {};
|
|
173
211
|
const promptSourceSeat = cfg.promptSource ? { promptSource: cfg.promptSource } : {};
|
|
174
212
|
const onErrorSeat = cfg.onError ? { onError: cfg.onError } : {};
|
|
175
213
|
const principalSpec = () => {
|
|
176
|
-
const
|
|
177
|
-
return
|
|
214
|
+
const subject = currentSubject();
|
|
215
|
+
return taskSpecIdentityOf(subject === undefined ? undefined : partsOf(subject));
|
|
178
216
|
};
|
|
179
217
|
const mkRepair = (rawEnv, repoDir, oracleFiles, entry) => {
|
|
180
218
|
if (repairRounds <= 0)
|
|
181
219
|
return undefined;
|
|
182
220
|
return {
|
|
183
221
|
maxRounds: repairRounds,
|
|
184
|
-
run: async ({ round, errorText, testCmd }) => {
|
|
222
|
+
run: async ({ round, errorText, testCmd, signal }) => {
|
|
185
223
|
for (const f of oracleFiles) {
|
|
186
224
|
await rawEnv.remove(f.path).catch(() => { });
|
|
187
225
|
const ex = await rawEnv.exists(f.path);
|
|
@@ -189,7 +227,7 @@ export function createLeaderRunner(cfg) {
|
|
|
189
227
|
throw new Error(`oracle still present after remove (${f.path}) — refusing repair (measurement integrity)`);
|
|
190
228
|
}
|
|
191
229
|
try {
|
|
192
|
-
const runner = new Runner({ brain: cfg.brain, ...servedTableSeat, pricing: cfg.pricing, ...onNoticeSeat, ...governanceSeat, ...deploymentPostureSeat(), ...tracerSeat, ...usageWindowSeat, ...promptSourceSeat, ...onErrorSeat, ...modsSeat, executionEnv: rawEnv, rootPath: repoDir });
|
|
230
|
+
const runner = new Runner({ brain: cfg.brain, ...servedTableSeat, pricing: cfg.pricing, ...onNoticeSeat, ...governanceSeat, ...deploymentPostureSeat(), ...tracerSeat, ...usageWindowSeat, ...promptSourceSeat, ...onErrorSeat, ...modsSeat, ...handsSeat, executionEnv: rawEnv, rootPath: repoDir });
|
|
193
231
|
const objective = [
|
|
194
232
|
`The integrated project at ${repoDir} fails its build/test. Make the MINIMAL change to the working tree so this command exits 0 (cd into the repo and run it yourself to confirm):`,
|
|
195
233
|
` ${testCmd}`,
|
|
@@ -203,6 +241,7 @@ export function createLeaderRunner(cfg) {
|
|
|
203
241
|
objective,
|
|
204
242
|
...principalSpec(),
|
|
205
243
|
sessionId: `leader-repair-${Date.now()}-${round}`,
|
|
244
|
+
signal,
|
|
206
245
|
limits: { maxCostUsd: repairBudgetUsd, maxWalltimeMs: Math.max(300_000, Math.floor(leaderTimeoutMs / 2)) },
|
|
207
246
|
}, entry))
|
|
208
247
|
.result();
|
|
@@ -220,7 +259,7 @@ export function createLeaderRunner(cfg) {
|
|
|
220
259
|
},
|
|
221
260
|
};
|
|
222
261
|
};
|
|
223
|
-
return async (raw) => {
|
|
262
|
+
return async (raw, signal) => {
|
|
224
263
|
const body = raw;
|
|
225
264
|
if (!body.objective || !body.durableRemote || !body.testCmd || !body.seedCmd || !body.baseSha) {
|
|
226
265
|
return { ok: false, reports: [], cancelled: false, error: "request must provide objective, durableRemote, baseSha, testCmd, seedCmd" };
|
|
@@ -256,12 +295,13 @@ export function createLeaderRunner(cfg) {
|
|
|
256
295
|
if (Array.isArray(body.subtasks) && body.subtasks.length > 0) {
|
|
257
296
|
return validateSubtasks(body.subtasks);
|
|
258
297
|
}
|
|
259
|
-
const planRunner = new Runner({ brain: cfg.brain, ...servedTableSeat, pricing: cfg.pricing, ...onNoticeSeat, ...governanceSeat, ...deploymentPostureSeat(), ...tracerSeat, ...usageWindowSeat, ...promptSourceSeat, ...onErrorSeat, ...modsSeat });
|
|
298
|
+
const planRunner = new Runner({ brain: cfg.brain, ...servedTableSeat, pricing: cfg.pricing, ...onNoticeSeat, ...governanceSeat, ...deploymentPostureSeat(), ...tracerSeat, ...usageWindowSeat, ...promptSourceSeat, ...onErrorSeat, ...modsSeat, ...handsSeat });
|
|
260
299
|
const runRoute = async (prompt) => {
|
|
261
300
|
const res = await planRunner.runTaskStream({
|
|
262
301
|
objective: prompt,
|
|
263
302
|
...principalSpec(),
|
|
264
303
|
sessionId: `leader-route-${Date.now()}`,
|
|
304
|
+
signal,
|
|
265
305
|
...(cfg.routerModel ? { model: cfg.routerModel } : { modelRole: "classifier" }),
|
|
266
306
|
}).result();
|
|
267
307
|
return res.result ?? "";
|
|
@@ -285,7 +325,7 @@ export function createLeaderRunner(cfg) {
|
|
|
285
325
|
durableSpec = {
|
|
286
326
|
toolPolicy: combinePolicies(createDurableQuestionPolicy(), createDurableAskPolicy({ requireApproval: d.requireApproval, ...(d.deny ? { deny: d.deny } : {}), ...(d.autoBudget ? { autoBudget: d.autoBudget } : {}), ...(d.neverAuto ? { neverAuto: d.neverAuto } : {}) })),
|
|
287
327
|
checkpointStore: d.checkpointStore,
|
|
288
|
-
durableApproval: { scope:
|
|
328
|
+
durableApproval: { scope: LEADER_APPROVAL_SCOPE, ...(d.ttlMs ? { ttlMs: d.ttlMs } : {}) },
|
|
289
329
|
onQuestion: QUESTION_AWAITS_RESUME,
|
|
290
330
|
};
|
|
291
331
|
await d.checkpointStore.putCtx(sessionId, storedResumeCtx).catch((e) => {
|
|
@@ -300,7 +340,7 @@ export function createLeaderRunner(cfg) {
|
|
|
300
340
|
if (resourceCfg && !repairLoopActive && durable && cfg.toolResultStore && cfg.sessionStore) {
|
|
301
341
|
resourceSpec = {
|
|
302
342
|
checkpointStore: durable.checkpointStore,
|
|
303
|
-
resourceSuspend: { scope:
|
|
343
|
+
resourceSuspend: { scope: leaderResourceScope(sub.workerId), totalBudgetUsd: resourceCfg.totalBudgetUsd },
|
|
304
344
|
limits: { ...workerLimits.limits, maxCostUsd: resourceCfg.sliceMaxCostUsd },
|
|
305
345
|
maxSuspends: resourceCfg.maxSuspends,
|
|
306
346
|
};
|
|
@@ -350,7 +390,7 @@ export function createLeaderRunner(cfg) {
|
|
|
350
390
|
workerId: sub.workerId, sessionId, branch: sub.branch,
|
|
351
391
|
baseSha,
|
|
352
392
|
runner: keepCtxWarm(new Runner({
|
|
353
|
-
brain: cfg.brain, ...servedTableSeat, pricing: cfg.pricing, ...onNoticeSeat, ...governanceSeat, ...deploymentPostureSeat(), ...tracerSeat, ...usageWindowSeat, ...promptSourceSeat, ...onErrorSeat, ...modsSeat,
|
|
393
|
+
brain: cfg.brain, ...servedTableSeat, pricing: cfg.pricing, ...onNoticeSeat, ...governanceSeat, ...deploymentPostureSeat(), ...tracerSeat, ...usageWindowSeat, ...promptSourceSeat, ...onErrorSeat, ...modsSeat, ...handsSeat,
|
|
354
394
|
...(cfg.toolResultStore ? { toolResultStore: cfg.toolResultStore } : {}),
|
|
355
395
|
...(cfg.sessionStore ? { sessionStore: cfg.sessionStore } : {}),
|
|
356
396
|
executionEnvFactory: async (ctx) => {
|
|
@@ -375,7 +415,7 @@ export function createLeaderRunner(cfg) {
|
|
|
375
415
|
const baseSha = await sh(env)(`cd ${repo} && git rev-parse HEAD`);
|
|
376
416
|
return {
|
|
377
417
|
workerId: sub.workerId, sessionId, branch: sub.branch, baseSha,
|
|
378
|
-
runner: keepCtxWarm(new Runner({ brain: cfg.brain, ...servedTableSeat, pricing: cfg.pricing, ...onNoticeSeat, ...governanceSeat, ...deploymentPostureSeat(), ...tracerSeat, ...usageWindowSeat, ...promptSourceSeat, ...onErrorSeat, ...modsSeat, ...(cfg.toolResultStore ? { toolResultStore: cfg.toolResultStore } : {}), ...(cfg.sessionStore ? { sessionStore: cfg.sessionStore } : {}), executionEnv: env })),
|
|
418
|
+
runner: keepCtxWarm(new Runner({ brain: cfg.brain, ...servedTableSeat, pricing: cfg.pricing, ...onNoticeSeat, ...governanceSeat, ...deploymentPostureSeat(), ...tracerSeat, ...usageWindowSeat, ...promptSourceSeat, ...onErrorSeat, ...modsSeat, ...handsSeat, ...(cfg.toolResultStore ? { toolResultStore: cfg.toolResultStore } : {}), ...(cfg.sessionStore ? { sessionStore: cfg.sessionStore } : {}), executionEnv: env })),
|
|
379
419
|
diffEnv: env,
|
|
380
420
|
destroy: () => env.destroy().then(() => { }),
|
|
381
421
|
spec: withLeaderLeg({ ...workerLimits, ...sub.spec, ...durableSpec, ...resourceSpec, ...principalSpec() }, resumeBody),
|
|
@@ -419,6 +459,7 @@ export function createLeaderRunner(cfg) {
|
|
|
419
459
|
const push = createCoordinatorPush(body.durableRemote, body.targetRef, ident);
|
|
420
460
|
const deps = {
|
|
421
461
|
entry,
|
|
462
|
+
signal,
|
|
422
463
|
plan,
|
|
423
464
|
provisionWorker,
|
|
424
465
|
provisionIntegrationSandbox,
|
package/dist/leg-facts.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 一条腿的**部署事实**(执行车道 · run 技能名册 · 受理见证)—— server 自有的载体,**不搭引擎 spec 的车**。
|
|
2
|
+
* 一条腿的**部署事实**(执行车道 · run 技能名册 · 受理见证 · 登记的工作目录)—— server 自有的载体,**不搭引擎 spec 的车**。
|
|
3
3
|
*
|
|
4
|
-
* 规则:`TaskSpec` 是引擎的类型面,上面只放引擎读的成员。本仓装配器(`boot/resolve-spec.ts` 的 `createResolveSpec`)
|
|
4
|
+
* 规则:`TaskSpec` 是引擎的类型面,上面只放引擎读的成员。本仓装配器(`boot/resolve-spec.ts` 的 `createResolveSpec`)同时还判出四件
|
|
5
5
|
* 只有 server 自己读的事实 —— 它们以装配器**自己的输出对象**为键登记在这一张表里(单一铸点 {@link mintLegFacts}),由两只漏斗
|
|
6
6
|
* (受理 `http/admission.ts` 的 `prepareSpec` · 续跑 `http/resume-legs.ts` 的 `resolveResumeSpec`)在拿到装配输出的**同一只对象**时
|
|
7
7
|
* 读一次(唯一读口 {@link legFactsOf},读在 `stampSpecRoot` 复制之前),此后作普通值随 `PreparedTaskSubmission.legFacts` /
|
|
@@ -26,6 +26,11 @@ export interface LegFacts {
|
|
|
26
26
|
readonly skills: readonly RunSkillEntry[];
|
|
27
27
|
/** 受理时读根会话行的那一读(会话 id + 住客)。读者 = 腿的会话行记录座(`session-workspace.ts`)。 */
|
|
28
28
|
readonly sessionWitness: DelegationRootWitness;
|
|
29
|
+
/**
|
|
30
|
+
* 这次提交的根会话登记的工作目录(提交体 `cwd` 经唯一写口 `setSessionCwd` 登记的那一枚;装配器在登记之后读一次)。缺席 = 没登记。
|
|
31
|
+
* 读者 = 三只组合入口(同步 / 后台 / 续跑腿的梯子与验证门):经 `compositionLegRoot`(`task-cwd.ts`)交给它们驱动的每一条腿当交活方的工作目录。
|
|
32
|
+
*/
|
|
33
|
+
readonly registeredCwd?: string;
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
31
36
|
* 铸事实(**单一属主**:只允许 `createResolveSpec` 的出口调用)。同一只对象被第二次铸 ⇒ 当场抛 —— 两个写者是漂移的成因,
|
package/dist/leg-facts.js
CHANGED
|
@@ -6,6 +6,7 @@ export function mintLegFacts(resolved, facts) {
|
|
|
6
6
|
hands: facts.hands,
|
|
7
7
|
skills: Object.freeze(facts.skills.map((e) => Object.freeze({ ...e }))),
|
|
8
8
|
sessionWitness: Object.freeze({ ...facts.sessionWitness }),
|
|
9
|
+
...(facts.registeredCwd !== undefined ? { registeredCwd: facts.registeredCwd } : {}),
|
|
9
10
|
}));
|
|
10
11
|
return resolved;
|
|
11
12
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **local 店对引擎的声明**(会话店顶层 · 检查点店「两半」读同一份;委派分区的声明是子代转录档位的判据,不随两半降)—— 「这台部署向谁承诺店活过替换」的唯一读者,与运维那一个词的闭集。
|
|
3
|
+
*
|
|
4
|
+
* ## 规则(一句)
|
|
5
|
+
* local 文件店的设计声明是「活过进程重启」(`SESSION_DURABILITY`);起服的店持久性准入(`store-admission.ts`,第 2 段、第一笔写之前)拿这句声明与数据根介质对表
|
|
6
|
+
* (声明 `durable` ∧ 介质 `ephemeral` ⇒ 拒启 `config.store_not_durable`;第 9 段布线审计对引擎读到的声明同判)。声明降为引擎的 `process-local` 只有两个来源,都由 {@link localStoreDeclarationOf} 一处答:
|
|
7
|
+
* · 运维写了 `LOCAL_STORE_DURABILITY=ephemeral`(闭集只有这一个词;缺席 = 设计声明);
|
|
8
|
+
* · 店落在**调用方自己的盘**上(部署形表行 `callerOwnsWorkerDisk`:host 车道 ∧ 单主)且数据根介质判 `ephemeral` —— 调用方的工作区、工具与会话史同在那块盘上,
|
|
9
|
+
* 部署不替他承诺他自己那块易失盘活过替换(参照实现在无卷容器里同形)。
|
|
10
|
+
* 两半一起降:只降会话店,引擎的 durable-park 自检读出缺口(`durableParkGapOf`:检查点活过、会话不活);只降检查点店同理。
|
|
11
|
+
*
|
|
12
|
+
* 叶模块:值导入只有部署形表(叶)与店型常量的属主;`store-posture.ts` / `store-admission.ts` / `config.ts` / local 后端各读这里,不各写一份。
|
|
13
|
+
*/
|
|
14
|
+
import type { StoreDurability as EngineStoreDurability } from "@sema-agent/core";
|
|
15
|
+
import { type DeploymentShapeInput } from "./deployment-shape.js";
|
|
16
|
+
import type { StoreDurability } from "./store-posture.js";
|
|
17
|
+
/** `LOCAL_STORE_DURABILITY` 的词(闭集,只有「易失」一个词;缺席 = 店型的设计声明)。不给第二个放宽词 —— 声明只有「我就是易失」这一句。 */
|
|
18
|
+
export declare const LOCAL_STORE_DECLARATION_WORDS: readonly ["ephemeral"];
|
|
19
|
+
export type LocalStoreDeclarationWord = (typeof LOCAL_STORE_DECLARATION_WORDS)[number];
|
|
20
|
+
/**
|
|
21
|
+
* local 店声明的依据词(闭集;引擎声明词由 {@link engineDurabilityOfDeclarationRule} 的穷举 switch 派生 —— 加词 ⇒ 编译红):
|
|
22
|
+
* · `declared_ephemeral` —— 运维写了 `LOCAL_STORE_DURABILITY=ephemeral` ⇒ `process-local`(不论车道与介质:这是部署者对自己的店说的话);
|
|
23
|
+
* · `callers_own_volatile_disk` —— 部署形表行 `callerOwnsWorkerDisk` 成立(host 车道 ∧ 单主:店所在的盘就是调用方自己的盘 —— 他的工作区、工具与会话史同在一块盘上,
|
|
24
|
+
* CC 在容器里同形)且数据根介质判 `ephemeral` ⇒ `process-local`:部署不替调用方承诺他自己那块易失盘活过替换;
|
|
25
|
+
* · `store_design` —— 其余:local 文件店的设计声明(活过进程重启,`SESSION_DURABILITY`)。店落在调用方看不见的 worker 盘上而介质易失 ⇒ 审计拒启;
|
|
26
|
+
* 调用方自己的盘判 `durable` / `unknown` ⇒ 声明照旧(开发机、挂了卷的容器、非 Linux)。
|
|
27
|
+
*/
|
|
28
|
+
export declare const LOCAL_STORE_DECLARATION_RULES: readonly ["declared_ephemeral", "callers_own_volatile_disk", "store_design"];
|
|
29
|
+
export type LocalStoreDeclarationRule = (typeof LOCAL_STORE_DECLARATION_RULES)[number];
|
|
30
|
+
/** 依据词 → 引擎声明词(穷举 switch)。 */
|
|
31
|
+
export declare function engineDurabilityOfDeclarationRule(rule: LocalStoreDeclarationRule): EngineStoreDurability;
|
|
32
|
+
/** local 店的声明(依据词 + 派生的引擎声明词;两半店读同一份)。 */
|
|
33
|
+
export interface LocalStoreDeclaration {
|
|
34
|
+
readonly rule: LocalStoreDeclarationRule;
|
|
35
|
+
readonly durability: EngineStoreDurability;
|
|
36
|
+
}
|
|
37
|
+
/** 声明读的部署事实:部署形表行 `callerOwnsWorkerDisk` 的读入形(车道 × 租户)+ 运维的词 `LOCAL_STORE_DURABILITY`(`ServiceConfig` 结构上满足)。 */
|
|
38
|
+
export type LocalStoreDeclarationDeployment = DeploymentShapeInput<"lane" | "principal"> & {
|
|
39
|
+
readonly localStoreDurability: LocalStoreDeclarationWord | undefined;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 🔴 「local 店对引擎声明自己活过什么」的**唯一读者**(两个调用点读同一组输入:local 后端的构造 —— 两半店的声明都从它的返回值来;起服第 2 段的店持久性准入 `store-admission.ts` —— 拒启判读同一份)。
|
|
43
|
+
* `dataRootMedium` = 起服第 2 段对数据根介质的判定;没有起服证据的入口(`run-local`、嵌入方直调 `createStoreBackend`)递 `unknown` —— 与装配值同一条缺证据律:
|
|
44
|
+
* 判不出的介质不放宽声明,只有运维的词能。
|
|
45
|
+
*/
|
|
46
|
+
export declare function localStoreDeclarationOf(deployment: LocalStoreDeclarationDeployment, dataRootMedium: StoreDurability): LocalStoreDeclaration;
|
|
47
|
+
/** 依据词的人读形(布线审计的 warn 行与店的持久性准入的拒句用)。 */
|
|
48
|
+
export declare function describeLocalStoreDeclaration(d: LocalStoreDeclaration): string;
|
|
49
|
+
/**
|
|
50
|
+
* `LOCAL_STORE_DURABILITY` 的读法(配置装载调这一只):缺席 / 空串 ⇒ `undefined`(设计声明);恰为闭集里的词(去首尾空白后逐字)⇒ 那个词;
|
|
51
|
+
* 别的任何值 ⇒ 抛(拒启)—— 一个读不懂的声明不许被折成「持久」或「易失」中的任何一边。
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseLocalStoreDurabilityWord(raw: string | undefined): LocalStoreDeclarationWord | undefined;
|
|
54
|
+
//# sourceMappingURL=local-store-declaration.d.ts.map
|