@elaraai/east-node-cli 1.0.78 → 1.0.80

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/dist/merge.js CHANGED
@@ -3,54 +3,112 @@
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
5
  /**
6
- * The blob merge behind `east-node merge` (issue #770).
6
+ * The blob merge behind an `exec` merge unit (issue #770).
7
7
  *
8
- * Canonical Set or Dict blobs of one type in — sorted, indexed beast2 v5
9
- * collections, as every runner writes them — and one canonical blob out, in
10
- * a single pass: every input is read segment by segment through positioned
11
- * reads on its descriptor, a heap over the inputs' current entries yields
12
- * keys in East order, and the output is written through the same segment
13
- * writer as `run --emit`, so the file is byte-identical to what that sink
14
- * writes for the same entries emitted ascending. Memory is one decoded
15
- * segment per input plus one open batch; no temporary file is ever written.
8
+ * Canonical Set or Dict collections of one type in — sorted, indexed beast2 v5
9
+ * blobs, or manifest directories, as a unit's parts are staged — and one
10
+ * canonical collection out, merged by the library's `mergeBeast2For`: every
11
+ * input is read segment by segment through positioned reads, and the output is
12
+ * written through the canonical element writer, so it is byte-identical to
13
+ * what that writer writes for the merged value. Memory is one decoded segment
14
+ * per input plus one open output segment; no temporary file is ever written.
15
+ * This module opens and checks the inputs, reads the key range and loads the
16
+ * fold, refusing each in the words east-c and east-py use.
16
17
  *
17
18
  * Equal keys across inputs fold in input order: with a merge function (Dict
18
19
  * inputs) `acc = merge(key, acc, value)`; in union mode (Set inputs) the
19
- * first element stands. Without a fold, an equal key is the duplicate error
20
- * the emit sink raises. An input whose keys do not ascend, an input whose
21
- * type is not input 0's, and an Array input are refused.
20
+ * first element stands. Without a fold, an equal key is the library's
21
+ * duplicate error. An input whose keys do not ascend, an input whose type is
22
+ * not input 0's, and an Array input are refused.
22
23
  *
23
- * With a key range (`--range`, a blob of `Struct{from: Option<K>, to:
24
- * Option<K>}` over the inputs' key type) only the keys in `[from, to)`
25
- * merge: every input is sought to the segment owning `from` through its
26
- * fences and read up to the first key at or past `to`, so a unit over a
27
- * range of a large output reads that range's share of each input, plus at
28
- * most one segment. An absent bound is open; both absent is the whole merge.
24
+ * With a key range (a blob of `Struct{from: Option<K>, to: Option<K>}` over
25
+ * the inputs' key type) only the keys in `[from, to)` merge: every input is
26
+ * sought to the segment owning `from` through its fences and read up to the
27
+ * first key at or past `to`, so a unit over a range of a large output reads
28
+ * that range's share of each input, plus at most one segment. An absent bound
29
+ * is open; both absent is the whole merge.
29
30
  *
30
- * This is the fan-in of a partitioned task's keyed partials: e3 runs it as an
31
- * ordinary execution on the task's runner, one unit per key range of a group
32
- * of partials, and never decodes a partial itself. east-c and east-py merge
33
- * through the same contract, so the three runners write the same bytes.
31
+ * This is the fan-in of a split task's set and dict parts: e3 runs it as a
32
+ * merge unit on the task's runner, one per key range of a group of parts, and
33
+ * never decodes a part itself. east-c and east-py merge through the same
34
+ * contract, so the three runners write the same bytes.
34
35
  */
35
- import { closeSync, fstatSync, openSync, readFileSync, readSync } from 'fs';
36
- import { OptionType, SortedMap, SortedSet, StructType, compareFor, decodeBeast2For, fromEastTypeValue, isTypeValueEqual, openBeast2LazyFor, printFor, readBeast2Extents, readBeast2HeaderType, readBeast2Type, toEastTypeValue, } from '@elaraai/east';
36
+ import { closeSync, fstatSync, openSync, readFileSync, readSync, statSync, writeSync } from 'fs';
37
+ import { OptionType, StructType, decodeBeast2For, fromEastTypeValue, isTypeValueEqual, mergeBeast2For, readBeast2Extents, readBeast2HeaderType, readBeast2Manifest, readBeast2Type, toEastTypeValue, } from '@elaraai/east';
37
38
  import { printTypeValue } from '@elaraai/east/internal';
