@telorun/sdk 0.62.0 → 0.63.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.
package/dist/index.d.ts CHANGED
@@ -22,6 +22,8 @@ export * from "./contract-errors.js";
22
22
  export * from "./invoke-error.js";
23
23
  export * from "./log-record.js";
24
24
  export * from "./log-sink.js";
25
+ export * from "./record-buffer.js";
26
+ export * from "./runtime-seam.js";
25
27
  export * from "./log-severity.js";
26
28
  export * from "./logger.js";
27
29
  export * from "./network-fetch.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -22,6 +22,8 @@ export * from "./contract-errors.js";
22
22
  export * from "./invoke-error.js";
23
23
  export * from "./log-record.js";
24
24
  export * from "./log-sink.js";
25
+ export * from "./record-buffer.js";
26
+ export * from "./runtime-seam.js";
25
27
  export * from "./log-severity.js";
26
28
  export * from "./logger.js";
27
29
  export * from "./network-fetch.js";
@@ -0,0 +1,29 @@
1
+ import type { LogRecord } from "./log-record.js";
2
+ import type { SinkBufferPolicy } from "./log-sink.js";
3
+ /**
4
+ * The bounded buffer every asynchronous sink composes — `kernel/specs/logging.md`
5
+ * §10.3.
6
+ *
7
+ * It lives beside the sink contract for the same reason that contract does: a
8
+ * third-party sink is an ordinary module, so the piece it composes to honour
9
+ * `on_full` must be on the module-author surface rather than behind a
10
+ * kernel-internal import.
11
+ *
12
+ * The ecosystems disagree by default: Rust's `tracing-appender` drops, zap
13
+ * buffers 256 kB / 30 s, and pino has no bound at all. Telo therefore makes the
14
+ * policy explicit and required, and the buffer is never unbounded.
15
+ *
16
+ * `drop_old` has no precedent among the surveyed libraries, so it is implemented
17
+ * as specified — true ring-buffer semantics, evicting the oldest record — rather
18
+ * than by analogy to something else.
19
+ */
20
+ export declare class RecordBuffer {
21
+ #private;
22
+ constructor(policy: SinkBufferPolicy, onDrop: () => void);
23
+ get size(): number;
24
+ get isFull(): boolean;
25
+ push(record: LogRecord): void;
26
+ /** Take everything buffered, leaving the buffer empty. */
27
+ drain(): LogRecord[];
28
+ }
29
+ //# sourceMappingURL=record-buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-buffer.d.ts","sourceRoot":"","sources":["../src/record-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,YAAY;;gBASX,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,IAAI;IAMxD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAiB7B,0DAA0D;IAC1D,KAAK,IAAI,SAAS,EAAE;CAerB"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The bounded buffer every asynchronous sink composes — `kernel/specs/logging.md`
3
+ * §10.3.
4
+ *
5
+ * It lives beside the sink contract for the same reason that contract does: a
6
+ * third-party sink is an ordinary module, so the piece it composes to honour
7
+ * `on_full` must be on the module-author surface rather than behind a
8
+ * kernel-internal import.
9
+ *
10
+ * The ecosystems disagree by default: Rust's `tracing-appender` drops, zap
11
+ * buffers 256 kB / 30 s, and pino has no bound at all. Telo therefore makes the
12
+ * policy explicit and required, and the buffer is never unbounded.
13
+ *
14
+ * `drop_old` has no precedent among the surveyed libraries, so it is implemented
15
+ * as specified — true ring-buffer semantics, evicting the oldest record — rather
16
+ * than by analogy to something else.
17
+ */
18
+ export class RecordBuffer {
19
+ #capacity;
20
+ #policy;
21
+ #onDrop;
22
+ #items = [];
23
+ /** Index of the oldest record, so `drop_old` evicts in O(1) instead of
24
+ * shifting the whole array on every overflow. */
25
+ #head = 0;
26
+ constructor(policy, onDrop) {
27
+ this.#capacity = Math.max(1, policy.buffer);
28
+ this.#policy = policy;
29
+ this.#onDrop = onDrop;
30
+ }
31
+ get size() {
32
+ return this.#items.length - this.#head;
33
+ }
34
+ get isFull() {
35
+ return this.size >= this.#capacity;
36
+ }
37
+ push(record) {
38
+ if (this.isFull) {
39
+ if (this.#policy.onFull === "drop_old") {
40
+ this.#head += 1;
41
+ this.#compact();
42
+ }
43
+ else {
44
+ // `drop_new` — and `block`, which never reaches here because a runtime
45
+ // that cannot honour it rejects the manifest at load rather than
46
+ // silently degrading to a dropping policy.
47
+ this.#onDrop();
48
+ return;
49
+ }
50
+ this.#onDrop();
51
+ }
52
+ this.#items.push(record);
53
+ }
54
+ /** Take everything buffered, leaving the buffer empty. */
55
+ drain() {
56
+ const drained = this.#head === 0 ? this.#items : this.#items.slice(this.#head);
57
+ this.#items = [];
58
+ this.#head = 0;
59
+ return drained;
60
+ }
61
+ #compact() {
62
+ // Reclaim the consumed prefix once it dominates the array, so a long-lived
63
+ // ring does not grow its backing store without bound.
64
+ if (this.#head > 32 && this.#head * 2 >= this.#items.length) {
65
+ this.#items = this.#items.slice(this.#head);
66
+ this.#head = 0;
67
+ }
68
+ }
69
+ }
@@ -9,6 +9,7 @@ import type { KindRef } from "./ref.js";
9
9
  import { ResourceInstance } from "./resource-instance.js";
10
10
  import { ResourceManifest } from "./resource-manifest.js";
11
11
  import { RuntimeResource } from "./runtime-resource.js";
12
+ import type { RuntimeSeam } from "./runtime-seam.js";
12
13
  export interface LoadOptions {
13
14
  /** When true, `${{ }}` templates are replaced with CompiledValue wrappers
14
15
  * so they can be evaluated at runtime. Leave unset for static analysis. */
@@ -210,6 +211,13 @@ export interface ResourceContext extends ControllerContext {
210
211
  * {@link log}.
211
212
  */
212
213
  readonly logging: LoggingHost;
214
+ /**
215
+ * The host's own manifest machinery — run a manifest, analyze a manifest.
216
+ * See {@link RuntimeSeam}. A controller that needs either reaches it here
217
+ * rather than importing the kernel or the analyzer, so a published module
218
+ * binds to a versioned contract instead of to whatever kernel loads it.
219
+ */
220
+ readonly runtime: RuntimeSeam;
213
221
  readonly moduleContext: ModuleContext;
214
222
  readonly env: Record<string, string | undefined>;
215
223
  readonly stdin: NodeJS.ReadableStream;
@@ -1 +1 @@
1
- {"version":3,"file":"resource-context.d.ts","sourceRoot":"","sources":["../src/resource-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5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,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;CACxC"}
@@ -0,0 +1,108 @@
1
+ import type { Stream } from "./stream.js";
2
+ /**
3
+ * The host's own manifest machinery, exposed to a controller as `ctx.runtime`:
4
+ * **run a manifest**, **analyze a manifest**.
5
+ *
6
+ * It lives on the module-author surface because the modules that need it are
7
+ * ordinary modules — `test` runs a child manifest, `assert`'s `Manifest` kind
8
+ * analyzes one — and reaching into a kernel-internal import to do that would make
9
+ * kernel internals an unversioned ABI between a published artifact and whatever
10
+ * kernel loads it. It is deliberately not test-shaped: a workflow engine running
11
+ * sub-manifests, a supervisor, a hub validating a published module and CI tooling
12
+ * all want one half or the other.
13
+ *
14
+ * Every shape crossing this boundary is plain serializable data or a
15
+ * {@link Stream}, so no kernel or analyzer class is part of the contract and a
16
+ * kernel in any language can implement it. **Isolation is the kernel's choice** —
17
+ * an in-process child kernel today, a subprocess later — which is what keeps
18
+ * process-global host state an implementation detail rather than something a
19
+ * caller has to reason about.
20
+ */
21
+ export interface RuntimeSeam {
22
+ /**
23
+ * Load and start `source` as a child manifest, isolated from the caller's.
24
+ *
25
+ * Resolves once the child has **started**, not once it has finished, so the
26
+ * caller can consume its output while it runs; completion is
27
+ * {@link RuntimeRun.exitCode}. A child that fails to load is not an exception
28
+ * here — it settles `exitCode` non-zero with the failure written to `stderr`,
29
+ * so a caller handles both failure modes in one place.
30
+ *
31
+ * **The caller owns the child's lifetime.** Drain both streams, or stop it with
32
+ * {@link RuntimeRun.cancel}; a child nobody reads and nobody stops keeps
33
+ * producing, and its output accumulates in the host's memory.
34
+ */
35
+ run(source: string, options?: RuntimeRunOptions): Promise<RuntimeRun>;
36
+ /**
37
+ * Run the static-analysis pass over `source` and its import graph without
38
+ * instantiating anything. Never throws for a manifest that fails to load —
39
+ * that is {@link RuntimeCheckResult.loadError}, which is an answer, not an
40
+ * error.
41
+ */
42
+ check(source: string, options?: RuntimeCheckOptions): Promise<RuntimeCheckResult>;
43
+ }
44
+ export interface RuntimeRunOptions {
45
+ /** Host environment the child binds its `variables:` / `secrets:` / `ports:`
46
+ * from. Omitted means the caller's own — a child never inherits more than it
47
+ * is handed. */
48
+ env?: Record<string, string | undefined>;
49
+ }
50
+ /**
51
+ * A started child manifest.
52
+ *
53
+ * Output is a stream rather than a captured string because the two useful
54
+ * behaviours — forward it live, keep it to print on failure — are the caller's
55
+ * to choose, and only one of them survives a value produced at the end. A caller
56
+ * that just wants the text drains the stream itself.
57
+ *
58
+ * A stream does **not** by itself bound the host's memory: an unread stream still
59
+ * accumulates whatever the child writes. What bounds it is {@link cancel} — stop
60
+ * the child, rather than hoping it stops producing.
61
+ */
62
+ export interface RuntimeRun {
63
+ readonly stdout: Stream<string>;
64
+ readonly stderr: Stream<string>;
65
+ /** Settles when the child has finished — including after {@link cancel}. Both
66
+ * streams have ended by then. */
67
+ readonly exitCode: Promise<number>;
68
+ /**
69
+ * Stop the child and tear it down.
70
+ *
71
+ * On the contract from the start rather than added later: termination is the
72
+ * first thing a supervisor or a workflow engine running an open-ended
73
+ * sub-manifest needs, and it is also the only bound on an unread child's
74
+ * output. Idempotent, and safe after the child has already finished.
75
+ *
76
+ * Resolves when teardown has completed, so a caller that must know the child
77
+ * released its resources — ports, connections, files — can await it.
78
+ */
79
+ cancel(reason?: string): Promise<void>;
80
+ }
81
+ export interface RuntimeCheckOptions {
82
+ /** Expand each module document's inline `imports:` map into synthetic
83
+ * `Telo.Import` manifests before analysis, so a manifest using inline imports
84
+ * analyzes the way it runs. */
85
+ desugarImports?: boolean;
86
+ }
87
+ /** Severity as a name rather than the LSP integer: the integer is a protocol
88
+ * detail of one editor transport, and this contract is read by a Rust or Go
89
+ * kernel too. */
90
+ export type CheckDiagnosticSeverity = "error" | "warning" | "info" | "hint";
91
+ /** One analyzer finding, flattened to data. Positions are zero-based, matching
92
+ * the analyzer's own range model. */
93
+ export interface CheckDiagnostic {
94
+ code: string;
95
+ message: string;
96
+ severity: CheckDiagnosticSeverity;
97
+ /** URL of the manifest the finding is in, when the analyzer located one. */
98
+ source?: string;
99
+ line?: number;
100
+ column?: number;
101
+ }
102
+ export interface RuntimeCheckResult {
103
+ diagnostics: CheckDiagnostic[];
104
+ /** Set when the import graph could not be loaded at all, in which case
105
+ * `diagnostics` is empty — there was nothing to analyze. */
106
+ loadError?: string;
107
+ }
108
+ //# sourceMappingURL=runtime-seam.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-seam.d.ts","sourceRoot":"","sources":["../src/runtime-seam.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACtE;;;;;OAKG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACnF;AAED,MAAM,WAAW,iBAAiB;IAChC;;qBAEiB;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC;sCACkC;IAClC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAClC;;oCAEgC;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;kBAEkB;AAClB,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5E;sCACsC;AACtC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B;iEAC6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/sdk",
3
- "version": "0.62.0",
3
+ "version": "0.63.0",
4
4
  "description": "Telo SDK - Public API for Telo module authors.",
5
5
  "keywords": [
6
6
  "telo",
package/src/index.ts CHANGED
@@ -22,6 +22,8 @@ export * from "./contract-errors.js";
22
22
  export * from "./invoke-error.js";
23
23
  export * from "./log-record.js";
24
24
  export * from "./log-sink.js";
25
+ export * from "./record-buffer.js";
26
+ export * from "./runtime-seam.js";
25
27
  export * from "./log-severity.js";
26
28
  export * from "./logger.js";
27
29
  export * from "./network-fetch.js";
@@ -0,0 +1,77 @@
1
+ import type { LogRecord } from "./log-record.js";
2
+ import type { SinkBufferPolicy } from "./log-sink.js";
3
+
4
+ /**
5
+ * The bounded buffer every asynchronous sink composes — `kernel/specs/logging.md`
6
+ * §10.3.
7
+ *
8
+ * It lives beside the sink contract for the same reason that contract does: a
9
+ * third-party sink is an ordinary module, so the piece it composes to honour
10
+ * `on_full` must be on the module-author surface rather than behind a
11
+ * kernel-internal import.
12
+ *
13
+ * The ecosystems disagree by default: Rust's `tracing-appender` drops, zap
14
+ * buffers 256 kB / 30 s, and pino has no bound at all. Telo therefore makes the
15
+ * policy explicit and required, and the buffer is never unbounded.
16
+ *
17
+ * `drop_old` has no precedent among the surveyed libraries, so it is implemented
18
+ * as specified — true ring-buffer semantics, evicting the oldest record — rather
19
+ * than by analogy to something else.
20
+ */
21
+ export class RecordBuffer {
22
+ readonly #capacity: number;
23
+ readonly #policy: SinkBufferPolicy;
24
+ readonly #onDrop: () => void;
25
+ #items: LogRecord[] = [];
26
+ /** Index of the oldest record, so `drop_old` evicts in O(1) instead of
27
+ * shifting the whole array on every overflow. */
28
+ #head = 0;
29
+
30
+ constructor(policy: SinkBufferPolicy, onDrop: () => void) {
31
+ this.#capacity = Math.max(1, policy.buffer);
32
+ this.#policy = policy;
33
+ this.#onDrop = onDrop;
34
+ }
35
+
36
+ get size(): number {
37
+ return this.#items.length - this.#head;
38
+ }
39
+
40
+ get isFull(): boolean {
41
+ return this.size >= this.#capacity;
42
+ }
43
+
44
+ push(record: LogRecord): void {
45
+ if (this.isFull) {
46
+ if (this.#policy.onFull === "drop_old") {
47
+ this.#head += 1;
48
+ this.#compact();
49
+ } else {
50
+ // `drop_new` — and `block`, which never reaches here because a runtime
51
+ // that cannot honour it rejects the manifest at load rather than
52
+ // silently degrading to a dropping policy.
53
+ this.#onDrop();
54
+ return;
55
+ }
56
+ this.#onDrop();
57
+ }
58
+ this.#items.push(record);
59
+ }
60
+
61
+ /** Take everything buffered, leaving the buffer empty. */
62
+ drain(): LogRecord[] {
63
+ const drained = this.#head === 0 ? this.#items : this.#items.slice(this.#head);
64
+ this.#items = [];
65
+ this.#head = 0;
66
+ return drained;
67
+ }
68
+
69
+ #compact(): void {
70
+ // Reclaim the consumed prefix once it dominates the array, so a long-lived
71
+ // ring does not grow its backing store without bound.
72
+ if (this.#head > 32 && this.#head * 2 >= this.#items.length) {
73
+ this.#items = this.#items.slice(this.#head);
74
+ this.#head = 0;
75
+ }
76
+ }
77
+ }
@@ -9,6 +9,7 @@ import type { KindRef } from "./ref.js";
9
9
  import { ResourceInstance } from "./resource-instance.js";
10
10
  import { ResourceManifest } from "./resource-manifest.js";
11
11
  import { RuntimeResource } from "./runtime-resource.js";
12
+ import type { RuntimeSeam } from "./runtime-seam.js";
12
13
 
13
14
  export interface LoadOptions {
14
15
  /** When true, `${{ }}` templates are replaced with CompiledValue wrappers
@@ -227,6 +228,13 @@ export interface ResourceContext extends ControllerContext {
227
228
  * {@link log}.
228
229
  */
229
230
  readonly logging: LoggingHost;
231
+ /**
232
+ * The host's own manifest machinery — run a manifest, analyze a manifest.
233
+ * See {@link RuntimeSeam}. A controller that needs either reaches it here
234
+ * rather than importing the kernel or the analyzer, so a published module
235
+ * binds to a versioned contract instead of to whatever kernel loads it.
236
+ */
237
+ readonly runtime: RuntimeSeam;
230
238
  readonly moduleContext: ModuleContext;
231
239
  readonly env: Record<string, string | undefined>;
232
240
  readonly stdin: NodeJS.ReadableStream;
@@ -0,0 +1,114 @@
1
+ import type { Stream } from "./stream.js";
2
+
3
+ /**
4
+ * The host's own manifest machinery, exposed to a controller as `ctx.runtime`:
5
+ * **run a manifest**, **analyze a manifest**.
6
+ *
7
+ * It lives on the module-author surface because the modules that need it are
8
+ * ordinary modules — `test` runs a child manifest, `assert`'s `Manifest` kind
9
+ * analyzes one — and reaching into a kernel-internal import to do that would make
10
+ * kernel internals an unversioned ABI between a published artifact and whatever
11
+ * kernel loads it. It is deliberately not test-shaped: a workflow engine running
12
+ * sub-manifests, a supervisor, a hub validating a published module and CI tooling
13
+ * all want one half or the other.
14
+ *
15
+ * Every shape crossing this boundary is plain serializable data or a
16
+ * {@link Stream}, so no kernel or analyzer class is part of the contract and a
17
+ * kernel in any language can implement it. **Isolation is the kernel's choice** —
18
+ * an in-process child kernel today, a subprocess later — which is what keeps
19
+ * process-global host state an implementation detail rather than something a
20
+ * caller has to reason about.
21
+ */
22
+ export interface RuntimeSeam {
23
+ /**
24
+ * Load and start `source` as a child manifest, isolated from the caller's.
25
+ *
26
+ * Resolves once the child has **started**, not once it has finished, so the
27
+ * caller can consume its output while it runs; completion is
28
+ * {@link RuntimeRun.exitCode}. A child that fails to load is not an exception
29
+ * here — it settles `exitCode` non-zero with the failure written to `stderr`,
30
+ * so a caller handles both failure modes in one place.
31
+ *
32
+ * **The caller owns the child's lifetime.** Drain both streams, or stop it with
33
+ * {@link RuntimeRun.cancel}; a child nobody reads and nobody stops keeps
34
+ * producing, and its output accumulates in the host's memory.
35
+ */
36
+ run(source: string, options?: RuntimeRunOptions): Promise<RuntimeRun>;
37
+ /**
38
+ * Run the static-analysis pass over `source` and its import graph without
39
+ * instantiating anything. Never throws for a manifest that fails to load —
40
+ * that is {@link RuntimeCheckResult.loadError}, which is an answer, not an
41
+ * error.
42
+ */
43
+ check(source: string, options?: RuntimeCheckOptions): Promise<RuntimeCheckResult>;
44
+ }
45
+
46
+ export interface RuntimeRunOptions {
47
+ /** Host environment the child binds its `variables:` / `secrets:` / `ports:`
48
+ * from. Omitted means the caller's own — a child never inherits more than it
49
+ * is handed. */
50
+ env?: Record<string, string | undefined>;
51
+ }
52
+
53
+ /**
54
+ * A started child manifest.
55
+ *
56
+ * Output is a stream rather than a captured string because the two useful
57
+ * behaviours — forward it live, keep it to print on failure — are the caller's
58
+ * to choose, and only one of them survives a value produced at the end. A caller
59
+ * that just wants the text drains the stream itself.
60
+ *
61
+ * A stream does **not** by itself bound the host's memory: an unread stream still
62
+ * accumulates whatever the child writes. What bounds it is {@link cancel} — stop
63
+ * the child, rather than hoping it stops producing.
64
+ */
65
+ export interface RuntimeRun {
66
+ readonly stdout: Stream<string>;
67
+ readonly stderr: Stream<string>;
68
+ /** Settles when the child has finished — including after {@link cancel}. Both
69
+ * streams have ended by then. */
70
+ readonly exitCode: Promise<number>;
71
+ /**
72
+ * Stop the child and tear it down.
73
+ *
74
+ * On the contract from the start rather than added later: termination is the
75
+ * first thing a supervisor or a workflow engine running an open-ended
76
+ * sub-manifest needs, and it is also the only bound on an unread child's
77
+ * output. Idempotent, and safe after the child has already finished.
78
+ *
79
+ * Resolves when teardown has completed, so a caller that must know the child
80
+ * released its resources — ports, connections, files — can await it.
81
+ */
82
+ cancel(reason?: string): Promise<void>;
83
+ }
84
+
85
+ export interface RuntimeCheckOptions {
86
+ /** Expand each module document's inline `imports:` map into synthetic
87
+ * `Telo.Import` manifests before analysis, so a manifest using inline imports
88
+ * analyzes the way it runs. */
89
+ desugarImports?: boolean;
90
+ }
91
+
92
+ /** Severity as a name rather than the LSP integer: the integer is a protocol
93
+ * detail of one editor transport, and this contract is read by a Rust or Go
94
+ * kernel too. */
95
+ export type CheckDiagnosticSeverity = "error" | "warning" | "info" | "hint";
96
+
97
+ /** One analyzer finding, flattened to data. Positions are zero-based, matching
98
+ * the analyzer's own range model. */
99
+ export interface CheckDiagnostic {
100
+ code: string;
101
+ message: string;
102
+ severity: CheckDiagnosticSeverity;
103
+ /** URL of the manifest the finding is in, when the analyzer located one. */
104
+ source?: string;
105
+ line?: number;
106
+ column?: number;
107
+ }
108
+
109
+ export interface RuntimeCheckResult {
110
+ diagnostics: CheckDiagnostic[];
111
+ /** Set when the import graph could not be loaded at all, in which case
112
+ * `diagnostics` is empty — there was nothing to analyze. */
113
+ loadError?: string;
114
+ }