Module: SwarmSDK::Concerns::Validatable
- Included in:
- Swarm
- Defined in:
- lib/swarm_sdk/concerns/validatable.rb
Overview
Shared validation functionality for Swarm and Workflow
Both classes must have:
- agent_definitions: Hash of Agent::Definition objects
- swarm_id: Swarm/workflow identifier
- parent_swarm_id: Parent identifier (or nil)
Instance Method Summary collapse
-
#emit_validation_warnings ⇒ Array<Hash>
Emit validation warnings as log events.
-
#validate ⇒ Array<Hash>
Validate swarm/workflow configuration and return warnings.
Instance Method Details
#emit_validation_warnings ⇒ Array<Hash>
Emit validation warnings as log events
This validates all agent definitions and emits any warnings as model_lookup_warning events through LogStream. Useful for emitting warnings before execution starts (e.g., in REPL after welcome screen).
Requires LogStream.emitter to be set.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/swarm_sdk/concerns/validatable.rb', line 32 def emit_validation_warnings warnings = validate warnings.each do |warning| case warning[:type] when :model_not_found LogStream.emit( type: "model_lookup_warning", agent: warning[:agent], swarm_id: @swarm_id, parent_swarm_id: @parent_swarm_id, model: warning[:model], error_message: warning[:error_message], suggestions: warning[:suggestions], timestamp: Time.now.utc.iso8601, ) end end warnings end |
#validate ⇒ Array<Hash>
Validate swarm/workflow configuration and return warnings
This performs lightweight validation checks without creating agents. Useful for displaying configuration warnings before execution.
19 20 21 |
# File 'lib/swarm_sdk/concerns/validatable.rb', line 19 def validate @agent_definitions.flat_map { |_name, definition| definition.validate } end |