@elaraai/e3-core 0.0.2-beta.3 → 0.0.2-beta.31

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 (184) 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 +134 -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 +53 -0
  11. package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts.map +1 -0
  12. package/dist/src/dataflow/orchestrator/LocalOrchestrator.js +416 -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 +157 -0
  19. package/dist/src/dataflow/orchestrator/interfaces.d.ts.map +1 -0
  20. package/dist/src/dataflow/orchestrator/interfaces.js +51 -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 +286 -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 +214 -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 +176 -0
  39. package/dist/src/dataflow/steps.d.ts.map +1 -0
  40. package/dist/src/dataflow/steps.js +528 -0
  41. package/dist/src/dataflow/steps.js.map +1 -0
  42. package/dist/src/dataflow/types.d.ts +116 -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 +142 -9
  47. package/dist/src/dataflow.d.ts.map +1 -1
  48. package/dist/src/dataflow.js +427 -64
  49. package/dist/src/dataflow.js.map +1 -1
  50. package/dist/src/errors.d.ts +39 -9
  51. package/dist/src/errors.d.ts.map +1 -1
  52. package/dist/src/errors.js +51 -8
  53. package/dist/src/errors.js.map +1 -1
  54. package/dist/src/execution/LocalTaskRunner.d.ts +73 -0
  55. package/dist/src/execution/LocalTaskRunner.d.ts.map +1 -0
  56. package/dist/src/execution/LocalTaskRunner.js +399 -0
  57. package/dist/src/execution/LocalTaskRunner.js.map +1 -0
  58. package/dist/src/execution/MockTaskRunner.d.ts +49 -0
  59. package/dist/src/execution/MockTaskRunner.d.ts.map +1 -0
  60. package/dist/src/execution/MockTaskRunner.js +55 -0
  61. package/dist/src/execution/MockTaskRunner.js.map +1 -0
  62. package/dist/src/execution/index.d.ts +16 -0
  63. package/dist/src/execution/index.d.ts.map +1 -0
  64. package/dist/src/execution/index.js +8 -0
  65. package/dist/src/execution/index.js.map +1 -0
  66. package/dist/src/execution/interfaces.d.ts +246 -0
  67. package/dist/src/execution/interfaces.d.ts.map +1 -0
  68. package/dist/src/execution/interfaces.js +6 -0
  69. package/dist/src/execution/interfaces.js.map +1 -0
  70. package/dist/src/execution/processHelpers.d.ts +20 -0
  71. package/dist/src/execution/processHelpers.d.ts.map +1 -0
  72. package/dist/src/execution/processHelpers.js +62 -0
  73. package/dist/src/execution/processHelpers.js.map +1 -0
  74. package/dist/src/executions.d.ts +71 -104
  75. package/dist/src/executions.d.ts.map +1 -1
  76. package/dist/src/executions.js +110 -476
  77. package/dist/src/executions.js.map +1 -1
  78. package/dist/src/index.d.ts +17 -9
  79. package/dist/src/index.d.ts.map +1 -1
  80. package/dist/src/index.js +44 -18
  81. package/dist/src/index.js.map +1 -1
  82. package/dist/src/objects.d.ts +6 -53
  83. package/dist/src/objects.d.ts.map +1 -1
  84. package/dist/src/objects.js +11 -232
  85. package/dist/src/objects.js.map +1 -1
  86. package/dist/src/packages.d.ts +22 -14
  87. package/dist/src/packages.d.ts.map +1 -1
  88. package/dist/src/packages.js +116 -83
  89. package/dist/src/packages.js.map +1 -1
  90. package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts +35 -0
  91. package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts.map +1 -0
  92. package/dist/src/storage/in-memory/InMemoryRepoStore.js +107 -0
  93. package/dist/src/storage/in-memory/InMemoryRepoStore.js.map +1 -0
  94. package/dist/src/storage/in-memory/InMemoryStorage.d.ts +114 -0
  95. package/dist/src/storage/in-memory/InMemoryStorage.d.ts.map +1 -0
  96. package/dist/src/storage/in-memory/InMemoryStorage.js +349 -0
  97. package/dist/src/storage/in-memory/InMemoryStorage.js.map +1 -0
  98. package/dist/src/storage/in-memory/index.d.ts +12 -0
  99. package/dist/src/storage/in-memory/index.d.ts.map +1 -0
  100. package/dist/src/storage/in-memory/index.js +12 -0
  101. package/dist/src/storage/in-memory/index.js.map +1 -0
  102. package/dist/src/storage/index.d.ts +18 -0
  103. package/dist/src/storage/index.d.ts.map +1 -0
  104. package/dist/src/storage/index.js +10 -0
  105. package/dist/src/storage/index.js.map +1 -0
  106. package/dist/src/storage/interfaces.d.ts +520 -0
  107. package/dist/src/storage/interfaces.d.ts.map +1 -0
  108. package/dist/src/storage/interfaces.js +6 -0
  109. package/dist/src/storage/interfaces.js.map +1 -0
  110. package/dist/src/storage/local/LocalBackend.d.ts +54 -0
  111. package/dist/src/storage/local/LocalBackend.d.ts.map +1 -0
  112. package/dist/src/storage/local/LocalBackend.js +141 -0
  113. package/dist/src/storage/local/LocalBackend.js.map +1 -0
  114. package/dist/src/storage/local/LocalLockService.d.ts +105 -0
  115. package/dist/src/storage/local/LocalLockService.d.ts.map +1 -0
  116. package/dist/src/storage/local/LocalLockService.js +342 -0
  117. package/dist/src/storage/local/LocalLockService.js.map +1 -0
  118. package/dist/src/storage/local/LocalLogStore.d.ts +23 -0
  119. package/dist/src/storage/local/LocalLogStore.d.ts.map +1 -0
  120. package/dist/src/storage/local/LocalLogStore.js +66 -0
  121. package/dist/src/storage/local/LocalLogStore.js.map +1 -0
  122. package/dist/src/storage/local/LocalObjectStore.d.ts +52 -0
  123. package/dist/src/storage/local/LocalObjectStore.d.ts.map +1 -0
  124. package/dist/src/storage/local/LocalObjectStore.js +287 -0
  125. package/dist/src/storage/local/LocalObjectStore.js.map +1 -0
  126. package/dist/src/storage/local/LocalRefStore.d.ts +50 -0
  127. package/dist/src/storage/local/LocalRefStore.d.ts.map +1 -0
  128. package/dist/src/storage/local/LocalRefStore.js +337 -0
  129. package/dist/src/storage/local/LocalRefStore.js.map +1 -0
  130. package/dist/src/storage/local/LocalRepoStore.d.ts +53 -0
  131. package/dist/src/storage/local/LocalRepoStore.d.ts.map +1 -0
  132. package/dist/src/storage/local/LocalRepoStore.js +353 -0
  133. package/dist/src/storage/local/LocalRepoStore.js.map +1 -0
  134. package/dist/src/storage/local/gc.d.ts +92 -0
  135. package/dist/src/storage/local/gc.d.ts.map +1 -0
  136. package/dist/src/storage/local/gc.js +322 -0
  137. package/dist/src/storage/local/gc.js.map +1 -0
  138. package/dist/src/storage/local/index.d.ts +17 -0
  139. package/dist/src/storage/local/index.d.ts.map +1 -0
  140. package/dist/src/storage/local/index.js +17 -0
  141. package/dist/src/storage/local/index.js.map +1 -0
  142. package/dist/src/storage/local/localHelpers.d.ts +25 -0
  143. package/dist/src/storage/local/localHelpers.d.ts.map +1 -0
  144. package/dist/src/storage/local/localHelpers.js +69 -0
  145. package/dist/src/storage/local/localHelpers.js.map +1 -0
  146. package/dist/src/{repository.d.ts → storage/local/repository.d.ts} +8 -4
  147. package/dist/src/storage/local/repository.d.ts.map +1 -0
  148. package/dist/src/{repository.js → storage/local/repository.js} +31 -29
  149. package/dist/src/storage/local/repository.js.map +1 -0
  150. package/dist/src/tasks.d.ts +16 -10
  151. package/dist/src/tasks.d.ts.map +1 -1
  152. package/dist/src/tasks.js +35 -41
  153. package/dist/src/tasks.js.map +1 -1
  154. package/dist/src/test-helpers.d.ts +4 -4
  155. package/dist/src/test-helpers.d.ts.map +1 -1
  156. package/dist/src/test-helpers.js +7 -21
  157. package/dist/src/test-helpers.js.map +1 -1
  158. package/dist/src/trees.d.ts +89 -27
  159. package/dist/src/trees.d.ts.map +1 -1
  160. package/dist/src/trees.js +218 -100
  161. package/dist/src/trees.js.map +1 -1
  162. package/dist/src/uuid.d.ts +26 -0
  163. package/dist/src/uuid.d.ts.map +1 -0
  164. package/dist/src/uuid.js +80 -0
  165. package/dist/src/uuid.js.map +1 -0
  166. package/dist/src/workspaceStatus.d.ts +6 -4
  167. package/dist/src/workspaceStatus.d.ts.map +1 -1
  168. package/dist/src/workspaceStatus.js +43 -49
  169. package/dist/src/workspaceStatus.js.map +1 -1
  170. package/dist/src/workspaces.d.ts +35 -26
  171. package/dist/src/workspaces.d.ts.map +1 -1
  172. package/dist/src/workspaces.js +169 -118
  173. package/dist/src/workspaces.js.map +1 -1
  174. package/package.json +4 -4
  175. package/dist/src/gc.d.ts +0 -54
  176. package/dist/src/gc.d.ts.map +0 -1
  177. package/dist/src/gc.js +0 -233
  178. package/dist/src/gc.js.map +0 -1
  179. package/dist/src/repository.d.ts.map +0 -1
  180. package/dist/src/repository.js.map +0 -1
  181. package/dist/src/workspaceLock.d.ts +0 -67
  182. package/dist/src/workspaceLock.d.ts.map +0 -1
  183. package/dist/src/workspaceLock.js +0 -217
  184. package/dist/src/workspaceLock.js.map +0 -1
@@ -0,0 +1,353 @@
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 { RepoNotFoundError, RepoAlreadyExistsError, RepoStatusConflictError, } from '../../errors.js';
8
+ import { decodeBeast2For } from '@elaraai/east';
9
+ import { WorkspaceStateType } from '@elaraai/e3-types';
10
+ const METADATA_FILENAME = '.e3-metadata.json';
11
+ /**
12
+ * Local filesystem implementation of RepoStore.
13
+ *
14
+ * Manages repository lifecycle for local e3 repositories stored
15
+ * as subdirectories within a parent directory.
16
+ */
17
+ export class LocalRepoStore {
18
+ reposDir;
19
+ refs;
20
+ /**
21
+ * Create a new LocalRepoStore.
22
+ * @param reposDir - Parent directory containing repositories
23
+ * @param refs - RefStore for reading package/workspace/execution refs
24
+ */
25
+ constructor(reposDir, refs) {
26
+ this.reposDir = reposDir;
27
+ this.refs = refs;
28
+ }
29
+ /**
30
+ * Get the path to a repository directory.
31
+ */
32
+ getRepoPath(repo) {
33
+ return path.join(this.reposDir, repo);
34
+ }
35
+ /**
36
+ * Get the path to a repository's metadata file.
37
+ */
38
+ getMetadataPath(repo) {
39
+ return path.join(this.getRepoPath(repo), METADATA_FILENAME);
40
+ }
41
+ /**
42
+ * Check if a directory is a valid e3 repository.
43
+ */
44
+ async isValidRepository(repoPath) {
45
+ const requiredDirs = ['objects', 'packages', 'executions', 'workspaces'];
46
+ for (const dir of requiredDirs) {
47
+ try {
48
+ const stat = await fs.stat(path.join(repoPath, dir));
49
+ if (!stat.isDirectory()) {
50
+ return false;
51
+ }
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ }
57
+ return true;
58
+ }
59
+ // ===========================================================================
60
+ // Queries
61
+ // ===========================================================================
62
+ async list() {
63
+ const repos = [];
64
+ try {
65
+ const entries = await fs.readdir(this.reposDir, { withFileTypes: true });
66
+ for (const entry of entries) {
67
+ if (entry.isDirectory()) {
68
+ const repoPath = path.join(this.reposDir, entry.name);
69
+ if (await this.isValidRepository(repoPath)) {
70
+ repos.push(entry.name);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ catch {
76
+ // reposDir doesn't exist or can't be read
77
+ }
78
+ return repos;
79
+ }
80
+ async exists(repo) {
81
+ const repoPath = this.getRepoPath(repo);
82
+ return this.isValidRepository(repoPath);
83
+ }
84
+ async getMetadata(repo) {
85
+ const repoPath = this.getRepoPath(repo);
86
+ // Check if repo exists
87
+ if (!(await this.isValidRepository(repoPath))) {
88
+ return null;
89
+ }
90
+ const metadataPath = this.getMetadataPath(repo);
91
+ try {
92
+ const content = await fs.readFile(metadataPath, 'utf-8');
93
+ const metadata = JSON.parse(content);
94
+ return {
95
+ name: metadata.name,
96
+ status: metadata.status,
97
+ createdAt: metadata.createdAt,
98
+ statusChangedAt: metadata.statusChangedAt,
99
+ };
100
+ }
101
+ catch {
102
+ // No metadata file - synthesize for legacy repos
103
+ // Get mtime from repo directory for createdAt
104
+ try {
105
+ const stat = await fs.stat(repoPath);
106
+ const createdAt = stat.birthtime.toISOString();
107
+ return {
108
+ name: repo,
109
+ status: 'active',
110
+ createdAt,
111
+ statusChangedAt: createdAt,
112
+ };
113
+ }
114
+ catch {
115
+ return null;
116
+ }
117
+ }
118
+ }
119
+ // ===========================================================================
120
+ // Lifecycle
121
+ // ===========================================================================
122
+ async create(repo) {
123
+ const repoPath = this.getRepoPath(repo);
124
+ // Check if already exists
125
+ if (await this.isValidRepository(repoPath)) {
126
+ throw new RepoAlreadyExistsError(repo);
127
+ }
128
+ // Create directory structure
129
+ await fs.mkdir(repoPath, { recursive: true });
130
+ await fs.mkdir(path.join(repoPath, 'objects'), { recursive: true });
131
+ await fs.mkdir(path.join(repoPath, 'packages'), { recursive: true });
132
+ await fs.mkdir(path.join(repoPath, 'executions'), { recursive: true });
133
+ await fs.mkdir(path.join(repoPath, 'workspaces'), { recursive: true });
134
+ // Write metadata file
135
+ const now = new Date().toISOString();
136
+ const metadata = {
137
+ name: repo,
138
+ status: 'active',
139
+ createdAt: now,
140
+ statusChangedAt: now,
141
+ };
142
+ await fs.writeFile(this.getMetadataPath(repo), JSON.stringify(metadata, null, 2));
143
+ }
144
+ async setStatus(repo, status, expected) {
145
+ const current = await this.getMetadata(repo);
146
+ if (!current) {
147
+ throw new RepoNotFoundError(repo);
148
+ }
149
+ // Check expected status (CAS)
150
+ if (expected !== undefined) {
151
+ const expectedArray = Array.isArray(expected) ? expected : [expected];
152
+ if (!expectedArray.includes(current.status)) {
153
+ throw new RepoStatusConflictError(repo, expected, current.status);
154
+ }
155
+ }
156
+ // Update metadata
157
+ const now = new Date().toISOString();
158
+ const metadata = {
159
+ name: current.name,
160
+ status,
161
+ createdAt: current.createdAt,
162
+ statusChangedAt: now,
163
+ };
164
+ // Atomic write using rename
165
+ const metadataPath = this.getMetadataPath(repo);
166
+ const tempPath = `${metadataPath}.tmp`;
167
+ await fs.writeFile(tempPath, JSON.stringify(metadata, null, 2));
168
+ await fs.rename(tempPath, metadataPath);
169
+ }
170
+ async remove(repo) {
171
+ const repoPath = this.getRepoPath(repo);
172
+ try {
173
+ // Remove the entire repository directory
174
+ await fs.rm(repoPath, { recursive: true, force: true });
175
+ }
176
+ catch {
177
+ // Ignore errors if directory doesn't exist
178
+ }
179
+ }
180
+ // ===========================================================================
181
+ // Batched Deletion
182
+ // ===========================================================================
183
+ async deleteRefsBatch(repo, _cursor) {
184
+ const repoPath = this.getRepoPath(repo);
185
+ let deleted = 0;
186
+ // For local storage, we delete all refs in one pass
187
+ // (packages/, workspaces/, executions/, locks/)
188
+ const refDirs = ['packages', 'workspaces', 'executions', 'locks'];
189
+ for (const dir of refDirs) {
190
+ const dirPath = path.join(repoPath, dir);
191
+ try {
192
+ deleted += await this.deleteDirectoryContents(dirPath);
193
+ }
194
+ catch {
195
+ // Directory doesn't exist
196
+ }
197
+ }
198
+ return { status: 'done', deleted };
199
+ }
200
+ async deleteObjectsBatch(repo, _cursor) {
201
+ const repoPath = this.getRepoPath(repo);
202
+ const objectsDir = path.join(repoPath, 'objects');
203
+ let deleted = 0;
204
+ try {
205
+ deleted = await this.deleteDirectoryContents(objectsDir);
206
+ }
207
+ catch {
208
+ // objects dir doesn't exist
209
+ }
210
+ return { status: 'done', deleted };
211
+ }
212
+ /**
213
+ * Recursively delete all contents of a directory.
214
+ * Returns count of files deleted.
215
+ */
216
+ async deleteDirectoryContents(dir) {
217
+ let count = 0;
218
+ try {
219
+ const entries = await fs.readdir(dir, { withFileTypes: true });
220
+ for (const entry of entries) {
221
+ const entryPath = path.join(dir, entry.name);
222
+ if (entry.isDirectory()) {
223
+ count += await this.deleteDirectoryContents(entryPath);
224
+ await fs.rmdir(entryPath);
225
+ }
226
+ else {
227
+ await fs.unlink(entryPath);
228
+ count++;
229
+ }
230
+ }
231
+ }
232
+ catch {
233
+ // Directory doesn't exist or can't be read
234
+ }
235
+ return count;
236
+ }
237
+ // ===========================================================================
238
+ // GC Primitives
239
+ // ===========================================================================
240
+ // Note: GC primitives receive `repo` as a full path (same as ObjectStore/RefStore),
241
+ // NOT as a repo name relative to reposDir. This is consistent with how all
242
+ // storage interfaces work in the local implementation.
243
+ async gcScanPackageRoots(repo, _cursor) {
244
+ const roots = [];
245
+ const packages = await this.refs.packageList(repo);
246
+ for (const { name, version } of packages) {
247
+ const hash = await this.refs.packageResolve(repo, name, version);
248
+ if (hash) {
249
+ roots.push(hash);
250
+ }
251
+ }
252
+ return { roots };
253
+ }
254
+ async gcScanWorkspaceRoots(repo, _cursor) {
255
+ const roots = [];
256
+ const decoder = decodeBeast2For(WorkspaceStateType);
257
+ const names = await this.refs.workspaceList(repo);
258
+ for (const name of names) {
259
+ const data = await this.refs.workspaceRead(repo, name);
260
+ if (!data || data.length === 0)
261
+ continue;
262
+ try {
263
+ const state = decoder(data);
264
+ roots.push(state.packageHash);
265
+ roots.push(state.rootHash);
266
+ }
267
+ catch {
268
+ // Corrupt workspace state - skip
269
+ }
270
+ }
271
+ return { roots };
272
+ }
273
+ async gcScanExecutionRoots(repo, _cursor) {
274
+ const roots = [];
275
+ const entries = await this.refs.executionList(repo);
276
+ for (const { taskHash, inputsHash } of entries) {
277
+ const ids = await this.refs.executionListIds(repo, taskHash, inputsHash);
278
+ for (const executionId of ids) {
279
+ const status = await this.refs.executionGet(repo, taskHash, inputsHash, executionId);
280
+ if (!status)
281
+ continue;
282
+ // ExecutionStatus is a variant; extract outputHash from success
283
+ const raw = status;
284
+ if (raw.type === 'success' && raw.value.outputHash && /^[a-f0-9]{64}$/.test(raw.value.outputHash)) {
285
+ roots.push(raw.value.outputHash);
286
+ }
287
+ }
288
+ }
289
+ return { roots };
290
+ }
291
+ async gcScanObjects(repo, _cursor) {
292
+ const objectsDir = path.join(repo, 'objects');
293
+ const objects = [];
294
+ try {
295
+ const subdirs = await fs.readdir(objectsDir);
296
+ for (const subdir of subdirs) {
297
+ if (!/^[a-f0-9]{2}$/.test(subdir))
298
+ continue;
299
+ const subdirPath = path.join(objectsDir, subdir);
300
+ try {
301
+ const stat = await fs.stat(subdirPath);
302
+ if (!stat.isDirectory())
303
+ continue;
304
+ }
305
+ catch {
306
+ continue;
307
+ }
308
+ const files = await fs.readdir(subdirPath);
309
+ for (const file of files) {
310
+ if (file.endsWith('.partial'))
311
+ continue;
312
+ if (!file.endsWith('.beast2'))
313
+ continue;
314
+ const hash = subdir + file.slice(0, -7); // remove .beast2
315
+ try {
316
+ const fileStat = await fs.stat(path.join(subdirPath, file));
317
+ objects.push({ hash, lastModified: fileStat.mtimeMs, size: fileStat.size });
318
+ }
319
+ catch {
320
+ // Skip files we can't stat
321
+ }
322
+ }
323
+ }
324
+ }
325
+ catch {
326
+ // Objects directory doesn't exist
327
+ }
328
+ // Local returns all in one batch (no cursor)
329
+ return { objects };
330
+ }
331
+ async gcDeleteObjects(repo, hashes) {
332
+ const objectsDir = path.join(repo, 'objects');
333
+ for (const hash of hashes) {
334
+ const subdir = hash.slice(0, 2);
335
+ const rest = hash.slice(2);
336
+ const filePath = path.join(objectsDir, subdir, `${rest}.beast2`);
337
+ try {
338
+ await fs.unlink(filePath);
339
+ }
340
+ catch {
341
+ // File doesn't exist
342
+ }
343
+ // Try to remove empty subdirectory
344
+ try {
345
+ await fs.rmdir(path.join(objectsDir, subdir));
346
+ }
347
+ catch {
348
+ // Directory not empty or doesn't exist
349
+ }
350
+ }
351
+ }
352
+ }
353
+ //# sourceMappingURL=LocalRepoStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalRepoStore.js","sourceRoot":"","sources":["../../../../src/storage/local/LocalRepoStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAW7B,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAYvD,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAON;IACA;IAPnB;;;;OAIG;IACH,YACmB,QAAgB,EAChB,IAAc;QADd,aAAQ,GAAR,QAAQ,CAAQ;QAChB,SAAI,GAAJ,IAAI,CAAU;IAC9B,CAAC;IAEJ;;OAEG;IACK,WAAW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;QAAC,MAAM,CAAC;YACP,kCAAkC;QACpC,CAAC;QAED,6CAA6C;QAC7C,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,IAAY,EAAE,MAAgB;QAClD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAE9C,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAChC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,SAAS,CAAC,CAAC;YACjE,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC5B,CAAC;YAAC,MAAM,CAAC;gBACP,qBAAqB;YACvB,CAAC;YACD,mCAAmC;YACnC,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;YAChD,CAAC;YAAC,MAAM,CAAC;gBACP,uCAAuC;YACzC,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ import type { RepoStore, GcObjectEntry, StorageBackend } from '../interfaces.js';
6
+ /**
7
+ * Options for garbage collection
8
+ */
9
+ export interface GcOptions {
10
+ /**
11
+ * Minimum age in milliseconds for files to be considered for deletion.
12
+ * Files younger than this are skipped to avoid race conditions with concurrent writes.
13
+ * Default: 60000 (1 minute)
14
+ */
15
+ minAge?: number;
16
+ /**
17
+ * If true, only report what would be deleted without actually deleting.
18
+ * Default: false
19
+ */
20
+ dryRun?: boolean;
21
+ }
22
+ /**
23
+ * Result of garbage collection
24
+ */
25
+ export interface GcResult {
26
+ /** Number of objects deleted */
27
+ deletedObjects: number;
28
+ /** Number of orphaned staging files deleted */
29
+ deletedPartials: number;
30
+ /** Number of objects retained */
31
+ retainedObjects: number;
32
+ /** Number of files skipped due to being too young */
33
+ skippedYoung: number;
34
+ /** Total bytes freed */
35
+ bytesFreed: number;
36
+ }
37
+ /**
38
+ * Result from sweepBatch — pure decision, no side effects.
39
+ */
40
+ export interface SweepBatchResult {
41
+ /** Hashes of objects to delete */
42
+ toDelete: string[];
43
+ /** Number of objects retained (reachable) */
44
+ retained: number;
45
+ /** Number of objects skipped due to being too young */
46
+ skippedYoung: number;
47
+ /** Total bytes that would be freed */
48
+ bytesFreed: number;
49
+ }
50
+ /**
51
+ * Collect all root hashes from packages, workspaces, and executions.
52
+ *
53
+ * Calls each gcScan*Roots method with pagination support.
54
+ * Adding a new root scan method to RepoStore requires updating this function.
55
+ */
56
+ export declare function collectAllRoots(store: RepoStore, repo: string): Promise<Set<string>>;
57
+ /**
58
+ * Trace the object graph from roots using iterative DFS with schema-aware traversal.
59
+ *
60
+ * Decodes each object using BEAST2 self-describing format and extracts child
61
+ * hashes based on the detected object type (Package, Task, or Tree). Objects
62
+ * known to be leaves (values, IR blobs) are marked reachable without reading.
63
+ *
64
+ * @param readObject - Function to read an object by hash (returns null if missing)
65
+ * @param roots - Set of root hashes to start from
66
+ * @returns Set of all reachable hashes
67
+ */
68
+ export declare function markReachable(readObject: (hash: string) => Promise<Uint8Array | null>, roots: Set<string>): Promise<Set<string>>;
69
+ /**
70
+ * Pure decision function: determine which objects to delete.
71
+ *
72
+ * No side effects — trivially testable. Caller decides whether to
73
+ * actually delete (supports dry-run by skipping gcDeleteObjects).
74
+ *
75
+ * @param objects - Object entries from gcScanObjects
76
+ * @param reachable - Set of reachable hashes from markReachable
77
+ * @param minAge - Minimum age in ms; objects younger than this are skipped
78
+ * @returns Decision result with toDelete list and stats
79
+ */
80
+ export declare function sweepBatch(objects: GcObjectEntry[], reachable: Set<string>, minAge: number): SweepBatchResult;
81
+ /**
82
+ * Run garbage collection on an e3 repository.
83
+ *
84
+ * Works with any StorageBackend — no instanceof checks.
85
+ *
86
+ * @param storage - Storage backend
87
+ * @param repo - Repository identifier
88
+ * @param options - GC options
89
+ * @returns GC result with statistics
90
+ */
91
+ export declare function repoGc(storage: StorageBackend, repo: string, options?: GcOptions): Promise<GcResult>;
92
+ //# sourceMappingURL=gc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gc.d.ts","sourceRoot":"","sources":["../../../../src/storage/local/gc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAoB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEnG;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,gCAAgC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,eAAe,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,K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