feat(node): add confirmed board shutdown with expiring commands

This commit is contained in:
DCCONSTRUCTIONS
2026-11-04 15:52:46 +03:00
parent f76928b606
commit ab8e977f11
21 changed files with 967 additions and 4 deletions
+53
View File
@@ -0,0 +1,53 @@
# Confirmed board shutdown
The operator opens the existing **Бортовой компьютер** settings window and
uses the canonical `power` header action beside move/close. The danger
confirmation names the board; cancelling or Escape sends no command. This
extends the existing window: a new fleet route or a terminal command form is
not needed. Disabled, pending, accepted, expired and OS failure states are
visible. An acknowledgement never claims proof that the host has powered off.
`POST /api/v1/fleet/{vehicle_id}/power/shutdown` is local-operator-only, takes
an expected process epoch and a request UUID, and accepts no command text.
`GET .../power` is no-store. Power support and its last receipt are bounded
latest state in RAM. There is no persistent command or historical telemetry.
Node advertises `missioncore.node-power/v1` and a random per-process epoch on
the existing authenticated heartbeat. Core requires a capability less than
12 seconds old. Commands are bound to the current pairing and expire after
20 seconds. Node rejects wrong epochs, bindings, methods and expired commands;
it records acceptance, then waits for the matching Core acknowledgement before
invoking the OS once. A lost ack expires without execution. Reconnection,
process restart and duplicate delivery cannot replay an old power-off.
Clocks must agree within the short command window; disagreement fails closed.
The fixed executor uses systemd-logind `PowerOff(false)` over the system bus
via `/usr/bin/busctl`. Capability discovery calls only `CanPowerOff`.
The installer-owned policy grants the `mission-core-node` account only
`org.freedesktop.login1.power-off` and `power-off-multiple-sessions`.
It grants neither reboot, arbitrary service control nor ignoring inhibitors.
See the [systemd interface](https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.login1.html).
Node112 is an incremental package over qualified Node111; the Node binary,
provenance and package version change, and one policy is added. Other driver
payloads and maintainer scripts remain byte-identical. The full builder includes
the same policy. Distribution profile stays Ubuntu 24.04 amd64. Removing the
package or installing the pinned Node111 rollback removes the package-owned
policy; operator/runtime data stays intact. Downgrade is an explicit installer
operation, never an automatic retry of shutdown.
Validation uses a fake OS executor for actual power-off. Live acceptance checks
the installed capability and opens/cancels the confirmation; it deliberately
does not shut down Rover006. Prepared-board acceptance does not claim a new
clean-image qualification. Detailed local evidence lives in
`outputs/board-power-20261104`.
The release launcher also resumes a power-interrupted, half-configured Node
package only when it is the same version carried by the release and the only
package needing configuration. Pending cache triggers for dbus,
desktop-file-utils, gnome-menus and hicolor-icon-theme are allowed; they remain
for the normal APT transaction. It runs
`dpkg --no-triggers --configure mission-core-node` under the existing
CAN maintenance barrier, then continues normal APT installation. It never runs
`dpkg --configure -a`, deletes locks or interrupts a package manager. Recovery
is installer-owned; a different version or another incomplete package stops it.