edge: geo answer tests through HA forward, HA ingress, regional (R2)
Astra round 2 (REVIEW-FINDINGS-static-site-geo-962-R2.md): READY AFTER FIXES, no P1, so the review stops here (AGENTS.md stopping rule 1). R1-1 resolved; census approved for Edge.ServeHTTP, Edge.serveDemoTraffic and the internal/edge envelope. R2-1 (P2, carried from R1-2: geo provenance on every arm): tests for the geo path through an HA front forward and the HA ingress (the holder answers from the front's lookup on the hop, no holder lookup, no app reached, no-store, private) and on a regional name (answered where it is bound, 503 from a deny entry). Test-only; no code change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+152
−0
docs/superpowers/reviews/REVIEW-FINDINGS-static-site-geo-962-R2.md+28 −0internal/edge/forwardha_export_test.go+19 −0internal/edge/geoanswer_test.go+61 −0internal/edge/haingress_test.go+44 −0
CI failed — run details
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/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_test.go b/internal/edge/geoanswer_test.go| index 9cc2bba17..1dd694ebe 100644 |
| --- a/internal/edge/geoanswer_test.go |
| +++ b/internal/edge/geoanswer_test.go |
| @@ -536,3 +536,64 @@ func TestGeoAnswerForAForwardRowAtTheHub(t *testing.T) { |
| 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) |
| + } |
| +} |