carlos / platform Public

edges file: publish route owner and path eligibility (#186)

Each exact route row in the edges file now carries route_account and
route_app (release.RouteAccount and the row's app) and path_front and
path_target (registry.PathFront and PathTarget). Alias, platform-alias
and "*." rows carry none of them. The door owner (account/app) is
unchanged. All four are additive and omitempty.

The home map carries the four values with the dial winner, never
merged, and exactPathRoute (internal/edge/pathroute_home.go) answers
the exact, dialable route row another box published, with no wildcard
fallback. TestEdgesFilePathMarksMatchPredicates is the spec 5.1 guard:
every PathEligibilityCases row goes through the real writer, and the
cases its filters leave out are listed.

The byte-pinned wire tests and goldens gain the new fields.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 995a08e4ed3a9932fb534fbafd3cfcf6d564e2e0 parent 9f96b1c
12 files changed, +427 −16
  • internal/edge/homemap.go +16 −1
  • internal/edge/pathroute_home.go +51 −0
  • internal/edge/pathroute_home_test.go +99 −0
  • internal/edge/testdata/edges-forward-hub.json +1 −1
  • internal/edgesfile/testdata/assets-host.golden.json +5 −1
  • internal/edgesfile/testdata/regional-box-uk.golden.json +5 −1
  • internal/edgesfile/testdata/regional-box.golden.json +5 −1
  • internal/host/edgesfile.go +21 −1
  • internal/host/edgesfile_pathroute_test.go +214 −0
  • internal/host/edgesfile_test.go +7 −7
  • internal/host/egress_nopolicy_linux_test.go +2 −2
  • internal/host/testdata/edges-p2b-golden.json +1 −1
diff --git a/internal/edge/homemap.go b/internal/edge/homemap.go
index eacdc9893..639abb937 100644
--- a/internal/edge/homemap.go
+++ b/internal/edge/homemap.go
@@ -242,6 +242,15 @@ type edgesHostView struct {
// (#724). Absent reads as pointing: edgesfile.DNSPointing is its only
// reader, and holds the compatibility rule.
DNSPointing *bool `json:"dns_pointing,omitempty"`
+ // RouteAccount, RouteApp, PathFront and PathTarget are the publisher's
+ // exact route row's own owner and path marks (#186, spec §5.1), on a
+ // real route row only. Absent reads as empty and false: an older
+ // publisher's routes are never path targets. Read only through
+ // exactPathRoute.
+ RouteAccount string `json:"route_account,omitempty"`
+ RouteApp string `json:"route_app,omitempty"`
+ PathFront bool `json:"path_front,omitempty"`
+ PathTarget bool `json:"path_target,omitempty"`
}
// edgesAssetsView is the wire shape of the assets block: path prefixes, the
@@ -288,6 +297,11 @@ type homeEntry struct {
// merged across entries; it points into the parsed file and is never
// written after the fold.
assets *edgesAssetsView
+ // routeAccount, routeApp, pathFront and pathTarget are the dial
+ // winner's route owner and path marks (edgesHostView), travelling with
+ // it like account and app, never merged across entries.
+ routeAccount, routeApp string
+ pathFront, pathTarget bool
}
// homeSnapshot is one poll's result, swapped in whole and immutable once
@@ -1047,7 +1061,8 @@ func foldHomes(files map[string]edgesFileView, self string, privateDial bool) (m
entries[host] = map[string]homeEntry{}
}
entries[host][k] = homeEntry{eip: addr, box: f.Box, alias: h.Alias, account: h.Account, app: h.App, stamp: h.Stamp,
- incarnation: h.Incarnation, servingSeq: h.ServingSeq, targetHost: h.TargetHost, assets: h.Assets}
+ incarnation: h.Incarnation, servingSeq: h.ServingSeq, targetHost: h.TargetHost, assets: h.Assets,
+ routeAccount: h.RouteAccount, routeApp: h.RouteApp, pathFront: h.PathFront, pathTarget: h.PathTarget}
merged := hosts[host]
merged.platform = merged.platform || (h.Platform && !h.Alias && !h.Wildcard)
merged.wildcard = merged.wildcard || h.Wildcard
diff --git a/internal/edge/pathroute_home.go b/internal/edge/pathroute_home.go
new file mode 100644
index 000000000..eb906f770
--- /dev/null
+++ b/internal/edge/pathroute_home.go
@@ -0,0 +1,51 @@
+package edge
+
+import (
+ "strings"
+
+ "github.com/carlosframework/platform/internal/edgesfile"
+)
+
+// Path routes across boxes (#186, spec §5.1): the home map's view of another
+// box's exact route rows, for deciding whether a request may be sent there as
+// a path front or target.
+
+// pathRouteInfo is one exact route row another box published, as the dial
+// winner for its name: the route's own account and app and its two path
+// marks (edgesfile route_account, route_app, path_front, path_target), with
+// where to dial it and the identity a backhaul checks before it does.
+type pathRouteInfo struct {
+ Account, App string
+ Front, Target bool
+ Dial, Box string
+ Owner backhaulOwner // backhaulOwnerOf(resolution.Authority)
+ Stamp int64
+ Incarnation uint64
+}
+
+// exactPathRoute answers the exact (never wildcard) dialable route row another
+// box published for host, from one snapshot. false when absent, held, an alias
+// or "*." row, or published without route_account.
+func (m *homeMap) exactPathRoute(host string) (pathRouteInfo, bool) {
+ if m == nil || m.self == "" || strings.HasPrefix(host, "*.") {
+ return pathRouteInfo{}, false
+ }
+ hosts := m.snapshot().hosts
+ r := resolveHomeName(host, nil, true, hosts)
+ if r.State != edgesfile.NameDialable || r.Authority.Class != edgesfile.NameRoute || r.Serving.Name != host {
+ return pathRouteInfo{}, false
+ }
+ // The fold kept the serving claim's own entry for the name; the box check
+ // keeps an entry from ever lending its fields to another box's claim.
+ h, ok := hosts[host]
+ if !ok || !h.dial || h.box != r.Serving.Box || h.routeAccount == "" {
+ return pathRouteInfo{}, false
+ }
+ return pathRouteInfo{
+ Account: h.routeAccount, App: h.routeApp,
+ Front: h.pathFront, Target: h.pathTarget,
+ Dial: r.Serving.Dial, Box: r.Serving.Box,
+ Owner: backhaulOwnerOf(r.Authority),
+ Stamp: r.Serving.Stamp, Incarnation: r.Serving.Incarnation,
+ }, true
+}
diff --git a/internal/edge/pathroute_home_test.go b/internal/edge/pathroute_home_test.go
new file mode 100644
index 000000000..38f267824
--- /dev/null
+++ b/internal/edge/pathroute_home_test.go
@@ -0,0 +1,99 @@
+package edge
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/edgesfile"
+)
+
+// putPathFile lands one box's file holding the given host entries (raw JSON
+// bodies keyed by host).
+func putPathFile(t *testing.T, m *homeMap, box, eip string, hosts map[string]string) {
+ t.Helper()
+ body := ""
+ for h, e := range hosts {
+ if body != "" {
+ body += ","
+ }
+ body += fmt.Sprintf("%q:%s", h, e)
+ }
+ putJSON(t, m.s, "control/edges/"+box+".json", fmt.Sprintf(`{"v":1,"box":%q,"eip":%q,"hosts":{%s}}`, box, eip, body))
+}
+
+const pathRouteEntry = `{"role":"home","route_account":"bae","route_app":"shop","path_front":true,"path_target":true}`
+
+// A "*." row answers no concrete name and is not itself an exact route: the
+// exact lookup never falls back to a catch-all, whatever it publishes.
+func TestExactPathRouteIgnoresWildcard(t *testing.T) {
+ m := newHomeMap(meshTestStore(t), "annie")
+ putPathFile(t, m, "betty", "2.2.2.2", map[string]string{"*.example.com": pathRouteEntry})
+ refreshHomeMap(t, m)
+ if _, _, ok := m.Home("shop.example.com"); !ok {
+ t.Fatal("precondition: Home answers the name through the catch-all")
+ }
+ for _, h := range []string{"shop.example.com", "*.example.com"} {
+ if got, ok := m.exactPathRoute(h); ok {
+ t.Errorf("exactPathRoute(%q) = %+v, want none", h, got)
+ }
+ }
+}
+
+// The answer is the dial winner's own row, never merged with a loser's: the
+// higher stamp wins the name and every field comes from its file.
+func TestExactPathRouteReadsWinner(t *testing.T) {
+ m := newHomeMap(meshTestStore(t), "annie")
+ putPathFile(t, m, "betty", "2.2.2.2", map[string]string{
+ "shop.example.com": `{"role":"home","account":"bae","app":"shop","stamp":5,"route_account":"bae","route_app":"shop","path_front":true}`,
+ "alias.example.com": `{"role":"home","alias":true,"target_host":"shop.example.com","route_account":"bae","route_app":"shop","path_front":true,"path_target":true}`,
+ })
+ putPathFile(t, m, "cindy", "3.3.3.3", map[string]string{
+ "shop.example.com": `{"role":"home","account":"baf","app":"other","stamp":9,"incarnation":4,"route_account":"baf","route_app":"other","path_target":true}`,
+ })
+ refreshHomeMap(t, m)
+ got, ok := m.exactPathRoute("shop.example.com")
+ if !ok {
+ t.Fatal("exactPathRoute = false for a published route row")
+ }
+ want := pathRouteInfo{Account: "baf", App: "other", Front: false, Target: true, Dial: "3.3.3.3", Box: "cindy",
+ Owner: backhaulOwner{name: "shop.example.com", class: edgesfile.NameRoute, account: "baf", app: "other"},
+ Stamp: 9, Incarnation: 4}
+ if got != want {
+ t.Errorf("exactPathRoute = %+v, want %+v", got, want)
+ }
+ // An alias is never a path route, whatever it carries.
+ if got, ok := m.exactPathRoute("alias.example.com"); ok {
+ t.Errorf("exactPathRoute(alias) = %+v, want none", got)
+ }
+ var nilMap *homeMap
+ if _, ok := nilMap.exactPathRoute("shop.example.com"); ok {
+ t.Error("a nil home map answered")
+ }
+ if _, ok := newHomeMap(m.s, "").exactPathRoute("shop.example.com"); ok {
+ t.Error("a home map with no self label answered")
+ }
+}
+
+// A missing mark reads false, and a row without route_account (an older
+// publisher) is not a path route at all.
+func TestExactPathRouteAbsentFieldsAreFalse(t *testing.T) {
+ m := newHomeMap(meshTestStore(t), "annie")
+ putPathFile(t, m, "betty", "2.2.2.2", map[string]string{
+ "bare.example.com": `{"role":"home","route_account":"bae","route_app":"shop"}`,
+ "older.example.com": `{"role":"home","account":"bae","app":"shop","path_front":true,"path_target":true}`,
+ })
+ refreshHomeMap(t, m)
+ got, ok := m.exactPathRoute("bare.example.com")
+ if !ok {
+ t.Fatal("exactPathRoute = false for a row with a route owner")
+ }
+ if got.Front || got.Target || got.Account != "bae" || got.App != "shop" {
+ t.Errorf("exactPathRoute = %+v, want bae/shop with both marks false", got)
+ }
+ if got, ok := m.exactPathRoute("older.example.com"); ok {
+ t.Errorf("exactPathRoute(no route_account) = %+v, want none", got)
+ }
+ if _, ok := m.exactPathRoute("missing.example.com"); ok {
+ t.Error("exactPathRoute answered an unpublished name")
+ }
+}
diff --git a/internal/edge/testdata/edges-forward-hub.json b/internal/edge/testdata/edges-forward-hub.json
index 5d64d4f05..4152f4b14 100644
--- a/internal/edge/testdata/edges-forward-hub.json
+++ b/internal/edge/testdata/edges-forward-hub.json
@@ -1 +1 @@
-{"v":1,"box":"hub","eip":"198.51.100.7","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"named_pools":[],"burst_notices":true,"ha_handover":1,"capabilities":["names-2"],"moves_protocol":0,"seeds_protocol":0,"addrs":null,"generation":"2026-10-30T00:00:00Z","hosts":{"*.bah-certonly.example.com":{"role":"wildcard","platform":false,"wildcard":true},"*.bah-certs.example.com":{"role":"wildcard","platform":false,"wildcard":true},"*.bah-regional.example.com":{"role":"wildcard","platform":false,"wildcard":true},"*.bah-wild.example.com":{"role":"home","platform":false,"alias":true,"wildcard":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"bah-certonly.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"shop.bah-custom.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"shop.bah.example.com":{"role":"home","platform":true,"account":"bah","app":"shop"},"tickets.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"}}}
+{"v":1,"box":"hub","eip":"198.51.100.7","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"named_pools":[],"burst_notices":true,"ha_handover":1,"capabilities":["names-2"],"moves_protocol":0,"seeds_protocol":0,"addrs":null,"generation":"2026-10-30T00:00:00Z","hosts":{"*.bah-certonly.example.com":{"role":"wildcard","platform":false,"wildcard":true},"*.bah-certs.example.com":{"role":"wildcard","platform":false,"wildcard":true},"*.bah-regional.example.com":{"role":"wildcard","platform":false,"wildcard":true},"*.bah-wild.example.com":{"role":"home","platform":false,"alias":true,"wildcard":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"bah-certonly.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"shop.bah-custom.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"shop.bah.example.com":{"role":"home","platform":true,"account":"bah","app":"shop","route_account":"bah","route_app":"shop"},"tickets.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"}}}
diff --git a/internal/edgesfile/testdata/assets-host.golden.json b/internal/edgesfile/testdata/assets-host.golden.json
index 1bcc7a7a2..23ad0b66d 100644
--- a/internal/edgesfile/testdata/assets-host.golden.json
+++ b/internal/edgesfile/testdata/assets-host.golden.json
@@ -8,5 +8,9 @@
"gen": "0123456789abcdef",
"at": 1792832400,
"primary": "shop.example.com"
- }
+ },
+ "route_account": "abc",
+ "route_app": "shop",
+ "path_front": true,
+ "path_target": true
}
diff --git a/internal/edgesfile/testdata/regional-box-uk.golden.json b/internal/edgesfile/testdata/regional-box-uk.golden.json
index 52440f72b..0c857546a 100644
--- a/internal/edgesfile/testdata/regional-box-uk.golden.json
+++ b/internal/edgesfile/testdata/regional-box-uk.golden.json
@@ -8,6 +8,10 @@
"role": "home",
"platform": true,
"account": "abc",
- "app": "shop"
+ "app": "shop",
+ "route_account": "abc",
+ "route_app": "shop",
+ "path_front": true,
+ "path_target": true
}
}
diff --git a/internal/edgesfile/testdata/regional-box.golden.json b/internal/edgesfile/testdata/regional-box.golden.json
index 7974184cf..9c5a84e19 100644
--- a/internal/edgesfile/testdata/regional-box.golden.json
+++ b/internal/edgesfile/testdata/regional-box.golden.json
@@ -8,6 +8,10 @@
"role": "home",
"platform": true,
"account": "abc",
- "app": "shop"
+ "app": "shop",
+ "route_account": "abc",
+ "route_app": "shop",
+ "path_front": true,
+ "path_target": true
}
}
diff --git a/internal/host/edgesfile.go b/internal/host/edgesfile.go
index 143653013..23cb0178f 100644
--- a/internal/host/edgesfile.go
+++ b/internal/host/edgesfile.go
@@ -123,6 +123,19 @@ type edgeHost struct {
// reader takes absent as pointing (edgesfile.DNSPointing). Additive
// (omitempty on the pointer, so false is written and nil is not).
DNSPointing *bool `json:"dns_pointing,omitempty"`
+ // RouteAccount and RouteApp are this exact route row's own account
+ // (release.RouteAccount) and app, and PathFront and PathTarget the
+ // shared predicates' answers for it (registry.PathFront, PathTarget):
+ // whose route the name is, and whether it may front or be the target
+ // of a path route across boxes (#186, spec §5.1). Unlike Account/App
+ // (the door's owner, folded over every route under the name) they
+ // describe the row alone. Published only on a real route row, never on
+ // an alias, platform alias or "*." row. Additive (omitempty): absent
+ // reads as empty and false.
+ RouteAccount string `json:"route_account,omitempty"`
+ RouteApp string `json:"route_app,omitempty"`
+ PathFront bool `json:"path_front,omitempty"`
+ PathTarget bool `json:"path_target,omitempty"`
}
// dnsPointingMark is a published name's dns_pointing mark. A name under the
@@ -706,7 +719,8 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re
if r.IsSidecar() {
continue
}
- if _, alias := platformSources[r.Host]; !alias && !r.IsForward() && !pools.Serves(r.Pool) {
+ _, platformAlias := platformSources[r.Host]
+ if !platformAlias && !r.IsForward() && !pools.Serves(r.Pool) {
continue
}
if withheld[r.Host] {
@@ -744,6 +758,12 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re
// §6.4): the edge orders two unstamped entries by it.
h.Incarnation, h.ServingSeq = r.Incarnation, r.ServingSeq
}
+ // The route's own owner and path marks (#186), on an exact route row
+ // only: an alias is never a path front or target across boxes.
+ if !platformAlias && !strings.HasPrefix(r.Host, "*.") {
+ h.RouteAccount, h.RouteApp = release.RouteAccount(r), r.App
+ h.PathFront, h.PathTarget = registry.PathFront(r), registry.PathTarget(r)
+ }
hosts[r.Host] = h
}
// A platform alias is served with its source's own entry, so one whose
diff --git a/internal/host/edgesfile_pathroute_test.go b/internal/host/edgesfile_pathroute_test.go
new file mode 100644
index 000000000..bca63f3dc
--- /dev/null
+++ b/internal/host/edgesfile_pathroute_test.go
@@ -0,0 +1,214 @@
+package host
+
+// Path routes across boxes (#186), spec §5.1: each real route row in the
+// edges file carries its own route's account and app (route_account,
+// route_app) and the two eligibility marks the shared predicates answer for
+// it (path_front, path_target). The door owner (account/app) is unchanged.
+
+import (
+ "encoding/json"
+ "fmt"
+ "slices"
+ "sync"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// pathWire is the wire shape of the four fields, read from the raw JSON so
+// the test pins the published names, not the writer's struct.
+type pathWire struct {
+ RouteAccount string `json:"route_account"`
+ RouteApp string `json:"route_app"`
+ PathFront bool `json:"path_front"`
+ PathTarget bool `json:"path_target"`
+}
+
+var pathWireKeys = []string{"route_account", "route_app", "path_front", "path_target"}
+
+// publishPathHosts runs one writer pass on box "annie" and returns each
+// host's raw entry.
+func publishPathHosts(t *testing.T, reg *registry.Registry) map[string]map[string]json.RawMessage {
+ t.Helper()
+ withheldAliasSaid = sync.Map{}
+ s := release.NewDirStore(t.TempDir())
+ var last []byte
+ if err := edgesFileWriteClaims(t.Context(), s, reg, edgesFile{Box: "annie"}, "1.2.3.4", &last, false, nil, false, nil, nil); err != nil {
+ t.Fatal(err)
+ }
+ body, _, err := s.Get(t.Context(), edgesFileKey("annie"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ var raw struct {
+ Hosts map[string]map[string]json.RawMessage `json:"hosts"`
+ }
+ if err := json.Unmarshal(body, &raw); err != nil {
+ t.Fatal(err)
+ }
+ return raw.Hosts
+}
+
+// pathFields decodes the four fields of one raw entry.
+func pathFields(t *testing.T, entry map[string]json.RawMessage) pathWire {
+ t.Helper()
+ b, err := json.Marshal(entry)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var w pathWire
+ if err := json.Unmarshal(b, &w); err != nil {
+ t.Fatal(err)
+ }
+ return w
+}
+
+func upsertRoute(t *testing.T, reg *registry.Registry, rt registry.Route) {
+ t.Helper()
+ if err := reg.Upsert(rt); err != nil {
+ t.Fatalf("Upsert(%s): %v", rt.Host, err)
+ }
+}
+
+// A hub whose prefixes reach other apps publishes no door owner (the mixed
+// rule stands), but its route row names its own account and app and both
+// marks.
+func TestEdgesFilePublishesRouteOwner(t *testing.T) {
+ reg := edgesTestRegistry(t)
+ upsertRoute(t, reg, registry.Route{Host: "hub.example.com", Kind: "instance", Addr: "10.0.0.1:3000", Status: "ready", Account: "bae", App: "hub"})
+ upsertRoute(t, reg, registry.Route{Host: "acme.example.net", Kind: "instance", Addr: "10.0.0.2:3000", Status: "ready", Account: "bae", App: "acme"})
+ if err := reg.UpsertPath(registry.RoutePath{Host: "hub.example.com", Prefix: "acme", Target: "acme.example.net", Account: "bae", App: "hub"}); err != nil {
+ t.Fatal(err)
+ }
+ hosts := publishPathHosts(t, reg)
+ e, ok := hosts["hub.example.com"]
+ if !ok {
+ t.Fatalf("hub.example.com not published: %v", hosts)
+ }
+ if _, ok := e["account"]; ok {
+ t.Errorf("hub.example.com publishes a door account %s, want none (mixed)", e["account"])
+ }
+ if _, ok := e["app"]; ok {
+ t.Errorf("hub.example.com publishes a door app %s, want none (mixed)", e["app"])
+ }
+ want := pathWire{RouteAccount: "bae", RouteApp: "hub", PathFront: true, PathTarget: true}
+ if got := pathFields(t, e); got != want {
+ t.Errorf("hub.example.com path fields = %+v, want %+v", got, want)
+ }
+ if got, want := pathFields(t, hosts["acme.example.net"]), (pathWire{RouteAccount: "bae", RouteApp: "acme", PathFront: true, PathTarget: true}); got != want {
+ t.Errorf("acme.example.net path fields = %+v, want %+v", got, want)
+ }
+}
+
+// A route with no valid account names the ops account, as every other reader
+// of a route's account does (release.RouteAccount).
+func TestEdgesFileRouteOwnerDefaultsToTheOpsAccount(t *testing.T) {
+ reg := edgesTestRegistry(t)
+ upsertRoute(t, reg, registry.Route{Host: "ops.example.com", Kind: "static", Addr: "10.0.0.1:3000", Status: "ready", App: "site"})
+ got := pathFields(t, publishPathHosts(t, reg)["ops.example.com"])
+ if got.RouteAccount != release.OpsAccount || got.RouteApp != "site" {
+ t.Errorf("route owner = %q/%q, want %q/site", got.RouteAccount, got.RouteApp, release.OpsAccount)
+ }
+}
+
+// Aliases and "*." rows are never a path front or target across boxes: an
+// attached custom domain, a platform alias, a catch-all route row and a
+// served wildcard catch-all publish none of the four fields, while their
+// primary does.
+func TestEdgesFileAliasRowsCarryNoRouteOwner(t *testing.T) {
+ reg := edgesTestRegistry(t)
+ upsertRoute(t, reg, registry.Route{Host: "shop.example.com", Kind: "instance", Socket: "/run/carlos/shop.sock", Status: "ready", Account: "bae", App: "shop"})
+ // A platform alias: a platform row on the same tenant's socket.
+ upsertRoute(t, reg, registry.Route{Host: "shop.apps.example.org", Kind: "instance", Socket: "/run/carlos/shop.sock", Status: "ready", Platform: true, Account: "bae", App: "shop"})
+ // A catch-all route row.
+ upsertRoute(t, reg, registry.Route{Host: "*.go.example.org", Kind: "instance", Addr: "10.0.0.3:3000", Status: "ready", Account: "bae", App: "go"})
+ // An attached custom domain and a served wildcard catch-all.
+ if err := reg.UpsertAlias(registry.RouteAlias{Alias: "tickets.example.net", Host: "shop.example.com", Account: "bae", App: "shop", DNSStatus: "pointing"}); err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.UpsertAlias(registry.RouteAlias{Alias: "*.shop.example.net", Host: "shop.example.com", Account: "bae", App: "shop"}); err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.UpsertWildcardDomain(registry.WildcardDomain{Host: "shop.example.net", Account: "bae", App: "shop"}); err != nil {
+ t.Fatal(err)
+ }
+ hosts := publishPathHosts(t, reg)
+ for _, n := range []string{"shop.apps.example.org", "*.go.example.org", "tickets.example.net", "*.shop.example.net"} {
+ e, ok := hosts[n]
+ if !ok {
+ t.Fatalf("%s not published: %v", n, hosts)
+ }
+ for _, k := range pathWireKeys {
+ if v, ok := e[k]; ok {
+ t.Errorf("%s publishes %s = %s, want none on an alias or \"*.\" row", n, k, v)
+ }
+ }
+ }
+ want := pathWire{RouteAccount: "bae", RouteApp: "shop", PathFront: true, PathTarget: true}
+ if got := pathFields(t, hosts["shop.example.com"]); got != want {
+ t.Errorf("primary path fields = %+v, want %+v", got, want)
+ }
+}
+
+// pathGuardAbsent names the PathEligibilityCases the writer leaves out by its
+// own filters (edgesFileWriteClaims: a row that is not ready, a sidecar).
+// A change to those filters shows up here, as a case appearing or vanishing.
+var pathGuardAbsent = []string{"starting instance", "ready sidecar"}
+
+// TestEdgesFilePathMarksMatchPredicates is spec §5.1's guard: for every route
+// kind and flag the registry carries, the marks a box publishes are exactly
+// what registry.PathFront and registry.PathTarget answer for the route it
+// read, so a sender reading the marks and a box checking its own route can
+// never disagree. A row the writer does not publish carries no marks at all.
+func TestEdgesFilePathMarksMatchPredicates(t *testing.T) {
+ var absent []string
+ for i, c := range registry.PathEligibilityCases {
+ t.Run(c.Name, func(t *testing.T) {
+ rt := c.Route
+ rt.Host = fmt.Sprintf("case%d.example.com", i)
+ var reg *registry.Registry
+ if rt.IsForward() {
+ // A forward row is published only by a hub serving its fleet
+ // (edgesfile_forward_test.go's world).
+ setHubEnv(t, fpTunnel, "")
+ reg = fpRegistry(t)
+ rt.Account, rt.App, rt.Slug = fpOwner, "shop", "shop"
+ rt.Region, rt.Channel = registry.PlacementTarget("home"), "production"
+ fpPutForward(t, reg, rt)
+ } else {
+ reg = edgesTestRegistry(t)
+ rt.Account, rt.App, rt.Addr = "bae", "shop", "10.0.0.1:3000"
+ upsertRoute(t, reg, rt)
+ }
+ sp, err := reg.Get(rt.Host)
+ if err != nil || sp == nil {
+ t.Fatalf("Get(%s) = %v, %v", rt.Host, sp, err)
+ }
+ stored := *sp
+ if registry.PathFront(stored) != c.Front || registry.PathTarget(stored) != c.Target {
+ t.Fatalf("stored route %+v answers front %v target %v, the case says %v %v: the fixture did not survive the registry",
+ stored, registry.PathFront(stored), registry.PathTarget(stored), c.Front, c.Target)
+ }
+ e, published := publishPathHosts(t, reg)[rt.Host]
+ if !published {
+ absent = append(absent, c.Name)
+ return
+ }
+ got := pathFields(t, e)
+ if got.PathFront != registry.PathFront(stored) || got.PathTarget != registry.PathTarget(stored) {
+ t.Errorf("published front %v target %v, predicates say %v %v", got.PathFront, got.PathTarget,
+ registry.PathFront(stored), registry.PathTarget(stored))
+ }
+ if got.RouteAccount != release.RouteAccount(stored) || got.RouteApp != stored.App {
+ t.Errorf("published route owner %q/%q, want %q/%q", got.RouteAccount, got.RouteApp, release.RouteAccount(stored), stored.App)
+ }
+ if stored.IsForward() && got.PathTarget {
+ t.Error("a forward row is published as a path target")
+ }
+ })
+ }
+ if !slices.Equal(absent, pathGuardAbsent) {
+ t.Errorf("cases the writer leaves out = %q, want %q", absent, pathGuardAbsent)
+ }
+}
diff --git a/internal/host/edgesfile_test.go b/internal/host/edgesfile_test.go
index 182cb64ed..76c83c7fa 100644
--- a/internal/host/edgesfile_test.go
+++ b/internal/host/edgesfile_test.go
@@ -327,7 +327,7 @@ func TestEdgesFileRawWireBodyMatchesSchema(t *testing.T) {
}
want := `{"v":1,"box":"quiet-harbour","eip":"203.0.113.10","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"named_pools":[],"burst_notices":true,"ha_handover":1,"capabilities":["names-2"],"moves_protocol":0,"seeds_protocol":0,"addrs":null,"generation":"` +
- probe.Generation + `","hosts":{"app.example.com":{"role":"home","platform":false}}}`
+ probe.Generation + `","hosts":{"app.example.com":{"role":"home","platform":false,"route_account":"bab"}}}`
if string(got) != want {
t.Fatalf("raw wire body =\n%s\nwant\n%s", got, want)
}
@@ -370,7 +370,7 @@ func TestEdgesFileRawWireBodyRegionField(t *testing.T) {
}
gen := genOf(t, got)
want := `{"v":1,"box":"quiet-harbour","eip":"203.0.113.10","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"named_pools":[],"burst_notices":true,"ha_handover":1,"capabilities":["names-2"],"moves_protocol":0,"seeds_protocol":0,"addrs":null,"generation":"` +
- gen + `","hosts":{"app.example.com":{"role":"home","platform":false}}}`
+ gen + `","hosts":{"app.example.com":{"role":"home","platform":false,"route_account":"bab"}}}`
if string(got) != want {
t.Fatalf("raw wire body (region unset) =\n%s\nwant\n%s", got, want)
}
@@ -389,7 +389,7 @@ func TestEdgesFileRawWireBodyRegionField(t *testing.T) {
}
gen := genOf(t, got)
want := `{"v":1,"box":"quiet-harbour","eip":"203.0.113.10","region":"eu-west-1","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"named_pools":[],"burst_notices":true,"ha_handover":1,"capabilities":["names-2"],"moves_protocol":0,"seeds_protocol":0,"addrs":null,"generation":"` +
- gen + `","hosts":{"app.example.com":{"role":"home","platform":false}}}`
+ gen + `","hosts":{"app.example.com":{"role":"home","platform":false,"route_account":"bab"}}}`
if string(got) != want {
t.Fatalf("raw wire body (region set) =\n%s\nwant\n%s", got, want)
}
@@ -672,7 +672,7 @@ func TestEdgesFileMarksPlatformRows(t *testing.T) {
}
// The mark is always written, so a keyless host object can only mean a
// pre-mark publisher.
- if !strings.Contains(string(body), `"stray.acct.apps.test":{"role":"home","platform":false}`) {
+ if !strings.Contains(string(body), `"stray.acct.apps.test":{"role":"home","platform":false,`) {
t.Errorf("mark not emitted for an unclassed row: %s", body)
}
}
@@ -941,7 +941,7 @@ func TestEdgesFileRawWireBodyPlacementField(t *testing.T) {
t.Fatal(err)
}
want := `{"v":1,"box":"quiet-harbour","eip":"203.0.113.10","region":"eu-west-2","placement":"uk","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"named_pools":[],"burst_notices":true,"ha_handover":1,"capabilities":["names-2"],"moves_protocol":0,"seeds_protocol":0,"addrs":null,"generation":"` +
- probe.Generation + `","hosts":{"app.example.com":{"role":"home","platform":false}}}`
+ probe.Generation + `","hosts":{"app.example.com":{"role":"home","platform":false,"route_account":"bab"}}}`
if string(got) != want {
t.Fatalf("raw wire body (placement set) =\n%s\nwant\n%s", got, want)
}
@@ -1857,7 +1857,7 @@ func TestEdgesFileAddrsEmptyAndUnreadable(t *testing.T) {
return strings.Replace(string(body), probe.Generation, "GEN", 1)
}
const head = `{"v":1,"box":"%s","eip":"203.0.113.10","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"named_pools":[],"burst_notices":true,"ha_handover":1,"capabilities":["names-2"],"moves_protocol":0,"seeds_protocol":0,`
- const tail = `,"generation":"GEN","hosts":{"app.example.com":{"role":"home","platform":false}}}`
+ const tail = `,"generation":"GEN","hosts":{"app.example.com":{"role":"home","platform":false,"route_account":"bab"}}}`
r := &addrsReader{}
r.set(nil, "127.0.0.0/8", "127.0.0.1/32", "::1/128")
@@ -2025,7 +2025,7 @@ func TestEdgesFilePublishesThePairAndTargetHost(t *testing.T) {
if h := wantEntry(t, "the cert-only parent", hosts, "*.certonly.example.net", 0, 0, ""); h.Role != "wildcard" {
t.Errorf("cert-only entry = %+v, want role wildcard", h)
}
- for _, s := range []string{`"incarnation":2,"serving_seq":3}`, `"incarnation":2,"serving_seq":3,"target_host":"shop.example.com"}`} {
+ for _, s := range []string{`"incarnation":2,"serving_seq":3,"route_account":`, `"incarnation":2,"serving_seq":3,"target_host":"shop.example.com"}`} {
if !bytes.Contains(body, []byte(s)) {
t.Errorf("raw body lacks %s:\n%s", s, body)
}
diff --git a/internal/host/egress_nopolicy_linux_test.go b/internal/host/egress_nopolicy_linux_test.go
index 48288321c..2997ceaf5 100644
--- a/internal/host/egress_nopolicy_linux_test.go
+++ b/internal/host/egress_nopolicy_linux_test.go
@@ -96,8 +96,8 @@ const mainNoPolicySnapshot = `{
// mainNoPolicyEdges is control/edges/quiet-harbour.json as main's
// edgesFileWriteClaims wrote it for noPolicyBoxRows, with %s for its
-// generation.
-const mainNoPolicyEdges = `{"v":1,"box":"quiet-harbour","eip":"203.0.113.10","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"moves_protocol":0,"seeds_protocol":0,"generation":"%s","hosts":{"console.example.com":{"role":"home","platform":false,"account":"abc","app":"console"},"files.example.com":{"role":"home","platform":false,"account":"abc","app":"files"},"old.example.com":{"role":"home","platform":false,"account":"zzz","app":"blog"},"shop-a-long-name-for-an-instance.example.com":{"role":"home","platform":false,"account":"abc","app":"shop"},"shop-a.example.com":{"role":"home","platform":false,"account":"abc","app":"shop"}}}`
+// generation, and each route row's #186 route owner and path marks.
+const mainNoPolicyEdges = `{"v":1,"box":"quiet-harbour","eip":"203.0.113.10","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"moves_protocol":0,"seeds_protocol":0,"generation":"%s","hosts":{"console.example.com":{"role":"home","platform":false,"account":"abc","app":"console","route_account":"abc","route_app":"console","path_front":true,"path_target":true},"files.example.com":{"role":"home","platform":false,"account":"abc","app":"files","route_account":"abc","route_app":"files","path_front":true,"path_target":true},"old.example.com":{"role":"home","platform":false,"account":"zzz","app":"blog","route_account":"zzz","route_app":"blog","path_front":true,"path_target":true},"shop-a-long-name-for-an-instance.example.com":{"role":"home","platform":false,"account":"abc","app":"shop","route_account":"abc","route_app":"shop","path_front":true,"path_target":true},"shop-a.example.com":{"role":"home","platform":false,"account":"abc","app":"shop","route_account":"abc","route_app":"shop","path_front":true,"path_target":true}}}`
// The store requests main made for them: the snapshot's write, the edges
// file's first pass, and its second, unchanged pass.
diff --git a/internal/host/testdata/edges-p2b-golden.json b/internal/host/testdata/edges-p2b-golden.json
index dbfbb96a7..89b77dcc5 100644
--- a/internal/host/testdata/edges-p2b-golden.json
+++ b/internal/host/testdata/edges-p2b-golden.json
@@ -1 +1 @@
-{"box_role":"serve","admitted":true,"drained":false,"v":1,"box":"leo","eip":"203.0.113.10","region":"eu-west-1","data_bucket":"test-data","data_bucket_region":"eu-west-1","hibernation_configured":true,"serves_shared_pool":false,"accepts_inbound":true,"named_pools":["cohort1","hapair"],"burst_notices":true,"ha_take":1,"ha_handover":1,"secrets_key_fp":"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","box_id":"leo","capabilities":["region-ha-1","names-2"],"headroom":{"mem_free_mib":512,"disk_free_mib":2048,"awake":0,"mem_total_mib":1024,"disk_total_mib":4096},"moves_protocol":0,"seeds_protocol":0,"addrs":null,"generation":"2026-11-04T12:00:00Z","hosts":{"app.example.com":{"role":"home","platform":false}}}
\ No newline at end of file
+{"box_role":"serve","admitted":true,"drained":false,"v":1,"box":"leo","eip":"203.0.113.10","region":"eu-west-1","data_bucket":"test-data","data_bucket_region":"eu-west-1","hibernation_configured":true,"serves_shared_pool":false,"accepts_inbound":true,"named_pools":["cohort1","hapair"],"burst_notices":true,"ha_take":1,"ha_handover":1,"secrets_key_fp":"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","box_id":"leo","capabilities":["region-ha-1","names-2"],"headroom":{"mem_free_mib":512,"disk_free_mib":2048,"awake":0,"mem_total_mib":1024,"disk_total_mib":4096},"moves_protocol":0,"seeds_protocol":0,"addrs":null,"generation":"2026-11-04T12:00:00Z","hosts":{"app.example.com":{"role":"home","platform":false,"route_account":"bab"}}}
\ No newline at end of file