carlos / platform Public

console: pin the home-name rule's three spellings together (home part 2, Task 5 P3)

moveHomeName, homeRegionIn and homeRegionOut each spell the home-name
rule out. TestMoveHomeNameRuleAgrees asserts they agree, and that every
region the door accepts survives the round trip it relies on
(toName == homeRegionOut(homeRegionIn(region))), for an explicit home
with and without host claims, the claim fallback, claims disabled, an
unnamed home, and a named region called "home". Red when moveHomeName
drops the claim fallback.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 3ada18decdf99ef95face05077d93d1d19898468 parent 6299f3a
1 file changed, +48 −0
  • internal/console/apiinstancemove_home_test.go +48 −0
diff --git a/internal/console/apiinstancemove_home_test.go b/internal/console/apiinstancemove_home_test.go
index 13d57f031..a04de01c5 100644
--- a/internal/console/apiinstancemove_home_test.go
+++ b/internal/console/apiinstancemove_home_test.go
@@ -403,6 +403,54 @@ func TestMoveDoorHomeRefusalsNameTheHome(t *testing.T) {
}
}
+// moveHomeName, homeRegionIn and homeRegionOut each spell the home-name
+// rule out (homeRegionIn and homeRegionOut inline, to keep the copy gate's
+// derivation shallow), so this pins that they agree, and that every region
+// the door accepts survives the round trip the door relies on: toName, the
+// caller's region, is homeRegionOut(homeRegionIn(region)).
+func TestMoveHomeNameRuleAgrees(t *testing.T) {
+ fallback := Config{HostClaim: true, HibernateBucket: "hibernate-bucket", HibernateRegion: "ie"}
+ claimsOff := fallback
+ claimsOff.HostClaim = false
+ for _, tc := range []struct {
+ name string
+ cfg Config
+ home string // moveHomeName's answer
+ in map[string]string // caller's region -> homeRegionIn's code
+ }{
+ {"explicit home, no host claims", Config{HomeRegion: "ie"}, "ie", map[string]string{"ie": "", "ca": "ca", "home": "home"}},
+ {"explicit home, host claims", Config{HomeRegion: "ie", HostClaim: true}, "ie", map[string]string{"ie": "", "ca": "ca"}},
+ {"claim fallback", fallback, "ie", map[string]string{"ie": "", "ca": "ca"}},
+ {"claims disabled: no fallback", claimsOff, "", map[string]string{"ie": "ie", "ca": "ca"}},
+ {"unnamed home", Config{HostClaim: true}, "", map[string]string{"ie": "ie", "home": "home"}},
+ {"unnamed home, no host claims", Config{}, "", map[string]string{"ie": "ie"}},
+ {"a named region called home", Config{HomeRegion: "ie", HostClaim: true}, "ie", map[string]string{"home": "home", "ie": ""}},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ s := &Server{cfg: tc.cfg}
+ if got := s.moveHomeName(); got != tc.home {
+ t.Fatalf("moveHomeName = %q, want %q", got, tc.home)
+ }
+ if got := s.homeRegionOut(""); got != tc.home {
+ t.Fatalf("homeRegionOut(\"\") = %q, moveHomeName = %q", got, tc.home)
+ }
+ for region, code := range tc.in {
+ to := s.homeRegionIn(region)
+ if to != code || to != homePlacementCode(s.moveHomeName(), region) {
+ t.Fatalf("homeRegionIn(%q) = %q, want %q (homePlacementCode under moveHomeName: %q)", region, to, code, homePlacementCode(s.moveHomeName(), region))
+ }
+ // The door accepts a non-empty region whose code is valid.
+ if !provision.ValidRegion(to) {
+ t.Fatalf("fixture: %q is not a region the door accepts", region)
+ }
+ if toName := s.homeRegionOut(to); toName != region {
+ t.Fatalf("round trip of %q: homeRegionOut(%q) = %q", region, to, toName)
+ }
+ }
+ })
+ }
+}
+
// The legacy door (switch off) is not touched: its home refusal keeps
// main's sentence, byte for byte.
func TestLegacyMoveDoorStillRefusesHome(t *testing.T) {