Module runner

Module runner 

Source
Expand description

§MeTTa Runner Implementation

This documentation addresses the different objects involved with the MeTTa runner, and how they fit together.

§Environment

Environment is the gateway to the outside world. It creates a platform-abstraction layer for MeTTa, and is responsible for managing configuration and implementing a security model with permissions. In a typical situation, there will only be one Environment needed.

§Metta

Metta is the runner object. It is owned by the caller and hosts all state associated with MeTTa execution, including loaded MettaMod modules. A Metta runner has one top-level module, (named “top”) and all other modules are loaded as dependents (or transitive dependents) of the top-level module. Metta is a long-lived object, and it may be sufficient to create one Metta runner that lasts for the duration of the host program.

§RunnerState

A RunnerState object encapsulates one conceptual “thread” of MeTTa execution (although it may be parallelized in its implementation) A RunnerState is short-lived; it is created to evaluate some MeTTa code, and can be run until it finishes or encounters an error. Multiple RunnerState objects may be executing within the same Metta at the same time. UPDATE: I think I will be removing the RunnerState shortly, in favor of a delegate interface that allows a function to interact with the runner in specific ways for the implementation of a debugger.

§ModuleDescriptor

A self-contained data-structure that uniquely identifies a specific version of a specific module. Two modules that have the same ModuleDescriptor are considered to be the same module from the perspective of the implementation.

§MettaMod

A MettaMod contains a loaded module. A module is fundamentally a [Space] of atoms, although it also contains an associated Tokenizer to help with the conversion from text to [Atom]s and sometimes a resources directory. Modules are loaded via loader functions, and they can originate from code in pure MeTTa as well as through extensions in other host languages, namely Rust, C, and Python.

§RunContext

A RunContext objects encapsulates the interface accessible to code running inside a RunnerState. It provides access to the currently loaded module and any other shared state required for the atoms executing within the MeTTa interpreter. A RunContext is created inside the runner, and it is not possible for code outside the MeTTa core library to own a RunContext.

Metta (Runner) ┌─────────────────────────────────────────────────────────────────┐ │ MettaMods (Modules) │ │ ┌────────────────────────────────────────────────────┐ │ │ │ Space Tokenizer ├─┐ │ │ │ ┌─────────────────┐ ┌─────────────────────┐ │ ├─┐ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────────────────┘ └─────────────────────┘ │ │ │ │ │ └─┬──────────────────────────────────────────────────┘ │ │ │ │ └─┬──────────────────────────────────────────────────┘ │ │ │ └────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────┘

Modules§

modules
pkg_mgmt
stdlib

Structs§

EnvBuilder
Used to customize the Environment configuration
Environment
Contains state and host platform interfaces shared by all MeTTa runners. This includes config settings and logger
Metta
A Metta object encapsulates everything needed to execute MeTTa code
PragmaSettings
RunContext
Runtime data that is available to Grounded Atom execution
RunnerState
A RunnerState encapsulates a single in-flight process, executing code within a Metta runner