@zakkster/lite-signal 1.6.0-alpha.0 → 1.6.0-alpha.1
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 +35 -0
- package/README.md +27 -27
- package/Signal.js +29 -1
- package/llms.txt +37 -36
- package/package.json +6 -7
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,41 @@ 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
|
+
### Fixed -- dangling re-tracking cursor on source disposal (crash)
|
|
10
|
+
|
|
11
|
+
Disposing a signal/computed from inside an observer that had linked it on the
|
|
12
|
+
previous run, but had not yet re-read it on the current run, crashed with
|
|
13
|
+
`TypeError: Cannot set properties of null (setting 'headSub')`. `disposeNode`'s
|
|
14
|
+
sub-list teardown freed the link while the observer's re-tracking cursor
|
|
15
|
+
(`activeObserverCurrentDep`) was still parked on it; `severTail` then walked from
|
|
16
|
+
a freed link, wiped the observer's `headDep`, and double-freed the link. Reachable
|
|
17
|
+
from the plain public API (see `COVERAGE-NOTES.md` for the repro). Fixed with a
|
|
18
|
+
one-line cursor repair in `disposeNode` (advance the cursor to the next surviving
|
|
19
|
+
dep before the free); O(1), disposal path only, no steady-state cost. The now-dead
|
|
20
|
+
`freeLink` `-1` defensive ternaries were removed with it. Pinned by a regression
|
|
21
|
+
test in `test/12-coverage.test.mjs`.
|
|
22
|
+
|
|
23
|
+
**Hot-path parity note:** this touches `disposeNode` and `freeLink`, so their
|
|
24
|
+
sha256 no longer matches the `1.6.0-alpha.0` baseline. The steady-state read /
|
|
25
|
+
propagation bodies (`pullComputed`, `markDownstream`, `executeEffect`,
|
|
26
|
+
`flushEffects`, `allocateLink`, `severTail`, `createNode`, `runCleanup`) are
|
|
27
|
+
unchanged. Re-baseline the VersionMatrix engine sha256 on the next publish.
|
|
28
|
+
|
|
29
|
+
### Changed -- branch coverage closed to 100%
|
|
30
|
+
|
|
31
|
+
Branch coverage on `Signal.js` went `96.96% -> 100%`. The gap the `1.6.0-alpha.0`
|
|
32
|
+
notes described -- the hook-attached side of the new op-6 / op-7 gates, which the
|
|
33
|
+
active suite never exercised because it never attached a hook -- is now closed by
|
|
34
|
+
a test that attaches a mutation hook and asserts both opcodes fire on the flush
|
|
35
|
+
path. Alongside it: the three reachable branches ported from the 1.4.0-rc pass
|
|
36
|
+
(`allocateLink` dead-target, `executeEffect` scheduler re-entrancy, `computed`
|
|
37
|
+
stale-handle read), the 1.5.0 box + owner surface (box stale-handle guards,
|
|
38
|
+
`computedBox` `equals`, top-level `getOwner` / `runWithOwner`), and the two
|
|
39
|
+
provably-unreachable clamps (link-ledger, `batchEpoch` wraparound) now carrying
|
|
40
|
+
`/* c8 ignore */` with proofs. See `COVERAGE-NOTES.md`; reconfirm under codify.
|
|
41
|
+
|
|
7
42
|
## [1.6.0-alpha.0] -- 2026-07-XX
|
|
8
43
|
|
|
9
44
|
The observability-and-lifecycle minor, shipping on the `alpha` dist-tag while it
|
package/README.md
CHANGED
|
@@ -792,32 +792,32 @@ Three tiers, all reproducible.
|
|
|
792
792
|
|
|
793
793
|
`npm test` runs the suite in `test/`, covering:
|
|
794
794
|
|
|
795
|
-
- **`01-
|
|
796
|
-
- **`02-
|
|
797
|
-
- **`03-
|
|
798
|
-
- **`05-
|
|
799
|
-
- **`06-nested-
|
|
800
|
-
- **`07-
|
|
801
|
-
- **`08-
|
|
802
|
-
- **`09-
|
|
803
|
-
- **`10-is-
|
|
804
|
-
- **`11-adopted-
|
|
805
|
-
- **`12-
|
|
806
|
-
- **`13-
|
|
807
|
-
- **`14-lifecycle-
|
|
808
|
-
- **`15-owner-lazy-
|
|
809
|
-
- **`16-alien-
|
|
810
|
-
- **`17-
|
|
811
|
-
- **`18-
|
|
812
|
-
- **`19-v12-
|
|
813
|
-
- **`20-axis-
|
|
814
|
-
- **`21-perf-
|
|
815
|
-
- **`22-mutation-
|
|
816
|
-
- **`23-owner-
|
|
817
|
-
- **`24-
|
|
818
|
-
- **`27-create-
|
|
819
|
-
- **`25-devtools-real-
|
|
820
|
-
- **`26-free-list-
|
|
795
|
+
- **`01-core.test.mjs`** -- signal/computed/effect basics, equality semantics, NaN/+/-0, subscribe/peek/update, untrack, batch, cleanup ordering, first-run error recovery, nested object reference-identity gotchas.
|
|
796
|
+
- **`02-topology.test.mjs`** -- diamond glitch-freedom, 256-deep and 1024-deep computed chains, wide fan-out (1000 effects from one signal), dynamic dependency switching, conditional fan-out, nested effects, cycle detection (`CycleError`).
|
|
797
|
+
- **`03-pool.test.mjs`** -- `CapacityError` under both `"throw"` and `"grow"` policies, the 16× link ceiling, stable pool reuse across thousands of create/dispose cycles, registry isolation, (1.3.0) the lazy-prealloc paths: on-demand construction reaching the same steady state as eager, a never-allocated lazy registry surviving `destroy()`, and `"grow"` extending both pool ledgers past their initial capacity, and (1.4.0) the `stats()` lifecycle counters: the 11-key shape, `totalAllocations` / `totalDisposals` tracking the `activeNodes` live invariant, `poolGrowths` firing on growth and staying 0 on a correctly-sized eager pool, and `destroy()` resetting all three.
|
|
798
|
+
- **`05-scheduler.test.mjs`** -- scheduler-deferred effects, dispose-during-schedule races, microtask integration, 32-bit version wrap (simulated), `setDefaultRegistry`, `onCleanup` inside computeds.
|
|
799
|
+
- **`06-nested-objects.test.mjs`** -- array mutation patterns (push/splice/spread), deep nested paths, Map/Set/Date inside signals, custom structural equality, computed memoisation cutoffs over object slices, signal-of-signals composition, high-frequency object updates, batched immutable updates.
|
|
800
|
+
- **`07-dispose.test.mjs`** -- unified `dispose(api)` across signals, computeds and effect handles, idempotency, cross-registry isolation (per-registry Symbol prevents pool corruption), foreign-value safety, top-level helper routing, 500-cycle balanced churn leaving pool and stats stable.
|
|
801
|
+
- **`08-watch.test.mjs`** -- Validates the user-land observer utilities (watch, when, whenAsync). Covers lifecycle teardown, old/new value tracking, and Promise-based asynchronous state resolution.
|
|
802
|
+
- **`09-conformance.test.mjs`** -- Industry-standard conformance tests. Validates the engine against extreme edge cases from the johnsoncodehk reactive test suite, ensuring strict zero-GC invariants, correct cleanup isolation, and re-entrant stability.
|
|
803
|
+
- **`10-is-tracking.test.mjs`** -- The `isTracking()` observer-context predicate. 11 tests across 5 describe blocks: true inside effect/computed bodies; false inside `untrack`, `subscribe` callbacks, `onCleanup` bodies, and `watch` callbacks (the untracked-window cases that catch an observer-only misimplementation); false outside any observer including at the call site of an unobserved computed read; state-restoration after a thrown body; per-registry isolation; top-level binding.
|
|
804
|
+
- **`11-adopted-reactive.test.mjs`** -- 24 engine-agnostic edge cases adopted from across the ecosystem: alien-signals' parent-child link-integrity regression (#226-228), equality-predicate corners (preact/solid/vue), `signal.update(fn)` functional setter (vue/solid), `peek()` non-subscription depth (preact/vue), and the `subscribe` behavioral contract (preact/mobx).
|
|
805
|
+
- **`12-coverage.test.mjs`** -- 34 targeted exercises for public surface and hot-path branches the behavioral suites don't incidentally hit: top-level routing to the default registry, the computed clean-read short-circuit (`markEpoch` O(1) skip), dependency-set shrink severing the stale tail, error/structural edge paths, scheduler ABA across a recycled pool slot, and the v1.2 owner-tree paths (direct-child detach, cascade tolerates an already-freed child). The coverage-closure block adds: the `allocateLink` dead-target gate, the `executeEffect` scheduler-reentrancy cycle throw, the `computed` stale-handle read, the `disposeNode` cursor-repair regression (the dangling-cursor crash fix), the box stale-handle guards (`boxUpdate`/`boxComputedGet`/`boxComputedPeek`), the `computedBox` `equals` option, the top-level `getOwner`/`runWithOwner` delegators, and the 1.6.0 flush-path opcodes (op 7 effect-enqueue, op 6 flush-pass) on the hook-attached branch. Capability-gated via runtime probes, so the same file runs unchanged across engines.
|
|
806
|
+
- **`13-introspection.test.mjs`** -- The observer-lifecycle surface (1.1.4). 10 tests across 3 describe blocks: `hasObservers` (live observation reflects; a peek doesn't count), `observeObservers` auto-pause lifecycle (start-on-first / stop-on-last, no extra connect for a 2nd observer, re-observe fires again, no churn on re-track, conditional reads toggle honestly, transition-only registration, works for computeds), and `forEachObserver`/`forEachSource` enumeration (both directions; descriptor carries kind + value).
|
|
807
|
+
- **`14-lifecycle-teardown.test.mjs`** -- Effect-teardown guards against the alien-signals@3.2.1 regressions (4 tests). A stopped effect must not re-subscribe to a signal read later in the same run; self-dispose must leave no orphaned link (clean `activeLinks`); a throwing setup must leave no live subscription; normal and dynamic re-tracking stay unaffected by the `allocateLink` eligibility gate.
|
|
808
|
+
- **`15-owner-lazy-alloc.test.mjs`** -- Owner-adoption contract for the 1.2.0 owner tree (5 tests). A signal allocated lazily *inside* a computed/effect must **not** be owner-adopted (it survives the owner's re-run -- the lite-store/lite-form lazy-field shape) and sibling lazy signals must not cross-wire, while observers (nested effect/computed) *are* still auto-disposed on the owner's re-run.
|
|
809
|
+
- **`16-alien-parity.test.mjs`** -- Differential regression guards (3 tests) reproducing the *properties* behind alien-signals@3.2.0 fixed bugs: reads inside a cleanup create no spurious dependencies (the dispose-cleanup fix); an inner-effect write does not block later propagation through a computed chain (#112); a dynamic dependency-set change stays correct under dirty-check (#109/#110).
|
|
810
|
+
- **`17-reactivity.test.mjs`** -- Behavioral suite (~30 tests across 11 groups) mirroring universal signal-system bug classes: subscription lifecycle, cleanup ordering, stale-dependency tracking, batching/timing (incl. set-then-revert), equality cutoff (NaN/+/-0/custom), nested invalidation + glitch-free diamond, memory/retained nodes, the synchronous async-boundary, scheduler & loops (self-write termination, self-reading computed), and differential-review additions (cached computed errors, mid-batch pull, self-disposing getter, pooled-slot return). SSR hydration is a documented N/A -- lite has no DOM layer.
|
|
811
|
+
- **`18-identity.test.mjs`** -- Node identity (1.1.5; 5 tests). Unique/stable ids; `nodeId`/`describe` return `undefined` for a non-handle; the descriptor's visible shape is `{ id, kind, value }`; `forEach*` descriptors carry `id` and are **re-walkable** (`nodeId`/`forEachSource` accept a descriptor); identity walks are non-perturbing (add no observers).
|
|
812
|
+
- **`19-v12-additions.test.mjs`** -- v1.2.0 release-prep regressions (24 tests across 8 suites). Shared `peek` (one closure per registry, identical reference across primitives, no tracking, two registries hold independent peeks). Owner-adoption rule (signals not adopted, computeds/effects adopted, cascade drains correctly). Pre-batch revert (signal-level, propagates through computeds, respects custom `equals`, nested batches, final-different-value still fires). Multi-throw aggregation (`AggregateError` with both errors carried, single-throw unwrapped, engine survives). `CycleError` via `maxFlushPasses` (default + custom). `maxLinks` config branch under `throw` and `grow`. Documented disposed-signal semantics (read undefined, set silent no-op, dispose idempotent). Scheduler-thunk ABA guard across a recycled pool slot.
|
|
813
|
+
- **`20-axis-stress.test.mjs`** -- engine-invariant regression guards along eight orthogonal "axes" (16 tests across 9 suites). Pins lite-signal's actual contract on: batch semantics under exception (writes commit; pre-batch revert holds; effects see the post-throw value), connect/disconnect lifecycle re-entrancy (`observeObservers` from inside an `onConnect`, transition-only registration), untrack does NOT suppress owner adoption (a nested effect created via `untrack` is still owner-cascaded), untrack inside a computed body (no hidden dep leaks; tracked source re-evaluates), queue safety under self-dispose mid-flush (no UAF), value-dependent cycle detection (computed graph closes a cycle, `CycleError` thrown), nested-effect creation order (effects run synchronously on creation; immediately-stopped one still ran), synchronous flush (no scheduler in the default path; batch coalesces). Plus a bonus suite: 1,000 effect-create-then-dispose cycles return pool to baseline; `dispose()` idempotent; `dispose()` on foreign values safe.
|
|
814
|
+
- **`21-perf-pins.test.mjs`** -- v1.2.1 construction-shape pins (6 tests). Locks the canonical handle shapes (`signal` 6 own props: peek/set/update/subscribe + NODE_PTR/NODE_GEN; `computed` 4: peek/subscribe + NODE_PTR/NODE_GEN) so a future "let's unify them" change has to be explicit. Locks the 1.2.1 ABA guards: detached `const {set} = signal()` keeps working on a LIVE signal; `read()` returns `undefined` and skips dep-tracking on a stale handle (no phantom subscription to the recycled slot); `set()` on a stale handle is a no-op across three corruption tiers (disposed slot, recycled slot, downstream propagation); `peek()` returns `undefined` for stale signal and computed handles.
|
|
815
|
+
- **`22-mutation-hook.test.mjs`** -- 1.2.1 `onGraphMutation` semantics (12 tests across 2 suites). Registration: unsubscribe returns a function; `null` argument clears and the unsub restores the prior listener; non-function/non-null throws `TypeError`; multiple registrations stack LIFO; registries are isolated (no cross-talk). Opcode emission: `1` node-create fires with `(id, flags)` for signal (32) / computed (1) / effect (2); `2` node-dispose fires for cascade-disposed owned children; `3` link-add fires with `(source.id, target.id)` on dependency record; `4` link-remove fires when a dep-set flip severs the tail; `5` recompute fires on initial eval AND re-eval; the hook fires synchronously inside the mutation (listener sees its own event before the caller returns); payload is always three plain numbers -- no objects, no closures.
|
|
816
|
+
- **`23-owner-introspection.test.mjs`** -- 1.2.1 owner-tree introspection + effect-disposer regression (22 tests across 4 suites). `ownerOf`: undefined for top-level / garbage input / stale handle; returns the enclosing effect's descriptor for a child created inside an effect body. `forEachOwned`: no-op for handles with no owned children / garbage input / stale handle; iterates owned children as `{id, kind, value}` descriptors. Gen-guarded introspection (ABA fix): `nodeId` / `describe` / `hasObservers` return undefined / false for stale handles; `observeObservers` throws `TypeError`; `forEachObserver` / `forEachSource` are no-ops; descriptors returned by `describeNode` are themselves gen-stamped so a descriptor obtained pre-recycle correctly walks as a no-op post-recycle (the "descriptors are re-walkable handles" contract survives the guard). Plus the 1.2.1 effect-dispose-handle fix: passing the effect's disposer directly to `describe` / `nodeId` / `forEachSource` / `forEachOwned` / `ownerOf` / `hasObservers` works as a first-class introspection handle (pre-fix it was a bare closure and returned `undefined` for a *live* effect); after `fx()` dispose the same handle correctly goes stale on every entry point; the disposer's `NODE_GEN` mirrors the effect node's birthGen exactly.
|
|
817
|
+
- **`24-signalbox.test.mjs`** -- the `signalBox` / `computedBox` allocation-light handle API, **activated in 1.5.0** (committed `{skip:true}` since 1.3.0, now running against the real implementation). 12 tests: box get/set/peek/update, `computedBox` derive + memoize, peek-does-not-track, subscribe fires-and-untracks, box<->callable interop both directions, batch coalescing (including set-then-revert net no-op), dispose with ABA-safety, the `equals` short-circuit, `computedBox.peek`, and the top-level helpers bound to the default registry.
|
|
818
|
+
- **`27-create-root.test.mjs`** -- `createRoot` (1.5.0), the ownership escape hatch. A watcher spawned inside a consumer effect via `createRoot` survives the consumer's re-run (the exact `lite-query` lazy-watcher pattern); the contrast case confirms an *unwrapped* spawn is cascade-disposed; `createRoot` returns `fn`'s value, detaches tracking in `fn`'s direct body while inner effect bodies still track, and composes with box handles.
|
|
819
|
+
- **`25-devtools-real-boot.test.mjs`** -- Devtools/Studio contract (10 tests). Boots the actual `Devtools.js` against the 1.5.0 engine and exercises all 19 Devtools exports plus the 10 symbols Studio imports from Devtools. Pins the ghost contract: heavy introspection (graph walk, owner-tree, observer descriptors) adds **zero** nodes to the live graph. Catches the real-rig failure mode where importing the package by its own name from a repo whose `package.json` declares `name: "@zakkster/lite-signal"` resolves to the published build instead of the local engine.
|
|
820
|
+
- **`26-free-list-invariant.test.mjs`** -- the 1.2.2 audit's cleanliness pins (3 invariant tests + 1 targeted coverage test). Asserts directly -- by inspecting freshly-allocated nodes through the documented `describe()` -> `NODE_PTR` introspection protocol -- that the `ReactiveNode` constructor and the fresh-pool-growth path initialize the ten fields the audit removed from `createNode` to identical values, so the deleted writes were defending against a state the engine cannot produce on a clean free list. The 4th test covers the swallow-on-self-dispose-then-throw branch in `pullComputed` (the path that lifted branch coverage from 98.07% to 98.43%).
|
|
821
821
|
|
|
822
822
|
```bash
|
|
823
823
|
npm test
|
|
@@ -825,7 +825,7 @@ npm test
|
|
|
825
825
|
|
|
826
826
|
### Tier 2 -- Memory (allocation-free verification)
|
|
827
827
|
|
|
828
|
-
`npm run test:gc` runs `test/04-zero-
|
|
828
|
+
`npm run test:gc` runs `test/04-zero-gc.test.mjs` with `--expose-gc`:
|
|
829
829
|
|
|
830
830
|
- 100,000 `set()` calls on a graph with effects retain **< 200 KB** of heap.
|
|
831
831
|
- 1,000 create/dispose cycles retain **< 50 KB**.
|
package/Signal.js
CHANGED
|
@@ -385,6 +385,14 @@ export function createRegistry(config) {
|
|
|
385
385
|
if (linkPool.length > currentLinkCapacity) {
|
|
386
386
|
let doubled = currentLinkCapacity;
|
|
387
387
|
while (doubled < linkPool.length) doubled *= 2;
|
|
388
|
+
// The `> maxLinkLimit` arm is provably unreachable, retained as a clamp.
|
|
389
|
+
// Proof: maxLinkLimit === initialLinkCapacity * 16, currentLinkCapacity is
|
|
390
|
+
// only ever assigned a power-of-2 multiple of that same initial capacity,
|
|
391
|
+
// so 16x is ON the doubling chain (m, 2m, 4m, 8m, 16m). The guard above
|
|
392
|
+
// (`linkPool.length >= maxLinkLimit -> CapacityError`) plus the chunk math
|
|
393
|
+
// (`chunk = limit - linkPool.length`) cap linkPool.length AT maxLinkLimit,
|
|
394
|
+
// so `doubled` terminates at exactly 16m and can never exceed it.
|
|
395
|
+
/* c8 ignore next -- unreachable clamp; see proof above + COVERAGE-NOTES.md */
|
|
388
396
|
currentLinkCapacity = doubled > maxLinkLimit ? maxLinkLimit : doubled;
|
|
389
397
|
statPoolGrowths++; // 1.4: link capacity ledger crossed
|
|
390
398
|
}
|
|
@@ -417,7 +425,12 @@ export function createRegistry(config) {
|
|
|
417
425
|
|
|
418
426
|
/** Return a link to the free pool and unlink it from the source's sub list. @private */
|
|
419
427
|
function freeLink(link, target, source) {
|
|
420
|
-
|
|
428
|
+
// Every caller (allocateLink sever, severTail, disposeNode dep-walk) passes a
|
|
429
|
+
// LIVE link: `source === link.source`, `target === link.target`. The 1.3.x
|
|
430
|
+
// `link.source !== null ? ... : -1` guards existed only to survive a cursor
|
|
431
|
+
// dangling at an already-freed link -- a state disposeNode's CURSOR REPAIR now
|
|
432
|
+
// makes unreachable. Reading the params directly is equivalent and branch-free.
|
|
433
|
+
if (mutationHook !== null) mutationHook(4, source.id, target.id);
|
|
421
434
|
const pSub = link.prevSub;
|
|
422
435
|
const nSub = link.nextSub;
|
|
423
436
|
if (pSub !== null) pSub.nextSub = nSub; else source.headSub = nSub;
|
|
@@ -528,6 +541,17 @@ export function createRegistry(config) {
|
|
|
528
541
|
if (pDep !== null) pDep.nextDep = nDep; else target.headDep = nDep;
|
|
529
542
|
if (nDep !== null) nDep.prevDep = pDep; else target.tailDep = pDep;
|
|
530
543
|
|
|
544
|
+
// CURSOR REPAIR (1.4.0): `target` may be an observer that is MID-RUN with
|
|
545
|
+
// its re-tracking cursor parked on this very link -- it linked `source` on
|
|
546
|
+
// the previous run, has not reached that read yet on this one, and now
|
|
547
|
+
// disposes `source` from its own body. Splicing the link out and handing it
|
|
548
|
+
// to the free list would leave activeObserverCurrentDep dangling at a freed
|
|
549
|
+
// slot: severTail would then read a nulled prevDep, wipe target.headDep
|
|
550
|
+
// (orphaning every surviving dep), and double-free the link -- freeLink
|
|
551
|
+
// null-derefs on `source.headSub`. Advance the cursor to the next surviving
|
|
552
|
+
// dep instead. Disposal path only; no steady-state cost.
|
|
553
|
+
if (activeObserverCurrentDep === sLink) activeObserverCurrentDep = nDep;
|
|
554
|
+
|
|
531
555
|
sLink.source = null;
|
|
532
556
|
sLink.target = null;
|
|
533
557
|
sLink.prevDep = null;
|
|
@@ -1405,6 +1429,10 @@ export function createRegistry(config) {
|
|
|
1405
1429
|
function batch(fn) {
|
|
1406
1430
|
if (batchDepth === 0) {
|
|
1407
1431
|
batchEpoch = (batchEpoch + 1) | 0;
|
|
1432
|
+
// 2^32 wraparound sentinel: batchEpoch is bumped ONLY here (and reset to 1 by
|
|
1433
|
+
// destroy()), so reaching 0 costs 4,294,967,295 top-level batch() calls. Kept
|
|
1434
|
+
// because revertEpoch comparisons treat 0 as "no capture".
|
|
1435
|
+
/* c8 ignore next -- 2^32 wraparound; unreachable without ~4.3e9 batches */
|
|
1408
1436
|
if (batchEpoch === 0) batchEpoch = 1;
|
|
1409
1437
|
}
|
|
1410
1438
|
batchDepth = (batchDepth + 1) | 0;
|
package/llms.txt
CHANGED
|
@@ -176,8 +176,9 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
176
176
|
total, 438 pass, 0 fail, **1 skip** (only the architecturally-N/A SSR case in
|
|
177
177
|
`17-reactivity`; the 9 originally-staged signalBox tests are now active and
|
|
178
178
|
the suite carries +3 box-coverage additions for a 12-test file, +7 `createRoot`
|
|
179
|
-
tests in `test/27-create-
|
|
180
|
-
100% statements /
|
|
179
|
+
tests in `test/27-create-root.test.mjs`). **Coverage:** `Signal.js`
|
|
180
|
+
100% statements / 100% branches / 100% functions / 100% lines; `Watch.js` 100%
|
|
181
|
+
(coverage-closure pass; reconfirm under codify).
|
|
181
182
|
Drop-in over 1.4.0.
|
|
182
183
|
**VersionMatrix (identical-code guard, new in 1.5.0-beta):** the
|
|
183
184
|
`harness/VersionMatrix/` regression gate now records the sha256 of the engine
|
|
@@ -245,7 +246,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
245
246
|
rate (delta totalAllocations / delta t), pool-reuse ratio
|
|
246
247
|
(1 - poolGrowths*initialCap/totalAllocations), and churn without the engine
|
|
247
248
|
computing rates -- the series lite-devtools 1.2 / lite-studio 1.2 plot. **Tests:**
|
|
248
|
-
429 total, 419 pass, 0 fail, 10 skip (6 new counter tests in `test/03-
|
|
249
|
+
429 total, 419 pass, 0 fail, 10 skip (6 new counter tests in `test/03-pool.test.mjs`
|
|
249
250
|
cover the 11-key shape, the live invariant, poolGrowths firing on growth vs staying
|
|
250
251
|
0 on a sized eager pool, and destroy() reset). **Coverage:** `Signal.js` 100%
|
|
251
252
|
statements / 98.26% branches / 100% functions / 100% lines; `Watch.js` 100%.
|
|
@@ -284,8 +285,8 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
284
285
|
allocation counters (`totalAllocations` / `totalDisposals` / `poolGrowths`) remain
|
|
285
286
|
reserved for 1.4.0 and are still absent. **Tests:** 423 total, 413 pass, 0 fail,
|
|
286
287
|
10 skip (the 10 skips are 9 signalBox-staged-for-1.5.0 in
|
|
287
|
-
`test/24-
|
|
288
|
-
`17-reactivity`); 4 new pool tests in `test/03-
|
|
288
|
+
`test/24-signalbox.test.mjs` plus 1 architecturally-N/A SSR case in
|
|
289
|
+
`17-reactivity`); 4 new pool tests in `test/03-pool.test.mjs` cover the lazy
|
|
289
290
|
on-demand / never-allocated-destroy / grow-extends-ledger / link-ceiling paths.
|
|
290
291
|
**Coverage** (c8@11, Node 22): `Signal.js` 100% statements / 98.26% branches /
|
|
291
292
|
100% functions / 100% lines; `Watch.js` 100% across all four. Behavior-
|
|
@@ -303,17 +304,17 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
303
304
|
the `ReactiveNode` constructor initializes them to the same values on the
|
|
304
305
|
fresh-pool-growth path -- so the redundant writes in `createNode` were
|
|
305
306
|
defense against a state that cannot exist. **No public surface change, no
|
|
306
|
-
semantic change.** New `test/26-free-list-
|
|
307
|
+
semantic change.** New `test/26-free-list-invariant.test.mjs` (3 invariant
|
|
307
308
|
tests + 1 targeted coverage test for the swallow-on-self-dispose-then-throw
|
|
308
309
|
branch in `pullComputed`) asserts the invariant directly by inspecting
|
|
309
310
|
freshly-allocated nodes via the documented `describe()` -> `NODE_PTR`
|
|
310
|
-
introspection protocol; new `test/25-devtools-real-
|
|
311
|
+
introspection protocol; new `test/25-devtools-real-boot.test.mjs` (10 tests)
|
|
311
312
|
boots the actual `Devtools.js` against the 1.2.2 engine and pins the 1.2.x
|
|
312
313
|
introspection contract for downstream tooling, including the 8-key
|
|
313
314
|
`stats()` shape (`signals`, `computeds`, `effects`, `activeNodes`,
|
|
314
315
|
`activeLinks`, `pooledLinks`, `nodePoolCapacity`, `linkPoolCapacity`).
|
|
315
316
|
408 tests total: 398 pass, 10 skip, 0 fail (the 10 skips are 9
|
|
316
|
-
signalBox-staged-for-1.5.0 in `test/24-
|
|
317
|
+
signalBox-staged-for-1.5.0 in `test/24-signalbox.test.mjs` plus 1
|
|
317
318
|
architecturally-N/A SSR case in `17-reactivity`). Coverage on `Signal.js`:
|
|
318
319
|
100% statements / 98.43% branches / 100% functions / 100% lines; `Watch.js`
|
|
319
320
|
100% across all four (c8@11, Node 22) -- a branch-coverage gain over the
|
|
@@ -415,7 +416,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
415
416
|
own `{ id, kind, value }` descriptor, **re-walkable** (pass it back into
|
|
416
417
|
`forEachObserver`/`forEachSource` to walk the full DAG); `forEach*` descriptors now carry
|
|
417
418
|
`id`. One SMI write at allocation, node shape kept monomorphic -- **zero steady-state
|
|
418
|
-
cost**. Drop-in over 1.1.4, no breaking changes. New `test/18-
|
|
419
|
+
cost**. Drop-in over 1.1.4, no breaking changes. New `test/18-identity.test.mjs` (5 tests); plus `14-lifecycle-teardown`, `16-alien-parity`, and the `17-reactivity` behavioral suite.
|
|
419
420
|
|
|
420
421
|
- **1.1.4**: combined release -- a retracking rewrite plus an observer-lifecycle
|
|
421
422
|
introspection surface. Drop-in over 1.1.3. **Retracking:** version-stamped O(1)
|
|
@@ -426,7 +427,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
426
427
|
wide dense` 5115ms->912ms (verified by `retracking.difftest.mjs`: 20k direct + 10k batched, 0
|
|
427
428
|
disagreements; no regressions elsewhere). **Introspection:** `hasObservers`,
|
|
428
429
|
`observeObservers`, `forEachObserver`, `forEachSource` (top-level + per-registry), gated by
|
|
429
|
-
an internal counter so zero steady-state cost when unused. New `test/13-
|
|
430
|
+
an internal counter so zero steady-state cost when unused. New `test/13-introspection.test.mjs`
|
|
430
431
|
(10 tests). Internally staged as 1.1.4 + 1.1.5; ships as a single 1.1.4.
|
|
431
432
|
|
|
432
433
|
- **1.1.3**: adds `isTracking()` (top-level + per-registry). Returns true iff a
|
|
@@ -741,32 +742,32 @@ function dumpOwnerTree(handle, depth = 0) {
|
|
|
741
742
|
|
|
742
743
|
- `Signal.js` -- full implementation, single file.
|
|
743
744
|
- `Signal.d.ts` -- TypeScript declarations for all public API.
|
|
744
|
-
- `test/01-
|
|
745
|
-
- `test/02-
|
|
746
|
-
- `test/03-
|
|
747
|
-
- `test/04-zero-
|
|
748
|
-
- `test/05-
|
|
749
|
-
- `test/06-nested-
|
|
750
|
-
- `test/07-
|
|
751
|
-
- `test/08-
|
|
752
|
-
- `test/09-
|
|
753
|
-
- `test/10-is-
|
|
754
|
-
- `test/11-adopted-
|
|
755
|
-
- `test/12-
|
|
756
|
-
- `test/13-
|
|
757
|
-
- `test/14-lifecycle-
|
|
758
|
-
- `test/15-owner-lazy-
|
|
759
|
-
- `test/16-alien-
|
|
760
|
-
- `test/17-
|
|
761
|
-
- `test/18-
|
|
762
|
-
- `test/19-v12-
|
|
763
|
-
- `test/20-axis-
|
|
764
|
-
- `test/21-perf-
|
|
765
|
-
- `test/22-mutation-
|
|
766
|
-
- `test/23-owner-
|
|
767
|
-
- `test/24-
|
|
768
|
-
- `test/25-devtools-real-
|
|
769
|
-
- `test/26-free-list-
|
|
745
|
+
- `test/01-core.test.mjs` -- signal/computed/effect basics, equality, untrack.
|
|
746
|
+
- `test/02-topology.test.mjs` -- diamonds, chains, fan-out/in, cycle detection.
|
|
747
|
+
- `test/03-pool.test.mjs` -- capacity errors, grow policy, pool reuse.
|
|
748
|
+
- `test/04-zero-gc.test.mjs` -- heap retention (run with --expose-gc).
|
|
749
|
+
- `test/05-scheduler.test.mjs` -- scheduler races, dispose, gen counter, version wrap.
|
|
750
|
+
- `test/06-nested-objects.test.mjs` -- nested-object & reference-identity behaviours.
|
|
751
|
+
- `test/07-dispose.test.mjs` -- universal disposal: registry.dispose(api).
|
|
752
|
+
- `test/08-watch.test.mjs` -- new watch reactivity tests.
|
|
753
|
+
- `test/09-conformance.test.mjs` -- johnsoncodehk/reactive-framework-test-suite conformance fixes tests.
|
|
754
|
+
- `test/10-is-tracking.test.mjs` -- `isTracking()` across observer bodies, untracked windows, and outside any observer.
|
|
755
|
+
- `test/11-adopted-reactive.test.mjs` -- engine-agnostic edge cases adopted from the wider ecosystem (alien-signals link-integrity #226-228, equality-predicate corners, `update()`/`peek()`/`subscribe` contracts).
|
|
756
|
+
- `test/12-coverage.test.mjs` -- targeted public-surface + hot-path branch coverage (top-level routing, clean-read short-circuit, tail severance, scheduler ABA); owner-tree block capability-gated.
|
|
757
|
+
- `test/13-introspection.test.mjs` -- observer-lifecycle surface: `hasObservers`, `observeObservers` auto-pause, `forEach*` enumeration (10 tests).
|
|
758
|
+
- `test/14-lifecycle-teardown.test.mjs` -- effect-teardown guards: stopped effect doesn't re-subscribe to a signal read later in the same run, self-dispose leaves no orphan link, throwing setup leaves no live subscription (4 tests).
|
|
759
|
+
- `test/15-owner-lazy-alloc.test.mjs` -- owner-adoption contract for the 1.2.0 owner tree (lazy signals never adopted; observers still auto-disposed); capability-gated, skipped on 1.1.x (4 tests).
|
|
760
|
+
- `test/16-alien-parity.test.mjs` -- differential guards vs alien-signals@3.2.0 fixed-bug classes: cleanup reads create no deps, inner write doesn't block computed-chain propagation, dynamic dep-set correct under dirty-check (3 tests).
|
|
761
|
+
- `test/17-reactivity.test.mjs` -- behavioral suite over universal signal-system bug classes (subscription lifecycle, cleanup ordering, stale-dep tracking, batching, equality, nested invalidation, memory, sync async-boundary, scheduler/loops, + differential-review additions); SSR is N/A (~30 tests).
|
|
762
|
+
- `test/18-identity.test.mjs` -- node identity (1.1.5): `nodeId`/`describe`, descriptor `id`, re-walkable descriptors, non-perturbing (5 tests).
|
|
763
|
+
- `test/19-v12-additions.test.mjs` -- 1.2.0 surface coverage: shared-peek, owner-adoption rule, pre-batch revert (24 tests).
|
|
764
|
+
- `test/20-axis-stress.test.mjs` -- eight orthogonal stress axes (batch-under-exception, connect/disconnect re-entrancy, untrack vs owner cascade, etc.) (23 tests).
|
|
765
|
+
- `test/21-perf-pins.test.mjs` -- 1.2.1 construction-shape + ABA-guard pins (6 tests).
|
|
766
|
+
- `test/22-mutation-hook.test.mjs` -- 1.2.1 `onGraphMutation` registration + opcode emission (12 tests).
|
|
767
|
+
- `test/23-owner-introspection.test.mjs` -- `ownerOf`, `forEachOwned`, gen-guarded introspection (14 tests).
|
|
768
|
+
- `test/24-signalbox.test.mjs` -- staged for 1.5.0; all tests `{skip: true}` on 1.2.x.
|
|
769
|
+
- `test/25-devtools-real-boot.test.mjs` -- 1.2.2: real `Devtools.js` boot against the engine, ghost-contract pin, `stats()` shape pin (10 tests).
|
|
770
|
+
- `test/26-free-list-invariant.test.mjs` -- 1.2.2: the audit's clean-free-list invariant, asserted by inspecting freshly-allocated nodes (4 tests).
|
|
770
771
|
- `bench/benchmark.mjs` -- anti-DCE throughput harness (ops/s; results.txt).
|
|
771
772
|
- `bench/benchmarkReactive.mjs` -- cross-framework reactivity suite vs alien-signals, preact, vue-reactivity, solid (resultsReactive.txt).
|
|
772
773
|
- `bench/dispose-recycle.mjs` -- 1.2.2 targeted microbench: create/dispose/recreate cycle (the free-list invariant audit target).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zakkster/lite-signal",
|
|
3
|
-
"version": "1.6.0-alpha.
|
|
3
|
+
"version": "1.6.0-alpha.1",
|
|
4
4
|
"description": "Zero-GC reactive graph. Monomorphic object pool, versioned push-pull propagation, 32-bit modular versioning. Built for hot paths and long-running processes.",
|
|
5
5
|
"author": "Zahary Shinikchiev <shinikchiev@yahoo.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,8 +47,7 @@
|
|
|
47
47
|
"profile:burst": "node --expose-gc harness/burst-dag.mjs ./Signal.js",
|
|
48
48
|
"profile:pull": "node --expose-gc harness/pull-stress.mjs",
|
|
49
49
|
"verify": "npm test && npm run test:zgc && npm run bench",
|
|
50
|
-
"gate": "node harness/VersionMatrix/pre-publish.mjs"
|
|
51
|
-
"prepublishOnly": "node harness/VersionMatrix/pre-publish.mjs"
|
|
50
|
+
"gate": "node harness/VersionMatrix/pre-publish.mjs"
|
|
52
51
|
},
|
|
53
52
|
"keywords": [
|
|
54
53
|
"signal",
|
|
@@ -85,11 +84,11 @@
|
|
|
85
84
|
},
|
|
86
85
|
"sideEffects": false,
|
|
87
86
|
"devDependencies": {
|
|
88
|
-
"
|
|
89
|
-
"@zakkster/lite-devtools": "^1.1.0",
|
|
90
|
-
"@zakkster/lite-signal": "^1.3.0 || >=1.4.0-beta.0 || >=1.6.0-preview.0",
|
|
87
|
+
"@zakkster/lite-devtools": "^1.2.0",
|
|
91
88
|
"@zakkster/lite-profiler": "^1.1.0",
|
|
92
|
-
"@zakkster/lite-profiler-signal": "^1.2.0"
|
|
89
|
+
"@zakkster/lite-profiler-signal": "^1.2.0",
|
|
90
|
+
"@zakkster/lite-signal": "^1.3.0 || >=1.4.0-beta.0 || >=1.6.0-preview.0",
|
|
91
|
+
"c8": "^11.0.0"
|
|
93
92
|
},
|
|
94
93
|
"overrides": {
|
|
95
94
|
"@zakkster/lite-time": {
|