A JavaScript signals runtime of about 2.2 KB gzip: signals, computeds and effects, with exact dynamic dependency tracking, glitch-free propagation, and no recursion on any path.
npm install reflex-quantQuant is a research project as much as a library. It asks one question: what is the smallest reactive machine we can derive from a fixed semantic contract, with every retained mechanism justified by a counterexample? Each mechanism has one showing that this implementation breaks the contract, or a structural bound, without it. That makes it the smallest known set, not a proven lower bound. Nothing is in it because another framework has it.
Fine-grained reactivity in one example
A computation depends on exactly what its last run read, so dependencies change from run to run:
import { computed, effect, get, set, signal } from "reflex-quant";
const full = signal(false);
const first = signal("Ada");
const last = signal("Lovelace");
const name = computed(() => (get(full) ? `${get(first)} ${get(last)}` : get(first)));
effect(() => console.log(get(name))); // "Ada" name reads full, first
set(last, "Byron"); // nothing runs: last was not read
set(full, true); // "Ada Byron" name now reads last too
set(full, false); // "Ada" last is dropped again
set(last, "King"); // nothing runsWhat makes Quant different
- Exact tracking. A computed observes exactly the sources it read; branches add and drop dependencies. How dynamic dependency tracking works.
- Glitch freedom. No computation sees a mix of old and new values, and a node runs at most once per wave, diamonds included. A write made during a run starts a new obligation (P5), which may run it again.
- Stack safety. Propagation and validation use one explicit work stack, so chain depth is bounded by memory, not by the JavaScript call stack.
- Defined failure semantics. A computed that throws commits nothing and runs again on its next demand.
- Executable specification. Equal to the reference spec on 27,061 bounded programs, 18,660 recovery programs and 100,000 generated ones, with graph integrity checked after every operation.
A computed can own state, not just cache a derivation
computed(fn, initial) passes fn its last committed value. That turns a computed into a state transition: it keeps its own state in prev, takes causes in through reads, and sends consequences out through writes.
prev carries local state.One small machine, three kinds of computation. Game of Life: state evolves, the whole world is one computed. Fireflies: events propagate, and the runtime itself finds the fixpoint. Constraints: knowledge converges, until no cell can rule out anything more.
Performance
Reflex remains faster on reorders and sorts (Quant takes 1.20–1.43× its time there). Against alien-signals, the difference on reorders is structural:
| edges created | edges removed | |
|---|---|---|
| Reflex Quant | 0 | 0 |
| alien-signals 3.2.1 | 255 | 255 |
node bench/structure.mjs.More: benchmarks and methodology, alien-signals vs Reflex Quant, Vue reactivity vs signals.
Read next
- JavaScript signals: what a reactive runtime actually needs
- Anatomy of a reactive engine: how Quant is built, with diagrams
- The contract (invariants and structural bounds)
- Design log: one counterexample per mechanism
FAQ
What is Reflex Quant?
A JavaScript and TypeScript signals library (signal, computed, effect) of about 2.2 KB gzip, derived from a fixed reactive contract, with every retained mechanism justified by a counterexample.
Is Reflex Quant production ready?
Quant is usable as a library, but it is a research-driven runtime, not a mature dependency with years of production deployment. It is published on npm under MIT, tested differentially against an executable specification on over 140,000 programs, and benchmarked on every CI build. Read the contract before relying on edge-case behaviour.
Does Reflex Quant work with React, Vue or Solid?
Quant is framework-agnostic: it has no rendering layer. It can back state in any framework through an adapter that subscribes with effect().