@telorun/kernel 0.59.0 → 0.61.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 (120) hide show
  1. package/dist/bundle/files-integrity.d.ts +21 -12
  2. package/dist/bundle/files-integrity.d.ts.map +1 -1
  3. package/dist/bundle/files-integrity.js +27 -14
  4. package/dist/bundle/files-integrity.js.map +1 -1
  5. package/dist/bundle/module-artifact.d.ts +134 -0
  6. package/dist/bundle/module-artifact.d.ts.map +1 -0
  7. package/dist/bundle/module-artifact.js +300 -0
  8. package/dist/bundle/module-artifact.js.map +1 -0
  9. package/dist/bundle/module-manifest.d.ts +12 -4
  10. package/dist/bundle/module-manifest.d.ts.map +1 -1
  11. package/dist/bundle/module-manifest.js +8 -4
  12. package/dist/bundle/module-manifest.js.map +1 -1
  13. package/dist/controller-loader.d.ts +3 -2
  14. package/dist/controller-loader.d.ts.map +1 -1
  15. package/dist/controller-loader.js +8 -8
  16. package/dist/controller-loader.js.map +1 -1
  17. package/dist/controller-loaders/bundle-loader.d.ts +8 -6
  18. package/dist/controller-loaders/bundle-loader.d.ts.map +1 -1
  19. package/dist/controller-loaders/bundle-loader.js +52 -13
  20. package/dist/controller-loaders/bundle-loader.js.map +1 -1
  21. package/dist/controller-loaders/npm-loader.d.ts +0 -18
  22. package/dist/controller-loaders/npm-loader.d.ts.map +1 -1
  23. package/dist/controller-loaders/npm-loader.js +3 -190
  24. package/dist/controller-loaders/npm-loader.js.map +1 -1
  25. package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -1
  26. package/dist/controllers/resource-definition/resource-definition-controller.js +6 -1
  27. package/dist/controllers/resource-definition/resource-definition-controller.js.map +1 -1
  28. package/dist/controllers/resource-definition/resource-inherited-controller.d.ts.map +1 -1
  29. package/dist/controllers/resource-definition/resource-inherited-controller.js +57 -10
  30. package/dist/controllers/resource-definition/resource-inherited-controller.js.map +1 -1
  31. package/dist/controllers/type/json-schema-controller.d.ts +8 -0
  32. package/dist/controllers/type/json-schema-controller.d.ts.map +1 -0
  33. package/dist/controllers/type/json-schema-controller.js +91 -0
  34. package/dist/controllers/type/json-schema-controller.js.map +1 -0
  35. package/dist/directory-lock.d.ts +27 -0
  36. package/dist/directory-lock.d.ts.map +1 -0
  37. package/dist/directory-lock.js +205 -0
  38. package/dist/directory-lock.js.map +1 -0
  39. package/dist/evaluation-context.d.ts +5 -0
  40. package/dist/evaluation-context.d.ts.map +1 -1
  41. package/dist/evaluation-context.js +63 -33
  42. package/dist/evaluation-context.js.map +1 -1
  43. package/dist/index.d.ts +5 -2
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +4 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/init-failure-diagnostics.d.ts +61 -0
  48. package/dist/init-failure-diagnostics.d.ts.map +1 -0
  49. package/dist/init-failure-diagnostics.js +141 -0
  50. package/dist/init-failure-diagnostics.js.map +1 -0
  51. package/dist/invocation-contract-binding.d.ts +105 -0
  52. package/dist/invocation-contract-binding.d.ts.map +1 -0
  53. package/dist/invocation-contract-binding.js +296 -0
  54. package/dist/invocation-contract-binding.js.map +1 -0
  55. package/dist/kernel.d.ts +49 -0
  56. package/dist/kernel.d.ts.map +1 -1
  57. package/dist/kernel.js +117 -6
  58. package/dist/kernel.js.map +1 -1
  59. package/dist/manifest-sources/local-manifest-cache-source.d.ts +1 -1
  60. package/dist/manifest-sources/local-manifest-cache-source.d.ts.map +1 -1
  61. package/dist/manifest-sources/local-manifest-cache-source.js +1 -1
  62. package/dist/manifest-sources/local-manifest-cache-source.js.map +1 -1
  63. package/dist/module-context.d.ts.map +1 -1
  64. package/dist/module-context.js +21 -0
  65. package/dist/module-context.js.map +1 -1
  66. package/dist/resource-context.d.ts +61 -0
  67. package/dist/resource-context.d.ts.map +1 -1
  68. package/dist/resource-context.js +131 -0
  69. package/dist/resource-context.js.map +1 -1
  70. package/dist/schema-compiled-values.d.ts +9 -1
  71. package/dist/schema-compiled-values.d.ts.map +1 -1
  72. package/dist/schema-compiled-values.js +55 -16
  73. package/dist/schema-compiled-values.js.map +1 -1
  74. package/dist/schema-validator.d.ts.map +1 -1
  75. package/dist/schema-validator.js +15 -1
  76. package/dist/schema-validator.js.map +1 -1
  77. package/dist/transports/oci/oci-client.d.ts +28 -1
  78. package/dist/transports/oci/oci-client.d.ts.map +1 -1
  79. package/dist/transports/oci/oci-client.js +24 -1
  80. package/dist/transports/oci/oci-client.js.map +1 -1
  81. package/dist/transports/oci/oci-transport.d.ts +20 -14
  82. package/dist/transports/oci/oci-transport.d.ts.map +1 -1
  83. package/dist/transports/oci/oci-transport.js +105 -46
  84. package/dist/transports/oci/oci-transport.js.map +1 -1
  85. package/dist/transports/registry-transport.d.ts +7 -2
  86. package/dist/transports/registry-transport.d.ts.map +1 -1
  87. package/dist/transports/registry-transport.js +8 -33
  88. package/dist/transports/registry-transport.js.map +1 -1
  89. package/dist/transports/transport-registry.d.ts +5 -4
  90. package/dist/transports/transport-registry.d.ts.map +1 -1
  91. package/dist/transports/transport-registry.js +4 -4
  92. package/dist/transports/transport-registry.js.map +1 -1
  93. package/dist/transports/transport.d.ts +27 -19
  94. package/dist/transports/transport.d.ts.map +1 -1
  95. package/package.json +3 -3
  96. package/src/bundle/files-integrity.ts +34 -14
  97. package/src/bundle/module-artifact.ts +375 -0
  98. package/src/bundle/module-manifest.ts +22 -6
  99. package/src/controller-loader.ts +9 -4
  100. package/src/controller-loaders/bundle-loader.ts +57 -11
  101. package/src/controller-loaders/npm-loader.ts +3 -209
  102. package/src/controllers/resource-definition/resource-definition-controller.ts +19 -0
  103. package/src/controllers/resource-definition/resource-inherited-controller.ts +69 -10
  104. package/src/controllers/type/json-schema-controller.ts +114 -0
  105. package/src/directory-lock.ts +225 -0
  106. package/src/evaluation-context.ts +81 -32
  107. package/src/index.ts +11 -2
  108. package/src/init-failure-diagnostics.ts +169 -0
  109. package/src/invocation-contract-binding.ts +392 -0
  110. package/src/kernel.ts +149 -6
  111. package/src/manifest-sources/local-manifest-cache-source.ts +1 -1
  112. package/src/module-context.ts +27 -0
  113. package/src/resource-context.ts +138 -0
  114. package/src/schema-compiled-values.ts +55 -15
  115. package/src/schema-validator.ts +15 -1
  116. package/src/transports/oci/oci-client.ts +32 -1
  117. package/src/transports/oci/oci-transport.ts +122 -51
  118. package/src/transports/registry-transport.ts +10 -38
  119. package/src/transports/transport-registry.ts +5 -5
  120. package/src/transports/transport.ts +32 -19
@@ -0,0 +1,105 @@
1
+ import { type ContractDirection, type DefResolver } from "@telorun/analyzer";
2
+ import type { ResourceDefinition, ResourceInstance, ResourceManifest } from "@telorun/sdk";
3
+ /**
4
+ * Binds a resource's resolved invocation contract to its dispatch entry points,
5
+ * at the moment the kernel produces the instance.
6
+ *
7
+ * A contract is only a guarantee if it cannot be dispatched around, and most
8
+ * consumers never reach the kernel's dispatch chokepoint: Phase-5 injection puts
9
+ * the live instance straight into a consumer's config object, so `Ai.Agent`
10
+ * reads `this.resource.model` and calls `model.invoke(...)` in hand. Enforcing at
11
+ * a handoff would mean enforcing at every handoff — Phase-5 injection,
12
+ * `ctx.resolveRef`, scope-handle resolution, the template controller's direct
13
+ * dispatch, `ctx.invoke`'s target lookup — and one forgotten site silently
14
+ * reopens the hole.
15
+ *
16
+ * So the kernel binds instead, at `_createInstance`: its single production site.
17
+ * Every consumer, on every path, then holds an instance whose dispatch already
18
+ * enforces. Binding rather than wrapping is also what keeps the rest a
19
+ * non-problem — there is one object, so controller-specific members are
20
+ * genuinely its own, the prototype chain (and `instanceof` across the SDK realm
21
+ * boundary) is untouched, and `stripCompiledValues` / `detachSnapshotValue` see
22
+ * exactly the object they always saw. It is the same in-place technique the
23
+ * kernel already uses to fold detached-task draining into `teardown()` and
24
+ * runtime CEL expansion into `invoke()`.
25
+ *
26
+ * Consequence, stated rather than left to be discovered: the bound `invoke`
27
+ * shadows the controller's, so a controller calling `this.invoke()` internally
28
+ * goes through its own contract.
29
+ */
30
+ /** Compiles a JSON Schema to a validator. The kernel's `SchemaValidator` runs
31
+ * with `useDefaults`, so validating also fills declared defaults. */
32
+ export interface ContractValidatorFactory {
33
+ (typeRef: unknown): {
34
+ validate(value: unknown): void;
35
+ };
36
+ /** Resolves a type field to its JSON Schema, for the schema-level decisions
37
+ * (stream skipping, default paths) a compiled validator can't answer. */
38
+ schemaOf(typeRef: unknown): Record<string, any> | undefined;
39
+ /** Resolves a `$ref` to the registered schema it names, so the schema walks
40
+ * can see through the reference form the compiled validator keeps intact. */
41
+ resolveRef(ref: string): Record<string, any> | undefined;
42
+ /** Compiles an adjusted schema while keeping the CEL `rules:` registered under
43
+ * a named type — the one path that survives stripping a stream property from
44
+ * a named contract without abandoning its invariants. */
45
+ withRules(name: string | undefined, schema: Record<string, any>): {
46
+ validate(value: unknown): void;
47
+ };
48
+ }
49
+ export interface BoundContract {
50
+ direction: ContractDirection;
51
+ validate(value: unknown): void;
52
+ /** Paths a default can be written to — how far the caller's value must be
53
+ * copied before validation runs. Empty when the contract declares none. */
54
+ defaultPaths(): string[][];
55
+ }
56
+ export declare function resolveBoundContract(direction: ContractDirection, manifest: ResourceManifest, definition: ResourceDefinition | undefined, resolveDef: DefResolver, factory: ContractValidatorFactory): BoundContract | undefined;
57
+ /**
58
+ * A copy of `value` deep along exactly the paths a default can be written to and
59
+ * shared everywhere else.
60
+ *
61
+ * A flat shallow copy would not do: AJV's `useDefaults` writes at every level it
62
+ * finds a default, so a nested default would mutate the structure the caller
63
+ * still holds. Bounded by the schema's defaults rather than by the size of the
64
+ * payload — a contract declaring no defaults copies one level and nothing more.
65
+ */
66
+ export declare function copyForDefaults(value: unknown, paths: readonly string[][]): unknown;
67
+ /**
68
+ * Raise a contract violation as a structured {@link InvokeError}.
69
+ *
70
+ * Structured rather than a plain error because the run engine assigns
71
+ * `INTERNAL_ERROR` to anything that is not an `InvokeError` — a contract
72
+ * violation would then reach a `catch` block indistinguishable from a crash, and
73
+ * an author could neither match it nor rethrow it faithfully. These are ambient
74
+ * kernel codes: catchable by name, and never counted against a kind's own
75
+ * `throws:` union.
76
+ *
77
+ * The message names the target, the direction, and the offending detail, because
78
+ * a caller several steps away otherwise cannot tell which boundary rejected the
79
+ * value or which side supplied it.
80
+ */
81
+ export declare function contractViolation(direction: ContractDirection, describeTarget: () => string, cause: unknown): Error;
82
+ export interface ContractBinding {
83
+ input?: BoundContract;
84
+ output?: BoundContract;
85
+ /** Names the resource in a violation message — the target, so a caller several
86
+ * steps away can tell which boundary rejected the value. */
87
+ describeTarget(): string;
88
+ }
89
+ /**
90
+ * Bind `invoke()` and `provide()` in place.
91
+ *
92
+ * `provide()` takes no caller arguments, so it has no input side, but it returns
93
+ * a value against a declared `outputType` and that result is validated exactly as
94
+ * an invocable's is — same path, same stream skip, same ambient error code.
95
+ * `run()` is bound to nothing: parameterless and void, there is nothing to fill
96
+ * defaults into and no result to validate, so it is guarded statically instead.
97
+ */
98
+ export declare function bindContract(instance: ResourceInstance, binding: ContractBinding): void;
99
+ /** A structural copy with every BigInt rendered as a Number, for validation
100
+ * only. A value beyond the safe-integer range loses precision in the VIEW,
101
+ * which can only affect a bound check at the extremes; the dispatched value is
102
+ * untouched. Non-plain objects (a live `Stream`, a resource instance) pass
103
+ * through by reference — they are not data to be walked. */
104
+ export declare function withBigIntsAsNumbers(value: unknown): unknown;
105
+ //# sourceMappingURL=invocation-contract-binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocation-contract-binding.d.ts","sourceRoot":"","sources":["../src/invocation-contract-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EAGtB,KAAK,WAAW,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQ3F;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;sEACsE;AACtE,MAAM,WAAW,wBAAwB;IACvC,CAAC,OAAO,EAAE,OAAO,GAAG;QAAE,Q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Aa,CAAC;IACvB;iEAC6D;IAC7D,cAAc,IAAI,MAAM,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CA2DvF;AAED;;;;6DAI6D;AAC7D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAqB5D"}
@@ -0,0 +1,296 @@
1
+ import { defaultBearingPaths, effectiveContractField, withStreamPropertiesSkipped, } from "@telorun/analyzer";
2
+ import { ERR_CONTRACT_UNRESOLVABLE, ERR_INPUT_INVALID, ERR_OUTPUT_INVALID, InvokeError, } from "@telorun/sdk";
3
+ const CONTRACT_ERROR = {
4
+ inputType: ERR_INPUT_INVALID,
5
+ outputType: ERR_OUTPUT_INVALID,
6
+ };
7
+ /**
8
+ * Resolve one direction of a resource's contract to a bound validator.
9
+ *
10
+ * The declaration is layered instance-manifest → nearest along `extends` (see
11
+ * `effectiveContractField` — nearest wins, contracts never merge), then compiled.
12
+ *
13
+ * A NAMED reference (`inputType: RequestShape`, or a `!ref` to a type) is
14
+ * compiled by name so it keeps the CEL `rules:` registered alongside it, which a
15
+ * plain schema copy would drop. Everything else is compiled from the resolved
16
+ * schema — inline `{kind, schema}` and raw forms carry no rules, and resolving
17
+ * first is what lets a `{ $ref: "telo://Self/X" }` contract compile at all
18
+ * (`resolveTypeSchema` follows it through the kernel's registry, which AJV
19
+ * cannot).
20
+ *
21
+ * The resolved schema is stripped of `x-telo-stream` properties first: a live
22
+ * `Stream` in a declared slot is not data to be traversed, the same defect as
23
+ * `stripCompiledValues` walking a live instance in a ref slot. Streams travel in
24
+ * both directions (`Codec.Encoder` marks `input` on its `inputType` and requires
25
+ * it), so the skip is not one-directional.
26
+ *
27
+ * WHICH declaration applies is decided here, at create time — that is a fact
28
+ * about the manifest. COMPILING it is deferred to first dispatch and memoized: a
29
+ * contract may reference a named `telo#Type` whose `Type.JsonSchema` resource
30
+ * initializes later in the same multi-pass loop, and resolving it eagerly would
31
+ * make every contract-declaring kind depend on type-registration order. Nothing
32
+ * can dispatch before the loop finishes, so first-use is always late enough.
33
+ */
34
+ /** True when a type field names a registered `telo#Type` — a bare name, or the
35
+ * `{kind, name}` object a `!ref` normalizes to. Only these carry CEL `rules:`,
36
+ * so only these are worth compiling by name rather than from their schema. */
37
+ function isNamedTypeReference(declared) {
38
+ if (typeof declared === "string")
39
+ return true;
40
+ if (!declared || typeof declared !== "object")
41
+ return false;
42
+ const ref = declared;
43
+ return typeof ref.name === "string" && !(ref.schema && typeof ref.schema === "object");
44
+ }
45
+ export function resolveBoundContract(direction, manifest, definition, resolveDef, factory) {
46
+ const own = manifest[direction];
47
+ const declared = own !== undefined && own !== null
48
+ ? own
49
+ : effectiveContractField(definition, resolveDef, direction);
50
+ if (declared === undefined || declared === null)
51
+ return undefined;
52
+ let compiled;
53
+ let paths;
54
+ const resolve = () => {
55
+ if (compiled !== undefined)
56
+ return compiled;
57
+ const schema = factory.schemaOf(declared);
58
+ if (!schema) {
59
+ // A declared contract that resolves to nothing is a manifest fault — a
60
+ // named type that never registered — and it MUST NOT degrade to
61
+ // "unvalidated". Silently disabling enforcement is the failure mode
62
+ // nobody notices: every later call passes because nothing is checking.
63
+ throw new InvokeError(ERR_CONTRACT_UNRESOLVABLE, `declared \`${direction}\` could not be resolved to a schema: ${describeDeclaration(declared)}. ` +
64
+ `The type is not registered, so the contract cannot be enforced.`);
65
+ }
66
+ const stripped = withStreamPropertiesSkipped(schema, factory.resolveRef);
67
+ paths = defaultBearingPaths(stripped, factory.resolveRef);
68
+ // Compile by NAME whenever the declaration is one, so the type's CEL
69
+ // `rules:` are composed in — including when a stream had to be stripped, in
70
+ // which case the stream-bearing properties are dropped from the schema the
71
+ // named validator sees rather than the reference being abandoned.
72
+ compiled = !isNamedTypeReference(declared)
73
+ ? factory(stripped)
74
+ : stripped === schema
75
+ ? factory(declared)
76
+ : factory.withRules(nameOf(declared), stripped);
77
+ return compiled;
78
+ };
79
+ return {
80
+ direction,
81
+ validate: (value) => resolve().validate(value),
82
+ defaultPaths: () => {
83
+ resolve();
84
+ return paths ?? [];
85
+ },
86
+ };
87
+ }
88
+ const nameOf = (declared) => typeof declared === "string"
89
+ ? declared
90
+ : declared?.name;
91
+ const describeDeclaration = (declared) => typeof declared === "string" ? `'${declared}'` : JSON.stringify(declared);
92
+ /**
93
+ * A copy of `value` deep along exactly the paths a default can be written to and
94
+ * shared everywhere else.
95
+ *
96
+ * A flat shallow copy would not do: AJV's `useDefaults` writes at every level it
97
+ * finds a default, so a nested default would mutate the structure the caller
98
+ * still holds. Bounded by the schema's defaults rather than by the size of the
99
+ * payload — a contract declaring no defaults copies one level and nothing more.
100
+ */
101
+ export function copyForDefaults(value, paths) {
102
+ if (!value || typeof value !== "object")
103
+ return value;
104
+ let out = shallowCopy(value);
105
+ for (const path of paths) {
106
+ // The leaf is what gets written; every CONTAINER above it is what must not
107
+ // be shared. An `[]` segment fans out: the default lands in each element, so
108
+ // the array and every element on the path have to be copied too — bailing
109
+ // there would leave `rows[0]` shared and let a fill mutate the caller's data.
110
+ out = copyAlong(out, path.slice(0, -1));
111
+ }
112
+ return out;
113
+ }
114
+ const shallowCopy = (value) => Array.isArray(value) ? [...value] : { ...value };
115
+ function copyAlong(node, segments) {
116
+ if (!node || typeof node !== "object")
117
+ return node;
118
+ if (segments.length === 0)
119
+ return node;
120
+ const [head, ...rest] = segments;
121
+ if (head === "[]") {
122
+ if (!Array.isArray(node))
123
+ return node;
124
+ return node.map((item) => item && typeof item === "object" ? copyAlong(shallowCopy(item), rest) : item);
125
+ }
126
+ const container = node;
127
+ const child = container[head];
128
+ if (!child || typeof child !== "object")
129
+ return node;
130
+ container[head] = copyAlong(shallowCopy(child), rest);
131
+ return node;
132
+ }
133
+ /**
134
+ * Raise a contract violation as a structured {@link InvokeError}.
135
+ *
136
+ * Structured rather than a plain error because the run engine assigns
137
+ * `INTERNAL_ERROR` to anything that is not an `InvokeError` — a contract
138
+ * violation would then reach a `catch` block indistinguishable from a crash, and
139
+ * an author could neither match it nor rethrow it faithfully. These are ambient
140
+ * kernel codes: catchable by name, and never counted against a kind's own
141
+ * `throws:` union.
142
+ *
143
+ * The message names the target, the direction, and the offending detail, because
144
+ * a caller several steps away otherwise cannot tell which boundary rejected the
145
+ * value or which side supplied it.
146
+ */
147
+ export function contractViolation(direction, describeTarget, cause) {
148
+ // A type's CEL `rules:` raise the author's OWN code — that is the whole point
149
+ // of declaring one, and `modules/type` documents rule codes as catchable.
150
+ // Only a structural schema failure is the ambient contract violation.
151
+ //
152
+ // Re-raised as a STRUCTURED error carrying that code: the rule itself throws a
153
+ // `RuntimeError`, which has a code but not the marker a catch block matches
154
+ // on, so it used to reach `catch` as the generic plain-failure code — the
155
+ // documented behaviour never actually worked. Wrapping preserves the code and
156
+ // makes it match.
157
+ const ruleCode = ruleViolationCode(cause);
158
+ if (ruleCode) {
159
+ return new InvokeError(ruleCode, cause.message, undefined, { cause });
160
+ }
161
+ const side = direction === "inputType" ? "inputs" : "result";
162
+ const detail = cause instanceof Error ? cause.message : String(cause);
163
+ return new InvokeError(CONTRACT_ERROR[direction], `${describeTarget()}: ${side} do not satisfy the declared ${direction}: ${detail}`, undefined, { cause });
164
+ }
165
+ /** Codes the validator itself raises for a STRUCTURAL failure. Anything else
166
+ * carrying a code came from a declared rule and belongs to its author. */
167
+ const STRUCTURAL_VALIDATION_CODES = new Set([
168
+ "ERR_RESOURCE_SCHEMA_VALIDATION_FAILED",
169
+ "ERR_TYPE_NOT_FOUND",
170
+ ]);
171
+ function ruleViolationCode(cause) {
172
+ const code = cause?.code;
173
+ if (typeof code !== "string" || code.length === 0)
174
+ return undefined;
175
+ return STRUCTURAL_VALIDATION_CODES.has(code) ? undefined : code;
176
+ }
177
+ /**
178
+ * Bind `invoke()` and `provide()` in place.
179
+ *
180
+ * `provide()` takes no caller arguments, so it has no input side, but it returns
181
+ * a value against a declared `outputType` and that result is validated exactly as
182
+ * an invocable's is — same path, same stream skip, same ambient error code.
183
+ * `run()` is bound to nothing: parameterless and void, there is nothing to fill
184
+ * defaults into and no result to validate, so it is guarded statically instead.
185
+ */
186
+ export function bindContract(instance, binding) {
187
+ const { input, output, describeTarget } = binding;
188
+ if (!input && !output)
189
+ return;
190
+ if (typeof instance.invoke === "function") {
191
+ const original = instance.invoke.bind(instance);
192
+ // EVERY argument is forwarded, not just `inputs`. `invoke(inputs, ctx)`
193
+ // carries the InvokeContext — cancellation, tracing — as its second
194
+ // parameter, and a wrapper that takes only `inputs` silently drops it: a
195
+ // detached body would then never see its cancellation token and a lease
196
+ // holding across it would never be released. The contract only concerns the
197
+ // first argument; the rest belong to the caller and the callee.
198
+ instance.invoke = async (inputs, ...rest) => {
199
+ let effective = inputs;
200
+ if (input) {
201
+ effective = copyForDefaults(inputs, input.defaultPaths());
202
+ // Validate a BIGINT-NORMALIZED view, not the values themselves. CEL
203
+ // evaluates an integer literal to a BigInt, which a JSON Schema
204
+ // validator does not recognise as `integer` — so every computed integer
205
+ // reaching a declared integer input would be rejected for a reason the
206
+ // author cannot act on. The dispatched values keep their BigInts, since
207
+ // a controller may need the full 64-bit range.
208
+ const view = withBigIntsAsNumbers(effective);
209
+ try {
210
+ input.validate(view);
211
+ }
212
+ catch (error) {
213
+ throw contractViolation("inputType", describeTarget, error);
214
+ }
215
+ // Defaults are additive, so anything the validator filled into the view
216
+ // is a key the caller omitted — copy exactly those back.
217
+ effective = mergeFilledDefaults(effective, view);
218
+ }
219
+ const result = await original(effective, ...rest);
220
+ if (output) {
221
+ try {
222
+ output.validate(withBigIntsAsNumbers(result));
223
+ }
224
+ catch (error) {
225
+ throw contractViolation("outputType", describeTarget, error);
226
+ }
227
+ }
228
+ return result;
229
+ };
230
+ }
231
+ if (output && typeof instance.provide === "function") {
232
+ const original = instance.provide.bind(instance);
233
+ instance.provide = async (...args) => {
234
+ const result = await original(...args);
235
+ try {
236
+ output.validate(withBigIntsAsNumbers(result));
237
+ }
238
+ catch (error) {
239
+ throw contractViolation("outputType", describeTarget, error);
240
+ }
241
+ return result;
242
+ };
243
+ }
244
+ }
245
+ /** A structural copy with every BigInt rendered as a Number, for validation
246
+ * only. A value beyond the safe-integer range loses precision in the VIEW,
247
+ * which can only affect a bound check at the extremes; the dispatched value is
248
+ * untouched. Non-plain objects (a live `Stream`, a resource instance) pass
249
+ * through by reference — they are not data to be walked. */
250
+ export function withBigIntsAsNumbers(value) {
251
+ if (typeof value === "bigint")
252
+ return Number(value);
253
+ if (Array.isArray(value)) {
254
+ let changed = false;
255
+ const items = value.map((item) => {
256
+ const next = withBigIntsAsNumbers(item);
257
+ if (next !== item)
258
+ changed = true;
259
+ return next;
260
+ });
261
+ return changed ? items : value;
262
+ }
263
+ if (!value || typeof value !== "object")
264
+ return value;
265
+ if (Object.getPrototypeOf(value) !== Object.prototype)
266
+ return value;
267
+ let changed = false;
268
+ const out = {};
269
+ for (const [key, item] of Object.entries(value)) {
270
+ const next = withBigIntsAsNumbers(item);
271
+ if (next !== item)
272
+ changed = true;
273
+ out[key] = next;
274
+ }
275
+ return changed ? out : value;
276
+ }
277
+ /** Copy keys the validator's default-fill added to `view` back onto `target`.
278
+ * Only ADDITIONS are taken: a key already present came from the caller and its
279
+ * original (possibly BigInt) value is the one to dispatch. */
280
+ function mergeFilledDefaults(target, view) {
281
+ if (target === view)
282
+ return target;
283
+ if (!target || typeof target !== "object" || Array.isArray(target))
284
+ return target;
285
+ if (!view || typeof view !== "object" || Array.isArray(view))
286
+ return target;
287
+ const out = target;
288
+ for (const [key, filled] of Object.entries(view)) {
289
+ if (!(key in out))
290
+ out[key] = filled;
291
+ else
292
+ out[key] = mergeFilledDefaults(out[key], filled);
293
+ }
294
+ return out;
295
+ }
296
+ //# sourceMappingURL=invocation-contract-binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocation-contract-binding.js","sourceRoot":"","sources":["../src/invocation-contract-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBA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C,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/B,CAAC;AAED;;+DAE+D;AAC/D,SAAS,mBAAmB,CAAC,MAAe,EAAE,IAAa;IACzD,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IACnC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAClF,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAC5E,MAAM,GAAG,GAAG,MAAiC,CAAC;IAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAA+B,CAAC,EAAE,CAAC;QAC5E,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;;YAChC,GAAG,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/kernel.d.ts CHANGED
@@ -2,6 +2,7 @@ import { AnalysisRegistry, type LoadedGraph, type ManifestSource } from "@teloru
2
2
  import { Kernel as IKernel, ResourceDefinition, ResourceInstance, ResourceManifest, RuntimeEvent, type EvaluationContext as IEvaluationContext, type InvokeOptions, type LoadOptions } from "@telorun/sdk";
3
3
  import { KernelLogging } from "./logging/kernel-logging.js";
4
4
  import type { ScopeConfig } from "./logging/scope-config.js";
5
+ import { type ModuleArtifact } from "./bundle/module-artifact.js";
5
6
  export interface KernelOptions {
6
7
  stdin?: NodeJS.ReadableStream;
7
8
  stdout?: NodeJS.WritableStream;
@@ -44,6 +45,9 @@ export declare class Kernel implements IKernel {
44
45
  /** The `.telo` cache root for this load, resolved once in `load()` and
45
46
  * threaded to the validator, analysis stamp, and npm install root. */
46
47
  private _cacheRoot?;
48
+ /** Per-module artifact handles, keyed by canonical manifest source. Rebuilt on
49
+ * every `load()`; empty for a graph of purely local / manifest-only modules. */
50
+ private readonly moduleArtifacts;
47
51
  private _loadedGraph?;
48
52
  private _bootCalled;
49
53
  private _isBooted;
@@ -219,6 +223,34 @@ export declare class Kernel implements IKernel {
219
223
  /** The npm install root for this load (`<cache-root>/npm`), threaded to the
220
224
  * controller loader so it doesn't re-derive it from the entry URL. */
221
225
  getInstallRoot(): string | undefined;
226
+ /**
227
+ * Build one {@link ModuleArtifact} per loaded module that ships a payload.
228
+ *
229
+ * Here, and not inside a controller loader, because this is the only point
230
+ * where both halves are in hand: the **pinned** ref the importer wrote
231
+ * (`requestedUrl`, integrity fragment included) and the manifest text that has
232
+ * already been verified against it. A loader sees only the canonical base URI,
233
+ * which carries no `#sha256-`, so a loader that fetched for itself would have
234
+ * to re-read the index off the cache directory — verification downgraded from
235
+ * "anchored at the importer's pin" to "trust whatever is on disk".
236
+ *
237
+ * Keyed by canonical `source`, which is what a definition's `metadata.source`
238
+ * carries, so a controller resolution can find its module's artifact.
239
+ *
240
+ * The trigger is "this manifest carries a `layers:` index", never "its source
241
+ * maps to a cache path". Those differ the moment the cache is warm:
242
+ * `LocalManifestCacheSource` serves a hit as a `file://` URL into
243
+ * `.telo/manifests/`, which no transport claims, so deriving the directory from
244
+ * `source` yields nothing and every OCI module would silently lose its artifact
245
+ * on the second and every later run — taking lazy asset materialization with it.
246
+ * The **pinned** `requestedUrl` survives a cache hit, so placement is derived
247
+ * from that, with a local `source` resolving to its own directory.
248
+ */
249
+ private buildModuleArtifacts;
250
+ /** The artifact of the module whose manifest resolved from `source`, or
251
+ * `undefined` for a module with no fetchable payload (already on disk,
252
+ * manifest-only, or not cacheable). */
253
+ getModuleArtifact(source: string | undefined): ModuleArtifact | undefined;
222
254
  /** Authored `kind` of a declared resource by name, from the static manifest
223
255
  * set. Init-order-independent (unlike `resourceInstances`), so a controller
224
256
  * resolving a `!ref <name>` sentinel before the target initializes can still
@@ -265,6 +297,17 @@ export declare class Kernel implements IKernel {
265
297
  * is not yet registered (retry signal).
266
298
  */
267
299
  private _createInstance;
300
+ /**
301
+ * Resolve and bind both directions of a resource's invocation contract.
302
+ *
303
+ * The declaration is layered instance-manifest → nearest along `extends`;
304
+ * contracts never merge (a call signature is not additive the way construction
305
+ * config is), so a definition that declares one fully replaces its ancestor's.
306
+ * Resolution runs in the scope that DECLARED each definition — an `extends`
307
+ * alias is lexical, and a `telo#Type` reference goes through import aliases, so
308
+ * a chain crossing module boundaries re-scopes at every hop.
309
+ */
310
+ private bindInvocationContract;
268
311
  /**
269
312
  * Create phase for an inherited (concrete-`extends`) definition's parent: runs
270
313
  * the ordinary create pipeline (controller resolution + lazy load, schema
@@ -282,6 +325,12 @@ export declare class Kernel implements IKernel {
282
325
  * field map and replaces each {kind, name} reference value (outside scope visibility
283
326
  * paths) with the live ResourceInstance returned by getInstance(name). Fields within
284
327
  * scope paths are left as {kind, name} — the controller resolves them at runtime.
328
+ *
329
+ * `owner` is the context the resource belongs to, and the scope handle built for an
330
+ * `x-telo-scope` field hangs off it rather than off the root: a `with:` block's inline
331
+ * declarations name their kinds through the import aliases of the module that DECLARED
332
+ * the resource, so a library's scoped `kind: OAuth.RedirectListener` resolves against
333
+ * that library's imports — the root has never heard of the alias.
285
334
  */
286
335
  private _injectDependencies;
287
336
  }
@@ -1 +1 @@
1
- {"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAOhB,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,MAAM,IAAI,OAAO,EAEjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAEhB,YAAY,EAGZ,KAAK,iBAAiB,IAAI,kBAAkB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