Skip to content
tinymachinesPublic

About

An assembly-like agentic programming language designed for self-improving systems.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

13 Commits

Folders and files

Repository files navigation

PROJECT SOVEREIGN

An assembly-like agentic programming language that integrates traditional assembly concepts with modern AI capabilities through local LLM integration via Ollama.

πŸš€ Project Status

  • Phase 1: Core Infrastructure βœ… COMPLETED
  • Phase 2: LLM Integration βœ… COMPLETED
  • Phase 3: CLI/UX Development 🚧 IN PROGRESS
  • Phase 4: Advanced Features πŸ“‹ PLANNED

Latest Updates (2025-06-20):

  • βœ… Fixed test lockup issues in RuntimeAdapter tests
  • βœ… Resolved linting and formatting issues
  • βœ… Enhanced development workflow with reliable test suite
  • βœ… Improved async event loop handling with proper timeouts

✨ Features

  • Assembly-like syntax with modern programming constructs
  • Local LLM integration via Ollama for AI-powered operations
  • Self-evolving code through error-driven evolution engine
  • Comprehensive instruction set including arithmetic, control flow, and I/O
  • Advanced opcodes: LLMGEN for code generation, EVOLVE for self-improvement
  • Built with Python 3.13 (free-threading/no-GIL and JIT compiler support)
  • Production-ready async architecture with thread-safe LLM operations
  • Comprehensive testing with property-based testing via Hypothesis
  • High-performance tooling (Ruff 30x faster than Black, Pyright 3-5x faster than mypy, uv 10-100x faster than pip)

Installation

πŸ“‹ Prerequisites

  • Python 3.13+ (with free-threading/no-GIL and JIT support)
  • Ollama (for local LLM integration)
  • uv (recommended) or pip for package management

πŸ”§ Installation

Quick Start

# Clone the repository
git clone https://github.com/tinymachines/sovereign.git
cd sovereign

# Create and activate virtual environment with Python 3.13
uv venv .venv --python 3.13
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install development dependencies
uv pip install -e ".[dev]"

# Start Ollama service (in another terminal)
ollama serve

# Pull a model for LLM features
ollama pull codellama:7b

πŸ“ Example Programs

Basic Arithmetic

; examples/simple.sov
PUSH #10
PUSH #32
ADD
DUP
HALT

LLM-Powered Code Generation

; Generate code using AI
LLMGEN "Create a bubble sort implementation"
STORE "bubble_sort_code"
HALT

Self-Evolving Code

; Fix buggy code automatically
PUSH "PUSH #10\nPUSH #0\nDIV"  ; Division by zero
EVOLVE "Division by zero error"
STORE "fixed_code"
HALT

πŸ› οΈ Development

Quick Development Setup

# Automated setup script
./scripts/dev-setup.sh

# Manual setup alternative
source .venv/bin/activate
uv pip install -e ".[dev]"

Running Tests

# Run all tests with convenience script
./scripts/run-tests.sh

# Run all tests with nox
nox -s tests

# Run specific test file
pytest tests/unit/test_config.py

# Run with coverage
nox -s coverage

Running Examples

# Run all examples
./scripts/run-examples.sh

# Run specific example
./scripts/run-examples.sh hello
sovereign run examples/hello.sov

Code Quality

# Format code
ruff format src/ tests/

# Lint code
ruff check src/ tests/

# Type checking
pyright src/

Documentation

# Serve documentation locally
mkdocs serve

πŸ—οΈ Architecture

Core Components

project-sovereign/
β”œβ”€β”€ src/project_sovereign/
β”‚   β”œβ”€β”€ core/           # Language implementation
β”‚   β”‚   β”œβ”€β”€ lexer.py         # Tokenization
β”‚   β”‚   β”œβ”€β”€ parser.py        # Lark-based parser
β”‚   β”‚   β”œβ”€β”€ ast_.py          # Abstract syntax tree
β”‚   β”‚   β”œβ”€β”€ interpreter.py   # Stack-based VM
β”‚   β”‚   └── instructions.py  # Opcode implementations
β”‚   β”œβ”€β”€ compiler/       # Compilation components
β”‚   β”‚   β”œβ”€β”€ codegen.py       # Code generation
β”‚   β”‚   └── optimizer.py     # AST optimization
β”‚   β”œβ”€β”€ agents/         # AI/LLM integration
β”‚   β”‚   β”œβ”€β”€ ollama_client.py # Async Ollama client
β”‚   β”‚   β”œβ”€β”€ model_manager.py # Model selection
β”‚   β”‚   β”œβ”€β”€ evolution.py     # Self-improvement engine
β”‚   β”‚   └── runtime_adapter.py # Sync-async bridge
β”‚   └── cli/            # Command-line interface
β”œβ”€β”€ tests/              # Comprehensive test suite
β”œβ”€β”€ docs/               # Documentation
└── examples/           # Example programs

Key Technologies

  • Parser: Lark parser generator for balance of power and performance
  • LLM Backend: Ollama for local, private AI capabilities
  • Async Architecture: aiohttp with thread-safe sync-async bridge
  • Testing: pytest + Hypothesis for property-based testing
  • Type Safety: Full Python 3.13 type annotations with Pyright
  • Code Quality: Ruff for ultra-fast linting and formatting

πŸ› οΈ Advanced Features

LLM Integration Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   VM Opcodes    β”‚    β”‚  Runtime Adapter β”‚    β”‚  Ollama Client  β”‚
β”‚  (LLMGEN/EVOLVE)│───▢│  (Sync-Async)    │───▢│  (Async HTTP)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Evolution Engine

  • Error Pattern Recognition: ML-inspired pattern matching
  • Sandboxed Execution: Safe testing with resource limits
  • Learning System: Tracks fix success rates over time
  • Model Selection: Chooses optimal model for each task

πŸ”§ Troubleshooting

Common Issues

Test lockups or hanging: Fixed as of 2025-06-20. If you encounter test timeouts:

# Should complete quickly now
pytest tests/unit/test_llm_integration.py::TestRuntimeAdapter::test_initialize -v

Environment variable configuration: Tests now respect OLLAMA_MODEL environment variable:

export OLLAMA_MODEL=codellama:7b  # or your preferred model
pytest tests/

Import/formatting issues: Use the development scripts:

./scripts/quality-check.sh  # Runs formatting, linting, and type checking

Bug Reports

Known issues and their resolutions are documented in docs/bugs/.

πŸ“š Documentation

🀝 Contributing

We welcome contributions! Please see our contributing guidelines and check the development documentation.

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ™ Acknowledgments

  • Powered by Ollama for local LLM capabilities
  • Built with modern Python tooling ecosystem
  • Inspired by assembly languages and AI-driven development

About

An assembly-like agentic programming language designed for self-improving systems.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages