Architecture and Ecosystem

Crate Structure

MORK is a 9-member Rust workspace (MORK/Cargo.toml; requires a nightly Rust toolchain):

  • interning/ β€” Symbol interning with lock-free handles (128 concurrent writers)
  • expr/ β€” S-expression types, binary encoding, macros
  • frontend/ β€” Multiple parsers (CZ2, CZ3, HE, Rosetta, bytestring formats)
  • kernel/ β€” Core Space implementation, sinks, sources, pure reduction engine
  • experiments/eval/ β€” Exploratory MM2 evaluator
  • experiments/eval-ffi/ β€” FFI-side evaluator integration
  • experiments/eval-examples/ β€” Example workloads
  • experiments/unification_test_laws/ β€” MORK ↔ SWI-Prolog unification correctness audit (PR #49 Prolog-as-oracle for the unification subset only)
  • linalg/ β€” Sparse and dense linear algebra: CSR SpGEMM, block-sparse SIMD attention, and a runtime einsum VM (see Linear Algebra / Tensor Logic section below)

Foundational dependency: PathMap β€” sibling repo authored by Luke Peterson; declared as ../PathMap/ with jemalloc, arena_compact, nightly features. PathMap is the low-level trie substrate (key-value store with prefix compression, structural sharing, algebraic operations); MORK's path-algebra and zipper machinery sit on top of it. See PathMap for substrate details.

Server branch: The mork-server deployment is maintained on a separate server branch, distinct from main. DAS pins MORK to an older commit via das/src/docker/mork/Dockerfile.server; the live server branch has diverged with deadlock and UTF-8 fixes applied. See Status for drift detail.

System Interfaces

  • PeTTa: Primary MeTTa compiler connecting via FFI. PeTTa alone handles 50–100M atoms; PeTTa/MORK has been benchmarked up to 400M atoms in RAM (documented successful 100M/200M/300M/400M loads; 500M ran out of memory in the same benchmark). Earlier wiki text quoting "500M+ atoms in RAM" treated the OOM ceiling as demonstrated capacity β€” corrected.
  • mork_ffi: Rust FFI bindings for SWI-Prolog. 65s for 1M atoms (vs OOM with predicate store). Two distinct Prolog roles: (1) PR #49 unification oracle in experiments/unification_test_laws/; (2) PeTTa runtime bridge via SWI-Prolog predicate mork/3 (see mork_ffi/mork.c and morkspaces.pl).
  • faiss_ffi: FAISS vector similarity FFI for Prolog, enabling structural random indexing.
  • MeTTa-IL: Compilation target β€” routes execution to MORK for local low-latency reasoning.
  • DAS: DAS contains a code-real MorkDB AtomDB backend (subclass of RedisMongoDB) that talks to a MORK HTTP server (server-branch deployment) and Mongo-side metadata. Link/S-expression delete is hard-failed in the MorkDB implementation ("MORKDB does not support deleting links") β€” DAS-as-MORK-backend is integration-ready for loads and queries, NOT a Decko-compatible mutable store. See DAS Full.
  • Linear Algebra / Tensor Logic (linalg crate): Merged into MORK in 2026-06 (the linalg/ crate in trueagi-io/MORK).einsum An Einstein-notation () kernel expresses sparse (CSR) and dense tensors in one expression with dynamic per-dimension sparse↔dense switching at a density cutoff (~1.5%); a JIT compiler emits native machine code (AVX), reported ~290Γ— over the interpreted prototype and on par with hand-written kernels (CPUβ‰ˆGPU price/performance for matmul, currently F32). Applied e.g. to transitive closure via repeated graph powers. (MORKification Weekly 2026-04-27 β†’ 06-15.)
  • IO / Resource interface (supersedes ByteFlow and ShardZipper): The earlier ByteFlow (adaptive block packing) and ShardZipper (Merkle-based distributed state) experiments were retired β€” ByteFlow judged infeasible without rebuilding MORK, and ShardZipper's GPU-offload mechanics lifted from the PathMap level into a single narrow IO resource interface at the MORK level (the same resource API now backs CPU multithreading, GPU/float acceleration, strings, external programs, network, and a live Z3 theorem-prover sink). (MORKification Weekly 2026-04-27 / 05-04; neither term remains in the MORK codebase as of last verification.) Historical detail: RAPTL had enhanced partitioning with a triple quantale \((\varphi, \alpha, r)\) and confidence-weighted scoring: \(\text{partition\_score}(s) = \text{avg\_confidence}(s) / (\text{predicted\_cost}(s) \cdot \text{locality}(s))\). (Goertzel 2025, RAPTL ShardZipper Β§3.2–3.3)

MORK Special Forms (MeTTaTron)

MeTTaTron provides four special forms that bridge high-level MeTTa and low-level MORK execution. All use uniform conjunction semantics β€” the (,) wrapper makes result cardinality explicit and enables meta-programming:

  • exec (<priority> <antecedent> <consequent>) β€” Rule execution with conjunction antecedents. All antecedent goals must match (left-to-right, variable bindings threaded through). Consequents can be conjunction results or space-modifying Operations (O (+ fact) (- fact)). Priority determines execution order. Non-deterministic: multiple antecedent solutions produce multiple consequent evaluations.
  • coalg (<pattern> <templates>) β€” Coalgebra patterns for tree transformations. Template conjunction cardinality determines result count: (,) = zero results (termination), (, t) = one result, (, t1 t2) = unfold to two. Enables hierarchical decomposition (e.g., tree β†’ contexts β†’ leaf values via lift/explode/drop stages).
  • lookup (<pattern> <success-goals> <failure-goals>) β€” Conditional fact queries with branching. Variables bound during pattern match are available in the success branch. Nestable for priority chains.
  • rulify ($name <pattern> <templates> <antecedent> <consequent>) β€” Meta-programming: generates exec rules from coalgebra definitions by pattern matching on template arity. Enables runtime rule generation from declarative specifications.

The conjunction pattern provides ~36% parser code reduction, ~40% evaluator simplification, and ~80% fewer edge-case bugs, with negligible runtime overhead (~2 bytes per conjunction, ~10ns per goal evaluation).

(Provenance: repo-doc, MeTTa-Compiler MORK special forms documentation)

Key Cognitive Algorithm Integrations

  • PLN: Backward chaining (HeadIndex/FactIndex/UnifyIndex) and factor-graph belief propagation (FactorAtom/VariableAtom with near-constant-time neighbor lookups) β€” paper/proposal/benchmark-only at this snapshot. 2026 source-code reviews of PLN and of the MORK backend both confirm no code-real FactorGraph PLN over MORK in the inspected primary repos (MORK/, PathMap/, mork_ffi/, mork-rust-sdk/, mork-ts-sdk/: 0 hits for FactorGraph/factor_graph/belief_propagation/pln/wmpln/lib_pln/AttentionBank/cog-av-sti).
  • WILLIAM: Trie nodes carry occurrence counts, subtree totals, compression-gain sums for real-time pattern detection
  • Weighted Atom Sweeps (implementation analogy, NOT ECAN currency): The weighted-atom-sweep repo is a separate adjacent experimental crate outside the canonical MORK 9-member workspace, depending on PathMap and MORK expr. Its AtomHeader is a generic trait β€” NOT an STI/LTI/TruthValue/AttentionValue β€” and its match counter is an integer, not an ECAN attention currency. The pattern (aggregate weight counters in trie nodes for importance-proportional sampling) is repurposable for recency/priority/card-version metadata if a Decko-specific AtomHeader and traversal policy are defined, but NOT a code-real ECAN bridge at this snapshot.
  • MOSES/GEO-EVO: Program templates as content-addressed atoms; near-identical candidates deduplicated automatically
  • Pattern Mining: Patterns as subtree traversals; counts as capsule summaries at nodes

Implementation Anchors

  • MORK (primary kernel) β€” 9-member Rust workspace; nightly toolchain required.
  • PathMap (foundational substrate, sibling repo) β€” Luke Peterson's prefix-compressed triemap; declared as MORK ../PathMap/ dep. See PathMap.
  • MORK server branch (deployment line) β€” mork-server at origin/server; DAS pin and image-tag reconciliation discussed at Status.
  • CZ2 β€” Scala 3 triemap toolkit and scaling experiments.
  • mork_ffi β€” Rust FFI bindings for SWI-Prolog/MeTTa integration.
  • weighted-atom-sweep (adjacent experimental crate, NOT in canonical MORK workspace) β€” Rust weighted atom sweep on PathMap; implementation analogy for ECAN-style sampling but no ECAN/AtomSpace Value bridge code at this snapshot.
  • MM2_Structuring_Code β€” Comprehensive MM2 tutorial (28 examples).