@elaraai/e3-core 0.0.2-beta.4 → 0.0.2-beta.41

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.
Files changed (208) hide show
  1. package/README.md +25 -22
  2. package/dist/src/dataflow/api-compat.d.ts +90 -0
  3. package/dist/src/dataflow/api-compat.d.ts.map +1 -0
  4. package/dist/src/dataflow/api-compat.js +139 -0
  5. package/dist/src/dataflow/api-compat.js.map +1 -0
  6. package/dist/src/dataflow/index.d.ts +18 -0
  7. package/dist/src/dataflow/index.d.ts.map +1 -0
  8. package/dist/src/dataflow/index.js +23 -0
  9. package/dist/src/dataflow/index.js.map +1 -0
  10. package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts +76 -0
  11. package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts.map +1 -0
  12. package/dist/src/dataflow/orchestrator/LocalOrchestrator.js +695 -0
  13. package/dist/src/dataflow/orchestrator/LocalOrchestrator.js.map +1 -0
  14. package/dist/src/dataflow/orchestrator/index.d.ts +12 -0
  15. package/dist/src/dataflow/orchestrator/index.d.ts.map +1 -0
  16. package/dist/src/dataflow/orchestrator/index.js +12 -0
  17. package/dist/src/dataflow/orchestrator/index.js.map +1 -0
  18. package/dist/src/dataflow/orchestrator/interfaces.d.ts +163 -0
  19. package/dist/src/dataflow/orchestrator/interfaces.d.ts.map +1 -0
  20. package/dist/src/dataflow/orchestrator/interfaces.js +52 -0
  21. package/dist/src/dataflow/orchestrator/interfaces.js.map +1 -0
  22. package/dist/src/dataflow/state-store/FileStateStore.d.ts +67 -0
  23. package/dist/src/dataflow/state-store/FileStateStore.d.ts.map +1 -0
  24. package/dist/src/dataflow/state-store/FileStateStore.js +300 -0
  25. package/dist/src/dataflow/state-store/FileStateStore.js.map +1 -0
  26. package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts +42 -0
  27. package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts.map +1 -0
  28. package/dist/src/dataflow/state-store/InMemoryStateStore.js +229 -0
  29. package/dist/src/dataflow/state-store/InMemoryStateStore.js.map +1 -0
  30. package/dist/src/dataflow/state-store/index.d.ts +13 -0
  31. package/dist/src/dataflow/state-store/index.d.ts.map +1 -0
  32. package/dist/src/dataflow/state-store/index.js +13 -0
  33. package/dist/src/dataflow/state-store/index.js.map +1 -0
  34. package/dist/src/dataflow/state-store/interfaces.d.ts +159 -0
  35. package/dist/src/dataflow/state-store/interfaces.d.ts.map +1 -0
  36. package/dist/src/dataflow/state-store/interfaces.js +6 -0
  37. package/dist/src/dataflow/state-store/interfaces.js.map +1 -0
  38. package/dist/src/dataflow/steps.d.ts +222 -0
  39. package/dist/src/dataflow/steps.d.ts.map +1 -0
  40. package/dist/src/dataflow/steps.js +707 -0
  41. package/dist/src/dataflow/steps.js.map +1 -0
  42. package/dist/src/dataflow/types.d.ts +127 -0
  43. package/dist/src/dataflow/types.d.ts.map +1 -0
  44. package/dist/src/dataflow/types.js +7 -0
  45. package/dist/src/dataflow/types.js.map +1 -0
  46. package/dist/src/dataflow.d.ts +113 -38
  47. package/dist/src/dataflow.d.ts.map +1 -1
  48. package/dist/src/dataflow.js +269 -416
  49. package/dist/src/dataflow.js.map +1 -1
  50. package/dist/src/dataset-refs.d.ts +124 -0
  51. package/dist/src/dataset-refs.d.ts.map +1 -0
  52. package/dist/src/dataset-refs.js +319 -0
  53. package/dist/src/dataset-refs.js.map +1 -0
  54. package/dist/src/errors.d.ts +39 -9
  55. package/dist/src/errors.d.ts.map +1 -1
  56. package/dist/src/errors.js +51 -8
  57. package/dist/src/errors.js.map +1 -1
  58. package/dist/src/execution/LocalTaskRunner.d.ts +73 -0
  59. package/dist/src/execution/LocalTaskRunner.d.ts.map +1 -0
  60. package/dist/src/execution/LocalTaskRunner.js +399 -0
  61. package/dist/src/execution/LocalTaskRunner.js.map +1 -0
  62. package/dist/src/execution/MockTaskRunner.d.ts +49 -0
  63. package/dist/src/execution/MockTaskRunner.d.ts.map +1 -0
  64. package/dist/src/execution/MockTaskRunner.js +54 -0
  65. package/dist/src/execution/MockTaskRunner.js.map +1 -0
  66. package/dist/src/execution/index.d.ts +16 -0
  67. package/dist/src/execution/index.d.ts.map +1 -0
  68. package/dist/src/execution/index.js +8 -0
  69. package/dist/src/execution/index.js.map +1 -0
  70. package/dist/src/execution/interfaces.d.ts +246 -0
  71. package/dist/src/execution/interfaces.d.ts.map +1 -0
  72. package/dist/src/execution/interfaces.js +6 -0
  73. package/dist/src/execution/interfaces.js.map +1 -0
  74. package/dist/src/execution/processHelpers.d.ts +20 -0
  75. package/dist/src/execution/processHelpers.d.ts.map +1 -0
  76. package/dist/src/execution/processHelpers.js +62 -0
  77. package/dist/src/execution/processHelpers.js.map +1 -0
  78. package/dist/src/executions.d.ts +71 -104
  79. package/dist/src/executions.d.ts.map +1 -1
  80. package/dist/src/executions.js +110 -476
  81. package/dist/src/executions.js.map +1 -1
  82. package/dist/src/index.d.ts +19 -9
  83. package/dist/src/index.d.ts.map +1 -1
  84. package/dist/src/index.js +48 -18
  85. package/dist/src/index.js.map +1 -1
  86. package/dist/src/objects.d.ts +8 -51
  87. package/dist/src/objects.d.ts.map +1 -1
  88. package/dist/src/objects.js +13 -230
  89. package/dist/src/objects.js.map +1 -1
  90. package/dist/src/packages.d.ts +22 -14
  91. package/dist/src/packages.d.ts.map +1 -1
  92. package/dist/src/packages.js +134 -88
  93. package/dist/src/packages.js.map +1 -1
  94. package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts +35 -0
  95. package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts.map +1 -0
  96. package/dist/src/storage/in-memory/InMemoryRepoStore.js +107 -0
  97. package/dist/src/storage/in-memory/InMemoryRepoStore.js.map +1 -0
  98. package/dist/src/storage/in-memory/InMemoryStorage.d.ts +139 -0
  99. package/dist/src/storage/in-memory/InMemoryStorage.d.ts.map +1 -0
  100. package/dist/src/storage/in-memory/InMemoryStorage.js +439 -0
  101. package/dist/src/storage/in-memory/InMemoryStorage.js.map +1 -0
  102. package/dist/src/storage/in-memory/index.d.ts +12 -0
  103. package/dist/src/storage/in-memory/index.d.ts.map +1 -0
  104. package/dist/src/storage/in-memory/index.js +12 -0
  105. package/dist/src/storage/in-memory/index.js.map +1 -0
  106. package/dist/src/storage/index.d.ts +18 -0
  107. package/dist/src/storage/index.d.ts.map +1 -0
  108. package/dist/src/storage/index.js +10 -0
  109. package/dist/src/storage/index.js.map +1 -0
  110. package/dist/src/storage/interfaces.d.ts +581 -0
  111. package/dist/src/storage/interfaces.d.ts.map +1 -0
  112. package/dist/src/storage/interfaces.js +6 -0
  113. package/dist/src/storage/interfaces.js.map +1 -0
  114. package/dist/src/storage/local/LocalBackend.d.ts +56 -0
  115. package/dist/src/storage/local/LocalBackend.d.ts.map +1 -0
  116. package/dist/src/storage/local/LocalBackend.js +145 -0
  117. package/dist/src/storage/local/LocalBackend.js.map +1 -0
  118. package/dist/src/storage/local/LocalDatasetRefStore.d.ts +22 -0
  119. package/dist/src/storage/local/LocalDatasetRefStore.d.ts.map +1 -0
  120. package/dist/src/storage/local/LocalDatasetRefStore.js +118 -0
  121. package/dist/src/storage/local/LocalDatasetRefStore.js.map +1 -0
  122. package/dist/src/storage/local/LocalLockService.d.ts +111 -0
  123. package/dist/src/storage/local/LocalLockService.d.ts.map +1 -0
  124. package/dist/src/storage/local/LocalLockService.js +355 -0
  125. package/dist/src/storage/local/LocalLockService.js.map +1 -0
  126. package/dist/src/storage/local/LocalLogStore.d.ts +23 -0
  127. package/dist/src/storage/local/LocalLogStore.d.ts.map +1 -0
  128. package/dist/src/storage/local/LocalLogStore.js +66 -0
  129. package/dist/src/storage/local/LocalLogStore.js.map +1 -0
  130. package/dist/src/storage/local/LocalObjectStore.d.ts +55 -0
  131. package/dist/src/storage/local/LocalObjectStore.d.ts.map +1 -0
  132. package/dist/src/storage/local/LocalObjectStore.js +300 -0
  133. package/dist/src/storage/local/LocalObjectStore.js.map +1 -0
  134. package/dist/src/storage/local/LocalRefStore.d.ts +50 -0
  135. package/dist/src/storage/local/LocalRefStore.d.ts.map +1 -0
  136. package/dist/src/storage/local/LocalRefStore.js +337 -0
  137. package/dist/src/storage/local/LocalRefStore.js.map +1 -0
  138. package/dist/src/storage/local/LocalRepoStore.d.ts +55 -0
  139. package/dist/src/storage/local/LocalRepoStore.d.ts.map +1 -0
  140. package/dist/src/storage/local/LocalRepoStore.js +365 -0
  141. package/dist/src/storage/local/LocalRepoStore.js.map +1 -0
  142. package/dist/src/storage/local/gc.d.ts +92 -0
  143. package/dist/src/storage/local/gc.d.ts.map +1 -0
  144. package/dist/src/storage/local/gc.js +377 -0
  145. package/dist/src/storage/local/gc.js.map +1 -0
  146. package/dist/src/storage/local/index.d.ts +18 -0
  147. package/dist/src/storage/local/index.d.ts.map +1 -0
  148. package/dist/src/storage/local/index.js +18 -0
  149. package/dist/src/storage/local/index.js.map +1 -0
  150. package/dist/src/storage/local/localHelpers.d.ts +25 -0
  151. package/dist/src/storage/local/localHelpers.d.ts.map +1 -0
  152. package/dist/src/storage/local/localHelpers.js +69 -0
  153. package/dist/src/storage/local/localHelpers.js.map +1 -0
  154. package/dist/src/{repository.d.ts → storage/local/repository.d.ts} +8 -4
  155. package/dist/src/storage/local/repository.d.ts.map +1 -0
  156. package/dist/src/{repository.js → storage/local/repository.js} +31 -29
  157. package/dist/src/storage/local/repository.js.map +1 -0
  158. package/dist/src/tasks.d.ts +16 -10
  159. package/dist/src/tasks.d.ts.map +1 -1
  160. package/dist/src/tasks.js +35 -41
  161. package/dist/src/tasks.js.map +1 -1
  162. package/dist/src/test-helpers.d.ts +5 -4
  163. package/dist/src/test-helpers.d.ts.map +1 -1
  164. package/dist/src/test-helpers.js +9 -21
  165. package/dist/src/test-helpers.js.map +1 -1
  166. package/dist/src/transfer/InMemoryTransferBackend.d.ts +66 -0
  167. package/dist/src/transfer/InMemoryTransferBackend.d.ts.map +1 -0
  168. package/dist/src/transfer/InMemoryTransferBackend.js +166 -0
  169. package/dist/src/transfer/InMemoryTransferBackend.js.map +1 -0
  170. package/dist/src/transfer/index.d.ts +8 -0
  171. package/dist/src/transfer/index.d.ts.map +1 -0
  172. package/dist/src/transfer/index.js +9 -0
  173. package/dist/src/transfer/index.js.map +1 -0
  174. package/dist/src/transfer/interfaces.d.ts +103 -0
  175. package/dist/src/transfer/interfaces.d.ts.map +1 -0
  176. package/dist/src/transfer/interfaces.js +6 -0
  177. package/dist/src/transfer/interfaces.js.map +1 -0
  178. package/dist/src/transfer/types.d.ts +79 -0
  179. package/dist/src/transfer/types.d.ts.map +1 -0
  180. package/dist/src/transfer/types.js +58 -0
  181. package/dist/src/transfer/types.js.map +1 -0
  182. package/dist/src/trees.d.ts +147 -59
  183. package/dist/src/trees.d.ts.map +1 -1
  184. package/dist/src/trees.js +372 -419
  185. package/dist/src/trees.js.map +1 -1
  186. package/dist/src/uuid.d.ts +26 -0
  187. package/dist/src/uuid.d.ts.map +1 -0
  188. package/dist/src/uuid.js +80 -0
  189. package/dist/src/uuid.js.map +1 -0
  190. package/dist/src/workspaceStatus.d.ts +6 -4
  191. package/dist/src/workspaceStatus.d.ts.map +1 -1
  192. package/dist/src/workspaceStatus.js +43 -49
  193. package/dist/src/workspaceStatus.js.map +1 -1
  194. package/dist/src/workspaces.d.ts +35 -47
  195. package/dist/src/workspaces.d.ts.map +1 -1
  196. package/dist/src/workspaces.js +194 -156
  197. package/dist/src/workspaces.js.map +1 -1
  198. package/package.json +4 -4
  199. package/dist/src/gc.d.ts +0 -54
  200. package/dist/src/gc.d.ts.map +0 -1
  201. package/dist/src/gc.js +0 -233
  202. package/dist/src/gc.js.map +0 -1
  203. package/dist/src/repository.d.ts.map +0 -1
  204. package/dist/src/repository.js.map +0 -1
  205. package/dist/src/workspaceLock.d.ts +0 -67
  206. package/dist/src/workspaceLock.d.ts.map +0 -1
  207. package/dist/src/workspaceLock.js +0 -217
  208. package/dist/src/workspaceLock.js.map +0 -1
