How biruk-gebru/metta-moses works
Project Type and Purpose
• This is a domain-specific library/tool: a MeTTa-based reimplementation of the MOSES evolutionary program learner.
• It is not a typical frontend/backend web app but a pipeline of MeTTa modules implementing genetic-programming operators, reduction functions, scoring, and orchestration code.
High-Level Architecture (Main Components)
a. Runtime Environment (External Service)
• MeTTa interpreter / hyperon-experimental library (v0.1.12)
• Optional metta-run binary on Windows
b. Core Modules (MeTTa Files)
1. Types (types.metta, experimentalTypes.metta)
2. Utilities (utilities/)
3. Optimization Strategies (optimization/)
• PGE (probabilistic grammar evolution)
• SGE (stochastic grammar evolution)
• SGGGP (stochastic grammar-guided genetic programming)
4. Reduction Engine (reduct/boolean-reduct/)
5. Scoring Engine (scoring/fitness.metta)
6. Entry Points (exec.metta)
c. Orchestration & Tests
• Python test runner (scripts/run-tests.py)
• Test suites under each module’s test/ directories
Relationships and Data Flow
1. Input dataset & parameters → MeTTa interpreter
2. exec.metta & types load definitions → initialize population
3. Optimization Engine
→ picks exemplar trees → calls Reduction Engine to simplify candidates
→ calls Scoring Engine to evaluate fitness
→ selects survivors & repeats (loop back)
4. Utilities module called by both Reduction and Scoring for shared helpers
5. Final best program(s) returned or printed via exec.metta
Architectural Patterns and Principles
• Pipeline pattern: distinct stages (generation → reduction → scoring)
• Plugin-style strategy modules (PGE/SGE/SGGP) implementing a common interface
• Separation of concerns: types, helpers, core logic, and test code each in its own directory
• Test-driven development: each module has corresponding tests
Technologies and Frameworks
• MeTTa language for core logic
• Python for orchestration/test script
• GitHub Actions (MeTTa-CI.yml) for CI
• Standard GitHub workflows and issue templates