@telorun/sdk 0.83.0 → 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.
@@ -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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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.83.0",
3
+ "version": "0.86.0",
4
4
  "description": "Telo SDK - Public API for Telo module authors.",
5
5
  "keywords": [
6
6
  "telo",
@@ -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;