Skip to main content

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.

For standalone Postgres, apply matrx_graph/db/migrations/0100_baseline_post_reorg.sql, register the database with matrx-orm, then call matrx_graph.db.configure_standalone_db("<registered-name>"). Aidream hosts use their generated package wiring instead.

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. MemoryCheckpointer for tests, PostgresCheckpointer (via matrx-graph[postgres]) for prod.
  • JSON-only channel values. Pydantic models are dumped at write. Checkpoints round-trip losslessly.
  • Typed nodes. Every NodeSpec declares input_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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matrx_graph-0.2.161.tar.gz (944.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matrx_graph-0.2.161-py3-none-any.whl (699.2 kB view details)

Uploaded Python 3

File details

Details for the file matrx_graph-0.2.161.tar.gz.

File metadata

  • Download URL: matrx_graph-0.2.161.tar.gz
  • Upload date:
  • Size: 944.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for matrx_graph-0.2.161.tar.gz
Algorithm Hash digest
SHA256 1fa409709d29b5af801c905d66fd1b3160f3a5176cee22b9520c78cf24fb1686
MD5 7852b48b0e197df536a77faa051e946a
BLAKE2b-256 30d8bee235d1f626f1c5644c2c89cb658e3858cc9ae83ac43e9e1bc52598603a

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrx_graph-0.2.161.tar.gz:

Publisher: publish-package.yml on AI-Matrix-Engine/aidream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matrx_graph-0.2.161-py3-none-any.whl.

File metadata

  • Download URL: matrx_graph-0.2.161-py3-none-any.whl
  • Upload date:
  • Size: 699.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for matrx_graph-0.2.161-py3-none-any.whl
Algorithm Hash digest
SHA256 67a4c0ac87c31dba18d94f6994aa8db90df02f3fd90400b6510d8fc0b4e4062b
MD5 1537c7b924ed870c3da0260eff5dce94
BLAKE2b-256 a70ca47d8f34f960ab97ccb513707f02dababff7dc4657522844ddff1c0ab9dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrx_graph-0.2.161-py3-none-any.whl:

Publisher: publish-package.yml on AI-Matrix-Engine/aidream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.163

2 files

0.2.162

2 files

This release

0.2.161 This release

2 files

0.2.160

2 files

0.2.159

2 files

0.2.158

2 files

0.2.157

2 files

0.2.156

2 files

0.2.155

2 files

0.2.154

2 files

0.2.153

2 files

0.2.152

2 files

0.2.151

2 files

0.2.150

2 files

0.2.149

2 files

0.2.148

2 files

0.2.147

2 files

0.2.146

2 files

0.2.145

2 files

0.2.144

2 files

0.2.143

2 files

0.2.142

2 files

0.2.141

2 files

0.2.140

2 files

0.2.139

2 files

0.2.138

2 files

0.2.137

2 files

0.2.136

2 files

0.2.135

2 files

0.2.134

2 files

0.2.133

2 files

0.2.132

2 files

0.2.131

2 files

0.2.130

2 files

0.2.129

2 files

0.2.128

2 files

0.2.127

2 files

0.2.126

2 files

0.2.125

2 files

0.2.124

2 files

0.2.123

2 files

0.2.122

2 files

0.2.121

2 files

0.2.120

2 files

0.2.119

2 files

0.2.118

2 files

0.2.117

2 files

0.2.116

2 files

0.2.115

2 files

0.2.114

2 files

0.2.113

2 files

0.2.112

2 files

0.2.111

2 files

0.2.110

2 files

0.2.109

2 files

0.2.108

2 files

0.2.107

2 files

0.2.106

2 files

0.2.105

2 files

0.2.104

2 files

0.2.103

2 files

0.2.102

2 files

0.2.101

2 files

0.2.100

2 files

0.2.99

2 files

0.2.98

2 files

0.2.97

2 files

0.2.96

2 files

0.2.95

2 files

0.2.94

2 files

0.2.93

2 files

0.2.92

2 files

0.2.91

2 files

0.2.90

2 files

0.2.89

2 files

0.2.88

2 files

0.2.87

2 files

0.2.86

2 files

0.2.85

2 files

0.2.84

2 files

0.2.83

2 files

0.2.82

2 files

0.2.81

2 files

0.2.80

2 files

0.2.79

2 files

0.2.78

2 files

0.2.77

2 files

0.2.76

2 files

0.2.75

2 files

0.2.74

2 files

0.2.73

2 files

0.2.72

2 files

0.2.71

2 files

0.2.70

2 files

0.2.69

2 files

0.2.68

2 files

0.2.67

2 files

0.2.66

2 files

0.2.65

2 files

0.2.64

2 files

0.2.63

2 files

0.2.62

2 files

0.2.61

2 files

0.2.60

2 files

0.2.59

2 files

0.2.58

2 files

0.2.57

2 files

0.2.56

2 files

0.2.55

2 files

0.2.54

2 files

0.2.53

2 files

0.2.52

2 files

0.2.51

2 files

0.2.50

2 files

0.2.49

2 files

0.2.48

2 files

0.2.47

2 files

0.2.46

2 files

0.2.45

2 files

0.2.44

2 files

0.2.43

2 files

0.2.42

2 files

0.2.41

2 files

0.2.40

2 files

0.2.39

2 files

0.2.38

2 files

0.2.37

2 files

0.2.36

2 files

0.2.35

2 files

0.2.34

2 files

0.2.33

2 files

0.2.32

2 files

0.2.31

2 files

0.2.30

2 files

0.2.29

2 files

0.2.28

2 files

0.2.27

2 files

0.2.26

2 files

0.2.25

2 files

0.2.24

2 files

0.2.23

2 files

0.2.22

2 files

0.2.21

2 files

0.2.20

2 files

0.2.19

2 files

0.2.18

2 files

0.2.17

2 files

0.2.16

2 files

0.2.15

2 files

0.2.14

2 files

0.2.13

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.27

2 files

0.1.26

2 files

0.1.25

2 files

0.1.24

2 files

0.1.23

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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