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
Stateinterface with three concrete state types, transitions, the registry, andWorkflow.compile(). - Runtime —
Blackboard, theEventhistory,Directivematerialization, andSession.start/updatewith 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 flagshad_executedfor host compensation. All derived fromhistory— no parallel bookkeeping. - Blockers & rendering — every state explains why it hasn't advanced via
blockers(MISSING/INVALID/AWAITING_*); requirements takedescription+options(enum with per-value descriptions); components render to safe, factual prompt text viaRenderable. - Serialization — import/export workflows as JSON or YAML (
to_json/from_json/…), validated throughcompile().
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1bed610f82e44833bda7016ca131e22765801c91be9651cd09bfe6a646a6abb
|
|
| MD5 |
9ce3ab696484479794618aa1328e9d0f
|
|
| BLAKE2b-256 |
94fe88a5b50ea1245571cd3abae02506cf592839f909500cd86d72b2b0275851
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8340bf282b693b5e43dfa443da15d3dc2e3ec4dc55d22ce2edd867b8a2253f78
|
|
| MD5 |
e0209ed2138bb653801b21e2de411a55
|
|
| BLAKE2b-256 |
92e7d34157ece602e61042e1e5d2d746c90470f672f01b41b34811b93ad37c05
|