@zakkster/lite-signal 1.5.0-rc.2 → 1.5.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,132 @@ 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.5.1] -- 2026-09-05
8
+
9
+ Docs + verification patch. `Signal.js` is byte-identical to 1.5.0 except the
10
+ version banner comment; no API change, no behavior change. Ships the corrected
11
+ allocation economics below to the `latest` line while `1.6.0-rc` bakes.
12
+
13
+ ### Added -- mint-cycle allocation anatomy probe (harness, no engine change)
14
+
15
+ A dedicated probe (`harness/mint-anatomy.mjs`, dispatched as `mint`) pins the
16
+ per-op heap cost of every creation primitive's mint+dispose cycle on a pre-grown
17
+ fixed-ceiling registry (`createRegistry({maxNodes:1<<16, maxLinks:1<<18,
18
+ onCapacityExceeded:"throw"})`). Fresh child process per (variant, warmup) cell --
19
+ JIT tier state poisons same-process comparisons. `Signal.js` / `Signal.d.ts`
20
+ untouched; this is verification + attribution only.
21
+
22
+ **Corrected numbers** (all-space B/op, node v26.3.1 darwin/arm64, pre-grown
23
+ throw-policy registry, slope over ops windows {1000,4000,16000} so the sampler
24
+ constant cancels):
25
+
26
+ | cycle (mint + dispose) | all-space B/op | note |
27
+ | ---------------------- | -------------: | --------------------------------------- |
28
+ | `signal(1)` + dispose | 264 | tier-invariant |
29
+ | `computed(fn)` + dispose | 208 | 4 own props, no `set`/`update` |
30
+ | `effect(fn)` + disposeFn() | 160 | 2-prop disposer + 3-slot context |
31
+ | `signalBox(1)` + dispose | 56 | `Object.create(proto)` handle, 0 closures |
32
+ | `computedBox(fn)` + dispose | 56 | same |
33
+ | dispose side (all forms) | 0 | mint-and-hold equals the cycle to +-0.3 B |
34
+
35
+ LiteStore LS-06's ~209 B for the signal cycle was a **new-space-only reading at a
36
+ pre-TurboFan tier**: below ~15-25k lifetime mints, ~56 B/op of closure-feedback
37
+ plumbing lands in OLD space, invisible to a `new_space` delta. The total was
38
+ always 264. `--no-turbofan` freezes the new-space witness at 208 forever;
39
+ `--no-maglev` shows 264 immediately; all-space totals never move (264.3 at every
40
+ tier). Hence the methodology rule this probe enforces (P3, and the sampling-profiler
41
+ cross-check in the findings): **allocation accounting must sum `space_used_size`
42
+ over ALL heap spaces** -- a new-space-only delta is valid only for scavenge-churn
43
+ characterization, never for per-op cost.
44
+
45
+ **Pooling accessor closures with their nodes -- evaluated and REJECTED (fail-open).**
46
+ Reusing one accessor-closure identity across dispose/reuse makes a retained stale
47
+ handle and a fresh handle *the same object* (`a === b`), so both holders share one
48
+ captured `birthGen` and the ABA gen-guard -- checked at the only place it runs and
49
+ pinned by `probe-c1-stale-set` / `probe-c1-stale-read` -- becomes undecidable: a
50
+ stale `a()` reads the recycled slot's new resident, a stale `a.set()` overwrites
51
+ it. That fails open; suite law is fail closed. **Fresh accessor identity per mint
52
+ is load-bearing** for the stale-handle contract and cannot be repaired by any stamp
53
+ placement. The callable path's ~264 B is therefore the documented, irreducible
54
+ price of `count()` / `count.set(x)` ergonomics; **`signalBox` (56 B/op, same graph,
55
+ same but DECIDABLE guard -- each box carries its own `NODE_GEN`) is the sanctioned
56
+ cheap path** (-79%). FinalizationRegistry-gated recycling is semantically sound but
57
+ allocates per mint, makes reuse GC-scheduled, and retains every accessor until
58
+ finalization -- rejected too.
59
+
60
+ Run it: `node harness/run.mjs mint [--verify]` (`--verify` applies relative pins
61
+ P1..P5; exit 0 iff every cell succeeded and every pin passed).
62
+
63
+ ### Added -- attribution instrument set (harness-only, none ship in the tarball)
64
+
65
+ - `harness/costmodel.mjs`, `creation-anatomy.mjs` (+ child), `floors.mjs`
66
+ (+ `floors-history.json`), `jit-health.mjs` (+ `jit-baseline.json`),
67
+ `trend.mjs`, `visit-anatomy.mjs`; VersionMatrix `creation-churn` workload +
68
+ same-host 1.3.0/1.5.0 reference baselines. Verification instruments only.
69
+
70
+ ### Changed
71
+
72
+ - devDependencies: `@zakkster/lite-devtools` ^1.2.0 -> ^1.3.1,
73
+ `@zakkster/lite-gc-profiler` ^1.15.0 -> ^1.16.0 (the instrument versions the
74
+ suite is gated with). Runtime dependencies remain zero.
75
+
76
+ ## [1.5.0] -- 2026-08-21
77
+
78
+ **Stable 1.5.0.** Graduates `1.5.0-rc.3` to the release line with **no further engine
79
+ change** -- `Signal.js` / `Signal.d.ts` are byte-identical to rc.3 past the version
80
+ header, and the zero-GC gates (`bench/torture/run.mjs` 22/22) are unchanged. This is
81
+ the first stable to carry the **1.4.5 `createRegistry` input validation** (folded in
82
+ at rc.3; see below) on top of the 1.5.0 surface: `signalBox` / `computedBox`,
83
+ `createRoot`, and `getOwner` / `runWithOwner`. Drop-in over 1.4.5 for the callable
84
+ API; the only observable delta on existing code is `stats()` growing 11 -> 13 keys
85
+ (purely additive). The full rc/beta history is retained below.
86
+
87
+ ## [1.5.0-rc.3] -- 2026-08-20
88
+
89
+ Backports the **1.4.5 `createRegistry` input validation** (all four findings) onto
90
+ the rc.2 engine. This is the first engine change since the RC line began -- the hot
91
+ paths are still byte-identical to 1.4.0; only `createRegistry`'s *cold* construction
92
+ path gained validation, so the zero-GC gates (`bench/torture/run.mjs` 22/22) are
93
+ unchanged. If you had a typo in your registry config, you will now hear about it.
94
+
95
+ ### Added -- createRegistry validates its config (fail closed)
96
+
97
+ - **Bounded eager construction.** `prealloc:"eager"` with a non-finite or absurd
98
+ capacity (`maxNodes:Infinity`, `maxNodes:1e9`) previously ran an unbounded
99
+ construction loop and killed the process with an **uncatchable SIGABRT**. It now
100
+ throws a `TypeError` **by name**, before allocating, gated on `(maxNodes+maxLinks)`
101
+ against a ceiling of `1<<24` (16,777,216) objects. `prealloc:"lazy"` keeps its
102
+ unbounded on-demand ledger, untouched.
103
+ - **Per-option validation by name.** `maxNodes` / `maxLinks` / `maxFlushPasses` must
104
+ be finite integers `>= 1`; `prealloc` must be exactly `"eager"` | `"lazy"`;
105
+ `onCapacityExceeded` must be exactly `"throw"` | `"grow"`. Each bad value throws a
106
+ `TypeError` prefixed `createRegistry: "<option>"` at construction -- not a delayed
107
+ internal `nextFree` TypeError on first use.
108
+ - **Config-shape gate.** A non-object, `null`, or array `config` throws
109
+ `createRegistry: "config"` rather than dying later.
110
+ - **Unknown-key rejection with did-you-mean.** An unrecognized key throws with a
111
+ Levenshtein suggestion (`maxNods` -> `maxNodes`, `preAlloc` -> `prealloc`) instead
112
+ of being silently ignored.
113
+ - **`stats()` gains `nodePoolPopulation` / `linkPoolPopulation`** -- the TRUE count
114
+ of physically constructed nodes/links (`nodePool.length` / `linkPool.length`),
115
+ distinct from the `*Capacity` ledgers. A silently mis-set `prealloc` is now
116
+ observable (population 0 under lazy) instead of telemetry-blind. **This is the one
117
+ observable API change: `stats()` grows 11 -> 13 keys, purely additive** -- no
118
+ existing key changed; only an exact key-*count* assertion is affected (updated
119
+ in `test/03-pool.test.mjs`).
120
+
121
+ ### Tests
122
+
123
+ `test/30-config-validation.test.mjs` adds the full 25-config matrix, the did-you-mean
124
+ cases, the eager ceiling, the population contract, and the three OOM rows as isolated
125
+ child-process cases (`test/30-config-oom.child.mjs`) proving the fixed engine throws
126
+ + exits 0 under a 256 MB cap where the unvalidated engine died.
127
+
128
+ ## [1.5.0-rc.2] -- 2026-08-18
129
+
130
+ Version-only bump over rc.1; engine byte-identical past the header. Superseded by
131
+ rc.3, the first entry to carry an engine change.
132
+
7
133
  ## [1.5.0-rc.1] -- 2026-07-27
