@telorun/sdk 0.54.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/dispatch-invoke-ref.js +1 -1
- package/dist/evaluation-context.d.ts +9 -0
- package/dist/evaluation-context.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/observed-state.d.ts +36 -0
- package/dist/observed-state.d.ts.map +1 -0
- package/dist/observed-state.js +59 -0
- package/dist/ref.d.ts +12 -1
- package/dist/ref.d.ts.map +1 -1
- package/dist/ref.js +1 -1
- package/dist/resolve-ref-instance.d.ts +2 -2
- package/dist/resolve-ref-instance.js +2 -2
- package/dist/resource-context.d.ts +22 -1
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dispatch-invoke-ref.ts +1 -1
- package/src/evaluation-context.ts +9 -0
- package/src/index.ts +1 -0
- package/src/observed-state.ts +59 -0
- package/src/ref.ts +12 -1
- package/src/resolve-ref-instance.ts +2 -2
- package/src/resource-context.ts +22 -1
- package/src/types.ts +9 -1
|
@@ -12,7 +12,7 @@ import { getRefIdentity } from "./resource-instance.js";
|
|
|
12
12
|
* invocation context applies unchanged.
|
|
13
13
|
*/
|
|
14
14
|
export function resolveInvocableDispatcher(field, ctx, describe) {
|
|
15
|
-
const target = resolveRefInstance(field, ctx, isInvocableInstance, () => `${describe()}: 'invoke'`, "
|
|
15
|
+
const target = resolveRefInstance(field, ctx, isInvocableInstance, () => `${describe()}: 'invoke'`, "Telo.Invocable");
|
|
16
16
|
// Dispatch through the traced chokepoint needs the target's kind+name: from
|
|
17
17
|
// the `!ref` identity the kernel stamped at injection, else from the raw ref.
|
|
18
18
|
const id = getRefIdentity(target) ?? field;
|
|
@@ -114,6 +114,15 @@ export interface EvaluationContext {
|
|
|
114
114
|
initializeResources(): Promise<void>;
|
|
115
115
|
withManifests<T>(manifests: any[], fn: () => T): T;
|
|
116
116
|
createScopeHandle(manifests: ResourceManifest[]): ScopeHandle;
|
|
117
|
+
/** Re-read a resource's `snapshot()` and republish it, joined with whatever
|
|
118
|
+
* observed state the resource has reported. The publication path the
|
|
119
|
+
* post-init capture, the post-run publication, the post-invoke refresh and
|
|
120
|
+
* every `setStatus()` all share. */
|
|
121
|
+
publishSnapshot(name: string): Promise<void>;
|
|
122
|
+
/** Record what a resource observed (`ResourceContext.setStatus`) and
|
|
123
|
+
* republish. Validated against the kind's `status:`; replaces rather than
|
|
124
|
+
* merges; an error before the resource has started. */
|
|
125
|
+
setResourceStatus(name: string, status: Record<string, unknown>): Promise<void>;
|
|
117
126
|
teardownResources(): Promise<void>;
|
|
118
127
|
transientChild(context: Record<string, any>): EvaluationContext;
|
|
119
128
|
invoke<TInputs>(kind: string, name: string, inputs: TInputs, ctx?: InvokeContext): Promise<any>;
|
|
@@ -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;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,MAAM,SAAS,GAAG,CACtB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,GAAG,EACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC3B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;;;GAIG;AACH,MAAM,WA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pB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,OAAO,EACf,GAAG,CAAC,EAAE,aAAa,GAClB,OAAO,CAAC,GAAG,CAAC,CAAC;IAChB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpF;;6DAEyD;IACzD,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAChC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAC3E,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from "./log-sink.js";
|
|
|
24
24
|
export * from "./log-severity.js";
|
|
25
25
|
export * from "./logger.js";
|
|
26
26
|
export * from "./network-fetch.js";
|
|
27
|
+
export * from "./observed-state.js";
|
|
27
28
|
export * from "./runtime-error.js";
|
|
28
29
|
export * from "./runtime-event.js";
|
|
29
30
|
export * from "./runtime-resource.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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C;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export * from "./log-sink.js";
|
|
|
24
24
|
export * from "./log-severity.js";
|
|
25
25
|
export * from "./logger.js";
|
|
26
26
|
export * from "./network-fetch.js";
|
|
27
|
+
export * from "./observed-state.js";
|
|
27
28
|
export * from "./runtime-error.js";
|
|
28
29
|
export * from "./runtime-event.js";
|
|
29
30
|
export * from "./runtime-resource.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observed state — what a resource learns while it is running (a socket's
|
|
3
|
+
* actual port, a negotiated endpoint) as opposed to what its author configured.
|
|
4
|
+
*
|
|
5
|
+
* The two are reported through two different channels, because only one of them
|
|
6
|
+
* is derivable on demand:
|
|
7
|
+
*
|
|
8
|
+
* - **Configured state is pulled.** `snapshot()` returns it, and the kernel
|
|
9
|
+
* calls that whenever it needs the value; it is a function of the manifest,
|
|
10
|
+
* so re-deriving it is always correct.
|
|
11
|
+
* - **Observed state is pushed.** `ResourceContext.setStatus()` reports it at
|
|
12
|
+
* the moment it is learned, because nothing but the controller knows when
|
|
13
|
+
* that is. The kernel holds the last value reported and publishes it at
|
|
14
|
+
* `resources.<name>.{@link OBSERVED_STATE_KEY}.<field>`.
|
|
15
|
+
*
|
|
16
|
+
* Splitting them is what keeps each shape described in exactly one place: a
|
|
17
|
+
* controller never rebuilds observed state inside `snapshot()` from a field it
|
|
18
|
+
* stashed only for that purpose, and the two payloads can never collide.
|
|
19
|
+
*/
|
|
20
|
+
/** The CEL segment observed state is published under: `resources.<name>.status`. */
|
|
21
|
+
export declare const OBSERVED_STATE_KEY = "status";
|
|
22
|
+
/**
|
|
23
|
+
* Copy the plain containers out of a published value so what reaches CEL is a
|
|
24
|
+
* point-in-time reading rather than a live window into the controller.
|
|
25
|
+
*
|
|
26
|
+
* A controller that reported a structure it goes on to mutate would otherwise
|
|
27
|
+
* keep rewriting an already-published value — an accident no schema check can
|
|
28
|
+
* catch, because the shape never changes, only the contents.
|
|
29
|
+
*
|
|
30
|
+
* Plain objects and arrays are rebuilt; everything else — class instances (a
|
|
31
|
+
* `Stream`, a connection pool), functions, primitives — is passed through by
|
|
32
|
+
* reference, because those are not copyable in any meaningful sense and CEL
|
|
33
|
+
* cannot read into them anyway. Cycles resolve to the copy already made.
|
|
34
|
+
*/
|
|
35
|
+
export declare function detachSnapshotValue(value: unknown, seen?: Map<object, unknown>): unknown;
|
|
36
|
+
//# sourceMappingURL=observed-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observed-state.d.ts","sourceRoot":"","sources":["../src/observed-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,uBAA6B,GAAG,OAAO,CAsB9F"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observed state — what a resource learns while it is running (a socket's
|
|
3
|
+
* actual port, a negotiated endpoint) as opposed to what its author configured.
|
|
4
|
+
*
|
|
5
|
+
* The two are reported through two different channels, because only one of them
|
|
6
|
+
* is derivable on demand:
|
|
7
|
+
*
|
|
8
|
+
* - **Configured state is pulled.** `snapshot()` returns it, and the kernel
|
|
9
|
+
* calls that whenever it needs the value; it is a function of the manifest,
|
|
10
|
+
* so re-deriving it is always correct.
|
|
11
|
+
* - **Observed state is pushed.** `ResourceContext.setStatus()` reports it at
|
|
12
|
+
* the moment it is learned, because nothing but the controller knows when
|
|
13
|
+
* that is. The kernel holds the last value reported and publishes it at
|
|
14
|
+
* `resources.<name>.{@link OBSERVED_STATE_KEY}.<field>`.
|
|
15
|
+
*
|
|
16
|
+
* Splitting them is what keeps each shape described in exactly one place: a
|
|
17
|
+
* controller never rebuilds observed state inside `snapshot()` from a field it
|
|
18
|
+
* stashed only for that purpose, and the two payloads can never collide.
|
|
19
|
+
*/
|
|
20
|
+
/** The CEL segment observed state is published under: `resources.<name>.status`. */
|
|
21
|
+
export const OBSERVED_STATE_KEY = "status";
|
|
22
|
+
/**
|
|
23
|
+
* Copy the plain containers out of a published value so what reaches CEL is a
|
|
24
|
+
* point-in-time reading rather than a live window into the controller.
|
|
25
|
+
*
|
|
26
|
+
* A controller that reported a structure it goes on to mutate would otherwise
|
|
27
|
+
* keep rewriting an already-published value — an accident no schema check can
|
|
28
|
+
* catch, because the shape never changes, only the contents.
|
|
29
|
+
*
|
|
30
|
+
* Plain objects and arrays are rebuilt; everything else — class instances (a
|
|
31
|
+
* `Stream`, a connection pool), functions, primitives — is passed through by
|
|
32
|
+
* reference, because those are not copyable in any meaningful sense and CEL
|
|
33
|
+
* cannot read into them anyway. Cycles resolve to the copy already made.
|
|
34
|
+
*/
|
|
35
|
+
export function detachSnapshotValue(value, seen = new Map()) {
|
|
36
|
+
if (value === null || typeof value !== "object")
|
|
37
|
+
return value;
|
|
38
|
+
const existing = seen.get(value);
|
|
39
|
+
if (existing !== undefined)
|
|
40
|
+
return existing;
|
|
41
|
+
if (Array.isArray(value)) {
|
|
42
|
+
const copy = new Array(value.length);
|
|
43
|
+
seen.set(value, copy);
|
|
44
|
+
for (let i = 0; i < value.length; i++)
|
|
45
|
+
copy[i] = detachSnapshotValue(value[i], seen);
|
|
46
|
+
return copy;
|
|
47
|
+
}
|
|
48
|
+
// Only plain objects: a class instance's identity and behaviour are the point
|
|
49
|
+
// of returning it, and rebuilding one as a bare object would break it.
|
|
50
|
+
const proto = Object.getPrototypeOf(value);
|
|
51
|
+
if (proto !== Object.prototype && proto !== null)
|
|
52
|
+
return value;
|
|
53
|
+
const copy = {};
|
|
54
|
+
seen.set(value, copy);
|
|
55
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
56
|
+
copy[key] = detachSnapshotValue(entry, seen);
|
|
57
|
+
}
|
|
58
|
+
return copy;
|
|
59
|
+
}
|
package/dist/ref.d.ts
CHANGED
|
@@ -27,6 +27,17 @@ export interface ScopeContext {
|
|
|
27
27
|
* this is always a programming error; all scope members are statically
|
|
28
28
|
* validated in Phase 3 before the kernel ever reaches runtime. */
|
|
29
29
|
getInstance(name: string, alias?: string): ResourceInstance;
|
|
30
|
+
/** `run()` a scope-local resource through the kernel's dispatch chokepoint, so
|
|
31
|
+
* it is traced, records that it started, and publishes its snapshot — a bare
|
|
32
|
+
* `getInstance(name).run()` does none of that. Throws if the name was not
|
|
33
|
+
* declared in the scope or the instance is not runnable. */
|
|
34
|
+
run(name: string): Promise<void>;
|
|
35
|
+
/** The CEL `resources` map as seen from inside this scope: the enclosing
|
|
36
|
+
* module's published resources with the scope-local ones layered on top
|
|
37
|
+
* (scope-local names win, matching {@link getInstance}'s resolution order).
|
|
38
|
+
* Rebuilt per `ScopeHandle.run()`, so two concurrent runs of the same
|
|
39
|
+
* sequence never observe each other's scoped resources. */
|
|
40
|
+
readonly resources: Record<string, unknown>;
|
|
30
41
|
}
|
|
31
42
|
/** Returned by Phase 5 injection in place of an x-telo-scope manifest array.
|
|
32
43
|
* The controller calls run() to open the scope, execute work, and tear it down. */
|
|
@@ -44,7 +55,7 @@ export type Injected<T> = {
|
|
|
44
55
|
/** Returns a schema node that emits `x-telo-ref` for buildReferenceFieldMap and carries
|
|
45
56
|
* KindRef<T> as its TypeScript type. For TypeBox schemas use Type.Unsafe<KindRef<T>>(Ref(...)).
|
|
46
57
|
*
|
|
47
|
-
* @param ref
|
|
58
|
+
* @param ref The slot's `x-telo-ref` constraint, e.g. "Sql.Connection" or "Telo.Invocable" */
|
|
48
59
|
export declare const Ref: <T = ResourceInstance>(ref: string) => KindRef<T>;
|
|
49
60
|
/** Returns a schema node that emits `x-telo-scope` for buildReferenceFieldMap and carries
|
|
50
61
|
* ScopeRef as its TypeScript type. For TypeBox schemas use Type.Unsafe<ScopeRef>(Scope(...)).
|
package/dist/ref.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../src/ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;;;;gFAOgF;AAChF,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,gBAAgB;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;CACrB;AAED;6DAC6D;AAC7D,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;CACxB;AAED,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B;;;;;uEAKmE;IACnE,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../src/ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,g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,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GACrC,CAAC,CAAC,CAAC,CAAC;CACb,CAAC;AAEF;;;+FAG+F;AAC/F,eAAO,MAAM,GAAG,GAAI,CAAC,GAAG,gBAAgB,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,CAAC,CACf,CAAC;AAEnD;;;;wEAIwE;AACxE,eAAO,MAAM,KAAK,GAAI,gBAAgB,MAAM,GAAG,MAAM,EAAE,KAAG,QACG,CAAC"}
|
package/dist/ref.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Returns a schema node that emits `x-telo-ref` for buildReferenceFieldMap and carries
|
|
2
2
|
* KindRef<T> as its TypeScript type. For TypeBox schemas use Type.Unsafe<KindRef<T>>(Ref(...)).
|
|
3
3
|
*
|
|
4
|
-
* @param ref
|
|
4
|
+
* @param ref The slot's `x-telo-ref` constraint, e.g. "Sql.Connection" or "Telo.Invocable" */
|
|
5
5
|
export const Ref = (ref) => ({ "x-telo-ref": ref });
|
|
6
6
|
/** Returns a schema node that emits `x-telo-scope` for buildReferenceFieldMap and carries
|
|
7
7
|
* ScopeRef as its TypeScript type. For TypeBox schemas use Type.Unsafe<ScopeRef>(Scope(...)).
|
|
@@ -26,13 +26,13 @@ export interface RefResolveContext {
|
|
|
26
26
|
* on the methods the caller will actually invoke, so a mis-wired ref fails with a
|
|
27
27
|
* clear message here rather than as `undefined is not a function` later.
|
|
28
28
|
* `describe` labels the owning resource and slot; `expects` names the contract
|
|
29
|
-
* the slot wants — the slot's own `x-telo-ref` string (`
|
|
29
|
+
* the slot wants — the slot's own `x-telo-ref` string (`Cache.Store`) — so
|
|
30
30
|
* the message says what was missing, not just that something was.
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* const store = resolveRefInstance(
|
|
34
34
|
* this.resource.store, this.ctx, isKvStore,
|
|
35
|
-
* () => `Idempotency.Once "${name}": 'store'`, "
|
|
35
|
+
* () => `Idempotency.Once "${name}": 'store'`, "KvStore.Store",
|
|
36
36
|
* );
|
|
37
37
|
*/
|
|
38
38
|
export declare function resolveRefInstance<T>(value: unknown, ctx: RefResolveContext, guard: (candidate: unknown) => candidate is T, describe: () => string, expects?: string): T;
|
|
@@ -22,13 +22,13 @@ import { RuntimeError } from "./types.js";
|
|
|
22
22
|
* on the methods the caller will actually invoke, so a mis-wired ref fails with a
|
|
23
23
|
* clear message here rather than as `undefined is not a function` later.
|
|
24
24
|
* `describe` labels the owning resource and slot; `expects` names the contract
|
|
25
|
-
* the slot wants — the slot's own `x-telo-ref` string (`
|
|
25
|
+
* the slot wants — the slot's own `x-telo-ref` string (`Cache.Store`) — so
|
|
26
26
|
* the message says what was missing, not just that something was.
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
29
|
* const store = resolveRefInstance(
|
|
30
30
|
* this.resource.store, this.ctx, isKvStore,
|
|
31
|
-
* () => `Idempotency.Once "${name}": 'store'`, "
|
|
31
|
+
* () => `Idempotency.Once "${name}": 'store'`, "KvStore.Store",
|
|
32
32
|
* );
|
|
33
33
|
*/
|
|
34
34
|
export function resolveRefInstance(value, ctx, guard, describe, expects) {
|
|
@@ -45,6 +45,27 @@ export interface ResourceContext extends ControllerContext {
|
|
|
45
45
|
* collide and the children nest under their parent in a debug view. */
|
|
46
46
|
readonly ownerPrefix: string;
|
|
47
47
|
acquireHold(reason?: string): () => void;
|
|
48
|
+
/**
|
|
49
|
+
* Report this resource's **observed state** — what it has learned while
|
|
50
|
+
* running — publishing it at `resources.<name>.status.<field>`.
|
|
51
|
+
*
|
|
52
|
+
* Pushed rather than pulled because nothing but the controller knows when the
|
|
53
|
+
* value was learned. Configured state stays on `snapshot()`, which the kernel
|
|
54
|
+
* pulls whenever it needs it; the two never share a payload, so neither shape
|
|
55
|
+
* is described twice.
|
|
56
|
+
*
|
|
57
|
+
* - **Replaces**, never merges: this is the resource's observed state now. A
|
|
58
|
+
* field the kind declares but this call omits reads as missing, which is the
|
|
59
|
+
* truth — declare a sometimes-absent field with a nullable type and report
|
|
60
|
+
* it as `null`.
|
|
61
|
+
* - **Validated** against the kind's `status:` on every call.
|
|
62
|
+
* - **Illegal before the resource has started** (`ERR_OBSERVED_STATE_BEFORE_START`).
|
|
63
|
+
* `init()` performs no I/O, so there is nothing observed to report there.
|
|
64
|
+
* - **Sticky**: the last value reported stays published until the resource is
|
|
65
|
+
* torn down. A dispatch that reports nothing leaves the previous reading in
|
|
66
|
+
* place — a listener's bound address does not stop being true between calls.
|
|
67
|
+
*/
|
|
68
|
+
setStatus(status: Record<string, unknown>): Promise<void>;
|
|
48
69
|
emitEvent(event: string, payload?: any): Promise<void>;
|
|
49
70
|
/** Mint a writable cancellation source for a trigger to own (HTTP request,
|
|
50
71
|
* lambda budget). Pass `source.context` into `invokeResolved` to scope an
|
|
@@ -95,7 +116,7 @@ export interface ResourceContext extends ControllerContext {
|
|
|
95
116
|
* Resolve a `!ref` config field to a live instance of `T`. See
|
|
96
117
|
* {@link resolveRefInstance} — this is the same resolution, reached through
|
|
97
118
|
* the context a controller already holds. `expects` names the contract the
|
|
98
|
-
* slot wants — its `x-telo-ref` string (`
|
|
119
|
+
* slot wants — its `x-telo-ref` string (`Cache.Store`) — so a mis-wire
|
|
99
120
|
* says what was missing.
|
|
100
121
|
*/
|
|
101
122
|
resolveRef<T>(value: unknown, guard: (candidate: unknown) => candidate is T, describe: () => string, expects?: string): T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-context.d.ts","sourceRoot":"","sources":["../src/resource-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAA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SON Schema for the resource's compile-time configuration fields. */
|
|
42
42
|
schema?: Record<string, any>;
|
|
43
|
+
/** JSON Schema for the observed state the resource reports while running —
|
|
44
|
+
* what it learns, not what it was configured with. Surfaces as its own CEL
|
|
45
|
+
* segment, `resources.<name>.status.<field>`, readable only from fields that
|
|
46
|
+
* resolve while the application runs. Declaring the block (even empty) opts
|
|
47
|
+
* the kind into typed `.status` reads. `required:` is rejected: every
|
|
48
|
+
* declared field is mandatory once the resource has run, and a genuinely
|
|
49
|
+
* sometimes-absent one is declared with a nullable type instead. */
|
|
50
|
+
status?: Record<string, any>;
|
|
43
51
|
capability?: string;
|
|
44
52
|
/** Alias-form reference to a Telo.Abstract this definition implements, e.g. "Ai.Model".
|
|
45
53
|
* Resolved against the declaring file's `Telo.Import` declarations — same pattern as
|
|
46
54
|
* kind prefixes (`kind: Http.Api`). Orthogonal to `capability` (lifecycle role); the
|
|
47
55
|
* analyzer populates its `extendedBy` index from this field so references typed via
|
|
48
|
-
* `x-telo-ref:
|
|
56
|
+
* `x-telo-ref: <Alias>.<Abstract>` accept this definition. */
|
|
49
57
|
extends?: string;
|
|
50
58
|
/** Type reference (named, inline `Type.JsonSchema`, or raw schema) for the
|
|
51
59
|
* resource's `invoke()` inputs / outputs. Read by the analyzer's CEL typing
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,uB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AAM,GAAG,IAAI,CAAC;IAC9B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,YAAa,SAAQ,KAAK;IAE5B,IAAI,EAAE,gBAAgB;IAEtB,WAAW,CAAC,EAAE,iBAAiB,EAAE;gBAFjC,IAAI,EAAE,gBAAgB,EAC7B,OAAO,EAAE,MAAM,EACR,WAAW,CAAC,EAAE,iBAAiB,EAAE,YAAA;CAK3C"}
|
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@ export function resolveInvocableDispatcher(
|
|
|
38
38
|
ctx,
|
|
39
39
|
isInvocableInstance,
|
|
40
40
|
() => `${describe()}: 'invoke'`,
|
|
41
|
-
"
|
|
41
|
+
"Telo.Invocable",
|
|
42
42
|
);
|
|
43
43
|
// Dispatch through the traced chokepoint needs the target's kind+name: from
|
|
44
44
|
// the `!ref` identity the kernel stamped at injection, else from the raw ref.
|
|
@@ -146,6 +146,15 @@ export interface EvaluationContext {
|
|
|
146
146
|
initializeResources(): Promise<void>;
|
|
147
147
|
withManifests<T>(manifests: any[], fn: () => T): T;
|
|
148
148
|
createScopeHandle(manifests: ResourceManifest[]): ScopeHandle;
|
|
149
|
+
/** Re-read a resource's `snapshot()` and republish it, joined with whatever
|
|
150
|
+
* observed state the resource has reported. The publication path the
|
|
151
|
+
* post-init capture, the post-run publication, the post-invoke refresh and
|
|
152
|
+
* every `setStatus()` all share. */
|
|
153
|
+
publishSnapshot(name: string): Promise<void>;
|
|
154
|
+
/** Record what a resource observed (`ResourceContext.setStatus`) and
|
|
155
|
+
* republish. Validated against the kind's `status:`; replaces rather than
|
|
156
|
+
* merges; an error before the resource has started. */
|
|
157
|
+
setResourceStatus(name: string, status: Record<string, unknown>): Promise<void>;
|
|
149
158
|
teardownResources(): Promise<void>;
|
|
150
159
|
transientChild(context: Record<string, any>): EvaluationContext;
|
|
151
160
|
invoke<TInputs>(kind: string, name: string, inputs: TInputs, ctx?: InvokeContext): Promise<any>;
|
package/src/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from "./log-sink.js";
|
|
|
24
24
|
export * from "./log-severity.js";
|
|
25
25
|
export * from "./logger.js";
|
|
26
26
|
export * from "./network-fetch.js";
|
|
27
|
+
export * from "./observed-state.js";
|
|
27
28
|
export * from "./runtime-error.js";
|
|
28
29
|
export * from "./runtime-event.js";
|
|
29
30
|
export * from "./runtime-resource.js";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observed state — what a resource learns while it is running (a socket's
|
|
3
|
+
* actual port, a negotiated endpoint) as opposed to what its author configured.
|
|
4
|
+
*
|
|
5
|
+
* The two are reported through two different channels, because only one of them
|
|
6
|
+
* is derivable on demand:
|
|
7
|
+
*
|
|
8
|
+
* - **Configured state is pulled.** `snapshot()` returns it, and the kernel
|
|
9
|
+
* calls that whenever it needs the value; it is a function of the manifest,
|
|
10
|
+
* so re-deriving it is always correct.
|
|
11
|
+
* - **Observed state is pushed.** `ResourceContext.setStatus()` reports it at
|
|
12
|
+
* the moment it is learned, because nothing but the controller knows when
|
|
13
|
+
* that is. The kernel holds the last value reported and publishes it at
|
|
14
|
+
* `resources.<name>.{@link OBSERVED_STATE_KEY}.<field>`.
|
|
15
|
+
*
|
|
16
|
+
* Splitting them is what keeps each shape described in exactly one place: a
|
|
17
|
+
* controller never rebuilds observed state inside `snapshot()` from a field it
|
|
18
|
+
* stashed only for that purpose, and the two payloads can never collide.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** The CEL segment observed state is published under: `resources.<name>.status`. */
|
|
22
|
+
export const OBSERVED_STATE_KEY = "status";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Copy the plain containers out of a published value so what reaches CEL is a
|
|
26
|
+
* point-in-time reading rather than a live window into the controller.
|
|
27
|
+
*
|
|
28
|
+
* A controller that reported a structure it goes on to mutate would otherwise
|
|
29
|
+
* keep rewriting an already-published value — an accident no schema check can
|
|
30
|
+
* catch, because the shape never changes, only the contents.
|
|
31
|
+
*
|
|
32
|
+
* Plain objects and arrays are rebuilt; everything else — class instances (a
|
|
33
|
+
* `Stream`, a connection pool), functions, primitives — is passed through by
|
|
34
|
+
* reference, because those are not copyable in any meaningful sense and CEL
|
|
35
|
+
* cannot read into them anyway. Cycles resolve to the copy already made.
|
|
36
|
+
*/
|
|
37
|
+
export function detachSnapshotValue(value: unknown, seen = new Map<object, unknown>()): unknown {
|
|
38
|
+
if (value === null || typeof value !== "object") return value;
|
|
39
|
+
const existing = seen.get(value);
|
|
40
|
+
if (existing !== undefined) return existing;
|
|
41
|
+
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
const copy: unknown[] = new Array(value.length);
|
|
44
|
+
seen.set(value, copy);
|
|
45
|
+
for (let i = 0; i < value.length; i++) copy[i] = detachSnapshotValue(value[i], seen);
|
|
46
|
+
return copy;
|
|
47
|
+
}
|
|
48
|
+
// Only plain objects: a class instance's identity and behaviour are the point
|
|
49
|
+
// of returning it, and rebuilding one as a bare object would break it.
|
|
50
|
+
const proto = Object.getPrototypeOf(value);
|
|
51
|
+
if (proto !== Object.prototype && proto !== null) return value;
|
|
52
|
+
|
|
53
|
+
const copy: Record<string, unknown> = {};
|
|
54
|
+
seen.set(value, copy);
|
|
55
|
+
for (const [key, entry] of Object.entries(value as Record<string, unknown>)) {
|
|
56
|
+
copy[key] = detachSnapshotValue(entry, seen);
|
|
57
|
+
}
|
|
58
|
+
return copy;
|
|
59
|
+
}
|
package/src/ref.ts
CHANGED
|
@@ -30,6 +30,17 @@ export interface ScopeContext {
|
|
|
30
30
|
* this is always a programming error; all scope members are statically
|
|
31
31
|
* validated in Phase 3 before the kernel ever reaches runtime. */
|
|
32
32
|
getInstance(name: string, alias?: string): ResourceInstance;
|
|
33
|
+
/** `run()` a scope-local resource through the kernel's dispatch chokepoint, so
|
|
34
|
+
* it is traced, records that it started, and publishes its snapshot — a bare
|
|
35
|
+
* `getInstance(name).run()` does none of that. Throws if the name was not
|
|
36
|
+
* declared in the scope or the instance is not runnable. */
|
|
37
|
+
run(name: string): Promise<void>;
|
|
38
|
+
/** The CEL `resources` map as seen from inside this scope: the enclosing
|
|
39
|
+
* module's published resources with the scope-local ones layered on top
|
|
40
|
+
* (scope-local names win, matching {@link getInstance}'s resolution order).
|
|
41
|
+
* Rebuilt per `ScopeHandle.run()`, so two concurrent runs of the same
|
|
42
|
+
* sequence never observe each other's scoped resources. */
|
|
43
|
+
readonly resources: Record<string, unknown>;
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
/** Returned by Phase 5 injection in place of an x-telo-scope manifest array.
|
|
@@ -56,7 +67,7 @@ export type Injected<T> = {
|
|
|
56
67
|
/** Returns a schema node that emits `x-telo-ref` for buildReferenceFieldMap and carries
|
|
57
68
|
* KindRef<T> as its TypeScript type. For TypeBox schemas use Type.Unsafe<KindRef<T>>(Ref(...)).
|
|
58
69
|
*
|
|
59
|
-
* @param ref
|
|
70
|
+
* @param ref The slot's `x-telo-ref` constraint, e.g. "Sql.Connection" or "Telo.Invocable" */
|
|
60
71
|
export const Ref = <T = ResourceInstance>(ref: string): KindRef<T> =>
|
|
61
72
|
({ "x-telo-ref": ref } as unknown as KindRef<T>);
|
|
62
73
|
|
|
@@ -30,13 +30,13 @@ export interface RefResolveContext {
|
|
|
30
30
|
* on the methods the caller will actually invoke, so a mis-wired ref fails with a
|
|
31
31
|
* clear message here rather than as `undefined is not a function` later.
|
|
32
32
|
* `describe` labels the owning resource and slot; `expects` names the contract
|
|
33
|
-
* the slot wants — the slot's own `x-telo-ref` string (`
|
|
33
|
+
* the slot wants — the slot's own `x-telo-ref` string (`Cache.Store`) — so
|
|
34
34
|
* the message says what was missing, not just that something was.
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* const store = resolveRefInstance(
|
|
38
38
|
* this.resource.store, this.ctx, isKvStore,
|
|
39
|
-
* () => `Idempotency.Once "${name}": 'store'`, "
|
|
39
|
+
* () => `Idempotency.Once "${name}": 'store'`, "KvStore.Store",
|
|
40
40
|
* );
|
|
41
41
|
*/
|
|
42
42
|
export function resolveRefInstance<T>(
|
package/src/resource-context.ts
CHANGED
|
@@ -54,6 +54,27 @@ export interface ResourceContext extends ControllerContext {
|
|
|
54
54
|
* collide and the children nest under their parent in a debug view. */
|
|
55
55
|
readonly ownerPrefix: string;
|
|
56
56
|
acquireHold(reason?: string): () => void;
|
|
57
|
+
/**
|
|
58
|
+
* Report this resource's **observed state** — what it has learned while
|
|
59
|
+
* running — publishing it at `resources.<name>.status.<field>`.
|
|
60
|
+
*
|
|
61
|
+
* Pushed rather than pulled because nothing but the controller knows when the
|
|
62
|
+
* value was learned. Configured state stays on `snapshot()`, which the kernel
|
|
63
|
+
* pulls whenever it needs it; the two never share a payload, so neither shape
|
|
64
|
+
* is described twice.
|
|
65
|
+
*
|
|
66
|
+
* - **Replaces**, never merges: this is the resource's observed state now. A
|
|
67
|
+
* field the kind declares but this call omits reads as missing, which is the
|
|
68
|
+
* truth — declare a sometimes-absent field with a nullable type and report
|
|
69
|
+
* it as `null`.
|
|
70
|
+
* - **Validated** against the kind's `status:` on every call.
|
|
71
|
+
* - **Illegal before the resource has started** (`ERR_OBSERVED_STATE_BEFORE_START`).
|
|
72
|
+
* `init()` performs no I/O, so there is nothing observed to report there.
|
|
73
|
+
* - **Sticky**: the last value reported stays published until the resource is
|
|
74
|
+
* torn down. A dispatch that reports nothing leaves the previous reading in
|
|
75
|
+
* place — a listener's bound address does not stop being true between calls.
|
|
76
|
+
*/
|
|
77
|
+
setStatus(status: Record<string, unknown>): Promise<void>;
|
|
57
78
|
emitEvent(event: string, payload?: any): Promise<void>;
|
|
58
79
|
/** Mint a writable cancellation source for a trigger to own (HTTP request,
|
|
59
80
|
* lambda budget). Pass `source.context` into `invokeResolved` to scope an
|
|
@@ -107,7 +128,7 @@ export interface ResourceContext extends ControllerContext {
|
|
|
107
128
|
* Resolve a `!ref` config field to a live instance of `T`. See
|
|
108
129
|
* {@link resolveRefInstance} — this is the same resolution, reached through
|
|
109
130
|
* the context a controller already holds. `expects` names the contract the
|
|
110
|
-
* slot wants — its `x-telo-ref` string (`
|
|
131
|
+
* slot wants — its `x-telo-ref` string (`Cache.Store`) — so a mis-wire
|
|
111
132
|
* says what was missing.
|
|
112
133
|
*/
|
|
113
134
|
resolveRef<T>(
|
package/src/types.ts
CHANGED
|
@@ -46,12 +46,20 @@ export interface ResourceDefinition {
|
|
|
46
46
|
};
|
|
47
47
|
/** JSON Schema for the resource's compile-time configuration fields. */
|
|
48
48
|
schema?: Record<string, any>;
|
|
49
|
+
/** JSON Schema for the observed state the resource reports while running —
|
|
50
|
+
* what it learns, not what it was configured with. Surfaces as its own CEL
|
|
51
|
+
* segment, `resources.<name>.status.<field>`, readable only from fields that
|
|
52
|
+
* resolve while the application runs. Declaring the block (even empty) opts
|
|
53
|
+
* the kind into typed `.status` reads. `required:` is rejected: every
|
|
54
|
+
* declared field is mandatory once the resource has run, and a genuinely
|
|
55
|
+
* sometimes-absent one is declared with a nullable type instead. */
|
|
56
|
+
status?: Record<string, any>;
|
|
49
57
|
capability?: string;
|
|
50
58
|
/** Alias-form reference to a Telo.Abstract this definition implements, e.g. "Ai.Model".
|
|
51
59
|
* Resolved against the declaring file's `Telo.Import` declarations — same pattern as
|
|
52
60
|
* kind prefixes (`kind: Http.Api`). Orthogonal to `capability` (lifecycle role); the
|
|
53
61
|
* analyzer populates its `extendedBy` index from this field so references typed via
|
|
54
|
-
* `x-telo-ref:
|
|
62
|
+
* `x-telo-ref: <Alias>.<Abstract>` accept this definition. */
|
|
55
63
|
extends?: string;
|
|
56
64
|
/** Type reference (named, inline `Type.JsonSchema`, or raw schema) for the
|
|
57
65
|
* resource's `invoke()` inputs / outputs. Read by the analyzer's CEL typing
|