carlos / platform Public

host: link fixes: cancel before state, strict forwarded chain

Task 8 fix round 2 (Astra items 1 and 2, Fable minor).

- stop cancels the run before it takes the state lock or writes the
  registry, so a revocation never waits on a state write.
- A linked request's X-Forwarded-For reaches the app, and keys the
  gate's attempt limit, only when every entry is an IP; otherwise both
  keep the connection peer.
- The obsolete-run check runs straight after the link row is read,
  before the claim, its re-read and the published-set read.
- Census overlay linked-deployments-slice1 re-proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev e0994445e6c635470d1161368573923570c6e654 parent 05508d0
8 files changed, +263 −64
  • docs/superpowers/notes/census-proposal-linked-deployments-slice1.md +4 −3
  • internal/edge/edge.go +29 −22
  • internal/edge/homemap.go +7 −6
  • internal/edge/linkpin_test.go +90 −0
  • internal/host/link_client.go +50 −27
  • internal/host/link_e2e_test.go +75 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-linked-deployments-slice1.tsv +7 −5
diff --git a/docs/superpowers/notes/census-proposal-linked-deployments-slice1.md b/docs/superpowers/notes/census-proposal-linked-deployments-slice1.md
index bd28a0737..129c16bcd 100644
--- a/docs/superpowers/notes/census-proposal-linked-deployments-slice1.md
+++ b/docs/superpowers/notes/census-proposal-linked-deployments-slice1.md
@@ -1,6 +1,6 @@
# Census approval: linked-deployments-slice1
-Ruling `census-ruling-linked-deployments-slice1`. The independent reviewer approves or rejects every change below, 39 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+Ruling `census-ruling-linked-deployments-slice1`. The independent reviewer approves or rejects every change below, 40 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
| unit | change | read sites | what changed |
|---|---|---|---|
@@ -62,7 +62,8 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/edge/edge.go:Edge.pinnedUpstream`: reads +registry:Account, +registry:App, +registry:Host, +registry:Kind, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/edge/fleetforward.go:linkServeEligible`: reads +registry:Account ×3, +registry:FleetBox, +registry:FleetBoxes, +registry:FleetLabel; written legacy, accepted-legacy, frozen
-- new `internal/host/link_client.go:linkLoopState.pass`: reads +registry:BoxLabel ×4, +registry:ConnGen, +registry:ID ×4, +registry:Name, +registry:Token, +registry:TunnelURL, +whole:HomeLink ×4, +whole:HomeLinkApp ×9; written legacy, accepted-legacy, frozen
+- new `internal/host/link_client.go:linkLoopState.dropObsolete`: reads +registry:BoxLabel, +registry:ConnGen, +registry:ID, +registry:Token, +registry:TunnelURL; written legacy, accepted-legacy, frozen
+- new `internal/host/link_client.go:linkLoopState.pass`: reads +registry:BoxLabel ×4, +registry:ID ×3, +registry:Name, +whole:HomeLink ×6, +whole:HomeLinkApp ×9; written legacy, accepted-legacy, frozen
- new `internal/host/link_client.go:linkLoopState.start`: reads +registry:ConnGen, +registry:ID ×3, +registry:Token ×2, +registry:TunnelURL ×3, +whole:HomeLinkApp ×3; written legacy, accepted-legacy, frozen
- new `internal/host/link_client.go:linkSetNarrowed`: reads +whole:HomeLinkApp ×4; written legacy, accepted-legacy, frozen
- new `internal/host/link_handler.go:linkHandler.ServeHTTP`: reads +registry:HomeAccount ×2, +registry:HomeApp ×2, +registry:HomeHost ×2, +whole:HomeLinkApp; written legacy, accepted-legacy, frozen
@@ -100,6 +101,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- reads `internal/provision/forward.go:forwardView.retirements`: +registry:Region; keeps legacy, task accepted-legacy
- reads `internal/registry/remote_dispatch.go:Registry.dispatchRemote`: +registry:Changed ×5, +registry:HomeLink ×2, +registry:HomeLinkApp ×2, +registry:HomeLinkApps, +registry:Host, +registry:Label, +registry:Link, +registry:LinkID ×5, +registry:LinkSeen, +registry:Name ×2, +registry:Number64, +registry:On ×2, +registry:Routes, +registry:SeenAt, +registry:Seq, +registry:Status, +registry:StringMap ×2, +whole:HomeLink ×2, +whole:HomeLinkApp ×3, +whole:LinkChannel, +whole:LinkSeen, +whole:Route; keeps hint, task E2
-Seal: `6d3ea7fccce1a7f4bc507b6eb8d368ed0b62f83022504aa04c7684c72c93aa9a` → `0b8e44b7660274dbbd5d31545dc5704db2f3cfd2838fd982993a31c8436d15b9`.
+Seal: `6d3ea7fccce1a7f4bc507b6eb8d368ed0b62f83022504aa04c7684c72c93aa9a` → `91a9fbb640ba280de65c041879cc84d5ef6a0137a576d789733dc03eb6946cae`.
Overlay: `internal/provision/testdata/plan14-root-reads-linked-deployments-slice1.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/edge/edge.go b/internal/edge/edge.go
index f7bde5d78..fb50e2c56 100644
--- a/internal/edge/edge.go
+++ b/internal/edge/edge.go
@@ -2044,11 +2044,12 @@ func linkedRequest(ctx context.Context) bool {
// want.PublicHost (gate.WithPublicHost), and the app is sent
// Host and X-Forwarded-Host want.PublicHost with X-Forwarded-Proto
// https (linkedBackend, setForwarded).
-// - The visitor: the hub's X-Forwarded-For chain goes to the app as the
-// hub sent it (setForwarded), and the gate's attempt limiter keys on its
-// last entry, the client the hub observed (linkVisitor,
-// gate.WithClientAddr), not on the tunnel's address every visitor
-// shares.
+// - The visitor: when the hub's X-Forwarded-For is well formed
+// (linkVisitor: every entry an IP), the chain goes to the app
+// (setForwarded) and the gate's attempt limiter keys on its last entry,
+// the client the hub observed (gate.WithClientAddr), not on the
+// tunnel's address every visitor shares. A malformed or missing header
+// changes nothing: the app and the limiter see the connection peer.
// - No caching at home in either direction: the response LRU, the page
// cache and the asset catch are skipped, so an answer made for one
// origin is never replayed to the other. A Carlos-Purge-Host naming
@@ -2060,7 +2061,7 @@ func linkedRequest(ctx context.Context) bool {
// the request.
func (e *Edge) ServeLinked(w http.ResponseWriter, r *http.Request, want LinkedTarget) {
ctx := gate.WithPublicHost(withLinkPin(r.Context(), want), want.PublicHost)
- if visitor, ok := linkVisitor(r.Header); ok {
+ if visitor, _, ok := linkVisitor(r.Header); ok {
ctx = gate.WithClientAddr(ctx, visitor)
}
r = r.WithContext(ctx)
@@ -2070,23 +2071,29 @@ func (e *Edge) ServeLinked(w http.ResponseWriter, r *http.Request, want LinkedTa
// linkVisitor is a linked request's visitor: the last X-Forwarded-For entry,
// the client address the hub observed and appended (the hub never passes a
-// client's own X-Forwarded-For on). Only a linked request is read this way
-// (ServeLinked): on every other ingress the header is the client's to
-// forge. False when there is no entry or it is not an IP address.
-func linkVisitor(h http.Header) (string, bool) {
- chain := strings.Join(h.Values("X-Forwarded-For"), ",")
- if chain == "" {
- return "", false
- }
- last := chain
- if i := strings.LastIndexByte(chain, ','); i >= 0 {
- last = chain[i+1:]
- }
- ip := net.ParseIP(strings.TrimSpace(last))
- if ip == nil {
- return "", false
+// client's own X-Forwarded-For on), and the whole chain, normalized. Only a
+// linked request is read this way (ServeLinked, setForwarded): on every
+// other ingress the header is the client's to forge. It accepts the header
+// only when every entry, on every line, is an IP address; anything else
+// (no header, an empty one, an empty or malformed entry anywhere) is false,
+// and the request keeps the connection peer as its client, as any request
+// does.
+func linkVisitor(h http.Header) (visitor, chain string, ok bool) {
+ lines := h.Values("X-Forwarded-For")
+ if len(lines) == 0 {
+ return "", "", false
+ }
+ var ips []string
+ for _, line := range lines {
+ for _, entry := range strings.Split(line, ",") {
+ ip := net.ParseIP(strings.TrimSpace(entry))
+ if ip == nil {
+ return "", "", false
+ }
+ ips = append(ips, ip.String())
+ }
}
- return ip.String(), true
+ return ips[len(ips)-1], strings.Join(ips, ", "), true
}
// selectUpstream is where a request's upstream is chosen: the only
diff --git a/internal/edge/homemap.go b/internal/edge/homemap.go
index 23a091ee0..5e312a816 100644
--- a/internal/edge/homemap.go
+++ b/internal/edge/homemap.go
@@ -1689,13 +1689,14 @@ func setForwarded(pr *httputil.ProxyRequest) {
defer signForwarded(pr)
// A linked request (ServeLinked) reaches its app as the visitor sent it
// to the serving side: the public host (linkedBackend has already made
- // it pr.In.Host, so Host and the proof agree) over https, and the hub's
- // X-Forwarded-For chain, whose last entry is the client the hub
- // observed, rather than the tunnel's address SetXForwarded wrote. It
- // is never a door call or a hop.
+ // it pr.In.Host, so Host and the proof agree) over https, and, when
+ // linkVisitor accepts it, the hub's X-Forwarded-For chain (normalized),
+ // whose last entry is the client the hub observed. A chain it refuses
+ // never reaches the app: SetXForwarded's value, the connection peer,
+ // stays. It is never a door call or a hop.
if want, pinned := linkPinFrom(pr.In.Context()); pinned {
- if chain := pr.In.Header.Values("X-Forwarded-For"); len(chain) > 0 {
- pr.Out.Header.Set("X-Forwarded-For", strings.Join(chain, ", "))
+ if _, chain, ok := linkVisitor(pr.In.Header); ok {
+ pr.Out.Header.Set("X-Forwarded-For", chain)
}
pr.Out.Header.Set("X-Forwarded-Host", want.PublicHost)
pr.Out.Header.Set("X-Forwarded-Proto", "https")
diff --git a/internal/edge/linkpin_test.go b/internal/edge/linkpin_test.go
index 6176ddc7f..43f661fe7 100644
--- a/internal/edge/linkpin_test.go
+++ b/internal/edge/linkpin_test.go
@@ -11,6 +11,7 @@ import (
"io"
"net/http"
"net/http/httptest"
+ "net/url"
"os"
"path/filepath"
"sort"
@@ -21,6 +22,7 @@ import (
"time"
"github.com/carlosframework/platform/internal/assetcache"
+ "github.com/carlosframework/platform/internal/gate"
"github.com/carlosframework/platform/internal/registry"
)
@@ -323,3 +325,91 @@ func TestLinkPinNoAssetCatchReplay(t *testing.T) {
}
linked(4)
}
+
+// A linked request's X-Forwarded-For becomes the app's view of the visitor,
+// and the gate's attempt key, only when every entry is an IP address.
+// Otherwise both fall back to the connection's peer, as for any request.
+func TestLinkPinForwardedFallback(t *testing.T) {
+ dir := genSockDir(t)
+ var mu sync.Mutex
+ var xff []string
+ app := startGenApp(t, filepath.Join(dir, "a.sock"), http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ mu.Lock()
+ xff = append(xff, strings.Join(r.Header.Values("X-Forwarded-For"), ", "))
+ mu.Unlock()
+ io.WriteString(w, "app")
+ }))
+ reg := openReg(t)
+ if err := reg.Upsert(registry.Route{Host: laHost, Kind: "instance", Socket: app.sock, Status: "ready", Account: "abc", App: "shop"}); err != nil {
+ t.Fatal(err)
+ }
+ e, err := New(reg, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(e.probers.Stop)
+ want := LinkedTarget{Host: laHost, Account: "abc", App: "shop", PublicHost: "shop.pub.example.com"}
+ const peer = "192.0.2.10"
+ serve := func(method, path, chain, body string) *httptest.ResponseRecorder {
+ req := httptest.NewRequest(method, "http://"+want.PublicHost+path, strings.NewReader(body))
+ req.RemoteAddr = peer + ":40000"
+ if chain != "-" {
+ req.Header.Set("X-Forwarded-For", chain)
+ }
+ if body != "" {
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ }
+ rec := httptest.NewRecorder()
+ e.ServeLinked(rec, req, want)
+ return rec
+ }
+ cases := []struct{ chain, app string }{
+ {"198.51.100.7", "198.51.100.7"},
+ {"203.0.113.5, 198.51.100.7", "203.0.113.5, 198.51.100.7"},
+ {"198.51.100.7, invalid", peer},
+ {"invalid, 198.51.100.7", peer},
+ {"", peer},
+ {"-", peer},
+ {"198.51.100.7,", peer},
+ }
+ for _, c := range cases {
+ mu.Lock()
+ xff = nil
+ mu.Unlock()
+ if rec := serve("GET", "/", c.chain, ""); rec.Code != 200 {
+ t.Fatalf("X-Forwarded-For %q: %d", c.chain, rec.Code)
+ }
+ mu.Lock()
+ got := strings.Join(xff, "|")
+ mu.Unlock()
+ if got != c.app {
+ t.Errorf("X-Forwarded-For %q: the app saw %q, want %q", c.chain, got, c.app)
+ }
+ }
+
+ hash, err := gate.Hash("shop-password")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.SetGate(laHost, hash); err != nil {
+ t.Fatal(err)
+ }
+ if err := e.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ wrong := url.Values{"password": {"nope-nope-nope"}, "next": {"/"}}.Encode()
+ login := func(chain string) int { return serve("POST", gate.LoginPath, chain, wrong).Code }
+ // Ten malformed or missing chains from one peer share the peer's bucket.
+ bad := []string{"198.51.100.7, invalid", "", "-", "x", "invalid, 198.51.100.8"}
+ for i := 0; i < 10; i++ {
+ if code := login(bad[i%len(bad)]); code != http.StatusUnauthorized {
+ t.Fatalf("attempt %d: %d, want 401", i+1, code)
+ }
+ }
+ if code := login("198.51.100.7, also-invalid"); code != http.StatusTooManyRequests {
+ t.Fatalf("an 11th malformed attempt from the peer: %d, want 429 (the peer's bucket)", code)
+ }
+ if code := login("198.51.100.9"); code != http.StatusUnauthorized {
+ t.Fatalf("a well-formed visitor through the same peer: %d, want its own 401", code)
+ }
+}
diff --git a/internal/host/link_client.go b/internal/host/link_client.go
index 4a2378e67..e6b96cd6d 100644
--- a/internal/host/link_client.go
+++ b/internal/host/link_client.go
@@ -169,6 +169,10 @@ func (l *linkLoopState) pass() (retry bool) {
l.stop("the deployment is not linked", linkStopIdle)
return false
}
+ // What the link row alone says is obsolete is closed before anything
+ // else is attempted (a claim, a re-read, the published set): a
+ // revocation must not wait on them.
+ l.dropObsolete(link)
if link.BoxLabel == "" {
if _, err := d.reg.ClaimHomeLink(d.label); err != nil {
d.logf("agent: link %s: claiming as box %s: %v", link.ID, d.label, err)
@@ -183,6 +187,7 @@ func (l *linkLoopState) pass() (retry bool) {
l.stop("the deployment is not linked", linkStopIdle)
return false
}
+ l.dropObsolete(link)
if link.BoxLabel == d.label {
d.logf("agent: link %s: claimed as box %s", link.ID, d.label)
}
@@ -191,20 +196,6 @@ func (l *linkLoopState) pass() (retry bool) {
l.stop("box "+link.BoxLabel+" holds the link", linkStopLost)
return false
}
- // What the link row alone says is obsolete is closed before anything
- // else is read: a revocation must not wait on the published set.
- if c := l.cur; c != nil {
- switch {
- case c.id != link.ID:
- l.stop("the link was replaced", linkStopReplace)
- case c.token != link.Token:
- l.stop("the link's key was rotated", linkStopReplace)
- case c.url != link.TunnelURL:
- l.stop("the link's tunnel address changed", linkStopReplace)
- case c.gen != link.ConnGen:
- l.stop("an app was unpublished or retargeted", linkStopReplace)
- }
- }
apps, err := d.reg.HomeLinkApps()
if err != nil {
d.logf("agent: link %s: reading the published set: %v", link.ID, err)
@@ -228,6 +219,32 @@ func (l *linkLoopState) pass() (retry bool) {
return false
}
+// dropObsolete stops the running tunnel when link, as just read, is not the
+// link it was started for: another link ID, a rotated token, another
+// tunnel URL, or a moved conn_gen (an unpublish or retarget). It records
+// "reconnecting" only when this box holds link; otherwise the state is not
+// this box's to write.
+func (l *linkLoopState) dropObsolete(link *registry.HomeLink) {
+ c := l.cur
+ if c == nil {
+ return
+ }
+ kind := linkStopLost
+ if link.BoxLabel == l.d.label {
+ kind = linkStopReplace
+ }
+ switch {
+ case c.id != link.ID:
+ l.stop("the link was replaced", kind)
+ case c.token != link.Token:
+ l.stop("the link's key was rotated", kind)
+ case c.url != link.TunnelURL:
+ l.stop("the link's tunnel address changed", kind)
+ case c.gen != link.ConnGen:
+ l.stop("an app was unpublished or retargeted", kind)
+ }
+}
+
// linkSetNarrowed reports whether a name in was is gone from now or names
// another home app, account or host there.
func linkSetNarrowed(was, now map[string]registry.HomeLinkApp) bool {
@@ -280,17 +297,26 @@ func (l *linkLoopState) reportState(run *linkRun, s string) {
}
}
-// stop cancels the running tunnel, if any, records the state kind says,
-// and returns the stopped run (nil when none ran). Cancelling closes the
-// run's connection and every stream on it; the caller waits on its done
-// only when it must (the agent stopping): a replacement starts at once.
+// stop cancels the running tunnel, if any, then records the state kind
+// says, and returns the stopped run (nil when none ran). Cancelling closes
+// the run's connection and every stream on it, and comes first, before
+// the lock or the registry: a revocation never waits on a state write
+// (which may sit behind another SQLite writer). The caller waits on the
+// run's done only when it must (the agent stopping): a replacement starts
+// at once.
func (l *linkLoopState) stop(why string, kind linkStopKind) *linkRun {
- l.mu.Lock()
+ // cur is written only on this goroutine, so it is read here unlocked.
c := l.cur
if c == nil {
- l.mu.Unlock()
return nil
}
+ c.cancel()
+ l.d.logf("agent: link %s: closing the connection: %s", c.id, why)
+ // The bookkeeping, serialized with the run's own reports: once cur is
+ // cleared under mu, a late report from c is dropped, and this write is
+ // the last one c's run makes.
+ l.mu.Lock()
+ defer l.mu.Unlock()
l.cur = nil
var state string
switch kind {
@@ -298,15 +324,12 @@ func (l *linkLoopState) stop(why string, kind linkStopKind) *linkRun {
state = registry.HomeLinkReconnecting
case linkStopIdle:
state = ""
+ case linkStopLost:
+ return c
}
- if kind != linkStopLost {
- if err := l.d.reg.SetHomeLinkState(state); err != nil {
- l.d.logf("agent: link %s: recording state %q: %v", c.id, state, err)
- }
+ if err := l.d.reg.SetHomeLinkState(state); err != nil {
+ l.d.logf("agent: link %s: recording state %q: %v", c.id, state, err)
}
- l.mu.Unlock()
- l.d.logf("agent: link %s: closing the connection: %s", c.id, why)
- c.cancel()
return c
}
diff --git a/internal/host/link_e2e_test.go b/internal/host/link_e2e_test.go
index 3796dd343..790cb15d1 100644
--- a/internal/host/link_e2e_test.go
+++ b/internal/host/link_e2e_test.go
@@ -1150,3 +1150,78 @@ func TestLinkVisitorIdentity(t *testing.T) {
t.Fatalf("tailnet 11th attempt with a new forged X-Forwarded-For: %d, want 429", code)
}
}
+
+// linkStallReg can hold SetHomeLinkState (as a SQLite writer holding the
+// lock would) and fail ClaimHomeLink, on top of the real registry.
+type linkStallReg struct {
+ *registry.Registry
+ stall atomic.Bool
+ release chan struct{}
+ stalled atomic.Int32
+ failClaim atomic.Bool
+}
+
+func (r *linkStallReg) SetHomeLinkState(s string) error {
+ if r.stall.Load() {
+ r.stalled.Add(1)
+ <-r.release
+ }
+ return r.Registry.SetHomeLinkState(s)
+}
+
+func (r *linkStallReg) ClaimHomeLink(label string) (bool, error) {
+ if r.failClaim.Load() {
+ return false, errors.New("claim failed")
+ }
+ return r.Registry.ClaimHomeLink(label)
+}
+
+func newLinkStallWorld(t *testing.T) (*linkWorld, *linkStallReg) {
+ t.Helper()
+ w := newLinkWorld(t, true, map[string]string{"shop": "shop", "blog": "blog"})
+ stall := &linkStallReg{Registry: w.homeReg, release: make(chan struct{})}
+ w.loopReg = stall
+ w.startLoop(t)
+ // Runs before the loop's own cleanup (LIFO), so a held write lets go.
+ t.Cleanup(func() { close(stall.release) })
+ w.waitConnected(t)
+ linkWait(t, "state connected", func() bool {
+ l, err := w.homeReg.HomeLink()
+ return err == nil && l.State == registry.HomeLinkConnected
+ })
+ return w, stall
+}
+
+// A revocation cancels the run even while state writes cannot complete.
+func TestLinkRevocationDoesNotWaitOnStateWrite(t *testing.T) {
+ w, stall := newLinkStallWorld(t)
+ sse := w.openSSE(t, "shop")
+ stall.stall.Store(true)
+ if ok, err := w.homeReg.DeleteHomeLinkApp("blog"); err != nil || !ok {
+ t.Fatalf("DeleteHomeLinkApp = %v, %v", ok, err)
+ }
+ resumed := time.Now()
+ w.reloadHome(t)
+ linkEndsWithin(t, "shop's SSE response with state writes held", sse, resumed, linkWatch)
+ if stall.stalled.Load() == 0 {
+ t.Fatal("no state write was held: the test proved nothing")
+ }
+}
+
+// A link replaced by another (new ID, unclaimed) closes the old link's
+// connection even while the claim fails.
+func TestLinkReplacedDoesNotWaitOnClaim(t *testing.T) {
+ w, stall := newLinkStallWorld(t)
+ sse := w.openSSE(t, "shop")
+ stall.failClaim.Store(true)
+ if err := w.homeReg.PutHomeLink(registry.HomeLink{ID: "ba9876543210", ServingURL: "https://console.example.com",
+ TunnelURL: w.hubURL, Token: "other-token", Account: linkServingAcct, AppsDomain: "apps.example.com"}); err != nil {
+ t.Fatal(err)
+ }
+ resumed := time.Now()
+ w.reloadHome(t)
+ linkEndsWithin(t, "the old link's SSE response with the claim failing", sse, resumed, linkWatch)
+ if l, err := w.homeReg.HomeLink(); err != nil || l.ID != "ba9876543210" || l.BoxLabel != "" {
+ t.Fatalf("HomeLink = %+v, %v; want the new link, unclaimed", l, err)
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index fad786bca..ced109099 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -155,4 +155,4 @@ plan14-root-reads-gvisor-probe-diag.tsv a9ae6b238b6b2e177be1f9c7ae06ea0f24477e4e
plan14-root-reads-deploy-happy-path.tsv a9ae6b238b6b2e177be1f9c7ae06ea0f24477e4eb0e58abda63f4b7337dbe3ee
plan14-root-reads-held-move-speed.tsv 837f27a6b7b6ed272f8c68aca07650fa32cf3ec92ce28bf9d812a4282eeb0b58
plan14-root-reads-litestream-quiet-802.tsv 6d3ea7fccce1a7f4bc507b6eb8d368ed0b62f83022504aa04c7684c72c93aa9a
-plan14-root-reads-linked-deployments-slice1.tsv 0b8e44b7660274dbbd5d31545dc5704db2f3cfd2838fd982993a31c8436d15b9
+plan14-root-reads-linked-deployments-slice1.tsv 91a9fbb640ba280de65c041879cc84d5ef6a0137a576d789733dc03eb6946cae
diff --git a/internal/provision/testdata/plan14-root-reads-linked-deployments-slice1.tsv b/internal/provision/testdata/plan14-root-reads-linked-deployments-slice1.tsv
index a6029dbc9..b06df1f10 100644
--- a/internal/provision/testdata/plan14-root-reads-linked-deployments-slice1.tsv
+++ b/internal/provision/testdata/plan14-root-reads-linked-deployments-slice1.tsv
@@ -1,6 +1,6 @@
# Census overlay linked-deployments-slice1, written by census-propose (#369). census-ruling-linked-deployments-slice1, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-linked-deployments-slice1.md.
# 15 body, 8 sites, 8 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
-# 39 new dispositions: 4 reads re-frozen at their disposition with the claim, 34 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 1 other.
+# 40 new dispositions: 4 reads re-frozen at their disposition with the claim, 35 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 1 other.
@legacy 1cb1c2d61f2c9cac86a37ae03cbc610d0a6adb9862c436283aae7af1203081a2 internal/edge/demo.go Edge.handleDemoRequest legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-2;basis=demo.go:87-109 classifies request authority using the loaded refusal/upstream maps and checks the existing Route binding before protected dispatch. Five whole Route uses; malformed, unknown and expired names receive fixed policy-bearing refusals, never ordinary fallback. No new storage read.;rev3=census-ruling-agent-start-demo-3;basis=Check verified moved notices before route lookup so a purged source can still display its bounded notice. Census read-site delta: unchanged (5).;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: the upstream comes from selectUpstream(r, host, path), which is lookupUpstreamPath(host, path) unless the request carries a link pin; same reads whole:Route@446,whole:Route@513,whole:Route@554,whole:Route@770,whole:Route@812 a6d6ab6a73419e8fd1e9e38b2b3be8dab387a2fc119ced5eb35fa73ed9feb581
@legacy 22be9ee0cf964afa8a4748c7c1ccfab5f0982a634e1905b6eef02024cf4f2bc6 internal/edge/demo.go Edge.redirectDemoRequest legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-2;basis=demo.go:87-102 answers a plain-HTTP demo request with a 308 to the same host and path over HTTPS, with demo policy headers, only after the loaded Route, alias and serving checks pass; reads only the already-loaded Route (whole value), never dispatches, counts or opens anything.;rev3=census-ruling-agent-start-demo-3;basis=Serve signed moved notices at the demo redirect entry before redirecting; retain exact-host validation. Census read-site delta: unchanged (3).;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: the upstream comes from selectUpstream(r, host, path), which is lookupUpstreamPath(host, path) unless the request carries a link pin (never on :80); same reads whole:Route@296,whole:Route@338,whole:Route@432 db1a9db900e5f41fd5f4696bd72bac7b7f038fcfce1beae6a2cd0c3465f431bb
@legacy 692b495a9271d335562f5eafe3992156fe67947a51a727bca8116f4e16f3eff9 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 registry:App@2655,registry:DemoExpiresAt@1390,registry:Kind@6523,whole:Route@1089,whole:Route@1393,whole:Route@1532,whole:Route@1619,whole:Route@1742,whole:Route@223,whole:Route@2266,whole:Route@2582,whole:Route@2647,whole:Route@2658,whole:Route@2744,whole:Route@2840,whole:Route@2914,whole:Route@2961,whole:Route@3019,whole:Route@3048,whole:Route@3267,whole:Route@3298,whole:Route@3330,whole:Route@3703,whole:Route@375,whole:Route@4367,whole:Route@4417,whole:Route@4469,whole:Route@454,whole:Route@4708,whole:Route@5473,whole:Route@6016,whole:Route@6526,whole:Route@6974 e967e257733b9d3afe3c2cf256b9ff2156b9b1b593ef37fe97df6f132abfd77e
@@ -16,7 +16,8 @@
@legacy 016a166915f0e50879425a00398d783afebf2c3f2b138fe7303689dc5be0933a internal/registry/registry.go Registry.migrate legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user), on every registry open; a box CLI verb that opens the registry directly runs it as whoever runs the verb: census-ruling-seeded-instances's body with two more columns added to routes (incarnation and serving_seq, INTEGER NOT NULL DEFAULT 0, idempotent through the duplicate-column rule); self-serve moves 1 Task 7;rev3=census-ruling-rootfs-apps-2;basis=one more ALTER TABLE, routes ADD COLUMN runtime TEXT NOT NULL DEFAULT '', beside main's rate_limit, assets_off, asset_gen, incarnation and serving_seq (the last four from the merges of origin/main 3c33f2eb and 953b9fda); the same sixteen sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328/#329 plan 1 Task 4: three more ALTER TABLE statements in the existing loop, routes ADD COLUMN egress_allow, size and policy_expires_at, each TEXT NOT NULL DEFAULT '' and idempotent through the duplicate-column rule; the same sixteen sites, no read added.;rev3=census-ruling-region-ha-p1a;basis=one more ALTER TABLE in the existing loop: routes ADD COLUMN ha INTEGER NOT NULL DEFAULT 0, idempotent through the duplicate-column rule; the same sixteen sites, no read added;rev3=census-ruling-ha-p1a-433;basis=the registry's SQLite side as carlos (agent, registry child; a box CLI verb that opens the registry directly runs it as whoever runs it), on every registry open: the ALTER TABLE routes statements are now built from the one migration definition routeAddedColumns (addedColumn name, type, default; review r1 P2): for each entry without the Claim mark, "ALTER TABLE routes ADD COLUMN " + spec(), byte for byte the statements main runs, in main's order, under the same duplicate-column rule. +registry:Claim is that mark, +whole:addedColumn the struct. Every name, type and default is an in-binary literal; no statement added, removed or changed; no read added.;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: one more CREATE TABLE IF NOT EXISTS regional_domains (host TEXT PRIMARY KEY, target, account, app, region TEXT NOT NULL DEFAULT '', created_at INTEGER NOT NULL DEFAULT 0), beside wildcard_domains; the added sites are that statement (+file:Exec, +registry:sql), an in-binary literal; additive, no existing statement changed;rev3=census-ruling-region-ha-p1b3b-t;basis=Create local HA duty/replay tables and revision triggers in the existing registry connection; no new database path.;rev3=census-ruling-agent-start-demo-3;basis=Create moved-notice storage as a single (id, wire) row; fingerprints include the stored wire bytes. Census read-site delta: +file:Exec, +registry:sql.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: calls migrateLinks after migrateHADuties (one CREATE TABLE IF NOT EXISTS link_channels, an in-binary literal); additive, no existing statement changed; linked deployments slice 1 Task 7: also runs migrateHomeLink (CREATE TABLE IF NOT EXISTS home_link and home_link_apps) after migrateLinks; additive, the box's own registry database, as carlos file:Exec@1124,file:Exec@1855,file:Exec@212,file:Exec@2409,file:Exec@3347,file:Exec@3626,file:Exec@4489,file:Exec@4665,file:Exec@51,file:Exec@761,registry:Claim@686,registry:sql@1124,registry:sql@1855,registry:sql@212,registry:sql@2409,registry:sql@3347,registry:sql@3626,registry:sql@4489,registry:sql@4665,registry:sql@51,registry:sql@761,whole:addedColumn@661 63fc63e2dd8bcd22c23e590d7e79f2996c31e0edc94aa1da2d48646f99c64ef2
@legacy f859ac9ca9fc6e6e2f12190382770c2913ea39e0dd915557aa75b5396d3925f6 internal/edge/edge.go Edge.pinnedUpstream legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; a linked request's upstream: the exact in-memory routing-map entry for the pinned home host, admitted only when its route is that host's own row for the pinned account and app, an instance, not forward, demo or sidecar, served from this box; reads the route fields of the map entry the last Reload built, no registry, file or bucket read registry:Account@435,registry:App@466,registry:Host@156,registry:Kind@331,whole:Route@146 9e26e286bc9973a11697c46766f19587f791fb83cf4275d3ed6df2d638ec03a8
@legacy a10d080a12c01e05c132febd9e72b6656c340866c1749be14ba9e1f142d8e1ea internal/edge/fleetforward.go linkServeEligible legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: new pure rule for a link-placed forward row: refused off the hub, when not inert, when it carries a fleet box, label or replica set, when its link is not in the active link owners, or when its raw Account is empty or not the link's owner; reads only the row and the owners map registry:Account@567,registry:Account@636,registry:Account@720,registry:FleetBox@277,registry:FleetBoxes@321,registry:FleetLabel@298 e15bfdfc2c2928ccd325b8844346be778eb5e186bd7898c2f21bf84c7574dde7
-@legacy f860132d57fd2caeb25fa014f4623c9f134f49fb7035abbee16294698ec8c4a0 internal/host/link_client.go linkLoopState.pass legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; the home link loop's pass: reads HomeLink and HomeLinkApps from the agent's own registry, claims an unclaimed link with ClaimHomeLink(label) unless this is a fleet box (tunnelEnvComplete), and starts, keeps or cancels the link's tunnel by link ID, token, tunnel URL, conn_gen and the published set; no file or bucket read, nothing executed; fix round 1: a run the link row alone shows obsolete (link ID, token, tunnel URL or conn_gen changed) is cancelled before HomeLinkApps is read, so a failing set read cannot hold a revoked connection open; stops record the link state as reconnecting (replaced), empty (unlinked, fleet box) or nothing (another box holds the claim); same reads registry:BoxLabel@1004,registry:BoxLabel@429,registry:BoxLabel@858,registry:BoxLabel@961,registry:ConnGen@1520,registry:ID@1260,registry:ID@1718,registry:ID@561,registry:ID@932,registry:Name@1838,registry:Token@1339,registry:TunnelURL@1424,whole:HomeLink@2215,whole:HomeLink@338,whole:HomeLink@644,whole:HomeLink@763,whole:HomeLinkApp@1799,whole:HomeLinkApp@1825,whole:HomeLinkApp@1834,whole:HomeLinkApp@1848,whole:HomeLinkApp@1904,whole:HomeLinkApp@1910,whole:HomeLinkApp@1991,whole:HomeLinkApp@1998,whole:HomeLinkApp@2221 fa7441cf65bde320d4f58c08d43f927e9e8868960b303700fd26358e3668b29c
+@legacy ee295a36717cc4064d71e186b1915b9185e4aa42bff4cd209e7b5c9b63d4511b internal/host/link_client.go linkLoopState.dropObsolete legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8 fix round 2: new; compares the running tunnel's link ID, token, tunnel URL and conn_gen with the HomeLink row just read and stops (cancels first, then records the state) when they differ; records reconnecting only when this box's label holds the row; reads only the row already read, no registry, file or bucket read of its own registry:BoxLabel@129,registry:ConnGen@431,registry:ID@210,registry:Token@276,registry:TunnelURL@348 3f6749b7121d1effc9cee94b6aed37718a8e7701aae5cb648ad1198da97169c3
+@legacy 4c89c17ca8c4b8ccb9bfdb1b045405188eef76131c0dd5f20dc66e7766754caf internal/host/link_client.go linkLoopState.pass legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; the home link loop's pass: reads HomeLink and HomeLinkApps from the agent's own registry, claims an unclaimed link with ClaimHomeLink(label) unless this is a fleet box (tunnelEnvComplete), and starts, keeps or cancels the link's tunnel by link ID, token, tunnel URL, conn_gen and the published set; no file or bucket read, nothing executed; fix round 1: a run the link row alone shows obsolete (link ID, token, tunnel URL or conn_gen changed) is cancelled before HomeLinkApps is read, so a failing set read cannot hold a revoked connection open; stops record the link state as reconnecting (replaced), empty (unlinked, fleet box) or nothing (another box holds the claim); same reads; fix round 2: the obsolete-run comparison moved into dropObsolete, called right after the link row is read and again after the claim's re-read, so a replaced, rotated or revoked link is closed before a claim, re-read or published-set read is attempted; same kind of reads (the HomeLink row passed whole) registry:BoxLabel@1077,registry:BoxLabel@1180,registry:BoxLabel@1223,registry:BoxLabel@625,registry:ID@1151,registry:ID@1398,registry:ID@757,registry:Name@1518,whole:HomeLink@1066,whole:HomeLink@1895,whole:HomeLink@338,whole:HomeLink@615,whole:HomeLink@840,whole:HomeLink@959,whole:HomeLinkApp@1479,whole:HomeLinkApp@1505,whole:HomeLinkApp@1514,whole:HomeLinkApp@1528,whole:HomeLinkApp@1584,whole:HomeLinkApp@1590,whole:HomeLinkApp@1671,whole:HomeLinkApp@1678,whole:HomeLinkApp@1901 c7f5a19669fc5e24a26d3b97456fd9af29e9aecf03f3c483fa630b1fc22eb6f3
@legacy 2a3a9d15fb722558e494553cb2b35373b688a0cacc948a8714c4531c8743d25e internal/host/link_client.go linkLoopState.start legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; starts tunnelclient.Loop for the link (channel name from the link ID, the stored token and tunnel URL) serving linkHandler, and records its state with SetHomeLinkState while it is the running loop; no file or bucket read; fix round 1: the run is made current under the loop's lock before its tunnel starts, and its OnState goes through reportState, which writes SetHomeLinkState only while that run is still current; one fewer read site (the link ID in the state callback's log line moved to reportState) registry:ConnGen@221,registry:ID@167,registry:ID@337,registry:ID@416,registry:Token@183,registry:Token@642,registry:TunnelURL@200,registry:TunnelURL@425,registry:TunnelURL@596,whole:HomeLinkApp@237,whole:HomeLinkApp@254,whole:HomeLinkApp@454 db8518154691958ef28b923401c208758c03925d23c2ff64ffb291effe6c013a
@legacy e14481c06286c23fa3ff9f20d51f906ae9fdfb69c56063c28b1a4d59d44e66ae internal/host/link_client.go linkSetNarrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; compares two in-memory published sets by name; no read whole:HomeLinkApp@112,whole:HomeLinkApp@130,whole:HomeLinkApp@135,whole:HomeLinkApp@92 acf871a54433606a3d9a43fdc646108df576a8d6b25bdf6f8bbfa15f8e2dbcc6
@legacy 6ddce06ad2bfd7fc901dc0f2e9de3aaac45f241045fc6dfe185af49d82960d8e internal/host/link_handler.go linkHandler.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; the link channel's handler: reads the one Carlos-Link-App value, looks it up with HomeLinkAppByName in the agent's own registry on every request, refuses a missing or unpublished name with 404, and hands a published one to edge.ServeLinked with the row's home account, app and host; the request's Host never selects; no file or bucket read registry:HomeAccount@1279,registry:HomeAccount@705,registry:HomeApp@1301,registry:HomeApp@730,registry:HomeHost@1256,registry:HomeHost@683,whole:HomeLinkApp@669 4a5cacac0f6fba9392d40246171f2dd4d38dcc99dd29f2bfccb8f19fe94c49a8
@@ -76,7 +77,8 @@ internal/registry/forward.go Registry.DeleteForward legacy accepted-legacy accep
internal/registry/registry.go Registry.migrate legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user), on every registry open; a box CLI verb that opens the registry directly runs it as whoever runs the verb: census-ruling-seeded-instances's body with two more columns added to routes (incarnation and serving_seq, INTEGER NOT NULL DEFAULT 0, idempotent through the duplicate-column rule); self-serve moves 1 Task 7;rev3=census-ruling-rootfs-apps-2;basis=one more ALTER TABLE, routes ADD COLUMN runtime TEXT NOT NULL DEFAULT '', beside main's rate_limit, assets_off, asset_gen, incarnation and serving_seq (the last four from the merges of origin/main 3c33f2eb and 953b9fda); the same sixteen sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328/#329 plan 1 Task 4: three more ALTER TABLE statements in the existing loop, routes ADD COLUMN egress_allow, size and policy_expires_at, each TEXT NOT NULL DEFAULT '' and idempotent through the duplicate-column rule; the same sixteen sites, no read added.;rev3=census-ruling-region-ha-p1a;basis=one more ALTER TABLE in the existing loop: routes ADD COLUMN ha INTEGER NOT NULL DEFAULT 0, idempotent through the duplicate-column rule; the same sixteen sites, no read added;rev3=census-ruling-ha-p1a-433;basis=the registry's SQLite side as carlos (agent, registry child; a box CLI verb that opens the registry directly runs it as whoever runs it), on every registry open: the ALTER TABLE routes statements are now built from the one migration definition routeAddedColumns (addedColumn name, type, default; review r1 P2): for each entry without the Claim mark, "ALTER TABLE routes ADD COLUMN " + spec(), byte for byte the statements main runs, in main's order, under the same duplicate-column rule. +registry:Claim is that mark, +whole:addedColumn the struct. Every name, type and default is an in-binary literal; no statement added, removed or changed; no read added.;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: one more CREATE TABLE IF NOT EXISTS regional_domains (host TEXT PRIMARY KEY, target, account, app, region TEXT NOT NULL DEFAULT '', created_at INTEGER NOT NULL DEFAULT 0), beside wildcard_domains; the added sites are that statement (+file:Exec, +registry:sql), an in-binary literal; additive, no existing statement changed;rev3=census-ruling-region-ha-p1b3b-t;basis=Create local HA duty/replay tables and revision triggers in the existing registry connection; no new database path.;rev3=census-ruling-agent-start-demo-3;basis=Create moved-notice storage as a single (id, wire) row; fingerprints include the stored wire bytes. Census read-site delta: +file:Exec, +registry:sql.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: calls migrateLinks after migrateHADuties (one CREATE TABLE IF NOT EXISTS link_channels, an in-binary literal); additive, no existing statement changed; linked deployments slice 1 Task 7: also runs migrateHomeLink (CREATE TABLE IF NOT EXISTS home_link and home_link_apps) after migrateLinks; additive, the box's own registry database, as carlos file:Exec@1124,file:Exec@1855,file:Exec@212,file:Exec@2409,file:Exec@3347,file:Exec@3626,file:Exec@4489,file:Exec@4665,file:Exec@51,file:Exec@761,registry:Claim@686,registry:sql@1124,registry:sql@1855,registry:sql@212,registry:sql@2409,registry:sql@3347,registry:sql@3626,registry:sql@4489,registry:sql@4665,registry:sql@51,registry:sql@761,whole:addedColumn@661 63fc63e2dd8bcd22c23e590d7e79f2996c31e0edc94aa1da2d48646f99c64ef2
internal/edge/edge.go Edge.pinnedUpstream legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; a linked request's upstream: the exact in-memory routing-map entry for the pinned home host, admitted only when its route is that host's own row for the pinned account and app, an instance, not forward, demo or sidecar, served from this box; reads the route fields of the map entry the last Reload built, no registry, file or bucket read registry:Account@435,registry:App@466,registry:Host@156,registry:Kind@331,whole:Route@146 9e26e286bc9973a11697c46766f19587f791fb83cf4275d3ed6df2d638ec03a8
internal/edge/fleetforward.go linkServeEligible legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: new pure rule for a link-placed forward row: refused off the hub, when not inert, when it carries a fleet box, label or replica set, when its link is not in the active link owners, or when its raw Account is empty or not the link's owner; reads only the row and the owners map registry:Account@567,registry:Account@636,registry:Account@720,registry:FleetBox@277,registry:FleetBoxes@321,registry:FleetLabel@298 e15bfdfc2c2928ccd325b8844346be778eb5e186bd7898c2f21bf84c7574dde7
-internal/host/link_client.go linkLoopState.pass legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; the home link loop's pass: reads HomeLink and HomeLinkApps from the agent's own registry, claims an unclaimed link with ClaimHomeLink(label) unless this is a fleet box (tunnelEnvComplete), and starts, keeps or cancels the link's tunnel by link ID, token, tunnel URL, conn_gen and the published set; no file or bucket read, nothing executed; fix round 1: a run the link row alone shows obsolete (link ID, token, tunnel URL or conn_gen changed) is cancelled before HomeLinkApps is read, so a failing set read cannot hold a revoked connection open; stops record the link state as reconnecting (replaced), empty (unlinked, fleet box) or nothing (another box holds the claim); same reads registry:BoxLabel@1004,registry:BoxLabel@429,registry:BoxLabel@858,registry:BoxLabel@961,registry:ConnGen@1520,registry:ID@1260,registry:ID@1718,registry:ID@561,registry:ID@932,registry:Name@1838,registry:Token@1339,registry:TunnelURL@1424,whole:HomeLink@2215,whole:HomeLink@338,whole:HomeLink@644,whole:HomeLink@763,whole:HomeLinkApp@1799,whole:HomeLinkApp@1825,whole:HomeLinkApp@1834,whole:HomeLinkApp@1848,whole:HomeLinkApp@1904,whole:HomeLinkApp@1910,whole:HomeLinkApp@1991,whole:HomeLinkApp@1998,whole:HomeLinkApp@2221 fa7441cf65bde320d4f58c08d43f927e9e8868960b303700fd26358e3668b29c
+internal/host/link_client.go linkLoopState.dropObsolete legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8 fix round 2: new; compares the running tunnel's link ID, token, tunnel URL and conn_gen with the HomeLink row just read and stops (cancels first, then records the state) when they differ; records reconnecting only when this box's label holds the row; reads only the row already read, no registry, file or bucket read of its own registry:BoxLabel@129,registry:ConnGen@431,registry:ID@210,registry:Token@276,registry:TunnelURL@348 3f6749b7121d1effc9cee94b6aed37718a8e7701aae5cb648ad1198da97169c3
+internal/host/link_client.go linkLoopState.pass legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; the home link loop's pass: reads HomeLink and HomeLinkApps from the agent's own registry, claims an unclaimed link with ClaimHomeLink(label) unless this is a fleet box (tunnelEnvComplete), and starts, keeps or cancels the link's tunnel by link ID, token, tunnel URL, conn_gen and the published set; no file or bucket read, nothing executed; fix round 1: a run the link row alone shows obsolete (link ID, token, tunnel URL or conn_gen changed) is cancelled before HomeLinkApps is read, so a failing set read cannot hold a revoked connection open; stops record the link state as reconnecting (replaced), empty (unlinked, fleet box) or nothing (another box holds the claim); same reads; fix round 2: the obsolete-run comparison moved into dropObsolete, called right after the link row is read and again after the claim's re-read, so a replaced, rotated or revoked link is closed before a claim, re-read or published-set read is attempted; same kind of reads (the HomeLink row passed whole) registry:BoxLabel@1077,registry:BoxLabel@1180,registry:BoxLabel@1223,registry:BoxLabel@625,registry:ID@1151,registry:ID@1398,registry:ID@757,registry:Name@1518,whole:HomeLink@1066,whole:HomeLink@1895,whole:HomeLink@338,whole:HomeLink@615,whole:HomeLink@840,whole:HomeLink@959,whole:HomeLinkApp@1479,whole:HomeLinkApp@1505,whole:HomeLinkApp@1514,whole:HomeLinkApp@1528,whole:HomeLinkApp@1584,whole:HomeLinkApp@1590,whole:HomeLinkApp@1671,whole:HomeLinkApp@1678,whole:HomeLinkApp@1901 c7f5a19669fc5e24a26d3b97456fd9af29e9aecf03f3c483fa630b1fc22eb6f3
internal/host/link_client.go linkLoopState.start legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; starts tunnelclient.Loop for the link (channel name from the link ID, the stored token and tunnel URL) serving linkHandler, and records its state with SetHomeLinkState while it is the running loop; no file or bucket read; fix round 1: the run is made current under the loop's lock before its tunnel starts, and its OnState goes through reportState, which writes SetHomeLinkState only while that run is still current; one fewer read site (the link ID in the state callback's log line moved to reportState) registry:ConnGen@221,registry:ID@167,registry:ID@337,registry:ID@416,registry:Token@183,registry:Token@642,registry:TunnelURL@200,registry:TunnelURL@425,registry:TunnelURL@596,whole:HomeLinkApp@237,whole:HomeLinkApp@254,whole:HomeLinkApp@454 db8518154691958ef28b923401c208758c03925d23c2ff64ffb291effe6c013a
internal/host/link_client.go linkSetNarrowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; compares two in-memory published sets by name; no read whole:HomeLinkApp@112,whole:HomeLinkApp@130,whole:HomeLinkApp@135,whole:HomeLinkApp@92 acf871a54433606a3d9a43fdc646108df576a8d6b25bdf6f8bbfa15f8e2dbcc6
internal/host/link_handler.go linkHandler.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: new; the link channel's handler: reads the one Carlos-Link-App value, looks it up with HomeLinkAppByName in the agent's own registry on every request, refuses a missing or unpublished name with 404, and hands a published one to edge.ServeLinked with the row's home account, app and host; the request's Host never selects; no file or bucket read registry:HomeAccount@1279,registry:HomeAccount@705,registry:HomeApp@1301,registry:HomeApp@730,registry:HomeHost@1256,registry:HomeHost@683,whole:HomeLinkApp@669 4a5cacac0f6fba9392d40246171f2dd4d38dcc99dd29f2bfccb8f19fe94c49a8
@@ -121,9 +123,9 @@ internal/regionlabel/regionlabel.go ForRoute legacy accepted-legacy accepted-leg
internal/registry/forward.go Registry.PutForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 2: the only writer of a forward row's declared columns: refuses an argument whose kind is not forward; copies only the declared fields from its argument (Status ready, Provisioned true; no forbidden column is ever written); inside one IMMEDIATE transaction refuses a host a non-forward row holds (ErrHostHeld); keeps FleetBox while Region is unchanged; preserves the observational columns (+file:Exec, +file:QueryRow, +registry:Account, App, Channel, RateLimit, Region, Slug, +registry:Host x3, +registry:Kind, +registry:remote x2, +whole:Route x3, +whole:remoteClient x2).;rev3=census-ruling-fleet-routes-followups;basis=refuses up front, with the new sentinel ErrNotForward and before any read or write, an rt that is not a forward row (as before, now a sentinel), has an empty Host, or whose Region is not a fleet placement (registry.FleetPlacement); +registry:Host x2 and +registry:Region x2 read only the argument in those checks; the transaction and statement are unchanged;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3), merged with main's ErrNotForward refusals (kept unchanged): the written row also carries FleetLabel = rt.FleetLabel and FleetBox = rt.FleetLabel; its conflict arm (forwardKept) writes fleet_label from the call and fleet_box as the call's label when set, else kept while the region is unchanged. The hub's forward phase in the agent, not root.;rev3=census-ruling-stateless-replicas-1;basis=Carry declarative Stateless into forward rows under existing transaction and shape guards; projection only.;rev3=census-ruling-agent-start-demo-1;basis=Reads and carries the four demo fields in the existing forward INSERT; the guarded conflict SQL refuses downgrade or identity change.;rev3=census-ruling-stateless-replicas-2;basis=Validates canonical set projection, writes explicit declarative columns and clears single-box binding; all forbidden columns zero. Same transaction/read source. merge of origin/main 6be08467: Retain main demo columns and immutable descriptor conflict guard alongside set validation/projection; merge-only existing route fields.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: also accepts a Region that LinkPlacement parses (link/ + 12 hex), refusing a link row with a FleetLabel (ErrNotForward); the existing in-transaction SELECT also reads the held row's region and refuses a different placement class (ErrHostHeld); a link row additionally needs an active link_channels row of its account in the same transaction (linkAdmits, ErrLinkInactive). Same transaction and statement; the added reads are the argument and the box's own registry database, as carlos file:Exec@2052,file:QueryRow@1631,registry:Account@1092,registry:Account@1989,registry:App@1069,registry:Channel@1145,registry:Copies@1392,registry:DemoExpiresAt@960,registry:DemoHost@901,registry:DemoID@880,registry:DemoLifetime@928,registry:FleetBox@1513,registry:FleetBoxes@1369,registry:FleetBoxes@1490,registry:FleetLabel@1280,registry:FleetLabel@1310,registry:FleetLabel@1525,registry:FleetLabel@540,registry:Host@1693,registry:Host@250,registry:Host@287,registry:Host@500,registry:Host@660,registry:Host@993,registry:Kind@259,registry:RateLimit@1172,registry:Region@1119,registry:Region@130,registry:Region@1898,registry:Region@509,registry:Region@82,registry:ReplicaIncarnation@1460,registry:ReplicaRevision@1420,registry:Slug@1045,registry:Stateless@1340,registry:remote@737,registry:remote@767,whole:Route@2085,whole:Route@822,whole:Route@830,whole:remoteClient@739,whole:remoteClient@769 92749de50752ac228f653180d60ea0b177331657a7062598c8b877b35c694106
internal/registry/registry.go Registry.Fingerprint legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user); the remote arm, unchanged, in the process that holds a remote handle: census-ruling-seeded-instances's body with the row's lifetime pair (incarnation, serving_seq) folded into the edge's change poll, each only when non-zero, so a registry with no pair digests as before; self-serve moves 1 Task 7;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: hashes regional_domains (host, target, account, app, region; created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no regional rows digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; no file path read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): review R1 finding 1: the routes SELECT also reads host, kind, account, app, platform and fingerprintForwardInert (one CASE over the ForwardForbidden columns), and every row folds host, kind, account and app (tagged, quoted), platform when set, and forward_inert=0 for a forward row that is not inert, so a rowid reused by another hostname, an in-place account or app rewrite, or a stray forbidden column moves the edge's change poll. Same one SELECT per table on the same fresh connection to the box's own registry database, as carlos; no table, file or bucket read added; a digest, never a decision.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5): the SELECT also reads fleet_label and, only when it is set, hashes "fleet_label=<q>" into the digest, so labelling a row moves the edge's reload fingerprint. Read sites unchanged (33). Registry side, not root; an unlabelled registry's digest is byte-identical.;rev3=census-ruling-stateless-replicas-1;basis=Read the additive stateless projection in the existing registry SELECT and hash only when set; no new read source.;rev3=census-ruling-agent-start-demo-1;basis=Existing SELECT reads four more demo columns; only a marked row adds them to the hash, so ordinary hashes remain unchanged.;rev3=census-ruling-stateless-replicas-2;basis=Four additive projection columns join the existing routes SELECT and hash only when nonzero; no new query or file read. merge of origin/main 6be08467: Union main demo identity and expiry with replica columns in the same SELECT and hash; merge-only body change.;rev3=census-ruling-agent-start-demo-3;basis=Hash moved-notice wire bytes so notice-only changes invalidate an edge route snapshot. Census read-site delta: +file:QueryRow.;rev3=census-ruling-edge-page-cache-1;basis=selects the new pages_off column with the rest and folds "pages_off=1" into the hash only when set, as assets_off, so a registry that never sets it fingerprints as before; same routes SELECT, no new table; read sites unchanged (34); no read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: hashes link_channels (link_id, account, token_hash, status, generation; connected, seen_at, seq and created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no links digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; a digest, never a decision; linked deployments slice 1 Task 7: also folds home_link (id, serving_url, tunnel_url, the token's sha256 never the token, account, apps_domain, box_label, conn_gen; state and created_at not) and home_link_apps (name, home_account, home_app, home_host) through fingerprintHomeLink over the same fresh connection, each section marker written only when a row exists, so a registry with no link digests as before; no file path read; a digest, never a decision file:Exec@284,file:Open@188,file:Query@10785,file:Query@11990,file:Query@368,file:Query@6655,file:Query@7134,file:Query@8120,file:Query@8816,file:Query@9728,file:QueryRow@12907,registry:ClaimIncarnation@1729,registry:ClaimIncarnation@5563,registry:ClaimIncarnation@5640,registry:ClaimOwner@1773,registry:ClaimOwner@5764,registry:ClaimOwner@5829,registry:ClaimRowID@1792,registry:ClaimRowID@5856,registry:ClaimRowID@5922,registry:ClaimStamp@1754,registry:ClaimStamp@5673,registry:ClaimStamp@5737,registry:Incarnation@1848,registry:Incarnation@6143,registry:Incarnation@6207,registry:ServingSeq@1867,registry:ServingSeq@6234,registry:ServingSeq@6297,registry:Text@158,registry:path@207,registry:remote@55,registry:remote@87,whole:remoteClient@57,whole:remoteClient@89 992e25925704805387f5c460a886c0ee9ba7eb57a06aa5ca384e94b677ea491f
@coverage . 52c69727a1e337a47920a1c9f37d9808f1df8d14dbefd29db86f9892bdf10b7d
-@coverage internal/edge 9c0eb8a58548921c20de856c13fe990efd7902b15af404dcb6f57cd364f99182
+@coverage internal/edge ae50155c5f75eecb67afd1070d65edbb6d0b8f9ad98f34b4e0da065b7c59e012
@coverage internal/gate 17307a6623f6149db163fc8de9139f8d824b36d70d2da635c712aee3671e582a
-@coverage internal/host 18a1996c7aaeaddd6beaefb8197e80cb2c5818e92062ecb51c8943a1869b0e99
+@coverage internal/host 9a1b98f6896147e930776114271105b245546a5b96551872002810ff9ae5403d
@coverage internal/provision 6c3f9188cfe17a2f7f87d78cf5f60e9104f5bcd55941947129a5bcea3e4c586c
@coverage internal/regionlabel 8d831085b7e3ce7bb1ea1f20f443b4529c5b7177de18e7c4889e4ca330aa6a00
@coverage internal/registry d160203302b7508294b6568f2a452e32c64921b5b1a1196ec358ee1128e335ba