Skip to main content

PyO3-backed Manyfold RFC scaffolding and in-memory runtime.

Project description

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 manyfold import Graph, Schema, route

graph = Graph()
temperature = route(
    owner="sensor",
    family="environment",
    stream="temperature",
    schema=Schema.bytes(name="Temperature"),
)

graph.publish(temperature, b"72.4F")
graph.publish(temperature, b"72.9F")
latest = graph.latest(temperature)
assert latest is not None
print(f"latest #{latest.closed.seq_source}: {latest.value!r}")

Output:

latest #2: b'72.9F'

The fields are the parts of the graph name:

  • owner is the component or subsystem responsible for the signal.
  • family groups related streams.
  • stream names this specific signal.
  • schema says how payloads are encoded and decoded.

Basic routes default to read/logical/meta, so the first example stays focused on the moving signal. Pass explicit plane, layer, or variant when that role matters.

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).

Read Next

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.

Project details


Download files

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

Source Distribution

manyfold-0.1.35.tar.gz (2.5 MB view details)

Uploaded Source

Built Distributions

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

manyfold-0.1.35-cp310-abi3-win_amd64.whl (460.1 kB view details)

Uploaded CPython 3.10+Windows x86-64

manyfold-0.1.35-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

manyfold-0.1.35-cp310-abi3-macosx_11_0_arm64.whl (575.9 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

manyfold-0.1.35-cp310-abi3-macosx_10_12_x86_64.whl (588.8 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file manyfold-0.1.35.tar.gz.

File metadata

  • Download URL: manyfold-0.1.35.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for manyfold-0.1.35.tar.gz
Algorithm Hash digest
SHA256 83b785fa72e73e57b29a7a50bc808125f8e75e7445c8ae27a5ab9dcd893bcd94
MD5 d7d4b437e234bce4607f23b2584e4338
BLAKE2b-256 87206bd7e2df8cfe6863aa8d69ee2f3dc41873f1a559db4c15ccee71f8ac8ca0

See more details on using hashes here.

Provenance

The following attestation bundles were made for manyfold-0.1.35.tar.gz:

Publisher: pypi.yml on Organization5762/manyfold

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

File details

Details for the file manyfold-0.1.35-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: manyfold-0.1.35-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 460.1 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for manyfold-0.1.35-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d2b0ec2f6856ca1b6f016c54e065655ddae1d2bbd824845ea5aa0e2c66d663e0
MD5 5d234e17c420efdc893cd1557a12a957
BLAKE2b-256 1bbfabef4ff8cd26ab7430c0b4ab16fa1d173ca5e24d74e0c0800ae4ea4f07c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for manyfold-0.1.35-cp310-abi3-win_amd64.whl:

Publisher: pypi.yml on Organization5762/manyfold

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

File details

Details for the file manyfold-0.1.35-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for manyfold-0.1.35-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5cac773f9f8590e02f639f0e97ccd7631291d0fc995e2418387c46dd3e735b34
MD5 03e46a28f2a379faf79dde312ce96638
BLAKE2b-256 dcf167dcb9af24a101bbe1beea1ac63d03b91f735024d51fa1b438190b06562c

See more details on using hashes here.

Provenance

The following attestation bundles were made for manyfold-0.1.35-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi.yml on Organization5762/manyfold

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

File details

Details for the file manyfold-0.1.35-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for manyfold-0.1.35-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d269526b51c7e43b98b53fc2c8c302fdc951834f1a08d6171e563317ccde8f4b
MD5 f3978ff77ebb119bd1fabd7462a19f96
BLAKE2b-256 f8ebaac9f4ead9678c636ba00bc213d9361c3b192d1516894c3f4eaf0f32f8df

See more details on using hashes here.

Provenance

The following attestation bundles were made for manyfold-0.1.35-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: pypi.yml on Organization5762/manyfold

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

File details

Details for the file manyfold-0.1.35-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for manyfold-0.1.35-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8151975329189b60e215a9b3dbcb5d3d8493259897a59b33423f724811497d60
MD5 505daa079f8079d5ecddb2bbb636edfd
BLAKE2b-256 af0d4fb69570b905ead49c17f311e385bbae9617bba3926a5f8c679feba8ab55

See more details on using hashes here.

Provenance

The following attestation bundles were made for manyfold-0.1.35-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: pypi.yml on Organization5762/manyfold

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page