edge: static pages read the visitor's country from /.carlos/geo (#962)
Every site answers GET /.carlos/geo with {country, source} from the
same lookup as the X-Carlos-Geo-* headers; no-store, no cookie, not
counted. Docs copy approved by Paul. Astra R1 NOT READY (fixed), R2
READY AFTER FIXES (fixed); census approved on #280.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Squashed from static-site-geo-962 into main.
Co-Authored-By: Paul Campbell <claude~paul@keymail.dev>
17 files changed,
+1,215
−2
docs/site/cli.md+19 −0docs/superpowers/notes/census-proposal-static-site-geo-962.md+21 −0docs/superpowers/reviews/REVIEW-BRIEF-static-site-geo-962-R1.md+130 −0docs/superpowers/reviews/REVIEW-BRIEF-static-site-geo-962-R2.md+150 −0docs/superpowers/reviews/REVIEW-FINDINGS-static-site-geo-962-R1.md+34 −0docs/superpowers/reviews/REVIEW-FINDINGS-static-site-geo-962-R2.md+28 −0internal/edge/assetcatch.go+8 −0internal/edge/demo_traffic.go+16 −1internal/edge/edge.go+16 −0internal/edge/forwardha_export_test.go+19 −0internal/edge/geoanswer.go+87 −0internal/edge/geoanswer_test.go+599 −0internal/edge/haingress_test.go+44 −0internal/provision/plan9_b8_census_test.go+1 −1internal/provision/static_site_geo_962_census_test.go+35 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-static-site-geo-962.tsv+7 −0
CI passed — run details
diff --git a/docs/site/cli.md b/docs/site/cli.md| index fa617a5e5..c8583bf10 100644 |
| --- a/docs/site/cli.md |
| +++ b/docs/site/cli.md |
| @@ -1794,6 +1794,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..c62e1e64c |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-static-site-geo-962.md |
| @@ -0,0 +1,21 @@ |
| +# 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/demo_traffic.go` `Edge.serveDemoTraffic` | body | unchanged (33) | discussion #962, Astra R1-1: a demo request whose cleaned path is /.carlos/geo is answered by serveGeoAnswer through the demo response policy, after the demo's admission, import-gate and lapse refusals and before the guard, throttles, the demo traffic allowance and the app; merged with main (no new read) | |
| +| `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; merged with main (no new read) | |
| + |
| +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/demo_traffic.go` `Edge.serveDemoTraffic`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-2;basis=demo_traffic.go:128-334 reads the resolved Route and passes it to existing admission, metering, rate and activator helpers. Resident serving checks precede the inert moved hook (:143), retirement and durable request debit (:302); output debits use the writer below compression. Forwarders do not count or transform again. Existing expiry/control cancellations and five-second write bounds apply; no request-path console or bucket read.;rev3=census-ruling-edge-page-cache-1;basis=attaches the in-memory page mark holder to a demo's request when the route is an instance (up.route.Kind, the +registry:Kind and +whole:Route sites), as ServeHTTP does; nothing else; final fix wave: also wraps the app's writer in the page diagnostics writer (pageDiagnostics(r, host, up).wrap(appWriter)), which sets Carlos-Cache: bypass on a marked response and records nothing; in memory, no read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: the demo route's request header scrub also deletes tunnelclient.LinkAppHeader (Carlos-Link-App), the hub-set link publication header, beside the tunnel markers it already deletes; a header delete on the cloned request, no read added |
| +- `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;rev3=census-ruling-stateless-replicas-4-r28;basis=R28 (#511): for a request whose host has no entry (the lookup miss), after the replica-probe branch, calls refuseRetiredCopy(r, host): within the grace of a host whose replica copy this box retired, the fleet tunnel stream is refused with REFUSED_STREAM (tunnelclient.Refuse) and nothing is written; any other miss gets the unknown-host answer as before; memory only, a refusal only, no read added |
| + |
| +Seal: `44e5745a1d22ea2ddd6e73d775d87759afe7121666212b6ed2563c1518261bc4` → `5e8a72175700a3e60c1e283b133c1ee25e36f292e2e319f02a19138f15186376`. |
| + |
| +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/docs/superpowers/reviews/REVIEW-BRIEF-static-site-geo-962-R1.md b/docs/superpowers/reviews/REVIEW-BRIEF-static-site-geo-962-R1.md| new file mode 100644 |
| index 000000000..d6d082a2f |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/REVIEW-BRIEF-static-site-geo-962-R1.md |
| @@ -0,0 +1,130 @@ |
| +# Review brief: branch static-site-geo-962 (visitor country for static sites), round 1 of 3 |
| + |
| +Repo carlos/platform, branch `static-site-geo-962`, commit 2edc14b3dda274fc215b58a53eea3553f57261a3. |
| +Under review: the diff `origin/main..2edc14b3` (base f2cf2828fcbdd863e408a8b37b58529cbbdbb2ea). |
| +Authorities, all merged on main: `docs/superpowers/specs/2026-10-06-platform-geoip-design.md` |
| +(the X-Carlos-Geo-* headers, §8 trust rules, R4 "no per-app switch"), |
| +`docs/superpowers/specs/2026-11-08-edge-page-cache-design.md`, |
| +`docs/superpowers/specs/2026-10-24-edge-asset-cache-design.md`, |
| +`docs/superpowers/specs/2026-11-10-linked-deployments-design.md`, and AGENTS.md |
| +(the census section, "A ResponseWriter wrapper that edits headers needs its own |
| +header map"). The request is discussion #962 on amadan (quoted below). Do not |
| +review against unmerged branches; if this work needs one, say so as a P1 and stop. |
| + |
| +You are an independent reviewer. Read the diff, then the code it touches |
| +(`internal/edge/edge.go` Edge.ServeHTTP in full, `internal/edge/geoipheaders.go`, |
| +`internal/edge/assetcatch.go`, `internal/edge/static.go`), and check every claim |
| +in the new comments, the commit message and the docs section against that code. |
| + |
| +The request (#962): a static site (no app code) needs its page script to learn |
| +the visitor's country, so a pricing page can default its currency. Expose the |
| +same answer the X-Carlos-Geo-* headers carry through a same-origin endpoint the |
| +edge answers itself. Constraints given: same lookup, trust rules and opt-outs |
| +as the headers; `Cache-Control: no-store, private` and `Vary: *`; never in the |
| +edge page cache or the asset cache; nothing logged or stored per visitor beyond |
| +normal request logs; no cookies; GET and HEAD only; tiny JSON; decide and state |
| +what happens to a site's own file at the path; work for static and app sites on |
| +every edge kind that serves sites (shared boxes, fleet edges, ingress) and |
| +behind custom domains; count it in analytics the way other edge-answered |
| +requests are, or not at all; provider-neutral (no new cloud calls). |
| + |
| +## Design as built (check it; do not re-argue the choices themselves) |
| + |
| +- Path `/.carlos/geo` (the platform's existing reserved prefix, beside |
| + `/.carlos/gate`, `/.carlos/ha-drain`, `/.carlos/lb-health`), matched after |
| + `path.Clean` (`isGeoPath`), so every spelling that cleans to it is reserved. |
| +- GET/HEAD: 200 `{"country":"GB","source":"GeoIP2-City"}`; both null unless the |
| + answer is a hit with a country. Other methods: 405 with `Allow: GET, HEAD`. |
| + Headers: `Cache-Control: no-store, private`, `Vary: *`, `nosniff`, JSON. |
| +- Geo off: there is no per-app or per-account switch (geoip spec R4), so "off" |
| + means no database on the deployment; the answer is null (not 404). |
| +- Answered in Edge.ServeHTTP right after `planDisabledAdmit`, before the page |
| + mark holder, the meter/observer defer, the guard, the password gate, the asset |
| + catch, the page cache and the LRU. Not counted, billed or recorded, like the |
| + load-balancer health, steering probe and HA control answers. Answered before |
| + the password gate on purpose: it describes the visitor, not the site. |
| +- A linked (pinned) request is not answered; it goes on to the pinned app. |
| +- `farAssetCatch` skips the geo path, so a far edge never catches it under a |
| + declared `/.carlos/` asset prefix; it is backhauled and the home answers from |
| + the hop's geo. |
| + |
| +## What to check |
| + |
| +1. **Same answer as the headers on every arm.** For each way a request reaches |
| + the answering line (direct ingress, verified backhaul hop, rejected hop, HA |
| + front forward and HA ingress, tunnel hub for a `Tunnel` row, the tunnel |
| + client side, a forward row (`IsForward`) on the hub, alias and catch-all |
| + custom domains, a regional name, a door call, a demo route, a linked |
| + request), is the JSON exactly what `WriteApp` would have put in the headers |
| + for that request? Is there an arm that answers the geo path BEFORE |
| + `decideGeo` runs, or one that would answer with this box's own lookup where |
| + the headers would carry the ingress's? |
| +2. **Never cached or stored.** Can any cache (page cache, local or far asset |
| + catch, the hop fill `serveAssetFillForHop`, the response LRU, the backhaul |
| + path, a browser or shared cache downstream) store or replay this answer, or |
| + replay an older stored copy from before this change (for example an asset |
| + entry or LRU entry an app produced at `/.carlos/geo`)? Do any wrappers |
| + between the client and `serveGeoAnswer` (gzip, recorders, the countingWriter, |
| + the connection tracker, the gate, HTTP/2) alter or drop its headers? |
| +3. **Shadowing and reservation.** Is the rule "the edge always answers the |
| + cleaned path; a site's file or an app's route there is never reached" what |
| + the code does for static trees, apps, prefix-mapped hosts and gated hosts? |
| + Any spelling that reaches the site's file anyway, or a spelling the edge |
| + answers that a site could reasonably need? |
| +4. **Skipped checks.** Answering before the guard, the rate limit, the plan |
| + throttle and the password gate: does that let anyone learn anything about a |
| + site, wake an instance, bypass a lapse or import refusal, or cost the |
| + platform more than the request it answers? Is anything per-visitor logged or |
| + stored? |
| +5. **Tests.** `internal/edge/geoanswer_test.go`: do they go through the real |
| + wiring (`New`, `Reload`, `EnableStatic`, `ServeHTTP`, the real MaxMind test |
| + database), and would each fail if the behaviour it names broke? Name any |
| + arm from item 1 without a test that matters. |
| +6. **Census** (AGENTS.md, "The census: the reviewer decides"). Card: |
| + `docs/superpowers/notes/census-proposal-static-site-geo-962.md`. Give a |
| + verdict for the unit `internal/edge/edge.go` `Edge.ServeHTTP` (class body, |
| + read sites unchanged) and for the re-pinned envelope `internal/edge` (read |
| + every changed function in the package: `geoanswer.go`, the `farAssetCatch` |
| + hunk). 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 recorded basis relies on; or if the diff cannot settle |
| + either. Otherwise approve, citing the lines you read. |
| +7. **Docs accuracy** (`docs/site/cli.md`, "The visitor's country in a static |
| + page"): is every statement true of the code? The wording itself goes to Paul's |
| + copy review; report only statements that are false or misleading. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). Then the census verdicts (item 6). End with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +In round 3, a NOT READY also says whether the P1s share one cause, and |
| +whether refusing the case up front or cutting the feature would remove |
| +them. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites; a targeted |
| +`go test ./internal/edge/ -run 'TestGeoAnswer|TestIsGeoPath' -count=1` with |
| +`TMPDIR=/tmp/g` and `GOFLAGS=-buildvcs=false` is fine, with GOCACHE left unset. |
diff --git a/docs/superpowers/reviews/REVIEW-BRIEF-static-site-geo-962-R2.md b/docs/superpowers/reviews/REVIEW-BRIEF-static-site-geo-962-R2.md| new file mode 100644 |
| index 000000000..97624ec85 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/REVIEW-BRIEF-static-site-geo-962-R2.md |
| @@ -0,0 +1,150 @@ |
| +# Review brief: branch static-site-geo-962 (visitor country for static sites), round 2 of 3 |
| + |
| +Repo carlos/platform, branch `static-site-geo-962`, commit 07a813d8ececb78718b16f9dae861b66d1143b25. |
| +Under review: the whole diff `f2cf2828fcbdd863e408a8b37b58529cbbdbb2ea..07a813d8` (base is origin/main at f2cf2828); the round 1 fixes are `565cbe67..07a813d8`. |
| +Authorities, all merged on main: `docs/superpowers/specs/2026-10-06-platform-geoip-design.md` |
| +(the X-Carlos-Geo-* headers, §8 trust rules, R4 "no per-app switch"), |
| +`docs/superpowers/specs/2026-11-08-edge-page-cache-design.md`, |
| +`docs/superpowers/specs/2026-10-24-edge-asset-cache-design.md`, |
| +`docs/superpowers/specs/2026-11-10-linked-deployments-design.md`, and AGENTS.md |
| +(the census section, "A ResponseWriter wrapper that edits headers needs its own |
| +header map"). The request is discussion #962 on amadan (quoted below). Do not |
| +review against unmerged branches; if this work needs one, say so as a P1 and stop. |
| + |
| +You are an independent reviewer. Read the diff, then the code it touches |
| +(`internal/edge/edge.go` Edge.ServeHTTP in full, `internal/edge/geoipheaders.go`, |
| +`internal/edge/assetcatch.go`, `internal/edge/static.go`), and check every claim |
| +in the new comments, the commit message and the docs section against that code. |
| + |
| +The request (#962): a static site (no app code) needs its page script to learn |
| +the visitor's country, so a pricing page can default its currency. Expose the |
| +same answer the X-Carlos-Geo-* headers carry through a same-origin endpoint the |
| +edge answers itself. Constraints given: same lookup, trust rules and opt-outs |
| +as the headers; `Cache-Control: no-store, private` and `Vary: *`; never in the |
| +edge page cache or the asset cache; nothing logged or stored per visitor beyond |
| +normal request logs; no cookies; GET and HEAD only; tiny JSON; decide and state |
| +what happens to a site's own file at the path; work for static and app sites on |
| +every edge kind that serves sites (shared boxes, fleet edges, ingress) and |
| +behind custom domains; count it in analytics the way other edge-answered |
| +requests are, or not at all; provider-neutral (no new cloud calls). |
| + |
| +## Design as built (check it; do not re-argue the choices themselves) |
| + |
| +- Path `/.carlos/geo` (the platform's existing reserved prefix, beside |
| + `/.carlos/gate`, `/.carlos/ha-drain`, `/.carlos/lb-health`), matched after |
| + `path.Clean` (`isGeoPath`), so every spelling that cleans to it is reserved. |
| +- GET/HEAD: 200 `{"country":"GB","source":"GeoIP2-City"}`; both null unless the |
| + answer is a hit with a country. Other methods: 405 with `Allow: GET, HEAD`. |
| + Headers: `Cache-Control: no-store, private`, `Vary: *`, `nosniff`, JSON. |
| +- Geo off: there is no per-app or per-account switch (geoip spec R4), so "off" |
| + means no database on the deployment; the answer is null (not 404). |
| +- Answered in Edge.ServeHTTP right after `planDisabledAdmit`, before the page |
| + mark holder, the meter/observer defer, the guard, the password gate, the asset |
| + catch, the page cache and the LRU. Not counted, billed or recorded, like the |
| + load-balancer health, steering probe and HA control answers. Answered before |
| + the password gate on purpose: it describes the visitor, not the site. |
| +- A linked (pinned) request is not answered; it goes on to the pinned app. |
| +- A live demo route (`serveDemoTraffic`) answers it too, after the demo's |
| + admission, import-gate and lapse refusals, through the demo response policy |
| + (which turns Cache-Control into its own `no-store`), and skips the demo's |
| + observer defer, guard, throttles and traffic allowance. |
| +- `farAssetCatch` skips the geo path, so a far edge never catches it under a |
| + declared `/.carlos/` asset prefix; it is backhauled and the home answers from |
| + the hop's geo. |
| + |
| +## What to check |
| + |
| +1. **Same answer as the headers on every arm.** For each way a request reaches |
| + the answering line (direct ingress, verified backhaul hop, rejected hop, HA |
| + front forward and HA ingress, tunnel hub for a `Tunnel` row, the tunnel |
| + client side, a forward row (`IsForward`) on the hub, alias and catch-all |
| + custom domains, a regional name, a door call, a demo route, a linked |
| + request), is the JSON exactly what `WriteApp` would have put in the headers |
| + for that request? Is there an arm that answers the geo path BEFORE |
| + `decideGeo` runs, or one that would answer with this box's own lookup where |
| + the headers would carry the ingress's? |
| +2. **Never cached or stored.** Can any cache (page cache, local or far asset |
| + catch, the hop fill `serveAssetFillForHop`, the response LRU, the backhaul |
| + path, a browser or shared cache downstream) store or replay this answer, or |
| + replay an older stored copy from before this change (for example an asset |
| + entry or LRU entry an app produced at `/.carlos/geo`)? Do any wrappers |
| + between the client and `serveGeoAnswer` (gzip, recorders, the countingWriter, |
| + the connection tracker, the gate, HTTP/2) alter or drop its headers? |
| +3. **Shadowing and reservation.** Is the rule "the edge always answers the |
| + cleaned path; a site's file or an app's route there is never reached" what |
| + the code does for static trees, apps, prefix-mapped hosts and gated hosts? |
| + Any spelling that reaches the site's file anyway, or a spelling the edge |
| + answers that a site could reasonably need? |
| +4. **Skipped checks.** Answering before the guard, the rate limit, the plan |
| + throttle and the password gate: does that let anyone learn anything about a |
| + site, wake an instance, bypass a lapse or import refusal, or cost the |
| + platform more than the request it answers? Is anything per-visitor logged or |
| + stored? |
| +5. **Tests.** `internal/edge/geoanswer_test.go`: do they go through the real |
| + wiring (`New`, `Reload`, `EnableStatic`, `ServeHTTP`, the real MaxMind test |
| + database), and would each fail if the behaviour it names broke? Name any |
| + arm from item 1 without a test that matters. |
| +6. **Census** (AGENTS.md, "The census: the reviewer decides"). Card: |
| + `docs/superpowers/notes/census-proposal-static-site-geo-962.md`. Give a |
| + verdict for the unit `internal/edge/edge.go` `Edge.ServeHTTP` (class body, |
| + read sites unchanged) and for the re-pinned envelope `internal/edge` (read |
| + every changed function in the package: `geoanswer.go`, the `farAssetCatch` |
| + hunk). 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 recorded basis relies on; or if the diff cannot settle |
| + either. Otherwise approve, citing the lines you read. |
| +7. **Docs accuracy** (`docs/site/cli.md`, "The visitor's country in a static |
| + page"): is every statement true of the code? The wording itself goes to Paul's |
| + copy review; report only statements that are false or misleading. |
| + |
| +## Round 2 |
| + |
| +Earlier rounds: `docs/superpowers/reviews/REVIEW-FINDINGS-static-site-geo-962-R1.md` |
| +(round 1, Astra: R1-1 P1 demo sites never reach the endpoint; R1-2 P2 missing |
| +arm tests; census approved for `Edge.ServeHTTP` and the `internal/edge` |
| +envelope). The round number counts every earlier review of this change. |
| + |
| +First give one line per P1 and P2 from round 1: resolved, partly, or not. |
| +Carry every unresolved or partly resolved finding forward at its current |
| +severity, then add new findings. The verdict covers everything outstanding, |
| +earlier rounds included. Focus new review on `internal/edge/demo_traffic.go` |
| +(the new `geoAsk` branch and the defer it skips) and the new tests; also |
| +give the census verdict for the new unit `internal/edge/demo_traffic.go` |
| +`Edge.serveDemoTraffic` (class body, read sites unchanged) on the updated |
| +card, and re-confirm the `internal/edge` envelope for the round 1 diff. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). Then the census verdicts (item 6). End with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +In round 3, a NOT READY also says whether the P1s share one cause, and |
| +whether refusing the case up front or cutting the feature would remove |
| +them. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites; a targeted |
| +`go test ./internal/edge/ -run 'TestGeoAnswer|TestIsGeoPath' -count=1` with |
| +`TMPDIR=/tmp/g` and `GOFLAGS=-buildvcs=false` is fine, with GOCACHE left unset. |
diff --git a/docs/superpowers/reviews/REVIEW-FINDINGS-static-site-geo-962-R1.md b/docs/superpowers/reviews/REVIEW-FINDINGS-static-site-geo-962-R1.md| new file mode 100644 |
| index 000000000..51e5bea7f |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/REVIEW-FINDINGS-static-site-geo-962-R1.md |
| @@ -0,0 +1,34 @@ |
| +Reviewed `f2cf2828..2edc14b3`, round 1 of 3. No files changed. |
| + |
| +1. **P1 — Demo sites never reach the geo endpoint** — brief items 1, 3, 4 and 7. |
| + |
| + `ServeHTTP` returns through `handleDemoRequest` at [edge.go:2250](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/edge.go:2250), before the new handler at line 2739. [demo.go:128](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/demo.go:128) dispatches to `serveDemoTraffic`, which computes geo but ultimately calls the app at [demo_traffic.go:343](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/demo_traffic.go:343). |
| + |
| + **Failure scenario:** A live demo requests `GET /.carlos/geo`. It receives the app’s response—potentially a 404 or its own route’s content—instead of country JSON. The request also passes through demo accounting and can reach the activator. This contradicts the endpoint’s reservation and accounting contract, plus “Every site” and “isn’t counted in analytics” in [cli.md:1792](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/docs/site/cli.md:1792). |
| + |
| + **Fix:** Add the geo answer to the demo dispatch path after geo selection and applicable serving refusals, before accounting and activation. Preserve demo response protections. Add a real demo-route test asserting country JSON, required headers, no app request, no wake and no accounting. |
| + |
| + **Fault family:** Every supported site dispatch path must enforce the reserved endpoint before tenant execution. |
| + |
| +2. **P2 — Important endpoint dispatch and trust cases lack regression tests** — brief item 5. |
| + |
| + The backhaul test covers a verified hop, while [geoanswer_test.go:373](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/geoanswer_test.go:373) deliberately answers at the tunnel hub and asserts that the receiving edge sees nothing. It therefore does not test the endpoint’s tunnel-side adoption. |
| + |
| + Missing endpoint cases include rejected hops, tunnel-client delivery, HA front forwarding and HA ingress, `IsForward` rows, catch-all domains, regional names and the linked-request exception. The demo omission is demonstrated above. |
| + |
| + **Failure scenario:** An alternate ingress answers using its own lookup, or a pinned request is intercepted, while the current endpoint tests remain green. |
| + |
| + **Fix:** Extend the existing fixtures to exercise these paths. Assert ingress-derived JSON without a receiving-edge lookup, nulls for rejected hops, and app delivery for pinned requests. |
| + |
| + **Fault family:** Geo provenance and endpoint ownership must survive every dispatch arm. |
| + |
| +No P3 findings. |
| + |
| +Census verdicts for the reviewed diff: |
| + |
| +- **Approve `Edge.ServeHTTP` — body, read sites unchanged.** Read the complete function, including geo selection at [edge.go:2418](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/edge.go:2418), door/import/lapse checks and the new return at line 2739. The change consumes existing request context and adds no root file, registry or bucket read. |
| +- **Approve the `internal/edge` envelope.** Reviewed all new functions in [geoanswer.go:29](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/geoanswer.go:29), the tests and the exclusion at [assetcatch.go:1055](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/assetcatch.go:1055). These add no new authority to open, execute or follow tenant-controlled resources. Ordinary requests bypass local cache reads and writes; the far exclusion also prevents replay of existing asset entries. |
| + |
| +`git diff --check` passed. The targeted Go tests could not start because the read-only sandbox prevented creation of Go’s build directory. No full suites were run. |
| + |
| +**NOT READY** |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/REVIEW-FINDINGS-static-site-geo-962-R2.md b/docs/superpowers/reviews/REVIEW-FINDINGS-static-site-geo-962-R2.md| new file mode 100644 |
| index 000000000..fca42c99c |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/REVIEW-FINDINGS-static-site-geo-962-R2.md |
| @@ -0,0 +1,28 @@ |
| +R1-1 (P1): **Resolved.** Demos now answer after serving refusals and before accounting or app dispatch. |
| +R1-2 (P2): **Partly resolved.** HA front forwarding, HA ingress and regional-name endpoint tests remain missing. |
| + |
| +Reviewed `f2cf2828..07a813d8`, including fixes `565cbe67..07a813d8`, in the worktree at `f5bceb83`. No files changed. |
| + |
| +1. **P2 — Missing dispatch regression coverage** — brief items 1 and 5; carried forward from R1-2. |
| + |
| + The added tests cover rejected hops, tunnel-client adoption, linked requests, wildcard domains, demos and forward rows, starting at [geoanswer_test.go:424](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/geoanswer_test.go:424). They do not exercise the endpoint through HA front forwarding, HA ingress or regional-name routing. |
| + |
| + Those paths make distinct decisions before the endpoint: [forwardha.go:181](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/forwardha.go:181), [haingress.go:46](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/haingress.go:46), and [edge.go:2431](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/edge.go:2431). |
| + |
| + **Failure scenario:** A regression could lose ingress geo during HA forwarding, answer using the receiving box’s lookup, or incorrectly refuse a valid regional endpoint while all endpoint tests remain green. |
| + |
| + **Fix:** Extend the existing HA and regional fixtures with `/.carlos/geo` requests. Assert ingress-derived JSON, zero receiving-edge lookups and app requests, preserved cache-prevention headers, and correct regional admission/refusal. |
| + |
| + **Fault family:** Geo provenance and endpoint ownership must survive every dispatch arm. |
| + |
| +No P1 or P3 findings. |
| + |
| +Census verdicts: |
| + |
| +- **Approve `Edge.ServeHTTP` — body, read sites unchanged.** The return at [edge.go:2739](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/edge.go:2739) consumes the existing geo context after routing, door scope, import and lapse checks. It adds no resource access or tenant-execution authority. |
| +- **Approve `Edge.serveDemoTraffic` — body, read sites unchanged.** Reviewed the complete function, including serving and retirement checks, geo selection, the observer exemption at [demo_traffic.go:208](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/demo_traffic.go:208), and the answer after refusals at [demo_traffic.go:266](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/demo_traffic.go:266). Existing expiry, cancellation and output checks remain effective; no new root reads or authority are introduced. |
| +- **Approve the re-pinned `internal/edge` envelope.** Reviewed all changed functions and tests. The helpers in [geoanswer.go:29](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/geoanswer.go:29) only normalize paths and serialize existing context. The exclusion at [assetcatch.go:1054](/home/paulca/.cache/tmp/claude-1001/geo-962/wt/internal/edge/assetcatch.go:1054) prevents far-cache lookup and fill, including replay of older entries. |
| + |
| +`git diff --check` passed. Targeted tests could not start because the read-only sandbox blocked Go’s build directory; no full suites ran. Fix the remaining P2 without reopening the review. |
| + |
| +**READY AFTER FIXES** |
| \ No newline at end of file |
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/demo_traffic.go b/internal/edge/demo_traffic.go| index 90aa32a22..e8b2bd49f 100644 |
| --- a/internal/edge/demo_traffic.go |
| +++ b/internal/edge/demo_traffic.go |
| @@ -200,11 +200,20 @@ func (e *Edge) serveDemoTraffic(dst http.ResponseWriter, r *http.Request, up ups |
| var delivered int64 |
| ob := &countingWriter{ResponseWriter: dst, n: &delivered} |
| r, out := withOutcome(r) |
| - if e.guard != guardOff && !isDoor && !hopDoorFrom(ctx) && !fromTunnel(ctx) { |
| + // The visitor's country (geoanswer.go) is the edge's own answer on a |
| + // demo as on every other site: answered below, after the demo's own |
| + // refusals and before the guard, the throttles and the demo's traffic |
| + // allowance, and never metered, counted or recorded, as on the |
| + // ordinary path. |
| + geoAsk := isGeoPath(r.URL.Path) |
| + if e.guard != guardOff && !geoAsk && !isDoor && !hopDoorFrom(ctx) && !fromTunnel(ctx) { |
| out.guard = e.newGuardState(up.route) |
| out.guard.acct, out.guard.app = release.RouteAccount(up.route), up.route.App |
| } |
| defer func() { |
| + if geoAsk { |
| + return |
| + } |
| if m := e.usageMeter.Load(); m != nil { |
| m.Record(up.route, 1, delivered, hopped) |
| } |
| @@ -257,6 +266,12 @@ func (e *Edge) serveDemoTraffic(dst http.ResponseWriter, r *http.Request, up ups |
| if e.admissionRefuses(refusal, r, up.route) || !e.importGateAdmit(refusal, r, host, up.route) || !e.planDisabledAdmit(refusal, r, host, up.route) { |
| return |
| } |
| + if geoAsk { |
| + // Through the demo's response policy, which keeps its own headers |
| + // (Cache-Control becomes its no-store) and refuses a cookie. |
| + serveGeoAnswer(policy, r) |
| + return |
| + } |
| if out.guard != nil { |
| if hit, matched := edgeguard.Check(r.URL.Path, r.URL.RawQuery); matched { |
| if until, from, cooling := out.guard.cooling(r); cooling && burstDecide(refusal, r, until, from, up.viaTunnel || up.route.IsForward()) { |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index d498b623b..57e8ca19c 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -2761,6 +2761,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/forwardha_export_test.go b/internal/edge/forwardha_export_test.go| index 694a95a2c..3c9ac5c68 100644 |
| --- a/internal/edge/forwardha_export_test.go |
| +++ b/internal/edge/forwardha_export_test.go |
| @@ -335,3 +335,22 @@ func (s *HAForwardScene) SetIngressReceiver(t *testing.T, act Activator) { |
| t.Fatal(err) |
| } |
| } |
| + |
| +// SpyGeo makes every lookup on the ingress (annie) a hit for country and on |
| +// the holder (betty) a hit for "XX", and returns their lookup counts: the |
| +// geo answer's provenance across the HA ingress (geoanswer.go, #962). |
| +func (s *HAForwardScene) SpyGeo(country string) func() (ingress, holder int64) { |
| + a, b := spyGeo(s.x.a.edge, country), spyGeo(s.x.b.edge, "XX") |
| + return func() (int64, int64) { return a.Load(), b.Load() } |
| +} |
| + |
| +// IngressGeo is IngressRequest for a GET of the geo path from a visitor's |
| +// address, with the response's status, body and Cache-Control. |
| +func (s *HAForwardScene) IngressGeo(t *testing.T, host, from string) (int, string, string) { |
| + t.Helper() |
| + r := httptest.NewRequest(http.MethodGet, "https://"+host+GeoPath, nil) |
| + r.RemoteAddr = net.JoinHostPort(from, "4444") |
| + w := httptest.NewRecorder() |
| + s.x.a.edge.ServeHTTP(w, r) |
| + return w.Code, w.Body.String(), w.Header().Get("Cache-Control") |
| +} |
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..1dd694ebe |
| --- /dev/null |
| +++ b/internal/edge/geoanswer_test.go |
| @@ -0,0 +1,599 @@ |
| +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") |
| + } |
| +} |
| + |
| +// A rejected hop is answered with no geo at all: its RemoteAddr is the |
| +// sending edge, so neither its claim nor a lookup is believed (codex R2-1). |
| +func TestGeoAnswerForARejectedHopIsNull(t *testing.T) { |
| + e, _ := meshGeoEdge(t, "app.test") |
| + spy := spyGeo(e, "XX") |
| + r := geoReq("app.test", geoTestGB) |
| + r.URL.Path = GeoPath |
| + r.Header.Set(hopHeader, "1") |
| + r.Header.Set(hopAuthHeader, signHop([]byte("not-the-mesh-key-not-the-mesh-key"), "app.test", time.Now())) |
| + r.Header.Set(geoip.HeaderHop, "hit;src=GeoLite2-City") |
| + r.Header.Set(geoip.HeaderCountry, "FR") |
| + w := httptest.NewRecorder() |
| + e.ServeHTTP(w, r) |
| + wantGeoAnswer(t, "rejected hop", w, geoNull) |
| + if spy.Load() != 0 { |
| + t.Fatal("a rejected hop was looked up") |
| + } |
| +} |
| + |
| +// The tunnel client's side: a request a tunnel delivered carries the hub's |
| +// answer (spec §8.4), which this edge adopts without a lookup of its own. |
| +func TestGeoAnswerOnATunnelClientAdoptsTheHubs(t *testing.T) { |
| + e, n := geoAppEdge(t, "app.test", "service") |
| + spy := spyGeo(e, "XX") |
| + saved := fromTunnel |
| + fromTunnel = func(context.Context) bool { return true } |
| + t.Cleanup(func() { fromTunnel = saved }) |
| + w := geoAsk(e, "GET", "app.test", GeoPath, "127.0.0.1", |
| + geoip.HeaderHop, "hit;src=GeoLite2-City", geoip.HeaderCountry, "DE") |
| + wantGeoAnswer(t, "tunnel client", w, `{"country":"DE","source":"GeoLite2-City"}`) |
| + if spy.Load() != 0 || n.Load() != 0 { |
| + t.Fatalf("lookups %d, app requests %d; want 0 and 0", spy.Load(), n.Load()) |
| + } |
| +} |
| + |
| +// A linked request is the pinned app's alone (ServeLinked): the path goes on |
| +// to the app, as every other edge-owned handler is skipped for it. |
| +func TestGeoAnswerSkipsALinkedRequest(t *testing.T) { |
| + s := newPCScene(t, pageOK(pcBody), func(r *registry.Route) { r.Hibernate = true }) |
| + loadTestDB(t, s.e) |
| + rec := linkedGet(s.e, LinkedTarget{Host: pcHost, Account: "abc", App: "blog", PublicHost: "blog.pub.example.com"}, GeoPath) |
| + wantBody(t, rec, 200, pcBody) |
| + if n := s.b.n.Load(); n != 1 { |
| + t.Fatalf("the app saw %d requests, want the linked geo path", n) |
| + } |
| +} |
| + |
| +// A catch-all custom domain (a wildcard route_aliases row) answers too. |
| +func TestGeoAnswerOnAWildcardDomain(t *testing.T) { |
| + app, n := countingApp(t) |
| + reg := openReg(t) |
| + if err := reg.Upsert(registry.Route{Host: "relay.bab.oncarlos.com", Kind: "service", Addr: app.Listener.Addr().String(), Status: "ready"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + upsertAlias(t, reg, "*.woodstar.app", "relay.bab.oncarlos.com") |
| + e, err := New(reg, nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(e.probers.Stop) |
| + loadTestDB(t, e) |
| + wantGeoAnswer(t, "wildcard", geoAsk(e, "GET", "paul.woodstar.app", GeoPath, geoTestGB), geoGBAnswer) |
| + if n.Load() != 0 { |
| + t.Fatal("the app saw the geo ask") |
| + } |
| +} |
| + |
| +// A live demo answers it too, through the demo's response policy (its |
| +// Cache-Control is no-store), without spending the demo's traffic |
| +// allowance, reaching the app, or being counted. |
| +func TestGeoAnswerOnADemo(t *testing.T) { |
| + var n atomic.Int64 |
| + e, rt, c := demoTrafficFixture(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + n.Add(1) |
| + w.Write([]byte("app")) |
| + })) |
| + loadTestDB(t, e) |
| + m := &memAnalytics{} |
| + e.EnableAnalytics(m) |
| + e.SetAnalyticsOn(map[string]bool{release.RouteAccount(rt) + "/" + rt.App: true}) |
| + meter := NewUsageMeter() |
| + e.EnableUsage(meter) |
| + r := httptest.NewRequest("GET", "https://"+rt.Host+GeoPath, nil) |
| + r.RemoteAddr = net.JoinHostPort(geoTestGB, "4444") |
| + rec := httptest.NewRecorder() |
| + e.ServeHTTP(rec, r) |
| + if rec.Code != 200 || rec.Body.String() != geoGBAnswer { |
| + t.Fatalf("demo geo = %d %q", rec.Code, rec.Body.String()) |
| + } |
| + assertDemoPolicy(t, rec.Header()) |
| + h := rec.Header() |
| + if h.Get("Cache-Control") != "no-store" || h.Get("Vary") != "*" || h.Get("Content-Type") != "application/json" || len(h.Values("Set-Cookie")) != 0 { |
| + t.Fatalf("demo geo headers %v", h) |
| + } |
| + if n.Load() != 0 || c.requests != 0 { |
| + t.Fatalf("app requests %d, demo allowance spent %d", n.Load(), c.requests) |
| + } |
| + if len(m.snap()) != 0 || len(meter.Drain().Rows) != 0 { |
| + t.Fatal("the demo's geo answer was counted or metered") |
| + } |
| +} |
| + |
| +// A fleet's forward row on the hub: the hub answers from its own lookup, and |
| +// the fleet box never sees the request. |
| +func TestGeoAnswerForAForwardRowAtTheHub(t *testing.T) { |
| + cb := &countingBox{} |
| + hubURL, hub, box := forwardHubAndBox(t, []registry.Route{forwardRow("shop.example.com", "home", fwdOwner)}, nil, cb) |
| + hubSpy, boxSpy := spyGeo(hub, "NL"), spyGeo(box, "XX") |
| + resp, body := fwdDo(t, hubURL, "GET", "shop.example.com", GeoPath, "", nil) |
| + if resp.StatusCode != 200 || string(body) != `{"country":"NL","source":"TestDB-NL"}` || |
| + resp.Header.Get("Cache-Control") != "no-store, private" { |
| + t.Fatalf("forward row geo = %d %q %v", resp.StatusCode, body, resp.Header) |
| + } |
| + if n := cb.count("shop.example.com"); n != 0 || hubSpy.Load() != 1 || boxSpy.Load() != 0 { |
| + t.Fatalf("box requests %d, lookups hub=%d box=%d", n, hubSpy.Load(), boxSpy.Load()) |
| + } |
| +} |
| + |
| +// An HA host whose lease another box holds: the front edge forwards the geo |
| +// path to the holder, which answers from the front edge's lookup carried on |
| +// the hop, reaching neither app. |
| +func TestGeoAnswerThroughAnHAFrontForward(t *testing.T) { |
| + x := newFwScene(t, fwOpts{}) |
| + aSpy, bSpy := spyGeo(x.a.edge, "PT"), spyGeo(x.b.edge, "XX") |
| + resp, body := x.fetch(t, fwHost, GeoPath) |
| + if resp.StatusCode != 200 || body != `{"country":"PT","source":"TestDB-PT"}` || |
| + resp.Header.Get("Cache-Control") != "no-store, private" { |
| + t.Fatalf("HA forward geo = %d %q Cache-Control %q", resp.StatusCode, body, resp.Header.Get("Cache-Control")) |
| + } |
| + if aSpy.Load() != 1 || bSpy.Load() != 0 { |
| + t.Fatalf("lookups front=%d holder=%d, want 1 and 0", aSpy.Load(), bSpy.Load()) |
| + } |
| + if x.aApp.n.Load() != 0 || x.bApp.n.Load() != 0 { |
| + t.Fatalf("app requests front=%d holder=%d", x.aApp.n.Load(), x.bApp.n.Load()) |
| + } |
| + if got := x.aAct.asked.Load(); got != 1 { |
| + t.Fatalf("the front edge asked its activator %d times, want 1 (a forward)", got) |
| + } |
| +} |
| + |
| +// A regional name answers it where the name is bound, and a deny entry |
| +// refuses it as it refuses every path (#447): it never answers for a region |
| +// the name does not serve here. |
| +func TestGeoAnswerOnARegionalName(t *testing.T) { |
| + tie := rgSocketBackend(t, shortSockDir(t), "tie") |
| + reg := openReg(t) |
| + if err := reg.Upsert(rgInstance(rgTie, tie.sock, rgApp, "")); err != nil { |
| + t.Fatal(err) |
| + } |
| + store := release.NewDirStore(t.TempDir()) |
| + rgWriteClaim(t, store, rgClaim()) |
| + rgPass(t, store, reg, "") |
| + e, err := New(reg, nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(e.probers.Stop) |
| + loadTestDB(t, e) |
| + wantGeoAnswer(t, "bound regional name", geoAsk(e, "GET", rgApex, GeoPath, geoTestGB), geoGBAnswer) |
| + if tie.n.Load() != 0 { |
| + t.Fatal("the regional target saw the geo ask") |
| + } |
| + // Moved to another region: the kept row is now a deny entry here. |
| + if err := reg.Delete(rgTie); err != nil { |
| + t.Fatal(err) |
| + } |
| + moved := rgInstance(rgTie, tie.sock, rgApp, "") |
| + moved.Region = "uk" |
| + if err := reg.Upsert(moved); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := e.Reload(); err != nil { |
| + t.Fatal(err) |
| + } |
| + if w := geoAsk(e, "GET", rgApex, GeoPath, geoTestGB); w.Code != http.StatusServiceUnavailable { |
| + t.Fatalf("deny entry geo = %d %q, want 503", w.Code, w.Body.String()) |
| + } |
| +} |
diff --git a/internal/edge/haingress_test.go b/internal/edge/haingress_test.go| index 0df1579d6..0ba323ab9 100644 |
| --- a/internal/edge/haingress_test.go |
| +++ b/internal/edge/haingress_test.go |
| @@ -192,3 +192,47 @@ func TestHAIngressReceiverOwnAcquire(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +// The visitor's country through the HA ingress (geoanswer.go, #962): the |
| +// ingress, which holds no row, sends the geo path to the holder over a |
| +// signed hop carrying its own lookup, and the holder answers from it |
| +// without looking the visitor up or reaching either app. |
| +func TestHAIngressGeoAnswerIsTheIngresss(t *testing.T) { |
| + fx := locktest.NewLockFixture(t) |
| + prefix := activator.HibernatePrefix("", edge.HAForwardHost) |
| + body, _ := json.Marshal(hafresh.Lock{Generation: 9, ExpiresAt: time.Now().Add(time.Hour), Owner: hafresh.OwnerFor(hafresh.Self{Ref: "betty", IID: "i-b"}, 7, true)}) |
| + fx.PutLock(prefix, body) |
| + cfg := activator.Config{Bucket: fx.Bucket, Idle: time.Hour, Self: func() hafresh.Self { return hafresh.Self{Ref: "annie", IID: "i-a"} }} |
| + svc := activator.New(cfg, &activator.ExecBackend{ServedPools: (provision.ReconcileConfig{}).ServedPools, Cfg: cfg}, nil) |
| + t.Cleanup(func() { svc.Shutdown(context.Background()) }) |
| + x := edge.NewHAForwardScene(t, svc) |
| + x.IngressPools(t, "holder") |
| + store := release.NewDirStore(t.TempDir()) |
| + rec := provision.Record{Schema: 1, Host: edge.HAForwardHost, Slug: "ha", App: "shop", Account: release.OpsAccount, Channel: "stable", Region: "", Pool: "ha", HA: true} |
| + if err := provision.PutManifest(t.Context(), store, rec.Account, rec.App, provision.Manifest{Schema: 1, App: rec.App, Domain: "forward.test"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := provision.CreateRecord(t.Context(), store, rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + v := provision.NewRecordView(store, release.NewChangeWatch(store)) |
| + if err := v.Rebuild(t.Context()); err != nil { |
| + t.Fatal(err) |
| + } |
| + routes, err := v.Snapshot().HAIngressRoutes("") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + x.Ingress(t, func(host string) (registry.Route, bool) { rt, ok := routes[host]; return rt, ok }, "missing") |
| + lookups := x.SpyGeo("SE") |
| + code, got, cc := x.IngressGeo(t, edge.HAForwardHost, "81.2.69.142") |
| + if code != 200 || got != `{"country":"SE","source":"TestDB-SE"}` || cc != "no-store, private" { |
| + t.Fatalf("HA ingress geo = %d %q Cache-Control %q", code, got, cc) |
| + } |
| + if ingress, holder := lookups(); ingress != 1 || holder != 0 { |
| + t.Fatalf("lookups ingress=%d holder=%d, want 1 and 0", ingress, holder) |
| + } |
| + if a, b := x.IngressCounts(); a != 0 || b != 0 { |
| + t.Fatalf("app deliveries ingress=%d holder=%d, want none", a, b) |
| + } |
| +} |
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go| index cbc9b9701..8bbdb99bb 100644 |
| --- a/internal/provision/plan9_b8_census_test.go |
| +++ b/internal/provision/plan9_b8_census_test.go |
| @@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) { |
| if len(got) < 100 { |
| t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root) |
| } |
| - inventory := statelessReplicas4Drill1WriteCensusInventory() |
| + inventory := staticSiteGeo962WriteCensusInventory() |
| problems := append(censusDiff(inventory, got), censusPolicy(inventory)...) |
| if len(problems) > 0 { |
| t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n ")) |
diff --git a/internal/provision/static_site_geo_962_census_test.go b/internal/provision/static_site_geo_962_census_test.go| new file mode 100644 |
| index 000000000..4f406316b |
| --- /dev/null |
| +++ b/internal/provision/static_site_geo_962_census_test.go |
| @@ -0,0 +1,35 @@ |
| +package provision |
| + |
| +// staticSiteGeo962WriteCensusInventory is the static-site geo review |
| +// (discussion #962) of the record-write census, layered on |
| +// memberBackups2aWriteCensusInventory. |
| +// |
| +// One unit is re-digested; no record write is added and no class or kind |
| +// changes: |
| +// - Edge.serveDemoTraffic: a demo request for /.carlos/geo is answered by |
| +// serveGeoAnswer (the visitor's country from the request's geo answer, |
| +// no-store JSON) after the demo's admission, import-gate and lapse |
| +// refusals, and skips the observer defer and the guard state. It writes |
| +// nothing to any store. Its one sel:Put is still the gzip writer going |
| +// back to sync.Pool, not a record store. nonrecord / sel:Put, as before. |
| +func staticSiteGeo962WriteCensusInventory() []censusEntry { |
| + entries := append([]censusEntry(nil), statelessReplicas4Drill1WriteCensusInventory()...) |
| + repins := []censusEntry{ |
| + {"internal/edge/demo_traffic.go", "Edge.serveDemoTraffic", "nonrecord", "sel:Put", "da278b352dc5a3a7bcf00e894a6b2e2cf16415584ee704c2555f90e9e66614d1"}, |
| + } |
| + for _, r := range repins { |
| + found := false |
| + for i, e := range entries { |
| + if e.File == r.File && e.Unit == r.Unit { |
| + if e.Class != r.Class || e.Kinds != r.Kinds { |
| + panic("static-site-geo-962 census: classification changed for " + r.File + ":" + r.Unit) |
| + } |
| + entries[i], found = r, true |
| + } |
| + } |
| + if !found { |
| + panic("static-site-geo-962 census: re-pin of an unlisted unit " + r.File + ":" + r.Unit) |
| + } |
| + } |
| + return entries |
| +} |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index ba24c2742..96e02662b 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -200,3 +200,4 @@ plan14-root-reads-stateless-replicas-4-merge-main3.tsv 55d66980f8db645c762b56e20 |
| plan14-root-reads-ha-unclean-marker-waits.tsv 821598970e60a776d4a62138d5adbfa393cd30bc1ec1f266d290e5b6d4e12c42 |
| plan14-root-reads-ha-unclean-files-only.tsv bc138ce5435f3ab37f6adff46656eea1c20f48168c569550fe94e390c69ba309 |
| plan14-root-reads-edge-ppv2.tsv 44e5745a1d22ea2ddd6e73d775d87759afe7121666212b6ed2563c1518261bc4 |
| +plan14-root-reads-static-site-geo-962.tsv 5e8a72175700a3e60c1e283b133c1ee25e36f292e2e319f02a19138f15186376 |
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..3dc9d3a6c |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-static-site-geo-962.tsv |
| @@ -0,0 +1,7 @@ |
| +# 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. |
| +# 2 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy 95c627eacfd9a2d6b6fff4c965bf53d261196574936cd2a2c26a36f32714cf95 internal/edge/demo_traffic.go Edge.serveDemoTraffic legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-2;basis=demo_traffic.go:128-334 reads the resolved Route and passes it to existing admission, metering, rate and activator helpers. Resident serving checks precede the inert moved hook (:143), retirement and durable request debit (:302); output debits use the writer below compression. Forwarders do not count or transform again. Existing expiry/control cancellations and five-second write bounds apply; no request-path console or bucket read.;rev3=census-ruling-edge-page-cache-1;basis=attaches the in-memory page mark holder to a demo's request when the route is an instance (up.route.Kind, the +registry:Kind and +whole:Route sites), as ServeHTTP does; nothing else; final fix wave: also wraps the app's writer in the page diagnostics writer (pageDiagnostics(r, host, up).wrap(appWriter)), which sets Carlos-Cache: bypass on a marked response and records nothing; in memory, no read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: the demo route's request header scrub also deletes tunnelclient.LinkAppHeader (Carlos-Link-App), the hub-set link publication header, beside the tunnel markers it already deletes; a header delete on the cloned request, no read added;rev3=census-ruling-static-site-geo-962;basis=discussion #962, Astra R1-1: a demo request whose cleaned path is /.carlos/geo is answered by serveGeoAnswer through the demo response policy, after the demo's admission, import-gate and lapse refusals and before the guard, throttles, the demo traffic allowance and the app; merged with main (no new read) registry:App@2996,registry:DemoExpiresAt@1390,registry:Kind@7078,whole:Route@1089,whole:Route@1393,whole:Route@1532,whole:Route@1619,whole:Route@1742,whole:Route@223,whole:Route@2266,whole:Route@2923,whole:Route@2988,whole:Route@2999,whole:Route@3113,whole:Route@3209,whole:Route@3283,whole:Route@3330,whole:Route@3388,whole:Route@3417,whole:Route@3636,whole:Route@3667,whole:Route@3699,whole:Route@375,whole:Route@4072,whole:Route@454,whole:Route@4736,whole:Route@4786,whole:Route@4838,whole:Route@5263,whole:Route@6028,whole:Route@6571,whole:Route@7081,whole:Route@7529 da278b352dc5a3a7bcf00e894a6b2e2cf16415584ee704c2555f90e9e66614d1 |
| +@legacy 12f1917ff29b61627ec58fcb5f509fb1097d78e1b451a59a056a2837ad80b0ee 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-stateless-replicas-4-r28;basis=R28 (#511): for a request whose host has no entry (the lookup miss), after the replica-probe branch, calls refuseRetiredCopy(r, host): within the grace of a host whose replica copy this box retired, the fleet tunnel stream is refused with REFUSED_STREAM (tunnelclient.Refuse) and nothing is written; any other miss gets the unknown-host answer as before; memory only, a refusal only, 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; merged with main (no new read) file:ReadAll@20117,registry:Account@11002,registry:App@11026,registry:App@27912,registry:ClaimStamp@11056,registry:Gate@19091,registry:Gate@32303,registry:Gate@32363,registry:Gate@32421,registry:HA@14826,registry:HA@15168,registry:Host@11233,registry:Host@15207,registry:Host@32406,registry:ImportGate@41257,registry:Incarnation@11091,registry:Kind@24946,registry:Kind@26774,registry:Kind@30212,registry:Kind@41199,registry:Kind@41228,registry:ServingSeq@11125,whole:Route@11005,whole:Route@11029,whole:Route@11059,whole:Route@11094,whole:Route@11128,whole:Route@11236,whole:Route@14829,whole:Route@14923,whole:Route@15171,whole:Route@15210,whole:Route@18986,whole:Route@19097,whole:Route@21914,whole:Route@22698,whole:Route@23156,whole:Route@23348,whole:Route@24949,whole:Route@26777,whole:Route@27838,whole:Route@27904,whole:Route@27915,whole:Route@28168,whole:Route@28263,whole:Route@28339,whole:Route@28383,whole:Route@28685,whole:Route@28715,whole:Route@30215,whole:Route@30500,whole:Route@32306,whole:Route@32366,whole:Route@32409,whole:Route@32424,whole:Route@33635,whole:Route@35923,whole:Route@41202,whole:Route@41231,whole:Route@41260,whole:Route@41292,whole:Route@43737,whole:Route@8418,whole:Route@8517,whole:Route@8623 71f01ab7421b2c518e7ac54cc8c2984422cc1046bc886ea7e5d2665ab7e29a1e |
| +internal/edge/demo_traffic.go Edge.serveDemoTraffic legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-2;basis=demo_traffic.go:128-334 reads the resolved Route and passes it to existing admission, metering, rate and activator helpers. Resident serving checks precede the inert moved hook (:143), retirement and durable request debit (:302); output debits use the writer below compression. Forwarders do not count or transform again. Existing expiry/control cancellations and five-second write bounds apply; no request-path console or bucket read.;rev3=census-ruling-edge-page-cache-1;basis=attaches the in-memory page mark holder to a demo's request when the route is an instance (up.route.Kind, the +registry:Kind and +whole:Route sites), as ServeHTTP does; nothing else; final fix wave: also wraps the app's writer in the page diagnostics writer (pageDiagnostics(r, host, up).wrap(appWriter)), which sets Carlos-Cache: bypass on a marked response and records nothing; in memory, no read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: the demo route's request header scrub also deletes tunnelclient.LinkAppHeader (Carlos-Link-App), the hub-set link publication header, beside the tunnel markers it already deletes; a header delete on the cloned request, no read added;rev3=census-ruling-static-site-geo-962;basis=discussion #962, Astra R1-1: a demo request whose cleaned path is /.carlos/geo is answered by serveGeoAnswer through the demo response policy, after the demo's admission, import-gate and lapse refusals and before the guard, throttles, the demo traffic allowance and the app; merged with main (no new read) registry:App@2996,registry:DemoExpiresAt@1390,registry:Kind@7078,whole:Route@1089,whole:Route@1393,whole:Route@1532,whole:Route@1619,whole:Route@1742,whole:Route@223,whole:Route@2266,whole:Route@2923,whole:Route@2988,whole:Route@2999,whole:Route@3113,whole:Route@3209,whole:Route@3283,whole:Route@3330,whole:Route@3388,whole:Route@3417,whole:Route@3636,whole:Route@3667,whole:Route@3699,whole:Route@375,whole:Route@4072,whole:Route@454,whole:Route@4736,whole:Route@4786,whole:Route@4838,whole:Route@5263,whole:Route@6028,whole:Route@6571,whole:Route@7081,whole:Route@7529 da278b352dc5a3a7bcf00e894a6b2e2cf16415584ee704c2555f90e9e66614d1 |
| +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-stateless-replicas-4-r28;basis=R28 (#511): for a request whose host has no entry (the lookup miss), after the replica-probe branch, calls refuseRetiredCopy(r, host): within the grace of a host whose replica copy this box retired, the fleet tunnel stream is refused with REFUSED_STREAM (tunnelclient.Refuse) and nothing is written; any other miss gets the unknown-host answer as before; memory only, a refusal only, 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; merged with main (no new read) file:ReadAll@20117,registry:Account@11002,registry:App@11026,registry:App@27912,registry:ClaimStamp@11056,registry:Gate@19091,registry:Gate@32303,registry:Gate@32363,registry:Gate@32421,registry:HA@14826,registry:HA@15168,registry:Host@11233,registry:Host@15207,registry:Host@32406,registry:ImportGate@41257,registry:Incarnation@11091,registry:Kind@24946,registry:Kind@26774,registry:Kind@30212,registry:Kind@41199,registry:Kind@41228,registry:ServingSeq@11125,whole:Route@11005,whole:Route@11029,whole:Route@11059,whole:Route@11094,whole:Route@11128,whole:Route@11236,whole:Route@14829,whole:Route@14923,whole:Route@15171,whole:Route@15210,whole:Route@18986,whole:Route@19097,whole:Route@21914,whole:Route@22698,whole:Route@23156,whole:Route@23348,whole:Route@24949,whole:Route@26777,whole:Route@27838,whole:Route@27904,whole:Route@27915,whole:Route@28168,whole:Route@28263,whole:Route@28339,whole:Route@28383,whole:Route@28685,whole:Route@28715,whole:Route@30215,whole:Route@30500,whole:Route@32306,whole:Route@32366,whole:Route@32409,whole:Route@32424,whole:Route@33635,whole:Route@35923,whole:Route@41202,whole:Route@41231,whole:Route@41260,whole:Route@41292,whole:Route@43737,whole:Route@8418,whole:Route@8517,whole:Route@8623 71f01ab7421b2c518e7ac54cc8c2984422cc1046bc886ea7e5d2665ab7e29a1e |
| +@coverage internal/edge 6f39ea98c95c7de3fac2846fa3bdf74a343f86baad05c9580234da2a8e48b838 |