@substrat-run/kernel 0.229.0 → 0.230.0

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 (43) hide show
  1. package/dist/app-environments.d.ts +46 -3
  2. package/dist/app-environments.d.ts.map +1 -1
  3. package/dist/app-environments.js +70 -13
  4. package/dist/app-environments.js.map +1 -1
  5. package/dist/broker-delivery-events.d.ts +89 -0
  6. package/dist/broker-delivery-events.d.ts.map +1 -0
  7. package/dist/broker-delivery-events.js +114 -0
  8. package/dist/broker-delivery-events.js.map +1 -0
  9. package/dist/broker-schema.d.ts.map +1 -1
  10. package/dist/broker-schema.js +29 -0
  11. package/dist/broker-schema.js.map +1 -1
  12. package/dist/container-pass-sdk.d.ts +92 -0
  13. package/dist/container-pass-sdk.d.ts.map +1 -0
  14. package/dist/container-pass-sdk.js +210 -0
  15. package/dist/container-pass-sdk.js.map +1 -0
  16. package/dist/container-pass.d.ts +189 -0
  17. package/dist/container-pass.d.ts.map +1 -0
  18. package/dist/container-pass.js +384 -0
  19. package/dist/container-pass.js.map +1 -0
  20. package/dist/delivery-broker.d.ts +20 -1
  21. package/dist/delivery-broker.d.ts.map +1 -1
  22. package/dist/delivery-broker.js +52 -2
  23. package/dist/delivery-broker.js.map +1 -1
  24. package/dist/index.d.ts +7 -2
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +4 -2
  27. package/dist/index.js.map +1 -1
  28. package/dist/job-run.d.ts +111 -3
  29. package/dist/job-run.d.ts.map +1 -1
  30. package/dist/job-run.js +197 -58
  31. package/dist/job-run.js.map +1 -1
  32. package/dist/job-start.d.ts +14 -0
  33. package/dist/job-start.d.ts.map +1 -1
  34. package/dist/job-start.js +26 -0
  35. package/dist/job-start.js.map +1 -1
  36. package/dist/scope-host.d.ts +13 -7
  37. package/dist/scope-host.d.ts.map +1 -1
  38. package/dist/scope-host.js.map +1 -1
  39. package/dist/scope-store.d.ts +2 -3
  40. package/dist/scope-store.d.ts.map +1 -1
  41. package/dist/scope-store.js +4 -6
  42. package/dist/scope-store.js.map +1 -1
  43. package/package.json +6 -2
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The code a container pass is written with (D-85, #3752): `@substrat-run/kernel/container-pass`.
3
+ *
4
+ * A job its package places in a container (`substrat.jobs.<name>.placement: 'container'`) has an entry
5
+ * module whose default export is `containerPass(handler)`. The platform runs it in the job's runtime
6
+ * (`node24`, `node24-ffmpeg`), and the handler gets the same pass an in-process job handler gets, over
7
+ * the door the platform serves beside the container:
8
+ *
9
+ * ```ts
10
+ * import { containerPass } from '@substrat-run/kernel/container-pass';
11
+ *
12
+ * export default containerPass(async (pass) => {
13
+ * const source = await pass.files.open(pass.payload.fileId);
14
+ * const out = await pass.step('encode', () => encode(source)); // memoised: a retry skips it
15
+ * const record = await pass.files.put({ entity: pass.payload.episode, filename: 'episode.mp3', contentType: 'audio/mpeg', body: out });
16
+ * return { done: true, result: { attachmentId: record.id } };
17
+ * });
18
+ * ```
19
+ *
20
+ * What a pass returns is committed as an in-process pass's result is: `{ cursor }` keeps the run going
21
+ * from there with another pass, `{ done: true }` ends it (its `result` is what `job.run-ended`
22
+ * carries). A throw fails the pass, and the run retries it by the job's policy. The lease is renewed
23
+ * while the handler runs; a pass that loses its run (`LeaseLostError`) stops at its next door call,
24
+ * and whatever it did since its last step is done again by the pass that took over. So a step's
25
+ * effect is either memoised by `pass.step` or safe to repeat.
26
+ *
27
+ * Imports nothing but the kernel's byte and fetch shapes, so a pass bundle stays small.
28
+ */
29
+ import { type ByteStream, type SizedByteStream } from './byte-stream.js';
30
+ import { type FetchLike } from './connector-transport.js';
31
+ import type { AttachmentRecord, EntityRef, Visibility } from '@substrat-run/contracts';
32
+ import type { ContainerPassEntry, ContainerPassStart } from './container-pass.js';
33
+ /** The pass lost its run: another drive took it over. Stop; do not write anything else. */
34
+ export declare class LeaseLostError extends Error {
35
+ constructor();
36
+ }
37
+ /** A step whose recorded attempts reached its policy: the pass fails without running it again. */
38
+ export declare class StepExhaustedError extends Error {
39
+ readonly step: string;
40
+ readonly attempts: number;
41
+ constructor(step: string, attempts: number, cause: string);
42
+ }
43
+ /** A file the pass opened: its record and its bytes, read once. */
44
+ export interface PassFile {
45
+ readonly record: AttachmentRecord;
46
+ readonly contentType: string;
47
+ readonly length: number;
48
+ readonly body: ByteStream;
49
+ /** The whole file, read into memory. For a small file; a large one is read from `body`. */
50
+ bytes(): Promise<Uint8Array>;
51
+ }
52
+ export interface PassFileInput {
53
+ readonly entity: EntityRef;
54
+ readonly filename: string;
55
+ readonly contentType: string;
56
+ /** Default `internal`. */
57
+ readonly visibility?: Visibility;
58
+ /** The bytes, whole or as a stream with the length it declares. */
59
+ readonly body: Uint8Array | SizedByteStream;
60
+ }
61
+ export interface ContainerPassContext<Payload = unknown, Cursor = unknown> {
62
+ readonly run: ContainerPassStart['run'];
63
+ readonly payload: Payload;
64
+ /** Where the last committed pass left the walk; null on a run's first pass. */
65
+ readonly cursor: Cursor | null;
66
+ /** The counters the run holds so far. `count` adds to them; the commit writes them. */
67
+ readonly counters: Readonly<Record<string, number>>;
68
+ /** Run `fn` once per run: a later pass that reaches the same step gets its stored result. */
69
+ step<T>(name: string, fn: () => Promise<T>, options?: {
70
+ maxAttempts?: number;
71
+ }): Promise<T>;
72
+ count(name: string, by?: number): void;
73
+ readonly files: {
74
+ open(attachmentId: string): Promise<PassFile>;
75
+ put(input: PassFileInput): Promise<AttachmentRecord>;
76
+ };
77
+ /** Renew the lease now. The SDK renews on its own; call it inside a long synchronous stretch's gaps. */
78
+ heartbeat(): Promise<void>;
79
+ /** The pass's `fetch`: the hosts its job declares (D-86), judged by the platform. */
80
+ readonly fetch: FetchLike;
81
+ }
82
+ export interface ContainerPassResult<Cursor = unknown> {
83
+ /** Where the next pass starts. Omitted with `done`. */
84
+ readonly cursor?: Cursor;
85
+ readonly done?: boolean;
86
+ /** A finished run's result, on `job.run-ended`. JSON, at most 1 MB. */
87
+ readonly result?: unknown;
88
+ }
89
+ export type ContainerPassHandler<Payload = unknown, Cursor = unknown> = (pass: ContainerPassContext<Payload, Cursor>) => Promise<ContainerPassResult<Cursor> | void>;
90
+ /** The entry a container pass's bundle exports by default. */
91
+ export declare function containerPass<Payload = unknown, Cursor = unknown>(handler: ContainerPassHandler<Payload, Cursor>): ContainerPassEntry;
92
+ //# sourceMappingURL=container-pass-sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container-pass-sdk.d.ts","sourceRoot":"","sources":["../src/container-pass-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAkC,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzG,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAKlF,2FAA2F;AAC3F,qBAAa,cAAe,SAAQ,KAAK;IACvC,cAGC;CACF;AAED,kGAAkG;AAClG,qBAAa,kBAAmB,SAAQ,KAAK;IAEzC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAF3B,YACW,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EACzB,KAAK,EAAE,MAAM,EAId;CACF;AAED,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,2FAA2F;IAC3F,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC,CA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,qFAAqF;IACrF,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAmB,CAAC,MAAM,GAAG,OAAO;IACnD,uDAAuD;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,MAAM,oBAAoB,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,CACtE,IAAI,EAAE,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,KACxC,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;AAEjD,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,kBAAkB,CAwHrI"}
@@ -0,0 +1,210 @@
1
+ /**
2
+ * The code a container pass is written with (D-85, #3752): `@substrat-run/kernel/container-pass`.
3
+ *
4
+ * A job its package places in a container (`substrat.jobs.<name>.placement: 'container'`) has an entry
5
+ * module whose default export is `containerPass(handler)`. The platform runs it in the job's runtime
6
+ * (`node24`, `node24-ffmpeg`), and the handler gets the same pass an in-process job handler gets, over
7
+ * the door the platform serves beside the container:
8
+ *
9
+ * ```ts
10
+ * import { containerPass } from '@substrat-run/kernel/container-pass';
11
+ *
12
+ * export default containerPass(async (pass) => {
13
+ * const source = await pass.files.open(pass.payload.fileId);
14
+ * const out = await pass.step('encode', () => encode(source)); // memoised: a retry skips it
15
+ * const record = await pass.files.put({ entity: pass.payload.episode, filename: 'episode.mp3', contentType: 'audio/mpeg', body: out });
16
+ * return { done: true, result: { attachmentId: record.id } };
17
+ * });
18
+ * ```
19
+ *
20
+ * What a pass returns is committed as an in-process pass's result is: `{ cursor }` keeps the run going
21
+ * from there with another pass, `{ done: true }` ends it (its `result` is what `job.run-ended`
22
+ * carries). A throw fails the pass, and the run retries it by the job's policy. The lease is renewed
23
+ * while the handler runs; a pass that loses its run (`LeaseLostError`) stops at its next door call,
24
+ * and whatever it did since its last step is done again by the pass that took over. So a step's
25
+ * effect is either memoised by `pass.step` or safe to repeat.
26
+ *
27
+ * Imports nothing but the kernel's byte and fetch shapes, so a pass bundle stays small.
28
+ */
29
+ import { bytesStream, isSizedByteStream } from './byte-stream.js';
30
+ import { globalFetch } from './connector-transport.js';
31
+ /** The pass lost its run: another drive took it over. Stop; do not write anything else. */
32
+ export class LeaseLostError extends Error {
33
+ constructor() {
34
+ super('this pass no longer holds its run');
35
+ this.name = 'LeaseLostError';
36
+ }
37
+ }
38
+ /** A step whose recorded attempts reached its policy: the pass fails without running it again. */
39
+ export class StepExhaustedError extends Error {
40
+ step;
41
+ attempts;
42
+ constructor(step, attempts, cause) {
43
+ super(`step '${step}' exhausted after ${attempts} attempt(s): ${cause}`);
44
+ this.step = step;
45
+ this.attempts = attempts;
46
+ this.name = 'StepExhaustedError';
47
+ }
48
+ }
49
+ /** The entry a container pass's bundle exports by default. */
50
+ export function containerPass(handler) {
51
+ return async (env) => {
52
+ const doorFetch = env.fetch ?? globalFetch;
53
+ const door = async (path, init) => {
54
+ const res = await doorFetch(`${env.door}${path}`, init);
55
+ if (res.status === 409)
56
+ throw new LeaseLostError();
57
+ if (!res.ok)
58
+ throw new Error(`door ${path} answered ${res.status}: ${await res.text()}`);
59
+ return res;
60
+ };
61
+ const post = (path, body) => door(path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
62
+ const start = (await (await door('/pass')).json());
63
+ const counters = { ...start.counters };
64
+ let lost = false;
65
+ let failedStep;
66
+ const renew = async () => {
67
+ if (lost)
68
+ throw new LeaseLostError();
69
+ try {
70
+ await post('/renew', {});
71
+ }
72
+ catch (err) {
73
+ if (err instanceof LeaseLostError)
74
+ lost = true;
75
+ throw err;
76
+ }
77
+ };
78
+ const timer = setInterval(() => void renew().catch(() => undefined), Math.max(1_000, start.renewEveryMs));
79
+ const pass = {
80
+ run: start.run,
81
+ payload: start.payload,
82
+ cursor: (start.cursor ?? null),
83
+ counters,
84
+ async step(name, fn, options) {
85
+ if (lost)
86
+ throw new LeaseLostError();
87
+ const begun = (await (await post('/step/begin', { name, ...(options?.maxAttempts ? { maxAttempts: options.maxAttempts } : {}) })).json());
88
+ if ('memo' in begun)
89
+ return JSON.parse(begun.memo);
90
+ if ('exhausted' in begun) {
91
+ failedStep = { attempts: begun.attempts, ...(options?.maxAttempts ? { maxAttempts: options.maxAttempts } : {}) };
92
+ throw new StepExhaustedError(name, begun.attempts, begun.exhausted);
93
+ }
94
+ let value;
95
+ try {
96
+ value = await fn();
97
+ }
98
+ catch (err) {
99
+ if (!(err instanceof LeaseLostError)) {
100
+ await post('/step/record', { name, attempt: begun.attempt, error: errorText(err) });
101
+ failedStep = { attempts: begun.attempt, ...(options?.maxAttempts ? { maxAttempts: options.maxAttempts } : {}) };
102
+ }
103
+ throw err;
104
+ }
105
+ await post('/step/record', { name, attempt: begun.attempt, result: value === undefined ? null : value });
106
+ return value;
107
+ },
108
+ count(name, by = 1) {
109
+ if (!Number.isFinite(by))
110
+ throw new Error('a count is a finite number');
111
+ counters[name] = (counters[name] ?? 0) + by;
112
+ },
113
+ files: {
114
+ async open(attachmentId) {
115
+ const res = await door(`/files/${encodeURIComponent(attachmentId)}`);
116
+ const record = JSON.parse(res.headers?.get('x-substrat-attachment') ?? 'null');
117
+ const length = Number(res.headers?.get('content-length') ?? record.size);
118
+ const body = res.body ?? bytesStream(new Uint8Array(await res.arrayBuffer())).stream;
119
+ let read = false;
120
+ return {
121
+ record,
122
+ contentType: res.headers?.get('content-type') ?? record.contentType,
123
+ length,
124
+ body,
125
+ async bytes() {
126
+ if (read)
127
+ throw new Error('a file is read once');
128
+ read = true;
129
+ return readAll(body, length);
130
+ },
131
+ };
132
+ },
133
+ async put(input) {
134
+ const sized = isSizedByteStream(input.body) ? input.body : bytesStream(input.body);
135
+ const res = await door('/files', {
136
+ method: 'POST',
137
+ headers: {
138
+ 'content-type': input.contentType,
139
+ 'content-length': String(sized.length),
140
+ 'x-substrat-attachment': JSON.stringify({
141
+ entity: input.entity,
142
+ filename: input.filename,
143
+ contentType: input.contentType,
144
+ visibility: input.visibility ?? 'internal',
145
+ }),
146
+ },
147
+ body: sized,
148
+ });
149
+ return (await res.json());
150
+ },
151
+ },
152
+ heartbeat: renew,
153
+ fetch: env.fetch ?? globalFetch,
154
+ };
155
+ try {
156
+ const result = (await handler(pass)) ?? {};
157
+ if (lost)
158
+ return;
159
+ await post('/commit', {
160
+ done: result.done === true,
161
+ ...('cursor' in result ? { cursor: result.cursor } : {}),
162
+ ...('result' in result ? { result: result.result } : {}),
163
+ counters,
164
+ });
165
+ }
166
+ catch (err) {
167
+ if (err instanceof LeaseLostError || lost)
168
+ return;
169
+ await post('/fail', { error: errorText(err), ...(failedStep ? { step: failedStep } : {}) }).catch((e) => {
170
+ if (!(e instanceof LeaseLostError))
171
+ throw e;
172
+ });
173
+ }
174
+ finally {
175
+ clearInterval(timer);
176
+ }
177
+ };
178
+ }
179
+ function errorText(err) {
180
+ return err instanceof Error ? `${err.name}: ${err.message}` : String(err);
181
+ }
182
+ async function readAll(body, length) {
183
+ const chunks = [];
184
+ let total = 0;
185
+ const reader = body.getReader();
186
+ try {
187
+ for (;;) {
188
+ const { done, value } = await reader.read();
189
+ if (done)
190
+ break;
191
+ if (!value)
192
+ continue;
193
+ chunks.push(value);
194
+ total += value.byteLength;
195
+ }
196
+ }
197
+ finally {
198
+ reader.releaseLock();
199
+ }
200
+ if (Number.isFinite(length) && total !== length)
201
+ throw new Error(`a file carried ${total} of its declared ${length} bytes`);
202
+ const out = new Uint8Array(total);
203
+ let at = 0;
204
+ for (const c of chunks) {
205
+ out.set(c, at);
206
+ at += c.byteLength;
207
+ }
208
+ return out;
209
+ }
210
+ //# sourceMappingURL=container-pass-sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container-pass-sdk.js","sourceRoot":"","sources":["../src/container-pass-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAyC,MAAM,kBAAkB,CAAC;AACzG,OAAO,EAAE,WAAW,EAA0C,MAAM,0BAA0B,CAAC;AAO/F,2FAA2F;AAC3F,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC;QACE,KAAK,CAAC,mCAAmC,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED,kGAAkG;AAClG,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEhC,IAAI;IACJ,QAAQ;IAFnB,YACW,IAAY,EACZ,QAAgB,EACzB,KAAa;QAEb,KAAK,CAAC,SAAS,IAAI,qBAAqB,QAAQ,gBAAgB,KAAK,EAAE,CAAC,CAAC;oBAJhE,IAAI;wBACJ,QAAQ;QAIjB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAsDD,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAsC,OAA8C;IAC/G,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE;QACnB,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,IAAI,WAAW,CAAC;QAC3C,MAAM,IAAI,GAAG,KAAK,EAAE,IAAY,EAAE,IAA+B,EAA8B,EAAE;YAC/F,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;YACxD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;gBAAE,MAAM,IAAI,cAAc,EAAE,CAAC;YACnD,IAAI,CAAC,GAAG,CAAC,EAAE;gBAAE,MAAM,IAAI,KAA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,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC5E,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,IAAgB,EAAE,MAAc;IACrD,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,IAAI,CAAC;QACH,SAAS,CAAC;YACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI;gBAAE,MAAM;YAChB,IAAI,CAAC,KAAK;gBAAE,SAAS;YACrB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC;QAC5B,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,oBAAoB,MAAM,QAAQ,CAAC,CAAC;IAC5H,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACf,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * A declared job's pass, run in a container the platform supplies (D-85, #3752).
3
+ *
4
+ * A job run (#1577) is driven where it always was: the scope's own drive claims a due run, begins its
5
+ * pass under a lease, and invokes the job's handler. For a job its package places in a container, that
6
+ * handler is `containerPassRegistration`'s: it DETACHES the pass (`pass.detach()`), asks the host's
7
+ * launcher to start a container for it, and returns. The drive is done with it; the lease is not. The
8
+ * container's code then reaches its run through one door, `serveContainerPassDoor`, which the platform
9
+ * serves on a hostname only the container can reach (`run.substrat.internal` on the hosted platform),
10
+ * and every write there is the kernel's detached-pass function, conditional on the lease:
11
+ *
12
+ * - `GET /pass` — the run, its payload, the cursor and counters the last commit left, and how often to
13
+ * renew;
14
+ * - `POST /renew` — the lease, renewed; a pass that stops renewing loses its run to the next drive,
15
+ * which takes it over and charges the attempt (#2034), so a container that dies is a failed attempt
16
+ * on the run's record, never a run that waits forever;
17
+ * - `POST /step/begin`, `POST /step/record` — a step's memo, as `pass.step` keeps it in-process;
18
+ * - `POST /commit`, `POST /fail` — the pass's end, written as an in-process pass's is;
19
+ * - `GET /files/:id`, `POST /files` — the run's module's files, as `system:<module>` (the target's
20
+ * read key to open, its write key to put).
21
+ *
22
+ * The container holds no token, no credential and no scope stub. The lease owner never leaves the
23
+ * host: the door adds it. That is the whole of a pass's authority: its run, its module's files, and
24
+ * the egress its job declares (D-86), which the platform judges outside the container.
25
+ *
26
+ * Where the pass's code comes from is the host's: on the hosted platform the release carries each
27
+ * job's bundle and the door serves it (`GET /bundle`); locally the bundle is imported in-process
28
+ * (`localContainerPasses`).
29
+ */
30
+ import { type AttachmentRecord, type ModuleId, type ScopeId, type TenantId } from '@substrat-run/contracts';
31
+ import type { OpenedAttachmentStream } from './attachment-bytes.js';
32
+ import { type ByteStream, type SizedByteStream } from './byte-stream.js';
33
+ import type { FetchLike } from './connector-transport.js';
34
+ import { type DetachedPassTicket, type JobPassOutcome, type JobRegistration, type JobRunStore } from './job-run.js';
35
+ import type { AttachmentUploadInput } from './scope-host.js';
36
+ export { CONTAINER_INSTANCES, CONTAINER_PASS_DEADLINE_DEFAULT_MS, CONTAINER_PASS_DEADLINE_MAX_MS, CONTAINER_RUNTIMES, containerPlacementOf, type ContainerPlacement, type ContainerRuntime, } from '@substrat-run/contracts';
37
+ import type { ContainerPlacement } from '@substrat-run/contracts';
38
+ /**
39
+ * A container pass's lease. Short, so a container that dies is taken over within minutes rather than
40
+ * the in-process default's quarter hour; the pass renews it every third (`renewEveryMs`).
41
+ */
42
+ export declare const CONTAINER_PASS_LEASE_MS: number;
43
+ /** What a launcher is handed to start one pass. */
44
+ export interface ContainerPassLaunch {
45
+ readonly tenantId: TenantId;
46
+ readonly scopeId: ScopeId;
47
+ readonly placement: ContainerPlacement;
48
+ /** The lease and the run as the claim left it. The launcher keeps it on the host side of the door. */
49
+ readonly ticket: DetachedPassTicket;
50
+ /**
51
+ * The door's dependencies, when the host can hand them over in-process (the pure host, a test).
52
+ * The hosted launcher builds its own beside the container, from the scope it names.
53
+ */
54
+ readonly door?: () => Promise<ContainerPassDoorDeps>;
55
+ }
56
+ /**
57
+ * What starts container passes for a host: which declared jobs it places, and how it starts one. On
58
+ * the hosted platform the platform entry publishes one (`registerContainerPasses`); a pure host takes
59
+ * one as an option (`localContainerPasses`).
60
+ */
61
+ export interface ContainerPassLauncher {
62
+ /** The job's placement, or undefined when this launcher does not place it. */
63
+ placementOf(moduleId: ModuleId, job: string): ContainerPlacement | undefined;
64
+ /**
65
+ * Start the pass and return once it is started: the container runs on after this returns. A throw
66
+ * fails the pass, as a throwing handler does; the lease is released by that failure.
67
+ */
68
+ launch(launch: ContainerPassLaunch): Promise<void>;
69
+ }
70
+ /** The global key the platform entry publishes its launcher under, as `SCOPE_DUE_HOST_KEY` is published. */
71
+ export declare const CONTAINER_PASSES_KEY = "substrat.container-passes";
72
+ /** Publish this script's launcher. The platform entry calls it; nothing else should. */
73
+ export declare function registerContainerPasses(launcher: ContainerPassLauncher): void;
74
+ /** The launcher this script's platform entry published, if any. */
75
+ export declare function registeredContainerPasses(): ContainerPassLauncher | undefined;
76
+ /**
77
+ * The registration a host drives a container-placed job with, or undefined when the launcher does not
78
+ * place it. Its handler detaches the pass and launches it; the pass's end is written by the container
79
+ * through the door. The lease is `CONTAINER_PASS_LEASE_MS`.
80
+ */
81
+ export declare function containerPassRegistration(launcher: ContainerPassLauncher | undefined, run: {
82
+ readonly module_id: string;
83
+ readonly job: string;
84
+ }, context: {
85
+ tenantId: TenantId;
86
+ scopeId: ScopeId;
87
+ door?: (ticket: DetachedPassTicket) => Promise<ContainerPassDoorDeps>;
88
+ }): JobRegistration | undefined;
89
+ /** The run's module's files, as a container pass reaches them: `system:<module>`'s read and write. */
90
+ export interface ContainerPassFiles {
91
+ openStream(attachmentId: string): Promise<OpenedAttachmentStream | null>;
92
+ upload(input: AttachmentUploadInput): Promise<AttachmentRecord>;
93
+ }
94
+ export interface ContainerPassDoorDeps {
95
+ readonly store: JobRunStore;
96
+ readonly ticket: DetachedPassTicket;
97
+ readonly now: () => string;
98
+ /** The pass's bundle, when the door serves it (the hosted runtime boots from `GET /bundle`). */
99
+ readonly bundle?: () => Promise<string>;
100
+ readonly files?: () => Promise<ContainerPassFiles>;
101
+ /** Told once the pass has ended through the door, with how; the container is then stopped. */
102
+ readonly ended?: (outcome: JobPassOutcome) => void | Promise<void>;
103
+ }
104
+ /** What `GET /pass` answers. */
105
+ export interface ContainerPassStart {
106
+ readonly run: {
107
+ readonly id: string;
108
+ readonly module: string;
109
+ readonly job: string;
110
+ readonly instance: string;
111
+ };
112
+ readonly payload: unknown;
113
+ readonly cursor: unknown;
114
+ readonly counters: Readonly<Record<string, number>>;
115
+ readonly definitionVersion: number | null;
116
+ /** Renew at least this often, or the lease lapses and the run is taken over. */
117
+ readonly renewEveryMs: number;
118
+ }
119
+ /**
120
+ * One request to the door, structurally: a web `Request` is made one by `passDoorRequestOf`, and the
121
+ * in-process runner builds one directly. The kernel carries no platform typings (as `FetchLike`).
122
+ */
123
+ export interface PassDoorRequest {
124
+ readonly method: string;
125
+ /** The URL's path, without its query. */
126
+ readonly path: string;
127
+ header(name: string): string | null;
128
+ text(): Promise<string>;
129
+ readonly body: ByteStream | null;
130
+ }
131
+ /** The door's answer, structurally; a host makes it a web `Response` (`body` a string, a sized stream or none). */
132
+ export interface PassDoorReply {
133
+ readonly status: number;
134
+ readonly headers: Readonly<Record<string, string>>;
135
+ readonly body: string | SizedByteStream | null;
136
+ }
137
+ /** A web `Request` (Node, workerd), as the door reads it. */
138
+ export declare function passDoorRequestOf(request: {
139
+ readonly method: string;
140
+ readonly url: string;
141
+ readonly headers: {
142
+ get(name: string): string | null;
143
+ };
144
+ text(): Promise<string>;
145
+ readonly body: unknown;
146
+ }): PassDoorRequest;
147
+ /** The hostname the door answers on, inside the container. Nothing else there is reachable unless declared (D-86). */
148
+ export declare const CONTAINER_PASS_DOOR_HOST = "run.substrat.internal";
149
+ /** The largest JSON body the door reads (a commit's cursor, a step's result). Files go by their own route. */
150
+ export declare const CONTAINER_PASS_DOOR_JSON_MAX = 1000000;
151
+ /** The largest file a pass may put, in bytes. */
152
+ export declare const CONTAINER_PASS_FILE_MAX: number;
153
+ /** The header a file's record travels in: on `GET /files/:id` the record, on `POST /files` the target and name. */
154
+ export declare const CONTAINER_PASS_FILE_HEADER = "x-substrat-attachment";
155
+ /**
156
+ * Serve one request from a container pass. Every route but `/pass` and `/bundle` writes under the
157
+ * ticket's lease; `409 lease_lost` tells the pass to stop. A malformed request is a 400 the pass reads,
158
+ * never a write.
159
+ */
160
+ export declare function serveContainerPassDoor(request: PassDoorRequest, deps: ContainerPassDoorDeps): Promise<PassDoorReply>;
161
+ /** What a pass's bundle exports by default (`containerPass` in `@substrat-run/kernel/container-pass`). */
162
+ export type ContainerPassEntry = (env: ContainerPassEnv) => Promise<void>;
163
+ /** What a pass's entry is handed: the door's origin, and the `fetch` that reaches it. */
164
+ export interface ContainerPassEnv {
165
+ readonly door: string;
166
+ readonly fetch: FetchLike;
167
+ }
168
+ /** A launcher that runs each pass in this process, against a door served in-process. */
169
+ export interface LocalContainerPasses extends ContainerPassLauncher {
170
+ /** Resolves when every pass started so far has ended. For a test, or a dev server shutting down. */
171
+ settled(): Promise<void>;
172
+ }
173
+ /**
174
+ * Run container passes in this process: each job's entry is called with a `fetch` that reaches the
175
+ * door in-process. For the pure host, `substrat dev` and the contract suites: the same door and the
176
+ * same detached-pass rules as the hosted container, without the container.
177
+ *
178
+ * `fetch` is what the pass's `fetch` falls back to for every host but the door; left out, a pass
179
+ * reaches nothing but its door. An entry that throws fails its pass, as a container that exits
180
+ * without ending its pass is failed by its deadline on the hosted platform.
181
+ */
182
+ export declare function localContainerPasses(options: {
183
+ readonly jobs: Readonly<Record<string, {
184
+ readonly placement: ContainerPlacement;
185
+ readonly entry: ContainerPassEntry;
186
+ }>>;
187
+ readonly fetch?: FetchLike;
188
+ }): LocalContainerPasses;
189
+ //# sourceMappingURL=container-pass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container-pass.d.ts","sourceRoot":"","sources":["../src/container-pass.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAA8C,KAAK,gBAAgB,EAAE,KAAK,QAAQ,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxJ,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAkC,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzG,OAAO,KAAK,EAAgE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACxH,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAK7D,OAAO,EACL,mBAAmB,EACnB,kCAAkC,EAClC,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,y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