GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - devsoniclk/railyard: State-machine execution guardrails — enforces strict verification checkpoints so agents cannot skip phases or deploy early

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
docs
docs
 
 
examples
examples
 
 
src/railyard
src/railyard
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

Railyard

Prompts tell agents what not to do. State machines make certain things impossible.

The problem with prompt-based guardrails is that they're suggestions. "Don't deploy before tests pass" is a polite request. Railyard enforces it structurally — the deploy tool simply doesn't exist until the machine is in the approved state.

pip install -e .

How it works

You define a state machine. Each state exposes only the tools valid in that state. Transitions between states are declared explicitly, with optional guard conditions. The agent runs through the runtime, which enforces the machine at every step.

from railyard import Machine, state, AgentAction

m = Machine(start="draft")

m.add(state("draft",    tools=["write", "edit"]))
m.add(state("review",   tools=["comment", "request_changes", "approve"]))
m.add(state("approved", tools=["deploy"]))
m.add(state("done",     terminal=True))

m.allow("draft -> review")
m.allow("review -> approved", guard=lambda ctx: ctx.get("tests_passed", False))
m.allow("approved -> done")

m.validate()

The validate() call checks that every non-terminal state has at least one outgoing transition, and that no state is unreachable. Catches structural bugs in your machine definition before runtime.

Running an agent through it:

def my_agent(rt, ctx):
    if rt.current_state == "draft":
        return AgentAction(tool="edit", next_state="review")
    if rt.current_state == "review":
        return AgentAction(tool="approve", next_state="approved")
    if rt.current_state == "approved":
        return AgentAction(tool="deploy", next_state="done")

with m.run(my_agent) as session:
    session.run_until_done(context={"tests_passed": True})

If the agent tries to skip a step:

def rogue_agent(rt, ctx):
    return AgentAction(tool="deploy", next_state="done")  # from draft state

with m.run(rogue_agent) as session:
    session.step()
    # InvalidTransition: Tool 'deploy' not allowed in state 'draft'

It doesn't return an error to the agent. It raises. The agent can't recover from it by trying something else.

Audit trail

Every transition is logged as JSONL:

session._runtime.log.save("audit.jsonl")

from railyard import TransitionLog, Replay
log = TransitionLog.load("audit.jsonl")
result = Replay(m).check(log)
print(result.valid)   # did every transition follow the declared machine?
print(result.errors)  # details if not

CLI

railyard validate machine.yaml
railyard replay audit.jsonl

Examples

  • examples/code_review_deploy.py — 4-state deploy workflow with test gate
  • examples/support_triage.py — ticket routing with escalation path

What's missing

YAML machine loader is on the list. Right now you define machines in Python. LangChain and CrewAI adapters aren't done either — the core runtime is framework-agnostic but the integrations that filter tool lists automatically are still manual.

License

MIT

About

State-machine execution guardrails — enforces strict verification checkpoints so agents cannot skip phases or deploy early

Topics

ai-agentsguardrailspythonreliabilitystate-machineworkflow-engine

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.