# Daemon-lifecycle int verification — kitsubito systemd rig (2026-06-08)

> Manual live-rig verification of REQ-DAEMON-6/7/8 (commit `ccbef73`) against a
> real systemd **user** unit. Not an automated committed test — the systemd
> `--user` instance + a live `spt-daemon.service` is environment-specific, so
> `required_stages` for these REQs stays `[impl, unit]` (the routing logic is
> unit-covered; this doc is the integration evidence, per rule 5's "activate,
> don't pre-fail"). Re-run on a fleet box after any change to `service.rs`.

## Rig

- Host: `reavus@kitsubito` (Linux, systemd user unit `spt-daemon.service`,
  `active` + `enabled`, `ExecStart=/home/reavus/.local/bin/spt daemon run`,
  no `Environment=SPT_HOME` → default home, shared socket).
- New binary built on-box from `ccbef73` at
  `~/spt-core-deploy/target/debug/spt` (the installed `~/.local/bin/spt` was
  **not** touched — zero live contamination). Transferred as a git bundle of
  the unpushed commits; deploy checkout + bundle artifacts restored after.

## Results

Non-disruptive (live unit active):

- `daemon status` → `daemon: running (pid 458997)` + `managed-by: systemd
  --user (active)`. Proves the new binary pings the live daemon's socket
  cross-binary, and `detected()` + `is_active()` + `label()` resolve against
  real `systemctl --user`. **[int→REQ-DAEMON-6]**
- `daemon start` (already running) → `DAEMON_ALREADY_RUNNING`. Idempotent;
  `plan_start(running=true,…)=AlreadyRunning`. **[int→REQ-DAEMON-6/8]**

Self-restoring disruptive cycle:

1. `systemctl --user stop` → `inactive`; new `daemon status` → `not running
   (\`spt daemon start\`, or any spt command auto-starts it)`.
2. `daemon stop` (down) → `DAEMON_NOT_RUNNING (already stopped)` —
   `plan_stop(running=false,…)=NotRunning`. **[int→REQ-DAEMON-6]**
3. `daemon start` (down + service detected) → `DAEMON_STARTED (via systemd
   --user)`; unit `active`; the running daemon PID (`555157`) **equals systemd
   `MainPID`** → it is the *service*, not a competing manual detached spawn;
   exactly one `spt daemon run` process. **[int→REQ-DAEMON-6/8]** (no
   double-daemon — the kitsubito 2026-06-08 restart-loop cannot recur.)
4. `daemon stop` (active + managed) → `DAEMON_STOPPED (via systemd --user)`;
   unit `inactive`. A clean `systemctl stop`, so `Restart=on-failure` does not
   fire — no auto-restart-fight (the bug an IPC-kill caused). **[int→REQ-DAEMON-6]**
5. Restore → `systemctl --user start` → `active` + `enabled`, daemon running.
   Live service left exactly as found.

## Notes

- REQ-DAEMON-7's elevated-`run`-refuses behavior is Windows-only (N/A on this
  rig); Linux `daemon run` is foreground by construction (the in-process
  privilege drop keeps it foreground), which the unit's `ExecStart` relies on.
- The internal `ensure_running` auto-start shares the exact `plan_start(false,
  detected) → ServiceStart → systemctl --user start` path proven in step 3; a
  dedicated CLI trigger was skipped to avoid mutating live node state.