8
134
 
9
135
  Release candidate for 1.5.0. Promotes `1.5.0-beta.8` with **no engine change** --
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.5.0-rc.1
2
+ * @zakkster/lite-signal v1.5.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 = [];
@@ -1562,6 +1700,12 @@ export function createRegistry(config) {
1562
1700
  pooledLinks: currentLinkCapacity - activeLinks,
1563
1701
  linkPoolCapacity: currentLinkCapacity,
1564
1702
  nodePoolCapacity: currentNodesCapacity,
1703
+ // 1.4.5 backport: TRUE pool population (nodePool.length / linkPool.length),
1704
+ // distinct from the *Capacity ledgers above. Under prealloc:"lazy" (or a
1705
+ // silently-flipped `prealloc` typo) population stays 0 while capacity reads
1706
+ // the ledger -- so a mis-set prealloc is now observable, not telemetry-blind.
1707
+ nodePoolPopulation: nodePool.length,
1708
+ linkPoolPopulation: linkPool.length,
1565
1709
  activeNodes,
1566
1710
  // 1.4: cumulative lifecycle counters (monotonic; reset by destroy()).
1567
1711
  // Derive: allocationRate = deltatotalAllocations/deltat; poolReuseRate =
package/llms.txt CHANGED
@@ -16,7 +16,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
16
16
  - **Signal**: root reactive cell. `signal(initial, { equals? })` returns a function. Call it to read (tracked), use `.peek()` to read without tracking, `.set(v)` to notify downstream, `.update(fn)` for read-modify-write, `.subscribe(fn)` for an effect-backed listener.
17
17
  - **Computed**: lazy memoized derivation. `computed(fn, { equals? })`. Cache hits return in O(deps) (version comparison only). Cache misses re-run the body and refresh `evalVersion`. Errors are cached via `FLAG_HAS_ERROR` and re-thrown on every read until a dep changes.
18
18
  - **Effect**: side-effect runner. `effect(fn, { scheduler? })`. Runs immediately on creation, then on any tracked dep change. Returns a dispose function. Optional scheduler defers execution (e.g., to rAF, microtask, custom frame loop).
19
- - **Box (1.5.0)**: non-callable, allocation-light variants. `signalBox(initial, { equals? })` returns `{ get, set, peek, update, subscribe }`; `computedBox(fn, { equals? })` returns `{ get, peek, subscribe }` (no set/update -- derived). Same `ReactiveNode` and zero-GC read/write path as the callable forms, full interop in one graph (a callable can read `box.get()` and vice versa). Construction is ~1.7x cheaper than the callable (an `Object.create(proto)` handle, not a closure). Built on a shared prototype from the start -- never `setPrototypeOf` (which would deopt the method-call ICs to megamorphic). Exported as registry methods and top-level helpers.
19
+ - **Box (1.5.0)**: non-callable, allocation-light variants. `signalBox(initial, { equals? })` returns `{ get, set, peek, update, subscribe }`; `computedBox(fn, { equals? })` returns `{ get, peek, subscribe }` (no set/update -- derived). Same `ReactiveNode` and zero-GC read/write path as the callable forms, full interop in one graph (a callable can read `box.get()` and vice versa). Construction is ~1.7x cheaper than the callable (an `Object.create(proto)` handle, not a closure): measured at **56 B/op per mint+dispose cycle vs 264 B/op for the callable** (all-space, node v26.3.1; the callable's cost is two accessor closures + shared context + property store + closure feedback -- see `harness/run.mjs mint`). The box guard stays DECIDABLE because each box is a fresh identity carrying its own `NODE_GEN`, so pooling closure identity is not needed to cut the cost. Built on a shared prototype from the start -- never `setPrototypeOf` (which would deopt the method-call ICs to megamorphic). Exported as registry methods and top-level helpers.
20
20
  - **createRoot (1.5.0)**: `createRoot(fn)` runs `fn` in a detached ownership scope and returns `fn`'s value. Effects/computeds created directly in `fn` are NOT adopted by the enclosing owner, so they survive its re-runs/disposal (the caller owns their lifecycle). Both ownership and tracking are detached for `fn`'s direct body; inner effect/computed bodies still establish their own scopes. The escape hatch for lazily spawning a long-lived node from inside a consumer effect (e.g. `lite-query`'s query-watcher) -- without it, the consumer owns the watcher and cascade-disposes it on its next re-run. Mirrors Solid's `createRoot`.
21
21
  - **getOwner / runWithOwner (1.5.0-beta.2)**: the re-attach companion. `getOwner()` returns the current lifecycle owner as an opaque gen-stamped handle (`undefined` outside any effect/computed body); `runWithOwner(handle, fn)` runs `fn` with that owner reinstated so effects/computeds created directly in `fn` are adopted by it (and cascade-dispose when it re-runs). Nulls the tracking observer for `fn`'s direct body (same pairing as `createRoot`). Handles are **safe to hold across async boundaries**: they use the `describeNode` / `liveNode` ABA-guard machinery (`NODE_GEN` stamp checked against the pool slot's current gen), so stale handles -- owner disposed, slot recycled by an unrelated effect via the LIFO free list -- degrade to rooted execution rather than corrupting the graph. A raw-pointer implementation would (i) silently adopt continuations into the recycled slot's new resident (measured: continuation dies with a stranger on its next disposal), or (ii) crash the engine with `RangeError: Maximum call stack size exceeded` on a corpse handle (owner disposed, slot not yet recycled -- the disposal walk recurses without termination). Both hazards pinned in `test/28-run-with-owner.test.mjs`, empirically reproduced via `harness/owner-hazard-repro.mjs`. Also exported as registry methods + top-level helpers.
22
22
  - **dispose(api)**: universal disposal. Accepts a signal, computed, or effect dispose handle; idempotent; cross-registry calls are silent no-ops (per-registry `Symbol("node_ptr")` keys the node-identity slot on the returned API function, foreign signals fail the lookup and fall through). Passing an unrelated value is also safe; passing an arbitrary function invokes it (effect-handle contract).
@@ -25,7 +25,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
25
25
  - **isTracking**: `isTracking()` returns true iff a read right now would record a dependency on this registry (for wrappers that lazily allocate signals).
26
26
  - **onCleanup**: registers teardown for the current computation; fires before each re-run and once on dispose. Works in effects and computeds.
27
27
  - **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.
28
- - **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.
28
+ - **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.5.0, backported from 1.4.5):** every option is checked BY NAME (`maxNodes`/`maxLinks`/`maxFlushPasses` finite integer `>= 1`; `prealloc` exactly `"eager"`|`"lazy"`; `onCapacityExceeded` exactly `"throw"`|`"grow"`), 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) -> **13 keys**.
29
29
  - **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.
