open-multi-agent-kit 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +2 -2
- package/dist/approval-api.d.ts +5 -0
- package/dist/approval-api.d.ts.map +1 -0
- package/dist/approval-api.js +5 -0
- package/dist/approval-api.js.map +1 -0
- package/dist/cli/session-picker.d.ts +2 -2
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/commands/verified-run-cli.d.ts.map +1 -1
- package/dist/commands/verified-run-cli.js +69 -22
- package/dist/commands/verified-run-cli.js.map +1 -1
- package/dist/commands/verified-run-signal.d.ts +3 -0
- package/dist/commands/verified-run-signal.d.ts.map +1 -0
- package/dist/commands/verified-run-signal.js +15 -0
- package/dist/commands/verified-run-signal.js.map +1 -0
- package/dist/coordination/broker.d.ts.map +1 -1
- package/dist/coordination/broker.js +13 -6
- package/dist/coordination/broker.js.map +1 -1
- package/dist/coordination/operation.d.ts +1 -0
- package/dist/coordination/operation.d.ts.map +1 -1
- package/dist/coordination/operation.js +55 -3
- package/dist/coordination/operation.js.map +1 -1
- package/dist/coordination/resource.d.ts +1 -1
- package/dist/coordination/resource.d.ts.map +1 -1
- package/dist/coordination/resource.js +10 -4
- package/dist/coordination/resource.js.map +1 -1
- package/dist/coordination/types.d.ts.map +1 -1
- package/dist/coordination/types.js +1 -1
- package/dist/coordination/types.js.map +1 -1
- package/dist/core/adaptorch-bridge.d.ts +1 -1
- package/dist/core/adaptorch-bridge.d.ts.map +1 -1
- package/dist/core/adaptorch-bridge.js +1 -1
- package/dist/core/adaptorch-bridge.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +16 -16
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +32 -33
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/canonical-json.d.ts +3 -0
- package/dist/core/canonical-json.d.ts.map +1 -0
- package/dist/core/canonical-json.js +20 -0
- package/dist/core/canonical-json.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +7 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +14 -29
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/fallback.d.ts +16 -5
- package/dist/core/compaction/fallback.d.ts.map +1 -1
- package/dist/core/compaction/fallback.js +4 -3
- package/dist/core/compaction/fallback.js.map +1 -1
- package/dist/core/compaction/model-failover.d.ts +21 -0
- package/dist/core/compaction/model-failover.d.ts.map +1 -0
- package/dist/core/compaction/model-failover.js +46 -0
- package/dist/core/compaction/model-failover.js.map +1 -0
- package/dist/core/compaction/session-summary.d.ts +21 -0
- package/dist/core/compaction/session-summary.d.ts.map +1 -0
- package/dist/core/compaction/session-summary.js +27 -0
- package/dist/core/compaction/session-summary.js.map +1 -0
- package/dist/core/export-html/template.js +14 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/session-lifecycle-types.d.ts +14 -0
- package/dist/core/extensions/session-lifecycle-types.d.ts.map +1 -0
- package/dist/core/extensions/session-lifecycle-types.js +2 -0
- package/dist/core/extensions/session-lifecycle-types.js.map +1 -0
- package/dist/core/extensions/types.d.ts +4 -9
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +10 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +3 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/legacy-resource-policy.d.ts +7 -0
- package/dist/core/legacy-resource-policy.d.ts.map +1 -0
- package/dist/core/legacy-resource-policy.js +9 -0
- package/dist/core/legacy-resource-policy.js.map +1 -0
- package/dist/core/mcp/config.d.ts.map +1 -1
- package/dist/core/mcp/config.js +17 -3
- package/dist/core/mcp/config.js.map +1 -1
- package/dist/core/mcp/connection-queue.d.ts +12 -0
- package/dist/core/mcp/connection-queue.d.ts.map +1 -0
- package/dist/core/mcp/connection-queue.js +46 -0
- package/dist/core/mcp/connection-queue.js.map +1 -0
- package/dist/core/mcp/manager-runtime.d.ts +55 -0
- package/dist/core/mcp/manager-runtime.d.ts.map +1 -0
- package/dist/core/mcp/manager-runtime.js +66 -0
- package/dist/core/mcp/manager-runtime.js.map +1 -0
- package/dist/core/mcp/manager.d.ts +12 -68
- package/dist/core/mcp/manager.d.ts.map +1 -1
- package/dist/core/mcp/manager.js +33 -113
- package/dist/core/mcp/manager.js.map +1 -1
- package/dist/core/mcp/protocol.d.ts.map +1 -1
- package/dist/core/mcp/protocol.js +70 -40
- package/dist/core/mcp/protocol.js.map +1 -1
- package/dist/core/package-manager.d.ts +4 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +59 -129
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/package-resource-patterns.d.ts +7 -0
- package/dist/core/package-resource-patterns.d.ts.map +1 -0
- package/dist/core/package-resource-patterns.js +99 -0
- package/dist/core/package-resource-patterns.js.map +1 -0
- package/dist/core/provider-resilience.d.ts +9 -0
- package/dist/core/provider-resilience.d.ts.map +1 -1
- package/dist/core/provider-resilience.js +15 -0
- package/dist/core/provider-resilience.js.map +1 -1
- package/dist/core/reasoning-router-v4.d.ts +5 -2
- package/dist/core/reasoning-router-v4.d.ts.map +1 -1
- package/dist/core/reasoning-router-v4.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +4 -8
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/run-execution-api.d.ts +8 -1
- package/dist/core/run-execution-api.d.ts.map +1 -1
- package/dist/core/run-execution-api.js +4 -0
- package/dist/core/run-execution-api.js.map +1 -1
- package/dist/core/run-journal.d.ts +1 -2
- package/dist/core/run-journal.d.ts.map +1 -1
- package/dist/core/run-journal.js +2 -19
- package/dist/core/run-journal.js.map +1 -1
- package/dist/core/session-listing.d.ts +51 -0
- package/dist/core/session-listing.d.ts.map +1 -0
- package/dist/core/session-listing.js +111 -0
- package/dist/core/session-listing.js.map +1 -0
- package/dist/core/session-manager.d.ts +12 -37
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +12 -118
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-message-text.d.ts +5 -0
- package/dist/core/session-message-text.d.ts.map +1 -0
- package/dist/core/session-message-text.js +9 -0
- package/dist/core/session-message-text.js.map +1 -0
- package/dist/core/skills-catalog-cache.d.ts +2 -0
- package/dist/core/skills-catalog-cache.d.ts.map +1 -1
- package/dist/core/skills-catalog-cache.js +71 -17
- package/dist/core/skills-catalog-cache.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/verified-run/authority-clock.d.ts +3 -0
- package/dist/core/verified-run/authority-clock.d.ts.map +1 -0
- package/dist/core/verified-run/authority-clock.js +25 -0
- package/dist/core/verified-run/authority-clock.js.map +1 -0
- package/dist/core/verified-run/authority-errors.d.ts +10 -0
- package/dist/core/verified-run/authority-errors.d.ts.map +1 -0
- package/dist/core/verified-run/authority-errors.js +17 -0
- package/dist/core/verified-run/authority-errors.js.map +1 -0
- package/dist/core/verified-run/authority-events.d.ts +126 -0
- package/dist/core/verified-run/authority-events.d.ts.map +1 -0
- package/dist/core/verified-run/authority-events.js +482 -0
- package/dist/core/verified-run/authority-events.js.map +1 -0
- package/dist/core/verified-run/authority-journal.d.ts +27 -0
- package/dist/core/verified-run/authority-journal.d.ts.map +1 -0
- package/dist/core/verified-run/authority-journal.js +83 -0
- package/dist/core/verified-run/authority-journal.js.map +1 -0
- package/dist/core/verified-run/authority-meaning.d.ts +13 -0
- package/dist/core/verified-run/authority-meaning.d.ts.map +1 -0
- package/dist/core/verified-run/authority-meaning.js +40 -0
- package/dist/core/verified-run/authority-meaning.js.map +1 -0
- package/dist/core/verified-run/authority-runtime.d.ts +82 -0
- package/dist/core/verified-run/authority-runtime.d.ts.map +1 -0
- package/dist/core/verified-run/authority-runtime.js +169 -0
- package/dist/core/verified-run/authority-runtime.js.map +1 -0
- package/dist/core/verified-run/authority-store.d.ts +204 -0
- package/dist/core/verified-run/authority-store.d.ts.map +1 -0
- package/dist/core/verified-run/authority-store.js +852 -0
- package/dist/core/verified-run/authority-store.js.map +1 -0
- package/dist/core/verified-run/broker.d.ts +8 -1
- package/dist/core/verified-run/broker.d.ts.map +1 -1
- package/dist/core/verified-run/broker.js +94 -90
- package/dist/core/verified-run/broker.js.map +1 -1
- package/dist/core/verified-run/candidate-policy.d.ts +10 -0
- package/dist/core/verified-run/candidate-policy.d.ts.map +1 -0
- package/dist/core/verified-run/candidate-policy.js +33 -0
- package/dist/core/verified-run/candidate-policy.js.map +1 -0
- package/dist/core/verified-run/candidate.d.ts.map +1 -1
- package/dist/core/verified-run/candidate.js +5 -10
- package/dist/core/verified-run/candidate.js.map +1 -1
- package/dist/core/verified-run/coordinator.d.ts +35 -17
- package/dist/core/verified-run/coordinator.d.ts.map +1 -1
- package/dist/core/verified-run/coordinator.js +111 -57
- package/dist/core/verified-run/coordinator.js.map +1 -1
- package/dist/core/verified-run/dag-phase.d.ts.map +1 -1
- package/dist/core/verified-run/dag-phase.js +1 -1
- package/dist/core/verified-run/dag-phase.js.map +1 -1
- package/dist/core/verified-run/dag-recovery.d.ts +5 -1
- package/dist/core/verified-run/dag-recovery.d.ts.map +1 -1
- package/dist/core/verified-run/dag-recovery.js +10 -4
- package/dist/core/verified-run/dag-recovery.js.map +1 -1
- package/dist/core/verified-run/event-parser.d.ts.map +1 -1
- package/dist/core/verified-run/event-parser.js +33 -0
- package/dist/core/verified-run/event-parser.js.map +1 -1
- package/dist/core/verified-run/evidence-read-projection.d.ts +4 -0
- package/dist/core/verified-run/evidence-read-projection.d.ts.map +1 -0
- package/dist/core/verified-run/evidence-read-projection.js +27 -0
- package/dist/core/verified-run/evidence-read-projection.js.map +1 -0
- package/dist/core/verified-run/evidence.d.ts +12 -1
- package/dist/core/verified-run/evidence.d.ts.map +1 -1
- package/dist/core/verified-run/evidence.js +51 -2
- package/dist/core/verified-run/evidence.js.map +1 -1
- package/dist/core/verified-run/git-candidate-preflight.d.ts +4 -0
- package/dist/core/verified-run/git-candidate-preflight.d.ts.map +1 -0
- package/dist/core/verified-run/git-candidate-preflight.js +34 -0
- package/dist/core/verified-run/git-candidate-preflight.js.map +1 -0
- package/dist/core/verified-run/git-effect-supervisor.d.ts +24 -0
- package/dist/core/verified-run/git-effect-supervisor.d.ts.map +1 -0
- package/dist/core/verified-run/git-effect-supervisor.js +174 -0
- package/dist/core/verified-run/git-effect-supervisor.js.map +1 -0
- package/dist/core/verified-run/git-execution.d.ts +27 -0
- package/dist/core/verified-run/git-execution.d.ts.map +1 -0
- package/dist/core/verified-run/git-execution.js +118 -0
- package/dist/core/verified-run/git-execution.js.map +1 -0
- package/dist/core/verified-run/git-plumbing.d.ts +37 -0
- package/dist/core/verified-run/git-plumbing.d.ts.map +1 -0
- package/dist/core/verified-run/git-plumbing.js +171 -0
- package/dist/core/verified-run/git-plumbing.js.map +1 -0
- package/dist/core/verified-run/git-publication-worker.d.ts +2 -0
- package/dist/core/verified-run/git-publication-worker.d.ts.map +1 -0
- package/dist/core/verified-run/git-publication-worker.js +54 -0
- package/dist/core/verified-run/git-publication-worker.js.map +1 -0
- package/dist/core/verified-run/git-sandbox-layout.d.ts +4 -0
- package/dist/core/verified-run/git-sandbox-layout.d.ts.map +1 -0
- package/dist/core/verified-run/git-sandbox-layout.js +29 -0
- package/dist/core/verified-run/git-sandbox-layout.js.map +1 -0
- package/dist/core/verified-run/git-worker-protocol.d.ts +19 -0
- package/dist/core/verified-run/git-worker-protocol.d.ts.map +1 -0
- package/dist/core/verified-run/git-worker-protocol.js +109 -0
- package/dist/core/verified-run/git-worker-protocol.js.map +1 -0
- package/dist/core/verified-run/git-worker-runtime.d.ts +19 -0
- package/dist/core/verified-run/git-worker-runtime.d.ts.map +1 -0
- package/dist/core/verified-run/git-worker-runtime.js +74 -0
- package/dist/core/verified-run/git-worker-runtime.js.map +1 -0
- package/dist/core/verified-run/journal.d.ts +2 -3
- package/dist/core/verified-run/journal.d.ts.map +1 -1
- package/dist/core/verified-run/journal.js.map +1 -1
- package/dist/core/verified-run/namespace-identity.d.ts.map +1 -1
- package/dist/core/verified-run/namespace-identity.js +1 -1
- package/dist/core/verified-run/namespace-identity.js.map +1 -1
- package/dist/core/verified-run/owned-execution.d.ts +10 -1
- package/dist/core/verified-run/owned-execution.d.ts.map +1 -1
- package/dist/core/verified-run/owned-execution.js +124 -31
- package/dist/core/verified-run/owned-execution.js.map +1 -1
- package/dist/core/verified-run/phase-context.d.ts +2 -0
- package/dist/core/verified-run/phase-context.d.ts.map +1 -1
- package/dist/core/verified-run/phase-context.js.map +1 -1
- package/dist/core/verified-run/projection.d.ts.map +1 -1
- package/dist/core/verified-run/projection.js +51 -1
- package/dist/core/verified-run/projection.js.map +1 -1
- package/dist/core/verified-run/publish-preflight.d.ts +12 -0
- package/dist/core/verified-run/publish-preflight.d.ts.map +1 -0
- package/dist/core/verified-run/publish-preflight.js +38 -0
- package/dist/core/verified-run/publish-preflight.js.map +1 -0
- package/dist/core/verified-run/publish-start.d.ts +5 -0
- package/dist/core/verified-run/publish-start.d.ts.map +1 -0
- package/dist/core/verified-run/publish-start.js +7 -0
- package/dist/core/verified-run/publish-start.js.map +1 -0
- package/dist/core/verified-run/recovery-projection.d.ts.map +1 -1
- package/dist/core/verified-run/recovery-projection.js +5 -0
- package/dist/core/verified-run/recovery-projection.js.map +1 -1
- package/dist/core/verified-run/recovery.d.ts +5 -1
- package/dist/core/verified-run/recovery.d.ts.map +1 -1
- package/dist/core/verified-run/recovery.js +10 -4
- package/dist/core/verified-run/recovery.js.map +1 -1
- package/dist/core/verified-run/run-plan.d.ts +17 -0
- package/dist/core/verified-run/run-plan.d.ts.map +1 -0
- package/dist/core/verified-run/run-plan.js +18 -0
- package/dist/core/verified-run/run-plan.js.map +1 -0
- package/dist/core/verified-run/run-publish-owned.d.ts +6 -0
- package/dist/core/verified-run/run-publish-owned.d.ts.map +1 -0
- package/dist/core/verified-run/run-publish-owned.js +199 -0
- package/dist/core/verified-run/run-publish-owned.js.map +1 -0
- package/dist/core/verified-run/run-publish.d.ts +19 -0
- package/dist/core/verified-run/run-publish.d.ts.map +1 -0
- package/dist/core/verified-run/run-publish.js +210 -0
- package/dist/core/verified-run/run-publish.js.map +1 -0
- package/dist/core/verified-run/run-status-owned.d.ts +4 -0
- package/dist/core/verified-run/run-status-owned.d.ts.map +1 -0
- package/dist/core/verified-run/run-status-owned.js +14 -0
- package/dist/core/verified-run/run-status-owned.js.map +1 -0
- package/dist/core/verified-run/run-status.d.ts +133 -0
- package/dist/core/verified-run/run-status.d.ts.map +1 -0
- package/dist/core/verified-run/run-status.js +193 -0
- package/dist/core/verified-run/run-status.js.map +1 -0
- package/dist/core/verified-run/run-types.d.ts +31 -0
- package/dist/core/verified-run/run-types.d.ts.map +1 -1
- package/dist/core/verified-run/run-types.js.map +1 -1
- package/dist/core/verified-run/storage.d.ts.map +1 -1
- package/dist/core/verified-run/storage.js +1 -1
- package/dist/core/verified-run/storage.js.map +1 -1
- package/dist/core/verified-run/supervisor-adapter.d.ts +77 -0
- package/dist/core/verified-run/supervisor-adapter.d.ts.map +1 -0
- package/dist/core/verified-run/supervisor-adapter.js +164 -0
- package/dist/core/verified-run/supervisor-adapter.js.map +1 -0
- package/dist/core/verified-run/verification-phase.d.ts.map +1 -1
- package/dist/core/verified-run/verification-phase.js +1 -1
- package/dist/core/verified-run/verification-phase.js.map +1 -1
- package/dist/core/verified-run/writer-phase.d.ts.map +1 -1
- package/dist/core/verified-run/writer-phase.js +1 -0
- package/dist/core/verified-run/writer-phase.js.map +1 -1
- package/dist/core/verified-run/writer-recovery.d.ts +2 -0
- package/dist/core/verified-run/writer-recovery.d.ts.map +1 -1
- package/dist/core/verified-run/writer-recovery.js +1 -0
- package/dist/core/verified-run/writer-recovery.js.map +1 -1
- package/dist/core/workload-shard-execution-types.d.ts +4 -1
- package/dist/core/workload-shard-execution-types.d.ts.map +1 -1
- package/dist/core/workload-shard-execution-types.js.map +1 -1
- package/dist/core/workload-shard-executor.d.ts +2 -2
- package/dist/core/workload-shard-executor.d.ts.map +1 -1
- package/dist/core/workload-shard-executor.js +16 -37
- package/dist/core/workload-shard-executor.js.map +1 -1
- package/dist/core/workload-shard-frontier.d.ts +5 -0
- package/dist/core/workload-shard-frontier.d.ts.map +1 -0
- package/dist/core/workload-shard-frontier.js +47 -0
- package/dist/core/workload-shard-frontier.js.map +1 -0
- package/dist/core/workload-shard-runner.d.ts.map +1 -1
- package/dist/core/workload-shard-runner.js +28 -17
- package/dist/core/workload-shard-runner.js.map +1 -1
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -1
- package/dist/main.js.map +1 -1
- package/dist/metacognition/bridge-result.d.ts +148 -0
- package/dist/metacognition/bridge-result.d.ts.map +1 -0
- package/dist/metacognition/bridge-result.js +46 -0
- package/dist/metacognition/bridge-result.js.map +1 -0
- package/dist/metacognition/calibration-selective.d.ts.map +1 -1
- package/dist/metacognition/calibration-selective.js +8 -2
- package/dist/metacognition/calibration-selective.js.map +1 -1
- package/dist/metacognition/index.d.ts +1 -0
- package/dist/metacognition/index.d.ts.map +1 -1
- package/dist/metacognition/index.js +1 -0
- package/dist/metacognition/index.js.map +1 -1
- package/dist/metacognition/risk.d.ts.map +1 -1
- package/dist/metacognition/risk.js +28 -14
- package/dist/metacognition/risk.js.map +1 -1
- package/dist/metacognition/runtime-bridge.d.ts +41 -14
- package/dist/metacognition/runtime-bridge.d.ts.map +1 -1
- package/dist/metacognition/runtime-bridge.js +357 -39
- package/dist/metacognition/runtime-bridge.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +2 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +42 -26
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-container.d.ts +7 -0
- package/dist/modes/interactive/components/chat-container.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-container.js +14 -0
- package/dist/modes/interactive/components/chat-container.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +4 -2
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +0 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-async-search.d.ts +33 -0
- package/dist/modes/interactive/components/session-selector-async-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-async-search.js +109 -0
- package/dist/modes/interactive/components/session-selector-async-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-loaders.d.ts +6 -0
- package/dist/modes/interactive/components/session-selector-loaders.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-loaders.js +9 -0
- package/dist/modes/interactive/components/session-selector-loaders.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-tree.d.ts +16 -0
- package/dist/modes/interactive/components/session-selector-tree.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-tree.js +46 -0
- package/dist/modes/interactive/components/session-selector-tree.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +6 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +36 -76
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution-images.d.ts +32 -0
- package/dist/modes/interactive/components/tool-execution-images.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-images.js +144 -0
- package/dist/modes/interactive/components/tool-execution-images.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +3 -4
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +22 -71
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +7 -9
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tui-diagnostics.d.ts +8 -4
- package/dist/modes/interactive/tui-diagnostics.d.ts.map +1 -1
- package/dist/modes/interactive/tui-diagnostics.js +35 -1
- package/dist/modes/interactive/tui-diagnostics.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +14 -17
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-response.d.ts +5 -0
- package/dist/modes/rpc/rpc-response.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-response.js +17 -0
- package/dist/modes/rpc/rpc-response.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +3 -5
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/adaptorch-preview-spec.md +7 -7
- package/docs/atomic-commit-planning.md +69 -0
- package/docs/compaction.md +26 -1
- package/docs/extensions.md +14 -0
- package/docs/mcp.md +22 -0
- package/docs/metacognition.md +79 -0
- package/docs/model-catalog-refresh.md +159 -1
- package/docs/models.md +1 -1
- package/docs/runtime-algorithms.md +49 -4
- package/docs/session-format.md +8 -0
- package/docs/sessions.md +19 -0
- package/docs/skills.md +19 -0
- package/docs/terminal-setup.md +15 -0
- package/docs/tui.md +41 -0
- package/docs/verified-run-safety.md +75 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +18 -18
- package/package.json +6 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/core/verified-run/coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,GAE5B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,gBAAgB,C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7D,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,KAAK,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;IAAA,CACD;CACD","sourcesContent":["import { join, resolve } from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport {\n\tparseRunContract,\n\tparseRunResumeCommand,\n\tparseRunStartCommand,\n\tparseRunTaskRetryCommand,\n\tparseRunWriterRestartCommand,\n\ttype RunContract,\n} from \"omk-protocol\";\nimport { ensureDurableDirectorySync } from \"../durable-file-io.ts\";\nimport { acquireSessionOwnerLeaseSync } from \"../session-owner-lease.ts\";\nimport { commandEnvironmentDigest, probeVerifiedSandbox } from \"./broker.ts\";\nimport { captureCandidate, materializeCandidate, storeCandidate } from \"./candidate.ts\";\nimport { preflightCheckReceipts } from \"./check-receipt.ts\";\nimport { inspectTaskRecovery, retryDagTasks, type TaskRecoveryInspection } from \"./dag-recovery.ts\";\nimport { createRunIssuer, readRunEvidence, type VerifiedRunEvidence } from \"./evidence.ts\";\nimport { journalPath, readRunJournal, VerifiedRunJournal } from \"./journal.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { inspectRunRecovery, type RecoveryInspection, resumeFrozenCandidate } from \"./recovery.ts\";\nimport { anchorRunBudget, readRunClock } from \"./recovery-clock.ts\";\nimport type { RunProjection } from \"./run-types.ts\";\nimport type { VerifiedRunRuntime } from \"./session-port.ts\";\nimport {\n\tassertStateOutsideWorkspace,\n\tdigestBytes,\n\tdigestObject,\n\treadRegularFile,\n\tstateRunPath,\n\tVerifiedRunError,\n} from \"./storage.ts\";\nimport { verifyCandidate } from \"./verification-phase.ts\";\nimport { publishWriterCandidate } from \"./writer-completion.ts\";\nimport { executeWriter } from \"./writer-phase.ts\";\nimport { inspectWriterRecovery, restartIsolatedWriter, type WriterRecoveryInspection } from \"./writer-recovery.ts\";\n\nexport interface VerifiedRunApproval {\n\t/** Trusted host grant, not a JSON field in the model-authored contract or command. */\n\treadonly approvedContractDigest: string;\n\treadonly signal?: AbortSignal;\n}\nexport interface VerifiedRunPlan {\n\treadonly profile: RunContract[\"profile\"];\n\treadonly contractDigest: string;\n\treadonly baseDigest: string;\n\treadonly baseMatches: boolean;\n\treadonly environmentDigest: string;\n\treadonly checks: readonly string[];\n\treadonly executionRequested: false;\n}\n\nexport function planVerifiedRun(input: unknown): VerifiedRunPlan {\n\tconst contract = parseRunContract(input);\n\tconst snapshot = captureCandidate(contract.workspace.root, contract.budget);\n\treturn Object.freeze({\n\t\tprofile: contract.profile,\n\t\tcontractDigest: digestObject(contract),\n\t\tbaseDigest: snapshot.digest,\n\t\tbaseMatches: snapshot.digest === contract.workspace.baseDigest,\n\t\tenvironmentDigest: commandEnvironmentDigest(contract, \"gated-v1\"),\n\t\tchecks: Object.freeze(contract.checks.map((check) => check.claimId)),\n\t\texecutionRequested: false,\n\t});\n}\n\n/** Owns the opt-in single-host run; session capabilities come only from trusted host composition. */\nexport class RunCoordinator {\n\tprivate readonly stateRoot: string;\n\tprivate readonly runtime: VerifiedRunRuntime | undefined;\n\tconstructor(stateRoot: string, runtime?: VerifiedRunRuntime) {\n\t\tthis.stateRoot = resolve(stateRoot);\n\t\tthis.runtime = runtime;\n\t}\n\n\tinspect(runId: string): RunProjection {\n\t\tconst journal = readRunJournal(stateRunPath(this.stateRoot, runId));\n\t\tif (!journal || journal.state.runId !== runId) throw new VerifiedRunError(\"missing_run\");\n\t\tif (journal.state.receiptDigest) this.evidence(runId);\n\t\treturn journal.state;\n\t}\n\n\tinspectRecovery(runId: string): RecoveryInspection {\n\t\tconst report = inspectRunRecovery(stateRunPath(this.stateRoot, runId));\n\t\tif (report.state.runId !== runId) throw new VerifiedRunError(\"missing_run\");\n\t\tif (report.state.receiptDigest) this.evidence(runId);\n\t\treturn report;\n\t}\n\n\tinspectWriterRecovery(runId: string): WriterRecoveryInspection {\n\t\tconst report = inspectWriterRecovery(stateRunPath(this.stateRoot, runId));\n\t\tif (report.state.runId !== runId) throw new VerifiedRunError(\"missing_run\");\n\t\tif (report.state.receiptDigest) this.evidence(runId);\n\t\treturn report;\n\t}\n\n\tinspectTaskRecovery(runId: string): TaskRecoveryInspection {\n\t\tconst report = inspectTaskRecovery(stateRunPath(this.stateRoot, runId));\n\t\tif (report.state.runId !== runId) throw new VerifiedRunError(\"missing_run\");\n\t\tif (report.state.receiptDigest) this.evidence(runId);\n\t\treturn report;\n\t}\n\n\tasync retryTasks(input: unknown, approval: VerifiedRunApproval): Promise<RunProjection> {\n\t\tconst command = parseRunTaskRetryCommand(input);\n\t\tif (approval.approvedContractDigest !== command.contractDigest) throw new VerifiedRunError(\"approval\");\n\t\tawait retryDagTasks(stateRunPath(this.stateRoot, command.runId), command, approval.signal);\n\t\treturn this.inspect(command.runId);\n\t}\n\n\tevidence(runId: string): VerifiedRunEvidence {\n\t\tconst runPath = stateRunPath(this.stateRoot, runId);\n\t\tconst journal = readRunJournal(runPath);\n\t\tconst first = journal?.records[0]?.event;\n\t\tif (!journal || first?.kind !== \"created\" || first.contract.runId !== runId)\n\t\t\tthrow new VerifiedRunError(\"missing_run\");\n\t\treturn readRunEvidence(\n\t\t\trunPath,\n\t\t\tjournal,\n\t\t\tcommandEnvironmentDigest(first.contract, journal.state.budget ? \"gated-v1\" : \"legacy\"),\n\t\t);\n\t}\n\n\tartifact(runId: string, candidateDigest: string, path: string): Buffer {\n\t\tconst evidence = this.evidence(runId);\n\t\tif (!evidence.verified || candidateDigest !== evidence.candidateDigest)\n\t\t\tthrow new VerifiedRunError(\"candidate_mismatch\");\n\t\tconst file = evidence.manifest.files.find((entry) => entry.path === path);\n\t\tif (!file) throw new VerifiedRunError(\"artifact_scope\");\n\t\tconst bytes = readRegularFile(join(stateRunPath(this.stateRoot, runId), \"blobs\", file.digest), file.size);\n\t\tif (digestBytes(bytes) !== file.digest || bytes.length !== file.size) throw new VerifiedRunError(\"integrity\");\n\t\treturn bytes;\n\t}\n\n\tasync resume(input: unknown, approval: VerifiedRunApproval): Promise<RunProjection> {\n\t\tconst command = parseRunResumeCommand(input);\n\t\tif (approval.approvedContractDigest !== command.contractDigest) throw new VerifiedRunError(\"approval\");\n\t\tawait resumeFrozenCandidate(stateRunPath(this.stateRoot, command.runId), command, approval.signal);\n\t\treturn this.inspect(command.runId);\n\t}\n\n\tasync restartWriter(input: unknown, approval: VerifiedRunApproval): Promise<RunProjection> {\n\t\tconst command = parseRunWriterRestartCommand(input);\n\t\tif (approval.approvedContractDigest !== command.contractDigest) throw new VerifiedRunError(\"approval\");\n\t\tawait restartIsolatedWriter(stateRunPath(this.stateRoot, command.runId), command, {\n\t\t\t...(approval.signal ? { signal: approval.signal } : {}),\n\t\t\t...(this.runtime ? { runtime: this.runtime } : {}),\n\t\t});\n\t\treturn this.inspect(command.runId);\n\t}\n\n\tasync start(input: unknown, request: unknown, approval: VerifiedRunApproval): Promise<RunProjection> {\n\t\tconst began = performance.now();\n\t\tconst clock = readRunClock();\n\t\tconst contract = parseRunContract(input);\n\t\tconst command = parseRunStartCommand(request);\n\t\tconst contractDigest = digestObject(contract);\n\t\tif (approval.approvedContractDigest !== contractDigest) throw new VerifiedRunError(\"approval\");\n\t\tif (command.contractDigest !== contractDigest || command.runId !== contract.runId)\n\t\t\tthrow new VerifiedRunError(\"command_conflict\");\n\t\tif (approval.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\t\tassertStateOutsideWorkspace(this.stateRoot, contract.workspace.root);\n\t\tconst runPath = stateRunPath(this.stateRoot, contract.runId);\n\t\tconst existing = readRunJournal(runPath);\n\t\tif (existing) {\n\t\t\tconst first = existing.records[0]?.event;\n\t\t\tif (\n\t\t\t\tfirst?.kind !== \"created\" ||\n\t\t\t\tdigestObject(first.command) !== digestObject(command) ||\n\t\t\t\tdigestObject(first.contract) !== contractDigest\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"command_conflict\");\n\t\t\treturn this.inspect(contract.runId);\n\t\t}\n\t\tconst base = captureCandidate(contract.workspace.root, contract.budget);\n\t\tif (base.digest !== contract.workspace.baseDigest) throw new VerifiedRunError(\"base_conflict\");\n\t\tconst environmentDigest = commandEnvironmentDigest(contract, \"gated-v1\");\n\t\tpreflightCheckReceipts(contract);\n\t\tprobeVerifiedSandbox();\n\t\tensureDurableDirectorySync(runPath);\n\t\tconst owner = acquireSessionOwnerLeaseSync(journalPath(runPath));\n\t\ttry {\n\t\t\tif (readRunJournal(runPath)) throw new VerifiedRunError(\"command_conflict\");\n\t\t\tconst journal = new VerifiedRunJournal(runPath, owner);\n\t\t\tjournal.append({ kind: \"created\", contract, command });\n\t\t\tconst budget = anchorRunBudget(contract.budget, clock);\n\t\t\tjournal.append({ kind: \"budget_anchored\", budget, environmentDigest, driver: \"linux-pidns-gate-v1\" });\n\t\t\tconst context: RunPhaseContext = {\n\t\t\t\trunPath,\n\t\t\t\tcontract,\n\t\t\t\tjournal,\n\t\t\t\t...(approval.signal ? { signal: approval.signal } : {}),\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tcreateRunIssuer(runPath);\n\t\t\t\tstoreCandidate(base, runPath);\n\t\t\t\tjournal.append({ kind: \"input_checkpoint\", digest: base.digest });\n\t\t\t\tconst work = join(runPath, \"writer\");\n\t\t\t\tif (contract.profile !== \"linux-command-dag-v1\") materializeCandidate(base, work);\n\t\t\t\tconst workDeadline = began + contract.budget.workMs;\n\t\t\t\tawait executeWriter(context, {\n\t\t\t\t\tworkspace: work,\n\t\t\t\t\tdeadline: workDeadline,\n\t\t\t\t\t...(this.runtime ? { runtime: this.runtime } : {}),\n\t\t\t\t});\n\t\t\t\tif (journal.state.execution === \"paused\") return this.inspect(contract.runId);\n\t\t\t\tpublishWriterCandidate(context, work, workDeadline);\n\t\t\t\tawait verifyCandidate(context);\n\t\t\t\treturn this.inspect(contract.runId);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof VerifiedRunError && !journal.state.receiptDigest)\n\t\t\t\t\treturn journal.append({ kind: \"failed\", code: error.code });\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} finally {\n\t\t\towner.release();\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/core/verified-run/coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACN,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAEN,mBAAmB,EAEnB,gBAAgB,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAA+B,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAE,eAAe,EAAqB,eAAe,EAA4B,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAyB,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEtG,OAAO,EAAE,kBAAkB,EAA2B,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAkB,MAAM,iBAAiB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,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;oBAC7D,MAAM,KAAK,CAAC;gBACb,CAAC;YACF,CAAC;oBAAS,CAAC;gBACV,KAAK,CAAC,OAAO,EAAE,CAAC;YACjB,CAAC;QAAA,CACD,CAAC,CAAC;IAAA,CACH;CACD","sourcesContent":["import { join, resolve } from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport {\n\tparseRunContract,\n\tparseRunPublishCommand,\n\tparseRunResumeCommand,\n\tparseRunStartCommand,\n\tparseRunTaskRetryCommand,\n\tparseRunWriterRestartCommand,\n} from \"omk-protocol\";\nimport { ensureDurableDirectorySync } from \"../durable-file-io.ts\";\nimport { acquireSessionOwnerLeaseSync } from \"../session-owner-lease.ts\";\nimport {\n\ttype AuthorityStoreView,\n\tinspectRunAuthority,\n\ttype RunAuthority,\n\tRunAuthorityPool,\n} from \"./authority-runtime.ts\";\nimport { commandEnvironmentDigest, probeVerifiedSandbox } from \"./broker.ts\";\nimport { captureCandidate, materializeCandidate, storeCandidate } from \"./candidate.ts\";\nimport { preflightCheckReceipts } from \"./check-receipt.ts\";\nimport { inspectTaskRecovery, retryDagTasks, type TaskRecoveryInspection } from \"./dag-recovery.ts\";\nimport { createRunIssuer, type EvidenceRead, readRunEvidence, type VerifiedRunEvidence } from \"./evidence.ts\";\nimport { readEvidenceProjection } from \"./evidence-read-projection.ts\";\nimport { journalPath, type RunJournalRecord, readRunJournal, VerifiedRunJournal } from \"./journal.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { inspectRunRecovery, type RecoveryInspection, resumeFrozenCandidate } from \"./recovery.ts\";\nimport { anchorRunBudget, readRunClock } from \"./recovery-clock.ts\";\nimport type { VerifiedRunApproval } from \"./run-plan.ts\";\nimport type { PublishOptions } from \"./run-publish.ts\";\nimport { publishVerifiedRunOwned } from \"./run-publish-owned.ts\";\nimport { deriveRunStatus, type RunStatus } from \"./run-status.ts\";\nimport { withOwnedGitStatus } from \"./run-status-owned.ts\";\nimport type { RunProjection } from \"./run-types.ts\";\nimport type { VerifiedRunRuntime } from \"./session-port.ts\";\nimport {\n\tassertStateOutsideWorkspace,\n\tdigestBytes,\n\tdigestObject,\n\treadRegularFile,\n\tstateRunPath,\n\tVerifiedRunError,\n} from \"./storage.ts\";\nimport { verifyCandidate } from \"./verification-phase.ts\";\nimport { publishWriterCandidate } from \"./writer-completion.ts\";\nimport { executeWriter } from \"./writer-phase.ts\";\nimport { inspectWriterRecovery, restartIsolatedWriter, type WriterRecoveryInspection } from \"./writer-recovery.ts\";\n\nexport type { AuthorityStoreView } from \"./authority-runtime.ts\";\nexport { planVerifiedRun, type VerifiedRunApproval, type VerifiedRunPlan } from \"./run-plan.ts\";\n\n/** Owns the opt-in single-host run; session capabilities come only from trusted host composition. */\nexport class RunCoordinator {\n\tprivate readonly stateRoot: string;\n\tprivate readonly runtime: VerifiedRunRuntime | undefined;\n\t/**\n\t * One shared authority store while dispatch-capable work is in flight: the\n\t * authority lease is fail-fast cross-process, so concurrent operations on\n\t * this coordinator pool a single open store rather than open their own.\n\t * The open is the restart boundary — epoch advance plus reconciliation\n\t * complete before any new dispatch may be admitted.\n\t */\n\tprivate readonly authorityPool = new RunAuthorityPool();\n\tconstructor(stateRoot: string, runtime?: VerifiedRunRuntime) {\n\t\tthis.stateRoot = resolve(stateRoot);\n\t\tthis.runtime = runtime;\n\t}\n\n\t/** Run `work` under the shared, reconciled authority store for this run's state root. */\n\tprivate withAuthority<T>(runId: string, work: (runPath: string, authority: RunAuthority) => T | Promise<T>) {\n\t\tconst runPath = stateRunPath(this.stateRoot, runId);\n\t\treturn this.authorityPool.run(runPath, runId, (authority) => work(runPath, authority));\n\t}\n\n\tinspect(runId: string): RunProjection {\n\t\tconst journal = readRunJournal(stateRunPath(this.stateRoot, runId));\n\t\tif (!journal || journal.state.runId !== runId) throw new VerifiedRunError(\"missing_run\");\n\t\tif (journal.state.receiptDigest) this.evidence(runId);\n\t\treturn journal.state;\n\t}\n\n\t/**\n\t * Derived lifecycle/recovery status of a run — same journal truth as\n\t * `inspect`, projected into the machine-readable `RunStatus` view\n\t * (lifecycle token, completion ladder, unresolved concerns, recovery\n\t * command hints). Never reports a recovered/quarantined run as clean.\n\t */\n\tstatus(runId: string): RunStatus {\n\t\treturn withOwnedGitStatus(deriveRunStatus(this.inspect(runId)), this.inspectAuthority().status);\n\t}\n\n\t/** The run's hashed journal records — the event stream the projection replays. */\n\tevents(runId: string): readonly RunJournalRecord[] {\n\t\tconst journal = readRunJournal(stateRunPath(this.stateRoot, runId));\n\t\tif (!journal || journal.state.runId !== runId) throw new VerifiedRunError(\"missing_run\");\n\t\tif (journal.state.receiptDigest) this.evidence(runId);\n\t\treturn journal.records;\n\t}\n\n\t/**\n\t * The durable authority store under this state root: which grant holds\n\t * which claims, why it is quarantined, and whether termination was\n\t * witnessed. Read-only; a missing store reads as an empty projection.\n\t */\n\tinspectAuthority(): AuthorityStoreView {\n\t\treturn inspectRunAuthority(this.stateRoot);\n\t}\n\n\tinspectRecovery(runId: string): RecoveryInspection {\n\t\tconst report = inspectRunRecovery(stateRunPath(this.stateRoot, runId));\n\t\tif (report.state.runId !== runId) throw new VerifiedRunError(\"missing_run\");\n\t\tif (report.state.receiptDigest) this.evidence(runId);\n\t\treturn report;\n\t}\n\n\tinspectWriterRecovery(runId: string): WriterRecoveryInspection {\n\t\tconst report = inspectWriterRecovery(stateRunPath(this.stateRoot, runId));\n\t\tif (report.state.runId !== runId) throw new VerifiedRunError(\"missing_run\");\n\t\tif (report.state.receiptDigest) this.evidence(runId);\n\t\treturn report;\n\t}\n\n\tinspectTaskRecovery(runId: string): TaskRecoveryInspection {\n\t\tconst report = inspectTaskRecovery(stateRunPath(this.stateRoot, runId));\n\t\tif (report.state.runId !== runId) throw new VerifiedRunError(\"missing_run\");\n\t\tif (report.state.receiptDigest) this.evidence(runId);\n\t\treturn report;\n\t}\n\n\tasync retryTasks(input: unknown, approval: VerifiedRunApproval): Promise<RunProjection> {\n\t\tconst command = parseRunTaskRetryCommand(input);\n\t\tif (approval.approvedContractDigest !== command.contractDigest) throw new VerifiedRunError(\"approval\");\n\t\tawait this.withAuthority(command.runId, (runPath, authority) =>\n\t\t\tretryDagTasks(runPath, command, { ...(approval.signal ? { signal: approval.signal } : {}), authority }),\n\t\t);\n\t\treturn this.inspect(command.runId);\n\t}\n\n\tevidence(runId: string): VerifiedRunEvidence {\n\t\tconst runPath = stateRunPath(this.stateRoot, runId);\n\t\tconst journal = readRunJournal(runPath);\n\t\tconst first = journal?.records[0]?.event;\n\t\tif (!journal || first?.kind !== \"created\" || first.contract.runId !== runId)\n\t\t\tthrow new VerifiedRunError(\"missing_run\");\n\t\treturn readRunEvidence(runPath, journal);\n\t}\n\n\tevidenceRead(runId: string): EvidenceRead {\n\t\treturn readEvidenceProjection(stateRunPath(this.stateRoot, runId));\n\t}\n\n\tartifact(runId: string, candidateDigest: string, path: string): Buffer {\n\t\tconst evidence = this.evidence(runId);\n\t\tif (!evidence.verified || candidateDigest !== evidence.candidateDigest)\n\t\t\tthrow new VerifiedRunError(\"candidate_mismatch\");\n\t\tconst file = evidence.manifest.files.find((entry) => entry.path === path);\n\t\tif (!file) throw new VerifiedRunError(\"artifact_scope\");\n\t\tconst bytes = readRegularFile(join(stateRunPath(this.stateRoot, runId), \"blobs\", file.digest), file.size);\n\t\tif (digestBytes(bytes) !== file.digest || bytes.length !== file.size) throw new VerifiedRunError(\"integrity\");\n\t\treturn bytes;\n\t}\n\n\tasync publish(input: unknown, approval: VerifiedRunApproval, options: PublishOptions = {}): Promise<RunProjection> {\n\t\tconst command = parseRunPublishCommand(input);\n\t\tif (approval.approvedContractDigest !== command.contractDigest) throw new VerifiedRunError(\"approval\");\n\t\tif (approval.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\t\treturn this.withAuthority(command.runId, (runPath, authority) =>\n\t\t\tpublishVerifiedRunOwned(runPath, command, {\n\t\t\t\t...options,\n\t\t\t\tauthority,\n\t\t\t\t...(approval.signal ? { signal: approval.signal } : {}),\n\t\t\t}),\n\t\t);\n\t}\n\n\tasync resume(input: unknown, approval: VerifiedRunApproval): Promise<RunProjection> {\n\t\tconst command = parseRunResumeCommand(input);\n\t\tif (approval.approvedContractDigest !== command.contractDigest) throw new VerifiedRunError(\"approval\");\n\t\tawait this.withAuthority(command.runId, (runPath, authority) =>\n\t\t\tresumeFrozenCandidate(runPath, command, {\n\t\t\t\t...(approval.signal ? { signal: approval.signal } : {}),\n\t\t\t\tauthority,\n\t\t\t}),\n\t\t);\n\t\treturn this.inspect(command.runId);\n\t}\n\n\tasync restartWriter(input: unknown, approval: VerifiedRunApproval): Promise<RunProjection> {\n\t\tconst command = parseRunWriterRestartCommand(input);\n\t\tif (approval.approvedContractDigest !== command.contractDigest) throw new VerifiedRunError(\"approval\");\n\t\tawait this.withAuthority(command.runId, (runPath, authority) =>\n\t\t\trestartIsolatedWriter(runPath, command, {\n\t\t\t\t...(approval.signal ? { signal: approval.signal } : {}),\n\t\t\t\t...(this.runtime ? { runtime: this.runtime } : {}),\n\t\t\t\tauthority,\n\t\t\t}),\n\t\t);\n\t\treturn this.inspect(command.runId);\n\t}\n\n\tasync start(input: unknown, request: unknown, approval: VerifiedRunApproval): Promise<RunProjection> {\n\t\tconst began = performance.now();\n\t\tconst clock = readRunClock();\n\t\tconst contract = parseRunContract(input);\n\t\tconst command = parseRunStartCommand(request);\n\t\tconst contractDigest = digestObject(contract);\n\t\tif (approval.approvedContractDigest !== contractDigest) throw new VerifiedRunError(\"approval\");\n\t\tif (command.contractDigest !== contractDigest || command.runId !== contract.runId)\n\t\t\tthrow new VerifiedRunError(\"command_conflict\");\n\t\tif (approval.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\t\tassertStateOutsideWorkspace(this.stateRoot, contract.workspace.root);\n\t\tconst runPath = stateRunPath(this.stateRoot, contract.runId);\n\t\tconst existing = readRunJournal(runPath);\n\t\tif (existing) {\n\t\t\tconst first = existing.records[0]?.event;\n\t\t\tif (\n\t\t\t\tfirst?.kind !== \"created\" ||\n\t\t\t\tdigestObject(first.command) !== digestObject(command) ||\n\t\t\t\tdigestObject(first.contract) !== contractDigest\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"command_conflict\");\n\t\t\treturn this.inspect(contract.runId);\n\t\t}\n\t\tconst base = captureCandidate(contract.workspace.root, contract.budget);\n\t\tif (base.digest !== contract.workspace.baseDigest) throw new VerifiedRunError(\"base_conflict\");\n\t\tconst environmentDigest = commandEnvironmentDigest(contract, \"gated-v1\");\n\t\tpreflightCheckReceipts(contract);\n\t\tprobeVerifiedSandbox();\n\t\tensureDurableDirectorySync(runPath);\n\t\treturn this.authorityPool.run(runPath, contract.runId, async (authority: RunAuthority) => {\n\t\t\tconst owner = acquireSessionOwnerLeaseSync(journalPath(runPath));\n\t\t\ttry {\n\t\t\t\tif (readRunJournal(runPath)) throw new VerifiedRunError(\"command_conflict\");\n\t\t\t\tconst journal = new VerifiedRunJournal(runPath, owner);\n\t\t\t\tjournal.append({ kind: \"created\", contract, command });\n\t\t\t\tconst budget = anchorRunBudget(contract.budget, clock);\n\t\t\t\tjournal.append({ kind: \"budget_anchored\", budget, environmentDigest, driver: \"linux-pidns-gate-v1\" });\n\t\t\t\tconst context: RunPhaseContext = {\n\t\t\t\t\trunPath,\n\t\t\t\t\tcontract,\n\t\t\t\t\tjournal,\n\t\t\t\t\tauthority,\n\t\t\t\t\t...(approval.signal ? { signal: approval.signal } : {}),\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tcreateRunIssuer(runPath);\n\t\t\t\t\tstoreCandidate(base, runPath);\n\t\t\t\t\tjournal.append({ kind: \"input_checkpoint\", digest: base.digest });\n\t\t\t\t\tconst work = join(runPath, \"writer\");\n\t\t\t\t\tif (contract.profile !== \"linux-command-dag-v1\") materializeCandidate(base, work);\n\t\t\t\t\tconst workDeadline = began + contract.budget.workMs;\n\t\t\t\t\tawait executeWriter(context, {\n\t\t\t\t\t\tworkspace: work,\n\t\t\t\t\t\tdeadline: workDeadline,\n\t\t\t\t\t\t...(this.runtime ? { runtime: this.runtime } : {}),\n\t\t\t\t\t});\n\t\t\t\t\tif (journal.state.execution === \"paused\") return this.inspect(contract.runId);\n\t\t\t\t\tpublishWriterCandidate(context, work, workDeadline);\n\t\t\t\t\tawait verifyCandidate(context);\n\t\t\t\t\treturn this.inspect(contract.runId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof VerifiedRunError && !journal.state.receiptDigest)\n\t\t\t\t\t\treturn journal.append({ kind: \"failed\", code: error.code });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\towner.release();\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dag-phase.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/dag-phase.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAqE1D,iGAAiG;AACjG,wBAAsB,UAAU,CAC/B,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAChE,OAAO,CAAC,IAAI,CAAC,CAuDf","sourcesContent":["import { join } from \"node:path\";\nimport { orderRunDag, type RunDagTask, runDagAncestors } from \"omk-protocol\";\nimport { ensureDurableDirectorySync } from \"../durable-file-io.ts\";\nimport { assertCandidateScope, captureCandidate, materializeCandidate, storeCandidate } from \"./candidate.ts\";\nimport { composeDagCandidate } from \"./dag-candidates.ts\";\nimport { readyDagTasks } from \"./dag-projection.ts\";\nimport { executeRunCommand } from \"./owned-execution.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { readRunClock, remainingRunTime } from \"./recovery-clock.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nfunction observeWork(context: RunPhaseContext): number {\n\tconst budget = context.journal.state.budget;\n\tif (!budget) throw new VerifiedRunError(\"input_checkpoint_missing\");\n\tconst clock = readRunClock();\n\tif (remainingRunTime(budget, budget.workDeadlineMs, clock) <= 0) throw new VerifiedRunError(\"deadline\");\n\treturn clock.nowMs;\n}\n\nasync function executeTask(context: RunPhaseContext, task: RunDagTask, deadline: number): Promise<void> {\n\tconst { contract, journal, runPath } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"unsupported\");\n\tif (context.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\tconst previous = journal.state.tasks.find((item) => item.taskId === task.id);\n\tif (previous?.status !== \"pending\") throw new VerifiedRunError(\"task_not_ready\");\n\tconst attempt = previous.attempt + 1;\n\tconst argv = task.attempts[previous.attempt];\n\tif (!argv) throw new VerifiedRunError(\"task_attempt_limit\");\n\tconst input = composeDagCandidate(context, runDagAncestors(contract.writer.tasks, task.id));\n\tstoreCandidate(input, runPath);\n\tconst workspace = join(runPath, \"tasks\", `${task.id}-${attempt}-g${journal.state.generation}`);\n\tmaterializeCandidate(input, workspace);\n\tjournal.append({\n\t\tkind: \"task_started\",\n\t\ttaskId: task.id,\n\t\tattempt,\n\t\tinputDigest: input.digest,\n\t\tobservedMs: observeWork(context),\n\t});\n\tconst { result } = await executeRunCommand(\n\t\tjournal,\n\t\t{ role: \"writer\", argv, workspace, deadline, claimId: null, taskId: task.id },\n\t\t{ ...contract.budget, ...(context.signal ? { signal: context.signal } : {}) },\n\t);\n\tif (result.failure === \"deadline\" || result.failure === \"cancelled\") throw new VerifiedRunError(result.failure);\n\tlet outputDigest: string | null = null;\n\tlet failure = result.failure;\n\tif (!failure) {\n\t\ttry {\n\t\t\tconst output = captureCandidate(workspace, contract.budget);\n\t\t\tassertCandidateScope(input.manifest, output.manifest, task.writablePaths);\n\t\t\tstoreCandidate(output, runPath);\n\t\t\toutputDigest = output.digest;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\t!(error instanceof VerifiedRunError) ||\n\t\t\t\t![\"scope_changed\", \"file_type\", \"storage_limit\"].includes(error.code)\n\t\t\t)\n\t\t\t\tthrow error;\n\t\t\tfailure = error.code;\n\t\t}\n\t}\n\tjournal.append({\n\t\tkind: \"task_finished\",\n\t\ttaskId: task.id,\n\t\tattempt,\n\t\toutputDigest,\n\t\tfailure,\n\t\tobservedMs: observeWork(context),\n\t});\n}\n\ntype TaskCompletion =\n\t| { readonly kind: \"done\"; readonly taskId: string }\n\t| { readonly kind: \"failed\"; readonly taskId: string; readonly error: unknown };\n\n/** Bounded ready frontier; every started task is drained before this phase returns or throws. */\nexport async function executeDag(\n\tcontext: RunPhaseContext,\n\toptions: { readonly workspace: string; readonly deadline: number },\n): Promise<void> {\n\tconst { contract, journal, runPath } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"unsupported\");\n\tensureDurableDirectorySync(join(runPath, \"tasks\"));\n\tconst order = orderRunDag(contract.writer.tasks);\n\tconst limit = contract.writer.maxConcurrentTasks ?? 1;\n\tconst stop = new AbortController();\n\tconst signal = context.signal ? AbortSignal.any([context.signal, stop.signal]) : stop.signal;\n\tconst work = { ...context, signal };\n\tconst inFlight = new Map<string, Promise<TaskCompletion>>();\n\tlet firstFailure: { readonly error: unknown } | undefined;\n\ttry {\n\t\tfor (;;) {\n\t\t\tif (firstFailure) throw firstFailure.error;\n\t\t\tif (signal.aborted) throw new VerifiedRunError(\"cancelled\");\n\t\t\tconst ready = new Set(readyDagTasks(contract.writer, journal.state).map((task) => task.id));\n\t\t\tfor (const task of order) {\n\t\t\t\tif (inFlight.size >= limit) break;\n\t\t\t\tif (!ready.has(task.id) || inFlight.has(task.id)) continue;\n\t\t\t\tconst completion = executeTask(work, task, options.deadline).then<TaskCompletion, TaskCompletion>(\n\t\t\t\t\t() => ({ kind: \"done\", taskId: task.id }),\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tfirstFailure ??= { error };\n\t\t\t\t\t\tstop.abort();\n\t\t\t\t\t\treturn { kind: \"failed\", taskId: task.id, error };\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tinFlight.set(task.id, completion);\n\t\t\t}\n\t\t\tif (!inFlight.size) break;\n\t\t\tconst completed = await Promise.race(inFlight.values());\n\t\t\tinFlight.delete(completed.taskId);\n\t\t\tswitch (completed.kind) {\n\t\t\t\tcase \"failed\":\n\t\t\t\t\tthrow completed.error;\n\t\t\t\tcase \"done\":\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: {\n\t\t\t\t\tconst exhaustive: never = completed;\n\t\t\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tstop.abort();\n\t\tawait Promise.all(inFlight.values());\n\t}\n\tif (\n\t\tjournal.state.tasks.some((task) => task.status !== \"succeeded\" || task.generation !== journal.state.generation)\n\t) {\n\t\tjournal.append({ kind: \"tasks_paused\" });\n\t\treturn;\n\t}\n\tobserveWork(context);\n\tmaterializeCandidate(composeDagCandidate(context, order), options.workspace);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dag-phase.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/dag-phase.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAqE1D,iGAAiG;AACjG,wBAAsB,UAAU,CAC/B,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAChE,OAAO,CAAC,IAAI,CAAC,CAuDf","sourcesContent":["import { join } from \"node:path\";\nimport { orderRunDag, type RunDagTask, runDagAncestors } from \"omk-protocol\";\nimport { ensureDurableDirectorySync } from \"../durable-file-io.ts\";\nimport { assertCandidateScope, captureCandidate, materializeCandidate, storeCandidate } from \"./candidate.ts\";\nimport { composeDagCandidate } from \"./dag-candidates.ts\";\nimport { readyDagTasks } from \"./dag-projection.ts\";\nimport { executeRunCommand } from \"./owned-execution.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { readRunClock, remainingRunTime } from \"./recovery-clock.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nfunction observeWork(context: RunPhaseContext): number {\n\tconst budget = context.journal.state.budget;\n\tif (!budget) throw new VerifiedRunError(\"input_checkpoint_missing\");\n\tconst clock = readRunClock();\n\tif (remainingRunTime(budget, budget.workDeadlineMs, clock) <= 0) throw new VerifiedRunError(\"deadline\");\n\treturn clock.nowMs;\n}\n\nasync function executeTask(context: RunPhaseContext, task: RunDagTask, deadline: number): Promise<void> {\n\tconst { contract, journal, runPath } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"unsupported\");\n\tif (context.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\tconst previous = journal.state.tasks.find((item) => item.taskId === task.id);\n\tif (previous?.status !== \"pending\") throw new VerifiedRunError(\"task_not_ready\");\n\tconst attempt = previous.attempt + 1;\n\tconst argv = task.attempts[previous.attempt];\n\tif (!argv) throw new VerifiedRunError(\"task_attempt_limit\");\n\tconst input = composeDagCandidate(context, runDagAncestors(contract.writer.tasks, task.id));\n\tstoreCandidate(input, runPath);\n\tconst workspace = join(runPath, \"tasks\", `${task.id}-${attempt}-g${journal.state.generation}`);\n\tmaterializeCandidate(input, workspace);\n\tjournal.append({\n\t\tkind: \"task_started\",\n\t\ttaskId: task.id,\n\t\tattempt,\n\t\tinputDigest: input.digest,\n\t\tobservedMs: observeWork(context),\n\t});\n\tconst { result } = await executeRunCommand(\n\t\tjournal,\n\t\t{ role: \"writer\", argv, workspace, deadline, claimId: null, taskId: task.id },\n\t\t{ ...contract.budget, authority: context.authority, ...(context.signal ? { signal: context.signal } : {}) },\n\t);\n\tif (result.failure === \"deadline\" || result.failure === \"cancelled\") throw new VerifiedRunError(result.failure);\n\tlet outputDigest: string | null = null;\n\tlet failure = result.failure;\n\tif (!failure) {\n\t\ttry {\n\t\t\tconst output = captureCandidate(workspace, contract.budget);\n\t\t\tassertCandidateScope(input.manifest, output.manifest, task.writablePaths);\n\t\t\tstoreCandidate(output, runPath);\n\t\t\toutputDigest = output.digest;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\t!(error instanceof VerifiedRunError) ||\n\t\t\t\t![\"scope_changed\", \"file_type\", \"storage_limit\"].includes(error.code)\n\t\t\t)\n\t\t\t\tthrow error;\n\t\t\tfailure = error.code;\n\t\t}\n\t}\n\tjournal.append({\n\t\tkind: \"task_finished\",\n\t\ttaskId: task.id,\n\t\tattempt,\n\t\toutputDigest,\n\t\tfailure,\n\t\tobservedMs: observeWork(context),\n\t});\n}\n\ntype TaskCompletion =\n\t| { readonly kind: \"done\"; readonly taskId: string }\n\t| { readonly kind: \"failed\"; readonly taskId: string; readonly error: unknown };\n\n/** Bounded ready frontier; every started task is drained before this phase returns or throws. */\nexport async function executeDag(\n\tcontext: RunPhaseContext,\n\toptions: { readonly workspace: string; readonly deadline: number },\n): Promise<void> {\n\tconst { contract, journal, runPath } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"unsupported\");\n\tensureDurableDirectorySync(join(runPath, \"tasks\"));\n\tconst order = orderRunDag(contract.writer.tasks);\n\tconst limit = contract.writer.maxConcurrentTasks ?? 1;\n\tconst stop = new AbortController();\n\tconst signal = context.signal ? AbortSignal.any([context.signal, stop.signal]) : stop.signal;\n\tconst work = { ...context, signal };\n\tconst inFlight = new Map<string, Promise<TaskCompletion>>();\n\tlet firstFailure: { readonly error: unknown } | undefined;\n\ttry {\n\t\tfor (;;) {\n\t\t\tif (firstFailure) throw firstFailure.error;\n\t\t\tif (signal.aborted) throw new VerifiedRunError(\"cancelled\");\n\t\t\tconst ready = new Set(readyDagTasks(contract.writer, journal.state).map((task) => task.id));\n\t\t\tfor (const task of order) {\n\t\t\t\tif (inFlight.size >= limit) break;\n\t\t\t\tif (!ready.has(task.id) || inFlight.has(task.id)) continue;\n\t\t\t\tconst completion = executeTask(work, task, options.deadline).then<TaskCompletion, TaskCompletion>(\n\t\t\t\t\t() => ({ kind: \"done\", taskId: task.id }),\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tfirstFailure ??= { error };\n\t\t\t\t\t\tstop.abort();\n\t\t\t\t\t\treturn { kind: \"failed\", taskId: task.id, error };\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tinFlight.set(task.id, completion);\n\t\t\t}\n\t\t\tif (!inFlight.size) break;\n\t\t\tconst completed = await Promise.race(inFlight.values());\n\t\t\tinFlight.delete(completed.taskId);\n\t\t\tswitch (completed.kind) {\n\t\t\t\tcase \"failed\":\n\t\t\t\t\tthrow completed.error;\n\t\t\t\tcase \"done\":\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: {\n\t\t\t\t\tconst exhaustive: never = completed;\n\t\t\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tstop.abort();\n\t\tawait Promise.all(inFlight.values());\n\t}\n\tif (\n\t\tjournal.state.tasks.some((task) => task.status !== \"succeeded\" || task.generation !== journal.state.generation)\n\t) {\n\t\tjournal.append({ kind: \"tasks_paused\" });\n\t\treturn;\n\t}\n\tobserveWork(context);\n\tmaterializeCandidate(composeDagCandidate(context, order), options.workspace);\n}\n"]}
|
|
@@ -40,7 +40,7 @@ async function executeTask(context, task, deadline) {
|
|
|
40
40
|
inputDigest: input.digest,
|
|
41
41
|
observedMs: observeWork(context),
|
|
42
42
|
});
|
|
43
|
-
const { result } = await executeRunCommand(journal, { role: "writer", argv, workspace, deadline, claimId: null, taskId: task.id }, { ...contract.budget, ...(context.signal ? { signal: context.signal } : {}) });
|
|
43
|
+
const { result } = await executeRunCommand(journal, { role: "writer", argv, workspace, deadline, claimId: null, taskId: task.id }, { ...contract.budget, authority: context.authority, ...(context.signal ? { signal: context.signal } : {}) });
|
|
44
44
|
if (result.failure === "deadline" || result.failure === "cancelled")
|
|
45
45
|
throw new VerifiedRunError(result.failure);
|
|
46
46
|
let outputDigest = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dag-phase.js","sourceRoot":"","sources":["../../../src/core/verified-run/dag-phase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAmB,eAAe,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9G,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,SAAS,WAAW,CAAC,OAAwB,EAAU;IACtD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;IAC5C,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,gBAAgB,CAAC,0BAA0B,CAAC,CAAC;IACpE,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;IAC7B,IAAI,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxG,OAAO,KAAK,CAAC,KAAK,CAAC;AAAA,CACnB;AAED,KAAK,UAAU,WAAW,CAAC,OAAwB,EAAE,IAAgB,EAAE,QAAgB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,CAAC;YAClC,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;gBACxB,KAAK,QAAQ;oBACZ,MAAM,SAAS,CAAC,KAAK,CAAC;gBACvB,KAAK,MAAM;oBACV,MAAM;gBACP,SAAS,CAAC;oBACT,MAAM,UAAU,GAAU,SAAS,CAAC;oBACpC,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;gBAChD,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;YAAS,CAAC;QACV,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,IACC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,IAAI,CAAC,UAAU,KAAK,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAC9G,CAAC;QACF,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QACzC,OAAO;IACR,CAAC;IACD,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,oBAAoB,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;AAAA,CAC7E","sourcesContent":["import { join } from \"node:path\";\nimport { orderRunDag, type RunDagTask, runDagAncestors } from \"omk-protocol\";\nimport { ensureDurableDirectorySync } from \"../durable-file-io.ts\";\nimport { assertCandidateScope, captureCandidate, materializeCandidate, storeCandidate } from \"./candidate.ts\";\nimport { composeDagCandidate } from \"./dag-candidates.ts\";\nimport { readyDagTasks } from \"./dag-projection.ts\";\nimport { executeRunCommand } from \"./owned-execution.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { readRunClock, remainingRunTime } from \"./recovery-clock.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nfunction observeWork(context: RunPhaseContext): number {\n\tconst budget = context.journal.state.budget;\n\tif (!budget) throw new VerifiedRunError(\"input_checkpoint_missing\");\n\tconst clock = readRunClock();\n\tif (remainingRunTime(budget, budget.workDeadlineMs, clock) <= 0) throw new VerifiedRunError(\"deadline\");\n\treturn clock.nowMs;\n}\n\nasync function executeTask(context: RunPhaseContext, task: RunDagTask, deadline: number): Promise<void> {\n\tconst { contract, journal, runPath } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"unsupported\");\n\tif (context.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\tconst previous = journal.state.tasks.find((item) => item.taskId === task.id);\n\tif (previous?.status !== \"pending\") throw new VerifiedRunError(\"task_not_ready\");\n\tconst attempt = previous.attempt + 1;\n\tconst argv = task.attempts[previous.attempt];\n\tif (!argv) throw new VerifiedRunError(\"task_attempt_limit\");\n\tconst input = composeDagCandidate(context, runDagAncestors(contract.writer.tasks, task.id));\n\tstoreCandidate(input, runPath);\n\tconst workspace = join(runPath, \"tasks\", `${task.id}-${attempt}-g${journal.state.generation}`);\n\tmaterializeCandidate(input, workspace);\n\tjournal.append({\n\t\tkind: \"task_started\",\n\t\ttaskId: task.id,\n\t\tattempt,\n\t\tinputDigest: input.digest,\n\t\tobservedMs: observeWork(context),\n\t});\n\tconst { result } = await executeRunCommand(\n\t\tjournal,\n\t\t{ role: \"writer\", argv, workspace, deadline, claimId: null, taskId: task.id },\n\t\t{ ...contract.budget, ...(context.signal ? { signal: context.signal } : {}) },\n\t);\n\tif (result.failure === \"deadline\" || result.failure === \"cancelled\") throw new VerifiedRunError(result.failure);\n\tlet outputDigest: string | null = null;\n\tlet failure = result.failure;\n\tif (!failure) {\n\t\ttry {\n\t\t\tconst output = captureCandidate(workspace, contract.budget);\n\t\t\tassertCandidateScope(input.manifest, output.manifest, task.writablePaths);\n\t\t\tstoreCandidate(output, runPath);\n\t\t\toutputDigest = output.digest;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\t!(error instanceof VerifiedRunError) ||\n\t\t\t\t![\"scope_changed\", \"file_type\", \"storage_limit\"].includes(error.code)\n\t\t\t)\n\t\t\t\tthrow error;\n\t\t\tfailure = error.code;\n\t\t}\n\t}\n\tjournal.append({\n\t\tkind: \"task_finished\",\n\t\ttaskId: task.id,\n\t\tattempt,\n\t\toutputDigest,\n\t\tfailure,\n\t\tobservedMs: observeWork(context),\n\t});\n}\n\ntype TaskCompletion =\n\t| { readonly kind: \"done\"; readonly taskId: string }\n\t| { readonly kind: \"failed\"; readonly taskId: string; readonly error: unknown };\n\n/** Bounded ready frontier; every started task is drained before this phase returns or throws. */\nexport async function executeDag(\n\tcontext: RunPhaseContext,\n\toptions: { readonly workspace: string; readonly deadline: number },\n): Promise<void> {\n\tconst { contract, journal, runPath } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"unsupported\");\n\tensureDurableDirectorySync(join(runPath, \"tasks\"));\n\tconst order = orderRunDag(contract.writer.tasks);\n\tconst limit = contract.writer.maxConcurrentTasks ?? 1;\n\tconst stop = new AbortController();\n\tconst signal = context.signal ? AbortSignal.any([context.signal, stop.signal]) : stop.signal;\n\tconst work = { ...context, signal };\n\tconst inFlight = new Map<string, Promise<TaskCompletion>>();\n\tlet firstFailure: { readonly error: unknown } | undefined;\n\ttry {\n\t\tfor (;;) {\n\t\t\tif (firstFailure) throw firstFailure.error;\n\t\t\tif (signal.aborted) throw new VerifiedRunError(\"cancelled\");\n\t\t\tconst ready = new Set(readyDagTasks(contract.writer, journal.state).map((task) => task.id));\n\t\t\tfor (const task of order) {\n\t\t\t\tif (inFlight.size >= limit) break;\n\t\t\t\tif (!ready.has(task.id) || inFlight.has(task.id)) continue;\n\t\t\t\tconst completion = executeTask(work, task, options.deadline).then<TaskCompletion, TaskCompletion>(\n\t\t\t\t\t() => ({ kind: \"done\", taskId: task.id }),\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tfirstFailure ??= { error };\n\t\t\t\t\t\tstop.abort();\n\t\t\t\t\t\treturn { kind: \"failed\", taskId: task.id, error };\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tinFlight.set(task.id, completion);\n\t\t\t}\n\t\t\tif (!inFlight.size) break;\n\t\t\tconst completed = await Promise.race(inFlight.values());\n\t\t\tinFlight.delete(completed.taskId);\n\t\t\tswitch (completed.kind) {\n\t\t\t\tcase \"failed\":\n\t\t\t\t\tthrow completed.error;\n\t\t\t\tcase \"done\":\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: {\n\t\t\t\t\tconst exhaustive: never = completed;\n\t\t\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tstop.abort();\n\t\tawait Promise.all(inFlight.values());\n\t}\n\tif (\n\t\tjournal.state.tasks.some((task) => task.status !== \"succeeded\" || task.generation !== journal.state.generation)\n\t) {\n\t\tjournal.append({ kind: \"tasks_paused\" });\n\t\treturn;\n\t}\n\tobserveWork(context);\n\tmaterializeCandidate(composeDagCandidate(context, order), options.workspace);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dag-phase.js","sourceRoot":"","sources":["../../../src/core/verified-run/dag-phase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAmB,eAAe,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9G,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,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AAU,CAAC,EAC9G,CAAC;QACF,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QACzC,OAAO;IACR,CAAC;IACD,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,oBAAoB,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;AAAA,CAC7E","sourcesContent":["import { join } from \"node:path\";\nimport { orderRunDag, type RunDagTask, runDagAncestors } from \"omk-protocol\";\nimport { ensureDurableDirectorySync } from \"../durable-file-io.ts\";\nimport { assertCandidateScope, captureCandidate, materializeCandidate, storeCandidate } from \"./candidate.ts\";\nimport { composeDagCandidate } from \"./dag-candidates.ts\";\nimport { readyDagTasks } from \"./dag-projection.ts\";\nimport { executeRunCommand } from \"./owned-execution.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { readRunClock, remainingRunTime } from \"./recovery-clock.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nfunction observeWork(context: RunPhaseContext): number {\n\tconst budget = context.journal.state.budget;\n\tif (!budget) throw new VerifiedRunError(\"input_checkpoint_missing\");\n\tconst clock = readRunClock();\n\tif (remainingRunTime(budget, budget.workDeadlineMs, clock) <= 0) throw new VerifiedRunError(\"deadline\");\n\treturn clock.nowMs;\n}\n\nasync function executeTask(context: RunPhaseContext, task: RunDagTask, deadline: number): Promise<void> {\n\tconst { contract, journal, runPath } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"unsupported\");\n\tif (context.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\tconst previous = journal.state.tasks.find((item) => item.taskId === task.id);\n\tif (previous?.status !== \"pending\") throw new VerifiedRunError(\"task_not_ready\");\n\tconst attempt = previous.attempt + 1;\n\tconst argv = task.attempts[previous.attempt];\n\tif (!argv) throw new VerifiedRunError(\"task_attempt_limit\");\n\tconst input = composeDagCandidate(context, runDagAncestors(contract.writer.tasks, task.id));\n\tstoreCandidate(input, runPath);\n\tconst workspace = join(runPath, \"tasks\", `${task.id}-${attempt}-g${journal.state.generation}`);\n\tmaterializeCandidate(input, workspace);\n\tjournal.append({\n\t\tkind: \"task_started\",\n\t\ttaskId: task.id,\n\t\tattempt,\n\t\tinputDigest: input.digest,\n\t\tobservedMs: observeWork(context),\n\t});\n\tconst { result } = await executeRunCommand(\n\t\tjournal,\n\t\t{ role: \"writer\", argv, workspace, deadline, claimId: null, taskId: task.id },\n\t\t{ ...contract.budget, authority: context.authority, ...(context.signal ? { signal: context.signal } : {}) },\n\t);\n\tif (result.failure === \"deadline\" || result.failure === \"cancelled\") throw new VerifiedRunError(result.failure);\n\tlet outputDigest: string | null = null;\n\tlet failure = result.failure;\n\tif (!failure) {\n\t\ttry {\n\t\t\tconst output = captureCandidate(workspace, contract.budget);\n\t\t\tassertCandidateScope(input.manifest, output.manifest, task.writablePaths);\n\t\t\tstoreCandidate(output, runPath);\n\t\t\toutputDigest = output.digest;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\t!(error instanceof VerifiedRunError) ||\n\t\t\t\t![\"scope_changed\", \"file_type\", \"storage_limit\"].includes(error.code)\n\t\t\t)\n\t\t\t\tthrow error;\n\t\t\tfailure = error.code;\n\t\t}\n\t}\n\tjournal.append({\n\t\tkind: \"task_finished\",\n\t\ttaskId: task.id,\n\t\tattempt,\n\t\toutputDigest,\n\t\tfailure,\n\t\tobservedMs: observeWork(context),\n\t});\n}\n\ntype TaskCompletion =\n\t| { readonly kind: \"done\"; readonly taskId: string }\n\t| { readonly kind: \"failed\"; readonly taskId: string; readonly error: unknown };\n\n/** Bounded ready frontier; every started task is drained before this phase returns or throws. */\nexport async function executeDag(\n\tcontext: RunPhaseContext,\n\toptions: { readonly workspace: string; readonly deadline: number },\n): Promise<void> {\n\tconst { contract, journal, runPath } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"unsupported\");\n\tensureDurableDirectorySync(join(runPath, \"tasks\"));\n\tconst order = orderRunDag(contract.writer.tasks);\n\tconst limit = contract.writer.maxConcurrentTasks ?? 1;\n\tconst stop = new AbortController();\n\tconst signal = context.signal ? AbortSignal.any([context.signal, stop.signal]) : stop.signal;\n\tconst work = { ...context, signal };\n\tconst inFlight = new Map<string, Promise<TaskCompletion>>();\n\tlet firstFailure: { readonly error: unknown } | undefined;\n\ttry {\n\t\tfor (;;) {\n\t\t\tif (firstFailure) throw firstFailure.error;\n\t\t\tif (signal.aborted) throw new VerifiedRunError(\"cancelled\");\n\t\t\tconst ready = new Set(readyDagTasks(contract.writer, journal.state).map((task) => task.id));\n\t\t\tfor (const task of order) {\n\t\t\t\tif (inFlight.size >= limit) break;\n\t\t\t\tif (!ready.has(task.id) || inFlight.has(task.id)) continue;\n\t\t\t\tconst completion = executeTask(work, task, options.deadline).then<TaskCompletion, TaskCompletion>(\n\t\t\t\t\t() => ({ kind: \"done\", taskId: task.id }),\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tfirstFailure ??= { error };\n\t\t\t\t\t\tstop.abort();\n\t\t\t\t\t\treturn { kind: \"failed\", taskId: task.id, error };\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tinFlight.set(task.id, completion);\n\t\t\t}\n\t\t\tif (!inFlight.size) break;\n\t\t\tconst completed = await Promise.race(inFlight.values());\n\t\t\tinFlight.delete(completed.taskId);\n\t\t\tswitch (completed.kind) {\n\t\t\t\tcase \"failed\":\n\t\t\t\t\tthrow completed.error;\n\t\t\t\tcase \"done\":\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: {\n\t\t\t\t\tconst exhaustive: never = completed;\n\t\t\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tstop.abort();\n\t\tawait Promise.all(inFlight.values());\n\t}\n\tif (\n\t\tjournal.state.tasks.some((task) => task.status !== \"succeeded\" || task.generation !== journal.state.generation)\n\t) {\n\t\tjournal.append({ kind: \"tasks_paused\" });\n\t\treturn;\n\t}\n\tobserveWork(context);\n\tmaterializeCandidate(composeDagCandidate(context, order), options.workspace);\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type RunTaskRetryCommand } from "omk-protocol";
|
|
2
|
+
import type { RunAuthority } from "./authority-runtime.ts";
|
|
2
3
|
import type { RunProjection } from "./run-types.ts";
|
|
3
4
|
export interface TaskRecoveryInspection {
|
|
4
5
|
readonly state: RunProjection;
|
|
@@ -9,5 +10,8 @@ export interface TaskRecoveryInspection {
|
|
|
9
10
|
readonly ownership: "lease_required";
|
|
10
11
|
}
|
|
11
12
|
export declare function inspectTaskRecovery(runPath: string): TaskRecoveryInspection;
|
|
12
|
-
export declare function retryDagTasks(runPath: string, command: RunTaskRetryCommand,
|
|
13
|
+
export declare function retryDagTasks(runPath: string, command: RunTaskRetryCommand, options: {
|
|
14
|
+
readonly signal?: AbortSignal;
|
|
15
|
+
readonly authority: RunAuthority;
|
|
16
|
+
}): Promise<RunProjection>;
|
|
13
17
|
//# sourceMappingURL=dag-recovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dag-recovery.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/dag-recovery.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,mBAAmB,EAAmB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"dag-recovery.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/dag-recovery.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,mBAAmB,EAAmB,MAAM,cAAc,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAU3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAMpD,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;CACrC;AA0BD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,sBAAsB,CA+B3E;AAED,wBAAsB,aAAa,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAA;CAAE,GAC1E,OAAO,CAAC,aAAa,CAAC,CAgCxB","sourcesContent":["import { join } from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport { type RunTaskRetryCommand, runDagAncestors } from \"omk-protocol\";\nimport type { RunAuthority } from \"./authority-runtime.ts\";\nimport { probeVerifiedSandbox } from \"./broker.ts\";\nimport { assertCandidateScope, loadCandidate } from \"./candidate.ts\";\nimport { preflightCheckReceipts } from \"./check-receipt.ts\";\nimport { composeDagCandidate } from \"./dag-candidates.ts\";\nimport { executeDag } from \"./dag-phase.ts\";\nimport { assertTaskSelection, taskCheckpoints } from \"./dag-retry-projection.ts\";\nimport type { JournalSnapshot } from \"./journal.ts\";\nimport { readRunClock, remainingRunTime } from \"./recovery-clock.ts\";\nimport { requireRunJournal, withRecoveryLease } from \"./recovery-command.ts\";\nimport type { RunProjection } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { verifyCandidate } from \"./verification-phase.ts\";\nimport { assertWorkRecoverable } from \"./work-recovery.ts\";\nimport { publishWriterCandidate } from \"./writer-completion.ts\";\n\nexport interface TaskRecoveryInspection {\n\treadonly state: RunProjection;\n\treadonly readiness: \"ready\" | \"blocked\";\n\treadonly reason: string | null;\n\treadonly retryableTaskIds: readonly string[];\n\treadonly remainingWorkMs: number | null;\n\treadonly ownership: \"lease_required\";\n}\n\nfunction assertDagRecoverable(runPath: string, snapshot: JournalSnapshot) {\n\tconst recovery = assertWorkRecoverable(runPath, snapshot);\n\tconst { contract } = recovery;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"task_recovery_unavailable\");\n\tfor (const task of snapshot.state.tasks) {\n\t\tif (task.status === \"pending\") continue;\n\t\tconst definition = contract.writer.tasks.find((item) => item.id === task.taskId);\n\t\tif (!definition) throw new VerifiedRunError(\"integrity\");\n\t\tconst expected = composeDagCandidate(\n\t\t\t{ runPath, contract, journal: snapshot },\n\t\t\trunDagAncestors(contract.writer.tasks, task.taskId),\n\t\t);\n\t\tconst input = loadCandidate(runPath, task.inputDigest, contract.budget);\n\t\tif (input.digest !== expected.digest) throw new VerifiedRunError(\"task_checkpoint_mismatch\");\n\t\tif (task.status === \"succeeded\")\n\t\t\tassertCandidateScope(\n\t\t\t\tinput.manifest,\n\t\t\t\tloadCandidate(runPath, task.outputDigest, contract.budget).manifest,\n\t\t\t\tdefinition.writablePaths,\n\t\t\t);\n\t}\n\treturn { contract, remainingMs: recovery.remainingMs };\n}\n\nexport function inspectTaskRecovery(runPath: string): TaskRecoveryInspection {\n\tconst snapshot = requireRunJournal(runPath);\n\ttry {\n\t\tconst { contract, remainingMs } = assertDagRecoverable(runPath, snapshot);\n\t\tconst taskIds = snapshot.state.tasks\n\t\t\t.filter(\n\t\t\t\t(task) =>\n\t\t\t\t\t(task.status === \"failed\" || task.status === \"running\") &&\n\t\t\t\t\ttask.attempt < (contract.writer.tasks.find((item) => item.id === task.taskId)?.attempts.length ?? 0),\n\t\t\t)\n\t\t\t.map((task) => task.taskId);\n\t\tassertTaskSelection(contract, snapshot.state, taskIds);\n\t\treturn Object.freeze({\n\t\t\tstate: snapshot.state,\n\t\t\treadiness: \"ready\",\n\t\t\treason: null,\n\t\t\tretryableTaskIds: Object.freeze(taskIds),\n\t\t\tremainingWorkMs: remainingMs,\n\t\t\townership: \"lease_required\",\n\t\t});\n\t} catch (error) {\n\t\tif (!(error instanceof Error)) throw error;\n\t\treturn Object.freeze({\n\t\t\tstate: snapshot.state,\n\t\t\treadiness: \"blocked\",\n\t\t\treason: error instanceof VerifiedRunError ? error.code : \"integrity\",\n\t\t\tretryableTaskIds: Object.freeze([]),\n\t\t\tremainingWorkMs: null,\n\t\t\townership: \"lease_required\",\n\t\t});\n\t}\n}\n\nexport async function retryDagTasks(\n\trunPath: string,\n\tcommand: RunTaskRetryCommand,\n\toptions: { readonly signal?: AbortSignal; readonly authority: RunAuthority },\n): Promise<RunProjection> {\n\tif (options.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\treturn withRecoveryLease(runPath, command, async ({ snapshot, journal }) => {\n\t\tconst { contract } = assertDagRecoverable(runPath, snapshot);\n\t\tassertTaskSelection(contract, snapshot.state, command.taskIds);\n\t\tpreflightCheckReceipts(contract);\n\t\tprobeVerifiedSandbox();\n\t\tassertDagRecoverable(runPath, snapshot);\n\t\tif (options.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\t\tjournal.append({\n\t\t\tkind: \"tasks_retried\",\n\t\t\tcommand,\n\t\t\tobservedMs: readRunClock().nowMs,\n\t\t\treconciledExecutionIds: snapshot.state.activeExecutionIds,\n\t\t\tadopted: taskCheckpoints(snapshot.state),\n\t\t});\n\t\tconst budget = journal.state.budget;\n\t\tif (!budget) throw new VerifiedRunError(\"integrity\");\n\t\tconst deadline = performance.now() + remainingRunTime(budget, budget.workDeadlineMs);\n\t\tconst workspace = join(runPath, `writer-${journal.state.generation}`);\n\t\tconst context = {\n\t\t\trunPath,\n\t\t\tcontract,\n\t\t\tjournal,\n\t\t\tauthority: options.authority,\n\t\t\t...(options.signal ? { signal: options.signal } : {}),\n\t\t};\n\t\tawait executeDag(context, { workspace, deadline });\n\t\tif (journal.state.execution === \"paused\") return journal.state;\n\t\tpublishWriterCandidate(context, workspace, deadline);\n\t\treturn verifyCandidate(context);\n\t});\n}\n"]}
|
|
@@ -64,8 +64,8 @@ export function inspectTaskRecovery(runPath) {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
export async function retryDagTasks(runPath, command,
|
|
68
|
-
if (signal?.aborted)
|
|
67
|
+
export async function retryDagTasks(runPath, command, options) {
|
|
68
|
+
if (options.signal?.aborted)
|
|
69
69
|
throw new VerifiedRunError("cancelled");
|
|
70
70
|
return withRecoveryLease(runPath, command, async ({ snapshot, journal }) => {
|
|
71
71
|
const { contract } = assertDagRecoverable(runPath, snapshot);
|
|
@@ -73,7 +73,7 @@ export async function retryDagTasks(runPath, command, signal) {
|
|
|
73
73
|
preflightCheckReceipts(contract);
|
|
74
74
|
probeVerifiedSandbox();
|
|
75
75
|
assertDagRecoverable(runPath, snapshot);
|
|
76
|
-
if (signal?.aborted)
|
|
76
|
+
if (options.signal?.aborted)
|
|
77
77
|
throw new VerifiedRunError("cancelled");
|
|
78
78
|
journal.append({
|
|
79
79
|
kind: "tasks_retried",
|
|
@@ -87,7 +87,13 @@ export async function retryDagTasks(runPath, command, signal) {
|
|
|
87
87
|
throw new VerifiedRunError("integrity");
|
|
88
88
|
const deadline = performance.now() + remainingRunTime(budget, budget.workDeadlineMs);
|
|
89
89
|
const workspace = join(runPath, `writer-${journal.state.generation}`);
|
|
90
|
-
const context = {
|
|
90
|
+
const context = {
|
|
91
|
+
runPath,
|
|
92
|
+
contract,
|
|
93
|
+
journal,
|
|
94
|
+
authority: options.authority,
|
|
95
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
96
|
+
};
|
|
91
97
|
await executeDag(context, { workspace, deadline });
|
|
92
98
|
if (journal.state.execution === "paused")
|
|
93
99
|
return journal.state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dag-recovery.js","sourceRoot":"","sources":["../../../src/core/verified-run/dag-recovery.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E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QAC9E,MAAM,UAAU,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;QACnD,IAAI,OAAO,CAAC,KAAK,CAAC,SAAS,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC,KAAK,CAAC;QAC/D,sBAAsB,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACrD,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;IAAA,CAChC,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { join } from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport { type RunTaskRetryCommand, runDagAncestors } from \"omk-protocol\";\nimport { probeVerifiedSandbox } from \"./broker.ts\";\nimport { assertCandidateScope, loadCandidate } from \"./candidate.ts\";\nimport { preflightCheckReceipts } from \"./check-receipt.ts\";\nimport { composeDagCandidate } from \"./dag-candidates.ts\";\nimport { executeDag } from \"./dag-phase.ts\";\nimport { assertTaskSelection, taskCheckpoints } from \"./dag-retry-projection.ts\";\nimport type { JournalSnapshot } from \"./journal.ts\";\nimport { readRunClock, remainingRunTime } from \"./recovery-clock.ts\";\nimport { requireRunJournal, withRecoveryLease } from \"./recovery-command.ts\";\nimport type { RunProjection } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { verifyCandidate } from \"./verification-phase.ts\";\nimport { assertWorkRecoverable } from \"./work-recovery.ts\";\nimport { publishWriterCandidate } from \"./writer-completion.ts\";\n\nexport interface TaskRecoveryInspection {\n\treadonly state: RunProjection;\n\treadonly readiness: \"ready\" | \"blocked\";\n\treadonly reason: string | null;\n\treadonly retryableTaskIds: readonly string[];\n\treadonly remainingWorkMs: number | null;\n\treadonly ownership: \"lease_required\";\n}\n\nfunction assertDagRecoverable(runPath: string, snapshot: JournalSnapshot) {\n\tconst recovery = assertWorkRecoverable(runPath, snapshot);\n\tconst { contract } = recovery;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"task_recovery_unavailable\");\n\tfor (const task of snapshot.state.tasks) {\n\t\tif (task.status === \"pending\") continue;\n\t\tconst definition = contract.writer.tasks.find((item) => item.id === task.taskId);\n\t\tif (!definition) throw new VerifiedRunError(\"integrity\");\n\t\tconst expected = composeDagCandidate(\n\t\t\t{ runPath, contract, journal: snapshot },\n\t\t\trunDagAncestors(contract.writer.tasks, task.taskId),\n\t\t);\n\t\tconst input = loadCandidate(runPath, task.inputDigest, contract.budget);\n\t\tif (input.digest !== expected.digest) throw new VerifiedRunError(\"task_checkpoint_mismatch\");\n\t\tif (task.status === \"succeeded\")\n\t\t\tassertCandidateScope(\n\t\t\t\tinput.manifest,\n\t\t\t\tloadCandidate(runPath, task.outputDigest, contract.budget).manifest,\n\t\t\t\tdefinition.writablePaths,\n\t\t\t);\n\t}\n\treturn { contract, remainingMs: recovery.remainingMs };\n}\n\nexport function inspectTaskRecovery(runPath: string): TaskRecoveryInspection {\n\tconst snapshot = requireRunJournal(runPath);\n\ttry {\n\t\tconst { contract, remainingMs } = assertDagRecoverable(runPath, snapshot);\n\t\tconst taskIds = snapshot.state.tasks\n\t\t\t.filter(\n\t\t\t\t(task) =>\n\t\t\t\t\t(task.status === \"failed\" || task.status === \"running\") &&\n\t\t\t\t\ttask.attempt < (contract.writer.tasks.find((item) => item.id === task.taskId)?.attempts.length ?? 0),\n\t\t\t)\n\t\t\t.map((task) => task.taskId);\n\t\tassertTaskSelection(contract, snapshot.state, taskIds);\n\t\treturn Object.freeze({\n\t\t\tstate: snapshot.state,\n\t\t\treadiness: \"ready\",\n\t\t\treason: null,\n\t\t\tretryableTaskIds: Object.freeze(taskIds),\n\t\t\tremainingWorkMs: remainingMs,\n\t\t\townership: \"lease_required\",\n\t\t});\n\t} catch (error) {\n\t\tif (!(error instanceof Error)) throw error;\n\t\treturn Object.freeze({\n\t\t\tstate: snapshot.state,\n\t\t\treadiness: \"blocked\",\n\t\t\treason: error instanceof VerifiedRunError ? error.code : \"integrity\",\n\t\t\tretryableTaskIds: Object.freeze([]),\n\t\t\tremainingWorkMs: null,\n\t\t\townership: \"lease_required\",\n\t\t});\n\t}\n}\n\nexport async function retryDagTasks(\n\trunPath: string,\n\tcommand: RunTaskRetryCommand,\n\tsignal?: AbortSignal,\n): Promise<RunProjection> {\n\tif (signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\treturn withRecoveryLease(runPath, command, async ({ snapshot, journal }) => {\n\t\tconst { contract } = assertDagRecoverable(runPath, snapshot);\n\t\tassertTaskSelection(contract, snapshot.state, command.taskIds);\n\t\tpreflightCheckReceipts(contract);\n\t\tprobeVerifiedSandbox();\n\t\tassertDagRecoverable(runPath, snapshot);\n\t\tif (signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\t\tjournal.append({\n\t\t\tkind: \"tasks_retried\",\n\t\t\tcommand,\n\t\t\tobservedMs: readRunClock().nowMs,\n\t\t\treconciledExecutionIds: snapshot.state.activeExecutionIds,\n\t\t\tadopted: taskCheckpoints(snapshot.state),\n\t\t});\n\t\tconst budget = journal.state.budget;\n\t\tif (!budget) throw new VerifiedRunError(\"integrity\");\n\t\tconst deadline = performance.now() + remainingRunTime(budget, budget.workDeadlineMs);\n\t\tconst workspace = join(runPath, `writer-${journal.state.generation}`);\n\t\tconst context = { runPath, contract, journal, ...(signal ? { signal } : {}) };\n\t\tawait executeDag(context, { workspace, deadline });\n\t\tif (journal.state.execution === \"paused\") return journal.state;\n\t\tpublishWriterCandidate(context, workspace, deadline);\n\t\treturn verifyCandidate(context);\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dag-recovery.js","sourceRoot":"","sources":["../../../src/core/verified-run/dag-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAA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,SAAS;YAC5B,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACrD,CAAC;QACF,MAAM,UAAU,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;QACnD,IAAI,OAAO,CAAC,KAAK,CAAC,SAAS,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC,KAAK,CAAC;QAC/D,sBAAsB,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACrD,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;IAAA,CAChC,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { join } from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport { type RunTaskRetryCommand, runDagAncestors } from \"omk-protocol\";\nimport type { RunAuthority } from \"./authority-runtime.ts\";\nimport { probeVerifiedSandbox } from \"./broker.ts\";\nimport { assertCandidateScope, loadCandidate } from \"./candidate.ts\";\nimport { preflightCheckReceipts } from \"./check-receipt.ts\";\nimport { composeDagCandidate } from \"./dag-candidates.ts\";\nimport { executeDag } from \"./dag-phase.ts\";\nimport { assertTaskSelection, taskCheckpoints } from \"./dag-retry-projection.ts\";\nimport type { JournalSnapshot } from \"./journal.ts\";\nimport { readRunClock, remainingRunTime } from \"./recovery-clock.ts\";\nimport { requireRunJournal, withRecoveryLease } from \"./recovery-command.ts\";\nimport type { RunProjection } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { verifyCandidate } from \"./verification-phase.ts\";\nimport { assertWorkRecoverable } from \"./work-recovery.ts\";\nimport { publishWriterCandidate } from \"./writer-completion.ts\";\n\nexport interface TaskRecoveryInspection {\n\treadonly state: RunProjection;\n\treadonly readiness: \"ready\" | \"blocked\";\n\treadonly reason: string | null;\n\treadonly retryableTaskIds: readonly string[];\n\treadonly remainingWorkMs: number | null;\n\treadonly ownership: \"lease_required\";\n}\n\nfunction assertDagRecoverable(runPath: string, snapshot: JournalSnapshot) {\n\tconst recovery = assertWorkRecoverable(runPath, snapshot);\n\tconst { contract } = recovery;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"task_recovery_unavailable\");\n\tfor (const task of snapshot.state.tasks) {\n\t\tif (task.status === \"pending\") continue;\n\t\tconst definition = contract.writer.tasks.find((item) => item.id === task.taskId);\n\t\tif (!definition) throw new VerifiedRunError(\"integrity\");\n\t\tconst expected = composeDagCandidate(\n\t\t\t{ runPath, contract, journal: snapshot },\n\t\t\trunDagAncestors(contract.writer.tasks, task.taskId),\n\t\t);\n\t\tconst input = loadCandidate(runPath, task.inputDigest, contract.budget);\n\t\tif (input.digest !== expected.digest) throw new VerifiedRunError(\"task_checkpoint_mismatch\");\n\t\tif (task.status === \"succeeded\")\n\t\t\tassertCandidateScope(\n\t\t\t\tinput.manifest,\n\t\t\t\tloadCandidate(runPath, task.outputDigest, contract.budget).manifest,\n\t\t\t\tdefinition.writablePaths,\n\t\t\t);\n\t}\n\treturn { contract, remainingMs: recovery.remainingMs };\n}\n\nexport function inspectTaskRecovery(runPath: string): TaskRecoveryInspection {\n\tconst snapshot = requireRunJournal(runPath);\n\ttry {\n\t\tconst { contract, remainingMs } = assertDagRecoverable(runPath, snapshot);\n\t\tconst taskIds = snapshot.state.tasks\n\t\t\t.filter(\n\t\t\t\t(task) =>\n\t\t\t\t\t(task.status === \"failed\" || task.status === \"running\") &&\n\t\t\t\t\ttask.attempt < (contract.writer.tasks.find((item) => item.id === task.taskId)?.attempts.length ?? 0),\n\t\t\t)\n\t\t\t.map((task) => task.taskId);\n\t\tassertTaskSelection(contract, snapshot.state, taskIds);\n\t\treturn Object.freeze({\n\t\t\tstate: snapshot.state,\n\t\t\treadiness: \"ready\",\n\t\t\treason: null,\n\t\t\tretryableTaskIds: Object.freeze(taskIds),\n\t\t\tremainingWorkMs: remainingMs,\n\t\t\townership: \"lease_required\",\n\t\t});\n\t} catch (error) {\n\t\tif (!(error instanceof Error)) throw error;\n\t\treturn Object.freeze({\n\t\t\tstate: snapshot.state,\n\t\t\treadiness: \"blocked\",\n\t\t\treason: error instanceof VerifiedRunError ? error.code : \"integrity\",\n\t\t\tretryableTaskIds: Object.freeze([]),\n\t\t\tremainingWorkMs: null,\n\t\t\townership: \"lease_required\",\n\t\t});\n\t}\n}\n\nexport async function retryDagTasks(\n\trunPath: string,\n\tcommand: RunTaskRetryCommand,\n\toptions: { readonly signal?: AbortSignal; readonly authority: RunAuthority },\n): Promise<RunProjection> {\n\tif (options.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\treturn withRecoveryLease(runPath, command, async ({ snapshot, journal }) => {\n\t\tconst { contract } = assertDagRecoverable(runPath, snapshot);\n\t\tassertTaskSelection(contract, snapshot.state, command.taskIds);\n\t\tpreflightCheckReceipts(contract);\n\t\tprobeVerifiedSandbox();\n\t\tassertDagRecoverable(runPath, snapshot);\n\t\tif (options.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\t\tjournal.append({\n\t\t\tkind: \"tasks_retried\",\n\t\t\tcommand,\n\t\t\tobservedMs: readRunClock().nowMs,\n\t\t\treconciledExecutionIds: snapshot.state.activeExecutionIds,\n\t\t\tadopted: taskCheckpoints(snapshot.state),\n\t\t});\n\t\tconst budget = journal.state.budget;\n\t\tif (!budget) throw new VerifiedRunError(\"integrity\");\n\t\tconst deadline = performance.now() + remainingRunTime(budget, budget.workDeadlineMs);\n\t\tconst workspace = join(runPath, `writer-${journal.state.generation}`);\n\t\tconst context = {\n\t\t\trunPath,\n\t\t\tcontract,\n\t\t\tjournal,\n\t\t\tauthority: options.authority,\n\t\t\t...(options.signal ? { signal: options.signal } : {}),\n\t\t};\n\t\tawait executeDag(context, { workspace, deadline });\n\t\tif (journal.state.execution === \"paused\") return journal.state;\n\t\tpublishWriterCandidate(context, workspace, deadline);\n\t\treturn verifyCandidate(context);\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-parser.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/event-parser.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"event-parser.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/event-parser.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAsC/C,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CAuIpD","sourcesContent":["import {\n\tparseRunContract,\n\tparseRunResumeCommand,\n\tparseRunStartCommand,\n\tparseRunTaskRetryCommand,\n\tparseRunWriterRestartCommand,\n} from \"omk-protocol\";\nimport type { RunTaskCheckpoint } from \"./dag-types.ts\";\nimport { parseNamespaceIdentity } from \"./namespace-identity.ts\";\nimport { parseRecoveryBudget } from \"./recovery-clock.ts\";\nimport type { RunEvent } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nfunction text(value: unknown): string {\n\tif (typeof value !== \"string\" || !/^[A-Za-z0-9_-]{1,128}$/.test(value)) throw new VerifiedRunError(\"integrity\");\n\treturn value;\n}\nfunction digest(value: unknown): string {\n\tconst result = text(value);\n\tif (!/^[a-f0-9]{64}$/.test(result)) throw new VerifiedRunError(\"integrity\");\n\treturn result;\n}\nfunction integer(value: unknown): number {\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0) throw new VerifiedRunError(\"integrity\");\n\treturn value;\n}\nfunction oid(value: unknown, zeroAllowed: boolean): string {\n\tif (typeof value !== \"string\" || !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(value))\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tif (!zeroAllowed && /^0+$/.test(value)) throw new VerifiedRunError(\"integrity\");\n\treturn value;\n}\n\nfunction checkpoint(raw: unknown): RunTaskCheckpoint {\n\tif (typeof raw !== \"object\" || raw === null) throw new VerifiedRunError(\"integrity\");\n\tconst value: Record<string, unknown> = Object.fromEntries(Object.entries(raw));\n\tif (value.status !== \"succeeded\" || value.failure !== null) throw new VerifiedRunError(\"integrity\");\n\treturn Object.freeze({\n\t\ttaskId: text(value.taskId),\n\t\tattempt: integer(value.attempt),\n\t\tgeneration: integer(value.generation),\n\t\tstatus: \"succeeded\",\n\t\tinputDigest: digest(value.inputDigest),\n\t\toutputDigest: digest(value.outputDigest),\n\t\tfailure: null,\n\t});\n}\n\nexport function parseRunEvent(raw: unknown): RunEvent {\n\tif (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) throw new VerifiedRunError(\"integrity\");\n\tconst value: Record<string, unknown> = Object.fromEntries(Object.entries(raw));\n\tswitch (value.kind) {\n\t\tcase \"created\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tcontract: parseRunContract(value.contract),\n\t\t\t\tcommand: parseRunStartCommand(value.command),\n\t\t\t};\n\t\tcase \"budget_anchored\":\n\t\t\tif (value.driver !== \"linux-pidns-gate-v1\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tbudget: parseRecoveryBudget(value.budget),\n\t\t\t\tenvironmentDigest: digest(value.environmentDigest),\n\t\t\t\tdriver: value.driver,\n\t\t\t};\n\t\tcase \"dispatch\": {\n\t\t\tif (value.role !== \"writer\" && value.role !== \"verifier\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\texecutionId: text(value.executionId),\n\t\t\t\trole: value.role,\n\t\t\t\tclaimId: value.claimId === null ? null : text(value.claimId),\n\t\t\t\t...(value.taskId === undefined ? {} : { taskId: text(value.taskId) }),\n\t\t\t};\n\t\t}\n\t\tcase \"input_checkpoint\":\n\t\t\treturn { kind: value.kind, digest: digest(value.digest) };\n\t\tcase \"process_ready\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\texecutionId: text(value.executionId),\n\t\t\t\tidentity: parseNamespaceIdentity(value.identity),\n\t\t\t};\n\t\tcase \"task_started\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\ttaskId: text(value.taskId),\n\t\t\t\tattempt: integer(value.attempt),\n\t\t\t\tinputDigest: digest(value.inputDigest),\n\t\t\t\tobservedMs: integer(value.observedMs),\n\t\t\t};\n\t\tcase \"task_finished\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\ttaskId: text(value.taskId),\n\t\t\t\tattempt: integer(value.attempt),\n\t\t\t\toutputDigest: value.outputDigest === null ? null : digest(value.outputDigest),\n\t\t\t\tfailure: value.failure === null ? null : text(value.failure),\n\t\t\t\tobservedMs: integer(value.observedMs),\n\t\t\t};\n\t\tcase \"tasks_paused\":\n\t\tcase \"writer_opened\":\n\t\t\treturn { kind: value.kind };\n\t\tcase \"model_request\":\n\t\t\treturn { kind: value.kind, requestId: text(value.requestId) };\n\t\tcase \"writer_closed\":\n\t\t\tif (typeof value.completed !== \"boolean\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn { kind: value.kind, completed: value.completed };\n\t\tcase \"exited\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\texecutionId: text(value.executionId),\n\t\t\t\tfailure: value.failure === null ? null : text(value.failure),\n\t\t\t};\n\t\tcase \"candidate\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tdigest: digest(value.digest),\n\t\t\t\t...(value.observedMs === undefined ? {} : { observedMs: integer(value.observedMs) }),\n\t\t\t\t...(value.verificationDeadlineMs === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { verificationDeadlineMs: integer(value.verificationDeadlineMs) }),\n\t\t\t};\n\t\tcase \"resumed\":\n\t\tcase \"tasks_retried\":\n\t\tcase \"writer_restarted\": {\n\t\t\tif (!Array.isArray(value.reconciledExecutionIds) || value.reconciledExecutionIds.length > 128)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tconst fields = {\n\t\t\t\tobservedMs: integer(value.observedMs),\n\t\t\t\treconciledExecutionIds: Object.freeze(value.reconciledExecutionIds.map(text)),\n\t\t\t};\n\t\t\tswitch (value.kind) {\n\t\t\t\tcase \"resumed\":\n\t\t\t\t\treturn { ...fields, kind: value.kind, command: parseRunResumeCommand(value.command) };\n\t\t\t\tcase \"writer_restarted\":\n\t\t\t\t\treturn { ...fields, kind: value.kind, command: parseRunWriterRestartCommand(value.command) };\n\t\t\t\tcase \"tasks_retried\":\n\t\t\t\t\tif (!Array.isArray(value.adopted) || value.adopted.length > 16) throw new VerifiedRunError(\"integrity\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t\tkind: value.kind,\n\t\t\t\t\t\tcommand: parseRunTaskRetryCommand(value.command),\n\t\t\t\t\t\tadopted: Object.freeze(value.adopted.map(checkpoint)),\n\t\t\t\t\t};\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t}\n\t\t}\n\t\tcase \"evaluated\":\n\t\t\tif (typeof value.verified !== \"boolean\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn { kind: value.kind, receiptDigest: digest(value.receiptDigest), verified: value.verified };\n\t\tcase \"publish_intent\": {\n\t\t\tconst candidateOid = oid(value.candidateOid, false);\n\t\t\tconst parentOid = oid(value.parentOid, true);\n\t\t\tif (value.targetRef !== \"refs/omk/accepted\" || parentOid.length !== candidateOid.length)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tcommandId: text(value.commandId),\n\t\t\t\tcandidateDigest: digest(value.candidateDigest),\n\t\t\t\tcandidateOid,\n\t\t\t\tparentOid,\n\t\t\t\ttargetRef: value.targetRef,\n\t\t\t\treceiptDigest: digest(value.receiptDigest),\n\t\t\t\tpolicyDigest: digest(value.policyDigest),\n\t\t\t\tgeneration: integer(value.generation),\n\t\t\t};\n\t\t}\n\t\tcase \"published\": {\n\t\t\tconst candidateOid = oid(value.candidateOid, false);\n\t\t\tconst previousOid = oid(value.previousOid, true);\n\t\t\tif (previousOid.length !== candidateOid.length) throw new VerifiedRunError(\"integrity\");\n\t\t\treturn { kind: value.kind, commandId: text(value.commandId), candidateOid, previousOid };\n\t\t}\n\t\tcase \"publish_failed\":\n\t\t\treturn { kind: value.kind, commandId: text(value.commandId), code: text(value.code) };\n\t\tcase \"failed\":\n\t\t\treturn { kind: value.kind, code: text(value.code) };\n\t\tdefault:\n\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t}\n}\n"]}
|
|
@@ -18,6 +18,13 @@ function integer(value) {
|
|
|
18
18
|
throw new VerifiedRunError("integrity");
|
|
19
19
|
return value;
|
|
20
20
|
}
|
|
21
|
+
function oid(value, zeroAllowed) {
|
|
22
|
+
if (typeof value !== "string" || !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(value))
|
|
23
|
+
throw new VerifiedRunError("integrity");
|
|
24
|
+
if (!zeroAllowed && /^0+$/.test(value))
|
|
25
|
+
throw new VerifiedRunError("integrity");
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
21
28
|
function checkpoint(raw) {
|
|
22
29
|
if (typeof raw !== "object" || raw === null)
|
|
23
30
|
throw new VerifiedRunError("integrity");
|
|
@@ -145,6 +152,32 @@ export function parseRunEvent(raw) {
|
|
|
145
152
|
if (typeof value.verified !== "boolean")
|
|
146
153
|
throw new VerifiedRunError("integrity");
|
|
147
154
|
return { kind: value.kind, receiptDigest: digest(value.receiptDigest), verified: value.verified };
|
|
155
|
+
case "publish_intent": {
|
|
156
|
+
const candidateOid = oid(value.candidateOid, false);
|
|
157
|
+
const parentOid = oid(value.parentOid, true);
|
|
158
|
+
if (value.targetRef !== "refs/omk/accepted" || parentOid.length !== candidateOid.length)
|
|
159
|
+
throw new VerifiedRunError("integrity");
|
|
160
|
+
return {
|
|
161
|
+
kind: value.kind,
|
|
162
|
+
commandId: text(value.commandId),
|
|
163
|
+
candidateDigest: digest(value.candidateDigest),
|
|
164
|
+
candidateOid,
|
|
165
|
+
parentOid,
|
|
166
|
+
targetRef: value.targetRef,
|
|
167
|
+
receiptDigest: digest(value.receiptDigest),
|
|
168
|
+
policyDigest: digest(value.policyDigest),
|
|
169
|
+
generation: integer(value.generation),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
case "published": {
|
|
173
|
+
const candidateOid = oid(value.candidateOid, false);
|
|
174
|
+
const previousOid = oid(value.previousOid, true);
|
|
175
|
+
if (previousOid.length !== candidateOid.length)
|
|
176
|
+
throw new VerifiedRunError("integrity");
|
|
177
|
+
return { kind: value.kind, commandId: text(value.commandId), candidateOid, previousOid };
|
|
178
|
+
}
|
|
179
|
+
case "publish_failed":
|
|
180
|
+
return { kind: value.kind, commandId: text(value.commandId), code: text(value.code) };
|
|
148
181
|
case "failed":
|
|
149
182
|
return { kind: value.kind, code: text(value.code) };
|
|
150
183
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-parser.js","sourceRoot":"","sources":["../../../src/core/verified-run/event-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,GAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,SAAS,IAAI,CAAC,KAAc,EAAU;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAChH,OAAO,KAAK,CAAC;AAAA,CACb;AACD,SAAS,MAAM,C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AC,GAAG,CAAC,UAAU,CAAC,CAAC;qBACrD,CAAC;gBACH;oBACC,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;YAC1C,CAAC;QACF,CAAC;QACD,KAAK,WAAW;YACf,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,SAAS;gBAAE,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;YACjF,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnG,KAAK,QAAQ;YACZ,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD;YACC,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;AAAA,CACD","sourcesContent":["import {\n\tparseRunContract,\n\tparseRunResumeCommand,\n\tparseRunStartCommand,\n\tparseRunTaskRetryCommand,\n\tparseRunWriterRestartCommand,\n} from \"omk-protocol\";\nimport type { RunTaskCheckpoint } from \"./dag-types.ts\";\nimport { parseNamespaceIdentity } from \"./namespace-identity.ts\";\nimport { parseRecoveryBudget } from \"./recovery-clock.ts\";\nimport type { RunEvent } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nfunction text(value: unknown): string {\n\tif (typeof value !== \"string\" || !/^[A-Za-z0-9_-]{1,128}$/.test(value)) throw new VerifiedRunError(\"integrity\");\n\treturn value;\n}\nfunction digest(value: unknown): string {\n\tconst result = text(value);\n\tif (!/^[a-f0-9]{64}$/.test(result)) throw new VerifiedRunError(\"integrity\");\n\treturn result;\n}\nfunction integer(value: unknown): number {\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0) throw new VerifiedRunError(\"integrity\");\n\treturn value;\n}\n\nfunction checkpoint(raw: unknown): RunTaskCheckpoint {\n\tif (typeof raw !== \"object\" || raw === null) throw new VerifiedRunError(\"integrity\");\n\tconst value: Record<string, unknown> = Object.fromEntries(Object.entries(raw));\n\tif (value.status !== \"succeeded\" || value.failure !== null) throw new VerifiedRunError(\"integrity\");\n\treturn Object.freeze({\n\t\ttaskId: text(value.taskId),\n\t\tattempt: integer(value.attempt),\n\t\tgeneration: integer(value.generation),\n\t\tstatus: \"succeeded\",\n\t\tinputDigest: digest(value.inputDigest),\n\t\toutputDigest: digest(value.outputDigest),\n\t\tfailure: null,\n\t});\n}\n\nexport function parseRunEvent(raw: unknown): RunEvent {\n\tif (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) throw new VerifiedRunError(\"integrity\");\n\tconst value: Record<string, unknown> = Object.fromEntries(Object.entries(raw));\n\tswitch (value.kind) {\n\t\tcase \"created\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tcontract: parseRunContract(value.contract),\n\t\t\t\tcommand: parseRunStartCommand(value.command),\n\t\t\t};\n\t\tcase \"budget_anchored\":\n\t\t\tif (value.driver !== \"linux-pidns-gate-v1\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tbudget: parseRecoveryBudget(value.budget),\n\t\t\t\tenvironmentDigest: digest(value.environmentDigest),\n\t\t\t\tdriver: value.driver,\n\t\t\t};\n\t\tcase \"dispatch\": {\n\t\t\tif (value.role !== \"writer\" && value.role !== \"verifier\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\texecutionId: text(value.executionId),\n\t\t\t\trole: value.role,\n\t\t\t\tclaimId: value.claimId === null ? null : text(value.claimId),\n\t\t\t\t...(value.taskId === undefined ? {} : { taskId: text(value.taskId) }),\n\t\t\t};\n\t\t}\n\t\tcase \"input_checkpoint\":\n\t\t\treturn { kind: value.kind, digest: digest(value.digest) };\n\t\tcase \"process_ready\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\texecutionId: text(value.executionId),\n\t\t\t\tidentity: parseNamespaceIdentity(value.identity),\n\t\t\t};\n\t\tcase \"task_started\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\ttaskId: text(value.taskId),\n\t\t\t\tattempt: integer(value.attempt),\n\t\t\t\tinputDigest: digest(value.inputDigest),\n\t\t\t\tobservedMs: integer(value.observedMs),\n\t\t\t};\n\t\tcase \"task_finished\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\ttaskId: text(value.taskId),\n\t\t\t\tattempt: integer(value.attempt),\n\t\t\t\toutputDigest: value.outputDigest === null ? null : digest(value.outputDigest),\n\t\t\t\tfailure: value.failure === null ? null : text(value.failure),\n\t\t\t\tobservedMs: integer(value.observedMs),\n\t\t\t};\n\t\tcase \"tasks_paused\":\n\t\tcase \"writer_opened\":\n\t\t\treturn { kind: value.kind };\n\t\tcase \"model_request\":\n\t\t\treturn { kind: value.kind, requestId: text(value.requestId) };\n\t\tcase \"writer_closed\":\n\t\t\tif (typeof value.completed !== \"boolean\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn { kind: value.kind, completed: value.completed };\n\t\tcase \"exited\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\texecutionId: text(value.executionId),\n\t\t\t\tfailure: value.failure === null ? null : text(value.failure),\n\t\t\t};\n\t\tcase \"candidate\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tdigest: digest(value.digest),\n\t\t\t\t...(value.observedMs === undefined ? {} : { observedMs: integer(value.observedMs) }),\n\t\t\t\t...(value.verificationDeadlineMs === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { verificationDeadlineMs: integer(value.verificationDeadlineMs) }),\n\t\t\t};\n\t\tcase \"resumed\":\n\t\tcase \"tasks_retried\":\n\t\tcase \"writer_restarted\": {\n\t\t\tif (!Array.isArray(value.reconciledExecutionIds) || value.reconciledExecutionIds.length > 128)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tconst fields = {\n\t\t\t\tobservedMs: integer(value.observedMs),\n\t\t\t\treconciledExecutionIds: Object.freeze(value.reconciledExecutionIds.map(text)),\n\t\t\t};\n\t\t\tswitch (value.kind) {\n\t\t\t\tcase \"resumed\":\n\t\t\t\t\treturn { ...fields, kind: value.kind, command: parseRunResumeCommand(value.command) };\n\t\t\t\tcase \"writer_restarted\":\n\t\t\t\t\treturn { ...fields, kind: value.kind, command: parseRunWriterRestartCommand(value.command) };\n\t\t\t\tcase \"tasks_retried\":\n\t\t\t\t\tif (!Array.isArray(value.adopted) || value.adopted.length > 16) throw new VerifiedRunError(\"integrity\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t\tkind: value.kind,\n\t\t\t\t\t\tcommand: parseRunTaskRetryCommand(value.command),\n\t\t\t\t\t\tadopted: Object.freeze(value.adopted.map(checkpoint)),\n\t\t\t\t\t};\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t}\n\t\t}\n\t\tcase \"evaluated\":\n\t\t\tif (typeof value.verified !== \"boolean\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn { kind: value.kind, receiptDigest: digest(value.receiptDigest), verified: value.verified };\n\t\tcase \"failed\":\n\t\t\treturn { kind: value.kind, code: text(value.code) };\n\t\tdefault:\n\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"event-parser.js","sourceRoot":"","sources":["../../../src/core/verified-run/event-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,GAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,q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,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD;YACC,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;AAAA,CACD","sourcesContent":["import {\n\tparseRunContract,\n\tparseRunResumeCommand,\n\tparseRunStartCommand,\n\tparseRunTaskRetryCommand,\n\tparseRunWriterRestartCommand,\n} from \"omk-protocol\";\nimport type { RunTaskCheckpoint } from \"./dag-types.ts\";\nimport { parseNamespaceIdentity } from \"./namespace-identity.ts\";\nimport { parseRecoveryBudget } from \"./recovery-clock.ts\";\nimport type { RunEvent } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nfunction text(value: unknown): string {\n\tif (typeof value !== \"string\" || !/^[A-Za-z0-9_-]{1,128}$/.test(value)) throw new VerifiedRunError(\"integrity\");\n\treturn value;\n}\nfunction digest(value: unknown): string {\n\tconst result = text(value);\n\tif (!/^[a-f0-9]{64}$/.test(result)) throw new VerifiedRunError(\"integrity\");\n\treturn result;\n}\nfunction integer(value: unknown): number {\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0) throw new VerifiedRunError(\"integrity\");\n\treturn value;\n}\nfunction oid(value: unknown, zeroAllowed: boolean): string {\n\tif (typeof value !== \"string\" || !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(value))\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tif (!zeroAllowed && /^0+$/.test(value)) throw new VerifiedRunError(\"integrity\");\n\treturn value;\n}\n\nfunction checkpoint(raw: unknown): RunTaskCheckpoint {\n\tif (typeof raw !== \"object\" || raw === null) throw new VerifiedRunError(\"integrity\");\n\tconst value: Record<string, unknown> = Object.fromEntries(Object.entries(raw));\n\tif (value.status !== \"succeeded\" || value.failure !== null) throw new VerifiedRunError(\"integrity\");\n\treturn Object.freeze({\n\t\ttaskId: text(value.taskId),\n\t\tattempt: integer(value.attempt),\n\t\tgeneration: integer(value.generation),\n\t\tstatus: \"succeeded\",\n\t\tinputDigest: digest(value.inputDigest),\n\t\toutputDigest: digest(value.outputDigest),\n\t\tfailure: null,\n\t});\n}\n\nexport function parseRunEvent(raw: unknown): RunEvent {\n\tif (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) throw new VerifiedRunError(\"integrity\");\n\tconst value: Record<string, unknown> = Object.fromEntries(Object.entries(raw));\n\tswitch (value.kind) {\n\t\tcase \"created\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tcontract: parseRunContract(value.contract),\n\t\t\t\tcommand: parseRunStartCommand(value.command),\n\t\t\t};\n\t\tcase \"budget_anchored\":\n\t\t\tif (value.driver !== \"linux-pidns-gate-v1\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tbudget: parseRecoveryBudget(value.budget),\n\t\t\t\tenvironmentDigest: digest(value.environmentDigest),\n\t\t\t\tdriver: value.driver,\n\t\t\t};\n\t\tcase \"dispatch\": {\n\t\t\tif (value.role !== \"writer\" && value.role !== \"verifier\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\texecutionId: text(value.executionId),\n\t\t\t\trole: value.role,\n\t\t\t\tclaimId: value.claimId === null ? null : text(value.claimId),\n\t\t\t\t...(value.taskId === undefined ? {} : { taskId: text(value.taskId) }),\n\t\t\t};\n\t\t}\n\t\tcase \"input_checkpoint\":\n\t\t\treturn { kind: value.kind, digest: digest(value.digest) };\n\t\tcase \"process_ready\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\texecutionId: text(value.executionId),\n\t\t\t\tidentity: parseNamespaceIdentity(value.identity),\n\t\t\t};\n\t\tcase \"task_started\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\ttaskId: text(value.taskId),\n\t\t\t\tattempt: integer(value.attempt),\n\t\t\t\tinputDigest: digest(value.inputDigest),\n\t\t\t\tobservedMs: integer(value.observedMs),\n\t\t\t};\n\t\tcase \"task_finished\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\ttaskId: text(value.taskId),\n\t\t\t\tattempt: integer(value.attempt),\n\t\t\t\toutputDigest: value.outputDigest === null ? null : digest(value.outputDigest),\n\t\t\t\tfailure: value.failure === null ? null : text(value.failure),\n\t\t\t\tobservedMs: integer(value.observedMs),\n\t\t\t};\n\t\tcase \"tasks_paused\":\n\t\tcase \"writer_opened\":\n\t\t\treturn { kind: value.kind };\n\t\tcase \"model_request\":\n\t\t\treturn { kind: value.kind, requestId: text(value.requestId) };\n\t\tcase \"writer_closed\":\n\t\t\tif (typeof value.completed !== \"boolean\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn { kind: value.kind, completed: value.completed };\n\t\tcase \"exited\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\texecutionId: text(value.executionId),\n\t\t\t\tfailure: value.failure === null ? null : text(value.failure),\n\t\t\t};\n\t\tcase \"candidate\":\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tdigest: digest(value.digest),\n\t\t\t\t...(value.observedMs === undefined ? {} : { observedMs: integer(value.observedMs) }),\n\t\t\t\t...(value.verificationDeadlineMs === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { verificationDeadlineMs: integer(value.verificationDeadlineMs) }),\n\t\t\t};\n\t\tcase \"resumed\":\n\t\tcase \"tasks_retried\":\n\t\tcase \"writer_restarted\": {\n\t\t\tif (!Array.isArray(value.reconciledExecutionIds) || value.reconciledExecutionIds.length > 128)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tconst fields = {\n\t\t\t\tobservedMs: integer(value.observedMs),\n\t\t\t\treconciledExecutionIds: Object.freeze(value.reconciledExecutionIds.map(text)),\n\t\t\t};\n\t\t\tswitch (value.kind) {\n\t\t\t\tcase \"resumed\":\n\t\t\t\t\treturn { ...fields, kind: value.kind, command: parseRunResumeCommand(value.command) };\n\t\t\t\tcase \"writer_restarted\":\n\t\t\t\t\treturn { ...fields, kind: value.kind, command: parseRunWriterRestartCommand(value.command) };\n\t\t\t\tcase \"tasks_retried\":\n\t\t\t\t\tif (!Array.isArray(value.adopted) || value.adopted.length > 16) throw new VerifiedRunError(\"integrity\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t\tkind: value.kind,\n\t\t\t\t\t\tcommand: parseRunTaskRetryCommand(value.command),\n\t\t\t\t\t\tadopted: Object.freeze(value.adopted.map(checkpoint)),\n\t\t\t\t\t};\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\t}\n\t\t}\n\t\tcase \"evaluated\":\n\t\t\tif (typeof value.verified !== \"boolean\") throw new VerifiedRunError(\"integrity\");\n\t\t\treturn { kind: value.kind, receiptDigest: digest(value.receiptDigest), verified: value.verified };\n\t\tcase \"publish_intent\": {\n\t\t\tconst candidateOid = oid(value.candidateOid, false);\n\t\t\tconst parentOid = oid(value.parentOid, true);\n\t\t\tif (value.targetRef !== \"refs/omk/accepted\" || parentOid.length !== candidateOid.length)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\treturn {\n\t\t\t\tkind: value.kind,\n\t\t\t\tcommandId: text(value.commandId),\n\t\t\t\tcandidateDigest: digest(value.candidateDigest),\n\t\t\t\tcandidateOid,\n\t\t\t\tparentOid,\n\t\t\t\ttargetRef: value.targetRef,\n\t\t\t\treceiptDigest: digest(value.receiptDigest),\n\t\t\t\tpolicyDigest: digest(value.policyDigest),\n\t\t\t\tgeneration: integer(value.generation),\n\t\t\t};\n\t\t}\n\t\tcase \"published\": {\n\t\t\tconst candidateOid = oid(value.candidateOid, false);\n\t\t\tconst previousOid = oid(value.previousOid, true);\n\t\t\tif (previousOid.length !== candidateOid.length) throw new VerifiedRunError(\"integrity\");\n\t\t\treturn { kind: value.kind, commandId: text(value.commandId), candidateOid, previousOid };\n\t\t}\n\t\tcase \"publish_failed\":\n\t\t\treturn { kind: value.kind, commandId: text(value.commandId), code: text(value.code) };\n\t\tcase \"failed\":\n\t\t\treturn { kind: value.kind, code: text(value.code) };\n\t\tdefault:\n\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t}\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type EvidenceRead } from "./evidence.ts";
|
|
2
|
+
/** Read-only projection. A missing current sandbox cannot invalidate a historical attestation. */
|
|
3
|
+
export declare function readEvidenceProjection(runPath: string): EvidenceRead;
|
|
4
|
+
//# sourceMappingURL=evidence-read-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence-read-projection.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/evidence-read-projection.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAIxE,kGAAkG;AAClG,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAmBpE","sourcesContent":["import { commandEnvironmentDigest } from \"./broker.ts\";\nimport { classifyEvidenceRead, type EvidenceRead } from \"./evidence.ts\";\nimport { requireRunJournal } from \"./recovery-command.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\n/** Read-only projection. A missing current sandbox cannot invalidate a historical attestation. */\nexport function readEvidenceProjection(runPath: string): EvidenceRead {\n\tconst journal = requireRunJournal(runPath);\n\tconst first = journal.records[0]?.event;\n\tif (first?.kind !== \"created\") throw new VerifiedRunError(\"missing_run\");\n\tlet current: string | { status: \"unsupported\" | \"unknown\" };\n\ttry {\n\t\tcurrent = commandEnvironmentDigest(first.contract, journal.state.budget ? \"gated-v1\" : \"legacy\");\n\t} catch (error) {\n\t\tif (error instanceof VerifiedRunError)\n\t\t\tcurrent = { status: error.code.startsWith(\"unsupported\") ? \"unsupported\" : \"unknown\" };\n\t\telse if (\n\t\t\terror instanceof Error &&\n\t\t\t\"code\" in error &&\n\t\t\t[\"ENOENT\", \"ENOTDIR\", \"EACCES\", \"EIO\"].includes(String(error.code))\n\t\t)\n\t\t\tcurrent = { status: error.code === \"ENOENT\" || error.code === \"ENOTDIR\" ? \"unsupported\" : \"unknown\" };\n\t\telse throw error;\n\t}\n\treturn classifyEvidenceRead(runPath, journal, current);\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { commandEnvironmentDigest } from "./broker.js";
|
|
2
|
+
import { classifyEvidenceRead } from "./evidence.js";
|
|
3
|
+
import { requireRunJournal } from "./recovery-command.js";
|
|
4
|
+
import { VerifiedRunError } from "./storage.js";
|
|
5
|
+
/** Read-only projection. A missing current sandbox cannot invalidate a historical attestation. */
|
|
6
|
+
export function readEvidenceProjection(runPath) {
|
|
7
|
+
const journal = requireRunJournal(runPath);
|
|
8
|
+
const first = journal.records[0]?.event;
|
|
9
|
+
if (first?.kind !== "created")
|
|
10
|
+
throw new VerifiedRunError("missing_run");
|
|
11
|
+
let current;
|
|
12
|
+
try {
|
|
13
|
+
current = commandEnvironmentDigest(first.contract, journal.state.budget ? "gated-v1" : "legacy");
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error instanceof VerifiedRunError)
|
|
17
|
+
current = { status: error.code.startsWith("unsupported") ? "unsupported" : "unknown" };
|
|
18
|
+
else if (error instanceof Error &&
|
|
19
|
+
"code" in error &&
|
|
20
|
+
["ENOENT", "ENOTDIR", "EACCES", "EIO"].includes(String(error.code)))
|
|
21
|
+
current = { status: error.code === "ENOENT" || error.code === "ENOTDIR" ? "unsupported" : "unknown" };
|
|
22
|
+
else
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
return classifyEvidenceRead(runPath, journal, current);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=evidence-read-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence-read-projection.js","sourceRoot":"","sources":["../../../src/core/verified-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C,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;;YAClG,MAAM,KAAK,CAAC;IAClB,CAAC;IACD,OAAO,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAAA,CACvD","sourcesContent":["import { commandEnvironmentDigest } from \"./broker.ts\";\nimport { classifyEvidenceRead, type EvidenceRead } from \"./evidence.ts\";\nimport { requireRunJournal } from \"./recovery-command.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\n/** Read-only projection. A missing current sandbox cannot invalidate a historical attestation. */\nexport function readEvidenceProjection(runPath: string): EvidenceRead {\n\tconst journal = requireRunJournal(runPath);\n\tconst first = journal.records[0]?.event;\n\tif (first?.kind !== \"created\") throw new VerifiedRunError(\"missing_run\");\n\tlet current: string | { status: \"unsupported\" | \"unknown\" };\n\ttry {\n\t\tcurrent = commandEnvironmentDigest(first.contract, journal.state.budget ? \"gated-v1\" : \"legacy\");\n\t} catch (error) {\n\t\tif (error instanceof VerifiedRunError)\n\t\t\tcurrent = { status: error.code.startsWith(\"unsupported\") ? \"unsupported\" : \"unknown\" };\n\t\telse if (\n\t\t\terror instanceof Error &&\n\t\t\t\"code\" in error &&\n\t\t\t[\"ENOENT\", \"ENOTDIR\", \"EACCES\", \"EIO\"].includes(String(error.code))\n\t\t)\n\t\t\tcurrent = { status: error.code === \"ENOENT\" || error.code === \"ENOTDIR\" ? \"unsupported\" : \"unknown\" };\n\t\telse throw error;\n\t}\n\treturn classifyEvidenceRead(runPath, journal, current);\n}\n"]}
|
|
@@ -12,6 +12,7 @@ export interface VerifiedRunEvidence {
|
|
|
12
12
|
readonly checks: readonly CheckObservation[];
|
|
13
13
|
readonly receiptFormat: "v3" | "legacy";
|
|
14
14
|
readonly receipts: readonly EvidenceReceipt[];
|
|
15
|
+
readonly environmentDigest: string;
|
|
15
16
|
}
|
|
16
17
|
export declare function createRunIssuer(runPath: string): void;
|
|
17
18
|
export declare function issueRunEvidence(runPath: string, contract: RunContract, material: {
|
|
@@ -23,5 +24,15 @@ export declare function issueRunEvidence(runPath: string, contract: RunContract,
|
|
|
23
24
|
readonly digest: string;
|
|
24
25
|
readonly verified: boolean;
|
|
25
26
|
};
|
|
26
|
-
export
|
|
27
|
+
export interface EvidenceRead {
|
|
28
|
+
readonly authenticity: "valid" | "invalid" | "unverifiable";
|
|
29
|
+
readonly verification: "passed" | "failed" | "incomplete";
|
|
30
|
+
readonly currentEnvironmentEligibility: "matching" | "different" | "unsupported" | "unknown";
|
|
31
|
+
readonly evidence: VerifiedRunEvidence | null;
|
|
32
|
+
}
|
|
33
|
+
/** Historical authenticity is separate from whether this machine can rerun the receipt. */
|
|
34
|
+
export declare function classifyEvidenceRead(runPath: string, journal: JournalSnapshot, currentEnvironment?: string | {
|
|
35
|
+
readonly status: "unsupported" | "unknown";
|
|
36
|
+
}): EvidenceRead;
|
|
37
|
+
export declare function readRunEvidence(runPath: string, journal: JournalSnapshot, environment?: string): VerifiedRunEvidence;
|
|
27
38
|
//# sourceMappingURL=evidence.d.ts.map
|