Repository navigation
feat(custody): Add the power operation kind - #179
Conversation
61bcf7c to
e61d79a
Compare
2796b3a to
9b16aab
Compare
9b16aab to
c036142
Compare
c036142 to
f93a539
Compare
f93a539 to
c6dcaa8
Compare
c6dcaa8 to
b403325
Compare
b403325 to
6762ac0
Compare
ecv
left a comment
There was a problem hiding this comment.
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-recordsgained the commissioning kinds (#195, #196) after this branch was cut, andgh pr viewreports CONFLICTING.git merge-treeshows real conflicts ininternal/custody/kinds.goandinternal/custody/creatorwebhook/handler.go. Resolve by keeping both kinds' resources in every list. - Webhook coverage survives that rebase safely:
TestEveryOperationKindIsGovernedrequires the Go list, the packaged webhook and the standalone policy to name every operation CRD. I removeddevicepoweroperationsfromwebhook.yamland the test failed as intended. Rerun it after the rebase. - Custody holder check:
DevicePowerOperationhas 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.goalso requires the operation'sAllocationRefto equal the holder's.power uses the shared reasons...(HolderMismatch for staff power on an allocated Device) anda staff request naming a customer's allocation never replaces the provider's pending operationcover it. - Requester and operator are separate:
power-operatorcan only create, andpower-requester(the provider) can create and read custody. The creator class, taken from the webhook-verified creator, picks the row, andonly the two power rows admit; every other creator and authority pair is refusedcovers 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-operatorlets any holder of it request a ForceOff on an unheld Device with no second approver. Say in the docs whether that is intended.
6762ac0 to
f016150
Compare
kevwilliams
left a comment
There was a problem hiding this comment.
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.
f016150 to
4c48d63
Compare
ecv
left a comment
There was a problem hiding this comment.
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.
TestPowerOperationsnow admits both a nil and an empty list for a staff requester, then has the worker'sFailed ResetTypeNotOfferedresult end with no hold and custody free.TestPowerCheckscovers 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:
resetTypesObservedis 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
ResetTypesObservedfield 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
TestPowerOperationswould pin it.
4c48d63 to
4b0e723
Compare
ecv
left a comment
There was a problem hiding this comment.
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.
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>
4b0e723 to
cf80de8
Compare
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:
Test plan
🤖 Generated with Claude Code