Channel-based, super-step workflow orchestration engine for the Matrx ecosystem
Project description
matrx-graph
Channel-based, super-step workflow orchestration engine for the Matrx ecosystem. Think of it as a typed DAG + Pregel scheduler designed for mixing deterministic nodes with agent-style nodes in the same graph, with durable checkpoints and optional human-in-the-loop interrupts.
Install
pip install matrx-graph # core engine, in-memory checkpointer
pip install "matrx-graph[postgres]" # + durable Postgres checkpointer (via matrx-orm)
pip install "matrx-graph[otel]" # + OpenTelemetry instrumentation
Python 3.13+ required. Depends on matrx-connect (for AppContext and Emitter), matrx-utils, pydantic.
Design pillars
- Channels + reducers, not mutable state. Nodes return partial updates; a reducer merges them into typed channels. Safe under parallel writes.
- Pregel super-steps. Each step: active nodes run in parallel via
asyncio.TaskGroup→ writes reduced into state → next wave scheduled. Predictable and debuggable. - Durable checkpoints. Every super-step produces a checkpoint. Resume, fork, or time-travel from any point.
MemoryCheckpointerfor tests,PostgresCheckpointer(viamatrx-graph[postgres]) for prod. - JSON-only channel values. Pydantic models are dumped at write. Checkpoints round-trip losslessly.
- Typed nodes. Every
NodeSpecdeclaresinput_schema,output_schema,config_schema(Pydantic). JSON Schema is auto-exported for UI form generation. - Explicit edge semantics. Data / Control / Conditional / Error / Stream edges — no guessing from topology.
- Interrupts + Send. First-class primitives for human-in-the-loop pauses and dynamic fanout.
Design principle
Choose where to be deterministic and where to delegate to an agent.
A workflow can do everything an agent can (branch, loop, dispatch tools) but is more predictable, debuggable, and cheaper. An agent can do everything a workflow can but adapts to unexpected input. matrx-graph exists so authors draw that line consciously per node.
Usage sketch
from matrx_graph import (
Definition, NodeDef, EdgeDef, EdgeKind,
compile_graph, Scheduler, register, register_builtin_nodes,
)
register_builtin_nodes()
# A custom action — registered once, referenced by name in node definitions
@register("greet")
async def greet(ctx, inputs, config):
return {"message": f"Hello, {inputs['name']}!"}
definition = Definition(
nodes=[
NodeDef(id="start", action="noop"),
NodeDef(id="greet", action="greet"),
],
edges=[
EdgeDef(source="start", target="greet", kind=EdgeKind.Data),
],
)
graph = compile_graph(definition)
scheduler = Scheduler(graph)
result = await scheduler.run(inputs={"name": "world"})
print(result.channels["greet"]) # {"message": "Hello, world!"}
For a full example including conditional edges, dynamic ctx.send(...) fanout, checkpoints, and resume, see examples/self_validating_news.py.
Dependency posture
matrx-graph is a generic engine. It depends only on matrx-connect, matrx-utils, and pydantic. Optional postgres extra adds matrx-orm for durable checkpointing.
Domain-specific node packs (LLM, agent, scraper) live in their sibling packages (matrx-ai, matrx-scraper) and register executors with the engine at runtime via matrx_graph.registry. No hard import cycles.
Status
Phase 1 in progress — foundation + in-process executor. Not yet production-ready. The legacy root-level workflows/ and workflows_v2/ directories in the monorepo are being consolidated into this package.
Contributing
See CLAUDE.md for package-specific rules. This package lives in the aidream monorepo at github.com/AI-Matrix-Engine/aidream-current.
License
MIT.
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 matrx_graph-0.1.8.tar.gz.
File metadata
- Download URL: matrx_graph-0.1.8.tar.gz
- Upload date:
- Size: 405.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7cae9c79b0df32bd0477a763434823bf0e59df653eab61eb84331ac014a58c9
|
|
| MD5 |
974f33e3746be178ac172b836be2be71
|
|
| BLAKE2b-256 |
84d4780b73d50d663bb428358c731b73fb8d73a387bdb960f5ccaa437bc9279e
|
Provenance
The following attestation bundles were made for matrx_graph-0.1.8.tar.gz:
Publisher:
publish-package.yml on AI-Matrix-Engine/aidream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matrx_graph-0.1.8.tar.gz -
Subject digest:
e7cae9c79b0df32bd0477a763434823bf0e59df653eab61eb84331ac014a58c9 - Sigstore transparency entry: 2218335056
- Sigstore integration time:
-
Permalink:
AI-Matrix-Engine/aidream@e67fa8fba23cc3fe9ddf940555f9f87d58dcd6d4 -
Branch / Tag:
refs/tags/matrx-graph/v0.1.8 - Owner: https://github.com/AI-Matrix-Engine
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@e67fa8fba23cc3fe9ddf940555f9f87d58dcd6d4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file matrx_graph-0.1.8-py3-none-any.whl.
File metadata
- Download URL: matrx_graph-0.1.8-py3-none-any.whl
- Upload date:
- Size: 326.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
914a55212bf13ee5d87731348b4133aa56dc8b94eed00dd9e0971ba2f23b6166
|
|
| MD5 |
c1cb58db69db4b5ad3d987c3575f461c
|
|
| BLAKE2b-256 |
875b9150caf2dd4aa62bd5d4a4855527b94668bc1487668a30745dedc48327bc
|
Provenance
The following attestation bundles were made for matrx_graph-0.1.8-py3-none-any.whl:
Publisher:
publish-package.yml on AI-Matrix-Engine/aidream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matrx_graph-0.1.8-py3-none-any.whl -
Subject digest:
914a55212bf13ee5d87731348b4133aa56dc8b94eed00dd9e0971ba2f23b6166 - Sigstore transparency entry: 2218335067
- Sigstore integration time:
-
Permalink:
AI-Matrix-Engine/aidream@e67fa8fba23cc3fe9ddf940555f9f87d58dcd6d4 -
Branch / Tag:
refs/tags/matrx-graph/v0.1.8 - Owner: https://github.com/AI-Matrix-Engine
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@e67fa8fba23cc3fe9ddf940555f9f87d58dcd6d4 -
Trigger Event:
push
-
Statement type: