@zakkster/lite-signal 1.8.0-experimental → 1.8.0-experimental.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 +1491 -0
- package/Signal.js +80 -1
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,1491 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@zakkster/lite-signal` are documented here.
|
|
4
|
+
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
This project follows [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [1.8.0-preview] -- 2026-07-XX
|
|
8
|
+
|
|
9
|
+
The **effect cleanup return** minor -- Reflex-study pattern A. One additive
|
|
10
|
+
hot-path change: an effect body may now `return` a cleanup function, which
|
|
11
|
+
runs before the next re-run and on dispose, composing with imperative
|
|
12
|
+
`onCleanup(fn)` in call order. Plus the recurring **`getOwner` /
|
|
13
|
+
`runWithOwner` forward-port from 1.5.0-beta.2** -- the 1.8.0-preview
|
|
14
|
+
`Signal.js` was branched from the same pre-1.5.0-beta.2 base as 1.7.0-preview
|
|
15
|
+
and 1.6.0-alpha, so the two async-gap ownership primitives are re-added
|
|
16
|
+
unchanged on this line.
|
|
17
|
+
|
|
18
|
+
The 1.7.0 flushStrategy scaffolding (`"eager"` | `"sab"` | `"manual"` + explicit
|
|
19
|
+
`r.flush()`) carries forward unchanged, as does every 1.5-era API surface
|
|
20
|
+
(`signalBox` / `computedBox` / `createRoot` / `createScope`) and every
|
|
21
|
+
propagation-core primitive. **Only `executeEffect` legitimately changed** from
|
|
22
|
+
1.7.0-preview; sha256 over the 15 other function bodies is byte-identical
|
|
23
|
+
between pristine 1.7.0-preview and pristine 1.8.0 (verified: `pullComputed`,
|
|
24
|
+
`markDownstream`, `flushEffects`, `allocateLink`, `severTail`, `createNode`,
|
|
25
|
+
`runCleanup`, `disposeNode`, `createRoot`, `createScope`, `flush`, `batch`,
|
|
26
|
+
`signal`, `computed`, `effect`).
|
|
27
|
+
|
|
28
|
+
Drop-in over 1.7.0-preview. The default is unchanged; effects that do not
|
|
29
|
+
return a function are unaffected (one `typeof` check per effect run, off the
|
|
30
|
+
mark/pull path).
|
|
31
|
+
|
|
32
|
+
### Added -- effect cleanup return (Reflex pattern A)
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
effect(() => {
|
|
36
|
+
const timer = setInterval(tick, 16);
|
|
37
|
+
return () => clearInterval(timer); // <-- ran before next re-run, and on dispose
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Solid/Vue/Reflex-compatible: an effect body may **return a cleanup function**.
|
|
42
|
+
It runs before the next re-run and on the effect's disposal, appended to any
|
|
43
|
+
imperative `onCleanup(fn)` registered inside the same body with the same append
|
|
44
|
+
semantics (single fn -> pair array -> push), so the two registration styles
|
|
45
|
+
**compose in call order**. Non-function returns are ignored. A self-disposed
|
|
46
|
+
body (one that generation-advances mid-execution) registers nothing -- the
|
|
47
|
+
slot may already host a new resident by the time the return is inspected, so
|
|
48
|
+
the guard is `node.gen === savedGen` before touching `node.cleanupFn`.
|
|
49
|
+
|
|
50
|
+
**Computeds are untouched.** A computed returning a function keeps treating
|
|
51
|
+
that function as the *value*. The cleanup-return check is inside
|
|
52
|
+
`executeEffect` and gated on the effect body's return type; the computed pull
|
|
53
|
+
path has no analogous inspection.
|
|
54
|
+
|
|
55
|
+
**Cost.** One `typeof` per effect run, entirely off the mark/pull path.
|
|
56
|
+
`executeEffect`'s sha256 is the only 1.7 -> 1.8 body change; every other
|
|
57
|
+
propagation function is byte-identical (see Hot-path safety below).
|
|
58
|
+
|
|
59
|
+
### Added -- `getOwner` / `runWithOwner` (carried forward from 1.5.0-beta.2)
|
|
60
|
+
|
|
61
|
+
The capture-and-restore companion to `createRoot`. `getOwner()` returns the
|
|
62
|
+
current lifecycle owner as an opaque, gen-stamped handle (`undefined` outside
|
|
63
|
+
any effect/computed body); `runWithOwner(handle, fn)` runs `fn` with that
|
|
64
|
+
owner reinstated so effects/computeds created directly in `fn` are adopted by
|
|
65
|
+
it (and cascade-dispose when the owner re-runs). Nulls the tracking observer
|
|
66
|
+
for `fn`'s direct body -- same pairing as `createRoot`, so accidental
|
|
67
|
+
cross-async dependency edges cannot form.
|
|
68
|
+
|
|
69
|
+
**Handles are gen-stamped.** They use the `describeNode` + `liveNode`
|
|
70
|
+
ABA-guard machinery (`NODE_GEN` stamp checked against the pool slot's current
|
|
71
|
+
gen), same as `describe` / `nodeId` / `forEachOwned` / `ownerOf` since 1.2.1.
|
|
72
|
+
Safe to hold across async boundaries: stale handles (owner disposed, slot
|
|
73
|
+
recycled by an unrelated effect via the LIFO free list) degrade to **rooted
|
|
74
|
+
execution** rather than adopting the continuation into the recycled slot's new
|
|
75
|
+
resident. Two hazards on the raw-pointer alternative are empirically
|
|
76
|
+
reproduced by `Publications/owner-hazard-repro.mjs`:
|
|
77
|
+
|
|
78
|
+
- **Recycled-slot cascade death** -- capture, dispose owner, allocate a
|
|
79
|
+
stranger effect that reuses the slot; a raw-pointer
|
|
80
|
+
`runWithOwner(captured)` silently adopts the continuation into the
|
|
81
|
+
stranger; the stranger's next re-run cascade-disposes it.
|
|
82
|
+
- **Corpse adoption = engine crash** -- capture, dispose owner but
|
|
83
|
+
not-yet-recycled; a raw-pointer `runWithOwner(captured, () => effect(...))`
|
|
84
|
+
splices a child into a disposed owner's `firstOwned`; the next disposal
|
|
85
|
+
walk recurses without termination (`RangeError: Maximum call stack size
|
|
86
|
+
exceeded`). Not a leak; a crash.
|
|
87
|
+
|
|
88
|
+
Both fail on the raw-pointer sketch; both pass on the shipped `describeNode` /
|
|
89
|
+
`liveNode` implementation. Verified against 1.8.0-preview's engine directly:
|
|
90
|
+
`Publications/owner-hazard-repro.mjs ./Signal.js` reports `VERDICT: SAFE` on
|
|
91
|
+
the recycled-slot case (continuation runs 2 times before stranger disposal, 3
|
|
92
|
+
times after) and completes the corpse case without stack overflow.
|
|
93
|
+
|
|
94
|
+
Exported as registry methods AND top-level helpers bound to `defaultRegistry`,
|
|
95
|
+
inserted between `createRoot`'s top-level binding and `createScope`'s for
|
|
96
|
+
stable ordering. No hot path touched; sha256 over the 15 other function
|
|
97
|
+
bodies matches pristine 1.8.0-preview byte-for-byte.
|
|
98
|
+
|
|
99
|
+
### Rejected during this cycle (ledger #13)
|
|
100
|
+
|
|
101
|
+
The **"lean node shape" batch-revert side stack** (Reflex pattern C). Moving
|
|
102
|
+
the on-node `{preBatchValue, preBatchVersion, revertEpoch}` triple into a
|
|
103
|
+
registry-level capture stack -- both a parallel-arrays variant AND an
|
|
104
|
+
interleaved stride-3 variant -- held the full behavioral contract (**439/439
|
|
105
|
+
internal tests, conformance clean**) and was VersionMatrix-neutral, but
|
|
106
|
+
regressed capture-dense batched writes **+5-9%** and revert-heavy batches
|
|
107
|
+
**+20%** in cold-process A/B (n=3, consistent).
|
|
108
|
+
|
|
109
|
+
Family (c) loses in **both** directions: these fields are not cold. The first
|
|
110
|
+
batched write is a hot edge (every batch that mutates a signal touches
|
|
111
|
+
`preBatchValue` on the way in), and the on-node triple **already rides
|
|
112
|
+
`node.value`'s cache line** -- no side structure can beat sitting inside the
|
|
113
|
+
line that's about to be loaded anyway. The build is archived under
|
|
114
|
+
`engines/rejected/1_8_0-sidestack.js` with its probe for future reference.
|
|
115
|
+
|
|
116
|
+
### Also measured this cycle (not a 1.8.0 engine property)
|
|
117
|
+
|
|
118
|
+
The **recursive-pull depth plateau is V8-scope-shape-sensitive**. Adding ANY
|
|
119
|
+
context slots to `createRegistry` -- **four dummy consts suffice** -- drops
|
|
120
|
+
the cold-pull overflow point from ~4096 to ~2559 on Node 22 by parking the
|
|
121
|
+
probe on interpreted-size frames. Ceiling scales linearly with
|
|
122
|
+
`--stack-size` on every build. Public claims quoting `~4k depth` should be
|
|
123
|
+
tightened to **"plateau-dependent, 2.5k-4k, tunable"** because the exact
|
|
124
|
+
ceiling is a V8 frame-layout artifact, not an engine constant. Nothing in
|
|
125
|
+
this release changed the pull path; the sensitivity was there in 1.7 too and
|
|
126
|
+
is documented here for the record. `pull-stress.mjs` (1.6+) will pin the
|
|
127
|
+
exact number on any given build.
|
|
128
|
+
|
|
129
|
+
### Hot-path safety
|
|
130
|
+
|
|
131
|
+
**Only `executeEffect` legitimately changed** from 1.7.0-preview -- the
|
|
132
|
+
cleanup-return check is an extra `typeof` + a small append. sha256 over the
|
|
133
|
+
15 other propagation-relevant function bodies (`pullComputed`,
|
|
134
|
+
`markDownstream`, `flushEffects`, `allocateLink`, `severTail`, `createNode`,
|
|
135
|
+
`runCleanup`, `disposeNode`, `createRoot`, `createScope`, `flush`, `batch`,
|
|
136
|
+
`signal`, `computed`, `effect`) matches pristine 1.7.0-preview byte-for-byte.
|
|
137
|
+
|
|
138
|
+
The `getOwner` / `runWithOwner` port only adds new user-API functions between
|
|
139
|
+
`createRoot` and `createScope` -- verified via sha256 that no pre-existing
|
|
140
|
+
function was disturbed by the insertion. Nothing in the propagation core,
|
|
141
|
+
scheduler, or pool moved.
|
|
142
|
+
|
|
143
|
+
### Test coverage
|
|
144
|
+
|
|
145
|
+
- **Full suite green** on 1.8.0-preview with the getOwner/runWithOwner port
|
|
146
|
+
merged in: **451 total**, 440 pass, 0 fail, 1 skip (only the
|
|
147
|
+
architecturally-N/A SSR case in `17-reactivity`), 10 cancelled (the
|
|
148
|
+
`25-devtools-real-boot` cases that need `@zakkster/lite-devtools` installed
|
|
149
|
+
as a peer -- pre-existing, unrelated). Default-mode behavior for effects
|
|
150
|
+
that do not return a function is unchanged from 1.7.0-preview byte-for-byte.
|
|
151
|
+
- **+16 tests in `test/28-run-with-owner.test.mjs`** carried forward from
|
|
152
|
+
1.5.0-beta.2 (basic shape, degradation, and the three hazard pins with
|
|
153
|
+
allocation pressure applied).
|
|
154
|
+
- **`test/03-pool` "stats() shape"** carries the 12-key 1.6+ shape assertion
|
|
155
|
+
forward (`flushPasses` present).
|
|
156
|
+
- **New behavioral coverage to add** for effect cleanup return (deferred to
|
|
157
|
+
`1.8.0-preview.1`): fires before next re-run, fires on dispose,
|
|
158
|
+
composition with `onCleanup(fn)` respects call order, non-function returns
|
|
159
|
+
ignored, self-disposed body registers no cleanup, computed returning a
|
|
160
|
+
function still treats it as the VALUE (regression pin), cleanup exceptions
|
|
161
|
+
do not stop the effect from re-running (or do -- design decision either way
|
|
162
|
+
needs a test).
|
|
163
|
+
|
|
164
|
+
### Verified
|
|
165
|
+
|
|
166
|
+
- **Full engine test suite** green on the merged engine (451 total, 440 pass,
|
|
167
|
+
0 fail, 1 skip, 10 cancelled).
|
|
168
|
+
- **`Publications/owner-hazard-repro.mjs ./Signal.js`** reports `VERDICT:
|
|
169
|
+
SAFE` on the recycled-slot case AND completes the corpse case without stack
|
|
170
|
+
overflow -- the ABA guard degrades both hazards to rooted execution as
|
|
171
|
+
designed.
|
|
172
|
+
- **sha256 over 15 pre-existing function bodies** byte-identical between
|
|
173
|
+
pristine 1.8.0-preview and my merged-with-getOwner engine (port added new
|
|
174
|
+
code only). **`executeEffect` sha256** matches between pristine 1.8.0 and
|
|
175
|
+
my merged file too -- the cleanup-return addition survives the port
|
|
176
|
+
unchanged; my port did not touch that function.
|
|
177
|
+
- **`executeEffect` sha256 vs 1.7.0-preview**: `26613285331deaed` ->
|
|
178
|
+
`4487beb9d15f80c6`. Legitimate change; the sole 1.7 -> 1.8 hot-path
|
|
179
|
+
modification.
|
|
180
|
+
- **`markDownstream` / `flushEffects` sha256**: unchanged from 1.7.0-preview
|
|
181
|
+
(still `ad7a007ec23260fc` / `a25b36ba097fdf1a`), which in turn track back
|
|
182
|
+
to 1.6.0-alpha's opcode 6/7 additions. The 1.8 minor introduces no new
|
|
183
|
+
hook-gate branches.
|
|
184
|
+
|
|
185
|
+
### Migration
|
|
186
|
+
|
|
187
|
+
- **Every existing user**: zero work needed. Effects that don't return a
|
|
188
|
+
function are unaffected. `flushStrategy` default remains `"eager"` (1.7's
|
|
189
|
+
byte-identical mode).
|
|
190
|
+
- **Effects that already return a value (e.g. a state update)**: only
|
|
191
|
+
function returns are treated as cleanups. If an effect happens to return a
|
|
192
|
+
function today (rare, but possible), it will now be registered as a
|
|
193
|
+
cleanup. Audit before upgrading if this is your codebase's pattern.
|
|
194
|
+
- **Users of `createRoot` who want capture-and-restore across async
|
|
195
|
+
boundaries**: `getOwner()` + `runWithOwner()` are now on the 1.8 line
|
|
196
|
+
(same signatures and semantics as 1.5.0-beta.2 / 1.6.0-alpha /
|
|
197
|
+
1.7.0-preview).
|
|
198
|
+
|
|
199
|
+
## [1.7.0-preview] -- 2026-07-XX
|
|
200
|
+
|
|
201
|
+
The **flush-strategy minor**, shipping on the `preview` dist-tag while it settles.
|
|
202
|
+
Two additions on top of 1.6.0-preview:
|
|
203
|
+
|
|
204
|
+
- **`flushStrategy` registry option + `r.flush()`** -- the primary 1.7 lever, a
|
|
205
|
+
per-registry choice of when effects auto-deliver (`"eager"` default | `"sab"` |
|
|
206
|
+
`"manual"`) plus an explicit `flush()` method on every registry. Resolved once at
|
|
207
|
+
registry init by binding to a pre-built closure reference; the "eager" inlined
|
|
208
|
+
body is byte-identical to 1.6's `if (batchDepth === 0) flushEffects()` so
|
|
209
|
+
existing users see zero behavioral or performance regression.
|
|
210
|
+
- **`getOwner` / `runWithOwner` port** -- carried forward from 1.5.0-beta.2 into
|
|
211
|
+
this line. The 1.7.0-preview `Signal.js` was branched from a pre-1.5.0-beta.2
|
|
212
|
+
base and the two async-gap primitives (`getOwner()` capture, `runWithOwner()`
|
|
213
|
+
restore) were missing. Ported unchanged: the same safe `describeNode` +
|
|
214
|
+
`liveNode` gen-guard machinery that landed in 1.5.0-beta.2 and carried into 1.6
|
|
215
|
+
is now present here too, so any consumer using the ownership escape hatch (e.g.
|
|
216
|
+
`lite-query`'s query-watcher across an `await`) gets the same guarantees on the
|
|
217
|
+
1.7 line.
|
|
218
|
+
|
|
219
|
+
The two hot-path changes 1.6 -> 1.7 are localised to `signal` / `computed` /
|
|
220
|
+
`effect` / `signalBox` / `computedBox` (their `.set` sites) and `batch` (their
|
|
221
|
+
exit sites) -- specifically the resolved-once binding to `flushAfterWrite` /
|
|
222
|
+
`flushAfterBatch`. **Every other hot-path body is byte-identical to 1.6.0**
|
|
223
|
+
(sha256-verified over `pullComputed`, `markDownstream`, `executeEffect`,
|
|
224
|
+
`flushEffects`, `allocateLink`, `severTail`, `createNode`, `runCleanup`,
|
|
225
|
+
`disposeNode`, `createRoot`, `createScope`). The two ownership primitives added
|
|
226
|
+
by this port only add new user-API functions -- they do not touch any of the
|
|
227
|
+
above; the sha256 check confirms it.
|
|
228
|
+
|
|
229
|
+
Drop-in over 1.6.0-preview. The default is unchanged.
|
|
230
|
+
|
|
231
|
+
### Added -- `flushStrategy` registry option
|
|
232
|
+
|
|
233
|
+
Selects when effects auto-deliver, chosen once at `createRegistry` time:
|
|
234
|
+
|
|
235
|
+
- **`"eager"`** (default, byte-identical to 1.6.0): `.set` outside batch
|
|
236
|
+
auto-flushes; batch exit auto-flushes.
|
|
237
|
+
- **`"sab"`** (**stable-after-batch**, matches Reflex semantics): `.set` outside
|
|
238
|
+
batch enqueues effects via the existing `FLAG_SCHEDULED` dedup but does NOT
|
|
239
|
+
auto-flush; batch exit DOES auto-flush. This is the apples-to-apples mode for
|
|
240
|
+
the `js-reactivity-benchmark` `update*` group -- on shapes with observers but
|
|
241
|
+
no effects, the eager `flushEffects` empty-path `try/finally` was the dominant
|
|
242
|
+
per-write overhead.
|
|
243
|
+
- **`"manual"`**: neither `.set` nor batch exit auto-flush; only explicit
|
|
244
|
+
`r.flush()` drains the queue. For hard-real-time loops that need frame-aligned
|
|
245
|
+
settle points (Hueforge, Gradient Studio).
|
|
246
|
+
|
|
247
|
+
### Added -- `r.flush()` explicit flush API
|
|
248
|
+
|
|
249
|
+
Explicit flush method on every registry. Re-entrant safe (the existing
|
|
250
|
+
`isFlushing` guard applies unchanged); empty queue exits immediately. The three
|
|
251
|
+
strategies use it as follows: `"eager"` never needs it (auto-flushes cover
|
|
252
|
+
everything); `"sab"` needs it if you `.set` outside batch and want the effects
|
|
253
|
+
to run without waiting for the next batch exit; `"manual"` needs it to run any
|
|
254
|
+
effects at all.
|
|
255
|
+
|
|
256
|
+
### Added -- `getOwner` / `runWithOwner` (carried forward from 1.5.0-beta.2)
|
|
257
|
+
|
|
258
|
+
The capture-and-restore companion to `createRoot`. `getOwner()` returns the
|
|
259
|
+
current lifecycle owner as an opaque, gen-stamped handle (`undefined` outside
|
|
260
|
+
any effect/computed body); `runWithOwner(handle, fn)` runs `fn` with that owner
|
|
261
|
+
reinstated so effects/computeds created directly in `fn` are adopted by it (and
|
|
262
|
+
cascade-dispose when the owner re-runs). Nulls the tracking observer for `fn`'s
|
|
263
|
+
direct body -- same pairing as `createRoot`, so accidental cross-async
|
|
264
|
+
dependency edges cannot form.
|
|
265
|
+
|
|
266
|
+
**Handles are gen-stamped.** They use the `describeNode` + `liveNode` ABA-guard
|
|
267
|
+
machinery (`NODE_GEN` stamp checked against the pool slot's current gen), same as
|
|
268
|
+
`describe` / `nodeId` / `forEachOwned` / `ownerOf` since 1.2.1. Safe to hold
|
|
269
|
+
across async boundaries: if the captured owner is disposed and the pool slot is
|
|
270
|
+
recycled by an unrelated effect via the LIFO free list, the handle's gen no
|
|
271
|
+
longer matches and `runWithOwner` degrades to **rooted execution** rather than
|
|
272
|
+
adopting the continuation into the recycled slot's new resident. Two hazards on
|
|
273
|
+
the raw-pointer alternative pinned in `test/28-run-with-owner.test.mjs` and
|
|
274
|
+
empirically reproduced against a patched engine via
|
|
275
|
+
`Publications/owner-hazard-repro.mjs`:
|
|
276
|
+
|
|
277
|
+
- **Recycled-slot cascade death** -- capture, dispose owner, allocate a stranger
|
|
278
|
+
effect that reuses the slot; a raw-pointer `runWithOwner(captured)` silently
|
|
279
|
+
adopts the continuation into the stranger; the stranger's next re-run
|
|
280
|
+
cascade-disposes it.
|
|
281
|
+
- **Corpse adoption = engine crash** -- capture, dispose owner but not-yet-
|
|
282
|
+
recycled; a raw-pointer `runWithOwner(captured, () => effect(...))` splices a
|
|
283
|
+
child into a disposed owner's `firstOwned`; the next disposal walk recurses
|
|
284
|
+
without termination (`RangeError: Maximum call stack size exceeded`). Not a
|
|
285
|
+
leak; a crash.
|
|
286
|
+
|
|
287
|
+
Both fail on the raw-pointer sketch; both pass on the shipped `describeNode` /
|
|
288
|
+
`liveNode` implementation. Verified against 1.7.0-preview's engine directly --
|
|
289
|
+
`Publications/owner-hazard-repro.mjs ./Signal.js` reports `VERDICT: SAFE` on the
|
|
290
|
+
recycled-slot case (continuation runs 2 times before stranger disposal, 3
|
|
291
|
+
times after) and completes the corpse case without stack overflow.
|
|
292
|
+
|
|
293
|
+
Exported as registry methods AND top-level helpers bound to `defaultRegistry`,
|
|
294
|
+
mirroring `createRoot` and `createScope`. Top-level exports added right before
|
|
295
|
+
the top-level `createScope` binding for stable ordering.
|
|
296
|
+
|
|
297
|
+
### Hot-path safety
|
|
298
|
+
|
|
299
|
+
The `flushStrategy` lever is resolved ONCE at registry init by binding
|
|
300
|
+
`flushAfterWrite` and `flushAfterBatch` to one of two pre-built closure
|
|
301
|
+
references (`eagerFlushHook | noopFlush`). Every `.set` / `boxSet` / `batch`
|
|
302
|
+
call site captures a constant function reference for its lifetime; V8 sees
|
|
303
|
+
monomorphic targets and inlines the body. In "eager" mode the inlined body is
|
|
304
|
+
byte-identical to the 1.6.0 inline check `if (batchDepth === 0) flushEffects()`
|
|
305
|
+
-- **zero behavioral or performance regression** for any existing user.
|
|
306
|
+
|
|
307
|
+
This is NOT ledger §0b #6 (per-call closure-var load of a primitive). It is a
|
|
308
|
+
hoisted function reference resolved once at registry build time and is a NEW
|
|
309
|
+
mechanism by the v1 roadmap §0b line 100 definition.
|
|
310
|
+
|
|
311
|
+
The `getOwner` / `runWithOwner` port adds new user-API functions but touches no
|
|
312
|
+
hot path. sha256 over the extracted function bodies of `pullComputed`,
|
|
313
|
+
`markDownstream`, `executeEffect`, `flushEffects`, `allocateLink`, `severTail`,
|
|
314
|
+
`createNode`, `runCleanup`, `disposeNode`, `createRoot`, `createScope` matches
|
|
315
|
+
pristine 1.7.0-preview byte-for-byte; the two new functions are inserted between
|
|
316
|
+
`createRoot` and `createScope` without disturbing either.
|
|
317
|
+
|
|
318
|
+
### Test coverage
|
|
319
|
+
|
|
320
|
+
- **Full suite green** on 1.7.0-preview with the getOwner/runWithOwner port
|
|
321
|
+
merged in: **451 total**, 440 pass, 0 fail, 1 skip (only the
|
|
322
|
+
architecturally-N/A SSR case in `17-reactivity`), 10 cancelled (the
|
|
323
|
+
`25-devtools-real-boot` cases that need `@zakkster/lite-devtools` installed as
|
|
324
|
+
a peer -- pre-existing, unrelated). Default-mode behavior is unchanged
|
|
325
|
+
byte-for-byte from 1.6.0.
|
|
326
|
+
- **+16 tests in `test/28-run-with-owner.test.mjs`** (carried forward from
|
|
327
|
+
1.5.0-beta.2 / 1.6.0-alpha): 7 basic-shape tests, 3 degradation tests
|
|
328
|
+
(`null` / `undefined` / signal-handle all fall through to rooted execution),
|
|
329
|
+
and 3 **hazard pins** with allocation pressure applied so the ABA guard is
|
|
330
|
+
actually exercised (recycled-slot cascade, corpse adoption, composed).
|
|
331
|
+
- **`test/03-pool` "stats() shape" test** bumped from the 11-key 1.4.0 shape to
|
|
332
|
+
the 12-key 1.6+ shape (adds `flushPasses`). This was flagged already in the
|
|
333
|
+
1.6.0 line; the 1.7 line inherits it.
|
|
334
|
+
- **New behavioral coverage to add** (per the drafted 1.7 notes, deferred to
|
|
335
|
+
1.7.0-preview.1): `sab` batch-exit flush, `sab` dedup across many writes,
|
|
336
|
+
`manual` flush gating, lazy-pull correctness across all three modes, invalid
|
|
337
|
+
`flushStrategy` validation.
|
|
338
|
+
|
|
339
|
+
### Bench impact (sandbox VM medians, 7 samples)
|
|
340
|
+
|
|
341
|
+
`update*` group with observers-but-no-effects, apples-to-apples in `sab` mode:
|
|
342
|
+
|
|
343
|
+
| Shape (n=writes) | eager | sab | speedup |
|
|
344
|
+
|------------------|-------:|-------:|--------:|
|
|
345
|
+
| 1to1 (400k) | 14.15 | 12.04 | 1.18x |
|
|
346
|
+
| 1to2 (400k) | 11.68 | 10.25 | 1.14x |
|
|
347
|
+
| 1to4 (400k) | 11.36 | 11.01 | 1.03x |
|
|
348
|
+
| 1to8 (400k) | 11.47 | 10.09 | 1.14x |
|
|
349
|
+
| 1to1000 (4k) | 1.59 | 1.55 | 1.03x |
|
|
350
|
+
| 1000to1 (1k) | 0.07 | 0.03 | 2.31x |
|
|
351
|
+
|
|
352
|
+
Real wins, but smaller than the gap to Reflex on the same shapes. The residual
|
|
353
|
+
gap is structural (per-write `gen` check, batch-revert epoch tracking, global
|
|
354
|
+
version bumping) -- design decisions accepted by §0b and not in scope here.
|
|
355
|
+
Modern V8's `try/finally` elision varies; expect higher absolute speedups on
|
|
356
|
+
production V8 than on this sandbox.
|
|
357
|
+
|
|
358
|
+
### Migration
|
|
359
|
+
|
|
360
|
+
- **Every existing user**: zero work needed. The default is unchanged; every
|
|
361
|
+
registry created without a `flushStrategy` argument runs the same code as on
|
|
362
|
+
1.6.0.
|
|
363
|
+
- **Bench adapters wanting apples-to-apples with Reflex-style flush semantics**:
|
|
364
|
+
pass `flushStrategy: "sab"` to `createRegistry` (see `liteSignal.ts` example
|
|
365
|
+
in the changeset).
|
|
366
|
+
- **Frame-aligned real-time loops**: pass `flushStrategy: "manual"` and call
|
|
367
|
+
`r.flush()` at the settle point.
|
|
368
|
+
- **Users of `createRoot` who want the capture-and-restore idiom across
|
|
369
|
+
async boundaries**: `getOwner()` + `runWithOwner()` are now available on
|
|
370
|
+
the 1.7 line (they were absent from pre-1.5.0-beta.2 branches and needed the
|
|
371
|
+
forward-port to reach 1.7 through the flushStrategy branch).
|
|
372
|
+
|
|
373
|
+
### Verified
|
|
374
|
+
|
|
375
|
+
- **Full engine test suite** green on the merged engine (451 total, 440 pass,
|
|
376
|
+
0 fail, 1 skip, 10 cancelled).
|
|
377
|
+
- **`Publications/owner-hazard-repro.mjs ./Signal.js`** reports
|
|
378
|
+
`VERDICT: SAFE` on the recycled-slot case AND completes the corpse case
|
|
379
|
+
without stack overflow -- the ABA guard degrades both hazards to rooted
|
|
380
|
+
execution as designed.
|
|
381
|
+
- **sha256 over 11 hot-path function bodies** (`pullComputed`, `markDownstream`,
|
|
382
|
+
`executeEffect`, `flushEffects`, `allocateLink`, `severTail`, `createNode`,
|
|
383
|
+
`runCleanup`, `disposeNode`, `createRoot`, `createScope`) byte-identical
|
|
384
|
+
between pristine 1.7.0-preview (as uploaded) and the merged-with-getOwner
|
|
385
|
+
engine. The port literally only adds new code between `createRoot` and
|
|
386
|
+
`createScope` plus updates the return object and adds two top-level exports;
|
|
387
|
+
zero touch on any pre-existing function.
|
|
388
|
+
|
|
389
|
+
## [1.6.0] -- 2026-06-26 (preview)
|
|
390
|
+
|
|
391
|
+
The observability-and-lifecycle minor, shipping on the `preview` dist-tag while it
|
|
392
|
+
settles. Two additions: `stats()` gains a twelfth key, **`flushPasses`**, plus two
|
|
393
|
+
flush-profiling mutation-hook opcodes -- the flush/recompute dimension
|
|
394
|
+
lite-devtools 1.2 / lite-studio 1.2 read through `watchAllocations`; and
|
|
395
|
+
**`createScope(fn)`** (landed in `preview.0`), the disposable-owner counterpart to
|
|
396
|
+
`createRoot` that a keyed-list / scene reconciler needs for per-item teardown.
|
|
397
|
+
Drop-in over 1.5.0: the callable API and hot paths are unchanged, and the new
|
|
398
|
+
instrumentation is frozen and zero-cost unless a mutation-hook listener is attached.
|
|
399
|
+
|
|
400
|
+
### Added -- `flushPasses` on `stats()` + flush-profiling opcodes
|
|
401
|
+
|
|
402
|
+
`stats()` now returns **12 keys**: the 11 from 1.4.x plus `flushPasses`, a counter
|
|
403
|
+
that advances once per effect-flush drain pass. Two `onGraphMutation` opcodes back
|
|
404
|
+
the flush dimension:
|
|
405
|
+
|
|
406
|
+
- **`6` flush pass** -- `(passCount, effectsToRun)`, at the top of each drain pass.
|
|
407
|
+
- **`7` effect run in pass** -- `(id, 0)`, before each effect re-run inside a pass.
|
|
408
|
+
|
|
409
|
+
Both the counter bump and the opcode dispatch sit behind the existing
|
|
410
|
+
`if (mutationHook !== null)` gate, so when no profiler is attached they are inert:
|
|
411
|
+
`flushPasses` is frozen and the flush loop is byte-identical to 1.5.0. This is what
|
|
412
|
+
lets `watchAllocations` chart recompute/flush activity alongside the 1.4.0
|
|
413
|
+
allocation counters (`totalAllocations` / `poolGrowths` / `totalDisposals`), which
|
|
414
|
+
remain available from 1.4.0 on every engine -- only the flush series requires 1.6.
|
|
415
|
+
|
|
416
|
+
### Added -- `createScope(fn)` (disposable owner scope) [preview.0]
|
|
417
|
+
|
|
418
|
+
`createScope` runs `fn(dispose)` in a detached scope and returns whatever `fn`
|
|
419
|
+
returns, having handed `fn` a single `dispose` that **cascade-disposes every effect
|
|
420
|
+
and computed created inside `fn`**. It is the lifecycle complement to `createRoot`:
|
|
421
|
+
|
|
422
|
+
- `createRoot(fn)` only **detaches** -- nodes created inside are unowned and the
|
|
423
|
+
caller must dispose each one by hand (there is no owner to do it automatically).
|
|
424
|
+
Correct for spawning one known long-lived watcher (lite-query's pattern).
|
|
425
|
+
- `createScope(fn)` **adopts** -- it owns whatever `fn` builds, so one disposer tears
|
|
426
|
+
down a subtree of *unknown* shape. This is what a per-item scope in a keyed-list or
|
|
427
|
+
scene reconciler requires, where the item's reactive graph is the consumer's
|
|
428
|
+
`mapFn`, not something the reconciler can enumerate.
|
|
429
|
+
|
|
430
|
+
**Semantics.** `fn` runs once in a detached, untracked context: no ownership and no
|
|
431
|
+
dependency leak from `fn`'s direct body into the enclosing scope, and the scope owner
|
|
432
|
+
never re-runs. Reactive bindings belong in inner effect/computed bodies inside `fn`
|
|
433
|
+
(those track normally and are owned by the scope); direct-body reads are untracked.
|
|
434
|
+
Consistent with the 1.2.0 ownership rule, **plain signals created directly in `fn` are
|
|
435
|
+
not adopted** -- dispose those explicitly (the creator holds the handle) or let them
|
|
436
|
+
fall out of reference; computeds and effects are adopted and cascade.
|
|
437
|
+
|
|
438
|
+
**Implementation.** The scope owner is backed by a never-re-running effect node, so it
|
|
439
|
+
counts as one effect in `stats()` and its disposer is the same gen-guarded, ABA-safe,
|
|
440
|
+
introspection-stamped handle `effect()` returns (`describe` / `nodeId` / `forEachOwned`
|
|
441
|
+
resolve it to the owner). No new node kind, flag, or `stats()` key -- the pinned
|
|
442
|
+
`signals + computeds + effects === activeNodes` invariant is untouched. The API
|
|
443
|
+
(`fn => dispose`) is the stable contract; a future engine may swap in a lighter
|
|
444
|
+
pure-owner node transparently.
|
|
445
|
+
|
|
446
|
+
Exported as a registry method and a top-level helper bound to the default registry,
|
|
447
|
+
mirroring `createRoot`.
|
|
448
|
+
|
|
449
|
+
### Added -- characterization harnesses (`burst-dag.mjs`, `pull-stress.mjs`)
|
|
450
|
+
|
|
451
|
+
Two root-level standalone harnesses that exercise the new 1.6.0 instrumentation
|
|
452
|
+
surface against the engine's two main hot paths. Both are engine-agnostic
|
|
453
|
+
(`./Signal.js` + public `onGraphMutation` only), both expose a CLI + module
|
|
454
|
+
exports, both stay out of `npm test` and the published tarball.
|
|
455
|
+
|
|
456
|
+
**`burst-dag.mjs`** (`npm run profile:burst`, also `node --expose-gc burst-dag.mjs
|
|
457
|
+
[--width=512 --layers=32 ...]`) reconstructs the published
|
|
458
|
+
`js-reactivity-benchmark` burst shape (sources -> width x layers, fanIn 8, burst
|
|
459
|
+
16) and characterizes lite-signal's own flush behavior. The standalone path uses
|
|
460
|
+
the new `stats().flushPasses` counter as a cross-check against the opcode-6 pass
|
|
461
|
+
count -- by construction they must match when the hook is attached for exactly
|
|
462
|
+
one burst, which the harness asserts inline. Also exports `burstDagScenario`
|
|
463
|
+
(for plugging into a steady-state allocation gate) and `multiPassProbe` (a
|
|
464
|
+
controlled two-effect write-back that forces a `passes > 1` case so the opcode
|
|
465
|
+
dispatch can be smoke-tested on an engine where multi-pass actually occurs).
|
|
466
|
+
|
|
467
|
+
**`pull-stress.mjs`** (`npm run profile:pull`, also `node --expose-gc
|
|
468
|
+
pull-stress.mjs [--maxDepth=3584 --step=512 ...]`) is the pull-path companion:
|
|
469
|
+
characterizes how the recursive pull scales with chain depth and binary-searches
|
|
470
|
+
the exact overflow point. Three answers per run: (1) the exact deepest chain
|
|
471
|
+
that pulls successfully (the roadmap's "~5,000 chained computeds" pinned to a
|
|
472
|
+
number for the current engine), (2) per-level cold cost across a depth sweep
|
|
473
|
+
(should be roughly linear; superlinear flags a per-node bookkeeping cost
|
|
474
|
+
growing with depth), and (3) cached-read cost (should be O(1) regardless of
|
|
475
|
+
depth via the 1.1.4 `markEpoch` short-circuit). Structure pass at a safe fixed
|
|
476
|
+
depth confirms the opcode triple (0 flush passes, 0 effect runs, recomputes ==
|
|
477
|
+
depth) -- the pull path is doing nothing it shouldn't. Also exports
|
|
478
|
+
`pullStressScenario` for steady-state allocation gates and `probeOverflow`
|
|
479
|
+
for the binary search alone. Both `--kind=callable` and `--kind=box` are
|
|
480
|
+
supported and surface a real engine difference (box pulls overflow earlier
|
|
481
|
+
because `box.get()` adds a prototype-method frame per level, and cached box
|
|
482
|
+
reads are several times more expensive than cached callable reads).
|
|
483
|
+
|
|
484
|
+
Both files import only `./Signal.js`, so the same harness runs against any
|
|
485
|
+
engine build: point `Signal.js` at 1.5.x to compare without the counters
|
|
486
|
+
(`burst-dag` adapts -- only opcode 5 fires on that engine -- and `pull-stress`
|
|
487
|
+
works identically), or at a rejected candidate to re-verify on. The numbers
|
|
488
|
+
they produce are reproducible, comparable, and engine-version-aware.
|
|
489
|
+
|
|
490
|
+
### Verified
|
|
491
|
+
|
|
492
|
+
- **Full suite green** against the 1.6.0 engine: 443 tests, 442 pass, 0 fail,
|
|
493
|
+
1 skip (only the architecturally-N/A SSR case in `17-reactivity`). +4
|
|
494
|
+
`createScope` tests in `test/28-scope_test.mjs`; the 1.5.0 box and createRoot
|
|
495
|
+
suites carry forward unchanged. **Coverage** (c8@11, Node 22): `Signal.js`
|
|
496
|
+
100% statements / 96.96% branches / 100% functions / 100% lines; `Watch.js`
|
|
497
|
+
100% across all four. The branch drop vs 1.5.0 (97.35% -> 96.96%) is the
|
|
498
|
+
zero-cost gate on `flushPasses` / opcode 6 / opcode 7 -- the
|
|
499
|
+
`if (mutationHook !== null)` mutation-hook-attached branch is not exercised
|
|
500
|
+
by the active test suite, which never attaches a hook; the inert path is
|
|
501
|
+
covered.
|
|
502
|
+
- **`createScope` behavior** (4 tests, `node --expose-gc`): returns `fn`'s value and
|
|
503
|
+
runs the owner exactly once even when `fn` reads signals in its direct body
|
|
504
|
+
(untracked); inner effects/computeds track and update; `dispose()` cascade-disposes
|
|
505
|
+
the owned subtree (effects + computeds) while an un-adopted signal correctly
|
|
506
|
+
survives; a disposed scope's inner effects stop firing; **a scope created inside a
|
|
507
|
+
consumer effect survives that consumer's re-run** (the reconciler-critical detach
|
|
508
|
+
property); `dispose()` is an idempotent no-op on the second call; the disposer is
|
|
509
|
+
introspection-stamped to its owner effect; and `totalAllocations - totalDisposals
|
|
510
|
+
=== activeNodes` holds after teardown. Plus a smoke confirming signal -> computed ->
|
|
511
|
+
effect is unaffected by the additive change.
|
|
512
|
+
- **Instrumentation is zero-cost when unobserved**: `flushPasses` advances and opcodes
|
|
513
|
+
6/7 fire only while a mutation-hook listener is attached; with none, the flush path
|
|
514
|
+
is unchanged from 1.5.0.
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
## [1.5.0] -- 2026-06-XX
|
|
519
|
+
|
|
520
|
+
The API-surface minor: two new **non-callable, allocation-light** reactive
|
|
521
|
+
primitives, `signalBox` and `computedBox`, land alongside the existing callable
|
|
522
|
+
`signal` / `computed`; and **`createRoot`** lands as the ownership escape hatch
|
|
523
|
+
the owner tree was designed for. They wrap the same `ReactiveNode` machinery and
|
|
524
|
+
interoperate freely in one graph -- a box can depend on a callable and vice
|
|
525
|
+
versa -- so this is an additive surface, not a second engine. Drop-in over 1.4.0:
|
|
526
|
+
the callable API, hot paths, and `stats()` shape are unchanged; the boxes are new
|
|
527
|
+
exports and the `24-signalbox` suite (staged `{skip:true}` since 1.3.0) now runs
|
|
528
|
+
and passes. The 1.3.0 eager pool default carries forward (`prealloc: "eager"`).
|
|
529
|
+
|
|
530
|
+
### Added -- `signalBox(initial, opts?)` and `computedBox(fn, opts?)`
|
|
531
|
+
|
|
532
|
+
Non-callable variants that return a plain object on a shared prototype instead of
|
|
533
|
+
a callable function:
|
|
534
|
+
|
|
535
|
+
- **`signalBox`** returns `{ get, set, peek, update, subscribe }`.
|
|
536
|
+
- **`computedBox`** returns `{ get, peek, subscribe }` (no `set` / `update` --
|
|
537
|
+
it is derived).
|
|
538
|
+
|
|
539
|
+
Both are exported as registry methods *and* as top-level helpers bound to the
|
|
540
|
+
default registry, mirroring `signal` / `computed`. The `opts.equals` custom
|
|
541
|
+
equality option is supported on both, same default (`Object.is`).
|
|
542
|
+
|
|
543
|
+
**Why a second shape.** The callable API (`count()`, `count.set(x)`) is the most
|
|
544
|
+
ergonomic surface, but constructing a callable means building a function object
|
|
545
|
+
and hanging methods/state off it. For code that creates *many* short-lived
|
|
546
|
+
reactive cells, or that wants a plain serializable-looking handle, the box trades
|
|
547
|
+
call ergonomics for cheaper construction:
|
|
548
|
+
|
|
549
|
+
- **Box creation is faster than callable** -- on this host, 10,000 `signalBox`
|
|
550
|
+
in ~10ms vs ~18ms for 10,000 callable `signal` (about 1.7x cheaper),
|
|
551
|
+
because `Object.create(proto)` is cheaper than allocating a closure with
|
|
552
|
+
attached properties.
|
|
553
|
+
- **The hot read/write path stays zero-GC** -- 200,000 box writes through a
|
|
554
|
+
256-wide graph allocate nothing and grow the pool zero times. The box is a
|
|
555
|
+
thin handle over the same pooled node; only the *handle object* differs from
|
|
556
|
+
the callable, and it is created once.
|
|
557
|
+
|
|
558
|
+
### Engineering note -- monomorphic boxes via `Object.create`, not `setPrototypeOf`
|
|
559
|
+
|
|
560
|
+
Each box is built with `Object.create(SIGNAL_BOX_PROTO)` (resp.
|
|
561
|
+
`COMPUTED_BOX_PROTO`) and then has its two own properties (`NODE_PTR`,
|
|
562
|
+
`NODE_GEN`) added in a fixed order. This is deliberate: using `setPrototypeOf`
|
|
563
|
+
on an already-constructed object transitions it to dictionary mode and forces the
|
|
564
|
+
method-call inline caches at `box.get()` / `box.set()` to megamorphic. Building on
|
|
565
|
+
the shared prototype from the start keeps every box monomorphic, so the method
|
|
566
|
+
calls stay inline-cached and fast. This is the same class of V8-closure-tax
|
|
567
|
+
avoidance the engine applies throughout; a rejected earlier prototype that used
|
|
568
|
+
`setPrototypeOf` regressed box method calls and was not shipped.
|
|
569
|
+
|
|
570
|
+
### Interop -- one graph, two handle shapes
|
|
571
|
+
|
|
572
|
+
A box and a callable handle wrap the same kind of `ReactiveNode`. Verified both
|
|
573
|
+
directions: a callable `computed` that reads `box.get()` tracks the box as a
|
|
574
|
+
dependency and updates correctly; a `computedBox` that reads a callable
|
|
575
|
+
`signal()` does the same. Glitch-freedom, batching, ownership/auto-disposal, and
|
|
576
|
+
the introspection surface all apply uniformly -- a box node is indistinguishable
|
|
577
|
+
from a callable node to the graph, the owner tree, and devtools.
|
|
578
|
+
|
|
579
|
+
### Added -- `test/24-signalbox_test.mjs` activated (9 tests)
|
|
580
|
+
|
|
581
|
+
The suite that was committed-but-skipped since 1.3.0 now runs against the real
|
|
582
|
+
implementation: box get/set/peek/update, computedBox derive + memoize,
|
|
583
|
+
peek-does-not-track, subscribe fires-and-untracks, box<->callable interop both
|
|
584
|
+
directions, batch coalescing across boxes, dispose stopping updates with
|
|
585
|
+
ABA-safety, and the `equals` short-circuit. All 9 pass.
|
|
586
|
+
|
|
587
|
+
### Added -- `createRoot(fn)` (ownership escape hatch)
|
|
588
|
+
|
|
589
|
+
`createRoot` runs `fn` in a **detached ownership scope**: effects and computeds
|
|
590
|
+
created inside `fn` are not adopted by the enclosing owner, so they survive the
|
|
591
|
+
enclosing effect's re-runs and disposal. The caller owns their lifecycle (there
|
|
592
|
+
is no parent to auto-dispose them -- `fn` typically returns a disposer or the
|
|
593
|
+
created handle). Exported as a registry method and a top-level helper, mirroring
|
|
594
|
+
`signal` / `computed` / `untrack`.
|
|
595
|
+
|
|
596
|
+
**Why it exists.** The owner tree's defining behavior is that owned children
|
|
597
|
+
dispose with their parent -- correct and intended (pinned by the cleanup-ordering
|
|
598
|
+
tests since 1.2.0). But that makes one pattern a footgun: lazily spawning a
|
|
599
|
+
*long-lived* node from *inside* a consumer effect. The spawned node is adopted by
|
|
600
|
+
the consumer, so the consumer's next re-run cascade-disposes it. This is not an
|
|
601
|
+
engine defect -- it is the ownership model working as designed -- but until now
|
|
602
|
+
there was no sanctioned way to opt a child *out* of ownership. `createRoot` is
|
|
603
|
+
that opt-out. The engine head comment has named `runWithOwner` / `createRoot` as
|
|
604
|
+
the intended future API for exactly this since the owner/observer split shipped
|
|
605
|
+
in 1.2.0 (`currentOwner` and `currentObserver` were made distinct pointers
|
|
606
|
+
precisely so ownership could be detached without affecting tracking); 1.5.0
|
|
607
|
+
delivers the first of the two.
|
|
608
|
+
|
|
609
|
+
**What it detaches.** For the duration of `fn`, both `currentOwner` and
|
|
610
|
+
`currentObserver` (and the tracking flag) are nulled, so neither ownership nor a
|
|
611
|
+
reactive dependency leaks from `fn`'s direct body into the enclosing scope. Inner
|
|
612
|
+
effect / computed bodies still establish their own owner+observer scopes as
|
|
613
|
+
usual -- only the boundary at `fn` is detached. Mirrors Solid's `createRoot` on
|
|
614
|
+
the lifecycle axis.
|
|
615
|
+
|
|
616
|
+
**Who needs it.** Any consumer that lazily creates a watcher/subscription inside
|
|
617
|
+
a reactive scope and expects it to outlive that scope -- `lite-query`'s
|
|
618
|
+
query-watcher being the first in the ecosystem. Those consumers wrap the spawn in
|
|
619
|
+
`createRoot(() => effect(...))` and dispose it themselves; the watcher then
|
|
620
|
+
survives consumer re-runs.
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
- **Full suite green** against the 1.5.0 engine: 439 tests, 438 pass, 0 fail,
|
|
624
|
+
1 skip (only the architecturally-N/A SSR case in `17-reactivity`; the 9
|
|
625
|
+
`24-signalbox` tests are now active, +6 `createRoot` tests in
|
|
626
|
+
`test/27-create-root_test.mjs`, +3 box-coverage tests). **Coverage** (c8@11,
|
|
627
|
+
Node 22): `Signal.js` 100% statements / 97.35% branches / 100% functions / 100%
|
|
628
|
+
lines; `Watch.js` 100% across all four.
|
|
629
|
+
- **Box hot path is zero-GC**: 200,000 writes through a 256-wide box graph,
|
|
630
|
+
0 heap growth, 0 pool growths after warm-up -- identical steady-state profile
|
|
631
|
+
to the callable API.
|
|
632
|
+
- **Box creation is allocation-light**: measurably cheaper construction than the
|
|
633
|
+
callable equivalent (~1.7x on this host), the design goal of the second shape.
|
|
634
|
+
- **Interop confirmed**: callable-reads-box and box-reads-callable both track and
|
|
635
|
+
update correctly in a single graph; `stats()` counts box nodes in `signals` /
|
|
636
|
+
`computeds` exactly as callable nodes.
|
|
637
|
+
- **`stats()` shape unchanged** from 1.4.0 (11 keys); boxes allocate nodes
|
|
638
|
+
through the same `createNode` path, so the 1.4.0 lifecycle counters
|
|
639
|
+
(`totalAllocations` etc.) account for box nodes automatically.
|
|
640
|
+
- **`createRoot` detaches ownership without leaking**: a watcher effect spawned
|
|
641
|
+
inside a consumer effect via `createRoot` survives the consumer's re-run (fires
|
|
642
|
+
on later dependency changes where, unwrapped, it would have been cascade-
|
|
643
|
+
disposed), and an explicit disposer on the detached effect still stops it
|
|
644
|
+
cleanly -- detachment costs no auto-cleanup but introduces no leak. Verified
|
|
645
|
+
against the exact lazy-watcher pattern `lite-query` uses.
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
## [1.4.0] -- 2026-06-XX
|
|
650
|
+
|
|
651
|
+
The observability minor: `stats()` gains **three cumulative lifecycle counters**
|
|
652
|
+
(`totalAllocations`, `totalDisposals`, `poolGrowths`) -- the surface reserved for
|
|
653
|
+
1.4.0 in the 1.2.x and 1.3.0 notes, now delivered. This is what lite-devtools /
|
|
654
|
+
lite-studio read to chart allocation rate, pool-reuse ratio, and graph churn over
|
|
655
|
+
time. Drop-in over 1.3.0 -- no hot-path change, no public callable API change; the
|
|
656
|
+
counters are bumped on existing lifecycle edges (acquire / dispose / grow) that
|
|
657
|
+
already ran, so steady-state throughput and zero-GC are unchanged. The eager pool
|
|
658
|
+
default introduced in 1.3.0 carries forward (`prealloc: "eager"`).
|
|
659
|
+
|
|
660
|
+
### Added -- cumulative lifecycle counters on `stats()`
|
|
661
|
+
|
|
662
|
+
`stats()` now returns **11 keys**: the 8 from 1.2.x/1.3.0 plus three monotonic
|
|
663
|
+
counters. They are cumulative over the registry's life and reset only by
|
|
664
|
+
`destroy()`.
|
|
665
|
+
|
|
666
|
+
- **`totalAllocations`** -- incremented on every node acquire, whether the node
|
|
667
|
+
is popped from the free list or freshly constructed during a pool-growth chunk.
|
|
668
|
+
This is the true number of nodes the registry has ever handed out, not the
|
|
669
|
+
current live count (`activeNodes` remains the live gauge).
|
|
670
|
+
- **`totalDisposals`** -- incremented on every `disposeNode`, i.e. every node
|
|
671
|
+
returned to the pool. `totalAllocations - totalDisposals` tracks the live set
|
|
672
|
+
and should equal `activeNodes` in a quiescent registry.
|
|
673
|
+
- **`poolGrowths`** -- incremented whenever a node *or* link refill chunk pushes
|
|
674
|
+
capacity past its current ledger (`maxNodes` / `maxLinks`). A nonzero value
|
|
675
|
+
after warm-up means the initial pool was undersized for the workload and the
|
|
676
|
+
registry grew at runtime -- the signal a tool uses to recommend a larger
|
|
677
|
+
`maxNodes` / `maxLinks`, or that confirms an eager pool was sized correctly
|
|
678
|
+
(stays 0).
|
|
679
|
+
|
|
680
|
+
The counters are exact, not sampled: they sit on the same `createNode` /
|
|
681
|
+
`disposeNode` / chunk-refill edges the engine already executes, so reading them
|
|
682
|
+
costs nothing and they cannot drift from the real lifecycle.
|
|
683
|
+
|
|
684
|
+
### Why these three, and what they enable
|
|
685
|
+
|
|
686
|
+
The point is *derivable* observability without the engine itself computing rates.
|
|
687
|
+
A consumer sampling `stats()` over time gets, with no extra engine work:
|
|
688
|
+
|
|
689
|
+
- **allocation rate** = delta `totalAllocations` / delta t (graph build pressure),
|
|
690
|
+
- **pool-reuse ratio** = `1 - poolGrowths * initialCapacity / totalAllocations`
|
|
691
|
+
(how much work the pool absorbed vs. how much forced growth),
|
|
692
|
+
- **approximate average lifetime** ~ `totalDisposals` / allocation rate (churn).
|
|
693
|
+
|
|
694
|
+
These are exactly the series lite-devtools 1.2 / lite-studio 1.2 plot. The engine
|
|
695
|
+
stays a measurement *source*, not a metrics framework -- consistent with the
|
|
696
|
+
zero-overhead-in-steady-state contract.
|
|
697
|
+
|
|
698
|
+
### Changed -- `destroy()` resets the counters
|
|
699
|
+
|
|
700
|
+
`destroy()` (the in-place arena reset) now also zeroes the three counters along
|
|
701
|
+
with the rest of registry state, so a reused registry reports lifecycle numbers
|
|
702
|
+
for its current epoch only. Grown pool *capacity* is retained across `destroy()`
|
|
703
|
+
as before (the reset keeps the arena warm); only the cumulative counts reset.
|
|
704
|
+
|
|
705
|
+
### Verified
|
|
706
|
+
|
|
707
|
+
- **Full suite green** against the 1.4.0 engine: 429 tests, 419 pass, 0 fail,
|
|
708
|
+
10 skip (9 signalBox-staged-for-1.5.0 plus 1 architecturally-N/A SSR skip). The eager-default and the counter additions
|
|
709
|
+
changed no existing test outcome.
|
|
710
|
+
- **Counter correctness** confirmed directly: after building a signal ->
|
|
711
|
+
computed -> effect graph, `totalAllocations` equals the node count and
|
|
712
|
+
`totalDisposals` tracks effect/computed teardown; forcing a pool past its
|
|
713
|
+
ledger under `onCapacityExceeded: "grow"` increments `poolGrowths`; an
|
|
714
|
+
eager pool sized to cover its graph keeps `poolGrowths` at 0.
|
|
715
|
+
- **Zero-GC steady state holds**: the counters bump only on acquire / dispose /
|
|
716
|
+
grow, none of which occur on the steady-state write path after warm-up. Writing
|
|
717
|
+
through a built graph allocates nothing and moves no counter.
|
|
718
|
+
- **`stats()` shape** is now the authoritative 11-key 1.4.x shape, pinned by a
|
|
719
|
+
new shape-and-initial-zeros test in `03-pool` -- the first explicit pin for
|
|
720
|
+
the `stats()` surface (the 1.2.x / 1.3.0 entries described the absence of the
|
|
721
|
+
counters in prose; 1.4.0 codifies the new shape as a test assertion).
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
## [1.3.0] -- 2026-06-XX
|
|
726
|
+
|
|
727
|
+
The pool minor: the node and link pools become **growable and incrementally
|
|
728
|
+
populated**, the propagation mark phase moves to an **intrusive linked-list
|
|
729
|
+
stack**, and a small **registry config surface** (`prealloc`,
|
|
730
|
+
`onCapacityExceeded`, `maxFlushPasses`) is exposed. Drop-in over 1.2.2 -- the
|
|
731
|
+
hot paths and public callable API are byte-identical; everything here is pool
|
|
732
|
+
mechanics, construction-time behavior, and new opt-in config. Steady-state
|
|
733
|
+
zero-GC is unchanged: after warm-up the pools recycle exactly as before.
|
|
734
|
+
|
|
735
|
+
**Default behavior: `prealloc: "eager"`.** The pools are preallocated up front
|
|
736
|
+
by default, preserving 1.2.x's deterministic-latency profile (no allocation
|
|
737
|
+
inside a hot loop or render frame -- the contract that matters for the 16ms /
|
|
738
|
+
120fps Twitch-overlay and canvas use cases this engine targets). Lazy population
|
|
739
|
+
is available as an opt-in (`prealloc: "lazy"`) for footprint-sensitive or
|
|
740
|
+
fast-cold-start consumers. See the tradeoff note under *Added -- registry config*.
|
|
741
|
+
|
|
742
|
+
### Added -- growable pools (`onCapacityExceeded: "grow"`)
|
|
743
|
+
|
|
744
|
+
The node and link pools can now grow past their initial capacity instead of
|
|
745
|
+
only throwing. Growth is **chunked and incremental**, not a single doubling
|
|
746
|
+
burst:
|
|
747
|
+
|
|
748
|
+
- **Link pool** refills in contiguous runs of up to **1024** links per
|
|
749
|
+
free-list miss; **node pool** in runs of up to **256**. This bounds any
|
|
750
|
+
single growth pause to roughly `chunk x ~0.5us` and keeps the freshly
|
|
751
|
+
constructed slots contiguous in memory (better locality than scattered
|
|
752
|
+
one-at-a-time `new`).
|
|
753
|
+
- `onCapacityExceeded` (default `"throw"`) selects the policy: `"throw"` fails
|
|
754
|
+
fast with a `CapacityError` when a pool is full (the 1.2.x behavior, now
|
|
755
|
+
named); `"grow"` extends the pool on demand. Link growth is bounded by a hard
|
|
756
|
+
ceiling of `maxLinks * 16`.
|
|
757
|
+
- The growth path **no longer length-extends the effect queues or mark stack**.
|
|
758
|
+
Previously `arr.length = newCap` permanently converted those arrays from
|
|
759
|
+
PACKED to HOLEY elements-kind -- a silent flush-path tax. They now grow by
|
|
760
|
+
sequential `arr[len++] = x` appends, which keep them packed.
|
|
761
|
+
|
|
762
|
+
### Added -- registry config surface
|
|
763
|
+
|
|
764
|
+
`createRegistry(config)` accepts three new options. All are additive and
|
|
765
|
+
non-breaking; omitting `config` reproduces 1.2.x behavior with the eager
|
|
766
|
+
default.
|
|
767
|
+
|
|
768
|
+
- **`prealloc`** (`"eager"` default | `"lazy"`). `"eager"` constructs the full
|
|
769
|
+
`maxNodes` / `maxLinks` pools up front -- deterministic latency, zero
|
|
770
|
+
allocation inside any subsequent hot path, at the cost of a larger resident
|
|
771
|
+
heap that every major GC must trace. `"lazy"` treats `maxNodes` / `maxLinks`
|
|
772
|
+
as capacity *ledgers*, constructs nodes/links on first demand, and recycles
|
|
773
|
+
through the free lists thereafter -- smaller heap, faster cold start, lighter
|
|
774
|
+
GC marking, identical zero-GC steady state after warm-up. **Choose eager for
|
|
775
|
+
hard-real-time (render loops, game ticks, extension frame budgets); choose
|
|
776
|
+
lazy for footprint-sensitive or short-lived registries.**
|
|
777
|
+
- **`onCapacityExceeded`** (`"throw"` default | `"grow"`) -- see above.
|
|
778
|
+
- **`maxFlushPasses`** (default `100`) -- cycle-protection ceiling: the maximum
|
|
779
|
+
number of effect-queue drain passes before the flush throws an `Error`
|
|
780
|
+
prefixed `"CycleError:"`. Exposes what was a fixed internal bound so
|
|
781
|
+
pathological-but-legitimate deep-cascade graphs can raise it.
|
|
782
|
+
|
|
783
|
+
### Changed -- intrusive mark stack in `markDownstream`
|
|
784
|
+
|
|
785
|
+
The propagation mark phase now walks an **iterative DFS backed by an intrusive
|
|
786
|
+
linked-list stack** (a `nextMark` field on each node) instead of a separate
|
|
787
|
+
`markStack` container array. Because `nextMark` sits adjacent to the
|
|
788
|
+
`markEpoch` field that the same sweep reads, the stack write lands in an
|
|
789
|
+
already-hot cache line. Behaviorally identical -- same nodes marked in the same
|
|
790
|
+
order, same glitch-free guarantee -- and it removes the container array's growth
|
|
791
|
+
and HOLEY-conversion concerns entirely. The mark stack never grows the JS call
|
|
792
|
+
stack regardless of graph depth (the iterative property from 1.2.4 is retained).
|
|
793
|
+
|
|
794
|
+
### Added -- `ReactiveNode.nextMark`
|
|
795
|
+
|
|
796
|
+
One field added to the node shape to back the intrusive mark stack. Initialized
|
|
797
|
+
to `null` on construction, cleared on pop during a sweep and defensively on
|
|
798
|
+
dispose, so the chain stays clean for reuse. This is the only node-shape change
|
|
799
|
+
in 1.3.0.
|
|
800
|
+
|
|
801
|
+
### Verified
|
|
802
|
+
|
|
803
|
+
- **Full suite green** against the 1.3.0 engine: 423 tests, 413 pass, 0 fail,
|
|
804
|
+
10 skip (9 `24-signalbox` tests `{skip:true}` on 1.3.x -- those primitives
|
|
805
|
+
land in 1.5.0 -- plus 1 architecturally-N/A SSR skip). The eager-default flip
|
|
806
|
+
changed no test outcome.
|
|
807
|
+
- **Behavior-preservation difftest**: 20,000 direct + 10,000 batched writes
|
|
808
|
+
against the published 1.1.5 reference, 0 disagreements. Pool growth, chunked
|
|
809
|
+
refill, and the intrusive mark stack do not alter observable propagation.
|
|
810
|
+
- **Zero-GC steady state holds**: after warm-up, writing through a built graph
|
|
811
|
+
allocates nothing and the pool does not grow (eager) / does not grow further
|
|
812
|
+
(lazy, post warm-up). Confirmed across deep-chain, wide fan-out, and batched
|
|
813
|
+
scenarios.
|
|
814
|
+
- **`stats()` shape unchanged from 1.2.x** (8 keys). The cumulative allocation
|
|
815
|
+
counters (`totalAllocations` / `totalDisposals` / `poolGrowths`) remain
|
|
816
|
+
reserved for 1.4.0 and are still absent here.
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
## [1.2.2] -- 2026-06-XX
|
|
821
|
+
|
|
822
|
+
A code-deletion ship: a `createNode` audit removes ten redundant field-writes
|
|
823
|
+
that defended against a state the engine cannot produce on a clean free-list.
|
|
824
|
+
No public surface change, no semantic change, no new tests required for new
|
|
825
|
+
behavior (because there is none) -- only an added invariant suite that pins
|
|
826
|
+
the cleanliness claim the audit relies on. Drop-in over 1.2.1.
|
|
827
|
+
|
|
828
|
+
**Version lineage note.** This is the engine previously labeled `1.2.3` in dev.
|
|
829
|
+
Renumbered to `1.2.2` to keep semver tidy: the deletion is small, isolated, and
|
|
830
|
+
intentionally non-behavioral; bumping the patch rather than the minor reflects
|
|
831
|
+
that. The upcoming `1.3.0` (lazy/chunked pool with `prealloc:"eager"` default
|
|
832
|
+
and intrusive mark stack) carries the next minor bump.
|
|
833
|
+
|
|
834
|
+
### Changed -- clean free-list invariant audit in `createNode`
|
|
835
|
+
|
|
836
|
+
Two clusters of redundant writes removed. Both rely on a single invariant:
|
|
837
|
+
**every node leaving the pool has the listed fields at their fresh-construct
|
|
838
|
+
default values** because `disposeNode` and `runCleanup` already null them and
|
|
839
|
+
the `ReactiveNode` constructor initializes them to the same values on
|
|
840
|
+
fresh-pool-growth allocation.
|
|
841
|
+
|
|
842
|
+
- **Seven graph/batch fields** no longer rewritten on every allocate:
|
|
843
|
+
`headDep`, `tailDep`, `headSub`, `tailSub`, `revertEpoch`, `preBatchValue`,
|
|
844
|
+
`preBatchVersion`. Paired-checked: `disposeNode` clears all seven on the
|
|
845
|
+
recycle path; the `ReactiveNode` constructor inits all seven to the same
|
|
846
|
+
values on the fresh-allocation path used by pool growth.
|
|
847
|
+
- **Three owner-tree fields** in the non-adoption path no longer rewritten:
|
|
848
|
+
the `firstOwned = null`, the adoption-path `prevOwned = null`, and the
|
|
849
|
+
else-branch `owner = null`. The `disposeNode` direct path nulls
|
|
850
|
+
`owner / prevOwned / nextOwned`; the `runCleanup` cascade path nulls them
|
|
851
|
+
on every disposed child and sets the parent's `firstOwned = null` at exit.
|
|
852
|
+
The constructor inits all four owner-tree fields to `null` on
|
|
853
|
+
fresh-allocation.
|
|
854
|
+
|
|
855
|
+
What `createNode` still writes are the *lifetime* writes for the new resident:
|
|
856
|
+
`value`, `flags`, `id`, and the three fields `disposeNode` does NOT touch
|
|
857
|
+
(`version`, `evalVersion`, `markEpoch` -- propagation state that must reset for
|
|
858
|
+
the new lifetime), plus the conditional owner-adoption splice
|
|
859
|
+
(`owner`, `nextOwned`, parent chain link).
|
|
860
|
+
|
|
861
|
+
### Added -- `test/10-free-list-invariant_test.mjs`
|
|
862
|
+
|
|
863
|
+
A three-test invariant suite that asserts the audit's claim by inspecting
|
|
864
|
+
freshly-allocated nodes' underlying field state (via the documented
|
|
865
|
+
`describe()` -> `NODE_PTR` surface, the same protocol devtools uses). Tests:
|
|
866
|
+
|
|
867
|
+
- Recycled slot reports null `headDep/tailDep/headSub/tailSub` and zero
|
|
868
|
+
`revertEpoch/preBatchVersion`, undefined `preBatchValue`, after disposing
|
|
869
|
+
a real signal->computed->effect graph.
|
|
870
|
+
- Recycled slot reports null `owner/prevOwned/nextOwned/firstOwned` after an
|
|
871
|
+
owner-cascade tears down a nested observer tree.
|
|
872
|
+
- Mixed-pattern churn (simple, batched-write, error-flush) leaves no dirty
|
|
873
|
+
state on the free list across 32 follow-up allocations.
|
|
874
|
+
|
|
875
|
+
If any future change reintroduces a write to a clean-state field on the
|
|
876
|
+
dispose path or removes a write that turns out NOT to be redundant, this
|
|
877
|
+
suite catches it.
|
|
878
|
+
|
|
879
|
+
### Added -- `test/11-devtools-contract_test.mjs`
|
|
880
|
+
|
|
881
|
+
A 12-test smoke probe of the introspection surface that lite-devtools 1.1 /
|
|
882
|
+
lite-studio 1.1 consume. Verifies handle resolution + walkers, owner-tree
|
|
883
|
+
walkers, the `onGraphMutation` push hook, the `observeObservers` ghost
|
|
884
|
+
contract (zero added nodes under heavy introspection), and pins the
|
|
885
|
+
authoritative 1.2.x `stats()` shape (exactly 8 keys: `signals`, `computeds`,
|
|
886
|
+
`effects`, `activeNodes`, `activeLinks`, `pooledLinks`, `nodePoolCapacity`,
|
|
887
|
+
`linkPoolCapacity`). Also pins the absence of `totalAllocations` /
|
|
888
|
+
`totalDisposals` / `poolGrowths` on 1.2.x -- those are reserved for 1.4.0 and
|
|
889
|
+
the test fails if they appear early.
|
|
890
|
+
|
|
891
|
+
### Verified
|
|
892
|
+
|
|
893
|
+
- **408 tests total: 398 pass, 10 skip, 0 fail** across the 23 active
|
|
894
|
+
suites (01-09 baseline + 11-23 introspection/ownership/perf-pin + my new
|
|
895
|
+
25 devtools-real-boot + 26 free-list-invariant). The 10 skips are 9
|
|
896
|
+
signalBox-staged-for-1.5.0 in `24-signalbox` and 1 architecturally-N/A
|
|
897
|
+
SSR case in `17-reactivity`.
|
|
898
|
+
- **Coverage on `Signal.js`: 100% statements, 98.43% branches, 100%
|
|
899
|
+
functions, 100% lines.** `Watch.js`: 100% across all four. (c8@11,
|
|
900
|
+
Node 22.) Better branch coverage than the 1.2.1 baseline documented in
|
|
901
|
+
`llms.txt` (was 98.07%); the engine path that closed the gap was a
|
|
902
|
+
targeted test of the swallow-on-self-dispose-then-throw branch in
|
|
903
|
+
`pullComputed`. The remaining ~5 unreached branches are exactly the
|
|
904
|
+
unreachable-by-construction cases already catalogued as `/* c8 ignore */`
|
|
905
|
+
candidates in `COVERAGE-NOTES.md` (cursor fast path, batch wraparound
|
|
906
|
+
sentinel, etc.).
|
|
907
|
+
- **Devtools 1.1.0 + Studio 1.1.0 contract: green.** Test
|
|
908
|
+
`25-devtools-real-boot` boots the actual `Devtools.js` against the
|
|
909
|
+
1.2.2 engine and exercises all 19 exports + the 10 symbols Studio
|
|
910
|
+
imports from Devtools. The ghost contract holds (heavy introspection
|
|
911
|
+
adds zero nodes). One real test-rig finding surfaced during this work:
|
|
912
|
+
if the engine is developed in a repo whose own `package.json` declares
|
|
913
|
+
`name: "@zakkster/lite-signal"`, importing the package by name from the
|
|
914
|
+
project root can resolve to a different module instance than imports
|
|
915
|
+
from inside a sibling `node_modules/@zakkster/lite-devtools/`,
|
|
916
|
+
fragmenting the `defaultRegistry`. This is purely a dev-loop / test-rig
|
|
917
|
+
matter (not an engine, devtools, or studio bug) -- in a real consumer
|
|
918
|
+
installation both packages live in `node_modules` and resolve once.
|
|
919
|
+
|
|
920
|
+
### Not changed
|
|
921
|
+
|
|
922
|
+
- Public API: no additions, no removals, no signature changes.
|
|
923
|
+
- Type surface: `Signal.d.ts` unchanged.
|
|
924
|
+
- Behavior: every existing test case in 01-09 passes unmodified.
|
|
925
|
+
|
|
926
|
+
### Honest notes
|
|
927
|
+
|
|
928
|
+
- **Perf**: no microbench numbers cited. Ten removed field writes per
|
|
929
|
+
`createNode` is a real saving on creation-heavy workloads, but creation
|
|
930
|
+
cost is dominated by the owner-adoption splice and the optional mutation
|
|
931
|
+
hook, not by these writes. Any "X% faster on creation" claim would need
|
|
932
|
+
to come from a per-run lite-vs-alien measurement on the project's
|
|
933
|
+
standard benchmark harness; this ship does not include one because the
|
|
934
|
+
audit is justified by correctness (clean invariant beats defensive
|
|
935
|
+
writes) rather than measured speedup.
|
|
936
|
+
- **Differential testing**: the retracking difftest harness expects two
|
|
937
|
+
engine builds (REF = prior shipped, CANDIDATE = under review). This ship
|
|
938
|
+
was validated against itself (30,000 writes, 0 disagreements), which
|
|
939
|
+
proves determinism but not 1.2.2-vs-1.2.1 behavioral equivalence --
|
|
940
|
+
equivalence is argued instead from the audit being a code-deletion of
|
|
941
|
+
writes provably-redundant under the existing pre/post-invariants, and
|
|
942
|
+
from the full 01-09 suite passing unmodified.
|
|
943
|
+
|
|
944
|
+
### Benchmarks
|
|
945
|
+
|
|
946
|
+
The audit ship does not move the curve on any benchmark -- by design;
|
|
947
|
+
the steady-state hot paths are byte-identical to 1.2.1. The bench
|
|
948
|
+
results were re-measured against 1.2.2 on the project's reference host
|
|
949
|
+
(2016 MacBook Pro, Intel, Node 22) and are published as the baseline
|
|
950
|
+
for the next version. See [`bench/results.txt`](./bench/results.txt)
|
|
951
|
+
(in-house anti-DCE harness, median-of-3 cold-process runs from
|
|
952
|
+
`bench/run-all.sh`), [`bench/resultsReactive.txt`](./bench/resultsReactive.txt)
|
|
953
|
+
(community reactive suite, 10 raw runs), and the third-party
|
|
954
|
+
[js-reactivity-benchmark](https://github.com/volynetstyle/js-reactivity-benchmark)
|
|
955
|
+
results (16 frameworks). Position on the third-party suite: **#4 of 16
|
|
956
|
+
by geomean** (2.05× vs alien-signals 1.00×), behind alien-signals,
|
|
957
|
+
reflex, and @reactively; ahead of Preact Signals (2.09×), uSignal,
|
|
958
|
+
$mol_wire, and 9 others. Outright wins on `manyEffectsFromOneSource`
|
|
959
|
+
and `manySourcesIntoOneComputedEffectWithDirect`; top-3 finishes on
|
|
960
|
+
18 of 47 tests. The version dependencies used for these numbers are
|
|
961
|
+
pinned in [`bench/package.json`](./bench/package.json) at
|
|
962
|
+
`lite-signal-bench@2.2.0`.
|
|
963
|
+
|
|
964
|
+
## [1.2.1] -- 2026-06-12
|
|
965
|
+
|
|
966
|
+
A correctness-and-pauses patch in two halves: the pool allocator stops paying
|
|
967
|
+
for growth in unbounded bursts, and the introspection surface stops lying about
|
|
968
|
+
handles the 1.2.0 owner tree disposed behind your back. Plus the graph-mutation
|
|
969
|
+
hook -- the keystone that lets lite-devtools 1.1 / lite-studio 1.1 go push-based.
|
|
970
|
+
Drop-in over 1.2.0: 404-test suite green, 177/178 on
|
|
971
|
+
johnsoncodehk/reactive-framework-test-suite (same single open cell, Inner
|
|
972
|
+
Write #179), hot-path regression gate flat on two hosts.
|
|
973
|
+
|
|
974
|
+
### Fixed -- bounded pool growth (no more construction bursts)
|
|
975
|
+
- Under `onCapacityExceeded: "grow"`, exhausting a pool used to double it by
|
|
976
|
+
synchronously constructing `currentCapacity` fresh nodes/links -- at a
|
|
977
|
+
524,288-node pool that is a quarter-million 25-field allocations in one
|
|
978
|
+
pause, in whatever frame triggered it. Growth is now incremental: **one**
|
|
979
|
+
node/link constructed per free-list miss, pushed into the pool, recycled
|
|
980
|
+
forever after. The capacity **ledger** still doubles, so `stats()`
|
|
981
|
+
(`nodePoolCapacity` / `linkPoolCapacity` / `pooledLinks`), the
|
|
982
|
+
`maxLinks × 16` ceiling, and every `CapacityError` are bit-identical to
|
|
983
|
+
1.2.0 -- only the construction schedule changed. Locked by the existing
|
|
984
|
+
`test/03-pool` capacity/ceiling/recycle contracts.
|
|
985
|
+
- Benchmark effect (volynetstyle/js-reactivity-benchmark, same host as the
|
|
986
|
+
1.2.0 baseline run): creation group 489 -> 423 ms (-13.5%), with the burst
|
|
987
|
+
cases roughly halved (`1to2` 112 -> 58, `1to8` 113 -> 55, `1to4` 81 -> 54).
|
|
988
|
+
Honest redistribution note: rows that previously *fit inside the doubling
|
|
989
|
+
overshoot* (`createDataSignals` 12.8 -> 71.9, `1to1` 17.8 -> 43.2) now pay
|
|
990
|
+
their construction inside the measured window -- 1.2.0's overshoot was an
|
|
991
|
+
accidental prefetch, and the same mechanism produced the pathological
|
|
992
|
+
bursts. Bounded pauses are the right trade for real applications; the
|
|
993
|
+
group total still improves.
|
|
994
|
+
- Steady-state hot paths are untouched (update / dynamic-retracking /
|
|
995
|
+
effect-recycle measured flat on both benchmark hosts).
|
|
996
|
+
|
|
997
|
+
### Fixed -- effect queues / mark stack stay PACKED
|
|
998
|
+
- Pool growth used to pre-size `effectQueueA/B` and the mark stack with
|
|
999
|
+
`arr.length = newCap` -- which permanently converts a PACKED V8 array to
|
|
1000
|
+
HOLEY elements, a silent tax on every subsequent flush read. The queues now
|
|
1001
|
+
grow by sequential append (packed-preserving, auto-amortised) and
|
|
1002
|
+
`destroy()` truncates instead of null-filling to capacity.
|
|
1003
|
+
|
|
1004
|
+
### Fixed -- `destroy()` iterates physical pools
|
|
1005
|
+
- `destroy()` walked `currentNodesCapacity` slots by index; with incremental
|
|
1006
|
+
growth (and any future lazy population) the ledger can exceed the physical
|
|
1007
|
+
pool. It now walks `nodePool.length` / `linkPool.length` and is safe on an
|
|
1008
|
+
empty pool.
|
|
1009
|
+
|
|
1010
|
+
### Fixed -- stale-handle introspection (the owner-tree follow-up)
|
|
1011
|
+
- 1.2.0's owner tree made the engine recycle pool slots **autonomously**: an
|
|
1012
|
+
owner re-run cascade-disposes its owned observers, so holding a stale handle
|
|
1013
|
+
stopped being a user error and became a routine occurrence. The
|
|
1014
|
+
introspection surface -- `nodeId` / `describe` / `forEachObserver` /
|
|
1015
|
+
`forEachSource` / `hasObservers` / `observeObservers` -- still resolved
|
|
1016
|
+
`NODE_PTR` without a generation check and would happily report the
|
|
1017
|
+
**recycled slot's new resident** (wrong id, wrong value, wrong edges)
|
|
1018
|
+
through an old handle. All six entry points now resolve through a
|
|
1019
|
+
gen-guarded `liveNode()` and report stale handles as `undefined` (or throw
|
|
1020
|
+
the existing `TypeError`, for `observeObservers`) -- the same ABA discipline
|
|
1021
|
+
`read()` / `set()` / `dispose()` already had.
|
|
1022
|
+
- `describe()` descriptors are now **gen-stamped** alongside the node
|
|
1023
|
+
reference, so the documented "descriptors are re-walkable handles" contract
|
|
1024
|
+
survives the guard: a fresh descriptor walks; one held across a recycle
|
|
1025
|
+
correctly goes stale. Pinned by the existing
|
|
1026
|
+
"forEach* descriptors carry id and are re-walkable" test.
|
|
1027
|
+
- **Effect dispose handles are now first-class introspection handles.** On
|
|
1028
|
+
every prior version, `effect()` returned a bare closure carrying neither
|
|
1029
|
+
`NODE_PTR` nor `NODE_GEN` -- so `describe` / `nodeId` / `forEachSource`
|
|
1030
|
+
returned `undefined`/empty for a **live** effect handle, and
|
|
1031
|
+
`observeObservers(effectHandle)` threw. The dispose function is now stamped
|
|
1032
|
+
with the same symbol pair as signal/computed handles (`NODE_GEN` mirrors the
|
|
1033
|
+
disposer's own `birthGen`, so introspection validity agrees exactly with its
|
|
1034
|
+
stale-guard). After explicit dispose, slot recycle, or owner-cascade the
|
|
1035
|
+
handle correctly reads stale. Measured cost: two property stores per effect
|
|
1036
|
+
creation (~50 ns on a create/dispose churn microbench) -- symmetric with
|
|
1037
|
+
what signal/computed handles already pay, create-path only. Found by the
|
|
1038
|
+
lite-devtools 1.1 cross-probe campaign (`track(effectHandle)` threw).
|
|
1039
|
+
- `peek()` had the same hole: `sharedSignalPeek` / `sharedComputedPeek`
|
|
1040
|
+
resolved the slot ungated, so a stale handle's `peek()` returned the new
|
|
1041
|
+
resident's value. Both now gen-check first and return `undefined` when
|
|
1042
|
+
stale -- closing the last unguarded entry point in the probe-c1 ABA family.
|
|
1043
|
+
Measured cost: 4M peeks 7.1 -> 7.4 ms (~0.08 ns/op).
|
|
1044
|
+
|
|
1045
|
+
### Added -- `onGraphMutation(fn)`: the graph-mutation hook
|
|
1046
|
+
- Registry-level (and default-registry module export) debug hook, the
|
|
1047
|
+
connection point for push-based tooling. Single nullable listener; every
|
|
1048
|
+
fire point is one `if (mutationHook !== null)` branch and the dispatch is
|
|
1049
|
+
allocation-free -- `(opcode, intA, intB)`:
|
|
1050
|
+
- `1` node create -- `(id, flags)`, end of `createNode`
|
|
1051
|
+
- `2` node dispose -- `(id, flags)`, top of `disposeNode` (cascades included)
|
|
1052
|
+
- `3` link add -- `(source.id, target.id)`
|
|
1053
|
+
- `4` link remove -- `(source.id, target.id)`
|
|
1054
|
+
- `5` recompute -- `(id, 0)`, before an effect re-run / computed re-eval
|
|
1055
|
+
- Cost: **zero when unregistered** (hot-path gate flat); registered, the
|
|
1056
|
+
worst case measured is +29% on a dynamic-retracking torture loop (11.4M
|
|
1057
|
+
events for 400K writes) -- a debug-mode tax paid only while a consumer is
|
|
1058
|
+
attached, proportional to event volume.
|
|
1059
|
+
- **Listener contract: observe only -- never throw, never mutate the graph.**
|
|
1060
|
+
The hook fires synchronously inside mutation points; lite-devtools 1.1
|
|
1061
|
+
multiplexes all of its consumers behind one registration, isolates their
|
|
1062
|
+
exceptions, and unregisters when the last consumer stops (returning the
|
|
1063
|
+
engine to the zero-cost state). `onGraphMutation` returns an unsubscribe
|
|
1064
|
+
that restores the previously registered listener.
|
|
1065
|
+
|
|
1066
|
+
### Added -- owner-tree introspection: `forEachOwned` / `ownerOf`
|
|
1067
|
+
- The 1.2.0 owner tree finally gets a (read-only, gen-guarded) window:
|
|
1068
|
+
`forEachOwned(handle, fn)` iterates a node's owned children as standard
|
|
1069
|
+
re-walkable descriptors; `ownerOf(handle)` returns the owner's descriptor
|
|
1070
|
+
or `undefined` (top-level or stale). Same descriptor conventions as
|
|
1071
|
+
`forEachObserver` / `forEachSource`; garbage input is a no-op /
|
|
1072
|
+
`undefined`. This is what lite-devtools 1.1 builds `ownerTree()` and the
|
|
1073
|
+
`graph({owners: true})` ownership edges on
|
|
1074
|
+
(`capabilities().owners === true` from this release).
|
|
1075
|
+
|
|
1076
|
+
### Compatibility
|
|
1077
|
+
- No behavioural change for live handles; stale handles now read as stale
|
|
1078
|
+
everywhere instead of as the slot's next tenant. Allocation strategy is
|
|
1079
|
+
unobservable through the public API. Tooling floor: lite-devtools >= 1.1.0
|
|
1080
|
+
detects `onGraphMutation` / `forEachOwned` at load and degrades to its
|
|
1081
|
+
1.0 polling behaviour on older engines.
|
|
1082
|
+
|
|
1083
|
+
## [1.2.0] -- 2026-06-11
|
|
1084
|
+
|
|
1085
|
+
A structural refactor that internally splits the engine into three named layers
|
|
1086
|
+
(graph topology / ownership-lifecycle / propagation-execution) with a strict
|
|
1087
|
+
dependency direction, plus a small set of additive features built on top of
|
|
1088
|
+
that split. No behavioural changes for existing code -- drop-in over 1.1.5.
|
|
1089
|
+
|
|
1090
|
+
### Added -- auto-disposal of nested observers (owner tree)
|
|
1091
|
+
- An effect or computed that creates **observers** (nested `effect`/`computed`)
|
|
1092
|
+
now owns them via an internal owner tree. When the owner re-runs or is
|
|
1093
|
+
disposed, all owned observers are cascade-disposed before the new run starts.
|
|
1094
|
+
This is what closes the long-standing "nested effects leak on re-run" hazard
|
|
1095
|
+
that other engines fix with `createRoot` wrappers.
|
|
1096
|
+
- **Plain signals are deliberately NOT owner-adopted.** Lazy-allocation
|
|
1097
|
+
wrappers (`lite-store` allocates a key's signal on first read, `lite-form`
|
|
1098
|
+
allocates lazy fields the same way) depend on a lazily-created signal
|
|
1099
|
+
surviving its allocating computed's re-runs. The rule is:
|
|
1100
|
+
*observers cascade with the owner; signals do not.* Locked in by 5 tests in
|
|
1101
|
+
`test/15-owner-lazy-alloc.test.mjs` (the lite-store cross-wire shape) and
|
|
1102
|
+
the new `test/19-v12-additions.test.mjs`.
|
|
1103
|
+
|
|
1104
|
+
### Added -- pre-batch revert (the "set X, set X back" optimisation)
|
|
1105
|
+
- Inside a `batch(...)`, if a signal is set and then set back to its
|
|
1106
|
+
pre-batch value (under the signal's own `equals`), the version bump is
|
|
1107
|
+
reverted and downstream effects/computeds do **not** fire. Eliminates a
|
|
1108
|
+
whole class of "spurious re-run from a temporary mutation" patterns common
|
|
1109
|
+
in form state and undo/redo. Verified end-to-end (signal, computed, effect)
|
|
1110
|
+
in `test/19-v12-additions.test.mjs`.
|
|
1111
|
+
|
|
1112
|
+
### Added -- multi-effect throws aggregate to `AggregateError`
|
|
1113
|
+
- When two or more effects throw in the **same flush pass**, the engine
|
|
1114
|
+
collects all errors and rethrows a native `AggregateError` at the
|
|
1115
|
+
triggering `set()` / batch boundary. A single thrown error is rethrown
|
|
1116
|
+
unwrapped (no change). Effects that don't throw still run. Cycle detection
|
|
1117
|
+
unchanged -- a flush exceeding `maxFlushPasses` (default 100) throws an
|
|
1118
|
+
`Error` prefixed `"CycleError:"`.
|
|
1119
|
+
|
|
1120
|
+
### Added -- scheduler thunk caching with gen-bound ABA guard
|
|
1121
|
+
- `effect(fn, { scheduler })` now caches the scheduler thunk on the node
|
|
1122
|
+
itself (`node.schedulerThunk`) so repeated re-schedules reuse the same
|
|
1123
|
+
closure (no allocation per re-schedule). The thunk holds a generation snapshot
|
|
1124
|
+
taken at effect creation: after `dispose()` the engine bumps the node's
|
|
1125
|
+
generation, so a stale thunk fired by an async scheduler against a recycled
|
|
1126
|
+
pool slot is a guaranteed no-op (ABA safe).
|
|
1127
|
+
|
|
1128
|
+
### Changed -- internal refactor, no behavioural difference
|
|
1129
|
+
- The engine is reorganised into three explicit layers with documented
|
|
1130
|
+
invariants (see the file header in `Signal.js`):
|
|
1131
|
+
- **L1 Graph topology** -- `allocateLink` / `freeLink` / `severTail`. Pure
|
|
1132
|
+
edge mechanics. Never touches `owner` / `firstOwned`.
|
|
1133
|
+
- **L2 Ownership/lifecycle** -- `createNode` / `disposeNode` / `runCleanup`.
|
|
1134
|
+
Owns the owner tree and user cleanup. Never touches the tracking cursor.
|
|
1135
|
+
- **L3 Propagation/execution** -- `markDownstream` (cursor-free), and the
|
|
1136
|
+
orchestrators `executeEffect` / `pullComputed` that drive the cursor
|
|
1137
|
+
(L1) and call `runCleanup` (L2) before a re-run.
|
|
1138
|
+
- `currentObserver` and `currentOwner` are now distinct pointers. Today they
|
|
1139
|
+
move together (no behavioural change), but the split paves the way for
|
|
1140
|
+
future `runWithOwner`/`createRoot` without coupling tracking and lifecycle.
|
|
1141
|
+
- **Shared `peek` (perf).** `signal()` and `computed()` now reuse a single
|
|
1142
|
+
`peek` function per registry instead of allocating a fresh closure per
|
|
1143
|
+
primitive. Equivalent across registries (each registry has its own pair).
|
|
1144
|
+
~10-14% faster signal/computed creation on the `S:create*` micros, no
|
|
1145
|
+
hot-path or behavioural change. Verified by 5 dedicated tests + the full
|
|
1146
|
+
309-strong existing suite + 30,000-write differential retracking fuzz vs
|
|
1147
|
+
the published 1.1.5.
|
|
1148
|
+
|
|
1149
|
+
### Changed -- port-forward of the 1.1.3/1.1.4 perf fixes
|
|
1150
|
+
- `pullComputed` retains the **`markEpoch` clean short-circuit** -- re-reading
|
|
1151
|
+
a computed after an unrelated source changed is O(1).
|
|
1152
|
+
- `allocateLink` retains the **O(1) `tailSub` dedup** -- divergent re-tracking
|
|
1153
|
+
remains O(N), not O(N^2). The same documented edge note applies: a nested
|
|
1154
|
+
re-read of the same source after an intervening observer can retain one
|
|
1155
|
+
duplicate link per intervening edge, bounded by the loop count and
|
|
1156
|
+
dispose-reclaimed.
|
|
1157
|
+
|
|
1158
|
+
### Fixed -- conformance regressions surfaced during release prep
|
|
1159
|
+
- **#141 (`dispose during execution then continue: no re-run`)**: an effect that
|
|
1160
|
+
called its own dispose handle mid-run and then continued to read another
|
|
1161
|
+
signal would corrupt the link-list bookkeeping in `severTail` (latent crash
|
|
1162
|
+
present in 1.1.5 too -- the v1.2 owner tree exercised the path more
|
|
1163
|
+
aggressively and made it visible). Fixed by nulling the tracking cursor in
|
|
1164
|
+
`disposeNode` when the disposed node is the active observer, plus a
|
|
1165
|
+
gen-snapshot guard in `executeEffect` / `pullComputed` so a post-body
|
|
1166
|
+
`severTail` on a recycled slot is skipped.
|
|
1167
|
+
- **#238 / #241 / #243 (cleanup ordering)**: nested effect cleanups must fire
|
|
1168
|
+
inside-out on owner-tree disposal -- grandchild before child before outer.
|
|
1169
|
+
The previous `runCleanup` ran the node's OWN cleanup before cascading, which
|
|
1170
|
+
surfaced on cascade-dispose, on owner re-run, AND on the regression path
|
|
1171
|
+
where an inner-only re-run had fired first. Fixed by swapping the order:
|
|
1172
|
+
cascade children first, then own. Matches React / Solid (children may rely
|
|
1173
|
+
on parent state being live at cleanup time; never the reverse).
|
|
1174
|
+
- Permanent regression guards for all four landed in
|
|
1175
|
+
`test/20-axis-stress.test.mjs` under "Conformance pins" (7 new tests across
|
|
1176
|
+
two suites; includes a BONUS test for the re-run cascade path which has the
|
|
1177
|
+
same invariant).
|
|
1178
|
+
|
|
1179
|
+
### Test suite (released numbers)
|
|
1180
|
+
- 363 tests / 133 suites total, all passing under `node --expose-gc --test`.
|
|
1181
|
+
- **100% line coverage** and **98.62% branch coverage** on `Signal.js`
|
|
1182
|
+
+ `Watch.js` (the few uncovered branches are defensive guards: cycle
|
|
1183
|
+
detection, batchEpoch wraparound after 2^3^2 batches, and the self-dispose
|
|
1184
|
+
`gen` branches added by the conformance fixes -- unreachable from
|
|
1185
|
+
conformance + existing user code).
|
|
1186
|
+
- New file `test/19-v12-additions.test.mjs` (24 tests) locks in shared peek,
|
|
1187
|
+
owner adoption rule, pre-batch revert, AggregateError aggregation,
|
|
1188
|
+
CycleError detection, the `maxLinks` config branch, the disposed-signal
|
|
1189
|
+
read/set behaviour, and the stop-fn ABA guard.
|
|
1190
|
+
- New file `test/20-axis-stress.test.mjs` (23 tests) -- eight orthogonal
|
|
1191
|
+
engine-invariant "axes" plus the permanent conformance pins for #141,
|
|
1192
|
+
#238, #241, #243.
|
|
1193
|
+
- Existing `test/15-owner-lazy-alloc.test.mjs` skips ("scheduler-thunk
|
|
1194
|
+
caching lands in v1.2.0") are removed -- the owner tree exists, the
|
|
1195
|
+
tests pass.
|
|
1196
|
+
- Differential retracking fuzz against the published 1.1.5: 30,000 writes,
|
|
1197
|
+
**0 disagreements** (`bench/retracking.difftest.mjs`).
|
|
1198
|
+
|
|
1199
|
+
### Notes for users
|
|
1200
|
+
- **Drop-in.** No public surface removed. Behaviour identical to 1.1.5 except
|
|
1201
|
+
for: (i) the owner-cascade auto-dispose of nested observers (was: leaked),
|
|
1202
|
+
(ii) the pre-batch revert (was: always fired even if reverted), and
|
|
1203
|
+
(iii) multi-throw aggregation. (i) and (ii) are silent wins; if you
|
|
1204
|
+
previously caught the first thrown effect in a flush, you now get an
|
|
1205
|
+
`AggregateError` whose `.errors[0]` is what you used to get.
|
|
1206
|
+
- The "scheduler-thunk caching" hint that referenced an older internal
|
|
1207
|
+
staging name (Signal-1.3.0-rc) is gone; the file is the public 1.2.0.
|
|
1208
|
+
|
|
1209
|
+
## [1.1.5] -- 2026-06-04
|
|
1210
|
+
|
|
1211
|
+
Additive release in service of `@zakkster/lite-devtools`: stable node identity on the
|
|
1212
|
+
introspection surface, so a tool can dedupe and traverse the full reactive DAG. Drop-in
|
|
1213
|
+
over 1.1.4, no breaking changes.
|
|
1214
|
+
|
|
1215
|
+
### Added -- node identity (top-level + per-registry)
|
|
1216
|
+
- `nodeId(handle)` -> the node's stable per-allocation id (`number`), or `undefined` for a
|
|
1217
|
+
non-handle. The dedupe key for graph walks.
|
|
1218
|
+
- `describe(handle)` -> the handle's own `{ id, kind, value }` descriptor, or `undefined`
|
|
1219
|
+
for a non-handle. **Re-walkable**: the descriptor may be passed back into
|
|
1220
|
+
`forEachObserver`/`forEachSource` -- the recursion primitive for full DAG discovery.
|
|
1221
|
+
- `forEachObserver`/`forEachSource` descriptors now carry `id` (`{ id, kind, value }`).
|
|
1222
|
+
- Every node gains a stable `id` assigned at allocation: one SMI write at creation, node
|
|
1223
|
+
shape kept uniform (monomorphic). **Zero steady-state cost.**
|
|
1224
|
+
|
|
1225
|
+
### Test suite
|
|
1226
|
+
- Added `test/15-identity_test.mjs`: 5 tests -- ids unique + stable, `nodeId`/`describe`
|
|
1227
|
+
undefined on non-handles, descriptor shape `{ id, kind, value }`, descriptors re-walkable,
|
|
1228
|
+
identity walks non-perturbing.
|
|
1229
|
+
|
|
1230
|
+
## [1.1.4] -- 2026-05-31
|
|
1231
|
+
|
|
1232
|
+
Combined release: a retracking rewrite that closes the two documented chaotic
|
|
1233
|
+
read-order limitations, plus an observer-lifecycle introspection surface. No
|
|
1234
|
+
breaking changes, no public-API removals -- drop-in over 1.1.3. (This release
|
|
1235
|
+
folds in the work that was internally staged as 1.1.4 and 1.1.5; it ships as a
|
|
1236
|
+
single 1.1.4.)
|
|
1237
|
+
|
|
1238
|
+
### Changed -- performance (retracking, no semantic change)
|
|
1239
|
+
- **Version-stamped O(1) reconciliation + clean-read short-circuit.** The cursor
|
|
1240
|
+
reconciliation now stamps each source per evaluation and a `markEpoch` guard
|
|
1241
|
+
short-circuits the pull when a subtree is already clean. This replaces the
|
|
1242
|
+
prior strategy's O(N)-per-dep degradation under chaotic, high-fan-in, batched
|
|
1243
|
+
read-after-write (every read re-validating its dependency subtree). Stable
|
|
1244
|
+
read order is unchanged -- still O(1) per dep via cursor reuse, still zero-alloc.
|
|
1245
|
+
- **Result.** The two rows that were the documented v1.1.x limitation flipped from
|
|
1246
|
+
multiples-behind to ahead of `alien-signals`, and are now the fastest of the five
|
|
1247
|
+
benchmarked frameworks:
|
|
1248
|
+
- `dyn: large web app` 6194ms -> **571ms** (~10.9× faster; +9% vs alien)
|
|
1249
|
+
- `dyn: wide dense` 5115ms -> **912ms** (~5.6× faster; +10% vs alien)
|
|
1250
|
+
No regressions on the other rows (steady-state update, propagation, and creation
|
|
1251
|
+
paths are within noise of 1.1.2). See `resultsReactive.txt`.
|
|
1252
|
+
- **Correctness.** The new retracking is validated by `retracking.difftest.mjs`
|
|
1253
|
+
against a reference reconciler: 20,000 direct writes and 10,000 batched writes,
|
|
1254
|
+
**0 disagreements**.
|
|
1255
|
+
|
|
1256
|
+
### Added -- observer-lifecycle introspection (top-level + per-registry)
|
|
1257
|
+
A small, zero-cost-when-unused surface for auto-pausing wrappers and devtools.
|
|
1258
|
+
All accept a public `Signal`/`Computed` handle.
|
|
1259
|
+
- **`hasObservers(handle)` -> `boolean`.** O(1) (`node.headSub !== null`). The
|
|
1260
|
+
auto-pause predicate: is anything subscribed to this source right now? A `peek`
|
|
1261
|
+
does not count.
|
|
1262
|
+
- **`observeObservers(handle, { onConnect?, onDisconnect? })` -> `unobserve`.**
|
|
1263
|
+
Fires `onConnect` on the 0->1 observer transition and `onDisconnect` on 1->0,
|
|
1264
|
+
*after* registration (transition-only -- no immediate fire if the handle is
|
|
1265
|
+
already observed). Re-tracking a persistently-read source does **not** churn
|
|
1266
|
+
connect/disconnect. This is the hook `lite-time` / `lite-raf` use to start a
|
|
1267
|
+
ticker only while a derived value is being watched.
|
|
1268
|
+
- **`forEachObserver(handle, fn)` / `forEachSource(handle, fn)`.** Walk the live
|
|
1269
|
+
graph in either direction; `fn` receives a `{ kind, value }` descriptor where
|
|
1270
|
+
`kind` is `"signal" | "computed" | "effect"`. For graph inspection (lite-devtools).
|
|
1271
|
+
- **Cost.** The hooks sit behind an internal lifecycle counter -- when no handle is
|
|
1272
|
+
being observed, the hot path adds a single branch-predicted `count !== 0` check
|
|
1273
|
+
inside link alloc/free and nothing else. Zero steady-state cost when unused.
|
|
1274
|
+
- **Error contract.** `hasObservers` / `forEachObserver` / `forEachSource` no-op
|
|
1275
|
+
on a non-handle argument; `observeObservers` throws `TypeError`.
|
|
1276
|
+
|
|
1277
|
+
### Test suite
|
|
1278
|
+
- Added `test/13-introspection_test.mjs`: 10 tests across 3 describe blocks --
|
|
1279
|
+
`hasObservers` (live observation reflects, peek doesn't count), `observeObservers`
|
|
1280
|
+
auto-pause lifecycle (start-on-first/stop-on-last, no extra connect for a 2nd
|
|
1281
|
+
observer, re-observe fires again, no churn on re-track, conditional reads toggle
|
|
1282
|
+
honestly, transition-only registration, works for computeds), and
|
|
1283
|
+
`forEachObserver`/`forEachSource` enumeration (both directions, descriptor carries
|
|
1284
|
+
kind + value).
|
|
1285
|
+
|
|
1286
|
+
### Migration from 1.1.3
|
|
1287
|
+
None required. Drop-in upgrade. No existing surface or behavior changed; the
|
|
1288
|
+
introspection functions are purely additive and the retracking change is internal.
|
|
1289
|
+
|
|
1290
|
+
## [1.1.3] -- 2026-05-28
|
|
1291
|
+
|
|
1292
|
+
Patch release: one new export, no behavior changes, no engine changes -- drop-in
|
|
1293
|
+
over 1.1.2.
|
|
1294
|
+
|
|
1295
|
+
### Added
|
|
1296
|
+
- **`isTracking()`** (top-level + per-registry). Returns `true` iff a read RIGHT
|
|
1297
|
+
NOW would record a dependency on this registry -- an observer body is on the
|
|
1298
|
+
stack AND tracking is enabled. Returns `false` inside `untrack()`, inside the
|
|
1299
|
+
callback of `signal.subscribe` (which inlines the same untracked-notify), inside
|
|
1300
|
+
`onCleanup` bodies, inside the `watch` / `when` callback path, and outside any
|
|
1301
|
+
observer. The predicate mirrors the engine's own read-trap check
|
|
1302
|
+
(`isTrackingDeps && currentObserver !== null`) so callers stay in lockstep with
|
|
1303
|
+
what the engine actually does on a read, not just whether an observer is on the
|
|
1304
|
+
stack.
|
|
1305
|
+
|
|
1306
|
+
### Why
|
|
1307
|
+
Wrapper libraries (lite-store, lite-query, lite-form) need to allocate reactive
|
|
1308
|
+
primitives lazily on property reads to preserve the zero-GC contract. Without a
|
|
1309
|
+
predicate they must either always allocate (defeats the point) or inspect engine
|
|
1310
|
+
internals (fragile coupling). `isTracking()` is the first-class way to gate
|
|
1311
|
+
allocation on whether the read will actually subscribe anything.
|
|
1312
|
+
|
|
1313
|
+
### API notes
|
|
1314
|
+
- **Per-registry.** A wrapper operating against a non-default registry MUST call
|
|
1315
|
+
THAT registry's `isTracking()`, not the top-level one -- each registry has its
|
|
1316
|
+
own tracking state. The top-level helper delegates to the default registry,
|
|
1317
|
+
matching the existing pattern for `signal`/`computed`/`effect`/`untrack`.
|
|
1318
|
+
- **Cost.** Two closure-variable loads, one AND, one return; V8 inlines it.
|
|
1319
|
+
Roughly 1-2 ns per call.
|
|
1320
|
+
|
|
1321
|
+
### Test suite
|
|
1322
|
+
- Added `test/10-is-tracking_test.mjs`: 11 tests across 5 describe blocks --
|
|
1323
|
+
observer-bodies (effect + computed), untracked windows (`untrack`, `subscribe`
|
|
1324
|
+
callback, `onCleanup`, `watch` callback), outside-observer (module scope,
|
|
1325
|
+
call-site of unobserved computed read), robustness (state restored after
|
|
1326
|
+
observer body throws, per-registry isolation), and the top-level binding.
|
|
1327
|
+
|
|
1328
|
+
### Migration from 1.1.2
|
|
1329
|
+
None required. Drop-in upgrade. No existing surface or behavior changed.
|
|
1330
|
+
|
|
1331
|
+
## [1.1.2] -- 2026-05-26
|
|
1332
|
+
|
|
1333
|
+
Patch release: hot-path micro-optimizations and a zero-allocation cleanup of
|
|
1334
|
+
the creation path. No behavior changes, no API changes -- drop-in over 1.1.1.
|
|
1335
|
+
|
|
1336
|
+
### Changed -- performance (no semantic change)
|
|
1337
|
+
- **Inlined cursor fast-path in `signal()`/`computed()` reads.** On stable read
|
|
1338
|
+
order the cursor match is now handled inline; only a cursor *miss* falls
|
|
1339
|
+
through into the (large, non-inlinable) `allocateLink` frame. Removes a
|
|
1340
|
+
function call from the steady-state read hot path.
|
|
1341
|
+
- **Allocation-free creation.** `signal`/`computed`/`effect` now read their
|
|
1342
|
+
`opts` argument defensively instead of defaulting the parameter to `{}`. The
|
|
1343
|
+
`= {}` default allocated a throwaway object on every no-opts call -- the common
|
|
1344
|
+
path when mounting many cells. Creation is now zero-allocation on that path.
|
|
1345
|
+
- **Single-closure `subscribe`.** The tracked read + untracked notify is inlined
|
|
1346
|
+
(one closure instead of two), dropping a per-subscription closure and an
|
|
1347
|
+
`untrack` wrapper call on every fire.
|
|
1348
|
+
- **`markDownstream` micro-cleanup.** Combined `(FLAG_QUEUED | FLAG_COMPUTING)`
|
|
1349
|
+
test and tightened stack/queue index arithmetic. The `flags` read stays inside
|
|
1350
|
+
the `markEpoch` dedup guard on purpose (hoisting it would add work on the
|
|
1351
|
+
already-marked revisit path that the guard exists to keep cheap).
|
|
1352
|
+
|
|
1353
|
+
### Changed -- packaging
|
|
1354
|
+
- Canonical single-engine layout: the implementation is `Signal.js` and the
|
|
1355
|
+
watcher utilities are `Watch.js`, which imports `effect`/`untrack` from
|
|
1356
|
+
`./Signal.js`. Both the public entry and `Watch.js` resolve to one engine
|
|
1357
|
+
instance -- eliminating any chance of a duplicate-module-instance split that
|
|
1358
|
+
would silently break cross-module dependency tracking.
|
|
1359
|
+
|
|
1360
|
+
### Test suite
|
|
1361
|
+
- `tests/09-conformance.test.mjs`: the owner-tree conformance items **#209** and
|
|
1362
|
+
**#210** (three-level cascading disposal; inner-effect cleanup on outer re-run)
|
|
1363
|
+
are marked skipped with a v1.2 pointer. The baseline engine maintains no owner
|
|
1364
|
+
tree; these are validated against the v1.2 ownership hybrid. All other
|
|
1365
|
+
conformance items pass.
|
|
1366
|
+
|
|
1367
|
+
### Performance
|
|
1368
|
+
- Steady-state hot path remains **0 allocations** (`signal.set`, `peek`, computed
|
|
1369
|
+
read, effect re-run, dispose). Creation path now also 0-allocation on the
|
|
1370
|
+
no-opts common case. Re-run `npm run bench` on your target host for current
|
|
1371
|
+
ops/s; the 1.1.1 numbers stand as a floor.
|
|
1372
|
+
|
|
1373
|
+
### Migration from 1.1.x
|
|
1374
|
+
None required. Drop-in upgrade.
|
|
1375
|
+
|
|
1376
|
+
## [1.1.1] -- 2026-05-22
|
|
1377
|
+
|
|
1378
|
+
Patch release: cleanup-semantics adapter integration, conformance fixes from
|
|
1379
|
+
the `johnsoncodehk/reactive-framework-test-suite`, and one targeted
|
|
1380
|
+
correctness bug in flush error reporting.
|
|
1381
|
+
|
|
1382
|
+
### Added
|
|
1383
|
+
- Top-level `destroy()` export. Wipes the default registry; intended for
|
|
1384
|
+
test-suite isolation only. Previously the function existed but was not
|
|
1385
|
+
re-exported from the package entrypoint, breaking any adapter that
|
|
1386
|
+
destructure-imports it.
|
|
1387
|
+
- `tailSub` field on `ReactiveNode`. Symmetric with the existing `tailDep`;
|
|
1388
|
+
enables O(1) tail insertion into the subscriber list.
|
|
1389
|
+
|
|
1390
|
+
### Changed -- conformance fixes
|
|
1391
|
+
|
|
1392
|
+
- **#216** Effects now fire in **creation order** on a shared signal.
|
|
1393
|
+
Subscriber list insertion is tail-first instead of head-first; traversal
|
|
1394
|
+
order in `markDownstream` is unchanged. Brings lite-signal in line with
|
|
1395
|
+
every other library in the suite except solid-js and pota.
|
|
1396
|
+
|
|
1397
|
+
- **#178** `runCleanup` invokes registered cleanups in an **untracked
|
|
1398
|
+
context** (`currentObserver = null`, `isTrackingDeps = false`). Reads
|
|
1399
|
+
inside a cleanup body -- including reads triggered by a synchronous
|
|
1400
|
+
`dispose()` from a containing effect -- no longer leak into the parent
|
|
1401
|
+
observer's dep set.
|
|
1402
|
+
|
|
1403
|
+
- **#111** `executeEffect` bails cleanly when a node is disposed by its own
|
|
1404
|
+
cleanup. Previously the post-cleanup body invocation hit `undefined()` on
|
|
1405
|
+
the cleared `computeFn`.
|
|
1406
|
+
|
|
1407
|
+
- **#123 / #132 / #147** **Revert detection in batches.** A signal whose
|
|
1408
|
+
in-batch write sequence ends at the pre-batch value (per its `equals`
|
|
1409
|
+
predicate) restores its `version` and skips propagation. Captures are
|
|
1410
|
+
scoped per top-level batch via a `revertEpoch` counter; the `0` sentinel
|
|
1411
|
+
is preserved through SMI wraparound by skipping it on increment.
|
|
1412
|
+
|
|
1413
|
+
- **#121** **Throw isolation in flush.** Effects that throw during
|
|
1414
|
+
`flushEffects` no longer halt the flush. Errors are collected in a
|
|
1415
|
+
reused per-registry buffer; on flush completion, a single thrown error
|
|
1416
|
+
re-raises as-is, multiple throws raise as `AggregateError`. `isFlushing`
|
|
1417
|
+
is now cleared in a `try/finally`, eliminating the registry-deadlock
|
|
1418
|
+
that the prior throw-out path would leave behind.
|
|
1419
|
+
|
|
1420
|
+
- **#180 / #213** **No-re-run semantics for self-cycles.** An effect that
|
|
1421
|
+
is currently executing on the call stack is no longer re-queued by
|
|
1422
|
+
`markDownstream` when its own body's writes propagate back through a
|
|
1423
|
+
computed chain. Matches S.js / pre-2.0 Solid. Sibling effects on the
|
|
1424
|
+
same chain continue to fire normally.
|
|
1425
|
+
|
|
1426
|
+
### Fixed
|
|
1427
|
+
- Flush error buffer no longer leaks across calls when a `CycleError`
|
|
1428
|
+
escapes the flush loop. Buffered effect errors are cleared in the
|
|
1429
|
+
outer `finally` if the flush is exiting abnormally.
|
|
1430
|
+
|
|
1431
|
+
### Performance
|
|
1432
|
+
- No regressions observed in MUX, BROADCAST, DEEP CHAIN, KAIROS, or
|
|
1433
|
+
SELECTIVE DAG benchmarks. MUX moved from 156K to 226K ops/s -- V8 appears
|
|
1434
|
+
to optimise the flush loop more aggressively now that the per-iteration
|
|
1435
|
+
`try/catch` shape is stable. Out-of-batch `signal.set` is unchanged
|
|
1436
|
+
(revert-detection guards short-circuit on `batchDepth === 0`).
|
|
1437
|
+
|
|
1438
|
+
### Conformance score
|
|
1439
|
+
- Before 1.1.1: 145 / 156 (with v1.1.0 adapter pre-fix), 164 / 177
|
|
1440
|
+
(corrected adapter, no library fixes).
|
|
1441
|
+
- After 1.1.1: TBD pending full conformance re-run. Expected: all
|
|
1442
|
+
Tier 1 + Tier 2 items closed (#216, #178, #111, #123, #132, #147, #121,
|
|
1443
|
+
#180, #213, #235), leaving `#179`, `#209`, `#210` deferred to v1.2
|
|
1444
|
+
(owner-tree / computed-self-write).
|
|
1445
|
+
|
|
1446
|
+
### Internal test suite
|
|
1447
|
+
- Added `tests/09-conformance.test.mjs` collecting the upstream test IDs
|
|
1448
|
+
by number, with companion tests pinning the design decisions
|
|
1449
|
+
(sibling-effect propagation under no-re-run, cycle precedence over
|
|
1450
|
+
buffered errors, custom-equals revert, etc.).
|
|
1451
|
+
|
|
1452
|
+
## [1.1.0] -- 2026-05-20
|
|
1453
|
+
|
|
1454
|
+
### Added
|
|
1455
|
+
- `markDownstream` iterative DFS marker backed by preallocated `markStack` -- propagation no longer grows the JS call stack regardless of graph depth.
|
|
1456
|
+
- Double-buffered effect queue (`effectQueueA` / `effectQueueB`) -- effects scheduled mid-flush land in the next pass, no recursive flush.
|
|
1457
|
+
- Generation counter (`gen`) per node -- stale handles after dispose+recycle silently no-op instead of corrupting the pool.
|
|
1458
|
+
- `CapacityError` with `kind` (`"nodes"` | `"links"`) and `capacity` fields, thrown when the `"throw"` policy is set and a pool is exhausted.
|
|
1459
|
+
- `createRegistry({ onCapacityExceeded: "grow" })` -- opt-in unbounded pool growth, bounded by `maxLinks * 16` ceiling.
|
|
1460
|
+
- `createRegistry({ maxFlushPasses })` -- configurable cycle-protection limit (default `100`).
|
|
1461
|
+
- `destroy()` -- full registry reset; all prior handles silently no-op afterward.
|
|
1462
|
+
- `watch(source, callback, { immediate? })`, `when(predicate, callback)`, `whenAsync(predicate)` -- re-exported from `Watch.js`. Zero-allocation hot paths in `watch` and `when`; `whenAsync` allocates one Promise per call (documented; not for per-frame use).
|
|
1463
|
+
|
|
1464
|
+
### Changed
|
|
1465
|
+
- 32-bit modular epoch arithmetic across `globalVersion`, `evalVersion`, `markEpoch`. Engine survives indefinite uptime without integer-overflow risk.
|
|
1466
|
+
- `dispose(api)` is now universal across signals, computeds, effect handles, and `.subscribe()` return values. Cross-registry calls are silent no-ops. Foreign reactive primitives are duck-typed (on `.peek`) and not invoked.
|
|
1467
|
+
- `untrack(fn)` restores prior tracking state via `try / finally` -- safe under thrown errors inside `fn`.
|
|
1468
|
+
- `onCleanup(fn)` now accepts multiple registrations per scope and works in computeds, not just effects. Stored as a single function or upgraded to an array.
|
|
1469
|
+
|
|
1470
|
+
### Fixed
|
|
1471
|
+
- Diamond dependency reads no longer over-fire effects (versioned pull resolves convergence cleanly in one pass).
|
|
1472
|
+
- Effect re-runs no longer leak link slots when the dep set shrinks (tail-link severance in `severTail`).
|
|
1473
|
+
- Disposed-then-recycled slots no longer mis-dispose under stale handles (generation guard in `dispose`).
|
|
1474
|
+
- Cleanup functions registered inside computeds now fire (previously effect-only).
|
|
1475
|
+
|
|
1476
|
+
### Performance
|
|
1477
|
+
- Steady-state hot path: **0 allocations** across `signal.set`, `signal.peek`, computed read, effect re-run, dispose.
|
|
1478
|
+
- **249K ops/s** on MUX fan-in (Node 22, 2016 MacBook Pro). +20% vs alien-signals on identical workload.
|
|
1479
|
+
- **15 KB** transient heap across 20,000 iterations.
|
|
1480
|
+
- Full methodology and reproducibility recipe in [`bench/README.md`](./bench/README.md).
|
|
1481
|
+
|
|
1482
|
+
### Known limitations
|
|
1483
|
+
- Dependency reconciliation is O(1) per read on stable read order; degrades to O(N) under chaotic read order. v1.2 (in benchmark validation) replaces the cursor-based retracking with per-source version-stamped reconciliation -- see [RFC #N1](https://github.com/PeshoVurtoleta/lite-signal/issues/1).
|
|
1484
|
+
- Computed resolution is recursive on the JS call stack; bounded by the engine stack limit (~10,000 frames).
|
|
1485
|
+
- `whenAsync` allocates one Promise per call. Use `when` (callback form) for per-frame paths.
|
|
1486
|
+
|
|
1487
|
+
### Migration from 1.0.x
|
|
1488
|
+
None required. Drop-in upgrade.
|
|
1489
|
+
|
|
1490
|
+
## [1.0.0] -- 2026-05-12
|
|
1491
|
+
Initial public release.
|