Kernel Core
How a write in this.me reaches only the values that depend on it. Every link and number on this page is this.me 4.2.1 (tag v4.2.1; the npm 4.2.1 dist is built from the same src).
Concept first: O(k) · me.explain(path) · Extreme Fan-Out. How a call becomes a path: Proxy calls.
Cost model
k is the number of derived values one write recomputes; n is everything else in the tree. A write costs O(k), and explain(path).meta.k reports k for the last wave.
| Piece | Source (v4.2.1) |
|---|---|
Derivation state: derivations, refSubscribers, refVersions, derivationRefVersions, staleDerivations, recomputeMode | kernel-state.ts L102–108 |
registerDerivation: parse refs, subscribe source → target | derivation.ts L577–608 |
extractExpressionRefs | derivation.ts L289–299 |
subscribe (the inverted index) | derivation.ts L484 |
invalidateFromPaths: walk subscribers, eager wave or stale marks | derivation.ts L824–961 |
recomputeTarget (early cutoff) | derivation.ts L705–710 |
ensureTargetFresh (lazy read) | derivation.ts L757–812 |
unregisterDerivation | derivation.ts L551–559 |
Cycles: failCycle | derivation.ts L712–719 |
Inverted index
On ["="] the kernel extracts the formula's references and records source path → [target paths] in refSubscribers. A write to a source walks only that entry:
write(source) → invalidateFromPaths([source])
→ refSubscribers[source] → targets
→ eager: recomputeTarget(target), then its own subscribers
→ lazy: mark stale; ensureTargetFresh(target) on readrecomputeTarget returns whether the value changed. Dependents of an unchanged value are not recomputed (early cutoff, explain().meta.changed).
Measured on 4.2.1
1,200 trucks, one [i] formula, eager mode (default). Run with node on npm this.me 4.2.1; box: Intel Xeon, 8 vCPU, Node v20.19.2, 2026-10-14, p50 of 30.
import ME from "this.me";
const me = new ME();
me.finance.fuel_price(24.5);
for (let i = 1; i <= 1200; i++) me.fleet.trucks[i].fuel(100 + (i % 50));
me.fleet["trucks[i]"]["="]("cost", "fuel * finance.fuel_price");
me.finance.fuel_price(99);
me.explain("fleet.trucks.600.cost").meta.k; // 1200
me.fleet.trucks[600].fuel(1);
me.explain("fleet.trucks.600.cost").meta.k; // 1
me("fleet.trucks.600.cost"); // 99| Measure | 4.2.1 |
|---|---|
| Setup (1,200 writes + formula + first read) | 149–187 ms |
Global write finance.fuel_price + read, k = 1,200 | 32–34 ms |
Local write trucks[600].fuel + read, k = 1 | 0.12 ms |
Larger sweeps: Kernel benchmarks.
Evaluator
Formulas run in a small evaluator, not eval or new Function: tokenize, precedence (shunting-yard) to RPN, evaluate. Source: tokenizeEvalExpression L47–151, compileUncached L228–322, tryEvaluateAssignExpression L324–429. Details and outputs: Intelligence.
explain() and secrets
explain(path) (derivation.ts L140–251) returns the expression, every input with its path, origin and status, and meta (dependsOn, k, recomputed, changed). Inputs read from a secret branch are returned as ●●●● with masked: true (L214–215). Example output: Intelligence.
Snapshots
exportSnapshot L44–57 emits the memory log and the secret planes (localSecrets, localNoises, encryptedBranches, keySpaces, …). hydrate L73–111 rebuilds from them and resets derivations (L95). Values come back; live formulas do not (see Intelligence).
Guarantees and limits in 4.2.1
- Memories. Every write is appended to the memory log (Memory).
- Cycles.
a = b + 1,b = a + 1does not overflow: both values areundefinedandexplain().meta.unresolvedis{ reason: "cycle", cycle: [...] }. - Cleanup. Redefining a target (L584) or removing a subtree (
clearDerivationsByPrefixL1052–1066) callsunregisterDerivation, which drops its subscriptions. - Log growth. Recomputed values are appended too, so a long eager stream grows the log (#5).
Related
Intelligence · Benchmarks · Proxy calls · Axioms · O(k) · me.explain(path)