Module: RobotLab::To::Guards
- Defined in:
- lib/robot_lab/to/guards.rb,
lib/robot_lab/to/guards/run_store.rb,
lib/robot_lab/to/guards/checkpoint.rb,
lib/robot_lab/to/guards/grader_lock.rb,
lib/robot_lab/to/guards/write_guard.rb,
lib/robot_lab/to/guards/path_resolution.rb,
lib/robot_lab/to/guards/quality_monitor.rb,
lib/robot_lab/to/guards/read_before_edit.rb
Overview
Small-model guardrails ported from little-coder (Apache-2.0).
These RobotLab::Hook subclasses make file/bash tools safe for a small local model driving an autonomous robot_lab-to loop. They are no-ops for a frontier model, so registration is opt-in.
Wire them onto a per-iteration robot in Orchestrator#build_robot:
robot = RobotLab.build(...)
RobotLab::To::Guards.install(robot, run: @run) if @config.local_guards
robot
Each guard is single-purpose and independently testable: its class methods take a HookContext and have no hidden global state beyond a per-robot store that is reset on before_run.
Defined Under Namespace
Modules: PathResolution, RunStore Classes: Checkpoint, GraderLock, QualityMonitor, ReadBeforeEdit, WriteGuard
Constant Summary collapse
- ALL =
[ Guards::WriteGuard, Guards::ReadBeforeEdit, Guards::Checkpoint, Guards::QualityMonitor ].freeze
Class Method Summary collapse
-
.install(robot, run: nil, except: []) ⇒ RobotLab::Robot
Register every guard on a robot.
Class Method Details
.install(robot, run: nil, except: []) ⇒ RobotLab::Robot
Register every guard on a robot.
except: lists guard classes to skip. Passing [WriteGuard] lets a robot
overwrite existing files (WriteGuard otherwise refuses Write on an existing
file and redirects to Edit -- unhelpful for iterative prose that rewrites a
draft).
45 46 47 48 49 50 51 |
# File 'lib/robot_lab/to/guards.rb', line 45 def self.install(robot, run: nil, except: []) active = ALL - Array(except) robot.on(Guards::Checkpoint, context: { run: run }) if run (active - [Guards::Checkpoint]).each { |guard| robot.on(guard) } robot.on(Guards::Checkpoint) unless run robot end |