Expand description
locode-host — the one place the system touches the OS (ADR-0008).
Every side effect funnels through the Host: a path jail, shell execution with a
timeout + output cap, jailed filesystem helpers, and the shared
post-processes. Tools never call std::fs/Command directly —
they go through a Host. This crate is a sibling of locode-tools, so it defines
its own plain error types; the harness pack (which depends on both) maps them to
ToolError::Respond.
Structs§
- DirEntry
- One entry in a directory listing.
- Exec
Limits - Limits on shell execution. Defaults mirror Grok Build (the primary model).
- Exec
Output - The captured result of a command (completed, timed out, or cancelled).
- Exec
Request - A command to run through the host’s shell.
- File
Read - A file’s contents plus its stat (the stat is the freshness token edits compare).
- File
Stat - A file’s size and last-modified time.
- Front
Back Capture - The combined front/back capture (present when the request asked for it).
- Front
Back Spec - Opt-in combined-stream retention (Task 26 Slice 0b; grok’s bash capture shape): keep the first and last halves of a char budget, stream the full output to a host-owned spill file. The pack renders separators/headers — the host returns structure only.
- GitMeta
- Git provenance for the header (grok
summary.json’s git fields). - Host
- The injectable side-effect seam (ADR-0008). Construct once per session, share behind
an
Arc; holds the jail root + policy and the exec/truncation limits. - Host
Config - Construction-time configuration for a
Host. - Rollout
Contents - A parsed rollout: the header plus the replayable message history.
- Session
Meta - Line-1 payload: the session header (ADR-0024 §2.3). An open, growing record — every field beyond the identity core is optional-with-default so old and new binaries share one on-disk population (§2.3 rules).
- Settings
- The typed view of the merged settings (v1 fields, ADR-0024 §1.4). Unknown keys
are tolerated at every layer; absent keys are
None/empty. - Settings
Load - The loader result: the merged settings plus human-readable warnings the caller surfaces on stderr (this crate never prints).
- Shell
Spec - A harness’s shell invocation shape (plan-finalization Q5, 2026-07-21): the
choice rides the request; execution stays behind the host door. Grok’s
shape is
{ detect_program: true, login_arg: false, login_path_probe: true }. - Trace
Extras - Construction-time inputs the
Event::Initevent doesn’t carry. - Trace
Writer - The rollout writer: feed it every engine
Event; it materializes the file onInit(header + preamblemessagelines) and appends onemessageline per appendedMessage. All other event types are ignored — deltas are display-only and the report already has its own artifact (ADR-0014). - Walk
Entry - One traversal entry (the root itself is not reported).
- Walk
Options - Options for
Host::walk.
Enums§
- Exec
Error - A failure to spawn or capture — not a failed command (that is a successful capture
with a non-zero
exit_code). - FsError
- A filesystem operation failure.
- Path
Error - A path-jail failure.
- Path
Policy - Whether the filesystem tools are jailed to the workspace root (ADR-0008 amendment).
- Skills
Extra Entry - One validated
skills.extraentry (ADR-0024 §1.4).
Constants§
- SPILL_
RETAIN_ MAX - Hard cap on bytes written to a spill file (grok retains ≤ 64 MiB).
- TRACE_
SCHEMA_ VERSION - The trace schema version (
session_meta.schema_version). Bumped only by a breaking change the §2.4 rules exist to make unnecessary.
Functions§
- decode_
cwd_ dirname - Decode a session-directory name back to the cwd it encodes, or
Nonefor a hash-fallback name (recover via the.cwdsidecar) or a malformed escape. - default_
locode_ home - The default home (
$HOME/.locode), ignoring any$LOCODE_HOMEoverride — so a caller can detect “am I on the default” (grok’sdefault_grok_homesplit). - encode_
cwd_ dirname - Encode a (canonicalized, absolute)
cwdinto its session-directory name. - find_
latest_ rollout - The newest resumable rollout for
cwd(--continue): list the one encoded directory, take rollouts newest-first by filename (the timestamp prefix sorts chronologically), and return the first whose header parses withkind == "main"— unknown kinds are not listed (§2.4 rule 3), but remain reachable by id. - find_
rollout_ by_ id - Locate a rollout by session id (
--resume <id>): the cwd’s directory first, then every other session directory (Claude’s scoped-then-global resolver). Anykindis resumable by id. - find_
root_ from_ markers - Ascend from
start; the nearest ancestor containing anymarkersentry or whose absolute path matchesstop_patternis the root (ADR-0023 rules 1+2). No hit up to the filesystem root ⇒ cwd-only (returnsstart). The filesystem root is only a backstop, never itself the project root. - load_
settings - Load and merge the five layers for
cwd.flagis the raw--settingsvalue (a path, or inline JSON when it starts with{). - load_
settings_ from - The env-free core of
load_settings:user_diris the resolved~/.locode(orNone),home_for_tildebacks~expansion. - locode_
home - The resolved home, memoized for the process (env is read once).
- read_
rollout - Read a rollout tolerantly (ADR-0024 §2.4 rules 1-2): unknown record
types and unknown payload fields are skipped/ignored; an unparsable line
(the torn tail) is skipped; a
compactedrecord replaces all prior messages with itsreplacement_history. - resolve_
home_ from - The env-free core of
locode_home: resolve the home from explicit environment values instead of the process environment. - rg_
program - The ripgrep program to invoke: the
LOCODE_RG_PATHoverride, else barergon PATH (invoked by name — PATH-hijack hygiene, per Claude Code). - update_
user_ setting - Write
key = valueinto the user settings file, preserving every other key.