# H v0.3.0 - API Reference

## Modules

- [H.ExecutionEnv.Host.Fs](H.ExecutionEnv.Host.Fs.md): Local host filesystem operations for `H.ExecutionEnv.Host`: symlink-hop-bounded
`canonical_path`, UTF-8 line scanning, bounded byte reads, atomic file writes,
directory listing, and bounded BFS file discovery.

- [H.Session.Tree](H.Session.Tree.md): Read-only session-wide entry tree builder for live, cold native, and imported
archived sessions.
- [H.Storage.File.Wal](H.Storage.File.Wal.md): CRC32-framed binary write-ahead log (`commit.log`) encoding, appending,
replay, and torn-tail recovery for `H.Storage.File`.

- Daemon &amp; Entry Points
  - [H](H.md): Elixir/OTP core for H (`hiness` on Hex, `:harness` OTP application).
  - [H.Accounts](H.Accounts.md): Daemon-owned named accounts and login operations. Inference workers can
resolve a credential; owner clients get only an explicitly projected view.

  - [H.Accounts.Vault](H.Accounts.Vault.md): Private single-writer credential storage under the daemon's data-dir lock.
Not part of session storage and not an isolation boundary for same-UID tools.

  - [H.Application](H.Application.md): OTP application entry point. Embedded hosts can opt into the same daemon
instance as `H.serve/1` by configuring `:harness, :data_dir`. Read
[Embed the core in an OTP application on hiness.dev](https://hiness.dev/docs/architecture/#embed-the-core-in-an-otp-application)
for store isolation and workspace boundaries.

  - [H.Auth](H.Auth.md): Owner bearer token and browser session cookie manager backed by a `:protected`
ETS table and `<data_dir>/auth.token` (`0600`).
  - [H.Catalog](H.Catalog.md): Server-owned session metadata index (`<data_dir>/catalog/sessions.json`)
backed by a `:protected` ETS table for lock-free concurrent reads.
  - [H.Credentials](H.Credentials.md): In-memory credential resolver for LLM providers.
  - [H.Daemon](H.Daemon.md): Transport-agnostic daemon API for `H` sessions, conversations, transcripts,
SSE subscriptions, and idempotent commands.
  - [H.Daemon.ColdSession](H.Daemon.ColdSession.md): Side-effect-free cold storage reader for archived native sessions.
  - [H.Daemon.Validation](H.Daemon.Validation.md): Boundary parameter, query, and command envelope validation for `H.Daemon`.

  - [H.Daemon.Workspace](H.Daemon.Workspace.md): Workspace directory browsing, bounded recursive file discovery, UTF-8 file
reading, and lexical + canonical symlink containment checks for `H.Daemon`.

  - [H.StoreLock](H.StoreLock.md): OS-level single-daemon ownership lock for `data_dir`.

- Sessions &amp; Domain
  - [H.Archive](H.Archive.md): Read-only imported session snapshots, stored separately from live session WALs.
  - [H.Context](H.Context.md): Pure context reducer projecting visible transcript entries, agent settings,
and tool descriptors into a provider-neutral request map and `ReqLLM` structs.

  - [H.Conversation](H.Conversation.md): A linear transcript segment, optionally inheriting another conversation's prefix.
  - [H.Document](H.Document.md): Versioned pure-functional conversation documents (`agent`, `live`, `inbox`, `usage`),
JSON delta operations, and fork policy resolution.

  - [H.Entry](H.Entry.md): An immutable transcript record. IDs are ordered and unique within a session.
  - [H.Schema](H.Schema.md): Boundary validator for untrusted decoded JSON maps, command envelopes,
and HTTP parameters.
  - [H.Session](H.Session.md): Pure session history: a working directory, conversations, and immutable entries.
  - [H.Submission](H.Submission.md): Idempotent command receipt keyed by `request_id` with deterministic payload
fingerprinting and status transitions (`queued`, `placed`, `done`, `unanswered`, `withdrawn`).

  - [H.Task](H.Task.md): Versioned durable task record (`generation`, `tool_call`) and pure state
transitions (`pending`, `running`, `waiting`, `sleeping`, `terminal`).

  - [H.Transcript](H.Transcript.md): Pure Elixir reducer for conversation transcript SSE/PubSub frames.
Applies document deltas with `H.Document.apply_ops/2`.

- Session Runtime
  - [H.Session.Compaction](H.Session.Compaction.md): Manual `/compact` policy, safe provider-visible prefix projection, boundary
selection, and single-call summarization for `H` sessions.
  - [H.Session.Server](H.Session.Server.md): Single mutation authority and durable coordinator for one `H` session.
  - [H.Session.Server.Commands](H.Session.Server.Commands.md): Command envelope deduplication and staging (`submit`, `fork`, `fork_and_submit`,
`configure`, `abort`, `withdraw`, `rename`, `compact`, and `user_shell`
delegation) for `H.Session.Server`.

  - [H.Session.Server.Generation](H.Session.Server.Generation.md): Generation and compaction worker spawning, auto-compaction promotion,
retry/wake staging, and completion/cancellation/abort settlement for
`H.Session.Server`.

  - [H.Session.Server.Recovery](H.Session.Server.Recovery.md): Session store bootstrap, open-time checkpoint reconciliation, worker crash
recovery, restart-budget enforcement, and clean-shutdown persistence for
`H.Session.Server`.

  - [H.Session.Server.State](H.Session.Server.State.md): Shared session coordinator state transitions, conversation entry/visibility
queries, workspace lease coordination, worker termination, and `H.Catalog`
runtime reporting.

  - [H.Session.Server.Stream](H.Session.Server.Stream.md): Ephemeral streaming output buffers, periodic live document flushing,
`ProcBin` SSE commit/ephemeral frame broadcasting, 64-entry replay ring,
and initial conversation snapshot encoding.

  - [H.Session.Server.Submissions](H.Session.Server.Submissions.md): Submission lookup, bounded LRU caching, settlement, inbox draining, automatic
initial title derivation, and pending generation run creation for
`H.Session.Server` and `H.Session.UserShell`.

  - [H.Session.Server.Tools](H.Session.Server.Tools.md): Tool worker spawning, argument validation, mutating workspace lease handling,
sequential tool-round advancement, and interrupted/aborted tool settlement
for `H.Session.Server`.

  - [H.Session.Server.WorkspaceWait](H.Session.Server.WorkspaceWait.md): Signal-driven workspace admission. Waiting work has no execution attempt to replay.
  - [H.Session.Subagents](H.Session.Subagents.md): Coordinator-managed subagent delegation lifecycle for `H.Session.Server`.
  - [H.Session.Supervisor](H.Session.Supervisor.md): Per-session `:one_for_all` supervision boundary (`Task.Supervisor` + `H.Session.Server`).
  - [H.Session.UserShell](H.Session.UserShell.md): Durable backend lifecycle for user-invoked shell commands (`!` / `!!`).

- Extensions, Harnesses &amp; Tools
  - [H.Extension](H.Extension.md): Startup contract for a trusted, locally built H extension (API 1).
  - [H.Harness](H.Harness.md): Behaviour for pluggable agent harness profiles (`H.Harness.Coding`, etc.).
  - [H.Harness.Coding](H.Harness.Coding.md): Default `Pi`-compatible coding harness profile (`id: "coding"`).
  - [H.Tool](H.Tool.md): Behaviour and JSON Schema validation helper for durable tools in `H`.
  - [H.Tools.Bash](H.Tools.Bash.md): Core `bash` tool for executing shell commands via `H.ExecutionEnv.exec/3`.

  - [H.Tools.Edit](H.Tools.Edit.md): Core `edit` tool for exact, unique, non-overlapping multi-hunk replacements
against the original file contents while preserving untouched line endings.

  - [H.Tools.Read](H.Tools.Read.md): Core `read` tool for bounded UTF-8 text reads and PNG/JPEG/GIF/WebP image reads.

  - [H.Tools.SearchHistory](H.Tools.SearchHistory.md): Core `search_history` tool for searching raw un-truncated transcript entries.

  - [H.Tools.Subagent](H.Tools.Subagent.md): Coordinator-managed subagent delegation tool (`name: "subagent"`).
  - [H.Tools.Write](H.Tools.Write.md): Core `write` tool for atomically writing a file through `H.ExecutionEnv`.

- Execution Environments
  - [H.EnvRegistry](H.EnvRegistry.md): Stateless resolver turning environment configurations into live `H.ExecutionEnv.t()`
handles and plain JSON-safe environment descriptors.

  - [H.ExecutionEnv](H.ExecutionEnv.md): Pluggable filesystem and process execution boundary for `H` tools.
  - [H.ExecutionEnv.Host](H.ExecutionEnv.Host.md): Local host filesystem and OTP `Port` process-group execution environment (`H.ExecutionEnv`).

  - [H.ExecutionEnv.Host.Exec](H.ExecutionEnv.Host.Exec.md): Sanitized environment construction, OTP `Port` execution, OS `PGID` process-group
reaping, and rolling tail/spill-file output buffering for `H.ExecutionEnv.Host`.

  - [H.ExecutionEnv.Local](H.ExecutionEnv.Local.md): Compatibility wrapper delegating to `H.ExecutionEnv.Host`.

  - [H.ExecutionEnv.Remote](H.ExecutionEnv.Remote.md): Cooperative remote `H.ExecutionEnv` adapter backed by a `H.RemoteAgent` handle.
  - [H.RemoteAgent](H.RemoteAgent.md): In-VM cooperative remote execution agent GenServer (`H.ExecutionEnv.Remote` transport seam).
  - [H.WorkspaceLease](H.WorkspaceLease.md): Coordinates per-workspace mutating tool leases by `{env_id, canonical_cwd}`
so concurrent coding runs do not clobber the same working tree while keeping
separate execution environments isolated.

- Storage
  - [H.Storage](H.Storage.md): Pluggable persistence boundary for a single `H` session.
  - [H.Storage.Engine](H.Storage.Engine.md): Shared in-memory domain projection, batch evaluation, entry scanning,
revisioned document lookup, and safe string-key normalization for `H.Storage`
backends.

  - [H.Storage.File](H.Storage.File.md): Durable local file backend implementing `H.Storage` with a CRC32-framed
binary WAL (`commit.log`) and atomic JSON snapshots (`snapshot.<seq>.json`).

  - [H.Storage.File.Snapshot](H.Storage.File.Snapshot.md): Atomic JSON snapshot persistence (`snapshot.<seq>.json`), WAL truncation,
and snapshot recovery for `H.Storage.File`.

  - [H.Storage.Memory](H.Storage.Memory.md): In-memory reference backend implementing `H.Storage`.

- Providers
  - [H.Provider](H.Provider.md): Storage-neutral LLM streaming behaviour for `H`.
  - [H.Provider.AccountPolicy](H.Provider.AccountPolicy.md): Optional account ordering for the existing Codex adapter. Return a subset
of the supplied aliases, in preference order, using cached data only.
  - [H.Provider.Fake](H.Provider.Fake.md): Deterministic scripted `H.Provider` for `--no-start` unit and recovery tests.
  - [H.Provider.Fake.UnscriptedRequestError](H.Provider.Fake.UnscriptedRequestError.md): Raised when `H.Provider.Fake` receives a turn after its scripted steps are exhausted.
  - [H.Provider.ReqLLM](H.Provider.ReqLLM.md): `H.Provider` adapter backed by `ReqLLM` and `LLMDB`.
  - [H.Provider.ReqLLM.Catalog](H.Provider.ReqLLM.Catalog.md): Model catalog curation, `LLMDB` lookup, Gemini/Vertex synchronous limit
normalization, and default model selection for `H.Provider.ReqLLM`.

  - [H.Provider.ReqLLM.CodexPool](H.Provider.ReqLLM.CodexPool.md): Managed Codex account dispatch, pooled credential selection, and pre-output
authentication rejection handling for `H.Provider.ReqLLM`.

- HTTP &amp; SSE Transport
  - [H.HTTP.Router](H.HTTP.Router.md): `Plug.Router` for the local `H` HTTP/JSON and SSE daemon.
  - [H.HTTP.SSE](H.HTTP.SSE.md): Chunked Server-Sent Events (`text/event-stream`) transport loop.
  - [H.HTTP.SecurityPlug](H.HTTP.SecurityPlug.md): HTTP security boundary

