Skip to main content

AI Software Factory for the RaceOS motorsport platform

Project description

RaceOS AI Software Factory

AI-native software factory for the RaceOS motorsport platform.

PyPI License: MIT


How It Works

┌─────────────────────────────────────────────────────────────────────┐
│                                                                     │
│   Human: "implement engine load gauge"                              │
│     │                                                               │
│     ▼                                                               │
│   ┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐    │
│   │   CLI    │───►│ 9Router  │───►│ LangGraph│───►│ OpenCode │    │
│   │ (raceos) │    │(select   │    │(orchestr)│    │(execute) │    │
│   └──────────┘    │ model)   │    └──────────┘    └──────────┘    │
│                   └──────────┘         │                │          │
│                        │               ▼                ▼          │
│                        │         ┌──────────┐    ┌──────────┐     │
│                        │         │  Brain   │    │LLM Gateway│     │
│                        │         │(.raceos/)│    │(OpenRouter│     │
│                        │         └──────────┘    │ / 9Router)│     │
│                        │                         └──────────┘     │
│                        │                              │            │
│                        ▼                              ▼            │
│                   ┌──────────────────────────────────────┐        │
│                   │  LLM (Claude / GPT-5 / Gemini / DS)  │        │
│                   └──────────────────────────────────────┘        │
│                                                                     │
└─────────────────────────────────────────────────────────────────────┘

Complete Flow

Human
  │
  │  $ raceos firmware "fix load always showing 100%"
  │
  ▼
┌─ CLI ──────────────────────────────────────────────────────────────┐
│  1. Parse input → intent: "debug", domain: "firmware"              │
│  2. Create task → TASK-A1B2C3                                      │
│  3. Save checkpoint (crash recovery)                               │
└────────────────────────────────────────────────────────────────────┘
  │
  ▼
┌─ 9Router (model selection) ────────────────────────────────────────┐
│  4. Task type: debugging → select Claude Sonnet 4.6, temp=0        │
│  5. Check budget: $3.42/$50.00 (OK, no downgrade)                  │
│  6. Set timeout: 120s                                              │
└────────────────────────────────────────────────────────────────────┘
  │
  ▼
┌─ LangGraph (orchestration) ────────────────────────────────────────┐
│                                                                    │
│  7. ORCHESTRATOR → classify: type=debugging, complexity=medium     │
│  │                                                                 │
│  8. CONTEXT AGENT → load tiered context:                           │
│  │   Tier 1: .raceos/ principles (cached)              2K tokens  │
│  │   Tier 2: openspec/specs/display-dashboard/         3K tokens  │
│  │   Tier 3: firmware/middleware/telemetry_parser.cpp   4K tokens  │
│  │   Tier 4: codebase memory patterns                  1K tokens  │
│  │                                                                 │
│  9. ENGINEER → dispatch to OpenCode                                │
│  │                                                                 │
│  10. REVIEWER → verify code quality (Claude, temp=0)               │
│  │                                                                 │
│  11. VALIDATOR → trust executor (tests already passed)             │
│  │                                                                 │
│  12. KNOWLEDGE → store patterns + suggest follow-ups               │
│                                                                    │
└────────────────────────────────────────────────────────────────────┘
  │
  ▼
┌─ OpenCode (execution) ─────────────────────────────────────────────┐
│  13. Receive: context (10K tokens) + task + constraints            │
│  14. Tools: file.read → file.write → terminal.run → git.commit    │
│  15. LLM calls → via Gateway → Claude generates fix               │
│  16. Run: pio build ✅ → pio test ✅ (16 passed)                    │
│  17. Commit: [factory] fix: convert raw byte to percentage         │
└────────────────────────────────────────────────────────────────────┘
  │
  ▼
┌─ LLM Gateway (HTTP) ──────────────────────────────────────────────┐
│  18. POST /chat/completions → model: claude-sonnet-4.6             │
│  19. Retry: 429→backoff, 5xx→retry, 400→fail                      │
│  20. Fallback: Claude fails → try GPT-5 → try DeepSeek            │
│  21. Cost: track tokens, record to ledger                          │
└────────────────────────────────────────────────────────────────────┘
  │
  ▼
Human sees:
  ✅ Fixed: raw byte (0-255) not converted to percentage
  📁 Modified: telemetry_parser.cpp, board_config.h, test_telemetry_parser.cpp
  💰 Cost: $0.20
  ⏱️  Duration: 44s
  💡 Follow-up: "check if rpm, temp, duty also need conversion"

Components

