@elaraai/e3-types 1.0.108 → 1.0.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/src/api.d.ts +382 -17
  2. package/dist/src/api.d.ts.map +1 -1
  3. package/dist/src/api.js +201 -17
  4. package/dist/src/api.js.map +1 -1
  5. package/dist/src/environment.d.ts +95 -8
  6. package/dist/src/environment.d.ts.map +1 -1
  7. package/dist/src/environment.js +102 -9
  8. package/dist/src/environment.js.map +1 -1
  9. package/dist/src/environment.spec.js +31 -19
  10. package/dist/src/environment.spec.js.map +1 -1
  11. package/dist/src/function-call.d.ts +91 -13
  12. package/dist/src/function-call.d.ts.map +1 -1
  13. package/dist/src/function-call.js +48 -4
  14. package/dist/src/function-call.js.map +1 -1
  15. package/dist/src/function-draft.d.ts +80 -0
  16. package/dist/src/function-draft.d.ts.map +1 -0
  17. package/dist/src/function-draft.js +71 -0
  18. package/dist/src/function-draft.js.map +1 -0
  19. package/dist/src/function-draft.spec.d.ts +6 -0
  20. package/dist/src/function-draft.spec.d.ts.map +1 -0
  21. package/dist/src/function-draft.spec.js +58 -0
  22. package/dist/src/function-draft.spec.js.map +1 -0
  23. package/dist/src/function.d.ts +45 -8
  24. package/dist/src/function.d.ts.map +1 -1
  25. package/dist/src/function.js +40 -7
  26. package/dist/src/function.js.map +1 -1
  27. package/dist/src/function.spec.d.ts +6 -0
  28. package/dist/src/function.spec.d.ts.map +1 -0
  29. package/dist/src/function.spec.js +61 -0
  30. package/dist/src/function.spec.js.map +1 -0
  31. package/dist/src/index.d.ts +7 -6
  32. package/dist/src/index.d.ts.map +1 -1
  33. package/dist/src/index.js +9 -7
  34. package/dist/src/index.js.map +1 -1
  35. package/dist/src/record.d.ts +81 -29
  36. package/dist/src/record.d.ts.map +1 -1
  37. package/dist/src/record.js +92 -22
  38. package/dist/src/record.js.map +1 -1
  39. package/dist/src/release.d.ts +1 -1
  40. package/dist/src/release.js +1 -1
  41. package/dist/src/structure.d.ts +18 -0
  42. package/dist/src/structure.d.ts.map +1 -1
  43. package/dist/src/structure.js +20 -0
  44. package/dist/src/structure.js.map +1 -1
  45. package/dist/src/structure.spec.js +8 -1
  46. package/dist/src/structure.spec.js.map +1 -1
  47. package/dist/src/task.d.ts +15 -2
  48. package/dist/src/task.d.ts.map +1 -1
  49. package/dist/src/task.js +14 -2
  50. package/dist/src/task.js.map +1 -1
  51. package/dist/src/task.spec.js +19 -2
  52. package/dist/src/task.spec.js.map +1 -1
  53. package/package.json +2 -2
  54. package/src/api.ts +215 -17
  55. package/src/environment.spec.ts +42 -21
  56. package/src/environment.ts +109 -9
  57. package/src/function-call.ts +52 -4
  58. package/src/function-draft.spec.ts +69 -0
  59. package/src/function-draft.ts +96 -0
  60. package/src/function.spec.ts +66 -0
  61. package/src/function.ts +44 -7
  62. package/src/index.ts +38 -2
  63. package/src/record.ts +97 -24
  64. package/src/release.ts +1 -1
  65. package/src/structure.spec.ts +9 -1
  66. package/src/structure.ts +21 -0
  67. package/src/task.spec.ts +20 -2
  68. package/src/task.ts +14 -2
@@ -17,7 +17,7 @@
17
17
  * an object holding the file's bytes as a beast2 Blob, which rides the
18
18
  * content-addressed object store and transfer machinery.
19
19
  */
20
- import { ArrayType, OptionType, StringType, StructType, VariantType } from '@elaraai/east';
20
+ import { ArrayType, OptionType, StringType, StructType, VariantType, decodeBeast2For, isTypeValueEqual, readBeast2Type, toEastTypeValue, } from '@elaraai/east';
21
21
  /**
22
22
  * A Python (uv) project environment.
23
23
  *
@@ -139,6 +139,49 @@ export const WorkspaceNodeEnvironmentType = StructType({
139
139
  /** Dependency closure (path + package name + tarball hash), sorted by path */
140
140
  members: ArrayType(StructType({ path: StringType, name: StringType, tarball: StringType })),
141
141
  });
142
+ /**
143
+ * A Python **workspace-member** environment (a uv workspace).
144
+ *
145
+ * Where {@link PythonEnvironmentType} captures one self-contained project,
146
+ * whose locked dependencies are all its own, this captures members of a
147
+ * workspace: the workspace root's manifest and lock, which pin everything,
148
+ * and the code of exactly the members the environment is of and the local
149
+ * packages they depend on. Materialized by installing, from the root lock,
150
+ * the third-party dependencies of those members alone — what `uv export
151
+ * --frozen --no-default-groups --package <member>` lists — then the
152
+ * distributions `requires` names, then the members' own sdists. Nothing else
153
+ * the workspace root or another member depends on is installed, and none of
154
+ * a member's development groups.
155
+ *
156
+ * @remarks
157
+ * - `pyproject`: object hash of the workspace **root** `pyproject.toml` blob.
158
+ * - `lock`: object hash of the **root** `uv.lock` blob.
159
+ * - `subjects`: the members the environment is of, by the names the lock
160
+ * gives them, sorted: a task's runner names one or more as its custom
161
+ * platform packages.
162
+ * - `sdists`: the source distributions of the subjects and of every local
163
+ * package they depend on, each with its original filename, sorted by it.
164
+ * - `requires`: the lock's registry distributions installed beside the
165
+ * subjects' own dependencies, sorted: the runtime's (`elaraai-east-py`,
166
+ * `elaraai-east-py-cli`) and those of the stock platform packages the
167
+ * task's runner names (`elaraai-east-py-std`), which a workspace commonly
168
+ * lists on its root alone. Each is named with the extras the workspace
169
+ * declares it with (`elaraai-east-py-datascience[lightning]`), and
170
+ * installed at the version the lock pins, with what it and those extras
171
+ * depend on.
172
+ */
173
+ export const WorkspacePythonEnvironmentType = StructType({
174
+ /** Object hash of the workspace root pyproject.toml blob */
175
+ pyproject: StringType,
176
+ /** Object hash of the root uv.lock blob */
177
+ lock: StringType,
178
+ /** The members the environment is of, by the lock's names, sorted */
179
+ subjects: ArrayType(StringType),
180
+ /** The closure's sdist blobs (original filename + object hash), sorted by filename */
181
+ sdists: ArrayType(StructType({ filename: StringType, hash: StringType })),
182
+ /** The lock's registry distributions installed beside the subjects' own, sorted */
183
+ requires: ArrayType(StringType),
184
+ });
142
185
  /**
143
186
  * An execution environment specification.
144
187
  *
@@ -147,14 +190,12 @@ export const WorkspaceNodeEnvironmentType = StructType({
147
190
  * (`none`) runs on the stock runtime image as today.
148
191
  *
149
192
  * @remarks
150
- * BEAST2 encodes a variant's tag as the index of its case in the
151
- * **alphabetically sorted** case list, so the case order is load-bearing: a
152
- * repo persists specs by that order, and reordering the cases in a later
153
- * edit would re-tag every case after the insertion point and mis-decode
154
- * already-stored specs. New cases must therefore be added so the sorted
155
- * order only grows at the end (`tools` and `workspace_node` sort after the
156
- * original three). The frozen-order guard test in `environment.spec.ts`
157
- * turns an accidental reorder into a red test.
193
+ * A spec is package-borne: an export writes it, at the type of the e3 that
194
+ * exported the package. It is read at this type alone
195
+ * ({@link decodeEnvironmentSpec}): a spec an earlier release wrote, of a type
196
+ * with other cases, is refused, and its package exported again
197
+ * (`docs/conventions/WIRE_MIGRATION.md`). So a case added here changes the
198
+ * bytes, and the hash, of every spec an export writes after it.
158
199
  */
159
200
  export const EnvironmentSpecType = VariantType({
160
201
  /** Python (uv) project environment */
@@ -167,7 +208,57 @@ export const EnvironmentSpecType = VariantType({
167
208
  tools: ToolsEnvironmentType,
168
209
  /** Node workspace-member environment (npm/pnpm workspaces) */
169
210
  workspace_node: WorkspaceNodeEnvironmentType,
211
+ /** Python workspace-member environment (a uv workspace) */
212
+ workspace_python: WorkspacePythonEnvironmentType,
170
213
  });
214
+ const ENVIRONMENT_SPEC_TYPE = toEastTypeValue(EnvironmentSpecType);
215
+ const decodeSpec = decodeBeast2For(EnvironmentSpecType);
216
+ /** The names of this release's cases of a spec. */
217
+ const SPEC_CASES = new Set(Object.keys(EnvironmentSpecType.cases));
218
+ /**
219
+ * Decodes an environment's spec object, as this release writes it.
220
+ *
221
+ * @remarks
222
+ * Whatever reads a spec reads it here, so a spec of another type is refused in
223
+ * one set of words wherever it is read, by its type, before it is read. The
224
+ * spec's type grows by cases, so the refusal names the fix by its cases:
225
+ * - each a case this release names: an earlier SDK wrote it, of a type with
226
+ * fewer cases, which would decode at this one still; its package is
227
+ * exported again, as one whose file an older SDK stored raw is;
228
+ * - a case this release does not name: a later SDK wrote it, which this
229
+ * release cannot read; e3 is upgraded to the release that exported it;
230
+ * - no variant at all, or no beast2: it is no spec.
231
+ *
232
+ * @param data - The object's bytes
233
+ * @param hash - The object's hash, which a refusal names
234
+ * @returns The spec
235
+ * @throws {Error} When the object is not a spec of this release's type, saying
236
+ * which of the three it is
237
+ * @example
238
+ * ```ts
239
+ * const spec = decodeEnvironmentSpec(await storage.objects.read(repo, envHash), envHash);
240
+ * ```
241
+ */
242
+ export function decodeEnvironmentSpec(data, hash) {
243
+ let type = null;
244
+ try {
245
+ type = readBeast2Type(data);
246
+ }
247
+ catch {
248
+ // Not beast2 at all
249
+ }
250
+ if (type !== null && isTypeValueEqual(type, ENVIRONMENT_SPEC_TYPE))
251
+ return decodeSpec(data);
252
+ if (type === null || type.type !== 'Variant' || type.value.length === 0) {
253
+ throw new Error(`the object ${hash} is not an environment's spec`);
254
+ }
255
+ if (type.value.every(({ name }) => SPEC_CASES.has(name))) {
256
+ throw new Error(`the environment ${hash} was exported by an older e3 SDK — re-export its package with the current one`);
257
+ }
258
+ const unknown = type.value.map(({ name }) => name).filter((name) => !SPEC_CASES.has(name));
259
+ throw new Error(`the environment ${hash} was exported by a newer e3 SDK than this one, as its ${unknown.join(', ')} says — ` +
260
+ 'upgrade e3 to the release that exported its package');
261
+ }
171
262
  /**
172
263
  * Lists the object-store hashes an environment spec references.
173
264
  *
@@ -194,6 +285,8 @@ export function environmentSpecObjectHashes(spec) {
194
285
  ...(spec.value.config.type === 'some' ? [spec.value.config.value] : []),
195
286
  ...spec.value.members.map((m) => m.tarball),
196
287
  ];
288
+ case 'workspace_python':
289
+ return [spec.value.pyproject, spec.value.lock, ...spec.value.sdists.map((s) => s.hash)];
197
290
  }
198
291
  }
199
292
  //# sourceMappingURL=environment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAe,WAAW,EAAE,MAAM,eAAe,CAAC;AAExG;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CAAC,CAAC,CAAC,EAAE,CAAC;gBACvE,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;aAC5C,CAAC;QACJ,KAAK,kBAAkB;YACrB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC"}
@@ -3,30 +3,32 @@
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
5
  /**
6
- * Encode/decode contract for {@link EnvironmentSpecType}.
7
- *
8
- * BEAST2 encodes a variant's tag as the index of its case in the
9
- * alphabetically-sorted case list, so the case order is load-bearing: a repo
10
- * persists specs by that order, and a later code edit that inserts a case
11
- * before an existing one silently re-tags every later case and mis-decodes
12
- * already-stored specs. The frozen-order test pins the order so that mistake
13
- * is a red test; the round-trip tests pin the new cases.
6
+ * Encode/decode contract for {@link EnvironmentSpecType}: every case round
7
+ * trips through {@link decodeEnvironmentSpec}, which reads a spec at this
8
+ * release's type alone.
14
9
  */
15
10
  import { describe, it } from 'node:test';
16
11
  import * as assert from 'node:assert';
17
- import { encodeBeast2For, decodeBeast2For, variant, some, none } from '@elaraai/east';
18
- import { EnvironmentSpecType, environmentSpecObjectHashes, } from './environment.js';
12
+ import { StringType, VariantType, encodeBeast2For, variant, some, none } from '@elaraai/east';
13
+ import { EnvironmentSpecType, ImageEnvironmentType, NodeEnvironmentType, PythonEnvironmentType, ToolsEnvironmentType, WorkspaceNodeEnvironmentType, decodeEnvironmentSpec, environmentSpecObjectHashes, } from './environment.js';
19
14
  const encodeCurrent = encodeBeast2For(EnvironmentSpecType);
20
- const decodeCurrent = decodeBeast2For(EnvironmentSpecType);
15
+ const decodeCurrent = (bytes) => decodeEnvironmentSpec(bytes, H('9'));
21
16
  const H = (c) => c.repeat(64); // stand-in 64-hex object hash
22
- describe('EnvironmentSpecType frozen case order', () => {
23
- it('is exactly [image, node, python, tools, workspace_node]', () => {
24
- // BEAST2 tags are indices into this sorted list. A new case must be
25
- // added so the order only grows at the end (or readers must migrate to
26
- // name-based decoding first) — inserting before an existing case
27
- // re-tags every later one and mis-decodes stored specs. This assertion
28
- // turns that mistake into a red test.
29
- assert.deepStrictEqual(Object.keys(EnvironmentSpecType.cases), ['image', 'node', 'python', 'tools', 'workspace_node']);
17
+ describe('decodeEnvironmentSpec', () => {
18
+ it('refuses a spec an earlier release exported, which decodes at this type, naming the re-export; a later release\'s, naming the upgrade; and what is no spec', () => {
19
+ // The type before its `workspace_python` case: its values decode at today's, and are refused by their type
20
+ const Earlier = VariantType({
21
+ python: PythonEnvironmentType, node: NodeEnvironmentType, image: ImageEnvironmentType, tools: ToolsEnvironmentType,
22
+ workspace_node: WorkspaceNodeEnvironmentType,
23
+ });
24
+ const tools = variant('tools', { files: [{ path: 'bin/my-runner', hash: H('1') }] });
25
+ assert.throws(() => decodeEnvironmentSpec(encodeBeast2For(Earlier)(tools), H('a')), { message: `the environment ${H('a')} was exported by an older e3 SDK — re-export its package with the current one` });
26
+ // A later release's, with a case this one does not know: re-exporting with this one cannot help
27
+ const Later = VariantType({ ...EnvironmentSpecType.cases, conda: StringType });
28
+ assert.throws(() => decodeEnvironmentSpec(encodeBeast2For(Later)(tools), H('a')), { message: `the environment ${H('a')} was exported by a newer e3 SDK than this one, as its conda says — upgrade e3 to the release that exported its package` });
29
+ for (const bytes of [encodeBeast2For(StringType)('not a spec'), new TextEncoder().encode('not beast2')]) {
30
+ assert.throws(() => decodeEnvironmentSpec(bytes, H('a')), { message: `the object ${H('a')} is not an environment's spec` });
31
+ }
30
32
  });
31
33
  });
32
34
  describe('EnvironmentSpecType round-trips every case', () => {
@@ -39,6 +41,10 @@ describe('EnvironmentSpecType round-trips every case', () => {
39
41
  packageJson: H('2'), lock: H('3'), config: none, subject: 'packages/pricing',
40
42
  members: [{ path: 'packages/pricing', name: '@acme/pricing', tarball: H('4') }],
41
43
  }),
44
+ variant('workspace_python', {
45
+ pyproject: H('5'), lock: H('6'), subjects: ['features'],
46
+ sdists: [{ filename: 'features-0.1.0.tar.gz', hash: H('7') }], requires: ['elaraai-east-py', 'elaraai-east-py-std'],
47
+ }),
42
48
  ];
43
49
  it('encodes and decodes back to the same value', () => {
44
50
  for (const spec of specs) {
@@ -80,6 +86,12 @@ describe('environmentSpecObjectHashes', () => {
80
86
  members: [{ path: 'packages/x', name: '@acme/x', tarball: 't1' }, { path: 'packages/y', name: '@acme/y', tarball: 't2' }],
81
87
  })), ['p', 'l', 'cfg', 't1', 't2']);
82
88
  });
89
+ it('lists a workspace_python\'s root manifest, lock and every sdist', () => {
90
+ assert.deepStrictEqual(environmentSpecObjectHashes(variant('workspace_python', {
91
+ pyproject: 'p', lock: 'l', subjects: ['features', 'trainer'],
92
+ sdists: [{ filename: 'features-0.1.0.tar.gz', hash: 's1' }, { filename: 'trainer-0.1.0.tar.gz', hash: 's2' }], requires: [],
93
+ })), ['p', 'l', 's1', 's2']);
94
+ });
83
95
  it('omits the config hash for an npm workspace_node (none)', () => {
84
96
  assert.deepStrictEqual(environmentSpecObjectHashes(variant('workspace_node', {
85
97
  packageJson: 'p', lock: 'l', config: none, subject: 'packages/x',
@@ -1 +1 @@
1
- {"version":3,"file":"environment.spec.js","sourceRoot":"","sources":["../../src/environment.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;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link FunctionCallType}). Beside it,
14
14
  * it keeps what the call's run needs and no reader is shown: the function
15
15
  * object it runs, the runner it runs on, whether it runs verbose, its
16
- * deadline, and a request to cancel it.
16
+ * deadline, a request to cancel it, and what its run lays its drafts from.
17
17
  *
18
18
  * It is stored state (`WIRE_MIGRATION.md`): a change to its type ships a
19
19
  * repository upgrade step.
20
20
  */
21
- import { BooleanType, DateTimeType, IntegerType, OptionType, StringType, StructType, type ValueTypeOf } from '@elaraai/east';
21
+ import { ArrayType, BooleanType, DateTimeType, DictType, IntegerType, OptionType, StringType, StructType, type ValueTypeOf } from '@elaraai/east';
22
22
  /**
23
23
  * A request to cancel a running call: who asked, and when.
24
24
  *
@@ -40,7 +40,7 @@ export type FunctionCallCancel = ValueTypeOf<typeof FunctionCallCancelType>;
40
40
  *
41
41
  * @property succeeded - A call that succeeded, or was cancelled
42
42
  * @property failed - A call that failed, was refused (`invalid`), returned too
43
- * large a value, timed out, or was lost
43
+ * large a value, timed out, met a `conflict` laying a draft, or was lost
44
44
  */
45
45
  export declare const FunctionCallKeepType: StructType<{
46
46
  readonly succeeded: IntegerType;
@@ -49,6 +49,37 @@ export declare const FunctionCallKeepType: StructType<{
49
49
  export type FunctionCallKeepType = typeof FunctionCallKeepType;
50
50
  /** How long a call is kept once it ends. */
51
51
  export type FunctionCallKeep = ValueTypeOf<typeof FunctionCallKeepType>;
52
+ /**
53
+ * A record a kept call drafts, as its run lays the drafts: everything the
54
+ * laying reads, named as the call started, so the run reads the workspace no
55
+ * more and lays the same state however often it is run; and the commit the
56
+ * record stood at, which the call's result names.
57
+ *
58
+ * @property record - The record's name, as the call's drafts name it
59
+ * @property path - Where the workspace holds the record: the call's inputs at
60
+ * this path are read at the drafted state, and a dataset argument naming it
61
+ * as saved, at `base`
62
+ * @property base - The state the record held as the call started, which the
63
+ * call's drafts of it are laid over, in order
64
+ * @property commit - The commit the record stood at as the call started,
65
+ * read with `base`: a caller that holds another knows its edits were laid
66
+ * over newer saves
67
+ * @property mutations - The object of each mutation the call's drafts of the
68
+ * record name, by the mutation's name: the one the deployed package named
69
+ * when the call started, whatever is deployed since
70
+ */
71
+ export declare const FunctionCallDraftedType: StructType<{
72
+ readonly record: StringType;
73
+ readonly path: ArrayType<import("@elaraai/east").VariantType<{
74
+ readonly field: StringType;
75
+ }>>;
76
+ readonly base: StringType;
77
+ readonly commit: StringType;
78
+ readonly mutations: DictType<StringType, StringType>;
79
+ }>;
80
+ export type FunctionCallDraftedType = typeof FunctionCallDraftedType;
81
+ /** A record a kept call drafts, as its run lays the drafts. */
82
+ export type FunctionCallDrafted = ValueTypeOf<typeof FunctionCallDraftedType>;
52
83
  /**
53
84
  * A kept call, as its store keeps it.
54
85
  *
@@ -65,6 +96,9 @@ export type FunctionCallKeep = ValueTypeOf<typeof FunctionCallKeepType>;
65
96
  * once its deadline and a grace have passed is lost
66
97
  * @property cancel - A request to cancel it, once one is made
67
98
  * @property keep - How long it is kept once it ends, by how it ended
99
+ * @property drafted - The records it drafts, each once, in the order its
100
+ * drafts first name them, with what its run lays them from and the commit
101
+ * each stood at; none for a call that passed no draft
68
102
  */
69
103
  export declare const FunctionCallJobType: StructType<{
70
104
  readonly call: StructType<{
@@ -77,11 +111,18 @@ export declare const FunctionCallJobType: StructType<{
77
111
  readonly cancelled: StructType<{
78
112
  readonly by: OptionType<StringType>;
79
113
  }>;
114
+ readonly conflict: StructType<{
115
+ readonly record: StringType;
116
+ readonly mutation: StringType;
117
+ readonly place: IntegerType;
118
+ readonly of: IntegerType;
119
+ readonly message: StringType;
120
+ }>;
80
121
  readonly failed: StructType<{
81
122
  readonly exitCode: IntegerType;
82
123
  }>;
83
124
  readonly invalid: StructType<{
84
- readonly diagnostics: import("@elaraai/east").ArrayType<StructType<{
125
+ readonly diagnostics: ArrayType<StructType<{
85
126
  readonly message: StringType;
86
127
  readonly filename: OptionType<StringType>;
87
128
  readonly line: OptionType<IntegerType>;
@@ -107,21 +148,42 @@ export declare const FunctionCallJobType: StructType<{
107
148
  readonly name: StringType;
108
149
  readonly version: StringType;
109
150
  }>>;
110
- readonly args: import("@elaraai/east").ArrayType<import("@elaraai/east").VariantType<{
151
+ readonly args: ArrayType<import("@elaraai/east").VariantType<{
111
152
  readonly dataset: StructType<{
112
- readonly path: import("@elaraai/east").ArrayType<import("@elaraai/east").VariantType<{
153
+ readonly path: ArrayType<import("@elaraai/east").VariantType<{
113
154
  readonly field: StringType;
114
155
  }>>;
115
156
  readonly hash: StringType;
116
157
  }>;
117
158
  readonly value: StringType;
118
159
  }>>;
119
- readonly inputs: import("@elaraai/east").ArrayType<StructType<{
120
- readonly path: import("@elaraai/east").ArrayType<import("@elaraai/east").VariantType<{
160
+ readonly inputs: ArrayType<StructType<{
161
+ readonly path: ArrayType<import("@elaraai/east").VariantType<{
121
162
  readonly field: StringType;
122
163
  }>>;
164
+ readonly index: OptionType<StringType>;
123
165
  readonly hash: StringType;
124
166
  }>>;
167
+ readonly drafts: ArrayType<StructType<{
168
+ readonly record: StringType;
169
+ readonly mutation: StringType;
170
+ readonly args: OptionType<StringType>;
171
+ }>>;
172
+ readonly draftEnd: OptionType<import("@elaraai/east").VariantType<{
173
+ readonly draft: StructType<{
174
+ readonly record: StringType;
175
+ readonly mutation: StringType;
176
+ readonly place: IntegerType;
177
+ readonly of: IntegerType;
178
+ readonly how: import("@elaraai/east").VariantType<{
179
+ readonly failed: import("@elaraai/east").NullType;
180
+ readonly timed_out: import("@elaraai/east").NullType;
181
+ }>;
182
+ }>;
183
+ readonly laid: StructType<{
184
+ readonly of: IntegerType;
185
+ }>;
186
+ }>>;
125
187
  readonly limits: StructType<{
126
188
  readonly timeoutMs: IntegerType;
127
189
  readonly maxResultBytes: IntegerType;
@@ -137,28 +199,28 @@ export declare const FunctionCallJobType: StructType<{
137
199
  readonly functionObject: StringType;
138
200
  readonly runner: import("@elaraai/east").VariantType<{
139
201
  readonly east_node: StructType<{
140
- readonly platforms: import("@elaraai/east").ArrayType<StringType>;
202
+ readonly platforms: ArrayType<StringType>;
141
203
  readonly decode: import("@elaraai/east").VariantType<{
142
204
  readonly lazy: import("@elaraai/east").NullType;
143
205
  readonly whole: import("@elaraai/east").NullType;
144
206
  }>;
145
207
  }>;
146
208
  readonly east_py: StructType<{
147
- readonly platforms: import("@elaraai/east").ArrayType<StringType>;
209
+ readonly platforms: ArrayType<StringType>;
148
210
  readonly decode: import("@elaraai/east").VariantType<{
149
211
  readonly lazy: import("@elaraai/east").NullType;
150
212
  readonly whole: import("@elaraai/east").NullType;
151
213
  }>;
152
214
  }>;
153
215
  readonly east_c: StructType<{
154
- readonly platforms: import("@elaraai/east").ArrayType<StringType>;
216
+ readonly platforms: ArrayType<StringType>;
155
217
  readonly decode: import("@elaraai/east").VariantType<{
156
218
  readonly lazy: import("@elaraai/east").NullType;
157
219
  readonly whole: import("@elaraai/east").NullType;
158
220
  }>;
159
221
  }>;
160
222
  readonly custom: StructType<{
161
- readonly command: import("@elaraai/east").ArrayType<StringType>;
223
+ readonly command: ArrayType<StringType>;
162
224
  }>;
163
225
  }>;
164
226
  readonly verbose: BooleanType;
@@ -171,6 +233,15 @@ export declare const FunctionCallJobType: StructType<{
171
233
  readonly succeeded: IntegerType;
172
234
  readonly failed: IntegerType;
173
235
  }>;
236
+ readonly drafted: ArrayType<StructType<{
237
+ readonly record: StringType;
238
+ readonly path: ArrayType<import("@elaraai/east").VariantType<{
239
+ readonly field: StringType;
240
+ }>>;
241
+ readonly base: StringType;
242
+ readonly commit: StringType;
243
+ readonly mutations: DictType<StringType, StringType>;
244
+ }>>;
174
245
  }>;
175
246
  export type FunctionCallJobType = typeof FunctionCallJobType;
176
247
  /** A kept call, as its store keeps it. */
@@ -198,9 +269,16 @@ export declare function decodeFunctionCallJob(bytes: Uint8Array): FunctionCallJo
198
269
  * its own, which no package names, so the call alone keeps it, and its
199
270
  * program, for as long as it runs and is kept.
200
271
  *
272
+ * A call that drafts a record names more: each draft's arguments; the state
273
+ * each drafted record held as the call started and the mutations its drafts
274
+ * run, which its run lays the drafts from; and, among its inputs once the
275
+ * drafts are laid, the drafted state, which nothing else names. So the drafted
276
+ * state lives as long as the call is kept, and is collected after it.
277
+ *
201
278
  * @param job - The call
202
279
  * @returns The hashes it names: its function object's, then its arguments' in
203
- * order, then its inputs', then its value's
280
+ * order, then its inputs', then its drafts' arguments', then each drafted
281
+ * record's state and mutations, then its value's
204
282
  */
205
283
  export declare function functionCallRoots(job: FunctionCallJob): string[];
206
284
  //# sourceMappingURL=function-call.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"function-call.d.ts","sourceRoot":"","sources":["../../src/function-call.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAoC,KAAK,WAAW,EAC/H,MAAM,eAAe,CAAC;AAIvB;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB;;;EAGjC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,sBAAsB,CAAC;AAEnE,0CAA0C;AAC1C,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB;;;EAG/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC;AAE/D,4CAA4C;AAC5C,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC;AAE7D,0CAA0C;AAC1C,MAAM,M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AmBG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC;AAE7D,0CAA0C;AAC1C,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAKtE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,eAAe,GAAG,UAAU,CAEtE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,CAExE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,EAAE,CAUhE"}
@@ -13,14 +13,15 @@
13
13
  * shown, the call as the API answers it ({@link FunctionCallType}). Beside it,
14
14
  * it keeps what the call's run needs and no reader is shown: the function
15
15
  * object it runs, the runner it runs on, whether it runs verbose, its
16
- * deadline, and a request to cancel it.
16
+ * deadline, a request to cancel it, and what its run lays its drafts from.
17
17
  *
18
18
  * It is stored state (`WIRE_MIGRATION.md`): a change to its type ships a
19
19
  * repository upgrade step.
20
20
  */
21
- import { BooleanType, DateTimeType, IntegerType, OptionType, StringType, StructType, decodeBeast2For, encodeBeast2For, } from '@elaraai/east';
21
+ import { ArrayType, BooleanType, DateTimeType, DictType, IntegerType, OptionType, StringType, StructType, decodeBeast2For, encodeBeast2For, } from '@elaraai/east';
22
22
  import { FunctionCallType } from './api.js';
23
23
  import { RunnerType } from './runner.js';
24
+ import { TreePathType } from './structure.js';
24
25
  /**
25
26
  * A request to cancel a running call: who asked, and when.
26
27
  *
@@ -39,12 +40,38 @@ export const FunctionCallCancelType = StructType({
39
40
  *
40
41
  * @property succeeded - A call that succeeded, or was cancelled
41
42
  * @property failed - A call that failed, was refused (`invalid`), returned too
42
- * large a value, timed out, or was lost
43
+ * large a value, timed out, met a `conflict` laying a draft, or was lost
43
44
  */
44
45
  export const FunctionCallKeepType = StructType({
45
46
  succeeded: IntegerType,
46
47
  failed: IntegerType,
47
48
  });
49
+ /**
50
+ * A record a kept call drafts, as its run lays the drafts: everything the
51
+ * laying reads, named as the call started, so the run reads the workspace no
52
+ * more and lays the same state however often it is run; and the commit the
53
+ * record stood at, which the call's result names.
54
+ *
55
+ * @property record - The record's name, as the call's drafts name it
56
+ * @property path - Where the workspace holds the record: the call's inputs at
57
+ * this path are read at the drafted state, and a dataset argument naming it
58
+ * as saved, at `base`
59
+ * @property base - The state the record held as the call started, which the
60
+ * call's drafts of it are laid over, in order
61
+ * @property commit - The commit the record stood at as the call started,
62
+ * read with `base`: a caller that holds another knows its edits were laid
63
+ * over newer saves
64
+ * @property mutations - The object of each mutation the call's drafts of the
65
+ * record name, by the mutation's name: the one the deployed package named
66
+ * when the call started, whatever is deployed since
67
+ */
68
+ export const FunctionCallDraftedType = StructType({
69
+ record: StringType,
70
+ path: TreePathType,
71
+ base: StringType,
72
+ commit: StringType,
73
+ mutations: DictType(StringType, StringType),
74
+ });
48
75
  /**
49
76
  * A kept call, as its store keeps it.
50
77
  *
@@ -61,6 +88,9 @@ export const FunctionCallKeepType = StructType({
61
88
  * once its deadline and a grace have passed is lost
62
89
  * @property cancel - A request to cancel it, once one is made
63
90
  * @property keep - How long it is kept once it ends, by how it ended
91
+ * @property drafted - The records it drafts, each once, in the order its
92
+ * drafts first name them, with what its run lays them from and the commit
93
+ * each stood at; none for a call that passed no draft
64
94
  */
65
95
  export const FunctionCallJobType = StructType({
66
96
  call: FunctionCallType,
@@ -71,6 +101,7 @@ export const FunctionCallJobType = StructType({
71
101
  deadline: DateTimeType,
72
102
  cancel: OptionType(FunctionCallCancelType),
73
103
  keep: FunctionCallKeepType,
104
+ drafted: ArrayType(FunctionCallDraftedType),
74
105
  });
75
106
  const encodeJob = encodeBeast2For(FunctionCallJobType);
76
107
  const decodeJob = decodeBeast2For(FunctionCallJobType);
@@ -101,15 +132,28 @@ export function decodeFunctionCallJob(bytes) {
101
132
  * its own, which no package names, so the call alone keeps it, and its
102
133
  * program, for as long as it runs and is kept.
103
134
  *
135
+ * A call that drafts a record names more: each draft's arguments; the state
136
+ * each drafted record held as the call started and the mutations its drafts
137
+ * run, which its run lays the drafts from; and, among its inputs once the
138
+ * drafts are laid, the drafted state, which nothing else names. So the drafted
139
+ * state lives as long as the call is kept, and is collected after it.
140
+ *
104
141
  * @param job - The call
105
142
  * @returns The hashes it names: its function object's, then its arguments' in
106
- * order, then its inputs', then its value's
143
+ * order, then its inputs', then its drafts' arguments', then each drafted
144
+ * record's state and mutations, then its value's
107
145
  */
108
146
  export function functionCallRoots(job) {
109
147
  const { call } = job;
110
148
  const roots = [job.functionObject, ...call.args.map((arg) => (arg.type === 'value' ? arg.value : arg.value.hash))];
111
149
  for (const input of call.inputs)
112
150
  roots.push(input.hash);
151
+ for (const draft of call.drafts) {
152
+ if (draft.args.type === 'some')
153
+ roots.push(draft.args.value);
154
+ }
155
+ for (const record of job.drafted)
156
+ roots.push(record.base, ...record.mutations.values());
113
157
  if (call.state.type === 'succeeded')
114
158
  roots.push(call.state.value.value);
115
159
  return roots;
@@ -1 +1 @@
1
- {"version":3,"file":"function-call.js","sourceRoot":"","sources":["../../src/function-call.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,GAC7G,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;GAMG;AACH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