MeTTaScript 2.0.0
MeTTaScript 2.0.0 is a rename. The project was MeTTa TS; it is now MeTTaScript. On the conformance
oracle and the PeTTa corpus it reproduces 1.5.0 exactly; the one engine change is a crash fix, a
unification that could recurse forever now terminates, and it leaves every terminating program's
output identical, so upgrading from 1.5.0 is safe. Two things are genuinely new around the rename:
the typed eDSL can now join across patterns, and the documentation is rewritten for people who want a
metagraph rewriting database in TypeScript without first learning MeTTa.
Two npm scopes, one library
The packages moved to the @mettascript scope, and the old @metta-ts names keep working. Each
@metta-ts/x package is now a thin re-export of @mettascript/x, so both installs resolve to the
same code:
npm install @mettascript/core # the canonical name
npm install @metta-ts/core # still works, re-exports the aboveExisting imports do not break. New code should use @mettascript.
Joins in the eDSL
The typed eDSL matched one pattern at a time. It now joins across patterns on shared variables, the
query DataScript is built around, written as TypeScript:
import { mettaDB, names, vars } from "@mettascript/edsl";
const db = mettaDB();
const { parent } = names();
const { x, y, z } = vars();
db.add(parent("Tom", "Bob"), parent("Bob", "Ann"));
// join two patterns that share $y
db.query([parent(x, y), parent(y, z)], { x, z }); // [{ x: "Tom", z: "Ann" }]All(...patterns) is the conjunction form for rule bodies, so Match(All(edge(x, y), edge(y, z)), z)
is a two-hop rule. The single-pattern query is unchanged.
Documentation
The docs open by saying what MeTTaScript is, a metagraph rewriting database you use from TypeScript,
and lead with TypeScript and eDSL examples that earn the comparison to DataScript: joins, facts about
facts, and reachability rules. A new Use cases page compares it to DataScript, the other Datalog
stores, TinyBase, and Prolog in the browser. The MeTTa language track is still there for anyone who
wants it, no longer a prerequisite.
Code blocks now highlight with the MeTTa-LSP grammar instead of a Scheme alias, so !(...),
import!, &self, and $variables are coloured the way the editor colours them.
Fixes
A unification whose rebind cascade aliases value pairs in a ring, for example binding sets carrying
e ← (g $a 1), d ← (g $b 1), a ← (g $e 1), b ← $d when the alias a = b is added, recursed
forever in binding reconciliation and crashed with a native stack overflow. The reconciler now
grey-marks each value pair for the duration of its reconciliation and closes a revisited pair as
success, the standard rational-tree treatment, so the merge terminates and the resulting cyclic
solution is discarded by the ordinary variable-loop filter. Observable behaviour on this class
matches Hyperon 0.2.10, checked directly, and no terminating program changes output: the guard can
only fire on inputs that previously recursed forever. Found by the randomized property suite in CI.
Verification
The engine matches 1.5.0 exactly except for the reconciliation termination fix above: the core
source otherwise changed only in package names, and the differential suites, the 23-file oracle, and
the PeTTa corpus all reproduce 1.5.0's output. A fuzz seed also surfaced an order-only interleaving
difference between the conjunction router and its worst-case-optimal reference on shapes whose
enumeration order MeTTa's semantics leaves unspecified; the solution multisets are identical, and
the differential suite now asserts that criterion there and pins both witness shapes (70,000 fuzz
cases across ten seeds pass, plus 27,500 for the reconciliation fix). The full workspace gate is
green: 1,336 tests across 134 files plus the 23-file byte-identical oracle, typecheck, lint, and
format, with the full suite repeated under fresh property seeds. The PeTTa corpus gate holds:
MeTTaScript is faster than PeTTa on all 98 shared corpus examples both engines pass, median 1.49x,
geomean 1.55x, no shared row slower than PeTTa, and no example changed pass status from 1.5.0
(minimum of five runs each on SWI-Prolog 9.2.9, measured on the shipping engine). The documentation
site builds. Both npm scopes install and resolve to one implementation, checked by a test asserting
reference equality.
Packages
All public packages use version 2.0.0, under both scopes:
npm install @mettascript/core@2.0.0
npm install -g @mettascript/node@2.0.0The @metta-ts names publish the same version and re-export the @mettascript packages.