grove · docs

desired state vs actual state

grove cultivates git worktrees. manifest.toml declares desired state, git on disk is actual state, and grove converges them additively — never deleting what it did not create. One binary; grove serve is the daemon, and every status it holds is a cache re-derived from disk.

store and pool files are authoritative push-based, no timers

The root layout

Two trees under $GROVE_HOME, one entry per root in each: roots/<owner>/<repo>/ holds everything grove owns, code/<owner>/<repo>/ holds checkouts and only checkouts.

authoritative · files under $GROVE_HOME, default ~/.grove

desired state

manifest.toml

Declares every root and its worktrees. grove_ops::manifest is its sole owner: format-preserving toml_edit writes under a flock on manifest.toml.lock.

daemon custody

grove.lock · grove.pid · serve.log

grove on spawns under the flock on grove.lock; grove.pid names the daemon with its start time. serve.log is the daemon's own log, rotated to serve.log.1 at 10 MiB.

roots::reconcile_one realizes both trees · additive, never deletes

derived · daemon memory, a cache

roots/<owner>/<repo>/

the root · everything grove owns for it

code/<owner>/<repo>/

the code dir · checkouts, and only checkouts

bare/

The bare clone. adopt walks roots/ for an undeclared bare, never the code tree.

HEAD

<trunk>/

The checkout of the trunk branch, named by worktrees::name_for like every other checkout.

pool/slot-N

Warm detached checkouts. No shares while a slot; promote moves one into the code dir.

promote

<name>/

A worktree, a direct sibling of the trunk: feature/x → feature-x. Canonical depth, so its shares link.

cloning

The clone marker, flock-held while a clone runs; a free lock means a crashed clone.

.DS_Store

The one tolerated stranger. Anything else makes the code dir occupied, and reconcile refuses to clone into it.

re-derived

per root · never persisted

engine status

unknown · missing · cloning · ready · degraded

ready: the bare and the trunk checkout are both directories. Re-derived on every roots_changed and on restart.

a hint

warm-pool count

pool.fill re-observes disk before it mutates, so a stale hint costs at most one no-op fill.

a tail, not a record

log ring

The last 500 lines this process logged. Empty again on the next boot.

Files are authoritative: no database. The daemon may be killed and restarted with only the filesystem intact, and every box on the right is re-derived from disk.

Engine lanes

One engine per declared root drives convergence through that root's lane; the watcher only discovers and announces. Events, never a clock. Detail: engine.

three triggers

nudge · watch · boot

POST /api/roots/reconcile (and the poke a root removal sends), the optional watch on manifest.toml, one announcement at boot.

trigger

discover and announce

watcher

150 ms debounce · never clones

Runs roots::adopt, declaring any undeclared on-disk bare, then reads the declared set and publishes roots_changed.

publish

state channel

EventBus

bounded 256 · tokio broadcast

roots_changed · root_sync_changed · task_started · task_finished. Level-triggered: a lagging subscriber re-reads the world.

subscribes

per-root serialization

lane

one git writer per root · reaped after 60 s idle

Foreground mutations (256) drain first, strictly. Reads (16) come next but yield to waiting background after 16 in a row; background (coalesced, one per kind) last. Nothing in flight is preempted, and a read whose caller left is dropped. Work runs on spawn_blocking; roots run in parallel.

dispatch

one driver per declared root

engine

status cache · one background slot · pool hint

At most one of reconcile / sync / fill in flight, picked in that order on each completion. No timers: a failure degrades, logs, and waits for the next event.

start · stop

the engine set

engine::RootSet

one task · slug → engine

On every roots_changed, starts the declared-minus-running and stops the running-minus-declared.

an unrealized reconcile

the clone bound

ClonePermits

4 permits · GROVE_CLONE_LIMIT

Tried at the head of the root's own lane, never waited for. A miss parks the driver holding nothing; a freed permit pokes one parked driver.

two channels · one wire

GET /api/events

stream::pump

A snapshot, then every bus event and every log-ring line (the last 500, never on the bus), with a heartbeat after 15 s of silence.

boot state · drain

shutdown

booting → ready → stopping

A degrade beside them is sticky. POST /api/daemon/shutdown, SIGTERM, SIGINT or SIGHUP marks stopping, then one 5 s drain_budget: open responses, then lane work.

process custody

launchd · grove on · off

dev.gigantic.grove · grove.pid

launchd keeps grove serve alive and off boots it out. Without the agent, on launches it detached and gates on /api/health; off drains over the API, then SIGTERM → SIGKILL.

Every git write for a root runs on its lane, one at a time, and different roots run in parallel. grove-ops does not enforce this: its flock serializes the manifest, deliberately not git.

Install and upgrade

hotswap, linked into the binary, installs and swaps the version; packslip verifies each release against grove's signer. Every merge to main is a GitHub Release YYYY.M.N, macOS arm64 only.

grove setup           # install, load agents
grove upgrade         # every 900 s by agent
grove upgrade --check # or --back, --retry
grove setup --remove  # ~/.grove stays

grove setup installs the latest release into ~/.local/share/hotswap/grove/<V>/ when none is active — run from a checkout too: the release is linked, never the checkout's binary — links ~/.local/bin/grove through current, and runs two launchd agents on that link: grove's dev.gigantic.grove keeps grove serve alive, and hotswap's own dev.gigantic.grove.upgrade runs grove upgrade every 900 s. The server's PATH keeps mise's shims dir, when one exists, after ~/.local/bin, for what git runs (hooks, git-lfs). An upgrade installs the newer release, repoints current, re-runs setup, then swaps the server with one launchctl kickstart -k, whose SIGTERM runs the daemon's bounded drain. An agent launchd loaded at login carries a managed launch constraint, which the first spawn after a swap violates; hotswap detects it (managed LWCR in launchctl print) and boots the agent out and back in from its plist instead of kicking it, which drains the same way. The upgrade smokes grove --version and GET /api/health, and red rolls back. The record is ~/.local/state/hotswap/grove.json; setup --remove drops it, the agents, the link and the layout.

Decisions

Shipped designs, the choice each made and why.

hotswap installs and swaps · 2026-11-17

grove ships as a packslip release; setup and upgrade are hotswap's tool contract, shared with sandman and routines, and neither needs mise. The versions live in ~/.local/share/hotswap/grove, outside $GROVE_HOME, so the workspace holds nothing an install can delete; an install tree inside it is the doctor finding install-under-home. Why: one install and swap path for every gigantic tool, on a machine with nothing else.

Every stop signal drains · 2026-11-11

SIGTERM, SIGINT and SIGHUP run the shutdown route's drain inside a budget that fits the server agent's ExitTimeOut (10 s), then exit 0 with an exit line in serve.log. A swap is one kickstart -k, or a bootout and bootstrap from the plist for an agent under a managed launch constraint, and a launchd-owned daemon stops by bootout. Why: a separate drain raced KeepAlive's respawn and refused the swap on every tick.

The trunk is a branch, named by that branch · v0.2.0, ea9629a

Every checkout directory is worktrees::name_for(branch); the trunk is the worktree the manifest's optional trunk key points at, else the bare's HEAD. The manifest key is desired state, the bare's HEAD actual state, and reconcile sets one from the other (git::set_head). Changing the trunk is a manifest edit: the new trunk checkout is ensured, shares repoint, and the old trunk stays on disk as an ordinary worktree. Why: a hidden role-named .trunk beside branch-named worktrees was two naming schemes, and some repos integrate on a branch other than the remote default. The wire carries trunk_branch.

Reconcile refuses a legacy or occupied root · v0.2.2, b43745e

realize never clones into a directory it does not own: a root in any older layout is a Failed outcome naming the generation and the remedy (grove doctor --fix), and a code dir holding anything but .DS_Store is refused naming the entries. Migration happens only in doctor --fix, where the operator asked for it; the error reaches RootView.error and grove tree list, and the doctor route nudges a migrated root to re-derive. Why: a daemon booted over legacy roots re-cloned each beside its old layout.

A root holds checkouts and nothing else · v0.3.0, 99b7299

