@zakkster/lite-signal 1.8.0-alpha.6 → 1.8.0-beta
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 +138 -0
- package/README.md +20 -12
- package/Signal.d.ts +10 -0
- package/Signal.js +145 -1
- package/llms.txt +20 -9
- package/package.json +14 -9
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,144 @@ 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.8.0-beta] -- 2026-09-06
|
|
8
|
+
|
|
9
|
+
The verification-infrastructure migration: the full 1.6.0-rc.1 / 1.7.0-beta audit
|
|
10
|
+
toolchain forward-ported onto the 1.8.0 engine. **The engine is byte-frozen** --
|
|
11
|
+
`Signal.js` changed by exactly one line (the version banner comment), `Signal.d.ts`
|
|
12
|
+
and `Watch.js` by zero. Everything below is test, gate, harness, and doc
|
|
13
|
+
infrastructure; no runtime behaviour moved.
|
|
14
|
+
|
|
15
|
+
### Added -- torture suite 22 -> 27 scenarios, audit-hardened runner
|
|
16
|
+
|
|
17
|
+
- **Five scenarios join the suite**: `contract-torture` (the probed behavioural
|
|
18
|
+
contract, pinned: throw-inside-batch commit+flush semantics, write-inside-computed
|
|
19
|
+
delivery, `flushPasses` exact counts), `interop-torture` (multi-registry isolation +
|
|
20
|
+
`destroy()` staleness degradation), `retrack-dispose-torture` (the
|
|
21
|
+
dispose-during-retracking cursor hazard as a seeded fuzz), `burst-profile-torture`
|
|
22
|
+
(the op-6/op-7 lane: coalescing exactly 1.0x, `BURST_BREAK=drop7|ghost6`
|
|
23
|
+
self-tests), and the opt-in `wraparound-torture` (`TORTURE_WRAPAROUND=1`: the 2^31
|
|
24
|
+
dormancy band pinned at full distance -- re-run here, 12/12).
|
|
25
|
+
- **Audit-hardened runner** (`run.mjs`): 3-state skip protocol (exit 77 floor-skip /
|
|
26
|
+
exit 78 env-skip), **version-floor enforcement** (a scenario that skips while the
|
|
27
|
+
engine is at or above its floor FAILS the run), per-scenario wall-clock caps, and
|
|
28
|
+
assert-nothing detection. On this engine: **25 execute / 1 floor-skip
|
|
29
|
+
(`dispose-torture` 1.9.0) / 1 opt-in**.
|
|
30
|
+
- **Folder-native supersets kept over the canonical copies** (reviewed per file):
|
|
31
|
+
`cleanup-return-torture` -- native here and RICHER than the canonical version: its
|
|
32
|
+
section 6b pins the 1.8 severTail cursor-repair **by mechanism** (five named
|
|
33
|
+
deterministic dispose-mid-retrack geometries, including the cursor parked exactly
|
|
34
|
+
on the freed link and a survivors-intact headDep check); `lifecycle-torture` with
|
|
35
|
+
the createScope-native root-vs-scope differential; the 1.8.0-re-anchored
|
|
36
|
+
`capacity`/`deep-chain`/`error` scenarios; `harness/smoke.mjs`; `test/30` with its
|
|
37
|
+
site audit anchored to 1.8.0 line numbers; the `test/34` config pair (OOM rows in
|
|
38
|
+
a child process under a 256MB cap). Both kept torture natives gained the runner's
|
|
39
|
+
exit-77 skip protocol (one-line patches).
|
|
40
|
+
- The audit-hardened scenario set (`zerogc-torture` with scavenge witness +
|
|
41
|
+
bounded-churn graveyard + `ZEROGC_BREAK=1|transient`, soak sentinels with the
|
|
42
|
+
Int32Array value-oracle, `introspect-torture` with the native-scope section 7b,
|
|
43
|
+
hardened `oracle-fuzzer`/`owner-torture`/`scope-torture`/`graph-fuzzer`/
|
|
44
|
+
`scheduler-bench`/`torture-soak`) replaces the July copies.
|
|
45
|
+
|
|
46
|
+
### Added -- test and gate lanes
|
|
47
|
+
|
|
48
|
+
- `test/zgc/` -- the promoted zero-GC gate lane (`npm run test:zgc` +
|
|
49
|
+
`test:zgc:report`), Node-26 nursery-proofed. 7/7 + 3/3 here.
|
|
50
|
+
- `test/ProfilerTests/` -- the gc-profiler hardening sub-package
|
|
51
|
+
(`npm run test:hardening`): 22 execute / 0 fail / 6 version-gated skips here.
|
|
52
|
+
- `test/25-devtools-real-boot.test.mjs` REWRITTEN against **devtools 1.6.2** via the
|
|
53
|
+
single-instance import-rewrite rig; the 13-key `capabilities()` fingerprint was
|
|
54
|
+
probed live on this engine before pinning: **`cleanupReturn:true` is the one flip
|
|
55
|
+
vs 1.7.0** (`flushControl:T`, `statsKeys:14`; 14 tests).
|
|
56
|
+
- `test/35-devtools-zerogc-probe.test.mjs` -- devtools attach/detach allocation
|
|
57
|
+
probes against the 14-key `stats()` surface (ported, renumbered above the folder
|
|
58
|
+
max).
|
|
59
|
+
- **VersionMatrix** carries the read + creation + exact-counter lanes with
|
|
60
|
+
trimmed-spread aggregation and the NO-EVIDENCE refusal. **GATE PASSED 5/5** vs
|
|
61
|
+
floor-1.3.0 + rolling-1.5.0; creation counters exact (288 allocs/frame,
|
|
62
|
+
0 poolGrowths, zero variance across 1500 frames).
|
|
63
|
+
|
|
64
|
+
### Measured on this engine (probe-before-pin)
|
|
65
|
+
|
|
66
|
+
- **Creation anatomy IDENTICAL for the fourth engine running**: signal(1)+dispose
|
|
67
|
+
264 B/op, computed 208, effect 160, signalBox/computedBox 56 -- all-space,
|
|
68
|
+
tier-invariant (`node harness/run.mjs mint --verify`, all pins PASS). The
|
|
69
|
+
out-of-line `registerCleanupReturn` ladder is provably outside the creation path,
|
|
70
|
+
exactly as its ledger-#18 counter-placement comment claims.
|
|
71
|
+
- **visit-anatomy: 21/21 exact structural pins hold with NO re-anchor needed** --
|
|
72
|
+
the cleanup ladder adds no `eq`-dispatch site (the eq x5 expectation from the 1.7
|
|
73
|
+
closure split carries unchanged). Both failure paths re-witnessed in scratch
|
|
74
|
+
clones: anchor drift refuses at exit 2 (6x vs expected 5), the gutted
|
|
75
|
+
short-circuit mutant fires `unrelated-read.depWalk` 640,000 vs pinned 0.
|
|
76
|
+
- **jit-health --strict**: signal/computed/signalBox/computedBox handle families all
|
|
77
|
+
MONOMORPHIC; fresh Node-26 deopt baseline recorded (5 engine-attributed bailouts).
|
|
78
|
+
- Probed cleanup-return compose order confirmed: imperative `onCleanup` fires before
|
|
79
|
+
the returned cleanup, in registration order, per run.
|
|
80
|
+
- Full ladder: unit 539/540 (0 fail, 1 skip), torture 25/2/0 in 30.6s, wraparound
|
|
81
|
+
full-distance 12/12, zgc 7/7 + report 3/3, hardening 22/0/6, harness 5/5, all four
|
|
82
|
+
BREAK mutants exit 1.
|
|
83
|
+
|
|
84
|
+
### Changed
|
|
85
|
+
|
|
86
|
+
- devDeps: `@zakkster/lite-devtools` ^1.2.0 -> **^1.6.2**,
|
|
87
|
+
`@zakkster/lite-gc-profiler` ^1.15.0 -> **^1.16.0**.
|
|
88
|
+
- Test scripts are now glob-scoped (`'test/*.test.mjs'`) so the new `test/zgc/` and
|
|
89
|
+
`test/ProfilerTests/` sub-lanes stay separate lanes instead of being swept into
|
|
90
|
+
bare `node --test` discovery (which would run them without their required flags);
|
|
91
|
+
added `test:report`, `test:hardening(:gc)`, `test:zgc(:report)`, `test:all`;
|
|
92
|
+
`test:harness` now runs the ProfilerTools sub-package via `npm --prefix`;
|
|
93
|
+
`verify` gained `test:zgc`.
|
|
94
|
+
|
|
95
|
+
### Removed
|
|
96
|
+
|
|
97
|
+
- The stale `bench-reactive` script -- its target (`bench/benchmarkReactive.mjs`)
|
|
98
|
+
was deliberately removed from the suite at 1.6.0-beta and does not exist in this
|
|
99
|
+
folder; the cross-framework standing lives in `bench/mirror.mjs` + `bench/sweep.mjs`.
|
|
100
|
+
- The stale `llms.txt` File-layout claims: the `demo/index.html` line (no `demo/`
|
|
101
|
+
dir in this folder), the `benchmarkReactive.mjs` line, and the "wired as
|
|
102
|
+
prepublishOnly" description of the VersionMatrix gate (it is `npm run gate`).
|
|
103
|
+
|
|
104
|
+
## [1.8.0-alpha.7] -- 2026-08-20
|
|
105
|
+
|
|
106
|
+
Backports the **1.4.5 `createRegistry` input validation** (all four findings) onto
|
|
107
|
+
the 1.8.0-alpha.6 engine. Supersedes 1.8.0-alpha.6. Only `createRegistry`'s *cold*
|
|
108
|
+
construction path changed -- the hot paths are byte-identical and the zero-GC gates
|
|
109
|
+
(`bench/torture/run.mjs` 22/22) are unchanged. If you had a typo in your registry
|
|
110
|
+
config, you will now hear about it.
|
|
111
|
+
|
|
112
|
+
### Added -- createRegistry validates its config (fail closed)
|
|
113
|
+
|
|
114
|
+
- **Bounded eager construction.** `prealloc:"eager"` with a non-finite or absurd
|
|
115
|
+
capacity (`maxNodes:Infinity`, `maxNodes:1e9`) previously ran an unbounded
|
|
116
|
+
construction loop and killed the process with an **uncatchable SIGABRT**. It now
|
|
117
|
+
throws a `TypeError` **by name**, before allocating, gated on `(maxNodes+maxLinks)`
|
|
118
|
+
against a ceiling of `1<<24` (16,777,216) objects. `prealloc:"lazy"` keeps its
|
|
119
|
+
unbounded on-demand ledger, untouched.
|
|
120
|
+
- **Per-option validation by name.** `maxNodes` / `maxLinks` / `maxFlushPasses` must
|
|
121
|
+
be finite integers `>= 1`; `prealloc` must be exactly `"eager"` | `"lazy"`;
|
|
122
|
+
`onCapacityExceeded` must be exactly `"throw"` | `"grow"`. Each bad value throws a
|
|
123
|
+
`TypeError` prefixed `createRegistry: "<option>"` at construction -- not a delayed
|
|
124
|
+
internal `nextFree` TypeError on first use.
|
|
125
|
+
- **Config-shape gate.** A non-object, `null`, or array `config` throws
|
|
126
|
+
`createRegistry: "config"` rather than dying later.
|
|
127
|
+
- **Unknown-key rejection with did-you-mean.** An unrecognized key throws with a
|
|
128
|
+
Levenshtein suggestion (`maxNods` -> `maxNodes`, `preAlloc` -> `prealloc`) instead
|
|
129
|
+
of being silently ignored.
|
|
130
|
+
- **`flushStrategy` stays a first-class option.** It is a recognized key (its own native value-guard is unchanged); only misspelled *keys* are rejected.
|
|
131
|
+
- **`stats()` gains `nodePoolPopulation` / `linkPoolPopulation`** -- the TRUE count
|
|
132
|
+
of physically constructed nodes/links, distinct from the `*Capacity` ledgers. A
|
|
133
|
+
silently mis-set `prealloc` is now observable (population 0 under lazy) instead of
|
|
134
|
+
telemetry-blind. **The one observable API change: `stats()` grows to 14 keys,
|
|
135
|
+
purely additive** -- no existing key changed; only an exact key-*count* assertion
|
|
136
|
+
is affected (updated in `test/03-pool.test.mjs`).
|
|
137
|
+
|
|
138
|
+
### Tests
|
|
139
|
+
|
|
140
|
+
New `test/*-config-validation.test.mjs` adds the full config matrix, the did-you-mean
|
|
141
|
+
cases, the eager ceiling, the population contract, and the three OOM rows as isolated
|
|
142
|
+
child-process cases proving the fixed engine throws + exits 0 under a 256 MB cap where
|
|
143
|
+
the unvalidated engine died.
|
|
144
|
+
|
|
7
145
|
## [1.8.0-alpha.5] -- 2026-08-18
|
|
8
146
|
|
|
9
147
|
Brings the `bench/torture/` suite and the throwing-`equals` unit test to **full
|
package/README.md
CHANGED
|
@@ -878,15 +878,17 @@ npm run bench
|
|
|
878
878
|
|
|
879
879
|
### Tier 4 -- Torture (correctness and resources under chaos)
|
|
880
880
|
|
|
881
|
-
`bench/torture/` holds the complete **
|
|
882
|
-
soak)** behind one runner (`run.mjs`), the forward-compatible set
|
|
883
|
-
They are not perf benchmarks: the ops/sec figures reflect random
|
|
884
|
-
composition, not engine throughput -- `bench/benchmark.mjs` remains the
|
|
885
|
-
perf harness. Every scenario feature-detects and **skips cleanly**
|
|
886
|
-
engine version that introduces its feature,
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
881
|
+
`bench/torture/` holds the complete **27-scenario superset (23 semantic + 4
|
|
882
|
+
soak, one opt-in)** behind one runner (`run.mjs`), the forward-compatible set
|
|
883
|
+
through 1.9. They are not perf benchmarks: the ops/sec figures reflect random
|
|
884
|
+
workload composition, not engine throughput -- `bench/benchmark.mjs` remains the
|
|
885
|
+
canonical perf harness. Every scenario feature-detects and **skips cleanly**
|
|
886
|
+
(exit 77) below the engine version that introduces its feature, and the runner
|
|
887
|
+
**enforces the floors**: a scenario that skips while the engine is at or above
|
|
888
|
+
its floor FAILS the run -- a dropped export cannot masquerade as a green skip.
|
|
889
|
+
On the 1.8.0 engine the runner executes **22 semantic** scenarios (including
|
|
890
|
+
`cleanup-return-torture`, native here) and reports a clean SKIP for the one
|
|
891
|
+
remaining later-version scenario (`dispose-torture` 1.9.0).
|
|
890
892
|
|
|
891
893
|
```bash
|
|
892
894
|
npm run torture # everything
|
|
@@ -920,7 +922,11 @@ tagged `1.9.0+` scenario feature-detects and SKIPs on this engine.
|
|
|
920
922
|
| `error-torture` | throwing effect bodies: single throw re-thrown unwrapped, 2+ aggregate into an exact-order `AggregateError`, survivor still runs, buffer drains over 4096 cycles with `activeNodes`/`activeLinks` flat |
|
|
921
923
|
| `deep-chain-torture` | `pullComputed` recursion fail-closed (a `RangeError` at some depth <= the ceiling; registry stays usable, deterministic re-throw) vs the heap-iterative push cascade that completes |
|
|
922
924
|
| `flush-torture` (1.7.0) | the three `flushStrategy` modes by cross-strategy differential (same graph + op sequence under eager/sab/manual settling to identical values), per-strategy scheduling, re-entrant/empty `flush()`, and the `.subscribe()` contract under each |
|
|
923
|
-
| `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 guard, and the computed exclusion -- 400 seeds |
|
|
925
|
+
| `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 guard, and the computed exclusion -- 400 seeds; plus the 1.8 severTail cursor-repair pinned by mechanism (five named dispose-mid-retrack geometries, section 6b) |
|
|
926
|
+
| `retrack-dispose-torture` (1.6.0) | dispose-during-retracking: the cursor hazard the 1.8 repair targets, driven as a seeded fuzz across cursor positions with scope-native sections |
|
|
927
|
+
| `contract-torture` | the probed 1.5.0 behavioural contract, pinned: write-inside-computed staleness, throw-in-batch flush semantics, stranded scheduler thunks, `flushPasses` exact counts |
|
|
928
|
+
| `interop-torture` | cross-surface interop: callable x box x scope x owner combinations against the value oracle |
|
|
929
|
+
| `burst-profile-torture` (1.6.0) | the op-6/op-7 burst lane: batched write-bursts coalesce to exactly 1.0x (zero redundant recomputes), payload sanity, observe-only hook contract; `BURST_BREAK=drop7|ghost6` self-tests |
|
|
924
930
|
| `zerogc-torture` | the falsifiable zero-GC gate: retained bytes (`measureAllocs`/`checkAllocs`, `maxBytesPerCall: 0`), major/pause window (`measureOps`/`checkNoGc`, `maxMajor: 0`), and `stats()` counters across steady + churn scenarios; `ZEROGC_BREAK=1` self-test |
|
|
925
931
|
| `lifecycle-torture` (1.5.0) | `createRoot` detachment (children survive, deps isolated) + `destroy` full registry reset (handles stale, pool baseline restored) |
|
|
926
932
|
| `dispose-torture` (1.9.0+) | `Symbol.dispose` / `using` on lifecycle objects -- SKIP on 1.8.0 |
|
|
@@ -930,8 +936,9 @@ tagged `1.9.0+` scenario feature-detects and SKIPs on this engine.
|
|
|
930
936
|
Three soak harnesses build large randomised graphs (1,500 / 7,500 / 3,300 nodes)
|
|
931
937
|
and run mixed fuzz workloads -- leaf writes, batched writes, computed rewires,
|
|
932
938
|
effect rewires, nested-batch + untrack reads, and microtask-scheduled async
|
|
933
|
-
flushes -- for 5-10 seconds
|
|
934
|
-
|
|
939
|
+
flushes -- for 5-10 seconds; a fourth, opt-in soak spins the 32-bit version
|
|
940
|
+
counter across the full 2^31 dormancy band. What they assert, with a non-zero
|
|
941
|
+
exit code on failure:
|
|
935
942
|
|
|
936
943
|
- zero thrown exceptions during the run, and
|
|
937
944
|
- after teardown, `activeNodes` / `activeLinks` return to the leaf-only baseline (the dispose path is sound under sustained churn), and
|
|
@@ -941,6 +948,7 @@ failure:
|
|
|
941
948
|
node --expose-gc bench/torture/graph-fuzzer.mjs # 10s random-DAG fuzz, 1500 nodes
|
|
942
949
|
node --expose-gc bench/torture/torture-soak.mjs # 5s high-volume churn, 7500 nodes
|
|
943
950
|
node --expose-gc bench/torture/scheduler-bench.mjs # 10s microtask-scheduled, 3300 nodes
|
|
951
|
+
TORTURE_WRAPAROUND=1 node bench/torture/wraparound-torture.mjs # ~50s full-distance 2^31 dormancy-band soak (opt-in)
|
|
944
952
|
```
|
|
945
953
|
|
|
946
954
|
Run any of them with `TORTURE_SECONDS=N` for a longer soak. Indicative numbers from a development host (post-teardown pool returns to baseline in all three):
|
package/Signal.d.ts
CHANGED
|
@@ -136,6 +136,16 @@ export interface RegistryStats {
|
|
|
136
136
|
/** Node-pool capacity ledger. Doubles under the `"grow"` policy; under `"lazy"`
|
|
137
137
|
* prealloc it may exceed the count of physically constructed nodes. */
|
|
138
138
|
nodePoolCapacity: number;
|
|
139
|
+
/** TRUE node-pool population: the number of `ReactiveNode`s physically constructed
|
|
140
|
+
* (`nodePool.length`), distinct from the `nodePoolCapacity` ledger. Under
|
|
141
|
+
* `prealloc:"lazy"` (or a silently-flipped `prealloc` typo) this stays 0 until
|
|
142
|
+
* first demand while capacity reads the ledger -- so a mis-set `prealloc` is
|
|
143
|
+
* observable here rather than telemetry-blind. Added in the 1.4.5 backport. */
|
|
144
|
+
nodePoolPopulation: number;
|
|
145
|
+
/** TRUE link-pool population: the number of `ReactiveLink`s physically constructed
|
|
146
|
+
* (`linkPool.length`), distinct from the `linkPoolCapacity` ledger. Added in the
|
|
147
|
+
* 1.4.5 backport. */
|
|
148
|
+
linkPoolPopulation: number;
|
|
139
149
|
/** Number of nodes currently allocated (signals + computeds + alive effects). */
|
|
140
150
|
activeNodes: number;
|
|
141
151
|
/**
|
package/Signal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zakkster/lite-signal v1.8.0-
|
|
2
|
+
* @zakkster/lite-signal v1.8.0-beta
|
|
3
3
|
* Copyright (c) Zahary Shinikchiev <shinikchiev@yahoo.com>
|
|
4
4
|
* MIT License
|
|
5
5
|
* --------------------
|
|
@@ -274,10 +274,134 @@ export class CapacityError extends Error {
|
|
|
274
274
|
* Error prefixed `"CycleError:"`.
|
|
275
275
|
* @returns {Registry}
|
|
276
276
|
*/
|
|
277
|
+
/** The only config keys {@link createRegistry} recognizes. Anything else is
|
|
278
|
+
* rejected at construction with a did-you-mean hint (fail closed on an
|
|
279
|
+
* unverified state -- an unknown key is an error, never a silent ignore). */
|
|
280
|
+
const ALLOWED_KEYS = ["maxNodes", "maxLinks", "prealloc", "onCapacityExceeded", "maxFlushPasses", "flushStrategy"];
|
|
281
|
+
|
|
282
|
+
/** Ceiling on eager pool construction: `(maxNodes + maxLinks)` objects. A finite
|
|
283
|
+
* but absurd `maxNodes` (e.g. `1e9`, a plausible typo for `1e5`) that would
|
|
284
|
+
* otherwise OOM the process is refused BY NAME at construction rather than
|
|
285
|
+
* allocating forever. Only the `"eager"` path is bounded; `"lazy"` keeps its
|
|
286
|
+
* unbounded ledger. `1 << 24` == 16777216. */
|
|
287
|
+
const EAGER_CONSTRUCT_CEILING = 1 << 24;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Levenshtein edit distance between two short strings. Cold: called only on the
|
|
291
|
+
* constructor error path, over the known option names, so its per-call array
|
|
292
|
+
* allocation never touches any hot path.
|
|
293
|
+
* @param {string} a
|
|
294
|
+
* @param {string} b
|
|
295
|
+
* @returns {number}
|
|
296
|
+
*/
|
|
297
|
+
function editDistance(a, b) {
|
|
298
|
+
const m = a.length;
|
|
299
|
+
const n = b.length;
|
|
300
|
+
const prev = new Array(n + 1);
|
|
301
|
+
const cur = new Array(n + 1);
|
|
302
|
+
for (let j = 0; j <= n; j++) prev[j] = j;
|
|
303
|
+
for (let i = 1; i <= m; i++) {
|
|
304
|
+
cur[0] = i;
|
|
305
|
+
for (let j = 1; j <= n; j++) {
|
|
306
|
+
const cost = a.charCodeAt(i - 1) === b.charCodeAt(j - 1) ? 0 : 1;
|
|
307
|
+
let min = prev[j] + 1;
|
|
308
|
+
if (cur[j - 1] + 1 < min) min = cur[j - 1] + 1;
|
|
309
|
+
if (prev[j - 1] + cost < min) min = prev[j - 1] + cost;
|
|
310
|
+
cur[j] = min;
|
|
311
|
+
}
|
|
312
|
+
for (let j = 0; j <= n; j++) prev[j] = cur[j];
|
|
313
|
+
}
|
|
314
|
+
return prev[n];
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* The closest known config key to `key` within edit distance 2 (case-folded so
|
|
319
|
+
* `preAlloc`/`MAXNODES` resolve), or null when nothing is close. Cold path only.
|
|
320
|
+
* @param {string} key
|
|
321
|
+
* @returns {string|null}
|
|
322
|
+
*/
|
|
323
|
+
function suggestKey(key) {
|
|
324
|
+
const lk = key.toLowerCase();
|
|
325
|
+
let best = null;
|
|
326
|
+
let bestD = 3;
|
|
327
|
+
for (let i = 0; i < ALLOWED_KEYS.length; i++) {
|
|
328
|
+
const d = editDistance(lk, ALLOWED_KEYS[i].toLowerCase());
|
|
329
|
+
if (d < bestD) { bestD = d; best = ALLOWED_KEYS[i]; }
|
|
330
|
+
}
|
|
331
|
+
return bestD <= 2 ? best : null;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Render a rejected value for an error message, e.g. `42 (number)`.
|
|
336
|
+
* Cold: this runs only on a throw path, never on any hot path. `String(symbol)`
|
|
337
|
+
* throws, so symbols are stringified defensively.
|
|
338
|
+
* @param {*} v
|
|
339
|
+
* @returns {string}
|
|
340
|
+
*/
|
|
341
|
+
function received(v) {
|
|
342
|
+
return (typeof v === "symbol" ? v.toString() : String(v)) + " (" + typeof v + ")";
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Validate that a numeric option is a finite integer >= 1. Cold: constructor
|
|
347
|
+
* error path only. Throws a {@link TypeError} prefixed `createRegistry: "<name>"`.
|
|
348
|
+
* @param {*} v
|
|
349
|
+
* @param {string} name
|
|
350
|
+
*/
|
|
351
|
+
function requirePositiveInt(v, name) {
|
|
352
|
+
if (!Number.isInteger(v) || v < 1) {
|
|
353
|
+
throw new TypeError(
|
|
354
|
+
'createRegistry: "' + name + '" must be a finite integer >= 1, received ' + received(v) + '.'
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
277
359
|
export function createRegistry(config) {
|
|
278
360
|
const NODE_PTR = Symbol("node_ptr");
|
|
279
361
|
const NODE_GEN = Symbol("node_gen");
|
|
280
362
|
|
|
363
|
+
// --- 1.4.5 backport: createRegistry input validation (all cold, constructor-only).
|
|
364
|
+
// Config-shape gate: accept `undefined` or a non-null, non-array object; reject
|
|
365
|
+
// `null`, primitives and arrays BY NAME rather than dying later on `config.maxNodes`
|
|
366
|
+
// or an internal `nextFree` read (fail closed on an unverified state).
|
|
367
|
+
if (config !== undefined && (config === null || typeof config !== "object" || Array.isArray(config))) {
|
|
368
|
+
throw new TypeError(
|
|
369
|
+
'createRegistry: "config" must be a plain object or undefined, received ' + received(config) + '.'
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
if (config !== undefined) {
|
|
373
|
+
// Per-option validation BY NAME -- a bad value throws `createRegistry: "<option>"`
|
|
374
|
+
// at construction, not a delayed internal TypeError on first use.
|
|
375
|
+
if (config.maxNodes !== undefined) requirePositiveInt(config.maxNodes, "maxNodes");
|
|
376
|
+
if (config.maxLinks !== undefined) requirePositiveInt(config.maxLinks, "maxLinks");
|
|
377
|
+
if (config.maxFlushPasses !== undefined) requirePositiveInt(config.maxFlushPasses, "maxFlushPasses");
|
|
378
|
+
if (config.prealloc !== undefined && config.prealloc !== "eager" && config.prealloc !== "lazy") {
|
|
379
|
+
throw new TypeError(
|
|
380
|
+
'createRegistry: "prealloc" must be "eager" or "lazy", received ' + received(config.prealloc) + '.'
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
if (config.onCapacityExceeded !== undefined && config.onCapacityExceeded !== "throw" && config.onCapacityExceeded !== "grow") {
|
|
384
|
+
throw new TypeError(
|
|
385
|
+
'createRegistry: "onCapacityExceeded" must be "throw" or "grow", received ' + received(config.onCapacityExceeded) + '.'
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
// Unknown-key rejection with a did-you-mean hint (`preAlloc` -> `prealloc`,
|
|
389
|
+
// `maxNods` -> `maxNodes`). Own enumerable keys only; cold path.
|
|
390
|
+
const badKeys = Object.keys(config);
|
|
391
|
+
for (let bi = 0; bi < badKeys.length; bi++) {
|
|
392
|
+
const bk = badKeys[bi];
|
|
393
|
+
if (ALLOWED_KEYS.indexOf(bk) === -1) {
|
|
394
|
+
const hint = suggestKey(bk);
|
|
395
|
+
throw new TypeError(
|
|
396
|
+
'createRegistry: "' + bk + '" is not a recognized option' +
|
|
397
|
+
(hint !== null ? ' (did you mean "' + hint + '"?)' : '') +
|
|
398
|
+
'. Allowed: ' + ALLOWED_KEYS.join(", ") + '.'
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// --- end 1.4.5 backport.
|
|
404
|
+
|
|
281
405
|
let currentNodesCapacity = (config !== undefined && config.maxNodes !== undefined) ? config.maxNodes : 1024;
|
|
282
406
|
let currentLinkCapacity = (config !== undefined && config.maxLinks !== undefined) ? config.maxLinks : currentNodesCapacity * 4;
|
|
283
407
|
const policy = (config !== undefined && config.onCapacityExceeded !== undefined) ? config.onCapacityExceeded : "throw";
|
|
@@ -301,6 +425,20 @@ export function createRegistry(config) {
|
|
|
301
425
|
// steady state is identical after warm-up, but the heap no longer carries
|
|
302
426
|
// never-used live objects for every major GC to mark.
|
|
303
427
|
const prealloc = (config !== undefined && config.prealloc !== undefined) ? config.prealloc : "eager";
|
|
428
|
+
// Eager-construction ceiling (cold): `"eager"` builds `(maxNodes + maxLinks)`
|
|
429
|
+
// objects up front; a finite-but-absurd capacity (e.g. `1e9`) would OOM the
|
|
430
|
+
// process with an uncatchable SIGABRT, not a throw. Refuse BY NAME before
|
|
431
|
+
// allocating. Named for the larger driver. `"lazy"` keeps its unbounded ledger.
|
|
432
|
+
if (prealloc === "eager" && (currentNodesCapacity + currentLinkCapacity) > EAGER_CONSTRUCT_CEILING) {
|
|
433
|
+
const driver = currentLinkCapacity > currentNodesCapacity ? "maxLinks" : "maxNodes";
|
|
434
|
+
throw new TypeError(
|
|
435
|
+
'createRegistry: "' + driver + '" eager construction of ' +
|
|
436
|
+
(currentNodesCapacity + currentLinkCapacity) + ' objects (maxNodes ' +
|
|
437
|
+
currentNodesCapacity + ' + maxLinks ' + currentLinkCapacity + ') exceeds the ceiling of ' +
|
|
438
|
+
EAGER_CONSTRUCT_CEILING + '. Use prealloc:"lazy" for an unbounded on-demand ledger, ' +
|
|
439
|
+
'or lower the capacity.'
|
|
440
|
+
);
|
|
441
|
+
}
|
|
304
442
|
const nodePool = [];
|
|
305
443
|
let freeNodeHead = null;
|
|
306
444
|
const linkPool = [];
|
|
@@ -1858,6 +1996,12 @@ export function createRegistry(config) {
|
|
|
1858
1996
|
pooledLinks: currentLinkCapacity - activeLinks,
|
|
1859
1997
|
linkPoolCapacity: currentLinkCapacity,
|
|
1860
1998
|
nodePoolCapacity: currentNodesCapacity,
|
|
1999
|
+
// 1.4.5 backport: TRUE pool population (nodePool.length / linkPool.length),
|
|
2000
|
+
// distinct from the *Capacity ledgers above. Under prealloc:"lazy" (or a
|
|
2001
|
+
// silently-flipped `prealloc` typo) population stays 0 while capacity reads
|
|
2002
|
+
// the ledger -- so a mis-set prealloc is now observable, not telemetry-blind.
|
|
2003
|
+
nodePoolPopulation: nodePool.length,
|
|
2004
|
+
linkPoolPopulation: linkPool.length,
|
|
1861
2005
|
activeNodes,
|
|
1862
2006
|
// 1.4: cumulative lifecycle counters (monotonic; reset by destroy()).
|
|
1863
2007
|
// Derive: allocationRate = deltatotalAllocations/deltat; poolReuseRate =
|
package/llms.txt
CHANGED
|
@@ -16,7 +16,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
16
16
|
- **Signal**: root reactive cell. `signal(initial, { equals? })` returns a function. Call it to read (tracked), use `.peek()` to read without tracking, `.set(v)` to notify downstream, `.update(fn)` for read-modify-write, `.subscribe(fn)` for an effect-backed listener.
|
|
17
17
|
- **Computed**: lazy memoized derivation. `computed(fn, { equals? })`. Cache hits return in O(deps) (version comparison only). Cache misses re-run the body and refresh `evalVersion`. Errors are cached via `FLAG_HAS_ERROR` and re-thrown on every read until a dep changes.
|
|
18
18
|
- **Effect**: side-effect runner. `effect(fn, { scheduler? })`. Runs immediately on creation, then on any tracked dep change. Returns a dispose function. Optional scheduler defers execution (e.g., to rAF, microtask, custom frame loop).
|
|
19
|
-
- **Box (1.5.0)**: non-callable, allocation-light variants. `signalBox(initial, { equals? })` returns `{ get, set, peek, update, subscribe }`; `computedBox(fn, { equals? })` returns `{ get, peek, subscribe }` (no set/update -- derived). Same `ReactiveNode` and zero-GC read/write path as the callable forms, full interop in one graph (a callable can read `box.get()` and vice versa). Construction is ~1.7x cheaper than the callable (an `Object.create(proto)` handle, not a closure). Built on a shared prototype from the start -- never `setPrototypeOf` (which would deopt the method-call ICs to megamorphic). Exported as registry methods and top-level helpers.
|
|
19
|
+
- **Box (1.5.0)**: non-callable, allocation-light variants. `signalBox(initial, { equals? })` returns `{ get, set, peek, update, subscribe }`; `computedBox(fn, { equals? })` returns `{ get, peek, subscribe }` (no set/update -- derived). Same `ReactiveNode` and zero-GC read/write path as the callable forms, full interop in one graph (a callable can read `box.get()` and vice versa). Construction is ~1.7x cheaper than the callable (an `Object.create(proto)` handle, not a closure). Measured at **56 B/op per mint+dispose cycle vs 264 B/op for the callable** (all-space, node v26.3.1, probed on this engine -- the out-of-line cleanup-return ladder sits outside the creation path; see `node harness/run.mjs mint`). The box guard stays DECIDABLE because each box is a fresh identity carrying its own `NODE_GEN`, so pooling closure identity is not needed to cut the cost. Built on a shared prototype from the start -- never `setPrototypeOf` (which would deopt the method-call ICs to megamorphic). Exported as registry methods and top-level helpers.
|
|
20
20
|
- **createRoot (1.5.0)**: `createRoot(fn)` runs `fn` in a detached ownership scope and returns `fn`'s value. Effects/computeds created directly in `fn` are NOT adopted by the enclosing owner, so they survive its re-runs/disposal (the caller owns their lifecycle). Both ownership and tracking are detached for `fn`'s direct body; inner effect/computed bodies still establish their own scopes. The escape hatch for lazily spawning a long-lived node from inside a consumer effect (e.g. `lite-query`'s query-watcher) -- without it, the consumer owns the watcher and cascade-disposes it on its next re-run. Mirrors Solid's `createRoot`. The re-attach companion `runWithOwner` is named in the engine as the intended second half and is not yet shipped.
|
|
21
21
|
- **dispose(api)**: universal disposal. Accepts a signal, computed, or effect dispose handle; idempotent; cross-registry calls are silent no-ops (per-registry `Symbol("node_ptr")` keys the node-identity slot on the returned API function, foreign signals fail the lookup and fall through). Passing an unrelated value is also safe; passing an arbitrary function invokes it (effect-handle contract).
|
|
22
22
|
- **Batch**: `batch(fn)` defers effect flush until the outermost batch closes. Nestable.
|
|
@@ -25,7 +25,7 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
25
25
|
- **onCleanup**: registers teardown for the current computation; fires before each re-run and once on dispose. Works in effects and computeds.
|
|
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
|
-
- **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.
|
|
28
|
+
- **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.8.0-alpha.7, 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
29
|
- **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.
|
|
30
30
|
|
|
31
31
|
## Architecture invariants
|
|
@@ -53,7 +53,9 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
|
|
|
53
53
|
|
|
54
54
|
## Version notes
|
|
55
55
|
|
|
56
|
-
- **1.8.0-
|
|
56
|
+
- **1.8.0-beta** (current): the verification-infrastructure migration -- the full 1.6.0-rc.1/1.7.0-beta audit toolchain forward-ported onto the 1.8.0 engine with the ENGINE BYTE-FROZEN (banner comment only). bench/torture grows 22 -> 27 scenarios (adds `contract-torture`, `interop-torture`, `retrack-dispose-torture`, `burst-profile-torture`, the opt-in `wraparound-torture`; audit-hardened runner: 3-state skip protocol, version-floor enforcement -- a skip at/above floor FAILS -- per-scenario wall-clock caps, assert-nothing detection). THIS folder's richer natives KEPT over the canonical copies: `cleanup-return-torture` (section 6b pins the 1.8 severTail cursor-repair by mechanism), `lifecycle-torture` (createScope-native root-vs-scope differential), the 1.8.0-re-anchored capacity/deep-chain/error scenarios, `harness/smoke.mjs`, `test/30` at 1.8.0 line refs, and the `test/34` config pair (OOM rows in a child under a 256MB cap). New lanes: `test/zgc/` (`test:zgc` + `test:zgc:report`), `test/ProfilerTests/` (`test:hardening`), `test/35` devtools-zerogc probe; `test/25` REWRITTEN against **devtools 1.6.2** (live-probed 13-key fingerprint -- `cleanupReturn:T` is the one flip vs 1.7.0; `flushControl:T`, `statsKeys:14`; 14 tests). Harness gains `mint-anatomy` (re-measured IDENTICAL for the fourth engine running: signal 264 / computed 208 / effect 160 / boxes 56 B/op all-space -- the out-of-line cleanup-return ladder is provably off the creation path), `visit-anatomy --verify` (21 exact structural pins hold with NO re-anchor needed -- the cleanup ladder adds no eq-dispatch site; both failure paths re-witnessed in scratch clones), `jit-health --strict` (4 handle families monomorphic; fresh Node-26 deopt baseline), costmodel / floors / trend / creation-anatomy / burst-real, and the phase-3 rewrites of andrii-isolated / creation-isolated / owner-hazard-repro. VersionMatrix carries the read + creation + exact-counter lanes with trimmed-spread aggregation and the NO-EVIDENCE refusal; **GATE PASSED 5/5** vs floor-1.3.0 + rolling-1.5.0 (creation counters exact: 288 allocs/frame, 0 poolGrowths, zero variance over 1500 frames). Verified ladder on node v26.3.1: unit 539/540 (0 fail, 1 skip), torture 25/2/0 in 30.6s, wraparound full-distance 12/12, zgc 7/7 + report 3/3, hardening 22/0/6, harness 5/5, ZEROGC_BREAK=1|transient and BURST_BREAK=drop7|ghost6 all exit 1. devDeps: devtools ^1.6.2, gc-profiler ^1.16.0; test scripts glob-scoped ('test/*.test.mjs'); the stale `bench-reactive` script dropped (its target was removed at 1.6.0-beta). See CHANGELOG `[1.8.0-beta]`.
|
|
57
|
+
- **1.8.0-alpha.7**: backports the **1.4.5 `createRegistry` input validation** (all four findings) onto the 1.8.0-alpha.6 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.8.0-alpha.7]`.
|
|
58
|
+
- **1.8.0-alpha.4**: the **effect-cleanup-return minor**. An EFFECT body
|
|
57
59
|
may now `return` a cleanup function (Solid/Vue/Reflex-compatible), run at the same
|
|
58
60
|
points as imperative `onCleanup` -- before each re-run and once on dispose -- and
|
|
59
61
|
APPENDED after any `onCleanup` from the same body, so both compose in call order.
|
|
@@ -723,14 +725,24 @@ function dumpOwnerTree(handle, depth = 0) {
|
|
|
723
725
|
- `test/22-mutation-hook.test.mjs` -- 1.2.1 `onGraphMutation` registration + opcode emission (12 tests).
|
|
724
726
|
- `test/23-owner-introspection.test.mjs` -- `ownerOf`, `forEachOwned`, gen-guarded introspection (14 tests).
|
|
725
727
|
- `test/24-signalbox.test.mjs` -- staged for 1.5.0; all tests `{skip: true}` on 1.2.x.
|
|
726
|
-
- `test/25-devtools-real-boot.test.mjs` -- 1.
|
|
728
|
+
- `test/25-devtools-real-boot.test.mjs` -- real **devtools 1.6.2** boot against the 1.8.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`), live `burstProfile()` stop-summary, the 1.6.x `Symbol.dispose` stamps (14 tests).
|
|
727
729
|
- `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).
|
|
730
|
+
- `test/27-create-root.test.mjs` -- `createRoot` (1.5.0), the ownership escape hatch; includes the top-level-export binding case (7 tests).
|
|
731
|
+
- `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).
|
|
732
|
+
- `test/29-scope.test.mjs` -- `createScope` (1.6.0), the adopting counterpart to `createRoot` (4 tests).
|
|
733
|
+
- `test/30-throwing-equals.test.mjs` -- a user `equals` that THROWS: every eq() dispatch site on this engine (callable set pre-check/revert, boxSet pre-check/revert -- both split-closure variants -- and the computed re-eval site) surfaces the throw with coherent state after; site audit anchored to 1.8.0 line numbers (9 tests).
|
|
734
|
+
- `test/33-cleanup-return.test.mjs` -- the 1.8.0 effect cleanup-return contract at unit grain: timing, compose order with `onCleanup`, non-function returns ignored, computed exclusion (7 tests).
|
|
735
|
+
- `test/34-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 `34-config-oom.child.mjs` (13 tests).
|
|
736
|
+
- `test/35-devtools-zerogc-probe.test.mjs` -- devtools attach/detach allocation probes against the 14-key `stats()` surface (5 tests).
|
|
737
|
+
- `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.
|
|
738
|
+
- `test/ProfilerTests/` -- gc-profiler x engine hardening sub-package (`npm run test:hardening`; 28 tests, 22 execute + 6 version-gated skips).
|
|
728
739
|
- `bench/benchmark.mjs` -- anti-DCE throughput harness (ops/s; results.txt).
|
|
729
|
-
- `bench/
|
|
740
|
+
- `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).
|
|
730
741
|
- `bench/dispose-recycle.mjs` -- 1.2.2 targeted microbench: create/dispose/recreate cycle (the free-list invariant audit target).
|
|
731
|
-
- `bench/torture/` -- the complete **
|
|
742
|
+
- `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.8.0 engine and stays green from 1.4.x forward. On the 1.8.0 engine **25 of the 27 execute** (22 semantic + 3 soak), **1 skips cleanly** at its floor, and the wraparound soak is opt-in. `semantic` (deterministic, fast, asserts on MEANING; CI on every commit) -- the **22 that execute on 1.8.0**: `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.8.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, NATIVE here: 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 THIS folder's 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), `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; THIS folder's copy runs the createScope-native root-vs-scope differential); plus **1 that skips cleanly** as a later-version feature: `dispose-torture` (1.9.0 `Symbol.dispose`). `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`.
|
|
732
743
|
- `bench/run-all.sh` + `bench/aggregate.mjs` -- cold-process-per-engine protocol + per-scenario aggregation.
|
|
733
|
-
- `harness/run.mjs` -- dispatcher for the run-on-demand probes (smoke, field, dispose, churn, owner, creation, perf, burst, pull, toe, all).
|
|
744
|
+
- `harness/run.mjs` -- dispatcher for the run-on-demand probes (smoke, field, dispose, churn, owner, creation, perf, burst, pull, toe, mint, all).
|
|
745
|
+
- `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 (a new-space-only witness undercounts by ~56 B/op of pre-TurboFan closure-feedback). Re-measured IDENTICAL on the 1.8.0 engine -- the out-of-line cleanup-return ladder sits outside the creation path. `--verify` applies relative pins P1..P5.
|
|
734
746
|
- `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`.
|
|
735
747
|
- `harness/perf-probe.mjs` -- sBench update-group shape, eager vs sab, per scenario.
|
|
736
748
|
- `harness/fieldkit.mjs` -- single-file portable verify + cold-child A/B bench across six shapes.
|
|
@@ -740,10 +752,9 @@ function dumpOwnerTree(handle, depth = 0) {
|
|
|
740
752
|
- `harness/owner-hazard-repro.mjs` -- async-gap owner-recycling hazard verdict (cited by getOwner/runWithOwner).
|
|
741
753
|
- `harness/retracking.difftest.mjs` -- differential retracking fuzzer; takes <reference.js> [candidate.js] and asserts both builds agree under thousands of value-dependent topology flips.
|
|
742
754
|
- `harness/toe-to-toe/` -- cross-version sweep (round-robin ordering, drift sentinel, capability columns). Its `engines/` dir is PRIVATE/gitignored: several snapshots are unreleased.
|
|
743
|
-
- `harness/VersionMatrix/` -- cold-process-per-version regression gate (
|
|
755
|
+
- `harness/VersionMatrix/` -- cold-process-per-version regression gate (`npm run gate` -> `pre-publish.mjs`, run before every publish); refuses a verdict on unstable captures (NO EVIDENCE) rather than misreading host noise as a regression.
|
|
744
756
|
- `harness/ProfilerTools/` -- profiler-signal x devtools composition harness (wired as test:harness).
|
|
745
757
|
- `harness/attic/` -- parked probes (1.2.0->1.2.1 shape hunt, the superseded contiguous burst-dag, the superseded sbench sweep); wired into nothing.
|
|
746
|
-
- `demo/index.html` -- interactive visualization of the reactive graph.
|
|
747
758
|
|
|
748
759
|
## Install
|
|
749
760
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zakkster/lite-signal",
|
|
3
|
-
"version": "1.8.0-
|
|
3
|
+
"version": "1.8.0-beta",
|
|
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",
|
|
@@ -26,12 +26,17 @@
|
|
|
26
26
|
"CHANGELOG.md"
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
|
-
"test": "node --test --test-reporter=spec",
|
|
30
|
-
"test:gc": "node --expose-gc --test --test-reporter=spec",
|
|
31
|
-
"test:coverage": "c8 node --test --test-reporter=spec",
|
|
32
|
-
"test:
|
|
29
|
+
"test": "node --test --test-reporter=spec 'test/*.test.mjs'",
|
|
30
|
+
"test:gc": "node --expose-gc --test --test-reporter=spec 'test/*.test.mjs'",
|
|
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'",
|
|
33
|
+
"test:hardening": "npm --prefix test/ProfilerTests test",
|
|
34
|
+
"test:hardening:gc": "npm --prefix test/ProfilerTests run test:gc",
|
|
35
|
+
"test:harness": "npm --prefix harness/ProfilerTools test",
|
|
36
|
+
"test:zgc": "node --expose-gc --max-semi-space-size=4 --test 'test/zgc/*.test.mjs'",
|
|
37
|
+
"test:zgc:report": "node --expose-gc test/zgc/zero-gc-gate.mjs",
|
|
38
|
+
"test:all": "npm test && npm run test:hardening && npm run test:harness && npm run test:zgc",
|
|
33
39
|
"bench": "node --expose-gc bench/benchmark.mjs",
|
|
34
|
-
"bench-reactive": "node --expose-gc bench/benchmarkReactive.mjs",
|
|
35
40
|
"harness": "node harness/run.mjs",
|
|
36
41
|
"harness:smoke": "node harness/run.mjs smoke",
|
|
37
42
|
"harness:field": "node harness/run.mjs field",
|
|
@@ -45,7 +50,7 @@
|
|
|
45
50
|
"profile:burst": "node --expose-gc harness/burst-dag.mjs ./Signal.js",
|
|
46
51
|
"profile:pull": "node --expose-gc harness/pull-stress.mjs",
|
|
47
52
|
"gate": "node harness/VersionMatrix/pre-publish.mjs",
|
|
48
|
-
"verify": "npm test && npm run harness:smoke && npm run bench",
|
|
53
|
+
"verify": "npm test && npm run test:zgc && npm run harness:smoke && npm run bench",
|
|
49
54
|
"torture": "node bench/torture/run.mjs",
|
|
50
55
|
"torture:semantic": "node bench/torture/run.mjs --group semantic",
|
|
51
56
|
"torture:soak": "node bench/torture/run.mjs --group soak"
|
|
@@ -85,8 +90,8 @@
|
|
|
85
90
|
},
|
|
86
91
|
"sideEffects": false,
|
|
87
92
|
"devDependencies": {
|
|
88
|
-
"@zakkster/lite-devtools": "^1.2
|
|
89
|
-
"@zakkster/lite-gc-profiler": "^1.
|
|
93
|
+
"@zakkster/lite-devtools": "^1.6.2",
|
|
94
|
+
"@zakkster/lite-gc-profiler": "^1.16.0",
|
|
90
95
|
"@zakkster/lite-profiler": "^1.1.0",
|
|
91
96
|
"@zakkster/lite-profiler-signal": "^1.2.0",
|
|
92
97
|
"@zakkster/lite-signal": "^1.3.0 || >=1.4.0-beta.0 || >=1.6.0-preview.0",
|