@zakkster/lite-signal 1.5.0-beta.4 → 1.5.0-beta.5
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 +24 -0
- package/README.md +27 -27
- package/Signal.js +29 -1
- package/llms.txt +39 -38
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,30 @@ This project follows [Semantic Versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
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
|
+
### Changed -- branch coverage closed to 100%
|
|
24
|
+
|
|
25
|
+
Branch coverage on `Signal.js` went `97.35% -> 100%`. Three reachable branches
|
|
26
|
+
gained tests (`allocateLink` dead-target gate, `executeEffect` scheduler
|
|
27
|
+
re-entrancy, `computed` stale-handle read), the new box + owner surface gained
|
|
28
|
+
tests (box stale-handle guards, `computedBox` `equals`, top-level `getOwner` /
|
|
29
|
+
`runWithOwner` delegators), and the two provably-unreachable clamps (link-ledger,
|
|
30
|
+
`batchEpoch` wraparound) carry `/* c8 ignore */` with proofs. See
|
|
31
|
+
`COVERAGE-NOTES.md`; reconfirm under codify.
|
|
32
|
+
|
|
9
33
|
### Tooling -- harness reorganization (no engine change)
|
|
10
34
|
|
|
11
35
|
The loose `harness/` probes are now routed through a single dispatcher
|
package/README.md
CHANGED
|
@@ -767,33 +767,33 @@ Three tiers, all reproducible.
|
|
|
767
767
|
|
|
768
768
|
`npm test` runs the suite in `test/`, covering:
|
|
769
769
|
|
|
770
|
-
- **`01-
|
|
771
|
-
- **`02-
|
|
772
|
-
- **`03-
|
|
773
|
-
- **`05-
|
|
774
|
-
- **`06-nested-
|
|
775
|
-
- **`07-
|
|
776
|
-
- **`08-
|
|
777
|
-
- **`09-
|
|
778
|
-
- **`10-is-
|
|
779
|
-
- **`11-adopted-
|
|
780
|
-
- **`12-
|
|
781
|
-
- **`13-
|
|
782
|
-
- **`14-lifecycle-
|
|
783
|
-
- **`15-owner-lazy-
|
|
784
|
-
- **`16-alien-
|
|
785
|
-
- **`17-
|
|
786
|
-
- **`18-
|
|
787
|
-
- **`19-v12-
|
|
788
|
-
- **`20-axis-
|
|
789
|
-
- **`21-perf-
|
|
790
|
-
- **`22-mutation-
|
|
791
|
-
- **`23-owner-
|
|
792
|
-
- **`24-
|
|
793
|
-
- **`27-create-
|
|
770
|
+
- **`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.
|
|
771
|
+
- **`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`).
|
|
772
|
+
- **`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.
|
|
773
|
+
- **`05-scheduler.test.mjs`** -- scheduler-deferred effects, dispose-during-schedule races, microtask integration, 32-bit version wrap (simulated), `setDefaultRegistry`, `onCleanup` inside computeds.
|
|
774
|
+
- **`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.
|
|
775
|
+
- **`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.
|
|
776
|
+
- **`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.
|
|
777
|
+
- **`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.
|
|
778
|
+
- **`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.
|
|
779
|
+
- **`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).
|
|
780
|
+
- **`12-coverage.test.mjs`** -- 33 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 1.5.0 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, and the top-level `getOwner`/`runWithOwner` delegators. Capability-gated via runtime probes, so the same file runs unchanged across engines.
|
|
781
|
+
- **`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).
|
|
782
|
+
- **`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.
|
|
783
|
+
- **`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.
|
|
784
|
+
- **`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).
|
|
785
|
+
- **`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.
|
|
786
|
+
- **`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).
|
|
787
|
+
- **`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.
|
|
788
|
+
- **`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.
|
|
789
|
+
- **`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.
|
|
790
|
+
- **`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.
|
|
791
|
+
- **`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.
|
|
792
|
+
- **`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.
|
|
793
|
+
- **`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.
|
|
794
794
|
- **`28-run-with-owner.test.mjs`** -- `getOwner` / `runWithOwner` (1.5.0-beta.2), the re-attach companion. 16 tests, structured in three groups: basic shape (7 tests: undefined outside, effect/computed inside, restore-on-return, throw-safety, nesting), degradation (3 tests: null / undefined / signal-handle all fall through to rooted execution), and the three **hazard pins** that a raw-pointer implementation fails: (i) recycled-slot cascade -- capture, dispose owner, allocate an effect that reuses the pool slot, `runWithOwner(captured)` must not adopt into the recycled slot's new resident; (ii) corpse adoption -- capture, dispose owner but not-yet-recycled, `runWithOwner(captured, () => effect(...))` must not crash with `RangeError` in the cleanup recursion; (iii) composed -- both together, continuation must survive stranger re-runs AND disposal. All three fail against the naive `getOwner() { return currentOwner; }` shape (empirically verified against a 1.5.0-beta engine patched with the raw-pointer alternative -- `harness/owner-hazard-repro.mjs`); all three pass with the `describeNode` gen-stamped handle + `liveNode` ABA guard that ships.
|
|
795
|
-
- **`25-devtools-real-
|
|
796
|
-
- **`26-free-list-
|
|
795
|
+
- **`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.
|
|
796
|
+
- **`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%).
|
|
797
797
|
|
|
798
798
|
```bash
|
|
799
799
|
npm test
|
|
@@ -801,7 +801,7 @@ npm test
|
|
|
801
801
|
|
|
802
802
|
### Tier 2 -- Memory (allocation-free verification)
|
|
803
803
|
|
|
804
|
-
`npm run test:gc` runs `test/04-zero-
|
|
804
|
+
`npm run test:gc` runs `test/04-zero-gc.test.mjs` with `--expose-gc`:
|
|
805
805
|
|
|
806
806
|
- 100,000 `set()` calls on a graph with effects retain **< 200 KB** of heap.
|
|
807
807
|
- 1,000 create/dispose cycles retain **< 50 KB**.
|
package/Signal.js
CHANGED
|
@@ -382,6 +382,14 @@ export function createRegistry(config) {
|
|
|
382
382
|
if (linkPool.length > currentLinkCapacity) {
|
|
383
383
|
let doubled = currentLinkCapacity;
|
|
384
384
|
while (doubled < linkPool.length) doubled *= 2;
|
|
385
|
+
// The `> maxLinkLimit` arm is provably unreachable, retained as a clamp.
|
|
386
|
+
// Proof: maxLinkLimit === initialLinkCapacity * 16, currentLinkCapacity is
|
|
387
|
+
// only ever assigned a power-of-2 multiple of that same initial capacity,
|
|
388
|
+
// so 16x is ON the doubling chain (m, 2m, 4m, 8m, 16m). The guard above
|
|
389
|
+
// (`linkPool.length >= maxLinkLimit -> CapacityError`) plus the chunk math
|
|
390
|
+
// (`chunk = limit - linkPool.length`) cap linkPool.length AT maxLinkLimit,
|
|
391
|
+
// so `doubled` terminates at exactly 16m and can never exceed it.
|
|
392
|
+
/* c8 ignore next -- unreachable clamp; see proof above + COVERAGE-NOTES.md */
|
|
385
393
|
currentLinkCapacity = doubled > maxLinkLimit ? maxLinkLimit : doubled;
|
|
386
394
|
statPoolGrowths++; // 1.4: link capacity ledger crossed
|
|
387
395
|
}
|
|
@@ -414,7 +422,12 @@ export function createRegistry(config) {
|
|
|
414
422
|
|
|
415
423
|
/** Return a link to the free pool and unlink it from the source's sub list. @private */
|
|
416
424
|
function freeLink(link, target, source) {
|
|
417
|
-
|
|
425
|
+
// Every caller (allocateLink sever, severTail, disposeNode dep-walk) passes a
|
|
426
|
+
// LIVE link: `source === link.source`, `target === link.target`. The 1.3.x
|
|
427
|
+
// `link.source !== null ? ... : -1` guards existed only to survive a cursor
|
|
428
|
+
// dangling at an already-freed link -- a state disposeNode's CURSOR REPAIR now
|
|
429
|
+
// makes unreachable. Reading the params directly is equivalent and branch-free.
|
|
430
|
+
if (mutationHook !== null) mutationHook(4, source.id, target.id);
|
|
418
431
|
const pSub = link.prevSub;
|
|
419
432
|
const nSub = link.nextSub;
|
|
420
433
|
if (pSub !== null) pSub.nextSub = nSub; else source.headSub = nSub;
|
|
@@ -525,6 +538,17 @@ export function createRegistry(config) {
|
|
|
525
538
|
if (pDep !== null) pDep.nextDep = nDep; else target.headDep = nDep;
|
|
526
539
|
if (nDep !== null) nDep.prevDep = pDep; else target.tailDep = pDep;
|
|
527
540
|
|
|
541
|
+
// CURSOR REPAIR (1.4.0): `target` may be an observer that is MID-RUN with
|
|
542
|
+
// its re-tracking cursor parked on this very link -- it linked `source` on
|
|
543
|
+
// the previous run, has not reached that read yet on this one, and now
|
|
544
|
+
// disposes `source` from its own body. Splicing the link out and handing it
|
|
545
|
+
// to the free list would leave activeObserverCurrentDep dangling at a freed
|
|
546
|
+
// slot: severTail would then read a nulled prevDep, wipe target.headDep
|
|
547
|
+
// (orphaning every surviving dep), and double-free the link -- freeLink
|
|
548
|
+
// null-derefs on `source.headSub`. Advance the cursor to the next surviving
|
|
549
|
+
// dep instead. Disposal path only; no steady-state cost.
|
|
550
|
+
if (activeObserverCurrentDep === sLink) activeObserverCurrentDep = nDep;
|
|
551
|
+
|
|
528
552
|
sLink.source = null;
|
|
529
553
|
sLink.target = null;
|
|
530
554
|
sLink.prevDep = null;
|
|
@@ -1396,6 +1420,10 @@ export function createRegistry(config) {
|
|
|
1396
1420
|
function batch(fn) {
|
|
1397
1421
|
if (batchDepth === 0) {
|
|
1398
1422
|
batchEpoch = (batchEpoch + 1) | 0;
|
|
1423
|
+
// 2^32 wraparound sentinel: batchEpoch is bumped ONLY here (and reset to 1 by
|
|
1424
|
+
// destroy()), so reaching 0 costs 4,294,967,295 top-level batch() calls. Kept
|
|
1425
|
+
// because revertEpoch comparisons treat 0 as "no capture".
|
|
1426
|
+
/* c8 ignore next -- 2^32 wraparound; unreachable without ~4.3e9 batches */
|
|
1399
1427
|
if (batchEpoch === 0) batchEpoch = 1;
|
|
1400
1428
|
}
|
|
1401
1429
|
batchDepth = (batchDepth + 1) | 0;
|
package/llms.txt
CHANGED
|
@@ -136,10 +136,11 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
136
136
|
suite (staged `{skip:true}` since 1.3.0) now runs and passes. **Tests:** 439
|
|
137
137
|
total, 438 pass, 0 fail, **1 skip** (only the architecturally-N/A SSR case in
|
|
138
138
|
`17-reactivity`; the 9 originally-staged signalBox tests are now active and
|
|
139
|
-
the suite carries
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
the suite carries box-coverage additions plus the 1.5.0 coverage-closure block
|
|
140
|
+
in `test/12-coverage.test.mjs`, and `createRoot` tests in
|
|
141
|
+
`test/27-create-root.test.mjs`). **Coverage:** `Signal.js`
|
|
142
|
+
100% statements / 100% branches / 100% functions / 100% lines; `Watch.js` 100%
|
|
143
|
+
(rc coverage pass; reconfirm under codify). Drop-in over 1.4.0.
|
|
143
144
|
**VersionMatrix (identical-code guard, new in 1.5.0-beta):** the
|
|
144
145
|
`harness/VersionMatrix/` regression gate now records the sha256 of the engine
|
|
145
146
|
source at every capture (`baselines/<label>/engine.sha256`). If the candidate's
|
|
@@ -206,7 +207,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
206
207
|
rate (delta totalAllocations / delta t), pool-reuse ratio
|
|
207
208
|
(1 - poolGrowths*initialCap/totalAllocations), and churn without the engine
|
|
208
209
|
computing rates -- the series lite-devtools 1.2 / lite-studio 1.2 plot. **Tests:**
|
|
209
|
-
429 total, 419 pass, 0 fail, 10 skip (6 new counter tests in `test/03-
|
|
210
|
+
429 total, 419 pass, 0 fail, 10 skip (6 new counter tests in `test/03-pool.test.mjs`
|
|
210
211
|
cover the 11-key shape, the live invariant, poolGrowths firing on growth vs staying
|
|
211
212
|
0 on a sized eager pool, and destroy() reset). **Coverage:** `Signal.js` 100%
|
|
212
213
|
statements / 98.26% branches / 100% functions / 100% lines; `Watch.js` 100%.
|
|
@@ -245,8 +246,8 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
245
246
|
allocation counters (`totalAllocations` / `totalDisposals` / `poolGrowths`) remain
|
|
246
247
|
reserved for 1.4.0 and are still absent. **Tests:** 423 total, 413 pass, 0 fail,
|
|
247
248
|
10 skip (the 10 skips are 9 signalBox-staged-for-1.5.0 in
|
|
248
|
-
`test/24-
|
|
249
|
-
`17-reactivity`); 4 new pool tests in `test/03-
|
|
249
|
+
`test/24-signalbox.test.mjs` plus 1 architecturally-N/A SSR case in
|
|
250
|
+
`17-reactivity`); 4 new pool tests in `test/03-pool.test.mjs` cover the lazy
|
|
250
251
|
on-demand / never-allocated-destroy / grow-extends-ledger / link-ceiling paths.
|
|
251
252
|
**Coverage** (c8@11, Node 22): `Signal.js` 100% statements / 98.26% branches /
|
|
252
253
|
100% functions / 100% lines; `Watch.js` 100% across all four. Behavior-
|
|
@@ -264,17 +265,17 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
264
265
|
the `ReactiveNode` constructor initializes them to the same values on the
|
|
265
266
|
fresh-pool-growth path -- so the redundant writes in `createNode` were
|
|
266
267
|
defense against a state that cannot exist. **No public surface change, no
|
|
267
|
-
semantic change.** New `test/26-free-list-
|
|
268
|
+
semantic change.** New `test/26-free-list-invariant.test.mjs` (3 invariant
|
|
268
269
|
tests + 1 targeted coverage test for the swallow-on-self-dispose-then-throw
|
|
269
270
|
branch in `pullComputed`) asserts the invariant directly by inspecting
|
|
270
271
|
freshly-allocated nodes via the documented `describe()` -> `NODE_PTR`
|
|
271
|
-
introspection protocol; new `test/25-devtools-real-
|
|
272
|
+
introspection protocol; new `test/25-devtools-real-boot.test.mjs` (10 tests)
|
|
272
273
|
boots the actual `Devtools.js` against the 1.2.2 engine and pins the 1.2.x
|
|
273
274
|
introspection contract for downstream tooling, including the 8-key
|
|
274
275
|
`stats()` shape (`signals`, `computeds`, `effects`, `activeNodes`,
|
|
275
276
|
`activeLinks`, `pooledLinks`, `nodePoolCapacity`, `linkPoolCapacity`).
|
|
276
277
|
408 tests total: 398 pass, 10 skip, 0 fail (the 10 skips are 9
|
|
277
|
-
signalBox-staged-for-1.5.0 in `test/24-
|
|
278
|
+
signalBox-staged-for-1.5.0 in `test/24-signalbox.test.mjs` plus 1
|
|
278
279
|
architecturally-N/A SSR case in `17-reactivity`). Coverage on `Signal.js`:
|
|
279
280
|
100% statements / 98.43% branches / 100% functions / 100% lines; `Watch.js`
|
|
280
281
|
100% across all four (c8@11, Node 22) -- a branch-coverage gain over the
|
|
@@ -376,7 +377,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
376
377
|
own `{ id, kind, value }` descriptor, **re-walkable** (pass it back into
|
|
377
378
|
`forEachObserver`/`forEachSource` to walk the full DAG); `forEach*` descriptors now carry
|
|
378
379
|
`id`. One SMI write at allocation, node shape kept monomorphic -- **zero steady-state
|
|
379
|
-
cost**. Drop-in over 1.1.4, no breaking changes. New `test/18-
|
|
380
|
+
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.
|
|
380
381
|
|
|
381
382
|
- **1.1.4**: combined release -- a retracking rewrite plus an observer-lifecycle
|
|
382
383
|
introspection surface. Drop-in over 1.1.3. **Retracking:** version-stamped O(1)
|
|
@@ -387,7 +388,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
387
388
|
wide dense` 5115ms->912ms (verified by `retracking.difftest.mjs`: 20k direct + 10k batched, 0
|
|
388
389
|
disagreements; no regressions elsewhere). **Introspection:** `hasObservers`,
|
|
389
390
|
`observeObservers`, `forEachObserver`, `forEachSource` (top-level + per-registry), gated by
|
|
390
|
-
an internal counter so zero steady-state cost when unused. New `test/13-
|
|
391
|
+
an internal counter so zero steady-state cost when unused. New `test/13-introspection.test.mjs`
|
|
391
392
|
(10 tests). Internally staged as 1.1.4 + 1.1.5; ships as a single 1.1.4.
|
|
392
393
|
|
|
393
394
|
- **1.1.3**: adds `isTracking()` (top-level + per-registry). Returns true iff a
|
|
@@ -685,32 +686,32 @@ function dumpOwnerTree(handle, depth = 0) {
|
|
|
685
686
|
|
|
686
687
|
- `Signal.js` -- full implementation, single file.
|
|
687
688
|
- `Signal.d.ts` -- TypeScript declarations for all public API.
|
|
688
|
-
- `test/01-
|
|
689
|
-
- `test/02-
|
|
690
|
-
- `test/03-
|
|
691
|
-
- `test/04-zero-
|
|
692
|
-
- `test/05-
|
|
693
|
-
- `test/06-nested-
|
|
694
|
-
- `test/07-
|
|
695
|
-
- `test/08-
|
|
696
|
-
- `test/09-
|
|
697
|
-
- `test/10-is-
|
|
698
|
-
- `test/11-adopted-
|
|
699
|
-
- `test/12-
|
|
700
|
-
- `test/13-
|
|
701
|
-
- `test/14-lifecycle-
|
|
702
|
-
- `test/15-owner-lazy-
|
|
703
|
-
- `test/16-alien-
|
|
704
|
-
- `test/17-
|
|
705
|
-
- `test/18-
|
|
706
|
-
- `test/19-v12-
|
|
707
|
-
- `test/20-axis-
|
|
708
|
-
- `test/21-perf-
|
|
709
|
-
- `test/22-mutation-
|
|
710
|
-
- `test/23-owner-
|
|
711
|
-
- `test/24-
|
|
712
|
-
- `test/25-devtools-real-
|
|
713
|
-
- `test/26-free-list-
|
|
689
|
+
- `test/01-core.test.mjs` -- signal/computed/effect basics, equality, untrack.
|
|
690
|
+
- `test/02-topology.test.mjs` -- diamonds, chains, fan-out/in, cycle detection.
|
|
691
|
+
- `test/03-pool.test.mjs` -- capacity errors, grow policy, pool reuse.
|
|
692
|
+
- `test/04-zero-gc.test.mjs` -- heap retention (run with --expose-gc).
|
|
693
|
+
- `test/05-scheduler.test.mjs` -- scheduler races, dispose, gen counter, version wrap.
|
|
694
|
+
- `test/06-nested-objects.test.mjs` -- nested-object & reference-identity behaviours.
|
|
695
|
+
- `test/07-dispose.test.mjs` -- universal disposal: registry.dispose(api).
|
|
696
|
+
- `test/08-watch.test.mjs` -- new watch reactivity tests.
|
|
697
|
+
- `test/09-conformance.test.mjs` -- johnsoncodehk/reactive-framework-test-suite conformance fixes tests.
|
|
698
|
+
- `test/10-is-tracking.test.mjs` -- `isTracking()` across observer bodies, untracked windows, and outside any observer.
|
|
699
|
+
- `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).
|
|
700
|
+
- `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.
|
|
701
|
+
- `test/13-introspection.test.mjs` -- observer-lifecycle surface: `hasObservers`, `observeObservers` auto-pause, `forEach*` enumeration (10 tests).
|
|
702
|
+
- `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).
|
|
703
|
+
- `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).
|
|
704
|
+
- `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).
|
|
705
|
+
- `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).
|
|
706
|
+
- `test/18-identity.test.mjs` -- node identity (1.1.5): `nodeId`/`describe`, descriptor `id`, re-walkable descriptors, non-perturbing (5 tests).
|
|
707
|
+
- `test/19-v12-additions.test.mjs` -- 1.2.0 surface coverage: shared-peek, owner-adoption rule, pre-batch revert (24 tests).
|
|
708
|
+
- `test/20-axis-stress.test.mjs` -- eight orthogonal stress axes (batch-under-exception, connect/disconnect re-entrancy, untrack vs owner cascade, etc.) (23 tests).
|
|
709
|
+
- `test/21-perf-pins.test.mjs` -- 1.2.1 construction-shape + ABA-guard pins (6 tests).
|
|
710
|
+
- `test/22-mutation-hook.test.mjs` -- 1.2.1 `onGraphMutation` registration + opcode emission (12 tests).
|
|
711
|
+
- `test/23-owner-introspection.test.mjs` -- `ownerOf`, `forEachOwned`, gen-guarded introspection (14 tests).
|
|
712
|
+
- `test/24-signalbox.test.mjs` -- staged for 1.5.0; all tests `{skip: true}` on 1.2.x.
|
|
713
|
+
- `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).
|
|
714
|
+
- `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).
|
|
714
715
|
- `bench/benchmark.mjs` -- anti-DCE throughput harness (ops/s; results.txt).
|
|
715
716
|
- `bench/benchmarkReactive.mjs` -- cross-framework reactivity suite vs alien-signals, preact, vue-reactivity, solid (resultsReactive.txt).
|
|
716
717
|
- `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.5.0-beta.
|
|
3
|
+
"version": "1.5.0-beta.5",
|
|
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",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"test": "node --test --test-reporter=spec 'test/*.test.mjs'",
|
|
30
30
|
"test:gc": "node --expose-gc --test --test-reporter=spec 'test/*.test.mjs'",
|
|
31
31
|
"test:coverage": "c8 node --test --test-reporter=spec 'test/*.test.mjs'",
|
|
32
|
+
"test:report": "c8 --reporter=lcov --reporter=text node --test --test-reporter=spec 'test/*.test.mjs'",
|
|
32
33
|
"test:hardening": "npm --prefix test/ProfilerTests test",
|
|
33
34
|
"test:hardening:gc": "npm --prefix test/ProfilerTests run test:gc",
|
|
34
35
|
"test:harness": "npm --prefix harness/ProfilerTools test",
|
|
@@ -43,8 +44,7 @@
|
|
|
43
44
|
"harness:creation": "node harness/run.mjs creation",
|
|
44
45
|
"harness:all": "node harness/run.mjs all",
|
|
45
46
|
"verify": "npm test && npm run bench",
|
|
46
|
-
"gate": "node harness/VersionMatrix/pre-publish.mjs"
|
|
47
|
-
"prepublishOnly": "node harness/VersionMatrix/pre-publish.mjs"
|
|
47
|
+
"gate": "node harness/VersionMatrix/pre-publish.mjs"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"signal",
|
|
@@ -81,11 +81,11 @@
|
|
|
81
81
|
},
|
|
82
82
|
"sideEffects": false,
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"
|
|
85
|
-
"@zakkster/lite-devtools": "^1.1.0",
|
|
86
|
-
"@zakkster/lite-signal": "^1.3.0 || >=1.4.0-beta.0 || >=1.6.0-preview.0",
|
|
84
|
+
"@zakkster/lite-devtools": "^1.2.0",
|
|
87
85
|
"@zakkster/lite-profiler": "^1.1.0",
|
|
88
|
-
"@zakkster/lite-profiler-signal": "^1.2.0"
|
|
86
|
+
"@zakkster/lite-profiler-signal": "^1.2.0",
|
|
87
|
+
"@zakkster/lite-signal": "^1.3.0 || >=1.4.0-beta.0 || >=1.6.0-preview.0",
|
|
88
|
+
"c8": "^11.0.0"
|
|
89
89
|
},
|
|
90
90
|
"overrides": {
|
|
91
91
|
"@zakkster/lite-time": {
|