A root is a declared repo — [roots."o/r"] in the manifest, roots/o/r/ on disk (root_dir) holding bare/, pool/slot-N and the cloning marker; its code dir is code/o/r/ (code_dir). clone remove deletes both, so nothing of a root survives elsewhere; adopt walks roots/, and checkouts without a root are the report-only finding orphan-code. One detector (layout::legacy) names all three layout generations and doctor --fix migrates any of them to v3 idempotently, refusing a half-moved root rather than guessing. The root view gains root (shown under --verbose), and grove workspace writes a .code-workspace of every checkout on demand. Why: grove's private entries sat in every editor explorer beside the operator's checkouts, and every rule had to except them.

A stopped engine writes nothing new · #2

Engine::stop raises a flag the reconcile lane job reads before its clone-permit try, so a queued reconcile of a stopped engine never begins. grove-ops work already running cannot be cancelled: a clone mid-transfer finishes and reports to a mailbox nobody reads. The remove ordering stays ※ delete-before-undeclare: undeclaring first would let adopt, which runs off the lane, re-declare the still-present bare, while the window it was to close never reaches reconcile — remove holds the root's lane, and reconcile_one re-reads the declaration under it. Why: a reconcile queued behind a daemon shutting down still cloned the root.

Next

Open, in order.

  1. Bump hk 2.5.0 → 2.8.0 on a host; the shift sandbox cannot reach mise-versions.
  2. Share plan/apply, stage 4 (thread 0109c212): the two seeding rules, waiting on the owner (b7981283) — how a directory source seeds, and whether an ex-trunk's seeded source becomes a link.
  3. Telemetry beyond the lane's ops: a span's status is not set from an op's result, and the daemon's own tracing spans are not exported (a tracing-opentelemetry layer would).

Open sweep findings

Highest first.

  1. A symlink share whose source is a directory refuses every trunk change (confirmed, medium; env.rs carry seed). read_present bails on a directory, which source_op accepts everywhere else; the fix is the directory seeding rule above.
  2. Only origin counts as a branch's remote (plausible, low; git::branch_target, branch_exists). A branch living only on a remote the operator added (upstream/x) is minted off HEAD, untracked. Waits on proposal:jgeschwendt/grove:only-origin-counts.
  3. The old trunk's own share source reads as a conflict after a trunk change (confirmed, low; c079973). The ex-trunk is adopted as a worktree and its real .env is a conflict row, so grove doctor exits 5 after any trunk change.
  4. A refused trunk change still links new worktrees through the occupant (plausible, low; c079973). While a worktree occupies the new trunk's directory, ordinary passes take that checkout as the trunk; a symlink source there reads ok (env.rs source classification), so worktrees created in that window link into the user's checkout.
  5. doctor --fix --force rewrites the old trunk's source during a held trunk change (plausible, low). The ex-trunk is listed as an undeclared worktree, so the link pass backs up main/.env to .env.grove-bak and links it to ../canary/.env before HEAD moves. Fix: skip the bare's HEAD checkout in link/copy/GC while pending.
  6. A carry holds on an in-trunk link whose target the new trunk will have (plausible, low). .k1 -> .real is held even when .real is tracked or itself a declared share, until the operator re-creates it; the check is lexical.

Unattended shifts

Sandbox denials, not regressions; gate them on a host run.

Gate spans

Every run of mise run check is one OpenTelemetry trace through floodgate span: a check span with its two parallel steps, fmt and clippy, nested under it, so floodgate's page shows which step costs the time and CPU.

check only wraps check:steps in its root span; the steps live there. A step is wrapped in mise run span -- <name> [--attr k=v]… -- <cmd…> (.mise/tasks/span): it execs floodgate span when floodgate is on PATH, else the command after the second --, so a machine without floodgate, CI included, gates as before. To add a step, put it in the check:steps task's script wrapped the same way; a step left bare is time no span explains. cover and test are separate tasks, not spanned.

Reference

The mechanics; this page is the design and the plan.

pagewhat it covers
apithe HTTP surface the daemon serves
architecturecrates, desired vs actual state, reconcile
deploymentrequirements, environment, served mode
engineper-root engines, lanes, status derivation
worktreestrunk, worktrees, pool, recovery, adoption; shares and the per-worktree environment
jgeschwendt/grovethe repository