38
- import { EmitFileWriter } from './emit-writer.js';
39
- import { duplicateMessage, formatFileSize, loadMergeFunction } from './runner.js';
39
+ import { segmentDirFor } from './loader.js';
40
+ import { loadMergeFunction } from './runner.js';
41
+ /** Writes all of `bytes` to `fd` — `writeSync` may write fewer bytes than
42
+ * asked, and a silently short write would corrupt the file. */
43
+ function writeAll(fd, bytes) {
44
+ let written = 0;
45
+ while (written < bytes.length) {
46
+ written += writeSync(fd, bytes, written, bytes.length - written);
47
+ }
48
+ }
49
+ /** Exactly `length` bytes of the file open as `fd`, from `offset`. */
50
+ function readExactly(fd, offset, length) {
51
+ const out = new Uint8Array(length);
52
+ let done = 0;
53
+ while (done < length) {
54
+ const n = readSync(fd, out, done, length - done, offset + done);
55
+ if (n === 0)
56
+ throw new Error(`beast2: short read at offset ${offset + done}`);
57
+ done += n;
58
+ }
59
+ return out;
60
+ }
40
61
  /**
41
- * Opens input `index` at `path`: reads its geometry and type, and prepares a
42
- * segment-by-segment iteration of its entries — from the first key, or from
43
- * a range's lower bound, whose owning segment the lazy value seeks through
44
- * the fences.
62
+ * The segments of the manifest directory at `path`, each read through
63
+ * positioned reads on its file in `<path>.segments/`, the convention e3 stages
64
+ * inputs in. A segment's file is opened for each read and closed after it, so
65
+ * a merge of a large manifest holds no descriptor per segment.
45
66
  *
46
- * @param path - the blob
67
+ * @param path - the manifest's file
68
+ * @param manifest - its decoded manifest
69
+ * @returns the source the merge reads the input through
70
+ */
71
+ function manifestSource(path, manifest) {
72
+ const dir = segmentDirFor(path);
73
+ return {
74
+ manifest,
75
+ segment(i) {
76
+ const file = `${dir}/${manifest.entries[i].hash}.beast2`;
77
+ let size;
78
+ try {
79
+ size = statSync(file).size;
80
+ }
81
+ catch {
82
+ throw new Error(`beast2 v5: manifest segment ${file} cannot be read`);
83
+ }
84
+ return {
85
+ size,
86
+ read(offset, length) {
87
+ const fd = openSync(file, 'r');
88
+ try {
89
+ return readExactly(fd, offset, length);
90
+ }
91
+ finally {
92
+ closeSync(fd);
93
+ }
94
+ },
95
+ };
96
+ },
97
+ };
98
+ }
99
+ /**
100
+ * Opens input `index` at `path` and checks it is a canonical Set or Dict
101
+ * collection of `expected`'s type: a blob, read through positioned reads on
102
+ * its descriptor, or a manifest directory, read through its segment files.
103
+ *
104
+ * @param path - the blob, or the manifest's file
47
105
  * @param index - the input's position, for messages
48
106
  * @param expected - input 0's type, or `null` for input 0 itself
49
107
  * @returns the opened input and its type
50
108
  * @throws {Error} When the file cannot be opened (missing, unreadable, not
51
109
  * a regular file), is not a blob (too short, or without the magic — the
52
- * reader's own words), cannot be read as a canonical collection blob, or
53
- * its type is not `expected`.
110
+ * reader's own words), cannot be read as a canonical collection blob or a
111
+ * manifest, or its type is not `expected`.
54
112
  */
