DEV Community

Cover image for I built a constitution for AI agents — budgets, permissions, and audits enforced before execution
Justin Yuan
Justin Yuan

Posted on

I built a constitution for AI agents — budgets, permissions, and audits enforced before execution

Every agent framework today works like this: give the LLM an API key, define some tools, and let it run. Cost control? Check your bill at the end of the month. Quality assurance? Hope for the best.

Permissions? All or nothing.

This doesn't scale. When agents are spending real money, producing customer-facing output, and making autonomous decisions, "hope" is not a governance strategy.

What I built

Sovereign OS is an open-source orchestration system where governance is the architecture, not an afterthought.

Everything starts with a Charter — a single YAML file that declares:

  • Mission and objectives
  • Budget limits (per-task, daily, total runway)
  • Quality KPIs
  • Authorized capabilities

The execution pipeline enforces the Charter at every step:

Charter → CEO (plan) → CFO (approve budget) → Workers (execute) → Auditor (verify) → Ledger (record)



Key ideas

Pre-execution budget approval

The CFO agent checks every task against max_task_cost_usd, daily_budget_usd, and runway_days before a single token is spent. Not after.

Trust is earned

Agents start in a sandbox with zero capabilities. They unlock permissions (SPEND_USD, CALL_API, WRITE_FILES) by passing audits. This is the opposite of how every other framework works.

Immutable audit trail

Every output is verified against Charter KPIs. Audit reports include proof_hash (SHA-256 of inputs + output). The ledger is append-only JSONL — no deletions, sequence-numbered, verifiable offline.



Built-in monetization

SQLite job queue (Redis optional), Stripe integration for per-job billing, webhook delivery, ingest from Reddit, Shopify, WooCommerce.



Tech stack

Python 3.12+, FastAPI, SQLite + JSONL, OpenAI/Anthropic, Docker Compose, OpenTelemetry, Prometheus.

Try it

git clone https://github.com/Justin0504/Sovereign-OS

cd Sovereign-OS

docker compose up -d

Or local:

pip install -e ".[llm]"

python -m sovereign_os.web

MIT licensed. Self-hosted. No telemetry.

GitHub: https://github.com/Justin0504/Sovereign-OS

Top comments (0)