alias-wake-338: Astra round 1 fixes (two P1, two P2)
- P1 1: a platform alias is served only through one READY owner of its own tenant. An owner that is not ready (moving, failed), two owners, or another tenant's socket refuse the alias; it never falls back to a direct proxy around the owner's status, fence or tenancy. - P1 2: an alias with its own prefix map keeps the map over the instance's entry, so its default backend wakes the instance. - P2 3: the asset policy resolves a platform alias to its instance as the edge does (edge.PlatformAliasFold, now exported and shared). - P2 4: the edges file does not advertise a refused alias (nor anything attached to it), so no other edge forwards to it or orders its cert. Production-wired tests for a moving instance, the prefix map, and the publication; mutation-checked. Census overlay alias-wake-338 re-proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 files changed,
+291
−59
docs/superpowers/notes/census-proposal-alias-wake-338.md+10 −4docs/superpowers/reviews/CODEX-FINDINGS-alias-wake-338.md+32 −0internal/edge/edge.go+21 −12internal/edge/platformalias.go+31 −25internal/edge/platformalias_test.go+46 −11internal/host/aliaswake_assets_test.go+55 −0internal/host/aliaswake_test.go+60 −0internal/host/assetpolicy.go+15 −0internal/host/edgesfile.go+8 −0internal/provision/testdata/plan14-root-reads-alias-wake-338.tsv+12 −6internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1
Intent
diff --git a/docs/superpowers/notes/census-proposal-alias-wake-338.md b/docs/superpowers/notes/census-proposal-alias-wake-338.md| index 25daa5cbb..12d02879b 100644 |
| --- a/docs/superpowers/notes/census-proposal-alias-wake-338.md |
| +++ b/docs/superpowers/notes/census-proposal-alias-wake-338.md |
| @@ -5,9 +5,12 @@ Ruling `census-ruling-alias-wake-338`. The independent reviewer approves or reje |
| | unit | change | read sites | what changed | |
| |---|---|---|---| |
| | `internal/edge/edge.go` `Edge.currentHosts` | body | unchanged (4) | #338 follow-up: a resolved platform alias (platformAlias) stays in the wildcard parent set as its own row was before; attached hostnames still excluded | |
| -| `internal/edge/edge.go` `Edge.Reload` | sites | +whole:Route | #338 follow-up: after the path fold, a platform alias with a source takes the source's own upstream entry (same proxy, route, hibernating, so the existing activator wake, lease and fence apply) unless it has its own prefix map; a foreign alias is dropped from the map (not served, so not Allowed for ACME either); the attached-hostname fold clears platformAlias | |
| +| `internal/edge/edge.go` `Edge.Reload` | sites | +whole:Route | #338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map if it has one; a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias | |
| +| `internal/host/assetpolicy.go` `assetInputs.primary` | sites | +whole:Route ×2 | #338 follow-up: a refused platform alias has no primary; a resolved one resolves to its source's row, as the edge serves it | |
| +| `internal/host/assetpolicy.go` `newAssetInputs` | sites | +whole:Route | #338 follow-up: records edge.PlatformAliasFold over the same routes (platformOf, platformRefused) | |
| +| `internal/host/edgesfile.go` `edgesFileWriteClaims` | sites | +registry:Host, +whole:Route | #338 follow-up: skips publishing a platform alias edge.PlatformAliasFold refuses (and so anything attached to it); reads the same route listing | |
| -Envelopes re-pinned: `internal/edge`. |
| +Envelopes re-pinned: `internal/edge`, `internal/host`. |
| Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Escalate if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. An escalation goes to the census owner as a decision. |
| @@ -15,11 +18,14 @@ Recorded dispositions, which each change must still satisfy: |
| - `internal/edge/edge.go` `Edge.currentHosts`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route |
| - `internal/edge/edge.go` `Edge.Reload`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added |
| +- `internal/host/assetpolicy.go` `assetInputs.primary`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), in the edges file loop (edgesFileLoop, edgesFileWriteClaims), only on a box armed with CARLOS_ASSET_CACHE=1 (armAssetPolicy answers nil otherwise): resolves a hostname to its route row or, for an exact alias, its primary's, over rows already read; reads nothing itself; no root pass calls it; no root decision |
| +- `internal/host/assetpolicy.go` `newAssetInputs`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), in the edges file loop (edgesFileLoop, edgesFileWriteClaims), only on a box armed with CARLOS_ASSET_CACHE=1 (armAssetPolicy answers nil otherwise): indexes rows already read (routes by host, exact aliases to their primary, hosts with path rows) and the owners (servedOwners when not handed them); reads nothing itself; no root pass calls it; no root decision |
| +- `internal/host/edgesfile.go` `edgesFileWriteClaims`: authority, task F,J1. Basis: rev3=census-ruling-self-serve-moves-1;basis=root-route;kept=F;scope=protected-decision-only; the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): region-ha-2a's body, which with the box's lifetimes switch on also publishes each served row's lifetime pair (registry:Incarnation and registry:ServingSeq, two new sites on the rows it already lists) and an alias's or served catch-all's primary's pair, and names that primary as target_host whatever the switch; a report the edge orders unstamped entries by, not a decision; no record, /data, release or claim read added; F,J1 authority retained; self-serve moves 1 Task 8;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 8: takes a localAddrs reader (instancectl.LocalAddresses in production, which reads /proc/net/fib_trie and /proc/net/if_inet6 in the agent) and publishes its non-loopback entries as the edges file's addrs before the write gate (boxAddrs, no read of its own), so an address change writes once. The same 44 sites, offsets moved; no record, /data, release or claim read added; a report the console's egress grant check reads, not a root decision; F,J1 authority retained.;rev3=census-ruling-edge-asset-cache-3;basis=starts with assets = assets.active(), so a policy whose box has not opened its asset store publishes no assets blocks and reads no manifests, and copies the decision's Primary (the route host the block was decided for, drift D4) into the published assets block; read sites unchanged (44); no read added. Merged onto main's #328 body, which takes the localAddrs reader: the assets.active() line sits after that signature and the loop passes pub and instancectl.LocalAddresses;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: the claims argument (*edgesClaims) becomes addrs (AddressSource) and the applyEdgesClaims(ctx, claims, routes, hosts) call is deleted with edgesclaims.go, which is the one whole:Route site removed: no host claim is read and every served row publishes as with region HA off; the box-address publication is the same code reading addrs.BoxAddresses() instead of claims.addrs; a report the edge reads, not a root decision; no read added; merge of origin/main d7ae1d76: main's edge asset cache plan 3 body is kept (census-ruling-edge-asset-cache-3): the first line is assets = assets.active(), so a policy whose store has not opened publishes no assets blocks and reads no manifests, and edgesFileLoop passes pub (assets.active() for that tick) in the assets argument; main's claims *edgesClaims argument is this branch's addrs AddressSource, and no edgesClaims, applyEdgesClaims or hostclaim reference remains |
| New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| -- new `internal/edge/platformalias.go:platformAliasFold`: reads +registry:Account ×2, +registry:App ×4, +registry:Host ×3, +registry:Platform ×2, +registry:Socket ×6, +registry:Status ×2, +whole:Route ×2; written legacy, accepted-legacy, frozen |
| +- new `internal/edge/platformalias.go:PlatformAliasFold`: reads +registry:Account ×2, +registry:App ×4, +registry:Host ×3, +registry:Platform ×2, +registry:Socket ×6, +registry:Status ×2, +whole:Route ×10; written legacy, accepted-legacy, frozen |
| -Seal: `5192052a23d2fdd6f5d48b5617fe28a9bb03458e1e931c060fbdc42c3d627927` → `410ee337af4419b4ef7b3e78acee5408ae196d276d4d1f6ac3cde1697c84b7be`. |
| +Seal: `5192052a23d2fdd6f5d48b5617fe28a9bb03458e1e931c060fbdc42c3d627927` → `b2d44f5fc354d2c47c91ec55842d1b8f6be0a2913a25157408cb177ed91a67ae`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-alias-wake-338.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-alias-wake-338.md b/docs/superpowers/reviews/CODEX-FINDINGS-alias-wake-338.md| new file mode 100644 |
| index 000000000..e6a90b403 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-alias-wake-338.md |
| @@ -0,0 +1,32 @@ |
| +| Census item | Verdict | Evidence | |
| +|---|---|---| |
| +| `Edge.currentHosts` | APPROVE | [edge.go:1215](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/edge/edge.go:1215) preserves platform aliases in the parent set; attached hostnames clear `platformAlias` at line 1062. No new input authority. | |
| +| `Edge.Reload` | APPROVE | [edge.go:1023](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/edge/edge.go:1023) uses the existing registry snapshot and already-built upstreams. No additional privileged filesystem operation or root-side validation change. | |
| +| `platformAliasFold` | APPROVE | [platformalias.go:37](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/edge/platformalias.go:37) reads route columns and builds maps; it opens nothing. The `legacy` / `accepted-legacy` disposition fits these reads. | |
| +| `internal/edge` envelope | APPROVE | Reviewed all changed production declarations and their dispatch consumers. The Linux envelope, three function digests, frozen-row fingerprints and appended chain seal match. These census approvals do not clear the behavioral findings below. | |
| + |
| +1. **P1 — Tenant boundary / maintenance fence: non-ready sources restore the unsafe direct proxy.** |
| + [platformalias.go:41](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/edge/platformalias.go:41) excludes non-ready routes from both ownership maps. When an instance changes from `ready` to `moving`, its still-ready platform alias therefore becomes neither resolved nor rejected. Reload retains the alias’s original `unixProxy`, without hibernation or the instance’s fence. The move path explicitly sets that status before quiescence at [movespass.go:1557](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/host/movespass.go:1557). While the socket remains live, alias requests can still reach it. A foreign alias likewise escapes rejection when the foreign socket owner becomes non-ready. |
| + |
| + **Fix:** distinguish socket ownership from eligibility to serve. Refuse aliases whose known source is non-ready or foreign instead of treating those sockets as unowned. Add a request-level test covering a ready → moving transition and reload. **Fault family:** alias requests must retain the source’s readiness, tenancy and maintenance restrictions. |
| + |
| +2. **P1 — Path routing: an alias’s own prefix map disables the wake fix entirely.** |
| + The `own.paths != nil` condition at [edge.go:1034](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/edge/edge.go:1034) preserves the complete old alias entry. Requests for `/` or an unmatched prefix return that entry through [edge.go:1496](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/edge/edge.go:1496). Consequently, a sleeping instance still produces 502, and the instance’s gate and fence remain bypassed on that fallback. |
| + |
| + **Fix:** inherit the instance’s upstream entry while preserving the alias’s own prefix map. Test both an unmatched path waking the instance and a matched prefix reaching its configured target. **Fault family:** path dispatch must preserve lifecycle protection for the default backend. |
| + |
| +3. **P2 — Asset cache: policy resolution disagrees permanently with the folded upstream.** |
| + After [edge.go:1038](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/edge/edge.go:1038), the alias’s upstream names the instance. However, [assetpolicy.go:253](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/host/assetpolicy.go:253) still resolves it to the platform row. Ordinary minted aliases lack the instance’s asset generation; aliases carrying asset metadata instead fail the primary comparison at [assetcatch.go:245](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/edge/assetcatch.go:245). Local caching and acknowledged remote fills cannot work for these folded names, including hostnames attached to them. |
| + |
| + **Fix:** apply the same primary resolution in asset-policy construction, including generation, gates and path exclusions. Test cache fill followed by a hit through a platform alias. **Fault family:** cache policy and request dispatch must identify the same primary. |
| + |
| +4. **P2 — Homes / ACME: rejected aliases remain advertised deployment-wide.** |
| + Deleting a foreign alias at [edge.go:1026](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/edge/edge.go:1026) changes only the local routing map. The publisher still includes its ready registry row at [edgesfile.go:584](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/host/edgesfile.go:584). Other edges continue advertising that home and forwarding requests that it refuses. Certificate admission also remains possible because [certsync.go:195](/home/paulca/amadan.net/carlos/platform-alias-wake/internal/edge/certsync.go:195) uses `deploymentHost`, which accepts published home-map membership. |
| + |
| + **Fix:** apply the alias rejection rule before publishing homes and dependent attached hostnames. Test the published file and another edge’s certificate admission. **Fault family:** advertised serving and certificate eligibility must match actual routing. |
| + |
| +No P3 findings. |
| + |
| +Reviewed requested commit `e06f553b312a4e7f71dfb4e09443861bf13e9eb7` against `origin/main`. Formatting and diff checks passed. Targeted alias tests could not start because the read-only filesystem prevented Go from creating its build directory; execution and mutation-test results remain unverified. No files changed. |
| + |
| +NOT READY |
| \ No newline at end of file |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index 3b2d83120..9a4695ace 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -1013,27 +1013,36 @@ func (e *Edge) Reload() error { |
| m[p.Host] = up |
| } |
| // Platform aliases (#338 follow-up, platformalias.go): an alias that |
| - // shares one same-tenant route's socket resolves to that route's OWN |
| - // entry, as an attached hostname does below, so a request to it wakes |
| - // the instance through the instance's own wake path, fence and lease. |
| - // After the path fold so it inherits the instance's prefix map, and |
| - // before the attached-hostname fold so a hostname attached to the alias |
| - // inherits the result. An alias with a prefix map of its own keeps its |
| - // own entry. An alias whose socket is another tenant's is not served. |
| - sources, foreign := platformAliasFold(routes) |
| - for host := range foreign { |
| + // shares one ready same-tenant route's socket resolves to that route's |
| + // OWN entry, as an attached hostname does below, so a request to it |
| + // wakes the instance through the instance's own wake path, fence and |
| + // lease. After the path fold so it inherits the instance's prefix map, |
| + // and before the attached-hostname fold so a hostname attached to the |
| + // alias inherits the result. An alias with a prefix map of its own keeps |
| + // that map over the instance's entry, so its default backend is still |
| + // the instance's. A refused alias, or one whose instance has no entry |
| + // here, is not served: never a direct proxy around the instance. |
| + sources, refused := PlatformAliasFold(routes) |
| + for host := range refused { |
| if _, ok := m[host]; ok { |
| delete(m, host) |
| - e.logThrottled("platform-alias-foreign "+host, fmt.Sprintf( |
| - "platform alias %s names a socket of another account or app; not served", host)) |
| + e.logThrottled("platform-alias-refused "+host, fmt.Sprintf( |
| + "platform alias %s is not served: its socket is not one ready route of its own account and app", host)) |
| } |
| } |
| for host, src := range sources { |
| own, ok := m[host] |
| + if !ok { |
| + continue |
| + } |
| up, srcOK := m[src] |
| - if !ok || !srcOK || own.paths != nil { |
| + if !srcOK { |
| + delete(m, host) |
| continue |
| } |
| + if own.paths != nil { |
| + up.paths = own.paths |
| + } |
| up.alias, up.platformAlias = true, true |
| m[host] = up |
| } |
diff --git a/internal/edge/platformalias.go b/internal/edge/platformalias.go| index 11129809d..2f17a7fc4 100644 |
| --- a/internal/edge/platformalias.go |
| +++ b/internal/edge/platformalias.go |
| @@ -11,8 +11,8 @@ import ( |
| // process of its own, the same instance under a second name. Built as an |
| // ordinary socket route it was a plain proxy to that socket, so it never |
| // woke a sleeping instance (502 whenever the instance slept), it bypassed |
| -// the instance's gate, and under generations it dialled a socket the |
| -// instance no longer listens on. |
| +// the instance's gate and maintenance fence, and under generations it |
| +// dialled a socket the instance no longer listens on. |
| // |
| // So the edge resolves such an alias to its instance's OWN entry, exactly as |
| // an attached hostname (#151) resolves to its primary's: the same proxy, the |
| @@ -20,43 +20,49 @@ import ( |
| // generation socket and usage are all the instance's, and nothing about the |
| // wake path is new. |
| // |
| -// The instance is the one route that shares the alias's socket and belongs |
| -// to the same tenant: the same effective account and the same app. An alias |
| -// whose socket belongs to another tenant's route is not served at all; one |
| -// whose socket is nobody's (a stale path, a hand-made row) keeps today's |
| -// plain proxy. |
| +// The rule, one function for every reader (the edge's table, the edges file |
| +// the box publishes, the asset policy), so what is served, advertised and |
| +// cached never disagree: |
| +// - the alias's owners are the non-platform, non-sidecar routes of its |
| +// own tenant (the same effective account and app) on its socket, |
| +// whatever their status; |
| +// - exactly one owner, ready: the alias resolves to it (sources); |
| +// - one owner not ready (moving, failed, creating), two owners, or no |
| +// owner of its own while another tenant's route holds the socket: the |
| +// alias is not served at all (refused). It never falls back to a |
| +// direct proxy that would skip the owner's readiness, fence or tenancy; |
| +// - nobody's socket (a stale path, a hand-made row): neither. The row |
| +// stays the plain socket route it always was. |
| // platformAliasKey is a socket as one tenant holds it. |
| type platformAliasKey struct{ account, app, socket string } |
| -// platformAliasFold reads one registry listing and returns, for every ready |
| -// platform alias with a socket, either its instance's host (sources) or that |
| -// it must not be served (foreign): its socket belongs to a ready route of |
| -// another account or app and to none of its own tenant's. An alias whose |
| -// socket two of its own tenant's routes share resolves to neither. |
| -func platformAliasFold(routes []registry.Route) (sources map[string]string, foreign map[string]bool) { |
| - owners := map[platformAliasKey][]string{} |
| - bySocket := map[string]bool{} |
| +// PlatformAliasFold applies the rule above to one registry listing. It |
| +// judges only ready platform rows with a socket; the caller serves nothing |
| +// that is not ready anyway. |
| +func PlatformAliasFold(routes []registry.Route) (sources map[string]string, refused map[string]bool) { |
| + owners := map[platformAliasKey][]registry.Route{} |
| + held := map[string]bool{} |
| for _, s := range routes { |
| - if s.Platform || s.IsSidecar() || s.App == "" || s.Socket == "" || s.Status != "ready" { |
| + if s.Platform || s.IsSidecar() || s.App == "" || s.Socket == "" { |
| continue |
| } |
| k := platformAliasKey{registry.EffectiveAccount(s.Account), s.App, s.Socket} |
| - owners[k] = append(owners[k], s.Host) |
| - bySocket[s.Socket] = true |
| + owners[k] = append(owners[k], s) |
| + held[s.Socket] = true |
| } |
| - sources, foreign = map[string]string{}, map[string]bool{} |
| + sources, refused = map[string]string{}, map[string]bool{} |
| for _, a := range routes { |
| if !a.Platform || a.Socket == "" || a.Status != "ready" { |
| continue |
| } |
| - hosts := owners[platformAliasKey{registry.EffectiveAccount(a.Account), a.App, a.Socket}] |
| + own := owners[platformAliasKey{registry.EffectiveAccount(a.Account), a.App, a.Socket}] |
| switch { |
| - case a.App != "" && len(hosts) == 1: |
| - sources[a.Host] = hosts[0] |
| - case len(hosts) == 0 && bySocket[a.Socket]: |
| - foreign[a.Host] = true |
| + case a.App != "" && len(own) == 1 && own[0].Status == "ready": |
| + sources[a.Host] = own[0].Host |
| + case len(own) > 0 || held[a.Socket]: |
| + refused[a.Host] = true |
| } |
| } |
| - return sources, foreign |
| + return sources, refused |
| } |
diff --git a/internal/edge/platformalias_test.go b/internal/edge/platformalias_test.go| index 2f8c3b1fe..1c9c9b3b7 100644 |
| --- a/internal/edge/platformalias_test.go |
| +++ b/internal/edge/platformalias_test.go |
| @@ -8,10 +8,10 @@ import ( |
| "github.com/carlosframework/platform/internal/registry" |
| ) |
| -// The fold's tenancy rule: an alias resolves only to the one ready route of |
| -// its own effective account and app on its socket; another tenant's socket |
| -// is foreign; a socket nobody holds, or two of its own tenant's routes |
| -// share, resolves to neither. |
| +// The fold's rule: an alias resolves only to the one ready route of its |
| +// own effective account and app on its socket. Another tenant's socket, two |
| +// of its own tenant's routes, or its one owner not ready: refused, never a |
| +// direct proxy. A socket nobody holds: neither. |
| func TestPlatformAliasFold(t *testing.T) { |
| inst := func(host, acct, app, sock string) registry.Route { |
| return registry.Route{Host: host, Kind: "instance", Account: acct, App: app, Socket: sock, Status: "ready", Hibernate: true} |
| @@ -29,20 +29,21 @@ func TestPlatformAliasFold(t *testing.T) { |
| alias("ops.bab.example.com", "bab", "ops", "/s/l.sock"), // ...so this is the same tenant |
| inst("d1.abc.example.com", "abc", "dup", "/s/d.sock"), // two of one tenant's |
| inst("d2.abc.example.com", "abc", "dup", "/s/d.sock"), // routes on one socket |
| - alias("dup.abc.example.com", "abc", "dup", "/s/d.sock"), // resolve to neither |
| + alias("dup.abc.example.com", "abc", "dup", "/s/d.sock"), // refused |
| {Host: "w.abc.example.com", Kind: "sidecar", Account: "abc", App: "shop", Socket: "/s/w.sock", Status: "ready"}, |
| - alias("side.abc.example.com", "abc", "shop", "/s/w.sock"), // a sidecar is no source |
| + alias("side.abc.example.com", "abc", "shop", "/s/w.sock"), // a sidecar holds nothing |
| {Host: "n.abc.example.com", Kind: "instance", Account: "abc", App: "shop", Socket: "/s/n.sock", Status: "creating"}, |
| - alias("notready.abc.example.com", "abc", "shop", "/s/n.sock"), // a source not ready is no source |
| + alias("notready.abc.example.com", "abc", "shop", "/s/n.sock"), // its owner is not ready: refused |
| } |
| - sources, foreign := platformAliasFold(routes) |
| + sources, refused := PlatformAliasFold(routes) |
| wantSources := map[string]string{"shop.abc.example.com": "a.abc.example.com", "ops.bab.example.com": "legacy.example.com"} |
| if !maps.Equal(sources, wantSources) { |
| t.Errorf("sources = %v, want %v", sources, wantSources) |
| } |
| - wantForeign := map[string]bool{"shop.xyz.example.com": true, "blog.abc.example.com": true} |
| - if !maps.Equal(foreign, wantForeign) { |
| - t.Errorf("foreign = %v, want %v", foreign, wantForeign) |
| + wantRefused := map[string]bool{"shop.xyz.example.com": true, "blog.abc.example.com": true, |
| + "dup.abc.example.com": true, "notready.abc.example.com": true} |
| + if !maps.Equal(refused, wantRefused) { |
| + t.Errorf("refused = %v, want %v", refused, wantRefused) |
| } |
| } |
| @@ -85,3 +86,37 @@ func TestPlatformAliasSharesTheInstanceEntry(t *testing.T) { |
| t.Errorf("currentHosts = %v, want the platform alias and not the attached hostname", hosts) |
| } |
| } |
| + |
| +// An alias with a prefix map of its own keeps the map over the instance's |
| +// entry: its default backend is the instance's (and wakes it), and a |
| +// matched prefix still names its own target. |
| +func TestPlatformAliasKeepsItsOwnPrefixMap(t *testing.T) { |
| + reg := openReg(t) |
| + for _, rt := range []registry.Route{ |
| + {Host: "a.abc.oncarlos.com", Kind: "instance", Account: "abc", App: "shop", Socket: "/s/a.sock", Status: "ready", Hibernate: true}, |
| + {Host: "shop.abc.oncarlos.com", Kind: "instance", Account: "abc", App: "shop", Socket: "/s/a.sock", Status: "ready", Platform: true}, |
| + {Host: "docs.abc.oncarlos.com", Kind: "service", Account: "abc", App: "docs", Addr: "127.0.0.1:1", Status: "ready"}, |
| + } { |
| + if err := reg.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if err := reg.UpsertPath(registry.RoutePath{Host: "shop.abc.oncarlos.com", Prefix: "docs", Target: "docs.abc.oncarlos.com"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + e, err := New(reg, &routeRecordingActivator{}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + m := e.current() |
| + up := m["shop.abc.oncarlos.com"] |
| + if up.proxy != m["a.abc.oncarlos.com"].proxy || !up.hibernating || up.route.Host != "a.abc.oncarlos.com" { |
| + t.Fatalf("alias default backend is not the instance's entry: %+v", up) |
| + } |
| + if up.paths["docs"] != "docs.abc.oncarlos.com" { |
| + t.Errorf("alias prefix map lost: %v", up.paths) |
| + } |
| + if m["a.abc.oncarlos.com"].paths != nil { |
| + t.Errorf("the alias's prefix map leaked onto the instance: %v", m["a.abc.oncarlos.com"].paths) |
| + } |
| +} |
diff --git a/internal/host/aliaswake_assets_test.go b/internal/host/aliaswake_assets_test.go| new file mode 100644 |
| index 000000000..18a533913 |
| --- /dev/null |
| +++ b/internal/host/aliaswake_assets_test.go |
| @@ -0,0 +1,55 @@ |
| +package host |
| + |
| +import ( |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +// #338 follow-up, Astra r1 P2s: the edges file and the asset policy read |
| +// platform aliases by the edge's own rule (edge.PlatformAliasFold). A |
| +// served alias publishes its instance's asset block, naming the instance |
| +// as its primary, as the edge's folded entry does; a refused alias |
| +// (another account's socket, or an instance that is not ready) is neither |
| +// advertised nor given assets, so no other edge forwards to it or orders a |
| +// certificate for it. |
| +func TestPlatformAliasPublicationFollowsTheEdgesRule(t *testing.T) { |
| + t.Parallel() |
| + w := newAssetWorld(t) |
| + w.ship("v1", "/assets/") |
| + const inst = "shop-a.abc.example.com" |
| + w.instance(inst, assetGen1, "v1") |
| + sock := "/run/carlos/" + inst + ".sock" |
| + for _, rt := range []registry.Route{ |
| + {Host: "shop.abc.example.com", Kind: "instance", Account: "abc", App: "shop", Platform: true, Status: "ready", Socket: sock}, |
| + {Host: "shop.xyz.example.com", Kind: "instance", Account: "xyz", App: "shop", Platform: true, Status: "ready", Socket: sock}, |
| + } { |
| + if err := w.reg.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + w.confirm() |
| + hosts := w.hosts() |
| + wantAssets(t, hosts, "shop.abc.example.com", []string{"/assets/"}, assetGen1, assetT0) |
| + if got := hosts["shop.abc.example.com"].Assets.Primary; got != inst { |
| + t.Errorf("alias published primary %q, want %s", got, inst) |
| + } |
| + if got, ok := w.policy.For("shop.abc.example.com"); !ok || got.Primary != inst || got.Gen != assetGen1 { |
| + t.Errorf("For(alias) = %+v %v, want the instance's block", got, ok) |
| + } |
| + if _, ok := hosts["shop.xyz.example.com"]; ok { |
| + t.Error("another account's alias on the socket was advertised") |
| + } |
| + if _, ok := w.policy.For("shop.xyz.example.com"); ok { |
| + t.Error("another account's alias was given assets") |
| + } |
| + |
| + // The instance leaves ready: its alias stops being advertised with it. |
| + if err := w.reg.SetStatus(inst, "moving"); err != nil { |
| + t.Fatal(err) |
| + } |
| + hosts = w.hosts() |
| + if _, ok := hosts["shop.abc.example.com"]; ok { |
| + t.Error("the alias of a moving instance is still advertised") |
| + } |
| +} |
diff --git a/internal/host/aliaswake_test.go b/internal/host/aliaswake_test.go| index 4ce2f450e..0358f489e 100644 |
| --- a/internal/host/aliaswake_test.go |
| +++ b/internal/host/aliaswake_test.go |
| @@ -112,4 +112,64 @@ func TestPlatformAliasWakesItsSleepingInstance(t *testing.T) { |
| if len(inst.served()) != before { |
| t.Errorf("another tenant's alias reached the awake instance") |
| } |
| + |
| + // The instance leaves "ready" (a move sets "moving" before it |
| + // quiesces): its alias is not served, even with the socket still live. |
| + // Never a direct proxy around the instance's own status. |
| + if err := reg.SetStatus(host, "moving"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := e.Reload(); err != nil { |
| + t.Fatal(err) |
| + } |
| + before = len(inst.served()) |
| + if code, _ := get("shop.bab.oncarlos.com"); code == http.StatusOK || len(inst.served()) != before { |
| + t.Errorf("alias of a moving instance answered %d and reached it", code) |
| + } |
| +} |
| + |
| +// The alias's own prefix map, through the real edge and activator: a |
| +// matched prefix reaches its target, the default wakes the instance. |
| +func TestPlatformAliasPrefixMapWakesTheInstanceByDefault(t *testing.T) { |
| + const host = "shop-a.bab.oncarlos.com" |
| + reg, inst, svc, _ := wakeFixture(t, host, time.Hour, func(w http.ResponseWriter, r *http.Request) { |
| + io.WriteString(w, "awake") |
| + }) |
| + docs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { io.WriteString(w, "docs") })) |
| + defer docs.Close() |
| + for _, rt := range []registry.Route{ |
| + {Host: "shop.bab.oncarlos.com", Kind: "instance", Account: "bab", App: "app", Platform: true, Status: "ready", Socket: inst.socket}, |
| + {Host: "docs.bab.oncarlos.com", Kind: "service", Account: "bab", App: "docs", Status: "ready", Addr: docs.Listener.Addr().String()}, |
| + } { |
| + if err := reg.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if err := reg.UpsertPath(registry.RoutePath{Host: "shop.bab.oncarlos.com", Prefix: "docs", Target: "docs.bab.oncarlos.com"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + e, err := edge.New(reg, svc) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + server := httptest.NewServer(e) |
| + defer server.Close() |
| + get := func(path string) (int, string) { |
| + t.Helper() |
| + r, _ := http.NewRequest(http.MethodGet, server.URL+path, nil) |
| + r.Host = "shop.bab.oncarlos.com" |
| + resp, err := (&http.Client{Timeout: 10 * time.Second}).Do(r) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer resp.Body.Close() |
| + b, _ := io.ReadAll(resp.Body) |
| + return resp.StatusCode, string(b) |
| + } |
| + if code, body := get("/docs/intro"); code != http.StatusOK || body != "docs" || inst.startCount() != 0 { |
| + t.Fatalf("matched prefix: %d %q, starts %d", code, body, inst.startCount()) |
| + } |
| + if code, body := get("/elsewhere"); code != http.StatusOK || body != "awake" || inst.startCount() != 1 { |
| + t.Fatalf("unmatched path: %d %q, starts %d", code, body, inst.startCount()) |
| + } |
| } |
diff --git a/internal/host/assetpolicy.go b/internal/host/assetpolicy.go| index 5ae832c93..10fabb7e0 100644 |
| --- a/internal/host/assetpolicy.go |
| +++ b/internal/host/assetpolicy.go |
| @@ -198,11 +198,19 @@ type assetInputs struct { |
| pathHosts map[string]bool |
| // owners is servedOwners over the served rows. |
| owners map[string]*hostOwner |
| + // platformOf maps a platform alias the edge serves with its instance's |
| + // entry to that instance's host; platformRefused holds the ones the edge |
| + // does not serve (edge.PlatformAliasFold). |
| + platformOf map[string]string |
| + platformRefused map[string]bool |
| } |
| func newAssetInputs(routes []registry.Route, served map[string]edgeHost, paths []registry.RoutePath, aliases []registry.RouteAlias, owners map[string]*hostOwner) assetInputs { |
| in := assetInputs{byHost: make(map[string]registry.Route, len(routes)), aliasOf: map[string]string{}, |
| pathHosts: map[string]bool{}, owners: owners} |
| + // Platform aliases resolve as the edge resolves them (#338 follow-up), |
| + // so the policy names the primary the edge serves the alias with. |
| + in.platformOf, in.platformRefused = edge.PlatformAliasFold(routes) |
| for _, r := range routes { |
| in.byHost[r.Host] = r |
| } |
| @@ -251,6 +259,13 @@ func (p *assetPolicy) readAssetInputs() (assetInputs, error) { |
| // primary resolves host to the route the edge serves it with: its own row, |
| // or for an exact alias its primary's (a real route beats an alias). |
| func (in assetInputs) primary(host string) (registry.Route, bool) { |
| + if in.platformRefused[host] { |
| + return registry.Route{}, false |
| + } |
| + if src, ok := in.platformOf[host]; ok { |
| + r, ok := in.byHost[src] |
| + return r, ok |
| + } |
| if r, ok := in.byHost[host]; ok { |
| return r, true |
| } |
diff --git a/internal/host/edgesfile.go b/internal/host/edgesfile.go| index 7dd53d55e..8b5fb1f8b 100644 |
| --- a/internal/host/edgesfile.go |
| +++ b/internal/host/edgesfile.go |
| @@ -16,6 +16,7 @@ import ( |
| "time" |
| "github.com/carlosframework/platform/internal/appconfig" |
| + "github.com/carlosframework/platform/internal/edge" |
| "github.com/carlosframework/platform/internal/instancectl" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| @@ -535,7 +536,14 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| return fmt.Errorf("edges: list: %w", err) |
| } |
| hosts := make(map[string]edgeHost, len(routes)) |
| + // A platform alias the edge refuses to serve (edge.PlatformAliasFold: |
| + // another tenant's socket, or an owner that is not ready) is not |
| + // advertised either, nor anything attached to it (#338 follow-up). |
| + _, refusedAliases := edge.PlatformAliasFold(routes) |
| for _, r := range routes { |
| + if refusedAliases[r.Host] { |
| + continue |
| + } |
| // edge.Reload (internal/edge/edge.go) is the deployment's own |
| // definition of "serves": it skips any row whose Status != "ready" |
| // because a pending/creating/failed row has no working backend and |
diff --git a/internal/provision/testdata/plan14-root-reads-alias-wake-338.tsv b/internal/provision/testdata/plan14-root-reads-alias-wake-338.tsv| index 5e2b53621..d95323690 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-alias-wake-338.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-alias-wake-338.tsv |
| @@ -1,10 +1,16 @@ |
| # Census overlay alias-wake-338, written by census-propose (#369). census-ruling-alias-wake-338, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-alias-wake-338.md. |
| -# 1 body, 1 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 1 body, 4 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| # 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| @legacy 50b49b4c666f8ef7da4d351441b1518dfa0ab7022e1a32f0de1c7730257190c9 internal/edge/edge.go Edge.currentHosts legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: a resolved platform alias (platformAlias) stays in the wildcard parent set as its own row was before; attached hostnames still excluded registry:Platform@123,registry:Provisioned@144,whole:Route@126,whole:Route@147 ca98cb2611a9334a4f42b2dea56f3273f4ee01395657d70a3012891927199354 |
| -@legacy d7aecec81ec29d7e1ef8e63a35a2b5f22f7ec69a6b8c3c0678f1fad0cf2d32c5 internal/edge/platformalias.go platformAliasFold legacy accepted-legacy accepted-legacy;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: from the edge's own registry listing, maps each ready platform alias with a socket to the one ready non-platform, non-sidecar route of the same effective account and app on that socket (sources), or marks it foreign when only another tenant's route holds that socket; reads route columns only, opens nothing registry:Account@362,registry:Account@686,registry:App@241,registry:App@374,registry:App@698,registry:App@734,registry:Host@423,registry:Host@777,registry:Host@853,registry:Platform@210,registry:Platform@555,registry:Socket@256,registry:Socket@381,registry:Socket@442,registry:Socket@569,registry:Socket@705,registry:Socket@831,registry:Status@274,registry:Status@587,whole:Route@196,whole:Route@540 2469d4d74c457bdcd6de221649cf7907c38b2c97cbb2ee7715e219f557020895 |
| -@legacy ae27b00e587f0301bd966c308c3df382475a603eb559970cd23d8f6b4923e4fb internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a platform alias with a source takes the source's own upstream entry (same proxy, route, hibernating, so the existing activator wake, lease and fence apply) unless it has its own prefix map; a foreign alias is dropped from the map (not served, so not Allowed for ACME either); the attached-hostname fold clears platformAlias registry:Account@19866,registry:Alias@18035,registry:Alias@18122,registry:Alias@18358,registry:FleetBox@5526,registry:Health@7689,registry:Health@7807,registry:Hibernate@13017,registry:Hibernate@14927,registry:Hibernate@6049,registry:Host@13065,registry:Host@14989,registry:Host@15297,registry:Host@15324,registry:Host@16125,registry:Host@16391,registry:Host@18161,registry:Host@6098,registry:Host@8290,registry:Host@8385,registry:Host@8665,registry:Host@8691,registry:Host@8743,registry:Kind@11542,registry:Kind@11564,registry:Kind@12993,registry:Kind@14903,registry:Kind@6025,registry:Kind@8831,registry:Kind@8891,registry:Name@19856,registry:Prefix@16366,registry:Region@2252,registry:Socket@15305,registry:Socket@5633,registry:Socket@6162,registry:Status@1835,registry:Target@16378,registry:Tunnel@4574,registry:Tunnel@4630,registry:Version@11523,registry:Version@11625,whole:Fleet@19806,whole:Fleet@19835,whole:Route@130,whole:Route@15357,whole:Route@15364,whole:Route@15460,whole:Route@17021,whole:Route@4692,whole:Route@5590,whole:Route@6218,whole:Route@648,whole:Route@8808,whole:Route@8881,whole:Route@8941,whole:RouteAlias@18006,whole:RoutePath@16103 aeed86152a343620191525e310ebe9daeb69b9587a466cb20274afae2b38ec57 |
| +@legacy 830ca468138fa214556ed707b67fdec08b6746a072e7a6d665c666360b1f090a internal/edge/platformalias.go PlatformAliasFold legacy accepted-legacy accepted-legacy;rev3=census-ruling-alias-wake-338;basis=#338 follow-up (renamed from platformAliasFold, exported for the publisher and asset policy): from a registry listing, maps each ready platform alias with a socket to the one ready non-platform, non-sidecar route of the same effective account and app on that socket (sources), else refuses it when its socket has any owner (its own tenant's not ready or ambiguous, or another tenant's); reads route columns only, opens nothing registry:Account@343,registry:Account@656,registry:App@245,registry:App@355,registry:App@668,registry:App@704,registry:Host@773,registry:Host@783,registry:Host@845,registry:Platform@214,registry:Platform@527,registry:Socket@260,registry:Socket@362,registry:Socket@414,registry:Socket@541,registry:Socket@675,registry:Socket@823,registry:Status@559,registry:Status@736,whole:Route@200,whole:Route@374,whole:Route@393,whole:Route@404,whole:Route@512,whole:Route@606,whole:Route@723,whole:Route@736,whole:Route@783,whole:Route@806 a18e4963cf88320ef3fb94b666b02838dc12cc3e9b2df3f2cbe2576ca682735f |
| +@legacy e79a1e502c75ba00552231c94d5a5286f74c102b009c3738d3a3d183a096b522 internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map if it has one; a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias registry:Account@20101,registry:Alias@18270,registry:Alias@18357,registry:Alias@18593,registry:FleetBox@5526,registry:Health@7689,registry:Health@7807,registry:Hibernate@13017,registry:Hibernate@14927,registry:Hibernate@6049,registry:Host@13065,registry:Host@14989,registry:Host@15297,registry:Host@15324,registry:Host@16125,registry:Host@16391,registry:Host@18396,registry:Host@6098,registry:Host@8290,registry:Host@8385,registry:Host@8665,registry:Host@8691,registry:Host@8743,registry:Kind@11542,registry:Kind@11564,registry:Kind@12993,registry:Kind@14903,registry:Kind@6025,registry:Kind@8831,registry:Kind@8891,registry:Name@20091,registry:Prefix@16366,registry:Region@2252,registry:Socket@15305,registry:Socket@5633,registry:Socket@6162,registry:Status@1835,registry:Target@16378,registry:Tunnel@4574,registry:Tunnel@4630,registry:Version@11523,registry:Version@11625,whole:Fleet@20041,whole:Fleet@20070,whole:Route@130,whole:Route@15357,whole:Route@15364,whole:Route@15460,whole:Route@17162,whole:Route@4692,whole:Route@5590,whole:Route@6218,whole:Route@648,whole:Route@8808,whole:Route@8881,whole:Route@8941,whole:RouteAlias@18241,whole:RoutePath@16103 46144861ccd1f5bc29ed968f475eaa39082c39d522930a7119ae7810bf4f998c |
| +@legacy d23c6f92cc700f29435b0af46e92957dc62643d7284f410e9eab710a4e5624f5 internal/host/assetpolicy.go assetInputs.primary legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), in the edges file loop (edgesFileLoop, edgesFileWriteClaims), only on a box armed with CARLOS_ASSET_CACHE=1 (armAssetPolicy answers nil otherwise): resolves a hostname to its route row or, for an exact alias, its primary's, over rows already read; reads nothing itself; no root pass calls it; no root decision;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: a refused platform alias has no primary; a resolved one resolves to its source's row, as the edge serves it whole:Route@190,whole:Route@211,whole:Route@236,whole:Route@264,whole:Route@326,whole:Route@346 855f8f6e91e6f313186c39360efde17c472fb30a1bf2b689a93b51c42d9e3edc |
| +@legacy 1a9bb53143c27a675bcaf1b5683f6be5de1c5dc1e0d367bc3f7d9c144f49671f internal/host/assetpolicy.go newAssetInputs legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), in the edges file loop (edgesFileLoop, edgesFileWriteClaims), only on a box armed with CARLOS_ASSET_CACHE=1 (armAssetPolicy answers nil otherwise): indexes rows already read (routes by host, exact aliases to their primary, hosts with path rows) and the owners (servedOwners when not handed them); reads nothing itself; no root pass calls it; no root decision;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: records edge.PlatformAliasFold over the same routes (platformOf, platformRefused) registry:Alias@685,registry:Alias@720,registry:Alias@766,registry:Host@576,registry:Host@633,registry:Host@777,whole:Route@195,whole:Route@239,whole:Route@528,whole:Route@555,whole:Route@569,whole:Route@586,whole:Route@837,whole:RouteAlias@670,whole:RoutePath@610,whole:RoutePath@853 54c90ae15c22220b05121ba828a4a7c7be5c8a990d585bbe88900caaf319225d |
| internal/edge/edge.go Edge.currentHosts legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: a resolved platform alias (platformAlias) stays in the wildcard parent set as its own row was before; attached hostnames still excluded registry:Platform@123,registry:Provisioned@144,whole:Route@126,whole:Route@147 ca98cb2611a9334a4f42b2dea56f3273f4ee01395657d70a3012891927199354 |
| -internal/edge/platformalias.go platformAliasFold legacy accepted-legacy accepted-legacy;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: from the edge's own registry listing, maps each ready platform alias with a socket to the one ready non-platform, non-sidecar route of the same effective account and app on that socket (sources), or marks it foreign when only another tenant's route holds that socket; reads route columns only, opens nothing registry:Account@362,registry:Account@686,registry:App@241,registry:App@374,registry:App@698,registry:App@734,registry:Host@423,registry:Host@777,registry:Host@853,registry:Platform@210,registry:Platform@555,registry:Socket@256,registry:Socket@381,registry:Socket@442,registry:Socket@569,registry:Socket@705,registry:Socket@831,registry:Status@274,registry:Status@587,whole:Route@196,whole:Route@540 2469d4d74c457bdcd6de221649cf7907c38b2c97cbb2ee7715e219f557020895 |
| -internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a platform alias with a source takes the source's own upstream entry (same proxy, route, hibernating, so the existing activator wake, lease and fence apply) unless it has its own prefix map; a foreign alias is dropped from the map (not served, so not Allowed for ACME either); the attached-hostname fold clears platformAlias registry:Account@19866,registry:Alias@18035,registry:Alias@18122,registry:Alias@18358,registry:FleetBox@5526,registry:Health@7689,registry:Health@7807,registry:Hibernate@13017,registry:Hibernate@14927,registry:Hibernate@6049,registry:Host@13065,registry:Host@14989,registry:Host@15297,registry:Host@15324,registry:Host@16125,registry:Host@16391,registry:Host@18161,registry:Host@6098,registry:Host@8290,registry:Host@8385,registry:Host@8665,registry:Host@8691,registry:Host@8743,registry:Kind@11542,registry:Kind@11564,registry:Kind@12993,registry:Kind@14903,registry:Kind@6025,registry:Kind@8831,registry:Kind@8891,registry:Name@19856,registry:Prefix@16366,registry:Region@2252,registry:Socket@15305,registry:Socket@5633,registry:Socket@6162,registry:Status@1835,registry:Target@16378,registry:Tunnel@4574,registry:Tunnel@4630,registry:Version@11523,registry:Version@11625,whole:Fleet@19806,whole:Fleet@19835,whole:Route@130,whole:Route@15357,whole:Route@15364,whole:Route@15460,whole:Route@17021,whole:Route@4692,whole:Route@5590,whole:Route@6218,whole:Route@648,whole:Route@8808,whole:Route@8881,whole:Route@8941,whole:RouteAlias@18006,whole:RoutePath@16103 aeed86152a343620191525e310ebe9daeb69b9587a466cb20274afae2b38ec57 |
| -@coverage internal/edge 3a63e0e4f9b658e43f42abfbbb8661b718be8e647d6f2b74093b1dfdcf871841 |
| +internal/edge/platformalias.go PlatformAliasFold legacy accepted-legacy accepted-legacy;rev3=census-ruling-alias-wake-338;basis=#338 follow-up (renamed from platformAliasFold, exported for the publisher and asset policy): from a registry listing, maps each ready platform alias with a socket to the one ready non-platform, non-sidecar route of the same effective account and app on that socket (sources), else refuses it when its socket has any owner (its own tenant's not ready or ambiguous, or another tenant's); reads route columns only, opens nothing registry:Account@343,registry:Account@656,registry:App@245,registry:App@355,registry:App@668,registry:App@704,registry:Host@773,registry:Host@783,registry:Host@845,registry:Platform@214,registry:Platform@527,registry:Socket@260,registry:Socket@362,registry:Socket@414,registry:Socket@541,registry:Socket@675,registry:Socket@823,registry:Status@559,registry:Status@736,whole:Route@200,whole:Route@374,whole:Route@393,whole:Route@404,whole:Route@512,whole:Route@606,whole:Route@723,whole:Route@736,whole:Route@783,whole:Route@806 a18e4963cf88320ef3fb94b666b02838dc12cc3e9b2df3f2cbe2576ca682735f |
| +internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map if it has one; a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias registry:Account@20101,registry:Alias@18270,registry:Alias@18357,registry:Alias@18593,registry:FleetBox@5526,registry:Health@7689,registry:Health@7807,registry:Hibernate@13017,registry:Hibernate@14927,registry:Hibernate@6049,registry:Host@13065,registry:Host@14989,registry:Host@15297,registry:Host@15324,registry:Host@16125,registry:Host@16391,registry:Host@18396,registry:Host@6098,registry:Host@8290,registry:Host@8385,registry:Host@8665,registry:Host@8691,registry:Host@8743,registry:Kind@11542,registry:Kind@11564,registry:Kind@12993,registry:Kind@14903,registry:Kind@6025,registry:Kind@8831,registry:Kind@8891,registry:Name@20091,registry:Prefix@16366,registry:Region@2252,registry:Socket@15305,registry:Socket@5633,registry:Socket@6162,registry:Status@1835,registry:Target@16378,registry:Tunnel@4574,registry:Tunnel@4630,registry:Version@11523,registry:Version@11625,whole:Fleet@20041,whole:Fleet@20070,whole:Route@130,whole:Route@15357,whole:Route@15364,whole:Route@15460,whole:Route@17162,whole:Route@4692,whole:Route@5590,whole:Route@6218,whole:Route@648,whole:Route@8808,whole:Route@8881,whole:Route@8941,whole:RouteAlias@18241,whole:RoutePath@16103 46144861ccd1f5bc29ed968f475eaa39082c39d522930a7119ae7810bf4f998c |
| +internal/host/assetpolicy.go assetInputs.primary legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), in the edges file loop (edgesFileLoop, edgesFileWriteClaims), only on a box armed with CARLOS_ASSET_CACHE=1 (armAssetPolicy answers nil otherwise): resolves a hostname to its route row or, for an exact alias, its primary's, over rows already read; reads nothing itself; no root pass calls it; no root decision;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: a refused platform alias has no primary; a resolved one resolves to its source's row, as the edge serves it whole:Route@190,whole:Route@211,whole:Route@236,whole:Route@264,whole:Route@326,whole:Route@346 855f8f6e91e6f313186c39360efde17c472fb30a1bf2b689a93b51c42d9e3edc |
| +internal/host/assetpolicy.go newAssetInputs legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), in the edges file loop (edgesFileLoop, edgesFileWriteClaims), only on a box armed with CARLOS_ASSET_CACHE=1 (armAssetPolicy answers nil otherwise): indexes rows already read (routes by host, exact aliases to their primary, hosts with path rows) and the owners (servedOwners when not handed them); reads nothing itself; no root pass calls it; no root decision;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: records edge.PlatformAliasFold over the same routes (platformOf, platformRefused) registry:Alias@685,registry:Alias@720,registry:Alias@766,registry:Host@576,registry:Host@633,registry:Host@777,whole:Route@195,whole:Route@239,whole:Route@528,whole:Route@555,whole:Route@569,whole:Route@586,whole:Route@837,whole:RouteAlias@670,whole:RoutePath@610,whole:RoutePath@853 54c90ae15c22220b05121ba828a4a7c7be5c8a990d585bbe88900caaf319225d |
| +internal/host/edgesfile.go edgesFileWriteClaims authority F,J1 rev3=census-ruling-self-serve-moves-1;basis=root-route;kept=F;scope=protected-decision-only; the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): region-ha-2a's body, which with the box's lifetimes switch on also publishes each served row's lifetime pair (registry:Incarnation and registry:ServingSeq, two new sites on the rows it already lists) and an alias's or served catch-all's primary's pair, and names that primary as target_host whatever the switch; a report the edge orders unstamped entries by, not a decision; no record, /data, release or claim read added; F,J1 authority retained; self-serve moves 1 Task 8;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 8: takes a localAddrs reader (instancectl.LocalAddresses in production, which reads /proc/net/fib_trie and /proc/net/if_inet6 in the agent) and publishes its non-loopback entries as the edges file's addrs before the write gate (boxAddrs, no read of its own), so an address change writes once. The same 44 sites, offsets moved; no record, /data, release or claim read added; a report the console's egress grant check reads, not a root decision; F,J1 authority retained.;rev3=census-ruling-edge-asset-cache-3;basis=starts with assets = assets.active(), so a policy whose box has not opened its asset store publishes no assets blocks and reads no manifests, and copies the decision's Primary (the route host the block was decided for, drift D4) into the published assets block; read sites unchanged (44); no read added. Merged onto main's #328 body, which takes the localAddrs reader: the assets.active() line sits after that signature and the loop passes pub and instancectl.LocalAddresses;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: the claims argument (*edgesClaims) becomes addrs (AddressSource) and the applyEdgesClaims(ctx, claims, routes, hosts) call is deleted with edgesclaims.go, which is the one whole:Route site removed: no host claim is read and every served row publishes as with region HA off; the box-address publication is the same code reading addrs.BoxAddresses() instead of claims.addrs; a report the edge reads, not a root decision; no read added; merge of origin/main d7ae1d76: main's edge asset cache plan 3 body is kept (census-ruling-edge-asset-cache-3): the first line is assets = assets.active(), so a policy whose store has not opened publishes no assets blocks and reads no manifests, and edgesFileLoop passes pub (assets.active() for that tick) in the assets argument; main's claims *edgesClaims argument is this branch's addrs AddressSource, and no edgesClaims, applyEdgesClaims or hostclaim reference remains;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: skips publishing a platform alias edge.PlatformAliasFold refuses (and so anything attached to it); reads the same route listing registry:Account@12119,registry:Alias@6067,registry:Alias@6102,registry:Alias@6524,registry:Alias@6681,registry:Alias@6751,registry:Alias@6783,registry:Alias@7456,registry:Alias@9811,registry:App@12131,registry:DNSStatus@6199,registry:DNSStatus@6690,registry:Host@10039,registry:Host@1068,registry:Host@11549,registry:Host@3905,registry:Host@6159,registry:Host@7004,registry:Host@7440,registry:Host@7613,registry:Host@9858,registry:Host@9905,registry:Host@9955,registry:Host@9990,registry:Incarnation@3865,registry:Platform@3644,registry:Provisioned@3658,registry:Replica@3682,registry:ServingSeq@3880,registry:Status@1611,whole:Route@1012,whole:Route@1039,whole:Route@13214,whole:Route@13640,whole:Route@13815,whole:Route@4275,whole:Route@750,whole:RouteAlias@13236,whole:RouteAlias@13830,whole:RouteAlias@6052,whole:RouteAlias@9764,whole:RoutePath@13229,whole:RoutePath@13823,whole:RoutePath@4290,whole:WildcardDomain@9944 e75a5d7aacc51670ce9506f9301600c8a2bcfa3340825de0cc5b1b89ec8b5508 |
| +@coverage internal/edge 956fa8e246ca8b11f05fbb2e0db708317b9ee58c20464800f075da720fe702fd |
| +@coverage internal/host 66d7da5192204f380d0e8cef9a5b969aa40d9191d27157382898991bf34c2c8b |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 368b384dc..c231f2b56 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -8,4 +8,4 @@ plan14-root-reads-remote-metrics-nested.tsv e923841657499fc729713abdd750cbd2d601 |
| plan14-root-reads-region-ha-p1a.tsv 125c5c411cd0a04000d9652800b51bc7c066081c00753fb1c7b6ee0b6e717dbd |
| plan14-root-reads-nearest-region-b.tsv f4e36134015ec6d09bada7be500c8faad22450afda12d033a8e3e24b1e8bb361 |
| plan14-root-reads-alias-socket-follow-338.tsv 5192052a23d2fdd6f5d48b5617fe28a9bb03458e1e931c060fbdc42c3d627927 |
| -plan14-root-reads-alias-wake-338.tsv 410ee337af4419b4ef7b3e78acee5408ae196d276d4d1f6ac3cde1697c84b7be |
| +plan14-root-reads-alias-wake-338.tsv b2d44f5fc354d2c47c91ec55842d1b8f6be0a2913a25157408cb177ed91a67ae |