Skip to main content

Reliable, Rust-Powered Agentic AI Framework with Transactional Memory.

Project description

Theus Framework

PyPI version License: MIT Python 3.14+

"Safe architecture for AI-assisted development. Powered by Rust."


🧭 Where do I start?

Theus is vast. Use our Interactive Documentation Map to find your path:


� Why Theus?

"Build with confidence. Your AI assistant writes the code—Theus makes sure it's safe."

Whether you're vibe coding with an AI assistant, building a complex agent, or crafting production software that needs to last for years—Theus has your back.

For Vibe Coders & AI-Assisted Development

You focus on what you want to build. Let your AI write the logic. Theus automatically ensures:

  • Every function declares exactly what data it reads and writes
  • No hidden side effects or surprise mutations
  • If something goes wrong, it rolls back cleanly

For Teams Who Care About Maintainability

Come back to your code in 2 years. You'll thank yourself:

  • Explicit Contracts: Every @process is self-documenting
  • Transparent State: Know exactly where your data lives and who can touch it
  • Built-in Audit: Validate business rules at the boundary, not scattered in code

For Safety-Critical Applications

When bugs aren't just annoying—they're costly:

  • Transaction Safety: Automatic rollback on failure
  • Zero-Trust Memory: Processes can't access data they didn't declare
  • Industrial Audit: Block, warn, or stop based on configurable rules

📦 Installation

Theus v3.0 requires Python 3.14+ to leverage Sub-interpreter support.

pip install theus

⚡ Quick Start

Option 1: Use a Template (Recommended)

# Create a new project with the E-Commerce demo (full-featured)
py -m theus.cli init my_app --template ecommerce
cd my_app
python main.py

This creates a complete runnable demo with: Orders, Payments, Heavy Zone, Audit Rules, and Workflow.

Option 2: Manual Setup

from theus import TheusEngine, process

# 1. Define a Process with Contract
@process(
    inputs=['domain.accounts'],
    outputs=['domain.accounts'],
    errors=['ValueError']
)
def transfer(ctx, from_user: str, to_user: str, amount: int):
    if amount <= 0:
        raise ValueError("Amount must be positive")
    
    accounts = ctx.domain.accounts
    if accounts.get(from_user, 0) < amount:
        raise ValueError("Insufficient funds")
    
    accounts[from_user] -= amount
    accounts[to_user] = accounts.get(to_user, 0) + amount
    return accounts

# 2. Initialize Engine
from src.context import DemoSystemContext
engine = TheusEngine(DemoSystemContext(), strict_mode=True)
engine.register(transfer)

# 3. Execute with Transaction Safety
result = engine.execute(transfer, from_user="Alice", to_user="Bob", amount=500)

💡 Available Templates: standard, ecommerce, hybrid, agent, minimal Run py -m theus.cli init --help to see all options.


🔄 Workflow: Flux DSL

v3.0 introduces Flux DSL - a declarative YAML language for workflow control.

# workflows/main.yaml
steps:
  - process: "initialize"
  
  - flux: if
    condition: "domain['is_valid'] == True"
    then:
      - "process_data"
      - "save_result"
    else:
      - "handle_error"
  
  - flux: while
    condition: "domain['items_left'] > 0"
    do:
      - "process_next_item"

Execute with:

engine.execute_workflow("workflows/main.yaml")

🛠️ CLI Tools

Theus provides a powerful CLI suite to accelerate development and maintain architectural integrity.

  • py -m theus.cli init <project_name>: Scaffolds a new project with the standard V3 structure.
  • py -m theus.cli audit gen-spec: Scans your @process functions and automatically populates specs/audit_recipe.yaml.
  • py -m theus.cli audit inspect <process_name>: Inspects the effective audit rules for a process.
  • py -m theus.cli schema gen: Generates specs/context_schema.yaml from your Python Dataclass definitions.
  • py -m theus.cli check: Runs the POP Linter to enforce architectural purity.

🧠 Advanced Architecture

The Transaction Engine

Theus uses a Hybrid Transaction Model:

  • Scalars: Updated in-place with an Undo Log (for speed).
  • Collections: Updated via Shadow Copy (for safety). If a process crashes or is blocked by Audit, Theus rolls back the entire state instantly.

The Heavy Zone (Optimization)

For AI workloads (Images, Tensors) > 1MB, use heavy_ variables.

  • Behavior: Writes bypass the Transaction Log (Zero-Copy).
  • Trade-off: Changes to Heavy data are NOT reverted on Rollback.

🚀 High Performance Training

For Pure Training Loops where Transaction safety is overkill:

engine = TheusEngine(sys_ctx, strict_mode=False)
  • Effect: Completely disables Rust Transaction Layer (Zero Overhead).
  • Performance: Native Python execution speed.

📚 Documentation

  • POP Manifesto: The philosophy behind Process-Oriented Programming.

⚖️ License

Maintained by: Hoàng Đỗ Huy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

theus-3.0.1.tar.gz (292.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

theus-3.0.1-cp312-abi3-win_amd64.whl (577.7 kB view details)

Uploaded CPython 3.12+Windows x86-64

theus-3.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (801.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

theus-3.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (798.4 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

theus-3.0.1-cp312-abi3-macosx_11_0_arm64.whl (720.1 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

theus-3.0.1-cp312-abi3-macosx_10_12_x86_64.whl (736.4 kB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file theus-3.0.1.tar.gz.

File metadata

  • Download URL: theus-3.0.1.tar.gz
  • Upload date:
  • Size: 292.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for theus-3.0.1.tar.gz
Algorithm Hash digest
SHA256 38b6593663b0ff1ae78d133c1fd1ec581cd8a464be0250b5497244f27ee342ce
MD5 beb28eb4e579f3522b759a85ca4208ce
BLAKE2b-256 4ae43feb1ef366f07b4a2f3feb9db92fbeff35fcbf1a430223b8d0d2d44945ea

See more details on using hashes here.

File details

Details for the file theus-3.0.1-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: theus-3.0.1-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 577.7 kB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for theus-3.0.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2daabf42ac5b8a94dbf03ad83781765f2f370b965740231547665c3f0afb2c0c
MD5 e6d1fac5dcd3080043b64646087ddaf6
BLAKE2b-256 d4c48de25c589d153ecb0635389361d6db9c4f098eddeff73b051795603ed168

See more details on using hashes here.

File details

Details for the file theus-3.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for theus-3.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 edf576d9b4773902595bf2676c668e4a0573aea6b8d72bae7f167cf56c3f4a86
MD5 d44b391629fc405720c6cd477dabe2e9
BLAKE2b-256 2694854af2acf1fdfd6d6d768e048a853ff0d2ae566428a479c5adbe8b00bcad

See more details on using hashes here.

File details

Details for the file theus-3.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for theus-3.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f73c7f9768eb78374fffc2597ba10a1511730522edcfe408f069517c6d636fb0
MD5 960b90fc5c98d7d6e55da6b9a4bdc310
BLAKE2b-256 9020059b92e5bed601c5ab0146ffedbef510325c1797f0ba3851f409b1cc07cb

See more details on using hashes here.

File details

Details for the file theus-3.0.1-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for theus-3.0.1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 028a88e461fa0665add687763a8759a2bf9e89a5e349ee981fcc97fc9d5eb058
MD5 d6c834bd068e8cbfdb2c28ba7de79292
BLAKE2b-256 dce3f680a6fca57f458f43ca2d5cdc2c63f05c949b58633cccab1827fe80f64a

See more details on using hashes here.

File details

Details for the file theus-3.0.1-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for theus-3.0.1-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2e6fe081dcb62bb259d0a906cf9998e861962dacc4bb3bf63a01ab3c2461ac45
MD5 b1d343d09ec303dd5c6b7d1794412983
BLAKE2b-256 570ae17ec590ef5c58edfe1bf108570eed39ab27c04b0eed8507eb28a74d2f50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page