Skip to content

[Feature] Appliance: reboot and power off from the dashboard #2384

Closed

Description

@VijitSingh97

What's the problem

An appliance operator has no host shell, so the dashboard is the whole control surface. Its only reboot is os-reboot, which refuses unless an installed A/B update is waiting, and there is no clean shutdown at all. Three dead ends follow:

  1. The media-config channel is documented as reading only at boot, so a headless operator must reboot a box they cannot reboot.
  2. Moving the machine means pulling power on a running miner, which os/KNOWN-ISSUES.md records as what breaks A/B and data state.
  3. A wedged-but-reachable stack has no next step short of a site visit.

This is a gap in the #786 host-CLI inventory, not a duplicate of it. The lean UI spec (#3566, closed) settles placement: Reboot and Power off live in Advanced > Maintenance (#2540), appliance only. The earlier plan to mount them in the old dashboard header is dropped and no work goes into the old UI.

What it impacts

Appliance operators, who gain a safe reboot and a clean power off from the dashboard. DIY users are unaffected: the host has a shell, so both controls are hidden there. Touches the host control verbs, the dashboard control route, the Maintenance section of #2540, docs/appliance.md, os/KNOWN-ISSUES.md and the KVM battery.

How I found it

From the original report and the operator's 2026-09-23 investigation brief, which confirmed on develop that the only dashboard reboot verb is control_os_reboot in lib/pithead/48-os-update-verbs.sh, gated on an in-flight update, and that no poweroff verb exists. A prior implementation, PR #2449, was closed unmerged on 2026-10-16 (stale and conflicting; the owner said to reuse its backend for the maintenance view). Its branch is kept at f5df025fbeb4c3981b49260650f48fdb76fc5a02. The tier4-kvm run on that head (log 840) passed all six power rows: reboot ordered, dashboard back, poweroff ordered, guest returns on the power button, orderly stop, mining resumed. No tier4-e2e run completed on it. PR #2434 (#2385, merged) added "Reboot now?" to the OS update flow and uses os-reboot; it does not provide this.

Still open: #2513 (shell, PR #3584) and #2540 (PR #3708), neither in develop-v2.1.0. Not confirmed: that the preserved backend applies cleanly to current develop-v2.1.0 control contracts. The media-config sentence has moved lines more than once; find it by text in docs/appliance.md.

How important is it

Medium: lean roadmap P3, in v2.1.0, not a release blocker. The workaround today is a physical power cycle, which risks A/B and data state. It carries security because sys-poweroff is the first control-channel lever whose effect cannot be undone remotely. That trade-off is accepted: it is an availability escalation only, reaching no credential, payout destination or security toggle, and the typed confirmation is not a security control against a compromised container. Blocked on #2513 and #2540.

Acceptance criteria

Host and API

  • sys-reboot and sys-poweroff exist as control-channel verbs with no new config key gating either. Off an appliance, or with the control channel off, both are refused and the captured power-order log is empty.
  • The verb only selects between two fixed orders (systemctl reboot, systemctl poweroff); no container-supplied string reaches a command line. A drift-guard test fails when the shell dispatch and the dashboard action allowlist differ.
  • The result file and an audit line (id, actor, action) are written before the order; a test asserts that ordering.
  • One power verb per drain; a second in the same drain is rejected with a retry hint. A second order inside the cooldown (5 minutes on the preserved branch) is refused with nothing ordered, and the check fails closed if the clock steps backwards.
  • POST /api/control/power rejects a missing X-Pithead-Control header, a non-JSON body (400) and an action outside {reboot, poweroff} (400, before the spool); a valid request returns 202 and spools sys-reboot or sys-poweroff with the actor from X-Auth-User.

