@elaraai/e3-core 0.0.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE.md +50 -0
  2. package/README.md +103 -0
  3. package/dist/src/dataflow.d.ts +136 -0
  4. package/dist/src/dataflow.d.ts.map +1 -0
  5. package/dist/src/dataflow.js +562 -0
  6. package/dist/src/dataflow.js.map +1 -0
  7. package/dist/src/errors.d.ts +125 -0
  8. package/dist/src/errors.d.ts.map +1 -0
  9. package/dist/src/errors.js +211 -0
  10. package/dist/src/errors.js.map +1 -0
  11. package/dist/src/executions.d.ts +176 -0
  12. package/dist/src/executions.d.ts.map +1 -0
  13. package/dist/src/executions.js +585 -0
  14. package/dist/src/executions.js.map +1 -0
  15. package/dist/src/formats.d.ts +38 -0
  16. package/dist/src/formats.d.ts.map +1 -0
  17. package/dist/src/formats.js +115 -0
  18. package/dist/src/formats.js.map +1 -0
  19. package/dist/src/gc.d.ts +54 -0
  20. package/dist/src/gc.d.ts.map +1 -0
  21. package/dist/src/gc.js +233 -0
  22. package/dist/src/gc.js.map +1 -0
  23. package/dist/src/index.d.ts +25 -0
  24. package/dist/src/index.d.ts.map +1 -0
  25. package/dist/src/index.js +72 -0
  26. package/dist/src/index.js.map +1 -0
  27. package/dist/src/objects.d.ts +62 -0
  28. package/dist/src/objects.d.ts.map +1 -0
  29. package/dist/src/objects.js +245 -0
  30. package/dist/src/objects.js.map +1 -0
  31. package/dist/src/packages.d.ts +93 -0
  32. package/dist/src/packages.d.ts.map +1 -0
  33. package/dist/src/packages.js +370 -0
  34. package/dist/src/packages.js.map +1 -0
  35. package/dist/src/repository.d.ts +38 -0
  36. package/dist/src/repository.d.ts.map +1 -0
  37. package/dist/src/repository.js +103 -0
  38. package/dist/src/repository.js.map +1 -0
  39. package/dist/src/tasks.d.ts +63 -0
  40. package/dist/src/tasks.d.ts.map +1 -0
  41. package/dist/src/tasks.js +145 -0
  42. package/dist/src/tasks.js.map +1 -0
  43. package/dist/src/test-helpers.d.ts +44 -0
  44. package/dist/src/test-helpers.d.ts.map +1 -0
  45. package/dist/src/test-helpers.js +141 -0
  46. package/dist/src/test-helpers.js.map +1 -0
  47. package/dist/src/trees.d.ts +178 -0
  48. package/dist/src/trees.d.ts.map +1 -0
  49. package/dist/src/trees.js +636 -0
  50. package/dist/src/trees.js.map +1 -0
  51. package/dist/src/workspaceLock.d.ts +67 -0
  52. package/dist/src/workspaceLock.d.ts.map +1 -0
  53. package/dist/src/workspaceLock.js +217 -0
  54. package/dist/src/workspaceLock.js.map +1 -0
  55. package/dist/src/workspaceStatus.d.ts +126 -0
  56. package/dist/src/workspaceStatus.d.ts.map +1 -0
  57. package/dist/src/workspaceStatus.js +352 -0
  58. package/dist/src/workspaceStatus.js.map +1 -0
  59. package/dist/src/workspaces.d.ts +150 -0
  60. package/dist/src/workspaces.d.ts.map +1 -0
  61. package/dist/src/workspaces.js +390 -0
  62. package/dist/src/workspaces.js.map +1 -0
  63. package/package.json +59 -0
@@ -0,0 +1,636 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Low-level tree and dataset operations for e3 repositories.
7
+ *
8
+ * Trees are persistent data structures with structural sharing (like git trees).
9
+ * Each tree node contains DataRefs pointing to either other trees or dataset values.
10
+ *
11
+ * Tree operations require a Structure parameter which describes the shape of the
12
+ * tree node. This enables proper encoding/decoding with the correct StructType
13
+ * and supports future tree types (array, variant, etc.).
14
+ *
15
+ * Low-level operations work with hashes directly (by-hash).
16
+ * High-level operations traverse paths from a root (by-path).
17
+ */
18
+ import { decodeBeast2, decodeBeast2For, encodeBeast2For, StructType, } from '@elaraai/east';
19
+ import { DataRefType, PackageObjectType, WorkspaceStateType } from '@elaraai/e3-types';
20
+ import { objectRead, objectWrite } from './objects.js';
21
+ import { packageRead } from './packages.js';
22
+ import { WorkspaceNotFoundError, WorkspaceNotDeployedError, isNotFoundError, } from './errors.js';
23
+ import { acquireWorkspaceLock } from './workspaceLock.js';
24
+ import * as fs from 'fs/promises';
25
+ import * as path from 'path';
26
+ /**
27
+ * Build the EastType for a tree object based on its structure.
28
+ *
29
+ * For struct trees, creates a StructType with DataRefType for each field.
30
+ * Future: will handle array, variant, and other tree types.
31
+ *
32
+ * @param structure - The structure describing this tree node
33
+ * @returns The EastType for encoding/decoding the tree object
34
+ */
35
+ function treeTypeFromStructure(structure) {
36
+ if (structure.type === 'struct') {
37
+ const fields = {};
38
+ for (const fieldName of structure.value.keys()) {
39
+ fields[fieldName] = DataRefType;
40
+ }
41
+ return StructType(fields);
42
+ }
43
+ else if (structure.type === 'value') {
44
+ throw new Error('Cannot create tree type for a value structure - this is a dataset, not a tree');
45
+ }
46
+ else {
47
+ throw new Error(`Unsupported structure type: ${structure.type}`);
48
+ }
49
+ }
50
+ /**
51
+ * Read and decode a tree object from the object store.
52
+ *
53
+ * @param repoPath - Path to .e3 repository
54
+ * @param hash - Hash of the tree object
55
+ * @param structure - The structure describing this tree node's shape
56
+ * @returns The decoded tree object (field name -> DataRef)
57
+ * @throws If object not found, structure is not a tree, or decoding fails
58
+ */
59
+ export async function treeRead(repoPath, hash, structure) {
60
+ const treeType = treeTypeFromStructure(structure);
61
+ const data = await objectRead(repoPath, hash);
62
+ const decoder = decodeBeast2For(treeType);
63
+ return decoder(Buffer.from(data));
64
+ }
65
+ /**
66
+ * Encode and write a tree object to the object store.
67
+ *
68
+ * @param repoPath - Path to .e3 repository
69
+ * @param fields - Object mapping field names to DataRefs
70
+ * @param structure - The structure describing this tree node's shape
71
+ * @returns Hash of the written tree object
72
+ * @throws If structure is not a tree or encoding fails
73
+ */
74
+ export async function treeWrite(repoPath, fields, structure) {
75
+ const treeType = treeTypeFromStructure(structure);
76
+ const encoder = encodeBeast2For(treeType);
77
+ const data = encoder(fields);
78
+ return objectWrite(repoPath, data);
79
+ }
80
+ /**
81
+ * Read and decode a dataset value from the object store.
82
+ *
83
+ * The .beast2 format includes type information in the header, so values
84
+ * can be decoded without knowing the schema in advance.
85
+ *
86
+ * @param repoPath - Path to .e3 repository
87
+ * @param hash - Hash of the dataset value
88
+ * @returns The decoded value and its type
89
+ * @throws If object not found or not a valid beast2 object
90
+ */
91
+ export async function datasetRead(repoPath, hash) {
92
+ const data = await objectRead(repoPath, hash);
93
+ const result = decodeBeast2(Buffer.from(data));
94
+ return { type: result.type, value: result.value };
95
+ }
96
+ /**
97
+ * Encode and write a dataset value to the object store.
98
+ *
99
+ * @param repoPath - Path to .e3 repository
100
+ * @param value - The value to encode
101
+ * @param type - The East type for encoding (EastType or EastTypeValue)
102
+ * @returns Hash of the written dataset value
103
+ */
104
+ export async function datasetWrite(repoPath, value, type) {
105
+ // encodeBeast2For accepts both EastType and EastTypeValue, but TypeScript
106
+ // overloads don't support union types directly. Cast to EastTypeValue since
107
+ // that's the more general case and the runtime handles both.
108
+ const encoder = encodeBeast2For(type);
109
+ const data = encoder(value);
110
+ return objectWrite(repoPath, data);
111
+ }
112
+ /**
113
+ * Traverse a tree from root to a path, co-walking structure and data.
114
+ *
115
+ * @param repoPath - Path to .e3 repository
116
+ * @param rootHash - Hash of the root tree object
117
+ * @param rootStructure - Structure of the root tree
118
+ * @param path - Path to traverse
119
+ * @returns The structure and DataRef at the path location
120
+ * @throws If path is invalid or traversal fails
121
+ */
122
+ async function traverse(repoPath, rootHash, rootStructure, path) {
123
+ let currentStructure = rootStructure;
124
+ let currentHash = rootHash;
125
+ for (let i = 0; i < path.length; i++) {
126
+ const segment = path[i];
127
+ if (segment.type !== 'field') {
128
+ throw new Error(`Unsupported path segment type: ${segment.type}`);
129
+ }
130
+ const fieldName = segment.value;
131
+ // Current structure must be a struct tree to descend into
132
+ if (currentStructure.type !== 'struct') {
133
+ const pathSoFar = path.slice(0, i).map(s => s.value).join('.');
134
+ throw new Error(`Cannot descend into non-struct at path '${pathSoFar}'`);
135
+ }
136
+ // Read the current tree object
137
+ const treeObject = await treeRead(repoPath, currentHash, currentStructure);
138
+ // Look up the child ref
139
+ const childRef = treeObject[fieldName];
140
+ if (!childRef) {
141
+ const pathSoFar = path.slice(0, i).map(s => s.value).join('.');
142
+ const available = Object.keys(treeObject).join(', ');
143
+ throw new Error(`Field '${fieldName}' not found at '${pathSoFar}'. Available: ${available}`);
144
+ }
145
+ // Look up the child structure
146
+ const childStructure = currentStructure.value.get(fieldName);
147
+ if (!childStructure) {
148
+ throw new Error(`Field '${fieldName}' not found in structure`);
149
+ }
150
+ // If this is the last segment, return the result
151
+ if (i === path.length - 1) {
152
+ return { structure: childStructure, ref: childRef };
153
+ }
154
+ // Otherwise, continue traversing (must be a tree ref)
155
+ if (childRef.type !== 'tree') {
156
+ const pathSoFar = path.slice(0, i + 1).map(s => s.value).join('.');
157
+ throw new Error(`Expected tree ref at '${pathSoFar}', got '${childRef.type}'`);
158
+ }
159
+ currentStructure = childStructure;
160
+ currentHash = childRef.value;
161
+ }
162
+ // Empty path - return root
163
+ return {
164
+ structure: rootStructure,
165
+ ref: { type: 'tree', value: rootHash },
166
+ };
167
+ }
168
+ /**
169
+ * List field names at a tree path within a package's data tree.
170
+ *
171
+ * @param repoPath - Path to .e3 repository
172
+ * @param name - Package name
173
+ * @param version - Package version
174
+ * @param path - Path to the tree node
175
+ * @returns Array of field names at the path
176
+ * @throws If package not found, path invalid, or path points to a dataset
177
+ */
178
+ export async function packageListTree(repoPath, name, version, path) {
179
+ // Read the package to get root structure and hash
180
+ const pkg = await packageRead(repoPath, name, version);
181
+ const rootStructure = pkg.data.structure;
182
+ const rootHash = pkg.data.value;
183
+ if (path.length === 0) {
184
+ // Empty path - list root tree fields
185
+ if (rootStructure.type !== 'struct') {
186
+ throw new Error('Root is not a tree');
187
+ }
188
+ const treeObject = await treeRead(repoPath, rootHash, rootStructure);
189
+ return Object.keys(treeObject);
190
+ }
191
+ // Traverse to the path
192
+ const { structure, ref } = await traverse(repoPath, rootHash, rootStructure, path);
193
+ // Must be a tree structure
194
+ if (structure.type !== 'struct') {
195
+ const pathStr = path.map(s => s.value).join('.');
196
+ throw new Error(`Path '${pathStr}' points to a dataset, not a tree`);
197
+ }
198
+ // Must be a tree ref
199
+ if (ref.type !== 'tree') {
200
+ const pathStr = path.map(s => s.value).join('.');
201
+ throw new Error(`Path '${pathStr}' has ref type '${ref.type}', expected 'tree'`);
202
+ }
203
+ // Read the tree and return field names
204
+ const treeObject = await treeRead(repoPath, ref.value, structure);
205
+ return Object.keys(treeObject);
206
+ }
207
+ /**
208
+ * Read and decode a dataset value at a path within a package's data tree.
209
+ *
210
+ * @param repoPath - Path to .e3 repository
211
+ * @param name - Package name
212
+ * @param version - Package version
213
+ * @param path - Path to the dataset
214
+ * @returns The decoded dataset value
215
+ * @throws If package not found, path invalid, or path points to a tree
216
+ */
217
+ export async function packageGetDataset(repoPath, name, version, path) {
218
+ // Read the package to get root structure and hash
219
+ const pkg = await packageRead(repoPath, name, version);
220
+ const rootStructure = pkg.data.structure;
221
+ const rootHash = pkg.data.value;
222
+ if (path.length === 0) {
223
+ throw new Error('Cannot get dataset at root path - root is always a tree');
224
+ }
225
+ // Traverse to the path
226
+ const { structure, ref } = await traverse(repoPath, rootHash, rootStructure, path);
227
+ // Must be a value structure
228
+ if (structure.type !== 'value') {
229
+ const pathStr = path.map(s => s.value).join('.');
230
+ throw new Error(`Path '${pathStr}' points to a tree, not a dataset`);
231
+ }
232
+ // Handle different ref types
233
+ if (ref.type === 'unassigned') {
234
+ throw new Error(`Dataset at path is unassigned (pending task output)`);
235
+ }
236
+ if (ref.type === 'null') {
237
+ return null;
238
+ }
239
+ if (ref.type === 'tree') {
240
+ const pathStr = path.map(s => s.value).join('.');
241
+ throw new Error(`Path '${pathStr}' structure says value but ref is tree`);
242
+ }
243
+ // Read and return the dataset value
244
+ const result = await datasetRead(repoPath, ref.value);
245
+ return result.value;
246
+ }
247
+ /**
248
+ * Update a dataset at a path within a workspace.
249
+ *
250
+ * This creates new tree objects along the path with structural sharing,
251
+ * then atomically updates the workspace root.
252
+ *
253
+ * Acquires an exclusive lock on the workspace for the duration of the write
254
+ * to prevent concurrent modifications.
255
+ *
256
+ * @param repoPath - Path to .e3 repository
257
+ * @param ws - Workspace name
258
+ * @param treePath - Path to the dataset
259
+ * @param value - The new value to write
260
+ * @param type - The East type for encoding the value (EastType or EastTypeValue)
261
+ * @param options - Optional settings including external lock
262
+ * @throws {WorkspaceLockError} If workspace is locked by another process
263
+ * @throws If workspace not deployed, path invalid, or path points to a tree
264
+ */
265
+ export async function workspaceSetDataset(repoPath, ws, treePath, value, type, options = {}) {
266
+ if (treePath.length === 0) {
267
+ throw new Error('Cannot set dataset at root path - root is always a tree');
268
+ }
269
+ // Acquire lock if not provided externally
270
+ const externalLock = options.lock;
271
+ const lock = externalLock ?? await acquireWorkspaceLock(repoPath, ws);
272
+ try {
273
+ await workspaceSetDatasetUnlocked(repoPath, ws, treePath, value, type);
274
+ }
275
+ finally {
276
+ // Only release the lock if we acquired it internally
277
+ if (!externalLock) {
278
+ await lock.release();
279
+ }
280
+ }
281
+ }
282
+ /**
283
+ * Internal: Update a dataset without acquiring a lock.
284
+ * Caller must hold the workspace lock.
285
+ */
286
+ async function workspaceSetDatasetUnlocked(repoPath, ws, treePath, value, type) {
287
+ const state = await readWorkspaceState(repoPath, ws);
288
+ // Read the deployed package object to get the structure
289
+ const pkgData = await objectRead(repoPath, state.packageHash);
290
+ const decoder = decodeBeast2For(PackageObjectType);
291
+ const pkgObject = decoder(Buffer.from(pkgData));
292
+ const rootStructure = pkgObject.data.structure;
293
+ // Validate that the path leads to a value structure
294
+ let currentStructure = rootStructure;
295
+ for (let i = 0; i < treePath.length; i++) {
296
+ const segment = treePath[i];
297
+ if (segment.type !== 'field') {
298
+ throw new Error(`Unsupported path segment type: ${segment.type}`);
299
+ }
300
+ if (currentStructure.type !== 'struct') {
301
+ const pathSoFar = treePath.slice(0, i).map(s => s.value).join('.');
302
+ throw new Error(`Cannot descend into non-struct at path '${pathSoFar}'`);
303
+ }
304
+ const childStructure = currentStructure.value.get(segment.value);
305
+ if (!childStructure) {
306
+ const pathSoFar = treePath.slice(0, i).map(s => s.value).join('.');
307
+ const available = Array.from(currentStructure.value.keys()).join(', ');
308
+ throw new Error(`Field '${segment.value}' not found at '${pathSoFar}'. Available: ${available}`);
309
+ }
310
+ currentStructure = childStructure;
311
+ }
312
+ // Final structure must be a value
313
+ if (currentStructure.type !== 'value') {
314
+ const pathStr = treePath.map(s => s.value).join('.');
315
+ throw new Error(`Path '${pathStr}' points to a tree, not a dataset`);
316
+ }
317
+ // Write the new dataset value
318
+ const newValueHash = await datasetWrite(repoPath, value, type);
319
+ // Now rebuild the tree path from leaf to root (structural sharing)
320
+ // We need to read each tree along the path, modify it, and write a new version
321
+ // Collect all tree hashes and structures along the path
322
+ const treeInfos = [];
323
+ let currentHash = state.rootHash;
324
+ currentStructure = rootStructure;
325
+ // Read all trees along the path (except the last segment which is the dataset)
326
+ for (let i = 0; i < treePath.length - 1; i++) {
327
+ treeInfos.push({ hash: currentHash, structure: currentStructure });
328
+ const segment = treePath[i];
329
+ const treeObject = await treeRead(repoPath, currentHash, currentStructure);
330
+ const childRef = treeObject[segment.value];
331
+ if (!childRef || childRef.type !== 'tree') {
332
+ throw new Error(`Expected tree ref at path segment ${i}`);
333
+ }
334
+ currentHash = childRef.value;
335
+ currentStructure = currentStructure.value.get(segment.value);
336
+ }
337
+ // Add the final tree that contains the dataset
338
+ treeInfos.push({ hash: currentHash, structure: currentStructure });
339
+ // Now rebuild from leaf to root
340
+ // Start with the new value hash as the new ref
341
+ let newRef = { type: 'value', value: newValueHash };
342
+ for (let i = treeInfos.length - 1; i >= 0; i--) {
343
+ const { hash, structure } = treeInfos[i];
344
+ const fieldName = treePath[i].value;
345
+ // Read the current tree
346
+ const treeObject = await treeRead(repoPath, hash, structure);
347
+ // Create modified tree with the new ref
348
+ const newTreeObject = {
349
+ ...treeObject,
350
+ [fieldName]: newRef,
351
+ };
352
+ // Write the new tree
353
+ const newTreeHash = await treeWrite(repoPath, newTreeObject, structure);
354
+ // This becomes the new ref for the parent
355
+ newRef = { type: 'tree', value: newTreeHash };
356
+ }
357
+ // The final newRef is always a tree ref pointing to the new root
358
+ // (because we start with a value ref and wrap it in tree refs bottom-up)
359
+ if (newRef.type !== 'tree' || newRef.value === null) {
360
+ throw new Error('Internal error: expected tree ref after rebuilding path');
361
+ }
362
+ const newRootHash = newRef.value;
363
+ // Update workspace state atomically
364
+ await writeWorkspaceState(repoPath, ws, {
365
+ ...state,
366
+ rootHash: newRootHash,
367
+ rootUpdatedAt: new Date(),
368
+ });
369
+ }
370
+ // =============================================================================
371
+ // Workspace Helper Functions
372
+ // =============================================================================
373
+ /**
374
+ * Write workspace state to file atomically.
375
+ */
376
+ async function writeWorkspaceState(repoPath, ws, state) {
377
+ const wsDir = path.join(repoPath, 'workspaces');
378
+ const stateFile = path.join(wsDir, `${ws}.beast2`);
379
+ // Ensure workspaces directory exists
380
+ await fs.mkdir(wsDir, { recursive: true });
381
+ const encoder = encodeBeast2For(WorkspaceStateType);
382
+ const data = encoder(state);
383
+ // Write atomically: write to temp file, then rename
384
+ const randomSuffix = Math.random().toString(36).slice(2, 10);
385
+ const tempPath = path.join(wsDir, `.${ws}.${Date.now()}.${randomSuffix}.tmp`);
386
+ await fs.writeFile(tempPath, data);
387
+ await fs.rename(tempPath, stateFile);
388
+ }
389
+ /**
390
+ * Read workspace state from file.
391
+ * @throws {WorkspaceNotFoundError} If workspace doesn't exist
392
+ * @throws {WorkspaceNotDeployedError} If workspace exists but not deployed
393
+ */
394
+ async function readWorkspaceState(repoPath, ws) {
395
+ const stateFile = path.join(repoPath, 'workspaces', `${ws}.beast2`);
396
+ try {
397
+ const data = await fs.readFile(stateFile);
398
+ if (data.length === 0) {
399
+ throw new WorkspaceNotDeployedError(ws);
400
+ }
401
+ const decoder = decodeBeast2For(WorkspaceStateType);
402
+ return decoder(data);
403
+ }
404
+ catch (err) {
405
+ if (err instanceof WorkspaceNotDeployedError)
406
+ throw err;
407
+ if (isNotFoundError(err)) {
408
+ throw new WorkspaceNotFoundError(ws);
409
+ }
410
+ throw err;
411
+ }
412
+ }
413
+ /**
414
+ * Get root structure and hash for a workspace.
415
+ * Reads the deployed package object to get the structure.
416
+ */
417
+ async function getWorkspaceRootInfo(repoPath, ws) {
418
+ const state = await readWorkspaceState(repoPath, ws);
419
+ // Read the deployed package object using the stored hash
420
+ const pkgData = await objectRead(repoPath, state.packageHash);
421
+ const decoder = decodeBeast2For(PackageObjectType);
422
+ const pkgObject = decoder(Buffer.from(pkgData));
423
+ return {
424
+ rootHash: state.rootHash,
425
+ rootStructure: pkgObject.data.structure,
426
+ };
427
+ }
428
+ // =============================================================================
429
+ // Workspace High-level Operations (by path)
430
+ // =============================================================================
431
+ /**
432
+ * List field names at a tree path within a workspace's data tree.
433
+ *
434
+ * @param repoPath - Path to .e3 repository
435
+ * @param ws - Workspace name
436
+ * @param path - Path to the tree node
437
+ * @returns Array of field names at the path
438
+ * @throws If workspace not deployed, path invalid, or path points to a dataset
439
+ */
440
+ export async function workspaceListTree(repoPath, ws, treePath) {
441
+ const { rootHash, rootStructure } = await getWorkspaceRootInfo(repoPath, ws);
442
+ if (treePath.length === 0) {
443
+ // Empty path - list root tree fields
444
+ if (rootStructure.type !== 'struct') {
445
+ throw new Error('Root is not a tree');
446
+ }
447
+ const treeObject = await treeRead(repoPath, rootHash, rootStructure);
448
+ return Object.keys(treeObject);
449
+ }
450
+ // Traverse to the path
451
+ const { structure, ref } = await traverse(repoPath, rootHash, rootStructure, treePath);
452
+ // Must be a tree structure
453
+ if (structure.type !== 'struct') {
454
+ const pathStr = treePath.map(s => s.value).join('.');
455
+ throw new Error(`Path '${pathStr}' points to a dataset, not a tree`);
456
+ }
457
+ // Must be a tree ref
458
+ if (ref.type !== 'tree') {
459
+ const pathStr = treePath.map(s => s.value).join('.');
460
+ throw new Error(`Path '${pathStr}' has ref type '${ref.type}', expected 'tree'`);
461
+ }
462
+ // Read the tree and return field names
463
+ const treeObject = await treeRead(repoPath, ref.value, structure);
464
+ return Object.keys(treeObject);
465
+ }
466
+ /**
467
+ * Read and decode a dataset value at a path within a workspace's data tree.
468
+ *
469
+ * @param repoPath - Path to .e3 repository
470
+ * @param ws - Workspace name
471
+ * @param path - Path to the dataset
472
+ * @returns The decoded dataset value
473
+ * @throws If workspace not deployed, path invalid, or path points to a tree
474
+ */
475
+ export async function workspaceGetDataset(repoPath, ws, treePath) {
476
+ const { rootHash, rootStructure } = await getWorkspaceRootInfo(repoPath, ws);
477
+ if (treePath.length === 0) {
478
+ throw new Error('Cannot get dataset at root path - root is always a tree');
479
+ }
480
+ // Traverse to the path
481
+ const { structure, ref } = await traverse(repoPath, rootHash, rootStructure, treePath);
482
+ // Must be a value structure
483
+ if (structure.type !== 'value') {
484
+ const pathStr = treePath.map(s => s.value).join('.');
485
+ throw new Error(`Path '${pathStr}' points to a tree, not a dataset`);
486
+ }
487
+ // Handle different ref types
488
+ if (ref.type === 'unassigned') {
489
+ throw new Error(`Dataset at path is unassigned (pending task output)`);
490
+ }
491
+ if (ref.type === 'null') {
492
+ return null;
493
+ }
494
+ if (ref.type === 'tree') {
495
+ const pathStr = treePath.map(s => s.value).join('.');
496
+ throw new Error(`Path '${pathStr}' structure says value but ref is tree`);
497
+ }
498
+ // Read and return the dataset value
499
+ const result = await datasetRead(repoPath, ref.value);
500
+ return result.value;
501
+ }
502
+ /**
503
+ * Get the hash of a dataset at a path within a workspace's data tree.
504
+ *
505
+ * Unlike workspaceGetDataset which decodes the value, this returns the raw
506
+ * hash reference. Useful for dataflow execution which operates on hashes.
507
+ *
508
+ * @param repoPath - Path to .e3 repository
509
+ * @param ws - Workspace name
510
+ * @param treePath - Path to the dataset
511
+ * @returns Object with ref type and hash (null for unassigned/null refs)
512
+ * @throws If workspace not deployed, path invalid, or path points to a tree
513
+ */
514
+ export async function workspaceGetDatasetHash(repoPath, ws, treePath) {
515
+ const { rootHash, rootStructure } = await getWorkspaceRootInfo(repoPath, ws);
516
+ if (treePath.length === 0) {
517
+ throw new Error('Cannot get dataset at root path - root is always a tree');
518
+ }
519
+ // Traverse to the path
520
+ const { structure, ref } = await traverse(repoPath, rootHash, rootStructure, treePath);
521
+ // Must be a value structure
522
+ if (structure.type !== 'value') {
523
+ const pathStr = treePath.map(s => s.value).join('.');
524
+ throw new Error(`Path '${pathStr}' points to a tree, not a dataset`);
525
+ }
526
+ // Return ref type and hash
527
+ if (ref.type === 'unassigned' || ref.type === 'null') {
528
+ return { refType: ref.type, hash: null };
529
+ }
530
+ if (ref.type === 'tree') {
531
+ const pathStr = treePath.map(s => s.value).join('.');
532
+ throw new Error(`Path '${pathStr}' structure says value but ref is tree`);
533
+ }
534
+ return { refType: ref.type, hash: ref.value };
535
+ }
536
+ /**
537
+ * Set a dataset at a path within a workspace using a pre-computed hash.
538
+ *
539
+ * Unlike workspaceSetDataset which encodes a value, this takes a hash
540
+ * directly. Useful for dataflow execution which already has the output hash.
541
+ *
542
+ * IMPORTANT: This function does NOT acquire a workspace lock. The caller must
543
+ * hold an exclusive lock on the workspace (via acquireWorkspaceLock) before
544
+ * calling this function. This is typically used by dataflowExecute which
545
+ * holds the lock for the entire execution.
546
+ *
547
+ * @param repoPath - Path to .e3 repository
548
+ * @param ws - Workspace name
549
+ * @param treePath - Path to the dataset
550
+ * @param valueHash - Hash of the dataset value already in the object store
551
+ * @throws If workspace not deployed, path invalid, or path points to a tree
552
+ */
553
+ export async function workspaceSetDatasetByHash(repoPath, ws, treePath, valueHash) {
554
+ if (treePath.length === 0) {
555
+ throw new Error('Cannot set dataset at root path - root is always a tree');
556
+ }
557
+ const state = await readWorkspaceState(repoPath, ws);
558
+ // Read the deployed package object to get the structure
559
+ const pkgData = await objectRead(repoPath, state.packageHash);
560
+ const decoder = decodeBeast2For(PackageObjectType);
561
+ const pkgObject = decoder(Buffer.from(pkgData));
562
+ const rootStructure = pkgObject.data.structure;
563
+ // Validate that the path leads to a value structure
564
+ let currentStructure = rootStructure;
565
+ for (let i = 0; i < treePath.length; i++) {
566
+ const segment = treePath[i];
567
+ if (segment.type !== 'field') {
568
+ throw new Error(`Unsupported path segment type: ${segment.type}`);
569
+ }
570
+ if (currentStructure.type !== 'struct') {
571
+ const pathSoFar = treePath.slice(0, i).map(s => s.value).join('.');
572
+ throw new Error(`Cannot descend into non-struct at path '${pathSoFar}'`);
573
+ }
574
+ const childStructure = currentStructure.value.get(segment.value);
575
+ if (!childStructure) {
576
+ const pathSoFar = treePath.slice(0, i).map(s => s.value).join('.');
577
+ const available = Array.from(currentStructure.value.keys()).join(', ');
578
+ throw new Error(`Field '${segment.value}' not found at '${pathSoFar}'. Available: ${available}`);
579
+ }
580
+ currentStructure = childStructure;
581
+ }
582
+ // Final structure must be a value
583
+ if (currentStructure.type !== 'value') {
584
+ const pathStr = treePath.map(s => s.value).join('.');
585
+ throw new Error(`Path '${pathStr}' points to a tree, not a dataset`);
586
+ }
587
+ // Rebuild the tree path from leaf to root (structural sharing)
588
+ // Collect all tree hashes and structures along the path
589
+ const treeInfos = [];
590
+ let currentHash = state.rootHash;
591
+ currentStructure = rootStructure;
592
+ // Read all trees along the path (except the last segment which is the dataset)
593
+ for (let i = 0; i < treePath.length - 1; i++) {
594
+ treeInfos.push({ hash: currentHash, structure: currentStructure });
595
+ const segment = treePath[i];
596
+ const treeObject = await treeRead(repoPath, currentHash, currentStructure);
597
+ const childRef = treeObject[segment.value];
598
+ if (!childRef || childRef.type !== 'tree') {
599
+ throw new Error(`Expected tree ref at path segment ${i}`);
600
+ }
601
+ currentHash = childRef.value;
602
+ currentStructure = currentStructure.value.get(segment.value);
603
+ }
604
+ // Add the final tree that contains the dataset
605
+ treeInfos.push({ hash: currentHash, structure: currentStructure });
606
+ // Now rebuild from leaf to root
607
+ // Start with the provided value hash as the new ref
608
+ let newRef = { type: 'value', value: valueHash };
609
+ for (let i = treeInfos.length - 1; i >= 0; i--) {
610
+ const { hash, structure } = treeInfos[i];
611
+ const fieldName = treePath[i].value;
612
+ // Read the current tree
613
+ const treeObject = await treeRead(repoPath, hash, structure);
614
+ // Create modified tree with the new ref
615
+ const newTreeObject = {
616
+ ...treeObject,
617
+ [fieldName]: newRef,
618
+ };
619
+ // Write the new tree
620
+ const newTreeHash = await treeWrite(repoPath, newTreeObject, structure);
621
+ // This becomes the new ref for the parent
622
+ newRef = { type: 'tree', value: newTreeHash };
623
+ }
624
+ // The final newRef is always a tree ref pointing to the new root
625
+ if (newRef.type !== 'tree' || newRef.value === null) {
626
+ throw new Error('Internal error: expected tree ref after rebuilding path');
627
+ }
628
+ const newRootHash = newRef.value;
629
+ // Update workspace state atomically
630
+ await writeWorkspaceState(repoPath, ws, {
631
+ ...state,
632
+ rootHash: newRootHash,
633
+ rootUpdatedAt: new Date(),
634
+ });
635
+ }
636
+ //# sourceMappingURL=trees.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trees.js","sourceRoot":"","sources":["../../src/trees.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,UAAU,GAGX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAoE,MAAM,mBAAmB,CAAC;AACzJ,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAA4B,MAAM,oBAAoB,CAAC;AACpF,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAU7B;;;;;;;;GAQG;AACH,SAAS,qBAAqB,CAAC,SAAoB;IACjD,IAAI,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE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