@zakkster/lite-signal 1.6.0-alpha → 1.6.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -23
- package/README.md +28 -6
- package/llms.txt +26 -12
- package/package.json +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -100,7 +100,7 @@ its pool slot recycled by an unrelated effect via the LIFO free list, the gen
|
|
|
100
100
|
no longer matches and `runWithOwner` degrades to **rooted execution** rather
|
|
101
101
|
than corrupting the graph. Two hazards on the raw-pointer alternative were
|
|
102
102
|
empirically reproduced against a 1.5.0-beta engine patched with the naive
|
|
103
|
-
implementation (`
|
|
103
|
+
implementation (`harness/owner-hazard-repro.mjs`) and are pinned in
|
|
104
104
|
`test/28-run-with-owner.test.mjs`:
|
|
105
105
|
|
|
106
106
|
- **Recycled-slot cascade death** -- capture, dispose owner, allocate a stranger
|
|
@@ -121,24 +121,31 @@ Exported as registry methods and top-level helpers, mirroring `createRoot` /
|
|
|
121
121
|
|
|
122
122
|
### Added -- characterization harnesses (`burst-dag.mjs`, `pull-stress.mjs`)
|
|
123
123
|
|
|
124
|
-
Two
|
|
125
|
-
surface against the engine's
|
|
126
|
-
(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
(
|
|
137
|
-
|
|
138
|
-
|
|
124
|
+
Two standalone harnesses in `harness/` that exercise the new 1.6.0 instrumentation
|
|
125
|
+
surface against the engine's hot paths, both consuming public `onGraphMutation`
|
|
126
|
+
(opcodes 5/6/7) and both staying out of `npm test` and the published tarball.
|
|
127
|
+
`pull-stress.mjs` imports `../Signal.js` and exposes a CLI + module exports;
|
|
128
|
+
`burst-dag.mjs` takes the engine path as an argument and is CLI-only.
|
|
129
|
+
|
|
130
|
+
**`burst-dag.mjs`** (`npm run profile:burst`, also `node --expose-gc
|
|
131
|
+
harness/burst-dag.mjs <Signal.js>`) reproduces Andrii's actual generator: the
|
|
132
|
+
layer edges use his **verbatim strided picker** (`base = (node*13 + layer*17) %
|
|
133
|
+
prevW`, strided step), `staticFraction = 1` (all-static computeds, per-batch pull
|
|
134
|
+
reads, no effects) -- the real `layered burst flush warm` shape. It runs that
|
|
135
|
+
head-to-head against the earlier contiguous-window guess it embeds and reports
|
|
136
|
+
structure (passes/burst, recomputed, maxRecompute/node, poolGrowths) plus median
|
|
137
|
+
us/burst for each. On 1.6.0-alpha the strided real topology recomputes ~2x the
|
|
138
|
+
nodes (15928 vs 8120) at ~26% higher us/burst, both with `passes = 0` (pure pull,
|
|
139
|
+
nothing to flush) and `maxRecompute/node = 1`: no redundant work either way, so
|
|
140
|
+
the ~2x gap is **locality** on the correct topology. This resolves the ROADMAP S5
|
|
141
|
+
open question (was the contiguous guess faithful to Andrii's generator?). The
|
|
142
|
+
earlier contiguous version -- with its `--width` / `--layers` CLI and its
|
|
143
|
+
`burstDagScenario` / `multiPassProbe` exports for the zero-GC gate -- is archived
|
|
144
|
+
as `harness/attic/burst-dag.mjs`; nothing mounted those exports, so retiring it
|
|
145
|
+
is inert.
|
|
139
146
|
|
|
140
147
|
**`pull-stress.mjs`** (`npm run profile:pull`, also `node --expose-gc
|
|
141
|
-
pull-stress.mjs [--maxDepth=3584 --step=512 ...]`) is the pull-path companion:
|
|
148
|
+
harness/pull-stress.mjs [--maxDepth=3584 --step=512 ...]`) is the pull-path companion:
|
|
142
149
|
characterizes how the recursive pull scales with chain depth and binary-searches
|
|
143
150
|
the exact overflow point. Three answers per run: (1) the exact deepest chain
|
|
144
151
|
that pulls successfully (the roadmap's "~5,000 chained computeds" pinned to a
|
|
@@ -154,11 +161,12 @@ supported and surface a real engine difference (box pulls overflow earlier
|
|
|
154
161
|
because `box.get()` adds a prototype-method frame per level, and cached box
|
|
155
162
|
reads are several times more expensive than cached callable reads).
|
|
156
163
|
|
|
157
|
-
|
|
158
|
-
engine build: point
|
|
159
|
-
(`burst-dag` adapts -- only opcode 5 fires on
|
|
160
|
-
|
|
161
|
-
they produce are reproducible,
|
|
164
|
+
`pull-stress` imports only `../Signal.js`, and `burst-dag` takes the engine path
|
|
165
|
+
as an argument, so both run against any engine build: point them at 1.5.x to
|
|
166
|
+
compare without the new counters (`burst-dag` adapts -- only opcode 5 fires on
|
|
167
|
+
that engine, so `passes` reads 0 -- and `pull-stress` works identically), or at a
|
|
168
|
+
rejected candidate to re-verify on. The numbers they produce are reproducible,
|
|
169
|
+
comparable, and engine-version-aware.
|
|
162
170
|
|
|
163
171
|
### Verified
|
|
164
172
|
|
|
@@ -237,7 +245,45 @@ run_1.txt` ... `run_10.txt` so anyone can re-median independently.
|
|
|
237
245
|
solid-js 1.9.13). No peer bumps this cycle -- the deltas here are the 1.6
|
|
238
246
|
engine's own footprint plus host noise.
|
|
239
247
|
|
|
240
|
-
|
|
248
|
+
### Tooling -- harness reorganization (no published-surface change)
|
|
249
|
+
|
|
250
|
+
The loose `harness/` probes are routed through a single dispatcher
|
|
251
|
+
(`harness/run.mjs`) and exposed as npm scripts: `harness:field`,
|
|
252
|
+
`harness:dispose`, `harness:churn`, `harness:owner`, `harness:creation`, and
|
|
253
|
+
`harness:all` (field + dispose + churn in sequence). `harness:field` is the
|
|
254
|
+
portable fieldkit verify + cold-child A/B bench; the rest map one-to-one to the
|
|
255
|
+
existing probe files. Paths resolve from the dispatcher, so the working
|
|
256
|
+
directory no longer matters.
|
|
257
|
+
|
|
258
|
+
- **`churnprobe.mjs` corrected.** It read link churn from `stats().totalLink*`
|
|
259
|
+
fields that never existed on this engine (`stats()` tracks only NODE lifecycle
|
|
260
|
+
plus a live `activeLinks` gauge), so every row printed `NaN`. It now counts
|
|
261
|
+
gross link churn off `onGraphMutation` -- opcode `3` (link-add) and `4`
|
|
262
|
+
(link-sever) -- which is strictly better: a net `activeLinks` delta would read
|
|
263
|
+
zero on `dep-flip` because each sever is matched by an add, hiding exactly the
|
|
264
|
+
retracking the probe exists to catch. Stable shapes now read `churn/recompute
|
|
265
|
+
= 0`; `dep-flip` reads `2.0`. Opcodes `3`/`4`/`5` are unchanged from 1.5; the
|
|
266
|
+
probe does not use the new `6`/`7` flush opcodes.
|
|
267
|
+
- **`burst-dag.mjs` reconciled.** The contiguous-window guess was first promoted
|
|
268
|
+
from `futureVersions/` into `harness/` (wiring up the `profile:burst` script
|
|
269
|
+
that already pointed there), then superseded by the verbatim-Andrii strided
|
|
270
|
+
reconciliation now carrying that name (see Added above); the contiguous guess
|
|
271
|
+
and its `burstDagScenario` / `multiPassProbe` exports are preserved in
|
|
272
|
+
`harness/attic/`. `pull-stress.mjs` -- the pull-path companion documented
|
|
273
|
+
alongside it -- landed in `harness/`.
|
|
274
|
+
- **The owner-recycling reproducer** is documented at its real home,
|
|
275
|
+
`harness/owner-hazard-repro.mjs`; the earlier `Publications/...` citations
|
|
276
|
+
in README / CHANGELOG / llms.txt pointed at a path the file was never in, and
|
|
277
|
+
are corrected. The createComputations matrix parent/child link
|
|
278
|
+
(`creation-isolated.mjs` -> `andrii-isolated-child.mjs`) is repaired.
|
|
279
|
+
- **Six settled one-off probes** -- the five from the 1.2.0 -> 1.2.1
|
|
280
|
+
construction-shape regression hunt, plus the superseded
|
|
281
|
+
`repro-set-after-dispose.mjs` (its invariant now pinned by `test/07-dispose`
|
|
282
|
+
and `test/26-free-list-invariant`) -- are parked in `harness/attic/` with a
|
|
283
|
+
README explaining each.
|
|
284
|
+
|
|
285
|
+
`Signal.js` and the published `files[]` whitelist are untouched by any of the
|
|
286
|
+
above; this is a repo-tooling change only.
|
|
241
287
|
|
|
242
288
|
## [1.5.0] -- 2026-06-XX
|
|
243
289
|
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
[](https://bundlephobia.com/result?p=@zakkster/lite-signal)
|
|
10
10
|
[](https://www.npmjs.com/package/@zakkster/lite-signal)
|
|
11
11
|
[](https://www.npmjs.com/package/@zakkster/lite-signal)
|
|
12
|
+

|
|
12
13
|

|
|
13
14
|

|
|
14
15
|
[](./LICENSE)
|
|
@@ -381,7 +382,7 @@ effect(() => {
|
|
|
381
382
|
|
|
382
383
|
`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.
|
|
383
384
|
|
|
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 `
|
|
385
|
+
**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`.
|
|
385
386
|
|
|
386
387
|
The handles do **not** keep owners alive -- they are snapshots, not references. Node lifetime is controlled by the owner tree, not by outstanding handles.
|
|
387
388
|
|
|
@@ -878,6 +879,23 @@ Beyond the engine's own test tiers above, `@zakkster/lite-signal` ships **dedica
|
|
|
878
879
|
|
|
879
880
|
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.
|
|
880
881
|
|
|
882
|
+
### `harness/` -- run-on-demand probes
|
|
883
|
+
|
|
884
|
+
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:
|
|
885
|
+
|
|
886
|
+
```bash
|
|
887
|
+
npm run harness:field # verify + cold-child A/B bench (fieldkit)
|
|
888
|
+
npm run harness:field -- ./Signal.js ./archived/1.5.0.js # A/B two engines
|
|
889
|
+
npm run harness:dispose # creation cost: signal() vs signalBox() vs alien
|
|
890
|
+
npm run harness:churn # topology-churn-per-recompute (1.11 cone-cache gate)
|
|
891
|
+
npm run harness:owner # async-gap owner-recycling hazard verdict
|
|
892
|
+
npm run harness:creation # per-framework createComputations matrix
|
|
893
|
+
npm run harness:all # field + dispose + churn, in sequence
|
|
894
|
+
npm run profile:burst # 1.6 burst-shape characterization (Andrii strided vs contiguous guess)
|
|
895
|
+
```
|
|
896
|
+
|
|
897
|
+
`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. `churnprobe.mjs` reads link churn off `onGraphMutation` (opcodes `3` link-add / `4` link-sever), not `stats()`, so it reports gross retracking a net `activeLinks` gauge would hide -- stable shapes read `0`, `dep-flip` reads `2.0`. `burst-dag.mjs` runs Andrii's verbatim strided burst shape head-to-head against the earlier contiguous-window guess (now archived in `harness/attic/`) to answer whether the burst gap is redundant work or locality. 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.
|
|
898
|
+
|
|
881
899
|
### `test/ProfilerTests/` -- version-portable hardening suite
|
|
882
900
|
|
|
883
901
|
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.
|
|
@@ -957,9 +975,9 @@ Both flags are required (`--expose-gc` for the explicit `gc()` calls in the mete
|
|
|
957
975
|
|
|
958
976
|
### `harness/burst-dag.mjs` and `harness/pull-stress.mjs` -- 1.6 profiling harnesses
|
|
959
977
|
|
|
960
|
-
Two standalone profiling harnesses that consume the new op 6/7 mutation-hook counters to characterise **shape**-specific engine behaviour that the throughput benches can only aggregate over.
|
|
978
|
+
Two standalone profiling harnesses that consume the new op 6/7 mutation-hook counters to characterise **shape**-specific engine behaviour that the throughput benches can only aggregate over. `pull-stress.mjs` imports `../Signal.js` and is dual-mode (standalone runner or mountable zero-GC scenario); `burst-dag.mjs` takes the engine path as an argument (`node --expose-gc harness/burst-dag.mjs <Signal.js>`) so the same contrast runs against any build. Wired as `npm run profile:burst` and `npm run profile:pull`.
|
|
961
979
|
|
|
962
|
-
**`burst-dag.mjs`** -- the burst-
|
|
980
|
+
**`burst-dag.mjs`** -- the burst-shape characterisation harness, built on Andrii's **verbatim strided generator** (`base = (node*13 + layer*17) % prevW`, strided step; `staticFraction = 1`, all-static computeds read per-batch by pull -- his real *layered burst flush warm* shape). It answers the question the roadmap hinges on: is the ~2x gap on that shape **redundant work** (multi-pass flush re-marking already-clean cones, fixable by coalescing) or **locality at scale** (touching ~16k nodes' worth of marks + pulls per burst, not fixable without a layout change -- and layout changes have been shown to deopt the propagation hot path)? To settle it, the harness runs Andrii's strided topology head-to-head against the earlier *contiguous-window* guess it embeds, reporting structure (passes/burst, recomputed, max recomputes per node) and median us/burst for each. On 1.6.0-alpha the strided real shape recomputes ~2x the nodes of the contiguous guess (15928 vs 8120) at ~26% higher us/burst, both with `passes/burst = 0` (pure pull -- nothing to flush) and `maxRecompute/node = 1` -- no redundant work in either, so the gap is **locality** (the strided edges spread the cone wider across each layer). The standalone contiguous guess that preceded this reconciliation (ROADMAP S5, now closed) is preserved as `harness/attic/burst-dag.mjs`, complete with its `burstDagScenario` / `multiPassProbe` exports.
|
|
963
981
|
|
|
964
982
|
**`pull-stress.mjs`** -- the pull-mode recursion characterisation harness. Answers three questions on the current engine:
|
|
965
983
|
|
|
@@ -970,11 +988,11 @@ Two standalone profiling harnesses that consume the new op 6/7 mutation-hook cou
|
|
|
970
988
|
Also verifies the structure of the cold-pull correctness: opcode 6 (flush pass) MUST be 0, opcode 7 (effect enqueued) MUST be 0, opcode 5 (recompute) MUST equal depth. A correct engine produces this exact triple; deviation is a real finding, reported as a STRUCTURE FAILED verdict that suppresses the timing summary.
|
|
971
989
|
|
|
972
990
|
```bash
|
|
973
|
-
npm run profile:burst #
|
|
991
|
+
npm run profile:burst # Andrii's strided burst shape vs the contiguous guess, head-to-head
|
|
974
992
|
npm run profile:pull # per-level cost + exact overflow depth + O(1) cached-read sanity
|
|
975
993
|
```
|
|
976
994
|
|
|
977
|
-
|
|
995
|
+
These harnesses land in 1.6 alongside the mutation-hook opcodes they consume; they are not test files (no assertion budget beyond the structure invariants), they are characterisation tools intended to make the "is this shape's cost redundant work or locality?" question answerable reproducibly on any engine build.
|
|
978
996
|
|
|
979
997
|
### Notes
|
|
980
998
|
|
|
@@ -1042,7 +1060,7 @@ The cross-framework reactivity suite agrees independently, re-run on **1.6.0-alp
|
|
|
1042
1060
|
- **1.3.0** -- the **pool minor**: node and link pools become growable and incrementally populated. New `prealloc` config (`"eager"` default | `"lazy"`) chooses up-front vs on-demand construction; `onCapacityExceeded: "grow"` extends pools via chunked refill (runs of up to 1024 links / 256 nodes, ledger doubles) bounded by the 16x link ceiling; `maxFlushPasses` is now a public config. Internally the propagation mark phase moved to an intrusive linked-list stack (a `nextMark` field) -- the only node-shape change. The hot paths and public callable API are byte-identical to 1.2.2; steady-state zero-GC is unchanged. *Shipped.*
|
|
1043
1061
|
- **1.4.0** -- the **observability minor**: `stats()` gains three cumulative lifecycle counters (`totalAllocations`, `totalDisposals`, `poolGrowths`), the surface reserved for it in the 1.2.x/1.3.0 notes. Monotonic over the registry's life, reset by `destroy()`, bumped on the existing acquire/dispose/grow edges -- no hot-path change, no public callable API change. This is what lite-devtools / lite-studio read to chart allocation rate, pool-reuse ratio, and graph churn. Also adds the `harness/VersionMatrix/` regression gate (cold-process, same-host, two baselines) as a `prepublish` step, so a release that regresses `frame.avg` on the four reference workloads (reactive-graph-mix, deep-chain, broadcast-fanout, dynamic-dep-churn) fails the publish. Drop-in over 1.3.0. *Shipped.*
|
|
1044
1062
|
- **1.5.0** -- the **API-surface minor**: two non-callable, allocation-light primitives `signalBox` / `computedBox` land alongside the callable `signal` / `computed` (same `ReactiveNode`, full interop, ~1.7x cheaper construction), and **`createRoot`** lands as the ownership escape hatch the owner tree was designed for (detached scope for lazily spawning long-lived nodes from inside a consumer effect -- the pattern `lite-query` needs). The callable API, hot paths, and `stats()` shape are unchanged; the `24-signalbox` suite (staged since 1.3.0) now runs and passes. VersionMatrix gains an **identical-code guard** (SHA-256 of the engine source per baseline): a re-versioned publish with byte-identical `Signal.js` is marked `SKIP` structurally rather than flagged by noisy median variance. *Shipped (beta).* **1.5.0-beta.2** adds the re-attach companions **`getOwner` / `runWithOwner`** (gen-stamped handles that degrade to rooted execution when the captured owner has been recycled; both async-gap hazards -- recycled-slot cascade death and corpse-adoption crash -- pinned in `test/28-run-with-owner.test.mjs`). **1.5.1** promotes the zero-GC gate from `futureVersions/zgc/` to `test/zgc/` (six scenarios + controls + injected-allocation self-test), wired into `test:zgc` / `test:all` / `verify` -- CI-wireable proof that the steady-state hot path allocates nothing.
|
|
1045
|
-
- **1.6.0-alpha** -- the **observability + lifecycle minor**. Two additions to the mutation-hook stream: op 6 (`flush-pass-start`, once per pass in `flushEffects`) and op 7 (`effect-enqueue`, in `markDownstream` when a dirty subscriber is enqueued) -- both branch-predicted-free when detached, allocation-free when attached, letting lite-devtools/profiler chart flush structure and per-burst enqueue counts without instrumentation. Plus the `flushPasses` counter on `stats()` (the 12th key) advancing only while a hook is attached. Adds **`createScope`** as the third ownership primitive alongside `createRoot` / `runWithOwner`: an adopting scope that returns one disposer for the whole subtree, exactly the per-item lifecycle a keyed-list or scene reconciler needs. Ships the
|
|
1063
|
+
- **1.6.0-alpha** -- the **observability + lifecycle minor**. Two additions to the mutation-hook stream: op 6 (`flush-pass-start`, once per pass in `flushEffects`) and op 7 (`effect-enqueue`, in `markDownstream` when a dirty subscriber is enqueued) -- both branch-predicted-free when detached, allocation-free when attached, letting lite-devtools/profiler chart flush structure and per-burst enqueue counts without instrumentation. Plus the `flushPasses` counter on `stats()` (the 12th key) advancing only while a hook is attached. Adds **`createScope`** as the third ownership primitive alongside `createRoot` / `runWithOwner`: an adopting scope that returns one disposer for the whole subtree, exactly the per-item lifecycle a keyed-list or scene reconciler needs. Ships the profiling harnesses `harness/burst-dag.mjs` (Andrii's verbatim strided burst shape, resolving ROADMAP S5 -- the earlier contiguous guess is archived in `harness/attic/`) and `harness/pull-stress.mjs` (see the Test harnesses section). The engine hot path is no longer byte-identical to 1.5 -- `markDownstream` and `flushEffects` picked up the new gate branches -- and the observable cost is a few percent on the cheap propagation shapes (KAIROS -7 -> -12%, DEEP CHAIN -14 -> -21% vs alien); the wide-aggregation wins are unchanged because the gate is round-off there. *Shipped (alpha).*
|
|
1046
1064
|
- **Next** -- the pull-mode recursion depth limit (~5,000 chained computeds; `pull-stress.mjs` now pins the exact number on the current engine and will be the before/after baseline for the eventual iterative pull rewrite) remains the main outstanding architectural item.
|
|
1047
1065
|
|
|
1048
1066
|
> Note: the retracking rewrite that closes the dynamic-topology gap shipped in **1.1.4**, not a future release. The earlier roadmap that listed it under "v1.2" is superseded.
|
|
@@ -1295,6 +1313,10 @@ npm test # behavior suite, ~1.3s
|
|
|
1295
1313
|
npm run test:gc # zero-gc suite, requires --expose-gc, ~3s
|
|
1296
1314
|
npm run bench # comparative benchmark vs alien-signals (results.txt), ~5min
|
|
1297
1315
|
npm run bench-reactive # 5-framework reactivity suite (resultsReactive.txt)
|
|
1316
|
+
npm run harness:field # verify + cold-child A/B bench (fieldkit)
|
|
1317
|
+
npm run harness:all # field + dispose + churn probes, in sequence
|
|
1318
|
+
npm run profile:burst # 1.6 burst/flush characterization harness
|
|
1319
|
+
npm run gate # cold-process version-matrix regression gate (also runs on prepublish)
|
|
1298
1320
|
npm run verify # test + test:gc + sanity bench; gate for publish
|
|
1299
1321
|
```
|
|
1300
1322
|
|
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, carried into 1.6)**: 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 `
|
|
21
|
+
- **getOwner / runWithOwner (1.5.0-beta.2, carried into 1.6)**: 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
|
- **createScope (1.6.0)**: `createScope(fn)` runs `fn(dispose)` in a detached, untracked scope and returns whatever `fn` returns, having handed `fn` a single `dispose` that cascade-disposes every effect and computed created inside `fn`. The lifecycle complement to `createRoot`: where `createRoot` only *detaches* (caller disposes each child by hand), `createScope` *adopts*, so one disposer tears down a subtree of unknown shape -- the per-item lifecycle a keyed-list or scene reconciler needs. Plain signals created directly in `fn` are NOT adopted (consistent with the 1.2.0 ownership rule); computeds and effects are. The scope owner is backed by a never-re-running effect node (counts as one effect in `stats()`), the pinned `signals + computeds + effects === activeNodes` invariant is untouched, and the disposer is the same gen-guarded ABA-safe handle `effect()` returns (`describe` / `nodeId` / `forEachOwned` resolve it to the owner). A scope created inside a consumer effect SURVIVES that consumer's re-run -- the reconciler-critical detach property.
|
|
23
23
|
- **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).
|
|
24
24
|
- **Batch**: `batch(fn)` defers effect flush until the outermost batch closes. Nestable.
|
|
@@ -101,7 +101,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
101
101
|
degrading to rooted execution on stale/null/non-tracker handles. The two
|
|
102
102
|
hazards (recycled-slot cascade death, corpse-adoption crash) are pinned in
|
|
103
103
|
`test/28-run-with-owner.test.mjs` with allocation pressure applied so the
|
|
104
|
-
ABA guard is genuinely exercised. `
|
|
104
|
+
ABA guard is genuinely exercised. `harness/owner-hazard-repro.mjs`
|
|
105
105
|
reports `VERDICT: SAFE` on the 1.6.0-alpha engine on both cases. The port
|
|
106
106
|
was verified via sha256 over the extracted function bodies of `pullComputed`,
|
|
107
107
|
`executeEffect`, `allocateLink`, `severTail`, `createNode`, `runCleanup`,
|
|
@@ -111,16 +111,21 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
111
111
|
hash-tracked from this cycle instead.
|
|
112
112
|
|
|
113
113
|
Drop-in over 1.5.1-beta.1 modulo the small gate cost on the cheapest shapes.
|
|
114
|
-
Two
|
|
115
|
-
tarball): **`burst-dag.mjs`** (`npm run profile:burst`)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
Two characterization harnesses in `harness/` ship in source (not in the
|
|
115
|
+
tarball): **`burst-dag.mjs`** (`npm run profile:burst`) reproduces Andrii's
|
|
116
|
+
verbatim strided generator (`base=(node*13+layer*17)%prevW`, staticFraction=1,
|
|
117
|
+
pull reads -- his real `layered burst flush warm` shape) and runs it
|
|
118
|
+
head-to-head against the earlier contiguous-window guess it embeds, using
|
|
119
|
+
opcodes 5/6 + `stats().flushPasses`; the strided real topology recomputes ~2x
|
|
120
|
+
the nodes at ~26% higher us/burst, both single-pass -- locality, not
|
|
121
|
+
redundancy (ROADMAP S5 closed). The contiguous guess it replaced, with its
|
|
122
|
+
`burstDagScenario` + `multiPassProbe` exports, is archived in `harness/attic/`.
|
|
123
|
+
**`pull-stress.mjs`** (`npm run profile:pull`) is the pull-path companion:
|
|
124
|
+
binary-searches the recursive-pull depth limit (~5,000 named in the roadmap,
|
|
125
|
+
pinned to a number per engine), sweeps cold cost per level, confirms cached
|
|
126
|
+
reads are O(1) via markEpoch; exports `pullStressScenario` + `probeOverflow`.
|
|
127
|
+
`pull-stress` imports `../Signal.js`; `burst-dag` takes the engine path as an
|
|
128
|
+
argument; both run against any engine build via public `onGraphMutation`.
|
|
124
129
|
**Tests:** 447 total (443 from 1.6-preview + the 4 createScope tests
|
|
125
130
|
+ 16 getOwner/runWithOwner tests already counted; the 447 aggregates the
|
|
126
131
|
full green suite on the merged engine), 436 pass, 0 fail, 1 skip (only the
|
|
@@ -767,6 +772,15 @@ function dumpOwnerTree(handle, depth = 0) {
|
|
|
767
772
|
- `bench/dispose-recycle.mjs` -- 1.2.2 targeted microbench: create/dispose/recreate cycle (the free-list invariant audit target).
|
|
768
773
|
- `bench/torture/` -- crash-detection soaks: `graph-fuzzer`, `scheduler-bench`, `torture-soak`. Exit 0 iff zero errors AND post-teardown pool clean.
|
|
769
774
|
- `bench/run-all.sh` + `bench/aggregate.mjs` -- cold-process-per-engine protocol + per-scenario aggregation.
|
|
775
|
+
- `harness/run.mjs` -- dispatcher for the run-on-demand probes (field, dispose, churn, owner, creation, all).
|
|
776
|
+
- `harness/fieldkit.mjs` -- single-file portable verify + cold-child A/B bench across six shapes.
|
|
777
|
+
- `harness/churnprobe.mjs` -- topology-churn-per-recompute via onGraphMutation opcodes 3/4 (link add/sever); the 1.11 cone-cache gate.
|
|
778
|
+
- `harness/burst-dag.mjs` -- 1.6 burst-shape characterization: Andrii's verbatim strided topology vs the contiguous guess it embeds (ROADMAP S5 closed); CLI, takes engine-path arg.
|
|
779
|
+
- `harness/pull-stress.mjs` -- 1.6 pull-mode depth characterization: per-level cost, exact overflow depth, O(1) cached-read; CLI + pullStressScenario/probeOverflow exports.
|
|
780
|
+
- `harness/owner-hazard-repro.mjs` -- async-gap owner-recycling hazard verdict (cited by getOwner/runWithOwner).
|
|
781
|
+
- `harness/VersionMatrix/` -- cold-process-per-version performance regression gate (wired as prepublishOnly).
|
|
782
|
+
- `harness/ProfilerTools/` -- profiler-signal x devtools composition harness (wired as test:harness).
|
|
783
|
+
- `harness/attic/` -- parked probes: the 1.2.0->1.2.1 shape-regression hunt + the superseded contiguous burst-dag guess (with its burstDagScenario/multiPassProbe exports); wired into nothing.
|
|
770
784
|
- `demo/index.html` -- interactive visualization of the reactive graph.
|
|
771
785
|
|
|
772
786
|
## Install
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zakkster/lite-signal",
|
|
3
|
-
"version": "1.6.0-alpha",
|
|
3
|
+
"version": "1.6.0-alpha.0",
|
|
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",
|
|
@@ -37,7 +37,14 @@
|
|
|
37
37
|
"test:all": "npm test && npm run test:hardening && npm run test:harness && npm run test:zgc",
|
|
38
38
|
"bench": "node --expose-gc bench/benchmark.mjs",
|
|
39
39
|
"bench-reactive": "node --expose-gc bench/benchmarkReactive.mjs",
|
|
40
|
-
"
|
|
40
|
+
"harness": "node harness/run.mjs",
|
|
41
|
+
"harness:field": "node harness/run.mjs field",
|
|
42
|
+
"harness:dispose": "node harness/run.mjs dispose",
|
|
43
|
+
"harness:churn": "node harness/run.mjs churn",
|
|
44
|
+
"harness:owner": "node harness/run.mjs owner",
|
|
45
|
+
"harness:creation": "node harness/run.mjs creation",
|
|
46
|
+
"harness:all": "node harness/run.mjs all",
|
|
47
|
+
"profile:burst": "node --expose-gc harness/burst-dag.mjs ./Signal.js",
|
|
41
48
|
"profile:pull": "node --expose-gc harness/pull-stress.mjs",
|
|
42
49
|
"verify": "npm test && npm run test:zgc && npm run bench",
|
|
43
50
|
"gate": "node harness/VersionMatrix/pre-publish.mjs",
|