carlos / platform Public

registry: an import gate leaves PathFront unchanged (#186)

Paul's ruling of 2026-11-21: a front's import gate covers its own route
and its same-box prefixes (case 1), as on main; prefixes whose target
is a tenant app on another box are separate apps and keep serving
during the import. Extending the gate across boxes reliably needs a
cross-box acknowledgement protocol; three review rounds found the
attempts bypassable.

PathFront and PathTarget return to their definitions before 75d18c81
(pathRouteKind goes) and PathEligibilityCases loses the import-gated
and rollback-closed rows. TestImportGateCoversPathRoutesAcrossBoxes is
replaced: TestImportGateLeavesCrossBoxPrefixesServing holds the front's
own route and a same-box prefix gated on the front's box (and from B
and C), and serves the cross-box prefix from all three boxes, open and
rollback-closed gate alike; TestImportCommitRoutesPathsAcrossBoxes
routes all three normally after commit. The HA and upgrade-trigger
fixes from the same wave (6d692fef, ea5800d5) stay.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 37682911fc5e1a704df0a89321433582cc09fd75 parent 3d71110
2 files changed, +107 −73
  • internal/edge/path_across_import_test.go +93 −44
  • internal/registry/pathroute.go +14 −29
diff --git a/internal/edge/path_across_import_test.go b/internal/edge/path_across_import_test.go
index e8b5e4fee..cb74a1277 100644
--- a/internal/edge/path_across_import_test.go
+++ b/internal/edge/path_across_import_test.go
@@ -1,12 +1,13 @@
package edge
// Path routes across boxes (#186) and the import gate (seeded-instances spec
-// §5.4; whole-branch review R1 P1-1). An uncommitted import is not a front
-// route (registry.PathFront), so no box selects its prefixes across boxes:
-// the front's own box keeps today's import gate over them, and every other
-// box sends the request there or refuses it. pathAcrossScene's boxes: the
-// hub (A, the gated front), the tenant (B, the prefix's target) and the
-// third (C, neither).
+// §5.4; spec §7.6, Paul's ruling of 2026-11-21). A front's import gate
+// covers its own route and its same-box prefixes, exactly as on one box
+// (TestImportGateCoversPathRoutes). A prefix whose target is a tenant app on
+// another box is a separate app: it keeps serving while the front imports.
+// pathAcrossScene's boxes: the hub (A, the gated front), the tenant (B, the
+// cross-box prefix's target) and the third (C, neither); A also serves
+// here.example, the target of a same-box prefix.
import (
"net/http"
@@ -16,6 +17,25 @@ import (
"github.com/carlosframework/platform/internal/seeds"
)
+const (
+ acrossHere = "here.example"
+ acrossHerePrefix = "here"
+)
+
+// addSameBoxPrefix homes here.example on A (published as a route of its
+// own) and adds the prefix here -> here.example to the hub's claim on every
+// box, as Task 3 derives the rows.
+func (s *pathAcrossScene) addSameBoxPrefix(t *testing.T) *acrossApp {
+ t.Helper()
+ here := newAcrossApp(t, "here-1")
+ s.route(t, s.hub, acrossInstance(acrossHere, acrossAcct, "here", here.addr()))
+ for _, be := range s.boxes() {
+ s.path(t, be, acrossHub, acrossHerePrefix, acrossHere, acrossAcct, "hub")
+ }
+ s.publish(t, s.hub, acrossHere, acrossRouteEntry(acrossAcct, "here", 5))
+ return here
+}
+
// gateHubAcross swaps hub.example on A for a gated import row served by app,
// reloads A, and republishes A's edges-file row with the marks the shared
// predicates give the stored row, exactly as the edges-file writer does
@@ -53,68 +73,97 @@ func wantImportRefusal(t *testing.T, res acrossResp, what string) {
}
}
-// The gated front's prefix is closed on every box, open gate and rollback's
-// closed gate alike: on A by A's own gate (no dial), on B and C by the
-// backhaul to A (the front's home) and A's gate; and a hop for it reaching
-// B is refused as stale, never served from the target. Nothing reaches the
-// target. Once the legacy row is restored the prefix crosses again.
-func TestImportGateCoversPathRoutesAcrossBoxes(t *testing.T) {
+// The ruling, open gate and rollback's closed gate alike: on the front's box
+// the front's own route and its same-box prefix are refused by the gate, as
+// on main (and from B and C, which send them to A); the cross-box prefix is served by its tenant from every box (case
+// 2 on A, case 3 on B, case 3 with a remote target on C), and never reaches
+// the import's row. After commit everything routes as normal.
+func TestImportGateLeavesCrossBoxPrefixesServing(t *testing.T) {
s := newPathAcrossScene(t)
+ here := s.addSameBoxPrefix(t)
imported := newAcrossApp(t, "imported-1")
token := s.gateHubAcross(t, imported)
+ var tenantSeen []acrossSeen
verified := 0
- closed := func(when string) {
+ during := func(when string) {
t.Helper()
- for _, p := range []string{"/acme/x", "//acme/x", "/x/../acme/x"} {
- wantImportRefusal(t, s.get(t, s.hub, acrossHub, p), when+": front box "+p)
- wantImportRefusal(t, s.get(t, s.tenant, acrossHub, p), when+": target box "+p)
- wantImportRefusal(t, s.get(t, s.third, acrossHub, p), when+": third box "+p)
+ // On the front's box: its own route and the same-box prefix stay
+ // gated, every spelling.
+ wantImportRefusal(t, s.get(t, s.hub, acrossHub, "/other"), when+": front's own route")
+ for _, p := range []string{"/here/x", "//here/x", "/x/../here/x"} {
+ wantImportRefusal(t, s.get(t, s.hub, acrossHub, p), when+": same-box prefix "+p)
}
- s.hop(t, s.tenant, acrossHub, "/acme/x", false).wantStale(t)
- s.hop(t, s.third, acrossHub, "/acme/x", false).wantStale(t)
- if n := s.dialsFrom(s.hub, acrossIPTenant); n != 0 {
- t.Fatalf("%s: the front box dialled the target's box %d times", when, n)
+ // Landing elsewhere they reach the front's box, whose gate refuses
+ // them.
+ for _, be := range []*backhaulEdge{s.tenant, s.third} {
+ wantImportRefusal(t, s.get(t, be, acrossHub, "/other"), when+": front's own route via "+be.box)
+ wantImportRefusal(t, s.get(t, be, acrossHub, "/here/x"), when+": same-box prefix via "+be.box)
}
- if n := s.dialsFrom(s.third, acrossIPTenant); n != 0 {
- t.Fatalf("%s: the third box dialled the target's box %d times", when, n)
+ here.wantSeen(t)
+ // The cross-box prefix keeps serving, from every box.
+ for _, be := range s.boxes() {
+ for _, p := range []string{"/acme/x", "//acme/x"} {
+ s.get(t, be, acrossHub, p).want(t, http.StatusOK, "tenant-1|"+acrossHub+"|"+p)
+ tenantSeen = append(tenantSeen, acrossSeen{acrossHub, p})
+ }
}
- s.tenantApp.wantSeen(t)
+ s.tenantApp.wantSeen(t, tenantSeen...)
+ s.hubApp.wantSeen(t)
if n := len(imported.requests()); n != verified {
t.Fatalf("%s: the import's row was reached %d times, want only the %d verify requests", when, n, verified)
}
- s.hubApp.wantSeen(t)
}
- closed("open gate")
+ during("open gate")
+ if n := s.dialsFrom(s.hub, acrossIPTenant); n == 0 {
+ t.Fatal("the front's box never sent the cross-box prefix to the target's box")
+ }
- // The verify token never opens the prefix's target: no box selects it,
- // so on every box the verify is the front's own request, which the
- // front's box admits to the import's own row and nothing else (as on
- // main, where a prefix naming another box's route fell through to the
- // host's own route).
- for _, be := range s.boxes() {
- req, err := http.NewRequest(http.MethodGet, "https://"+acrossHub+"/acme/x", nil)
- if err != nil {
- t.Fatal(err)
- }
- req.Header.Set(ImportVerifyHeader, token)
- s.do(t, be, req).want(t, http.StatusOK, "imported-1|"+acrossHub+"|/acme/x")
+ // The verify token still opens only the import's own row, on the
+ // front's box; the cross-box prefix is not the import's business.
+ req, err := http.NewRequest(http.MethodGet, "https://"+acrossHub+"/up", nil)
+ if err != nil {
+ t.Fatal(err)
}
- s.tenantApp.wantSeen(t)
- imported.wantSeen(t, acrossSeen{acrossHub, "/acme/x"}, acrossSeen{acrossHub, "/acme/x"}, acrossSeen{acrossHub, "/acme/x"})
- verified = 3
+ req.Header.Set(ImportVerifyHeader, token)
+ s.do(t, s.hub, req).want(t, http.StatusOK, "imported-1|"+acrossHub+"|/up")
+ verified = 1
- // Rollback, step 1: the gate closes; still closed everywhere.
+ // Rollback's closed gate holds the same line.
if err := s.hub.reg.CloseImportGate(acrossHub, gateSeedID, 1); err != nil {
t.Fatal(err)
}
s.republishHub(t, 7)
- closed("closed gate")
+ during("closed gate")
- // Rollback, step 2: the legacy row is back and its prefix crosses again.
+ // Restore the legacy row: everything routes as normal.
if err := s.hub.reg.RestoreImportRoute(acrossHub, gateSeedID); err != nil {
t.Fatal(err)
}
s.republishHub(t, 8)
+ s.get(t, s.hub, acrossHub, "/other").want(t, http.StatusOK, "hub-1|"+acrossHub+"|/other")
+ s.get(t, s.hub, acrossHub, "/here/x").want(t, http.StatusOK, "here-1|"+acrossHub+"|/here/x")
s.get(t, s.third, acrossHub, "/acme/x").want(t, http.StatusOK, "tenant-1|"+acrossHub+"|/acme/x")
}
+
+// After commit the front, its same-box prefix and its cross-box prefix all
+// route as normal, from every box.
+func TestImportCommitRoutesPathsAcrossBoxes(t *testing.T) {
+ s := newPathAcrossScene(t)
+ here := s.addSameBoxPrefix(t)
+ imported := newAcrossApp(t, "imported-1")
+ s.gateHubAcross(t, imported)
+ s.get(t, s.hub, acrossHub, "/acme/x").want(t, http.StatusOK, "tenant-1|"+acrossHub+"|/acme/x")
+
+ if err := s.hub.reg.CommitImport(acrossHub, gateSeedID); err != nil {
+ t.Fatal(err)
+ }
+ s.republishHub(t, 7)
+ s.get(t, s.hub, acrossHub, "/other").want(t, http.StatusOK, "imported-1|"+acrossHub+"|/other")
+ s.get(t, s.hub, acrossHub, "/here/x").want(t, http.StatusOK, "here-1|"+acrossHub+"|/here/x")
+ here.wantSeen(t, acrossSeen{acrossHub, "/here/x"})
+ for _, be := range s.boxes() {
+ s.get(t, be, acrossHub, "/acme/y").want(t, http.StatusOK, "tenant-1|"+acrossHub+"|/acme/y")
+ }
+ s.hubApp.wantSeen(t)
+}
diff --git a/internal/registry/pathroute.go b/internal/registry/pathroute.go
index ad38840db..edf88a907 100644
--- a/internal/registry/pathroute.go
+++ b/internal/registry/pathroute.go
@@ -7,38 +7,28 @@ package registry
// into the edges file) and the edge's selection, so the two can never
// disagree about which routes take part.
-// PathFront reports whether rt may front a cross-box path route: a path
-// route (pathRouteKind) with no import gate. Status does not matter (a
-// starting front still owns its hostname), and HA changes nothing.
+// PathFront reports whether rt may front a cross-box path route: an
+// instance or static route that is not a forward row, a demo or a sidecar.
+// Status does not matter (a starting front still owns its hostname), and
+// HA changes nothing.
//
-// An uncommitted import, its gate open or closed by a rollback, is not a
-// front (whole-branch review R1 P1-1): its own box's import gate holds
-// every prefix under it closed (edge importGateAdmit), and a box that
-// selected one of those prefixes across boxes would dispatch before any
-// box could see the gate. So no box selects across boxes for it; its
-// prefixes reach its own box, which refuses them as it always has.
+// An import gate changes nothing either (spec §7.6, Paul 2026-11-21): the
+// gate covers the front's own route and its same-box prefixes on its own
+// box (edge importGateAdmit), and a prefix whose target is on another box
+// is a separate app that keeps serving during the import.
func PathFront(rt Route) bool {
- return pathRouteKind(rt) && rt.ImportGate == ""
-}
-
-// PathTarget reports whether rt may be the target of a cross-box path
-// route: a path route (pathRouteKind) with Status "ready". HA changes
-// nothing. An import-gated target stays a target: the box serving it runs
-// its import gate on the selected row, so a prefix naming it is refused
-// there, as on one box.
-func PathTarget(rt Route) bool {
- return rt.Status == "ready" && pathRouteKind(rt)
-}
-
-// pathRouteKind is the kind rule both predicates share: an instance or
-// static route that is not a forward row, a demo or a sidecar.
-func pathRouteKind(rt Route) bool {
if rt.Kind != "instance" && rt.Kind != "static" {
return false
}
return !rt.IsForward() && !rt.IsDemo() && !rt.IsSidecar()
}
+// PathTarget reports whether rt may be the target of a cross-box path
+// route: PathFront's rule plus Status "ready". HA changes nothing.
+func PathTarget(rt Route) bool {
+ return rt.Status == "ready" && PathFront(rt)
+}
+
// PathEligibilityCase is one row of PathEligibilityCases.
type PathEligibilityCase struct {
Name string
@@ -63,9 +53,4 @@ var PathEligibilityCases = []PathEligibilityCase{
{Name: "ready HA instance", Route: Route{Kind: "instance", Status: "ready", HA: true}, Front: true, Target: true},
{Name: "ready replica instance", Route: Route{Kind: "instance", Status: "ready", Replica: true}, Front: true, Target: true},
{Name: "ready hibernating instance", Route: Route{Kind: "instance", Status: "ready", Hibernate: true}, Front: true, Target: true},
- // An uncommitted import (seeded-instances spec §5.4) keeps its own box's
- // import gate over every prefix, so it is never a front across boxes;
- // as a target the receiving box's gate refuses it, as on one box.
- {Name: "import-gated instance", Route: Route{Kind: "instance", Status: "ready", ImportGate: "gate-hash"}, Front: false, Target: true},
- {Name: "rollback-closed instance", Route: Route{Kind: "instance", Status: "ready", ImportGate: ImportGateClosed}, Front: false, Target: true},
}