Placement rules: the console's doors and the offline round call regionname
regionname.PlacementMatches is park's rule unchanged; park delegates. The console's homePlacementCode (create, regions, seeds floor, legacy and offline move doors), the box's offline move round and seal, and moveCfg.parkRegion call regionname directly. The golden table passes for both packages. The dbreads fixture computes incarnations through provision.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+31
−18
internal/console/apiinstancemove.go+2 −1internal/dbreads/fixture_test.go+1 −2internal/host/movesoffline.go+10 −10internal/host/movesoffline_seal.go+2 −2internal/host/movessources.go+2 −1internal/park/region_names.go+3 −2internal/regionname/region.go+8 −0internal/regionname/region_golden_test.go+3 −0
diff --git a/internal/console/apiinstancemove.go b/internal/console/apiinstancemove.go| index 2ac1ca6b4..95fda4da5 100644 |
| --- a/internal/console/apiinstancemove.go |
| +++ b/internal/console/apiinstancemove.go |
| @@ -8,6 +8,7 @@ import ( |
| "errors" |
| "fmt" |
| "github.com/carlosframework/platform/internal/park" |
| + "github.com/carlosframework/platform/internal/regionname" |
| "log" |
| "net/http" |
| "os" |
| @@ -316,7 +317,7 @@ func (s *Server) homeRegionIn(region string) string { |
| // home named nothing is the home. claimMoveRosterPlaces reads roster |
| // regions through it too, so the door and the API translate home one way. |
| func homePlacementCode(home, region string) string { |
| - return park.HomePlacementCode(home, region) |
| + return regionname.HomePlacementCode(home, region) |
| } |
| func (s *Server) homeRegionOut(region string) string { |
diff --git a/internal/dbreads/fixture_test.go b/internal/dbreads/fixture_test.go| index c4a481a30..b6388798e 100644 |
| --- a/internal/dbreads/fixture_test.go |
| +++ b/internal/dbreads/fixture_test.go |
| @@ -22,7 +22,6 @@ import ( |
| "github.com/carlosframework/platform/internal/dbdoor" |
| "github.com/carlosframework/platform/internal/dbdoor/dbdoortest" |
| - "github.com/carlosframework/platform/internal/hostclaim" |
| "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/release" |
| ) |
| @@ -182,7 +181,7 @@ func (fx *fixture) record() provision.Record { |
| func (fx *fixture) request(sqlText, at string) Request { |
| fx.t.Helper() |
| rec := fx.record() |
| - inc, err := hostclaim.Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt) |
| + inc, err := provision.Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt) |
| if err != nil { |
| fx.t.Fatal(err) |
| } |
diff --git a/internal/host/movesoffline.go b/internal/host/movesoffline.go| index 3052233d5..aafd2a173 100644 |
| --- a/internal/host/movesoffline.go |
| +++ b/internal/host/movesoffline.go |
| @@ -22,8 +22,8 @@ import ( |
| "github.com/carlosframework/platform/internal/layout" |
| "github.com/carlosframework/platform/internal/lease" |
| "github.com/carlosframework/platform/internal/moves" |
| - "github.com/carlosframework/platform/internal/park" |
| "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/regionname" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| ) |
| @@ -87,7 +87,7 @@ func offlineFenceOwner(id string) string { return "offline:" + id } |
| // offline-landed. offline-open is the target's to release (Task 5). |
| // |
| // Placements are compared as movesNamesBox compares them, by |
| -// park.PlacementMatches under the verified home binding, so the home's "" |
| +// regionname.PlacementMatches under the verified home binding, so the home's "" |
| // and its roster name are one. |
| func offlineHold(box moveCfg) func(rec provision.Record) (status, op string, ok bool) { |
| home, here := box.ParkHomeRegion, box.parkRegion() |
| @@ -98,11 +98,11 @@ func offlineHold(box moveCfg) func(rec provision.Record) (status, op string, ok |
| } |
| switch m.State { |
| case provision.OfflineStopping, provision.OfflineSealing, provision.OfflineSealed: |
| - if park.PlacementMatches(home, m.From, here) { |
| + if regionname.PlacementMatches(home, m.From, here) { |
| return "moving", m.ID, true |
| } |
| case provision.OfflineLanding, provision.OfflineLanded: |
| - if rec.Region == m.To && park.PlacementMatches(home, m.To, here) { |
| + if rec.Region == m.To && regionname.PlacementMatches(home, m.To, here) { |
| return "landing", m.ID, true |
| } |
| } |
| @@ -222,10 +222,10 @@ func (v *offlineView) keep(host string) bool { |
| if !ok || v.region == "" { |
| return false |
| } |
| - if park.PlacementMatches(v.home, m.To, v.region) { |
| + if regionname.PlacementMatches(v.home, m.To, v.region) { |
| return true |
| } |
| - if park.PlacementMatches(v.home, m.From, v.region) { |
| + if regionname.PlacementMatches(v.home, m.From, v.region) { |
| return m.State != provision.OfflineFinishing |
| } |
| return false |
| @@ -250,7 +250,7 @@ func (v *offlineView) elsewhere(host string) bool { |
| case provision.OfflineLanding, provision.OfflineLanded, provision.OfflineOpen, provision.OfflineFinishing: |
| region = m.To |
| } |
| - return !park.PlacementMatches(v.home, region, v.region) |
| + return !regionname.PlacementMatches(v.home, region, v.region) |
| } |
| // refreshOfflineView reads the record list once, outside a moves pass: at |
| @@ -420,8 +420,8 @@ func (w *movesWorker) offlineRound(ctx context.Context, s release.Store, rec pro |
| return nil |
| } |
| here := cfg.parkRegion() |
| - source := here != "" && park.PlacementMatches(cfg.ParkHomeRegion, m.From, here) |
| - target := here != "" && park.PlacementMatches(cfg.ParkHomeRegion, m.To, here) |
| + source := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.From, here) |
| + target := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.To, here) |
| sealer := cfg.Box != "" && cfg.Box == m.Sealer |
| if !cfg.OfflineCapable { |
| if source || target || sealer { |
| @@ -498,7 +498,7 @@ func (w *movesWorker) offlineReassert(ctx context.Context, s release.Store) int |
| } |
| here := cfg.parkRegion() |
| roles := func(m *provision.MoveState) (bool, bool) { |
| - source := here != "" && park.PlacementMatches(cfg.ParkHomeRegion, m.From, here) |
| + source := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.From, here) |
| return offlineReassertRoles(m, source, m.Sealer == cfg.Box) |
| } |
| var hosts []string |
diff --git a/internal/host/movesoffline_seal.go b/internal/host/movesoffline_seal.go| index f72f38d61..f98559c24 100644 |
| --- a/internal/host/movesoffline_seal.go |
| +++ b/internal/host/movesoffline_seal.go |
| @@ -26,8 +26,8 @@ import ( |
| "github.com/carlosframework/platform/internal/lease" |
| "github.com/carlosframework/platform/internal/moves" |
| "github.com/carlosframework/platform/internal/moves/archive" |
| - "github.com/carlosframework/platform/internal/park" |
| "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/regionname" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| ) |
| @@ -214,7 +214,7 @@ func (w *movesWorker) offlineTarget(ctx context.Context, s release.Store, m *pro |
| } |
| sort.Strings(codes) |
| for _, code := range codes { |
| - if park.PlacementMatches(w.cfg.ParkHomeRegion, m.To, park.PlacementRegion(code)) { |
| + if regionname.PlacementMatches(w.cfg.ParkHomeRegion, m.To, regionname.PlacementRegion(code)) { |
| return fleet.targets[code], nil |
| } |
| } |
diff --git a/internal/host/movessources.go b/internal/host/movessources.go| index 3b8a8ed1c..0a4178935 100644 |
| --- a/internal/host/movessources.go |
| +++ b/internal/host/movessources.go |
| @@ -56,6 +56,7 @@ import ( |
| "github.com/carlosframework/platform/internal/moves" |
| "github.com/carlosframework/platform/internal/park" |
| "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/regionname" |
| "github.com/carlosframework/platform/internal/release" |
| ) |
| @@ -73,7 +74,7 @@ const movesNoLiveRegion = "@none" |
| // for or queues in its own region, and the region its claim's engine must |
| // have go through it. An invalid code maps to "", which arms nothing and |
| // which every engine entry refuses. |
| -func (c moveCfg) parkRegion() string { return park.PlacementRegion(c.Region) } |
| +func (c moveCfg) parkRegion() string { return regionname.PlacementRegion(c.Region) } |
| // movesBoxRegion refuses a placement that disagrees with the verified roster. |
| // productionRosterRegion maps home only after checking the signed designation. |
diff --git a/internal/park/region_names.go b/internal/park/region_names.go| index f865694db..739b2cd23 100644 |
| --- a/internal/park/region_names.go |
| +++ b/internal/park/region_names.go |
| @@ -28,9 +28,10 @@ func (e Engine) OwnsRegion(region string) bool { |
| func (v View) sameRegion(a, b string) bool { return SameRegion(v.HomeRegion, a, b) } |
| -// PlacementMatches compares a record code with a nonempty engine identity. |
| +// PlacementMatches compares a record code with a nonempty engine identity |
| +// (regionname.PlacementMatches). |
| func PlacementMatches(home, code, engine string) bool { |
| - return SameRegion(home, PlacementRegion(code), engine) |
| + return regionname.PlacementMatches(home, code, engine) |
| } |
| // BoundHome joins the verified local binding and the admitted operation's |
diff --git a/internal/regionname/region.go b/internal/regionname/region.go| index d56e208f8..ad7fa7691 100644 |
| --- a/internal/regionname/region.go |
| +++ b/internal/regionname/region.go |
| @@ -56,3 +56,11 @@ func SameRegion(home, a, b string) bool { |
| return home != "" && PlacementRegion(home) == home && |
| ((a == home && b == HomeRegion) || (a == HomeRegion && b == home)) |
| } |
| + |
| +// PlacementMatches compares a record's placement code with a nonempty |
| +// engine identity under the verified home binding: the home's "" and its |
| +// roster name are one region. The console's doors and the box's offline |
| +// move round use it (it moved here from park in claims cleanup R1). |
| +func PlacementMatches(home, code, engine string) bool { |
| + return SameRegion(home, PlacementRegion(code), engine) |
| +} |
diff --git a/internal/regionname/region_golden_test.go b/internal/regionname/region_golden_test.go| index a39a30983..03d57825a 100644 |
| --- a/internal/regionname/region_golden_test.go |
| +++ b/internal/regionname/region_golden_test.go |
| @@ -8,6 +8,7 @@ import ( |
| "testing" |
| "github.com/carlosframework/platform/internal/park" |
| + "github.com/carlosframework/platform/internal/regionname" |
| ) |
| // The placement rules the console's create, regions and move doors and the |
| @@ -26,6 +27,8 @@ type placementRules struct { |
| } |
| var placementImpls = map[string]placementRules{ |
| + "regionname": {regionname.PlacementRegion, regionname.HomePlacementCode, regionname.SameRegion, regionname.PlacementMatches}, |
| + // park's delegates, until claims cleanup deletes park. |
| "park": {park.PlacementRegion, park.HomePlacementCode, park.SameRegion, park.PlacementMatches}, |
| } |