vm: Health folds a systemctl failure into "stopped" — the ADR 0129 seat read fabricates guest state #296

Closed
opened 2026-08-05 23:10:50 +00:00 by ben · 2 comments
Owner

Branch note: Health/Start/Stop and the seat read live on private-standup-polish (ADR 0129, unmerged). Actionable once that branch lands — or fold the fix into the branch itself.

internal/vm/manager.go:384-388 — Health treats any systemctl is-active error as "inactive": nil error either way, so Running (line ~418) can never return an error and Exists (line ~375) returns nil unconditionally. But a non-zero exit also happens when systemctl itself could not run (dbus down, permission denied) — the probe fault becomes a confident "stopped".

internal/founding/seat.go:70-76 guards on err == nil && running, but the fabrication happens a layer below, so the guard is moot; seat.go:42 promises "Every field is a read, never a fabrication (ADR 0100)". The operator home renders state: "stopped" for a guest that may be running — and the new Stop/Start row acts on that fabrication.

Acceptance

  • Health distinguishes "unit inactive" (a legitimate is-active non-zero exit) from "could not probe" (exec/permission/dbus failure) and propagates the latter.
  • The seat read renders an honest unknown/error state, never "stopped", when the probe failed.
  • Tests for both.

Filed from the 2026-08-05 fail-loud audit (three-agent pre-production sweep; findings verified against code).

**Branch note: `Health`/`Start`/`Stop` and the seat read live on `private-standup-polish` (ADR 0129, unmerged). Actionable once that branch lands — or fold the fix into the branch itself.** `internal/vm/manager.go:384-388` — `Health` treats any `systemctl is-active` error as "inactive": nil error either way, so `Running` (line ~418) can never return an error and `Exists` (line ~375) returns nil unconditionally. But a non-zero exit also happens when systemctl itself could not run (dbus down, permission denied) — the probe fault becomes a confident "stopped". `internal/founding/seat.go:70-76` guards on `err == nil && running`, but the fabrication happens a layer below, so the guard is moot; seat.go:42 promises "Every field is a read, never a fabrication (ADR 0100)". The operator home renders `state: "stopped"` for a guest that may be running — and the new Stop/Start row acts on that fabrication. **Acceptance** - `Health` distinguishes "unit inactive" (a legitimate is-active non-zero exit) from "could not probe" (exec/permission/dbus failure) and propagates the latter. - The seat read renders an honest unknown/error state, never "stopped", when the probe failed. - Tests for both. --- _Filed from the 2026-08-05 fail-loud audit (three-agent pre-production sweep; findings verified against code)._
Author
Owner

This was generated by AI during triage.

Agent Brief

Category: bug
Summary: vm.Manager.Health folds any systemctl is-active probe failure into a confident "stopped", so a probe fault (dbus down, permission denied, binary missing) is indistinguishable from a genuinely inactive unit.

Verification: Confirmed on main, independent of the branch note in the body. Health is live production code today, wired into the heartbeat's VM section (enroll.VMHealth) — this isn't gated on the ADR 0129 (private-standup-polish) branch landing. The body's exact line numbers have drifted (the function is shorter and lives earlier in the file now), but the described defect is exactly reproducible: Health runs systemctl is-active, then computes running := err == nil && output == "active" and returns VMHealth{Running: false}, nil whenever running is false — collapsing "confirmed inactive" and "could not probe" into the same honest-looking false with no error.

One correction to the original report: internal/founding/seat.go does not currently guard on VM health at all — the seat model on main only carries operator-posture kind + community, no VM/running field. That part of the report, and its second acceptance bullet, belongs to the still-unmerged ADR 0129 arc. Scoping this brief to what's actually true on main today.

Current behavior:
Health reports Running: false with a nil error both when the unit is cleanly confirmed inactive (a legitimate non-zero is-active exit) and when the probe itself failed to run (exec error, permission denied, dbus unavailable, etc.). Callers cannot tell "the guest is stopped" from "we don't actually know."

Desired behavior:
Health distinguishes the two cases: a clean, legitimate "inactive" read still returns Running: false, err: nil. A probe failure (the systemctl invocation itself erroring for a reason other than a clean non-active exit code) returns a non-nil error instead of a confident Running: false.

Key interfaces:

  • vm.Manager.Health(ctx) (enroll.VMHealth, error) — the return contract changes from "always nil error" to "nil error only on a legitimate read (active or cleanly inactive), non-nil error when the probe itself couldn't be trusted."

Acceptance criteria:

  • A clean is-active non-zero exit (unit genuinely inactive) still returns Running: false with a nil error.
  • A probe failure (e.g. the systemctl invocation errors for a reason other than a clean inactive exit — exec error, permission denied, dbus unavailable) returns a non-nil error rather than a confident Running: false.
  • Tests cover both the clean-inactive and probe-failure cases.

Out of scope (belongs to the still-unmerged ADR 0129 arc, not on main):

  • Any change to internal/founding/seat.go or the seat model — it doesn't consume VM health today.
  • Any Operator-home UI rendering of an unknown/error state.
