AlgRelay: The State Machine Enhancer for Exact Algorithmic Work
Most people are chasing LLMs. But some of us are building systems where "maybe" isn't good enough. Where every transition must be exact. Where algorithms need to be provable, testable, and deterministic.
That's where AlgRelay comes in.
What It Is
AlgRelay is a simple but powerful enhancer for state machine algorithms. It lets you define common input cases per state and maps them to integer codes for clean match/case transitions.
class AlgRelay:
# this module is used to enhance state machine algorithms
# it lets the coder add common cases per state
def __init__(self):
super().__init__()
self.dic: dict[str, int] = {}
# code 1: next mode
# code 2: goal achieved
# code 3: error/failure
# code 4: empty str
# code 5: any other str
def add_next_mode(self, *keys: str) -> None:
for key in keys:
self.dic[key] = 1
def add_goal_achieved(self, *keys: str) -> None:
for key in keys:
self.dic[key] = 2
def add_error(self, *keys: str) -> None:
for key in keys:
self.dic[key] = 3
def relay(self, str1: str) -> int:
if str1 in self.dic:
return self.dic[str1]
if len(str1) == 0:
return 4
return 5
Why This Matters for Exact Algorithms
When you're building state machines for exact algorithmic work, you need:
- Deterministic behavior: Same input always produces same output
- Per-state context: Each state cares about different inputs
- Clean transitions: No spaghetti code
- Testability: Every path can be verified
AlgRelay delivers all of this. Each state gets its own instance with its own mapping. The same input string can mean "advance" in one state and "error" in another. Empty strings are handled consistently. Unknown inputs don't crash – they return code 5.
What LLMs Can't Do
This is the key point. LLMs are probabilistic. They're great for generation, terrible for exactness. They can't:
- Guarantee the same output for the same input
- Maintain strict state boundaries
- Handle timeouts deterministically
- Provide provable transitions
- Run on resource-constrained hardware
- Work without internet or API calls
AlgRelay and systems built on it can do all of these things. Because sometimes you need code that always works the same way, every time, forever.
Part of a Complete Toolkit
AlgRelay is just one module in the LivinGrimoire ecosystem – a comprehensive collection of primitives for building exact, deterministic algorithms.
👉 AXPython.py – The Complete Module
Browse the repository. You'll find dozens of battle-tested modules for state management, timing, triggers, and more. All built for exact algorithmic work.
Building something that needs to be exact? Check out the repo. And drop a comment below – I'd love to hear what you're working on.
Top comments (0)