@elaraai/e3-api-server 1.0.103 → 1.0.105
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/README.md +114 -9
- package/dist/src/call-limits.d.ts +72 -0
- package/dist/src/call-limits.d.ts.map +1 -0
- package/dist/src/call-limits.js +104 -0
- package/dist/src/call-limits.js.map +1 -0
- package/dist/src/call-limits.spec.d.ts +6 -0
- package/dist/src/call-limits.spec.d.ts.map +1 -0
- package/dist/src/call-limits.spec.js +264 -0
- package/dist/src/call-limits.spec.js.map +1 -0
- package/dist/src/cli.js +10 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/handlers/calls.d.ts +238 -0
- package/dist/src/handlers/calls.d.ts.map +1 -0
- package/dist/src/handlers/calls.js +383 -0
- package/dist/src/handlers/calls.js.map +1 -0
- package/dist/src/handlers/functions.d.ts +47 -14
- package/dist/src/handlers/functions.d.ts.map +1 -1
- package/dist/src/handlers/functions.js +159 -94
- package/dist/src/handlers/functions.js.map +1 -1
- package/dist/src/handlers/functions.spec.js +71 -14
- package/dist/src/handlers/functions.spec.js.map +1 -1
- package/dist/src/handlers/index.d.ts +2 -1
- package/dist/src/handlers/index.d.ts.map +1 -1
- package/dist/src/handlers/index.js +2 -1
- package/dist/src/handlers/index.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/portable.d.ts +2 -1
- package/dist/src/portable.d.ts.map +1 -1
- package/dist/src/portable.js +4 -1
- package/dist/src/portable.js.map +1 -1
- package/dist/src/portable.spec.js +1 -0
- package/dist/src/portable.spec.js.map +1 -1
- package/dist/src/routes/calls.d.ts +81 -0
- package/dist/src/routes/calls.d.ts.map +1 -0
- package/dist/src/routes/calls.js +141 -0
- package/dist/src/routes/calls.js.map +1 -0
- package/dist/src/routes/functions.d.ts +97 -25
- package/dist/src/routes/functions.d.ts.map +1 -1
- package/dist/src/routes/functions.js +147 -30
- package/dist/src/routes/functions.js.map +1 -1
- package/dist/src/routes/index.d.ts +2 -1
- package/dist/src/routes/index.d.ts.map +1 -1
- package/dist/src/routes/index.js +2 -1
- package/dist/src/routes/index.js.map +1 -1
- package/dist/src/server.d.ts +15 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +43 -10
- package/dist/src/server.js.map +1 -1
- package/dist/src/types.d.ts +295 -3
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +13 -2
- package/dist/src/types.js.map +1 -1
- package/package.json +7 -6
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A server's call limits (#1103). A server made with them runs its calls
|
|
7
|
+
* under them, on the real east-node runner: a result is answered inline up to
|
|
8
|
+
* its result limit and `too_large` past it, a function's through its package
|
|
9
|
+
* as through a workspace, a split call's job ends `timed_out` at its job
|
|
10
|
+
* limit, and a one-shot or function call `timed_out` at its deadline. A limit
|
|
11
|
+
* that becomes a timer is at most what a timer waits. The CLI's flags resolve
|
|
12
|
+
* to them, and a malformed one is refused, naming the flag.
|
|
13
|
+
*/
|
|
14
|
+
import { describe, it, before, after } from 'node:test';
|
|
15
|
+
import assert from 'node:assert/strict';
|
|
16
|
+
import { spawnSync } from 'node:child_process';
|
|
17
|
+
import { randomBytes } from 'node:crypto';
|
|
18
|
+
import { fileURLToPath } from 'node:url';
|
|
19
|
+
import { ArrayType, BlobType, East, FunctionType, IntegerType, NullType, decodeBeast2For, encodeBeast2For, encodeEastIR, equalFor, none, some, toEastTypeValue, variant, } from '@elaraai/east';
|
|
20
|
+
import { LocalStorage, datasetWrite, workspaceCreate, workspaceDeploy } from '@elaraai/e3-core';
|
|
21
|
+
import { createTestRepo, removeTestRepo } from '@elaraai/e3-core/test';
|
|
22
|
+
import { BEAST2_CONTENT_TYPE, FunctionObjectType, PackageObjectType } from '@elaraai/e3-types';
|
|
23
|
+
import { checkCallLimits, resolveCallLimits } from './call-limits.js';
|
|
24
|
+
import { createServer } from './server.js';
|
|
25
|
+
import { ExecuteResultType, FunctionCallRequestType, OneShotRequestType, PackageJobResponseType, ResponseType, SplitCallRequestType, SplitCallStatusType, } from './types.js';
|
|
26
|
+
const MiB = 1024 * 1024;
|
|
27
|
+
const NumbersType = ArrayType(IntegerType);
|
|
28
|
+
const NUMBERS = [variant('field', 'inputs'), variant('field', 'numbers')];
|
|
29
|
+
const EAST_NODE = variant('east_node', { platforms: [], decode: variant('lazy', null) });
|
|
30
|
+
/** Answers the bytes it is given. */
|
|
31
|
+
const echo = East.function([BlobType], BlobType, ($, bytes) => bytes);
|
|
32
|
+
/** Bytes that encode to as many: beast2 compresses what repeats. */
|
|
33
|
+
function noise(bytes) {
|
|
34
|
+
return new Uint8Array(randomBytes(bytes));
|
|
35
|
+
}
|
|
36
|
+
/** Counts for ever: only a limit ends it. */
|
|
37
|
+
const spin = East.function([], IntegerType, ($) => {
|
|
38
|
+
const count = $.let(0n);
|
|
39
|
+
$.while(true, ($) => {
|
|
40
|
+
$.assign(count, count.add(1n));
|
|
41
|
+
});
|
|
42
|
+
return count;
|
|
43
|
+
});
|
|
44
|
+
/** A split call's program that counts for ever over its piece. */
|
|
45
|
+
const spinEach = East.function([NumbersType, FunctionType([IntegerType], NullType)], NullType, ($, _numbers, _emit) => {
|
|
46
|
+
const count = $.let(0n);
|
|
47
|
+
$.while(true, ($) => {
|
|
48
|
+
$.assign(count, count.add(1n));
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Deploys to workspace `main` of the repository at `repo` a package of one
|
|
53
|
+
* input, `numbers` ([1, 2, 3]), and two functions, `spin` and `echo`.
|
|
54
|
+
*/
|
|
55
|
+
async function deploy(repo) {
|
|
56
|
+
const storage = new LocalStorage();
|
|
57
|
+
const numbers = await datasetWrite(storage, repo, [1n, 2n, 3n], NumbersType);
|
|
58
|
+
const spinning = await storage.objects.write(repo, encodeBeast2For(FunctionObjectType)({
|
|
59
|
+
bodyIr: await storage.objects.write(repo, encodeEastIR(spin.toIR())),
|
|
60
|
+
inputs: [],
|
|
61
|
+
argTypes: [],
|
|
62
|
+
outputType: toEastTypeValue(IntegerType),
|
|
63
|
+
runner: EAST_NODE,
|
|
64
|
+
environment: none,
|
|
65
|
+
}));
|
|
66
|
+
const echoing = await storage.objects.write(repo, encodeBeast2For(FunctionObjectType)({
|
|
67
|
+
bodyIr: await storage.objects.write(repo, encodeEastIR(echo.toIR())),
|
|
68
|
+
inputs: [],
|
|
69
|
+
argTypes: [toEastTypeValue(BlobType)],
|
|
70
|
+
outputType: toEastTypeValue(BlobType),
|
|
71
|
+
runner: EAST_NODE,
|
|
72
|
+
environment: none,
|
|
73
|
+
}));
|
|
74
|
+
const pkg = await storage.objects.write(repo, encodeBeast2For(PackageObjectType)({
|
|
75
|
+
tasks: new Map(),
|
|
76
|
+
data: {
|
|
77
|
+
structure: variant('struct', new Map([
|
|
78
|
+
['inputs', variant('struct', new Map([['numbers', variant('value', { type: toEastTypeValue(NumbersType), writable: true })]]))],
|
|
79
|
+
])),
|
|
80
|
+
refs: new Map([['inputs/numbers', variant('value', { hash: numbers, versions: new Map() })]]),
|
|
81
|
+
},
|
|
82
|
+
functions: new Map([['echo', echoing], ['spin', spinning]]),
|
|
83
|
+
records: new Map(),
|
|
84
|
+
sources: new Map(),
|
|
85
|
+
}));
|
|
86
|
+
await storage.refs.packageWrite(repo, 'limits', '1.0.0', pkg);
|
|
87
|
+
await workspaceCreate(storage, repo, 'main');
|
|
88
|
+
await workspaceDeploy(storage, repo, 'main', 'limits', '1.0.0');
|
|
89
|
+
}
|
|
90
|
+
async function serving(calls) {
|
|
91
|
+
const repo = createTestRepo();
|
|
92
|
+
await deploy(repo);
|
|
93
|
+
const server = await createServer({ singleRepoPath: repo, port: 0, host: '127.0.0.1', calls });
|
|
94
|
+
await server.start();
|
|
95
|
+
return {
|
|
96
|
+
async send(path, body) {
|
|
97
|
+
const response = await fetch(`http://127.0.0.1:${server.port}/api/repos/default${path}`, body === undefined ? {} : {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: { 'Content-Type': BEAST2_CONTENT_TYPE },
|
|
100
|
+
body,
|
|
101
|
+
});
|
|
102
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
103
|
+
},
|
|
104
|
+
async stop() {
|
|
105
|
+
await server.stop();
|
|
106
|
+
removeTestRepo(repo);
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** The success an answer of `type` holds, failing the test on an error. */
|
|
111
|
+
function success(type, bytes) {
|
|
112
|
+
const answer = decodeBeast2For(ResponseType(type))(bytes);
|
|
113
|
+
if (answer.type !== 'success')
|
|
114
|
+
assert.fail(`the request was refused: ${answer.value.type}`);
|
|
115
|
+
return answer.value;
|
|
116
|
+
}
|
|
117
|
+
/** A one-shot call of `body` on east-node over the values given. */
|
|
118
|
+
function oneShot(body, args) {
|
|
119
|
+
return encodeBeast2For(OneShotRequestType)({
|
|
120
|
+
bodyIr: encodeEastIR(body.toIR()),
|
|
121
|
+
args: args.map((arg) => variant('value', arg)),
|
|
122
|
+
runner: EAST_NODE,
|
|
123
|
+
limits: none,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
describe('a server\'s call limits (#1103)', () => {
|
|
127
|
+
describe('a result limit of 2 MiB', () => {
|
|
128
|
+
let server;
|
|
129
|
+
before(async () => {
|
|
130
|
+
server = await serving({ ceilings: { maxResultBytes: 2 * MiB } });
|
|
131
|
+
});
|
|
132
|
+
after(async () => {
|
|
133
|
+
await server.stop();
|
|
134
|
+
});
|
|
135
|
+
it('answers a result of 1.5 MiB inline, over the default limit of 1 MiB', async () => {
|
|
136
|
+
const bytes = noise(1.5 * MiB);
|
|
137
|
+
const result = success(ExecuteResultType, await server.send('/workspaces/main/one-shot', oneShot(echo, [encodeBeast2For(BlobType)(bytes)])));
|
|
138
|
+
if (result.outcome.type !== 'success')
|
|
139
|
+
assert.fail(`expected success, got ${result.outcome.type}: ${result.stderr}`);
|
|
140
|
+
assert.ok(equalFor(BlobType)(decodeBeast2For(BlobType)(result.outcome.value.value), bytes), 'the result is the bytes given');
|
|
141
|
+
});
|
|
142
|
+
it('answers a result of 3 MiB too_large, naming the limit', async () => {
|
|
143
|
+
const result = success(ExecuteResultType, await server.send('/workspaces/main/one-shot', oneShot(echo, [encodeBeast2For(BlobType)(noise(3 * MiB))])));
|
|
144
|
+
if (result.outcome.type !== 'too_large')
|
|
145
|
+
assert.fail(`expected too_large, got ${result.outcome.type}: ${result.stderr}`);
|
|
146
|
+
assert.equal(result.outcome.value.limit, BigInt(2 * MiB));
|
|
147
|
+
assert.ok(Number(result.outcome.value.bytes) > 3 * MiB, `the result is ${result.outcome.value.bytes} bytes`);
|
|
148
|
+
});
|
|
149
|
+
it('answers a function call of 1.5 MiB inline too, through the package as through the workspace', async () => {
|
|
150
|
+
const bytes = noise(1.5 * MiB);
|
|
151
|
+
const call = encodeBeast2For(FunctionCallRequestType)({ args: [variant('value', encodeBeast2For(BlobType)(bytes))], runner: none, limits: none });
|
|
152
|
+
for (const path of ['/workspaces/main/functions/echo', '/packages/limits/1.0.0/functions/echo']) {
|
|
153
|
+
const result = success(ExecuteResultType, await server.send(path, call));
|
|
154
|
+
if (result.outcome.type !== 'success')
|
|
155
|
+
assert.fail(`${path}: expected success, got ${result.outcome.type}: ${result.stderr}`);
|
|
156
|
+
assert.ok(equalFor(BlobType)(decodeBeast2For(BlobType)(result.outcome.value.value), bytes), `${path}: the result is the bytes given`);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
describe('a job limit of 2 s and a deadline of 1 s', () => {
|
|
161
|
+
let server;
|
|
162
|
+
before(async () => {
|
|
163
|
+
server = await serving({ syncDeadlineMs: 1_000, ceilings: { timeoutMs: 2_000 } });
|
|
164
|
+
});
|
|
165
|
+
after(async () => {
|
|
166
|
+
await server.stop();
|
|
167
|
+
});
|
|
168
|
+
it('ends a slower split call timed_out at the job limit', { timeout: 60_000 }, async () => {
|
|
169
|
+
const { id } = success(PackageJobResponseType, await server.send('/workspaces/main/one-shot/split', encodeBeast2For(SplitCallRequestType)({
|
|
170
|
+
bodyIr: encodeEastIR(spinEach.toIR()),
|
|
171
|
+
args: [{ arg: variant('dataset', NUMBERS), partition: some({ by: [] }) }],
|
|
172
|
+
output: variant('array', null),
|
|
173
|
+
then: none,
|
|
174
|
+
runner: EAST_NODE,
|
|
175
|
+
limits: none,
|
|
176
|
+
})));
|
|
177
|
+
let status = success(SplitCallStatusType, await server.send(`/workspaces/main/one-shot/split/${id}`));
|
|
178
|
+
while (status.type === 'processing') {
|
|
179
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
180
|
+
status = success(SplitCallStatusType, await server.send(`/workspaces/main/one-shot/split/${id}`));
|
|
181
|
+
}
|
|
182
|
+
if (status.type !== 'completed')
|
|
183
|
+
assert.fail(`expected the call completed, got ${status.type}`);
|
|
184
|
+
const { outcome } = status.value.result;
|
|
185
|
+
if (outcome.type !== 'timed_out')
|
|
186
|
+
assert.fail(`expected timed_out, got ${outcome.type}: ${status.value.result.stderr}`);
|
|
187
|
+
assert.equal(outcome.value.ms, 2000n);
|
|
188
|
+
});
|
|
189
|
+
it('ends a slower one-shot call timed_out at the deadline', { timeout: 60_000 }, async () => {
|
|
190
|
+
const result = success(ExecuteResultType, await server.send('/workspaces/main/one-shot', oneShot(spin, [])));
|
|
191
|
+
if (result.outcome.type !== 'timed_out')
|
|
192
|
+
assert.fail(`expected timed_out, got ${result.outcome.type}: ${result.stderr}`);
|
|
193
|
+
assert.equal(result.outcome.value.ms, 1000n);
|
|
194
|
+
});
|
|
195
|
+
it('ends a slower function call timed_out at the deadline, through the workspace and through the package', { timeout: 60_000 }, async () => {
|
|
196
|
+
const call = encodeBeast2For(FunctionCallRequestType)({ args: [], runner: none, limits: none });
|
|
197
|
+
for (const path of ['/workspaces/main/functions/spin', '/packages/limits/1.0.0/functions/spin']) {
|
|
198
|
+
const result = success(ExecuteResultType, await server.send(path, call));
|
|
199
|
+
if (result.outcome.type !== 'timed_out')
|
|
200
|
+
assert.fail(`${path}: expected timed_out, got ${result.outcome.type}: ${result.stderr}`);
|
|
201
|
+
assert.equal(result.outcome.value.ms, 1000n, path);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
it('refuses a limit that is not positive, naming it', async () => {
|
|
206
|
+
await assert.rejects(createServer({ singleRepoPath: '/nonexistent', calls: { syncDeadlineMs: 0 } }), { name: 'RangeError', message: 'calls.syncDeadlineMs must be a positive number of milliseconds, got 0' });
|
|
207
|
+
await assert.rejects(createServer({ singleRepoPath: '/nonexistent', calls: { ceilings: { maxResultBytes: 1.5 } } }), { name: 'RangeError', message: 'calls.ceilings.maxResultBytes must be a positive whole number of bytes, got 1.5' });
|
|
208
|
+
});
|
|
209
|
+
it('refuses a deadline, a timeout, a window or a wait longer than a timer waits, naming it, and takes a lifetime as long', async () => {
|
|
210
|
+
const days30 = 30 * 24 * 60 * 60_000;
|
|
211
|
+
const refused = [
|
|
212
|
+
[{ syncDeadlineMs: days30 }, 'syncDeadlineMs'],
|
|
213
|
+
[{ ceilings: { timeoutMs: days30 } }, 'ceilings.timeoutMs'],
|
|
214
|
+
[{ windowMs: days30 }, 'windowMs'],
|
|
215
|
+
[{ pollWaitMs: days30 }, 'pollWaitMs'],
|
|
216
|
+
];
|
|
217
|
+
for (const [calls, name] of refused) {
|
|
218
|
+
await assert.rejects(createServer({ singleRepoPath: '/nonexistent', calls }), {
|
|
219
|
+
name: 'RangeError',
|
|
220
|
+
message: `calls.${name} must be at most 2147483647 ms (about 24.8 days), the longest a timer waits, got ${days30}`,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
const longest = 2 ** 31 - 1;
|
|
224
|
+
const kept = { syncDeadlineMs: longest, ceilings: { timeoutMs: longest }, windowMs: longest, pollWaitMs: longest };
|
|
225
|
+
assert.deepEqual(checkCallLimits(kept), kept, 'the longest a timer waits is taken');
|
|
226
|
+
const lifetimes = { succeededMs: days30, failedMs: days30 };
|
|
227
|
+
assert.deepEqual(checkCallLimits({ lifetimes }), { lifetimes }, 'a lifetime is no timer');
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
describe('the CLI\'s call limit flags (#1103)', () => {
|
|
231
|
+
it('resolves each flag, and leaves a limit no flag gives to the server\'s default', () => {
|
|
232
|
+
assert.deepEqual(resolveCallLimits({ callDeadline: '90s', jobTimeout: '2h', maxResult: '8M', maxLog: '1M' }), {
|
|
233
|
+
syncDeadlineMs: 90_000,
|
|
234
|
+
ceilings: { timeoutMs: 7_200_000, maxResultBytes: 8 * MiB, maxLogBytes: MiB },
|
|
235
|
+
});
|
|
236
|
+
assert.deepEqual(resolveCallLimits({ jobTimeout: '30m' }), { ceilings: { timeoutMs: 1_800_000 } });
|
|
237
|
+
assert.deepEqual(resolveCallLimits({ jobTimeout: '24d' }), { ceilings: { timeoutMs: 24 * 24 * 3_600_000 } }, 'days are taken, up to what a timer waits');
|
|
238
|
+
assert.deepEqual(resolveCallLimits({}), {});
|
|
239
|
+
});
|
|
240
|
+
it('refuses a malformed value, naming its flag', () => {
|
|
241
|
+
const refusals = [
|
|
242
|
+
[{ callDeadline: 'soon' }, "--call-deadline must be a duration, as 90s, 15m or 2h, got 'soon'"],
|
|
243
|
+
[{ callDeadline: '0s' }, "--call-deadline must be a duration, as 90s, 15m or 2h, got '0s'"],
|
|
244
|
+
[{ jobTimeout: '90' }, "--job-timeout must be a duration, as 90s, 15m or 2h, got '90'"],
|
|
245
|
+
// A timer waits at most 2^31 - 1 ms, and fires at once past it
|
|
246
|
+
[{ jobTimeout: '30d' }, "--job-timeout must be at most about 24.8 days (2147483647 ms), the longest a timer waits, got '30d'"],
|
|
247
|
+
[{ callDeadline: '597h' }, "--call-deadline must be at most about 24.8 days (2147483647 ms), the longest a timer waits, got '597h'"],
|
|
248
|
+
[{ maxResult: 'big' }, "--max-result must be a size in bytes, or with a K, M, G or T suffix (binary units, as 8M), got 'big'"],
|
|
249
|
+
[{ maxLog: '0' }, "--max-log must be a size in bytes, or with a K, M, G or T suffix (binary units, as 8M), got '0'"],
|
|
250
|
+
];
|
|
251
|
+
for (const [settings, message] of refusals) {
|
|
252
|
+
assert.throws(() => resolveCallLimits(settings), { name: 'RangeError', message });
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
it('e3-api-server refuses a malformed flag before it serves anything, naming it', () => {
|
|
256
|
+
const cli = fileURLToPath(new URL('./cli.js', import.meta.url));
|
|
257
|
+
for (const [flag, value] of [['--call-deadline', 'soon'], ['--job-timeout', '2x'], ['--max-result', 'big'], ['--max-log', '-1K']]) {
|
|
258
|
+
const run = spawnSync(process.execPath, [cli, '--repo', '/nonexistent', flag, value], { encoding: 'utf8' });
|
|
259
|
+
assert.equal(run.status, 1, `${flag}: ${run.stderr}`);
|
|
260
|
+
assert.match(run.stderr, new RegExp(`^Error: ${flag} must be a .*, got '${value}'$`, 'm'));
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
//# sourceMappingURL=call-limits.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-limits.spec.js","sourceRoot":"","sources":["../../src/call-limits.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC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E,GAAG,IAAI,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACtD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,MAAM,CAAC,WAAW,IAAI,uBAAuB,KAAK,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/src/cli.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { Command } from 'commander';
|
|
7
7
|
import { resolveBudget } from '@elaraai/e3-core';
|
|
8
8
|
import { createServer } from './server.js';
|
|
9
|
+
import { resolveCallLimits } from './call-limits.js';
|
|
9
10
|
const program = new Command();
|
|
10
11
|
program
|
|
11
12
|
.name('e3-api-server')
|
|
@@ -25,6 +26,10 @@ program
|
|
|
25
26
|
.option('--auth-audience <aud>', 'Expected JWT audience (external auth)')
|
|
26
27
|
.option('-j, --jobs <n>', 'Cores: runner processes to keep in flight across every run and call the server serves and every upload it takes in (default: $E3_JOBS, else the CPUs available)')
|
|
27
28
|
.option('--memory <size>', 'Memory those runner processes may reserve between them, as 8G or 512M (default: $E3_MEMORY, else the memory available, less a reserve for e3 and the OS)')
|
|
29
|
+
.option('--call-deadline <duration>', 'How long a one-shot call, or a function called through its sync route, may run before it answers, as 90s or 15m (default: 120s); a call that names no timeout of its own gets 60s within it')
|
|
30
|
+
.option('--job-timeout <duration>', 'How long a split call\'s job, or a kept call of a workspace\'s function, may run, as 30m or 2h, which is also the longest timeout a one-shot call may ask for (default: 10m)')
|
|
31
|
+
.option('--max-result <size>', 'The largest result a one-shot, split or kept call answers, as 8M (default: 1M). The server holds a result in memory while it answers it, so a larger limit takes more of it; a split call\'s larger result is read from its stored output, by its hash')
|
|
32
|
+
.option('--max-log <size>', 'The most of each of a call\'s stdout and stderr its answer may carry, as 1M (default: 256K; a call that names no limit gets 64K)')
|
|
28
33
|
.action(async (options) => {
|
|
29
34
|
// Validate mutually exclusive options
|
|
30
35
|
if (options.repos && options.repo) {
|
|
@@ -38,8 +43,12 @@ program
|
|
|
38
43
|
const port = parseInt(options.port, 10);
|
|
39
44
|
const host = options.host;
|
|
40
45
|
let budget;
|
|
46
|
+
let calls;
|
|
41
47
|
try {
|
|
42
48
|
budget = resolveBudget({ jobs: options.jobs, memory: options.memory });
|
|
49
|
+
calls = resolveCallLimits({
|
|
50
|
+
callDeadline: options.callDeadline, jobTimeout: options.jobTimeout, maxResult: options.maxResult, maxLog: options.maxLog,
|
|
51
|
+
});
|
|
43
52
|
}
|
|
44
53
|
catch (err) {
|
|
45
54
|
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -85,6 +94,7 @@ program
|
|
|
85
94
|
auth,
|
|
86
95
|
oidc,
|
|
87
96
|
budget,
|
|
97
|
+
calls,
|
|
88
98
|
dataflowRunner,
|
|
89
99
|
});
|
|
90
100
|
await server.start();
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAe,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAA8B,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAe,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAA8B,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AAEtE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,eAAe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@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import type { ExecuteCeilings, FunctionCallDispatch, FunctionCallLifetimes, OneShotGrant, StorageBackend } from '@elaraai/e3-core/portable';
|
|
6
|
+
import { type FunctionCall, type FunctionCallRequest, type FunctionCallState, type OneShotRequest } from '../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Whether a request's caller may read, or cancel, a kept call: what a host
|
|
9
|
+
* whose callers see only some of a workspace's calls decides, by the call's
|
|
10
|
+
* `caller` say.
|
|
11
|
+
*/
|
|
12
|
+
export type CallAdmit = (call: FunctionCall) => boolean | Promise<boolean>;
|
|
13
|
+
/** Options for {@link startFunctionCall} and {@link callFunctionInWorkspace}. */
|
|
14
|
+
export interface FunctionCallFilingOptions {
|
|
15
|
+
/** Who makes the call, as the host's auth names them; `null` without one */
|
|
16
|
+
caller: string | null;
|
|
17
|
+
/** The caller's one-shot grant, which decides whether its call may give the
|
|
18
|
+
* function a platform package the function does not load: only `any` may */
|
|
19
|
+
grant: OneShotGrant;
|
|
20
|
+
/** The most a call may ask for (default: a server's) */
|
|
21
|
+
ceilings?: ExecuteCeilings;
|
|
22
|
+
/** How long a call is kept once it ends (default: an hour for a success or a
|
|
23
|
+
* cancel, a week for any other end) */
|
|
24
|
+
lifetimes?: FunctionCallLifetimes;
|
|
25
|
+
/** Pass `-v` to a stock runner */
|
|
26
|
+
verbose?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Options for {@link startFunctionCall}. */
|
|
29
|
+
export interface StartFunctionCallOptions extends FunctionCallFilingOptions {
|
|
30
|
+
/** How long the start waits for the call to end before it answers
|
|
31
|
+
* `running`, in ms: 0 answers at once */
|
|
32
|
+
waitMs: number;
|
|
33
|
+
/** An id the client chose for the call, a UUIDv7 of about now, so it can
|
|
34
|
+
* stop the call before the start answers (e3-core's `functionCallStart`
|
|
35
|
+
* sets aside one far from the server's clock) */
|
|
36
|
+
id?: string;
|
|
37
|
+
}
|
|
38
|
+
/** Options for {@link callFunctionInWorkspace}. */
|
|
39
|
+
export interface CallFunctionInWorkspaceOptions extends FunctionCallFilingOptions {
|
|
40
|
+
/** The host's deadline for a sync call, under its request timeout (default
|
|
41
|
+
* 120 000 ms): the call's timeout is clamped under it */
|
|
42
|
+
syncDeadlineMs?: number;
|
|
43
|
+
}
|
|
44
|
+
/** Options for {@link getFunctionCallStatus}. */
|
|
45
|
+
export interface FunctionCallStatusOptions {
|
|
46
|
+
/** How long the poll waits for the call to end before it answers
|
|
47
|
+
* `running`, in ms: 0 answers at once */
|
|
48
|
+
waitMs: number;
|
|
49
|
+
/** Whether the caller may read the call (default: any caller may) */
|
|
50
|
+
admit?: CallAdmit;
|
|
51
|
+
}
|
|
52
|
+
/** Options for {@link cancelFunctionCall}. */
|
|
53
|
+
export interface CancelFunctionCallOptions {
|
|
54
|
+
/** Who asks, as the host's auth names them; `null` without one */
|
|
55
|
+
by: string | null;
|
|
56
|
+
/** How long the cancel waits for the call to stop before it answers
|
|
57
|
+
* `running`, in ms */
|
|
58
|
+
waitMs: number;
|
|
59
|
+
/** Whether the caller may cancel the call (default: any caller may) */
|
|
60
|
+
admit?: CallAdmit;
|
|
61
|
+
}
|
|
62
|
+
/** Which of a workspace's calls {@link listFunctionCalls} answers. */
|
|
63
|
+
export interface FunctionCallListQuery {
|
|
64
|
+
/** Only the calls whose ids sort before it, the next page's cursor */
|
|
65
|
+
before?: string;
|
|
66
|
+
/** At most this many (default {@link FUNCTION_CALLS_PAGE_DEFAULT}, and at
|
|
67
|
+
* most {@link FUNCTION_CALLS_PAGE_MAX}) */
|
|
68
|
+
limit?: number;
|
|
69
|
+
/** Only the calls of the function of this name */
|
|
70
|
+
function?: string;
|
|
71
|
+
/** Only the calls in the state of this tag */
|
|
72
|
+
state?: FunctionCallState['type'];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Start a call of a named function through a workspace: file it, run it where
|
|
76
|
+
* the backend runs calls, and wait up to `waitMs` for it to end.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* The call is checked, its inputs and dataset arguments pinned and its value
|
|
80
|
+
* arguments stored as e3-core's `functionCallStart` does, and it is kept from
|
|
81
|
+
* now until its lifetime ends. A call found wrong is filed ended `invalid`,
|
|
82
|
+
* and answered `completed` with that result. A call is held to its own
|
|
83
|
+
* timeout, never to the request's: one still running when the wait passes is
|
|
84
|
+
* answered `running`, and its caller polls by its id. A call the dispatch
|
|
85
|
+
* cannot hand to the compute that runs calls is recorded `lost`, and answered
|
|
86
|
+
* so.
|
|
87
|
+
*
|
|
88
|
+
* @param storage - Storage backend
|
|
89
|
+
* @param dispatch - Runs the call where the backend runs calls
|
|
90
|
+
* @param repo - The repository's name, which the dispatch takes
|
|
91
|
+
* @param repoPath - The repository's identifier, which the store takes
|
|
92
|
+
* @param workspace - The workspace the call is made through
|
|
93
|
+
* @param fnName - The function's name in the deployed package
|
|
94
|
+
* @param request - The arguments, and any runner and limits the caller names
|
|
95
|
+
* @param options - Who calls, their grant, the ceilings, the lifetimes and how
|
|
96
|
+
* long to wait
|
|
97
|
+
* @returns The response: the call's id and how it stood when the wait ended;
|
|
98
|
+
* or the error that stopped its start — the workspace, its package or the
|
|
99
|
+
* function not found, or `permission_denied` (`path` `runner`)
|
|
100
|
+
*/
|
|
101
|
+
export declare function startFunctionCall(storage: StorageBackend, dispatch: FunctionCallDispatch, repo: string, repoPath: string, workspace: string, fnName: string, request: FunctionCallRequest, options: StartFunctionCallOptions): Promise<Response>;
|
|
102
|
+
/**
|
|
103
|
+
* Start a one-shot as a call through a workspace: file it, run it where the
|
|
104
|
+
* backend runs calls, and wait up to `waitMs` for it to end — what a named
|
|
105
|
+
* function's start does, for its caller's program.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* The request is held to its caller's grant, as a one-shot run within a
|
|
109
|
+
* request is, before anything is read; its program is filed as an anonymous
|
|
110
|
+
* function, its dataset arguments pinned and its value arguments stored, as
|
|
111
|
+
* e3-core's `oneShotCallStart` does; and it is kept from now until its
|
|
112
|
+
* lifetime ends, listed among the workspace's calls naming no function. A
|
|
113
|
+
* call found wrong is filed ended `invalid`, and answered `completed` with
|
|
114
|
+
* that result. A call is held to its own timeout, never to the request's: one
|
|
115
|
+
* still running when the wait passes is answered `running`, and its caller
|
|
116
|
+
* polls it by its id, and cancels it, through the calls routes. A call the
|
|
117
|
+
* dispatch cannot hand to the compute that runs calls is recorded `lost`, and
|
|
118
|
+
* answered so.
|
|
119
|
+
*
|
|
120
|
+
* @param storage - Storage backend
|
|
121
|
+
* @param dispatch - Runs the call where the backend runs calls
|
|
122
|
+
* @param repo - The repository's name, which the dispatch takes
|
|
123
|
+
* @param repoPath - The repository's identifier, which the store takes
|
|
124
|
+
* @param workspace - The workspace whose datasets the call reads
|
|
125
|
+
* @param request - The program, its arguments, its runner and its limits
|
|
126
|
+
* @param options - Who calls, their grant, the ceilings, the lifetimes and how
|
|
127
|
+
* long to wait
|
|
128
|
+
* @returns The response: the call's id and how it stood when the wait ended;
|
|
129
|
+
* or the error that stopped its start — `permission_denied` (`path`
|
|
130
|
+
* `one-shot`) for a request the caller's grant does not run, and the
|
|
131
|
+
* workspace not found or not deployed
|
|
132
|
+
*/
|
|
133
|
+
export declare function startOneShotCall(storage: StorageBackend, dispatch: FunctionCallDispatch, repo: string, repoPath: string, workspace: string, request: OneShotRequest, options: StartFunctionCallOptions): Promise<Response>;
|
|
134
|
+
/**
|
|
135
|
+
* Call a named function through a workspace synchronously: the call is filed
|
|
136
|
+
* and kept as a started one is, and the request waits for it to end.
|
|
137
|
+
*
|
|
138
|
+
* @remarks
|
|
139
|
+
* The call's timeout defaults as a sync call's does, and is clamped under the
|
|
140
|
+
* host's sync deadline, so the caller gets a structured `timed_out` instead of
|
|
141
|
+
* a transport cut. Its run stops it at that timeout and records it so; should
|
|
142
|
+
* the record not land within a second of the deadline, the request answers
|
|
143
|
+
* `timed_out` itself. A call cancelled while the request waits, or lost, has
|
|
144
|
+
* no result: it is answered `internal`, saying which.
|
|
145
|
+
*
|
|
146
|
+
* @param storage - Storage backend
|
|
147
|
+
* @param dispatch - Runs the call where the backend runs calls
|
|
148
|
+
* @param repo - The repository's name, which the dispatch takes
|
|
149
|
+
* @param repoPath - The repository's identifier, which the store takes
|
|
150
|
+
* @param workspace - The workspace the call is made through
|
|
151
|
+
* @param fnName - The function's name in the deployed package
|
|
152
|
+
* @param request - The arguments, and any runner and limits the caller names
|
|
153
|
+
* @param options - Who calls, their grant, the ceilings, the lifetimes and the
|
|
154
|
+
* host's sync deadline
|
|
155
|
+
* @returns The response: the call's result, or the error that stopped it
|
|
156
|
+
*/
|
|
157
|
+
export declare function callFunctionInWorkspace(storage: StorageBackend, dispatch: FunctionCallDispatch, repo: string, repoPath: string, workspace: string, fnName: string, request: FunctionCallRequest, options: CallFunctionInWorkspaceOptions): Promise<Response>;
|
|
158
|
+
/**
|
|
159
|
+
* A call's status, as its caller polls it, waiting up to `waitMs` for it to
|
|
160
|
+
* end.
|
|
161
|
+
*
|
|
162
|
+
* @remarks
|
|
163
|
+
* `running` until it ends; then its result, its value read back inline up to
|
|
164
|
+
* its `maxResultBytes`, or `cancelled` or `lost`. A call still recorded running
|
|
165
|
+
* past its deadline and a grace — its host stopped before it ended — is
|
|
166
|
+
* recorded `lost`, and answered so.
|
|
167
|
+
*
|
|
168
|
+
* @param storage - Storage backend
|
|
169
|
+
* @param dispatch - Runs the workspace's calls, and hears of their ends
|
|
170
|
+
* @param repo - The repository's name, which the dispatch takes
|
|
171
|
+
* @param repoPath - The repository's identifier, which the store takes
|
|
172
|
+
* @param workspace - The workspace the call was made through
|
|
173
|
+
* @param id - The call's id
|
|
174
|
+
* @param options - How long to wait, and whether the caller may read the call
|
|
175
|
+
* @returns The response: the status; or the error — `permission_denied`
|
|
176
|
+
* (`path` `call`) for a caller the host does not admit, and `internal` for a
|
|
177
|
+
* call the workspace does not keep: none was made, or its lifetime has ended
|
|
178
|
+
*/
|
|
179
|
+
export declare function getFunctionCallStatus(storage: StorageBackend, dispatch: FunctionCallDispatch, repo: string, repoPath: string, workspace: string, id: string, options: FunctionCallStatusOptions): Promise<Response>;
|
|
180
|
+
/**
|
|
181
|
+
* Cancel a running call: record the request, tell the dispatch, and wait up to
|
|
182
|
+
* `waitMs` for the call to stop.
|
|
183
|
+
*
|
|
184
|
+
* @remarks
|
|
185
|
+
* The call's run stops its runner and records it `cancelled`, naming who
|
|
186
|
+
* asked: at once where the dispatch runs the call in its own process, and
|
|
187
|
+
* otherwise at the run's next look at its record. A call that has ended is
|
|
188
|
+
* left as it is, and answered with its status: a cancel changes nothing then.
|
|
189
|
+
*
|
|
190
|
+
* @param storage - Storage backend
|
|
191
|
+
* @param dispatch - Runs the workspace's calls, and stops them
|
|
192
|
+
* @param repo - The repository's name, which the dispatch takes
|
|
193
|
+
* @param repoPath - The repository's identifier, which the store takes
|
|
194
|
+
* @param workspace - The workspace the call was made through
|
|
195
|
+
* @param id - The call's id
|
|
196
|
+
* @param options - Who asks, how long to wait, and whether they may
|
|
197
|
+
* @returns The response: the call's status once it stopped, or `running`
|
|
198
|
+
* while it stops; or the error, as {@link getFunctionCallStatus} answers it
|
|
199
|
+
*/
|
|
200
|
+
export declare function cancelFunctionCall(storage: StorageBackend, dispatch: FunctionCallDispatch, repo: string, repoPath: string, workspace: string, id: string, options: CancelFunctionCallOptions): Promise<Response>;
|
|
201
|
+
/**
|
|
202
|
+
* A page of a workspace's kept calls, the latest first: each by who made it,
|
|
203
|
+
* when, and how it stands or ended.
|
|
204
|
+
*
|
|
205
|
+
* @remarks
|
|
206
|
+
* A call is kept for its lifetime, so the list holds the last hour's successes
|
|
207
|
+
* and the last week's failures, by default, however many calls are made: a
|
|
208
|
+
* client reads it a page at a time, passing a page's `next` as the next one's
|
|
209
|
+
* `before`. A page may hold fewer calls than its limit, or none, and name a
|
|
210
|
+
* next all the same: a store that reads a bounded number of calls a list, as
|
|
211
|
+
* the cloud's does, stops where its reads stopped. A call still recorded
|
|
212
|
+
* running past its deadline and a grace is recorded `lost` as the page passes
|
|
213
|
+
* it, as a read of it records it.
|
|
214
|
+
*
|
|
215
|
+
* @param storage - Storage backend
|
|
216
|
+
* @param repoPath - The repository's identifier
|
|
217
|
+
* @param workspace - The workspace
|
|
218
|
+
* @param query - The page's cursor and size, and only a function's calls, or
|
|
219
|
+
* only those in a state
|
|
220
|
+
* @returns The response: the page; or the error — `workspace_not_found` for a
|
|
221
|
+
* workspace there is not
|
|
222
|
+
*/
|
|
223
|
+
export declare function listFunctionCalls(storage: StorageBackend, repoPath: string, workspace: string, query?: FunctionCallListQuery): Promise<Response>;
|
|
224
|
+
/**
|
|
225
|
+
* A kept call, whole: what it ran, its arguments, the versions of the inputs
|
|
226
|
+
* it read, its value by hash, its limits, its log tails and when it is
|
|
227
|
+
* forgotten.
|
|
228
|
+
*
|
|
229
|
+
* @param storage - Storage backend
|
|
230
|
+
* @param repoPath - The repository's identifier
|
|
231
|
+
* @param workspace - The workspace the call was made through
|
|
232
|
+
* @param id - The call's id
|
|
233
|
+
* @param admit - Whether the caller may read the call (default: any caller may)
|
|
234
|
+
* @returns The response: the call; or the error, as
|
|
235
|
+
* {@link getFunctionCallStatus} answers it
|
|
236
|
+
*/
|
|
237
|
+
export declare function getFunctionCall(storage: StorageBackend, repoPath: string, workspace: string, id: string, admit?: CallAdmit): Promise<Response>;
|
|
238
|
+
//# sourceMappingURL=calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../../src/handlers/calls.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+BH,OAAO,KAAK,EACV,eAAe,EAAE,oBAAoB,EAAE,qBAAqB,EAA4B,YAAY,EAAE,cAAc,EACrH,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,mBAA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