Class: VSM::Meta::Tools::ExplainRole

Inherits:
Base show all
Defined in:
lib/vsm/meta/tools.rb

Constant Summary collapse

ROLE_SUMMARIES =
{
  "identity" => "Defines purpose and invariants; handles alerts/escalation and represents the capsule’s identity.",
  "governance" => "Applies policy and safety constraints; enforces budgets/limits around message handling.",
  "coordination" => "Stages, orders, and drains messages; manages session floor/turn-taking across events.",
  "intelligence" => "Plans and converses using an LLM; maintains conversation state and invokes tools.",
  "operations" => "Executes tool calls by routing to child tool capsules with appropriate execution mode.",
  "monitoring" => "Observes the bus and records telemetry/metrics for observability and debugging."
}.freeze

Instance Attribute Summary

Attributes inherited from Base

#draft_store, #root, #snapshot_cache

Attributes inherited from ToolCapsule

#governance

Instance Method Summary collapse

Methods inherited from Base

#execution_mode, #initialize

Methods included from ActsAsTool

included, #tool_descriptor

Constructor Details

This class inherits a constructor from VSM::Meta::Tools::Base

Instance Method Details

#run(args) ⇒ Object



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/vsm/meta/tools.rb', line 258

def run(args)
  role_name = args["role"].to_s.strip
  raise "role name required" if role_name.empty?

  target_capsule = resolve_capsule(args["capsule"]) || snapshot
  live_capsule = resolve_live_capsule(target_capsule)
  role_instance = resolve_role_instance(role_name, live_capsule)
  roles = target_capsule[:roles] || {}
  role_info = roles[role_name]
  raise "unknown role: #{role_name}" unless role_info

  {
    capsule: {
      name: target_capsule[:name],
      path: target_capsule[:path],
      class: target_capsule[:class]
    },
    role: {
      name: role_name,
      class: role_info[:class],
      constructor_args: role_info[:constructor_args]
    },
    vsm_summary: ROLE_SUMMARIES[role_name] || "",
    source_locations: role_info[:source_locations],
    code: source_blocks_for(role_info[:source_locations]),
    sibling_roles: roles_summary(roles),
    role_specific: role_specific_details(role_name, target_capsule, live_capsule, role_instance)
  }
end