carlos / platform Public

claim stamps and comparisons use the box binding (roster binding task 3)

Every installed-state stamp the box and root write, and every fresh
comparison against the roster, now uses actor.Binding instead of the
roster write counter: the agent's install and census pins
(claimassembly.go), root's startup census, inventory write, local and
remote wake, launch authorize (both checks), launch owner and fence
target stamps, the stop request producers (wake stop, writers stopped,
relocation release), execution authority, serving handover, park and
legacy checks, handover recovery, recovery rebind's successor, the
agent's cold handover successor and the remote recovery producer
(claimrecovery_remote.go, N4's producer).

servingPriorRevision's ordering becomes servingPriorBinding, equality
with the fresh binding. sameVerifiedActor is deleted (7b805720
reconciled): VerifyRegional, claimBoundIdentity (regional store,
leases, move fence and parks) and the evidence wiring use
hostbox.SameBinding. The identity sanity checks also require a
binding.

Receipt numerals and fences (task 4), fresh root identities (task 5),
startup settlement (5b), predecessor checks (6) and the cold handover
admission (6b) are later phases; until task 4 a receipt's
directory_revision carries the binding, so this branch must not roll
before phase B.

Tests: L2 TestClaimBindingSurvivesRosterWritesWithoutRestart and L3
...AfterRestart (production roster identity, six real roster writes,
remote install into root's commitRootInventory, census, second
inventory write, bound identity, VerifyRegional, readmission refused);
TestClaimBindingLaunchAuthorizeSurvivesRosterWrites;
TestClaimBindingServingHandoverSurvivesRosterWrites;
TestServingPriorBindingIsEquality; existing revision-bump attacks
become binding attacks; the ruling-6 pin on sameVerifiedActor is
dropped with the function.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev ae31266266a599b160ba4b2d2cc727a03a7efae7 parent 18decb1
82 files changed, +834 −203
  • internal/host/claim_binding_fixture_test.go +254 −0
  • internal/host/claim_binding_launch_linux_test.go +134 −0
  • internal/host/claim_binding_test.go +36 −0
  • internal/host/claim_binding_witness_linux_test.go +235 −0
  • internal/host/claim_evidence_wiring.go +1 −1
  • internal/host/claim_regional_revision_test.go +2 −45
  • internal/host/claimassembly.go +4 −17
  • internal/host/claimconstruction.go +1 −2
  • internal/host/claimfilesseed_cli_rootrunner_linux_test.go +1 −1
  • internal/host/claimfilesseed_recovery_linux_test.go +2 −2
  • internal/host/claimfilesseed_select.go +1 −1
  • internal/host/claimfilesseed_select_linux_test.go +1 −1
  • internal/host/claimhandover_recovery.go +2 −2
  • internal/host/claimhandover_recovery_test.go +2 −2
  • internal/host/claimhandover_transport.go +1 −2
  • internal/host/claimlaunch_authority.go +1 −2
  • internal/host/claimlaunch_root.go +1 −1
  • internal/host/claimlaunch_root_test.go +2 −2
  • internal/host/claimmoveparks.go +3 −2
  • internal/host/claimmoveparks_test.go +13 −3
  • internal/host/claimordinaryparks_linux_test.go +3 −3
  • internal/host/claimrecovery_remote.go +1 −2
  • internal/host/claimretryrecovery_test.go +13 −2
  • internal/host/claimroleassembly.go +1 −2
  • internal/host/claimroleassembly_linux.go +1 −2
  • internal/host/claimservinghandover.go +8 −6
  • internal/host/claimservinghandover_linux_test.go +2 −3
  • internal/host/claimservinglegacyroot_linux.go +2 −3
  • internal/host/claimservinglegacyroot_linux_test.go +4 −4
  • internal/host/claimservingnamespace_linux_test.go +1 −1
  • internal/host/claimservingpark_recovery_linux_test.go +3 −3
  • internal/host/claimservingpark_rootrunner_linux_test.go +2 −2
  • internal/host/claimservingpark_transport.go +1 −1
  • internal/host/claimservingparkroot_linux.go +2 −2
  • internal/host/claimservingparkroot_linux_test.go +17 −6
  • internal/host/claimservingparksource_linux.go +2 −2
  • internal/host/claimservingparksource_linux_test.go +1 −1
  • internal/host/claimservingreboot_prepare_linux_test.go +10 −5
  • internal/host/claimservingrenumber_linux_test.go +1 −1
  • internal/host/claimservingretire_linux_test.go +6 −1
  • internal/host/claimstep8_ruling6_test.go +0 −3
  • internal/host/claimstep8_witness_rootrunner_linux_test.go +1 −1
  • internal/host/claimstop_noprocess_test.go +1 −1
  • internal/host/claimstop_writers.go +1 −1
  • internal/host/claimwakestop.go +1 −2
  • internal/host/claimwakewriters_test.go +1 −1
  • internal/host/moveswakesource_linux_test.go +1 −1
  • internal/host/moveswakesource_test.go +1 −1
  • internal/host/plan12_handover_test.go +1 −1
  • internal/host/plan13_region_test.go +4 −4
  • internal/host/plan13_views_test.go +1 −1
  • internal/host/plan14_install_registration_test.go +1 −1
  • internal/host/plan14_lifecycle_root_linux_test.go +2 −2
  • internal/host/plan14_r11_handover_test.go +1 −2
  • internal/host/plan14_recovery_source_test.go +1 −1
  • internal/host/plan14_timer_intention_test.go +1 −1
  • internal/host/plan9_cleanup_identity_test.go +1 −1
  • internal/host/plan9_fix1_reset_worker_test.go +1 −1
  • internal/host/plan9_production_test.go +4 −4
  • internal/host/plan9fix4_claimjournal_migration_linux_test.go +1 −1
  • internal/host/relocationassembly_test.go +1 −1
  • internal/host/relocationattempts_linux_test.go +1 −1
  • internal/host/relocationeffects.go +1 −1
  • internal/host/relocationeffects_test.go +5 −5
  • internal/host/relocationfinish_unix_test.go +1 −1
  • internal/host/relocationfirstwake_unix_test.go +1 −1
  • internal/host/relocationhandover_unix_test.go +3 −3
  • internal/host/relocationinstall_linux_test.go +1 −1
  • internal/host/relocationparticipation_linux_test.go +1 −1
  • internal/host/relocationprobefiles_linux_test.go +2 −2
  • internal/host/relocationreleases_test.go +1 −1
  • internal/host/relocationstopprobe_unix_test.go +1 −1
  • internal/host/rootexecution_authority.go +1 −2
  • internal/host/rootinventory.go +1 −2
  • internal/host/rootinventory_process_test.go +1 −1
  • internal/host/rootinventory_startup.go +1 −2
  • internal/host/rootinventory_state_linux.go +1 −2
  • internal/host/rootinventory_test.go +2 −2
  • internal/host/rootinventory_timer_test.go +1 −1
  • internal/host/rootrecovery_process_test.go +1 −1
  • internal/host/rootrecovery_rebind.go +1 −1
  • internal/host/rootrecovery_rebind_test.go +1 −1
diff --git a/internal/host/claim_binding_fixture_test.go b/internal/host/claim_binding_fixture_test.go
new file mode 100644
index 000000000..f44e017f0
--- /dev/null
+++ b/internal/host/claim_binding_fixture_test.go
@@ -0,0 +1,254 @@
+package host
+
+import (
+ "crypto/ed25519"
+ "encoding/json"
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/hostactors"
+ "github.com/carlosframework/platform/internal/hostbox"
+ "github.com/carlosframework/platform/internal/hostclaim"
+ "github.com/carlosframework/platform/internal/hostfloor"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// bindingRosterFixture is a signed one-box roster in a release.DirStore, with
+// a published floor and the matching local floor policy, read through the
+// production roster adapter. Roster writes go through the real
+// hostactors.Directory writers unless a step says otherwise.
+type bindingRosterFixture struct {
+ t *testing.T
+ store release.Store
+ signer release.Signer
+ dir hostactors.Directory
+ floorDir string
+ box string
+ churn int
+}
+
+const bindingFixtureBucket = "deployment"
+
+func newBindingRosterFixture(t *testing.T, box, region string) *bindingRosterFixture {
+ t.Helper()
+ key := ed25519.NewKeyFromSeed(make([]byte, ed25519.SeedSize))
+ s := release.NewDirStore(t.TempDir())
+ f := &bindingRosterFixture{t: t, store: s, signer: release.RootSigner(key), dir: hostactors.Directory{Store: s, PublicKey: key.Public().(ed25519.PublicKey), Bucket: bindingFixtureBucket}, floorDir: t.TempDir(), box: box}
+ if err := hostfloor.Publish(t.Context(), s, f.signer, bindingFixtureBucket, hostfloor.Floor{Min: 1, MinRelease: "v0.1.0"}); err != nil {
+ t.Fatalf("newBindingRosterFixture: %v", err)
+ }
+ raw, _, err := s.Get(t.Context(), hostfloor.Key)
+ if err != nil {
+ t.Fatalf("newBindingRosterFixture: %v", err)
+ }
+ auth, _, err := s.Get(t.Context(), hostfloor.AuthKey)
+ if err != nil {
+ t.Fatalf("newBindingRosterFixture: %v", err)
+ }
+ body, _ := json.Marshal(hostfloor.Policy{Schema: 1, DeploymentBucket: bindingFixtureBucket, Mode: "enforced", Floor: raw, Authorization: auth})
+ if err := os.WriteFile(filepath.Join(f.floorDir, "policy.json"), body, 0600); err != nil {
+ t.Fatalf("newBindingRosterFixture: %v", err)
+ }
+ if err := f.dir.Initialize(t.Context(), f.signer); err != nil {
+ t.Fatalf("newBindingRosterFixture: %v", err)
+ }
+ o := f.read()
+ next := hostactors.Clone(o.Roster)
+ next.RequestLimitNS, next.Publication, next.FloorSHA256 = int64(hostbox.RequestLimit), "published", hostfloor.Digest(raw)
+ // A region HA group, so enrollmentAttempt can run the real writer.
+ next.Regions = map[string]hostactors.Region{region: {Namespaces: []string{"platform"}, Pools: []string{"default"}, Account: "111122223333", AWSRegion: "eu-west-1", GroupName: "group", GroupARN: "arn:aws:autoscaling:eu-west-1:111122223333:autoScalingGroup:x:autoScalingGroupName/group"}}
+ next.Boxes[box] = hostactors.Box{BoxID: box, Enrollment: strings.Repeat("a", 32), Namespace: "platform", Label: box, Region: region, Pool: "default", Cloud: hostactors.Cloud{Provider: "aws", Account: "111122223333", Region: "eu-west-1", InstanceID: "i-0abc"}, EvidenceSHA256: strings.Repeat("c", 64), State: "active", LossIDs: []string{}}
+ if _, err := f.dir.Replace(t.Context(), f.signer, o, next); err != nil {
+ t.Fatalf("newBindingRosterFixture: %v", err)
+ }
+ return f
+}
+
+func (f *bindingRosterFixture) read() hostactors.Observed {
+ f.t.Helper()
+ o, err := f.dir.Read(f.t.Context())
+ if err != nil {
+ f.t.Fatalf("read: %v", err)
+ }
+ return o
+}
+
+func (f *bindingRosterFixture) row() hostactors.Box { return f.read().Roster.Boxes[f.box] }
+
+// identity is the box's production identity: signed cloud evidence for the
+// row's instance and productionClaimRoster over this roster.
+func (f *bindingRosterFixture) identity() hostbox.IdentityProvider {
+ f.t.Helper()
+ row := f.row()
+ identity := handoverRecoveryIdentity(f.t, hostbox.Actor{Box: f.box, Enrollment: row.Enrollment, Region: row.Region, ControlBucket: bindingFixtureBucket, Revision: 1})
+ identity.Roster = productionClaimRoster{Directory: f.dir, DataBucket: identity.Bucket, FloorDir: f.floorDir}
+ return identity
+}
+
+func (f *bindingRosterFixture) binding() string {
+ f.t.Helper()
+ b, ok := hostactors.BoxBinding(f.read().Roster, f.box)
+ if !ok {
+ f.t.Fatal("box not in roster")
+ }
+ return b
+}
+
+// holdChurn is one console create's roster traffic: a real hold Reserve, then
+// the claim it names moves on and ReleaseFinishedHold drops the hold. The
+// roster write counter moves by two; this box's binding does not.
+func (f *bindingRosterFixture) holdChurn() {
+ f.t.Helper()
+ before := f.read().Roster.Revision
+ f.releaseHold(f.reserveHold())
+ after := f.read()
+ if after.Roster.Revision != before+2 || len(after.Roster.Holds) != 0 {
+ f.t.Fatalf("hold churn: revision %d -> %d, holds %d", before, after.Roster.Revision, len(after.Roster.Holds))
+ }
+}
+
+// reserveHold is a create's real hold Reserve naming this box, left held.
+func (f *bindingRosterFixture) reserveHold() hostactors.Reservation {
+ f.t.Helper()
+ ctx := f.t.Context()
+ f.churn++
+ host := fmt.Sprintf("churn-%d.example.com", f.churn)
+ before := f.read()
+ claim, err := hostclaim.Read(ctx, f.store, host)
+ if err != nil {
+ f.t.Fatalf("reserveHold: %v", err)
+ }
+ actor := "box:" + f.box
+ enrollment := before.Roster.Boxes[f.box].Enrollment
+ h := hostactors.Reservation{ID: fmt.Sprintf("hold_%d", f.churn), Host: host, OpID: "create", ExpectedClaimETag: claim.ETag, FloorSHA256: before.Roster.FloorSHA256, Actors: map[string]string{actor: enrollment}, Releases: map[string]hostactors.Report{actor: {Enrollment: enrollment}}}
+ if _, err := f.dir.Reserve(ctx, f.signer, before, h, false); err != nil {
+ f.t.Fatalf("reserveHold: %v", err)
+ }
+ return h
+}
+
+// releaseHold moves the hold's claim on, then ReleaseFinishedHold drops it.
+func (f *bindingRosterFixture) releaseHold(h hostactors.Reservation) {
+ f.t.Helper()
+ ctx := f.t.Context()
+ claim, err := hostclaim.Read(ctx, f.store, h.Host)
+ if err != nil {
+ f.t.Fatalf("releaseHold: %v", err)
+ }
+ if _, err := hostclaim.Update(ctx, f.store, claim, func(*hostclaim.Claim) error { return nil }); err != nil {
+ f.t.Fatalf("releaseHold: %v", err)
+ }
+ if err := f.dir.ReleaseFinishedHold(ctx, f.signer, h.ID); err != nil {
+ f.t.Fatalf("releaseHold: %v", err)
+ }
+}
+
+// quarantine is a real Directory.Quarantine of the box.
+func (f *bindingRosterFixture) quarantine(loss string) {
+ f.t.Helper()
+ o := f.read()
+ if _, err := f.dir.Quarantine(f.t.Context(), f.signer, o, f.box, o.Roster.Boxes[f.box].Enrollment, loss); err != nil {
+ f.t.Fatalf("quarantine: %v", err)
+ }
+}
+
+// readmit returns the quarantined row to active by a DIRECT SIGNED WRITE.
+// Directory.Replace admits a quarantined -> active change on a published
+// roster only with a fresh box-signed census report (hostactors
+// checkMembership), which this fixture has no box to produce. The written
+// roster is exactly what hostresolve's readmission writes: the row's state
+// alone changes, its quarantine revision and loss ids stay, and Revision
+// moves by one.
+func (f *bindingRosterFixture) readmit() {
+ f.t.Helper()
+ o := f.read()
+ next := hostactors.Clone(o.Roster)
+ b := next.Boxes[f.box]
+ if b.State != "quarantined" {
+ f.t.Fatalf("readmit: state %q", b.State)
+ }
+ b.State = "active"
+ next.Boxes[f.box] = b
+ next.Revision++
+ wire, err := release.SignRootEnvelope(f.signer, next)
+ if err != nil {
+ f.t.Fatalf("readmit: %v", err)
+ }
+ if _, err := f.store.Put(f.t.Context(), hostactors.Key, wire, o.ETag); err != nil {
+ f.t.Fatalf("readmit: %v", err)
+ }
+}
+
+// activationChurn is one platform promote's roster traffic: a real activation
+// Reserve (with a prepared system publication) and CancelActivation.
+func (f *bindingRosterFixture) activationChurn() {
+ f.t.Helper()
+ ctx := f.t.Context()
+ f.churn++
+ id := fmt.Sprintf("activation_%d", f.churn)
+ platform := release.AdoptPlatform()
+ rel := release.SystemRelease{Version: "v2.0.0", ReleaseTag: "v2.0.0", MovesProtocol: 1, Artifacts: map[string]release.SystemArtifact{platform: {Key: release.SystemArtifactKey("v2.0.0", platform), SHA256: strings.Repeat("a", 64)}}}
+ pub, err := release.PrepareSystemPromotion(ctx, f.store, f.signer, "router", "stable", rel, release.SystemPromoteOptions{Actor: "operator"}, id)
+ if err != nil {
+ f.t.Fatalf("activationChurn: %v", err)
+ }
+ before := f.read()
+ actor := "box:" + f.box
+ enrollment := before.Roster.Boxes[f.box].Enrollment
+ h := hostactors.Reservation{ID: id, Publication: &pub, RequestSHA256: strings.Repeat("e", 64), UpdateMode: "promote", FloorSHA256: before.Roster.FloorSHA256, Actors: map[string]string{actor: enrollment}, Releases: map[string]hostactors.Report{actor: {Enrollment: enrollment}}, Hashes: map[string][]string{actor: {"a", "b", "c"}}}
+ if _, err := f.dir.Reserve(ctx, f.signer, before, h, true); err != nil {
+ f.t.Fatalf("activationChurn: %v", err)
+ }
+ if err := f.dir.CancelActivation(ctx, f.signer, id); err != nil {
+ f.t.Fatalf("activationChurn: %v", err)
+ }
+ if after := f.read(); after.Roster.Revision != before.Roster.Revision+2 || len(after.Roster.Activations) != 0 {
+ f.t.Fatalf("activation churn: revision %d -> %d", before.Roster.Revision, after.Roster.Revision)
+ }
+}
+
+// enrollmentAttempt is region HA autoscaling's real BeginEnrollmentAttempt
+// for another instance in the box's region.
+func (f *bindingRosterFixture) enrollmentAttempt() {
+ f.t.Helper()
+ f.churn++
+ o := f.read()
+ ref := fmt.Sprintf("replacement-%d", f.churn)
+ if _, _, err := f.dir.BeginEnrollmentAttempt(f.t.Context(), f.signer, o, hostactors.EnrollmentRequest{Reference: ref, Region: o.Roster.Boxes[f.box].Region}, []byte("evidence-"+ref), "i-0"+ref); err != nil {
+ f.t.Fatalf("enrollmentAttempt: %v", err)
+ }
+}
+
+// roleChange is the operator's real SetBoxRole on this box.
+func (f *bindingRosterFixture) roleChange(role string) {
+ f.t.Helper()
+ if _, err := f.dir.SetBoxRole(f.t.Context(), f.signer, f.read(), f.box, role); err != nil {
+ f.t.Fatalf("roleChange: %v", err)
+ }
+}
+
+// sixWrites is the design's L2 sequence: hold Reserve and ReleaseFinishedHold,
+// activation Reserve and CancelActivation, BeginEnrollmentAttempt and
+// SetBoxRole. The roster write counter moves by exactly six and this box's
+// binding does not move at all.
+func (f *bindingRosterFixture) sixWrites() {
+ f.t.Helper()
+ before, binding := f.read().Roster.Revision, f.binding()
+ f.holdChurn()
+ f.activationChurn()
+ f.enrollmentAttempt()
+ role := hostactors.RoleLegacy
+ if f.row().Role == role {
+ role = hostactors.RoleDefault
+ }
+ f.roleChange(role)
+ if after := f.read().Roster.Revision; after != before+6 {
+ f.t.Fatalf("six roster writes moved the revision %d -> %d", before, after)
+ }
+ if f.binding() != binding {
+ f.t.Fatal("unrelated roster writes moved the box binding")
+ }
+}
diff --git a/internal/host/claim_binding_launch_linux_test.go b/internal/host/claim_binding_launch_linux_test.go
new file mode 100644
index 000000000..ff717c134
--- /dev/null
+++ b/internal/host/claim_binding_launch_linux_test.go
@@ -0,0 +1,134 @@
+//go:build linux
+
+package host
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/cgroup"
+ "github.com/carlosframework/platform/internal/hostbox"
+ "github.com/carlosframework/platform/internal/hostclaim"
+ execlease "github.com/carlosframework/platform/internal/hostexec"
+ "github.com/carlosframework/platform/internal/hostguard"
+ "github.com/carlosframework/platform/internal/hostwrite"
+ "github.com/carlosframework/platform/internal/instancectl"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+)
+
+// L2, launch authorize (claimlaunch_authority.go): root's launch authority
+// reads the production identity fresh. A reservation whose target carries the
+// box binding is authorized before and after six roster writes; a target
+// stamped with the roster numeral is refused, and after a quarantine and
+// readmission the same reservation is refused.
+func TestClaimBindingLaunchAuthorizeSurvivesRosterWrites(t *testing.T) {
+ ctx := t.Context()
+ roster := newBindingRosterFixture(t, "dst", "ie")
+ identity := roster.identity()
+ actor, err := identity.Verify(ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ dataDir := t.TempDir()
+ f := newROFixture(t, roOptions{})
+ f.inputs.Launch = func(context.Context, registry.Route) (ClaimServingLaunch, error) {
+ return ClaimServingLaunch{Identity: hostwrite.Identity{Config: "sha256:config", Release: "sha256:release"}, Executable: "/opt/carlos/versions/v1/app", ExecutableSHA256: strings.Repeat("b", 64), Version: "v1",
+ Args: []string{"--socket", filepath.Join(provision.InstanceRunDir(roHost), "app.sock"), "--db", provision.NestedDBPath(dataDir, roHost)}, Env: []string{"CARLOS_ADMIN_TOKEN=test"}}, nil
+ }
+ in, err := f.inputs.Select(ctx, f.route, f.read(), roProbe)
+ if err != nil {
+ t.Fatal(err)
+ }
+ admitted := f.admit(f.read(), in)
+ h := admitted.Claim.Holder
+ boot, err := execlease.BootID()
+ if err != nil {
+ t.Fatal(err)
+ }
+ start, err := claimConstructionProcessStart()
+ if err != nil {
+ t.Fatal(err)
+ }
+ peer := StopPeer{UID: 1001, PID: os.Getpid(), ProcessStart: start, BootID: boot, ControllerID: "controller-1"}
+ target := hostguard.FenceTarget{Region: "ie", Host: roHost, Incarnation: h.Incarnation, Stamp: h.Stamp, Session: h.Session, Op: roOp, Phase: hostclaim.PhaseRelocatingProbing, Box: actor.Box, Enrollment: actor.Enrollment, BootID: peer.BootID, ControllerID: peer.ControllerID, ClaimETag: admitted.ETag, DirectoryRevision: actor.Binding}
+ attempts := &relocationProbeAttempts{Claims: f.claims, DataDir: dataDir, Box: actor.Box, NewID: f.inputs.NewID, Now: f.inputs.Now}
+ s := OperationStart{Admitted: admitted, Policy: roProbe, Inputs: in, Owner: target}
+ if err := attempts.Reserve(ctx, s, 0); err != nil {
+ t.Fatal(err)
+ }
+ a := attempts.CurrentAttempt(s)
+ exe := hostbox.LaunchFile{Device: 5, Inode: 6}
+ kernel := &launchKernel{path: in.Executable, want: exe, digest: in.ExecutableSHA256}
+ root := &ClaimLaunchRoot{ValidateExecutable: func(string, string, string) error { return nil }, Local: &rev2Local{}, Clock: &rev2Clock{wall: time.Now(), boot: 100}, DataRoot: dataDir, ExecLockDir: t.TempDir(),
+ Attempts: map[string]claimLaunchAttemptReader{hostclaim.KindRelocating: relocationAttemptReader{DataDir: dataDir}},
+ Guard: hostguard.Guard{DataDir: dataDir, LockDir: t.TempDir(), Claims: hostguard.StoreReader{Store: f.claims}},
+ Actor: identity.Verify, Kernel: kernel}
+ configureLaunchParticipation(t, &launchFixture{root: root, peer: peer, target: target, claims: &launchClaims{obs: admitted}})
+ spec := &hostbox.LaunchSpec{Identity: in.Identity, Executable: in.Executable, Digest: in.ExecutableSHA256, Args: in.Args, Env: in.Env}
+ reservation := hostbox.LaunchReservation{ID: a.ID + ":main", Role: "main", InvocationID: a.InvocationID, Inputs: a.LaunchInputs, Target: target, Group: hostbox.LaunchGroup{RelativePath: instancectl.ClaimUnitControlGroup(roHost)}, Executable: exe}
+ q := hostbox.RoleLaunchRequest{V: hostbox.RoleLaunchV, Op: hostbox.RoleLaunchStart, Spec: spec, Reservation: &reservation, Executable: in.Executable, MemoryMax: cgroup.TierDefault.MemoryMax}
+ if err := root.authorize(ctx, peer, q, admitted.Claim); err != nil {
+ t.Fatal("authorize at the install's binding:", err)
+ }
+ roster.sixWrites()
+ if err := root.authorize(ctx, peer, q, admitted.Claim); err != nil {
+ t.Fatal("authorize after six roster writes:", err)
+ }
+ numeral := reservation
+ numeral.Target.DirectoryRevision = fmt.Sprint(roster.read().Roster.Revision)
+ q.Reservation = &numeral
+ if err := root.authorize(ctx, peer, q, admitted.Claim); !errors.Is(err, hostbox.ErrChanged) {
+ t.Fatalf("numeral-stamped target: %v, want ErrChanged", err)
+ }
+ q.Reservation = &reservation
+ roster.quarantine("loss_1")
+ roster.readmit()
+ if err := root.authorize(ctx, peer, q, admitted.Claim); !errors.Is(err, hostbox.ErrChanged) {
+ t.Fatalf("after readmission: %v, want ErrChanged", err)
+ }
+}
+
+// L2, serving handover (claimservinghandover.go validateServingHandover): the
+// prior installation and the successor are both stamped with the binding;
+// after six roster writes the handover runs. A successor stamped with the
+// roster numeral is refused before any successor state.
+func TestClaimBindingServingHandoverSurvivesRosterWrites(t *testing.T) {
+ ctx := t.Context()
+ roster := newBindingRosterFixture(t, "box-1", "ie")
+ identity := roster.identity()
+ actor, err := identity.Verify(ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ f := newServingRootFixtureFor(t, true, actor)
+ f.p.root.InventoryActor = identity.Verify
+ root := servingHandoverRoot(t, f)
+ roster.sixWrites()
+ before := f.f.read()
+ next := hostbox.ColdSuccessor{Host: f.current.Host, Incarnation: f.current.Incarnation, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: fmt.Sprint(roster.read().Roster.Revision), ETag: before.ETag, Generation: f.current.Generation, Stamp: f.current.Stamp, Session: f.current.Session}
+ if err := root.servingHandover().Run(ctx, f.receipt.Target, next); !errors.Is(err, hostbox.ErrChanged) {
+ t.Fatalf("numeral successor: %v, want ErrChanged", err)
+ }
+ if _, err := f.f.guard.Capture(f.current.Host); err != nil {
+ t.Fatal(err)
+ }
+ next.DirectoryRevision = actor.Binding
+ if err := root.servingHandover().Run(ctx, f.receipt.Target, next); err != nil {
+ t.Fatal("serving handover after six roster writes:", err)
+ }
+ installed, err := f.f.guard.Capture(f.current.Host)
+ if err != nil || installed != (hostguard.Captured{Incarnation: f.current.Incarnation, Stamp: f.current.Stamp}) {
+ t.Fatalf("successor installation: %+v %v", installed, err)
+ }
+ in, _, err := root.Reconcile.Inventory.Snapshot(ctx, f.current.Host, installed)
+ if err != nil || in.DirectoryRevision != actor.Binding {
+ t.Fatalf("successor inventory stamp %q: %v", in.DirectoryRevision, err)
+ }
+}
diff --git a/internal/host/claim_binding_test.go b/internal/host/claim_binding_test.go
new file mode 100644
index 000000000..c22c98537
--- /dev/null
+++ b/internal/host/claim_binding_test.go
@@ -0,0 +1,36 @@
+package host
+
+import (
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/hostbox"
+)
+
+// servingPriorBinding is equality with the fresh actor's binding, never an
+// ordering: an older numeral stamp, a stamp from before a readmission, or
+// any stamp against an actor without a binding is refused.
+func TestServingPriorBindingIsEquality(t *testing.T) {
+ b0, b1 := strings.Repeat("a", 64), strings.Repeat("b", 64)
+ actor := hostbox.Actor{Revision: 9, Binding: b0}
+ for _, c := range []struct {
+ recorded string
+ actor hostbox.Actor
+ want bool
+ }{
+ {b0, actor, true},
+ {b0, hostbox.Actor{Revision: 10, Binding: b0}, true},
+ {b1, actor, false},
+ {"9", actor, false},
+ {"8", actor, false},
+ {"1", actor, false},
+ {"", actor, false},
+ {"", hostbox.Actor{Revision: 9}, false},
+ {"9", hostbox.Actor{Revision: 9}, false},
+ {b0 + " ", actor, false},
+ } {
+ if got := servingPriorBinding(c.recorded, c.actor); got != c.want {
+ t.Errorf("servingPriorBinding(%q, %+v) = %v, want %v", c.recorded, c.actor, got, c.want)
+ }
+ }
+}
diff --git a/internal/host/claim_binding_witness_linux_test.go b/internal/host/claim_binding_witness_linux_test.go
new file mode 100644
index 000000000..5dcbce8e4
--- /dev/null
+++ b/internal/host/claim_binding_witness_linux_test.go
@@ -0,0 +1,235 @@
+//go:build linux
+
+package host
+
+import (
+ "context"
+ "os"
+ "path/filepath"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/hostactors"
+ "github.com/carlosframework/platform/internal/hostbox"
+ "github.com/carlosframework/platform/internal/hostclaim"
+ "github.com/carlosframework/platform/internal/hostguard"
+ "github.com/carlosframework/platform/internal/hostwrite"
+ "github.com/carlosframework/platform/internal/park"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+)
+
+// bindingInstallWorld is one box's agent and root halves over one roster: the
+// agent's ReconcileAdapter pinned to a verified actor's binding, installing
+// through the remote journal into root's real commitRootInventory, and root's
+// inventory actor the production identity, fresh on every read (agent mode's
+// actorForRoot).
+type bindingInstallWorld struct {
+ roster *bindingRosterFixture
+ identity hostbox.IdentityProvider
+ f *recoveryFixture
+ rec provision.Record
+ route registry.Route
+ reg *registry.Registry
+ journals *hostbox.JournalService
+ roots map[string]string
+ guard hostguard.Guard
+ rootAuth *hostguard.RootAuthority
+ // rebuilt by pin
+ pinned hostbox.Actor
+ root ClaimRootHTTP
+ census *hostbox.EmptyInstallationCensus
+ adapter hostbox.ReconcileAdapter
+ remote *hostbox.StopInventoryDB
+ source hostbox.WorkSource
+}
+
+func newBindingInstallWorld(t *testing.T) *bindingInstallWorld {
+ t.Helper()
+ w := &bindingInstallWorld{roster: newBindingRosterFixture(t, "box-1", "ie")}
+ w.identity = w.roster.identity()
+ w.f = newRecoveryFixture(t)
+ obs := w.f.read()
+ holder := obs.Claim.Holder
+ w.rec = provision.Record{Schema: 1, Host: obs.Host, Account: holder.Account, App: holder.App, Channel: "stable", CreatedAt: w.f.now}
+ plan14PutRecord(t, w.f.claims, w.rec)
+ w.reg = restartTestRegistry(t)
+ var err error
+ if w.journals, err = hostbox.NewJournalService(w.f.journal); err != nil {
+ t.Fatal(err)
+ }
+ w.rootAuth = hostguard.NewRootAuthority(&rollbackDisk{dir: t.TempDir()})
+ w.roots = map[string]string{"data": w.f.guard.DataDir, "opt": t.TempDir(), "units": t.TempDir()}
+ w.route = registry.Route{Host: w.rec.Host, Account: w.rec.Account, App: w.rec.App, Kind: "instance", DBPath: provision.NestedDBPath(w.f.guard.DataDir, w.rec.Host), Socket: provision.NestedSocket(w.rec.Host)}
+ w.start(t)
+ return w
+}
+
+// start is an agent and root start: Verify once, pin the binding into the
+// agent's adapter and census exactly as ClaimAssembly.Build does
+// (claimassembly.go, Reconcile.DirectoryRevision and the census), and wire
+// root with the fresh production identity.
+func (w *bindingInstallWorld) start(t *testing.T) {
+ t.Helper()
+ pinned, err := w.identity.Verify(t.Context())
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !hostactors.ValidBinding(pinned.Binding) {
+ t.Fatalf("pinned binding %q", pinned.Binding)
+ }
+ w.pinned = pinned
+ rootGuard := w.f.guard
+ rootGuard.Root = w.rootAuth
+ w.census = &hostbox.EmptyInstallationCensus{Inventory: w.journals.Inventory, Registry: w.reg, Launches: w.f.journal, Box: pinned.Box, Enrollment: pinned.Enrollment, DirectoryRevision: pinned.Binding, Roots: w.roots, SharedPaths: map[string][]string{"data": {"hostguard"}}}
+ w.root = ClaimRootHTTP{Journals: w.journals, Launches: w.f.journal, Roots: w.roots, InventoryActor: w.identity.Verify, Reconcile: hostbox.ReconcileAdapter{Registry: w.reg, Inventory: w.journals.Inventory, Census: w.census, Box: pinned.Box, Enrollment: pinned.Enrollment}, Stop: ClaimStopHTTP{Coordinator: ClaimStopCoordinator{Guard: rootGuard, Evidence: w.f.claims}}}
+ root := w.root
+ _, w.remote = hostbox.RemoteJournals(func(ctx context.Context, q hostbox.JournalRequest) (hostbox.JournalResponse, error) {
+ if q.Op == "inventory-write" {
+ return root.commitRootInventory(ctx, q)
+ }
+ return w.journals.Execute(ctx, pinned.Box+"/"+pinned.Enrollment, q)
+ })
+ w.guard = w.f.guard
+ w.guard.FenceView = w.rootAuth.View
+ w.source = hostbox.WorkSource{Guard: w.guard, Box: pinned.Box, Region: "ie", Now: time.Now, Policy: func(context.Context, *hostclaim.Claim, hostbox.Selection, hostwrite.Identity) error { return nil }, Local: func(context.Context, *hostclaim.Claim, hostbox.Selection) error { return nil }}
+ w.adapter = hostbox.ReconcileAdapter{Registry: w.reg, Inventory: w.remote, Box: pinned.Box, Enrollment: pinned.Enrollment, DirectoryRevision: pinned.Binding, Census: w.census, Reconciler: hostbox.Reconciler{Claims: w.f.claims, Guard: w.guard, Box: pinned.Box, Region: "ie", Now: time.Now, Writes: hostwrite.Config{Enabled: true, Selector: w.source}, Local: park.Local{Guard: w.guard, Claims: w.f.claims, DataDir: w.guard.DataDir, Box: pinned.Box}, CheckRecord: func(context.Context, hostbox.RecordSelection) error { return nil }, CheckLocal: func(context.Context, hostclaim.Observed, hostbox.RecordSelection) error { return nil }}}
+}
+
+func (w *bindingInstallWorld) install(t *testing.T) {
+ t.Helper()
+ holder := w.f.read().Claim.Holder
+ ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second)
+ defer cancel()
+ writes := 0
+ err := w.adapter.Install(ctx, provision.ClaimRecord{Host: w.rec.Host, Key: holder.Key, Account: w.rec.Account, App: w.rec.App, Family: "instance", CreatedAt: w.rec.CreatedAt, Value: w.rec, Route: w.route}, func(owner registry.ClaimOwnership) error {
+ writes++
+ w.route.ClaimOwnership = owner
+ return w.reg.Upsert(w.route)
+ })
+ if err != nil || writes != 1 {
+ t.Fatalf("install: %v, effects=%d", err, writes)
+ }
+}
+
+func (w *bindingInstallWorld) inventory(t *testing.T) (hostbox.StopInventory, uint64) {
+ t.Helper()
+ holder := w.f.read().Claim.Holder
+ in, revision, err := w.journals.Inventory.Snapshot(t.Context(), w.rec.Host, hostguard.Captured{Incarnation: holder.Incarnation, Stamp: holder.Stamp})
+ if err != nil {
+ t.Fatal(err)
+ }
+ return in, revision
+}
+
+// L2 and L3 (roster binding): install at the binding B0 through the remote
+// path into root's commitRootInventory, then six real roster writes that move
+// the write counter (hold reserve and release, activation reserve and cancel,
+// an enrollment attempt, a role change). Without a restart (L2), and after
+// the agent and root start again and re-pin (L3), every comparison still
+// passes: the agent's census, a second inventory write through root
+// (prepareStateRemote), the regional and move-park bound identity and
+// VerifyRegional, and Verify's fresh actor is SameBinding with the pin.
+//
+// Root's inventory actor is the fresh production identity, as in agent mode.
+// Instance-control mode's startup-pinned inventory actor becomes fresh in
+// phase B (task 5); L4 covers it there.
+func TestClaimBindingSurvivesRosterWritesWithoutRestart(t *testing.T) {
+ testClaimBindingSurvivesRosterWrites(t, false)
+}
+
+func TestClaimBindingSurvivesRosterWritesAfterRestart(t *testing.T) {
+ testClaimBindingSurvivesRosterWrites(t, true)
+}
+
+func testClaimBindingSurvivesRosterWrites(t *testing.T, restart bool) {
+ ctx := t.Context()
+ w := newBindingInstallWorld(t)
+ b0 := w.pinned.Binding
+ w.install(t)
+ in, revision := w.inventory(t)
+ if in.DirectoryRevision != b0 || revision != 3 {
+ t.Fatalf("installed stamp %q (want the binding %q), inventory revision %d", in.DirectoryRevision, b0, revision)
+ }
+
+ before := w.roster.read().Roster.Revision
+ w.roster.sixWrites()
+ fresh, err := w.identity.Verify(ctx)
+ if err != nil {
+ t.Fatal("Verify after six roster writes:", err)
+ }
+ if fresh.Revision != before+6 || !hostbox.SameBinding(fresh, w.pinned) || fresh.Binding != b0 {
+ t.Fatalf("fresh actor revision %d (pinned %d), binding %q (pinned %q)", fresh.Revision, w.pinned.Revision, fresh.Binding, b0)
+ }
+ pinned := w.pinned
+ if restart {
+ w.start(t)
+ if w.pinned.Binding != b0 || w.pinned.Revision == pinned.Revision {
+ t.Fatalf("restart pinned %q at revision %d", w.pinned.Binding, w.pinned.Revision)
+ }
+ }
+
+ // A create's hold stays held through the comparisons below, as the
+ // create's own hold does while its box installs.
+ held := w.roster.reserveHold()
+ if fresh, err = w.identity.Verify(ctx); err != nil || fresh.Binding != b0 {
+ t.Fatalf("Verify with a hold held: binding %q, %v", fresh.Binding, err)
+ }
+ holder := w.f.read().Claim.Holder
+ if err := w.census.CheckLocal(ctx, w.f.read(), hostbox.RecordSelection{Host: w.rec.Host, Incarnation: holder.Incarnation}); err != nil {
+ t.Fatal("agent census after roster writes:", err)
+ }
+
+ // The second inventory write: state registration through root.
+ if err := os.Mkdir(filepath.Join(w.guard.DataDir, "instances"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ work, err := w.source.Select(ctx, w.rec.Host, "spawn")
+ if err != nil {
+ t.Fatal(err)
+ }
+ roles := &ClaimRoleAssembly{Inventory: w.remote, ManagedRoots: w.roots, Guard: w.guard, Claims: w.f.claims}
+ if err := roles.prepareStateRemote(ctx, w.f.read(), work, ClaimLaunchInputs{DBPath: w.route.DBPath}, fresh); err != nil {
+ t.Fatal("state registration after roster writes:", err)
+ }
+ if in, revision = w.inventory(t); in.DirectoryRevision != b0 || revision != 5 {
+ t.Fatalf("after state registration: stamp %q, revision %d", in.DirectoryRevision, revision)
+ }
+
+ // The regional request store's and the move parks' bound identity, and
+ // the regional enrollment check, against the actor this start pinned.
+ if err := claimBoundIdentity(w.identity.Verify, w.pinned)(ctx); err != nil {
+ t.Fatal("bound identity after roster writes:", err)
+ }
+ if err := (claimRegionalEnrollment{identity: w.identity, actor: w.pinned}).VerifyRegional(ctx, w.pinned.Region, w.pinned.Bucket, hostbox.RequestLimit); err != nil {
+ t.Fatal("VerifyRegional after roster writes:", err)
+ }
+
+ // The hold is released and more writes land: nothing pins the counter.
+ w.roster.releaseHold(held)
+ w.roster.holdChurn()
+ if err := claimBoundIdentity(w.identity.Verify, w.pinned)(ctx); err != nil {
+ t.Fatal("bound identity after a further hold:", err)
+ }
+ if err := w.census.CheckLocal(ctx, w.f.read(), hostbox.RecordSelection{Host: w.rec.Host, Incarnation: holder.Incarnation}); err != nil {
+ t.Fatal("census after a further hold:", err)
+ }
+
+ // A binding change is still refused by the same comparisons: quarantine
+ // and readmission (direct signed write, see readmit) move the binding.
+ w.roster.quarantine("loss_1")
+ w.roster.readmit()
+ readmitted, err := w.identity.Verify(ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if hostbox.SameBinding(readmitted, w.pinned) {
+ t.Fatal("readmitted actor is SameBinding with the startup pin")
+ }
+ if err := claimBoundIdentity(w.identity.Verify, w.pinned)(ctx); err == nil {
+ t.Fatal("bound identity accepted a readmitted box")
+ }
+ if err := (claimRegionalEnrollment{identity: w.identity, actor: w.pinned}).VerifyRegional(ctx, w.pinned.Region, w.pinned.Bucket, hostbox.RequestLimit); err == nil {
+ t.Fatal("VerifyRegional accepted a readmitted box")
+ }
+}
diff --git a/internal/host/claim_evidence_wiring.go b/internal/host/claim_evidence_wiring.go
index 2a9c6b977..e2c15f4ce 100644
--- a/internal/host/claim_evidence_wiring.go
+++ b/internal/host/claim_evidence_wiring.go
@@ -58,7 +58,7 @@ func (owners ClaimOwnerBindings) claimEvidenceCoordinator(ctx context.Context, s
if mode == "instance-control" {
var err error
if owners.cleanupEnrollment != nil {
- if owners.cleanupEnrollment.actor != actor {
+ if !hostbox.SameBinding(owners.cleanupEnrollment.actor, actor) {
return nil, ErrClaimStopIdentity
}
err = owners.cleanupEnrollment.configureSigner(ctx, stop, owners.EvidenceKey)
diff --git a/internal/host/claim_regional_revision_test.go b/internal/host/claim_regional_revision_test.go
index d823d7da5..bb4cf4d45 100644
--- a/internal/host/claim_regional_revision_test.go
+++ b/internal/host/claim_regional_revision_test.go
@@ -6,7 +6,6 @@ import (
"errors"
"os"
"path/filepath"
- "reflect"
"strings"
"testing"
@@ -16,48 +15,6 @@ import (
"github.com/carlosframework/platform/internal/release"
)
-// Every actor field but the roster-wide Revision is part of the enrollment
-// a built assembly is bound to. The reflection walk covers fields added later.
-func TestSameVerifiedActorIgnoresOnlyRevision(t *testing.T) {
- base := hostbox.Actor{FleetHomeRegion: "ie", HomeRegion: "ie", ControlBucket: "deployment", Box: "box", Enrollment: strings.Repeat("a", 32), Revision: 7, Region: "ie", Bucket: "data", Namespace: "platform", Cloud: hostbox.CloudIdentity{Provider: "aws", Account: "111122223333", Region: "eu-west-1", InstanceID: "i-0abc"}, Eligible: true, Binding: "binding"}
- var walk func(v reflect.Value, path string)
- walk = func(v reflect.Value, path string) {
- for i := 0; i < v.NumField(); i++ {
- f, name := v.Field(i), path+v.Type().Field(i).Name
- if f.Kind() == reflect.Struct {
- walk(f, name+".")
- continue
- }
- changed := base
- field := reflect.ValueOf(&changed).Elem().FieldByIndex(fieldIndex(reflect.TypeOf(base), name))
- switch field.Kind() {
- case reflect.String:
- field.SetString(field.String() + "-changed")
- case reflect.Uint64:
- field.SetUint(field.Uint() + 1)
- case reflect.Bool:
- field.SetBool(!field.Bool())
- default:
- t.Fatalf("%s: unhandled kind %s", name, field.Kind())
- }
- if got, want := sameVerifiedActor(changed, base), name == "Revision"; got != want {
- t.Errorf("%s changed: same = %v, want %v", name, got, want)
- }
- }
- }
- walk(reflect.ValueOf(base), "")
-}
-
-func fieldIndex(t reflect.Type, path string) []int {
- var index []int
- for _, name := range strings.Split(path, ".") {
- f, _ := t.FieldByName(name)
- index = append(index, f.Index...)
- t = f.Type
- }
- return index
-}
-
// The regional enrollment check runs on the production roster adapter: a
// roster revision bump (a create's actor hold is one) passes, and a
// quarantine and readmission since startup still refuses.
@@ -75,7 +32,7 @@ func TestClaimRegionalEnrollmentSurvivesRosterRevision(t *testing.T) {
if err := os.WriteFile(filepath.Join(dir, "policy.json"), body, 0600); err != nil {
t.Fatal(err)
}
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: strings.Repeat("a", 32), Region: "ie", ControlBucket: bucket, Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: strings.Repeat("a", 32), Region: "ie", ControlBucket: bucket, Revision: 1, Binding: "1"})
row := hostactors.Box{BoxID: "box", Enrollment: strings.Repeat("a", 32), Namespace: identity.Namespace, Label: "box", Region: "ie", Pool: "default", Cloud: hostactors.Cloud{Provider: "aws", Account: identity.Account, Region: identity.AWSRegion, InstanceID: "i-0abc"}, EvidenceSHA256: strings.Repeat("c", 64), State: "active"}
roster := hostactors.Roster{V: 1, DeploymentBucket: bucket, Revision: 1, RequestLimitNS: int64(hostbox.RequestLimit), Publication: "published", FloorSHA256: hostfloor.Digest(raw), Boxes: map[string]hostactors.Box{"box": row}, Consoles: map[string]hostactors.Console{}, Holds: map[string]hostactors.Reservation{}, Activations: map[string]hostactors.Reservation{}}
write := func() {
@@ -122,7 +79,7 @@ func TestClaimRegionalEnrollmentSurvivesRosterRevision(t *testing.T) {
// Each enrollment field the roster carries still refuses when it changes
// under a running assembly; only the revision bump passes.
func TestClaimRegionalEnrollmentFieldChanges(t *testing.T) {
- base := hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "region", FleetHomeRegion: "region", ControlBucket: "control", Revision: 1}
+ base := hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "region", FleetHomeRegion: "region", ControlBucket: "control", Revision: 1, Binding: "1"}
identity := handoverRecoveryIdentity(t, base)
actor, err := identity.Verify(t.Context())
if err != nil {
diff --git a/internal/host/claimassembly.go b/internal/host/claimassembly.go
index 4b1984cca..3dd372f7f 100644
--- a/internal/host/claimassembly.go
+++ b/internal/host/claimassembly.go
@@ -176,8 +176,8 @@ func (a ClaimAssembly) Build(ctx context.Context) (ClaimProviders, error) {
a.Reconcile.Reconciler.Local = park.Local{Guard: a.Guard, Claims: a.Claims, DataDir: a.Guard.DataDir, Box: actor.Box}
a.Reconcile.Box = actor.Box
a.Reconcile.Enrollment = actor.Enrollment
- a.Reconcile.DirectoryRevision = fmt.Sprint(actor.Revision)
- census := &hostbox.EmptyInstallationCensus{Inventory: a.Reconcile.Inventory, Registry: a.Reconcile.Registry, Launches: a.Launches, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: fmt.Sprint(actor.Revision), Roots: a.ManagedRoots, SharedPaths: a.SharedPaths}
+ a.Reconcile.DirectoryRevision = actor.Binding
+ census := &hostbox.EmptyInstallationCensus{Inventory: a.Reconcile.Inventory, Registry: a.Reconcile.Registry, Launches: a.Launches, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: actor.Binding, Roots: a.ManagedRoots, SharedPaths: a.SharedPaths}
a.Reconcile.Census = census
a.Reconcile.Reconciler.CheckLocal = census.CheckLocal
a.Reconcile.Stop = a.collectRetirementStop
@@ -286,25 +286,12 @@ func (e claimRegionalEnrollment) VerifyRegional(ctx context.Context, region, buc
if err != nil {
return err
}
- if !sameVerifiedActor(a, e.actor) || !park.SameRegion(a.HomeRegion, park.PlacementRegion(a.Region), region) || a.Bucket != bucket {
+ if !hostbox.SameBinding(a, e.actor) || !park.SameRegion(a.HomeRegion, park.PlacementRegion(a.Region), region) || a.Bucket != bucket {
return hostbox.ErrChanged
}
return nil
}
-// sameVerifiedActor reports whether a freshly verified actor is still the
-// enrollment the regional worker was built for. Every field must match except the
-// roster-wide Revision, which every roster write bumps, a create's own actor
-// hold among them; pinning it stopped the regional worker at the first
-// create after each agent start. What the startup pin protected stays
-// explicit: Verify refuses an ineligible, quarantined, fenced or retired
-// row, and QuarantineRevision only grows, so a box quarantined and readmitted
-// since startup still never matches its startup actor.
-func sameVerifiedActor(current, expected hostbox.Actor) bool {
- current.Revision, expected.Revision = 0, 0
- return current == expected
-}
-
func productionClaimFactory(ctx context.Context) (ClaimProviders, error) {
entry, _ := ctx.Value(claimEntryKey{}).(claimEntry)
if entry.Store == nil {
@@ -378,7 +365,7 @@ func NewProductionRootClaimStop(ctx context.Context) (http.Handler, error) {
}
reconcile := *assembly.Reconcile
reconcile.Box, reconcile.Enrollment = actor.Box, actor.Enrollment
- reconcile.Census = &hostbox.EmptyInstallationCensus{Inventory: assembly.Reconcile.Inventory, Registry: assembly.Reconcile.Registry, Launches: assembly.Launches, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: fmt.Sprint(actor.Revision), Roots: assembly.ManagedRoots, SharedPaths: assembly.SharedPaths}
+ reconcile.Census = &hostbox.EmptyInstallationCensus{Inventory: assembly.Reconcile.Inventory, Registry: assembly.Reconcile.Registry, Launches: assembly.Launches, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: actor.Binding, Roots: assembly.ManagedRoots, SharedPaths: assembly.SharedPaths}
root := ClaimRootHTTP{inventoryIdentity: rootstate.ObjectIdentity, InventoryActor: assembly.actorForRoot, Journals: assembly.Journals, RequireNewWork: func(ctx context.Context) error { _, err := assembly.Identity.Verify(ctx); return err }, Launches: assembly.Launches, Stop: stop, Reconcile: reconcile, Roots: assembly.ManagedRoots}
state, err := openClaimExecutionAuthority()
if err != nil {
diff --git a/internal/host/claimconstruction.go b/internal/host/claimconstruction.go
index e9c6f08ee..dfc7bc189 100644
--- a/internal/host/claimconstruction.go
+++ b/internal/host/claimconstruction.go
@@ -12,7 +12,6 @@ import (
"log"
"os"
"path/filepath"
- "strconv"
"strings"
"sync"
"time"
@@ -324,7 +323,7 @@ func OpenProductionClaimAssembly(ctx context.Context, store release.Store, r Cla
return nil, hostwrite.ErrUnavailable
}
h := o.Claim.Holder
- target := hostguard.FenceTarget{Host: o.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Session: h.Session, Op: o.Claim.Op.ID, Phase: o.Claim.Op.Phase, Box: actor.Box, Region: actor.Region, Enrollment: actor.Enrollment, BootID: strings.TrimSpace(string(boot)), ControllerID: controller, ClaimETag: o.ETag, DirectoryRevision: strconv.FormatUint(actor.Revision, 10)}
+ target := hostguard.FenceTarget{Host: o.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Session: h.Session, Op: o.Claim.Op.ID, Phase: o.Claim.Op.Phase, Box: actor.Box, Region: actor.Region, Enrollment: actor.Enrollment, BootID: strings.TrimSpace(string(boot)), ControllerID: controller, ClaimETag: o.ETag, DirectoryRevision: actor.Binding}
return producers.Ensure(target, processStart, launches.RecordProducer, launches.CompleteProducer)
}
wake.Roles = &ClaimRoleAssembly{Guard: guard, Claims: store, Manager: r.Manager, Journal: launches, Inventory: inventory, ManagedRoots: roots, Identity: owners.Identity, BootID: strings.TrimSpace(string(boot)), ControllerID: controller}
diff --git a/internal/host/claimfilesseed_cli_rootrunner_linux_test.go b/internal/host/claimfilesseed_cli_rootrunner_linux_test.go
index e079bfd05..612b71f38 100644
--- a/internal/host/claimfilesseed_cli_rootrunner_linux_test.go
+++ b/internal/host/claimfilesseed_cli_rootrunner_linux_test.go
@@ -304,7 +304,7 @@ func TestFilesSeedCLIStopFixture(t *testing.T) {
c.RetainNoProcess = f.p.retainLegacyNoProcess
o := f.f.read()
h := o.Claim.Holder
- req := StopRequest{Region: f.actor.Region, Host: o.Host, Incarnation: h.Incarnation, InstallationStamp: h.Stamp, Box: f.actor.Box, Enrollment: f.actor.Enrollment, BootID: f.f.peer.BootID, ControllerID: f.f.peer.ControllerID, ExpectedClaimETag: o.ETag, ExpectedDirectoryRevision: strconv.FormatUint(f.actor.Revision, 10)}
+ req := StopRequest{Region: f.actor.Region, Host: o.Host, Incarnation: h.Incarnation, InstallationStamp: h.Stamp, Box: f.actor.Box, Enrollment: f.actor.Enrollment, BootID: f.f.peer.BootID, ControllerID: f.f.peer.ControllerID, ExpectedClaimETag: o.ETag, ExpectedDirectoryRevision: f.actor.Binding}
if _, err := c.FenceAndStop(t.Context(), req); err != nil {
t.Fatal("CLI fixture no-process", err)
}
diff --git a/internal/host/claimfilesseed_recovery_linux_test.go b/internal/host/claimfilesseed_recovery_linux_test.go
index 9f5d136d4..94a4bdeed 100644
--- a/internal/host/claimfilesseed_recovery_linux_test.go
+++ b/internal/host/claimfilesseed_recovery_linux_test.go
@@ -12,7 +12,7 @@ import (
)
func TestServingParkIncompleteRecoveryRechecksEnrollment(t *testing.T) {
- for _, change := range []string{"enrollment", "revision"} {
+ for _, change := range []string{"enrollment", "binding"} {
t.Run(change, func(t *testing.T) {
f := newServingRootFixture(t, true)
a, err := f.park()
@@ -28,7 +28,7 @@ func TestServingParkIncompleteRecoveryRechecksEnrollment(t *testing.T) {
if change == "enrollment" {
f.actor.Enrollment = "new-enrollment"
} else {
- f.actor.Revision++
+ f.actor.Binding = "8"
}
// Reconstruct the authority object, retaining only durable journals.
root := &servingParkRoot{root: f.p.root, ledger: &servingParkLedger{state: f.p.ledger.state, fs: f.p.ledger.fs, journal: f.f.journal, now: f.p.ledger.now}}
diff --git a/internal/host/claimfilesseed_select.go b/internal/host/claimfilesseed_select.go
index 039072395..805f2ce63 100644
--- a/internal/host/claimfilesseed_select.go
+++ b/internal/host/claimfilesseed_select.go
@@ -35,7 +35,7 @@ func inspectFilesSeed(ctx context.Context, claims release.Store, f *movesFiles,
}
out.Observation = o
out.State = "blocked"
- if ctx == nil || claims == nil || f == nil || f.Data == nil || f.EnvFile == nil || !actor.Eligible || actor.Quarantined || actor.Enrollment == "" || actor.Revision == 0 || actor.Box != f.Box || actor.Bucket != f.Bucket || !regionname.SameRegion(f.HomeRegion, actor.Region, f.Region) {
+ if ctx == nil || claims == nil || f == nil || f.Data == nil || f.EnvFile == nil || !actor.Eligible || actor.Quarantined || actor.Enrollment == "" || actor.Revision == 0 || actor.Binding == "" || actor.Box != f.Box || actor.Bucket != f.Bucket || !regionname.SameRegion(f.HomeRegion, actor.Region, f.Region) {
return out, hostbox.ErrUnsupported
}
check := func() error {
diff --git a/internal/host/claimfilesseed_select_linux_test.go b/internal/host/claimfilesseed_select_linux_test.go
index 86aa948c6..76a3f5803 100644
--- a/internal/host/claimfilesseed_select_linux_test.go
+++ b/internal/host/claimfilesseed_select_linux_test.go
@@ -54,7 +54,7 @@ func newFilesSeedFixture(t *testing.T) *filesSeedFixture {
t.Fatal(err)
}
f := &movesFiles{Files: casBucketStore{b: data, bucket: "data"}, Data: data, Bucket: "data", Box: "box-1", Region: "ie", HomeRegion: "ie", DataDir: dir, EnvFile: claimEnvFileFor(dir, testClaimRoutes{rows: map[string]registry.Route{filesHost: rt}}), Proof: ClaimOriginProof{Claims: claims, HomeRegion: "ie", Region: "ie"}}
- return &filesSeedFixture{t: t, claims: claims, data: data, files: f, route: rt, observed: o, actor: hostbox.Actor{Box: "box-1", Region: "ie", HomeRegion: "ie", Bucket: "data", Enrollment: "enrolled", Revision: 1, Eligible: true}}
+ return &filesSeedFixture{t: t, claims: claims, data: data, files: f, route: rt, observed: o, actor: hostbox.Actor{Box: "box-1", Region: "ie", HomeRegion: "ie", Bucket: "data", Enrollment: "enrolled", Revision: 1, Binding: "1", Eligible: true}}
}
func (f *filesSeedFixture) admit(gen string) {
f.t.Helper()
diff --git a/internal/host/claimhandover_recovery.go b/internal/host/claimhandover_recovery.go
index fd3a4b8c9..de4740835 100644
--- a/internal/host/claimhandover_recovery.go
+++ b/internal/host/claimhandover_recovery.go
@@ -221,7 +221,7 @@ func (h claimCrossBoxHandover) installRecoveryInventory(ctx context.Context, pri
owner := hex.EncodeToString(sum[:])
current, err := h.Inventory.ReadInstallation(ctx, prior.Host, next.Incarnation, next.Stamp)
if err == nil {
- if !current.Complete || current.Box != actor.Box || current.Enrollment != actor.Enrollment || current.DirectoryRevision != fmt.Sprint(actor.Revision) {
+ if !current.Complete || current.Box != actor.Box || current.Enrollment != actor.Enrollment || current.DirectoryRevision != actor.Binding {
return hostbox.ErrTypedInventory
}
if h.Registry == nil {
@@ -240,7 +240,7 @@ func (h claimCrossBoxHandover) installRecoveryInventory(ctx context.Context, pri
if !errors.Is(err, sql.ErrNoRows) {
return err
}
- inv.InstallationStamp, inv.DirectoryRevision = next.Stamp, fmt.Sprint(actor.Revision)
+ inv.InstallationStamp, inv.DirectoryRevision = next.Stamp, actor.Binding
if err := h.rebindRecoveryRows(ctx, &inv, stamp, owner); err != nil {
return err
}
diff --git a/internal/host/claimhandover_recovery_test.go b/internal/host/claimhandover_recovery_test.go
index 809ca67e6..6c0870b8c 100644
--- a/internal/host/claimhandover_recovery_test.go
+++ b/internal/host/claimhandover_recovery_test.go
@@ -209,7 +209,7 @@ func TestClaimColdHandoverAfterControllerRecoveryReachesNextWake(t *testing.T) {
hook := coldAdmissionHook(f.guard, handoverRecoveryIdentity(t, restarted.local.Actor), socket)
restarted.wake.AfterAdmission = func(ctx context.Context, before, after hostclaim.Observed) error {
h := after.Claim.Holder
- request := coldHandoverRequest{Prior: receipt.Target, Next: hostbox.ColdSuccessor{Host: after.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Session: h.Session, Generation: h.Generation, Box: "box-1", Enrollment: "enrollment-1", DirectoryRevision: "8", ETag: after.ETag, Op: after.Claim.Op.ID, Phase: after.Claim.Op.Phase}}
+ request := coldHandoverRequest{Prior: receipt.Target, Next: hostbox.ColdSuccessor{Host: after.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Session: h.Session, Generation: h.Generation, Box: "box-1", Enrollment: "enrollment-1", DirectoryRevision: recoveryFixtureBinding, ETag: after.ETag, Op: after.Claim.Op.ID, Phase: after.Claim.Op.Phase}}
if status := postRecoveryHandover(t, refusedSocket, request); status != http.StatusForbidden {
t.Fatalf("receipt authenticated an unknown requester: %d", status)
}
@@ -269,7 +269,7 @@ func TestClaimColdHandoverAfterControllerRecoveryReachesNextWake(t *testing.T) {
t.Fatalf("handover rewrote predecessor evidence: %+v %v", replayed, err)
}
launch, err := f.journal.Read(ctx, recoveryTuple(next, restarted.local))
- if err != nil || launch.ControllerPID != 4202 || launch.ProcessStart != "start-2" || launch.Target.DirectoryRevision != fmt.Sprint(f.revision) {
+ if err != nil || launch.ControllerPID != 4202 || launch.ProcessStart != "start-2" || launch.Target.DirectoryRevision != recoveryFixtureBinding {
t.Fatalf("next wake launch tuple: %+v %v", launch, err)
}
})
diff --git a/internal/host/claimhandover_transport.go b/internal/host/claimhandover_transport.go
index 7d1e6d8f6..1b1c891c1 100644
--- a/internal/host/claimhandover_transport.go
+++ b/internal/host/claimhandover_transport.go
@@ -4,7 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
- "fmt"
"io"
"net"
"net/http"
@@ -107,7 +106,7 @@ func coldHandoverWith(identity hostbox.IdentityProvider, socket string, find fun
if err != nil {
return err
}
- request := coldHandoverRequest{Prior: receipt.Target, Next: hostbox.ColdSuccessor{Host: admitted.Host, Incarnation: next.Incarnation, Stamp: next.Stamp, Session: next.Session, Generation: next.Generation, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: fmt.Sprint(actor.Revision), ETag: admitted.ETag, Op: admitted.Claim.Op.ID, Phase: admitted.Claim.Op.Phase}}
+ request := coldHandoverRequest{Prior: receipt.Target, Next: hostbox.ColdSuccessor{Host: admitted.Host, Incarnation: next.Incarnation, Stamp: next.Stamp, Session: next.Session, Generation: next.Generation, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: actor.Binding, ETag: admitted.ETag, Op: admitted.Claim.Op.ID, Phase: admitted.Claim.Op.Phase}}
body, err := json.Marshal(request)
if err != nil {
return err
diff --git a/internal/host/claimlaunch_authority.go b/internal/host/claimlaunch_authority.go
index 45aa0e48c..129d6fe4c 100644
--- a/internal/host/claimlaunch_authority.go
+++ b/internal/host/claimlaunch_authority.go
@@ -5,7 +5,6 @@ import (
"errors"
"github.com/carlosframework/platform/internal/park"
"path/filepath"
- "strconv"
"time"
"github.com/carlosframework/platform/internal/activator"
@@ -79,7 +78,7 @@ func (h *ClaimLaunchRoot) authorize(ctx context.Context, peer StopPeer, q hostbo
if err != nil {
return err
}
- if !actor.Eligible || actor.Quarantined || actor.Box != t.Box || actor.Enrollment != t.Enrollment || actor.Region != t.Region || strconv.FormatUint(actor.Revision, 10) != t.DirectoryRevision {
+ if !actor.Eligible || actor.Quarantined || actor.Box != t.Box || actor.Enrollment != t.Enrollment || actor.Region != t.Region || actor.Binding == "" || actor.Binding != t.DirectoryRevision {
return hostbox.ErrChanged
}
if c == nil || c.Host != t.Host {
diff --git a/internal/host/claimlaunch_root.go b/internal/host/claimlaunch_root.go
index 866ababad..f64f98684 100644
--- a/internal/host/claimlaunch_root.go
+++ b/internal/host/claimlaunch_root.go
@@ -213,7 +213,7 @@ func (h *ClaimLaunchRoot) startRecorded(ctx context.Context, peer StopPeer, q ho
if err != nil {
return hostbox.RoleLaunchGrant{}, err
}
- if actor.Quarantined || actor.Box != t.Box || actor.Enrollment != t.Enrollment || actor.Region != t.Region || strconv.FormatUint(actor.Revision, 10) != t.DirectoryRevision {
+ if actor.Quarantined || actor.Box != t.Box || actor.Enrollment != t.Enrollment || actor.Region != t.Region || actor.Binding == "" || actor.Binding != t.DirectoryRevision {
return hostbox.RoleLaunchGrant{}, hostbox.ErrChanged
}
if err = h.Kernel.Verify(q.Executable, r.Executable); err != nil {
diff --git a/internal/host/claimlaunch_root_test.go b/internal/host/claimlaunch_root_test.go
index 5e468eff0..ef7a4f2f8 100644
--- a/internal/host/claimlaunch_root_test.go
+++ b/internal/host/claimlaunch_root_test.go
@@ -167,7 +167,7 @@ func newLaunchFixtureHost(t *testing.T, op hostclaim.Op, host string) *launchFix
if err = journal.Prelaunch(t.Context(), hostbox.LaunchInventory{ControllerPID: os.Getpid(), ProcessStart: start, Target: target, Groups: []hostbox.LaunchGroup{{RelativePath: filepath.Join("system.slice/carlos-edge.service", cgroup.ExecName(claimContainmentName(target))), Device: 1, Inode: 9}}, NoState: true}); err != nil {
t.Fatal(err)
}
- actor := &hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7, Region: "eu", Eligible: true}
+ actor := &hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7, Binding: "7", Region: "eu", Eligible: true}
exe := hostbox.LaunchFile{Device: 5, Inode: 6}
units := &launchUnits{started: instancectl.ClaimUnitStarted{Unit: instancectl.UnitName(instancectl.RoleRun, host), InvocationID: "unit-inv-1", ControlGroup: instancectl.ClaimUnitControlGroup(host), MainPID: 4242}}
kernel := &launchKernel{path: "/opt/carlos/versions/v1/app", want: exe, observed: ClaimLaunchObserved{ProcessStart: "ps-4242", TenantPID: 4243, TenantStart: "ps-4243", Group: hostbox.LaunchFile{Device: 3, Inode: 4}, Executable: exe}}
@@ -248,7 +248,7 @@ func TestClaimLaunchRootTrustsOnlyItsOwnProviders(t *testing.T) {
"restarted controller": func(f *launchFixture) { f.peer.ProcessStart = "start-43" },
"roster box": func(f *launchFixture) { f.actor.Box = "box-2" },
"roster enrollment": func(f *launchFixture) { f.actor.Enrollment = "enrollment-2" },
- "roster revision": func(f *launchFixture) { f.actor.Revision = 8 },
+ "box binding": func(f *launchFixture) { f.actor.Binding = "8" },
"roster region": func(f *launchFixture) { f.actor.Region = "us" },
"quarantined box": func(f *launchFixture) { f.actor.Quarantined = true },
"holder session": func(f *launchFixture) { f.claims.set(func(c *hostclaim.Claim) { c.Holder.Session = 14 }) },
diff --git a/internal/host/claimmoveparks.go b/internal/host/claimmoveparks.go
index cf3c9997c..263a86c12 100644
--- a/internal/host/claimmoveparks.go
+++ b/internal/host/claimmoveparks.go
@@ -94,7 +94,8 @@ func refusingClaimMoveWake(box string, store release.Store, reason error) *activ
}
// claimBoundIdentity pins the entire verified enrollment, including its cloud
-// instance, buckets, namespace and directory revision, for a built assembly.
+// instance, buckets, namespace and binding, for a built assembly. The roster
+// write counter is not pinned: holds and other boxes' rows move it.
func claimBoundIdentity(verify func(context.Context) (hostbox.Actor, error), expected hostbox.Actor) func(context.Context) error {
return func(ctx context.Context) error {
if ctx == nil || verify == nil || expected.Enrollment == "" {
@@ -104,7 +105,7 @@ func claimBoundIdentity(verify func(context.Context) (hostbox.Actor, error), exp
if err != nil {
return err
}
- if current != expected {
+ if !hostbox.SameBinding(current, expected) {
return hostbox.ErrChanged
}
return nil
diff --git a/internal/host/claimmoveparks_test.go b/internal/host/claimmoveparks_test.go
index f3800c30b..3e865c9de 100644
--- a/internal/host/claimmoveparks_test.go
+++ b/internal/host/claimmoveparks_test.go
@@ -106,7 +106,7 @@ func TestMoveParksWakeFailureRemainsWakeRefusal(t *testing.T) {
}
func TestMoveParksVerifiedIdentityAndRealEngine(t *testing.T) {
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "region", ControlBucket: "control", Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "region", ControlBucket: "control", Revision: 1, Binding: "1"})
actor, err := identity.Verify(t.Context())
if err != nil {
t.Fatal(err)
@@ -126,7 +126,7 @@ func TestMoveParksVerifiedIdentityAndRealEngine(t *testing.T) {
if names, err := leases(t.Context(), actor.Bucket, "scope"); err != nil || len(names) != 1 || names[0] != "real lease" {
t.Fatal("leases replaced")
}
- mutations := map[string]func(*hostbox.Actor){"enrollment": func(a *hostbox.Actor) { a.Enrollment = "new" }, "instance": func(a *hostbox.Actor) { a.Cloud.InstanceID = "new" }, "control bucket": func(a *hostbox.Actor) { a.ControlBucket = "new" }, "data bucket": func(a *hostbox.Actor) { a.Bucket = "new" }, "namespace": func(a *hostbox.Actor) { a.Namespace = "new" }, "revision": func(a *hostbox.Actor) { a.Revision++ }, "account": func(a *hostbox.Actor) { a.Cloud.Account = "new" }}
+ mutations := map[string]func(*hostbox.Actor){"enrollment": func(a *hostbox.Actor) { a.Enrollment = "new" }, "instance": func(a *hostbox.Actor) { a.Cloud.InstanceID = "new" }, "control bucket": func(a *hostbox.Actor) { a.ControlBucket = "new" }, "data bucket": func(a *hostbox.Actor) { a.Bucket = "new" }, "namespace": func(a *hostbox.Actor) { a.Namespace = "new" }, "binding": func(a *hostbox.Actor) { a.Binding += "-changed" }, "account": func(a *hostbox.Actor) { a.Cloud.Account = "new" }}
for name, mutate := range mutations {
t.Run(name, func(t *testing.T) {
changed := actor
@@ -137,6 +137,16 @@ func TestMoveParksVerifiedIdentityAndRealEngine(t *testing.T) {
}
})
}
+ // The roster write counter is not part of the bound identity: holds and
+ // other boxes' rows move it without changing this box's binding.
+ t.Run("revision", func(t *testing.T) {
+ changed := actor
+ changed.Revision++
+ providers.moveParks.check = claimBoundIdentity(func(context.Context) (hostbox.Actor, error) { return changed, nil }, actor)
+ if _, _, _, err := providers.MoveParks(t.Context()); err != nil {
+ t.Fatalf("roster revision bump refused: %v", err)
+ }
+ })
if _, _, _, err := (ClaimProviders{}).MoveParks(t.Context()); !errors.Is(err, hostwrite.ErrUnavailable) {
t.Fatal("unbuilt accessor accepted")
}
@@ -159,7 +169,7 @@ func TestMoveParksBuildWithFailedWakeUsesRegionalEngine(t *testing.T) {
}
defer inventory.Close()
store := release.NewDirStore(filepath.Join(base, "store"))
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "region", ControlBucket: "control", Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "region", ControlBucket: "control", Revision: 1, Binding: "1"})
actor, err := identity.Verify(ctx)
if err != nil {
t.Fatal(err)
diff --git a/internal/host/claimordinaryparks_linux_test.go b/internal/host/claimordinaryparks_linux_test.go
index 1916b1885..2fe41addf 100644
--- a/internal/host/claimordinaryparks_linux_test.go
+++ b/internal/host/claimordinaryparks_linux_test.go
@@ -39,7 +39,7 @@ func TestPlan14OrdinaryGenerationParks(t *testing.T) {
if ob.ID == "" {
t.Fatal("missing publication obligation")
}
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment", Revision: 7, Region: "ie", FleetHomeRegion: "ie"})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment", Revision: 7, Binding: "7", Region: "ie", FleetHomeRegion: "ie"})
identity.HomeRegion = "ie"
if tc == "foreign-enrollment" {
receipt.Target.Enrollment = "another-enrollment"
@@ -194,7 +194,7 @@ func TestPlan14OrdinaryRetirementRequiresProof(t *testing.T) {
t.Run(target, func(t *testing.T) {
f, _, _, in := servingRetirementFixture(t)
o := servingAdmit(t, f, &in, "G")
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment", Revision: 7, Region: "ie", FleetHomeRegion: "ie"})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment", Revision: 7, Binding: "7", Region: "ie", FleetHomeRegion: "ie"})
identity.HomeRegion = "ie"
data := leasetest.NewVersionedBucket()
data.AddBucket("data")
@@ -228,7 +228,7 @@ func TestPlan14OrdinaryRetirementRequiresProof(t *testing.T) {
func TestPlan14OrdinaryParkView(t *testing.T) {
f, _, _, in := servingRetirementFixture(t)
o := servingAdmit(t, f, &in, "G")
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment", Revision: 7, Region: "ie", FleetHomeRegion: "ie"})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment", Revision: 7, Binding: "7", Region: "ie", FleetHomeRegion: "ie"})
identity.HomeRegion = "ie"
data := leasetest.NewVersionedBucket()
data.AddBucket("data")
diff --git a/internal/host/claimrecovery_remote.go b/internal/host/claimrecovery_remote.go
index 9f01cc353..f549b9aa6 100644
--- a/internal/host/claimrecovery_remote.go
+++ b/internal/host/claimrecovery_remote.go
@@ -2,7 +2,6 @@ package host
import (
"context"
- "fmt"
"reflect"
"strconv"
@@ -51,7 +50,7 @@ func (h claimCrossBoxHandover) installRecoveryRemote(ctx context.Context, prior,
if err != nil {
return err
}
- q = recoveryRebindRequest{V: 1, Prior: captured, Revision: revision, RecordKey: next.Key, RecordETag: etag, Next: hostbox.ColdSuccessor{Host: admitted.Host, Incarnation: next.Incarnation, Stamp: next.Stamp, Session: next.Session, Generation: next.Generation, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: fmt.Sprint(actor.Revision), ETag: admitted.ETag, Op: admitted.Claim.Op.ID, Phase: admitted.Claim.Op.Phase}}
+ q = recoveryRebindRequest{V: 1, Prior: captured, Revision: revision, RecordKey: next.Key, RecordETag: etag, Next: hostbox.ColdSuccessor{Host: admitted.Host, Incarnation: next.Incarnation, Stamp: next.Stamp, Session: next.Session, Generation: next.Generation, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: actor.Binding, ETag: admitted.ETag, Op: admitted.Claim.Op.ID, Phase: admitted.Claim.Op.Phase}}
return nil
})
if err != nil {
diff --git a/internal/host/claimretryrecovery_test.go b/internal/host/claimretryrecovery_test.go
index e849a7250..09429886f 100644
--- a/internal/host/claimretryrecovery_test.go
+++ b/internal/host/claimretryrecovery_test.go
@@ -237,7 +237,13 @@ func (f *recoveryFixture) retry() hostclaim.WakeRetry {
func recoveryTuple(o hostclaim.Observed, l claimStopLocal) hostguard.FenceTarget {
h := o.Claim.Holder
- return hostguard.FenceTarget{Region: l.Actor.Region, Host: o.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Session: h.Session, Box: l.Actor.Box, Enrollment: l.Actor.Enrollment, BootID: l.BootID, ControllerID: l.ControllerID, ClaimETag: o.ETag, DirectoryRevision: fmt.Sprint(l.Actor.Revision)}
+ // Fixture actors without a binding stamp their numeral (the shorthand of
+ // handoverRecoveryIdentity); a production actor stamps its binding.
+ stamp := l.Actor.Binding
+ if stamp == "" {
+ stamp = fmt.Sprint(l.Actor.Revision)
+ }
+ return hostguard.FenceTarget{Region: l.Actor.Region, Host: o.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Session: h.Session, Box: l.Actor.Box, Enrollment: l.Actor.Enrollment, BootID: l.BootID, ControllerID: l.ControllerID, ClaimETag: o.ETag, DirectoryRevision: stamp}
}
// root is instance-control's coordinator for one request. The live peer is
@@ -258,6 +264,11 @@ func (f *recoveryFixture) root(drain StopDrainer) ClaimStopCoordinator {
// controller starts one agent process: its own wake assembly, retries and stop
// path, sharing the durable claim, guard and launch journal of the box.
+// recoveryFixtureBinding is the fixture box's binding (shorthand "7"). A
+// controller started after a roster write (f.revision) keeps it: roster
+// writes move the counter, not the box's binding.
+const recoveryFixtureBinding = "7"
+
func (f *recoveryFixture) controller(boot, controller string, pid int, start string) *recoveryController {
t := f.t
revision := f.revision
@@ -265,7 +276,7 @@ func (f *recoveryFixture) controller(boot, controller string, pid int, start str
revision = 7
}
box, enrollment, region, leaseRegion := f.identity()
- local := claimStopLocal{Actor: hostbox.Actor{Box: box, Enrollment: enrollment, Revision: revision, Region: region, HomeRegion: f.homeRegion, FleetHomeRegion: f.fleetHomeRegion}, BootID: boot, ControllerID: controller, PID: pid, ProcessStart: start}
+ local := claimStopLocal{Actor: hostbox.Actor{Box: box, Enrollment: enrollment, Revision: revision, Binding: recoveryFixtureBinding, Region: region, HomeRegion: f.homeRegion, FleetHomeRegion: f.fleetHomeRegion}, BootID: boot, ControllerID: controller, PID: pid, ProcessStart: start}
f.peer = StopPeer{UID: 1001, PID: pid, ProcessStart: start, BootID: boot, ControllerID: controller}
producers := &ClaimProducerSet{}
w := &ClaimWakeAssembly{LeaseRegion: leaseRegion, Inputs: recoveryInputs{f}, Manager: new(cgroup.Manager)}
diff --git a/internal/host/claimroleassembly.go b/internal/host/claimroleassembly.go
index 02cc601f1..d67fbbbbb 100644
--- a/internal/host/claimroleassembly.go
+++ b/internal/host/claimroleassembly.go
@@ -7,7 +7,6 @@ import (
"encoding/json"
"errors"
"path/filepath"
- "strconv"
"github.com/carlosframework/platform/internal/activator"
"github.com/carlosframework/platform/internal/cgroup"
@@ -55,7 +54,7 @@ func (a *ClaimRoleAssembly) launchTarget(ctx context.Context, o hostclaim.Observ
return hostguard.FenceTarget{}, err
}
h := o.Claim.Holder
- return hostguard.FenceTarget{Region: actor.Region, Host: o.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Session: h.Session, Op: o.Claim.Op.ID, Phase: o.Claim.Op.Phase, Box: actor.Box, Enrollment: actor.Enrollment, BootID: a.BootID, ControllerID: a.ControllerID, ClaimETag: o.ETag, DirectoryRevision: strconv.FormatUint(actor.Revision, 10)}, nil
+ return hostguard.FenceTarget{Region: actor.Region, Host: o.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Session: h.Session, Op: o.Claim.Op.ID, Phase: o.Claim.Op.Phase, Box: actor.Box, Enrollment: actor.Enrollment, BootID: a.BootID, ControllerID: a.ControllerID, ClaimETag: o.ETag, DirectoryRevision: actor.Binding}, nil
}
// Preflight admits a launch before retry reservation, admission or state
diff --git a/internal/host/claimroleassembly_linux.go b/internal/host/claimroleassembly_linux.go
index 143887817..13c4b52dc 100644
--- a/internal/host/claimroleassembly_linux.go
+++ b/internal/host/claimroleassembly_linux.go
@@ -14,7 +14,6 @@ import (
"os/exec"
"path/filepath"
"reflect"
- "strconv"
"strings"
"sync"
@@ -370,7 +369,7 @@ func (a *ClaimRoleAssembly) PrepareState(ctx context.Context, o hostclaim.Observ
if err != nil {
return err
}
- if !inventory.Complete || inventory.Host != o.Host || inventory.Incarnation != h.Incarnation || inventory.InstallationStamp != h.Stamp || inventory.Box != actor.Box || inventory.Enrollment != actor.Enrollment || inventory.DirectoryRevision != strconv.FormatUint(actor.Revision, 10) {
+ if !inventory.Complete || inventory.Host != o.Host || inventory.Incarnation != h.Incarnation || inventory.InstallationStamp != h.Stamp || inventory.Box != actor.Box || inventory.Enrollment != actor.Enrollment || inventory.DirectoryRevision != actor.Binding {
return hostbox.ErrTypedInventory
}
root := a.ManagedRoots["data"]
diff --git a/internal/host/claimservinghandover.go b/internal/host/claimservinghandover.go
index e5afeb85b..3e86bf38f 100644
--- a/internal/host/claimservinghandover.go
+++ b/internal/host/claimservinghandover.go
@@ -4,7 +4,6 @@ import (
"context"
"path/filepath"
"reflect"
- "strconv"
"github.com/carlosframework/platform/internal/hostbox"
"github.com/carlosframework/platform/internal/hostclaim"
@@ -26,10 +25,10 @@ func (h ClaimRootHTTP) validateServingHandover(ctx context.Context, c *hostclaim
if err != nil {
return err
}
- if !actor.Eligible || actor.Quarantined || actor.Revision == 0 || actor.Box != prior.Box || actor.Region != prior.Region || actor.Enrollment != prior.Enrollment || strconv.FormatUint(actor.Revision, 10) != next.DirectoryRevision {
+ if !actor.Eligible || actor.Quarantined || actor.Revision == 0 || actor.Box != prior.Box || actor.Region != prior.Region || actor.Enrollment != prior.Enrollment || !servingPriorBinding(next.DirectoryRevision, actor) {
return hostbox.ErrChanged
}
- if !servingPriorRevision(prior.DirectoryRevision, actor.Revision) {
+ if !servingPriorBinding(prior.DirectoryRevision, actor) {
return hostbox.ErrChanged
}
current, err := servingWriterIdentity(hostclaim.Observed{Host: prior.Host, Claim: c}, actor.Box, actor.Region)
@@ -133,7 +132,10 @@ func (h ClaimRootHTTP) servingLegacyHandoverTarget(ctx context.Context, q coldHa
return t, ctx.Err()
}
-func servingPriorRevision(recorded string, current uint64) bool {
- revision, err := strconv.ParseUint(recorded, 10, 64)
- return err == nil && revision > 0 && revision <= current && strconv.FormatUint(revision, 10) == recorded
+// servingPriorBinding reports whether a recorded installation stamp is the
+// fresh actor's binding. It is equality, not an ordering: a binding is a
+// digest, and an installation stamped under any other binding (before a
+// quarantine and readmission, say) is never served again.
+func servingPriorBinding(recorded string, actor hostbox.Actor) bool {
+ return actor.Binding != "" && recorded == actor.Binding
}
diff --git a/internal/host/claimservinghandover_linux_test.go b/internal/host/claimservinghandover_linux_test.go
index 32cf7bc8a..b40186979 100644
--- a/internal/host/claimservinghandover_linux_test.go
+++ b/internal/host/claimservinghandover_linux_test.go
@@ -9,7 +9,6 @@ import (
"os"
"path/filepath"
"reflect"
- "strconv"
"testing"
"time"
@@ -166,7 +165,7 @@ func runServingColdHandoverBoundary(t *testing.T, mount func(*testing.T, string)
if err != nil {
t.Fatal(err)
}
- next := hostbox.ColdSuccessor{Host: f.current.Host, Incarnation: f.current.Incarnation, Box: f.actor.Box, Enrollment: f.actor.Enrollment, DirectoryRevision: strconv.FormatUint(f.actor.Revision, 10), ETag: before.ETag, Generation: f.current.Generation, Stamp: f.current.Stamp, Session: f.current.Session}
+ next := hostbox.ColdSuccessor{Host: f.current.Host, Incarnation: f.current.Incarnation, Box: f.actor.Box, Enrollment: f.actor.Enrollment, DirectoryRevision: f.actor.Binding, ETag: before.ETag, Generation: f.current.Generation, Stamp: f.current.Stamp, Session: f.current.Session}
handover := root.servingHandover()
for i := 0; i < 2; i++ {
if err = handover.Run(t.Context(), f.receipt.Target, next); err != nil {
@@ -228,7 +227,7 @@ func TestServingHandoverLegacy(t *testing.T) {
t.Fatal(err)
}
f.actor.Revision = 8
- n := hostbox.ColdSuccessor{Host: f.current.Host, Incarnation: f.current.Incarnation, Box: f.actor.Box, Enrollment: f.actor.Enrollment, DirectoryRevision: strconv.FormatUint(f.actor.Revision, 10), ETag: f.f.read().ETag, Generation: f.current.Generation, Stamp: f.current.Stamp, Session: f.current.Session}
+ n := hostbox.ColdSuccessor{Host: f.current.Host, Incarnation: f.current.Incarnation, Box: f.actor.Box, Enrollment: f.actor.Enrollment, DirectoryRevision: f.actor.Binding, ETag: f.f.read().ETag, Generation: f.current.Generation, Stamp: f.current.Stamp, Session: f.current.Session}
if err := root.servingHandover().Run(t.Context(), saved.Result.Target, n); err != nil {
t.Fatalf("legacy transfer: %v prior=%+v next=%+v", err, saved.Result.Target, n)
}
diff --git a/internal/host/claimservinglegacyroot_linux.go b/internal/host/claimservinglegacyroot_linux.go
index 13ffc6246..781c2df67 100644
--- a/internal/host/claimservinglegacyroot_linux.go
+++ b/internal/host/claimservinglegacyroot_linux.go
@@ -8,7 +8,6 @@ import (
"net"
"os"
"reflect"
- "strconv"
"github.com/carlosframework/platform/internal/hostbox"
"github.com/carlosframework/platform/internal/hostclaim"
@@ -41,7 +40,7 @@ func (p *servingParkRoot) retainLegacyNoProcess(ctx context.Context, o hostclaim
return err
}
t := result.Target
- if !actor.Eligible || actor.Quarantined || actor.Box != t.Box || actor.Region != t.Region || actor.Enrollment != t.Enrollment || actor.Revision == 0 || strconv.FormatUint(actor.Revision, 10) != t.DirectoryRevision {
+ if !actor.Eligible || actor.Quarantined || actor.Box != t.Box || actor.Region != t.Region || actor.Enrollment != t.Enrollment || actor.Revision == 0 || !servingPriorBinding(t.DirectoryRevision, actor) {
return hostbox.ErrChanged
}
fresh, err := p.root.Stop.Coordinator.Guard.Claims.Read(ctx, o.Host)
@@ -99,7 +98,7 @@ func (p *servingParkRoot) validateLegacyRootEvidence(ctx context.Context, o host
return hostbox.ErrChanged
}
t, h := saved.Result.Target, saved.Observed.Claim.Holder
- if t.Enrollment != actor.Enrollment || !servingPriorRevision(t.DirectoryRevision, actor.Revision) || h.Account != o.Claim.Holder.Account || h.App != o.Claim.Holder.App || h.Key != o.Claim.Holder.Key || !h.CreatedAt.Equal(o.Claim.Holder.CreatedAt) {
+ if t.Enrollment != actor.Enrollment || !servingPriorBinding(t.DirectoryRevision, actor) || h.Account != o.Claim.Holder.Account || h.App != o.Claim.Holder.App || h.Key != o.Claim.Holder.Key || !h.CreatedAt.Equal(o.Claim.Holder.CreatedAt) {
return hostbox.ErrChanged
}
for _, r := range o.Claim.Holder.Admissions {
diff --git a/internal/host/claimservinglegacyroot_linux_test.go b/internal/host/claimservinglegacyroot_linux_test.go
index 3dcdaa62c..c14eac0e6 100644
--- a/internal/host/claimservinglegacyroot_linux_test.go
+++ b/internal/host/claimservinglegacyroot_linux_test.go
@@ -56,7 +56,7 @@ func newServingLegacyRootSetup(t *testing.T, empty bool, dataRoot ...string) (*s
if err != nil {
t.Fatal(err)
}
- fx := &servingRootFixture{t: t, f: f, disk: disk, rootDisk: roots, db: in.DBPath, actor: hostbox.Actor{Box: "box-1", Region: "ie", Enrollment: "enrollment", Revision: 7, Eligible: true}}
+ fx := &servingRootFixture{t: t, f: f, disk: disk, rootDisk: roots, db: in.DBPath, actor: hostbox.Actor{Box: "box-1", Region: "ie", Enrollment: "enrollment", Revision: 7, Binding: "7", Eligible: true}}
fs := newServingParkFS(f.guard.DataDir, disk)
fs.owner = uint32(os.Geteuid())
fs.mount = func(string) (bool, error) { return true, nil }
@@ -154,7 +154,7 @@ func TestServingLegacyRootAuthority(t *testing.T) {
}
func TestServingLegacyRootRefusals(t *testing.T) {
- for _, attack := range []string{"stop-missing", "stop-bytes", "stop-region", "first-creator", "marker", "half-tags", "tags", "peer", "census", "enrollment", "revision", "source", "main-intention", "empty-database", "empty-wal", "empty-remote", "empty-unavailable", "selector"} {
+ for _, attack := range []string{"stop-missing", "stop-bytes", "stop-region", "first-creator", "marker", "half-tags", "tags", "peer", "census", "enrollment", "binding", "source", "main-intention", "empty-database", "empty-wal", "empty-remote", "empty-unavailable", "selector"} {
t.Run(attack, func(t *testing.T) {
empty := strings.HasPrefix(attack, "empty-")
f, _ := newServingLegacyRootFixture(t, empty)
@@ -200,8 +200,8 @@ func TestServingLegacyRootRefusals(t *testing.T) {
f.p.root.RequireNewWork = func(context.Context) error { return hostbox.ErrChanged }
case "enrollment":
f.actor.Enrollment = "changed"
- case "revision":
- f.actor.Revision++
+ case "binding":
+ f.actor.Binding = "8"
case "source":
if err := os.Rename(filepath.Dir(f.db), filepath.Dir(f.db)+".saved"); err != nil {
t.Fatal(err)
diff --git a/internal/host/claimservingnamespace_linux_test.go b/internal/host/claimservingnamespace_linux_test.go
index 577f81a35..bb66df4c9 100644
--- a/internal/host/claimservingnamespace_linux_test.go
+++ b/internal/host/claimservingnamespace_linux_test.go
@@ -70,7 +70,7 @@ func TestServingNamespaceParentRequiresIndependentInstallation(t *testing.T) {
case "installation":
f.actor.Enrollment = "changed"
case "inventory":
- f.actor.Revision++
+ f.actor.Binding = "8"
case "receipt":
f.mutateRoot(func(m map[string]any) { m["State"].(map[string]any)["fence_journal"] = []any{} })
case "source":
diff --git a/internal/host/claimservingpark_recovery_linux_test.go b/internal/host/claimservingpark_recovery_linux_test.go
index 14503a6e6..231e1d116 100644
--- a/internal/host/claimservingpark_recovery_linux_test.go
+++ b/internal/host/claimservingpark_recovery_linux_test.go
@@ -109,7 +109,7 @@ func TestServingParkStartupResumesRecordedIntent(t *testing.T) {
}
func TestServingParkStartupRefusesChangedAuthority(t *testing.T) {
- for _, change := range []string{"enrollment", "revision", "claim", "tags", "directory", "receipt", "launch-intent", "census", "cancel"} {
+ for _, change := range []string{"enrollment", "binding", "claim", "tags", "directory", "receipt", "launch-intent", "census", "cancel"} {
t.Run(change, func(t *testing.T) {
f := newServingRootFixture(t, true)
a, err := f.park()
@@ -122,8 +122,8 @@ func TestServingParkStartupRefusesChangedAuthority(t *testing.T) {
switch change {
case "enrollment":
f.actor.Enrollment = "new-enrollment"
- case "revision":
- f.actor.Revision++
+ case "binding":
+ f.actor.Binding = "8"
case "claim":
_, err = hostclaim.Update(ctx, f.f.claims, f.f.read(), func(c *hostclaim.Claim) error { c.Holder.WriterBox = "other-box"; return nil })
case "tags":
diff --git a/internal/host/claimservingpark_rootrunner_linux_test.go b/internal/host/claimservingpark_rootrunner_linux_test.go
index 2185c6b30..53ad534b3 100644
--- a/internal/host/claimservingpark_rootrunner_linux_test.go
+++ b/internal/host/claimservingpark_rootrunner_linux_test.go
@@ -651,7 +651,7 @@ func TestRootRebootServingParkChangedMountPhase2(t *testing.T) {
t.Fatal(err)
}
a := saved.Record.activeAuthorization()
- active := &servingParkRebootAuthority{ClaimETag: "runner-claim", Actor: hostbox.Actor{Box: a.Successor.Box, Region: a.Successor.Region, Enrollment: "runner-enrollment", Revision: 1, Eligible: true}, Directory: observe.Source, Tags: a.TagsFrom}
+ active := &servingParkRebootAuthority{ClaimETag: "runner-claim", Actor: hostbox.Actor{Box: a.Successor.Box, Region: a.Successor.Region, Enrollment: "runner-enrollment", Revision: 1, Binding: "1", Eligible: true}, Directory: observe.Source, Tags: a.TagsFrom}
if err := ledger.withNamespace(t.Context(), func() error { return ledger.commitRebootLocked(t.Context(), saved.Record, active) }); err != nil {
t.Fatal("commit after actual reboot", err)
}
@@ -709,7 +709,7 @@ func servingRunnerPrepareReboot(t *testing.T, fs *servingParkFS, r servingParkRe
t.Fatal(err)
}
a := r.activeAuthorization()
- active := &servingParkRebootAuthority{ClaimETag: "runner-claim", Actor: hostbox.Actor{Box: a.Successor.Box, Region: a.Successor.Region, Enrollment: "runner-enrollment", Revision: 1, Eligible: true}, Directory: observe.Source, Tags: a.TagsFrom}
+ active := &servingParkRebootAuthority{ClaimETag: "runner-claim", Actor: hostbox.Actor{Box: a.Successor.Box, Region: a.Successor.Region, Enrollment: "runner-enrollment", Revision: 1, Binding: "1", Eligible: true}, Directory: observe.Source, Tags: a.TagsFrom}
prepare := func() error {
return ledger.withNamespace(t.Context(), func() error { return ledger.prepareRebootLocked(t.Context(), r, active) })
}
diff --git a/internal/host/claimservingpark_transport.go b/internal/host/claimservingpark_transport.go
index 42ae7040c..e2d334cc6 100644
--- a/internal/host/claimservingpark_transport.go
+++ b/internal/host/claimservingpark_transport.go
@@ -155,7 +155,7 @@ func (h ClaimRootHTTP) serveServingPark(w http.ResponseWriter, r *http.Request,
return
}
actor, err := h.InventoryActor(ctx)
- if err != nil || !actor.Eligible || actor.Quarantined || actor.Box == "" || actor.Enrollment == "" || actor.Revision == 0 || q.ServingPark.Successor.Box != actor.Box || q.ServingPark.Successor.Region != actor.Region {
+ if err != nil || !actor.Eligible || actor.Quarantined || actor.Box == "" || actor.Enrollment == "" || actor.Revision == 0 || actor.Binding == "" || q.ServingPark.Successor.Box != actor.Box || q.ServingPark.Successor.Region != actor.Region {
w.WriteHeader(http.StatusForbidden)
return
}
diff --git a/internal/host/claimservingparkroot_linux.go b/internal/host/claimservingparkroot_linux.go
index 406ff955a..e37877296 100644
--- a/internal/host/claimservingparkroot_linux.go
+++ b/internal/host/claimservingparkroot_linux.go
@@ -72,7 +72,7 @@ func (p *servingParkRoot) withRootInstallation(ctx context.Context, current serv
if err != nil {
return err
}
- if !actor.Eligible || actor.Quarantined || actor.Enrollment == "" || actor.Revision == 0 {
+ if !actor.Eligible || actor.Quarantined || actor.Enrollment == "" || actor.Revision == 0 || actor.Binding == "" {
return hostbox.ErrChanged
}
actual, err := servingWriterIdentity(o, actor.Box, actor.Region)
@@ -128,7 +128,7 @@ func servingRootStops(ctx context.Context, view hostguard.FenceView, prior servi
if t.Host != prior.Host || t.Incarnation != prior.Incarnation || t.Stamp != prior.Stamp || t.Box != prior.Box || t.Op != "" || t.Phase != "" || t.ObligationID != "" {
continue
}
- if t.Session != prior.Session || t.Region != prior.Region || t.Enrollment != actor.Enrollment || !servingPriorRevision(t.DirectoryRevision, actor.Revision) || t.FenceID == "" || seen[t.FenceID] || verifyRetirementReceipt(ctx, receipt) != nil {
+ if t.Session != prior.Session || t.Region != prior.Region || t.Enrollment != actor.Enrollment || !servingPriorBinding(t.DirectoryRevision, actor) || t.FenceID == "" || seen[t.FenceID] || verifyRetirementReceipt(ctx, receipt) != nil {
return nil, ErrClaimStopReceipt
}
seen[t.FenceID] = true
diff --git a/internal/host/claimservingparkroot_linux_test.go b/internal/host/claimservingparkroot_linux_test.go
index 6ab192cb1..c9fa1a941 100644
--- a/internal/host/claimservingparkroot_linux_test.go
+++ b/internal/host/claimservingparkroot_linux_test.go
@@ -74,7 +74,18 @@ type servingRootFixture struct {
trace []string
}
+// servingFixtureActor is the serving fixtures' root actor. Its binding is the
+// fixture shorthand "7"; newServingRootFixtureFor takes a production actor.
+var servingFixtureActor = hostbox.Actor{Box: "box-1", Region: "ie", Enrollment: "enrollment", Revision: 7, Binding: "7", Eligible: true}
+
func newServingRootFixture(t *testing.T, launched bool) *servingRootFixture {
+ t.Helper()
+ return newServingRootFixtureFor(t, launched, servingFixtureActor)
+}
+
+// newServingRootFixtureFor stamps the installation, its stop receipt and the
+// root's inventory actor with actor (box-1 in ie).
+func newServingRootFixtureFor(t *testing.T, launched bool, actor hostbox.Actor) *servingRootFixture {
t.Helper()
f, _, _, in := servingRetirementFixture(t)
first := servingAdmit(t, f, &in, "G")
@@ -85,7 +96,7 @@ func newServingRootFixture(t *testing.T, launched bool) *servingRootFixture {
if err != nil {
t.Fatal(err)
}
- fx := &servingRootFixture{t: t, f: f, disk: disk, rootDisk: roots, db: in.DBPath, actor: hostbox.Actor{Box: "box-1", Region: "ie", Enrollment: "enrollment", Revision: 7, Eligible: true}}
+ fx := &servingRootFixture{t: t, f: f, disk: disk, rootDisk: roots, db: in.DBPath, actor: actor}
fx.prior, err = servingWriterIdentity(first, "box-1", "ie")
if err != nil {
t.Fatal(err)
@@ -105,7 +116,7 @@ func newServingRootFixture(t *testing.T, launched bool) *servingRootFixture {
if err != nil {
t.Fatal(err)
}
- fx.receipt = servingStop(t, f, f.read(), boot)
+ fx.receipt = servingStopFor(t, f, f.read(), fx.actor, boot)
target := fx.receipt.Target
if err := f.journal.Prelaunch(t.Context(), hostbox.LaunchInventory{Target: target, ControllerPID: 77, ProcessStart: "edge-start", NoState: true, Groups: []hostbox.LaunchGroup{{RelativePath: "carlos/parent", Device: 1, Inode: 2}}}); err != nil {
t.Fatal(err)
@@ -156,7 +167,7 @@ func (f *servingRootFixture) install(o hostclaim.Observed) {
f.t.Fatal(err)
}
owner := sha256.Sum256([]byte(fmt.Sprintf("%s\x00%s\x00%d\x00%s", o.Host, h.Incarnation, h.Stamp, f.actor.Box)))
- in := hostbox.StopInventory{Complete: true, Host: o.Host, Incarnation: h.Incarnation, InstallationStamp: h.Stamp, Box: f.actor.Box, Enrollment: f.actor.Enrollment, DirectoryRevision: "7", Entries: []hostbox.StopInventoryEntry{{Kind: "path", ManagedRoot: "data", RelativePath: "instances/" + provision.InstanceID(o.Host), ArtifactID: "state", Ownership: hex.EncodeToString(owner[:]), Materialization: "materialized", Device: id.Device, Inode: id.Inode, Type: unix.S_IFDIR}}}
+ in := hostbox.StopInventory{Complete: true, Host: o.Host, Incarnation: h.Incarnation, InstallationStamp: h.Stamp, Box: f.actor.Box, Enrollment: f.actor.Enrollment, DirectoryRevision: f.actor.Binding, Entries: []hostbox.StopInventoryEntry{{Kind: "path", ManagedRoot: "data", RelativePath: "instances/" + provision.InstanceID(o.Host), ArtifactID: "state", Ownership: hex.EncodeToString(owner[:]), Materialization: "materialized", Device: id.Device, Inode: id.Inode, Type: unix.S_IFDIR}}}
inventory := f.p.root.Journals.Inventory
if err := inventory.WriteStopInventory(f.t.Context(), in); err != nil {
f.t.Fatal(err)
@@ -296,7 +307,7 @@ func TestServingParkRootReplaysOriginalSelectorAfterRetag(t *testing.T) {
}
}
func TestServingParkRootRefusesBeforeEffects(t *testing.T) {
- for _, attack := range []string{"peer", "peer-root", "census", "roster", "quarantine", "enrollment", "revision", "claim", "prior", "tags", "half-tags", "source", "inventory-revision", "receipt", "pending", "root-quarantine", "root-pending", "barrier", "canceled"} {
+ for _, attack := range []string{"peer", "peer-root", "census", "roster", "quarantine", "enrollment", "binding", "claim", "prior", "tags", "half-tags", "source", "inventory-revision", "receipt", "pending", "root-quarantine", "root-pending", "barrier", "canceled"} {
t.Run(attack, func(t *testing.T) {
f := newServingRootFixture(t, true)
ctx := t.Context()
@@ -315,8 +326,8 @@ func TestServingParkRootRefusesBeforeEffects(t *testing.T) {
f.actor.Quarantined = true
case "enrollment":
f.actor.Enrollment = "other"
- case "revision":
- f.actor.Revision++
+ case "binding":
+ f.actor.Binding = "8"
case "claim":
f.current.Generation = "foreign"
case "prior":
diff --git a/internal/host/claimservingparksource_linux.go b/internal/host/claimservingparksource_linux.go
index 462d42c4c..407046a6e 100644
--- a/internal/host/claimservingparksource_linux.go
+++ b/internal/host/claimservingparksource_linux.go
@@ -30,7 +30,7 @@ func servingParkStateDirectory(data string, o hostclaim.Observed, installation h
return zero, hostbox.ErrChanged
}
h := o.Claim.Holder
- if h.Family != "instance" || installation.Migration == 0 || installation.Empty || installation.Host != current.Host || installation.Incarnation != current.Incarnation || installation.Stamp == 0 || installation.Stamp > current.Stamp || installation.Account != h.Account || installation.App != h.App || installation.Record != h.Key || installation.Box != actor.Box || installation.Enrollment != actor.Enrollment || actor.Enrollment == "" || actor.Revision == 0 || revision == 0 || installation.InventoryRevision != revision {
+ if h.Family != "instance" || installation.Migration == 0 || installation.Empty || installation.Host != current.Host || installation.Incarnation != current.Incarnation || installation.Stamp == 0 || installation.Stamp > current.Stamp || installation.Account != h.Account || installation.App != h.App || installation.Record != h.Key || installation.Box != actor.Box || installation.Enrollment != actor.Enrollment || actor.Enrollment == "" || actor.Revision == 0 || actor.Binding == "" || revision == 0 || installation.InventoryRevision != revision {
return zero, hostbox.ErrChanged
}
if installation.Stamp != current.Stamp {
@@ -38,7 +38,7 @@ func servingParkStateDirectory(data string, o hostclaim.Observed, installation h
return zero, err
}
}
- if !in.Complete || in.Host != installation.Host || in.Incarnation != installation.Incarnation || in.InstallationStamp != installation.Stamp || in.Box != actor.Box || in.Enrollment != actor.Enrollment || in.DirectoryRevision != fmt.Sprint(actor.Revision) {
+ if !in.Complete || in.Host != installation.Host || in.Incarnation != installation.Incarnation || in.InstallationStamp != installation.Stamp || in.Box != actor.Box || in.Enrollment != actor.Enrollment || in.DirectoryRevision != actor.Binding {
return zero, hostbox.ErrTypedInventory
}
relative := filepath.ToSlash(filepath.Join("instances", provision.InstanceID(current.Host)))
diff --git a/internal/host/claimservingparksource_linux_test.go b/internal/host/claimservingparksource_linux_test.go
index 2929b82ed..5f2c25363 100644
--- a/internal/host/claimservingparksource_linux_test.go
+++ b/internal/host/claimservingparksource_linux_test.go
@@ -22,7 +22,7 @@ func TestServingParkSourceUsesRootInventory(t *testing.T) {
f, _, _, inputs := servingRetirementFixture(t)
o := servingAdmit(t, f, &inputs, "G")
h := o.Claim.Holder
- actor := hostbox.Actor{Box: "box-1", Region: "ie", Enrollment: "enrollment", Revision: 7}
+ actor := hostbox.Actor{Box: "box-1", Region: "ie", Enrollment: "enrollment", Revision: 7, Binding: "7"}
root := hostguard.RootInstallation{Host: o.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Migration: 1, InventoryRevision: 3, Account: h.Account, App: h.App, Record: h.Key, Box: actor.Box, Enrollment: actor.Enrollment}
d, err := os.Open(filepath.Dir(inputs.DBPath))
if err != nil {
diff --git a/internal/host/claimservingreboot_prepare_linux_test.go b/internal/host/claimservingreboot_prepare_linux_test.go
index bb9bf1c5a..8ec4db07f 100644
--- a/internal/host/claimservingreboot_prepare_linux_test.go
+++ b/internal/host/claimservingreboot_prepare_linux_test.go
@@ -19,7 +19,12 @@ import (
func servingRebootPreparationFixture(t *testing.T, phase string) (*servingRootFixture, servingParkRecord) {
t.Helper()
- f := newServingRootFixture(t, true)
+ return servingRebootPreparationFixtureFor(t, phase, servingFixtureActor)
+}
+
+func servingRebootPreparationFixtureFor(t *testing.T, phase string, actor hostbox.Actor) (*servingRootFixture, servingParkRecord) {
+ t.Helper()
+ f := newServingRootFixtureFor(t, true, actor)
fs := f.p.ledger.fs.(*servingParkFS)
fs.volume = func(uint64) string { return "vol0123456789abcdef0" }
if phase == "rename-reply" {
@@ -121,7 +126,7 @@ func TestServingParkRebootPreparationPreservesHistory(t *testing.T) {
}
func TestServingParkRebootPreparationRefusesAuthority(t *testing.T) {
- for _, fault := range []string{"enrollment", "revision", "claim", "tags", "receipt", "launch-intent", "census", "cancel", "slot-id", "slot-pending", "slot-last", "slot-foreign", "slot-missing", "record-missing"} {
+ for _, fault := range []string{"enrollment", "binding", "claim", "tags", "receipt", "launch-intent", "census", "cancel", "slot-id", "slot-pending", "slot-last", "slot-foreign", "slot-missing", "record-missing"} {
t.Run(fault, func(t *testing.T) {
f, r := servingRebootPreparationFixture(t, "parked")
ctx := t.Context()
@@ -129,8 +134,8 @@ func TestServingParkRebootPreparationRefusesAuthority(t *testing.T) {
switch fault {
case "enrollment":
f.actor.Enrollment = "changed"
- case "revision":
- f.actor.Revision++
+ case "binding":
+ f.actor.Binding = "8"
case "claim":
_, err = hostclaim.Update(ctx, f.f.claims, f.f.read(), func(c *hostclaim.Claim) error { c.Holder.WriterBox = "other"; return nil })
case "tags":
@@ -335,7 +340,7 @@ func TestServingParkRebootPreparationDetectsWriteRace(t *testing.T) {
case "claim":
f.tags(f.current.Stamp)
case "actor":
- f.actor.Revision++
+ f.actor.Binding = "8"
case "census":
f.p.root.RequireNewWork = func(context.Context) error { return hostbox.ErrChanged }
case "slot":
diff --git a/internal/host/claimservingrenumber_linux_test.go b/internal/host/claimservingrenumber_linux_test.go
index f8a109970..971ddae36 100644
--- a/internal/host/claimservingrenumber_linux_test.go
+++ b/internal/host/claimservingrenumber_linux_test.go
@@ -84,7 +84,7 @@ func TestServingParkRebootDeviceRenumber(t *testing.T) {
var active *servingParkRebootAuthority
if !r.Complete {
a := r.activeAuthorization()
- active = &servingParkRebootAuthority{ClaimETag: "fixture", Actor: hostbox.Actor{Box: a.Successor.Box, Region: a.Successor.Region, Enrollment: "fixture", Revision: 1, Eligible: true}, Directory: got.Source, Tags: a.TagsFrom}
+ active = &servingParkRebootAuthority{ClaimETag: "fixture", Actor: hostbox.Actor{Box: a.Successor.Box, Region: a.Successor.Region, Enrollment: "fixture", Revision: 1, Binding: "1", Eligible: true}, Directory: got.Source, Tags: a.TagsFrom}
}
if err := f.ledger.prepareRebootLocked(t.Context(), r, active); err != nil {
t.Fatal("prepare", err)
diff --git a/internal/host/claimservingretire_linux_test.go b/internal/host/claimservingretire_linux_test.go
index 1c3189306..52c7a0483 100644
--- a/internal/host/claimservingretire_linux_test.go
+++ b/internal/host/claimservingretire_linux_test.go
@@ -160,12 +160,17 @@ func servingAdmit(t *testing.T, f *recoveryFixture, in *ClaimLaunchInputs, gener
return admitted
}
func servingStop(t *testing.T, f *recoveryFixture, o hostclaim.Observed, boots ...string) hostguard.FenceReceipt {
+ t.Helper()
+ return servingStopFor(t, f, o, hostbox.Actor{Box: "box-1", Region: "ie", Enrollment: "enrollment", Revision: 7, Binding: "7"}, boots...)
+}
+
+func servingStopFor(t *testing.T, f *recoveryFixture, o hostclaim.Observed, actor hostbox.Actor, boots ...string) hostguard.FenceReceipt {
t.Helper()
boot := "boot"
if len(boots) != 0 {
boot = boots[0]
}
- target := recoveryTuple(o, claimStopLocal{Actor: hostbox.Actor{Box: "box-1", Region: "ie", Enrollment: "enrollment", Revision: 7}, BootID: boot, ControllerID: "controller"})
+ target := recoveryTuple(o, claimStopLocal{Actor: actor, BootID: boot, ControllerID: "controller"})
target.FenceID, target.ClaimGen = "stop-"+o.Claim.Holder.Generation, o.Claim.Gen
if _, err := f.guard.BeginFence(t.Context(), target); err != nil {
t.Fatal(err)
diff --git a/internal/host/claimstep8_ruling6_test.go b/internal/host/claimstep8_ruling6_test.go
index bcd687137..67b6bb60f 100644
--- a/internal/host/claimstep8_ruling6_test.go
+++ b/internal/host/claimstep8_ruling6_test.go
@@ -77,9 +77,6 @@ func TestStep8CensusChangesReachOnlyClaimMode(t *testing.T) {
"migrateRootClaimAuthority": {"migrateClaimJournalsWith"},
"prepareRootRetryUnitDirectory": {"installActivationControl", "readClaimUnitSettings"},
"collector.routes": {"migrateRootClaimAuthority"},
- // G10 (claim-ack-refresh): only the claim assembly's regional
- // enrollment check ignores the roster revision.
- "sameVerifiedActor": {"VerifyRegional"},
}
for name, w := range want {
got := slices.Compact(sortedCopy(callers[name]))
diff --git a/internal/host/claimstep8_witness_rootrunner_linux_test.go b/internal/host/claimstep8_witness_rootrunner_linux_test.go
index fd94a977d..d5904d5df 100644
--- a/internal/host/claimstep8_witness_rootrunner_linux_test.go
+++ b/internal/host/claimstep8_witness_rootrunner_linux_test.go
@@ -266,7 +266,7 @@ systemctl show "${UNITS[@]}" -p Id -p LoadState -p ActiveState
leoKey := ed25519.NewKeyFromSeed(bytes.Repeat([]byte{2}, ed25519.SeedSize))
sophieKey := ed25519.NewKeyFromSeed(bytes.Repeat([]byte{3}, ed25519.SeedSize))
enrollment := strings.Repeat("a", 32)
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: step8Leo, Enrollment: enrollment, Revision: 9, Region: "ie", ControlBucket: step8Bucket})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: step8Leo, Enrollment: enrollment, Revision: 9, Binding: "9", Region: "ie", ControlBucket: step8Bucket})
actor, err := identity.Verify(ctx)
if err != nil {
t.Fatal(err)
diff --git a/internal/host/claimstop_noprocess_test.go b/internal/host/claimstop_noprocess_test.go
index 18547ce04..b6f838294 100644
--- a/internal/host/claimstop_noprocess_test.go
+++ b/internal/host/claimstop_noprocess_test.go
@@ -178,7 +178,7 @@ func TestStopCapturedSessionZeroAsksRootForTheWitness(t *testing.T) {
var drain StopDrainer
a := ClaimAssembly{Claims: f.claims, Wake: &ClaimWakeAssembly{}}
a.stopLocal = func(context.Context) (claimStopLocal, error) {
- return claimStopLocal{Actor: hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Region: "ie", Revision: 7}, BootID: "boot-1", ControllerID: "controller-1", PID: 42, ProcessStart: "start-42"}, nil
+ return claimStopLocal{Actor: hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Region: "ie", Revision: 7, Binding: "7"}, BootID: "boot-1", ControllerID: "controller-1", PID: 42, ProcessStart: "start-42"}, nil
}
a.collectStop = func(_ context.Context, r StopRequest, d StopDrainer) (StopResult, error) {
got, drain = r, d
diff --git a/internal/host/claimstop_writers.go b/internal/host/claimstop_writers.go
index 15d2d4fa3..362accb25 100644
--- a/internal/host/claimstop_writers.go
+++ b/internal/host/claimstop_writers.go
@@ -238,7 +238,7 @@ func (a ClaimAssembly) writersStopped(ctx context.Context, host string, read fun
}
revision := t.DirectoryRevision
if revision == "" {
- revision = fmt.Sprint(local.Actor.Revision)
+ revision = local.Actor.Binding
}
att.mu.Lock()
hints := slices.Clone(att.replicatorFDs)
diff --git a/internal/host/claimwakestop.go b/internal/host/claimwakestop.go
index 529a149db..20214edfa 100644
--- a/internal/host/claimwakestop.go
+++ b/internal/host/claimwakestop.go
@@ -4,7 +4,6 @@ import (
"context"
"database/sql"
"errors"
- "fmt"
"os"
"strings"
@@ -308,7 +307,7 @@ func (a ClaimAssembly) collectCapturedStop(ctx context.Context, captured hostcla
directoryRevision := owner.DirectoryRevision
if directoryRevision == "" {
// No record was found. Root still requires exact journal evidence.
- directoryRevision = fmt.Sprint(actor.Revision)
+ directoryRevision = actor.Binding
}
req := StopRequest{Region: actor.Region, Recover: recovering, Host: observed.Host, Incarnation: holder.Incarnation, InstallationStamp: holder.Stamp, WriterSession: holder.Session, OperationID: claim.Op.ID, Phase: claim.Op.Phase, ObligationID: obligation, Box: actor.Box, Enrollment: actor.Enrollment, BootID: owner.BootID, ControllerID: owner.ControllerID, ExpectedClaimETag: observed.ETag, ExpectedDirectoryRevision: directoryRevision}
target := hostguard.FenceTarget{Region: req.Region, Host: req.Host, Incarnation: req.Incarnation, Stamp: req.InstallationStamp, Session: req.WriterSession, Op: req.OperationID, Phase: req.Phase, ObligationID: req.ObligationID, Box: req.Box}
diff --git a/internal/host/claimwakewriters_test.go b/internal/host/claimwakewriters_test.go
index 9adde1a79..5a2c62d4a 100644
--- a/internal/host/claimwakewriters_test.go
+++ b/internal/host/claimwakewriters_test.go
@@ -382,7 +382,7 @@ func TestClaimAssemblyWritersStoppedAsksRootForTheWitnessedSession(t *testing.T)
f.wake.pending = map[string]*claimWakeAttempt{f.target.Host: f.attempt}
current := f.attempt.observed
a := ClaimAssembly{Wake: f.wake, stopLocal: func(context.Context) (claimStopLocal, error) {
- return claimStopLocal{Actor: hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Region: "eu-west-1", Revision: 9}, BootID: "boot-1", ControllerID: "controller-1", PID: 42, ProcessStart: "start-42"}, nil
+ return claimStopLocal{Actor: hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Region: "eu-west-1", Revision: 9, Binding: "9"}, BootID: "boot-1", ControllerID: "controller-1", PID: 42, ProcessStart: "start-42"}, nil
}}
read := func(context.Context, string) (hostclaim.Observed, error) { return current, nil }
var got WritersStoppedRequest
diff --git a/internal/host/moveswakesource_linux_test.go b/internal/host/moveswakesource_linux_test.go
index 633105cc7..7960a78ee 100644
--- a/internal/host/moveswakesource_linux_test.go
+++ b/internal/host/moveswakesource_linux_test.go
@@ -144,7 +144,7 @@ func mwRegister(t *testing.T, f *poFixture, box, region string, files ClaimFiles
}
}
w.guard = hostguard.Guard{DataDir: f.dataDir, LockDir: t.TempDir(), Claims: hostguard.StoreReader{Store: f.claims}}
- w.local = claimStopLocal{Actor: hostbox.Actor{Box: box, Enrollment: "enrollment-1", Revision: 7, Region: region}, BootID: "boot-1", ControllerID: "controller-1", PID: 4101, ProcessStart: "start-1"}
+ w.local = claimStopLocal{Actor: hostbox.Actor{Box: box, Enrollment: "enrollment-1", Revision: 7, Binding: "7", Region: region}, BootID: "boot-1", ControllerID: "controller-1", PID: 4101, ProcessStart: "start-1"}
actor := hostbox.Actor{Box: box, Region: region, Bucket: "data", Enrollment: "enrollment-1", Cloud: hostbox.CloudIdentity{Region: "eu-west-1"}}
out := ClaimOwnerBindings{Data: f.bucket}
var opened ClaimFilesManifest
diff --git a/internal/host/moveswakesource_test.go b/internal/host/moveswakesource_test.go
index ee55ae21b..91fdac848 100644
--- a/internal/host/moveswakesource_test.go
+++ b/internal/host/moveswakesource_test.go
@@ -233,7 +233,7 @@ func TestTheClaimsParkViewIsTheMovesView(t *testing.T) {
"the claim's park view": claimMoveSources.Parks.View,
"the wake source's View": src.View,
"the registered parks": parks.View,
- "the claim's regional view": productionClaimRegional{Identity: handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7, Region: "ie"}), Parks: claimMoveSources.Parks}.View,
+ "the claim's regional view": productionClaimRegional{Identity: handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7, Binding: "7", Region: "ie"}), Parks: claimMoveSources.Parks}.View,
} {
got, err := view(t.Context(), obs)
if err != nil {
diff --git a/internal/host/plan12_handover_test.go b/internal/host/plan12_handover_test.go
index a7cab583d..e4d59cea0 100644
--- a/internal/host/plan12_handover_test.go
+++ b/internal/host/plan12_handover_test.go
@@ -107,7 +107,7 @@ func plan12Handover(t *testing.T, kind, mode string) (*recoveryFixture, hostclai
t.Fatal(err)
}
}
- h.Identity = handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7, Region: "ie"})
+ h.Identity = handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7, Binding: "7", Region: "ie"})
h.Inventory, err = openLegacyInventory(t, filepath.Join(t.TempDir(), "inventory.db"))
if err != nil {
t.Fatal(err)
diff --git a/internal/host/plan13_region_test.go b/internal/host/plan13_region_test.go
index bb960d51d..bdbee4ea4 100644
--- a/internal/host/plan13_region_test.go
+++ b/internal/host/plan13_region_test.go
@@ -24,7 +24,7 @@ func TestPlan13ClaimRegionBinding(t *testing.T) {
}
func TestPlan13VerifyRegionalHomeNames(t *testing.T) {
for _, home := range []string{"region", ""} {
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "region", FleetHomeRegion: "region", ControlBucket: "control", Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "region", FleetHomeRegion: "region", ControlBucket: "control", Revision: 1, Binding: "1"})
identity.HomeRegion = home
actor, err := identity.Verify(t.Context())
if err != nil {
@@ -46,7 +46,7 @@ func TestPlan13VerifyRegionalHomeNames(t *testing.T) {
func TestPlan13UnverifiedAliasRefused(t *testing.T) {
for _, fleet := range []string{"", "ie"} {
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "ca", FleetHomeRegion: fleet, Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "ca", FleetHomeRegion: fleet, Revision: 1, Binding: "1"})
identity.HomeRegion = "ca"
if _, err := identity.Verify(t.Context()); err == nil {
t.Fatal("unverified home alias accepted", fleet)
@@ -58,7 +58,7 @@ func TestPlan13NamedBoxCannotAcknowledgeHomeDelete(t *testing.T) {
if _, _, err := claimRegionBinding("ca", "", "ie"); err == nil {
t.Fatal("missing CARLOS_REGION granted alias")
}
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "ca-box", Enrollment: "enrolled", Region: "ca", FleetHomeRegion: "ie", Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "ca-box", Enrollment: "enrolled", Region: "ca", FleetHomeRegion: "ie", Revision: 1, Binding: "1"})
p := productionClaimRegional{Identity: identity, Local: &productionClaimLocal{legacyParticipation: true, Identity: identity, Resources: ClaimRuntimeResources{Mode: "agent", DataDir: t.TempDir()}, assembly: &ClaimAssembly{}, lifetime: t.Context()}}
for _, kind := range []string{hostclaim.KindDeleting, hostclaim.KindParking, hostclaim.KindPurging} {
ob := hostclaim.Obligation{ID: "chore", Op: "delete", Kind: "park-replica", Owner: "region:ca", Region: "ca", Retirement: "retirement"}
@@ -88,7 +88,7 @@ func TestPlan13MissingDesignationRunsNamedOnly(t *testing.T) {
if !p.OwnsRegion(name) || p.OwnsRegion(park.HomeRegion) {
t.Fatal("degraded ownership", p)
}
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: name, Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: name, Revision: 1, Binding: "1"})
identity.HomeRegion = home
if _, err := identity.Verify(t.Context()); err != nil {
t.Fatal("named runtime identity", err)
diff --git a/internal/host/plan13_views_test.go b/internal/host/plan13_views_test.go
index eca3fa747..9f4ef727f 100644
--- a/internal/host/plan13_views_test.go
+++ b/internal/host/plan13_views_test.go
@@ -17,7 +17,7 @@ func TestPlan13ProductionRemoteHomeView(t *testing.T) {
f.rec.Move = &provision.MoveState{ID: vwMove, Incarnation: f.inc, From: "", To: "uk", State: provision.MoveLanding}
h := f.holder("src", "src@ie")
o := hostclaim.Observed{Host: vwHost, ETag: "tag", Claim: &hostclaim.Claim{Host: vwHost, Holder: h, Op: hostclaim.Op{ID: vwMove, Kind: hostclaim.KindLanding, Phase: "installing", Intent: map[string]string{"home_region": "ie"}}}}
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "uk", FleetHomeRegion: "ie", ControlBucket: "control", Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: "enrolled", Region: "uk", FleetHomeRegion: "ie", ControlBucket: "control", Revision: 1, Binding: "1"})
p := productionClaimRegional{Identity: identity, Local: &productionClaimLocal{legacyParticipation: true, Identity: identity, Resources: ClaimRuntimeResources{Mode: "agent", DataDir: t.TempDir()}, assembly: &ClaimAssembly{}, lifetime: t.Context()}, Parks: &claimMoveParkSources{View: f.view("uk")}}
if _, err := p.View(t.Context(), hostclaim.Observed{}); err == nil {
t.Fatal("missing claim accepted")
diff --git a/internal/host/plan14_install_registration_test.go b/internal/host/plan14_install_registration_test.go
index fe6121ff9..c978cea99 100644
--- a/internal/host/plan14_install_registration_test.go
+++ b/internal/host/plan14_install_registration_test.go
@@ -41,7 +41,7 @@ func plan14InstallRegistration(t *testing.T, kind, phase string) (*recoveryFixtu
}
guard := f.guard
guard.Root = hostguard.NewRootAuthority(&rollbackDisk{dir: t.TempDir()})
- actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Region: "ie", Revision: 1}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Region: "ie", Revision: 1, Binding: "1"}
roots := map[string]string{"data": guard.DataDir, "opt": t.TempDir(), "units": t.TempDir()}
census := &hostbox.EmptyInstallationCensus{Inventory: journals.Inventory, Registry: reg, Launches: f.journal, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: "1", Roots: roots, SharedPaths: map[string][]string{"data": {"hostguard"}}}
root := ClaimRootHTTP{Journals: journals, Launches: f.journal, Roots: roots, InventoryActor: func(context.Context) (hostbox.Actor, error) { return actor, nil }, Reconcile: hostbox.ReconcileAdapter{Registry: reg, Inventory: journals.Inventory, Census: census}, Stop: ClaimStopHTTP{Coordinator: ClaimStopCoordinator{Guard: guard, Evidence: f.claims}}}
diff --git a/internal/host/plan14_lifecycle_root_linux_test.go b/internal/host/plan14_lifecycle_root_linux_test.go
index 016362681..054f74133 100644
--- a/internal/host/plan14_lifecycle_root_linux_test.go
+++ b/internal/host/plan14_lifecycle_root_linux_test.go
@@ -114,7 +114,7 @@ type lifecycleOwners struct{ t *testing.T }
func (p lifecycleOwners) OpenClaimOwners(ctx context.Context, store release.Store, r ClaimRuntimeResources) (ClaimOwnerBindings, error) {
key := ed25519.NewKeyFromSeed(bytes.Repeat([]byte{1}, ed25519.SeedSize))
- identity := handoverRecoveryIdentity(p.t, hostbox.Actor{Box: "box", Enrollment: strings.Repeat("a", 32), Revision: 1, Region: "ie", FleetHomeRegion: "ie", ControlBucket: "deployment"})
+ identity := handoverRecoveryIdentity(p.t, hostbox.Actor{Box: "box", Enrollment: strings.Repeat("a", 32), Revision: 1, Binding: "1", Region: "ie", FleetHomeRegion: "ie", ControlBucket: "deployment"})
identity.HomeRegion = "ie"
actor, err := identity.Verify(ctx)
if err != nil {
@@ -230,7 +230,7 @@ func lifecycleRun(t *testing.T) {
lifecycleEnvironment(t, server.URL)
store := release.NewDirStore(lifecycleHome + "/deployment")
key := ed25519.NewKeyFromSeed(bytes.Repeat([]byte{1}, ed25519.SeedSize))
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: strings.Repeat("a", 32), Revision: 1, Region: "ie", FleetHomeRegion: "ie", ControlBucket: "deployment"})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: strings.Repeat("a", 32), Revision: 1, Binding: "1", Region: "ie", FleetHomeRegion: "ie", ControlBucket: "deployment"})
identity.HomeRegion = "ie"
actor, err := identity.Verify(t.Context())
lifecycleCheck(t, "identity", err)
diff --git a/internal/host/plan14_r11_handover_test.go b/internal/host/plan14_r11_handover_test.go
index 87d5f65f4..cc35847b6 100644
--- a/internal/host/plan14_r11_handover_test.go
+++ b/internal/host/plan14_r11_handover_test.go
@@ -11,7 +11,6 @@ import (
"os"
"path/filepath"
"reflect"
- "strconv"
"testing"
)
@@ -30,7 +29,7 @@ func TestPlan14ServingHandoverPins(t *testing.T) {
}
return generationReadHandovers(t.Context(), &rollbackDisk{dir: filepath.Join(root.Reconcile.Retirement.JournalDir, "serving")})
}
- next := hostbox.ColdSuccessor{Host: f.current.Host, Incarnation: f.current.Incarnation, Box: f.actor.Box, Enrollment: f.actor.Enrollment, DirectoryRevision: strconv.FormatUint(f.actor.Revision, 10), ETag: f.f.read().ETag, Generation: f.current.Generation, Stamp: f.current.Stamp, Session: f.current.Session}
+ next := hostbox.ColdSuccessor{Host: f.current.Host, Incarnation: f.current.Incarnation, Box: f.actor.Box, Enrollment: f.actor.Enrollment, DirectoryRevision: f.actor.Binding, ETag: f.f.read().ETag, Generation: f.current.Generation, Stamp: f.current.Stamp, Session: f.current.Session}
if err := root.servingHandover().Run(t.Context(), f.receipt.Target, next); err != nil {
t.Fatal(err)
}
diff --git a/internal/host/plan14_recovery_source_test.go b/internal/host/plan14_recovery_source_test.go
index c7588b064..bdfbd8503 100644
--- a/internal/host/plan14_recovery_source_test.go
+++ b/internal/host/plan14_recovery_source_test.go
@@ -28,7 +28,7 @@ func TestPlan14RecoveryInventorySourceGap(t *testing.T) {
}
h.Guard.FenceView = authority.Root.View
plan14PutRecord(t, f.claims, provision.Record{Schema: 1, Host: o.Host, Account: holder.Account, App: holder.App, Channel: "stable", CreatedAt: f.now})
- actor := hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7, Binding: "7"}
root := ClaimRootHTTP{Stop: ClaimStopHTTP{Coordinator: ClaimStopCoordinator{Guard: authority, Evidence: f.claims}, Authenticate: func(context.Context, net.Conn) (StopPeer, error) { return f.peer, nil }}, InventoryActor: func(context.Context) (hostbox.Actor, error) { return actor, nil }, Roots: map[string]string{"data": f.guard.DataDir}, Reconcile: hostbox.ReconcileAdapter{Inventory: h.Inventory, Registry: h.Registry, Box: actor.Box, Enrollment: actor.Enrollment}}
// Inventory reads use the same authenticated Unix endpoint as production.
journals, err := hostbox.NewJournalService(f.journal)
diff --git a/internal/host/plan14_timer_intention_test.go b/internal/host/plan14_timer_intention_test.go
index e3687b7b5..aca98c78d 100644
--- a/internal/host/plan14_timer_intention_test.go
+++ b/internal/host/plan14_timer_intention_test.go
@@ -100,7 +100,7 @@ func plan14TimerIntention(t *testing.T, open func(*testing.T) rootstate.Store) {
if err := g.EstablishRoot(t.Context(), hostguard.RootInstallation{Artifacts: artifacts, Host: o.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Account: h.Account, App: h.App, Record: h.Key, Box: "box-1", Enrollment: "en", Migration: 1, InventoryRevision: 1}, func(*hostclaim.Claim) error { return nil }); err != nil {
t.Fatal(err)
}
- actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Revision: 1}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Revision: 1, Binding: "1"}
root := ClaimRootHTTP{Stop: ClaimStopHTTP{Coordinator: ClaimStopCoordinator{Guard: g, Evidence: f.claims}}, Journals: journals, InventoryActor: func(context.Context) (hostbox.Actor, error) { return actor, nil }, Roots: map[string]string{"data": g.DataDir}, Reconcile: hostbox.ReconcileAdapter{Registry: reg, Census: &hostbox.EmptyInstallationCensus{}}}
var last hostbox.JournalRequest
_, client := hostbox.RemoteJournals(func(ctx context.Context, q hostbox.JournalRequest) (hostbox.JournalResponse, error) {
diff --git a/internal/host/plan9_cleanup_identity_test.go b/internal/host/plan9_cleanup_identity_test.go
index c4bda94fb..09c83a876 100644
--- a/internal/host/plan9_cleanup_identity_test.go
+++ b/internal/host/plan9_cleanup_identity_test.go
@@ -19,7 +19,7 @@ import (
func TestPlan9CleanupEnrollmentDoesNotGrantExecution(t *testing.T) {
root := ed25519.NewKeyFromSeed(make([]byte, 32))
evidence := ed25519.NewKeyFromSeed([]byte(strings.Repeat("e", 32)))
- actor := hostbox.Actor{Box: "box", Enrollment: strings.Repeat("a", 32), Revision: 1, Region: "ie"}
+ actor := hostbox.Actor{Box: "box", Enrollment: strings.Repeat("a", 32), Revision: 1, Binding: "1", Region: "ie"}
identity := handoverRecoveryIdentity(t, actor)
cloudActor, err := identity.Roster.Actor(t.Context(), actor.Box)
if err != nil {
diff --git a/internal/host/plan9_fix1_reset_worker_test.go b/internal/host/plan9_fix1_reset_worker_test.go
index f331b1d92..598316e32 100644
--- a/internal/host/plan9_fix1_reset_worker_test.go
+++ b/internal/host/plan9_fix1_reset_worker_test.go
@@ -25,7 +25,7 @@ func (s *plan9ResetListingStore) List(ctx context.Context, prefix string) ([]str
}
func TestPlan9Fix1ResetWorkerAppliesBackoff(t *testing.T) {
store := &plan9ResetListingStore{Store: release.NewDirStore(t.TempDir()), calls: make(chan time.Time, 4)}
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 1, Region: "ie"})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 1, Binding: "1", Region: "ie"})
a := &ClaimAssembly{Mode: "agent", Identity: identity, Claims: store, RetirementAuthority: &hostops.ProductionAuthority{Directory: hostactors.Directory{Store: store}}, Wake: &ClaimWakeAssembly{}, Launches: &hostbox.LaunchJournal{}, Close: func(context.Context) error { return nil }}
if err := a.startWakeResetWorker(t.Context()); err != nil {
t.Fatal(err)
diff --git a/internal/host/plan9_production_test.go b/internal/host/plan9_production_test.go
index 42060ef85..518a679b1 100644
--- a/internal/host/plan9_production_test.go
+++ b/internal/host/plan9_production_test.go
@@ -140,7 +140,7 @@ func TestPlan9ParticipationFailedOpenCanDischargeAfterPositiveCleanup(t *testing
if err := os.Mkdir(filepath.Join(f.guard.DataDir, ".hostexec"), 0700); err != nil {
t.Fatal(err)
}
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 1, Region: "ie"})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 1, Binding: "1", Region: "ie"})
ready := make(chan struct{})
close(ready)
slot := &claimParticipation{Ready: ready, Err: execlease.ErrLost, CleanupSucceeded: true, Captured: o,
@@ -195,7 +195,7 @@ func TestPlan9RootAndAdoptLeaveStaleParticipationForAgent(t *testing.T) {
if err = os.WriteFile(path, raw, 0600); err != nil {
t.Fatal(err)
}
- actor := hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 1, Region: "ie"}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 1, Binding: "1", Region: "ie"}
// No cleanup dependencies: a root observer must refuse before touching
// the journal, root socket or lifetime locks.
p := productionClaimLocal{legacyParticipation: true, Resources: ClaimRuntimeResources{Mode: mode, DataDir: f.guard.DataDir}, assembly: &ClaimAssembly{}, lifetime: t.Context(), slots: map[string]*claimParticipation{}}
@@ -234,7 +234,7 @@ func TestPlan9ParticipationDoesNotSkipPreviousAgentState(t *testing.T) {
if err := os.WriteFile(filepath.Join(directory, o.Host+".json"), body, 0600); err != nil {
t.Fatal(err)
}
- actor := hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 1, Region: "ie"}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 1, Binding: "1", Region: "ie"}
p := productionClaimLocal{legacyParticipation: true, Resources: ClaimRuntimeResources{Mode: "agent", DataDir: f.guard.DataDir}, Identity: handoverRecoveryIdentity(t, actor), Store: f.claims, assembly: &ClaimAssembly{}, lifetime: t.Context(), slots: map[string]*claimParticipation{}}
// Missing cleanup proof must surface. Success would mean the scan silently
// skipped a surviving prior controller just because no slot exists in RAM.
@@ -257,7 +257,7 @@ func (s *plan9DeadlineStore) Get(ctx context.Context, key string) ([]byte, strin
}
func TestPlan9ParticipationBoundsEachClaimReadIndependently(t *testing.T) {
f := newRecoveryFixture(t)
- actor := hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 1, Region: "ie"}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 1, Binding: "1", Region: "ie"}
store := &plan9DeadlineStore{Store: f.claims}
p := productionClaimLocal{legacyParticipation: true, Resources: ClaimRuntimeResources{Mode: "agent", DataDir: f.guard.DataDir}, Identity: handoverRecoveryIdentity(t, actor), Store: store, slots: map[string]*claimParticipation{}}
before := time.Now()
diff --git a/internal/host/plan9fix4_claimjournal_migration_linux_test.go b/internal/host/plan9fix4_claimjournal_migration_linux_test.go
index 81d0e24fd..f605c7223 100644
--- a/internal/host/plan9fix4_claimjournal_migration_linux_test.go
+++ b/internal/host/plan9fix4_claimjournal_migration_linux_test.go
@@ -46,7 +46,7 @@ func fix4JournalFixture(t *testing.T) (release.Store, ClaimRuntimeResources, fix
root := ed25519.NewKeyFromSeed(bytes.Repeat([]byte{1}, ed25519.SeedSize))
evidence := ed25519.NewKeyFromSeed(bytes.Repeat([]byte{2}, ed25519.SeedSize))
store := release.NewDirStore(t.TempDir())
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: strings.Repeat("a", 32), Revision: 1, Region: "ie", ControlBucket: "deployment"})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "box", Enrollment: strings.Repeat("a", 32), Revision: 1, Binding: "1", Region: "ie", ControlBucket: "deployment"})
actor, err := identity.Verify(t.Context())
if err != nil {
t.Fatal(err)
diff --git a/internal/host/relocationassembly_test.go b/internal/host/relocationassembly_test.go
index 07da054e9..fbfeacbd4 100644
--- a/internal/host/relocationassembly_test.go
+++ b/internal/host/relocationassembly_test.go
@@ -234,7 +234,7 @@ func TestRelocationCollectRecoversAfterARestart(t *testing.T) {
t.Fatal(err)
}
e.Identity = func(context.Context) (RelocationIdentity, error) {
- return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 4}, BootID: "boot-2", ControllerID: "ctl-2", PID: 200, ProcessStart: "9000"}, nil
+ return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 4, Binding: "4"}, BootID: "boot-2", ControllerID: "ctl-2", PID: 200, ProcessStart: "9000"}, nil
}
if _, err := e.Release(ctx, obs); err != nil {
t.Fatal(err)
diff --git a/internal/host/relocationattempts_linux_test.go b/internal/host/relocationattempts_linux_test.go
index a5f713f88..dd8317231 100644
--- a/internal/host/relocationattempts_linux_test.go
+++ b/internal/host/relocationattempts_linux_test.go
@@ -196,7 +196,7 @@ func TestRootAuthorizesAReservationTheRelocationJournalHolds(t *testing.T) {
Attempts: map[string]claimLaunchAttemptReader{hostclaim.KindRelocating: relocationAttemptReader{DataDir: dataDir}},
Guard: hostguard.Guard{DataDir: dataDir, LockDir: t.TempDir(), Claims: hostguard.StoreReader{Store: f.claims}},
Actor: func(context.Context) (hostbox.Actor, error) {
- return hostbox.Actor{Box: "dst", Enrollment: enrollment, Revision: 7, Region: "ie", Eligible: true}, nil
+ return hostbox.Actor{Box: "dst", Enrollment: enrollment, Revision: 7, Binding: "7", Region: "ie", Eligible: true}, nil
},
Kernel: kernel}
configureLaunchParticipation(t, &launchFixture{root: root, peer: peer, target: target, claims: &launchClaims{obs: admitted}})
diff --git a/internal/host/relocationeffects.go b/internal/host/relocationeffects.go
index 3a8dbdd7f..303f4cea0 100644
--- a/internal/host/relocationeffects.go
+++ b/internal/host/relocationeffects.go
@@ -272,7 +272,7 @@ func releaseStopRequest(obs hostclaim.Observed, id RelocationIdentity) StopReque
c, h := obs.Claim, obs.Claim.Holder
return StopRequest{Region: id.Actor.Region, Host: c.Host, Incarnation: h.Incarnation, InstallationStamp: h.Stamp, WriterSession: h.Session,
OperationID: c.Op.ID, Phase: c.Op.Phase, ObligationID: RelocationReleaseObligation, Box: id.Actor.Box, Enrollment: id.Actor.Enrollment,
- BootID: id.BootID, ControllerID: id.ControllerID, ExpectedClaimETag: obs.ETag, ExpectedDirectoryRevision: fmt.Sprint(id.Actor.Revision)}
+ BootID: id.BootID, ControllerID: id.ControllerID, ExpectedClaimETag: obs.ETag, ExpectedDirectoryRevision: id.Actor.Binding}
}
// replayDischarged returns the release whose receipt already discharged
diff --git a/internal/host/relocationeffects_test.go b/internal/host/relocationeffects_test.go
index 77517d050..fff2cb9a9 100644
--- a/internal/host/relocationeffects_test.go
+++ b/internal/host/relocationeffects_test.go
@@ -92,7 +92,7 @@ func effectsFixture(t *testing.T) (*RelocationEffects, hostclaim.Observed, *[]st
return execctl.State{Binding: execctl.Binding{Host: "shop.example", Incarnation: "inc", Op: "rel-1", Enrollment: "enr", BootID: "boot", ControllerID: "c9"}, LeaseETag: "lease-1", Expires: exp}, nil
},
Identity: func(context.Context) (RelocationIdentity, error) {
- return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 4}, BootID: "boot", ControllerID: "ctl", PID: 100, ProcessStart: "5000"}, nil
+ return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 4, Binding: "4"}, BootID: "boot", ControllerID: "ctl", PID: 100, ProcessStart: "5000"}, nil
},
Producers: func(context.Context, hostclaim.Observed) (StopDrainer, error) { return recordingDrain{calls}, nil },
WritersStopped: func(_ context.Context, o hostclaim.Observed) (ClaimWritersDrained, WritersStoppedEvidence, error) {
@@ -234,7 +234,7 @@ func TestRelocationReleaseReplaysOnlyRecordedPositions(t *testing.T) {
t.Run("an identity without its process", func(t *testing.T) {
e, obs, calls, _ := effectsFixture(t)
e.Identity = func(context.Context) (RelocationIdentity, error) {
- return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 4}, BootID: "boot", ControllerID: "ctl"}, nil
+ return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 4, Binding: "4"}, BootID: "boot", ControllerID: "ctl"}, nil
}
if _, err := e.Release(context.Background(), obs); !errors.Is(err, ErrClaimStopUnavailable) || len(*calls) != 0 {
t.Fatalf("released without a process identity: %v ran %v", err, *calls)
@@ -286,7 +286,7 @@ func TestReleaseNeverReturnsBeforeRootsReceipt(t *testing.T) {
// (same boot, same controller); the retry still names the
// revision the stop was flushed under.
e.Identity = func(context.Context) (RelocationIdentity, error) {
- return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 5}, BootID: "boot", ControllerID: "ctl", PID: 100, ProcessStart: "5000"}, nil
+ return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 5, Binding: "5"}, BootID: "boot", ControllerID: "ctl", PID: 100, ProcessStart: "5000"}, nil
}
r, err := e.Release(context.Background(), obs)
if err != nil || r.FinalTXID != 41 || r.ManifestSeq != 8 {
@@ -320,7 +320,7 @@ func TestReleaseAfterARestartRecoversTheRecordedOwner(t *testing.T) {
t.Fatal(err)
}
e.Identity = func(context.Context) (RelocationIdentity, error) {
- return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 5}, BootID: "boot-2", ControllerID: "ctl-2", PID: 200, ProcessStart: "9000"}, nil
+ return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 5, Binding: "5"}, BootID: "boot-2", ControllerID: "ctl-2", PID: 200, ProcessStart: "9000"}, nil
}
var asked StopRequest
recovery := false
@@ -351,7 +351,7 @@ func TestReleaseAfterARestartRecoversTheRecordedOwner(t *testing.T) {
}
*calls = nil
e.Identity = func(context.Context) (RelocationIdentity, error) {
- return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 4}, BootID: "boot", ControllerID: "ctl", PID: 101, ProcessStart: "6000"}, nil
+ return RelocationIdentity{Actor: hostbox.Actor{Box: "src", Enrollment: "enr", Revision: 4, Binding: "4"}, BootID: "boot", ControllerID: "ctl", PID: 101, ProcessStart: "6000"}, nil
}
var asked StopRequest
recovery := false
diff --git a/internal/host/relocationfinish_unix_test.go b/internal/host/relocationfinish_unix_test.go
index 4047b0e7b..22aeed30c 100644
--- a/internal/host/relocationfinish_unix_test.go
+++ b/internal/host/relocationfinish_unix_test.go
@@ -207,7 +207,7 @@ func TestRelocatePassFinishesACompletionFromItsRecord(t *testing.T) {
// to the world's assembly: DischargeCompleted is the production discharge
// (carry 6), its identity a verifying one for dst.
func (w *finishWorld) productionLocal() *productionClaimLocal {
- identity := handoverRecoveryIdentity(w.t, hostbox.Actor{Box: "dst", Enrollment: "enr", Region: "ie", Revision: 1})
+ identity := handoverRecoveryIdentity(w.t, hostbox.Actor{Box: "dst", Enrollment: "enr", Region: "ie", Revision: 1, Binding: "1"})
return &productionClaimLocal{legacyParticipation: true, Resources: ClaimRuntimeResources{Mode: "agent", DataDir: w.dataDir}, Identity: identity, Store: w.store,
slots: map[string]*claimParticipation{}, assembly: w.assembly, lifetime: w.t.Context()}
}
diff --git a/internal/host/relocationfirstwake_unix_test.go b/internal/host/relocationfirstwake_unix_test.go
index 93f1bacb6..d8ac69136 100644
--- a/internal/host/relocationfirstwake_unix_test.go
+++ b/internal/host/relocationfirstwake_unix_test.go
@@ -40,7 +40,7 @@ func TestCompletionPassThenFirstServingWakeWithRegionHAOff(t *testing.T) {
ctx := t.Context()
f := newRecoveryFixture(t)
const box, op = "box-1", "rel-1"
- local := claimStopLocal{Actor: hostbox.Actor{Box: box, Enrollment: "enrollment-1", Revision: 7, Region: "ie"}, BootID: "boot-0", ControllerID: "controller-0", PID: 4000, ProcessStart: "start-0"}
+ local := claimStopLocal{Actor: hostbox.Actor{Box: box, Enrollment: "enrollment-1", Revision: 7, Binding: "7", Region: "ie"}, BootID: "boot-0", ControllerID: "controller-0", PID: 4000, ProcessStart: "start-0"}
// The relocating claim at probing on box-1, its probe passed with
// session 12 at install stamp 9.
diff --git a/internal/host/relocationhandover_unix_test.go b/internal/host/relocationhandover_unix_test.go
index 35eb474bd..af152b40b 100644
--- a/internal/host/relocationhandover_unix_test.go
+++ b/internal/host/relocationhandover_unix_test.go
@@ -74,7 +74,7 @@ func TestRelocationCompletedHandoverRoutesOnlyTheCompletedPrior(t *testing.T) {
stops, locals := 0, 0
w := &ClaimWakeAssembly{Stop: func(context.Context, hostclaim.Observed) error { stops++; return nil }}
local := func(context.Context, hostclaim.Observed, hostclaim.Observed) error { locals++; return nil }
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "dst", Enrollment: "enr", Region: "ie", Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "dst", Enrollment: "enr", Region: "ie", Revision: 1, Binding: "1"})
completed := &relocationCompletedHandover{Guard: f.a.Guard, Identity: identity, Socket: socket, Box: "dst"}
wireClaimAdmission(w, "dst", local, claimCrossBoxHandover{}, &ClaimRelocationOwners{}, completed)
@@ -210,7 +210,7 @@ func TestRelocationCompletedHandoverWithRegionHAOff(t *testing.T) {
stops, locals := 0, 0
w := &ClaimWakeAssembly{Stop: func(context.Context, hostclaim.Observed) error { stops++; return nil }}
w.AfterAdmission = func(context.Context, hostclaim.Observed, hostclaim.Observed) error { locals++; return nil }
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "dst", Enrollment: "enr", Region: "ie", Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "dst", Enrollment: "enr", Region: "ie", Revision: 1, Binding: "1"})
wireProductionAdmission(w, "dst", movesC1, claimCrossBoxHandover{Box: "dst"}, nil,
&relocationCompletedHandover{Guard: f.a.Guard, Identity: identity, Socket: socket, Box: "dst"})
@@ -238,7 +238,7 @@ func TestRelocationCompletedHandoverWithRegionHAOff(t *testing.T) {
stops, locals := 0, 0
w := &ClaimWakeAssembly{Stop: func(context.Context, hostclaim.Observed) error { stops++; return nil }}
w.AfterAdmission = func(context.Context, hostclaim.Observed, hostclaim.Observed) error { locals++; return nil }
- identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "dst", Enrollment: "enr", Region: "ie", Revision: 1})
+ identity := handoverRecoveryIdentity(t, hostbox.Actor{Box: "dst", Enrollment: "enr", Region: "ie", Revision: 1, Binding: "1"})
wireProductionAdmission(w, "dst", movesC1, claimCrossBoxHandover{Box: "dst"}, nil,
&relocationCompletedHandover{Guard: f.a.Guard, Identity: identity, Socket: socket, Box: "dst"})
c := *f.obs.Claim
diff --git a/internal/host/relocationinstall_linux_test.go b/internal/host/relocationinstall_linux_test.go
index f4df9b38e..817469357 100644
--- a/internal/host/relocationinstall_linux_test.go
+++ b/internal/host/relocationinstall_linux_test.go
@@ -86,7 +86,7 @@ func newInstallFixtureWith(t *testing.T, opts buildOptions) *installFixture {
r := claimCensusBox(t)
opts.Data = r.DataDir
b := newBuildFixtureWith(t, opts)
- f := &installFixture{buildFixture: b, r: r, actor: hostbox.Actor{Box: "dst", Enrollment: strings.Repeat("a", 32), Region: "ie", Revision: 4}}
+ f := &installFixture{buildFixture: b, r: r, actor: hostbox.Actor{Box: "dst", Enrollment: strings.Repeat("a", 32), Region: "ie", Revision: 4, Binding: "4"}}
// The record the claim's holder names: a hibernating instance that
// derives its paths.
if err := provision.CreateRecord(ctx, b.claims, provision.Record{Schema: 1, Host: buildHost, Slug: "shop", App: "app", Account: "acct", Region: "ie", Channel: "stable", CreatedAt: time.Date(2026, 10, 7, 1, 0, 0, 0, time.UTC)}); err != nil && !errors.Is(err, release.ErrCASConflict) {
diff --git a/internal/host/relocationparticipation_linux_test.go b/internal/host/relocationparticipation_linux_test.go
index 16a8b7529..5b035ed37 100644
--- a/internal/host/relocationparticipation_linux_test.go
+++ b/internal/host/relocationparticipation_linux_test.go
@@ -69,7 +69,7 @@ func newParticipationBox(t *testing.T) *participationBox {
if _, err := b.store.Put(ctx, hostactors.Key, raw, ""); err != nil {
t.Fatal(err)
}
- b.actor = hostbox.Actor{Box: "dst", Enrollment: enrollment("dst"), Region: "ie", Revision: 4}
+ b.actor = hostbox.Actor{Box: "dst", Enrollment: enrollment("dst"), Region: "ie", Revision: 4, Binding: "4"}
created := time.Date(2026, 10, 7, 1, 0, 0, 0, time.UTC)
nh := hostclaim.NewHolder{Family: "instance", Key: "apps/acct/app/instances/" + participationHost + ".json", Account: "acct", App: "app", Host: participationHost, Region: "ie", RecordRegion: "ie", CreatedAt: created}
diff --git a/internal/host/relocationprobefiles_linux_test.go b/internal/host/relocationprobefiles_linux_test.go
index e853ead93..1daf03b75 100644
--- a/internal/host/relocationprobefiles_linux_test.go
+++ b/internal/host/relocationprobefiles_linux_test.go
@@ -104,7 +104,7 @@ func newReplacedProbeFilesFixture(t *testing.T, opts buildOptions, phase string)
t.Fatal(err)
}
build := f.read().Claim.Holder.Stamp
- next := hostbox.Actor{Box: "dst2", Enrollment: strings.Repeat("b", 32), Region: "ie", Revision: 4}
+ next := hostbox.Actor{Box: "dst2", Enrollment: strings.Repeat("b", 32), Region: "ie", Revision: 4, Binding: "4"}
f.update(func(c *hostclaim.Claim) error {
if hostclaim.PreparedOpened(c) {
return errors.New("P was opened")
@@ -544,7 +544,7 @@ func TestRelocationReplacementActivationRefuses(t *testing.T) {
func newReplacedNamedFixture(t *testing.T, opts buildOptions, change func(*hostclaim.Claim)) *probeFilesFixture {
t.Helper()
f := newProbeFilesInstalled(t, opts)
- next := hostbox.Actor{Box: "dst2", Enrollment: strings.Repeat("b", 32), Region: "ie", Revision: 4}
+ next := hostbox.Actor{Box: "dst2", Enrollment: strings.Repeat("b", 32), Region: "ie", Revision: 4, Binding: "4"}
f.update(func(c *hostclaim.Claim) error {
stamp := c.Gen + 1
c.Op.Exec, c.Op.Phase = next.Box, hostclaim.PhaseInstalled
diff --git a/internal/host/relocationreleases_test.go b/internal/host/relocationreleases_test.go
index 23b07b291..6a7e074c8 100644
--- a/internal/host/relocationreleases_test.go
+++ b/internal/host/relocationreleases_test.go
@@ -336,7 +336,7 @@ func (w releaseWorld) releaseEffects(t *testing.T, dir string, pid int, calls *i
steps := &[]string{}
return &RelocationEffects{
Identity: func(context.Context) (RelocationIdentity, error) {
- return RelocationIdentity{Actor: hostbox.Actor{Box: "box", Enrollment: w.en, Region: "ie", Revision: 1}, BootID: "boot", ControllerID: fmt.Sprint("ctl-", pid), PID: pid, ProcessStart: fmt.Sprint(pid * 10)}, nil
+ return RelocationIdentity{Actor: hostbox.Actor{Box: "box", Enrollment: w.en, Region: "ie", Revision: 1, Binding: "1"}, BootID: "boot", ControllerID: fmt.Sprint("ctl-", pid), PID: pid, ProcessStart: fmt.Sprint(pid * 10)}, nil
},
Producers: func(context.Context, hostclaim.Observed) (StopDrainer, error) { return recordingDrain{steps}, nil },
Collect: w.rootCollect(t, calls),
diff --git a/internal/host/relocationstopprobe_unix_test.go b/internal/host/relocationstopprobe_unix_test.go
index 80ea796ab..69ab5d864 100644
--- a/internal/host/relocationstopprobe_unix_test.go
+++ b/internal/host/relocationstopprobe_unix_test.go
@@ -124,7 +124,7 @@ func newStopProbeFixture(t *testing.T) *stopProbeFixture {
}}
f.act = newStopProbeActivator(&f.order)
f.a = ClaimAssembly{Guard: guard, Wake: wake, stopLocal: func(context.Context) (claimStopLocal, error) {
- return claimStopLocal{Actor: hostbox.Actor{Box: box, Enrollment: "enr", Region: "ie", Revision: 1}, BootID: "boot", ControllerID: "ctl", PID: 100, ProcessStart: "5000"}, nil
+ return claimStopLocal{Actor: hostbox.Actor{Box: box, Enrollment: "enr", Region: "ie", Revision: 1, Binding: "1"}, BootID: "boot", ControllerID: "ctl", PID: 100, ProcessStart: "5000"}, nil
}}
f.cfg = RelocationAssemblyConfig{Activator: f.act, DataDir: dataDir}
return f
diff --git a/internal/host/rootexecution_authority.go b/internal/host/rootexecution_authority.go
index f062d6274..d6962febb 100644
--- a/internal/host/rootexecution_authority.go
+++ b/internal/host/rootexecution_authority.go
@@ -8,7 +8,6 @@ import (
"os"
"reflect"
"slices"
- "strconv"
"github.com/carlosframework/platform/internal/hostbox"
"github.com/carlosframework/platform/internal/hostclaim"
@@ -76,7 +75,7 @@ func (h ClaimRootHTTP) executionAuthority(ctx context.Context, q execlease.Execu
if retirement && etag != c.Op.Intent["etag"] {
return out, hostbox.ErrChanged
}
- out = execlease.ExecutionAuthority{Box: actor.Box, Enrollment: actor.Enrollment, Account: c.Holder.Account, App: c.Holder.App, ClaimRevision: obs.ETag, RecordRevision: etag, DirectoryRevision: strconv.FormatUint(actor.Revision, 10), Kind: c.Op.Kind, Phase: c.Op.Phase}
+ out = execlease.ExecutionAuthority{Box: actor.Box, Enrollment: actor.Enrollment, Account: c.Holder.Account, App: c.Holder.App, ClaimRevision: obs.ETag, RecordRevision: etag, DirectoryRevision: actor.Binding, Kind: c.Op.Kind, Phase: c.Op.Phase}
captured := hostguard.Captured{Incarnation: q.Incarnation, Stamp: q.Stamp}
view, err := h.Stop.Coordinator.Guard.Root.View(ctx, q.Host, captured)
if retirement && err != nil {
diff --git a/internal/host/rootinventory.go b/internal/host/rootinventory.go
index 219ab5e42..209810034 100644
--- a/internal/host/rootinventory.go
+++ b/internal/host/rootinventory.go
@@ -11,7 +11,6 @@ import (
"os"
"path/filepath"
"reflect"
- "strconv"
"time"
"github.com/carlosframework/platform/internal/hostbox"
@@ -64,7 +63,7 @@ func (h ClaimRootHTTP) commitRootInventoryPending(ctx context.Context, q hostbox
}
in, t := q.Inventory, q.Target
in.Entries = append([]hostbox.StopInventoryEntry(nil), in.Entries...)
- if q.Op != "inventory-write" || !in.Complete || in.Box != actor.Box || in.Enrollment != actor.Enrollment || in.DirectoryRevision != strconv.FormatUint(actor.Revision, 10) || t.Host != in.Host || t.Incarnation != in.Incarnation || t.Stamp != in.InstallationStamp || t.Box != actor.Box || t.Enrollment != actor.Enrollment || t.ClaimETag == "" || q.RecordKey == "" || q.RecordETag == "" {
+ if q.Op != "inventory-write" || !in.Complete || in.Box != actor.Box || in.Enrollment != actor.Enrollment || in.DirectoryRevision != actor.Binding || t.Host != in.Host || t.Incarnation != in.Incarnation || t.Stamp != in.InstallationStamp || t.Box != actor.Box || t.Enrollment != actor.Enrollment || t.ClaimETag == "" || q.RecordKey == "" || q.RecordETag == "" {
return out, hostbox.ErrChanged
}
observed, err := hostclaim.Read(ctx, h.Stop.Coordinator.Evidence, in.Host)
diff --git a/internal/host/rootinventory_process_test.go b/internal/host/rootinventory_process_test.go
index ac1077f4e..bc889405a 100644
--- a/internal/host/rootinventory_process_test.go
+++ b/internal/host/rootinventory_process_test.go
@@ -30,7 +30,7 @@ func plan14InventoryProcessRoot(t *testing.T, dir string) (ClaimRootHTTP, *rollb
}
disk := &rollbackDisk{dir: filepath.Join(dir, "root")}
guard := hostguard.Guard{DataDir: filepath.Join(dir, "data"), LockDir: filepath.Join(dir, "locks"), Claims: hostguard.StoreReader{Store: store}, Root: hostguard.NewRootAuthority(disk)}
- actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Revision: 1, Region: "ie"}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Revision: 1, Binding: "1", Region: "ie"}
roots := map[string]string{"data": guard.DataDir, "opt": filepath.Join(dir, "opt"), "units": filepath.Join(dir, "units")}
reg := restartTestRegistry(t)
census := &hostbox.EmptyInstallationCensus{Inventory: journals.Inventory, Registry: reg, Launches: journal, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: "1", Roots: roots}
diff --git a/internal/host/rootinventory_startup.go b/internal/host/rootinventory_startup.go
index 6c3dd851e..16fdae1c3 100644
--- a/internal/host/rootinventory_startup.go
+++ b/internal/host/rootinventory_startup.go
@@ -2,7 +2,6 @@ package host
import (
"context"
- "strconv"
"github.com/carlosframework/platform/internal/hostbox"
"github.com/carlosframework/platform/internal/hostguard"
@@ -42,7 +41,7 @@ func recoverRootInventoryStartup(ctx context.Context, store release.Store, r Cla
}
roots := map[string]string{"data": r.DataDir, "opt": r.OptDir, "units": r.UnitsDir}
guard := hostguard.Guard{Root: authority, DataDir: r.DataDir, Claims: hostguard.StoreReader{Store: store}}
- census := &hostbox.EmptyInstallationCensus{Inventory: journals.Inventory, Registry: r.Registry, Launches: launches, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: strconv.FormatUint(actor.Revision, 10), Roots: roots, SharedPaths: claimGlobalSharedPaths(r)}
+ census := &hostbox.EmptyInstallationCensus{Inventory: journals.Inventory, Registry: r.Registry, Launches: launches, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: actor.Binding, Roots: roots, SharedPaths: claimGlobalSharedPaths(r)}
h := ClaimRootHTTP{history: productionCreationHistory, inventoryIdentity: rootstate.ObjectIdentity, Journals: journals, Launches: launches, Roots: roots,
InventoryActor: func(ctx context.Context) (hostbox.Actor, error) { return owners.actorForConstruction(ctx, r.Mode) },
Reconcile: hostbox.ReconcileAdapter{Registry: r.Registry, Inventory: journals.Inventory, Census: census, Box: actor.Box, Enrollment: actor.Enrollment},
diff --git a/internal/host/rootinventory_state_linux.go b/internal/host/rootinventory_state_linux.go
index a01ce8698..c9e03de87 100644
--- a/internal/host/rootinventory_state_linux.go
+++ b/internal/host/rootinventory_state_linux.go
@@ -8,7 +8,6 @@ import (
"fmt"
"os"
"path/filepath"
- "strconv"
"strings"
"github.com/carlosframework/platform/internal/hostbox"
@@ -35,7 +34,7 @@ func (a *ClaimRoleAssembly) prepareStateRemote(ctx context.Context, o hostclaim.
if err != nil {
return err
}
- if !inventory.Complete || inventory.Host != o.Host || inventory.Incarnation != h.Incarnation || inventory.InstallationStamp != h.Stamp || inventory.Box != actor.Box || inventory.Enrollment != actor.Enrollment || inventory.DirectoryRevision != strconv.FormatUint(actor.Revision, 10) {
+ if !inventory.Complete || inventory.Host != o.Host || inventory.Incarnation != h.Incarnation || inventory.InstallationStamp != h.Stamp || inventory.Box != actor.Box || inventory.Enrollment != actor.Enrollment || inventory.DirectoryRevision != actor.Binding {
return hostbox.ErrTypedInventory
}
var expected hostbox.InventoryExpectation
diff --git a/internal/host/rootinventory_test.go b/internal/host/rootinventory_test.go
index ae17b7faf..30723770a 100644
--- a/internal/host/rootinventory_test.go
+++ b/internal/host/rootinventory_test.go
@@ -41,7 +41,7 @@ func TestPlan14RootInventoryEstablishment(t *testing.T) {
guard := f.guard
guard.Root = hostguard.NewRootAuthority(&rollbackMemory{files: map[string][]byte{}})
roots := map[string]string{"data": t.TempDir(), "opt": t.TempDir(), "units": t.TempDir()}
- actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Revision: 1, Region: "ie"}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Revision: 1, Binding: "1", Region: "ie"}
census := &hostbox.EmptyInstallationCensus{Inventory: journals.Inventory, Registry: reg, Launches: f.journal, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: "1", Roots: roots}
root := ClaimRootHTTP{Journals: journals, Launches: f.journal, Roots: roots, InventoryActor: func(context.Context) (hostbox.Actor, error) { return actor, nil }, Reconcile: hostbox.ReconcileAdapter{Registry: reg, Inventory: journals.Inventory, Census: census, Box: actor.Box, Enrollment: actor.Enrollment}, Stop: ClaimStopHTTP{Coordinator: ClaimStopCoordinator{Guard: guard, Evidence: f.claims}}}
expected := hostbox.InventoryExpectation{RecordKey: h.Key, RecordETag: etag, Target: hostguard.FenceTarget{Host: o.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Session: h.Session, Box: actor.Box, Enrollment: actor.Enrollment, ClaimETag: o.ETag, Op: o.Claim.Op.ID, Phase: o.Claim.Op.Phase}}
@@ -131,7 +131,7 @@ func testInventoryRegistrationWith(t *testing.T, persistent bool, oldBoot []bool
rootGuard.Root = hostguard.NewRootAuthority(authority)
}
roots := map[string]string{"data": f.guard.DataDir, "opt": t.TempDir(), "units": t.TempDir()}
- actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Revision: 1, Region: "ie"}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Revision: 1, Binding: "1", Region: "ie"}
census := &hostbox.EmptyInstallationCensus{Inventory: journals.Inventory, Registry: reg, Launches: f.journal, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: "1", Roots: roots, SharedPaths: map[string][]string{"data": {"hostguard"}}}
root := ClaimRootHTTP{Journals: journals, Launches: f.journal, Roots: roots, InventoryActor: func(context.Context) (hostbox.Actor, error) { return actor, nil }, Reconcile: hostbox.ReconcileAdapter{Registry: reg, Inventory: journals.Inventory, Census: census, Box: actor.Box, Enrollment: actor.Enrollment}, Stop: ClaimStopHTTP{Coordinator: ClaimStopCoordinator{Guard: rootGuard, Evidence: f.claims}}}
if persistent {
diff --git a/internal/host/rootinventory_timer_test.go b/internal/host/rootinventory_timer_test.go
index 4e195d950..04f0e372a 100644
--- a/internal/host/rootinventory_timer_test.go
+++ b/internal/host/rootinventory_timer_test.go
@@ -53,7 +53,7 @@ func TestPlan14RootTimerInventory(t *testing.T) {
if err = g.EstablishRoot(t.Context(), hostguard.RootInstallation{Artifacts: hostguard.InstallationArtifacts{Schema: 1, StateDirectory: true}, Host: o.Host, Incarnation: h.Incarnation, Stamp: h.Stamp, Account: h.Account, App: h.App, Record: h.Key, Box: "box-1", Enrollment: "en", Migration: 1, InventoryRevision: 1}, func(*hostclaim.Claim) error { return nil }); err != nil {
t.Fatal(err)
}
- actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Revision: 1}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "en", Revision: 1, Binding: "1"}
root := ClaimRootHTTP{Stop: ClaimStopHTTP{Coordinator: ClaimStopCoordinator{Guard: g, Evidence: f.claims}}, Journals: journals, InventoryActor: func(context.Context) (hostbox.Actor, error) { return actor, nil }, Roots: map[string]string{"data": g.DataDir}, Reconcile: hostbox.ReconcileAdapter{Registry: reg, Census: &hostbox.EmptyInstallationCensus{}}}
e := hostbox.StopInventoryEntry{Kind: "timer", ArtifactID: "timer", ManagedRoot: "registry", RelativePath: o.Host + "/daily", RowIdentity: timer.ClaimRowID, Ownership: owner.ClaimOwner, Materialization: "materialized"}
switch attack {
diff --git a/internal/host/rootrecovery_process_test.go b/internal/host/rootrecovery_process_test.go
index 0fdb97239..b721bf2b3 100644
--- a/internal/host/rootrecovery_process_test.go
+++ b/internal/host/rootrecovery_process_test.go
@@ -16,7 +16,7 @@ import (
func plan14RebindProcessRoot(t *testing.T, dir string) (ClaimRootHTTP, *rollbackDisk, recoveryRebindRequest) {
root, disk := plan14InventoryProcessRoot(t, dir)
root.InventoryActor = func(context.Context) (hostbox.Actor, error) {
- return hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7}, nil
+ return hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7, Binding: "7"}, nil
}
raw, err := os.ReadFile(filepath.Join(dir, "request.json"))
if err != nil {
diff --git a/internal/host/rootrecovery_rebind.go b/internal/host/rootrecovery_rebind.go
index 4d400b6a9..66b9c7392 100644
--- a/internal/host/rootrecovery_rebind.go
+++ b/internal/host/rootrecovery_rebind.go
@@ -65,7 +65,7 @@ func (h ClaimRootHTTP) rebindRecoveryInventory(ctx context.Context, q recoveryRe
return err
}
n := q.Next
- if n.Box != actor.Box || n.Enrollment != actor.Enrollment || n.DirectoryRevision != strconv.FormatUint(actor.Revision, 10) || n.Incarnation != q.Prior.Incarnation || n.Stamp <= q.Prior.Stamp || n.Session != n.Stamp || n.Generation == "" || n.ETag == "" {
+ if n.Box != actor.Box || n.Enrollment != actor.Enrollment || actor.Binding == "" || n.DirectoryRevision != actor.Binding || n.Incarnation != q.Prior.Incarnation || n.Stamp <= q.Prior.Stamp || n.Session != n.Stamp || n.Generation == "" || n.ETag == "" {
return hostbox.ErrChanged
}
source, revision, err := h.Reconcile.Inventory.Snapshot(ctx, n.Host, q.Prior)
diff --git a/internal/host/rootrecovery_rebind_test.go b/internal/host/rootrecovery_rebind_test.go
index cc1d07c84..2081e3631 100644
--- a/internal/host/rootrecovery_rebind_test.go
+++ b/internal/host/rootrecovery_rebind_test.go
@@ -33,7 +33,7 @@ func plan14RecoveryRebind(t *testing.T) (*recoveryFixture, ClaimRootHTTP, *rollb
if err != nil {
t.Fatal(err)
}
- actor := hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7}
+ actor := hostbox.Actor{Box: "box-1", Enrollment: "enrollment-1", Revision: 7, Binding: "7"}
root := ClaimRootHTTP{Stop: ClaimStopHTTP{Coordinator: ClaimStopCoordinator{Guard: g, Evidence: f.claims}}, InventoryActor: func(context.Context) (hostbox.Actor, error) { return actor, nil }, Roots: map[string]string{"data": g.DataDir}, Reconcile: hostbox.ReconcileAdapter{Inventory: h.Inventory, Registry: h.Registry, Box: actor.Box, Enrollment: actor.Enrollment}}
q := recoveryRebindRequest{V: 1, Prior: hostguard.Captured{Incarnation: holder.Incarnation, Stamp: holder.Stamp}, Revision: 1, RecordKey: holder.Key, RecordETag: etag, Next: hostbox.ColdSuccessor{Host: next.Host, Incarnation: n.Incarnation, Stamp: n.Stamp, Session: n.Session, Generation: n.Generation, Box: actor.Box, Enrollment: actor.Enrollment, DirectoryRevision: "7", ETag: next.ETag, Op: next.Claim.Op.ID, Phase: next.Claim.Op.Phase}}
return f, root, disk, q