Component · for humans & their agents
State Machine Executor
verified · first-partyactively maintained$0 during beta (was $29)
An illegal state transition that quietly does nothing is worse than a crash. A generic, pure transition engine: given a table, a current state, an event and a guard context, it enforces legality and emits a typed event with actor attribution — or refuses, naming the reason.
by saltyhash · Code Recycle admin
Every claim on this page is refundable if it is untrue — refund policy.
Building it yourself: ~0.7h of agent time across about 2 attempts. Your credits are already paid for, so that feels free — but they are rivalrous: those are hours not spent on the part only you can build. And this one fails quietly when it is wrong, so the attempt that looks finished may not be. $29.
7 tests. Zero runtime dependencies, ESM. No I/O, no database, and no Date.now() — the
The bug this exists to prevent
Hand-rolled state machines are a switch that falls through. An event arrives in a state nobody considered, no case matches, and the function returns. The entity stays where it was, the caller sees success, and the mismatch surfaces later somewhere unrelated — an order stuck in awaiting_payment that was paid, a job neither running nor finished.
Nothing logs, because from the code's point of view nothing happened. That is the defect: **not transitioning and transitioning are indistinguishable to the caller.**
Rule 1 — refuse, never no-op
Every rejection is explicit. An undefined (from, event) pair is refused. A defined pair whose guard fails is refused naming the guard and the reason, because "transition rejected" without a reason sends the reader to the wrong file.
Rule 2 — an ambiguous table is a programming error, not a runtime choice
Two rows matching the same (from, event) pair throws, rather than returning a result. There is no correct way to pick one, and picking either silently makes the table's meaning depend on row order. This is the one case that escalates past the Result type: a caller cannot handle it, only a developer can fix it.
Rule 3 — a successful transition emits evidence
Success produces a typed event carrying the actor and the timestamp. A state machine that records only the new state cannot answer who changed it or when — the two questions asked first when something is wrong.
Creation transitions (from: null) are first-class, so an entity's first state is recorded the same way as every later one rather than appearing from nowhere.
What this does NOT do
No persistence, no event bus, no scheduling, no retries, no clock. You supply the transition table, the guard context and occurredAt; you persist the emitted event.
It does not model parallel states, hierarchies or history states. It is a flat table.
Verified
7 tests: row lookup for defined and undefined pairs, refusal with no matching row, guard failure naming the guard, a legal transition emitting a typed event with actor and timestamp, creation from null, and the ambiguous-table throw.
Not covered: no concurrency test. Two writers racing the same entity is your storage layer's problem — this decides legality, it does not serialise anything.
01Capabilities
Does
- + Audit logs
- + Workflow builder
- + Event ordering and gap detection
Doesn’t
- No exclusions declared
02Requirements & stack
Depends on
No declared dependencies
Credentials needed
None declared
Stack
03Community
No endorsements yetNo verified confirmations yet — be the first.
Confirmations come from verified purchasers, installers, vetted reviewers, or an installation outcome your org reported through the agent tools. They grade quality — security is verified separately, and community votes can never override the security gate.
Sign in to confirm — weight comes from verified usage, not vote count.
Issues 0
Open an issueNobody has reported anything yet — a success counts as a report too.
04Trust Passport
Full passport →0/0 automated components pass. An automated score is never a security guarantee.
- publisher identity Publisher status verified; 1 verification(s) on file
- malicious pattern scan No known malicious-behavior patterns across 9 source file(s) plus listing text
- capability contract All 0 observed capability reference(s) match the declared manifest
- agent safety scan No injection patterns in agent-readable content
- provenance No release signature or provenance attestation
- behavioral sandbox Not performed in this environment — requires the production isolated runner (docs/sandbox-requirements.md). No untrusted code is ever executed on the application host.
Every listing must pass this review before it can be sold, and it is re-run on every release. Verification describes what we checked — it is not a guarantee that the software is safe.
05Versions
Full history →| Version | Channel | Released | Notes |
|---|---|---|---|
| 0.1.0 | stable | Aug 11, 2026 | Initial extraction. |