Skip to content

feat(ui): Add staff power control to Device page - #191

Merged
scotwells merged 10 commits into
feat/manual-inventory-recordsfrom
feat/device-power-ui
Nov 29, 2026
Merged

scotwells merged 10 commits into
feat/manual-inventory-recordsfrom
feat/device-power-ui

Conversation

@scotwells

@scotwells scotwells commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Adds staff power requests and an Operations tab to the Device page. The diff against feat/manual-inventory-records is limited to UI, fixtures, tests and documentation; staging's discovery, custody, RBAC, admission and site worker are unchanged.

The control offers only explicitly observed reset actions on the matching system, requires a reason, and confirms destructive actions by server name. The request uses the authenticated username plus UID when supplied. A session check holds dispatch; a lost create response is unknown and is never automatically retried. Recovery holds block ordinary requests; this page does not authorize recovery or retries.

Synthetic verification

  • Provider: typecheck, 1,057 tests, production build. Consumer: typecheck, 72 tests, production build.
  • 10 fixture captures cover the header, dialog, history and held device, including all four at 390 px. No horizontal overflow or API calls in the fixture preview.
  • Local documentation links and diff whitespace passed. No live power commands or acceptance runs.

@scotwells
scotwells requested review from ecv and kevwilliams November 25, 2026 15:59
@scotwells
scotwells force-pushed the feat/device-power-kind branch from c036142 to f93a539 Compare November 25, 2026 17:44
@scotwells
scotwells force-pushed the feat/device-power-ui branch from 662d262 to 4325eb9 Compare November 25, 2026 18:24
scotwells and others added 5 commits November 25, 2026 18:44
Power admission reads which ComputerSystem.Reset types each System
offers. This adds that field to the observed System in Device status,
in the Go type and the CRD schema, so the power kind compiles and its
tests can record the field.

Nothing writes it here: BMC discovery starts recording it in a
separate change. Until then the field is absent and power refuses
every action as not offered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TestAddingRowsLeavesExistingRowsAlone compared rows with
reflect.DeepEqual, which never finds two non-nil functions equal. A
row that sets its own Name rule, the per-row naming seam, therefore
failed the test even when nothing changed. Compare Name by identity
and the rest of the row as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Power is the first real kind on the custody foundation. Staff and the
Fleet provider for Metal can request one power action, and the
coordinator decides whether it may run, without any change to the
coordinator itself.

The kind registers its inputs and their digest, an 8-minute deadline,
and the two power rows of the operations table. Staff rows use the
kind's generated names; the provider row names its operations from
the allocation and the Machine generation. Only an operation the
provider row admits replaces an older pending one for its allocation.

Its admission checks refuse a staff request for a Device with no
recorded system UUID or a different one, discovery that did not read
the current BMC within twice the discovery interval, and an action the
BMC does not offer, each with a declared reason. The snapshot records
what the reset-type check read.

A power success settles only a power hold, after a Retry. A Settle
needs discovery read after the operation ended, at the current BMC
endpoint, showing On or Off. Result evidence is typed and bounded in
the CRD, required for a success, and checked against the action.

A staff power operator role creates only power operations and does not
read allocations; a power requester role is the provider's. Nothing
wires the kind into a root, and no worker runs it.

Implements step P1 of #173 on #174's foundation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The custody guide gains a short power section: what P1 implements and
leaves inert, and the decisions behind its inputs, names, rows, checks,
replacement, settle rule, evidence and roles. It lists two places where
the foundation still does not fit power: a kind check cannot make a
queued operation wait, and the evidence hook does not see the result's
phase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cutover ships the device-operations component in the Milo roots and
its CRDs in standalone, so the power kind now ships with them. Each
place that names the operation kinds must name power too, or a power
operation's creator goes unchecked and the coordinator cannot list the
kind it registers.

The creator webhook and standalone's creator policy now govern
DevicePowerOperation. The standalone and multi-plane coordinators may
read, delete and update the status of power operations, and the
multi-plane harness reads them with the other custody records. The
standalone smoke expects the CRD fresh and refuses consumer access to
it.

TestEveryOperationKindIsGoverned requires the webhook's resource list,
the packaged webhook and the standalone policy to name every operation
kind the CRDs define.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the feat/device-power-kind branch from f93a539 to c6dcaa8 Compare November 26, 2026 00:55
scotwells and others added 2 commits November 25, 2026 19:09
Staff can power a Device on or off, or reset it, from its page. The
control creates a staff DevicePowerOperation with a generated name, the
caller from a SelfSubjectReview as creator, the Device by name and UID,
the reason as the service request, and the recorded system UUID. It
offers only the actions discovery lists for the System with that UUID,
and destructive actions ask again, naming the server.

