carlos / platform Public

edge: drop the hop checked mark; far deliveries follow ordinary-backhaul parity (asset cache plan 3 fix wave 4)

Controller ruling after Astra's re-review 2: drop X-Carlos-Hop-Checked
rather than harden it. Its signing (mesh.go), acceptance and stripping
(acceptHop), the guard and record exemptions (ServeHTTP, observeRecords)
and the far edge's sending and recording of fills all go: these files
return to their wave-1 bodies.

The far edge judges every far request with its own mode before reading
its store (block refuses and is recorded there) and records only what it
answers itself: hits, waiter hits and its own refusals. A fill or a
re-forward is judged and recorded by the home under its own mode, as an
ordinary backhauled request is.

TestAssetE2EFarDeliveriesFollowBackhaulParity pins it over two real
edges: far watch + home off (cold fill recorded by nobody, as for an
ordinary backhaul; warm hit by the far edge), far watch + home watch
(fill by the home, hit by the far edge), far block (refused before the
store, one far record), far watch + home block (the home refuses the
fill and records it).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev f5b2e51a8a558de0c9a424becfc94d6d2bc5a48d parent a22f26d
7 files changed, +135 −320
  • internal/edge/asset_e2e_test.go +111 −103
  • internal/edge/asset_far_test.go +4 −122
  • internal/edge/assetcatch.go +13 −36
  • internal/edge/edge.go +1 −5
  • internal/edge/homemap.go +4 −28
  • internal/edge/mesh.go +0 −22
  • internal/edge/reqrecords.go +2 −4
diff --git a/internal/edge/asset_e2e_test.go b/internal/edge/asset_e2e_test.go
index 759c9b932..5b1f04198 100644
--- a/internal/edge/asset_e2e_test.go
+++ b/internal/edge/asset_e2e_test.go
@@ -1417,7 +1417,7 @@ func TestAssetE2EGenerationOrOwnerMismatchGetsNoAck(t *testing.T) {
}
}
-// ---- protection recorded once across the two edges (fix wave 2) ----------
+// ---- protection on far deliveries: ordinary-backhaul parity ---------------
// lockedRecorder keeps request records filed from server goroutines.
type lockedRecorder struct {
@@ -1438,112 +1438,120 @@ func (l *lockedRecorder) Match(x reqrec.Match) {
l.match = append(l.match, x)
}
-func (l *lockedRecorder) counts() (resp, match int, last reqrec.Match) {
+// matches is the matches recorded so far.
+func (l *lockedRecorder) matches() []reqrec.Match {
l.mu.Lock()
defer l.mu.Unlock()
- if n := len(l.match); n > 0 {
- last = l.match[n-1]
- }
- return len(l.resp), len(l.match), last
+ return append([]reqrec.Match(nil), l.match...)
}
-// A far request for a cached asset path a protection rule matches
-// (/assets/.env, hard tier) is recorded exactly once across the two edges,
-// by the far edge, whatever the home's own mode: on the cold fill and on the
-// warm hit. With far protection watching and the home's off, the fill is
-// not lost; with both watching, the home does not record it a second time
-// (the fill hop carries the far edge's checked mark). With far protection
-// blocking, the far edge answers the block page and the home never sees the
-// request. With far protection watching and the home's blocking, the mark
-// buys nothing: the home still checks the fill hop and answers its block
-// page (the stricter mode wins), nothing is stored, and the one record is
-// still the far edge's (fix wave 3). An unmatched path is unchanged: no
-// mark, recorded by the home.
-func TestAssetE2EFarGuardRecordsOnce(t *testing.T) {
- for _, tc := range []struct {
- name string
- far, home guardMode
- }{
- {"far watch, home off", guardWatch, guardOff},
- {"far watch, home watch", guardWatch, guardWatch},
- {"far block, home watch", guardBlock, guardWatch},
- {"far watch, home block", guardWatch, guardBlock},
- } {
- t.Run(tc.name, func(t *testing.T) {
- x := newAssetE2E(t, assetE2EOpts{handler: assetOK(laBody)})
- x.a.edge.guard, x.b.edge.guard = tc.home, tc.far
- homeRec, farRec := &lockedRecorder{}, &lockedRecorder{}
- x.a.edge.EnableRequestRecords(homeRec)
- x.b.edge.EnableRequestRecords(farRec)
- block := tc.far == guardBlock
- homeBlocks := tc.home == guardBlock
- for i, cache := range []string{"miss", "hit"} {
- resp, body := x.fetch(t, x.b, "/assets/.env")
- x.rows(t) // every handler on both edges has returned
- if block || homeBlocks {
- if resp.StatusCode != http.StatusNotFound || resp.Header.Get("X-Carlos-Ref") == "" {
- t.Fatalf("request %d = %d ref %q, want the block page", i, resp.StatusCode, resp.Header.Get("X-Carlos-Ref"))
- }
- } else {
- wantE2ECache(t, resp, cache)
- if resp.StatusCode != http.StatusOK || body != laBody {
- t.Fatalf("request %d = %d %q", i, resp.StatusCode, body)
- }
- }
- hr, hm, _ := homeRec.counts()
- fr, fm, m := farRec.counts()
- if hr != 0 || hm != 0 || fr != 0 || fm != i+1 {
- t.Fatalf("after request %d: home %d responses %d matches, far %d responses %d matches; want the far edge's one match each",
- i, hr, hm, fr, fm)
- }
- wantKind, wantStatus := reqrec.KindWatch, http.StatusOK
- if block {
- wantKind = reqrec.KindBlock
- }
- if block || homeBlocks {
- wantStatus = http.StatusNotFound
- }
- if m.Kind != wantKind || m.Status != wantStatus || m.RuleID != "hard.secrets.env" || m.Acct != "abc" || m.App != "shop" || m.Path != "/assets/.env" {
- t.Fatalf("request %d recorded %+v", i, m)
- }
- }
- if homeBlocks {
- if n := x.app.n.Load(); n != 0 {
- t.Fatalf("the home's app saw %d request(s) its guard blocks", n)
- }
- x.wantNothingStored(t, "a fill the home blocked")
- }
- if block {
- if n := x.a.calls.Load(); n != 0 {
- t.Fatalf("the home saw %d request(s) the far edge blocked", n)
- }
- } else {
- req, _ := x.aTap.last()
- if mark := req.Get(hopCheckedHeader); !verifyHopCheckedEitherKey(x.key, nil, laHost, mark, time.Now()) {
- t.Fatalf("the fill hop carried checked mark %q, want a valid one", mark)
- }
- if r := x.app.lastReq(); r != nil && r.Header.Get(hopCheckedHeader) != "" {
- got := r.Header.Get(hopCheckedHeader)
- t.Fatalf("the home's app received the checked mark %q", got)
- }
- }
- if tc.home != guardWatch || block {
- return
- }
- // An unmatched asset: no mark, and the home records the fill
- // hop as before.
- resp, _ := x.fetch(t, x.b, "/assets/app.js")
- x.rows(t)
- wantE2ECache(t, resp, "miss")
- if req, _ := x.aTap.last(); req.Get(hopCheckedHeader) != "" {
- t.Fatal("an unmatched fill carried the checked mark")
- }
- if hr, hm, _ := homeRec.counts(); hr != 1 || hm != 0 {
- t.Fatalf("an unmatched fill: home %d responses %d matches, want one response", hr, hm)
- }
- if fr, fm, _ := farRec.counts(); fr != 0 || fm != 2 {
- t.Fatalf("an unmatched fill: far %d responses %d matches, want nothing new", fr, fm)
+// Far deliveries of a cached asset path a protection rule matches
+// (/assets/.env, hard tier) follow ordinary-backhaul parity (controller
+// ruling, fix wave 4). The far edge judges every far request with its own
+// mode before reading its store, and records only what it answers itself: a
+// hit, or its own refusal. Whatever it sends to the home (a fill) is judged
+// and recorded by the home under the home's own mode, exactly as an ordinary
+// backhauled request is, and the far edge does not record it.
+func TestAssetE2EFarDeliveriesFollowBackhaulParity(t *testing.T) {
+ const p = "/assets/.env"
+ scene := func(t *testing.T, far, home guardMode) (*assetE2E, *lockedRecorder, *lockedRecorder) {
+ x := newAssetE2E(t, assetE2EOpts{handler: assetOK(laBody)})
+ x.a.edge.guard, x.b.edge.guard = home, far
+ homeRec, farRec := &lockedRecorder{}, &lockedRecorder{}
+ x.a.edge.EnableRequestRecords(homeRec)
+ x.b.edge.EnableRequestRecords(farRec)
+ return x, homeRec, farRec
+ }
+ // want checks one request's recorded matches: home and far are the kinds
+ // each edge recorded for it ("" for none).
+ want := func(t *testing.T, step string, homeRec, farRec *lockedRecorder, homeBefore, farBefore int, home, far reqrec.Kind) {
+ t.Helper()
+ for _, e := range []struct {
+ name string
+ rec *lockedRecorder
+ before int
+ kind reqrec.Kind
+ }{{"home", homeRec, homeBefore, home}, {"far", farRec, farBefore, far}} {
+ got := e.rec.matches()[e.before:]
+ switch {
+ case e.kind == "" && len(got) != 0:
+ t.Fatalf("%s: the %s edge recorded %+v, want nothing", step, e.name, got)
+ case e.kind != "" && (len(got) != 1 || got[0].Kind != e.kind || got[0].RuleID != "hard.secrets.env" || got[0].Path != p):
+ t.Fatalf("%s: the %s edge recorded %+v, want one %s match", step, e.name, got, e.kind)
}
- })
+ }
+ }
+ fetch := func(t *testing.T, x *assetE2E) (*http.Response, string) {
+ t.Helper()
+ resp, body := x.fetch(t, x.b, p)
+ x.rows(t) // every handler on both edges has returned
+ return resp, body
}
+ wantServed := func(t *testing.T, step string, resp *http.Response, body, cache string) {
+ t.Helper()
+ wantE2ECache(t, resp, cache)
+ if resp.StatusCode != http.StatusOK || body != laBody {
+ t.Fatalf("%s = %d %q, want the asset", step, resp.StatusCode, body)
+ }
+ }
+ wantBlocked := func(t *testing.T, step string, resp *http.Response) {
+ t.Helper()
+ if resp.StatusCode != http.StatusNotFound || resp.Header.Get("X-Carlos-Ref") == "" {
+ t.Fatalf("%s = %d ref %q, want the block page", step, resp.StatusCode, resp.Header.Get("X-Carlos-Ref"))
+ }
+ }
+
+ t.Run("far watch, home off", func(t *testing.T) {
+ x, homeRec, farRec := scene(t, guardWatch, guardOff)
+ resp, body := fetch(t, x)
+ wantServed(t, "cold miss", resp, body, "miss")
+ // The fill went to the home, whose protection is off: nobody
+ // records it, the same as an ordinary backhauled request to a home
+ // with protection off.
+ want(t, "cold miss", homeRec, farRec, 0, 0, "", "")
+ resp, body = fetch(t, x)
+ wantServed(t, "warm hit", resp, body, "hit")
+ want(t, "warm hit", homeRec, farRec, 0, 0, "", reqrec.KindWatch)
+ })
+ t.Run("far watch, home watch", func(t *testing.T) {
+ x, homeRec, farRec := scene(t, guardWatch, guardWatch)
+ resp, body := fetch(t, x)
+ wantServed(t, "cold miss", resp, body, "miss")
+ want(t, "cold miss", homeRec, farRec, 0, 0, reqrec.KindWatch, "")
+ resp, body = fetch(t, x)
+ wantServed(t, "warm hit", resp, body, "hit")
+ want(t, "warm hit", homeRec, farRec, 1, 0, "", reqrec.KindWatch)
+ })
+ t.Run("far block refuses before the store", func(t *testing.T) {
+ x, homeRec, farRec := scene(t, guardWatch, guardOff)
+ resp, body := fetch(t, x)
+ wantServed(t, "cold miss", resp, body, "miss")
+ calls := x.a.calls.Load()
+ x.b.edge.guard = guardBlock
+ resp, _ = fetch(t, x)
+ wantBlocked(t, "far block over a warm entry", resp)
+ if got := resp.Header.Get("Carlos-Cache"); got != "" {
+ t.Fatalf("the block page carried Carlos-Cache %q", got)
+ }
+ want(t, "far block", homeRec, farRec, 0, 0, "", reqrec.KindBlock)
+ if n := x.a.calls.Load(); n != calls {
+ t.Fatalf("the home saw %d request(s) the far edge blocked", n-calls)
+ }
+ if _, ok := x.bStore.Get(x.entryKey(p)); !ok {
+ t.Fatal("the far edge's warm entry went")
+ }
+ })
+ t.Run("far watch, home block", func(t *testing.T) {
+ x, homeRec, farRec := scene(t, guardWatch, guardBlock)
+ resp, _ := fetch(t, x)
+ wantBlocked(t, "the fill at a blocking home", resp)
+ // The home's block page is its own unacknowledged answer: passed on
+ // uncached, recorded by the home.
+ wantE2ECache(t, resp, "bypass")
+ want(t, "the fill at a blocking home", homeRec, farRec, 0, 0, reqrec.KindBlock, "")
+ if n := x.app.n.Load(); n != 0 {
+ t.Fatalf("the home's app saw %d request(s) its guard blocks", n)
+ }
+ x.wantNothingStored(t, "a fill the home blocked")
+ })
}
diff --git a/internal/edge/asset_far_test.go b/internal/edge/asset_far_test.go
index f919cc4cb..9cff2b9b3 100644
--- a/internal/edge/asset_far_test.go
+++ b/internal/edge/asset_far_test.go
@@ -1146,23 +1146,12 @@ func TestFarHitsMeetTheGuard(t *testing.T) {
rec := &memRecorder{}
s.e.EnableRequestRecords(rec)
s.e.guard = guardWatch
- for p, want := range rules {
+ for p := range rules {
wantCache(t, s.get(t, p), "miss")
- // The fill is recorded here, once, and its hop tells the
- // home so with the checked mark (fix wave 2).
- if len(rec.match) == 0 {
- t.Fatalf("watched far fill of %s recorded nothing", p)
- }
- if m := rec.match[len(rec.match)-1]; m.Kind != reqrec.KindWatch || m.RuleID != want.id || m.Path != p || m.WokeKnown {
- t.Fatalf("watched far fill of %s recorded %+v", p, m)
- }
- mark := s.rec.get().header.Get(hopCheckedHeader)
- if !verifyHopCheckedEitherKey(s.meshKey, nil, laHost, mark, time.Now()) {
- t.Fatalf("the fill hop for %s carried checked mark %q, want a valid one", p, mark)
- }
}
- if len(rec.match) != len(rules) || len(rec.resp) != 0 {
- t.Fatalf("watched fills recorded matches %+v responses %+v, want one match each", rec.match, rec.resp)
+ // A fill reached the home as a hop, and the home records it.
+ if len(rec.match) != 0 || len(rec.resp) != 0 {
+ t.Fatalf("the far edge recorded fills: matches %+v responses %+v", rec.match, rec.resp)
}
s.meter.Drain()
@@ -1297,110 +1286,3 @@ func TestUncaughtLocalInformationalVocabularyIsScrubbed(t *testing.T) {
})
}
}
-
-// ---- the checked mark (fix wave 2) ----------------------------------------
-
-// A buffered far request the far edge's checks matched, whose fill the home
-// app vetoes with a late Set-Cookie trailer, is re-forwarded: two hops reach
-// the real home edge, the fill and the re-forward. Both carry the checked
-// mark, so the watching home records neither, and the far edge records the
-// request once.
-func TestFarReforwardIsRecordedOnceAcrossTheEdges(t *testing.T) {
- var home *laScene
- homeRec := &lockedRecorder{}
- s := newFarEdge(t, func(key []byte, m *homeMap) http.Handler {
- home = newLAScene(t, func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("Content-Type", "application/javascript")
- w.Header().Set("Cache-Control", "public, max-age=3600")
- w.Header().Set("Trailer", "Set-Cookie")
- io.WriteString(w, laBody)
- w.(http.Flusher).Flush()
- w.Header().Set("Set-Cookie", "late=1")
- })
- hm := newHomeMap(m.s, "betty")
- refreshHomeMap(t, hm)
- home.e.homes.Store(hm)
- home.e.guard = guardWatch
- home.e.EnableRequestRecords(homeRec)
- return home.e
- })
- farRec := &lockedRecorder{}
- s.e.EnableRequestRecords(farRec)
- s.e.guard = guardWatch
- rec := s.get(t, "/assets/.env", "Range", "bytes=0-6")
- wantCache(t, rec, "bypass")
- if rec.Code != 200 || rec.Body.String() != laBody {
- t.Fatalf("re-forwarded = %d %q, want the app's whole answer", rec.Code, rec.Body.String())
- }
- if n := home.b.n.Load(); n != 3 {
- t.Fatalf("the app saw %d requests, want 3 (the far fill, the home's own fill, the re-forward)", n)
- }
- if hr, hm, _ := homeRec.counts(); hr != 0 || hm != 0 {
- t.Fatalf("the home recorded %d responses and %d matches, want none", hr, hm)
- }
- fr, fm, m := farRec.counts()
- if fr != 0 || fm != 1 || m.Kind != reqrec.KindWatch || m.RuleID != "hard.secrets.env" || m.Status != 200 || m.WokeKnown {
- t.Fatalf("the far edge recorded %d responses, %d matches, last %+v; want one watch match", fr, fm, m)
- }
-}
-
-// The checked mark counts only beside a verified hop, and only in its own MAC
-// domain: a client's mark, even one signed with the mesh key, a mark beside
-// a hop whose own auth fails, and a hop signature passed off as a mark all
-// leave the home's record in place. The mark is deleted at entry and never
-// reaches the app. Even a verified hop's mark skips only the record: a home
-// that blocks still answers its block page (fix wave 3).
-func TestCheckedMarkCountsOnlyBesideAVerifiedHop(t *testing.T) {
- s := newLAScene(t, assetOK(laBody))
- key := s.armMesh(t)
- rec := &memRecorder{}
- s.e.EnableRequestRecords(rec)
- s.e.guard = guardWatch
- valid := func() string { return signHopChecked(key, laHost, time.Now()) }
- for _, tc := range []struct {
- name string
- hop string // "" none, "valid", "forged"
- mark func() string
- block bool
- recorded bool
- }{
- {"a client's mark", "", valid, false, true},
- {"a mark beside a forged hop", "forged", valid, false, true},
- {"a hop signature as the mark", "valid", func() string { return signHop(key, laHost, time.Now()) }, false, true},
- {"a verified hop's mark", "valid", valid, false, false},
- {"a verified hop's mark at a blocking home", "valid", valid, true, false},
- } {
- t.Run(tc.name, func(t *testing.T) {
- s.e.guard = guardWatch
- if tc.block {
- s.e.guard = guardBlock
- }
- before, app := len(rec.match), s.b.n.Load()
- req := httptest.NewRequest(http.MethodGet, "http://"+laHost+"/.env", nil)
- req.Header.Set(hopCheckedHeader, tc.mark())
- switch tc.hop {
- case "valid":
- req.Header.Set(hopHeader, "1")
- req.Header.Set(hopAuthHeader, signHop(key, laHost, time.Now()))
- case "forged":
- req.Header.Set(hopHeader, "1")
- req.Header.Set(hopAuthHeader, signHop([]byte("not the mesh key"), laHost, time.Now()))
- }
- w := httptest.NewRecorder()
- s.e.ServeHTTP(w, req)
- if got := len(rec.match) - before; (got == 1) != tc.recorded || got > 1 {
- t.Fatalf("%d match(es) recorded at the home, want recorded=%v", got, tc.recorded)
- }
- if tc.block {
- if w.Code != http.StatusNotFound || w.Header().Get("X-Carlos-Ref") == "" || s.b.n.Load() != app {
- t.Fatalf("a marked hop at a blocking home = %d ref %q, app saw %d new; want the block page",
- w.Code, w.Header().Get("X-Carlos-Ref"), s.b.n.Load()-app)
- }
- return
- }
- if v := s.b.lastReq().Header.Get(hopCheckedHeader); v != "" {
- t.Fatalf("the app received the checked mark %q", v)
- }
- })
- }
-}
diff --git a/internal/edge/assetcatch.go b/internal/edge/assetcatch.go
index dba0da5de..ec998dcd7 100644
--- a/internal/edge/assetcatch.go
+++ b/internal/edge/assetcatch.go
@@ -1039,10 +1039,8 @@ func (e *Edge) farAssetCatch(r *http.Request, host string) (a HostAssets, eip, b
// Protection (edge request protection, internal/edgeguard): every request
// this catch keeps first meets the hard and probe checks under this box's
// mode, before the store is read, exactly as a request the home serves meets
-// them in ServeHTTP. A block is answered with the block page. A match is
-// recorded here as one Match under the synthetic route, however the request
-// was answered, and every hop sent for it carries the checked mark, so the
-// home, which still checks it under its own mode, does not record it again.
+// them in ServeHTTP. A block is answered with the block page; a match it
+// answers itself is recorded as a Match under the synthetic route.
func (e *Edge) serveAssetFar(w http.ResponseWriter, r *http.Request, host string) bool {
a, eip, box, key, ok := e.farAssetCatch(r, host)
if !ok {
@@ -1057,7 +1055,7 @@ func (e *Edge) serveAssetFar(w http.ResponseWriter, r *http.Request, host string
rt := registry.Route{Host: host, Account: a.Account, App: a.App, Kind: "instance"}
var n int64
cw := &countingWriter{ResponseWriter: w, n: &n}
- var billed, acked, reforwarded, viaHome bool
+ var billed, acked, reforwarded bool
var out *outcome
defer func() {
if billed || (acked && !reforwarded) {
@@ -1065,13 +1063,12 @@ func (e *Edge) serveAssetFar(w http.ResponseWriter, r *http.Request, host string
m.Record(rt, 1, n, false)
}
}
- // A request a rule matched is recorded here, once, however it was
- // answered: a hit, the block page, a throttle refusal, a fill or a
- // forward, a home's block page included. Every hop sent for it
- // carried this edge's checked mark, so the home does not record it.
- // viaHome: a wake, if any, happened on the home, out of sight.
- if out != nil && out.guard != nil && out.guard.verdict != nil {
- e.observeRecords(rt, viaHome, r, cw, out)
+ // What this edge answered itself (a hit, the block page, a throttle
+ // refusal) is recorded here when a rule matched it, as ServeHTTP's
+ // observer defer records a matched request it serves. A fill or a
+ // forward reached the home as a hop, and the home records it there.
+ if billed && out != nil && out.guard != nil && out.guard.verdict != nil {
+ e.observeRecords(rt, false, r, cw, out)
}
}()
// The hard and probe checks, as ServeHTTP runs them for a request this
@@ -1087,21 +1084,6 @@ func (e *Edge) serveAssetFar(w http.ResponseWriter, r *http.Request, host string
return true
}
}
- // From here on, when a rule matched (a watch: a block has returned),
- // every hop this edge sends for the request (a fill, a forward) carries
- // its checked mark (signHopChecked), signed when the hop is sent: the
- // home still runs its own checks, and refuses when its mode blocks, but
- // does not record the request, which this edge's defer records once. A
- // request no rule matched carries no mark, and the home records it as an
- // ordinary hop.
- checked := out != nil && out.guard != nil && out.guard.verdict != nil
- forward = func() {
- viaHome = true
- if checked {
- r.Header.Set(hopCheckedHeader, signHopChecked(key, host, time.Now()))
- }
- e.farForward(cw, r, host, eip, box)
- }
var judged, admitted bool
throttle := func() bool {
if !judged {
@@ -1145,17 +1127,16 @@ func (e *Edge) serveAssetFar(w http.ResponseWriter, r *http.Request, host string
forward()
return true
}
- releaseSlot, ok := e.backhaulAdmit(cw, r, eip, box)
+ releaseSlot, ok := e.backhaulAdmit(w, r, eip, box)
if !ok {
done(nil)
return true
}
- viaHome = true
e.leadAssetFill(cw, r, nil, done, func(ctx context.Context, onHeader func(assetVerdict, http.Header)) (*assetcache.Entry, error) {
// The slot is held for the fill's whole exchange with the home, and
// given back before any re-forward takes its own.
defer releaseSlot()
- return e.fillFromHome(ctx, cw, r, k, host, eip, box, key, assertion, checked, &acked, onHeader)
+ return e.fillFromHome(ctx, cw, r, k, host, eip, box, key, assertion, &acked, onHeader)
}, func(_ assetVerdict, h http.Header) { stripAssetFillVocabulary(h) }, func() {
reforwarded = true
forward()
@@ -1174,10 +1155,9 @@ func (e *Edge) serveAssetFar(w http.ResponseWriter, r *http.Request, host string
// set when the acknowledgement verifies, storable or not: the caller meters
// exactly those responses. The rest (body size, reservation, trailer veto,
// fallback ETag, the initiating-request rule) is runAssetFill's, as for a
-// fill from the app. checked adds this edge's checked mark (signHopChecked)
-// to the hop, when its own checks matched r and it records r itself.
+// fill from the app.
func (e *Edge) fillFromHome(ctx context.Context, w http.ResponseWriter, r *http.Request, k assetcache.Key, host, eip, box string,
- key []byte, assertion string, checked bool, acked *bool, onHeader func(assetVerdict, http.Header)) (*assetcache.Entry, error) {
+ key []byte, assertion string, acked *bool, onHeader func(assetVerdict, http.Header)) (*assetcache.Entry, error) {
judge := func(code int, snap http.Header, reqTime, respTime time.Time) assetVerdict {
exp, ok := assetAcknowledged(snap, key, assertion)
if !ok {
@@ -1202,9 +1182,6 @@ func (e *Edge) fillFromHome(ctx context.Context, w http.ResponseWriter, r *http.
}
send := func(w http.ResponseWriter, req *http.Request) {
req.Header.Set(assetFillHeader, assertion)
- if checked {
- req.Header.Set(hopCheckedHeader, signHopChecked(key, host, time.Now()))
- }
backhaulProxy(host, eip, box, signHop(key, host, time.Now()), "", true, e.backhaulTransport(eip), e.logThrottled).ServeHTTP(w, req)
}
return e.runAssetFill(ctx, w, r, k, host, judge, send, onHeader)
diff --git a/internal/edge/edge.go b/internal/edge/edge.go
index b779fa442..e986d4258 100644
--- a/internal/edge/edge.go
+++ b/internal/edge/edge.go
@@ -1805,11 +1805,7 @@ func (e *Edge) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// backhauled it here (hopDoorFrom, set only beside a verified hop,
// as the rate limit reads it). A request a tunnel delivered was
// checked, and is recorded, by the hub that forwarded it, so
- // checking it again here would answer or count it twice. A hop a far
- // edge's asset catch sent with its checked mark (hopCheckedFrom) is
- // still checked here, so a home that blocks refuses it whatever the
- // far edge's mode (the stricter mode wins); only its record is left
- // to the far edge, which has filed it (observeRecords).
+ // checking it again here would answer or count it twice.
if e.guard != guardOff && !isDoor && !hopDoorFrom(r.Context()) && !fromTunnel(r.Context()) {
out.guard = e.newGuardState()
}
diff --git a/internal/edge/homemap.go b/internal/edge/homemap.go
index d2c9b1526..9820ad0fb 100644
--- a/internal/edge/homemap.go
+++ b/internal/edge/homemap.go
@@ -101,10 +101,6 @@ const (
hopHeader = "X-Carlos-Hop"
hopAuthHeader = "X-Carlos-Hop-Auth"
hopDoorHeader = "X-Carlos-Hop-Door"
- // hopCheckedHeader is the checked mark (signHopChecked): the sending
- // edge's hard and probe checks matched this request, and it records the
- // request itself.
- hopCheckedHeader = "X-Carlos-Hop-Checked"
)
// edgeRoleHome is the only role v1 writes, and the only one that routes.
@@ -1234,32 +1230,17 @@ func hopDoorFrom(ctx context.Context) bool {
return v
}
-// hopCheckedKey marks a verified hop whose sender vouched, with
-// X-Carlos-Hop-Checked, that its hard and probe checks matched the request
-// and that it has recorded it (a far edge's asset catch, serveAssetFar). Set
-// only beside hopVerifiedKey. It means "already recorded", not "already
-// judged": this box still runs its own checks and refuses the request when
-// its mode blocks, and only its request record (observeRecords) is skipped,
-// so the match is recorded once; it exempts nothing else.
-type hopCheckedKey struct{}
-
-func hopCheckedFrom(ctx context.Context) bool {
- v, _ := ctx.Value(hopCheckedKey{}).(bool)
- return v
-}
-
// acceptHop is the whole of hop handling on the request path, and it runs
// before the route lookup so that BOTH of its outcomes are decided ahead of
// anything that serves:
//
-// no hop header → nothing happens beyond deleting the door and
-// checked marks (the overwhelming case: a few header
-// lookups on a request that is not a hop).
+// no hop header → nothing happens beyond deleting the door mark (the
+// overwhelming case: a few header lookups on a request
+// that is not a hop).
// verified hop → the mark goes on the context, the inbound
// X-Forwarded-For is believed, and the caller serves
// the route locally or refuses (staleHopRefusal). A
-// door mark that verifies adds hopDoorKey; a checked
-// mark that verifies adds hopCheckedKey.
+// door mark that verifies adds hopDoorKey.
// unverified hop → every forwarded header is stripped and the sender is
// an ordinary client from here on.
//
@@ -1279,8 +1260,6 @@ func (e *Edge) acceptHop(r *http.Request, host string) (*http.Request, bool) {
// and only when it is a single value.
door := r.Header.Values(hopDoorHeader)
r.Header.Del(hopDoorHeader)
- checked := r.Header.Values(hopCheckedHeader)
- r.Header.Del(hopCheckedHeader)
if r.Header.Get(hopHeader) == "" {
// A signature with no marker beside it is not a hop — but it is still
// this edge's vocabulary, and the invariant above is "deleted in ALL
@@ -1317,9 +1296,6 @@ func (e *Edge) acceptHop(r *http.Request, host string) (*http.Request, bool) {
if len(door) == 1 && verifyHopDoorEitherKey(current, next, host, door[0], now) {
ctx = context.WithValue(ctx, hopDoorKey{}, true)
}
- if len(checked) == 1 && verifyHopCheckedEitherKey(current, next, host, checked[0], now) {
- ctx = context.WithValue(ctx, hopCheckedKey{}, true)
- }
return r.WithContext(ctx), true
}
diff --git a/internal/edge/mesh.go b/internal/edge/mesh.go
index 086a003dd..54d21b992 100644
--- a/internal/edge/mesh.go
+++ b/internal/edge/mesh.go
@@ -266,28 +266,6 @@ func verifyHopDoorEitherKey(current, next []byte, host, header string, now time.
return len(current) > 0 && verifyHopMAC(current, hopDoorDomain, host, header, now)
}
-// hopCheckedDomain separates the checked mark's MAC from the hop's and the
-// door mark's, by the same NUL argument as hopDoorDomain.
-const hopCheckedDomain = "checked\x00"
-
-// signHopChecked produces the value of the X-Carlos-Hop-Checked header, which
-// a far edge's asset catch adds to every hop it sends for a request its own
-// hard and probe checks matched and that it records itself (serveAssetFar).
-// Same key, host and timestamp format as signHop, in its own MAC domain.
-func signHopChecked(key []byte, host string, now time.Time) string {
- ts := strconv.FormatInt(now.Unix(), 10)
- return ts + ":" + hex.EncodeToString(hopMAC(key, hopCheckedDomain, host, ts))
-}
-
-// verifyHopCheckedEitherKey is verifyHopEitherKey for the checked mark.
-// acceptHop consults it only once the hop itself has verified.
-func verifyHopCheckedEitherKey(current, next []byte, host, header string, now time.Time) bool {
- if len(next) > 0 && verifyHopMAC(next, hopCheckedDomain, host, header, now) {
- return true
- }
- return len(current) > 0 && verifyHopMAC(current, hopCheckedDomain, host, header, now)
-}
-
// hopMAC is the MAC signHop and verifyHop both compute — one place so the
// two can never drift out of sync on what bytes are actually signed, and
// the one choke point that canonicalizes host before it enters the MAC.
diff --git a/internal/edge/reqrecords.go b/internal/edge/reqrecords.go
index 38cdb66b6..4a9d5a812 100644
--- a/internal/edge/reqrecords.go
+++ b/internal/edge/reqrecords.go
@@ -60,10 +60,8 @@ func (e *Edge) observeRecords(rt registry.Route, viaTunnel bool, r *http.Request
return
}
// One record per served response, observeAnalytics's rule: the hub that
- // forwarded this over the tunnel records it from its own defer, and a
- // far edge whose checks matched a hop it sent, and that marked it
- // checked, records it itself (serveAssetFar).
- if fromTunnel(r.Context()) || hopCheckedFrom(r.Context()) {
+ // forwarded this over the tunnel records it from its own defer.
+ if fromTunnel(r.Context()) {
return
}
status := ob.status