Metadata-Version: 2.5
Name: cairndev
Version: 0.4.1
Summary: A governed control plane for AI and ML work: pipelines that fine-tune, evaluate, compress and serve models, with approval, policy, budget and lineage on every step
Project-URL: Homepage, https://cairndev.sh
Project-URL: Documentation, https://docs.cairndev.sh
Project-URL: Source, https://github.com/cairndev-sh/cairn
Project-URL: Issues, https://github.com/cairndev-sh/cairn/issues
Author: cairn maintainers
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
License-File: THIRD_PARTY_NOTICES.md
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.12
Requires-Dist: aiofiles>=24.1.0
Requires-Dist: apscheduler>=3.10.0
Requires-Dist: cairn-client
Requires-Dist: fastapi[standard]>=0.115.0
Requires-Dist: fastmcp>=2.0.0
Requires-Dist: httpx>=0.28.0
Requires-Dist: jinja2>=3.1.0
Requires-Dist: jmespath>=1.0
Requires-Dist: jsonschema>=4.26.0
Requires-Dist: langchain-core>=0.3.0
Requires-Dist: langchain-mcp-adapters>=0.2.0
Requires-Dist: langchain-openai>=0.3.0
Requires-Dist: langgraph>=0.4.0
Requires-Dist: litellm>=1.50.0
Requires-Dist: opentelemetry-instrumentation-logging
Requires-Dist: opentelemetry-sdk==1.41.1
Requires-Dist: packaging>=23.0
Requires-Dist: pwdlib[argon2]>=0.2.0
Requires-Dist: pydantic-settings>=2.6.0
Requires-Dist: pyjwt>=2.8.0
Requires-Dist: python-frontmatter>=1.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: referencing>=0.37.0
Requires-Dist: sse-starlette>=2.0.0
Requires-Dist: starlette>=1.0.1
Requires-Dist: tomlkit>=0.13.0
Requires-Dist: typer>=0.12.0
Provides-Extra: auth
Requires-Dist: pwdlib[argon2]>=0.2.0; extra == 'auth'
Provides-Extra: dataflow-engine
Requires-Dist: duckdb>=1.0; extra == 'dataflow-engine'
Requires-Dist: polars>=1.0; extra == 'dataflow-engine'
Requires-Dist: pyarrow>=15; extra == 'dataflow-engine'
Provides-Extra: dev
Requires-Dist: blockbuster<1.6,>=1.5.20; extra == 'dev'
Requires-Dist: deepeval>=1.5.0; extra == 'dev'
Requires-Dist: httpx>=0.28.0; extra == 'dev'
Requires-Dist: langgraph-cli[inmem]>=0.1.50; extra == 'dev'
Requires-Dist: moto>=5.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Provides-Extra: hello
Requires-Dist: cairn-pack-hello[all]; extra == 'hello'
Provides-Extra: infisical
Requires-Dist: infisicalsdk>=1.0.0; extra == 'infisical'
Provides-Extra: kernel
Requires-Dist: boto3>=1.34.0; extra == 'kernel'
Requires-Dist: jmespath>=1.0; extra == 'kernel'
Requires-Dist: jsonschema>=4.26.0; extra == 'kernel'
Requires-Dist: pydantic-settings>=2.6.0; extra == 'kernel'
Requires-Dist: pydantic>=2.7; extra == 'kernel'
Requires-Dist: pyyaml>=6.0; extra == 'kernel'
Provides-Extra: metaflow
Requires-Dist: cairn-operator-dataflow-metaflow; extra == 'metaflow'
Requires-Dist: metaflow>=2.12; extra == 'metaflow'
Provides-Extra: nats
Requires-Dist: nats-py>=2.6.0; extra == 'nats'
Provides-Extra: oauth
Requires-Dist: authlib>=1.3.0; extra == 'oauth'
Provides-Extra: optuna
Requires-Dist: optuna>=4.0; extra == 'optuna'
Provides-Extra: pii
Requires-Dist: presidio-analyzer>=2.2; extra == 'pii'
Requires-Dist: presidio-anonymizer>=2.2; extra == 'pii'
Provides-Extra: rag
Requires-Dist: fastembed>=0.3.0; extra == 'rag'
Requires-Dist: google-genai>=1.0.0; extra == 'rag'
Requires-Dist: llama-cloud>=0.1.0; extra == 'rag'
Requires-Dist: llama-index-core>=0.12.0; extra == 'rag'
Requires-Dist: onnxruntime<=1.20.1; (platform_system == 'Darwin' and platform_machine == 'x86_64') and extra == 'rag'
Requires-Dist: trafilatura>=2.0.0; extra == 'rag'
Provides-Extra: rag-pgvector
Requires-Dist: asyncpg>=0.29.0; extra == 'rag-pgvector'
Requires-Dist: pgvector>=0.3.0; extra == 'rag-pgvector'
Provides-Extra: rag-pinecone
Requires-Dist: pinecone-client>=3.0.0; extra == 'rag-pinecone'
Provides-Extra: rag-qdrant
Requires-Dist: qdrant-client>=1.9.0; extra == 'rag-qdrant'
Provides-Extra: rag-sqlite-vec
Requires-Dist: sqlite-vec>=0.1.0; extra == 'rag-sqlite-vec'
Provides-Extra: rerank-cohere
Requires-Dist: cohere>=5.0; extra == 'rerank-cohere'
Provides-Extra: rerank-cross-encoder
Requires-Dist: sentence-transformers>=3.0; extra == 'rerank-cross-encoder'
Provides-Extra: runtime-dbos
Requires-Dist: dbos>=2.0; extra == 'runtime-dbos'
Provides-Extra: runtime-postgres
Requires-Dist: langgraph-checkpoint-postgres>=3.0.0; extra == 'runtime-postgres'
Provides-Extra: runtime-sqlite
Requires-Dist: langgraph-checkpoint-sqlite>=2.0.0; extra == 'runtime-sqlite'
Provides-Extra: runtime-temporal
Requires-Dist: temporalio[langgraph]>=1.28.0; extra == 'runtime-temporal'
Provides-Extra: skypilot
Requires-Dist: cairn-operator-dataflow-skypilot; extra == 'skypilot'
Requires-Dist: skypilot[aws,kubernetes,runpod,ssh,vast]>=0.13; extra == 'skypilot'
Provides-Extra: ssh
Requires-Dist: asyncssh>=2.14; extra == 'ssh'
Provides-Extra: storage-postgres
Requires-Dist: asyncpg>=0.29.0; extra == 'storage-postgres'
Provides-Extra: telemetry
Requires-Dist: opentelemetry-api>=1.27.0; extra == 'telemetry'
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.27.0; extra == 'telemetry'
Requires-Dist: opentelemetry-instrumentation-logging>=0.48b0; extra == 'telemetry'
Requires-Dist: opentelemetry-sdk>=1.27.0; extra == 'telemetry'
Provides-Extra: train
Requires-Dist: datasets<4.4,>=4.3; extra == 'train'
Requires-Dist: peft<0.21,>=0.20; extra == 'train'
Requires-Dist: torch<2.12,>=2.11; extra == 'train'
Requires-Dist: transformers<5.6,>=5.5; extra == 'train'
Description-Content-Type: text/markdown

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="./assets/logo-dark.svg">
    <img src="./assets/logo.svg" alt="cairn" width="72">
  </picture>
