@telorun/sdk 0.82.1 → 0.86.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.
@@ -81,6 +81,12 @@ export interface EvaluationContext {
81
81
  readonly emit: EmitEvent;
82
82
  parent: EvaluationContext | undefined;
83
83
  readonly children: EvaluationContext[];
84
+ /** Where this node sits in its parent's teardown cascade — ascending, default
85
+ * 0, reverse-registration order within a tier. The context-level analogue of
86
+ * {@link ResourceInstance.teardownPriority}: a node that must outlive its
87
+ * siblings says so, rather than depending on when it happened to be created.
88
+ * A `lifecycle: shared` library sets `TEARDOWN_LAST`. */
89
+ teardownPriority?: number;
84
90
  state: LifecycleState;
85
91
  readonly resourceInstances: Map<string, {
86
92
  resource: ResourceManifest;
@@ -106,6 +112,16 @@ export interface EvaluationContext {
106
112
  /** Looks up a registered resource definition by fully-qualified kind.
107
113
  * Set by the kernel; used for declared-throw-union checks. */
108
114
  getDefinition?: (kind: string) => ResourceDefinition | undefined;
115
+ /** Resolve an alias-form kind (`Http.Server`) to its canonical
116
+ * `<module>.<Kind>` in THIS context's scope. Only a module context carries
117
+ * the import-alias table, so a template / scope child inherits its parent's.
118
+ * Optional, like every other kernel-supplied hook here. */
119
+ kindResolver?: (kind: string) => string;
120
+ /** Bind a name into this context's own CEL scope, detached from the parent's.
121
+ * A template uses it to put `self` in scope for the body it creates, so a
122
+ * node the nested kind evaluates later can read the enclosing resource's
123
+ * configuration beside the call-time names that kind binds. */
124
+ bindContextValue?(name: string, value: unknown): void;
109
125
  /** Per-kernel invocation tracer. Set by the kernel on the root context and
110
126
  * propagated through `spawnChild`; drives invocation-id minting in `invoke`. */
111
127
  tracer?: Tracer;
@@ -1 +1 @@
1
- {"version":3,"file":"evaluation-context.d.ts","sourceRoot":"","sources":["../src/evaluation-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACl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AM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3B,WAAW,CACT,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,CAAC,EAAE,MAAM,EAAE,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5B"}
@@ -42,7 +42,36 @@ export interface ModuleContext extends EvaluationContext {
42
42
  } | undefined;
43
43
  /** Resolve a cross-module exported-instance reference `Alias.name` to its live instance. */
44
44
  resolveImportedInstance(alias: string, name: string): ResourceInstance | undefined;
45
- getInstance(name: string): unknown;
45
+ /**
46
+ * Resolve a sibling by NAME.
47
+ *
48
+ * A resolution taken while the module is still initializing is RECORDED,
49
+ * because a caller that resolves during `init()` may hold what it gets, and
50
+ * nothing in the manifest says so: a name passed here is invisible to the
51
+ * reference walk that builds the dependency edges, so a host rebuilding that
52
+ * resource cannot know this caller is holding it. Recording is what makes the
53
+ * host fall back to rebuilding the whole context instead of silently leaving
54
+ * a holder pointing at a dead instance.
55
+ *
56
+ * A resolution taken after initialization is not recorded: it re-resolves per
57
+ * dispatch, so there is nothing to hold and nothing to invalidate.
58
+ *
59
+ * Prefer an `x-telo-ref` slot, which declares the edge and costs the caller
60
+ * nothing at run time — the kernel injects the live instance before `init()`.
61
+ * This is for the case a slot cannot express, and its cost is that the
62
+ * resource it names can no longer be rebuilt on its own.
63
+ *
64
+ * `declaredBy` is for the one caller that has a declared slot behind it and
65
+ * only wants the lookup: the SDK's own `!ref` resolution, for a reference that
66
+ * reached a controller as a raw sentinel instead of being injected. Passing
67
+ * the resolved ref suppresses the record, because the edge is in the manifest
68
+ * already. There is deliberately no second METHOD for this — a public door
69
+ * whose documentation asks you not to use it is one that gets used.
70
+ */
71
+ getInstance(name: string, declaredBy?: {
72
+ kind: string;
73
+ name: string;
74
+ }): unknown;
46
75
  getInvocable<TInput = Record<string, any>, TOutput = any>(name: string): Invocable<TInput, TOutput>;
47
76
  resolveKind(kind: string): string;
48
77
  runTargets(ctx?: InvokeContext): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"module-context.d.ts","sourceRoot":"","sources":["../src/module-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE5C,4EAA4E;IAC5E,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAElC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAClD,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACrC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACnD,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAChE,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS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B,EACtB,KAAK,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,SAAS,IAAI,CAAC,EAC7C,QAAQ,EAAE,MAAM,MAAM,EACtB,OAAO,CAAC,EAAE,MAAM,GACf,CAAC,CAiCH"}
1
+ {"version":3,"file":"resolve-ref-instance.d.ts","sourceRoot":"","sources":["../src/resolve-ref-instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,oEAAoE;AACpE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC;;;;;;;OAOG;IACH,oBAAoB,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;CACnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,SAAS,IAAI,CAAC,EAC7C,QAAQ,EAAE,MAAM,MAAM,EACtB,OAAO,CAAC,EAAE,MAAM,GACf,CAAC,CAqCH"}
@@ -47,7 +47,11 @@ export function resolveRefInstance(value, ctx, guard, describe, expects) {
47
47
  // it is an alias that crosses no import boundary.
48
48
  const instance = ref.alias && ref.alias !== "Self"
49
49
  ? ctx.moduleContext.resolveImportedInstance(ref.alias, ref.name)
50
- : (ctx.resolveLocalInstance?.(ref.name) ?? ctx.moduleContext.getInstance(ref.name));
50
+ : // The DECLARED door: this name came out of a ref slot, so the edge is
51
+ // already in the manifest and recording it would mark the target
52
+ // unreconcilable on the strength of a reference the host can see.
53
+ (ctx.resolveLocalInstance?.(ref.name) ??
54
+ ctx.moduleContext.getInstance(ref.name, { kind: ref.kind, name: ref.name }));
51
55
  if (!guard(instance)) {
52
56
  const label = ref.alias ? `${ref.alias}.${ref.name}` : ref.name;
53
57
  throw new RuntimeError("ERR_REF_UNRESOLVED", `${describe()} reference '${label}' did not resolve to a ${target}` +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/sdk",
3
- "version": "0.82.1",
3
+ "version": "0.86.0",
4
4
  "description": "Telo SDK - Public API for Telo module authors.",
5
5
  "keywords": [
6
6
  "telo",
@@ -106,6 +106,13 @@ export interface EvaluationContext {
106
106
  parent: EvaluationContext | undefined;
107
107
  readonly children: EvaluationContext[];
108
108
 
109
+ /** Where this node sits in its parent's teardown cascade — ascending, default
110
+ * 0, reverse-registration order within a tier. The context-level analogue of
111
+ * {@link ResourceInstance.teardownPriority}: a node that must outlive its
112
+ * siblings says so, rather than depending on when it happened to be created.
113
+ * A `lifecycle: shared` library sets `TEARDOWN_LAST`. */
114
+ teardownPriority?: number;
115
+
109
116
  state: LifecycleState;
110
117
 
111
118
  readonly resourceInstances: Map<
@@ -136,6 +143,18 @@ export interface EvaluationContext {
136
143
  * Set by the kernel; used for declared-throw-union checks. */
137
144
  getDefinition?: (kind: string) => ResourceDefinition | undefined;
138
145
 
146
+ /** Resolve an alias-form kind (`Http.Server`) to its canonical
147
+ * `<module>.<Kind>` in THIS context's scope. Only a module context carries
148
+ * the import-alias table, so a template / scope child inherits its parent's.
149
+ * Optional, like every other kernel-supplied hook here. */
150
+ kindResolver?: (kind: string) => string;
151
+
152
+ /** Bind a name into this context's own CEL scope, detached from the parent's.
153
+ * A template uses it to put `self` in scope for the body it creates, so a
154
+ * node the nested kind evaluates later can read the enclosing resource's
155
+ * configuration beside the call-time names that kind binds. */
156
+ bindContextValue?(name: string, value: unknown): void;
157
+
139
158
  /** Per-kernel invocation tracer. Set by the kernel on the root context and
140
159
  * propagated through `spawnChild`; drives invocation-id minting in `invoke`. */
141
160
  tracer?: Tracer;
@@ -43,7 +43,33 @@ export interface ModuleContext extends EvaluationContext {
43
43
  resolveImportedRef(alias: string, name: string): { kind: string; name: string } | undefined;
44
44
  /** Resolve a cross-module exported-instance reference `Alias.name` to its live instance. */
45
45
  resolveImportedInstance(alias: string, name: string): ResourceInstance | undefined;
46
- getInstance(name: string): unknown;
46
+ /**
47
+ * Resolve a sibling by NAME.
48
+ *
49
+ * A resolution taken while the module is still initializing is RECORDED,
50
+ * because a caller that resolves during `init()` may hold what it gets, and
51
+ * nothing in the manifest says so: a name passed here is invisible to the
52
+ * reference walk that builds the dependency edges, so a host rebuilding that
53
+ * resource cannot know this caller is holding it. Recording is what makes the
54
+ * host fall back to rebuilding the whole context instead of silently leaving
55
+ * a holder pointing at a dead instance.
56
+ *
57
+ * A resolution taken after initialization is not recorded: it re-resolves per
58
+ * dispatch, so there is nothing to hold and nothing to invalidate.
59
+ *
60
+ * Prefer an `x-telo-ref` slot, which declares the edge and costs the caller
61
+ * nothing at run time — the kernel injects the live instance before `init()`.
62
+ * This is for the case a slot cannot express, and its cost is that the
63
+ * resource it names can no longer be rebuilt on its own.
64
+ *
65
+ * `declaredBy` is for the one caller that has a declared slot behind it and
66
+ * only wants the lookup: the SDK's own `!ref` resolution, for a reference that
67
+ * reached a controller as a raw sentinel instead of being injected. Passing
68
+ * the resolved ref suppresses the record, because the edge is in the manifest
69
+ * already. There is deliberately no second METHOD for this — a public door
70
+ * whose documentation asks you not to use it is one that gets used.
71
+ */
72
+ getInstance(name: string, declaredBy?: { kind: string; name: string }): unknown;
47
73
  getInvocable<TInput = Record<string, any>, TOutput = any>(
48
74
  name: string,
49
75
  ): Invocable<TInput, TOutput>;
@@ -77,7 +77,11 @@ export function resolveRefInstance<T>(
77
77
  const instance =
78
78
  ref.alias && ref.alias !== "Self"
79
79
  ? ctx.moduleContext.resolveImportedInstance(ref.alias, ref.name)
80
- : (ctx.resolveLocalInstance?.(ref.name) ?? ctx.moduleContext.getInstance(ref.name));
80
+ : // The DECLARED door: this name came out of a ref slot, so the edge is
81
+ // already in the manifest and recording it would mark the target
82
+ // unreconcilable on the strength of a reference the host can see.
83
+ (ctx.resolveLocalInstance?.(ref.name) ??
84
+ ctx.moduleContext.getInstance(ref.name, { kind: ref.kind as string, name: ref.name }));
81
85
 
82
86
  if (!guard(instance)) {
83
87
  const label = ref.alias ? `${ref.alias}.${ref.name}` : ref.name;