@telorun/kernel 0.82.1 → 0.83.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 +237 -12
- package/dist/controllers/module/import-controller.js.map +1 -1
- package/dist/controllers/module/shared-libraries.d.ts +83 -0
- package/dist/controllers/module/shared-libraries.d.ts.map +1 -0
- package/dist/controllers/module/shared-libraries.js +110 -0
- package/dist/controllers/module/shared-libraries.js.map +1 -0
- package/dist/controllers/resource-definition/resource-template-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/resource-template-controller.js +104 -30
- package/dist/controllers/resource-definition/resource-template-controller.js.map +1 -1
- package/dist/evaluation-context.d.ts +60 -0
- package/dist/evaluation-context.d.ts.map +1 -1
- package/dist/evaluation-context.js +125 -2
- package/dist/evaluation-context.js.map +1 -1
- package/dist/module-context.d.ts +5 -0
- package/dist/module-context.d.ts.map +1 -1
- package/dist/module-context.js +5 -0
- package/dist/module-context.js.map +1 -1
- package/package.json +4 -4
- package/src/controllers/module/import-controller.ts +324 -13
- package/src/controllers/module/shared-libraries.ts +180 -0
- package/src/controllers/resource-definition/resource-template-controller.ts +129 -29
- package/src/evaluation-context.ts +136 -2
- package/src/module-context.ts +6 -0
|
@@ -1,24 +1,50 @@
|
|
|
1
|
+
import { celEvalSites, effectiveAuthorSchema, evalPathCovers, mergeCelEvalSites, NO_CEL_EVAL_SITES, pathMatchesScope, } from "@telorun/analyzer";
|
|
1
2
|
import { isCompiledValue } from "@telorun/sdk";
|
|
2
3
|
import { isRefSentinel } from "@telorun/templating";
|
|
3
4
|
import { celSelfView } from "../../evaluation-context.js";
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
/**
|
|
6
|
+
* WHICH NODES OF A TEMPLATE BODY SURVIVE init() UNEXPANDED.
|
|
7
|
+
*
|
|
8
|
+
* A `resources:` entry is a DECLARATION of another kind, and that kind decides
|
|
9
|
+
* when each of its fields is evaluated: an `x-telo-eval: runtime` field, or any
|
|
10
|
+
* field under a CEL-bearing region (an `x-telo-context`, an error branch, a step
|
|
11
|
+
* body), is evaluated by the child's OWN controller against a scope only it can
|
|
12
|
+
* build. Those nodes must reach the child compiled.
|
|
13
|
+
*
|
|
14
|
+
* Read off the nested kind's schema through the containment matcher both halves
|
|
15
|
+
* already share (`celEvalSites` / `evalPathCovers`), never off a list of
|
|
16
|
+
* variable names. The name list — `request`, `result`, `steps`, `error` — was
|
|
17
|
+
* the reason a body could not read the call's own arguments (`inputs`) or an
|
|
18
|
+
* iteration's element (`item`): those two names were simply absent from it, so
|
|
19
|
+
* such a node was expanded at init() against a scope where they do not exist and
|
|
20
|
+
* failed with `Unknown variable: inputs`. A list has to be extended for every
|
|
21
|
+
* name any kind ever binds; the annotations already say where evaluation
|
|
22
|
+
* happens.
|
|
23
|
+
*/
|
|
24
|
+
/** True when a node at `path` inside a body is evaluated by the child's own
|
|
25
|
+
* controller rather than at the template's init(). `runtime` paths are
|
|
26
|
+
* property-only and match by containment; a region scope is a JSONPath
|
|
27
|
+
* (`$.routes[*].returns`) whose wildcards a plain prefix test cannot resolve. */
|
|
28
|
+
function isDeferredPath(sites, path) {
|
|
29
|
+
return (sites.runtime.some((p) => evalPathCovers(p, path)) ||
|
|
30
|
+
sites.regions.some((scope) => pathMatchesScope(path, scope)));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* True when an expression reads anything other than `self`. A deferred node that
|
|
34
|
+
* names only `self` is still resolved at `init()`: `self` is fixed for the life
|
|
35
|
+
* of the instance, so expanding it there costs nothing and keeps a `self`-built
|
|
36
|
+
* literal (a SQL string, a route path) a literal.
|
|
37
|
+
*
|
|
38
|
+
* Read off the AST-derived roots the compile step stamps, never off the source
|
|
39
|
+
* text. A regex over the source both over- and under-matches — it fires on a
|
|
40
|
+
* word inside a string literal and misses a bare `${{ item }}` with no member
|
|
41
|
+
* access — and there is nothing to fall back FOR: every built-in engine carries
|
|
42
|
+
* `refs` through. An engine that surfaces none is treated as reading nothing but
|
|
43
|
+
* `self`, which resolves it at `init()` and fails loudly there rather than
|
|
44
|
+
* silently deferring a node the child cannot evaluate.
|
|
45
|
+
*/
|
|
46
|
+
function referencesBeyondSelf(value) {
|
|
47
|
+
return (value.refs ?? []).some((r) => r !== "self");
|
|
22
48
|
}
|
|
23
49
|
/** Matches a CEL source that is exactly a `self.<path>` member access (capturing
|
|
24
50
|
* the `.<path>` tail) — the form resolved by direct navigation rather than CEL. */
|
|
@@ -54,6 +80,14 @@ export function createTemplateController(definition, definingContext) {
|
|
|
54
80
|
const targetName = (field) => {
|
|
55
81
|
if (field == null)
|
|
56
82
|
return null;
|
|
83
|
+
// `invoke: !ref body` names a sibling `resources:` entry — the same
|
|
84
|
+
// spelling every other reference uses. Phase 2.5 does not descend into a
|
|
85
|
+
// `Telo.Definition`, so the sentinel arrives raw; `Self.` is the
|
|
86
|
+
// explicit self-qualifier and names the same local entry.
|
|
87
|
+
if (isRefSentinel(field)) {
|
|
88
|
+
const source = field.source;
|
|
89
|
+
return source.startsWith("Self.") ? source.slice("Self.".length) : source;
|
|
90
|
+
}
|
|
57
91
|
const nameTemplate = typeof field === "object" && !isCompiledValue(field) ? field.name : field;
|
|
58
92
|
return nameTemplate
|
|
59
93
|
? definingContext.expandWith(nameTemplate, { self: getSelf() })
|
|
@@ -110,16 +144,16 @@ export function createTemplateController(definition, definingContext) {
|
|
|
110
144
|
}
|
|
111
145
|
}
|
|
112
146
|
// Expand a persistent child's body against `self`. Self-only CEL resolves
|
|
113
|
-
// to literals now;
|
|
114
|
-
// through compiled for the child's own controller. `!ref` sentinels are
|
|
147
|
+
// to literals now; a node the NESTED KIND evaluates later (see
|
|
148
|
+
// `deferredPaths`) passes through compiled for the child's own controller. `!ref` sentinels are
|
|
115
149
|
// rewritten to the `{kind, name, alias?}` injection shape here — Phase 2.5
|
|
116
150
|
// (`resolveRefSentinels`) does not descend into template bodies, so the
|
|
117
151
|
// child context's Phase 5 injection would otherwise see an unrecognized
|
|
118
152
|
// sentinel and leave the slot unresolved. Kind is left empty: injection
|
|
119
153
|
// dispatches by name and recovers the kind from the resolved instance.
|
|
120
|
-
const expandSelf = (value) => {
|
|
154
|
+
const expandSelf = (value, path, deferred) => {
|
|
121
155
|
if (isCompiledValue(value)) {
|
|
122
|
-
if (
|
|
156
|
+
if (isDeferredPath(deferred, path) && referencesBeyondSelf(value))
|
|
123
157
|
return value;
|
|
124
158
|
// A pure `self.<path>` access (e.g. a `connection: !ref` passed down) is
|
|
125
159
|
// resolved by navigating the resource directly. Going through CEL would
|
|
@@ -128,10 +162,10 @@ export function createTemplateController(definition, definingContext) {
|
|
|
128
162
|
// a consumer wired in could never reach a child's slot. Complex self
|
|
129
163
|
// expressions (string building) still evaluate via CEL, where they yield
|
|
130
164
|
// CEL-safe scalars.
|
|
131
|
-
const
|
|
132
|
-
if (
|
|
165
|
+
const selfPath = typeof value.source === "string" ? value.source.trim().match(SELF_PATH) : null;
|
|
166
|
+
if (selfPath) {
|
|
133
167
|
let cur = getSelf();
|
|
134
|
-
for (const key of
|
|
168
|
+
for (const key of selfPath[1].split(".").slice(1))
|
|
135
169
|
cur = cur?.[key];
|
|
136
170
|
return cur;
|
|
137
171
|
}
|
|
@@ -154,22 +188,55 @@ export function createTemplateController(definition, definingContext) {
|
|
|
154
188
|
const name = alias === "Self" ? source.slice(dot + 1) : source;
|
|
155
189
|
return { kind: siblingKinds.get(name) ?? "", name };
|
|
156
190
|
}
|
|
157
|
-
if (Array.isArray(value))
|
|
158
|
-
return value.map(expandSelf);
|
|
191
|
+
if (Array.isArray(value)) {
|
|
192
|
+
return value.map((item, i) => expandSelf(item, `${path}[${i}]`, deferred));
|
|
193
|
+
}
|
|
159
194
|
if (value !== null && typeof value === "object") {
|
|
160
195
|
const out = {};
|
|
161
|
-
for (const [k, v] of Object.entries(value))
|
|
162
|
-
out[k] = expandSelf(v);
|
|
196
|
+
for (const [k, v] of Object.entries(value)) {
|
|
197
|
+
out[k] = expandSelf(v, path ? `${path}.${k}` : k, deferred);
|
|
198
|
+
}
|
|
163
199
|
return out;
|
|
164
200
|
}
|
|
165
201
|
return value;
|
|
166
202
|
};
|
|
203
|
+
/**
|
|
204
|
+
* The nested kind's own CEL evaluation sites, resolved once per body. The
|
|
205
|
+
* kind is written in the DEFINING library's alias scope, so it is
|
|
206
|
+
* resolved there — the consumer has never heard of the alias.
|
|
207
|
+
*
|
|
208
|
+
* The INHERITANCE-RESOLVED schema, merged with the capability abstract's,
|
|
209
|
+
* exactly as the analyzer half reads it (`effectiveSchemaOf` in
|
|
210
|
+
* `cel-scope.ts`). A nested kind that inherits a CEL region from an
|
|
211
|
+
* `extends` parent — or gets one implicitly from `Telo.Provider` — would
|
|
212
|
+
* otherwise be covered on the static side and not here, which is the two
|
|
213
|
+
* halves disagreeing about when a node is evaluated.
|
|
214
|
+
*/
|
|
215
|
+
const deferredPathsFor = (kind) => {
|
|
216
|
+
if (typeof kind !== "string")
|
|
217
|
+
return NO_CEL_EVAL_SITES;
|
|
218
|
+
const cached = deferredByKind.get(kind);
|
|
219
|
+
if (cached)
|
|
220
|
+
return cached;
|
|
221
|
+
const resolveDef = (k) => definingContext.getDefinition?.(definingContext.kindResolver?.(k) ?? k) ??
|
|
222
|
+
definingContext.getDefinition?.(k);
|
|
223
|
+
const def = resolveDef(kind);
|
|
224
|
+
const capability = def?.capability;
|
|
225
|
+
const sites = def
|
|
226
|
+
? mergeCelEvalSites(celEvalSites(effectiveAuthorSchema(def, resolveDef)), celEvalSites((capability ? resolveDef(capability)?.schema : undefined)))
|
|
227
|
+
: NO_CEL_EVAL_SITES;
|
|
228
|
+
deferredByKind.set(kind, sites);
|
|
229
|
+
return sites;
|
|
230
|
+
};
|
|
167
231
|
// init() may run more than once: when a child's local ref names a sibling
|
|
168
232
|
// not yet initialized, child init defers with ERR_LOCAL_REF_PENDING and the
|
|
169
233
|
// outer multi-pass loop retries this resource. Registration must happen
|
|
170
234
|
// once; each retry only resumes the child init loop (already-initialized
|
|
171
235
|
// children are skipped, still-pending ones advance).
|
|
172
236
|
let registered = false;
|
|
237
|
+
/** Memo per nested kind — a body is expanded once, but a template kind is
|
|
238
|
+
* instantiated many times across an application. */
|
|
239
|
+
const deferredByKind = new Map();
|
|
173
240
|
return {
|
|
174
241
|
// The template's own resources are its allocation, and tearing the child
|
|
175
242
|
// context down is the inverse. `init()` still resumes rather than
|
|
@@ -177,8 +244,15 @@ export function createTemplateController(definition, definingContext) {
|
|
|
177
244
|
// not initialized) keeps the instance: only a real failure discards it.
|
|
178
245
|
init: (templateCtx) => templateCtx.effect("template resources", async () => {
|
|
179
246
|
if (!registered) {
|
|
247
|
+
// `self` is in scope for the whole body, not only for what init()
|
|
248
|
+
// resolves: a node the nested kind evaluates later (a step's
|
|
249
|
+
// `inputs`, a route's `returns`) may read `self` beside the
|
|
250
|
+
// call-time names its own controller binds. Bound as the
|
|
251
|
+
// published-reading view, so `self.<ref>.<field>` answers exactly
|
|
252
|
+
// as `resources.<name>.<field>` does.
|
|
253
|
+
childContext.bindContextValue?.("self", celSelfView(getSelf()));
|
|
180
254
|
for (const template of definition.resources ?? []) {
|
|
181
|
-
childContext.registerManifest(expandSelf(template));
|
|
255
|
+
childContext.registerManifest(expandSelf(template, "", deferredPathsFor(template?.kind)));
|
|
182
256
|
}
|
|
183
257
|
registered = true;
|
|
184
258
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-template-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-template-controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAA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,GAAQ,EAAE,MAAe,EAAE,EAAE;wBACtC,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;wBAClD,MAAM,SAAS,GAAG,KAAK,CAAC,QAAiE,CAAC;wBAC1F,IAAI,OAAO,SAAS,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;4BAC7C,MAAM,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;wBACnE,CAAC;wBACD,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;oBACzC,CAAC;iBACF,CAAC;aAEH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"resource-template-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-template-controller.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAA2B,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;;;;;;;;;;;;;;;;;GAkBG;AACH;;;kFAGkF;AAClF,SAAS,cAAc,CAAC,KAAmB,EAAE,IAAY;IACvD,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAClD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAC7D,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAS,oBAAoB,CAAC,KA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ACF,CAAC;gBAEF,GAAG,CAAC,WAAW,IAAI;oBACjB,iEAAiE;oBACjE,qEAAqE;oBACrE,uDAAuD;oBACvD,QAAQ,EAAE,CAAC,GAAQ,EAAE,MAAe,EAAE,EAAE;wBACtC,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;wBAClD,MAAM,SAAS,GAAG,KAAK,CAAC,QAAiE,CAAC;wBAC1F,IAAI,OAAO,SAAS,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;4BAC7C,MAAM,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;wBACnE,CAAC;wBACD,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;oBACzC,CAAC;iBACF,CAAC;aAEH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -43,6 +43,9 @@ export declare class EvaluationContext implements IEvaluationContext {
|
|
|
43
43
|
/** Position in the lifecycle tree. */
|
|
44
44
|
parent: IEvaluationContext | undefined;
|
|
45
45
|
readonly children: IEvaluationContext[];
|
|
46
|
+
/** Where this node sits in its parent's teardown cascade — ascending, default
|
|
47
|
+
* 0, reverse-registration within a tier. See `childTeardownOrder`. */
|
|
48
|
+
teardownPriority: number | undefined;
|
|
46
49
|
/** Current lifecycle state of this context node. */
|
|
47
50
|
state: LifecycleState;
|
|
48
51
|
/** Resource instances owned by this context node, keyed by resourceKey(). */
|
|
@@ -71,6 +74,38 @@ export declare class EvaluationContext implements IEvaluationContext {
|
|
|
71
74
|
/** Resources discarded after a failed `init()` and re-queued for creation.
|
|
72
75
|
* Their re-creation is not progress — see the create sub-phase. */
|
|
73
76
|
private readonly recreatedResources;
|
|
77
|
+
/**
|
|
78
|
+
* Instances this context can reach by name but does NOT own — a library's
|
|
79
|
+
* declared `resources:` inputs, bound here by the import that handed them
|
|
80
|
+
* down.
|
|
81
|
+
*
|
|
82
|
+
* **Borrowed, not owned.** The instance's effect frame belongs to the scope
|
|
83
|
+
* that DECLARED it, so this context must never include it in its own
|
|
84
|
+
* teardown: a library tearing one down would close the application's
|
|
85
|
+
* connection out from under everything else still using it.
|
|
86
|
+
*/
|
|
87
|
+
protected readonly borrowedResources: Set<string>;
|
|
88
|
+
/**
|
|
89
|
+
* Bind an instance this context does not own under `name`, and mirror its
|
|
90
|
+
* published reading into this context's `resources` scope so
|
|
91
|
+
* `resources.<name>.<field>` reads here exactly as it does where the resource
|
|
92
|
+
* is declared.
|
|
93
|
+
*
|
|
94
|
+
* The mirror is a subscription rather than a copy because a published value is
|
|
95
|
+
* a READING: the owner republishes after `run()`, after every `invoke()` and
|
|
96
|
+
* on every `setStatus()`, and a snapshot taken once at binding would go stale
|
|
97
|
+
* at the first of those — silently, since nothing downstream can tell a stale
|
|
98
|
+
* reading from a current one.
|
|
99
|
+
*/
|
|
100
|
+
adoptBorrowedResource(name: string, resource: ResourceManifest, instance: ResourceInstance, owner: EvaluationContext): void | (() => void);
|
|
101
|
+
/** Publication mirrors registered by {@link adoptBorrowedResource}, by the
|
|
102
|
+
* OWNER's name for the resource. */
|
|
103
|
+
private readonly publicationMirrors;
|
|
104
|
+
/** Register a mirror and replay the current reading, so a borrower that binds
|
|
105
|
+
* after the owner has already published does not wait for the next one.
|
|
106
|
+
* Returns the unsubscribe — a subscription with no way to end it outlives
|
|
107
|
+
* whatever registered it. */
|
|
108
|
+
mirrorPublications(name: string, sink: (props: Record<string, unknown>) => void): () => void;
|
|
74
109
|
/** Resources queued for initialization on this context node. */
|
|
75
110
|
private pendingResources;
|
|
76
111
|
/**
|
|
@@ -204,6 +239,18 @@ export declare class EvaluationContext implements IEvaluationContext {
|
|
|
204
239
|
*/
|
|
205
240
|
detachChild(child: IEvaluationContext): void;
|
|
206
241
|
spawnChild<T extends IEvaluationContext>(child: T): T;
|
|
242
|
+
/**
|
|
243
|
+
* Bind a name into this context's own CEL scope.
|
|
244
|
+
*
|
|
245
|
+
* A copy is written rather than a mutation: `spawnChildContext` hands the
|
|
246
|
+
* child the PARENT's context object by reference, so mutating it in place
|
|
247
|
+
* would put the binding in the parent's scope as well.
|
|
248
|
+
*
|
|
249
|
+
* Used by a template to put `self` in scope for the body it creates, so a node
|
|
250
|
+
* the nested kind evaluates later can read the enclosing resource's
|
|
251
|
+
* configuration beside the call-time names that kind binds.
|
|
252
|
+
*/
|
|
253
|
+
bindContextValue(name: string, value: unknown): void;
|
|
207
254
|
/** Spawn a fresh child context attached to this node — the isolated scope a
|
|
208
255
|
* templated definition registers its `resources:` into. Rooting it on the
|
|
209
256
|
* context that DEFINED the template (not the consumer that instantiated the
|
|
@@ -257,6 +304,19 @@ export declare class EvaluationContext implements IEvaluationContext {
|
|
|
257
304
|
* emitting a Teardown event for each via the injected emit callback.
|
|
258
305
|
*/
|
|
259
306
|
teardownResources(): Promise<void>;
|
|
307
|
+
/**
|
|
308
|
+
* Child contexts in teardown order: ascending `teardownPriority` (default 0),
|
|
309
|
+
* with the base reverse-registration order preserved within each tier.
|
|
310
|
+
*
|
|
311
|
+
* The same rule `teardownOrder` applies to resource instances, and for the
|
|
312
|
+
* same reason: reverse registration is reverse init order in the happy path,
|
|
313
|
+
* but a node that must reliably outlive the rest has to say so rather than
|
|
314
|
+
* depend on when it happened to be created. A `lifecycle: shared` library is
|
|
315
|
+
* registered when the FIRST import reaches it — which, for an import declared
|
|
316
|
+
* inside another library, is after that library's own context — so reverse
|
|
317
|
+
* registration would tear the singleton down while a borrower still holds it.
|
|
318
|
+
*/
|
|
319
|
+
private childTeardownOrder;
|
|
260
320
|
/**
|
|
261
321
|
* Resource instances in teardown order: ascending `teardownPriority`, with the
|
|
262
322
|
* base reverse-insertion order preserved within each priority tier.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluation-context.d.ts","sourceRoot":"","sources":["../src/evaluation-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,WAAW,EAEX,KAAK,iBAAiB,IAA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41
|
function collectResourceRefs(resource) {
|
|
42
42
|
const found = new Map();
|
|
43
43
|
const skipSchema = SCHEMA_AS_CONTRACT_KINDS.has(resource.kind);
|
|
44
|
+
// A re-created resource is rebuilt from the manifest as REGISTERED, but
|
|
45
|
+
// Phase-5 injection mutated that object in place on the previous pass — so a
|
|
46
|
+
// ref slot may already hold a live instance, whose object graph is cyclic.
|
|
47
|
+
// The walk is a best-effort edge collection for failure attribution, so it
|
|
48
|
+
// stops at anything it has already seen rather than recursing forever.
|
|
49
|
+
const seen = new WeakSet();
|
|
44
50
|
const visit = (value) => {
|
|
45
51
|
if (isResolvedRef(value)) {
|
|
46
52
|
const key = `${value.alias ?? ""}::${value.name}`;
|
|
@@ -49,10 +55,16 @@ function collectResourceRefs(resource) {
|
|
|
49
55
|
return;
|
|
50
56
|
}
|
|
51
57
|
if (Array.isArray(value)) {
|
|
58
|
+
if (seen.has(value))
|
|
59
|
+
return;
|
|
60
|
+
seen.add(value);
|
|
52
61
|
for (const item of value)
|
|
53
62
|
visit(item);
|
|
54
63
|
}
|
|
55
64
|
else if (value && typeof value === "object") {
|
|
65
|
+
if (seen.has(value))
|
|
66
|
+
return;
|
|
67
|
+
seen.add(value);
|
|
56
68
|
for (const [k, v] of Object.entries(value)) {
|
|
57
69
|
if (k === "metadata" || (skipSchema && k === "schema"))
|
|
58
70
|
continue;
|
|
@@ -395,6 +407,9 @@ export class EvaluationContext {
|
|
|
395
407
|
/** Position in the lifecycle tree. */
|
|
396
408
|
parent = undefined;
|
|
397
409
|
children = [];
|
|
410
|
+
/** Where this node sits in its parent's teardown cascade — ascending, default
|
|
411
|
+
* 0, reverse-registration within a tier. See `childTeardownOrder`. */
|
|
412
|
+
teardownPriority = undefined;
|
|
398
413
|
/** Current lifecycle state of this context node. */
|
|
399
414
|
state = "Pending";
|
|
400
415
|
/** Resource instances owned by this context node, keyed by resourceKey(). */
|
|
@@ -415,6 +430,76 @@ export class EvaluationContext {
|
|
|
415
430
|
/** Resources discarded after a failed `init()` and re-queued for creation.
|
|
416
431
|
* Their re-creation is not progress — see the create sub-phase. */
|
|
417
432
|
recreatedResources = new Set();
|
|
433
|
+
/**
|
|
434
|
+
* Instances this context can reach by name but does NOT own — a library's
|
|
435
|
+
* declared `resources:` inputs, bound here by the import that handed them
|
|
436
|
+
* down.
|
|
437
|
+
*
|
|
438
|
+
* **Borrowed, not owned.** The instance's effect frame belongs to the scope
|
|
439
|
+
* that DECLARED it, so this context must never include it in its own
|
|
440
|
+
* teardown: a library tearing one down would close the application's
|
|
441
|
+
* connection out from under everything else still using it.
|
|
442
|
+
*/
|
|
443
|
+
borrowedResources = new Set();
|
|
444
|
+
/**
|
|
445
|
+
* Bind an instance this context does not own under `name`, and mirror its
|
|
446
|
+
* published reading into this context's `resources` scope so
|
|
447
|
+
* `resources.<name>.<field>` reads here exactly as it does where the resource
|
|
448
|
+
* is declared.
|
|
449
|
+
*
|
|
450
|
+
* The mirror is a subscription rather than a copy because a published value is
|
|
451
|
+
* a READING: the owner republishes after `run()`, after every `invoke()` and
|
|
452
|
+
* on every `setStatus()`, and a snapshot taken once at binding would go stale
|
|
453
|
+
* at the first of those — silently, since nothing downstream can tell a stale
|
|
454
|
+
* reading from a current one.
|
|
455
|
+
*/
|
|
456
|
+
adoptBorrowedResource(name, resource, instance, owner) {
|
|
457
|
+
this.resourceInstances.set(name, { resource, instance });
|
|
458
|
+
this.borrowedResources.add(name);
|
|
459
|
+
this.declaredManifests.set(name, resource);
|
|
460
|
+
const unmirror = owner.mirrorPublications(resource.metadata.name, (props) => this.onResourceSnapshotted(name, props));
|
|
461
|
+
// The INVERSE, returned rather than performed: an import whose `init()`
|
|
462
|
+
// fails is discarded and re-created on the next pass, so a subscription left
|
|
463
|
+
// behind would be appended again on every pass — unbounded — and would keep
|
|
464
|
+
// a dead child context reachable from the live owner. The binding is not on
|
|
465
|
+
// this context's teardown path either (`teardownOrder` filters a borrowed
|
|
466
|
+
// name out, and that is also the only place an entry is deleted), so
|
|
467
|
+
// undoing it has to be stated here.
|
|
468
|
+
return () => {
|
|
469
|
+
unmirror();
|
|
470
|
+
this.borrowedResources.delete(name);
|
|
471
|
+
this.resourceInstances.delete(name);
|
|
472
|
+
this.declaredManifests.delete(name);
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
/** Publication mirrors registered by {@link adoptBorrowedResource}, by the
|
|
476
|
+
* OWNER's name for the resource. */
|
|
477
|
+
publicationMirrors = new Map();
|
|
478
|
+
/** Register a mirror and replay the current reading, so a borrower that binds
|
|
479
|
+
* after the owner has already published does not wait for the next one.
|
|
480
|
+
* Returns the unsubscribe — a subscription with no way to end it outlives
|
|
481
|
+
* whatever registered it. */
|
|
482
|
+
mirrorPublications(name, sink) {
|
|
483
|
+
const bucket = this.publicationMirrors.get(name);
|
|
484
|
+
if (bucket)
|
|
485
|
+
bucket.push(sink);
|
|
486
|
+
else
|
|
487
|
+
this.publicationMirrors.set(name, [sink]);
|
|
488
|
+
const entry = this.resourceInstances.get(name) ?? this.createdInstances.get(name);
|
|
489
|
+
const current = entry ? publishedByInstance.get(entry.instance) : undefined;
|
|
490
|
+
if (current)
|
|
491
|
+
sink(current);
|
|
492
|
+
return () => {
|
|
493
|
+
const sinks = this.publicationMirrors.get(name);
|
|
494
|
+
if (!sinks)
|
|
495
|
+
return;
|
|
496
|
+
const at = sinks.indexOf(sink);
|
|
497
|
+
if (at >= 0)
|
|
498
|
+
sinks.splice(at, 1);
|
|
499
|
+
if (sinks.length === 0)
|
|
500
|
+
this.publicationMirrors.delete(name);
|
|
501
|
+
};
|
|
502
|
+
}
|
|
418
503
|
/** Resources queued for initialization on this context node. */
|
|
419
504
|
pendingResources = [];
|
|
420
505
|
/**
|
|
@@ -557,6 +642,8 @@ export class EvaluationContext {
|
|
|
557
642
|
});
|
|
558
643
|
publishedByInstance.set(entry.instance, props);
|
|
559
644
|
this.onResourceSnapshotted(name, props);
|
|
645
|
+
for (const sink of this.publicationMirrors.get(name) ?? [])
|
|
646
|
+
sink(props);
|
|
560
647
|
}
|
|
561
648
|
get context() {
|
|
562
649
|
return this._context;
|
|
@@ -665,6 +752,20 @@ export class EvaluationContext {
|
|
|
665
752
|
}
|
|
666
753
|
return child;
|
|
667
754
|
}
|
|
755
|
+
/**
|
|
756
|
+
* Bind a name into this context's own CEL scope.
|
|
757
|
+
*
|
|
758
|
+
* A copy is written rather than a mutation: `spawnChildContext` hands the
|
|
759
|
+
* child the PARENT's context object by reference, so mutating it in place
|
|
760
|
+
* would put the binding in the parent's scope as well.
|
|
761
|
+
*
|
|
762
|
+
* Used by a template to put `self` in scope for the body it creates, so a node
|
|
763
|
+
* the nested kind evaluates later can read the enclosing resource's
|
|
764
|
+
* configuration beside the call-time names that kind binds.
|
|
765
|
+
*/
|
|
766
|
+
bindContextValue(name, value) {
|
|
767
|
+
this._context = { ...this._context, [name]: value };
|
|
768
|
+
}
|
|
668
769
|
/** Spawn a fresh child context attached to this node — the isolated scope a
|
|
669
770
|
* templated definition registers its `resources:` into. Rooting it on the
|
|
670
771
|
* context that DEFINED the template (not the consumer that instantiated the
|
|
@@ -1035,7 +1136,7 @@ export class EvaluationContext {
|
|
|
1035
1136
|
async teardownResources() {
|
|
1036
1137
|
this.state = "Draining";
|
|
1037
1138
|
const failures = [];
|
|
1038
|
-
for (const child of
|
|
1139
|
+
for (const child of this.childTeardownOrder()) {
|
|
1039
1140
|
try {
|
|
1040
1141
|
await child.teardownResources();
|
|
1041
1142
|
}
|
|
@@ -1105,6 +1206,24 @@ export class EvaluationContext {
|
|
|
1105
1206
|
})));
|
|
1106
1207
|
}
|
|
1107
1208
|
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Child contexts in teardown order: ascending `teardownPriority` (default 0),
|
|
1211
|
+
* with the base reverse-registration order preserved within each tier.
|
|
1212
|
+
*
|
|
1213
|
+
* The same rule `teardownOrder` applies to resource instances, and for the
|
|
1214
|
+
* same reason: reverse registration is reverse init order in the happy path,
|
|
1215
|
+
* but a node that must reliably outlive the rest has to say so rather than
|
|
1216
|
+
* depend on when it happened to be created. A `lifecycle: shared` library is
|
|
1217
|
+
* registered when the FIRST import reaches it — which, for an import declared
|
|
1218
|
+
* inside another library, is after that library's own context — so reverse
|
|
1219
|
+
* registration would tear the singleton down while a borrower still holds it.
|
|
1220
|
+
*/
|
|
1221
|
+
childTeardownOrder() {
|
|
1222
|
+
return [...this.children]
|
|
1223
|
+
.reverse()
|
|
1224
|
+
.sort((a, b) => (a.teardownPriority ?? 0) -
|
|
1225
|
+
(b.teardownPriority ?? 0));
|
|
1226
|
+
}
|
|
1108
1227
|
/**
|
|
1109
1228
|
* Resource instances in teardown order: ascending `teardownPriority`, with the
|
|
1110
1229
|
* base reverse-insertion order preserved within each priority tier.
|
|
@@ -1119,7 +1238,11 @@ export class EvaluationContext {
|
|
|
1119
1238
|
* instance shape.
|
|
1120
1239
|
*/
|
|
1121
1240
|
teardownOrder() {
|
|
1122
|
-
|
|
1241
|
+
// A borrowed instance is torn down by the scope that declared it, never
|
|
1242
|
+
// here — see `borrowedResources`.
|
|
1243
|
+
const entries = [...this.resourceInstances.entries()]
|
|
1244
|
+
.filter(([name]) => !this.borrowedResources.has(name))
|
|
1245
|
+
.reverse();
|
|
1123
1246
|
// Stable sort by priority (default 0); Array.prototype.sort is stable, so
|
|
1124
1247
|
// the reverse-insertion order survives within each tier.
|
|
1125
1248
|
return entries.sort(([, a], [, b]) => (a.instance?.teardownPriority ?? 0) -
|