state-machines-and-invariants

Solid

Governing correctness through explicit state machines and enforced invariants. Defines when the system is READY vs DEGRADED vs STALE vs INVALID, what is allowed in each state, and when to fail fast. Use when designing or reviewing real-time data systems, streaming pipelines, upstream adapters, aggregated feeds, health checks, or any logic that can silently degrade data quality. Prevents optimistic outputs. Also use when the user mentions "state machine", "system state", "fail fast", "invariant violation", "when to stop", or when reviewing any code that decides whether to serve or reject data.

AI & Automation 3 stars 0 forks Updated today MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
20
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# State Machines and Invariants ## Cardinal Rule State is the source of truth. If state is not READY, the system must not behave as if it is. Never compute, merge, or present results that imply correctness when state indicates degradation, staleness, or invalidity. When any mandatory invariant fails: **fail fast** with a structured reason. ## No Policy, No Answer If the system depends on thresholds (staleness ms, consecutive events N, failure count K, cooldown period T) and those values are not provided or configured, **refuse to make state decisions**. Return: > "Missing policy values — cannot decide state transitions. Provide thresholds." Never invent or guess threshold values. ## Core Concepts ### Event vs State - **Events** are inputs: WS messages, REST responses, timeouts, validation failures. - **State** is the maintained truth of what the system currently believes. - A single good event does NOT erase a bad state unless the state machine rules explicitly allow it. ### No Silent Recovery Recovery must be explicit. Document: - What changed? - Why is it safe now? - Which invariants are passing again? ## State Models ### System State (Global) ```typescript type SystemState = | 'BOOTING' // starting up, loading config | 'WARMING' // acquiring initial data | 'READY' // fully operational | 'DEGRADED' // some sources unavailable | 'UNHEALTHY' // critical invariants failing | 'DISABLED'; // manually turned off ``` ### Source ...

Details

Author
Canhada-Labs
Repository
Canhada-Labs/ceo-orchestration
Created
4 weeks ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category