Skip to content

feat(vault): M5 slice 5 — CLI agent auto-spawn + headless feature gate#4

Merged
UnbreakableMJ merged 1 commit into
mainfrom
m5-slice5-autospawn-headless
Jun 12, 2026
Merged

feat(vault): M5 slice 5 — CLI agent auto-spawn + headless feature gate#4
UnbreakableMJ merged 1 commit into
mainfrom
m5-slice5-autospawn-headless

Conversation

@UnbreakableMJ

Copy link
Copy Markdown
Contributor

Summary

Closes out M5 with its two non-TUI items: the CLI now auto-starts the agent (PRD §7.3), and the headless server install is a real, CI-guarded feature gate (PRD G6).

Auto-spawn (PRD §7.3) — new vault-cli/src/spawn.rs

  • Any vault verb starts vault-agent when the socket is dead (missing file or stale connection-refused socket; other errors, e.g. permissions, still surface directly).
  • Binary resolution: $VAULT_AGENT_BIN override → vault-agent sibling of the vault binary → $PATH.
  • The agent is started in its own process group (a Ctrl+C aimed at the CLI can't kill it), with --socket passed explicitly and stderr appended to agent.log beside the socket in the 0700 runtime dir.
  • The CLI poll-connects (2 s deadline / 25 ms interval) and reuses the first accepted stream — no second-connect race.
  • Global --no-auto-spawn opts out per call; stop-agent never spawns (stopping a dead agent must not start one).
  • A small Endpoint { socket, auto_spawn } context replaces the bare &Path through the command handlers.

Headless gate (PRD G6)

  • The vault bin now carries required-features = ["cli"], making the documented server install literal:
    cargo install --path crates/vault-cli --no-default-features --features cli
    cargo install --path crates/vault-agent --no-default-features   # drops the X11/Wayland tree
  • New CI headless job builds both combos so the gate can't rot.

Docs

README Status section trued up (was still claiming "M0 scaffolding only") + headless install instructions; vault-agent's stale "run via nohup" module doc replaced.

Known limitation (tracked in CHANGELOG)

Two racing CLI invocations can each spawn an agent; the second bind steals the socket path and the first idles until its lock. Benign at single-user posture; a flock around spawn is a possible follow-up.

Tests

Binary-resolution precedence (override > sibling > $PATH, empty override ignored), dead-socket error classification, and poll-loop behavior (picks up a late listener; gives up at the deadline). Verified live end-to-end: spawn-on-first-verb (one call: spawn + answer), silent reuse on the second call, agent.log placement, --no-auto-spawn, and stop-agent-never-spawns. Workspace: 100+ tests green, clippy -D warnings (pedantic+nursery) clean, cargo deny clean.

🤖 Generated with Claude Code

Close out M5 with its two non-TUI items.

Auto-spawn (PRD §7.3): any `vault` verb now starts `vault-agent` itself
when the socket is dead (missing file or stale connection-refused
socket; other errors, e.g. permissions, still surface directly). New
vault-cli/src/spawn.rs locates the agent via $VAULT_AGENT_BIN, then a
vault-agent sibling of the `vault` binary, then $PATH; starts it in its
own process group (--socket passed explicitly, stdin/stdout null,
stderr appended to agent.log beside the socket in the 0700 runtime
dir); and poll-connects until the agent accepts (2 s deadline, 25 ms
interval), reusing the first accepted stream. A new global
--no-auto-spawn flag opts out per call, and stop-agent never spawns —
stopping a dead agent must not start one. A small
Endpoint { socket, auto_spawn } context replaces the bare &Path through
the command handlers.

Headless gate (PRD G6): the `vault` bin now carries
required-features = ["cli"], making the documented server install
literal: cargo install --path crates/vault-cli --no-default-features
--features cli (pair with vault-agent --no-default-features to drop the
clipboard's X11/Wayland tree). A new CI `headless` job builds both
combos so the gate can't rot.

Docs trued up: README Status (was still "M0 scaffolding only") and the
headless install section; vault-agent's "run via nohup" module doc;
CLAUDE.md's agent/cli/tui bullets and milestone state.

Known limitation (tracked in CHANGELOG): two racing CLI invocations can
each spawn an agent; the second bind steals the socket path and the
first agent idles until its lock. Benign at single-user posture.

Tests: binary-resolution precedence (override > sibling > $PATH, empty
override ignored), dead-socket error classification, and poll-loop
behavior (picks up a late listener, gives up at the deadline). Verified
live end-to-end: spawn-on-first-verb, silent reuse, agent.log placement,
--no-auto-spawn, and stop-agent-never-spawns.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@UnbreakableMJ
UnbreakableMJ merged commit 4723c7e into main Jun 12, 2026
8 checks passed
@UnbreakableMJ
UnbreakableMJ deleted the m5-slice5-autospawn-headless branch June 12, 2026 23:42
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