Module: RobotLab::To::Guards::RunStore
- Defined in:
- lib/robot_lab/to/guards/run_store.rb
Overview
Per-run shared state for the guards.
RobotLab creates a fresh tool-call HookContext per call with its own ExtensionState, so cross-call guard state (the read-set, checkpoint-set, loop tracker) cannot live in ctx.local. robot_lab-to runs each iteration in its own thread (Orchestrator#run_robot_with_interrupt), so a thread-local is a clean per-run scope — the same idiom robot_lab-audit uses for run ids. before_run resets it; the thread ends with the iteration, so nothing leaks across runs.
Class Method Summary collapse
-
.fetch(key, default = nil) ⇒ Object
Fetch the value for
key, initializing todefaultwhen unset. -
.reset(key, value) ⇒ Object
Set/replace the value for
key.
Class Method Details
.fetch(key, default = nil) ⇒ Object
Fetch the value for key, initializing to default when unset.
24 25 26 27 |
# File 'lib/robot_lab/to/guards/run_store.rb', line 24 def fetch(key, default = nil) Thread.current[key] = default if Thread.current[key].nil? && !default.nil? Thread.current[key] end |
.reset(key, value) ⇒ Object
Set/replace the value for key.
19 20 21 |
# File 'lib/robot_lab/to/guards/run_store.rb', line 19 def reset(key, value) Thread.current[key] = value end |