Skip to content

feat(custody): Add the commissioning kinds - #195

Merged
scotwells merged 3 commits into
feat/manual-inventory-recordsfrom
feat/device-commissioning-kind
Nov 28, 2026
Merged

scotwells merged 3 commits into
feat/manual-inventory-recordsfrom
feat/device-commissioning-kind

Conversation

@scotwells

@scotwells scotwells commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Related to #185. Targets the feature branch now that #182 and #219 have merged.

Staff can now ask to commission a server. A plan qualifies only when a second person, not its author, approves its exact content. Nothing runs a commissioning until #196 adds the site worker, so one created before then holds its server until its deadline and ends with an unknown outcome.

Landing

The capacity stack lands first: #182, #219, #208 and #232 (all merged), then #195, #196, #200 and #201. Overlapping PRs on other stacks (cleaning #193, #202, #205, #206 and #207, power #190, NSO and IPAM #198 and #225, virtual media #229) rebase onto it, and #205 adds its NVMe lab drive on top of the lab model in #196.

Decisions for a person

  • Who approves commissioning plans. The plan approver role stays unbound until a person picks the team that holds it, so no plan qualifies until then. Admission rejects an approval by the plan's author. Author and approver are told apart by username, ignoring case, as feat: Run Machine allocation and release through Device custody #182 identifies principals. A client certificate carries no UID, so UIDs are compared only when both have one. Never bind the author and approver roles to the same principal, or to groups that share a member. The role descriptions and the custody doc state this rule, because Fleet does not own IAM bindings and cannot refuse one. Recommendation: bind approvers to a separate operations group.
  • A plan revoked during admission. Admission reads the plan before it updates custody, so a plan revoked in between can still be admitted once. The capacity projector in feat(capacity): Derive capacity status from commissioning #200 must read the current plan again on every pass, so that run makes nothing allocatable.

Test plan

  • Tests pass with the race detector against a real API server
  • An approval by the author, by the author's UID, or by the author's username in another case does not qualify the plan, and authors without UIDs are told apart by username
  • A Failed verdict without the admission snapshot's serial, system UUID and BMC key proves nothing, and a Failed verdict with them ends Succeeded but leaves a commissioning hold in place, live and after rebuild
  • No packaged role, counting inherited roles, both writes and approves plans, and no packaged PolicyBinding grants one subject both
  • The multi-plane CRD rule phase refuses a write that breaks each new rule, in both modes, on the top of the stack
  • Manifest, Milo packaging, overlay isolation and harness checks pass, and a test keeps the packaged webhook and standalone policy resource lists in step

🤖 Generated with Claude Code

@scotwells
scotwells requested review from ecv and kevwilliams November 25, 2026 16:24
@scotwells
scotwells force-pushed the feat/device-commissioning-kind branch 2 times, most recently from 02825ef to c147372 Compare November 25, 2026 21:36
@scotwells
scotwells changed the base branch from feat/device-custody-cutover to feat/device-custody-failure-scenarios November 25, 2026 21:36
@scotwells
scotwells force-pushed the feat/device-custody-failure-scenarios branch 5 times, most recently from 8c6052e to c73530a Compare November 28, 2026 01:12
@scotwells
scotwells force-pushed the feat/device-commissioning-kind branch 4 times, most recently from a7c1973 to 87b08a6 Compare November 28, 2026 03:55
@scotwells scotwells changed the title feat(custody): Add the commissioning operation kind feat(custody): Add the commissioning kinds Nov 28, 2026
Base automatically changed from feat/device-custody-failure-scenarios to feat/manual-inventory-records November 28, 2026 15:12
Add DeviceCommissioning, with DeviceCommissioningPlan and
DeviceCommissioningPlanApproval, as the commissioning proposal describes.
A plan qualifies only when someone other than its author approves its
exact generation and digest. Approver and author are told apart by
username ignoring case; UIDs are compared only when both carry one, since
a client certificate carries none. A Device's current plan is the one
qualified plan that selects it and that no other selecting plan
supersedes.

No spec holds an object UID. An approval's name is the plan's name and a
suffix derived from the plan's UID, and a commissioning names that
approval, so a plan recreated under the same name inherits nothing. The
Device incarnation is the device-uid label.

Custody admits a commissioning from holder None, or from Service to settle
a commissioning hold, under the Device's current plan with an exact copy
of its content. A proven verdict ends Succeeded with a Passed or Failed
result; anything else ends OutcomeUnknown. Two seams let a kind derive its
deadline from its inputs and keep each Device's latest success past
retention.

Every mode's coordinator role reads the new kinds. The creator webhook
and the standalone creator policy govern them, and a test keeps both
packaged resource lists in step. The multi-plane CRD rule phase refuses
a write that breaks each new CEL rule, and the standalone smoke and the
harness custody reads cover the new kinds.

Nothing runs a commissioning worker yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the feat/device-commissioning-kind branch from 87b08a6 to 6a28951 Compare November 28, 2026 16:30
@scotwells
scotwells marked this pull request as ready for review November 28, 2026 17:13
@scotwells
scotwells requested a review from a team as a code owner November 28, 2026 17:13
@scotwells
scotwells removed the request for review from a team November 28, 2026 17:13

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

Hold: a Failed commissioning can settle a commissioning hold without proving the server identity.

  • validateCommissioningEvidence returns early for Failed, so serial, system UUID and BMC key go unchecked. If the operation then ends Succeeded, the Settles rule clears a Service hold left by an OutcomeUnknown run cut off mid-flash or mid-burn-in.
  • Fix: require the identity check for Failed results too, or settle a hold only on a Passed verdict.
  • Add a test that a Failed verdict does not settle a hold.

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

