open-multi-agent-kit 1.0.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -1
- package/README.md +2 -2
- package/dist/approval-api.d.ts +5 -0
- package/dist/approval-api.d.ts.map +1 -0
- package/dist/approval-api.js +5 -0
- package/dist/approval-api.js.map +1 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +1 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/session-picker.d.ts +2 -2
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/commands/verified-run-cli.d.ts.map +1 -1
- package/dist/commands/verified-run-cli.js +69 -22
- package/dist/commands/verified-run-cli.js.map +1 -1
- package/dist/commands/verified-run-signal.d.ts +3 -0
- package/dist/commands/verified-run-signal.d.ts.map +1 -0
- package/dist/commands/verified-run-signal.js +15 -0
- package/dist/commands/verified-run-signal.js.map +1 -0
- package/dist/coordination/awareness.d.ts +32 -0
- package/dist/coordination/awareness.d.ts.map +1 -0
- package/dist/coordination/awareness.js +55 -0
- package/dist/coordination/awareness.js.map +1 -0
- package/dist/coordination/broker.d.ts +79 -0
- package/dist/coordination/broker.d.ts.map +1 -0
- package/dist/coordination/broker.js +202 -0
- package/dist/coordination/broker.js.map +1 -0
- package/dist/coordination/index.d.ts +16 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +16 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/coordination/integration.d.ts +59 -0
- package/dist/coordination/integration.d.ts.map +1 -0
- package/dist/coordination/integration.js +126 -0
- package/dist/coordination/integration.js.map +1 -0
- package/dist/coordination/operation.d.ts +107 -0
- package/dist/coordination/operation.d.ts.map +1 -0
- package/dist/coordination/operation.js +231 -0
- package/dist/coordination/operation.js.map +1 -0
- package/dist/coordination/resource.d.ts +33 -0
- package/dist/coordination/resource.d.ts.map +1 -0
- package/dist/coordination/resource.js +95 -0
- package/dist/coordination/resource.js.map +1 -0
- package/dist/coordination/session.d.ts +74 -0
- package/dist/coordination/session.d.ts.map +1 -0
- package/dist/coordination/session.js +143 -0
- package/dist/coordination/session.js.map +1 -0
- package/dist/coordination/types.d.ts +68 -0
- package/dist/coordination/types.d.ts.map +1 -0
- package/dist/coordination/types.js +26 -0
- package/dist/coordination/types.js.map +1 -0
- package/dist/core/adaptorch-bridge.d.ts +1 -1
- package/dist/core/adaptorch-bridge.d.ts.map +1 -1
- package/dist/core/adaptorch-bridge.js +1 -1
- package/dist/core/adaptorch-bridge.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +16 -16
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +35 -15
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/canonical-json.d.ts +3 -0
- package/dist/core/canonical-json.d.ts.map +1 -0
- package/dist/core/canonical-json.js +20 -0
- package/dist/core/canonical-json.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +7 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +14 -29
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/control-state.d.ts +41 -0
- package/dist/core/compaction/control-state.d.ts.map +1 -0
- package/dist/core/compaction/control-state.js +85 -0
- package/dist/core/compaction/control-state.js.map +1 -0
- package/dist/core/compaction/fallback.d.ts +71 -0
- package/dist/core/compaction/fallback.d.ts.map +1 -0
- package/dist/core/compaction/fallback.js +118 -0
- package/dist/core/compaction/fallback.js.map +1 -0
- package/dist/core/compaction/index.d.ts +2 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +2 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/model-failover.d.ts +21 -0
- package/dist/core/compaction/model-failover.d.ts.map +1 -0
- package/dist/core/compaction/model-failover.js +46 -0
- package/dist/core/compaction/model-failover.js.map +1 -0
- package/dist/core/compaction/session-summary.d.ts +21 -0
- package/dist/core/compaction/session-summary.d.ts.map +1 -0
- package/dist/core/compaction/session-summary.js +27 -0
- package/dist/core/compaction/session-summary.js.map +1 -0
- package/dist/core/context-budget-headroom-candidates.d.ts +16 -1
- package/dist/core/context-budget-headroom-candidates.d.ts.map +1 -1
- package/dist/core/context-budget-headroom-candidates.js +31 -13
- package/dist/core/context-budget-headroom-candidates.js.map +1 -1
- package/dist/core/context-budget-headroom-types.d.ts +7 -1
- package/dist/core/context-budget-headroom-types.d.ts.map +1 -1
- package/dist/core/context-budget-headroom-types.js +0 -1
- package/dist/core/context-budget-headroom-types.js.map +1 -1
- package/dist/core/context-budget-headroom.d.ts +10 -0
- package/dist/core/context-budget-headroom.d.ts.map +1 -1
- package/dist/core/context-budget-headroom.js +11 -2
- package/dist/core/context-budget-headroom.js.map +1 -1
- package/dist/core/context-budget-v2-global-pass.d.ts +21 -0
- package/dist/core/context-budget-v2-global-pass.d.ts.map +1 -0
- package/dist/core/context-budget-v2-global-pass.js +203 -0
- package/dist/core/context-budget-v2-global-pass.js.map +1 -0
- package/dist/core/context-budget-v2-planned-items.d.ts +12 -0
- package/dist/core/context-budget-v2-planned-items.d.ts.map +1 -1
- package/dist/core/context-budget-v2-planned-items.js +21 -2
- package/dist/core/context-budget-v2-planned-items.js.map +1 -1
- package/dist/core/context-budget-v2-planner.d.ts.map +1 -1
- package/dist/core/context-budget-v2-planner.js +18 -19
- package/dist/core/context-budget-v2-planner.js.map +1 -1
- package/dist/core/context-budget-v2-scoring.d.ts +7 -1
- package/dist/core/context-budget-v2-scoring.d.ts.map +1 -1
- package/dist/core/context-budget-v2-scoring.js.map +1 -1
- package/dist/core/context-budget-v2-selection.d.ts +3 -0
- package/dist/core/context-budget-v2-selection.d.ts.map +1 -1
- package/dist/core/context-budget-v2-selection.js +6 -2
- package/dist/core/context-budget-v2-selection.js.map +1 -1
- package/dist/core/context-budget-v2-types.d.ts +6 -1
- package/dist/core/context-budget-v2-types.d.ts.map +1 -1
- package/dist/core/context-budget-v2-types.js +6 -1
- package/dist/core/context-budget-v2-types.js.map +1 -1
- package/dist/core/export-html/template.js +14 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/session-lifecycle-types.d.ts +14 -0
- package/dist/core/extensions/session-lifecycle-types.d.ts.map +1 -0
- package/dist/core/extensions/session-lifecycle-types.js +2 -0
- package/dist/core/extensions/session-lifecycle-types.js.map +1 -0
- package/dist/core/extensions/types.d.ts +4 -9
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +10 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +3 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/legacy-resource-policy.d.ts +7 -0
- package/dist/core/legacy-resource-policy.d.ts.map +1 -0
- package/dist/core/legacy-resource-policy.js +9 -0
- package/dist/core/legacy-resource-policy.js.map +1 -0
- package/dist/core/mcp/config.d.ts.map +1 -1
- package/dist/core/mcp/config.js +17 -3
- package/dist/core/mcp/config.js.map +1 -1
- package/dist/core/mcp/connection-queue.d.ts +12 -0
- package/dist/core/mcp/connection-queue.d.ts.map +1 -0
- package/dist/core/mcp/connection-queue.js +46 -0
- package/dist/core/mcp/connection-queue.js.map +1 -0
- package/dist/core/mcp/manager-runtime.d.ts +55 -0
- package/dist/core/mcp/manager-runtime.d.ts.map +1 -0
- package/dist/core/mcp/manager-runtime.js +66 -0
- package/dist/core/mcp/manager-runtime.js.map +1 -0
- package/dist/core/mcp/manager.d.ts +12 -68
- package/dist/core/mcp/manager.d.ts.map +1 -1
- package/dist/core/mcp/manager.js +33 -113
- package/dist/core/mcp/manager.js.map +1 -1
- package/dist/core/mcp/protocol.d.ts.map +1 -1
- package/dist/core/mcp/protocol.js +70 -40
- package/dist/core/mcp/protocol.js.map +1 -1
- package/dist/core/package-manager.d.ts +4 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +59 -129
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/package-resource-patterns.d.ts +7 -0
- package/dist/core/package-resource-patterns.d.ts.map +1 -0
- package/dist/core/package-resource-patterns.js +99 -0
- package/dist/core/package-resource-patterns.js.map +1 -0
- package/dist/core/provider-default-models.d.ts +1 -0
- package/dist/core/provider-default-models.d.ts.map +1 -1
- package/dist/core/provider-default-models.js +1 -0
- package/dist/core/provider-default-models.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +1 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/provider-resilience.d.ts +9 -0
- package/dist/core/provider-resilience.d.ts.map +1 -1
- package/dist/core/provider-resilience.js +15 -0
- package/dist/core/provider-resilience.js.map +1 -1
- package/dist/core/reasoning-router-resolver.d.ts +7 -0
- package/dist/core/reasoning-router-resolver.d.ts.map +1 -1
- package/dist/core/reasoning-router-resolver.js +21 -3
- package/dist/core/reasoning-router-resolver.js.map +1 -1
- package/dist/core/reasoning-router-v4.d.ts +13 -7
- package/dist/core/reasoning-router-v4.d.ts.map +1 -1
- package/dist/core/reasoning-router-v4.js +8 -5
- package/dist/core/reasoning-router-v4.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +4 -8
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/run-execution-api.d.ts +8 -1
- package/dist/core/run-execution-api.d.ts.map +1 -1
- package/dist/core/run-execution-api.js +4 -0
- package/dist/core/run-execution-api.js.map +1 -1
- package/dist/core/run-journal.d.ts +1 -2
- package/dist/core/run-journal.d.ts.map +1 -1
- package/dist/core/run-journal.js +2 -19
- package/dist/core/run-journal.js.map +1 -1
- package/dist/core/session-compaction-service.d.ts +15 -0
- package/dist/core/session-compaction-service.d.ts.map +1 -1
- package/dist/core/session-compaction-service.js +17 -4
- package/dist/core/session-compaction-service.js.map +1 -1
- package/dist/core/session-listing.d.ts +51 -0
- package/dist/core/session-listing.d.ts.map +1 -0
- package/dist/core/session-listing.js +111 -0
- package/dist/core/session-listing.js.map +1 -0
- package/dist/core/session-manager.d.ts +12 -37
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +12 -118
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-message-text.d.ts +5 -0
- package/dist/core/session-message-text.d.ts.map +1 -0
- package/dist/core/session-message-text.js +9 -0
- package/dist/core/session-message-text.js.map +1 -0
- package/dist/core/skills-catalog-cache.d.ts +2 -0
- package/dist/core/skills-catalog-cache.d.ts.map +1 -1
- package/dist/core/skills-catalog-cache.js +71 -17
- package/dist/core/skills-catalog-cache.js.map +1 -1
- package/dist/core/todo-runtime-state.d.ts +12 -0
- package/dist/core/todo-runtime-state.d.ts.map +1 -1
- package/dist/core/todo-runtime-state.js +23 -0
- package/dist/core/todo-runtime-state.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/verified-run/authority-clock.d.ts +3 -0
- package/dist/core/verified-run/authority-clock.d.ts.map +1 -0
- package/dist/core/verified-run/authority-clock.js +25 -0
- package/dist/core/verified-run/authority-clock.js.map +1 -0
- package/dist/core/verified-run/authority-errors.d.ts +10 -0
- package/dist/core/verified-run/authority-errors.d.ts.map +1 -0
- package/dist/core/verified-run/authority-errors.js +17 -0
- package/dist/core/verified-run/authority-errors.js.map +1 -0
- package/dist/core/verified-run/authority-events.d.ts +126 -0
- package/dist/core/verified-run/authority-events.d.ts.map +1 -0
- package/dist/core/verified-run/authority-events.js +482 -0
- package/dist/core/verified-run/authority-events.js.map +1 -0
- package/dist/core/verified-run/authority-journal.d.ts +27 -0
- package/dist/core/verified-run/authority-journal.d.ts.map +1 -0
- package/dist/core/verified-run/authority-journal.js +83 -0
- package/dist/core/verified-run/authority-journal.js.map +1 -0
- package/dist/core/verified-run/authority-meaning.d.ts +13 -0
- package/dist/core/verified-run/authority-meaning.d.ts.map +1 -0
- package/dist/core/verified-run/authority-meaning.js +40 -0
- package/dist/core/verified-run/authority-meaning.js.map +1 -0
- package/dist/core/verified-run/authority-runtime.d.ts +82 -0
- package/dist/core/verified-run/authority-runtime.d.ts.map +1 -0
- package/dist/core/verified-run/authority-runtime.js +169 -0
- package/dist/core/verified-run/authority-runtime.js.map +1 -0
- package/dist/core/verified-run/authority-store.d.ts +204 -0
- package/dist/core/verified-run/authority-store.d.ts.map +1 -0
- package/dist/core/verified-run/authority-store.js +852 -0
- package/dist/core/verified-run/authority-store.js.map +1 -0
- package/dist/core/verified-run/broker.d.ts +8 -1
- package/dist/core/verified-run/broker.d.ts.map +1 -1
- package/dist/core/verified-run/broker.js +94 -90
- package/dist/core/verified-run/broker.js.map +1 -1
- package/dist/core/verified-run/candidate-policy.d.ts +10 -0
- package/dist/core/verified-run/candidate-policy.d.ts.map +1 -0
- package/dist/core/verified-run/candidate-policy.js +33 -0
- package/dist/core/verified-run/candidate-policy.js.map +1 -0
- package/dist/core/verified-run/candidate.d.ts.map +1 -1
- package/dist/core/verified-run/candidate.js +5 -10
- package/dist/core/verified-run/candidate.js.map +1 -1
- package/dist/core/verified-run/coordinator.d.ts +35 -17
- package/dist/core/verified-run/coordinator.d.ts.map +1 -1
- package/dist/core/verified-run/coordinator.js +111 -57
- package/dist/core/verified-run/coordinator.js.map +1 -1
- package/dist/core/verified-run/dag-phase.d.ts.map +1 -1
- package/dist/core/verified-run/dag-phase.js +1 -1
- package/dist/core/verified-run/dag-phase.js.map +1 -1
- package/dist/core/verified-run/dag-recovery.d.ts +5 -1
- package/dist/core/verified-run/dag-recovery.d.ts.map +1 -1
- package/dist/core/verified-run/dag-recovery.js +10 -4
- package/dist/core/verified-run/dag-recovery.js.map +1 -1
- package/dist/core/verified-run/event-parser.d.ts.map +1 -1
- package/dist/core/verified-run/event-parser.js +33 -0
- package/dist/core/verified-run/event-parser.js.map +1 -1
- package/dist/core/verified-run/evidence-read-projection.d.ts +4 -0
- package/dist/core/verified-run/evidence-read-projection.d.ts.map +1 -0
- package/dist/core/verified-run/evidence-read-projection.js +27 -0
- package/dist/core/verified-run/evidence-read-projection.js.map +1 -0
- package/dist/core/verified-run/evidence.d.ts +12 -1
- package/dist/core/verified-run/evidence.d.ts.map +1 -1
- package/dist/core/verified-run/evidence.js +51 -2
- package/dist/core/verified-run/evidence.js.map +1 -1
- package/dist/core/verified-run/git-candidate-preflight.d.ts +4 -0
- package/dist/core/verified-run/git-candidate-preflight.d.ts.map +1 -0
- package/dist/core/verified-run/git-candidate-preflight.js +34 -0
- package/dist/core/verified-run/git-candidate-preflight.js.map +1 -0
- package/dist/core/verified-run/git-effect-supervisor.d.ts +24 -0
- package/dist/core/verified-run/git-effect-supervisor.d.ts.map +1 -0
- package/dist/core/verified-run/git-effect-supervisor.js +174 -0
- package/dist/core/verified-run/git-effect-supervisor.js.map +1 -0
- package/dist/core/verified-run/git-execution.d.ts +27 -0
- package/dist/core/verified-run/git-execution.d.ts.map +1 -0
- package/dist/core/verified-run/git-execution.js +118 -0
- package/dist/core/verified-run/git-execution.js.map +1 -0
- package/dist/core/verified-run/git-plumbing.d.ts +37 -0
- package/dist/core/verified-run/git-plumbing.d.ts.map +1 -0
- package/dist/core/verified-run/git-plumbing.js +171 -0
- package/dist/core/verified-run/git-plumbing.js.map +1 -0
- package/dist/core/verified-run/git-publication-worker.d.ts +2 -0
- package/dist/core/verified-run/git-publication-worker.d.ts.map +1 -0
- package/dist/core/verified-run/git-publication-worker.js +54 -0
- package/dist/core/verified-run/git-publication-worker.js.map +1 -0
- package/dist/core/verified-run/git-sandbox-layout.d.ts +4 -0
- package/dist/core/verified-run/git-sandbox-layout.d.ts.map +1 -0
- package/dist/core/verified-run/git-sandbox-layout.js +29 -0
- package/dist/core/verified-run/git-sandbox-layout.js.map +1 -0
- package/dist/core/verified-run/git-worker-protocol.d.ts +19 -0
- package/dist/core/verified-run/git-worker-protocol.d.ts.map +1 -0
- package/dist/core/verified-run/git-worker-protocol.js +109 -0
- package/dist/core/verified-run/git-worker-protocol.js.map +1 -0
- package/dist/core/verified-run/git-worker-runtime.d.ts +19 -0
- package/dist/core/verified-run/git-worker-runtime.d.ts.map +1 -0
- package/dist/core/verified-run/git-worker-runtime.js +74 -0
- package/dist/core/verified-run/git-worker-runtime.js.map +1 -0
- package/dist/core/verified-run/journal.d.ts +2 -3
- package/dist/core/verified-run/journal.d.ts.map +1 -1
- package/dist/core/verified-run/journal.js.map +1 -1
- package/dist/core/verified-run/namespace-identity.d.ts.map +1 -1
- package/dist/core/verified-run/namespace-identity.js +1 -1
- package/dist/core/verified-run/namespace-identity.js.map +1 -1
- package/dist/core/verified-run/owned-execution.d.ts +10 -1
- package/dist/core/verified-run/owned-execution.d.ts.map +1 -1
- package/dist/core/verified-run/owned-execution.js +124 -31
- package/dist/core/verified-run/owned-execution.js.map +1 -1
- package/dist/core/verified-run/phase-context.d.ts +2 -0
- package/dist/core/verified-run/phase-context.d.ts.map +1 -1
- package/dist/core/verified-run/phase-context.js.map +1 -1
- package/dist/core/verified-run/projection.d.ts.map +1 -1
- package/dist/core/verified-run/projection.js +51 -1
- package/dist/core/verified-run/projection.js.map +1 -1
- package/dist/core/verified-run/publish-preflight.d.ts +12 -0
- package/dist/core/verified-run/publish-preflight.d.ts.map +1 -0
- package/dist/core/verified-run/publish-preflight.js +38 -0
- package/dist/core/verified-run/publish-preflight.js.map +1 -0
- package/dist/core/verified-run/publish-start.d.ts +5 -0
- package/dist/core/verified-run/publish-start.d.ts.map +1 -0
- package/dist/core/verified-run/publish-start.js +7 -0
- package/dist/core/verified-run/publish-start.js.map +1 -0
- package/dist/core/verified-run/recovery-projection.d.ts.map +1 -1
- package/dist/core/verified-run/recovery-projection.js +5 -0
- package/dist/core/verified-run/recovery-projection.js.map +1 -1
- package/dist/core/verified-run/recovery.d.ts +5 -1
- package/dist/core/verified-run/recovery.d.ts.map +1 -1
- package/dist/core/verified-run/recovery.js +10 -4
- package/dist/core/verified-run/recovery.js.map +1 -1
- package/dist/core/verified-run/run-plan.d.ts +17 -0
- package/dist/core/verified-run/run-plan.d.ts.map +1 -0
- package/dist/core/verified-run/run-plan.js +18 -0
- package/dist/core/verified-run/run-plan.js.map +1 -0
- package/dist/core/verified-run/run-publish-owned.d.ts +6 -0
- package/dist/core/verified-run/run-publish-owned.d.ts.map +1 -0
- package/dist/core/verified-run/run-publish-owned.js +199 -0
- package/dist/core/verified-run/run-publish-owned.js.map +1 -0
- package/dist/core/verified-run/run-publish.d.ts +19 -0
- package/dist/core/verified-run/run-publish.d.ts.map +1 -0
- package/dist/core/verified-run/run-publish.js +210 -0
- package/dist/core/verified-run/run-publish.js.map +1 -0
- package/dist/core/verified-run/run-status-owned.d.ts +4 -0
- package/dist/core/verified-run/run-status-owned.d.ts.map +1 -0
- package/dist/core/verified-run/run-status-owned.js +14 -0
- package/dist/core/verified-run/run-status-owned.js.map +1 -0
- package/dist/core/verified-run/run-status.d.ts +133 -0
- package/dist/core/verified-run/run-status.d.ts.map +1 -0
- package/dist/core/verified-run/run-status.js +193 -0
- package/dist/core/verified-run/run-status.js.map +1 -0
- package/dist/core/verified-run/run-types.d.ts +31 -0
- package/dist/core/verified-run/run-types.d.ts.map +1 -1
- package/dist/core/verified-run/run-types.js.map +1 -1
- package/dist/core/verified-run/storage.d.ts.map +1 -1
- package/dist/core/verified-run/storage.js +1 -1
- package/dist/core/verified-run/storage.js.map +1 -1
- package/dist/core/verified-run/supervisor-adapter.d.ts +77 -0
- package/dist/core/verified-run/supervisor-adapter.d.ts.map +1 -0
- package/dist/core/verified-run/supervisor-adapter.js +164 -0
- package/dist/core/verified-run/supervisor-adapter.js.map +1 -0
- package/dist/core/verified-run/verification-phase.d.ts.map +1 -1
- package/dist/core/verified-run/verification-phase.js +1 -1
- package/dist/core/verified-run/verification-phase.js.map +1 -1
- package/dist/core/verified-run/writer-phase.d.ts.map +1 -1
- package/dist/core/verified-run/writer-phase.js +1 -0
- package/dist/core/verified-run/writer-phase.js.map +1 -1
- package/dist/core/verified-run/writer-recovery.d.ts +2 -0
- package/dist/core/verified-run/writer-recovery.d.ts.map +1 -1
- package/dist/core/verified-run/writer-recovery.js +1 -0
- package/dist/core/verified-run/writer-recovery.js.map +1 -1
- package/dist/core/workload-shard-execution-types.d.ts +4 -1
- package/dist/core/workload-shard-execution-types.d.ts.map +1 -1
- package/dist/core/workload-shard-execution-types.js.map +1 -1
- package/dist/core/workload-shard-executor.d.ts +2 -2
- package/dist/core/workload-shard-executor.d.ts.map +1 -1
- package/dist/core/workload-shard-executor.js +16 -37
- package/dist/core/workload-shard-executor.js.map +1 -1
- package/dist/core/workload-shard-frontier.d.ts +5 -0
- package/dist/core/workload-shard-frontier.d.ts.map +1 -0
- package/dist/core/workload-shard-frontier.js +47 -0
- package/dist/core/workload-shard-frontier.js.map +1 -0
- package/dist/core/workload-shard-runner.d.ts.map +1 -1
- package/dist/core/workload-shard-runner.js +28 -17
- package/dist/core/workload-shard-runner.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -1
- package/dist/main.js.map +1 -1
- package/dist/metacognition/bridge-result.d.ts +148 -0
- package/dist/metacognition/bridge-result.d.ts.map +1 -0
- package/dist/metacognition/bridge-result.js +46 -0
- package/dist/metacognition/bridge-result.js.map +1 -0
- package/dist/metacognition/calibration-selective.d.ts +78 -0
- package/dist/metacognition/calibration-selective.d.ts.map +1 -0
- package/dist/metacognition/calibration-selective.js +167 -0
- package/dist/metacognition/calibration-selective.js.map +1 -0
- package/dist/metacognition/calibration.d.ts +62 -0
- package/dist/metacognition/calibration.d.ts.map +1 -0
- package/dist/metacognition/calibration.js +122 -0
- package/dist/metacognition/calibration.js.map +1 -0
- package/dist/metacognition/checkpoint.d.ts +60 -0
- package/dist/metacognition/checkpoint.d.ts.map +1 -0
- package/dist/metacognition/checkpoint.js +57 -0
- package/dist/metacognition/checkpoint.js.map +1 -0
- package/dist/metacognition/context7.d.ts +48 -0
- package/dist/metacognition/context7.d.ts.map +1 -0
- package/dist/metacognition/context7.js +154 -0
- package/dist/metacognition/context7.js.map +1 -0
- package/dist/metacognition/decision.d.ts +44 -0
- package/dist/metacognition/decision.d.ts.map +1 -0
- package/dist/metacognition/decision.js +111 -0
- package/dist/metacognition/decision.js.map +1 -0
- package/dist/metacognition/evaluation.d.ts +73 -0
- package/dist/metacognition/evaluation.d.ts.map +1 -0
- package/dist/metacognition/evaluation.js +97 -0
- package/dist/metacognition/evaluation.js.map +1 -0
- package/dist/metacognition/index.d.ts +32 -0
- package/dist/metacognition/index.d.ts.map +1 -0
- package/dist/metacognition/index.js +32 -0
- package/dist/metacognition/index.js.map +1 -0
- package/dist/metacognition/knowledge-action.d.ts +43 -0
- package/dist/metacognition/knowledge-action.d.ts.map +1 -0
- package/dist/metacognition/knowledge-action.js +60 -0
- package/dist/metacognition/knowledge-action.js.map +1 -0
- package/dist/metacognition/knowledge.d.ts +84 -0
- package/dist/metacognition/knowledge.d.ts.map +1 -0
- package/dist/metacognition/knowledge.js +165 -0
- package/dist/metacognition/knowledge.js.map +1 -0
- package/dist/metacognition/obligations.d.ts +82 -0
- package/dist/metacognition/obligations.d.ts.map +1 -0
- package/dist/metacognition/obligations.js +139 -0
- package/dist/metacognition/obligations.js.map +1 -0
- package/dist/metacognition/observation-validity.d.ts +83 -0
- package/dist/metacognition/observation-validity.d.ts.map +1 -0
- package/dist/metacognition/observation-validity.js +118 -0
- package/dist/metacognition/observation-validity.js.map +1 -0
- package/dist/metacognition/observe.d.ts +45 -0
- package/dist/metacognition/observe.d.ts.map +1 -0
- package/dist/metacognition/observe.js +59 -0
- package/dist/metacognition/observe.js.map +1 -0
- package/dist/metacognition/policy.d.ts +53 -0
- package/dist/metacognition/policy.d.ts.map +1 -0
- package/dist/metacognition/policy.js +155 -0
- package/dist/metacognition/policy.js.map +1 -0
- package/dist/metacognition/predictions.d.ts +78 -0
- package/dist/metacognition/predictions.d.ts.map +1 -0
- package/dist/metacognition/predictions.js +181 -0
- package/dist/metacognition/predictions.js.map +1 -0
- package/dist/metacognition/retrieval.d.ts +53 -0
- package/dist/metacognition/retrieval.d.ts.map +1 -0
- package/dist/metacognition/retrieval.js +170 -0
- package/dist/metacognition/retrieval.js.map +1 -0
- package/dist/metacognition/risk.d.ts +48 -0
- package/dist/metacognition/risk.d.ts.map +1 -0
- package/dist/metacognition/risk.js +179 -0
- package/dist/metacognition/risk.js.map +1 -0
- package/dist/metacognition/route-economics.d.ts +95 -0
- package/dist/metacognition/route-economics.d.ts.map +1 -0
- package/dist/metacognition/route-economics.js +110 -0
- package/dist/metacognition/route-economics.js.map +1 -0
- package/dist/metacognition/runtime-bridge.d.ts +81 -0
- package/dist/metacognition/runtime-bridge.d.ts.map +1 -0
- package/dist/metacognition/runtime-bridge.js +458 -0
- package/dist/metacognition/runtime-bridge.js.map +1 -0
- package/dist/metacognition/skills.d.ts +42 -0
- package/dist/metacognition/skills.d.ts.map +1 -0
- package/dist/metacognition/skills.js +220 -0
- package/dist/metacognition/skills.js.map +1 -0
- package/dist/metacognition/state.d.ts +110 -0
- package/dist/metacognition/state.d.ts.map +1 -0
- package/dist/metacognition/state.js +52 -0
- package/dist/metacognition/state.js.map +1 -0
- package/dist/metacognition/validation.d.ts +19 -0
- package/dist/metacognition/validation.d.ts.map +1 -0
- package/dist/metacognition/validation.js +58 -0
- package/dist/metacognition/validation.js.map +1 -0
- package/dist/metacognition/verification.d.ts +93 -0
- package/dist/metacognition/verification.d.ts.map +1 -0
- package/dist/metacognition/verification.js +132 -0
- package/dist/metacognition/verification.js.map +1 -0
- package/dist/metacognition/verifier.d.ts +49 -0
- package/dist/metacognition/verifier.d.ts.map +1 -0
- package/dist/metacognition/verifier.js +88 -0
- package/dist/metacognition/verifier.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +2 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +42 -26
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-container.d.ts +7 -0
- package/dist/modes/interactive/components/chat-container.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-container.js +14 -0
- package/dist/modes/interactive/components/chat-container.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +4 -2
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +0 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-async-search.d.ts +33 -0
- package/dist/modes/interactive/components/session-selector-async-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-async-search.js +109 -0
- package/dist/modes/interactive/components/session-selector-async-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-loaders.d.ts +6 -0
- package/dist/modes/interactive/components/session-selector-loaders.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-loaders.js +9 -0
- package/dist/modes/interactive/components/session-selector-loaders.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-tree.d.ts +16 -0
- package/dist/modes/interactive/components/session-selector-tree.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-tree.js +46 -0
- package/dist/modes/interactive/components/session-selector-tree.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +6 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +36 -76
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution-images.d.ts +32 -0
- package/dist/modes/interactive/components/tool-execution-images.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-images.js +144 -0
- package/dist/modes/interactive/components/tool-execution-images.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +3 -4
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +22 -71
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +7 -9
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tui-diagnostics.d.ts +8 -4
- package/dist/modes/interactive/tui-diagnostics.d.ts.map +1 -1
- package/dist/modes/interactive/tui-diagnostics.js +35 -1
- package/dist/modes/interactive/tui-diagnostics.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +14 -17
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-response.d.ts +5 -0
- package/dist/modes/rpc/rpc-response.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-response.js +17 -0
- package/dist/modes/rpc/rpc-response.js.map +1 -0
- package/dist/observation/identity.d.ts +14 -0
- package/dist/observation/identity.d.ts.map +1 -0
- package/dist/observation/identity.js +29 -0
- package/dist/observation/identity.js.map +1 -0
- package/dist/observation/index.d.ts +13 -0
- package/dist/observation/index.d.ts.map +1 -0
- package/dist/observation/index.js +13 -0
- package/dist/observation/index.js.map +1 -0
- package/dist/observation/observe-mode.d.ts +46 -0
- package/dist/observation/observe-mode.d.ts.map +1 -0
- package/dist/observation/observe-mode.js +83 -0
- package/dist/observation/observe-mode.js.map +1 -0
- package/dist/observation/store.d.ts +53 -0
- package/dist/observation/store.d.ts.map +1 -0
- package/dist/observation/store.js +126 -0
- package/dist/observation/store.js.map +1 -0
- package/dist/observation/types.d.ts +72 -0
- package/dist/observation/types.d.ts.map +1 -0
- package/dist/observation/types.js +9 -0
- package/dist/observation/types.js.map +1 -0
- package/dist/observation/view.d.ts +39 -0
- package/dist/observation/view.d.ts.map +1 -0
- package/dist/observation/view.js +173 -0
- package/dist/observation/view.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +3 -5
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/adaptorch-preview-spec.md +7 -7
- package/docs/atomic-commit-planning.md +69 -0
- package/docs/compaction.md +26 -1
- package/docs/extensions.md +14 -0
- package/docs/mcp.md +22 -0
- package/docs/metacognition.md +130 -0
- package/docs/model-catalog-refresh.md +218 -1
- package/docs/models.md +1 -1
- package/docs/providers.md +53 -0
- package/docs/runtime-algorithms.md +156 -7
- package/docs/session-format.md +8 -0
- package/docs/sessions.md +19 -0
- package/docs/skills.md +19 -0
- package/docs/terminal-setup.md +15 -0
- package/docs/tui.md +41 -0
- package/docs/verified-run-safety.md +75 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +18 -18
- package/package.json +6 -8
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { VerifiedRunError } from "./storage.js";
|
|
2
|
+
/** Whole-tree inclusion, with explicit metadata exclusions and sensitive-name rejection. */
|
|
3
|
+
export const CANDIDATE_POLICY = Object.freeze({
|
|
4
|
+
version: "whole-tree-sensitive-names-v1",
|
|
5
|
+
excludedRoots: Object.freeze([".git", ".omk"]),
|
|
6
|
+
deniedNames: Object.freeze([
|
|
7
|
+
".env",
|
|
8
|
+
".env.local",
|
|
9
|
+
".env.production",
|
|
10
|
+
".env.development",
|
|
11
|
+
".npmrc",
|
|
12
|
+
".netrc",
|
|
13
|
+
".pypirc",
|
|
14
|
+
"credentials.json",
|
|
15
|
+
"id_rsa",
|
|
16
|
+
"id_ed25519",
|
|
17
|
+
]),
|
|
18
|
+
deniedSuffixes: Object.freeze([".pem", ".key"]),
|
|
19
|
+
});
|
|
20
|
+
const denied = new Set(CANDIDATE_POLICY.deniedNames);
|
|
21
|
+
export function safeCandidatePath(path) {
|
|
22
|
+
if (!path ||
|
|
23
|
+
Buffer.from(path, "utf8").toString("utf8") !== path ||
|
|
24
|
+
/[\\\u0000-\u001f\u007f]/.test(path) ||
|
|
25
|
+
path.split("/").some((part) => ["", ".", "..", ".git", ".omk"].includes(part)))
|
|
26
|
+
throw new VerifiedRunError("file_type");
|
|
27
|
+
}
|
|
28
|
+
export function assertPublishablePath(path) {
|
|
29
|
+
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
30
|
+
if (denied.has(name) || CANDIDATE_POLICY.deniedSuffixes.some((suffix) => name.endsWith(suffix)))
|
|
31
|
+
throw new VerifiedRunError("secret_path");
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=candidate-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-policy.js","sourceRoot":"","sources":["../../../src/core/verified-run/candidate-policy.ts"],"names":[],"mappings":"AAAA,OA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C,IAAI,CAAC,IAAI,gBAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC9F,MAAM,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC;AAAA,CAC3C","sourcesContent":["import { VerifiedRunError } from \"./storage.ts\";\n\n/** Whole-tree inclusion, with explicit metadata exclusions and sensitive-name rejection. */\nexport const CANDIDATE_POLICY = Object.freeze({\n\tversion: \"whole-tree-sensitive-names-v1\",\n\texcludedRoots: Object.freeze([\".git\", \".omk\"]),\n\tdeniedNames: Object.freeze([\n\t\t\".env\",\n\t\t\".env.local\",\n\t\t\".env.production\",\n\t\t\".env.development\",\n\t\t\".npmrc\",\n\t\t\".netrc\",\n\t\t\".pypirc\",\n\t\t\"credentials.json\",\n\t\t\"id_rsa\",\n\t\t\"id_ed25519\",\n\t]),\n\tdeniedSuffixes: Object.freeze([\".pem\", \".key\"]),\n});\nconst denied = new Set(CANDIDATE_POLICY.deniedNames);\n\nexport function safeCandidatePath(path: string): void {\n\tif (\n\t\t!path ||\n\t\tBuffer.from(path, \"utf8\").toString(\"utf8\") !== path ||\n\t\t/[\\\\\\u0000-\\u001f\\u007f]/.test(path) ||\n\t\tpath.split(\"/\").some((part) => [\"\", \".\", \"..\", \".git\", \".omk\"].includes(part))\n\t)\n\t\tthrow new VerifiedRunError(\"file_type\");\n}\n\nexport function assertPublishablePath(path: string): void {\n\tconst name = path.slice(path.lastIndexOf(\"/\") + 1);\n\tif (denied.has(name) || CANDIDATE_POLICY.deniedSuffixes.some((suffix) => name.endsWith(suffix)))\n\t\tthrow new VerifiedRunError(\"secret_path\");\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/candidate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
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AE,cAAc,GAAG,iBAAiB,CAyExG","sourcesContent":["import { chmodSync, lstatSync, mkdirSync, readdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { RunPhaseBudget } from \"omk-protocol\";\nimport { assertPublishablePath, safeCandidatePath } from \"./candidate-policy.ts\";\nimport {\n\tassertDirectory,\n\tdigestBytes,\n\tdigestObject,\n\tpublishBytes,\n\tpublishObject,\n\treadJson,\n\treadRegularFile,\n\tVerifiedRunError,\n} from \"./storage.ts\";\n\nexport interface CandidateFile {\n\treadonly path: string;\n\treadonly mode: number;\n\treadonly digest: string;\n\treadonly size: number;\n}\nexport interface CandidateManifest {\n\treadonly version: 1;\n\treadonly directories: readonly string[];\n\treadonly files: readonly CandidateFile[];\n}\nexport interface CandidateSnapshot {\n\treadonly manifest: CandidateManifest;\n\treadonly digest: string;\n\treadonly contents: ReadonlyMap<string, Buffer>;\n}\n\n/** Entire regular-file tree, including dot/untracked files; .git/.omk metadata is excluded by this profile. */\nexport function captureCandidate(root: string, limits: RunPhaseBudget): CandidateSnapshot {\n\tassertDirectory(root);\n\tconst files: CandidateFile[] = [];\n\tconst directories: string[] = [];\n\tconst contents = new Map<string, Buffer>();\n\tlet bytesUsed = 0;\n\tconst visit = (prefix: string): void => {\n\t\tconst names = readdirSync(join(root, prefix), { encoding: \"buffer\" })\n\t\t\t.map((name) => new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: true }).decode(name))\n\t\t\t.sort();\n\t\tfor (const name of names) {\n\t\t\tif (!prefix && (name === \".git\" || name === \".omk\")) continue;\n\t\t\tconst path = prefix ? `${prefix}/${name}` : name;\n\t\t\tsafeCandidatePath(path);\n\t\t\tassertPublishablePath(path);\n\t\t\tif (files.length + directories.length >= limits.maxFiles) throw new VerifiedRunError(\"storage_limit\");\n\t\t\tconst absolute = join(root, path);\n\t\t\tconst stat = lstatSync(absolute);\n\t\t\tif (stat.isDirectory()) {\n\t\t\t\tif ((stat.mode & 0o7777) !== 0o755) throw new VerifiedRunError(\"file_type\");\n\t\t\t\tdirectories.push(path);\n\t\t\t\tvisit(path);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!stat.isFile() || stat.nlink !== 1 || (stat.mode & 0o7000) !== 0) throw new VerifiedRunError(\"file_type\");\n\t\t\tconst bytes = readRegularFile(absolute, limits.maxBytes - bytesUsed);\n\t\t\tbytesUsed += bytes.length;\n\t\t\tconst digest = digestBytes(bytes);\n\t\t\tcontents.set(digest, bytes);\n\t\t\tfiles.push(Object.freeze({ path, mode: stat.mode & 0o777, digest, size: bytes.length }));\n\t\t}\n\t};\n\tvisit(\"\");\n\tconst manifest: CandidateManifest = Object.freeze({\n\t\tversion: 1,\n\t\tdirectories: Object.freeze(directories),\n\t\tfiles: Object.freeze(files),\n\t});\n\treturn { manifest, digest: digestObject(manifest), contents };\n}\n\nexport function materializeCandidate(snapshot: CandidateSnapshot, target: string): void {\n\tmkdirSync(target, { mode: 0o700 });\n\tfor (const directory of snapshot.manifest.directories) mkdirSync(join(target, directory), { mode: 0o755 });\n\tfor (const file of snapshot.manifest.files) {\n\t\tconst bytes = snapshot.contents.get(file.digest);\n\t\tif (!bytes) throw new VerifiedRunError(\"integrity\");\n\t\tpublishBytes(join(target, file.path), bytes);\n\t\tchmodSync(join(target, file.path), file.mode);\n\t}\n}\n\nexport function assertCandidateScope(\n\tbase: CandidateManifest,\n\tcandidate: CandidateManifest,\n\twritable: readonly string[],\n): void {\n\tconst before = new Map(base.files.map((file) => [file.path, digestObject(file)]));\n\tconst after = new Map(candidate.files.map((file) => [file.path, digestObject(file)]));\n\tfor (const directory of base.directories) before.set(`${directory}/`, \"directory\");\n\tfor (const directory of candidate.directories) after.set(`${directory}/`, \"directory\");\n\tfor (const path of new Set([...before.keys(), ...after.keys()])) {\n\t\tif (before.get(path) === after.get(path)) continue;\n\t\tconst normalized = path.endsWith(\"/\") ? path.slice(0, -1) : path;\n\t\tif (!writable.some((scope) => normalized === scope || normalized.startsWith(`${scope}/`)))\n\t\t\tthrow new VerifiedRunError(\"scope_changed\");\n\t}\n}\n\nexport function storeCandidate(snapshot: CandidateSnapshot, runPath: string): void {\n\tfor (const [digest, bytes] of snapshot.contents) publishBytes(join(runPath, \"blobs\", digest), bytes);\n\tpublishObject(join(runPath, \"candidates\", `${snapshot.digest}.json`), snapshot.manifest);\n}\n\nexport function loadCandidate(runPath: string, digest: string, limits: RunPhaseBudget): CandidateSnapshot {\n\tif (!/^[a-f0-9]{64}$/.test(digest)) throw new VerifiedRunError(\"integrity\");\n\tconst raw = readJson(join(runPath, \"candidates\", `${digest}.json`), 4194304);\n\tif (\n\t\tdigestObject(raw) !== digest ||\n\t\ttypeof raw !== \"object\" ||\n\t\traw === null ||\n\t\t!(\"version\" in raw) ||\n\t\traw.version !== 1 ||\n\t\t!(\"files\" in raw) ||\n\t\t!Array.isArray(raw.files) ||\n\t\t!(\"directories\" in raw) ||\n\t\t!Array.isArray(raw.directories)\n\t) {\n\t\tthrow new VerifiedRunError(\"integrity\");\n\t}\n\tif (raw.files.length + raw.directories.length > limits.maxFiles) throw new VerifiedRunError(\"integrity\");\n\tconst files: CandidateFile[] = [];\n\tconst directories: string[] = [];\n\tconst paths = new Set<string>();\n\tlet total = 0;\n\tfor (const directory of raw.directories) {\n\t\tif (typeof directory !== \"string\") throw new VerifiedRunError(\"integrity\");\n\t\tsafeCandidatePath(directory);\n\t\tif (paths.has(directory)) throw new VerifiedRunError(\"integrity\");\n\t\tpaths.add(directory);\n\t\tdirectories.push(directory);\n\t}\n\tconst contents = new Map<string, Buffer>();\n\tconst rawFiles: readonly unknown[] = raw.files;\n\tfor (const file of rawFiles) {\n\t\tif (\n\t\t\ttypeof file !== \"object\" ||\n\t\t\tfile === null ||\n\t\t\t!(\"path\" in file) ||\n\t\t\ttypeof file.path !== \"string\" ||\n\t\t\t!(\"digest\" in file) ||\n\t\t\ttypeof file.digest !== \"string\" ||\n\t\t\t!/^[a-f0-9]{64}$/.test(file.digest) ||\n\t\t\t!(\"mode\" in file) ||\n\t\t\ttypeof file.mode !== \"number\" ||\n\t\t\t!Number.isSafeInteger(file.mode) ||\n\t\t\tfile.mode < 0 ||\n\t\t\tfile.mode > 0o777 ||\n\t\t\t!(\"size\" in file) ||\n\t\t\ttypeof file.size !== \"number\" ||\n\t\t\t!Number.isSafeInteger(file.size) ||\n\t\t\tfile.size < 0\n\t\t)\n\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\tsafeCandidatePath(file.path);\n\t\tif (paths.has(file.path)) throw new VerifiedRunError(\"integrity\");\n\t\tpaths.add(file.path);\n\t\ttotal += file.size;\n\t\tif (total > limits.maxBytes) throw new VerifiedRunError(\"integrity\");\n\t\tlet bytes: Buffer;\n\t\ttry {\n\t\t\tbytes = readRegularFile(join(runPath, \"blobs\", file.digest), file.size);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) throw new VerifiedRunError(\"integrity\");\n\t\t\tthrow error;\n\t\t}\n\t\tif (bytes.length !== file.size || digestBytes(bytes) !== file.digest) throw new VerifiedRunError(\"integrity\");\n\t\tcontents.set(file.digest, bytes);\n\t\tfiles.push(Object.freeze({ path: file.path, mode: file.mode, digest: file.digest, size: file.size }));\n\t}\n\tconst manifest: CandidateManifest = Object.freeze({\n\t\tversion: 1,\n\t\tdirectories: Object.freeze(directories),\n\t\tfiles: Object.freeze(files),\n\t});\n\tif (digestObject(manifest) !== digest) throw new VerifiedRunError(\"integrity\");\n\treturn { manifest, digest, contents };\n}\n"]}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { chmodSync, lstatSync, mkdirSync, readdirSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { assertPublishablePath, safeCandidatePath } from "./candidate-policy.js";
|
|
3
4
|
import { assertDirectory, digestBytes, digestObject, publishBytes, publishObject, readJson, readRegularFile, VerifiedRunError, } from "./storage.js";
|
|
4
|
-
function safePath(path) {
|
|
5
|
-
if (!path ||
|
|
6
|
-
/[\\\u0000-\u001f\u007f]/.test(path) ||
|
|
7
|
-
path.split("/").some((part) => ["", ".", "..", ".git", ".omk"].includes(part))) {
|
|
8
|
-
throw new VerifiedRunError("file_type");
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
5
|
/** Entire regular-file tree, including dot/untracked files; .git/.omk metadata is excluded by this profile. */
|
|
12
6
|
export function captureCandidate(root, limits) {
|
|
13
7
|
assertDirectory(root);
|
|
@@ -23,7 +17,8 @@ export function captureCandidate(root, limits) {
|
|
|
23
17
|
if (!prefix && (name === ".git" || name === ".omk"))
|
|
24
18
|
continue;
|
|
25
19
|
const path = prefix ? `${prefix}/${name}` : name;
|
|
26
|
-
|
|
20
|
+
safeCandidatePath(path);
|
|
21
|
+
assertPublishablePath(path);
|
|
27
22
|
if (files.length + directories.length >= limits.maxFiles)
|
|
28
23
|
throw new VerifiedRunError("storage_limit");
|
|
29
24
|
const absolute = join(root, path);
|
|
@@ -108,7 +103,7 @@ export function loadCandidate(runPath, digest, limits) {
|
|
|
108
103
|
for (const directory of raw.directories) {
|
|
109
104
|
if (typeof directory !== "string")
|
|
110
105
|
throw new VerifiedRunError("integrity");
|
|
111
|
-
|
|
106
|
+
safeCandidatePath(directory);
|
|
112
107
|
if (paths.has(directory))
|
|
113
108
|
throw new VerifiedRunError("integrity");
|
|
114
109
|
paths.add(directory);
|
|
@@ -134,7 +129,7 @@ export function loadCandidate(runPath, digest, limits) {
|
|
|
134
129
|
!Number.isSafeInteger(file.size) ||
|
|
135
130
|
file.size < 0)
|
|
136
131
|
throw new VerifiedRunError("integrity");
|
|
137
|
-
|
|
132
|
+
safeCandidatePath(file.path);
|
|
138
133
|
if (paths.has(file.path))
|
|
139
134
|
throw new VerifiedRunError("integrity");
|
|
140
135
|
paths.add(file.path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate.js","sourceRoot":"","sources":["../../../src/core/verified-run/candidate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,E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AK,CAAC,KAAK,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAC9G,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACvG,CAAC;IACD,MAAM,QAAQ,GAAsB,MAAM,CAAC,MAAM,CAAC;QACjD,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;QACvC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;KAC3B,CAAC,CAAC;IACH,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,MAAM;QAAE,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAAA,CACtC","sourcesContent":["import { chmodSync, lstatSync, mkdirSync, readdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { RunPhaseBudget } from \"omk-protocol\";\nimport {\n\tassertDirectory,\n\tdigestBytes,\n\tdigestObject,\n\tpublishBytes,\n\tpublishObject,\n\treadJson,\n\treadRegularFile,\n\tVerifiedRunError,\n} from \"./storage.ts\";\n\nexport interface CandidateFile {\n\treadonly path: string;\n\treadonly mode: number;\n\treadonly digest: string;\n\treadonly size: number;\n}\nexport interface CandidateManifest {\n\treadonly version: 1;\n\treadonly directories: readonly string[];\n\treadonly files: readonly CandidateFile[];\n}\nexport interface CandidateSnapshot {\n\treadonly manifest: CandidateManifest;\n\treadonly digest: string;\n\treadonly contents: ReadonlyMap<string, Buffer>;\n}\n\nfunction safePath(path: string): void {\n\tif (\n\t\t!path ||\n\t\t/[\\\\\\u0000-\\u001f\\u007f]/.test(path) ||\n\t\tpath.split(\"/\").some((part) => [\"\", \".\", \"..\", \".git\", \".omk\"].includes(part))\n\t) {\n\t\tthrow new VerifiedRunError(\"file_type\");\n\t}\n}\n\n/** Entire regular-file tree, including dot/untracked files; .git/.omk metadata is excluded by this profile. */\nexport function captureCandidate(root: string, limits: RunPhaseBudget): CandidateSnapshot {\n\tassertDirectory(root);\n\tconst files: CandidateFile[] = [];\n\tconst directories: string[] = [];\n\tconst contents = new Map<string, Buffer>();\n\tlet bytesUsed = 0;\n\tconst visit = (prefix: string): void => {\n\t\tconst names = readdirSync(join(root, prefix), { encoding: \"buffer\" })\n\t\t\t.map((name) => new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: true }).decode(name))\n\t\t\t.sort();\n\t\tfor (const name of names) {\n\t\t\tif (!prefix && (name === \".git\" || name === \".omk\")) continue;\n\t\t\tconst path = prefix ? `${prefix}/${name}` : name;\n\t\t\tsafePath(path);\n\t\t\tif (files.length + directories.length >= limits.maxFiles) throw new VerifiedRunError(\"storage_limit\");\n\t\t\tconst absolute = join(root, path);\n\t\t\tconst stat = lstatSync(absolute);\n\t\t\tif (stat.isDirectory()) {\n\t\t\t\tif ((stat.mode & 0o7777) !== 0o755) throw new VerifiedRunError(\"file_type\");\n\t\t\t\tdirectories.push(path);\n\t\t\t\tvisit(path);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!stat.isFile() || stat.nlink !== 1 || (stat.mode & 0o7000) !== 0) throw new VerifiedRunError(\"file_type\");\n\t\t\tconst bytes = readRegularFile(absolute, limits.maxBytes - bytesUsed);\n\t\t\tbytesUsed += bytes.length;\n\t\t\tconst digest = digestBytes(bytes);\n\t\t\tcontents.set(digest, bytes);\n\t\t\tfiles.push(Object.freeze({ path, mode: stat.mode & 0o777, digest, size: bytes.length }));\n\t\t}\n\t};\n\tvisit(\"\");\n\tconst manifest: CandidateManifest = Object.freeze({\n\t\tversion: 1,\n\t\tdirectories: Object.freeze(directories),\n\t\tfiles: Object.freeze(files),\n\t});\n\treturn { manifest, digest: digestObject(manifest), contents };\n}\n\nexport function materializeCandidate(snapshot: CandidateSnapshot, target: string): void {\n\tmkdirSync(target, { mode: 0o700 });\n\tfor (const directory of snapshot.manifest.directories) mkdirSync(join(target, directory), { mode: 0o755 });\n\tfor (const file of snapshot.manifest.files) {\n\t\tconst bytes = snapshot.contents.get(file.digest);\n\t\tif (!bytes) throw new VerifiedRunError(\"integrity\");\n\t\tpublishBytes(join(target, file.path), bytes);\n\t\tchmodSync(join(target, file.path), file.mode);\n\t}\n}\n\nexport function assertCandidateScope(\n\tbase: CandidateManifest,\n\tcandidate: CandidateManifest,\n\twritable: readonly string[],\n): void {\n\tconst before = new Map(base.files.map((file) => [file.path, digestObject(file)]));\n\tconst after = new Map(candidate.files.map((file) => [file.path, digestObject(file)]));\n\tfor (const directory of base.directories) before.set(`${directory}/`, \"directory\");\n\tfor (const directory of candidate.directories) after.set(`${directory}/`, \"directory\");\n\tfor (const path of new Set([...before.keys(), ...after.keys()])) {\n\t\tif (before.get(path) === after.get(path)) continue;\n\t\tconst normalized = path.endsWith(\"/\") ? path.slice(0, -1) : path;\n\t\tif (!writable.some((scope) => normalized === scope || normalized.startsWith(`${scope}/`)))\n\t\t\tthrow new VerifiedRunError(\"scope_changed\");\n\t}\n}\n\nexport function storeCandidate(snapshot: CandidateSnapshot, runPath: string): void {\n\tfor (const [digest, bytes] of snapshot.contents) publishBytes(join(runPath, \"blobs\", digest), bytes);\n\tpublishObject(join(runPath, \"candidates\", `${snapshot.digest}.json`), snapshot.manifest);\n}\n\nexport function loadCandidate(runPath: string, digest: string, limits: RunPhaseBudget): CandidateSnapshot {\n\tif (!/^[a-f0-9]{64}$/.test(digest)) throw new VerifiedRunError(\"integrity\");\n\tconst raw = readJson(join(runPath, \"candidates\", `${digest}.json`), 4194304);\n\tif (\n\t\tdigestObject(raw) !== digest ||\n\t\ttypeof raw !== \"object\" ||\n\t\traw === null ||\n\t\t!(\"version\" in raw) ||\n\t\traw.version !== 1 ||\n\t\t!(\"files\" in raw) ||\n\t\t!Array.isArray(raw.files) ||\n\t\t!(\"directories\" in raw) ||\n\t\t!Array.isArray(raw.directories)\n\t) {\n\t\tthrow new VerifiedRunError(\"integrity\");\n\t}\n\tif (raw.files.length + raw.directories.length > limits.maxFiles) throw new VerifiedRunError(\"integrity\");\n\tconst files: CandidateFile[] = [];\n\tconst directories: string[] = [];\n\tconst paths = new Set<string>();\n\tlet total = 0;\n\tfor (const directory of raw.directories) {\n\t\tif (typeof directory !== \"string\") throw new VerifiedRunError(\"integrity\");\n\t\tsafePath(directory);\n\t\tif (paths.has(directory)) throw new VerifiedRunError(\"integrity\");\n\t\tpaths.add(directory);\n\t\tdirectories.push(directory);\n\t}\n\tconst contents = new Map<string, Buffer>();\n\tconst rawFiles: readonly unknown[] = raw.files;\n\tfor (const file of rawFiles) {\n\t\tif (\n\t\t\ttypeof file !== \"object\" ||\n\t\t\tfile === null ||\n\t\t\t!(\"path\" in file) ||\n\t\t\ttypeof file.path !== \"string\" ||\n\t\t\t!(\"digest\" in file) ||\n\t\t\ttypeof file.digest !== \"string\" ||\n\t\t\t!/^[a-f0-9]{64}$/.test(file.digest) ||\n\t\t\t!(\"mode\" in file) ||\n\t\t\ttypeof file.mode !== \"number\" ||\n\t\t\t!Number.isSafeInteger(file.mode) ||\n\t\t\tfile.mode < 0 ||\n\t\t\tfile.mode > 0o777 ||\n\t\t\t!(\"size\" in file) ||\n\t\t\ttypeof file.size !== \"number\" ||\n\t\t\t!Number.isSafeInteger(file.size) ||\n\t\t\tfile.size < 0\n\t\t)\n\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\tsafePath(file.path);\n\t\tif (paths.has(file.path)) throw new VerifiedRunError(\"integrity\");\n\t\tpaths.add(file.path);\n\t\ttotal += file.size;\n\t\tif (total > limits.maxBytes) throw new VerifiedRunError(\"integrity\");\n\t\tlet bytes: Buffer;\n\t\ttry {\n\t\t\tbytes = readRegularFile(join(runPath, \"blobs\", file.digest), file.size);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) throw new VerifiedRunError(\"integrity\");\n\t\t\tthrow error;\n\t\t}\n\t\tif (bytes.length !== file.size || digestBytes(bytes) !== file.digest) throw new VerifiedRunError(\"integrity\");\n\t\tcontents.set(file.digest, bytes);\n\t\tfiles.push(Object.freeze({ path: file.path, mode: file.mode, digest: file.digest, size: file.size }));\n\t}\n\tconst manifest: CandidateManifest = Object.freeze({\n\t\tversion: 1,\n\t\tdirectories: Object.freeze(directories),\n\t\tfiles: Object.freeze(files),\n\t});\n\tif (digestObject(manifest) !== digest) throw new VerifiedRunError(\"integrity\");\n\treturn { manifest, digest, contents };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"candidate.js","sourceRoot":"","sources":["../../../src/core/verified-run/candidate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EACN,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,eAAe,EACf,gBAAgB,GAChB,MAAM,cAAc,CAAC;AAmBtB,+GAA+G;AAC/G,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,MAAsB,EAAqB;IACzF,eAAe,CAAC,IAAI,CAAC,CAAC;IACtB,MAAM,KAAK,GAAoB,EAAE,CAAC;IAClC,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,MAAM,KAAK,GAAG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RunPhaseBudget } from \"omk-protocol\";\nimport { assertPublishablePath, safeCandidatePath } from \"./candidate-policy.ts\";\nimport {\n\tassertDirectory,\n\tdigestBytes,\n\tdigestObject,\n\tpublishBytes,\n\tpublishObject,\n\treadJson,\n\treadRegularFile,\n\tVerifiedRunError,\n} from \"./storage.ts\";\n\nexport interface CandidateFile {\n\treadonly path: string;\n\treadonly mode: number;\n\treadonly digest: string;\n\treadonly size: number;\n}\nexport interface CandidateManifest {\n\treadonly version: 1;\n\treadonly directories: readonly string[];\n\treadonly files: readonly CandidateFile[];\n}\nexport interface CandidateSnapshot {\n\treadonly manifest: CandidateManifest;\n\treadonly digest: string;\n\treadonly contents: ReadonlyMap<string, Buffer>;\n}\n\n/** Entire regular-file tree, including dot/untracked files; .git/.omk metadata is excluded by this profile. */\nexport function captureCandidate(root: string, limits: RunPhaseBudget): CandidateSnapshot {\n\tassertDirectory(root);\n\tconst files: CandidateFile[] = [];\n\tconst directories: string[] = [];\n\tconst contents = new Map<string, Buffer>();\n\tlet bytesUsed = 0;\n\tconst visit = (prefix: string): void => {\n\t\tconst names = readdirSync(join(root, prefix), { encoding: \"buffer\" })\n\t\t\t.map((name) => new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: true }).decode(name))\n\t\t\t.sort();\n\t\tfor (const name of names) {\n\t\t\tif (!prefix && (name === \".git\" || name === \".omk\")) continue;\n\t\t\tconst path = prefix ? `${prefix}/${name}` : name;\n\t\t\tsafeCandidatePath(path);\n\t\t\tassertPublishablePath(path);\n\t\t\tif (files.length + directories.length >= limits.maxFiles) throw new VerifiedRunError(\"storage_limit\");\n\t\t\tconst absolute = join(root, path);\n\t\t\tconst stat = lstatSync(absolute);\n\t\t\tif (stat.isDirectory()) {\n\t\t\t\tif ((stat.mode & 0o7777) !== 0o755) throw new VerifiedRunError(\"file_type\");\n\t\t\t\tdirectories.push(path);\n\t\t\t\tvisit(path);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!stat.isFile() || stat.nlink !== 1 || (stat.mode & 0o7000) !== 0) throw new VerifiedRunError(\"file_type\");\n\t\t\tconst bytes = readRegularFile(absolute, limits.maxBytes - bytesUsed);\n\t\t\tbytesUsed += bytes.length;\n\t\t\tconst digest = digestBytes(bytes);\n\t\t\tcontents.set(digest, bytes);\n\t\t\tfiles.push(Object.freeze({ path, mode: stat.mode & 0o777, digest, size: bytes.length }));\n\t\t}\n\t};\n\tvisit(\"\");\n\tconst manifest: CandidateManifest = Object.freeze({\n\t\tversion: 1,\n\t\tdirectories: Object.freeze(directories),\n\t\tfiles: Object.freeze(files),\n\t});\n\treturn { manifest, digest: digestObject(manifest), contents };\n}\n\nexport function materializeCandidate(snapshot: CandidateSnapshot, target: string): void {\n\tmkdirSync(target, { mode: 0o700 });\n\tfor (const directory of snapshot.manifest.directories) mkdirSync(join(target, directory), { mode: 0o755 });\n\tfor (const file of snapshot.manifest.files) {\n\t\tconst bytes = snapshot.contents.get(file.digest);\n\t\tif (!bytes) throw new VerifiedRunError(\"integrity\");\n\t\tpublishBytes(join(target, file.path), bytes);\n\t\tchmodSync(join(target, file.path), file.mode);\n\t}\n}\n\nexport function assertCandidateScope(\n\tbase: CandidateManifest,\n\tcandidate: CandidateManifest,\n\twritable: readonly string[],\n): void {\n\tconst before = new Map(base.files.map((file) => [file.path, digestObject(file)]));\n\tconst after = new Map(candidate.files.map((file) => [file.path, digestObject(file)]));\n\tfor (const directory of base.directories) before.set(`${directory}/`, \"directory\");\n\tfor (const directory of candidate.directories) after.set(`${directory}/`, \"directory\");\n\tfor (const path of new Set([...before.keys(), ...after.keys()])) {\n\t\tif (before.get(path) === after.get(path)) continue;\n\t\tconst normalized = path.endsWith(\"/\") ? path.slice(0, -1) : path;\n\t\tif (!writable.some((scope) => normalized === scope || normalized.startsWith(`${scope}/`)))\n\t\t\tthrow new VerifiedRunError(\"scope_changed\");\n\t}\n}\n\nexport function storeCandidate(snapshot: CandidateSnapshot, runPath: string): void {\n\tfor (const [digest, bytes] of snapshot.contents) publishBytes(join(runPath, \"blobs\", digest), bytes);\n\tpublishObject(join(runPath, \"candidates\", `${snapshot.digest}.json`), snapshot.manifest);\n}\n\nexport function loadCandidate(runPath: string, digest: string, limits: RunPhaseBudget): CandidateSnapshot {\n\tif (!/^[a-f0-9]{64}$/.test(digest)) throw new VerifiedRunError(\"integrity\");\n\tconst raw = readJson(join(runPath, \"candidates\", `${digest}.json`), 4194304);\n\tif (\n\t\tdigestObject(raw) !== digest ||\n\t\ttypeof raw !== \"object\" ||\n\t\traw === null ||\n\t\t!(\"version\" in raw) ||\n\t\traw.version !== 1 ||\n\t\t!(\"files\" in raw) ||\n\t\t!Array.isArray(raw.files) ||\n\t\t!(\"directories\" in raw) ||\n\t\t!Array.isArray(raw.directories)\n\t) {\n\t\tthrow new VerifiedRunError(\"integrity\");\n\t}\n\tif (raw.files.length + raw.directories.length > limits.maxFiles) throw new VerifiedRunError(\"integrity\");\n\tconst files: CandidateFile[] = [];\n\tconst directories: string[] = [];\n\tconst paths = new Set<string>();\n\tlet total = 0;\n\tfor (const directory of raw.directories) {\n\t\tif (typeof directory !== \"string\") throw new VerifiedRunError(\"integrity\");\n\t\tsafeCandidatePath(directory);\n\t\tif (paths.has(directory)) throw new VerifiedRunError(\"integrity\");\n\t\tpaths.add(directory);\n\t\tdirectories.push(directory);\n\t}\n\tconst contents = new Map<string, Buffer>();\n\tconst rawFiles: readonly unknown[] = raw.files;\n\tfor (const file of rawFiles) {\n\t\tif (\n\t\t\ttypeof file !== \"object\" ||\n\t\t\tfile === null ||\n\t\t\t!(\"path\" in file) ||\n\t\t\ttypeof file.path !== \"string\" ||\n\t\t\t!(\"digest\" in file) ||\n\t\t\ttypeof file.digest !== \"string\" ||\n\t\t\t!/^[a-f0-9]{64}$/.test(file.digest) ||\n\t\t\t!(\"mode\" in file) ||\n\t\t\ttypeof file.mode !== \"number\" ||\n\t\t\t!Number.isSafeInteger(file.mode) ||\n\t\t\tfile.mode < 0 ||\n\t\t\tfile.mode > 0o777 ||\n\t\t\t!(\"size\" in file) ||\n\t\t\ttypeof file.size !== \"number\" ||\n\t\t\t!Number.isSafeInteger(file.size) ||\n\t\t\tfile.size < 0\n\t\t)\n\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\tsafeCandidatePath(file.path);\n\t\tif (paths.has(file.path)) throw new VerifiedRunError(\"integrity\");\n\t\tpaths.add(file.path);\n\t\ttotal += file.size;\n\t\tif (total > limits.maxBytes) throw new VerifiedRunError(\"integrity\");\n\t\tlet bytes: Buffer;\n\t\ttry {\n\t\t\tbytes = readRegularFile(join(runPath, \"blobs\", file.digest), file.size);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) throw new VerifiedRunError(\"integrity\");\n\t\t\tthrow error;\n\t\t}\n\t\tif (bytes.length !== file.size || digestBytes(bytes) !== file.digest) throw new VerifiedRunError(\"integrity\");\n\t\tcontents.set(file.digest, bytes);\n\t\tfiles.push(Object.freeze({ path: file.path, mode: file.mode, digest: file.digest, size: file.size }));\n\t}\n\tconst manifest: CandidateManifest = Object.freeze({\n\t\tversion: 1,\n\t\tdirectories: Object.freeze(directories),\n\t\tfiles: Object.freeze(files),\n\t});\n\tif (digestObject(manifest) !== digest) throw new VerifiedRunError(\"integrity\");\n\treturn { manifest, digest, contents };\n}\n"]}
|
|
@@ -1,37 +1,55 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type AuthorityStoreView } from "./authority-runtime.ts";
|
|
2
2
|
import { type TaskRecoveryInspection } from "./dag-recovery.ts";
|
|
3
|
-
import { type VerifiedRunEvidence } from "./evidence.ts";
|
|
3
|
+
import { type EvidenceRead, type VerifiedRunEvidence } from "./evidence.ts";
|
|
4
|
+
import { type RunJournalRecord } from "./journal.ts";
|
|
4
5
|
import { type RecoveryInspection } from "./recovery.ts";
|
|
6
|
+
import type { VerifiedRunApproval } from "./run-plan.ts";
|
|
7
|
+
import type { PublishOptions } from "./run-publish.ts";
|
|
8
|
+
import { type RunStatus } from "./run-status.ts";
|
|
5
9
|
import type { RunProjection } from "./run-types.ts";
|
|
6
10
|
import type { VerifiedRunRuntime } from "./session-port.ts";
|
|
7
11
|
import { type WriterRecoveryInspection } from "./writer-recovery.ts";
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
readonly approvedContractDigest: string;
|
|
11
|
-
readonly signal?: AbortSignal;
|
|
12
|
-
}
|
|
13
|
-
export interface VerifiedRunPlan {
|
|
14
|
-
readonly profile: RunContract["profile"];
|
|
15
|
-
readonly contractDigest: string;
|
|
16
|
-
readonly baseDigest: string;
|
|
17
|
-
readonly baseMatches: boolean;
|
|
18
|
-
readonly environmentDigest: string;
|
|
19
|
-
readonly checks: readonly string[];
|
|
20
|
-
readonly executionRequested: false;
|
|
21
|
-
}
|
|
22
|
-
export declare function planVerifiedRun(input: unknown): VerifiedRunPlan;
|
|
12
|
+
export type { AuthorityStoreView } from "./authority-runtime.ts";
|
|
13
|
+
export { planVerifiedRun, type VerifiedRunApproval, type VerifiedRunPlan } from "./run-plan.ts";
|
|
23
14
|
/** Owns the opt-in single-host run; session capabilities come only from trusted host composition. */
|
|
24
15
|
export declare class RunCoordinator {
|
|
25
16
|
private readonly stateRoot;
|
|
26
17
|
private readonly runtime;
|
|
18
|
+
/**
|
|
19
|
+
* One shared authority store while dispatch-capable work is in flight: the
|
|
20
|
+
* authority lease is fail-fast cross-process, so concurrent operations on
|
|
21
|
+
* this coordinator pool a single open store rather than open their own.
|
|
22
|
+
* The open is the restart boundary — epoch advance plus reconciliation
|
|
23
|
+
* complete before any new dispatch may be admitted.
|
|
24
|
+
*/
|
|
25
|
+
private readonly authorityPool;
|
|
27
26
|
constructor(stateRoot: string, runtime?: VerifiedRunRuntime);
|
|
27
|
+
/** Run `work` under the shared, reconciled authority store for this run's state root. */
|
|
28
|
+
private withAuthority;
|
|
28
29
|
inspect(runId: string): RunProjection;
|
|
30
|
+
/**
|
|
31
|
+
* Derived lifecycle/recovery status of a run — same journal truth as
|
|
32
|
+
* `inspect`, projected into the machine-readable `RunStatus` view
|
|
33
|
+
* (lifecycle token, completion ladder, unresolved concerns, recovery
|
|
34
|
+
* command hints). Never reports a recovered/quarantined run as clean.
|
|
35
|
+
*/
|
|
36
|
+
status(runId: string): RunStatus;
|
|
37
|
+
/** The run's hashed journal records — the event stream the projection replays. */
|
|
38
|
+
events(runId: string): readonly RunJournalRecord[];
|
|
39
|
+
/**
|
|
40
|
+
* The durable authority store under this state root: which grant holds
|
|
41
|
+
* which claims, why it is quarantined, and whether termination was
|
|
42
|
+
* witnessed. Read-only; a missing store reads as an empty projection.
|
|
43
|
+
*/
|
|
44
|
+
inspectAuthority(): AuthorityStoreView;
|
|
29
45
|
inspectRecovery(runId: string): RecoveryInspection;
|
|
30
46
|
inspectWriterRecovery(runId: string): WriterRecoveryInspection;
|
|
31
47
|
inspectTaskRecovery(runId: string): TaskRecoveryInspection;
|
|
32
48
|
retryTasks(input: unknown, approval: VerifiedRunApproval): Promise<RunProjection>;
|
|
33
49
|
evidence(runId: string): VerifiedRunEvidence;
|
|
50
|
+
evidenceRead(runId: string): EvidenceRead;
|
|
34
51
|
artifact(runId: string, candidateDigest: string, path: string): Buffer;
|
|
52
|
+
publish(input: unknown, approval: VerifiedRunApproval, options?: PublishOptions): Promise<RunProjection>;
|
|
35
53
|
resume(input: unknown, approval: VerifiedRunApproval): Promise<RunProjection>;
|
|
36
54
|
restartWriter(input: unknown, approval: VerifiedRunApproval): Promise<RunProjection>;
|
|
37
55
|
start(input: unknown, request: unknown, approval: VerifiedRunApproval): Promise<RunProjection>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/coordinator.ts"],"names":[],"mappings":"AAEA,OAAO,EAMN,KAAK,WAAW,EAChB,MAAM,cAAc,CAAC;AAMtB,OAAO,EAAsC,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAoC,KAAK,mBAAmB,EAAE,MAAM,eAAe,C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,CAKzD;IAEK,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAKtF;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAW3C;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CASrE;IAEK,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAKlF;IAEK,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAQzF;IAEK,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAkEnG;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.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/coordinator.ts"],"names":[],"mappings":"AAYA,OAAO,EACN,KAAK,kBAAkB,EAIvB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAsC,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAmB,KAAK,YAAY,EAAmB,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE9G,OAAO,EAAe,KAAK,gBAAgB,EAAsC,MAAM,cAAc,CAAC;AAEtG,OAAO,EAAsB,KAAK,kBAAkB,EAAyB,MAAM,eAAe,CAAC;AAEnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAY5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rE;IAEK,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAWjH;IAEK,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAUlF;IAEK,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAWzF;IAEK,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAqEnG;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,42 +1,48 @@
|
|
|
1
1
|
import { join, resolve } from "node:path";
|
|
2
2
|
import { performance } from "node:perf_hooks";
|
|
3
|
-
import { parseRunContract, parseRunResumeCommand, parseRunStartCommand, parseRunTaskRetryCommand, parseRunWriterRestartCommand, } from "omk-protocol";
|
|
3
|
+
import { parseRunContract, parseRunPublishCommand, parseRunResumeCommand, parseRunStartCommand, parseRunTaskRetryCommand, parseRunWriterRestartCommand, } from "omk-protocol";
|
|
4
4
|
import { ensureDurableDirectorySync } from "../durable-file-io.js";
|
|
5
5
|
import { acquireSessionOwnerLeaseSync } from "../session-owner-lease.js";
|
|
6
|
+
import { inspectRunAuthority, RunAuthorityPool, } from "./authority-runtime.js";
|
|
6
7
|
import { commandEnvironmentDigest, probeVerifiedSandbox } from "./broker.js";
|
|
7
8
|
import { captureCandidate, materializeCandidate, storeCandidate } from "./candidate.js";
|
|
8
9
|
import { preflightCheckReceipts } from "./check-receipt.js";
|
|
9
10
|
import { inspectTaskRecovery, retryDagTasks } from "./dag-recovery.js";
|
|
10
11
|
import { createRunIssuer, readRunEvidence } from "./evidence.js";
|
|
12
|
+
import { readEvidenceProjection } from "./evidence-read-projection.js";
|
|
11
13
|
import { journalPath, readRunJournal, VerifiedRunJournal } from "./journal.js";
|
|
12
14
|
import { inspectRunRecovery, resumeFrozenCandidate } from "./recovery.js";
|
|
13
15
|
import { anchorRunBudget, readRunClock } from "./recovery-clock.js";
|
|
16
|
+
import { publishVerifiedRunOwned } from "./run-publish-owned.js";
|
|
17
|
+
import { deriveRunStatus } from "./run-status.js";
|
|
18
|
+
import { withOwnedGitStatus } from "./run-status-owned.js";
|
|
14
19
|
import { assertStateOutsideWorkspace, digestBytes, digestObject, readRegularFile, stateRunPath, VerifiedRunError, } from "./storage.js";
|
|
15
20
|
import { verifyCandidate } from "./verification-phase.js";
|
|
16
21
|
import { publishWriterCandidate } from "./writer-completion.js";
|
|
17
22
|
import { executeWriter } from "./writer-phase.js";
|
|
18
23
|
import { inspectWriterRecovery, restartIsolatedWriter } from "./writer-recovery.js";
|
|
19
|
-
export
|
|
20
|
-
const contract = parseRunContract(input);
|
|
21
|
-
const snapshot = captureCandidate(contract.workspace.root, contract.budget);
|
|
22
|
-
return Object.freeze({
|
|
23
|
-
profile: contract.profile,
|
|
24
|
-
contractDigest: digestObject(contract),
|
|
25
|
-
baseDigest: snapshot.digest,
|
|
26
|
-
baseMatches: snapshot.digest === contract.workspace.baseDigest,
|
|
27
|
-
environmentDigest: commandEnvironmentDigest(contract, "gated-v1"),
|
|
28
|
-
checks: Object.freeze(contract.checks.map((check) => check.claimId)),
|
|
29
|
-
executionRequested: false,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
24
|
+
export { planVerifiedRun } from "./run-plan.js";
|
|
32
25
|
/** Owns the opt-in single-host run; session capabilities come only from trusted host composition. */
|
|
33
26
|
export class RunCoordinator {
|
|
34
27
|
stateRoot;
|
|
35
28
|
runtime;
|
|
29
|
+
/**
|
|
30
|
+
* One shared authority store while dispatch-capable work is in flight: the
|
|
31
|
+
* authority lease is fail-fast cross-process, so concurrent operations on
|
|
32
|
+
* this coordinator pool a single open store rather than open their own.
|
|
33
|
+
* The open is the restart boundary — epoch advance plus reconciliation
|
|
34
|
+
* complete before any new dispatch may be admitted.
|
|
35
|
+
*/
|
|
36
|
+
authorityPool = new RunAuthorityPool();
|
|
36
37
|
constructor(stateRoot, runtime) {
|
|
37
38
|
this.stateRoot = resolve(stateRoot);
|
|
38
39
|
this.runtime = runtime;
|
|
39
40
|
}
|
|
41
|
+
/** Run `work` under the shared, reconciled authority store for this run's state root. */
|
|
42
|
+
withAuthority(runId, work) {
|
|
43
|
+
const runPath = stateRunPath(this.stateRoot, runId);
|
|
44
|
+
return this.authorityPool.run(runPath, runId, (authority) => work(runPath, authority));
|
|
45
|
+
}
|
|
40
46
|
inspect(runId) {
|
|
41
47
|
const journal = readRunJournal(stateRunPath(this.stateRoot, runId));
|
|
42
48
|
if (!journal || journal.state.runId !== runId)
|
|
@@ -45,6 +51,32 @@ export class RunCoordinator {
|
|
|
45
51
|
this.evidence(runId);
|
|
46
52
|
return journal.state;
|
|
47
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Derived lifecycle/recovery status of a run — same journal truth as
|
|
56
|
+
* `inspect`, projected into the machine-readable `RunStatus` view
|
|
57
|
+
* (lifecycle token, completion ladder, unresolved concerns, recovery
|
|
58
|
+
* command hints). Never reports a recovered/quarantined run as clean.
|
|
59
|
+
*/
|
|
60
|
+
status(runId) {
|
|
61
|
+
return withOwnedGitStatus(deriveRunStatus(this.inspect(runId)), this.inspectAuthority().status);
|
|
62
|
+
}
|
|
63
|
+
/** The run's hashed journal records — the event stream the projection replays. */
|
|
64
|
+
events(runId) {
|
|
65
|
+
const journal = readRunJournal(stateRunPath(this.stateRoot, runId));
|
|
66
|
+
if (!journal || journal.state.runId !== runId)
|
|
67
|
+
throw new VerifiedRunError("missing_run");
|
|
68
|
+
if (journal.state.receiptDigest)
|
|
69
|
+
this.evidence(runId);
|
|
70
|
+
return journal.records;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The durable authority store under this state root: which grant holds
|
|
74
|
+
* which claims, why it is quarantined, and whether termination was
|
|
75
|
+
* witnessed. Read-only; a missing store reads as an empty projection.
|
|
76
|
+
*/
|
|
77
|
+
inspectAuthority() {
|
|
78
|
+
return inspectRunAuthority(this.stateRoot);
|
|
79
|
+
}
|
|
48
80
|
inspectRecovery(runId) {
|
|
49
81
|
const report = inspectRunRecovery(stateRunPath(this.stateRoot, runId));
|
|
50
82
|
if (report.state.runId !== runId)
|
|
@@ -73,7 +105,7 @@ export class RunCoordinator {
|
|
|
73
105
|
const command = parseRunTaskRetryCommand(input);
|
|
74
106
|
if (approval.approvedContractDigest !== command.contractDigest)
|
|
75
107
|
throw new VerifiedRunError("approval");
|
|
76
|
-
await
|
|
108
|
+
await this.withAuthority(command.runId, (runPath, authority) => retryDagTasks(runPath, command, { ...(approval.signal ? { signal: approval.signal } : {}), authority }));
|
|
77
109
|
return this.inspect(command.runId);
|
|
78
110
|
}
|
|
79
111
|
evidence(runId) {
|
|
@@ -82,7 +114,10 @@ export class RunCoordinator {
|
|
|
82
114
|
const first = journal?.records[0]?.event;
|
|
83
115
|
if (!journal || first?.kind !== "created" || first.contract.runId !== runId)
|
|
84
116
|
throw new VerifiedRunError("missing_run");
|
|
85
|
-
return readRunEvidence(runPath, journal
|
|
117
|
+
return readRunEvidence(runPath, journal);
|
|
118
|
+
}
|
|
119
|
+
evidenceRead(runId) {
|
|
120
|
+
return readEvidenceProjection(stateRunPath(this.stateRoot, runId));
|
|
86
121
|
}
|
|
87
122
|
artifact(runId, candidateDigest, path) {
|
|
88
123
|
const evidence = this.evidence(runId);
|
|
@@ -96,21 +131,37 @@ export class RunCoordinator {
|
|
|
96
131
|
throw new VerifiedRunError("integrity");
|
|
97
132
|
return bytes;
|
|
98
133
|
}
|
|
134
|
+
async publish(input, approval, options = {}) {
|
|
135
|
+
const command = parseRunPublishCommand(input);
|
|
136
|
+
if (approval.approvedContractDigest !== command.contractDigest)
|
|
137
|
+
throw new VerifiedRunError("approval");
|
|
138
|
+
if (approval.signal?.aborted)
|
|
139
|
+
throw new VerifiedRunError("cancelled");
|
|
140
|
+
return this.withAuthority(command.runId, (runPath, authority) => publishVerifiedRunOwned(runPath, command, {
|
|
141
|
+
...options,
|
|
142
|
+
authority,
|
|
143
|
+
...(approval.signal ? { signal: approval.signal } : {}),
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
99
146
|
async resume(input, approval) {
|
|
100
147
|
const command = parseRunResumeCommand(input);
|
|
101
148
|
if (approval.approvedContractDigest !== command.contractDigest)
|
|
102
149
|
throw new VerifiedRunError("approval");
|
|
103
|
-
await
|
|
150
|
+
await this.withAuthority(command.runId, (runPath, authority) => resumeFrozenCandidate(runPath, command, {
|
|
151
|
+
...(approval.signal ? { signal: approval.signal } : {}),
|
|
152
|
+
authority,
|
|
153
|
+
}));
|
|
104
154
|
return this.inspect(command.runId);
|
|
105
155
|
}
|
|
106
156
|
async restartWriter(input, approval) {
|
|
107
157
|
const command = parseRunWriterRestartCommand(input);
|
|
108
158
|
if (approval.approvedContractDigest !== command.contractDigest)
|
|
109
159
|
throw new VerifiedRunError("approval");
|
|
110
|
-
await
|
|
160
|
+
await this.withAuthority(command.runId, (runPath, authority) => restartIsolatedWriter(runPath, command, {
|
|
111
161
|
...(approval.signal ? { signal: approval.signal } : {}),
|
|
112
162
|
...(this.runtime ? { runtime: this.runtime } : {}),
|
|
113
|
-
|
|
163
|
+
authority,
|
|
164
|
+
}));
|
|
114
165
|
return this.inspect(command.runId);
|
|
115
166
|
}
|
|
116
167
|
async start(input, request, approval) {
|
|
@@ -143,48 +194,51 @@ export class RunCoordinator {
|
|
|
143
194
|
preflightCheckReceipts(contract);
|
|
144
195
|
probeVerifiedSandbox();
|
|
145
196
|
ensureDurableDirectorySync(runPath);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (readRunJournal(runPath))
|
|
149
|
-
throw new VerifiedRunError("command_conflict");
|
|
150
|
-
const journal = new VerifiedRunJournal(runPath, owner);
|
|
151
|
-
journal.append({ kind: "created", contract, command });
|
|
152
|
-
const budget = anchorRunBudget(contract.budget, clock);
|
|
153
|
-
journal.append({ kind: "budget_anchored", budget, environmentDigest, driver: "linux-pidns-gate-v1" });
|
|
154
|
-
const context = {
|
|
155
|
-
runPath,
|
|
156
|
-
contract,
|
|
157
|
-
journal,
|
|
158
|
-
...(approval.signal ? { signal: approval.signal } : {}),
|
|
159
|
-
};
|
|
197
|
+
return this.authorityPool.run(runPath, contract.runId, async (authority) => {
|
|
198
|
+
const owner = acquireSessionOwnerLeaseSync(journalPath(runPath));
|
|
160
199
|
try {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
journal
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
200
|
+
if (readRunJournal(runPath))
|
|
201
|
+
throw new VerifiedRunError("command_conflict");
|
|
202
|
+
const journal = new VerifiedRunJournal(runPath, owner);
|
|
203
|
+
journal.append({ kind: "created", contract, command });
|
|
204
|
+
const budget = anchorRunBudget(contract.budget, clock);
|
|
205
|
+
journal.append({ kind: "budget_anchored", budget, environmentDigest, driver: "linux-pidns-gate-v1" });
|
|
206
|
+
const context = {
|
|
207
|
+
runPath,
|
|
208
|
+
contract,
|
|
209
|
+
journal,
|
|
210
|
+
authority,
|
|
211
|
+
...(approval.signal ? { signal: approval.signal } : {}),
|
|
212
|
+
};
|
|
213
|
+
try {
|
|
214
|
+
createRunIssuer(runPath);
|
|
215
|
+
storeCandidate(base, runPath);
|
|
216
|
+
journal.append({ kind: "input_checkpoint", digest: base.digest });
|
|
217
|
+
const work = join(runPath, "writer");
|
|
218
|
+
if (contract.profile !== "linux-command-dag-v1")
|
|
219
|
+
materializeCandidate(base, work);
|
|
220
|
+
const workDeadline = began + contract.budget.workMs;
|
|
221
|
+
await executeWriter(context, {
|
|
222
|
+
workspace: work,
|
|
223
|
+
deadline: workDeadline,
|
|
224
|
+
...(this.runtime ? { runtime: this.runtime } : {}),
|
|
225
|
+
});
|
|
226
|
+
if (journal.state.execution === "paused")
|
|
227
|
+
return this.inspect(contract.runId);
|
|
228
|
+
publishWriterCandidate(context, work, workDeadline);
|
|
229
|
+
await verifyCandidate(context);
|
|
174
230
|
return this.inspect(contract.runId);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
if (error instanceof VerifiedRunError && !journal.state.receiptDigest)
|
|
234
|
+
return journal.append({ kind: "failed", code: error.code });
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
178
237
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
return journal.append({ kind: "failed", code: error.code });
|
|
182
|
-
throw error;
|
|
238
|
+
finally {
|
|
239
|
+
owner.release();
|
|
183
240
|
}
|
|
184
|
-
}
|
|
185
|
-
finally {
|
|
186
|
-
owner.release();
|
|
187
|
-
}
|
|
241
|
+
});
|
|
188
242
|
}
|
|
189
243
|
}
|
|
190
244
|
//# sourceMappingURL=coordinator.js.map
|