Class: Insika::Commands::WriteGolden
- Inherits:
-
Object
- Object
- Insika::Commands::WriteGolden
- Defined in:
- lib/insika/commands/write_golden.rb
Overview
Control command: writes an eval case into the GoldenStore. This is what lets a domain owner add a case — above all its RUBRIC, the part of an eval that is plain language — without a checkout and a text editor.
The payload carries the case as DATA (case:), the same mapping the YAML file
holds; the store validates it with the one loader, so a case authored here and a
case read from evals/golden/ cannot diverge. -> { id, agent }.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(golden_store:, event_stream:) ⇒ WriteGolden
constructor
A new instance of WriteGolden.
Constructor Details
#initialize(golden_store:, event_stream:) ⇒ WriteGolden
Returns a new instance of WriteGolden.
15 16 17 18 |
# File 'lib/insika/commands/write_golden.rb', line 15 def initialize(golden_store:, event_stream:) @goldens = golden_store @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/insika/commands/write_golden.rb', line 20 def call(command) p = AgentPayload.symbolize(command.payload) raise Insika::ValidationError, "case is required" unless p[:case].is_a?(Hash) golden = @goldens.write(p[:case]) emit(:golden_written, id: golden.id, agent: golden.agent) { id: golden.id, agent: golden.agent } end |