carlos / platform Public

moves: the lost-box gate names this box's region through park.PlacementMatches (Task 4 fix round 1, item 4)

movesNamesBox (the gate's and setStrict's predicate) compares each record
code with this box's engine region under the verified home binding, so a
home spelled by its roster name and the home's "" code are one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev f7f3d8e5021a3fcc57bec8c75aa1887c6f54f644 parent 79e817d
2 files changed, +53 −2
  • internal/host/movespass.go +14 −2
  • internal/host/movespass_lost_test.go +39 −0
diff --git a/internal/host/movespass.go b/internal/host/movespass.go
index d83535a37..4c98a4493 100644
--- a/internal/host/movespass.go
+++ b/internal/host/movespass.go
@@ -168,9 +168,21 @@ func (w *movesWorker) setStrict(recs []provision.Record) {
}
// movesNamesBox reports whether rec carries a Phase 1 move naming this
-// box's region: its record's, its source's or its target's.
+// box's region: its record's, its source's or its target's. Each record
+// code is compared with this box's engine region by the shared placement
+// rule (park.PlacementMatches under the verified home binding,
+// ParkHomeRegion), so the home's roster name and its "" code are one.
func movesNamesBox(cfg moveCfg, rec provision.Record) bool {
- return rec.Move != nil && !rec.Move.Legacy() && (rec.Region == cfg.Region || rec.Move.To == cfg.Region || rec.Move.From == cfg.Region)
+ if rec.Move == nil || rec.Move.Legacy() {
+ return false
+ }
+ here := cfg.parkRegion()
+ for _, code := range []string{rec.Region, rec.Move.To, rec.Move.From} {
+ if park.PlacementMatches(cfg.ParkHomeRegion, code, here) {
+ return true
+ }
+ }
+ return false
}
// lostHere is the lost-box gate (moves Q9, Plan 4 Task 10, delta M15) for
diff --git a/internal/host/movespass_lost_test.go b/internal/host/movespass_lost_test.go
index 533f4d53e..cc1f4ec8b 100644
--- a/internal/host/movespass_lost_test.go
+++ b/internal/host/movespass_lost_test.go
@@ -185,3 +185,42 @@ func TestLostBoxGateCoversTheWholePass(t *testing.T) {
})
}
}
+
+// Fix round 1, item 4: the gate names this box's region through the shared
+// placement rule (park.PlacementMatches under the verified home binding),
+// never raw string equality: on the home box (placement code "") a record
+// that spells the home by its roster name names this box, and is gated;
+// without the verified binding it names another region.
+func TestLostBoxGateReadsHomeSpellingsUnderTheBinding(t *testing.T) {
+ s := release.NewDirStore(t.TempDir())
+ inc, err := hostclaim.Incarnation("bab", "app", p1Host, p1Created)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := hostclaim.Update(t.Context(), s, hostclaim.Observed{Host: p1Host, Absent: true}, func(c *hostclaim.Claim) error {
+ c.Holder = &hostclaim.Holder{Family: "instance", Key: provision.RecordKey("bab", "app", p1Host), Account: "bab", App: "app", Incarnation: inc, CreatedAt: p1Created, Location: "instances/" + p1Host, Generation: "cur", Stamp: 1}
+ c.Op = hostclaim.Op{Kind: hostclaim.KindServing, Exec: "home-box"}
+ c.Lost, c.LostRevisions = []string{"home-box"}, map[string]uint64{"home-box": 1}
+ return nil
+ }); err != nil {
+ t.Fatal(err)
+ }
+ for _, spelling := range []provision.Record{
+ {Host: p1Host, Region: "ie", Move: &provision.MoveState{ID: p1ID, From: "ie", To: "uk"}},
+ {Host: p1Host, Region: "uk", Move: &provision.MoveState{ID: p1ID, From: "uk", To: "ie"}},
+ {Host: p1Host, Region: "", Move: &provision.MoveState{ID: p1ID, From: "", To: "uk"}},
+ } {
+ bound := &movesWorker{cfg: moveCfg{Box: "home-box", Region: "", ParkHomeRegion: "ie"}}
+ if !movesNamesBox(bound.cfg, spelling) || !bound.lostHere(t.Context(), s, spelling) {
+ t.Fatalf("the home box under the binding does not gate %+v", spelling.Move)
+ }
+ }
+ unbound := moveCfg{Box: "home-box", Region: ""}
+ if movesNamesBox(unbound, provision.Record{Host: p1Host, Region: "ie", Move: &provision.MoveState{ID: p1ID, From: "ie", To: "uk"}}) {
+ t.Fatal("a roster name matched the home without the verified binding")
+ }
+ named := moveCfg{Box: "de-box", Region: "de", ParkHomeRegion: "ie"}
+ if movesNamesBox(named, provision.Record{Host: p1Host, Region: "", Move: &provision.MoveState{ID: p1ID, From: "", To: "uk"}}) {
+ t.Fatal("a named box matched the home")
+ }
+}