@elaraai/e3-types 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/dist/src/api.d.ts +437 -16
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/api.js +210 -17
- package/dist/src/api.js.map +1 -1
- package/dist/src/function-call.d.ts +206 -0
- package/dist/src/function-call.d.ts.map +1 -0
- package/dist/src/function-call.js +117 -0
- package/dist/src/function-call.js.map +1 -0
- package/dist/src/function.d.ts +17 -7
- package/dist/src/function.d.ts.map +1 -1
- package/dist/src/function.js +16 -7
- package/dist/src/function.js.map +1 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/names.d.ts +2 -2
- package/dist/src/names.d.ts.map +1 -1
- package/dist/src/record.d.ts +11 -0
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/record.js +13 -0
- package/dist/src/record.js.map +1 -1
- package/dist/src/release.d.ts +1 -1
- package/dist/src/release.js +1 -1
- package/package.json +2 -2
- package/src/api.ts +229 -17
- package/src/function-call.ts +137 -0
- package/src/function.ts +16 -7
- package/src/index.ts +33 -0
- package/src/names.ts +2 -2
- package/src/record.ts +14 -0
- package/src/release.ts +1 -1
package/src/api.ts
CHANGED
|
@@ -1255,10 +1255,11 @@ export const DiagnosticType = StructType({
|
|
|
1255
1255
|
* - `too_large`: result over `maxResultBytes`; deploy a task and read it with `datasetGet`
|
|
1256
1256
|
* - `timed_out`: exceeded `timeoutMs` / the server's sync deadline guard
|
|
1257
1257
|
*
|
|
1258
|
-
* `inputs` names what the call read: each
|
|
1259
|
-
* it was pinned at, in
|
|
1260
|
-
* stale one noticed. It is empty for a
|
|
1261
|
-
*
|
|
1258
|
+
* `inputs` names what the call read: each input the function declares, then
|
|
1259
|
+
* each dataset argument, with the hash it was pinned at, in parameter order,
|
|
1260
|
+
* so an answer can be reproduced and a stale one noticed. It is empty for a
|
|
1261
|
+
* call of a function with no inputs and value arguments only, and for an
|
|
1262
|
+
* `invalid` result.
|
|
1262
1263
|
*/
|
|
1263
1264
|
export const ExecuteResultType = StructType({
|
|
1264
1265
|
outcome: VariantType({
|
|
@@ -1286,10 +1287,12 @@ export const CallArgType = VariantType({
|
|
|
1286
1287
|
});
|
|
1287
1288
|
|
|
1288
1289
|
/**
|
|
1289
|
-
* Named function call. Positional args, one per
|
|
1290
|
-
*
|
|
1291
|
-
*
|
|
1292
|
-
*
|
|
1290
|
+
* Named function call. Positional args, one per argument the function takes
|
|
1291
|
+
* (its `argTypes`, never its inputs, which the server reads): a value, or a
|
|
1292
|
+
* dataset of the workspace ({@link CallArgType}). The package-scoped route has
|
|
1293
|
+
* no workspace to read a dataset from, and answers a dataset argument — or a
|
|
1294
|
+
* function with inputs — `invalid`; the workspace-scoped route pins it, as a
|
|
1295
|
+
* one-shot's is.
|
|
1293
1296
|
*/
|
|
1294
1297
|
export const FunctionCallRequestType = StructType({
|
|
1295
1298
|
args: ArrayType(CallArgType),
|
|
@@ -1297,18 +1300,33 @@ export const FunctionCallRequestType = StructType({
|
|
|
1297
1300
|
limits: OptionType(ExecuteLimitsType),
|
|
1298
1301
|
});
|
|
1299
1302
|
|
|
1300
|
-
/**
|
|
1303
|
+
/**
|
|
1304
|
+
* A function signature, returned by `describe` so dynamic callers can encode
|
|
1305
|
+
* args.
|
|
1306
|
+
*
|
|
1307
|
+
* @property name - The function's name
|
|
1308
|
+
* @property inputs - The datasets a call reads from the workspace it runs in,
|
|
1309
|
+
* which the caller does not pass; a function with any is called through a
|
|
1310
|
+
* workspace
|
|
1311
|
+
* @property argTypes - The types of the arguments a caller passes
|
|
1312
|
+
* @property outputType - The result's type
|
|
1313
|
+
* @property runner - The runtime it runs on
|
|
1314
|
+
*/
|
|
1301
1315
|
export const FunctionSignatureType = StructType({
|
|
1302
1316
|
name: StringType,
|
|
1303
|
-
|
|
1317
|
+
inputs: ArrayType(TreePathType),
|
|
1318
|
+
argTypes: ArrayType(EastTypeType),
|
|
1304
1319
|
outputType: EastTypeType,
|
|
1305
1320
|
runner: RunnerType,
|
|
1306
1321
|
});
|
|
1307
1322
|
|
|
1308
1323
|
/**
|
|
1309
1324
|
* One-shot execution request: run an anonymous function whose IR is supplied
|
|
1310
|
-
* at call time, optionally bound to existing workspace datasets
|
|
1311
|
-
*
|
|
1325
|
+
* at call time, optionally bound to existing workspace datasets. Run within
|
|
1326
|
+
* one request (`POST …/one-shot`), its result is returned inline and nothing
|
|
1327
|
+
* is kept. Started (`POST …/one-shot/calls`), it is a kept call as a named
|
|
1328
|
+
* function's is: filed, run outside the request, polled to its end, and kept
|
|
1329
|
+
* for its lifetime with no function named ({@link FunctionCallType}).
|
|
1312
1330
|
*
|
|
1313
1331
|
* SECURITY: one-shot evaluates a caller-supplied IR. One that is platform-free
|
|
1314
1332
|
* — a stock runtime given no platform package, and a body that calls no
|
|
@@ -1345,7 +1363,19 @@ export const SplitCallArgType = VariantType({
|
|
|
1345
1363
|
* not partitioned reaches every piece whole. `output` is how the pieces'
|
|
1346
1364
|
* outputs combine, as a task's output kinds do, with its programs and its zero
|
|
1347
1365
|
* inline. `then`, when given, runs once over the assembled output and then the
|
|
1348
|
-
* arguments, and its value is the call's.
|
|
1366
|
+
* arguments not partitioned, in their order, and its value is the call's. The
|
|
1367
|
+
* partitioned arguments are the pieces' to read: `then` reads what the pieces
|
|
1368
|
+
* made. A `then` that takes any other count is `invalid`, and nothing runs. A
|
|
1369
|
+
* plan that needs a partitioned dataset again after the combine runs another
|
|
1370
|
+
* split call over it, given this call's output as an `object` argument.
|
|
1371
|
+
*
|
|
1372
|
+
* `first` (#1110) is an `array` whose call stops once it has its first `limit`
|
|
1373
|
+
* elements, at least 1: the body emits as an array's does, and the value is an
|
|
1374
|
+
* Array of the first `limit` elements in input order, or of every element when
|
|
1375
|
+
* there are fewer. Its pieces run in input order, a few at a time, and once the
|
|
1376
|
+
* pieces finished from the first hold `limit` elements no piece after them
|
|
1377
|
+
* starts. Its pieces are an `array` call's, so the two share them in the
|
|
1378
|
+
* cache. `then` is given the first `limit` elements as its output.
|
|
1349
1379
|
*
|
|
1350
1380
|
* SECURITY: a caller whose one-shot grant is `platform_free` may launch one
|
|
1351
1381
|
* only when it is platform-free: a stock runtime given no platform package,
|
|
@@ -1361,6 +1391,7 @@ export const SplitCallRequestType = StructType({
|
|
|
1361
1391
|
output: VariantType({
|
|
1362
1392
|
array: NullType,
|
|
1363
1393
|
dict: StructType({ merge: OptionType(BlobType) }),
|
|
1394
|
+
first: StructType({ limit: IntegerType }),
|
|
1364
1395
|
fold: StructType({ combine: BlobType, zero: BlobType }),
|
|
1365
1396
|
set: NullType,
|
|
1366
1397
|
}),
|
|
@@ -1391,25 +1422,198 @@ export const SplitCallPlanType = StructType({
|
|
|
1391
1422
|
bytes: IntegerType,
|
|
1392
1423
|
});
|
|
1393
1424
|
|
|
1425
|
+
/**
|
|
1426
|
+
* How a finished split call ran: how many pieces its input was cut into; the
|
|
1427
|
+
* units this job ran, pieces and merges, and those the execution cache served
|
|
1428
|
+
* it; and the highest peak resident memory a unit reached, in bytes, as the
|
|
1429
|
+
* task's execution records it — for a call the cache served too. A call the
|
|
1430
|
+
* cache served whole consulted no unit: it ran 0, and was served 0. `then`'s
|
|
1431
|
+
* run is no unit.
|
|
1432
|
+
*/
|
|
1433
|
+
export const SplitCallReportType = StructType({
|
|
1434
|
+
pieces: IntegerType,
|
|
1435
|
+
ran: IntegerType,
|
|
1436
|
+
cached: IntegerType,
|
|
1437
|
+
peakBytes: OptionType(IntegerType),
|
|
1438
|
+
});
|
|
1439
|
+
|
|
1394
1440
|
/**
|
|
1395
1441
|
* A split call's status, as its poll answers it.
|
|
1396
1442
|
*
|
|
1397
1443
|
* - `processing`: the job runs, and how far it has got once it has said
|
|
1398
1444
|
* - `completed`: the call's result, and the assembled output's hash once the
|
|
1399
1445
|
* pieces ran — what a caller reads through the object route when the result
|
|
1400
|
-
* is `too_large`, or passes on as the next call's `object` argument;
|
|
1401
|
-
*
|
|
1446
|
+
* is `too_large`, or passes on as the next call's `object` argument; and how
|
|
1447
|
+
* it ran ({@link SplitCallReportType}), `none` for a call found wrong, which
|
|
1448
|
+
* ran nothing. An explain found wrong ends here too, `invalid`
|
|
1402
1449
|
* - `planned`: an explain's answer, the pieces the call's run would cut, which
|
|
1403
|
-
* its job
|
|
1450
|
+
* its job planned and ran no unit for; a run plans them again, and finds the
|
|
1451
|
+
* pieces it stored
|
|
1404
1452
|
* - `failed`: why e3 could not run it
|
|
1453
|
+
* - `cancelled`: the call was cancelled before it ended, and its units
|
|
1454
|
+
* stopped; the units that finished are cached, so a relaunch is served them
|
|
1405
1455
|
*/
|
|
1406
1456
|
export const SplitCallStatusType = VariantType({
|
|
1407
1457
|
processing: OptionType(SplitCallProgressType),
|
|
1408
|
-
completed: StructType({ result: ExecuteResultType, output: OptionType(StringType) }),
|
|
1458
|
+
completed: StructType({ result: ExecuteResultType, output: OptionType(StringType), report: OptionType(SplitCallReportType) }),
|
|
1409
1459
|
planned: SplitCallPlanType,
|
|
1410
1460
|
failed: StructType({ message: StringType }),
|
|
1461
|
+
cancelled: NullType,
|
|
1462
|
+
});
|
|
1463
|
+
|
|
1464
|
+
// =============================================================================
|
|
1465
|
+
// Function calls: started, polled, cancelled, and kept for a lifetime
|
|
1466
|
+
// =============================================================================
|
|
1467
|
+
// A call of a named function through a workspace is filed, run on compute
|
|
1468
|
+
// that outlives the request, and kept once it ends: its arguments, the
|
|
1469
|
+
// versions of the inputs it read, its value and its log tails, until the
|
|
1470
|
+
// lifetime its end gives it (east-workspace#1554). A one-shot started as a
|
|
1471
|
+
// call is kept the same way, naming no function: its program is its caller's.
|
|
1472
|
+
// A kept call names its values by hash, so it stays small whatever the call
|
|
1473
|
+
// weighs.
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* A kept call's state.
|
|
1477
|
+
*
|
|
1478
|
+
* - `running`: it has not ended
|
|
1479
|
+
* - `succeeded`: it returned, and `value` is the object its value was stored as
|
|
1480
|
+
* - `failed`: its runner exited non-zero (see its stderr)
|
|
1481
|
+
* - `invalid`: it was refused before it ran: a wrong arity, a runner the
|
|
1482
|
+
* caller may not name, an input with no value
|
|
1483
|
+
* - `too_large`: its value was over its `maxResultBytes`, and was not kept
|
|
1484
|
+
* - `timed_out`: it ran past its timeout, and was stopped
|
|
1485
|
+
* - `cancelled`: it was asked to stop, by `by` (`none` without an identity),
|
|
1486
|
+
* and was stopped
|
|
1487
|
+
* - `lost`: e3 could not run it, or lost it: its host stopped before it ended
|
|
1488
|
+
*/
|
|
1489
|
+
export const FunctionCallStateType = VariantType({
|
|
1490
|
+
cancelled: StructType({ by: OptionType(StringType) }),
|
|
1491
|
+
failed: StructType({ exitCode: IntegerType }),
|
|
1492
|
+
invalid: StructType({ diagnostics: ArrayType(DiagnosticType) }),
|
|
1493
|
+
lost: StructType({ message: StringType }),
|
|
1494
|
+
running: NullType,
|
|
1495
|
+
succeeded: StructType({ value: StringType }),
|
|
1496
|
+
timed_out: StructType({ ms: IntegerType }),
|
|
1497
|
+
too_large: StructType({ bytes: IntegerType, limit: IntegerType }),
|
|
1498
|
+
});
|
|
1499
|
+
|
|
1500
|
+
/**
|
|
1501
|
+
* A kept call's argument: a value, by the object it was stored as through the
|
|
1502
|
+
* store's door; or a dataset of the workspace, by its path and the hash it was
|
|
1503
|
+
* pinned at.
|
|
1504
|
+
*/
|
|
1505
|
+
export const FunctionCallArgType = VariantType({
|
|
1506
|
+
dataset: StructType({ path: TreePathType, hash: StringType }),
|
|
1507
|
+
value: StringType,
|
|
1508
|
+
});
|
|
1509
|
+
|
|
1510
|
+
/**
|
|
1511
|
+
* A kept call, as a workspace's list of calls shows it.
|
|
1512
|
+
*
|
|
1513
|
+
* @property id - The call's id, a UUIDv7, so ids order as the calls started
|
|
1514
|
+
* @property function - The function's name in the deployed package; `none`
|
|
1515
|
+
* for a one-shot call, whose program its caller sent
|
|
1516
|
+
* @property caller - Who made the call, as the host's auth names them; `none`
|
|
1517
|
+
* for a server without auth
|
|
1518
|
+
* @property startedAt - When it was filed
|
|
1519
|
+
* @property endedAt - When it ended; `none` while it runs
|
|
1520
|
+
* @property state - How it stands, or how it ended
|
|
1521
|
+
*/
|
|
1522
|
+
export const FunctionCallSummaryType = StructType({
|
|
1523
|
+
id: StringType,
|
|
1524
|
+
function: OptionType(StringType),
|
|
1525
|
+
caller: OptionType(StringType),
|
|
1526
|
+
startedAt: DateTimeType,
|
|
1527
|
+
endedAt: OptionType(DateTimeType),
|
|
1528
|
+
state: FunctionCallStateType,
|
|
1529
|
+
});
|
|
1530
|
+
|
|
1531
|
+
/**
|
|
1532
|
+
* A kept call, whole: a {@link FunctionCallSummaryType}'s fields, and what the
|
|
1533
|
+
* call ran, took, read and wrote.
|
|
1534
|
+
*
|
|
1535
|
+
* @property package - The package it ran from, as deployed when it started;
|
|
1536
|
+
* `none` for a one-shot call, which runs no package's function
|
|
1537
|
+
* @property args - Its arguments, in order: values by their objects, datasets
|
|
1538
|
+
* by the hashes they were pinned at
|
|
1539
|
+
* @property inputs - The function's own inputs, each by its path and the hash
|
|
1540
|
+
* it was pinned at, in the order the function declares them
|
|
1541
|
+
* @property limits - The limits it ran under
|
|
1542
|
+
* @property expiresAt - When it is forgotten: its lifetime's end, which its
|
|
1543
|
+
* end sets. A running call's is past its deadline by a grace and then a
|
|
1544
|
+
* failure's lifetime, so one whose host stopped is still kept when a read
|
|
1545
|
+
* past the grace records it `lost`
|
|
1546
|
+
* @property stdout - The tail of its stdout
|
|
1547
|
+
* @property stderr - The tail of its stderr
|
|
1548
|
+
* @property stdoutTruncated - Whether `stdout` holds less than all of it
|
|
1549
|
+
* @property stderrTruncated - Whether `stderr` holds less than all of it
|
|
1550
|
+
*/
|
|
1551
|
+
export const FunctionCallType = StructType({
|
|
1552
|
+
id: StringType,
|
|
1553
|
+
function: OptionType(StringType),
|
|
1554
|
+
caller: OptionType(StringType),
|
|
1555
|
+
startedAt: DateTimeType,
|
|
1556
|
+
endedAt: OptionType(DateTimeType),
|
|
1557
|
+
state: FunctionCallStateType,
|
|
1558
|
+
package: OptionType(StructType({ name: StringType, version: StringType })),
|
|
1559
|
+
args: ArrayType(FunctionCallArgType),
|
|
1560
|
+
inputs: ArrayType(StructType({ path: TreePathType, hash: StringType })),
|
|
1561
|
+
limits: StructType({ timeoutMs: IntegerType, maxResultBytes: IntegerType, maxLogBytes: IntegerType }),
|
|
1562
|
+
expiresAt: DateTimeType,
|
|
1563
|
+
stdout: StringType,
|
|
1564
|
+
stderr: StringType,
|
|
1565
|
+
stdoutTruncated: BooleanType,
|
|
1566
|
+
stderrTruncated: BooleanType,
|
|
1567
|
+
});
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* A call's status, as its caller polls it.
|
|
1571
|
+
*
|
|
1572
|
+
* - `running`: it has not ended; poll again
|
|
1573
|
+
* - `completed`: its result, as a sync call answers it, its value inline up to
|
|
1574
|
+
* its `maxResultBytes`
|
|
1575
|
+
* - `cancelled`: it was asked to stop, by `by`, and was stopped
|
|
1576
|
+
* - `lost`: e3 could not run it, or lost it, and why
|
|
1577
|
+
*/
|
|
1578
|
+
export const FunctionCallStatusType = VariantType({
|
|
1579
|
+
cancelled: StructType({ by: OptionType(StringType) }),
|
|
1580
|
+
completed: ExecuteResultType,
|
|
1581
|
+
lost: StructType({ message: StringType }),
|
|
1582
|
+
running: NullType,
|
|
1411
1583
|
});
|
|
1412
1584
|
|
|
1585
|
+
/**
|
|
1586
|
+
* What a call's start answers: its id, and how it stood when the start
|
|
1587
|
+
* stopped waiting for it, which is `completed` for a call that ended within
|
|
1588
|
+
* the wait.
|
|
1589
|
+
*/
|
|
1590
|
+
export const FunctionCallAnswerType = StructType({
|
|
1591
|
+
id: StringType,
|
|
1592
|
+
status: FunctionCallStatusType,
|
|
1593
|
+
});
|
|
1594
|
+
|
|
1595
|
+
/**
|
|
1596
|
+
* A page of a workspace's kept calls, newest first.
|
|
1597
|
+
*
|
|
1598
|
+
* @property calls - The calls on the page
|
|
1599
|
+
* @property next - The cursor of the next page, which a request passes as
|
|
1600
|
+
* `before`; `none` on the last page
|
|
1601
|
+
*/
|
|
1602
|
+
export const FunctionCallPageType = StructType({
|
|
1603
|
+
calls: ArrayType(FunctionCallSummaryType),
|
|
1604
|
+
next: OptionType(StringType),
|
|
1605
|
+
});
|
|
1606
|
+
|
|
1607
|
+
/** The calls a page of a workspace's calls holds when its request names no `limit`. */
|
|
1608
|
+
export const FUNCTION_CALLS_PAGE_DEFAULT = 50;
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* The most calls a page holds ({@link FunctionCallPageType}): a request naming
|
|
1612
|
+
* a larger `limit` is served this many, so a page stays within what a host's
|
|
1613
|
+
* response may hold.
|
|
1614
|
+
*/
|
|
1615
|
+
export const FUNCTION_CALLS_PAGE_MAX = 200;
|
|
1616
|
+
|
|
1413
1617
|
/**
|
|
1414
1618
|
* A record mutation call. Positional args (after the implicit current state),
|
|
1415
1619
|
* one beast2-encoded value per declared parameter.
|
|
@@ -1672,6 +1876,14 @@ export type SplitCallRequest = ValueTypeOf<typeof SplitCallRequestType>;
|
|
|
1672
1876
|
export type SplitCallProgress = ValueTypeOf<typeof SplitCallProgressType>;
|
|
1673
1877
|
export type SplitCallStatus = ValueTypeOf<typeof SplitCallStatusType>;
|
|
1674
1878
|
export type SplitCallPlan = ValueTypeOf<typeof SplitCallPlanType>;
|
|
1879
|
+
export type FunctionCallState = ValueTypeOf<typeof FunctionCallStateType>;
|
|
1880
|
+
export type FunctionCallArg = ValueTypeOf<typeof FunctionCallArgType>;
|
|
1881
|
+
export type FunctionCallSummary = ValueTypeOf<typeof FunctionCallSummaryType>;
|
|
1882
|
+
export type FunctionCall = ValueTypeOf<typeof FunctionCallType>;
|
|
1883
|
+
export type FunctionCallStatus = ValueTypeOf<typeof FunctionCallStatusType>;
|
|
1884
|
+
export type FunctionCallAnswer = ValueTypeOf<typeof FunctionCallAnswerType>;
|
|
1885
|
+
export type FunctionCallPage = ValueTypeOf<typeof FunctionCallPageType>;
|
|
1886
|
+
export type SplitCallReport = ValueTypeOf<typeof SplitCallReportType>;
|
|
1675
1887
|
export type MutationCallRequest = ValueTypeOf<typeof MutationCallRequestType>;
|
|
1676
1888
|
export type MutationResult = ValueTypeOf<typeof MutationResultType>;
|
|
1677
1889
|
export type RecordMigrationApplied = ValueTypeOf<typeof RecordMigrationAppliedType>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A kept function call, as a repository's call store keeps it
|
|
8
|
+
* (east-workspace#1554).
|
|
9
|
+
*
|
|
10
|
+
* A call of a named function through a workspace is filed when it starts,
|
|
11
|
+
* runs where its backend runs calls, and is kept once it ends, until the
|
|
12
|
+
* lifetime its end gives it; so is a one-shot started as a call, its caller's
|
|
13
|
+
* program run as an anonymous function. The store keeps what readers are
|
|
14
|
+
* shown, the call as the API answers it ({@link FunctionCallType}). Beside it,
|
|
15
|
+
* it keeps what the call's run needs and no reader is shown: the function
|
|
16
|
+
* object it runs, the runner it runs on, whether it runs verbose, its
|
|
17
|
+
* deadline, and a request to cancel it.
|
|
18
|
+
*
|
|
19
|
+
* It is stored state (`WIRE_MIGRATION.md`): a change to its type ships a
|
|
20
|
+
* repository upgrade step.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import {
|
|
24
|
+
BooleanType, DateTimeType, IntegerType, OptionType, StringType, StructType, decodeBeast2For, encodeBeast2For, type ValueTypeOf,
|
|
25
|
+
} from '@elaraai/east';
|
|
26
|
+
import { FunctionCallType } from './api.js';
|
|
27
|
+
import { RunnerType } from './runner.js';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A request to cancel a running call: who asked, and when.
|
|
31
|
+
*
|
|
32
|
+
* @property by - Who asked, as the host's auth names them; `none` without an
|
|
33
|
+
* identity
|
|
34
|
+
* @property at - When they asked
|
|
35
|
+
*/
|
|
36
|
+
export const FunctionCallCancelType = StructType({
|
|
37
|
+
by: OptionType(StringType),
|
|
38
|
+
at: DateTimeType,
|
|
39
|
+
});
|
|
40
|
+
export type FunctionCallCancelType = typeof FunctionCallCancelType;
|
|
41
|
+
|
|
42
|
+
/** A request to cancel a running call. */
|
|
43
|
+
export type FunctionCallCancel = ValueTypeOf<typeof FunctionCallCancelType>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* How long a call is kept once it ends, by how it ended, in milliseconds: the
|
|
47
|
+
* lifetimes the host that filed it gives, which whatever records its end
|
|
48
|
+
* applies.
|
|
49
|
+
*
|
|
50
|
+
* @property succeeded - A call that succeeded, or was cancelled
|
|
51
|
+
* @property failed - A call that failed, was refused (`invalid`), returned too
|
|
52
|
+
* large a value, timed out, or was lost
|
|
53
|
+
*/
|
|
54
|
+
export const FunctionCallKeepType = StructType({
|
|
55
|
+
succeeded: IntegerType,
|
|
56
|
+
failed: IntegerType,
|
|
57
|
+
});
|
|
58
|
+
export type FunctionCallKeepType = typeof FunctionCallKeepType;
|
|
59
|
+
|
|
60
|
+
/** How long a call is kept once it ends. */
|
|
61
|
+
export type FunctionCallKeep = ValueTypeOf<typeof FunctionCallKeepType>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A kept call, as its store keeps it.
|
|
65
|
+
*
|
|
66
|
+
* @property call - The call as readers are shown it
|
|
67
|
+
* @property workspace - The workspace it was called through
|
|
68
|
+
* @property functionObject - The hash of the function object it runs: the one
|
|
69
|
+
* the deployed package named when it started, whatever is deployed since;
|
|
70
|
+
* for a one-shot call, the anonymous one its start stored, naming the
|
|
71
|
+
* caller's program, its types and its runner, and no inputs
|
|
72
|
+
* @property runner - The runner it runs on: the function's own, or one the
|
|
73
|
+
* call named and its caller's grant allowed; a one-shot call's own
|
|
74
|
+
* @property verbose - Whether a stock runner runs it with `-v`
|
|
75
|
+
* @property deadline - When its timeout ends: a call still recorded running
|
|
76
|
+
* once its deadline and a grace have passed is lost
|
|
77
|
+
* @property cancel - A request to cancel it, once one is made
|
|
78
|
+
* @property keep - How long it is kept once it ends, by how it ended
|
|
79
|
+
*/
|
|
80
|
+
export const FunctionCallJobType = StructType({
|
|
81
|
+
call: FunctionCallType,
|
|
82
|
+
workspace: StringType,
|
|
83
|
+
functionObject: StringType,
|
|
84
|
+
runner: RunnerType,
|
|
85
|
+
verbose: BooleanType,
|
|
86
|
+
deadline: DateTimeType,
|
|
87
|
+
cancel: OptionType(FunctionCallCancelType),
|
|
88
|
+
keep: FunctionCallKeepType,
|
|
89
|
+
});
|
|
90
|
+
export type FunctionCallJobType = typeof FunctionCallJobType;
|
|
91
|
+
|
|
92
|
+
/** A kept call, as its store keeps it. */
|
|
93
|
+
export type FunctionCallJob = ValueTypeOf<typeof FunctionCallJobType>;
|
|
94
|
+
|
|
95
|
+
const encodeJob = encodeBeast2For(FunctionCallJobType);
|
|
96
|
+
const decodeJob = decodeBeast2For(FunctionCallJobType);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Encode a kept call as its store keeps it, in beast2.
|
|
100
|
+
*
|
|
101
|
+
* @param job - The call
|
|
102
|
+
* @returns Its bytes
|
|
103
|
+
*/
|
|
104
|
+
export function encodeFunctionCallJob(job: FunctionCallJob): Uint8Array {
|
|
105
|
+
return encodeJob(job);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Decode a kept call from its store's bytes.
|
|
110
|
+
*
|
|
111
|
+
* @param bytes - The call's bytes, as {@link encodeFunctionCallJob} wrote them
|
|
112
|
+
* @returns The call
|
|
113
|
+
* @throws {Error} When the bytes are not a kept call of this release's form
|
|
114
|
+
*/
|
|
115
|
+
export function decodeFunctionCallJob(bytes: Uint8Array): FunctionCallJob {
|
|
116
|
+
return decodeJob(bytes);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* What a kept call names, which gc keeps while the call is kept: the function
|
|
121
|
+
* object it runs, and with it the program the object names; each value
|
|
122
|
+
* argument's object; the version of each dataset argument and each input it
|
|
123
|
+
* read; and its value once it succeeded. A one-shot call's function object is
|
|
124
|
+
* its own, which no package names, so the call alone keeps it, and its
|
|
125
|
+
* program, for as long as it runs and is kept.
|
|
126
|
+
*
|
|
127
|
+
* @param job - The call
|
|
128
|
+
* @returns The hashes it names: its function object's, then its arguments' in
|
|
129
|
+
* order, then its inputs', then its value's
|
|
130
|
+
*/
|
|
131
|
+
export function functionCallRoots(job: FunctionCallJob): string[] {
|
|
132
|
+
const { call } = job;
|
|
133
|
+
const roots = [job.functionObject, ...call.args.map((arg) => (arg.type === 'value' ? arg.value : arg.value.hash))];
|
|
134
|
+
for (const input of call.inputs) roots.push(input.hash);
|
|
135
|
+
if (call.state.type === 'succeeded') roots.push(call.state.value.value);
|
|
136
|
+
return roots;
|
|
137
|
+
}
|
package/src/function.ts
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* Function object types for e3.
|
|
8
8
|
*
|
|
9
9
|
* An `e3.function` is a named, typed function stored in a package and
|
|
10
|
-
* invoked by name with argument values over the CLI and HTTP API.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* invoked by name with argument values over the CLI and HTTP API. It may
|
|
11
|
+
* read datasets of the workspace a call runs through — its inputs — beside
|
|
12
|
+
* the arguments its caller passes. Unlike a task it is not part of the
|
|
13
|
+
* dataflow graph, and triggers no recomputation.
|
|
13
14
|
*
|
|
14
15
|
* The function object stores its signature explicitly so `describe` and
|
|
15
16
|
* arity/type validation work from the small function object without
|
|
@@ -19,17 +20,25 @@
|
|
|
19
20
|
|
|
20
21
|
import { StructType, StringType, ArrayType, EastTypeType, OptionType, ValueTypeOf, decodeBeast2For } from '@elaraai/east';
|
|
21
22
|
import { RunnerType } from './runner.js';
|
|
23
|
+
import { TreePathType } from './structure.js';
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* Function object stored in the object store, referenced by name from
|
|
25
27
|
* `PackageObject.functions`.
|
|
26
28
|
*/
|
|
27
29
|
export const FunctionObjectType = StructType({
|
|
28
|
-
/** Hash of the encoded EastIR bundle (encodeEastIR), as a task's program is.
|
|
30
|
+
/** Hash of the encoded EastIR bundle (encodeEastIR), as a task's program is.
|
|
31
|
+
* Its parameters are the inputs' types, in `inputs` order, then
|
|
32
|
+
* `argTypes`. */
|
|
29
33
|
bodyIr: StringType,
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
|
|
34
|
+
/** The datasets a call reads from the workspace it runs in, each pinned at
|
|
35
|
+
* its hash when the call launches and passed before the caller's
|
|
36
|
+
* arguments; empty for a function that reads none. */
|
|
37
|
+
inputs: ArrayType(TreePathType),
|
|
38
|
+
/** The types of the arguments a caller passes, after the inputs, surfaced
|
|
39
|
+
* for arity/type validation and `describe` without decoding the whole
|
|
40
|
+
* IR. */
|
|
41
|
+
argTypes: ArrayType(EastTypeType),
|
|
33
42
|
/** Return type — used to decode the result `value` blob client-side. */
|
|
34
43
|
outputType: EastTypeType,
|
|
35
44
|
/** Author-chosen runtime: a stock runner runs the function as a unit, and a
|
package/src/index.ts
CHANGED
|
@@ -112,6 +112,19 @@ export {
|
|
|
112
112
|
decodeFunctionObject,
|
|
113
113
|
} from './function.js';
|
|
114
114
|
|
|
115
|
+
// Kept function calls, as a repository's call store keeps them
|
|
116
|
+
export {
|
|
117
|
+
FunctionCallCancelType,
|
|
118
|
+
type FunctionCallCancel,
|
|
119
|
+
FunctionCallKeepType,
|
|
120
|
+
type FunctionCallKeep,
|
|
121
|
+
FunctionCallJobType,
|
|
122
|
+
type FunctionCallJob,
|
|
123
|
+
encodeFunctionCallJob,
|
|
124
|
+
decodeFunctionCallJob,
|
|
125
|
+
functionCallRoots,
|
|
126
|
+
} from './function-call.js';
|
|
127
|
+
|
|
115
128
|
// Record objects
|
|
116
129
|
export {
|
|
117
130
|
RecordCommitType,
|
|
@@ -141,6 +154,7 @@ export {
|
|
|
141
154
|
NestedEntryKeyType,
|
|
142
155
|
NestedSpanKeyType,
|
|
143
156
|
nestedSpanName,
|
|
157
|
+
entriesRowsName,
|
|
144
158
|
RecordNestedTotalsType,
|
|
145
159
|
type RecordNestedTotals,
|
|
146
160
|
NestedEntryType,
|
|
@@ -442,6 +456,17 @@ export {
|
|
|
442
456
|
SplitCallProgressType,
|
|
443
457
|
SplitCallStatusType,
|
|
444
458
|
SplitCallPlanType,
|
|
459
|
+
// Function calls, kept for a lifetime
|
|
460
|
+
FunctionCallStateType,
|
|
461
|
+
FunctionCallArgType,
|
|
462
|
+
FunctionCallSummaryType,
|
|
463
|
+
FunctionCallType,
|
|
464
|
+
FunctionCallStatusType,
|
|
465
|
+
FunctionCallAnswerType,
|
|
466
|
+
FunctionCallPageType,
|
|
467
|
+
FUNCTION_CALLS_PAGE_DEFAULT,
|
|
468
|
+
FUNCTION_CALLS_PAGE_MAX,
|
|
469
|
+
SplitCallReportType,
|
|
445
470
|
MutationCallRequestType,
|
|
446
471
|
MutationResultType,
|
|
447
472
|
RecordMigrationAppliedType,
|
|
@@ -518,6 +543,14 @@ export {
|
|
|
518
543
|
type SplitCallProgress,
|
|
519
544
|
type SplitCallStatus,
|
|
520
545
|
type SplitCallPlan,
|
|
546
|
+
type FunctionCallState,
|
|
547
|
+
type FunctionCallArg,
|
|
548
|
+
type FunctionCallSummary,
|
|
549
|
+
type FunctionCall,
|
|
550
|
+
type FunctionCallStatus,
|
|
551
|
+
type FunctionCallAnswer,
|
|
552
|
+
type FunctionCallPage,
|
|
553
|
+
type SplitCallReport,
|
|
521
554
|
type MutationCallRequest,
|
|
522
555
|
type MutationResult,
|
|
523
556
|
type RecordMigrationApplied,
|
package/src/names.ts
CHANGED
|
@@ -18,8 +18,8 @@ export type NamedKind = 'repository' | 'workspace' | 'package' | 'package versio
|
|
|
18
18
|
export type HashKind = 'object hash' | 'task hash' | 'inputs hash';
|
|
19
19
|
|
|
20
20
|
/** What an id e3 makes a path or a key of names: an execution attempt, a
|
|
21
|
-
* dataflow run,
|
|
22
|
-
export type IdKind = 'execution id' | 'run id' | 'gc run id';
|
|
21
|
+
* dataflow run, a gc run in steps, or a kept function call. */
|
|
22
|
+
export type IdKind = 'execution id' | 'run id' | 'gc run id' | 'call id';
|
|
23
23
|
|
|
24
24
|
/** What a hash or an id e3 makes a path or a key of names: not a name, so
|
|
25
25
|
* checked for its form rather than by {@link nameProblem}. */
|
package/src/record.ts
CHANGED
|
@@ -325,6 +325,20 @@ export function nestedSpanName(index: string): string {
|
|
|
325
325
|
return `${index}_span`;
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
+
/**
|
|
329
|
+
* The name of the index an entries index's lean rows are kept in, beside it
|
|
330
|
+
* (#1521): the record's rows by key, each with the Dict field the entries
|
|
331
|
+
* index files emptied — an index of its record's, built with it and never
|
|
332
|
+
* declared, as a nested series index's span is. A reader of the entries reads
|
|
333
|
+
* the rows here, without the entries it reads apart.
|
|
334
|
+
*
|
|
335
|
+
* @param index - The entries index's name
|
|
336
|
+
* @returns Its lean rows'
|
|
337
|
+
*/
|
|
338
|
+
export function entriesRowsName(index: string): string {
|
|
339
|
+
return `${index}_rows`;
|
|
340
|
+
}
|
|
341
|
+
|
|
328
342
|
/**
|
|
329
343
|
* One collection's totals in one summary tile (#1434), for one node, or for
|
|
330
344
|
* its descendants' items under `subtreeTotals`.
|
package/src/release.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/** The release of e3 this build is. */
|
|
20
|
-
export const E3_RELEASE = '1.0.
|
|
20
|
+
export const E3_RELEASE = '1.0.105';
|
|
21
21
|
|
|
22
22
|
/** A semantic version: its core, a pre-release, and build metadata. */
|
|
23
23
|
const RELEASE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|