Skip to content

Commit 4723c7e

Browse files
Merge pull request #4 from Spacecraft-Software/m5-slice5-autospawn-headless
feat(vault): M5 slice 5 — CLI agent auto-spawn + headless feature gate
2 parents 045790b + ca60477 commit 4723c7e

8 files changed

Lines changed: 336 additions & 60 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ jobs:
4747
- run: cargo build --workspace --all-targets
4848
- run: cargo test --workspace --all-targets
4949

50+
headless:
51+
name: headless build (no TUI / clipboard deps)
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v5
55+
- uses: dtolnay/rust-toolchain@stable
56+
- uses: Swatinem/rust-cache@v2
57+
# PRD G6: the server install path must keep building — the CLI behind
58+
# its `cli` feature gate, and the agent without the clipboard's
59+
# X11/Wayland dependency tree.
60+
- run: cargo build -p vault-cli --no-default-features --features cli
61+
- run: cargo build -p vault-agent --no-default-features
62+
5063
version-gate:
5164
name: vault --version emits §13.2 attribution
5265
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,35 @@ range may break in any release.
1010

1111
### Added
1212

13+
- **M5 (slice 5) — CLI agent auto-spawn + headless feature gate.** The two
14+
non-TUI M5 items, closing out the milestone.
15+
- **Auto-spawn (PRD §7.3).** Any `vault` verb now starts `vault-agent`
16+
itself when the socket is dead (missing file or stale, connection-refused
17+
socket — other errors, e.g. permissions, still surface directly). The CLI
18+
locates the agent via `$VAULT_AGENT_BIN`, then a `vault-agent` sibling of
19+
the `vault` binary, then `$PATH`; starts it in its own process group
20+
(`--socket` passed explicitly, stdin/stdout null, stderr appended to
21+
`agent.log` beside the socket in the 0700 runtime dir); and poll-connects
22+
until the agent accepts (2 s deadline, 25 ms interval), reusing the first
23+
accepted stream. Opt out per-call with the global `--no-auto-spawn`;
24+
`stop-agent` never spawns (stopping a dead agent shouldn't start one).
25+
New `vault-cli/src/spawn.rs` module; the old "start the daemon with
26+
`vault-agent &`" hint remains only on the no-spawn paths.
27+
- **Headless gate (PRD G6).** The `vault` bin now carries
28+
`required-features = ["cli"]`, making the documented server install
29+
literal: `cargo install --path crates/vault-cli --no-default-features
30+
--features cli` (pair with `cargo install --path crates/vault-agent
31+
--no-default-features` to drop the clipboard's X11/Wayland tree). A new
32+
CI `headless` job builds both combos so the gate can't rot. README's
33+
Status and headless sections updated to match reality.
34+
- Known limitation: two racing CLI invocations can each spawn an agent; the
35+
second bind steals the socket path (the listener removes a pre-existing
36+
socket file) and the first agent is orphaned until its idle lock. Benign
37+
for the single-user posture; a flock around spawn is a possible follow-up.
38+
- Tests: binary-resolution precedence (override > sibling > `$PATH`,
39+
empty override ignored), dead-socket error classification, and poll-loop
40+
behavior (picks up a late listener; gives up at the deadline).
41+
1342
- **M5 (slice 4) — TUI mutations: `a` add, `e` edit, `d` delete (confirm).**
1443
PRD §7.2's Mutation row goes live, completing the daily-driver loop (browse
1544
→ search → reveal/copy → mutate) without falling back to the CLI. Pure TUI

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ The full product requirements live in [`PRD.md`](./PRD.md).
1515

1616
## Status
1717

18-
Pre-alpha — M0 scaffolding only. The `vault` binary builds and emits the
19-
Standard §13.2 attribution block via `--version`; nothing else is wired up
20-
yet. See [PRD §12](./PRD.md#12-milestones) for the roadmap (M0 → v0.1).
18+
Pre-alpha, M5. The read and write paths are wired end-to-end against a live
19+
agent: `status` / `unlock` / `lock` / `sync` / `list` / `get` / `add` /
20+
`edit` / `remove` / `generate` / `stop-agent` on the CLI (with `--json`
21+
everywhere), and a three-pane `vault-tui` with search, reveal/copy
22+
(agent-side clipboard, 30 s auto-clear), a generator overlay, a `:` command
23+
line, and add/edit/delete. The CLI auto-starts the agent when needed. See
24+
[PRD §12](./PRD.md#12-milestones) for the roadmap (M0 → v0.1) and
25+
[`CHANGELOG.md`](./CHANGELOG.md) for per-slice detail.
2126

2227
## Build
2328

@@ -26,12 +31,19 @@ cargo build --release
2631
./target/release/vault --version
2732
```
2833

29-
Headless install (no TUI dependencies) — once the feature gate lands in M5:
34+
Headless install (no TUI dependencies; the agent additionally drops the
35+
clipboard's X11/Wayland tree):
3036

3137
```sh
3238
cargo install --path crates/vault-cli --no-default-features --features cli
39+
cargo install --path crates/vault-agent --no-default-features
3340
```
3441

42+
The CLI auto-starts `vault-agent` when the socket is dead: it looks for a
43+
sibling of the `vault` binary, then `$PATH` (override with
44+
`$VAULT_AGENT_BIN`; opt out per-call with `--no-auto-spawn`). A spawned
45+
agent logs to `agent.log` beside the socket.
46+
3547
## Repository layout
3648

3749
```

crates/vault-agent/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
//!
55
//! Run with no arguments to bind the default socket
66
//! (`$XDG_RUNTIME_DIR/vault/agent.sock`). Override with `--socket PATH` or
7-
//! `VAULT_AGENT_SOCK`. The agent does NOT yet daemonise itself — start it
8-
//! with `nohup vault-agent &` or run it under a systemd user unit. M5 adds
9-
//! auto-spawn from the CLI.
7+
//! `VAULT_AGENT_SOCK`. The agent does not daemonise itself: the normal start
8+
//! path is the CLI's auto-spawn — any `vault` verb starts it detached when
9+
//! the socket is dead, logging to `agent.log` beside the socket — and a
10+
//! systemd user unit works too.
1011
1112
#![forbid(unsafe_code)]
1213

crates/vault-cli/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ readme.workspace = true
1616
[[bin]]
1717
name = "vault"
1818
path = "src/main.rs"
19+
# The headless gate (PRD G6): `cargo install --path crates/vault-cli
20+
# --no-default-features --features cli` is the supported server install;
21+
# with no features at all there is nothing to build.
22+
required-features = ["cli"]
1923

2024
[lints]
2125
workspace = true
@@ -24,6 +28,9 @@ workspace = true
2428
default = ["cli"]
2529
cli = []
2630

31+
[dev-dependencies]
32+
tempfile = { workspace = true }
33+
2734
[dependencies]
2835
anyhow = { workspace = true }
2936
clap = { workspace = true }

0 commit comments

Comments
 (0)