SuperPi.Env.Behaviour behaviour (super_pi v0.1.0)

Copy Markdown View Source

Unified execution environment contract (SuperPi.Env, REQ-SAFE-01..REQ-SAFE-04).

Provides isolated filesystem, search, and OS process operations that never crash the BEAM VM.

Summary

Callbacks

edit_file(path, old_text, new_text, opts)

@callback edit_file(
  path :: String.t(),
  old_text :: String.t(),
  new_text :: String.t(),
  opts :: keyword()
) ::
  {:ok, %{replacements: non_neg_integer()}} | {:error, term()}

exec_command(cmd, args, opts)

@callback exec_command(cmd :: String.t(), args :: [String.t()], opts :: keyword()) ::
  {:ok,
   %{exit_code: integer(), output: String.t(), spilled_path: String.t() | nil}}
  | {:error, term()}

id()

@callback id() :: String.t()

list_files(root_dir, opts)

@callback list_files(root_dir :: String.t(), opts :: keyword()) ::
  {:ok, [String.t()]} | {:error, term()}

read_file(path, opts)

@callback read_file(path :: String.t(), opts :: keyword()) ::
  {:ok, String.t()} | {:error, term()}

scan_lines(root_dir, pattern, opts)

@callback scan_lines(root_dir :: String.t(), pattern :: String.t(), opts :: keyword()) ::
  {:ok, [map()]} | {:error, term()}

write_file(path, content, opts)

@callback write_file(path :: String.t(), content :: String.t(), opts :: keyword()) ::
  :ok | {:error, term()}