open-multi-agent-kit 1.0.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 +52 -1
- 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/help.d.ts.map +1 -1
- package/dist/cli/help.js +1 -0
- package/dist/cli/help.js.map +1 -1
- 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/awareness.d.ts +32 -0
- package/dist/coordination/awareness.d.ts.map +1 -0
- package/dist/coordination/awareness.js +55 -0
- package/dist/coordination/awareness.js.map +1 -0
- package/dist/coordination/broker.d.ts +79 -0
- package/dist/coordination/broker.d.ts.map +1 -0
- package/dist/coordination/broker.js +202 -0
- package/dist/coordination/broker.js.map +1 -0
- package/dist/coordination/index.d.ts +16 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +16 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/coordination/integration.d.ts +59 -0
- package/dist/coordination/integration.d.ts.map +1 -0
- package/dist/coordination/integration.js +126 -0
- package/dist/coordination/integration.js.map +1 -0
- package/dist/coordination/operation.d.ts +107 -0
- package/dist/coordination/operation.d.ts.map +1 -0
- package/dist/coordination/operation.js +231 -0
- package/dist/coordination/operation.js.map +1 -0
- package/dist/coordination/resource.d.ts +33 -0
- package/dist/coordination/resource.d.ts.map +1 -0
- package/dist/coordination/resource.js +95 -0
- package/dist/coordination/resource.js.map +1 -0
- package/dist/coordination/session.d.ts +74 -0
- package/dist/coordination/session.d.ts.map +1 -0
- package/dist/coordination/session.js +143 -0
- package/dist/coordination/session.js.map +1 -0
- package/dist/coordination/types.d.ts +68 -0
- package/dist/coordination/types.d.ts.map +1 -0
- package/dist/coordination/types.js +26 -0
- package/dist/coordination/types.js.map +1 -0
- 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 +35 -15
- 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/control-state.d.ts +41 -0
- package/dist/core/compaction/control-state.d.ts.map +1 -0
- package/dist/core/compaction/control-state.js +85 -0
- package/dist/core/compaction/control-state.js.map +1 -0
- package/dist/core/compaction/fallback.d.ts +71 -0
- package/dist/core/compaction/fallback.d.ts.map +1 -0
- package/dist/core/compaction/fallback.js +118 -0
- package/dist/core/compaction/fallback.js.map +1 -0
- package/dist/core/compaction/index.d.ts +2 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +2 -0
- package/dist/core/compaction/index.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/context-budget-headroom-candidates.d.ts +16 -1
- package/dist/core/context-budget-headroom-candidates.d.ts.map +1 -1
- package/dist/core/context-budget-headroom-candidates.js +31 -13
- package/dist/core/context-budget-headroom-candidates.js.map +1 -1
- package/dist/core/context-budget-headroom-types.d.ts +7 -1
- package/dist/core/context-budget-headroom-types.d.ts.map +1 -1
- package/dist/core/context-budget-headroom-types.js +0 -1
- package/dist/core/context-budget-headroom-types.js.map +1 -1
- package/dist/core/context-budget-headroom.d.ts +10 -0
- package/dist/core/context-budget-headroom.d.ts.map +1 -1
- package/dist/core/context-budget-headroom.js +11 -2
- package/dist/core/context-budget-headroom.js.map +1 -1
- package/dist/core/context-budget-v2-global-pass.d.ts +21 -0
- package/dist/core/context-budget-v2-global-pass.d.ts.map +1 -0
- package/dist/core/context-budget-v2-global-pass.js +203 -0
- package/dist/core/context-budget-v2-global-pass.js.map +1 -0
- package/dist/core/context-budget-v2-planned-items.d.ts +12 -0
- package/dist/core/context-budget-v2-planned-items.d.ts.map +1 -1
- package/dist/core/context-budget-v2-planned-items.js +21 -2
- package/dist/core/context-budget-v2-planned-items.js.map +1 -1
- package/dist/core/context-budget-v2-planner.d.ts.map +1 -1
- package/dist/core/context-budget-v2-planner.js +18 -19
- package/dist/core/context-budget-v2-planner.js.map +1 -1
- package/dist/core/context-budget-v2-scoring.d.ts +7 -1
- package/dist/core/context-budget-v2-scoring.d.ts.map +1 -1
- package/dist/core/context-budget-v2-scoring.js.map +1 -1
- package/dist/core/context-budget-v2-selection.d.ts +3 -0
- package/dist/core/context-budget-v2-selection.d.ts.map +1 -1
- package/dist/core/context-budget-v2-selection.js +6 -2
- package/dist/core/context-budget-v2-selection.js.map +1 -1
- package/dist/core/context-budget-v2-types.d.ts +6 -1
- package/dist/core/context-budget-v2-types.d.ts.map +1 -1
- package/dist/core/context-budget-v2-types.js +6 -1
- package/dist/core/context-budget-v2-types.js.map +1 -1
- 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-default-models.d.ts +1 -0
- package/dist/core/provider-default-models.d.ts.map +1 -1
- package/dist/core/provider-default-models.js +1 -0
- package/dist/core/provider-default-models.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +1 -0
- package/dist/core/provider-display-names.js.map +1 -1
- 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-resolver.d.ts +7 -0
- package/dist/core/reasoning-router-resolver.d.ts.map +1 -1
- package/dist/core/reasoning-router-resolver.js +21 -3
- package/dist/core/reasoning-router-resolver.js.map +1 -1
- package/dist/core/reasoning-router-v4.d.ts +13 -7
- package/dist/core/reasoning-router-v4.d.ts.map +1 -1
- package/dist/core/reasoning-router-v4.js +8 -5
- 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-compaction-service.d.ts +15 -0
- package/dist/core/session-compaction-service.d.ts.map +1 -1
- package/dist/core/session-compaction-service.js +17 -4
- package/dist/core/session-compaction-service.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/todo-runtime-state.d.ts +12 -0
- package/dist/core/todo-runtime-state.d.ts.map +1 -1
- package/dist/core/todo-runtime-state.js +23 -0
- package/dist/core/todo-runtime-state.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 +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -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 +78 -0
- package/dist/metacognition/calibration-selective.d.ts.map +1 -0
- package/dist/metacognition/calibration-selective.js +167 -0
- package/dist/metacognition/calibration-selective.js.map +1 -0
- package/dist/metacognition/calibration.d.ts +62 -0
- package/dist/metacognition/calibration.d.ts.map +1 -0
- package/dist/metacognition/calibration.js +122 -0
- package/dist/metacognition/calibration.js.map +1 -0
- package/dist/metacognition/checkpoint.d.ts +60 -0
- package/dist/metacognition/checkpoint.d.ts.map +1 -0
- package/dist/metacognition/checkpoint.js +57 -0
- package/dist/metacognition/checkpoint.js.map +1 -0
- package/dist/metacognition/context7.d.ts +48 -0
- package/dist/metacognition/context7.d.ts.map +1 -0
- package/dist/metacognition/context7.js +154 -0
- package/dist/metacognition/context7.js.map +1 -0
- package/dist/metacognition/decision.d.ts +44 -0
- package/dist/metacognition/decision.d.ts.map +1 -0
- package/dist/metacognition/decision.js +111 -0
- package/dist/metacognition/decision.js.map +1 -0
- package/dist/metacognition/evaluation.d.ts +73 -0
- package/dist/metacognition/evaluation.d.ts.map +1 -0
- package/dist/metacognition/evaluation.js +97 -0
- package/dist/metacognition/evaluation.js.map +1 -0
- package/dist/metacognition/index.d.ts +32 -0
- package/dist/metacognition/index.d.ts.map +1 -0
- package/dist/metacognition/index.js +32 -0
- package/dist/metacognition/index.js.map +1 -0
- package/dist/metacognition/knowledge-action.d.ts +43 -0
- package/dist/metacognition/knowledge-action.d.ts.map +1 -0
- package/dist/metacognition/knowledge-action.js +60 -0
- package/dist/metacognition/knowledge-action.js.map +1 -0
- package/dist/metacognition/knowledge.d.ts +84 -0
- package/dist/metacognition/knowledge.d.ts.map +1 -0
- package/dist/metacognition/knowledge.js +165 -0
- package/dist/metacognition/knowledge.js.map +1 -0
- package/dist/metacognition/obligations.d.ts +82 -0
- package/dist/metacognition/obligations.d.ts.map +1 -0
- package/dist/metacognition/obligations.js +139 -0
- package/dist/metacognition/obligations.js.map +1 -0
- package/dist/metacognition/observation-validity.d.ts +83 -0
- package/dist/metacognition/observation-validity.d.ts.map +1 -0
- package/dist/metacognition/observation-validity.js +118 -0
- package/dist/metacognition/observation-validity.js.map +1 -0
- package/dist/metacognition/observe.d.ts +45 -0
- package/dist/metacognition/observe.d.ts.map +1 -0
- package/dist/metacognition/observe.js +59 -0
- package/dist/metacognition/observe.js.map +1 -0
- package/dist/metacognition/policy.d.ts +53 -0
- package/dist/metacognition/policy.d.ts.map +1 -0
- package/dist/metacognition/policy.js +155 -0
- package/dist/metacognition/policy.js.map +1 -0
- package/dist/metacognition/predictions.d.ts +78 -0
- package/dist/metacognition/predictions.d.ts.map +1 -0
- package/dist/metacognition/predictions.js +181 -0
- package/dist/metacognition/predictions.js.map +1 -0
- package/dist/metacognition/retrieval.d.ts +53 -0
- package/dist/metacognition/retrieval.d.ts.map +1 -0
- package/dist/metacognition/retrieval.js +170 -0
- package/dist/metacognition/retrieval.js.map +1 -0
- package/dist/metacognition/risk.d.ts +48 -0
- package/dist/metacognition/risk.d.ts.map +1 -0
- package/dist/metacognition/risk.js +179 -0
- package/dist/metacognition/risk.js.map +1 -0
- package/dist/metacognition/route-economics.d.ts +95 -0
- package/dist/metacognition/route-economics.d.ts.map +1 -0
- package/dist/metacognition/route-economics.js +110 -0
- package/dist/metacognition/route-economics.js.map +1 -0
- package/dist/metacognition/runtime-bridge.d.ts +81 -0
- package/dist/metacognition/runtime-bridge.d.ts.map +1 -0
- package/dist/metacognition/runtime-bridge.js +458 -0
- package/dist/metacognition/runtime-bridge.js.map +1 -0
- package/dist/metacognition/skills.d.ts +42 -0
- package/dist/metacognition/skills.d.ts.map +1 -0
- package/dist/metacognition/skills.js +220 -0
- package/dist/metacognition/skills.js.map +1 -0
- package/dist/metacognition/state.d.ts +110 -0
- package/dist/metacognition/state.d.ts.map +1 -0
- package/dist/metacognition/state.js +52 -0
- package/dist/metacognition/state.js.map +1 -0
- package/dist/metacognition/validation.d.ts +19 -0
- package/dist/metacognition/validation.d.ts.map +1 -0
- package/dist/metacognition/validation.js +58 -0
- package/dist/metacognition/validation.js.map +1 -0
- package/dist/metacognition/verification.d.ts +93 -0
- package/dist/metacognition/verification.d.ts.map +1 -0
- package/dist/metacognition/verification.js +132 -0
- package/dist/metacognition/verification.js.map +1 -0
- package/dist/metacognition/verifier.d.ts +49 -0
- package/dist/metacognition/verifier.d.ts.map +1 -0
- package/dist/metacognition/verifier.js +88 -0
- package/dist/metacognition/verifier.js.map +1 -0
- 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/observation/identity.d.ts +14 -0
- package/dist/observation/identity.d.ts.map +1 -0
- package/dist/observation/identity.js +29 -0
- package/dist/observation/identity.js.map +1 -0
- package/dist/observation/index.d.ts +13 -0
- package/dist/observation/index.d.ts.map +1 -0
- package/dist/observation/index.js +13 -0
- package/dist/observation/index.js.map +1 -0
- package/dist/observation/observe-mode.d.ts +46 -0
- package/dist/observation/observe-mode.d.ts.map +1 -0
- package/dist/observation/observe-mode.js +83 -0
- package/dist/observation/observe-mode.js.map +1 -0
- package/dist/observation/store.d.ts +53 -0
- package/dist/observation/store.d.ts.map +1 -0
- package/dist/observation/store.js +126 -0
- package/dist/observation/store.js.map +1 -0
- package/dist/observation/types.d.ts +72 -0
- package/dist/observation/types.d.ts.map +1 -0
- package/dist/observation/types.js +9 -0
- package/dist/observation/types.js.map +1 -0
- package/dist/observation/view.d.ts +39 -0
- package/dist/observation/view.d.ts.map +1 -0
- package/dist/observation/view.js +173 -0
- package/dist/observation/view.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 +130 -0
- package/docs/model-catalog-refresh.md +218 -1
- package/docs/models.md +1 -1
- package/docs/providers.md +53 -0
- package/docs/runtime-algorithms.md +156 -7
- 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
|
@@ -1,46 +1,139 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
2
3
|
import { performance } from "node:perf_hooks";
|
|
3
4
|
import { executeSandbox } from "./broker.js";
|
|
4
|
-
import { VerifiedRunError } from "./storage.js";
|
|
5
|
-
/**
|
|
5
|
+
import { digestObject, VerifiedRunError } from "./storage.js";
|
|
6
|
+
/**
|
|
7
|
+
* The filesystem claim a dispatched process is authorized for: exactly the
|
|
8
|
+
* workspace bind it receives inside the namespace — nothing wider. Keys are
|
|
9
|
+
* the resolved absolute path minus the leading slash so prefix containment
|
|
10
|
+
* matches real tree containment; `realpathSync` keeps two spellings of the
|
|
11
|
+
* same directory one claim.
|
|
12
|
+
*/
|
|
13
|
+
function workspaceClaim(workspace, access, generation) {
|
|
14
|
+
let root;
|
|
15
|
+
try {
|
|
16
|
+
root = realpathSync(workspace);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
throw new VerifiedRunError("authority_claim");
|
|
20
|
+
}
|
|
21
|
+
return Object.freeze([
|
|
22
|
+
{
|
|
23
|
+
namespace: "filesystem",
|
|
24
|
+
instanceId: "verified-run",
|
|
25
|
+
canonicalKey: root.replace(/^\/+/, ""),
|
|
26
|
+
access,
|
|
27
|
+
generation: String(generation),
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
/** Rejection codes that can only be produced before the supervisor spawned. */
|
|
32
|
+
const NEVER_SPAWNED = new Set(["cancelled", "deadline", "unsupported_boundary"]);
|
|
33
|
+
/**
|
|
34
|
+
* Mandatory durable dispatch intent, shared by command and AgentSession
|
|
35
|
+
* writers. There is no ungated execution lane: a journal without an anchored
|
|
36
|
+
* budget cannot commit a process identity, so the supervisor boundary would
|
|
37
|
+
* be unprovable and must refuse dispatch. Every dispatch now also crosses the
|
|
38
|
+
* durable authority boundary — grant → intent → start → termination witness
|
|
39
|
+
* — so a restart can reconcile effects the journal alone cannot settle.
|
|
40
|
+
*/
|
|
6
41
|
export async function executeRunCommand(journal, request, policy) {
|
|
7
42
|
if (Math.floor(request.deadline - performance.now()) <= 0)
|
|
8
43
|
throw new VerifiedRunError("deadline");
|
|
9
44
|
if (policy.signal?.aborted)
|
|
10
45
|
throw new VerifiedRunError("cancelled");
|
|
46
|
+
// The supervisor boundary only exists once a budget (and therefore the
|
|
47
|
+
// gated driver) is anchored. Dispatching without it would run code whose
|
|
48
|
+
// termination cannot be witnessed — refuse rather than degrade.
|
|
49
|
+
if (!journal.state.budget)
|
|
50
|
+
throw new VerifiedRunError("unsupported_boundary");
|
|
51
|
+
const authority = policy.authority;
|
|
11
52
|
const generation = journal.state.generation;
|
|
12
53
|
const executionId = randomUUID();
|
|
13
|
-
|
|
14
|
-
kind: "dispatch",
|
|
15
|
-
executionId,
|
|
16
|
-
role: request.role,
|
|
17
|
-
claimId: request.claimId,
|
|
18
|
-
...(request.taskId === undefined ? {} : { taskId: request.taskId }),
|
|
19
|
-
});
|
|
54
|
+
const claims = workspaceClaim(request.workspace, request.role === "writer" ? "write" : "read", generation);
|
|
20
55
|
const timeoutMs = Math.floor(request.deadline - performance.now());
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
writable: request.role === "writer",
|
|
30
|
-
timeoutMs,
|
|
31
|
-
cleanupMs: policy.cleanupMs,
|
|
32
|
-
maxOutputBytes: policy.maxOutputBytes,
|
|
33
|
-
...(policy.signal ? { signal: policy.signal } : {}),
|
|
34
|
-
...(journal.state.budget
|
|
35
|
-
? {
|
|
36
|
-
onReady: (identity) => {
|
|
37
|
-
if (journal.state.generation !== generation)
|
|
38
|
-
throw new VerifiedRunError("stale_generation");
|
|
39
|
-
journal.append({ kind: "process_ready", executionId, identity });
|
|
40
|
-
},
|
|
41
|
-
}
|
|
42
|
-
: {}),
|
|
56
|
+
const admission = authority.store.acquire({
|
|
57
|
+
sessionId: authority.sessionId,
|
|
58
|
+
incarnation: authority.incarnation,
|
|
59
|
+
commandId: executionId,
|
|
60
|
+
intentDigest: digestObject({ argv: request.argv, claims, role: request.role }),
|
|
61
|
+
claims,
|
|
62
|
+
now: Date.now(),
|
|
63
|
+
ttl: timeoutMs + policy.cleanupMs + 30000,
|
|
43
64
|
});
|
|
65
|
+
if (admission.status !== "granted") {
|
|
66
|
+
// A fresh executionId can only collide with a conflicting or wedged
|
|
67
|
+
// claim — quarantined effects hold theirs until witnessed (fail closed).
|
|
68
|
+
throw new VerifiedRunError("authority_blocked");
|
|
69
|
+
}
|
|
70
|
+
const token = admission.token;
|
|
71
|
+
let supervisorInvoked = false;
|
|
72
|
+
let readyObserved = false;
|
|
73
|
+
let result;
|
|
74
|
+
try {
|
|
75
|
+
journal.append({
|
|
76
|
+
kind: "dispatch",
|
|
77
|
+
executionId,
|
|
78
|
+
role: request.role,
|
|
79
|
+
claimId: request.claimId,
|
|
80
|
+
...(request.taskId === undefined ? {} : { taskId: request.taskId }),
|
|
81
|
+
});
|
|
82
|
+
if (timeoutMs <= 0 || policy.signal?.aborted) {
|
|
83
|
+
const failure = policy.signal?.aborted ? "cancelled" : "deadline";
|
|
84
|
+
// Provably pre-spawn: the intent never reached the adapter, so the grant
|
|
85
|
+
// settles immediately instead of wedging as an unwitnessed live effect.
|
|
86
|
+
authority.store.cancel(token);
|
|
87
|
+
authority.store.confirmTerminated(token);
|
|
88
|
+
journal.append({ kind: "exited", executionId, failure });
|
|
89
|
+
throw new VerifiedRunError(failure);
|
|
90
|
+
}
|
|
91
|
+
// The intent commits before the adapter is invoked: from this record on,
|
|
92
|
+
// the effect may be live and a crash must quarantine it, never assume
|
|
93
|
+
// it did not run.
|
|
94
|
+
if (!authority.store.dispatchIntent(token, executionId))
|
|
95
|
+
throw new VerifiedRunError("authority");
|
|
96
|
+
supervisorInvoked = true;
|
|
97
|
+
result = await executeSandbox({
|
|
98
|
+
workspace: request.workspace,
|
|
99
|
+
argv: request.argv,
|
|
100
|
+
writable: request.role === "writer",
|
|
101
|
+
timeoutMs: Math.floor(request.deadline - performance.now()),
|
|
102
|
+
cleanupMs: policy.cleanupMs,
|
|
103
|
+
maxOutputBytes: policy.maxOutputBytes,
|
|
104
|
+
...(policy.signal ? { signal: policy.signal } : {}),
|
|
105
|
+
onReady: (identity) => {
|
|
106
|
+
readyObserved = true;
|
|
107
|
+
if (journal.state.generation !== generation)
|
|
108
|
+
throw new VerifiedRunError("stale_generation");
|
|
109
|
+
journal.append({ kind: "process_ready", executionId, identity });
|
|
110
|
+
if (!authority.store.effectStarted(token, claims, identity))
|
|
111
|
+
throw new VerifiedRunError("authority");
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
// Only pre-spawn rejections prove nothing ran; everything else may have
|
|
117
|
+
// a live or dying effect, which stays owned until a witness or a later
|
|
118
|
+
// reconcile settles it.
|
|
119
|
+
try {
|
|
120
|
+
authority.store.cancel(token);
|
|
121
|
+
if (!supervisorInvoked ||
|
|
122
|
+
(!readyObserved && error instanceof VerifiedRunError && NEVER_SPAWNED.has(error.code)))
|
|
123
|
+
authority.store.confirmTerminated(token);
|
|
124
|
+
}
|
|
125
|
+
catch (cleanupError) {
|
|
126
|
+
throw new AggregateError([error, cleanupError], "Execution ownership cleanup failed");
|
|
127
|
+
}
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
if (result.failure === "cancelled")
|
|
131
|
+
authority.store.cancel(token);
|
|
132
|
+
// Resolve means both witnesses fired: the direct child closed and the
|
|
133
|
+
// recorded namespace drained empty. That is the termination-observed event
|
|
134
|
+
// — the grant releases its claims here and nowhere else.
|
|
135
|
+
if (!authority.store.confirmTerminated(token))
|
|
136
|
+
throw new VerifiedRunError("authority");
|
|
44
137
|
if (journal.state.generation !== generation)
|
|
45
138
|
throw new VerifiedRunError("stale_generation");
|
|
46
139
|
journal.append({ kind: "exited", executionId, failure: request.role === "writer" ? result.failure : null });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owned-execution.js","sourceRoot":"","sources":["../../../src/core/verified-run/owned-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAgBhD,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,OAA2B,EAC3B,OAAwB,EACxB,MAIC,EACyB;IAC1B,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAClG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO;QAAE,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC;IAC5C,MAAM,WAAW,GAAG,UAAU,EAAE,CAAC;IACjC,OAAO,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,UAAU;QAChB,WAAW;QACX,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;KACnE,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAC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C,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5G,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAAA,CAC1C","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { performance } from \"node:perf_hooks\";\nimport { executeSandbox, type SandboxOutcome } from \"./broker.ts\";\nimport type { VerifiedRunJournal } from \"./journal.ts\";\nimport type { NamespaceIdentity } from \"./namespace-identity.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nexport interface OwnedRunCommand {\n\treadonly role: \"writer\" | \"verifier\";\n\treadonly argv: readonly string[];\n\treadonly workspace: string;\n\treadonly deadline: number;\n\treadonly claimId: string | null;\n\treadonly taskId?: string;\n}\nexport interface OwnedRunResult {\n\treadonly executionId: string;\n\treadonly result: SandboxOutcome;\n\treadonly timeoutMs: number;\n}\n\n/** The mandatory durable intent boundary is shared by command and AgentSession writers. */\nexport async function executeRunCommand(\n\tjournal: VerifiedRunJournal,\n\trequest: OwnedRunCommand,\n\tpolicy: {\n\t\treadonly cleanupMs: number;\n\t\treadonly maxOutputBytes: number;\n\t\treadonly signal?: AbortSignal;\n\t},\n): Promise<OwnedRunResult> {\n\tif (Math.floor(request.deadline - performance.now()) <= 0) throw new VerifiedRunError(\"deadline\");\n\tif (policy.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\tconst generation = journal.state.generation;\n\tconst executionId = randomUUID();\n\tjournal.append({\n\t\tkind: \"dispatch\",\n\t\texecutionId,\n\t\trole: request.role,\n\t\tclaimId: request.claimId,\n\t\t...(request.taskId === undefined ? {} : { taskId: request.taskId }),\n\t});\n\tconst timeoutMs = Math.floor(request.deadline - performance.now());\n\tif (timeoutMs <= 0 || policy.signal?.aborted) {\n\t\tconst failure = policy.signal?.aborted ? \"cancelled\" : \"deadline\";\n\t\tjournal.append({ kind: \"exited\", executionId, failure });\n\t\tthrow new VerifiedRunError(failure);\n\t}\n\tconst result = await executeSandbox({\n\t\tworkspace: request.workspace,\n\t\targv: request.argv,\n\t\twritable: request.role === \"writer\",\n\t\ttimeoutMs,\n\t\tcleanupMs: policy.cleanupMs,\n\t\tmaxOutputBytes: policy.maxOutputBytes,\n\t\t...(policy.signal ? { signal: policy.signal } : {}),\n\t\t...(journal.state.budget\n\t\t\t? {\n\t\t\t\t\tonReady: (identity: NamespaceIdentity) => {\n\t\t\t\t\t\tif (journal.state.generation !== generation) throw new VerifiedRunError(\"stale_generation\");\n\t\t\t\t\t\tjournal.append({ kind: \"process_ready\", executionId, identity });\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t});\n\tif (journal.state.generation !== generation) throw new VerifiedRunError(\"stale_generation\");\n\tjournal.append({ kind: \"exited\", executionId, failure: request.role === \"writer\" ? result.failure : null });\n\treturn { executionId, result, timeoutMs };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"owned-execution.js","sourceRoot":"","sources":["../../../src/core/verified-run/owned-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9C,OAAO,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAgB9D;;;;;;GAMG;AACH,SAAS,cAAc,CACtB,SAAiB,EACjB,MAAwB,EACxB,UAAkB,EACc;IAChC,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACJ,IAAI,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACR,MAAM,IAAI,gBAAgB,CA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,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5G,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAAA,CAC1C","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { realpathSync } from \"node:fs\";\nimport { performance } from \"node:perf_hooks\";\nimport type { ResourceClaimInput } from \"../../coordination/resource.ts\";\nimport type { GrantToken } from \"../../coordination/types.ts\";\nimport type { RunAuthority } from \"./authority-runtime.ts\";\nimport { executeSandbox, type SandboxOutcome } from \"./broker.ts\";\nimport type { VerifiedRunJournal } from \"./journal.ts\";\nimport type { NamespaceIdentity } from \"./namespace-identity.ts\";\nimport { digestObject, VerifiedRunError } from \"./storage.ts\";\n\nexport interface OwnedRunCommand {\n\treadonly role: \"writer\" | \"verifier\";\n\treadonly argv: readonly string[];\n\treadonly workspace: string;\n\treadonly deadline: number;\n\treadonly claimId: string | null;\n\treadonly taskId?: string;\n}\nexport interface OwnedRunResult {\n\treadonly executionId: string;\n\treadonly result: SandboxOutcome;\n\treadonly timeoutMs: number;\n}\n\n/**\n * The filesystem claim a dispatched process is authorized for: exactly the\n * workspace bind it receives inside the namespace — nothing wider. Keys are\n * the resolved absolute path minus the leading slash so prefix containment\n * matches real tree containment; `realpathSync` keeps two spellings of the\n * same directory one claim.\n */\nfunction workspaceClaim(\n\tworkspace: string,\n\taccess: \"read\" | \"write\",\n\tgeneration: number,\n): readonly ResourceClaimInput[] {\n\tlet root: string;\n\ttry {\n\t\troot = realpathSync(workspace);\n\t} catch {\n\t\tthrow new VerifiedRunError(\"authority_claim\");\n\t}\n\treturn Object.freeze([\n\t\t{\n\t\t\tnamespace: \"filesystem\",\n\t\t\tinstanceId: \"verified-run\",\n\t\t\tcanonicalKey: root.replace(/^\\/+/, \"\"),\n\t\t\taccess,\n\t\t\tgeneration: String(generation),\n\t\t},\n\t]);\n}\n\n/** Rejection codes that can only be produced before the supervisor spawned. */\nconst NEVER_SPAWNED = new Set([\"cancelled\", \"deadline\", \"unsupported_boundary\"]);\n\n/**\n * Mandatory durable dispatch intent, shared by command and AgentSession\n * writers. There is no ungated execution lane: a journal without an anchored\n * budget cannot commit a process identity, so the supervisor boundary would\n * be unprovable and must refuse dispatch. Every dispatch now also crosses the\n * durable authority boundary — grant → intent → start → termination witness\n * — so a restart can reconcile effects the journal alone cannot settle.\n */\nexport async function executeRunCommand(\n\tjournal: VerifiedRunJournal,\n\trequest: OwnedRunCommand,\n\tpolicy: {\n\t\treadonly cleanupMs: number;\n\t\treadonly maxOutputBytes: number;\n\t\treadonly authority: RunAuthority;\n\t\treadonly signal?: AbortSignal;\n\t},\n): Promise<OwnedRunResult> {\n\tif (Math.floor(request.deadline - performance.now()) <= 0) throw new VerifiedRunError(\"deadline\");\n\tif (policy.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\t// The supervisor boundary only exists once a budget (and therefore the\n\t// gated driver) is anchored. Dispatching without it would run code whose\n\t// termination cannot be witnessed — refuse rather than degrade.\n\tif (!journal.state.budget) throw new VerifiedRunError(\"unsupported_boundary\");\n\tconst authority = policy.authority;\n\tconst generation = journal.state.generation;\n\tconst executionId = randomUUID();\n\tconst claims = workspaceClaim(request.workspace, request.role === \"writer\" ? \"write\" : \"read\", generation);\n\tconst timeoutMs = Math.floor(request.deadline - performance.now());\n\tconst admission = authority.store.acquire({\n\t\tsessionId: authority.sessionId,\n\t\tincarnation: authority.incarnation,\n\t\tcommandId: executionId,\n\t\tintentDigest: digestObject({ argv: request.argv, claims, role: request.role }),\n\t\tclaims,\n\t\tnow: Date.now(),\n\t\tttl: timeoutMs + policy.cleanupMs + 30000,\n\t});\n\tif (admission.status !== \"granted\") {\n\t\t// A fresh executionId can only collide with a conflicting or wedged\n\t\t// claim — quarantined effects hold theirs until witnessed (fail closed).\n\t\tthrow new VerifiedRunError(\"authority_blocked\");\n\t}\n\tconst token: GrantToken = admission.token;\n\tlet supervisorInvoked = false;\n\tlet readyObserved = false;\n\tlet result: SandboxOutcome;\n\ttry {\n\t\tjournal.append({\n\t\t\tkind: \"dispatch\",\n\t\t\texecutionId,\n\t\t\trole: request.role,\n\t\t\tclaimId: request.claimId,\n\t\t\t...(request.taskId === undefined ? {} : { taskId: request.taskId }),\n\t\t});\n\t\tif (timeoutMs <= 0 || policy.signal?.aborted) {\n\t\t\tconst failure = policy.signal?.aborted ? \"cancelled\" : \"deadline\";\n\t\t\t// Provably pre-spawn: the intent never reached the adapter, so the grant\n\t\t\t// settles immediately instead of wedging as an unwitnessed live effect.\n\t\t\tauthority.store.cancel(token);\n\t\t\tauthority.store.confirmTerminated(token);\n\t\t\tjournal.append({ kind: \"exited\", executionId, failure });\n\t\t\tthrow new VerifiedRunError(failure);\n\t\t}\n\t\t// The intent commits before the adapter is invoked: from this record on,\n\t\t// the effect may be live and a crash must quarantine it, never assume\n\t\t// it did not run.\n\t\tif (!authority.store.dispatchIntent(token, executionId)) throw new VerifiedRunError(\"authority\");\n\t\tsupervisorInvoked = true;\n\t\tresult = await executeSandbox({\n\t\t\tworkspace: request.workspace,\n\t\t\targv: request.argv,\n\t\t\twritable: request.role === \"writer\",\n\t\t\ttimeoutMs: Math.floor(request.deadline - performance.now()),\n\t\t\tcleanupMs: policy.cleanupMs,\n\t\t\tmaxOutputBytes: policy.maxOutputBytes,\n\t\t\t...(policy.signal ? { signal: policy.signal } : {}),\n\t\t\tonReady: (identity: NamespaceIdentity) => {\n\t\t\t\treadyObserved = true;\n\t\t\t\tif (journal.state.generation !== generation) throw new VerifiedRunError(\"stale_generation\");\n\t\t\t\tjournal.append({ kind: \"process_ready\", executionId, identity });\n\t\t\t\tif (!authority.store.effectStarted(token, claims, identity)) throw new VerifiedRunError(\"authority\");\n\t\t\t},\n\t\t});\n\t} catch (error) {\n\t\t// Only pre-spawn rejections prove nothing ran; everything else may have\n\t\t// a live or dying effect, which stays owned until a witness or a later\n\t\t// reconcile settles it.\n\t\ttry {\n\t\t\tauthority.store.cancel(token);\n\t\t\tif (\n\t\t\t\t!supervisorInvoked ||\n\t\t\t\t(!readyObserved && error instanceof VerifiedRunError && NEVER_SPAWNED.has(error.code))\n\t\t\t)\n\t\t\t\tauthority.store.confirmTerminated(token);\n\t\t} catch (cleanupError) {\n\t\t\tthrow new AggregateError([error, cleanupError], \"Execution ownership cleanup failed\");\n\t\t}\n\t\tthrow error;\n\t}\n\tif (result.failure === \"cancelled\") authority.store.cancel(token);\n\t// Resolve means both witnesses fired: the direct child closed and the\n\t// recorded namespace drained empty. That is the termination-observed event\n\t// — the grant releases its claims here and nowhere else.\n\tif (!authority.store.confirmTerminated(token)) throw new VerifiedRunError(\"authority\");\n\tif (journal.state.generation !== generation) throw new VerifiedRunError(\"stale_generation\");\n\tjournal.append({ kind: \"exited\", executionId, failure: request.role === \"writer\" ? result.failure : null });\n\treturn { executionId, result, timeoutMs };\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { RunContract } from "omk-protocol";
|
|
2
|
+
import type { RunAuthority } from "./authority-runtime.ts";
|
|
2
3
|
import type { VerifiedRunJournal } from "./journal.ts";
|
|
3
4
|
export interface RunPhaseContext {
|
|
4
5
|
readonly contract: RunContract;
|
|
5
6
|
readonly runPath: string;
|
|
6
7
|
readonly journal: VerifiedRunJournal;
|
|
8
|
+
readonly authority: RunAuthority;
|
|
7
9
|
readonly signal?: AbortSignal;
|
|
8
10
|
}
|
|
9
11
|
//# sourceMappingURL=phase-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phase-context.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/phase-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B","sourcesContent":["import type { RunContract } from \"omk-protocol\";\nimport type { VerifiedRunJournal } from \"./journal.ts\";\n\nexport interface RunPhaseContext {\n\treadonly contract: RunContract;\n\treadonly runPath: string;\n\treadonly journal: VerifiedRunJournal;\n\treadonly signal?: AbortSignal;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"phase-context.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/phase-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B","sourcesContent":["import type { RunContract } from \"omk-protocol\";\nimport type { RunAuthority } from \"./authority-runtime.ts\";\nimport type { VerifiedRunJournal } from \"./journal.ts\";\n\nexport interface RunPhaseContext {\n\treadonly contract: RunContract;\n\treadonly runPath: string;\n\treadonly journal: VerifiedRunJournal;\n\treadonly authority: RunAuthority;\n\treadonly signal?: AbortSignal;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phase-context.js","sourceRoot":"","sources":["../../../src/core/verified-run/phase-context.ts"],"names":[],"mappings":"","sourcesContent":["import type { RunContract } from \"omk-protocol\";\nimport type { VerifiedRunJournal } from \"./journal.ts\";\n\nexport interface RunPhaseContext {\n\treadonly contract: RunContract;\n\treadonly runPath: string;\n\treadonly journal: VerifiedRunJournal;\n\treadonly signal?: AbortSignal;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"phase-context.js","sourceRoot":"","sources":["../../../src/core/verified-run/phase-context.ts"],"names":[],"mappings":"","sourcesContent":["import type { RunContract } from \"omk-protocol\";\nimport type { RunAuthority } from \"./authority-runtime.ts\";\nimport type { VerifiedRunJournal } from \"./journal.ts\";\n\nexport interface RunPhaseContext {\n\treadonly contract: RunContract;\n\treadonly runPath: string;\n\treadonly journal: VerifiedRunJournal;\n\treadonly authority: RunAuthority;\n\treadonly signal?: AbortSignal;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/projection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAmB,MAAM,gBAAgB,CAAC;AAI/E,iGAAiG;AACjG,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/projection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAmB,MAAM,gBAAgB,CAAC;AAI/E,iGAAiG;AACjG,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,aAAa,CA0OrE","sourcesContent":["import { reduceDagEvent } from \"./dag-projection.ts\";\nimport type { RunTaskProjection } from \"./dag-types.ts\";\nimport { type ProcessReduction, reduceProcessEvent } from \"./process-projection.ts\";\nimport { reduceRecoveryEvent } from \"./recovery-projection.ts\";\nimport type { RunEvent, RunProjection, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { reduceWriterEvent } from \"./writer-projection.ts\";\n\n/** Deterministic replay only. Recovery observations are supplied by the trusted host adapter. */\nexport function projectRun(events: readonly RunEvent[]): RunProjection {\n\tconst first = events[0];\n\tif (first?.kind !== \"created\" || first.contract.runId !== first.command.runId)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tconst context: WriterReduction = {\n\t\tcontract: first.contract,\n\t\twriterFinished: false,\n\t\twriterStarted: false,\n\t\tproducerStarted: false,\n\t\twriterCommands: 0,\n\t\trequestBaseline: 0,\n\t\trequests: new Set(),\n\t\tstate: {\n\t\t\trunId: first.contract.runId,\n\t\t\trevision: 1,\n\t\t\tgeneration: 1,\n\t\t\texecution: \"ready\",\n\t\t\tsettlement: \"open\",\n\t\t\tverification: \"not_requested\",\n\t\t\tapplication: \"not_requested\",\n\t\t\tpublication: \"none\",\n\t\t\tpublicationCandidateOid: null,\n\t\t\tpublicationRef: null,\n\t\t\tpublicationCommandId: null,\n\t\t\tpublicationFailure: null,\n\t\t\tcandidateDigest: null,\n\t\t\tinputDigest: null,\n\t\t\treceiptDigest: null,\n\t\t\tfailure: null,\n\t\t\tlastRecovery: null,\n\t\t\tactiveExecutionIds: [],\n\t\t\twriterOpen: false,\n\t\t\tmodelRequests: 0,\n\t\t\ttasks:\n\t\t\t\tfirst.contract.profile === \"linux-command-dag-v1\"\n\t\t\t\t\t? first.contract.writer.tasks.map(\n\t\t\t\t\t\t\t(task): RunTaskProjection => ({\n\t\t\t\t\t\t\t\ttaskId: task.id,\n\t\t\t\t\t\t\t\tattempt: 0,\n\t\t\t\t\t\t\t\tgeneration: 1,\n\t\t\t\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\t\t\t\tinputDigest: null,\n\t\t\t\t\t\t\t\toutputDigest: null,\n\t\t\t\t\t\t\t\tfailure: null,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: [],\n\t\t\tbudget: null,\n\t\t\tenvironmentDigest: null,\n\t\t\tverificationDeadlineMs: null,\n\t\t\tlastClockMs: null,\n\t\t\tprocesses: [],\n\t\t},\n\t};\n\tconst progress: ProcessReduction = { dispatched: new Set(), checked: new Set(), activeRole: \"writer\" };\n\tconst commands = new Set([first.command.commandId]);\n\tfor (const event of events.slice(1)) {\n\t\tconst state = context.state;\n\t\tif (state.execution === \"failed\") throw new VerifiedRunError(\"integrity\");\n\t\tif (\n\t\t\tstate.receiptDigest &&\n\t\t\tevent.kind !== \"publish_intent\" &&\n\t\t\tevent.kind !== \"published\" &&\n\t\t\tevent.kind !== \"publish_failed\"\n\t\t)\n\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\tswitch (event.kind) {\n\t\t\tcase \"created\":\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcase \"budget_anchored\": {\n\t\t\t\tconst budget = event.budget;\n\t\t\t\tconst limits = first.contract.budget;\n\t\t\t\tif (\n\t\t\t\t\tstate.revision !== 1 ||\n\t\t\t\t\tstate.budget ||\n\t\t\t\t\tbudget.workDeadlineMs - budget.startedMs !== limits.workMs ||\n\t\t\t\t\tbudget.verifyCapMs - budget.workDeadlineMs !== limits.verifyMs ||\n\t\t\t\t\tbudget.cleanupDeadlineMs - budget.verifyCapMs !== limits.cleanupMs\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tbudget,\n\t\t\t\t\tenvironmentDigest: event.environmentDigest,\n\t\t\t\t\tlastClockMs: budget.startedMs,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"input_checkpoint\":\n\t\t\t\tif (\n\t\t\t\t\tstate.revision !== 2 ||\n\t\t\t\t\t!state.budget ||\n\t\t\t\t\tstate.inputDigest ||\n\t\t\t\t\tevent.digest !== first.contract.workspace.baseDigest\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = { ...state, inputDigest: event.digest };\n\t\t\t\tbreak;\n\t\t\tcase \"task_started\":\n\t\t\tcase \"task_finished\":\n\t\t\tcase \"tasks_paused\":\n\t\t\t\treduceDagEvent(context, event);\n\t\t\t\tbreak;\n\t\t\tcase \"writer_opened\":\n\t\t\tcase \"model_request\":\n\t\t\tcase \"writer_closed\":\n\t\t\t\treduceWriterEvent(context, event);\n\t\t\t\tbreak;\n\t\t\tcase \"dispatch\":\n\t\t\tcase \"process_ready\":\n\t\t\tcase \"exited\":\n\t\t\t\treduceProcessEvent(context, event, progress);\n\t\t\t\tbreak;\n\t\t\tcase \"candidate\": {\n\t\t\t\tif (\n\t\t\t\t\t!context.writerFinished ||\n\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\tstate.failure ||\n\t\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t\tstate.candidateDigest ||\n\t\t\t\t\tstate.tasks.some((task) => task.status !== \"succeeded\" || task.generation !== state.generation)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tif (state.budget) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.observedMs === undefined ||\n\t\t\t\t\t\tevent.verificationDeadlineMs === undefined ||\n\t\t\t\t\t\tevent.observedMs < state.budget.startedMs ||\n\t\t\t\t\t\tevent.observedMs > state.budget.workDeadlineMs ||\n\t\t\t\t\t\tevent.verificationDeadlineMs !==\n\t\t\t\t\t\t\tMath.min(event.observedMs + first.contract.budget.verifyMs, state.budget.verifyCapMs)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\t} else if (event.observedMs !== undefined || event.verificationDeadlineMs !== undefined)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tcandidateDigest: event.digest,\n\t\t\t\t\tverificationDeadlineMs: event.verificationDeadlineMs ?? null,\n\t\t\t\t\tlastClockMs: event.observedMs ?? null,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"resumed\":\n\t\t\tcase \"tasks_retried\":\n\t\t\tcase \"writer_restarted\":\n\t\t\t\treduceRecoveryEvent(context, event, {\n\t\t\t\t\tcommands,\n\t\t\t\t\tchecked: progress.checked,\n\t\t\t\t\tactiveRole: progress.activeRole,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"evaluated\":\n\t\t\t\tif (\n\t\t\t\t\t!state.candidateDigest ||\n\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t\tprogress.checked.size !== first.contract.checks.length ||\n\t\t\t\t\t(event.verified && state.failure)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\treceiptDigest: event.receiptDigest,\n\t\t\t\t\texecution: \"succeeded\",\n\t\t\t\t\tverification: event.verified ? \"verified\" : \"violated\",\n\t\t\t\t\tapplication: event.verified ? \"candidate_ready\" : \"not_requested\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"failed\":\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\texecution: \"failed\",\n\t\t\t\t\tfailure: event.code,\n\t\t\t\t\tverification: \"inconclusive\",\n\t\t\t\t\tsettlement: state.activeExecutionIds.length || state.writerOpen ? \"quarantined\" : \"settled\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"publish_intent\":\n\t\t\t\tif (\n\t\t\t\t\tstate.verification !== \"verified\" ||\n\t\t\t\t\tstate.application !== \"candidate_ready\" ||\n\t\t\t\t\tstate.settlement !== \"settled\" ||\n\t\t\t\t\t!state.receiptDigest ||\n\t\t\t\t\tstate.receiptDigest !== event.receiptDigest ||\n\t\t\t\t\tstate.candidateDigest !== event.candidateDigest ||\n\t\t\t\t\tstate.generation !== event.generation ||\n\t\t\t\t\tevent.targetRef !== \"refs/omk/accepted\" ||\n\t\t\t\t\tstate.publication === \"intent\" ||\n\t\t\t\t\tstate.publication === \"accepted\"\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tpublication: \"intent\",\n\t\t\t\t\tpublicationCandidateOid: event.candidateOid,\n\t\t\t\t\tpublicationRef: event.targetRef,\n\t\t\t\t\tpublicationCommandId: event.commandId,\n\t\t\t\t\tpublicationFailure: null,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"published\":\n\t\t\t\tif (\n\t\t\t\t\tstate.publication !== \"intent\" ||\n\t\t\t\t\tstate.publicationCommandId !== event.commandId ||\n\t\t\t\t\tstate.publicationCandidateOid !== event.candidateOid\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = { ...state, publication: \"accepted\", publicationCommandId: null };\n\t\t\t\tbreak;\n\t\t\tcase \"publish_failed\":\n\t\t\t\tif (state.publication !== \"intent\" || state.publicationCommandId !== event.commandId)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tpublication: event.code === \"reconciliation-required\" ? \"reconciliation_required\" : \"failed\",\n\t\t\t\t\tpublicationCommandId: null,\n\t\t\t\t\tpublicationFailure: event.code,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tconst exhaustive: never = event;\n\t\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t\t}\n\t\t}\n\t\tcontext.state = { ...context.state, revision: state.revision + 1 };\n\t}\n\treturn Object.freeze({\n\t\t...context.state,\n\t\tlastRecovery: context.state.lastRecovery ? Object.freeze(context.state.lastRecovery) : null,\n\t\tactiveExecutionIds: Object.freeze([...context.state.activeExecutionIds]),\n\t\tprocesses: Object.freeze(context.state.processes.map((item) => Object.freeze(item))),\n\t\ttasks: Object.freeze(context.state.tasks.map((task) => Object.freeze(task))),\n\t});\n}\n"]}
|
|
@@ -24,10 +24,16 @@ export function projectRun(events) {
|
|
|
24
24
|
settlement: "open",
|
|
25
25
|
verification: "not_requested",
|
|
26
26
|
application: "not_requested",
|
|
27
|
+
publication: "none",
|
|
28
|
+
publicationCandidateOid: null,
|
|
29
|
+
publicationRef: null,
|
|
30
|
+
publicationCommandId: null,
|
|
31
|
+
publicationFailure: null,
|
|
27
32
|
candidateDigest: null,
|
|
28
33
|
inputDigest: null,
|
|
29
34
|
receiptDigest: null,
|
|
30
35
|
failure: null,
|
|
36
|
+
lastRecovery: null,
|
|
31
37
|
activeExecutionIds: [],
|
|
32
38
|
writerOpen: false,
|
|
33
39
|
modelRequests: 0,
|
|
@@ -53,7 +59,12 @@ export function projectRun(events) {
|
|
|
53
59
|
const commands = new Set([first.command.commandId]);
|
|
54
60
|
for (const event of events.slice(1)) {
|
|
55
61
|
const state = context.state;
|
|
56
|
-
if (state.execution === "failed"
|
|
62
|
+
if (state.execution === "failed")
|
|
63
|
+
throw new VerifiedRunError("integrity");
|
|
64
|
+
if (state.receiptDigest &&
|
|
65
|
+
event.kind !== "publish_intent" &&
|
|
66
|
+
event.kind !== "published" &&
|
|
67
|
+
event.kind !== "publish_failed")
|
|
57
68
|
throw new VerifiedRunError("integrity");
|
|
58
69
|
switch (event.kind) {
|
|
59
70
|
case "created":
|
|
@@ -158,6 +169,44 @@ export function projectRun(events) {
|
|
|
158
169
|
settlement: state.activeExecutionIds.length || state.writerOpen ? "quarantined" : "settled",
|
|
159
170
|
};
|
|
160
171
|
break;
|
|
172
|
+
case "publish_intent":
|
|
173
|
+
if (state.verification !== "verified" ||
|
|
174
|
+
state.application !== "candidate_ready" ||
|
|
175
|
+
state.settlement !== "settled" ||
|
|
176
|
+
!state.receiptDigest ||
|
|
177
|
+
state.receiptDigest !== event.receiptDigest ||
|
|
178
|
+
state.candidateDigest !== event.candidateDigest ||
|
|
179
|
+
state.generation !== event.generation ||
|
|
180
|
+
event.targetRef !== "refs/omk/accepted" ||
|
|
181
|
+
state.publication === "intent" ||
|
|
182
|
+
state.publication === "accepted")
|
|
183
|
+
throw new VerifiedRunError("integrity");
|
|
184
|
+
context.state = {
|
|
185
|
+
...state,
|
|
186
|
+
publication: "intent",
|
|
187
|
+
publicationCandidateOid: event.candidateOid,
|
|
188
|
+
publicationRef: event.targetRef,
|
|
189
|
+
publicationCommandId: event.commandId,
|
|
190
|
+
publicationFailure: null,
|
|
191
|
+
};
|
|
192
|
+
break;
|
|
193
|
+
case "published":
|
|
194
|
+
if (state.publication !== "intent" ||
|
|
195
|
+
state.publicationCommandId !== event.commandId ||
|
|
196
|
+
state.publicationCandidateOid !== event.candidateOid)
|
|
197
|
+
throw new VerifiedRunError("integrity");
|
|
198
|
+
context.state = { ...state, publication: "accepted", publicationCommandId: null };
|
|
199
|
+
break;
|
|
200
|
+
case "publish_failed":
|
|
201
|
+
if (state.publication !== "intent" || state.publicationCommandId !== event.commandId)
|
|
202
|
+
throw new VerifiedRunError("integrity");
|
|
203
|
+
context.state = {
|
|
204
|
+
...state,
|
|
205
|
+
publication: event.code === "reconciliation-required" ? "reconciliation_required" : "failed",
|
|
206
|
+
publicationCommandId: null,
|
|
207
|
+
publicationFailure: event.code,
|
|
208
|
+
};
|
|
209
|
+
break;
|
|
161
210
|
default: {
|
|
162
211
|
const exhaustive = event;
|
|
163
212
|
throw new VerifiedRunError(String(exhaustive));
|
|
@@ -167,6 +216,7 @@ export function projectRun(events) {
|
|
|
167
216
|
}
|
|
168
217
|
return Object.freeze({
|
|
169
218
|
...context.state,
|
|
219
|
+
lastRecovery: context.state.lastRecovery ? Object.freeze(context.state.lastRecovery) : null,
|
|
170
220
|
activeExecutionIds: Object.freeze([...context.state.activeExecutionIds]),
|
|
171
221
|
processes: Object.freeze(context.state.processes.map((item) => Object.freeze(item))),
|
|
172
222
|
tasks: Object.freeze(context.state.tasks.map((task) => Object.freeze(task))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../../../src/core/verified-run/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAyB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,iGAAiG;AACjG,MAAM,UAAU,UAAU,CAAC,MAA2B,EAAiB;IACtE,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,KAAK,EAAE,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK;QAC5E,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,OAAO,GAAoB;QAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,cAAc,EAAE,KAAK;QACrB,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,CAAC;QACjB,eAAe,EAAE,CAAC;QAClB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,KAAK,EAAE;YACN,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK;YAC3B,QAAQ,EAAE,CAAC;YACX,UAAU,EAAE,CAAC;YACb,SAAS,EAAE,OAAO;YAClB,UAAU,EAAE,MAAM;YAClB,YAAY,EAAE,eAAe;YAC7B,WAAW,EAAE,eAAe;YAC5B,eAAe,EAAE,IAAI;YACrB,WAAW,EAAE,IAAI;YACjB,aAAa,EAAE,IAAI;YACnB,OAAO,EAAE,IAAI;YACb,kBAAkB,EAAE,E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,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;iBAC3F,CAAC;gBACF,MAAM;YACP,SAAS,CAAC;gBACT,MAAM,UAAU,GAAU,KAAK,CAAC;gBAChC,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;QACD,OAAO,CAAC,KAAK,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;IACpE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACpB,GAAG,OAAO,CAAC,KAAK;QAChB,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACxE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;KAC5E,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { reduceDagEvent } from \"./dag-projection.ts\";\nimport type { RunTaskProjection } from \"./dag-types.ts\";\nimport { type ProcessReduction, reduceProcessEvent } from \"./process-projection.ts\";\nimport { reduceRecoveryEvent } from \"./recovery-projection.ts\";\nimport type { RunEvent, RunProjection, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { reduceWriterEvent } from \"./writer-projection.ts\";\n\n/** Deterministic replay only. Recovery observations are supplied by the trusted host adapter. */\nexport function projectRun(events: readonly RunEvent[]): RunProjection {\n\tconst first = events[0];\n\tif (first?.kind !== \"created\" || first.contract.runId !== first.command.runId)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tconst context: WriterReduction = {\n\t\tcontract: first.contract,\n\t\twriterFinished: false,\n\t\twriterStarted: false,\n\t\tproducerStarted: false,\n\t\twriterCommands: 0,\n\t\trequestBaseline: 0,\n\t\trequests: new Set(),\n\t\tstate: {\n\t\t\trunId: first.contract.runId,\n\t\t\trevision: 1,\n\t\t\tgeneration: 1,\n\t\t\texecution: \"ready\",\n\t\t\tsettlement: \"open\",\n\t\t\tverification: \"not_requested\",\n\t\t\tapplication: \"not_requested\",\n\t\t\tcandidateDigest: null,\n\t\t\tinputDigest: null,\n\t\t\treceiptDigest: null,\n\t\t\tfailure: null,\n\t\t\tactiveExecutionIds: [],\n\t\t\twriterOpen: false,\n\t\t\tmodelRequests: 0,\n\t\t\ttasks:\n\t\t\t\tfirst.contract.profile === \"linux-command-dag-v1\"\n\t\t\t\t\t? first.contract.writer.tasks.map(\n\t\t\t\t\t\t\t(task): RunTaskProjection => ({\n\t\t\t\t\t\t\t\ttaskId: task.id,\n\t\t\t\t\t\t\t\tattempt: 0,\n\t\t\t\t\t\t\t\tgeneration: 1,\n\t\t\t\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\t\t\t\tinputDigest: null,\n\t\t\t\t\t\t\t\toutputDigest: null,\n\t\t\t\t\t\t\t\tfailure: null,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: [],\n\t\t\tbudget: null,\n\t\t\tenvironmentDigest: null,\n\t\t\tverificationDeadlineMs: null,\n\t\t\tlastClockMs: null,\n\t\t\tprocesses: [],\n\t\t},\n\t};\n\tconst progress: ProcessReduction = { dispatched: new Set(), checked: new Set(), activeRole: \"writer\" };\n\tconst commands = new Set([first.command.commandId]);\n\tfor (const event of events.slice(1)) {\n\t\tconst state = context.state;\n\t\tif (state.execution === \"failed\" || state.receiptDigest) throw new VerifiedRunError(\"integrity\");\n\t\tswitch (event.kind) {\n\t\t\tcase \"created\":\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcase \"budget_anchored\": {\n\t\t\t\tconst budget = event.budget;\n\t\t\t\tconst limits = first.contract.budget;\n\t\t\t\tif (\n\t\t\t\t\tstate.revision !== 1 ||\n\t\t\t\t\tstate.budget ||\n\t\t\t\t\tbudget.workDeadlineMs - budget.startedMs !== limits.workMs ||\n\t\t\t\t\tbudget.verifyCapMs - budget.workDeadlineMs !== limits.verifyMs ||\n\t\t\t\t\tbudget.cleanupDeadlineMs - budget.verifyCapMs !== limits.cleanupMs\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tbudget,\n\t\t\t\t\tenvironmentDigest: event.environmentDigest,\n\t\t\t\t\tlastClockMs: budget.startedMs,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"input_checkpoint\":\n\t\t\t\tif (\n\t\t\t\t\tstate.revision !== 2 ||\n\t\t\t\t\t!state.budget ||\n\t\t\t\t\tstate.inputDigest ||\n\t\t\t\t\tevent.digest !== first.contract.workspace.baseDigest\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = { ...state, inputDigest: event.digest };\n\t\t\t\tbreak;\n\t\t\tcase \"task_started\":\n\t\t\tcase \"task_finished\":\n\t\t\tcase \"tasks_paused\":\n\t\t\t\treduceDagEvent(context, event);\n\t\t\t\tbreak;\n\t\t\tcase \"writer_opened\":\n\t\t\tcase \"model_request\":\n\t\t\tcase \"writer_closed\":\n\t\t\t\treduceWriterEvent(context, event);\n\t\t\t\tbreak;\n\t\t\tcase \"dispatch\":\n\t\t\tcase \"process_ready\":\n\t\t\tcase \"exited\":\n\t\t\t\treduceProcessEvent(context, event, progress);\n\t\t\t\tbreak;\n\t\t\tcase \"candidate\": {\n\t\t\t\tif (\n\t\t\t\t\t!context.writerFinished ||\n\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\tstate.failure ||\n\t\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t\tstate.candidateDigest ||\n\t\t\t\t\tstate.tasks.some((task) => task.status !== \"succeeded\" || task.generation !== state.generation)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tif (state.budget) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.observedMs === undefined ||\n\t\t\t\t\t\tevent.verificationDeadlineMs === undefined ||\n\t\t\t\t\t\tevent.observedMs < state.budget.startedMs ||\n\t\t\t\t\t\tevent.observedMs > state.budget.workDeadlineMs ||\n\t\t\t\t\t\tevent.verificationDeadlineMs !==\n\t\t\t\t\t\t\tMath.min(event.observedMs + first.contract.budget.verifyMs, state.budget.verifyCapMs)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\t} else if (event.observedMs !== undefined || event.verificationDeadlineMs !== undefined)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tcandidateDigest: event.digest,\n\t\t\t\t\tverificationDeadlineMs: event.verificationDeadlineMs ?? null,\n\t\t\t\t\tlastClockMs: event.observedMs ?? null,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"resumed\":\n\t\t\tcase \"tasks_retried\":\n\t\t\tcase \"writer_restarted\":\n\t\t\t\treduceRecoveryEvent(context, event, {\n\t\t\t\t\tcommands,\n\t\t\t\t\tchecked: progress.checked,\n\t\t\t\t\tactiveRole: progress.activeRole,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"evaluated\":\n\t\t\t\tif (\n\t\t\t\t\t!state.candidateDigest ||\n\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t\tprogress.checked.size !== first.contract.checks.length ||\n\t\t\t\t\t(event.verified && state.failure)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\treceiptDigest: event.receiptDigest,\n\t\t\t\t\texecution: \"succeeded\",\n\t\t\t\t\tverification: event.verified ? \"verified\" : \"violated\",\n\t\t\t\t\tapplication: event.verified ? \"candidate_ready\" : \"not_requested\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"failed\":\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\texecution: \"failed\",\n\t\t\t\t\tfailure: event.code,\n\t\t\t\t\tverification: \"inconclusive\",\n\t\t\t\t\tsettlement: state.activeExecutionIds.length || state.writerOpen ? \"quarantined\" : \"settled\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tconst exhaustive: never = event;\n\t\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t\t}\n\t\t}\n\t\tcontext.state = { ...context.state, revision: state.revision + 1 };\n\t}\n\treturn Object.freeze({\n\t\t...context.state,\n\t\tactiveExecutionIds: Object.freeze([...context.state.activeExecutionIds]),\n\t\tprocesses: Object.freeze(context.state.processes.map((item) => Object.freeze(item))),\n\t\ttasks: Object.freeze(context.state.tasks.map((task) => Object.freeze(task))),\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../../../src/core/verified-run/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAyB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,i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,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;KAC5E,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { reduceDagEvent } from \"./dag-projection.ts\";\nimport type { RunTaskProjection } from \"./dag-types.ts\";\nimport { type ProcessReduction, reduceProcessEvent } from \"./process-projection.ts\";\nimport { reduceRecoveryEvent } from \"./recovery-projection.ts\";\nimport type { RunEvent, RunProjection, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { reduceWriterEvent } from \"./writer-projection.ts\";\n\n/** Deterministic replay only. Recovery observations are supplied by the trusted host adapter. */\nexport function projectRun(events: readonly RunEvent[]): RunProjection {\n\tconst first = events[0];\n\tif (first?.kind !== \"created\" || first.contract.runId !== first.command.runId)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tconst context: WriterReduction = {\n\t\tcontract: first.contract,\n\t\twriterFinished: false,\n\t\twriterStarted: false,\n\t\tproducerStarted: false,\n\t\twriterCommands: 0,\n\t\trequestBaseline: 0,\n\t\trequests: new Set(),\n\t\tstate: {\n\t\t\trunId: first.contract.runId,\n\t\t\trevision: 1,\n\t\t\tgeneration: 1,\n\t\t\texecution: \"ready\",\n\t\t\tsettlement: \"open\",\n\t\t\tverification: \"not_requested\",\n\t\t\tapplication: \"not_requested\",\n\t\t\tpublication: \"none\",\n\t\t\tpublicationCandidateOid: null,\n\t\t\tpublicationRef: null,\n\t\t\tpublicationCommandId: null,\n\t\t\tpublicationFailure: null,\n\t\t\tcandidateDigest: null,\n\t\t\tinputDigest: null,\n\t\t\treceiptDigest: null,\n\t\t\tfailure: null,\n\t\t\tlastRecovery: null,\n\t\t\tactiveExecutionIds: [],\n\t\t\twriterOpen: false,\n\t\t\tmodelRequests: 0,\n\t\t\ttasks:\n\t\t\t\tfirst.contract.profile === \"linux-command-dag-v1\"\n\t\t\t\t\t? first.contract.writer.tasks.map(\n\t\t\t\t\t\t\t(task): RunTaskProjection => ({\n\t\t\t\t\t\t\t\ttaskId: task.id,\n\t\t\t\t\t\t\t\tattempt: 0,\n\t\t\t\t\t\t\t\tgeneration: 1,\n\t\t\t\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\t\t\t\tinputDigest: null,\n\t\t\t\t\t\t\t\toutputDigest: null,\n\t\t\t\t\t\t\t\tfailure: null,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t: [],\n\t\t\tbudget: null,\n\t\t\tenvironmentDigest: null,\n\t\t\tverificationDeadlineMs: null,\n\t\t\tlastClockMs: null,\n\t\t\tprocesses: [],\n\t\t},\n\t};\n\tconst progress: ProcessReduction = { dispatched: new Set(), checked: new Set(), activeRole: \"writer\" };\n\tconst commands = new Set([first.command.commandId]);\n\tfor (const event of events.slice(1)) {\n\t\tconst state = context.state;\n\t\tif (state.execution === \"failed\") throw new VerifiedRunError(\"integrity\");\n\t\tif (\n\t\t\tstate.receiptDigest &&\n\t\t\tevent.kind !== \"publish_intent\" &&\n\t\t\tevent.kind !== \"published\" &&\n\t\t\tevent.kind !== \"publish_failed\"\n\t\t)\n\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\tswitch (event.kind) {\n\t\t\tcase \"created\":\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcase \"budget_anchored\": {\n\t\t\t\tconst budget = event.budget;\n\t\t\t\tconst limits = first.contract.budget;\n\t\t\t\tif (\n\t\t\t\t\tstate.revision !== 1 ||\n\t\t\t\t\tstate.budget ||\n\t\t\t\t\tbudget.workDeadlineMs - budget.startedMs !== limits.workMs ||\n\t\t\t\t\tbudget.verifyCapMs - budget.workDeadlineMs !== limits.verifyMs ||\n\t\t\t\t\tbudget.cleanupDeadlineMs - budget.verifyCapMs !== limits.cleanupMs\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tbudget,\n\t\t\t\t\tenvironmentDigest: event.environmentDigest,\n\t\t\t\t\tlastClockMs: budget.startedMs,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"input_checkpoint\":\n\t\t\t\tif (\n\t\t\t\t\tstate.revision !== 2 ||\n\t\t\t\t\t!state.budget ||\n\t\t\t\t\tstate.inputDigest ||\n\t\t\t\t\tevent.digest !== first.contract.workspace.baseDigest\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = { ...state, inputDigest: event.digest };\n\t\t\t\tbreak;\n\t\t\tcase \"task_started\":\n\t\t\tcase \"task_finished\":\n\t\t\tcase \"tasks_paused\":\n\t\t\t\treduceDagEvent(context, event);\n\t\t\t\tbreak;\n\t\t\tcase \"writer_opened\":\n\t\t\tcase \"model_request\":\n\t\t\tcase \"writer_closed\":\n\t\t\t\treduceWriterEvent(context, event);\n\t\t\t\tbreak;\n\t\t\tcase \"dispatch\":\n\t\t\tcase \"process_ready\":\n\t\t\tcase \"exited\":\n\t\t\t\treduceProcessEvent(context, event, progress);\n\t\t\t\tbreak;\n\t\t\tcase \"candidate\": {\n\t\t\t\tif (\n\t\t\t\t\t!context.writerFinished ||\n\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\tstate.failure ||\n\t\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t\tstate.candidateDigest ||\n\t\t\t\t\tstate.tasks.some((task) => task.status !== \"succeeded\" || task.generation !== state.generation)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tif (state.budget) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.observedMs === undefined ||\n\t\t\t\t\t\tevent.verificationDeadlineMs === undefined ||\n\t\t\t\t\t\tevent.observedMs < state.budget.startedMs ||\n\t\t\t\t\t\tevent.observedMs > state.budget.workDeadlineMs ||\n\t\t\t\t\t\tevent.verificationDeadlineMs !==\n\t\t\t\t\t\t\tMath.min(event.observedMs + first.contract.budget.verifyMs, state.budget.verifyCapMs)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\t} else if (event.observedMs !== undefined || event.verificationDeadlineMs !== undefined)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tcandidateDigest: event.digest,\n\t\t\t\t\tverificationDeadlineMs: event.verificationDeadlineMs ?? null,\n\t\t\t\t\tlastClockMs: event.observedMs ?? null,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"resumed\":\n\t\t\tcase \"tasks_retried\":\n\t\t\tcase \"writer_restarted\":\n\t\t\t\treduceRecoveryEvent(context, event, {\n\t\t\t\t\tcommands,\n\t\t\t\t\tchecked: progress.checked,\n\t\t\t\t\tactiveRole: progress.activeRole,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"evaluated\":\n\t\t\t\tif (\n\t\t\t\t\t!state.candidateDigest ||\n\t\t\t\t\tstate.writerOpen ||\n\t\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t\tprogress.checked.size !== first.contract.checks.length ||\n\t\t\t\t\t(event.verified && state.failure)\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\treceiptDigest: event.receiptDigest,\n\t\t\t\t\texecution: \"succeeded\",\n\t\t\t\t\tverification: event.verified ? \"verified\" : \"violated\",\n\t\t\t\t\tapplication: event.verified ? \"candidate_ready\" : \"not_requested\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"failed\":\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\texecution: \"failed\",\n\t\t\t\t\tfailure: event.code,\n\t\t\t\t\tverification: \"inconclusive\",\n\t\t\t\t\tsettlement: state.activeExecutionIds.length || state.writerOpen ? \"quarantined\" : \"settled\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"publish_intent\":\n\t\t\t\tif (\n\t\t\t\t\tstate.verification !== \"verified\" ||\n\t\t\t\t\tstate.application !== \"candidate_ready\" ||\n\t\t\t\t\tstate.settlement !== \"settled\" ||\n\t\t\t\t\t!state.receiptDigest ||\n\t\t\t\t\tstate.receiptDigest !== event.receiptDigest ||\n\t\t\t\t\tstate.candidateDigest !== event.candidateDigest ||\n\t\t\t\t\tstate.generation !== event.generation ||\n\t\t\t\t\tevent.targetRef !== \"refs/omk/accepted\" ||\n\t\t\t\t\tstate.publication === \"intent\" ||\n\t\t\t\t\tstate.publication === \"accepted\"\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tpublication: \"intent\",\n\t\t\t\t\tpublicationCandidateOid: event.candidateOid,\n\t\t\t\t\tpublicationRef: event.targetRef,\n\t\t\t\t\tpublicationCommandId: event.commandId,\n\t\t\t\t\tpublicationFailure: null,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"published\":\n\t\t\t\tif (\n\t\t\t\t\tstate.publication !== \"intent\" ||\n\t\t\t\t\tstate.publicationCommandId !== event.commandId ||\n\t\t\t\t\tstate.publicationCandidateOid !== event.candidateOid\n\t\t\t\t)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = { ...state, publication: \"accepted\", publicationCommandId: null };\n\t\t\t\tbreak;\n\t\t\tcase \"publish_failed\":\n\t\t\t\tif (state.publication !== \"intent\" || state.publicationCommandId !== event.commandId)\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t\tcontext.state = {\n\t\t\t\t\t...state,\n\t\t\t\t\tpublication: event.code === \"reconciliation-required\" ? \"reconciliation_required\" : \"failed\",\n\t\t\t\t\tpublicationCommandId: null,\n\t\t\t\t\tpublicationFailure: event.code,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tconst exhaustive: never = event;\n\t\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t\t}\n\t\t}\n\t\tcontext.state = { ...context.state, revision: state.revision + 1 };\n\t}\n\treturn Object.freeze({\n\t\t...context.state,\n\t\tlastRecovery: context.state.lastRecovery ? Object.freeze(context.state.lastRecovery) : null,\n\t\tactiveExecutionIds: Object.freeze([...context.state.activeExecutionIds]),\n\t\tprocesses: Object.freeze(context.state.processes.map((item) => Object.freeze(item))),\n\t\ttasks: Object.freeze(context.state.tasks.map((task) => Object.freeze(task))),\n\t});\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RunContract, RunPublishCommand } from "omk-protocol";
|
|
2
|
+
import type { JournalSnapshot } from "./journal.ts";
|
|
3
|
+
import type { RunProjection } from "./run-types.ts";
|
|
4
|
+
export declare function publishPolicyDigest(contract: RunContract): string;
|
|
5
|
+
export declare function assertPublishable(snapshot: JournalSnapshot, command: RunPublishCommand, runPath: string): {
|
|
6
|
+
readonly contract: RunContract;
|
|
7
|
+
readonly state: RunProjection & {
|
|
8
|
+
readonly candidateDigest: string;
|
|
9
|
+
readonly receiptDigest: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=publish-preflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-preflight.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/publish-preflight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAInE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAOjE;AAED,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACb;IACF,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG;QAAE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;CACrG,CA6BA","sourcesContent":["import type { RunContract, RunPublishCommand } from \"omk-protocol\";\nimport { commandEnvironmentDigest } from \"./broker.ts\";\nimport { readRunEvidence } from \"./evidence.ts\";\nimport { OMK_ACCEPTED_REF } from \"./git-plumbing.ts\";\nimport type { JournalSnapshot } from \"./journal.ts\";\nimport type { RunProjection } from \"./run-types.ts\";\nimport { digestObject, VerifiedRunError } from \"./storage.ts\";\n\nexport function publishPolicyDigest(contract: RunContract): string {\n\treturn digestObject({\n\t\tapply: contract.apply,\n\t\tprofile: contract.profile,\n\t\ttargetRef: OMK_ACCEPTED_REF,\n\t\twritablePaths: contract.writablePaths,\n\t});\n}\n\nexport function assertPublishable(\n\tsnapshot: JournalSnapshot,\n\tcommand: RunPublishCommand,\n\trunPath: string,\n): {\n\treadonly contract: RunContract;\n\treadonly state: RunProjection & { readonly candidateDigest: string; readonly receiptDigest: string };\n} {\n\tconst first = snapshot.records[0]?.event;\n\tif (first?.kind !== \"created\") throw new VerifiedRunError(\"missing_run\");\n\tconst contract = first.contract;\n\tconst state = snapshot.state;\n\tif (\n\t\tstate.verification !== \"verified\" ||\n\t\tstate.application !== \"candidate_ready\" ||\n\t\tstate.settlement !== \"settled\" ||\n\t\t!state.receiptDigest ||\n\t\t!state.candidateDigest ||\n\t\tstate.activeExecutionIds.length !== 0 ||\n\t\tstate.writerOpen\n\t)\n\t\tthrow new VerifiedRunError(\"unverified\");\n\tif (\n\t\tcommand.candidateDigest !== state.candidateDigest ||\n\t\tcommand.receiptDigest !== state.receiptDigest ||\n\t\tcommand.policyDigest !== publishPolicyDigest(contract)\n\t)\n\t\tthrow new VerifiedRunError(\"invalid_binding\");\n\tconst evidence = readRunEvidence(runPath, snapshot, commandEnvironmentDigest(contract, \"gated-v1\"));\n\tif (\n\t\t!evidence.verified ||\n\t\tevidence.candidateDigest !== state.candidateDigest ||\n\t\tevidence.receiptDigest !== state.receiptDigest\n\t)\n\t\tthrow new VerifiedRunError(\"invalid_binding\");\n\treturn { contract, state: { ...state, candidateDigest: state.candidateDigest, receiptDigest: state.receiptDigest } };\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { commandEnvironmentDigest } from "./broker.js";
|
|
2
|
+
import { readRunEvidence } from "./evidence.js";
|
|
3
|
+
import { OMK_ACCEPTED_REF } from "./git-plumbing.js";
|
|
4
|
+
import { digestObject, VerifiedRunError } from "./storage.js";
|
|
5
|
+
export function publishPolicyDigest(contract) {
|
|
6
|
+
return digestObject({
|
|
7
|
+
apply: contract.apply,
|
|
8
|
+
profile: contract.profile,
|
|
9
|
+
targetRef: OMK_ACCEPTED_REF,
|
|
10
|
+
writablePaths: contract.writablePaths,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export function assertPublishable(snapshot, command, runPath) {
|
|
14
|
+
const first = snapshot.records[0]?.event;
|
|
15
|
+
if (first?.kind !== "created")
|
|
16
|
+
throw new VerifiedRunError("missing_run");
|
|
17
|
+
const contract = first.contract;
|
|
18
|
+
const state = snapshot.state;
|
|
19
|
+
if (state.verification !== "verified" ||
|
|
20
|
+
state.application !== "candidate_ready" ||
|
|
21
|
+
state.settlement !== "settled" ||
|
|
22
|
+
!state.receiptDigest ||
|
|
23
|
+
!state.candidateDigest ||
|
|
24
|
+
state.activeExecutionIds.length !== 0 ||
|
|
25
|
+
state.writerOpen)
|
|
26
|
+
throw new VerifiedRunError("unverified");
|
|
27
|
+
if (command.candidateDigest !== state.candidateDigest ||
|
|
28
|
+
command.receiptDigest !== state.receiptDigest ||
|
|
29
|
+
command.policyDigest !== publishPolicyDigest(contract))
|
|
30
|
+
throw new VerifiedRunError("invalid_binding");
|
|
31
|
+
const evidence = readRunEvidence(runPath, snapshot, commandEnvironmentDigest(contract, "gated-v1"));
|
|
32
|
+
if (!evidence.verified ||
|
|
33
|
+
evidence.candidateDigest !== state.candidateDigest ||
|
|
34
|
+
evidence.receiptDigest !== state.receiptDigest)
|
|
35
|
+
throw new VerifiedRunError("invalid_binding");
|
|
36
|
+
return { contract, state: { ...state, candidateDigest: state.candidateDigest, receiptDigest: state.receiptDigest } };
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=publish-preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-preflight.js","sourceRoot":"","sources":["../../../src/core/verified-run/publish-preflight.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,UAAU,mBAAmB,CAAC,QAAqB,EAAU;IAClE,OAAO,YAAY,CAAC;QACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,SAAS,EAAE,gBAAgB;QAC3B,aAAa,EAAE,QAAQ,CAAC,aAAa;KACrC,CAAC,CAAC;AAAA,CACH;AAED,MAAM,UAAU,iBAAiB,CAChC,QAAyB,EACzB,OAA0B,EAC1B,OAAe,EAId;IACD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;IACzC,IAAI,KAAK,EAAE,IAAI,KAAK,SAAS;QAAE,MAAM,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACzE,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;IAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7B,IACC,KAAK,CAAC,YAAY,KAAK,UAAU;QACjC,KAAK,CAAC,WAAW,KAAK,iBAAiB;QACvC,KAAK,CAAC,UAAU,KAAK,SAAS;QAC9B,CAAC,KAAK,CAAC,aAAa;QACpB,CAAC,KAAK,CAAC,eAAe;QACtB,KAAK,CAAC,kBAAkB,CAAC,MAAM,KAAK,CAAC;QACrC,KAAK,CAAC,UAAU;QAEhB,MAAM,IAAI,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC1C,IACC,OAAO,CAAC,eAAe,KAAK,KAAK,CAAC,eAAe;QACjD,OAAO,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa;QAC7C,OAAO,CAAC,YAAY,KAAK,mBAAmB,CAAC,QAAQ,CAAC;QAEtD,MAAM,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,wBAAwB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;IACpG,IACC,CAAC,QAAQ,CAAC,QAAQ;QAClB,QAAQ,CAAC,eAAe,KAAK,KAAK,CAAC,eAAe;QAClD,QAAQ,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa;QAE9C,MAAM,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IAC/C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE,EAAE,CAAC;AAAA,CACrH","sourcesContent":["import type { RunContract, RunPublishCommand } from \"omk-protocol\";\nimport { commandEnvironmentDigest } from \"./broker.ts\";\nimport { readRunEvidence } from \"./evidence.ts\";\nimport { OMK_ACCEPTED_REF } from \"./git-plumbing.ts\";\nimport type { JournalSnapshot } from \"./journal.ts\";\nimport type { RunProjection } from \"./run-types.ts\";\nimport { digestObject, VerifiedRunError } from \"./storage.ts\";\n\nexport function publishPolicyDigest(contract: RunContract): string {\n\treturn digestObject({\n\t\tapply: contract.apply,\n\t\tprofile: contract.profile,\n\t\ttargetRef: OMK_ACCEPTED_REF,\n\t\twritablePaths: contract.writablePaths,\n\t});\n}\n\nexport function assertPublishable(\n\tsnapshot: JournalSnapshot,\n\tcommand: RunPublishCommand,\n\trunPath: string,\n): {\n\treadonly contract: RunContract;\n\treadonly state: RunProjection & { readonly candidateDigest: string; readonly receiptDigest: string };\n} {\n\tconst first = snapshot.records[0]?.event;\n\tif (first?.kind !== \"created\") throw new VerifiedRunError(\"missing_run\");\n\tconst contract = first.contract;\n\tconst state = snapshot.state;\n\tif (\n\t\tstate.verification !== \"verified\" ||\n\t\tstate.application !== \"candidate_ready\" ||\n\t\tstate.settlement !== \"settled\" ||\n\t\t!state.receiptDigest ||\n\t\t!state.candidateDigest ||\n\t\tstate.activeExecutionIds.length !== 0 ||\n\t\tstate.writerOpen\n\t)\n\t\tthrow new VerifiedRunError(\"unverified\");\n\tif (\n\t\tcommand.candidateDigest !== state.candidateDigest ||\n\t\tcommand.receiptDigest !== state.receiptDigest ||\n\t\tcommand.policyDigest !== publishPolicyDigest(contract)\n\t)\n\t\tthrow new VerifiedRunError(\"invalid_binding\");\n\tconst evidence = readRunEvidence(runPath, snapshot, commandEnvironmentDigest(contract, \"gated-v1\"));\n\tif (\n\t\t!evidence.verified ||\n\t\tevidence.candidateDigest !== state.candidateDigest ||\n\t\tevidence.receiptDigest !== state.receiptDigest\n\t)\n\t\tthrow new VerifiedRunError(\"invalid_binding\");\n\treturn { contract, state: { ...state, candidateDigest: state.candidateDigest, receiptDigest: state.receiptDigest } };\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ResourceClaimInput } from "../../coordination/resource.ts";
|
|
2
|
+
import type { GrantToken } from "../../coordination/types.ts";
|
|
3
|
+
import type { AuthorityStore } from "./authority-store.ts";
|
|
4
|
+
export declare function assertPublishEffectStart(store: AuthorityStore, token: GrantToken, claims: readonly ResourceClaimInput[], _pending: boolean, now?: number): void;
|
|
5
|
+
//# sourceMappingURL=publish-start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-start.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/publish-start.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,SAAS,kBAAkB,EAAE,EACrC,QAAQ,EAAE,OAAO,EACjB,GAAG,CAAC,EAAE,MAAM,GACV,IAAI,CAGN","sourcesContent":["import type { ResourceClaimInput } from \"../../coordination/resource.ts\";\nimport type { GrantToken } from \"../../coordination/types.ts\";\nimport type { AuthorityStore } from \"./authority-store.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nexport function assertPublishEffectStart(\n\tstore: AuthorityStore,\n\ttoken: GrantToken,\n\tclaims: readonly ResourceClaimInput[],\n\t_pending: boolean,\n\tnow?: number,\n): void {\n\t// A lookup result cannot substitute for a fresh durable start transition.\n\tif (!store.effectStarted(token, claims, undefined, now)) throw new VerifiedRunError(\"authority\");\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { VerifiedRunError } from "./storage.js";
|
|
2
|
+
export function assertPublishEffectStart(store, token, claims, _pending, now) {
|
|
3
|
+
// A lookup result cannot substitute for a fresh durable start transition.
|
|
4
|
+
if (!store.effectStarted(token, claims, undefined, now))
|
|
5
|
+
throw new VerifiedRunError("authority");
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=publish-start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-start.js","sourceRoot":"","sources":["../../../src/core/verified-run/publish-start.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,UAAU,wBAAwB,CACvC,KAAqB,EACrB,KAAiB,EACjB,MAAqC,EACrC,QAAiB,EACjB,GAAY,EACL;IACP,0EAA0E;IAC1E,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC;QAAE,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;AAAA,CACjG","sourcesContent":["import type { ResourceClaimInput } from \"../../coordination/resource.ts\";\nimport type { GrantToken } from \"../../coordination/types.ts\";\nimport type { AuthorityStore } from \"./authority-store.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nexport function assertPublishEffectStart(\n\tstore: AuthorityStore,\n\ttoken: GrantToken,\n\tclaims: readonly ResourceClaimInput[],\n\t_pending: boolean,\n\tnow?: number,\n): void {\n\t// A lookup result cannot substitute for a fresh durable start transition.\n\tif (!store.effectStarted(token, claims, undefined, now)) throw new VerifiedRunError(\"authority\");\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery-projection.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/recovery-projection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGhE,KAAK,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,GAAG,eAAe,CAAA;CAAE,CAAC,CAAC;AAEnG,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE;IACT,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC3C,GACC,IAAI,
|
|
1
|
+
{"version":3,"file":"recovery-projection.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/recovery-projection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGhE,KAAK,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,GAAG,eAAe,CAAA;CAAE,CAAC,CAAC;AAEnG,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE;IACT,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC3C,GACC,IAAI,CA8FN","sourcesContent":["import { MAX_VERIFIED_RUN_GENERATIONS } from \"omk-protocol\";\nimport { retryTaskProjection } from \"./dag-retry-projection.ts\";\nimport type { RunEvent, WriterReduction } from \"./run-types.ts\";\nimport { digestObject, VerifiedRunError } from \"./storage.ts\";\n\ntype RecoveryEvent = Extract<RunEvent, { kind: \"resumed\" | \"writer_restarted\" | \"tasks_retried\" }>;\n\n/** Shared generation/command fence; only the writer variant resets attempt-local progress. */\nexport function reduceRecoveryEvent(\n\tcontext: WriterReduction,\n\tevent: RecoveryEvent,\n\tprogress: {\n\t\treadonly commands: Set<string>;\n\t\treadonly checked: Set<string>;\n\t\treadonly activeRole: \"writer\" | \"verifier\";\n\t},\n): void {\n\tconst state = context.state;\n\tconst command = event.command;\n\tif (!state.budget) throw new VerifiedRunError(\"resume_unavailable\");\n\tif (state.generation >= MAX_VERIFIED_RUN_GENERATIONS) throw new VerifiedRunError(\"recovery_limit\");\n\tif (command.expectedRevision !== state.revision || command.expectedGeneration !== state.generation)\n\t\tthrow new VerifiedRunError(\"stale_revision\");\n\tif (\n\t\tcommand.runId !== state.runId ||\n\t\tcommand.contractDigest !== digestObject(context.contract) ||\n\t\tprogress.commands.has(command.commandId)\n\t)\n\t\tthrow new VerifiedRunError(\"command_conflict\");\n\tif (\n\t\tevent.reconciledExecutionIds.length !== state.activeExecutionIds.length ||\n\t\tevent.reconciledExecutionIds.some((id, index) => id !== state.activeExecutionIds[index])\n\t)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tlet deadline: number;\n\tlet tasks = state.tasks;\n\tswitch (event.kind) {\n\t\tcase \"resumed\":\n\t\t\tif (\n\t\t\t\t!state.candidateDigest ||\n\t\t\t\tstate.writerOpen ||\n\t\t\t\tstate.verificationDeadlineMs === null ||\n\t\t\t\tevent.command.candidateDigest !== state.candidateDigest\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"resume_unavailable\");\n\t\t\tif (state.activeExecutionIds.length && progress.activeRole !== \"verifier\")\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tdeadline = state.verificationDeadlineMs;\n\t\t\tbreak;\n\t\tcase \"tasks_retried\":\n\t\t\tif (state.activeExecutionIds.length && progress.activeRole !== \"writer\")\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\ttasks = retryTaskProjection(context, event);\n\t\t\tdeadline = state.budget.workDeadlineMs;\n\t\t\tcontext.writerStarted = false;\n\t\t\tcontext.writerFinished = tasks.every((task) => task.status === \"succeeded\");\n\t\t\tcontext.producerStarted = false;\n\t\t\tcontext.writerCommands = 0;\n\t\t\tcontext.requestBaseline = state.modelRequests;\n\t\t\tbreak;\n\t\tcase \"writer_restarted\":\n\t\t\tif (context.contract.profile === \"linux-command-dag-v1\") throw new VerifiedRunError(\"task_recovery_required\");\n\t\t\tif (\n\t\t\t\t!state.inputDigest ||\n\t\t\t\tstate.candidateDigest ||\n\t\t\t\tevent.command.baseDigest !== state.inputDigest ||\n\t\t\t\tstate.inputDigest !== context.contract.workspace.baseDigest\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"input_checkpoint_missing\");\n\t\t\tif (state.activeExecutionIds.length && progress.activeRole !== \"writer\")\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tif (\n\t\t\t\tcontext.contract.profile === \"linux-scripted-agent-v1\" &&\n\t\t\t\tcontext.contract.writer.maxRequests - state.modelRequests < context.contract.writer.steps.length + 1\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"model_request_limit\");\n\t\t\tdeadline = state.budget.workDeadlineMs;\n\t\t\tcontext.writerStarted = false;\n\t\t\tcontext.writerFinished = false;\n\t\t\tcontext.producerStarted = false;\n\t\t\tcontext.writerCommands = 0;\n\t\t\tcontext.requestBaseline = state.modelRequests;\n\t\t\tbreak;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = event;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n\tif (event.observedMs < (state.lastClockMs ?? state.budget.startedMs) || event.observedMs >= deadline)\n\t\tthrow new VerifiedRunError(\"deadline\");\n\tprogress.commands.add(command.commandId);\n\tprogress.checked.clear();\n\tcontext.state = {\n\t\t...state,\n\t\tgeneration: state.generation + 1,\n\t\ttasks,\n\t\texecution: \"running\",\n\t\tsettlement: \"settled\",\n\t\tverification: \"not_requested\",\n\t\twriterOpen: false,\n\t\tactiveExecutionIds: [],\n\t\tprocesses: [],\n\t\tfailure: null,\n\t\tlastRecovery: {\n\t\t\tkind: event.kind,\n\t\t\tcommandId: command.commandId,\n\t\t\tgeneration: state.generation + 1,\n\t\t},\n\t\tlastClockMs: event.observedMs,\n\t};\n}\n"]}
|
|
@@ -82,6 +82,11 @@ export function reduceRecoveryEvent(context, event, progress) {
|
|
|
82
82
|
activeExecutionIds: [],
|
|
83
83
|
processes: [],
|
|
84
84
|
failure: null,
|
|
85
|
+
lastRecovery: {
|
|
86
|
+
kind: event.kind,
|
|
87
|
+
commandId: command.commandId,
|
|
88
|
+
generation: state.generation + 1,
|
|
89
|
+
},
|
|
85
90
|
lastClockMs: event.observedMs,
|
|
86
91
|
};
|
|
87
92
|
}
|