UI (Advanced > Maintenance, #2540, per #3566 sections A, G and J)

  • Reboot and Power off render only on the appliance with control enabled, and never on DIY with or without a login (one fixture per platform). They are not counted controls; the control-count fixture test still passes.
  • Each button stays disabled until the exact word REBOOT or POWEROFF is typed; the POST body matches the route contract.
  • After reboot the page reconnects. After power off the copy says the dashboard will not return until someone presses the physical power button, and no reconnect poll starts.
  • Keyboard reachable, no horizontal scroll at 375 px, AA contrast in light and dark.

Proof

  • A tier4-kvm job on the final head, provision phase, with conclusion quoted: the dashboard-ordered reboot returns unaided; the dashboard-ordered power off reaches shut off on its own, the next boot shows an orderly stop of the compose units, and mining resumes. The new KVM leg has a --self-test driven from tier 1.
  • A tier4-e2e job on the head that built and deployed the change, conclusion quoted.
  • docs/dev/manual-release-checklist.md gains one step: power off from the dashboard, press the physical button, confirm boot and mining unaided (KVM cannot prove this).
  • Tiers 2 and 3 are deliberately omitted, stated in the PR. The host-side verbs pass the repository security review.

Docs and hygiene

  • The docs/appliance.md media-config sentence no longer leaves a headless operator with only a power cut; it points to Reboot in Maintenance and says power off needs the physical button to return.
  • docs/dashboard.md, CHANGELOG.md and the Appliance feature parity: everything host-CLI-only is impossible on a shell-less box #786 inventory in os/KNOWN-ISSUES.md list the power controls; the existing verb inventory in lib/pithead/42-control-policy-and-host-checks.sh still matches the dispatch.
  • No explanatory source comments. make test, make test-patch-coverage, make lint-pithead-build, make lint-file-budget and make test-inventory pass.

Possible solutions

  • Re-apply the backend from the preserved branch on current develop-v2.1.0 rather than merging the stale branch: a small 46b-control-power.sh slice dispatched from the control request loop, is_appliance as the gate, the route modelled on handle_control_os_update, and the KVM leg with a _poweroff_wait. Drop its old-header UI and mount the two controls in Maintenance once Sovereign: build navigation, page headers and persistent status #2513 and Sovereign: build maintenance health and contextual troubleshooting #2540 land. The host and API half can be built ahead of the UI.
  • Keep os-reboot unchanged: its 24-hour TTL and pending-update gate bound that lever, and the OS update UI reads its state from the same flag.
  • A hardware watchdog is orthogonal: it covers a hang, not an operator who wants the box off.
  • Reboot only, without power off, was considered; both ship by earlier decision.
Earlier scope, kept as evidence only (superseded 2026-10-27; do not implement from it)

What's the problem

Problem / motivation

An appliance operator has no host shell (lib/pithead/42-control-policy-and-host-checks.sh:117),
so the dashboard is the whole control surface. It can reboot the box in exactly one situation:
os-reboot, and only while an installed A/B update is waiting
(lib/pithead/48-os-update-verbs.sh:336 refuses when the in-flight flag is absent). There is no
plain reboot and no clean shutdown at all.

Three concrete dead ends today:

  1. The media-config channel is documented as needing a reboot the operator cannot perform.
    docs/appliance.md:582 — "this channel only reads at boot. Inserting the stick into a running
    machine does nothing until you reboot it." On a headless appliance in a cupboard, the only
    way to act on that sentence is a physical power cycle.
  2. Moving or unplugging the machine means pulling power on a running box. An operator who
    needs to physically relocate the appliance — a new shelf, a different room, a house move — has
    no way to stop it cleanly first. os/KNOWN-ISSUES.md records that mid-write power cuts are
    precisely what breaks the A/B/data state (lines ~107-115); the product tells operators to cut
    power because it offers no way not to. A clean shutdown followed by a press of the physical
    power button is a complete round trip: the machine boots back up on its own
    (pithead-boot owns unaided recovery, proved by tests/os/phases/provision-reboot.sh).
  3. A wedged-but-reachable stack (dashboard up, stack sick, restart/apply not enough) has no
    next step short of a site visit.

This is the same class as #786 ("part of the host-CLI surface is still unreachable on the
appliance"), which os/KNOWN-ISSUES.md tracks along with its fast-follows. Power control was
never enumerated there — it is a gap in that inventory, not a duplicate of it.

How this gets tested

Per docs/dev/testing-strategy.md, each situation is proved at the lowest tier that is honest.
This change touches the control plane and appliance behaviour, so the "What a PR must prove" table
puts it in the tier4-kvm row — tiers 1-3 alone are not sufficient proof for merge.

Tier 1 — shell (tests/stack/)

New domain fragment tests/stack/control/test-control-power-verbs.sh, with its source stanza added
to the explicit ordered list in tests/stack/run.sh (a fragment, not a script: it opens with the
STACK_SUITE marker check like every sibling). Build it on the sandbox pattern in
tests/stack/appliance/test-appliance-os-update-verbs.sh — control channel on, PITHEAD_APPLIANCE
forced, the power order captured through the PITHEAD_REBOOT_CMD-style seam (or a stubbed
systemctl, as the OS-update domain does today), requests driven through the real spool.
Assertions:

  • off-appliance (PITHEAD_APPLIANCE=0) → rejected, and the order log is empty — the assertion
    that matters is that nothing was ordered, not that a message was printed;
  • control channel disabled → refused by control_run_pending's existing gate;
  • the order log contains exactly one order, and it is the right one for the verb;
  • the result file exists and the audit line carries id/actor/action before the order —
    assert ordering, not just presence;
  • a second power verb in the same drain is rejected with the retry hint (budget);
  • a malformed/unknown action still falls through to the case's unknown action branch.

Tier 1 — Python (dashboard/tests/web/)

Mirror dashboard/tests/web/test_server_control_routes_enabled.py and
dashboard/tests/service/test_request_spool.py: missing X-Pithead-Control rejected; non-JSON body
400; action outside the frozenset 400 before anything reaches the spool; a good request → 202 and a
spool file whose action is sys-reboot/sys-poweroff with the actor taken from X-Auth-User.
make test-patch-coverage (90% changed-line) applies.

Tier 1 — frontend (dashboard/tests/frontend/system/)

New power.test.mjs beside osupdate.test.mjs: renders nothing when state.os_update is absent
(non-appliance) or control_enabled is false; the button stays disabled until the exact confirm
word is typed; the POST body matches the route's contract; the poweroff branch renders copy that names the
physical power button as the way back and does not start the reconnect poll.

Drift guard. The action set now lives in two places (the shell case and the Python frozenset).
Pin it the way tests/stack/control/test-control-editable-allowlist.sh pins the editable keys, so a
verb added on one side and not the other goes red instead of silently 400ing or being rejected
host-side.

Tiers 2 and 3 — deliberately nothing. Tier 2 is real daemon wire formats; tier 3 is containers
being stopped and started by the control plane. Neither is what this change is about, and the
strategy doc asks for the omission to be stated rather than silently skipped.

Tier 4 — KVM (tests/os/)

The irreducibly-real part: that the box actually goes down and comes back, cleanly.

  • New leg tests/os/appliance-power-leg.sh, following tests/os/appliance-diagnostics-leg.sh,
    carrying a --self-test driven from tier 1 by tests/stack/test-harness-tooling.sh — the
    convention every leg in this suite follows, so the leg's own logic is provable without a KVM.
  • Reboot folds into tests/os/phases/provision-reboot.sh, which already reboots and proves an
    unaided return via _reboot_wait (tests/os/lib/core.sh:113). The new assertion is that the
    reboot was ordered through the dashboard control channel and that the stack returns unaided
    afterwards — same bar as the existing leg.
  • Poweroff needs the one genuinely new piece of harness: a _poweroff_wait beside
    _reboot_wait, built from primitives the harness already uses — poll virsh domstate "$VM" to
    shut off within a deadline, then virsh start and reuse _wait_ssh. Assert the guest reached
    shut off on its own (not destroyed), that the next boot shows an orderly stop of the
    compose units in the journal rather than a dirty mount, and that mining resumes.
  • What KVM cannot prove. The battery shows the software ordered a clean shutdown and the
    guest reached shut off by itself. It does not show that pressing the physical power button
    brings the machine back — that is firmware behaviour on real hardware, and
    os/KNOWN-ISSUES.md already says a VM cannot stand in for it. Add one step to
    docs/dev/manual-release-checklist.md beside the existing M-series: power the appliance off
    from the dashboard, press the button, confirm it boots and resumes mining unaided. Without that
    step the round trip this issue promises operators is only half-proved.
  • Recent history says to watch the interaction with the battery itself: a53ee97
    ("keep the battery from interrupting control requests") is the precedent for a phase whose power
    behaviour races the control runner.

Repo gates. make test (lint, dashboard 80% total, frontend, CLI, compose, integration
selftests, fake-daemon contracts), then make test-patch-coverage; make to regenerate the CLI
plus make lint-pithead-build for slice ordering; make lint-file-budget;
make test-inventory (the count moves up — a lower count would need explaining).

Docs. docs/appliance.md (the operator-facing surface, and the :582 sentence that currently
describes an impossible instruction), docs/dashboard.md, CHANGELOG.md, and the verb inventory
comment in lib/pithead/42-control-policy-and-host-checks.sh.

what it impacts

Scope ruling: both verbs ship

Decided — sys-reboot and sys-poweroff both ship, with no new config key gating either.

The motivating case for poweroff is physical: the operator is moving the machine. In that case
they are standing at the box anyway, so "you must press the power button to bring it back" is not
a cost — it is the same trip they were already making. The alternative the product offers today is
pulling the cord on a live miner, which os/KNOWN-ISSUES.md documents as the thing that actually
corrupts A/B and data state.

Recorded trade-off, not an open question. sys-poweroff is still the first control-channel
lever whose effect cannot be undone remotely, and the threat model in
lib/pithead/42-control-policy-and-host-checks.sh is explicit that the typed-confirm modal is
not a security control — a compromised container writes the request spool directly and never
renders the modal. A compromised dashboard already holds restart, apply and os-install, so it
can already stop mining; what poweroff adds is that recovery needs a person at the machine. That is
an availability escalation and nothing more: it reaches no credential, no payout destination and no
security toggle, and it cannot be laundered into a config change. Accepted on that basis. Anyone
revisiting this should re-read that file's header first rather than reasoning by analogy from the
os-* verbs.

How I found it

Discovery details are not separately established in the existing report; preserve and verify the evidence already recorded.

how important is it

Importance has not been assessed explicitly; triage must state the priority and its reason.

acceptance criteria

Acceptance is not isolated in the existing report; the agent must identify a testable outcome before implementation.

possible solutions

Proposed solution

Two new control-channel verbs, sys-reboot and sys-poweroff, following the shape of the
existing os-* and diag-* verbs rather than inventing a mechanism.

Host runner — new function beside the OS verbs (or a small 46b-control-power.sh slice, so
lib/pithead/48-os-update-verbs.sh does not grow), dispatched from the case in
lib/pithead/49-control-request-loop.sh:41-60:

  • Refuse off-appliance via is_appliance (lib/pithead/10-installer-preseed.sh:123), the same
    door control_os_gate uses. A Compose install has a host shell and does not need this.
  • Write the result and audit line before issuing the order — the ordering
    control_os_reboot already relies on (48-os-update-verbs.sh:360-363), otherwise the page never
    learns the order was accepted.
  • One power verb per drain, like CONTROL_OS_BUDGET.
  • systemctl reboot / systemctl poweroff. No string from the container reaches a command line;
    the action name only selects between two hardcoded orders, per this channel's standing rule.
    Reuse the existing test seam rather than inventing one: lib/pithead/16-reset.sh:83 already
    dispatches through ${PITHEAD_REBOOT_CMD:-systemctl reboot}, so tier 1 can observe the order
    without stubbing systemctl on $PATH. Neither order is new to the product —
    lib/pithead/12-firstboot-wizard.sh:52 already calls systemctl poweroff at the end of an
    install (os/KNOWN-ISSUES.md:183).
  • Update the verb inventory comment at the top of 42-control-policy-and-host-checks.sh, which
    states it must match the dispatching case.

Dashboard — POST /api/control/power in dashboard/mining_dashboard/web/server.py, modelled
directly on handle_control_os_update (server.py:227-258): a frozenset {"reboot", "poweroff"},
_require_control_header (server.py:131), control_service.submit(f"sys-{action}", actor=...),
202 + poll /api/control/result. Registered next to the other control routes at server.py:619.

UI — a small control in web/static/system/, mounted from app/header.mjs behind the same
appliance = !!state.os_update gate the OS-update control already uses (header.mjs:12,32-36) and
the existing state.control_enabled flag. Reuse the typed-confirm modal pattern from
system/osupdate.mjs:324-336 (type REBOOT / POWEROFF). Reboot reuses reconnect()
(osupdate.mjs:268-281); poweroff must not — it has to say plainly that the dashboard is not
coming back, and that the machine restarts when someone presses its physical power button. An
operator who reads "powering off" and then waits for a reconnect that never arrives will assume
they bricked it.

Alternatives considered

  • Widen os-reboot to work without a pending update. Rejected: its 24-hour TTL and in-flight
    gate exist to bound how long that lever stays armed, and the OS-update UI reads its state machine
    from the same flag. A separate verb keeps both meanings intact.
  • A hardware watchdog instead. Already present and orthogonal (docs/appliance.md:326) — it
    covers a hang, not an operator who wants the machine off.
  • Reboot only, no poweroff. A real option; see the decision section above.

Activity

  1. added this to the v2 - appliance milestone on Sep 19, 2026
  2. added
    enhancement
    dashboard
    security
    appliance
    on Sep 19, 2026
  3. pithead-developer commented on Sep 19, 2026

    @pithead-developer
    Contributor

    Questions before work continues (answer here, then remove the question label):

    The worker stopped without a result (error, success). Branch agent/2384-feature-appliance-reboot-and-power-off-f holds what it had. Raise the cap, split the issue, or take it over.

  4. added
    question
    on Sep 19, 2026
  5. pithead-architect commented on Sep 19, 2026

    @pithead-architect

    Ruling: Neither cap, split nor takeover. No worker ran: the Claude plan refused the session at 06:31Z with "You've hit your session limit · resets 2:10am (America/Chicago)", one turn, zero tokens, 0.00 USD, and the branch is untouched. Pick the issue up as freshly handed. Build the two verbs in the shape the issue proposes, following the existing os-* and diag-* verbs in 48-os-update-verbs.sh and the same approval gate the disruptive verbs use; add the row to os/KNOWN-ISSUES.md's inventory and the operator doc line at docs/appliance.md:582 so the media-config channel no longer tells a headless operator to pull power. The proof is a tier4-kvm job on the head in which the dashboard-driven reboot comes back on its own and the poweroff halts cleanly, conclusion quoted. Take your defaults, list them under "Decisions taken", and return only for a product decision.

  6. removed
    question
    on Sep 19, 2026
  7. pithead-developer commented on Sep 19, 2026

    @pithead-developer
    Contributor

    Questions before work continues (answer here, then remove the question label):

    I ran out of session budget (~$8) partway through the CI/PR/bench pipeline for this large issue, with a complete but uncommitted local diff. Locally verified so far: make, make lint-file-budget, make lint-pithead-build all pass; shellcheck clean on every changed/new shell file; ruff check+format clean on the two Python files; biome clean on the two JS files; all new tier-1 tests pass (12 pytest cases including the drift guard, 9 node --test cases, and the new shell fragment sanity-checked via a full untrusted-macOS tests/stack/run.sh run showing no new failures beyond the documented macOS baseline noise). NOT yet done: git commit, push, opening the draft PR, running the ponytail-review pass required before PR creation, submitting the tier4-kvm bench-ci job (bench-ci is inaccessible from this budget-exhausted session), running the verifier/security-reviewer subagents, and re-checking dashboard/tests patch coverage (90% changed-line) and make test end-to-end (blocked on this Mac anyway per repo rules — needs bench-ci). Default I'd take with more budget/turns: resume this exact session, commit the diff, push, open the draft PR, run ponytail-review, submit a tier4-kvm job scoped to the provision phase (which now carries the new dashboard-driven reboot+poweroff assertions), wait for it, then run verifier/security-reviewer and iterate to a clean PASS before reporting done. Is that the right way to proceed, or should this be split/handed to a fresh worker session instead given how much of the $8 this single issue consumed?

  8. added
    question
    on Sep 19, 2026
  9. pithead-architect commented on Sep 19, 2026

    @pithead-architect

    Ruling: Resume in place, no split; the work is one surface and splitting it now would cost more than finishing. In order: commit the verified diff and push the branch before anything else, open the draft PR, run the review pass, then submit tier4-kvm phases:[provision] at the pushed head and return waiting with it in bench_jobs; the verifier and security-reviewer passes run while the job queues, and their findings are fixed on the branch with the job resubmitted only if the fix touches what the provision phase deploys. Two constraints: PR #2434 belongs to #2385 and is not this branch, so nothing from it is merged in or duplicated here, and if #2385's Reboot-now flow needs your sys-reboot verb, say so in your PR body and let that PR rebase on yours after merge. A sys-poweroff that leaves the box needing the physical button is the accepted design per the issue; document it in docs/appliance.md next to the media-config sentence the issue quotes.

  10. removed
    question
    on Sep 19, 2026
  11. 53 remaining items

  12. pithead-developer commented on Nov 2, 2026

    @pithead-developer
    Contributor

    Blocked on #3844. The required check "Container bridge awk portability (Debian 12)" fails at head ebc080c and is not caused by this PR. It fails in the same step with the same exit code 2 as the earlier head, where the log read "Bridge awk: 45 passed, 0 failed" followed by "make: *** [Makefile:75: test-bridge-awk] Error 1". I could not read the log for the current head's run because it was still in progress. The cause is a stale hard-coded pass count in the base's tests/stack/standalone/test_bridge_awk.sh after #3715, tracked in #3844 and fixed by open PR #3845 (mergeable). This PR does not touch that file, and I will not fold in another issue's change. Finished: the power route, host verbs, lean UI mount and KVM leg. Provision job 3323 and the base control 3324 are green; e2e job 3325 has one red, the pool-history row owned by #3819. Both review rounds are addressed, and I commented the blocker on PR #3780. Once #3845 merges, merge the base into this branch, confirm the checks, and report done.

    The runner resumes this issue when that one closes.

  13. added
    blocked
    on Nov 2, 2026
  14. removed
    blocked
    on Nov 2, 2026
  15. pithead-developer commented on Nov 2, 2026

    @pithead-developer
    Contributor

    Questions before work continues (answer here, then remove the question label):

    The worker reported done but no PR exists for branch agent/2384-feature-appliance-reboot-and-power-off-f. PR #3780 for #2384 is merged into develop-v2.1.0. The final head was a99cdde. The round-3 reviewer passed that head and the adversarial-review status is green. I checked only the PR state and its listed checks. I made no further changes this session.

  16. added
    question
    on Nov 2, 2026
  17. pithead-architect commented on Nov 2, 2026

    @pithead-architect

    Ruling: #2384 is done. Close it as completed by PR #3780. That PR merged into develop-v2.1.0 at 2026-11-02T17:41:28Z as squash commit 457f0de. Its final head, a99cdde, is the one the round-3 adversarial review passed, so the gate holds on the merged head. The issue stayed open for a mechanical reason. GitHub fills closingIssuesReferences only for PRs into the default branch, so for develop-v2.1.0 the runner reads closing lines from the PR body. It counts a closing keyword only at the start of a line. PR #3780 has Closes #2384. at the end of the first paragraph, so the merged-PR sweep never matched it. That is why the worker came back with "done, no PR". Do not start another worker session, open a new PR or push again. The milestone stays v2.1.0. The other red rows found along the way already have their own issues: the migration/floor fallback evidence on #3674 and the pool-history failure on #3819. Under the row-scoped evidence rule they do not hold #2384 open. For future PRs into an integration branch, put Closes #N on a line of its own so the runner closes the issue at merge.

  18. removed
    question
    on Nov 2, 2026
  19. pithead-developer commented on Nov 2, 2026

    @pithead-developer
    Contributor

    Completed by #3780, which merged into develop-v2.1.0 as squash commit 457f0de. The round-3 adversarial review passed its final head, a99cdde. The issue stayed open because the PR's closing line was not on a line of its own, so the integration-branch sweep did not match it. The other red rows found during proof already have their own issues: the migration and floor fallback evidence is on #3674, and the pool-history failure is #3819.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appliancedashboardenhancementsecurity

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions