close fullscreen

Knowledge Representations+MORK (MeTTa Optimized Reduction Kernel)+MORK Full+Architecture and Ecosystem

help edit space_dashboard

Crate Structure

MORK is an 8-member Rust workspace (verified at HEAD 4cef6f7 against MORK/Cargo.toml:3-12; nightly toolchain required for generators, coroutines, SIMD):

  • 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)

Foundational dependency: PathMap — sibling repo authored by Luke Peterson; declared at MORK/Cargo.toml:28-32 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 578a759 (2025-07-21) via das/src/docker/mork/Dockerfile.server; local origin/server HEAD as of 2026-04-29 is 5b04a1d (2026-04-18), 49 commits ahead of the DAS pin with deadlock and UTF-8 fixes. 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 (mork_ffi/example_space.metta:13-17 documents successful 100M/200M/300M/400M loads; 500M ran out of memory at the same site). 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 at mork_ffi/mork.c:33-36 + morkspaces.pl:7-32.
  • 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 at MorkDB.cc:268-270 ("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.
  • ByteFlow and Tensor Logic: Adaptive block packing for dense numerical data. Relations become sparse matrices, joins become matrix products. Operations generalize across semirings.
  • ShardZipper: Merkle-based distributed state management. RAPTL enhances with 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. PLN cluster pilot Sources 8/11 and AtomSpace cluster pilot Source 3 confirm no code-real FactorGraph PLN over MORK in 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 (HEAD 1471ff2c, 2026-03-03) is a separate adjacent experimental crate outside the canonical MORK 8-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) — 8-member Rust workspace at HEAD 4cef6f7; 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).