@telorun/kernel 0.12.0 → 0.13.2
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/LICENSE +2 -2
- package/dist/application-env.d.ts +24 -0
- package/dist/application-env.d.ts.map +1 -0
- package/dist/application-env.js +156 -0
- package/dist/application-env.js.map +1 -0
- package/dist/controller-loaders/npm-loader.d.ts +32 -8
- package/dist/controller-loaders/npm-loader.d.ts.map +1 -1
- package/dist/controller-loaders/npm-loader.js +74 -101
- package/dist/controller-loaders/npm-loader.js.map +1 -1
- package/dist/controllers/module/import-controller.d.ts +3 -2
- package/dist/controllers/module/import-controller.d.ts.map +1 -1
- package/dist/controllers/module/import-controller.js +23 -25
- 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 +3 -0
- package/dist/controllers/resource-definition/resource-definition-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-template-controller.d.ts +5 -0
- package/dist/controllers/resource-definition/resource-template-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/resource-template-controller.js +67 -6
- package/dist/controllers/resource-definition/resource-template-controller.js.map +1 -1
- package/dist/internal-context.d.ts +25 -0
- package/dist/internal-context.d.ts.map +1 -0
- package/dist/internal-context.js +2 -0
- package/dist/internal-context.js.map +1 -0
- package/dist/kernel.d.ts +21 -1
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +109 -5
- package/dist/kernel.js.map +1 -1
- package/dist/manifest-schemas.d.ts +7 -23
- package/dist/manifest-schemas.d.ts.map +1 -1
- package/dist/manifest-schemas.js +18 -8
- package/dist/manifest-schemas.js.map +1 -1
- package/dist/manifest-sources/analysis-stamp.d.ts +25 -0
- package/dist/manifest-sources/analysis-stamp.d.ts.map +1 -0
- package/dist/manifest-sources/analysis-stamp.js +151 -0
- package/dist/manifest-sources/analysis-stamp.js.map +1 -0
- package/dist/resource-context.d.ts +2 -0
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/resource-context.js +28 -0
- package/dist/resource-context.js.map +1 -1
- package/dist/schema-validator.d.ts +28 -0
- package/dist/schema-validator.d.ts.map +1 -1
- package/dist/schema-validator.js +161 -1
- package/dist/schema-validator.js.map +1 -1
- package/package.json +9 -6
- package/src/application-env.ts +216 -0
- package/src/controller-loaders/npm-loader.ts +78 -103
- package/src/controllers/module/import-controller.ts +33 -36
- package/src/controllers/resource-definition/resource-definition-controller.ts +6 -0
- package/src/controllers/resource-definition/resource-template-controller.ts +95 -7
- package/src/internal-context.ts +25 -0
- package/src/kernel.ts +130 -5
- package/src/manifest-schemas.ts +31 -11
- package/src/manifest-sources/analysis-stamp.ts +169 -0
- package/src/resource-context.ts +34 -0
- package/src/schema-validator.ts +178 -2
- package/dist/generated/runtime-deps.json +0 -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,
|
|
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;AAErD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAI1E,wBAAsB,MAAM,CAC1B,QAAQ,EAAE,GAAG,EACb,GAAG,EAAE,wBAAwB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAsI3B;AAeD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBlB,CAAC"}
|
|
@@ -2,17 +2,6 @@ import { DiagnosticSeverity, StaticAnalyzer } from "@telorun/analyzer";
|
|
|
2
2
|
import { RuntimeError } from "@telorun/sdk";
|
|
3
3
|
import { ModuleContext } from "../../module-context.js";
|
|
4
4
|
import { isDefaultPolicy, normalizeRuntime } from "../../runtime-registry.js";
|
|
5
|
-
const importAnalysisCache = new Map();
|
|
6
|
-
// Only resolve relative/absolute-path sources against the importer's URL. Registry refs
|
|
7
|
-
// (std/foo@1.2.3) and absolute URLs (https://, file://) must pass through unchanged so the
|
|
8
|
-
// loader's source chain can dispatch them — otherwise `new URL("std/foo@1", "file:///srv/telo.yaml")`
|
|
9
|
-
// turns a registry ref into a bogus file path and LocalFileSource ENOENTs on it.
|
|
10
|
-
function resolveImportSource(source, baseSource) {
|
|
11
|
-
if (source.startsWith(".") || source.startsWith("/")) {
|
|
12
|
-
return new URL(source, baseSource).toString();
|
|
13
|
-
}
|
|
14
|
-
return source;
|
|
15
|
-
}
|
|
16
5
|
export async function create(resource, ctx) {
|
|
17
6
|
const alias = resource.metadata.name;
|
|
18
7
|
const moduleSource = resource.module ?? resource.source;
|
|
@@ -26,23 +15,32 @@ export async function create(resource, ctx) {
|
|
|
26
15
|
// Validate the imported module and all its transitive imports before loading for runtime.
|
|
27
16
|
// loadManifests() follows Telo.Import chains so definitions from sub-imports are present,
|
|
28
17
|
// preventing false UNDEFINED_KIND errors for kinds that come from the module's own imports.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
//
|
|
19
|
+
// Route URL resolution through the kernel/loader's own helper rather than
|
|
20
|
+
// a hand-rolled `new URL(...).toString()`. For LocalFileSource the
|
|
21
|
+
// outputs match; for any custom `ManifestSource` with a non-trivial
|
|
22
|
+
// `resolveRelative`, only this path produces the canonical URL the
|
|
23
|
+
// loader keyed its caches under — without which fast paths like
|
|
24
|
+
// `isImportValidatedAtLoad` silently miss.
|
|
25
|
+
const resolvedUrl = ctx.resolveImportUrl(base, moduleSource);
|
|
26
|
+
// Fast path: when the kernel's load-time `analyzeErrors` already covered
|
|
27
|
+
// this import's subtree (the common case — every Telo.Import declared in
|
|
28
|
+
// the entry graph is walked by `loadGraph` and validated by
|
|
29
|
+
// `kernel.load`), skip the redundant per-import StaticAnalyzer pass.
|
|
30
|
+
// Falls through to the full analysis for URLs that arrived
|
|
31
|
+
// programmatically after `load()` (e.g. dynamically constructed imports
|
|
32
|
+
// in tests). Two Telo.Imports with the same source but distinct
|
|
33
|
+
// metadata.name would each re-run analysis here — a memoisation hook
|
|
34
|
+
// can be reintroduced if that turns into a measurable cost.
|
|
35
|
+
if (!ctx.isImportValidatedAtLoad(resolvedUrl)) {
|
|
36
|
+
const analysisManifests = await ctx.loadManifests(resolvedUrl);
|
|
38
37
|
const diagnostics = new StaticAnalyzer().analyze(analysisManifests);
|
|
39
|
-
errors = diagnostics
|
|
38
|
+
const errors = diagnostics
|
|
40
39
|
.filter((d) => d.severity === DiagnosticSeverity.Error)
|
|
41
40
|
.map((d) => d.message);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
throw new RuntimeError("ERR_MANIFEST_VALIDATION_FAILED", errors.join("\n"));
|
|
41
|
+
if (errors.length > 0) {
|
|
42
|
+
throw new RuntimeError("ERR_MANIFEST_VALIDATION_FAILED", errors.join("\n"));
|
|
43
|
+
}
|
|
46
44
|
}
|
|
47
45
|
// Load target module manifests for runtime. Inject variables/secrets as compile context so
|
|
48
46
|
// that ${{ variables.x }} / ${{ secrets.y }} templates in the child module resolve correctly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-controller.js","sourceRoot":"","sources":["../../../src/controllers/module/import-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEvE,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,EA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AAQ,EAAE,CAAC,MAAM,CAAC;YAClB,oBAAoB,EAAE,IAAI;SAC3B;QACD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAClB,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;aAC7C;SACF;KACF;IACD,QAAQ,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;IAChC,oBAAoB,EAAE,KAAK;CAC5B,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,EACf,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;AAKtB,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,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,KAAK,CAAC,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,EACf,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;AAKtB,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,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,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;CAqChC;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;AAED,eAAO,MAAM,MAAM;;;CAGlB,CAAC"}
|
|
@@ -12,6 +12,9 @@ class ResourceDefinition {
|
|
|
12
12
|
}
|
|
13
13
|
async init(ctx) {
|
|
14
14
|
if (!this.resource.controllers?.length) {
|
|
15
|
+
if (this.resource.capability === "Telo.Provider" && this.resource.provide == null) {
|
|
16
|
+
throw new Error(`Telo.Definition '${this.resource.metadata.name}': 'capability: Telo.Provider' requires either 'controllers:' (TS-backed) or 'provide:' (template-backed).`);
|
|
17
|
+
}
|
|
15
18
|
const controllerInstance = createTemplateController(this.resource);
|
|
16
19
|
ctx.registerDefinition(this.resource);
|
|
17
20
|
await ctx.registerController(this.resource.metadata.module, this.resource.metadata.name, controllerInstance);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-definition-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-definition-controller.ts"],"names":[],"mappings":"AAMA,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;
|
|
1
|
+
{"version":3,"file":"resource-definition-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-definition-controller.ts"],"names":[],"mappings":"AAMA,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;AAe7E;;;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,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;YACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,KAAK,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;gBAClF,MAAM,IAAI,KAAK,CACb,oBAAoB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,4GAA4G,CAC5J,CAAC;YACJ,CAAC;YACD,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,IAAI,CAAC,QAAe,CAAC,CAAC;YAC1E,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC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,CAChH,CAAC;IACJ,CAAC;IAED,oDAAoD;IACpD,MAAM,UAAU,GAAG,QAAiD,CAAC;IACrE,OAAO,IAAI,kBAAkB,CAAC,UAAU,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,IAAI;CAC3B,CAAC"}
|
|
@@ -8,5 +8,10 @@ export declare function createTemplateController(definition: {
|
|
|
8
8
|
};
|
|
9
9
|
inputs?: Record<string, any>;
|
|
10
10
|
run?: string;
|
|
11
|
+
provide?: {
|
|
12
|
+
kind: string;
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
result?: Record<string, any>;
|
|
11
16
|
}): ControllerInstance;
|
|
12
17
|
//# sourceMappingURL=resource-template-controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-template-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-template-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAqC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-template-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-template-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAqC,MAAM,cAAc,CAAC;AAqB1F,wBAAgB,wBAAwB,CAAC,UAAU,EAAE;IACnD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B,GAAG,kBAAkB,CA0MrB"}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { isCompiledValue } from "@telorun/sdk";
|
|
2
|
+
/** Reports the resources: entries available to dispatch against, by expanded
|
|
3
|
+
* name and kind. Used in error messages to guide the developer back to the
|
|
4
|
+
* template's `resources:` array when a dispatch target doesn't match. */
|
|
5
|
+
function describeAvailableTargets(ctx, resources, self) {
|
|
6
|
+
if (!resources || resources.length === 0)
|
|
7
|
+
return "<none>";
|
|
8
|
+
return resources
|
|
9
|
+
.map((r) => {
|
|
10
|
+
const expanded = ctx.moduleContext.expandWith(r?.metadata?.name ?? "", { self });
|
|
11
|
+
const kind = typeof r?.kind === "string" ? r.kind : "<unknown-kind>";
|
|
12
|
+
return `'${expanded || "<unnamed>"}' (${kind})`;
|
|
13
|
+
})
|
|
14
|
+
.join(", ");
|
|
15
|
+
}
|
|
2
16
|
export function createTemplateController(definition) {
|
|
3
17
|
return {
|
|
4
18
|
schema: definition.schema ?? { type: "object", additionalProperties: true },
|
|
@@ -21,13 +35,18 @@ export function createTemplateController(definition) {
|
|
|
21
35
|
const runTarget = definition.run
|
|
22
36
|
? ctx.moduleContext.expandWith(definition.run, { self })
|
|
23
37
|
: null;
|
|
38
|
+
const provideTarget = definition.provide?.name
|
|
39
|
+
? ctx.moduleContext.expandWith(definition.provide.name, { self })
|
|
40
|
+
: null;
|
|
24
41
|
const persistentManifests = [];
|
|
25
42
|
let ephemeralTemplate = null;
|
|
26
43
|
for (const template of definition.resources ?? []) {
|
|
27
44
|
const expandedName = ctx.moduleContext.expandWith(template.metadata?.name ?? "", {
|
|
28
45
|
self,
|
|
29
46
|
});
|
|
30
|
-
const isTarget = expandedName === invokeTarget ||
|
|
47
|
+
const isTarget = expandedName === invokeTarget ||
|
|
48
|
+
expandedName === runTarget ||
|
|
49
|
+
expandedName === provideTarget;
|
|
31
50
|
if (isTarget) {
|
|
32
51
|
ephemeralTemplate = template;
|
|
33
52
|
}
|
|
@@ -70,14 +89,19 @@ export function createTemplateController(definition) {
|
|
|
70
89
|
...(invokeTarget && {
|
|
71
90
|
invoke: async (inputs) => {
|
|
72
91
|
if (!ephemeralTemplate) {
|
|
73
|
-
throw new Error(`Template '${resource.metadata.name}':
|
|
92
|
+
throw new Error(`Template '${resource.metadata.name}': 'invoke:' targets '${invokeTarget}' ` +
|
|
93
|
+
`but no entry in 'resources:' has that metadata.name. Available: ${describeAvailableTargets(ctx, definition.resources, self)}.`);
|
|
74
94
|
}
|
|
75
95
|
const extraContext = { self, inputs };
|
|
76
96
|
const expanded = ctx.moduleContext.expandWith(ctx.moduleContext.expandWith(ephemeralTemplate, extraContext), extraContext);
|
|
77
97
|
return withEphemeral(expanded, async (name) => {
|
|
78
98
|
const entry = ctx.moduleContext.resourceInstances.get(name);
|
|
79
99
|
if (!entry?.instance?.invoke) {
|
|
80
|
-
|
|
100
|
+
const targetKind = (entry?.resource?.kind ?? expanded?.kind ?? "<unknown-kind>");
|
|
101
|
+
const targetDef = ctx.moduleContext.getDefinition?.(targetKind);
|
|
102
|
+
const actualCap = typeof targetDef?.capability === "string" ? targetDef.capability : "<unknown>";
|
|
103
|
+
throw new Error(`Template '${resource.metadata.name}': 'invoke:' target '${targetKind}/${invokeTarget}' ` +
|
|
104
|
+
`has capability '${actualCap}', not Telo.Invocable. Update 'invoke:' to a Telo.Invocable kind, or change the target's kind in 'resources:'.`);
|
|
81
105
|
}
|
|
82
106
|
// Top-level `inputs:` (sibling of `invoke:`) carries the values passed
|
|
83
107
|
// to the dispatch target's invoke(). When absent, fall back to the
|
|
@@ -87,26 +111,63 @@ export function createTemplateController(definition) {
|
|
|
87
111
|
const invokeInputs = definition.inputs != null
|
|
88
112
|
? ctx.moduleContext.expandWith(ctx.moduleContext.expandWith(definition.inputs, extraContext), extraContext)
|
|
89
113
|
: expanded.inputs ?? inputs;
|
|
90
|
-
|
|
114
|
+
const raw = await entry.instance.invoke(invokeInputs);
|
|
115
|
+
if (definition.result == null)
|
|
116
|
+
return raw;
|
|
117
|
+
const resultContext = { self, result: raw };
|
|
118
|
+
return ctx.moduleContext.expandWith(ctx.moduleContext.expandWith(definition.result, resultContext), resultContext);
|
|
91
119
|
});
|
|
92
120
|
},
|
|
93
121
|
}),
|
|
94
122
|
...(runTarget && {
|
|
95
123
|
run: async () => {
|
|
96
124
|
if (!ephemeralTemplate) {
|
|
97
|
-
throw new Error(`Template '${resource.metadata.name}':
|
|
125
|
+
throw new Error(`Template '${resource.metadata.name}': 'run:' targets '${runTarget}' ` +
|
|
126
|
+
`but no entry in 'resources:' has that metadata.name. Available: ${describeAvailableTargets(ctx, definition.resources, self)}.`);
|
|
98
127
|
}
|
|
99
128
|
const extraContext = { self };
|
|
100
129
|
const expanded = ctx.moduleContext.expandWith(ctx.moduleContext.expandWith(ephemeralTemplate, extraContext), extraContext);
|
|
101
130
|
return withEphemeral(expanded, async (name) => {
|
|
102
131
|
const entry = ctx.moduleContext.resourceInstances.get(name);
|
|
103
132
|
if (!entry?.instance?.run) {
|
|
104
|
-
|
|
133
|
+
const targetKind = (entry?.resource?.kind ?? expanded?.kind ?? "<unknown-kind>");
|
|
134
|
+
const targetDef = ctx.moduleContext.getDefinition?.(targetKind);
|
|
135
|
+
const actualCap = typeof targetDef?.capability === "string" ? targetDef.capability : "<unknown>";
|
|
136
|
+
throw new Error(`Template '${resource.metadata.name}': 'run:' target '${targetKind}/${runTarget}' ` +
|
|
137
|
+
`has capability '${actualCap}', not Telo.Runnable. Update 'run:' to a Telo.Runnable kind, or change the target's kind in 'resources:'.`);
|
|
105
138
|
}
|
|
106
139
|
return entry.instance.run();
|
|
107
140
|
});
|
|
108
141
|
},
|
|
109
142
|
}),
|
|
143
|
+
...(provideTarget && {
|
|
144
|
+
provide: async () => {
|
|
145
|
+
if (!ephemeralTemplate) {
|
|
146
|
+
throw new Error(`Template '${resource.metadata.name}': 'provide:' targets '${provideTarget}' ` +
|
|
147
|
+
`but no entry in 'resources:' has that metadata.name. Available: ${describeAvailableTargets(ctx, definition.resources, self)}.`);
|
|
148
|
+
}
|
|
149
|
+
const extraContext = { self };
|
|
150
|
+
const expanded = ctx.moduleContext.expandWith(ctx.moduleContext.expandWith(ephemeralTemplate, extraContext), extraContext);
|
|
151
|
+
return withEphemeral(expanded, async (name) => {
|
|
152
|
+
const entry = ctx.moduleContext.resourceInstances.get(name);
|
|
153
|
+
if (!entry?.instance?.invoke) {
|
|
154
|
+
const targetKind = (entry?.resource?.kind ?? expanded?.kind ?? "<unknown-kind>");
|
|
155
|
+
const targetDef = ctx.moduleContext.getDefinition?.(targetKind);
|
|
156
|
+
const actualCap = typeof targetDef?.capability === "string" ? targetDef.capability : "<unknown>";
|
|
157
|
+
throw new Error(`Template '${resource.metadata.name}': 'provide:' target '${targetKind}/${provideTarget}' ` +
|
|
158
|
+
`has capability '${actualCap}', not Telo.Invocable. Update 'provide:' to a Telo.Invocable kind, or change the target's kind in 'resources:'.`);
|
|
159
|
+
}
|
|
160
|
+
const provideInputs = definition.inputs != null
|
|
161
|
+
? ctx.moduleContext.expandWith(ctx.moduleContext.expandWith(definition.inputs, extraContext), extraContext)
|
|
162
|
+
: {};
|
|
163
|
+
const raw = await entry.instance.invoke(provideInputs);
|
|
164
|
+
if (definition.result == null)
|
|
165
|
+
return raw;
|
|
166
|
+
const resultContext = { self, result: raw };
|
|
167
|
+
return ctx.moduleContext.expandWith(ctx.moduleContext.expandWith(definition.result, resultContext), resultContext);
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
}),
|
|
110
171
|
teardown: async () => {
|
|
111
172
|
await childContext.teardownResources();
|
|
112
173
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-template-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-template-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,UAAU,wBAAwB,CAAC,
|
|
1
|
+
{"version":3,"file":"resource-template-controller.js","sourceRoot":"","sources":["../../../src/controllers/resource-definition/resource-template-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;0EAE0E;AAC1E,SAAS,wBAAwB,CAC/B,GAAoB,EACpB,SAA4B,EAC5B,IAA6B;IAE7B,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC1D,OAAO,SAAS;SACb,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,QAAQ,GAAG,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAW,CAAC;QAC3F,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC;QACrE,OAAO,IAAI,QAAQ,IAAI,WAAW,MAAM,IAAI,GAAG,CAAC;IAClD,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,UAQxC;IACC,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE;QAE3E,MAAM,EAAE,KAAK,EAAE,QAAa,EAAE,GAAoB,EAA6B,EAAE;YAC/E,MAAM,IAAI,GAAG,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAE3D,yEAAyE;YACzE,oEAAoE;Y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;4BACJ,CAAC;4BACD,MAAM,aAAa,GACjB,UAAU,CAAC,MAAM,IAAI,IAAI;gCACvB,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,UAAU,CAC1B,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,CAAC,EAC7D,YAAY,CACb;gCACH,CAAC,CAAC,EAAE,CAAC;4BACT,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;4BACvD,IAAI,UAAU,CAAC,MAAM,IAAI,IAAI;gCAAE,OAAO,GAAG,CAAC;4BAC1C,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;4BAC5C,OAAO,GAAG,CAAC,aAAa,CAAC,UAAU,CACjC,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,EAC9D,aAAa,CACd,CAAC;wBACJ,CAAC,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC;gBAEF,QAAQ,EAAE,KAAK,IAAI,EAAE;oBACnB,MAAM,YAAY,CAAC,iBAAiB,EAAE,CAAC;gBACzC,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ResourceContext } from "@telorun/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Context interface used by built-in kernel controllers (Telo.Application /
|
|
4
|
+
* Telo.Library / Telo.Import / Telo.Definition / Telo.Abstract) that need
|
|
5
|
+
* privileged access to load-time graph identity. These methods are
|
|
6
|
+
* intentionally *not* on the public `ResourceContext` exposed to module
|
|
7
|
+
* authors — they couple the caller to the kernel's load-time view of the
|
|
8
|
+
* world, and the import-controller is the only consumer today.
|
|
9
|
+
*
|
|
10
|
+
* `ResourceContextImpl` in this package implements both interfaces, so a
|
|
11
|
+
* controller authored against this type still works under the generic
|
|
12
|
+
* `controller.create(resource, ctx)` dispatch — the kernel just types it
|
|
13
|
+
* locally as `BuiltinControllerContext` instead of `ResourceContext`.
|
|
14
|
+
*/
|
|
15
|
+
export interface BuiltinControllerContext extends ResourceContext {
|
|
16
|
+
/** True when `url` resolved (via the loader's URL → canonical-source
|
|
17
|
+
* map) to a module that was part of the entry graph successfully
|
|
18
|
+
* analyzed during `Kernel.load()`. */
|
|
19
|
+
isImportValidatedAtLoad(url: string): boolean;
|
|
20
|
+
/** Resolve `importSource` against `fromSource` through the loader's
|
|
21
|
+
* source-chain `resolveRelative`. Identical to what `loadGraph` used
|
|
22
|
+
* internally — so the produced URL agrees with the loader's caches. */
|
|
23
|
+
resolveImportUrl(fromSource: string, importSource: string): string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=internal-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-context.d.ts","sourceRoot":"","sources":["../src/internal-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,wBAAyB,SAAQ,eAAe;IAC/D;;2CAEuC;IACvC,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9C;;4EAEwE;IACxE,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CACpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-context.js","sourceRoot":"","sources":["../src/internal-context.ts"],"names":[],"mappings":""}
|
package/dist/kernel.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalysisRegistry, type ManifestSource } from "@telorun/analyzer";
|
|
1
|
+
import { AnalysisRegistry, type LoadedGraph, type ManifestSource } from "@telorun/analyzer";
|
|
2
2
|
import { Kernel as IKernel, ResourceDefinition, ResourceManifest, RuntimeEvent, type LoadOptions } from "@telorun/sdk";
|
|
3
3
|
import { EventStream } from "./event-stream.js";
|
|
4
4
|
export interface KernelOptions {
|
|
@@ -31,6 +31,7 @@ export declare class Kernel implements IKernel {
|
|
|
31
31
|
private rootContext;
|
|
32
32
|
private staticManifests;
|
|
33
33
|
private _entryUrl?;
|
|
34
|
+
private _loadedGraph?;
|
|
34
35
|
private _bootCalled;
|
|
35
36
|
private _isBooted;
|
|
36
37
|
private _targetsRan;
|
|
@@ -53,6 +54,25 @@ export declare class Kernel implements IKernel {
|
|
|
53
54
|
* Pass to StaticAnalyzer.analyze() for incremental validation of new manifests against
|
|
54
55
|
* already-registered types (e.g. front-end editor validating a manifest before submitting). */
|
|
55
56
|
getAnalysisRegistry(): AnalysisRegistry;
|
|
57
|
+
/** The full LoadedGraph captured during `load()`. Used by the CLI to
|
|
58
|
+
* feed `writeManifestCache` so a successful `telo run` populates
|
|
59
|
+
* `<entry-dir>/.telo/manifests/` for subsequent runs — the same on-disk
|
|
60
|
+
* layout `telo install` writes. Undefined before `load()` has been
|
|
61
|
+
* called or if it threw before the graph was captured. */
|
|
62
|
+
getLoadedGraph(): LoadedGraph | undefined;
|
|
63
|
+
/** True when `url` resolves (via the loader's URL → canonical-source map)
|
|
64
|
+
* to a module that was already part of the entry graph successfully
|
|
65
|
+
* analyzed during `load()`. The import-controller uses it to skip its
|
|
66
|
+
* per-import `analyze()` pass when the kernel's load-time validation
|
|
67
|
+
* already covered the same subtree. */
|
|
68
|
+
isImportValidatedAtLoad(url: string): boolean;
|
|
69
|
+
/** Resolve a `Telo.Import.source` against the importing file's URL
|
|
70
|
+
* through the same source-chain `resolveRelative` the loader used at
|
|
71
|
+
* graph-walk time. The import-controller routes through here so its
|
|
72
|
+
* `resolveImportSource` no longer second-guesses the loader for
|
|
73
|
+
* custom `ManifestSource`s — `isImportValidatedAtLoad` etc. only hit
|
|
74
|
+
* when both sides agree on the canonical URL. */
|
|
75
|
+
resolveImportUrl(fromSource: string, importSource: string): string;
|
|
56
76
|
/**
|
|
57
77
|
* Load built-in Runtime definitions (e.g., Telo.Application, Telo.Library).
|
|
58
78
|
* Also declares all known module namespaces upfront so that resources can be
|
package/dist/kernel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAMhB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,MAAM,IAAI,OAAO,EAGjB,kBAAkB,EAElB,gBAAgB,EAEhB,YAAY,EAGZ,KAAK,WAAW,EAEjB,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAMhB,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,MAAM,IAAI,OAAO,EAGjB,kBAAkB,EAElB,gBAAgB,EAEhB,YAAY,EAGZ,KAAK,WAAW,EAEjB,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiDhD,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;wEAGoE;IACpE,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;8EAE0E;IAC1E,WAAW,CAAC,EAAE,MAAM,C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AIjC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI/B,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,IAAI;IAyBxC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5B;;;;;;;OAOG;IACH,SAAS,IAAI,IAAI;IAKjB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIxC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAI/E,OAAO,CAAC,uBAAuB;IAe/B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,qBAAqB;IAkB7B;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IA4B9B;;;;;OAKG;YACW,eAAe;IA0F7B;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;OAEG;IACG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAI1B;;OAEG;IACH,cAAc,IAAI,WAAW;IAI7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAS5B"}
|
package/dist/kernel.js
CHANGED
|
@@ -7,6 +7,9 @@ import { EventStream } from "./event-stream.js";
|
|
|
7
7
|
import { EventBus } from "./events.js";
|
|
8
8
|
import { ModuleContext } from "./module-context.js";
|
|
9
9
|
import { ResourceContextImpl } from "./resource-context.js";
|
|
10
|
+
import { computeAnalysisSignature, readAnalysisStamp, writeAnalysisStamp, } from "./manifest-sources/analysis-stamp.js";
|
|
11
|
+
import { resolveEntryDir } from "./manifest-sources/local-manifest-cache-source.js";
|
|
12
|
+
import { resolveApplicationEnv } from "./application-env.js";
|
|
10
13
|
import { policyFingerprint } from "./runtime-registry.js";
|
|
11
14
|
import { SchemaValidator } from "./schema-validator.js";
|
|
12
15
|
/** Walks up the EvaluationContext parent chain to the nearest enclosing
|
|
@@ -107,6 +110,36 @@ export class Kernel {
|
|
|
107
110
|
getAnalysisRegistry() {
|
|
108
111
|
return this.registry;
|
|
109
112
|
}
|
|
113
|
+
/** The full LoadedGraph captured during `load()`. Used by the CLI to
|
|
114
|
+
* feed `writeManifestCache` so a successful `telo run` populates
|
|
115
|
+
* `<entry-dir>/.telo/manifests/` for subsequent runs — the same on-disk
|
|
116
|
+
* layout `telo install` writes. Undefined before `load()` has been
|
|
117
|
+
* called or if it threw before the graph was captured. */
|
|
118
|
+
getLoadedGraph() {
|
|
119
|
+
return this._loadedGraph;
|
|
120
|
+
}
|
|
121
|
+
/** True when `url` resolves (via the loader's URL → canonical-source map)
|
|
122
|
+
* to a module that was already part of the entry graph successfully
|
|
123
|
+
* analyzed during `load()`. The import-controller uses it to skip its
|
|
124
|
+
* per-import `analyze()` pass when the kernel's load-time validation
|
|
125
|
+
* already covered the same subtree. */
|
|
126
|
+
isImportValidatedAtLoad(url) {
|
|
127
|
+
if (!this._loadedGraph)
|
|
128
|
+
return false;
|
|
129
|
+
const canonical = this.loader.canonicalize(url);
|
|
130
|
+
if (!canonical)
|
|
131
|
+
return false;
|
|
132
|
+
return this._loadedGraph.modules.has(canonical);
|
|
133
|
+
}
|
|
134
|
+
/** Resolve a `Telo.Import.source` against the importing file's URL
|
|
135
|
+
* through the same source-chain `resolveRelative` the loader used at
|
|
136
|
+
* graph-walk time. The import-controller routes through here so its
|
|
137
|
+
* `resolveImportSource` no longer second-guesses the loader for
|
|
138
|
+
* custom `ManifestSource`s — `isImportValidatedAtLoad` etc. only hit
|
|
139
|
+
* when both sides agree on the canonical URL. */
|
|
140
|
+
resolveImportUrl(fromSource, importSource) {
|
|
141
|
+
return this.loader.resolveImportUrl(fromSource, importSource);
|
|
142
|
+
}
|
|
110
143
|
/**
|
|
111
144
|
* Load built-in Runtime definitions (e.g., Telo.Application, Telo.Library).
|
|
112
145
|
* Also declares all known module namespaces upfront so that resources can be
|
|
@@ -136,6 +169,14 @@ export class Kernel {
|
|
|
136
169
|
async load(url) {
|
|
137
170
|
const sourceUrl = await this.loader.resolveEntryPoint(url);
|
|
138
171
|
this._entryUrl = sourceUrl;
|
|
172
|
+
// Point the shared schema validator at the entry-anchored cache so
|
|
173
|
+
// compiled AJV validators are persisted (standalone CJS) under
|
|
174
|
+
// `<entry-dir>/.telo/manifests/__validators/`. Memory- or HTTP-rooted
|
|
175
|
+
// entries skip the cache; their schema compiles stay in-process only.
|
|
176
|
+
const validatorCacheDir = resolveEntryDir(sourceUrl);
|
|
177
|
+
this.sharedSchemaValidator.setCacheDir(validatorCacheDir
|
|
178
|
+
? `${validatorCacheDir}/.telo/manifests/__validators`
|
|
179
|
+
: undefined);
|
|
139
180
|
this.rootContext = new ModuleContext(sourceUrl, {}, {}, {}, [], this._createInstance.bind(this), (event, payload) => this.eventBus.emit(event, payload), this.env);
|
|
140
181
|
// Initialize built-in Runtime definitions first
|
|
141
182
|
await this.loadBuiltinDefinitions();
|
|
@@ -151,6 +192,7 @@ export class Kernel {
|
|
|
151
192
|
if (analysisGraph.errors.length > 0) {
|
|
152
193
|
throw analysisGraph.errors[0].error;
|
|
153
194
|
}
|
|
195
|
+
this._loadedGraph = analysisGraph;
|
|
154
196
|
const staticManifests = flattenForAnalyzer(analysisGraph);
|
|
155
197
|
this.staticManifests = staticManifests;
|
|
156
198
|
// Register module identities for x-telo-ref resolution (Phase 3 prerequisite).
|
|
@@ -165,7 +207,18 @@ export class Kernel {
|
|
|
165
207
|
this.registry.registerModuleIdentity(m.metadata.namespace, m.metadata.name);
|
|
166
208
|
}
|
|
167
209
|
}
|
|
168
|
-
|
|
210
|
+
// Hash-keyed analysis cache: when the entry's full LoadedGraph matches
|
|
211
|
+
// a previously-stamped successful run (same file bytes, same stamp
|
|
212
|
+
// protocol version), skip the per-resource validation walk inside
|
|
213
|
+
// `analyzeErrors`. Registration of identities / aliases / definitions
|
|
214
|
+
// and inline-resource normalisation still runs — only the diagnostic
|
|
215
|
+
// passes are elided. Memory- / HTTP-rooted entries have no
|
|
216
|
+
// local stamp store and always re-validate.
|
|
217
|
+
const entryDir = resolveEntryDir(sourceUrl);
|
|
218
|
+
const analysisSignature = computeAnalysisSignature(analysisGraph);
|
|
219
|
+
const stamp = entryDir ? await readAnalysisStamp(entryDir) : undefined;
|
|
220
|
+
const skipValidation = stamp?.signature === analysisSignature;
|
|
221
|
+
const errors = this.analyzer.analyzeErrors(staticManifests, { skipValidation }, this.registry);
|
|
169
222
|
if (errors.length > 0) {
|
|
170
223
|
throw new RuntimeError("ERR_MANIFEST_VALIDATION_FAILED", "Manifest validation failed", errors.map((d) => ({
|
|
171
224
|
severity: "error",
|
|
@@ -176,6 +229,18 @@ export class Kernel {
|
|
|
176
229
|
: undefined,
|
|
177
230
|
})));
|
|
178
231
|
}
|
|
232
|
+
if (entryDir && !skipValidation) {
|
|
233
|
+
// Best-effort: stamp the verdict so subsequent loads hit the fast
|
|
234
|
+
// path. A read-only filesystem (baked Docker image) reports the
|
|
235
|
+
// failure on stderr and keeps running — the lookup above will
|
|
236
|
+
// simply miss next time.
|
|
237
|
+
try {
|
|
238
|
+
await writeAnalysisStamp(entryDir, analysisSignature);
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
this.stderr.write(`[telo:kernel] analysis stamp write failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
179
244
|
// Load runtime configuration — root module gets access to host env.
|
|
180
245
|
// Imports are loaded separately via the import-controller; this load is
|
|
181
246
|
// entry-only with compile-time CEL.
|
|
@@ -187,15 +252,47 @@ export class Kernel {
|
|
|
187
252
|
// the same normalized structure.
|
|
188
253
|
const normalizedManifests = this.analyzer.normalize(allManifests, this.registry);
|
|
189
254
|
this.staticManifests = normalizedManifests;
|
|
255
|
+
let rootApplicationManifest;
|
|
190
256
|
for (const manifest of normalizedManifests) {
|
|
191
257
|
if (isModuleKind(manifest.kind)) {
|
|
192
|
-
// Root is always Telo.Application (Library root rejected above).
|
|
193
|
-
//
|
|
194
|
-
//
|
|
195
|
-
|
|
258
|
+
// Root is always Telo.Application (Library root rejected above).
|
|
259
|
+
// Application-level `variables` / `secrets` declarations carry an `env:`
|
|
260
|
+
// mapping per field; the kernel populates the root scope from
|
|
261
|
+
// `process.env` after the manifest loop so imports can read
|
|
262
|
+
// `${{ variables.X }}` during their own init.
|
|
263
|
+
//
|
|
264
|
+
// Targets normalize down to bare names regardless of source surface.
|
|
265
|
+
// The analyzer's `resolveRefSentinels` pass already substituted any
|
|
266
|
+
// `!ref <name>` to `{kind, name}`; bare-string forms pass through.
|
|
267
|
+
// Anything else (e.g. an unresolved sentinel because the analyzer
|
|
268
|
+
// couldn't see it, or a malformed manifest) is a hard error —
|
|
269
|
+
// silently dropping the entry would leave the user staring at a
|
|
270
|
+
// "no targets ran" outcome with no signal where it went wrong.
|
|
271
|
+
const rawTargets = (manifest.targets ?? []);
|
|
272
|
+
const targetNames = rawTargets.map((t, index) => {
|
|
273
|
+
if (typeof t === "string")
|
|
274
|
+
return t;
|
|
275
|
+
if (t && typeof t === "object" && typeof t.name === "string") {
|
|
276
|
+
return t.name;
|
|
277
|
+
}
|
|
278
|
+
throw new RuntimeError("ERR_INVALID_VALUE", `Telo.Application '${manifest.metadata?.name ?? "(unnamed)"}' targets[${index}] could not be normalized to a resource name. Got: ${JSON.stringify(t)}`);
|
|
279
|
+
});
|
|
280
|
+
this.rootContext.setTargets(targetNames);
|
|
281
|
+
if (manifest.kind === "Telo.Application") {
|
|
282
|
+
rootApplicationManifest = manifest;
|
|
283
|
+
}
|
|
196
284
|
}
|
|
197
285
|
this.rootContext.registerManifest(manifest);
|
|
198
286
|
}
|
|
287
|
+
if (rootApplicationManifest) {
|
|
288
|
+
const { variables, secrets } = resolveApplicationEnv(rootApplicationManifest, this.env, this.sharedSchemaValidator);
|
|
289
|
+
if (Object.keys(variables).length > 0) {
|
|
290
|
+
this.rootContext.setVariables(variables);
|
|
291
|
+
}
|
|
292
|
+
if (Object.keys(secrets).length > 0) {
|
|
293
|
+
this.rootContext.setSecrets(secrets);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
199
296
|
}
|
|
200
297
|
/**
|
|
201
298
|
* Initialize every resource declared in the manifest. Does not run targets
|
|
@@ -285,6 +382,13 @@ export class Kernel {
|
|
|
285
382
|
if (this.rootContext) {
|
|
286
383
|
await this.rootContext.teardownResources();
|
|
287
384
|
}
|
|
385
|
+
// Drop the load-time graph so a teardown'd kernel doesn't pin every
|
|
386
|
+
// manifest file's text in memory (LoadedFile retains the parsed
|
|
387
|
+
// documents + the original YAML bytes). Reusing the kernel after
|
|
388
|
+
// teardown is a hard error elsewhere, so this is purely a memory
|
|
389
|
+
// hygiene step.
|
|
390
|
+
this._loadedGraph = undefined;
|
|
391
|
+
this.staticManifests = [];
|
|
288
392
|
await this.eventBus.emit("Kernel.Stopped", { exitCode: this._exitCode });
|
|
289
393
|
}
|
|
290
394
|
/**
|