@graphrefly/graphrefly 0.21.0 → 0.23.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/README.md +7 -5
- package/dist/chunk-263BEJJO.js +115 -0
- package/dist/chunk-263BEJJO.js.map +1 -0
- package/dist/chunk-2GQLMQVJ.js +47 -0
- package/dist/chunk-2GQLMQVJ.js.map +1 -0
- package/dist/chunk-32N5A454.js +36 -0
- package/dist/chunk-32N5A454.js.map +1 -0
- package/dist/chunk-7TAQJHQV.js +103 -0
- package/dist/chunk-7TAQJHQV.js.map +1 -0
- package/dist/{chunk-VOQFK7YN.js → chunk-CWYPA63G.js} +109 -259
- package/dist/chunk-CWYPA63G.js.map +1 -0
- package/dist/{chunk-7IGHIFTT.js → chunk-HVBX5KIW.js} +15 -26
- package/dist/chunk-HVBX5KIW.js.map +1 -0
- package/dist/chunk-JFONSPNF.js +391 -0
- package/dist/chunk-JFONSPNF.js.map +1 -0
- package/dist/chunk-NZMBRXQV.js +2330 -0
- package/dist/chunk-NZMBRXQV.js.map +1 -0
- package/dist/{chunk-XWBVAO2R.js → chunk-PNUZM7PC.js} +20 -30
- package/dist/chunk-PNUZM7PC.js.map +1 -0
- package/dist/{chunk-ZTCDY5NQ.js → chunk-PX6PDUJ5.js} +34 -50
- package/dist/chunk-PX6PDUJ5.js.map +1 -0
- package/dist/chunk-XRFJJ2IU.js +2417 -0
- package/dist/chunk-XRFJJ2IU.js.map +1 -0
- package/dist/chunk-XTLYW4FR.js +6829 -0
- package/dist/chunk-XTLYW4FR.js.map +1 -0
- package/dist/compat/nestjs/index.cjs +3489 -2286
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.d.cts +6 -4
- package/dist/compat/nestjs/index.d.ts +6 -4
- package/dist/compat/nestjs/index.js +10 -8
- package/dist/core/index.cjs +1706 -1217
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +3 -2
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.js +37 -34
- package/dist/extra/index.cjs +7519 -6125
- package/dist/extra/index.cjs.map +1 -1
- package/dist/extra/index.d.cts +4 -4
- package/dist/extra/index.d.ts +4 -4
- package/dist/extra/index.js +63 -34
- package/dist/graph/index.cjs +3199 -2212
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +5 -3
- package/dist/graph/index.d.ts +5 -3
- package/dist/graph/index.js +24 -11
- package/dist/graph-BtdSRHUc.d.cts +1128 -0
- package/dist/graph-CEO2FkLY.d.ts +1128 -0
- package/dist/{index-DuN3bhtm.d.ts → index-B0tfuXwV.d.cts} +1697 -586
- package/dist/index-BFGjXbiP.d.cts +315 -0
- package/dist/{index-CgSiUouz.d.ts → index-BPlWVAKY.d.cts} +4 -4
- package/dist/index-BUj3ASVe.d.cts +406 -0
- package/dist/{index-VHA43cGP.d.cts → index-C59uSJAH.d.cts} +2 -2
- package/dist/index-CkElcUY6.d.ts +315 -0
- package/dist/index-DSPc5rkv.d.ts +406 -0
- package/dist/{index-BjtlNirP.d.cts → index-DgscL7v0.d.ts} +4 -4
- package/dist/{index-SFzE_KTa.d.cts → index-RXN94sHK.d.ts} +1697 -586
- package/dist/{index-8a605sg9.d.ts → index-jEtF4N7L.d.ts} +2 -2
- package/dist/index.cjs +9947 -7949
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +214 -37
- package/dist/index.d.ts +214 -37
- package/dist/index.js +919 -648
- package/dist/index.js.map +1 -1
- package/dist/meta-3QjzotRv.d.ts +41 -0
- package/dist/meta-B-Lbs4-O.d.cts +41 -0
- package/dist/node-C7PD3sn9.d.cts +1188 -0
- package/dist/node-C7PD3sn9.d.ts +1188 -0
- package/dist/{observable-DcBwQY7t.d.ts → observable-EyO-moQY.d.ts} +1 -1
- package/dist/{observable-C8Kx_O6k.d.cts → observable-axpzv1K2.d.cts} +1 -1
- package/dist/patterns/reactive-layout/index.cjs +3205 -2138
- package/dist/patterns/reactive-layout/index.cjs.map +1 -1
- package/dist/patterns/reactive-layout/index.d.cts +5 -3
- package/dist/patterns/reactive-layout/index.d.ts +5 -3
- package/dist/patterns/reactive-layout/index.js +7 -4
- package/dist/storage-CHT5WE9m.d.ts +182 -0
- package/dist/storage-DIgAr7M_.d.cts +182 -0
- package/package.json +2 -1
- package/dist/chunk-2UDLYZHT.js +0 -2117
- package/dist/chunk-2UDLYZHT.js.map +0 -1
- package/dist/chunk-4MQ2J6IG.js +0 -1631
- package/dist/chunk-4MQ2J6IG.js.map +0 -1
- package/dist/chunk-7IGHIFTT.js.map +0 -1
- package/dist/chunk-DOSLSFKL.js +0 -162
- package/dist/chunk-DOSLSFKL.js.map +0 -1
- package/dist/chunk-ECN37NVS.js +0 -6227
- package/dist/chunk-ECN37NVS.js.map +0 -1
- package/dist/chunk-G66H6ZRK.js +0 -111
- package/dist/chunk-G66H6ZRK.js.map +0 -1
- package/dist/chunk-VOQFK7YN.js.map +0 -1
- package/dist/chunk-WZ2Z2CRV.js +0 -32
- package/dist/chunk-WZ2Z2CRV.js.map +0 -1
- package/dist/chunk-XWBVAO2R.js.map +0 -1
- package/dist/chunk-ZTCDY5NQ.js.map +0 -1
- package/dist/graph-KsTe57nI.d.cts +0 -750
- package/dist/graph-mILUUqW8.d.ts +0 -750
- package/dist/index-B2SvPEbc.d.ts +0 -257
- package/dist/index-BHfg_Ez3.d.ts +0 -629
- package/dist/index-Bc_diYYJ.d.cts +0 -629
- package/dist/index-UudxGnzc.d.cts +0 -257
- package/dist/meta-BnG7XAaE.d.cts +0 -778
- package/dist/meta-BnG7XAaE.d.ts +0 -778
package/dist/meta-BnG7XAaE.d.ts
DELETED
|
@@ -1,778 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GraphReFly message protocol — §1 `~/src/graphrefly/GRAPHREFLY-SPEC.md`.
|
|
3
|
-
* Emissions are always `[[Type, Data?], ...]` (no single-tuple shorthand).
|
|
4
|
-
*
|
|
5
|
-
* ## Canonical message ordering (within a composite batch)
|
|
6
|
-
*
|
|
7
|
-
* When multiple message types appear in a single `down()` call, the canonical
|
|
8
|
-
* delivery order is determined by **signal tier**:
|
|
9
|
-
*
|
|
10
|
-
* | Tier | Signals | Role | Batch behavior |
|
|
11
|
-
* |------|------------------------|-------------------|-------------------------------------|
|
|
12
|
-
* | 0 | START | Subscribe handshake | Immediate (never deferred) |
|
|
13
|
-
* | 1 | DIRTY, INVALIDATE | Notification | Immediate (never deferred) |
|
|
14
|
-
* | 2 | PAUSE, RESUME | Flow control | Immediate (never deferred) |
|
|
15
|
-
* | 3 | DATA, RESOLVED | Value settlement | Deferred inside `batch()` |
|
|
16
|
-
* | 4 | COMPLETE, ERROR | Terminal lifecycle | Deferred to after phase-2 |
|
|
17
|
-
* | 5 | TEARDOWN | Destruction | Immediate (usually sent alone) |
|
|
18
|
-
*
|
|
19
|
-
* **Rule:** Within `downWithBatch`, messages are partitioned by tier and delivered
|
|
20
|
-
* in tier order. This ensures phase-2 values (DATA/RESOLVED) reach sinks before
|
|
21
|
-
* terminal signals (COMPLETE/ERROR) mark the node as done, preventing the
|
|
22
|
-
* "COMPLETE-before-DATA" class of bugs. Sources that emit in canonical order
|
|
23
|
-
* naturally partition correctly with zero overhead.
|
|
24
|
-
*
|
|
25
|
-
* Unknown message types (forward-compat) are tier 1 (immediate).
|
|
26
|
-
*
|
|
27
|
-
* ## Meta node bypass rules (centralized — GRAPHREFLY-SPEC §2.3)
|
|
28
|
-
*
|
|
29
|
-
* - **INVALIDATE** via `graph.signal()` — no-op on meta nodes (cached values preserved).
|
|
30
|
-
* - **COMPLETE / ERROR** — not propagated from parent to meta (meta outlives terminal
|
|
31
|
-
* state for post-mortem writes like setting `meta.error` after ERROR).
|
|
32
|
-
* - **TEARDOWN** — propagated from parent to meta, releasing meta resources.
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
|
-
* Subscribe-time handshake (`START`). Delivered to each new sink at the top of
|
|
36
|
-
* `subscribe()` — `[[START]]` for a SENTINEL (no cached value) node or
|
|
37
|
-
* `[[START], [DATA, cached]]` for a node with a cached value.
|
|
38
|
-
*
|
|
39
|
-
* Semantics: "upstream connected and ready to flow." A new sink receiving
|
|
40
|
-
* `[[START]]` alone knows the upstream is alive but has no current value; a
|
|
41
|
-
* sink receiving `[[START], [DATA, v]]` knows the upstream is ready
|
|
42
|
-
* with value `v`. Absence of `START` before any other message means the
|
|
43
|
-
* subscription was either never established or the node is terminal.
|
|
44
|
-
*
|
|
45
|
-
* Tier 0 — immediate, delivered before any DIRTY/DATA in the same batch.
|
|
46
|
-
* Not forwarded through nodes — each node emits its own `START` to its own
|
|
47
|
-
* new sinks.
|
|
48
|
-
*/
|
|
49
|
-
declare const START: unique symbol;
|
|
50
|
-
/** Value delivery (`DATA`, value). Tier 3 — deferred inside `batch()`. */
|
|
51
|
-
declare const DATA: unique symbol;
|
|
52
|
-
/** Phase 1: value about to change. Tier 1 — immediate. */
|
|
53
|
-
declare const DIRTY: unique symbol;
|
|
54
|
-
/** Phase 2: dirty pass completed, value unchanged. Tier 3 — deferred inside `batch()`. */
|
|
55
|
-
declare const RESOLVED: unique symbol;
|
|
56
|
-
/** Clear cached state; do not auto-emit. Tier 1 — immediate. */
|
|
57
|
-
declare const INVALIDATE: unique symbol;
|
|
58
|
-
/** Suspend activity. Tier 2 — immediate. */
|
|
59
|
-
declare const PAUSE: unique symbol;
|
|
60
|
-
/** Resume after pause. Tier 2 — immediate. */
|
|
61
|
-
declare const RESUME: unique symbol;
|
|
62
|
-
/** Permanent cleanup. Tier 5 — immediate (usually sent alone). */
|
|
63
|
-
declare const TEARDOWN: unique symbol;
|
|
64
|
-
/** Clean termination. Tier 4 — delivered after phase-2 in the same batch. */
|
|
65
|
-
declare const COMPLETE: unique symbol;
|
|
66
|
-
/** Error termination. Tier 4 — delivered after phase-2 in the same batch. */
|
|
67
|
-
declare const ERROR: unique symbol;
|
|
68
|
-
/** Known protocol type symbols (open set — other symbols are valid and forward). */
|
|
69
|
-
declare const knownMessageTypes: readonly symbol[];
|
|
70
|
-
/** One protocol tuple: `[Type, optional payload]`. */
|
|
71
|
-
type Message = readonly [symbol, unknown?];
|
|
72
|
-
/**
|
|
73
|
-
* A batch of tuples — the wire shape for `node.down()` / `node.up()`.
|
|
74
|
-
*/
|
|
75
|
-
type Messages = readonly Message[];
|
|
76
|
-
/**
|
|
77
|
-
* Whether `t` is one of the built-in protocol symbols in this module.
|
|
78
|
-
*
|
|
79
|
-
* @param t — Message type symbol (unknown types are still valid; they must forward).
|
|
80
|
-
* @returns `true` for `DATA`, `DIRTY`, `RESOLVED`, etc.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```ts
|
|
84
|
-
* import { DATA, DIRTY, isKnownMessageType } from "@graphrefly/graphrefly-ts";
|
|
85
|
-
*
|
|
86
|
-
* isKnownMessageType(DATA); // true
|
|
87
|
-
* isKnownMessageType(Symbol("custom")); // false
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
declare function isKnownMessageType(t: symbol): boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Returns the signal tier for a message type (see module-level ordering table).
|
|
93
|
-
*
|
|
94
|
-
* - 0: subscribe handshake (START) — immediate, first in canonical order
|
|
95
|
-
* - 1: notification (DIRTY, INVALIDATE) — immediate
|
|
96
|
-
* - 2: flow control (PAUSE, RESUME) — immediate
|
|
97
|
-
* - 3: value (DATA, RESOLVED) — deferred inside `batch()`
|
|
98
|
-
* - 4: terminal (COMPLETE, ERROR) — delivered after phase-3
|
|
99
|
-
* - 5: destruction (TEARDOWN) — immediate, usually alone
|
|
100
|
-
* - 1 for unknown types (forward-compat: immediate)
|
|
101
|
-
*
|
|
102
|
-
* @param t — Message type symbol.
|
|
103
|
-
* @returns Tier number (0–5).
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```ts
|
|
107
|
-
* import { DATA, DIRTY, COMPLETE, TEARDOWN, messageTier, START } from "@graphrefly/graphrefly-ts";
|
|
108
|
-
*
|
|
109
|
-
* messageTier(START); // 0
|
|
110
|
-
* messageTier(DIRTY); // 1
|
|
111
|
-
* messageTier(DATA); // 3
|
|
112
|
-
* messageTier(COMPLETE); // 4
|
|
113
|
-
* messageTier(TEARDOWN); // 5
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
declare function messageTier(t: symbol): number;
|
|
117
|
-
/**
|
|
118
|
-
* Returns whether this tuple is deferred by `batch()` (phase 2: `DATA` or `RESOLVED`).
|
|
119
|
-
*
|
|
120
|
-
* @param msg — Single message tuple.
|
|
121
|
-
* @returns `true` if `msg` is `DATA` or `RESOLVED`.
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* ```ts
|
|
125
|
-
* import { DATA, RESOLVED, DIRTY, isPhase2Message } from "@graphrefly/graphrefly-ts";
|
|
126
|
-
*
|
|
127
|
-
* isPhase2Message([DATA, 42]); // true
|
|
128
|
-
* isPhase2Message([RESOLVED]); // true
|
|
129
|
-
* isPhase2Message([DIRTY]); // false
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
declare function isPhase2Message(msg: Message): boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Returns whether this message type is terminal (COMPLETE or ERROR).
|
|
135
|
-
* Terminal messages are delivered after phase-2 in the same batch to prevent
|
|
136
|
-
* the node from becoming terminal before value messages reach sinks.
|
|
137
|
-
*
|
|
138
|
-
* @param t — Message type symbol.
|
|
139
|
-
* @returns `true` for `COMPLETE` or `ERROR`.
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```ts
|
|
143
|
-
* import { COMPLETE, ERROR, DATA, isTerminalMessage } from "@graphrefly/graphrefly-ts";
|
|
144
|
-
*
|
|
145
|
-
* isTerminalMessage(COMPLETE); // true
|
|
146
|
-
* isTerminalMessage(ERROR); // true
|
|
147
|
-
* isTerminalMessage(DATA); // false
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
declare function isTerminalMessage(t: symbol): boolean;
|
|
151
|
-
/**
|
|
152
|
-
* Whether `t` is a graph-local signal that should NOT cross a wire/transport
|
|
153
|
-
* boundary (SSE, WebSocket, worker bridge, persistence sinks).
|
|
154
|
-
*
|
|
155
|
-
* Local-only signals (tier 0–2): START, DIRTY, INVALIDATE, PAUSE, RESUME.
|
|
156
|
-
* These are internal to the reactive graph — subscribe handshakes,
|
|
157
|
-
* notification phases, and flow control have no semantics for remote consumers.
|
|
158
|
-
*
|
|
159
|
-
* Wire-crossing signals (tier 3+): DATA, RESOLVED, COMPLETE, ERROR, TEARDOWN.
|
|
160
|
-
* Unknown message types (spec §1.3.6 forward-compat) also cross the wire.
|
|
161
|
-
*
|
|
162
|
-
* Individual adapters may further opt-in to local signals for observability
|
|
163
|
-
* (e.g. SSE `includeDirty`, `includeResolved` options). Storage/persistence
|
|
164
|
-
* adapters that need INVALIDATE for remote cache-clear should explicitly
|
|
165
|
-
* forward it despite `isLocalOnly(INVALIDATE) === true`. The default is to
|
|
166
|
-
* skip all local-only signals at the boundary.
|
|
167
|
-
*
|
|
168
|
-
* @param t — Message type symbol.
|
|
169
|
-
* @returns `true` if the message should be kept local (not sent over wire).
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* ```ts
|
|
173
|
-
* import { START, DIRTY, DATA, COMPLETE, isLocalOnly } from "@graphrefly/graphrefly-ts";
|
|
174
|
-
*
|
|
175
|
-
* isLocalOnly(START); // true — subscribe handshake
|
|
176
|
-
* isLocalOnly(DIRTY); // true — notification phase
|
|
177
|
-
* isLocalOnly(RESOLVED); // false — value settlement crosses wire
|
|
178
|
-
* isLocalOnly(DATA); // false — value crosses wire
|
|
179
|
-
* isLocalOnly(COMPLETE); // false — terminal crosses wire
|
|
180
|
-
* ```
|
|
181
|
-
*
|
|
182
|
-
* @category core
|
|
183
|
-
*/
|
|
184
|
-
declare function isLocalOnly(t: symbol): boolean;
|
|
185
|
-
/**
|
|
186
|
-
* Whether `t` should be propagated from a parent node to its companion meta nodes.
|
|
187
|
-
* Only TEARDOWN propagates; COMPLETE/ERROR/INVALIDATE do not (meta outlives parent
|
|
188
|
-
* terminal state for post-mortem writes).
|
|
189
|
-
*
|
|
190
|
-
* @param t — Message type symbol.
|
|
191
|
-
* @returns `true` if the signal should reach meta nodes.
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```ts
|
|
195
|
-
* import { TEARDOWN, COMPLETE, ERROR, propagatesToMeta } from "@graphrefly/graphrefly-ts";
|
|
196
|
-
*
|
|
197
|
-
* propagatesToMeta(TEARDOWN); // true
|
|
198
|
-
* propagatesToMeta(COMPLETE); // false
|
|
199
|
-
* propagatesToMeta(ERROR); // false
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
declare function propagatesToMeta(t: symbol): boolean;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Who is performing an operation (attribution + ABAC input).
|
|
206
|
-
*
|
|
207
|
-
* @see GRAPHREFLY-SPEC — roadmap Phase 1.5 (Actor & Guard).
|
|
208
|
-
*/
|
|
209
|
-
type Actor = {
|
|
210
|
-
type: "human" | "llm" | "wallet" | "system" | string;
|
|
211
|
-
id: string;
|
|
212
|
-
} & Record<string, unknown>;
|
|
213
|
-
/** Default actor when none is passed ({@link normalizeActor}). */
|
|
214
|
-
declare const DEFAULT_ACTOR: Actor;
|
|
215
|
-
/**
|
|
216
|
-
* Fills missing `type` / `id` on an actor and returns {@link DEFAULT_ACTOR} when input is undefined.
|
|
217
|
-
*
|
|
218
|
-
* @param actor - Optional partial actor from a transport hint.
|
|
219
|
-
* @returns A normalized `Actor` safe to pass to guards and graph APIs.
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* ```ts
|
|
223
|
-
* import { normalizeActor } from "@graphrefly/graphrefly-ts";
|
|
224
|
-
*
|
|
225
|
-
* normalizeActor({ type: "human", id: "u1" });
|
|
226
|
-
* ```
|
|
227
|
-
*/
|
|
228
|
-
declare function normalizeActor(actor?: Actor): Actor;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Actions checked by {@link NodeGuard}. `write` covers both {@link Node.down} and
|
|
232
|
-
* {@link Node.up} today; finer-grained strings may be added later (e.g. `"write.data"`).
|
|
233
|
-
*/
|
|
234
|
-
type GuardAction = "write" | "signal" | "observe" | (string & {});
|
|
235
|
-
type NodeGuard = (actor: Actor, action: GuardAction) => boolean;
|
|
236
|
-
type GuardDeniedDetails = {
|
|
237
|
-
actor: Actor;
|
|
238
|
-
action: GuardAction;
|
|
239
|
-
/** Registry or options name when known */
|
|
240
|
-
nodeName?: string;
|
|
241
|
-
};
|
|
242
|
-
/**
|
|
243
|
-
* Thrown when a {@link NodeGuard} denies an action for a given actor.
|
|
244
|
-
*
|
|
245
|
-
* Carries the rejected `actor`, `action`, and optional `nodeName` for diagnostic
|
|
246
|
-
* messages and middleware error handling.
|
|
247
|
-
*
|
|
248
|
-
* @example
|
|
249
|
-
* ```ts
|
|
250
|
-
* import { GuardDenied, policy } from "@graphrefly/graphrefly-ts";
|
|
251
|
-
*
|
|
252
|
-
* const guard = policy((allow) => { allow("observe"); });
|
|
253
|
-
* try {
|
|
254
|
-
* if (!guard({ type: "llm", id: "agent-1" }, "write")) {
|
|
255
|
-
* throw new GuardDenied(
|
|
256
|
-
* { actor: { type: "llm", id: "agent-1" }, action: "write", nodeName: "userInput" },
|
|
257
|
-
* );
|
|
258
|
-
* }
|
|
259
|
-
* } catch (e) {
|
|
260
|
-
* if (e instanceof GuardDenied) console.error(e.action, e.actor.type); // "write" "llm"
|
|
261
|
-
* }
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
declare class GuardDenied extends Error {
|
|
265
|
-
readonly actor: Actor;
|
|
266
|
-
readonly action: GuardAction;
|
|
267
|
-
readonly nodeName?: string;
|
|
268
|
-
/**
|
|
269
|
-
* @param details - Actor, action, and optional node name for the denial.
|
|
270
|
-
* @param message - Optional override for the default error message.
|
|
271
|
-
*/
|
|
272
|
-
constructor(details: GuardDeniedDetails, message?: string);
|
|
273
|
-
/** Qualified registry path when known (roadmap diagnostics: same as {@link nodeName}). */
|
|
274
|
-
get node(): string | undefined;
|
|
275
|
-
}
|
|
276
|
-
type Where = (actor: Actor) => boolean;
|
|
277
|
-
type PolicyAllow = (action: GuardAction | readonly GuardAction[], opts?: {
|
|
278
|
-
where?: Where;
|
|
279
|
-
}) => void;
|
|
280
|
-
type PolicyDeny = (action: GuardAction | readonly GuardAction[], opts?: {
|
|
281
|
-
where?: Where;
|
|
282
|
-
}) => void;
|
|
283
|
-
type PolicyRuleData = {
|
|
284
|
-
effect: "allow" | "deny";
|
|
285
|
-
action: GuardAction | readonly GuardAction[];
|
|
286
|
-
actorType?: string | readonly string[];
|
|
287
|
-
actorId?: string | readonly string[];
|
|
288
|
-
claims?: Record<string, unknown>;
|
|
289
|
-
};
|
|
290
|
-
/**
|
|
291
|
-
* Declarative guard builder. Precedence: any matching **deny** blocks even if an allow also matches.
|
|
292
|
-
* If no rule matches, the guard returns `false` (deny-by-default). Aligned with graphrefly-py `policy()`.
|
|
293
|
-
*
|
|
294
|
-
* @param build - Callback that registers `allow(...)` / `deny(...)` rules in order.
|
|
295
|
-
* @returns A `NodeGuard` for use as `node({ guard })`.
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* ```ts
|
|
299
|
-
* const guard = policy((allow, deny) => {
|
|
300
|
-
* allow("observe");
|
|
301
|
-
* deny("write", { where: (a) => a.type === "llm" });
|
|
302
|
-
* });
|
|
303
|
-
* ```
|
|
304
|
-
*/
|
|
305
|
-
declare function policy(build: (allow: PolicyAllow, deny: PolicyDeny) => void): NodeGuard;
|
|
306
|
-
/**
|
|
307
|
-
* Rebuild a declarative guard from persisted policy data (snapshot-safe).
|
|
308
|
-
*
|
|
309
|
-
* Rules are deny-overrides, same semantics as {@link policy}.
|
|
310
|
-
*/
|
|
311
|
-
declare function policyFromRules(rules: readonly PolicyRuleData[]): NodeGuard;
|
|
312
|
-
/**
|
|
313
|
-
* Derives a best-effort `meta.access` hint string by probing `guard` with the
|
|
314
|
-
* standard actor types `human`, `llm`, `wallet`, `system` for the `"write"` action
|
|
315
|
-
* (roadmap 1.5). Aligned with graphrefly-py `access_hint_for_guard`.
|
|
316
|
-
*
|
|
317
|
-
* @param guard - Guard function to probe (typically from {@link policy}).
|
|
318
|
-
* @returns `"restricted"` when no standard type is allowed; `"both"` when both
|
|
319
|
-
* `human` and `llm` are allowed (plus optionally `system`); the single allowed
|
|
320
|
-
* type name when only one passes; or a `"+"` joined list otherwise.
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* ```ts
|
|
324
|
-
* import { policy, accessHintForGuard } from "@graphrefly/graphrefly-ts";
|
|
325
|
-
*
|
|
326
|
-
* const guardBoth = policy((allow) => { allow("write"); });
|
|
327
|
-
* accessHintForGuard(guardBoth); // "both"
|
|
328
|
-
*
|
|
329
|
-
* const guardHuman = policy((allow) => {
|
|
330
|
-
* allow("write", { where: (a) => a.type === "human" });
|
|
331
|
-
* });
|
|
332
|
-
* accessHintForGuard(guardHuman); // "human"
|
|
333
|
-
* ```
|
|
334
|
-
*/
|
|
335
|
-
declare function accessHintForGuard(guard: NodeGuard): string;
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Node versioning — GRAPHREFLY-SPEC §7.
|
|
339
|
-
*
|
|
340
|
-
* Progressive, optional versioning for node identity and change tracking.
|
|
341
|
-
*
|
|
342
|
-
* - **V0**: `id` + `version` — identity & change detection (~16 bytes overhead)
|
|
343
|
-
* - **V1**: + `cid` + `prev` — content addressing & linked history (~60 bytes overhead)
|
|
344
|
-
*
|
|
345
|
-
* **Lifecycle notes:**
|
|
346
|
-
* - Version advances only on DATA (not RESOLVED, INVALIDATE, or TEARDOWN).
|
|
347
|
-
* - `resetOnTeardown` clears the cached value but does NOT reset versioning state.
|
|
348
|
-
* After teardown, `v.cid` still reflects the last DATA value, not the cleared cache.
|
|
349
|
-
* The invariant `hash(node.get()) === v.cid` only holds in `settled`/`resolved` status.
|
|
350
|
-
* - Resubscribable nodes preserve versioning across subscription lifetimes (monotonic counter).
|
|
351
|
-
*/
|
|
352
|
-
/** V0: identity + monotonic version counter. */
|
|
353
|
-
type V0 = {
|
|
354
|
-
readonly id: string;
|
|
355
|
-
version: number;
|
|
356
|
-
};
|
|
357
|
-
/** V1: V0 + content-addressed identifier + previous cid link. */
|
|
358
|
-
type V1 = V0 & {
|
|
359
|
-
cid: string;
|
|
360
|
-
prev: string | null;
|
|
361
|
-
};
|
|
362
|
-
/** Union of all versioning info shapes. */
|
|
363
|
-
type NodeVersionInfo = V0 | V1;
|
|
364
|
-
/** Supported versioning levels (extensible to 2, 3 later). */
|
|
365
|
-
type VersioningLevel = 0 | 1;
|
|
366
|
-
/** Function that hashes a value to a hex string (for V1 cid). */
|
|
367
|
-
type HashFn = (value: unknown) => string;
|
|
368
|
-
interface VersioningOptions {
|
|
369
|
-
/** Override auto-generated id. */
|
|
370
|
-
id?: string;
|
|
371
|
-
/** Custom hash function for V1 cid (default: SHA-256 truncated to 16 hex chars). */
|
|
372
|
-
hash?: HashFn;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Default content hash: SHA-256 of deterministic JSON, truncated to 16 hex chars (~64-bit).
|
|
376
|
-
* Uses {@link canonicalizeForHash} for cross-language parity with Python `default_hash`.
|
|
377
|
-
*/
|
|
378
|
-
declare function defaultHash(value: unknown): string;
|
|
379
|
-
/**
|
|
380
|
-
* Create initial versioning state for a node.
|
|
381
|
-
*
|
|
382
|
-
* @param level - 0 for V0, 1 for V1.
|
|
383
|
-
* @param initialValue - The node's initial cached value (used for V1 cid).
|
|
384
|
-
* @param opts - Optional overrides (id, hash).
|
|
385
|
-
*/
|
|
386
|
-
declare function createVersioning(level: VersioningLevel, initialValue: unknown, opts?: VersioningOptions): NodeVersionInfo;
|
|
387
|
-
/**
|
|
388
|
-
* Advance versioning state after a DATA emission (value changed).
|
|
389
|
-
*
|
|
390
|
-
* Mutates `info` in place for performance (called on every DATA).
|
|
391
|
-
* Only call when the cached value has actually changed (not on RESOLVED).
|
|
392
|
-
*
|
|
393
|
-
* @param info - The node's current versioning state.
|
|
394
|
-
* @param newValue - The new cached value.
|
|
395
|
-
* @param hashFn - Hash function (only used for V1).
|
|
396
|
-
*/
|
|
397
|
-
declare function advanceVersion(info: NodeVersionInfo, newValue: unknown, hashFn: HashFn): void;
|
|
398
|
-
/** Type guard: is this V1 versioning info? */
|
|
399
|
-
declare function isV1(info: NodeVersionInfo): info is V1;
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* `NodeBase` — abstract class implementing the {@link Node} protocol with
|
|
403
|
-
* lifecycle machinery shared between {@link NodeImpl} (static deps) and
|
|
404
|
-
* {@link DynamicNodeImpl} (runtime-tracked deps).
|
|
405
|
-
*
|
|
406
|
-
* **Responsibilities (shared):**
|
|
407
|
-
* - Identity (name, describeKind, meta, guard, versioning)
|
|
408
|
-
* - Cache + status lifecycle (`_cached`, `_status`, `_terminal`)
|
|
409
|
-
* - Sink storage (null / single / Set fast paths)
|
|
410
|
-
* - `subscribe()` with START handshake + first-subscriber activation
|
|
411
|
-
* - `_downInternal` → `_downToSinks` delivery pipeline (via `downWithBatch`)
|
|
412
|
-
* - `_downAutoValue` (value → protocol framing with equals)
|
|
413
|
-
* - `_handleLocalLifecycle` (cached/status/terminal updates + meta propagation)
|
|
414
|
-
*
|
|
415
|
-
* **Subclass hooks (abstract):**
|
|
416
|
-
* - `_onActivate()` — called when sinkCount transitions 0 → 1
|
|
417
|
-
* - `_doDeactivate()` — cleanup on deactivation (at-most-once, guarded by `_onDeactivate`)
|
|
418
|
-
* - `up()` / `unsubscribe()` / `_upInternal()` — dep-iteration specifics
|
|
419
|
-
* - `_createMetaNode()` — meta companion factory (avoids circular imports)
|
|
420
|
-
*
|
|
421
|
-
* See GRAPHREFLY-SPEC §2 and COMPOSITION-GUIDE §1 for protocol contracts.
|
|
422
|
-
*/
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Internal sentinel value: "no cached value has been set or emitted."
|
|
426
|
-
* Used instead of `undefined` so that `undefined` can be a valid emitted value.
|
|
427
|
-
*/
|
|
428
|
-
declare const NO_VALUE: unique symbol;
|
|
429
|
-
/**
|
|
430
|
-
* Branded symbol that marks a {@link CleanupResult} wrapper — prevents
|
|
431
|
-
* duck-type collisions with domain objects that happen to have a `cleanup`
|
|
432
|
-
* property.
|
|
433
|
-
*/
|
|
434
|
-
declare const CLEANUP_RESULT: unique symbol;
|
|
435
|
-
/** Lifecycle status of a node (GRAPHREFLY-SPEC §2.2). */
|
|
436
|
-
type NodeStatus = "disconnected" | "pending" | "dirty" | "settled" | "resolved" | "completed" | "errored";
|
|
437
|
-
/** Callback that receives downstream message batches. */
|
|
438
|
-
type NodeSink = (messages: Messages) => void;
|
|
439
|
-
/** Imperative actions available inside a node's compute function. */
|
|
440
|
-
interface NodeActions {
|
|
441
|
-
/** Emit raw messages downstream. */
|
|
442
|
-
down(messages: Messages): void;
|
|
443
|
-
/** Emit a single value (auto-wraps in DIRTY/DATA or DIRTY/RESOLVED). */
|
|
444
|
-
emit(value: unknown): void;
|
|
445
|
-
/** Send messages upstream toward sources. */
|
|
446
|
-
up(messages: Messages): void;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Callback for intercepting messages before the default dispatch (§2.6).
|
|
450
|
-
*
|
|
451
|
-
* Called for every message from every dep. Return `true` to consume
|
|
452
|
-
* (skip default handling), or `false` to let default dispatch run.
|
|
453
|
-
*/
|
|
454
|
-
type OnMessageHandler = (msg: Message, depIndex: number, actions: NodeActions) => boolean;
|
|
455
|
-
/**
|
|
456
|
-
* Internal inspector hook (opt-in): emits dependency message and run events
|
|
457
|
-
* for graph-level observability features (`observe(..., { causal|derived })`).
|
|
458
|
-
*/
|
|
459
|
-
type NodeInspectorHookEvent = {
|
|
460
|
-
kind: "dep_message";
|
|
461
|
-
depIndex: number;
|
|
462
|
-
message: Message;
|
|
463
|
-
} | {
|
|
464
|
-
kind: "run";
|
|
465
|
-
depValues: readonly unknown[];
|
|
466
|
-
};
|
|
467
|
-
type NodeInspectorHook = (event: NodeInspectorHookEvent) => void;
|
|
468
|
-
/** Explicit describe `type` for {@link Graph.describe} (GRAPHREFLY-SPEC Appendix B). */
|
|
469
|
-
type NodeDescribeKind = "state" | "derived" | "producer" | "operator" | "effect";
|
|
470
|
-
/** Options accepted by every node constructor. */
|
|
471
|
-
interface NodeOptions {
|
|
472
|
-
name?: string;
|
|
473
|
-
/**
|
|
474
|
-
* Overrides inferred `type` in describe output. Sugar constructors set this;
|
|
475
|
-
* omit to infer from deps / fn / manual emit usage.
|
|
476
|
-
*/
|
|
477
|
-
describeKind?: NodeDescribeKind;
|
|
478
|
-
/** Equality check for RESOLVED detection. Defaults to `Object.is`. */
|
|
479
|
-
equals?: (a: unknown, b: unknown) => boolean;
|
|
480
|
-
initial?: unknown;
|
|
481
|
-
/**
|
|
482
|
-
* Each key becomes an independently subscribable companion node.
|
|
483
|
-
* Meta nodes outlive the parent's subscription lifecycle: when all sinks
|
|
484
|
-
* unsubscribe the parent deactivates but meta nodes stay alive.
|
|
485
|
-
* Send `[[TEARDOWN]]` to the parent to release meta node resources.
|
|
486
|
-
*/
|
|
487
|
-
meta?: Record<string, unknown>;
|
|
488
|
-
/** Allow fresh subscriptions after COMPLETE/ERROR. */
|
|
489
|
-
resubscribable?: boolean;
|
|
490
|
-
/**
|
|
491
|
-
* Invoked when a new {@link Node.subscribe} clears a terminal state on a
|
|
492
|
-
* resubscribable node — reset operator-local counters/accumulators here.
|
|
493
|
-
*/
|
|
494
|
-
onResubscribe?: () => void;
|
|
495
|
-
/** Clear cached value on TEARDOWN. */
|
|
496
|
-
resetOnTeardown?: boolean;
|
|
497
|
-
/**
|
|
498
|
-
* When `true` (default), auto-emit `[[COMPLETE]]` when all deps complete
|
|
499
|
-
* (spec §1.3.5). Set `false` for derived/operator nodes that should not
|
|
500
|
-
* auto-complete.
|
|
501
|
-
*/
|
|
502
|
-
completeWhenDepsComplete?: boolean;
|
|
503
|
-
/**
|
|
504
|
-
* Intercept messages before the default dispatch (spec §2.6).
|
|
505
|
-
*
|
|
506
|
-
* Return `true` to consume the message (skip default handling),
|
|
507
|
-
* or `false` to let the default dispatch run.
|
|
508
|
-
*/
|
|
509
|
-
onMessage?: OnMessageHandler;
|
|
510
|
-
/**
|
|
511
|
-
* ABAC: `(actor, action) => boolean`. `write` applies to both {@link Node.down} and {@link Node.up}.
|
|
512
|
-
* Companion {@link NodeOptions.meta | meta} nodes inherit this guard from the primary.
|
|
513
|
-
*/
|
|
514
|
-
guard?: NodeGuard;
|
|
515
|
-
/** Opt-in versioning level (GRAPHREFLY-SPEC §7). */
|
|
516
|
-
versioning?: VersioningLevel;
|
|
517
|
-
/** Override auto-generated versioning id. */
|
|
518
|
-
versioningId?: string;
|
|
519
|
-
/** Custom hash function for V1 cid computation. */
|
|
520
|
-
versioningHash?: HashFn;
|
|
521
|
-
}
|
|
522
|
-
/** Actor/delivery context for {@link Node.down} and {@link Node.up}. */
|
|
523
|
-
type NodeTransportOptions = {
|
|
524
|
-
actor?: Actor;
|
|
525
|
-
/**
|
|
526
|
-
* When `true`, skips guard checks (reactive internals, graph lifecycle TEARDOWN, etc.).
|
|
527
|
-
* Not for untrusted call sites.
|
|
528
|
-
*/
|
|
529
|
-
internal?: boolean;
|
|
530
|
-
/**
|
|
531
|
-
* `signal` for {@link Graph.signal} deliveries; default `write` for {@link Graph.set}
|
|
532
|
-
* and direct `down`.
|
|
533
|
-
*/
|
|
534
|
-
delivery?: "write" | "signal";
|
|
535
|
-
};
|
|
536
|
-
/** Optional hints passed to {@link Node.subscribe}. */
|
|
537
|
-
interface SubscribeHints {
|
|
538
|
-
/**
|
|
539
|
-
* Subscriber has exactly one dep with `fn` — the source may skip DIRTY
|
|
540
|
-
* dispatch when this is the sole subscriber. The subscriber synthesizes
|
|
541
|
-
* dirty state locally.
|
|
542
|
-
*/
|
|
543
|
-
singleDep?: boolean;
|
|
544
|
-
/**
|
|
545
|
-
* Actor to check against the node's `observe` guard. When set,
|
|
546
|
-
* `subscribe()` throws {@link GuardDenied} if the actor is not permitted
|
|
547
|
-
* to observe this node.
|
|
548
|
-
*/
|
|
549
|
-
actor?: Actor;
|
|
550
|
-
}
|
|
551
|
-
/** A reactive node in the GraphReFly protocol. */
|
|
552
|
-
interface Node<T = unknown> {
|
|
553
|
-
readonly name?: string;
|
|
554
|
-
readonly status: NodeStatus;
|
|
555
|
-
readonly meta: Record<string, Node>;
|
|
556
|
-
/** Returns the current cached value. */
|
|
557
|
-
get(): T | undefined;
|
|
558
|
-
/** Push messages downstream. */
|
|
559
|
-
down(messages: Messages, options?: NodeTransportOptions): void;
|
|
560
|
-
/**
|
|
561
|
-
* Registers a sink to receive downstream messages.
|
|
562
|
-
*
|
|
563
|
-
* @param sink - Callback receiving message batches.
|
|
564
|
-
* @param hints - Optional optimization hints (e.g. `{ singleDep: true }`).
|
|
565
|
-
* @returns An unsubscribe function (idempotent).
|
|
566
|
-
*/
|
|
567
|
-
subscribe(sink: NodeSink, hints?: SubscribeHints): () => void;
|
|
568
|
-
/** Send messages upstream (present on nodes with deps). */
|
|
569
|
-
up?: (messages: Messages, options?: NodeTransportOptions) => void;
|
|
570
|
-
/** Disconnect from upstream deps (present on nodes with deps). */
|
|
571
|
-
unsubscribe?: () => void;
|
|
572
|
-
/** Last successful guarded `down` / `up` (not set for `internal` deliveries). */
|
|
573
|
-
readonly lastMutation?: Readonly<{
|
|
574
|
-
actor: Actor;
|
|
575
|
-
timestamp_ns: number;
|
|
576
|
-
}>;
|
|
577
|
-
/** Whether `actor` may {@link Graph.observe} this node. */
|
|
578
|
-
allowsObserve(actor: Actor): boolean;
|
|
579
|
-
/** Whether a {@link NodeOptions.guard | guard} is installed. */
|
|
580
|
-
hasGuard(): boolean;
|
|
581
|
-
/** Versioning info (GRAPHREFLY-SPEC §7). `undefined` when versioning is not enabled. */
|
|
582
|
-
readonly v: Readonly<NodeVersionInfo> | undefined;
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* Explicit cleanup wrapper. When a node fn returns `{ cleanup, value? }`,
|
|
586
|
-
* `cleanup` is registered as the teardown/recompute cleanup and `value`
|
|
587
|
-
* (if present) is emitted as data. This avoids the ambiguity where returning
|
|
588
|
-
* a plain function is silently consumed as cleanup instead of emitted as data.
|
|
589
|
-
*/
|
|
590
|
-
type CleanupResult<T = unknown> = {
|
|
591
|
-
readonly [CLEANUP_RESULT]: true;
|
|
592
|
-
cleanup: () => void;
|
|
593
|
-
value?: T;
|
|
594
|
-
};
|
|
595
|
-
/** Create a branded {@link CleanupResult}. */
|
|
596
|
-
declare function cleanupResult<T>(cleanup: () => void): CleanupResult<T>;
|
|
597
|
-
declare function cleanupResult<T>(cleanup: () => void, value: T): CleanupResult<T>;
|
|
598
|
-
/**
|
|
599
|
-
* Abstract base class for every node in the graph. Both {@link NodeImpl}
|
|
600
|
-
* (static deps) and {@link DynamicNodeImpl} (runtime-tracked deps) extend
|
|
601
|
-
* this to share subscribe/sink/lifecycle machinery.
|
|
602
|
-
*
|
|
603
|
-
* Invariants (see GRAPHREFLY-SPEC §2.2):
|
|
604
|
-
* - `_sinkCount` always reflects the size of `_sinks`.
|
|
605
|
-
* - `_cached === NO_VALUE` iff the node has never produced a value (SENTINEL).
|
|
606
|
-
* - `_terminal` is set exactly once (per subscription cycle for resubscribable).
|
|
607
|
-
* - `_onActivate` runs exactly once per activation cycle; `_doDeactivate`
|
|
608
|
-
* runs at most once per deactivation (guarded by `_active` flag).
|
|
609
|
-
*
|
|
610
|
-
* ROM/RAM rule (GRAPHREFLY-SPEC §2.2): state nodes (no fn) preserve `_cached`
|
|
611
|
-
* across disconnect — intrinsic, non-volatile. Compute nodes (derived,
|
|
612
|
-
* producer, dynamic) clear `_cached` on disconnect in their subclass
|
|
613
|
-
* `_doDeactivate` — their value is a function of live subscriptions.
|
|
614
|
-
*/
|
|
615
|
-
declare abstract class NodeBase<T = unknown> implements Node<T> {
|
|
616
|
-
protected readonly _optsName: string | undefined;
|
|
617
|
-
private _registryName;
|
|
618
|
-
/** @internal Read by `describeNode` before inference. */
|
|
619
|
-
readonly _describeKind: NodeDescribeKind | undefined;
|
|
620
|
-
readonly meta: Record<string, Node>;
|
|
621
|
-
protected readonly _equals: (a: unknown, b: unknown) => boolean;
|
|
622
|
-
protected readonly _resubscribable: boolean;
|
|
623
|
-
protected readonly _resetOnTeardown: boolean;
|
|
624
|
-
protected readonly _onResubscribe: (() => void) | undefined;
|
|
625
|
-
protected readonly _onMessage: OnMessageHandler | undefined;
|
|
626
|
-
/** @internal Read by `describeNode` for `accessHintForGuard`. */
|
|
627
|
-
readonly _guard: NodeGuard | undefined;
|
|
628
|
-
/** @internal Subclasses update this through {@link _recordMutation}. */
|
|
629
|
-
protected _lastMutation: {
|
|
630
|
-
actor: Actor;
|
|
631
|
-
timestamp_ns: number;
|
|
632
|
-
} | undefined;
|
|
633
|
-
protected _hashFn: HashFn;
|
|
634
|
-
private _versioning;
|
|
635
|
-
/** @internal Read by `describeNode` and `graph.ts`. */
|
|
636
|
-
_cached: T | typeof NO_VALUE;
|
|
637
|
-
/** @internal Read externally via `get status()`. */
|
|
638
|
-
_status: NodeStatus;
|
|
639
|
-
protected _terminal: boolean;
|
|
640
|
-
private _active;
|
|
641
|
-
/** @internal Read by `graph/profile.ts` for subscriber counts. */
|
|
642
|
-
_sinkCount: number;
|
|
643
|
-
protected _singleDepSinkCount: number;
|
|
644
|
-
protected _singleDepSinks: WeakSet<NodeSink>;
|
|
645
|
-
protected _sinks: NodeSink | Set<NodeSink> | null;
|
|
646
|
-
protected readonly _actions: NodeActions;
|
|
647
|
-
protected readonly _boundDownToSinks: (messages: Messages) => void;
|
|
648
|
-
private _inspectorHook;
|
|
649
|
-
constructor(opts: NodeOptions);
|
|
650
|
-
/**
|
|
651
|
-
* Subclass hook invoked by `actions.down` / `actions.emit`. Default no-op;
|
|
652
|
-
* {@link NodeImpl} overrides to set `_manualEmitUsed`.
|
|
653
|
-
*/
|
|
654
|
-
protected _onManualEmit(): void;
|
|
655
|
-
/**
|
|
656
|
-
* Create a companion meta node. Called from the base constructor; must
|
|
657
|
-
* not touch subclass fields that haven't been initialized yet (safe to
|
|
658
|
-
* read from `opts`).
|
|
659
|
-
*/
|
|
660
|
-
protected abstract _createMetaNode(key: string, initialValue: unknown, opts: NodeOptions): Node;
|
|
661
|
-
get name(): string | undefined;
|
|
662
|
-
/** @internal Assigned by `Graph.add` when registered without an options `name`. */
|
|
663
|
-
_assignRegistryName(localName: string): void;
|
|
664
|
-
/**
|
|
665
|
-
* @internal Attach/remove inspector hook for graph-level observability.
|
|
666
|
-
* Returns a disposer that restores the previous hook.
|
|
667
|
-
*/
|
|
668
|
-
_setInspectorHook(hook?: NodeInspectorHook): () => void;
|
|
669
|
-
/** @internal Used by subclasses to surface inspector events. */
|
|
670
|
-
protected _emitInspectorHook(event: NodeInspectorHookEvent): void;
|
|
671
|
-
get status(): NodeStatus;
|
|
672
|
-
get lastMutation(): Readonly<{
|
|
673
|
-
actor: Actor;
|
|
674
|
-
timestamp_ns: number;
|
|
675
|
-
}> | undefined;
|
|
676
|
-
get v(): Readonly<NodeVersionInfo> | undefined;
|
|
677
|
-
/** @internal Used by `Graph.setVersioning` to retroactively apply versioning. */
|
|
678
|
-
_applyVersioning(level: VersioningLevel, opts?: {
|
|
679
|
-
id?: string;
|
|
680
|
-
hash?: HashFn;
|
|
681
|
-
}): void;
|
|
682
|
-
hasGuard(): boolean;
|
|
683
|
-
allowsObserve(actor: Actor): boolean;
|
|
684
|
-
get(): T | undefined;
|
|
685
|
-
down(messages: Messages, options?: NodeTransportOptions): void;
|
|
686
|
-
/** @internal Record a successful guarded mutation (called by `down` and subclass `up`). */
|
|
687
|
-
protected _recordMutation(actor: Actor): void;
|
|
688
|
-
/** Abstract — subclasses forward messages to dependencies (or no-op for sources). */
|
|
689
|
-
abstract up(messages: Messages, options?: NodeTransportOptions): void;
|
|
690
|
-
/** Abstract — subclasses release upstream subscriptions (or no-op for sources). */
|
|
691
|
-
abstract unsubscribe(): void;
|
|
692
|
-
/** Internal upstream-send used by `actions.up`. */
|
|
693
|
-
protected abstract _upInternal(messages: Messages): void;
|
|
694
|
-
/** Called when `_sinkCount` transitions 0 → 1. */
|
|
695
|
-
protected abstract _onActivate(): void;
|
|
696
|
-
/**
|
|
697
|
-
* At-most-once deactivation guard. Both TEARDOWN (eager) and
|
|
698
|
-
* unsubscribe-body (lazy) call this. The `_active` flag ensures
|
|
699
|
-
* `_doDeactivate` runs exactly once per activation cycle.
|
|
700
|
-
*/
|
|
701
|
-
protected _onDeactivate(): void;
|
|
702
|
-
/** Subclass hook: cleanup on deactivation (called at most once). */
|
|
703
|
-
protected abstract _doDeactivate(): void;
|
|
704
|
-
subscribe(sink: NodeSink, hints?: SubscribeHints): () => void;
|
|
705
|
-
/**
|
|
706
|
-
* Core outgoing dispatch. Applies terminal filter + local lifecycle
|
|
707
|
-
* update, then hands messages to `downWithBatch` for tier-aware delivery.
|
|
708
|
-
*/
|
|
709
|
-
protected _downInternal(messages: Messages): void;
|
|
710
|
-
protected _canSkipDirty(): boolean;
|
|
711
|
-
protected _downToSinks(messages: Messages): void;
|
|
712
|
-
/**
|
|
713
|
-
* Update `_cached`, `_status`, `_terminal` from message batch before
|
|
714
|
-
* delivery. Subclass hooks `_onInvalidate` / `_onTeardown` let
|
|
715
|
-
* {@link NodeImpl} clear `_lastDepValues` and invoke cleanup fns.
|
|
716
|
-
*/
|
|
717
|
-
protected _handleLocalLifecycle(messages: Messages): void;
|
|
718
|
-
/**
|
|
719
|
-
* Subclass hook: invoked when INVALIDATE arrives (before `_cached` is
|
|
720
|
-
* cleared). {@link NodeImpl} uses this to run the fn cleanup fn and
|
|
721
|
-
* drop `_lastDepValues` so the next wave re-runs fn.
|
|
722
|
-
*/
|
|
723
|
-
protected _onInvalidate(): void;
|
|
724
|
-
/**
|
|
725
|
-
* Subclass hook: invoked when TEARDOWN arrives, before `_onDeactivate`.
|
|
726
|
-
* {@link NodeImpl} uses this to run any pending cleanup fn.
|
|
727
|
-
*/
|
|
728
|
-
protected _onTeardown(): void;
|
|
729
|
-
/** Forward a signal to all companion meta nodes (best-effort). */
|
|
730
|
-
protected _propagateToMeta(t: symbol): void;
|
|
731
|
-
/**
|
|
732
|
-
* Frame a computed value into the right protocol messages and dispatch
|
|
733
|
-
* via `_downInternal`. Used by `_runFn` and `actions.emit`.
|
|
734
|
-
*/
|
|
735
|
-
protected _downAutoValue(value: unknown): void;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
/** JSON-shaped slice of a node for Phase 1 `Graph.describe()` (GRAPHREFLY-SPEC §3.6, Appendix B). */
|
|
739
|
-
type DescribeNodeOutput = {
|
|
740
|
-
type: "state" | "derived" | "producer" | "operator" | "effect";
|
|
741
|
-
status?: Node["status"];
|
|
742
|
-
deps: string[];
|
|
743
|
-
meta?: Record<string, unknown>;
|
|
744
|
-
name?: string;
|
|
745
|
-
value?: unknown;
|
|
746
|
-
/** True when the node has never received or been initialized with a value (cache holds SENTINEL). */
|
|
747
|
-
sentinel?: boolean;
|
|
748
|
-
/** Node versioning info (GRAPHREFLY-SPEC §7). Present only when versioning is enabled. */
|
|
749
|
-
v?: {
|
|
750
|
-
id: string;
|
|
751
|
-
version: number;
|
|
752
|
-
cid?: string;
|
|
753
|
-
prev?: string | null;
|
|
754
|
-
};
|
|
755
|
-
/** Guard info (full detail). */
|
|
756
|
-
guard?: string;
|
|
757
|
-
/** Last mutation attribution (full detail). */
|
|
758
|
-
lastMutation?: Readonly<{
|
|
759
|
-
actor: Actor;
|
|
760
|
-
timestamp_ns: number;
|
|
761
|
-
}>;
|
|
762
|
-
};
|
|
763
|
-
/**
|
|
764
|
-
* Detail level for `describe()` progressive disclosure (Phase 3.3b).
|
|
765
|
-
* - `"minimal"` — type + deps only (default). LLM-friendly.
|
|
766
|
-
* - `"standard"` — type, status, value, deps, meta, versioning (`v`).
|
|
767
|
-
* - `"full"` — standard + guard, lastMutation.
|
|
768
|
-
*/
|
|
769
|
-
type DescribeDetail = "minimal" | "standard" | "full";
|
|
770
|
-
/**
|
|
771
|
-
* Valid field names for `describe({ fields: [...] })` (Phase 3.3b).
|
|
772
|
-
* Dotted paths like `"meta.label"` select specific meta keys.
|
|
773
|
-
*/
|
|
774
|
-
type DescribeField = "type" | "status" | "value" | "deps" | "meta" | "v" | "guard" | "lastMutation" | `meta.${string}`;
|
|
775
|
-
/** Resolve which fields to include based on detail level or explicit field list. */
|
|
776
|
-
declare function resolveDescribeFields(detail?: DescribeDetail, fields?: readonly DescribeField[]): Set<string> | null;
|
|
777
|
-
|
|
778
|
-
export { normalizeActor as $, type Actor as A, accessHintForGuard as B, CLEANUP_RESULT as C, DATA as D, ERROR as E, advanceVersion as F, type GuardAction as G, type HashFn as H, INVALIDATE as I, cleanupResult as J, createVersioning as K, defaultHash as L, type Message as M, type Node as N, type OnMessageHandler as O, PAUSE as P, isKnownMessageType as Q, RESOLVED as R, START as S, TEARDOWN as T, isLocalOnly as U, type V0 as V, isPhase2Message as W, isTerminalMessage as X, isV1 as Y, knownMessageTypes as Z, messageTier as _, type NodeOptions as a, policy as a0, policyFromRules as a1, propagatesToMeta as a2, resolveDescribeFields as a3, NodeBase as a4, type NodeActions as b, COMPLETE as c, type CleanupResult as d, DEFAULT_ACTOR as e, DIRTY as f, type DescribeDetail as g, type DescribeField as h, type DescribeNodeOutput as i, GuardDenied as j, type GuardDeniedDetails as k, type Messages as l, type NodeDescribeKind as m, type NodeGuard as n, type NodeSink as o, type NodeStatus as p, type NodeTransportOptions as q, type NodeVersionInfo as r, type PolicyAllow as s, type PolicyDeny as t, type PolicyRuleData as u, RESUME as v, type SubscribeHints as w, type V1 as x, type VersioningLevel as y, type VersioningOptions as z };
|