Type-safe orchestration for unpredictable AI.
Reason this release was yanked:
Version reset to 0.x for alpha phase
Project description
ClearFlow
Type-safe orchestration for unpredictable AI.
Why ClearFlow?
- 100% test coverage – Every path proven to work
- Type-safe transformations – Errors caught at development time, not runtime
- Immutable state – No hidden mutations
- Zero dependencies – No hidden failure modes
- Single exit enforcement – No ambiguous endings
Installation
pip install clearflow
Upgrading from v0.x? See the Migration Guide for breaking changes.
Examples
| Name | Description |
|---|---|
| Chat | Simple conversational flow with OpenAI |
| Portfolio Analysis | Multi-specialist workflow for financial analysis |
| RAG | Full retrieval-augmented generation with vector search |
Core Concepts
Node[TIn, TOut]
A unit that transforms state from TIn to TOut (or Node[T] when types are the same).
prep(state: TIn) -> TIn– optional pre-work/validationexec(state: TIn) -> NodeResult[TOut]– required; return new state + outcomepost(result: NodeResult[TOut]) -> NodeResult[TOut]– optional cleanup/logging
Nodes are frozen dataclasses that execute async transformations without mutating input state.
NodeResult[T]
Holds the new state and an outcome string used for routing.
flow()
A function that creates a flow with explicit routing:
flow("Name", start_node)
.route(start_node, "outcome1", next_node)
.route(next_node, "outcome2", final_node)
.end(final_node, "done") # exactly one termination
Routing: Routes are (node, outcome) pairs. Each outcome must have exactly one route.
Type inference: The flow infers types from start to end, supporting transformations.
Composability: A flow is itself a Node – compose flows within flows.
ClearFlow vs PocketFlow
| Aspect | ClearFlow | PocketFlow |
|---|---|---|
| State | Immutable, passed via NodeResult |
Mutable, passed via shared param |
| Routing | Outcome-based explicit routes | Action-based graph edges |
| Termination | Exactly one exit enforced | Multiple exits allowed |
| Type safety | Full Python 3.13+ generics | Dynamic (no annotations) |
ClearFlow emphasizes robust, type-safe orchestration with validation and guardrails. PocketFlow emphasizes brevity and flexibility with minimal overhead.
Development
# Install uv (if not already installed)
pipx install uv
# Clone and set up development environment
git clone https://github.com/artificial-sapience/ClearFlow.git
cd ClearFlow
uv sync --all-extras # Creates venv and installs deps automatically
./quality-check.sh # Run all checks
License
Acknowledgments
Inspired by PocketFlow's Node-Flow-State pattern.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clearflow-1.0.0.tar.gz.
File metadata
- Download URL: clearflow-1.0.0.tar.gz
- Upload date:
- Size: 55.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c70286fd4adb58f0af354a4acfa2fb4b9c92e702eb1e86a6b0ed94ef3a98d107
|
|
| MD5 |
472d22986be059a6b4166d09c5bc92d2
|
|
| BLAKE2b-256 |
2d9647281e6943ac1b4c5d4cb0837a49effde96a4e5e25f59eb7e41795db9791
|
Provenance
The following attestation bundles were made for clearflow-1.0.0.tar.gz:
Publisher:
release.yml on artificial-sapience/ClearFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clearflow-1.0.0.tar.gz -
Subject digest:
c70286fd4adb58f0af354a4acfa2fb4b9c92e702eb1e86a6b0ed94ef3a98d107 - Sigstore transparency entry: 480356620
- Sigstore integration time:
-
Permalink:
artificial-sapience/ClearFlow@8924659a8f5accb0747bf1c77f5db23c57a37d59 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/artificial-sapience
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8924659a8f5accb0747bf1c77f5db23c57a37d59 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file clearflow-1.0.0-py3-none-any.whl.
File metadata
- Download URL: clearflow-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8074aca09d1fa84ef9350200aef8fbc4aa5613b069ed9406a6f95903888bfded
|
|
| MD5 |
47a3318934c06fad5129261b0b09dea0
|
|
| BLAKE2b-256 |
c3cfa78145a26e169919a4383366f5d333a1cef9d6058ccd6d031942444c0a5b
|
Provenance
The following attestation bundles were made for clearflow-1.0.0-py3-none-any.whl:
Publisher:
release.yml on artificial-sapience/ClearFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clearflow-1.0.0-py3-none-any.whl -
Subject digest:
8074aca09d1fa84ef9350200aef8fbc4aa5613b069ed9406a6f95903888bfded - Sigstore transparency entry: 480356639
- Sigstore integration time:
-
Permalink:
artificial-sapience/ClearFlow@8924659a8f5accb0747bf1c77f5db23c57a37d59 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/artificial-sapience
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8924659a8f5accb0747bf1c77f5db23c57a37d59 -
Trigger Event:
workflow_dispatch
-
Statement type: