@zakkster/lite-signal 1.10.0-preview → 1.11.0-preview

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 CHANGED
@@ -4,6 +4,82 @@ 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
+ ## [1.11.0-preview] -- 2026-09-06
8
+
9
+ **Feature of the cut: `onSettled`, rebuilt as a creation-time capability.** The
10
+ redemption of the feature whose naive always-checked drain hook was the +27-31%
11
+ 1to1batch regression (ledger #17). It returns with the cost model inverted.
12
+ This preview also carries the full verification-infrastructure parity of the
13
+ rebuilt line (assembled from the finalized 1.10.0-preview tree) and a one-time,
14
+ user-authorized engine port of the same two cold-path fixes 1.10.0 needed.
15
+
16
+ ### Added
17
+ - `createRegistry({ settled: true })` -- selects, ONCE at build time, a `flushEffects`
18
+ variant with a drain-complete tail, using the same const-selection discipline as the
19
+ 1.7.0 `flushStrategy` closures.
20
+ - `onSettled(fn)` (registry method + top-level) -- fires once per top-level, non-empty,
21
+ clean drain; returns an idempotent unsubscribe. Throws `onSettled requires
22
+ createRegistry({ settled: true })` on a registry built without the capability. Does
23
+ not fire on re-entrant flushes, empty flushes, or a flush that threw. Coalesces under
24
+ batch and multi-effect drains; callbacks fire in subscription order and a throwing
25
+ callback is swallowed (observer, not control path). Module surface: 34 exports /
26
+ registry 28 fns.
27
+ - `settled` joins the validated config family (7 keys) as a **strict boolean**: a
28
+ truthy non-boolean (`{settled: "yes"}`) throws
29
+ `createRegistry: "settled" must be true or false` rather than silently binding the
30
+ plain drain, and `setled` gets a did-you-mean suggestion.
31
+ - `bench/torture/settled-torture.mjs` -- the 28th scenario (native, floor 1.11.0,
32
+ 39 asserts): exact settle accounting across all three `flushStrategy` builds,
33
+ fan/batch/cascade coalescing, clean-quiescence negatives, observer isolation,
34
+ mid-fire un/subscribe safety, destroy, 10k-cycle + 1000-batch exact soaks;
35
+ `SETTLED_BREAK=phantom|lost` self-tests verified to fail the gate.
36
+ - `zerogc-torture` gains the 1.11.0-gated `steady-settled` lane: a LIVE subscriber
37
+ under the full witness battery (retained 0 B, poolGrowths 0, zero scavenges over
38
+ the 1M-op un-forced window) with in-loop fail-closed non-vacuity.
39
+ - `test/38-onsettled.test.mjs` (the authored discriminator, 9 tests) and ten new
40
+ `test/35` cases (the settled matrix rows, the suggestion-set test, and a
41
+ first-class option describe).
42
+
43
+ ### Fixed (engine port, user-authorized, one-time)
44
+ - The staged `v1.11.0-candidate.1` engine had forked the rebuilt line at the SAME
45
+ pre-fix point as the 1.10.0 canary. Ported verbatim from the 1.10.0 engine:
46
+ the `disposeNode` **cursor repair** (+ branch-free `freeLink`) -- without it,
47
+ `scope-torture`, `retrack-dispose-torture` and `cleanup-return-torture` all
48
+ crashed (`Cannot set properties of null (setting 'headSub')`) -- and the
49
+ **1.4.5 `createRegistry` validation cascade** (+ the 2 pool-population stats
50
+ keys, 12 -> 14), whose absence failed ~34 unit tests including a real OOM
51
+ SIGABRT where the missing eager ceiling let the guard child OOM. Residual
52
+ engine diff vs 1.10.0 = the 8 authored onSettled hunks + the two `settled`
53
+ validation lines; **no hot body touched** (`flushEffectsPlain`'s body is
54
+ byte-identical to 1.10.0's `flushEffects` -- only the binding became a
55
+ build-time-selected const).
56
+
57
+ ### Unchanged (proven, not asserted)
58
+ - A default registry (`settled` off) binds the **verbatim plain drain**, so its
59
+ `flushEffects` -- and the hot write path that calls it -- is **byte-identical** to
60
+ 1.10.0 (body sha256). `markDownstream` / `executeEffect` / `pullComputed` untouched.
61
+ Zero cost BY CONSTRUCTION -- there is no per-flush check.
62
+ - Creation anatomy re-measured **IDENTICAL for the seventh engine running**
63
+ (`mint --verify` all pins PASS: signal 264.3 / computed 208.1 / effect 160.0 /
64
+ boxes 56.0 B/op all-space -- `CAP_SETTLED` is read once at `createRegistry`,
65
+ off the mint path). `visit-anatomy --verify` holds all 21 structural pins with
66
+ NO re-anchor. JIT strict: 4x monomorphic on a fresh Node-26 baseline.
67
+ VersionMatrix **GATE PASSED 5/5 first try** (floor 1.3.0 + rolling 1.5.0,
68
+ REPS=5 trimmed-spread; counter lane exact 288 allocs/frame min=max=p99 over
69
+ 1500 frames, poolGrowths 0).
70
+ - Full ladder: unit 572/571/0/1 (`test:gc` 580/579/0/1); torture 27 pass /
71
+ 1 opt-in skip / 0 fail with **zero floor-skips** (wraparound re-run at full
72
+ distance, 12/12); zgc 7/7 + report; hardening 23/0/5; harness 5/5; smoke PASS.
73
+
74
+ ### Known sharp edge (observed, deliberately un-asserted)
75
+ - `fireSettled` iterates the live callbacks array while unsubscribe splices it:
76
+ a callback that unsubscribes ITSELF mid-fire makes its next sibling miss THAT
77
+ drain (recovery from the next drain on is exact); a mid-fire subscribe is
78
+ delivered in the same drain; `destroy()` retains `settledCallbacks` (bounded,
79
+ freed with the registry). Flagged for an explicit decision rather than pinned
80
+ as law -- see `settled-torture`'s header.
81
+
82
+
7
83
  ## [1.10.0-preview] -- 2026-09-06
8
84
 
9
85
  The **verification-infrastructure parity cut** for the named-nodes + `whyDirty()`
package/README.md CHANGED
@@ -475,6 +475,44 @@ whyDirty(shield); // [ { id, kind: "signal", name: "hp", value: 80 } ]
475
475
  - **Named nodes.** `signal(v, {name})`, `computed(fn, {name})`, `effect(fn, {name})`. The name lives in a registry-side `Map<id, name>` populated **only** when you pass one -- no field is added to the node, so the `21-perf-pins` handle shapes (signal 6 own props, computed 4) are unchanged and unnamed nodes pay nothing. `describe()` / `describeNode()` gain `name` when present; devtools and the profilers render `hp` instead of `#412`.
476
476
  - **`whyDirty(handle)`.** The pull-side answer to "why will this recompute / why did this fire". For a computed it walks the deps and returns each one whose version moved past the observer's `evalVersion` -- the **exact** predicate `pullComputed` runs (`((dep.version - evalVer) | 0) > 0`, modular, not `!==`) -- and traces transitively to the underlying signal write as `rootCause`. It **never pulls**, so it cannot recompute anything or move the clock it is describing; it allocates freely, as a diagnostic on your cold path the engine never invokes. Empty for a clean computed and for non-computeds.
477
477
 
478
+ ### onSettled (1.11.0)
479
+
480
+ The redemption of the feature that once reset the line: the original always-checked
481
+ drain hook cost ~7ns per flush through V8's inline budget (a +27-31% batched-update
482
+ regression, ledger #17). 1.11.0 brings it back with the cost model **inverted** -- a
483
+ **creation-time capability**, decided once at `createRegistry` and never again:
484
+
485
+ ```ts
486
+ const r = createRegistry({ settled: true }); // selects the drain variant at BUILD time
487
+ const off = r.onSettled(() => paint()); // fires once per settled drain
488
+ r.batch(() => { hp.set(80); mana.set(20); }); // many writes, ONE settle
489
+ off(); // unsubscribe
490
+ ```
491
+
492
+ - **Zero cost by construction.** `flushEffects` is a `const` chosen once from
493
+ `{ plain, settled }` -- the same build-time selection discipline as the 1.7.0
494
+ `flushStrategy` closures. A default registry binds the **verbatim plain drain**
495
+ (byte-identical body), so the hot write path never checks anything: there is no
496
+ per-flush branch to mispredict, and no cost to not using the feature.
497
+ - **"Settled" means the graph actually quiesced.** The callback fires **once per
498
+ top-level, non-empty, clean drain**: not per effect, not on a re-entrant flush
499
+ during a drain, not on an empty `flush()`, and not on a drain that threw. A
500
+ `batch()` of many writes, or one write fanning out to many effects -- including
501
+ cascades where effects write further signals -- is exactly one settle.
502
+ - **Observer, not control path.** A throwing callback is swallowed; the write that
503
+ triggered the drain never sees it and sibling callbacks still fire, in
504
+ subscription order. `onSettled` on a registry built *without* the capability
505
+ throws, pointing at the option; `settled` is validated as a strict boolean
506
+ (`{settled: "yes"}` throws by name rather than silently binding the plain drain).
507
+ - **Allocation-free delivery.** The notification tail iterates a pre-existing
508
+ array of pre-existing closures -- the `zerogc-torture` `steady-settled` lane
509
+ proves a live subscriber sustains a 1M-op window with zero retained bytes and
510
+ zero scavenges. Subscribe/unsubscribe are cold-path by design.
511
+
512
+ This is what a scheduler, a test harness, or a frame coordinator needs to know a
513
+ reactive update has fully landed -- and the notification the 1.12.0 trace twin
514
+ will hang its per-flush records off.
515
+
478
516
  ### onGraphMutation (1.2.1)
479
517
 
480
518
  ```ts
@@ -574,7 +612,8 @@ const r = createRegistry({
574
612
  maxLinks: 4 * 1024, // default = maxNodes * 4 (ledger)
575
613
  prealloc: "eager", // default. Other: "lazy"
576
614
  maxFlushPasses: 100, // default
577
- onCapacityExceeded: "throw" // default. Other: "grow"
615
+ onCapacityExceeded: "throw", // default. Other: "grow"
616
+ settled: false // default. true builds the onSettled tail (1.11.0)
578
617
  });
579
618
 
580
619
  const s = r.signal(0);
@@ -829,8 +868,8 @@ Three tiers, all reproducible.
829
868
 
830
869
  ### Tier 1 -- Behavior (unit tests, fast)
831
870
 
832
- On the 1.10.0 engine `npm test` reports **553 tests, 552 pass, 0 fail, 1 skip**, and
833
- `npm run test:gc` (Tier 2, `--expose-gc`) reports **561 tests, 560 pass, 0 fail, 1
871
+ On the 1.11.0 engine `npm test` reports **572 tests, 571 pass, 0 fail, 1 skip**, and
872
+ `npm run test:gc` (Tier 2, `--expose-gc`) reports **580 tests, 579 pass, 0 fail, 1
834
873
  skip**. `npm test` runs the glob-scoped suite in `test/`, covering:
835
874
 
836
875
  - **`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.
@@ -860,12 +899,13 @@ skip**. `npm test` runs the glob-scoped suite in `test/`, covering:
860
899
  - **`29-scope.test.mjs`** -- `createScope` (1.6.0), the adopting counterpart to `createRoot`. 4 tests: the scope owner runs exactly once on creation; direct-body signal reads in `fn` are untracked while inner effect/computed bodies track normally; `dispose()` cascade-disposes the owned subtree (effects + computeds) while a directly-allocated signal correctly survives (the engine never owner-adopts signals); a scope created inside a consumer effect SURVIVES that consumer's re-run -- the reconciler-critical detach property; `dispose()` is idempotent; the disposer is introspection-stamped to its owner effect (`describe(dispose).kind === "effect"`); and `totalAllocations - totalDisposals === activeNodes` holds across the entire lifecycle.
861
900
  - **`25-devtools-real-boot.test.mjs`** -- the devtools pairing contract (14 tests). Boots the REAL installed `@zakkster/lite-devtools` 1.6.2 against this engine through an import-rewrite rig (both share ONE engine instance -- the rig catches the two-instance failure mode where the package resolves to the published build instead of the local engine). Pins the live-probed ground truth: all 22 function exports + the `VERSION` const, the EXACT 13-key `capabilities()` fingerprint (1.5 through 1.8 all true, `statsKeys: 14` -- devtools 1.6.2 has no 1.9 or 1.10 cap key, so the exact key set is itself the pin), the `burstProfile()` live-handle and `stop()` summary shapes, and the 1.6.x `Symbol.dispose` stamps on devtools' own stopper handles.
862
901
  - **`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%).
863
- - **`30-throwing-equals.test.mjs`** -- a user `equals` that THROWS, pinned at all five 1.10.0 invocation sites (9 tests): the three callable sites (signal set pre-check, batch revert, computed re-eval -- with a CONTRAST anti-tautology test proving the batch-revert pin is caused by the throw, not the set-then-back shape) and the two `signalBox` `boxSet` sites (pre-check leaves the box unmutated; batch-revert strands the version bump so the net value fires downstream).
902
+ - **`30-throwing-equals.test.mjs`** -- a user `equals` that THROWS, pinned at all five 1.11.0 invocation sites (9 tests): the three callable sites (signal set pre-check, batch revert, computed re-eval -- with a CONTRAST anti-tautology test proving the batch-revert pin is caused by the throw, not the set-then-back shape) and the two `signalBox` `boxSet` sites (pre-check leaves the box unmutated; batch-revert strands the version bump so the net value fires downstream).
864
903
  - **`33-cleanup-return.test.mjs`** -- the 1.8.0 effect cleanup-return contract at unit grain (7 tests): timing (fires before re-run + on dispose), compose order with `onCleanup`, non-function returns ignored, the computed exclusion.
865
904
  - **`34-computed-selfdirty-prev-owner.test.mjs`** -- forward-compat suite for the roadmap 1.10.x+ surface (11 tests): `computed(fn(prev), {initial})` and the gen-guarded owner APIs, feature-discriminated so legacy engines degrade cleanly; plus the DELIBERATE #179/#15 absorption pin (a computed writing its own tracked dep ABSORBS) that holds on every 1.x engine.
866
- - **`35-config-validation.test.mjs`** -- the 1.4.5 `createRegistry` validation matrix on the 6-key config family incl `flushStrategy` (13 tests): per-option `TypeError`s, did-you-mean hints, the eager-construction ceiling, the two pool-population stats keys, and OOM rows spawned as child processes under a 256 MB cap via `35-config-oom.child.mjs`.
905
+ - **`35-config-validation.test.mjs`** -- the 1.4.5 `createRegistry` validation matrix on the 7-key config family incl `flushStrategy` and the 1.11.0 `settled` capability key (23 tests): per-option `TypeError`s, did-you-mean hints (`setled` suggests `settled`), the strict-boolean `settled` guard, the eager-construction ceiling, the two pool-population stats keys, and OOM rows spawned as child processes under a 256 MB cap via `35-config-oom.child.mjs`.
867
906
  - **`36-named-and-whydirty.test.mjs`** -- the 1.10.0 discriminator (6 tests): `signal(v, {name})` / `computed` / `effect` names surface in `describe().name` (and are absent for unnamed nodes -- zero node-shape change); `whyDirty(computed)` returns EXACTLY the dep whose version moved past the observer's `evalVersion` (never the whole dep set -- the rejected-sketch bug), traces transitively to the root signal write, and is read-only (a `whyDirty` call never pulls, so it cannot perturb the clock it describes).
868
907
  - **`37-devtools-zerogc-probe.test.mjs`** -- the zero-GC claim on the reactive-benchmark weak-group shapes (5 tests), through both the engine's `stats().poolGrowths` counter and devtools 1.6.2's `watchAllocations()` feed: the pool never grows its backing store (`poolGrowths` delta == 0).
908
+ - **`38-onsettled.test.mjs`** -- the 1.11.0 discriminator (9 tests, authored with the engine): `onSettled` throws without the capability and stays inert when off; fires once per top-level drain; coalesces under multi-effect fan-out, `batch()`, and nested writes during a drain; stays silent on empty and thrown flushes; unsubscribes cleanly with sibling callbacks unaffected.
869
909
 
870
910
  ```bash
871
911
  npm test
@@ -896,17 +936,17 @@ npm run bench
896
936
 
897
937
  ### Tier 4 -- Torture (correctness and resources under chaos)
898
938
 
899
- `bench/torture/` holds the complete **27-scenario superset (23 semantic + 4
939
+ `bench/torture/` holds the complete **28-scenario superset (24 semantic + 4
900
940
  soak, one opt-in)** behind one runner (`run.mjs`), the forward-compatible set
901
- through 1.9. They are not perf benchmarks: the ops/sec figures reflect random
941
+ through 1.11. They are not perf benchmarks: the ops/sec figures reflect random
902
942
  workload composition, not engine throughput -- `bench/benchmark.mjs` remains the
903
943
  canonical perf harness. Every scenario feature-detects and **skips cleanly**
904
944
  (exit 77) below the engine version that introduces its feature, and the runner
905
945
  **enforces the floors**: a scenario that skips while the engine is at or above
906
946
  its floor FAILS the run -- a dropped export cannot masquerade as a green skip.
907
- On the **1.10.0 engine all 23 semantic scenarios execute with zero
908
- feature-skips** -- the first engine version to run the complete superset, since
909
- `dispose` was the last gate.
947
+ On the **1.11.0 engine all 24 semantic scenarios execute with zero
948
+ feature-skips** (as on 1.9.0/1.10.0 -- `dispose` was the last gate), and the
949
+ new `settled-torture` runs natively.
910
950
 
911
951
  ```bash
912
952
  npm run torture # everything
@@ -920,9 +960,9 @@ node bench/torture/run.mjs --list
920
960
  Run these on every commit. Most scenarios run on any 1.4.x+ engine;
921
961
  `box-torture`, `owner-torture` and `lifecycle-torture` (1.5.0),
922
962
  `scope-torture` / `introspect-torture` / `burst-profile-torture` (1.6.0),
923
- `flush-torture` (1.7.0), `cleanup-return-torture` (1.8.0), and
924
- `dispose-torture` (1.9.0) all run here because their features exist --
925
- nothing floor-skips on this engine.
963
+ `flush-torture` (1.7.0), `cleanup-return-torture` (1.8.0),
964
+ `dispose-torture` (1.9.0), and `settled-torture` (1.11.0) all run here
965
+ because their features exist -- nothing floor-skips on this engine.
926
966
 
927
967
  | scenario | pins |
928
968
  | -------- | ---- |
@@ -948,6 +988,7 @@ nothing floor-skips on this engine.
948
988
  | `flush-torture` (1.7.0) | the three `flushStrategy` modes by cross-strategy differential, per-strategy scheduling, re-entrant/empty `flush()`, and the `.subscribe()` contract under each |
949
989
  | `cleanup-return-torture` (1.8.0) | an effect's returned cleanup: timing at re-run/dispose, compose order after `onCleanup`, the self-dispose guard, and the computed exclusion; plus the 1.8 severTail cursor-repair pinned by mechanism (five named dispose-mid-retrack geometries, section 6b) |
950
990
  | `dispose-torture` (1.9.0) | `Symbol.dispose` stamped at five sites (registry, effect stop handle, scope/root disposers, both box prototypes) driven through the TC39 `using` path; idempotent disposal, feature-detected via the box-prototype stamp |
991
+ | `settled-torture` (1.11.0) | the `onSettled` creation-time capability: exact settle accounting across all three `flushStrategy` builds, fan/batch/cascade coalescing, clean-quiescence negatives (empty / re-entrant / thrown drains), observer isolation with ordered siblings, mid-fire un/subscribe safety, destroy, 10k-cycle exact soaks; `SETTLED_BREAK=phantom\|lost` self-tests must fail the gate |
951
992
  | `zerogc-torture` | the zero-GC claim as a gate via `@zakkster/lite-gc-profiler`: `measureAllocs`/`checkAllocs` at `maxBytesPerCall: 0` + `measureOps`/`checkNoGc` at `maxMajor: 0`/`maxPauseMs: 2` + `stats()` deltas over steady + create/dispose churn (callable and `signalBox`); `ZEROGC_BREAK=1` self-tests that the gate rejects a planted allocation |
952
993
 
953
994
  #### `soak` -- wall-clock bound, asserts on **resources**
package/Signal.d.ts CHANGED
@@ -361,6 +361,21 @@ export interface RegistryConfig {
361
361
  * @throws Error if the value is not one of the three tokens.
362
362
  */
363
363
  flushStrategy?: "eager" | "sab" | "manual";
364
+
365
+ /** 1.11.0: build the {@link Registry.onSettled} drain-complete tail into
366
+ * this registry. Decided ONCE here -- `flushEffects` is a build-time-selected
367
+ * const (the same discipline as {@link RegistryConfig.flushStrategy}), so a
368
+ * registry built without the capability binds the verbatim plain drain and
369
+ * pays nothing: there is no per-flush check. On such a registry
370
+ * `onSettled` throws, pointing at this option.
371
+ *
372
+ * Validated as a strict boolean: a truthy non-boolean (e.g. `"yes"`) throws
373
+ * `createRegistry: "settled" must be true or false` at construction rather
374
+ * than silently binding the plain drain.
375
+ *
376
+ * @default false
377
+ */
378
+ settled?: boolean;
364
379
  }
365
380
 
366
381
  /** Method surface of {@link Registry}; see that type for the full contract. */
@@ -440,6 +455,18 @@ interface RegistryMembers {
440
455
  * computed carry a {@link NodeDescriptor.rootCause}. Empty for a clean
441
456
  * computed and for non-computed (or stale/non-) handles. */
442
457
  whyDirty(handle: ReactiveHandle): NodeDescriptor[];
458
+ /** 1.11.0: register a drain-complete callback; requires the registry to be
459
+ * built with {@link RegistryConfig.settled} `: true` (throws otherwise,
460
+ * pointing at the option). Fires once per **top-level, non-empty, clean**
461
+ * drain -- not per effect, not on re-entrant or empty flushes, not on a
462
+ * drain that threw -- so a settle always means the graph actually
463
+ * quiesced; a `batch()` of many writes or one write fanning out to many
464
+ * effects (cascades included) is exactly one settle. Callbacks fire in
465
+ * subscription order; a throwing callback is swallowed (observer, not
466
+ * control path) and siblings still fire. Returns an idempotent
467
+ * unsubscribe. Delivery is allocation-free; subscribing and unsubscribing
468
+ * are cold-path. */
469
+ onSettled(fn: () => void): () => void;
443
470
  /** True iff a read RIGHT NOW would record a dependency on this registry.
444
471
  * False inside `untrack`, `subscribe` callbacks, `onCleanup` bodies, and
445
472
  * outside any observer. Use for lazy-allocation wrappers like lite-store. */
@@ -551,6 +578,11 @@ export function nodeId(handle: ReactiveHandle): number | undefined;
551
578
  export function describe(handle: ReactiveHandle): NodeDescriptor | undefined;
552
579
  /** Top-level binding of {@link Registry.whyDirty} (1.10.0). */
553
580
  export function whyDirty(handle: ReactiveHandle): NodeDescriptor[];
581
+ /** Top-level binding of {@link Registry.onSettled} (1.11.0). NOTE: the module's
582
+ * default registry is built without `settled`, so this throws unless the
583
+ * default registry was created with the capability -- practical use is the
584
+ * registry method on a `createRegistry({ settled: true })` instance. */
585
+ export function onSettled(fn: () => void): () => void;
554
586
  /** Top-level binding of {@link Registry.onGraphMutation} (1.2.1+). */
555
587
  export function onGraphMutation(fn: GraphMutationListener | null): GraphMutationUnsubscribe;
556
588
  export function onCleanup(fn: () => void): void;
package/Signal.js CHANGED
@@ -1,5 +1,26 @@
1
1
  /**
2
- * @zakkster/lite-signal v1.10.0-preview
2
+ * @zakkster/lite-signal v1.11.0-preview
3
+ * Copyright (c) Zahary Shinikchiev <shinikchiev@yahoo.com>
4
+ * MIT License
5
+ * --------------------
6
+ * 1.11.0 -- onSettled, rebuilt as a CREATION-TIME capability.
7
+ * createRegistry({ settled: true }) selects, ONCE at build time, a flushEffects
8
+ * variant with a drain-complete tail -- the same const-selection discipline as the
9
+ * 1.7.0 flushStrategy closures. A DEFAULT registry binds the verbatim plain drain,
10
+ * so its flushEffects (and the hot write path that calls it) is byte-identical to
11
+ * 1.10.0's: zero cost BY CONSTRUCTION, not by a per-flush check. onSettled() on a
12
+ * registry built without the capability throws, pointing at the option.
13
+ * onSettled(fn) fires ONCE per top-level, non-empty, clean drain (not per effect,
14
+ * not on re-entrant or empty flushes, not on a flush that threw), and returns an
15
+ * unsubscribe. This retires the rejected always-checked hook (ledger #17): the
16
+ * feature returns with its cost inverted, decided before the first closure is built.
17
+ * Hot bodies markDownstream / executeEffect / pullComputed are byte-identical to
18
+ * 1.10.0; flushEffects's PLAIN body is byte-identical (only its binding became a
19
+ * build-time-selected const). See ROADMAP-1_9-REBUILT s1.11.0.
20
+ *
21
+ * Previous 1.10.0 header follows.
22
+ * --------------------
23
+ * @zakkster/lite-signal v1.10.0 (rebuilt line, candidate)
3
24
  * Copyright (c) Zahary Shinikchiev <shinikchiev@yahoo.com>
4
25
  * MIT License
5
26
  * --------------------
@@ -326,7 +347,7 @@ export class CapacityError extends Error {
326
347
  /** The only config keys {@link createRegistry} recognizes. Anything else is
327
348
  * rejected at construction with a did-you-mean hint (fail closed on an
328
349
  * unverified state -- an unknown key is an error, never a silent ignore). */
329
- const ALLOWED_KEYS = ["maxNodes", "maxLinks", "prealloc", "onCapacityExceeded", "maxFlushPasses", "flushStrategy"];
350
+ const ALLOWED_KEYS = ["maxNodes", "maxLinks", "prealloc", "onCapacityExceeded", "maxFlushPasses", "flushStrategy", "settled"];
330
351
 
331
352
  /** Ceiling on eager pool construction: `(maxNodes + maxLinks)` objects. A finite
332
353
  * but absurd `maxNodes` (e.g. `1e9`, a plausible typo for `1e5`) that would
@@ -434,6 +455,13 @@ export function createRegistry(config) {
434
455
  'createRegistry: "onCapacityExceeded" must be "throw" or "grow", received ' + received(config.onCapacityExceeded) + '.'
435
456
  );
436
457
  }
458
+ // 1.11.0: `settled` is a strict boolean -- a truthy non-boolean (e.g. "yes")
459
+ // must throw here, never silently bind the plain drain below (fail closed).
460
+ if (config.settled !== undefined && config.settled !== true && config.settled !== false) {
461
+ throw new TypeError(
462
+ 'createRegistry: "settled" must be true or false, received ' + received(config.settled) + '.'
463
+ );
464
+ }
437
465
  // Unknown-key rejection with a did-you-mean hint (`preAlloc` -> `prealloc`,
438
466
  // `maxNods` -> `maxNodes`). Own enumerable keys only; cold path.
439
467
  const badKeys = Object.keys(config);
@@ -474,6 +502,11 @@ export function createRegistry(config) {
474
502
  throw new Error("flushStrategy must be one of: 'eager', 'sab', 'manual'");
475
503
  }
476
504
 
505
+ // 1.11.0: settled capability, decided ONCE here. Selects a flushEffects variant
506
+ // at build time (see near flushEffects); it is never a per-flush check. A default
507
+ // registry pays nothing and its flushEffects is byte-identical to 1.10.0's.
508
+ const CAP_SETTLED = (config !== undefined && config.settled === true);
509
+
477
510
  // Lazy pool population (P1): maxNodes / maxLinks are capacity ledgers,
478
511
  // not eager construction counts. Nodes/links are constructed on first
479
512
  // demand and recycled through the free lists thereafter -- the zero-GC
@@ -1062,7 +1095,7 @@ export function createRegistry(config) {
1062
1095
  * `maxFlushPasses` (default 100) -> Error prefixed `"CycleError:"`.
1063
1096
  * @private
1064
1097
  */
1065
- function flushEffects() {
1098
+ const flushEffectsPlain = function () {
1066
1099
  if (isFlushing) return;
1067
1100
  isFlushing = true;
1068
1101
  let passes = 0;
@@ -1116,7 +1149,47 @@ export function createRegistry(config) {
1116
1149
  flushErrorCount = 0;
1117
1150
  throw new AggregateError(errs, "Effects threw during flush");
1118
1151
  }
1152
+ };
1153
+
1154
+ // 1.11.0: onSettled -- drain-complete notification, selected at build time.
1155
+ //
1156
+ // The rejected 1.9.x onSettled was an always-checked drain hook: ~7ns/flush
1157
+ // through V8's inline budget, a +27-31% batched-update regression (ledger #17).
1158
+ // This inverts the cost model. `flushEffects` below is a const chosen ONCE from
1159
+ // { plain, settled }. A default registry (CAP_SETTLED false) binds the verbatim
1160
+ // plain drain, so the hot write path calls a byte-identical closure and pays
1161
+ // nothing -- zero cost BY CONSTRUCTION, decided before the first closure is built.
1162
+ // Only a registry built with { settled: true } binds the settled variant.
1163
+ const settledCallbacks = CAP_SETTLED ? [] : null;
1164
+ function onSettled(fn) {
1165
+ if (!CAP_SETTLED) throw new Error("onSettled requires createRegistry({ settled: true })");
1166
+ settledCallbacks.push(fn);
1167
+ let live = true;
1168
+ return function () {
1169
+ if (!live) return;
1170
+ live = false;
1171
+ const i = settledCallbacks.indexOf(fn);
1172
+ if (i !== -1) settledCallbacks.splice(i, 1);
1173
+ };
1174
+ }
1175
+ function fireSettled() {
1176
+ const cbs = settledCallbacks;
1177
+ for (let i = 0; i < cbs.length; i++) {
1178
+ // A notification callback must never break the drain it observes.
1179
+ try { cbs[i](); } catch (_e) { /* swallow: settled is an observer, not a control path */ }
1180
+ }
1119
1181
  }
1182
+ // The settle tail fires ONCE per top-level, non-empty, clean drain: re-entrant
1183
+ // calls (wasFlushing) and empty flushes (no queued work) do not notify, and a
1184
+ // drain that throws propagates before the tail, so "settled" always means the
1185
+ // graph actually quiesced.
1186
+ const flushEffectsSettled = function () {
1187
+ const wasFlushing = isFlushing;
1188
+ const hadWork = activeQueueLen > 0;
1189
+ flushEffectsPlain();
1190
+ if (!wasFlushing && hadWork) fireSettled();
1191
+ };
1192
+ const flushEffects = CAP_SETTLED ? flushEffectsSettled : flushEffectsPlain;
1120
1193
 
1121
1194
  // 1.7: flushStrategy hot-path lever (REVISION).
1122
1195
  //
@@ -2311,7 +2384,7 @@ export function createRegistry(config) {
2311
2384
  while (l !== null) { const nx = l.nextDep; fn(describeNode(l.source)); l = nx; }
2312
2385
  }
2313
2386
 
2314
- const registry = {signal, computed, effect, signalBox, computedBox, dispose, batch, flush, untrack, createRoot, getOwner, runWithOwner, createScope, onCleanup, stats, destroy, isTracking, hasObservers, observeObservers, forEachObserver, forEachSource, forEachOwned, ownerOf, nodeId, describe, whyDirty, onGraphMutation};
2387
+ const registry = {signal, computed, effect, signalBox, computedBox, dispose, batch, flush, untrack, createRoot, getOwner, runWithOwner, createScope, onCleanup, stats, destroy, isTracking, hasObservers, observeObservers, forEachObserver, forEachSource, forEachOwned, ownerOf, nodeId, describe, whyDirty, onSettled, onGraphMutation};
2315
2388
  // 1.9.0: `using r = createRegistry()` destroys at block exit.
2316
2389
  if (SYMBOL_DISPOSE !== null) registry[SYMBOL_DISPOSE] = destroy;
2317
2390
  return registry;
@@ -2438,5 +2511,8 @@ export function describe(handle) {
2438
2511
  export function whyDirty(handle) {
2439
2512
  return defaultRegistry.whyDirty(handle);
2440
2513
  }
2514
+ export function onSettled(fn) {
2515
+ return defaultRegistry.onSettled(fn);
2516
+ }
2441
2517
 
2442
2518
  export {watch, when, whenAsync} from "./Watch.js";
package/llms.txt CHANGED
@@ -26,7 +26,8 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
26
26
  - **Returned cleanup (1.8.0)**: an EFFECT body may `return` a cleanup function (Solid/Vue/Reflex-compatible). Runs at the same points as onCleanup (before each re-run, once on dispose) and is APPENDED after any onCleanup registered in the same body, so the two styles compose in call order. Non-function returns are ignored; a self-disposed body registers nothing (gen-guarded). COMPUTEDS ARE EXCLUDED: a computed returning a function keeps treating it as the VALUE. Cost: one `typeof` per effect run, off the mark/pull path; `executeEffect` is the only body whose sha256 changed 1.7.0 -> 1.8.0.
27
27
  - **Observer-lifecycle introspection** (1.1.4; top-level + per-registry): `hasObservers(handle)` returns true iff a signal/computed has >=1 live observer right now (O(1); a `peek` does not count). `observeObservers(handle, { onConnect?, onDisconnect? })` fires on the 0->1 and 1->0 observer transitions (after registration; transition-only) and returns an idempotent unobserve -- the auto-pause hook for tickers (lite-time/lite-raf start a source only while it's watched). `forEachObserver(handle, fn)` / `forEachSource(handle, fn)` walk the live graph in either direction, passing a `{ kind, value }` descriptor (`kind` is `"signal" | "computed" | "effect"`) -- for inspection (lite-devtools). The surface is gated by an internal counter: zero steady-state cost when nothing is observed. `hasObservers`/`forEach*` no-op on a non-handle; `observeObservers` throws `TypeError`. **Node identity (1.1.5):** `nodeId(handle)` returns the node's stable per-allocation id, `describe(handle)` returns the handle's own `{ id, kind, value }` descriptor, and `forEach*` descriptors now carry `id` too; a descriptor is **re-walkable** (pass it back into `forEachObserver`/`forEachSource`) -- the recursion primitive lite-devtools uses to walk the full DAG. **Owner-tree introspection (1.2.1):** `forEachOwned(handle, fn)` walks a node's owned children (lifetime-binding edges from the 1.2 owner tree -- invisible through dep/sub); `ownerOf(handle)` returns the owner's descriptor or `undefined` for top-level / stale handles. **Stale-handle guard (1.2.1):** the entire introspection surface plus `peek()`/`read()`/`set()` is now generation-checked. A handle held across the 1.2 owner-cascade auto-dispose used to resolve `NODE_PTR` ungated and silently report the recycled slot's NEW resident; 1.2.1 surfaces stale handles as `undefined` (or `TypeError`, for `observeObservers`) -- same ABA discipline `dispose()` always had. Descriptors are gen-stamped so the re-walkable contract survives the guard. **Push-based mutation hook (1.2.1):** `onGraphMutation(fn)` registers a single nullable listener invoked synchronously at every mutation point with three integers `(opcode, intA, intB)` -- opcodes `1` node-create / `2` node-dispose / `3` link-add / `4` link-remove / `5` recompute. Zero-cost gate when no listener is registered (one branch-predicted null check); allocation-free dispatch when registered. The connection point for push-based devtools/studio. Contract: observe only -- never throw, never mutate.
28
28
  - **Named nodes + `whyDirty` (1.10.0):** `signal(v, {name})` / `computed(fn, {name})` / `effect(fn, {name})` attach a debug name that lives in a cold registry-side `Map<id, name>` populated ONLY when a name is given -- zero node-shape change (the `21-perf-pins` handle shapes are unchanged), zero cost for unnamed nodes; `describe()` / `describeNode()` return `name` when present. `whyDirty(handle)` is the pull-side diagnostic: for a computed it returns each dep whose version moved past the observer's `evalVersion` -- the EXACT predicate `pullComputed` runs, `((dep.version - evalVer) | 0) > 0`, modular not `!==` -- with a transitive `rootCause` down to the root signal write. Read-only: it never pulls, so it cannot perturb the graph it describes; allocates freely (a cold diagnostic the engine never invokes). Empty for a clean computed and for non-computeds. Module surface is now 33 exports / registry 27 fns (whyDirty added); the four hot propagation bodies are byte-identical to 1.9.0 (sha-proven, WHY-1_10.md).
29
- - **Registry**: `createRegistry({ maxNodes, maxLinks, prealloc, onCapacityExceeded, maxFlushPasses })` creates an isolated reactive world with its own pools. Useful for tests, plugins, multi-tenant sandboxes. Top-level helpers use a default registry created at module load. `prealloc` (1.3.0; `"eager"` default | `"lazy"`) chooses up-front vs on-demand pool construction; `onCapacityExceeded` (`"throw"` default | `"grow"`) chooses fail-fast vs chunked-incremental growth bounded by the 16x link ceiling. **Config is validated at construction (1.9.0-preview.6, backported from 1.4.5):** every option is checked BY NAME (the six recognized keys include `flushStrategy`), a bad shape or unknown key throws a `TypeError` prefixed `createRegistry: "<name>"` with a did-you-mean hint, and an absurd eager capacity (`maxNodes:Infinity`/`1e9`) is refused before it can OOM the process. `stats()` gains `nodePoolPopulation` / `linkPoolPopulation` (true constructed-object counts, distinct from the `*Capacity` ledgers) -> **14 keys**.
29
+ - **`onSettled` as a creation-time capability (1.11.0):** the ledger-#17 redemption -- the rejected always-checked drain hook (~7ns/flush through V8's inline budget, a +27-31% 1to1batch regression) returns with its cost model INVERTED. `createRegistry({ settled: true })` selects ONCE at build time a `flushEffects` variant with a drain-complete tail (`const flushEffects = CAP_SETTLED ? flushEffectsSettled : flushEffectsPlain` -- the same const-selection discipline as the 1.7.0 flushStrategy closures); a DEFAULT registry binds the verbatim plain drain, so the hot write path is byte-identical and pays nothing BY CONSTRUCTION -- there is no per-flush check to mispredict. `onSettled(fn)` (registry method + top-level, on a settled default registry) registers a drain-complete callback and returns an idempotent unsubscribe; it fires once per TOP-LEVEL, NON-EMPTY, CLEAN drain -- not per effect, not on re-entrant or empty flushes, not on a drain that threw -- so "settled" always means the graph actually quiesced (a `batch()` of many writes, or one write fanning to many effects, incl. cascades, is ONE settle). Callbacks fire in subscription order; a THROWING callback is swallowed (observer, not control path) and siblings still fire. On a registry built without the option `onSettled` throws, pointing at it; `settled` is a strict boolean in the validated config family (a truthy non-boolean throws by name rather than silently binding the plain drain). The notification tail is allocation-free (zerogc `steady-settled` lane: a live subscriber over the 1M-op window, 0 retained, 0 scavenges); subscribe/unsubscribe are cold-path by design. Module surface is now **34 exports / registry 28 fns** (onSettled added). This is the notification the 1.12.0 trace twin hangs its per-flush records off.
30
+ - **Registry**: `createRegistry({ maxNodes, maxLinks, prealloc, onCapacityExceeded, maxFlushPasses })` creates an isolated reactive world with its own pools. Useful for tests, plugins, multi-tenant sandboxes. Top-level helpers use a default registry created at module load. `prealloc` (1.3.0; `"eager"` default | `"lazy"`) chooses up-front vs on-demand pool construction; `onCapacityExceeded` (`"throw"` default | `"grow"`) chooses fail-fast vs chunked-incremental growth bounded by the 16x link ceiling. **Config is validated at construction (1.9.0-preview.6, backported from 1.4.5):** every option is checked BY NAME (the seven recognized keys include `flushStrategy` and, from 1.11.0, `settled`), a bad shape or unknown key throws a `TypeError` prefixed `createRegistry: "<name>"` with a did-you-mean hint (`setled` suggests `settled`), and an absurd eager capacity (`maxNodes:Infinity`/`1e9`) is refused before it can OOM the process. `stats()` gains `nodePoolPopulation` / `linkPoolPopulation` (true constructed-object counts, distinct from the `*Capacity` ledgers) -> **14 keys**.
30
31
  - **CapacityError**: thrown when a fixed-size pool is exhausted under the `"throw"` policy, or when a `"grow"` policy hits the 16× starting-capacity ceiling on links.
31
32
 
32
33
  ## Architecture invariants
@@ -54,7 +55,8 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
54
55
 
55
56
  ## Version notes
56
57
 
57
- - **1.10.0-preview** (current): **named nodes + `whyDirty()`** -- the tracing foundation, two cold-path diagnostics the profilers consume directly (`signal/computed/effect(v, {name})` into a cold registry-side `Map<id,name>`; `whyDirty(computed)` returns the deps whose version moved past the observer's `evalVersion`, tracing to the root signal write, read-only and never pulling). Zero node-shape change, zero cost for unnamed nodes; the four hot propagation bodies are byte-identical to 1.9.0 (sha-proven, see WHY-1_10.md). Module 33 exports / registry 27 fns. This cut ALSO lands the verification-infrastructure parity that the rest of the line carries: torture 22 -> **27 scenarios** (all 23 semantic execute, zero floor-skips), unit suite glob-scoped to **553 tests** (test/25 rewritten against the live devtools-1.6.2 pairing; new `test/36-named-and-whydirty` discriminator + `test/37` zero-GC probe), the `test/zgc` + `test/ProfilerTests` + `harness/ProfilerTools` lanes, the phase-1/2/3 harness instruments (mint measured IDENTICAL for the sixth engine; visit 21/21 no re-anchor; jit strict 4x monomorphic), and the VersionMatrix gate (PASSED 5/5, counters 288/0). devDeps: devtools ^1.6.2, gc-profiler ^1.16.0. ENGINE NOTE: the folder's v1.10.0-canary.1 engine had forked the rebuilt-1.9 line before two later cold-path fixes; the disposeNode cursor-repair and the 1.4.5 createRegistry validation (+ 2 stats keys) were ported verbatim from 1.9.0 (no hot body touched), fixing a real dispose-mid-retrack crash. See CHANGELOG `[1.10.0-preview]`.
58
+ - **1.11.0-preview** (current): **`onSettled` rebuilt as a creation-time capability** -- the redemption of the feature whose naive always-checked drain hook was the +27-31% 1to1batch regression that reset the line (ledger #17). `createRegistry({ settled: true })` selects ONCE at build time a `flushEffects` variant with a drain-complete tail (`const flushEffects = CAP_SETTLED ? flushEffectsSettled : flushEffectsPlain` -- the 1.7.0 flushStrategy const-selection discipline); a DEFAULT registry binds the verbatim plain drain, byte-identical to 1.10.0's, so the hot write path pays nothing BY CONSTRUCTION. `onSettled(fn)` (registry + module) fires once per top-level, non-empty, clean drain and returns an idempotent unsubscribe; throws without the capability; `settled` joins the validated config family as a strict boolean (typo suggestion included). Module **34 exports / registry 28 fns**. Suite on this cut: torture 27 -> **28 scenarios** (`settled-torture` NATIVE, 39 asserts, `SETTLED_BREAK=phantom|lost` verified exit 1; the zerogc `steady-settled` lane -- a live subscriber over the 1M-op window, 0 retained, 0 scavenges), unit **572 tests / gc 580** (test/35 -> 23 tests with the settled matrix + suggestion-set + first-class rows; new `test/38-onsettled` discriminator, 9 tests), mint re-measured IDENTICAL for the **SEVENTH engine** (264.3/208.1/160.0/56.0/56.0 B/op all-space -- `CAP_SETTLED` is read once at `createRegistry`, off the mint path), visit-anatomy 21/21 with NO re-anchor, jit strict 4x monomorphic (fresh Node-26 baseline), VersionMatrix **GATE PASSED 5/5 first try** (floor 1.3.0 + rolling 1.5.0; counter lane exact 288 allocs/frame min=max=p99 over 1500 frames, poolGrowths 0). devDeps: devtools ^1.6.2 (NO 1.9/1.10/1.11 cap key exists there, so test/25's exact 13-key fingerprint is the era pin -- the in-progress devtools update must re-pin deliberately), gc-profiler ^1.16.0. ENGINE NOTE: the staged v1.11.0-candidate.1 engine had forked at the SAME pre-fix point as the 1.10.0 canary; the disposeNode cursor-repair + the 1.4.5 createRegistry validation cascade were ported VERBATIM from the 1.10.0 engine (user-authorized; two plan-scoped adaptations: ALLOWED_KEYS gains "settled" + a strict boolean guard), fixing the same dispose-mid-retrack crash class (baseline: 3 torture scenarios crashed, ~34 unit fails, incl a real OOM SIGABRT from the missing eager ceiling); no hot body touched -- `flushEffectsPlain`'s body is byte-identical to 1.10.0's `flushEffects`, only the binding became a build-time-selected const. KNOWN SHARP EDGE (observed, deliberately un-asserted, flagged for a decision): a settled callback that unsubscribes ITSELF mid-fire makes its next sibling miss THAT drain (indexOf+splice in the live fire loop); a mid-fire subscribe delivers same-drain; `destroy()` retains `settledCallbacks`. See CHANGELOG `[1.11.0-preview]` + WHY-1_11.md.
59
+ - **1.10.0-preview**: **named nodes + `whyDirty()`** -- the tracing foundation, two cold-path diagnostics the profilers consume directly (`signal/computed/effect(v, {name})` into a cold registry-side `Map<id,name>`; `whyDirty(computed)` returns the deps whose version moved past the observer's `evalVersion`, tracing to the root signal write, read-only and never pulling). Zero node-shape change, zero cost for unnamed nodes; the four hot propagation bodies are byte-identical to 1.9.0 (sha-proven, see WHY-1_10.md). Module 33 exports / registry 27 fns. This cut ALSO lands the verification-infrastructure parity that the rest of the line carries: torture 22 -> **27 scenarios** (all 23 semantic execute, zero floor-skips), unit suite glob-scoped to **553 tests** (test/25 rewritten against the live devtools-1.6.2 pairing; new `test/36-named-and-whydirty` discriminator + `test/37` zero-GC probe), the `test/zgc` + `test/ProfilerTests` + `harness/ProfilerTools` lanes, the phase-1/2/3 harness instruments (mint measured IDENTICAL for the sixth engine; visit 21/21 no re-anchor; jit strict 4x monomorphic), and the VersionMatrix gate (PASSED 5/5, counters 288/0). devDeps: devtools ^1.6.2, gc-profiler ^1.16.0. ENGINE NOTE: the folder's v1.10.0-canary.1 engine had forked the rebuilt-1.9 line before two later cold-path fixes; the disposeNode cursor-repair and the 1.4.5 createRegistry validation (+ 2 stats keys) were ported verbatim from 1.9.0 (no hot body touched), fixing a real dispose-mid-retrack crash. See CHANGELOG `[1.10.0-preview]`.
58
60
  - **1.9.0-preview.6**: backports the **1.4.5 `createRegistry` input validation** (all four findings) onto the 1.9.0-preview.5 engine. Only `createRegistry`'s *cold* path moved; hot paths stay byte-identical and `bench/torture/run.mjs` is unchanged at 22/22. Bad config now throws a named `TypeError` (unknown keys get a did-you-mean); an absurd eager capacity is refused before it can OOM the process; `stats()` grows to 14 keys (adds `nodePoolPopulation`/`linkPoolPopulation`, purely additive). New `test/*-config-validation.test.mjs` (matrix + ceiling + population + OOM child processes). See CHANGELOG `[1.9.0-preview.6]`.
59
61
  - **1.9.0-preview.5**: a **packaging-only cut** -- the engine is
60
62
  behaviourally unchanged from preview.4 (`Signal.js` differs only in its header
@@ -772,7 +774,7 @@ function dumpOwnerTree(handle, depth = 0) {
772
774
  - `test/22-mutation-hook.test.mjs` -- 1.2.1 `onGraphMutation` registration + opcode emission (12 tests).
773
775
  - `test/23-owner-introspection.test.mjs` -- `ownerOf`, `forEachOwned`, gen-guarded introspection (14 tests).
774
776
  - `test/24-signalbox.test.mjs` -- the signalBox/computedBox handle API, active since 1.5.0: get/set/peek/update, derive + memoize, interop both directions, batch coalescing, dispose ABA-safety, plus the 1.9.0 `Symbol.dispose` box test (`using`-path disposal via the shared prototype stamp) (13 tests).
775
- - `test/25-devtools-real-boot.test.mjs` -- real **devtools 1.6.2** boot against the 1.10.0 engine via the single-instance import-rewrite rig: all 22 exports + `VERSION`, the exact 13-key `capabilities()` fingerprint probed live (`flushControl:T`, `cleanupReturn:T`, `statsKeys:14`; devtools 1.6.2 has NO 1.9 cap key, so the exact key set is itself the 1.9-era pin), live `burstProfile()` stop-summary, the 1.6.x `Symbol.dispose` stamps (14 tests).
777
+ - `test/25-devtools-real-boot.test.mjs` -- real **devtools 1.6.2** boot against the 1.11.0 engine via the single-instance import-rewrite rig: all 22 exports + `VERSION`, the exact 13-key `capabilities()` fingerprint probed live (`flushControl:T`, `cleanupReturn:T`, `statsKeys:14`; devtools 1.6.2 has NO 1.9 cap key, so the exact key set is itself the 1.9-era pin), live `burstProfile()` stop-summary, the 1.6.x `Symbol.dispose` stamps (14 tests).
776
778
  - `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).
777
779
  - `test/27-create-root.test.mjs` -- `createRoot` (1.5.0), the ownership escape hatch; includes the top-level-export binding case (7 tests).
778
780
  - `test/28-run-with-owner.test.mjs` -- `getOwner`/`runWithOwner`: 7 basic shapes, 3 degradation cases (null/undefined/signal-handle fall through to rooted execution), 3 HAZARD PINS under allocation pressure so the ABA guard is genuinely exercised (16 tests).
@@ -783,15 +785,16 @@ function dumpOwnerTree(handle, depth = 0) {
783
785
  - `test/35-config-validation.test.mjs` -- the 1.4.5-backport validation matrix on the 6-key config family (incl `flushStrategy`): per-option TypeErrors, did-you-mean, the eager-construction ceiling, population keys, OOM rows spawned as child processes under a 256MB cap via `35-config-oom.child.mjs` (13 tests).
784
786
  - `test/36-named-and-whydirty.test.mjs` -- the 1.10.0 discriminator (6 tests): `signal(v,{name})`/`computed`/`effect` names surface in `describe().name` (absent for unnamed nodes -- zero node-shape change), and `whyDirty(computed)` returns EXACTLY the dep whose version moved past the observer's `evalVersion` (never the whole dep set), traces to the root signal write, and never pulls (read-only, cannot perturb the clock it describes).
785
787
  - `test/37-devtools-zerogc-probe.test.mjs` -- devtools attach/detach allocation probes against the 14-key `stats()` surface (5 tests).
788
+ - `test/38-onsettled.test.mjs` -- the 1.11.0 discriminator (9 tests, authored with the engine): `onSettled` throws without the capability and stays inert when off, fires once per top-level drain, coalesces under fan-out/`batch()`/nested writes, stays silent on empty and thrown flushes, unsubscribes cleanly with siblings unaffected.
786
789
  - `test/zgc/` -- the promoted zero-GC gate lane (`npm run test:zgc` + `test:zgc:report`): scavenge-witness scenarios under a 4 MB semi-space, Node-26 nursery-proofed ctrlPositive, `ZEROGC_BREAK` self-tests.
787
790
  - `test/ProfilerTests/` -- gc-profiler x engine hardening sub-package (`npm run test:hardening`; 28 tests, 22 execute + 6 version-gated skips).
788
791
  - `bench/benchmark.mjs` -- anti-DCE throughput harness (ops/s; results.txt).
789
792
  - `bench/mirror.mjs` + `bench/sweep.mjs` -- Andrii's canonical adapter verbatim, cross-framework rows diffing 1:1 against his log; aggregate output `rb.txt` (isolated-per-row).
790
793
  - `bench/dispose-recycle.mjs` -- 1.2.2 targeted microbench: create/dispose/recreate cycle (the free-list invariant audit target).
791
- - `bench/torture/` -- the complete **27-scenario superset (23 semantic + 4 soak)** -- the shipped canonical suite plus the 2026-08 audit-phase hardening (`contract-torture`, `interop-torture`, `retrack-dispose-torture`, `burst-profile-torture`, the opt-in `wraparound-torture`) -- behind one runner (`run.mjs`), two groups, forward-compatible through 1.9. Every scenario feature-detects and SKIPS cleanly below the engine version that introduces its feature, so the whole set is safe on the 1.10.0 engine and stays green from 1.4.x forward. On the 1.10.0 engine **26 of the 27 execute** (23 semantic + 3 soak) with **zero floor-skips** (as on 1.9.0 -- `dispose` was the last feature gate) -- and the wraparound soak is opt-in. `semantic` (deterministic, fast, asserts on MEANING; CI on every commit) -- all **23 semantic**: `oracle-fuzzer` (every computed vs an independent uncached reference, 400 seeds x 120 ops), `glitch-hunter` (glitch freedom + exact wakeups), `work-accounting` (minimum body-execution counts over 10 topologies), `op-accounting` (structural work from the `onGraphMutation` opcode lane, not wall-clock), `introspect-torture` (1.6.0: read-only introspection surface -- `describe`/`nodeId`/`hasObservers`/`isTracking`/`forEach*`/`ownerOf`/`observeObservers` -- walk-agreement + the ABA gen-stamp guard, `forEachOwned` pinned to EXACTLY 2 owned children), `concurrent-storm` (8 reentrancy / flush-ordering contracts), `scheduler-storm` (gen-bound thunk ABA guard, FLAG_QUEUED coalescing, throwing-scheduler containment), `box-torture` (1.5.0: signalBox/computedBox interop -- the oracle differential fuzz with every node realised as callable OR box), `scope-torture` (1.6.0: `createScope` adoption + disposal-crash fuzz + `runWithOwner` re-attachment), `retrack-dispose-torture` (the dispose-during-retracking cursor hazard: mid-retrack disposals under a survivor-value + pool oracle, plus a seeded disposal fuzz; hoisted so it runs from 1.4), `owner-torture` (1.6.0: `getOwner`/`runWithOwner` capture-restore -- live-owner adoption cascade-disposes, a STALE handle degrades to ROOTED, dep-isolation holds, plus a 300-seed capture/dispose/recycle/restore fuzz; native since 1.6.0), `async-torture` (watch / when / whenAsync contracts + a 300-seed projection-guard storm), `capacity-torture` (the fail-closed pool boundary + `CapacityError` + the 16x link-grow ceiling, growth terminating AT `maxLinks * 16` with a fail-closed re-throw), `error-torture` (throwing effect bodies under flush -- a single throw re-thrown UNWRAPPED, 2+ aggregated into an `AggregateError` carrying EXACTLY those errors, a survivor between two throwers still runs, and the error buffer drains flat over 4096 throw/clean cycles), `contract-torture` (throw-inside-batch commit+flush semantics incl the PENDING scheduler thunk, write-inside-computed in-pass delivery, the equals contract under churn, and the 1.6.0+ `flushPasses` pins on the abnormal paths), `interop-torture` (multi-registry isolation + `destroy()` staleness degradation: cross-registry handles stay inert, post-destroy handles read as stale), `deep-chain-torture` (`pullComputed` recursion fails CLOSED with a RangeError beyond the stack budget while the iterative push path stays open; the registry that threw stays usable and the re-throw is deterministic), `flush-torture` (1.7.0: the three `flushStrategy` modes by cross-strategy differential -- same graph + op sequence under eager/sab/manual reaching identical settled values -- plus per-strategy scheduling, re-entrant/empty `flush()`, and the `.subscribe()` contract under each), `zerogc-torture` (the zero-GC claim made falsifiable via `@zakkster/lite-gc-profiler`: `measureAllocs`/`checkAllocs` at `maxBytesPerCall: 0` + `measureOps`/`checkNoGc` at `maxMajor: 0`/`maxPauseMs: 2` + engine `stats()` deltas across steady + create/dispose churn, with the `churn-box` signalBox path active on 1.10.0 and a `ZEROGC_BREAK=1` self-test that must fail the gate), `burst-profile-torture` (the op-6/7 flush lane engine-raw: burst coalescing == 1.0x EXACTLY, pass accounting, `stats().flushPasses` agreement; `BURST_BREAK=drop7|ghost6` self-tests must fail the gate), `cleanup-return-torture` (1.8.0: an effect's returned cleanup -- timing at re-run/dispose, compose order appended after `onCleanup` from the same body, the self-dispose gen-guard, the computed exclusion, a 400-seed `return fn` vs `onCleanup(fn)` differential -- plus the 1.8.0-origin section 6b, which pins the 1.8 severTail cursor-repair by MECHANISM: five named deterministic dispose-mid-retrack geometries, including the cursor parked exactly on the freed link and a survivors-intact headDep check), `dispose-torture` (1.9.0, native here: `Symbol.dispose` stamped at five sites -- registry -> `destroy`, effect + `createScope` disposers -> themselves, both box PROTOTYPES shared per registry -- driven through the TC39 `using` path, idempotent disposal, feature-detected via the box-prototype stamp), `lifecycle-torture` (1.5.0 `createRoot` detachment -- detached children survive and stay reactive, deps isolated -- + 1.4.0 `destroy` registry reset that stales every handle and returns `stats().activeNodes` to 0; runs the createScope-native root-vs-scope differential); nothing floor-skips on this engine. `soak` (wall-clock bound, asserts on RESOURCES AND value-correctness via a once-allocated `Int32Array` shadow oracle -- a rotating fixed window per tick with zero per-tick allocation, a full sweep at teardown, mismatch -> exit 1 with seed+index; nightly): `graph-fuzzer`, `scheduler-bench`, `torture-soak`, plus the opt-in `wraparound-torture` (`TORTURE_WRAPAROUND=1`: the 2^31 dormancy band pinned at FULL distance, ~30s) -- exit 0 iff zero errors AND post-teardown pool at or below its leaf-only floor AND every shadowed value matched AND the JIT sink advanced. Runner spawns each scenario as a child process (several assert on global pool accounting), passes `--expose-gc` unconditionally, and ENFORCES version floors: a skip (exit 77) at/above the engine floor is a FAILURE, exit 78 marks an environment skip, each scenario gets a wall-clock cap, and a scenario that reaches PASS having asserted nothing fails. Scripts: `npm run torture`, `torture:semantic`, `torture:soak`.
794
+ - `bench/torture/` -- the complete **28-scenario superset (24 semantic + 4 soak)** -- the shipped canonical suite plus the 2026-08 audit-phase hardening (`contract-torture`, `interop-torture`, `retrack-dispose-torture`, `burst-profile-torture`, the opt-in `wraparound-torture`) -- behind one runner (`run.mjs`), two groups, forward-compatible through 1.11. Every scenario feature-detects and SKIPS cleanly below the engine version that introduces its feature, so the whole set is safe on the 1.11.0 engine and stays green from 1.4.x forward. On the 1.11.0 engine **27 of the 28 execute** (24 semantic + 3 soak) with **zero floor-skips** (as on 1.9.0/1.10.0 -- `dispose` was the last feature gate) -- and the wraparound soak is opt-in. `semantic` (deterministic, fast, asserts on MEANING; CI on every commit) -- all **24 semantic**: `oracle-fuzzer` (every computed vs an independent uncached reference, 400 seeds x 120 ops), `glitch-hunter` (glitch freedom + exact wakeups), `work-accounting` (minimum body-execution counts over 10 topologies), `op-accounting` (structural work from the `onGraphMutation` opcode lane, not wall-clock), `introspect-torture` (1.6.0: read-only introspection surface -- `describe`/`nodeId`/`hasObservers`/`isTracking`/`forEach*`/`ownerOf`/`observeObservers` -- walk-agreement + the ABA gen-stamp guard, `forEachOwned` pinned to EXACTLY 2 owned children), `concurrent-storm` (8 reentrancy / flush-ordering contracts), `scheduler-storm` (gen-bound thunk ABA guard, FLAG_QUEUED coalescing, throwing-scheduler containment), `box-torture` (1.5.0: signalBox/computedBox interop -- the oracle differential fuzz with every node realised as callable OR box), `scope-torture` (1.6.0: `createScope` adoption + disposal-crash fuzz + `runWithOwner` re-attachment), `retrack-dispose-torture` (the dispose-during-retracking cursor hazard: mid-retrack disposals under a survivor-value + pool oracle, plus a seeded disposal fuzz; hoisted so it runs from 1.4), `owner-torture` (1.6.0: `getOwner`/`runWithOwner` capture-restore -- live-owner adoption cascade-disposes, a STALE handle degrades to ROOTED, dep-isolation holds, plus a 300-seed capture/dispose/recycle/restore fuzz; native since 1.6.0), `async-torture` (watch / when / whenAsync contracts + a 300-seed projection-guard storm), `capacity-torture` (the fail-closed pool boundary + `CapacityError` + the 16x link-grow ceiling, growth terminating AT `maxLinks * 16` with a fail-closed re-throw), `error-torture` (throwing effect bodies under flush -- a single throw re-thrown UNWRAPPED, 2+ aggregated into an `AggregateError` carrying EXACTLY those errors, a survivor between two throwers still runs, and the error buffer drains flat over 4096 throw/clean cycles), `contract-torture` (throw-inside-batch commit+flush semantics incl the PENDING scheduler thunk, write-inside-computed in-pass delivery, the equals contract under churn, and the 1.6.0+ `flushPasses` pins on the abnormal paths), `interop-torture` (multi-registry isolation + `destroy()` staleness degradation: cross-registry handles stay inert, post-destroy handles read as stale), `deep-chain-torture` (`pullComputed` recursion fails CLOSED with a RangeError beyond the stack budget while the iterative push path stays open; the registry that threw stays usable and the re-throw is deterministic), `flush-torture` (1.7.0: the three `flushStrategy` modes by cross-strategy differential -- same graph + op sequence under eager/sab/manual reaching identical settled values -- plus per-strategy scheduling, re-entrant/empty `flush()`, and the `.subscribe()` contract under each), `zerogc-torture` (the zero-GC claim made falsifiable via `@zakkster/lite-gc-profiler`: `measureAllocs`/`checkAllocs` at `maxBytesPerCall: 0` + `measureOps`/`checkNoGc` at `maxMajor: 0`/`maxPauseMs: 2` + engine `stats()` deltas across steady + create/dispose churn, with the `churn-box` signalBox path active on 1.11.0, the 1.11.0 `steady-settled` lane (a LIVE `onSettled` subscriber under the full witness battery: retained 0 B, zero scavenges over the 1M-op window) and a `ZEROGC_BREAK=1` self-test that must fail the gate), `burst-profile-torture` (the op-6/7 flush lane engine-raw: burst coalescing == 1.0x EXACTLY, pass accounting, `stats().flushPasses` agreement; `BURST_BREAK=drop7|ghost6` self-tests must fail the gate), `cleanup-return-torture` (1.8.0: an effect's returned cleanup -- timing at re-run/dispose, compose order appended after `onCleanup` from the same body, the self-dispose gen-guard, the computed exclusion, a 400-seed `return fn` vs `onCleanup(fn)` differential -- plus the 1.8.0-origin section 6b, which pins the 1.8 severTail cursor-repair by MECHANISM: five named deterministic dispose-mid-retrack geometries, including the cursor parked exactly on the freed link and a survivors-intact headDep check), `dispose-torture` (1.9.0, native here: `Symbol.dispose` stamped at five sites -- registry -> `destroy`, effect + `createScope` disposers -> themselves, both box PROTOTYPES shared per registry -- driven through the TC39 `using` path, idempotent disposal, feature-detected via the box-prototype stamp), `settled-torture` (1.11.0, NATIVE here -- the `onSettled` creation-time capability: exact settle accounting across all three `flushStrategy` builds, fan/batch/cascade coalescing = ONE settle per top-level non-empty clean drain, the negative space (creation, empty flush, zero-write batch, thrown drain + recovery, re-entrant flush), observer isolation (a throwing callback is swallowed, ordered siblings still fire), mid-fire un/subscribe safety, destroy, 10k-cycle + 1000-batch exact soaks; `SETTLED_BREAK=phantom|lost` self-tests must fail the gate), `lifecycle-torture` (1.5.0 `createRoot` detachment -- detached children survive and stay reactive, deps isolated -- + 1.4.0 `destroy` registry reset that stales every handle and returns `stats().activeNodes` to 0; runs the createScope-native root-vs-scope differential); nothing floor-skips on this engine. `soak` (wall-clock bound, asserts on RESOURCES AND value-correctness via a once-allocated `Int32Array` shadow oracle -- a rotating fixed window per tick with zero per-tick allocation, a full sweep at teardown, mismatch -> exit 1 with seed+index; nightly): `graph-fuzzer`, `scheduler-bench`, `torture-soak`, plus the opt-in `wraparound-torture` (`TORTURE_WRAPAROUND=1`: the 2^31 dormancy band pinned at FULL distance, ~30s) -- exit 0 iff zero errors AND post-teardown pool at or below its leaf-only floor AND every shadowed value matched AND the JIT sink advanced. Runner spawns each scenario as a child process (several assert on global pool accounting), passes `--expose-gc` unconditionally, and ENFORCES version floors: a skip (exit 77) at/above the engine floor is a FAILURE, exit 78 marks an environment skip, each scenario gets a wall-clock cap, and a scenario that reaches PASS having asserted nothing fails. Scripts: `npm run torture`, `torture:semantic`, `torture:soak`.
792
795
  - `bench/run-all.sh` + `bench/aggregate.mjs` -- cold-process-per-engine protocol + per-scenario aggregation.
793
796
  - `harness/run.mjs` -- dispatcher for the run-on-demand probes (smoke, field, dispose, churn, owner, creation, perf, burst, pull, toe, mint, all).
794
- - `harness/mint-anatomy.mjs` -- mint+dispose cycle allocation anatomy (`mint` / `mint --verify`): per-op all-space vs new-space heap bytes for every creation primitive on a pre-grown throw-policy registry, fresh child per (variant, warmup) cell. Documents the 264 B/op callable cycle vs 56 B/op signalBox and the ALL-space accounting rule. Re-measured IDENTICAL on the 1.10.0 engine (SIXTH engine running) -- the cold `nodeNames.set` on named creation is off the unnamed fast path. `--verify` applies relative pins P1..P5.
797
+ - `harness/mint-anatomy.mjs` -- mint+dispose cycle allocation anatomy (`mint` / `mint --verify`): per-op all-space vs new-space heap bytes for every creation primitive on a pre-grown throw-policy registry, fresh child per (variant, warmup) cell. Documents the 264 B/op callable cycle vs 56 B/op signalBox and the ALL-space accounting rule. Re-measured IDENTICAL on the 1.11.0 engine (SEVENTH engine running) -- `CAP_SETTLED` is read once at `createRegistry`, off the mint path entirely. `--verify` applies relative pins P1..P5.
795
798
  - `harness/smoke.mjs` -- 1.7 flushStrategy semantics (eager/sab/manual) + `flush()`, and the 1.8 effect-cleanup-return contract (fires before re-run + on dispose, composes with onCleanup in call order, non-function returns ignored, computed-returning-a-function still yields the VALUE). ASSERTS, so it fails loudly on a regression. First in `harness:all` and `verify`.
796
799
  - `harness/perf-probe.mjs` -- sBench update-group shape, eager vs sab, per scenario.
797
800
  - `harness/fieldkit.mjs` -- single-file portable verify + cold-child A/B bench across six shapes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zakkster/lite-signal",
3
- "version": "1.10.0-preview",
3
+ "version": "1.11.0-preview",
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",