Skip to content

soulhash-labs/metaflow-clockwork

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
        โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
        โ•‘   โš™  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โš™   โ•‘
        โ•‘                                               โ•‘
        โ•‘       M E T A F L O W   C L O C K W O R K     โ•‘
        โ•‘                                               โ•‘
        โ•‘   โš™  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โš™   โ•‘
        โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

adds deterministic local runtime for AI agents

Where Python code becomes conscious

self-executing tags ย ยทย  bounded recursion ย ยทย  spec-driven runs ย ยทย  append-only ledgers

License Import Runtime PyPI

MetaFlow Clockwork banner

Quickstart ย ยทย  Architecture ย ยทย  Prompt Assets ย ยทย  Roadmap ย ยทย  Contributing ย ยทย  Changelog


pip install metaflow-clockwork ย ยทย  import metaflow_clockwork ย ยทย  metaflow-clockwork

Public open-source package distributed as metaflow-clockwork and imported as metaflow_clockwork.

Not affiliated with Netflix Metaflow or the metaflow package on PyPI.


What Is It?

MetaFlow Clockwork is a deterministic local runtime for building and testing AI agents โ€” with explicit tagged execution units, bounded recursive workflows, and replayable ledgers baked in.

Most agent frameworks optimize for speed of experimentation. MetaFlow Clockwork optimizes for clarity of execution.

{
  "version": 1,
  "run_id": "example_harmonics",
  "tick_limit": 2,
  "root_tags": [
    {
      "tag_type": "gear",
      "functions": ["spawn_harmonics"]
    }
  ]
}

Built for teams who want to:

  • Model behavior as explicit execution units โ€” no magic, no hidden wiring
  • Bound recursion deliberately โ€” depth is a parameter, not a liability
  • Validate runs before they execute โ€” catch spec errors before a single tick fires
  • Produce replayable, verifiable ledgers โ€” every meaningful run leaves a trace
  • Stay local-first โ€” no broker, no daemon, no hidden orchestration layer

What Ships Today

  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚                                                                     โ”‚
  โ”‚   โš™  MetaTag execution    Deterministic units that describe and     โ”‚
  โ”‚                            run behavior                             โ”‚
  โ”‚                                                                     โ”‚
  โ”‚   โš™  ClockworkEngine      Bounded recursive ticking with explicit   โ”‚
  โ”‚                            depth control                            โ”‚
  โ”‚                                                                     โ”‚
  โ”‚   โš™  Event sinks          In-memory and append-only ledger          โ”‚
  โ”‚                            backends                                 โ”‚
  โ”‚                                                                     โ”‚
  โ”‚   โš™  Run-spec validation  Validate a spec before a single tick      โ”‚
  โ”‚                            fires                                    โ”‚
  โ”‚                                                                     โ”‚
  โ”‚   โš™  Ledger tools         Summary, replay, and verification         โ”‚
  โ”‚                                                                     โ”‚
  โ”‚   โš™  CLI                  validate ยท spec-validate ยท spec-run ยท     โ”‚
  โ”‚                            ledger-verify                            โ”‚
  โ”‚                                                                     โ”‚
  โ”‚   โš™  Prompt assets        Hygiene, template, doctrine, and role     โ”‚
  โ”‚                            contract examples                        โ”‚
  โ”‚                                                                     โ”‚
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Install

pip install metaflow-clockwork
From source / dev install
# Standard local install
pip install .

# Editable install
pip install -e .

