@zakkster/lite-signal 1.6.0-preview.2 → 1.7.0-alpha.2
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 +445 -8
- package/README.md +318 -98
- package/Signal.d.ts +61 -0
- package/Signal.js +280 -41
- package/llms.txt +209 -86
- package/package.json +32 -9
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,443 @@ All notable changes to `@zakkster/lite-signal` are documented here.
|
|
|
4
4
|
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
5
|
This project follows [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Changed -- bench protocol v3 (carried forward)
|
|
10
|
+
|
|
11
|
+
The `bench/` harness is bench protocol v3: three instruments (microscope / mirror /
|
|
12
|
+
version-economics), each with a fixed config and a machine-generated `#STAMP`
|
|
13
|
+
(engine + harness sha256, live registry config, host, node). The pre-v3
|
|
14
|
+
five-framework reactivity suite was removed after 1.5.1. See `bench/README.md`.
|
|
15
|
+
|
|
16
|
+
### Added -- Coveralls coverage badge
|
|
17
|
+
|
|
18
|
+
README carries a Coveralls badge; lcov is produced by `npm run test:report`
|
|
19
|
+
(`coveralls-next` in devDependencies).
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Fixed -- dangling re-tracking cursor on source disposal (crash)
|
|
23
|
+
|
|
24
|
+
Disposing a signal/computed from inside an observer that had linked it on the
|
|
25
|
+
previous run, but had not yet re-read it on the current run, crashed with
|
|
26
|
+
`TypeError: Cannot set properties of null (setting 'headSub')`. `disposeNode`'s
|
|
27
|
+
sub-list teardown freed the link while the observer's re-tracking cursor
|
|
28
|
+
(`activeObserverCurrentDep`) was still parked on it; `severTail` then walked from
|
|
29
|
+
a freed link, wiped the observer's `headDep`, and double-freed the link. Reachable
|
|
30
|
+
from the plain public API (see `COVERAGE-NOTES.md` for the repro). Fixed with a
|
|
31
|
+
one-line cursor repair in `disposeNode` (advance the cursor to the next surviving
|
|
32
|
+
dep before the free); O(1), disposal path only, no steady-state cost. Pinned by a
|
|
33
|
+
regression test in `test/12-coverage.test.mjs`.
|
|
34
|
+
|
|
35
|
+
This also corrects the record on `freeLink`: the `link.source !== null ? … : -1`
|
|
36
|
+
fallbacks were documented as "unreachable defensive code," but they were in fact
|
|
37
|
+
reachable -- and *only* reachable -- through this crash path. With the cursor
|
|
38
|
+
repaired they are genuinely dead, so they were removed (replaced by the passed
|
|
39
|
+
`source.id` / `target.id`, which are always live). Branch coverage on `Signal.js`
|
|
40
|
+
is now 100%: the two remaining unreachable arms (link-ledger clamp, `batchEpoch`
|
|
41
|
+
2^32 wraparound) carry `/* c8 ignore */` with proofs. See `COVERAGE-NOTES.md`.
|
|
42
|
+
|
|
43
|
+
**Hot-path parity note:** this touches `disposeNode` and `freeLink`; re-baseline the
|
|
44
|
+
VersionMatrix engine sha256 on the next publish. Steady-state read/propagation
|
|
45
|
+
bodies are unchanged.
|
|
46
|
+
|
|
47
|
+
### Changed -- test file numbering
|
|
48
|
+
|
|
49
|
+
`test/28-scope.test.mjs` renamed to `test/29-scope.test.mjs` to resolve the
|
|
50
|
+
duplicate `28-` prefix it shared with `28-run-with-owner.test.mjs`
|
|
51
|
+
(`createScope` is the 1.6.0 primitive, sequenced after `runWithOwner`).
|
|
52
|
+
|
|
53
|
+
## [1.7.0-alpha.0] -- 2026-07-14
|
|
54
|
+
|
|
55
|
+
The **flush-strategy minor**, promoted from `preview` to the `alpha` dist-tag.
|
|
56
|
+
Two additions on top of 1.6.0-preview:
|
|
57
|
+
|
|
58
|
+
- **`flushStrategy` registry option + `r.flush()`** -- the primary 1.7 lever, a
|
|
59
|
+
per-registry choice of when effects auto-deliver (`"eager"` default | `"sab"` |
|
|
60
|
+
`"manual"`) plus an explicit `flush()` method on every registry. Resolved once at
|
|
61
|
+
registry init by binding to a pre-built closure reference; the "eager" inlined
|
|
62
|
+
body is byte-identical to 1.6's `if (batchDepth === 0) flushEffects()` so
|
|
63
|
+
existing users see zero behavioral or performance regression.
|
|
64
|
+
- **`getOwner` / `runWithOwner` port** -- carried forward from 1.5.0-beta.2 into
|
|
65
|
+
this line. The 1.7.0-preview `Signal.js` was branched from a pre-1.5.0-beta.2
|
|
66
|
+
base and the two async-gap primitives (`getOwner()` capture, `runWithOwner()`
|
|
67
|
+
restore) were missing. Ported unchanged: the same safe `describeNode` +
|
|
68
|
+
`liveNode` gen-guard machinery that landed in 1.5.0-beta.2 and carried into 1.6
|
|
69
|
+
is now present here too, so any consumer using the ownership escape hatch (e.g.
|
|
70
|
+
`lite-query`'s query-watcher across an `await`) gets the same guarantees on the
|
|
71
|
+
1.7 line.
|
|
72
|
+
|
|
73
|
+
The two hot-path changes 1.6 -> 1.7 are localised to `signal` / `computed` /
|
|
74
|
+
`effect` / `signalBox` / `computedBox` (their `.set` sites) and `batch` (its
|
|
75
|
+
exit site) -- specifically the resolved-once `FLUSH_ON_IDLE_WRITE` /
|
|
76
|
+
`FLUSH_ON_BATCH_EXIT` booleans. **Every other hot-path body is byte-identical to 1.6.0**
|
|
77
|
+
(sha256-verified over `pullComputed`, `markDownstream`, `executeEffect`,
|
|
78
|
+
`flushEffects`, `allocateLink`, `severTail`, `createNode`, `runCleanup`,
|
|
79
|
+
`disposeNode`, `createRoot`, `createScope`). The two ownership primitives added
|
|
80
|
+
by this port only add new user-API functions -- they do not touch any of the
|
|
81
|
+
above; the sha256 check confirms it.
|
|
82
|
+
|
|
83
|
+
Drop-in over 1.6.0-preview. The default is unchanged.
|
|
84
|
+
|
|
85
|
+
### Added -- `flushStrategy` registry option
|
|
86
|
+
|
|
87
|
+
Selects when effects auto-deliver, chosen once at `createRegistry` time:
|
|
88
|
+
|
|
89
|
+
- **`"eager"`** (default, byte-identical to 1.6.0): `.set` outside batch
|
|
90
|
+
auto-flushes; batch exit auto-flushes.
|
|
91
|
+
- **`"sab"`** (**stable-after-batch**, matches Reflex semantics): `.set` outside
|
|
92
|
+
batch enqueues effects via the existing `FLAG_SCHEDULED` dedup but does NOT
|
|
93
|
+
auto-flush; batch exit DOES auto-flush. This is the apples-to-apples mode for
|
|
94
|
+
the `js-reactivity-benchmark` `update*` group -- on shapes with observers but
|
|
95
|
+
no effects, the eager `flushEffects` empty-path `try/finally` was the dominant
|
|
96
|
+
per-write overhead.
|
|
97
|
+
- **`"manual"`**: neither `.set` nor batch exit auto-flush; only explicit
|
|
98
|
+
`r.flush()` drains the queue. For hard-real-time loops that need frame-aligned
|
|
99
|
+
settle points (Hueforge, Gradient Studio).
|
|
100
|
+
|
|
101
|
+
### Added -- `r.flush()` explicit flush API
|
|
102
|
+
|
|
103
|
+
Explicit flush method on every registry. Re-entrant safe (the existing
|
|
104
|
+
`isFlushing` guard applies unchanged); empty queue exits immediately. The three
|
|
105
|
+
strategies use it as follows: `"eager"` never needs it (auto-flushes cover
|
|
106
|
+
everything); `"sab"` needs it if you `.set` outside batch and want the effects
|
|
107
|
+
to run without waiting for the next batch exit; `"manual"` needs it to run any
|
|
108
|
+
effects at all.
|
|
109
|
+
|
|
110
|
+
### Added -- `getOwner` / `runWithOwner` (carried forward from 1.5.0-beta.2)
|
|
111
|
+
|
|
112
|
+
The capture-and-restore companion to `createRoot`. `getOwner()` returns the
|
|
113
|
+
current lifecycle owner as an opaque, gen-stamped handle (`undefined` outside
|
|
114
|
+
any effect/computed body); `runWithOwner(handle, fn)` runs `fn` with that owner
|
|
115
|
+
reinstated so effects/computeds created directly in `fn` are adopted by it (and
|
|
116
|
+
cascade-dispose when the owner re-runs). Nulls the tracking observer for `fn`'s
|
|
117
|
+
direct body -- same pairing as `createRoot`, so accidental cross-async
|
|
118
|
+
dependency edges cannot form.
|
|
119
|
+
|
|
120
|
+
**Handles are gen-stamped.** They use the `describeNode` + `liveNode` ABA-guard
|
|
121
|
+
machinery (`NODE_GEN` stamp checked against the pool slot's current gen), same as
|
|
122
|
+
`describe` / `nodeId` / `forEachOwned` / `ownerOf` since 1.2.1. Safe to hold
|
|
123
|
+
across async boundaries: if the captured owner is disposed and the pool slot is
|
|
124
|
+
recycled by an unrelated effect via the LIFO free list, the handle's gen no
|
|
125
|
+
longer matches and `runWithOwner` degrades to **rooted execution** rather than
|
|
126
|
+
adopting the continuation into the recycled slot's new resident. Two hazards on
|
|
127
|
+
the raw-pointer alternative pinned in `test/28-run-with-owner.test.mjs` and
|
|
128
|
+
empirically reproduced against a patched engine via
|
|
129
|
+
`harness/owner-hazard-repro.mjs`:
|
|
130
|
+
|
|
131
|
+
- **Recycled-slot cascade death** -- capture, dispose owner, allocate a stranger
|
|
132
|
+
effect that reuses the slot; a raw-pointer `runWithOwner(captured)` silently
|
|
133
|
+
adopts the continuation into the stranger; the stranger's next re-run
|
|
134
|
+
cascade-disposes it.
|
|
135
|
+
- **Corpse adoption = engine crash** -- capture, dispose owner but not-yet-
|
|
136
|
+
recycled; a raw-pointer `runWithOwner(captured, () => effect(...))` splices a
|
|
137
|
+
child into a disposed owner's `firstOwned`; the next disposal walk recurses
|
|
138
|
+
without termination (`RangeError: Maximum call stack size exceeded`). Not a
|
|
139
|
+
leak; a crash.
|
|
140
|
+
|
|
141
|
+
Both fail on the raw-pointer sketch; both pass on the shipped `describeNode` /
|
|
142
|
+
`liveNode` implementation. Verified against 1.7.0-preview's engine directly --
|
|
143
|
+
`harness/owner-hazard-repro.mjs ./Signal.js` reports `VERDICT: SAFE` on the
|
|
144
|
+
recycled-slot case (continuation runs 2 times before stranger disposal, 3
|
|
145
|
+
times after) and completes the corpse case without stack overflow.
|
|
146
|
+
|
|
147
|
+
Exported as registry methods AND top-level helpers bound to `defaultRegistry`,
|
|
148
|
+
mirroring `createRoot` and `createScope`. Top-level exports added right before
|
|
149
|
+
the top-level `createScope` binding for stable ordering.
|
|
150
|
+
|
|
151
|
+
### Hot-path safety -- and the design that was tried, measured, and rejected
|
|
152
|
+
|
|
153
|
+
**The shipped mechanism is a pair of closure-captured `const` booleans**, not a
|
|
154
|
+
function reference:
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
const FLUSH_ON_IDLE_WRITE = (flushStrategy === "eager");
|
|
158
|
+
const FLUSH_ON_BATCH_EXIT = (flushStrategy !== "manual");
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
They are immutable for the registry's lifetime, which gives V8's JIT the
|
|
162
|
+
constant-folding hook it needs: in `"eager"` mode the emitted code for `.set` is
|
|
163
|
+
byte-identical to 1.6.0's `if (batchDepth === 0) flushEffects()`; in
|
|
164
|
+
`"sab"`/`"manual"` the `FLUSH_ON_IDLE_WRITE && …` short-circuits on the const-false
|
|
165
|
+
and V8 elides the branch entirely after one tier-up. `signal()` additionally
|
|
166
|
+
selects between **two pre-built `.set` closures at construction time**, so the eager
|
|
167
|
+
body carries no extra load or branch at all. **Zero behavioural or performance
|
|
168
|
+
regression** for any existing user.
|
|
169
|
+
|
|
170
|
+
**The first 1.7 implementation did something else and it was slower.** It captured
|
|
171
|
+
a function reference (`flushAfterWrite` / `flushAfterBatch`, bound to
|
|
172
|
+
`eagerFlushHook | noopFlush`) and called it from `.set` / `boxSet`. V8 did **not**
|
|
173
|
+
inline that reference on this workload: eager-mode `.set` measured **16-65% slower
|
|
174
|
+
than 1.6.0** on Andrii's `updateComputations*` tests, because every write paid a
|
|
175
|
+
function-call indirection. A second attempt -- a single `.set` body with
|
|
176
|
+
`if (FLUSH_ON_IDLE_WRITE && batchDepth === 0)` -- measured **16-30% slower**, because
|
|
177
|
+
a closure-captured `const` boolean lives in a context slot, not as a literal in
|
|
178
|
+
bytecode, when the body is shared. Splitting the closure at *build* time is what
|
|
179
|
+
recovered parity. Both dead ends are recorded here so nobody re-derives them.
|
|
180
|
+
|
|
181
|
+
This is NOT ledger §0b #6 (per-call closure-var load of a primitive V8 can't fold).
|
|
182
|
+
The literals are declared `const` and never reassigned, and the hot body is selected
|
|
183
|
+
before the first write.
|
|
184
|
+
|
|
185
|
+
> **Known stale comment:** the file header of `Signal.js` (around line 22) still
|
|
186
|
+
> describes the *abandoned* function-reference design ("one of two pre-built flush
|
|
187
|
+
> hooks (eagerFlushHook | noopFlush)"). No such identifier exists in the code; the
|
|
188
|
+
> in-place comment at the `FLUSH_ON_IDLE_WRITE` declaration is the accurate one.
|
|
189
|
+
> The header needs a one-line correction. It is called out rather than silently
|
|
190
|
+
> edited because `Signal.js` is sha256-pinned across the 1.6 -> 1.7 boundary.
|
|
191
|
+
|
|
192
|
+
The `getOwner` / `runWithOwner` port adds new user-API functions but touches no
|
|
193
|
+
hot path. sha256 over the extracted function bodies of `pullComputed`,
|
|
194
|
+
`markDownstream`, `executeEffect`, `flushEffects`, `allocateLink`, `severTail`,
|
|
195
|
+
`createNode`, `runCleanup`, `disposeNode`, `createRoot`, `createScope` matches
|
|
196
|
+
pristine 1.7.0-preview byte-for-byte; the two new functions are inserted between
|
|
197
|
+
`createRoot` and `createScope` without disturbing either.
|
|
198
|
+
|
|
199
|
+
### Test coverage
|
|
200
|
+
|
|
201
|
+
- **Full suite green:** **484 tests across 29 files**, 483 pass, **0 fail**, 1 skip
|
|
202
|
+
(only the architecturally-N/A SSR case in `17-reactivity`), 0 cancelled. Plain
|
|
203
|
+
`npm test` runs 476 of them -- 8 are gated on `--expose-gc` (3 in `04-zero-gc`,
|
|
204
|
+
4 in `09-conformance`, 1 in `11-adopted-reactive`) and need `npm run test:gc`. The 10
|
|
205
|
+
previously-cancelled `25-devtools-real-boot` cases now run and pass (19/19) with
|
|
206
|
+
`@zakkster/lite-devtools` resolvable as a dev peer. Default-mode behaviour is
|
|
207
|
+
unchanged byte-for-byte from 1.6.0.
|
|
208
|
+
- **Coverage: `Signal.js` at 100% statements / 100% functions / 100% lines /
|
|
209
|
+
99.24% branches; `Watch.js` at 100% on every metric** (`npm run test:coverage`).
|
|
210
|
+
Up from 97.84 / 93.40 / 97.84 / 96.22 on `preview.2`.
|
|
211
|
+
|
|
212
|
+
The four residual branch arms are **unreachable by construction**, and are listed
|
|
213
|
+
rather than papered over with an ignore pragma (which would have broken the
|
|
214
|
+
sha256 hot-path proof above for no behavioural gain):
|
|
215
|
+
|
|
216
|
+
1-2. `freeLink`'s `link.source !== null ? … : -1` and `link.target !== null ? … : -1`
|
|
217
|
+
fallbacks. All three call sites pass a link taken from a live dep/sub list;
|
|
218
|
+
both endpoints are always non-null.
|
|
219
|
+
3. The `doubled > maxLinkLimit ? maxLinkLimit : doubled` clamp in the link-growth
|
|
220
|
+
ledger. `maxLinkLimit` is `maxLinks * 16` and the ledger only doubles from
|
|
221
|
+
`maxLinks`, so the doubling sequence lands *exactly* on the ceiling and cannot
|
|
222
|
+
overshoot. The ceiling itself is a real wall and is tested.
|
|
223
|
+
4. The `if (batchEpoch === 0) batchEpoch = 1;` 32-bit-wraparound guard in `batch()`.
|
|
224
|
+
Reaching it needs 2^32 batches in one registry.
|
|
225
|
+
|
|
226
|
+
- **+16 tests in `test/28-run-with-owner.test.mjs`** (carried forward from
|
|
227
|
+
1.5.0-beta.2 / 1.6.0-alpha): 7 basic-shape tests, 3 degradation tests
|
|
228
|
+
(`null` / `undefined` / signal-handle all fall through to rooted execution),
|
|
229
|
+
and 3 **hazard pins** with allocation pressure applied so the ABA guard is
|
|
230
|
+
actually exercised (recycled-slot cascade, corpse adoption, composed).
|
|
231
|
+
- **`test/03-pool` "stats() shape" test** bumped from the 11-key 1.4.0 shape to
|
|
232
|
+
the 12-key 1.6+ shape (adds `flushPasses`).
|
|
233
|
+
- **+16 tests in `test/12-coverage.test.mjs`** -- the behavioural coverage that
|
|
234
|
+
`preview.2` explicitly deferred is now **delivered**, and it is what closed the
|
|
235
|
+
gap above:
|
|
236
|
+
- `flushStrategy` validation (a bogus token throws at `createRegistry`; all three
|
|
237
|
+
valid tokens construct; an omitted config and an omitted key both default to
|
|
238
|
+
`"eager"`).
|
|
239
|
+
- All three modes end-to-end: `eager` delivers per idle write and once per batch;
|
|
240
|
+
`sab` defers an idle write, **dedups 1000 un-batched writes into one run**, and
|
|
241
|
+
drains the whole backlog at batch exit; `manual` gates *both* the idle write and
|
|
242
|
+
the batch exit, leaving `r.flush()` as the only settle point.
|
|
243
|
+
- **Lazy-pull correctness in every mode** -- a `computed` / `computedBox` read after
|
|
244
|
+
a deferred write returns the NEW value with no flush. The write is always eager;
|
|
245
|
+
only delivery defers. This is the invariant that makes `"sab"`/`"manual"` safe.
|
|
246
|
+
- The **entire non-eager `.set` / `boxSet` body, branch by branch**: gen guard
|
|
247
|
+
(a write through a stale handle is a silent no-op), `equals` short-circuit
|
|
248
|
+
(default and custom predicates), pre-batch revert (set-then-revert inside a batch
|
|
249
|
+
is a net no-op and restores `preBatchVersion`), and the real-net-change path.
|
|
250
|
+
- The **top-level `flush` / `getOwner` / `runWithOwner` delegators** bound to the
|
|
251
|
+
default registry (all three were 0% covered).
|
|
252
|
+
- `flush()` on an empty queue is a no-op; `flush()` is the escape hatch for an
|
|
253
|
+
idle-write backlog in `sab`.
|
|
254
|
+
- **+5 engine-edge tests in `test/12-coverage.test.mjs`** for branches no behavioural
|
|
255
|
+
suite reached. Two are worth recording because finding them corrected a wrong
|
|
256
|
+
assumption in the source comments:
|
|
257
|
+
- **The `allocateLink` eligibility gate (`target.flags === 0`) is NOT reachable by
|
|
258
|
+
plain self-dispose.** `disposeNode` already nulls `currentObserver` /
|
|
259
|
+
`activeObserverCurrentDep` / `isTrackingDeps` when the disposing node *is* the
|
|
260
|
+
current observer, so a read later in a self-disposing effect's body never reaches
|
|
261
|
+
`allocateLink` at all. The gate's live path is the *other* case its own comment
|
|
262
|
+
names: an **outer observer torn down while suspended** inside a nested pull -- a
|
|
263
|
+
computed whose body disposes the effect that is currently pulling it. There,
|
|
264
|
+
`currentObserver` is the *computed*, the effect's tracking state survives, and
|
|
265
|
+
`pullComputed` restores a **dead node** as the observer. The next read in the
|
|
266
|
+
effect's body must not splice a phantom edge into the corpse. Now pinned.
|
|
267
|
+
- **`executeEffect`'s `CycleError: Infinite effect loop detected.`** is likewise not
|
|
268
|
+
reachable through `markDownstream` (which skips any node carrying `FLAG_COMPUTING`,
|
|
269
|
+
so an effect writing to its own dependency is deliberately **absorbed**). It IS
|
|
270
|
+
reachable through a user `scheduler` that retains the cached thunk and re-invokes
|
|
271
|
+
it from inside the effect body. Now pinned as a `CycleError`, not a stack overflow.
|
|
272
|
+
|
|
273
|
+
### Bench impact -- `sab` vs `eager` on the update group (sandbox VM medians, 7 samples)
|
|
274
|
+
|
|
275
|
+
`update*` group with observers-but-no-effects, apples-to-apples in `sab` mode:
|
|
276
|
+
|
|
277
|
+
| Shape (n=writes) | eager | sab | speedup |
|
|
278
|
+
|------------------|-------:|-------:|--------:|
|
|
279
|
+
| 1to1 (400k) | 14.15 | 12.04 | 1.18x |
|
|
280
|
+
| 1to2 (400k) | 11.68 | 10.25 | 1.14x |
|
|
281
|
+
| 1to4 (400k) | 11.36 | 11.01 | 1.03x |
|
|
282
|
+
| 1to8 (400k) | 11.47 | 10.09 | 1.14x |
|
|
283
|
+
| 1to1000 (4k) | 1.59 | 1.55 | 1.03x |
|
|
284
|
+
| 1000to1 (1k) | 0.07 | 0.03 | 2.31x |
|
|
285
|
+
|
|
286
|
+
Real wins, but smaller than the gap to Reflex on the same shapes. The residual
|
|
287
|
+
gap is structural (per-write `gen` check, batch-revert epoch tracking, global
|
|
288
|
+
version bumping) -- design decisions accepted by §0b and not in scope here.
|
|
289
|
+
Modern V8's `try/finally` elision varies; expect higher absolute speedups on
|
|
290
|
+
production V8 than on this sandbox.
|
|
291
|
+
|
|
292
|
+
### Fixed -- `Signal.d.ts` was missing the entire 1.7.0 surface
|
|
293
|
+
|
|
294
|
+
`preview.2` shipped `flushStrategy`, `flush()`, `getOwner()` and `runWithOwner()` in
|
|
295
|
+
the engine and **declared none of them in the types**. Any TypeScript consumer would
|
|
296
|
+
have got a compile error on `createRegistry({ flushStrategy: "manual" })`, on
|
|
297
|
+
`r.flush()`, and on both ownership primitives. Added:
|
|
298
|
+
|
|
299
|
+
- `RegistryConfig.flushStrategy?: "eager" | "sab" | "manual"`
|
|
300
|
+
- `Registry.flush(): void`
|
|
301
|
+
- `Registry.getOwner(): OwnerHandle | undefined`
|
|
302
|
+
- `Registry.runWithOwner<T>(owner: OwnerHandle | null | undefined, fn: () => T): T`
|
|
303
|
+
- top-level `flush` / `getOwner` / `runWithOwner` bound to the default registry
|
|
304
|
+
- `export type OwnerHandle = NodeDescriptor` -- the gen-stamped handle, structurally
|
|
305
|
+
the same descriptor `describe()` returns, so it stays re-walkable through
|
|
306
|
+
`forEachOwned` / `ownerOf` / `nodeId`
|
|
307
|
+
|
|
308
|
+
Verified structurally: all **32** runtime exports and all **26** registry methods now
|
|
309
|
+
have a declaration.
|
|
310
|
+
|
|
311
|
+
### Fixed -- documentation had `runWithOwner` marked "not yet shipped"
|
|
312
|
+
|
|
313
|
+
Both `README.md` and `llms.txt` still carried the 1.5.0-era sentence *"the re-attach
|
|
314
|
+
companion `runWithOwner` … is not yet shipped"* while the engine exported it. Corrected
|
|
315
|
+
in both, and `flushStrategy` / `flush()` -- previously mentioned nowhere outside the
|
|
316
|
+
harness notes -- now have a full API-reference section in the README and a Core-concepts
|
|
317
|
+
entry in `llms.txt`.
|
|
318
|
+
|
|
319
|
+
### Regenerated -- every published benchmark number
|
|
320
|
+
|
|
321
|
+
`bench/results.txt`, `bench/resultsReactive.txt`, and both benchmark sections of the
|
|
322
|
+
README are rebuilt from the checked-in raw runs (`bench/bench-runs/`,
|
|
323
|
+
`bench/bench-runs-reactive/`) rather than carried forward. Two consequences worth
|
|
324
|
+
stating out loud:
|
|
325
|
+
|
|
326
|
+
- **The headline ranking improved.** On Andrii's 1.7.0 run (`bench/AndriiVolynetsReactiveBench1.7.0.log`,
|
|
327
|
+
15 frameworks x 47 tests, checked in), lite-signal is **4th of 15 by geomean at
|
|
328
|
+
71.5 ms** -- and the gap to 5th-place Preact Signals widened from ~5% to **20%**.
|
|
329
|
+
Outright fastest of all 15 on four tests. The `1000x5 - 25 sources` wide-dense DAG,
|
|
330
|
+
which was **5.7x behind** the leaders on the 1.1.2 engine Andrii first measured, is
|
|
331
|
+
now the **fastest result in the entire field**.
|
|
332
|
+
- **Two local results got worse, and are now stated plainly instead of buried.**
|
|
333
|
+
**DEEP CHAIN is a -73% loss to alien-signals** (172 ms vs 99 ms), not the -18% the
|
|
334
|
+
old (invalid) table reported -- it is the engine's largest open performance gap and
|
|
335
|
+
it is structural. And **DYNAMIC DAG, while +20% over alien, loses to preact-signals**
|
|
336
|
+
(3622 ms vs 3011 ms). The old `resultsReactive.txt` claims "fastest of all five on
|
|
337
|
+
every `dyn` row" and "ahead on all seven `updateComputations` rows" do not survive
|
|
338
|
+
the re-measurement: it is four of five `dyn` rows (solid takes `simple component`)
|
|
339
|
+
and two of seven update rows. Both retracted.
|
|
340
|
+
|
|
341
|
+
### Migration
|
|
342
|
+
|
|
343
|
+
- **Every existing user**: zero work needed. The default is unchanged; every
|
|
344
|
+
registry created without a `flushStrategy` argument runs the same code as on
|
|
345
|
+
1.6.0.
|
|
346
|
+
- **Bench adapters wanting apples-to-apples with Reflex-style flush semantics**:
|
|
347
|
+
pass `flushStrategy: "sab"` to `createRegistry` (see `liteSignal.ts` example
|
|
348
|
+
in the changeset).
|
|
349
|
+
- **Frame-aligned real-time loops**: pass `flushStrategy: "manual"` and call
|
|
350
|
+
`r.flush()` at the settle point.
|
|
351
|
+
- **Users of `createRoot` who want the capture-and-restore idiom across
|
|
352
|
+
async boundaries**: `getOwner()` + `runWithOwner()` are now available on
|
|
353
|
+
the 1.7 line (they were absent from pre-1.5.0-beta.2 branches and needed the
|
|
354
|
+
forward-port to reach 1.7 through the flushStrategy branch).
|
|
355
|
+
|
|
356
|
+
### Verified
|
|
357
|
+
|
|
358
|
+
- **Full engine test suite** green: 484 total across 29 files (476 without
|
|
359
|
+
`--expose-gc`), 483 pass, 0 fail, 1 skip, 0 cancelled. Coverage: `Signal.js` 100/99.24/100/100
|
|
360
|
+
(stmts/branch/funcs/lines), `Watch.js` 100 on every metric.
|
|
361
|
+
- **`harness/owner-hazard-repro.mjs ./Signal.js`** reports
|
|
362
|
+
`VERDICT: SAFE` on the recycled-slot case AND completes the corpse case
|
|
363
|
+
without stack overflow -- the ABA guard degrades both hazards to rooted
|
|
364
|
+
execution as designed.
|
|
365
|
+
- **sha256 over 11 hot-path function bodies** (`pullComputed`, `markDownstream`,
|
|
366
|
+
`executeEffect`, `flushEffects`, `allocateLink`, `severTail`, `createNode`,
|
|
367
|
+
`runCleanup`, `disposeNode`, `createRoot`, `createScope`) byte-identical
|
|
368
|
+
between pristine 1.7.0-preview (as uploaded) and the merged-with-getOwner
|
|
369
|
+
engine. The port literally only adds new code between `createRoot` and
|
|
370
|
+
`createScope` plus updates the return object and adds two top-level exports;
|
|
371
|
+
zero touch on any pre-existing function.
|
|
372
|
+
|
|
373
|
+
### Tooling -- harness wiring, and a benchmark that was measuring nothing
|
|
374
|
+
|
|
375
|
+
**`bench/benchmark.mjs` was producing invalid numbers and is fixed.** Every
|
|
376
|
+
lite-signal adapter in it constructed its registry with `flushStrategy: "sab"`
|
|
377
|
+
while driving un-batched `.set` calls. In SAB mode a `.set` outside `batch()`
|
|
378
|
+
*enqueues* effects but does not flush them, and the harness never called
|
|
379
|
+
`batch()` or `r.flush()` anywhere -- so the effect ran exactly **once** (its
|
|
380
|
+
creation-time run) and never again inside the timed loop. The loop was timing a
|
|
381
|
+
bare mark-dirty against dead-code-eliminated downstream work.
|
|
382
|
+
|
|
383
|
+
The symptom was visible in the reports and went unread: nine of eleven rows
|
|
384
|
+
printed `sink=[ ]` and `BENCH_SINK_SUM (anti-DCE): 0.00`. MUX reported
|
|
385
|
+
**22,032K ops/s** against a real **~219K** -- a ~100x fiction. Measured on the
|
|
386
|
+
same host: as-written `sab`-no-flush = 1 effect run, sink 0; `sab` + explicit
|
|
387
|
+
`r.flush()` = 20,000 runs, 191K ops/s; `eager` = 20,000 runs, 219K ops/s (which
|
|
388
|
+
matches the long-published ~223K MUX figure).
|
|
389
|
+
|
|
390
|
+
- The nine adapters now run **eager**, which is byte-identical to 1.6.0 and the
|
|
391
|
+
only mode comparable to the reference libraries -- alien-signals, preact,
|
|
392
|
+
vue-reactivity and solid all deliver eagerly. SAB is the right mode for
|
|
393
|
+
Andrii's `update*` group (observers but no effects), which is what
|
|
394
|
+
`harness/perf-probe.mjs` and `harness/toe-to-toe/` are for, not this harness.
|
|
395
|
+
- A **VALIDITY GUARD** was added: any scenario finishing with a dead sink now
|
|
396
|
+
prints an `INVALID RUN` block naming the offending rows and sets a non-zero
|
|
397
|
+
exit code. The old code computed the `sink=[x]` / `[ ]` column and then ignored
|
|
398
|
+
it. Silence was the bug.
|
|
399
|
+
- **Every number in `results.txt` and `bench/bench-runs/` predating this fix is
|
|
400
|
+
invalid and must be regenerated.** `bench/benchmarkReactive.mjs` is
|
|
401
|
+
**unaffected**: it also sets `"sab"`, but it drives every write through
|
|
402
|
+
`withBatch(...)`, and batch exit *does* auto-flush in SAB mode -- verified
|
|
403
|
+
clean against 1.7.0 (cellx vectors matched, all internal assertions pass).
|
|
404
|
+
|
|
405
|
+
**Harness wiring restored and extended.** `profile:burst` / `profile:pull`
|
|
406
|
+
pointed at `burst-dag.mjs` / `pull-stress.mjs` in the repo root, where neither
|
|
407
|
+
file has lived since 1.6; both now resolve into `harness/`. The dispatcher
|
|
408
|
+
(`harness/run.mjs`) gained `smoke`, `perf`, `burst`, `pull` and `toe`, and the
|
|
409
|
+
`harness:*` scripts plus `gate` / `prepublishOnly` (VersionMatrix) and
|
|
410
|
+
`test:harness` (ProfilerTools) are wired in `package.json` again. `harness:smoke`
|
|
411
|
+
now leads `harness:all` and `npm run verify`, because it is the only probe that
|
|
412
|
+
**asserts** -- a `flushStrategy` regression fails in a second instead of after
|
|
413
|
+
twenty minutes of timed probes.
|
|
414
|
+
|
|
415
|
+
**Scratch directories folded in.** `tmp/`, `tmp2/` and `tmp3/` are gone:
|
|
416
|
+
|
|
417
|
+
- `tmp3/toe-to-toe.mjs` + `runner.mjs` -> `harness/toe-to-toe/`. This is the
|
|
418
|
+
corrected cross-version sweep and it supersedes the sbench driver: it replaces
|
|
419
|
+
sequential ordering with round-robin (the old loop ran the newest engine last,
|
|
420
|
+
on the hottest chassis, which is why three sha256-**identical** propagation
|
|
421
|
+
bodies appeared to trend across 1.9 -> 1.11), adds a `1.6.0-sentinel` drift
|
|
422
|
+
column, and fixes the **silent corrupter** -- `if (mode === "sab" && engineDir
|
|
423
|
+
=== "v17")` meant only v17 ever received `flushStrategy: "sab"`, while every
|
|
424
|
+
later engine was *labelled* sab and batch-wrapped but built **eager**. Its
|
|
425
|
+
`engines/` dir is gitignored: several snapshots are unreleased, so the sweep
|
|
426
|
+
script is public and the engine source is not.
|
|
427
|
+
- `tmp/sbench-driver.mjs` + `sbench-runner.mjs` -> `harness/attic/` (superseded).
|
|
428
|
+
Their output stands, though: in that sweep v17 was the only `sab` combo, so the
|
|
429
|
+
corrupter was accidentally correct there. Preserved as
|
|
430
|
+
`harness/toe-to-toe/sbench-results-1.7.0.txt`.
|
|
431
|
+
- `tmp2/TESTING-SAB-METHODOLOGY.md` -> `harness/`; `tmp2/sink-check.mjs` ->
|
|
432
|
+
`harness/attic/` (redundant -- `harness/smoke.mjs` covers eager/sab/manual and
|
|
433
|
+
asserts). `tmp/Signal.js` (a stale 1.7.0-WIP snapshot) and the duplicated
|
|
434
|
+
`CHANGELOG-1.7.0.md` / `ROADMAP` copies are dropped.
|
|
435
|
+
- Root loose files cleaned: `owner-hazard-repro.mjs` (a formatting-only duplicate
|
|
436
|
+
of the `harness/` copy) removed; `retracking.difftest.mjs` moved into
|
|
437
|
+
`harness/` and **fixed** -- it imported a hard-coded `./1.1.6.js` that does not
|
|
438
|
+
exist in this tree, so it could not run at all; it now takes
|
|
439
|
+
`<reference.js> [candidate.js]` on the command line.
|
|
440
|
+
|
|
441
|
+
`Signal.js` and the published `files[]` whitelist are untouched by any of the
|
|
442
|
+
above; installed tarballs are byte-identical.
|
|
443
|
+
|
|
7
444
|
## [1.6.0] -- 2026-06-26 (preview)
|
|
8
445
|
|
|
9
446
|
The observability-and-lifecycle minor, shipping on the `preview` dist-tag while it
|
|
@@ -109,7 +546,7 @@ they produce are reproducible, comparable, and engine-version-aware.
|
|
|
109
546
|
|
|
110
547
|
- **Full suite green** against the 1.6.0 engine: 443 tests, 442 pass, 0 fail,
|
|
111
548
|
1 skip (only the architecturally-N/A SSR case in `17-reactivity`). +4
|
|
112
|
-
`createScope` tests in `test/
|
|
549
|
+
`createScope` tests in `test/29-scope.test.mjs`; the 1.5.0 box and createRoot
|
|
113
550
|
suites carry forward unchanged. **Coverage** (c8@11, Node 22): `Signal.js`
|
|
114
551
|
100% statements / 96.96% branches / 100% functions / 100% lines; `Watch.js`
|
|
115
552
|
100% across all four. The branch drop vs 1.5.0 (97.35% -> 96.96%) is the
|
|
@@ -194,7 +631,7 @@ dependency and updates correctly; a `computedBox` that reads a callable
|
|
|
194
631
|
the introspection surface all apply uniformly -- a box node is indistinguishable
|
|
195
632
|
from a callable node to the graph, the owner tree, and devtools.
|
|
196
633
|
|
|
197
|
-
### Added -- `test/24-
|
|
634
|
+
### Added -- `test/24-signalbox.test.mjs` activated (9 tests)
|
|
198
635
|
|
|
199
636
|
The suite that was committed-but-skipped since 1.3.0 now runs against the real
|
|
200
637
|
implementation: box get/set/peek/update, computedBox derive + memoize,
|
|
@@ -241,7 +678,7 @@ survives consumer re-runs.
|
|
|
241
678
|
- **Full suite green** against the 1.5.0 engine: 439 tests, 438 pass, 0 fail,
|
|
242
679
|
1 skip (only the architecturally-N/A SSR case in `17-reactivity`; the 9
|
|
243
680
|
`24-signalbox` tests are now active, +6 `createRoot` tests in
|
|
244
|
-
`test/27-create-
|
|
681
|
+
`test/27-create-root.test.mjs`, +3 box-coverage tests). **Coverage** (c8@11,
|
|
245
682
|
Node 22): `Signal.js` 100% statements / 97.35% branches / 100% functions / 100%
|
|
246
683
|
lines; `Watch.js` 100% across all four.
|
|
247
684
|
- **Box hot path is zero-GC**: 200,000 writes through a 256-wide box graph,
|
|
@@ -476,7 +913,7 @@ What `createNode` still writes are the *lifetime* writes for the new resident:
|
|
|
476
913
|
the new lifetime), plus the conditional owner-adoption splice
|
|
477
914
|
(`owner`, `nextOwned`, parent chain link).
|
|
478
915
|
|
|
479
|
-
### Added -- `test/10-free-list-
|
|
916
|
+
### Added -- `test/10-free-list-invariant.test.mjs`
|
|
480
917
|
|
|
481
918
|
A three-test invariant suite that asserts the audit's claim by inspecting
|
|
482
919
|
freshly-allocated nodes' underlying field state (via the documented
|
|
@@ -494,7 +931,7 @@ If any future change reintroduces a write to a clean-state field on the
|
|
|
494
931
|
dispose path or removes a write that turns out NOT to be redundant, this
|
|
495
932
|
suite catches it.
|
|
496
933
|
|
|
497
|
-
### Added -- `test/11-devtools-
|
|
934
|
+
### Added -- `test/11-devtools-contract.test.mjs`
|
|
498
935
|
|
|
499
936
|
A 12-test smoke probe of the introspection surface that lite-devtools 1.1 /
|
|
500
937
|
lite-studio 1.1 consume. Verifies handle resolution + walkers, owner-tree
|
|
@@ -841,7 +1278,7 @@ over 1.1.4, no breaking changes.
|
|
|
841
1278
|
shape kept uniform (monomorphic). **Zero steady-state cost.**
|
|
842
1279
|
|
|
843
1280
|
### Test suite
|
|
844
|
-
- Added `test/15-
|
|
1281
|
+
- Added `test/15-identity.test.mjs`: 5 tests -- ids unique + stable, `nodeId`/`describe`
|
|
845
1282
|
undefined on non-handles, descriptor shape `{ id, kind, value }`, descriptors re-walkable,
|
|
846
1283
|
identity walks non-perturbing.
|
|
847
1284
|
|
|
@@ -893,7 +1330,7 @@ All accept a public `Signal`/`Computed` handle.
|
|
|
893
1330
|
on a non-handle argument; `observeObservers` throws `TypeError`.
|
|
894
1331
|
|
|
895
1332
|
### Test suite
|
|
896
|
-
- Added `test/13-
|
|
1333
|
+
- Added `test/13-introspection.test.mjs`: 10 tests across 3 describe blocks --
|
|
897
1334
|
`hasObservers` (live observation reflects, peek doesn't count), `observeObservers`
|
|
898
1335
|
auto-pause lifecycle (start-on-first/stop-on-last, no extra connect for a 2nd
|
|
899
1336
|
observer, re-observe fires again, no churn on re-track, conditional reads toggle
|
|
@@ -937,7 +1374,7 @@ allocation on whether the read will actually subscribe anything.
|
|
|
937
1374
|
Roughly 1-2 ns per call.
|
|
938
1375
|
|
|
939
1376
|
### Test suite
|
|
940
|
-
- Added `test/10-is-
|
|
1377
|
+
- Added `test/10-is-tracking.test.mjs`: 11 tests across 5 describe blocks --
|
|
941
1378
|
observer-bodies (effect + computed), untracked windows (`untrack`, `subscribe`
|
|
942
1379
|
callback, `onCleanup`, `watch` callback), outside-observer (module scope,
|
|
943
1380
|
call-site of unobserved computed read), robustness (state restored after
|