# `H.ExecutionEnv`
[🔗](https://github.com/parlant/harness/blob/v0.3.0/lib/h/execution_env.ex#L1)

Pluggable filesystem and process execution boundary for `H` tools.

Tools (`read`, `write`, `edit`, `bash`) interact exclusively through `H.ExecutionEnv`
rather than calling `File` or `System.cmd` directly, allowing local workspaces,
disposable test directories, and later remote/sandbox environments to share one
tool implementation and conformance suite.

# `command`

```elixir
@type command() :: {:shell, String.t()} | {:argv, [String.t()]}
```

# `exec_result`

```elixir
@type exec_result() :: %{
  exit_code: integer(),
  output: binary(),
  truncated: boolean(),
  skipped_bytes: non_neg_integer(),
  full_output_path: nil | String.t()
}
```

# `t`

```elixir
@type t() :: {module(), state :: term()}
```

# `bind_cwd`
*optional* 

```elixir
@callback bind_cwd(state :: term(), cwd :: String.t()) ::
  {:ok, state :: term()} | {:error, term()}
```

# `canonical_path`
*optional* 

```elixir
@callback canonical_path(state :: term(), path :: String.t()) ::
  {:ok, String.t()} | {:error, term()}
```

# `cwd`

```elixir
@callback cwd(state :: term()) :: String.t()
```

# `env_id`
*optional* 

```elixir
@callback env_id(state :: term()) :: String.t()
```

# `exec`

```elixir
@callback exec(state :: term(), command(), opts :: keyword()) ::
  {:ok, exec_result()} | {:error, term()}
```

# `kind`
*optional* 

```elixir
@callback kind(state :: term()) :: String.t()
```

# `list_dir`

```elixir
@callback list_dir(state :: term(), path :: String.t(), opts :: keyword()) ::
  {:ok, %{entries: [map()], next_cursor: nil | non_neg_integer()}}
  | {:error, term()}
```

# `list_files`
*optional* 

```elixir
@callback list_files(state :: term(), path :: String.t(), opts :: keyword()) ::
  {:ok, %{entries: [map()], truncated: boolean()}} | {:error, term()}
```

# `read_file_bytes`

```elixir
@callback read_file_bytes(state :: term(), path :: String.t(), opts :: keyword()) ::
  {:ok, binary()} | {:error, term()}
```

# `read_file_lines`

```elixir
@callback read_file_lines(state :: term(), path :: String.t(), opts :: keyword()) ::
  {:ok, map()} | {:error, term()}
```

# `resolve_path`

```elixir
@callback resolve_path(state :: term(), path :: String.t()) ::
  {:ok, String.t()} | {:error, term()}
```

# `write_file`

```elixir
@callback write_file(state :: term(), path :: String.t(), content :: iodata()) ::
  :ok | {:error, term()}
```

# `bind_canonical_cwd`

```elixir
@spec bind_canonical_cwd(t(), String.t(), keyword()) :: {:ok, t()} | {:error, term()}
```

Binds to an existing directory. With `exact: true`, rejects changes to its previously resolved canonical path.

# `bind_cwd`

```elixir
@spec bind_cwd(t(), String.t()) :: {:ok, t()} | {:error, term()}
```

# `canonical_path`

```elixir
@spec canonical_path(t(), String.t()) :: {:ok, String.t()} | {:error, term()}
```

# `cwd`

```elixir
@spec cwd(t()) :: String.t()
```

# `default_markers`

```elixir
@spec default_markers() :: [String.t()]
```

Standardized project marker filenames used when browsing directories.

# `env_id`

```elixir
@spec env_id(t()) :: String.t()
```

# `exec`

```elixir
@spec exec(t(), command(), keyword()) :: {:ok, exec_result()} | {:error, term()}
```

Runs a command in the bound environment. Host and Remote accept
`raw_output: true` to preserve bytes and `spill_output: false` to retain
only the bounded output window without persisting an overflow file.

# `kind`

```elixir
@spec kind(t()) :: String.t()
```

# `list_dir`

```elixir
@spec list_dir(t(), String.t(), keyword()) ::
  {:ok, %{entries: [map()], next_cursor: nil | non_neg_integer()}}
  | {:error, term()}
```

# `list_files`

```elixir
@spec list_files(t(), String.t(), keyword()) ::
  {:ok, %{entries: [map()], truncated: boolean()}} | {:error, term()}
```

# `new`

```elixir
@spec new(module(), term()) :: t()
```

# `read_file_bytes`

```elixir
@spec read_file_bytes(t(), String.t(), keyword()) ::
  {:ok, binary()} | {:error, term()}
```

# `read_file_lines`

```elixir
@spec read_file_lines(t(), String.t(), keyword()) :: {:ok, map()} | {:error, term()}
```

# `resolve_path`

```elixir
@spec resolve_path(t(), String.t()) :: {:ok, String.t()} | {:error, term()}
```

# `write_file`

```elixir
@spec write_file(t(), String.t(), iodata()) :: :ok | {:error, term()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
