@sema-agent/server 7.133.0 → 7.135.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 +221 -0
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/USAGE.md +222 -36
- package/deploy/sema-up/README.md +16 -0
- package/deploy/sema-up/chart/Chart.yaml +1 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +15 -0
- package/deploy/sema-up/chart/templates/_helpers.tpl +129 -0
- package/deploy/sema-up/chart/templates/sealed-key.yaml +24 -0
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +14 -0
- package/deploy/sema-up/chart/templates/server.yaml +14 -0
- package/deploy/sema-up/chart/values-full-single.yaml +5 -1
- package/deploy/sema-up/chart/values.yaml +34 -0
- package/dist/adoption/plan.d.ts +1 -1
- package/dist/approval-ask-audit-store.d.ts +25 -25
- package/dist/approval-ask-machine.d.ts +2 -2
- package/dist/approval-card.d.ts +66 -154
- package/dist/approval-card.js +33 -52
- package/dist/approval-content-kind.d.ts +26 -6
- package/dist/approval-content-kind.js +23 -3
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval-gate-currency.d.ts +91 -0
- package/dist/approval-gate-currency.js +120 -0
- 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 +14 -8
- package/dist/approval.js +35 -16
- package/dist/auth-bridge.d.ts +1 -1
- 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/coordinators.d.ts +7 -2
- package/dist/boot/coordinators.js +8 -5
- 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 +2 -0
- package/dist/boot/leader.js +2 -1
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/memory-consolidation.d.ts +15 -15
- package/dist/boot/parked-revive-gate.d.ts +3 -3
- package/dist/boot/parked-revive-gate.js +3 -2
- package/dist/boot/read-deny-anchor-audit.js +2 -2
- package/dist/boot/reapers.d.ts +4 -4
- package/dist/boot/resolve-spec.d.ts +1 -1
- package/dist/boot/resolve-spec.js +28 -24
- package/dist/boot/runner-deps.d.ts +29 -16
- package/dist/boot/runner-deps.js +12 -2
- 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-05-execution-env.js +4 -4
- package/dist/boot/stage-06-runners.d.ts +4 -3
- package/dist/boot/stage-06-runners.js +15 -4
- package/dist/boot/stage-07-capability-layer.d.ts +2 -1
- package/dist/boot/stage-08-reapers.d.ts +2 -1
- package/dist/boot/stage-09-leader.d.ts +2 -1
- package/dist/boot/stage-09-leader.js +2 -2
- package/dist/boot/stage-10-http-server.d.ts +2 -1
- package/dist/boot/stage-10-http-server.js +2 -1
- package/dist/boot/stores.d.ts +8 -0
- package/dist/boot/stores.js +10 -13
- package/dist/boot/web-admin.d.ts +21 -15
- package/dist/boot/web-admin.js +16 -12
- package/dist/boot/workflow-orchestration.js +2 -9
- package/dist/brain.d.ts +11 -11
- package/dist/budget.d.ts +4 -4
- package/dist/budget.js +5 -1
- package/dist/caller-text-echo.d.ts +2 -0
- package/dist/caller-text-echo.js +2 -1
- package/dist/canonical-json.d.ts +2 -41
- package/dist/canonical-json.js +2 -13
- 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 +2 -2
- package/dist/capabilities/composite-members.js +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 +10 -7
- package/dist/capabilities/mcp-probe.js +2 -2
- 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 +27 -24
- package/dist/capability-facts.js +18 -20
- package/dist/center-config-tier.d.ts +1 -1
- package/dist/center-credential.d.ts +4 -4
- package/dist/checkpoint-ctx-seal-m28.d.ts +42 -0
- package/dist/checkpoint-ctx-seal-m28.js +19 -0
- 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-invariants.d.ts +4 -4
- package/dist/config-invariants.js +3 -2
- package/dist/config-lkg.d.ts +1 -1
- package/dist/config-provider.d.ts +13 -13
- package/dist/config-provider.js +2 -1
- package/dist/config-types.d.ts +83 -83
- package/dist/config.d.ts +26 -24
- package/dist/config.js +12 -10
- 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/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/field-conflict.d.ts +2 -1
- package/dist/field-conflict.js +1 -0
- package/dist/file-history-capture.d.ts +9 -9
- package/dist/file-history-disclosure.d.ts +50 -9
- package/dist/file-history-disclosure.js +8 -13
- package/dist/fleet/drain-entry.d.ts +2 -2
- package/dist/fleet/fleet-bus.d.ts +26 -14
- package/dist/fleet/fleet-bus.js +6 -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 +13 -13
- package/dist/fleet-lease.d.ts +16 -16
- package/dist/governance-http-status.d.ts +2 -2
- package/dist/hooks/hook-llm.d.ts +7 -7
- package/dist/hooks/hook-runner.d.ts +57 -30
- package/dist/hooks/hook-runner.js +38 -20
- 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 +28 -5
- package/dist/http/approval-sweeps.d.ts +1 -1
- package/dist/http/approval-sweeps.js +5 -2
- package/dist/http/checkpoint-ctx.d.ts +183 -2
- package/dist/http/checkpoint-ctx.js +197 -2
- package/dist/http/dispatch.d.ts +3 -3
- package/dist/http/dispatch.js +3 -3
- package/dist/http/durable-run-leg.js +7 -5
- package/dist/http/idempotency.d.ts +4 -4
- package/dist/http/idempotency.js +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 +39 -13
- package/dist/http/principal-gate.js +30 -6
- package/dist/http/readiness.d.ts +1 -1
- package/dist/http/refusal-body.d.ts +12 -0
- package/dist/http/refusal-body.js +11 -0
- package/dist/http/request-guards.d.ts +4 -13
- package/dist/http/request-guards.js +4 -17
- package/dist/http/resume-ctx-read.d.ts +53 -6
- package/dist/http/resume-ctx-read.js +26 -3
- package/dist/http/resume-legs.d.ts +5 -4
- package/dist/http/resume-legs.js +47 -29
- package/dist/http/route-ctx.d.ts +29 -38
- package/dist/http/route-table.d.ts +9 -9
- package/dist/http/routes/agents-roster.d.ts +1 -1
- package/dist/http/routes/agents-roster.js +2 -3
- package/dist/http/routes/approvals-assistant.d.ts +5 -5
- package/dist/http/routes/approvals-assistant.js +91 -17
- 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 +6 -6
- package/dist/http/routes/diagnostics.js +1 -1
- package/dist/http/routes/fleet.d.ts +1 -1
- package/dist/http/routes/fleet.js +5 -4
- 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/memory-origin.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/rules.js +4 -4
- package/dist/http/routes/runs.js +44 -11
- package/dist/http/routes/session-sync.d.ts +3 -2
- package/dist/http/routes/session-sync.js +109 -62
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions-list.js +4 -5
- package/dist/http/routes/sessions.js +34 -48
- package/dist/http/routes/tasks.d.ts +1 -1
- package/dist/http/routes/tasks.js +21 -16
- package/dist/http/routes/trace-usage.d.ts +1 -1
- package/dist/http/routes/trace-usage.js +7 -9
- 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 +39 -33
- package/dist/http/server.js +5 -2
- 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.d.ts +4 -3
- package/dist/http/submit-ctx.js +19 -3
- 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 +35 -24
- package/dist/index.d.ts +2 -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 +9 -5
- package/dist/leader/wire.js +8 -7
- package/dist/list-entry-display.d.ts +1 -1
- package/dist/lsp-evict.d.ts +1 -1
- package/dist/main.js +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-origin-fence.js +2 -2
- 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-compat.d.ts +1 -1
- 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-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/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 +12 -8
- package/dist/observability/fail-open.js +12 -8
- package/dist/observability/metrics.d.ts +3 -3
- package/dist/observability/prompt-manifest.d.ts +19 -8
- package/dist/observability/prompt-manifest.js +9 -8
- 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/observability/tool-trace.js +8 -9
- 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/orchestration/workflow-park-decision.d.ts +1 -1
- package/dist/orchestration/workflow-park-decision.js +1 -0
- package/dist/outbound-dispatcher.d.ts +4 -4
- package/dist/parent-watch.d.ts +4 -4
- package/dist/parked-decide.d.ts +20 -20
- package/dist/parked-decide.js +8 -5
- package/dist/parked-revive-surface.d.ts +7 -7
- package/dist/parked-revive-surface.js +2 -3
- package/dist/peer-directory.d.ts +3 -3
- package/dist/peer-directory.js +1 -1
- package/dist/permission-rule-list.d.ts +10 -1
- package/dist/permission-rule-list.js +7 -5
- package/dist/permission-rule-vocab.d.ts +3 -25
- package/dist/permission-rule-vocab.js +0 -13
- 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 +34 -15
- package/dist/plugins/approval-ask-store-sql.js +18 -5
- package/dist/plugins/approval-exemption-store.d.ts +3 -3
- package/dist/plugins/approval-nonce-store.d.ts +3 -3
- package/dist/plugins/approval-payload-fingerprint.d.ts +14 -6
- package/dist/plugins/approval-payload-fingerprint.js +1 -1
- 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/caching-session-store.d.ts +24 -33
- package/dist/plugins/caching-session-store.js +8 -19
- package/dist/plugins/checkpoint-index-columns.d.ts +81 -0
- package/dist/plugins/checkpoint-index-columns.js +62 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +66 -67
- package/dist/plugins/checkpoint-store-sql.js +100 -103
- 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 +9 -7
- package/dist/plugins/file-history-store-sql.js +27 -15
- 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 +23 -12
- package/dist/plugins/local-checkpoint-store.js +29 -4
- package/dist/plugins/local-session-store.d.ts +44 -45
- package/dist/plugins/local-session-store.js +42 -52
- package/dist/plugins/local-session-window.d.ts +12 -6
- package/dist/plugins/local-session-window.js +1 -17
- 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 +76 -39
- package/dist/plugins/one-time-migrations.js +127 -34
- 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 +16 -19
- package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
- package/dist/plugins/permission-rule-store-sql.js +74 -31
- 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 +9 -21
- package/dist/plugins/pg-session-storage.js +51 -42
- package/dist/plugins/remote-env-adb.d.ts +10 -10
- package/dist/plugins/remote-env-device.d.ts +22 -14
- package/dist/plugins/remote-env-device.js +28 -16
- 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 +8 -8
- 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/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.d.ts +11 -0
- package/dist/plugins/session-ownership.js +11 -0
- package/dist/plugins/session-placement.d.ts +12 -14
- package/dist/plugins/session-placement.js +2 -15
- 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/sql-driver.d.ts +8 -8
- package/dist/plugins/sql-errors.d.ts +1 -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/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 +9 -2
- package/dist/plugins/tidb-session-store.d.ts +17 -27
- package/dist/plugins/tidb-session-store.js +52 -42
- 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 +19 -4
- 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-key-closure.d.ts +1 -1
- package/dist/request-key-closure.js +1 -1
- package/dist/request-tool-axes.d.ts +12 -0
- package/dist/request-tool-axes.js +20 -0
- 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/run-local.js +1 -0
- package/dist/runs.d.ts +15 -12
- package/dist/runs.js +19 -4
- package/dist/runtime-caps-resolver.d.ts +6 -6
- package/dist/runtime-governance.d.ts +9 -9
- package/dist/sandbox-pkg-source.d.ts +9 -31
- package/dist/sandbox-pkg-source.js +14 -8
- package/dist/sealed-key.d.ts +34 -2
- package/dist/sealed-key.js +55 -1
- package/dist/security.d.ts +31 -32
- 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 +19 -12
- package/dist/session-error-wire.js +4 -1
- package/dist/session-incarnation.d.ts +52 -35
- package/dist/session-incarnation.js +23 -8
- 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-sync-kernel.d.ts +38 -11
- package/dist/session-sync-kernel.js +10 -0
- package/dist/session-sync.d.ts +49 -6
- package/dist/session-sync.js +52 -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 +3 -1
- package/dist/task-a2a.js +38 -5
- package/dist/task-cwd.d.ts +7 -88
- package/dist/task-cwd.js +2 -15
- package/dist/task-mcp.d.ts +14 -10
- package/dist/task-mcp.js +39 -12
- package/dist/task-settings.d.ts +34 -18
- package/dist/task-settings.js +34 -4
- 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 +273 -228
- package/dist/tool-approval.js +125 -47
- package/dist/tool-rule-names.d.ts +7 -1
- package/dist/trace/core-keyset-guard.d.ts +15 -9
- 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 +40 -1
- package/dist/trace/exit-seat.js +46 -14
- package/dist/trace/ledger-events.d.ts +6 -4
- package/dist/trace/ledger-sink.d.ts +1 -1
- package/dist/trace/model-segment.d.ts +3 -3
- package/dist/trace/project.d.ts +65 -46
- package/dist/trace/project.js +49 -5
- package/dist/trace/redact.d.ts +44 -27
- package/dist/trace/redact.js +343 -73
- package/dist/trace/self-minted-wire.d.ts +39 -14
- package/dist/trace/self-minted-wire.js +9 -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 +9 -3
- package/dist/trace/wire-projection-faces.js +7 -1
- package/dist/unattended-permission-mode.d.ts +5 -5
- package/dist/url-credential.d.ts +52 -0
- package/dist/url-credential.js +49 -0
- package/dist/url-refusal.d.ts +6 -2
- package/dist/url-refusal.js +8 -1
- 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 +29 -4
- package/dist/web-admin-client/skills-mcp.js +31 -4
- package/dist/web-admin-client/types.d.ts +17 -10
- package/dist/workspace-space.d.ts +5 -3
- package/dist/write-protection.d.ts +2 -2
- package/package.json +4 -3
- package/scripts/drain-check-local.mjs +35 -2
- package/scripts/drain-check.mysql.sql +22 -2
- package/scripts/drain-check.pg.sql +22 -2
- package/skills/loop.md +1 -1
- package/dist/mcp-tool-faces.d.ts +0 -69
- package/dist/mcp-tool-faces.js +0 -104
- package/dist/orchestration/workflow-journal-entry.js +0 -27
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { FileSessionRepo, type AcquiredSession, type SessionStore, type SessionRepo, type SessionTreeEntry } from "@sema-agent/core";
|
|
1
|
+
import { FileSessionRepo, type AcquiredSession, type SessionHead, type SessionStore, type SessionRepo, type SessionTreeEntry } from "@sema-agent/core";
|
|
2
2
|
import type { SessionRunRollupSource, SessionSummary } from "./store-contracts.js";
|
|
3
3
|
import type { SessionRowPatch } from "../session-row.js";
|
|
4
4
|
import { type Logger } from "../observability/logger.js";
|
|
5
5
|
import { type SessionFace } from "../session-incarnation.js";
|
|
6
6
|
import { type InstructionSourceBaseline } from "../instruction-source-notice.js";
|
|
7
|
-
import { type StagingHandle, type SyncRelation } from "../session-sync-kernel.js";
|
|
7
|
+
import { type StagedCommitOptions, type StagingHandle, type SyncRelation } from "../session-sync-kernel.js";
|
|
8
8
|
/**
|
|
9
9
|
* local 车道会话存档的**唯一 repo 出口**:本仓里每一只读 `<root>/sessions/*.jsonl` 的 `FileSessionRepo` 都从这里取(`LocalSessionStore` 的底座与会话视图口
|
|
10
10
|
* 窗口 `local-session-window.ts#LocalSessionWindow.wake` 的读旁路),所以坏记录的披露座只有这一份接线 —— 修前视图口自建一只不带座的 repo,同一份坏档在这里读到有计数 / 探针,
|
|
@@ -13,6 +13,8 @@ import { type StagingHandle, type SyncRelation } from "../session-sync-kernel.js
|
|
|
13
13
|
* 的作用域里才记,作用域外 —— 列表 / 导出 / 视图口 —— 是空操作,那些读只进运维面)。
|
|
14
14
|
*/
|
|
15
15
|
export declare function createLocalSessionRepo(root: string): FileSessionRepo;
|
|
16
|
+
/** 本店包的 repo:core `SessionRepo` 且答头读(`headOf` —— 叶子出自它;core 7.55.0 起 `FileSessionRepo` / `InMemorySessionRepo` 都答)。 */
|
|
17
|
+
export type HeadReadingSessionRepo = SessionRepo & Required<Pick<SessionRepo, "headOf">>;
|
|
16
18
|
export declare class LocalSessionStore implements SessionStore {
|
|
17
19
|
private readonly repo;
|
|
18
20
|
private readonly runs;
|
|
@@ -58,14 +60,14 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
58
60
|
/** Pin map (`session-pinned.json`, {@link readPinnedSidecar}) — the local twin of `session_meta.pinned`. Its own file for
|
|
59
61
|
* the same reason titles have theirs (one small map per concern, no format coupling); absent key = not pinned. */
|
|
60
62
|
private readonly pinned;
|
|
61
|
-
/**
|
|
63
|
+
/** [ref] — instruction-source baselines (`session-instruction-sources.json`): the chain member the session's previous
|
|
62
64
|
* run selected, encoded like the SQL twins' `session_meta.instruction_source` column ('' = none; missing key = never
|
|
63
65
|
* recorded). Its own file for the same reason titles have theirs: one small map per concern, no format coupling. */
|
|
64
66
|
private readonly instructionSources;
|
|
65
67
|
/**
|
|
66
68
|
* 会话元数据(`session-incarnations.json`,一格的形与两种读法见 {@link SessionMetaCell}):**属主与化身的唯一真源**,SQL 孪生
|
|
67
69
|
* `session_meta` 行上 `owner` / `incarnation` 两列在本店的对位。两样都**必须落盘**:
|
|
68
|
-
* · 化身(
|
|
70
|
+
* · 化身([ref] / [ref],[ref] §2)的口径是「一位住客一生稳定」,记忆引擎按它绑定会话级记录(opt-out / 污染标记)——
|
|
69
71
|
* 重启后换一只值 = 同一位住客的 opt-out 不再绑它 = 静默恢复采集;
|
|
70
72
|
* · 属主(7.119.0)是会话策略规则的存储键:规则按「会话 × 属主」存、按 run 的 principal 读 —— 重启后属主丢了,规则照样在跑,
|
|
71
73
|
* 属主自己却读不到也删不掉(`409 conflict.session_ownerless`)。7.118.x 及更早属主只活在一只进程内存 Map 里,就是这个病。
|
|
@@ -91,7 +93,7 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
91
93
|
* restart (the file-backed deployment); omit it for the in-memory deployment (nothing survives).
|
|
92
94
|
* @param opts.log the `session_owner_claimed` line's sink (LocalBackend passes a logger at the deployment's LOG_LEVEL;
|
|
93
95
|
* absent ⇒ an info-level JSON-line logger — a claim is never silent). */
|
|
94
|
-
constructor(repo:
|
|
96
|
+
constructor(repo: HeadReadingSessionRepo, runs: SessionRunRollupSource, dataDir?: string, opts?: {
|
|
95
97
|
log?: Pick<Logger, "info">;
|
|
96
98
|
});
|
|
97
99
|
/**
|
|
@@ -111,7 +113,7 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
111
113
|
/** 盘上有没有这只会话(repo 的唯一探针;`open` 读整只存档,所以只在边档里没有那一格时才走到这里)。 */
|
|
112
114
|
private existsInRepo;
|
|
113
115
|
/**
|
|
114
|
-
* 一只会话的元数据 —— 属主与化身的**唯一读口**(
|
|
116
|
+
* 一只会话的元数据 —— 属主与化身的**唯一读口**(按 id 读 {@link headOf} / 删除与换装的属主门都经它)。`undefined` = 无此会话。
|
|
115
117
|
* 边档里有那一格 ⇒ 读它(一次同步读,两样同出一格,不会拼出混世代组合);没有那一格而盘上有会话(7.104.0 之前的会话从没被铸过化身)
|
|
116
118
|
* ⇒ 补铸一格只有化身的(属主没有事实可写,不伪造)并落盘后再答 —— 之后的读都命中那一格,不再回 repo。
|
|
117
119
|
*/
|
|
@@ -122,13 +124,21 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
122
124
|
* `undefined` = 补铸落盘之前那一格已被并发删除抹掉(只有锁外的 {@link metaOf} 走得到)。
|
|
123
125
|
*/
|
|
124
126
|
private cellOfPresent;
|
|
125
|
-
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
/**
|
|
128
|
+
* core `SessionStore.headOf` —— 本店按 id 读一行的**唯一**读口(SQL 孪生同义;此前的 `ownerOf` / `sessionFaceOf` / `incarnationOf` / `getHead` / `getLeafId`
|
|
129
|
+
* 五只读并进来,规则见 `session-incarnation.ts` 头注)。属主与住客出自 {@link metaOf} 读到的同一格(local 后端属主 + 化身的唯一真源 —— 本店的**行**),
|
|
130
|
+
* 叶子出自会话存档(本店的**内容**;core `SessionRepo.headOf`:File repo 读日志首记录与尾、不重放 —— 存档首行的属主 / 令牌本店不读)。
|
|
131
|
+
* 存档读不出(会话头坏了、I/O 故障)⇒ 头照答行上的属主与住客,叶子那一格带着那只故障(`UnreadableLeaf`,读叶子的人收到它):只判归属的读者
|
|
132
|
+
* 不因坏存档改判,坏存档只让读内容的那一位看见(SQL 孪生的头不碰 `session_event`,同一条律;规则在 `session-incarnation.ts` 头注)。
|
|
133
|
+
* 行本身读不出(边档里还没有这一格、要从存档推出这只会话在不在,而存档读不出 —— {@link metaOf} 的探针)⇒ 整只拒。
|
|
134
|
+
* 两样住在两只文件里 ⇒ 先读那一格、读叶子、再同步复读那一格:格没了(读间被删)或换了主 / 换了住客 ⇒ `undefined`(调用方按删处理),
|
|
135
|
+
* 所以一只头从不把这一代的属主配上另一代的叶子([ref] 六轮复审同一条)。`undefined` = 无此会话。
|
|
136
|
+
* 化身那一格经 `headFromRow` 的 `absent` 读法(边档对象形恒有令牌;读不出的边档整只严格拒在 `metaOf` 之前)。
|
|
137
|
+
*/
|
|
138
|
+
headOf(sessionId: string): Promise<SessionHead | undefined>;
|
|
129
139
|
/**
|
|
130
140
|
* 三条 acquire 腿(无 id 建 / 按 id 打开 / 按 id 首建)交出会话的唯一一处:住客 = 这只会话那一格({@link cellOfPresent} —— 刚建或刚在写锁里
|
|
131
|
-
* 打开,就是在盘上的证明,不再回 repo 探一次)
|
|
141
|
+
* 打开,就是在盘上的证明,不再回 repo 探一次),经活住客的唯一投影(`sessionFaceFromRow`)解码,挂到交出的会话上({@link occupiedBy})。
|
|
132
142
|
*/
|
|
133
143
|
private handOut;
|
|
134
144
|
/** Cheap pre-LLM probe (local twin). The map write needs no session_meta row, so there is
|
|
@@ -156,10 +166,10 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
156
166
|
sessionSummaryOf(sessionId: string): Promise<SessionSummary | undefined>;
|
|
157
167
|
/** 会话仓里这只会话的列表元数据(列表面上的行 = `repo.list()` 里的一项)。 */
|
|
158
168
|
private listedMeta;
|
|
159
|
-
/**
|
|
169
|
+
/** [ref] —— 换源通告的基线读(local 孪生;三态读法与 SQL 两孪生的 `session_meta.instruction_source` 同一只编解码)。 */
|
|
160
170
|
readInstructionSource(sessionId: string): Promise<InstructionSourceBaseline>;
|
|
161
171
|
/**
|
|
162
|
-
*
|
|
172
|
+
* [ref] —— CAS 覆写基线(契约见 `InstructionSourceStore`:期望值不符 ⇒ 不写;**没落盘 ⇒ 内存不动、抛**,与 SQL 孪生
|
|
163
173
|
* 「要么提交要么抛」同形 —— 修前写失败只 warn、内存照样前进,同来源的后续 run 在相等比较上短路、再也不重写,重启后
|
|
164
174
|
* 比的是一份过期的盘,codex che-NM r1 [medium])。CAS 判定(在草稿上)、落盘、发布**整段在写链的一节里**(`commit`):下一节
|
|
165
175
|
* 开始之前共享的那张表只含落过盘的值,判定永远不会建立在一个没落过盘的值上(codex che-NM r2 [medium])。
|
|
@@ -199,14 +209,14 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
199
209
|
* ENOENT(首次启动没有这份档)在调用点就被排除,压根到不了这里。
|
|
200
210
|
*/
|
|
201
211
|
private refuseSidecar;
|
|
202
|
-
/** `which` 点名是哪一只边档(
|
|
212
|
+
/** `which` 点名是哪一只边档([ref] 起有三只 —— 此前这句恒写 lastActivity,title 边档的失败也被报成「recency 降级」)。
|
|
203
213
|
* 节流仍是本实例一只。 */
|
|
204
214
|
private warnSidecar;
|
|
205
215
|
acquire(sessionId?: string, opts?: {
|
|
206
216
|
requireExisting?: boolean;
|
|
207
217
|
}): Promise<AcquiredSession>;
|
|
208
218
|
private load;
|
|
209
|
-
/** 为这只会话打开它自己的存档,锁内一形(调用方持这只会话的写锁,见 {@link load})。
|
|
219
|
+
/** 为这只会话打开它自己的存档,锁内一形(调用方持这只会话的写锁,见 {@link load})。[ref]:这是「为这只会话打开它自己的存档」的那一次
|
|
210
220
|
* (引擎 prepare 的 acquire)⇒ 包在打开作用域里:这次回放跳过了记录 ⇒ 打开成功后铸一帧 `session.records_skipped` 投给这只会话(唯一铸点
|
|
211
221
|
* 与作用域见 `session-records-skipped-notice.ts`);读不出(`corrupt_session`)照旧原样上抛,不铸。存档只读这一次:住客那一格缺(更早版本
|
|
212
222
|
* 写下的会话)时,这次打开就是补铸的证明({@link handOut})。GUARD(open 腿):打开一只已存在的会话**不写属主** —— 记下的属主(含「登记为
|
|
@@ -216,7 +226,7 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
216
226
|
* Idempotently record a session's owner — never overwrites a RECORDED owner (incl. a recorded `null`, "registered ownerless";
|
|
217
227
|
* mirrors TiDBSessionStore.register's first-write rule). TiDB parity: register INSERTs a session_meta row so the session EXISTS
|
|
218
228
|
* (forkable) even before its first acquire/run — so we also ensure an EMPTY repo session exists (open if present → never
|
|
219
|
-
* overwrite history; create if not), else `
|
|
229
|
+
* overwrite history; create if not), else `headOf` would say a registered-but-never-acquired session exists while `fork` 404s it.
|
|
220
230
|
*
|
|
221
231
|
* 首写判据在写链里判(两只并发登记:先落盘的那一只赢,后一只不改、也不建会话)。一只**盘上已有、属主从没被记下**的会话
|
|
222
232
|
* (边档那一格只有化身 —— 7.118.x 及更早写下的,或更早到连化身都没有)是一次性迁移 M10 的对象(窗口见 `plugins/one-time-migrations.ts`
|
|
@@ -225,27 +235,12 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
225
235
|
* `REQUIRE_PRINCIPAL=true`,授权口也只在那时才把 principal 递过来认领(`security.ts` `createAuthorizer`)。
|
|
226
236
|
*/
|
|
227
237
|
register(sessionId: string, owner: string | null): Promise<void>;
|
|
228
|
-
/** Owner of a session: `null` if ownerless (registered ownerless, or an owner that was never recorded — a session written by
|
|
229
|
-
* an earlier version), `undefined` if no such session (mirrors TiDBSessionStore.ownerOf). Reads {@link metaOf}: the persisted
|
|
230
|
-
* cell, so the answer survives a restart exactly like the SQL twins' `session_meta.owner` column does. (Before 7.119.0 the
|
|
231
|
-
* owner lived in a process-local Map and this method answered `null` for every session after a restart — the S3 fallback
|
|
232
|
-
* "on disk ⇒ ownerless" kept the E21 delete working, but froze every owner-keyed session-policy rule.) */
|
|
233
|
-
ownerOf(sessionId: string): Promise<string | null | undefined>;
|
|
234
|
-
/** [ref] 六轮复审:owner+leafId 原子快照 —— 先读那一格,读 leaf,再同步复读那一格:格没了(读间被删)或换了主 / 换了住客 ⇒
|
|
235
|
-
* undefined(调用方按删处理)。 */
|
|
236
|
-
getHead(sessionId: string): Promise<{
|
|
237
|
-
owner: string | null;
|
|
238
|
-
leafId: string | null;
|
|
239
|
-
} | undefined>;
|
|
240
238
|
/** 2c P1d-β — re-stamp the session's owner WITHOUT rewriting entries (the staged-commit `identical` path: the log is
|
|
241
239
|
* already present & equal, so only the owner needs re-stamping to the importing principal, §9). Persisted like every
|
|
242
240
|
* owner write; the incarnation is untouched (same occupant). No cell (no such session) ⇒ no-op. Only caller:
|
|
243
241
|
* {@link commitStagedImport}, inside the session's write lock. */
|
|
244
242
|
private restampOwner;
|
|
245
243
|
touch(sessionId: string): Promise<void>;
|
|
246
|
-
/** E18 — the session's current leaf SessionTreeEntry.id (@see TiDBSessionStore.getLeafId). Reads the repo's storage
|
|
247
|
-
* leaf (no acquire-lock; InMemory/File repo reads don't lock). null when the session doesn't exist / has no leaf. */
|
|
248
|
-
getLeafId(sessionId: string): Promise<string | null>;
|
|
249
244
|
/** Durable history is retained by the repo; just drop the in-flight cache entry (mirrors TiDBSessionStore.release). */
|
|
250
245
|
release(sessionId: string): Promise<void>;
|
|
251
246
|
/**
|
|
@@ -259,7 +254,7 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
259
254
|
* - `firstActivityAt` — the session's `createdAt` (repo metadata).
|
|
260
255
|
* - `lastActivityAt` — the touch marker (falls back to `createdAt`); the keyset sort key.
|
|
261
256
|
* - `objectivePreview`— the last USER-text entry, synthesized from the session tree (no run ledger).
|
|
262
|
-
* - `runCount`/`lastStatus`/`lastRunId`/`lastTaskRunId` —
|
|
257
|
+
* - `runCount`/`lastStatus`/`lastRunId`/`lastTaskRunId` — [ref]:read from the run store handed in (`runs`; the TiDB
|
|
263
258
|
* twin LEFT-JOINs `task_run` for the same values, the run store's own `listSessions` is that
|
|
264
259
|
* join's same-semantics projection — latest run by `created_at DESC, task_id DESC`, count of all,
|
|
265
260
|
* `lastTaskRunId` = that run's `result.runId`). One call per list (not per row); a session with no
|
|
@@ -282,16 +277,16 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
282
277
|
}): Promise<SessionSummary[]>;
|
|
283
278
|
/** 列表行要读的边档一次装齐(lastActivity / 标题 / 置顶 / 会话元数据);各自记忆化,只有第一次真读盘。 */
|
|
284
279
|
private loadRowSidecars;
|
|
285
|
-
/** 列表行上的属主:那一格的属主(没有格 / 属主从没被记下 ⇒ null —— 与 `
|
|
280
|
+
/** 列表行上的属主:那一格的属主(没有格 / 属主从没被记下 ⇒ null —— 与 `headOf(id)?.owner` 同答;列表不补铸缺的格,`headOf` 在第一次读时补)。 */
|
|
286
281
|
private ownerCellOf;
|
|
287
282
|
/** 一只会话的列表行 —— {@link listSessions} 与 {@link sessionSummaryOf} 的**同一只**合成(字段来源逐位见 listSessions 的头注)。调用方先 {@link loadRowSidecars}。 */
|
|
288
283
|
private summaryOf;
|
|
289
|
-
/**
|
|
284
|
+
/** [ref]:run 店里每个会话的 run 投影(按 sessionId 索引)。
|
|
290
285
|
* **一次读**:run 店的 `listSessions` 本来就按会话聚合全账(无会话过滤口),这里取全量再按会话仓的 id 查表 —— 比逐会话 N 次读便宜,
|
|
291
286
|
* 也不在会话店里另存一份 run 账。读失败 ⇒ 抛(不吞成 `0 / ""`:那会把「读不到」说成「没跑过」)。 */
|
|
292
287
|
private runRollups;
|
|
293
288
|
/**
|
|
294
|
-
* 一行里 run 身份与计数的**唯一出处**(
|
|
289
|
+
* 一行里 run 身份与计数的**唯一出处**([ref],会话行四位一源):四位全读 {@link runRollups} 的投影(与 SQL 双生的 `task_run` rn=1 JOIN 同口径);
|
|
295
290
|
* 该会话没有 run 行 ⇒ `0` / `""` / `null`、`lastTaskRunId` 缺席(TiDB 的 `COALESCE(…,0)` / null→"" 映射)。在途的最新一条:`lastRunId` 在场(run 行建出来就有)、
|
|
296
291
|
* `lastTaskRunId` 缺席(`result` 在终局与 park 时才写)。
|
|
297
292
|
*/
|
|
@@ -299,9 +294,14 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
299
294
|
/** Synthesize a session's objective preview = the most-recent USER text message (the objective the run last saw).
|
|
300
295
|
* Reads the session's entries through the repo; any read error degrades to null (never fails the list). */
|
|
301
296
|
private previewOf;
|
|
302
|
-
/** E17 — fork a session's WHOLE history to a NEW id
|
|
303
|
-
*
|
|
304
|
-
|
|
297
|
+
/** E17 — fork a session's WHOLE history to a NEW id (core SessionRepo.fork). Returns the new id, or null if the source does not exist.
|
|
298
|
+
* 属主按 core `SessionStore.fork` 契约(core 7.54.0 `sessionStoreContract` 的 [ownership] 格,唯一读法 {@link forkOwnerOf}):显式串 ⇒ 该串;
|
|
299
|
+
* 无参 / 显式 `null` ⇒ **源会话记下的属主**(一份有主历史的拷贝永不降成匿名 —— 匿名的拷贝谁都能认领);源会话没记属主 ⇒ 拷贝也不记(读作无主)。
|
|
300
|
+
* 修前把参数原样写进新格:`fork(owned, null)` 铸出一份匿名的有主历史。
|
|
301
|
+
* 拷**已提交**的叶(契约):在飞的 assistant 轮不进孩子 —— 分叉点只有引擎那一只判官(core 7.55.0 起包根导出的 `settledForkOptions`),本店把唤醒出来的源会话交给它、
|
|
302
|
+
* 把它的答案原样交给引擎自己的 `repo.fork`(与 core 内存店 `TtlSessionStore.fork` 同一条调用链);两只 SQL 孪生同读它(`session-fork.ts`)。钉:
|
|
303
|
+
* core 店契约盒的 `[fork]` 格(`test/session-store-contract-kit.test.ts`)。 */
|
|
304
|
+
fork(sourceId: string, owner?: string | null): Promise<string | null>;
|
|
305
305
|
/** 2c session-sync — EXPORT a session's full durable entry log (core `SessionRepo.exportEntries`; the
|
|
306
306
|
* in-memory/file repo holds the whole log so there is no floor to bypass). null if the source is unknown / the
|
|
307
307
|
* underlying repo lacks the optional seam. The owner is NOT exported — import re-stamps it. */
|
|
@@ -352,14 +352,13 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
352
352
|
/** Drop a finished/aborted local staging handle from the registry (called by the handle on commit/abort). */
|
|
353
353
|
forgetStaging(stagingId: string): void;
|
|
354
354
|
/**
|
|
355
|
-
* {@link LocalStagingHandle.commit} 的整段 —— **一次持锁**(这只会话的写锁,{@link withSessionWriteLock})
|
|
355
|
+
* {@link LocalStagingHandle.commit} 的整段 —— **一次持锁**(这只会话的写锁,{@link withSessionWriteLock}):属主 CAS(此刻的属主格 = 这次导入的门判过的那一格,
|
|
356
|
+
* 否则抛 {@link StagedCommitOwnerChangedError},一个字节不写;在判目的端日志之前判,SQL 孪生同序)→ 提交时重新分类(目的端此刻的日志 vs staged)
|
|
356
357
|
* → 拒未经同意的 fork / stale / 载荷分叉 → 换装(validate-first → 删 → 导入,化身按换装律沿用)或 identical 且内容相同时只重戳属主 → **在同一次持锁里**
|
|
357
358
|
* 读出落定的会话面交回。锁放下之前谁也换不掉这一位住客,所以交回的面就是这次提交落下的那一位(SQL 孪生在提交事务里读同一行,同义);
|
|
358
|
-
* 提交之后按住客条件写的重放(会话行两位)
|
|
359
|
+
* 提交之后按住客条件写的重放(会话行两位)只认这只面,不再重读。改属主的每一条写腿(登记 / 删除 / 导入 / 换装)都在同一把锁里,所以锁内这一读到锁放下都成立。
|
|
359
360
|
*/
|
|
360
|
-
commitStagedImport(sessionId: string, owner: string | null, staged: SessionTreeEntry[], opts
|
|
361
|
-
resolution?: "overwrite-dst";
|
|
362
|
-
}): Promise<{
|
|
361
|
+
commitStagedImport(sessionId: string, owner: string | null, staged: SessionTreeEntry[], opts: StagedCommitOptions): Promise<{
|
|
363
362
|
relation: SyncRelation["relation"];
|
|
364
363
|
face: SessionFace;
|
|
365
364
|
}>;
|
|
@@ -369,14 +368,14 @@ export declare class LocalSessionStore implements SessionStore {
|
|
|
369
368
|
deleteSession(sessionId: string, owner: string | null): Promise<boolean>;
|
|
370
369
|
/**
|
|
371
370
|
* {@link deleteSession} 的锁内一形(调用方持这只会话的写锁;换装 {@link replaceEntriesHeld} 也走它)。
|
|
372
|
-
* 删的是 SQL 孪生 `session_meta` 那一行在本店的全部对位:会话存档、三只行边档(标题 / 置顶 /
|
|
371
|
+
* 删的是 SQL 孪生 `session_meta` 那一行在本店的全部对位:会话存档、三只行边档(标题 / 置顶 / [ref] 的指令来源基线)、属主 + 化身那一格。
|
|
373
372
|
* 三只边档的那一键**都经各自的写链删**(`commit`:草稿上删、落盘、再发布 —— 与写它们的那一笔同一条链、同一把会话锁),落不了盘 ⇒ 抛:
|
|
374
373
|
* 留在盘上的值会挂到同 id 的下一位住客身上(E21 的删除权残留)。元数据格**最后**删:三只边档任一只落不了而抛时,那一格还在 ⇒ 会话对属主门仍
|
|
375
374
|
* 「在」,重发删除照样走得进来、收敛;反过来先删格,重发就成了 no-op,残留永远留下。
|
|
376
375
|
* 🔴 hydrate FIRST (workflow audit 2026-07-13): after a restart the maps start empty — an un-hydrated delete would find nothing and
|
|
377
376
|
* the sidecar would keep the value (an E21 right-to-delete residue that would RESURRECT onto a same-id re-import). ensureLoaded is
|
|
378
377
|
* memoized — first caller pays, rest no-op.
|
|
379
|
-
*
|
|
378
|
+
* [ref]:化身随那一格消失(同 id 重登记铸新的 —— 那就是下一位住客)。
|
|
380
379
|
*/
|
|
381
380
|
private deleteSessionHeld;
|
|
382
381
|
get size(): number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { assertFirstOwnerWritable, forkOwnerOf } from "./session-ownership.js";
|
|
4
|
+
import { FileSessionRepo, SessionError, StoredSession, settledForkOptions, validateEntriesForImport } from "@sema-agent/core";
|
|
4
5
|
import { z } from "zod";
|
|
5
6
|
import { contentForkRelation, fastForwardSharedContentDiverged, identicalIdsAlsoIdenticalContent } from "../session-sync-content.js";
|
|
6
7
|
import { quarantineUnreadableSidecar } from "./local-sidecar-quarantine.js";
|
|
@@ -8,12 +9,12 @@ import { createZodColumnReader, decodeJsonColumn, readStringRecordColumn, SqlJso
|
|
|
8
9
|
import { ONE_TIME_MIGRATIONS, migrationWindowOpen } from "./one-time-migrations.js";
|
|
9
10
|
import { createLogger } from "../observability/logger.js";
|
|
10
11
|
import { UNMANAGED_RETENTION } from "./retention-store-sql.js";
|
|
11
|
-
import { carriedIncarnation, mintSessionIncarnation, sessionFaceFromRow } from "../session-incarnation.js";
|
|
12
|
+
import { UnreadableLeaf, carriedIncarnation, headFromRow, mintSessionIncarnation, sessionFaceFromRow } from "../session-incarnation.js";
|
|
12
13
|
import { decodeInstructionSource, encodeInstructionSource, sameInstructionSourceBaseline } from "../instruction-source-notice.js";
|
|
13
14
|
import { noteReplayInSessionOpenScope, openSessionForItself } from "../session-records-skipped-notice.js";
|
|
14
15
|
import { createCorruptReadFailOpenSeat } from "../observability/corrupt-read-seat.js";
|
|
15
16
|
import { buildObjectivePreview, isAttachmentFrame } from "../user-authored-text.js";
|
|
16
|
-
import { classifySyncRelationshipByIds, SyncConflictError, stagingIdFor, } from "../session-sync-kernel.js";
|
|
17
|
+
import { classifySyncRelationshipByIds, ownerCellIs, SyncConflictError, StagedCommitOwnerChangedError, stagingIdFor, } from "../session-sync-kernel.js";
|
|
17
18
|
const ownerEq = (a, b) => (a ?? null) === (b ?? null);
|
|
18
19
|
const isNotFound = (e) => e instanceof SessionError && e.code === "not_found";
|
|
19
20
|
const SESSION_OBJECTIVE_PREVIEW_CHARS = 200;
|
|
@@ -256,12 +257,16 @@ export class LocalSessionStore {
|
|
|
256
257
|
const cell = this.meta.state.entries.get(sessionId);
|
|
257
258
|
return cell === undefined ? undefined : readSessionMetaCell(cell);
|
|
258
259
|
}
|
|
259
|
-
async
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
async headOf(sessionId) {
|
|
261
|
+
const before = await this.metaOf(sessionId);
|
|
262
|
+
if (before === undefined)
|
|
263
|
+
return undefined;
|
|
264
|
+
const leaf = await this.repo.headOf(sessionId).then((archive) => archive?.leafId ?? null, (fault) => new UnreadableLeaf(fault));
|
|
265
|
+
const cell = this.meta.state.entries.get(sessionId);
|
|
266
|
+
const after = cell === undefined ? undefined : readSessionMetaCell(cell);
|
|
267
|
+
if (after === undefined || after.incarnation !== before.incarnation || (after.owner ?? null) !== (before.owner ?? null))
|
|
268
|
+
return undefined;
|
|
269
|
+
return headFromRow(sessionId, before.owner ?? null, before.incarnation, leaf);
|
|
265
270
|
}
|
|
266
271
|
async handOut(sessionId, session) {
|
|
267
272
|
const meta = await this.cellOfPresent(sessionId);
|
|
@@ -459,6 +464,7 @@ export class LocalSessionStore {
|
|
|
459
464
|
await this.meta.ensureLoaded();
|
|
460
465
|
if (ownerRecorded(this.meta.state.entries.get(sessionId)))
|
|
461
466
|
return;
|
|
467
|
+
assertFirstOwnerWritable(sessionId, owner);
|
|
462
468
|
const existed = await this.existsInRepo(sessionId);
|
|
463
469
|
const claim = existed && owner !== null && ownerClaimWindowOpen();
|
|
464
470
|
const wrote = await this.writeMeta(sessionId, (before) => {
|
|
@@ -474,21 +480,6 @@ export class LocalSessionStore {
|
|
|
474
480
|
this.log.info("session_owner_claimed", { sessionId });
|
|
475
481
|
});
|
|
476
482
|
}
|
|
477
|
-
async ownerOf(sessionId) {
|
|
478
|
-
const meta = await this.metaOf(sessionId);
|
|
479
|
-
return meta === undefined ? undefined : (meta.owner ?? null);
|
|
480
|
-
}
|
|
481
|
-
async getHead(sessionId) {
|
|
482
|
-
const before = await this.metaOf(sessionId);
|
|
483
|
-
if (before === undefined)
|
|
484
|
-
return undefined;
|
|
485
|
-
const leafId = await this.getLeafId(sessionId);
|
|
486
|
-
const cell = this.meta.state.entries.get(sessionId);
|
|
487
|
-
const after = cell === undefined ? undefined : readSessionMetaCell(cell);
|
|
488
|
-
if (after === undefined || after.incarnation !== before.incarnation || (after.owner ?? null) !== (before.owner ?? null))
|
|
489
|
-
return undefined;
|
|
490
|
-
return { owner: before.owner ?? null, leafId };
|
|
491
|
-
}
|
|
492
483
|
async restampOwner(sessionId, owner) {
|
|
493
484
|
await this.writeMeta(sessionId, (before) => (before === undefined ? undefined : { incarnation: readSessionMetaCell(before).incarnation, owner }));
|
|
494
485
|
}
|
|
@@ -496,17 +487,6 @@ export class LocalSessionStore {
|
|
|
496
487
|
this.lastActivity.set(sessionId, new Date().toISOString());
|
|
497
488
|
this.scheduleFlush();
|
|
498
489
|
}
|
|
499
|
-
async getLeafId(sessionId) {
|
|
500
|
-
try {
|
|
501
|
-
const session = await this.repo.open({ id: sessionId, createdAt: "" });
|
|
502
|
-
return (await session.getStorage().getLeafId()) ?? null;
|
|
503
|
-
}
|
|
504
|
-
catch (e) {
|
|
505
|
-
if (isNotFound(e))
|
|
506
|
-
return null;
|
|
507
|
-
throw e;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
490
|
async release(sessionId) {
|
|
511
491
|
this.pending.delete(sessionId);
|
|
512
492
|
}
|
|
@@ -580,17 +560,23 @@ export class LocalSessionStore {
|
|
|
580
560
|
}
|
|
581
561
|
async fork(sourceId, owner) {
|
|
582
562
|
await this.meta.ensureLoaded();
|
|
583
|
-
|
|
584
|
-
const
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
563
|
+
return this.withSessionWriteLock(sourceId, async () => {
|
|
564
|
+
const source = this.meta.state.entries.get(sourceId);
|
|
565
|
+
const forkOwner = forkOwnerOf(owner, source === undefined ? undefined : readSessionMetaCell(source).owner);
|
|
566
|
+
try {
|
|
567
|
+
const sourceMeta = { id: sourceId, createdAt: "" };
|
|
568
|
+
const forkOptions = await settledForkOptions(await this.repo.open(sourceMeta));
|
|
569
|
+
const session = await this.repo.fork(sourceMeta, forkOptions);
|
|
570
|
+
const id = (await session.getMetadata()).id;
|
|
571
|
+
await this.writeMeta(id, () => (forkOwner === undefined ? mintSessionIncarnation() : { incarnation: mintSessionIncarnation(), owner: forkOwner }));
|
|
572
|
+
return id;
|
|
573
|
+
}
|
|
574
|
+
catch (e) {
|
|
575
|
+
if (isNotFound(e))
|
|
576
|
+
return null;
|
|
577
|
+
throw e;
|
|
578
|
+
}
|
|
579
|
+
});
|
|
594
580
|
}
|
|
595
581
|
async exportEntries(sessionId) {
|
|
596
582
|
if (!this.repo.exportEntries)
|
|
@@ -657,12 +643,15 @@ export class LocalSessionStore {
|
|
|
657
643
|
}
|
|
658
644
|
async commitStagedImport(sessionId, owner, staged, opts) {
|
|
659
645
|
return this.withSessionWriteLock(sessionId, async () => {
|
|
646
|
+
const current = await this.metaOf(sessionId);
|
|
647
|
+
if (!ownerCellIs(opts.expectedOwner, current === undefined ? undefined : (current.owner ?? null)))
|
|
648
|
+
throw new StagedCommitOwnerChangedError(sessionId);
|
|
660
649
|
const dstEntries = await this.exportEntries(sessionId);
|
|
661
650
|
const rel = classifySyncRelationshipByIds(staged.map((e) => e.id), dstEntries === null ? null : dstEntries.map((e) => e.id));
|
|
662
|
-
if ((rel.relation === "fork" || rel.relation === "stale") && opts
|
|
651
|
+
if ((rel.relation === "fork" || rel.relation === "stale") && opts.resolution !== "overwrite-dst") {
|
|
663
652
|
throw new SyncConflictError(sessionId, rel);
|
|
664
653
|
}
|
|
665
|
-
if (rel.relation === "fast_forward" && opts
|
|
654
|
+
if (rel.relation === "fast_forward" && opts.resolution !== "overwrite-dst" && dstEntries !== null && dstEntries.length > 0) {
|
|
666
655
|
const dstSet = new Set(dstEntries.map((e) => e.id));
|
|
667
656
|
const diverged = fastForwardSharedContentDiverged(staged.filter((e) => dstSet.has(e.id)), dstEntries);
|
|
668
657
|
if (diverged)
|
|
@@ -675,9 +664,10 @@ export class LocalSessionStore {
|
|
|
675
664
|
else {
|
|
676
665
|
await this.restampOwner(sessionId, owner);
|
|
677
666
|
}
|
|
678
|
-
const
|
|
679
|
-
if (
|
|
667
|
+
const meta = await this.metaOf(sessionId);
|
|
668
|
+
if (meta === undefined)
|
|
680
669
|
throw new SessionError("storage", `LocalSessionStore: staged commit for session ${sessionId} left no session face — nothing was settled`);
|
|
670
|
+
const face = sessionFaceFromRow(sessionId, meta.owner ?? null, meta.incarnation);
|
|
681
671
|
return { relation: rel.relation, face };
|
|
682
672
|
});
|
|
683
673
|
}
|
|
@@ -685,8 +675,8 @@ export class LocalSessionStore {
|
|
|
685
675
|
return this.withSessionWriteLock(sessionId, () => this.deleteSessionHeld(sessionId, owner));
|
|
686
676
|
}
|
|
687
677
|
async deleteSessionHeld(sessionId, owner) {
|
|
688
|
-
const current = await this.
|
|
689
|
-
if (current === undefined || !ownerEq(current, owner))
|
|
678
|
+
const current = await this.metaOf(sessionId);
|
|
679
|
+
if (current === undefined || !ownerEq(current.owner ?? null, owner))
|
|
690
680
|
return false;
|
|
691
681
|
try {
|
|
692
682
|
await this.repo.delete({ id: sessionId, createdAt: "" });
|
|
@@ -16,12 +16,18 @@
|
|
|
16
16
|
* branch below the floor — so the record the engine reads is the one the run's walk reaches.
|
|
17
17
|
* Read-only: the log is read once (`exportEntries`, pure), no append log is opened, and the window refuses writes.
|
|
18
18
|
*
|
|
19
|
-
* ## Cost: one linear walk
|
|
20
|
-
* The branch is
|
|
21
|
-
* without a parent ends it
|
|
22
|
-
* 7.
|
|
23
|
-
*
|
|
24
|
-
* the floor.
|
|
19
|
+
* ## Cost: one linear walk, the engine's
|
|
20
|
+
* The branch is core's own `getPathToRoot` over the whole log (the walk every engine read of a local session makes, with its stop
|
|
21
|
+
* rules: an entry without a parent ends it, a parent the log does not hold is `invalid_session`, an unknown leaf is `not_found`).
|
|
22
|
+
* Since core 7.54.0 ([ref]) that walk is linear; before, it built the path with `unshift` (quadratic — seconds on a long session, on
|
|
23
|
+
* the event loop) and this module walked the `parentId` chain itself. The second walker is retired: the view reads the branch the
|
|
24
|
+
* engine reads, by the engine's reading. Every later read of the window goes through the same walk, bounded by the floor.
|
|
25
|
+
* A parent CYCLE (a corrupted log; the engine never writes one) is refused by that same walk: since core 7.54.1 it carries one
|
|
26
|
+
* `ParentChainGuard`, and the entry it stands on twice ends it with `invalid_session` naming that entry — `wake` refuses a looped log
|
|
27
|
+
* the way it refuses one whose parent is missing. Core 7.54.0's walk had no guard (a looped log spun it forever on the event loop,
|
|
28
|
+
* and the view's wake with it). The retired walker's own cycle refusal went with it: the engine's guard is the one refusal now, shared
|
|
29
|
+
* by `getPathToRoot` and the run's resume ancestor scan (the two walks core 7.54.1 guards; this module has no walker of its own left).
|
|
30
|
+
* Pinned in `test/session-log-parent-cycle.test.ts`.
|
|
25
31
|
*/
|
|
26
32
|
import { BaseSessionStorage } from "@sema-agent/core";
|
|
27
33
|
export declare class LocalSessionWindow extends BaseSessionStorage {
|
|
@@ -30,25 +30,9 @@ export class LocalSessionWindow extends BaseSessionStorage {
|
|
|
30
30
|
const metadata = (await repo.list()).find((m) => m.id === sessionId) ?? { id: sessionId, createdAt: new Date().toISOString() };
|
|
31
31
|
const whole = new InMemorySessionStorage({ entries: log });
|
|
32
32
|
const leafId = await whole.getLeafId();
|
|
33
|
-
const branch = await
|
|
33
|
+
const branch = await whole.getPathToRoot(leafId);
|
|
34
34
|
const { tail, floorEntryId } = boundedTail(branch);
|
|
35
35
|
return new LocalSessionWindow(metadata, tail, leafId, floorEntryId, branch.slice(0, branch.length - tail.length));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
async function branchOf(whole, leafId, logLength) {
|
|
39
|
-
const fromLeaf = [];
|
|
40
|
-
let current = leafId === null ? undefined : await whole.getEntry(leafId);
|
|
41
|
-
while (current) {
|
|
42
|
-
fromLeaf.push(current);
|
|
43
|
-
if (!current.parentId)
|
|
44
|
-
break;
|
|
45
|
-
if (fromLeaf.length > logLength)
|
|
46
|
-
throw new SessionError("invalid_session", `Entry ${current.id} is on a parent cycle`);
|
|
47
|
-
const parent = await whole.getEntry(current.parentId);
|
|
48
|
-
if (!parent)
|
|
49
|
-
throw new SessionError("invalid_session", `Entry ${current.parentId} not found`);
|
|
50
|
-
current = parent;
|
|
51
|
-
}
|
|
52
|
-
return fromLeaf.reverse();
|
|
53
|
-
}
|
|
54
38
|
//# sourceMappingURL=local-session-window.js.map
|
|
@@ -44,14 +44,14 @@ export declare function mailboxKeyDeleteSql(dialect: "tidb" | "pg", table: Mailb
|
|
|
44
44
|
/** 店侧日志座(可选;boot 注入 `Logger`)。7.58.0 合并重扫 [medium]:坏行的 fail-closed 抛必须**响亮**——core 唯一的
|
|
45
45
|
* claimLease 调用方(peer-session-drain)吞掉该错,店不记这一笔就成了「静默永久卡箱」。抛之前记
|
|
46
46
|
* `mailbox_message_column_corrupt`(scope/handle/seq/column/code),运维按 seq 修行。
|
|
47
|
-
* 🔴
|
|
47
|
+
* 🔴 [ref] 车③a **改名并归一**:旧事件名 `mailbox_peer_meta_corrupt` 在 `hop_chain` 也变成 fail-closed 的
|
|
48
48
|
* 那一刻就说不出真话了(同一条读腿两列同判)。一个事件 + 一个 `column` 字段,而不是两个事件名 —— 运维
|
|
49
49
|
* 面按 column 分桶,店里只有一条留痕规则。 */
|
|
50
50
|
export interface MailboxStoreLogger {
|
|
51
51
|
warn(event: string, fields: Record<string, unknown>): void;
|
|
52
52
|
}
|
|
53
53
|
export declare function ensureTiDBMailboxSchema(pool: MySqlPool): Promise<void>;
|
|
54
|
-
/**
|
|
54
|
+
/** [ref]:本 store 的索引**声明**(两方言共用一份)。PG 侧由下面的 `ensurePgMailboxSchema` 应用,MySQL 侧由 `tidb-pool.ts` 的中央 `ensureSchema` 应用(那里内联 `KEY` 已在 `CREATE TABLE` 里 ⇒ 新建库探到即零 DDL,存量库缺谁补谁)。加索引以外的 schema 变更仍归运维,见 `plugins/ensure-index.ts` 头注。 */
|
|
55
55
|
export declare const MAILBOX_INDEXES: readonly IndexSpec[];
|
|
56
56
|
export declare function ensurePgMailboxSchema(q: (text: string, params?: unknown[]) => Promise<unknown>): Promise<void>;
|
|
57
57
|
export declare class TiDBMailboxStore implements MailboxStore, MailboxRecipientLifecycle {
|
|
@@ -17,7 +17,7 @@ export interface PgMemoryEngineSchemaOptions {
|
|
|
17
17
|
pgvector?: boolean;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
20
|
+
/** [ref]:记忆引擎 PG 面的索引**声明**(MySQL 孪生是 `memory-engine-tidb.ts` 的内联 `KEY`/`UNIQUE KEY`,
|
|
21
21
|
* 由 `tidb-pool.ts` 的中央 `ensureSchema` 用同一份声明补存量库)。 */
|
|
22
22
|
export declare const MEMORY_ENGINE_INDEXES: readonly IndexSpec[];
|
|
23
23
|
/** Idempotent DDL for the entry plane. Call once at startup (or run through your migration tool). */
|
|
@@ -73,10 +73,10 @@ export declare class MemoryRunStore implements InProcessClaimFence {
|
|
|
73
73
|
* offered) → the terminal row → the active-run slot release. Returns whether the pending row is now this run's. */
|
|
74
74
|
private writeTerminal;
|
|
75
75
|
/** Durable F4: park NON-terminal `suspended`, KEEP the task_active claim. CAS on running/suspended (reaper-revert guard).
|
|
76
|
-
*
|
|
76
|
+
* [ref]:同时落 `result` —— 封口脱敏后的投影(`sealRunRowResult`,凭据不落;`null` = 没观察到 park 结果),SQL 孪生同注。 */
|
|
77
77
|
setSuspended(taskId: string, result: PersistedTaskResult | null): Promise<void>;
|
|
78
78
|
/** [ref] D-B: park NON-terminal `needs_review`, KEEP the claim. CAS on running/needs_review.
|
|
79
|
-
*
|
|
79
|
+
* [ref]:同 {@link setSuspended} 落封口脱敏后的 `result`。 */
|
|
80
80
|
setNeedsReview(taskId: string, result: PersistedTaskResult | null): Promise<void>;
|
|
81
81
|
/** Durable F4 resume: flip suspended/needs_review → running (CAS) + reset cancel/preempt flags.
|
|
82
82
|
* [ref](codex R1 [medium]):认领 = 接管 `instanceId`(= 当前持有副本;SQL 孪生同注)。CAS 输不改。 */
|
|
@@ -88,7 +88,7 @@ export declare class MemoryRunStore implements InProcessClaimFence {
|
|
|
88
88
|
/** Runs newest-first, keyset on (createdAt, taskId) DESC; optional exact-match filters (owner is exact, like the SQL). */
|
|
89
89
|
listRuns(opts: RunListQuery): Promise<RunRecord[]>;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
91
|
+
* [ref] —— 这个会话**最近一条腿**的窄指针({@link SqlRunStore.latestRunForSession} 的孪生:同一个排序口径
|
|
92
92
|
* `createdAt DESC, taskId DESC`,与本店 {@link MemoryRunStore.listSessions} 挑 `rn=1` 那一行的比较器逐字同一份)。
|
|
93
93
|
*/
|
|
94
94
|
latestRunForSession(sessionId: string): Promise<LatestRunRef | undefined>;
|
|
@@ -135,7 +135,7 @@ export declare class MemoryRunStore implements InProcessClaimFence {
|
|
|
135
135
|
/** Fail stale `running` rows (crashed-run backstop) + release task_active for any now-terminal row. */
|
|
136
136
|
reapStale(olderThanMs: number): Promise<number>;
|
|
137
137
|
/** [ref] shared tail of both suspended-run reapers: flip one parked row → failed('approval.expired'), the
|
|
138
|
-
* in-memory twin of the SQL UPDATE (`error`/`error_code` set directly — no result blob to derive from;
|
|
138
|
+
* in-memory twin of the SQL UPDATE (`error`/`error_code` set directly — no result blob to derive from; [ref]: the park-time `result` is cleared, same as the SQL `result = NULL`). */
|
|
139
139
|
private failExpiredPark;
|
|
140
140
|
/** Release the claim for TERMINAL rows only — suspended/needs_review keep it (the `DELETE ta … WHERE tr.status
|
|
141
141
|
* NOT IN ('running','suspended','needs_review')` twin, shared by reapStale + the [ref] suspended reapers). */
|
|
@@ -46,14 +46,14 @@ export interface MemorySyncStore {
|
|
|
46
46
|
/** Transient failure: attempts+1 (SQL-atomic), record the error, schedule the next attempt. */
|
|
47
47
|
fail(id: string, error: string, nextAttemptAtMs: number): Promise<void>;
|
|
48
48
|
}
|
|
49
|
-
/**
|
|
49
|
+
/** [ref]:push queue 的索引**声明**(MySQL 孪生 = `memory-sync-store-tidb.ts` 的内联 `KEY`)。 */
|
|
50
50
|
export declare const MEMORY_SYNC_INDEXES: readonly IndexSpec[];
|
|
51
51
|
/** Idempotent DDL for the sync plane (PG dialect). Call once at startup. */
|
|
52
52
|
export declare function ensurePgMemorySyncSchema(query: PgQueryFn): Promise<void>;
|
|
53
53
|
/**
|
|
54
54
|
* 本店三只 JSON 承载列的**折码点**(唯一)—— 本店没有枚举式 corrupt 码,既有的「读不出来」口径就是
|
|
55
55
|
* 响亮抛(`claimLeaseMs` 守卫 / dup id 一律 fail-loud)⇒ 折成响亮裸 `Error`,点名 `<表>.<列>` + 行标识
|
|
56
|
-
* (
|
|
56
|
+
* ([ref] 车①② 裁定,沿用;不新铸码)。两个孪生共用本函数(MySQL 腿 import 它 —— 一条折码规则一个写者)。
|
|
57
57
|
*/
|
|
58
58
|
export declare function refusingMemorySyncRow<T>(read: () => T): T;
|
|
59
59
|
/** Options for {@link PgMemorySyncStore}. */
|
|
@@ -115,7 +115,7 @@ export interface MemoryHistoryStore {
|
|
|
115
115
|
/** Ops read face (§1.3 保留策略: v1 无界 + 运维计数 — quota/pruning waits for a demand signal). */
|
|
116
116
|
countByScope(scope: string): Promise<number>;
|
|
117
117
|
}
|
|
118
|
-
/**
|
|
118
|
+
/** [ref]:history 表的索引**声明**(MySQL 孪生 = `memory-sync-store-tidb.ts` 的内联 `KEY`)。 */
|
|
119
119
|
export declare const MEMORY_HISTORY_INDEXES: readonly IndexSpec[];
|
|
120
120
|
/** Idempotent DDL for the history table (PG dialect). Separate from the sync-plane ensure so S5.1
|
|
121
121
|
* can wire the write point independently of the S4 sync wiring. */
|