Skip to main content

A deterministic finite state machine for modeling workflows that guide AI agents.

Project description

markov-protocols

A Finite State Machine capable of modeling workflows to provide guidance to an AI agent with determinism.

A standalone Python module providing the state-machine mechanism, meant to be reused across other Python projects.

Status

Slices 1–3 complete — the engine is functionally whole:

  • Definition — conditions, references, metadata, the State interface with three concrete state types, transitions, the registry, and Workflow.compile().
  • RuntimeBlackboard, the Event history, Directive materialization, and Session.start/update with the write + fast-forward passes.
  • Integrity — a correction (ValueChanged) reopens the states that depend on it, strict-rewinds to the earliest one, clears reopened actions' outputs so they re-run, and flags had_executed for host compensation. All derived from history — no parallel bookkeeping.
  • Blockers & rendering — every state explains why it hasn't advanced via blockers (MISSING / INVALID / AWAITING_*); requirements take description + options (enum with per-value descriptions); components render to safe, factual prompt text via Renderable.
  • Serialization — import/export workflows as JSON or YAML (to_json/from_json/…), validated through compile().

See docs/DESIGN.md for the full architecture and build plan.

Development

Managed with uv.

uv sync            # create the environment and install dev tools
uv run pytest      # run the test suite
uv run ruff check  # lint
uv run mypy        # type-check

Layout

src/markov_protocols/
    __init__.py        # curated public API
    result.py          # Result[T, E] / ErrorType — the error-handling pattern
    base.py            # StrictModel / StrictOpenModel
    slug.py            # deterministic title -> id
    conditions/        # the typed boolean vocabulary + pure evaluator
    references.py      # Ref + resolve + referenced_fields
    definition/        # metadata, State interface + concrete states, Transition,
                       #   registry, Workflow.compile()
    runtime/           # Blackboard, Event history, Session + update() pipeline
tests/                 # one property-focused module per unit

Conventions

  • Operations return a Result[T, E] instead of raising exceptions.
  • Target Python 3.13+.

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

markov_protocols-0.2.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

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

markov_protocols-0.2.0-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file markov_protocols-0.2.0.tar.gz.

File metadata

  • Download URL: markov_protocols-0.2.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for markov_protocols-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d1bed610f82e44833bda7016ca131e22765801c91be9651cd09bfe6a646a6abb
MD5 9ce3ab696484479794618aa1328e9d0f
BLAKE2b-256 94fe88a5b50ea1245571cd3abae02506cf592839f909500cd86d72b2b0275851

See more details on using hashes here.

File details

Details for the file markov_protocols-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: markov_protocols-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for markov_protocols-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8340bf282b693b5e43dfa443da15d3dc2e3ec4dc55d22ce2edd867b8a2253f78
MD5 e0209ed2138bb653801b21e2de411a55
BLAKE2b-256 92e7d34157ece602e61042e1e5d2d746c90470f672f01b41b34811b93ad37c05

See more details on using hashes here.

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