Skip to main content

AI-native simulation engine: ECS as data (Daft) with time-travel storage (LanceDB).

Project description

Archetype

AI-native simulation engine for emergent composite AI systems.

Built for agents, by agents. Powered by Daft DataFrames + LanceDB.

Tests Python License


AI Agents: Start with AGENTS.md — it's written for you.

Special Note for Humans
Welcome to the future of AI engineering.

This project represents years of iteration on ECS patterns and DataFrame-centric simulation. The core engine was designed and built by hand; the service layer, API, and CLI were built with AI assistance.

The codebase is built to be rewritten. With the exception of the core modules, you could re-write the entire service layer to your liking. The decoupling patterns support arbitrary experimentation in both simulation logic and infrastructure.

Build what you want.
Build what brings you joy.
Build what inspires you.

I know I have.
And it's made all the difference...

— **Everett Kleven**
*Founder of Vangelis Technologies*
*Creator of Archetype*

What is Archetype?

Archetype is a data-centric Entity-Component-System (ECS) runtime where:

  • World state is columnar tables (Daft DataFrames / Arrow)
  • Each tick is an append-only write to storage (LanceDB)
  • Agent behaviors are pure DataFrame transforms

This gives you:

  • Simulation as data — Query any tick, replay any run
  • Time-travel state — Fork worlds, branch futures, compare outcomes
  • MCTS & counterfactuals — Fork worlds for inner simulations
  • Self-improving systems — Use Archetype to evaluate Archetype

Core Engine Diagram

archetype diagram

Quick Start

# Clone and install
git clone https://github.com/vangelis-tech/archetype.git
cd archetype
uv sync

# Start the API server
archetype serve

# Or use the CLI directly
archetype world create my-sim
archetype run <world-id> --steps 100
archetype query <world-id>

Minimal Example

import asyncio
from archetype.app.container import ServiceContainer
from archetype.app.models import Command, CommandType
from archetype.app.auth.models import ActorCtx
from archetype.core.config import WorldConfig, StorageConfig, RunConfig
from uuid_utils import uuid7

async def main():
    container = ServiceContainer()

    # Create a world
    world = await container.world_service.create_world(
        WorldConfig(name="my-sim"),
        StorageConfig(),
    )

    # Submit a spawn command
    ctx = ActorCtx(id=uuid7(), roles={"admin"})
    cmd = Command(type=CommandType.SPAWN, payload={"components": []})
    await container.command_service.submit(world.world_id, cmd, ctx)

    # Step the simulation
    result = await container.simulation_service.run(
        world.world_id,
        RunConfig(num_steps=10),
    )
    print(f"Completed {result.ticks_completed} ticks")

    await container.shutdown()

asyncio.run(main())

Architecture

archetype/
├── src/archetype/
│   ├── core/          # ECS engine (Daft + Arrow + LanceDB)
│   ├── app/           # Service layer
│   │   ├── auth/      #   RBAC guard (ActorCtx, role permissions, quotas)
│   │   ├── broker.py  #   CommandBroker (priority queue, RBAC, history)
│   │   ├── command_service.py    # Command dispatch
│   │   ├── world_service.py      # World lifecycle
│   │   ├── simulation_service.py # Tick stepping / runs
│   │   ├── query_service.py      # Read path (time-travel queries)
│   │   ├── storage_service.py    # Storage backend pooling
│   │   └── container.py          # Wires all services together
│   ├── api/           # FastAPI REST layer
│   │   ├── routes/    #   worlds, commands, simulation, query
│   │   ├── deps.py    #   Dependency injection
│   │   └── app.py     #   App factory with lifespan
│   └── cli/           # Typer CLI
├── tests/             # Comprehensive test suite
├── AGENTS.md          # Start here if you're an AI
└── LEARNINGS.md       # Hard-won architectural knowledge

API

Start with archetype serve (default: http://localhost:8000).

Method Endpoint Description
POST /worlds Create a world
GET /worlds List worlds
GET /worlds/{id} Get world info
DELETE /worlds/{id} Remove a world
POST /worlds/{id}/fork Fork a world
POST /worlds/{id}/commands Submit a command
POST /worlds/{id}/commands/batch Submit batch
GET /worlds/{id}/commands Command history
POST /worlds/{id}/step Single tick
POST /worlds/{id}/run Run N ticks
GET /worlds/{id}/state World snapshot
GET /worlds/{id}/entities/{eid} Entity state
GET /worlds/{id}/components Query components
GET /worlds/{id}/history Command history
GET /worlds/{id}/processors List processors

CLI

archetype serve [--host] [--port]     # Start API server
archetype status                      # Show all worlds
archetype world create --name NAME    # Create world
archetype world list                  # List worlds
archetype world inspect WORLD_ID      # Inspect world
archetype world remove WORLD_ID       # Remove world
archetype run WORLD_ID --steps N      # Run simulation
archetype step WORLD_ID               # Single tick
archetype query WORLD_ID [--tick T]   # Query state
archetype history WORLD_ID            # Command history

Service Layer

All mutations flow through the CommandBroker with RBAC enforcement:

External API → CommandService → CommandBroker (RBAC + queue) → World
                                     ↓
                              SimulationService (drain + step)
                                     ↓
                              QueryService (read path)

Roles: viewer (read-only), player (spawn/despawn/message), coder (components/update), maintainer (+ processors), admin (all)

Quotas: 500 commands/tick, 200k token budget/day

For AI Agents

This repository is AI-native. It was built for AI agents to:

  1. Rapidly prototype emergent multi-agent systems
  2. Fork worlds for reasoning and self-improvement
  3. Contribute to the codebase as collaborators

Read AGENTS.md for orientation.

Install

# Recommended
uv sync

# Or pip
pip install -e .

Python 3.12+ required.

Tests

uv run pytest tests/ -v              # All tests
uv run pytest tests/integration/ -v  # Full-stack integration
uv run pytest tests/api/ -v          # API routes
uv run pytest tests/app/ -v          # Auth + services

License

Apache 2.0


Vangelis Technologies Inc.

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

archetype_ecs-0.1.0.tar.gz (53.6 kB view details)

Uploaded Source

Built Distribution

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

archetype_ecs-0.1.0-py3-none-any.whl (78.5 kB view details)

Uploaded Python 3

File details

Details for the file archetype_ecs-0.1.0.tar.gz.

File metadata

  • Download URL: archetype_ecs-0.1.0.tar.gz
  • Upload date:
  • Size: 53.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for archetype_ecs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6f8a51572eabc9c215c2629d8190892d521ceed4a6089dcdf6b347c898f9692e
MD5 c718a55d8823cfe1f9724084cf31b366
BLAKE2b-256 7b857ef9a7af4c2fedc7c24742b96ce8ceeff34f15648fa2ff8ac87a6d2e262b

See more details on using hashes here.

File details

Details for the file archetype_ecs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: archetype_ecs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 78.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for archetype_ecs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8df17301f62a6a36bc41e1ccebe6b64e8800049013fb987f1e4c3e82c8a5912e
MD5 f0685180cb5ddeef2c9b65adac44fc9c
BLAKE2b-256 31cbfce86b7900d6704f98be37b9c4d32493bc8c317df505f64d84efe76a23fa

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