Repository navigation
feat: Add the Device custody and operations foundation - #178
Conversation
Add DeviceCustody and the DeviceInstallation, DeviceWipe and DeviceRecovery operation kinds proposed in #174 at 3907eec. Every operation shares one envelope and one status. CEL keeps an operation's spec immutable, moves its phases forward only, keeps the custody fence from decreasing and keeps Retired terminal. The device-operations component also carries the ProtectedResources, the coordinator, requester, viewer and recovery operator roles, and the creator webhook configuration. No root includes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the coordinator, the only writer of custody and of operation status. It admits each operation with one conditional custody update, queues provider and release work, refuses staff work it cannot run now, and expires staff work after five minutes. It accepts only results that carry the active fence, moves unknown outcomes into a recovery hold, applies DeviceRecovery decisions after the sites confirm the raised fence, and rebuilds missing custody as Unverified. Kinds plug in through a registry entry and rows of the admission table. Test-only kinds prove each seam, against a real API server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the validating webhook that Milo's root API server calls. It admits a create only when spec.creator is the authenticated caller, and an update only when the creator is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mark Increment A implemented and inert, record its decisions and the points that need a person, and describe how to add an operation kind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A DeviceRecovery with Settle or Retry now needs current discovery and a unique BMC key, like any other operation. Settling a power hold needs fresh discovery evidence of the power state. Retire and Resolve still skip both checks, so a server with an unreachable BMC can be retired. The registry refuses the skip for any kind that can reach the server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The allocation's non-secret facts live on its MachineAllocation, which only Fleet writes. Increment C can start after B. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rebuild now holds an operation that ended OutcomeUnknown unless a later success settled it, ends a held unfinished operation OutcomeUnknown, and never admits a held operation again. With several, the newest is held and custody stays Unverified for a Resolve. Admission decides only on custody that did not change while it listed operations, raises the fence above every fence a site reports, and confirms a recovery only once the sites report that older workers stopped. Resolve must agree with the live MachineAllocations. Queued operations wait under a hold they cannot settle. Retention keeps a succeeded retirement until inventory retires the Device. The creator webhook reads keys case-sensitively. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Separate the fence a fake site has seen from the fence for which it confirmed older workers stopped, and test that admission rises above the first while a recovery waits for the second. Test on its own that a held operation is never a candidate for admission. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kind checks now see the Device object the snapshot records, the injected clock and the discovery interval, and the coordinator decides again if the Device changes before the custody update. Kinds can add bounded fields to the snapshot, declare their refusal reasons with where each is raised, and declare whether a Retry applies to their holds. A hold keeps its deadline and admission snapshot for the settle hook. A refusal with an undeclared reason is recorded as UndeclaredReason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both local end-to-end runs now install the custody CRDs into the provider project, require its API to refuse eight writes the CEL rules forbid, and remove the CRDs again. Milo ignores admission policies stored in a project, so the rules need this proof. Record each extension-point decision for the power and commissioning kinds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Prove that a newer pending operation replaces only its own kind when two superseding kinds share an allocation, that Retry needs the held kind to be Retryable, and that a rebuilt hold keeps the deadline and snapshot its operation's status recorded. A held kind's reasons are accepted only through its settle hook. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rename the shared admission reasons to the names #174 now gives them: CustodyUnverified, CreatorNotPermitted, OperationInProgress and DeviceIdentityMismatch, which also covers discovery that is not current. A hold now counts the Retry decisions applied to it, so a kind such as power can name its next operation from a retry count. Pin #174 at abb1f88 throughout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An operation created after a Retry is now named from the held operation: its name, -retry- and the Retry count custody records with the hold. It waits until the Retry is applied, and a retry that itself ends unknown keeps the original name and count. Rebuild reads that lineage back from the names. Pending replacement never cancels an operation that settles a hold, and operations waiting for the hold no longer hold back the one that settles it. A row can admit from a holder only to settle a hold of its kind, as the staff power row needs. Pin #174 at 23c583f. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#174 now says what a recovery hold carries and when a Retry is accepted. The implementation already matches. Record how the hold's retry count and its unused-Retry marker map to that text, and pin the new head. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover the refusals of a row that admits from Service only under a hold of its kind: with no hold, and under a hold the kind does not settle. Both end Failed with HolderMismatch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kevwilliams
left a comment
There was a problem hiding this comment.
Verified only the coordinator role writes custody or operation status, the creator webhook rejects spoofed callers, and envtest refuses every custody CEL violation.
The power kind, built on this foundation, found six gaps. Each now has a subtest in TestRowsAndReplacement that fails when its fix is removed. - Only an operation that passes the creator, authority, holder and allocation checks on a queue row can replace another, so a request refused its permission check no longer cancels a customer's pending operation. - Staff rows never queue, so staff requests never replace one another. - A row can set its own naming rule, such as generated names for staff power and generation-based names for provider power. - A kind's own checks run before the shared identity and key checks, so its more specific reason is the one reported. - An operation named for a Retry waits for it, a staff one included, and does not expire while it waits. - The evidence validator receives the operation, and EvidenceRequired makes a success without evidence prove nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reading the operation for its evidence returned a plain error for a result naming an unregistered kind, so the site would retry it forever. Read the operation only when there is evidence to check for a registered kind, and let the stale path reject the rest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The power kind, built on this branch in #179, found six gaps in the admission seams. Each now has a subtest that fails when its fix is removed, and the head is 9cf6d32.
A follow-up commit fixes a regression the rereview found: a result naming an unregistered kind is rejected as stale again, instead of failing so the site retries it forever. The rereviewer approved this exact head. #180 is rebased onto it. |
ecv
left a comment
There was a problem hiding this comment.
Approve.
Custody foundation looks sound on the fencing and admission paths I read; the coordinator raises the fence above every fence a site has seen (spec.Fence = max(spec.Fence, seen) + 1) and confirms stops before a recovery applies. CI is green (validate, standalone-smoke, image and bundle builds), and custody tests pass locally at 9cf6d32.
- The enforcement of the fence at the BMC action point lives in #180's site
Step, not here, so this PR's safety rests on that stack member; #180 currently has an open hold on a same-fence redelivery. - Stack: base is
feat/manual-inventory-records, and #180 is rebased onto this head (9cf6d32) with only its own delta.
Follow-ups:
- I read
internal/custody/coordinator.gofor fence handling and did not read the 9k lines of CRDs, protected-resource policies, generated code or the tenancy/role wiring inconfig/components/admission/policies.yamlin depth. A tenant-cannot-trigger-operations test on hardware they do not hold should be confirmed before the API is exposed. - Tamper-test the fence confirmation (
siteFence) and theSeen-above rule in the coordinator tests; I only tampered the site-side guards in #180.
|
@ecv the tamper tests you suggested for the coordinator's fence confirmation and the rule that admission raises the fence above every fence a site has seen go into the end-to-end failure-scenarios increment, stacked on #182. A commit here would move this PR's approved head and force a rebase of #180 and #182, so this PR stays at 9cf6d32. |
Summary
Every physical action on a server will go through one custody record per Device, as the Device custody and operations proposal describes.
This change adds that record, the shared operation envelope, and the coordinator that admits operations, fences them, holds unproven outcomes, and rebuilds lost custody. It also adds the webhook that records who created each operation, and the seams a new kind such as power plugs into.
Nothing is wired into a deployment, the manager, or staging yet, and the existing lifecycle is unchanged.
Decisions
Decisions for a person
Test plan
Related to #174
🤖 Generated with Claude Code