Metadata-Version: 2.5
Name: cofork
Version: 0.1.0a0
Summary: Git-like branching, rewinding, cross-branch context mounting, and trajectory DAG IR for LLM execution.
Author: CoFork Contributors
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: branching,context,dag,fork,llm,mcp,rewind,rl
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: <3.14,>=3.10
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# CoFork

**The Git-like branching, rewinding, and cross-branch mounting substrate for LLM execution and tree learning.**

`cofork` (`0.1.0a0`) ships the zero-dependency Python standard-library core:

- **Protocol (`cofork.protocol`)**: immutable `ContextDAG` (`fork`, `rewind`, `read_thread`, `wait`, `done`), synchronized `SnapshotableWorld` (`StatelessWorld`, SQLite `SavepointWorld`, Git `GitWorktreeWorld` with 3-way merge), async `ProtocolHarness`, JSON-RPC 2.0 `MCPClient`, and OpenAI Chat Completions / Responses wire codec.
- **Trajectory IR (`cofork.ir`)**: lossless `TrajectoryDAG` intermediate representation (`from_context_dag`, `from_tree_log`) bridging execution trees and downstream tree distillation / RL engines.
- **Tier 0 Serving (`cofork.serving`)**: standard-library `Tier0APIClient` with `(branch, role)` heterogeneous model routing, deterministic prompt-cache prefix canonicalization, and `ProgressiveRouter`.

## Install

```bash
pip install cofork
```

## Quickstart

```python
from cofork import ContextDAG, SavepointWorld, from_context_dag

dag = ContextDAG.create(system="You are a careful engineer.", user="Explore two options.")
dag, (b0, b1) = dag.fork("main", ["Investigate option A", "Investigate option B"])
dag = dag.step(b0, {"role": "assistant", "content": "Option A clue: 42"})
dag, mounted = dag.read(b1, "branch-0")
dag = dag.done(b0, "A done").done(b1, "B done").done("main", "Merged result")

ir = from_context_dag(dag, outcome=1.0)
ir.validate()
```

## Development

```bash
pytest
```

## License

Apache-2.0
