carlos / platform Public

moves: the home lane's staging lease is keyed by park.HomeRegion

StagingLeasePrefix built control/staging-leases//<host> for a lane in the
home region (a move out of home's return lane, taken with the record's
From). The key now names the lane's engine region, so home is
park.HomeRegion and named regions, one named "home" among them, keep
their keys unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 89dbfe958519c8c47de9ed653ee9ad4002a4631a parent 7fb8079
2 files changed, +30 −2
  • internal/moves/lease.go +11 −2
  • internal/moves/lease_test.go +19 −0
diff --git a/internal/moves/lease.go b/internal/moves/lease.go
index 8eb0c08e3..e7388cae4 100644
--- a/internal/moves/lease.go
+++ b/internal/moves/lease.go
@@ -5,6 +5,8 @@ import (
"fmt"
"math"
"time"
+
+ "github.com/carlosframework/platform/internal/park"
)
// SignatureLife is how long S3 accepts a SigV4 signature (15 minutes,
@@ -28,9 +30,16 @@ var ErrLeaseUnsafe = errors.New("moves: staging lease too close to its end to si
// StagingLeasePrefix is the claim's shared staging-work lease (claim C3,
// §7.3 D3): in the deployment bucket, keyed by target region and host, so
// a source that cannot read the target's lock.json still excludes other
-// writers of the same lane.
+// writers of the same lane. targetRegion is the lane's placement code; the
+// key names its engine region (park.PlacementRegion), so the home's "" (a
+// move out of home's return lane) is park.HomeRegion and never an empty
+// segment. A code that is no placement is kept as it is.
func StagingLeasePrefix(targetRegion, host string) string {
- return "control/staging-leases/" + targetRegion + "/" + host
+ region := park.PlacementRegion(targetRegion)
+ if region == "" {
+ region = targetRegion
+ }
+ return "control/staging-leases/" + region + "/" + host
}
// ErrInvalidSkew is a negative Guarded.Skew: it would shrink the window
diff --git a/internal/moves/lease_test.go b/internal/moves/lease_test.go
index 351a664ab..bc557d6f5 100644
--- a/internal/moves/lease_test.go
+++ b/internal/moves/lease_test.go
@@ -6,12 +6,14 @@ import (
"math"
"net/http"
"net/http/httptest"
+ "strings"
"testing"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/carlosframework/platform/internal/lease"
"github.com/carlosframework/platform/internal/lease/leasetest"
+ "github.com/carlosframework/platform/internal/park"
)
type fixedLease struct{ until time.Time }
@@ -185,3 +187,20 @@ func TestGuardedSkewIsValidated(t *testing.T) {
}
}
}
+
+// Home-region parks, part 1: the staging lease of a lane in the home region
+// (a move out of home's return lane) is keyed by park.HomeRegion, never by
+// an empty segment, and apart from every named region, one named "home"
+// among them.
+func TestStagingLeasePrefixNamesHome(t *testing.T) {
+ const host = "a.go.example.com"
+ home := StagingLeasePrefix("", host)
+ if home != "control/staging-leases/"+park.HomeRegion+"/"+host || strings.Contains(home, "//") {
+ t.Fatalf("the home lane's staging lease is %q", home)
+ }
+ for _, code := range []string{"uk", "home", "none"} {
+ if got := StagingLeasePrefix(code, host); got == home || got != "control/staging-leases/"+code+"/"+host {
+ t.Fatalf("%s's staging lease is %q (home's %q)", code, got, home)
+ }
+ }
+}