@telorun/kernel 0.56.0 → 0.58.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/controllers/module/import-controller.d.ts.map +1 -1
- package/dist/controllers/module/import-controller.js +7 -3
- package/dist/controllers/module/import-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts +1 -0
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.js +10 -1
- package/dist/controllers/resource-definition/resource-definition-controller.js.map +1 -1
- package/dist/evaluation-context.d.ts +57 -2
- package/dist/evaluation-context.d.ts.map +1 -1
- package/dist/evaluation-context.js +209 -8
- package/dist/evaluation-context.js.map +1 -1
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +6 -3
- package/dist/kernel.js.map +1 -1
- package/dist/manifest-schemas.d.ts +8 -0
- package/dist/manifest-schemas.d.ts.map +1 -1
- package/dist/manifest-schemas.js +6 -0
- package/dist/manifest-schemas.js.map +1 -1
- package/dist/module-context.d.ts +8 -0
- package/dist/module-context.d.ts.map +1 -1
- package/dist/module-context.js +20 -5
- package/dist/module-context.js.map +1 -1
- package/dist/observed-state.d.ts +94 -0
- package/dist/observed-state.d.ts.map +1 -0
- package/dist/observed-state.js +148 -0
- package/dist/observed-state.js.map +1 -0
- package/dist/resource-context.d.ts +50 -1
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/resource-context.js +56 -12
- package/dist/resource-context.js.map +1 -1
- package/dist/transports/oci/oci-ref.d.ts +1 -1
- package/dist/transports/oci/oci-ref.d.ts.map +1 -1
- package/dist/transports/oci/oci-ref.js +1 -1
- package/dist/transports/oci/oci-ref.js.map +1 -1
- package/dist/transports/oci/oci-transport.d.ts.map +1 -1
- package/dist/transports/oci/oci-transport.js +7 -10
- package/dist/transports/oci/oci-transport.js.map +1 -1
- package/dist/transports/registry-transport.d.ts.map +1 -1
- package/dist/transports/registry-transport.js +3 -8
- package/dist/transports/registry-transport.js.map +1 -1
- package/package.json +3 -3
- package/src/controllers/module/import-controller.ts +12 -3
- package/src/controllers/resource-definition/resource-definition-controller.ts +14 -0
- package/src/evaluation-context.ts +253 -8
- package/src/kernel.ts +5 -0
- package/src/manifest-schemas.ts +6 -0
- package/src/module-context.ts +19 -5
- package/src/observed-state.ts +210 -0
- package/src/resource-context.ts +55 -11
- package/src/transports/oci/oci-ref.ts +8 -1
- package/src/transports/oci/oci-transport.ts +12 -9
- package/src/transports/registry-transport.ts +4 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/module/import-controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"import-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/module/import-controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAK1E,wBAAsB,MAAM,CAC1B,QAAQ,EAAE,GAAG,EACb,GAAG,EAAE,wBAAwB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAmU3B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AnalysisRegistry, DiagnosticSeverity, foldIntegrity, parseExportEntry, StaticAnalyzer } from "@telorun/analyzer";
|
|
2
2
|
import { RuntimeError } from "@telorun/sdk";
|
|
3
|
+
import { publishedPropsOf } from "../../evaluation-context.js";
|
|
3
4
|
import { buildScopeConfig } from "../../logging/kernel-logging.js";
|
|
4
5
|
import { ModuleContext } from "../../module-context.js";
|
|
5
6
|
import { isDefaultPolicy, normalizeRuntime } from "../../runtime-registry.js";
|
|
@@ -236,9 +237,12 @@ export async function create(resource, ctx) {
|
|
|
236
237
|
snapshot: async () => {
|
|
237
238
|
const exported = {};
|
|
238
239
|
for (const name of exportedResourceNames) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
// Through the shared publication policy, not the raw snapshot: an
|
|
241
|
+
// exported instance's observed state stays withheld until it starts and
|
|
242
|
+
// is validated against its `status:` on this side of the boundary too.
|
|
243
|
+
const target = childCtx.getExported(name);
|
|
244
|
+
if (target?.instance) {
|
|
245
|
+
exported[name] = await publishedPropsOf(target.kind, name, target.instance, childCtx.getDefinition);
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
248
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-controller.js","sourceRoot":"","sources":["../../../src/controllers/module/import-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE1H,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"import-controller.js","sourceRoot":"","sources":["../../../src/controllers/module/import-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE1H,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAA6B,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE9E,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,QAAa,EACb,GAA6B;IAE7B,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAc,CAAC;IAE/C,MAAM,SAAS,GAA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EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACpD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC;YAAE,SAAS;QAC7E,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;YAChD,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,sBAAsB,CAC7B,UAA+B,EAC/B,QAAiC,EACjC,IAA6B;IAE7B,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACpD,MAAM,UAAU,GAAG,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC;QAClF,IAAI,UAAU,IAAI,CAAC,CAAC,GAAG,IAAI,QAAQ,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,WAAW,GAAG,kCAAkC,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-definition-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-definition-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EAEf,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-definition-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-definition-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EAEf,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;AAetB,KAAK,0BAA0B,GAAG,eAAe,GAAG;IAClD,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,cAAM,kBAAmB,YAAW,gBAAgB;IAGtC,QAAQ,CAAC,QAAQ,EAAE,0BAA0B;IAFzD,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAwB;gBAEtC,QAAQ,EAAE,0BAA0B;IAEnD,IAAI,CAAC,GAAG,EAAE,eAAe;CAwJhC;AAeD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI,CAErD;AAED,wBAAsB,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAW7F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RuntimeError } from "@telorun/sdk";
|
|
2
|
-
import { controllerBearingAncestor, effectiveAuthorSchema, hasOwnControllerOrTemplate, inheritedCapability, } from "@telorun/analyzer";
|
|
2
|
+
import { controllerBearingAncestor, effectiveAuthorSchema, effectiveStatusSchema, hasOwnControllerOrTemplate, inheritedCapability, } from "@telorun/analyzer";
|
|
3
3
|
import { ControllerLoader } from "../../controller-loader.js";
|
|
4
4
|
import { formatAjvErrors, validateResourceDefinition } from "../../manifest-schemas.js";
|
|
5
5
|
import { createTemplateController } from "./resource-template-controller.js";
|
|
@@ -42,6 +42,15 @@ class ResourceDefinition {
|
|
|
42
42
|
throw new RuntimeError("ERR_LOCAL_REF_PENDING", `Telo.Definition '${this.resource.metadata.name}': 'extends' target '${this.resource.extends}' is not loaded yet.`);
|
|
43
43
|
}
|
|
44
44
|
this.resource.schema = effectiveAuthorSchema(this.resource, resolveDef);
|
|
45
|
+
// Same for the observed-state contract: a child without `base:` merges its
|
|
46
|
+
// parent's `status:`, one with `base:` publishes the parent's unchanged.
|
|
47
|
+
// Stamped here, in the DEFINING library's scope, because an `extends` alias
|
|
48
|
+
// belongs to the file that declared it — a consumer that imports only the
|
|
49
|
+
// backend (the sanctioned "one import instead of two") has no alias for the
|
|
50
|
+
// abstract's library and would resolve the parent to nothing. Stamping also
|
|
51
|
+
// makes the folded schema a stable object, so the publication path's AJV
|
|
52
|
+
// validator cache hits instead of recompiling on every snapshot.
|
|
53
|
+
this.resource.status = effectiveStatusSchema(this.resource, resolveDef);
|
|
45
54
|
}
|
|
46
55
|
// Inherited-controller delegation: a definition that `extends` a concrete
|
|
47
56
|
// kind, declares no own `controllers:` / template body, inherits the parent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-definition-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-definition-controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,GAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-definition-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-definition-controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,GAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAkB/E;;;GAGG;AACH,MAAM,kBAAkB;IAGtB,YAAqB,QAAoC;QAApC,aAAQ,GAAR,QAAQ,CAA4B;QAFhD,SAAI,GAAyB,oBAAoB,CAAC;IAEC,CAAC;IAE7D,KAAK,CAAC,IAAI,CAAC,GAAoB;QAC7B,MAAM,WAAW,GAAG,GAAG,CAAC,aAAa,CAAC;QACtC,oEAAoE;QACpE,wEAAwE;QACxE,sBAAsB;QACtB,MAAM,UAAU,GAAgB,CAAC,IAAI,EAAE,EAAE;YACvC,IAAI,SAAS,GAAG,IAAI,CAAC;YACrB,IAAI,CAAC;gBACH,SAAS,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAC5C,CAAC;YAAC,MAAM,CAAC;gBACP,0DAA0D;YAC5D,CAAC;YACD,OAAO,WAAW,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAA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mitEvent, type InstanceFactory, type InvokeContext, type LifecycleState, type OpenSpan, type OpenSpanOptions, type PreInitHook, type ResourceDefinition, type ResourceInstance, type ResourceManifest, type ResourceOwner, type ScopeHandle, type Tracer } from "@telorun/sdk";
|
|
2
2
|
export { resourceKey };
|
|
3
3
|
export declare function buildResolvedProperties(resource: ResourceManifest, secretValues: Set<string>): Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* The published value for an instance the caller resolved itself, rather than
|
|
6
|
+
* one reached by name through a context's own `resourceInstances`. The
|
|
7
|
+
* cross-module export path uses it: an importer surfaces a library's exported
|
|
8
|
+
* instances under `resources.<Alias>.<name>`, which crosses the boundary
|
|
9
|
+
* without passing through the owner's `resources` map — and must still carry the
|
|
10
|
+
* reading the instance reported, under the same rules.
|
|
11
|
+
*
|
|
12
|
+
* `kind` is already canonical (`<module>.<Kind>`) on that path, so the resolver
|
|
13
|
+
* needs no alias table.
|
|
14
|
+
*/
|
|
15
|
+
export declare function publishedPropsOf(kind: string, name: string, instance: ResourceInstance, getDefinition: ((kind: string) => ResourceDefinition | undefined) | undefined): Promise<Record<string, unknown>>;
|
|
4
16
|
/**
|
|
5
17
|
* The ambient dispatch context, for §7.2's automatic trace correlation: a record
|
|
6
18
|
* emitted inside an active span carries that span's ids without the controller
|
|
@@ -84,8 +96,39 @@ export declare class EvaluationContext implements IEvaluationContext {
|
|
|
84
96
|
private qualifyDeps;
|
|
85
97
|
constructor(source: string, context: Record<string, unknown>, createInstance: InstanceFactory | undefined, secretValues: Set<string>, emit: EmitEvent);
|
|
86
98
|
get createInstance(): InstanceFactory;
|
|
87
|
-
/** Called after init() when a resource snapshot is available. Overridden by
|
|
88
|
-
|
|
99
|
+
/** Called after init() when a resource snapshot is available. Overridden by
|
|
100
|
+
* ModuleContext, and by a scope child (which keeps its own per-run map). */
|
|
101
|
+
protected onResourceSnapshotted(name: string, snap: Record<string, unknown>): void;
|
|
102
|
+
/** Where published snapshots go for a context that has no `resources` map of
|
|
103
|
+
* its own — set by `createScopeHandle` on the per-run child so scope-local
|
|
104
|
+
* resources publish like any other. */
|
|
105
|
+
protected snapshotSink: ((name: string, snap: Record<string, unknown>) => void) | undefined;
|
|
106
|
+
/** Record that an instance has started. Republished so a read that arrives
|
|
107
|
+
* before the resource reports gets the "still running" message rather than
|
|
108
|
+
* the "never started" one. */
|
|
109
|
+
private markStarted;
|
|
110
|
+
/**
|
|
111
|
+
* Record what a resource observed and republish. Validated against the kind's
|
|
112
|
+
* `status:` here, at the point the claim is made, so an invalid report names
|
|
113
|
+
* the call that made it rather than surfacing at some later publication.
|
|
114
|
+
*
|
|
115
|
+
* Replaces rather than merges: this is the resource's observed state now. A
|
|
116
|
+
* declared field this call omits reads as missing, which is the truth — a
|
|
117
|
+
* sometimes-absent field is declared nullable and reported as `null`.
|
|
118
|
+
*/
|
|
119
|
+
setResourceStatus(name: string, status: Record<string, unknown>): Promise<void>;
|
|
120
|
+
/** The kind's effective `status:` — already folded through `extends` and
|
|
121
|
+
* stamped onto the definition at registration, in the scope that DECLARED it
|
|
122
|
+
* (`resource-definition-controller`). Only the kind's own alias is resolved
|
|
123
|
+
* here, in the reading module's scope, which is where it was written. */
|
|
124
|
+
private statusSchemaOf;
|
|
125
|
+
/**
|
|
126
|
+
* Re-read a resource's `snapshot()` and republish it, joined with whatever
|
|
127
|
+
* observed state the resource has reported. The single publication path — the
|
|
128
|
+
* post-init capture, the post-run publication, the post-invoke refresh and
|
|
129
|
+
* every `setStatus()` all land here.
|
|
130
|
+
*/
|
|
131
|
+
publishSnapshot(name: string): Promise<void>;
|
|
89
132
|
get context(): Record<string, unknown>;
|
|
90
133
|
get secretValues(): Set<string>;
|
|
91
134
|
/**
|
|
@@ -220,6 +263,11 @@ export declare class EvaluationContext implements IEvaluationContext {
|
|
|
220
263
|
* kind unchanged. A typed seam (overridden in `ModuleContext`), matching the
|
|
221
264
|
* `traceRootScope()` pattern, rather than reaching across the boundary. */
|
|
222
265
|
protected resolveKindSafe(kind: string): string;
|
|
266
|
+
/** Alias-kind resolver inherited from the context that spawned this one. A
|
|
267
|
+
* scope / template child holds no import table of its own, but its resources
|
|
268
|
+
* are written with the declaring module's aliases (`Observed.Listener`), so
|
|
269
|
+
* definition lookups there have to go through the parent's table. */
|
|
270
|
+
kindResolver: ((kind: string) => string) | undefined;
|
|
223
271
|
private capabilityOf;
|
|
224
272
|
private getDeclaredThrowCodes;
|
|
225
273
|
run(name: string, ctx?: InvokeContext): Promise<void>;
|
|
@@ -292,4 +340,11 @@ export declare class EvaluationContext implements IEvaluationContext {
|
|
|
292
340
|
* against the activation — callers fall back to the original error text.
|
|
293
341
|
*/
|
|
294
342
|
export declare function describeFailedAccess(source: string, ctx: unknown, msg: string): string | null;
|
|
343
|
+
/**
|
|
344
|
+
* The observed-state message for a failed access, or null when the failure has
|
|
345
|
+
* nothing to do with observed state (the caller then falls back to the generic
|
|
346
|
+
* enrichment above). See `observed-state.ts` for why "has not started" and
|
|
347
|
+
* "started but reported nothing" are two different messages.
|
|
348
|
+
*/
|
|
349
|
+
export declare function describeObservedStateFailure(source: string, ctx: unknown, msg: string): string | null;
|
|
295
350
|
//# sourceMappingURL=evaluation-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluation-context.d.ts","sourceRoot":"","sources":["../src/evaluation-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,WAAW,EAEX,KAAK,iBAAiB,IAAI,kBAAkB,EAC5C,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAGlB,KAAK,WAAW,EAChB,KAAK,MAAM,EACZ,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"evaluation-context.d.ts","sourceRoot":"","sources":["../src/evaluation-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f;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,IAAI,CAIf"}
|
|
@@ -3,6 +3,7 @@ import { formatSpanCounter } from "./logging/span-id.js";
|
|
|
3
3
|
import { getRefIdentity, isCompiledValue, isInvokeError, isCancellationError, resourceKey, UNCANCELLABLE_CONTEXT, } from "@telorun/sdk";
|
|
4
4
|
import { RuntimeError } from "@telorun/sdk";
|
|
5
5
|
import { evalPathCovers } from "@telorun/analyzer";
|
|
6
|
+
import { acceptReportedStatus, buildPublishedProps, diagnoseObservedStateAccess, } from "./observed-state.js";
|
|
6
7
|
export { resourceKey };
|
|
7
8
|
/** A pure resolved reference is a `{ kind, name, alias? }` object and nothing
|
|
8
9
|
* else — the shape `resolveRefSentinels` produces (Phase 2.5). An inline
|
|
@@ -143,6 +144,60 @@ export function buildResolvedProperties(resource, secretValues) {
|
|
|
143
144
|
* when a composing controller re-invokes without threading it by hand.
|
|
144
145
|
*/
|
|
145
146
|
const cancellationStore = new AsyncLocalStorage();
|
|
147
|
+
/**
|
|
148
|
+
* Instances whose `run()` has been dispatched. Reporting observed state before
|
|
149
|
+
* this is an error (see observed-state.ts).
|
|
150
|
+
*
|
|
151
|
+
* Keyed on the instance rather than on `(context, name)` because the context
|
|
152
|
+
* that STARTS a resource is not always the one that OWNS it: an importer's
|
|
153
|
+
* `targets:` can name a library's exported instance, and the library's own
|
|
154
|
+
* `ctx.setStatus()` — publishing into the context where its name lives — has to
|
|
155
|
+
* see that it started.
|
|
156
|
+
*/
|
|
157
|
+
const startedInstances = new WeakSet();
|
|
158
|
+
/**
|
|
159
|
+
* The last observed state each instance reported. Sticky: it stays until the
|
|
160
|
+
* resource is torn down, so a dispatch that reports nothing leaves the previous
|
|
161
|
+
* reading in place — a listener's bound address does not stop being true between
|
|
162
|
+
* calls. Keyed by instance for the same reason as `startedInstances`, and
|
|
163
|
+
* because a scope's per-run instances are distinct by construction, which is
|
|
164
|
+
* what keeps two concurrent runs from observing each other's readings.
|
|
165
|
+
*/
|
|
166
|
+
const reportedStatus = new WeakMap();
|
|
167
|
+
/**
|
|
168
|
+
* Instances whose `run()` has RETURNED. A long-lived Service never appears here
|
|
169
|
+
* — its `run()` stays pending for the process lifetime — which is exactly the
|
|
170
|
+
* distinction the reader needs: a Runnable that finished and reported nothing
|
|
171
|
+
* for a field it declares is a producer defect, while a Service that is still
|
|
172
|
+
* coming up is ordering, and telling those apart is not something the reader
|
|
173
|
+
* can do from the manifest.
|
|
174
|
+
*/
|
|
175
|
+
const completedInstances = new WeakSet();
|
|
176
|
+
/**
|
|
177
|
+
* The published value for an instance the caller resolved itself, rather than
|
|
178
|
+
* one reached by name through a context's own `resourceInstances`. The
|
|
179
|
+
* cross-module export path uses it: an importer surfaces a library's exported
|
|
180
|
+
* instances under `resources.<Alias>.<name>`, which crosses the boundary
|
|
181
|
+
* without passing through the owner's `resources` map — and must still carry the
|
|
182
|
+
* reading the instance reported, under the same rules.
|
|
183
|
+
*
|
|
184
|
+
* `kind` is already canonical (`<module>.<Kind>`) on that path, so the resolver
|
|
185
|
+
* needs no alias table.
|
|
186
|
+
*/
|
|
187
|
+
export async function publishedPropsOf(kind, name, instance, getDefinition) {
|
|
188
|
+
const snap = typeof instance.snapshot === "function"
|
|
189
|
+
? (await Promise.resolve(instance.snapshot()))
|
|
190
|
+
: undefined;
|
|
191
|
+
return buildPublishedProps(snap, {
|
|
192
|
+
kind,
|
|
193
|
+
name,
|
|
194
|
+
module: kind.split(".")[0],
|
|
195
|
+
statusSchema: getDefinition?.(kind)?.status,
|
|
196
|
+
status: reportedStatus.get(instance),
|
|
197
|
+
started: startedInstances.has(instance),
|
|
198
|
+
completed: completedInstances.has(instance),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
146
201
|
/**
|
|
147
202
|
* The ambient dispatch context, for §7.2's automatic trace correlation: a record
|
|
148
203
|
* emitted inside an active span carries that span's ids without the controller
|
|
@@ -170,6 +225,14 @@ function compileWalker(value) {
|
|
|
170
225
|
catch (error) {
|
|
171
226
|
const expr = compiled.source ? `\${{ ${compiled.source} }}` : "unknown expression";
|
|
172
227
|
const msg = error instanceof Error ? error.message : String(error);
|
|
228
|
+
// Reading observed state that was never reported is its own failure with
|
|
229
|
+
// its own remedy, so it does not degrade into a bare "No such key".
|
|
230
|
+
const observed = compiled.source
|
|
231
|
+
? describeObservedStateFailure(compiled.source, ctx, msg)
|
|
232
|
+
: null;
|
|
233
|
+
if (observed) {
|
|
234
|
+
throw new RuntimeError("ERR_OBSERVED_STATE_UNAVAILABLE", `${expr}: ${observed}`);
|
|
235
|
+
}
|
|
173
236
|
const hint = compiled.source ? describeFailedAccess(compiled.source, ctx, msg) : null;
|
|
174
237
|
const suffix = hint ? `\n ${hint}` : "";
|
|
175
238
|
throw new Error(`Expression ${expr} failed: ${msg}${suffix}`);
|
|
@@ -256,8 +319,70 @@ export class EvaluationContext {
|
|
|
256
319
|
get createInstance() {
|
|
257
320
|
return this._createInstance;
|
|
258
321
|
}
|
|
259
|
-
/** Called after init() when a resource snapshot is available. Overridden by
|
|
260
|
-
|
|
322
|
+
/** Called after init() when a resource snapshot is available. Overridden by
|
|
323
|
+
* ModuleContext, and by a scope child (which keeps its own per-run map). */
|
|
324
|
+
onResourceSnapshotted(name, snap) {
|
|
325
|
+
this.snapshotSink?.(name, snap);
|
|
326
|
+
}
|
|
327
|
+
/** Record that an instance has started. Republished so a read that arrives
|
|
328
|
+
* before the resource reports gets the "still running" message rather than
|
|
329
|
+
* the "never started" one. */
|
|
330
|
+
async markStarted(name, instance) {
|
|
331
|
+
if (startedInstances.has(instance))
|
|
332
|
+
return;
|
|
333
|
+
startedInstances.add(instance);
|
|
334
|
+
await this.publishSnapshot(name);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Record what a resource observed and republish. Validated against the kind's
|
|
338
|
+
* `status:` here, at the point the claim is made, so an invalid report names
|
|
339
|
+
* the call that made it rather than surfacing at some later publication.
|
|
340
|
+
*
|
|
341
|
+
* Replaces rather than merges: this is the resource's observed state now. A
|
|
342
|
+
* declared field this call omits reads as missing, which is the truth — a
|
|
343
|
+
* sometimes-absent field is declared nullable and reported as `null`.
|
|
344
|
+
*/
|
|
345
|
+
async setResourceStatus(name, status) {
|
|
346
|
+
const entry = this.resourceInstances.get(name) ?? this.createdInstances.get(name);
|
|
347
|
+
if (!entry)
|
|
348
|
+
return;
|
|
349
|
+
const kind = entry.resource.kind;
|
|
350
|
+
if (!startedInstances.has(entry.instance)) {
|
|
351
|
+
throw new RuntimeError("ERR_OBSERVED_STATE_BEFORE_START", `${kind} '${name}' reported observed state before it started. init() performs no I/O, so there is nothing observed to report there — call setStatus() from run(), or from a handler it reaches.`);
|
|
352
|
+
}
|
|
353
|
+
reportedStatus.set(entry.instance, acceptReportedStatus(status, { kind, name, statusSchema: this.statusSchemaOf(kind) }));
|
|
354
|
+
await this.publishSnapshot(name);
|
|
355
|
+
}
|
|
356
|
+
/** The kind's effective `status:` — already folded through `extends` and
|
|
357
|
+
* stamped onto the definition at registration, in the scope that DECLARED it
|
|
358
|
+
* (`resource-definition-controller`). Only the kind's own alias is resolved
|
|
359
|
+
* here, in the reading module's scope, which is where it was written. */
|
|
360
|
+
statusSchemaOf(kind) {
|
|
361
|
+
const def = this.getDefinition?.(this.resolveKindSafe(kind)) ?? this.getDefinition?.(kind);
|
|
362
|
+
return def?.status;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Re-read a resource's `snapshot()` and republish it, joined with whatever
|
|
366
|
+
* observed state the resource has reported. The single publication path — the
|
|
367
|
+
* post-init capture, the post-run publication, the post-invoke refresh and
|
|
368
|
+
* every `setStatus()` all land here.
|
|
369
|
+
*/
|
|
370
|
+
async publishSnapshot(name) {
|
|
371
|
+
const entry = this.resourceInstances.get(name) ?? this.createdInstances.get(name);
|
|
372
|
+
if (!entry?.instance.snapshot)
|
|
373
|
+
return;
|
|
374
|
+
const snap = (await Promise.resolve(entry.instance.snapshot()));
|
|
375
|
+
const kind = entry.resource.kind;
|
|
376
|
+
this.onResourceSnapshotted(name, buildPublishedProps(snap, {
|
|
377
|
+
kind,
|
|
378
|
+
name,
|
|
379
|
+
module: entry.resource.metadata?.module,
|
|
380
|
+
statusSchema: this.statusSchemaOf(kind),
|
|
381
|
+
status: reportedStatus.get(entry.instance),
|
|
382
|
+
started: startedInstances.has(entry.instance),
|
|
383
|
+
completed: completedInstances.has(entry.instance),
|
|
384
|
+
}));
|
|
385
|
+
}
|
|
261
386
|
get context() {
|
|
262
387
|
return this._context;
|
|
263
388
|
}
|
|
@@ -332,6 +457,7 @@ export class EvaluationContext {
|
|
|
332
457
|
spawnChildContext() {
|
|
333
458
|
const child = new EvaluationContext(this.source, this.context, this._createInstance, this._secretValues, this.emit);
|
|
334
459
|
child.resolveImportedInstance = (alias, name) => this.resolveImportedInstance(alias, name);
|
|
460
|
+
child.kindResolver = (kind) => this.resolveKindSafe(kind);
|
|
335
461
|
return this.spawnChild(child);
|
|
336
462
|
}
|
|
337
463
|
/**
|
|
@@ -431,10 +557,13 @@ export class EvaluationContext {
|
|
|
431
557
|
}
|
|
432
558
|
if (instance.init)
|
|
433
559
|
await instance.init(ctx);
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
560
|
+
// Publish BEFORE registering: publication can fail (a kind returning
|
|
561
|
+
// the reserved `status` key without declaring it, a report that does
|
|
562
|
+
// not match `status:`), and a resource that failed must not be left
|
|
563
|
+
// reachable through `getInstance` / Phase 5 injection / teardown.
|
|
564
|
+
// `publishSnapshot` looks the instance up in `createdInstances` too,
|
|
565
|
+
// so it resolves fine from here.
|
|
566
|
+
await this.publishSnapshot(name);
|
|
438
567
|
this.resourceInstances.set(name, { resource, instance });
|
|
439
568
|
this.createdInstances.delete(name);
|
|
440
569
|
errors.delete(name);
|
|
@@ -521,6 +650,17 @@ export class EvaluationContext {
|
|
|
521
650
|
return {
|
|
522
651
|
async run(fn) {
|
|
523
652
|
const child = parent.spawnChild(new EvaluationContext(parent.source, parent._context, parent._createInstance, parent._secretValues, parent.emit));
|
|
653
|
+
child.kindResolver = (kind) => parent.resolveKindSafe(kind);
|
|
654
|
+
// Per-run map of the scope's OWN resources. Fresh per run, so two
|
|
655
|
+
// concurrent runs of the same sequence never observe each other's.
|
|
656
|
+
// The enclosing module's map is layered in at read time, not copied
|
|
657
|
+
// here: `setResource` replaces `_resources` wholesale on every publish,
|
|
658
|
+
// so a snapshot taken at scope entry would go stale the moment an outer
|
|
659
|
+
// resource republished (a post-invoke refresh, a later boot target).
|
|
660
|
+
const scopeLocal = new Map();
|
|
661
|
+
child.snapshotSink = (name, snap) => {
|
|
662
|
+
scopeLocal.set(name, snap);
|
|
663
|
+
};
|
|
524
664
|
// Propagate injection hook: extend getInstance to also resolve parent singleton instances.
|
|
525
665
|
if (parent.preInitHook) {
|
|
526
666
|
const parentHook = parent.preInitHook;
|
|
@@ -557,6 +697,23 @@ export class EvaluationContext {
|
|
|
557
697
|
return parentEntry.instance;
|
|
558
698
|
throw new RuntimeError("ERR_SCOPE_RESOURCE_NOT_FOUND", `Resource '${name}' not found in scope or outer context. Available scoped: ${[...child.resourceInstances.keys()].join(", ")}`);
|
|
559
699
|
},
|
|
700
|
+
async run(name) {
|
|
701
|
+
// Through the child context's chokepoint, so a scope target is
|
|
702
|
+
// traced, records that it started, and publishes its snapshot —
|
|
703
|
+
// exactly like a boot target. A scope target is always a
|
|
704
|
+
// with-resource, so it lives in the child.
|
|
705
|
+
await child.run(name);
|
|
706
|
+
},
|
|
707
|
+
get resources() {
|
|
708
|
+
// Merged on read so the outer half stays live; scope-local names
|
|
709
|
+
// win, matching `getInstance`'s order so CEL and `!ref` agree.
|
|
710
|
+
const merged = {
|
|
711
|
+
...(parent._context.resources ?? {}),
|
|
712
|
+
};
|
|
713
|
+
for (const [name, snap] of scopeLocal)
|
|
714
|
+
merged[name] = snap;
|
|
715
|
+
return merged;
|
|
716
|
+
},
|
|
560
717
|
};
|
|
561
718
|
return await fn(scope);
|
|
562
719
|
}
|
|
@@ -589,6 +746,13 @@ export class EvaluationContext {
|
|
|
589
746
|
}
|
|
590
747
|
for (const [key, { resource, instance }] of this.teardownOrder()) {
|
|
591
748
|
const label = `${resource.kind}.${resource.metadata.name}`;
|
|
749
|
+
// A reading belongs to the run that produced it. The WeakMap would drop it
|
|
750
|
+
// with the instance anyway; clearing here also covers an instance something
|
|
751
|
+
// else still holds, so a torn-down resource can never keep publishing what
|
|
752
|
+
// it observed in a previous life.
|
|
753
|
+
reportedStatus.delete(instance);
|
|
754
|
+
startedInstances.delete(instance);
|
|
755
|
+
completedInstances.delete(instance);
|
|
592
756
|
try {
|
|
593
757
|
if (instance.teardown)
|
|
594
758
|
await instance.teardown();
|
|
@@ -770,12 +934,19 @@ export class EvaluationContext {
|
|
|
770
934
|
// `run()` — side effects only, no outputs. Prefer `invoke()` when both
|
|
771
935
|
// exist so a dual-capability instance (e.g. Run.Sequence) keeps invoke
|
|
772
936
|
// semantics and returns its `steps`/`outputs`.
|
|
937
|
+
// A pure Runnable reached through an `invoke:` slot runs exactly as it
|
|
938
|
+
// would from a `targets:` list, so it starts here too — its observed state
|
|
939
|
+
// must not stay withheld just because the dispatch slot was a different one.
|
|
940
|
+
if (typeof instance.invoke !== "function")
|
|
941
|
+
await this.markStarted(name, instance);
|
|
773
942
|
const call = () => typeof instance.invoke === "function"
|
|
774
943
|
? instance.invoke(inputs, invokeCtx)
|
|
775
944
|
: instance.run(invokeCtx);
|
|
776
945
|
const outputs = await (invokeCtx === ambient
|
|
777
946
|
? call()
|
|
778
947
|
: cancellationStore.run(invokeCtx, call));
|
|
948
|
+
if (typeof instance.invoke !== "function")
|
|
949
|
+
completedInstances.add(instance);
|
|
779
950
|
await this.emit(`${name}.Invoked`, span("end", "ok", { inputs, outputs }));
|
|
780
951
|
return outputs;
|
|
781
952
|
}
|
|
@@ -833,7 +1004,7 @@ export class EvaluationContext {
|
|
|
833
1004
|
* kind unchanged. A typed seam (overridden in `ModuleContext`), matching the
|
|
834
1005
|
* `traceRootScope()` pattern, rather than reaching across the boundary. */
|
|
835
1006
|
resolveKindSafe(kind) {
|
|
836
|
-
return kind;
|
|
1007
|
+
return this.kindResolver?.(kind) ?? kind;
|
|
837
1008
|
}
|
|
838
1009
|
capabilityOf(kind) {
|
|
839
1010
|
const resolved = this.resolveKindSafe(kind);
|
|
@@ -953,6 +1124,11 @@ export class EvaluationContext {
|
|
|
953
1124
|
}
|
|
954
1125
|
if (tracing)
|
|
955
1126
|
await this.emit(`${name}.Running`, span("start", undefined, {}));
|
|
1127
|
+
// Marked before the call, not after: a Service's `run()` stays pending for
|
|
1128
|
+
// the process lifetime, and reporting what it discovered while listening is
|
|
1129
|
+
// the whole point — `ctx.setStatus()` is an error until the resource counts
|
|
1130
|
+
// as started, so this has to happen first.
|
|
1131
|
+
await this.markStarted(name, instance);
|
|
956
1132
|
try {
|
|
957
1133
|
// Runnable: run inside the ALS scope so nested invokes inherit the token and
|
|
958
1134
|
// trace id (skip the redundant `run` when the token is already ambient).
|
|
@@ -960,6 +1136,10 @@ export class EvaluationContext {
|
|
|
960
1136
|
// its long-lived async work does not capture this scope.
|
|
961
1137
|
const call = () => instance.run(invokeCtx);
|
|
962
1138
|
await (isService || invokeCtx === ambient ? call() : cancellationStore.run(invokeCtx, call));
|
|
1139
|
+
// A one-shot Runnable that discovered something during run() publishes it
|
|
1140
|
+
// without an explicit call; a Service never reaches this until teardown.
|
|
1141
|
+
completedInstances.add(instance);
|
|
1142
|
+
await this.publishSnapshot(name);
|
|
963
1143
|
await this.emit(`${name}.Run`, span("end", "ok", {}));
|
|
964
1144
|
}
|
|
965
1145
|
catch (err) {
|
|
@@ -1160,6 +1340,27 @@ function tokenizeAccessPath(source) {
|
|
|
1160
1340
|
* against the activation — callers fall back to the original error text.
|
|
1161
1341
|
*/
|
|
1162
1342
|
export function describeFailedAccess(source, ctx, msg) {
|
|
1343
|
+
const failure = locateFailedAccess(source, ctx, msg);
|
|
1344
|
+
if (!failure)
|
|
1345
|
+
return null;
|
|
1346
|
+
return `at ${failure.walked}: ${describeMissingAccess(failure.container, failure.missingKey)}`;
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* The observed-state message for a failed access, or null when the failure has
|
|
1350
|
+
* nothing to do with observed state (the caller then falls back to the generic
|
|
1351
|
+
* enrichment above). See `observed-state.ts` for why "has not started" and
|
|
1352
|
+
* "started but reported nothing" are two different messages.
|
|
1353
|
+
*/
|
|
1354
|
+
export function describeObservedStateFailure(source, ctx, msg) {
|
|
1355
|
+
const failure = locateFailedAccess(source, ctx, msg);
|
|
1356
|
+
if (!failure)
|
|
1357
|
+
return null;
|
|
1358
|
+
return diagnoseObservedStateAccess(failure.container, failure.missingKey);
|
|
1359
|
+
}
|
|
1360
|
+
/** Walk a dotted CEL access path against the activation and stop at the node
|
|
1361
|
+
* whose key was missing. Null when the error isn't a key-access failure, the
|
|
1362
|
+
* source isn't a plain access path, or the path doesn't match the activation. */
|
|
1363
|
+
function locateFailedAccess(source, ctx, msg) {
|
|
1163
1364
|
const m = /^No such key:\s*(\S+)/.exec(msg);
|
|
1164
1365
|
if (!m)
|
|
1165
1366
|
return null;
|
|
@@ -1186,7 +1387,7 @@ export function describeFailedAccess(source, ctx, msg) {
|
|
|
1186
1387
|
!(tok.name in current)) {
|
|
1187
1388
|
if (tok.name !== missingKey)
|
|
1188
1389
|
return null;
|
|
1189
|
-
return
|
|
1390
|
+
return { container: current, missingKey, walked: walked.join("") };
|
|
1190
1391
|
}
|
|
1191
1392
|
current = current[tok.name];
|
|
1192
1393
|
walked.push("." + tok.name);
|