Skip to content

About

A graded ladder of nine state machines (chain, cycle, reversible graph, containment poset, DFA, LR automaton, register machine, replicated state machine), each posed as reconstruct-a-view-from-a-log. One worked reference and eight open challenges to implement as event-stream projections. Spec-driven, oracle-gated.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

state-machine-ladder

https://img.shields.io/badge/reference-9%2F9_solved-brightgreen.svg https://img.shields.io/badge/challenges-9-blue.svg https://img.shields.io/badge/spec-v2.8.0-blue.svg https://img.shields.io/badge/method-spec--driven_%C2%B7_EDD-77aa99.svg https://img.shields.io/badge/cell-FreeBSD_amd64-orange.svg

Nine state machines of increasing difficulty, each posed as the same problem: reconstruct a view from a log. Every machine is a source-derivation-view instance (see =spec.org=) - the source is an append-only event log, the derivation is a pure fold, and the view is a projection. Your job is to implement the fold and reproduce the challenge’s byte-exact oracle. The ladder climbs from a linear chain (trivial as an event stream) to a replicated state machine (Raft), which is the pattern made fault-tolerant and the reason all of these are the same problem: a state machine is a deterministic function of its log.

The ladder

#challengestructure Sdifficultysourcestatus
1order-lifecyclechain (total order)1referencesolved
2traffic-light3-cycle2classic / TLA+solved
3elevatorproduct + request set4classicsolved
4lamp-two-switchreversible graph ({0,1}^2)3learntlasolved
5login-hierarchycontainment poset (tree)4learntlasolved
6dfa-even-01complete DFA (cyclic)5Hopcroftsolved
7lr-parser-fsmLR automaton + stack6Graphviz gallerysolved
8register-machinecontroller + datapath7SICP §5.1solved
9raft-replicated-smreplicated log -> apply8Raft / C. Troysolved

The structure column is the point: a chain has a sound wide-flag projection (down-sets); a cycle or reversible graph does not - there the view must be the current state plus a transition-legality check; a poset (the login tree) restores down-sets in general form; a DFA collapses the view to accept/reject; an LR automaton and a register machine need a stack; Raft replicates the whole thing. Choosing the right projection is half of each challenge.

How to play

bin/verify.sh                         # run every challenge that has a reference
bin/verify.sh challenges/01-order-lifecycle
cat challenges/02-traffic-light/README.org    # read a challenge's spec
bin/new-exercise -d /tmp/scratch -n mine ...  # stamp a fresh skeleton (see spec §12)

Each challenge is challenges/NN-<name>/. A solved one ships fixtures under data/, a reference under examples/<tag>-<lang>/ whose run.sh prints the oracle, and examples/oracle-contract.txt; bin/verify.sh diffs them. An open one ships the spec (states, transitions, structure, what to implement, how it is judged) - build the fixtures + reference per spec.org §8 and pin the oracle.

Layout

pathwhat
challenges/NN-<name>/one state machine, easy -> hard
spec.orgthe generator: the source-derivation-view pattern
.meta/operating disciplines and vocabulary
bin/verify.shladder runner (PASS / FAIL / OPEN per challenge)
bin/new-exercisestamp a new challenge skeleton from the §2 parameters

About

A graded ladder of nine state machines (chain, cycle, reversible graph, containment poset, DFA, LR automaton, register machine, replicated state machine), each posed as reconstruct-a-view-from-a-log. One worked reference and eight open challenges to implement as event-stream projections. Spec-driven, oracle-gated.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages