carlos / platform Public

link: revocation simulations on all three sides

Seeded random sequences check the revocation invariant against the
registry on each side: the serving console (doors, store and
linkSyncPass behind a fault-injecting registry), the hub (registry
mutations, home dials, overtaken registrations, failing reloads) and
the home (publish, unpublish, retarget and reuse between watch ticks
with open SSE and WebSocket streams). 500 seeds per side by default;
LINKSIM_SEEDS, LINKSIM_SEED and LINKSIM_STEPS tune a run.

The hub simulation found that a reload failing after its registry
reads left a revoked or rotated-away home connected and served until
a reload completed. Reload now reads the link credentials first and
applies them at once through TunnelHub.SetLinkAuth (the link half of
the set; fleets untouched). The failing seeds and a fixed-scene test
keep the finding. Census overlay linked-deployments-slice1 re-proposed
for Edge.Reload and the edge envelope.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 9281753a99d2045ab921f17d14f5cc1d57804a2f parent e099444
10 files changed, +2,040 −26
  • docs/superpowers/notes/census-proposal-linked-deployments-slice1.md +2 −2
  • internal/console/link_sim_test.go +664 −0
  • internal/edge/edge.go +19 −6
  • internal/edge/link_sim_test.go +784 −0
  • internal/edge/reload_guard_test.go +2 −2
  • internal/edge/tunnel.go +36 −0
  • internal/edge/tunnel_publish_guard_test.go +31 −12
  • internal/host/link_sim_test.go +498 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-linked-deployments-slice1.tsv +3 −3
diff --git a/docs/superpowers/notes/census-proposal-linked-deployments-slice1.md b/docs/superpowers/notes/census-proposal-linked-deployments-slice1.md
index 129c16bcd..e40847d98 100644
--- a/docs/superpowers/notes/census-proposal-linked-deployments-slice1.md
+++ b/docs/superpowers/notes/census-proposal-linked-deployments-slice1.md
@@ -19,7 +19,7 @@ Ruling `census-ruling-linked-deployments-slice1`. The independent reviewer appro
| `internal/host/edgesfile.go` `edgesFileWriteClaims` | body | unchanged (70) | linked deployments slice 1 Task 3: fleetArmInputs now returns edge.ForwardOwners (this box's fleets table and its active links, registry LinkOwners, read only where tunnels are on), passed to edge.FleetArmVerdict as before, so the hub's eligible link-placed forward rows are published for backhaul like fleet rows; same listing and verdict, no read added in the unit |
| `internal/registry/forward.go` `Registry.DeleteForward` | body | unchanged (7) | linked deployments slice 1 Task 1: the one DELETE also refuses a link-placed forward row (AND substr(region, 1, 5) <> 'link/'); a narrower delete, no read added |
| `internal/registry/registry.go` `Registry.migrate` | body | unchanged (22) | 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 |
-| `internal/edge/edge.go` `Edge.Reload` | sites | +whole:Route | linked deployments slice 1 Task 3: with tunnels on, the pass also reads LinkChannelAuth and LinkOwners from the box's own registry (fresh connection, as FleetChannelAuth and FleetOwners) and merges each well-formed link channel's hash into the set SetDynamicAuth takes; the verdict judges link-placed forward rows by the link owners; an admitted one takes the new ArmLink case (linkProxy down the link's channel, tenancy with the link); the door's fleet snapshot stays fleet owners only and link owners go to a separate snapshot; +whole:Route is the row handed to the new case's responseModifier; the edge process as carlos, no root decision; linked deployments slice 1 Task 8: each upstream entry also records localBackend (ArmSocket, or an instance the activator runs here), from values the pass already holds; no read added |
+| `internal/edge/edge.go` `Edge.Reload` | sites | +whole:Route | linked deployments slice 1 Task 3: with tunnels on, the pass also reads LinkChannelAuth and LinkOwners from the box's own registry (fresh connection, as FleetChannelAuth and FleetOwners) and merges each well-formed link channel's hash into the set SetDynamicAuth takes; the verdict judges link-placed forward rows by the link owners; an admitted one takes the new ArmLink case (linkProxy down the link's channel, tenancy with the link); the door's fleet snapshot stays fleet owners only and link owners go to a separate snapshot; +whole:Route is the row handed to the new case's responseModifier; the edge process as carlos, no root decision; linked deployments slice 1 Task 8: each upstream entry also records localBackend (ArmSocket, or an instance the activator runs here), from values the pass already holds; no read added; linked deployments slice 1 Task 11: the LinkChannelAuth read (the same fresh-connection read) moves to the top of the pass, before List, and its map is applied at once through the hub's new SetLinkAuth (the link half of the credential set only; fleet entries untouched), so a link revocation or rotation closes the home connection on the old hash even when a later read or step of the same reload fails; the same map is still merged into the set SetDynamicAuth takes; no read added, one moved; the edge process as carlos, no root decision |
| `internal/edge/fleetforward.go` `FleetArmVerdict` | sites | +registry:App, +registry:Host, +registry:Region | linked deployments slice 1 Task 3: owners is edge.ForwardOwners; a link-placed forward row (registry.LinkPlacement over the listed row's Region) admitted by FleetServeEligible gets an Arm entry with its link, app and the link's owner, and ArmLink rows count as served; +registry:App, +registry:Host, +registry:Region are that row's fields; a pure decision over the listing, no read source added |
| `internal/edge/fleetforward.go` `FleetServeEligible` | sites | +registry:Region, +whole:Route | linked deployments slice 1 Task 3: owners is edge.ForwardOwners; a forward row whose Region parses as a link placement is judged by linkServeEligible against owners.Links only, and every other row as before against owners.Fleets; +registry:Region and +whole:Route are that parse and the hand-off; refuses more, never admits a fleet row by link owners |
| `internal/edge/purge_header.go` `Edge.resolvePurgeOwnersIn` | sites | +registry:Host ×2, +whole:Route | linked deployments slice 1 Task 8: a declared Carlos-Purge-Host equal to the linked request's public host is the serving route's own host (rt.Host, owner rt), as naming rt.Host already is; the new sites read rt.Host and build purgeHost{rt.Host, rt}; nothing outside rt's own entries becomes purgeable |
@@ -101,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` → `91a9fbb640ba280de65c041879cc84d5ef6a0137a576d789733dc03eb6946cae`.
+Seal: `6d3ea7fccce1a7f4bc507b6eb8d368ed0b62f83022504aa04c7684c72c93aa9a` → `a86f0ab3b84a5d16a45d0a4a9dba46865bc7740363f3353c8e069ead958fd362`.
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/console/link_sim_test.go b/internal/console/link_sim_test.go
new file mode 100644
index 000000000..e3f9d8f8e
--- /dev/null
+++ b/internal/console/link_sim_test.go
@@ -0,0 +1,664 @@
+package console
+
+// Linked deployments slice 1, Task 11: the revocation invariant on the
+// serving side, checked by seeded random sequences.
+//
+// The invariant (plan Task 11): after any revocation event (unpublish,
+// rotate, unlink), within a bound and with no further API call, nothing
+// revoked is served. On the serving side the hub registry is the contract:
+// once the sequence ends and linkSyncLoop has ticked three times with no
+// faults, the registry equals the state derived from the console database:
+//
+// - a revoked link has no active channel, and no forward rows;
+// - a live link's channel is active, owned by the link's account, at the
+// links row's generation, with the links row's current token hash;
+// - a live link's forward rows are exactly its live publications (its
+// linked apps rows), each naming the account and the app;
+// - nothing is left for linkSyncPass to do.
+//
+// Each step also checks its own door's promise: a 204 unpublish leaves no
+// forward row for the name, a 204 unlink leaves the channel revoked and no
+// forward row, and a rotated-away token gets 401 at every link door.
+//
+// Every step goes through the real console: the link doors over HTTP, the
+// real Store, and linkSyncPass (linkSyncLoop's tick). Links are minted as
+// the poll mints them (the store's mint, then the background first sync).
+// The registry is the real one behind simFaultReg, which fails a chosen
+// registry write (PutLinkChannel, RevokeLinkChannel, PutForward or
+// DeleteLinkForward) once, or enough times in a row to outlast a door's own
+// retries. The write does not apply: the console's registry is a local
+// SQLite handle (openRegistry), where an error means nothing committed.
+//
+// LINKSIM_LOST_REPLY=1 also fails writes after they applied, as a remote
+// registry can ("Canceled does not mean not applied", registry/remote.go).
+// The console never writes through one today, and this mode fails: a lost
+// PutForward answer on a new publish rolls back the apps row and leaves the
+// forward row (LINKSIM_LOST_REPLY=1 LINKSIM_SEED=15), and a lost
+// DeleteLinkForward answer on an unpublish keeps the apps row of a
+// publication the registry no longer serves. See the Task 11 report.
+//
+// Seeds: LINKSIM_SEEDS=n runs n seeds (default linkSimDefaultSeeds),
+// LINKSIM_SEED=s runs seed s alone in a fresh fixture (the reproduction of
+// a failure, which prints its seed and trace). LINKSIM_STEPS caps the
+// steps per seed (default 40).
+
+import (
+ "context"
+ "database/sql"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "math/rand"
+ "net/http"
+ "os"
+ "slices"
+ "strconv"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/registry"
+)
+
+// linkSimDefaultSeeds is the seed count CI runs. LINKSIM_SEEDS raises it.
+const linkSimDefaultSeeds = 500
+
+// linkSimMaxFailedSeeds is how many failing seeds a run reports before it
+// stops.
+const linkSimMaxFailedSeeds = 3
+
+// linkSimBatch is how many seeds share one console fixture. Each seed mints
+// its own links and ends by unlinking them, so the next seed starts from no
+// live link and no linked app.
+const linkSimBatch = 50
+
+// linkSimSeeds is the seed list: LINKSIM_SEED alone, else 1..LINKSIM_SEEDS.
+func linkSimSeeds(t *testing.T, def int) (seeds []int64, one bool) {
+ t.Helper()
+ if s := os.Getenv("LINKSIM_SEED"); s != "" {
+ n, err := strconv.ParseInt(s, 10, 64)
+ if err != nil {
+ t.Fatalf("LINKSIM_SEED=%q: %v", s, err)
+ }
+ return []int64{n}, true
+ }
+ n := def
+ if s := os.Getenv("LINKSIM_SEEDS"); s != "" {
+ v, err := strconv.Atoi(s)
+ if err != nil || v < 1 {
+ t.Fatalf("LINKSIM_SEEDS=%q: want a positive count", s)
+ }
+ n = v
+ }
+ for i := 1; i <= n; i++ {
+ seeds = append(seeds, int64(i))
+ }
+ return seeds, false
+}
+
+func linkSimSteps(t *testing.T, def int) int {
+ t.Helper()
+ if s := os.Getenv("LINKSIM_STEPS"); s != "" {
+ v, err := strconv.Atoi(s)
+ if err != nil || v < 1 {
+ t.Fatalf("LINKSIM_STEPS=%q: want a positive count", s)
+ }
+ return v
+ }
+ return def
+}
+
+var errSimInjected = errors.New("linksim: injected registry failure")
+
+// simFault is one armed failure of a registry write: left more calls fail;
+// after, the write is made and then its answer is replaced by an error.
+type simFault struct {
+ after bool
+ left int
+}
+
+// simFaultReg is the console's registry with injected write failures.
+type simFaultReg struct {
+ consoleRegistry
+ mu sync.Mutex
+ armed map[string]simFault
+ hits []string
+}
+
+func (f *simFaultReg) arm(method string, ft simFault) {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ f.armed[method] = ft
+}
+
+func (f *simFaultReg) clear() {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ f.armed = map[string]simFault{}
+}
+
+// take reports whether this call of method fails, and how.
+func (f *simFaultReg) take(method string) (after, hit bool) {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ ft, ok := f.armed[method]
+ if !ok || ft.left <= 0 {
+ return false, false
+ }
+ ft.left--
+ if ft.left == 0 {
+ delete(f.armed, method)
+ } else {
+ f.armed[method] = ft
+ }
+ mode := "before"
+ if ft.after {
+ mode = "after"
+ }
+ f.hits = append(f.hits, method+"/"+mode)
+ return ft.after, true
+}
+
+func (f *simFaultReg) drainHits() []string {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ h := f.hits
+ f.hits = nil
+ return h
+}
+
+func (f *simFaultReg) PutLinkChannel(c registry.LinkChannel) (bool, error) {
+ after, hit := f.take("PutLinkChannel")
+ if hit && !after {
+ return false, errSimInjected
+ }
+ applied, err := f.consoleRegistry.PutLinkChannel(c)
+ if hit && err == nil {
+ return false, errSimInjected
+ }
+ return applied, err
+}
+
+func (f *simFaultReg) RevokeLinkChannel(id string) (bool, error) {
+ after, hit := f.take("RevokeLinkChannel")
+ if hit && !after {
+ return false, errSimInjected
+ }
+ moved, err := f.consoleRegistry.RevokeLinkChannel(id)
+ if hit && err == nil {
+ return false, errSimInjected
+ }
+ return moved, err
+}
+
+func (f *simFaultReg) PutForward(rt registry.Route) error {
+ after, hit := f.take("PutForward")
+ if hit && !after {
+ return errSimInjected
+ }
+ err := f.consoleRegistry.PutForward(rt)
+ if hit && err == nil {
+ return errSimInjected
+ }
+ return err
+}
+
+func (f *simFaultReg) DeleteLinkForward(host, id string) (bool, error) {
+ after, hit := f.take("DeleteLinkForward")
+ if hit && !after {
+ return false, errSimInjected
+ }
+ deleted, err := f.consoleRegistry.DeleteLinkForward(host, id)
+ if hit && err == nil {
+ return false, errSimInjected
+ }
+ return deleted, err
+}
+
+var simFaultMethods = []string{"PutLinkChannel", "RevokeLinkChannel", "PutForward", "DeleteLinkForward"}
+
+// simLink is one link the sequence minted: its ID, the token the home
+// holds now, and every token it held before.
+type simLink struct {
+ id, token string
+ old []string
+}
+
+// simReq is one link door request, kept so that "retry" can send it again.
+type simReq struct {
+ link int
+ method, path string
+ body string
+}
+
+// consoleSim is one fixture and the seed running on it.
+type consoleSim struct {
+ t *testing.T
+ fx *consoleFixture
+ reg *simFaultReg
+ acct *Account
+ links []*simLink
+ trace []string
+ last *simReq // the last request that did not succeed
+ fails []string
+ stats map[string]int // what the run exercised, summed over seeds
+ // lostReply also injects failures after the write applied
+ // (LINKSIM_LOST_REPLY=1); see TestLinkSimServingSide.
+ lostReply bool
+}
+
+func (s *consoleSim) logf(format string, args ...any) {
+ s.trace = append(s.trace, fmt.Sprintf(format, args...))
+}
+
+func (s *consoleSim) failf(format string, args ...any) {
+ s.fails = append(s.fails, fmt.Sprintf(format, args...))
+}
+
+// mint makes a link as the poll does (the store's mint, then the
+// background first sync, waited for), under the fixture account.
+func (s *consoleSim) mint() {
+ t := s.t
+ now := time.Now()
+ userCode, deviceCode, err := s.fx.st.NewLinkAuth("home", "sim", "127.0.0.1", now)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := s.fx.st.ApproveLinkAuth(userCode, "paul@keymail.dev", s.acct.ID, now); err != nil {
+ t.Fatal(err)
+ }
+ res, err := s.fx.st.pollCLIAuth(deviceCode, now)
+ if err != nil || res.Status != CLIAuthApproved || res.LinkID == "" {
+ t.Fatalf("mint: %+v %v", res, err)
+ }
+ s.fx.srv.firstLinkSync(res.LinkID)
+ s.fx.srv.linkFirstSyncs.Wait()
+ s.links = append(s.links, &simLink{id: res.LinkID, token: res.Token})
+ s.logf("mint L%d=%s faults=%v", len(s.links)-1, res.LinkID, s.reg.drainHits())
+}
+
+// send sends req with the link's current token, records the answer, and
+// checks it against what its door promises. A rotate's new token becomes
+// the link's token, however the rotate was sent (a retry included).
+func (s *consoleSim) send(req simReq, what string) (int, string) {
+ l := s.links[req.link]
+ status, _, body := rawReq(s.t, req.method, s.fx.ts.URL+req.path, l.token, req.body)
+ hits := s.reg.drainHits()
+ s.logf("%s L%d %s %s %s -> %d %s faults=%v", what, req.link, req.method, req.path, req.body, status, strings.TrimSpace(body), hits)
+ s.stats[fmt.Sprintf("%s %s %d", req.method, req.path, status)]++
+ s.stats["registry faults hit"] += len(hits)
+ ok := status < 300 && status != http.StatusAccepted
+ if ok {
+ s.last = nil
+ } else {
+ r := req
+ s.last = &r
+ }
+ switch {
+ case req.method == http.MethodPost && req.path == "/api/link/publications":
+ switch status {
+ case http.StatusOK, http.StatusCreated, http.StatusUnauthorized, http.StatusConflict,
+ http.StatusTooManyRequests, http.StatusServiceUnavailable:
+ default:
+ s.failf("publish L%d %s answered %d %s", req.link, req.body, status, body)
+ }
+ case req.method == http.MethodDelete && strings.HasPrefix(req.path, "/api/link/publications/"):
+ name := strings.TrimPrefix(req.path, "/api/link/publications/")
+ switch status {
+ case http.StatusNoContent:
+ // The door's own bound: a 204 means the forward row is gone now.
+ if slices.Contains(s.forwardHosts(l.id), s.host(name)) {
+ s.failf("unpublish L%d %s answered 204 but the registry still holds its forward row", req.link, name)
+ }
+ case http.StatusUnauthorized, http.StatusServiceUnavailable:
+ default:
+ s.failf("unpublish L%d %s answered %d %s", req.link, name, status, body)
+ }
+ case req.path == "/api/link/rotate":
+ switch status {
+ case http.StatusOK:
+ var out map[string]string
+ if err := json.Unmarshal([]byte(body), &out); err != nil || out["token"] == "" {
+ s.failf("rotate L%d answered 200 without a token: %s", req.link, body)
+ break
+ }
+ l.old = append(l.old, l.token)
+ l.token = out["token"]
+ case http.StatusUnauthorized, http.StatusServiceUnavailable:
+ default:
+ s.failf("rotate L%d answered %d %s", req.link, status, body)
+ }
+ case req.method == http.MethodDelete && req.path == "/api/link":
+ switch status {
+ case http.StatusNoContent:
+ // 204 only once the registry applied the revocation.
+ if c := s.regChannel(l.id); c.ok && c.status != "revoked" {
+ s.failf("unlink L%d answered 204 but the registry channel is %q", req.link, c.status)
+ }
+ if hosts := s.forwardHosts(l.id); len(hosts) != 0 {
+ s.failf("unlink L%d answered 204 but forward rows remain: %v", req.link, hosts)
+ }
+ case http.StatusAccepted, http.StatusUnauthorized, http.StatusServiceUnavailable:
+ default:
+ s.failf("unlink L%d answered %d %s", req.link, status, body)
+ }
+ default:
+ if status >= 500 && status != http.StatusServiceUnavailable {
+ s.failf("%s L%d %s %s answered %d %s", what, req.link, req.method, req.path, status, body)
+ }
+ }
+ return status, body
+}
+
+func (s *consoleSim) host(app string) string { return s.fx.srv.apexHost(s.acct.Sqid, app) }
+
+// forwardHosts is the hosts of linkID's forward rows in the registry.
+func (s *consoleSim) forwardHosts(linkID string) []string {
+ rows, err := s.reg.consoleRegistry.LinkForwards(linkID)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ var out []string
+ for _, r := range rows {
+ out = append(out, r.Host)
+ }
+ return out
+}
+
+// regChannel reads linkID's link_channels row straight from the registry
+// file: status, token hash, account and generation.
+type simChannel struct {
+ status, hash, account string
+ gen int64
+ ok bool
+}
+
+func (s *consoleSim) regChannel(linkID string) simChannel {
+ db, err := sql.Open("sqlite", "file:"+s.fx.regPath+"?mode=ro")
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ defer db.Close()
+ var c simChannel
+ err = db.QueryRow(`SELECT status, token_hash, account, generation FROM link_channels WHERE link_id = ?`, linkID).
+ Scan(&c.status, &c.hash, &c.account, &c.gen)
+ if errors.Is(err, sql.ErrNoRows) {
+ return c
+ }
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ c.ok = true
+ return c
+}
+
+var simNames = []string{"shop", "blog", "news"}
+
+// step runs one random step.
+func (s *consoleSim) step(rng *rand.Rand) {
+ if len(s.links) == 0 {
+ s.mint()
+ return
+ }
+ li := rng.Intn(len(s.links))
+ l := s.links[li]
+ name := simNames[rng.Intn(len(simNames))]
+ switch r := rng.Intn(100); {
+ case r < 22: // publish
+ s.send(simReq{li, http.MethodPost, "/api/link/publications", `{"app":"` + name + `"}`}, "publish")
+ case r < 37: // unpublish
+ s.send(simReq{li, http.MethodDelete, "/api/link/publications/" + name, ""}, "unpublish")
+ case r < 45: // rotate
+ s.send(simReq{li, http.MethodPost, "/api/link/rotate", ""}, "rotate")
+ case r < 50: // unlink
+ s.send(simReq{li, http.MethodDelete, "/api/link", ""}, "unlink")
+ case r < 55: // read the link (linkRoute syncs first)
+ s.send(simReq{li, http.MethodGet, "/api/link", ""}, "get")
+ case r < 63: // retry the last request that did not succeed
+ if s.last == nil {
+ s.logf("retry: nothing to retry")
+ return
+ }
+ s.send(*s.last, "retry")
+ case r < 73: // a linkSyncLoop tick
+ err := s.fx.srv.linkSyncPass(context.Background())
+ hits := s.reg.drainHits()
+ s.logf("tick -> %v faults=%v", err, hits)
+ s.stats["ticks"]++
+ s.stats["registry faults hit"] += len(hits)
+ case r < 88: // arm a registry write failure
+ m := simFaultMethods[rng.Intn(len(simFaultMethods))]
+ ft := simFault{after: s.lostReply && rng.Intn(2) == 0, left: 1}
+ if rng.Intn(5) == 0 {
+ ft.left = 1 + len(linkSyncRetryBackoff) // outlasts a door's own retries
+ }
+ s.reg.arm(m, ft)
+ s.logf("fault %s after=%v x%d", m, ft.after, ft.left)
+ case r < 92: // a rotated-away token is refused at every door
+ if len(l.old) == 0 {
+ s.logf("stale L%d: no old token", li)
+ return
+ }
+ tok := l.old[rng.Intn(len(l.old))]
+ for _, d := range []struct{ method, path, body string }{
+ {http.MethodGet, "/api/link", ""},
+ {http.MethodPost, "/api/link/publications", `{"app":"` + name + `"}`},
+ {http.MethodDelete, "/api/link/publications/" + name, ""},
+ {http.MethodPost, "/api/link/rotate", ""},
+ {http.MethodDelete, "/api/link", ""},
+ } {
+ status, _, body := rawReq(s.t, d.method, s.fx.ts.URL+d.path, tok, d.body)
+ if status != http.StatusUnauthorized {
+ s.failf("stale token of L%d at %s %s answered %d %s, want 401", li, d.method, d.path, status, body)
+ }
+ }
+ s.logf("stale L%d: refused at every door faults=%v", li, s.reg.drainHits())
+ default: // another link
+ if len(s.links) < 3 {
+ s.mint()
+ } else {
+ s.logf("mint: already three links")
+ }
+ }
+}
+
+// settle clears every fault and runs three linkSyncLoop ticks.
+func (s *consoleSim) settle() {
+ s.reg.clear()
+ for i := 0; i < 3; i++ {
+ if err := s.fx.srv.linkSyncPass(context.Background()); err != nil {
+ s.failf("tick %d with no faults: %v", i+1, err)
+ }
+ }
+ s.logf("settle: three ticks, no faults")
+}
+
+// check compares the registry with the state the console database derives,
+// link by link.
+func (s *consoleSim) check() {
+ need, err := s.fx.st.linksNeedingSync()
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ holding, err := s.fx.st.revokedLinksHoldingApps()
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ auth, err := s.reg.consoleRegistry.LinkChannelAuth()
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ owners, err := s.reg.consoleRegistry.LinkOwners()
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ for i, l := range s.links {
+ row, err := s.fx.st.linkRow(l.id)
+ if err != nil || row == nil {
+ s.t.Fatalf("L%d: links row %v %v", i, row, err)
+ }
+ if slices.Contains(need, l.id) {
+ s.failf("L%d: still needs a sync after three ticks", i)
+ }
+ if slices.Contains(holding, l.id) {
+ s.failf("L%d: revoked, and still holds apps rows after three ticks", i)
+ }
+ ch := s.regChannel(l.id)
+ hosts := s.forwardHosts(l.id)
+ apps, err := s.fx.st.LinkedApps(l.id)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ _, inAuth := auth[registry.LinkChannelName(l.id)]
+ if !row.RevokedAt.IsZero() {
+ if ch.ok && ch.status != "revoked" {
+ s.failf("L%d: revoked on the console, registry channel %q", i, ch.status)
+ }
+ if inAuth || owners[l.id] != "" {
+ s.failf("L%d: revoked on the console, yet in LinkChannelAuth or LinkOwners", i)
+ }
+ if len(hosts) != 0 {
+ s.failf("L%d: revoked on the console, registry forward rows %v", i, hosts)
+ }
+ if len(apps) != 0 {
+ s.failf("L%d: revoked on the console, apps rows %v", i, apps)
+ }
+ if _, ok := s.fx.st.CLIPrincipal(l.token, time.Now()); ok {
+ s.failf("L%d: revoked, yet its last token resolves", i)
+ }
+ continue
+ }
+ switch {
+ case !ch.ok || ch.status != "active":
+ s.failf("L%d: live on the console, registry channel %+v", i, ch)
+ case ch.hash != row.tokenHash:
+ s.failf("L%d: registry hash %s, console's current hash %s", i, ch.hash, row.tokenHash)
+ case ch.gen != row.generation:
+ s.failf("L%d: registry generation %d, console's %d", i, ch.gen, row.generation)
+ case ch.account != s.acct.Sqid || owners[l.id] != s.acct.Sqid:
+ s.failf("L%d: registry account %q (owners %q), want %q", i, ch.account, owners[l.id], s.acct.Sqid)
+ case auth[registry.LinkChannelName(l.id)] != row.tokenHash:
+ s.failf("L%d: LinkChannelAuth hash is not the current one", i)
+ }
+ if ch.hash != hashToken(l.token) {
+ s.failf("L%d: the registry hash is not the hash of the token the home holds", i)
+ }
+ for _, old := range l.old {
+ if _, ok := s.fx.st.CLIPrincipal(old, time.Now()); ok {
+ s.failf("L%d: a rotated-away token resolves", i)
+ }
+ }
+ var want []string
+ for _, a := range apps {
+ want = append(want, s.host(a.App))
+ }
+ slices.Sort(want)
+ got := slices.Clone(hosts)
+ slices.Sort(got)
+ if !slices.Equal(got, want) {
+ s.failf("L%d: registry forward rows %v, live publications %v", i, got, want)
+ }
+ rows, err := s.reg.consoleRegistry.LinkForwards(l.id)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ for _, rt := range rows {
+ if rt.Account != s.acct.Sqid || rt.Host != s.host(rt.App) || rt.Region != registry.LinkPlacementPrefix+l.id {
+ s.failf("L%d: forward row %+v does not name its publication", i, rt)
+ }
+ }
+ }
+}
+
+// cleanup unlinks every link the seed left live, with no faults, so the
+// next seed on the fixture starts from nothing.
+func (s *consoleSim) cleanup() {
+ ctx := context.Background()
+ for _, l := range s.links {
+ link, err := s.fx.st.LinkByID(l.id)
+ if err != nil || link == nil {
+ s.t.Fatalf("cleanup %s: %v %v", l.id, link, err)
+ }
+ if link.RevokedAt.IsZero() {
+ if err := s.fx.srv.unlink(ctx, link, "linksim"); err != nil {
+ s.t.Fatalf("cleanup unlink %s: %v", l.id, err)
+ }
+ }
+ if hosts := s.forwardHosts(l.id); len(hosts) != 0 {
+ s.t.Fatalf("cleanup %s: forward rows %v", l.id, hosts)
+ }
+ if apps, _ := s.fx.st.LinkedApps(l.id); len(apps) != 0 {
+ s.t.Fatalf("cleanup %s: apps rows %v", l.id, apps)
+ }
+ }
+}
+
+func newConsoleSimFixture(t *testing.T) (*consoleFixture, *simFaultReg, *Account) {
+ fx := newLinkFixture(t, "tunnel.example.com")
+ reg := &simFaultReg{consoleRegistry: linkRegistryOf(t, fx), armed: map[string]simFault{}}
+ fx.srv.linkRegistry = func() (consoleRegistry, error) { return reg, nil }
+ return fx, reg, linkOpsAccount(t, fx)
+}
+
+// TestLinkSimServingSide runs the serving-side simulation.
+func TestLinkSimServingSide(t *testing.T) {
+ // A door's own retries back off 50, 150 and 400 ms; the sequence does
+ // not need the waits, only the retries.
+ saved := linkSyncRetryBackoff
+ linkSyncRetryBackoff = []time.Duration{time.Millisecond, time.Millisecond, time.Millisecond}
+ t.Cleanup(func() { linkSyncRetryBackoff = saved })
+
+ seeds, one := linkSimSeeds(t, linkSimDefaultSeeds)
+ lostReply := os.Getenv("LINKSIM_LOST_REPLY") == "1"
+ maxSteps := linkSimSteps(t, 40)
+ var fx *consoleFixture
+ var reg *simFaultReg
+ var acct *Account
+ start := time.Now()
+ failed := 0
+ stats := map[string]int{}
+ for i, seed := range seeds {
+ if one || i%linkSimBatch == 0 {
+ fx, reg, acct = newConsoleSimFixture(t)
+ }
+ rng := rand.New(rand.NewSource(seed))
+ s := &consoleSim{t: t, fx: fx, reg: reg, acct: acct, lostReply: lostReply, stats: stats}
+ s.logf("seed %d", seed)
+ s.mint()
+ s.mint()
+ n := 1 + rng.Intn(maxSteps)
+ for j := 0; j < n && len(s.fails) == 0; j++ {
+ s.step(rng)
+ }
+ if len(s.fails) == 0 {
+ s.settle()
+ s.check()
+ }
+ if len(s.fails) != 0 {
+ failed++
+ t.Errorf("seed %d (reproduce with LINKSIM_SEED=%d):\n%s\n\ntrace:\n %s",
+ seed, seed, strings.Join(s.fails, "\n"), strings.Join(s.trace, "\n "))
+ if failed == linkSimMaxFailedSeeds {
+ t.FailNow()
+ }
+ }
+ s.cleanup()
+ }
+ t.Logf("%d seeds, up to %d steps each, in %s; exercised:\n%s", len(seeds), maxSteps,
+ time.Since(start).Round(time.Millisecond), linkSimStats(stats))
+}
+
+// linkSimStats renders a run's counts, one per line, sorted.
+func linkSimStats(stats map[string]int) string {
+ keys := make([]string, 0, len(stats))
+ for k := range stats {
+ keys = append(keys, k)
+ }
+ slices.Sort(keys)
+ var b strings.Builder
+ for _, k := range keys {
+ fmt.Fprintf(&b, " %6d %s\n", stats[k], k)
+ }
+ return b.String()
+}
diff --git a/internal/edge/edge.go b/internal/edge/edge.go
index fb50e2c56..54a5d37b6 100644
--- a/internal/edge/edge.go
+++ b/internal/edge/edge.go
@@ -934,6 +934,22 @@ func (e *Edge) Reload() error {
e.reloadMu.Lock()
defer e.reloadMu.Unlock()
e.loadDemoMoved()
+ // Link credentials first, and applied at once (SetLinkAuth): a link's
+ // revocation or rotation (linked deployments spec §5.3, §6.2) closes
+ // the home connection on the old hash and refuses it as soon as this
+ // read succeeds, never behind the rest of the reload, whose later
+ // failure would otherwise keep it connected and served until a reload
+ // completes. Admitting a new hash early is harmless: a connection
+ // carries only what the map, published below, routes to it. The same
+ // read is merged into the whole set further down.
+ var linkAuth map[string]string
+ if e.tunnels != nil {
+ var err error
+ if linkAuth, err = e.reg.LinkChannelAuth(); err != nil {
+ return err
+ }
+ e.tunnels.SetLinkAuth(linkAuth)
+ }
routes, err := e.reg.List()
if err != nil {
return err
@@ -976,8 +992,9 @@ func (e *Edge) Reload() error {
// pass and the edges-file writer) on a box whose tunnels are enabled.
//
// Links (linked deployments spec §6.2) ride the same pass: each active
- // link's channel hash (LinkChannelAuth) is merged into the set the hub
- // authenticates by, and its owner (LinkOwners) is what the verdict
+ // link's channel hash (LinkChannelAuth, read and applied at the top of
+ // the reload) is merged into the set the hub authenticates by, so the
+ // swap below keeps it, and its owner (LinkOwners) is what the verdict
// judges a link-placed forward row by. Link owners never enter the door's
// fleet snapshot.
var channelAuth map[string]string
@@ -997,10 +1014,6 @@ func (e *Edge) Reload() error {
if err != nil {
return err
}
- linkAuth, err := e.reg.LinkChannelAuth()
- if err != nil {
- return err
- }
channelAuth = make(map[string]string, len(fleetAuth)+len(linkAuth))
maps.Copy(channelAuth, fleetAuth)
for name, hash := range linkAuth {
diff --git a/internal/edge/link_sim_test.go b/internal/edge/link_sim_test.go
new file mode 100644
index 000000000..a6397f3b5
--- /dev/null
+++ b/internal/edge/link_sim_test.go
@@ -0,0 +1,784 @@
+package edge
+
+// Linked deployments slice 1, Task 11: the revocation invariant on the hub
+// side, checked by seeded random sequences.
+//
+// The hub registry is the contract: the serving console writes it, and the
+// hub follows it on reload. Each sequence interleaves registry mutations as
+// any writer could make them (a channel put at a higher or a stale
+// generation, sometimes for another account; a revocation; a link forward
+// row put or deleted) with homes dialling the hub with the current token, an
+// older one or a made-up one, dials whose registration is overtaken by a
+// mutation and a reload between authentication and publication (afterAuth),
+// homes that go away, visitor requests, and reloads, some of which fail
+// part-way (an error from the reload's afterRead or beforePublish point,
+// the error returns before and after the channel credentials apply).
+//
+// After the sequence and one reload, the invariant: no channel is connected
+// on a hash that is not the registry's active one for that link, and no
+// request is dialled down a link for a row the registry no longer holds (a
+// visitor request reaches a home only for a link forward row the registry
+// holds, on an active link owned by the row's account). As a liveness
+// check, a row whose active link has a live connection on its current hash
+// does reach that home. When that one reload fails, the credential half
+// must hold anyway and the row half is checked after the next reload (see
+// check).
+//
+// What it found: a reload that failed after its registry reads left a
+// revoked or rotated-away home connected and served until a reload
+// completed, since the credentials were applied only at the end of a
+// successful reload. Reload now applies the link credentials first
+// (TunnelHub.SetLinkAuth); hubSimRegressionSeeds and
+// TestLinkRevocationSurvivesAFailedReload keep the finding.
+//
+// The whole hub is real: the registry, Edge.Reload, the TunnelHub and its
+// registration path, and the visitor path through Edge.ServeHTTP to
+// linkProxy. A home is a registration made by hand over TCP (the
+// tunnelclient's own serving loop on the hijacked connection) whose handler
+// records what reached it.
+//
+// Seeds: LINKSIM_SEEDS=n runs n seeds (default linkSimDefaultSeeds),
+// LINKSIM_SEED=s runs seed s alone in a fresh hub (the reproduction of a
+// failure, which prints its seed and trace). LINKSIM_STEPS caps the steps
+// per seed.
+
+import (
+ "bufio"
+ "database/sql"
+ "errors"
+ "fmt"
+ "io"
+ "math/rand"
+ "net"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "os"
+ "path/filepath"
+ "slices"
+ "strconv"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/tunnelclient"
+)
+
+const (
+ linkSimDefaultSeeds = 500
+ linkSimBatch = 50
+ linkSimMaxFailedSeeds = 3
+)
+
+func linkSimSeeds(t *testing.T, def int) (seeds []int64, one bool) {
+ t.Helper()
+ if s := os.Getenv("LINKSIM_SEED"); s != "" {
+ n, err := strconv.ParseInt(s, 10, 64)
+ if err != nil {
+ t.Fatalf("LINKSIM_SEED=%q: %v", s, err)
+ }
+ return []int64{n}, true
+ }
+ n := def
+ if s := os.Getenv("LINKSIM_SEEDS"); s != "" {
+ v, err := strconv.Atoi(s)
+ if err != nil || v < 1 {
+ t.Fatalf("LINKSIM_SEEDS=%q: want a positive count", s)
+ }
+ n = v
+ }
+ for i := 1; i <= n; i++ {
+ seeds = append(seeds, int64(i))
+ }
+ return seeds, false
+}
+
+func linkSimSteps(t *testing.T, def int) int {
+ t.Helper()
+ if s := os.Getenv("LINKSIM_STEPS"); s != "" {
+ v, err := strconv.Atoi(s)
+ if err != nil || v < 1 {
+ t.Fatalf("LINKSIM_STEPS=%q: want a positive count", s)
+ }
+ return v
+ }
+ return def
+}
+
+var errHubSimReload = errors.New("linksim: injected reload failure")
+
+// hubSim is one hub and the seed running on it.
+type hubSim struct {
+ t *testing.T
+ hub *Edge
+ reg *registry.Registry
+ regPath string
+ url string
+ seed int64
+ links []*hubSimLink
+ homes []*hubSimHome
+ trace []string
+ fails []string
+ // reloadFault, when set, is where the next reload fails: "afterRead"
+ // or "beforePublish". One reload only.
+ reloadFault string
+ tokens int
+ stats map[string]int // what the run exercised, summed over seeds
+}
+
+// hubSimLink is one link of the seed: its ID and every token any writer
+// has put for it (the newest last).
+type hubSimLink struct {
+ id string
+ tokens []string
+}
+
+// hubSimHome is one registration made by hand: the link and token it
+// dialled with, its connection, and what reached it.
+type hubSimHome struct {
+ n int
+ link int
+ token string
+ conn net.Conn
+ local string
+ done chan struct{}
+ mu sync.Mutex
+ served []string // Carlos-Link-App of each request that reached it
+}
+
+func (h *hubSimHome) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ h.mu.Lock()
+ h.served = append(h.served, strings.Join(r.Header.Values(tunnelclient.LinkAppHeader), ","))
+ h.mu.Unlock()
+ w.Header().Set("X-Sim-Home", strconv.Itoa(h.n))
+ io.WriteString(w, "home")
+}
+
+func (h *hubSimHome) ended() bool {
+ select {
+ case <-h.done:
+ return true
+ default:
+ return false
+ }
+}
+
+func (s *hubSim) logf(format string, args ...any) {
+ s.trace = append(s.trace, fmt.Sprintf(format, args...))
+}
+
+func (s *hubSim) failf(format string, args ...any) {
+ s.fails = append(s.fails, fmt.Sprintf(format, args...))
+}
+
+var hubSimNames = []string{"shop", "blog", "news"}
+
+// host is the public hostname of name in the seed (distinct per seed, so
+// seeds sharing a hub never share a row).
+func (s *hubSim) host(name string) string {
+ return fmt.Sprintf("%s-%d.%s.apps.example.com", name, s.seed, fwdOwner)
+}
+
+func (s *hubSim) newToken(li int) string {
+ s.tokens++
+ return fmt.Sprintf("tok-%d-%d-%d", s.seed, li, s.tokens)
+}
+
+// hubSimChannel is a link's link_channels row, read straight from the file.
+type hubSimChannel struct {
+ ok bool
+ status, hash, account string
+ gen int64
+}
+
+func (s *hubSim) channel(id string) hubSimChannel {
+ db, err := sql.Open("sqlite", "file:"+s.regPath+"?mode=ro")
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ defer db.Close()
+ var c hubSimChannel
+ err = db.QueryRow(`SELECT status, token_hash, account, generation FROM link_channels WHERE link_id = ?`, id).
+ Scan(&c.status, &c.hash, &c.account, &c.gen)
+ if errors.Is(err, sql.ErrNoRows) {
+ return c
+ }
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ c.ok = true
+ return c
+}
+
+// reload runs one hub reload, failing it at the armed point if one is.
+func (s *hubSim) reload(why string) error {
+ at := s.reloadFault
+ s.reloadFault = ""
+ fail := func(point string) func(uint64) error {
+ return func(uint64) error {
+ if at == point {
+ return errHubSimReload
+ }
+ return nil
+ }
+ }
+ s.hub.hooks = &reloadHooks{afterRead: fail("afterRead"), beforePublish: fail("beforePublish")}
+ err := s.hub.Reload()
+ s.hub.hooks = nil
+ s.logf("%s: reload (fault %q) -> %v", why, at, err)
+ if err != nil {
+ s.stats["reloads failed at "+at]++
+ } else {
+ s.stats["reloads"]++
+ }
+ if err != nil && !errors.Is(err, errHubSimReload) {
+ s.failf("reload: %v", err)
+ }
+ return err
+}
+
+// put writes a channel row for link li as a writer would, at generation
+// gen with a fresh token, and checks the registry's one-writer rules.
+func (s *hubSim) put(li int, gen int64, account, why string) {
+ l := s.links[li]
+ before := s.channel(l.id)
+ tok := s.newToken(li)
+ applied, err := s.reg.PutLinkChannel(registry.LinkChannel{LinkID: l.id, Account: account,
+ TokenHash: sha256Hex(tok), Status: "active", Generation: uint64(gen)})
+ s.logf("%s L%d gen %d account %s token %s -> applied %v %v (stored %+v)", why, li, gen, account, tok, applied, err, before)
+ if err != nil {
+ s.failf("PutLinkChannel L%d: %v", li, err)
+ return
+ }
+ want := !before.ok || (before.status != "revoked" && gen > before.gen)
+ if applied != want {
+ s.failf("PutLinkChannel L%d gen %d over %+v applied %v, want %v", li, gen, before, applied, want)
+ }
+ if applied {
+ l.tokens = append(l.tokens, tok)
+ }
+}
+
+// dial registers a home for link li with token. With race set, a mutation
+// and a reload land between the hub's authentication of it and its
+// publication. It waits until the hub has published the connection or
+// closed it.
+func (s *hubSim) dial(li int, token string, race func()) {
+ l := s.links[li]
+ name := registry.LinkChannelName(l.id)
+ // raced is closed once race has run inside the hub's registration.
+ raced := make(chan struct{})
+ if race != nil {
+ var once sync.Once
+ s.hub.tunnels.afterAuth = func(n string) {
+ if n == name {
+ once.Do(func() {
+ race()
+ close(raced)
+ })
+ }
+ }
+ defer func() { s.hub.tunnels.afterAuth = nil }()
+ }
+ u, err := url.Parse(s.url)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ conn, err := net.Dial("tcp", u.Host)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ req := tunnelReq(name, token)
+ req.Host = s.hub.tunnels.Host()
+ req.Header.Set(tunnelclient.CapsHeader, tunnelclient.CapUpgrade)
+ if err := req.Write(conn); err != nil {
+ s.t.Fatal(err)
+ }
+ br := bufio.NewReader(conn)
+ resp, err := http.ReadResponse(br, req)
+ if err != nil {
+ s.t.Fatalf("registration %s: %v", name, err)
+ }
+ if resp.StatusCode != http.StatusSwitchingProtocols {
+ conn.Close()
+ s.logf("dial L%d token %s race=%v -> %d", li, token, race != nil, resp.StatusCode)
+ s.stats[fmt.Sprintf("dials refused %d", resp.StatusCode)]++
+ if resp.StatusCode != http.StatusUnauthorized {
+ s.failf("dial L%d answered %d", li, resp.StatusCode)
+ }
+ return
+ }
+ h := &hubSimHome{n: len(s.homes), link: li, token: token, conn: conn, local: conn.LocalAddr().String(), done: make(chan struct{})}
+ s.homes = append(s.homes, h)
+ go func() {
+ tunnelclient.ServeWith(&readerConn{Conn: conn, r: io.MultiReader(br, conn)}, tunnelclient.Mark(h), tunnelclient.DefaultLimits)
+ close(h.done)
+ }()
+ if race != nil {
+ select {
+ case <-raced:
+ case <-time.After(5 * time.Second):
+ s.failf("dial L%d: the registration never reached its publication", li)
+ return
+ }
+ }
+ // The hub writes the 101 before it publishes the connection (or
+ // refuses it at publication): wait for one or the other.
+ deadline := time.Now().Add(5 * time.Second)
+ for !s.published(h) && !h.ended() {
+ if time.Now().After(deadline) {
+ s.failf("dial L%d home %d: neither published nor closed after 5 s", li, h.n)
+ return
+ }
+ time.Sleep(time.Millisecond)
+ }
+ s.logf("dial L%d token %s race=%v -> 101, home %d published=%v", li, token, race != nil, h.n, s.published(h))
+ if s.published(h) {
+ s.stats["dials published"]++
+ } else {
+ s.stats["dials refused at publication"]++
+ }
+ if race != nil {
+ s.stats["dials overtaken between auth and publish"]++
+ }
+}
+
+// published reports whether the hub's live connection for h's link is h's.
+func (s *hubSim) published(h *hubSimHome) bool {
+ tc := s.hub.tunnels.channel(registry.LinkChannelName(s.links[h.link].id))
+ return tc != nil && tc.raw.RemoteAddr().String() == h.local
+}
+
+// visit sends a visitor's GET for host to the hub and reports which home
+// answered (-1 for none) with the status.
+func (s *hubSim) visit(host string) (home, status int) {
+ req, err := http.NewRequest("GET", s.url+"/sim", nil)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ req.Host = host
+ resp, err := http.DefaultClient.Do(req)
+ if err != nil {
+ s.t.Fatalf("GET %s: %v", host, err)
+ }
+ io.Copy(io.Discard, resp.Body)
+ resp.Body.Close()
+ home = -1
+ if v := resp.Header.Get("X-Sim-Home"); v != "" {
+ home, _ = strconv.Atoi(v)
+ }
+ return home, resp.StatusCode
+}
+
+// mutate makes one random registry mutation.
+func (s *hubSim) mutate(rng *rand.Rand) {
+ li := rng.Intn(len(s.links))
+ l := s.links[li]
+ name := hubSimNames[rng.Intn(len(hubSimNames))]
+ c := s.channel(l.id)
+ switch r := rng.Intn(100); {
+ case r < 30: // a channel put at a higher generation
+ account := fwdOwner
+ if rng.Intn(10) == 0 {
+ account = fwdOther
+ }
+ s.put(li, c.gen+1+int64(rng.Intn(2)), account, "put")
+ case r < 45: // a stale or replayed channel put
+ gen := int64(0)
+ if c.gen > 0 {
+ gen = rng.Int63n(c.gen + 1)
+ }
+ s.put(li, gen, fwdOwner, "stale put")
+ case r < 55:
+ moved, err := s.reg.RevokeLinkChannel(l.id)
+ s.logf("revoke L%d -> %v %v", li, moved, err)
+ if err != nil {
+ s.failf("RevokeLinkChannel L%d: %v", li, err)
+ }
+ case r < 82: // a link forward row put
+ account := c.account
+ if account == "" || rng.Intn(10) == 0 {
+ account = fwdOther
+ }
+ err := s.reg.PutForward(registry.Route{Host: s.host(name), Kind: registry.KindForward, Slug: name, App: name,
+ Account: account, Region: registry.LinkPlacementPrefix + l.id, Channel: "production"})
+ s.logf("forward put L%d %s account %s -> %v", li, name, account, err)
+ default:
+ deleted, err := s.reg.DeleteLinkForward(s.host(name), l.id)
+ s.logf("forward delete L%d %s -> %v %v", li, name, deleted, err)
+ }
+}
+
+// step runs one random step.
+func (s *hubSim) step(rng *rand.Rand) {
+ switch r := rng.Intn(100); {
+ case r < 40:
+ s.mutate(rng)
+ case r < 66: // a home dials; some registrations are overtaken
+ li := rng.Intn(len(s.links))
+ l := s.links[li]
+ var token string
+ switch k := rng.Intn(10); {
+ case k < 6 && len(l.tokens) > 0:
+ token = l.tokens[len(l.tokens)-1]
+ case k < 9 && len(l.tokens) > 1:
+ token = l.tokens[rng.Intn(len(l.tokens)-1)]
+ default:
+ token = fmt.Sprintf("made-up-%d", rng.Int63())
+ }
+ var race func()
+ if r >= 60 {
+ race = func() {
+ s.mutate(rng)
+ if rng.Intn(3) == 0 {
+ s.reloadFault = []string{"afterRead", "beforePublish"}[rng.Intn(2)]
+ }
+ s.reload("between auth and publish")
+ }
+ }
+ s.dial(li, token, race)
+ case r < 78:
+ if rng.Intn(3) == 0 {
+ s.reloadFault = []string{"afterRead", "beforePublish"}[rng.Intn(2)]
+ }
+ s.reload("reload")
+ case r < 92:
+ host := s.host(hubSimNames[rng.Intn(len(hubSimNames))])
+ home, status := s.visit(host)
+ s.logf("visit %s -> %d home %d", host, status, home)
+ if home >= 0 {
+ s.stats["visits reaching a home"]++
+ } else {
+ s.stats[fmt.Sprintf("visits answered %d by the hub", status)]++
+ }
+ default: // a home goes away
+ if len(s.homes) == 0 {
+ return
+ }
+ h := s.homes[rng.Intn(len(s.homes))]
+ h.conn.Close()
+ <-h.done
+ s.logf("home %d (L%d) went away", h.n, h.link)
+ }
+}
+
+// check is the invariant after the last reload. loaded is whether that
+// reload completed: the row half and the liveness check need it.
+//
+// The credential half (no connection on a hash that is not the active one,
+// so nothing goes down a revoked or rotated-away connection) holds after
+// any reload that read the link credentials, since Reload applies them
+// first (TunnelHub.SetLinkAuth). The row half (a request is dialled only
+// for a row the registry holds) needs the new routing map, which only a
+// reload that completes publishes: after a failed one, a row deleted from,
+// or moved off, a link whose connection is current still routes down that
+// connection until the next reload that completes (Edge.Watch retries
+// every 2 s). The home refuses such a request itself (its per-request
+// published-set check, Task 8), and every unpublish starts at the home.
+// The simulation checks the row half after the next reload, which
+// completes.
+func (s *hubSim) check(loaded bool) {
+ auth, err := s.reg.LinkChannelAuth()
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ owners, err := s.reg.LinkOwners()
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ // No channel is connected on a hash that is not the registry's active
+ // one for its link.
+ for _, h := range s.homes {
+ if !s.published(h) {
+ continue
+ }
+ s.stats["connections live at a check"]++
+ l := s.links[h.link]
+ active, ok := auth[registry.LinkChannelName(l.id)]
+ if !ok || active != sha256Hex(h.token) {
+ s.failf("home %d is connected for L%d on token %s; the registry's active hash is %q (active=%v)",
+ h.n, h.link, h.token, active, ok)
+ }
+ }
+ // A visitor request reaches a home only for a row the registry holds.
+ for _, name := range hubSimNames {
+ host := s.host(name)
+ rt, err := s.reg.Get(host)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ before := make([]int, len(s.homes))
+ for i, h := range s.homes {
+ h.mu.Lock()
+ before[i] = len(h.served)
+ h.mu.Unlock()
+ }
+ home, status := s.visit(host)
+ reached := -1
+ for i, h := range s.homes {
+ h.mu.Lock()
+ if len(h.served) > before[i] {
+ reached = i
+ if got := h.served[len(h.served)-1]; got != name {
+ s.failf("visit %s reached home %d naming %q, want %q", host, i, got, name)
+ }
+ }
+ h.mu.Unlock()
+ }
+ if reached != home {
+ s.failf("visit %s: X-Sim-Home %d but home %d recorded it", host, home, reached)
+ }
+ var rowLink = -1
+ if rt != nil && rt.IsForward() {
+ if id, ok := registry.LinkPlacement(rt.Region); ok {
+ for i, l := range s.links {
+ if l.id == id {
+ rowLink = i
+ }
+ }
+ }
+ }
+ if reached >= 0 {
+ s.stats["check visits reaching a home"]++
+ h := s.homes[reached]
+ l := s.links[h.link]
+ switch {
+ case auth[registry.LinkChannelName(l.id)] != sha256Hex(h.token):
+ s.failf("visit %s went down home %d, connected on a hash that is not L%d's active one", host, reached, h.link)
+ case !loaded:
+ // The row half waits on a reload that completes (see
+ // check's comment).
+ case rowLink < 0:
+ s.failf("visit %s reached home %d (L%d) but the registry holds no link row for it (%+v)", host, reached, h.link, rt)
+ case rowLink != h.link:
+ s.failf("visit %s reached home %d of L%d, but the registry's row is L%d's", host, reached, h.link, rowLink)
+ case owners[l.id] == "" || owners[l.id] != rt.Account:
+ s.failf("visit %s reached L%d, whose registry owner is %q, for a row of account %q", host, h.link, owners[l.id], rt.Account)
+ }
+ continue
+ }
+ // Liveness: an admitted row with a live connection on the current
+ // hash reaches that home.
+ if loaded && rowLink >= 0 && rt.Account != "" && owners[s.links[rowLink].id] == rt.Account {
+ for _, h := range s.homes {
+ if h.link == rowLink && s.published(h) && !h.ended() &&
+ auth[registry.LinkChannelName(s.links[rowLink].id)] == sha256Hex(h.token) {
+ s.failf("visit %s (%d) reached no home, though L%d's row is admitted and home %d is live on its hash",
+ host, status, rowLink, h.n)
+ }
+ }
+ }
+ }
+ s.logf("check: done")
+}
+
+// cleanup revokes the seed's links, reloads, and closes its homes, so the
+// next seed on the hub starts with no live link connection.
+func (s *hubSim) cleanup() {
+ for _, l := range s.links {
+ if _, err := s.reg.RevokeLinkChannel(l.id); err != nil {
+ s.t.Fatal(err)
+ }
+ }
+ if err := s.hub.Reload(); err != nil {
+ s.t.Fatal(err)
+ }
+ for _, h := range s.homes {
+ h.conn.Close()
+ select {
+ case <-h.done:
+ case <-time.After(5 * time.Second):
+ s.t.Fatalf("seed %d cleanup: home %d did not end", s.seed, h.n)
+ }
+ }
+}
+
+// hubSimFixture is a hub as newLinkScene builds one, with no links yet.
+type hubSimFixture struct {
+ hub *Edge
+ reg *registry.Registry
+ regPath string
+ url string
+}
+
+func newHubSimFixture(t *testing.T) hubSimFixture {
+ t.Helper()
+ regPath := filepath.Join(t.TempDir(), "registry.db")
+ reg, err := registry.Open(regPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ hub, err := New(reg, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(hub.probers.Stop)
+ srv := httptest.NewServer(hub)
+ t.Cleanup(srv.Close)
+ u, err := url.Parse(srv.URL)
+ if err != nil {
+ t.Fatal(err)
+ }
+ hub.EnableTunnels(NewTunnelHub(u.Hostname(), nil))
+ if err := hub.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ return hubSimFixture{hub: hub, reg: reg, regPath: regPath, url: srv.URL}
+}
+
+// TestLinkSimHubSide runs the hub-side simulation.
+func TestLinkSimHubSide(t *testing.T) {
+ seeds, one := linkSimSeeds(t, linkSimDefaultSeeds)
+ runHubSim(t, seeds, one, linkSimSteps(t, 40))
+}
+
+// hubSimRegressionSeeds failed before Reload applied the link credentials
+// ahead of its other reads (TunnelHub.SetLinkAuth): each ends with a reload
+// that fails after the credential read, which left a rotated-away (28,
+// 130) or revoked (28, 73) home connected and served. They name sequences of
+// this file's generator: a change to it changes what they replay.
+var hubSimRegressionSeeds = []int64{28, 73, 130}
+
+// TestLinkSimHubSideRegressions runs the seeds that found a violation, each
+// on a fresh hub, with the step count they were found with.
+func TestLinkSimHubSideRegressions(t *testing.T) {
+ runHubSim(t, hubSimRegressionSeeds, true, 40)
+}
+
+// runHubSim runs seeds, on a fresh hub for each when fresh is set and on
+// one hub per linkSimBatch seeds otherwise.
+func runHubSim(t *testing.T, seeds []int64, fresh bool, maxSteps int) {
+ // The hub test (HubArmed) for every fixture of the run.
+ t.Setenv("CARLOS_TUNNEL_HOST", "127.0.0.1")
+ t.Setenv("CARLOS_FLEET", "")
+ var fx hubSimFixture
+ start := time.Now()
+ failed := 0
+ stats := map[string]int{}
+ for i, seed := range seeds {
+ if fresh || i%linkSimBatch == 0 {
+ fx = newHubSimFixture(t)
+ }
+ rng := rand.New(rand.NewSource(seed))
+ s := &hubSim{t: t, hub: fx.hub, reg: fx.reg, regPath: fx.regPath, url: fx.url, seed: seed, stats: stats}
+ s.logf("seed %d", seed)
+ nLinks := 1 + rng.Intn(3)
+ for k := 0; k < nLinks; k++ {
+ s.links = append(s.links, &hubSimLink{id: fmt.Sprintf("%08x%04x", seed, k)})
+ s.put(k, 1, fwdOwner, "link")
+ }
+ // Each name starts published on one of the links.
+ for i, name := range hubSimNames {
+ l := s.links[rng.Intn(len(s.links))]
+ err := s.reg.PutForward(registry.Route{Host: s.host(name), Kind: registry.KindForward, Slug: name, App: name,
+ Account: fwdOwner, Region: registry.LinkPlacementPrefix + l.id, Channel: "production"})
+ if err != nil {
+ t.Fatalf("seed %d: forward row %d: %v", seed, i, err)
+ }
+ }
+ s.reload("start")
+ n := 1 + rng.Intn(maxSteps)
+ for j := 0; j < n && len(s.fails) == 0; j++ {
+ s.step(rng)
+ }
+ if len(s.fails) == 0 {
+ // One reload, which may itself fail part-way.
+ if rng.Intn(4) == 0 {
+ s.reloadFault = []string{"afterRead", "beforePublish"}[rng.Intn(2)]
+ }
+ err := s.reload("final")
+ s.check(err == nil)
+ if err != nil && len(s.fails) == 0 {
+ // The next reload completes: now the whole invariant.
+ s.reload("after the failed one")
+ s.check(true)
+ }
+ }
+ if len(s.fails) != 0 {
+ failed++
+ t.Errorf("seed %d (reproduce with LINKSIM_SEED=%d):\n%s\n\ntrace:\n %s",
+ seed, seed, strings.Join(s.fails, "\n"), strings.Join(s.trace, "\n "))
+ if failed == linkSimMaxFailedSeeds {
+ t.FailNow()
+ }
+ }
+ s.cleanup()
+ }
+ t.Logf("%d seeds, up to %d steps each, in %s; exercised:\n%s", len(seeds), maxSteps,
+ time.Since(start).Round(time.Millisecond), linkSimStats(stats))
+}
+
+// linkSimStats renders a run's counts, one per line, sorted.
+func linkSimStats(stats map[string]int) string {
+ keys := make([]string, 0, len(stats))
+ for k := range stats {
+ keys = append(keys, k)
+ }
+ slices.Sort(keys)
+ var b strings.Builder
+ for _, k := range keys {
+ fmt.Fprintf(&b, " %6d %s\n", stats[k], k)
+ }
+ return b.String()
+}
+
+// TestLinkRevocationSurvivesAFailedReload is the regression seeds' finding
+// as one fixed scene: a home connected on its link's token; the link is
+// revoked (or rotated) in the registry; the next reload fails after its
+// registry reads. The home's connection is closed anyway, and its token is
+// refused, by that failed reload.
+func TestLinkRevocationSurvivesAFailedReload(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ change func(t *testing.T, s linkScene)
+ }{
+ {"revoked", func(t *testing.T, s linkScene) {
+ if _, err := s.reg.RevokeLinkChannel(linkTestID); err != nil {
+ t.Fatal(err)
+ }
+ }},
+ {"rotated", func(t *testing.T, s linkScene) { putLinkChannel(t, s.reg, fwdOwner, linkTestTokB, 2) }},
+ } {
+ for _, point := range []string{"afterRead", "beforePublish"} {
+ t.Run(tc.name+"/"+point, func(t *testing.T) {
+ s := newLinkScene(t, nil, linkForwardRow(linkTestHost, linkTestID, fwdOwner))
+ home := &linkHome{body: "home"}
+ a := dialByHand(t, s, linkTestName, linkTestTok, home)
+ if a.status != http.StatusSwitchingProtocols {
+ t.Fatalf("registration = %d, want 101", a.status)
+ }
+ waitForTunnelState(t, s.hub.tunnels, linkTestName, "connected", e2eReconnectBound)
+
+ tc.change(t, s)
+ fail := func(at string) func(uint64) error {
+ return func(uint64) error {
+ if at == point {
+ return errHubSimReload
+ }
+ return nil
+ }
+ }
+ s.hub.hooks = &reloadHooks{afterRead: fail("afterRead"), beforePublish: fail("beforePublish")}
+ if err := s.hub.Reload(); !errors.Is(err, errHubSimReload) {
+ t.Fatalf("Reload = %v, want the injected failure", err)
+ }
+ s.hub.hooks = nil
+ waitClosed(t, a.done, "the connection on the old credential")
+ if c := s.hub.tunnels.channel(linkTestName); c != nil {
+ t.Fatalf("%s still has a live connection", linkTestName)
+ }
+ if again := dialByHand(t, s, linkTestName, linkTestTok, home); again.status != http.StatusUnauthorized {
+ t.Fatalf("redial with the old token = %d, want 401", again.status)
+ }
+ if resp, body := linkDo(t, s.url, linkTestHost, "/", nil); resp.StatusCode == http.StatusOK || body == "home" {
+ t.Fatalf("GET after the failed reload = %d %q, want no answer from the home", resp.StatusCode, body)
+ }
+ if got := home.requests(); len(got) != 0 {
+ t.Fatalf("the home was dialled %d times after its credential went", len(got))
+ }
+ })
+ }
+ }
+}
diff --git a/internal/edge/reload_guard_test.go b/internal/edge/reload_guard_test.go
index 57e6895bf..6afa7900e 100644
--- a/internal/edge/reload_guard_test.go
+++ b/internal/edge/reload_guard_test.go
@@ -125,7 +125,7 @@ func TestReloadIsTheOnlyPublisher(t *testing.T) {
switch {
case sel.Sel.Name == "Store" && strings.HasSuffix(selChain(sel.X), ".upstreams"):
stores = append(stores, at)
- case sel.Sel.Name == "SetDynamicAuth":
+ case sel.Sel.Name == "SetDynamicAuth" || sel.Sel.Name == "SetLinkAuth":
dynAuth = append(dynAuth, at)
case sel.Sel.Name == "sweepUpgrades":
sweeps = append(sweeps, at)
@@ -154,7 +154,7 @@ func TestReloadIsTheOnlyPublisher(t *testing.T) {
}
}
only("e.upstreams.Store", stores, 1)
- only("SetDynamicAuth", dynAuth, 0)
+ only("SetDynamicAuth or SetLinkAuth", dynAuth, 0)
only("sweepUpgrades", sweeps, 1)
only("reloadMu", reloadMu, 0)
if t.Failed() {
diff --git a/internal/edge/tunnel.go b/internal/edge/tunnel.go
index 658b472ab..0bdb35cc0 100644
--- a/internal/edge/tunnel.go
+++ b/internal/edge/tunnel.go
@@ -527,6 +527,41 @@ func (h *TunnelHub) verifyLinkLocked(name, token string) (linkID string, ok bool
// not by name, so a home that redials with the new token in the gap keeps
// its fresh connection. A link that leaves the set is closed the same way.
func (h *TunnelHub) SetDynamicAuth(auth map[string]string) {
+ h.swapAuth(func(map[string]string) map[string]string { return auth })
+}
+
+// SetLinkAuth replaces only the link half of the credential set with links
+// (link channel name -> sha256 hex, the registry's LinkChannelAuth) and
+// keeps every fleet entry as it is. Link connections whose hash changed or
+// went are closed as SetDynamicAuth closes them; no fleet channel is
+// touched. Reload calls it as soon as it has read the link credentials,
+// ahead of every other read, so a link's revocation or rotation does not
+// wait on the rest of the reload succeeding (Task 11's hub simulation: a
+// reload that failed after that read used to leave a revoked home
+// connected, and served, until the next reload that completed). A name in
+// links that is not a well-formed link channel name is ignored.
+func (h *TunnelHub) SetLinkAuth(links map[string]string) {
+ h.swapAuth(func(old map[string]string) map[string]string {
+ next := make(map[string]string, len(old)+len(links))
+ for name, hash := range old {
+ if _, isLink := registry.LinkOfChannel(name); !isLink {
+ next[name] = hash
+ }
+ }
+ for name, hash := range links {
+ if _, isLink := registry.LinkOfChannel(name); isLink {
+ next[name] = hash
+ }
+ }
+ return next
+ })
+}
+
+// swapAuth replaces the credential set with next(old), under h.mu, and
+// then closes what the replacement revoked: each fleet name that left the
+// set (CloseChannel), and each link connection live at the swap whose hash
+// changed or went (closeConn on that connection).
+func (h *TunnelHub) swapAuth(next func(old map[string]string) map[string]string) {
type captured struct {
name string
tc *tunnelConn
@@ -534,6 +569,7 @@ func (h *TunnelHub) SetDynamicAuth(auth map[string]string) {
var links []captured
h.mu.Lock()
old := h.dynamicAuth
+ auth := next(old)
h.dynamicAuth = auth
for name, oldHash := range old {
if _, isLink := registry.LinkOfChannel(name); !isLink {
diff --git a/internal/edge/tunnel_publish_guard_test.go b/internal/edge/tunnel_publish_guard_test.go
index 1872f4244..2c239de55 100644
--- a/internal/edge/tunnel_publish_guard_test.go
+++ b/internal/edge/tunnel_publish_guard_test.go
@@ -2,8 +2,9 @@ package edge
// Tunnel WebSockets (#471) Task 4: a dynamic channel's registration checks
// its credential again as it publishes the connection, and the check and
-// the publish sit inside one TunnelHub.mu hold; SetDynamicAuth replaces the
-// credential map under that same mutex. Between them, a publish and a
+// the publish sit inside one TunnelHub.mu hold; SetDynamicAuth (and
+// SetLinkAuth, through swapAuth) replaces the credential map under that
+// same mutex. Between them, a publish and a
// replacement exclude each other, so a detach can never leave a revoked box
// with a live channel. A source check over tunnel.go, in the manner of
// reload_guard_test.go, so moving the re-check out of the lock, unlocking
@@ -156,16 +157,34 @@ func TestTunnelRegistrationRecheckAndPublishShareOneLock(t *testing.T) {
unlocksOnlyToLeave(t, fset, "ServeHTTP", s)
}
- // SetDynamicAuth: the map is replaced, and the old one read, inside
- // one h.mu hold; nothing else in tunnel.go assigns h.dynamicAuth.
- set := fns["(*TunnelHub).SetDynamicAuth"]
+ // swapAuth: the map is replaced, and the old one read, inside one h.mu
+ // hold; nothing else in tunnel.go assigns h.dynamicAuth. SetDynamicAuth
+ // and SetLinkAuth (Task 11: Reload applies the link half first) replace
+ // it only through swapAuth.
+ for _, via := range []string{"(*TunnelHub).SetDynamicAuth", "(*TunnelHub).SetLinkAuth"} {
+ fd := fns[via]
+ if fd == nil {
+ t.Fatalf("no %s in tunnel.go", via)
+ }
+ calls := false
+ ast.Inspect(fd.Body, func(n ast.Node) bool {
+ if c, ok := n.(*ast.CallExpr); ok && selChain(c.Fun) == "h.swapAuth" {
+ calls = true
+ }
+ return true
+ })
+ if !calls {
+ t.Errorf("%s does not replace the credential set through h.swapAuth", via)
+ }
+ }
+ set := fns["(*TunnelHub).swapAuth"]
if set == nil {
- t.Fatal("no (*TunnelHub).SetDynamicAuth in tunnel.go")
+ t.Fatal("no (*TunnelHub).swapAuth in tunnel.go")
}
sb := set.Body.List
slock, sunlock := lockedSpan(sb)
if slock < 0 {
- t.Fatal("SetDynamicAuth does not call h.mu.Lock() as a statement of its body")
+ t.Fatal("swapAuth does not call h.mu.Lock() as a statement of its body")
}
replace, readOld := -1, -1
for i, s := range sb {
@@ -181,13 +200,13 @@ func TestTunnelRegistrationRecheckAndPublishShareOneLock(t *testing.T) {
}
}
if replace < 0 {
- t.Fatal("SetDynamicAuth does not assign h.dynamicAuth as a statement of its body")
+ t.Fatal("swapAuth does not assign h.dynamicAuth as a statement of its body")
}
if !(slock < replace && replace < sunlock) {
- t.Fatalf("SetDynamicAuth replaces h.dynamicAuth (statement %d) outside its h.mu hold (Lock at %d, Unlock at %d)", replace, slock, sunlock)
+ t.Fatalf("swapAuth replaces h.dynamicAuth (statement %d) outside its h.mu hold (Lock at %d, Unlock at %d)", replace, slock, sunlock)
}
if !(slock < readOld && readOld < sunlock) {
- t.Fatalf("SetDynamicAuth reads the old h.dynamicAuth (statement %d) outside the hold that replaces it (Lock at %d, Unlock at %d)", readOld, slock, sunlock)
+ t.Fatalf("swapAuth reads the old h.dynamicAuth (statement %d) outside the hold that replaces it (Lock at %d, Unlock at %d)", readOld, slock, sunlock)
}
for name, fd := range fns {
ast.Inspect(fd.Body, func(n ast.Node) bool {
@@ -196,8 +215,8 @@ func TestTunnelRegistrationRecheckAndPublishShareOneLock(t *testing.T) {
return true
}
for _, l := range as.Lhs {
- if sel, ok := l.(*ast.SelectorExpr); ok && sel.Sel.Name == "dynamicAuth" && name != "(*TunnelHub).SetDynamicAuth" {
- t.Errorf("%s assigns %s at %s; only SetDynamicAuth may, under h.mu", name, selChain(sel), fset.Position(l.Pos()))
+ if sel, ok := l.(*ast.SelectorExpr); ok && sel.Sel.Name == "dynamicAuth" && name != "(*TunnelHub).swapAuth" {
+ t.Errorf("%s assigns %s at %s; only swapAuth may, under h.mu", name, selChain(sel), fset.Position(l.Pos()))
}
}
return true
diff --git a/internal/host/link_sim_test.go b/internal/host/link_sim_test.go
new file mode 100644
index 000000000..c478e4fd8
--- /dev/null
+++ b/internal/host/link_sim_test.go
@@ -0,0 +1,498 @@
+package host
+
+// Linked deployments slice 1, Task 11: the revocation invariant on the home
+// side, checked by seeded random sequences.
+//
+// Each sequence publishes, unpublishes, retargets and reuses public names
+// in the home registry between watch ticks (a tick is the home edge's
+// reload, which the link loop follows), with event streams (SSE) and
+// WebSockets held open through the hub and plain visitor requests in
+// between. A name may be retargeted to another app, or to an app of the
+// same name in another home account, so the published target is the whole
+// (name, account, app).
+//
+// Checked:
+//
+// - every request is answered by the app its name is published to at the
+// moment it is sent, or by no app: a request sent after an unpublish of
+// its name, or after a retarget away from an app, never reaches that
+// app (linkHandler's per-request read; no tick needed);
+// - after a tick, every stream opened for a (name, account, app) that is
+// no longer published ends within one watch interval (the link loop
+// replaces the connection on conn_gen; Paul's choice 3).
+//
+// The whole home is real: the home registry (0640), the home Edge and its
+// pinned pipeline (ServeLinked), runLinkLoop with the real tunnelclient.Loop,
+// the hub Edge and TunnelHub, and Unix-socket apps (newLinkWorld). The only
+// stand-in is the watch: the test reloads the home edge itself, so "between
+// watch ticks" is exact.
+//
+// Seeds: LINKSIM_SEEDS=n runs n seeds (default linkSimDefaultSeeds),
+// LINKSIM_SEED=s runs seed s alone in a fresh world (the reproduction of a
+// failure, which prints its seed and trace). LINKSIM_STEPS caps the steps
+// per seed.
+
+import (
+ "bufio"
+ "fmt"
+ "io"
+ "math/rand"
+ "net"
+ "net/http"
+ "net/url"
+ "os"
+ "strconv"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/registry"
+)
+
+const (
+ linkSimDefaultSeeds = 500
+ linkSimBatch = 50
+ linkSimMaxFailedSeeds = 3
+)
+
+func linkSimSeeds(t *testing.T, def int) (seeds []int64, one bool) {
+ t.Helper()
+ if s := os.Getenv("LINKSIM_SEED"); s != "" {
+ n, err := strconv.ParseInt(s, 10, 64)
+ if err != nil {
+ t.Fatalf("LINKSIM_SEED=%q: %v", s, err)
+ }
+ return []int64{n}, true
+ }
+ n := def
+ if s := os.Getenv("LINKSIM_SEEDS"); s != "" {
+ v, err := strconv.Atoi(s)
+ if err != nil || v < 1 {
+ t.Fatalf("LINKSIM_SEEDS=%q: want a positive count", s)
+ }
+ n = v
+ }
+ for i := 1; i <= n; i++ {
+ seeds = append(seeds, int64(i))
+ }
+ return seeds, false
+}
+
+func linkSimSteps(t *testing.T, def int) int {
+ t.Helper()
+ if s := os.Getenv("LINKSIM_STEPS"); s != "" {
+ v, err := strconv.Atoi(s)
+ if err != nil || v < 1 {
+ t.Fatalf("LINKSIM_STEPS=%q: want a positive count", s)
+ }
+ return v
+ }
+ return def
+}
+
+// homeSimTarget is one home app a name can be published to.
+type homeSimTarget struct {
+ key string // the app's linkTestApp name
+ app registry.HomeLinkApp
+ test *linkTestApp
+}
+
+// homeSimStream is one open stream: what it was opened for, which app
+// served it, and when it ended.
+type homeSimStream struct {
+ n int
+ kind string // "sse" or "ws"
+ name string
+ target string // the target key that served it
+ ended chan struct{}
+ close func()
+}
+
+func (st *homeSimStream) isEnded() bool {
+ select {
+ case <-st.ended:
+ return true
+ default:
+ return false
+ }
+}
+
+// homeSimStats counts what a run exercised, so a pass is not vacuous.
+type homeSimStats struct {
+ served, refused, refusedPublished, streams, revokedEnded, ticks, retargets int
+}
+
+type homeSim struct {
+ t *testing.T
+ stats *homeSimStats
+ w *linkWorld
+ targets []homeSimTarget
+ pub map[string]string // public name -> target key, as the home registry holds it
+ streams []*homeSimStream
+ trace []string
+ fails []string
+}
+
+func (s *homeSim) logf(format string, args ...any) {
+ s.trace = append(s.trace, fmt.Sprintf(format, args...))
+}
+
+func (s *homeSim) failf(format string, args ...any) {
+ s.fails = append(s.fails, fmt.Sprintf(format, args...))
+}
+
+var homeSimNames = []string{"one", "two", "three"}
+
+func (s *homeSim) target(key string) homeSimTarget {
+ for _, tg := range s.targets {
+ if tg.key == key {
+ return tg
+ }
+ }
+ s.t.Fatalf("no target %q", key)
+ return homeSimTarget{}
+}
+
+// counts is how many requests each target's app has seen.
+func (s *homeSim) counts() map[string]int {
+ out := make(map[string]int, len(s.targets))
+ for _, tg := range s.targets {
+ out[tg.key] = len(tg.test.requests())
+ }
+ return out
+}
+
+// reached is the one target whose app saw a request since before, "" for
+// none. More than one is a failure.
+func (s *homeSim) reached(before map[string]int, what string) string {
+ got := ""
+ for _, tg := range s.targets {
+ if n := len(tg.test.requests()); n > before[tg.key] {
+ if got != "" || n > before[tg.key]+1 {
+ s.failf("%s reached more than one request at the apps (%s and %s)", what, got, tg.key)
+ }
+ got = tg.key
+ }
+ }
+ return got
+}
+
+// admitted checks that a request for name, sent while pub held what it
+// holds now, reached the published target or none.
+func (s *homeSim) admitted(name, reached, what string, status int) {
+ want, published := s.pub[name]
+ if reached == "" {
+ s.stats.refused++
+ if published {
+ s.stats.refusedPublished++
+ }
+ } else {
+ s.stats.served++
+ }
+ switch {
+ case reached == "":
+ if published && status == http.StatusOK {
+ s.failf("%s for %s answered 200 from no app", what, name)
+ }
+ case !published:
+ s.failf("%s for %s, which is not published, reached %s (%d)", what, name, reached, status)
+ case reached != want:
+ s.failf("%s for %s, published to %s, reached %s (%d)", what, name, want, reached, status)
+ }
+}
+
+func (s *homeSim) publish(name, key string) {
+ tg := s.target(key)
+ a := tg.app
+ a.Name = name
+ if err := s.w.homeReg.PutHomeLinkApp(a); err != nil {
+ s.t.Fatal(err)
+ }
+ s.pub[name] = key
+}
+
+func (s *homeSim) unpublish(name string) {
+ if _, err := s.w.homeReg.DeleteHomeLinkApp(name); err != nil {
+ s.t.Fatal(err)
+ }
+ delete(s.pub, name)
+}
+
+// request sends one plain visitor request through the hub.
+func (s *homeSim) request(name string) {
+ before := s.counts()
+ req, err := http.NewRequest("GET", s.w.hubURL+"/hello", nil)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ req.Host = linkPublicHost(name)
+ resp, err := linkNoRedirect.Do(req)
+ status := 0
+ if err == nil {
+ io.Copy(io.Discard, resp.Body)
+ resp.Body.Close()
+ status = resp.StatusCode
+ }
+ got := s.reached(before, "request")
+ s.logf("request %s -> %d %v reached %q (published %q)", name, status, err, got, s.pub[name])
+ s.admitted(name, got, "a request", status)
+}
+
+// openSSE opens /sse for name through the hub. A refusal opens nothing.
+func (s *homeSim) openSSE(name string) {
+ before := s.counts()
+ req, err := http.NewRequest("GET", s.w.hubURL+"/sse", nil)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ req.Host = linkPublicHost(name)
+ resp, err := http.DefaultClient.Do(req)
+ if err != nil {
+ s.logf("sse %s -> %v", name, err)
+ s.admitted(name, s.reached(before, "an SSE open"), "an SSE open", 0)
+ return
+ }
+ if resp.StatusCode != http.StatusOK {
+ io.Copy(io.Discard, resp.Body)
+ resp.Body.Close()
+ got := s.reached(before, "an SSE open")
+ s.logf("sse %s -> %d reached %q (published %q)", name, resp.StatusCode, got, s.pub[name])
+ s.admitted(name, got, "an SSE open", resp.StatusCode)
+ return
+ }
+ br := bufio.NewReader(resp.Body)
+ if line, err := br.ReadString('\n'); err != nil || line != "data: hello\n" {
+ resp.Body.Close()
+ got := s.reached(before, "an SSE open")
+ s.logf("sse %s -> 200, first line %q %v, reached %q", name, line, err, got)
+ s.admitted(name, got, "an SSE open", 0)
+ return
+ }
+ got := s.reached(before, "an SSE open")
+ st := &homeSimStream{n: len(s.streams), kind: "sse", name: name, target: got, ended: make(chan struct{}), close: func() { resp.Body.Close() }}
+ go func() {
+ io.Copy(io.Discard, br)
+ close(st.ended)
+ }()
+ s.streams = append(s.streams, st)
+ s.stats.streams++
+ s.logf("sse %s -> open stream %d served by %q (published %q)", name, st.n, got, s.pub[name])
+ s.admitted(name, got, "an SSE open", http.StatusOK)
+}
+
+// openWS opens a raw WebSocket upgrade for name through the hub and checks
+// one echo. A refusal opens nothing.
+func (s *homeSim) openWS(name string) {
+ before := s.counts()
+ u, _ := url.Parse(s.w.hubURL)
+ conn, err := net.Dial("tcp", u.Host)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ host := linkPublicHost(name)
+ fmt.Fprintf(conn, "GET /ws HTTP/1.1\r\nHost: %s\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nOrigin: https://%s\r\n\r\n", host, host)
+ br := bufio.NewReader(conn)
+ conn.SetReadDeadline(time.Now().Add(5 * time.Second))
+ resp, err := http.ReadResponse(br, nil)
+ if err != nil || resp.StatusCode != http.StatusSwitchingProtocols {
+ status := 0
+ if err == nil {
+ status = resp.StatusCode
+ }
+ conn.Close()
+ got := s.reached(before, "a WebSocket open")
+ s.logf("ws %s -> %d %v reached %q (published %q)", name, status, err, got, s.pub[name])
+ s.admitted(name, got, "a WebSocket open", status)
+ return
+ }
+ buf := make([]byte, 4)
+ if _, err := conn.Write([]byte("ping")); err == nil {
+ _, err = io.ReadFull(br, buf)
+ }
+ conn.SetReadDeadline(time.Time{})
+ got := s.reached(before, "a WebSocket open")
+ if string(buf) != "ping" {
+ conn.Close()
+ s.logf("ws %s -> 101, no echo, reached %q", name, got)
+ s.admitted(name, got, "a WebSocket open", 0)
+ return
+ }
+ st := &homeSimStream{n: len(s.streams), kind: "ws", name: name, target: got, ended: make(chan struct{}), close: func() { conn.Close() }}
+ go func() {
+ io.Copy(io.Discard, br)
+ close(st.ended)
+ }()
+ s.streams = append(s.streams, st)
+ s.stats.streams++
+ s.logf("ws %s -> open stream %d served by %q (published %q)", name, st.n, got, s.pub[name])
+ s.admitted(name, got, "a WebSocket open", http.StatusSwitchingProtocols)
+}
+
+// tick is one watch tick: the home edge reloads and the link loop follows.
+// Then every open stream whose (name, account, app) is no longer published
+// must end within one watch interval.
+func (s *homeSim) tick() {
+ passes := s.w.passes.Load()
+ at := time.Now()
+ if err := s.w.home.Reload(); err != nil {
+ s.t.Fatal(err)
+ }
+ var revoked []*homeSimStream
+ for _, st := range s.streams {
+ if !st.isEnded() && s.pub[st.name] != st.target {
+ revoked = append(revoked, st)
+ }
+ }
+ for _, st := range revoked {
+ select {
+ case <-st.ended:
+ case <-time.After(time.Until(at.Add(linkWatch))):
+ s.failf("stream %d (%s %s served by %s) still open %s after the tick; %s is now published to %q",
+ st.n, st.kind, st.name, st.target, linkWatch, st.name, s.pub[st.name])
+ }
+ }
+ took := time.Since(at)
+ s.stats.ticks++
+ s.stats.revokedEnded += len(revoked)
+ s.settled(passes)
+ s.logf("tick: %d revoked stream(s) ended within %s", len(revoked), took.Round(time.Millisecond))
+}
+
+// settled waits for the link loop's pass after a reload (one more than
+// passes) and then for its run to report connected: the connection is
+// replaced on every unpublish and retarget, and the next opens should go
+// down the new one rather than be refused by the old one's teardown.
+func (s *homeSim) settled(passes int64) {
+ linkWait(s.t, "the link loop's pass after the reload", func() bool { return s.w.passes.Load() > passes })
+ linkWait(s.t, "the link connected after the reload", func() bool {
+ l, err := s.w.homeReg.HomeLink()
+ return err == nil && l != nil && l.State == registry.HomeLinkConnected && s.w.tunnels.State(linkE2EChannel) == "connected"
+ })
+}
+
+// step runs one random step.
+func (s *homeSim) step(rng *rand.Rand) {
+ name := homeSimNames[rng.Intn(len(homeSimNames))]
+ key := s.targets[rng.Intn(len(s.targets))].key
+ switch r := rng.Intn(100); {
+ case r < 18:
+ was := s.pub[name]
+ if was != "" && was != key {
+ s.stats.retargets++
+ }
+ s.publish(name, key)
+ s.logf("publish %s -> %s (was %q)", name, key, was)
+ case r < 30:
+ s.unpublish(name)
+ s.logf("unpublish %s", name)
+ case r < 36: // the same name reused between ticks
+ s.unpublish(name)
+ s.publish(name, key)
+ s.logf("reuse %s: unpublished, then published -> %s", name, key)
+ case r < 50:
+ s.openSSE(name)
+ case r < 62:
+ s.openWS(name)
+ case r < 86:
+ s.request(name)
+ default:
+ s.tick()
+ }
+}
+
+// reset ends the previous seed's streams and publishes nothing, so a seed
+// starts from an empty published set and a fresh connection.
+func (s *homeSim) reset() {
+ for _, name := range homeSimNames {
+ if _, err := s.w.homeReg.DeleteHomeLinkApp(name); err != nil {
+ s.t.Fatal(err)
+ }
+ }
+ passes := s.w.passes.Load()
+ if err := s.w.home.Reload(); err != nil {
+ s.t.Fatal(err)
+ }
+ s.settled(passes)
+}
+
+func (s *homeSim) cleanup() {
+ for _, st := range s.streams {
+ st.close()
+ select {
+ case <-st.ended:
+ case <-time.After(5 * time.Second):
+ s.t.Fatalf("cleanup: stream %d did not end", st.n)
+ }
+ }
+}
+
+// newHomeSimWorld is newLinkWorld, linked and with the loop running, with a
+// fourth home app: "shop" again, in another home account (bac), so a name
+// can be retargeted to the same app name in another account. The hub holds
+// a link forward row for every public name the sequence may publish.
+func newHomeSimWorld(t *testing.T) (*linkWorld, []homeSimTarget) {
+ t.Helper()
+ pub := map[string]string{}
+ for _, name := range homeSimNames {
+ pub[name] = "shop"
+ }
+ w := newLinkWorld(t, true, pub)
+ other := startLinkApp(t, "shopbac")
+ if err := w.homeReg.Upsert(registry.Route{Host: other.host, Slug: "shop", Kind: "instance", Socket: other.sock, Status: "ready",
+ App: "shop", Account: "bac", Channel: "production"}); err != nil {
+ t.Fatal(err)
+ }
+ w.apps["shopbac"] = other
+ if err := w.home.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ w.startLoop(t)
+ w.waitConnected(t)
+ var targets []homeSimTarget
+ for _, key := range []string{"shop", "admin", "blog"} {
+ targets = append(targets, homeSimTarget{key: key, test: w.apps[key],
+ app: registry.HomeLinkApp{HomeAccount: linkHomeAcct, HomeApp: key, HomeHost: linkHomeHost(key)}})
+ }
+ targets = append(targets, homeSimTarget{key: "shopbac", test: other,
+ app: registry.HomeLinkApp{HomeAccount: "bac", HomeApp: "shop", HomeHost: other.host}})
+ return w, targets
+}
+
+// TestLinkSimHomeSide runs the home-side simulation.
+func TestLinkSimHomeSide(t *testing.T) {
+ seeds, one := linkSimSeeds(t, linkSimDefaultSeeds)
+ maxSteps := linkSimSteps(t, 40)
+ var w *linkWorld
+ var targets []homeSimTarget
+ start := time.Now()
+ failed := 0
+ var stats homeSimStats
+ for i, seed := range seeds {
+ if one || i%linkSimBatch == 0 {
+ w, targets = newHomeSimWorld(t)
+ }
+ rng := rand.New(rand.NewSource(seed))
+ s := &homeSim{t: t, stats: &stats, w: w, targets: targets, pub: map[string]string{}}
+ s.reset()
+ s.logf("seed %d", seed)
+ n := 1 + rng.Intn(maxSteps)
+ for j := 0; j < n && len(s.fails) == 0; j++ {
+ s.step(rng)
+ }
+ if len(s.fails) == 0 {
+ s.tick()
+ }
+ if len(s.fails) != 0 {
+ failed++
+ t.Errorf("seed %d (reproduce with LINKSIM_SEED=%d):\n%s\n\ntrace:\n %s",
+ seed, seed, strings.Join(s.fails, "\n"), strings.Join(s.trace, "\n "))
+ if failed == linkSimMaxFailedSeeds {
+ t.FailNow()
+ }
+ }
+ s.cleanup()
+ }
+ t.Logf("%d seeds, up to %d steps each, in %s: %d requests and opens served, %d refused (%d of them published), %d streams opened, %d revoked streams ended at %d ticks, %d retargets",
+ len(seeds), maxSteps, time.Since(start).Round(time.Millisecond),
+ stats.served, stats.refused, stats.refusedPublished, stats.streams, stats.revokedEnded, stats.ticks, stats.retargets)
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index ced109099..1390872d8 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 91a9fbb640ba280de65c041879cc84d5ef6a0137a576d789733dc03eb6946cae
+plan14-root-reads-linked-deployments-slice1.tsv a86f0ab3b84a5d16a45d0a4a9dba46865bc7740363f3353c8e069ead958fd362
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 b06df1f10..d3b673694 100644
--- a/internal/provision/testdata/plan14-root-reads-linked-deployments-slice1.tsv
+++ b/internal/provision/testdata/plan14-root-reads-linked-deployments-slice1.tsv
@@ -52,7 +52,7 @@
@legacy 1cc218bca0ee6eb3adcb76a8f2931775aa0d3245f0366398bdbc3a20c38c6509 internal/edge/fleetforward.go DispatchArm 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): review R2: Reload's dispatch order as one function over a row it serves (forward only when admitted to the fleet arm, own Tunnel where tunnels are on, fleet arm, socket, AddrList, static, status, else none), moved out of Reload's switch unchanged; read by Reload and FleetArmVerdict. Pure; no I/O.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: read FleetBoxes and ValidReplicaProjection on the supplied row before the legacy forward/tunnel/fleet arms. An admitted valid set selects ArmReplica; a set without fleet authority selects no arm. Local non-hub resident socket dispatch remains unchanged. No external read.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: a link-placed forward row (registry.LinkPlacement over Region) dispatches to ArmLink when the verdict's Arm holds it and to ArmNone otherwise, ahead of every other case; +registry:Region is that parse registry:FleetBoxes@219,registry:Kind@603,registry:Kind@649,registry:Region@106,registry:Socket@513,registry:Tunnel@426 319127d0441ea71dc3acb0a24426a85b02eb31ee1b780b5037f51b6b2bf97c59
@legacy 854eb333b3939208c7162ded875278297ef1793fa538c36a71282470818614f7 internal/provision/forward.go forwardPhase.mint 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 10: mints a forward row through PutForward for an owner's fleet-placed record; a host another row holds is left alone and logged naming the holding row (+registry:Account, +registry:App, +registry:Kind, +whole:Route x4). Agent only.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 2: before any write, an existing forward row whose Region registry.LinkPlacement parses is reported held (the existing held log line, naming the link, its app and account) and nothing is written; reads only the listed row (Region, App, Account); the pass writes less, never more registry:Account@335,registry:Account@488,registry:App@321,registry:App@474,registry:Kind@306,registry:Region@182,whole:Route@121,whole:Route@543,whole:Route@553,whole:Route@762 ff5165ed5028b296f57b4877b8c36d6c30ec764db8a7085711c3e884b6d11f79
@legacy d2790bf237d4ce6e6594e2af851f312c3e58b5bfa62d329b7d07a03551172f20 internal/provision/forward.go forwardView.retirements 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 10: the forward rows to retire over the snapshot re-walk (+registry:Host x5, +whole:Route): only forward rows; disputed hosts kept. Agent only.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 2: a forward row whose Region registry.LinkPlacement parses is never listed for retirement, on the hub or off it; reads only the listed row's Region; the pass deletes less, never more (DeleteForward already refuses link rows) registry:Host@299,registry:Host@368,registry:Host@416,registry:Host@443,registry:Host@606,registry:Region@245,whole:Route@160 04c5190f27d514ec8a95eb0149324ed64ef79411c5f792fb6456c60eae2eb72e
-@legacy bc707cb3f525a7524b1046dc8b2753cb507501cb2b0ba5fd66858a79a8bd53ed internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map (none for a minted apex) and never inheriting the source's (Astra r2 P1); a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test (generation proxy, hib, no-activator 404) is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance goes through the activator; binary rows unchanged;rev3=census-ruling-edge-roll-blip;basis=the tcpProxy and multiProxy calls pass e.hold (the per-Edge localHold set once in newEdge): a loopback TCP upstream that refuses is redialled for up to 13 s and a probed route with a local upstream waits for prober readmission instead of answering 502/503 (#434 part B); edge-side dial policy only, no read added, same 52 sites;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: after the alias fold, reads the regional_domains rows (e.reg.ListRegional; an error aborts the reload as every registry read here does) and applies them with foldRegional against the routes slice the same reload read; the added reads are that one registry list and the routes already read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 4 and 6: the forward case (fleetProxy toward the binding's FleetBox, throttled refusal); one refusal check before the switch from FleetArmVerdict (sidecar not judged; a non-ready forward row refused; a forward row always judged by FleetServeEligible, any other row only where tunnels are on; an alias of a refused source refused with it); the accountless note; path rows of a forward host not folded; no alias folded onto a refused row; refusedHosts held through every fold. ListFleets and FleetChannelAuth read before the loop (+registry:FleetBox, +registry:Host x7, +whole:Route x3). Serving only; the hub's agent, not root. Review R1 finding 2: the switch reads verdict.Served (FleetArmVerdict) by host; the forward case and the fleet-placed case take their fleet from it (served.Fleet) instead of FleetPlacement(t.Region), and an admitted forward row not Served continues rather than falling through (+registry:Host, -registry:Region); the same rows take the same arms; no read added. Review R2: the switch is on DispatchArm(t, viaFleet, tunnels) (the order moved there unchanged: forward only when in Arm, own Tunnel, fleet, socket, addrs, static, status, else continue), the fleet cases read verdict.Arm (renamed from Served), and the platform-alias fold is foldPlatformAliases with the same take (source entry, own paths, alias marks) and the same refusal log (-registry:Kind x2, -registry:Socket, -registry:Tunnel, +whole:Route: those reads moved into DispatchArm); same rows, same arms, same entries; no read added.;rev3=census-ruling-fleet-routes-followups;basis=the owners map is now e.reg.FleetOwners() instead of ListFleets folded inline: the same fresh-connection ListFleets read and the same name->account map (-registry:Account, -registry:Name, -whole:Fleet x2 move into Registry.FleetOwners); no read added; same error path (abort the reload);rev3=census-ruling-tunnel-websockets;basis=The ArmTunnel arm now records its tenancy (Account, App, Tunnel) copied from the row t that Reload already lists; no new registry query, no file read. Also the reload mutex taken first and held to return, five nil-in-production test hooks, and the sweepUpgrades call after the swap, which reads only the map Reload has just built (spec 7, Tasks 3 and 4).;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the two fleet proxy builds pass the row to fleetBoxOf(t) instead of reading t.FleetBox (-registry:FleetBox x2, +whole:Route x2); fleetBoxOf answers FleetLabel as authoritative when set, else FleetBox; an authoritative box has no fallback to another of the fleet's channels (503 errFleetDark instead). The edge in the agent, not root; it routes to fewer channels, never more.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): after the new upstream map is published, closes the held streams of any host the new map no longer holds (absent, not hibernating, route no longer Hibernate). Reads the freshly built in-memory map m and the in-memory held set; no read added beyond the rebuild Reload already does.;rev3=census-ruling-devbox-identity;basis=#486 A: only the devbox edge created by newDevboxEdge (carlos-devbox service user, not root) enables the new proxy hooks. Saves the existing DispatchArm result and reads t.Socket from an already-listed route when that arm is ArmSocket, passing it to configureDevboxProxy for per-request expected-owner validation and visitor-header rewriting. Adds one registry:Socket field site; no new registry query or file open, and ordinary fleet/agent edges leave the hook disabled. Final fix wave: its devbox-only outgoing-header/trailer hooks now also strip case-insensitive underscore/hyphen aliases through stripVisitorHeaders; no new read.;rev3=census-ruling-agent-start-demo-1;basis=Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query. Merge resolution against origin/main 9bd45488 retains main's devbox proxy hooks (reading the existing route Socket) alongside demo filtering; no additional registry query.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: dispatch admitted stateless set rows through replicaProxy before legacy fleetBoxOf. Read Host and supplied whole Route values from the existing listing to build and filter the set probe inputs after all registry reads and alias folds; synchronize before map publication. Tenancy comes only from FleetArmVerdict. No new external read; no set row reaches legacy fallback, local addresses, provision.Health or hibernation on the hub. Fix round 1 M2: comment and whitespace correction only; read sites and routing behavior unchanged.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1175-1177 passes an already-listed demo Route to demoProxy; :1358 passes existing Route and RouteAlias slices to demoRefusalNames; :1401 publishes refusal names before upstreams. Adds whole-value uses only, no new registry query; retained names refuse fallback after filtering.;rev3=census-ruling-demo-api-site-route;basis=Build a dedicated demo API proxy from the selected existing socket, TCP or probed console transport in the same atomic route snapshot, before ordinary wrappers. Reads existing route Host twice, Version and two whole Route values for exact operator-configured console eligibility. No additional registry query or external read.;rev3=census-ruling-agent-start-demo-3;basis=Refresh the verified moved snapshot from registry on reload before route-independent serving. Census read-site delta: unchanged (87).;rev3=census-ruling-region-ha-g2-fixes;basis=Derive blocked ingress names from already listed unready/held/import-gated/sidecar and fleet-refused rows; added field reads only.;rev3=census-ruling-edge-page-cache-1;basis=keeps every row this reload already read from the registry (e.pageRoutes, e.pageRoutesRead = routes, true, under reloadMu) for the page reload hook; the +whole:Route sites are that assignment of the same slice; no new read;rev3=census-ruling-held-move-speed;basis=the six tenant reverse proxies' ModifyResponse is now classifyMoveStreams(e.responseModifier(t)): MarkMoveStream first reads the response head (status 101, or Content-Type text/event-stream) and sets a flag on the request's in-memory StreamEnd, then responseModifier runs unchanged (byte-identical to main). The hook never wraps or touches the body, so the trailer scrubs keep the proxy as their one closer (Astra r2 F2.1: the graceful boundary end and its watcher were cut). No read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: with tunnels on, the pass also reads LinkChannelAuth and LinkOwners from the box's own registry (fresh connection, as FleetChannelAuth and FleetOwners) and merges each well-formed link channel's hash into the set SetDynamicAuth takes; the verdict judges link-placed forward rows by the link owners; an admitted one takes the new ArmLink case (linkProxy down the link's channel, tenancy with the link); the door's fleet snapshot stays fleet owners only and link owners go to a separate snapshot; +whole:Route is the row handed to the new case's responseModifier; the edge process as carlos, no root decision; linked deployments slice 1 Task 8: each upstream entry also records localBackend (ArmSocket, or an instance the activator runs here), from values the pass already holds; no read added registry:Account@11643,registry:Alias@27003,registry:Alias@27090,registry:Alias@27670,registry:App@11659,registry:Health@15426,registry:Health@15552,registry:Hibernate@31954,registry:HoldOp@30750,registry:Host@12970,registry:Host@13027,registry:Host@13063,registry:Host@13827,registry:Host@16035,registry:Host@16130,registry:Host@16418,registry:Host@16444,registry:Host@16496,registry:Host@19326,registry:Host@19359,registry:Host@21382,registry:Host@23289,registry:Host@23597,registry:Host@23624,registry:Host@24522,registry:Host@25094,registry:Host@27424,registry:Host@27473,registry:Host@30186,registry:Host@30211,registry:Host@30228,registry:Host@30827,registry:Host@5253,registry:Host@5622,registry:Host@5676,registry:Host@5726,registry:Host@6746,registry:Host@6935,registry:ImportGate@30769,registry:Kind@19718,registry:Kind@19740,registry:Prefix@25069,registry:Socket@13891,registry:Socket@19597,registry:Socket@23605,registry:Status@30726,registry:Status@5547,registry:Target@25081,registry:Tunnel@11482,registry:Tunnel@11674,registry:Version@19449,registry:Version@19699,registry:Version@19801,whole:RegionalDomain@28312,whole:Route@11564,whole:Route@13118,whole:Route@13246,whole:Route@13967,whole:Route@16589,whole:Route@16654,whole:Route@16705,whole:Route@19376,whole:Route@19383,whole:Route@19507,whole:Route@23685,whole:Route@23692,whole:Route@23788,whole:Route@24957,whole:Route@26125,whole:Route@28304,whole:Route@28360,whole:Route@28400,whole:Route@30092,whole:Route@30126,whole:Route@30214,whole:Route@30293,whole:Route@30712,whole:Route@313,whole:Route@31956,whole:Route@32013,whole:Route@32044,whole:Route@4273,whole:Route@4331,whole:Route@5261,whole:Route@6775,whole:Route@7058,whole:Route@7192,whole:Route@7215,whole:Route@7230,whole:Route@8076,whole:Route@8204,whole:Route@9021,whole:RouteAlias@26974,whole:RouteAlias@28368,whole:RoutePath@24500 1c699b6275029e783c62648fe6d42b29103acb66d806e9e70b4aae41a73020a6
+@legacy d6828712d10fc2f7974d361b8c38f3fd3da311fd4b153745d0a5a6ab24820b49 internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map (none for a minted apex) and never inheriting the source's (Astra r2 P1); a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test (generation proxy, hib, no-activator 404) is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance goes through the activator; binary rows unchanged;rev3=census-ruling-edge-roll-blip;basis=the tcpProxy and multiProxy calls pass e.hold (the per-Edge localHold set once in newEdge): a loopback TCP upstream that refuses is redialled for up to 13 s and a probed route with a local upstream waits for prober readmission instead of answering 502/503 (#434 part B); edge-side dial policy only, no read added, same 52 sites;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: after the alias fold, reads the regional_domains rows (e.reg.ListRegional; an error aborts the reload as every registry read here does) and applies them with foldRegional against the routes slice the same reload read; the added reads are that one registry list and the routes already read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 4 and 6: the forward case (fleetProxy toward the binding's FleetBox, throttled refusal); one refusal check before the switch from FleetArmVerdict (sidecar not judged; a non-ready forward row refused; a forward row always judged by FleetServeEligible, any other row only where tunnels are on; an alias of a refused source refused with it); the accountless note; path rows of a forward host not folded; no alias folded onto a refused row; refusedHosts held through every fold. ListFleets and FleetChannelAuth read before the loop (+registry:FleetBox, +registry:Host x7, +whole:Route x3). Serving only; the hub's agent, not root. Review R1 finding 2: the switch reads verdict.Served (FleetArmVerdict) by host; the forward case and the fleet-placed case take their fleet from it (served.Fleet) instead of FleetPlacement(t.Region), and an admitted forward row not Served continues rather than falling through (+registry:Host, -registry:Region); the same rows take the same arms; no read added. Review R2: the switch is on DispatchArm(t, viaFleet, tunnels) (the order moved there unchanged: forward only when in Arm, own Tunnel, fleet, socket, addrs, static, status, else continue), the fleet cases read verdict.Arm (renamed from Served), and the platform-alias fold is foldPlatformAliases with the same take (source entry, own paths, alias marks) and the same refusal log (-registry:Kind x2, -registry:Socket, -registry:Tunnel, +whole:Route: those reads moved into DispatchArm); same rows, same arms, same entries; no read added.;rev3=census-ruling-fleet-routes-followups;basis=the owners map is now e.reg.FleetOwners() instead of ListFleets folded inline: the same fresh-connection ListFleets read and the same name->account map (-registry:Account, -registry:Name, -whole:Fleet x2 move into Registry.FleetOwners); no read added; same error path (abort the reload);rev3=census-ruling-tunnel-websockets;basis=The ArmTunnel arm now records its tenancy (Account, App, Tunnel) copied from the row t that Reload already lists; no new registry query, no file read. Also the reload mutex taken first and held to return, five nil-in-production test hooks, and the sweepUpgrades call after the swap, which reads only the map Reload has just built (spec 7, Tasks 3 and 4).;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the two fleet proxy builds pass the row to fleetBoxOf(t) instead of reading t.FleetBox (-registry:FleetBox x2, +whole:Route x2); fleetBoxOf answers FleetLabel as authoritative when set, else FleetBox; an authoritative box has no fallback to another of the fleet's channels (503 errFleetDark instead). The edge in the agent, not root; it routes to fewer channels, never more.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): after the new upstream map is published, closes the held streams of any host the new map no longer holds (absent, not hibernating, route no longer Hibernate). Reads the freshly built in-memory map m and the in-memory held set; no read added beyond the rebuild Reload already does.;rev3=census-ruling-devbox-identity;basis=#486 A: only the devbox edge created by newDevboxEdge (carlos-devbox service user, not root) enables the new proxy hooks. Saves the existing DispatchArm result and reads t.Socket from an already-listed route when that arm is ArmSocket, passing it to configureDevboxProxy for per-request expected-owner validation and visitor-header rewriting. Adds one registry:Socket field site; no new registry query or file open, and ordinary fleet/agent edges leave the hook disabled. Final fix wave: its devbox-only outgoing-header/trailer hooks now also strip case-insensitive underscore/hyphen aliases through stripVisitorHeaders; no new read.;rev3=census-ruling-agent-start-demo-1;basis=Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query. Merge resolution against origin/main 9bd45488 retains main's devbox proxy hooks (reading the existing route Socket) alongside demo filtering; no additional registry query.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: dispatch admitted stateless set rows through replicaProxy before legacy fleetBoxOf. Read Host and supplied whole Route values from the existing listing to build and filter the set probe inputs after all registry reads and alias folds; synchronize before map publication. Tenancy comes only from FleetArmVerdict. No new external read; no set row reaches legacy fallback, local addresses, provision.Health or hibernation on the hub. Fix round 1 M2: comment and whitespace correction only; read sites and routing behavior unchanged.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1175-1177 passes an already-listed demo Route to demoProxy; :1358 passes existing Route and RouteAlias slices to demoRefusalNames; :1401 publishes refusal names before upstreams. Adds whole-value uses only, no new registry query; retained names refuse fallback after filtering.;rev3=census-ruling-demo-api-site-route;basis=Build a dedicated demo API proxy from the selected existing socket, TCP or probed console transport in the same atomic route snapshot, before ordinary wrappers. Reads existing route Host twice, Version and two whole Route values for exact operator-configured console eligibility. No additional registry query or external read.;rev3=census-ruling-agent-start-demo-3;basis=Refresh the verified moved snapshot from registry on reload before route-independent serving. Census read-site delta: unchanged (87).;rev3=census-ruling-region-ha-g2-fixes;basis=Derive blocked ingress names from already listed unready/held/import-gated/sidecar and fleet-refused rows; added field reads only.;rev3=census-ruling-edge-page-cache-1;basis=keeps every row this reload already read from the registry (e.pageRoutes, e.pageRoutesRead = routes, true, under reloadMu) for the page reload hook; the +whole:Route sites are that assignment of the same slice; no new read;rev3=census-ruling-held-move-speed;basis=the six tenant reverse proxies' ModifyResponse is now classifyMoveStreams(e.responseModifier(t)): MarkMoveStream first reads the response head (status 101, or Content-Type text/event-stream) and sets a flag on the request's in-memory StreamEnd, then responseModifier runs unchanged (byte-identical to main). The hook never wraps or touches the body, so the trailer scrubs keep the proxy as their one closer (Astra r2 F2.1: the graceful boundary end and its watcher were cut). No read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: with tunnels on, the pass also reads LinkChannelAuth and LinkOwners from the box's own registry (fresh connection, as FleetChannelAuth and FleetOwners) and merges each well-formed link channel's hash into the set SetDynamicAuth takes; the verdict judges link-placed forward rows by the link owners; an admitted one takes the new ArmLink case (linkProxy down the link's channel, tenancy with the link); the door's fleet snapshot stays fleet owners only and link owners go to a separate snapshot; +whole:Route is the row handed to the new case's responseModifier; the edge process as carlos, no root decision; linked deployments slice 1 Task 8: each upstream entry also records localBackend (ArmSocket, or an instance the activator runs here), from values the pass already holds; no read added; linked deployments slice 1 Task 11: the LinkChannelAuth read (the same fresh-connection read) moves to the top of the pass, before List, and its map is applied at once through the hub's new SetLinkAuth (the link half of the credential set only; fleet entries untouched), so a link revocation or rotation closes the home connection on the old hash even when a later read or step of the same reload fails; the same map is still merged into the set SetDynamicAuth takes; no read added, one moved; the edge process as carlos, no root decision registry:Account@12371,registry:Alias@27731,registry:Alias@27818,registry:Alias@28398,registry:App@12387,registry:Health@16154,registry:Health@16280,registry:Hibernate@32682,registry:HoldOp@31478,registry:Host@13698,registry:Host@13755,registry:Host@13791,registry:Host@14555,registry:Host@16763,registry:Host@16858,registry:Host@17146,registry:Host@17172,registry:Host@17224,registry:Host@20054,registry:Host@20087,registry:Host@22110,registry:Host@24017,registry:Host@24325,registry:Host@24352,registry:Host@25250,registry:Host@25822,registry:Host@28152,registry:Host@28201,registry:Host@30914,registry:Host@30939,registry:Host@30956,registry:Host@31555,registry:Host@5981,registry:Host@6350,registry:Host@6404,registry:Host@6454,registry:Host@7474,registry:Host@7663,registry:ImportGate@31497,registry:Kind@20446,registry:Kind@20468,registry:Prefix@25797,registry:Socket@14619,registry:Socket@20325,registry:Socket@24333,registry:Status@31454,registry:Status@6275,registry:Target@25809,registry:Tunnel@12210,registry:Tunnel@12402,registry:Version@20177,registry:Version@20427,registry:Version@20529,whole:RegionalDomain@29040,whole:Route@1045,whole:Route@12292,whole:Route@13846,whole:Route@13974,whole:Route@14695,whole:Route@17317,whole:Route@17382,whole:Route@17433,whole:Route@20104,whole:Route@20111,whole:Route@20235,whole:Route@24413,whole:Route@24420,whole:Route@24516,whole:Route@25685,whole:Route@26853,whole:Route@29032,whole:Route@29088,whole:Route@29128,whole:Route@30820,whole:Route@30854,whole:Route@30942,whole:Route@31021,whole:Route@31440,whole:Route@32684,whole:Route@32741,whole:Route@32772,whole:Route@5001,whole:Route@5059,whole:Route@5989,whole:Route@7503,whole:Route@7786,whole:Route@7920,whole:Route@7943,whole:Route@7958,whole:Route@8804,whole:Route@8932,whole:Route@9749,whole:RouteAlias@27702,whole:RouteAlias@29096,whole:RoutePath@25228 57267b6a9cfcaeed4995b1857bd851ae19e2f3d5f67e83209e0a85daeb3bb0a7
@legacy 42304ac2f37522340c2bda552d9967300504dab2102ccdec079d9b0bc740f3af internal/edge/fleetforward.go FleetArmVerdict 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 6 fix round 3: the single fleet-arm refusal decision over one listing, used by Edge.Reload, the edges-file writer and the alias pass (parity by construction); returns the refused set with reasons and the accountless notes (+registry:Host x3, +registry:Status, +whole:Route x3). Pure; no I/O. Review R1 finding 2: also returns Served, each admitted row Reload sends through the fleet arm (a forward row, or a fleet-placed row with no Tunnel) with its fleet, app and the fleet owner from owners; a host the alias step refuses is dropped from it (+registry:App, +registry:Host, +registry:Region, +registry:Tunnel on the listing it already holds). Pure; no I/O. Review R2: the pre-fold fleet rows are now Arm; Served is the destination after the platform-alias fold: every ready, unrefused, non-sidecar row DispatchArm gives an entry, with its Arm fleet when its arm is a fleet's, folded by foldPlatformAliases (Reload's own fold), keeping the hosts that go to a fleet (+registry:Host, +registry:Status, +whole:Route on the listing it already holds). Pure; no I/O; refusals unchanged.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: classify ArmReplica as fleet-served for the existing shared routing, edges-file and alias verdict. Existing field reads unchanged; pure in-memory decision, same owner and alias checks.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: owners is edge.ForwardOwners; a link-placed forward row (registry.LinkPlacement over the listed row's Region) admitted by FleetServeEligible gets an Arm entry with its link, app and the link's owner, and ArmLink rows count as served; +registry:App, +registry:Host, +registry:Region are that row's fields; a pure decision over the listing, no read source added registry:App@769,registry:App@970,registry:Host@1615,registry:Host@1675,registry:Host@1807,registry:Host@1867,registry:Host@376,registry:Host@559,registry:Host@618,registry:Host@729,registry:Host@928,registry:Region@681,registry:Region@859,registry:Status@1547,registry:Status@316,registry:Tunnel@900,whole:Route@1049,whole:Route@1515,whole:Route@1705,whole:Route@1923,whole:Route@264,whole:Route@518 b98bcc250129fbe47a5fc5be92bac28d809683358010420c3c52388bb42f36a2
@legacy 88e9d5cee56487049c335bd495dc6b39da00bb40f3b834440711ffa2e669f5e4 internal/edge/fleetforward.go FleetServeEligible 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 4 (§4.4 tenancy): a forward row is eligible only on a hub, inert, fleet-placed, its fleet in the fleets table and its raw Account non-empty and equal to the owner; a non-forward fleet-placed row: empty raw Account served and noted, else release.RouteAccount must equal the owner; raw field before RouteAccount (+registry:Account x7, +registry:Region x2, +registry:Tunnel, +whole:Route). Pure; no I/O.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: gate set routing on hub role, valid projection, nonempty account/app, instance or inert forward kind, no platform ownership, HA, hibernation or explicit tunnel. New reads are fields of the already-supplied Route. Existing fleet-owner and inert-forward checks still apply; no external read or expansion of destination authority. Fix round 1 M1: retain the same fail-closed structural predicate but give each invalid condition an internal diagnostic instead of the no-healthy-copy message. No admission expansion, user-facing answer, or additional read.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: owners is edge.ForwardOwners; a forward row whose Region parses as a link placement is judged by linkServeEligible against owners.Links only, and every other row as before against owners.Fleets; +registry:Region and +whole:Route are that parse and the hand-off; refuses more, never admits a fleet row by link owners registry:Account@1413,registry:Account@1484,registry:Account@1570,registry:Account@1672,registry:Account@1828,registry:Account@1926,registry:Account@2189,registry:Account@512,registry:App@532,registry:FleetBoxes@297,registry:HA@683,registry:Hibernate@692,registry:Kind@860,registry:Platform@610,registry:Region@1244,registry:Region@142,registry:Region@282,registry:Tunnel@1629,registry:Tunnel@774,whole:Route@208,whole:Route@2111 94d88d4b36a3dbc2d0cac93be76da320d5926d71b66a2ad8f89bc84ec639468e
@legacy 7c635b65e7b6d5dc6aba50ec2f9d77d8c084cc2bb154483af5279b9311af8ee8 internal/edge/purge_header.go Edge.resolvePurgeOwnersIn legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-page-cache-1;basis=resolvePurgeHosts' former body, verbatim but for three things: it takes the snapshot (cur) from its caller, answers purgeHost{host, owner} pairs, and a host admitted by the path-routing exception (another app) is owned by the serving route rt (the +registry:App sites), so its page clear is of rt's own pages; the same caps, validation and ownership checks;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: a declared Carlos-Purge-Host equal to the linked request's public host is the serving route's own host (rt.Host, owner rt), as naming rt.Host already is; the new sites read rt.Host and build purgeHost{rt.Host, rt}; nothing outside rt's own entries becomes purgeable registry:Account@5255,registry:Account@5303,registry:App@4466,registry:App@4484,registry:App@5247,registry:App@5289,registry:App@5394,registry:App@5407,registry:Host@1110,registry:Host@1238,registry:Host@1444,registry:Host@1557,registry:Host@183,registry:Host@1836,registry:Host@2033,registry:Host@2456,registry:Host@2989,registry:Host@3038,registry:Host@4449,registry:Host@4599,registry:Host@4797,registry:Host@494,registry:Host@4959,registry:Host@5238,registry:Host@6019,registry:Host@617,registry:Host@6180,whole:Route@192,whole:Route@2716,whole:Route@3047,whole:Route@4471,whole:Route@4524,whole:Route@4555,whole:Route@4910,whole:Route@5292,whole:Route@5306,whole:Route@5383,whole:Route@5547,whole:Route@5555,whole:Route@5602 3cc7b6ca49d2474edb365c73781a5384a2d171f44ecb969acdf7763536e47477
@@ -114,7 +114,7 @@ internal/edge/fleetforward.go DispatchArm legacy accepted-legacy accepted-legacy
internal/provision/forward.go forwardPhase.mint 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 10: mints a forward row through PutForward for an owner's fleet-placed record; a host another row holds is left alone and logged naming the holding row (+registry:Account, +registry:App, +registry:Kind, +whole:Route x4). Agent only.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 2: before any write, an existing forward row whose Region registry.LinkPlacement parses is reported held (the existing held log line, naming the link, its app and account) and nothing is written; reads only the listed row (Region, App, Account); the pass writes less, never more registry:Account@335,registry:Account@488,registry:App@321,registry:App@474,registry:Kind@306,registry:Region@182,whole:Route@121,whole:Route@543,whole:Route@553,whole:Route@762 ff5165ed5028b296f57b4877b8c36d6c30ec764db8a7085711c3e884b6d11f79
internal/provision/forward.go forwardView.retirements 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 10: the forward rows to retire over the snapshot re-walk (+registry:Host x5, +whole:Route): only forward rows; disputed hosts kept. Agent only.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 2: a forward row whose Region registry.LinkPlacement parses is never listed for retirement, on the hub or off it; reads only the listed row's Region; the pass deletes less, never more (DeleteForward already refuses link rows) registry:Host@299,registry:Host@368,registry:Host@416,registry:Host@443,registry:Host@606,registry:Region@245,whole:Route@160 04c5190f27d514ec8a95eb0149324ed64ef79411c5f792fb6456c60eae2eb72e
internal/registry/remote_dispatch.go Registry.dispatchRemote hint E2 rev3=census-ruling-self-serve-moves-1;basis=the registry child (carlos __registry-child, the service user a root pass forks): plan14-root-reads-e's mixed declaration (E2 adds only the ArtifactHosts read; every other arm is the local method of the same name), with three more write arms, SetHoldIfSeq, ReleaseHoldSeq and InstallLifetimeIf, each calling the local setter; no read operation added; self-serve moves 1 Task 7;rev3=census-ruling-instance-egress-sizes-328-329;identity=the registry child (carlos __registry-child, the service user a root pass forks);basis=#328/#329 plan 1 Task 4: one more write arm, SetPolicy, calling the local Registry.SetPolicy with the request's Host, EgressAllow, Size and PolicyExpiresAt (remoteRequest fields sent by the remote handle's holder); the new kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, plus one more registry:Host site, all of the request; no read operation added; the read-only worker never reaches it (serveRemote's method gate); no production root pass sends SetPolicy;rev3=census-ruling-region-ha-p1a;basis=the registry child (carlos __registry-child, the service user a root pass forks): one more write arm, SetHA, calling the local Registry.SetHA with the request's Host (+registry:Host); no read operation added; only the provision pass sends it;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 8: two new remote methods, UpsertUnlessRootfs (carlos add's guarded write) and ResidentInstances (the residency sweep's list), each calling the same-named Registry method;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: two more methods on the existing remote registry transport, ListRegional and ReplaceRegionalSet (request field RDs, response field Regional), each calling the local method of the same name, which validates its own input; no new kind of read;rev3=census-ruling-fleet-secrets-key;basis=one new case, SetFleetSecretsKey, reading the request's Name, Pub, KeyFP, By and At fields and calling SetFleetSecretsKey;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 1-2: three new cases (SetFleetBoxIf reads the request's Fleet and answers Changed; PutForward reads TValue, a whole Route; DeleteForward reads Host and answers Changed); SetFleetBox gone (+registry:Changed x2, +registry:Fleet, +registry:Host, +registry:TValue, +whole:Route). Each case calls the local writer with its own guards.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Tasks 2 and 6b): three more remote methods dispatched to their local forms, SetFleetBoxDraining (q.Fleet, q.Label, q.At, answering Number64), MarkFleetBoxLabelled (q.Fleet, q.Label, q.At) and SetFleetAssignment (q.Host, q.Assigned, q.Moved); remoteRequest gains Assigned and Moved. The registry child, not root.;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Add SetServingMode dispatch using the existing remote request Host, Ver and On fields; the same local narrow writer handles it. No new transport or root path. Task 4 R24: dispatch SeedStateless with the existing Observed Route and On carriers to its symmetric guarded local method. No new transport; the existing read-only service gate still refuses writes.;rev3=census-ruling-region-ha-p1b3b-t;basis=Dispatch typed duty, import, exact replacement and guarded receipt operations through the existing service-user registry transport, preserving comparisons and errors. B2 fix r1: dispatch AdvanceHADuty through the existing service-user registry channel and error mapping, reading the request Host only. Read-only method allowlist remains unchanged. B3b: transport bounded typed local journal requests and results over the existing authenticated registry channel; no arbitrary SQL or disk path.;rev3=census-ruling-managed-fleets-2a;basis=Expose the two owned managed preparation methods with Fleet envelope fields, preserving conditional result. Witness TestManagedRegistryPreparationMethods local/remote parity. Dispatch ClearFleetBoxDraining with fleet, label and timestamp to validated local method; no new transport or root path. Witness TestManagedConditionalDrainClear. Dispatch managed insert with FleetBox and At, and return Changed for conditional drain clear. Existing transport and local validation; no new root path. Witness TestAddManagedFleetBox local/remote parity.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: adds ClearReplicaAssignment over the existing typed registry RPC; local writer checks the complete observed row. Existing read-only RPC gate unchanged. merge of origin/main 9b8b2c50: retain all HA journal/duty/wake/adoption RPCs alongside replica assignment RPCs; union of request/response fields and error sentinels, unchanged transport and read-only gate. Merge 0b3098cb also retains main's two managed fleet RPCs; the replica RPCs and shared refusal gate remain intact.;rev3=census-ruling-managed-fleets-2b1;basis=managed fleets 2b-1 Task 1: the registry child (carlos __registry-child, the service user a root pass forks) answers GetFleet and ListFleetBoxes with GetFleetContext(ctx, q.Name) and ListFleetBoxesContext(ctx, q.Fleet), passing its existing request context so a cancelled caller ends the child's SQL read; same request fields (Name, Fleet) and same local queries; no method, field or read operation added; read-only method gate unchanged;rev3=census-ruling-edge-page-cache-1;basis=adds the SetPages method: r.SetPages(q.Host, q.PagesOff), the request's PagesOff field (the +registry:Host and +registry:PagesOff sites); the same dispatch as SetAssets. Merged onto main's body at 04dc1dc0 (managed fleets 2b-1: GetFleet and ListFleetBoxes now go through their Context forms with the dispatch ctx), which this branch does not change;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 1: nine more cases (PutLinkChannel, RevokeLinkChannel, LinkChannelAuth, LinkOwners, SetLinkSeen, ResetLinkSeen, LinkSeen, LinkForwards, DeleteLinkForward), each calling the local method with request fields; no other case changed; linked deployments slice 1 Task 7: ten cases for the home link methods (HomeLink, PutHomeLink, DeleteHomeLink, ClaimHomeLink, SetHomeLinkState, HomeLinkConnGen, HomeLinkApps, HomeLinkAppByName, PutHomeLinkApp, DeleteHomeLinkApp), each passing the request's HomeLink, HomeLinkApp, Label, Status or Name to the registry method of that name; the same transport, no read added; linked deployments slice 1 Task 7 fix round 1: one more case, SetHomeLinkUnlinkPending, passing the request's LinkID and On to the registry method of that name; no read added registry:A@10839,registry:Account@2988,registry:Account@3087,registry:Account@7055,registry:Accounts@5717,registry:Addr@7632,registry:Addrs@7640,registry:Adoption@1013,registry:Adoption@818,registry:Alias@10887,registry:Alias@10951,registry:Alias@11039,registry:Aliases@10761,registry:Alive@12714,registry:Args@10463,registry:AssetGen@7839,registry:AssetsOff@7826,registry:Assigned@8317,registry:Assignment@9733,registry:Assignment@9831,registry:At@10970,registry:At@11048,registry:At@12462,registry:At@3322,registry:At@3390,registry:At@3782,registry:At@3879,registry:At@3964,registry:At@9211,registry:Attempts@12484,registry:B@3385,registry:B@3439,registry:Backing@7451,registry:Bucket@3100,registry:BuildState@8076,registry:By@3316,registry:Changed@12394,registry:Changed@2860,registry:Changed@2933,registry:Changed@3034,registry:Changed@322,registry:Changed@3721,registry:Changed@4152,registry:Changed@4225,registry:Changed@464,registry:Changed@4674,registry:Changed@4915,registry:Changed@5448,registry:Changed@564,registry:Changed@6140,registry:Changed@6227,registry:Changed@6316,registry:Changed@6387,registry:Changed@6491,registry:Changed@6578,registry:Changed@6671,registry:Changed@6753,registry:Changed@832,registry:Changed@8664,registry:Changed@8801,registry:Changed@929,registry:Changed@9398,registry:Changed@9586,registry:Channel@7115,registry:Channel@8507,registry:Channel@9056,registry:CheckedAt@9137,registry:Class@7570,registry:DoneBefore@12723,registry:Due@10164,registry:Due@10228,registry:Due@12506,registry:Duty@312,registry:Duty@390,registry:Duty@634,registry:EgressAllow@7979,registry:Env@8575,registry:Env@8967,registry:Env@9067,registry:ExcludeHosts@12189,registry:ExcludeHosts@12284,registry:ExpectGood@9336,registry:ExpectOp@6195,registry:ExpectOp@6445,registry:ExpectPair@6625,registry:Expected@1001,registry:Expected@1153,registry:Expected@1626,registry:Expected@1803,registry:Expected@2114,registry:F@2832,registry:F@2893,registry:F@2978,registry:F@2988,registry:F@3077,registry:F@3087,registry:F@3100,registry:Fleet@3132,registry:Fleet@3497,registry:Fleet@3579,registry:Fleet@3660,registry:Fleet@3764,registry:Fleet@3861,registry:Fleet@3946,registry:Fleet@4047,registry:Fleet@8707,registry:FleetBoxes@3996,registry:Fleets@3202,registry:From@7226,registry:From@7287,registry:FromDB@7362,registry:FromOp@6283,registry:FromSock@7372,registry:HAJournal@183,registry:HAJournal@221,registry:Hash@8381,registry:Health@7649,registry:HomeLink@4751,registry:HomeLink@4827,registry:HomeLinkApp@5304,registry:HomeLinkApp@5404,registry:HomeLinkApps@5234,registry:Host@10041,registry:Host@10101,registry:Host@10156,registry:Host@10220,registry:Host@10404,registry:Host@10455,registry:Host@10522,registry:Host@10597,registry:Host@10660,registry:Host@11257,registry:Host@1136,registry:Host@11383,registry:Host@11537,registry:Host@11825,registry:Host@11889,registry:Host@11948,registry:Host@12031,registry:Host@12114,registry:Host@12345,registry:Host@12430,registry:Host@12562,registry:Host@12643,registry:Host@12806,registry:Host@1888,registry:Host@1999,registry:Host@286,registry:Host@350,registry:Host@422,registry:Host@4713,registry:Host@501,registry:Host@5901,registry:Host@5942,registry:Host@602,registry:Host@6095,registry:Host@6171,registry:Host@6257,registry:Host@6349,registry:Host@6421,registry:Host@6527,registry:Host@6617,registry:Host@6705,registry:Host@6797,registry:Host@694,registry:Host@7047,registry:Host@7107,registry:Host@7165,registry:Host@7218,registry:Host@7279,registry:Host@7354,registry:Host@7443,registry:Host@7497,registry:Host@7562,registry:Host@7624,registry:Host@7702,registry:Host@772,registry:Host@7759,registry:Host@7818,registry:Host@7906,registry:Host@7971,registry:Host@8068,registry:Host@8133,registry:Host@8194,registry:Host@8244,registry:Host@8309,registry:Host@8373,registry:Host@8434,registry:Host@8567,registry:Host@8621,registry:Host@869,registry:Host@8699,registry:Host@8836,registry:Host@8889,registry:Host@9119,registry:Host@9203,registry:Host@9260,registry:Host@9328,registry:Host@9543,registry:Host@973,registry:Host@9808,registry:Host@9965,registry:Hosts@1051,registry:Hosts@5780,registry:Hosts@8498,registry:Hosts@8958,registry:Hosts@9047,registry:Id@2108,registry:Id@2419,registry:Id@2518,registry:Id@2598,registry:Id@2749,registry:IdValue@5536,registry:Idle@10530,registry:Import@734,registry:Journal@1306,registry:Journal@2126,registry:Journal@2425,registry:Journal@2604,registry:Keep@12822,registry:KeyFP@3307,registry:Kind@12651,registry:Kind@12814,registry:Label@3506,registry:Label@3588,registry:Label@3669,registry:Label@3773,registry:Label@3870,registry:Label@3955,registry:Label@4950,registry:Label@8716,registry:Lifetime@358,registry:Lifetime@430,registry:Lifetime@517,registry:Lifetime@610,registry:Lifetime@877,registry:Limit@12180,registry:Limit@12275,registry:Link@4188,registry:LinkID@4264,registry:LinkID@4443,registry:LinkID@4635,registry:LinkID@4721,registry:LinkID@5091,registry:LinkSeen@4545,registry:MaxRun@10538,registry:Method@151,registry:Moved@8329,registry:Ms@12478,registry:Name@11897,registry:Name@11956,registry:Name@12039,registry:Name@12353,registry:Name@12438,registry:Name@12570,registry:Name@1896,registry:Name@2007,registry:Name@2978,registry:Name@3077,registry:Name@3172,registry:Name@3292,registry:Name@5347,registry:Name@5487,registry:Name@5555,registry:Next@1165,registry:NextAt@12496,registry:NextGood@9350,registry:NextValue@2678,registry:NextValue@2776,registry:Now@10731,registry:Now@12173,registry:Now@12268,registry:Now@12361,registry:Now@2031,registry:Number64@3819,registry:Number64@5184,registry:Number64@5643,registry:Number@12611,registry:Number@12682,registry:Number@12767,registry:Observed@1229,registry:Observed@9444,registry:Observed@9531,registry:Observed@9631,registry:Observed@9706,registry:Observed@9898,registry:ObservedValue@1507,registry:Old@2671,registry:Old@2769,registry:On@10109,registry:On@10605,registry:On@10668,registry:On@4460,registry:On@5101,registry:On@9845,registry:On@9910,registry:On@9980,registry:Op@6113,registry:Op@6189,registry:Op@6357,registry:Op@6439,registry:Op@6535,registry:Op@6713,registry:Op@6805,registry:Owner@1144,registry:Owner@1241,registry:Owner@1524,registry:P@11491,registry:PagesOff@7767,registry:Pair@509,registry:Pair@6457,registry:Pair@6541,registry:Pair@6639,registry:Pair@780,registry:Pair@981,registry:Path@11722,registry:Paths@11419,registry:PolicyExpiresAt@8002,registry:Prefix@11545,registry:Prev@9275,registry:Pub@3300,registry:RDs@11391,registry:RateLimit@8442,registry:Receipt@889,registry:Regional@11289,registry:Registration@12047,registry:Registration@12446,registry:Registration@1904,registry:Registration@2015,registry:Replica@8202,registry:ReplicaLife@9718,registry:ReplicaLife@9816,registry:Replicas@8141,registry:Retirement@2755,registry:Revision@529,registry:Revision@622,registry:Revision@989,registry:Route@5878,registry:Routes@10262,registry:Routes@10329,registry:Routes@10698,registry:Routes@4602,registry:Routes@5836,registry:Routes@6831,registry:Rows@11833,registry:Seed@10412,registry:SeenAt@4466,registry:Seq@4453,registry:Size@7994,registry:Sqid@5547,registry:Sqid@5610,registry:Sqid@5689,registry:Status@10960,registry:Status@12468,registry:Status@12578,registry:Status@1920,registry:Status@3678,registry:Status@5012,registry:Status@6103,registry:Status@6179,registry:Status@6265,registry:Status@6429,registry:Status@7173,registry:Status@9127,registry:Steering@7710,registry:StringMap@4084,registry:StringMap@4301,registry:StringMap@4364,registry:T@11773,registry:T@1621,registry:T@1715,registry:T@1798,registry:TValue@5983,registry:TValue@6050,registry:TValue@8766,registry:TValue@9456,registry:Tags@3597,registry:Target@8897,registry:Targets@1317,registry:Text@11578,registry:Text@11641,registry:Text@2324,registry:Text@2471,registry:Text@5657,registry:Timer@11861,registry:Timer@1573,registry:Timer@1755,registry:Timers@12084,registry:Timers@12143,registry:Timers@12232,registry:Times@12856,registry:To@7234,registry:To@7295,registry:ToDB@7384,registry:ToOp@6275,registry:ToSock@7392,registry:TokenHash@3515,registry:Tunnel@8629,registry:Unit@7505,registry:UpdateSettings@7914,registry:Ver@10049,registry:Ver@9268,registry:Ver@9973,registry:W@11191,registry:Wake@702,registry:Wake@788,registry:Wildcards@11085,whole:Account@5721,whole:ClaimOwnership@1146,whole:ClaimOwnership@1243,whole:ClaimOwnership@1526,whole:ClaimRow@1319,whole:ClaimRowArchive@1425,whole:ClaimRowArchive@1435,whole:ColdRows@2673,whole:ColdRows@2680,whole:ColdRows@2771,whole:ColdRows@2778,whole:DutyState@316,whole:DutyState@394,whole:DutyState@636,whole:Fleet@2834,whole:Fleet@2895,whole:Fleet@2980,whole:Fleet@2990,whole:Fleet@3079,whole:Fleet@3089,whole:Fleet@3102,whole:Fleet@3136,whole:Fleet@3206,whole:FleetBox@3387,whole:FleetBox@3441,whole:FleetBox@4000,whole:GoodBuild@9338,whole:GoodBuild@9352,whole:HAAdoption@1015,whole:HAAdoption@822,whole:HAWakeImport@704,whole:HAWakeImport@790,whole:HomeLink@4755,whole:HomeLink@4829,whole:HomeLinkApp@5238,whole:HomeLinkApp@5308,whole:HomeLinkApp@5406,whole:LinkChannel@4190,whole:LinkSeen@4549,whole:Pair@511,whole:Pair@6459,whole:Pair@6543,whole:Pair@6627,whole:Pair@6641,whole:Pair@782,whole:Pair@983,whole:RegionalDomain@11293,whole:RegionalDomain@11393,whole:Route@10266,whole:Route@10333,whole:Route@10702,whole:Route@1231,whole:Route@4606,whole:Route@5840,whole:Route@5882,whole:Route@5985,whole:Route@6052,whole:Route@6835,whole:Route@6990,whole:Route@6996,whole:Route@8768,whole:Route@9446,whole:Route@9458,whole:Route@9533,whole:Route@9633,whole:Route@9708,whole:Route@9900,whole:RouteAlias@10765,whole:RouteAlias@10841,whole:RoutePath@11423,whole:RoutePath@11493,whole:Timer@11775,whole:Timer@11835,whole:Timer@11865,whole:Timer@12088,whole:Timer@12147,whole:Timer@12236,whole:Timer@1509,whole:Timer@1577,whole:Timer@1623,whole:Timer@1717,whole:Timer@1759,whole:Timer@1800,whole:WildcardDomain@11089,whole:WildcardDomain@11193,whole:haJournalRequest@223,whole:haJournalResponse@187 b980809009dd01a889894a597029b1f29441100f50a2aebdd735468335da5ee0
-internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map (none for a minted apex) and never inheriting the source's (Astra r2 P1); a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test (generation proxy, hib, no-activator 404) is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance goes through the activator; binary rows unchanged;rev3=census-ruling-edge-roll-blip;basis=the tcpProxy and multiProxy calls pass e.hold (the per-Edge localHold set once in newEdge): a loopback TCP upstream that refuses is redialled for up to 13 s and a probed route with a local upstream waits for prober readmission instead of answering 502/503 (#434 part B); edge-side dial policy only, no read added, same 52 sites;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: after the alias fold, reads the regional_domains rows (e.reg.ListRegional; an error aborts the reload as every registry read here does) and applies them with foldRegional against the routes slice the same reload read; the added reads are that one registry list and the routes already read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 4 and 6: the forward case (fleetProxy toward the binding's FleetBox, throttled refusal); one refusal check before the switch from FleetArmVerdict (sidecar not judged; a non-ready forward row refused; a forward row always judged by FleetServeEligible, any other row only where tunnels are on; an alias of a refused source refused with it); the accountless note; path rows of a forward host not folded; no alias folded onto a refused row; refusedHosts held through every fold. ListFleets and FleetChannelAuth read before the loop (+registry:FleetBox, +registry:Host x7, +whole:Route x3). Serving only; the hub's agent, not root. Review R1 finding 2: the switch reads verdict.Served (FleetArmVerdict) by host; the forward case and the fleet-placed case take their fleet from it (served.Fleet) instead of FleetPlacement(t.Region), and an admitted forward row not Served continues rather than falling through (+registry:Host, -registry:Region); the same rows take the same arms; no read added. Review R2: the switch is on DispatchArm(t, viaFleet, tunnels) (the order moved there unchanged: forward only when in Arm, own Tunnel, fleet, socket, addrs, static, status, else continue), the fleet cases read verdict.Arm (renamed from Served), and the platform-alias fold is foldPlatformAliases with the same take (source entry, own paths, alias marks) and the same refusal log (-registry:Kind x2, -registry:Socket, -registry:Tunnel, +whole:Route: those reads moved into DispatchArm); same rows, same arms, same entries; no read added.;rev3=census-ruling-fleet-routes-followups;basis=the owners map is now e.reg.FleetOwners() instead of ListFleets folded inline: the same fresh-connection ListFleets read and the same name->account map (-registry:Account, -registry:Name, -whole:Fleet x2 move into Registry.FleetOwners); no read added; same error path (abort the reload);rev3=census-ruling-tunnel-websockets;basis=The ArmTunnel arm now records its tenancy (Account, App, Tunnel) copied from the row t that Reload already lists; no new registry query, no file read. Also the reload mutex taken first and held to return, five nil-in-production test hooks, and the sweepUpgrades call after the swap, which reads only the map Reload has just built (spec 7, Tasks 3 and 4).;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the two fleet proxy builds pass the row to fleetBoxOf(t) instead of reading t.FleetBox (-registry:FleetBox x2, +whole:Route x2); fleetBoxOf answers FleetLabel as authoritative when set, else FleetBox; an authoritative box has no fallback to another of the fleet's channels (503 errFleetDark instead). The edge in the agent, not root; it routes to fewer channels, never more.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): after the new upstream map is published, closes the held streams of any host the new map no longer holds (absent, not hibernating, route no longer Hibernate). Reads the freshly built in-memory map m and the in-memory held set; no read added beyond the rebuild Reload already does.;rev3=census-ruling-devbox-identity;basis=#486 A: only the devbox edge created by newDevboxEdge (carlos-devbox service user, not root) enables the new proxy hooks. Saves the existing DispatchArm result and reads t.Socket from an already-listed route when that arm is ArmSocket, passing it to configureDevboxProxy for per-request expected-owner validation and visitor-header rewriting. Adds one registry:Socket field site; no new registry query or file open, and ordinary fleet/agent edges leave the hook disabled. Final fix wave: its devbox-only outgoing-header/trailer hooks now also strip case-insensitive underscore/hyphen aliases through stripVisitorHeaders; no new read.;rev3=census-ruling-agent-start-demo-1;basis=Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query. Merge resolution against origin/main 9bd45488 retains main's devbox proxy hooks (reading the existing route Socket) alongside demo filtering; no additional registry query.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: dispatch admitted stateless set rows through replicaProxy before legacy fleetBoxOf. Read Host and supplied whole Route values from the existing listing to build and filter the set probe inputs after all registry reads and alias folds; synchronize before map publication. Tenancy comes only from FleetArmVerdict. No new external read; no set row reaches legacy fallback, local addresses, provision.Health or hibernation on the hub. Fix round 1 M2: comment and whitespace correction only; read sites and routing behavior unchanged.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1175-1177 passes an already-listed demo Route to demoProxy; :1358 passes existing Route and RouteAlias slices to demoRefusalNames; :1401 publishes refusal names before upstreams. Adds whole-value uses only, no new registry query; retained names refuse fallback after filtering.;rev3=census-ruling-demo-api-site-route;basis=Build a dedicated demo API proxy from the selected existing socket, TCP or probed console transport in the same atomic route snapshot, before ordinary wrappers. Reads existing route Host twice, Version and two whole Route values for exact operator-configured console eligibility. No additional registry query or external read.;rev3=census-ruling-agent-start-demo-3;basis=Refresh the verified moved snapshot from registry on reload before route-independent serving. Census read-site delta: unchanged (87).;rev3=census-ruling-region-ha-g2-fixes;basis=Derive blocked ingress names from already listed unready/held/import-gated/sidecar and fleet-refused rows; added field reads only.;rev3=census-ruling-edge-page-cache-1;basis=keeps every row this reload already read from the registry (e.pageRoutes, e.pageRoutesRead = routes, true, under reloadMu) for the page reload hook; the +whole:Route sites are that assignment of the same slice; no new read;rev3=census-ruling-held-move-speed;basis=the six tenant reverse proxies' ModifyResponse is now classifyMoveStreams(e.responseModifier(t)): MarkMoveStream first reads the response head (status 101, or Content-Type text/event-stream) and sets a flag on the request's in-memory StreamEnd, then responseModifier runs unchanged (byte-identical to main). The hook never wraps or touches the body, so the trailer scrubs keep the proxy as their one closer (Astra r2 F2.1: the graceful boundary end and its watcher were cut). No read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: with tunnels on, the pass also reads LinkChannelAuth and LinkOwners from the box's own registry (fresh connection, as FleetChannelAuth and FleetOwners) and merges each well-formed link channel's hash into the set SetDynamicAuth takes; the verdict judges link-placed forward rows by the link owners; an admitted one takes the new ArmLink case (linkProxy down the link's channel, tenancy with the link); the door's fleet snapshot stays fleet owners only and link owners go to a separate snapshot; +whole:Route is the row handed to the new case's responseModifier; the edge process as carlos, no root decision; linked deployments slice 1 Task 8: each upstream entry also records localBackend (ArmSocket, or an instance the activator runs here), from values the pass already holds; no read added registry:Account@11643,registry:Alias@27003,registry:Alias@27090,registry:Alias@27670,registry:App@11659,registry:Health@15426,registry:Health@15552,registry:Hibernate@31954,registry:HoldOp@30750,registry:Host@12970,registry:Host@13027,registry:Host@13063,registry:Host@13827,registry:Host@16035,registry:Host@16130,registry:Host@16418,registry:Host@16444,registry:Host@16496,registry:Host@19326,registry:Host@19359,registry:Host@21382,registry:Host@23289,registry:Host@23597,registry:Host@23624,registry:Host@24522,registry:Host@25094,registry:Host@27424,registry:Host@27473,registry:Host@30186,registry:Host@30211,registry:Host@30228,registry:Host@30827,registry:Host@5253,registry:Host@5622,registry:Host@5676,registry:Host@5726,registry:Host@6746,registry:Host@6935,registry:ImportGate@30769,registry:Kind@19718,registry:Kind@19740,registry:Prefix@25069,registry:Socket@13891,registry:Socket@19597,registry:Socket@23605,registry:Status@30726,registry:Status@5547,registry:Target@25081,registry:Tunnel@11482,registry:Tunnel@11674,registry:Version@19449,registry:Version@19699,registry:Version@19801,whole:RegionalDomain@28312,whole:Route@11564,whole:Route@13118,whole:Route@13246,whole:Route@13967,whole:Route@16589,whole:Route@16654,whole:Route@16705,whole:Route@19376,whole:Route@19383,whole:Route@19507,whole:Route@23685,whole:Route@23692,whole:Route@23788,whole:Route@24957,whole:Route@26125,whole:Route@28304,whole:Route@28360,whole:Route@28400,whole:Route@30092,whole:Route@30126,whole:Route@30214,whole:Route@30293,whole:Route@30712,whole:Route@313,whole:Route@31956,whole:Route@32013,whole:Route@32044,whole:Route@4273,whole:Route@4331,whole:Route@5261,whole:Route@6775,whole:Route@7058,whole:Route@7192,whole:Route@7215,whole:Route@7230,whole:Route@8076,whole:Route@8204,whole:Route@9021,whole:RouteAlias@26974,whole:RouteAlias@28368,whole:RoutePath@24500 1c699b6275029e783c62648fe6d42b29103acb66d806e9e70b4aae41a73020a6
+internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map (none for a minted apex) and never inheriting the source's (Astra r2 P1); a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test (generation proxy, hib, no-activator 404) is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance goes through the activator; binary rows unchanged;rev3=census-ruling-edge-roll-blip;basis=the tcpProxy and multiProxy calls pass e.hold (the per-Edge localHold set once in newEdge): a loopback TCP upstream that refuses is redialled for up to 13 s and a probed route with a local upstream waits for prober readmission instead of answering 502/503 (#434 part B); edge-side dial policy only, no read added, same 52 sites;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: after the alias fold, reads the regional_domains rows (e.reg.ListRegional; an error aborts the reload as every registry read here does) and applies them with foldRegional against the routes slice the same reload read; the added reads are that one registry list and the routes already read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 4 and 6: the forward case (fleetProxy toward the binding's FleetBox, throttled refusal); one refusal check before the switch from FleetArmVerdict (sidecar not judged; a non-ready forward row refused; a forward row always judged by FleetServeEligible, any other row only where tunnels are on; an alias of a refused source refused with it); the accountless note; path rows of a forward host not folded; no alias folded onto a refused row; refusedHosts held through every fold. ListFleets and FleetChannelAuth read before the loop (+registry:FleetBox, +registry:Host x7, +whole:Route x3). Serving only; the hub's agent, not root. Review R1 finding 2: the switch reads verdict.Served (FleetArmVerdict) by host; the forward case and the fleet-placed case take their fleet from it (served.Fleet) instead of FleetPlacement(t.Region), and an admitted forward row not Served continues rather than falling through (+registry:Host, -registry:Region); the same rows take the same arms; no read added. Review R2: the switch is on DispatchArm(t, viaFleet, tunnels) (the order moved there unchanged: forward only when in Arm, own Tunnel, fleet, socket, addrs, static, status, else continue), the fleet cases read verdict.Arm (renamed from Served), and the platform-alias fold is foldPlatformAliases with the same take (source entry, own paths, alias marks) and the same refusal log (-registry:Kind x2, -registry:Socket, -registry:Tunnel, +whole:Route: those reads moved into DispatchArm); same rows, same arms, same entries; no read added.;rev3=census-ruling-fleet-routes-followups;basis=the owners map is now e.reg.FleetOwners() instead of ListFleets folded inline: the same fresh-connection ListFleets read and the same name->account map (-registry:Account, -registry:Name, -whole:Fleet x2 move into Registry.FleetOwners); no read added; same error path (abort the reload);rev3=census-ruling-tunnel-websockets;basis=The ArmTunnel arm now records its tenancy (Account, App, Tunnel) copied from the row t that Reload already lists; no new registry query, no file read. Also the reload mutex taken first and held to return, five nil-in-production test hooks, and the sweepUpgrades call after the swap, which reads only the map Reload has just built (spec 7, Tasks 3 and 4).;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the two fleet proxy builds pass the row to fleetBoxOf(t) instead of reading t.FleetBox (-registry:FleetBox x2, +whole:Route x2); fleetBoxOf answers FleetLabel as authoritative when set, else FleetBox; an authoritative box has no fallback to another of the fleet's channels (503 errFleetDark instead). The edge in the agent, not root; it routes to fewer channels, never more.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): after the new upstream map is published, closes the held streams of any host the new map no longer holds (absent, not hibernating, route no longer Hibernate). Reads the freshly built in-memory map m and the in-memory held set; no read added beyond the rebuild Reload already does.;rev3=census-ruling-devbox-identity;basis=#486 A: only the devbox edge created by newDevboxEdge (carlos-devbox service user, not root) enables the new proxy hooks. Saves the existing DispatchArm result and reads t.Socket from an already-listed route when that arm is ArmSocket, passing it to configureDevboxProxy for per-request expected-owner validation and visitor-header rewriting. Adds one registry:Socket field site; no new registry query or file open, and ordinary fleet/agent edges leave the hook disabled. Final fix wave: its devbox-only outgoing-header/trailer hooks now also strip case-insensitive underscore/hyphen aliases through stripVisitorHeaders; no new read.;rev3=census-ruling-agent-start-demo-1;basis=Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query. Merge resolution against origin/main 9bd45488 retains main's devbox proxy hooks (reading the existing route Socket) alongside demo filtering; no additional registry query.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: dispatch admitted stateless set rows through replicaProxy before legacy fleetBoxOf. Read Host and supplied whole Route values from the existing listing to build and filter the set probe inputs after all registry reads and alias folds; synchronize before map publication. Tenancy comes only from FleetArmVerdict. No new external read; no set row reaches legacy fallback, local addresses, provision.Health or hibernation on the hub. Fix round 1 M2: comment and whitespace correction only; read sites and routing behavior unchanged.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1175-1177 passes an already-listed demo Route to demoProxy; :1358 passes existing Route and RouteAlias slices to demoRefusalNames; :1401 publishes refusal names before upstreams. Adds whole-value uses only, no new registry query; retained names refuse fallback after filtering.;rev3=census-ruling-demo-api-site-route;basis=Build a dedicated demo API proxy from the selected existing socket, TCP or probed console transport in the same atomic route snapshot, before ordinary wrappers. Reads existing route Host twice, Version and two whole Route values for exact operator-configured console eligibility. No additional registry query or external read.;rev3=census-ruling-agent-start-demo-3;basis=Refresh the verified moved snapshot from registry on reload before route-independent serving. Census read-site delta: unchanged (87).;rev3=census-ruling-region-ha-g2-fixes;basis=Derive blocked ingress names from already listed unready/held/import-gated/sidecar and fleet-refused rows; added field reads only.;rev3=census-ruling-edge-page-cache-1;basis=keeps every row this reload already read from the registry (e.pageRoutes, e.pageRoutesRead = routes, true, under reloadMu) for the page reload hook; the +whole:Route sites are that assignment of the same slice; no new read;rev3=census-ruling-held-move-speed;basis=the six tenant reverse proxies' ModifyResponse is now classifyMoveStreams(e.responseModifier(t)): MarkMoveStream first reads the response head (status 101, or Content-Type text/event-stream) and sets a flag on the request's in-memory StreamEnd, then responseModifier runs unchanged (byte-identical to main). The hook never wraps or touches the body, so the trailer scrubs keep the proxy as their one closer (Astra r2 F2.1: the graceful boundary end and its watcher were cut). No read added;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: with tunnels on, the pass also reads LinkChannelAuth and LinkOwners from the box's own registry (fresh connection, as FleetChannelAuth and FleetOwners) and merges each well-formed link channel's hash into the set SetDynamicAuth takes; the verdict judges link-placed forward rows by the link owners; an admitted one takes the new ArmLink case (linkProxy down the link's channel, tenancy with the link); the door's fleet snapshot stays fleet owners only and link owners go to a separate snapshot; +whole:Route is the row handed to the new case's responseModifier; the edge process as carlos, no root decision; linked deployments slice 1 Task 8: each upstream entry also records localBackend (ArmSocket, or an instance the activator runs here), from values the pass already holds; no read added; linked deployments slice 1 Task 11: the LinkChannelAuth read (the same fresh-connection read) moves to the top of the pass, before List, and its map is applied at once through the hub's new SetLinkAuth (the link half of the credential set only; fleet entries untouched), so a link revocation or rotation closes the home connection on the old hash even when a later read or step of the same reload fails; the same map is still merged into the set SetDynamicAuth takes; no read added, one moved; the edge process as carlos, no root decision registry:Account@12371,registry:Alias@27731,registry:Alias@27818,registry:Alias@28398,registry:App@12387,registry:Health@16154,registry:Health@16280,registry:Hibernate@32682,registry:HoldOp@31478,registry:Host@13698,registry:Host@13755,registry:Host@13791,registry:Host@14555,registry:Host@16763,registry:Host@16858,registry:Host@17146,registry:Host@17172,registry:Host@17224,registry:Host@20054,registry:Host@20087,registry:Host@22110,registry:Host@24017,registry:Host@24325,registry:Host@24352,registry:Host@25250,registry:Host@25822,registry:Host@28152,registry:Host@28201,registry:Host@30914,registry:Host@30939,registry:Host@30956,registry:Host@31555,registry:Host@5981,registry:Host@6350,registry:Host@6404,registry:Host@6454,registry:Host@7474,registry:Host@7663,registry:ImportGate@31497,registry:Kind@20446,registry:Kind@20468,registry:Prefix@25797,registry:Socket@14619,registry:Socket@20325,registry:Socket@24333,registry:Status@31454,registry:Status@6275,registry:Target@25809,registry:Tunnel@12210,registry:Tunnel@12402,registry:Version@20177,registry:Version@20427,registry:Version@20529,whole:RegionalDomain@29040,whole:Route@1045,whole:Route@12292,whole:Route@13846,whole:Route@13974,whole:Route@14695,whole:Route@17317,whole:Route@17382,whole:Route@17433,whole:Route@20104,whole:Route@20111,whole:Route@20235,whole:Route@24413,whole:Route@24420,whole:Route@24516,whole:Route@25685,whole:Route@26853,whole:Route@29032,whole:Route@29088,whole:Route@29128,whole:Route@30820,whole:Route@30854,whole:Route@30942,whole:Route@31021,whole:Route@31440,whole:Route@32684,whole:Route@32741,whole:Route@32772,whole:Route@5001,whole:Route@5059,whole:Route@5989,whole:Route@7503,whole:Route@7786,whole:Route@7920,whole:Route@7943,whole:Route@7958,whole:Route@8804,whole:Route@8932,whole:Route@9749,whole:RouteAlias@27702,whole:RouteAlias@29096,whole:RoutePath@25228 57267b6a9cfcaeed4995b1857bd851ae19e2f3d5f67e83209e0a85daeb3bb0a7
internal/edge/fleetforward.go FleetArmVerdict 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 6 fix round 3: the single fleet-arm refusal decision over one listing, used by Edge.Reload, the edges-file writer and the alias pass (parity by construction); returns the refused set with reasons and the accountless notes (+registry:Host x3, +registry:Status, +whole:Route x3). Pure; no I/O. Review R1 finding 2: also returns Served, each admitted row Reload sends through the fleet arm (a forward row, or a fleet-placed row with no Tunnel) with its fleet, app and the fleet owner from owners; a host the alias step refuses is dropped from it (+registry:App, +registry:Host, +registry:Region, +registry:Tunnel on the listing it already holds). Pure; no I/O. Review R2: the pre-fold fleet rows are now Arm; Served is the destination after the platform-alias fold: every ready, unrefused, non-sidecar row DispatchArm gives an entry, with its Arm fleet when its arm is a fleet's, folded by foldPlatformAliases (Reload's own fold), keeping the hosts that go to a fleet (+registry:Host, +registry:Status, +whole:Route on the listing it already holds). Pure; no I/O; refusals unchanged.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: classify ArmReplica as fleet-served for the existing shared routing, edges-file and alias verdict. Existing field reads unchanged; pure in-memory decision, same owner and alias checks.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: owners is edge.ForwardOwners; a link-placed forward row (registry.LinkPlacement over the listed row's Region) admitted by FleetServeEligible gets an Arm entry with its link, app and the link's owner, and ArmLink rows count as served; +registry:App, +registry:Host, +registry:Region are that row's fields; a pure decision over the listing, no read source added registry:App@769,registry:App@970,registry:Host@1615,registry:Host@1675,registry:Host@1807,registry:Host@1867,registry:Host@376,registry:Host@559,registry:Host@618,registry:Host@729,registry:Host@928,registry:Region@681,registry:Region@859,registry:Status@1547,registry:Status@316,registry:Tunnel@900,whole:Route@1049,whole:Route@1515,whole:Route@1705,whole:Route@1923,whole:Route@264,whole:Route@518 b98bcc250129fbe47a5fc5be92bac28d809683358010420c3c52388bb42f36a2
internal/edge/fleetforward.go FleetServeEligible 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 4 (§4.4 tenancy): a forward row is eligible only on a hub, inert, fleet-placed, its fleet in the fleets table and its raw Account non-empty and equal to the owner; a non-forward fleet-placed row: empty raw Account served and noted, else release.RouteAccount must equal the owner; raw field before RouteAccount (+registry:Account x7, +registry:Region x2, +registry:Tunnel, +whole:Route). Pure; no I/O.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: gate set routing on hub role, valid projection, nonempty account/app, instance or inert forward kind, no platform ownership, HA, hibernation or explicit tunnel. New reads are fields of the already-supplied Route. Existing fleet-owner and inert-forward checks still apply; no external read or expansion of destination authority. Fix round 1 M1: retain the same fail-closed structural predicate but give each invalid condition an internal diagnostic instead of the no-healthy-copy message. No admission expansion, user-facing answer, or additional read.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 3: owners is edge.ForwardOwners; a forward row whose Region parses as a link placement is judged by linkServeEligible against owners.Links only, and every other row as before against owners.Fleets; +registry:Region and +whole:Route are that parse and the hand-off; refuses more, never admits a fleet row by link owners registry:Account@1413,registry:Account@1484,registry:Account@1570,registry:Account@1672,registry:Account@1828,registry:Account@1926,registry:Account@2189,registry:Account@512,registry:App@532,registry:FleetBoxes@297,registry:HA@683,registry:Hibernate@692,registry:Kind@860,registry:Platform@610,registry:Region@1244,registry:Region@142,registry:Region@282,registry:Tunnel@1629,registry:Tunnel@774,whole:Route@208,whole:Route@2111 94d88d4b36a3dbc2d0cac93be76da320d5926d71b66a2ad8f89bc84ec639468e
internal/edge/purge_header.go Edge.resolvePurgeOwnersIn legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-page-cache-1;basis=resolvePurgeHosts' former body, verbatim but for three things: it takes the snapshot (cur) from its caller, answers purgeHost{host, owner} pairs, and a host admitted by the path-routing exception (another app) is owned by the serving route rt (the +registry:App sites), so its page clear is of rt's own pages; the same caps, validation and ownership checks;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 8: a declared Carlos-Purge-Host equal to the linked request's public host is the serving route's own host (rt.Host, owner rt), as naming rt.Host already is; the new sites read rt.Host and build purgeHost{rt.Host, rt}; nothing outside rt's own entries becomes purgeable registry:Account@5255,registry:Account@5303,registry:App@4466,registry:App@4484,registry:App@5247,registry:App@5289,registry:App@5394,registry:App@5407,registry:Host@1110,registry:Host@1238,registry:Host@1444,registry:Host@1557,registry:Host@183,registry:Host@1836,registry:Host@2033,registry:Host@2456,registry:Host@2989,registry:Host@3038,registry:Host@4449,registry:Host@4599,registry:Host@4797,registry:Host@494,registry:Host@4959,registry:Host@5238,registry:Host@6019,registry:Host@617,registry:Host@6180,whole:Route@192,whole:Route@2716,whole:Route@3047,whole:Route@4471,whole:Route@4524,whole:Route@4555,whole:Route@4910,whole:Route@5292,whole:Route@5306,whole:Route@5383,whole:Route@5547,whole:Route@5555,whole:Route@5602 3cc7b6ca49d2474edb365c73781a5384a2d171f44ecb969acdf7763536e47477
@@ -123,7 +123,7 @@ 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 ae50155c5f75eecb67afd1070d65edbb6d0b8f9ad98f34b4e0da065b7c59e012
+@coverage internal/edge d78675d7a8fdb560a49df34ec27ead41b1efcb50e83a6410f2a829dd8d53016b
@coverage internal/gate 17307a6623f6149db163fc8de9139f8d824b36d70d2da635c712aee3671e582a
@coverage internal/host 9a1b98f6896147e930776114271105b245546a5b96551872002810ff9ae5403d
@coverage internal/provision 6c3f9188cfe17a2f7f87d78cf5f60e9104f5bcd55941947129a5bcea3e4c586c