Class: OllamaAgent::Runtime::IsolatedValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/runtime/isolated_validator.rb

Overview

Runs array-exec validation commands inside a locked-down Docker container (no host shell). rubocop:disable Metrics/ClassLength – Docker argv + capture + status interpretation stay together

Instance Method Summary collapse

Constructor Details

#initialize(image:, workspace_root:, runtime_command: "docker", timeout_epochs: 300, wal: nil) ⇒ IsolatedValidator

Returns a new instance of IsolatedValidator.

Parameters:

  • image (String)

    Docker image reference (digest recorded when available).

  • workspace_root (String)

    host path bind-mounted read-only at /workspace.

  • runtime_command (String) (defaults to: "docker")

    container CLI executable name or path (default docker).

  • timeout_epochs (Integer) (defaults to: 300)

    wall-clock seconds allowed for the container run (E7 naming; not logical epoch).

  • wal (WAL, nil) (defaults to: nil)

    optional WAL for mutation_step audit rows.



15
16
17
18
19
20
21
22
23
24
# File 'lib/ollama_agent/runtime/isolated_validator.rb', line 15

def initialize(image:, workspace_root:, runtime_command: "docker", timeout_epochs: 300, wal: nil)
  @image = image
  @workspace_root = File.expand_path(workspace_root)
  @runtime_command = runtime_command
  @timeout_epochs = timeout_epochs.to_i
  @wal = wal
  @digest_memo = :unset
  @runtime_checked = false
  @runtime_ok = false
end

Instance Method Details

#run(command:, manifest_id:, logical_stamp:) ⇒ Hash

Returns keys: :status, :exit_code, :stdout, :stderr, :image_digest.

Parameters:

  • command (Array<String>)

    argv passed to the container entrypoint (no host shell).

  • manifest_id (String)
  • logical_stamp (String)

Returns:

  • (Hash)

    keys: :status, :exit_code, :stdout, :stderr, :image_digest



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ollama_agent/runtime/isolated_validator.rb', line 30

def run(command:, manifest_id:, logical_stamp:)
  assert_array_command!(command)
  digest = cached_image_digest
  return unavailable_result(digest) unless runtime_ok?

  argv = docker_argv(command)
  status, code, out, err = execute_docker(argv)
  result = base_result(status, code, out, err, digest)
  record_mutation_step(manifest_id, logical_stamp, result, command) if record_step?(status)
  result
end