@zakkster/lite-signal 1.6.0-beta → 1.6.0-beta-1

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/CHANGELOG.md CHANGED
@@ -4,6 +4,46 @@ All notable changes to `@zakkster/lite-signal` are documented here.
4
4
  Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
  This project follows [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [1.6.0-beta-1] -- 2026-08-20
8
+
9
+ Backports the **1.4.5 `createRegistry` input validation** (all four findings) onto
10
+ the 1.6.0-beta engine. Supersedes 1.6.0-beta. Only `createRegistry`'s *cold*
11
+ construction path changed -- the hot paths are byte-identical and the zero-GC gates
12
+ (`bench/torture/run.mjs` 22/22) are unchanged. If you had a typo in your registry
13
+ config, you will now hear about it.
14
+
15
+ ### Added -- createRegistry validates its config (fail closed)
16
+
17
+ - **Bounded eager construction.** `prealloc:"eager"` with a non-finite or absurd
18
+ capacity (`maxNodes:Infinity`, `maxNodes:1e9`) previously ran an unbounded
19
+ construction loop and killed the process with an **uncatchable SIGABRT**. It now
20
+ throws a `TypeError` **by name**, before allocating, gated on `(maxNodes+maxLinks)`
21
+ against a ceiling of `1<<24` (16,777,216) objects. `prealloc:"lazy"` keeps its
22
+ unbounded on-demand ledger, untouched.
23
+ - **Per-option validation by name.** `maxNodes` / `maxLinks` / `maxFlushPasses` must
24
+ be finite integers `>= 1`; `prealloc` must be exactly `"eager"` | `"lazy"`;
25
+ `onCapacityExceeded` must be exactly `"throw"` | `"grow"`. Each bad value throws a
26
+ `TypeError` prefixed `createRegistry: "<option>"` at construction -- not a delayed
27
+ internal `nextFree` TypeError on first use.
28
+ - **Config-shape gate.** A non-object, `null`, or array `config` throws
29
+ `createRegistry: "config"` rather than dying later.
30
+ - **Unknown-key rejection with did-you-mean.** An unrecognized key throws with a
31
+ Levenshtein suggestion (`maxNods` -> `maxNodes`, `preAlloc` -> `prealloc`) instead
32
+ of being silently ignored.
33
+ - **`stats()` gains `nodePoolPopulation` / `linkPoolPopulation`** -- the TRUE count
34
+ of physically constructed nodes/links, distinct from the `*Capacity` ledgers. A
35
+ silently mis-set `prealloc` is now observable (population 0 under lazy) instead of
36
+ telemetry-blind. **The one observable API change: `stats()` grows to 14 keys,
37
+ purely additive** -- no existing key changed; only an exact key-*count* assertion
38
+ is affected (updated in `test/03-pool.test.mjs`).
39
+
40
+ ### Tests
41
+
42
+ New `test/*-config-validation.test.mjs` adds the full config matrix, the did-you-mean
43
+ cases, the eager ceiling, the population contract, and the three OOM rows as isolated
44
+ child-process cases proving the fixed engine throws + exits 0 under a 256 MB cap where
45
+ the unvalidated engine died.
46
+
7
47
  ## [1.6.0-beta] -- 2026-07-27
8
48
 
9
49
  Promotes `1.6.0-alpha.0` to the `beta` dist-tag. The engine gains one behavioural
@@ -14,9 +54,12 @@ opcodes are carried forward from alpha.0 unchanged.
14
54
 
15
55
  ### Added -- torture suite completed: `introspect-torture`, and `scope-torture` now runs
16
56
 
17
- `bench/torture/run.mjs` now registers **17 scenarios (14 semantic + 3 soak)** --
18
- the forward-compatible superset through 1.9. Two changes matter on the 1.6.0
19
- engine specifically. First, **`scope-torture`** -- present but feature-skipped on
57
+ `bench/torture/run.mjs` now registers **22 scenarios (19 semantic + 3 soak)** --
58
+ full parity with the shipped 1.4.4 sibling, the forward-compatible superset
59
+ through 1.9. This is a **verification-only** parity pass: the engine
60
+ (`Signal.js` / `Signal.d.ts`) is **UNCHANGED** -- byte-identical shasum before
61
+ and after. Two changes matter on the 1.6.0 engine
62
+ specifically. First, **`scope-torture`** -- present but feature-skipped on
20
63
  the 1.5.0 line -- now **executes**, since `createScope` exists: it fuzzes the
21
64
  adoption contract (computeds/effects adopted, plain signals not; the
22
65
  `signals + computeds + effects === activeNodes` invariant), the disposal-crash
@@ -36,8 +79,27 @@ and the op-3/op-4 link lane) and **the ABA gen-stamp guard** (a descriptor
36
79
  captured before a node is disposed and its slot recycled must resolve to nothing,
37
80
  never the new resident -- the only scenario that catches this guard's removal).
38
81
 
82
+ Beyond `scope-torture` and `introspect-torture`, five further scenarios are
83
+ ported from the 1.4.4 sibling to close the parity gap: **`lifecycle-torture`**
84
+ (createRoot detachment + destroy registry reset), **`owner-torture`** (getOwner /
85
+ runWithOwner capture-restore, live-adoption cascade, and stale-handle ABA
86
+ degradation to rooted), **`error-torture`** (throwing effect bodies: per-effect
87
+ buffering, single re-throw vs `AggregateError`, and a 4096-cycle buffer drain),
88
+ **`deep-chain-torture`** (pullComputed recursion fail-closed with a `RangeError`
89
+ vs the iterative push path), and **`zerogc-torture`** (the zero-GC hot path made
90
+ falsifiable via `measureAllocs` / `measureOps` + `stats()` counters, with a
91
+ `ZEROGC_BREAK` self-test). Because 1.6.0 ships `createScope` / `getOwner` /
92
+ `runWithOwner` / `createRoot` **natively**, the owner/scope/createRoot scenarios
93
+ that SKIPPED on 1.4.4 (which lacks `createScope`) **run natively here** and passed
94
+ exactly as written -- no assertion needed pinning to a divergent behaviour; the
95
+ `churn-box` lane in `zerogc-torture` activates because `signalBox` exists. The
96
+ three soaks (`graph-fuzzer`, `scheduler-bench`, `torture-soak`) gain a
97
+ value-correctness oracle: a preallocated `Int32Array` shadow of every signal,
98
+ checked over a rotating window per tick and swept in full at teardown, alongside
99
+ the existing liveness assertions and the module-scoped int32 JIT sink.
100
+
39
101
  Every scenario feature-detects and **skips cleanly** below the engine version
40
- that introduces its feature, so on the 1.6.0 engine the runner executes **11
102
+ that introduces its feature, so on the 1.6.0 engine the runner executes **16
41
103
  semantic** scenarios and reports a clean SKIP for the three later-version ones
42
104
  (`flush-torture` 1.7.0, `cleanup-return-torture` 1.8.0, `dispose-torture` 1.9.0).
43
105
 
@@ -49,16 +111,25 @@ It is renamed to `test/29-scope.test.mjs`. Both always ran under the
49
111
  `test/*.test.mjs` glob; the rename only restores the one-file-per-number
50
112
  convention.
51
113
 
114
+ A new unit file **`test/30-throwing-equals.test.mjs`** (numbered 30 -- 28 is
115
+ still occupied by both `28-run-with-owner` and the renamed history, and 29 is
116
+ taken) pins the behaviour of a user `equals` predicate that throws. It covers all
117
+ five physical `eq()` sites: the three callable sites (signal set pre-check
118
+ :1105, batch-revert check :1112, computed re-eval :986) with a contrast
119
+ anti-tautology test, plus the two `signalBox` boxSet sites (pre-check :1210,
120
+ revert :1217) -- confirmed to behave identically to the callable path.
121
+
52
122
  ### Verified -- full suite green on the 1.6.0 engine (Node 22, `--expose-gc`)
53
123
 
54
- - **Torture:** 17/17 -- `torture:semantic` 14/14 (11 executed, 3 clean skips),
55
- `torture:soak` 3/3 (zero errors, every pool back to its leaf-only floor).
56
- - **Unit:** 467 tests, 456 pass, 0 fail, 1 skip (the architectural SSR N/A in
57
- `17-reactivity`). The 1 skip aside, the only non-passes are the 10 in
58
- `test/25-devtools-real-boot`, the real-rig that requires the sibling
59
- `@zakkster/lite-devtools`; with that sibling resolvable the suite is 466 pass +
60
- 1 skip. Up from alpha.0's 447 total -- the delta is the crash-fix regression
61
- test and the branch-coverage-closure tests below.
124
+ - **Torture:** 22/22 -- `torture:semantic` 19/19 (16 executed, 3 clean skips),
125
+ `torture:soak` 3/3 (zero errors, value oracle clean, every pool back to its
126
+ leaf-only floor).
127
+ - **Unit:** 472 tests, 471 pass, 0 fail, 1 skip (the architectural SSR N/A in
128
+ `17-reactivity`), measured with the sibling `@zakkster/lite-devtools` resolvable
129
+ so the 10-test `test/25-devtools-real-boot` real-rig runs. The +9 over the
130
+ previous cut is the new `test/30-throwing-equals.test.mjs` (throwing-`equals`
131
+ site audit). Without the devtools sibling the 10 real-boot tests do not pass;
132
+ that rig is the only sibling-dependent surface.
62
133
 
63
134
  ### Removed -- `bench-reactive-legacy` (deprecated in 1.5.0)
64
135
 
package/README.md CHANGED
@@ -816,6 +816,7 @@ Three tiers, all reproducible.
816
816
  - **`27-create-root.test.mjs`** -- `createRoot` (1.5.0), the ownership escape hatch. A watcher spawned inside a consumer effect via `createRoot` survives the consumer's re-run (the exact `lite-query` lazy-watcher pattern); the contrast case confirms an *unwrapped* spawn is cascade-disposed; `createRoot` returns `fn`'s value, detaches tracking in `fn`'s direct body while inner effect bodies still track, and composes with box handles.
817
817
  - **`25-devtools-real-boot.test.mjs`** -- Devtools/Studio contract (10 tests). Boots the actual `Devtools.js` against the 1.5.0 engine and exercises all 19 Devtools exports plus the 10 symbols Studio imports from Devtools. Pins the ghost contract: heavy introspection (graph walk, owner-tree, observer descriptors) adds **zero** nodes to the live graph. Catches the real-rig failure mode where importing the package by its own name from a repo whose `package.json` declares `name: "@zakkster/lite-signal"` resolves to the published build instead of the local engine.
818
818
  - **`26-free-list-invariant.test.mjs`** -- the 1.2.2 audit's cleanliness pins (3 invariant tests + 1 targeted coverage test). Asserts directly -- by inspecting freshly-allocated nodes through the documented `describe()` -> `NODE_PTR` introspection protocol -- that the `ReactiveNode` constructor and the fresh-pool-growth path initialize the ten fields the audit removed from `createNode` to identical values, so the deleted writes were defending against a state the engine cannot produce on a clean free list. The 4th test covers the swallow-on-self-dispose-then-throw branch in `pullComputed` (the path that lifted branch coverage from 98.07% to 98.43%).
819
+ - **`30-throwing-equals.test.mjs`** -- a user `equals` predicate that throws, pinned at all five physical `eq()` sites (9 tests). The three callable sites -- signal set pre-check, batch-revert check, computed re-eval -- with a contrast anti-tautology test proving the pinned batch-revert behaviour is caused by the throw and not the set-then-back shape; plus the two `signalBox` boxSet sites (pre-check + revert), confirmed to behave identically to the callable path. Pins that a throwing pre-check leaves the value unmutated and fires no downstream, and that a throwing batch-revert propagates the net value with the version bump stranded.
819
820
 
820
821
  ```bash
821
822
  npm test
@@ -846,13 +847,17 @@ npm run bench
846
847
 
847
848
  ### Tier 4 -- Torture (correctness and resources under chaos)
848
849
 
849
- `bench/torture/` holds the complete **17-scenario superset (14 semantic + 3
850
- soak)** behind one runner (`run.mjs`), the forward-compatible set through 1.9.
851
- They are not perf benchmarks: the ops/sec figures reflect random workload
852
- composition, not engine throughput -- `bench/benchmark.mjs` remains the canonical
853
- perf harness. Every scenario feature-detects and **skips cleanly** below the
854
- engine version that introduces its feature, so on the 1.6.0 engine the runner
855
- executes **11 semantic** scenarios and reports a clean SKIP for the three
850
+ `bench/torture/` holds the complete **22-scenario superset (19 semantic + 3
851
+ soak)** behind one runner (`run.mjs`), the forward-compatible set through 1.9 --
852
+ full parity with the shipped 1.4.4 sibling (verification-only; the engine is
853
+ unchanged). They are not perf benchmarks: the ops/sec figures reflect random
854
+ workload composition, not engine throughput -- `bench/benchmark.mjs` remains the
855
+ canonical perf harness. Every scenario feature-detects and **skips cleanly** below
856
+ the engine version that introduces its feature, so on the 1.6.0 engine the runner
857
+ executes **16 semantic** scenarios (including `lifecycle-torture`, `owner-torture`,
858
+ `error-torture`, `deep-chain-torture`, and `zerogc-torture` -- the owner/scope/
859
+ createRoot scenarios run natively here because 1.6.0 ships `createScope` /
860
+ `getOwner` / `runWithOwner` / `createRoot`) and reports a clean SKIP for the three
856
861
  later-version ones (`flush-torture` 1.7.0, `cleanup-return-torture` 1.8.0,
857
862
  `dispose-torture` 1.9.0).
858
863
 
package/Signal.d.ts CHANGED
@@ -122,6 +122,16 @@ export interface RegistryStats {
122
122
  /** Node-pool capacity ledger. Doubles under the `"grow"` policy; under `"lazy"`
123
123
  * prealloc it may exceed the count of physically constructed nodes. */
124
124
  nodePoolCapacity: number;
125
+ /** TRUE node-pool population: the number of `ReactiveNode`s physically constructed
126
+ * (`nodePool.length`), distinct from the `nodePoolCapacity` ledger. Under
127
+ * `prealloc:"lazy"` (or a silently-flipped `prealloc` typo) this stays 0 until
128
+ * first demand while capacity reads the ledger -- so a mis-set `prealloc` is
129
+ * observable here rather than telemetry-blind. Added in the 1.4.5 backport. */
130
+ nodePoolPopulation: number;
131
+ /** TRUE link-pool population: the number of `ReactiveLink`s physically constructed
132
+ * (`linkPool.length`), distinct from the `linkPoolCapacity` ledger. Added in the
133
+ * 1.4.5 backport. */
134
+ linkPoolPopulation: number;
125
135
  /** Number of nodes currently allocated (signals + computeds + alive effects). */
126
136
  activeNodes: number;
127
137
  /**
package/Signal.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @zakkster/lite-signal v1.6.0-beta
2
+ * @zakkster/lite-signal v1.6.0-beta-1
3
3
  * --------------------
4
4
  * Hybrid Doubly-Linked-List Reactive Graph Engine -- decoupled (Signal1_3) base
5
5
  * with the two 1.1.3 performance fixes ported in:
@@ -209,10 +209,134 @@ export class CapacityError extends Error {
209
209
  * Error prefixed `"CycleError:"`.
210
210
  * @returns {Registry}
211
211
  */
212
+ /** The only config keys {@link createRegistry} recognizes. Anything else is
213
+ * rejected at construction with a did-you-mean hint (fail closed on an
214
+ * unverified state -- an unknown key is an error, never a silent ignore). */
215
+ const ALLOWED_KEYS = ["maxNodes", "maxLinks", "prealloc", "onCapacityExceeded", "maxFlushPasses"];
216
+
217
+ /** Ceiling on eager pool construction: `(maxNodes + maxLinks)` objects. A finite
218
+ * but absurd `maxNodes` (e.g. `1e9`, a plausible typo for `1e5`) that would
219
+ * otherwise OOM the process is refused BY NAME at construction rather than
220
+ * allocating forever. Only the `"eager"` path is bounded; `"lazy"` keeps its
221
+ * unbounded ledger. `1 << 24` == 16777216. */
222
+ const EAGER_CONSTRUCT_CEILING = 1 << 24;
223
+
224
+ /**
225
+ * Levenshtein edit distance between two short strings. Cold: called only on the
226
+ * constructor error path, over the known option names, so its per-call array
227
+ * allocation never touches any hot path.
228
+ * @param {string} a
229
+ * @param {string} b
230
+ * @returns {number}
231
+ */
232
+ function editDistance(a, b) {
233
+ const m = a.length;
234
+ const n = b.length;
235
+ const prev = new Array(n + 1);
236
+ const cur = new Array(n + 1);
237
+ for (let j = 0; j <= n; j++) prev[j] = j;
238
+ for (let i = 1; i <= m; i++) {
239
+ cur[0] = i;
240
+ for (let j = 1; j <= n; j++) {
241
+ const cost = a.charCodeAt(i - 1) === b.charCodeAt(j - 1) ? 0 : 1;
242
+ let min = prev[j] + 1;
243
+ if (cur[j - 1] + 1 < min) min = cur[j - 1] + 1;
244
+ if (prev[j - 1] + cost < min) min = prev[j - 1] + cost;
245
+ cur[j] = min;
246
+ }
247
+ for (let j = 0; j <= n; j++) prev[j] = cur[j];
248
+ }
249
+ return prev[n];
250
+ }
251
+
252
+ /**
253
+ * The closest known config key to `key` within edit distance 2 (case-folded so
254
+ * `preAlloc`/`MAXNODES` resolve), or null when nothing is close. Cold path only.
255
+ * @param {string} key
256
+ * @returns {string|null}
257
+ */
258
+ function suggestKey(key) {
259
+ const lk = key.toLowerCase();
260
+ let best = null;
261
+ let bestD = 3;
262
+ for (let i = 0; i < ALLOWED_KEYS.length; i++) {
263
+ const d = editDistance(lk, ALLOWED_KEYS[i].toLowerCase());
264
+ if (d < bestD) { bestD = d; best = ALLOWED_KEYS[i]; }
265
+ }
266
+ return bestD <= 2 ? best : null;
267
+ }
268
+
269
+ /**
270
+ * Render a rejected value for an error message, e.g. `42 (number)`.
271
+ * Cold: this runs only on a throw path, never on any hot path. `String(symbol)`
272
+ * throws, so symbols are stringified defensively.
273
+ * @param {*} v
274
+ * @returns {string}
275
+ */
276
+ function received(v) {
277
+ return (typeof v === "symbol" ? v.toString() : String(v)) + " (" + typeof v + ")";
278
+ }
279
+
280
+ /**
281
+ * Validate that a numeric option is a finite integer >= 1. Cold: constructor
282
+ * error path only. Throws a {@link TypeError} prefixed `createRegistry: "<name>"`.
283
+ * @param {*} v
284
+ * @param {string} name
285
+ */
286
+ function requirePositiveInt(v, name) {
287
+ if (!Number.isInteger(v) || v < 1) {
288
+ throw new TypeError(
289
+ 'createRegistry: "' + name + '" must be a finite integer >= 1, received ' + received(v) + '.'
290
+ );
291
+ }
292
+ }
293
+
212
294
  export function createRegistry(config) {
213
295
  const NODE_PTR = Symbol("node_ptr");
214
296
  const NODE_GEN = Symbol("node_gen");
215
297
 
298
+ // --- 1.4.5 backport: createRegistry input validation (all cold, constructor-only).
299
+ // Config-shape gate: accept `undefined` or a non-null, non-array object; reject
300
+ // `null`, primitives and arrays BY NAME rather than dying later on `config.maxNodes`
301
+ // or an internal `nextFree` read (fail closed on an unverified state).
302
+ if (config !== undefined && (config === null || typeof config !== "object" || Array.isArray(config))) {
303
+ throw new TypeError(
304
+ 'createRegistry: "config" must be a plain object or undefined, received ' + received(config) + '.'
305
+ );
306
+ }
307
+ if (config !== undefined) {
308
+ // Per-option validation BY NAME -- a bad value throws `createRegistry: "<option>"`
309
+ // at construction, not a delayed internal TypeError on first use.
310
+ if (config.maxNodes !== undefined) requirePositiveInt(config.maxNodes, "maxNodes");
311
+ if (config.maxLinks !== undefined) requirePositiveInt(config.maxLinks, "maxLinks");
312
+ if (config.maxFlushPasses !== undefined) requirePositiveInt(config.maxFlushPasses, "maxFlushPasses");
313
+ if (config.prealloc !== undefined && config.prealloc !== "eager" && config.prealloc !== "lazy") {
314
+ throw new TypeError(
315
+ 'createRegistry: "prealloc" must be "eager" or "lazy", received ' + received(config.prealloc) + '.'
316
+ );
317
+ }
318
+ if (config.onCapacityExceeded !== undefined && config.onCapacityExceeded !== "throw" && config.onCapacityExceeded !== "grow") {
319
+ throw new TypeError(
320
+ 'createRegistry: "onCapacityExceeded" must be "throw" or "grow", received ' + received(config.onCapacityExceeded) + '.'
321
+ );
322
+ }
323
+ // Unknown-key rejection with a did-you-mean hint (`preAlloc` -> `prealloc`,
324
+ // `maxNods` -> `maxNodes`). Own enumerable keys only; cold path.
325
+ const badKeys = Object.keys(config);
326
+ for (let bi = 0; bi < badKeys.length; bi++) {
327
+ const bk = badKeys[bi];
328
+ if (ALLOWED_KEYS.indexOf(bk) === -1) {
329
+ const hint = suggestKey(bk);
330
+ throw new TypeError(
331
+ 'createRegistry: "' + bk + '" is not a recognized option' +
332
+ (hint !== null ? ' (did you mean "' + hint + '"?)' : '') +
333
+ '. Allowed: ' + ALLOWED_KEYS.join(", ") + '.'
334
+ );
335
+ }
336
+ }
337
+ }
338
+ // --- end 1.4.5 backport.
339
+
216
340
  let currentNodesCapacity = (config !== undefined && config.maxNodes !== undefined) ? config.maxNodes : 1024;
217
341
  let currentLinkCapacity = (config !== undefined && config.maxLinks !== undefined) ? config.maxLinks : currentNodesCapacity * 4;
218
342
  const policy = (config !== undefined && config.onCapacityExceeded !== undefined) ? config.onCapacityExceeded : "throw";
@@ -225,6 +349,20 @@ export function createRegistry(config) {
225
349
  // steady state is identical after warm-up, but the heap no longer carries
226
350
  // never-used live objects for every major GC to mark.
227
351
  const prealloc = (config !== undefined && config.prealloc !== undefined) ? config.prealloc : "eager";
352
+ // Eager-construction ceiling (cold): `"eager"` builds `(maxNodes + maxLinks)`
353
+ // objects up front; a finite-but-absurd capacity (e.g. `1e9`) would OOM the
354
+ // process with an uncatchable SIGABRT, not a throw. Refuse BY NAME before
355
+ // allocating. Named for the larger driver. `"lazy"` keeps its unbounded ledger.
356
+ if (prealloc === "eager" && (currentNodesCapacity + currentLinkCapacity) > EAGER_CONSTRUCT_CEILING) {
357
+ const driver = currentLinkCapacity > currentNodesCapacity ? "maxLinks" : "maxNodes";
358
+ throw new TypeError(
359
+ 'createRegistry: "' + driver + '" eager construction of ' +
360
+ (currentNodesCapacity + currentLinkCapacity) + ' objects (maxNodes ' +
361
+ currentNodesCapacity + ' + maxLinks ' + currentLinkCapacity + ') exceeds the ceiling of ' +
362
+ EAGER_CONSTRUCT_CEILING + '. Use prealloc:"lazy" for an unbounded on-demand ledger, ' +
363
+ 'or lower the capacity.'
364
+ );
365
+ }
228
366
  const nodePool = [];
229
367
  let freeNodeHead = null;
230
368
  const linkPool = [];
@@ -1673,6 +1811,12 @@ export function createRegistry(config) {
1673
1811
  pooledLinks: currentLinkCapacity - activeLinks,
1674
1812
  linkPoolCapacity: currentLinkCapacity,
1675
1813
  nodePoolCapacity: currentNodesCapacity,
1814
+ // 1.4.5 backport: TRUE pool population (nodePool.length / linkPool.length),
1815
+ // distinct from the *Capacity ledgers above. Under prealloc:"lazy" (or a
1816
+ // silently-flipped `prealloc` typo) population stays 0 while capacity reads
1817
+ // the ledger -- so a mis-set prealloc is now observable, not telemetry-blind.
1818
+ nodePoolPopulation: nodePool.length,
1819
+ linkPoolPopulation: linkPool.length,
1676
1820
  activeNodes,
1677
1821
  // 1.4: cumulative lifecycle counters (monotonic; reset by destroy()).
1678
1822
  // Derive: allocationRate = deltatotalAllocations/deltat; poolReuseRate =
package/llms.txt CHANGED
@@ -26,7 +26,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
26
26
  - **isTracking**: `isTracking()` returns true iff a read right now would record a dependency on this registry (for wrappers that lazily allocate signals).
27
27
  - **onCleanup**: registers teardown for the current computation; fires before each re-run and once on dispose. Works in effects and computeds.
28
28
  - **Observer-lifecycle introspection** (1.1.4; top-level + per-registry): `hasObservers(handle)` returns true iff a signal/computed has >=1 live observer right now (O(1); a `peek` does not count). `observeObservers(handle, { onConnect?, onDisconnect? })` fires on the 0->1 and 1->0 observer transitions (after registration; transition-only) and returns an idempotent unobserve -- the auto-pause hook for tickers (lite-time/lite-raf start a source only while it's watched). `forEachObserver(handle, fn)` / `forEachSource(handle, fn)` walk the live graph in either direction, passing a `{ kind, value }` descriptor (`kind` is `"signal" | "computed" | "effect"`) -- for inspection (lite-devtools). The surface is gated by an internal counter: zero steady-state cost when nothing is observed. `hasObservers`/`forEach*` no-op on a non-handle; `observeObservers` throws `TypeError`. **Node identity (1.1.5):** `nodeId(handle)` returns the node's stable per-allocation id, `describe(handle)` returns the handle's own `{ id, kind, value }` descriptor, and `forEach*` descriptors now carry `id` too; a descriptor is **re-walkable** (pass it back into `forEachObserver`/`forEachSource`) -- the recursion primitive lite-devtools uses to walk the full DAG. **Owner-tree introspection (1.2.1):** `forEachOwned(handle, fn)` walks a node's owned children (lifetime-binding edges from the 1.2 owner tree -- invisible through dep/sub); `ownerOf(handle)` returns the owner's descriptor or `undefined` for top-level / stale handles. **Stale-handle guard (1.2.1):** the entire introspection surface plus `peek()`/`read()`/`set()` is now generation-checked. A handle held across the 1.2 owner-cascade auto-dispose used to resolve `NODE_PTR` ungated and silently report the recycled slot's NEW resident; 1.2.1 surfaces stale handles as `undefined` (or `TypeError`, for `observeObservers`) -- same ABA discipline `dispose()` always had. Descriptors are gen-stamped so the re-walkable contract survives the guard. **Push-based mutation hook (1.2.1):** `onGraphMutation(fn)` registers a single nullable listener invoked synchronously at every mutation point with three integers `(opcode, intA, intB)` -- opcodes `1` node-create / `2` node-dispose / `3` link-add / `4` link-remove / `5` recompute. Zero-cost gate when no listener is registered (one branch-predicted null check); allocation-free dispatch when registered. The connection point for push-based devtools/studio. Contract: observe only -- never throw, never mutate.
29
- - **Registry**: `createRegistry({ maxNodes, maxLinks, prealloc, onCapacityExceeded, maxFlushPasses })` creates an isolated reactive world with its own pools. Useful for tests, plugins, multi-tenant sandboxes. Top-level helpers use a default registry created at module load. `prealloc` (1.3.0; `"eager"` default | `"lazy"`) chooses up-front vs on-demand pool construction; `onCapacityExceeded` (`"throw"` default | `"grow"`) chooses fail-fast vs chunked-incremental growth bounded by the 16x link ceiling.
29
+ - **Registry**: `createRegistry({ maxNodes, maxLinks, prealloc, onCapacityExceeded, maxFlushPasses })` creates an isolated reactive world with its own pools. Useful for tests, plugins, multi-tenant sandboxes. Top-level helpers use a default registry created at module load. `prealloc` (1.3.0; `"eager"` default | `"lazy"`) chooses up-front vs on-demand pool construction; `onCapacityExceeded` (`"throw"` default | `"grow"`) chooses fail-fast vs chunked-incremental growth bounded by the 16x link ceiling. **Config is validated at construction (1.6.0-beta-1, backported from 1.4.5):** every option is checked BY NAME, a bad shape or unknown key throws a `TypeError` prefixed `createRegistry: "<name>"` with a did-you-mean hint, and an absurd eager capacity (`maxNodes:Infinity`/`1e9`) is refused before it can OOM the process. `stats()` gains `nodePoolPopulation` / `linkPoolPopulation` (true constructed-object counts, distinct from the `*Capacity` ledgers) -> **14 keys**.
30
30
  - **CapacityError**: thrown when a fixed-size pool is exhausted under the `"throw"` policy, or when a `"grow"` policy hits the 16× starting-capacity ceiling on links.
31
31
 
32
32
  ## Architecture invariants
@@ -54,28 +54,43 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
54
54
 
55
55
  ## Version notes
56
56
 
57
- - **1.6.0-beta** (current): promotes `1.6.0-alpha.0` to the `beta` dist-tag. One
57
+ - **1.6.0-beta-1** (current): backports the **1.4.5 `createRegistry` input validation** (all four findings) onto the 1.6.0-beta engine. Only `createRegistry`'s *cold* path moved; hot paths stay byte-identical and `bench/torture/run.mjs` is unchanged at 22/22. Bad config now throws a named `TypeError` (unknown keys get a did-you-mean); an absurd eager capacity is refused before it can OOM the process; `stats()` grows to 14 keys (adds `nodePoolPopulation`/`linkPoolPopulation`, purely additive). New `test/*-config-validation.test.mjs` (matrix + ceiling + population + OOM child processes). See CHANGELOG `[1.6.0-beta-1]`.
58
+ - **1.6.0-beta**: promotes `1.6.0-alpha.0` to the `beta` dist-tag. One
58
59
  behavioural fix over alpha.0 -- the dangling re-tracking cursor crash
59
60
  (disposing a signal/computed from inside an observer that linked it last run but
60
61
  has not re-read it this run; a one-line cursor repair in `disposeNode`, O(1),
61
62
  disposal path only) -- plus branch coverage on `Signal.js` closed to **100%**
62
63
  and a **completed torture surface**. The alpha.0 API (`createScope`,
63
64
  `flushPasses`, the op-6 / op-7 mutation-hook opcodes) is carried forward
64
- unchanged. The torture runner now registers the full **17-scenario superset
65
- (14 semantic + 3 soak)**: `scope-torture` -- feature-skipped on 1.5.0 -- now
66
- **executes** on this engine (`createScope` exists), and a new semantic scenario
65
+ unchanged. The torture runner now registers the full **22-scenario superset
66
+ (19 semantic + 3 soak)** -- full parity with the shipped 1.4.4 sibling. This is
67
+ a verification-only parity pass: the engine (`Signal.js` / `Signal.d.ts`) is
68
+ UNCHANGED. `scope-torture` -- feature-skipped on 1.5.0 -- now **executes** on
69
+ this engine (`createScope` exists), and a new semantic scenario
67
70
  **`introspect-torture`** closes the read-only introspection surface (`describe`,
68
71
  `nodeId`, `hasObservers`, `isTracking`, `forEachObserver` / `forEachSource` /
69
72
  `forEachOwned`, `ownerOf`, `observeObservers`) that no value/wakeup/work oracle
70
73
  can see -- pinning walk-agreement (against the reference dep set + the op-3/op-4
71
74
  link lane) and the ABA gen-stamp guard (a descriptor captured before
72
- dispose+recycle must resolve to nothing, never the new resident). Every
73
- scenario feature-detects, so on 1.6.0 the runner executes **11 semantic** and
75
+ dispose+recycle must resolve to nothing, never the new resident). Five more
76
+ scenarios are ported to full parity: **`lifecycle-torture`** (createRoot
77
+ detachment + destroy registry reset), **`owner-torture`** (getOwner /
78
+ runWithOwner capture-restore + ABA degradation), **`error-torture`**
79
+ (throwing effect bodies: per-effect buffering, AggregateError, buffer drain),
80
+ **`deep-chain-torture`** (pullComputed recursion fail-closed vs iterative push
81
+ path), and **`zerogc-torture`** (zero-GC hot path via measureAllocs / measureOps
82
+ + `stats()` counters; ZEROGC_BREAK self-test). Because 1.6.0 ships createScope /
83
+ getOwner / runWithOwner / createRoot natively, the owner/scope/createRoot
84
+ scenarios that SKIPPED on 1.4.4 **run natively here** and passed as written --
85
+ no assertion needed pinning to a divergent behaviour. Every later-version
86
+ scenario feature-detects, so on 1.6.0 the runner executes **16 semantic** and
74
87
  cleanly SKIPS three later-version ones (`flush` 1.7.0, `cleanup-return` 1.8.0,
75
88
  `dispose` 1.9.0). The `28-scope` unit file is renamed to `29-scope` (it
76
- collided on the `28-` prefix with `28-run-with-owner`). Verified green on the
77
- 1.6.0 engine: torture 17/17 (semantic 14/14 = 11 run + 3 skip; soak 3/3, pools
78
- back to their leaf-only floor); unit **467 tests, 456 pass, 0 fail, 1 skip**
89
+ collided on the `28-` prefix with `28-run-with-owner`), and a new
90
+ `30-throwing-equals` unit file pins a user `equals` that throws at all five
91
+ physical eq() sites (three callable + the two signalBox boxSet sites). Verified
92
+ green on the 1.6.0 engine: torture 22/22 (semantic 19/19 = 16 run + 3 skip;
93
+ soak 3/3, pools back to their leaf-only floor); unit **472 tests, 471 pass, 0 fail, 1 skip**
79
94
  (the SSR N/A in `17-reactivity`) -- 466 pass with the sibling
80
95
  `@zakkster/lite-devtools` present, which the 10-test `test/25` real-boot rig
81
96
  needs. Drop-in over 1.6.0-alpha.0.
@@ -812,7 +827,7 @@ function dumpOwnerTree(handle, depth = 0) {
812
827
  - `bench/aggregate.mjs` + `bench/report.mjs` -- microscope + mirror aggregators writing `r.txt` / `rb.txt` with `#STAMP` headers (engine + harness sha256, live registry config, host, node).
813
828
  - `bench/AndriiVolynetsReactiveBenchScore/AndriiVolynetsReactiveBench.log` -- Andrii's own 15-framework x 47-test log, checked in for audit; the ranking source of truth.
814
829
  - `bench/dispose-recycle.mjs` -- 1.2.2 targeted microbench: create/dispose/recreate cycle (the free-list invariant audit target).
815
- - `bench/torture/` -- the complete **17-scenario superset (14 semantic + 3 soak)** behind one runner (`run.mjs`), two groups, forward-compatible through 1.9. Every scenario feature-detects and SKIPS cleanly below the engine version that introduces its feature, so the whole set is safe on the 1.6.0 engine and stays green from 1.4.x forward. `semantic` (deterministic, fast, asserts on MEANING; CI on every commit) -- the **11 that execute on 1.6.0**: `oracle-fuzzer` (every computed vs an independent uncached reference, 400 seeds x 120 ops), `glitch-hunter` (glitch freedom + exact wakeups), `work-accounting` (minimum body-execution counts over 10 topologies), `op-accounting` (structural work from the `onGraphMutation` opcode lane, not wall-clock), `introspect-torture` (1.6.0: the read-only introspection surface -- `describe`/`nodeId`/`hasObservers`/`isTracking`/`forEachObserver`/`forEachSource`/`forEachOwned`/`ownerOf`/`observeObservers` -- pinning walk-agreement against the reference dep set + op-3/op-4 lane, and the ABA gen-stamp guard on re-walkable descriptors), `concurrent-storm` (8 reentrancy / flush-ordering contracts), `scheduler-storm` (gen-bound thunk ABA guard, FLAG_QUEUED coalescing, throwing-scheduler containment), `box-torture` (1.5.0: signalBox/computedBox interop -- the oracle differential fuzz with every node realised as callable OR box), `scope-torture` (1.6.0: `createScope` adoption contract + the disposal-crash repro and its 300-seed fuzz + `runWithOwner` re-attachment into a scope + pool balance over 200 rounds), `async-torture` (watch / when / whenAsync contracts + a 300-seed projection-guard storm), `capacity-torture` (the fail-closed pool boundary); plus **3 that skip cleanly** as later-version features: `flush-torture` (1.7.0 `flushStrategy`), `cleanup-return-torture` (1.8.0 effect-return cleanup), `dispose-torture` (1.9.0 `Symbol.dispose`). `soak` (wall-clock bound, asserts on RESOURCES; nightly): `graph-fuzzer`, `scheduler-bench`, `torture-soak` -- exit 0 iff zero errors AND post-teardown pool at or below its leaf-only floor AND the JIT sink advanced. Runner spawns each scenario as a child process (several assert on global pool accounting) and passes `--expose-gc` unconditionally. Scripts: `npm run torture`, `torture:semantic`, `torture:soak`.
830
+ - `bench/torture/` -- the complete **22-scenario superset (19 semantic + 3 soak)** behind one runner (`run.mjs`), two groups, forward-compatible through 1.9 -- full parity with the shipped 1.4.4 sibling (verification-only; the engine is UNCHANGED). Every scenario feature-detects and SKIPS cleanly below the engine version that introduces its feature, so the whole set is safe on the 1.6.0 engine and stays green from 1.4.x forward. `semantic` (deterministic, fast, asserts on MEANING; CI on every commit) -- the **16 that execute on 1.6.0**: `oracle-fuzzer` (every computed vs an independent uncached reference, 400 seeds x 120 ops), `glitch-hunter` (glitch freedom + exact wakeups), `work-accounting` (minimum body-execution counts over 10 topologies), `op-accounting` (structural work from the `onGraphMutation` opcode lane, not wall-clock), `introspect-torture` (1.6.0: the read-only introspection surface -- `describe`/`nodeId`/`hasObservers`/`isTracking`/`forEachObserver`/`forEachSource`/`forEachOwned`/`ownerOf`/`observeObservers` -- pinning walk-agreement against the reference dep set + op-3/op-4 lane, and the ABA gen-stamp guard on re-walkable descriptors), `lifecycle-torture` (1.5.0+: createRoot detachment + destroy registry reset -- runs natively here), `concurrent-storm` (8 reentrancy / flush-ordering contracts), `scheduler-storm` (gen-bound thunk ABA guard, FLAG_QUEUED coalescing, throwing-scheduler containment), `box-torture` (1.5.0: signalBox/computedBox interop -- the oracle differential fuzz with every node realised as callable OR box), `scope-torture` (1.6.0: `createScope` adoption contract + the disposal-crash repro and its 300-seed fuzz + `runWithOwner` re-attachment into a scope + pool balance over 200 rounds), `owner-torture` (1.6.0: getOwner / runWithOwner capture-restore + live-adoption cascade + stale-handle ABA degradation to rooted -- runs natively here), `async-torture` (watch / when / whenAsync contracts + a 300-seed projection-guard storm), `capacity-torture` (the fail-closed pool boundary + the 16x grow ceiling), `error-torture` (throwing effect bodies: per-effect buffering, single re-throw vs AggregateError, 4096-cycle buffer drain), `deep-chain-torture` (pullComputed recursion fail-closed with a RangeError vs the iterative push path), `zerogc-torture` (zero-GC hot path via `measureAllocs`/`measureOps` + `stats()` counters; ZEROGC_BREAK self-test; churn-box activates on 1.6.0); plus **3 that skip cleanly** as later-version features: `flush-torture` (1.7.0 `flushStrategy`), `cleanup-return-torture` (1.8.0 effect-return cleanup), `dispose-torture` (1.9.0 `Symbol.dispose`). `soak` (wall-clock bound, asserts on RESOURCES; nightly): `graph-fuzzer`, `scheduler-bench`, `torture-soak` -- each now carries a value-correctness oracle (a preallocated `Int32Array` shadow, rotating window per tick, full sweep at teardown) alongside the liveness assertions -- exit 0 iff zero errors AND value-oracle clean AND post-teardown pool at or below its leaf-only floor AND the JIT sink advanced. Runner spawns each scenario as a child process (several assert on global pool accounting) and passes `--expose-gc` unconditionally. Scripts: `npm run torture`, `torture:semantic`, `torture:soak`.
816
831
  - `bench/run-all-bench.sh` -- cold-process-per-engine driver (`FW=<engine>` per child), fed to `aggregate.mjs` for medianing.
817
832
  - `harness/run.mjs` -- dispatcher for the run-on-demand probes (field, dispose, churn, owner, creation, all).
818
833
  - `harness/fieldkit.mjs` -- single-file portable verify + cold-child A/B bench across six shapes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zakkster/lite-signal",
3
- "version": "1.6.0-beta",
3
+ "version": "1.6.0-beta-1",
4
4
  "description": "Zero-GC reactive graph. Monomorphic object pool, versioned push-pull propagation, 32-bit modular versioning. Built for hot paths and long-running processes.",
5
5
  "author": "Zahary Shinikchiev <shinikchiev@yahoo.com>",
6
6
  "license": "MIT",
@@ -88,6 +88,7 @@
88
88
  "sideEffects": false,
89
89
  "devDependencies": {
90
90
  "@zakkster/lite-devtools": "^1.2.0",
91
+ "@zakkster/lite-gc-profiler": "^1.15.0",
91
92
  "@zakkster/lite-profiler": "^1.1.0",
92
93
  "@zakkster/lite-profiler-signal": "^1.2.0",
93
94
  "@zakkster/lite-signal": "^1.3.0 || >=1.4.0-beta.0 || >=1.6.0-preview.0",