30
30
 
31
31
  ## Architecture invariants
@@ -53,7 +53,30 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
53
53
 
54
54
  ## Version notes
55
55
 
56
- - **1.5.0-rc.1** (current): release candidate for 1.5.0. **No engine change** --
56
+ - **1.5.1** (current): docs + verification patch -- engine byte-identical to 1.5.0
57
+ past the version banner; no API or behavior change. Adds the mint-cycle allocation
58
+ anatomy probe (`node harness/run.mjs mint [--verify]`) and ships the corrected
59
+ creation economics it measured (callable mint+dispose 264 B/op all-space,
60
+ tier-invariant; `signalBox`/`computedBox` 56 B/op; dispose adds 0). devDeps:
61
+ devtools ^1.3.1, gc-profiler ^1.16.0. See CHANGELOG `[1.5.1]`.
62
+ - **1.5.0**: stable. Graduates rc.3 with **no further engine change** --
63
+ `Signal.js`/`Signal.d.ts` byte-identical to rc.3 past the header, `bench/torture/run.mjs`
64
+ unchanged at 22/22. First stable to carry the **1.4.5 `createRegistry` input
65
+ validation** (folded in at rc.3) atop the 1.5.0 surface (`signalBox`/`computedBox`,
66
+ `createRoot`, `getOwner`/`runWithOwner`). Drop-in over 1.4.5; the one observable delta
67
+ on existing code is `stats()` growing 11 -> 13 keys (additive). See CHANGELOG `[1.5.0]`.
68
+ - **1.5.0-rc.3**: backports the **1.4.5 `createRegistry` input validation**
69
+ (all four findings) onto the rc.2 engine. First engine change since the RC line
70
+ began -- but only `createRegistry`'s *cold* construction path moved; hot paths stay
71
+ byte-identical to 1.4.0 and `bench/torture/run.mjs` is unchanged at 22/22. Bad
72
+ config now throws a named `TypeError` (unknown keys get a did-you-mean); an absurd
73
+ eager capacity is refused before it can OOM the process; `stats()` grows 11 -> 13
74
+ keys (adds `nodePoolPopulation`/`linkPoolPopulation`, purely additive). New suite
75
+ `test/30-config-validation.test.mjs` (matrix + ceiling + population + OOM child
76
+ processes). See CHANGELOG `[1.5.0-rc.3]`.
77
+ - **1.5.0-rc.2**: version-only bump over rc.1; engine byte-identical past the header.
78
+ Superseded by rc.3.
79
+ - **1.5.0-rc.1**: release candidate for 1.5.0. **No engine change** --
57
80
  `Signal.js` and `Signal.d.ts` are FROZEN: byte-identical to beta.8, hot paths
