heph.nvim: rip out auto-spawn — connect-only plugin
All checks were successful
Build / validate (pull_request) Successful in 10m44s

The daemon is now an OS service (`heph daemon`); the plugin no longer spawns or
supervises one. Removes the managed-daemon machinery entirely.

- delete lua/heph/daemon.lua (spawn/ensure/stop_spawned/self-heal)
- init.lua: connect-only; probe `health` once and guide to `heph daemon start`
- rpc.lua: drop set_respawn + respawn-on-drop; a dropped connection just
  reconnects once (e.g. after `heph daemon restart`), never spawns
- config.lua: drop autostart/bin/db; stable socket fallback (data-dir, matches
  hephd::default_socket_path), keep $HEPH_SOCKET for dev isolation
- tests: spawn/wait_ready move into the e2e harness (test infra); rework
  managed_daemon_spec into a connect-only spec (connect / clean-fail / reconnect)

16 nvim e2e specs pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-06-02 21:21:28 -07:00
commit cdd4d9f62a
6 changed files with 114 additions and 308 deletions

View file

@ -11,48 +11,29 @@ M.config = nil
--- Configure the plugin. `opts.socket` overrides the daemon socket path;
--- `opts.keymaps = false` disables the default keymaps. Idempotent.
---
--- The plugin is **connect-only** — it never spawns or supervises a `hephd`.
--- Run the daemon as an OS service with `heph daemon start` ([[run-the-daemon]]);
--- this just connects to it. If nothing is serving the socket, we notify once
--- with guidance and let later calls retry (a plain reconnect, never a spawn).
function M.setup(opts)
local cfg = vim.tbl_deep_extend("force", config.defaults, opts or {})
cfg.socket = config.resolve_socket(cfg.socket)
cfg.db = config.resolve_db(cfg.db)
M.config = cfg
local rpc = require("heph.rpc")
local daemon = require("heph.daemon")
rpc.setup(cfg.socket)
if cfg.autostart then
-- Plug-and-play: bring up a managed local daemon if none is serving, and
-- self-heal a dropped connection on later calls.
local ok = pcall(daemon.ensure, {
socket = cfg.socket,
db = cfg.db,
bin = cfg.bin,
autostart = true,
})
if not ok then
require("heph.util").notify(
"could not start hephd; will retry on first use",
vim.log.levels.WARN
)
end
rpc.set_respawn(function()
pcall(daemon.ensure, {
socket = cfg.socket,
db = cfg.db,
bin = cfg.bin,
autostart = true,
})
end)
else
-- Explicit architecture: connect only, never spawn over the user's daemon.
rpc.set_respawn(nil)
if not daemon.ensure({ socket = cfg.socket, autostart = false }) then
require("heph.util").notify(
"no hephd reachable at " .. cfg.socket .. " (autostart disabled)",
vim.log.levels.WARN
)
end
-- A cheap liveness probe so a missing daemon is reported up front, not as a
-- cryptic error on the first command.
local ok = pcall(function()
rpc.call("health", {})
end)
if not ok then
require("heph.util").notify(
"no hephd at " .. cfg.socket .. " — run `heph daemon start`",
vim.log.levels.WARN
)
end
config.apply_keymaps(cfg)