</p>

<h1 align="center">cairn</h1>

<p align="center">
  <b>An open-source control plane for governed ModelOps.</b><br>
  Fine-tune, evaluate, promote, and serve models as single governed commands —
  cost-capped before the GPU spins up, policy-gated, and audited end to end.
</p>

<p align="center">
  <a href="https://docs.cairndev.sh"><img alt="Docs" src="https://img.shields.io/badge/docs-cairndev.sh-3b82f6"></a>
  <a href="https://cairndev.sh"><img alt="Website" src="https://img.shields.io/badge/website-cairndev.sh-111827"></a>
  <a href="https://demo.cairndev.sh"><img alt="Live demo" src="https://img.shields.io/badge/live%20demo-demo.cairndev.sh-16a34a"></a>
  <a href="https://github.com/cairndev-sh/cairn/actions/workflows/ci.yml?query=branch%3Amain"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/cairndev-sh/cairn/ci.yml?branch=main&label=ci"></a>
  <a href="https://pypi.org/project/cairndev/"><img alt="PyPI" src="https://img.shields.io/pypi/v/cairndev"></a>
  <a href="https://pypi.org/project/cairndev/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/cairndev"></a>
  <a href="./LICENSE"><img alt="License" src="https://img.shields.io/github/license/cairndev-sh/cairn"></a>
</p>

<p align="center">
  <a href="https://docs.cairndev.sh">Docs</a> ·
  <a href="https://demo.cairndev.sh">Live demo</a> ·
  <a href="https://docs.cairndev.sh/install/">Install</a> ·
  <a href="https://docs.cairndev.sh/reference/catalog/">Pipeline catalog</a> ·
  <a href="https://docs.cairndev.sh/concepts/gates/">Gates and approvals</a> ·
  <a href="https://github.com/cairndev-sh/cairn-extensions">Extensions</a>
</p>

---

## What is cairn?

cairn runs the work behind AI as **governed commands**. You declare an
outcome — gate a dataset, fine-tune a model, evaluate it against a baseline,
promote it, serve it — and cairn drives the tools underneath, enforces the
guardrails, and records exactly what ran.

The engine is **domain-neutral**. Everything that knows about a *domain* lives
in a **pack**; everything that touches a *tool* is an **operator**. The engine
never imports a pack — that one-way dependency is what lets the same machinery
run fine-tuning, dataset checks, model evaluation, or incident response, and
lets any operator inherit the budget, policy gate, and audit for free.

cairn is **open source** (Apache 2.0) and **self-hosted**: your keys, your
GPUs, your logs — nothing leaves your perimeter.

## Extensions

Domain packs and the operators they use are separate wheels, released from
[**cairn-extensions**](https://github.com/cairndev-sh/cairn-extensions). Install
the ones you need next to `cairndev`:

| Package | What it adds |
|---|---|
| [`cairn-pack-dataset-prep`](https://github.com/cairndev-sh/cairn-extensions/tree/main/packs/cairn-pack-dataset-prep) | Pin a dataset, audit and clean it, split it by group and register `train` / `val` / `test` versions |
| [`cairn-pack-finetune`](https://github.com/cairndev-sh/cairn-extensions/tree/main/packs/cairn-pack-finetune) | LoRA / QLoRA fine-tuning on a GPU box over SSH, with approvals, a priced budget, base-vs-candidate evaluation and a box that starts after approval and stops on every outcome |
| [Operator packs](https://github.com/cairndev-sh/cairn-extensions#packages) | Dataset checks, training, lm-evaluation-harness benchmarks, IFC validation, and the contract wheels they implement |

```bash
pip install cairndev cairn-pack-finetune
```

Walkthrough: [Fine-tune a model](https://docs.cairndev.sh/guides/fine-tune-a-model/).

## Why governed?

This is what separates cairn from a bare agent loop or a black-box tool — the
work runs behind deterministic guardrails you can inspect afterward:

- **Hard budget** — every run accrues cost in a scope; over the cap it raises
  `BudgetExceeded`, so a fine-tune can't quietly overspend.
- **Policy + human approval** — proposed actions pass declarative policy rules
  before any executor runs; high-risk ones (promote a model, destroy a
  resource) pause for a human and resume durably from a checkpoint.
- **Recorded runs** — every run on an engine stores its inputs, the operator, flow or
  template it ran, and its events. `cairn status <run-id> --replay` prints them. It doesn't
  execute anything again: it shows what happened, and doesn't reproduce the result.
- **Tamper-evident audit** — with `audit.sink` bound, approvals and every governed
  pipeline step land in a hash-chained, append-only log: what ran, what it cost, who
  approved it. So do direct model completions and `mcp/call` tool calls; a template's own
  prompt and agent nodes don't write a row yet. The quickstart's profile, the
  `secure` profile and the Compose stack bind it; `local-dev` leaves it off.
- **Citation validation** — for synthesized answers, every identifier the model
  cites is exact-string-matched against its context; unmatched citations are
  stripped.

## Proof it works

Every number here comes from a script you can run yourself, and each result records what it was
measured on: see [`benchmark/`](./benchmark/README.md).

<!-- benchmark:begin (generated by benchmark/render.py; do not edit) -->

**The quickstart's path on a local engine** ([reproduce](./benchmark/quickstart_path.py))

| Measured | Result |
|---|---|
| Engine start to answering | 33.7 s |
| Launch to a pipeline paused at its person gate | 12.1 s (median of 5, after one warm-up run) |
| Both approvals to a finished pipeline, nobody waiting | 1.4 s (median of 5, after one warm-up run) |
| Nothing published before the person gate | held on all 6 runs |
| A false data gate stops the pipeline before any later step starts, and is logged | held |
| Each decision a person made is in the audit log with the signed-in user | held for all 12 decisions |
| Audit chain verifies at the end | held (143 rows) |

cairndev 0.3.1, `uv.lock` `43c69f31e985`, Darwin x86_64 with 8 CPUs and Python 3.13.12, 2026-11-02.

<!-- benchmark:end -->

## Quickstart

Run a governed pipeline on your machine: it checks a dataset, stops at a gate for
you, and writes a hash-chained audit trail. No API key, no spend, about ten minutes.

```bash
curl -LsSf https://docs.cairndev.sh/install.sh | CAIRN_EXTRAS=hello sh   # or: pip install 'cairndev[hello]'
mkdir cairn-quickstart && cd cairn-quickstart
curl -LsSfO https://raw.githubusercontent.com/cairndev-sh/cairn/main/examples/hello-cairn/data/sample.jsonl
curl -LsSfO https://raw.githubusercontent.com/cairndev-sh/cairn/main/examples/hello-cairn/profiles/hello.toml
export CAIRN_PROFILE=$PWD/hello.toml                        # the example's profile: audit trail on

cairn dev --engine-only --port 8471 &                       # local engine on SQLite
cairn remote login -u dev -p dev -e http://localhost:8471
cairn remote launch hello-cairn/profile-and-publish \
  -i path=$PWD/sample.jsonl --environment sandbox --watch
```

The pipeline profiles the file, passes its **data gate** (the profile must pass and
count at least 10 rows), redacts and versions the file, and stops at `review`, a
**person gate**:

```text
  paused
    profile            done                 run=run-task-data--profile-1f9a14
    data-ok            done                 run=None
    redact             done                 run=run-task-redact--text-85ecfb
    engine-check       done                 run=run-flow-hello-cairn--engine-check-55b570
    stage              done                 run=run-task-storage--put-1295cd
    review             awaiting_approval    run=None
    promote            pending              run=None
    publish            pending              run=None
    audit              pending              run=None
⏸ paused — 1 step(s) waiting on a human
```

Approve it, then the promotion the operator itself gates, and read the record:

```bash
cairn remote advance <pipeline_id> review     # the person gate
cairn remote advance <pipeline_id> promote    # the operator's own gate
cairn remote findings <pipeline_id>           # what every leg produced
```

```text
pipeline pl_3f5b6ec6a25d414d  status=done
  …
  promote  [done] run=run-task-artifact--promote-3b4d2f
    artifact_id           sha256:d2c09d27b2874cee
    tag                   hello-sample@published
  audit  [done] run=run-task-audit--store-39b32a
    hash  af362a96212cf0d5298dfe71e81b5109d08a0219f3079387550e753f2fa25466
```

`cairn remote pipeline <pipeline_id>` prints the whole record as JSON: the plan, the
inputs, and every step's state and decision. The audit trail is in `./audit.jsonl`:
rows for the launch, each step, each decision a person made, with the signed-in user
(`pipeline.gate_approved`), and the row the pipeline's own `audit` step writes. Each
row is chained to the one before it by its hash, and `cairn audit verify` checks the
file. Try `-i min_rows=1000` to watch the data gate stop the pipeline before any later
step starts. The full walkthrough is the [Quickstart](https://docs.cairndev.sh/quickstart/);
to look around without installing, use the live demo at https://demo.cairndev.sh (a
shared sandbox, so don't enter real credentials).

From source:

```bash
git clone https://github.com/cairndev-sh/cairn && cd cairn
uv sync --extra dev
CAIRN_PACK_PATH=examples/hello-cairn uv run cairn pipeline explain hello-cairn/profile-and-publish
```

The engine ships as the `cairndev` distribution (import name `cairn`), carrying the
builtin operator packs and the core contracts; the container image is built from
`Dockerfile.engine` and the Helm chart lives under `deploy/helm/cairn`. Optional
extras and team setup: [Install and deploy](https://docs.cairndev.sh/install/) ·
[CLI reference](https://docs.cairndev.sh/reference/cli/).

## The ModelOps lifecycle

Each stage is a normal governed run; chained together they form one auditable
spine — as a template's subgraphs, or as an explicit
[pipeline](https://docs.cairndev.sh/concepts/pipelines/).

```mermaid
flowchart LR
  D[Gate dataset] --> P[Prep · scrub · split]
  P --> T[Train · local or remote GPU]
  T --> E[Evaluate · deterministic gates]
  E --> H{{Human approval}}
  H --> R[Register · MLflow]
  R --> S[Serve · vLLM]
```

Deterministic gates decide pass/fail; LLM judges are advisory and off by
default. Promotion pauses for a human. The shipped pipelines are listed in the
[pipeline catalog](https://docs.cairndev.sh/reference/catalog/).

## One engine, many surfaces

The same governed core is driven from two places in this repository:

- **CLI** — the full control surface: run, preflight, replay, approve, deploy.
  → [CLI reference](https://docs.cairndev.sh/reference/cli/)
- **HTTP + SSE API** — every control-plane action is an endpoint, including live
  run streaming.

## Documentation

| | |
|---|---|
| [Overview](https://docs.cairndev.sh/) | What cairn is and the governance thesis |
| [Architecture](./docs/architecture/00-overview.md) | Engine, packs, profiles, request lifecycle |
| [Write a pipeline](https://docs.cairndev.sh/guides/write-a-pipeline/) · [Capabilities and operators](https://docs.cairndev.sh/concepts/capabilities/) | Packs, and how operators pick up a provider |
| [Gates and approvals](https://docs.cairndev.sh/concepts/gates/) · [Cost and budgets](https://docs.cairndev.sh/concepts/cost/) | Policies, HITL gates, budget, audit |
| [Pipelines](https://docs.cairndev.sh/concepts/pipelines/) | Chain governed workflows with gates and events |
| [Install and deploy](https://docs.cairndev.sh/install/) | Install, Docker Compose, Helm, sign-in |
| [Operators catalog](https://docs.cairndev.sh/reference/operators/) | Every shipped operator, by domain |

## Contributing

Start with [`CONTRIBUTING.md`](./CONTRIBUTING.md): the dev loop, where each kind of test
lives, and the DCO sign-off every commit needs. Self-contained starting points are
labelled [`good first issue`](https://github.com/cairndev-sh/cairn/labels/good%20first%20issue).

<a href="https://github.com/cairndev-sh/cairn/graphs/contributors">
  <img alt="Contributors" src="https://contrib.rocks/image?repo=cairndev-sh/cairn">
</a>

## Status & license

cairn is in **early access** and under active development. The API and command
surface may still change between releases; see [`CHANGELOG.md`](./CHANGELOG.md).

Licensed under the **Apache License 2.0** — see [`LICENSE`](./LICENSE).
Contributions are welcome: read [`CONTRIBUTING.md`](./CONTRIBUTING.md) first.
