@sema-agent/server 7.134.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 +134 -0
- package/USAGE.md +98 -30
- 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 +62 -150
- package/dist/approval-card.js +33 -51
- package/dist/approval-content-kind.d.ts +22 -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 +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 +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/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 +28 -24
- package/dist/boot/runner-deps.d.ts +11 -11
- package/dist/boot/runner-deps.js +3 -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.js +0 -2
- package/dist/boot/stores.js +2 -1
- package/dist/boot/web-admin.d.ts +17 -17
- package/dist/boot/web-admin.js +5 -10
- package/dist/boot/workflow-orchestration.js +2 -9
- package/dist/brain.d.ts +11 -11
- package/dist/budget.d.ts +4 -4
- 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 +10 -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 +26 -25
- package/dist/capability-facts.js +14 -16
- package/dist/center-config-tier.d.ts +1 -1
- package/dist/center-credential.d.ts +4 -4
- 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/file-history-capture.d.ts +9 -9
- package/dist/file-history-disclosure.d.ts +23 -11
- package/dist/file-history-disclosure.js +7 -12
- 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 +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 +36 -18
- 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 +39 -13
- package/dist/http/checkpoint-ctx.js +74 -35
- package/dist/http/dispatch.d.ts +3 -3
- 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 +7 -7
- package/dist/http/resume-ctx-read.js +1 -1
- 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 -5
- package/dist/http/routes/approvals-assistant.js +55 -15
- 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 +22 -10
- package/dist/http/routes/session-sync.d.ts +1 -1
- package/dist/http/routes/session-sync.js +73 -44
- package/dist/http/routes/sessions-list.js +1 -1
- package/dist/http/routes/sessions.js +30 -44
- 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 +28 -21
- 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-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/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 +16 -15
- package/dist/parked-decide.js +5 -4
- 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 +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 +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/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 +23 -32
- package/dist/plugins/caching-session-store.js +5 -17
- 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 +44 -66
- package/dist/plugins/checkpoint-store-sql.js +55 -102
- 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 +10 -10
- package/dist/plugins/local-checkpoint-store.js +3 -4
- 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 +66 -40
- package/dist/plugins/one-time-migrations.js +115 -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 +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 +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.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/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 +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 +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-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-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 +3 -3
- 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 +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 +4 -4
- 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 +34 -2
- package/dist/task-cwd.d.ts +7 -88
- package/dist/task-cwd.js +2 -15
- package/dist/task-mcp.d.ts +12 -8
- package/dist/task-mcp.js +19 -4
- 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 +143 -197
- package/dist/tool-approval.js +13 -28
- package/dist/tool-rule-names.d.ts +2 -2
- package/dist/trace/core-keyset-guard.d.ts +12 -7
- 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 +41 -63
- 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 +44 -30
- package/dist/trace/redact.js +191 -89
- package/dist/trace/self-minted-wire.d.ts +35 -14
- package/dist/trace/self-minted-wire.js +8 -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.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 +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 +5 -3
- package/dist/write-protection.d.ts +2 -2
- package/package.json +4 -3
- package/scripts/drain-check-local.mjs +2 -1
- package/scripts/drain-check.mysql.sql +4 -2
- package/scripts/drain-check.pg.sql +4 -2
- package/skills/loop.md +1 -1
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { applyTombstones, assertDeleteDeltaCarriesNoAdd, assertRedemptionNotQuarantined, assertWriteDeltaScopeDurable, foldDelta, isValidDurableScope, parseRuleText, readRowBehavior, screenRuleSyncState, PERMISSION_RULE_WRITER, RULE_ADD_ORIGINS, RULE_APPROVAL_KINDS, RULE_APPROVAL_RECORD_SCHEMA, RULE_APPROVAL_STATES, RULE_BEHAVIORS, RULE_SYNC_DROP_CODES, EDITED_RULE_BREADTH_WARNING_CODES, PERSISTED_RULE_MATCHES, UNCOVERED_SEGMENT_REASONS, EMPTY_DURABLE_RULE_PARTITION, } from "@sema-agent/core";
|
|
3
|
+
import { applyTombstones, assertDeleteDeltaCarriesNoAdd, assertRedemptionNotQuarantined, assertWriteDeltaScopeDurable, foldDelta, isValidDurableScope, parseRuleText, readRowBehavior, screenRuleSyncState, PERMISSION_RULE_WRITER, RULE_ADD_ORIGINS, RULE_APPROVAL_KINDS, RULE_APPROVAL_RECORD_SCHEMA, RULE_APPROVAL_STATES, RULE_BEHAVIORS, RULE_SYNC_DROP_CODES, EDITED_RULE_BREADTH_WARNING_CODES, PERSISTED_RULE_MATCHES, UNCOVERED_SEGMENT_REASONS, EMPTY_DURABLE_RULE_PARTITION, PERMISSION_RULES_LATER_GRAMMAR_CODE, RULE_OFFER_KINDS, SESSION_RULES_GRAMMAR, readRuleGrammarStamp, readRuleOwner, } from "@sema-agent/core";
|
|
4
4
|
import { dialectProtocolJsonEncoder, sqlDbNowMs, SQL_DB_NOW_MS } from "./sql-driver.js";
|
|
5
5
|
import { isMissingColumnError } from "./sql-errors.js";
|
|
6
6
|
import { canonicalJsonStringify } from "@sema-agent/core";
|
|
@@ -64,11 +64,24 @@ function readBucketRowBehavior(raw, what, ownerKey) {
|
|
|
64
64
|
}
|
|
65
65
|
class BucketRefusedError extends Error {
|
|
66
66
|
verdict;
|
|
67
|
-
|
|
67
|
+
code;
|
|
68
|
+
constructor(verdict, evidence, code) {
|
|
68
69
|
super(`${verdict} ${evidence}`);
|
|
69
70
|
this.verdict = verdict;
|
|
71
|
+
if (code !== undefined)
|
|
72
|
+
this.code = code;
|
|
70
73
|
}
|
|
71
74
|
}
|
|
75
|
+
function readBucketStamp(ownerKey, stamp) {
|
|
76
|
+
const absent = stamp === null || stamp === undefined;
|
|
77
|
+
const read = readRuleGrammarStamp(absent ? undefined : stamp, SESSION_RULES_GRAMMAR, { rules: `the rules in permission_rule bucket ${ownerKey}`, held: "rows" });
|
|
78
|
+
if (!("got" in read))
|
|
79
|
+
return absent ? undefined : read.grammar;
|
|
80
|
+
if (read.later === true) {
|
|
81
|
+
throw new BucketRefusedError(read.sentence, "— loading zero rules and refusing every write until then; the row is left as it is", PERMISSION_RULES_LATER_GRAMMAR_CODE);
|
|
82
|
+
}
|
|
83
|
+
throw new BucketRefusedError(read.sentence, "— refusing the whole bucket; the row is left as it is");
|
|
84
|
+
}
|
|
72
85
|
const WritablePersistedRuleSchema = PersistedRuleRowSchema.extend({ behavior: z.enum(RULE_BEHAVIORS) });
|
|
73
86
|
const WritableRuleTombstoneSchema = RuleTombstoneSchema.extend({ behavior: z.enum(RULE_BEHAVIORS) });
|
|
74
87
|
const FrontierSchema = z.record(z.string(), z.number().int().nonnegative().safe());
|
|
@@ -77,9 +90,9 @@ const RedeemedDotsSchema = z.record(z.string(), RuleDotSchema);
|
|
|
77
90
|
const RuleEditedSchema = z
|
|
78
91
|
.object({ index: z.number().int().nonnegative().safe(), text: z.string(), at: z.string(), warnings: z.array(z.enum(EDITED_RULE_BREADTH_WARNING_CODES)).optional() })
|
|
79
92
|
.strict();
|
|
80
|
-
const
|
|
81
|
-
z.object({ kind: z.literal("single"), candidate: z.number().int().nonnegative().safe() }).strict(),
|
|
82
|
-
z
|
|
93
|
+
const RULE_OFFER2_ARMS = {
|
|
94
|
+
single: z.object({ kind: z.literal("single"), candidate: z.number().int().nonnegative().safe() }).strict(),
|
|
95
|
+
batch: z
|
|
83
96
|
.object({
|
|
84
97
|
kind: z.literal("batch"),
|
|
85
98
|
candidates: z.array(z.number().int().nonnegative().safe()),
|
|
@@ -88,7 +101,8 @@ const RuleOffer2Schema = z.union([
|
|
|
88
101
|
uncoveredDetail: z.array(z.object({ segment: z.string(), reason: z.enum(UNCOVERED_SEGMENT_REASONS) }).strict()).optional(),
|
|
89
102
|
})
|
|
90
103
|
.strict(),
|
|
91
|
-
|
|
104
|
+
};
|
|
105
|
+
export const RuleOffer2Schema = z.union([RULE_OFFER2_ARMS.single, RULE_OFFER2_ARMS.batch]);
|
|
92
106
|
export const PERMISSION_RULE_TABLE = "permission_rule";
|
|
93
107
|
export const PERMISSION_RULE_APPROVAL_TABLE = "permission_rule_approval";
|
|
94
108
|
export const PERMISSION_RULE_TICKET_TABLE = "permission_rule_ticket";
|
|
@@ -113,9 +127,13 @@ export const TIDB_PERMISSION_RULE_STATEMENTS = [
|
|
|
113
127
|
observed_vector_json LONGTEXT NULL,
|
|
114
128
|
last_round_at_ms BIGINT NULL,
|
|
115
129
|
-- checksum:core \`ruleStoreChecksum\` 同精神的完整性指纹(覆盖内容三列 + observed_vector 在场时的
|
|
116
|
-
--
|
|
130
|
+
-- 观测向量 + grammar 非 NULL 时的文法戳,不含 rev/counter——算法单点=buildRuleBucketChecksum)。
|
|
117
131
|
-- 读回不符 ⇒ throw(绝不静默当空店 —— core 对读失败的姿势明令如此)。
|
|
118
132
|
checksum VARCHAR(190) NOT NULL,
|
|
133
|
+
-- grammar:这只桶的规则行写在哪一版**规则文法**里(引擎 \`SESSION_RULES_GRAMMAR\` 的数,每次写盖章;core 7.55.0 起 File 店同样每桶一戳)。
|
|
134
|
+
-- NULL = 戳存在之前写下的存量行,按本引擎的文法读、下一次写盖戳;晚于本引擎的戳整桶拒(码 permission_rules.later_grammar,一个字节不动)。
|
|
135
|
+
-- 非 NULL 的戳进 checksum(戳列与指纹同一条语句写;存量 NULL 行的指纹与升级前逐字节相同):不读戳的旧副本按旧算法重算比不上,整桶拒。可空整数:PG 的 INTEGER 驱动交回 number(BIGINT 会交回串)。
|
|
136
|
+
grammar INT NULL,
|
|
119
137
|
created_at_ms BIGINT NOT NULL,
|
|
120
138
|
updated_at_ms BIGINT NOT NULL,
|
|
121
139
|
PRIMARY KEY (owner_key)
|
|
@@ -277,6 +295,7 @@ export async function ensurePgPermissionRuleSchema(q) {
|
|
|
277
295
|
observed_vector_json TEXT COLLATE "C",
|
|
278
296
|
last_round_at_ms BIGINT,
|
|
279
297
|
checksum VARCHAR(190) COLLATE "C" NOT NULL,
|
|
298
|
+
grammar INTEGER,
|
|
280
299
|
created_at_ms BIGINT NOT NULL,
|
|
281
300
|
updated_at_ms BIGINT NOT NULL,
|
|
282
301
|
PRIMARY KEY (owner_key)
|
|
@@ -357,15 +376,16 @@ async function refusingUnreadableColumns(what, fn) {
|
|
|
357
376
|
}
|
|
358
377
|
}
|
|
359
378
|
function bucketRowColumns(dialect) {
|
|
360
|
-
return `actor, counter, rev, ${jsonColumnText(dialect, "rules_json")}, ${jsonColumnText(dialect, "tombstones_json")}, ${jsonColumnText(dialect, "quarantined_json")}, ${jsonColumnText(dialect, "observed_vector_json")}, checksum`;
|
|
379
|
+
return `actor, counter, rev, ${jsonColumnText(dialect, "rules_json")}, ${jsonColumnText(dialect, "tombstones_json")}, ${jsonColumnText(dialect, "quarantined_json")}, ${jsonColumnText(dialect, "observed_vector_json")}, checksum, grammar`;
|
|
361
380
|
}
|
|
362
381
|
function decodeBucketRow(ownerKey, row) {
|
|
363
382
|
const at = `${PERMISSION_RULE_TABLE} bucket ${ownerKey}`;
|
|
383
|
+
const grammar = readBucketStamp(ownerKey, row.grammar);
|
|
364
384
|
const rulesRaw = decodeJsonColumn(row.rules_json, readRulesJson, `${at}.rules_json`);
|
|
365
385
|
const tombstonesRaw = decodeJsonColumn(row.tombstones_json, readTombstonesJson, `${at}.tombstones_json`);
|
|
366
386
|
const quarantinedRaw = decodeJsonColumn(row.quarantined_json, readQuarantinedJson, `${at}.quarantined_json`);
|
|
367
387
|
const observedVector = row.observed_vector_json === null || row.observed_vector_json === undefined ? undefined : decodeJsonColumn(row.observed_vector_json, readObservedVectorJson, `${at}.observed_vector_json`);
|
|
368
|
-
const expected = buildRuleBucketChecksum({ rules: rulesRaw, tombstones: tombstonesRaw, quarantined: quarantinedRaw, ...(observedVector !== undefined ? { observedVector } : {}) });
|
|
388
|
+
const expected = buildRuleBucketChecksum({ rules: rulesRaw, tombstones: tombstonesRaw, quarantined: quarantinedRaw, ...(observedVector !== undefined ? { observedVector } : {}), ...(grammar !== undefined ? { grammar } : {}) });
|
|
369
389
|
if (String(row.checksum ?? "") !== expected) {
|
|
370
390
|
throw new BucketRefusedError(`permission_rule bucket ${ownerKey} failed its integrity check`, `(stored ${String(row.checksum)}, computed ${expected}) — refusing the whole bucket rather than reporting a partial rule set`);
|
|
371
391
|
}
|
|
@@ -392,6 +412,14 @@ function decodeBucketRow(ownerKey, row) {
|
|
|
392
412
|
tombstones,
|
|
393
413
|
quarantined,
|
|
394
414
|
...(observedVector !== undefined ? { observedVector } : {}),
|
|
415
|
+
...(grammar !== undefined ? { grammar } : {}),
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function fencedCasWhere(dialect, firstPlaceholder, ownerKey, cas) {
|
|
419
|
+
const ph = (offset) => (dialect === "tidb" ? "?" : `$${firstPlaceholder + offset}`);
|
|
420
|
+
return {
|
|
421
|
+
sql: `owner_key = ${ph(0)} AND ${cas.column} = ${ph(1)} AND (grammar IS NULL OR grammar <= ${ph(2)})`,
|
|
422
|
+
params: [ownerKey, cas.expected, SESSION_RULES_GRAMMAR],
|
|
395
423
|
};
|
|
396
424
|
}
|
|
397
425
|
async function writeBucket(exec, dialect, ownerKey, cur, next, nowMs) {
|
|
@@ -401,16 +429,17 @@ async function writeBucket(exec, dialect, ownerKey, cur, next, nowMs) {
|
|
|
401
429
|
}
|
|
402
430
|
const body = { rules: next.rules, tombstones: next.tombstones, quarantined: cur.quarantined, ...(cur.observedVector !== undefined ? { observedVector: cur.observedVector } : {}) };
|
|
403
431
|
const enc = dialectProtocolJsonEncoder(dialect);
|
|
432
|
+
const where = fencedCasWhere(dialect, 7, ownerKey, { column: "rev", expected: cur.rev });
|
|
404
433
|
const affected = await exec(dialect === "tidb"
|
|
405
|
-
? `UPDATE ${PERMISSION_RULE_TABLE} SET rules_json = ?, tombstones_json = ?, quarantined_json = ?, checksum = ?, rev = rev + 1, updated_at_ms = ? WHERE
|
|
406
|
-
: `UPDATE ${PERMISSION_RULE_TABLE} SET rules_json = $1, tombstones_json = $2, quarantined_json = $3, checksum = $4, rev = rev + 1, updated_at_ms = $
|
|
434
|
+
? `UPDATE ${PERMISSION_RULE_TABLE} SET rules_json = ?, tombstones_json = ?, quarantined_json = ?, checksum = ?, grammar = ?, rev = rev + 1, updated_at_ms = ? WHERE ${where.sql}`
|
|
435
|
+
: `UPDATE ${PERMISSION_RULE_TABLE} SET rules_json = $1, tombstones_json = $2, quarantined_json = $3, checksum = $4, grammar = $5, rev = rev + 1, updated_at_ms = $6 WHERE ${where.sql}`, [
|
|
407
436
|
enc(next.rules, "permission_rule.rules_json"),
|
|
408
437
|
enc(next.tombstones, "permission_rule.tombstones_json"),
|
|
409
438
|
enc(cur.quarantined, "permission_rule.quarantined_json"),
|
|
410
|
-
buildRuleBucketChecksum(body),
|
|
439
|
+
buildRuleBucketChecksum({ ...body, grammar: SESSION_RULES_GRAMMAR }),
|
|
440
|
+
SESSION_RULES_GRAMMAR,
|
|
411
441
|
nowMs,
|
|
412
|
-
|
|
413
|
-
cur.rev,
|
|
442
|
+
...where.params,
|
|
414
443
|
]);
|
|
415
444
|
return affected === 1;
|
|
416
445
|
}
|
|
@@ -446,9 +475,9 @@ class SqlDurableRulePartition {
|
|
|
446
475
|
async ensureBucket() {
|
|
447
476
|
const nowMs = this.now();
|
|
448
477
|
const empty = { rules: [], tombstones: [], quarantined: [] };
|
|
449
|
-
await this.db.query(this.q(`INSERT IGNORE INTO ${PERMISSION_RULE_TABLE} (owner_key, owner_kind, principal, actor, counter, rev, rules_json, tombstones_json, quarantined_json, observed_vector_json, last_round_at_ms, checksum, created_at_ms, updated_at_ms)
|
|
450
|
-
VALUES (?, ?, ?, ?, 0, 0, ?, ?, ?, NULL, NULL, ?, ?, ?)`, `INSERT INTO ${PERMISSION_RULE_TABLE} (owner_key, owner_kind, principal, actor, counter, rev, rules_json, tombstones_json, quarantined_json, observed_vector_json, last_round_at_ms, checksum, created_at_ms, updated_at_ms)
|
|
451
|
-
VALUES ($1, $2, $3, $4, 0, 0, $5, $6, $7, NULL, NULL, $8, $9, $10) ON CONFLICT (owner_key) DO NOTHING`), [
|
|
478
|
+
await this.db.query(this.q(`INSERT IGNORE INTO ${PERMISSION_RULE_TABLE} (owner_key, owner_kind, principal, actor, counter, rev, rules_json, tombstones_json, quarantined_json, observed_vector_json, last_round_at_ms, checksum, grammar, created_at_ms, updated_at_ms)
|
|
479
|
+
VALUES (?, ?, ?, ?, 0, 0, ?, ?, ?, NULL, NULL, ?, ?, ?, ?)`, `INSERT INTO ${PERMISSION_RULE_TABLE} (owner_key, owner_kind, principal, actor, counter, rev, rules_json, tombstones_json, quarantined_json, observed_vector_json, last_round_at_ms, checksum, grammar, created_at_ms, updated_at_ms)
|
|
480
|
+
VALUES ($1, $2, $3, $4, 0, 0, $5, $6, $7, NULL, NULL, $8, $9, $10, $11) ON CONFLICT (owner_key) DO NOTHING`), [
|
|
452
481
|
this.ownerKey,
|
|
453
482
|
this.owner.kind,
|
|
454
483
|
this.owner.kind === "principal" ? this.owner.principal : null,
|
|
@@ -456,14 +485,15 @@ class SqlDurableRulePartition {
|
|
|
456
485
|
this.enc([], "permission_rule.rules_json"),
|
|
457
486
|
this.enc([], "permission_rule.tombstones_json"),
|
|
458
487
|
this.enc([], "permission_rule.quarantined_json"),
|
|
459
|
-
buildRuleBucketChecksum(empty),
|
|
488
|
+
buildRuleBucketChecksum({ ...empty, grammar: SESSION_RULES_GRAMMAR }),
|
|
489
|
+
SESSION_RULES_GRAMMAR,
|
|
460
490
|
nowMs,
|
|
461
491
|
nowMs,
|
|
462
492
|
]);
|
|
463
493
|
}
|
|
464
494
|
async list() {
|
|
465
495
|
const s = await this.read();
|
|
466
|
-
return { rules: applyTombstones(s.rules, s.tombstones), tombstones: s.tombstones, rev: s.rev, checksum: buildRuleBucketChecksum({ rules: s.rules, tombstones: s.tombstones, quarantined: s.quarantined, ...(s.observedVector !== undefined ? { observedVector: s.observedVector } : {}) }) };
|
|
496
|
+
return { rules: applyTombstones(s.rules, s.tombstones), tombstones: s.tombstones, rev: s.rev, checksum: buildRuleBucketChecksum({ rules: s.rules, tombstones: s.tombstones, quarantined: s.quarantined, ...(s.observedVector !== undefined ? { observedVector: s.observedVector } : {}), ...(s.grammar !== undefined ? { grammar: s.grammar } : {}) }) };
|
|
467
497
|
}
|
|
468
498
|
async quarantined() {
|
|
469
499
|
return (await this.read()).quarantined;
|
|
@@ -475,13 +505,15 @@ class SqlDurableRulePartition {
|
|
|
475
505
|
nextDot: async () => {
|
|
476
506
|
await this.ensureBucket();
|
|
477
507
|
for (let attempt = 0; attempt < NEXT_DOT_MAX_ATTEMPTS; attempt++) {
|
|
478
|
-
const { rows } = await this.db.query(this.q(`SELECT actor, counter FROM ${PERMISSION_RULE_TABLE} WHERE owner_key = ?`, `SELECT actor, counter FROM ${PERMISSION_RULE_TABLE} WHERE owner_key = $1`), [this.ownerKey]);
|
|
508
|
+
const { rows } = await this.db.query(this.q(`SELECT actor, counter, grammar FROM ${PERMISSION_RULE_TABLE} WHERE owner_key = ?`, `SELECT actor, counter, grammar FROM ${PERMISSION_RULE_TABLE} WHERE owner_key = $1`), [this.ownerKey]);
|
|
479
509
|
const row = rows[0];
|
|
480
510
|
if (row === undefined)
|
|
481
511
|
throw new Error(`permission_rule bucket ${this.ownerKey} vanished while minting a dot`);
|
|
512
|
+
readBucketStamp(this.ownerKey, row.grammar);
|
|
482
513
|
const cur = Number(row.counter);
|
|
483
514
|
const next = cur + 1;
|
|
484
|
-
const
|
|
515
|
+
const where = fencedCasWhere(this.db.dialect, 3, this.ownerKey, { column: "counter", expected: cur });
|
|
516
|
+
const { affected } = await this.db.query(this.q(`UPDATE ${PERMISSION_RULE_TABLE} SET counter = ?, updated_at_ms = ? WHERE ${where.sql}`, `UPDATE ${PERMISSION_RULE_TABLE} SET counter = $1, updated_at_ms = $2 WHERE ${where.sql}`), [next, this.now(), ...where.params]);
|
|
485
517
|
if (affected === 1)
|
|
486
518
|
return { actor: String(row.actor), counter: next };
|
|
487
519
|
}
|
|
@@ -554,6 +586,12 @@ export class SqlDurableRulePartitionProvider {
|
|
|
554
586
|
return new SqlDurableRulePartition(this.db, { kind: "local-owner" }, this.now);
|
|
555
587
|
}
|
|
556
588
|
}
|
|
589
|
+
export function recordOwnerOf(record) {
|
|
590
|
+
return readRuleOwner(record.owner ?? { kind: "principal", principal: record.principal });
|
|
591
|
+
}
|
|
592
|
+
export function refusedOwnerSentence(recordId) {
|
|
593
|
+
return `refusing to create approval record ${recordId}: its owner is not one the engine reads as an owner (a principal name must be a non-blank string; the kind must be a member of the owner set) — nothing was written`;
|
|
594
|
+
}
|
|
557
595
|
export class SqlRuleApprovalRecordStore {
|
|
558
596
|
db;
|
|
559
597
|
now;
|
|
@@ -575,9 +613,12 @@ export class SqlRuleApprovalRecordStore {
|
|
|
575
613
|
const row = rows[0];
|
|
576
614
|
if (row === undefined)
|
|
577
615
|
return undefined;
|
|
578
|
-
const ownerKind = String(row.owner_kind);
|
|
579
616
|
const principal = row.principal === null || row.principal === undefined ? undefined : String(row.principal);
|
|
580
|
-
const
|
|
617
|
+
const rowOwner = readRuleOwner({ kind: row.owner_kind, ...(principal !== undefined ? { principal } : {}) });
|
|
618
|
+
if (rowOwner === undefined) {
|
|
619
|
+
throw new Error(`${PERMISSION_RULE_APPROVAL_TABLE} row ${id} carries an owner the engine does not read as an owner (owner_kind ${JSON.stringify(String(row.owner_kind))}) — refusing the record rather than reading it as another owner's`);
|
|
620
|
+
}
|
|
621
|
+
const identity = rowOwner.kind === "principal" ? { principal: rowOwner.principal } : { owner: rowOwner };
|
|
581
622
|
if (Number(row.version) !== RULE_APPROVAL_RECORD_SCHEMA) {
|
|
582
623
|
return { staleSchema: true, id: String(row.record_id), ...identity };
|
|
583
624
|
}
|
|
@@ -612,7 +653,9 @@ export class SqlRuleApprovalRecordStore {
|
|
|
612
653
|
}
|
|
613
654
|
async create(record) {
|
|
614
655
|
const nowMs = this.now();
|
|
615
|
-
const owner = record
|
|
656
|
+
const owner = recordOwnerOf(record);
|
|
657
|
+
if (owner === undefined)
|
|
658
|
+
throw new Error(refusedOwnerSentence(record.id));
|
|
616
659
|
await this.db.query(this.q(`INSERT INTO ${PERMISSION_RULE_APPROVAL_TABLE} (record_id, owner_key, owner_kind, principal, kind, state, version, rev, candidates_json, offers_json, selected_offer, redeemed_dots_json, tool_call_id, bound_input_hash, command, edited_json, created_at_iso, created_at_ms, updated_at_ms)
|
|
617
660
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, `INSERT INTO ${PERMISSION_RULE_APPROVAL_TABLE} (record_id, owner_key, owner_kind, principal, kind, state, version, rev, candidates_json, offers_json, selected_offer, redeemed_dots_json, tool_call_id, bound_input_hash, command, edited_json, created_at_iso, created_at_ms, updated_at_ms)
|
|
618
661
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19)`), [
|
|
@@ -36,7 +36,7 @@ export declare class PgCostQuota implements QuotaTracker {
|
|
|
36
36
|
* DATETIME(3)→TIMESTAMPTZ(3), inline `KEY idx_window`→separate CREATE INDEX). DISJOINT from other stores'
|
|
37
37
|
* tables, so a self-contained ensureSchema is safe (the central pg-pool aggregation is done separately). */
|
|
38
38
|
export declare const PG_COST_QUOTA_SCHEMA: string[];
|
|
39
|
-
/**
|
|
39
|
+
/** [ref]:本 store 的索引**声明**(两方言共用一份)。PG 侧由下面的 `ensureSchema` 应用,MySQL 侧由 `tidb-pool.ts` 的中央 `ensureSchema` 应用(那里内联 `KEY` 已在 `CREATE TABLE` 里 ⇒ 新建库探到即零 DDL,存量库缺谁补谁)。加索引以外的 schema 变更仍归运维,见 `plugins/ensure-index.ts` 头注。 */
|
|
40
40
|
export declare const COST_QUOTA_INDEXES: readonly IndexSpec[];
|
|
41
41
|
/** Idempotent schema apply for the cost_quota table (the PG twin of tidb-pool.ts ensureSchema). */
|
|
42
42
|
export declare function ensureSchema(pool: Pool | PoolClient): Promise<void>;
|
|
@@ -80,7 +80,7 @@ export declare const ENSURE_SCHEMA_LOCK_KEY = 4906;
|
|
|
80
80
|
* `tidb-pool.ts acquireEnsureSchemaLock` 的逐条同形(循环共用 `ensure-schema-lock-policy.ts`)。轮到拿到为止;坏连接连续抛上抛
|
|
81
81
|
* (每条 DDL 本来就各自幂等),而不是把启动挂死。
|
|
82
82
|
*
|
|
83
|
-
* 🔴 **为什么不能再用阻塞的 `pg_advisory_lock()`**(
|
|
83
|
+
* 🔴 **为什么不能再用阻塞的 `pg_advisory_lock()`**([ref] 复审 H1,对 7.82.1 的回归):本仓自 [ref] 起在
|
|
84
84
|
* 锁窗内发 `CREATE INDEX CONCURRENTLY`,而 CIC 的末相要**等掉同库里所有 xmin 比它老的运行中后端**
|
|
85
85
|
* (`WaitForOlderSnapshots`)。一条卡在 `SELECT pg_advisory_lock($1)` 里的副本**正是**一条持着快照的运行中
|
|
86
86
|
* 查询 —— 它等锁、锁等 CIC、CIC 等它:三方互等。命中形是「全新 PG 库 + 多副本同时起」(表刚建完 ⇒ 索引
|
|
@@ -101,7 +101,7 @@ export declare function releasePgEnsureSchemaLock(client: pg.PoolClient, tag: st
|
|
|
101
101
|
* calls ensurePgSchema), and in production every replica calls it at boot. Concurrent DDL on the SAME table makes
|
|
102
102
|
* PG raise `tuple concurrently updated` in its catalog. We serialize the entire run behind a session-level
|
|
103
103
|
* advisory lock, acquired NON-BLOCKINGLY with polling ({@link acquirePgEnsureSchemaLock} — 阻塞形会与本函数
|
|
104
|
-
* 自
|
|
104
|
+
* 自 [ref] 起发的 `CREATE INDEX CONCURRENTLY` 三方互等,理由写在那只函数的头注里): the first caller does
|
|
105
105
|
* the real CREATE/index work, the rest poll from OUTSIDE the database then find every statement already
|
|
106
106
|
* satisfied (IF NOT EXISTS ⇒ no-op), so there is no catalog race. The DDL semantics are
|
|
107
107
|
* unchanged — only its timing is serialized. The advisory lock is SESSION (connection)-level, so the lock and
|
package/dist/plugins/pg-pool.js
CHANGED
|
@@ -93,6 +93,8 @@ export const PG_SCHEMA_STATEMENTS = [
|
|
|
93
93
|
reopen_reason VARCHAR(32) COLLATE "C",
|
|
94
94
|
terminal_at_ms BIGINT,
|
|
95
95
|
gate_kind VARCHAR(32) COLLATE "C",
|
|
96
|
+
-- approval_card(core 7.55.0 #1468 P1 阶段二):门上的卡词照存;语义、读者与「本仓不发 ALTER」见 MySQL 孪生(tidb-pool.ts 同名列的行内注)。
|
|
97
|
+
approval_card TEXT COLLATE "C",
|
|
96
98
|
bound_input_hash VARCHAR(190) COLLATE "C",
|
|
97
99
|
-- pending_steer_queue / pending_steer_rev:队列化后的 durable steering(core 5.14.0 #147)。两列的语义、
|
|
98
100
|
-- 退役的单座列 pending_steer 为何删列(以及存量库里仍带着它时的拒启臂)、48000 字节预算、
|
|
@@ -340,8 +342,9 @@ export const PG_SCHEMA_STATEMENTS = [
|
|
|
340
342
|
summary TEXT COLLATE "C" NOT NULL,
|
|
341
343
|
enqueued_at_ms BIGINT NOT NULL,
|
|
342
344
|
-- 1.109 delivery envelope. kind NULL = a LEGACY \`workflow_complete\` row (the shape that predates the
|
|
343
|
-
-- envelope); readers must keep treating NULL as that kind, it is not "unknown". payload = the kind's
|
|
344
|
-
--
|
|
345
|
+
-- envelope); readers must keep treating NULL as that kind, it is not "unknown". payload = the kind's JSON
|
|
346
|
+
-- extras: task_notification: task_type / result / …; workflow_complete: at most {"completionId": …} (the
|
|
347
|
+
-- engine's own correlation id, verbatim; NULL when the engine minted none).
|
|
345
348
|
kind VARCHAR(24) COLLATE "C",
|
|
346
349
|
payload TEXT COLLATE "C",
|
|
347
350
|
PRIMARY KEY (session_id, run_id),
|
|
@@ -40,7 +40,7 @@ export declare class PgRateLimiter implements RateGate {
|
|
|
40
40
|
* atomic ON CONFLICT increment.
|
|
41
41
|
*/
|
|
42
42
|
export declare const PG_RATE_LIMITER_SCHEMA: string[];
|
|
43
|
-
/**
|
|
43
|
+
/** [ref]:本 store 的索引**声明**(两方言共用一份)。PG 侧由下面的 `ensureSchema` 应用,MySQL 侧由 `tidb-pool.ts` 的中央 `ensureSchema` 应用(那里内联 `KEY` 已在 `CREATE TABLE` 里 ⇒ 新建库探到即零 DDL,存量库缺谁补谁)。加索引以外的 schema 变更仍归运维,见 `plugins/ensure-index.ts` 头注。 */
|
|
44
44
|
export declare const RATE_LIMIT_INDEXES: readonly IndexSpec[];
|
|
45
45
|
/** Self-contained schema bootstrap for tests (the rate_limit table is disjoint from other stores). */
|
|
46
46
|
export declare function ensureSchema(pool: Pool | PoolClient): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseSessionStorage, type AcquiredSession, type PlacedSessionRow, type SessionMetadata, type SessionPlacementRecord, type SessionStore, type SessionTreeEntry, type SessionWriteOptions } from "@sema-agent/core";
|
|
1
|
+
import { BaseSessionStorage, type AcquiredSession, type PlacedSessionRow, type SessionHead, type SessionMetadata, type SessionPlacementRecord, type SessionStore, type SessionTreeEntry, type SessionWriteOptions } from "@sema-agent/core";
|
|
2
2
|
import type { Pool, PoolClient } from "pg";
|
|
3
3
|
import type { SessionSummary } from "./store-contracts.js";
|
|
4
4
|
import { type SessionRowPatch } from "../session-row.js";
|
|
@@ -16,7 +16,7 @@ import { type IndexSpec } from "./ensure-index.js";
|
|
|
16
16
|
* drop-and-recreate, and NO new `ALTER TABLE` seams are added here; fold into the CREATE instead.
|
|
17
17
|
*/
|
|
18
18
|
export declare const PG_SESSION_SCHEMA: string[];
|
|
19
|
-
/**
|
|
19
|
+
/** [ref]:本 store 的索引**声明**(两方言共用一份)。PG 侧由下面的 `ensureSchema` 应用,MySQL 侧由 `tidb-pool.ts` 的中央 `ensureSchema` 应用(那里内联 `KEY` 已在 `CREATE TABLE` 里 ⇒ 新建库探到即零 DDL,存量库缺谁补谁)。加索引以外的 schema 变更仍归运维,见 `plugins/ensure-index.ts` 头注。 */
|
|
20
20
|
export declare const SESSION_INDEXES: readonly IndexSpec[];
|
|
21
21
|
/** Idempotent schema apply for this store's tables (the test calls this; production aggregation is separate). */
|
|
22
22
|
export declare function ensureSchema(pool: Pool | PoolClient): Promise<void>;
|
|
@@ -51,7 +51,7 @@ export declare class PgSessionStorage extends BaseSessionStorage {
|
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* PostgreSQL-backed {@link SessionStore} — the PG twin of {@link TiDBSessionStore}. Maps the
|
|
54
|
-
* `SessionStore` surface (acquire / register /
|
|
54
|
+
* `SessionStore` surface (acquire / register / headOf / touch / release) onto {@link PgSessionStorage}.
|
|
55
55
|
*/
|
|
56
56
|
export declare class PgSessionStore implements SessionStore {
|
|
57
57
|
private readonly pool;
|
|
@@ -75,11 +75,11 @@ export declare class PgSessionStore implements SessionStore {
|
|
|
75
75
|
private load;
|
|
76
76
|
/** Idempotently create a session_meta row with an owner (core `SessionStore.register`). Existing owner is never overwritten. */
|
|
77
77
|
register(sessionId: string, owner: string | null): Promise<void>;
|
|
78
|
-
/** acquire 的建行(唯一一处;
|
|
78
|
+
/** acquire 的建行(唯一一处;[ref] 委派继承律,只住在 `createPlacedSessionRow`,本店交既有读写口 —— TiDB 孪生同名方法同注)。 */
|
|
79
79
|
private createOnAcquire;
|
|
80
|
-
/**
|
|
80
|
+
/** [ref] 委派继承律的认领口(TiDB 孪生 {@link TiDBSessionStore.claimOwnerless} 同义;句 = `CLAIM_OWNERLESS_PLACED_SQL`,规则在 `delegated-session-owner.ts`)。 */
|
|
81
81
|
claimOwnerless(sessionId: string, incarnation: string, owner: string): Promise<boolean>;
|
|
82
|
-
/** 若干来源行的会话面(属主 + 化身)一次读回(TiDB
|
|
82
|
+
/** 若干来源行的会话面(属主 + 化身)一次读回(TiDB 孪生同义;活住客的投影 `sessionFaceFromRow`,空化身 ⇒ 响亮拒)。 */
|
|
83
83
|
private sourceFaces;
|
|
84
84
|
/** The one session_meta INSERT. Existing owner is never overwritten.
|
|
85
85
|
* [ref]:`placement` 与行同一条 INSERT;`DO NOTHING` 臂 ⇒ 已存在行的元组永不被重写(first-write 不可变)。 */
|
|
@@ -92,21 +92,9 @@ export declare class PgSessionStore implements SessionStore {
|
|
|
92
92
|
olderThanMs?: number;
|
|
93
93
|
scope?: string;
|
|
94
94
|
}): Promise<PlacedSessionRow[]>;
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
/** S-790:属主 + 化身一次读(TiDB 孪生 {@link TiDBSessionStore.sessionFaceOf} 同义;空化身 ⇒ 响亮拒)。 */
|
|
98
|
-
sessionFaceOf(sessionId: string): Promise<SessionFace | undefined>;
|
|
99
|
-
/** core `SessionStore.incarnationOf`:{@link sessionFaceOf} 的化身那一半(TiDB 孪生同义)。 */
|
|
100
|
-
incarnationOf(sessionId: string): Promise<string | undefined>;
|
|
95
|
+
/** core `SessionStore.headOf` —— 属主、住客、叶子一条 PK SELECT 一行(TiDB 孪生 {@link TiDBSessionStore.headOf} 同义:本店按 id 读一行的唯一读口)。 */
|
|
96
|
+
headOf(sessionId: string): Promise<SessionHead | undefined>;
|
|
101
97
|
touch(sessionId: string): Promise<void>;
|
|
102
|
-
/** E18 — the session's current leaf SessionTreeEntry.id (session_meta.leaf_id). @see TiDBSessionStore.getLeafId
|
|
103
|
-
* (single SELECT, no acquire/lock, cache-bypassing — safe to read mid-run for the resume-at turn-capture). */
|
|
104
|
-
getLeafId(sessionId: string): Promise<string | null>;
|
|
105
|
-
/** [ref] 六轮复审:owner+leafId 单行原子快照(@see TiDBSessionStore.getHead——混世代组合防)。 */
|
|
106
|
-
getHead(sessionId: string): Promise<{
|
|
107
|
-
owner: string | null;
|
|
108
|
-
leafId: string | null;
|
|
109
|
-
} | undefined>;
|
|
110
98
|
/** Durable history is retained; just drop any in-flight cache entry.
|
|
111
99
|
* 🔴 [ref] 义务 4:**placed 会话例外 —— release 是真删除**(理由/ABA 条件删/失败上浮三条读法逐字见
|
|
112
100
|
* {@link TiDBSessionStore.release},本腿是它的 PG 孪生)。 */
|
|
@@ -15,9 +15,10 @@ import { classifySyncRelationshipByIds, SyncConflictError, StagedCommitOwnerChan
|
|
|
15
15
|
import { isPgUniqueViolation } from "./sql-errors.js";
|
|
16
16
|
import { BASELINE_IO_DEADLINE_MS, decodeInstructionSource, encodeInstructionSource } from "../instruction-source-notice.js";
|
|
17
17
|
import { MANAGED_RETENTION } from "./retention-store-sql.js";
|
|
18
|
-
import { SESSION_META_INCARNATION_COLUMN, carriedIncarnation, incarnationFromCell, mintSessionIncarnation, sessionFaceFromRow } from "../session-incarnation.js";
|
|
18
|
+
import { SESSION_META_INCARNATION_COLUMN, carriedIncarnation, headFromRow, incarnationFromCell, mintSessionIncarnation, sessionFaceFromRow } from "../session-incarnation.js";
|
|
19
19
|
import { ensureIndexes } from "./ensure-index.js";
|
|
20
20
|
import { assertFirstOwnerWritable, forkOwnerOf } from "./session-ownership.js";
|
|
21
|
+
import { forkCopyOf, forkPointOf } from "./session-fork.js";
|
|
21
22
|
const isDupKey = isPgUniqueViolation;
|
|
22
23
|
function baselineQuery(text, values) {
|
|
23
24
|
return { text, values, query_timeout: BASELINE_IO_DEADLINE_MS };
|
|
@@ -219,7 +220,7 @@ export class PgSessionStore {
|
|
|
219
220
|
}
|
|
220
221
|
async register(sessionId, owner) {
|
|
221
222
|
if (typeof owner !== "string" && owner !== null) {
|
|
222
|
-
if ((await this.
|
|
223
|
+
if ((await this.headOf(sessionId)) !== undefined)
|
|
223
224
|
return;
|
|
224
225
|
assertFirstOwnerWritable(sessionId, owner);
|
|
225
226
|
}
|
|
@@ -231,7 +232,7 @@ export class PgSessionStore {
|
|
|
231
232
|
await createPlacedSessionRow(sessionId, placement, {
|
|
232
233
|
readFaces: (ids) => this.sourceFaces(ids),
|
|
233
234
|
insert: (owner) => this.insertMeta(sessionId, owner, placement),
|
|
234
|
-
readOwner: () => this.
|
|
235
|
+
readOwner: async () => (await this.headOf(sessionId))?.owner,
|
|
235
236
|
}, this.log);
|
|
236
237
|
}
|
|
237
238
|
async claimOwnerless(sessionId, incarnation, owner) {
|
|
@@ -266,20 +267,12 @@ export class PgSessionStore {
|
|
|
266
267
|
const res = await this.pool.query(sql, params);
|
|
267
268
|
return res.rows.map((r) => placedRowFromRow(String(r.session_id), r, r.updated_at instanceof Date ? r.updated_at.getTime() : undefined));
|
|
268
269
|
}
|
|
269
|
-
async
|
|
270
|
-
const res = await this.pool.query("SELECT owner FROM session_meta WHERE session_id = $1", [sessionId]);
|
|
270
|
+
async headOf(sessionId) {
|
|
271
|
+
const res = await this.pool.query("SELECT owner, incarnation, leaf_id FROM session_meta WHERE session_id = $1", [sessionId]);
|
|
271
272
|
if (res.rows.length === 0)
|
|
272
273
|
return undefined;
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
async sessionFaceOf(sessionId) {
|
|
276
|
-
const res = await this.pool.query("SELECT owner, incarnation FROM session_meta WHERE session_id = $1", [sessionId]);
|
|
277
|
-
if (res.rows.length === 0)
|
|
278
|
-
return undefined;
|
|
279
|
-
return sessionFaceFromRow(sessionId, res.rows[0].owner ?? null, res.rows[0].incarnation);
|
|
280
|
-
}
|
|
281
|
-
async incarnationOf(sessionId) {
|
|
282
|
-
return (await this.sessionFaceOf(sessionId))?.incarnation;
|
|
274
|
+
const r = res.rows[0];
|
|
275
|
+
return headFromRow(sessionId, r.owner ?? null, r.incarnation, r.leaf_id ?? null);
|
|
283
276
|
}
|
|
284
277
|
async touch(sessionId) {
|
|
285
278
|
await this.pool.query("UPDATE session_meta SET updated_at = $1 WHERE session_id = $2", [
|
|
@@ -287,16 +280,6 @@ export class PgSessionStore {
|
|
|
287
280
|
sessionId,
|
|
288
281
|
]);
|
|
289
282
|
}
|
|
290
|
-
async getLeafId(sessionId) {
|
|
291
|
-
const r = await this.pool.query("SELECT leaf_id FROM session_meta WHERE session_id = $1", [sessionId]);
|
|
292
|
-
return r.rows[0] ? (r.rows[0].leaf_id ?? null) : null;
|
|
293
|
-
}
|
|
294
|
-
async getHead(sessionId) {
|
|
295
|
-
const r = await this.pool.query("SELECT owner, leaf_id FROM session_meta WHERE session_id = $1", [sessionId]);
|
|
296
|
-
if (r.rows.length === 0)
|
|
297
|
-
return undefined;
|
|
298
|
-
return { owner: r.rows[0].owner ?? null, leafId: r.rows[0].leaf_id ?? null };
|
|
299
|
-
}
|
|
300
283
|
async release(sessionId) {
|
|
301
284
|
this.pending.delete(sessionId);
|
|
302
285
|
const placed = await this.placementOf(sessionId);
|
|
@@ -440,8 +423,12 @@ export class PgSessionStore {
|
|
|
440
423
|
return null;
|
|
441
424
|
const leafId = metaRes.rows[0].leaf_id ?? null;
|
|
442
425
|
const forkOwner = forkOwnerOf(owner, metaRes.rows[0].owner ?? null) ?? null;
|
|
426
|
+
const storage = await PgSessionStorage.wake(this.pool, sourceId);
|
|
427
|
+
if (storage === null)
|
|
428
|
+
return null;
|
|
429
|
+
const point = await forkPointOf(storage);
|
|
443
430
|
const eventRes = await this.pool.query(`SELECT entry_id, parent_id, type, ${jsonColumnText("pg", "payload")}, ts FROM session_event WHERE session_id = $1 ORDER BY seq ASC`, [sourceId]);
|
|
444
|
-
const rows = eventRes.rows;
|
|
431
|
+
const { rows, leafId: forkLeafId } = forkCopyOf(eventRes.rows, leafId, point);
|
|
445
432
|
const newId = uuidv7();
|
|
446
433
|
const now = new Date();
|
|
447
434
|
const conn = await this.pool.connect();
|
|
@@ -452,7 +439,7 @@ export class PgSessionStore {
|
|
|
452
439
|
const payload = String(r.payload);
|
|
453
440
|
await conn.query("INSERT INTO session_event (session_id, seq, entry_id, parent_id, type, payload, ts) VALUES ($1,$2,$3,$4,$5,$6::jsonb,$7)", [newId, seq, r.entry_id, r.parent_id ?? null, r.type, payload, r.ts]);
|
|
454
441
|
}
|
|
455
|
-
await conn.query("INSERT INTO session_meta (session_id, owner, created_at, updated_at, leaf_id, leaf_seq, incarnation) VALUES ($1,$2,$3,$4,$5,$6,$7)", [newId, forkOwner, now, now,
|
|
442
|
+
await conn.query("INSERT INTO session_meta (session_id, owner, created_at, updated_at, leaf_id, leaf_seq, incarnation) VALUES ($1,$2,$3,$4,$5,$6,$7)", [newId, forkOwner, now, now, forkLeafId, rows.length, mintSessionIncarnation()]);
|
|
456
443
|
await conn.query("COMMIT");
|
|
457
444
|
return newId;
|
|
458
445
|
}
|
|
@@ -35,13 +35,13 @@ export interface AdbEnvDeps {
|
|
|
35
35
|
/** [R78]#1: adb stderr markers that mean the DEVICE TRANSPORT died mid-op (not a normal command failure) —
|
|
36
36
|
* typed retryable (reconnect + retry per idempotency), never a fake command result. Exported for tests.
|
|
37
37
|
*
|
|
38
|
-
* 🔴 **
|
|
38
|
+
* 🔴 **[ref] 把这个判据的输入面改了一半(复审 F12 纠正:原来写的「此前 stderr 恒空 ⇒ 整条是死码」是
|
|
39
39
|
* **overclaim**,被本车自己的真机读数推翻)**。`exec-out` 合流的是**设备**的 stderr;**adb 客户端自己的**
|
|
40
40
|
* 诊断在两种传输下都照样走宿主 stderr。真机实测(同一台设备,拔掉 serial):
|
|
41
41
|
* `adb -s BOGUS exec-out 'true'` ⇒ host exit **255** + stderr `error: device 'BOGUS' not found`;
|
|
42
42
|
* `adb -s BOGUS shell -T -- 'true'` ⇒ host exit **1** + stderr `adb: device 'BOGUS' not found`。
|
|
43
|
-
* ⇒ 本判据在
|
|
44
|
-
* 措辞的原因);
|
|
43
|
+
* ⇒ 本判据在 [ref] 之前**对 adb 客户端级的传输故障是工作的**(这也正是原作者把词表写成这些 adb 自家
|
|
44
|
+
* 措辞的原因);[ref] 改变的是**设备侧 stderr 从此也进这条通道**。
|
|
45
45
|
*
|
|
46
46
|
* ⚠️ **随之而来的、如实登记的一格**:分流之后落到这里的 stderr **既有 adb 自己的诊断,也有设备命令自己的
|
|
47
47
|
* 输出**(adb 客户端把两者写在同一个 fd 上,真机实测无法在传输层分开)。于是设备上一条自己打印
|
|
@@ -53,7 +53,7 @@ export interface AdbEnvDeps {
|
|
|
53
53
|
export declare function isAdbTransportLost(stderr: string): boolean;
|
|
54
54
|
export declare class RemoteAdbExecutionEnv implements RemoteExecutionEnv {
|
|
55
55
|
/**
|
|
56
|
-
* 🔴 **
|
|
56
|
+
* 🔴 **[ref] / core 7.20.0([ref])`canonicalPathAuthoritative: true`** —— 本适配器的 `canonicalPath`
|
|
57
57
|
* 就是**命令真正跑的那块文件系统**的权威答案(`posix-shell-fs` 的 `canonicalPath` 原语,在设备 shell 里解到落点)。声明它 = 告诉引擎:整链答不出来是**解析器出了事**
|
|
58
58
|
* (RPC 断、传输掉),不是「一个它看不见的命名空间」⇒ 读边界的执行期复核**拒**,而不是让词法判决站着。
|
|
59
59
|
* 缺席是今天每个适配器的读法(整链沉默 ⇒ 词法判决成立、命令照跑),所以这一声明是**收紧**方向。
|
|
@@ -82,7 +82,7 @@ export declare class RemoteAdbExecutionEnv implements RemoteExecutionEnv {
|
|
|
82
82
|
get homeDir(): string | undefined;
|
|
83
83
|
/** 家目录的座(声明胜 · 否则首连时实测 · 实测缺席 ⇒ 缺席 + 一行 warn)。本车道**不对证**声明:Android 没有 POSIX 登录家目录,声明是运维的断言,照单全收。 */
|
|
84
84
|
private readonly homeSeat;
|
|
85
|
-
/** core 7.49.0
|
|
85
|
+
/** core 7.49.0 [ref]:shell 子进程真拿到的 `CDPATH` 条目 —— 本车道的命令跑在 Android 设备的 shell 里(设备自己的 env),本类不读那份 env ⇒ `"unknown"`(core 契约:说不出就说 unknown,
|
|
86
86
|
* 不许报一张没读过的空表;删除守卫因此对裸 `cd <相对名>` 之后的删除问人,而不是按「没有 CDPATH」放行)。 */
|
|
87
87
|
readonly cdPath: "unknown";
|
|
88
88
|
private readonly cfg;
|
|
@@ -156,7 +156,7 @@ export declare class RemoteAdbExecutionEnv implements RemoteExecutionEnv {
|
|
|
156
156
|
joinPath(parts: string[]): Promise<Result<string, FileError>>;
|
|
157
157
|
/** 文件面的门 —— 与 host/local-docker/k8s/e2b 的姿态对齐(它们的文件面在未连/已拆时都 fail-closed)。
|
|
158
158
|
*
|
|
159
|
-
* 🔴 **
|
|
159
|
+
* 🔴 **[ref] 复审 F2:这道门此前只查 `destroyed`,不查 `connected`**,于是 `readBinaryFile` /
|
|
160
160
|
* `readTextFile` / `readTextLines` / `appendFile` 能在**从没连过**的 env 上直接打一次真设备往返。
|
|
161
161
|
* 在本批之前那只是个不一致;本批**新开的 `shell_v2` fail-closed 闸就长在 `connect()` 里**,
|
|
162
162
|
* 所以「不查 connected」= 那道闸对整个读面**不生效** —— 而 `readTextFile` 把错误文本当文件内容返回
|
|
@@ -177,7 +177,7 @@ export declare class RemoteAdbExecutionEnv implements RemoteExecutionEnv {
|
|
|
177
177
|
fileInfo(p: string, abortSignal?: AbortSignal): Promise<Result<FileInfo, FileError>>;
|
|
178
178
|
listDir(p: string, abortSignal?: AbortSignal): Promise<Result<FileInfo[], FileError>>;
|
|
179
179
|
readLink(p: string, abortSignal?: AbortSignal): Promise<Result<string, FileError>>;
|
|
180
|
-
/**
|
|
180
|
+
/** [ref] / core 7.21.0 [ref] —— **实现**(表态:本腿实现 `canonicalChain`)。一次往返里的一个 `readlink`
|
|
181
181
|
* 循环(上限 64、只锚不折、遇环即止),脚本与读法的单一属主在 `remote-shell.ts`,四条 shell 腿共用同一份。
|
|
182
182
|
* 缺席读法用不上(本腿在场);`ok:false` 由 core 读作「这一次没有跳」,永不是拒绝。 */
|
|
183
183
|
canonicalChain(p: string, abortSignal?: AbortSignal): Promise<Result<SymlinkChain, FileError>>;
|
|
@@ -207,7 +207,7 @@ export declare class RemoteAdbExecutionEnv implements RemoteExecutionEnv {
|
|
|
207
207
|
/** Spawn the adb binary with the given args; collect stdout/stderr (+ raw bytes when binary), bound by timeout/abort. */
|
|
208
208
|
private adb;
|
|
209
209
|
/**
|
|
210
|
-
* 🔴 **
|
|
210
|
+
* 🔴 **[ref] —— 本适配器跑设备命令的唯一往返形**(`exec` / `execStream` / `readBinaryFile` 三个调用点
|
|
211
211
|
* 共用一只;此前 `exec-out` 写了三遍,于是「传输到底给不给退出码」这件事没有属主)。
|
|
212
212
|
*
|
|
213
213
|
* **`adb shell`(shell protocol v2)而不是 `adb exec-out`。** 协议出处 = adb 自己的 `adb help`:
|
|
@@ -226,7 +226,7 @@ export declare class RemoteAdbExecutionEnv implements RemoteExecutionEnv {
|
|
|
226
226
|
* 与链原语 `remote-shell.ts` 的 `runSymlinkChain`(第 8 处)认的都是 `exitCode !== 0`,而这条传输恒答 0
|
|
227
227
|
* ⇒ adb 腿上 `realpath` / `readlink` / `stat` / `ls` / `cat` **永不失败**,`canonicalPath` 把那行**错误
|
|
228
228
|
* 文本**当成 canonical key 交给敏感路径门。⚠️ **复审 F15 纠正:原文写「五处」是数错了**,而且漏掉的
|
|
229
|
-
* 第 8 处恰恰是最贵的一处 —— `canonicalChain`(
|
|
229
|
+
* 第 8 处恰恰是最贵的一处 —— `canonicalChain`([ref] / core 7.21.0 [ref],上一版刚接)在 exit 恒 0 下会把
|
|
230
230
|
* **合流进 stdout 的错误文本当成链上的跳**解析出来,等于给 core 的路径判官递一条**伪造的** symlink 链。
|
|
231
231
|
*
|
|
232
232
|
* 🔴 **`-T` 与 `--` 都是承重件,不是装饰**:
|
|
@@ -242,7 +242,7 @@ export declare class RemoteAdbExecutionEnv implements RemoteExecutionEnv {
|
|
|
242
242
|
* {@link createCwdGuardedCall} 组出的那一串(带工作目录时含 cwd 守卫前缀:cd 失败 ⇒ 整条不跑)。
|
|
243
243
|
*/
|
|
244
244
|
private deviceShellArgs;
|
|
245
|
-
/** 本腿只定工作目录(缺省 cwd 规则 + 绝对化);串的形状归 {@link buildCwdEnvCommand} / {@link createCwdGuardedCall}(
|
|
245
|
+
/** 本腿只定工作目录(缺省 cwd 规则 + 绝对化);串的形状归 {@link buildCwdEnvCommand} / {@link createCwdGuardedCall}([ref]:cwd 不可用 ⇒ 命令不跑;
|
|
246
246
|
* 车PL:buffered `exec` 上守卫触发 ⇒ `spawn_error`)。 */
|
|
247
247
|
private workingDirOf;
|
|
248
248
|
}
|
|
@@ -52,7 +52,7 @@ export interface DeviceEnvLogger {
|
|
|
52
52
|
info?(msg: string, fields?: Record<string, unknown>): void;
|
|
53
53
|
}
|
|
54
54
|
export interface DeviceEnvFactoryDeps {
|
|
55
|
-
/**
|
|
55
|
+
/** [ref]④ / core [ref]:设备上执行用户的 home(`ExecutionEnv.homeDir` 座)。由 `boot/execution-env.ts`
|
|
56
56
|
* 从唯一属主 `executionLaneHomeDir` 递进;缺席 ⇒ 本 env 声明「没有 home」,`~/` 规则判 unreadable。 */
|
|
57
57
|
homeDir?: string;
|
|
58
58
|
hub: DeviceWsHub;
|
|
@@ -60,7 +60,7 @@ export interface DeviceEnvFactoryDeps {
|
|
|
60
60
|
enrollment: DeviceEnrollment;
|
|
61
61
|
/** 指令级默认超时(ms;`DEVICE_EXEC_TIMEOUT_MS`,§4.7)。core 的 per-command `timeout` 可收紧它。 */
|
|
62
62
|
execTimeoutMs?: number;
|
|
63
|
-
/** §4.3.3
|
|
63
|
+
/** §4.3.3 蜂道:部署形表行 `callerCwd` 闸下由 resolve-spec 注册的 per-session cwd(**单写者**)。 */
|
|
64
64
|
perSessionCwd?: ReadonlyMap<string, string>;
|
|
65
65
|
perSessionShellEnv?: ReadonlyMap<string, Record<string, string>>;
|
|
66
66
|
logger?: DeviceEnvLogger;
|
|
@@ -72,7 +72,7 @@ interface DeviceEnvConfig {
|
|
|
72
72
|
deviceId: string;
|
|
73
73
|
owner: DeviceOwner;
|
|
74
74
|
cwd: string;
|
|
75
|
-
/**
|
|
75
|
+
/** [ref]④ / core [ref] —— 员工设备上执行用户的 home(`ExecutionEnv.homeDir` 座)。缺席 ⇒ 本 env 声明
|
|
76
76
|
* 「我没有 home」,`~/` 形权限规则对本腿判 unreadable(fail-closed)。值经 `boot/execution-env.ts`
|
|
77
77
|
* 从唯一属主 `executionLaneHomeDir` 递进;设备是运行期连进来的,boot 期只有运维显式声明才有值。 */
|
|
78
78
|
homeDir?: string;
|
|
@@ -86,7 +86,7 @@ export declare class RemoteDeviceExecutionEnv implements RemoteExecutionEnv {
|
|
|
86
86
|
private readonly cfg;
|
|
87
87
|
/** core `ExecutionEnv.homeDir`([ref]):设备上执行用户的 home。见 `DeviceEnvConfig.homeDir`。 */
|
|
88
88
|
readonly homeDir?: string | undefined;
|
|
89
|
-
/** core 7.49.0
|
|
89
|
+
/** core 7.49.0 [ref]:shell 子进程真拿到的 `CDPATH` 条目 —— 本车道的命令跑在设备上(设备自己的 env),本类不读那份 env ⇒ `"unknown"`(core 契约:说不出就说 unknown,
|
|
90
90
|
* 不许报一张没读过的空表;删除守卫因此对裸 `cd <相对名>` 之后的删除问人,而不是按「没有 CDPATH」放行)。 */
|
|
91
91
|
readonly cdPath: "unknown";
|
|
92
92
|
/**
|
|
@@ -96,7 +96,7 @@ export declare class RemoteDeviceExecutionEnv implements RemoteExecutionEnv {
|
|
|
96
96
|
* 落到一个空工作区上而链路上没有任何一层会报错。
|
|
97
97
|
*/
|
|
98
98
|
/**
|
|
99
|
-
* 🔴 **
|
|
99
|
+
* 🔴 **[ref] / core 7.20.0([ref])`canonicalPathAuthoritative: true`** —— 本适配器的 `canonicalPath`
|
|
100
100
|
* 就是**命令真正跑的那块文件系统**的权威答案(设备 WS 协议的**必答** `canonicalPath` op)。声明它 = 告诉引擎:整链答不出来是**解析器出了事**
|
|
101
101
|
* (RPC 断、传输掉),不是「一个它看不见的命名空间」⇒ 读边界的执行期复核**拒**,而不是让词法判决站着。
|
|
102
102
|
* 缺席是今天每个适配器的读法(整链沉默 ⇒ 词法判决成立、命令照跑),所以这一声明是**收紧**方向。
|
|
@@ -324,9 +324,10 @@ export declare class RemoteDeviceExecutionEnv implements RemoteExecutionEnv {
|
|
|
324
324
|
* 对比:「绑了但现在不在线」是运行期事实 ⇒ 构造成功,`connect()` 回 typed `device.offline`。
|
|
325
325
|
*
|
|
326
326
|
* 🔴 **工厂的每一只拒都是 typed 拒**(core 7.54.0 [ref] r3 契约:工厂抛的 `.code` 原样成失败终局的码):经 {@link deviceFactoryRefusal} 一处铸,码取
|
|
327
|
-
* `DEVICE_ERROR_CODES` 闭集(
|
|
327
|
+
* `DEVICE_ERROR_CODES` 闭集(装配 / 数据错误取 {@link DEVICE_FACTORY_CONFIG_CODES}:placement 根为空 · 有效工作目录非绝对路径),句子里的 `[码]` 与 `.code` 同值。修前抛裸 `Error`,码只在句子里
|
|
328
|
+
* (有效工作目录那一只直到 7.135.0 仍是裸 `Error`;钉:本工厂与 {@link effectiveDeviceCwd} 的函数体里没有 `new Error(`)。
|
|
328
329
|
*
|
|
329
|
-
* 🔴 **续跑腿的投递围栏**(core 7.54.0 [ref] r3 /
|
|
330
|
+
* 🔴 **续跑腿的投递围栏**(core 7.54.0 [ref] r3 / [ref],`ExecutionEnvFactoryContext.resumeWorkspace`):行记下了设备(`resumeWorkspace.deviceId`)⇒
|
|
330
331
|
* 本工厂**只**在那台设备上铸 —— placement 根此刻绑的不是它(换绑过)⇒ 抛 typed `device.identity_mismatch`(换绑后赎回的同一个词,零新码),
|
|
331
332
|
* 句子点名两台设备;不连另一台、不改道(新设备没有那个工作区)。读当前绑定只为判出这一拒与取属主,铸的设备恒是行记下的那一台。
|
|
332
333
|
* 「绑的就是它但现在不在线」与新跑同形:构造成功、`connect()` 回 typed `device.offline`(从不连别的设备)。
|
|
@@ -335,12 +336,12 @@ export declare class RemoteDeviceExecutionEnv implements RemoteExecutionEnv {
|
|
|
335
336
|
export declare function deviceExecutionEnvFactory(deps: DeviceEnvFactoryDeps): ExecutionEnvFactory;
|
|
336
337
|
/**
|
|
337
338
|
* §4.3.3 的 cwd 优先序 —— 与 host 腿的 `effectiveHostWorkspace` **同源**:
|
|
338
|
-
* ① 本 session 显式注册的 cwd(`
|
|
339
|
+
* ① 本 session 显式注册的 cwd(部署形表行 `callerCwd` 闸下由 resolve-spec 写);
|
|
339
340
|
* ② `ctx.parentCwd`(委派子代:自己没注册过 cwd,继承父的工作目录 —— 少了它子代会丢工作目录);
|
|
340
341
|
* ③ 设备入籍时登记并落库的 `workspaceRoot`(缺 cwd 时的解析基准,有明确 wire 契约,不是「executor
|
|
341
342
|
* 默认根」这种空话)。
|
|
342
343
|
*
|
|
343
|
-
* 🔴 **这一只解析源同时守它的后置条件:结果必是 POSIX
|
|
344
|
+
* 🔴 **这一只解析源同时守它的后置条件:结果必是 POSIX 绝对路径,否则响亮抛 typed 拒(`.code` = `config.device_cwd_invalid`)。** 协议文档对 executor 的承诺是
|
|
344
345
|
* 「exec / execStream 的指令帧恒带绝对 `cwd`」—— 不带或带相对的,都会把「用哪个目录」这件事留给 executor
|
|
345
346
|
* 自己猜(同一个事实两种读法)。判据是入籍口那**同一只**谓词 `isDeviceAbsolutePath`(`device-store.ts`):入籍口用它拒相对的
|
|
346
347
|
* `workspaceRoot`;这里的判留作存量行守卫(入籍口收紧之前落库的相对根)并守另两个来源 —— 委派链的父 cwd 来自引擎,不经入籍口。
|