Capital OS is a deterministic, auditable financial truth layer built around a double-entry ledger and schema-validated tool APIs for agent use.
- Core ledger foundation is implemented: accounts, balanced transaction bundles, idempotency, balance snapshots, obligations, and event logging.
- Capital posture tooling is implemented (
compute_capital_posture,compute_consolidated_posture). - Spend simulation tooling is implemented (
simulate_spend) with contract, logging, and latency guardrail coverage. - Debt analysis tooling is implemented (
analyze_debt) with deterministic ranking, explainability payloads, and sensitivity branch support. - Approval-gated write workflow is implemented (
record_transaction_bundleproposal path + approve/reject tools). - Epic 9 governance expansion is implemented (
close_period,lock_period, adjusting-entry enforcement, expanded policy rules, multi-party approvals). - Epic 6 deterministic read/query surface is implemented (
list_transactions,get_transaction_by_external_id,list_obligations,list_proposals,get_proposal,get_config), plus config-governance hooks (propose_config_change,approve_config_change). - Epic 5 hardening work is implemented: PRD traceability matrix, migration reversibility CI gate, and expanded determinism regression suite.
- Epic 10 security controls are implemented: header-token authentication, config-driven tool authorization, and mandatory correlation IDs.
- Epic 15 CLI operator interface is implemented: trusted local CLI (
capital-os) for tool invocation without HTTP server.
- Python 3.11+
- FastAPI (
GET /health,POST /tools/{tool_name}) - SQLite (file-backed, WAL mode)
- Pytest (unit/integration/replay/security/perf)
src/capital_os/
api/ # FastAPI transport
tools/ # Tool handlers and schema boundary
domain/ # Accounts, ledger, and posture domain logic
db/ # SQLite connection and transaction helpers
observability/ # Event log + deterministic hashing
schemas/ # Pydantic request/response contracts
migrations/ # Numbered schema migrations + rollback scripts
tests/ # Unit/integration/replay/security/perf coverage
docs/ # Project and agent documentation
skills/ # Example SKILL.md files for Codex and Claude
- Install dependencies:
pip install -e ".[dev]"- Set database URL (optional, default shown):
export CAPITAL_OS_DB_URL=sqlite:///./data/capital_os.db- Run the API:
uvicorn capital_os.main:app --reload- Run tests:
pytest- Build container:
docker build -t capital-os-mcp .- Run MCP server (integrates with Claude Desktop):
docker run -i --rm -v capital-os-data:/app/data capital-os-mcp:latestSee docs/docker-mcp-integration.md for full setup and configuration.
The capital-os CLI lets operators invoke tools locally without running the HTTP server. All core invariants (schema validation, deterministic hashing, event logging, transaction boundaries) are preserved through the shared runtime executor.
# Development (editable, recommended)
pip install -e .
# Or with uv
uv pip install -e .
# Operator install via pipx (isolated environment)
pipx install .# bash
capital-os --install-completion bash
# zsh
capital-os --install-completion zsh
# fish
capital-os --install-completion fishTo display the completion script without installing:
capital-os --show-completion bash# Check runtime / DB readiness
capital-os health
# Use a specific database file
capital-os health --db-path /path/to/capital_os.db
# List available tools
capital-os tool list
# Show schema for a tool
capital-os tool schema list_accounts
# Call a tool with inline JSON
capital-os tool call list_accounts --json '{"correlation_id":"local-001"}'
# Call a tool with a JSON file
capital-os tool call create_account --json @payload.json
# Call a tool from stdin
echo '{"correlation_id":"local-002"}' | capital-os tool call list_accounts
# Start the HTTP server
capital-os serve- CLI is a trusted local operator channel — no auth token required.
- All schema validation, event logging, and DB invariants are still enforced.
- CLI executions are distinguishable in the event log via
authn_method = "trusted_cli".
- Bootstrap database + COA seed:
make init- Start runtime in background (idempotent when already healthy):
make run- Start runtime with idle auto-shutdown:
CAPITAL_OS_IDLE_SECONDS=300 make serve-idle- Health check and stop:
make health
make stop- End-to-end deterministic MVP smoke flow (reset -> migrate -> seed -> serve -> write/read assertions -> stop):
make mvp-smoke- Runtime state files are written under
.run/:.run/capital-os.pid.run/capital-os.url.run/last_request.ts.run/uvicorn.log
config/coa.yamlis the authoritative initial chart-of-accounts seed for bootstrap/reset flows.- Validate only:
python3 scripts/import_coa.py config/coa.yaml --validate-only- Seed (idempotent upsert):
python3 scripts/import_coa.py config/coa.yaml- Dry-run seed:
python3 scripts/import_coa.py config/coa.yaml --dry-run- Governance boundary:
config/coa.yamlis bootstrap/reset only.- Post-bootstrap account changes should go through governed API/tool paths.
- Health:
GET /health
- Tool endpoint:
POST /tools/{tool_name}
- Registered tools:
record_transaction_bundlerecord_balance_snapshotcreate_or_update_obligationcompute_capital_posturecompute_consolidated_posturesimulate_spendanalyze_debtapprove_proposed_transactionreject_proposed_transactionlist_accountsget_account_treeget_account_balanceslist_transactionsget_transaction_by_external_idlist_obligationslist_proposalsget_proposalget_configpropose_config_changeapprove_config_changereconcile_accountclose_periodlock_period
curl -sS -X POST http://127.0.0.1:8000/tools/record_transaction_bundle \
-H "content-type: application/json" \
-H "x-capital-auth-token: ${CAPITAL_OS_AUTH_TOKEN:-dev-admin-token}" \
-d '{
"source_system":"example",
"external_id":"tx-001",
"date":"2026-01-01T00:00:00Z",
"description":"Opening balance",
"postings":[
{"account_id":"<asset-account-id>","amount":"100.00","currency":"USD"},
{"account_id":"<equity-account-id>","amount":"-100.00","currency":"USD"}
],
"correlation_id":"corr-001"
}'- Balanced transaction bundles are enforced before commit.
- Idempotency key is
(source_system, external_id)for transaction recording. - Monetary values are normalized to 4 decimal places with round-half-even.
- Tool input/output hashing is deterministic.
- Tool invocations are event-logged (success and validation failures).
- Tool invocations require authenticated actor context and capability authorization.
- Append-only protections exist on transaction, posting, and event-log history.
docs/README.mddocs/current-state.mddocs/tool-reference.mddocs/data-model.mddocs/testing-matrix.mddocs/traceability-matrix.mddocs/development-workflow.mddocs/agent-playbooks/README.mddocs/mvp-bootstrap-agent-testing.mddocs/backlog-phase1-prd-closure.md
Epic 11 portability features are intentionally deferred in this slice:
- Export ledger with integrity markers
- Controlled import (dry-run and strict mode)
- Admin backup/restore
- Sprint status:
_bmad-output/implementation-artifacts/sprint-status.yaml - Story briefs:
_bmad-output/implementation-artifacts/*.md - Epic planning:
_bmad-output/planning-artifacts/epic-*.md - PRD baseline:
initial_prd.md - Tool auth header (default dev token):
export CAPITAL_OS_AUTH_TOKEN=dev-admin-token