open-multi-agent-kit 1.2.0 → 1.2.2
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/CHANGELOG.md +46 -0
- package/README.md +2 -2
- package/dist/approval-api.d.ts +5 -0
- package/dist/approval-api.d.ts.map +1 -0
- package/dist/approval-api.js +5 -0
- package/dist/approval-api.js.map +1 -0
- package/dist/cli/session-picker.d.ts +2 -2
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/commands/verified-run-cli.d.ts.map +1 -1
- package/dist/commands/verified-run-cli.js +69 -22
- package/dist/commands/verified-run-cli.js.map +1 -1
- package/dist/commands/verified-run-signal.d.ts +3 -0
- package/dist/commands/verified-run-signal.d.ts.map +1 -0
- package/dist/commands/verified-run-signal.js +15 -0
- package/dist/commands/verified-run-signal.js.map +1 -0
- package/dist/coordination/broker.d.ts.map +1 -1
- package/dist/coordination/broker.js +13 -6
- package/dist/coordination/broker.js.map +1 -1
- package/dist/coordination/operation.d.ts +1 -0
- package/dist/coordination/operation.d.ts.map +1 -1
- package/dist/coordination/operation.js +55 -3
- package/dist/coordination/operation.js.map +1 -1
- package/dist/coordination/resource.d.ts +1 -1
- package/dist/coordination/resource.d.ts.map +1 -1
- package/dist/coordination/resource.js +10 -4
- package/dist/coordination/resource.js.map +1 -1
- package/dist/coordination/types.d.ts.map +1 -1
- package/dist/coordination/types.js +1 -1
- package/dist/coordination/types.js.map +1 -1
- package/dist/core/adaptorch-bridge.d.ts +1 -1
- package/dist/core/adaptorch-bridge.d.ts.map +1 -1
- package/dist/core/adaptorch-bridge.js +1 -1
- package/dist/core/adaptorch-bridge.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +16 -16
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +32 -33
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/canonical-json.d.ts +3 -0
- package/dist/core/canonical-json.d.ts.map +1 -0
- package/dist/core/canonical-json.js +20 -0
- package/dist/core/canonical-json.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +7 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +14 -29
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/fallback.d.ts +16 -5
- package/dist/core/compaction/fallback.d.ts.map +1 -1
- package/dist/core/compaction/fallback.js +4 -3
- package/dist/core/compaction/fallback.js.map +1 -1
- package/dist/core/compaction/model-failover.d.ts +21 -0
- package/dist/core/compaction/model-failover.d.ts.map +1 -0
- package/dist/core/compaction/model-failover.js +46 -0
- package/dist/core/compaction/model-failover.js.map +1 -0
- package/dist/core/compaction/session-summary.d.ts +21 -0
- package/dist/core/compaction/session-summary.d.ts.map +1 -0
- package/dist/core/compaction/session-summary.js +27 -0
- package/dist/core/compaction/session-summary.js.map +1 -0
- package/dist/core/export-html/template.js +14 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/session-lifecycle-types.d.ts +14 -0
- package/dist/core/extensions/session-lifecycle-types.d.ts.map +1 -0
- package/dist/core/extensions/session-lifecycle-types.js +2 -0
- package/dist/core/extensions/session-lifecycle-types.js.map +1 -0
- package/dist/core/extensions/types.d.ts +4 -9
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +10 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +3 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/legacy-resource-policy.d.ts +7 -0
- package/dist/core/legacy-resource-policy.d.ts.map +1 -0
- package/dist/core/legacy-resource-policy.js +9 -0
- package/dist/core/legacy-resource-policy.js.map +1 -0
- package/dist/core/mcp/config.d.ts.map +1 -1
- package/dist/core/mcp/config.js +17 -3
- package/dist/core/mcp/config.js.map +1 -1
- package/dist/core/mcp/connection-queue.d.ts +12 -0
- package/dist/core/mcp/connection-queue.d.ts.map +1 -0
- package/dist/core/mcp/connection-queue.js +46 -0
- package/dist/core/mcp/connection-queue.js.map +1 -0
- package/dist/core/mcp/manager-runtime.d.ts +55 -0
- package/dist/core/mcp/manager-runtime.d.ts.map +1 -0
- package/dist/core/mcp/manager-runtime.js +66 -0
- package/dist/core/mcp/manager-runtime.js.map +1 -0
- package/dist/core/mcp/manager.d.ts +12 -68
- package/dist/core/mcp/manager.d.ts.map +1 -1
- package/dist/core/mcp/manager.js +33 -113
- package/dist/core/mcp/manager.js.map +1 -1
- package/dist/core/mcp/protocol.d.ts.map +1 -1
- package/dist/core/mcp/protocol.js +70 -40
- package/dist/core/mcp/protocol.js.map +1 -1
- package/dist/core/package-manager.d.ts +4 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +59 -129
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/package-resource-patterns.d.ts +7 -0
- package/dist/core/package-resource-patterns.d.ts.map +1 -0
- package/dist/core/package-resource-patterns.js +99 -0
- package/dist/core/package-resource-patterns.js.map +1 -0
- package/dist/core/provider-resilience.d.ts +9 -0
- package/dist/core/provider-resilience.d.ts.map +1 -1
- package/dist/core/provider-resilience.js +15 -0
- package/dist/core/provider-resilience.js.map +1 -1
- package/dist/core/reasoning-router-v4.d.ts +5 -2
- package/dist/core/reasoning-router-v4.d.ts.map +1 -1
- package/dist/core/reasoning-router-v4.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +4 -8
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/run-execution-api.d.ts +8 -1
- package/dist/core/run-execution-api.d.ts.map +1 -1
- package/dist/core/run-execution-api.js +4 -0
- package/dist/core/run-execution-api.js.map +1 -1
- package/dist/core/run-journal.d.ts +1 -2
- package/dist/core/run-journal.d.ts.map +1 -1
- package/dist/core/run-journal.js +2 -19
- package/dist/core/run-journal.js.map +1 -1
- package/dist/core/session-listing.d.ts +51 -0
- package/dist/core/session-listing.d.ts.map +1 -0
- package/dist/core/session-listing.js +111 -0
- package/dist/core/session-listing.js.map +1 -0
- package/dist/core/session-manager.d.ts +12 -37
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +12 -118
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-message-text.d.ts +5 -0
- package/dist/core/session-message-text.d.ts.map +1 -0
- package/dist/core/session-message-text.js +9 -0
- package/dist/core/session-message-text.js.map +1 -0
- package/dist/core/skills-catalog-cache.d.ts +2 -0
- package/dist/core/skills-catalog-cache.d.ts.map +1 -1
- package/dist/core/skills-catalog-cache.js +71 -17
- package/dist/core/skills-catalog-cache.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/verified-run/authority-clock.d.ts +3 -0
- package/dist/core/verified-run/authority-clock.d.ts.map +1 -0
- package/dist/core/verified-run/authority-clock.js +25 -0
- package/dist/core/verified-run/authority-clock.js.map +1 -0
- package/dist/core/verified-run/authority-errors.d.ts +10 -0
- package/dist/core/verified-run/authority-errors.d.ts.map +1 -0
- package/dist/core/verified-run/authority-errors.js +17 -0
- package/dist/core/verified-run/authority-errors.js.map +1 -0
- package/dist/core/verified-run/authority-events.d.ts +126 -0
- package/dist/core/verified-run/authority-events.d.ts.map +1 -0
- package/dist/core/verified-run/authority-events.js +482 -0
- package/dist/core/verified-run/authority-events.js.map +1 -0
- package/dist/core/verified-run/authority-journal.d.ts +27 -0
- package/dist/core/verified-run/authority-journal.d.ts.map +1 -0
- package/dist/core/verified-run/authority-journal.js +83 -0
- package/dist/core/verified-run/authority-journal.js.map +1 -0
- package/dist/core/verified-run/authority-meaning.d.ts +13 -0
- package/dist/core/verified-run/authority-meaning.d.ts.map +1 -0
- package/dist/core/verified-run/authority-meaning.js +40 -0
- package/dist/core/verified-run/authority-meaning.js.map +1 -0
- package/dist/core/verified-run/authority-runtime.d.ts +82 -0
- package/dist/core/verified-run/authority-runtime.d.ts.map +1 -0
- package/dist/core/verified-run/authority-runtime.js +169 -0
- package/dist/core/verified-run/authority-runtime.js.map +1 -0
- package/dist/core/verified-run/authority-store.d.ts +204 -0
- package/dist/core/verified-run/authority-store.d.ts.map +1 -0
- package/dist/core/verified-run/authority-store.js +852 -0
- package/dist/core/verified-run/authority-store.js.map +1 -0
- package/dist/core/verified-run/broker.d.ts +8 -1
- package/dist/core/verified-run/broker.d.ts.map +1 -1
- package/dist/core/verified-run/broker.js +94 -90
- package/dist/core/verified-run/broker.js.map +1 -1
- package/dist/core/verified-run/candidate-policy.d.ts +10 -0
- package/dist/core/verified-run/candidate-policy.d.ts.map +1 -0
- package/dist/core/verified-run/candidate-policy.js +33 -0
- package/dist/core/verified-run/candidate-policy.js.map +1 -0
- package/dist/core/verified-run/candidate.d.ts.map +1 -1
- package/dist/core/verified-run/candidate.js +5 -10
- package/dist/core/verified-run/candidate.js.map +1 -1
- package/dist/core/verified-run/coordinator.d.ts +35 -17
- package/dist/core/verified-run/coordinator.d.ts.map +1 -1
- package/dist/core/verified-run/coordinator.js +111 -57
- package/dist/core/verified-run/coordinator.js.map +1 -1
- package/dist/core/verified-run/dag-phase.d.ts.map +1 -1
- package/dist/core/verified-run/dag-phase.js +1 -1
- package/dist/core/verified-run/dag-phase.js.map +1 -1
- package/dist/core/verified-run/dag-recovery.d.ts +5 -1
- package/dist/core/verified-run/dag-recovery.d.ts.map +1 -1
- package/dist/core/verified-run/dag-recovery.js +10 -4
- package/dist/core/verified-run/dag-recovery.js.map +1 -1
- package/dist/core/verified-run/event-parser.d.ts.map +1 -1
- package/dist/core/verified-run/event-parser.js +33 -0
- package/dist/core/verified-run/event-parser.js.map +1 -1
- package/dist/core/verified-run/evidence-read-projection.d.ts +4 -0
- package/dist/core/verified-run/evidence-read-projection.d.ts.map +1 -0
- package/dist/core/verified-run/evidence-read-projection.js +27 -0
- package/dist/core/verified-run/evidence-read-projection.js.map +1 -0
- package/dist/core/verified-run/evidence.d.ts +12 -1
- package/dist/core/verified-run/evidence.d.ts.map +1 -1
- package/dist/core/verified-run/evidence.js +51 -2
- package/dist/core/verified-run/evidence.js.map +1 -1
- package/dist/core/verified-run/git-candidate-preflight.d.ts +4 -0
- package/dist/core/verified-run/git-candidate-preflight.d.ts.map +1 -0
- package/dist/core/verified-run/git-candidate-preflight.js +34 -0
- package/dist/core/verified-run/git-candidate-preflight.js.map +1 -0
- package/dist/core/verified-run/git-effect-supervisor.d.ts +24 -0
- package/dist/core/verified-run/git-effect-supervisor.d.ts.map +1 -0
- package/dist/core/verified-run/git-effect-supervisor.js +174 -0
- package/dist/core/verified-run/git-effect-supervisor.js.map +1 -0
- package/dist/core/verified-run/git-execution.d.ts +27 -0
- package/dist/core/verified-run/git-execution.d.ts.map +1 -0
- package/dist/core/verified-run/git-execution.js +118 -0
- package/dist/core/verified-run/git-execution.js.map +1 -0
- package/dist/core/verified-run/git-plumbing.d.ts +37 -0
- package/dist/core/verified-run/git-plumbing.d.ts.map +1 -0
- package/dist/core/verified-run/git-plumbing.js +171 -0
- package/dist/core/verified-run/git-plumbing.js.map +1 -0
- package/dist/core/verified-run/git-publication-worker.d.ts +2 -0
- package/dist/core/verified-run/git-publication-worker.d.ts.map +1 -0
- package/dist/core/verified-run/git-publication-worker.js +54 -0
- package/dist/core/verified-run/git-publication-worker.js.map +1 -0
- package/dist/core/verified-run/git-sandbox-layout.d.ts +4 -0
- package/dist/core/verified-run/git-sandbox-layout.d.ts.map +1 -0
- package/dist/core/verified-run/git-sandbox-layout.js +29 -0
- package/dist/core/verified-run/git-sandbox-layout.js.map +1 -0
- package/dist/core/verified-run/git-worker-protocol.d.ts +19 -0
- package/dist/core/verified-run/git-worker-protocol.d.ts.map +1 -0
- package/dist/core/verified-run/git-worker-protocol.js +109 -0
- package/dist/core/verified-run/git-worker-protocol.js.map +1 -0
- package/dist/core/verified-run/git-worker-runtime.d.ts +19 -0
- package/dist/core/verified-run/git-worker-runtime.d.ts.map +1 -0
- package/dist/core/verified-run/git-worker-runtime.js +74 -0
- package/dist/core/verified-run/git-worker-runtime.js.map +1 -0
- package/dist/core/verified-run/journal.d.ts +2 -3
- package/dist/core/verified-run/journal.d.ts.map +1 -1
- package/dist/core/verified-run/journal.js.map +1 -1
- package/dist/core/verified-run/namespace-identity.d.ts.map +1 -1
- package/dist/core/verified-run/namespace-identity.js +1 -1
- package/dist/core/verified-run/namespace-identity.js.map +1 -1
- package/dist/core/verified-run/owned-execution.d.ts +10 -1
- package/dist/core/verified-run/owned-execution.d.ts.map +1 -1
- package/dist/core/verified-run/owned-execution.js +124 -31
- package/dist/core/verified-run/owned-execution.js.map +1 -1
- package/dist/core/verified-run/phase-context.d.ts +2 -0
- package/dist/core/verified-run/phase-context.d.ts.map +1 -1
- package/dist/core/verified-run/phase-context.js.map +1 -1
- package/dist/core/verified-run/projection.d.ts.map +1 -1
- package/dist/core/verified-run/projection.js +51 -1
- package/dist/core/verified-run/projection.js.map +1 -1
- package/dist/core/verified-run/publish-preflight.d.ts +12 -0
- package/dist/core/verified-run/publish-preflight.d.ts.map +1 -0
- package/dist/core/verified-run/publish-preflight.js +38 -0
- package/dist/core/verified-run/publish-preflight.js.map +1 -0
- package/dist/core/verified-run/publish-start.d.ts +5 -0
- package/dist/core/verified-run/publish-start.d.ts.map +1 -0
- package/dist/core/verified-run/publish-start.js +7 -0
- package/dist/core/verified-run/publish-start.js.map +1 -0
- package/dist/core/verified-run/recovery-projection.d.ts.map +1 -1
- package/dist/core/verified-run/recovery-projection.js +5 -0
- package/dist/core/verified-run/recovery-projection.js.map +1 -1
- package/dist/core/verified-run/recovery.d.ts +5 -1
- package/dist/core/verified-run/recovery.d.ts.map +1 -1
- package/dist/core/verified-run/recovery.js +10 -4
- package/dist/core/verified-run/recovery.js.map +1 -1
- package/dist/core/verified-run/run-plan.d.ts +17 -0
- package/dist/core/verified-run/run-plan.d.ts.map +1 -0
- package/dist/core/verified-run/run-plan.js +18 -0
- package/dist/core/verified-run/run-plan.js.map +1 -0
- package/dist/core/verified-run/run-publish-owned.d.ts +6 -0
- package/dist/core/verified-run/run-publish-owned.d.ts.map +1 -0
- package/dist/core/verified-run/run-publish-owned.js +199 -0
- package/dist/core/verified-run/run-publish-owned.js.map +1 -0
- package/dist/core/verified-run/run-publish.d.ts +19 -0
- package/dist/core/verified-run/run-publish.d.ts.map +1 -0
- package/dist/core/verified-run/run-publish.js +210 -0
- package/dist/core/verified-run/run-publish.js.map +1 -0
- package/dist/core/verified-run/run-status-owned.d.ts +4 -0
- package/dist/core/verified-run/run-status-owned.d.ts.map +1 -0
- package/dist/core/verified-run/run-status-owned.js +14 -0
- package/dist/core/verified-run/run-status-owned.js.map +1 -0
- package/dist/core/verified-run/run-status.d.ts +133 -0
- package/dist/core/verified-run/run-status.d.ts.map +1 -0
- package/dist/core/verified-run/run-status.js +193 -0
- package/dist/core/verified-run/run-status.js.map +1 -0
- package/dist/core/verified-run/run-types.d.ts +31 -0
- package/dist/core/verified-run/run-types.d.ts.map +1 -1
- package/dist/core/verified-run/run-types.js.map +1 -1
- package/dist/core/verified-run/storage.d.ts.map +1 -1
- package/dist/core/verified-run/storage.js +1 -1
- package/dist/core/verified-run/storage.js.map +1 -1
- package/dist/core/verified-run/supervisor-adapter.d.ts +77 -0
- package/dist/core/verified-run/supervisor-adapter.d.ts.map +1 -0
- package/dist/core/verified-run/supervisor-adapter.js +164 -0
- package/dist/core/verified-run/supervisor-adapter.js.map +1 -0
- package/dist/core/verified-run/verification-phase.d.ts.map +1 -1
- package/dist/core/verified-run/verification-phase.js +1 -1
- package/dist/core/verified-run/verification-phase.js.map +1 -1
- package/dist/core/verified-run/writer-phase.d.ts.map +1 -1
- package/dist/core/verified-run/writer-phase.js +1 -0
- package/dist/core/verified-run/writer-phase.js.map +1 -1
- package/dist/core/verified-run/writer-recovery.d.ts +2 -0
- package/dist/core/verified-run/writer-recovery.d.ts.map +1 -1
- package/dist/core/verified-run/writer-recovery.js +1 -0
- package/dist/core/verified-run/writer-recovery.js.map +1 -1
- package/dist/core/workload-shard-execution-types.d.ts +4 -1
- package/dist/core/workload-shard-execution-types.d.ts.map +1 -1
- package/dist/core/workload-shard-execution-types.js.map +1 -1
- package/dist/core/workload-shard-executor.d.ts +2 -2
- package/dist/core/workload-shard-executor.d.ts.map +1 -1
- package/dist/core/workload-shard-executor.js +16 -37
- package/dist/core/workload-shard-executor.js.map +1 -1
- package/dist/core/workload-shard-frontier.d.ts +5 -0
- package/dist/core/workload-shard-frontier.d.ts.map +1 -0
- package/dist/core/workload-shard-frontier.js +47 -0
- package/dist/core/workload-shard-frontier.js.map +1 -0
- package/dist/core/workload-shard-runner.d.ts.map +1 -1
- package/dist/core/workload-shard-runner.js +28 -17
- package/dist/core/workload-shard-runner.js.map +1 -1
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -1
- package/dist/main.js.map +1 -1
- package/dist/metacognition/bridge-result.d.ts +148 -0
- package/dist/metacognition/bridge-result.d.ts.map +1 -0
- package/dist/metacognition/bridge-result.js +46 -0
- package/dist/metacognition/bridge-result.js.map +1 -0
- package/dist/metacognition/calibration-selective.d.ts.map +1 -1
- package/dist/metacognition/calibration-selective.js +8 -2
- package/dist/metacognition/calibration-selective.js.map +1 -1
- package/dist/metacognition/index.d.ts +1 -0
- package/dist/metacognition/index.d.ts.map +1 -1
- package/dist/metacognition/index.js +1 -0
- package/dist/metacognition/index.js.map +1 -1
- package/dist/metacognition/risk.d.ts.map +1 -1
- package/dist/metacognition/risk.js +28 -14
- package/dist/metacognition/risk.js.map +1 -1
- package/dist/metacognition/runtime-bridge.d.ts +41 -14
- package/dist/metacognition/runtime-bridge.d.ts.map +1 -1
- package/dist/metacognition/runtime-bridge.js +357 -39
- package/dist/metacognition/runtime-bridge.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +2 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +42 -26
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-container.d.ts +7 -0
- package/dist/modes/interactive/components/chat-container.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-container.js +14 -0
- package/dist/modes/interactive/components/chat-container.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +4 -2
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +0 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-async-search.d.ts +33 -0
- package/dist/modes/interactive/components/session-selector-async-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-async-search.js +109 -0
- package/dist/modes/interactive/components/session-selector-async-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-loaders.d.ts +6 -0
- package/dist/modes/interactive/components/session-selector-loaders.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-loaders.js +9 -0
- package/dist/modes/interactive/components/session-selector-loaders.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-tree.d.ts +16 -0
- package/dist/modes/interactive/components/session-selector-tree.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-tree.js +46 -0
- package/dist/modes/interactive/components/session-selector-tree.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +6 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +36 -76
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution-images.d.ts +32 -0
- package/dist/modes/interactive/components/tool-execution-images.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-images.js +144 -0
- package/dist/modes/interactive/components/tool-execution-images.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +3 -4
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +22 -71
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +7 -9
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tui-diagnostics.d.ts +8 -4
- package/dist/modes/interactive/tui-diagnostics.d.ts.map +1 -1
- package/dist/modes/interactive/tui-diagnostics.js +35 -1
- package/dist/modes/interactive/tui-diagnostics.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +14 -17
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-response.d.ts +5 -0
- package/dist/modes/rpc/rpc-response.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-response.js +17 -0
- package/dist/modes/rpc/rpc-response.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +3 -5
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/adaptorch-preview-spec.md +7 -7
- package/docs/atomic-commit-planning.md +69 -0
- package/docs/compaction.md +26 -1
- package/docs/extensions.md +14 -0
- package/docs/mcp.md +22 -0
- package/docs/metacognition.md +79 -0
- package/docs/model-catalog-refresh.md +159 -1
- package/docs/models.md +1 -1
- package/docs/runtime-algorithms.md +49 -4
- package/docs/session-format.md +8 -0
- package/docs/sessions.md +19 -0
- package/docs/skills.md +19 -0
- package/docs/terminal-setup.md +15 -0
- package/docs/tui.md +41 -0
- package/docs/verified-run-safety.md +75 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +18 -18
- package/package.json +6 -8
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { canonicalJson } from "../run-journal.js";
|
|
2
|
+
import { AuthorityStoreError } from "./authority-errors.js";
|
|
3
|
+
import { applyAuthorityEvents, parseAuthorityEvent, projectAuthority, } from "./authority-events.js";
|
|
4
|
+
import { digestObject } from "./storage.js";
|
|
5
|
+
export const GENESIS_PREVIOUS = "0".repeat(64);
|
|
6
|
+
export function materializeRecord(seq, previous, event) {
|
|
7
|
+
const material = { version: 1, seq, previous, event };
|
|
8
|
+
return Object.freeze({ ...material, hash: digestObject(material) });
|
|
9
|
+
}
|
|
10
|
+
export function recordLine(record) {
|
|
11
|
+
return `${canonicalJson(record)}\n`;
|
|
12
|
+
}
|
|
13
|
+
/** Inode/head fencing is checked by the owner before offering a prefix. */
|
|
14
|
+
export function parseCommitted(bytes, prefix) {
|
|
15
|
+
if (prefix && (bytes.length < prefix.bytes.length || !prefix.bytes.equals(bytes.subarray(0, prefix.bytes.length))))
|
|
16
|
+
prefix = undefined;
|
|
17
|
+
if (prefix && bytes.length === prefix.bytes.length)
|
|
18
|
+
return { ...prefix, replay: { parsedRecords: 0, reusedPrefixRecords: prefix.records.length } };
|
|
19
|
+
if (!bytes.length)
|
|
20
|
+
return {
|
|
21
|
+
lastSeq: 0,
|
|
22
|
+
lastHash: GENESIS_PREVIOUS,
|
|
23
|
+
records: Object.freeze([]),
|
|
24
|
+
events: Object.freeze([]),
|
|
25
|
+
state: projectAuthority([]),
|
|
26
|
+
bytes: Buffer.alloc(0),
|
|
27
|
+
replay: { parsedRecords: 0, reusedPrefixRecords: 0 },
|
|
28
|
+
};
|
|
29
|
+
if (bytes.at(-1) !== 10)
|
|
30
|
+
throw new AuthorityStoreError("corrupt");
|
|
31
|
+
let text;
|
|
32
|
+
try {
|
|
33
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(prefix?.bytes.length ?? 0));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw new AuthorityStoreError("corrupt");
|
|
37
|
+
}
|
|
38
|
+
const lines = text.slice(0, -1).split("\n");
|
|
39
|
+
let seed;
|
|
40
|
+
let previous = prefix?.lastHash ?? GENESIS_PREVIOUS;
|
|
41
|
+
let expectedSeq = (prefix?.lastSeq ?? 0) + 1;
|
|
42
|
+
let lastSeq = prefix?.lastSeq ?? 0;
|
|
43
|
+
const events = [];
|
|
44
|
+
const records = [];
|
|
45
|
+
for (const [index, line] of lines.entries()) {
|
|
46
|
+
let raw;
|
|
47
|
+
try {
|
|
48
|
+
raw = JSON.parse(line);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new AuthorityStoreError("corrupt");
|
|
52
|
+
}
|
|
53
|
+
if (typeof raw !== "object" || raw === null || !("event" in raw))
|
|
54
|
+
throw new AuthorityStoreError("corrupt");
|
|
55
|
+
const event = parseAuthorityEvent(raw.event);
|
|
56
|
+
const record = event.kind === "authority-snapshot"
|
|
57
|
+
? materializeRecord(event.archivedThroughSequence + 1, event.continuesHash, event)
|
|
58
|
+
: materializeRecord(expectedSeq, previous, event);
|
|
59
|
+
if (canonicalJson(raw) !== canonicalJson(record))
|
|
60
|
+
throw new AuthorityStoreError("corrupt");
|
|
61
|
+
if (event.kind === "authority-snapshot") {
|
|
62
|
+
if (index !== 0 || (prefix && prefix.records.length > 0))
|
|
63
|
+
throw new AuthorityStoreError("corrupt");
|
|
64
|
+
seed = event.state;
|
|
65
|
+
}
|
|
66
|
+
else
|
|
67
|
+
events.push(event);
|
|
68
|
+
records.push(record);
|
|
69
|
+
previous = record.hash;
|
|
70
|
+
lastSeq = record.seq;
|
|
71
|
+
expectedSeq = record.seq + 1;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
lastSeq,
|
|
75
|
+
lastHash: previous,
|
|
76
|
+
records: Object.freeze(prefix ? [...prefix.records, ...records] : records),
|
|
77
|
+
events: Object.freeze(prefix ? [...prefix.events, ...events] : events),
|
|
78
|
+
state: prefix && !seed ? applyAuthorityEvents(prefix.state, events) : projectAuthority(events, seed),
|
|
79
|
+
bytes: Buffer.from(bytes),
|
|
80
|
+
replay: { parsedRecords: records.length, reusedPrefixRecords: prefix?.records.length ?? 0 },
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=authority-journal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-journal.js","sourceRoot":"","sources":["../../../src/core/verified-run/authority-journal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAIN,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,CAAC,MAAM,gBAAgB,GAA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AAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAC1E,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACtE,KAAK,EAAE,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC;QACpG,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE;KAC3F,CAAC;AAAA,CACF","sourcesContent":["import { canonicalJson } from \"../run-journal.ts\";\nimport { AuthorityStoreError } from \"./authority-errors.ts\";\nimport {\n\ttype AuthorityEvent,\n\ttype AuthorityProjection,\n\ttype AuthoritySnapshotState,\n\tapplyAuthorityEvents,\n\tparseAuthorityEvent,\n\tprojectAuthority,\n} from \"./authority-events.ts\";\nimport { digestObject } from \"./storage.ts\";\n\nexport const GENESIS_PREVIOUS = \"0\".repeat(64);\nexport interface AuthorityRecord {\n\treadonly version: 1;\n\treadonly seq: number;\n\treadonly previous: string;\n\treadonly event: AuthorityEvent;\n\treadonly hash: string;\n}\nexport interface ParsedAuthority {\n\treadonly lastSeq: number;\n\treadonly lastHash: string;\n\treadonly records: readonly AuthorityRecord[];\n\treadonly events: readonly AuthorityEvent[];\n\treadonly state: AuthorityProjection;\n\t/** Private copy; reuse requires byte equality, not just mtime, size or inode. */\n\treadonly bytes: Buffer;\n\treadonly replay: { readonly parsedRecords: number; readonly reusedPrefixRecords: number };\n}\nexport function materializeRecord(seq: number, previous: string, event: AuthorityEvent): AuthorityRecord {\n\tconst material = { version: 1 as const, seq, previous, event };\n\treturn Object.freeze({ ...material, hash: digestObject(material) });\n}\nexport function recordLine(record: AuthorityRecord): string {\n\treturn `${canonicalJson(record)}\\n`;\n}\n\n/** Inode/head fencing is checked by the owner before offering a prefix. */\nexport function parseCommitted(bytes: Buffer, prefix?: ParsedAuthority): ParsedAuthority {\n\tif (prefix && (bytes.length < prefix.bytes.length || !prefix.bytes.equals(bytes.subarray(0, prefix.bytes.length))))\n\t\tprefix = undefined;\n\tif (prefix && bytes.length === prefix.bytes.length)\n\t\treturn { ...prefix, replay: { parsedRecords: 0, reusedPrefixRecords: prefix.records.length } };\n\tif (!bytes.length)\n\t\treturn {\n\t\t\tlastSeq: 0,\n\t\t\tlastHash: GENESIS_PREVIOUS,\n\t\t\trecords: Object.freeze([]),\n\t\t\tevents: Object.freeze([]),\n\t\t\tstate: projectAuthority([]),\n\t\t\tbytes: Buffer.alloc(0),\n\t\t\treplay: { parsedRecords: 0, reusedPrefixRecords: 0 },\n\t\t};\n\tif (bytes.at(-1) !== 10) throw new AuthorityStoreError(\"corrupt\");\n\tlet text: string;\n\ttry {\n\t\ttext = new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes.subarray(prefix?.bytes.length ?? 0));\n\t} catch {\n\t\tthrow new AuthorityStoreError(\"corrupt\");\n\t}\n\tconst lines = text.slice(0, -1).split(\"\\n\");\n\tlet seed: AuthoritySnapshotState | undefined;\n\tlet previous = prefix?.lastHash ?? GENESIS_PREVIOUS;\n\tlet expectedSeq = (prefix?.lastSeq ?? 0) + 1;\n\tlet lastSeq = prefix?.lastSeq ?? 0;\n\tconst events: AuthorityEvent[] = [];\n\tconst records: AuthorityRecord[] = [];\n\tfor (const [index, line] of lines.entries()) {\n\t\tlet raw: unknown;\n\t\ttry {\n\t\t\traw = JSON.parse(line);\n\t\t} catch {\n\t\t\tthrow new AuthorityStoreError(\"corrupt\");\n\t\t}\n\t\tif (typeof raw !== \"object\" || raw === null || !(\"event\" in raw)) throw new AuthorityStoreError(\"corrupt\");\n\t\tconst event = parseAuthorityEvent(raw.event);\n\t\tconst record =\n\t\t\tevent.kind === \"authority-snapshot\"\n\t\t\t\t? materializeRecord(event.archivedThroughSequence + 1, event.continuesHash, event)\n\t\t\t\t: materializeRecord(expectedSeq, previous, event);\n\t\tif (canonicalJson(raw) !== canonicalJson(record)) throw new AuthorityStoreError(\"corrupt\");\n\t\tif (event.kind === \"authority-snapshot\") {\n\t\t\tif (index !== 0 || (prefix && prefix.records.length > 0)) throw new AuthorityStoreError(\"corrupt\");\n\t\t\tseed = event.state;\n\t\t} else events.push(event);\n\t\trecords.push(record);\n\t\tprevious = record.hash;\n\t\tlastSeq = record.seq;\n\t\texpectedSeq = record.seq + 1;\n\t}\n\treturn {\n\t\tlastSeq,\n\t\tlastHash: previous,\n\t\trecords: Object.freeze(prefix ? [...prefix.records, ...records] : records),\n\t\tevents: Object.freeze(prefix ? [...prefix.events, ...events] : events),\n\t\tstate: prefix && !seed ? applyAuthorityEvents(prefix.state, events) : projectAuthority(events, seed),\n\t\tbytes: Buffer.from(bytes),\n\t\treplay: { parsedRecords: records.length, reusedPrefixRecords: prefix?.records.length ?? 0 },\n\t};\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type GrantToken, type ResourceClaim, type Sequence } from "../../coordination/types.ts";
|
|
2
|
+
import type { AuthorityEvent, AuthorityGrantRecord, AuthorityProjection } from "./authority-events.ts";
|
|
3
|
+
export declare function assertSameCommandMeaning(grant: AuthorityGrantRecord, request: {
|
|
4
|
+
intentDigest: string;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
incarnation: Sequence;
|
|
7
|
+
claims: readonly ResourceClaim[];
|
|
8
|
+
weight: number;
|
|
9
|
+
}): void;
|
|
10
|
+
export declare function sameGrantToken(left: GrantToken, right: GrantToken): boolean;
|
|
11
|
+
export declare function expiryEvents(state: AuthorityProjection, now: number, epoch: Sequence): AuthorityEvent[];
|
|
12
|
+
export declare function authorizationStillOpen(now: number, deadline: number): boolean;
|
|
13
|
+
//# sourceMappingURL=authority-meaning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-meaning.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/authority-meaning.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAyB,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAExH,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEvG,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE;IACR,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,QAAQ,CAAC;IACtB,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;CACf,GACC,IAAI,CASN;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAQ3E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,cAAc,EAAE,CAavG;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI7E","sourcesContent":["import { sameClaimSet } from \"../../coordination/resource.ts\";\nimport { type GrantToken, type ResourceClaim, SETTLED_EFFECT_STATES, type Sequence } from \"../../coordination/types.ts\";\nimport { AuthorityStoreError } from \"./authority-errors.ts\";\nimport type { AuthorityEvent, AuthorityGrantRecord, AuthorityProjection } from \"./authority-events.ts\";\n\nexport function assertSameCommandMeaning(\n\tgrant: AuthorityGrantRecord,\n\trequest: {\n\t\tintentDigest: string;\n\t\tsessionId: string;\n\t\tincarnation: Sequence;\n\t\tclaims: readonly ResourceClaim[];\n\t\tweight: number;\n\t},\n): void {\n\tif (\n\t\tgrant.intentDigest !== request.intentDigest ||\n\t\tgrant.token.sessionId !== request.sessionId ||\n\t\tgrant.token.sessionIncarnation !== request.incarnation ||\n\t\t!sameClaimSet([...grant.claims], [...request.claims]) ||\n\t\tgrant.weight !== request.weight\n\t)\n\t\tthrow new AuthorityStoreError(\"command_conflict\");\n}\n\nexport function sameGrantToken(left: GrantToken, right: GrantToken): boolean {\n\treturn (\n\t\tleft.authorityEpoch === right.authorityEpoch &&\n\t\tleft.grantSequence === right.grantSequence &&\n\t\tleft.sessionId === right.sessionId &&\n\t\tleft.sessionIncarnation === right.sessionIncarnation &&\n\t\tleft.authorizationDeadline === right.authorizationDeadline\n\t);\n}\n\nexport function expiryEvents(state: AuthorityProjection, now: number, epoch: Sequence): AuthorityEvent[] {\n\tconst expired: AuthorityEvent[] = [];\n\tfor (const grant of state.grants.values()) {\n\t\tif (SETTLED_EFFECT_STATES.has(grant.state) || grant.state === \"quarantined\") continue;\n\t\tif (now < grant.token.authorizationDeadline) continue;\n\t\texpired.push({\n\t\t\tkind: \"authorization-expired\",\n\t\t\tgrantSequence: grant.token.grantSequence,\n\t\t\tauthorityEpoch: epoch,\n\t\t\toutcome: grant.effectLive ? \"quarantined\" : \"cancelled\",\n\t\t});\n\t}\n\treturn expired;\n}\n\nexport function authorizationStillOpen(now: number, deadline: number): boolean {\n\tif (typeof now !== \"number\" || !Number.isSafeInteger(now) || now < 0)\n\t\tthrow new TypeError(\"now must be a nonnegative safe integer\");\n\treturn now < deadline;\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { sameClaimSet } from "../../coordination/resource.js";
|
|
2
|
+
import { SETTLED_EFFECT_STATES } from "../../coordination/types.js";
|
|
3
|
+
import { AuthorityStoreError } from "./authority-errors.js";
|
|
4
|
+
export function assertSameCommandMeaning(grant, request) {
|
|
5
|
+
if (grant.intentDigest !== request.intentDigest ||
|
|
6
|
+
grant.token.sessionId !== request.sessionId ||
|
|
7
|
+
grant.token.sessionIncarnation !== request.incarnation ||
|
|
8
|
+
!sameClaimSet([...grant.claims], [...request.claims]) ||
|
|
9
|
+
grant.weight !== request.weight)
|
|
10
|
+
throw new AuthorityStoreError("command_conflict");
|
|
11
|
+
}
|
|
12
|
+
export function sameGrantToken(left, right) {
|
|
13
|
+
return (left.authorityEpoch === right.authorityEpoch &&
|
|
14
|
+
left.grantSequence === right.grantSequence &&
|
|
15
|
+
left.sessionId === right.sessionId &&
|
|
16
|
+
left.sessionIncarnation === right.sessionIncarnation &&
|
|
17
|
+
left.authorizationDeadline === right.authorizationDeadline);
|
|
18
|
+
}
|
|
19
|
+
export function expiryEvents(state, now, epoch) {
|
|
20
|
+
const expired = [];
|
|
21
|
+
for (const grant of state.grants.values()) {
|
|
22
|
+
if (SETTLED_EFFECT_STATES.has(grant.state) || grant.state === "quarantined")
|
|
23
|
+
continue;
|
|
24
|
+
if (now < grant.token.authorizationDeadline)
|
|
25
|
+
continue;
|
|
26
|
+
expired.push({
|
|
27
|
+
kind: "authorization-expired",
|
|
28
|
+
grantSequence: grant.token.grantSequence,
|
|
29
|
+
authorityEpoch: epoch,
|
|
30
|
+
outcome: grant.effectLive ? "quarantined" : "cancelled",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return expired;
|
|
34
|
+
}
|
|
35
|
+
export function authorizationStillOpen(now, deadline) {
|
|
36
|
+
if (typeof now !== "number" || !Number.isSafeInteger(now) || now < 0)
|
|
37
|
+
throw new TypeError("now must be a nonnegative safe integer");
|
|
38
|
+
return now < deadline;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=authority-meaning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-meaning.js","sourceRoot":"","sources":["../../../src/core/verified-run/authority-me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AAI,KAAK,CAAC,KAAK,KAAK,aAAa;YAAE,SAAS;QACtF,IAAI,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,qBAAqB;YAAE,SAAS;QACtD,OAAO,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,uBAAuB;YAC7B,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,aAAa;YACxC,cAAc,EAAE,KAAK;YACrB,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW;SACvD,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AAAA,CACf;AAED,MAAM,UAAU,sBAAsB,CAAC,GAAW,EAAE,QAAgB,EAAW;IAC9E,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC;QACnE,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;IAC/D,OAAO,GAAG,GAAG,QAAQ,CAAC;AAAA,CACtB","sourcesContent":["import { sameClaimSet } from \"../../coordination/resource.ts\";\nimport { type GrantToken, type ResourceClaim, SETTLED_EFFECT_STATES, type Sequence } from \"../../coordination/types.ts\";\nimport { AuthorityStoreError } from \"./authority-errors.ts\";\nimport type { AuthorityEvent, AuthorityGrantRecord, AuthorityProjection } from \"./authority-events.ts\";\n\nexport function assertSameCommandMeaning(\n\tgrant: AuthorityGrantRecord,\n\trequest: {\n\t\tintentDigest: string;\n\t\tsessionId: string;\n\t\tincarnation: Sequence;\n\t\tclaims: readonly ResourceClaim[];\n\t\tweight: number;\n\t},\n): void {\n\tif (\n\t\tgrant.intentDigest !== request.intentDigest ||\n\t\tgrant.token.sessionId !== request.sessionId ||\n\t\tgrant.token.sessionIncarnation !== request.incarnation ||\n\t\t!sameClaimSet([...grant.claims], [...request.claims]) ||\n\t\tgrant.weight !== request.weight\n\t)\n\t\tthrow new AuthorityStoreError(\"command_conflict\");\n}\n\nexport function sameGrantToken(left: GrantToken, right: GrantToken): boolean {\n\treturn (\n\t\tleft.authorityEpoch === right.authorityEpoch &&\n\t\tleft.grantSequence === right.grantSequence &&\n\t\tleft.sessionId === right.sessionId &&\n\t\tleft.sessionIncarnation === right.sessionIncarnation &&\n\t\tleft.authorizationDeadline === right.authorizationDeadline\n\t);\n}\n\nexport function expiryEvents(state: AuthorityProjection, now: number, epoch: Sequence): AuthorityEvent[] {\n\tconst expired: AuthorityEvent[] = [];\n\tfor (const grant of state.grants.values()) {\n\t\tif (SETTLED_EFFECT_STATES.has(grant.state) || grant.state === \"quarantined\") continue;\n\t\tif (now < grant.token.authorizationDeadline) continue;\n\t\texpired.push({\n\t\t\tkind: \"authorization-expired\",\n\t\t\tgrantSequence: grant.token.grantSequence,\n\t\t\tauthorityEpoch: epoch,\n\t\t\toutcome: grant.effectLive ? \"quarantined\" : \"cancelled\",\n\t\t});\n\t}\n\treturn expired;\n}\n\nexport function authorizationStillOpen(now: number, deadline: number): boolean {\n\tif (typeof now !== \"number\" || !Number.isSafeInteger(now) || now < 0)\n\t\tthrow new TypeError(\"now must be a nonnegative safe integer\");\n\treturn now < deadline;\n}\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Sequence } from "../../coordination/types.ts";
|
|
2
|
+
import type { AuthorityGrantRecord } from "./authority-events.ts";
|
|
3
|
+
import { type AuthorityJournalInspection, type AuthorityProbe, AuthorityStore, type AuthorityStoreHooks } from "./authority-store.ts";
|
|
4
|
+
import { type AuthorityStatus } from "./run-status.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Runtime bridge between the verified-run execution path and the durable
|
|
7
|
+
* `AuthorityStore` (WP03 §8 wiring).
|
|
8
|
+
*
|
|
9
|
+
* `RunAuthority` is the handle the dispatch boundary needs: the open store
|
|
10
|
+
* plus the session identity grants are minted under. `openRunAuthorityStore`
|
|
11
|
+
* is the restart boundary — it advances (or adopts) the durable epoch and
|
|
12
|
+
* finishes reconciliation before any new dispatch may be admitted. The
|
|
13
|
+
* `RunAuthorityPool` keeps one open store per coordinator while work is in
|
|
14
|
+
* flight, because the `"authority"` scope lease is fail-fast: two
|
|
15
|
+
* `AuthorityStore.open` calls on the same state root can never coexist, and a
|
|
16
|
+
* synchronous lock wait cannot be used inside one process.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Reconcile probe for the verified-run boundary. A recorded
|
|
20
|
+
* `NamespaceIdentity` is probed against the real execution boundary. A
|
|
21
|
+
* missing identity is not a termination witness: a lost writer lease does
|
|
22
|
+
* not prove a Git child or hook has exited, and the ref outbox is not that
|
|
23
|
+
* proof either. Those grants stay `"unknown"` until a supervisor witness
|
|
24
|
+
* settles them (F07).
|
|
25
|
+
*/
|
|
26
|
+
export declare function runAuthorityProbe(grant: AuthorityGrantRecord): ReturnType<AuthorityProbe>;
|
|
27
|
+
/** Total admissible weight of concurrently unsettled grants for one state root. */
|
|
28
|
+
export declare const RUN_AUTHORITY_CAPACITY = 16;
|
|
29
|
+
export interface OpenRunAuthorityStoreOptions {
|
|
30
|
+
readonly capacity?: number;
|
|
31
|
+
readonly hooks?: AuthorityStoreHooks;
|
|
32
|
+
readonly probe?: AuthorityProbe;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Open the state root's authority store and reconcile it before returning.
|
|
36
|
+
* The caller owns the store and must `release()` it; `acquire` stays refused
|
|
37
|
+
* (`reconcile_pending`) until this function has run.
|
|
38
|
+
*/
|
|
39
|
+
export declare function openRunAuthorityStore(runPath: string, options?: OpenRunAuthorityStoreOptions): AuthorityStore;
|
|
40
|
+
/** Handle the dispatch boundary records through. */
|
|
41
|
+
export interface RunAuthority {
|
|
42
|
+
readonly store: AuthorityStore;
|
|
43
|
+
readonly sessionId: string;
|
|
44
|
+
readonly incarnation: Sequence;
|
|
45
|
+
}
|
|
46
|
+
/** Read-only view of the durable authority store under a state root. */
|
|
47
|
+
export interface AuthorityStoreView {
|
|
48
|
+
readonly path: string;
|
|
49
|
+
readonly status: AuthorityStatus;
|
|
50
|
+
readonly records: AuthorityJournalInspection["records"];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The durable authority store under this state root: which grant holds
|
|
54
|
+
* which claims, why it is quarantined, and whether termination was
|
|
55
|
+
* witnessed. Read-only; a missing store reads as an empty projection.
|
|
56
|
+
*/
|
|
57
|
+
export declare function inspectRunAuthority(stateRoot: string): AuthorityStoreView;
|
|
58
|
+
/** Standalone open+reconcile+register for entry points without a pool (publish, tests). */
|
|
59
|
+
export declare function openRunAuthority(runPath: string, options?: OpenRunAuthorityStoreOptions): RunAuthority;
|
|
60
|
+
/**
|
|
61
|
+
* One open store per coordinator, ref-counted across in-flight operations.
|
|
62
|
+
* The authority lease is fail-fast and cross-process, so a coordinator-level
|
|
63
|
+
* pool is what lets concurrent operations share the single-writer boundary:
|
|
64
|
+
* the first operation opens (restart reconcile runs there), the last one
|
|
65
|
+
* releases. Session incarnations are registered once per run id per open
|
|
66
|
+
* lifetime — a later operation under a new epoch re-registers and fences the
|
|
67
|
+
* previous incarnation's tokens.
|
|
68
|
+
*/
|
|
69
|
+
export declare class RunAuthorityPool {
|
|
70
|
+
private readonly options;
|
|
71
|
+
private tail;
|
|
72
|
+
private store;
|
|
73
|
+
private users;
|
|
74
|
+
private readonly incarnations;
|
|
75
|
+
constructor(options?: OpenRunAuthorityStoreOptions);
|
|
76
|
+
private step;
|
|
77
|
+
private enter;
|
|
78
|
+
private exit;
|
|
79
|
+
/** Run `work` while holding one shared store slot; the slot releases when every user exits. */
|
|
80
|
+
run<T>(runPath: string, sessionId: string, work: (authority: RunAuthority) => T | Promise<T>): Promise<T>;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=authority-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-runtime.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/authority-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK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gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,4BAAiC,GAAG,YAAY,CAgB1G;AAED;;;;;;;;GAQG;AACH,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+B;IACvD,OAAO,CAAC,IAAI,CAAoC;IAChD,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA+B;IAE5D,YAAY,OAAO,GAAE,4BAAiC,EAErD;IAED,OAAO,CAAC,IAAI;YASE,KAAK;YA+BL,IAAI;IAYlB,+FAA+F;IACzF,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,YAAY,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAO9G;CACD","sourcesContent":["import { basename, dirname, resolve } from \"node:path\";\nimport type { Sequence } from \"../../coordination/types.ts\";\nimport type { AuthorityGrantRecord } from \"./authority-events.ts\";\nimport {\n\ttype AuthorityJournalInspection,\n\ttype AuthorityProbe,\n\tAuthorityStore,\n\ttype AuthorityStoreHooks,\n\tauthorityStorePath,\n} from \"./authority-store.ts\";\nimport { type AuthorityStatus, deriveAuthorityStatus } from \"./run-status.ts\";\nimport { probeOwnedNamespace } from \"./supervisor-adapter.ts\";\n\n/**\n * Runtime bridge between the verified-run execution path and the durable\n * `AuthorityStore` (WP03 §8 wiring).\n *\n * `RunAuthority` is the handle the dispatch boundary needs: the open store\n * plus the session identity grants are minted under. `openRunAuthorityStore`\n * is the restart boundary — it advances (or adopts) the durable epoch and\n * finishes reconciliation before any new dispatch may be admitted. The\n * `RunAuthorityPool` keeps one open store per coordinator while work is in\n * flight, because the `\"authority\"` scope lease is fail-fast: two\n * `AuthorityStore.open` calls on the same state root can never coexist, and a\n * synchronous lock wait cannot be used inside one process.\n */\n\n/**\n * Reconcile probe for the verified-run boundary. A recorded\n * `NamespaceIdentity` is probed against the real execution boundary. A\n * missing identity is not a termination witness: a lost writer lease does\n * not prove a Git child or hook has exited, and the ref outbox is not that\n * proof either. Those grants stay `\"unknown\"` until a supervisor witness\n * settles them (F07).\n */\nexport function runAuthorityProbe(grant: AuthorityGrantRecord): ReturnType<AuthorityProbe> {\n\tif (!grant.identity) return \"unknown\";\n\treturn probeOwnedNamespace(grant.identity);\n}\n\n/** Total admissible weight of concurrently unsettled grants for one state root. */\nexport const RUN_AUTHORITY_CAPACITY = 16;\n\nexport interface OpenRunAuthorityStoreOptions {\n\treadonly capacity?: number;\n\treadonly hooks?: AuthorityStoreHooks;\n\treadonly probe?: AuthorityProbe;\n}\n\n/**\n * Open the state root's authority store and reconcile it before returning.\n * The caller owns the store and must `release()` it; `acquire` stays refused\n * (`reconcile_pending`) until this function has run.\n */\nexport function openRunAuthorityStore(runPath: string, options: OpenRunAuthorityStoreOptions = {}): AuthorityStore {\n\tconst store = AuthorityStore.open(authorityStorePath(dirname(runPath)), {\n\t\tcapacity: options.capacity ?? RUN_AUTHORITY_CAPACITY,\n\t\tprobe: options.probe ?? runAuthorityProbe,\n\t\t...(options.hooks ? { hooks: options.hooks } : {}),\n\t});\n\ttry {\n\t\tstore.reconcile();\n\t} catch (error) {\n\t\ttry {\n\t\t\tstore.release();\n\t\t} catch (releaseError) {\n\t\t\tthrow new AggregateError(\n\t\t\t\t[error, releaseError instanceof Error ? releaseError : new Error(String(releaseError))],\n\t\t\t\t\"Authority store reconcile cleanup failed\",\n\t\t\t);\n\t\t}\n\t\tthrow error;\n\t}\n\treturn store;\n}\n\n/** Handle the dispatch boundary records through. */\nexport interface RunAuthority {\n\treadonly store: AuthorityStore;\n\treadonly sessionId: string;\n\treadonly incarnation: Sequence;\n}\n\n/** Read-only view of the durable authority store under a state root. */\nexport interface AuthorityStoreView {\n\treadonly path: string;\n\treadonly status: AuthorityStatus;\n\treadonly records: AuthorityJournalInspection[\"records\"];\n}\n\n/**\n * The durable authority store under this state root: which grant holds\n * which claims, why it is quarantined, and whether termination was\n * witnessed. Read-only; a missing store reads as an empty projection.\n */\nexport function inspectRunAuthority(stateRoot: string): AuthorityStoreView {\n\tconst path = authorityStorePath(resolve(stateRoot));\n\tconst inspection = AuthorityStore.inspectJournal(path);\n\treturn Object.freeze({\n\t\tpath,\n\t\tstatus: deriveAuthorityStatus(\n\t\t\tinspection.state,\n\t\t\tinspection.records.map((record) => record.event),\n\t\t),\n\t\trecords: inspection.records,\n\t});\n}\n\n/** Standalone open+reconcile+register for entry points without a pool (publish, tests). */\nexport function openRunAuthority(runPath: string, options: OpenRunAuthorityStoreOptions = {}): RunAuthority {\n\tconst store = openRunAuthorityStore(runPath, options);\n\tconst sessionId = basename(runPath);\n\ttry {\n\t\treturn Object.freeze({ store, sessionId, incarnation: store.register(sessionId) });\n\t} catch (error) {\n\t\ttry {\n\t\t\tstore.release();\n\t\t} catch (releaseError) {\n\t\t\tthrow new AggregateError(\n\t\t\t\t[error, releaseError instanceof Error ? releaseError : new Error(String(releaseError))],\n\t\t\t\t\"Authority session cleanup failed\",\n\t\t\t);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * One open store per coordinator, ref-counted across in-flight operations.\n * The authority lease is fail-fast and cross-process, so a coordinator-level\n * pool is what lets concurrent operations share the single-writer boundary:\n * the first operation opens (restart reconcile runs there), the last one\n * releases. Session incarnations are registered once per run id per open\n * lifetime — a later operation under a new epoch re-registers and fences the\n * previous incarnation's tokens.\n */\nexport class RunAuthorityPool {\n\tprivate readonly options: OpenRunAuthorityStoreOptions;\n\tprivate tail: Promise<void> = Promise.resolve();\n\tprivate store: AuthorityStore | null = null;\n\tprivate users = 0;\n\tprivate readonly incarnations = new Map<string, Sequence>();\n\n\tconstructor(options: OpenRunAuthorityStoreOptions = {}) {\n\t\tthis.options = options;\n\t}\n\n\tprivate step<T>(fn: () => T): Promise<T> {\n\t\tconst run = this.tail.then(fn);\n\t\tthis.tail = run.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\treturn run;\n\t}\n\n\tprivate async enter(runPath: string, sessionId: string): Promise<RunAuthority> {\n\t\treturn this.step(() => {\n\t\t\tif (this.users === 0) {\n\t\t\t\tthis.store = openRunAuthorityStore(runPath, this.options);\n\t\t\t\tthis.incarnations.clear();\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tlet incarnation = this.incarnations.get(sessionId);\n\t\t\t\tif (!incarnation) {\n\t\t\t\t\tif (!this.store) throw new Error(\"authority store missing\");\n\t\t\t\t\tincarnation = this.store.register(sessionId);\n\t\t\t\t\tthis.incarnations.set(sessionId, incarnation);\n\t\t\t\t}\n\t\t\t\tconst store = this.store;\n\t\t\t\tif (!store) throw new Error(\"authority store missing\");\n\t\t\t\tthis.users += 1;\n\t\t\t\treturn { store, sessionId, incarnation };\n\t\t\t} catch (error) {\n\t\t\t\tif (this.users === 0 && this.store) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthis.store.release();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tthis.store = null;\n\t\t\t\t\t\tthis.incarnations.clear();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate async exit(): Promise<void> {\n\t\tawait this.step(() => {\n\t\t\tif (this.users > 0) this.users -= 1;\n\t\t\tif (this.users === 0 && this.store) {\n\t\t\t\tconst store = this.store;\n\t\t\t\tthis.store = null;\n\t\t\t\tthis.incarnations.clear();\n\t\t\t\tstore.release();\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Run `work` while holding one shared store slot; the slot releases when every user exits. */\n\tasync run<T>(runPath: string, sessionId: string, work: (authority: RunAuthority) => T | Promise<T>): Promise<T> {\n\t\tconst authority = await this.enter(runPath, sessionId);\n\t\ttry {\n\t\t\treturn await work(authority);\n\t\t} finally {\n\t\t\tawait this.exit();\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { basename, dirname, resolve } from "node:path";
|
|
2
|
+
import { AuthorityStore, authorityStorePath, } from "./authority-store.js";
|
|
3
|
+
import { deriveAuthorityStatus } from "./run-status.js";
|
|
4
|
+
import { probeOwnedNamespace } from "./supervisor-adapter.js";
|
|
5
|
+
/**
|
|
6
|
+
* Runtime bridge between the verified-run execution path and the durable
|
|
7
|
+
* `AuthorityStore` (WP03 §8 wiring).
|
|
8
|
+
*
|
|
9
|
+
* `RunAuthority` is the handle the dispatch boundary needs: the open store
|
|
10
|
+
* plus the session identity grants are minted under. `openRunAuthorityStore`
|
|
11
|
+
* is the restart boundary — it advances (or adopts) the durable epoch and
|
|
12
|
+
* finishes reconciliation before any new dispatch may be admitted. The
|
|
13
|
+
* `RunAuthorityPool` keeps one open store per coordinator while work is in
|
|
14
|
+
* flight, because the `"authority"` scope lease is fail-fast: two
|
|
15
|
+
* `AuthorityStore.open` calls on the same state root can never coexist, and a
|
|
16
|
+
* synchronous lock wait cannot be used inside one process.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Reconcile probe for the verified-run boundary. A recorded
|
|
20
|
+
* `NamespaceIdentity` is probed against the real execution boundary. A
|
|
21
|
+
* missing identity is not a termination witness: a lost writer lease does
|
|
22
|
+
* not prove a Git child or hook has exited, and the ref outbox is not that
|
|
23
|
+
* proof either. Those grants stay `"unknown"` until a supervisor witness
|
|
24
|
+
* settles them (F07).
|
|
25
|
+
*/
|
|
26
|
+
export function runAuthorityProbe(grant) {
|
|
27
|
+
if (!grant.identity)
|
|
28
|
+
return "unknown";
|
|
29
|
+
return probeOwnedNamespace(grant.identity);
|
|
30
|
+
}
|
|
31
|
+
/** Total admissible weight of concurrently unsettled grants for one state root. */
|
|
32
|
+
export const RUN_AUTHORITY_CAPACITY = 16;
|
|
33
|
+
/**
|
|
34
|
+
* Open the state root's authority store and reconcile it before returning.
|
|
35
|
+
* The caller owns the store and must `release()` it; `acquire` stays refused
|
|
36
|
+
* (`reconcile_pending`) until this function has run.
|
|
37
|
+
*/
|
|
38
|
+
export function openRunAuthorityStore(runPath, options = {}) {
|
|
39
|
+
const store = AuthorityStore.open(authorityStorePath(dirname(runPath)), {
|
|
40
|
+
capacity: options.capacity ?? RUN_AUTHORITY_CAPACITY,
|
|
41
|
+
probe: options.probe ?? runAuthorityProbe,
|
|
42
|
+
...(options.hooks ? { hooks: options.hooks } : {}),
|
|
43
|
+
});
|
|
44
|
+
try {
|
|
45
|
+
store.reconcile();
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
try {
|
|
49
|
+
store.release();
|
|
50
|
+
}
|
|
51
|
+
catch (releaseError) {
|
|
52
|
+
throw new AggregateError([error, releaseError instanceof Error ? releaseError : new Error(String(releaseError))], "Authority store reconcile cleanup failed");
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
return store;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The durable authority store under this state root: which grant holds
|
|
60
|
+
* which claims, why it is quarantined, and whether termination was
|
|
61
|
+
* witnessed. Read-only; a missing store reads as an empty projection.
|
|
62
|
+
*/
|
|
63
|
+
export function inspectRunAuthority(stateRoot) {
|
|
64
|
+
const path = authorityStorePath(resolve(stateRoot));
|
|
65
|
+
const inspection = AuthorityStore.inspectJournal(path);
|
|
66
|
+
return Object.freeze({
|
|
67
|
+
path,
|
|
68
|
+
status: deriveAuthorityStatus(inspection.state, inspection.records.map((record) => record.event)),
|
|
69
|
+
records: inspection.records,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** Standalone open+reconcile+register for entry points without a pool (publish, tests). */
|
|
73
|
+
export function openRunAuthority(runPath, options = {}) {
|
|
74
|
+
const store = openRunAuthorityStore(runPath, options);
|
|
75
|
+
const sessionId = basename(runPath);
|
|
76
|
+
try {
|
|
77
|
+
return Object.freeze({ store, sessionId, incarnation: store.register(sessionId) });
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
try {
|
|
81
|
+
store.release();
|
|
82
|
+
}
|
|
83
|
+
catch (releaseError) {
|
|
84
|
+
throw new AggregateError([error, releaseError instanceof Error ? releaseError : new Error(String(releaseError))], "Authority session cleanup failed");
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* One open store per coordinator, ref-counted across in-flight operations.
|
|
91
|
+
* The authority lease is fail-fast and cross-process, so a coordinator-level
|
|
92
|
+
* pool is what lets concurrent operations share the single-writer boundary:
|
|
93
|
+
* the first operation opens (restart reconcile runs there), the last one
|
|
94
|
+
* releases. Session incarnations are registered once per run id per open
|
|
95
|
+
* lifetime — a later operation under a new epoch re-registers and fences the
|
|
96
|
+
* previous incarnation's tokens.
|
|
97
|
+
*/
|
|
98
|
+
export class RunAuthorityPool {
|
|
99
|
+
options;
|
|
100
|
+
tail = Promise.resolve();
|
|
101
|
+
store = null;
|
|
102
|
+
users = 0;
|
|
103
|
+
incarnations = new Map();
|
|
104
|
+
constructor(options = {}) {
|
|
105
|
+
this.options = options;
|
|
106
|
+
}
|
|
107
|
+
step(fn) {
|
|
108
|
+
const run = this.tail.then(fn);
|
|
109
|
+
this.tail = run.then(() => { }, () => { });
|
|
110
|
+
return run;
|
|
111
|
+
}
|
|
112
|
+
async enter(runPath, sessionId) {
|
|
113
|
+
return this.step(() => {
|
|
114
|
+
if (this.users === 0) {
|
|
115
|
+
this.store = openRunAuthorityStore(runPath, this.options);
|
|
116
|
+
this.incarnations.clear();
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
let incarnation = this.incarnations.get(sessionId);
|
|
120
|
+
if (!incarnation) {
|
|
121
|
+
if (!this.store)
|
|
122
|
+
throw new Error("authority store missing");
|
|
123
|
+
incarnation = this.store.register(sessionId);
|
|
124
|
+
this.incarnations.set(sessionId, incarnation);
|
|
125
|
+
}
|
|
126
|
+
const store = this.store;
|
|
127
|
+
if (!store)
|
|
128
|
+
throw new Error("authority store missing");
|
|
129
|
+
this.users += 1;
|
|
130
|
+
return { store, sessionId, incarnation };
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
if (this.users === 0 && this.store) {
|
|
134
|
+
try {
|
|
135
|
+
this.store.release();
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
this.store = null;
|
|
139
|
+
this.incarnations.clear();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async exit() {
|
|
147
|
+
await this.step(() => {
|
|
148
|
+
if (this.users > 0)
|
|
149
|
+
this.users -= 1;
|
|
150
|
+
if (this.users === 0 && this.store) {
|
|
151
|
+
const store = this.store;
|
|
152
|
+
this.store = null;
|
|
153
|
+
this.incarnations.clear();
|
|
154
|
+
store.release();
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/** Run `work` while holding one shared store slot; the slot releases when every user exits. */
|
|
159
|
+
async run(runPath, sessionId, work) {
|
|
160
|
+
const authority = await this.enter(runPath, sessionId);
|
|
161
|
+
try {
|
|
162
|
+
return await work(authority);
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
await this.exit();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=authority-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-runtime.js","sourceRoot":"","sources":["../../../src/core/verified-run/authority-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGvD,OAAO,EAGN,cAAc,EAEd,kBAAkB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAwB,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,mBAA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AAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC;YACJ,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC;QAC9B,CAAC;gBAAS,CAAC;YACV,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC;IAAA,CACD;CACD","sourcesContent":["import { basename, dirname, resolve } from \"node:path\";\nimport type { Sequence } from \"../../coordination/types.ts\";\nimport type { AuthorityGrantRecord } from \"./authority-events.ts\";\nimport {\n\ttype AuthorityJournalInspection,\n\ttype AuthorityProbe,\n\tAuthorityStore,\n\ttype AuthorityStoreHooks,\n\tauthorityStorePath,\n} from \"./authority-store.ts\";\nimport { type AuthorityStatus, deriveAuthorityStatus } from \"./run-status.ts\";\nimport { probeOwnedNamespace } from \"./supervisor-adapter.ts\";\n\n/**\n * Runtime bridge between the verified-run execution path and the durable\n * `AuthorityStore` (WP03 §8 wiring).\n *\n * `RunAuthority` is the handle the dispatch boundary needs: the open store\n * plus the session identity grants are minted under. `openRunAuthorityStore`\n * is the restart boundary — it advances (or adopts) the durable epoch and\n * finishes reconciliation before any new dispatch may be admitted. The\n * `RunAuthorityPool` keeps one open store per coordinator while work is in\n * flight, because the `\"authority\"` scope lease is fail-fast: two\n * `AuthorityStore.open` calls on the same state root can never coexist, and a\n * synchronous lock wait cannot be used inside one process.\n */\n\n/**\n * Reconcile probe for the verified-run boundary. A recorded\n * `NamespaceIdentity` is probed against the real execution boundary. A\n * missing identity is not a termination witness: a lost writer lease does\n * not prove a Git child or hook has exited, and the ref outbox is not that\n * proof either. Those grants stay `\"unknown\"` until a supervisor witness\n * settles them (F07).\n */\nexport function runAuthorityProbe(grant: AuthorityGrantRecord): ReturnType<AuthorityProbe> {\n\tif (!grant.identity) return \"unknown\";\n\treturn probeOwnedNamespace(grant.identity);\n}\n\n/** Total admissible weight of concurrently unsettled grants for one state root. */\nexport const RUN_AUTHORITY_CAPACITY = 16;\n\nexport interface OpenRunAuthorityStoreOptions {\n\treadonly capacity?: number;\n\treadonly hooks?: AuthorityStoreHooks;\n\treadonly probe?: AuthorityProbe;\n}\n\n/**\n * Open the state root's authority store and reconcile it before returning.\n * The caller owns the store and must `release()` it; `acquire` stays refused\n * (`reconcile_pending`) until this function has run.\n */\nexport function openRunAuthorityStore(runPath: string, options: OpenRunAuthorityStoreOptions = {}): AuthorityStore {\n\tconst store = AuthorityStore.open(authorityStorePath(dirname(runPath)), {\n\t\tcapacity: options.capacity ?? RUN_AUTHORITY_CAPACITY,\n\t\tprobe: options.probe ?? runAuthorityProbe,\n\t\t...(options.hooks ? { hooks: options.hooks } : {}),\n\t});\n\ttry {\n\t\tstore.reconcile();\n\t} catch (error) {\n\t\ttry {\n\t\t\tstore.release();\n\t\t} catch (releaseError) {\n\t\t\tthrow new AggregateError(\n\t\t\t\t[error, releaseError instanceof Error ? releaseError : new Error(String(releaseError))],\n\t\t\t\t\"Authority store reconcile cleanup failed\",\n\t\t\t);\n\t\t}\n\t\tthrow error;\n\t}\n\treturn store;\n}\n\n/** Handle the dispatch boundary records through. */\nexport interface RunAuthority {\n\treadonly store: AuthorityStore;\n\treadonly sessionId: string;\n\treadonly incarnation: Sequence;\n}\n\n/** Read-only view of the durable authority store under a state root. */\nexport interface AuthorityStoreView {\n\treadonly path: string;\n\treadonly status: AuthorityStatus;\n\treadonly records: AuthorityJournalInspection[\"records\"];\n}\n\n/**\n * The durable authority store under this state root: which grant holds\n * which claims, why it is quarantined, and whether termination was\n * witnessed. Read-only; a missing store reads as an empty projection.\n */\nexport function inspectRunAuthority(stateRoot: string): AuthorityStoreView {\n\tconst path = authorityStorePath(resolve(stateRoot));\n\tconst inspection = AuthorityStore.inspectJournal(path);\n\treturn Object.freeze({\n\t\tpath,\n\t\tstatus: deriveAuthorityStatus(\n\t\t\tinspection.state,\n\t\t\tinspection.records.map((record) => record.event),\n\t\t),\n\t\trecords: inspection.records,\n\t});\n}\n\n/** Standalone open+reconcile+register for entry points without a pool (publish, tests). */\nexport function openRunAuthority(runPath: string, options: OpenRunAuthorityStoreOptions = {}): RunAuthority {\n\tconst store = openRunAuthorityStore(runPath, options);\n\tconst sessionId = basename(runPath);\n\ttry {\n\t\treturn Object.freeze({ store, sessionId, incarnation: store.register(sessionId) });\n\t} catch (error) {\n\t\ttry {\n\t\t\tstore.release();\n\t\t} catch (releaseError) {\n\t\t\tthrow new AggregateError(\n\t\t\t\t[error, releaseError instanceof Error ? releaseError : new Error(String(releaseError))],\n\t\t\t\t\"Authority session cleanup failed\",\n\t\t\t);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * One open store per coordinator, ref-counted across in-flight operations.\n * The authority lease is fail-fast and cross-process, so a coordinator-level\n * pool is what lets concurrent operations share the single-writer boundary:\n * the first operation opens (restart reconcile runs there), the last one\n * releases. Session incarnations are registered once per run id per open\n * lifetime — a later operation under a new epoch re-registers and fences the\n * previous incarnation's tokens.\n */\nexport class RunAuthorityPool {\n\tprivate readonly options: OpenRunAuthorityStoreOptions;\n\tprivate tail: Promise<void> = Promise.resolve();\n\tprivate store: AuthorityStore | null = null;\n\tprivate users = 0;\n\tprivate readonly incarnations = new Map<string, Sequence>();\n\n\tconstructor(options: OpenRunAuthorityStoreOptions = {}) {\n\t\tthis.options = options;\n\t}\n\n\tprivate step<T>(fn: () => T): Promise<T> {\n\t\tconst run = this.tail.then(fn);\n\t\tthis.tail = run.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\treturn run;\n\t}\n\n\tprivate async enter(runPath: string, sessionId: string): Promise<RunAuthority> {\n\t\treturn this.step(() => {\n\t\t\tif (this.users === 0) {\n\t\t\t\tthis.store = openRunAuthorityStore(runPath, this.options);\n\t\t\t\tthis.incarnations.clear();\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tlet incarnation = this.incarnations.get(sessionId);\n\t\t\t\tif (!incarnation) {\n\t\t\t\t\tif (!this.store) throw new Error(\"authority store missing\");\n\t\t\t\t\tincarnation = this.store.register(sessionId);\n\t\t\t\t\tthis.incarnations.set(sessionId, incarnation);\n\t\t\t\t}\n\t\t\t\tconst store = this.store;\n\t\t\t\tif (!store) throw new Error(\"authority store missing\");\n\t\t\t\tthis.users += 1;\n\t\t\t\treturn { store, sessionId, incarnation };\n\t\t\t} catch (error) {\n\t\t\t\tif (this.users === 0 && this.store) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthis.store.release();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tthis.store = null;\n\t\t\t\t\t\tthis.incarnations.clear();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate async exit(): Promise<void> {\n\t\tawait this.step(() => {\n\t\t\tif (this.users > 0) this.users -= 1;\n\t\t\tif (this.users === 0 && this.store) {\n\t\t\t\tconst store = this.store;\n\t\t\t\tthis.store = null;\n\t\t\t\tthis.incarnations.clear();\n\t\t\t\tstore.release();\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Run `work` while holding one shared store slot; the slot releases when every user exits. */\n\tasync run<T>(runPath: string, sessionId: string, work: (authority: RunAuthority) => T | Promise<T>): Promise<T> {\n\t\tconst authority = await this.enter(runPath, sessionId);\n\t\ttry {\n\t\t\treturn await work(authority);\n\t\t} finally {\n\t\t\tawait this.exit();\n\t\t}\n\t}\n}\n"]}
|