@@ -15,11 +15,40 @@ export class E3Error extends Error {
15
15
  // =============================================================================
16
16
  // Repository Errors
17
17
  // =============================================================================
18
- export class RepositoryNotFoundError extends E3Error {
19
- path;
20
- constructor(path) {
21
- super(`Repository not found at '${path}'`);
22
- this.path = path;
18
+ /**
19
+ * Thrown when a repository is not found.
20
+ * Used by StorageBackend.validateRepository() and RepoStore operations.
21
+ */
22
+ export class RepoNotFoundError extends E3Error {
23
+ repo;
24
+ constructor(repo) {
25
+ super(`Repository '${repo}' not found`);
26
+ this.repo = repo;
27
+ }
28
+ }
29
+ /**
30
+ * Thrown when attempting to create a repository that already exists.
31
+ */
32
+ export class RepoAlreadyExistsError extends E3Error {
33
+ repo;
34
+ constructor(repo) {
35
+ super(`Repository '${repo}' already exists`);
36
+ this.repo = repo;
37
+ }
38
+ }
39
+ /**
40
+ * Thrown when a repository status doesn't match the expected value.
41
+ * Used for CAS (compare-and-swap) operations.
42
+ */
43
+ export class RepoStatusConflictError extends E3Error {
44
+ repo;
45
+ expected;
46
+ actual;
47
+ constructor(repo, expected, actual) {
48
+ super(`Repository '${repo}' status: expected ${JSON.stringify(expected)}, got '${actual}'`);
49
+ this.repo = repo;
50
+ this.expected = expected;
51
+ this.actual = actual;
23
52
  }
24
53
  }
25
54
  // =============================================================================
@@ -57,9 +86,16 @@ export class WorkspaceLockError extends E3Error {
57
86
  workspace;
58
87
  holder;
59
88
  constructor(workspace, holder) {
60
- const msg = holder
61
- ? `Workspace '${workspace}' is locked by process ${holder.pid} (since ${holder.acquiredAt})`
62
- : `Workspace '${workspace}' is locked by another process`;
89
+ let msg;
90
+ if (!holder) {
91
+ msg = `Workspace '${workspace}' is locked by another process`;
92
+ }
93
+ else if (holder.pid !== undefined) {
94
+ msg = `Workspace '${workspace}' is locked by process ${holder.pid} (since ${holder.acquiredAt})`;
95
+ }
96
+ else {
97
+ msg = `Workspace '${workspace}' is locked (since ${holder.acquiredAt})`;
98
+ }
63
99
  super(msg);
64
100
  this.workspace = workspace;
65
101
  this.holder = holder;
@@ -150,6 +186,13 @@ export class ExecutionCorruptError extends E3Error {
150
186
  this.cause = cause;
151
187
  }
152
188
  }
189
+ export class ExecutionNotFoundError extends E3Error {
190
+ task;
191
+ constructor(task) {
192
+ super(`No execution found for task '${task}'`);
193
+ this.task = task;
194
+ }
195
+ }
153
196
  // =============================================================================
154
197
  // Dataflow Errors
155
198
  // =============================================================================
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,gFAAgF;AAChF,aAAa;AACb,gFAAgF;AAEhF,mCAAmC;AACnC,MAAM,OAAO,OAAQ,SAAQ,KAAK;IAChC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AAED,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF,MAAM,OAAO,uBAAwB,SAAQ,OAAO;IACtB;IAA5B,YAA4B,IAAY;QACtC,KAAK,CAAC,4BAA4B,IAAI,GAAG,CAAC,CAAC;QADjB,SAAI,GAAJ,IAAI,CAAQ;IAExC,CAAC;CACF;AAED,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF,MAAM,OAAO,sBAAuB,SAAQ,OAAO;IACrB;IAA5B,YAA4B,SAAiB;QAC3C,KAAK,CAAC,cAAc,SAAS,kBAAkB,CAAC,CAAC;QADvB,cAAS,GAAT,SAAS,CAAQ;IAE7C,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,OAAO;IACxB;IAA5B,YAA4B,SAAiB;QAC3C,KAAK,CAAC,cAAc,SAAS,2BAA2B,CAAC,CAAC;QADhC,cAAS,GAAT,SAAS,CAAQ;IAE7C,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,OAAO;IACnB;IAA5B,YAA4B,SAAiB;QAC3C,KAAK,CAAC,cAAc,SAAS,kBAAkB,CAAC,CAAC;QAD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AS,CAAC,GAAY,EAAE,OAAe;IACrD,IAAI,GAAG,YAAY,OAAO;QAAE,OAAO,GAAG,CAAC;IACvC,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/D,OAAO,IAAI,OAAO,CAAC,GAAG,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ import type { StorageBackend } from '../storage/interfaces.js';
6
+ import type { TaskRunner, TaskExecuteOptions, TaskResult } from './interfaces.js';
7
+ /**
8
+ * Options for task execution
9
+ */
10
+ export interface ExecuteOptions {
11
+ /** Re-run even if cached (default: false) */
12
+ force?: boolean;
13
+ /** Timeout in milliseconds (default: none) */
14
+ timeout?: number;
15
+ /** AbortSignal for cancellation */
16
+ signal?: AbortSignal;
17
+ /** Stream stdout callback */
18
+ onStdout?: (data: string) => void;
19
+ /** Stream stderr callback */
20
+ onStderr?: (data: string) => void;
21
+ }
22
+ /**
23
+ * Result of task execution
24
+ */
25
+ export interface ExecutionResult {
26
+ /** Combined inputs hash (identifies this execution) */
27
+ inputsHash: string;
28
+ /** Execution ID (UUIDv7) */
29
+ executionId: string;
30
+ /** True if result was from cache */
31
+ cached: boolean;
32
+ /** Final state */
33
+ state: 'success' | 'failed' | 'error';
34
+ /** Output dataset hash (null on failure) */
35
+ outputHash: string | null;
36
+ /** Process exit code (null if not applicable) */
37
+ exitCode: number | null;
38
+ /** Execution time in ms (0 if cached) */
39
+ duration: number;
40
+ /** Error message on failure */
41
+ error: string | null;
42
+ }
43
+ /**
44
+ * TaskRunner implementation for local process execution.
45
+ *
46
+ * Spawns runner processes locally to execute tasks.
47
+ * Used by the local CLI and e3-api-server for task execution.
48
+ */
49
+ export declare class LocalTaskRunner implements TaskRunner {
50
+ private readonly repo;
51
+ constructor(repo: string);
52
+ execute(storage: StorageBackend, taskHash: string, inputHashes: string[], options?: TaskExecuteOptions): Promise<TaskResult>;
53
+ }
54
+ /**
55
+ * Execute a single task.
56
+ *
57
+ * This is the core execution primitive. It:
58
+ * 1. Computes the execution identity from task + inputs
59
+ * 2. Checks cache (unless force=true)
60
+ * 3. Marshals inputs to a scratch directory
61
+ * 4. Evaluates command IR to get exec args
62
+ * 5. Runs the command
63
+ * 6. Stores the output and updates status
64
+ *
65
+ * @param storage - Storage backend
66
+ * @param repo - Repository identifier (for local storage, the path to e3 repository directory)
67
+ * @param taskHash - Hash of the task object
68
+ * @param inputHashes - Array of input dataset hashes
69
+ * @param options - Execution options
70
+ * @returns Execution result
71
+ */
72
+ export declare function taskExecute(storage: StorageBackend, repo: string, taskHash: string, inputHashes: string[], options?: ExecuteOptions): Promise<ExecutionResult>;
73
+ //# sourceMappingURL=LocalTaskRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalTaskRunner.d.ts","sourceRoot":"","sources":["../../../src/execution/LocalTaskRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IACtC,4CAA4C;IAC5C,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,iDAAiD;IACjD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,UAAU;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,MAAM;IAEnC,OAAO,CACX,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,CAAC;CAyBvB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,eAAe,CAAC,CA2N1B"}
@@ -0,0 +1,399 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Local task execution for e3 repositories.
7
+ *
8
+ * This module handles all local process-specific execution:
9
+ * - Creating temporary scratch directories for task I/O
10
+ * - Spawning runner processes (east-node, east-py, julia)
11
+ * - Capturing stdout/stderr and persisting to logs
12
+ * - Process lifecycle management (signals, timeouts, cleanup)
13
+ */
14
+ import * as fs from 'fs/promises';
15
+ import * as path from 'path';
16
+ import { spawn } from 'child_process';
17
+ import { tmpdir } from 'os';
18
+ import { decodeBeast2For, variant } from '@elaraai/east';
19
+ import { TaskObjectType } from '@elaraai/e3-types';
20
+ import { inputsHash, evaluateCommandIr } from '../executions.js';
21
+ import { uuidv7 } from '../uuid.js';
22
+ import { getBootId, getPidStartTime } from './processHelpers.js';
23
+ /**
24
+ * TaskRunner implementation for local process execution.
25
+ *
26
+ * Spawns runner processes locally to execute tasks.
27
+ * Used by the local CLI and e3-api-server for task execution.
28
+ */
29
+ export class LocalTaskRunner {
30
+ repo;
31
+ constructor(repo) {
32
+ this.repo = repo;
33
+ }
34
+ async execute(storage, taskHash, inputHashes, options) {
35
+ const result = await taskExecute(storage, this.repo, taskHash, inputHashes, {
36
+ force: options?.force,
37
+ signal: options?.signal,
38
+ onStdout: options?.onStdout,
39
+ onStderr: options?.onStderr,
40
+ });
41
+ // Convert ExecutionResult to TaskResult
42
+ const taskResult = {
43
+ state: result.state,
44
+ cached: result.cached,
45
+ executionId: result.executionId,
46
+ };
47
+ if (result.state === 'success' && result.outputHash) {
48
+ taskResult.outputHash = result.outputHash;
49
+ }
50
+ else if (result.state === 'failed') {
51
+ taskResult.exitCode = result.exitCode ?? undefined;
52
+ }
53
+ else if (result.state === 'error') {
54
+ taskResult.error = result.error ?? undefined;
55
+ }
56
+ return taskResult;
57
+ }
58
+ }
59
+ /**
60
+ * Execute a single task.
61
+ *
62
+ * This is the core execution primitive. It:
63
+ * 1. Computes the execution identity from task + inputs
64
+ * 2. Checks cache (unless force=true)
65
+ * 3. Marshals inputs to a scratch directory
66
+ * 4. Evaluates command IR to get exec args
67
+ * 5. Runs the command
68
+ * 6. Stores the output and updates status
69
+ *
70
+ * @param storage - Storage backend
71
+ * @param repo - Repository identifier (for local storage, the path to e3 repository directory)
72
+ * @param taskHash - Hash of the task object
73
+ * @param inputHashes - Array of input dataset hashes
74
+ * @param options - Execution options
75
+ * @returns Execution result
76
+ */
77
+ export async function taskExecute(storage, repo, taskHash, inputHashes, options = {}) {
78
+ const inHash = inputsHash(inputHashes);
79
+ const startTime = Date.now();
80
+ // Step 1: Check cache (unless force)
81
+ if (!options.force) {
82
+ const existingOutput = await storage.refs.executionGetLatestOutput(repo, taskHash, inHash);
83
+ if (existingOutput !== null) {
84
+ const status = await storage.refs.executionGetLatest(repo, taskHash, inHash);
85
+ if (status && status.type === 'success') {
86
+ return {
87
+ inputsHash: inHash,
88
+ executionId: status.value.executionId,
89
+ cached: true,
90
+ state: 'success',
91
+ outputHash: existingOutput,
92
+ exitCode: 0,
93
+ duration: 0,
94
+ error: null,
95
+ };
96
+ }
97
+ }
98
+ }
99
+ // Step 2: Generate a new execution ID
100
+ const executionId = uuidv7();
101
+ // Step 3: Read task object
102
+ let task;
103
+ try {
104
+ const taskData = await storage.objects.read(repo, taskHash);
105
+ const decoder = decodeBeast2For(TaskObjectType);
106
+ task = decoder(Buffer.from(taskData));
107
+ }
108
+ catch (err) {
109
+ // Record error with executionId for audit trail
110
+ const status = variant('error', {
111
+ executionId,
112
+ inputHashes,
113
+ startedAt: new Date(startTime),
114
+ completedAt: new Date(),
115
+ message: `Failed to read task object: ${err}`,
116
+ });
117
+ await storage.refs.executionWrite(repo, taskHash, inHash, executionId, status);
118
+ return {
119
+ inputsHash: inHash,
120
+ executionId,
121
+ cached: false,
122
+ state: 'error',
123
+ outputHash: null,
124
+ exitCode: null,
125
+ duration: Date.now() - startTime,
126
+ error: `Failed to read task object: ${err}`,
127
+ };
128
+ }
129
+ // Step 4: Create scratch directory
130
+ // Include PID to prevent collisions when multiple e3 processes run the same
131
+ // task concurrently (e.g., same task in different workspaces at same millisecond)
132
+ const scratchDir = path.join(tmpdir(), `e3-exec-${taskHash.slice(0, 8)}-${inHash.slice(0, 8)}-${process.pid}-${Date.now()}`);
133
+ await fs.mkdir(scratchDir, { recursive: true });
134
+ try {
135
+ // Step 5: Marshal inputs to scratch dir
136
+ const inputPaths = [];
137
+ for (let i = 0; i < inputHashes.length; i++) {
138
+ const inputPath = path.join(scratchDir, `input-${i}.beast2`);
139
+ const inputData = await storage.objects.read(repo, inputHashes[i]);
140
+ await fs.writeFile(inputPath, inputData);
141
+ inputPaths.push(inputPath);
142
+ }
143
+ // Step 6: Evaluate command IR to get exec args
144
+ const outputPath = path.join(scratchDir, 'output.beast2');
145
+ let args;
146
+ try {
147
+ args = await evaluateCommandIr(storage, repo, task.commandIr, inputPaths, outputPath);
148
+ }
149
+ catch (err) {
150
+ const status = variant('error', {
151
+ executionId,
152
+ inputHashes,
153
+ startedAt: new Date(startTime),
154
+ completedAt: new Date(),
155
+ message: `Failed to evaluate command IR: ${err}`,
156
+ });
157
+ await storage.refs.executionWrite(repo, taskHash, inHash, executionId, status);
158
+ return {
159
+ inputsHash: inHash,
160
+ executionId,
161
+ cached: false,
162
+ state: 'error',
163
+ outputHash: null,
164
+ exitCode: null,
165
+ duration: Date.now() - startTime,
166
+ error: `Failed to evaluate command IR: ${err}`,
167
+ };
168
+ }
169
+ if (args.length === 0) {
170
+ const status = variant('error', {
171
+ executionId,
172
+ inputHashes,
173
+ startedAt: new Date(startTime),
174
+ completedAt: new Date(),
175
+ message: 'Command IR produced empty command',
176
+ });
177
+ await storage.refs.executionWrite(repo, taskHash, inHash, executionId, status);
178
+ return {
179
+ inputsHash: inHash,
180
+ executionId,
181
+ cached: false,
182
+ state: 'error',
183
+ outputHash: null,
184
+ exitCode: null,
185
+ duration: Date.now() - startTime,
186
+ error: 'Command IR produced empty command',
187
+ };
188
+ }
189
+ // Step 7: Get boot ID for crash detection
190
+ const bootId = await getBootId();
191
+ // Step 8: Execute command
192
+ const result = await runCommand(storage, repo, taskHash, inHash, executionId, args, inputHashes, bootId, options);
193
+ // Step 9: Handle result
194
+ if (result.exitCode === 0) {
195
+ // Success - read and store output
196
+ try {
197
+ const outputData = await fs.readFile(outputPath);
198
+ const outputHash = await storage.objects.write(repo, outputData);
199
+ // Write success status (output is stored within status.beast2's directory)
200
+ const status = variant('success', {
201
+ executionId,
202
+ inputHashes,
203
+ outputHash,
204
+ startedAt: new Date(startTime),
205
+ completedAt: new Date(),
206
+ });
207
+ await storage.refs.executionWrite(repo, taskHash, inHash, executionId, status);
208
+ return {
209
+ inputsHash: inHash,
210
+ executionId,
211
+ cached: false,
212
+ state: 'success',
213
+ outputHash,
214
+ exitCode: 0,
215
+ duration: Date.now() - startTime,
216
+ error: null,
217
+ };
218
+ }
219
+ catch (err) {
220
+ // Output file missing or unreadable
221
+ const status = variant('error', {
222
+ executionId,
223
+ inputHashes,
224
+ startedAt: new Date(startTime),
225
+ completedAt: new Date(),
226
+ message: `Failed to read output: ${err}`,
227
+ });
228
+ await storage.refs.executionWrite(repo, taskHash, inHash, executionId, status);
229
+ return {
230
+ inputsHash: inHash,
231
+ executionId,
232
+ cached: false,
233
+ state: 'error',
234
+ outputHash: null,
235
+ exitCode: 0,
236
+ duration: Date.now() - startTime,
237
+ error: `Failed to read output: ${err}`,
238
+ };
239
+ }
240
+ }
241
+ else {
242
+ // Failed - write failed status
243
+ const status = variant('failed', {
244
+ executionId,
245
+ inputHashes,
246
+ startedAt: new Date(startTime),
247
+ completedAt: new Date(),
248
+ exitCode: BigInt(result?.exitCode ?? -1),
249
+ });
250
+ await storage.refs.executionWrite(repo, taskHash, inHash, executionId, status);
251
+ return {
252
+ inputsHash: inHash,
253
+ executionId,
254
+ cached: false,
255
+ state: 'failed',
256
+ outputHash: null,
257
+ exitCode: result.exitCode,
258
+ duration: Date.now() - startTime,
259
+ error: result.error,
260
+ };
261
+ }
262
+ }
263
+ finally {
264
+ // Cleanup scratch directory
265
+ try {
266
+ await fs.rm(scratchDir, { recursive: true, force: true });
267
+ }
268
+ catch {
269
+ // Ignore cleanup errors
270
+ }
271
+ }
272
+ }
273
+ /**
274
+ * Run a command and capture output
275
+ */
276
+ async function runCommand(storage, repo, taskHash, inHash, executionId, args, inputHashes, bootId, options) {
277
+ const [cmd, ...cmdArgs] = args;
278
+ // Process Lifecycle Management
279
+ // ============================
280
+ // We use detached: true to create a new process group, allowing us to kill
281
+ // the entire process tree by signaling the negative PID (process group leader).
282
+ //
283
+ // LIMITATION: Process groups are flat, not hierarchical. If a task spawns a
284
+ // subprocess that creates its own process group (via setsid, daemonization,
285
+ // or another detached spawn), that subprocess will escape our kill signal.
286
+ // This is a fundamental Unix limitation - process groups were designed for
287
+ // terminal job control (Ctrl+C/Ctrl+Z), not process tree management.
288
+ //
289
+ // For most tasks (shell scripts, pipelines, normal child processes) this works
290
+ // fine. A task would have to intentionally call setsid() to escape.
291
+ //
292
+ // Potential improvements for hosted e3:
293
+ // - Linux cgroups: Hierarchical containment with no escape. Requires root or
294
+ // systemd integration (systemd-run --scope). Used by Docker/Kubernetes.
295
+ // - PR_SET_CHILD_SUBREAPER: Makes e3 adopt orphaned processes instead of init,
296
+ // allowing tracking and cleanup. Requires polling to detect orphans.
297
+ // - Firecracker/microVMs: Complete isolation with hardware virtualization.
298
+ // The VM boundary provides bulletproof containment. Best for multi-tenant.
299
+ const child = spawn(cmd, cmdArgs, {
300
+ stdio: ['ignore', 'pipe', 'pipe'],
301
+ detached: true,
302
+ });
303
+ // Set up event listeners IMMEDIATELY before any async work
304
+ // to avoid missing events if the process completes quickly
305
+ const resultPromise = new Promise((resolve) => {
306
+ child.on('error', (err) => {
307
+ resolve({ exitCode: null, error: `Failed to spawn: ${err.message}` });
308
+ });
309
+ child.on('close', (code) => {
310
+ resolve({ exitCode: code, error: code !== 0 ? `Exit code: ${code}` : null });
311
+ });
312
+ });
313
+ // Use promise chains to ensure sequential log writes without overlapping
314
+ let stdoutWriteChain = Promise.resolve();
315
+ let stderrWriteChain = Promise.resolve();
316
+ // Tee stdout - use storage.logs.append for log persistence
317
+ child.stdout?.on('data', (data) => {
318
+ const str = data.toString('utf-8');
319
+ // Chain writes sequentially to avoid overlapping
320
+ stdoutWriteChain = stdoutWriteChain.then(async () => {
321
+ try {
322
+ await storage.logs.append(repo, taskHash, inHash, executionId, 'stdout', str);
323
+ }
324
+ catch (err) {
325
+ console.warn(`Failed to append stdout log: ${err instanceof Error ? err.message : String(err)}`);
326
+ }
327
+ });
328
+ if (options.onStdout) {
329
+ options.onStdout(str);
330
+ }
331
+ });
332
+ // Tee stderr - use storage.logs.append for log persistence
333
+ child.stderr?.on('data', (data) => {
334
+ const str = data.toString('utf-8');
335
+ // Chain writes sequentially to avoid overlapping
336
+ stderrWriteChain = stderrWriteChain.then(async () => {
337
+ try {
338
+ await storage.logs.append(repo, taskHash, inHash, executionId, 'stderr', str);
339
+ }
340
+ catch (err) {
341
+ console.warn(`Failed to append stderr log: ${err instanceof Error ? err.message : String(err)}`);
342
+ }
343
+ });
344
+ if (options.onStderr) {
345
+ options.onStderr(str);
346
+ }
347
+ });
348
+ // Helper to kill the entire process group (child and all its descendants).
349
+ // With detached: true, child.pid is the process group leader, so killing
350
+ // -child.pid sends the signal to all processes in that group.
351
+ const killProcessGroup = () => {
352
+ if (child.pid) {
353
+ try {
354
+ process.kill(-child.pid, 'SIGKILL');
355
+ }
356
+ catch {
357
+ // Process may have already exited
358
+ }
359
+ }
360
+ };
361
+ // Handle timeout
362
+ let timeoutId;
363
+ if (options.timeout) {
364
+ timeoutId = setTimeout(killProcessGroup, options.timeout);
365
+ }
366
+ // Handle abort signal
367
+ if (options.signal) {
368
+ if (options.signal.aborted) {
369
+ // Already aborted before we started
370
+ killProcessGroup();
371
+ }
372
+ else {
373
+ options.signal.addEventListener('abort', killProcessGroup, { once: true });
374
+ }
375
+ }
376
+ // Write running status with actual child PID
377
+ const pidStartTime = await getPidStartTime(child.pid);
378
+ const status = variant('running', {
379
+ executionId,
380
+ inputHashes,
381
+ startedAt: new Date(),
382
+ pid: BigInt(child.pid ?? -1),
383
+ pidStartTime: BigInt(pidStartTime ?? -1),
384
+ bootId,
385
+ });
386
+ await storage.refs.executionWrite(repo, taskHash, inHash, executionId, status);
387
+ // Wait for process to complete
388
+ const result = await resultPromise;
389
+ // Wait for any pending log writes to complete
390
+ await Promise.all([stdoutWriteChain, stderrWriteChain]);
391
+ // Cleanup
392
+ if (timeoutId)
393
+ clearTimeout(timeoutId);
394
+ if (options.signal) {
395
+ options.signal.removeEventListener('abort', killProcessGroup);
396
+ }
397
+ return result;
398
+ }
399
+ //# sourceMappingURL=LocalTaskRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalTaskRunner.js","sourceRoot":"","sources":["../../../src/execution/LocalTaskRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAwB,cAAc,EAAmB,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGpC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAwCjE;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAE7C,KAAK,CAAC,OAAO,CACX,OAAuB,EACvB,QAAgB,EAChB,WAAqB,EACrB,OAA4B;QAE5B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE;YAC1E,KAAK,EAAE,OAAO,EAAE,KAAK;YACrB,MAAM,EAAE,OAAO,EAAE,MAAM;YACvB,QAAQ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See LICENSE for details.
4
+ */
5
+ import type { StorageBackend } from '../storage/interfaces.js';
6
+ import type { TaskRunner, TaskExecuteOptions, TaskResult } from './interfaces.js';
7
+ /**
8
+ * Record of a single task execution call.
9
+ */
10
+ export interface MockTaskCall {
11
+ taskHash: string;
12
+ inputHashes: string[];
13
+ options?: TaskExecuteOptions;
14
+ }
15
+ /**
16
+ * TaskRunner mock for testing dataflow orchestration without spawning processes.
17
+ *
18
+ * Allows configuring responses per task and records all calls for assertions.
19
+ */
20
+ export declare class MockTaskRunner implements TaskRunner {
21
+ private results;
22
+ private calls;
23
+ private defaultResult;
24
+ /**
25
+ * Set result for a specific task hash.
26
+ *
27
+ * @param taskHash - The task hash to configure
28
+ * @param result - Either a static TaskResult or a function that computes result from inputHashes
29
+ */
30
+ setResult(taskHash: string, result: TaskResult | ((inputHashes: string[]) => TaskResult | Promise<TaskResult>)): void;
31
+ /**
32
+ * Set default result for tasks without specific results configured.
33
+ *
34
+ * @param result - The default TaskResult to return
35
+ */
36
+ setDefaultResult(result: TaskResult): void;
37
+ /**
38
+ * Get all recorded calls.
39
+ *
40
+ * @returns Readonly array of all execute() calls
41
+ */
42
+ getCalls(): readonly MockTaskCall[];
43
+ /**
44
+ * Clear recorded calls.
45
+ */
46
+ clearCalls(): void;
47
+ execute(_storage: StorageBackend, taskHash: string, inputHashes: string[], options?: TaskExecuteOptions): Promise<TaskResult>;
48
+ }
49
+ //# sourceMappingURL=MockTaskRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockTaskRunner.d.ts","sourceRoot":"","sources":["../../../src/execution/MockTaskRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED;;;;GAIG;AACH,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,OAAO,CAAiG;IAChH,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,aAAa,CAA4E;IAEjG;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI;IAIrH;;;;OAIG;IACH,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAI1C;;;;OAIG;IACH,QAAQ,IAAI,SAAS,YAAY,EAAE;IAInC;;OAEG;IACH,UAAU,IAAI,IAAI;IAIZ,OAAO,CACX,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,CAAC;CASvB"}