58
81
  byte-identical to 1.4.0. This RC brings the torture surface to full **parity
59
82
  with 1.4.4**: `bench/torture/run.mjs` now registers the complete **22-scenario
@@ -774,7 +797,8 @@ function dumpOwnerTree(handle, depth = 0) {
774
797
  - `bench/torture/` -- the complete **16-scenario superset (13 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.5.0 engine and stays green from 1.4.x forward. `semantic` (deterministic, fast, asserts on MEANING; CI on every commit) -- the **9 that execute on 1.5.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), `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, plus box-only subscribe/update and the allocation-light representation contract), `async-torture` (watch / when / whenAsync contracts + a 300-seed projection-guard storm), `capacity-torture` (the fail-closed pool boundary -- exact ceilings, re-throw-on-read, `grow` crossing the same boundary), `op-accounting` (structural work counted from the engine's own `onGraphMutation` opcode lane, not wall-clock); plus **4 that skip cleanly** as later-version features: `scope-torture` (1.6.0 `createScope`), `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`.
775
798
  - `bench/torture/helpers/index.mjs` -- shared torture infrastructure: seeded `mulberry32` (failures replay from their seed), `soakRegistry` / `fixedRegistry`, `createReport` (collects failures rather than throwing on the first), and `VALUE_POOL`, the adversarial value domain carrying the pairs where candidate equality definitions disagree (`Object.is` vs `===` on NaN and -0/0; `===` vs `==` on 0/""/false/"0" and null/undefined). Dependency-free and side-effect-free by contract: importing it must not touch the default registry.
776
799
  - `bench/run-all.sh` + `bench/aggregate.mjs` -- cold-process-per-engine protocol + per-scenario aggregation.
777
- - `harness/run.mjs` -- dispatcher for the run-on-demand probes (field, dispose, churn, owner, creation, all).
800
+ - `harness/run.mjs` -- dispatcher for the run-on-demand probes (field, dispose, churn, owner, creation, mint, all).
801
+ - `harness/mint-anatomy.mjs` -- mint+dispose cycle allocation anatomy (`mint` / `mint --verify`): per-op all-space vs new-space heap bytes for every creation primitive on a pre-grown throw-policy registry, fresh child per (variant, warmup) cell. Documents the 264 B/op callable cycle vs 56 B/op signalBox and the ALL-space accounting rule (a new-space-only witness undercounts by ~56 B/op of pre-TurboFan closure-feedback -- the LS-06 correction). `--verify` applies relative pins P1..P5.
778
802
  - `harness/fieldkit.mjs` -- single-file portable verify + cold-child A/B bench across six shapes.
779
803
  - `harness/owner-hazard-repro.mjs` -- async-gap owner-recycling hazard verdict (cited by getOwner/runWithOwner).
780
804
  - `harness/VersionMatrix/` -- cold-process-per-version performance regression gate (wired as prepublishOnly).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zakkster/lite-signal",
3
- "version": "1.5.0-rc.2",
3
+ "version": "1.5.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",
@@ -84,8 +84,8 @@
84
84
  },
85
85
  "sideEffects": false,
86
86
  "devDependencies": {
87
- "@zakkster/lite-devtools": "^1.2.0",
88
- "@zakkster/lite-gc-profiler": "^1.15.0",
87
+ "@zakkster/lite-devtools": "^1.3.1",
88
+ "@zakkster/lite-gc-profiler": "^1.16.0",
89
89
  "@zakkster/lite-profiler": "^1.1.0",
90
90
  "@zakkster/lite-profiler-signal": "^1.2.0",
91
91
  "@zakkster/lite-signal": "^1.3.0 || >=1.4.0-beta.0 || >=1.6.0-preview.0",