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

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,31 @@ 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
+ ### Tooling -- harness reorganization (no engine change)
10
+
11
+ The loose `harness/` probes are now routed through a single dispatcher
12
+ (`harness/run.mjs`) and exposed as npm scripts: `harness:field`,
13
+ `harness:dispose`, `harness:churn`, `harness:owner`, `harness:creation`, and
14
+ `harness:all` (field + dispose + churn in sequence). `harness:field` is the
15
+ portable fieldkit verify + cold-child A/B bench; the rest map one-to-one to the
16
+ existing probe files. Paths resolve from the dispatcher, so the working
17
+ directory no longer matters.
18
+
19
+ The empirical owner-recycling reproducer is documented at its real home,
20
+ `harness/owner-hazard-repro.mjs`; the earlier `Publications/...` citations in
21
+ README / CHANGELOG / llms.txt pointed at a path the file was never in, and are
22
+ corrected. The broken parent/child link in the createComputations matrix
23
+ (`creation-isolated.mjs` now resolves `andrii-isolated-child.mjs`) is repaired.
24
+
25
+ Six settled one-off probes -- the five from the 1.2.0 -> 1.2.1 construction-
26
+ shape regression hunt, plus the superseded `repro-set-after-dispose.mjs` (its
27
+ invariant now pinned by `test/07-dispose` and `test/26-free-list-invariant`) --
28
+ are parked in `harness/attic/` with a README explaining each. `Signal.js` is
29
+ untouched and the published `files[]` whitelist is unchanged, so installed
30
+ tarballs are byte-identical; this is a repo-tooling change only.
31
+
7
32
  ## [1.5.0-beta.2] -- 2026-07-XX
8
33
 
9
34
  The re-attach companion to `createRoot`: **`getOwner`** and **`runWithOwner`**
@@ -46,7 +71,7 @@ engine because nodes are pooled and the LIFO free list recycles a
46
71
  disposed owner's slot into whatever effect/computed is allocated next.
47
72
  Two failure modes were empirically reproduced against a 1.5.0-beta
48
73
  engine patched with the raw-pointer alternative
49
- (`Publications/owner-hazard-repro.mjs`):
74
+ (`harness/owner-hazard-repro.mjs`):
50
75
 
51
76
  - **Recycled-slot cascade death.** Owner A captured; A disposed; effect B
52
77
  allocated (LIFO -> same slot); `runWithOwner(captured)` silently
@@ -93,13 +118,13 @@ Full test suite on 1.5.0-beta.2: **455 total** (439 pre-existing +
93
118
  `25-devtools-real-boot` cases that need `@zakkster/lite-devtools`
94
119
  installed as a peer -- pre-existing, unrelated).
95
120
 
96
- ### Added -- `Publications/owner-hazard-repro.mjs`
121
+ ### Added -- `harness/owner-hazard-repro.mjs`
97
122
 
98
123
  A standalone reproducer for the two hazards, callable against any engine
99
124
  (`node owner-hazard-repro.mjs <path-to-Signal.js>`). Prints
100
125
  `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
126
+ a stack overflow on the raw-pointer sketch. Kept in `harness/`
127
+ alongside the other run-on-demand probes rather than under `test/` so it can
103
128
  travel to other engines (a candidate 1.6, or a rejected candidate you
104
129
  want to confirm) without dragging the whole test tree along.
105
130
 
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
 
@@ -790,7 +791,7 @@ Three tiers, all reproducible.
790
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.
791
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.
792
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.
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
+ - **`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.
794
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.
795
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
 
@@ -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/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
@@ -716,6 +716,12 @@ function dumpOwnerTree(handle, depth = 0) {
716
716
  - `bench/dispose-recycle.mjs` -- 1.2.2 targeted microbench: create/dispose/recreate cycle (the free-list invariant audit target).
717
717
  - `bench/torture/` -- crash-detection soaks: `graph-fuzzer`, `scheduler-bench`, `torture-soak`. Exit 0 iff zero errors AND post-teardown pool clean.
718
718
  - `bench/run-all.sh` + `bench/aggregate.mjs` -- cold-process-per-engine protocol + per-scenario aggregation.
719
+ - `harness/run.mjs` -- dispatcher for the run-on-demand probes (field, dispose, churn, owner, creation, all).
720
+ - `harness/fieldkit.mjs` -- single-file portable verify + cold-child A/B bench across six shapes.
721
+ - `harness/owner-hazard-repro.mjs` -- async-gap owner-recycling hazard verdict (cited by getOwner/runWithOwner).
722
+ - `harness/VersionMatrix/` -- cold-process-per-version performance regression gate (wired as prepublishOnly).
723
+ - `harness/ProfilerTools/` -- profiler-signal x devtools composition harness (wired as test:harness).
724
+ - `harness/attic/` -- parked one-off probes (the 1.2.0->1.2.1 shape-regression hunt); wired into nothing.
719
725
  - `demo/index.html` -- interactive visualization of the reactive graph.
720
726
 
721
727
  ## 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.4",
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",
@@ -35,6 +35,13 @@
35
35
  "test:all": "npm test && npm run test:hardening && npm run test:harness",
36
36
  "bench": "node --expose-gc bench/benchmark.mjs",
37
37
  "bench-reactive": "node --expose-gc bench/benchmarkReactive.mjs",
38
+ "harness": "node harness/run.mjs",
39
+ "harness:field": "node harness/run.mjs field",
40
+ "harness:dispose": "node harness/run.mjs dispose",
41
+ "harness:churn": "node harness/run.mjs churn",
42
+ "harness:owner": "node harness/run.mjs owner",
43
+ "harness:creation": "node harness/run.mjs creation",
44
+ "harness:all": "node harness/run.mjs all",
38
45
  "verify": "npm test && npm run bench",
39
46
  "gate": "node harness/VersionMatrix/pre-publish.mjs",
40
47
  "prepublishOnly": "node harness/VersionMatrix/pre-publish.mjs"