region HA: drain acks name phase and publication; drained waits
Task 1 fix round 1 (Astra r1): - the ha_drain mark (transaction and per-transition id) identifies each drain-state publication; acks name phase and id, never a generation - a drained ack waits for the fold's drained effects to complete - drained clears the edge's own backhaul holder entries by reference - control requests take a verified name from the certificate mirror, not from either box's host map Census re-proposed under the same name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/notes/census-proposal-region-ha-held-build.md+2 −2internal/edge/backhaul_holder.go+19 −0internal/edge/certsync.go+1 −0internal/edge/edge.go+3 −0internal/edge/hadrain.go+151 −80internal/edge/hadrain_test.go+233 −81internal/edge/homemap.go+10 −5internal/host/edgesfile.go+6 −2internal/host/hadrainstate.go+71 −24internal/host/hadrainstate_test.go+47 −27internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-region-ha-held-build.tsv+5 −5
Intent
<task-notification> <task-id>a79933d5fcfe210b4</task-id> <tool-use-id>toolu_01WLZrcGGoB6K2CK8Adqv58H</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/283be278-5c6a-4a71-a8d6-b3d32c668985/tasks/a79933d5fcfe210b4.output</output-file> <status>completed</status> <summary>Agent "Implement Task 1: drain state" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE_WITH_CONCERNS Commits (not pushed): - `926057ca` region HA: drain state, placement withdrawal and drain acks - `ee8609ab` census: card and overlay for held-requests Task 1 Tests: 18 new tests across activator, edge and host fail without the code and pass with it. I checked that by removing each piece of the implementation in turn. The targeted HA, placement and silent runs pass in all three packages, gofmt, vet and the darwin/windows builds are clean, and the census test passes after the proposal. Concerns: 1. The drain reuses the existing box-level `draining` field; `drained` is a new `ha_drained` field, because admission's `drained` controls name authority. The side effect: while a box drains, it leaves db-read elections, and the console counts it out of HA capacity and db-read capability. If "db reads keep their meaning" means the box must keep serving db reads during a drain, `draining` needs a separate new field instead. 2. Any lease this draining box holds while the host is neither waking nor awake now gets a 503 instead of being served here. The box's own published file already caused this once folded back; the local rule only brings it forward. 3. A peer that publishes no hosts is asked using this box's own host as the TLS name. If neither box publishes one, the ask fails, which fails the drain. 4. The census is not approved yet: it needs the cross-family verdict on #280. There is one new unit, `serveHAControl`; the census scanner listed its bounded request-body read as a file read. 5. The §24 table in the spec does not yet list the three new readers (left for Task 8). Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-held-build/.superpowers/sdd/2026-11-08-region-ha-held-requests/task-1-report.md</result> <usage><subagent_tokens>302693</subagent_tokens><tool_uses>96</tool_uses><duration_ms>1798033</duration_ms></usage> </task-notification>
<task-notification> <task-id>b8fy4a65l</task-id> <tool-use-id>toolu_019pSYrCDJLxhTUwshHf1gko</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/283be278-5c6a-4a71-a8d6-b3d32c668985/tasks/b8fy4a65l.output</output-file> <status>completed</status> <summary>Background command "Wait for Task 1 review" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 18.6 g CO₂e (2,417,883 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-held-build, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/notes/census-proposal-region-ha-held-build.md b/docs/superpowers/notes/census-proposal-region-ha-held-build.md| index 37108eeda..531c463ab 100644 |
| --- a/docs/superpowers/notes/census-proposal-region-ha-held-build.md |
| +++ b/docs/superpowers/notes/census-proposal-region-ha-held-build.md |
| @@ -10,7 +10,7 @@ Ruling `census-ruling-region-ha-held-build`. The independent reviewer approves o |
| | `internal/activator/haforward.go` `Service.decideForward` | body | unchanged (9) | the wake snapshot is LocalDenied also when IsDraining(); only narrows local placement; no read added | |
| | `internal/edge/edge.go` `Edge.ServeHTTP` | body | unchanged (56) | first branch: a request for the reserved control paths /.carlos/ha-drain and /.carlos/ha-take goes to serveHAControl and returns (refused unless a signed ask); no request on those paths reaches a route, a forward or an app; no read added here | |
| | `internal/host/agent.go` `runAgent` | body | unchanged (9) | wires the drain state: svc.SetDrainingSource(boxDrain.IsDraining), svc.SetPeerDrainView(e.PeerDraining), e.SetPeerDrainedHook(svc.DropHoldersNaming); in-memory only; no read added | |
| -| `internal/host/edgesfile.go` `edgesFileWriteClaims` | body | unchanged (67) | writes also when DrainPublishRequired, and reports the written drain state and generation to DrainSource (in-memory); the file gains ha_drained beside the existing draining; no read added | |
| +| `internal/host/edgesfile.go` `edgesFileWriteClaims` | body | unchanged (67) | writes also when DrainPublishRequired, and reports the written drain state, its ha_drain mark (transaction and publication id) and generation to DrainSource (in-memory); the file gains ha_drained and ha_drain beside the existing draining; no read added | |
| Envelopes re-pinned: `internal/activator`, `internal/edge`, `internal/host`. |
| @@ -30,6 +30,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - new `internal/edge/hadrain.go:Edge.serveHAControl`: reads +file:ReadAll; written legacy, accepted-legacy, frozen |
| -Seal: `75fb3eb24d0bf3a8405b929675d919ec88f15386d43e9ff687ce138a7ed968a4` → `7c62551ef707837ca9dda6f91972f94a70a3285fd6fb3468bead605443ca6c64`. |
| +Seal: `75fb3eb24d0bf3a8405b929675d919ec88f15386d43e9ff687ce138a7ed968a4` → `5b22c20fe7ee69dad47d8113d934152f649f5f2444260f816d367fbcbdc9e56f`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-region-ha-held-build.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/edge/backhaul_holder.go b/internal/edge/backhaul_holder.go| index fb6316307..fed31871e 100644 |
| --- a/internal/edge/backhaul_holder.go |
| +++ b/internal/edge/backhaul_holder.go |
| @@ -98,6 +98,25 @@ func (c *backhaulHolderCache) drop(host, ref string, owner backhaulOwner) bool { |
| return false |
| } |
| +// dropRef forgets every entry naming ref (it published drained, §25.4 |
| +// step 4) and reports how many went. |
| +func (c *backhaulHolderCache) dropRef(ref string) int { |
| + if ref == "" { |
| + return 0 |
| + } |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + n := 0 |
| + for host, el := range c.entries { |
| + if el.Value.(backhaulHolderEntry).ref == ref { |
| + delete(c.entries, host) |
| + c.order.Remove(el) |
| + n++ |
| + } |
| + } |
| + return n |
| +} |
| + |
| func (e *Edge) dropBackhaulHolder(host, ref, reason string, owner backhaulOwner) { |
| if e.backhaulHolders.drop(host, ref, owner) { |
| e.logThrottled("backhaul-holder-drop "+ref, fmt.Sprintf("backhaul holder dropped for %s: %s (%s)", host, ref, reason)) |
diff --git a/internal/edge/certsync.go b/internal/edge/certsync.go| index bf9045dfc..e4bf83d5a 100644 |
| --- a/internal/edge/certsync.go |
| +++ b/internal/edge/certsync.go |
| @@ -591,6 +591,7 @@ func (e *Edge) newCertMirror(local autocert.Cache) *certMirror { |
| return nil |
| } |
| m := newCertMirror(e.staticStore, local) |
| + e.certs.Store(m) |
| m.health = e.lbHealth |
| m.watch = e.changeWatch |
| m.gated = func() bool { |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index d1cf55ecd..706a9700b 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -361,6 +361,9 @@ type Edge struct { |
| // peerDrained is the hook a fold runs when it first sees a peer's file |
| // say ha_drained (hadrain.go, SetPeerDrainedHook). |
| peerDrained atomic.Pointer[func(string)] |
| + // certs is the certificate mirror newCertMirror built, which control |
| + // requests choose their TLS name from (hadrain.go). |
| + certs atomic.Pointer[certMirror] |
| // backhaulTransports caches the outbound TLS transport of each backhaul |
| // target, keyed by the home box's EIP — see backhaulTransport. Bounded by |
| // the number of BOXES in the deployment, never by hostnames: a catch-all |
diff --git a/internal/edge/hadrain.go b/internal/edge/hadrain.go| index a126eabb4..fb729dee1 100644 |
| --- a/internal/edge/hadrain.go |
| +++ b/internal/edge/hadrain.go |
| @@ -26,13 +26,18 @@ import ( |
| // |
| // A draining box A publishes its drain state in its edges file, then asks |
| // every live box that views its region whether it now sees it: a POST to |
| -// HADrainPath naming the drain transaction and the generation of A's file. |
| -// The receiver refreshes its fold of the edges files (one normal fold read: |
| -// a LIST and a GET per file) unless it has already folded that generation, |
| -// and answers whether A's folded file says draining. An answer for a |
| -// (transaction, generation) the fold has settled is remembered, so a repeat |
| -// ask costs no store read. A refresh that fails answers "not seen" and is |
| -// not remembered. |
| +// HADrainPath naming the drain transaction, the phase (draining, or |
| +// drained) and the identity of the publication (the file's ha_drain |
| +// object: transaction and a per-transition ID, never a whole-second |
| +// generation, so no two transitions can alias). The receiver refreshes its |
| +// fold of the edges files (one normal fold read: a LIST and a GET per file) |
| +// unless its fold already holds that exact publication, and answers whether |
| +// the publication satisfies the phase. For drained it answers yes only once |
| +// the fold's drained effects for that publication have completed: the |
| +// edge's own backhaul holder entries and the activator's holder cache are |
| +// cleared of A. A settled answer is remembered, so a repeat ask costs no |
| +// store read. A refresh that fails, or a fold holding another publication, |
| +// answers "not seen" and is not remembered. |
| // |
| // Both control paths, HADrainPath and HATakePath (§25.7, the take request a |
| // later task adds), are reserved on every ingress: ServeHTTP answers them |
| @@ -73,11 +78,24 @@ const ( |
| // hopDoorDomain makes. |
| const haControlDomain = "carlos-ha-control\x00" |
| +// The phases an ask names. |
| +const ( |
| + DrainPhaseDraining = "draining" |
| + DrainPhaseDrained = "drained" |
| +) |
| + |
| // haDrainAsk is the ask's JSON body. |
| type haDrainAsk struct { |
| - From string `json:"from"` |
| - Txn string `json:"txn"` |
| - Generation string `json:"generation"` |
| + From string `json:"from"` |
| + Txn string `json:"txn"` |
| + Phase string `json:"phase"` |
| + ID uint64 `json:"id"` |
| +} |
| + |
| +// haDrainMarkView is a file's ha_drain object. |
| +type haDrainMarkView struct { |
| + Txn string `json:"txn"` |
| + ID uint64 `json:"id"` |
| } |
| // haDrainAnswer is the receiver's answer. |
| @@ -207,18 +225,14 @@ func (e *Edge) serveHAControl(w http.ResponseWriter, r *http.Request) { |
| return |
| } |
| var ask haDrainAsk |
| - if json.Unmarshal(body, &ask) != nil || ask.Txn != txn || !haControlField(ask.From) || ask.From == e.box { |
| - refuseHAControl(w) |
| - return |
| - } |
| - gen, err := time.Parse(time.RFC3339, ask.Generation) |
| - if err != nil { |
| + if json.Unmarshal(body, &ask) != nil || ask.Txn != txn || !haControlField(ask.From) || ask.From == e.box || ask.ID == 0 || |
| + (ask.Phase != DrainPhaseDraining && ask.Phase != DrainPhaseDrained) { |
| refuseHAControl(w) |
| return |
| } |
| ctx, cancel := context.WithTimeout(r.Context(), haDrainRefreshTimeout) |
| defer cancel() |
| - seen := m.drainSeen(ctx, ask.From, ask.Txn, gen) |
| + seen := m.drainSeen(ctx, ask) |
| w.Header().Set("Content-Type", "application/json") |
| w.Header().Set("Cache-Control", "no-store") |
| json.NewEncoder(w).Encode(haDrainAnswer{Seen: seen}) |
| @@ -233,24 +247,25 @@ type drainAcks struct { |
| order []string |
| } |
| -// drainSeen answers an ask from box from for transaction txn about the |
| -// generation gen of its file: whether the fold shows that file, at gen or |
| -// later, draining. The fold is read again unless it already settles the |
| -// question; a failed read answers false and remembers nothing. |
| -func (m *homeMap) drainSeen(ctx context.Context, from, txn string, gen time.Time) bool { |
| +// drainSeen answers an ask: whether the fold holds the asker's publication |
| +// ask names and that publication satisfies the phase, its drained effects |
| +// complete. The fold is read again unless it already holds that |
| +// publication; a failed read, or a fold still holding another one, answers |
| +// false and remembers nothing. |
| +func (m *homeMap) drainSeen(ctx context.Context, ask haDrainAsk) bool { |
| a := &m.drainAcks |
| a.mu.Lock() |
| defer a.mu.Unlock() |
| - key := txn + "\x00" + from + "\x00" + gen.UTC().Format(time.RFC3339) |
| + key := fmt.Sprintf("%s\x00%s\x00%s\x00%d", ask.Txn, ask.From, ask.Phase, ask.ID) |
| if seen, ok := a.seen[key]; ok { |
| return seen |
| } |
| - seen, settled := m.foldedDrain(from, gen) |
| + seen, settled := m.foldedDrain(ask) |
| if !settled { |
| if err := m.refreshHostsNow(ctx); err != nil { |
| return false |
| } |
| - if seen, settled = m.foldedDrain(from, gen); !settled { |
| + if seen, settled = m.foldedDrain(ask); !settled { |
| return false |
| } |
| } |
| @@ -266,32 +281,36 @@ func (m *homeMap) drainSeen(ctx context.Context, from, txn string, gen time.Time |
| return seen |
| } |
| -// foldedDrain reads from's file in the current fold. settled is true when |
| -// the fold answers for gen: a later generation (draining or not), or gen |
| -// itself already draining. A file at gen that is not draining may be an |
| -// earlier publication in the same second (generations are whole seconds), |
| -// so it is not settled and is read again. |
| -func (m *homeMap) foldedDrain(from string, gen time.Time) (seen, settled bool) { |
| - f, ok := m.snapshot().files[edgesPrefix+from+".json"] |
| - if !ok || f.Box != from { |
| +// foldedDrain reads the asker's file in the current fold. settled is true |
| +// only when the fold holds exactly the publication ask names (transaction |
| +// and ID) and, for drained, the fold's drained effects for it have |
| +// completed (notePeerDrained). seen is then whether that publication |
| +// satisfies the phase. |
| +func (m *homeMap) foldedDrain(ask haDrainAsk) (seen, settled bool) { |
| + f, ok := m.snapshot().files[edgesPrefix+ask.From+".json"] |
| + if !ok || f.Box != ask.From { |
| return false, false |
| } |
| - var text string |
| - if !placementField(f.Generation, &text) { |
| + mark, ok := f.drainMark() |
| + if !ok || mark.Txn != ask.Txn || mark.ID != ask.ID { |
| return false, false |
| } |
| - at, err := time.Parse(time.RFC3339, text) |
| - if err != nil { |
| - return false, false |
| + if ask.Phase == DrainPhaseDraining { |
| + return f.drainState(), true |
| } |
| - draining := f.drainState() |
| - switch { |
| - case at.After(gen): |
| - return draining, true |
| - case at.Equal(gen) && draining: |
| - return true, true |
| + if !f.drainedState() { |
| + return false, true |
| } |
| - return false, false |
| + return true, m.drainedDone(ask.From) == mark.ID |
| +} |
| + |
| +// drainMark is f's ha_drain object, when it has a valid one. |
| +func (f edgesFileView) drainMark() (haDrainMarkView, bool) { |
| + var mark haDrainMarkView |
| + if len(f.HADrain) == 0 || !placementField(f.HADrain, &mark) || mark.Txn == "" || mark.ID == 0 { |
| + return haDrainMarkView{}, false |
| + } |
| + return mark, true |
| } |
| // drainState is whether f says its box is in the drain state: draining, or |
| @@ -322,26 +341,45 @@ func (m *homeMap) refreshHostsNow(ctx context.Context) error { |
| return nil |
| } |
| -// notePeerDrained runs the drained hook for each box whose file in files |
| -// says ha_drained, once per generation of that file. Caller holds |
| -// refreshMu. |
| +// notePeerDrained runs the drained effects for each box whose file in |
| +// files says ha_drained, once per publication (ha_drain ID, else the |
| +// generation), and records each as completed only after its effects ran. |
| +// Caller holds refreshMu. |
| func (m *homeMap) notePeerDrained(files map[string]edgesFileView) { |
| - if m.peerDrained == nil { |
| - return |
| - } |
| - now := make(map[string]string) |
| + now := make(map[string]uint64) |
| for _, f := range files { |
| if f.Box == "" || f.Box == m.self || !f.drainedState() { |
| continue |
| } |
| - now[f.Box] = string(f.Generation) |
| - } |
| - for box, gen := range now { |
| - if m.drainedNoted[box] != gen { |
| - m.peerDrained(box) |
| + mark, _ := f.drainMark() |
| + now[f.Box] = mark.ID |
| + } |
| + m.drainedMu.Lock() |
| + prev := m.drainedNoted |
| + m.drainedMu.Unlock() |
| + done := make(map[string]uint64, len(now)) |
| + for box, id := range now { |
| + if old, ok := prev[box]; !ok || old != id { |
| + if m.peerDrained != nil { |
| + m.peerDrained(box) |
| + } |
| } |
| + done[box] = id |
| } |
| - m.drainedNoted = now |
| + m.drainedMu.Lock() |
| + m.drainedNoted = done |
| + m.drainedMu.Unlock() |
| +} |
| + |
| +// drainedDone is the publication ID of box's drained file whose effects |
| +// last completed here, 0 for none. |
| +func (m *homeMap) drainedDone(box string) uint64 { |
| + m.drainedMu.Lock() |
| + defer m.drainedMu.Unlock() |
| + if id, ok := m.drainedNoted[box]; ok && id != 0 { |
| + return id |
| + } |
| + return 0 |
| } |
| // PeerDraining is whether this edge's fold shows ref's edges file in the |
| @@ -355,10 +393,10 @@ func (e *Edge) PeerDraining(ref string) bool { |
| return ok && f.Box == ref && f.drainState() |
| } |
| -// SetPeerDrainedHook sets what runs when this edge's fold first sees a |
| +// SetPeerDrainedHook sets what else runs when this edge's fold first sees a |
| // peer's file say drained (§25.4 step 4): the activator's holder-cache |
| -// drop. It runs inside the fold, before an ask that caused the fold is |
| -// answered. |
| +// drop. The edge's own backhaul holder entries are dropped first, wired or |
| +// not. Both run inside the fold, and a drained ack waits for them. |
| func (e *Edge) SetPeerDrainedHook(fn func(ref string)) { |
| if fn == nil { |
| e.peerDrained.Store(nil) |
| @@ -368,16 +406,20 @@ func (e *Edge) SetPeerDrainedHook(fn func(ref string)) { |
| } |
| func (e *Edge) runPeerDrained(ref string) { |
| + if n := e.backhaulHolders.dropRef(ref); n > 0 { |
| + e.logThrottled("backhaul-holder-drained "+ref, fmt.Sprintf("backhaul holder: dropped %d entries naming %s: it published drained", n, ref)) |
| + } |
| if fn := e.peerDrained.Load(); fn != nil { |
| (*fn)(ref) |
| } |
| } |
| -// AskDrainSeen asks peer whether it sees this box draining at generation, |
| -// for drain transaction txn. seen is the peer's answer; err is a request |
| -// that got no answer (no key, no file for the peer, a dial or a refusal). |
| -// A drain driver asks again on its own cadence. |
| -func (e *Edge) AskDrainSeen(ctx context.Context, peer, txn, generation string) (bool, error) { |
| +// AskDrainSeen asks peer whether it sees this box's drain publication id of |
| +// transaction txn, in phase (DrainPhaseDraining or DrainPhaseDrained). seen |
| +// is the peer's answer; err is a request that got no answer (no key, no |
| +// file for the peer, no verified name to address it by, a dial or a |
| +// refusal). A drain driver asks again on its own cadence. |
| +func (e *Edge) AskDrainSeen(ctx context.Context, peer, txn, phase string, id uint64) (bool, error) { |
| m := e.homes.Load() |
| if m == nil || e.box == "" { |
| return false, errors.New("ha-drain: this edge has no home map or box name") |
| @@ -385,19 +427,19 @@ func (e *Edge) AskDrainSeen(ctx context.Context, peer, txn, generation string) ( |
| if !haControlField(txn) || !haControlField(peer) || peer == e.box { |
| return false, fmt.Errorf("ha-drain: bad transaction %q or peer %q", txn, peer) |
| } |
| - if _, err := time.Parse(time.RFC3339, generation); err != nil { |
| - return false, fmt.Errorf("ha-drain: generation %q: %w", generation, err) |
| + if id == 0 || (phase != DrainPhaseDraining && phase != DrainPhaseDrained) { |
| + return false, fmt.Errorf("ha-drain: bad phase %q or publication %d", phase, id) |
| } |
| current, next := m.meshKeys() |
| key := signingKey(current, next) |
| if len(key) == 0 { |
| return false, errors.New("ha-drain: no mesh key to sign with") |
| } |
| - dial, host, err := m.controlTarget(peer) |
| + dial, host, err := m.controlTarget(peer, e.certs.Load()) |
| if err != nil { |
| return false, err |
| } |
| - body, err := json.Marshal(haDrainAsk{From: e.box, Txn: txn, Generation: generation}) |
| + body, err := json.Marshal(haDrainAsk{From: e.box, Txn: txn, Phase: phase, ID: id}) |
| if err != nil { |
| return false, err |
| } |
| @@ -431,11 +473,16 @@ func (e *Edge) AskDrainSeen(ctx context.Context, peer, txn, generation string) ( |
| } |
| // controlTarget is where a control request to peer goes: its dial address, |
| -// by the same rule a hop uses, and a host to ask for. The host is the |
| -// lowest non-wildcard name peer publishes, else the lowest this box |
| -// publishes: every edge serves every mirrored certificate (certsync.go), and |
| -// a group member may publish no hosts (§24.1). |
| -func (m *homeMap) controlTarget(peer string) (dial, host string, err error) { |
| +// by the same rule a hop uses, and a name to ask for. Every edge serves |
| +// every mirrored certificate (certsync.go), and a group member may publish |
| +// no hosts (§24.1), so the name comes from this box's certificate mirror, |
| +// not from either box's host map: the lowest of peer's own published names |
| +// the mirror holds a usable certificate for, else the lowest exact name the |
| +// mirror holds one for. A host a stale file still lists without a |
| +// certificate is never chosen. TLS verification of that name is the |
| +// transport's as for any hop, and the request's own MAC binds the |
| +// receiving box. |
| +func (m *homeMap) controlTarget(peer string, certs *certMirror) (dial, host string, err error) { |
| snap := m.snapshot() |
| f, ok := snap.files[edgesPrefix+peer+".json"] |
| if !ok || f.Box != peer { |
| @@ -447,11 +494,35 @@ func (m *homeMap) controlTarget(peer string) (dial, host string, err error) { |
| if dial = reader.Dial(f.dialPoint()); dial == "" { |
| return "", "", fmt.Errorf("ha-drain: no dial address for %s", peer) |
| } |
| - if host = burstNoticeHost(f.Hosts); host == "" && ownKnown { |
| - host = burstNoticeHost(own.Hosts) |
| - } |
| - if host == "" { |
| - return "", "", fmt.Errorf("ha-drain: no host to address %s by", peer) |
| + if host = certs.controlName(f.Hosts); host == "" { |
| + return "", "", fmt.Errorf("ha-drain: no mirrored certificate to address %s by", peer) |
| } |
| return dial, host, nil |
| } |
| + |
| +// controlName is a name m holds a usable certificate for: the lowest of |
| +// prefer's exact names that has one, else the lowest exact name it holds. |
| +// "" when m is nil or holds none. |
| +func (m *certMirror) controlName(prefer map[string]edgesHostView) string { |
| + if m == nil { |
| + return "" |
| + } |
| + best := "" |
| + for h := range prefer { |
| + if h != "" && !strings.Contains(h, "*") && (best == "" || h < best) && m.certificate(h, false) != nil { |
| + best = h |
| + } |
| + } |
| + if best != "" { |
| + return best |
| + } |
| + for name, c := range m.snapshot().certs { |
| + if name == "" || strings.Contains(name, "*") || strings.HasSuffix(name, "+rsa") || !usableFor(c, name) { |
| + continue |
| + } |
| + if best == "" || name < best { |
| + best = name |
| + } |
| + } |
| + return best |
| +} |
diff --git a/internal/edge/hadrain_test.go b/internal/edge/hadrain_test.go| index 7afce9d48..ee49d4d4d 100644 |
| --- a/internal/edge/hadrain_test.go |
| +++ b/internal/edge/hadrain_test.go |
| @@ -5,7 +5,6 @@ import ( |
| "context" |
| "encoding/json" |
| "errors" |
| - "fmt" |
| "io" |
| "net/http" |
| "net/http/httptest" |
| @@ -94,6 +93,9 @@ func (x *drainBox) appSaw() []string { |
| type drainScene struct { |
| *noticeScene |
| boxes []*drainBox |
| + // view makes every file a holder-view peer: one data bucket and key, |
| + // and a fresh generation. |
| + view bool |
| } |
| func newDrainScene(t *testing.T) *drainScene { |
| @@ -133,17 +135,35 @@ func (s *drainScene) add(t *testing.T, box, ip, host, region string) *drainBox { |
| return x |
| } |
| -// file writes x's edges file at gen with the given drain state. |
| -func (s *drainScene) file(t *testing.T, x *drainBox, gen time.Time, draining, drained bool) { |
| +// drainPub is one drain-state publication of a box's file: its state and |
| +// its ha_drain identity (0: no drain object). |
| +type drainPub struct { |
| + draining, drained bool |
| + id uint64 |
| +} |
| + |
| +// file writes x's edges file at gen with publication p, in transaction |
| +// txn-1. |
| +func (s *drainScene) file(t *testing.T, x *drainBox, gen time.Time, p drainPub) { |
| t.Helper() |
| - f := map[string]any{"v": 1, "box": x.box, "eip": x.ip, "region": x.region, "generation": gen.UTC().Format(time.RFC3339), |
| - "hosts": map[string]any{x.host: map[string]any{"role": "home"}}} |
| - if draining { |
| + s.fileHosts(t, x, gen, p, map[string]any{x.host: map[string]any{"role": "home"}}) |
| +} |
| + |
| +func (s *drainScene) fileHosts(t *testing.T, x *drainBox, gen time.Time, p drainPub, hosts map[string]any) { |
| + t.Helper() |
| + f := map[string]any{"v": 1, "box": x.box, "eip": x.ip, "region": x.region, "generation": gen.UTC().Format(time.RFC3339), "hosts": hosts} |
| + if s.view { |
| + f["data_bucket"], f["secrets_key_fp"], f["generation"] = "data", "fp", time.Now().UTC().Format(time.RFC3339) |
| + } |
| + if p.draining { |
| f["draining"] = true |
| } |
| - if drained { |
| + if p.drained { |
| f["ha_drained"] = true |
| } |
| + if p.id != 0 { |
| + f["ha_drain"] = map[string]any{"txn": "txn-1", "id": p.id} |
| + } |
| b, err := json.Marshal(f) |
| if err != nil { |
| t.Fatal(err) |
| @@ -163,15 +183,24 @@ func (s *drainScene) sync(t *testing.T) { |
| s.key, _ = s.boxes[0].be.homes.meshKeys() |
| } |
| -var drainGen0 = time.Date(2026, 11, 8, 12, 0, 0, 0, time.UTC) |
| - |
| -func genText(t time.Time) string { return t.UTC().Format(time.RFC3339) } |
| +var ( |
| + drainGen0 = time.Date(2026, 11, 8, 12, 0, 0, 0, time.UTC) |
| + notDrain = drainPub{} |
| + draining1 = drainPub{draining: true, id: 101} |
| + drained2 = drainPub{draining: true, drained: true, id: 102} |
| + askDrain1 = func(x *drainBox, peer string) (bool, error) { |
| + return x.edge().AskDrainSeen(context.Background(), peer, "txn-1", DrainPhaseDraining, 101) |
| + } |
| + askDrained = func(x *drainBox, peer string) (bool, error) { |
| + return x.edge().AskDrainSeen(context.Background(), peer, "txn-1", DrainPhaseDrained, 102) |
| + } |
| +) |
| -// A receiver refreshes its fold of the asker's file once for a generation |
| -// it has not folded, answers what it sees, and answers every later ask for |
| -// that generation from memory (R3.9). Fixed and cross-region receivers |
| -// answer alike: the fold is member-blind. |
| -func TestHADrainAckOneFoldReadPerGeneration(t *testing.T) { |
| +// A receiver refreshes its fold once for a publication it has not folded, |
| +// answers what it sees, and answers every later ask for that publication |
| +// from memory (R3.9). Fixed and cross-region receivers answer alike: the |
| +// fold is member-blind. |
| +func TestHADrainAckOneFoldReadPerPublication(t *testing.T) { |
| for _, tc := range []struct{ name, receiver, region string }{ |
| {"fixed same region", "betty", "eu-west-1"}, |
| {"member", "g-0123456789abcdef0123", "eu-west-1"}, |
| @@ -181,17 +210,12 @@ func TestHADrainAckOneFoldReadPerGeneration(t *testing.T) { |
| s := newDrainScene(t) |
| a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "eu-west-1") |
| b := s.add(t, tc.receiver, "127.0.0.12", "blog.example.com", tc.region) |
| - s.file(t, a, drainGen0, false, false) |
| - s.file(t, b, drainGen0, false, false) |
| + s.file(t, a, drainGen0, notDrain) |
| + s.file(t, b, drainGen0, notDrain) |
| s.sync(t) |
| - ctx := context.Background() |
| - |
| - // annie publishes the drain state; betty has not folded it. |
| - gen1 := drainGen0.Add(time.Minute) |
| - s.file(t, a, gen1, true, false) |
| + s.file(t, a, drainGen0.Add(time.Minute), draining1) |
| l0, g0 := b.store.reads() |
| - seen, err := a.edge().AskDrainSeen(ctx, b.box, "txn-1", genText(gen1)) |
| - if err != nil || !seen { |
| + if seen, err := askDrain1(a, b.box); err != nil || !seen { |
| t.Fatalf("first ask: seen=%v err=%v, want seen", seen, err) |
| } |
| l1, g1 := b.store.reads() |
| @@ -202,22 +226,23 @@ func TestHADrainAckOneFoldReadPerGeneration(t *testing.T) { |
| t.Fatal("the receiver's fold does not show annie draining after the ack") |
| } |
| for range 5 { |
| - if seen, err := a.edge().AskDrainSeen(ctx, b.box, "txn-1", genText(gen1)); err != nil || !seen { |
| + if seen, err := askDrain1(a, b.box); err != nil || !seen { |
| t.Fatalf("repeat ask: seen=%v err=%v", seen, err) |
| } |
| } |
| if l, g := b.store.reads(); l != l1 || g != g1 { |
| t.Fatalf("repeat asks read the store: %d lists, %d gets more", l-l1, g-g1) |
| } |
| - |
| - // drained: a new generation, one more fold read, then memory. |
| - gen2 := gen1.Add(time.Minute) |
| - s.file(t, a, gen2, true, true) |
| - if seen, err := a.edge().AskDrainSeen(ctx, b.box, "txn-1", genText(gen2)); err != nil || !seen { |
| - t.Fatalf("drained ask: seen=%v err=%v", seen, err) |
| + // Asking drained of a draining publication is not seen. |
| + if seen, err := a.edge().AskDrainSeen(context.Background(), b.box, "txn-1", DrainPhaseDrained, 101); err != nil || seen { |
| + t.Fatalf("drained of a draining publication: seen=%v err=%v", seen, err) |
| } |
| - if seen, err := a.edge().AskDrainSeen(ctx, b.box, "txn-1", genText(gen2)); err != nil || !seen { |
| - t.Fatalf("drained repeat: seen=%v err=%v", seen, err) |
| + s.file(t, a, drainGen0.Add(2*time.Minute), drained2) |
| + l1, g1 = b.store.reads() |
| + for range 2 { |
| + if seen, err := askDrained(a, b.box); err != nil || !seen { |
| + t.Fatalf("drained ask: seen=%v err=%v", seen, err) |
| + } |
| } |
| if l, g := b.store.reads(); l-l1 != 1 || g-g1 != 2 { |
| t.Fatalf("drained round cost %d lists and %d gets, want one fold read", l-l1, g-g1) |
| @@ -226,72 +251,204 @@ func TestHADrainAckOneFoldReadPerGeneration(t *testing.T) { |
| } |
| } |
| +// P1 (finding 1): draining and drained published in the same second. The |
| +// drained ask names its own publication, so the remembered draining answer |
| +// cannot stand in: the receiver reads again, drops its holders, and only |
| +// then acknowledges. |
| +func TestHADrainSameSecondDrainedIsReadAndEvicted(t *testing.T) { |
| + s := newDrainScene(t) |
| + a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "eu-west-1") |
| + b := s.add(t, "betty", "127.0.0.12", "blog.example.com", "eu-west-1") |
| + var drops atomic.Int32 |
| + b.edge().SetPeerDrainedHook(func(string) { drops.Add(1) }) |
| + s.file(t, a, drainGen0, draining1) |
| + s.file(t, b, drainGen0, notDrain) |
| + s.sync(t) |
| + if seen, err := askDrain1(a, "betty"); err != nil || !seen { |
| + t.Fatalf("draining: seen=%v err=%v", seen, err) |
| + } |
| + owner := backhaulOwner{name: a.host, account: "bdk", app: "annie"} |
| + b.edge().backhaulHolders.remember(a.host, "annie", owner, time.Now()) |
| + s.file(t, a, drainGen0, drained2) // the same generation |
| + l0, _ := b.store.reads() |
| + if seen, err := askDrained(a, "betty"); err != nil || !seen { |
| + t.Fatalf("same-second drained: seen=%v err=%v", seen, err) |
| + } |
| + if l, _ := b.store.reads(); l-l0 != 1 { |
| + t.Fatalf("same-second drained read %d times, want 1", l-l0) |
| + } |
| + if drops.Load() != 1 || b.edge().backhaulHolders.get(a.host, owner, time.Now()) != "" { |
| + t.Fatalf("acknowledged drained before evicting: hook %d, backhaul %q", drops.Load(), b.edge().backhaulHolders.get(a.host, owner, time.Now())) |
| + } |
| + // And a draining ask cannot be answered from a drained ask's memory, or |
| + // the reverse, across another transaction's identity. |
| + if seen, err := a.edge().AskDrainSeen(context.Background(), "betty", "txn-2", DrainPhaseDrained, 102); err != nil || seen { |
| + t.Fatalf("another transaction: seen=%v err=%v", seen, err) |
| + } |
| +} |
| + |
| // A refresh that fails answers "not seen", caches nothing, and the next |
| // ask reads again. |
| func TestHADrainAckFailedRefreshNotSeen(t *testing.T) { |
| s := newDrainScene(t) |
| a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "eu-west-1") |
| b := s.add(t, "betty", "127.0.0.12", "blog.example.com", "eu-west-1") |
| - s.file(t, a, drainGen0, false, false) |
| - s.file(t, b, drainGen0, false, false) |
| + s.file(t, a, drainGen0, notDrain) |
| + s.file(t, b, drainGen0, notDrain) |
| s.sync(t) |
| - gen1 := drainGen0.Add(time.Minute) |
| - s.file(t, a, gen1, true, false) |
| + s.file(t, a, drainGen0.Add(time.Minute), draining1) |
| l0, _ := b.store.reads() |
| b.store.setFail(true) |
| - ctx := context.Background() |
| for range 2 { |
| - if seen, err := a.edge().AskDrainSeen(ctx, "betty", "txn-1", genText(gen1)); err != nil || seen { |
| + if seen, err := askDrain1(a, "betty"); err != nil || seen { |
| t.Fatalf("failed refresh: seen=%v err=%v, want an answer of not seen", seen, err) |
| } |
| } |
| if l, _ := b.store.reads(); l-l0 != 2 { |
| - t.Fatalf("a failed refresh was cached: %d lists", l) |
| + t.Fatalf("a failed refresh was cached: %d lists", l-l0) |
| } |
| if b.edge().PeerDraining("annie") { |
| t.Fatal("the fold changed on a failed refresh") |
| } |
| b.store.setFail(false) |
| - if seen, err := a.edge().AskDrainSeen(ctx, "betty", "txn-1", genText(gen1)); err != nil || !seen { |
| + if seen, err := askDrain1(a, "betty"); err != nil || !seen { |
| t.Fatalf("after recovery: seen=%v err=%v", seen, err) |
| } |
| } |
| -// The fold answers what it sees: a generation that is not draining is not |
| -// seen, and a same-second file that is not draining is read again rather |
| -// than remembered. |
| +// The fold answers only for the publication asked about: another |
| +// publication (not yet written, or a cancelled drain) is not seen and not |
| +// remembered. |
| func TestHADrainAckAnswersTheFold(t *testing.T) { |
| s := newDrainScene(t) |
| a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "eu-west-1") |
| b := s.add(t, "betty", "127.0.0.12", "blog.example.com", "eu-west-1") |
| - s.file(t, a, drainGen0, false, false) |
| - s.file(t, b, drainGen0, false, false) |
| + s.file(t, a, drainGen0, notDrain) |
| + s.file(t, b, drainGen0, notDrain) |
| s.sync(t) |
| - ctx := context.Background() |
| - // Same second, not draining yet: not seen, and not remembered. |
| for range 2 { |
| - if seen, err := a.edge().AskDrainSeen(ctx, "betty", "txn-1", genText(drainGen0)); err != nil || seen { |
| - t.Fatalf("not draining: seen=%v err=%v", seen, err) |
| + if seen, err := askDrain1(a, "betty"); err != nil || seen { |
| + t.Fatalf("not published: seen=%v err=%v", seen, err) |
| } |
| } |
| - l, _ := b.store.reads() |
| - s.file(t, a, drainGen0, true, false) |
| - if seen, err := a.edge().AskDrainSeen(ctx, "betty", "txn-1", genText(drainGen0)); err != nil || !seen { |
| - t.Fatalf("same-second drain: seen=%v err=%v", seen, err) |
| - } |
| - if l2, _ := b.store.reads(); l2 != l+1 { |
| - t.Fatalf("same-second drain read %d times, want 1", l2-l) |
| + s.file(t, a, drainGen0, draining1) |
| + if seen, err := askDrain1(a, "betty"); err != nil || !seen { |
| + t.Fatalf("published: seen=%v err=%v", seen, err) |
| } |
| - // A later generation that cleared the drain: not seen. |
| - gen := drainGen0.Add(time.Minute) |
| - s.file(t, a, gen, false, false) |
| - if seen, err := a.edge().AskDrainSeen(ctx, "betty", "txn-2", genText(gen)); err != nil || seen { |
| + s.file(t, a, drainGen0.Add(time.Minute), notDrain) |
| + if seen, err := a.edge().AskDrainSeen(context.Background(), "betty", "txn-1", DrainPhaseDraining, 103); err != nil || seen { |
| t.Fatalf("cancelled drain: seen=%v err=%v", seen, err) |
| } |
| } |
| -// Folding a drained file drops holder-cache entries naming the box, once |
| -// per generation, on the box that folds it. |
| +// P1 (finding 2): an ordinary poll that is still running the drained |
| +// effects holds every ask: none can acknowledge drained until they finish. |
| +func TestHADrainedAckWaitsForEffects(t *testing.T) { |
| + s := newDrainScene(t) |
| + a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "eu-west-1") |
| + b := s.add(t, "betty", "127.0.0.12", "blog.example.com", "eu-west-1") |
| + entered, release := make(chan struct{}), make(chan struct{}) |
| + var once sync.Once |
| + b.edge().SetPeerDrainedHook(func(string) { |
| + once.Do(func() { close(entered) }) |
| + <-release |
| + }) |
| + s.file(t, a, drainGen0, draining1) |
| + s.file(t, b, drainGen0, notDrain) |
| + s.sync(t) |
| + s.file(t, a, drainGen0.Add(time.Minute), drained2) |
| + polled := make(chan error, 1) |
| + go func() { polled <- b.be.homes.Refresh(context.Background()) }() |
| + <-entered |
| + // The new snapshot is published; the effects are not finished. |
| + if !b.edge().PeerDraining("annie") { |
| + t.Fatal("the poll had not published the drained fold") |
| + } |
| + asked := make(chan bool, 1) |
| + go func() { |
| + seen, _ := askDrained(a, "betty") |
| + asked <- seen |
| + }() |
| + select { |
| + case seen := <-asked: |
| + t.Fatalf("acknowledged (%v) while the drained effects were still running", seen) |
| + case <-time.After(300 * time.Millisecond): |
| + } |
| + close(release) |
| + if err := <-polled; err != nil { |
| + t.Fatal(err) |
| + } |
| + select { |
| + case seen := <-asked: |
| + if !seen { |
| + t.Fatal("not seen after the effects completed") |
| + } |
| + case <-time.After(10 * time.Second): |
| + t.Fatal("the ask never answered") |
| + } |
| +} |
| + |
| +// P2 (finding 3): the edge's own backhaul holder entries naming a drained |
| +// box go on a fixed, cross-region receiver with no activator wired, before |
| +// it acknowledges, and its next routing decision does not choose the box. |
| +func TestHADrainedClearsBackhaulHolders(t *testing.T) { |
| + s := newDrainScene(t) |
| + a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "eu-west-1") |
| + c := s.add(t, "carol", "127.0.0.13", "docs.example.com", "eu-west-1") |
| + b := s.add(t, "adi", "127.0.0.12", "blog.example.com", "us-east-1") |
| + s.view = true |
| + s.file(t, a, drainGen0, draining1) |
| + s.file(t, c, drainGen0, notDrain) |
| + s.file(t, b, drainGen0, notDrain) |
| + s.sync(t) |
| + owner := backhaulOwner{name: c.host, account: "bdk", app: "carol"} |
| + other := backhaulOwner{name: "x.example.com", account: "bdk", app: "x"} |
| + b.edge().backhaulHolders.remember(c.host, "annie", owner, time.Now()) |
| + b.edge().backhaulHolders.remember("x.example.com", "carol", other, time.Now()) |
| + if _, box := b.edge().backhaulTarget(c.host, c.ip, "carol", owner); box != "annie" { |
| + t.Fatalf("the learned holder was not used before the drain: %s", box) |
| + } |
| + s.file(t, a, drainGen0.Add(time.Minute), drained2) |
| + if seen, err := askDrained(a, "adi"); err != nil || !seen { |
| + t.Fatalf("drained ask: seen=%v err=%v", seen, err) |
| + } |
| + if dial, box := b.edge().backhaulTarget(c.host, c.ip, "carol", owner); box != "carol" || dial != c.ip { |
| + t.Fatalf("after drained the next routing chose %s (%s), want carol", box, dial) |
| + } |
| + if b.edge().backhaulHolders.get("x.example.com", other, time.Now()) != "carol" { |
| + t.Fatal("an entry naming another box was dropped") |
| + } |
| +} |
| + |
| +// P2 (finding 4): two members that publish no hosts still reach each |
| +// other, by a name the deployment's certificate mirror holds, with TLS |
| +// verified. A stale member's lingering host with no certificate is never |
| +// the name. |
| +func TestHADrainHostlessMembers(t *testing.T) { |
| + s := newDrainScene(t) |
| + a := s.add(t, "g-aaaaaaaaaaaaaaaaaaaa", "127.0.0.11", "shop.example.com", "eu-west-1") |
| + b := s.add(t, "g-bbbbbbbbbbbbbbbbbbbb", "127.0.0.12", "blog.example.com", "eu-west-1") |
| + stale := &drainBox{box: "g-cccccccccccccccccccc", ip: "127.0.0.13", region: "eu-west-1"} |
| + s.fileHosts(t, a, drainGen0, draining1, map[string]any{}) |
| + s.fileHosts(t, b, drainGen0, notDrain, map[string]any{}) |
| + // A terminated member's unchanged file: an old generation and a host |
| + // whose certificate the mirror does not hold (sorts first). |
| + s.fileHosts(t, stale, drainGen0.Add(-time.Hour), notDrain, map[string]any{"aaa-gone.example.com": map[string]any{"role": "home"}}) |
| + s.sync(t) |
| + _, host, err := a.be.homes.controlTarget(b.box, a.edge().certs.Load()) |
| + if err != nil || host != "blog.example.com" { |
| + t.Fatalf("control name %q (%v), want the lowest mirrored name", host, err) |
| + } |
| + if seen, err := askDrain1(a, b.box); err != nil || !seen { |
| + t.Fatalf("hostless members: seen=%v err=%v", seen, err) |
| + } |
| + // With no usable certificate there is no name, and no unverified send. |
| + if _, _, err := a.be.homes.controlTarget(b.box, nil); err == nil { |
| + t.Fatal("a control target without a certificate mirror") |
| + } |
| +} |
| + |
| +// Folding a drained file runs the drained effects once per publication. |
| func TestHADrainedFoldDropsHolders(t *testing.T) { |
| s := newDrainScene(t) |
| a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "eu-west-1") |
| @@ -303,30 +460,25 @@ func TestHADrainedFoldDropsHolders(t *testing.T) { |
| dropped = append(dropped, ref) |
| mu.Unlock() |
| }) |
| - s.file(t, a, drainGen0, true, false) |
| - s.file(t, b, drainGen0, false, false) |
| + s.file(t, a, drainGen0, draining1) |
| + s.file(t, b, drainGen0, notDrain) |
| s.sync(t) |
| refreshHomeMap(t, b.be.homes) |
| if len(dropped) != 0 { |
| t.Fatalf("draining alone dropped %v", dropped) |
| } |
| - gen := drainGen0.Add(time.Minute) |
| - s.file(t, a, gen, true, true) |
| - if seen, err := a.edge().AskDrainSeen(context.Background(), "betty", "txn-1", genText(gen)); err != nil || !seen { |
| + s.file(t, a, drainGen0.Add(time.Minute), drained2) |
| + if seen, err := askDrained(a, "betty"); err != nil || !seen { |
| t.Fatalf("drained ask: seen=%v err=%v", seen, err) |
| } |
| - mu.Lock() |
| - got := append([]string(nil), dropped...) |
| - mu.Unlock() |
| - if len(got) != 1 || got[0] != "annie" { |
| - t.Fatalf("dropped %v by the ack, want [annie]", got) |
| - } |
| + // A timed rewrite of the same publication runs nothing again. |
| + s.file(t, a, drainGen0.Add(2*time.Minute), drained2) |
| refreshHomeMap(t, b.be.homes) |
| refreshHomeMap(t, b.be.homes) |
| mu.Lock() |
| defer mu.Unlock() |
| - if len(dropped) != 1 { |
| - t.Fatalf("dropped %v, want once per generation", dropped) |
| + if len(dropped) != 1 || dropped[0] != "annie" { |
| + t.Fatalf("dropped %v, want [annie] once per publication", dropped) |
| } |
| if !b.edge().PeerDraining("annie") || b.edge().PeerDraining("betty") || b.edge().PeerDraining("nobody") { |
| t.Fatal("PeerDraining does not follow the fold") |
| @@ -340,11 +492,11 @@ func TestHADrainRefusesForgery(t *testing.T) { |
| s := newDrainScene(t) |
| a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "eu-west-1") |
| b := s.add(t, "betty", "127.0.0.12", "blog.example.com", "eu-west-1") |
| - s.file(t, a, drainGen0, true, false) |
| - s.file(t, b, drainGen0, false, false) |
| + s.file(t, a, drainGen0, draining1) |
| + s.file(t, b, drainGen0, notDrain) |
| s.sync(t) |
| now := time.Now() |
| - body := []byte(fmt.Sprintf(`{"from":"annie","txn":"txn-1","generation":%q}`, genText(drainGen0))) |
| + body := []byte(`{"from":"annie","txn":"txn-1","phase":"draining","id":101}`) |
| good := func() (string, string, []byte) { |
| return signHAControl(s.key, "betty", http.MethodPost, HADrainPath, "txn-1", now, body), "txn-1", body |
| } |
| @@ -398,8 +550,8 @@ func TestHAControlPathsReservedOnEveryIngress(t *testing.T) { |
| s := newDrainScene(t) |
| a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "eu-west-1") |
| b := s.add(t, "betty", "127.0.0.12", "blog.example.com", "eu-west-1") |
| - s.file(t, a, drainGen0, false, false) |
| - s.file(t, b, drainGen0, false, false) |
| + s.file(t, a, drainGen0, notDrain) |
| + s.file(t, b, drainGen0, notDrain) |
| s.sync(t) |
| send := func(x *drainBox, host, path string, hop bool) *httptest.ResponseRecorder { |
| r := httptest.NewRequest(http.MethodPost, "http://"+host+path, strings.NewReader(`{"from":"annie"}`)) |
diff --git a/internal/edge/homemap.go b/internal/edge/homemap.go| index e13ede322..ddc312ff5 100644 |
| --- a/internal/edge/homemap.go |
| +++ b/internal/edge/homemap.go |
| @@ -171,8 +171,11 @@ type edgesFileView struct { |
| // a fold that first sees it drops holder-cache entries naming the box |
| // (hadrain.go). |
| HADrained json.RawMessage `json:"ha_drained"` |
| - Role json.RawMessage `json:"role"` |
| - Headroom json.RawMessage `json:"headroom"` |
| + // HADrain is the drain publication's identity (transaction and ID), |
| + // which an acknowledgement names. |
| + HADrain json.RawMessage `json:"ha_drain"` |
| + Role json.RawMessage `json:"role"` |
| + Headroom json.RawMessage `json:"headroom"` |
| // placementNull is an explicit "placement": null. The holder decoder |
| // reads it as "" as before; cold-wake placement refuses it, because an |
| // omitted or empty placement is the home scope and null is neither. |
| @@ -383,11 +386,13 @@ type homeMap struct { |
| actedOK bool |
| // drainAcks remembers answered drain asks (hadrain.go). peerDrained is |
| - // the edge's drained hook (nil: none), and drainedNoted, guarded by |
| - // refreshMu, the generation of each drained file it last ran for. |
| + // the edge's drained effects (nil: none), and drainedNoted, guarded by |
| + // drainedMu, the publication ID of each drained file whose effects |
| + // completed. |
| drainAcks drainAcks |
| peerDrained func(ref string) |
| - drainedNoted map[string]string |
| + drainedMu sync.Mutex |
| + drainedNoted map[string]uint64 |
| } |
| func newHomeMap(s release.Store, self string) *homeMap { |
diff --git a/internal/host/edgesfile.go b/internal/host/edgesfile.go| index 67e92ec4d..ab50300e7 100644 |
| --- a/internal/host/edgesfile.go |
| +++ b/internal/host/edgesfile.go |
| @@ -395,6 +395,10 @@ type edgesFile struct { |
| // entries naming the box when they fold it, and placement reads it as |
| // local-denied. |
| HADrained bool `json:"ha_drained,omitempty"` |
| + // HADrain names the drain transaction and the identity of this |
| + // drain-state publication (hadrainstate.go), which acknowledgements |
| + // name. Present exactly while Draining. |
| + HADrain *haDrainMark `json:"ha_drain,omitempty"` |
| // Headroom is what placement chooses by (spec 2). It is refreshed when |
| // the file is written for another reason and on the loop's own tick; a |
| // headroom change alone never forces a write (see edgesFileWrite). |
| @@ -1044,7 +1048,7 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re |
| f.RoleSource.EdgesPublished(f.BoxRole, *f.Admitted, *f.Drained) |
| } |
| if f.DrainSource != nil { |
| - f.DrainSource.EdgesDrainPublished(f.Draining, f.HADrained, f.Generation) |
| + f.DrainSource.EdgesDrainPublished(f.Draining, f.HADrained, f.HADrain, f.Generation) |
| } |
| if assets != nil { |
| assets.passDone(clocks, settled, true, f.Hosts) |
| @@ -1318,7 +1322,7 @@ func edgesFileLoop(reg *registry.Registry, lifetimes bool, assets *assetPolicy) |
| eip = readPublicIP() |
| } |
| ident.Capabilities = withDemoMovedCapability(withDBReadCapability(withOfflineCapability(baseCaps, armedOfflineCapable()), dbReadsCapable()), os.Getenv) |
| - ident.Draining, ident.HADrained = boxDrain.want() |
| + ident.Draining, ident.HADrained, ident.HADrain = boxDrain.want() |
| ident.DrainSource, ident.DrainPublishRequired = boxDrain, drainDue |
| dbReadsDraining.Store(ident.Draining) |
| ident.Headroom = headroomFor(headroomCapabilities(ident.Capabilities), dataDir, reg) |
diff --git a/internal/host/hadrainstate.go b/internal/host/hadrainstate.go| index c316cce1b..82a9d26e5 100644 |
| --- a/internal/host/hadrainstate.go |
| +++ b/internal/host/hadrainstate.go |
| @@ -4,6 +4,7 @@ import ( |
| "context" |
| "errors" |
| "sync" |
| + "time" |
| ) |
| // haDrainState is this box's planned-handover drain state (region HA spec |
| @@ -24,20 +25,35 @@ import ( |
| type haDrainState struct { |
| mu sync.Mutex |
| draining, drained bool |
| + mark *haDrainMark |
| + lastID uint64 |
| pub haDrainPublished |
| // changed is closed and replaced at every reported publication. |
| changed chan struct{} |
| } |
| +// haDrainMark is the wire ha_drain object: the drain transaction and the |
| +// identity of this drain-state publication. ID is new at every state |
| +// change (begin, drained) and strictly increasing within the process; it is |
| +// nanoseconds of the wall clock, so a restarted agent never reuses an ID a |
| +// peer may remember. An acknowledgement names the transaction, the phase |
| +// and this ID, so no two transitions can stand in for each other however |
| +// close together they are published (generations are whole seconds). |
| +type haDrainMark struct { |
| + Txn string `json:"txn"` |
| + ID uint64 `json:"id"` |
| +} |
| + |
| // haDrainSource is what edgesFileWriteClaims reports a written file's drain |
| // state to. |
| type haDrainSource interface { |
| - EdgesDrainPublished(draining, drained bool, generation string) |
| + EdgesDrainPublished(draining, drained bool, mark *haDrainMark, generation string) |
| } |
| // haDrainPublished is what the edges loop last wrote. |
| type haDrainPublished struct { |
| Draining, Drained bool |
| + Mark *haDrainMark |
| Generation string |
| } |
| @@ -49,25 +65,46 @@ func newHADrainState() *haDrainState { |
| // (agent.go wires it); the edges loop publishes it. |
| var boxDrain = newHADrainState() |
| -// setDraining sets or clears the drain state. Clearing it clears drained. |
| -// The next edges loop tick publishes the change. |
| -func (s *haDrainState) setDraining(on bool) { |
| +// nextIDLocked is a fresh publication identity. |
| +func (s *haDrainState) nextIDLocked() uint64 { |
| + id := uint64(time.Now().UnixNano()) |
| + if id <= s.lastID { |
| + id = s.lastID + 1 |
| + } |
| + s.lastID = id |
| + return id |
| +} |
| + |
| +// begin enters the drain state for transaction txn. The next edges loop |
| +// tick publishes it. |
| +func (s *haDrainState) begin(txn string) error { |
| + if txn == "" { |
| + return errors.New("ha drain: no transaction") |
| + } |
| s.mu.Lock() |
| defer s.mu.Unlock() |
| - s.draining = on |
| - if !on { |
| - s.drained = false |
| - } |
| + s.draining, s.drained = true, false |
| + s.mark = &haDrainMark{Txn: txn, ID: s.nextIDLocked()} |
| + return nil |
| } |
| -// setDrained sets or clears drained, which needs draining. |
| -func (s *haDrainState) setDrained(on bool) error { |
| +// clear leaves the drain state, drained included. |
| +func (s *haDrainState) clear() { |
| s.mu.Lock() |
| defer s.mu.Unlock() |
| - if on && !s.draining { |
| + s.draining, s.drained, s.mark = false, false, nil |
| +} |
| + |
| +// setDrained publishes drained (§25.4 step 4), which needs draining, under |
| +// a new publication identity. |
| +func (s *haDrainState) setDrained() error { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + if !s.draining || s.mark == nil { |
| return errors.New("ha drain: drained without draining") |
| } |
| - s.drained = on |
| + s.drained = true |
| + s.mark = &haDrainMark{Txn: s.mark.Txn, ID: s.nextIDLocked()} |
| return nil |
| } |
| @@ -80,10 +117,14 @@ func (s *haDrainState) IsDraining() bool { |
| } |
| // want is the state the edges file should carry. |
| -func (s *haDrainState) want() (draining, drained bool) { |
| +func (s *haDrainState) want() (draining, drained bool, mark *haDrainMark) { |
| s.mu.Lock() |
| defer s.mu.Unlock() |
| - return s.draining, s.drained |
| + return s.draining, s.drained, s.mark |
| +} |
| + |
| +func sameMark(a, b *haDrainMark) bool { |
| + return (a == nil) == (b == nil) && (a == nil || *a == *b) |
| } |
| // needsPublish is whether the wanted state has not been reported published: |
| @@ -93,14 +134,19 @@ func (s *haDrainState) want() (draining, drained bool) { |
| func (s *haDrainState) needsPublish() bool { |
| s.mu.Lock() |
| defer s.mu.Unlock() |
| - return s.draining != s.pub.Draining || s.drained != s.pub.Drained || (s.draining && s.pub.Generation == "") |
| + return s.draining != s.pub.Draining || s.drained != s.pub.Drained || !sameMark(s.mark, s.pub.Mark) || (s.draining && s.pub.Generation == "") |
| } |
| // EdgesDrainPublished is the edges loop's report of a written file. |
| -func (s *haDrainState) EdgesDrainPublished(draining, drained bool, generation string) { |
| +func (s *haDrainState) EdgesDrainPublished(draining, drained bool, mark *haDrainMark, generation string) { |
| s.mu.Lock() |
| defer s.mu.Unlock() |
| - s.pub = haDrainPublished{Draining: draining, Drained: drained, Generation: generation} |
| + var m *haDrainMark |
| + if mark != nil { |
| + c := *mark |
| + m = &c |
| + } |
| + s.pub = haDrainPublished{Draining: draining, Drained: drained, Mark: m, Generation: generation} |
| close(s.changed) |
| s.changed = make(chan struct{}) |
| } |
| @@ -112,22 +158,23 @@ func (s *haDrainState) published() haDrainPublished { |
| return s.pub |
| } |
| -// waitPublished waits until the wanted state is published and returns that |
| -// publication's generation, the one a drain acknowledgement names. |
| -func (s *haDrainState) waitPublished(ctx context.Context) (string, error) { |
| +// waitPublished waits until the wanted drain state is published and |
| +// returns its mark: the transaction and publication identity a drain |
| +// acknowledgement names, with the phase. |
| +func (s *haDrainState) waitPublished(ctx context.Context) (haDrainMark, error) { |
| for { |
| s.mu.Lock() |
| - if s.draining == s.pub.Draining && s.drained == s.pub.Drained && s.pub.Generation != "" { |
| - gen := s.pub.Generation |
| + if s.mark != nil && s.draining == s.pub.Draining && s.drained == s.pub.Drained && sameMark(s.mark, s.pub.Mark) && s.pub.Generation != "" { |
| + m := *s.mark |
| s.mu.Unlock() |
| - return gen, nil |
| + return m, nil |
| } |
| ch := s.changed |
| s.mu.Unlock() |
| select { |
| case <-ch: |
| case <-ctx.Done(): |
| - return "", ctx.Err() |
| + return haDrainMark{}, ctx.Err() |
| } |
| } |
| } |
diff --git a/internal/host/hadrainstate_test.go b/internal/host/hadrainstate_test.go| index 9a7250065..b09f09bb2 100644 |
| --- a/internal/host/hadrainstate_test.go |
| +++ b/internal/host/hadrainstate_test.go |
| @@ -17,22 +17,29 @@ func TestHADrainStateTransitions(t *testing.T) { |
| if s.IsDraining() || s.needsPublish() { |
| t.Fatal("a new state drains") |
| } |
| - if err := s.setDrained(true); err == nil { |
| + if err := s.setDrained(); err == nil { |
| t.Fatal("drained without draining") |
| } |
| - s.setDraining(true) |
| + if err := s.begin(""); err == nil { |
| + t.Fatal("a drain without a transaction") |
| + } |
| + if err := s.begin("txn-1"); err != nil { |
| + t.Fatal(err) |
| + } |
| if !s.IsDraining() || !s.needsPublish() { |
| t.Fatal("draining not wanted") |
| } |
| - if err := s.setDrained(true); err != nil { |
| + _, _, m1 := s.want() |
| + if err := s.setDrained(); err != nil { |
| t.Fatal(err) |
| } |
| - if d, dd := s.want(); !d || !dd { |
| - t.Fatalf("want %v %v", d, dd) |
| + d, dd, m2 := s.want() |
| + if !d || !dd || m1 == nil || m2 == nil || m2.Txn != "txn-1" || m2.ID <= m1.ID { |
| + t.Fatalf("want %v %v %+v after %+v: drained needs a new, later identity", d, dd, m2, m1) |
| } |
| - s.setDraining(false) |
| - if d, dd := s.want(); d || dd || s.IsDraining() { |
| - t.Fatalf("cleared state still wants %v %v", d, dd) |
| + s.clear() |
| + if d, dd, m := s.want(); d || dd || m != nil || s.IsDraining() { |
| + t.Fatalf("cleared state still wants %v %v %+v", d, dd, m) |
| } |
| } |
| @@ -49,7 +56,7 @@ func TestHADrainPublishedThroughEdgesFile(t *testing.T) { |
| pass := func(last *[]byte) map[string]json.RawMessage { |
| t.Helper() |
| ident := edgesFile{Box: "box", DrainSource: drain} |
| - ident.Draining, ident.HADrained = drain.want() |
| + ident.Draining, ident.HADrained, ident.HADrain = drain.want() |
| ident.DrainPublishRequired = drain.needsPublish() |
| if err := edgesFilePass(ctx, st, reg, ident, "203.0.113.1", last); err != nil { |
| t.Fatal(err) |
| @@ -72,28 +79,36 @@ func TestHADrainPublishedThroughEdgesFile(t *testing.T) { |
| if _, ok := f["ha_drained"]; ok { |
| t.Fatal("a box not draining published ha_drained") |
| } |
| - drain.setDraining(true) |
| + if _, ok := f["ha_drain"]; ok { |
| + t.Fatal("a box not draining published ha_drain") |
| + } |
| + drain.begin("txn-1") |
| f = pass(&last) |
| p := drain.published() |
| - if string(f["draining"]) != "true" || !p.Draining || p.Drained || p.Generation == "" || `"`+p.Generation+`"` != string(f["generation"]) { |
| - t.Fatalf("draining publication %+v, file %s %s", p, f["draining"], f["generation"]) |
| + _, _, want := drain.want() |
| + var mark haDrainMark |
| + json.Unmarshal(f["ha_drain"], &mark) |
| + if string(f["draining"]) != "true" || !p.Draining || p.Drained || p.Generation == "" || `"`+p.Generation+`"` != string(f["generation"]) || p.Mark == nil || *p.Mark != *want || mark != *want { |
| + t.Fatalf("draining publication %+v, file %s %s %s", p, f["draining"], f["generation"], f["ha_drain"]) |
| } |
| if drain.needsPublish() { |
| t.Fatal("a published state still needs publishing") |
| } |
| - if err := drain.setDrained(true); err != nil { |
| + if err := drain.setDrained(); err != nil { |
| t.Fatal(err) |
| } |
| f = pass(&last) |
| - if p = drain.published(); string(f["ha_drained"]) != "true" || string(f["draining"]) != "true" || !p.Drained { |
| - t.Fatalf("drained publication %+v, file %s", p, f["ha_drained"]) |
| + _, _, want = drain.want() |
| + json.Unmarshal(f["ha_drain"], &mark) |
| + if p = drain.published(); string(f["ha_drained"]) != "true" || string(f["draining"]) != "true" || !p.Drained || mark != *want { |
| + t.Fatalf("drained publication %+v, file %s %s", p, f["ha_drained"], f["ha_drain"]) |
| } |
| // A restarted publisher whose gate is seeded from a file that already |
| // says draining still reports, so a driver waiting on it is answered. |
| seeded := seedEdgesFileGate(ctx, st, "box") |
| fresh := newHADrainState() |
| - fresh.setDraining(true) |
| - if err := fresh.setDrained(true); err != nil { |
| + fresh.begin("txn-1") |
| + if err := fresh.setDrained(); err != nil { |
| t.Fatal(err) |
| } |
| drain = fresh |
| @@ -107,26 +122,30 @@ func TestHADrainPublishedThroughEdgesFile(t *testing.T) { |
| // and gives up with its context. |
| func TestHADrainWaitPublished(t *testing.T) { |
| s := newHADrainState() |
| - s.setDraining(true) |
| + s.begin("txn-1") |
| + _, _, want := s.want() |
| ctx, cancel := context.WithTimeout(context.Background(), 20*time.Millisecond) |
| defer cancel() |
| if _, err := s.waitPublished(ctx); !errors.Is(err, context.DeadlineExceeded) { |
| t.Fatalf("unpublished wait: %v", err) |
| } |
| - done := make(chan string, 1) |
| + done := make(chan haDrainMark, 1) |
| go func() { |
| - gen, err := s.waitPublished(context.Background()) |
| + m, err := s.waitPublished(context.Background()) |
| if err != nil { |
| t.Error(err) |
| } |
| - done <- gen |
| + done <- m |
| }() |
| time.Sleep(10 * time.Millisecond) |
| - s.EdgesDrainPublished(true, false, "2026-11-08T12:00:00Z") |
| + // Another publication's identity does not answer the wait. |
| + s.EdgesDrainPublished(true, false, &haDrainMark{Txn: "txn-1", ID: want.ID - 1}, "2026-11-08T12:00:00Z") |
| + time.Sleep(10 * time.Millisecond) |
| + s.EdgesDrainPublished(true, false, want, "2026-11-08T12:00:00Z") |
| select { |
| - case gen := <-done: |
| - if gen != "2026-11-08T12:00:00Z" { |
| - t.Fatalf("generation %q", gen) |
| + case m := <-done: |
| + if m != *want { |
| + t.Fatalf("mark %+v, want %+v", m, *want) |
| } |
| case <-time.After(5 * time.Second): |
| t.Fatal("waitPublished did not return") |
| @@ -143,13 +162,14 @@ func TestHADrainForcesAPass(t *testing.T) { |
| if state.dueWithRole(clock, "fp", true, drain.needsPublish(), edgesFile{}) { |
| t.Fatal("due with nothing to publish") |
| } |
| - drain.setDraining(true) |
| + drain.begin("txn-1") |
| + _, _, mark := drain.want() |
| clock = clock.Add(2 * time.Second) |
| if !state.dueWithRole(clock, "fp", true, drain.needsPublish(), edgesFile{}) { |
| t.Fatal("a wanted drain state did not make the tick a pass") |
| } |
| state.done(clock, true) |
| - drain.EdgesDrainPublished(true, false, "2026-11-08T09:00:04Z") |
| + drain.EdgesDrainPublished(true, false, mark, "2026-11-08T09:00:04Z") |
| clock = clock.Add(2 * time.Second) |
| if state.dueWithRole(clock, "fp", true, drain.needsPublish(), edgesFile{}) { |
| t.Fatal("due after the state was published") |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 322e6eb8b..217e3b7b0 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -130,4 +130,4 @@ plan14-root-reads-instance-syscall-filter.tsv b970bb28c5a633d2572a1da549030e9258 |
| plan14-root-reads-instance-restore-658-cli.tsv b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c |
| plan14-root-reads-instance-stop-execstop-528.tsv 75fb3eb24d0bf3a8405b929675d919ec88f15386d43e9ff687ce138a7ed968a4 |
| plan14-root-reads-region-ha-shutting-down-retry.tsv 75fb3eb24d0bf3a8405b929675d919ec88f15386d43e9ff687ce138a7ed968a4 |
| -plan14-root-reads-region-ha-held-build.tsv 7c62551ef707837ca9dda6f91972f94a70a3285fd6fb3468bead605443ca6c64 |
| +plan14-root-reads-region-ha-held-build.tsv 5b22c20fe7ee69dad47d8113d934152f649f5f2444260f816d367fbcbdc9e56f |
diff --git a/internal/provision/testdata/plan14-root-reads-region-ha-held-build.tsv b/internal/provision/testdata/plan14-root-reads-region-ha-held-build.tsv| index d0b5fefbd..ff65778fc 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-region-ha-held-build.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-region-ha-held-build.tsv |
| @@ -5,15 +5,15 @@ |
| @legacy 6a044da8b179661c9a4889dcbac79d34c21e0b2c0b9021f9c717526d04b366f1 internal/activator/haforward.go Service.NoteForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-g2-fixes;basis=Ignore canceled forwards; classify connected-holder silence for bounded revalidation and refuse stale local-entry shortcuts by pool; reads cached route under the existing locks, no external read.;rev3=census-ruling-region-ha-held-build;basis=returns early, changing nothing, for a ForwardSilent outcome from a peer the edge fold shows draining (spec 25.5 Silence); all other outcomes unchanged; no read added whole:Route@1242,whole:Route@1253,whole:Route@1325 6063c04005c985b5976f9da2de4efb7fb5fbb1a82f1c5cbc189e451b1003a1bc |
| @legacy ed7e6b37c5c678bcb10532daee5ceaeabb08a6e9c81641b2f46d42195a4ed35a internal/activator/haforward.go Service.decideForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new: the second half of the old ForwardTarget body, moved unchanged: turns a holder resolution into the edge's ForwardDecision (the HA view and host reads it already made). Moved, not widened; no new read.;rev3=census-ruling-region-ha-g2-fixes;basis=Pass local eligibility into both placement decisions; supplied route only, no new external read.;rev3=census-ruling-region-ha-held-build;basis=the wake snapshot is LocalDenied also when IsDraining(); only narrows local placement; no read added registry:Host@1248,registry:Host@1396,registry:Host@1569,registry:Host@1860,registry:Host@1983,whole:Route@1038,whole:Route@1787,whole:Route@1825,whole:Route@990 915a0efc9f5ea2acaa0ef983cceb6dc741763054f707c3a6da3328b3eade8d8e |
| @legacy b93df02666fb95c399a2f79fa221a46b014f06c9485fd766dea1aeb08a063cbc internal/edge/edge.go Edge.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.;rev3=census-ruling-plans-4d-lapse;basis=calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here.;rev3=census-ruling-edge-protection-2;basis=runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read;rev3=census-ruling-edge-asset-cache-3;basis=the asset cache's three hooks (asset cache plan 3): the request's reserved asset headers are deleted at entry (the fill assertion kept only beside a verified hop); on the exact-remote and lookup-miss branches the far catch (serveAssetFar) is tried before backhaulTo and backhaul; after the observer defer and main's hard and probe checks, a verified hop with a valid fill assertion is answered by serveAssetFillForHop; after the upgrade branch and before gzip and the shared cache, the local catch (serveAssetLocal); the observer defer skips only the usage meter for an acknowledged home fill (out.unbilled); the new reads live in the new units of the edge-asset-cache-3-decisions overlay; the same route row and read sites (25); no read added;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: straight after lookupUpstreamPath it calls regionalGate (regional.go), which for an entry built from a regional_domains row answers 503 to a hop or a deny entry before any arm that can leave the box (the exact-home backhaul, the far asset catch, the door dial, the miss backhaul), and lets a star match through only to the exact-home arm when ExactHome names another box for that distinct exact name; after the exact-home arm a regional deny entry the arm did not answer is refused (regionalRefuse, 503); refusals only, on the route map the edge already holds; read sites unchanged (25);rev3=census-ruling-static-headers;basis=the shared response cache is no longer looked up or filled for a static-kind route: one more read of the route row the edge already resolved (up.route.Kind == "static") in the cacheable expression; a refusal only, nothing new opened or followed;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2 (N-HA10): one call, frontForwardHA, right after the route lookup's !ok block and before the login POST; same reads;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 4: loginPost and cacheable treat a forward row as not this box's to answer (IsForward(), +whole:Route x2): no login form and no shared cache for a forward host. Serving only.;rev3=census-ruling-tunnel-websockets;basis=Deletes the Carlos-Upgrade marker header from incoming requests and puts the upgrade admission (host, path, the entry tenancy, all in hand) on a tunnel arm request. For a login POST on an ungated ArmTunnel row it reads the visitor request body (bounded by gate.MaxFormBody, 413 past it; a request body, not a file) and resolves next against the entry Reload built (Gate, Route); the bytes pass on only when loginPassesThrough holds (spec 7, Tasks 3, 5 and 6).;rev3=census-ruling-console-protection-tab;basis=one more call in the observer defer, observeGuardCount(up.route, out), beside the observeRecords call that files the guard Match: it passes on the route row the defer already holds (+whole:Route) and the request outcome to the usage meter, which counts the check in memory. Called whether or not the request was unbilled, as observeRecords is. Nothing is opened, read or followed; no new kind of read; no check, refusal or serving decision changes.;rev3=census-ruling-probe-burst-limit;basis=answers a probe-burst notice POST (serveBurstNotice) ahead of every route for a non-door caller; builds the guard state for up.route and stamps its account and app (RouteAccount, App) for the cool-down's this-app/other-app label; for a catalogue match on a non-static or tunnelled route, offers the burst rule (in-memory limiter, burstDecide: 429 or a watch verdict, never a block for a fleet or forward row); the observer defer calls noteBurst(up.route, ...); the added sites are the route value already in hand (+registry:App, +whole:Route x5); no new root read or write kind;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): parses the request's query once (stripHoldMarker) to record the carlos_hold=1 mark in the request context; calls classifyHold on the upstream already resolved from the loaded map (the +whole:Route is that in-memory Route), including a second pass for a login POST; gives a marked request on a door-refused route the plain 404; adds the hold branch (planThrottleAdmit, rateAdmit, serveHeld) after the gate; and excludes marked requests from the shared cache. Reads only the request and the already-loaded upstream map; no registry or bucket read added.;rev3=census-ruling-region-ha-p3a;basis=Complete the P3a cut: an exact peer name with no dial target answers the approved admission 503 before local wildcard dispatch or asset serving. ExactHome and lookupHome stop fallback at a present non-dial entry; backhaulTo refuses an empty target before signing or dialing. Retain Task 3 local admission and fixed platform/unit exemptions. Two added whole Route uses feed the local in-memory admission predicate; existing Route values and store/path reads are unchanged.;rev3=census-ruling-stateless-coordinator-route;basis=P24/P25: POST only, exact /api/fleet/replicas/ prefix on the reserved tunnel host calls the existing local console proxy only for an unescaped, already-clean path; malformed forms remain on the hub. No new read sites relative to origin/main. Merge with main 3487d6f6 retains its region HA admission checks before routing and after login target lookup, its empty-home refusal, and their two existing whole:Route reads; these change this unit's digest relative to the previously approved branch tip 92b24a7d.;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: pass the already-resolved Route to the reserved replica-probe handler after acceptHop and existing admissionRefuses, requiring tunnel context plus private marker and refusing door/backhaul ingress. Added whole Route use only; scrub marker before forwarding; HA calls remain unchanged.;rev3=census-ruling-region-ha-p3b;basis=Resolve local aliases/catch-alls with cached peer name ownership before serving. Add registry Account/App/ClaimStamp/Host/Incarnation/ServingSeq and six whole Route references for NameClaim; inputs are agent registry rows/edges publications used by unprivileged edge, not root permits. Closed owners retain names and return 503; aware remote owner cannot fall through on missing transport, while legacy hop/door behavior remains. Merge 45cebde4 retains authenticated replica probes after local admission and before ordinary name resolution; probe authentication still requires the tunnel context.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1901 enters the protected demo path before ordinary exits; :2012-2015 rechecks the selected marked Route after lookup. Added whole Route use routes demos through serving checks, counters and policy; no new registry query or file open in this unit.;rev3=census-ruling-demo-api-site-route;basis=Reserve the configured site API namespace after hop verification and control-header scrubbing, before ordinary static, cache, billing and tenant dispatch. Validate hop field shape and delegate only allowlisted operations to the dedicated console path with verified client attribution and console admission. The alias helper enables HTTP/1.1 full duplex so an early console refusal does not wait for upload EOF. Existing 56 read sites unchanged; no new registry, bucket or file read.;rev3=census-ruling-region-ha-g2-fixes;basis=Consult HA ingress after region admission and before miss/alias backhaul; no new direct read; routing-only metadata does not create an upstream.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3/W4: backhaul and door calls pass the owner the door checked into backhaulTo; the §6.5 holder follow (once, GET/HEAD or an unswitched upgrade, no body) and one connect-failure fallback dial only boxes in the holder region's view (same Region/Placement/DataBucket, HomeEligible, fresh) for that owner. Holder name comes only from the TLS-verified signed hop answer; app-set X-Carlos-Holder stays stripped. Routing only; the receiving box still re-checks the lease. No new read site.;rev3=census-ruling-region-ha-held-build;basis=first branch: a request for the reserved control paths /.carlos/ha-drain and /.carlos/ha-take goes to serveHAControl and returns (refused unless a signed ask); no request on those paths reaches a route, a forward or an app; no read added here file:ReadAll@17048,registry:Account@8551,registry:App@23205,registry:App@8575,registry:ClaimStamp@8605,registry:Gate@16022,registry:Gate@27596,registry:Gate@27656,registry:Gate@27714,registry:Host@27699,registry:Host@8782,registry:ImportGate@35099,registry:Incarnation@8640,registry:Kind@22067,registry:Kind@25505,registry:Kind@35041,registry:Kind@35070,registry:ServingSeq@8674,whole:Route@15917,whole:Route@16028,whole:Route@18845,whole:Route@19629,whole:Route@20087,whole:Route@20279,whole:Route@22070,whole:Route@23131,whole:Route@23197,whole:Route@23208,whole:Route@23461,whole:Route@23556,whole:Route@23632,whole:Route@23676,whole:Route@23978,whole:Route@24008,whole:Route@25508,whole:Route@25793,whole:Route@27599,whole:Route@27659,whole:Route@27702,whole:Route@27717,whole:Route@28635,whole:Route@30698,whole:Route@35044,whole:Route@35073,whole:Route@35102,whole:Route@35134,whole:Route@36982,whole:Route@6625,whole:Route@6724,whole:Route@6819,whole:Route@8554,whole:Route@8578,whole:Route@8608,whole:Route@8643,whole:Route@8677,whole:Route@8785 ef0bcdc2a27ff6ed4ae1865618fc10a3cdc86f1edaa9e8a0f9b27105d6cad178 |
| -@legacy b7d45da1904b66c1552148de22d293c3aaeefcb5c90a8c11028fae64400107ed internal/edge/hadrain.go Edge.serveHAControl legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-held-build;basis=new: answers a signed drain ask. Reads the request body (io.ReadAll under MaxBytesReader 4 KiB and a 2 s read deadline), verifies its own mesh-key MAC, and may refresh the edges fold (the existing refreshHosts: LIST plus GET of control/edges/ in the deployment bucket); reads no local file; answers JSON seen true or false, or a bare 404 file:ReadAll@674 c4846ae9fc7f4fe0153cb2b937633eb714dc8ffa437e6b81fe9e6704b56df7a1 |
| +@legacy 2a74d8a3671b4a9fb769e3cb121865e6499b01f43a42b67ce4a3b8328b1444b6 internal/edge/hadrain.go Edge.serveHAControl legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-held-build;basis=new: answers a signed drain ask. Reads the request body (io.ReadAll under MaxBytesReader 4 KiB and a 2 s read deadline), verifies its own mesh-key MAC, requires a phase (draining or drained) and a nonzero publication id, and may refresh the edges fold (the existing refreshHosts: LIST plus GET of control/edges/ in the deployment bucket); reads no local file; answers JSON seen true or false, or a bare 404. Fix round 1: the ask names phase and publication id instead of a generation file:ReadAll@674 6f135b934ef3a804ed07bd8567e2ee4dc8db9f8abee97038d3946892ac9c1128 |
| internal/activator/activator.go type Service authority B,C,D,F,J4 rev3=PROPOSED-seed; existing activator lifecycle and due-wake state plus owned seed exclusion and incarnation-keyed diagnostics; normal refusal and preparation ordering remain authoritative; PROPOSED-plans-2-box-limits adds the idleFor hook field, which only narrows idle windows;rev3=census-ruling-plans-4c-box-throttle;basis=gains the maxRunFor hook field beside idleFor (plans 4c). No read added.;rev3=census-ruling-plans-4d-lapse;basis=gains the disabledFor hook field beside maxRunFor (plans 4d). No read added.;rev3=census-ruling-remote-instance-metrics;basis=gains tenancySeq, hostTenants and hostMixed, in-memory fields for Tenancies; no read added;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more field, markers (markerRetry: an atomic running flag and the last log time) for retryOwedMarkers; no read added; merge of origin/main d7ae1d76: main's fields are kept as main has them (census-ruling-remote-instance-metrics: tenancySeq, hostTenants, hostMixed); this branch's change is the same as above;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 7 and 8: new fields for rootfs admission (rootfsArmed, rootfsSwept), the per-host gate ask and refusal memo, and residency state (lister, backoff, start ceiling, cursor, test seam); no read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: one new field, releaseOps (host to the in-memory release record, under a.mu); no read;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W: one new field, leaseNow (a clock seam for a worker start's headroom against the lease deadline, nil is the real clock); no read;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: gains the holder cache and its single-flight state; no read;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): one field, Fleet (activator.FleetWake: the box's fleet state, not on a fleet by default, on a fleet with a known label and a record reader, or on a fleet with an invalid identity), set by the agent before Start and read only by routeCurrentUnderLease. No read in the declaration. Agent, not root.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a fix round 1: one field, drainBudget (time.Duration), which New copies from residentDrainBudget and a rootfs entry's lease watch reads in its place, so a test's change of the package var never races a watch goroutine; declaration only, reads nothing; merge of origin/main 6f1f6ca6: main's one field, Fleet (activator.FleetWake), is kept as main has it (census-ruling-managed-fleets-1b); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b3a;basis=Add bounded placement peer and diagnostic state and the over-capacity callback; no read in this declaration and no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Add coordinator, existing-record observation callback and per-host preparation locks; no read in the declaration. Task 3a: Add optional canonical storage-selection and durable deploy-ID callbacks; declaration only, no read or authority in these fields.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): adds the heldLegs map to actEntry (legs by id, under a.mu) and heldWakeHook (atomic pointer to a callback) and heldLegSeq (atomic counter) to Service. State only, in memory; no read of tenant, app or box-agent-writable input.;rev3=census-ruling-wake-storm-cap;basis=the agent as carlos: one field, wakeSlots (chan struct{}, the wake semaphore made by New from Config.WakeSlots, default 4); declaration only, no read.;rev3=census-ruling-region-ha-p1b3b-t;basis=Add the B2 DutyStore interface field and process-local duty view, suppression and invalidation state. No read added. B2 adds the verified-successor identity callback; no read in the declaration. B3b adds a nonblocking departure-suspicion callback, invoked only after an accepted holder-forward failure and after cache locks release; it cannot authorize a take.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: immutable callbacks installed before Start for tenant admission, local start permission, fixed route exemptions and shutdown closure; nil callbacks preserve switch-off behavior; no new reads. Fix R1: add an immutable startup-phase callback for response copy, set before service startup. No new read or execution authority.;rev3=census-ruling-region-ha-g2-fixes;basis=Add in-memory HA loss state and pool withdrawal jobs; no new read.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 1: one new field, drain (drainSources: two atomic func pointers for this box's and peers' drain state); no read added dae31ac007c1bf0b87c900c317a0c4753c476aab57e279a620f98a1a14301160 |
| internal/activator/haduties.go Service.dutyInput legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=Read HA classification/lifetime from the existing backend and route host, HA, replica, tunnel, import gate and status; read advisory DutyStore state and cached home projection outside a.mu. No new filesystem or bucket path. B2 aliases DutyState to registry.DutyState, exposing existing state-field reads to this census; ownership/restriction decisions are unchanged.;rev3=census-ruling-region-ha-g2-fixes;basis=Apply LocalEligible before legacy/HA duty shortcuts: HA and Provisioned routes require pool membership, operator-placed non-HA routes keep their prior behavior; no new direct I/O.;rev3=census-ruling-region-ha-held-build;basis=LocalDenied also when IsDraining() (this box in the planned-handover drain state); only narrows duty and adoption starts; no read added registry:Basis@1349,registry:HA@326,registry:HolderEpoch@1584,registry:HolderIID@1426,registry:HolderIID@1628,registry:HolderRef@1362,registry:HolderRef@1412,registry:HolderRef@1614,registry:Host@122,registry:Host@1280,registry:Host@592,registry:Host@658,registry:ImportGate@891,registry:NotBefore@1654,registry:NotBefore@1710,registry:Replica@858,registry:Status@915,registry:Status@934,registry:Tunnel@872,registry:ViewKey@1457,whole:DutyState@1327,whole:DutyState@1738,whole:Route@1086,whole:Route@152,whole:Route@231,whole:Route@298,whole:Route@394,whole:Route@686 bd5eb406a50f93e2fe8d5db0044d77a727b0d614dc5186237dd2ac30f192c8c1 |
| internal/activator/haforward.go Service.NoteForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-g2-fixes;basis=Ignore canceled forwards; classify connected-holder silence for bounded revalidation and refuse stale local-entry shortcuts by pool; reads cached route under the existing locks, no external read.;rev3=census-ruling-region-ha-held-build;basis=returns early, changing nothing, for a ForwardSilent outcome from a peer the edge fold shows draining (spec 25.5 Silence); all other outcomes unchanged; no read added whole:Route@1242,whole:Route@1253,whole:Route@1325 6063c04005c985b5976f9da2de4efb7fb5fbb1a82f1c5cbc189e451b1003a1bc |
| internal/activator/haforward.go Service.decideForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new: the second half of the old ForwardTarget body, moved unchanged: turns a holder resolution into the edge's ForwardDecision (the HA view and host reads it already made). Moved, not widened; no new read.;rev3=census-ruling-region-ha-g2-fixes;basis=Pass local eligibility into both placement decisions; supplied route only, no new external read.;rev3=census-ruling-region-ha-held-build;basis=the wake snapshot is LocalDenied also when IsDraining(); only narrows local placement; no read added registry:Host@1248,registry:Host@1396,registry:Host@1569,registry:Host@1860,registry:Host@1983,whole:Route@1038,whole:Route@1787,whole:Route@1825,whole:Route@990 915a0efc9f5ea2acaa0ef983cceb6dc741763054f707c3a6da3328b3eade8d8e |
| internal/edge/edge.go Edge.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.;rev3=census-ruling-plans-4d-lapse;basis=calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here.;rev3=census-ruling-edge-protection-2;basis=runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read;rev3=census-ruling-edge-asset-cache-3;basis=the asset cache's three hooks (asset cache plan 3): the request's reserved asset headers are deleted at entry (the fill assertion kept only beside a verified hop); on the exact-remote and lookup-miss branches the far catch (serveAssetFar) is tried before backhaulTo and backhaul; after the observer defer and main's hard and probe checks, a verified hop with a valid fill assertion is answered by serveAssetFillForHop; after the upgrade branch and before gzip and the shared cache, the local catch (serveAssetLocal); the observer defer skips only the usage meter for an acknowledged home fill (out.unbilled); the new reads live in the new units of the edge-asset-cache-3-decisions overlay; the same route row and read sites (25); no read added;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: straight after lookupUpstreamPath it calls regionalGate (regional.go), which for an entry built from a regional_domains row answers 503 to a hop or a deny entry before any arm that can leave the box (the exact-home backhaul, the far asset catch, the door dial, the miss backhaul), and lets a star match through only to the exact-home arm when ExactHome names another box for that distinct exact name; after the exact-home arm a regional deny entry the arm did not answer is refused (regionalRefuse, 503); refusals only, on the route map the edge already holds; read sites unchanged (25);rev3=census-ruling-static-headers;basis=the shared response cache is no longer looked up or filled for a static-kind route: one more read of the route row the edge already resolved (up.route.Kind == "static") in the cacheable expression; a refusal only, nothing new opened or followed;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2 (N-HA10): one call, frontForwardHA, right after the route lookup's !ok block and before the login POST; same reads;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 4: loginPost and cacheable treat a forward row as not this box's to answer (IsForward(), +whole:Route x2): no login form and no shared cache for a forward host. Serving only.;rev3=census-ruling-tunnel-websockets;basis=Deletes the Carlos-Upgrade marker header from incoming requests and puts the upgrade admission (host, path, the entry tenancy, all in hand) on a tunnel arm request. For a login POST on an ungated ArmTunnel row it reads the visitor request body (bounded by gate.MaxFormBody, 413 past it; a request body, not a file) and resolves next against the entry Reload built (Gate, Route); the bytes pass on only when loginPassesThrough holds (spec 7, Tasks 3, 5 and 6).;rev3=census-ruling-console-protection-tab;basis=one more call in the observer defer, observeGuardCount(up.route, out), beside the observeRecords call that files the guard Match: it passes on the route row the defer already holds (+whole:Route) and the request outcome to the usage meter, which counts the check in memory. Called whether or not the request was unbilled, as observeRecords is. Nothing is opened, read or followed; no new kind of read; no check, refusal or serving decision changes.;rev3=census-ruling-probe-burst-limit;basis=answers a probe-burst notice POST (serveBurstNotice) ahead of every route for a non-door caller; builds the guard state for up.route and stamps its account and app (RouteAccount, App) for the cool-down's this-app/other-app label; for a catalogue match on a non-static or tunnelled route, offers the burst rule (in-memory limiter, burstDecide: 429 or a watch verdict, never a block for a fleet or forward row); the observer defer calls noteBurst(up.route, ...); the added sites are the route value already in hand (+registry:App, +whole:Route x5); no new root read or write kind;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): parses the request's query once (stripHoldMarker) to record the carlos_hold=1 mark in the request context; calls classifyHold on the upstream already resolved from the loaded map (the +whole:Route is that in-memory Route), including a second pass for a login POST; gives a marked request on a door-refused route the plain 404; adds the hold branch (planThrottleAdmit, rateAdmit, serveHeld) after the gate; and excludes marked requests from the shared cache. Reads only the request and the already-loaded upstream map; no registry or bucket read added.;rev3=census-ruling-region-ha-p3a;basis=Complete the P3a cut: an exact peer name with no dial target answers the approved admission 503 before local wildcard dispatch or asset serving. ExactHome and lookupHome stop fallback at a present non-dial entry; backhaulTo refuses an empty target before signing or dialing. Retain Task 3 local admission and fixed platform/unit exemptions. Two added whole Route uses feed the local in-memory admission predicate; existing Route values and store/path reads are unchanged.;rev3=census-ruling-stateless-coordinator-route;basis=P24/P25: POST only, exact /api/fleet/replicas/ prefix on the reserved tunnel host calls the existing local console proxy only for an unescaped, already-clean path; malformed forms remain on the hub. No new read sites relative to origin/main. Merge with main 3487d6f6 retains its region HA admission checks before routing and after login target lookup, its empty-home refusal, and their two existing whole:Route reads; these change this unit's digest relative to the previously approved branch tip 92b24a7d.;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: pass the already-resolved Route to the reserved replica-probe handler after acceptHop and existing admissionRefuses, requiring tunnel context plus private marker and refusing door/backhaul ingress. Added whole Route use only; scrub marker before forwarding; HA calls remain unchanged.;rev3=census-ruling-region-ha-p3b;basis=Resolve local aliases/catch-alls with cached peer name ownership before serving. Add registry Account/App/ClaimStamp/Host/Incarnation/ServingSeq and six whole Route references for NameClaim; inputs are agent registry rows/edges publications used by unprivileged edge, not root permits. Closed owners retain names and return 503; aware remote owner cannot fall through on missing transport, while legacy hop/door behavior remains. Merge 45cebde4 retains authenticated replica probes after local admission and before ordinary name resolution; probe authentication still requires the tunnel context.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1901 enters the protected demo path before ordinary exits; :2012-2015 rechecks the selected marked Route after lookup. Added whole Route use routes demos through serving checks, counters and policy; no new registry query or file open in this unit.;rev3=census-ruling-demo-api-site-route;basis=Reserve the configured site API namespace after hop verification and control-header scrubbing, before ordinary static, cache, billing and tenant dispatch. Validate hop field shape and delegate only allowlisted operations to the dedicated console path with verified client attribution and console admission. The alias helper enables HTTP/1.1 full duplex so an early console refusal does not wait for upload EOF. Existing 56 read sites unchanged; no new registry, bucket or file read.;rev3=census-ruling-region-ha-g2-fixes;basis=Consult HA ingress after region admission and before miss/alias backhaul; no new direct read; routing-only metadata does not create an upstream.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3/W4: backhaul and door calls pass the owner the door checked into backhaulTo; the §6.5 holder follow (once, GET/HEAD or an unswitched upgrade, no body) and one connect-failure fallback dial only boxes in the holder region's view (same Region/Placement/DataBucket, HomeEligible, fresh) for that owner. Holder name comes only from the TLS-verified signed hop answer; app-set X-Carlos-Holder stays stripped. Routing only; the receiving box still re-checks the lease. No new read site.;rev3=census-ruling-region-ha-held-build;basis=first branch: a request for the reserved control paths /.carlos/ha-drain and /.carlos/ha-take goes to serveHAControl and returns (refused unless a signed ask); no request on those paths reaches a route, a forward or an app; no read added here file:ReadAll@17048,registry:Account@8551,registry:App@23205,registry:App@8575,registry:ClaimStamp@8605,registry:Gate@16022,registry:Gate@27596,registry:Gate@27656,registry:Gate@27714,registry:Host@27699,registry:Host@8782,registry:ImportGate@35099,registry:Incarnation@8640,registry:Kind@22067,registry:Kind@25505,registry:Kind@35041,registry:Kind@35070,registry:ServingSeq@8674,whole:Route@15917,whole:Route@16028,whole:Route@18845,whole:Route@19629,whole:Route@20087,whole:Route@20279,whole:Route@22070,whole:Route@23131,whole:Route@23197,whole:Route@23208,whole:Route@23461,whole:Route@23556,whole:Route@23632,whole:Route@23676,whole:Route@23978,whole:Route@24008,whole:Route@25508,whole:Route@25793,whole:Route@27599,whole:Route@27659,whole:Route@27702,whole:Route@27717,whole:Route@28635,whole:Route@30698,whole:Route@35044,whole:Route@35073,whole:Route@35102,whole:Route@35134,whole:Route@36982,whole:Route@6625,whole:Route@6724,whole:Route@6819,whole:Route@8554,whole:Route@8578,whole:Route@8608,whole:Route@8643,whole:Route@8677,whole:Route@8785 ef0bcdc2a27ff6ed4ae1865618fc10a3cdc86f1edaa9e8a0f9b27105d6cad178 |
| internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind;rev3=census-ruling-region-ha-p1b3a;basis=Arm HA placement exactly once on the existing Service before activatorStart and edges publication, wiring AwakeApps and the PageOperator callback; existing six read sites unchanged, no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: start the concrete coordinator's renewal worker with agent setup; existing closeReplicaCoordinator shutdown cancels and joins it before release. No new read sites or credentials. Merge origin/main c59715e7: retain main's armHAPlacement(svc, PageOperator) wiring beside the existing activator setup; stateless coordinator and shutdown wiring remain. Same read sites; no new root read or credential.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): in the edge-ready callback, calls act.SetHeldWakeHook(e.HeldWake) when act is non-nil (installing the non-blocking wake callback) and stores e.HeldStreamsForStatus in heldStreamsSource. Wiring of in-memory callbacks only; no read added.;rev3=census-ruling-region-ha-p1b3b-t;basis=Wire Service.SetDutyView to the live edge DutySnapshot in the ready callback. No new read; no new loop or cloud operation. B2 wires the registry as the persistent DutyStore before service startup; no new cloud or filesystem path. B3b: arm one journal-backed termination consumer before service startup using agentCtx and the shared confirmer; expose edge tick and join at edge shutdown. No new direct read sites.;rev3=census-ruling-agent-start-demo-1;basis=Passes the existing registry, data store and hibernation prefix into the demo worker, and the existing instance-control client into the demo before-exec hook. No alternate data store or polling loop. Merge resolution against origin/main 9bd45488 retains main's HA departure controller, lifecycle and duty wiring alongside the demo data store and worker; no read site added by the resolution.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: install closed fixed admission before every launch source, bind activator/backend and edge, wire the real termination Started lifecycle and role reader after the change index; close before cancellation/child shutdown. No new external reads or cloud authority. Fix R1: move bind/lifecycle/edge-option wiring into wireAgentAdmission and worker listing into runWorkerBootPassAfterAdmission. Worker boot waits for admission before listing then uses unchanged bounded wakes and per-host serialization; whole Route read moves to the helper. No new storage, cloud, or root execution authority. Preserve merged main's agent wiring and census basis; the branch removes one whole Route use by moving worker iteration to the helper, with no added read kind.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: arms a fleet-only worker using the existing registry, activator, backend and authenticated console transport. Owned worker stops and joins at shutdown. No new bucket reader. merge of origin/main 9b8b2c50: retain HA duty/departure lifecycle, wake-slot and existing agent wiring alongside the replica placement worker; no new read introduced by resolution. merge of origin/main 6be08467: Retain main demo configuration, admission, build and expiry wiring alongside the replica worker; merge-only body change, no additional read. merge of origin/main 7920cccf: Retain main box-role/group admission wiring and boot publication beside the owned replica worker and shutdown; main moves the boot registry List into runWorkerBootPassAfterAdmission, removing its inline whole Route site. No new read introduced by conflict resolution.;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 M3: retain the private snapshot source and cancel/join ownership, but use the replica-health-specific retry loop. It logs its first failure only and retains the existing exponential backoff capped at 30 seconds; unsupported builds return nil. Existing five direct read sites unchanged; no new credentials, bucket reader or app lifecycle action. Fix round 1 Q20: publish Edge.ReplicaSnapshots as a separate in-memory status source, leaving the tenant-visible Upstreams source unchanged. No new external reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Load root-written group marker/configuration, configure signed boot binding and agent receipt completer, wire cancellable admission into departure work and expose cached GroupReaderSnapshot. New indirect boot reads use protected root files; agent-owned receipt controls duplicate initial completion only, never root restart permission. Same five direct sites. Merge 45cebde4 retains the replica health socket lifecycle and setReplicaSource beside GroupReaderSnapshot; no extra read beyond main.;rev3=census-ruling-agent-start-demo-2;basis=agent.go:309-329 opens demo-traffic.db beside the operator-configured registry when a demo domain exists, closes it at shutdown and wires drain-before-purge; :1010-1019 shares the worker and write gate; :1164-1177 installs the fleet identity and closed-until-worker serving callback. One added whole Route pass; the new indirect filesystem/SQL reads are claimed in openDemoTraffic and worker/store units. No request chooses the database pathname.;rev3=census-ruling-region-ha-p1b3b-s;basis=Wire the service duty view to authoritative cached sidecar manifest placement in LifetimeIndex and the edge sidecar projection; missing policy denies duty. Existing instance duty wiring remains.;rev3=census-ruling-region-ha-g2-t3;basis=T3a: wire eb.Page = PageOperator beside OwnerTerminated before departures arm, so suspect-holder pages work if departure setup fails; no new read; existing nine sites and authority unchanged; pages through the existing sink. T3b: publish the same backend through an atomic pointer for the metrics observer, and clear it on return; no new external read or authority.;rev3=census-ruling-agent-start-demo-3;basis=Wire the claim activator and root snapshot client into the demo worker; pass moved readiness to status reporting. Census read-site delta: unchanged (9).;rev3=census-ruling-region-ha-g2-fixes;basis=Wire local pool evidence, live withdrawal activator, startup ingress scan and alias publication, and edge lookup; no new direct sites; new indirect record/claim reads use existing store/judge paths described in ingress helpers.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: starts the existing record-view backstop loop with a departure-inventory listener (non-blocking, coalesced signal) even without an armed RecordView; it requests the existing full pass (backstopFullDue) there. Same nine read sites; no new read or authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Derive one signal-time deadline with a 90-second budget; cap departure stop and startup/seed/service shutdown joins by it. No read added.;rev3=census-ruling-static-sweep-periodic;basis=in the edge-ready callback, publishes e.LargestStaticTree in staticTreeSource for the disk alert line (diskAlertFrac in the metrics loop); in-memory wiring only, no read added; read sites unchanged (9);rev3=census-ruling-region-ha-held-build;basis=wires the drain state: svc.SetDrainingSource(boxDrain.IsDraining), svc.SetPeerDrainView(e.PeerDraining), e.SetPeerDrainedHook(svc.DropHoldersNaming); in-memory only; no read added file:Exec@19204,file:Open@1707,file:Statfs@50791,registry:App@12803,registry:Host@46827,whole:Route@12795,whole:Route@45670,whole:Route@46950,whole:Route@47012 720a577f668d4515fa88cf1ff1799d969d0e144c3feba7b31b25b279827f3d85 |
| -internal/host/edgesfile.go edgesFileWriteClaims authority F,J1 rev3=census-ruling-self-serve-moves-1;basis=root-route;kept=F;scope=protected-decision-only; the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): region-ha-2a's body, which with the box's lifetimes switch on also publishes each served row's lifetime pair (registry:Incarnation and registry:ServingSeq, two new sites on the rows it already lists) and an alias's or served catch-all's primary's pair, and names that primary as target_host whatever the switch; a report the edge orders unstamped entries by, not a decision; no record, /data, release or claim read added; F,J1 authority retained; self-serve moves 1 Task 8;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 8: takes a localAddrs reader (instancectl.LocalAddresses in production, which reads /proc/net/fib_trie and /proc/net/if_inet6 in the agent) and publishes its non-loopback entries as the edges file's addrs before the write gate (boxAddrs, no read of its own), so an address change writes once. The same 44 sites, offsets moved; no record, /data, release or claim read added; a report the console's egress grant check reads, not a root decision; F,J1 authority retained.;rev3=census-ruling-edge-asset-cache-3;basis=starts with assets = assets.active(), so a policy whose box has not opened its asset store publishes no assets blocks and reads no manifests, and copies the decision's Primary (the route host the block was decided for, drift D4) into the published assets block; read sites unchanged (44); no read added. Merged onto main's #328 body, which takes the localAddrs reader: the assets.active() line sits after that signature and the loop passes pub and instancectl.LocalAddresses;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: the claims argument (*edgesClaims) becomes addrs (AddressSource) and the applyEdgesClaims(ctx, claims, routes, hosts) call is deleted with edgesclaims.go, which is the one whole:Route site removed: no host claim is read and every served row publishes as with region HA off; the box-address publication is the same code reading addrs.BoxAddresses() instead of claims.addrs; a report the edge reads, not a root decision; no read added; merge of origin/main d7ae1d76: main's edge asset cache plan 3 body is kept (census-ruling-edge-asset-cache-3): the first line is assets = assets.active(), so a policy whose store has not opened publishes no assets blocks and reads no manifests, and edgesFileLoop passes pub (assets.active() for that tick) in the assets argument; main's claims *edgesClaims argument is this branch's addrs AddressSource, and no edgesClaims, applyEdgesClaims or hostclaim reference remains;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: skips publishing a platform alias edge.PlatformAliasFold refuses (and so anything attached to it); reads the same route listing;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 6 and its fix rounds: publishes by FleetArmVerdict (via fleetRefusedFor): withheld rows left out; a forward host's path rows left out of its owner; no assets for forward rows; the alias loop replays Reload's alias fold from the served rows so a chained alias carries its root primary's owner; certRefused and parentRefused leave out a refused claim's wildcard parent (+registry:Alias x5, +registry:Host x4, +whole:Route, +whole:RouteAlias x2, +whole:RoutePath x7, +whole:WildcardDomain). Rows already read in the pass; keeps authority F,J1; publishes less, never more.;rev3=census-ruling-probe-burst-limit;basis=sets the constant BurstNotices=true on the box's own edges file (this build's edge answers probe-burst notices, so peers may send them); not from config or any read; the same 65 sites; a report other edges read, not a root decision; F,J1 authority retained; no new root read or write kind;rev3=census-ruling-region-ha-p3a;basis=Publish one injected role snapshot with box_role/admitted/drained; retain legacy route and alias rows during booting, cutting namespace withdrawal under the 2026-11-04 ruling; acknowledge the exact published tuple only after PUT; existing registry reads unchanged.;rev3=census-ruling-region-ha-p2b;basis=region HA P2b-1 T0 (Q1 ruling): before building the comparison copy and the body, a nil NamedPools on the identity becomes []string{} so the additive named_pools field is always an explicit array; the list itself is computed once at arm by edgesFileEligibility from the same provisionTickConfig(os.Getenv) parse as serves_shared_pool (CARLOS_POOLS through provision.ParseBoxPools, filtered to nonempty provision.ValidPool names, sorted, unique). A report the console reads for create admission, not a root decision; no record, /data, release or claim read added; read sites unchanged (65); F,J1 authority retained. One-off cost: the first pass after the upgrade writes once per box (seeded gate null vs []).;rev3=census-ruling-region-ha-p3b;basis=Require cached GroupReadersReady before first group publication and append additive names-2 capability even for supplied identities. Agent writes the same edges object/index with existing registry reads; known readers come from root boot configuration, snapshot from existing fold, no added GET/LIST or root authority.;rev3=census-ruling-region-ha-g2-fixes;basis=Omit non-forward, non-platform-alias rows outside local served pools from home publication; added Host/Pool field reads and local configuration use, existing registry/store operations retained.;rev3=census-ruling-region-ha-held-build;basis=writes also when DrainPublishRequired, and reports the written drain state and generation to DrainSource (in-memory); the file gains ha_drained beside the existing draining; no read added registry:Account@15918,registry:Alias@10421,registry:Alias@13391,registry:Alias@13441,registry:Alias@8848,registry:Alias@8867,registry:Alias@8966,registry:Alias@9020,registry:Alias@9055,registry:Alias@9117,registry:Alias@9487,registry:Alias@9644,registry:Alias@9714,registry:Alias@9746,registry:App@15930,registry:DNSStatus@9162,registry:DNSStatus@9653,registry:Host@13294,registry:Host@13314,registry:Host@13579,registry:Host@13659,registry:Host@13694,registry:Host@13743,registry:Host@14205,registry:Host@14240,registry:Host@15348,registry:Host@3963,registry:Host@4054,registry:Host@4100,registry:Host@4159,registry:Host@5274,registry:Host@6244,registry:Host@8893,registry:Host@8941,registry:Incarnation@5234,registry:Platform@5013,registry:Pool@4014,registry:Provisioned@5027,registry:Replica@5051,registry:ServingSeq@5249,registry:Status@2732,whole:Route@1026,whole:Route@17388,whole:Route@18206,whole:Route@18381,whole:Route@1841,whole:Route@2102,whole:Route@6329,whole:Route@750,whole:RouteAlias@13345,whole:RouteAlias@17410,whole:RouteAlias@18396,whole:RouteAlias@8731,whole:RouteAlias@8813,whole:RouteAlias@9005,whole:RoutePath@17403,whole:RoutePath@18389,whole:RoutePath@6113,whole:RoutePath@6145,whole:RoutePath@6192,whole:RoutePath@6220,whole:RoutePath@6258,whole:RoutePath@6278,whole:RoutePath@6290,whole:RoutePath@6344,whole:WildcardDomain@13272,whole:WildcardDomain@13648 4e38745e3b633d394dbf70f4cb473fcf8e90a171b1dd9de2194666162f810385 |
| -internal/edge/hadrain.go Edge.serveHAControl legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-held-build;basis=new: answers a signed drain ask. Reads the request body (io.ReadAll under MaxBytesReader 4 KiB and a 2 s read deadline), verifies its own mesh-key MAC, and may refresh the edges fold (the existing refreshHosts: LIST plus GET of control/edges/ in the deployment bucket); reads no local file; answers JSON seen true or false, or a bare 404 file:ReadAll@674 c4846ae9fc7f4fe0153cb2b937633eb714dc8ffa437e6b81fe9e6704b56df7a1 |
| +internal/host/edgesfile.go edgesFileWriteClaims authority F,J1 rev3=census-ruling-self-serve-moves-1;basis=root-route;kept=F;scope=protected-decision-only; the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): region-ha-2a's body, which with the box's lifetimes switch on also publishes each served row's lifetime pair (registry:Incarnation and registry:ServingSeq, two new sites on the rows it already lists) and an alias's or served catch-all's primary's pair, and names that primary as target_host whatever the switch; a report the edge orders unstamped entries by, not a decision; no record, /data, release or claim read added; F,J1 authority retained; self-serve moves 1 Task 8;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 8: takes a localAddrs reader (instancectl.LocalAddresses in production, which reads /proc/net/fib_trie and /proc/net/if_inet6 in the agent) and publishes its non-loopback entries as the edges file's addrs before the write gate (boxAddrs, no read of its own), so an address change writes once. The same 44 sites, offsets moved; no record, /data, release or claim read added; a report the console's egress grant check reads, not a root decision; F,J1 authority retained.;rev3=census-ruling-edge-asset-cache-3;basis=starts with assets = assets.active(), so a policy whose box has not opened its asset store publishes no assets blocks and reads no manifests, and copies the decision's Primary (the route host the block was decided for, drift D4) into the published assets block; read sites unchanged (44); no read added. Merged onto main's #328 body, which takes the localAddrs reader: the assets.active() line sits after that signature and the loop passes pub and instancectl.LocalAddresses;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: the claims argument (*edgesClaims) becomes addrs (AddressSource) and the applyEdgesClaims(ctx, claims, routes, hosts) call is deleted with edgesclaims.go, which is the one whole:Route site removed: no host claim is read and every served row publishes as with region HA off; the box-address publication is the same code reading addrs.BoxAddresses() instead of claims.addrs; a report the edge reads, not a root decision; no read added; merge of origin/main d7ae1d76: main's edge asset cache plan 3 body is kept (census-ruling-edge-asset-cache-3): the first line is assets = assets.active(), so a policy whose store has not opened publishes no assets blocks and reads no manifests, and edgesFileLoop passes pub (assets.active() for that tick) in the assets argument; main's claims *edgesClaims argument is this branch's addrs AddressSource, and no edgesClaims, applyEdgesClaims or hostclaim reference remains;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: skips publishing a platform alias edge.PlatformAliasFold refuses (and so anything attached to it); reads the same route listing;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 6 and its fix rounds: publishes by FleetArmVerdict (via fleetRefusedFor): withheld rows left out; a forward host's path rows left out of its owner; no assets for forward rows; the alias loop replays Reload's alias fold from the served rows so a chained alias carries its root primary's owner; certRefused and parentRefused leave out a refused claim's wildcard parent (+registry:Alias x5, +registry:Host x4, +whole:Route, +whole:RouteAlias x2, +whole:RoutePath x7, +whole:WildcardDomain). Rows already read in the pass; keeps authority F,J1; publishes less, never more.;rev3=census-ruling-probe-burst-limit;basis=sets the constant BurstNotices=true on the box's own edges file (this build's edge answers probe-burst notices, so peers may send them); not from config or any read; the same 65 sites; a report other edges read, not a root decision; F,J1 authority retained; no new root read or write kind;rev3=census-ruling-region-ha-p3a;basis=Publish one injected role snapshot with box_role/admitted/drained; retain legacy route and alias rows during booting, cutting namespace withdrawal under the 2026-11-04 ruling; acknowledge the exact published tuple only after PUT; existing registry reads unchanged.;rev3=census-ruling-region-ha-p2b;basis=region HA P2b-1 T0 (Q1 ruling): before building the comparison copy and the body, a nil NamedPools on the identity becomes []string{} so the additive named_pools field is always an explicit array; the list itself is computed once at arm by edgesFileEligibility from the same provisionTickConfig(os.Getenv) parse as serves_shared_pool (CARLOS_POOLS through provision.ParseBoxPools, filtered to nonempty provision.ValidPool names, sorted, unique). A report the console reads for create admission, not a root decision; no record, /data, release or claim read added; read sites unchanged (65); F,J1 authority retained. One-off cost: the first pass after the upgrade writes once per box (seeded gate null vs []).;rev3=census-ruling-region-ha-p3b;basis=Require cached GroupReadersReady before first group publication and append additive names-2 capability even for supplied identities. Agent writes the same edges object/index with existing registry reads; known readers come from root boot configuration, snapshot from existing fold, no added GET/LIST or root authority.;rev3=census-ruling-region-ha-g2-fixes;basis=Omit non-forward, non-platform-alias rows outside local served pools from home publication; added Host/Pool field reads and local configuration use, existing registry/store operations retained.;rev3=census-ruling-region-ha-held-build;basis=writes also when DrainPublishRequired, and reports the written drain state, its ha_drain mark (transaction and publication id) and generation to DrainSource (in-memory); the file gains ha_drained and ha_drain beside the existing draining; no read added registry:Account@15918,registry:Alias@10421,registry:Alias@13391,registry:Alias@13441,registry:Alias@8848,registry:Alias@8867,registry:Alias@8966,registry:Alias@9020,registry:Alias@9055,registry:Alias@9117,registry:Alias@9487,registry:Alias@9644,registry:Alias@9714,registry:Alias@9746,registry:App@15930,registry:DNSStatus@9162,registry:DNSStatus@9653,registry:Host@13294,registry:Host@13314,registry:Host@13579,registry:Host@13659,registry:Host@13694,registry:Host@13743,registry:Host@14205,registry:Host@14240,registry:Host@15348,registry:Host@3963,registry:Host@4054,registry:Host@4100,registry:Host@4159,registry:Host@5274,registry:Host@6244,registry:Host@8893,registry:Host@8941,registry:Incarnation@5234,registry:Platform@5013,registry:Pool@4014,registry:Provisioned@5027,registry:Replica@5051,registry:ServingSeq@5249,registry:Status@2732,whole:Route@1026,whole:Route@17388,whole:Route@18206,whole:Route@18381,whole:Route@1841,whole:Route@2102,whole:Route@6329,whole:Route@750,whole:RouteAlias@13345,whole:RouteAlias@17410,whole:RouteAlias@18396,whole:RouteAlias@8731,whole:RouteAlias@8813,whole:RouteAlias@9005,whole:RoutePath@17403,whole:RoutePath@18389,whole:RoutePath@6113,whole:RoutePath@6145,whole:RoutePath@6192,whole:RoutePath@6220,whole:RoutePath@6258,whole:RoutePath@6278,whole:RoutePath@6290,whole:RoutePath@6344,whole:WildcardDomain@13272,whole:WildcardDomain@13648 3313d7ba7f4587179a56d76b45703ec75f105fd818a7f32bcfaf361b58664740 |
| +internal/edge/hadrain.go Edge.serveHAControl legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-held-build;basis=new: answers a signed drain ask. Reads the request body (io.ReadAll under MaxBytesReader 4 KiB and a 2 s read deadline), verifies its own mesh-key MAC, requires a phase (draining or drained) and a nonzero publication id, and may refresh the edges fold (the existing refreshHosts: LIST plus GET of control/edges/ in the deployment bucket); reads no local file; answers JSON seen true or false, or a bare 404. Fix round 1: the ask names phase and publication id instead of a generation file:ReadAll@674 6f135b934ef3a804ed07bd8567e2ee4dc8db9f8abee97038d3946892ac9c1128 |
| @coverage internal/activator 67c3b9cafcb9ce380e6bf90e628cb1926bc6fe87f9428c368fae960586f0134c |
| -@coverage internal/edge dec0b06ca340ebac0b5106318cce74d0d107fb7e018626da5a6a4972e55afcb9 |
| -@coverage internal/host b58cbf597429f8374a3832c5cfde521ec2fa42a7daa34d1b7640e7b7a67707ee |
| +@coverage internal/edge 9b708161eef4bd895c8116c634fd332eeb2e193916e0329911dd3163c62d7d12 |
| +@coverage internal/host 2e83bba2a89d116388857912876ebde007a7c7b7fb6a3265c04856d60185583d |