feat(vault): M5 slice 5 — CLI agent auto-spawn + headless feature gate#4
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.rsvaultverb startsvault-agentwhen the socket is dead (missing file or stale connection-refused socket; other errors, e.g. permissions, still surface directly).$VAULT_AGENT_BINoverride →vault-agentsibling of thevaultbinary →$PATH.--socketpassed explicitly and stderr appended toagent.logbeside the socket in the 0700 runtime dir.--no-auto-spawnopts out per call;stop-agentnever spawns (stopping a dead agent must not start one).Endpoint { socket, auto_spawn }context replaces the bare&Paththrough the command handlers.Headless gate (PRD G6)
vaultbin now carriesrequired-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 treeDocs
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.logplacement,--no-auto-spawn, and stop-agent-never-spawns. Workspace: 100+ tests green,clippy -D warnings(pedantic+nursery) clean,cargo denyclean.🤖 Generated with Claude Code