Skip to content

API reference

Each page reproduces the public definitions, source signatures, and docstrings of one module. Class pages also include public method docstrings.

Core

These modules define atoms, spaces, queries, and the rows returned to Python.

ModuleSurface
metta.atomsatoms, constructors, encoding, unification
metta.pathslazy attributes and keys inside opaque handles
metta.Spacethe space handle returned by metta.space()
metta.resultsquery rows and tables
metta.answerthe explicit answer a provider yields: bindings, value, residue, annotation

Definition

These modules register Python behavior, translate structured objects, and enforce checked type boundaries.

ModuleSurface
metta.opsPython operation registration and type declarations
metta.converttwo-way object translation
metta.castingruntime typecasting through the engine's types
metta.strategiesreified strategy constructors and TP/TU traversal schemes

Diagnostics

These modules expose reduction events, structural findings, similarity scores, and custom match behavior.

ModuleSurface
metta.tracethe reduction trace as events
metta.derivationproof trees and their steps
metta.lintspace diagnostics for the silently-wrong class

Data and stores

These modules operate on array protocols and generate test data for public atoms. Journal-backed stores are created through metta.space(journal=...).

ModuleSurface
metta.structurespattern-keyed maps, indexes, and engine-backed views
metta.tablesSQL tables bridged in as declared shapes
metta.arraysarray operations and embedding stores
metta.testingthe hypothesis strategies the suite fuzzes itself with

Distribution

These modules connect spaces, processes, event loops, subscriptions, and external providers.

ModuleSurface
metta.remotespaces served and attached across processes
metta.spacesunion, readonly, mapped, and overlay combinators
metta.manifestapp assembly from a (boot ...) manifest
metta.aiothe engine on an event loop, one dedicated worker thread
metta.eventsthe public event stream and the fold over it
metta.subscribestanding queries, the fold that delivers
metta.foreignPython-backed spaces
metta.integratelibrary integration tools

The MeTTa libraries

metta-libraries reproduces each lib_*.metta library's own (@doc ...) atoms through extensions/python/tools/libdoc.py, one pipeline with the Python reference above, with a coverage table as the burn-down surface.

stdlib-phrasebook is the other direction: every operation MeTTa's standard library declares, and what you write in Python instead. extensions/python/tools/phrasebook.py runs both sides of every row, the MeTTa form and the Python spelling, so the page states a coverage number rather than a claim.

Sibling repositories

Three packages live in their own repositories beside this one, docs and tests included; each builds on the public surface documented here. pettorch is the PyTorch integration, pettaprove is soft unification and goal-directed soft proving (the engine-side equations stay here as lib/lib_soft/lib_soft.metta), and pettagrapher draws terms, spaces, proofs, and reductions as self-contained pages.

Released under the MIT License.