Signal Box (LeverFrame) — 1856 Victorian Mechanical Interlocking × Spec-Driven fast-check PBT Exorcist
Kiroween 2026 Submission (
ResurrectionCategory +Best Startup Project+Best Demo) Resurrecting the 19th-century Victorian mechanical railway interlocking signal box (Saxby & Farmer, 1856) in the browser as a safety-critical mutual-exclusion control tower for parallel AI coding agents (Builder,Migrator,Deployer,Verifier), verified step-by-step by an independent Physical Topology Oracle and afast-checkProperty-Based Testing (PBT) Exorcist.
Why Resurrect the 1856 Mechanical Signal Box?
When teams run multiple autonomous AI coding agents in parallel (such as in Kiro Crew workspaces), concurrent agents routinely step on shared resources—simultaneously mutating the same database schema, lockfile, or production deployment lane—while traditional example-based unit tests only check a handful of happy paths and miss multi-step interleaving collisions.
In 1856, John Saxby solved physical mutual exclusion on Victorian railways using the Mechanical Tappet Interlocking Frame: a bed of perpendicular steel locking bars beneath brass levers controlling track points, facing point locks (FPL), and semaphore signals that physically blocks conflicting pulls before a collision can occur.
Signal Box (LeverFrame) resurrects this 19th-century mechanical apparatus and fuses it with Kiro's Spec-Driven Development (/.kiro/specs, /.kiro/steering, /.kiro/hooks), EARS (WHEN ... THE SYSTEM SHALL ...) interlocking rules, and a stepwise fast-check Property-Based Testing (PBT) Exorcist.
Core Architecture & Key Features
8-Lever Victorian Mechanical Interlocking Frame (src/lib/interlocking.ts):
- Lever #1 (
SIGNAL): North Up Home Signal (NORTH_TO_BRIDGE—BuilderAgent) - Lever #2 (
POINT): Junction Crossover Switch (NORMALstraight /REVERSEdiverging) - Lever #3 (
LOCK): Facing Point Lock (FPL #3— plunges into Point #2 to prevent movement under a train) - Lever #4 (
SIGNAL): South Branch Home Signal (SOUTH_TO_BRIDGE—MigratorAgent) - Lever #5 (
SIGNAL): Schema Bridge Distant Signal (BRIDGE_MAINLINE—DeployerAgent) - Lever #6 (
SIGNAL): Shunt & Audit Dwarf Signal (AUDIT_SIDING—VerifierAgent) - Lever #7 (
CLEARANCE): Bridge Token Clearance (REVERSErequired for Signal #5) - Lever #8 (
CLEARANCE): Maintenance Isolation Lock (REVERSEisolates junction for Signal #6)
- Lever #1 (
Strict Separation Between SUT Tappet Matrix & Immutable Physical Topology Oracle:
getInterlockPreset(presetId)returns the System Under Test's tappet locking rules (EARS-ILK-01..08) for eitherSTANDARD_SAFEor the fault-injectedCURSED_MISSING_CROSSOVER_LOCKtable.evaluatePhysicalTopology(state)is completely decoupled frompresetIdand evaluates physical track-block occupancy (north-approach,south-branch,junction-throat,schema-bridge,prod-mainline,audit-siding) and switch alignment against immutable station geometry:P1_NO_CONFLICTING_ROUTES: No two active routes may ever occupy overlapping physical track blocks simultaneously.P2_SIGNAL_POINT_LOCK_INTEGRITY: Every active signal must have its required points aligned and facing point locks plunged.
Stepwise
fast-checkPBT Exorcist & Deterministic Shrinking Replay (src/lib/pbt-exorcist.ts):runInterlockingExorcism(presetId)generates un-filtered random sequences of lever pulls/releases and assertsP1andP2after every individual step.- On
STANDARD_SAFE, all 80 randomized runs (461 stepwise assertions) pass with 0 violations and non-zero reachability witnesses (clearedSignalCount: 19,blockedInterlockCount: 100). - On
CURSED_MISSING_CROSSOVER_LOCK(which omitsEARS-ILK-01and the crossover point check when Signal #1 is clear),fast-checkcatches the physical collision on["junction-throat", "schema-bridge"]in an 11-step sequence and shrinks it to a 3-step minimal counterexample (3.67xreduction):{ leverId: 3, intent: "PULL" }(Engage Facing Point Lock #3){ leverId: 1, intent: "PULL" }(Clear North Up Home Signal #1 →Builderentersjunction-throat&schema-bridge){ leverId: 4, intent: "PULL" }(Clear South Branch Signal #4 →Migratorcollides onjunction-throat&schema-bridgeatfailingStepIndex: 2).
replayCounterexampleSequence(bundle)replays the savedshrunkActionsarray deterministically step-by-step without relying on RNG state.
Interactive Victorian Control Tower UI, WebAudio Mechanical Synthesis & MCP Tool Surface (src/app/page.tsx, src/lib/signal-box-store.ts, src/app/api/mcp/route.ts):
- Live SVG illuminated track diagram, 8-lever brass frame, Tappet Locking Bed with EARS rule citations, step-by-step Shrinking Counterexample Replay controls, and WebAudio synthesized mechanical sounds (
LEVER_LATCH,INTERLOCK_CLANK,COLLISION_ALARM,BELL_CHIME). - Deterministic MCP tool dispatcher (
request_route,release_route,inspect_interlock,run_pbt_exorcism) exposed in-memory and atPOST /api/mcp.
- Live SVG illuminated track diagram, 8-lever brass frame, Tappet Locking Bed with EARS rule citations, step-by-step Shrinking Counterexample Replay controls, and WebAudio synthesized mechanical sounds (
Kiro Spec-Driven Directory (/.kiro/)
Per Kiroween 2026 rules, the root /.kiro/ directory is tracked in Git and contains:
- Specs: .kiro/specs/signal-box/requirements.md (EARS syntax), .kiro/specs/signal-box/design.md, .kiro/specs/signal-box/tasks.md
- Steering: .kiro/steering/product.md, .kiro/steering/tech.md, .kiro/steering/structure.md, .kiro/steering/workflow.md
- Agent Hooks: .kiro/hooks/verify-interlock-on-save.json, .kiro/hooks/run-pbt-on-stop.json
Quick Start & Verification
# Install dependencies (Node.js 24+)
npm install
# Run all 18 TDD & fast-check PBT acceptance tests
npm test
# Build production Next.js bundle
npm run build
# Start interactive Victorian Signal Box server
npm run dev
License
MIT License — see LICENSE.