Class: Space::Architect::Research::Supervisor

Inherits:
Object
  • Object
show all
Defined in:
lib/space_architect/research/supervisor.rb

Constant Summary collapse

DEFAULT_MODEL =
Harness::CLAUDE_DEFAULT_MODEL
DEFAULT_MAX_TURNS =
40

Instance Method Summary collapse

Constructor Details

#initialize(space:, bin: nil) ⇒ Supervisor

Returns a new instance of Supervisor.



12
13
14
15
16
# File 'lib/space_architect/research/supervisor.rb', line 12

def initialize(space:, bin: nil)
  @space    = space
  @bin      = bin
  @registry = Registry.new(space.path.join("build", "research", "registry.yaml"))
end

Instance Method Details

#dispatch(prompts, model: DEFAULT_MODEL, max_turns: DEFAULT_MAX_TURNS) ⇒ Object

Dispatch each prompt file as a detached read-only claude -p child. Returns array of Run objects (non-blocking).



20
21
22
# File 'lib/space_architect/research/supervisor.rb', line 20

def dispatch(prompts, model: DEFAULT_MODEL, max_turns: DEFAULT_MAX_TURNS)
  prompts.map { |path| dispatch_one(Pathname.new(path), model: model, max_turns: max_turns) }
end

#statusObject

Classify each registered run and return per-run state hashes.



25
26
27
28
29
30
31
# File 'lib/space_architect/research/supervisor.rb', line 25

def status
  @registry.all.map do |run|
    state = classify(run)
    tail  = tail_lines(run.run_log_path, 5)
    { run: run, state: state, tail: tail }
  end
end

#wait(quiet: false, level: 1, thinking: false, jsonl: false, out: $stdout) ⇒ Object

Async mux: tail all runs to terminal. Returns :ok or :failed.



34
35
36
37
38
39
40
41
# File 'lib/space_architect/research/supervisor.rb', line 34

def wait(quiet: false, level: 1, thinking: false, jsonl: false, out: $stdout)
  effective_level = quiet ? 0 : level
  renderer = Renderer.new(level: effective_level, thinking: thinking, jsonl: jsonl)
  runs = @registry.all
  return :ok if runs.empty?

  Mux.new(runs, renderer: renderer, out: out).run
end