omk-protocol 0.98.4 → 0.98.5
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 +6 -0
- package/README.md +15 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/run-contract.d.ts +58 -0
- package/dist/run-contract.d.ts.map +1 -0
- package/dist/run-contract.js +112 -0
- package/dist/run-contract.js.map +1 -0
- package/dist/run-dag.d.ts +18 -0
- package/dist/run-dag.d.ts.map +1 -0
- package/dist/run-dag.js +76 -0
- package/dist/run-dag.js.map +1 -0
- package/dist/run-parsing.d.ts +13 -0
- package/dist/run-parsing.d.ts.map +1 -0
- package/dist/run-parsing.js +81 -0
- package/dist/run-parsing.js.map +1 -0
- package/dist/run-resume.d.ts +15 -0
- package/dist/run-resume.d.ts.map +1 -0
- package/dist/run-resume.js +28 -0
- package/dist/run-resume.js.map +1 -0
- package/dist/run-task-retry.d.ts +8 -0
- package/dist/run-task-retry.d.ts.map +1 -0
- package/dist/run-task-retry.js +25 -0
- package/dist/run-task-retry.js.map +1 -0
- package/dist/run-writer-restart.d.ts +14 -0
- package/dist/run-writer-restart.d.ts.map +1 -0
- package/dist/run-writer-restart.js +27 -0
- package/dist/run-writer-restart.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.98.5] - 2026-09-12
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added immutable verified-run contracts and validated start, candidate-resume, writer-restart and task-retry commands, plus bounded static DAG types and ordering helpers. Protocol data does not execute or approve work by itself.
|
|
10
|
+
|
|
5
11
|
## [0.98.4] - 2026-09-10
|
|
6
12
|
|
|
7
13
|
### Added
|
package/README.md
CHANGED
|
@@ -12,6 +12,21 @@ TaskSpec -> ExecutionAttempt -> Observation -> EvaluationResult -> RuntimeDecisi
|
|
|
12
12
|
- `TaskSpec`, `ExecutionAttempt`, `Observation`, `ClaimPredicate`
|
|
13
13
|
- `ClaimEvaluation`, `EvaluationResult`, `RuntimeDecision`, `WaiverRecord`
|
|
14
14
|
- Runtime parsers for every top-level record
|
|
15
|
+
- Opt-in command/scripted-agent profiles: immutable `RunContract`, `RunScriptedWriter`,
|
|
16
|
+
`RunStartCommand`, `parseRunContract()` and `parseRunStartCommand()`
|
|
17
|
+
(`omk.verified-run.v1` and `omk.verified-command.v1`). The scripted profile bounds
|
|
18
|
+
approved steps and offline logical requests. Parsing never grants approval or executes work.
|
|
19
|
+
- `RunResumeCommand`, `parseRunResumeCommand()` and `MAX_VERIFIED_RUN_GENERATIONS`:
|
|
20
|
+
candidate/contract/revision/generation-bound intent for host-governed recovery.
|
|
21
|
+
The runtime must still verify owner, clock, budget, process termination and evidence.
|
|
22
|
+
- `RunWriterRestartCommand` / `parseRunWriterRestartCommand()` separately bind a local
|
|
23
|
+
writer restart to an immutable input checkpoint. They grant no remote replay authority.
|
|
24
|
+
- Bounded `linux-command-dag-v1`: `RunDagWriter`, `RunDagTask`, `orderRunDag()`,
|
|
25
|
+
`runDagAncestors()`, `MAX_RUN_DAG_TASKS` and `MAX_RUN_TASK_ATTEMPTS`. Pure graph
|
|
26
|
+
ordering/closure does not schedule or authorize a process.
|
|
27
|
+
- `RunTaskRetryCommand` / `parseRunTaskRetryCommand()` bind a failed/interrupted task
|
|
28
|
+
selection to the original input and exact revision/generation. Empty selections
|
|
29
|
+
request pending-only continuation, not permission to omit a failed dependency.
|
|
15
30
|
- `evaluateTask()` and `reduceRuntimeDecision()`
|
|
16
31
|
- Claim Closure Graph v1: `evaluateProofClosure()`, `validateClaimGraph()`,
|
|
17
32
|
`minimalBlockingCut()` and the readonly claim/observation/waiver vocabulary
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ export { ClaimGraphError, canonicalClaimGraph, rootClaimIds, topologicalClaimOrd
|
|
|
4
4
|
export { type BlockingCutExplanation, CLAIM_GRAPH_SCHEMA_VERSION, CLAIM_VERDICT_PRECEDENCE, type ClaimClosureEvaluation, type ClaimGraph, type ClaimNode, type ClaimNodeKind, type ClaimRule, type ClaimSeverity, type ClaimVerdict, OBSERVATION_TRUST_RANK, type ObservationNode, type ObservationPolarity, type ObservationSource, type ProofClosureInput, type ProofClosureResult, type VerificationVerdict, type WaiverNode, type WitnessIndependencePolicy, type WorkspaceCompleteness, } from "./claims/claim-types.ts";
|
|
5
5
|
export { reduceRuntimeDecision } from "./decision.ts";
|
|
6
6
|
export { evaluateTask, ProtocolInvariantError } from "./evaluation.ts";
|
|
7
|
+
export { parseRunContract, parseRunStartCommand, type RunCheck, type RunContract, RunContractError, type RunPhaseBudget, type RunScriptedWriter, type RunStartCommand, VERIFIED_COMMAND_VERSION, VERIFIED_RUN_VERSION, } from "./run-contract.ts";
|
|
8
|
+
export { MAX_RUN_DAG_TASKS, MAX_RUN_TASK_ATTEMPTS, orderRunDag, type RunDagTask, type RunDagWriter, runDagAncestors, } from "./run-dag.ts";
|
|
9
|
+
export { MAX_VERIFIED_RUN_GENERATIONS, parseRunResumeCommand, type RunResumeCommand } from "./run-resume.ts";
|
|
10
|
+
export { parseRunTaskRetryCommand, type RunTaskRetryCommand } from "./run-task-retry.ts";
|
|
11
|
+
export { parseRunWriterRestartCommand, type RunWriterRestartCommand } from "./run-writer-restart.ts";
|
|
7
12
|
export type { AllCondition, AnyCondition, AttemptExecutor, AttemptOutcome, AttemptTrigger, ClaimCondition, ClaimEvaluation, ClaimPredicate, ClaimReasonCode, ClaimResult, EvaluationInput, EvaluationResult, ExecutionAttempt, JsonObject, JsonPrimitive, JsonValue, NotCondition, Observation, ObservationCondition, ProtocolVersion, RequirementLevel, RuntimeAction, RuntimeDecision, RuntimeDecisionInput, RuntimeDecisionPolicy, RuntimeDecisionReason, SemanticVerdict, TaskSpec, WaiverRecord, } from "./types.ts";
|
|
8
13
|
export { PROTOCOL_VERSION } from "./types.ts";
|
|
9
14
|
export { ProtocolValidationError, parseEvaluationResult, parseExecutionAttempt, parseObservation, parseRuntimeDecision, parseTaskSpec, parseWaiverRecord, } from "./validation.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,GAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,qBAAqB,EACrB,kBAAkB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,KAAK,sBAAsB,EAC3B,0BAA0B,EAC1B,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACvE,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,SAAS,EACT,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,QAAQ,EACR,YAAY,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,GACjB,MAAM,iBAAiB,CAAC","sourcesContent":["export {\n\texplainBlockingCut,\n\tisBlockingVerdict,\n\tMAX_BLOCKING_CUT_CANDIDATES,\n\tminimalBlockingCut,\n} from \"./claims/claim-blocking-cut.ts\";\nexport { evaluateProofClosure } from \"./claims/claim-closure.ts\";\nexport {\n\tClaimGraphError,\n\tcanonicalClaimGraph,\n\trootClaimIds,\n\ttopologicalClaimOrder,\n\tvalidateClaimGraph,\n} from \"./claims/claim-graph.ts\";\nexport {\n\ttype BlockingCutExplanation,\n\tCLAIM_GRAPH_SCHEMA_VERSION,\n\tCLAIM_VERDICT_PRECEDENCE,\n\ttype ClaimClosureEvaluation,\n\ttype ClaimGraph,\n\ttype ClaimNode,\n\ttype ClaimNodeKind,\n\ttype ClaimRule,\n\ttype ClaimSeverity,\n\ttype ClaimVerdict,\n\tOBSERVATION_TRUST_RANK,\n\ttype ObservationNode,\n\ttype ObservationPolarity,\n\ttype ObservationSource,\n\ttype ProofClosureInput,\n\ttype ProofClosureResult,\n\ttype VerificationVerdict,\n\ttype WaiverNode,\n\ttype WitnessIndependencePolicy,\n\ttype WorkspaceCompleteness,\n} from \"./claims/claim-types.ts\";\nexport { reduceRuntimeDecision } from \"./decision.ts\";\nexport { evaluateTask, ProtocolInvariantError } from \"./evaluation.ts\";\nexport type {\n\tAllCondition,\n\tAnyCondition,\n\tAttemptExecutor,\n\tAttemptOutcome,\n\tAttemptTrigger,\n\tClaimCondition,\n\tClaimEvaluation,\n\tClaimPredicate,\n\tClaimReasonCode,\n\tClaimResult,\n\tEvaluationInput,\n\tEvaluationResult,\n\tExecutionAttempt,\n\tJsonObject,\n\tJsonPrimitive,\n\tJsonValue,\n\tNotCondition,\n\tObservation,\n\tObservationCondition,\n\tProtocolVersion,\n\tRequirementLevel,\n\tRuntimeAction,\n\tRuntimeDecision,\n\tRuntimeDecisionInput,\n\tRuntimeDecisionPolicy,\n\tRuntimeDecisionReason,\n\tSemanticVerdict,\n\tTaskSpec,\n\tWaiverRecord,\n} from \"./types.ts\";\nexport { PROTOCOL_VERSION } from \"./types.ts\";\nexport {\n\tProtocolValidationError,\n\tparseEvaluationResult,\n\tparseExecutionAttempt,\n\tparseObservation,\n\tparseRuntimeDecision,\n\tparseTaskSpec,\n\tparseWaiverRecord,\n} from \"./validation.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,GAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,qBAAqB,EACrB,kBAAkB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,KAAK,sBAAsB,EAC3B,0BAA0B,EAC1B,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAA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AAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,GACjB,MAAM,iBAAiB,CAAC","sourcesContent":["export {\n\texplainBlockingCut,\n\tisBlockingVerdict,\n\tMAX_BLOCKING_CUT_CANDIDATES,\n\tminimalBlockingCut,\n} from \"./claims/claim-blocking-cut.ts\";\nexport { evaluateProofClosure } from \"./claims/claim-closure.ts\";\nexport {\n\tClaimGraphError,\n\tcanonicalClaimGraph,\n\trootClaimIds,\n\ttopologicalClaimOrder,\n\tvalidateClaimGraph,\n} from \"./claims/claim-graph.ts\";\nexport {\n\ttype BlockingCutExplanation,\n\tCLAIM_GRAPH_SCHEMA_VERSION,\n\tCLAIM_VERDICT_PRECEDENCE,\n\ttype ClaimClosureEvaluation,\n\ttype ClaimGraph,\n\ttype ClaimNode,\n\ttype ClaimNodeKind,\n\ttype ClaimRule,\n\ttype ClaimSeverity,\n\ttype ClaimVerdict,\n\tOBSERVATION_TRUST_RANK,\n\ttype ObservationNode,\n\ttype ObservationPolarity,\n\ttype ObservationSource,\n\ttype ProofClosureInput,\n\ttype ProofClosureResult,\n\ttype VerificationVerdict,\n\ttype WaiverNode,\n\ttype WitnessIndependencePolicy,\n\ttype WorkspaceCompleteness,\n} from \"./claims/claim-types.ts\";\nexport { reduceRuntimeDecision } from \"./decision.ts\";\nexport { evaluateTask, ProtocolInvariantError } from \"./evaluation.ts\";\nexport {\n\tparseRunContract,\n\tparseRunStartCommand,\n\ttype RunCheck,\n\ttype RunContract,\n\tRunContractError,\n\ttype RunPhaseBudget,\n\ttype RunScriptedWriter,\n\ttype RunStartCommand,\n\tVERIFIED_COMMAND_VERSION,\n\tVERIFIED_RUN_VERSION,\n} from \"./run-contract.ts\";\nexport {\n\tMAX_RUN_DAG_TASKS,\n\tMAX_RUN_TASK_ATTEMPTS,\n\torderRunDag,\n\ttype RunDagTask,\n\ttype RunDagWriter,\n\trunDagAncestors,\n} from \"./run-dag.ts\";\nexport { MAX_VERIFIED_RUN_GENERATIONS, parseRunResumeCommand, type RunResumeCommand } from \"./run-resume.ts\";\nexport { parseRunTaskRetryCommand, type RunTaskRetryCommand } from \"./run-task-retry.ts\";\nexport { parseRunWriterRestartCommand, type RunWriterRestartCommand } from \"./run-writer-restart.ts\";\nexport type {\n\tAllCondition,\n\tAnyCondition,\n\tAttemptExecutor,\n\tAttemptOutcome,\n\tAttemptTrigger,\n\tClaimCondition,\n\tClaimEvaluation,\n\tClaimPredicate,\n\tClaimReasonCode,\n\tClaimResult,\n\tEvaluationInput,\n\tEvaluationResult,\n\tExecutionAttempt,\n\tJsonObject,\n\tJsonPrimitive,\n\tJsonValue,\n\tNotCondition,\n\tObservation,\n\tObservationCondition,\n\tProtocolVersion,\n\tRequirementLevel,\n\tRuntimeAction,\n\tRuntimeDecision,\n\tRuntimeDecisionInput,\n\tRuntimeDecisionPolicy,\n\tRuntimeDecisionReason,\n\tSemanticVerdict,\n\tTaskSpec,\n\tWaiverRecord,\n} from \"./types.ts\";\nexport { PROTOCOL_VERSION } from \"./types.ts\";\nexport {\n\tProtocolValidationError,\n\tparseEvaluationResult,\n\tparseExecutionAttempt,\n\tparseObservation,\n\tparseRuntimeDecision,\n\tparseTaskSpec,\n\tparseWaiverRecord,\n} from \"./validation.ts\";\n"]}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,11 @@ export { ClaimGraphError, canonicalClaimGraph, rootClaimIds, topologicalClaimOrd
|
|
|
4
4
|
export { CLAIM_GRAPH_SCHEMA_VERSION, CLAIM_VERDICT_PRECEDENCE, OBSERVATION_TRUST_RANK, } from "./claims/claim-types.js";
|
|
5
5
|
export { reduceRuntimeDecision } from "./decision.js";
|
|
6
6
|
export { evaluateTask, ProtocolInvariantError } from "./evaluation.js";
|
|
7
|
+
export { parseRunContract, parseRunStartCommand, RunContractError, VERIFIED_COMMAND_VERSION, VERIFIED_RUN_VERSION, } from "./run-contract.js";
|
|
8
|
+
export { MAX_RUN_DAG_TASKS, MAX_RUN_TASK_ATTEMPTS, orderRunDag, runDagAncestors, } from "./run-dag.js";
|
|
9
|
+
export { MAX_VERIFIED_RUN_GENERATIONS, parseRunResumeCommand } from "./run-resume.js";
|
|
10
|
+
export { parseRunTaskRetryCommand } from "./run-task-retry.js";
|
|
11
|
+
export { parseRunWriterRestartCommand } from "./run-writer-restart.js";
|
|
7
12
|
export { PROTOCOL_VERSION } from "./types.js";
|
|
8
13
|
export { ProtocolValidationError, parseEvaluationResult, parseExecutionAttempt, parseObservation, parseRuntimeDecision, parseTaskSpec, parseWaiverRecord, } from "./validation.js";
|
|
9
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,GAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,qBAAqB,EACrB,kBAAkB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,0BAA0B,EAC1B,wBAAwB,EAQxB,sBAAsB,GAUtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,GAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,qBAAqB,EACrB,kBAAkB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,0BAA0B,EAC1B,wBAAwB,EAQxB,sBAAsB,GAUtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,oBAAoB,EAGpB,gBAAgB,EAIhB,wBAAwB,EACxB,oBAAoB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EAGX,eAAe,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAyB,MAAM,iBAAiB,CAAC;AAC7G,OAAO,EAAE,wBAAwB,EAA4B,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,4BAA4B,EAAgC,MAAM,yBAAyB,CAAC;AAgCrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,GACjB,MAAM,iBAAiB,CAAC","sourcesContent":["export {\n\texplainBlockingCut,\n\tisBlockingVerdict,\n\tMAX_BLOCKING_CUT_CANDIDATES,\n\tminimalBlockingCut,\n} from \"./claims/claim-blocking-cut.ts\";\nexport { evaluateProofClosure } from \"./claims/claim-closure.ts\";\nexport {\n\tClaimGraphError,\n\tcanonicalClaimGraph,\n\trootClaimIds,\n\ttopologicalClaimOrder,\n\tvalidateClaimGraph,\n} from \"./claims/claim-graph.ts\";\nexport {\n\ttype BlockingCutExplanation,\n\tCLAIM_GRAPH_SCHEMA_VERSION,\n\tCLAIM_VERDICT_PRECEDENCE,\n\ttype ClaimClosureEvaluation,\n\ttype ClaimGraph,\n\ttype ClaimNode,\n\ttype ClaimNodeKind,\n\ttype ClaimRule,\n\ttype ClaimSeverity,\n\ttype ClaimVerdict,\n\tOBSERVATION_TRUST_RANK,\n\ttype ObservationNode,\n\ttype ObservationPolarity,\n\ttype ObservationSource,\n\ttype ProofClosureInput,\n\ttype ProofClosureResult,\n\ttype VerificationVerdict,\n\ttype WaiverNode,\n\ttype WitnessIndependencePolicy,\n\ttype WorkspaceCompleteness,\n} from \"./claims/claim-types.ts\";\nexport { reduceRuntimeDecision } from \"./decision.ts\";\nexport { evaluateTask, ProtocolInvariantError } from \"./evaluation.ts\";\nexport {\n\tparseRunContract,\n\tparseRunStartCommand,\n\ttype RunCheck,\n\ttype RunContract,\n\tRunContractError,\n\ttype RunPhaseBudget,\n\ttype RunScriptedWriter,\n\ttype RunStartCommand,\n\tVERIFIED_COMMAND_VERSION,\n\tVERIFIED_RUN_VERSION,\n} from \"./run-contract.ts\";\nexport {\n\tMAX_RUN_DAG_TASKS,\n\tMAX_RUN_TASK_ATTEMPTS,\n\torderRunDag,\n\ttype RunDagTask,\n\ttype RunDagWriter,\n\trunDagAncestors,\n} from \"./run-dag.ts\";\nexport { MAX_VERIFIED_RUN_GENERATIONS, parseRunResumeCommand, type RunResumeCommand } from \"./run-resume.ts\";\nexport { parseRunTaskRetryCommand, type RunTaskRetryCommand } from \"./run-task-retry.ts\";\nexport { parseRunWriterRestartCommand, type RunWriterRestartCommand } from \"./run-writer-restart.ts\";\nexport type {\n\tAllCondition,\n\tAnyCondition,\n\tAttemptExecutor,\n\tAttemptOutcome,\n\tAttemptTrigger,\n\tClaimCondition,\n\tClaimEvaluation,\n\tClaimPredicate,\n\tClaimReasonCode,\n\tClaimResult,\n\tEvaluationInput,\n\tEvaluationResult,\n\tExecutionAttempt,\n\tJsonObject,\n\tJsonPrimitive,\n\tJsonValue,\n\tNotCondition,\n\tObservation,\n\tObservationCondition,\n\tProtocolVersion,\n\tRequirementLevel,\n\tRuntimeAction,\n\tRuntimeDecision,\n\tRuntimeDecisionInput,\n\tRuntimeDecisionPolicy,\n\tRuntimeDecisionReason,\n\tSemanticVerdict,\n\tTaskSpec,\n\tWaiverRecord,\n} from \"./types.ts\";\nexport { PROTOCOL_VERSION } from \"./types.ts\";\nexport {\n\tProtocolValidationError,\n\tparseEvaluationResult,\n\tparseExecutionAttempt,\n\tparseObservation,\n\tparseRuntimeDecision,\n\tparseTaskSpec,\n\tparseWaiverRecord,\n} from \"./validation.ts\";\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type RunDagWriter } from "./run-dag.ts";
|
|
2
|
+
export { RunContractError } from "./run-parsing.ts";
|
|
3
|
+
export declare const VERIFIED_RUN_VERSION: "omk.verified-run.v1";
|
|
4
|
+
export declare const VERIFIED_COMMAND_VERSION: "omk.verified-command.v1";
|
|
5
|
+
interface RunContractFields {
|
|
6
|
+
readonly schemaVersion: typeof VERIFIED_RUN_VERSION;
|
|
7
|
+
readonly runId: string;
|
|
8
|
+
readonly goal: string;
|
|
9
|
+
readonly workspace: {
|
|
10
|
+
readonly root: string;
|
|
11
|
+
readonly baseDigest: string;
|
|
12
|
+
};
|
|
13
|
+
readonly writablePaths: readonly string[];
|
|
14
|
+
readonly checks: readonly RunCheck[];
|
|
15
|
+
readonly budget: RunPhaseBudget;
|
|
16
|
+
readonly apply: "artifact-only";
|
|
17
|
+
}
|
|
18
|
+
export interface RunScriptedWriter {
|
|
19
|
+
readonly kind: "scripted-agent";
|
|
20
|
+
readonly steps: readonly (readonly string[])[];
|
|
21
|
+
readonly maxRequests: number;
|
|
22
|
+
}
|
|
23
|
+
export type RunContract = RunContractFields & ({
|
|
24
|
+
readonly profile: "linux-command-v1";
|
|
25
|
+
readonly writer: readonly string[];
|
|
26
|
+
} | {
|
|
27
|
+
readonly profile: "linux-scripted-agent-v1";
|
|
28
|
+
readonly writer: RunScriptedWriter;
|
|
29
|
+
} | {
|
|
30
|
+
readonly profile: "linux-command-dag-v1";
|
|
31
|
+
readonly writer: RunDagWriter;
|
|
32
|
+
});
|
|
33
|
+
export interface RunCheck {
|
|
34
|
+
readonly claimId: string;
|
|
35
|
+
readonly argv: readonly string[];
|
|
36
|
+
readonly stdout: string;
|
|
37
|
+
}
|
|
38
|
+
export interface RunPhaseBudget {
|
|
39
|
+
readonly workMs: number;
|
|
40
|
+
readonly verifyMs: number;
|
|
41
|
+
readonly cleanupMs: number;
|
|
42
|
+
readonly maxOutputBytes: number;
|
|
43
|
+
readonly maxFiles: number;
|
|
44
|
+
readonly maxBytes: number;
|
|
45
|
+
}
|
|
46
|
+
export interface RunStartCommand {
|
|
47
|
+
readonly schemaVersion: typeof VERIFIED_COMMAND_VERSION;
|
|
48
|
+
readonly kind: "start";
|
|
49
|
+
readonly runId: string;
|
|
50
|
+
readonly commandId: string;
|
|
51
|
+
readonly expectedRevision: 0;
|
|
52
|
+
readonly expectedGeneration: 0;
|
|
53
|
+
readonly contractDigest: string;
|
|
54
|
+
}
|
|
55
|
+
export declare function parseRunContract(value: unknown): RunContract;
|
|
56
|
+
/** Parsing is not approval. The coordinator requires approval via its trusted host call. */
|
|
57
|
+
export declare function parseRunStartCommand(value: unknown): RunStartCommand;
|
|
58
|
+
//# sourceMappingURL=run-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-contract.d.ts","sourceRoot":"","sources":["../src/run-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAcpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,eAAO,MAAM,oBAAoB,uBAAiC,CAAC;AACnE,eAAO,MAAM,wBAAwB,2BAAqC,CAAC;AAE3E,UAAU,iBAAiB;IAC1B,QAAQ,CAAC,aAAa,EAAE,OAAO,oBAAoB,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE;Q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AAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AACD,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,aAAa,EAAE,OAAO,wBAAwB,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC7B,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CAChC;AAQD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAuE5D;AAED,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CA0BpE","sourcesContent":["import { parseRunDagWriter, type RunDagWriter } from \"./run-dag.ts\";\nimport {\n\tRunContractError,\n\trunAbsolutePath,\n\trunArgv,\n\trunArray,\n\trunDigest,\n\trunId,\n\trunLimit,\n\trunObject,\n\trunRelativePath,\n\trunText,\n} from \"./run-parsing.ts\";\n\nexport { RunContractError } from \"./run-parsing.ts\";\nexport const VERIFIED_RUN_VERSION = \"omk.verified-run.v1\" as const;\nexport const VERIFIED_COMMAND_VERSION = \"omk.verified-command.v1\" as const;\n\ninterface RunContractFields {\n\treadonly schemaVersion: typeof VERIFIED_RUN_VERSION;\n\treadonly runId: string;\n\treadonly goal: string;\n\treadonly workspace: { readonly root: string; readonly baseDigest: string };\n\treadonly writablePaths: readonly string[];\n\treadonly checks: readonly RunCheck[];\n\treadonly budget: RunPhaseBudget;\n\treadonly apply: \"artifact-only\";\n}\nexport interface RunScriptedWriter {\n\treadonly kind: \"scripted-agent\";\n\treadonly steps: readonly (readonly string[])[];\n\treadonly maxRequests: number;\n}\nexport type RunContract = RunContractFields &\n\t(\n\t\t| { readonly profile: \"linux-command-v1\"; readonly writer: readonly string[] }\n\t\t| { readonly profile: \"linux-scripted-agent-v1\"; readonly writer: RunScriptedWriter }\n\t\t| { readonly profile: \"linux-command-dag-v1\"; readonly writer: RunDagWriter }\n\t);\nexport interface RunCheck {\n\treadonly claimId: string;\n\treadonly argv: readonly string[];\n\treadonly stdout: string;\n}\nexport interface RunPhaseBudget {\n\treadonly workMs: number;\n\treadonly verifyMs: number;\n\treadonly cleanupMs: number;\n\treadonly maxOutputBytes: number;\n\treadonly maxFiles: number;\n\treadonly maxBytes: number;\n}\nexport interface RunStartCommand {\n\treadonly schemaVersion: typeof VERIFIED_COMMAND_VERSION;\n\treadonly kind: \"start\";\n\treadonly runId: string;\n\treadonly commandId: string;\n\treadonly expectedRevision: 0;\n\treadonly expectedGeneration: 0;\n\treadonly contractDigest: string;\n}\n\nfunction check(value: unknown): RunCheck {\n\tconst input = runObject(value, [\"claimId\", \"argv\", \"stdout\"]);\n\tif (typeof input.stdout !== \"string\" || input.stdout.length > 65536) throw new RunContractError(\"stdout\");\n\treturn Object.freeze({ claimId: runId(input.claimId), argv: runArgv(input.argv), stdout: input.stdout });\n}\n\nexport function parseRunContract(value: unknown): RunContract {\n\tconst input = runObject(value, [\n\t\t\"schemaVersion\",\n\t\t\"profile\",\n\t\t\"runId\",\n\t\t\"goal\",\n\t\t\"workspace\",\n\t\t\"writablePaths\",\n\t\t\"writer\",\n\t\t\"checks\",\n\t\t\"budget\",\n\t\t\"apply\",\n\t]);\n\tif (input.schemaVersion !== VERIFIED_RUN_VERSION || input.apply !== \"artifact-only\")\n\t\tthrow new RunContractError(\"version/profile/apply\");\n\tconst workspace = runObject(input.workspace, [\"root\", \"baseDigest\"]);\n\tconst budget = runObject(input.budget, [\n\t\t\"workMs\",\n\t\t\"verifyMs\",\n\t\t\"cleanupMs\",\n\t\t\"maxOutputBytes\",\n\t\t\"maxFiles\",\n\t\t\"maxBytes\",\n\t]);\n\tconst checks = runArray(input.checks, check, 32);\n\tif (new Set(checks.map((item) => item.claimId)).size !== checks.length)\n\t\tthrow new RunContractError(\"duplicate claim\");\n\tconst writablePaths = runArray(input.writablePaths, runRelativePath, 128);\n\tif (new Set(writablePaths).size !== writablePaths.length) throw new RunContractError(\"duplicate path\");\n\tconst fields: RunContractFields = {\n\t\tschemaVersion: VERIFIED_RUN_VERSION,\n\t\trunId: runId(input.runId),\n\t\tgoal: runText(input.goal, \"goal\", 16384),\n\t\tworkspace: Object.freeze({ root: runAbsolutePath(workspace.root), baseDigest: runDigest(workspace.baseDigest) }),\n\t\twritablePaths,\n\t\tchecks,\n\t\tapply: \"artifact-only\",\n\t\tbudget: Object.freeze({\n\t\t\tworkMs: runLimit(budget.workMs, \"workMs\"),\n\t\t\tverifyMs: runLimit(budget.verifyMs, \"verifyMs\"),\n\t\t\tcleanupMs: runLimit(budget.cleanupMs, \"cleanupMs\"),\n\t\t\tmaxOutputBytes: runLimit(budget.maxOutputBytes, \"maxOutputBytes\", 1048576),\n\t\t\tmaxFiles: runLimit(budget.maxFiles, \"maxFiles\", 10000),\n\t\t\tmaxBytes: runLimit(budget.maxBytes, \"maxBytes\", 104857600),\n\t\t}),\n\t};\n\tswitch (input.profile) {\n\t\tcase \"linux-command-v1\":\n\t\t\treturn Object.freeze({ ...fields, profile: input.profile, writer: runArgv(input.writer) });\n\t\tcase \"linux-command-dag-v1\":\n\t\t\treturn Object.freeze({\n\t\t\t\t...fields,\n\t\t\t\tprofile: input.profile,\n\t\t\t\twriter: parseRunDagWriter(input.writer, writablePaths),\n\t\t\t});\n\t\tcase \"linux-scripted-agent-v1\": {\n\t\t\tconst writer = runObject(input.writer, [\"kind\", \"steps\", \"maxRequests\"]);\n\t\t\tif (writer.kind !== \"scripted-agent\") throw new RunContractError(\"writer.kind\");\n\t\t\treturn Object.freeze({\n\t\t\t\t...fields,\n\t\t\t\tprofile: input.profile,\n\t\t\t\twriter: Object.freeze({\n\t\t\t\t\tkind: writer.kind,\n\t\t\t\t\tsteps: runArray(writer.steps, runArgv, 16),\n\t\t\t\t\tmaxRequests: runLimit(writer.maxRequests, \"maxRequests\", 32),\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t\tdefault:\n\t\t\tthrow new RunContractError(\"version/profile/apply\");\n\t}\n}\n\n/** Parsing is not approval. The coordinator requires approval via its trusted host call. */\nexport function parseRunStartCommand(value: unknown): RunStartCommand {\n\tconst input = runObject(value, [\n\t\t\"schemaVersion\",\n\t\t\"kind\",\n\t\t\"runId\",\n\t\t\"commandId\",\n\t\t\"expectedRevision\",\n\t\t\"expectedGeneration\",\n\t\t\"contractDigest\",\n\t]);\n\tif (\n\t\tinput.schemaVersion !== VERIFIED_COMMAND_VERSION ||\n\t\tinput.kind !== \"start\" ||\n\t\tinput.expectedRevision !== 0 ||\n\t\tinput.expectedGeneration !== 0\n\t)\n\t\tthrow new RunContractError(\"command version/kind/precondition\");\n\treturn Object.freeze({\n\t\tschemaVersion: VERIFIED_COMMAND_VERSION,\n\t\tkind: \"start\",\n\t\trunId: runId(input.runId),\n\t\tcommandId: runId(input.commandId),\n\t\texpectedRevision: 0,\n\t\texpectedGeneration: 0,\n\t\tcontractDigest: runDigest(input.contractDigest),\n\t});\n}\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { parseRunDagWriter } from "./run-dag.js";
|
|
2
|
+
import { RunContractError, runAbsolutePath, runArgv, runArray, runDigest, runId, runLimit, runObject, runRelativePath, runText, } from "./run-parsing.js";
|
|
3
|
+
export { RunContractError } from "./run-parsing.js";
|
|
4
|
+
export const VERIFIED_RUN_VERSION = "omk.verified-run.v1";
|
|
5
|
+
export const VERIFIED_COMMAND_VERSION = "omk.verified-command.v1";
|
|
6
|
+
function check(value) {
|
|
7
|
+
const input = runObject(value, ["claimId", "argv", "stdout"]);
|
|
8
|
+
if (typeof input.stdout !== "string" || input.stdout.length > 65536)
|
|
9
|
+
throw new RunContractError("stdout");
|
|
10
|
+
return Object.freeze({ claimId: runId(input.claimId), argv: runArgv(input.argv), stdout: input.stdout });
|
|
11
|
+
}
|
|
12
|
+
export function parseRunContract(value) {
|
|
13
|
+
const input = runObject(value, [
|
|
14
|
+
"schemaVersion",
|
|
15
|
+
"profile",
|
|
16
|
+
"runId",
|
|
17
|
+
"goal",
|
|
18
|
+
"workspace",
|
|
19
|
+
"writablePaths",
|
|
20
|
+
"writer",
|
|
21
|
+
"checks",
|
|
22
|
+
"budget",
|
|
23
|
+
"apply",
|
|
24
|
+
]);
|
|
25
|
+
if (input.schemaVersion !== VERIFIED_RUN_VERSION || input.apply !== "artifact-only")
|
|
26
|
+
throw new RunContractError("version/profile/apply");
|
|
27
|
+
const workspace = runObject(input.workspace, ["root", "baseDigest"]);
|
|
28
|
+
const budget = runObject(input.budget, [
|
|
29
|
+
"workMs",
|
|
30
|
+
"verifyMs",
|
|
31
|
+
"cleanupMs",
|
|
32
|
+
"maxOutputBytes",
|
|
33
|
+
"maxFiles",
|
|
34
|
+
"maxBytes",
|
|
35
|
+
]);
|
|
36
|
+
const checks = runArray(input.checks, check, 32);
|
|
37
|
+
if (new Set(checks.map((item) => item.claimId)).size !== checks.length)
|
|
38
|
+
throw new RunContractError("duplicate claim");
|
|
39
|
+
const writablePaths = runArray(input.writablePaths, runRelativePath, 128);
|
|
40
|
+
if (new Set(writablePaths).size !== writablePaths.length)
|
|
41
|
+
throw new RunContractError("duplicate path");
|
|
42
|
+
const fields = {
|
|
43
|
+
schemaVersion: VERIFIED_RUN_VERSION,
|
|
44
|
+
runId: runId(input.runId),
|
|
45
|
+
goal: runText(input.goal, "goal", 16384),
|
|
46
|
+
workspace: Object.freeze({ root: runAbsolutePath(workspace.root), baseDigest: runDigest(workspace.baseDigest) }),
|
|
47
|
+
writablePaths,
|
|
48
|
+
checks,
|
|
49
|
+
apply: "artifact-only",
|
|
50
|
+
budget: Object.freeze({
|
|
51
|
+
workMs: runLimit(budget.workMs, "workMs"),
|
|
52
|
+
verifyMs: runLimit(budget.verifyMs, "verifyMs"),
|
|
53
|
+
cleanupMs: runLimit(budget.cleanupMs, "cleanupMs"),
|
|
54
|
+
maxOutputBytes: runLimit(budget.maxOutputBytes, "maxOutputBytes", 1048576),
|
|
55
|
+
maxFiles: runLimit(budget.maxFiles, "maxFiles", 10000),
|
|
56
|
+
maxBytes: runLimit(budget.maxBytes, "maxBytes", 104857600),
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
switch (input.profile) {
|
|
60
|
+
case "linux-command-v1":
|
|
61
|
+
return Object.freeze({ ...fields, profile: input.profile, writer: runArgv(input.writer) });
|
|
62
|
+
case "linux-command-dag-v1":
|
|
63
|
+
return Object.freeze({
|
|
64
|
+
...fields,
|
|
65
|
+
profile: input.profile,
|
|
66
|
+
writer: parseRunDagWriter(input.writer, writablePaths),
|
|
67
|
+
});
|
|
68
|
+
case "linux-scripted-agent-v1": {
|
|
69
|
+
const writer = runObject(input.writer, ["kind", "steps", "maxRequests"]);
|
|
70
|
+
if (writer.kind !== "scripted-agent")
|
|
71
|
+
throw new RunContractError("writer.kind");
|
|
72
|
+
return Object.freeze({
|
|
73
|
+
...fields,
|
|
74
|
+
profile: input.profile,
|
|
75
|
+
writer: Object.freeze({
|
|
76
|
+
kind: writer.kind,
|
|
77
|
+
steps: runArray(writer.steps, runArgv, 16),
|
|
78
|
+
maxRequests: runLimit(writer.maxRequests, "maxRequests", 32),
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
default:
|
|
83
|
+
throw new RunContractError("version/profile/apply");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Parsing is not approval. The coordinator requires approval via its trusted host call. */
|
|
87
|
+
export function parseRunStartCommand(value) {
|
|
88
|
+
const input = runObject(value, [
|
|
89
|
+
"schemaVersion",
|
|
90
|
+
"kind",
|
|
91
|
+
"runId",
|
|
92
|
+
"commandId",
|
|
93
|
+
"expectedRevision",
|
|
94
|
+
"expectedGeneration",
|
|
95
|
+
"contractDigest",
|
|
96
|
+
]);
|
|
97
|
+
if (input.schemaVersion !== VERIFIED_COMMAND_VERSION ||
|
|
98
|
+
input.kind !== "start" ||
|
|
99
|
+
input.expectedRevision !== 0 ||
|
|
100
|
+
input.expectedGeneration !== 0)
|
|
101
|
+
throw new RunContractError("command version/kind/precondition");
|
|
102
|
+
return Object.freeze({
|
|
103
|
+
schemaVersion: VERIFIED_COMMAND_VERSION,
|
|
104
|
+
kind: "start",
|
|
105
|
+
runId: runId(input.runId),
|
|
106
|
+
commandId: runId(input.commandId),
|
|
107
|
+
expectedRevision: 0,
|
|
108
|
+
expectedGeneration: 0,
|
|
109
|
+
contractDigest: runDigest(input.contractDigest),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=run-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-contract.js","sourceRoot":"","sources":["../src/run-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,cAAc,CAAC;AACpE,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,EACL,QAAQ,EACR,SAAS,EACT,eAAe,EACf,OAAO,GACP,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAA8B,CAAC;AACnE,MAAM,CAAC,MAAM,wBAAwB,GAAG,yBAAkC,CAAC;AA8C3E,SAAS,KAAK,CAAC,KAAc,EAAY;IACxC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC9D,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK;QAAE,MAAM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,KAAK,OAAO;QACtB,KAAK,CAAC,gBAAgB,KAAK,CAAC;QAC5B,KAAK,CAAC,kBAAkB,KAAK,CAAC;QAE9B,MAAM,IAAI,gBAAgB,CAAC,mCAAmC,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,MAAM,CAAC;QACpB,aAAa,EAAE,wBAAwB;QACvC,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QACzB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC;QACjC,gBAAgB,EAAE,CAAC;QACnB,kBAAkB,EAAE,CAAC;QACrB,cAAc,EAAE,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC;KAC/C,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { parseRunDagWriter, type RunDagWriter } from \"./run-dag.ts\";\nimport {\n\tRunContractError,\n\trunAbsolutePath,\n\trunArgv,\n\trunArray,\n\trunDigest,\n\trunId,\n\trunLimit,\n\trunObject,\n\trunRelativePath,\n\trunText,\n} from \"./run-parsing.ts\";\n\nexport { RunContractError } from \"./run-parsing.ts\";\nexport const VERIFIED_RUN_VERSION = \"omk.verified-run.v1\" as const;\nexport const VERIFIED_COMMAND_VERSION = \"omk.verified-command.v1\" as const;\n\ninterface RunContractFields {\n\treadonly schemaVersion: typeof VERIFIED_RUN_VERSION;\n\treadonly runId: string;\n\treadonly goal: string;\n\treadonly workspace: { readonly root: string; readonly baseDigest: string };\n\treadonly writablePaths: readonly string[];\n\treadonly checks: readonly RunCheck[];\n\treadonly budget: RunPhaseBudget;\n\treadonly apply: \"artifact-only\";\n}\nexport interface RunScriptedWriter {\n\treadonly kind: \"scripted-agent\";\n\treadonly steps: readonly (readonly string[])[];\n\treadonly maxRequests: number;\n}\nexport type RunContract = RunContractFields &\n\t(\n\t\t| { readonly profile: \"linux-command-v1\"; readonly writer: readonly string[] }\n\t\t| { readonly profile: \"linux-scripted-agent-v1\"; readonly writer: RunScriptedWriter }\n\t\t| { readonly profile: \"linux-command-dag-v1\"; readonly writer: RunDagWriter }\n\t);\nexport interface RunCheck {\n\treadonly claimId: string;\n\treadonly argv: readonly string[];\n\treadonly stdout: string;\n}\nexport interface RunPhaseBudget {\n\treadonly workMs: number;\n\treadonly verifyMs: number;\n\treadonly cleanupMs: number;\n\treadonly maxOutputBytes: number;\n\treadonly maxFiles: number;\n\treadonly maxBytes: number;\n}\nexport interface RunStartCommand {\n\treadonly schemaVersion: typeof VERIFIED_COMMAND_VERSION;\n\treadonly kind: \"start\";\n\treadonly runId: string;\n\treadonly commandId: string;\n\treadonly expectedRevision: 0;\n\treadonly expectedGeneration: 0;\n\treadonly contractDigest: string;\n}\n\nfunction check(value: unknown): RunCheck {\n\tconst input = runObject(value, [\"claimId\", \"argv\", \"stdout\"]);\n\tif (typeof input.stdout !== \"string\" || input.stdout.length > 65536) throw new RunContractError(\"stdout\");\n\treturn Object.freeze({ claimId: runId(input.claimId), argv: runArgv(input.argv), stdout: input.stdout });\n}\n\nexport function parseRunContract(value: unknown): RunContract {\n\tconst input = runObject(value, [\n\t\t\"schemaVersion\",\n\t\t\"profile\",\n\t\t\"runId\",\n\t\t\"goal\",\n\t\t\"workspace\",\n\t\t\"writablePaths\",\n\t\t\"writer\",\n\t\t\"checks\",\n\t\t\"budget\",\n\t\t\"apply\",\n\t]);\n\tif (input.schemaVersion !== VERIFIED_RUN_VERSION || input.apply !== \"artifact-only\")\n\t\tthrow new RunContractError(\"version/profile/apply\");\n\tconst workspace = runObject(input.workspace, [\"root\", \"baseDigest\"]);\n\tconst budget = runObject(input.budget, [\n\t\t\"workMs\",\n\t\t\"verifyMs\",\n\t\t\"cleanupMs\",\n\t\t\"maxOutputBytes\",\n\t\t\"maxFiles\",\n\t\t\"maxBytes\",\n\t]);\n\tconst checks = runArray(input.checks, check, 32);\n\tif (new Set(checks.map((item) => item.claimId)).size !== checks.length)\n\t\tthrow new RunContractError(\"duplicate claim\");\n\tconst writablePaths = runArray(input.writablePaths, runRelativePath, 128);\n\tif (new Set(writablePaths).size !== writablePaths.length) throw new RunContractError(\"duplicate path\");\n\tconst fields: RunContractFields = {\n\t\tschemaVersion: VERIFIED_RUN_VERSION,\n\t\trunId: runId(input.runId),\n\t\tgoal: runText(input.goal, \"goal\", 16384),\n\t\tworkspace: Object.freeze({ root: runAbsolutePath(workspace.root), baseDigest: runDigest(workspace.baseDigest) }),\n\t\twritablePaths,\n\t\tchecks,\n\t\tapply: \"artifact-only\",\n\t\tbudget: Object.freeze({\n\t\t\tworkMs: runLimit(budget.workMs, \"workMs\"),\n\t\t\tverifyMs: runLimit(budget.verifyMs, \"verifyMs\"),\n\t\t\tcleanupMs: runLimit(budget.cleanupMs, \"cleanupMs\"),\n\t\t\tmaxOutputBytes: runLimit(budget.maxOutputBytes, \"maxOutputBytes\", 1048576),\n\t\t\tmaxFiles: runLimit(budget.maxFiles, \"maxFiles\", 10000),\n\t\t\tmaxBytes: runLimit(budget.maxBytes, \"maxBytes\", 104857600),\n\t\t}),\n\t};\n\tswitch (input.profile) {\n\t\tcase \"linux-command-v1\":\n\t\t\treturn Object.freeze({ ...fields, profile: input.profile, writer: runArgv(input.writer) });\n\t\tcase \"linux-command-dag-v1\":\n\t\t\treturn Object.freeze({\n\t\t\t\t...fields,\n\t\t\t\tprofile: input.profile,\n\t\t\t\twriter: parseRunDagWriter(input.writer, writablePaths),\n\t\t\t});\n\t\tcase \"linux-scripted-agent-v1\": {\n\t\t\tconst writer = runObject(input.writer, [\"kind\", \"steps\", \"maxRequests\"]);\n\t\t\tif (writer.kind !== \"scripted-agent\") throw new RunContractError(\"writer.kind\");\n\t\t\treturn Object.freeze({\n\t\t\t\t...fields,\n\t\t\t\tprofile: input.profile,\n\t\t\t\twriter: Object.freeze({\n\t\t\t\t\tkind: writer.kind,\n\t\t\t\t\tsteps: runArray(writer.steps, runArgv, 16),\n\t\t\t\t\tmaxRequests: runLimit(writer.maxRequests, \"maxRequests\", 32),\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t\tdefault:\n\t\t\tthrow new RunContractError(\"version/profile/apply\");\n\t}\n}\n\n/** Parsing is not approval. The coordinator requires approval via its trusted host call. */\nexport function parseRunStartCommand(value: unknown): RunStartCommand {\n\tconst input = runObject(value, [\n\t\t\"schemaVersion\",\n\t\t\"kind\",\n\t\t\"runId\",\n\t\t\"commandId\",\n\t\t\"expectedRevision\",\n\t\t\"expectedGeneration\",\n\t\t\"contractDigest\",\n\t]);\n\tif (\n\t\tinput.schemaVersion !== VERIFIED_COMMAND_VERSION ||\n\t\tinput.kind !== \"start\" ||\n\t\tinput.expectedRevision !== 0 ||\n\t\tinput.expectedGeneration !== 0\n\t)\n\t\tthrow new RunContractError(\"command version/kind/precondition\");\n\treturn Object.freeze({\n\t\tschemaVersion: VERIFIED_COMMAND_VERSION,\n\t\tkind: \"start\",\n\t\trunId: runId(input.runId),\n\t\tcommandId: runId(input.commandId),\n\t\texpectedRevision: 0,\n\t\texpectedGeneration: 0,\n\t\tcontractDigest: runDigest(input.contractDigest),\n\t});\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const MAX_RUN_DAG_TASKS = 16;
|
|
2
|
+
export declare const MAX_RUN_TASK_ATTEMPTS = 2;
|
|
3
|
+
export interface RunDagTask {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly dependsOn: readonly string[];
|
|
6
|
+
readonly writablePaths: readonly string[];
|
|
7
|
+
readonly attempts: readonly (readonly string[])[];
|
|
8
|
+
}
|
|
9
|
+
export interface RunDagWriter {
|
|
10
|
+
readonly kind: "command-dag";
|
|
11
|
+
readonly tasks: readonly RunDagTask[];
|
|
12
|
+
}
|
|
13
|
+
/** Deterministic FIFO Kahn ordering. This orders artifacts, not tool resource-conflict claims. */
|
|
14
|
+
export declare function orderRunDag(tasks: readonly RunDagTask[]): readonly RunDagTask[];
|
|
15
|
+
/** Every ancestor material is an input; unrelated successful branches are deliberately excluded. */
|
|
16
|
+
export declare function runDagAncestors(tasks: readonly RunDagTask[], taskId: string): readonly RunDagTask[];
|
|
17
|
+
export declare function parseRunDagWriter(value: unknown, writable: readonly string[]): RunDagWriter;
|
|
18
|
+
//# sourceMappingURL=run-dag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-dag.d.ts","sourceRoot":"","sources":["../src/run-dag.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;CAClD;AACD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;CACtC;AAED,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,SAAS,UAAU,EAAE,CAiB/E;AAED,oGAAoG;AACpG,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,UAAU,EAAE,CAQnG;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,CAoC3F","sourcesContent":["import { RunContractError, runArgv, runArray, runId, runObject, runRelativePath } from \"./run-parsing.ts\";\n\nexport const MAX_RUN_DAG_TASKS = 16;\nexport const MAX_RUN_TASK_ATTEMPTS = 2;\n\nexport interface RunDagTask {\n\treadonly id: string;\n\treadonly dependsOn: readonly string[];\n\treadonly writablePaths: readonly string[];\n\treadonly attempts: readonly (readonly string[])[];\n}\nexport interface RunDagWriter {\n\treadonly kind: \"command-dag\";\n\treadonly tasks: readonly RunDagTask[];\n}\n\n/** Deterministic FIFO Kahn ordering. This orders artifacts, not tool resource-conflict claims. */\nexport function orderRunDag(tasks: readonly RunDagTask[]): readonly RunDagTask[] {\n\tconst pending = new Map(tasks.map((task) => [task.id, task.dependsOn.length]));\n\tconst ready = tasks.filter((task) => task.dependsOn.length === 0);\n\tconst ordered: RunDagTask[] = [];\n\tfor (let index = 0; index < ready.length; index++) {\n\t\tconst next = ready[index];\n\t\tordered.push(next);\n\t\tfor (const task of tasks) {\n\t\t\tif (!task.dependsOn.includes(next.id)) continue;\n\t\t\tconst count = pending.get(task.id);\n\t\t\tif (count === undefined) throw new RunContractError(\"dependency\");\n\t\t\tpending.set(task.id, count - 1);\n\t\t\tif (count === 1) ready.push(task);\n\t\t}\n\t}\n\tif (ordered.length !== tasks.length) throw new RunContractError(\"cyclic dependency\");\n\treturn Object.freeze(ordered);\n}\n\n/** Every ancestor material is an input; unrelated successful branches are deliberately excluded. */\nexport function runDagAncestors(tasks: readonly RunDagTask[], taskId: string): readonly RunDagTask[] {\n\tif (!tasks.some((task) => task.id === taskId)) throw new RunContractError(\"taskId\");\n\tconst order = orderRunDag(tasks);\n\tconst included = new Set([taskId]);\n\tfor (const task of [...order].reverse()) {\n\t\tif (included.has(task.id)) for (const id of task.dependsOn) included.add(id);\n\t}\n\treturn Object.freeze(order.filter((task) => task.id !== taskId && included.has(task.id)));\n}\n\nexport function parseRunDagWriter(value: unknown, writable: readonly string[]): RunDagWriter {\n\tconst raw = runObject(value, [\"kind\", \"tasks\"]);\n\tif (raw.kind !== \"command-dag\") throw new RunContractError(\"writer.kind\");\n\tconst tasks = runArray(\n\t\traw.tasks,\n\t\t(value): RunDagTask => {\n\t\t\tconst task = runObject(value, [\"id\", \"dependsOn\", \"writablePaths\", \"attempts\"]);\n\t\t\tconst dependsOn =\n\t\t\t\tArray.isArray(task.dependsOn) && task.dependsOn.length === 0\n\t\t\t\t\t? Object.freeze([])\n\t\t\t\t\t: runArray(task.dependsOn, runId, MAX_RUN_DAG_TASKS);\n\t\t\tif (new Set(dependsOn).size !== dependsOn.length) throw new RunContractError(\"duplicate dependency\");\n\t\t\treturn Object.freeze({\n\t\t\t\tid: runId(task.id),\n\t\t\t\tdependsOn,\n\t\t\t\twritablePaths: runArray(task.writablePaths, runRelativePath, 128),\n\t\t\t\tattempts: runArray(task.attempts, runArgv, MAX_RUN_TASK_ATTEMPTS),\n\t\t\t});\n\t\t},\n\t\tMAX_RUN_DAG_TASKS,\n\t);\n\tconst ids = new Set(tasks.map((task) => task.id));\n\tif (ids.size !== tasks.length) throw new RunContractError(\"duplicate task\");\n\tconst scopes: string[] = [];\n\tfor (const task of tasks) {\n\t\tif (task.dependsOn.some((id) => id === task.id || !ids.has(id))) throw new RunContractError(\"dependency\");\n\t\tfor (const path of task.writablePaths) {\n\t\t\tif (!writable.some((scope) => path === scope || path.startsWith(`${scope}/`)))\n\t\t\t\tthrow new RunContractError(\"task scope\");\n\t\t\tif (scopes.some((scope) => path === scope || path.startsWith(`${scope}/`) || scope.startsWith(`${path}/`)))\n\t\t\t\tthrow new RunContractError(\"overlapping task scope\");\n\t\t\tscopes.push(path);\n\t\t}\n\t}\n\torderRunDag(tasks);\n\treturn Object.freeze({ kind: \"command-dag\", tasks });\n}\n"]}
|
package/dist/run-dag.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { RunContractError, runArgv, runArray, runId, runObject, runRelativePath } from "./run-parsing.js";
|
|
2
|
+
export const MAX_RUN_DAG_TASKS = 16;
|
|
3
|
+
export const MAX_RUN_TASK_ATTEMPTS = 2;
|
|
4
|
+
/** Deterministic FIFO Kahn ordering. This orders artifacts, not tool resource-conflict claims. */
|
|
5
|
+
export function orderRunDag(tasks) {
|
|
6
|
+
const pending = new Map(tasks.map((task) => [task.id, task.dependsOn.length]));
|
|
7
|
+
const ready = tasks.filter((task) => task.dependsOn.length === 0);
|
|
8
|
+
const ordered = [];
|
|
9
|
+
for (let index = 0; index < ready.length; index++) {
|
|
10
|
+
const next = ready[index];
|
|
11
|
+
ordered.push(next);
|
|
12
|
+
for (const task of tasks) {
|
|
13
|
+
if (!task.dependsOn.includes(next.id))
|
|
14
|
+
continue;
|
|
15
|
+
const count = pending.get(task.id);
|
|
16
|
+
if (count === undefined)
|
|
17
|
+
throw new RunContractError("dependency");
|
|
18
|
+
pending.set(task.id, count - 1);
|
|
19
|
+
if (count === 1)
|
|
20
|
+
ready.push(task);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (ordered.length !== tasks.length)
|
|
24
|
+
throw new RunContractError("cyclic dependency");
|
|
25
|
+
return Object.freeze(ordered);
|
|
26
|
+
}
|
|
27
|
+
/** Every ancestor material is an input; unrelated successful branches are deliberately excluded. */
|
|
28
|
+
export function runDagAncestors(tasks, taskId) {
|
|
29
|
+
if (!tasks.some((task) => task.id === taskId))
|
|
30
|
+
throw new RunContractError("taskId");
|
|
31
|
+
const order = orderRunDag(tasks);
|
|
32
|
+
const included = new Set([taskId]);
|
|
33
|
+
for (const task of [...order].reverse()) {
|
|
34
|
+
if (included.has(task.id))
|
|
35
|
+
for (const id of task.dependsOn)
|
|
36
|
+
included.add(id);
|
|
37
|
+
}
|
|
38
|
+
return Object.freeze(order.filter((task) => task.id !== taskId && included.has(task.id)));
|
|
39
|
+
}
|
|
40
|
+
export function parseRunDagWriter(value, writable) {
|
|
41
|
+
const raw = runObject(value, ["kind", "tasks"]);
|
|
42
|
+
if (raw.kind !== "command-dag")
|
|
43
|
+
throw new RunContractError("writer.kind");
|
|
44
|
+
const tasks = runArray(raw.tasks, (value) => {
|
|
45
|
+
const task = runObject(value, ["id", "dependsOn", "writablePaths", "attempts"]);
|
|
46
|
+
const dependsOn = Array.isArray(task.dependsOn) && task.dependsOn.length === 0
|
|
47
|
+
? Object.freeze([])
|
|
48
|
+
: runArray(task.dependsOn, runId, MAX_RUN_DAG_TASKS);
|
|
49
|
+
if (new Set(dependsOn).size !== dependsOn.length)
|
|
50
|
+
throw new RunContractError("duplicate dependency");
|
|
51
|
+
return Object.freeze({
|
|
52
|
+
id: runId(task.id),
|
|
53
|
+
dependsOn,
|
|
54
|
+
writablePaths: runArray(task.writablePaths, runRelativePath, 128),
|
|
55
|
+
attempts: runArray(task.attempts, runArgv, MAX_RUN_TASK_ATTEMPTS),
|
|
56
|
+
});
|
|
57
|
+
}, MAX_RUN_DAG_TASKS);
|
|
58
|
+
const ids = new Set(tasks.map((task) => task.id));
|
|
59
|
+
if (ids.size !== tasks.length)
|
|
60
|
+
throw new RunContractError("duplicate task");
|
|
61
|
+
const scopes = [];
|
|
62
|
+
for (const task of tasks) {
|
|
63
|
+
if (task.dependsOn.some((id) => id === task.id || !ids.has(id)))
|
|
64
|
+
throw new RunContractError("dependency");
|
|
65
|
+
for (const path of task.writablePaths) {
|
|
66
|
+
if (!writable.some((scope) => path === scope || path.startsWith(`${scope}/`)))
|
|
67
|
+
throw new RunContractError("task scope");
|
|
68
|
+
if (scopes.some((scope) => path === scope || path.startsWith(`${scope}/`) || scope.startsWith(`${path}/`)))
|
|
69
|
+
throw new RunContractError("overlapping task scope");
|
|
70
|
+
scopes.push(path);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
orderRunDag(tasks);
|
|
74
|
+
return Object.freeze({ kind: "command-dag", tasks });
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=run-dag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-dag.js","sourceRoot":"","sources":["../src/run-dag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE1G,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,M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AE,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAAE,MAAM,IAAI,gBAAgB,CAAC,YAAY,CAAC,CAAC;QAC1G,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;gBAC5E,MAAM,IAAI,gBAAgB,CAAC,YAAY,CAAC,CAAC;YAC1C,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;gBACzG,MAAM,IAAI,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;YACtD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACF,CAAC;IACD,WAAW,CAAC,KAAK,CAAC,CAAC;IACnB,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;AAAA,CACrD","sourcesContent":["import { RunContractError, runArgv, runArray, runId, runObject, runRelativePath } from \"./run-parsing.ts\";\n\nexport const MAX_RUN_DAG_TASKS = 16;\nexport const MAX_RUN_TASK_ATTEMPTS = 2;\n\nexport interface RunDagTask {\n\treadonly id: string;\n\treadonly dependsOn: readonly string[];\n\treadonly writablePaths: readonly string[];\n\treadonly attempts: readonly (readonly string[])[];\n}\nexport interface RunDagWriter {\n\treadonly kind: \"command-dag\";\n\treadonly tasks: readonly RunDagTask[];\n}\n\n/** Deterministic FIFO Kahn ordering. This orders artifacts, not tool resource-conflict claims. */\nexport function orderRunDag(tasks: readonly RunDagTask[]): readonly RunDagTask[] {\n\tconst pending = new Map(tasks.map((task) => [task.id, task.dependsOn.length]));\n\tconst ready = tasks.filter((task) => task.dependsOn.length === 0);\n\tconst ordered: RunDagTask[] = [];\n\tfor (let index = 0; index < ready.length; index++) {\n\t\tconst next = ready[index];\n\t\tordered.push(next);\n\t\tfor (const task of tasks) {\n\t\t\tif (!task.dependsOn.includes(next.id)) continue;\n\t\t\tconst count = pending.get(task.id);\n\t\t\tif (count === undefined) throw new RunContractError(\"dependency\");\n\t\t\tpending.set(task.id, count - 1);\n\t\t\tif (count === 1) ready.push(task);\n\t\t}\n\t}\n\tif (ordered.length !== tasks.length) throw new RunContractError(\"cyclic dependency\");\n\treturn Object.freeze(ordered);\n}\n\n/** Every ancestor material is an input; unrelated successful branches are deliberately excluded. */\nexport function runDagAncestors(tasks: readonly RunDagTask[], taskId: string): readonly RunDagTask[] {\n\tif (!tasks.some((task) => task.id === taskId)) throw new RunContractError(\"taskId\");\n\tconst order = orderRunDag(tasks);\n\tconst included = new Set([taskId]);\n\tfor (const task of [...order].reverse()) {\n\t\tif (included.has(task.id)) for (const id of task.dependsOn) included.add(id);\n\t}\n\treturn Object.freeze(order.filter((task) => task.id !== taskId && included.has(task.id)));\n}\n\nexport function parseRunDagWriter(value: unknown, writable: readonly string[]): RunDagWriter {\n\tconst raw = runObject(value, [\"kind\", \"tasks\"]);\n\tif (raw.kind !== \"command-dag\") throw new RunContractError(\"writer.kind\");\n\tconst tasks = runArray(\n\t\traw.tasks,\n\t\t(value): RunDagTask => {\n\t\t\tconst task = runObject(value, [\"id\", \"dependsOn\", \"writablePaths\", \"attempts\"]);\n\t\t\tconst dependsOn =\n\t\t\t\tArray.isArray(task.dependsOn) && task.dependsOn.length === 0\n\t\t\t\t\t? Object.freeze([])\n\t\t\t\t\t: runArray(task.dependsOn, runId, MAX_RUN_DAG_TASKS);\n\t\t\tif (new Set(dependsOn).size !== dependsOn.length) throw new RunContractError(\"duplicate dependency\");\n\t\t\treturn Object.freeze({\n\t\t\t\tid: runId(task.id),\n\t\t\t\tdependsOn,\n\t\t\t\twritablePaths: runArray(task.writablePaths, runRelativePath, 128),\n\t\t\t\tattempts: runArray(task.attempts, runArgv, MAX_RUN_TASK_ATTEMPTS),\n\t\t\t});\n\t\t},\n\t\tMAX_RUN_DAG_TASKS,\n\t);\n\tconst ids = new Set(tasks.map((task) => task.id));\n\tif (ids.size !== tasks.length) throw new RunContractError(\"duplicate task\");\n\tconst scopes: string[] = [];\n\tfor (const task of tasks) {\n\t\tif (task.dependsOn.some((id) => id === task.id || !ids.has(id))) throw new RunContractError(\"dependency\");\n\t\tfor (const path of task.writablePaths) {\n\t\t\tif (!writable.some((scope) => path === scope || path.startsWith(`${scope}/`)))\n\t\t\t\tthrow new RunContractError(\"task scope\");\n\t\t\tif (scopes.some((scope) => path === scope || path.startsWith(`${scope}/`) || scope.startsWith(`${path}/`)))\n\t\t\t\tthrow new RunContractError(\"overlapping task scope\");\n\t\t\tscopes.push(path);\n\t\t}\n\t}\n\torderRunDag(tasks);\n\treturn Object.freeze({ kind: \"command-dag\", tasks });\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class RunContractError extends Error {
|
|
2
|
+
constructor(field: string);
|
|
3
|
+
}
|
|
4
|
+
export declare function runObject(value: unknown, keys: readonly string[]): Record<string, unknown>;
|
|
5
|
+
export declare function runText(value: unknown, field: string, max?: number): string;
|
|
6
|
+
export declare function runId(value: unknown): string;
|
|
7
|
+
export declare function runDigest(value: unknown): string;
|
|
8
|
+
export declare function runLimit(value: unknown, field: string, max?: number): number;
|
|
9
|
+
export declare function runArray<T>(value: unknown, parse: (item: unknown) => T, max: number): readonly T[];
|
|
10
|
+
export declare function runRelativePath(value: unknown): string;
|
|
11
|
+
export declare function runAbsolutePath(value: unknown): string;
|
|
12
|
+
export declare function runArgv(value: unknown): readonly string[];
|
|
13
|
+
//# sourceMappingURL=run-parsing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-parsing.d.ts","sourceRoot":"","sources":["../src/run-parsing.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,YAAY,KAAK,EAAE,MAAM,EAGxB;CACD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAa1F;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAO,GAAG,MAAM,CAIzE;AACD,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI5C;AACD,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGhD;AACD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,MAAM,CAIhF;AACD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,EAAE,CASlG;AACD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQtD;AACD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAatD;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAQzD","sourcesContent":["export class RunContractError extends Error {\n\tconstructor(field: string) {\n\t\tsuper(`Invalid verified-run field: ${field}`);\n\t\tthis.name = \"RunContractError\";\n\t}\n}\n\nexport function runObject(value: unknown, keys: readonly string[]): Record<string, unknown> {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new RunContractError(\"object\");\n\tif (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)\n\t\tthrow new RunContractError(\"prototype\");\n\tconst descriptors = Object.getOwnPropertyDescriptors(value);\n\tif (Reflect.ownKeys(value).length !== keys.length) throw new RunContractError(\"fields\");\n\tconst result: Record<string, unknown> = {};\n\tfor (const key of keys) {\n\t\tconst descriptor = descriptors[key];\n\t\tif (!descriptor || !(\"value\" in descriptor) || !descriptor.enumerable) throw new RunContractError(key);\n\t\tresult[key] = descriptor.value;\n\t}\n\treturn result;\n}\nexport function runText(value: unknown, field: string, max = 4096): string {\n\tif (typeof value !== \"string\" || value.length === 0 || value.length > max || /[\\u0000\\ud800-\\udfff]/u.test(value))\n\t\tthrow new RunContractError(field);\n\treturn value;\n}\nexport function runId(value: unknown): string {\n\tconst id = runText(value, \"id\", 128);\n\tif (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(id)) throw new RunContractError(\"id\");\n\treturn id;\n}\nexport function runDigest(value: unknown): string {\n\tif (typeof value !== \"string\" || !/^[a-f0-9]{64}$/.test(value)) throw new RunContractError(\"digest\");\n\treturn value;\n}\nexport function runLimit(value: unknown, field: string, max = 2147483647): number {\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value) || value <= 0 || value > max)\n\t\tthrow new RunContractError(field);\n\treturn value;\n}\nexport function runArray<T>(value: unknown, parse: (item: unknown) => T, max: number): readonly T[] {\n\tif (!Array.isArray(value) || value.length === 0 || value.length > max) throw new RunContractError(\"array\");\n\tconst items: T[] = [];\n\tfor (let index = 0; index < value.length; index++) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(value, String(index));\n\t\tif (!descriptor || !(\"value\" in descriptor)) throw new RunContractError(\"array item\");\n\t\titems.push(parse(descriptor.value));\n\t}\n\treturn Object.freeze(items);\n}\nexport function runRelativePath(value: unknown): string {\n\tconst path = runText(value, \"path\", 1024);\n\tif (\n\t\t/[\\\\\\u0000-\\u001f\\u007f]/.test(path) ||\n\t\tpath.split(\"/\").some((part) => [\"\", \".\", \"..\", \".git\", \".omk\"].includes(part))\n\t)\n\t\tthrow new RunContractError(\"path\");\n\treturn path;\n}\nexport function runAbsolutePath(value: unknown): string {\n\tconst path = runText(value, \"absolute path\", 4096);\n\tif (\n\t\t!path.startsWith(\"/\") ||\n\t\tpath === \"/\" ||\n\t\tpath\n\t\t\t.slice(1)\n\t\t\t.split(\"/\")\n\t\t\t.some((part) => [\"\", \".\", \"..\"].includes(part)) ||\n\t\t/[\\\\\\u0000-\\u001f\\u007f]/.test(path)\n\t)\n\t\tthrow new RunContractError(\"absolute path\");\n\treturn path;\n}\nexport function runArgv(value: unknown): readonly string[] {\n\tconst args = runArray(\n\t\tvalue,\n\t\t(item) => (typeof item === \"string\" && item.length === 0 ? \"\" : runText(item, \"argv\", 16384)),\n\t\t128,\n\t);\n\trunAbsolutePath(args[0]);\n\treturn args;\n}\n"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export class RunContractError extends Error {
|
|
2
|
+
constructor(field) {
|
|
3
|
+
super(`Invalid verified-run field: ${field}`);
|
|
4
|
+
this.name = "RunContractError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export function runObject(value, keys) {
|
|
8
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
9
|
+
throw new RunContractError("object");
|
|
10
|
+
if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
|
|
11
|
+
throw new RunContractError("prototype");
|
|
12
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
13
|
+
if (Reflect.ownKeys(value).length !== keys.length)
|
|
14
|
+
throw new RunContractError("fields");
|
|
15
|
+
const result = {};
|
|
16
|
+
for (const key of keys) {
|
|
17
|
+
const descriptor = descriptors[key];
|
|
18
|
+
if (!descriptor || !("value" in descriptor) || !descriptor.enumerable)
|
|
19
|
+
throw new RunContractError(key);
|
|
20
|
+
result[key] = descriptor.value;
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
export function runText(value, field, max = 4096) {
|
|
25
|
+
if (typeof value !== "string" || value.length === 0 || value.length > max || /[\u0000\ud800-\udfff]/u.test(value))
|
|
26
|
+
throw new RunContractError(field);
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
export function runId(value) {
|
|
30
|
+
const id = runText(value, "id", 128);
|
|
31
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(id))
|
|
32
|
+
throw new RunContractError("id");
|
|
33
|
+
return id;
|
|
34
|
+
}
|
|
35
|
+
export function runDigest(value) {
|
|
36
|
+
if (typeof value !== "string" || !/^[a-f0-9]{64}$/.test(value))
|
|
37
|
+
throw new RunContractError("digest");
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
export function runLimit(value, field, max = 2147483647) {
|
|
41
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0 || value > max)
|
|
42
|
+
throw new RunContractError(field);
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
export function runArray(value, parse, max) {
|
|
46
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > max)
|
|
47
|
+
throw new RunContractError("array");
|
|
48
|
+
const items = [];
|
|
49
|
+
for (let index = 0; index < value.length; index++) {
|
|
50
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
51
|
+
if (!descriptor || !("value" in descriptor))
|
|
52
|
+
throw new RunContractError("array item");
|
|
53
|
+
items.push(parse(descriptor.value));
|
|
54
|
+
}
|
|
55
|
+
return Object.freeze(items);
|
|
56
|
+
}
|
|
57
|
+
export function runRelativePath(value) {
|
|
58
|
+
const path = runText(value, "path", 1024);
|
|
59
|
+
if (/[\\\u0000-\u001f\u007f]/.test(path) ||
|
|
60
|
+
path.split("/").some((part) => ["", ".", "..", ".git", ".omk"].includes(part)))
|
|
61
|
+
throw new RunContractError("path");
|
|
62
|
+
return path;
|
|
63
|
+
}
|
|
64
|
+
export function runAbsolutePath(value) {
|
|
65
|
+
const path = runText(value, "absolute path", 4096);
|
|
66
|
+
if (!path.startsWith("/") ||
|
|
67
|
+
path === "/" ||
|
|
68
|
+
path
|
|
69
|
+
.slice(1)
|
|
70
|
+
.split("/")
|
|
71
|
+
.some((part) => ["", ".", ".."].includes(part)) ||
|
|
72
|
+
/[\\\u0000-\u001f\u007f]/.test(path))
|
|
73
|
+
throw new RunContractError("absolute path");
|
|
74
|
+
return path;
|
|
75
|
+
}
|
|
76
|
+
export function runArgv(value) {
|
|
77
|
+
const args = runArray(value, (item) => (typeof item === "string" && item.length === 0 ? "" : runText(item, "argv", 16384)), 128);
|
|
78
|
+
runAbsolutePath(args[0]);
|
|
79
|
+
return args;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=run-parsing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-parsing.js","sourceRoot":"","sources":["../src/run-parsing.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAC1C,YAAY,KAAa,EAAE;QAC1B,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IAAA,CAC/B;CACD;AAED,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,IAAuB,EAA2B;IAC3F,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC9G,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI;QAC7F,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,WAAW,GAAG,MAAM,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;IAC5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C,CAAC,CAAC,CAAC;IACzB,OAAO,IAAI,CAAC;AAAA,CACZ","sourcesContent":["export class RunContractError extends Error {\n\tconstructor(field: string) {\n\t\tsuper(`Invalid verified-run field: ${field}`);\n\t\tthis.name = \"RunContractError\";\n\t}\n}\n\nexport function runObject(value: unknown, keys: readonly string[]): Record<string, unknown> {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new RunContractError(\"object\");\n\tif (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)\n\t\tthrow new RunContractError(\"prototype\");\n\tconst descriptors = Object.getOwnPropertyDescriptors(value);\n\tif (Reflect.ownKeys(value).length !== keys.length) throw new RunContractError(\"fields\");\n\tconst result: Record<string, unknown> = {};\n\tfor (const key of keys) {\n\t\tconst descriptor = descriptors[key];\n\t\tif (!descriptor || !(\"value\" in descriptor) || !descriptor.enumerable) throw new RunContractError(key);\n\t\tresult[key] = descriptor.value;\n\t}\n\treturn result;\n}\nexport function runText(value: unknown, field: string, max = 4096): string {\n\tif (typeof value !== \"string\" || value.length === 0 || value.length > max || /[\\u0000\\ud800-\\udfff]/u.test(value))\n\t\tthrow new RunContractError(field);\n\treturn value;\n}\nexport function runId(value: unknown): string {\n\tconst id = runText(value, \"id\", 128);\n\tif (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(id)) throw new RunContractError(\"id\");\n\treturn id;\n}\nexport function runDigest(value: unknown): string {\n\tif (typeof value !== \"string\" || !/^[a-f0-9]{64}$/.test(value)) throw new RunContractError(\"digest\");\n\treturn value;\n}\nexport function runLimit(value: unknown, field: string, max = 2147483647): number {\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value) || value <= 0 || value > max)\n\t\tthrow new RunContractError(field);\n\treturn value;\n}\nexport function runArray<T>(value: unknown, parse: (item: unknown) => T, max: number): readonly T[] {\n\tif (!Array.isArray(value) || value.length === 0 || value.length > max) throw new RunContractError(\"array\");\n\tconst items: T[] = [];\n\tfor (let index = 0; index < value.length; index++) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(value, String(index));\n\t\tif (!descriptor || !(\"value\" in descriptor)) throw new RunContractError(\"array item\");\n\t\titems.push(parse(descriptor.value));\n\t}\n\treturn Object.freeze(items);\n}\nexport function runRelativePath(value: unknown): string {\n\tconst path = runText(value, \"path\", 1024);\n\tif (\n\t\t/[\\\\\\u0000-\\u001f\\u007f]/.test(path) ||\n\t\tpath.split(\"/\").some((part) => [\"\", \".\", \"..\", \".git\", \".omk\"].includes(part))\n\t)\n\t\tthrow new RunContractError(\"path\");\n\treturn path;\n}\nexport function runAbsolutePath(value: unknown): string {\n\tconst path = runText(value, \"absolute path\", 4096);\n\tif (\n\t\t!path.startsWith(\"/\") ||\n\t\tpath === \"/\" ||\n\t\tpath\n\t\t\t.slice(1)\n\t\t\t.split(\"/\")\n\t\t\t.some((part) => [\"\", \".\", \"..\"].includes(part)) ||\n\t\t/[\\\\\\u0000-\\u001f\\u007f]/.test(path)\n\t)\n\t\tthrow new RunContractError(\"absolute path\");\n\treturn path;\n}\nexport function runArgv(value: unknown): readonly string[] {\n\tconst args = runArray(\n\t\tvalue,\n\t\t(item) => (typeof item === \"string\" && item.length === 0 ? \"\" : runText(item, \"argv\", 16384)),\n\t\t128,\n\t);\n\trunAbsolutePath(args[0]);\n\treturn args;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VERIFIED_COMMAND_VERSION } from "./run-contract.ts";
|
|
2
|
+
export declare const MAX_VERIFIED_RUN_GENERATIONS = 3;
|
|
3
|
+
/** Explicit execution intent; the host authenticates approval separately from this JSON. */
|
|
4
|
+
export interface RunResumeCommand {
|
|
5
|
+
readonly schemaVersion: typeof VERIFIED_COMMAND_VERSION;
|
|
6
|
+
readonly kind: "resume";
|
|
7
|
+
readonly runId: string;
|
|
8
|
+
readonly commandId: string;
|
|
9
|
+
readonly expectedRevision: number;
|
|
10
|
+
readonly expectedGeneration: number;
|
|
11
|
+
readonly contractDigest: string;
|
|
12
|
+
readonly candidateDigest: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseRunResumeCommand(value: unknown): RunResumeCommand;
|
|
15
|
+
//# sourceMappingURL=run-resume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-resume.d.ts","sourceRoot":"","sources":["../src/run-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C,4FAA4F;AAC5F,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,aAAa,EAAE,OAAO,wBAAwB,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CACjC;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAuBtE","sourcesContent":["import { VERIFIED_COMMAND_VERSION } from \"./run-contract.ts\";\nimport { RunContractError, runDigest, runId, runLimit, runObject } from \"./run-parsing.ts\";\n\nexport const MAX_VERIFIED_RUN_GENERATIONS = 3;\n\n/** Explicit execution intent; the host authenticates approval separately from this JSON. */\nexport interface RunResumeCommand {\n\treadonly schemaVersion: typeof VERIFIED_COMMAND_VERSION;\n\treadonly kind: \"resume\";\n\treadonly runId: string;\n\treadonly commandId: string;\n\treadonly expectedRevision: number;\n\treadonly expectedGeneration: number;\n\treadonly contractDigest: string;\n\treadonly candidateDigest: string;\n}\n\nexport function parseRunResumeCommand(value: unknown): RunResumeCommand {\n\tconst input = runObject(value, [\n\t\t\"schemaVersion\",\n\t\t\"kind\",\n\t\t\"runId\",\n\t\t\"commandId\",\n\t\t\"expectedRevision\",\n\t\t\"expectedGeneration\",\n\t\t\"contractDigest\",\n\t\t\"candidateDigest\",\n\t]);\n\tif (input.schemaVersion !== VERIFIED_COMMAND_VERSION || input.kind !== \"resume\")\n\t\tthrow new RunContractError(\"resume version/kind\");\n\treturn Object.freeze({\n\t\tschemaVersion: VERIFIED_COMMAND_VERSION,\n\t\tkind: \"resume\",\n\t\trunId: runId(input.runId),\n\t\tcommandId: runId(input.commandId),\n\t\texpectedRevision: runLimit(input.expectedRevision, \"expectedRevision\", Number.MAX_SAFE_INTEGER),\n\t\texpectedGeneration: runLimit(input.expectedGeneration, \"expectedGeneration\", Number.MAX_SAFE_INTEGER),\n\t\tcontractDigest: runDigest(input.contractDigest),\n\t\tcandidateDigest: runDigest(input.candidateDigest),\n\t});\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { VERIFIED_COMMAND_VERSION } from "./run-contract.js";
|
|
2
|
+
import { RunContractError, runDigest, runId, runLimit, runObject } from "./run-parsing.js";
|
|
3
|
+
export const MAX_VERIFIED_RUN_GENERATIONS = 3;
|
|
4
|
+
export function parseRunResumeCommand(value) {
|
|
5
|
+
const input = runObject(value, [
|
|
6
|
+
"schemaVersion",
|
|
7
|
+
"kind",
|
|
8
|
+
"runId",
|
|
9
|
+
"commandId",
|
|
10
|
+
"expectedRevision",
|
|
11
|
+
"expectedGeneration",
|
|
12
|
+
"contractDigest",
|
|
13
|
+
"candidateDigest",
|
|
14
|
+
]);
|
|
15
|
+
if (input.schemaVersion !== VERIFIED_COMMAND_VERSION || input.kind !== "resume")
|
|
16
|
+
throw new RunContractError("resume version/kind");
|
|
17
|
+
return Object.freeze({
|
|
18
|
+
schemaVersion: VERIFIED_COMMAND_VERSION,
|
|
19
|
+
kind: "resume",
|
|
20
|
+
runId: runId(input.runId),
|
|
21
|
+
commandId: runId(input.commandId),
|
|
22
|
+
expectedRevision: runLimit(input.expectedRevision, "expectedRevision", Number.MAX_SAFE_INTEGER),
|
|
23
|
+
expectedGeneration: runLimit(input.expectedGeneration, "expectedGeneration", Number.MAX_SAFE_INTEGER),
|
|
24
|
+
contractDigest: runDigest(input.contractDigest),
|
|
25
|
+
candidateDigest: runDigest(input.candidateDigest),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=run-resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-resume.js","sourceRoot":"","sources":["../src/run-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE3F,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAc9C,MAAM,UAAU,qBAAqB,CAAC,KAAc,EAAoB;IACvE,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE;QAC9B,eAAe;QACf,MAAM;QACN,OAAO;QACP,WAAW;QACX,kBAAkB;QAClB,oBAAoB;QACpB,gBAAgB;QAChB,iBAAiB;KACjB,CAAC,CAAC;IACH,IAAI,KAAK,CAAC,aAAa,KAAK,wBAAwB,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9E,MAAM,IAAI,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC;QACpB,aAAa,EAAE,wBAAwB;QACvC,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QACzB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC;QACjC,gBAAgB,EAAE,QAAQ,CAAC,KAAK,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,CAAC;QAC/F,kBAAkB,EAAE,QAAQ,CAAC,KAAK,CAAC,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,CAAC,gBAAgB,CAAC;QACrG,cAAc,EAAE,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC;QAC/C,eAAe,EAAE,SAAS,CAAC,KAAK,CAAC,eAAe,CAAC;KACjD,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { VERIFIED_COMMAND_VERSION } from \"./run-contract.ts\";\nimport { RunContractError, runDigest, runId, runLimit, runObject } from \"./run-parsing.ts\";\n\nexport const MAX_VERIFIED_RUN_GENERATIONS = 3;\n\n/** Explicit execution intent; the host authenticates approval separately from this JSON. */\nexport interface RunResumeCommand {\n\treadonly schemaVersion: typeof VERIFIED_COMMAND_VERSION;\n\treadonly kind: \"resume\";\n\treadonly runId: string;\n\treadonly commandId: string;\n\treadonly expectedRevision: number;\n\treadonly expectedGeneration: number;\n\treadonly contractDigest: string;\n\treadonly candidateDigest: string;\n}\n\nexport function parseRunResumeCommand(value: unknown): RunResumeCommand {\n\tconst input = runObject(value, [\n\t\t\"schemaVersion\",\n\t\t\"kind\",\n\t\t\"runId\",\n\t\t\"commandId\",\n\t\t\"expectedRevision\",\n\t\t\"expectedGeneration\",\n\t\t\"contractDigest\",\n\t\t\"candidateDigest\",\n\t]);\n\tif (input.schemaVersion !== VERIFIED_COMMAND_VERSION || input.kind !== \"resume\")\n\t\tthrow new RunContractError(\"resume version/kind\");\n\treturn Object.freeze({\n\t\tschemaVersion: VERIFIED_COMMAND_VERSION,\n\t\tkind: \"resume\",\n\t\trunId: runId(input.runId),\n\t\tcommandId: runId(input.commandId),\n\t\texpectedRevision: runLimit(input.expectedRevision, \"expectedRevision\", Number.MAX_SAFE_INTEGER),\n\t\texpectedGeneration: runLimit(input.expectedGeneration, \"expectedGeneration\", Number.MAX_SAFE_INTEGER),\n\t\tcontractDigest: runDigest(input.contractDigest),\n\t\tcandidateDigest: runDigest(input.candidateDigest),\n\t});\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type RunWriterRestartCommand } from "./run-writer-restart.ts";
|
|
2
|
+
/** Select failed/interrupted task attempts; an empty selection only continues pending work. */
|
|
3
|
+
export interface RunTaskRetryCommand extends Omit<RunWriterRestartCommand, "kind"> {
|
|
4
|
+
readonly kind: "retry_tasks";
|
|
5
|
+
readonly taskIds: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function parseRunTaskRetryCommand(value: unknown): RunTaskRetryCommand;
|
|
8
|
+
//# sourceMappingURL=run-task-retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-task-retry.d.ts","sourceRoot":"","sources":["../src/run-task-retry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAErG,+FAA+F;AAC/F,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACjF,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AACD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAmB5E","sourcesContent":["import { MAX_RUN_DAG_TASKS } from \"./run-dag.ts\";\nimport { RunContractError, runArray, runId, runObject } from \"./run-parsing.ts\";\nimport { parseRunWriterRestartCommand, type RunWriterRestartCommand } from \"./run-writer-restart.ts\";\n\n/** Select failed/interrupted task attempts; an empty selection only continues pending work. */\nexport interface RunTaskRetryCommand extends Omit<RunWriterRestartCommand, \"kind\"> {\n\treadonly kind: \"retry_tasks\";\n\treadonly taskIds: readonly string[];\n}\nexport function parseRunTaskRetryCommand(value: unknown): RunTaskRetryCommand {\n\tconst input = runObject(value, [\n\t\t\"schemaVersion\",\n\t\t\"kind\",\n\t\t\"runId\",\n\t\t\"commandId\",\n\t\t\"expectedRevision\",\n\t\t\"expectedGeneration\",\n\t\t\"contractDigest\",\n\t\t\"baseDigest\",\n\t\t\"taskIds\",\n\t]);\n\tif (input.kind !== \"retry_tasks\") throw new RunContractError(\"task retry kind\");\n\tconst { taskIds: rawIds, ...fields } = input;\n\tconst taskIds =\n\t\tArray.isArray(rawIds) && rawIds.length === 0 ? Object.freeze([]) : runArray(rawIds, runId, MAX_RUN_DAG_TASKS);\n\tif (new Set(taskIds).size !== taskIds.length) throw new RunContractError(\"duplicate task\");\n\tconst base = parseRunWriterRestartCommand({ ...fields, kind: \"restart_writer\" });\n\treturn Object.freeze({ ...base, kind: \"retry_tasks\", taskIds });\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MAX_RUN_DAG_TASKS } from "./run-dag.js";
|
|
2
|
+
import { RunContractError, runArray, runId, runObject } from "./run-parsing.js";
|
|
3
|
+
import { parseRunWriterRestartCommand } from "./run-writer-restart.js";
|
|
4
|
+
export function parseRunTaskRetryCommand(value) {
|
|
5
|
+
const input = runObject(value, [
|
|
6
|
+
"schemaVersion",
|
|
7
|
+
"kind",
|
|
8
|
+
"runId",
|
|
9
|
+
"commandId",
|
|
10
|
+
"expectedRevision",
|
|
11
|
+
"expectedGeneration",
|
|
12
|
+
"contractDigest",
|
|
13
|
+
"baseDigest",
|
|
14
|
+
"taskIds",
|
|
15
|
+
]);
|
|
16
|
+
if (input.kind !== "retry_tasks")
|
|
17
|
+
throw new RunContractError("task retry kind");
|
|
18
|
+
const { taskIds: rawIds, ...fields } = input;
|
|
19
|
+
const taskIds = Array.isArray(rawIds) && rawIds.length === 0 ? Object.freeze([]) : runArray(rawIds, runId, MAX_RUN_DAG_TASKS);
|
|
20
|
+
if (new Set(taskIds).size !== taskIds.length)
|
|
21
|
+
throw new RunContractError("duplicate task");
|
|
22
|
+
const base = parseRunWriterRestartCommand({ ...fields, kind: "restart_writer" });
|
|
23
|
+
return Object.freeze({ ...base, kind: "retry_tasks", taskIds });
|
|
24
|
+
}
|
|
25
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GAAG,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;AAAA,CAChE","sourcesContent":["import { MAX_RUN_DAG_TASKS } from \"./run-dag.ts\";\nimport { RunContractError, runArray, runId, runObject } from \"./run-parsing.ts\";\nimport { parseRunWriterRestartCommand, type RunWriterRestartCommand } from \"./run-writer-restart.ts\";\n\n/** Select failed/interrupted task attempts; an empty selection only continues pending work. */\nexport interface RunTaskRetryCommand extends Omit<RunWriterRestartCommand, \"kind\"> {\n\treadonly kind: \"retry_tasks\";\n\treadonly taskIds: readonly string[];\n}\nexport function parseRunTaskRetryCommand(value: unknown): RunTaskRetryCommand {\n\tconst input = runObject(value, [\n\t\t\"schemaVersion\",\n\t\t\"kind\",\n\t\t\"runId\",\n\t\t\"commandId\",\n\t\t\"expectedRevision\",\n\t\t\"expectedGeneration\",\n\t\t\"contractDigest\",\n\t\t\"baseDigest\",\n\t\t\"taskIds\",\n\t]);\n\tif (input.kind !== \"retry_tasks\") throw new RunContractError(\"task retry kind\");\n\tconst { taskIds: rawIds, ...fields } = input;\n\tconst taskIds =\n\t\tArray.isArray(rawIds) && rawIds.length === 0 ? Object.freeze([]) : runArray(rawIds, runId, MAX_RUN_DAG_TASKS);\n\tif (new Set(taskIds).size !== taskIds.length) throw new RunContractError(\"duplicate task\");\n\tconst base = parseRunWriterRestartCommand({ ...fields, kind: \"restart_writer\" });\n\treturn Object.freeze({ ...base, kind: \"retry_tasks\", taskIds });\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { VERIFIED_COMMAND_VERSION } from "./run-contract.ts";
|
|
2
|
+
/** Restart intent for an isolated writer, bound to its durable input checkpoint, not partial output. */
|
|
3
|
+
export interface RunWriterRestartCommand {
|
|
4
|
+
readonly schemaVersion: typeof VERIFIED_COMMAND_VERSION;
|
|
5
|
+
readonly kind: "restart_writer";
|
|
6
|
+
readonly runId: string;
|
|
7
|
+
readonly commandId: string;
|
|
8
|
+
readonly expectedRevision: number;
|
|
9
|
+
readonly expectedGeneration: number;
|
|
10
|
+
readonly contractDigest: string;
|
|
11
|
+
readonly baseDigest: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseRunWriterRestartCommand(value: unknown): RunWriterRestartCommand;
|
|
14
|
+
//# sourceMappingURL=run-writer-restart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-writer-restart.d.ts","sourceRoot":"","sources":["../src/run-writer-restart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,wGAAwG;AACxG,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,aAAa,EAAE,OAAO,wBAAwB,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAuBpF","sourcesContent":["import { VERIFIED_COMMAND_VERSION } from \"./run-contract.ts\";\nimport { RunContractError, runDigest, runId, runLimit, runObject } from \"./run-parsing.ts\";\n\n/** Restart intent for an isolated writer, bound to its durable input checkpoint, not partial output. */\nexport interface RunWriterRestartCommand {\n\treadonly schemaVersion: typeof VERIFIED_COMMAND_VERSION;\n\treadonly kind: \"restart_writer\";\n\treadonly runId: string;\n\treadonly commandId: string;\n\treadonly expectedRevision: number;\n\treadonly expectedGeneration: number;\n\treadonly contractDigest: string;\n\treadonly baseDigest: string;\n}\n\nexport function parseRunWriterRestartCommand(value: unknown): RunWriterRestartCommand {\n\tconst input = runObject(value, [\n\t\t\"schemaVersion\",\n\t\t\"kind\",\n\t\t\"runId\",\n\t\t\"commandId\",\n\t\t\"expectedRevision\",\n\t\t\"expectedGeneration\",\n\t\t\"contractDigest\",\n\t\t\"baseDigest\",\n\t]);\n\tif (input.schemaVersion !== VERIFIED_COMMAND_VERSION || input.kind !== \"restart_writer\")\n\t\tthrow new RunContractError(\"writer restart version/kind\");\n\treturn Object.freeze({\n\t\tschemaVersion: VERIFIED_COMMAND_VERSION,\n\t\tkind: \"restart_writer\",\n\t\trunId: runId(input.runId),\n\t\tcommandId: runId(input.commandId),\n\t\texpectedRevision: runLimit(input.expectedRevision, \"expectedRevision\", Number.MAX_SAFE_INTEGER),\n\t\texpectedGeneration: runLimit(input.expectedGeneration, \"expectedGeneration\", Number.MAX_SAFE_INTEGER),\n\t\tcontractDigest: runDigest(input.contractDigest),\n\t\tbaseDigest: runDigest(input.baseDigest),\n\t});\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { VERIFIED_COMMAND_VERSION } from "./run-contract.js";
|
|
2
|
+
import { RunContractError, runDigest, runId, runLimit, runObject } from "./run-parsing.js";
|
|
3
|
+
export function parseRunWriterRestartCommand(value) {
|
|
4
|
+
const input = runObject(value, [
|
|
5
|
+
"schemaVersion",
|
|
6
|
+
"kind",
|
|
7
|
+
"runId",
|
|
8
|
+
"commandId",
|
|
9
|
+
"expectedRevision",
|
|
10
|
+
"expectedGeneration",
|
|
11
|
+
"contractDigest",
|
|
12
|
+
"baseDigest",
|
|
13
|
+
]);
|
|
14
|
+
if (input.schemaVersion !== VERIFIED_COMMAND_VERSION || input.kind !== "restart_writer")
|
|
15
|
+
throw new RunContractError("writer restart version/kind");
|
|
16
|
+
return Object.freeze({
|
|
17
|
+
schemaVersion: VERIFIED_COMMAND_VERSION,
|
|
18
|
+
kind: "restart_writer",
|
|
19
|
+
runId: runId(input.runId),
|
|
20
|
+
commandId: runId(input.commandId),
|
|
21
|
+
expectedRevision: runLimit(input.expectedRevision, "expectedRevision", Number.MAX_SAFE_INTEGER),
|
|
22
|
+
expectedGeneration: runLimit(input.expectedGeneration, "expectedGeneration", Number.MAX_SAFE_INTEGER),
|
|
23
|
+
contractDigest: runDigest(input.contractDigest),
|
|
24
|
+
baseDigest: runDigest(input.baseDigest),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=run-writer-restart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-writer-restart.js","sourceRoot":"","sources":["../src/run-writer-restart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAc3F,MAAM,UAAU,4BAA4B,CAAC,KAAc,EAA2B;IACrF,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE;QAC9B,eAAe;QACf,MAAM;QACN,OAAO;QACP,WAAW;QACX,kBAAkB;QAClB,oBAAoB;QACpB,gBAAgB;QAChB,YAAY;KACZ,CAAC,CAAC;IACH,IAAI,KAAK,CAAC,aAAa,KAAK,wBAAwB,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB;QACtF,MAAM,IAAI,gBAAgB,CAAC,6BAA6B,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC,MAAM,CAAC;QACpB,aAAa,EAAE,wBAAwB;QACvC,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QACzB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC;QACjC,gBAAgB,EAAE,QAAQ,CAAC,KAAK,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,CAAC;QAC/F,kBAAkB,EAAE,QAAQ,CAAC,KAAK,CAAC,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,CAAC,gBAAgB,CAAC;QACrG,cAAc,EAAE,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC;QAC/C,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;KACvC,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { VERIFIED_COMMAND_VERSION } from \"./run-contract.ts\";\nimport { RunContractError, runDigest, runId, runLimit, runObject } from \"./run-parsing.ts\";\n\n/** Restart intent for an isolated writer, bound to its durable input checkpoint, not partial output. */\nexport interface RunWriterRestartCommand {\n\treadonly schemaVersion: typeof VERIFIED_COMMAND_VERSION;\n\treadonly kind: \"restart_writer\";\n\treadonly runId: string;\n\treadonly commandId: string;\n\treadonly expectedRevision: number;\n\treadonly expectedGeneration: number;\n\treadonly contractDigest: string;\n\treadonly baseDigest: string;\n}\n\nexport function parseRunWriterRestartCommand(value: unknown): RunWriterRestartCommand {\n\tconst input = runObject(value, [\n\t\t\"schemaVersion\",\n\t\t\"kind\",\n\t\t\"runId\",\n\t\t\"commandId\",\n\t\t\"expectedRevision\",\n\t\t\"expectedGeneration\",\n\t\t\"contractDigest\",\n\t\t\"baseDigest\",\n\t]);\n\tif (input.schemaVersion !== VERIFIED_COMMAND_VERSION || input.kind !== \"restart_writer\")\n\t\tthrow new RunContractError(\"writer restart version/kind\");\n\treturn Object.freeze({\n\t\tschemaVersion: VERIFIED_COMMAND_VERSION,\n\t\tkind: \"restart_writer\",\n\t\trunId: runId(input.runId),\n\t\tcommandId: runId(input.commandId),\n\t\texpectedRevision: runLimit(input.expectedRevision, \"expectedRevision\", Number.MAX_SAFE_INTEGER),\n\t\texpectedGeneration: runLimit(input.expectedGeneration, \"expectedGeneration\", Number.MAX_SAFE_INTEGER),\n\t\tcontractDigest: runDigest(input.contractDigest),\n\t\tbaseDigest: runDigest(input.baseDigest),\n\t});\n}\n"]}
|