The Reloading Lab

Follow the Brass

The complete Ruby project behind the Lab — browse every file, or download the zip and run the suite yourself.

The Reloading Lab: the code

The runnable miniature for the published Reloading Lab tutorial. The earlier first-draft loop remains in first_draft.rb, which nothing requires: it calls methods that exist nowhere, deliberately. If a tutorial snippet and this source disagree, the source is right and the tutorial has drifted.

Plain Ruby and RSpec. No Rails and no hidden globals. The inner fault spec uses owned-type doubles to pin the ProductionRun protocol. The outer lab spec composes real collaborators with one reusable fault fake so the wiring can catch a lying mock.

Requires Ruby 3.2 or newer (Data.define). Check first:

ruby -v
bundle install
bundle exec rspec

The 37-example suite tells the story from several altitudes:

  • mixed cleaning output classified into expected, wrong-context, and foreign exits;
  • a caliber carrier that refuses invalid placement without retaining it;
  • readiness derived from six facts against an injected caliber specification;
  • a four-position press that returns per-position truth and holds on fault;
  • repeatable recovery assessment from established facts;
  • a completed run with batch provenance; and
  • a halted run that preserves faults, positions, pre-production exits, and a recovery plan without executing it.

The unsized regression example exists because the readiness rule was wrong once. The fault-once system example exists because the first production loop silently retried. Both corrections stay visible in the suite.

The model deliberately does not execute recovery, model operator authorization, or prove the physical press. Interrupted-run provenance also remains an open ownership decision in the tutorial.