@zakkster/lite-signal 1.5.0-beta.3 → 1.5.0-beta.5

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,55 @@ 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
+ ## [Unreleased]
8
+
9
+ ### Fixed -- dangling re-tracking cursor on source disposal (crash)
10
+
11
+ Disposing a signal/computed from inside an observer that had linked it on the
12
+ previous run, but had not yet re-read it on the current run, crashed with
13
+ `TypeError: Cannot set properties of null (setting 'headSub')`. `disposeNode`'s
14
+ sub-list teardown freed the link while the observer's re-tracking cursor
15
+ (`activeObserverCurrentDep`) was still parked on it; `severTail` then walked from
16
+ a freed link, wiped the observer's `headDep`, and double-freed the link. Reachable
17
+ from the plain public API (see `COVERAGE-NOTES.md` for the repro). Fixed with a
18
+ one-line cursor repair in `disposeNode` (advance the cursor to the next surviving
19
+ dep before the free); O(1), disposal path only, no steady-state cost. The now-dead
20
+ `freeLink` `-1` defensive ternaries were removed with it. Pinned by a regression
21
+ test in `test/12-coverage.test.mjs`.
22
+
23
+ ### Changed -- branch coverage closed to 100%
24
+
25
+ Branch coverage on `Signal.js` went `97.35% -> 100%`. Three reachable branches
26
+ gained tests (`allocateLink` dead-target gate, `executeEffect` scheduler
27
+ re-entrancy, `computed` stale-handle read), the new box + owner surface gained
28
+ tests (box stale-handle guards, `computedBox` `equals`, top-level `getOwner` /
29
+ `runWithOwner` delegators), and the two provably-unreachable clamps (link-ledger,
30
+ `batchEpoch` wraparound) carry `/* c8 ignore */` with proofs. See
31
+ `COVERAGE-NOTES.md`; reconfirm under codify.
32
+
33
+ ### Tooling -- harness reorganization (no engine change)
34
+
35
+ The loose `harness/` probes are now routed through a single dispatcher
36
+ (`harness/run.mjs`) and exposed as npm scripts: `harness:field`,
37
+ `harness:dispose`, `harness:churn`, `harness:owner`, `harness:creation`, and
38
+ `harness:all` (field + dispose + churn in sequence). `harness:field` is the
39
+ portable fieldkit verify + cold-child A/B bench; the rest map one-to-one to the
40
+ existing probe files. Paths resolve from the dispatcher, so the working
41
+ directory no longer matters.
42
+
43
+ The empirical owner-recycling reproducer is documented at its real home,
44
+ `harness/owner-hazard-repro.mjs`; the earlier `Publications/...` citations in
45
+ README / CHANGELOG / llms.txt pointed at a path the file was never in, and are
46
+ corrected. The broken parent/child link in the createComputations matrix
47
+ (`creation-isolated.mjs` now resolves `andrii-isolated-child.mjs`) is repaired.
48
+
49
+ Six settled one-off probes -- the five from the 1.2.0 -> 1.2.1 construction-
50
+ shape regression hunt, plus the superseded `repro-set-after-dispose.mjs` (its
51
+ invariant now pinned by `test/07-dispose` and `test/26-free-list-invariant`) --
52
+ are parked in `harness/attic/` with a README explaining each. `Signal.js` is
53
+ untouched and the published `files[]` whitelist is unchanged, so installed
54
+ tarballs are byte-identical; this is a repo-tooling change only.
55
+
7
56
  ## [1.5.0-beta.2] -- 2026-07-XX
8
57
 
9
58
  The re-attach companion to `createRoot`: **`getOwner`** and **`runWithOwner`**
@@ -46,7 +95,7 @@ engine because nodes are pooled and the LIFO free list recycles a
46
95
  disposed owner's slot into whatever effect/computed is allocated next.
47
96
  Two failure modes were empirically reproduced against a 1.5.0-beta
48
97
  engine patched with the raw-pointer alternative
49
- (`Publications/owner-hazard-repro.mjs`):
98
+ (`harness/owner-hazard-repro.mjs`):
50
99
 
51
100
  - **Recycled-slot cascade death.** Owner A captured; A disposed; effect B
52
101
  allocated (LIFO -> same slot); `runWithOwner(captured)` silently
@@ -93,13 +142,13 @@ Full test suite on 1.5.0-beta.2: **455 total** (439 pre-existing +
93
142
  `25-devtools-real-boot` cases that need `@zakkster/lite-devtools`
94
143
  installed as a peer -- pre-existing, unrelated).
95
144
 
96
- ### Added -- `Publications/owner-hazard-repro.mjs`
145
+ ### Added -- `harness/owner-hazard-repro.mjs`
97
146
 
98
147
  A standalone reproducer for the two hazards, callable against any engine
99
148
  (`node owner-hazard-repro.mjs <path-to-Signal.js>`). Prints
100
149
  `VERDICT: SAFE` on the shipping implementation, `VERDICT: CORRUPTED` +
101
- a stack overflow on the raw-pointer sketch. Kept in `Publications/`
102
- alongside the other reproducers rather than under `test/` so it can
150
+ a stack overflow on the raw-pointer sketch. Kept in `harness/`
151
+ alongside the other run-on-demand probes rather than under `test/` so it can
103
152
  travel to other engines (a candidate 1.6, or a rejected candidate you
104
153
  want to confirm) without dragging the whole test tree along.
105
154
 
package/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  [![npm bundle size](https://img.shields.io/bundlephobia/minzip/@zakkster/lite-signal?style=for-the-badge)](https://bundlephobia.com/result?p=@zakkster/lite-signal)
10
10
  [![npm downloads](https://img.shields.io/npm/dm/@zakkster/lite-signal?style=for-the-badge&color=blue)](https://www.npmjs.com/package/@zakkster/lite-signal)
11
11
  [![npm total downloads](https://img.shields.io/npm/dt/@zakkster/lite-signal?style=for-the-badge&color=blue)](https://www.npmjs.com/package/@zakkster/lite-signal)
12
+ ![Tree-Shakeable](https://img.shields.io/badge/tree--shakeable-yes-brightgreen)
12
13
  ![TypeScript](https://img.shields.io/badge/TypeScript-Types-informational)
13
14
  ![Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)
14
15
  [![license](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](./LICENSE)
@@ -380,7 +381,7 @@ effect(() => {
380
381
 
381
382
  `getOwner()` returns the current owner as an **opaque, gen-stamped handle** (or `undefined` outside any effect/computed body). `runWithOwner(handle, fn)` runs `fn` with the captured lifecycle scope reinstated: effects and computeds created directly in `fn` are adopted by that owner and cascade-dispose when it re-runs or is disposed. Reads directly in `fn` do not link -- tracking is detached the same way `createRoot` detaches it, so accidental cross-async edges cannot form. Compose with an inner effect if you want tracking under the restored owner.
382
383
 
383
- **Handles are safe to hold across async boundaries.** This is where a raw-pointer implementation would corrupt the graph: node objects are pooled and the LIFO free list recycles a disposed owner's slot into whatever effect/computed is allocated next. A stale raw pointer would silently adopt continuations into that stranger. Instead, `getOwner` returns a `describeNode` handle stamped with the pool slot's generation; `runWithOwner` resolves via `liveNode()`, and if the gen has moved (slot recycled) or the handle refers to a signal (not a tracker), it degrades to **rooted execution** -- the continuation runs, stays alive, and is simply not owned by anyone. That is the only honest semantics for "the scope you captured no longer exists": the alternative was a silent cascade-dispose by an unrelated stranger, or, if the slot was disposed but not yet recycled, a `RangeError: Maximum call stack size exceeded` inside the cleanup recursion. Both hazards are pinned in `test/28-run-with-owner.test.mjs` and empirically demonstrated in `Publications/owner-hazard-repro.mjs`.
384
+ **Handles are safe to hold across async boundaries.** This is where a raw-pointer implementation would corrupt the graph: node objects are pooled and the LIFO free list recycles a disposed owner's slot into whatever effect/computed is allocated next. A stale raw pointer would silently adopt continuations into that stranger. Instead, `getOwner` returns a `describeNode` handle stamped with the pool slot's generation; `runWithOwner` resolves via `liveNode()`, and if the gen has moved (slot recycled) or the handle refers to a signal (not a tracker), it degrades to **rooted execution** -- the continuation runs, stays alive, and is simply not owned by anyone. That is the only honest semantics for "the scope you captured no longer exists": the alternative was a silent cascade-dispose by an unrelated stranger, or, if the slot was disposed but not yet recycled, a `RangeError: Maximum call stack size exceeded` inside the cleanup recursion. Both hazards are pinned in `test/28-run-with-owner.test.mjs` and empirically demonstrated in `harness/owner-hazard-repro.mjs`.
384
385
 
385
386
  The handles do **not** keep owners alive -- they are snapshots, not references. Node lifetime is controlled by the owner tree, not by outstanding handles.
386
387
 
@@ -766,33 +767,33 @@ Three tiers, all reproducible.
766
767
 
767
768
  `npm test` runs the suite in `test/`, covering:
768
769
 
769
- - **`01-core_test.mjs`** -- signal/computed/effect basics, equality semantics, NaN/+/-0, subscribe/peek/update, untrack, batch, cleanup ordering, first-run error recovery, nested object reference-identity gotchas.
770
- - **`02-topology_test.mjs`** -- diamond glitch-freedom, 256-deep and 1024-deep computed chains, wide fan-out (1000 effects from one signal), dynamic dependency switching, conditional fan-out, nested effects, cycle detection (`CycleError`).
771
- - **`03-pool_test.mjs`** -- `CapacityError` under both `"throw"` and `"grow"` policies, the 16× link ceiling, stable pool reuse across thousands of create/dispose cycles, registry isolation, (1.3.0) the lazy-prealloc paths: on-demand construction reaching the same steady state as eager, a never-allocated lazy registry surviving `destroy()`, and `"grow"` extending both pool ledgers past their initial capacity, and (1.4.0) the `stats()` lifecycle counters: the 11-key shape, `totalAllocations` / `totalDisposals` tracking the `activeNodes` live invariant, `poolGrowths` firing on growth and staying 0 on a correctly-sized eager pool, and `destroy()` resetting all three.
772
- - **`05-scheduler_test.mjs`** -- scheduler-deferred effects, dispose-during-schedule races, microtask integration, 32-bit version wrap (simulated), `setDefaultRegistry`, `onCleanup` inside computeds.
773
- - **`06-nested-objects_test.mjs`** -- array mutation patterns (push/splice/spread), deep nested paths, Map/Set/Date inside signals, custom structural equality, computed memoisation cutoffs over object slices, signal-of-signals composition, high-frequency object updates, batched immutable updates.
774
- - **`07-dispose_test.mjs`** -- unified `dispose(api)` across signals, computeds and effect handles, idempotency, cross-registry isolation (per-registry Symbol prevents pool corruption), foreign-value safety, top-level helper routing, 500-cycle balanced churn leaving pool and stats stable.
775
- - **`08-watch_test.mjs`** -- Validates the user-land observer utilities (watch, when, whenAsync). Covers lifecycle teardown, old/new value tracking, and Promise-based asynchronous state resolution.
776
- - **`09-conformance_test.mjs`** -- Industry-standard conformance tests. Validates the engine against extreme edge cases from the johnsoncodehk reactive test suite, ensuring strict zero-GC invariants, correct cleanup isolation, and re-entrant stability.
777
- - **`10-is-tracking_test.mjs`** -- The `isTracking()` observer-context predicate. 11 tests across 5 describe blocks: true inside effect/computed bodies; false inside `untrack`, `subscribe` callbacks, `onCleanup` bodies, and `watch` callbacks (the untracked-window cases that catch an observer-only misimplementation); false outside any observer including at the call site of an unobserved computed read; state-restoration after a thrown body; per-registry isolation; top-level binding.
778
- - **`11-adopted-reactive_test.mjs`** -- 24 engine-agnostic edge cases adopted from across the ecosystem: alien-signals' parent-child link-integrity regression (#226-228), equality-predicate corners (preact/solid/vue), `signal.update(fn)` functional setter (vue/solid), `peek()` non-subscription depth (preact/vue), and the `subscribe` behavioral contract (preact/mobx).
779
- - **`12-coverage_test.mjs`** -- 18 targeted exercises for public surface and hot-path branches the behavioral suites don't incidentally hit: top-level routing to the default registry, the computed clean-read short-circuit (`markEpoch` O(1) skip), dependency-set shrink severing the stale tail, error/structural edge paths, scheduler ABA across a recycled pool slot, and the v1.2 owner-tree paths (direct-child detach, cascade tolerates an already-freed child). Capability-gated via a runtime probe, so the same file runs unchanged across engines.
780
- - **`13-introspection_test.mjs`** -- The observer-lifecycle surface (1.1.4). 10 tests across 3 describe blocks: `hasObservers` (live observation reflects; a peek doesn't count), `observeObservers` auto-pause lifecycle (start-on-first / stop-on-last, no extra connect for a 2nd observer, re-observe fires again, no churn on re-track, conditional reads toggle honestly, transition-only registration, works for computeds), and `forEachObserver`/`forEachSource` enumeration (both directions; descriptor carries kind + value).
781
- - **`14-lifecycle-teardown_test.mjs`** -- Effect-teardown guards against the alien-signals@3.2.1 regressions (4 tests). A stopped effect must not re-subscribe to a signal read later in the same run; self-dispose must leave no orphaned link (clean `activeLinks`); a throwing setup must leave no live subscription; normal and dynamic re-tracking stay unaffected by the `allocateLink` eligibility gate.
782
- - **`15-owner-lazy-alloc_test.mjs`** -- Owner-adoption contract for the 1.2.0 owner tree (5 tests). A signal allocated lazily *inside* a computed/effect must **not** be owner-adopted (it survives the owner's re-run -- the lite-store/lite-form lazy-field shape) and sibling lazy signals must not cross-wire, while observers (nested effect/computed) *are* still auto-disposed on the owner's re-run.
783
- - **`16-alien-parity_test.mjs`** -- Differential regression guards (3 tests) reproducing the *properties* behind alien-signals@3.2.0 fixed bugs: reads inside a cleanup create no spurious dependencies (the dispose-cleanup fix); an inner-effect write does not block later propagation through a computed chain (#112); a dynamic dependency-set change stays correct under dirty-check (#109/#110).
784
- - **`17-reactivity_test.mjs`** -- Behavioral suite (~30 tests across 11 groups) mirroring universal signal-system bug classes: subscription lifecycle, cleanup ordering, stale-dependency tracking, batching/timing (incl. set-then-revert), equality cutoff (NaN/+/-0/custom), nested invalidation + glitch-free diamond, memory/retained nodes, the synchronous async-boundary, scheduler & loops (self-write termination, self-reading computed), and differential-review additions (cached computed errors, mid-batch pull, self-disposing getter, pooled-slot return). SSR hydration is a documented N/A -- lite has no DOM layer.
785
- - **`18-identity_test.mjs`** -- Node identity (1.1.5; 5 tests). Unique/stable ids; `nodeId`/`describe` return `undefined` for a non-handle; the descriptor's visible shape is `{ id, kind, value }`; `forEach*` descriptors carry `id` and are **re-walkable** (`nodeId`/`forEachSource` accept a descriptor); identity walks are non-perturbing (add no observers).
786
- - **`19-v12-additions_test.mjs`** -- v1.2.0 release-prep regressions (24 tests across 8 suites). Shared `peek` (one closure per registry, identical reference across primitives, no tracking, two registries hold independent peeks). Owner-adoption rule (signals not adopted, computeds/effects adopted, cascade drains correctly). Pre-batch revert (signal-level, propagates through computeds, respects custom `equals`, nested batches, final-different-value still fires). Multi-throw aggregation (`AggregateError` with both errors carried, single-throw unwrapped, engine survives). `CycleError` via `maxFlushPasses` (default + custom). `maxLinks` config branch under `throw` and `grow`. Documented disposed-signal semantics (read undefined, set silent no-op, dispose idempotent). Scheduler-thunk ABA guard across a recycled pool slot.
787
- - **`20-axis-stress_test.mjs`** -- engine-invariant regression guards along eight orthogonal "axes" (16 tests across 9 suites). Pins lite-signal's actual contract on: batch semantics under exception (writes commit; pre-batch revert holds; effects see the post-throw value), connect/disconnect lifecycle re-entrancy (`observeObservers` from inside an `onConnect`, transition-only registration), untrack does NOT suppress owner adoption (a nested effect created via `untrack` is still owner-cascaded), untrack inside a computed body (no hidden dep leaks; tracked source re-evaluates), queue safety under self-dispose mid-flush (no UAF), value-dependent cycle detection (computed graph closes a cycle, `CycleError` thrown), nested-effect creation order (effects run synchronously on creation; immediately-stopped one still ran), synchronous flush (no scheduler in the default path; batch coalesces). Plus a bonus suite: 1,000 effect-create-then-dispose cycles return pool to baseline; `dispose()` idempotent; `dispose()` on foreign values safe.
788
- - **`21-perf-pins_test.mjs`** -- v1.2.1 construction-shape pins (6 tests). Locks the canonical handle shapes (`signal` 6 own props: peek/set/update/subscribe + NODE_PTR/NODE_GEN; `computed` 4: peek/subscribe + NODE_PTR/NODE_GEN) so a future "let's unify them" change has to be explicit. Locks the 1.2.1 ABA guards: detached `const {set} = signal()` keeps working on a LIVE signal; `read()` returns `undefined` and skips dep-tracking on a stale handle (no phantom subscription to the recycled slot); `set()` on a stale handle is a no-op across three corruption tiers (disposed slot, recycled slot, downstream propagation); `peek()` returns `undefined` for stale signal and computed handles.
789
- - **`22-mutation-hook_test.mjs`** -- 1.2.1 `onGraphMutation` semantics (12 tests across 2 suites). Registration: unsubscribe returns a function; `null` argument clears and the unsub restores the prior listener; non-function/non-null throws `TypeError`; multiple registrations stack LIFO; registries are isolated (no cross-talk). Opcode emission: `1` node-create fires with `(id, flags)` for signal (32) / computed (1) / effect (2); `2` node-dispose fires for cascade-disposed owned children; `3` link-add fires with `(source.id, target.id)` on dependency record; `4` link-remove fires when a dep-set flip severs the tail; `5` recompute fires on initial eval AND re-eval; the hook fires synchronously inside the mutation (listener sees its own event before the caller returns); payload is always three plain numbers -- no objects, no closures.
790
- - **`23-owner-introspection_test.mjs`** -- 1.2.1 owner-tree introspection + effect-disposer regression (22 tests across 4 suites). `ownerOf`: undefined for top-level / garbage input / stale handle; returns the enclosing effect's descriptor for a child created inside an effect body. `forEachOwned`: no-op for handles with no owned children / garbage input / stale handle; iterates owned children as `{id, kind, value}` descriptors. Gen-guarded introspection (ABA fix): `nodeId` / `describe` / `hasObservers` return undefined / false for stale handles; `observeObservers` throws `TypeError`; `forEachObserver` / `forEachSource` are no-ops; descriptors returned by `describeNode` are themselves gen-stamped so a descriptor obtained pre-recycle correctly walks as a no-op post-recycle (the "descriptors are re-walkable handles" contract survives the guard). Plus the 1.2.1 effect-dispose-handle fix: passing the effect's disposer directly to `describe` / `nodeId` / `forEachSource` / `forEachOwned` / `ownerOf` / `hasObservers` works as a first-class introspection handle (pre-fix it was a bare closure and returned `undefined` for a *live* effect); after `fx()` dispose the same handle correctly goes stale on every entry point; the disposer's `NODE_GEN` mirrors the effect node's birthGen exactly.
791
- - **`24-signalbox_test.mjs`** -- the `signalBox` / `computedBox` allocation-light handle API, **activated in 1.5.0** (committed `{skip:true}` since 1.3.0, now running against the real implementation). 12 tests: box get/set/peek/update, `computedBox` derive + memoize, peek-does-not-track, subscribe fires-and-untracks, box<->callable interop both directions, batch coalescing (including set-then-revert net no-op), dispose with ABA-safety, the `equals` short-circuit, `computedBox.peek`, and the top-level helpers bound to the default registry.
792
- - **`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.
793
- - **`28-run-with-owner.test.mjs`** -- `getOwner` / `runWithOwner` (1.5.0-beta.2), the re-attach companion. 16 tests, structured in three groups: basic shape (7 tests: undefined outside, effect/computed inside, restore-on-return, throw-safety, nesting), degradation (3 tests: null / undefined / signal-handle all fall through to rooted execution), and the three **hazard pins** that a raw-pointer implementation fails: (i) recycled-slot cascade -- capture, dispose owner, allocate an effect that reuses the pool slot, `runWithOwner(captured)` must not adopt into the recycled slot's new resident; (ii) corpse adoption -- capture, dispose owner but not-yet-recycled, `runWithOwner(captured, () => effect(...))` must not crash with `RangeError` in the cleanup recursion; (iii) composed -- both together, continuation must survive stranger re-runs AND disposal. All three fail against the naive `getOwner() { return currentOwner; }` shape (empirically verified against a 1.5.0-beta engine patched with the raw-pointer alternative -- `Publications/owner-hazard-repro.mjs`); all three pass with the `describeNode` gen-stamped handle + `liveNode` ABA guard that ships.
794
- - **`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.
795
- - **`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%).
770
+ - **`01-core.test.mjs`** -- signal/computed/effect basics, equality semantics, NaN/+/-0, subscribe/peek/update, untrack, batch, cleanup ordering, first-run error recovery, nested object reference-identity gotchas.
771
+ - **`02-topology.test.mjs`** -- diamond glitch-freedom, 256-deep and 1024-deep computed chains, wide fan-out (1000 effects from one signal), dynamic dependency switching, conditional fan-out, nested effects, cycle detection (`CycleError`).
772
+ - **`03-pool.test.mjs`** -- `CapacityError` under both `"throw"` and `"grow"` policies, the 16× link ceiling, stable pool reuse across thousands of create/dispose cycles, registry isolation, (1.3.0) the lazy-prealloc paths: on-demand construction reaching the same steady state as eager, a never-allocated lazy registry surviving `destroy()`, and `"grow"` extending both pool ledgers past their initial capacity, and (1.4.0) the `stats()` lifecycle counters: the 11-key shape, `totalAllocations` / `totalDisposals` tracking the `activeNodes` live invariant, `poolGrowths` firing on growth and staying 0 on a correctly-sized eager pool, and `destroy()` resetting all three.
773
+ - **`05-scheduler.test.mjs`** -- scheduler-deferred effects, dispose-during-schedule races, microtask integration, 32-bit version wrap (simulated), `setDefaultRegistry`, `onCleanup` inside computeds.
774
+ - **`06-nested-objects.test.mjs`** -- array mutation patterns (push/splice/spread), deep nested paths, Map/Set/Date inside signals, custom structural equality, computed memoisation cutoffs over object slices, signal-of-signals composition, high-frequency object updates, batched immutable updates.
775
+ - **`07-dispose.test.mjs`** -- unified `dispose(api)` across signals, computeds and effect handles, idempotency, cross-registry isolation (per-registry Symbol prevents pool corruption), foreign-value safety, top-level helper routing, 500-cycle balanced churn leaving pool and stats stable.
776
+ - **`08-watch.test.mjs`** -- Validates the user-land observer utilities (watch, when, whenAsync). Covers lifecycle teardown, old/new value tracking, and Promise-based asynchronous state resolution.
777
+ - **`09-conformance.test.mjs`** -- Industry-standard conformance tests. Validates the engine against extreme edge cases from the johnsoncodehk reactive test suite, ensuring strict zero-GC invariants, correct cleanup isolation, and re-entrant stability.
778
+ - **`10-is-tracking.test.mjs`** -- The `isTracking()` observer-context predicate. 11 tests across 5 describe blocks: true inside effect/computed bodies; false inside `untrack`, `subscribe` callbacks, `onCleanup` bodies, and `watch` callbacks (the untracked-window cases that catch an observer-only misimplementation); false outside any observer including at the call site of an unobserved computed read; state-restoration after a thrown body; per-registry isolation; top-level binding.
779
+ - **`11-adopted-reactive.test.mjs`** -- 24 engine-agnostic edge cases adopted from across the ecosystem: alien-signals' parent-child link-integrity regression (#226-228), equality-predicate corners (preact/solid/vue), `signal.update(fn)` functional setter (vue/solid), `peek()` non-subscription depth (preact/vue), and the `subscribe` behavioral contract (preact/mobx).
780
+ - **`12-coverage.test.mjs`** -- 33 targeted exercises for public surface and hot-path branches the behavioral suites don't incidentally hit: top-level routing to the default registry, the computed clean-read short-circuit (`markEpoch` O(1) skip), dependency-set shrink severing the stale tail, error/structural edge paths, scheduler ABA across a recycled pool slot, and the v1.2 owner-tree paths (direct-child detach, cascade tolerates an already-freed child). The 1.5.0 coverage-closure block adds: the `allocateLink` dead-target gate, the `executeEffect` scheduler-reentrancy cycle throw, the `computed` stale-handle read, the `disposeNode` cursor-repair regression (the dangling-cursor crash fix), the box stale-handle guards (`boxUpdate`/`boxComputedGet`/`boxComputedPeek`), the `computedBox` `equals` option, and the top-level `getOwner`/`runWithOwner` delegators. Capability-gated via runtime probes, so the same file runs unchanged across engines.
781
+ - **`13-introspection.test.mjs`** -- The observer-lifecycle surface (1.1.4). 10 tests across 3 describe blocks: `hasObservers` (live observation reflects; a peek doesn't count), `observeObservers` auto-pause lifecycle (start-on-first / stop-on-last, no extra connect for a 2nd observer, re-observe fires again, no churn on re-track, conditional reads toggle honestly, transition-only registration, works for computeds), and `forEachObserver`/`forEachSource` enumeration (both directions; descriptor carries kind + value).
782
+ - **`14-lifecycle-teardown.test.mjs`** -- Effect-teardown guards against the alien-signals@3.2.1 regressions (4 tests). A stopped effect must not re-subscribe to a signal read later in the same run; self-dispose must leave no orphaned link (clean `activeLinks`); a throwing setup must leave no live subscription; normal and dynamic re-tracking stay unaffected by the `allocateLink` eligibility gate.
783
+ - **`15-owner-lazy-alloc.test.mjs`** -- Owner-adoption contract for the 1.2.0 owner tree (5 tests). A signal allocated lazily *inside* a computed/effect must **not** be owner-adopted (it survives the owner's re-run -- the lite-store/lite-form lazy-field shape) and sibling lazy signals must not cross-wire, while observers (nested effect/computed) *are* still auto-disposed on the owner's re-run.
784
+ - **`16-alien-parity.test.mjs`** -- Differential regression guards (3 tests) reproducing the *properties* behind alien-signals@3.2.0 fixed bugs: reads inside a cleanup create no spurious dependencies (the dispose-cleanup fix); an inner-effect write does not block later propagation through a computed chain (#112); a dynamic dependency-set change stays correct under dirty-check (#109/#110).
785
+ - **`17-reactivity.test.mjs`** -- Behavioral suite (~30 tests across 11 groups) mirroring universal signal-system bug classes: subscription lifecycle, cleanup ordering, stale-dependency tracking, batching/timing (incl. set-then-revert), equality cutoff (NaN/+/-0/custom), nested invalidation + glitch-free diamond, memory/retained nodes, the synchronous async-boundary, scheduler & loops (self-write termination, self-reading computed), and differential-review additions (cached computed errors, mid-batch pull, self-disposing getter, pooled-slot return). SSR hydration is a documented N/A -- lite has no DOM layer.
786
+ - **`18-identity.test.mjs`** -- Node identity (1.1.5; 5 tests). Unique/stable ids; `nodeId`/`describe` return `undefined` for a non-handle; the descriptor's visible shape is `{ id, kind, value }`; `forEach*` descriptors carry `id` and are **re-walkable** (`nodeId`/`forEachSource` accept a descriptor); identity walks are non-perturbing (add no observers).
787
+ - **`19-v12-additions.test.mjs`** -- v1.2.0 release-prep regressions (24 tests across 8 suites). Shared `peek` (one closure per registry, identical reference across primitives, no tracking, two registries hold independent peeks). Owner-adoption rule (signals not adopted, computeds/effects adopted, cascade drains correctly). Pre-batch revert (signal-level, propagates through computeds, respects custom `equals`, nested batches, final-different-value still fires). Multi-throw aggregation (`AggregateError` with both errors carried, single-throw unwrapped, engine survives). `CycleError` via `maxFlushPasses` (default + custom). `maxLinks` config branch under `throw` and `grow`. Documented disposed-signal semantics (read undefined, set silent no-op, dispose idempotent). Scheduler-thunk ABA guard across a recycled pool slot.
788
+ - **`20-axis-stress.test.mjs`** -- engine-invariant regression guards along eight orthogonal "axes" (16 tests across 9 suites). Pins lite-signal's actual contract on: batch semantics under exception (writes commit; pre-batch revert holds; effects see the post-throw value), connect/disconnect lifecycle re-entrancy (`observeObservers` from inside an `onConnect`, transition-only registration), untrack does NOT suppress owner adoption (a nested effect created via `untrack` is still owner-cascaded), untrack inside a computed body (no hidden dep leaks; tracked source re-evaluates), queue safety under self-dispose mid-flush (no UAF), value-dependent cycle detection (computed graph closes a cycle, `CycleError` thrown), nested-effect creation order (effects run synchronously on creation; immediately-stopped one still ran), synchronous flush (no scheduler in the default path; batch coalesces). Plus a bonus suite: 1,000 effect-create-then-dispose cycles return pool to baseline; `dispose()` idempotent; `dispose()` on foreign values safe.
789
+ - **`21-perf-pins.test.mjs`** -- v1.2.1 construction-shape pins (6 tests). Locks the canonical handle shapes (`signal` 6 own props: peek/set/update/subscribe + NODE_PTR/NODE_GEN; `computed` 4: peek/subscribe + NODE_PTR/NODE_GEN) so a future "let's unify them" change has to be explicit. Locks the 1.2.1 ABA guards: detached `const {set} = signal()` keeps working on a LIVE signal; `read()` returns `undefined` and skips dep-tracking on a stale handle (no phantom subscription to the recycled slot); `set()` on a stale handle is a no-op across three corruption tiers (disposed slot, recycled slot, downstream propagation); `peek()` returns `undefined` for stale signal and computed handles.
790
+ - **`22-mutation-hook.test.mjs`** -- 1.2.1 `onGraphMutation` semantics (12 tests across 2 suites). Registration: unsubscribe returns a function; `null` argument clears and the unsub restores the prior listener; non-function/non-null throws `TypeError`; multiple registrations stack LIFO; registries are isolated (no cross-talk). Opcode emission: `1` node-create fires with `(id, flags)` for signal (32) / computed (1) / effect (2); `2` node-dispose fires for cascade-disposed owned children; `3` link-add fires with `(source.id, target.id)` on dependency record; `4` link-remove fires when a dep-set flip severs the tail; `5` recompute fires on initial eval AND re-eval; the hook fires synchronously inside the mutation (listener sees its own event before the caller returns); payload is always three plain numbers -- no objects, no closures.
791
+ - **`23-owner-introspection.test.mjs`** -- 1.2.1 owner-tree introspection + effect-disposer regression (22 tests across 4 suites). `ownerOf`: undefined for top-level / garbage input / stale handle; returns the enclosing effect's descriptor for a child created inside an effect body. `forEachOwned`: no-op for handles with no owned children / garbage input / stale handle; iterates owned children as `{id, kind, value}` descriptors. Gen-guarded introspection (ABA fix): `nodeId` / `describe` / `hasObservers` return undefined / false for stale handles; `observeObservers` throws `TypeError`; `forEachObserver` / `forEachSource` are no-ops; descriptors returned by `describeNode` are themselves gen-stamped so a descriptor obtained pre-recycle correctly walks as a no-op post-recycle (the "descriptors are re-walkable handles" contract survives the guard). Plus the 1.2.1 effect-dispose-handle fix: passing the effect's disposer directly to `describe` / `nodeId` / `forEachSource` / `forEachOwned` / `ownerOf` / `hasObservers` works as a first-class introspection handle (pre-fix it was a bare closure and returned `undefined` for a *live* effect); after `fx()` dispose the same handle correctly goes stale on every entry point; the disposer's `NODE_GEN` mirrors the effect node's birthGen exactly.
792
+ - **`24-signalbox.test.mjs`** -- the `signalBox` / `computedBox` allocation-light handle API, **activated in 1.5.0** (committed `{skip:true}` since 1.3.0, now running against the real implementation). 12 tests: box get/set/peek/update, `computedBox` derive + memoize, peek-does-not-track, subscribe fires-and-untracks, box<->callable interop both directions, batch coalescing (including set-then-revert net no-op), dispose with ABA-safety, the `equals` short-circuit, `computedBox.peek`, and the top-level helpers bound to the default registry.
793
+ - **`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.
794
+ - **`28-run-with-owner.test.mjs`** -- `getOwner` / `runWithOwner` (1.5.0-beta.2), the re-attach companion. 16 tests, structured in three groups: basic shape (7 tests: undefined outside, effect/computed inside, restore-on-return, throw-safety, nesting), degradation (3 tests: null / undefined / signal-handle all fall through to rooted execution), and the three **hazard pins** that a raw-pointer implementation fails: (i) recycled-slot cascade -- capture, dispose owner, allocate an effect that reuses the pool slot, `runWithOwner(captured)` must not adopt into the recycled slot's new resident; (ii) corpse adoption -- capture, dispose owner but not-yet-recycled, `runWithOwner(captured, () => effect(...))` must not crash with `RangeError` in the cleanup recursion; (iii) composed -- both together, continuation must survive stranger re-runs AND disposal. All three fail against the naive `getOwner() { return currentOwner; }` shape (empirically verified against a 1.5.0-beta engine patched with the raw-pointer alternative -- `harness/owner-hazard-repro.mjs`); all three pass with the `describeNode` gen-stamped handle + `liveNode` ABA guard that ships.
795
+ - **`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.
796
+ - **`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%).
796
797
 
797
798
  ```bash
798
799
  npm test
@@ -800,7 +801,7 @@ npm test
800
801
 
801
802
  ### Tier 2 -- Memory (allocation-free verification)
802
803
 
803
- `npm run test:gc` runs `test/04-zero-gc_test.mjs` with `--expose-gc`:
804
+ `npm run test:gc` runs `test/04-zero-gc.test.mjs` with `--expose-gc`:
804
805
 
805
806
  - 100,000 `set()` calls on a graph with effects retain **< 200 KB** of heap.
806
807
  - 1,000 create/dispose cycles retain **< 50 KB**.
@@ -854,6 +855,22 @@ Beyond the engine's own test tiers above, `@zakkster/lite-signal` ships **dedica
854
855
 
855
856
  This section will grow. As future versions ship publications that need specific defensive validation (e.g. a `flushStrategy` ship, a TC39-polyfill ship, a zero-GC public gate, a profiler/observability ship), the corresponding harness lands here.
856
857
 
858
+ ### `harness/` -- run-on-demand probes
859
+
860
+ Single-file probes that don't warrant their own subdirectory. One dispatcher (`harness/run.mjs`) routes them; each keeps its own node flags, and paths resolve from the dispatcher so the working directory never matters. Run against the local engine, or pass an explicit `Signal.js` to profile a candidate build:
861
+
862
+ ```bash
863
+ npm run harness:field # verify + cold-child A/B bench (fieldkit)
864
+ npm run harness:field -- ./Signal.js ./archived/1.5.0.js # A/B two engines
865
+ npm run harness:dispose # creation cost: signal() vs signalBox() vs alien
866
+ npm run harness:churn # topology-churn-per-recompute (1.11 cone-cache gate)
867
+ npm run harness:owner # async-gap owner-recycling hazard verdict
868
+ npm run harness:creation # per-framework createComputations matrix
869
+ npm run harness:all # field + dispose + churn, in sequence
870
+ ```
871
+
872
+ `owner-hazard-repro.mjs` is the reproducer cited in the `getOwner` / `runWithOwner` notes: it prints `VERDICT: SAFE` on the shipping engine and `VERDICT: CORRUPTED` on a raw-pointer sketch. The `dispose` and `creation` probes compare against `alien-signals`, which is **not** a declared dependency -- without it, `dispose` runs the two lite columns only, and `creation` needs it plus `LITE_V120_PATH` to light the extra columns (`npm i -D alien-signals` unlocks them). Settled one-off probes -- the 1.2.0 -> 1.2.1 construction-shape regression hunt -- are parked in `harness/attic/`, kept for provenance and wired into nothing.
873
+
857
874
  ### `test/ProfilerTests/` -- version-portable hardening suite
858
875
 
859
876
  An adversarial, **version-portable** conformance + hardening suite for `@zakkster/lite-signal`. `node:test` only, zero test deps. Each file imports the **bare** package (`@zakkster/lite-signal`), so it resolves to whatever version is installed when run standalone, and self-references through this repo's own package name when run inside the source tree. Advanced cases are **feature-gated**: an older engine skips the cases for APIs it does not have yet, and they light up automatically as the surface grows.
@@ -1236,6 +1253,9 @@ npm test # behavior suite, ~1.3s
1236
1253
  npm run test:gc # zero-gc suite, requires --expose-gc, ~3s
1237
1254
  npm run bench # comparative benchmark vs alien-signals (results.txt), ~5min
1238
1255
  npm run bench-reactive # 5-framework reactivity suite (resultsReactive.txt)
1256
+ npm run harness:field # verify + cold-child A/B bench (fieldkit)
1257
+ npm run harness:all # field + dispose + churn probes, in sequence
1258
+ npm run gate # cold-process version-matrix regression gate (also runs on prepublish)
1239
1259
  npm run verify # test + test:gc + sanity bench; gate for publish
1240
1260
  ```
1241
1261
 
package/Signal.js CHANGED
@@ -382,6 +382,14 @@ export function createRegistry(config) {
382
382
  if (linkPool.length > currentLinkCapacity) {
383
383
  let doubled = currentLinkCapacity;
384
384
  while (doubled < linkPool.length) doubled *= 2;
385
+ // The `> maxLinkLimit` arm is provably unreachable, retained as a clamp.
386
+ // Proof: maxLinkLimit === initialLinkCapacity * 16, currentLinkCapacity is
387
+ // only ever assigned a power-of-2 multiple of that same initial capacity,
388
+ // so 16x is ON the doubling chain (m, 2m, 4m, 8m, 16m). The guard above
389
+ // (`linkPool.length >= maxLinkLimit -> CapacityError`) plus the chunk math
390
+ // (`chunk = limit - linkPool.length`) cap linkPool.length AT maxLinkLimit,
391
+ // so `doubled` terminates at exactly 16m and can never exceed it.
392
+ /* c8 ignore next -- unreachable clamp; see proof above + COVERAGE-NOTES.md */
385
393
  currentLinkCapacity = doubled > maxLinkLimit ? maxLinkLimit : doubled;
386
394
  statPoolGrowths++; // 1.4: link capacity ledger crossed
387
395
  }
@@ -414,7 +422,12 @@ export function createRegistry(config) {
414
422
 
415
423
  /** Return a link to the free pool and unlink it from the source's sub list. @private */
416
424
  function freeLink(link, target, source) {
417
- if (mutationHook !== null) mutationHook(4, link.source !== null ? link.source.id : -1, link.target !== null ? link.target.id : -1);
425
+ // Every caller (allocateLink sever, severTail, disposeNode dep-walk) passes a
426
+ // LIVE link: `source === link.source`, `target === link.target`. The 1.3.x
427
+ // `link.source !== null ? ... : -1` guards existed only to survive a cursor
428
+ // dangling at an already-freed link -- a state disposeNode's CURSOR REPAIR now
429
+ // makes unreachable. Reading the params directly is equivalent and branch-free.
430
+ if (mutationHook !== null) mutationHook(4, source.id, target.id);
418
431
  const pSub = link.prevSub;
419
432
  const nSub = link.nextSub;
420
433
  if (pSub !== null) pSub.nextSub = nSub; else source.headSub = nSub;
@@ -525,6 +538,17 @@ export function createRegistry(config) {
525
538
  if (pDep !== null) pDep.nextDep = nDep; else target.headDep = nDep;
526
539
  if (nDep !== null) nDep.prevDep = pDep; else target.tailDep = pDep;
527
540
 
541
+ // CURSOR REPAIR (1.4.0): `target` may be an observer that is MID-RUN with
542
+ // its re-tracking cursor parked on this very link -- it linked `source` on
543
+ // the previous run, has not reached that read yet on this one, and now
544
+ // disposes `source` from its own body. Splicing the link out and handing it
545
+ // to the free list would leave activeObserverCurrentDep dangling at a freed
546
+ // slot: severTail would then read a nulled prevDep, wipe target.headDep
547
+ // (orphaning every surviving dep), and double-free the link -- freeLink
548
+ // null-derefs on `source.headSub`. Advance the cursor to the next surviving
549
+ // dep instead. Disposal path only; no steady-state cost.
550
+ if (activeObserverCurrentDep === sLink) activeObserverCurrentDep = nDep;
551
+
528
552
  sLink.source = null;
529
553
  sLink.target = null;
530
554
  sLink.prevDep = null;
@@ -1396,6 +1420,10 @@ export function createRegistry(config) {
1396
1420
  function batch(fn) {
1397
1421
  if (batchDepth === 0) {
1398
1422
  batchEpoch = (batchEpoch + 1) | 0;
1423
+ // 2^32 wraparound sentinel: batchEpoch is bumped ONLY here (and reset to 1 by
1424
+ // destroy()), so reaching 0 costs 4,294,967,295 top-level batch() calls. Kept
1425
+ // because revertEpoch comparisons treat 0 as "no capture".
1426
+ /* c8 ignore next -- 2^32 wraparound; unreachable without ~4.3e9 batches */
1399
1427
  if (batchEpoch === 0) batchEpoch = 1;
1400
1428
  }
1401
1429
  batchDepth = (batchDepth + 1) | 0;
package/llms.txt CHANGED
@@ -18,7 +18,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
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
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.
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
- - **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 `Publications/owner-hazard-repro.mjs`. Also exported as registry methods + top-level helpers.
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).
23
23
  - **Batch**: `batch(fn)` defers effect flush until the outermost batch closes. Nestable.
24
24
  - **Untrack**: `untrack(fn)` reads without subscribing.
@@ -76,7 +76,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
76
76
  effect/computed allocated. A raw-pointer alternative
77
77
  (`getOwner() { return currentOwner; }`) fails two hazards, both pinned
78
78
  in `test/28-run-with-owner.test.mjs` and empirically reproduced by
79
- `Publications/owner-hazard-repro.mjs`:
79
+ `harness/owner-hazard-repro.mjs`:
80
80
  (i) **Recycled-slot cascade death** -- owner A captured; A disposed;
81
81
  stranger B allocated (LIFO -> A's slot); `runWithOwner(captured)`
82
82
  silently adopts continuation into B; B's next re-run
@@ -136,10 +136,11 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
136
136
  suite (staged `{skip:true}` since 1.3.0) now runs and passes. **Tests:** 439
137
137
  total, 438 pass, 0 fail, **1 skip** (only the architecturally-N/A SSR case in
138
138
  `17-reactivity`; the 9 originally-staged signalBox tests are now active and
139
- the suite carries +3 box-coverage additions for a 12-test file, +7 `createRoot`
140
- tests in `test/27-create-root_test.mjs`). **Coverage:** `Signal.js`
141
- 100% statements / 97.35% branches / 100% functions / 100% lines; `Watch.js` 100%.
142
- Drop-in over 1.4.0.
139
+ the suite carries box-coverage additions plus the 1.5.0 coverage-closure block
140
+ in `test/12-coverage.test.mjs`, and `createRoot` tests in
141
+ `test/27-create-root.test.mjs`). **Coverage:** `Signal.js`
142
+ 100% statements / 100% branches / 100% functions / 100% lines; `Watch.js` 100%
143
+ (rc coverage pass; reconfirm under codify). Drop-in over 1.4.0.
143
144
  **VersionMatrix (identical-code guard, new in 1.5.0-beta):** the
144
145
  `harness/VersionMatrix/` regression gate now records the sha256 of the engine
145
146
  source at every capture (`baselines/<label>/engine.sha256`). If the candidate's
@@ -206,7 +207,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
206
207
  rate (delta totalAllocations / delta t), pool-reuse ratio
207
208
  (1 - poolGrowths*initialCap/totalAllocations), and churn without the engine
208
209
  computing rates -- the series lite-devtools 1.2 / lite-studio 1.2 plot. **Tests:**
209
- 429 total, 419 pass, 0 fail, 10 skip (6 new counter tests in `test/03-pool_test.mjs`
210
+ 429 total, 419 pass, 0 fail, 10 skip (6 new counter tests in `test/03-pool.test.mjs`
210
211
  cover the 11-key shape, the live invariant, poolGrowths firing on growth vs staying
211
212
  0 on a sized eager pool, and destroy() reset). **Coverage:** `Signal.js` 100%
212
213
  statements / 98.26% branches / 100% functions / 100% lines; `Watch.js` 100%.
@@ -245,8 +246,8 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
245
246
  allocation counters (`totalAllocations` / `totalDisposals` / `poolGrowths`) remain
246
247
  reserved for 1.4.0 and are still absent. **Tests:** 423 total, 413 pass, 0 fail,
247
248
  10 skip (the 10 skips are 9 signalBox-staged-for-1.5.0 in
248
- `test/24-signalbox_test.mjs` plus 1 architecturally-N/A SSR case in
249
- `17-reactivity`); 4 new pool tests in `test/03-pool_test.mjs` cover the lazy
249
+ `test/24-signalbox.test.mjs` plus 1 architecturally-N/A SSR case in
250
+ `17-reactivity`); 4 new pool tests in `test/03-pool.test.mjs` cover the lazy
250
251
  on-demand / never-allocated-destroy / grow-extends-ledger / link-ceiling paths.
251
252
  **Coverage** (c8@11, Node 22): `Signal.js` 100% statements / 98.26% branches /
252
253
  100% functions / 100% lines; `Watch.js` 100% across all four. Behavior-
@@ -264,17 +265,17 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
264
265
  the `ReactiveNode` constructor initializes them to the same values on the
265
266
  fresh-pool-growth path -- so the redundant writes in `createNode` were
266
267
  defense against a state that cannot exist. **No public surface change, no
267
- semantic change.** New `test/26-free-list-invariant_test.mjs` (3 invariant
268
+ semantic change.** New `test/26-free-list-invariant.test.mjs` (3 invariant
268
269
  tests + 1 targeted coverage test for the swallow-on-self-dispose-then-throw
269
270
  branch in `pullComputed`) asserts the invariant directly by inspecting
270
271
  freshly-allocated nodes via the documented `describe()` -> `NODE_PTR`
271
- introspection protocol; new `test/25-devtools-real-boot_test.mjs` (10 tests)
272
+ introspection protocol; new `test/25-devtools-real-boot.test.mjs` (10 tests)
272
273
  boots the actual `Devtools.js` against the 1.2.2 engine and pins the 1.2.x
273
274
  introspection contract for downstream tooling, including the 8-key
274
275
  `stats()` shape (`signals`, `computeds`, `effects`, `activeNodes`,
275
276
  `activeLinks`, `pooledLinks`, `nodePoolCapacity`, `linkPoolCapacity`).
276
277
  408 tests total: 398 pass, 10 skip, 0 fail (the 10 skips are 9
277
- signalBox-staged-for-1.5.0 in `test/24-signalbox_test.mjs` plus 1
278
+ signalBox-staged-for-1.5.0 in `test/24-signalbox.test.mjs` plus 1
278
279
  architecturally-N/A SSR case in `17-reactivity`). Coverage on `Signal.js`:
279
280
  100% statements / 98.43% branches / 100% functions / 100% lines; `Watch.js`
280
281
  100% across all four (c8@11, Node 22) -- a branch-coverage gain over the
@@ -376,7 +377,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
376
377
  own `{ id, kind, value }` descriptor, **re-walkable** (pass it back into
377
378
  `forEachObserver`/`forEachSource` to walk the full DAG); `forEach*` descriptors now carry
378
379
  `id`. One SMI write at allocation, node shape kept monomorphic -- **zero steady-state
379
- cost**. Drop-in over 1.1.4, no breaking changes. New `test/18-identity_test.mjs` (5 tests); plus `14-lifecycle-teardown`, `16-alien-parity`, and the `17-reactivity` behavioral suite.
380
+ cost**. Drop-in over 1.1.4, no breaking changes. New `test/18-identity.test.mjs` (5 tests); plus `14-lifecycle-teardown`, `16-alien-parity`, and the `17-reactivity` behavioral suite.
380
381
 
381
382
  - **1.1.4**: combined release -- a retracking rewrite plus an observer-lifecycle
382
383
  introspection surface. Drop-in over 1.1.3. **Retracking:** version-stamped O(1)
@@ -387,7 +388,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
387
388
  wide dense` 5115ms->912ms (verified by `retracking.difftest.mjs`: 20k direct + 10k batched, 0
388
389
  disagreements; no regressions elsewhere). **Introspection:** `hasObservers`,
389
390
  `observeObservers`, `forEachObserver`, `forEachSource` (top-level + per-registry), gated by
390
- an internal counter so zero steady-state cost when unused. New `test/13-introspection_test.mjs`
391
+ an internal counter so zero steady-state cost when unused. New `test/13-introspection.test.mjs`
391
392
  (10 tests). Internally staged as 1.1.4 + 1.1.5; ships as a single 1.1.4.
392
393
 
393
394
  - **1.1.3**: adds `isTracking()` (top-level + per-registry). Returns true iff a
@@ -685,37 +686,43 @@ function dumpOwnerTree(handle, depth = 0) {
685
686
 
686
687
  - `Signal.js` -- full implementation, single file.
687
688
  - `Signal.d.ts` -- TypeScript declarations for all public API.
688
- - `test/01-core_test.mjs` -- signal/computed/effect basics, equality, untrack.
689
- - `test/02-topology_test.mjs` -- diamonds, chains, fan-out/in, cycle detection.
690
- - `test/03-pool_test.mjs` -- capacity errors, grow policy, pool reuse.
691
- - `test/04-zero-gc_test.mjs` -- heap retention (run with --expose-gc).
692
- - `test/05-scheduler_test.mjs` -- scheduler races, dispose, gen counter, version wrap.
693
- - `test/06-nested-objects_test.mjs` -- nested-object & reference-identity behaviours.
694
- - `test/07-dispose_test.mjs` -- universal disposal: registry.dispose(api).
695
- - `test/08-watch_test.mjs` -- new watch reactivity tests.
696
- - `test/09-conformance_test.mjs` -- johnsoncodehk/reactive-framework-test-suite conformance fixes tests.
697
- - `test/10-is-tracking_test.mjs` -- `isTracking()` across observer bodies, untracked windows, and outside any observer.
698
- - `test/11-adopted-reactive_test.mjs` -- engine-agnostic edge cases adopted from the wider ecosystem (alien-signals link-integrity #226-228, equality-predicate corners, `update()`/`peek()`/`subscribe` contracts).
699
- - `test/12-coverage_test.mjs` -- targeted public-surface + hot-path branch coverage (top-level routing, clean-read short-circuit, tail severance, scheduler ABA); owner-tree block capability-gated.
700
- - `test/13-introspection_test.mjs` -- observer-lifecycle surface: `hasObservers`, `observeObservers` auto-pause, `forEach*` enumeration (10 tests).
701
- - `test/14-lifecycle-teardown_test.mjs` -- effect-teardown guards: stopped effect doesn't re-subscribe to a signal read later in the same run, self-dispose leaves no orphan link, throwing setup leaves no live subscription (4 tests).
702
- - `test/15-owner-lazy-alloc_test.mjs` -- owner-adoption contract for the 1.2.0 owner tree (lazy signals never adopted; observers still auto-disposed); capability-gated, skipped on 1.1.x (4 tests).
703
- - `test/16-alien-parity_test.mjs` -- differential guards vs alien-signals@3.2.0 fixed-bug classes: cleanup reads create no deps, inner write doesn't block computed-chain propagation, dynamic dep-set correct under dirty-check (3 tests).
704
- - `test/17-reactivity_test.mjs` -- behavioral suite over universal signal-system bug classes (subscription lifecycle, cleanup ordering, stale-dep tracking, batching, equality, nested invalidation, memory, sync async-boundary, scheduler/loops, + differential-review additions); SSR is N/A (~30 tests).
705
- - `test/18-identity_test.mjs` -- node identity (1.1.5): `nodeId`/`describe`, descriptor `id`, re-walkable descriptors, non-perturbing (5 tests).
706
- - `test/19-v12-additions_test.mjs` -- 1.2.0 surface coverage: shared-peek, owner-adoption rule, pre-batch revert (24 tests).
707
- - `test/20-axis-stress_test.mjs` -- eight orthogonal stress axes (batch-under-exception, connect/disconnect re-entrancy, untrack vs owner cascade, etc.) (23 tests).
708
- - `test/21-perf-pins_test.mjs` -- 1.2.1 construction-shape + ABA-guard pins (6 tests).
709
- - `test/22-mutation-hook_test.mjs` -- 1.2.1 `onGraphMutation` registration + opcode emission (12 tests).
710
- - `test/23-owner-introspection_test.mjs` -- `ownerOf`, `forEachOwned`, gen-guarded introspection (14 tests).
711
- - `test/24-signalbox_test.mjs` -- staged for 1.5.0; all tests `{skip: true}` on 1.2.x.
712
- - `test/25-devtools-real-boot_test.mjs` -- 1.2.2: real `Devtools.js` boot against the engine, ghost-contract pin, `stats()` shape pin (10 tests).
713
- - `test/26-free-list-invariant_test.mjs` -- 1.2.2: the audit's clean-free-list invariant, asserted by inspecting freshly-allocated nodes (4 tests).
689
+ - `test/01-core.test.mjs` -- signal/computed/effect basics, equality, untrack.
690
+ - `test/02-topology.test.mjs` -- diamonds, chains, fan-out/in, cycle detection.
691
+ - `test/03-pool.test.mjs` -- capacity errors, grow policy, pool reuse.
692
+ - `test/04-zero-gc.test.mjs` -- heap retention (run with --expose-gc).
693
+ - `test/05-scheduler.test.mjs` -- scheduler races, dispose, gen counter, version wrap.
694
+ - `test/06-nested-objects.test.mjs` -- nested-object & reference-identity behaviours.
695
+ - `test/07-dispose.test.mjs` -- universal disposal: registry.dispose(api).
696
+ - `test/08-watch.test.mjs` -- new watch reactivity tests.
697
+ - `test/09-conformance.test.mjs` -- johnsoncodehk/reactive-framework-test-suite conformance fixes tests.
698
+ - `test/10-is-tracking.test.mjs` -- `isTracking()` across observer bodies, untracked windows, and outside any observer.
699
+ - `test/11-adopted-reactive.test.mjs` -- engine-agnostic edge cases adopted from the wider ecosystem (alien-signals link-integrity #226-228, equality-predicate corners, `update()`/`peek()`/`subscribe` contracts).
700
+ - `test/12-coverage.test.mjs` -- targeted public-surface + hot-path branch coverage (top-level routing, clean-read short-circuit, tail severance, scheduler ABA); owner-tree block capability-gated.
701
+ - `test/13-introspection.test.mjs` -- observer-lifecycle surface: `hasObservers`, `observeObservers` auto-pause, `forEach*` enumeration (10 tests).
702
+ - `test/14-lifecycle-teardown.test.mjs` -- effect-teardown guards: stopped effect doesn't re-subscribe to a signal read later in the same run, self-dispose leaves no orphan link, throwing setup leaves no live subscription (4 tests).
703
+ - `test/15-owner-lazy-alloc.test.mjs` -- owner-adoption contract for the 1.2.0 owner tree (lazy signals never adopted; observers still auto-disposed); capability-gated, skipped on 1.1.x (4 tests).
704
+ - `test/16-alien-parity.test.mjs` -- differential guards vs alien-signals@3.2.0 fixed-bug classes: cleanup reads create no deps, inner write doesn't block computed-chain propagation, dynamic dep-set correct under dirty-check (3 tests).
705
+ - `test/17-reactivity.test.mjs` -- behavioral suite over universal signal-system bug classes (subscription lifecycle, cleanup ordering, stale-dep tracking, batching, equality, nested invalidation, memory, sync async-boundary, scheduler/loops, + differential-review additions); SSR is N/A (~30 tests).
706
+ - `test/18-identity.test.mjs` -- node identity (1.1.5): `nodeId`/`describe`, descriptor `id`, re-walkable descriptors, non-perturbing (5 tests).
707
+ - `test/19-v12-additions.test.mjs` -- 1.2.0 surface coverage: shared-peek, owner-adoption rule, pre-batch revert (24 tests).
708
+ - `test/20-axis-stress.test.mjs` -- eight orthogonal stress axes (batch-under-exception, connect/disconnect re-entrancy, untrack vs owner cascade, etc.) (23 tests).
709
+ - `test/21-perf-pins.test.mjs` -- 1.2.1 construction-shape + ABA-guard pins (6 tests).
710
+ - `test/22-mutation-hook.test.mjs` -- 1.2.1 `onGraphMutation` registration + opcode emission (12 tests).
711
+ - `test/23-owner-introspection.test.mjs` -- `ownerOf`, `forEachOwned`, gen-guarded introspection (14 tests).
712
+ - `test/24-signalbox.test.mjs` -- staged for 1.5.0; all tests `{skip: true}` on 1.2.x.
713
+ - `test/25-devtools-real-boot.test.mjs` -- 1.2.2: real `Devtools.js` boot against the engine, ghost-contract pin, `stats()` shape pin (10 tests).
714
+ - `test/26-free-list-invariant.test.mjs` -- 1.2.2: the audit's clean-free-list invariant, asserted by inspecting freshly-allocated nodes (4 tests).
714
715
  - `bench/benchmark.mjs` -- anti-DCE throughput harness (ops/s; results.txt).
715
716
  - `bench/benchmarkReactive.mjs` -- cross-framework reactivity suite vs alien-signals, preact, vue-reactivity, solid (resultsReactive.txt).
716
717
  - `bench/dispose-recycle.mjs` -- 1.2.2 targeted microbench: create/dispose/recreate cycle (the free-list invariant audit target).
717
718
  - `bench/torture/` -- crash-detection soaks: `graph-fuzzer`, `scheduler-bench`, `torture-soak`. Exit 0 iff zero errors AND post-teardown pool clean.
718
719
  - `bench/run-all.sh` + `bench/aggregate.mjs` -- cold-process-per-engine protocol + per-scenario aggregation.
720
+ - `harness/run.mjs` -- dispatcher for the run-on-demand probes (field, dispose, churn, owner, creation, all).
721
+ - `harness/fieldkit.mjs` -- single-file portable verify + cold-child A/B bench across six shapes.
722
+ - `harness/owner-hazard-repro.mjs` -- async-gap owner-recycling hazard verdict (cited by getOwner/runWithOwner).
723
+ - `harness/VersionMatrix/` -- cold-process-per-version performance regression gate (wired as prepublishOnly).
724
+ - `harness/ProfilerTools/` -- profiler-signal x devtools composition harness (wired as test:harness).
725
+ - `harness/attic/` -- parked one-off probes (the 1.2.0->1.2.1 shape-regression hunt); wired into nothing.
719
726
  - `demo/index.html` -- interactive visualization of the reactive graph.
720
727
 
721
728
  ## Install
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zakkster/lite-signal",
3
- "version": "1.5.0-beta.3",
3
+ "version": "1.5.0-beta.5",
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",
@@ -29,15 +29,22 @@
29
29
  "test": "node --test --test-reporter=spec 'test/*.test.mjs'",
30
30
  "test:gc": "node --expose-gc --test --test-reporter=spec 'test/*.test.mjs'",
31
31
  "test:coverage": "c8 node --test --test-reporter=spec 'test/*.test.mjs'",
32
+ "test:report": "c8 --reporter=lcov --reporter=text node --test --test-reporter=spec 'test/*.test.mjs'",
32
33
  "test:hardening": "npm --prefix test/ProfilerTests test",
33
34
  "test:hardening:gc": "npm --prefix test/ProfilerTests run test:gc",
34
35
  "test:harness": "npm --prefix harness/ProfilerTools test",
35
36
  "test:all": "npm test && npm run test:hardening && npm run test:harness",
36
37
  "bench": "node --expose-gc bench/benchmark.mjs",
37
38
  "bench-reactive": "node --expose-gc bench/benchmarkReactive.mjs",
39
+ "harness": "node harness/run.mjs",
40
+ "harness:field": "node harness/run.mjs field",
41
+ "harness:dispose": "node harness/run.mjs dispose",
42
+ "harness:churn": "node harness/run.mjs churn",
43
+ "harness:owner": "node harness/run.mjs owner",
44
+ "harness:creation": "node harness/run.mjs creation",
45
+ "harness:all": "node harness/run.mjs all",
38
46
  "verify": "npm test && npm run bench",
39
- "gate": "node harness/VersionMatrix/pre-publish.mjs",
40
- "prepublishOnly": "node harness/VersionMatrix/pre-publish.mjs"
47
+ "gate": "node harness/VersionMatrix/pre-publish.mjs"
41
48
  },
42
49
  "keywords": [
43
50
  "signal",
@@ -74,11 +81,11 @@
74
81
  },
75
82
  "sideEffects": false,
76
83
  "devDependencies": {
77
- "c8": "^11.0.0",
78
- "@zakkster/lite-devtools": "^1.1.0",
79
- "@zakkster/lite-signal": "^1.3.0 || >=1.4.0-beta.0 || >=1.6.0-preview.0",
84
+ "@zakkster/lite-devtools": "^1.2.0",
80
85
  "@zakkster/lite-profiler": "^1.1.0",
81
- "@zakkster/lite-profiler-signal": "^1.2.0"
86
+ "@zakkster/lite-profiler-signal": "^1.2.0",
87
+ "@zakkster/lite-signal": "^1.3.0 || >=1.4.0-beta.0 || >=1.6.0-preview.0",
88
+ "c8": "^11.0.0"
82
89
  },
83
90
  "overrides": {
84
91
  "@zakkster/lite-time": {