55
113
  function openInput(path, index, expected) {
56
114
  let fd;
@@ -71,100 +129,54 @@ function openInput(path, index, expected) {
71
129
  closeSync(fd);
72
130
  throw new Error(`merge: input ${index} (${path}): cannot open the file`);
73
131
  }
74
- const reader = {
75
- size,
76
- read(offset, length) {
77
- const out = new Uint8Array(length);
78
- let done = 0;
79
- while (done < length) {
80
- const n = readSync(fd, out, done, length - done, offset + done);
81
- if (n === 0)
82
- throw new Error(`beast2: short read at offset ${offset + done}`);
83
- done += n;
84
- }
85
- return out;
86
- },
87
- };
88
- const prefixed = (err) => new Error(`merge: input ${index} (${path}): ${err.message ?? String(err)}`);
132
+ const reader = { size, read: (offset, length) => readExactly(fd, offset, length) };
133
+ let manifest;
89
134
  let type;
90
- let lazy;
135
+ let selfContained;
91
136
  try {
92
137
  // The header first: a file too short for a blob, or one without the
93
138
  // magic, is refused in the reader's words — the sentence east-c and
94
139
  // east-py give for the same bytes — before the index is looked for.
95
140
  readBeast2HeaderType(reader);
96
- const extents = readBeast2Extents(reader);
97
- type = extents.typeValue;
98
- if (expected !== null && !isTypeValueEqual(type, expected)) {
99
- closeSync(fd);
100
- throw new Error(`merge: input ${index} (${path}) has type ${printTypeValue(type)}, expected ${printTypeValue(expected)} (input 0)`);
141
+ // A manifest directory is the collection its manifest names, its
142
+ // segments standalone blobs, each self-contained.
143
+ manifest = readBeast2Manifest(reader);
144
+ if (manifest !== null) {
145
+ type = manifest.type;
146
+ selfContained = true;
101
147
  }
102
- if (type.type !== 'Set' && type.type !== 'Dict') {
103
- closeSync(fd);
104
- throw new Error(`merge: inputs must be Set or Dict blobs, got ${type.type}`);
148
+ else {
149
+ const extents = readBeast2Extents(reader);
150
+ type = extents.typeValue;
151
+ selfContained = extents.selfContained;
105
152
  }
106
- if (!extents.selfContained)
107
- throw new Error('the blob is not self-contained');
108
- lazy = openBeast2LazyFor(type, { frozen: true })(reader);
109
153
  }
110
154
  catch (err) {
111
- const message = err.message ?? '';
112
- if (message.startsWith('merge: '))
113
- throw err;
114
155
  closeSync(fd);
115
- throw prefixed(err);
156
+ throw new Error(`merge: input ${index} (${path}): ${err.message ?? String(err)}`);
116
157
  }
117
- const dict = type.type === 'Dict';
118
- return {
119
- type,
120
- close: () => closeSync(fd),
121
- start: (range, cmp) => {
122
- // The lazy value streams one decoded segment at a time, checking
123
- // the ascent within and across segments as the eager decoder does;
124
- // from a lower bound it starts at the segment owning it.
125
- let iterator;
126
- try {
127
- iterator = dict
128
- ? lazy.entries(range.from)
129
- : lazy.keys(range.from);
130
- }
131
- catch (err) {
132
- throw prefixed(err);
133
- }
134
- let exhausted = false;
135
- const input = {
136
- head: null,
137
- advance: () => {
138
- if (exhausted)
139
- return;
140
- let next;
141
- try {
142
- next = iterator.next();
143
- }
144
- catch (err) {
145
- throw prefixed(err);
146
- }
147
- if (next.done) {
148
- exhausted = true;
149
- input.head = null;
150
- return;
151
- }
152
- const [key, value] = dict ? next.value : [next.value, undefined];
153
- // The first key at or past the upper bound ends the input.
154
- if (range.to !== undefined && cmp(key, range.to) >= 0) {
155
- exhausted = true;
156
- input.head = null;
157
- return;
158
- }
159
- input.head = { key, value };
160
- },
161
- };
162
- return input;
163
- },
164
- };
158
+ let refusal = null;
159
+ if (expected !== null && !isTypeValueEqual(type, expected)) {
160
+ refusal = `merge: input ${index} (${path}) has type ${printTypeValue(type)}, expected ${printTypeValue(expected)} (input 0)`;
161
+ }
162
+ else if (type.type !== 'Set' && type.type !== 'Dict') {
163
+ refusal = `merge: inputs must be Set or Dict blobs, got ${type.type}`;
164
+ }
165
+ else if (!selfContained) {
166
+ refusal = `merge: input ${index} (${path}): the blob is not self-contained`;
167
+ }
168
+ if (refusal !== null) {
169
+ closeSync(fd);
170
+ throw new Error(refusal);
171
+ }
172
+ if (manifest === null)
173
+ return { type, source: reader, close: () => closeSync(fd) };
174
+ // The manifest is read; the segments are read from their own files.
175
+ closeSync(fd);
176
+ return { type, source: manifestSource(path, manifest), close: () => { } };
165
177
  }
166
178
  /**
167
- * Reads a `--range` blob: `Struct{from: Option<K>, to: Option<K>}` over the
179
+ * Reads a range blob: `Struct{from: Option<K>, to: Option<K>}` over the
168
180
  * inputs' key type, self-describing, checked against that type.
169
181
  *
170
182
  * @param path - the blob
@@ -179,10 +191,10 @@ function readRange(path, keyType) {
179
191
  bytes = new Uint8Array(readFileSync(path));
180
192
  }
181
193
  catch {
182
- throw new Error(`merge: --range (${path}): cannot open the file`);
194
+ throw new Error(`merge: range (${path}): cannot open the file`);
183
195
  }
184
196
  // The same shape east-c builds (merge.c) and e3-core writes
185
- // (partitionExec.ts): the bounds struct over the key type.
197
+ // (execution/steps.ts): the bounds struct over the key type.
186
198
  const key = fromEastTypeValue(keyType);
187
199
  const rangeType = toEastTypeValue(StructType({ from: OptionType(key), to: OptionType(key) }));
188
200
  let type;
@@ -190,17 +202,17 @@ function readRange(path, keyType) {
190
202
  type = readBeast2Type(bytes);
191
203
  }
192
204
  catch (err) {
193
- throw new Error(`merge: --range (${path}): ${err.message ?? String(err)}`);
205
+ throw new Error(`merge: range (${path}): ${err.message ?? String(err)}`);
194
206
  }
195
207
  if (!isTypeValueEqual(type, rangeType)) {
196
- throw new Error(`merge: --range (${path}) has type ${printTypeValue(type)}, expected ${printTypeValue(rangeType)} (bounds over the inputs' key type)`);
208
+ throw new Error(`merge: range (${path}) has type ${printTypeValue(type)}, expected ${printTypeValue(rangeType)} (bounds over the inputs' key type)`);
197
209
  }
198
210
  let bounds;
199
211
  try {
200
212
  bounds = decodeBeast2For(rangeType)(bytes);
201
213
  }
202
214
  catch (err) {
203
- throw new Error(`merge: --range (${path}): ${err.message ?? String(err)}`);
215
+ throw new Error(`merge: range (${path}): ${err.message ?? String(err)}`);
204
216
  }
205
217
  return {
206
218
  from: bounds.from.type === 'some' ? bounds.from.value : undefined,
@@ -208,135 +220,69 @@ function readRange(path, keyType) {
208
220
  };
209
221
  }
210
222
  /**
211
- * Merges sorted Set or Dict blobs of one type into one canonical blob — the
212
- * `merge` command.
223
+ * Merges sorted Set or Dict blobs of one type into one canonical collection —
224
+ * an `exec` merge unit's set or dict parts.
213
225
  *
214
226
  * @param inputPaths - the inputs, in the order equal keys fold; at least one
215
- * @param outputPath - the output blob
216
- * @param options - the fold, its platforms, the key range, verbosity
227
+ * @param output - the output blob's path, or the sink a manifest directory is
228
+ * written through
229
+ * @param options - the fold, its platforms, the key range
217
230
  * @returns the account: inputs merged, entries written, keys folded
218
231
  * @throws {Error} With the merge's message — an input of another type than
219
232
  * input 0's, an Array input, keys that do not ascend, a fold whose
220
233
  * signature does not match the inputs, a range blob of another shape than
221
234
  * the bounds over the inputs' key type, a file that cannot be opened, a
222
235
  * shared key without a fold — leaving the output unfinalised (no
223
- * terminator or index).
236
+ * terminator or index, or no manifest).
224
237
  */
225
- export function mergeBlobs(inputPaths, outputPath, options = {}) {
226
- const started = performance.now();
238
+ export function mergeBlobs(inputPaths, output, options = {}) {
227
239
  if (inputPaths.length === 0)
228
240
  throw new Error('merge: at least one input is needed');
229
241
  if (options.mergePath !== undefined && options.union) {
230
- throw new Error('merge: --merge and --union are two folds — give one');
242
+ throw new Error('merge: a merge function and union are two folds — give one');
231
243
  }
232
244
  const opened = [];
233
- const inputs = [];
234
- let out = null;
235
- let finished = false;
245
+ let fd = -1;
246
+ let stats;
236
247
  try {
237
248
  const first = openInput(inputPaths[0], 0, null);
238
249
  opened.push(first);
239
250
  const type = first.type;
240
- const kind = type.type === 'Dict' ? 'dict' : 'set';
241
- if (options.mergePath !== undefined && kind !== 'dict')
242
- throw new Error('--merge applies to Dict inputs only');
243
- if (options.union && kind !== 'set')
244
- throw new Error('--union applies to Set inputs only');
245
- const keyType = (kind === 'dict' ? type.value.key : type.value);
246
- const valueType = (kind === 'dict' ? type.value.value : null);
251
+ const dict = type.type === 'Dict';
252
+ if (options.mergePath !== undefined && !dict)
253
+ throw new Error('merge: a merge function applies to Dict inputs only');
254
+ if (options.union && dict)
255
+ throw new Error('merge: union applies to Set inputs only');
256
+ const keyType = (dict ? type.value.key : type.value);
247
257
  const merge = options.mergePath !== undefined
248
- ? loadMergeFunction(options.mergePath, keyType, valueType, options.platformFns ?? [], 'the inputs')
249
- : null;
250
- const union = options.union ?? false;
258
+ ? loadMergeFunction(options.mergePath, keyType, type.value.value, options.platformFns ?? [], 'the inputs')
259
+ : undefined;
251
260
  const range = options.rangePath !== undefined ? readRange(options.rangePath, keyType) : { from: undefined, to: undefined };
252
261
  for (let i = 1; i < inputPaths.length; i++)
253
262
  opened.push(openInput(inputPaths[i], i, type));
254
- const cmp = compareFor(keyType);
255
- const printKey = printFor(keyType);
256
- for (const input of opened)
257
- inputs.push(input.start(range, cmp));
258
- for (const input of inputs)
259
- input.advance();
260
- // A binary min-heap over the inputs' current keys, ordered by (key,
261
- // input index), so equal keys leave in input order.
262
- const heap = [];
263
- for (let i = 0; i < inputs.length; i++)
264
- if (inputs[i].head !== null)
265
- heap.push(i);
266
- const before = (a, b) => {
267
- const order = cmp(inputs[a].head.key, inputs[b].head.key);
268
- return order < 0 || (order === 0 && a < b);
269
- };
270
- const siftDown = (at) => {
271
- for (;;) {
272
- const l = 2 * at + 1;
273
- const r = l + 1;
274
- let least = at;
275
- if (l < heap.length && before(heap[l], heap[least]))
276
- least = l;
277
- if (r < heap.length && before(heap[r], heap[least]))
278
- least = r;
279
- if (least === at)
280
- return;
281
- [heap[at], heap[least]] = [heap[least], heap[at]];
282
- at = least;
283
- }
284
- };
285
- for (let i = (heap.length >> 1) - 1; i >= 0; i--)
286
- siftDown(i);
287
- out = new EmitFileWriter(kind, type, outputPath);
288
- let entries = 0;
289
- let folds = 0;
290
- // The current key's entry is held until a greater key arrives, so
291
- // every equal key folds into it before it is written.
292
- let held = null;
293
- const put = (entry) => {
294
- out.push(kind === 'dict' ? [entry.key, entry.value] : entry.key);
295
- entries++;
296
- };
297
- while (heap.length > 0) {
298
- const input = inputs[heap[0]];
299
- const { key, value } = input.head;
300
- if (held !== null && cmp(held.key, key) === 0) {
301
- if (merge !== null) {
302
- held.value = merge(key, held.value, value);
303
- }
304
- else if (!union) {
305
- throw new Error(duplicateMessage(kind, printKey, key));
306
- }
307
- folds++;
308
- }
309
- else {
310
- if (held !== null)
311
- put(held);
312
- held = { key, value };
313
- }
314
- input.advance();
315
- if (input.head === null) {
316
- heap[0] = heap[heap.length - 1];
317
- heap.pop();
318
- }
319
- if (heap.length > 0)
320
- siftDown(0);
321
- }
322
- if (held !== null)
323
- put(held);
324
- out.finishClose();
325
- finished = true;
326
- const stats = { inputs: inputs.length, entries, folds };
327
- if (options.verbose) {
328
- console.error(`merge: ${stats.inputs} input(s), ${stats.entries} entries, ${stats.folds} fold(s)`);
329
- console.error(`Output: ${outputPath} (${formatFileSize(outputPath)})`);
330
- console.error('\nTiming:');
331
- console.error(` Total: ${(performance.now() - started).toFixed(1).padStart(8)} ms`);
332
- }
333
- return stats;
263
+ stats = mergeBeast2For(type, {
264
+ ...(merge !== undefined && { merge }),
265
+ union: options.union ?? false,
266
+ from: range.from,
267
+ to: range.to,
268
+ labels: inputPaths,
269
+ // Frames deflate on worker threads (#763).
270
+ parallel: true,
271
+ })(opened.map((input) => input.source), typeof output !== 'string' ? output : (bytes) => {
272
+ // The output is created with its first bytes, which the merge
273
+ // writes once every input has opened, so a refused input leaves
274
+ // no file behind.
275
+ if (fd < 0)
276
+ fd = openSync(output, 'w');
277
+ writeAll(fd, bytes);
278
+ });
334
279
  }
335
280
  finally {
336
281
  for (const input of opened)
337
282
  input.close();
338
- if (out !== null && !finished)
339
- out.closeAbandoned();
283
+ if (fd >= 0)
284
+ closeSync(fd);
340
285
  }
286
+ return stats;
341
287
  }
342
288
  //# sourceMappingURL=merge.js.map
package/dist/merge.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"merge.js","sourceRoot":"","sources":["../src/merge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC5E,OAAO,EACH,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,eAAe,GAElB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAsB,MAAM,aAAa,CAAC;AAsDtG;;;;;;;;;;;;;;GAcG;AACH,SAAS,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,QAA8B;IAC1E,IAAI,EAAU,CAAC;IACf,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACD,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACL,MAAM,IAAI,KAAK,CAAC,gBAAgB,KAAK,KAAK,IAAI,yBAAyB,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,CAAC;QACD,MAAM,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC1D,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAAC,MA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E;YACzB,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC;YACrC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;YAC7B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,MAAM,EAAE,UAAU;YAClB,2CAA2C;YAC3C,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACpF,8DAA8D;YAC9D,gEAAgE;YAChE,kBAAkB;YAClB,IAAI,EAAE,GAAG,CAAC;gBAAE,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YACvC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACP,CAAC;YAAS,CAAC;QACP,KAAK,MAAM,KAAK,IAAI,MAAM;YAAE,KAAK,CAAC,KAAK,EAAE,CAAC;QAC1C,IAAI,EAAE,IAAI,CAAC;YAAE,SAAS,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
package/dist/runner.d.ts CHANGED
@@ -2,13 +2,13 @@
2
2
  * Copyright (c) 2025 Elara AI Pty Ltd
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
+ import { type UnitResult } from '@elaraai/east';
5
6
  import type { PlatformFunction, EastTypeValue } from '@elaraai/east/internal';
6
7
  /** A file's size for the verbose account, or `?` when it cannot be read. @internal */
7
8
  export declare function formatFileSize(path: string): string;
8
- /** Streaming-execution options accepted by {@link runProgram}. */
9
9
  /**
10
- * A refusal of the command line itself — a flag combination, an output
11
- * destination, a function shape the flags do not fit.
10
+ * A refusal of the command line itself — a function the inputs given do not
11
+ * fit.
12
12
  *
13
13
  * These are the user's errors, not the program's, and east-c and east-py
14
14
  * answer them with one sentence on stderr. Marking them lets the CLI do the
@@ -18,55 +18,27 @@ export declare function formatFileSize(path: string): string;
18
18
  export declare class UsageError extends Error {
19
19
  constructor(message: string);
20
20
  }
21
- export interface RunProgramOptions {
22
- /** Enable verbose timing/memory output on stderr. */
23
- verbose?: boolean;
24
- /** Write the output incrementally from the function's trailing `emit`
25
- * parameter instead of its return value. The value names the output
26
- * collection kind; element/key/value types come from the emit
27
- * parameter's function type. */
28
- emit?: 'array' | 'set' | 'dict';
29
- /** Feed these `-i` inputs (0-based) lazily — segment-by-segment
30
- * iteration with O(segment) decoded memory — regardless of size.
31
- * Element shapes the lazy contract excludes (nested mutable
32
- * containers, vectors/matrices, functions) decode whole instead. */
33
- streamInputs?: number[];
34
- /** With `emit: 'dict'`: an IR file (any format the IR positional
35
- * accepts) holding a `(K, V, V) -> V` East function over the emit
36
- * parameter's key and value types, compiled with the run's platforms.
37
- * Adjacent emissions with an equal key fold left with it, in emission
38
- * order. */
39
- merge?: string;
40
- /** With `emit: 'set'`: adjacent equal elements collapse to the first. */
41
- union?: boolean;
42
- /** Open indexed beast2 collection inputs at or above this many bytes as
43
- * lazy pager-backed values (0 disables). Defaults to 64 MiB, or the
44
- * `EAST_LAZY_INPUT_BYTES` environment variable. Applies only to
45
- * shape-gate-safe element types (see `loadInputLazy`) — others always
46
- * decode whole. */
47
- lazyInputBytes?: number;
48
- }
49
- /** Resolves the lazy-open threshold: explicit option, else environment, else
50
- * the default. An unset or empty `EAST_LAZY_INPUT_BYTES` falls through to
51
- * the 64 MiB default (`Number('')` is `0`, which would silently DISABLE
52
- * lazy opening); invalid or negative values fall through too, matching
53
- * east-c and east-py. Exported for the spec only. @internal */
54
- export declare function lazyThreshold(options: RunProgramOptions): number;
21
+ /** Resolves the lazy-open threshold: the environment, else the default. An
22
+ * unset or empty `EAST_LAZY_INPUT_BYTES` falls through to the 64 MiB default
23
+ * (`Number('')` is `0`, which would silently DISABLE lazy opening); invalid
24
+ * or negative values fall through too, matching east-c and east-py. Exported
25
+ * for `exec` and the spec. @internal */
26
+ export declare function lazyThreshold(): number;
55
27
  /**
56
28
  * Runs an East IR program.
57
29
  */
58
- export declare function runProgram(irPath: string, platformFns: PlatformFunction[], packages: string[], inputPaths: string[], outputPath?: string, options?: RunProgramOptions | boolean): Promise<unknown>;
30
+ export declare function runProgram(irPath: string, platformFns: PlatformFunction[], packages: string[], inputPaths: string[], outputPath?: string, verbose?: boolean): Promise<unknown>;
59
31
  /** A compiled `(K, V, V) -> V` fold of equal keys. */
60
32
  export type MergeFunction = (key: unknown, acc: unknown, value: unknown) => unknown;
61
33
  /**
62
- * Loads a `--merge` function: an IR file holding a `(K, V, V) -> V` East
63
- * function over the given key and value types, compiled with the run's
64
- * platforms. Shared by the emit sink and the blob merge.
34
+ * Loads a merge function: an IR file holding a `(K, V, V) -> V` East function
35
+ * over the given key and value types, compiled with the unit's platforms.
36
+ * Shared by `exec`'s dict output and the blob merge.
65
37
  *
66
38
  * @param path - the IR file (any format the IR positional accepts)
67
39
  * @param keyType - the key type
68
40
  * @param valueType - the value type
69
- * @param platformFns - the run's platforms
41
+ * @param platformFns - the unit's platforms
70
42
  * @param subject - what the function must match, for the message: `the emit
71
43
  * parameter` or `the inputs`
72
44
  * @returns the compiled merge function
@@ -75,13 +47,17 @@ export type MergeFunction = (key: unknown, acc: unknown, value: unknown) => unkn
75
47
  */
76
48
  export declare function loadMergeFunction(path: string, keyType: EastTypeValue, valueType: EastTypeValue, platformFns: PlatformFunction[], subject: string): MergeFunction;
77
49
  /**
78
- * The canonical duplicate-key error, identical across runners: the emit
79
- * sink's, and the blob merge's when a key is shared without a fold.
50
+ * Prints a unit's result as `-v` shows it: where the time went, and the
51
+ * process's peak memory.
52
+ *
53
+ * @param result - the result
54
+ */
55
+ export declare function printResult(result: UnitResult): void;
56
+ /**
57
+ * The process's peak resident memory in bytes: VmHWM on Linux, where
58
+ * `ru_maxrss` carries a parent's peak across exec, and `ru_maxrss` elsewhere.
80
59
  *
81
- * @param kind - the collection kind
82
- * @param printKey - the key type's printer
83
- * @param key - the repeated key
84
- * @returns the message
60
+ * @returns the peak
85
61
  */
86
- export declare function duplicateMessage(kind: 'set' | 'dict', printKey: (v: unknown) => string, key: unknown): string;
62
+ export declare function peakBytes(): bigint;
87
63
  //# sourceMappingURL=runner.d.ts.map