The button is hidden without create permission on
devicepoweroperations. It is disabled, with the reason as its tooltip,
when the records show the coordinator would refuse: discovery cannot
support the request, identity is not matched, the BMC key is unread or
shared, or custody shows the Device allocated, held, busy, retired or
unverified. A create whose outcome is unknown after sending keeps the
control off until the page is reopened, because a second POST would be
a second operation. Session, navigation and Device changes close an
open request, as in the location editor.

The header shows the observed power state and the latest operation's
progress. A new Operations tab lists recent power operations with their
result, power before and after, creator and reason. Operations and
custody are polled, and keep polling after a failed read. Fixture
builds carry synthetic custody and history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the feat/device-power-ui branch from 4325eb9 to 1134378 Compare November 26, 2026 01:09
The Device custody refactor keeps object UIDs out of every spec. The
Device incarnation is now the fleet.datumapis.com/device-uid label on an
operation and on custody, and custody names an operation by kind, name
and the fence recorded in its status.admission.

The power request now sends the Device's UID as that label and the
Device by name only; the creator stays the one UID in the spec. The
page lists a Device's power operations with a selector on the label
instead of reading every operation in the namespace, and keeps custody
only when its label is the Device's UID. A recovery hold is shown only
on the operation admitted at the hold's fence, so a same-name operation
created later is never shown as held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the feat/device-power-kind branch 6 times, most recently from 4b0e723 to cf80de8 Compare November 29, 2026 02:26
Base automatically changed from feat/device-power-kind to feat/manual-inventory-records November 29, 2026 03:16
@scotwells
scotwells marked this pull request as ready for review November 29, 2026 19:32
@scotwells
scotwells requested a review from a team as a code owner November 29, 2026 19:32

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

The page is a thin client over the coordinator's admission: confirmation, targeting and session handling are sound, and authorization is enforced on staging, not only in the UI. No power action can be sent without the second step except Power on.

  • Confirmation: Force off, Force restart and Power cycle take a reason, then a second "Continue", then a danger button that reads " ". device-power.test.tsx covers "asks again before %s, naming the server", Back not sending, and a reason being required. Power on sends directly, which fits an action that stops nothing.
  • Authorization: the control is hidden unless a SelfSubjectAccessReview allows create on devicepoweroperations. That is a display check only. The enforcement on staging is the power-operator role, which grants only that create, and the creator webhook (creatorwebhook/handler.go:96-97), which denies a spec.creator that is not the authenticated caller's username and UID. The page cannot forge a creator.
  • Wrong device: the request carries the Device name, its UID as the device-uid label, and expectedSystemUUID from the recorded system UUID. Custody refuses any operation whose device-uid does not match the current Device, and checks expectedSystemUUID for staff service requests such as this page sends, so a Device recreated under the same name is refused. History is selected by the UID label and re-filtered by name, with tests for another Device of the same name and for an unlabelled operation. An open dialog is closed when the Device's UID or resource version, or the session, changes.
  • Retry safety: the name is generated, so the page never re-sends after an unconfirmed create; it disables the control until the Device page is reopened, and says "Outcome unknown. Check Operations". A reopened page re-enables it once operations are read, which is a weak guard if the first create is still in flight; the coordinator's custody check is the real one.

Follow-ups:

  • The confirmation names the server by displayName, which is free text and need not be unique. The record name and system UUID appear only in a hover tooltip. Show the record name in the confirmation text for destructive actions.
  • The power-requester role (the Metal provider's) also grants create, so that identity would see the Power button if it opened the page. Gate the control on the staff role alone, or confirm the provider has no UI access.
  • Dismissing is blocked while sending and the reset on every resourceVersion change can close a half-typed dialog on each discovery refresh; consider keying the reset on the fields the request uses.
  • Provider and allocation power operations are not checked against expectedSystemUUID (only staff service requests are); only the device-uid label guards that path.

@scotwells
scotwells merged commit 0088ad8 into feat/manual-inventory-records Nov 29, 2026
19 checks passed
@scotwells
scotwells deleted the feat/device-power-ui branch November 29, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants