Skip to main content

manyfold

A schematic logical board with overlapping graph regions and circuit-style routes

Manyfold is a component library for execution graphs.

It helps make graph-shaped programs easier to build, inspect, and explain. Routes, schemas, buffers, demand, time, payload access, writes, taints, and lineage are modeled as graph concerns instead of being hidden in callback code or queue configuration.

Think of it as a logical board: routes are traces, ports are pads, components shape execution, and overlapping regions show where ownership, policy, and data flow meet.

This repository is an RFC-stage Python package with a PyO3/Rust extension. It is not a production runtime yet, but the package is runnable and the examples exercise the supported surface.

Start Fast

uv sync
uv run python examples/simple_latest.py
uv run python -m unittest tests.test_examples

A Small Graph in Motion

Publish Values

from dataclasses import dataclass

from manyfold.architecture import PubSub


@dataclass(frozen=True)
class Temperature:
    degrees: float
    unit: str


temperature = PubSub()

temperature.publish(Temperature(degrees=72.4, unit="F"))
temperature.publish(Temperature(degrees=72.9, unit="F"))
latest = temperature.latest()
latest_row = temperature.query_one(
    """
    SELECT pad_name, offset + 1 AS seq_source, degrees, unit
    FROM stream
    ORDER BY event_time DESC, process_sequence DESC
    LIMIT 1
    """
)
if latest is not None and latest_row is not None:
    print(f"latest #{latest_row['seq_source']}: {latest.degrees}{latest.unit}")

Output:

latest #2: 72.9F

When a topic matters, pass it explicitly. Dotted topics keep the same ownership shape as a route name:

  • owner is the component or subsystem responsible for the signal.
  • family groups related streams.
  • stream names this specific signal.

PubSub is a stream backed by PubSub delivery and a Rust SQL stream processor, so latest() is an ordinary ordered query_one(...) under the hood. If no topic is provided, the stream gets an ephemeral UUID5 topic. latest() returns a row object, so SQL-backed fields can be read as latest.degrees or latest["degrees"]. The SQL table exposes pad_name for filtering and joins. If no schema is provided, the first structured model publish fixes the stream schema lazily. Pydantic models work through their model_fields and model_dump() surface; dataclasses work through type annotations. The current runtime encodes those values as FlatBuffer bytes in payload and materializes the logical fields as typed SQL columns during Rust ingestion. Callers may still pass generated FlatBuffer bytes, builder Output(), or table objects. The queue assigns a default event_time when callers do not provide one, and key defaults to None; distributed queue implementations own their ordering contract.

Manyfold-native architecture elements remain available from manyfold.architecture.native for lower-level topology descriptions, but PubSub is the primary application stream surface. Behavior-heavy substrates stay backed by the runtime implementation.

Stats: Compute Values

temperature = route(
    owner="sensor",
    family="environment",
    stream="temperature",
    schema=Schema.float(name="Temperature"),
)
average_temperature = temperature.derivative_route(
    stream="average_temperature",
    schema=Schema.float(name="AverageTemperature"),
)

subscription = graph.observe(temperature, replay_latest=False).moving_average(
    window_size=3
).connect(average_temperature)
for reading in (72.4, 72.9, 73.7):
    graph.publish(temperature, reading)
subscription.dispose()

latest_average = graph.latest(average_temperature)
assert latest_average is not None
print(f"average: {latest_average.value:.1f}F")

node = next(
    node
    for node in graph.diagram_nodes()
    if dict(node.metadata).get("statistic") == "moving_average"
)
print(dict(node.metadata))

Output:

average: 73.0F
{'statistic': 'moving_average', 'storage': 'sliding_capacitor', 'window_size': '3'}

The shape is the same: computed values are just values published to another typed route. The moving average also renders as a graph-visible node backed by a sliding capacitor, so derived state and operational inspection stay in the same vocabulary.

Model Consensus

from manyfold import Consensus

consensus = Consensus.install(graph, nodes=("node-a", "node-b"))
consensus.tick(1)
consensus.tick(2)
consensus.propose(1, "set mode=auto")
consensus.propose(2, "set temp=21")

print(consensus.latest_leader())
print(consensus.latest_log())

Output:

('node-a', 3, True)
((1, 'set mode=auto'), (2, 'set temp=21'))

The consensus component uses Raft-shaped leader election and replicated-log concepts from Diego Ongaro and John Ousterhout's “In Search of an Understandable Consensus Algorithm” (USENIX ATC 2014).