Request changes.

The new kinds, roles and protected resources are sound, but a Failed commissioning result is accepted without proving the server's identity, and that result can still settle a recovery hold.

  • Agree with kevwilliams: validateCommissioningEvidence in internal/custody/commissioning.go returns early for Failed before the serial, system UUID and BMC key are compared with the admission snapshot. If the operation then ends Succeeded, Settles: DeviceCommissioning (commissioning.go:222) clears a Service hold left by an OutcomeUnknown run cut off mid-flash or mid-burn-in, on evidence from a server nobody identified. Check identity for Failed too, or settle a hold only on a Passed verdict, and add a test that a Failed verdict does not settle a hold.
  • Plan author and approver separation holds in the coordinator, not at admission: qualifies refuses an approval whose spec.creator is not distinct from the plan's creator (case-insensitive username, UID when both have one), and the creator webhook pins spec.creator to the authenticated caller on create and update. One identity cannot make a plan qualify by writing both objects. The approval name is derived from the plan UID and the digest is pinned, so a replaced plan needs a new approval.
  • Roles are least-privilege: author gets plans create/delete, approver gets approvals create/delete, operator gets commissionings create, and none gets update or patch. The coordinator is the only status writer. Nothing prevents one person from holding both the author and approver roles, because the check compares usernames; two accounts for one human pass.
  • The creator webhook covers all three new plurals and stays failurePolicy: Fail; TestPackagedResourcesMatch ties the three rule lists together.

Follow-ups:

  • Add an IAM-level guard (or a documented rule) that the author and approver roles are never bound to the same principal, so separation does not rest on the username comparison alone.
  • This PR's base is feat/manual-inventory-records, not main, so it cannot merge until that branch does. Re-review the delta once the base lands.

scotwells and others added 2 commits November 28, 2026 11:28
A Failed commissioning verdict skipped the identity check, so a verdict
about another server could end Succeeded and clear a commissioning hold
left by a run cut off mid-flash or mid-burn-in.

Every result now records the serial number, system UUID and BMC key the
admission snapshot holds. A kind may also decide from a success's
evidence whether it settles the hold it was admitted to settle; a
commissioning settles one only with a Passed verdict. Live results and
rebuild apply the same rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The username comparison at admission was the only stated guard on plan
separation. State the IAM rule it backs: the author and approver roles
are never bound to one principal or to groups that share a member. Fleet
does not own IAM bindings, so the rule is documented on both roles, and
the packaged-IAM test now follows inherited roles and refuses any
packaged PolicyBinding that grants one subject both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells

Copy link
Copy Markdown
Contributor Author

Thanks, both. Both points are fixed at c2cc6b6.

  1. Failed verdict and holds (f7c5d21). Every verdict, Passed or Failed, must now carry the serial, system UUID and BMC key from the admission snapshot. Only a Passed verdict settles a commissioning hold, and rebuild applies the same rule. New tests cover a Failed verdict that does not settle a hold, both live and after rebuild, and Failed evidence with a missing or wrong serial, UUID or key. Removing any part of the fix fails them. One consequence: Failed evidence without identity now ends the operation as an unknown outcome instead of Succeeded, and the custody doc says so.
  2. Author and approver separation (c2cc6b6). Fleet doesn't own IAM bindings, so it can't refuse one when it's created. The rule is documented in the custody doc and both role descriptions: never bind the author and approver roles to the same principal, or to groups that share a member. TestPlanAuthorsCannotApprove now follows inherited roles and rejects any packaged PolicyBinding that grants one subject both roles. The body now recommends a separate operations group for approvers.

@scotwells
scotwells requested a review from ecv November 28, 2026 18:57

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

Every verdict now proves the server identity against the admission snapshot, only a Passed result settles a hold, and a test pins that a Failed one does not.

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

Both holds are closed: every commissioning verdict now proves the admitted server's identity, and only a Passed result settles a hold. I diffed the PR's own commits (6a28951, f7c5d21, c2cc6b6); the old head is no longer fetchable after the rebase, so I read the fix commits against the earlier findings.

  • Agree with kevwilliams, now addressed: validateCommissioningEvidence compares serial, system UUID and BMC key with the admission snapshot before the Failed branch, so a Failed verdict from another server is refused. New cases cover a Failed verdict with no serial, another serial, another UUID and another key.
  • Failed no longer settles a hold: SettlesWith: commissioningPassed gates the Settles rule, and rebuild reads the same rule from recorded evidence. The new test "a Failed verdict does not settle a commissioning hold" leaves a Service hold from an OutcomeUnknown run, ends a second run Succeeded with a Failed verdict, checks the hold stays, then deletes the custody, rebuilds and checks again.
  • Follow-up from my first review, addressed: both role descriptions now say never to bind the author and approver roles to one principal or to groups sharing a member. This stays a documented rule, not an enforced one.
  • CI is green on this head, including go-test custody-1/2/3. The envtest suites skip locally without KUBEBUILDER_ASSETS, so I did not run my own tamper test (removing the SettlesWith guard); CI is the evidence.

Follow-ups:

  • This PR is based on feat/manual-inventory-records, so it merges only after that branch does.

@scotwells
scotwells merged commit 9e9209e into feat/manual-inventory-records Nov 28, 2026
15 checks passed
@scotwells
scotwells deleted the feat/device-commissioning-kind branch November 28, 2026 19:12
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.

3 participants