# Build distribution artifacts
python -m pip install --upgrade build twine
rm -rf build dist metaflow_clockwork.egg-info
python -m build --sdist --wheel
python -m twine check dist/*

Quickstart

Python

from metaflow_clockwork import ClockworkEngine, MetaTag, MetaTagType, RecordingEventSink

sink = RecordingEventSink()
engine = ClockworkEngine(
    event_sink=sink,
    run_id="demo-run",
    request_id="demo-request",
)

root = MetaTag(
    tag_id="root-gear",
    tag_type=MetaTagType.GEAR,
    event_sink=sink,
)

def spawn_once(tag: MetaTag):
    if tag.data.get("spawned"):
        return []
    tag.data["spawned"] = True
    child = tag.spawn_child(MetaTagType.COG, tag_id="child-cog")
    return [child] if child else []

root.add_function("spawn_once", spawn_once)
engine.add_root_gear(root)

summary = engine.tick()
print(summary)
print([event.kind for event in sink.events])

CLI

# Smoke check
metaflow-clockwork validate --run-root /tmp/metaflow-runs

# Validate a run spec
metaflow-clockwork spec-validate ./examples/basic_harmonics.json

# Execute locally and verify the resulting ledger
metaflow-clockwork spec-run ./examples/basic_harmonics.json --run-root /tmp/metaflow-runs
metaflow-clockwork ledger-verify /tmp/metaflow-runs/example_harmonics

# Module invocation also works
python -m metaflow_clockwork spec-validate ./examples/basic_harmonics.json

Tip: To validate the installed wheel rather than checked-out source, run commands from outside the repo root and pass an absolute path to the spec.


Core Features


โš™ Self-Executing Tags

MetaTag objects are the fundamental execution unit. They do not just describe behavior โ€” they carry it. Each tag holds typed functions, spawnable children, and scoped data. Tags execute deterministically: same input, same output, every time.


โš™ Bounded Recursion

The ClockworkEngine ticks through a tag tree with explicit depth control. Recursion is a deliberate design choice here, not a footgun โ€” you set the bounds, the engine respects them, the ledger records exactly what happened.


โš™ Run-Spec Validation

Catch configuration errors before a single tick fires. A run spec defines everything needed to execute a workflow: tag graph, function bindings, depth limits. Validate it locally, share it, version it.


โš™ Append-Only Ledgers

Every meaningful execution leaves a replayable trace. The ledger backend records events in append-only fashion โ€” suitable for verification, debugging, and auditing. Replay a run exactly as it happened, or diff two runs side by side.


โš™ Local-First by Design

No broker. No daemon. No hidden mesh. MetaFlow Clockwork runs entirely on your machine. The only orchestration layer is the one you can read in the source.


Design Principles

  โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
  โ•‘                                                                  โ•‘
  โ•‘   PROMPT HYGIENE FIRST                                           โ•‘
  โ•‘   Keep instructions, contracts, and boundaries explicit.         โ•‘
  โ•‘                                                                  โ•‘
  โ•‘   SELF-CONTAINED                                                 โ•‘
  โ•‘   Explicit inputs. Explicit local resources.                     โ•‘
  โ•‘   No hidden control plane.                                       โ•‘
  โ•‘                                                                  โ•‘
  โ•‘   DETERMINISTIC                                                  โ•‘
  โ•‘   Same input โ†’ inspectable, repeatable behavior.                 โ•‘
  โ•‘                                                                  โ•‘
  โ•‘   BOUNDED RECURSION                                              โ•‘
  โ•‘   Recursion is useful when deliberate and constrained.           โ•‘
  โ•‘                                                                  โ•‘
  โ•‘   LEDGERED EXECUTION                                             โ•‘
  โ•‘   Every meaningful run leaves a replayable trace.                โ•‘
  โ•‘                                                                  โ•‘
  โ•‘   LOCAL-FIRST                                                    โ•‘
  โ•‘   No broker. No daemon. No hidden mesh to get started.           โ•‘
  โ•‘                                                                  โ•‘
  โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Prompt Framework & Doctrine

The public prompt and doctrine surface lives under prompts/.

Asset Description
Prompt Hygiene Rules for keeping prompts explicit and bounded
Prompt Template v1 Canonical template for MetaFlow-style prompts
Self-Contained Execution Doctrine The core philosophy in full
Example role contract Reference contract for a local runtime agent
Example prompt A worked example

These assets are public docs and contracts. They describe how MetaFlow work should be framed and bounded. They do not add a hidden runtime loader, broker, or second orchestration surface.

Legacy QRBT bridge names remain only as compatibility notices for migration. Live QRBT bridge execution is not part of the public package.


Examples

Example Description
examples/basic_harmonics.json Minimal JSON run spec to validate and execute
examples/basic_clockwork.py Python example wiring tags and the engine
docs/quickstart.md Hands-on walkthrough from zero to ledger

Validation

Run the same checks used during release hardening:

# Syntax check
python3 -m py_compile metaflow_clockwork/*.py tests/test_*.py examples/basic_clockwork.py

# Unit tests
python3 -m unittest discover -s tests -p 'test_*.py' -v

# Build check
python3 -m pip install --upgrade build twine
rm -rf build dist metaflow_clockwork.egg-info
python3 -m build --sdist --wheel
python3 -m twine check dist/*

# End-to-end spec run
metaflow-clockwork spec-validate ./examples/basic_harmonics.json
metaflow-clockwork spec-run ./examples/basic_harmonics.json --run-root /tmp/metaflow-runs
metaflow-clockwork ledger-verify /tmp/metaflow-runs/example_harmonics

Docs & Community

Architecture How the engine, tags, and ledgers fit together
Prompt Assets Public prompt hygiene, doctrine, and role contract examples
Roadmap Where the public package is headed
Contributing How to contribute
Security Reporting vulnerabilities
Support Getting help
Trademarks Trademark and branding notice
Code of Conduct Community standards
Changelog What changed

License

Licensed under Apache 2.0. Trademark and branding guidance: TRADEMARKS.md.


        โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
        โ•‘   โš™  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โš™   โ•‘
        โ•‘                                               โ•‘
        โ•‘   Build agent systems that are inspectable,   โ•‘
        โ•‘       replayable, and auditable.              โ•‘
        โ•‘                                               โ•‘
        โ•‘   โš™  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โš™   โ•‘
        โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

MetaFlow Clockworkโ„ข ย ยทย  Open-source runtime by SoulHashยฎ ย ยทย  Apache 2.0

Branding rights are reserved. See TRADEMARKS.md.

About

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages