Skip to content

feat(custody): Add the power operation kind - #179

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

scotwells merged 7 commits into
feat/manual-inventory-recordsfrom
feat/device-power-kind

Conversation

@scotwells

@scotwells scotwells commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Related to #173. Builds on #182 and #181.

Staff and the Fleet provider for Metal get one way to power a server on or off, or reset it, that custody admits, holds and recovers like every other operation. The kind ships with the custody component in every root, governed by the creator webhook beside the commissioning kinds, but nothing creates power operations and no site runs them yet. Admission refuses an action as not offered only when discovery observed the server's reset actions and they lack it; otherwise the worker's live check at the BMC decides.

This also closes two gaps in the shared custody code, so later kinds get the fixes too:

  • A kind check can wait. A brief discovery lapse used to fail a provider power request for good. It now waits in Pending, with nothing sent, for up to twice the discovery interval. Staff requests still fail at once.
  • A kind can require proof of a success. A power success needs the requested state read after the command, and reset proof for a restart or power cycle. Anything less ends unknown under a recovery hold.

Test plan

  • Tests pass against a real API server with the race detector, including the foundation's
  • Every governed kind, power and commissioning alike, is checked by the creator webhook and the standalone policy
  • Observed reset actions without the action refuse; with it, or not observed, admit; and the worker's refusal at the BMC ends Failed with nothing sent
  • A provider request waits through stale discovery and fails only after its bound, and a success without proof ends unknown with a hold

🤖 Generated with Claude Code

@scotwells
scotwells requested review from ecv and kevwilliams November 25, 2026 04:18
@scotwells
scotwells force-pushed the feat/device-power-kind branch from 61bcf7c to e61d79a Compare November 25, 2026 05:26
@scotwells
scotwells force-pushed the feat/device-power-kind branch 2 times, most recently from 2796b3a to 9b16aab Compare November 25, 2026 06:15
Base automatically changed from feat/device-custody-foundation to feat/manual-inventory-records November 25, 2026 14:58
@scotwells
scotwells force-pushed the feat/device-power-kind branch from 9b16aab to c036142 Compare November 25, 2026 15:47
@scotwells
scotwells changed the base branch from feat/manual-inventory-records to feat/device-site-execution November 25, 2026 15:48
@scotwells
scotwells force-pushed the feat/device-power-kind branch from c036142 to f93a539 Compare November 25, 2026 17:44
@scotwells
scotwells changed the base branch from feat/device-site-execution to feat/device-custody-cutover November 25, 2026 17:44
@scotwells
scotwells force-pushed the feat/device-power-kind branch from f93a539 to c6dcaa8 Compare November 26, 2026 00:55
Base automatically changed from feat/device-custody-cutover to feat/manual-inventory-records November 28, 2026 14:54
@scotwells
scotwells force-pushed the feat/device-power-kind branch from c6dcaa8 to b403325 Compare November 28, 2026 17:41
@scotwells
scotwells force-pushed the feat/device-power-kind branch from b403325 to 6762ac0 Compare November 28, 2026 18:08
@scotwells scotwells added the multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners label Nov 28, 2026
@scotwells
scotwells marked this pull request as ready for review November 28, 2026 19:19
@scotwells
scotwells requested a review from a team as a code owner November 28, 2026 19:19
@scotwells
scotwells removed the request for review from a team November 28, 2026 19:19

@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 power kind is governed end to end: provider power is admitted only while the Device is held by that exact allocation, staff power only while no customer holds it, the creator webhook is fail-closed, and every checked guard has a test. The PR conflicts with its base branch and needs a rebase.

  • Merge state: feat/manual-inventory-records gained the commissioning kinds (#195, #196) after this branch was cut, and gh pr view reports CONFLICTING. git merge-tree shows real conflicts in internal/custody/kinds.go and internal/custody/creatorwebhook/handler.go. Resolve by keeping both kinds' resources in every list.
  • Webhook coverage survives that rebase safely: TestEveryOperationKindIsGoverned requires the Go list, the packaged webhook and the standalone policy to name every operation CRD. I removed devicepoweroperations from webhook.yaml and the test failed as intended. Rerun it after the rebase.
  • Custody holder check: DevicePowerOperation has a provider row (holder Allocation, with the allocation in the authority) and two staff rows (holder None, or Service only to settle a power hold). coordinator.go also requires the operation's AllocationRef to equal the holder's. power uses the shared reasons... (HolderMismatch for staff power on an allocated Device) and a staff request naming a customer's allocation never replaces the provider's pending operation cover it.
  • Requester and operator are separate: power-operator can only create, and power-requester (the provider) can create and read custody. The creator class, taken from the webhook-verified creator, picks the row, and only the two power rows admit; every other creator and authority pair is refused covers the cross cases.

Follow-ups:

  • Add a test that a staff power request is refused while a commissioning operation is active, once the rebase brings that kind in. Commissioning is the case where a forced power-off hurts most.
  • power-operator lets any holder of it request a ForceOff on an unheld Device with no second approver. Say in the docs whether that is intended.

@scotwells
scotwells force-pushed the feat/device-power-kind branch from 6762ac0 to f016150 Compare November 28, 2026 20:21

@kevwilliams kevwilliams 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.

Spec is immutable, staff and provider admission are disjoint and holder-bound, and a power success settles only a retried power hold on a fresh BMC read.

@scotwells
scotwells requested review from ecv and kevwilliams November 28, 2026 21:09

@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 delta (4c48d63) removes only the empty-list refusal inside checkPower; every custody rule (staff-held, wiping, allocated elsewhere, other tenant) lives in other rules and rows and is untouched, so admitting with no reset list cannot weaken them. A recorded list that lacks the action is still refused ResetTypeNotOffered.

  • TestPowerOperations now admits both a nil and an empty list for a staff requester, then has the worker's Failed ResetTypeNotOffered result end with no hold and custody free. TestPowerChecks covers nil and empty for staff and for the provider row.
  • Prior #181 follow-up "omitted list conflates offers-none with read-failed": answered at admission. The coordinator no longer treats omission as refusal, and the worker decides from the live read. The signal itself is still missing: resetTypesObserved is a nonempty-list stand-in, so a BMC that truly offers nothing is admitted and then fails at the worker.

Follow-ups:

  • Add the discovery-side ResetTypesObserved field the stand-in names, so a read BMC that offers no reset actions is refused at admission instead of after queueing.
  • No end-to-end test sends an empty list through the customer row with another tenant's or a staff-held Device. Guard independence is clear from the code, but a one-line case in TestPowerOperations would pin it.

@scotwells
scotwells force-pushed the feat/device-power-kind branch from 4c48d63 to 4b0e723 Compare November 29, 2026 01:56
@scotwells
scotwells requested a review from ecv November 29, 2026 02:07

@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 delta since 4c48d63 swaps the len(ResetTypes) > 0 stand-in for discovery's ResetTypesObserved from #251. Admission now refuses ResetTypeNotOffered when discovery read the reset actions and they lack the action, an observed empty list included, and otherwise defers to the worker's live BMC check. The tests flipped with it: an observed empty list refuses for staff and provider, and a list not observed in this pass admits. The rest of the stack is a rebase with no change.

scotwells and others added 7 commits November 28, 2026 20:16
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 beside the commissioning kinds. 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 names every governed kind and requires
the custody CRDs and the webhook's resource list to match it.
TestPackagedResourcesMatch already keeps the packaged webhook and the
standalone policy in step with that list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two seams the power kind needs, in their general form.

A kind check could only refuse. Rule 7 runs before rule 5, so a provider
operation whose check reads discovery that lapsed briefly ended Failed,
and an operation named from its request is not created again. A check
refusal now sets Wait for a condition that can clear by itself. An
operation on a queue row then waits in Pending with the reason, for at
most Wait after it was created or the Device's last operation finished,
whichever is later, and only then ends Failed. Staff rows never wait,
and a refusal with an undeclared reason still fails at once.

The evidence hook sees every phase's evidence, so it could not require
what only a success proves. ProvesSuccess runs on a Succeeded result's
canonical evidence only, and a success it rejects ends OutcomeUnknown
with InvalidEvidence, under a hold, as missing evidence already does.
It needs EvidenceRequired. TypedProof decodes the evidence for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A provider power request refused DiscoveryNotCurrent now waits in
Pending for up to twice the discovery interval, so a short discovery
lapse no longer fails that Machine generation's power change for good.
A staff request still fails at once.

A power success now needs both reads, power.after in the requested
state, a sent command unless the server was already in that state, and
for a restart or power cycle the command and reset proof. Anything less,
including the empty object, ends OutcomeUnknown under a hold, and a
retry whose success proves nothing keeps the hold.

The custody guide records both seams in place of the two gaps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Discovery omits resetTypes both when the BMC offers none and when it
could not read the System's ActionInfo, so the list alone proves
nothing. The coordinator refused every power action on it as
ResetTypeNotOffered, so a transient ActionInfo read failure refused a
power-on.

The coordinator now refuses ResetTypeNotOffered only when discovery
marked the system's reset actions observed in that pass and they lack
the action, an observed empty list included. Otherwise the worker's
live check at the BMC decides: it ends Failed with nothing sent if the
action is not offered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the feat/device-power-kind branch from 4b0e723 to cf80de8 Compare November 29, 2026 02:26
@scotwells scotwells added multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners and removed multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners labels Nov 29, 2026
@scotwells
scotwells requested a review from ecv November 29, 2026 02:40

@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.

Still approved at cf80de8: rebase only, picking up #252 from the base branch.

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

Labels

multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants