Skip to main content

@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:

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.py without changing contract.ts in the same PR (contract-parity checklist in the PR template).
  • The merge in crdt_merge.py must 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-sdk 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sutra-sdk 1.1.0
File Size Uploaded Provenance Actions
sutra_sdk-1.1.0.tar.gz 94.8 kB Without provenance Details for sutra_sdk-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sutra-sdk 1.1.0
File Interpreter ABI Platform Actions
sutra_sdk-1.1.0-py3-none-any.whl Python 3 none any Details for sutra_sdk-1.1.0-py3-none-any.whl

Total release size: 204.2 kB

Release files / sutra_sdk-1.1.0.tar.gz

Download URL sutra_sdk-1.1.0.tar.gz
Size 94.8 kB
Tags Source
SHA-256 checksum
How to use checksums
22f34f023ef8665830f864a4fa089367f3ce444055c958a4d7a4a5accab4e6cf
BLAKE2b-256 checksum
How to use checksums
5609fa63cee3d1a03e3ca01f4e013d3ce19658268ef7c5fbaca1f9a6d2989212
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / sutra_sdk-1.1.0-py3-none-any.whl

Download URL sutra_sdk-1.1.0-py3-none-any.whl
Size 109.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6eccc4bf43aef2958b6cfa9689b5d203264820cd90f4625d0224ca0490e3009d
BLAKE2b-256 checksum
How to use checksums
5ceae5f069e0d7663dc788863f0a1d9d53a93582aade1289d8b61e1e3ea9b5cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for sutra-sdk 1.1.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.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page