When miren restarts (e.g. systemd service restart) while buildkitd is already
running as a containerd-managed container, `restartExistingContainer()` detects
the Running container, sets `c.running = true`, and reuses it — only dialing
the socket to confirm readiness. It does not restart the buildkitd process.
buildkitd's in-process HTTP/2 session server is bound to the calling miren
process. After miren restarts, buildkitd can no longer reconnect to it, so any
in-flight or new jobs are expunged: `NotFound: no such job <ref>`.
This is silent — no error is returned and no log is emitted. All subsequent
builds fail until buildkitd is manually killed and miren restarted.
KillMode=process in the systemd unit means containerd-managed buildkitd
intentionally survives miren crashes/timeouts, making this trigger readily.
## Affected surface
- components/buildkit/buildkit.go — restartExistingContainer()
- servers/build/build_saga_buildkit.go — Info() health check silently ignored
- cli/commands/server_install.go — systemd unit has no ExecStopPost to evict buildkitd
## Fix (ready)
Six files changed — patch in workspace runtime-stale-buildkitd-fix/change.patch:
1. restartExistingContainer() force-stops the existing container before creating a fresh task
2. stopTask() early-return bug fixed; task.Delete() always called even on failed SIGTERM
3. Exit-monitor goroutine via task.Wait() clears c.running on unexpected buildkitd death
4. bkc.Info() made a fatal pre-flight check (returns error immediately)
5. ExecStopPost added to systemd unit to evict buildkitd via ctr at OS level
6. Tests: BuildKitProvider interface + unit tests + integration-gated subtests
## Incident
Triggered 2026-06-30 on luanchat cluster (Hetzner, single-node). miren.service
restarted at 12:49 UTC; buildkitd had been up ~3 days. All builds failed until
manual kill + restart at ~15:xx UTC.