What It Models

  • Typed routes for logical signals.
  • Replayable latest-value reads and Rx-style observation.
  • Graph-visible node thread placement for main, background, pooled, or isolated execution.
  • Graph-visible capacitors, resistors, watchdogs, mailboxes, windows, and joins.
  • Explicit demand, retention, lazy payload access, and write-shadow state.
  • Lineage, taints, route audit snapshots, and topology queries.
  • Local file-backed stores and a small consensus component scaffold.

The public Python surface is intentionally narrow at the top level. Advanced helpers live under manyfold.graph, and the examples are the best way to see which parts are supported today.

Examples

The examples/ directory is organized as a short path through the mental model. Start with a route, derive values, add explicit demand, then move into joins, watermarks, planning, consensus, and taint-aware runtime behavior. The supported examples are validated by the regular unittest run so they do not drift away from the API.

Start here: publish changing state and read the latest value

Layer computation: publish derived values

Control the flow: make downstream demand visible

Fuse streams: coordinate independent sensors

Reason in time: release data by watermark progress

Scale the graph: plan repartition work explicitly

Capstone: wire a Raft-shaped consensus component

Audit the hard parts: mark nondeterminism on purpose

More involved operator, query, transport, mesh, and security coverage stays in tests/test_graph_reactive.py, with archived exploratory scripts kept under examples/archived/. The example manifest, README featured-example list, and RFC reference suite all derive from the shared example catalog, so supported versus archived status lives in one place.

Verify

Use uv run for Python commands.

cargo test
uv run ruff check
uv run python -m unittest discover -s tests -p 'test_*.py'
uv run python -m manyfold.rfc_checklist_gen --check
uv run manyfold-example-catalog --check
uv run python -m examples.catalog --check-readme

Repo Map

  • python/manyfold/: Python wrapper API.
  • src/: Rust in-memory runtime and PyO3 extension.
  • examples/: runnable examples covered by tests.
  • tests/: unittest suite.
  • docs/: onboarding, usage, performance notes, release notes, and RFC docs.

Metadata

Release files for manyfold 0.1.42

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for manyfold 0.1.42
File Size Uploaded Provenance Actions
manyfold-0.1.42.tar.gz 2.7 MB With provenance Details for manyfold-0.1.42.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for manyfold 0.1.42
File Actions
manyfold-0.1.42-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for manyfold-0.1.42-cp310-abi3-win_amd64.whl
manyfold-0.1.42-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for manyfold-0.1.42-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
manyfold-0.1.42-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for manyfold-0.1.42-cp310-abi3-macosx_11_0_arm64.whl
manyfold-0.1.42-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for manyfold-0.1.42-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 22.0 MB

Release files / manyfold-0.1.42.tar.gz

Download URL manyfold-0.1.42.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
4fc1b32582ac772af6c5be615e5596ab3865f37f530de533b439fc678759ee6a
BLAKE2b-256 checksum
How to use checksums
cf35f1947a0fc44e9438dee7c88b5c3993365503e04b29810b13861ae0ee3c47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / manyfold-0.1.42-cp310-abi3-win_amd64.whl

Download URL manyfold-0.1.42-cp310-abi3-win_amd64.whl
Size 2.8 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1443403caf7160415bbf670de80ead20785a6689fb76ca6fccd9c570b9699427
BLAKE2b-256 checksum
How to use checksums
1f0846dcf4d7e66a377b35d5e3a0d2be14815c4adc8aa5fc0929b3158869f397
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / manyfold-0.1.42-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL manyfold-0.1.42-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 10.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f8ec95d5b87f7ac7714e926c8d473f7f8e956e1695672f7258474e731f399492
BLAKE2b-256 checksum
How to use checksums
6be2c24c9106900a4e60143b47822c0d7e431d8a356ddae03b4d4f7969cba0f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / manyfold-0.1.42-cp310-abi3-macosx_11_0_arm64.whl

Download URL manyfold-0.1.42-cp310-abi3-macosx_11_0_arm64.whl
Size 3.0 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
420c3678844943a0b852e3593233038430e8f3f953b583b5f3a782c4a633525c
BLAKE2b-256 checksum
How to use checksums
c96203a65f1243e03acc5b5c5d49fa277ee8cda8e4b7f8d69404da10d48595ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / manyfold-0.1.42-cp310-abi3-macosx_10_12_x86_64.whl

Download URL manyfold-0.1.42-cp310-abi3-macosx_10_12_x86_64.whl
Size 3.0 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
9307248202ec5ca04c80a871e9b88befaf6e819cb2c3b4d68ec94d214790725f
BLAKE2b-256 checksum
How to use checksums
bc24daec4b8d75102999f580713d90c83c24f4be75a1e6ca66ed9fc28559f453
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Security for manyfold 0.1.42

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for manyfold-0.1.42.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.42 This release

5 release files Full provenance

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