etcd-fsm
🤖 absolute ai, 0% of code written by human 🤖
A typed, asynchronous distributed finite-state machine over etcd.
The current implementation contains the declarative type system, schema and
processor compiler, signature-derived transition graph, an internal etcd
contract, a deterministic MVCC fake, and the production aetcd adapter. The
production runtime is under construction.
from enum import StrEnum, auto
from typing import Literal
from uuid import UUID
from etcd_fsm import BaseState, FSMProcessor, FSMSchema, Retry
class OrderStatus(StrEnum):
CREATED = auto()
PAYMENT_REQUIRED = auto()
class OrderState[S: OrderStatus](BaseState[S]):
order_id: UUID
def fsm_key(self) -> str:
return str(self.order_id)
class Created(OrderState[Literal[OrderStatus.CREATED]]):
state: Literal[OrderStatus.CREATED] = OrderStatus.CREATED
class PaymentRequired(OrderState[Literal[OrderStatus.PAYMENT_REQUIRED]]):
state: Literal[OrderStatus.PAYMENT_REQUIRED] = OrderStatus.PAYMENT_REQUIRED
attempt: int = 1
orders = FSMSchema(
name="orders",
namespace="/state/orders",
state_enum=OrderStatus,
states=(Created, PaymentRequired),
)
payments = FSMProcessor(schema=orders, name="payments")
@payments.reaction()
async def request_payment(state: Created) -> PaymentRequired | Retry:
return PaymentRequired(order_id=state.order_id)
payments.finalize()
Function annotations are the transition definition. Concrete State Models use literal enum discriminators, models are immutable snapshots, and the schema rejects incomplete or inconsistent declarations before a runtime starts.
The public Python API and graph CLI are documented in Russian in docs/API.md. The PyPI release process is documented in docs/RELEASING.md.
Transition graph
Import modules containing schemas and processors and render their combined transition graph as Mermaid:
etcd-fsm graph my_service.orders my_service.payments
Python file paths are accepted as well:
etcd-fsm graph tests/order_domain.py
Every transition is labeled with its processor, function, and producer kind.
Use explicit module:OBJECT or path/to/file.py:OBJECT references when
automatic discovery is not appropriate, or render Graphviz DOT into a file:
etcd-fsm graph my_service.orders:ORDER_SCHEMA \
my_service.payments:PAYMENTS --format dot -o orders.dot
The architectural vocabulary is documented in CONTEXT.md.
Design premises and implementation order are recorded in
docs/DESIGN-NOTES.md, with accepted decisions under
docs/adr/.
Local etcd
Start an ephemeral etcd instance for integration tests:
docker compose up -d --wait
The client endpoint is http://127.0.0.1:12379. Stop it and discard its data
with docker compose down.
Run the real-etcd integration suite explicitly:
uv run pytest --run-integration -m integration
The integration tests use a unique /etcd-fsm-tests/<uuid>/ prefix and clean
it after each test. Override the endpoint with ETCD_FSM_TEST_HOST and
ETCD_FSM_TEST_PORT.
Metadata
Release files for etcd-fsm 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| etcd_fsm-0.1.2.tar.gz | 76.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| etcd_fsm-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 103.2 kB
Release files / etcd_fsm-0.1.2.tar.gz
| Download URL | etcd_fsm-0.1.2.tar.gz |
|---|---|
| Size | 76.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
242f236a526f21ded5531b104a223bf55f3fc0f6e705a13d360103d5f628f7a7
|
|
BLAKE2b-256 checksum How to use checksums |
653443e195aa91a9acc04ced01116f86a8276e50577b882beb5e11ca3544f7f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.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 30, 2026.
Transparency logRelease files / etcd_fsm-0.1.2-py3-none-any.whl
| Download URL | etcd_fsm-0.1.2-py3-none-any.whl |
|---|---|
| Size | 26.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
677c3657a871916d20db53a350d162523f37bb8870af57795a0313d80c32a9f6
|
|
BLAKE2b-256 checksum How to use checksums |
1fef0ce8088576de4e9ee08b60b8f32e813fb47b552f98732eb05d15f4408103
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.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 30, 2026.
Transparency log