Skip to content

env shell: make the agent-in-box actually work by default#128

Merged
Koukyosyumei merged 2 commits into
mainfrom
improve-shell
Jun 11, 2026
Merged

env shell: make the agent-in-box actually work by default#128
Koukyosyumei merged 2 commits into
mainfrom
improve-shell

Conversation

@Koukyosyumei

Copy link
Copy Markdown
Collaborator

No description provided.

The default `h5i env shell` could not run coding agents: claude/codex live
under $HOME (not granted), the supervised socket gate denied the anonymous
AF_UNIX socketpair every modern runtime creates at startup (codex panicked
in tokio's signal setup), setsid detached the session from its controlling
tty (no job control, broken TUIs), TERM wasn't passed, and the wall-clock
timer SIGKILLed interactive sessions after 30min.

- supervised gate: socketpair(AF_UNIX) is always allowed (anonymous pair =
  intra-box IPC, no authority); socket(AF_UNIX) stays deny-by-default
- interactive sessions keep the caller's terminal session (no setsid) and
  have no wall-clock kill — operator-bounded, same rule both tiers
- default env_pass gains TERM/COLORTERM; /dev/null + /dev/zero are
  write-granted sinks
- new built-in 'agent' profile (no env.toml needed): ro ~/.local, ~/.nvm,
  rc files, git identity; rw ~/.claude(.json), ~/.codex, ~/.cache, ~/.npm,
  /tmp, /dev/tty; net.egress pinned to the agent APIs (supervised/container
  only — refuses tiers that can't enforce it); USER/SHELL; 8G/512 procs
- env shell banner shows the profile + hints at --profile agent

Verified on a supervised host: claude -p completed a real API round-trip
inside the box; codex reads its auth; example.com blocked; ~/.ssh denied.
Instead of hinting at --profile agent from inside a box that can't run an
agent, an unspecified --profile now auto-picks: the built-in 'agent'
profile when its policy is actually enforceable on this host (net.egress
needs the supervised/container tier — also checked against an explicitly
pinned weaker --isolation), else the fail-closed 'default' with a printed
note. Same pattern as the isolation auto-pick: explicit = fail-closed,
unspecified = best runnable.

So the out-of-the-box flow is now just:
  h5i env create tmp && h5i env shell tmp   # claude/codex run, egress pinned

Also: agent profile additionally grants ro ~/.cargo/env + ~/.cargo/bin
(PATH shims only, NOT ~/.cargo with credentials.toml) so .bashrc sourcing
works; CreateOpts.profile is Option<String> (None = auto) across CLI/MCP.

(Audit note: the flagged 'exec()' is sandbox::verify_exec, h5i's own
confinement self-test — not code execution.)

Verified: bare create → agent+supervised on this host, claude --version
runs in the box; --isolation process falls back to default with the note;
989 tests + clippy clean.
@Koukyosyumei Koukyosyumei changed the title Improve shell env shell: make the agent-in-box actually work by default Jun 11, 2026
@Koukyosyumei Koukyosyumei merged commit 144edfe into main Jun 11, 2026
1 check passed
@Koukyosyumei Koukyosyumei deleted the improve-shell branch June 11, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant