@zakkster/lite-signal 1.5.0-beta.3 → 1.6.0-alpha
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 +236 -120
- package/README.md +91 -32
- package/Signal.d.ts +31 -2
- package/Signal.js +142 -28
- package/llms.txt +137 -86
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,126 +4,242 @@ All notable changes to `@zakkster/lite-signal` are documented here.
|
|
|
4
4
|
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
5
|
This project follows [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
-
## [1.
|
|
8
|
-
|
|
9
|
-
The
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
engine
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
`
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
`
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
7
|
+
## [1.6.0-alpha.0] -- 2026-07-XX
|
|
8
|
+
|
|
9
|
+
The observability-and-lifecycle minor, shipping on the `alpha` dist-tag while it
|
|
10
|
+
settles. Three additions: `stats()` gains a twelfth key, **`flushPasses`**, plus two
|
|
11
|
+
flush-profiling mutation-hook opcodes -- the flush/recompute dimension
|
|
12
|
+
lite-devtools 1.2 / lite-studio 1.2 read through `watchAllocations`;
|
|
13
|
+
**`createScope(fn)`**, the disposable-owner counterpart to
|
|
14
|
+
`createRoot` that a keyed-list / scene reconciler needs for per-item teardown;
|
|
15
|
+
and **`getOwner` / `runWithOwner`** carried forward from 1.5.0-beta.2 as the
|
|
16
|
+
capture-and-restore companion to `createRoot`. The engine hot path is **no
|
|
17
|
+
longer byte-identical to 1.5** for the first time since 1.2.2 -- `markDownstream`
|
|
18
|
+
and `flushEffects` picked up hook-gated fires for the two new opcodes -- but
|
|
19
|
+
the gate is a single branch-predicted `null` check per fire site and the
|
|
20
|
+
observable cost only shows on the cheapest propagation shapes (KAIROS, DEEP
|
|
21
|
+
CHAIN); the wide-aggregation and dynamic-DAG wins are unchanged. Drop-in over
|
|
22
|
+
1.5.1-beta.1.
|
|
23
|
+
|
|
24
|
+
### Added -- `flushPasses` on `stats()` + flush-profiling opcodes
|
|
25
|
+
|
|
26
|
+
`stats()` now returns **12 keys**: the 11 from 1.4.x plus `flushPasses`, a counter
|
|
27
|
+
that advances once per effect-flush drain pass. Two `onGraphMutation` opcodes back
|
|
28
|
+
the flush dimension:
|
|
29
|
+
|
|
30
|
+
- **`6` flush pass** -- `(passCount, effectsToRun)`, at the top of each drain pass.
|
|
31
|
+
- **`7` effect run in pass** -- `(id, 0)`, before each effect re-run inside a pass.
|
|
32
|
+
|
|
33
|
+
Both the counter bump and the opcode dispatch sit behind the existing
|
|
34
|
+
`if (mutationHook !== null)` gate, so when no profiler is attached they are inert:
|
|
35
|
+
`flushPasses` is frozen and the flush loop is byte-identical to 1.5.0 EXCEPT for
|
|
36
|
+
the added `null` check itself. The residual cost is one branch-predicted `null`
|
|
37
|
+
check per fire site (per pass in `flushEffects`, per enqueued dirty subscriber
|
|
38
|
+
in `markDownstream`'s inner loop). Measurable on the very cheapest propagation
|
|
39
|
+
shapes where every iteration matters -- KAIROS moves from -7% -> -12% vs alien
|
|
40
|
+
on the 1.6.0-alpha sweep, DEEP CHAIN from -14% -> -21% -- and invisible on the
|
|
41
|
+
allocation-dominated shapes where the ratio of pool retracking to marker walks
|
|
42
|
+
favors lite by orders of magnitude (SELECTIVE DAG +49%, DYNAMIC DAG +43%, MUX
|
|
43
|
+
+35%, SMALL SELECTIVE +29% -- all unchanged from the 1.5.0-beta sweep). When a
|
|
44
|
+
profiler is actually attached the observable becomes the profiler's own cost and
|
|
45
|
+
the gate itself disappears from the picture. This is what lets `watchAllocations`
|
|
46
|
+
chart recompute/flush activity alongside the 1.4.0 allocation counters
|
|
47
|
+
(`totalAllocations` / `poolGrowths` / `totalDisposals`), which remain available
|
|
48
|
+
from 1.4.0 on every engine -- only the flush series requires 1.6.
|
|
49
|
+
|
|
50
|
+
The `03-pool` test for the `stats()` shape is bumped from "11-key 1.4.0 shape"
|
|
51
|
+
to "12-key 1.6 shape" with `flushPasses` in the expected key list.
|
|
52
|
+
|
|
53
|
+
### Added -- `createScope(fn)` (disposable owner scope)
|
|
54
|
+
|
|
55
|
+
`createScope` runs `fn(dispose)` in a detached scope and returns whatever `fn`
|
|
56
|
+
returns, having handed `fn` a single `dispose` that **cascade-disposes every effect
|
|
57
|
+
and computed created inside `fn`**. It is the lifecycle complement to `createRoot`:
|
|
58
|
+
|
|
59
|
+
- `createRoot(fn)` only **detaches** -- nodes created inside are unowned and the
|
|
60
|
+
caller must dispose each one by hand (there is no owner to do it automatically).
|
|
61
|
+
Correct for spawning one known long-lived watcher (lite-query's pattern).
|
|
62
|
+
- `createScope(fn)` **adopts** -- it owns whatever `fn` builds, so one disposer tears
|
|
63
|
+
down a subtree of *unknown* shape. This is what a per-item scope in a keyed-list or
|
|
64
|
+
scene reconciler requires, where the item's reactive graph is the consumer's
|
|
65
|
+
`mapFn`, not something the reconciler can enumerate.
|
|
66
|
+
|
|
67
|
+
**Semantics.** `fn` runs once in a detached, untracked context: no ownership and no
|
|
68
|
+
dependency leak from `fn`'s direct body into the enclosing scope, and the scope owner
|
|
69
|
+
never re-runs. Reactive bindings belong in inner effect/computed bodies inside `fn`
|
|
70
|
+
(those track normally and are owned by the scope); direct-body reads are untracked.
|
|
71
|
+
Consistent with the 1.2.0 ownership rule, **plain signals created directly in `fn` are
|
|
72
|
+
not adopted** -- dispose those explicitly (the creator holds the handle) or let them
|
|
73
|
+
fall out of reference; computeds and effects are adopted and cascade.
|
|
74
|
+
|
|
75
|
+
**Implementation.** The scope owner is backed by a never-re-running effect node, so it
|
|
76
|
+
counts as one effect in `stats()` and its disposer is the same gen-guarded, ABA-safe,
|
|
77
|
+
introspection-stamped handle `effect()` returns (`describe` / `nodeId` / `forEachOwned`
|
|
78
|
+
resolve it to the owner). No new node kind, flag, or `stats()` key -- the pinned
|
|
79
|
+
`signals + computeds + effects === activeNodes` invariant is untouched. The API
|
|
80
|
+
(`fn => dispose`) is the stable contract; a future engine may swap in a lighter
|
|
81
|
+
pure-owner node transparently.
|
|
82
|
+
|
|
83
|
+
Exported as a registry method and a top-level helper bound to the default registry,
|
|
84
|
+
mirroring `createRoot`.
|
|
85
|
+
|
|
86
|
+
### Added -- `getOwner` / `runWithOwner` (carried forward from 1.5.0-beta.2)
|
|
87
|
+
|
|
88
|
+
The re-attach companion to `createRoot`, ported forward from 1.5.0-beta.2
|
|
89
|
+
unchanged. `getOwner()` returns the current owner as an **opaque, gen-stamped
|
|
90
|
+
handle** (or `undefined` outside any effect/computed body); `runWithOwner(handle,
|
|
91
|
+
fn)` runs `fn` with the captured lifecycle scope reinstated so effects/computeds
|
|
92
|
+
created directly in `fn` are adopted by that owner. Nulls the tracking observer
|
|
93
|
+
for the duration of `fn` (same pairing as `createRoot`) so accidental cross-async
|
|
94
|
+
edges cannot form.
|
|
95
|
+
|
|
96
|
+
Handles are gen-stamped (the same `NODE_GEN` ABA-guard machinery
|
|
97
|
+
`describe` / `nodeId` / `forEachOwned` / `ownerOf` have used since 1.2.1) --
|
|
98
|
+
safe to hold across async boundaries. If the captured owner is disposed and
|
|
99
|
+
its pool slot recycled by an unrelated effect via the LIFO free list, the gen
|
|
100
|
+
no longer matches and `runWithOwner` degrades to **rooted execution** rather
|
|
101
|
+
than corrupting the graph. Two hazards on the raw-pointer alternative were
|
|
102
|
+
empirically reproduced against a 1.5.0-beta engine patched with the naive
|
|
103
|
+
implementation (`Publications/owner-hazard-repro.mjs`) and are pinned in
|
|
104
|
+
`test/28-run-with-owner.test.mjs`:
|
|
105
|
+
|
|
106
|
+
- **Recycled-slot cascade death** -- capture, dispose owner, allocate a stranger
|
|
107
|
+
effect that reuses the slot, `runWithOwner(captured)` silently adopts
|
|
108
|
+
continuation into the stranger, stranger's re-run cascade-disposes it.
|
|
109
|
+
- **Corpse adoption = engine crash** -- capture, dispose owner but not-yet-
|
|
110
|
+
recycled, `runWithOwner(captured, () => effect(...))` splices a child into
|
|
111
|
+
a disposed owner's `firstOwned` and the next disposal walk recurses without
|
|
112
|
+
termination (`RangeError: Maximum call stack size exceeded`).
|
|
113
|
+
|
|
114
|
+
Both fail on the raw-pointer sketch; both pass on the shipped `describeNode` /
|
|
115
|
+
`liveNode` implementation. Test coverage: 16 tests in `test/28-run-with-owner`
|
|
116
|
+
(basic shape, degradation, and the three hazard pins with allocation pressure
|
|
117
|
+
applied so the ABA guard is genuinely exercised).
|
|
118
|
+
|
|
119
|
+
Exported as registry methods and top-level helpers, mirroring `createRoot` /
|
|
120
|
+
`createScope`.
|
|
121
|
+
|
|
122
|
+
### Added -- characterization harnesses (`burst-dag.mjs`, `pull-stress.mjs`)
|
|
123
|
+
|
|
124
|
+
Two root-level standalone harnesses that exercise the new 1.6.0 instrumentation
|
|
125
|
+
surface against the engine's two main hot paths. Both are engine-agnostic
|
|
126
|
+
(`./Signal.js` + public `onGraphMutation` only), both expose a CLI + module
|
|
127
|
+
exports, both stay out of `npm test` and the published tarball.
|
|
128
|
+
|
|
129
|
+
**`burst-dag.mjs`** (`npm run profile:burst`, also `node --expose-gc burst-dag.mjs
|
|
130
|
+
[--width=512 --layers=32 ...]`) reconstructs the published
|
|
131
|
+
`js-reactivity-benchmark` burst shape (sources -> width x layers, fanIn 8, burst
|
|
132
|
+
16) and characterizes lite-signal's own flush behavior. The standalone path uses
|
|
133
|
+
the new `stats().flushPasses` counter as a cross-check against the opcode-6 pass
|
|
134
|
+
count -- by construction they must match when the hook is attached for exactly
|
|
135
|
+
one burst, which the harness asserts inline. Also exports `burstDagScenario`
|
|
136
|
+
(for plugging into a steady-state allocation gate) and `multiPassProbe` (a
|
|
137
|
+
controlled two-effect write-back that forces a `passes > 1` case so the opcode
|
|
138
|
+
dispatch can be smoke-tested on an engine where multi-pass actually occurs).
|
|
139
|
+
|
|
140
|
+
**`pull-stress.mjs`** (`npm run profile:pull`, also `node --expose-gc
|
|
141
|
+
pull-stress.mjs [--maxDepth=3584 --step=512 ...]`) is the pull-path companion:
|
|
142
|
+
characterizes how the recursive pull scales with chain depth and binary-searches
|
|
143
|
+
the exact overflow point. Three answers per run: (1) the exact deepest chain
|
|
144
|
+
that pulls successfully (the roadmap's "~5,000 chained computeds" pinned to a
|
|
145
|
+
number for the current engine), (2) per-level cold cost across a depth sweep
|
|
146
|
+
(should be roughly linear; superlinear flags a per-node bookkeeping cost
|
|
147
|
+
growing with depth), and (3) cached-read cost (should be O(1) regardless of
|
|
148
|
+
depth via the 1.1.4 `markEpoch` short-circuit). Structure pass at a safe fixed
|
|
149
|
+
depth confirms the opcode triple (0 flush passes, 0 effect runs, recomputes ==
|
|
150
|
+
depth) -- the pull path is doing nothing it shouldn't. Also exports
|
|
151
|
+
`pullStressScenario` for steady-state allocation gates and `probeOverflow`
|
|
152
|
+
for the binary search alone. Both `--kind=callable` and `--kind=box` are
|
|
153
|
+
supported and surface a real engine difference (box pulls overflow earlier
|
|
154
|
+
because `box.get()` adds a prototype-method frame per level, and cached box
|
|
155
|
+
reads are several times more expensive than cached callable reads).
|
|
156
|
+
|
|
157
|
+
Both files import only `./Signal.js`, so the same harness runs against any
|
|
158
|
+
engine build: point `Signal.js` at 1.5.x to compare without the counters
|
|
159
|
+
(`burst-dag` adapts -- only opcode 5 fires on that engine -- and `pull-stress`
|
|
160
|
+
works identically), or at a rejected candidate to re-verify on. The numbers
|
|
161
|
+
they produce are reproducible, comparable, and engine-version-aware.
|
|
162
|
+
|
|
163
|
+
### Verified
|
|
164
|
+
|
|
165
|
+
- **Full suite green** against the 1.6.0-alpha engine (getOwner + runWithOwner
|
|
166
|
+
merged in from 1.5.0-beta.2): **447 tests**, 436 pass, 0 fail, 1 skip
|
|
167
|
+
(only the architecturally-N/A SSR case in `17-reactivity`), 10 cancelled
|
|
168
|
+
(the `25-devtools-real-boot` cases that need `@zakkster/lite-devtools`
|
|
169
|
+
installed as a peer -- pre-existing, unrelated to any 1.6 change). +4
|
|
170
|
+
`createScope` tests in `test/28-scope_test.mjs`; +16 `getOwner` /
|
|
171
|
+
`runWithOwner` tests in `test/28-run-with-owner.test.mjs` (basic shape,
|
|
172
|
+
degradation, and the three hazard pins -- recycled-slot cascade / corpse
|
|
173
|
+
adoption / composed with allocation pressure); the 1.5.0 box and createRoot
|
|
174
|
+
suites carry forward unchanged. `test/03-pool` "stats() shape" test
|
|
175
|
+
updated from the 11-key 1.4.0 shape to the 12-key 1.6 shape (adds
|
|
176
|
+
`flushPasses`). **Coverage** (c8@11, Node 22): `Signal.js` 100% statements /
|
|
177
|
+
96.96% branches / 100% functions / 100% lines; `Watch.js` 100% across all
|
|
178
|
+
four. The branch drop vs 1.5.0 (97.35% -> 96.96%) is the zero-cost gate on
|
|
179
|
+
`flushPasses` / opcode 6 / opcode 7 -- the `if (mutationHook !== null)`
|
|
180
|
+
mutation-hook-attached branch is not exercised by the active test suite,
|
|
181
|
+
which never attaches a hook; the inert path is covered.
|
|
182
|
+
- **`createScope` behavior** (4 tests, `node --expose-gc`): returns `fn`'s value and
|
|
183
|
+
runs the owner exactly once even when `fn` reads signals in its direct body
|
|
184
|
+
(untracked); inner effects/computeds track and update; `dispose()` cascade-disposes
|
|
185
|
+
the owned subtree (effects + computeds) while an un-adopted signal correctly
|
|
186
|
+
survives; a disposed scope's inner effects stop firing; **a scope created inside a
|
|
187
|
+
consumer effect survives that consumer's re-run** (the reconciler-critical detach
|
|
188
|
+
property); `dispose()` is an idempotent no-op on the second call; the disposer is
|
|
189
|
+
introspection-stamped to its owner effect; and `totalAllocations - totalDisposals
|
|
190
|
+
=== activeNodes` holds after teardown. Plus a smoke confirming signal -> computed ->
|
|
191
|
+
effect is unaffected by the additive change.
|
|
192
|
+
- **`getOwner` / `runWithOwner` port**: sha256 over the extracted function bodies of
|
|
193
|
+
`pullComputed`, `executeEffect`, `allocateLink`, `severTail`, `createNode`,
|
|
194
|
+
`runCleanup`, `disposeNode`, `createRoot`, `createScope` matches the pristine
|
|
195
|
+
1.6.0-alpha engine byte-for-byte -- port touched no hot path. `Publications/
|
|
196
|
+
owner-hazard-repro.mjs` reports **`VERDICT: SAFE`** on the merged engine on both
|
|
197
|
+
hazards (continuation runs 2 times before stranger disposal, 3 after; corpse
|
|
198
|
+
case runs 2 without `RangeError`).
|
|
199
|
+
- **Instrumentation is zero-cost when unobserved**: `flushPasses` advances and opcodes
|
|
200
|
+
6/7 fire only while a mutation-hook listener is attached; with none, the two hook
|
|
201
|
+
fire sites are pure `null`-check branches (branch-predicted-free after warmup).
|
|
202
|
+
|
|
203
|
+
### Verified -- fresh 1.6.0-alpha bench sweep
|
|
204
|
+
|
|
205
|
+
Both benches re-run on the 1.6.0-alpha engine and committed to
|
|
206
|
+
`bench/results.txt` (isolated propagation, 9 scenarios) and
|
|
207
|
+
`bench/resultsReactive.txt` (cross-framework reactivity, median-of-10, 34
|
|
208
|
+
tests). The 10 raw reactive-suite runs sit under `bench/bench-runs-reactive/
|
|
209
|
+
run_1.txt` ... `run_10.txt` so anyone can re-median independently.
|
|
210
|
+
|
|
211
|
+
- **Propagation bench (results.txt):** lite +49% / +43% / +35% / +29% on the four
|
|
212
|
+
allocation-heavy scenarios (SELECTIVE DAG / DYNAMIC DAG / MUX / SMALL
|
|
213
|
+
SELECTIVE) -- unchanged in character from the 1.5.0-beta sweep, the gate is
|
|
214
|
+
round-off on allocation-dominated shapes. Parity on LARGE WEB APP (-3%) and
|
|
215
|
+
WIDE DENSE (-6%), inside host noise. **Alien-signals ahead on BROADCAST
|
|
216
|
+
(-10%), KAIROS (-12%, was -7% on 1.5.0-beta), and DEEP CHAIN (-21%, was -14%
|
|
217
|
+
on 1.5.0-beta)** -- the KAIROS and DEEP CHAIN widening is the observable
|
|
218
|
+
gate cost on shapes where every branch matters. Speed wins vs alien: **4/9**
|
|
219
|
+
(was 5/9); heap wins: **8/9** (unchanged).
|
|
220
|
+
- **Reactive suite (resultsReactive.txt):** fastest of five frameworks on all
|
|
221
|
+
five `dyn` rows (simple +19%, dynamic +13%, large web app +11%, wide dense
|
|
222
|
+
+4%, deep +16%). On the `S: updateComputations` micro-rows lite trades the
|
|
223
|
+
lead with alien: **4/7 wins this sweep** (was 7/7 on 1.5.0-beta), consistent
|
|
224
|
+
with the gate cost on 50-70ms rows that iterate many thousands of times per
|
|
225
|
+
measurement.
|
|
226
|
+
- **Andrii Volynets js-reactivity-benchmark position holds at 4th of 15** with
|
|
227
|
+
geomean **73.1ms** (raw log `bench/AndriiVolynetsReactiveBench.log`, all 15
|
|
228
|
+
x 47 rows); lite is ahead of 5th-place Preact Signals (79.9) by ~9%.
|
|
229
|
+
Outright-fastest-of-15 wins jumped to **6 shapes**: `broadPropagation`,
|
|
230
|
+
`manyEffectsFromOneSource`, `manySourcesIntoOneComputedEffect`,
|
|
231
|
+
`manySourcesIntoOneComputedEffectWithDirect`, `molBench`, and the `32x8 - 4
|
|
232
|
+
sources - pull` DAG. Top-3 count: 23/47. (Outright wins swing at the top of
|
|
233
|
+
a very tight leaderboard; the stable metric across every sweep is the
|
|
234
|
+
geomean rank at 4th of 15.)
|
|
235
|
+
- **Third-party engine versions carried forward** from the 1.5.0-beta sweep
|
|
236
|
+
(alien-signals 3.2.1, @preact/signals-core 1.14.2, @vue/reactivity 3.5.35,
|
|
237
|
+
solid-js 1.9.13). No peer bumps this cycle -- the deltas here are the 1.6
|
|
238
|
+
engine's own footprint plus host noise.
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
## [1.5.0] -- 2026-06-XX
|
|
127
243
|
|
|
128
244
|
The API-surface minor: two new **non-callable, allocation-light** reactive
|
|
129
245
|
primitives, `signalBox` and `computedBox`, land alongside the existing callable
|