@elaraai/e3-core 0.0.2-beta.9 → 1.0.1
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/LICENSE.md +4 -0
- package/README.md +74 -35
- package/dist/src/dataflow/api-compat.d.ts +90 -0
- package/dist/src/dataflow/api-compat.d.ts.map +1 -0
- package/dist/src/dataflow/api-compat.js +139 -0
- package/dist/src/dataflow/api-compat.js.map +1 -0
- package/dist/src/dataflow/api-compat.spec.d.ts +6 -0
- package/dist/src/dataflow/api-compat.spec.d.ts.map +1 -0
- package/dist/src/dataflow/api-compat.spec.js +182 -0
- package/dist/src/dataflow/api-compat.spec.js.map +1 -0
- package/dist/src/dataflow/index.d.ts +18 -0
- package/dist/src/dataflow/index.d.ts.map +1 -0
- package/dist/src/dataflow/index.js +23 -0
- package/dist/src/dataflow/index.js.map +1 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts +76 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.js +729 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.js.map +1 -0
- package/dist/src/dataflow/orchestrator/index.d.ts +12 -0
- package/dist/src/dataflow/orchestrator/index.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/index.js +12 -0
- package/dist/src/dataflow/orchestrator/index.js.map +1 -0
- package/dist/src/dataflow/orchestrator/interfaces.d.ts +163 -0
- package/dist/src/dataflow/orchestrator/interfaces.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/interfaces.js +52 -0
- package/dist/src/dataflow/orchestrator/interfaces.js.map +1 -0
- package/dist/src/dataflow/state-store/FileStateStore.d.ts +67 -0
- package/dist/src/dataflow/state-store/FileStateStore.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/FileStateStore.js +300 -0
- package/dist/src/dataflow/state-store/FileStateStore.js.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts +42 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.js +229 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.js.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.spec.d.ts +6 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.spec.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.spec.js +114 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.spec.js.map +1 -0
- package/dist/src/dataflow/state-store/index.d.ts +13 -0
- package/dist/src/dataflow/state-store/index.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/index.js +13 -0
- package/dist/src/dataflow/state-store/index.js.map +1 -0
- package/dist/src/dataflow/state-store/interfaces.d.ts +159 -0
- package/dist/src/dataflow/state-store/interfaces.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/interfaces.js +6 -0
- package/dist/src/dataflow/state-store/interfaces.js.map +1 -0
- package/dist/src/dataflow/steps.d.ts +222 -0
- package/dist/src/dataflow/steps.d.ts.map +1 -0
- package/dist/src/dataflow/steps.js +707 -0
- package/dist/src/dataflow/steps.js.map +1 -0
- package/dist/src/dataflow/steps.spec.d.ts +6 -0
- package/dist/src/dataflow/steps.spec.d.ts.map +1 -0
- package/dist/src/dataflow/steps.spec.js +343 -0
- package/dist/src/dataflow/steps.spec.js.map +1 -0
- package/dist/src/dataflow/types.d.ts +127 -0
- package/dist/src/dataflow/types.d.ts.map +1 -0
- package/dist/src/dataflow/types.js +7 -0
- package/dist/src/dataflow/types.js.map +1 -0
- package/dist/src/dataflow-orchestration.spec.d.ts +6 -0
- package/dist/src/dataflow-orchestration.spec.d.ts.map +1 -0
- package/dist/src/dataflow-orchestration.spec.js +1025 -0
- package/dist/src/dataflow-orchestration.spec.js.map +1 -0
- package/dist/src/dataflow.d.ts +113 -38
- package/dist/src/dataflow.d.ts.map +1 -1
- package/dist/src/dataflow.js +269 -416
- package/dist/src/dataflow.js.map +1 -1
- package/dist/src/dataflow.spec.d.ts +6 -0
- package/dist/src/dataflow.spec.d.ts.map +1 -0
- package/dist/src/dataflow.spec.js +663 -0
- package/dist/src/dataflow.spec.js.map +1 -0
- package/dist/src/dataset-refs.d.ts +124 -0
- package/dist/src/dataset-refs.d.ts.map +1 -0
- package/dist/src/dataset-refs.js +319 -0
- package/dist/src/dataset-refs.js.map +1 -0
- package/dist/src/errors.d.ts +39 -9
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +51 -8
- package/dist/src/errors.js.map +1 -1
- package/dist/src/errors.spec.d.ts +6 -0
- package/dist/src/errors.spec.d.ts.map +1 -0
- package/dist/src/errors.spec.js +276 -0
- package/dist/src/errors.spec.js.map +1 -0
- package/dist/src/execution/LocalTaskRunner.d.ts +73 -0
- package/dist/src/execution/LocalTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/LocalTaskRunner.js +399 -0
- package/dist/src/execution/LocalTaskRunner.js.map +1 -0
- package/dist/src/execution/MockTaskRunner.d.ts +49 -0
- package/dist/src/execution/MockTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/MockTaskRunner.js +54 -0
- package/dist/src/execution/MockTaskRunner.js.map +1 -0
- package/dist/src/execution/index.d.ts +16 -0
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/src/execution/index.js +8 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/interfaces.d.ts +246 -0
- package/dist/src/execution/interfaces.d.ts.map +1 -0
- package/dist/src/execution/interfaces.js +6 -0
- package/dist/src/execution/interfaces.js.map +1 -0
- package/dist/src/execution/processHelpers.d.ts +20 -0
- package/dist/src/execution/processHelpers.d.ts.map +1 -0
- package/dist/src/execution/processHelpers.js +62 -0
- package/dist/src/execution/processHelpers.js.map +1 -0
- package/dist/src/executions.d.ts +71 -104
- package/dist/src/executions.d.ts.map +1 -1
- package/dist/src/executions.js +113 -481
- package/dist/src/executions.js.map +1 -1
- package/dist/src/executions.spec.d.ts +6 -0
- package/dist/src/executions.spec.d.ts.map +1 -0
- package/dist/src/executions.spec.js +387 -0
- package/dist/src/executions.spec.js.map +1 -0
- package/dist/src/formats.d.ts +18 -2
- package/dist/src/formats.d.ts.map +1 -1
- package/dist/src/formats.js +34 -2
- package/dist/src/formats.js.map +1 -1
- package/dist/src/gc.spec.d.ts +6 -0
- package/dist/src/gc.spec.d.ts.map +1 -0
- package/dist/src/gc.spec.js +512 -0
- package/dist/src/gc.spec.js.map +1 -0
- package/dist/src/index.d.ts +20 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +48 -18
- package/dist/src/index.js.map +1 -1
- package/dist/src/objects.d.ts +7 -53
- package/dist/src/objects.d.ts.map +1 -1
- package/dist/src/objects.js +13 -232
- package/dist/src/objects.js.map +1 -1
- package/dist/src/objects.spec.d.ts +6 -0
- package/dist/src/objects.spec.d.ts.map +1 -0
- package/dist/src/objects.spec.js +247 -0
- package/dist/src/objects.spec.js.map +1 -0
- package/dist/src/packages.d.ts +41 -14
- package/dist/src/packages.d.ts.map +1 -1
- package/dist/src/packages.js +151 -89
- package/dist/src/packages.js.map +1 -1
- package/dist/src/packages.spec.d.ts +6 -0
- package/dist/src/packages.spec.d.ts.map +1 -0
- package/dist/src/packages.spec.js +324 -0
- package/dist/src/packages.spec.js.map +1 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts +35 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts.map +1 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.js +107 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.js.map +1 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.spec.d.ts +6 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.spec.d.ts.map +1 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.spec.js +187 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.spec.js.map +1 -0
- package/dist/src/storage/in-memory/InMemoryStorage.d.ts +139 -0
- package/dist/src/storage/in-memory/InMemoryStorage.d.ts.map +1 -0
- package/dist/src/storage/in-memory/InMemoryStorage.js +439 -0
- package/dist/src/storage/in-memory/InMemoryStorage.js.map +1 -0
- package/dist/src/storage/in-memory/index.d.ts +12 -0
- package/dist/src/storage/in-memory/index.d.ts.map +1 -0
- package/dist/src/storage/in-memory/index.js +12 -0
- package/dist/src/storage/in-memory/index.js.map +1 -0
- package/dist/src/storage/index.d.ts +18 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/index.js +10 -0
- package/dist/src/storage/index.js.map +1 -0
- package/dist/src/storage/interfaces.d.ts +581 -0
- package/dist/src/storage/interfaces.d.ts.map +1 -0
- package/dist/src/storage/interfaces.js +6 -0
- package/dist/src/storage/interfaces.js.map +1 -0
- package/dist/src/storage/local/LocalBackend.d.ts +56 -0
- package/dist/src/storage/local/LocalBackend.d.ts.map +1 -0
- package/dist/src/storage/local/LocalBackend.js +145 -0
- package/dist/src/storage/local/LocalBackend.js.map +1 -0
- package/dist/src/storage/local/LocalDatasetRefStore.d.ts +22 -0
- package/dist/src/storage/local/LocalDatasetRefStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalDatasetRefStore.js +118 -0
- package/dist/src/storage/local/LocalDatasetRefStore.js.map +1 -0
- package/dist/src/storage/local/LocalLockService.d.ts +111 -0
- package/dist/src/storage/local/LocalLockService.d.ts.map +1 -0
- package/dist/src/storage/local/LocalLockService.js +364 -0
- package/dist/src/storage/local/LocalLockService.js.map +1 -0
- package/dist/src/storage/local/LocalLockService.spec.d.ts +6 -0
- package/dist/src/storage/local/LocalLockService.spec.d.ts.map +1 -0
- package/dist/src/storage/local/LocalLockService.spec.js +148 -0
- package/dist/src/storage/local/LocalLockService.spec.js.map +1 -0
- package/dist/src/storage/local/LocalLogStore.d.ts +23 -0
- package/dist/src/storage/local/LocalLogStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalLogStore.js +66 -0
- package/dist/src/storage/local/LocalLogStore.js.map +1 -0
- package/dist/src/storage/local/LocalObjectStore.d.ts +55 -0
- package/dist/src/storage/local/LocalObjectStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalObjectStore.js +300 -0
- package/dist/src/storage/local/LocalObjectStore.js.map +1 -0
- package/dist/src/storage/local/LocalRefStore.d.ts +50 -0
- package/dist/src/storage/local/LocalRefStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalRefStore.js +337 -0
- package/dist/src/storage/local/LocalRefStore.js.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.d.ts +55 -0
- package/dist/src/storage/local/LocalRepoStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.js +365 -0
- package/dist/src/storage/local/LocalRepoStore.js.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.spec.d.ts +6 -0
- package/dist/src/storage/local/LocalRepoStore.spec.d.ts.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.spec.js +255 -0
- package/dist/src/storage/local/LocalRepoStore.spec.js.map +1 -0
- package/dist/src/storage/local/gc.d.ts +92 -0
- package/dist/src/storage/local/gc.d.ts.map +1 -0
- package/dist/src/storage/local/gc.js +377 -0
- package/dist/src/storage/local/gc.js.map +1 -0
- package/dist/src/storage/local/index.d.ts +18 -0
- package/dist/src/storage/local/index.d.ts.map +1 -0
- package/dist/src/storage/local/index.js +18 -0
- package/dist/src/storage/local/index.js.map +1 -0
- package/dist/src/storage/local/localHelpers.d.ts +25 -0
- package/dist/src/storage/local/localHelpers.d.ts.map +1 -0
- package/dist/src/storage/local/localHelpers.js +69 -0
- package/dist/src/storage/local/localHelpers.js.map +1 -0
- package/dist/src/{repository.d.ts → storage/local/repository.d.ts} +8 -4
- package/dist/src/storage/local/repository.d.ts.map +1 -0
- package/dist/src/{repository.js → storage/local/repository.js} +31 -29
- package/dist/src/storage/local/repository.js.map +1 -0
- package/dist/src/storage/local/repository.spec.d.ts +6 -0
- package/dist/src/storage/local/repository.spec.d.ts.map +1 -0
- package/dist/src/storage/local/repository.spec.js +186 -0
- package/dist/src/storage/local/repository.spec.js.map +1 -0
- package/dist/src/tasks.d.ts +16 -10
- package/dist/src/tasks.d.ts.map +1 -1
- package/dist/src/tasks.js +35 -41
- package/dist/src/tasks.js.map +1 -1
- package/dist/src/tasks.spec.d.ts +6 -0
- package/dist/src/tasks.spec.d.ts.map +1 -0
- package/dist/src/tasks.spec.js +105 -0
- package/dist/src/tasks.spec.js.map +1 -0
- package/dist/src/test-helpers.d.ts +5 -4
- package/dist/src/test-helpers.d.ts.map +1 -1
- package/dist/src/test-helpers.js +9 -21
- package/dist/src/test-helpers.js.map +1 -1
- package/dist/src/transfer/InMemoryTransferBackend.d.ts +75 -0
- package/dist/src/transfer/InMemoryTransferBackend.d.ts.map +1 -0
- package/dist/src/transfer/InMemoryTransferBackend.js +211 -0
- package/dist/src/transfer/InMemoryTransferBackend.js.map +1 -0
- package/dist/src/transfer/index.d.ts +9 -0
- package/dist/src/transfer/index.d.ts.map +1 -0
- package/dist/src/transfer/index.js +11 -0
- package/dist/src/transfer/index.js.map +1 -0
- package/dist/src/transfer/interfaces.d.ts +103 -0
- package/dist/src/transfer/interfaces.d.ts.map +1 -0
- package/dist/src/transfer/interfaces.js +6 -0
- package/dist/src/transfer/interfaces.js.map +1 -0
- package/dist/src/transfer/process.d.ts +55 -0
- package/dist/src/transfer/process.d.ts.map +1 -0
- package/dist/src/transfer/process.js +144 -0
- package/dist/src/transfer/process.js.map +1 -0
- package/dist/src/transfer/types.d.ts +106 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/transfer/types.js +61 -0
- package/dist/src/transfer/types.js.map +1 -0
- package/dist/src/trees.d.ts +102 -63
- package/dist/src/trees.d.ts.map +1 -1
- package/dist/src/trees.js +319 -479
- package/dist/src/trees.js.map +1 -1
- package/dist/src/trees.spec.d.ts +6 -0
- package/dist/src/trees.spec.d.ts.map +1 -0
- package/dist/src/trees.spec.js +635 -0
- package/dist/src/trees.spec.js.map +1 -0
- package/dist/src/uuid.d.ts +26 -0
- package/dist/src/uuid.d.ts.map +1 -0
- package/dist/src/uuid.js +80 -0
- package/dist/src/uuid.js.map +1 -0
- package/dist/src/workspaceStatus.d.ts +6 -4
- package/dist/src/workspaceStatus.d.ts.map +1 -1
- package/dist/src/workspaceStatus.js +46 -60
- package/dist/src/workspaceStatus.js.map +1 -1
- package/dist/src/workspaces.d.ts +46 -47
- package/dist/src/workspaces.d.ts.map +1 -1
- package/dist/src/workspaces.js +281 -221
- package/dist/src/workspaces.js.map +1 -1
- package/dist/src/workspaces.spec.d.ts +6 -0
- package/dist/src/workspaces.spec.d.ts.map +1 -0
- package/dist/src/workspaces.spec.js +273 -0
- package/dist/src/workspaces.spec.js.map +1 -0
- package/package.json +15 -15
- package/dist/src/gc.d.ts +0 -54
- package/dist/src/gc.d.ts.map +0 -1
- package/dist/src/gc.js +0 -233
- package/dist/src/gc.js.map +0 -1
- package/dist/src/repository.d.ts.map +0 -1
- package/dist/src/repository.js.map +0 -1
- package/dist/src/workspaceLock.d.ts +0 -67
- package/dist/src/workspaceLock.d.ts.map +0 -1
- package/dist/src/workspaceLock.js +0 -217
- package/dist/src/workspaceLock.js.map +0 -1
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs/promises';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { decodeBeast2For, encodeBeast2For } from '@elaraai/east';
|
|
8
|
+
import { ExecutionStatusType, DataflowRunType } from '@elaraai/e3-types';
|
|
9
|
+
import { isNotFoundError, ExecutionCorruptError } from '../../errors.js';
|
|
10
|
+
/**
|
|
11
|
+
* Local filesystem implementation of RefStore.
|
|
12
|
+
*
|
|
13
|
+
* The `repo` parameter is the path to the e3 repository directory.
|
|
14
|
+
*/
|
|
15
|
+
export class LocalRefStore {
|
|
16
|
+
// -------------------------------------------------------------------------
|
|
17
|
+
// Package References
|
|
18
|
+
// -------------------------------------------------------------------------
|
|
19
|
+
async packageList(repo) {
|
|
20
|
+
const packagesDir = path.join(repo, 'packages');
|
|
21
|
+
const packages = [];
|
|
22
|
+
try {
|
|
23
|
+
const names = await fs.readdir(packagesDir);
|
|
24
|
+
for (const name of names) {
|
|
25
|
+
const nameDir = path.join(packagesDir, name);
|
|
26
|
+
const stat = await fs.stat(nameDir);
|
|
27
|
+
if (stat.isDirectory()) {
|
|
28
|
+
const versions = await fs.readdir(nameDir);
|
|
29
|
+
for (const version of versions) {
|
|
30
|
+
packages.push({ name, version });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
// Only suppress ENOENT - directory may not exist yet
|
|
37
|
+
if (!isNotFoundError(err)) {
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return packages;
|
|
42
|
+
}
|
|
43
|
+
async packageResolve(repo, name, version) {
|
|
44
|
+
const refPath = path.join(repo, 'packages', name, version);
|
|
45
|
+
try {
|
|
46
|
+
const content = await fs.readFile(refPath, 'utf-8');
|
|
47
|
+
return content.trim();
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
if (isNotFoundError(err)) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async packageWrite(repo, name, version, hash) {
|
|
57
|
+
const refDir = path.join(repo, 'packages', name);
|
|
58
|
+
await fs.mkdir(refDir, { recursive: true });
|
|
59
|
+
const refPath = path.join(refDir, version);
|
|
60
|
+
await fs.writeFile(refPath, hash + '\n');
|
|
61
|
+
}
|
|
62
|
+
async packageRemove(repo, name, version) {
|
|
63
|
+
const refPath = path.join(repo, 'packages', name, version);
|
|
64
|
+
try {
|
|
65
|
+
await fs.unlink(refPath);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (isNotFoundError(err)) {
|
|
69
|
+
return; // Already removed, idempotent
|
|
70
|
+
}
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
// Try to remove the package name directory if empty
|
|
74
|
+
const packageDir = path.join(repo, 'packages', name);
|
|
75
|
+
try {
|
|
76
|
+
await fs.rmdir(packageDir);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Directory not empty, that's fine
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// -------------------------------------------------------------------------
|
|
83
|
+
// Workspace State
|
|
84
|
+
// -------------------------------------------------------------------------
|
|
85
|
+
async workspaceList(repo) {
|
|
86
|
+
const workspacesDir = path.join(repo, 'workspaces');
|
|
87
|
+
const names = [];
|
|
88
|
+
try {
|
|
89
|
+
const entries = await fs.readdir(workspacesDir);
|
|
90
|
+
for (const entry of entries) {
|
|
91
|
+
if (entry.endsWith('.beast2')) {
|
|
92
|
+
names.push(entry.slice(0, -7)); // Remove .beast2 extension
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
// Only suppress ENOENT - directory may not exist yet
|
|
98
|
+
if (!isNotFoundError(err)) {
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return names;
|
|
103
|
+
}
|
|
104
|
+
async workspaceRead(repo, name) {
|
|
105
|
+
const stateFile = path.join(repo, 'workspaces', `${name}.beast2`);
|
|
106
|
+
try {
|
|
107
|
+
return await fs.readFile(stateFile);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
if (isNotFoundError(err)) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
throw err;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async workspaceWrite(repo, name, state) {
|
|
117
|
+
const wsDir = path.join(repo, 'workspaces');
|
|
118
|
+
const stateFile = path.join(wsDir, `${name}.beast2`);
|
|
119
|
+
await fs.mkdir(wsDir, { recursive: true });
|
|
120
|
+
// Write atomically: write to temp file, then rename
|
|
121
|
+
const randomSuffix = Math.random().toString(36).slice(2, 10);
|
|
122
|
+
const tempPath = path.join(wsDir, `.${name}.${Date.now()}.${randomSuffix}.tmp`);
|
|
123
|
+
await fs.writeFile(tempPath, state);
|
|
124
|
+
await fs.rename(tempPath, stateFile);
|
|
125
|
+
}
|
|
126
|
+
async workspaceRemove(repo, name) {
|
|
127
|
+
const stateFile = path.join(repo, 'workspaces', `${name}.beast2`);
|
|
128
|
+
try {
|
|
129
|
+
await fs.unlink(stateFile);
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
if (isNotFoundError(err)) {
|
|
133
|
+
return; // Already removed, idempotent
|
|
134
|
+
}
|
|
135
|
+
throw err;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// -------------------------------------------------------------------------
|
|
139
|
+
// Execution Cache (with execution history)
|
|
140
|
+
// -------------------------------------------------------------------------
|
|
141
|
+
/**
|
|
142
|
+
* Path to execution directory: executions/<taskHash>/<inputsHash>/<executionId>/
|
|
143
|
+
*/
|
|
144
|
+
executionDir(repo, taskHash, inputsHash, executionId) {
|
|
145
|
+
return path.join(repo, 'executions', taskHash, inputsHash, executionId);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Path to inputs directory: executions/<taskHash>/<inputsHash>/
|
|
149
|
+
*/
|
|
150
|
+
inputsDir(repo, taskHash, inputsHash) {
|
|
151
|
+
return path.join(repo, 'executions', taskHash, inputsHash);
|
|
152
|
+
}
|
|
153
|
+
async executionGet(repo, taskHash, inputsHash, executionId) {
|
|
154
|
+
const execDir = this.executionDir(repo, taskHash, inputsHash, executionId);
|
|
155
|
+
const statusPath = path.join(execDir, 'status.beast2');
|
|
156
|
+
let data;
|
|
157
|
+
try {
|
|
158
|
+
data = await fs.readFile(statusPath);
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
if (isNotFoundError(err)) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
throw err;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const decoder = decodeBeast2For(ExecutionStatusType);
|
|
168
|
+
return decoder(data);
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
throw new ExecutionCorruptError(taskHash, inputsHash, err instanceof Error ? err : new Error(String(err)));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async executionWrite(repo, taskHash, inputsHash, executionId, status) {
|
|
175
|
+
const execDir = this.executionDir(repo, taskHash, inputsHash, executionId);
|
|
176
|
+
await fs.mkdir(execDir, { recursive: true });
|
|
177
|
+
const encoder = encodeBeast2For(ExecutionStatusType);
|
|
178
|
+
await fs.writeFile(path.join(execDir, 'status.beast2'), encoder(status));
|
|
179
|
+
// Also write output hash for success status
|
|
180
|
+
if (status.type === 'success') {
|
|
181
|
+
await fs.writeFile(path.join(execDir, 'output'), status.value.outputHash + '\n');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async executionListIds(repo, taskHash, inputsHash) {
|
|
185
|
+
const inputDir = this.inputsDir(repo, taskHash, inputsHash);
|
|
186
|
+
try {
|
|
187
|
+
const entries = await fs.readdir(inputDir);
|
|
188
|
+
// Filter for UUIDv7-like format (36 chars with dashes) and sort lexicographically
|
|
189
|
+
const uuids = entries.filter((e) => /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e));
|
|
190
|
+
return uuids.sort();
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
if (isNotFoundError(err)) {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
throw err;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async executionGetLatest(repo, taskHash, inputsHash) {
|
|
200
|
+
const ids = await this.executionListIds(repo, taskHash, inputsHash);
|
|
201
|
+
if (ids.length === 0) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
// Get the lexicographically greatest (latest) execution
|
|
205
|
+
const latestId = ids[ids.length - 1];
|
|
206
|
+
return this.executionGet(repo, taskHash, inputsHash, latestId);
|
|
207
|
+
}
|
|
208
|
+
async executionGetLatestOutput(repo, taskHash, inputsHash) {
|
|
209
|
+
const ids = await this.executionListIds(repo, taskHash, inputsHash);
|
|
210
|
+
// Iterate from latest to oldest, return first success
|
|
211
|
+
for (let i = ids.length - 1; i >= 0; i--) {
|
|
212
|
+
const execDir = this.executionDir(repo, taskHash, inputsHash, ids[i]);
|
|
213
|
+
const outputPath = path.join(execDir, 'output');
|
|
214
|
+
try {
|
|
215
|
+
const content = await fs.readFile(outputPath, 'utf-8');
|
|
216
|
+
return content.trim();
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
if (!isNotFoundError(err)) {
|
|
220
|
+
throw err;
|
|
221
|
+
}
|
|
222
|
+
// No output file, check status to see if it's a success without output
|
|
223
|
+
// or just continue to next execution
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
async executionList(repo) {
|
|
229
|
+
const executionsDir = path.join(repo, 'executions');
|
|
230
|
+
const result = [];
|
|
231
|
+
try {
|
|
232
|
+
const taskDirs = await fs.readdir(executionsDir);
|
|
233
|
+
for (const taskHash of taskDirs) {
|
|
234
|
+
if (!/^[a-f0-9]{64}$/.test(taskHash))
|
|
235
|
+
continue;
|
|
236
|
+
const taskDir = path.join(executionsDir, taskHash);
|
|
237
|
+
const stat = await fs.stat(taskDir);
|
|
238
|
+
if (!stat.isDirectory())
|
|
239
|
+
continue;
|
|
240
|
+
const inputsDirs = await fs.readdir(taskDir);
|
|
241
|
+
for (const inputsHash of inputsDirs) {
|
|
242
|
+
if (/^[a-f0-9]{64}$/.test(inputsHash)) {
|
|
243
|
+
result.push({ taskHash, inputsHash });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
if (!isNotFoundError(err)) {
|
|
250
|
+
throw err;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
async executionListForTask(repo, taskHash) {
|
|
256
|
+
const taskDir = path.join(repo, 'executions', taskHash);
|
|
257
|
+
try {
|
|
258
|
+
const entries = await fs.readdir(taskDir);
|
|
259
|
+
return entries.filter((e) => /^[a-f0-9]{64}$/.test(e));
|
|
260
|
+
}
|
|
261
|
+
catch (err) {
|
|
262
|
+
if (!isNotFoundError(err)) {
|
|
263
|
+
throw err;
|
|
264
|
+
}
|
|
265
|
+
return [];
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// -------------------------------------------------------------------------
|
|
269
|
+
// Dataflow Run History
|
|
270
|
+
// -------------------------------------------------------------------------
|
|
271
|
+
dataflowDir(repo, workspace) {
|
|
272
|
+
return path.join(repo, 'dataflows', workspace);
|
|
273
|
+
}
|
|
274
|
+
dataflowRunPath(repo, workspace, runId) {
|
|
275
|
+
return path.join(this.dataflowDir(repo, workspace), `${runId}.beast2`);
|
|
276
|
+
}
|
|
277
|
+
async dataflowRunGet(repo, workspace, runId) {
|
|
278
|
+
const runPath = this.dataflowRunPath(repo, workspace, runId);
|
|
279
|
+
let data;
|
|
280
|
+
try {
|
|
281
|
+
data = await fs.readFile(runPath);
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
if (isNotFoundError(err)) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
throw err;
|
|
288
|
+
}
|
|
289
|
+
const decoder = decodeBeast2For(DataflowRunType);
|
|
290
|
+
return decoder(data);
|
|
291
|
+
}
|
|
292
|
+
async dataflowRunWrite(repo, workspace, run) {
|
|
293
|
+
const dir = this.dataflowDir(repo, workspace);
|
|
294
|
+
await fs.mkdir(dir, { recursive: true });
|
|
295
|
+
const encoder = encodeBeast2For(DataflowRunType);
|
|
296
|
+
const runPath = this.dataflowRunPath(repo, workspace, run.runId);
|
|
297
|
+
await fs.writeFile(runPath, encoder(run));
|
|
298
|
+
}
|
|
299
|
+
async dataflowRunList(repo, workspace) {
|
|
300
|
+
const dir = this.dataflowDir(repo, workspace);
|
|
301
|
+
try {
|
|
302
|
+
const entries = await fs.readdir(dir);
|
|
303
|
+
// Filter for .beast2 files, extract runId, and sort
|
|
304
|
+
const runIds = entries
|
|
305
|
+
.filter((e) => e.endsWith('.beast2'))
|
|
306
|
+
.map((e) => e.slice(0, -7)) // Remove .beast2
|
|
307
|
+
.filter((e) => /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e));
|
|
308
|
+
return runIds.sort();
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
if (isNotFoundError(err)) {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
throw err;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
async dataflowRunGetLatest(repo, workspace) {
|
|
318
|
+
const ids = await this.dataflowRunList(repo, workspace);
|
|
319
|
+
if (ids.length === 0) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
const latestId = ids[ids.length - 1];
|
|
323
|
+
return this.dataflowRunGet(repo, workspace, latestId);
|
|
324
|
+
}
|
|
325
|
+
async dataflowRunDelete(repo, workspace, runId) {
|
|
326
|
+
const runPath = this.dataflowRunPath(repo, workspace, runId);
|
|
327
|
+
try {
|
|
328
|
+
await fs.unlink(runPath);
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
if (isNotFoundError(err))
|
|
332
|
+
return; // idempotent
|
|
333
|
+
throw err;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=LocalRefStore.js.map
|
|
@@ -0,0 +1 @@
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,CAAC,GAAG,CAAC;gBAAE,OAAO,CAAC,aAAa;YAC/C,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import type { RepoStore, RepoStatus, RepoMetadata, BatchResult, GcObjectScanResult, GcRootScanResult } from '../interfaces.js';
|
|
6
|
+
import type { RefStore, DatasetRefStore } from '../interfaces.js';
|
|
7
|
+
/**
|
|
8
|
+
* Local filesystem implementation of RepoStore.
|
|
9
|
+
*
|
|
10
|
+
* Manages repository lifecycle for local e3 repositories stored
|
|
11
|
+
* as subdirectories within a parent directory.
|
|
12
|
+
*/
|
|
13
|
+
export declare class LocalRepoStore implements RepoStore {
|
|
14
|
+
private readonly reposDir;
|
|
15
|
+
private readonly refs;
|
|
16
|
+
private readonly datasets?;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new LocalRepoStore.
|
|
19
|
+
* @param reposDir - Parent directory containing repositories
|
|
20
|
+
* @param refs - RefStore for reading package/workspace/execution refs
|
|
21
|
+
* @param datasets - DatasetRefStore for reading per-dataset refs (for GC scanning)
|
|
22
|
+
*/
|
|
23
|
+
constructor(reposDir: string, refs: RefStore, datasets?: DatasetRefStore | undefined);
|
|
24
|
+
/**
|
|
25
|
+
* Get the path to a repository directory.
|
|
26
|
+
*/
|
|
27
|
+
private getRepoPath;
|
|
28
|
+
/**
|
|
29
|
+
* Get the path to a repository's metadata file.
|
|
30
|
+
*/
|
|
31
|
+
private getMetadataPath;
|
|
32
|
+
/**
|
|
33
|
+
* Check if a directory is a valid e3 repository.
|
|
34
|
+
*/
|
|
35
|
+
private isValidRepository;
|
|
36
|
+
list(): Promise<string[]>;
|
|
37
|
+
exists(repo: string): Promise<boolean>;
|
|
38
|
+
getMetadata(repo: string): Promise<RepoMetadata | null>;
|
|
39
|
+
create(repo: string): Promise<void>;
|
|
40
|
+
setStatus(repo: string, status: RepoStatus, expected?: RepoStatus | RepoStatus[]): Promise<void>;
|
|
41
|
+
remove(repo: string): Promise<void>;
|
|
42
|
+
deleteRefsBatch(repo: string, _cursor?: string): Promise<BatchResult>;
|
|
43
|
+
deleteObjectsBatch(repo: string, _cursor?: string): Promise<BatchResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Recursively delete all contents of a directory.
|
|
46
|
+
* Returns count of files deleted.
|
|
47
|
+
*/
|
|
48
|
+
private deleteDirectoryContents;
|
|
49
|
+
gcScanPackageRoots(repo: string, _cursor?: unknown): Promise<GcRootScanResult>;
|
|
50
|
+
gcScanWorkspaceRoots(repo: string, _cursor?: unknown): Promise<GcRootScanResult>;
|
|
51
|
+
gcScanExecutionRoots(repo: string, _cursor?: unknown): Promise<GcRootScanResult>;
|
|
52
|
+
gcScanObjects(repo: string, _cursor?: unknown): Promise<GcObjectScanResult>;
|
|
53
|
+
gcDeleteObjects(repo: string, hashes: string[]): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=LocalRepoStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalRepoStore.d.ts","sourceRoot":"","sources":["../../../../src/storage/local/LocalRepoStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,WAAW,EAEX,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAqBlE;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,SAAS;IAQ5C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAT5B;;;;;OAKG;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