@elaraai/e3-types 1.0.79 → 1.0.81
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/README.md +1 -1
- package/dist/src/api.d.ts +829 -36
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/api.js +301 -32
- package/dist/src/api.js.map +1 -1
- package/dist/src/collection-manifest.d.ts +37 -0
- package/dist/src/collection-manifest.d.ts.map +1 -0
- package/dist/src/collection-manifest.js +37 -0
- package/dist/src/collection-manifest.js.map +1 -0
- package/dist/src/dataflow.d.ts +264 -19
- package/dist/src/dataflow.d.ts.map +1 -1
- package/dist/src/dataflow.js +156 -15
- package/dist/src/dataflow.js.map +1 -1
- package/dist/src/dataflow.spec.js +184 -27
- package/dist/src/dataflow.spec.js.map +1 -1
- package/dist/src/dataset-blob.d.ts +75 -15
- package/dist/src/dataset-blob.d.ts.map +1 -1
- package/dist/src/dataset-blob.js +95 -28
- package/dist/src/dataset-blob.js.map +1 -1
- package/dist/src/dataset-blob.spec.d.ts +6 -0
- package/dist/src/dataset-blob.spec.d.ts.map +1 -0
- package/dist/src/dataset-blob.spec.js +92 -0
- package/dist/src/dataset-blob.spec.js.map +1 -0
- package/dist/src/dataset-ref.d.ts +5 -4
- package/dist/src/dataset-ref.d.ts.map +1 -1
- package/dist/src/dataset-ref.js +5 -4
- package/dist/src/dataset-ref.js.map +1 -1
- package/dist/src/environment.d.ts +3 -2
- package/dist/src/environment.d.ts.map +1 -1
- package/dist/src/environment.js +3 -2
- package/dist/src/environment.js.map +1 -1
- package/dist/src/execution.d.ts +112 -18
- package/dist/src/execution.d.ts.map +1 -1
- package/dist/src/execution.js +174 -45
- package/dist/src/execution.js.map +1 -1
- package/dist/src/execution.spec.d.ts +6 -0
- package/dist/src/execution.spec.d.ts.map +1 -0
- package/dist/src/execution.spec.js +108 -0
- package/dist/src/execution.spec.js.map +1 -0
- package/dist/src/function.d.ts +14 -12
- package/dist/src/function.d.ts.map +1 -1
- package/dist/src/function.js +17 -32
- package/dist/src/function.js.map +1 -1
- package/dist/src/index.d.ts +17 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +28 -20
- package/dist/src/index.js.map +1 -1
- package/dist/src/intake.d.ts +75 -0
- package/dist/src/intake.d.ts.map +1 -0
- package/dist/src/intake.js +46 -0
- package/dist/src/intake.js.map +1 -0
- package/dist/src/lock.d.ts +253 -21
- package/dist/src/lock.d.ts.map +1 -1
- package/dist/src/lock.js +55 -21
- package/dist/src/lock.js.map +1 -1
- package/dist/src/names.d.ts +21 -0
- package/dist/src/names.d.ts.map +1 -0
- package/dist/src/names.js +31 -0
- package/dist/src/names.js.map +1 -0
- package/dist/src/package.d.ts +11 -78
- package/dist/src/package.d.ts.map +1 -1
- package/dist/src/package.js +13 -66
- package/dist/src/package.js.map +1 -1
- package/dist/src/record.d.ts +582 -18
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/record.js +405 -7
- package/dist/src/record.js.map +1 -1
- package/dist/src/{stream.spec.d.ts → record.spec.d.ts} +1 -1
- package/dist/src/record.spec.d.ts.map +1 -0
- package/dist/src/record.spec.js +143 -0
- package/dist/src/record.spec.js.map +1 -0
- package/dist/src/release.d.ts +36 -0
- package/dist/src/release.d.ts.map +1 -0
- package/dist/src/release.js +71 -0
- package/dist/src/release.js.map +1 -0
- package/dist/src/release.spec.d.ts +6 -0
- package/dist/src/release.spec.d.ts.map +1 -0
- package/dist/src/release.spec.js +42 -0
- package/dist/src/release.spec.js.map +1 -0
- package/dist/src/repository.d.ts +64 -0
- package/dist/src/repository.d.ts.map +1 -0
- package/dist/src/repository.js +49 -0
- package/dist/src/repository.js.map +1 -0
- package/dist/src/runner.d.ts +16 -62
- package/dist/src/runner.d.ts.map +1 -1
- package/dist/src/runner.js +16 -79
- package/dist/src/runner.js.map +1 -1
- package/dist/src/runner.spec.js +11 -85
- package/dist/src/runner.spec.js.map +1 -1
- package/dist/src/structure.d.ts +0 -57
- package/dist/src/structure.d.ts.map +1 -1
- package/dist/src/structure.js +0 -3
- package/dist/src/structure.js.map +1 -1
- package/dist/src/task.d.ts +210 -318
- package/dist/src/task.d.ts.map +1 -1
- package/dist/src/task.js +117 -472
- package/dist/src/task.js.map +1 -1
- package/dist/src/task.spec.js +62 -154
- package/dist/src/task.spec.js.map +1 -1
- package/dist/src/transfer.d.ts +38 -26
- package/dist/src/transfer.d.ts.map +1 -1
- package/dist/src/transfer.js +22 -26
- package/dist/src/transfer.js.map +1 -1
- package/dist/src/transfer.spec.js +4 -34
- package/dist/src/transfer.spec.js.map +1 -1
- package/dist/src/unit-plan.d.ts +130 -0
- package/dist/src/unit-plan.d.ts.map +1 -0
- package/dist/src/unit-plan.js +107 -0
- package/dist/src/unit-plan.js.map +1 -0
- package/dist/src/unit-plan.spec.d.ts +6 -0
- package/dist/src/unit-plan.spec.d.ts.map +1 -0
- package/dist/src/unit-plan.spec.js +29 -0
- package/dist/src/unit-plan.spec.js.map +1 -0
- package/dist/src/workspace.d.ts +22 -11
- package/dist/src/workspace.d.ts.map +1 -1
- package/dist/src/workspace.js +10 -11
- package/dist/src/workspace.js.map +1 -1
- package/package.json +3 -3
- package/src/api.ts +326 -32
- package/src/collection-manifest.ts +53 -0
- package/src/dataflow.spec.ts +223 -31
- package/src/dataflow.ts +183 -26
- package/src/dataset-blob.spec.ts +117 -0
- package/src/dataset-blob.ts +157 -21
- package/src/dataset-ref.ts +5 -4
- package/src/environment.ts +3 -2
- package/src/execution.spec.ts +114 -0
- package/src/execution.ts +175 -51
- package/src/function.ts +19 -32
- package/src/index.ts +141 -39
- package/src/intake.ts +53 -0
- package/src/lock.ts +67 -21
- package/src/names.ts +39 -0
- package/src/package.ts +15 -71
- package/src/record.spec.ts +195 -0
- package/src/record.ts +489 -7
- package/src/release.spec.ts +47 -0
- package/src/release.ts +69 -0
- package/src/repository.ts +67 -0
- package/src/runner.spec.ts +11 -94
- package/src/runner.ts +16 -80
- package/src/structure.ts +0 -8
- package/src/task.spec.ts +67 -188
- package/src/task.ts +140 -522
- package/src/transfer.spec.ts +4 -51
- package/src/transfer.ts +22 -26
- package/src/unit-plan.spec.ts +31 -0
- package/src/unit-plan.ts +121 -0
- package/src/workspace.ts +13 -11
- package/dist/src/stream.d.ts +0 -97
- package/dist/src/stream.d.ts.map +0 -1
- package/dist/src/stream.js +0 -134
- package/dist/src/stream.js.map +0 -1
- package/dist/src/stream.spec.d.ts.map +0 -1
- package/dist/src/stream.spec.js +0 -60
- package/dist/src/stream.spec.js.map +0 -1
- package/src/stream.spec.ts +0 -88
- package/src/stream.ts +0 -170
package/dist/src/execution.d.ts
CHANGED
|
@@ -6,30 +6,40 @@
|
|
|
6
6
|
* Execution status type definitions.
|
|
7
7
|
*
|
|
8
8
|
* An execution represents a single run of a task with specific inputs.
|
|
9
|
-
*
|
|
9
|
+
* A local repository keeps each attempt at
|
|
10
|
+
* executions/<taskHash>/<inputsHash>/<executionId>/
|
|
10
11
|
*
|
|
11
12
|
* The status file tracks:
|
|
12
13
|
* - For running: process identification for crash detection
|
|
13
|
-
* - For success: output hash and
|
|
14
|
-
* - For failed: exit code and
|
|
14
|
+
* - For success: output hash, timing, peak memory and a split task's last plan
|
|
15
|
+
* - For failed: exit code, timing and peak memory
|
|
15
16
|
* - For error: internal error message and timing
|
|
17
|
+
* - For cancelled and interrupted: how e3, not the task, ended it
|
|
18
|
+
*
|
|
19
|
+
* Every case says whether the execution is a unit of a split task — a piece,
|
|
20
|
+
* or a merge of the pieces' outputs — which is recorded under its task's hash
|
|
21
|
+
* as the task's own executions are, but is not a run of the task.
|
|
16
22
|
*/
|
|
17
|
-
import { VariantType, StructType, ArrayType, StringType, IntegerType, DateTimeType, ValueTypeOf } from '@elaraai/east';
|
|
23
|
+
import { VariantType, StructType, ArrayType, OptionType, StringType, IntegerType, BooleanType, DateTimeType, ValueTypeOf } from '@elaraai/east';
|
|
18
24
|
/**
|
|
19
|
-
* Execution status stored
|
|
20
|
-
*
|
|
21
|
-
* A variant type representing the four possible states of an execution:
|
|
25
|
+
* Execution status, stored locally at
|
|
26
|
+
* executions/<taskHash>/<inputsHash>/<executionId>/status.beast2
|
|
22
27
|
*
|
|
23
28
|
* - `running`: Task has been launched but not yet completed
|
|
24
29
|
* - `success`: Task ran and returned exit code 0
|
|
25
30
|
* - `failed`: Task ran and returned non-zero exit code
|
|
26
31
|
* - `error`: e3 execution engine had an internal error (runner not found, output missing, etc.)
|
|
32
|
+
* - `cancelled`: e3 stopped the execution because the run was aborted, before
|
|
33
|
+
* its runner started or while it ran — not the task's own failure
|
|
34
|
+
* - `interrupted`: the orchestrator that owned the execution exited before it
|
|
35
|
+
* finished, and its runner is gone too, so nothing will write its outcome
|
|
27
36
|
*
|
|
28
37
|
* The `running` state includes process identification fields (pid, pidStartTime, bootId)
|
|
29
38
|
* to enable detection of crashed executions. See design/e3-execution.md for details.
|
|
39
|
+
*
|
|
40
|
+
* Stored state: read it with {@link decodeExecutionStatus}.
|
|
30
41
|
*/
|
|
31
42
|
export declare const ExecutionStatusType: VariantType<{
|
|
32
|
-
/** Task has been launched but not yet completed */
|
|
33
43
|
readonly running: StructType<{
|
|
34
44
|
/** Unique execution ID (UUIDv7) */
|
|
35
45
|
readonly executionId: StringType;
|
|
@@ -43,8 +53,11 @@ export declare const ExecutionStatusType: VariantType<{
|
|
|
43
53
|
readonly pidStartTime: IntegerType;
|
|
44
54
|
/** System boot ID (from /proc/sys/kernel/random/boot_id) */
|
|
45
55
|
readonly bootId: StringType;
|
|
56
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
57
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
58
|
+
* unit of a task whose input closes no piece is */
|
|
59
|
+
readonly unit: BooleanType;
|
|
46
60
|
}>;
|
|
47
|
-
/** Task ran and returned exit code 0 */
|
|
48
61
|
readonly success: StructType<{
|
|
49
62
|
/** Unique execution ID (UUIDv7) */
|
|
50
63
|
readonly executionId: StringType;
|
|
@@ -56,8 +69,19 @@ export declare const ExecutionStatusType: VariantType<{
|
|
|
56
69
|
readonly startedAt: DateTimeType;
|
|
57
70
|
/** When execution completed */
|
|
58
71
|
readonly completedAt: DateTimeType;
|
|
72
|
+
/** The highest peak resident memory, in bytes, a runner process of the
|
|
73
|
+
* execution reached — a split task's, the largest of its units' — when
|
|
74
|
+
* its runners reported one */
|
|
75
|
+
readonly peakBytes: OptionType<IntegerType>;
|
|
76
|
+
/** A split task's: the `$plan` of the last stage it ran, which names the
|
|
77
|
+
* stages before it, and so every unit its output was assembled from;
|
|
78
|
+
* `none` for any other execution */
|
|
79
|
+
readonly plan: OptionType<StringType>;
|
|
80
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
81
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
82
|
+
* unit of a task whose input closes no piece is */
|
|
83
|
+
readonly unit: BooleanType;
|
|
59
84
|
}>;
|
|
60
|
-
/** Task ran and returned non-zero exit code */
|
|
61
85
|
readonly failed: StructType<{
|
|
62
86
|
/** Unique execution ID (UUIDv7) */
|
|
63
87
|
readonly executionId: StringType;
|
|
@@ -69,8 +93,15 @@ export declare const ExecutionStatusType: VariantType<{
|
|
|
69
93
|
readonly completedAt: DateTimeType;
|
|
70
94
|
/** Process exit code */
|
|
71
95
|
readonly exitCode: IntegerType;
|
|
96
|
+
/** The highest peak resident memory, in bytes, a runner process of the
|
|
97
|
+
* execution reached — a split task's, the largest of its units' — when
|
|
98
|
+
* its runners reported one */
|
|
99
|
+
readonly peakBytes: OptionType<IntegerType>;
|
|
100
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
101
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
102
|
+
* unit of a task whose input closes no piece is */
|
|
103
|
+
readonly unit: BooleanType;
|
|
72
104
|
}>;
|
|
73
|
-
/** e3 execution engine had an internal error */
|
|
74
105
|
readonly error: StructType<{
|
|
75
106
|
/** Unique execution ID (UUIDv7) */
|
|
76
107
|
readonly executionId: StringType;
|
|
@@ -82,24 +113,87 @@ export declare const ExecutionStatusType: VariantType<{
|
|
|
82
113
|
readonly completedAt: DateTimeType;
|
|
83
114
|
/** Error message describing what went wrong */
|
|
84
115
|
readonly message: StringType;
|
|
116
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
117
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
118
|
+
* unit of a task whose input closes no piece is */
|
|
119
|
+
readonly unit: BooleanType;
|
|
120
|
+
}>;
|
|
121
|
+
readonly cancelled: StructType<{
|
|
122
|
+
/** Unique execution ID (UUIDv7) */
|
|
123
|
+
readonly executionId: StringType;
|
|
124
|
+
/** Input dataset hashes */
|
|
125
|
+
readonly inputHashes: ArrayType<StringType>;
|
|
126
|
+
/** When execution started */
|
|
127
|
+
readonly startedAt: DateTimeType;
|
|
128
|
+
/** When e3 stopped it */
|
|
129
|
+
readonly completedAt: DateTimeType;
|
|
130
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
131
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
132
|
+
* unit of a task whose input closes no piece is */
|
|
133
|
+
readonly unit: BooleanType;
|
|
134
|
+
}>;
|
|
135
|
+
readonly interrupted: StructType<{
|
|
136
|
+
/** Unique execution ID (UUIDv7) */
|
|
137
|
+
readonly executionId: StringType;
|
|
138
|
+
/** Input dataset hashes */
|
|
139
|
+
readonly inputHashes: ArrayType<StringType>;
|
|
140
|
+
/** When execution started */
|
|
141
|
+
readonly startedAt: DateTimeType;
|
|
142
|
+
/** When the interruption was found */
|
|
143
|
+
readonly completedAt: DateTimeType;
|
|
144
|
+
/** Process ID the runner had */
|
|
145
|
+
readonly pid: IntegerType;
|
|
146
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
147
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
148
|
+
* unit of a task whose input closes no piece is */
|
|
149
|
+
readonly unit: BooleanType;
|
|
85
150
|
}>;
|
|
86
151
|
}>;
|
|
87
152
|
export type ExecutionStatus = ValueTypeOf<typeof ExecutionStatusType>;
|
|
88
153
|
/**
|
|
89
|
-
* The
|
|
154
|
+
* The objects an execution's record keeps from garbage collection: a
|
|
155
|
+
* success's output, and a split task's last `$plan`, which names every stage
|
|
156
|
+
* before it and so the units gc keeps beside the task.
|
|
157
|
+
*
|
|
158
|
+
* @remarks
|
|
159
|
+
* Every backend's scan of execution roots applies it, as gc does to the
|
|
160
|
+
* executions it keeps.
|
|
161
|
+
*
|
|
162
|
+
* @param status - the execution's status
|
|
163
|
+
* @returns the hashes of the objects it keeps
|
|
164
|
+
*/
|
|
165
|
+
export declare function executionStatusRoots(status: ExecutionStatus): string[];
|
|
166
|
+
/**
|
|
167
|
+
* Decode an execution status.
|
|
168
|
+
*
|
|
169
|
+
* @remarks
|
|
170
|
+
* Stored state, so it changes by hard cutover: a repository an older e3 wrote
|
|
171
|
+
* is re-created rather than read, and this says so.
|
|
172
|
+
*
|
|
173
|
+
* @param data - the stored bytes
|
|
174
|
+
* @returns the status
|
|
175
|
+
* @throws {Error} When the bytes are not a current status — one an older e3
|
|
176
|
+
* wrote, whose repository is re-created.
|
|
177
|
+
*/
|
|
178
|
+
export declare function decodeExecutionStatus(data: Uint8Array): ExecutionStatus;
|
|
179
|
+
/**
|
|
180
|
+
* The orchestrator process that launched an execution.
|
|
90
181
|
*
|
|
91
182
|
* @remarks
|
|
92
|
-
* Written beside the execution's `running` status as
|
|
183
|
+
* Written beside the execution's `running` status as its owner record. A
|
|
93
184
|
* `running` record whose runner is gone is repaired only when its owner is
|
|
94
185
|
* gone too: a live owner may be between the runner's exit and the record's
|
|
95
186
|
* write, hashing the output.
|
|
187
|
+
*
|
|
188
|
+
* Stored state: a record of another shape is read as none recorded.
|
|
96
189
|
*/
|
|
97
|
-
export
|
|
190
|
+
export declare const ExecutionOwnerType: StructType<{
|
|
98
191
|
/** Process ID of the orchestrator */
|
|
99
|
-
pid:
|
|
192
|
+
readonly pid: IntegerType;
|
|
100
193
|
/** Orchestrator start time in jiffies since boot (from /proc/<pid>/stat field 22) */
|
|
101
|
-
pidStartTime:
|
|
194
|
+
readonly pidStartTime: IntegerType;
|
|
102
195
|
/** System boot ID (from /proc/sys/kernel/random/boot_id) */
|
|
103
|
-
bootId:
|
|
104
|
-
}
|
|
196
|
+
readonly bootId: StringType;
|
|
197
|
+
}>;
|
|
198
|
+
export type ExecutionOwner = ValueTypeOf<typeof ExecutionOwnerType>;
|
|
105
199
|
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/execution.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/execution.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EAEZ,MAAM,eAAe,CAAC;AAqFvB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB;;QAnG9B,mCAAmC;;QAEnC,2BAA2B;;QAE3B,6BAA6B;;QAE7B,+BAA+B;;QAE/B,gFAAgF;;QAEhF,4DAA4D;;QAE5D;;4DAEoD;;;;QAKpD,mCAAmC;;QAEnC,2BAA2B;;QAE3B,iCAAiC;;QAEjC,6BAA6B;;QAE7B,+BAA+B;;QAE/B;;uCAE+B;;QAE/B;;6CAEqC;;QAErC;;4DAEoD;;;;QAKpD,mCAAmC;;QAEnC,2BAA2B;;QAE3B,6BAA6B;;QAE7B,+BAA+B;;QAE/B,wBAAwB;;QAExB;;uCAE+B;;QAE/B;;4DAEoD;;;;QAKpD,mCAAmC;;QAEnC,2BAA2B;;QAE3B,6BAA6B;;QAE7B,+BAA+B;;QAE/B,+CAA+C;;QAE/C;;4DAEoD;;;;QA4BlD,mCAAmC;;QAEnC,2BAA2B;;QAE3B,6BAA6B;;QAE7B,yBAAyB;;QAEzB;;4DAEoD;;;;QAIpD,mCAAmC;;QAEnC,2BAA2B;;QAE3B,6BAA6B;;QAE7B,sCAAsC;;QAEtC,gCAAgC;;QAEhC;;4DAEoD;;;EAGtD,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,EAAE,CAItE;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,eAAe,CASvE;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB;IAC7B,qCAAqC;;IAErC,qFAAqF;;IAErF,4DAA4D;;EAE5D,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
package/dist/src/execution.js
CHANGED
|
@@ -6,82 +6,211 @@
|
|
|
6
6
|
* Execution status type definitions.
|
|
7
7
|
*
|
|
8
8
|
* An execution represents a single run of a task with specific inputs.
|
|
9
|
-
*
|
|
9
|
+
* A local repository keeps each attempt at
|
|
10
|
+
* executions/<taskHash>/<inputsHash>/<executionId>/
|
|
10
11
|
*
|
|
11
12
|
* The status file tracks:
|
|
12
13
|
* - For running: process identification for crash detection
|
|
13
|
-
* - For success: output hash and
|
|
14
|
-
* - For failed: exit code and
|
|
14
|
+
* - For success: output hash, timing, peak memory and a split task's last plan
|
|
15
|
+
* - For failed: exit code, timing and peak memory
|
|
15
16
|
* - For error: internal error message and timing
|
|
17
|
+
* - For cancelled and interrupted: how e3, not the task, ended it
|
|
18
|
+
*
|
|
19
|
+
* Every case says whether the execution is a unit of a split task — a piece,
|
|
20
|
+
* or a merge of the pieces' outputs — which is recorded under its task's hash
|
|
21
|
+
* as the task's own executions are, but is not a run of the task.
|
|
16
22
|
*/
|
|
17
|
-
import { VariantType, StructType, ArrayType, StringType, IntegerType, DateTimeType, } from '@elaraai/east';
|
|
23
|
+
import { VariantType, StructType, ArrayType, OptionType, StringType, IntegerType, BooleanType, DateTimeType, decodeBeast2For, } from '@elaraai/east';
|
|
24
|
+
/** A running execution's process identification. */
|
|
25
|
+
const RunningStatusType = StructType({
|
|
26
|
+
/** Unique execution ID (UUIDv7) */
|
|
27
|
+
executionId: StringType,
|
|
28
|
+
/** Input dataset hashes */
|
|
29
|
+
inputHashes: ArrayType(StringType),
|
|
30
|
+
/** When execution started */
|
|
31
|
+
startedAt: DateTimeType,
|
|
32
|
+
/** Process ID of the runner */
|
|
33
|
+
pid: IntegerType,
|
|
34
|
+
/** Process start time in jiffies since boot (from /proc/<pid>/stat field 22) */
|
|
35
|
+
pidStartTime: IntegerType,
|
|
36
|
+
/** System boot ID (from /proc/sys/kernel/random/boot_id) */
|
|
37
|
+
bootId: StringType,
|
|
38
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
39
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
40
|
+
* unit of a task whose input closes no piece is */
|
|
41
|
+
unit: BooleanType,
|
|
42
|
+
});
|
|
43
|
+
const SuccessStatusType = StructType({
|
|
44
|
+
/** Unique execution ID (UUIDv7) */
|
|
45
|
+
executionId: StringType,
|
|
46
|
+
/** Input dataset hashes */
|
|
47
|
+
inputHashes: ArrayType(StringType),
|
|
48
|
+
/** Hash of the output dataset */
|
|
49
|
+
outputHash: StringType,
|
|
50
|
+
/** When execution started */
|
|
51
|
+
startedAt: DateTimeType,
|
|
52
|
+
/** When execution completed */
|
|
53
|
+
completedAt: DateTimeType,
|
|
54
|
+
/** The highest peak resident memory, in bytes, a runner process of the
|
|
55
|
+
* execution reached — a split task's, the largest of its units' — when
|
|
56
|
+
* its runners reported one */
|
|
57
|
+
peakBytes: OptionType(IntegerType),
|
|
58
|
+
/** A split task's: the `$plan` of the last stage it ran, which names the
|
|
59
|
+
* stages before it, and so every unit its output was assembled from;
|
|
60
|
+
* `none` for any other execution */
|
|
61
|
+
plan: OptionType(StringType),
|
|
62
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
63
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
64
|
+
* unit of a task whose input closes no piece is */
|
|
65
|
+
unit: BooleanType,
|
|
66
|
+
});
|
|
67
|
+
const FailedStatusType = StructType({
|
|
68
|
+
/** Unique execution ID (UUIDv7) */
|
|
69
|
+
executionId: StringType,
|
|
70
|
+
/** Input dataset hashes */
|
|
71
|
+
inputHashes: ArrayType(StringType),
|
|
72
|
+
/** When execution started */
|
|
73
|
+
startedAt: DateTimeType,
|
|
74
|
+
/** When execution completed */
|
|
75
|
+
completedAt: DateTimeType,
|
|
76
|
+
/** Process exit code */
|
|
77
|
+
exitCode: IntegerType,
|
|
78
|
+
/** The highest peak resident memory, in bytes, a runner process of the
|
|
79
|
+
* execution reached — a split task's, the largest of its units' — when
|
|
80
|
+
* its runners reported one */
|
|
81
|
+
peakBytes: OptionType(IntegerType),
|
|
82
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
83
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
84
|
+
* unit of a task whose input closes no piece is */
|
|
85
|
+
unit: BooleanType,
|
|
86
|
+
});
|
|
87
|
+
const ErrorStatusType = StructType({
|
|
88
|
+
/** Unique execution ID (UUIDv7) */
|
|
89
|
+
executionId: StringType,
|
|
90
|
+
/** Input dataset hashes */
|
|
91
|
+
inputHashes: ArrayType(StringType),
|
|
92
|
+
/** When execution started */
|
|
93
|
+
startedAt: DateTimeType,
|
|
94
|
+
/** When execution completed */
|
|
95
|
+
completedAt: DateTimeType,
|
|
96
|
+
/** Error message describing what went wrong */
|
|
97
|
+
message: StringType,
|
|
98
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
99
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
100
|
+
* unit of a task whose input closes no piece is */
|
|
101
|
+
unit: BooleanType,
|
|
102
|
+
});
|
|
18
103
|
/**
|
|
19
|
-
* Execution status stored
|
|
20
|
-
*
|
|
21
|
-
* A variant type representing the four possible states of an execution:
|
|
104
|
+
* Execution status, stored locally at
|
|
105
|
+
* executions/<taskHash>/<inputsHash>/<executionId>/status.beast2
|
|
22
106
|
*
|
|
23
107
|
* - `running`: Task has been launched but not yet completed
|
|
24
108
|
* - `success`: Task ran and returned exit code 0
|
|
25
109
|
* - `failed`: Task ran and returned non-zero exit code
|
|
26
110
|
* - `error`: e3 execution engine had an internal error (runner not found, output missing, etc.)
|
|
111
|
+
* - `cancelled`: e3 stopped the execution because the run was aborted, before
|
|
112
|
+
* its runner started or while it ran — not the task's own failure
|
|
113
|
+
* - `interrupted`: the orchestrator that owned the execution exited before it
|
|
114
|
+
* finished, and its runner is gone too, so nothing will write its outcome
|
|
27
115
|
*
|
|
28
116
|
* The `running` state includes process identification fields (pid, pidStartTime, bootId)
|
|
29
117
|
* to enable detection of crashed executions. See design/e3-execution.md for details.
|
|
118
|
+
*
|
|
119
|
+
* Stored state: read it with {@link decodeExecutionStatus}.
|
|
30
120
|
*/
|
|
31
121
|
export const ExecutionStatusType = VariantType({
|
|
32
|
-
|
|
33
|
-
|
|
122
|
+
running: RunningStatusType,
|
|
123
|
+
success: SuccessStatusType,
|
|
124
|
+
failed: FailedStatusType,
|
|
125
|
+
error: ErrorStatusType,
|
|
126
|
+
cancelled: StructType({
|
|
34
127
|
/** Unique execution ID (UUIDv7) */
|
|
35
128
|
executionId: StringType,
|
|
36
129
|
/** Input dataset hashes */
|
|
37
130
|
inputHashes: ArrayType(StringType),
|
|
38
131
|
/** When execution started */
|
|
39
132
|
startedAt: DateTimeType,
|
|
40
|
-
/**
|
|
41
|
-
pid: IntegerType,
|
|
42
|
-
/** Process start time in jiffies since boot (from /proc/<pid>/stat field 22) */
|
|
43
|
-
pidStartTime: IntegerType,
|
|
44
|
-
/** System boot ID (from /proc/sys/kernel/random/boot_id) */
|
|
45
|
-
bootId: StringType,
|
|
46
|
-
}),
|
|
47
|
-
/** Task ran and returned exit code 0 */
|
|
48
|
-
success: StructType({
|
|
49
|
-
/** Unique execution ID (UUIDv7) */
|
|
50
|
-
executionId: StringType,
|
|
51
|
-
/** Input dataset hashes */
|
|
52
|
-
inputHashes: ArrayType(StringType),
|
|
53
|
-
/** Hash of the output dataset */
|
|
54
|
-
outputHash: StringType,
|
|
55
|
-
/** When execution started */
|
|
56
|
-
startedAt: DateTimeType,
|
|
57
|
-
/** When execution completed */
|
|
133
|
+
/** When e3 stopped it */
|
|
58
134
|
completedAt: DateTimeType,
|
|
135
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
136
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
137
|
+
* unit of a task whose input closes no piece is */
|
|
138
|
+
unit: BooleanType,
|
|
59
139
|
}),
|
|
60
|
-
|
|
61
|
-
failed: StructType({
|
|
140
|
+
interrupted: StructType({
|
|
62
141
|
/** Unique execution ID (UUIDv7) */
|
|
63
142
|
executionId: StringType,
|
|
64
143
|
/** Input dataset hashes */
|
|
65
144
|
inputHashes: ArrayType(StringType),
|
|
66
145
|
/** When execution started */
|
|
67
146
|
startedAt: DateTimeType,
|
|
68
|
-
/** When
|
|
147
|
+
/** When the interruption was found */
|
|
69
148
|
completedAt: DateTimeType,
|
|
70
|
-
/** Process
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
executionId: StringType,
|
|
77
|
-
/** Input dataset hashes */
|
|
78
|
-
inputHashes: ArrayType(StringType),
|
|
79
|
-
/** When execution started */
|
|
80
|
-
startedAt: DateTimeType,
|
|
81
|
-
/** When execution completed */
|
|
82
|
-
completedAt: DateTimeType,
|
|
83
|
-
/** Error message describing what went wrong */
|
|
84
|
-
message: StringType,
|
|
149
|
+
/** Process ID the runner had */
|
|
150
|
+
pid: IntegerType,
|
|
151
|
+
/** Whether the execution is a unit of a split task — a piece, or a merge of
|
|
152
|
+
* the pieces' outputs — rather than a task's own execution, which the one
|
|
153
|
+
* unit of a task whose input closes no piece is */
|
|
154
|
+
unit: BooleanType,
|
|
85
155
|
}),
|
|
86
156
|
});
|
|
157
|
+
/**
|
|
158
|
+
* The objects an execution's record keeps from garbage collection: a
|
|
159
|
+
* success's output, and a split task's last `$plan`, which names every stage
|
|
160
|
+
* before it and so the units gc keeps beside the task.
|
|
161
|
+
*
|
|
162
|
+
* @remarks
|
|
163
|
+
* Every backend's scan of execution roots applies it, as gc does to the
|
|
164
|
+
* executions it keeps.
|
|
165
|
+
*
|
|
166
|
+
* @param status - the execution's status
|
|
167
|
+
* @returns the hashes of the objects it keeps
|
|
168
|
+
*/
|
|
169
|
+
export function executionStatusRoots(status) {
|
|
170
|
+
if (status.type !== 'success')
|
|
171
|
+
return [];
|
|
172
|
+
const { outputHash, plan } = status.value;
|
|
173
|
+
return plan.type === 'some' ? [outputHash, plan.value] : [outputHash];
|
|
174
|
+
}
|
|
175
|
+
const decodeCurrentStatus = decodeBeast2For(ExecutionStatusType);
|
|
176
|
+
/**
|
|
177
|
+
* Decode an execution status.
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* Stored state, so it changes by hard cutover: a repository an older e3 wrote
|
|
181
|
+
* is re-created rather than read, and this says so.
|
|
182
|
+
*
|
|
183
|
+
* @param data - the stored bytes
|
|
184
|
+
* @returns the status
|
|
185
|
+
* @throws {Error} When the bytes are not a current status — one an older e3
|
|
186
|
+
* wrote, whose repository is re-created.
|
|
187
|
+
*/
|
|
188
|
+
export function decodeExecutionStatus(data) {
|
|
189
|
+
try {
|
|
190
|
+
return decodeCurrentStatus(data);
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
throw new Error(`the execution status does not decode: an older e3 wrote this repository — re-create it: deploy again and import its data again ` +
|
|
194
|
+
`(${err instanceof Error ? err.message : String(err)})`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The orchestrator process that launched an execution.
|
|
199
|
+
*
|
|
200
|
+
* @remarks
|
|
201
|
+
* Written beside the execution's `running` status as its owner record. A
|
|
202
|
+
* `running` record whose runner is gone is repaired only when its owner is
|
|
203
|
+
* gone too: a live owner may be between the runner's exit and the record's
|
|
204
|
+
* write, hashing the output.
|
|
205
|
+
*
|
|
206
|
+
* Stored state: a record of another shape is read as none recorded.
|
|
207
|
+
*/
|
|
208
|
+
export const ExecutionOwnerType = StructType({
|
|
209
|
+
/** Process ID of the orchestrator */
|
|
210
|
+
pid: IntegerType,
|
|
211
|
+
/** Orchestrator start time in jiffies since boot (from /proc/<pid>/stat field 22) */
|
|
212
|
+
pidStartTime: IntegerType,
|
|
213
|
+
/** System boot ID (from /proc/sys/kernel/random/boot_id) */
|
|
214
|
+
bootId: StringType,
|
|
215
|
+
});
|
|
87
216
|
//# sourceMappingURL=execution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/execution.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/execution.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EAEZ,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,oDAAoD;AACpD,MAAM,iBAAiB,GAAG,UAAU,CAAC;IACnC,mCAAmC;IACnC,WAAW,EAAE,UAAU;IACvB,2BAA2B;IAC3B,WAAW,EAAE,SAAS,CAAC,UAAU,CAAC;IAClC,6BAA6B;IAC7B,SAAS,EAAE,YAAY;IACvB,+BAA+B;IAC/B,GAAG,EAAE,WAAW;IAChB,gFAAgF;IAChF,YAAY,EAAE,WAAW;IACzB,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,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,iIAAiI;YACjI,IAAI,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CACxD,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;IAC3C,qCAAqC;IACrC,GAAG,EAAE,WAAW;IAChB,qFAAqF;IACrF,YAAY,EAAE,WAAW;IACzB,4DAA4D;IAC5D,MAAM,EAAE,UAAU;CACnB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.spec.d.ts","sourceRoot":"","sources":["../../src/execution.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Execution status wire: the typed outcomes with their peaks, a split task's
|
|
7
|
+
* plan and whether the execution is a unit, what each keeps from gc, and the
|
|
8
|
+
* refusal of a record an older e3 wrote before `cancelled` and `interrupted`
|
|
9
|
+
* were cases of it, before a runner's peak was recorded, before a split task's
|
|
10
|
+
* plan was, or before a record said whether it is a unit.
|
|
11
|
+
*/
|
|
12
|
+
import { describe, it } from 'node:test';
|
|
13
|
+
import assert from 'node:assert/strict';
|
|
14
|
+
import { ArrayType, DateTimeType, IntegerType, OptionType, StringType, StructType, VariantType, encodeBeast2For, none, some, variant } from '@elaraai/east';
|
|
15
|
+
import { ExecutionStatusType, decodeExecutionStatus, executionStatusRoots } from './execution.js';
|
|
16
|
+
/** The four-case wire every record had before the typed outcomes. */
|
|
17
|
+
const PreOutcomeExecutionStatusType = VariantType({
|
|
18
|
+
running: StructType({
|
|
19
|
+
executionId: StringType, inputHashes: ArrayType(StringType), startedAt: DateTimeType,
|
|
20
|
+
pid: IntegerType, pidStartTime: IntegerType, bootId: StringType,
|
|
21
|
+
}),
|
|
22
|
+
success: StructType({
|
|
23
|
+
executionId: StringType, inputHashes: ArrayType(StringType), outputHash: StringType,
|
|
24
|
+
startedAt: DateTimeType, completedAt: DateTimeType,
|
|
25
|
+
}),
|
|
26
|
+
failed: StructType({
|
|
27
|
+
executionId: StringType, inputHashes: ArrayType(StringType), startedAt: DateTimeType,
|
|
28
|
+
completedAt: DateTimeType, exitCode: IntegerType,
|
|
29
|
+
}),
|
|
30
|
+
error: StructType({
|
|
31
|
+
executionId: StringType, inputHashes: ArrayType(StringType), startedAt: DateTimeType,
|
|
32
|
+
completedAt: DateTimeType, message: StringType,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
describe('ExecutionStatusType', () => {
|
|
36
|
+
const stopped = {
|
|
37
|
+
executionId: '0199-a',
|
|
38
|
+
inputHashes: ['a'.repeat(64)],
|
|
39
|
+
startedAt: new Date(1000),
|
|
40
|
+
completedAt: new Date(2000),
|
|
41
|
+
};
|
|
42
|
+
const encodeOlder = encodeBeast2For(PreOutcomeExecutionStatusType);
|
|
43
|
+
it('round-trips the typed outcomes, with a runner\'s peak or without one, a task\'s own or a unit\'s', () => {
|
|
44
|
+
const own = { ...stopped, unit: false };
|
|
45
|
+
const statuses = [
|
|
46
|
+
variant('success', { ...own, outputHash: 'b'.repeat(64), peakBytes: some(96n * 1024n ** 2n), plan: none }),
|
|
47
|
+
variant('success', { ...own, outputHash: 'b'.repeat(64), peakBytes: none, plan: some('c'.repeat(64)) }),
|
|
48
|
+
variant('success', { ...own, outputHash: 'b'.repeat(64), peakBytes: some(64n * 1024n ** 2n), plan: none, unit: true }),
|
|
49
|
+
variant('running', { executionId: '0199-b', inputHashes: ['a'.repeat(64)], startedAt: new Date(1000), pid: 4242n, pidStartTime: 7n, bootId: 'boot', unit: true }),
|
|
50
|
+
variant('failed', { ...own, exitCode: 1n, peakBytes: some(412n * 1024n ** 2n) }),
|
|
51
|
+
variant('failed', { ...own, exitCode: -1n, peakBytes: none }),
|
|
52
|
+
variant('cancelled', own),
|
|
53
|
+
variant('interrupted', { ...own, pid: 4242n }),
|
|
54
|
+
variant('error', { ...own, message: 'Failed to read output: no such file' }),
|
|
55
|
+
];
|
|
56
|
+
const encode = encodeBeast2For(ExecutionStatusType);
|
|
57
|
+
for (const status of statuses)
|
|
58
|
+
assert.deepEqual(decodeExecutionStatus(encode(status)), status);
|
|
59
|
+
});
|
|
60
|
+
it('keeps from gc a success\'s output, and a split task\'s last plan beside it', () => {
|
|
61
|
+
const success = { ...stopped, outputHash: 'b'.repeat(64), peakBytes: none, unit: false };
|
|
62
|
+
assert.deepEqual(executionStatusRoots(variant('success', { ...success, plan: none })), ['b'.repeat(64)]);
|
|
63
|
+
assert.deepEqual(executionStatusRoots(variant('success', { ...success, plan: some('c'.repeat(64)) })), ['b'.repeat(64), 'c'.repeat(64)]);
|
|
64
|
+
assert.deepEqual(executionStatusRoots(variant('failed', { ...stopped, exitCode: 1n, peakBytes: none, unit: false })), []);
|
|
65
|
+
assert.deepEqual(executionStatusRoots(variant('cancelled', { ...stopped, unit: false })), []);
|
|
66
|
+
});
|
|
67
|
+
it('refuses a record an older e3 wrote, naming the fix', () => {
|
|
68
|
+
const refusal = /^Error: the execution status does not decode: an older e3 wrote this repository — re-create it: deploy again and import its data again \(/;
|
|
69
|
+
const records = [
|
|
70
|
+
variant('error', { ...stopped, message: 'cancelled: e3 stopped the runner because the run was aborted' }),
|
|
71
|
+
variant('success', { ...stopped, outputHash: 'b'.repeat(64) }),
|
|
72
|
+
];
|
|
73
|
+
for (const record of records) {
|
|
74
|
+
assert.throws(() => decodeExecutionStatus(encodeOlder(record)), refusal);
|
|
75
|
+
}
|
|
76
|
+
// The typed outcomes, before a runner's peak was recorded.
|
|
77
|
+
const withoutPeaks = VariantType({
|
|
78
|
+
...PreOutcomeExecutionStatusType.cases,
|
|
79
|
+
cancelled: StructType({ executionId: StringType, inputHashes: ArrayType(StringType), startedAt: DateTimeType, completedAt: DateTimeType }),
|
|
80
|
+
interrupted: StructType({
|
|
81
|
+
executionId: StringType, inputHashes: ArrayType(StringType), startedAt: DateTimeType, completedAt: DateTimeType, pid: IntegerType,
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
assert.throws(() => decodeExecutionStatus(encodeBeast2For(withoutPeaks)(variant('success', { ...stopped, outputHash: 'b'.repeat(64) }))), refusal);
|
|
85
|
+
// With peaks, before a split task's plan was recorded.
|
|
86
|
+
const withoutPlans = VariantType({
|
|
87
|
+
...ExecutionStatusType.cases,
|
|
88
|
+
success: StructType({
|
|
89
|
+
executionId: StringType, inputHashes: ArrayType(StringType), outputHash: StringType,
|
|
90
|
+
startedAt: DateTimeType, completedAt: DateTimeType, peakBytes: OptionType(IntegerType),
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
assert.throws(() => decodeExecutionStatus(encodeBeast2For(withoutPlans)(variant('success', { ...stopped, outputHash: 'b'.repeat(64), peakBytes: none }))), refusal);
|
|
94
|
+
// With plans, before a record said whether it is a unit of a split task.
|
|
95
|
+
const withoutUnits = VariantType({
|
|
96
|
+
...ExecutionStatusType.cases,
|
|
97
|
+
success: StructType({
|
|
98
|
+
executionId: StringType, inputHashes: ArrayType(StringType), outputHash: StringType,
|
|
99
|
+
startedAt: DateTimeType, completedAt: DateTimeType, peakBytes: OptionType(IntegerType), plan: OptionType(StringType),
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
assert.throws(() => decodeExecutionStatus(encodeBeast2For(withoutUnits)(variant('success', { ...stopped, outputHash: 'b'.repeat(64), peakBytes: none, plan: none }))), refusal);
|
|
103
|
+
});
|
|
104
|
+
it('throws for bytes of no status shape', () => {
|
|
105
|
+
assert.throws(() => decodeExecutionStatus(encodeBeast2For(IntegerType)(7n)), /the execution status does not decode/);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=execution.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.spec.js","sourceRoot":"","sources":["../../src/execution.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC5J,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,oBAAoB,EAAwB,MAAM,gBAAgB,CAAC;AAExH,qEAAqE;AACrE,MAAM,6BAA6B,GAAG,WAAW,CAAC;IAChD,OAAO,EAAE,UAAU,CAAC;QAClB,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,YAAY;QACpF,GAAG,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU;KAChE,CAAC;IACF,OAAO,EAAE,UAAU,CAAC;QAClB,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,UAAU;QACnF,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY;KACnD,CAAC;IACF,MAAM,EAAE,UAAU,CAAC;QACjB,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,YAAY;QACpF,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW;KACjD,CAAC;IACF,K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