carlos / platform Public

edge: answer /.carlos/geo with the visitor's country, for static sites

A static site runs no code, so its pages never see the X-Carlos-Geo-*
headers an app gets (#241). Every site the edge serves now answers
GET/HEAD /.carlos/geo itself with {"country":"IE","source":"..."}, or
nulls when the country is unknown, from the request's one geo answer:
the same lookup, the same trust in a verified hop or a tunnel, null with
no database (there is no per-app switch, geoip spec R4) and for a door
call. Other methods get 405.

The box that serves the route answers it, after every check that decides
who serves the host (backhaul, HA forwards, door scope, import gate,
lapse) and before the meter, the observer, the guard, the password gate,
the asset catch, the page cache and the LRU. So it is never billed,
counted in analytics or filed as a request record, like the edge's other
own answers. Cache-Control no-store, private and Vary * keep it out of
every cache; the far asset catch skips the path whatever prefix an app
declared. The path is reserved in every spelling that cleans to it: a
site's own file or an app's route there is never served. A linked
request goes on to its pinned app.

Production-wired tests: static site and app site with the MaxMind test
database, no database, unplaced address, methods, never cached (page
cache, asset store, LRU), not counted or metered, custom domain,
backhaul, far asset catch, tunnel hub, door call. A short section on the
geo docs (cli.md) and the census card for Edge.ServeHTTP (body,
read sites unchanged).

Discussion #962.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 2edc14b3dda274fc215b58a53eea3553f57261a3 parent f2cf282
8 files changed, +575 −0
  • docs/site/cli.md +19 −0
  • docs/superpowers/notes/census-proposal-static-site-geo-962.md +19 −0
  • internal/edge/assetcatch.go +8 −0
  • internal/edge/edge.go +16 −0
  • internal/edge/geoanswer.go +87 −0
  • internal/edge/geoanswer_test.go +420 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-static-site-geo-962.tsv +5 −0

CI cancelled — superseded by a newer push — run details

diff --git a/docs/site/cli.md b/docs/site/cli.md
index 0e33fb9f4..1f7174243 100644
--- a/docs/site/cli.md
+++ b/docs/site/cli.md
@@ -1786,6 +1786,25 @@ these headers, it must credit the database `X-Carlos-Geo-Source` names:
- `GeoLite2-…`: "This product includes GeoLite2 data created by MaxMind,
available from https://www.maxmind.com"
+### The visitor's country in a static page
+
+A static site runs no code, so it never sees these headers. Its pages can
+ask the edge instead. Every site, static or app, answers `GET /.carlos/geo`
+with the visitor's country:
+
+```json
+{"country":"IE","source":"DBIP-City-Lite"}
+```
+
+Both are `null` when the country is unknown, for the same reasons the
+headers can be missing. Fetch it from the page's own address, and fall back
+to another guess, such as the browser's language, on `null` or an error.
+
+The edge answers this address itself, so a file or route of your own at
+`/.carlos/geo` is never served. The answer is never cached, sets no cookie
+and isn't counted in analytics. Credit the database `source` names, as
+above.
+
### carlos geo
```sh
diff --git a/docs/superpowers/notes/census-proposal-static-site-geo-962.md b/docs/superpowers/notes/census-proposal-static-site-geo-962.md
new file mode 100644
index 000000000..47d973240
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-static-site-geo-962.md
@@ -0,0 +1,19 @@
+# Census approval: static-site-geo-962
+
+Ruling `census-ruling-static-site-geo-962`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/edge/edge.go` `Edge.ServeHTTP` | body | unchanged (65) | discussion #962: after planDisabledAdmit and before the page mark holder and the observer, a request whose cleaned path is /.carlos/geo (not a linked request) is answered by serveGeoAnswer from the request's geo answer already on the context (decideGeo), 200 JSON no-store or 405, and returns; no store, registry or file read added; read sites unchanged |
+
+Envelopes re-pinned: `internal/edge`.
+
+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. Reject 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. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/edge/edge.go` `Edge.ServeHTTP`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.;rev3=census-ruling-plans-4d-lapse;basis=calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here.;rev3=census-ruling-edge-protection-2;basis=runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read;rev3=census-ruling-edge-asset-cache-3;basis=the asset cache's three hooks (asset cache plan 3): the request's reserved asset headers are deleted at entry (the fill assertion kept only beside a verified hop); on the exact-remote and lookup-miss branches the far catch (serveAssetFar) is tried before backhaulTo and backhaul; after the observer defer and main's hard and probe checks, a verified hop with a valid fill assertion is answered by serveAssetFillForHop; after the upgrade branch and before gzip and the shared cache, the local catch (serveAssetLocal); the observer defer skips only the usage meter for an acknowledged home fill (out.unbilled); the new reads live in the new units of the edge-asset-cache-3-decisions overlay; the same route row and read sites (25); no read added;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: straight after lookupUpstreamPath it calls regionalGate (regional.go), which for an entry built from a regional_domains row answers 503 to a hop or a deny entry before any arm that can leave the box (the exact-home backhaul, the far asset catch, the door dial, the miss backhaul), and lets a star match through only to the exact-home arm when ExactHome names another box for that distinct exact name; after the exact-home arm a regional deny entry the arm did not answer is refused (regionalRefuse, 503); refusals only, on the route map the edge already holds; read sites unchanged (25);rev3=census-ruling-static-headers;basis=the shared response cache is no longer looked up or filled for a static-kind route: one more read of the route row the edge already resolved (up.route.Kind == "static") in the cacheable expression; a refusal only, nothing new opened or followed;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2 (N-HA10): one call, frontForwardHA, right after the route lookup's !ok block and before the login POST; same reads;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 4: loginPost and cacheable treat a forward row as not this box's to answer (IsForward(), +whole:Route x2): no login form and no shared cache for a forward host. Serving only.;rev3=census-ruling-tunnel-websockets;basis=Deletes the Carlos-Upgrade marker header from incoming requests and puts the upgrade admission (host, path, the entry tenancy, all in hand) on a tunnel arm request. For a login POST on an ungated ArmTunnel row it reads the visitor request body (bounded by gate.MaxFormBody, 413 past it; a request body, not a file) and resolves next against the entry Reload built (Gate, Route); the bytes pass on only when loginPassesThrough holds (spec 7, Tasks 3, 5 and 6).;rev3=census-ruling-console-protection-tab;basis=one more call in the observer defer, observeGuardCount(up.route, out), beside the observeRecords call that files the guard Match: it passes on the route row the defer already holds (+whole:Route) and the request outcome to the usage meter, which counts the check in memory. Called whether or not the request was unbilled, as observeRecords is. Nothing is opened, read or followed; no new kind of read; no check, refusal or serving decision changes.;rev3=census-ruling-probe-burst-limit;basis=answers a probe-burst notice POST (serveBurstNotice) ahead of every route for a non-door caller; builds the guard state for up.route and stamps its account and app (RouteAccount, App) for the cool-down's this-app/other-app label; for a catalogue match on a non-static or tunnelled route, offers the burst rule (in-memory limiter, burstDecide: 429 or a watch verdict, never a block for a fleet or forward row); the observer defer calls noteBurst(up.route, ...); the added sites are the route value already in hand (+registry:App, +whole:Route x5); no new root read or write kind;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): parses the request's query once (stripHoldMarker) to record the carlos_hold=1 mark in the request context; calls classifyHold on the upstream already resolved from the loaded map (the +whole:Route is that in-memory Route), including a second pass for a login POST; gives a marked request on a door-refused route the plain 404; adds the hold branch (planThrottleAdmit, rateAdmit, serveHeld) after the gate; and excludes marked requests from the shared cache. Reads only the request and the already-loaded upstream map; no registry or bucket read added.;rev3=census-ruling-region-ha-p3a;basis=Complete the P3a cut: an exact peer name with no dial target answers the approved admission 503 before local wildcard dispatch or asset serving. ExactHome and lookupHome stop fallback at a present non-dial entry; backhaulTo refuses an empty target before signing or dialing. Retain Task 3 local admission and fixed platform/unit exemptions. Two added whole Route uses feed the local in-memory admission predicate; existing Route values and store/path reads are unchanged.;rev3=census-ruling-stateless-coordinator-route;basis=P24/P25: POST only, exact /api/fleet/replicas/ prefix on the reserved tunnel host calls the existing local console proxy only for an unescaped, already-clean path; malformed forms remain on the hub. No new read sites relative to origin/main. Merge with main 3487d6f6 retains its region HA admission checks before routing and after login target lookup, its empty-home refusal, and their two existing whole:Route reads; these change this unit's digest relative to the previously approved branch tip 92b24a7d.;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: pass the already-resolved Route to the reserved replica-probe handler after acceptHop and existing admissionRefuses, requiring tunnel context plus private marker and refusing door/backhaul ingress. Added whole Route use only; scrub marker before forwarding; HA calls remain unchanged.;rev3=census-ruling-region-ha-p3b;basis=Resolve local aliases/catch-alls with cached peer name ownership before serving. Add registry Account/App/ClaimStamp/Host/Incarnation/ServingSeq and six whole Route references for NameClaim; inputs are agent registry rows/edges publications used by unprivileged edge, not root permits. Closed owners retain names and return 503; aware remote owner cannot fall through on missing transport, while legacy hop/door behavior remains. Merge 45cebde4 retains authenticated replica probes after local admission and before ordinary name resolution; probe authentication still requires the tunnel context.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1901 enters the protected demo path before ordinary exits; :2012-2015 rechecks the selected marked Route after lookup. Added whole Route use routes demos through serving checks, counters and policy; no new registry query or file open in this unit.;rev3=census-ruling-demo-api-site-route;basis=Reserve the configured site API namespace after hop verification and control-header scrubbing, before ordinary static, cache, billing and tenant dispatch. Validate hop field shape and delegate only allowlisted operations to the dedicated console path with verified client attribution and console admission. The alias helper enables HTTP/1.1 full duplex so an early console refusal does not wait for upload EOF. Existing 56 read sites unchanged; no new registry, bucket or file read.;rev3=census-ruling-region-ha-g2-fixes;basis=Consult HA ingress after region admission and before miss/alias backhaul; no new direct read; routing-only metadata does not create an upstream.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3/W4: backhaul and door calls pass the owner the door checked into backhaulTo; the §6.5 holder follow (once, GET/HEAD or an unswitched upgrade, no body) and one connect-failure fallback dial only boxes in the holder region's view (same Region/Placement/DataBucket, HomeEligible, fresh) for that owner. Holder name comes only from the TLS-verified signed hop answer; app-set X-Carlos-Holder stays stripped. Routing only; the receiving box still re-checks the lease. No new read site.;rev3=census-ruling-edge-page-cache-1;basis=attaches an in-memory page mark holder to every request to an instance route (the +registry:Kind check of up.route.Kind), wraps the hold and upgrade branches in pageDiagnostics, asks servePage after the plan throttle (a hit answered from the page index over the asset store), keeps an opted-in instance out of the LRU (pagesOptedIn), wraps the response in the page writer, and wraps the proxy's writer in assetInformationalScrub on the remaining arms; the page reads are in the new pagecache.go units;rev3=census-ruling-region-ha-held-build;basis=first branch: a request for the reserved control paths /.carlos/ha-drain and /.carlos/ha-take goes to serveHAControl and returns (refused unless a signed ask); no request on those paths reaches a route, a forward or an app; no read added here. region HA held-requests Task 2: X-Carlos-Replayable is read from verified hops only and deleted from every request; just before frontForwardHA, moveGate runs for an HA hibernating route (route HA, Host and the whole Route passed in memory) and can only hold, refuse with an existing answer or front-forward to the confirmed holder; ReleaseMoveTicket before serveHeld; no store or filesystem read added; region HA held-requests Task 5: after the HA control-path branch, every request is counted by the connection drain (conns.track: a cancellable request context, and Connection: close only while draining); memory only; no read added; Task 5 fix 1: after the drain's final barrier a new request is refused at once through handoverExit with the existing answerHolderUnreachable, never forwarded; the tracked request also carries its connection (from ConnContext) so the drain can close it at its bound; memory only; no read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: the inbound strip also deletes tunnelclient.LinkAppHeader (Carlos-Link-App) from every client request, beside Carlos-Tunnel-Upgrade; a header delete, no read added; linked deployments slice 1 Task 8: a request carrying a link pin (ServeLinked, set only by the home agent's link handler from its own registry's published set) skips the edge's own handlers (HA control, demo handling, the steering probe, the tunnel hub, hop acceptance, the burst notice, the demo API alias, the replica probe), takes its upstream from selectUpstream (the pinned exact entry or a 502), never enters the alias/catch-all backhaul block, the HA front forward, the local asset catch, the page cache or the response LRU; the two lookupUpstreamPath calls become selectUpstream; no read added
+
+Seal: `b130b2d616e6476f056f4bd3dd5a5f64dd77aca49e95718ad6419ed0fd37f2d5` → `f8de0c7bd094ea95dc1ef1d8d7d56a4f00a326fd09114253004020c57ae0e9a3`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-static-site-geo-962.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/edge/assetcatch.go b/internal/edge/assetcatch.go
index 483b81946..40728a773 100644
--- a/internal/edge/assetcatch.go
+++ b/internal/edge/assetcatch.go
@@ -1046,6 +1046,14 @@ func (e *Edge) farAssetCatch(r *http.Request, host string) (a HostAssets, eip, b
if _, door := doorCallerFrom(r.Context()); door || hopVerified(r.Context()) {
return HostAssets{}, "", "", nil, false
}
+ // The visitor's country (geoanswer.go) is the home's answer, made from
+ // this edge's lookup carried on the hop, and never an asset, whatever
+ // prefix the app declared: a fill would drop the answer (runAssetFill
+ // sends geo off) and a stored copy would serve one visitor's country to
+ // the next.
+ if isGeoPath(r.URL.Path) {
+ return HostAssets{}, "", "", nil, false
+ }
m := e.homes.Load()
a, ok = m.AssetsFor(host, st.clock())
if !ok || !assetPrefixMatch(a.Paths, r.URL.Path) {
diff --git a/internal/edge/edge.go b/internal/edge/edge.go
index 4dc8cfe12..61a26efcd 100644
--- a/internal/edge/edge.go
+++ b/internal/edge/edge.go
@@ -2724,6 +2724,22 @@ func (e *Edge) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if !e.planDisabledAdmit(w, r, host, up.route) {
return
}
+ // The visitor's country for the site's own pages (geoanswer.go,
+ // discussion #962), answered by the box that serves the route, from the
+ // geo answer decided above. Here because everything that decides WHO
+ // serves the host has run: the backhaul and HA forwards (whose hop
+ // carries the ingress's answer), the door's scope, the import gate and a
+ // lapse's disabled page. And before everything that would treat it as
+ // the site's traffic: the meter and the observer (it is never billed,
+ // counted in analytics or filed as a request record, like the other
+ // answers the edge makes itself), the guard and the password gate (it
+ // says nothing about the site), and the asset catch, the page cache and
+ // the LRU, which never see it. A linked request is the pinned app's
+ // alone (ServeLinked) and goes on to it.
+ if !pinned && isGeoPath(r.URL.Path) {
+ serveGeoAnswer(w, r)
+ return
+ }
// Every proxied request to an instance route carries a page mark holder
// (pagemark.go), whatever its method: here, once the final upstream is
// settled (the login re-resolution, the door's scope), and before every
diff --git a/internal/edge/geoanswer.go b/internal/edge/geoanswer.go
new file mode 100644
index 000000000..6f5b487f7
--- /dev/null
+++ b/internal/edge/geoanswer.go
@@ -0,0 +1,87 @@
+package edge
+
+import (
+ "encoding/json"
+ "net/http"
+ "path"
+ "strconv"
+
+ "github.com/carlosframework/platform/internal/geoip"
+)
+
+// GeoPath is the visitor's country for a site's own pages (discussion #962).
+// A static site runs no code, so it never sees the X-Carlos-Geo-* headers an
+// app receives; its page script fetches this path instead, from its own
+// origin, and the edge answers it from the request's one geo answer
+// (geoip spec §8.1): the same lookup, the same trust in a hop or a tunnel,
+// and nothing when the deployment has no database.
+//
+// The path is the platform's, on every site this edge serves, beside
+// /.carlos/gate and the HA control paths: a site's own file or an app's own
+// route at it is never reached. Every spelling that cleans to it is the
+// edge's too (isGeoPath), so "/.carlos/geo/" cannot reach a directory the
+// site shipped there.
+const GeoPath = "/.carlos/geo"
+
+// isGeoPath reports whether a request path is GeoPath once cleaned: doubled
+// slashes, dot segments and a trailing slash resolve first, as the static
+// handler's own path.Clean would resolve them onto a file.
+func isGeoPath(p string) bool {
+ if p == "" {
+ return false
+ }
+ if p[0] != '/' {
+ p = "/" + p
+ }
+ return path.Clean(p) == GeoPath
+}
+
+// geoAnswerBody is the answer: the visitor's country as an ISO 3166-1 code,
+// and the database that placed it, which a page showing anything worked out
+// from it must credit, as the headers' Source. Both are null unless the
+// lookup placed the visitor in a country: no database, an address the
+// database cannot place, a door call and a hit with only a point all read
+// "unknown".
+func geoAnswerBody(a geoip.Answer) []byte {
+ var body struct {
+ Country *string `json:"country"`
+ Source *string `json:"source"`
+ }
+ if a.State == geoip.StateHit && a.Country != "" {
+ body.Country = &a.Country
+ if a.Source != "" {
+ body.Source = &a.Source
+ }
+ }
+ b, _ := json.Marshal(body) // two optional strings: cannot fail
+ return b
+}
+
+// serveGeoAnswer answers GeoPath. It is about the visitor, not the site, and
+// it is never stored: no-store, private and Vary: * keep it out of every
+// cache between here and the browser, and Edge.ServeHTTP answers it ahead of
+// the page cache, the asset catch and the response cache, which never see
+// it. It sets no cookie and keeps nothing. GET and HEAD only; any other
+// method is 405, never passed to the site.
+func serveGeoAnswer(w http.ResponseWriter, r *http.Request) {
+ h := w.Header()
+ h.Set("Cache-Control", "no-store, private")
+ h.Set("Vary", "*")
+ h.Set("X-Content-Type-Options", "nosniff")
+ if r.Method != http.MethodGet && r.Method != http.MethodHead {
+ h.Set("Allow", "GET, HEAD")
+ http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
+ return
+ }
+ a, ok := geoAnswerFrom(r.Context())
+ if !ok {
+ a = geoip.Off()
+ }
+ body := geoAnswerBody(a)
+ h.Set("Content-Type", "application/json")
+ h.Set("Content-Length", strconv.Itoa(len(body)))
+ w.WriteHeader(http.StatusOK)
+ if r.Method != http.MethodHead {
+ w.Write(body)
+ }
+}
diff --git a/internal/edge/geoanswer_test.go b/internal/edge/geoanswer_test.go
new file mode 100644
index 000000000..c3587040f
--- /dev/null
+++ b/internal/edge/geoanswer_test.go
@@ -0,0 +1,420 @@
+package edge
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "net"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "path/filepath"
+ "strings"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/assetcache"
+ "github.com/carlosframework/platform/internal/geo"
+ "github.com/carlosframework/platform/internal/geoip"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// The visitor's country for a site's own pages (discussion #962): every site
+// this edge serves answers GeoPath itself, from the request's one geo answer
+// (geoip spec §8.1), with nothing cached, counted or stored.
+
+const (
+ geoTestDB = "../geo/testdata/GeoIP2-City-Test.mmdb"
+ geoTestGB = "81.2.69.142" // GB in the MaxMind test database
+ geoGBAnswer = `{"country":"GB","source":"GeoIP2-City"}`
+ geoNull = `{"country":null,"source":null}`
+)
+
+// loadTestDB installs the MaxMind test database as e's reader, the way the
+// mirror's hot swap does.
+func loadTestDB(t *testing.T, e *Edge) {
+ t.Helper()
+ db, err := geo.OpenMMDB(geoTestDB)
+ if err != nil {
+ t.Fatal(err)
+ }
+ e.geo.Swap(db)
+}
+
+// geoAsk drives one request for target at e from the address from.
+func geoAsk(e *Edge, method, host, target, from string, hdr ...string) *httptest.ResponseRecorder {
+ r := httptest.NewRequest(method, "http://"+host+target, nil)
+ r.RemoteAddr = net.JoinHostPort(from, "4444")
+ for i := 0; i+1 < len(hdr); i += 2 {
+ r.Header.Set(hdr[i], hdr[i+1])
+ }
+ w := httptest.NewRecorder()
+ e.ServeHTTP(w, r)
+ return w
+}
+
+// wantGeoAnswer checks one answer: status, body and every header the answer
+// promises (no-store, private, Vary *, JSON, no cookie).
+func wantGeoAnswer(t *testing.T, what string, w *httptest.ResponseRecorder, body string) {
+ t.Helper()
+ if w.Code != http.StatusOK || w.Body.String() != body {
+ t.Fatalf("%s: %d %q, want 200 %q", what, w.Code, w.Body.String(), body)
+ }
+ wantGeoHeaders(t, what, w.Header(), len(body))
+}
+
+func wantGeoHeaders(t *testing.T, what string, h http.Header, n int) {
+ t.Helper()
+ for k, want := range map[string]string{
+ "Cache-Control": "no-store, private",
+ "Vary": "*",
+ "Content-Type": "application/json",
+ "X-Content-Type-Options": "nosniff",
+ "Content-Length": fmt.Sprint(n),
+ } {
+ if got := strings.Join(h.Values(k), ", "); got != want {
+ t.Errorf("%s: %s = %q, want %q", what, k, got, want)
+ }
+ }
+ if v := h.Values("Set-Cookie"); len(v) != 0 {
+ t.Errorf("%s: Set-Cookie %q", what, v)
+ }
+ if h.Get("X-Carlos-Version") != "" || h.Get("Carlos-Cache") != "" {
+ t.Errorf("%s: carried a site's headers: %v", what, h)
+ }
+}
+
+// countingApp is an app that counts every request that reaches it.
+func countingApp(t *testing.T) (*httptest.Server, *atomic.Int64) {
+ t.Helper()
+ var n atomic.Int64
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ n.Add(1)
+ w.Header().Set("Content-Type", "text/html; charset=utf-8")
+ io.WriteString(w, "<h1>the app</h1>")
+ }))
+ t.Cleanup(ts.Close)
+ return ts, &n
+}
+
+// geoAppEdge serves host (an app, kind kind) from a counting app.
+func geoAppEdge(t *testing.T, host, kind string) (*Edge, *atomic.Int64) {
+ t.Helper()
+ app, n := countingApp(t)
+ reg := openReg(t)
+ if err := reg.Upsert(registry.Route{Host: host, Kind: kind, Addr: app.Listener.Addr().String(), Status: "ready", App: "web"}); err != nil {
+ t.Fatal(err)
+ }
+ e, err := New(reg, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(e.probers.Stop)
+ return e, n
+}
+
+func TestIsGeoPath(t *testing.T) {
+ for p, want := range map[string]bool{
+ "/.carlos/geo": true,
+ "/.carlos/geo/": true,
+ "//.carlos/geo": true,
+ "/.carlos/./geo": true,
+ "/x/../.carlos/geo": true,
+ ".carlos/geo": true,
+ "/.carlos/geo/x": false,
+ "/.carlos/geography": false,
+ "/.carlos/": false,
+ "/.well-known/carlos/": false,
+ "/": false,
+ "": false,
+ } {
+ if got := isGeoPath(p); got != want {
+ t.Errorf("isGeoPath(%q) = %v, want %v", p, got, want)
+ }
+ }
+}
+
+// A static site, through the real wiring (EnableStatic, Reload, ServeHTTP)
+// and the real reader: the visitor's country, and the site's own file at the
+// path is never served.
+func TestGeoAnswerForAStaticSite(t *testing.T) {
+ storeRoot := filepath.Join(t.TempDir(), "store")
+ store := release.NewDirStore(storeRoot)
+ priv, pub := testKeys(t)
+ shipSite(t, store, "site", "v1", map[string]string{
+ "index.html": "home",
+ ".carlos/geo": `{"country":"KP"}`,
+ })
+ if err := release.Promote(context.Background(), store, priv, release.OpsAccount, "site", "canary/x", "v1"); err != nil {
+ t.Fatal(err)
+ }
+ reg := openReg(t)
+ if err := reg.Upsert(registry.Route{Host: "site.example.com", Kind: "static", App: "site", Channel: "canary/x", Status: "ready"}); err != nil {
+ t.Fatal(err)
+ }
+ e, err := New(reg, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(e.probers.Stop)
+ e.EnableStatic(store, pub, filepath.Join(t.TempDir(), "cache"))
+ if err := e.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ loadTestDB(t, e)
+
+ for _, p := range []string{"/.carlos/geo", "/.carlos/geo/", "//.carlos/geo", "/.carlos/geo?x=1"} {
+ wantGeoAnswer(t, "static "+p, geoAsk(e, "GET", "site.example.com", p, geoTestGB), geoGBAnswer)
+ }
+ // The site is still served beside it.
+ if w := geoAsk(e, "GET", "site.example.com", "/", geoTestGB); w.Code != 200 || w.Body.String() != "home" {
+ t.Fatalf("the site's own page = %d %q", w.Code, w.Body.String())
+ }
+}
+
+// An app site: the same answer, and the app never sees the request, whatever
+// the visitor forged.
+func TestGeoAnswerForAnAppSite(t *testing.T) {
+ for _, kind := range []string{"service", "instance"} {
+ e, n := geoAppEdge(t, "app.test", kind)
+ loadTestDB(t, e)
+ wantGeoAnswer(t, kind, geoAsk(e, "GET", "app.test", GeoPath, geoTestGB,
+ geoip.HeaderCountry, "KP", geoip.HeaderSource, "forged", geoip.HeaderHop, "hit;src=forged"), geoGBAnswer)
+ if n.Load() != 0 {
+ t.Fatalf("%s: the app saw %d requests for the geo path", kind, n.Load())
+ }
+ // The app still serves everything else.
+ if w := geoAsk(e, "GET", "app.test", "/", geoTestGB); w.Code != 200 || n.Load() != 1 {
+ t.Fatalf("%s: the app's page = %d, app requests %d", kind, w.Code, n.Load())
+ }
+ }
+}
+
+// Geo is off when the deployment has no database, and unknown when the
+// database cannot place the address: both answer null, never a forged value.
+func TestGeoAnswerIsNullWhenGeoIsOffOrUnknown(t *testing.T) {
+ e, _ := geoAppEdge(t, "app.test", "service")
+ wantGeoAnswer(t, "no database", geoAsk(e, "GET", "app.test", GeoPath, geoTestGB, geoip.HeaderCountry, "KP"), geoNull)
+
+ loadTestDB(t, e)
+ wantGeoAnswer(t, "unplaced address", geoAsk(e, "GET", "app.test", GeoPath, "192.0.2.1", geoip.HeaderCountry, "KP"), geoNull)
+
+ // A hit with only a point and no country: still no country.
+ e.geoLookup = func(net.IP) geo.Snapshot {
+ return geo.Snapshot{Loaded: true, Found: true, Source: "TestDB", Result: geo.Result{Point: geo.Point{Lat: 1, Lon: 2}, HasPoint: true}}
+ }
+ wantGeoAnswer(t, "point only", geoAsk(e, "GET", "app.test", GeoPath, geoTestGB), geoNull)
+}
+
+// GET and HEAD only; HEAD has the GET's headers and no body; anything else is
+// 405 and never reaches the app.
+func TestGeoAnswerMethods(t *testing.T) {
+ e, n := geoAppEdge(t, "app.test", "service")
+ loadTestDB(t, e)
+ head := geoAsk(e, "HEAD", "app.test", GeoPath, geoTestGB)
+ if head.Code != 200 || head.Body.Len() != 0 {
+ t.Fatalf("HEAD = %d %q", head.Code, head.Body.String())
+ }
+ wantGeoHeaders(t, "HEAD", head.Header(), len(geoGBAnswer))
+ for _, m := range []string{"POST", "PUT", "DELETE", "OPTIONS"} {
+ w := geoAsk(e, m, "app.test", GeoPath, geoTestGB)
+ if w.Code != http.StatusMethodNotAllowed || w.Header().Get("Allow") != "GET, HEAD" ||
+ w.Header().Get("Cache-Control") != "no-store, private" {
+ t.Fatalf("%s = %d Allow %q Cache-Control %q", m, w.Code, w.Header().Get("Allow"), w.Header().Get("Cache-Control"))
+ }
+ }
+ if n.Load() != 0 {
+ t.Fatalf("the app saw %d requests", n.Load())
+ }
+}
+
+// Nothing stores it: on an instance opted into the page cache, with the LRU
+// and the asset cache armed and the site declaring /.carlos/ as an asset
+// path, three asks reach no app and leave every store empty.
+func TestGeoAnswerIsNeverCached(t *testing.T) {
+ s := newPCScene(t, pageOK(pcBody))
+ s.decl.decls[pcDeclKey("abc", "blog", pcBuild)] = []string{"/.carlos/", "/assets/"}
+ loadTestDB(t, s.e)
+ // Opt the instance in, as a marked page does.
+ wantCache(t, s.get("/p"), "miss")
+ if !s.idx.OptedIn(s.scope()) {
+ t.Fatal("precondition: the instance is not opted in")
+ }
+ before := s.b.n.Load()
+ pagesBefore := s.pages()
+ for i := 0; i < 3; i++ {
+ r := httptest.NewRequest("GET", "http://"+pcHost+GeoPath, nil)
+ r.RemoteAddr = net.JoinHostPort(geoTestGB, "4444")
+ w := httptest.NewRecorder()
+ s.e.ServeHTTP(w, r)
+ wantGeoAnswer(t, fmt.Sprintf("ask %d", i), w, geoGBAnswer)
+ }
+ if n := s.b.n.Load() - before; n != 0 {
+ t.Fatalf("the app saw %d geo asks", n)
+ }
+ if n := s.pages(); n != pagesBefore {
+ t.Fatalf("pages stored %d -> %d", pagesBefore, n)
+ }
+ n := 0
+ s.store.Retain(func(k assetcache.Key) bool {
+ if strings.HasPrefix(k.Path, "/.carlos/") {
+ n++
+ }
+ return true
+ })
+ if n != 0 || s.store.Stats().Reserved != 0 {
+ t.Fatalf("the asset store holds %d geo entries, %d bytes reserved", n, s.store.Stats().Reserved)
+ }
+
+ // A service route with the LRU on: nothing stored either.
+ e, _ := geoAppEdge(t, "app.test", "service")
+ e.EnableCache(NewCache(DefaultCacheMaxEntries, DefaultCacheMaxBodyBytes))
+ loadTestDB(t, e)
+ wantGeoAnswer(t, "lru", geoAsk(e, "GET", "app.test", GeoPath, geoTestGB), geoGBAnswer)
+ if cachedVariants(e, "app.test", GeoPath) != 0 {
+ t.Fatal("the LRU stored the geo answer")
+ }
+}
+
+// Not counted: like the other answers the edge makes itself (the load
+// balancer health, the steering probe, the HA control paths), it is never
+// metered, counted in analytics or filed as a request record.
+func TestGeoAnswerIsNotCountedOrMetered(t *testing.T) {
+ e, _ := geoAppEdge(t, "app.test", "service")
+ loadTestDB(t, e)
+ m := &memAnalytics{}
+ e.EnableAnalytics(m)
+ e.SetAnalyticsOn(map[string]bool{release.OpsAccount + "/web": true})
+ meter := NewUsageMeter()
+ e.EnableUsage(meter)
+ wantGeoAnswer(t, "geo", geoAsk(e, "GET", "app.test", GeoPath, geoTestGB), geoGBAnswer)
+ if obs := m.snap(); len(obs) != 0 {
+ t.Fatalf("analytics observed %+v", obs)
+ }
+ if row, ok := meter.Drain().Rows["app.test"]; ok {
+ t.Fatalf("the meter billed %+v", row)
+ }
+ // The wiring is live: a page is counted.
+ geoAsk(e, "GET", "app.test", "/", geoTestGB)
+ if len(m.snap()) != 1 {
+ t.Fatalf("a page was observed %d times, want 1", len(m.snap()))
+ }
+}
+
+// A custom domain (a route_aliases row) gets the same answer.
+func TestGeoAnswerOnACustomDomain(t *testing.T) {
+ app, n := countingApp(t)
+ reg := openReg(t)
+ if err := reg.Upsert(registry.Route{Host: "app.acct.oncarlos.com", Kind: "service", Addr: app.Listener.Addr().String(), Status: "ready"}); err != nil {
+ t.Fatal(err)
+ }
+ upsertAlias(t, reg, "www.customer.example", "app.acct.oncarlos.com")
+ e, err := New(reg, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(e.probers.Stop)
+ loadTestDB(t, e)
+ wantGeoAnswer(t, "alias", geoAsk(e, "GET", "www.customer.example", GeoPath, geoTestGB), geoGBAnswer)
+ if n.Load() != 0 {
+ t.Fatal("the app saw the geo ask")
+ }
+}
+
+// A host this box does not serve: the ingress backhauls it to the home,
+// which answers with the INGRESS's lookup, carried on the hop (spec §8.2).
+func TestGeoAnswerThroughABackhaul(t *testing.T) {
+ s := newBackhaulScene(t)
+ s.converge(t)
+ homeSpy, senderSpy := spyGeo(s.a.edge, "XX"), spyGeo(s.b.edge, "IE")
+ resp, body := s.get(t, s.b, "https://"+e2eHomedHost+GeoPath, nil, true)
+ if resp.StatusCode != 200 || body != `{"country":"IE","source":"TestDB-IE"}` {
+ t.Fatalf("backhauled geo = %d %q", resp.StatusCode, body)
+ }
+ if got := resp.Header.Get("Cache-Control"); got != "no-store, private" {
+ t.Fatalf("Cache-Control = %q", got)
+ }
+ if homeSpy.Load() != 0 || senderSpy.Load() != 1 {
+ t.Fatalf("lookups home=%d sender=%d, want 0 and 1", homeSpy.Load(), senderSpy.Load())
+ }
+}
+
+// The far asset catch never takes the geo path, even under a declared
+// /.carlos/ prefix: it is backhauled plainly, carrying the ingress's answer,
+// and nothing is stored on the far box.
+func TestGeoAnswerIsNeverAFarAsset(t *testing.T) {
+ s := newFarScene(t, assetOK(laBody))
+ putJSON(t, s.m.s, "control/edges/betty.json", fmt.Sprintf(
+ `{"v":1,"box":"betty","eip":%q,"hosts":{%q:{"role":"home","account":"abc","app":"shop",`+
+ `"assets":{"paths":["/.carlos/"],"gen":%q,"at":%d,"primary":%q}}}}`,
+ s.eip, laHost, laGen, time.Now().Unix(), laHost))
+ refreshHomeMap(t, s.m)
+ // Precondition: the catch is live for the declared prefix.
+ wantCache(t, s.get(t, "/.carlos/app.js"), "miss")
+ before := s.rec.get().n
+
+ rec := s.get(t, GeoPath)
+ if rec.Header().Get("Carlos-Cache") != "" {
+ t.Fatalf("the far catch answered the geo path: Carlos-Cache %q", rec.Header().Get("Carlos-Cache"))
+ }
+ seen := s.rec.get()
+ if seen.n != before+1 || seen.fill != "" {
+ t.Fatalf("the home saw %d more requests (fill %q), want one plain backhaul", seen.n-before, seen.fill)
+ }
+ if _, ok := s.store.Get(s.key(GeoPath)); ok {
+ t.Fatal("the far store holds the geo path")
+ }
+}
+
+// A tunnel hub (a fleet's public edge) answers for a route it sends down a
+// tunnel, from its own lookup; the remote box never sees the request.
+func TestGeoAnswerAtATunnelHub(t *testing.T) {
+ hubReg := tunnelRoute(t, registry.Route{Host: "demo.example", Kind: "instance", Status: "ready", Tunnel: "pi-box"})
+ hub, err := New(hubReg, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(hub.probers.Stop)
+ srv := httptest.NewServer(hub)
+ t.Cleanup(srv.Close)
+ u, _ := url.Parse(srv.URL)
+ th := NewTunnelHub(u.Hostname(), map[string]string{"pi-box": "sekrit"})
+ hub.EnableTunnels(th)
+ if err := hub.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ remote, remoteN := geoAppEdge(t, "demo.example", "service")
+ stop := startFakeRemoteHost(t, srv.URL, "pi-box", "sekrit", remote)
+ t.Cleanup(stop)
+ waitForTunnelState(t, th, "pi-box", "connected", e2eReconnectBound)
+ hubSpy, remoteSpy := spyGeo(hub, "FR"), spyGeo(remote, "XX")
+
+ req, _ := http.NewRequest("GET", srv.URL+GeoPath, nil)
+ req.Host = "demo.example"
+ resp, err := http.DefaultClient.Do(req)
+ if err != nil {
+ t.Fatal(err)
+ }
+ b, _ := io.ReadAll(resp.Body)
+ resp.Body.Close()
+ if resp.StatusCode != 200 || string(b) != `{"country":"FR","source":"TestDB-FR"}` {
+ t.Fatalf("hub geo = %d %q", resp.StatusCode, b)
+ }
+ if hubSpy.Load() != 1 || remoteSpy.Load() != 0 || remoteN.Load() != 0 {
+ t.Fatalf("lookups hub=%d remote=%d, remote app requests %d", hubSpy.Load(), remoteSpy.Load(), remoteN.Load())
+ }
+}
+
+// A door caller is the platform itself, not a visitor: null, as the headers
+// are absent on a door call.
+func TestGeoAnswerForADoorCallerIsNull(t *testing.T) {
+ s := newDoorScene(t)
+ spy := spyGeo(s.e, "GB")
+ rec := s.do(t, "GET", doorOwnHost, GeoPath, s.key, nil, nil)
+ wantGeoAnswer(t, "door", rec, geoNull)
+ if spy.Load() != 0 {
+ t.Fatal("a door call was looked up")
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 0362759c8..53fda9c0e 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -177,3 +177,4 @@ plan14-root-reads-member-backups-1.tsv b3d35a0bd7c0500c74efbe5e8f566adb623696d31
plan14-root-reads-gvisor-empty-execstart.tsv 44b11f63c98595a70e62124034bdf5185c5a58561e99e3e269141557cf13880f
plan14-root-reads-demo-referrer-same-origin.tsv 44b11f63c98595a70e62124034bdf5185c5a58561e99e3e269141557cf13880f
plan14-root-reads-member-backups-2a.tsv b130b2d616e6476f056f4bd3dd5a5f64dd77aca49e95718ad6419ed0fd37f2d5
+plan14-root-reads-static-site-geo-962.tsv f8de0c7bd094ea95dc1ef1d8d7d56a4f00a326fd09114253004020c57ae0e9a3
diff --git a/internal/provision/testdata/plan14-root-reads-static-site-geo-962.tsv b/internal/provision/testdata/plan14-root-reads-static-site-geo-962.tsv
new file mode 100644
index 000000000..30d1d5874
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-static-site-geo-962.tsv
@@ -0,0 +1,5 @@
+# Census overlay static-site-geo-962, written by census-propose (#369). census-ruling-static-site-geo-962, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-static-site-geo-962.md.
+# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy 8fc2d1b7428a808e4e3dab84e8b212f3d9dcdb778bec9bebe3bd406701eedd0b internal/edge/edge.go Edge.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.;rev3=census-ruling-plans-4d-lapse;basis=calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here.;rev3=census-ruling-edge-protection-2;basis=runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read;rev3=census-ruling-edge-asset-cache-3;basis=the asset cache's three hooks (asset cache plan 3): the request's reserved asset headers are deleted at entry (the fill assertion kept only beside a verified hop); on the exact-remote and lookup-miss branches the far catch (serveAssetFar) is tried before backhaulTo and backhaul; after the observer defer and main's hard and probe checks, a verified hop with a valid fill assertion is answered by serveAssetFillForHop; after the upgrade branch and before gzip and the shared cache, the local catch (serveAssetLocal); the observer defer skips only the usage meter for an acknowledged home fill (out.unbilled); the new reads live in the new units of the edge-asset-cache-3-decisions overlay; the same route row and read sites (25); no read added;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: straight after lookupUpstreamPath it calls regionalGate (regional.go), which for an entry built from a regional_domains row answers 503 to a hop or a deny entry before any arm that can leave the box (the exact-home backhaul, the far asset catch, the door dial, the miss backhaul), and lets a star match through only to the exact-home arm when ExactHome names another box for that distinct exact name; after the exact-home arm a regional deny entry the arm did not answer is refused (regionalRefuse, 503); refusals only, on the route map the edge already holds; read sites unchanged (25);rev3=census-ruling-static-headers;basis=the shared response cache is no longer looked up or filled for a static-kind route: one more read of the route row the edge already resolved (up.route.Kind == "static") in the cacheable expression; a refusal only, nothing new opened or followed;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2 (N-HA10): one call, frontForwardHA, right after the route lookup's !ok block and before the login POST; same reads;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 4: loginPost and cacheable treat a forward row as not this box's to answer (IsForward(), +whole:Route x2): no login form and no shared cache for a forward host. Serving only.;rev3=census-ruling-tunnel-websockets;basis=Deletes the Carlos-Upgrade marker header from incoming requests and puts the upgrade admission (host, path, the entry tenancy, all in hand) on a tunnel arm request. For a login POST on an ungated ArmTunnel row it reads the visitor request body (bounded by gate.MaxFormBody, 413 past it; a request body, not a file) and resolves next against the entry Reload built (Gate, Route); the bytes pass on only when loginPassesThrough holds (spec 7, Tasks 3, 5 and 6).;rev3=census-ruling-console-protection-tab;basis=one more call in the observer defer, observeGuardCount(up.route, out), beside the observeRecords call that files the guard Match: it passes on the route row the defer already holds (+whole:Route) and the request outcome to the usage meter, which counts the check in memory. Called whether or not the request was unbilled, as observeRecords is. Nothing is opened, read or followed; no new kind of read; no check, refusal or serving decision changes.;rev3=census-ruling-probe-burst-limit;basis=answers a probe-burst notice POST (serveBurstNotice) ahead of every route for a non-door caller; builds the guard state for up.route and stamps its account and app (RouteAccount, App) for the cool-down's this-app/other-app label; for a catalogue match on a non-static or tunnelled route, offers the burst rule (in-memory limiter, burstDecide: 429 or a watch verdict, never a block for a fleet or forward row); the observer defer calls noteBurst(up.route, ...); the added sites are the route value already in hand (+registry:App, +whole:Route x5); no new root read or write kind;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): parses the request's query once (stripHoldMarker) to record the carlos_hold=1 mark in the request context; calls classifyHold on the upstream already resolved from the loaded map (the +whole:Route is that in-memory Route), including a second pass for a login POST; gives a marked request on a door-refused route the plain 404; adds the hold branch (planThrottleAdmit, rateAdmit, serveHeld) after the gate; and excludes marked requests from the shared cache. Reads only the request and the already-loaded upstream map; no registry or bucket read added.;rev3=census-ruling-region-ha-p3a;basis=Complete the P3a cut: an exact peer name with no dial target answers the approved admission 503 before local wildcard dispatch or asset serving. ExactHome and lookupHome stop fallback at a present non-dial entry; backhaulTo refuses an empty target before signing or dialing. Retain Task 3 local admission and fixed platform/unit exemptions. Two added whole Route uses feed the local in-memory admission predicate; existing Route values and store/path reads are unchanged.;rev3=census-ruling-stateless-coordinator-route;basis=P24/P25: POST only, exact /api/fleet/replicas/ prefix on the reserved tunnel host calls the existing local console proxy only for an unescaped, already-clean path; malformed forms remain on the hub. No new read sites relative to origin/main. Merge with main 3487d6f6 retains its region HA admission checks before routing and after login target lookup, its empty-home refusal, and their two existing whole:Route reads; these change this unit's digest relative to the previously approved branch tip 92b24a7d.;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: pass the already-resolved Route to the reserved replica-probe handler after acceptHop and existing admissionRefuses, requiring tunnel context plus private marker and refusing door/backhaul ingress. Added whole Route use only; scrub marker before forwarding; HA calls remain unchanged.;rev3=census-ruling-region-ha-p3b;basis=Resolve local aliases/catch-alls with cached peer name ownership before serving. Add registry Account/App/ClaimStamp/Host/Incarnation/ServingSeq and six whole Route references for NameClaim; inputs are agent registry rows/edges publications used by unprivileged edge, not root permits. Closed owners retain names and return 503; aware remote owner cannot fall through on missing transport, while legacy hop/door behavior remains. Merge 45cebde4 retains authenticated replica probes after local admission and before ordinary name resolution; probe authentication still requires the tunnel context.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1901 enters the protected demo path before ordinary exits; :2012-2015 rechecks the selected marked Route after lookup. Added whole Route use routes demos through serving checks, counters and policy; no new registry query or file open in this unit.;rev3=census-ruling-demo-api-site-route;basis=Reserve the configured site API namespace after hop verification and control-header scrubbing, before ordinary static, cache, billing and tenant dispatch. Validate hop field shape and delegate only allowlisted operations to the dedicated console path with verified client attribution and console admission. The alias helper enables HTTP/1.1 full duplex so an early console refusal does not wait for upload EOF. Existing 56 read sites unchanged; no new registry, bucket or file read.;rev3=census-ruling-region-ha-g2-fixes;basis=Consult HA ingress after region admission and before miss/alias backhaul; no new direct read; routing-only metadata does not create an upstream.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3/W4: backhaul and door calls pass the owner the door checked into backhaulTo; the §6.5 holder follow (once, GET/HEAD or an unswitched upgrade, no body) and one connect-failure fallback dial only boxes in the holder region's view (same Region/Placement/DataBucket, HomeEligible, fresh) for that owner. Holder name comes only from the TLS-verified signed hop answer; app-set X-Carlos-Holder stays stripped. Routing only; the receiving box still re-checks the lease. No new read site.;rev3=census-ruling-edge-page-cache-1;basis=attaches an in-memory page mark holder to every request to an instance route (the +registry:Kind check of up.route.Kind), wraps the hold and upgrade branches in pageDiagnostics, asks servePage after the plan throttle (a hit answered from the page index over the asset store), keeps an opted-in instance out of the LRU (pagesOptedIn), wraps the response in the page writer, and wraps the proxy's writer in assetInformationalScrub on the remaining arms; the page reads are in the new pagecache.go units;rev3=census-ruling-region-ha-held-build;basis=first branch: a request for the reserved control paths /.carlos/ha-drain and /.carlos/ha-take goes to serveHAControl and returns (refused unless a signed ask); no request on those paths reaches a route, a forward or an app; no read added here. region HA held-requests Task 2: X-Carlos-Replayable is read from verified hops only and deleted from every request; just before frontForwardHA, moveGate runs for an HA hibernating route (route HA, Host and the whole Route passed in memory) and can only hold, refuse with an existing answer or front-forward to the confirmed holder; ReleaseMoveTicket before serveHeld; no store or filesystem read added; region HA held-requests Task 5: after the HA control-path branch, every request is counted by the connection drain (conns.track: a cancellable request context, and Connection: close only while draining); memory only; no read added; Task 5 fix 1: after the drain's final barrier a new request is refused at once through handoverExit with the existing answerHolderUnreachable, never forwarded; the tracked request also carries its connection (from ConnContext) so the drain can close it at its bound; memory only; no read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: the inbound strip also deletes tunnelclient.LinkAppHeader (Carlos-Link-App) from every client request, beside Carlos-Tunnel-Upgrade; a header delete, no read added; linked deployments slice 1 Task 8: a request carrying a link pin (ServeLinked, set only by the home agent's link handler from its own registry's published set) skips the edge's own handlers (HA control, demo handling, the steering probe, the tunnel hub, hop acceptance, the burst notice, the demo API alias, the replica probe), takes its upstream from selectUpstream (the pinned exact entry or a 502), never enters the alias/catch-all backhaul block, the HA front forward, the local asset catch, the page cache or the response LRU; the two lookupUpstreamPath calls become selectUpstream; no read added;rev3=census-ruling-static-site-geo-962;basis=discussion #962: after planDisabledAdmit and before the page mark holder and the observer, a request whose cleaned path is /.carlos/geo (not a linked request) is answered by serveGeoAnswer from the request's geo answer already on the context (decideGeo), 200 JSON no-store or 405, and returns; no store, registry or file read added; read sites unchanged file:ReadAll@19701,registry:Account@10586,registry:App@10610,registry:App@27496,registry:ClaimStamp@10640,registry:Gate@18675,registry:Gate@31887,registry:Gate@31947,registry:Gate@32005,registry:HA@14410,registry:HA@14752,registry:Host@10817,registry:Host@14791,registry:Host@31990,registry:ImportGate@40841,registry:Incarnation@10675,registry:Kind@24530,registry:Kind@26358,registry:Kind@29796,registry:Kind@40783,registry:Kind@40812,registry:ServingSeq@10709,whole:Route@10589,whole:Route@10613,whole:Route@10643,whole:Route@10678,whole:Route@10712,whole:Route@10820,whole:Route@14413,whole:Route@14507,whole:Route@14755,whole:Route@14794,whole:Route@18570,whole:Route@18681,whole:Route@21498,whole:Route@22282,whole:Route@22740,whole:Route@22932,whole:Route@24533,whole:Route@26361,whole:Route@27422,whole:Route@27488,whole:Route@27499,whole:Route@27752,whole:Route@27847,whole:Route@27923,whole:Route@27967,whole:Route@28269,whole:Route@28299,whole:Route@29799,whole:Route@30084,whole:Route@31890,whole:Route@31950,whole:Route@31993,whole:Route@32008,whole:Route@33219,whole:Route@35507,whole:Route@40786,whole:Route@40815,whole:Route@40844,whole:Route@40876,whole:Route@43321,whole:Route@8418,whole:Route@8517,whole:Route@8623 d68f21252b234969203735ffdd9a4340186b2fbe5710b05bf587eea4e89d7fe0
+internal/edge/edge.go Edge.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.;rev3=census-ruling-plans-4d-lapse;basis=calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here.;rev3=census-ruling-edge-protection-2;basis=runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read;rev3=census-ruling-edge-asset-cache-3;basis=the asset cache's three hooks (asset cache plan 3): the request's reserved asset headers are deleted at entry (the fill assertion kept only beside a verified hop); on the exact-remote and lookup-miss branches the far catch (serveAssetFar) is tried before backhaulTo and backhaul; after the observer defer and main's hard and probe checks, a verified hop with a valid fill assertion is answered by serveAssetFillForHop; after the upgrade branch and before gzip and the shared cache, the local catch (serveAssetLocal); the observer defer skips only the usage meter for an acknowledged home fill (out.unbilled); the new reads live in the new units of the edge-asset-cache-3-decisions overlay; the same route row and read sites (25); no read added;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: straight after lookupUpstreamPath it calls regionalGate (regional.go), which for an entry built from a regional_domains row answers 503 to a hop or a deny entry before any arm that can leave the box (the exact-home backhaul, the far asset catch, the door dial, the miss backhaul), and lets a star match through only to the exact-home arm when ExactHome names another box for that distinct exact name; after the exact-home arm a regional deny entry the arm did not answer is refused (regionalRefuse, 503); refusals only, on the route map the edge already holds; read sites unchanged (25);rev3=census-ruling-static-headers;basis=the shared response cache is no longer looked up or filled for a static-kind route: one more read of the route row the edge already resolved (up.route.Kind == "static") in the cacheable expression; a refusal only, nothing new opened or followed;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2 (N-HA10): one call, frontForwardHA, right after the route lookup's !ok block and before the login POST; same reads;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 4: loginPost and cacheable treat a forward row as not this box's to answer (IsForward(), +whole:Route x2): no login form and no shared cache for a forward host. Serving only.;rev3=census-ruling-tunnel-websockets;basis=Deletes the Carlos-Upgrade marker header from incoming requests and puts the upgrade admission (host, path, the entry tenancy, all in hand) on a tunnel arm request. For a login POST on an ungated ArmTunnel row it reads the visitor request body (bounded by gate.MaxFormBody, 413 past it; a request body, not a file) and resolves next against the entry Reload built (Gate, Route); the bytes pass on only when loginPassesThrough holds (spec 7, Tasks 3, 5 and 6).;rev3=census-ruling-console-protection-tab;basis=one more call in the observer defer, observeGuardCount(up.route, out), beside the observeRecords call that files the guard Match: it passes on the route row the defer already holds (+whole:Route) and the request outcome to the usage meter, which counts the check in memory. Called whether or not the request was unbilled, as observeRecords is. Nothing is opened, read or followed; no new kind of read; no check, refusal or serving decision changes.;rev3=census-ruling-probe-burst-limit;basis=answers a probe-burst notice POST (serveBurstNotice) ahead of every route for a non-door caller; builds the guard state for up.route and stamps its account and app (RouteAccount, App) for the cool-down's this-app/other-app label; for a catalogue match on a non-static or tunnelled route, offers the burst rule (in-memory limiter, burstDecide: 429 or a watch verdict, never a block for a fleet or forward row); the observer defer calls noteBurst(up.route, ...); the added sites are the route value already in hand (+registry:App, +whole:Route x5); no new root read or write kind;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): parses the request's query once (stripHoldMarker) to record the carlos_hold=1 mark in the request context; calls classifyHold on the upstream already resolved from the loaded map (the +whole:Route is that in-memory Route), including a second pass for a login POST; gives a marked request on a door-refused route the plain 404; adds the hold branch (planThrottleAdmit, rateAdmit, serveHeld) after the gate; and excludes marked requests from the shared cache. Reads only the request and the already-loaded upstream map; no registry or bucket read added.;rev3=census-ruling-region-ha-p3a;basis=Complete the P3a cut: an exact peer name with no dial target answers the approved admission 503 before local wildcard dispatch or asset serving. ExactHome and lookupHome stop fallback at a present non-dial entry; backhaulTo refuses an empty target before signing or dialing. Retain Task 3 local admission and fixed platform/unit exemptions. Two added whole Route uses feed the local in-memory admission predicate; existing Route values and store/path reads are unchanged.;rev3=census-ruling-stateless-coordinator-route;basis=P24/P25: POST only, exact /api/fleet/replicas/ prefix on the reserved tunnel host calls the existing local console proxy only for an unescaped, already-clean path; malformed forms remain on the hub. No new read sites relative to origin/main. Merge with main 3487d6f6 retains its region HA admission checks before routing and after login target lookup, its empty-home refusal, and their two existing whole:Route reads; these change this unit's digest relative to the previously approved branch tip 92b24a7d.;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: pass the already-resolved Route to the reserved replica-probe handler after acceptHop and existing admissionRefuses, requiring tunnel context plus private marker and refusing door/backhaul ingress. Added whole Route use only; scrub marker before forwarding; HA calls remain unchanged.;rev3=census-ruling-region-ha-p3b;basis=Resolve local aliases/catch-alls with cached peer name ownership before serving. Add registry Account/App/ClaimStamp/Host/Incarnation/ServingSeq and six whole Route references for NameClaim; inputs are agent registry rows/edges publications used by unprivileged edge, not root permits. Closed owners retain names and return 503; aware remote owner cannot fall through on missing transport, while legacy hop/door behavior remains. Merge 45cebde4 retains authenticated replica probes after local admission and before ordinary name resolution; probe authentication still requires the tunnel context.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1901 enters the protected demo path before ordinary exits; :2012-2015 rechecks the selected marked Route after lookup. Added whole Route use routes demos through serving checks, counters and policy; no new registry query or file open in this unit.;rev3=census-ruling-demo-api-site-route;basis=Reserve the configured site API namespace after hop verification and control-header scrubbing, before ordinary static, cache, billing and tenant dispatch. Validate hop field shape and delegate only allowlisted operations to the dedicated console path with verified client attribution and console admission. The alias helper enables HTTP/1.1 full duplex so an early console refusal does not wait for upload EOF. Existing 56 read sites unchanged; no new registry, bucket or file read.;rev3=census-ruling-region-ha-g2-fixes;basis=Consult HA ingress after region admission and before miss/alias backhaul; no new direct read; routing-only metadata does not create an upstream.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3/W4: backhaul and door calls pass the owner the door checked into backhaulTo; the §6.5 holder follow (once, GET/HEAD or an unswitched upgrade, no body) and one connect-failure fallback dial only boxes in the holder region's view (same Region/Placement/DataBucket, HomeEligible, fresh) for that owner. Holder name comes only from the TLS-verified signed hop answer; app-set X-Carlos-Holder stays stripped. Routing only; the receiving box still re-checks the lease. No new read site.;rev3=census-ruling-edge-page-cache-1;basis=attaches an in-memory page mark holder to every request to an instance route (the +registry:Kind check of up.route.Kind), wraps the hold and upgrade branches in pageDiagnostics, asks servePage after the plan throttle (a hit answered from the page index over the asset store), keeps an opted-in instance out of the LRU (pagesOptedIn), wraps the response in the page writer, and wraps the proxy's writer in assetInformationalScrub on the remaining arms; the page reads are in the new pagecache.go units;rev3=census-ruling-region-ha-held-build;basis=first branch: a request for the reserved control paths /.carlos/ha-drain and /.carlos/ha-take goes to serveHAControl and returns (refused unless a signed ask); no request on those paths reaches a route, a forward or an app; no read added here. region HA held-requests Task 2: X-Carlos-Replayable is read from verified hops only and deleted from every request; just before frontForwardHA, moveGate runs for an HA hibernating route (route HA, Host and the whole Route passed in memory) and can only hold, refuse with an existing answer or front-forward to the confirmed holder; ReleaseMoveTicket before serveHeld; no store or filesystem read added; region HA held-requests Task 5: after the HA control-path branch, every request is counted by the connection drain (conns.track: a cancellable request context, and Connection: close only while draining); memory only; no read added; Task 5 fix 1: after the drain's final barrier a new request is refused at once through handoverExit with the existing answerHolderUnreachable, never forwarded; the tracked request also carries its connection (from ConnContext) so the drain can close it at its bound; memory only; no read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: the inbound strip also deletes tunnelclient.LinkAppHeader (Carlos-Link-App) from every client request, beside Carlos-Tunnel-Upgrade; a header delete, no read added; linked deployments slice 1 Task 8: a request carrying a link pin (ServeLinked, set only by the home agent's link handler from its own registry's published set) skips the edge's own handlers (HA control, demo handling, the steering probe, the tunnel hub, hop acceptance, the burst notice, the demo API alias, the replica probe), takes its upstream from selectUpstream (the pinned exact entry or a 502), never enters the alias/catch-all backhaul block, the HA front forward, the local asset catch, the page cache or the response LRU; the two lookupUpstreamPath calls become selectUpstream; no read added;rev3=census-ruling-static-site-geo-962;basis=discussion #962: after planDisabledAdmit and before the page mark holder and the observer, a request whose cleaned path is /.carlos/geo (not a linked request) is answered by serveGeoAnswer from the request's geo answer already on the context (decideGeo), 200 JSON no-store or 405, and returns; no store, registry or file read added; read sites unchanged file:ReadAll@19701,registry:Account@10586,registry:App@10610,registry:App@27496,registry:ClaimStamp@10640,registry:Gate@18675,registry:Gate@31887,registry:Gate@31947,registry:Gate@32005,registry:HA@14410,registry:HA@14752,registry:Host@10817,registry:Host@14791,registry:Host@31990,registry:ImportGate@40841,registry:Incarnation@10675,registry:Kind@24530,registry:Kind@26358,registry:Kind@29796,registry:Kind@40783,registry:Kind@40812,registry:ServingSeq@10709,whole:Route@10589,whole:Route@10613,whole:Route@10643,whole:Route@10678,whole:Route@10712,whole:Route@10820,whole:Route@14413,whole:Route@14507,whole:Route@14755,whole:Route@14794,whole:Route@18570,whole:Route@18681,whole:Route@21498,whole:Route@22282,whole:Route@22740,whole:Route@22932,whole:Route@24533,whole:Route@26361,whole:Route@27422,whole:Route@27488,whole:Route@27499,whole:Route@27752,whole:Route@27847,whole:Route@27923,whole:Route@27967,whole:Route@28269,whole:Route@28299,whole:Route@29799,whole:Route@30084,whole:Route@31890,whole:Route@31950,whole:Route@31993,whole:Route@32008,whole:Route@33219,whole:Route@35507,whole:Route@40786,whole:Route@40815,whole:Route@40844,whole:Route@40876,whole:Route@43321,whole:Route@8418,whole:Route@8517,whole:Route@8623 d68f21252b234969203735ffdd9a4340186b2fbe5710b05bf587eea4e89d7fe0
+@coverage internal/edge b58e2851c1e5aba3f3bd0022da7f3b8b79146b418504656f32a2e09f2d2d4818