Component Role Location
CLI Human interface (15 commands + shell) src/factory/cli/
9Router Select model + enforce budget src/factory/router/
LangGraph Orchestrate 11 AI agents src/factory/orchestrator/
OpenCode Execute code via MCP tools src/factory/executor/
LLM Gateway HTTP proxy to LLM providers src/factory/gateway/
Context Agent Load Brain + specs + memory src/factory/context/
OpenSpec Parse/generate specs src/factory/spec_engine/
Codebase Memory Store implementation patterns src/factory/memory/
Project Brain Immutable knowledge (read-only) ../.raceos/

Install

pip install raceos-factory

Setup

# 1. Get LLM API key (choose one gateway):
#    OpenRouter: https://openrouter.ai/keys
#    9Router:    https://9router.ai

# 2. Configure
cd your-raceos-project/raceos-factory
cp .env.example .env
# Edit .env → add your API key

# 3. Verify
raceos doctor

See LLM Gateway Setup Guide for detailed options.


Usage

Interactive Shell

$ raceos

raceos> implement engine load gauge
raceos> fix typo in ecu_parser.h
raceos> how to wire display to stm32
raceos> /status
raceos> /budget
raceos> /quit

Direct Commands

raceos feature "add BLE support" --domain firmware
raceos firmware "fix watchdog timeout"
raceos hardware "wiring diagram for racepanel"
raceos docs "explain HAL interfaces"
raceos review
raceos doctor
raceos install
raceos update

AI Agents (11)

Agent Handles Model
Orchestrator Classify + route tasks DeepSeek (cheap)
Context Load Brain + specs + memory No LLM (file I/O)
Planner Generate specs before execution GPT-5
Engineer Write/fix code Claude
Reviewer Independent code review Claude (temp=0)
Validator Run build + tests No LLM (subprocess)
Knowledge Learn patterns + suggest follow-ups No LLM
Architect Design systems + ADRs GPT-5
Research Market/user evidence GPT-5
Product Problem definition + MVP GPT-5
Hardware Wiring/BOM/pinout Gemini

Cost

Task Type Cost Time
Feature (complex) $0.54 ~56s
Bug fix $0.20 ~44s
Documentation $0.13 ~21s
Classification $0.0001 ~2s

Daily budget: $50 (configurable). Auto-downgrades model when approaching limit.


Architecture

Project Brain (.raceos/) ── read-only, immutable
         ↓
    OpenSpec (specs/) ── behavioral contracts
         ↓
    LangGraph (DAG) ── orchestrate 11 agents
         ↓
    OpenCode (tools) ── file, terminal, git, patch
         ↓
    9Router (rules) ── deterministic model selection
         ↓
    LLM Gateway ── HTTP to providers
         ↓
    LLM (Claude/GPT/Gemini/DeepSeek)

Zero circular dependencies. Single responsibility per component.


Configuration

File Controls
.env API key (secret)
config/router.yaml Model routing + budget + fallback + retry
config/factory.yaml Paths + workflow + logging
config/opencode.json Execution tools + safety
config/context-tiers.yaml Context budgets per tier
config/memory.yaml Codebase memory indexing
config/openspec.yaml Spec engine settings

See CONFIG_INDEX.md for "I want to change X → edit this file".


Documentation

Doc Purpose
LLM Gateway Setup Choose + configure gateway
Architecture Complete system flow
CLI Design CLI commands + shell
Integration How components connect
Deployment Production deployment
CONFIG_INDEX Configuration reference

Contributing

See CONTRIBUTING.md.

Security

See SECURITY.md.

License

MIT — see LICENSE.

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

raceos_factory-1.0.2.tar.gz (143.5 kB view details)

Uploaded Source

Built Distribution

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

raceos_factory-1.0.2-py3-none-any.whl (163.2 kB view details)

Uploaded Python 3

File details

Details for the file raceos_factory-1.0.2.tar.gz.

File metadata

  • Download URL: raceos_factory-1.0.2.tar.gz
  • Upload date:
  • Size: 143.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for raceos_factory-1.0.2.tar.gz
Algorithm Hash digest
SHA256 224da15224e2367ccacd23aa2ace2fdb1ddefebff0b3893c481805e780ab7759
MD5 d33ba859858fa76796ca6b2738ba082f
BLAKE2b-256 fde44ede01c0ad339830ed7790b1d918df30ad5dbdcddca57294ac0d3dbbe329

See more details on using hashes here.

File details

Details for the file raceos_factory-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: raceos_factory-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 163.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for raceos_factory-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0fdf825abf2960672aa6da9459e1ed4277d00ace5e6819fefed6174efa7ee49b
MD5 f8aaa6bb4fd6f95075d9fae1483cc7f6
BLAKE2b-256 2840db7a992a4c69329d9531c94c97638c8c086be2c9e9f9e2960d401b33b054

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