@sema-agent/server 7.134.0 → 7.136.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 +197 -1
- package/USAGE.md +147 -42
- package/deploy/sema-up/README.md +1 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
- package/deploy/sema-up/chart/values.yaml +1 -1
- package/dist/adoption/plan.d.ts +1 -1
- package/dist/approval-ask-audit-store.d.ts +24 -24
- package/dist/approval-ask-machine.d.ts +2 -2
- package/dist/approval-card.d.ts +122 -154
- package/dist/approval-card.js +50 -51
- package/dist/approval-content-kind.d.ts +23 -5
- package/dist/approval-content-kind.js +8 -1
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval-gate-currency.d.ts +22 -3
- package/dist/approval-gate-currency.js +44 -18
- package/dist/approval-hmac.d.ts +7 -7
- package/dist/approval-policy-settlement.d.ts +2 -2
- package/dist/approval-reconciler.d.ts +3 -3
- package/dist/approval.d.ts +8 -8
- package/dist/approval.js +4 -2
- package/dist/auth-bridge.d.ts +35 -6
- package/dist/auth-bridge.js +20 -3
- package/dist/auto-mode-face.d.ts +4 -4
- package/dist/background-session-reap.d.ts +2 -2
- package/dist/bake-runner/main.d.ts +2 -2
- package/dist/bake-runner/runner.d.ts +4 -4
- package/dist/bench/s1/live-deps.d.ts +1 -1
- package/dist/bench/s1/run-firm.d.ts +1 -1
- package/dist/boot/budget-tracing.d.ts +1 -2
- package/dist/boot/budget-tracing.js +2 -2
- package/dist/boot/coordinators.d.ts +2 -2
- package/dist/boot/coordinators.js +2 -2
- package/dist/boot/deferred-sandbox-path-env.d.ts +0 -6
- package/dist/boot/deferred-sandbox-path-env.js +0 -5
- package/dist/boot/engine-lease.d.ts +5 -5
- package/dist/boot/execution-env.d.ts +16 -15
- package/dist/boot/execution-env.js +19 -21
- package/dist/boot/fatal-exit.d.ts +2 -2
- package/dist/boot/late-binds.d.ts +1 -1
- package/dist/boot/leader.d.ts +1 -1
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/memory-consolidation.d.ts +15 -15
- package/dist/boot/org-memory.js +1 -1
- package/dist/boot/parked-revive-gate.d.ts +3 -3
- package/dist/boot/parked-revive-gate.js +3 -2
- package/dist/boot/reapers.d.ts +4 -4
- package/dist/boot/resolve-spec.d.ts +1 -1
- package/dist/boot/resolve-spec.js +36 -29
- package/dist/boot/runner-deps.d.ts +11 -11
- package/dist/boot/runner-deps.js +7 -4
- package/dist/boot/session-faces.d.ts +3 -3
- package/dist/boot/session-faces.js +11 -30
- package/dist/boot/shutdown.d.ts +5 -5
- package/dist/boot/side-query-lane.d.ts +2 -2
- package/dist/boot/stage-04-stores.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.js +4 -4
- package/dist/boot/stage-06-runners.d.ts +1 -1
- package/dist/boot/stage-06-runners.js +0 -2
- package/dist/boot/stage-07-capability-layer.d.ts +1 -1
- package/dist/boot/stage-08-reapers.d.ts +1 -1
- package/dist/boot/stage-09-leader.d.ts +1 -1
- package/dist/boot/stage-10-http-server.d.ts +1 -1
- package/dist/boot/stores.js +4 -4
- package/dist/boot/web-admin.d.ts +17 -17
- package/dist/boot/web-admin.js +15 -27
- package/dist/boot/workflow-orchestration.js +2 -9
- package/dist/brain.d.ts +11 -11
- package/dist/brain.js +12 -3
- package/dist/budget.d.ts +7 -7
- package/dist/budget.js +4 -0
- package/dist/capabilities/approvals-push.d.ts +4 -4
- package/dist/capabilities/builtin-tools.d.ts +5 -5
- package/dist/capabilities/center-plugins.d.ts +5 -5
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/center-prompts.d.ts +1 -1
- package/dist/capabilities/center-wiring.d.ts +1 -1
- package/dist/capabilities/composite-members.d.ts +1 -1
- package/dist/capabilities/execution-lane.d.ts +5 -5
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +5 -5
- package/dist/capabilities/mcp-probe.d.ts +11 -7
- package/dist/capabilities/sandbox-file-send.d.ts +1 -18
- package/dist/capabilities/sandbox-file-send.js +0 -7
- package/dist/capabilities/scenarios.d.ts +28 -10
- package/dist/capabilities/scenarios.js +15 -5
- package/dist/capabilities/send-user-file-tool.d.ts +1 -1
- package/dist/capabilities/skills.d.ts +31 -12
- package/dist/capabilities/skills.js +23 -17
- package/dist/capabilities/tool-defer.d.ts +1 -1
- package/dist/capability-facts.d.ts +29 -32
- package/dist/capability-facts.js +17 -21
- package/dist/center-config-tier.d.ts +1 -1
- package/dist/center-credential.d.ts +22 -8
- package/dist/center-credential.js +18 -3
- package/dist/checkpoint-identity.d.ts +5 -0
- package/dist/checkpoint-identity.js +14 -0
- package/dist/config-catalog.d.ts +12 -12
- package/dist/config-catalog.js +12 -10
- package/dist/config-d-migration.js +1 -1
- package/dist/config-invariants.d.ts +5 -5
- package/dist/config-invariants.js +11 -2
- package/dist/config-lkg.d.ts +1 -39
- package/dist/config-lkg.js +1 -83
- package/dist/config-provider.d.ts +13 -13
- package/dist/config-provider.js +2 -1
- package/dist/config-types.d.ts +95 -87
- package/dist/config.d.ts +26 -24
- package/dist/config.js +38 -18
- package/dist/cross-session-settings.d.ts +1 -1
- package/dist/delegated-session-owner.d.ts +16 -13
- package/dist/delegated-session-owner.js +9 -10
- package/dist/deployment-governance.d.ts +16 -16
- package/dist/deployment-shape.d.ts +127 -0
- package/dist/deployment-shape.js +72 -0
- package/dist/device-store.d.ts +1 -1
- package/dist/device-ws-hub.d.ts +1 -1
- package/dist/egress-redirect.d.ts +1 -1
- package/dist/elicitation.d.ts +8 -7
- package/dist/elicitation.js +9 -8
- package/dist/entry-mode-clamp-notice.d.ts +2 -2
- package/dist/env-facts.d.ts +10 -9
- package/dist/env-facts.js +1 -1
- package/dist/env-name-allowlist-knobs.d.ts +5 -5
- package/dist/exec-bounds.d.ts +2 -2
- package/dist/execution-lane-caps.d.ts +31 -43
- package/dist/execution-lane-caps.js +0 -13
- package/dist/file-history-capture.d.ts +9 -9
- package/dist/file-history-disclosure.d.ts +25 -11
- package/dist/file-history-disclosure.js +25 -14
- package/dist/fleet/drain-entry.d.ts +2 -2
- package/dist/fleet/fleet-bus.d.ts +22 -14
- package/dist/fleet/fleet-bus.js +5 -5
- package/dist/fleet/fleet-reconciler.d.ts +9 -9
- package/dist/fleet/subagent-tail-bus.d.ts +4 -4
- package/dist/fleet-client.d.ts +45 -14
- package/dist/fleet-client.js +24 -4
- package/dist/fleet-lease.d.ts +23 -19
- package/dist/fleet-lease.js +31 -23
- package/dist/governance-http-status.d.ts +2 -2
- package/dist/hooks/hook-llm.d.ts +7 -7
- package/dist/hooks/hook-llm.js +14 -8
- package/dist/hooks/hook-runner.d.ts +58 -31
- package/dist/hooks/hook-runner.js +37 -19
- package/dist/host-decision.d.ts +5 -5
- package/dist/host-lsp-manager.d.ts +5 -5
- package/dist/hosted-posture.d.ts +23 -13
- package/dist/hosted-posture.js +4 -9
- package/dist/http/admission.d.ts +2 -2
- package/dist/http/admission.js +20 -5
- package/dist/http/approval-sweeps.d.ts +1 -1
- package/dist/http/approval-sweeps.js +2 -1
- package/dist/http/checkpoint-ctx.d.ts +62 -17
- package/dist/http/checkpoint-ctx.js +78 -35
- package/dist/http/dispatch.d.ts +3 -3
- package/dist/http/dispatch.js +9 -9
- package/dist/http/durable-run-leg.js +4 -3
- package/dist/http/idempotency.d.ts +2 -2
- package/dist/http/mcp-dial-deadline.d.ts +7 -5
- package/dist/http/memory-compliance-failure-reply.d.ts +4 -4
- package/dist/http/owner-access.d.ts +4 -6
- package/dist/http/owner-access.js +1 -1
- package/dist/http/principal-gate.d.ts +7 -7
- package/dist/http/principal-gate.js +3 -2
- package/dist/http/readiness.d.ts +1 -1
- package/dist/http/request-guards.d.ts +4 -4
- package/dist/http/request-guards.js +2 -1
- package/dist/http/resume-ctx-read.d.ts +9 -23
- package/dist/http/resume-ctx-read.js +2 -3
- package/dist/http/resume-legs.d.ts +3 -3
- package/dist/http/resume-legs.js +11 -8
- package/dist/http/route-ctx.d.ts +29 -29
- package/dist/http/route-table.d.ts +9 -9
- package/dist/http/routes/agents-roster.d.ts +1 -1
- package/dist/http/routes/approvals-assistant.d.ts +5 -7
- package/dist/http/routes/approvals-assistant.js +101 -26
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/background.js +2 -2
- package/dist/http/routes/capabilities.d.ts +1 -1
- package/dist/http/routes/capabilities.js +16 -8
- package/dist/http/routes/config-catalog.d.ts +1 -1
- package/dist/http/routes/devices.d.ts +1 -1
- package/dist/http/routes/diagnostics.d.ts +3 -3
- package/dist/http/routes/fleet.d.ts +1 -1
- package/dist/http/routes/fleet.js +2 -1
- package/dist/http/routes/mcp-reconnect.d.ts +4 -4
- package/dist/http/routes/mcp-reconnect.js +3 -3
- package/dist/http/routes/memory-consolidation.d.ts +1 -1
- package/dist/http/routes/notify-wake.d.ts +1 -1
- package/dist/http/routes/notify-wake.js +2 -2
- package/dist/http/routes/rules.d.ts +1 -1
- package/dist/http/routes/runs.js +23 -11
- package/dist/http/routes/session-sync.d.ts +1 -1
- package/dist/http/routes/session-sync.js +97 -46
- package/dist/http/routes/sessions-list.js +1 -1
- package/dist/http/routes/sessions.js +43 -53
- package/dist/http/routes/tasks.d.ts +1 -1
- package/dist/http/routes/trace-usage.d.ts +1 -1
- package/dist/http/routes/workflows.d.ts +3 -0
- package/dist/http/routes/workflows.js +31 -28
- package/dist/http/send.d.ts +5 -5
- package/dist/http/server.d.ts +34 -34
- package/dist/http/session-inherit-env.d.ts +3 -3
- package/dist/http/sse-lifecycle.d.ts +1 -1
- package/dist/http/sse-log.d.ts +2 -2
- package/dist/http/submit-ctx.js +1 -1
- package/dist/http/sync-submit-body.d.ts +1 -1
- package/dist/http/verify-rounds.d.ts +1 -1
- package/dist/http/wire-types.d.ts +33 -24
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/instruction-source-notice.d.ts +2 -2
- package/dist/key-resolver.d.ts +3 -3
- package/dist/lane-home-probe.d.ts +1 -1
- package/dist/leader/diffout.d.ts +1 -1
- package/dist/leader/diffup.d.ts +2 -2
- package/dist/leader/endpoint.d.ts +1 -1
- package/dist/leader/fanout.d.ts +1 -1
- package/dist/leader/leader.d.ts +4 -4
- package/dist/leader/merge.d.ts +3 -3
- package/dist/leader/repair-wire.d.ts +1 -1
- package/dist/leader/wire.d.ts +6 -6
- package/dist/list-entry-display.d.ts +1 -1
- package/dist/lsp-evict.d.ts +1 -1
- package/dist/mcp-assertion-header.d.ts +1 -1
- package/dist/memory-layer-legacy-lock.d.ts +1 -1
- package/dist/memory-operator-faces.d.ts +1 -1
- package/dist/memory-posture.js +4 -2
- package/dist/memory-project-layer.d.ts +1 -1
- package/dist/memory-scope.d.ts +19 -19
- package/dist/memory-store-refusal.d.ts +4 -4
- package/dist/model-entry-headers.d.ts +2 -2
- package/dist/model-entry-refusal.d.ts +17 -17
- package/dist/model-provider.d.ts +10 -10
- package/dist/model-reach-scope.d.ts +1 -1
- package/dist/model-route-endpoint.d.ts +6 -6
- package/dist/model-route-gap.d.ts +49 -4
- package/dist/model-route-gap.js +34 -1
- package/dist/model-route-url.d.ts +5 -5
- package/dist/model-select.d.ts +15 -6
- package/dist/model-select.js +5 -0
- package/dist/model-unreachable-notice.d.ts +3 -3
- package/dist/namespaced-rule-name.d.ts +15 -5
- package/dist/namespaced-rule-name.js +3 -2
- package/dist/object-store-buckets.d.ts +13 -0
- package/dist/object-store-buckets.js +3 -0
- package/dist/observability/corrupt-read-seat.d.ts +9 -9
- package/dist/observability/cost-taxonomy.d.ts +1 -1
- package/dist/observability/err-text.d.ts +1 -1
- package/dist/observability/fail-open.d.ts +17 -13
- package/dist/observability/fail-open.js +17 -13
- package/dist/observability/metrics.d.ts +3 -3
- package/dist/observability/metrics.js +1 -1
- package/dist/observability/principal-context.d.ts +4 -1
- package/dist/observability/principal-context.js +6 -1
- package/dist/observability/run-terminal.d.ts +36 -36
- package/dist/observability/secret-env-scrub.d.ts +3 -3
- package/dist/observability/tool-trace.d.ts +1 -1
- package/dist/operator-ask.d.ts +4 -4
- package/dist/orchestration/workflow-agent-session-index.d.ts +3 -3
- package/dist/orchestration/workflow-completion-inbox.d.ts +20 -5
- package/dist/orchestration/workflow-completion-inbox.js +29 -7
- package/dist/orchestration/workflow-notify-journal.d.ts +43 -19
- package/dist/orchestration/workflow-notify-journal.js +17 -0
- package/dist/outbound-dispatcher.d.ts +4 -4
- package/dist/parent-watch.d.ts +4 -4
- package/dist/parked-decide.d.ts +20 -18
- package/dist/parked-decide.js +31 -11
- package/dist/parked-revive-surface.d.ts +7 -7
- package/dist/parked-revive-surface.js +2 -3
- package/dist/peer-directory.d.ts +5 -4
- package/dist/peer-directory.js +6 -6
- package/dist/permission-rule-list.d.ts +10 -1
- package/dist/permission-rule-list.js +7 -5
- package/dist/permission-rule-vocab.d.ts +2 -2
- package/dist/plugins/adoption-log-sql.d.ts +1 -1
- package/dist/plugins/approval-ask-store-file.d.ts +8 -1
- package/dist/plugins/approval-ask-store-file.js +6 -3
- package/dist/plugins/approval-ask-store-memory.d.ts +11 -7
- package/dist/plugins/approval-ask-store-memory.js +11 -7
- package/dist/plugins/approval-ask-store-sql.d.ts +42 -15
- package/dist/plugins/approval-ask-store-sql.js +21 -5
- package/dist/plugins/approval-exemption-store.d.ts +3 -3
- package/dist/plugins/approval-nonce-store.d.ts +3 -3
- package/dist/plugins/background-agent-store-sql.d.ts +1 -1
- package/dist/plugins/background-shell-support.d.ts +2 -2
- package/dist/plugins/blob-backend.d.ts +1 -1
- package/dist/plugins/blob-backend.js +2 -1
- package/dist/plugins/caching-session-store.d.ts +23 -32
- package/dist/plugins/caching-session-store.js +5 -17
- package/dist/plugins/checkpoint-index-columns.d.ts +130 -0
- package/dist/plugins/checkpoint-index-columns.js +90 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +71 -69
- package/dist/plugins/checkpoint-store-sql.js +109 -127
- package/dist/plugins/device-store-sql.d.ts +7 -6
- package/dist/plugins/e2b-orphan-reclaim.d.ts +1 -1
- package/dist/plugins/ensure-schema-lock-policy.d.ts +1 -1
- package/dist/plugins/file-history-store-sql.d.ts +15 -7
- package/dist/plugins/file-history-store-sql.js +55 -36
- package/dist/plugins/file-run-store.d.ts +8 -8
- package/dist/plugins/fork-routing-session-store.d.ts +2 -2
- package/dist/plugins/fork-routing-session-store.js +1 -1
- package/dist/plugins/host-platform.d.ts +10 -10
- package/dist/plugins/image-bake-store-sql.d.ts +1 -1
- package/dist/plugins/image-index-sql.d.ts +1 -1
- package/dist/plugins/leader-run-store-sql.d.ts +1 -1
- package/dist/plugins/local-checkpoint-store.d.ts +10 -10
- package/dist/plugins/local-checkpoint-store.js +7 -7
- package/dist/plugins/local-session-store.d.ts +34 -38
- package/dist/plugins/local-session-store.js +20 -39
- package/dist/plugins/local-session-window.d.ts +1 -1
- package/dist/plugins/mailbox-store-sql.d.ts +2 -2
- package/dist/plugins/memory-engine-pg.d.ts +1 -1
- package/dist/plugins/memory-run-store.d.ts +4 -4
- package/dist/plugins/memory-sync-store-pg.d.ts +3 -3
- package/dist/plugins/one-time-migrations.d.ts +73 -54
- package/dist/plugins/one-time-migrations.js +131 -134
- package/dist/plugins/outcome-ledger-sql.d.ts +1 -1
- package/dist/plugins/park-commit-watch.d.ts +3 -3
- package/dist/plugins/permission-rule-store-file.d.ts +5 -5
- package/dist/plugins/permission-rule-store-file.js +12 -19
- package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
- package/dist/plugins/permission-rule-store-sql.js +67 -24
- package/dist/plugins/pg-cost-quota.d.ts +1 -1
- package/dist/plugins/pg-pool.d.ts +2 -2
- package/dist/plugins/pg-pool.js +5 -2
- package/dist/plugins/pg-rate-limiter.d.ts +1 -1
- package/dist/plugins/pg-session-storage.d.ts +8 -20
- package/dist/plugins/pg-session-storage.js +14 -27
- package/dist/plugins/remote-env-adb.d.ts +10 -10
- package/dist/plugins/remote-env-device.d.ts +10 -9
- package/dist/plugins/remote-env-device.js +6 -2
- package/dist/plugins/remote-env-e2b.d.ts +3 -3
- package/dist/plugins/remote-env-host.d.ts +16 -16
- package/dist/plugins/remote-env-k8s.d.ts +26 -13
- package/dist/plugins/remote-env-k8s.js +24 -7
- package/dist/plugins/remote-env-local-docker.d.ts +2 -2
- package/dist/plugins/remote-env-ssh.d.ts +4 -4
- package/dist/plugins/remote-scratchpad.d.ts +2 -3
- package/dist/plugins/remote-scratchpad.js +0 -4
- package/dist/plugins/remote-shell.d.ts +6 -6
- package/dist/plugins/retention-lane-store-sql.d.ts +4 -4
- package/dist/plugins/retention-store-sql.d.ts +4 -4
- package/dist/plugins/roster-store-sql.d.ts +1 -1
- package/dist/plugins/run-store-sql.d.ts +8 -8
- package/dist/plugins/s3-answer.d.ts +15 -0
- package/dist/plugins/s3-answer.js +5 -0
- package/dist/plugins/schema-consistency.d.ts +2 -2
- package/dist/plugins/schema-ensure-legs.d.ts +3 -3
- package/dist/plugins/schema-indexes.d.ts +1 -1
- package/dist/plugins/schema-live-columns.d.ts +1 -1
- package/dist/plugins/session-event-payload.d.ts +4 -4
- package/dist/plugins/session-fork.d.ts +34 -0
- package/dist/plugins/session-fork.js +29 -0
- package/dist/plugins/session-ownership.js +1 -1
- package/dist/plugins/session-placement.d.ts +1 -1
- package/dist/plugins/session-policy-store-sql.d.ts +12 -12
- package/dist/plugins/session-store.d.ts +2 -2
- package/dist/plugins/session-store.js +2 -2
- package/dist/plugins/shared-memory-store-sql.d.ts +2 -2
- package/dist/plugins/snapshot-bucket-presence.d.ts +39 -4
- package/dist/plugins/snapshot-bucket-presence.js +35 -7
- package/dist/plugins/sql-driver.d.ts +8 -8
- package/dist/plugins/sql-errors.d.ts +40 -1
- package/dist/plugins/sql-errors.js +49 -1
- package/dist/plugins/sql-json-column.d.ts +21 -21
- package/dist/plugins/sql-row-helpers.d.ts +2 -2
- package/dist/plugins/store-backend.d.ts +17 -16
- package/dist/plugins/store-backend.js +3 -3
- package/dist/plugins/store-contracts.d.ts +21 -21
- package/dist/plugins/store-fault.d.ts +4 -0
- package/dist/plugins/store-fault.js +8 -0
- package/dist/plugins/task-attachment-store.d.ts +2 -2
- package/dist/plugins/task-list-store-sql.d.ts +1 -1
- package/dist/plugins/tidb-pool.d.ts +2 -2
- package/dist/plugins/tidb-pool.js +10 -3
- package/dist/plugins/tidb-session-store.d.ts +16 -26
- package/dist/plugins/tidb-session-store.js +15 -27
- package/dist/plugins/tool-result-store-sql.d.ts +1 -1
- package/dist/plugins/usage-window-store-sql.d.ts +3 -3
- package/dist/plugins/user-input-ledger-file.d.ts +1 -1
- package/dist/plugins/user-input-ledger-sql.d.ts +3 -3
- package/dist/plugins/web-search.d.ts +19 -5
- package/dist/plugins/web-search.js +20 -5
- package/dist/{orchestration/workflow-journal-entry.d.ts → plugins/workflow-journal-payload.d.ts} +23 -32
- package/dist/plugins/workflow-journal-payload.js +32 -0
- package/dist/plugins/workflow-journal-store-sql.d.ts +28 -14
- package/dist/plugins/workflow-journal-store-sql.js +34 -15
- package/dist/plugins/workflow-run-store-sql.d.ts +4 -4
- package/dist/posture-source.d.ts +11 -11
- package/dist/principal-jwt.d.ts +6 -6
- package/dist/project-identity.d.ts +3 -3
- package/dist/project-memory.d.ts +4 -4
- package/dist/read-face-posture.d.ts +7 -7
- package/dist/request-declaration-refusal.d.ts +94 -0
- package/dist/request-declaration-refusal.js +78 -0
- package/dist/request-image-urls.d.ts +6 -0
- package/dist/request-image-urls.js +27 -0
- package/dist/request-key-closure.d.ts +6 -1
- package/dist/request-key-closure.js +5 -2
- package/dist/request-value-closure.d.ts +15 -8
- package/dist/request-value-closure.js +2 -0
- package/dist/router/route-orchestration.d.ts +11 -16
- package/dist/router/route-orchestration.js +2 -12
- package/dist/rule-entry-list.d.ts +8 -7
- package/dist/rule-entry-list.js +2 -9
- package/dist/rules-consent.d.ts +6 -6
- package/dist/rules-consent.js +2 -0
- package/dist/run-cancel-context.d.ts +5 -5
- package/dist/run-local.d.ts +10 -10
- package/dist/runs.d.ts +13 -11
- package/dist/runs.js +15 -1
- package/dist/runtime-caps-resolver.d.ts +6 -6
- package/dist/runtime-caps-resolver.js +1 -1
- package/dist/runtime-governance.d.ts +9 -9
- package/dist/sandbox-pkg-source.d.ts +17 -12
- package/dist/sandbox-pkg-source.js +14 -9
- package/dist/sealed-key.d.ts +22 -3
- package/dist/sealed-key.js +47 -4
- package/dist/security.d.ts +23 -26
- package/dist/security.js +12 -9
- package/dist/server-secret-env.d.ts +10 -10
- package/dist/session-children-retire.d.ts +1 -1
- package/dist/session-error-wire.d.ts +7 -7
- package/dist/session-incarnation.d.ts +65 -37
- package/dist/session-incarnation.js +30 -12
- package/dist/session-policy-wire.d.ts +27 -5
- package/dist/session-policy-wire.js +15 -1
- package/dist/session-records-skipped-notice.d.ts +1 -1
- package/dist/session-row.d.ts +3 -17
- package/dist/session-row.js +4 -0
- package/dist/session-sync-kernel.d.ts +4 -4
- package/dist/session-sync.d.ts +61 -6
- package/dist/session-sync.js +55 -10
- package/dist/session-titler.d.ts +7 -6
- package/dist/session-titler.js +8 -13
- package/dist/session-watch.d.ts +3 -3
- package/dist/session-watch.js +4 -4
- package/dist/sighup-idle.d.ts +2 -2
- package/dist/spec-fields.d.ts +4 -4
- package/dist/sql-engine-posture.d.ts +3 -3
- package/dist/store-posture.d.ts +2 -2
- package/dist/stored-request-tool-axes-m19.d.ts +1 -1
- package/dist/task-a2a.d.ts +52 -79
- package/dist/task-a2a.js +224 -62
- package/dist/task-cwd.d.ts +7 -88
- package/dist/task-cwd.js +2 -15
- package/dist/task-mcp.d.ts +13 -17
- package/dist/task-mcp.js +29 -49
- package/dist/task-settings.d.ts +30 -18
- package/dist/task-settings.js +33 -3
- package/dist/task-workflow.d.ts +0 -24
- package/dist/task-workflow.js +2 -1
- package/dist/terminal.d.ts +5 -5
- package/dist/tighten-only-seats.d.ts +7 -6
- package/dist/tighten-only-seats.js +1 -1
- package/dist/tool-approval.d.ts +166 -207
- package/dist/tool-approval.js +61 -61
- package/dist/tool-rule-names.d.ts +2 -2
- package/dist/trace/core-keyset-guard.d.ts +13 -8
- package/dist/trace/engine-notice-wire.d.ts +5 -5
- package/dist/trace/engine-notice-wire.js +1 -0
- package/dist/trace/exit-seat.d.ts +31 -4
- package/dist/trace/exit-seat.js +69 -67
- package/dist/trace/ledger-events.d.ts +3 -3
- package/dist/trace/ledger-sink.d.ts +1 -1
- package/dist/trace/model-segment.d.ts +3 -3
- package/dist/trace/project.d.ts +47 -45
- package/dist/trace/project.js +33 -1
- package/dist/trace/redact.d.ts +61 -31
- package/dist/trace/redact.js +394 -153
- package/dist/trace/self-minted-wire.d.ts +302 -14
- package/dist/trace/self-minted-wire.js +87 -0
- package/dist/trace/sema-provenance.d.ts +1 -1
- package/dist/trace/task-notification-facets.d.ts +4 -4
- package/dist/trace/wire-projection-faces.d.ts +3 -3
- package/dist/trace/wire-projection-faces.js +1 -1
- package/dist/unattended-permission-mode.d.ts +5 -5
- package/dist/url-credential-refusal.d.ts +52 -0
- package/dist/url-credential-refusal.js +14 -0
- package/dist/url-refusal.d.ts +16 -3
- package/dist/url-refusal.js +15 -2
- package/dist/usage-analytics.d.ts +2 -2
- package/dist/user-input-ledger.d.ts +23 -23
- package/dist/web-admin-client/apply-effective.d.ts +5 -5
- package/dist/web-admin-client/apply-effective.js +2 -1
- package/dist/web-admin-client/apply-ledger.d.ts +2 -2
- package/dist/web-admin-client/center-request.d.ts +2 -2
- package/dist/web-admin-client/facade.d.ts +5 -5
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/hot-keys-registry.d.ts +2 -2
- package/dist/web-admin-client/http-client.d.ts +4 -4
- package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
- package/dist/web-admin-client/pull-state.d.ts +1 -1
- package/dist/web-admin-client/read-face.d.ts +2 -2
- package/dist/web-admin-client/read-warnings.d.ts +5 -5
- package/dist/web-admin-client/restart-signal.d.ts +6 -6
- package/dist/web-admin-client/skills-mcp.d.ts +28 -3
- package/dist/web-admin-client/skills-mcp.js +29 -1
- package/dist/web-admin-client/types.d.ts +16 -9
- package/dist/workspace-space.d.ts +32 -3
- package/dist/workspace-space.js +26 -0
- package/dist/write-protection.d.ts +2 -2
- package/package.json +5 -3
- package/scripts/drain-check-local.mjs +4 -2
- package/scripts/drain-check.mysql.sql +6 -2
- package/scripts/drain-check.pg.sql +6 -2
- package/skills/loop.md +1 -1
- package/skills/schedule.md +1 -1
- package/wire-changes/server@7.104.0.json +134 -0
- package/wire-changes/server@7.105.0.json +53 -0
- package/wire-changes/server@7.106.0.json +475 -0
- package/wire-changes/server@7.107.0.json +64 -0
- package/wire-changes/server@7.108.0.json +153 -0
- package/wire-changes/server@7.109.0.json +46 -0
- package/wire-changes/server@7.110.0.json +90 -0
- package/wire-changes/server@7.111.0.json +86 -0
- package/wire-changes/server@7.112.0.json +60 -0
- package/wire-changes/server@7.113.0.json +26 -0
- package/wire-changes/server@7.114.0.json +26 -0
- package/wire-changes/server@7.115.0.json +97 -0
- package/wire-changes/server@7.116.0.json +218 -0
- package/wire-changes/server@7.116.1.json +26 -0
- package/wire-changes/server@7.117.0.json +65 -0
- package/wire-changes/server@7.118.0.json +129 -0
- package/wire-changes/server@7.119.0.json +65 -0
- package/wire-changes/server@7.120.0.json +89 -0
- package/wire-changes/server@7.121.0.json +219 -0
- package/wire-changes/server@7.122.0.json +54 -0
- package/wire-changes/server@7.123.0.json +26 -0
- package/wire-changes/server@7.124.0.json +336 -0
- package/wire-changes/server@7.124.1.json +26 -0
- package/wire-changes/server@7.125.0.json +111 -0
- package/wire-changes/server@7.126.0.json +285 -0
- package/wire-changes/server@7.127.0.json +77 -0
- package/wire-changes/server@7.127.1.json +26 -0
- package/wire-changes/server@7.127.2.json +53 -0
- package/wire-changes/server@7.128.0.json +26 -0
- package/wire-changes/server@7.129.0.json +106 -0
- package/wire-changes/server@7.129.1.json +26 -0
- package/wire-changes/server@7.130.0.json +26 -0
- package/wire-changes/server@7.131.0.json +118 -0
- package/wire-changes/server@7.132.0.json +226 -0
- package/wire-changes/server@7.133.0.json +1155 -0
- package/wire-changes/server@7.134.0.json +107 -0
- package/wire-changes/server@7.135.0.json +174 -0
- package/wire-changes/server@7.136.0.json +448 -0
- package/dist/http/run-declared-families.d.ts +0 -16
- package/dist/http/run-declared-families.js +0 -12
- package/dist/orchestration/workflow-journal-entry.js +0 -27
|
@@ -50,7 +50,7 @@ export type { ApprovalNonceStore } from "./approval-nonce-store.js";
|
|
|
50
50
|
* 车3 刀 3a 起 `StoreBackend.approvalAsk()` 已在(见接口体的那条注)。 */
|
|
51
51
|
export type { ApprovalAskStore, AskRow, NewAskRow, AskTransitionPatch, DecideAskInput, DecideResult, ExpireResult, BindGateInput, BatchRow, AskDecision } from "./approval-ask-store-sql.js";
|
|
52
52
|
/** E6 SessionPolicyStore — core's interface, incl. its optional `deleteBySession` / `listBySession` seams (E21 purge / 2c
|
|
53
|
-
* export; core's File and InMemory stores carry both since core 7.25.0 —
|
|
53
|
+
* export; core's File and InMemory stores carry both since core 7.25.0 — [ref] A7 retired the service's own in-memory
|
|
54
54
|
* twin that existed only because they once did not). tidb/pg = the SQL twin; local = core's FileSessionPolicyStore
|
|
55
55
|
* (works local — rules need no cloud-only infra). The rev-line contract kit runs the SQL twin against core's InMemory
|
|
56
56
|
* as oracle (`test/helpers/session-policy-rev-line-contract.ts`). */
|
|
@@ -94,12 +94,13 @@ export type ServiceFileHistoryStore = FileHistoryStore & {
|
|
|
94
94
|
/** SVC-2 (core CORE-7) WorkflowJournalStore — core's interface PLUS the service `deleteByRun` (GC extra). tidb/pg =
|
|
95
95
|
* durable SQL twins (cross-replica resume journal); local = the service {@link FileWorkflowJournalStore}
|
|
96
96
|
* (single-box but RESTART-durable crash-safe JSONL, replacing core's InMemory). The shared equivalence suite keeps
|
|
97
|
-
* all three byte-matched (scope guard / idempotent-per-ordinal / oversize **refusal** ——
|
|
97
|
+
* all three byte-matched (scope guard / idempotent-per-ordinal / oversize **refusal** —— [ref] / core 7.12.0
|
|
98
98
|
* [ref] 起两臂一律抛 `workflow.journal_oversize`,判长口径归 core `assertJournalEntryFits` 单一属主). */
|
|
99
99
|
export type ServiceWorkflowJournalStore = WorkflowJournalStore & {
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
100
|
+
/** journal 读面的分页投影读:**判整份、取一页**——与 `load` 同一个判的范围(这条 journal 里任一行被 core 的判官判坏,本读就抛
|
|
101
|
+
* `WorkflowJournalIncompatibleError`,点名按序数升序的第一条坏行;页不是判的单位),只是内存按块有界:返回 `[offset, offset+limit)` 位置上的行,
|
|
102
|
+
* 字节超 `maxResultBytes` 的行 `resultJson=null` 只回 `resultBytes`(读面标 truncated,全文不进页)。HTTP 读面优先走此面;
|
|
103
|
+
* 缺席(file / in-memory 店)回落 `load` 后在进程内切页——`load` 本身就整份判,两条路同答。 */
|
|
103
104
|
loadPage?(runId: string, scope: string, opts: {
|
|
104
105
|
offset: number;
|
|
105
106
|
limit: number;
|
|
@@ -140,11 +141,11 @@ export type BreakerStateStore = TiDBBreakerState | PgBreakerState;
|
|
|
140
141
|
export type CostQuotaStore = TiDBCostQuota | PgCostQuota;
|
|
141
142
|
export type RateLimiterStore = TiDBRateLimiter | PgRateLimiter;
|
|
142
143
|
/**
|
|
143
|
-
*
|
|
144
|
+
* [ref] —— capture opt-out **记录载体的按平面取用座**。形与 core 的
|
|
144
145
|
* `RunnerDeps.memoryCaptureRecordStore`(`(plane: { controlDir }) => SessionCaptureRecordStore`)同构,
|
|
145
146
|
* 多一个**不指名平面**的缺省臂:`src()` = 「本部署记忆引擎自己那一只平面」。
|
|
146
147
|
*
|
|
147
|
-
* 🔴 为什么是工厂而不是一只实例(
|
|
148
|
+
* 🔴 为什么是工厂而不是一只实例([ref] codex r1 [high] 验真后改形):core 的记忆平面**不止一个**
|
|
148
149
|
* (`prepare-memory.js` 的 personal 平面自带 `derivePersonalControlDir(engineRoot)`,与 project 平面的
|
|
149
150
|
* controlDir 不是同一只)。返回单只实例 ⇒ server 把所有平面折到一只目录上,于是升级前落在 personal
|
|
150
151
|
* 控制面的旧 opt-out 记录在升级后读作**缺席**=采集恢复(隐私面的静默 fail-open)。按平面取用后,
|
|
@@ -173,7 +174,7 @@ export interface StoreBackend {
|
|
|
173
174
|
/** Per-session per-toolName approval exemption ("本会话不再询问") — an approval MEMORY the F4
|
|
174
175
|
* ask-gate consults after deny/neverAuto. REQUIRED on all backends (works local, like resumeAnchor). */
|
|
175
176
|
approvalExemption(): ApprovalExemptionStore;
|
|
176
|
-
/**
|
|
177
|
+
/** [ref] 直连门审批证明的一次性消费记录(`plan_review` 的 nonce)。REQUIRED on all backends —— 与
|
|
177
178
|
* `approvalExemption` 同姿势:tidb/pg = SQL 双方言(单类双语句),local = File 追加日志 + 压实。
|
|
178
179
|
* **不能**退化成进程内易失形:一次重启若把记录抹掉,JWT TTL 窗内的重放就复活了,而那正是本店要关的洞。 */
|
|
179
180
|
approvalNonce(): ApprovalNonceStore;
|
|
@@ -185,7 +186,7 @@ export interface StoreBackend {
|
|
|
185
186
|
/** [ref]([ref] §3.0-§3.2)流内审批协议持久层:每个流内工具调用一行的 ask 状态机 + 批行。
|
|
186
187
|
* REQUIRED **且持久** on all backends — tidb/pg = SQL 双方言 twin;local = {@link FileApprovalAskStore}。
|
|
187
188
|
*
|
|
188
|
-
* 🔴 **「持久」是本口的契约,不是某条腿的巧合**(
|
|
189
|
+
* 🔴 **「持久」是本口的契约,不是某条腿的巧合**([ref]):`resolveStreamApprovalGate` 自此**不再**
|
|
189
190
|
* 单独判一次 ask 账的持久性 —— 那条合取项(旧 `volatile_ask_ledger`)存在的唯一理由是 local 车道
|
|
190
191
|
* 当年交的是 `InMemoryApprovalAskStore`(两个进程内 Map ⇒ 重启同时丢重放基准、丢已接受的决议;
|
|
191
192
|
* 「一次真实的人类批准凭空消失」与「对账便利丢失」不是一个量级)。File 形落地后三条腿全是持久店,
|
|
@@ -220,12 +221,12 @@ export interface StoreBackend {
|
|
|
220
221
|
/** SendUserFile scope↔object ledger (multi-tenant list/revoke handle; the hashed key segment hides the
|
|
221
222
|
* mapping from URLs). REQUIRED on all backends (works local — one JSONL, like approvalExemption). */
|
|
222
223
|
sendFileLedger(): SendFileLedger;
|
|
223
|
-
/**
|
|
224
|
+
/** [ref] 用户输入受理账本的存储孪生(「200 applied」受理的影子;语义属主 `src/user-input-ledger.ts`)。REQUIRED on all backends ——
|
|
224
225
|
* local = File(数据根下 `user-input-ledger/ledger.jsonl`,singleton:追加 fd 与内存折叠都在实例里),SQL = 表 `user_input_acceptance`。 */
|
|
225
226
|
userInputLedger(): UserInputLedgerStore;
|
|
226
227
|
/** E6 durable SessionPolicyStore (operator-tightened per-session tool rules). REQUIRED on all backends — works local
|
|
227
228
|
* (local = core's FileSessionPolicyStore), like resumeAnchor. Backs core's RunnerDeps.sessionPolicyStore.
|
|
228
|
-
* `logger`:SQL 孪生抹除封键那一臂(
|
|
229
|
+
* `logger`:SQL 孪生抹除封键那一臂([ref])的点名口(缺席 ⇒ 店退回 `console.warn`);local(core 的 File 店)不收。 */
|
|
229
230
|
sessionPolicy(logger?: SessionPolicyStoreLogger): ServiceSessionPolicyStore;
|
|
230
231
|
/** [ref] per-edited-file rewind FileHistoryStore (trackEdit/annulTrack/snapshot/restore over the tracked set;
|
|
231
232
|
* also the 2c history-transfer store). REQUIRED on all backends (local = core's file-backed
|
|
@@ -243,14 +244,14 @@ export interface StoreBackend {
|
|
|
243
244
|
* 「没有行 ⇒ 代码缺省 allow」—— 那是**放宽面**上的静默降级(permissionRule 那条禁令的同一理由)。
|
|
244
245
|
* File 形候真实的 local+governed 部署需求出现再落(候需求档)。 */
|
|
245
246
|
memoryOptOutGrant(): MemoryOptOutGrantStore | undefined;
|
|
246
|
-
/** [ref]②([ref] §2.1b,core 7.0.2 [ref] 件2)/
|
|
247
|
+
/** [ref]②([ref] §2.1b,core 7.0.2 [ref] 件2)/ [ref]:会话 capture opt-out **记录**的载体 ——
|
|
247
248
|
* core `RunnerDeps.memoryCaptureRecordStore` / `MemoryEngineOptions.captureRecordStore` 的持久层。
|
|
248
249
|
* 与 §3.1 的**授权表**不是一个轴:那张管「谁**可以** opt-out」(operator 写的 verdict),这张管
|
|
249
250
|
* 「谁**已经** opt-out」(用户写的一次性单向记录)。
|
|
250
251
|
*
|
|
251
252
|
* 返回的是**按平面取用的源**({@link SessionCaptureRecordSource}),不是一只实例 —— core 的记忆平面
|
|
252
253
|
* 不止一只,折平会挪动旧记录的地址(理由全文见该类型的头注)。
|
|
253
|
-
* 载体按车道分形,但**三条车道都供**(
|
|
254
|
+
* 载体按车道分形,但**三条车道都供**([ref] 起):SQL 两支 = 双方言 twin(`session_capture_optout`,
|
|
254
255
|
* Promise 形三腿,池即依托 ⇒ 无条件供,`plane` 刻意忽略);`local` = core 的控制面文件三腿
|
|
255
256
|
* `fileSessionCaptureRecordStore(controlDir)` 按平面现造,依托是**记忆引擎的控制面目录** ⇒ 记忆面暗的
|
|
256
257
|
* 部署上该平面不存在,于是这一支**随引擎接线门缺席**(唯一的 `undefined` 成因,逐字理由见 LocalBackend 的实装注)。
|
|
@@ -259,7 +260,7 @@ export interface StoreBackend {
|
|
|
259
260
|
* 确实就是文件三腿)、在**接线层面**是假的:core 的 `captureCarrierUnsupported`
|
|
260
261
|
* (core 7.13.0 `prepare-task.js`)判的是「这个席位在不在」而不是「文件形能不能用」,叠上
|
|
261
262
|
* `isRemoteExecutionEnv` 的接口形鸭子判(`remote-env.js`)把本仓 host lane 一并算作 remote,
|
|
262
|
-
* 于是单机默认部署上 `memoryCapture:"off"` 两条 ingress 结构性不可达(
|
|
263
|
+
* 于是单机默认部署上 `memoryCapture:"off"` 两条 ingress 结构性不可达([ref])。
|
|
263
264
|
* 刻意仍不给 local 一个**内存** twin:内存形会在重启时把一条隐私记录静默丢掉(比文件三腿严格更差)。 */
|
|
264
265
|
sessionCaptureRecords(): SessionCaptureRecordSource | undefined;
|
|
265
266
|
/** Retired-epoch byte hygiene: GC grace-passed orphan `snapshot_blob` rows/objects — the whole-tree snapshot
|
|
@@ -301,7 +302,7 @@ export interface StoreBackend {
|
|
|
301
302
|
/** 1.108 review fix (lens③ HIGH): the notify-JOURNAL twin — third leg of the same axis (a SQL run store +
|
|
302
303
|
* inbox with a replica-LOCAL File journal stranded a dead replica's un-acked notify forever). */
|
|
303
304
|
notifyJournal?(): import("../orchestration/workflow-notify-journal.js").WorkflowNotifyJournalStore;
|
|
304
|
-
/**
|
|
305
|
+
/** [ref] 车CM:workflow 出身 park 的**有界 join** 索引(子会话 id → 它所属的 workflow run)。
|
|
305
306
|
* 与 `workflowRun`/`completionInbox`/`notifyJournal` 同一条轴 —— SQL 后端 = 跨副本双生;`local` 车道
|
|
306
307
|
* 缺席**是一个真答案**:那里的索引家在 run 店同一间屋子里(`LocalWorkflowAgentSessionIndex`,文件账本
|
|
307
308
|
* 或纯内存),不需要经过 backend。契约与单写者纪律的属主 = orchestration/workflow-agent-session-index.ts。 */
|
|
@@ -396,7 +397,7 @@ export interface StoreBackend {
|
|
|
396
397
|
* clock to expose replica clock skew (the write-behind counters bucket on LOCAL floor(now/windowMs); skew
|
|
397
398
|
* splits a fleet window into disjoint buckets = soft-limit leak). OPTIONAL: local backend omits (no fleet). */
|
|
398
399
|
dbNowMs?(): Promise<number>;
|
|
399
|
-
/**
|
|
400
|
+
/** [ref](core 7.41.0 [ref]):**local 后端专有**的 usage-window 账本店 = core `FileStorageBackend` 自己那一只(`usageWindowStore`)——
|
|
400
401
|
* 它的坏读披露座是 backend 构造时那**一只** `onCorruptRead`(core:「`FileStorageBackend` forwards its one sink」),所以坏账本拒(`usage_window.store_corrupt`,
|
|
401
402
|
* 拒绝句不带盘上位置)的同时,路径进本 backend 的 `file_store_corrupt_read` 披露座(逐命中 warn)。修前 `boot/stores.ts` 在同一数据根上自己
|
|
402
403
|
* `new FileUsageWindowStore(root)` 第二只实例、不接座 ⇒ 坏值只拒不披露,运维找不到是哪只文件。SQL 后端省略(它们有自己的 usage-window 双方言店)。 */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
|
-
import {
|
|
2
|
+
import { createCorruptReadSeat, createDurableAbsenceSeat } from "../observability/corrupt-read-seat.js";
|
|
3
3
|
import { createLogger } from "../observability/logger.js";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { AdoptionError, FileStorageBackend } from "@sema-agent/core";
|
|
@@ -272,7 +272,7 @@ class LocalBackend {
|
|
|
272
272
|
this.sendFileLedgerStore = new FileSendFileLedger(this.fileBackend.root);
|
|
273
273
|
this.userInputLedgerStore = new FileUserInputLedgerStore(this.fileBackend.root);
|
|
274
274
|
this.workflowJournalStore = new FileWorkflowJournalStore(this.fileBackend.root, undefined, {
|
|
275
|
-
onCorruptRead:
|
|
275
|
+
onCorruptRead: createCorruptReadSeat(corruptReadWarn, "workflow_journal_refused", "workflow journal = a line the engine cannot read refuses the whole load; the run cannot be listed or resumed until the file is repaired from a kept copy"),
|
|
276
276
|
});
|
|
277
277
|
this.outcomeSinkInst = new FileOutcomeSink(this.fileBackend.root);
|
|
278
278
|
const ownControlDir = fileMemoryControlDirFor(config);
|
|
@@ -324,7 +324,7 @@ class LocalBackend {
|
|
|
324
324
|
checkpointStoreOf() {
|
|
325
325
|
return (this.checkpointStoreInst ??= new LocalCheckpointStore(this.fileBackend.root, {
|
|
326
326
|
getActiveTaskId: (sessionId) => this.runStore.getActiveTaskId(sessionId),
|
|
327
|
-
|
|
327
|
+
readSessionOwner: async (sessionId) => (await this.sessionStore.headOf(sessionId))?.owner,
|
|
328
328
|
}));
|
|
329
329
|
}
|
|
330
330
|
checkpoint() {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Rules for this file:
|
|
10
10
|
* - ZERO dialect dependencies (no mysql2, no pg) — types + pure functions only. The only imports
|
|
11
11
|
* allowed are core contract types and the neutral sql-row-helpers leaf.
|
|
12
|
-
* (
|
|
12
|
+
* ([ref] 车③a:`mapBakeRow`/`mapImageRow`/`BAKE_SELECT_COLS` 搬回了它们**唯一**的消费者
|
|
13
13
|
* `image-bake-store-sql.ts` / `image-index-sql.ts` —— 「两个 SQL 孪生共用」那条理由在孪生合成
|
|
14
14
|
* 单文件双方言之后就不存在了,而一条 SELECT 的**列清单**必须和它的**投影铸点**、**解码点**长在
|
|
15
15
|
* 同一个文件里:否则 JSON 承载列的投影门(它按「这个文件查了哪张表」定列集)对那份清单是瞎的。)
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import type { PeerSessionTempo, TaskResult, TaskStatus } from "@sema-agent/core";
|
|
22
22
|
/**
|
|
23
|
-
* **File 店族的 boot 期拒启基类**(
|
|
23
|
+
* **File 店族的 boot 期拒启基类**([ref];把 `RunStoreStrictHydrateError` 的那条论证升成一条族规)。
|
|
24
24
|
*
|
|
25
25
|
* 🔴 **为什么必须是一个可判别的类型,而且必须是一个共同基类**:`openStoreBackendWithFallback` 对
|
|
26
26
|
* **默认推导**的 local(`DB_BACKEND` 未设 —— 也就是绝大多数单机部署)有一条既有降级臂:mkdir / 只读盘
|
|
@@ -31,7 +31,7 @@ import type { PeerSessionTempo, TaskResult, TaskStatus } from "@sema-agent/core"
|
|
|
31
31
|
* 「DB 不可达,已退回内存」把运维支去查连通性。
|
|
32
32
|
*
|
|
33
33
|
* 此前这条纪律是**逐个 `if instanceof` 手工登记**的(`AdoptionError` / `RunStoreStrictHydrateError`),
|
|
34
|
-
* 于是「下一只会拒启的 File 店」默认是**漏的** ——
|
|
34
|
+
* 于是「下一只会拒启的 File 店」默认是**漏的** —— [ref] 的 ask 账本拒启就这么漏了一次(替补对抗复审
|
|
35
35
|
* F1 [high] 实测:`DB_BACKEND` 未设时坏账本 ⇒ `{backend: undefined, degraded: true}`,不是拒启)。
|
|
36
36
|
* 收法:**一个基类,一条重抛**。新 File 店的拒启只要 `extends StoreBootRefusalError` 就自动落在正确的
|
|
37
37
|
* 一侧;忘了继承是**可见**的(它是一个必须显式选择的父类),而忘了往 if 链里加一行是不可见的。
|
|
@@ -97,7 +97,7 @@ export interface RunCancelContext {
|
|
|
97
97
|
elapsedMs?: number;
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
|
-
* 🔴
|
|
100
|
+
* 🔴 [ref](cli [ref] 第 3 件 / [ref])—— **server 为什么中止了这条 run**:取消终局的机读成因,闭集。
|
|
101
101
|
*
|
|
102
102
|
* 病:非 detach 流断连、`POST /v1/runs/:id/cancel`、断连时有 ask 但 park 宽限用尽 —— 三件事在终局上**逐字同形**
|
|
103
103
|
* (`failed` + `terminal.code:"cancelled"`),壳只能按 `errorMessage` 文案猜。
|
|
@@ -109,7 +109,7 @@ export interface RunCancelContext {
|
|
|
109
109
|
* · `cancel_verb` —— `POST /v1/runs/:id/cancel`:同副本快路、跨副本耐久取消旗的轮询(四条腿的心跳 / 登记追平),
|
|
110
110
|
* 以及 park 中的 run 被它直接终局化(那一形不经 abort,成因照样是这条动词)。
|
|
111
111
|
* **刻意不在表里**(普查过、没有真站点):抢占(`preempt` 是优雅让出,终局是 `paused`,不是取消)、有序关停
|
|
112
|
-
* (
|
|
112
|
+
* ([ref] 只把未决卡转 park,从不中止活 run;进程退出后的行由收割器落「持有者死亡」判决,那不是本仓铸的取消终局)、
|
|
113
113
|
* `interrupt`(引擎的 turn 动词,终局 `completed` + `haltedByUser`)、detach 断连(不中止)。
|
|
114
114
|
*
|
|
115
115
|
* 词表属主 = 本文件(与它所在的 {@link PersistedTaskResult} 同住);**单写者** = `run-cancel-context.ts` 的 `createRunAbort`
|
|
@@ -123,7 +123,7 @@ export type AbortCause = (typeof ABORT_CAUSES)[number];
|
|
|
123
123
|
* 本型是这一族键的**唯一登记处**(`trace/core-keyset-guard.ts` 的辖域线指向这里;那边另有一道编译期钉:
|
|
124
124
|
* core 的 `TaskResult` 哪天长出同名键 ⇒ 当场红 —— 同一个键两个铸者是本型存在要防的那件事)。
|
|
125
125
|
* · `cancelContext`([ref])—— 取消现场快照(分诊材料:多久没动静、起跑多久);
|
|
126
|
-
* · `abortCause`(
|
|
126
|
+
* · `abortCause`([ref])—— 这次取消是谁 / 什么发起的({@link AbortCause})。
|
|
127
127
|
* 两键**同一只铸点**(`mintCancelledResult`)、**同一条在场闸**(「只补空座」:终局就是被那次中止打断的那一条,
|
|
128
128
|
* 才挂;与中止赛跑跑完的终局、引擎自带码的失败一律原样立住、两键都不挂)。差别只在缺席纪律:快照一键都证不出 ⇒ 整只缺席;
|
|
129
129
|
* 成因在铸点那一刻恒已知 ⇒ 取消终局上恒在场。
|
|
@@ -141,14 +141,14 @@ export interface PersistedResultSideKeys {
|
|
|
141
141
|
*/
|
|
142
142
|
export type PersistedTaskResult = TaskResult & PersistedResultSideKeys;
|
|
143
143
|
/**
|
|
144
|
-
* 🔴 run 店「持有它的实例丢了」那一判的**行上落款**(
|
|
144
|
+
* 🔴 run 店「持有它的实例丢了」那一判的**行上落款**([ref] codex r1-F1 提为常量):三只 run 店的 `reapStale` 把心跳过期的 running 行翻成
|
|
145
145
|
* `failed` 并写下这一句。它是 run 店死亡判决留在行上的证据之一(另一只 = {@link RUN_ORPHANED_ERROR})—— 用户输入受理账本的收敛判词
|
|
146
|
-
* (
|
|
146
|
+
* ([ref] L8 起两车道同一只)据 {@link isHolderDeathVerdict} 在 reap **之后**仍能判出「写者死了」—— 7.116.0 起判据是同行的机读码 `run.stalled`({@link RUN_HOLDER_DEATH_CODES}),本句只给人读;三个写者同写句子与码。读时折叠成同一句话的 wire 展示站点
|
|
147
147
|
* (`routes/runs.ts` 的 stale 折叠、`routes/trace-usage.ts` 的 WORKER_DOWN 帧)刻意留字面量:它们由文案冻结门逐字钉着,且不参与任何判据。
|
|
148
148
|
*/
|
|
149
149
|
export declare const RUN_STALLED_ERROR = "run stalled (instance lost?)";
|
|
150
150
|
/**
|
|
151
|
-
* 🔴 File 车道「持有它的进程随重启没了」那一判的行上落款(
|
|
151
|
+
* 🔴 File 车道「持有它的进程随重启没了」那一判的行上落款([ref] L8 提为常量):boot 孤儿回收(`FileRunStore.reclaimOrphanedAtBoot`,
|
|
152
152
|
* 数据根 LOCK 作证前世进程已死 ⇒ 仍 running 的行无条件判孤儿)与运行期 claim 接管的 running 臂(`judgeClaim`,外来 + owner 已死 + 无可续)
|
|
153
153
|
* 都写这一句;接管臂在括号里附上前任持有者的进程指纹(取证用,形 = {@link buildRunOrphanedError})。与 {@link RUN_STALLED_ERROR} 同一种身份:
|
|
154
154
|
* run 店写在行上的**死亡判决**,读者 = {@link isHolderDeathVerdict}(按同行的机读码 `run.orphaned` 判,本句只给人读)。
|
|
@@ -220,7 +220,7 @@ export interface RunRecord {
|
|
|
220
220
|
* MY replica" (consult the in-process inflight/steerable map authoritatively) from "held elsewhere" (fall
|
|
221
221
|
* back to the durable cross-replica flag). null for pre-column rows. */
|
|
222
222
|
instanceId: string | null;
|
|
223
|
-
/** 🔴
|
|
223
|
+
/** 🔴 [ref] P-45 —— 这条 run 上**挂没挂着取消请求**(耐久 `cancel_requested` 列的投影,跨副本)。
|
|
224
224
|
*
|
|
225
225
|
* 语义就是那一列的字节:`POST /v1/runs/:id/cancel` 的 running 臂 CAS 成功即置位,持有副本的心跳拍
|
|
226
226
|
* poll 到它就 abort;`markResuming`(续跑认领)把它清零 —— 一次撞上 suspend 的取消不许在恢复之后
|
|
@@ -325,7 +325,7 @@ export interface InProcessClaimFence {
|
|
|
325
325
|
* 治理判决:门拒绝那条腿在 core 里走 `paused`/`failed`,永远不铸这个词;
|
|
326
326
|
* · `parked` —— 停在门上还能再动(`suspended` 审批/资源门、`needs_review` 评审门)。
|
|
327
327
|
*
|
|
328
|
-
* 🔴 为什么是**一张表**而不是三张 switch(
|
|
328
|
+
* 🔴 为什么是**一张表**而不是三张 switch([ref]③,2026-09-11):`blocked` 这个词此前在本仓有**两个
|
|
329
329
|
* 独立写者**且答案互斥 —— `observability/run-terminal.ts` 判它是「治理判决,不是失败 ⇒ 不打行」,
|
|
330
330
|
* `fleet/fleet-bus.ts` 判它是「非成功终局(agent 放弃)⇒ failed 桶、行离场」。两处各自穷举、各自正确
|
|
331
331
|
* 地编译,而一条 `report_blocked` 的 run 在面板上离场、在引擎日志里一个字都没有。三张手抄的 switch
|
|
@@ -355,20 +355,20 @@ export type UnsuccessfulRunStatus = {
|
|
|
355
355
|
[K in RunRecord["status"]]: (typeof RUN_STATUS_CLASS)[K] extends "unsuccessful" ? K : never;
|
|
356
356
|
}[RunRecord["status"]];
|
|
357
357
|
/** 表判为「park」(停在门上)的词 —— **从表派生**,不是手抄的第二份清单。今天 = `"suspended" | "needs_review"`。
|
|
358
|
-
* 消费点(
|
|
358
|
+
* 消费点([ref]:同步提交 200 体的 poll 回执 `status`,`http/sync-submit-body.ts`)拿它当型;表翻面 ⇒ 那里当场红。 */
|
|
359
359
|
export type ParkedRunStatus = {
|
|
360
360
|
[K in RunRecord["status"]]: (typeof RUN_STATUS_CLASS)[K] extends "parked" ? K : never;
|
|
361
361
|
}[RunRecord["status"]];
|
|
362
362
|
/**
|
|
363
363
|
* 一个状态词的类;**表里没有的词 ⇒ `undefined`**。
|
|
364
364
|
*
|
|
365
|
-
* 🔴 形参是 `string` 而不是 `RunRecord["status"]`(
|
|
365
|
+
* 🔴 形参是 `string` 而不是 `RunRecord["status"]`([ref]):本函数的**全部工作**就是「这个词在不在表里」,
|
|
366
366
|
* 把入参收成闭集等于在签名上宣称「传进来的一定是表内词」,而下一行的 `undefined` 臂正是为了不是的那些 ——
|
|
367
367
|
* 签名与实现自相矛盾时,消费点只能靠 `as RunRecord["status"]` 硬转把窄读口(`{ status: string }`,
|
|
368
368
|
* 三形 store 共同面)喂进来,而那正是本文件头注点名的 `rowToRun` 裸 cast 的同一条病。闭集词照样能传
|
|
369
369
|
* (联合 ⊂ string),编译期的执法点在上面那张表的双向钉,不在这里。
|
|
370
370
|
*
|
|
371
|
-
* 导出面(
|
|
371
|
+
* 导出面([ref]):`plugins/e2b-orphan-reclaim.ts` 的三臂判决(还能再动 / 终局 / 读不懂)需要的正是
|
|
372
372
|
* 「类 + unknown」这一对,而不是三条 boolean 谓词各问一遍 —— 它此前因此自带了第二份词表。
|
|
373
373
|
*
|
|
374
374
|
* 🔴 查的是 **null 原型**的那只表,不是 `RUN_STATUS_CLASS` 本身(codex 对抗复审 r1 [high],亲验后修):
|
|
@@ -395,7 +395,7 @@ export declare function runStatusClassOf(status: string): RunStatusClass | undef
|
|
|
395
395
|
*/
|
|
396
396
|
export declare function isTerminalRunStatus(status: RunRecord["status"]): boolean;
|
|
397
397
|
/**
|
|
398
|
-
* 「这一行的终局是**非成功**的吗」(
|
|
398
|
+
* 「这一行的终局是**非成功**的吗」([ref]③ 的共享判据)——`failed` 与 `blocked` 两词。
|
|
399
399
|
*
|
|
400
400
|
* 🔴 它回答的问题与 {@link isTerminalRunStatus} **不同**:后者只问「还会不会再动」,本判据问「这次任务
|
|
401
401
|
* 到底成没成」。凡是「这条 run 该不该在失败面上出声/离场」的判断都读这一条,不许再手抄
|
|
@@ -434,7 +434,7 @@ export declare function isParkedRunStatus(status: RunRecord["status"]): boolean;
|
|
|
434
434
|
* 它不是「我知道它闲着」,所以不许铸出 `idle` 这个断言;
|
|
435
435
|
* · 读不懂的词(滚动升级里新副本写入的新状态词经裸 cast 读到本进程)同判 —— 与
|
|
436
436
|
* {@link isTerminalRunStatus} 族的保守方向一致。
|
|
437
|
-
* · **缺席怎么渲染是 core 的辖域,本仓一个字都不复述**(
|
|
437
|
+
* · **缺席怎么渲染是 core 的辖域,本仓一个字都不复述**([ref]-JU:此处原写着「core 对缺席渲染成 `idle`」
|
|
438
438
|
* 并抄了当时 `list-agents-tool.js` 的旧三元 —— core 7.24.0 [ref] 把那一臂改成了一张 own-key 表 +
|
|
439
439
|
* `unknown` 兜底,于是那句复述当天就成了假话,而它在本仓被抄了六处)。本表只负责**铸不铸键**;
|
|
440
440
|
* 渲染词由**跑真 core 的黑盒**钉住(`test/peer-lane-e2e.test.ts` 的 G1 格),core 哪天再改那张表,
|
|
@@ -453,7 +453,7 @@ export declare const SESSION_TEMPO_BY_RUN_CLASS: {
|
|
|
453
453
|
* 返回词缺席 ⇒ 调用方**不铸键**(不是铸 `idle`),理由逐字见上表头注。 */
|
|
454
454
|
export declare function sessionTempoOfRunStatus(lastStatus: string): PeerSessionTempo | undefined;
|
|
455
455
|
/**
|
|
456
|
-
* 「**证得出**这条 run 活在别的副本上」——「他副本」那一句话的**唯一判据**(
|
|
456
|
+
* 「**证得出**这条 run 活在别的副本上」——「他副本」那一句话的**唯一判据**([ref] 收编;[ref] 迁居)。
|
|
457
457
|
*
|
|
458
458
|
* 成案:这个合取式此前在四处**逐字手抄**(`http/routes/runs.ts` 的 steer 臂与 interrupt 臂、同文件
|
|
459
459
|
* `sendHandleMiss`、`http/routes/run-memory-capture.ts`),`POST /v1/sessions/:id/mcp/reconnect` 是第五处、`fleet/fleet-reconciler.ts` 是第六处 ——
|
|
@@ -466,7 +466,7 @@ export declare function sessionTempoOfRunStatus(lastStatus: string): PeerSession
|
|
|
466
466
|
* `sendHandleMiss` 只对 `running` 行说这句话,而 steer 族在 park/终态两臂之后才走到这里 —— 各调用点
|
|
467
467
|
* 的前置臂不同族,合进来会让某一处悄悄改判。
|
|
468
468
|
*
|
|
469
|
-
* 🔴 **为什么住在这里而不是 `http/route-ctx.ts`**(
|
|
469
|
+
* 🔴 **为什么住在这里而不是 `http/route-ctx.ts`**([ref]):`src/fleet/fleet-reconciler.ts` 是第六个手抄点,
|
|
470
470
|
* 而 `src/fleet/` 今天对 `src/http/` **零依赖**(边向恒是 http → fleet)。把消费方拉去 http 取一只纯谓词
|
|
471
471
|
* 会凭空造一条反向装载边;而本文件正是 {@link RunRecord} 与它的兄弟谓词({@link isTerminalRunStatus} /
|
|
472
472
|
* {@link isParkedRunStatus})的所在 —— 「关于 run 行的判词」本来就该在行的属主这里,http 与 fleet 都已经
|
|
@@ -492,7 +492,7 @@ export interface SessionSummary {
|
|
|
492
492
|
* hop (`GET /v1/runs/:lastRunId/events`) when resuming a picked session, instead of a second lookup. */
|
|
493
493
|
lastRunId: string | null;
|
|
494
494
|
/** [ref]([ref]/[ref]):latest run 的 engine runId(`TaskResult.runId`,latest.result JSON 提取的
|
|
495
|
-
* 零迁移路线 —— result 在终局与 park 时写、认领续跑即清空(
|
|
495
|
+
* 零迁移路线 —— result 在终局与 park 时写、认领续跑即清空([ref])⇒ 在跑 run 键诚实缺席);OMIT-when-absent,恒不铸 null。轴辨析与
|
|
496
496
|
* wire 半场见 `security.ts SessionListItem.lastTaskRunId`(同名同义)。 */
|
|
497
497
|
lastTaskRunId?: string;
|
|
498
498
|
/** The session's title: the user's (`patchSessionMeta`, unconditional; `null` clears it back to automatic) or the auto-titler's
|
|
@@ -504,7 +504,7 @@ export interface SessionSummary {
|
|
|
504
504
|
pinned: boolean;
|
|
505
505
|
}
|
|
506
506
|
/**
|
|
507
|
-
*
|
|
507
|
+
* [ref] —— 会话**枚举面**读 run 账里「每会话的 run 投影」的窄读面:`runCount` / `lastStatus` / `lastRunId` / `lastTaskRunId` 四位,
|
|
508
508
|
* 同一次读、同一条「最新一条」的口径。
|
|
509
509
|
*
|
|
510
510
|
* 为什么是 run 店自己的 `listSessions`、不另造一只读口:这四位在 SQL 双生里就是 `task_run` 的 `rn=1` JOIN(计数、最新一条的状态与 task_id、
|
|
@@ -521,7 +521,7 @@ export interface SessionRunRollupSource {
|
|
|
521
521
|
}): Promise<ReadonlyArray<Pick<SessionSummary, "sessionId" | "runCount" | "lastStatus" | "lastRunId" | "lastTaskRunId">>>;
|
|
522
522
|
}
|
|
523
523
|
/**
|
|
524
|
-
*
|
|
524
|
+
* [ref] —— 「这个会话**最近一条腿**是哪一条 run」的窄读面(`latestRunForSession` 的回值)。
|
|
525
525
|
*
|
|
526
526
|
* 刻意**不是** {@link RunRecord}:那一形携 `result` 整只 blob,而本读面的三个消费点(run 身份 / 属主门 /
|
|
527
527
|
* 排序口径的自证)一个都用不到它 —— 与 `listSessions` 只提标量 `lastTaskRunId` 而不拉 `result` 是同一条
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { isConnectionFaultError } from "./sql-errors.js";
|
|
2
|
+
import { StoreCorruptError } from "./sql-json-column.js";
|
|
3
|
+
export function storeFaultClassOf(err) {
|
|
4
|
+
if (err instanceof StoreCorruptError)
|
|
5
|
+
return "corrupt";
|
|
6
|
+
return isConnectionFaultError(err) ? "connection" : "unclassified";
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=store-fault.js.map
|
|
@@ -31,7 +31,7 @@ import { type IndexSpec } from "./ensure-index.js";
|
|
|
31
31
|
/**
|
|
32
32
|
* 一条附件 meta 的**形属主**(整仓唯一那份键集)。
|
|
33
33
|
*
|
|
34
|
-
* 🔴 为什么是一只 schema 而不只是一个 interface(
|
|
34
|
+
* 🔴 为什么是一只 schema 而不只是一个 interface([ref] 车③b):SQL 车道把这些字段拆成**标量列**,
|
|
35
35
|
* 形由 DDL 管;local 车道把整条记录**序列化成一个 JSON 档**(`attachments/<id>.json`),于是它需要一个
|
|
36
36
|
* 运行期的形判据 —— 而那个判据必须与这里的键集是**同一份**(第二份键集分叉的那天 = 「写得进、读不出」)。
|
|
37
37
|
* 所以类型从 schema 推导({@link TaskAttachmentRecord}),两者按构造不可能漂。
|
|
@@ -126,7 +126,7 @@ export declare function materializeAttachmentsInto(env: {
|
|
|
126
126
|
}>;
|
|
127
127
|
}, store: TaskAttachmentStore, sessionId: string): Promise<number>;
|
|
128
128
|
export declare function ensureTiDBTaskAttachmentSchema(pool: Pool): Promise<void>;
|
|
129
|
-
/**
|
|
129
|
+
/** [ref]:本 store 的索引**声明**(两方言共用一份)。PG 侧由下面的 `ensurePgTaskAttachmentSchema` 应用,MySQL 侧由 `tidb-pool.ts` 的中央 `ensureSchema` 应用(那里内联 `KEY` 已在 `CREATE TABLE` 里 ⇒ 新建库探到即零 DDL,存量库缺谁补谁)。加索引以外的 schema 变更仍归运维,见 `plugins/ensure-index.ts` 头注。 */
|
|
130
130
|
export declare const TASK_ATTACHMENT_INDEXES: readonly IndexSpec[];
|
|
131
131
|
export declare function ensurePgTaskAttachmentSchema(q: PgQueryFn): Promise<void>;
|
|
132
132
|
/** bytes → 4 MiB 块序列(共享切块器,两方言 + 完整性校验共用)。 */
|
|
@@ -27,7 +27,7 @@ export declare const TASK_LIST_ITEM_TABLE = "task_list_item";
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function taskListKeyFor(sessionId: string): string;
|
|
29
29
|
/**
|
|
30
|
-
* `task_list_item.item_json` 的**形读者**(
|
|
30
|
+
* `task_list_item.item_json` 的**形读者**([ref])。
|
|
31
31
|
*
|
|
32
32
|
* 🔴 判据刻意只到「一只 JSON 对象 + 一把串 id」为止,**不复刻 core 的 `TaskListItem` 键表**:那张表的
|
|
33
33
|
* 属主在 core(`tools/task-list.d.ts`),而 core 今天没有导出验证器 —— 在这里手写一份等价 schema 就是
|
|
@@ -63,13 +63,13 @@ export declare const ENSURE_SCHEMA_LOCK = "sema_ensure_schema";
|
|
|
63
63
|
* lock row — which both exhausts TiDB's "pessimistic lock retry limit" (surfacing as a thrown error) AND starves the
|
|
64
64
|
* app's OWN `SELECT … FOR UPDATE` paths (image-bake admission/lease) of pessimistic-lock budget. So we acquire
|
|
65
65
|
* NON-BLOCKING (GET_LOCK(name, 0) returns 0 immediately if held) and POLL with jittered backoff: one holder, the
|
|
66
|
-
* rest sleeping (not blocked in-DB). Polls until acquired (7.83.0: never degrades to unserialized — the
|
|
66
|
+
* rest sleeping (not blocked in-DB). Polls until acquired (7.83.0: never degrades to unserialized — the [ref]
|
|
67
67
|
* `ADD INDEX` leg is not race-safe); a connection whose probe keeps throwing surfaces as a boot failure. */
|
|
68
68
|
export declare function acquireEnsureSchemaLock(conn: PoolConnection, tag?: string): Promise<void>;
|
|
69
69
|
/** Release {@link ENSURE_SCHEMA_LOCK} on `conn` (best-effort — the lock also auto-frees when the connection closes). */
|
|
70
70
|
export declare function releaseEnsureSchemaLock(conn: PoolConnection, tag?: string): Promise<void>;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* [ref]:`SCHEMA_STATEMENTS` 建的那批表**在存量库上可能缺的索引**(声明与 PG 侧逐条共用同一份 —— 见
|
|
73
73
|
* `plugins/ensure-index.ts` 头注与 `plugins/schema-indexes.ts`)。
|
|
74
74
|
*
|
|
75
75
|
* 组合口径与 `SCHEMA_STATEMENTS` **一一对应**:凡是它建的表,索引声明就进这个数组;它不建的表
|
|
@@ -86,7 +86,7 @@ export const SCHEMA_STATEMENTS = [
|
|
|
86
86
|
placed_at DATETIME(3) NULL,
|
|
87
87
|
-- S-790 / S-506(design/330 §2):会话化身 —— 同一个会话 id 上**这一位住客**的不透明令牌。铸点只在新建行(register /
|
|
88
88
|
-- 无 id 创建 / fork / 导入新行),删除随行消失,同 id 重登记铸新的;'' = 没铸过,读口响亮拒。列定义的唯一属主 =
|
|
89
|
-
-- src/session-incarnation.ts 的 SESSION_META_INCARNATION_COLUMN(
|
|
89
|
+
-- src/session-incarnation.ts 的 SESSION_META_INCARNATION_COLUMN(存量库缺这一列 ⇒ 起服列册对账拒启,拒句里的 ALTER 由本建表语句生成)。
|
|
90
90
|
-- 不上 wire、不进模型上下文、日志只打前 8 位。
|
|
91
91
|
${SESSION_META_INCARNATION_COLUMN.tidb},
|
|
92
92
|
PRIMARY KEY (session_id),
|
|
@@ -286,6 +286,13 @@ export const SCHEMA_STATEMENTS = [
|
|
|
286
286
|
-- NULL (a PRE-MIGRATION row, or a gate carrying no kind) ⇒ the LEGACY UNIFORM expire() path: the deny split
|
|
287
287
|
-- is NEW-ROWS-ONLY. See tidb-checkpoint-store.ts reapExpired / listExpiredApprovalGates.
|
|
288
288
|
gate_kind VARCHAR(32) NULL,
|
|
289
|
+
-- approval_card(core 7.55.0 #1468 P1 阶段二):门上的卡词**照存**(core checkpointIndexFacts(cp).approvalCard:TOOL_APPROVAL_CARDS 的词,或本引擎不认的串 ——
|
|
290
|
+
-- 留着,更晚的引擎读得对);非审批门 / 无卡 / 非串 = NULL。写口与一次性迁移 M29 的存量回填同一只派生(plugins/checkpoint-index-columns.ts)。
|
|
291
|
+
-- 读者:到期 facet 的生成谓词(由 core CARD_FACET_OVERRIDES + PAUSE_REGISTRY 生成;**不存 facet 本身** —— 存一份会在 core 改表那天陈旧)、运维队列行的卡。
|
|
292
|
+
-- 本仓不发 ALTER:存量库缺这一列 ⇒ 起服列册对账拒启并给 ADD COLUMN 句(持久数据:表里是在飞的停驻,不删表重建)。
|
|
293
|
+
-- 列型 TEXT 而不是定长 VARCHAR:引擎照存集外词,长度不由本仓定(191 字的集外词照存)。TEXT 自己的容量是 65,535 **字节**(plugins/checkpoint-index-columns.ts 的
|
|
294
|
+
-- APPROVAL_CARD_COLUMN_MAX_BYTES):引擎铸的卡词是闭集短词,超出只会是手改 / 外来写者的存量行 —— M29 回填对这样的行计数 + 点名跳过,不写、不挡起服。
|
|
295
|
+
approval_card TEXT NULL,
|
|
289
296
|
-- bound_input_hash (design/80 D-1): the server-minted opaque boundInputHash, stamped at put() from
|
|
290
297
|
-- pendingAction.boundInputHash, surfaced via listPending so the operator/portal can ECHO it on /decide (the
|
|
291
298
|
-- D-1 TOCTOU binding guard is UNREACHABLE by the portal without it — it can then only do the unbound legacy
|
|
@@ -605,8 +612,8 @@ export const SCHEMA_STATEMENTS = [
|
|
|
605
612
|
-- tidb-workflow-run-store.ts projects kind only when non-null and workflow-completion-inbox.ts routes
|
|
606
613
|
-- kind === "task_notification" vs everything-else. Do NOT "tidy" this into NOT NULL DEFAULT.
|
|
607
614
|
kind VARCHAR(24) NULL,
|
|
608
|
-
-- payload: bounded + redacted JSON extras
|
|
609
|
-
-- NULL
|
|
615
|
+
-- payload: bounded + redacted JSON extras of the entry's kind. task_notification: task_type / result / …;
|
|
616
|
+
-- workflow_complete: at most {"completionId": …} (the engine's own correlation id, verbatim; NULL when the engine minted none).
|
|
610
617
|
payload TEXT NULL,
|
|
611
618
|
PRIMARY KEY (session_id, run_id),
|
|
612
619
|
UNIQUE KEY uq_wfinbox_seq (seq),
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* on acquire (core's F1).
|
|
9
9
|
*
|
|
10
10
|
* Persistence only. **Tenant authorization (who may wake which session) lives in the service layer**
|
|
11
|
-
* (`src/security.ts`), which uses `
|
|
11
|
+
* (`src/security.ts`), which uses `headOf` (the one by-id read of a row) / `register` below. The store does not infer identity.
|
|
12
12
|
*/
|
|
13
|
-
import { type AcquiredSession, type PlacedSessionRow, type SessionPlacementRecord, type SessionStore, type SessionTreeEntry } from "@sema-agent/core";
|
|
13
|
+
import { type AcquiredSession, type PlacedSessionRow, type SessionHead, type SessionPlacementRecord, type SessionStore, type SessionTreeEntry } from "@sema-agent/core";
|
|
14
14
|
import type { Pool } from "mysql2/promise";
|
|
15
15
|
import { type InstructionSourceBaseline } from "../instruction-source-notice.js";
|
|
16
16
|
import { type SessionFace } from "../session-incarnation.js";
|
|
@@ -45,21 +45,21 @@ export declare class TiDBSessionStore implements SessionStore {
|
|
|
45
45
|
register(sessionId: string, owner: string | null): Promise<void>;
|
|
46
46
|
/**
|
|
47
47
|
* acquire 的建行(唯一一处):普通会话 ⇒ 无主(按 id 首建的既有读法);placed 会话 ⇒ 属主按委派继承律在**这一笔**里写入
|
|
48
|
-
* (
|
|
48
|
+
* ([ref]:根会话的属主,根行不在取父,都不在 ⇒ 孤行哨兵 + warn;属主 = 判断时见证到的,读来源 → 判 → INSERT —— 读法与顺序只住在
|
|
49
49
|
* `delegated-session-owner.ts` 的 `createPlacedSessionRow`,本店只交既有读写口,PG 孪生同调)。
|
|
50
50
|
*/
|
|
51
51
|
private createOnAcquire;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* [ref] 委派继承律的**认领口**:这只会话的那一位住客(判断时读到的化身)仍是无主的 placed 行 ⇒ 写 `owner`,返回是否写成
|
|
54
54
|
* (句 = `CLAIM_OWNERLESS_PLACED_SQL`,只 CAS 子行自己,与停驻挂点 / M23 同一只;规则在 `delegated-session-owner.ts`)。普通会话行不在射程(placed 判别位)。
|
|
55
55
|
*/
|
|
56
56
|
claimOwnerless(sessionId: string, incarnation: string, owner: string): Promise<boolean>;
|
|
57
|
-
/** 若干来源行的会话面(属主 + 化身)一次读回(委派继承律的来源读;本店没有的 id
|
|
57
|
+
/** 若干来源行的会话面(属主 + 化身)一次读回(委派继承律的来源读;本店没有的 id 不在表里;活住客的投影 `sessionFaceFromRow`,空化身 ⇒ 响亮拒)。 */
|
|
58
58
|
private sourceFaces;
|
|
59
59
|
/** The one session_meta INSERT. Existing owner is never overwritten.
|
|
60
60
|
* [ref]:`placement` 在场时与行同一条 INSERT 落六列;ON DUPLICATE 臂是 no-op ⇒ 已存在的行的元组
|
|
61
61
|
* **永不被重写**(first-write 不可变,义务 5 的写侧半场)。
|
|
62
|
-
*
|
|
62
|
+
* [ref]:化身与属主同一条 first-write 律 —— 新行铸一只(`mintSessionIncarnation`),已存在的行 no-op 臂一个字节不动。 */
|
|
63
63
|
private insertMeta;
|
|
64
64
|
/**
|
|
65
65
|
* [ref] 义务 6 的廉价探针 —— 一行 PK SELECT:`undefined` = 普通会话或无此行。
|
|
@@ -78,25 +78,15 @@ export declare class TiDBSessionStore implements SessionStore {
|
|
|
78
78
|
olderThanMs?: number;
|
|
79
79
|
scope?: string;
|
|
80
80
|
}): Promise<PlacedSessionRow[]>;
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
/**
|
|
82
|
+
* core `SessionStore.headOf` —— 这一行的属主、住客、叶子,**一条 PK SELECT、一行**(两次独立读在删除 / 重登记的缝里能拼出混世代组合;
|
|
83
|
+
* 单行单读天然一致)。`undefined` = 无此会话。本店按 id 问这一行的**唯一**读口:授权口的属主、parked 两读的住客、SSE 探针的叶子、
|
|
84
|
+
* resume-at 的叶子都是它的投影(此前的 `ownerOf` / `sessionFaceOf` / `incarnationOf` / `getLeafId` / `getHead` 五只读全部并进来;规则见
|
|
85
|
+
* `session-incarnation.ts` 头注)。化身那一格经 `headFromRow` 的 `absent` 读法(空 ⇒ 住客未知);要一位活住客的读者经 `sessionFaceOfHead` 响亮拒空。
|
|
86
|
+
* 只读、不取会话、不上锁、绕过暖缓存 —— 跑到一半读也安全(写的安全是追加时的 CAS)。
|
|
87
|
+
*/
|
|
88
|
+
headOf(sessionId: string): Promise<SessionHead | undefined>;
|
|
88
89
|
touch(sessionId: string): Promise<void>;
|
|
89
|
-
/** E18 — the session's current leaf `SessionTreeEntry.id` (`session_meta.leaf_id`, set transactionally on every
|
|
90
|
-
* persist). A single SELECT, NO acquire/lock/CAS — safe to call mid-run (write-safety is the append-time CAS, not
|
|
91
|
-
* an acquire lease) and cache-bypassing (the resume-at turn-capture reads it without touching the warm session).
|
|
92
|
-
* Returns the leaf id, or null when the session has none / no such session. */
|
|
93
|
-
getLeafId(sessionId: string): Promise<string | null>;
|
|
94
|
-
/** [ref] 六轮复审:owner+leafId **单行原子快照**(SSE watch 探针的租户围栏读)——两独立 SELECT 在
|
|
95
|
-
* delete/reclaim 缝里可拼出「旧 owner+新 leaf」混世代组合;单 SELECT 单行=天然一致。undefined=无此会话。 */
|
|
96
|
-
getHead(sessionId: string): Promise<{
|
|
97
|
-
owner: string | null;
|
|
98
|
-
leafId: string | null;
|
|
99
|
-
} | undefined>;
|
|
100
90
|
/**
|
|
101
91
|
* Durable history is retained; just drop any in-flight cache entry.
|
|
102
92
|
*
|
|
@@ -164,12 +154,12 @@ export declare class TiDBSessionStore implements SessionStore {
|
|
|
164
154
|
* writer order: `src/session-row.ts`). Returns whether this call set it. */
|
|
165
155
|
setTitleIfNull(sessionId: string, title: string): Promise<boolean>;
|
|
166
156
|
/**
|
|
167
|
-
*
|
|
157
|
+
* [ref] —— 换源通告的基线读(一行 PK SELECT;列的三态读法见 `tidb-pool.ts` 的列注)。行不在 ⇒ 读作「没记过」
|
|
168
158
|
* (loader 跑在 acquire 之后,行恒在;不在 = 被带外删了,没有下一 run 可比)。
|
|
169
159
|
*/
|
|
170
160
|
readInstructionSource(sessionId: string): Promise<InstructionSourceBaseline>;
|
|
171
161
|
/**
|
|
172
|
-
*
|
|
162
|
+
* [ref] —— CAS 覆写基线(期望值 = 调用方读到的那一份;不符 ⇒ 0 行、不抛 —— 契约见 `InstructionSourceStore`)。
|
|
173
163
|
* **不**碰 `updated_at`(那是会话活动时刻,留存腿按它判龄;记基线不是一次会话活动)。
|
|
174
164
|
* 两条基线查询都带每查询超时(`BASELINE_IO_DEADLINE_MS`,mysql2 的 `{sql, timeout}` 形):被行锁卡住的写由查询自己
|
|
175
165
|
* 在期限内拒。⚠️ mysql2 的超时是客户端侧的 —— 拒之后那条连接仍被挂着的命令占到服务端结束(S-9 同形,如实披露)。
|
|
@@ -5,13 +5,14 @@ import { jsonColumnText } from "./sql-json-column.js";
|
|
|
5
5
|
import { escapeLike } from "./sql-escape.js";
|
|
6
6
|
import { BASELINE_IO_DEADLINE_MS, decodeInstructionSource, encodeInstructionSource } from "../instruction-source-notice.js";
|
|
7
7
|
import { MANAGED_RETENTION } from "./retention-store-sql.js";
|
|
8
|
-
import { carriedIncarnation, mintSessionIncarnation, sessionFaceFromRow } from "../session-incarnation.js";
|
|
8
|
+
import { carriedIncarnation, headFromRow, mintSessionIncarnation, sessionFaceFromRow } from "../session-incarnation.js";
|
|
9
9
|
import { contentForkRelation, fastForwardSharedContentDiverged } from "../session-sync-content.js";
|
|
10
10
|
import { CLAIM_OWNERLESS_PLACED_SQL, claimOwnerlessParams, createPlacedSessionRow } from "../delegated-session-owner.js";
|
|
11
11
|
import { createLogger } from "../observability/logger.js";
|
|
12
12
|
import { placementCapabilityOf, LIST_PLACED_BATCH, PLACEMENT_SELECT_COLUMNS, placedRowFromRow, placementFromRow, placementInsertValues, SQL_SESSION_PLACEMENTS, } from "./session-placement.js";
|
|
13
13
|
import { classifySyncRelationshipByIds, SyncConflictError, StagedCommitOwnerChangedError, stagingIdFor, STAGING_ID_MARKER, STAGING_GC_GRACE_MS, } from "../session-sync-kernel.js";
|
|
14
14
|
import { assertFirstOwnerWritable, forkOwnerOf } from "./session-ownership.js";
|
|
15
|
+
import { forkCopyOf, forkPointOf } from "./session-fork.js";
|
|
15
16
|
export class TiDBSessionStore {
|
|
16
17
|
pool;
|
|
17
18
|
retention = MANAGED_RETENTION;
|
|
@@ -58,7 +59,7 @@ export class TiDBSessionStore {
|
|
|
58
59
|
}
|
|
59
60
|
async register(sessionId, owner) {
|
|
60
61
|
if (typeof owner !== "string" && owner !== null) {
|
|
61
|
-
if ((await this.
|
|
62
|
+
if ((await this.headOf(sessionId)) !== undefined)
|
|
62
63
|
return;
|
|
63
64
|
assertFirstOwnerWritable(sessionId, owner);
|
|
64
65
|
}
|
|
@@ -70,7 +71,7 @@ export class TiDBSessionStore {
|
|
|
70
71
|
await createPlacedSessionRow(sessionId, placement, {
|
|
71
72
|
readFaces: (ids) => this.sourceFaces(ids),
|
|
72
73
|
insert: (owner) => this.insertMeta(sessionId, owner, placement),
|
|
73
|
-
readOwner: () => this.
|
|
74
|
+
readOwner: async () => (await this.headOf(sessionId))?.owner,
|
|
74
75
|
}, this.log);
|
|
75
76
|
}
|
|
76
77
|
async claimOwnerless(sessionId, incarnation, owner) {
|
|
@@ -107,20 +108,12 @@ export class TiDBSessionStore {
|
|
|
107
108
|
const [rows] = await this.pool.query(sql, params);
|
|
108
109
|
return rows.map((r) => placedRowFromRow(String(r.session_id), r, r.updated_at instanceof Date ? r.updated_at.getTime() : undefined));
|
|
109
110
|
}
|
|
110
|
-
async
|
|
111
|
-
const [rows] = await this.pool.query("SELECT owner FROM session_meta WHERE session_id = ?", [sessionId]);
|
|
111
|
+
async headOf(sessionId) {
|
|
112
|
+
const [rows] = await this.pool.query("SELECT owner, incarnation, leaf_id FROM session_meta WHERE session_id = ?", [sessionId]);
|
|
112
113
|
if (rows.length === 0)
|
|
113
114
|
return undefined;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
async sessionFaceOf(sessionId) {
|
|
117
|
-
const [rows] = await this.pool.query("SELECT owner, incarnation FROM session_meta WHERE session_id = ?", [sessionId]);
|
|
118
|
-
if (rows.length === 0)
|
|
119
|
-
return undefined;
|
|
120
|
-
return sessionFaceFromRow(sessionId, rows[0].owner ?? null, rows[0].incarnation);
|
|
121
|
-
}
|
|
122
|
-
async incarnationOf(sessionId) {
|
|
123
|
-
return (await this.sessionFaceOf(sessionId))?.incarnation;
|
|
115
|
+
const r = rows[0];
|
|
116
|
+
return headFromRow(sessionId, r.owner ?? null, r.incarnation, r.leaf_id ?? null);
|
|
124
117
|
}
|
|
125
118
|
async touch(sessionId) {
|
|
126
119
|
await this.pool.query("UPDATE session_meta SET updated_at = ? WHERE session_id = ?", [
|
|
@@ -128,16 +121,6 @@ export class TiDBSessionStore {
|
|
|
128
121
|
sessionId,
|
|
129
122
|
]);
|
|
130
123
|
}
|
|
131
|
-
async getLeafId(sessionId) {
|
|
132
|
-
const [rows] = await this.pool.query("SELECT leaf_id FROM session_meta WHERE session_id = ?", [sessionId]);
|
|
133
|
-
return rows[0] ? (rows[0].leaf_id ?? null) : null;
|
|
134
|
-
}
|
|
135
|
-
async getHead(sessionId) {
|
|
136
|
-
const [rows] = await this.pool.query("SELECT owner, leaf_id FROM session_meta WHERE session_id = ?", [sessionId]);
|
|
137
|
-
if (rows.length === 0)
|
|
138
|
-
return undefined;
|
|
139
|
-
return { owner: rows[0].owner ?? null, leafId: rows[0].leaf_id ?? null };
|
|
140
|
-
}
|
|
141
124
|
async release(sessionId) {
|
|
142
125
|
this.pending.delete(sessionId);
|
|
143
126
|
const placed = await this.placementOf(sessionId);
|
|
@@ -270,7 +253,12 @@ export class TiDBSessionStore {
|
|
|
270
253
|
return null;
|
|
271
254
|
const leafId = metaRows[0].leaf_id ?? null;
|
|
272
255
|
const forkOwner = forkOwnerOf(owner, metaRows[0].owner ?? null) ?? null;
|
|
273
|
-
const
|
|
256
|
+
const storage = await TiDBSessionStorage.wake(this.pool, sourceId);
|
|
257
|
+
if (storage === null)
|
|
258
|
+
return null;
|
|
259
|
+
const point = await forkPointOf(storage);
|
|
260
|
+
const [allRows] = await this.pool.query(`SELECT entry_id, parent_id, type, ${jsonColumnText("tidb", "payload")}, ts FROM session_event WHERE session_id = ? ORDER BY seq ASC`, [sourceId]);
|
|
261
|
+
const { rows: eventRows, leafId: forkLeafId } = forkCopyOf(allRows, leafId, point);
|
|
274
262
|
const newId = uuidv7();
|
|
275
263
|
const now = new Date();
|
|
276
264
|
const conn = await this.pool.getConnection();
|
|
@@ -281,7 +269,7 @@ export class TiDBSessionStore {
|
|
|
281
269
|
const payload = String(r.payload);
|
|
282
270
|
await conn.query("INSERT INTO session_event (session_id, seq, entry_id, parent_id, type, payload, ts) VALUES (?,?,?,?,?,?,?)", [newId, seq, r.entry_id, r.parent_id ?? null, r.type, payload, r.ts]);
|
|
283
271
|
}
|
|
284
|
-
await conn.query("INSERT INTO session_meta (session_id, owner, created_at, updated_at, leaf_id, leaf_seq, incarnation) VALUES (?,?,?,?,?,?,?)", [newId, forkOwner, now, now,
|
|
272
|
+
await conn.query("INSERT INTO session_meta (session_id, owner, created_at, updated_at, leaf_id, leaf_seq, incarnation) VALUES (?,?,?,?,?,?,?)", [newId, forkOwner, now, now, forkLeafId, eventRows.length, mintSessionIncarnation()]);
|
|
285
273
|
await conn.commit();
|
|
286
274
|
return newId;
|
|
287
275
|
}
|