> *This was generated by AI during triage.* ## Agent Brief **Category:** bug **Summary:** `vm.Manager.Health` folds any `systemctl is-active` probe failure into a confident "stopped", so a probe fault (dbus down, permission denied, binary missing) is indistinguishable from a genuinely inactive unit. **Verification:** Confirmed on `main`, independent of the branch note in the body. `Health` is live production code today, wired into the heartbeat's VM section (`enroll.VMHealth`) — this isn't gated on the ADR 0129 (`private-standup-polish`) branch landing. The body's exact line numbers have drifted (the function is shorter and lives earlier in the file now), but the described defect is exactly reproducible: `Health` runs `systemctl is-active`, then computes `running := err == nil && output == "active"` and returns `VMHealth{Running: false}, nil` whenever `running` is false — collapsing "confirmed inactive" and "could not probe" into the same honest-looking false with no error. One correction to the original report: `internal/founding/seat.go` does **not** currently guard on VM health at all — the seat model on `main` only carries operator-posture `kind` + `community`, no VM/running field. That part of the report, and its second acceptance bullet, belongs to the still-unmerged ADR 0129 arc. Scoping this brief to what's actually true on `main` today. **Current behavior:** `Health` reports `Running: false` with a `nil` error both when the unit is cleanly confirmed inactive (a legitimate non-zero `is-active` exit) and when the probe itself failed to run (exec error, permission denied, dbus unavailable, etc.). Callers cannot tell "the guest is stopped" from "we don't actually know." **Desired behavior:** `Health` distinguishes the two cases: a clean, legitimate "inactive" read still returns `Running: false, err: nil`. A probe failure (the `systemctl` invocation itself erroring for a reason other than a clean non-active exit code) returns a non-nil error instead of a confident `Running: false`. **Key interfaces:** - `vm.Manager.Health(ctx) (enroll.VMHealth, error)` — the return contract changes from "always nil error" to "nil error only on a legitimate read (active or cleanly inactive), non-nil error when the probe itself couldn't be trusted." **Acceptance criteria:** - [ ] A clean `is-active` non-zero exit (unit genuinely inactive) still returns `Running: false` with a `nil` error. - [ ] A probe failure (e.g. the `systemctl` invocation errors for a reason other than a clean inactive exit — exec error, permission denied, dbus unavailable) returns a non-nil error rather than a confident `Running: false`. - [ ] Tests cover both the clean-inactive and probe-failure cases. **Out of scope (belongs to the still-unmerged ADR 0129 arc, not on `main`):** - Any change to `internal/founding/seat.go` or the seat model — it doesn't consume VM health today. - Any Operator-home UI rendering of an unknown/error state.
Author
Owner

Fixed in c18e837 (on origin/main).

vm.Manager.Health (internal/vm/manager.go) folded any systemctl is-active error into VMHealth{Running: false}, nil, so a probe fault (dbus down, permission denied, systemctl missing) was indistinguishable from a genuinely inactive unit — the heartbeat carried a fabricated "stopped".

Health now classifies on the is-active OUTPUT, not the error: a recognized systemd ActiveState word is an honest read (active/reloading → running; inactive/failed/activating/deactivating/maintenance → cleanly not-running) even on the clean exit-3, while unrecognized output (unknown, an error message, empty) is a probe fault that propagates a non-nil error. join.Orchestrator.Heartbeat already returns on a Health error, so a probe fault now fails loud rather than reporting a made-up state.

Red-first seam tests: TestHealthCleanInactiveIsHonestNotRunning (recognized states over a non-zero exit still read not-running with a nil error) and TestHealthProbeFaultPropagates (dbus/permission/exec faults error, never Running:true).

Scoped per the triage brief to Health on main; seat.go / Operator-home unknown-state rendering belongs to the still-unmerged ADR 0129 arc (out of scope, not on main). go build/go vet/go test ./... green.

Fixed in c18e837 (on origin/main). `vm.Manager.Health` (`internal/vm/manager.go`) folded any `systemctl is-active` error into `VMHealth{Running: false}, nil`, so a probe fault (dbus down, permission denied, systemctl missing) was indistinguishable from a genuinely inactive unit — the heartbeat carried a fabricated "stopped". Health now classifies on the `is-active` OUTPUT, not the error: a recognized systemd ActiveState word is an honest read (`active`/`reloading` → running; `inactive`/`failed`/`activating`/`deactivating`/`maintenance` → cleanly not-running) even on the clean exit-3, while unrecognized output (`unknown`, an error message, empty) is a probe fault that propagates a non-nil error. `join.Orchestrator.Heartbeat` already returns on a Health error, so a probe fault now fails loud rather than reporting a made-up state. Red-first seam tests: `TestHealthCleanInactiveIsHonestNotRunning` (recognized states over a non-zero exit still read not-running with a nil error) and `TestHealthProbeFaultPropagates` (dbus/permission/exec faults error, never `Running:true`). Scoped per the triage brief to Health on `main`; `seat.go` / Operator-home unknown-state rendering belongs to the still-unmerged ADR 0129 arc (out of scope, not on `main`). `go build`/`go vet`/`go test ./...` green.
ben closed this issue 2026-08-06 04:18:10 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#296
No description provided.