@zakkster/lite-signal 1.5.0-beta.4 → 1.6.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +273 -136
- package/README.md +94 -33
- package/Signal.d.ts +31 -2
- package/Signal.js +142 -28
- package/llms.txt +146 -87
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,250 @@ All notable changes to `@zakkster/lite-signal` are documented here.
|
|
|
4
4
|
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
5
|
This project follows [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
-
## [
|
|
7
|
+
## [1.6.0-alpha.0] -- 2026-07-XX
|
|
8
|
+
|
|
9
|
+
The observability-and-lifecycle minor, shipping on the `alpha` dist-tag while it
|
|
10
|
+
settles. Three additions: `stats()` gains a twelfth key, **`flushPasses`**, plus two
|
|
11
|
+
flush-profiling mutation-hook opcodes -- the flush/recompute dimension
|
|
12
|
+
lite-devtools 1.2 / lite-studio 1.2 read through `watchAllocations`;
|
|
13
|
+
**`createScope(fn)`**, the disposable-owner counterpart to
|
|
14
|
+
`createRoot` that a keyed-list / scene reconciler needs for per-item teardown;
|
|
15
|
+
and **`getOwner` / `runWithOwner`** carried forward from 1.5.0-beta.2 as the
|
|
16
|
+
capture-and-restore companion to `createRoot`. The engine hot path is **no
|
|
17
|
+
longer byte-identical to 1.5** for the first time since 1.2.2 -- `markDownstream`
|
|
18
|
+
and `flushEffects` picked up hook-gated fires for the two new opcodes -- but
|
|
19
|
+
the gate is a single branch-predicted `null` check per fire site and the
|
|
20
|
+
observable cost only shows on the cheapest propagation shapes (KAIROS, DEEP
|
|
21
|
+
CHAIN); the wide-aggregation and dynamic-DAG wins are unchanged. Drop-in over
|
|
22
|
+
1.5.1-beta.1.
|
|
23
|
+
|
|
24
|
+
### Added -- `flushPasses` on `stats()` + flush-profiling opcodes
|
|
25
|
+
|
|
26
|
+
`stats()` now returns **12 keys**: the 11 from 1.4.x plus `flushPasses`, a counter
|
|
27
|
+
that advances once per effect-flush drain pass. Two `onGraphMutation` opcodes back
|
|
28
|
+
the flush dimension:
|
|
29
|
+
|
|
30
|
+
- **`6` flush pass** -- `(passCount, effectsToRun)`, at the top of each drain pass.
|
|
31
|
+
- **`7` effect run in pass** -- `(id, 0)`, before each effect re-run inside a pass.
|
|
32
|
+
|
|
33
|
+
Both the counter bump and the opcode dispatch sit behind the existing
|
|
34
|
+
`if (mutationHook !== null)` gate, so when no profiler is attached they are inert:
|
|
35
|
+
`flushPasses` is frozen and the flush loop is byte-identical to 1.5.0 EXCEPT for
|
|
36
|
+
the added `null` check itself. The residual cost is one branch-predicted `null`
|
|
37
|
+
check per fire site (per pass in `flushEffects`, per enqueued dirty subscriber
|
|
38
|
+
in `markDownstream`'s inner loop). Measurable on the very cheapest propagation
|
|
39
|
+
shapes where every iteration matters -- KAIROS moves from -7% -> -12% vs alien
|
|
40
|
+
on the 1.6.0-alpha sweep, DEEP CHAIN from -14% -> -21% -- and invisible on the
|
|
41
|
+
allocation-dominated shapes where the ratio of pool retracking to marker walks
|
|
42
|
+
favors lite by orders of magnitude (SELECTIVE DAG +49%, DYNAMIC DAG +43%, MUX
|
|
43
|
+
+35%, SMALL SELECTIVE +29% -- all unchanged from the 1.5.0-beta sweep). When a
|
|
44
|
+
profiler is actually attached the observable becomes the profiler's own cost and
|
|
45
|
+
the gate itself disappears from the picture. This is what lets `watchAllocations`
|
|
46
|
+
chart recompute/flush activity alongside the 1.4.0 allocation counters
|
|
47
|
+
(`totalAllocations` / `poolGrowths` / `totalDisposals`), which remain available
|
|
48
|
+
from 1.4.0 on every engine -- only the flush series requires 1.6.
|
|
49
|
+
|
|
50
|
+
The `03-pool` test for the `stats()` shape is bumped from "11-key 1.4.0 shape"
|
|
51
|
+
to "12-key 1.6 shape" with `flushPasses` in the expected key list.
|
|
52
|
+
|
|
53
|
+
### Added -- `createScope(fn)` (disposable owner scope)
|
|
54
|
+
|
|
55
|
+
`createScope` runs `fn(dispose)` in a detached scope and returns whatever `fn`
|
|
56
|
+
returns, having handed `fn` a single `dispose` that **cascade-disposes every effect
|
|
57
|
+
and computed created inside `fn`**. It is the lifecycle complement to `createRoot`:
|
|
58
|
+
|
|
59
|
+
- `createRoot(fn)` only **detaches** -- nodes created inside are unowned and the
|
|
60
|
+
caller must dispose each one by hand (there is no owner to do it automatically).
|
|
61
|
+
Correct for spawning one known long-lived watcher (lite-query's pattern).
|
|
62
|
+
- `createScope(fn)` **adopts** -- it owns whatever `fn` builds, so one disposer tears
|
|
63
|
+
down a subtree of *unknown* shape. This is what a per-item scope in a keyed-list or
|
|
64
|
+
scene reconciler requires, where the item's reactive graph is the consumer's
|
|
65
|
+
`mapFn`, not something the reconciler can enumerate.
|
|
66
|
+
|
|
67
|
+
**Semantics.** `fn` runs once in a detached, untracked context: no ownership and no
|
|
68
|
+
dependency leak from `fn`'s direct body into the enclosing scope, and the scope owner
|
|
69
|
+
never re-runs. Reactive bindings belong in inner effect/computed bodies inside `fn`
|
|
70
|
+
(those track normally and are owned by the scope); direct-body reads are untracked.
|
|
71
|
+
Consistent with the 1.2.0 ownership rule, **plain signals created directly in `fn` are
|
|
72
|
+
not adopted** -- dispose those explicitly (the creator holds the handle) or let them
|
|
73
|
+
fall out of reference; computeds and effects are adopted and cascade.
|
|
74
|
+
|
|
75
|
+
**Implementation.** The scope owner is backed by a never-re-running effect node, so it
|
|
76
|
+
counts as one effect in `stats()` and its disposer is the same gen-guarded, ABA-safe,
|
|
77
|
+
introspection-stamped handle `effect()` returns (`describe` / `nodeId` / `forEachOwned`
|
|
78
|
+
resolve it to the owner). No new node kind, flag, or `stats()` key -- the pinned
|
|
79
|
+
`signals + computeds + effects === activeNodes` invariant is untouched. The API
|
|
80
|
+
(`fn => dispose`) is the stable contract; a future engine may swap in a lighter
|
|
81
|
+
pure-owner node transparently.
|
|
82
|
+
|
|
83
|
+
Exported as a registry method and a top-level helper bound to the default registry,
|
|
84
|
+
mirroring `createRoot`.
|
|
85
|
+
|
|
86
|
+
### Added -- `getOwner` / `runWithOwner` (carried forward from 1.5.0-beta.2)
|
|
87
|
+
|
|
88
|
+
The re-attach companion to `createRoot`, ported forward from 1.5.0-beta.2
|
|
89
|
+
unchanged. `getOwner()` returns the current owner as an **opaque, gen-stamped
|
|
90
|
+
handle** (or `undefined` outside any effect/computed body); `runWithOwner(handle,
|
|
91
|
+
fn)` runs `fn` with the captured lifecycle scope reinstated so effects/computeds
|
|
92
|
+
created directly in `fn` are adopted by that owner. Nulls the tracking observer
|
|
93
|
+
for the duration of `fn` (same pairing as `createRoot`) so accidental cross-async
|
|
94
|
+
edges cannot form.
|
|
95
|
+
|
|
96
|
+
Handles are gen-stamped (the same `NODE_GEN` ABA-guard machinery
|
|
97
|
+
`describe` / `nodeId` / `forEachOwned` / `ownerOf` have used since 1.2.1) --
|
|
98
|
+
safe to hold across async boundaries. If the captured owner is disposed and
|
|
99
|
+
its pool slot recycled by an unrelated effect via the LIFO free list, the gen
|
|
100
|
+
no longer matches and `runWithOwner` degrades to **rooted execution** rather
|
|
101
|
+
than corrupting the graph. Two hazards on the raw-pointer alternative were
|
|
102
|
+
empirically reproduced against a 1.5.0-beta engine patched with the naive
|
|
103
|
+
implementation (`harness/owner-hazard-repro.mjs`) and are pinned in
|
|
104
|
+
`test/28-run-with-owner.test.mjs`:
|
|
105
|
+
|
|
106
|
+
- **Recycled-slot cascade death** -- capture, dispose owner, allocate a stranger
|
|
107
|
+
effect that reuses the slot, `runWithOwner(captured)` silently adopts
|
|
108
|
+
continuation into the stranger, stranger's re-run cascade-disposes it.
|
|
109
|
+
- **Corpse adoption = engine crash** -- capture, dispose owner but not-yet-
|
|
110
|
+
recycled, `runWithOwner(captured, () => effect(...))` splices a child into
|
|
111
|
+
a disposed owner's `firstOwned` and the next disposal walk recurses without
|
|
112
|
+
termination (`RangeError: Maximum call stack size exceeded`).
|
|
113
|
+
|
|
114
|
+
Both fail on the raw-pointer sketch; both pass on the shipped `describeNode` /
|
|
115
|
+
`liveNode` implementation. Test coverage: 16 tests in `test/28-run-with-owner`
|
|
116
|
+
(basic shape, degradation, and the three hazard pins with allocation pressure
|
|
117
|
+
applied so the ABA guard is genuinely exercised).
|
|
118
|
+
|
|
119
|
+
Exported as registry methods and top-level helpers, mirroring `createRoot` /
|
|
120
|
+
`createScope`.
|
|
121
|
+
|
|
122
|
+
### Added -- characterization harnesses (`burst-dag.mjs`, `pull-stress.mjs`)
|
|
123
|
+
|
|
124
|
+
Two standalone harnesses in `harness/` that exercise the new 1.6.0 instrumentation
|
|
125
|
+
surface against the engine's hot paths, both consuming public `onGraphMutation`
|
|
126
|
+
(opcodes 5/6/7) and both staying out of `npm test` and the published tarball.
|
|
127
|
+
`pull-stress.mjs` imports `../Signal.js` and exposes a CLI + module exports;
|
|
128
|
+
`burst-dag.mjs` takes the engine path as an argument and is CLI-only.
|
|
129
|
+
|
|
130
|
+
**`burst-dag.mjs`** (`npm run profile:burst`, also `node --expose-gc
|
|
131
|
+
harness/burst-dag.mjs <Signal.js>`) reproduces Andrii's actual generator: the
|
|
132
|
+
layer edges use his **verbatim strided picker** (`base = (node*13 + layer*17) %
|
|
133
|
+
prevW`, strided step), `staticFraction = 1` (all-static computeds, per-batch pull
|
|
134
|
+
reads, no effects) -- the real `layered burst flush warm` shape. It runs that
|
|
135
|
+
head-to-head against the earlier contiguous-window guess it embeds and reports
|
|
136
|
+
structure (passes/burst, recomputed, maxRecompute/node, poolGrowths) plus median
|
|
137
|
+
us/burst for each. On 1.6.0-alpha the strided real topology recomputes ~2x the
|
|
138
|
+
nodes (15928 vs 8120) at ~26% higher us/burst, both with `passes = 0` (pure pull,
|
|
139
|
+
nothing to flush) and `maxRecompute/node = 1`: no redundant work either way, so
|
|
140
|
+
the ~2x gap is **locality** on the correct topology. This resolves the ROADMAP S5
|
|
141
|
+
open question (was the contiguous guess faithful to Andrii's generator?). The
|
|
142
|
+
earlier contiguous version -- with its `--width` / `--layers` CLI and its
|
|
143
|
+
`burstDagScenario` / `multiPassProbe` exports for the zero-GC gate -- is archived
|
|
144
|
+
as `harness/attic/burst-dag.mjs`; nothing mounted those exports, so retiring it
|
|
145
|
+
is inert.
|
|
146
|
+
|
|
147
|
+
**`pull-stress.mjs`** (`npm run profile:pull`, also `node --expose-gc
|
|
148
|
+
harness/pull-stress.mjs [--maxDepth=3584 --step=512 ...]`) is the pull-path companion:
|
|
149
|
+
characterizes how the recursive pull scales with chain depth and binary-searches
|
|
150
|
+
the exact overflow point. Three answers per run: (1) the exact deepest chain
|
|
151
|
+
that pulls successfully (the roadmap's "~5,000 chained computeds" pinned to a
|
|
152
|
+
number for the current engine), (2) per-level cold cost across a depth sweep
|
|
153
|
+
(should be roughly linear; superlinear flags a per-node bookkeeping cost
|
|
154
|
+
growing with depth), and (3) cached-read cost (should be O(1) regardless of
|
|
155
|
+
depth via the 1.1.4 `markEpoch` short-circuit). Structure pass at a safe fixed
|
|
156
|
+
depth confirms the opcode triple (0 flush passes, 0 effect runs, recomputes ==
|
|
157
|
+
depth) -- the pull path is doing nothing it shouldn't. Also exports
|
|
158
|
+
`pullStressScenario` for steady-state allocation gates and `probeOverflow`
|
|
159
|
+
for the binary search alone. Both `--kind=callable` and `--kind=box` are
|
|
160
|
+
supported and surface a real engine difference (box pulls overflow earlier
|
|
161
|
+
because `box.get()` adds a prototype-method frame per level, and cached box
|
|
162
|
+
reads are several times more expensive than cached callable reads).
|
|
163
|
+
|
|
164
|
+
`pull-stress` imports only `../Signal.js`, and `burst-dag` takes the engine path
|
|
165
|
+
as an argument, so both run against any engine build: point them at 1.5.x to
|
|
166
|
+
compare without the new counters (`burst-dag` adapts -- only opcode 5 fires on
|
|
167
|
+
that engine, so `passes` reads 0 -- and `pull-stress` works identically), or at a
|
|
168
|
+
rejected candidate to re-verify on. The numbers they produce are reproducible,
|
|
169
|
+
comparable, and engine-version-aware.
|
|
8
170
|
|
|
9
|
-
###
|
|
171
|
+
### Verified
|
|
172
|
+
|
|
173
|
+
- **Full suite green** against the 1.6.0-alpha engine (getOwner + runWithOwner
|
|
174
|
+
merged in from 1.5.0-beta.2): **447 tests**, 436 pass, 0 fail, 1 skip
|
|
175
|
+
(only the architecturally-N/A SSR case in `17-reactivity`), 10 cancelled
|
|
176
|
+
(the `25-devtools-real-boot` cases that need `@zakkster/lite-devtools`
|
|
177
|
+
installed as a peer -- pre-existing, unrelated to any 1.6 change). +4
|
|
178
|
+
`createScope` tests in `test/28-scope_test.mjs`; +16 `getOwner` /
|
|
179
|
+
`runWithOwner` tests in `test/28-run-with-owner.test.mjs` (basic shape,
|
|
180
|
+
degradation, and the three hazard pins -- recycled-slot cascade / corpse
|
|
181
|
+
adoption / composed with allocation pressure); the 1.5.0 box and createRoot
|
|
182
|
+
suites carry forward unchanged. `test/03-pool` "stats() shape" test
|
|
183
|
+
updated from the 11-key 1.4.0 shape to the 12-key 1.6 shape (adds
|
|
184
|
+
`flushPasses`). **Coverage** (c8@11, Node 22): `Signal.js` 100% statements /
|
|
185
|
+
96.96% branches / 100% functions / 100% lines; `Watch.js` 100% across all
|
|
186
|
+
four. The branch drop vs 1.5.0 (97.35% -> 96.96%) is the zero-cost gate on
|
|
187
|
+
`flushPasses` / opcode 6 / opcode 7 -- the `if (mutationHook !== null)`
|
|
188
|
+
mutation-hook-attached branch is not exercised by the active test suite,
|
|
189
|
+
which never attaches a hook; the inert path is covered.
|
|
190
|
+
- **`createScope` behavior** (4 tests, `node --expose-gc`): returns `fn`'s value and
|
|
191
|
+
runs the owner exactly once even when `fn` reads signals in its direct body
|
|
192
|
+
(untracked); inner effects/computeds track and update; `dispose()` cascade-disposes
|
|
193
|
+
the owned subtree (effects + computeds) while an un-adopted signal correctly
|
|
194
|
+
survives; a disposed scope's inner effects stop firing; **a scope created inside a
|
|
195
|
+
consumer effect survives that consumer's re-run** (the reconciler-critical detach
|
|
196
|
+
property); `dispose()` is an idempotent no-op on the second call; the disposer is
|
|
197
|
+
introspection-stamped to its owner effect; and `totalAllocations - totalDisposals
|
|
198
|
+
=== activeNodes` holds after teardown. Plus a smoke confirming signal -> computed ->
|
|
199
|
+
effect is unaffected by the additive change.
|
|
200
|
+
- **`getOwner` / `runWithOwner` port**: sha256 over the extracted function bodies of
|
|
201
|
+
`pullComputed`, `executeEffect`, `allocateLink`, `severTail`, `createNode`,
|
|
202
|
+
`runCleanup`, `disposeNode`, `createRoot`, `createScope` matches the pristine
|
|
203
|
+
1.6.0-alpha engine byte-for-byte -- port touched no hot path. `Publications/
|
|
204
|
+
owner-hazard-repro.mjs` reports **`VERDICT: SAFE`** on the merged engine on both
|
|
205
|
+
hazards (continuation runs 2 times before stranger disposal, 3 after; corpse
|
|
206
|
+
case runs 2 without `RangeError`).
|
|
207
|
+
- **Instrumentation is zero-cost when unobserved**: `flushPasses` advances and opcodes
|
|
208
|
+
6/7 fire only while a mutation-hook listener is attached; with none, the two hook
|
|
209
|
+
fire sites are pure `null`-check branches (branch-predicted-free after warmup).
|
|
210
|
+
|
|
211
|
+
### Verified -- fresh 1.6.0-alpha bench sweep
|
|
212
|
+
|
|
213
|
+
Both benches re-run on the 1.6.0-alpha engine and committed to
|
|
214
|
+
`bench/results.txt` (isolated propagation, 9 scenarios) and
|
|
215
|
+
`bench/resultsReactive.txt` (cross-framework reactivity, median-of-10, 34
|
|
216
|
+
tests). The 10 raw reactive-suite runs sit under `bench/bench-runs-reactive/
|
|
217
|
+
run_1.txt` ... `run_10.txt` so anyone can re-median independently.
|
|
10
218
|
|
|
11
|
-
|
|
219
|
+
- **Propagation bench (results.txt):** lite +49% / +43% / +35% / +29% on the four
|
|
220
|
+
allocation-heavy scenarios (SELECTIVE DAG / DYNAMIC DAG / MUX / SMALL
|
|
221
|
+
SELECTIVE) -- unchanged in character from the 1.5.0-beta sweep, the gate is
|
|
222
|
+
round-off on allocation-dominated shapes. Parity on LARGE WEB APP (-3%) and
|
|
223
|
+
WIDE DENSE (-6%), inside host noise. **Alien-signals ahead on BROADCAST
|
|
224
|
+
(-10%), KAIROS (-12%, was -7% on 1.5.0-beta), and DEEP CHAIN (-21%, was -14%
|
|
225
|
+
on 1.5.0-beta)** -- the KAIROS and DEEP CHAIN widening is the observable
|
|
226
|
+
gate cost on shapes where every branch matters. Speed wins vs alien: **4/9**
|
|
227
|
+
(was 5/9); heap wins: **8/9** (unchanged).
|
|
228
|
+
- **Reactive suite (resultsReactive.txt):** fastest of five frameworks on all
|
|
229
|
+
five `dyn` rows (simple +19%, dynamic +13%, large web app +11%, wide dense
|
|
230
|
+
+4%, deep +16%). On the `S: updateComputations` micro-rows lite trades the
|
|
231
|
+
lead with alien: **4/7 wins this sweep** (was 7/7 on 1.5.0-beta), consistent
|
|
232
|
+
with the gate cost on 50-70ms rows that iterate many thousands of times per
|
|
233
|
+
measurement.
|
|
234
|
+
- **Andrii Volynets js-reactivity-benchmark position holds at 4th of 15** with
|
|
235
|
+
geomean **73.1ms** (raw log `bench/AndriiVolynetsReactiveBench.log`, all 15
|
|
236
|
+
x 47 rows); lite is ahead of 5th-place Preact Signals (79.9) by ~9%.
|
|
237
|
+
Outright-fastest-of-15 wins jumped to **6 shapes**: `broadPropagation`,
|
|
238
|
+
`manyEffectsFromOneSource`, `manySourcesIntoOneComputedEffect`,
|
|
239
|
+
`manySourcesIntoOneComputedEffectWithDirect`, `molBench`, and the `32x8 - 4
|
|
240
|
+
sources - pull` DAG. Top-3 count: 23/47. (Outright wins swing at the top of
|
|
241
|
+
a very tight leaderboard; the stable metric across every sweep is the
|
|
242
|
+
geomean rank at 4th of 15.)
|
|
243
|
+
- **Third-party engine versions carried forward** from the 1.5.0-beta sweep
|
|
244
|
+
(alien-signals 3.2.1, @preact/signals-core 1.14.2, @vue/reactivity 3.5.35,
|
|
245
|
+
solid-js 1.9.13). No peer bumps this cycle -- the deltas here are the 1.6
|
|
246
|
+
engine's own footprint plus host noise.
|
|
247
|
+
|
|
248
|
+
### Tooling -- harness reorganization (no published-surface change)
|
|
249
|
+
|
|
250
|
+
The loose `harness/` probes are routed through a single dispatcher
|
|
12
251
|
(`harness/run.mjs`) and exposed as npm scripts: `harness:field`,
|
|
13
252
|
`harness:dispose`, `harness:churn`, `harness:owner`, `harness:creation`, and
|
|
14
253
|
`harness:all` (field + dispose + churn in sequence). `harness:field` is the
|
|
@@ -16,139 +255,37 @@ portable fieldkit verify + cold-child A/B bench; the rest map one-to-one to the
|
|
|
16
255
|
existing probe files. Paths resolve from the dispatcher, so the working
|
|
17
256
|
directory no longer matters.
|
|
18
257
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
current owner: effects and computeds created directly in `fn` are adopted
|
|
51
|
-
by that owner and cascade-dispose when it re-runs or is disposed. Nulls
|
|
52
|
-
the tracking observer for the duration of `fn` (Solid semantics, matching
|
|
53
|
-
`createRoot`'s pairing) so accidental cross-async edges cannot form.
|
|
54
|
-
|
|
55
|
-
The handles use the same `describeNode` / `liveNode` ABA-guard machinery
|
|
56
|
-
that `describe` / `nodeId` / `forEachOwned` / `ownerOf` have used since
|
|
57
|
-
1.2.1: a returned descriptor carries an internal `NODE_GEN` stamp, and
|
|
58
|
-
`runWithOwner` resolves via `liveNode()` which checks that the stamp
|
|
59
|
-
still matches the pool slot's current gen. Stale, null, undefined, or
|
|
60
|
-
non-tracker handles all **degrade to rooted execution** -- `currentOwner`
|
|
61
|
-
set to `null`, `fn` runs, created children survive without adoption, and
|
|
62
|
-
the caller is responsible for their disposal (the same contract as
|
|
63
|
-
`createRoot`).
|
|
64
|
-
|
|
65
|
-
### Fixed -- the two hazards the gen guard exists to prevent
|
|
66
|
-
|
|
67
|
-
The design was originally sketched with raw node pointers -- `getOwner()
|
|
68
|
-
{ return currentOwner; }` and `runWithOwner(node, fn) { const p =
|
|
69
|
-
currentOwner; currentOwner = node; ... }`. That shape is broken in this
|
|
70
|
-
engine because nodes are pooled and the LIFO free list recycles a
|
|
71
|
-
disposed owner's slot into whatever effect/computed is allocated next.
|
|
72
|
-
Two failure modes were empirically reproduced against a 1.5.0-beta
|
|
73
|
-
engine patched with the raw-pointer alternative
|
|
74
|
-
(`harness/owner-hazard-repro.mjs`):
|
|
75
|
-
|
|
76
|
-
- **Recycled-slot cascade death.** Owner A captured; A disposed; effect B
|
|
77
|
-
allocated (LIFO -> same slot); `runWithOwner(captured)` silently
|
|
78
|
-
adopts the continuation into B; B's re-run cascade-disposes it.
|
|
79
|
-
Measured on the unsafe engine: continuation ran 1 time before
|
|
80
|
-
stranger disposal, 1 time after (should have been 2, then 3).
|
|
81
|
-
- **Corpse adoption = engine crash.** Same capture, slot NOT yet
|
|
82
|
-
recycled; `runWithOwner(captured, () => effect(...))` splices a child
|
|
83
|
-
into a disposed owner's `firstOwned` list; the next disposal walk
|
|
84
|
-
recurses without termination. Measured: `RangeError: Maximum call
|
|
85
|
-
stack size exceeded` at `runCleanup` / `disposeNode`. Not a leak, a
|
|
86
|
-
crash.
|
|
87
|
-
|
|
88
|
-
Both hazards are pinned in `test/28-run-with-owner.test.mjs` and both
|
|
89
|
-
fail on the raw-pointer sketch; both pass on the shipped
|
|
90
|
-
`describeNode` / `liveNode` implementation. The safe implementation
|
|
91
|
-
degrades both hazards to rooted execution (the continuation runs and
|
|
92
|
-
survives independently of any stranger's lifecycle -- the only honest
|
|
93
|
-
semantics for "the scope you captured no longer exists").
|
|
94
|
-
|
|
95
|
-
### Added -- `test/28-run-with-owner.test.mjs`
|
|
96
|
-
|
|
97
|
-
**16 tests**, structured to catch the failure modes above rather than
|
|
98
|
-
just the microtask happy path:
|
|
99
|
-
|
|
100
|
-
- Basic shape (7 tests): `getOwner()` returns undefined outside any
|
|
101
|
-
effect/computed and a descriptor inside; `runWithOwner` adopts a
|
|
102
|
-
nested effect into the captured owner, nulls the tracking observer
|
|
103
|
-
for reads directly in `fn`, returns whatever `fn` returns, restores
|
|
104
|
-
previous owner/observer/tracking on return AND on throw, and nests
|
|
105
|
-
correctly (inner switches, outer unwinds).
|
|
106
|
-
- Degradation (3 tests): `null` / `undefined` / a signal handle all
|
|
107
|
-
degrade to rooted execution and the created effect works normally
|
|
108
|
-
(fires on updates, disposable).
|
|
109
|
-
- Hazard pins (3 tests, plus a composed test): the recycled-slot cascade
|
|
110
|
-
and the corpse-adoption case, each with allocation pressure applied
|
|
111
|
-
BEFORE `runWithOwner` (a stranger effect is created to force slot
|
|
112
|
-
recycling), so the ABA guard is genuinely exercised. A follow-up
|
|
113
|
-
composed test asserts the continuation survives both the stranger's
|
|
114
|
-
re-runs and its disposal.
|
|
115
|
-
|
|
116
|
-
Full test suite on 1.5.0-beta.2: **455 total** (439 pre-existing +
|
|
117
|
-
16 new), 444 pass, 0 fail, 1 skip (SSR N/A), 10 cancelled (the
|
|
118
|
-
`25-devtools-real-boot` cases that need `@zakkster/lite-devtools`
|
|
119
|
-
installed as a peer -- pre-existing, unrelated).
|
|
120
|
-
|
|
121
|
-
### Added -- `harness/owner-hazard-repro.mjs`
|
|
122
|
-
|
|
123
|
-
A standalone reproducer for the two hazards, callable against any engine
|
|
124
|
-
(`node owner-hazard-repro.mjs <path-to-Signal.js>`). Prints
|
|
125
|
-
`VERDICT: SAFE` on the shipping implementation, `VERDICT: CORRUPTED` +
|
|
126
|
-
a stack overflow on the raw-pointer sketch. Kept in `harness/`
|
|
127
|
-
alongside the other run-on-demand probes rather than under `test/` so it can
|
|
128
|
-
travel to other engines (a candidate 1.6, or a rejected candidate you
|
|
129
|
-
want to confirm) without dragging the whole test tree along.
|
|
130
|
-
|
|
131
|
-
### Verified -- no hot-path change vs 1.5.0-beta.1
|
|
132
|
-
|
|
133
|
-
sha256 over the extracted function bodies of `pullComputed`,
|
|
134
|
-
`markDownstream`, `executeEffect`, `flushEffects`, `allocateLink`,
|
|
135
|
-
`severTail`, `createNode`, `runCleanup`, and `disposeNode` matches
|
|
136
|
-
1.5.0-beta.1 byte-for-byte. `currentOwner` is written by exactly the
|
|
137
|
-
sites that wrote it before (creation adoption, effect-body save/restore,
|
|
138
|
-
cleanup), plus the two new user-API primitives. Propagation
|
|
139
|
-
(`markDownstream`) remains owner-free per its documented invariant.
|
|
140
|
-
|
|
141
|
-
### Not shipped
|
|
142
|
-
|
|
143
|
-
- Watch.js needs no changes -- `watch` / `when` / `whenAsync` create
|
|
144
|
-
effects through the normal path and inherit correct adoption under
|
|
145
|
-
`runWithOwner` automatically. Verified against the safe engine.
|
|
146
|
-
- `runWithOwner` deliberately does NOT accept a callable `signal`
|
|
147
|
-
handle as an "owner" (signals cannot own). It falls through to
|
|
148
|
-
rooted execution instead, matching the shape of every other
|
|
149
|
-
handle-taking introspection API.
|
|
150
|
-
|
|
151
|
-
## [1.5.0-beta.1] -- 2026-06-XX
|
|
258
|
+
- **`churnprobe.mjs` corrected.** It read link churn from `stats().totalLink*`
|
|
259
|
+
fields that never existed on this engine (`stats()` tracks only NODE lifecycle
|
|
260
|
+
plus a live `activeLinks` gauge), so every row printed `NaN`. It now counts
|
|
261
|
+
gross link churn off `onGraphMutation` -- opcode `3` (link-add) and `4`
|
|
262
|
+
(link-sever) -- which is strictly better: a net `activeLinks` delta would read
|
|
263
|
+
zero on `dep-flip` because each sever is matched by an add, hiding exactly the
|
|
264
|
+
retracking the probe exists to catch. Stable shapes now read `churn/recompute
|
|
265
|
+
= 0`; `dep-flip` reads `2.0`. Opcodes `3`/`4`/`5` are unchanged from 1.5; the
|
|
266
|
+
probe does not use the new `6`/`7` flush opcodes.
|
|
267
|
+
- **`burst-dag.mjs` reconciled.** The contiguous-window guess was first promoted
|
|
268
|
+
from `futureVersions/` into `harness/` (wiring up the `profile:burst` script
|
|
269
|
+
that already pointed there), then superseded by the verbatim-Andrii strided
|
|
270
|
+
reconciliation now carrying that name (see Added above); the contiguous guess
|
|
271
|
+
and its `burstDagScenario` / `multiPassProbe` exports are preserved in
|
|
272
|
+
`harness/attic/`. `pull-stress.mjs` -- the pull-path companion documented
|
|
273
|
+
alongside it -- landed in `harness/`.
|
|
274
|
+
- **The owner-recycling reproducer** is documented at its real home,
|
|
275
|
+
`harness/owner-hazard-repro.mjs`; the earlier `Publications/...` citations
|
|
276
|
+
in README / CHANGELOG / llms.txt pointed at a path the file was never in, and
|
|
277
|
+
are corrected. The createComputations matrix parent/child link
|
|
278
|
+
(`creation-isolated.mjs` -> `andrii-isolated-child.mjs`) is repaired.
|
|
279
|
+
- **Six settled one-off probes** -- the five from the 1.2.0 -> 1.2.1
|
|
280
|
+
construction-shape regression hunt, plus the superseded
|
|
281
|
+
`repro-set-after-dispose.mjs` (its invariant now pinned by `test/07-dispose`
|
|
282
|
+
and `test/26-free-list-invariant`) -- are parked in `harness/attic/` with a
|
|
283
|
+
README explaining each.
|
|
284
|
+
|
|
285
|
+
`Signal.js` and the published `files[]` whitelist are untouched by any of the
|
|
286
|
+
above; this is a repo-tooling change only.
|
|
287
|
+
|
|
288
|
+
## [1.5.0] -- 2026-06-XX
|
|
152
289
|
|
|
153
290
|
The API-surface minor: two new **non-callable, allocation-light** reactive
|
|
154
291
|
primitives, `signalBox` and `computedBox`, land alongside the existing callable
|