@moolam/cloud-orchestrator
The cloud engine: reference Cognitive State Machine implementation for the Hybrid Cognitive Sync Protocol. Python (FastAPI + LangGraph + pgvector). Any engine that honors the wire contract may replace this one.
Architecture
Domain-agnostic runtime components, each isolated from HTTP concerns:
| Module | Responsibility |
|---|---|
agent_runtime.py |
Composes router, state store, and memory into one agent turn |
task_router.py |
Cyclical prerequisite-graph routing (LangGraph state machine) |
planner.py |
Goal decomposition and cyclic plan revision (Python twin of the planning contract) |
memory_graph.py |
pgvector-backed long-term subject memory (MCE) with kind-aware decay |
sync_service.py |
CRDT reconciliation over master state documents |
contract_models.py |
Pydantic mirrors of the canonical TypeScript wire contract |
crdt_merge.py |
Join-semilattice merge, byte-identical twin of the TS resolver |
main.py |
FastAPI transport: /v1/sync, /v1/agent/turn, /v1/agent/turn/stream (SSE), /v1/subjects/{id}/state, /v1/subjects/{id}/sync-audit, /v1/health |
auth.py |
Pluggable AuthVerifier seam + reference API-key / permissive-dev verifiers |
No module knows about any profession. Domain configuration (task graphs, charters, tool packs) lives in domains/ and is loaded as data.
AuthN / AuthZ (pluggable)
Default-deny on /v1/* except /v1/health. Self-hosters inject an AuthVerifier at startup — Sutra does not ship an IdP.
Operator guide: docs/pluggable-auth-deployment.md (API-key setup, JWT sketch, mTLS-at-proxy pattern).
Quick API-key mode:
export SUTRA_AUTH_VERIFIER=api_key
export SUTRA_API_KEYS_JSON='{"sk_demo":{"principalId":"ops-1","subjectScope":"*"}}'
uvicorn sutra_orchestrator.main:app --app-dir src
Public API
The HTTP surface is defined by the wire contract in packages/sync-protocol/src/contract.ts. The Pydantic models here must stay field-for-field identical; CI compares generated JSON Schemas.
Quick start
pip install -e ".[dev]"
uvicorn sutra_orchestrator.main:app --reload --app-dir src
# with persistence:
SUTRA_PG_DSN=postgresql://sutra:sutra@localhost:5432/sutra uvicorn sutra_orchestrator.main:app --app-dir src
Or via the repo root: pnpm infra:up (see infra/docker-compose.yml).
Task graph pack (production)
Boot loads a versioned JSON pack via resolve_production_task_graph (not an inline demo graph):
# Optional override (compose sets this to the bundled pack path):
export TASK_GRAPH_PACK=/path/to/task-graph.v1.json
uvicorn sutra_orchestrator.main:app --app-dir src
When unset, the bundled sutra_orchestrator/packs/teacher-cbse-slice.json is used (same bytes as @moolam/domain-loader / playground). Override with TASK_GRAPH_PACK for alternate packs (e.g. demo-math-sd-slice.json). Postgres row injection is supported by the same resolver (pack_row=…) with threshold fallback when the row omits thresholds.
Operator runbooks:
- Local dev and compose bring-up —
pnpm install, Python venv, compose up,smoke_test.py, playground athttp://localhost:3000 - Sync audit query (SYNC-06) — SQL + API listing advisories by subject / device / code, remediation table, seeded fixture
- Incident triage basics —
X-Request-Idcorrelation; sync storm vs turn latency metrics; quarantined vs exhausted
Live verification (compose): bash packages/cloud-orchestrator/scripts/verify_operator_surfaces_compose.sh (HEALMETREN-003 + OPERRUNB-004).
All three link metrics (/v1/metrics) and the event catalog.
Dependency-light smoke test (pydantic only):
python smoke_test.py
Versioning
Distribution semver and the wire PROTOCOL_VERSION constant move together at
release. See docs/protocol/VERSION-LOCKSTEP.md
for the file list, bump procedure, and PyPI/npm alignment rules.
Contributing notes
- Never change
contract_models.pywithout changingcontract.tsin the same PR (contract-parity checklist in the PR template). - The merge in
crdt_merge.pymust remain commutative, associative, and idempotent; the smoke test asserts this on every run. - Keep runtime components free of domain vocabulary; see
docs/adr/0005-runtime.md.
Examples
examples/cloud-sync/ exercises the same merge algebra from TypeScript; smoke_test.py covers the Python side including the planner.
Metadata
Release files for sutra-orchestrator 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sutra_orchestrator-1.0.0.tar.gz | 94.7 kB | Without provenance | Details for sutra_orchestrator-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sutra_orchestrator-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for sutra_orchestrator-1.0.0-py3-none-any.whl |
Total release size: 204.2 kB
Release files / sutra_orchestrator-1.0.0.tar.gz
| Download URL | sutra_orchestrator-1.0.0.tar.gz |
|---|---|
| Size | 94.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b55459f02ea2f7a7385a844ecf75097f836892ac99a37168310ea70c861a0a4d
|
|
BLAKE2b-256 checksum How to use checksums |
995de73ebbc61820726ea969d3f0be53fe20e36f627a05b74daa6ab7e5a90407
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / sutra_orchestrator-1.0.0-py3-none-any.whl
| Download URL | sutra_orchestrator-1.0.0-py3-none-any.whl |
|---|---|
| Size | 109.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c3a0c67bb92c432ac82da49411bb15975659c48d7c5562ab3441689b0e02eb6
|
|
BLAKE2b-256 checksum How to use checksums |
f1b292c0da7b0de6fab0ba043c8caabf85ea245c92f3f1a08a1662826ca0a2f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for sutra-orchestrator 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.