region HA: retain detached dial failures after visitor cancellation
Enforce N-HA12 and R7: a detached connect or TLS failure reaches the existing suspect classifier even after its Placement or Recovery request is canceled. Successful dials, visitor cancellation alone and queue deadlines do not mark peers suspect. Keep Holder outcomes and N-HA15 rereads unchanged. Include the accumulated root-read census claims and proposal for follow-up items 1, 2 and 5. Independent review remains required before landing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 files changed,
+316
−13
docs/superpowers/notes/census-proposal-region-ha-followups.md+27 −0docs/superpowers/notes/census-region-ha-followups-claims.md+5 −0internal/activator/haplacement_test.go+35 −0internal/edge/forwardha.go+50 −9internal/edge/forwardha_export_test.go+53 −1internal/edge/forwardha_test.go+22 −0internal/edge/haplacement_wiring_test.go+106 −3internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-region-ha-followups.tsv+17 −0
diff --git a/docs/superpowers/notes/census-proposal-region-ha-followups.md b/docs/superpowers/notes/census-proposal-region-ha-followups.md| new file mode 100644 |
| index 000000000..2d518ffb1 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-region-ha-followups.md |
| @@ -0,0 +1,27 @@ |
| +# Census approval: region-ha-followups |
| + |
| +Ruling `census-ruling-region-ha-followups`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/host/hadeparture_identity.go` `departureIdentities.Proof` | body | unchanged (1) | Allow live EC2 fallback only after clean absence of pair, ref and iid; identity read errors, mismatches and verification failures refuse. Additional reads use the existing registry identity lookup for ref and iid separately. | |
| +| `internal/host/hadepartures_wiring.go` `armHADepartures` | body | unchanged (17) | Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport. | |
| +| `internal/activator/haadopt.go` `Service.AdoptHost` | sites | +whole:Route | Attach a per-acquire termination proof observer to finalizer acquisitions so refusals retain alarms; avoid duplicate fallback observations. The observer receives the existing route and departure ref for paging; no new storage read or takeover authority. | |
| +| `internal/activator/hatakeover.go` `ExecBackend.reportTakeover` | sites | +registry:Host ×2 | Page only departure-finalize proof refusals through the injected host sink, at warning level and once per host per hour. Read the existing route Host for page throttling and body; no new storage read or takeover authority. | |
| +| `internal/edge/forwardha.go` `Edge.frontForwardHA` | sites | +registry:Host, +whole:Route | Report detached TCP/TLS failure after a canceled Placement or Recovery request through the existing NoteForward classifier, preserving Ref, Gen and PeerGen. Reuse the route Host to correlate the late result; no new storage read or routing authority. | |
| + |
| +Envelopes re-pinned: `internal/activator`, `internal/edge`, `internal/host`, `internal/lease`, `internal/termfence`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/host/hadeparture_identity.go` `departureIdentities.Proof`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: read immutable box bytes and local verified bindings; require AWS signature plus independent fixed/group binding, unique ref/iid, exact digest and known scope. Unknown walks persist one 1000-key page and at most 32 new GETs per turn; errors never prove absence. |
| +- `internal/host/hadepartures_wiring.go` `armHADepartures`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority. |
| +- `internal/activator/haadopt.go` `Service.AdoptHost`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=Serialize through the existing host operation state. Read local route/revision/receipt plus configured lock/manifest/wake objects; use only restricted ordinary acquire, exact guarded restore, ordinary unclean release and verified readback for adoption. No process launch, local-copy reuse or secret access. B3: pass the optional shared durable termination proof adapter into the existing restricted finalizer acquire. The adapter validates the exact classified peer and current host lifetime, uses the acquire data-bucket client, and cannot bypass expiry or CAS. No new read in this unit. B4: A first scanner import may reuse its staging lock observation; the ordinary acquire still rereads and compares the exact ETag/generation and expiry. Existing receipt replay keeps its fresh read. No new read path or takeover authority. |
| +- `internal/activator/hatakeover.go` `ExecBackend.reportTakeover`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=Final fix P2-1: report all refused proof results through the per-host alarm and distinguish visitor from departure-finalize. No reads or authority. |
| +- `internal/edge/forwardha.go` `Edge.frontForwardHA`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b2;basis=new (region HA P1b-2): the agent's edge decides at the front door whether to forward a visitor request: reads the route's HA flag and host from the box's own registry row and asks the activator; forwards only to a box in view over the existing signed hop; root never calls it;rev3=census-ruling-region-ha-dead-holder-backoff;basis=ForwardTarget returns a ForwardDecision (Ref, Refuse, Gen); a Refuse is answered at the front door with the existing unreachable answer (503, Retry-After: 10, same body, via answerHolderUnreachable), with no forward, dial, note or per-request step. A forward passes the decision to forwardHA and NoteForward carries Ref and Gen back. The round-1 connection callback (NoteConnected) is gone: the dial bound now lives in forwardTransport's forwardDialGate, which coalesces TCP dials per holder address in memory. The same 5 read sites; no new read; root never calls it.;rev3=census-ruling-region-ha-p1b3a;basis=Pass the existing route to a lazy cached wakeSnapshot closure, handle explicit local denial before all accounting, and refuse a disappeared Placement choice rather than falling through locally; whole Route read only, no new store or filesystem operation and no root authority.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): for a marked request to a hibernating HA route it uses the new HAForwarderFromMemory (ForwardTargetFromMemory) instead of ForwardTarget, so the hold path makes no holder-lock read; a non-stream marked request is left to this box's classification, and a holder not known from memory is answered with the one-retry event. The unmarked path is unchanged. Reads only the request mark and the already-loaded route and home map; no read added. |
| + |
| +Seal: `6ef1e3bc1dbacd5b548b1cbfe3a6d37bd5f701e03969feef2736212ee11713df` → `61ed62d78faa0788b1afa997ac966cf69350fdf99914e90b7e70eb8d934e0470`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-region-ha-followups.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/notes/census-region-ha-followups-claims.md b/docs/superpowers/notes/census-region-ha-followups-claims.md| new file mode 100644 |
| index 000000000..3ee3bb947 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-region-ha-followups-claims.md |
| @@ -0,0 +1,5 @@ |
| +internal/host/hadeparture_identity.go:departureIdentities.Proof Allow live EC2 fallback only after clean absence of pair, ref and iid; identity read errors, mismatches and verification failures refuse. Additional reads use the existing registry identity lookup for ref and iid separately. |
| +internal/activator/haadopt.go:Service.AdoptHost Attach a per-acquire termination proof observer to finalizer acquisitions so refusals retain alarms; avoid duplicate fallback observations. The observer receives the existing route and departure ref for paging; no new storage read or takeover authority. |
| +internal/host/hadepartures_wiring.go:armHADepartures Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport. |
| +internal/activator/hatakeover.go:ExecBackend.reportTakeover Page only departure-finalize proof refusals through the injected host sink, at warning level and once per host per hour. Read the existing route Host for page throttling and body; no new storage read or takeover authority. |
| +internal/edge/forwardha.go:Edge.frontForwardHA Report detached TCP/TLS failure after a canceled Placement or Recovery request through the existing NoteForward classifier, preserving Ref, Gen and PeerGen. Reuse the route Host to correlate the late result; no new storage read or routing authority. |
diff --git a/internal/activator/haplacement_test.go b/internal/activator/haplacement_test.go| index c32fa8b35..b5382ef32 100644 |
| --- a/internal/activator/haplacement_test.go |
| +++ b/internal/activator/haplacement_test.go |
| @@ -785,3 +785,38 @@ func TestPlacementCanceledRetry(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +func TestPlacementCanceledDialCompletion(t *testing.T) { |
| + for _, kind := range []edge.ForwardKind{edge.Placement, edge.Recovery} { |
| + t.Run(fmt.Sprintf("kind=%d", kind), func(t *testing.T) { |
| + s := haService(t, "shop.example.com") |
| + s.rt.HA = true |
| + clk := &fakeClock{t: time.Now()} |
| + s.a.holders.now = clk.now |
| + if kind == edge.Recovery { |
| + putLockFor(t, s.b, s.rt, leaseBody(t, heldByB, clk.now().Add(-time.Second))) |
| + } |
| + project := func() boxchoice.WakeSnapshot { return placementSnapshot(clk.now()) } |
| + d := s.a.ForwardTarget(t.Context(), s.rt, project) |
| + if d.Ref != "b" || d.Kind != kind { |
| + t.Fatal(d) |
| + } |
| + r := placementResult(d, 0, "") |
| + r.Outcome = edge.ForwardCanceled |
| + s.a.NoteForward(s.rt.Host, r) |
| + if next := s.a.ForwardTarget(t.Context(), s.rt, project); next != d { |
| + t.Fatal("cancel changed decision", next) |
| + } |
| + r.Outcome = edge.ForwardUnreachable |
| + s.a.NoteForward(s.rt.Host, r) |
| + clk.advance(10*time.Second - time.Nanosecond) |
| + if next := s.a.ForwardTarget(t.Context(), s.rt, project); next.Ref == "b" { |
| + t.Fatal("failed dial was not excluded", next) |
| + } |
| + clk.advance(time.Nanosecond) |
| + if next := s.a.ForwardTarget(t.Context(), s.rt, project); next.Ref != "b" { |
| + t.Fatal("peer not readmitted after 10 seconds", next) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/edge/forwardha.go b/internal/edge/forwardha.go| index 7273c7cc5..6b4574ec3 100644 |
| --- a/internal/edge/forwardha.go |
| +++ b/internal/edge/forwardha.go |
| @@ -225,8 +225,18 @@ func (e *Edge) frontForwardHA(w http.ResponseWriter, r *http.Request, host strin |
| if d.Ref == "" { |
| return false |
| } |
| + var observation *forwardDialObservation |
| + if d.Kind != Holder { |
| + observation = &forwardDialObservation{report: func() { |
| + fw.NoteForward(up.route.Host, ForwardResult{Outcome: ForwardUnreachable, Ref: d.Ref, Gen: d.Gen, Kind: d.Kind, PeerGen: d.PeerGen}) |
| + }} |
| + r = r.WithContext(context.WithValue(r.Context(), forwardDialObservationKey{}, observation)) |
| + } |
| res := e.forwardHA(w, r, host, d) |
| fw.NoteForward(up.route.Host, res) |
| + if observation != nil { |
| + observation.update(false, res.Outcome == ForwardCanceled) |
| + } |
| if res.Outcome == ForwardNotInView && d.Kind == Placement { |
| answerHolderUnreachable(w, r) |
| return true |
| @@ -302,7 +312,7 @@ func answerHolderUnreachable(w http.ResponseWriter, r *http.Request) { |
| // is a forwardConnectError. A separate cache, so backhaulTo's 5 s transports |
| // to the same address are never this one. |
| // |
| -// Its TCP dials go through one forwardDialGate, the transport being one per |
| +// Its TCP and TLS dials go through one forwardDialGate, the transport being one per |
| // holder address: at most one dial to a holder is in flight, however many |
| // requests need a connection and whatever the holder cache believes. |
| // |
| @@ -324,15 +334,22 @@ func (e *Edge) forwardTransport(dial string) *http.Transport { |
| } |
| ctx, cancel := context.WithTimeout(ctx, forwardDialTimeout) |
| defer cancel() |
| - raw, err := gate.dial(ctx, func(ctx context.Context) (net.Conn, error) { |
| - return forwardDial(ctx, network, net.JoinHostPort(dial, backhaulPort)) |
| + conn, err := gate.dial(ctx, func(ctx context.Context) (net.Conn, error) { |
| + raw, err := forwardDial(ctx, network, net.JoinHostPort(dial, backhaulPort)) |
| + if err != nil { |
| + return nil, err |
| + } |
| + conn := tls.Client(raw, &tls.Config{ServerName: name, RootCAs: backhaulRootCAs, MinVersion: tls.VersionTLS12}) |
| + if err := conn.HandshakeContext(ctx); err != nil { |
| + raw.Close() |
| + return nil, err |
| + } |
| + return conn, nil |
| }) |
| if err != nil { |
| - return nil, &forwardConnectError{err} |
| - } |
| - conn := tls.Client(raw, &tls.Config{ServerName: name, RootCAs: backhaulRootCAs, MinVersion: tls.VersionTLS12}) |
| - if err := conn.HandshakeContext(ctx); err != nil { |
| - raw.Close() |
| + if observation, ok := ctx.Value(forwardDialObservationKey{}).(*forwardDialObservation); ok && !errors.Is(err, errForwardDialQueued) { |
| + observation.update(true, false) |
| + } |
| return nil, &forwardConnectError{err} |
| } |
| return conn, nil |
| @@ -353,7 +370,7 @@ func (e *Edge) forwardTransport(dial string) *http.Transport { |
| return tr |
| } |
| -// forwardDialGate serializes one holder address's TCP dials: at most one is |
| +// forwardDialGate serializes one holder address's TCP and TLS dials: at most one is |
| // in flight, always. A dial that arrives while one is in flight waits for |
| // its outcome. A failure answers every waiter at once with its error, and |
| // every dial that arrives until the failed one's forwardDialTimeout has run |
| @@ -420,3 +437,27 @@ func (g *forwardDialGate) dial(ctx context.Context, connect func(context.Context |
| g.mu.Unlock() |
| return conn, err |
| } |
| + |
| +// A cancelled forward and its detached dial can finish in either order. |
| +// Report a real dial failure once both are known; NoteForward still owns all |
| +// suspicion and generation checks. A healthy dial or queue timeout adds no note. |
| +type forwardDialObservationKey struct{} |
| +type forwardDialObservation struct { |
| + mu sync.Mutex |
| + failed, canceled, reported bool |
| + report func() |
| +} |
| + |
| +func (o *forwardDialObservation) update(failed, canceled bool) { |
| + o.mu.Lock() |
| + o.failed = o.failed || failed |
| + o.canceled = o.canceled || canceled |
| + report := o.failed && o.canceled && !o.reported |
| + if report { |
| + o.reported = true |
| + } |
| + o.mu.Unlock() |
| + if report { |
| + o.report() |
| + } |
| +} |
diff --git a/internal/edge/forwardha_export_test.go b/internal/edge/forwardha_export_test.go| index a498e58cb..631cabe56 100644 |
| --- a/internal/edge/forwardha_export_test.go |
| +++ b/internal/edge/forwardha_export_test.go |
| @@ -2,10 +2,13 @@ package edge |
| import ( |
| "context" |
| + "errors" |
| "fmt" |
| + "github.com/carlosframework/platform/internal/boxchoice" |
| "io" |
| "net" |
| "net/http" |
| + "sync" |
| "sync/atomic" |
| "testing" |
| "time" |
| @@ -54,7 +57,15 @@ func (s *HAForwardScene) Dials() int64 { return s.dials.Load() } |
| // Get is one visitor GET of path on HAForwardHost through annie. |
| func (s *HAForwardScene) Get(path string) (status int, retryAfter, body string, err error) { |
| - resp, err := s.x.a.client.Get("https://" + fwHost + path) |
| + return s.GetContext(context.Background(), path) |
| +} |
| + |
| +func (s *HAForwardScene) GetContext(ctx context.Context, path string) (status int, retryAfter, body string, err error) { |
| + req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://"+fwHost+path, nil) |
| + if err != nil { |
| + return 0, "", "", err |
| + } |
| + resp, err := s.x.a.client.Do(req) |
| if err != nil { |
| return 0, "", "", err |
| } |
| @@ -103,3 +114,44 @@ func (s *HAForwardScene) PausePeer(t *testing.T) { |
| } |
| t.Cleanup(func() { forwardDial = old }) |
| } |
| + |
| +// HoldDial controls the real forward transport's connect boundary. |
| +func (s *HAForwardScene) HoldDial(t *testing.T, mode string) (<-chan struct{}, func()) { |
| + t.Helper() |
| + started, release := make(chan struct{}), make(chan struct{}) |
| + var startOnce, releaseOnce sync.Once |
| + resume := func() { releaseOnce.Do(func() { close(release) }) } |
| + old := forwardDial |
| + forwardDial = func(ctx context.Context, network, _ string) (net.Conn, error) { |
| + s.dials.Add(1) |
| + startOnce.Do(func() { close(started) }) |
| + select { |
| + case <-release: |
| + case <-ctx.Done(): |
| + return nil, ctx.Err() |
| + } |
| + switch mode { |
| + case "connect": |
| + return nil, errors.New("connection refused") |
| + case "tls": |
| + a, b := net.Pipe() |
| + b.Close() |
| + return a, nil |
| + case "queued": |
| + return nil, fmt.Errorf("%w: %w", errForwardDialQueued, context.DeadlineExceeded) |
| + } |
| + var d net.Dialer |
| + return d.DialContext(ctx, network, s.x.b.tlsAddr) |
| + } |
| + t.Cleanup(func() { resume(); forwardDial = old }) |
| + return started, resume |
| +} |
| + |
| +func (s *HAForwardScene) PlacementDecision(t *testing.T) ForwardDecision { |
| + t.Helper() |
| + rt, err := s.x.a.reg.Get(fwHost) |
| + if err != nil || rt == nil { |
| + t.Fatal("route", err) |
| + } |
| + return s.x.a.edge.act.(HAForwarder).ForwardTarget(t.Context(), *rt, func() boxchoice.WakeSnapshot { return s.x.a.homes.wakeSnapshot(*rt, time.Now()) }) |
| +} |
diff --git a/internal/edge/forwardha_test.go b/internal/edge/forwardha_test.go| index 124033727..a1d7c3445 100644 |
| --- a/internal/edge/forwardha_test.go |
| +++ b/internal/edge/forwardha_test.go |
| @@ -1383,3 +1383,25 @@ func TestForwardHAClientCanceledOutcome(t *testing.T) { |
| } |
| } |
| } |
| + |
| +func TestForwardDialObservationCompletionOrder(t *testing.T) { |
| + for _, firstFailure := range []bool{false, true} { |
| + t.Run(fmt.Sprint(firstFailure), func(t *testing.T) { |
| + var reports atomic.Int32 |
| + o := &forwardDialObservation{report: func() { reports.Add(1) }} |
| + o.update(firstFailure, !firstFailure) |
| + if reports.Load() != 0 { |
| + t.Fatal("reported with only one outcome") |
| + } |
| + o.update(!firstFailure, firstFailure) |
| + var wg sync.WaitGroup |
| + for range 20 { |
| + wg.Go(func() { o.update(true, true) }) |
| + } |
| + wg.Wait() |
| + if reports.Load() != 1 { |
| + t.Fatalf("reports=%d", reports.Load()) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/edge/haplacement_wiring_test.go b/internal/edge/haplacement_wiring_test.go| index 0f7e37d8a..23503294b 100644 |
| --- a/internal/edge/haplacement_wiring_test.go |
| +++ b/internal/edge/haplacement_wiring_test.go |
| @@ -26,10 +26,10 @@ type placementAcquire struct { |
| } |
| func (a *placementAcquire) NoteForward(host string, res edge.ForwardResult) { |
| + a.Service.NoteForward(host, res) |
| a.mu.Lock() |
| a.notes = append(a.notes, res) |
| a.mu.Unlock() |
| - a.Service.NoteForward(host, res) |
| } |
| // Keep process launch at the fixture's existing HTTP app. A local dispatch |
| @@ -148,10 +148,18 @@ func testFrontPlacementPausedPeer(t *testing.T, previousHolder, stillHeld bool) |
| if previousHolder { |
| wantKind = edge.Holder |
| } |
| + sawDialFailure := false |
| for _, note := range a.notes { |
| - if note.Kind != wantKind || note.Outcome != edge.ForwardUnreachable || note.Ref != edge.HAForwardHolder || note.PeerGen == 0 { |
| - t.Fatalf("forward result: %+v, want unreachable kind %d", note, wantKind) |
| + // TLS now holds the same dial gate as TCP. A waiter can reach its |
| + // queue deadline before the detached handshake reports its failure. |
| + queued := note.Outcome == edge.ForwardCanceled && wantKind != edge.Holder || note.Outcome == edge.ForwardDone && wantKind == edge.Holder |
| + if note.Kind != wantKind || (note.Outcome != edge.ForwardUnreachable && !queued) || note.Ref != edge.HAForwardHolder || note.PeerGen == 0 || note.Status != 0 { |
| + t.Fatalf("forward result: %+v, want failed dial or queued kind %d", note, wantKind) |
| } |
| + sawDialFailure = sawDialFailure || note.Outcome == edge.ForwardUnreachable |
| + } |
| + if !sawDialFailure { |
| + t.Fatal("no actual dial failure reached the classifier") |
| } |
| dials := x.Dials() |
| failed := time.Now() |
| @@ -190,3 +198,98 @@ func testFrontPlacementPausedPeer(t *testing.T, previousHolder, stillHeld bool) |
| t.Fatalf("survivor lock: %+v %v", view, err) |
| } |
| } |
| + |
| +func TestPlacementCanceledDialRealWiring(t *testing.T) { |
| + for _, mode := range []string{"connect", "tls", "healthy", "queued"} { |
| + t.Run(mode, func(t *testing.T) { |
| + t.Cleanup(lease.ProcessStateForTest()) |
| + fx := locktest.NewLockFixture(t) |
| + self := hafresh.Self{Ref: "annie", IID: "i-a", Account: "111122223333", Region: "eu-west-1"} |
| + lease.SetSelf(self) |
| + if err := lease.SetObligationDir(t.TempDir()); err != nil { |
| + t.Fatal(err) |
| + } |
| + prefix := activator.HibernatePrefix("", edge.HAForwardHost) |
| + body, err := hafresh.MarkerBody(145, hafresh.Marker{V: 1, Box: "betty", IID: "i-b", Clean: true}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + fx.PutLock(prefix, body) |
| + cfg := activator.Config{Bucket: fx.Bucket, Idle: time.Hour, Self: func() hafresh.Self { return self }} |
| + a := &placementAcquire{Service: activator.New(cfg, &activator.ExecBackend{Cfg: cfg}, nil), bucket: fx.Bucket, prefix: prefix} |
| + t.Cleanup(func() { |
| + a.Service.Shutdown(context.Background()) |
| + if a.held != nil { |
| + _ = a.held.Release(context.Background()) |
| + } |
| + }) |
| + x := edge.NewHAForwardScene(t, a) |
| + x.EnablePlacement(t) |
| + started, resume := x.HoldDial(t, mode) |
| + ctx, cancel := context.WithCancel(t.Context()) |
| + defer cancel() |
| + done := make(chan struct{}) |
| + go func() { defer close(done); x.GetContext(ctx, "/") }() |
| + select { |
| + case <-started: |
| + case <-time.After(3 * time.Second): |
| + t.Fatal("dial never started") |
| + } |
| + cancel() |
| + select { |
| + case <-done: |
| + case <-time.After(time.Second): |
| + t.Fatal("visitor did not return") |
| + } |
| + waitNote := func(outcome edge.ForwardOutcome) bool { |
| + deadline := time.Now().Add(time.Second) |
| + for time.Now().Before(deadline) { |
| + a.mu.Lock() |
| + found := false |
| + for _, note := range a.notes { |
| + if note.Outcome == outcome { |
| + found = true |
| + } |
| + } |
| + a.mu.Unlock() |
| + if found { |
| + return true |
| + } |
| + time.Sleep(time.Millisecond) |
| + } |
| + return false |
| + } |
| + if !waitNote(edge.ForwardCanceled) { |
| + t.Fatal("missing canceled request outcome") |
| + } |
| + resume() |
| + failed := mode == "connect" || mode == "tls" |
| + if failed && !waitNote(edge.ForwardUnreachable) { |
| + t.Fatal("detached dial failure never reached NoteForward") |
| + } |
| + if !failed && waitNote(edge.ForwardUnreachable) { |
| + t.Fatal("cancel or queue timeout marked peer unreachable") |
| + } |
| + if mode == "queued" { |
| + if next := x.PlacementDecision(t); next.Ref != edge.HAForwardHolder { |
| + t.Fatal("queue timeout excluded peer", next) |
| + } |
| + return |
| + } |
| + status, _, got, err := x.Get("/") |
| + want := "betty|" + edge.HAForwardHost + "|/" |
| + if failed { |
| + want = "annie|" + edge.HAForwardHost + "|/" |
| + } |
| + if err != nil || status != 200 || got != want { |
| + t.Fatalf("next request: %d %q %v, want %q", status, got, err, want) |
| + } |
| + if failed && (x.Dials() != 1 || a.acquires != 1) { |
| + t.Fatalf("dead peer redialled: dials=%d acquires=%d", x.Dials(), a.acquires) |
| + } |
| + if !failed && a.acquires != 0 { |
| + t.Fatal("healthy peer excluded") |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 14f9a85a0..c93b60c66 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -78,3 +78,4 @@ plan14-root-reads-region-ha-p1b3b-t.tsv c68e2453bfc8afaf3794eb4c08850428982fa695 |
| plan14-root-reads-region-host-store-deny.tsv 951f33500fdf9e47408fd2b8fe8cab419eaf1f6b1803b6ccd169ff19fe7882c6 |
| plan14-root-reads-managed-fleets-2a.tsv f85f8dabebc725fa75b88853af634fa9ca08323721f879e220da44c1e3fdbc38 |
| plan14-root-reads-agent-start-demo-1.tsv 6ef1e3bc1dbacd5b548b1cbfe3a6d37bd5f701e03969feef2736212ee11713df |
| +plan14-root-reads-region-ha-followups.tsv 61ed62d78faa0788b1afa997ac966cf69350fdf99914e90b7e70eb8d934e0470 |
diff --git a/internal/provision/testdata/plan14-root-reads-region-ha-followups.tsv b/internal/provision/testdata/plan14-root-reads-region-ha-followups.tsv| new file mode 100644 |
| index 000000000..954e62939 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-region-ha-followups.tsv |
| @@ -0,0 +1,17 @@ |
| +# Census overlay region-ha-followups, written by census-propose (#369). census-ruling-region-ha-followups, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-region-ha-followups.md. |
| +# 2 body, 3 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy 483c203479120cde40c786e23804ada71cb946154c040c4dc687af44c02a8df2 internal/host/hadeparture_identity.go departureIdentities.Proof legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: read immutable box bytes and local verified bindings; require AWS signature plus independent fixed/group binding, unique ref/iid, exact digest and known scope. Unknown walks persist one 1000-key page and at most 32 new GETs per turn; errors never prove absence.;rev3=census-ruling-region-ha-followups;basis=Allow live EC2 fallback only after clean absence of pair, ref and iid; identity read errors, mismatches and verification failures refuse. Additional reads use the existing registry identity lookup for ref and iid separately. registry:Raw@925 d81bcf013b1bf180184550c4fe1db5991cf4d77c863426a0350d2121b0fb6fa5 |
| +@legacy 4b3bd237cdebfb9bb284f24d4892f973956e208951694a833a92f53e5c021b74 internal/host/hadepartures_wiring.go armHADepartures legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority.;rev3=census-ruling-region-ha-followups;basis=Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport. registry:Account@3494,registry:Account@7088,registry:App@7115,registry:IID@3515,registry:Incarnation@7275,registry:Pool@7134,registry:Region@3505,registry:Region@7155,registry:Revision@7510,registry:Revision@7907,registry:ServingSeq@7303,whole:DutyState@7629,whole:Pair@7492,whole:Pair@7885,whole:Pair@7891,whole:Route@7075,whole:Route@7784 f9f261f51c304508d6e989e75231debc648c5b613275dea26c70acea9757e55c |
| +@legacy 798811939bbc49ed2e48e5f0cf32221560070d13c68a7f5109c99a21b8a7380d internal/activator/haadopt.go Service.AdoptHost legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=Serialize through the existing host operation state. Read local route/revision/receipt plus configured lock/manifest/wake objects; use only restricted ordinary acquire, exact guarded restore, ordinary unclean release and verified readback for adoption. No process launch, local-copy reuse or secret access. B3: pass the optional shared durable termination proof adapter into the existing restricted finalizer acquire. The adapter validates the exact classified peer and current host lifetime, uses the acquire data-bucket client, and cannot bypass expiry or CAS. No new read in this unit. B4: A first scanner import may reuse its staging lock observation; the ordinary acquire still rereads and compares the exact ETag/generation and expiry. Existing receipt replay keeps its fresh read. No new read path or takeover authority.;rev3=census-ruling-region-ha-followups;basis=Attach a per-acquire termination proof observer to finalizer acquisitions so refusals retain alarms; avoid duplicate fallback observations. The observer receives the existing route and departure ref for paging; no new storage read or takeover authority. registry:AcquiredGeneration@2549,registry:AcquiredGeneration@2922,registry:AcquiredGeneration@3700,registry:AcquiredGeneration@4312,registry:AcquiredGeneration@4403,registry:AcquiredGeneration@5042,registry:AcquiredGeneration@5133,registry:DepartureIID@1797,registry:DepartureIID@5641,registry:DepartureRef@1761,registry:DepartureRef@5625,registry:ExpectedPair@8079,registry:Host@1162,registry:Host@1258,registry:Host@1330,registry:Host@1399,registry:Host@1665,registry:Host@2040,registry:Host@2766,registry:Host@3103,registry:Host@3490,registry:Host@5454,registry:Host@5875,registry:Host@6060,registry:Host@7084,registry:Host@7841,registry:Host@8143,registry:Host@861,registry:Host@8706,registry:Host@959,registry:Lifetime@5677,registry:Lifetime@8048,registry:LockETag@5712,registry:LockGeneration@1833,registry:LockGeneration@5724,registry:Phase@2881,registry:Phase@2898,registry:Phase@3240,registry:Phase@3278,registry:Phase@3334,registry:Phase@4344,registry:Phase@4436,registry:Phase@4986,registry:Phase@5074,registry:Receipt@5701,registry:Revision@3122,registry:Revision@5689,registry:Sequence@3026,registry:Sequence@3046,registry:WakeDigest@2985,registry:WakeDigest@3007,whole:HAAdoption@3139,whole:HAAdoption@6016,whole:HAWakeImport@2968,whole:HAWakeImport@5596,whole:HAWakeImport@5612,whole:HAWakeImport@5620,whole:HAWakeImport@5894,whole:HAWakeImport@7850,whole:HAWakeImport@8152,whole:HAWakeImport@8244,whole:Pair@3116,whole:Pair@5888,whole:Pair@8085,whole:Pair@8105,whole:Route@1128,whole:Route@1171,whole:Route@1178,whole:Route@138,whole:Route@193,whole:Route@2698,whole:Route@3400,whole:Route@453,whole:Route@4713,whole:Route@531,whole:Route@5543,whole:Route@6597,whole:Route@6642,whole:Route@6797,whole:Route@723,whole:Route@7352,whole:Route@7937,whole:Route@889 946a102ba08ce347a42263ecc03fe95b429e7acc93547972b38cd92be4c6f7ac |
| +@legacy ee48fadb790a9a28a6dbddd4d2b94fbc4abb0dd1a49a075897097d368614bb87 internal/activator/hatakeover.go ExecBackend.reportTakeover legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=Final fix P2-1: report all refused proof results through the per-host alarm and distinguish visitor from departure-finalize. No reads or authority.;rev3=census-ruling-region-ha-followups;basis=Page only departure-finalize proof refusals through the injected host sink, at warning level and once per host per hour. Read the existing route Host for page throttling and body; no new storage read or takeover authority. registry:Host@347,registry:Host@429,registry:Host@605,registry:Host@781,registry:Host@933 468e4efc3d2c7beaefa604e8741be14f5d7b198157b6680683b14bb03e3059f8 |
| +@legacy 9be352a054787e5ca61ba5bbad294e1c1a53ee4e15c81d6d70c9c9f38719cb07 internal/edge/forwardha.go Edge.frontForwardHA legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b2;basis=new (region HA P1b-2): the agent's edge decides at the front door whether to forward a visitor request: reads the route's HA flag and host from the box's own registry row and asks the activator; forwards only to a box in view over the existing signed hop; root never calls it;rev3=census-ruling-region-ha-dead-holder-backoff;basis=ForwardTarget returns a ForwardDecision (Ref, Refuse, Gen); a Refuse is answered at the front door with the existing unreachable answer (503, Retry-After: 10, same body, via answerHolderUnreachable), with no forward, dial, note or per-request step. A forward passes the decision to forwardHA and NoteForward carries Ref and Gen back. The round-1 connection callback (NoteConnected) is gone: the dial bound now lives in forwardTransport's forwardDialGate, which coalesces TCP dials per holder address in memory. The same 5 read sites; no new read; root never calls it.;rev3=census-ruling-region-ha-p1b3a;basis=Pass the existing route to a lazy cached wakeSnapshot closure, handle explicit local denial before all accounting, and refuse a disappeared Placement choice rather than falling through locally; whole Route read only, no new store or filesystem operation and no root authority.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): for a marked request to a hibernating HA route it uses the new HAForwarderFromMemory (ForwardTargetFromMemory) instead of ForwardTarget, so the hold path makes no holder-lock read; a non-stream marked request is left to this box's classification, and a holder not known from memory is answered with the one-retry event. The unmarked path is unchanged. Reads only the request mark and the already-loaded route and home map; no read added.;rev3=census-ruling-region-ha-followups;basis=Report detached TCP/TLS failure after a canceled Placement or Recovery request through the existing NoteForward classifier, preserving Ref, Gen and PeerGen. Reuse the route Host to correlate the late result; no new storage read or routing authority. registry:HA@225,registry:Hibernate@584,registry:Host@1833,registry:Host@2103,whole:Route@1244,whole:Route@1368,whole:Route@1836,whole:Route@2106,whole:Route@228,whole:Route@515,whole:Route@587 49fb997abc1b78de4456e64378c691fa191ca04541eddeedcddd80570989d298 |
| +internal/host/hadeparture_identity.go departureIdentities.Proof legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: read immutable box bytes and local verified bindings; require AWS signature plus independent fixed/group binding, unique ref/iid, exact digest and known scope. Unknown walks persist one 1000-key page and at most 32 new GETs per turn; errors never prove absence.;rev3=census-ruling-region-ha-followups;basis=Allow live EC2 fallback only after clean absence of pair, ref and iid; identity read errors, mismatches and verification failures refuse. Additional reads use the existing registry identity lookup for ref and iid separately. registry:Raw@925 d81bcf013b1bf180184550c4fe1db5991cf4d77c863426a0350d2121b0fb6fa5 |
| +internal/host/hadepartures_wiring.go armHADepartures legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority.;rev3=census-ruling-region-ha-followups;basis=Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport. registry:Account@3494,registry:Account@7088,registry:App@7115,registry:IID@3515,registry:Incarnation@7275,registry:Pool@7134,registry:Region@3505,registry:Region@7155,registry:Revision@7510,registry:Revision@7907,registry:ServingSeq@7303,whole:DutyState@7629,whole:Pair@7492,whole:Pair@7885,whole:Pair@7891,whole:Route@7075,whole:Route@7784 f9f261f51c304508d6e989e75231debc648c5b613275dea26c70acea9757e55c |
| +internal/activator/haadopt.go Service.AdoptHost legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=Serialize through the existing host operation state. Read local route/revision/receipt plus configured lock/manifest/wake objects; use only restricted ordinary acquire, exact guarded restore, ordinary unclean release and verified readback for adoption. No process launch, local-copy reuse or secret access. B3: pass the optional shared durable termination proof adapter into the existing restricted finalizer acquire. The adapter validates the exact classified peer and current host lifetime, uses the acquire data-bucket client, and cannot bypass expiry or CAS. No new read in this unit. B4: A first scanner import may reuse its staging lock observation; the ordinary acquire still rereads and compares the exact ETag/generation and expiry. Existing receipt replay keeps its fresh read. No new read path or takeover authority.;rev3=census-ruling-region-ha-followups;basis=Attach a per-acquire termination proof observer to finalizer acquisitions so refusals retain alarms; avoid duplicate fallback observations. The observer receives the existing route and departure ref for paging; no new storage read or takeover authority. registry:AcquiredGeneration@2549,registry:AcquiredGeneration@2922,registry:AcquiredGeneration@3700,registry:AcquiredGeneration@4312,registry:AcquiredGeneration@4403,registry:AcquiredGeneration@5042,registry:AcquiredGeneration@5133,registry:DepartureIID@1797,registry:DepartureIID@5641,registry:DepartureRef@1761,registry:DepartureRef@5625,registry:ExpectedPair@8079,registry:Host@1162,registry:Host@1258,registry:Host@1330,registry:Host@1399,registry:Host@1665,registry:Host@2040,registry:Host@2766,registry:Host@3103,registry:Host@3490,registry:Host@5454,registry:Host@5875,registry:Host@6060,registry:Host@7084,registry:Host@7841,registry:Host@8143,registry:Host@861,registry:Host@8706,registry:Host@959,registry:Lifetime@5677,registry:Lifetime@8048,registry:LockETag@5712,registry:LockGeneration@1833,registry:LockGeneration@5724,registry:Phase@2881,registry:Phase@2898,registry:Phase@3240,registry:Phase@3278,registry:Phase@3334,registry:Phase@4344,registry:Phase@4436,registry:Phase@4986,registry:Phase@5074,registry:Receipt@5701,registry:Revision@3122,registry:Revision@5689,registry:Sequence@3026,registry:Sequence@3046,registry:WakeDigest@2985,registry:WakeDigest@3007,whole:HAAdoption@3139,whole:HAAdoption@6016,whole:HAWakeImport@2968,whole:HAWakeImport@5596,whole:HAWakeImport@5612,whole:HAWakeImport@5620,whole:HAWakeImport@5894,whole:HAWakeImport@7850,whole:HAWakeImport@8152,whole:HAWakeImport@8244,whole:Pair@3116,whole:Pair@5888,whole:Pair@8085,whole:Pair@8105,whole:Route@1128,whole:Route@1171,whole:Route@1178,whole:Route@138,whole:Route@193,whole:Route@2698,whole:Route@3400,whole:Route@453,whole:Route@4713,whole:Route@531,whole:Route@5543,whole:Route@6597,whole:Route@6642,whole:Route@6797,whole:Route@723,whole:Route@7352,whole:Route@7937,whole:Route@889 946a102ba08ce347a42263ecc03fe95b429e7acc93547972b38cd92be4c6f7ac |
| +internal/activator/hatakeover.go ExecBackend.reportTakeover legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=Final fix P2-1: report all refused proof results through the per-host alarm and distinguish visitor from departure-finalize. No reads or authority.;rev3=census-ruling-region-ha-followups;basis=Page only departure-finalize proof refusals through the injected host sink, at warning level and once per host per hour. Read the existing route Host for page throttling and body; no new storage read or takeover authority. registry:Host@347,registry:Host@429,registry:Host@605,registry:Host@781,registry:Host@933 468e4efc3d2c7beaefa604e8741be14f5d7b198157b6680683b14bb03e3059f8 |
| +internal/edge/forwardha.go Edge.frontForwardHA legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b2;basis=new (region HA P1b-2): the agent's edge decides at the front door whether to forward a visitor request: reads the route's HA flag and host from the box's own registry row and asks the activator; forwards only to a box in view over the existing signed hop; root never calls it;rev3=census-ruling-region-ha-dead-holder-backoff;basis=ForwardTarget returns a ForwardDecision (Ref, Refuse, Gen); a Refuse is answered at the front door with the existing unreachable answer (503, Retry-After: 10, same body, via answerHolderUnreachable), with no forward, dial, note or per-request step. A forward passes the decision to forwardHA and NoteForward carries Ref and Gen back. The round-1 connection callback (NoteConnected) is gone: the dial bound now lives in forwardTransport's forwardDialGate, which coalesces TCP dials per holder address in memory. The same 5 read sites; no new read; root never calls it.;rev3=census-ruling-region-ha-p1b3a;basis=Pass the existing route to a lazy cached wakeSnapshot closure, handle explicit local denial before all accounting, and refuse a disappeared Placement choice rather than falling through locally; whole Route read only, no new store or filesystem operation and no root authority.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): for a marked request to a hibernating HA route it uses the new HAForwarderFromMemory (ForwardTargetFromMemory) instead of ForwardTarget, so the hold path makes no holder-lock read; a non-stream marked request is left to this box's classification, and a holder not known from memory is answered with the one-retry event. The unmarked path is unchanged. Reads only the request mark and the already-loaded route and home map; no read added.;rev3=census-ruling-region-ha-followups;basis=Report detached TCP/TLS failure after a canceled Placement or Recovery request through the existing NoteForward classifier, preserving Ref, Gen and PeerGen. Reuse the route Host to correlate the late result; no new storage read or routing authority. registry:HA@225,registry:Hibernate@584,registry:Host@1833,registry:Host@2103,whole:Route@1244,whole:Route@1368,whole:Route@1836,whole:Route@2106,whole:Route@228,whole:Route@515,whole:Route@587 49fb997abc1b78de4456e64378c691fa191ca04541eddeedcddd80570989d298 |
| +@coverage internal/activator ea527f56aadac16fbf3ffeffb9f9397f1bbe00571e2a25e491af4422db293066 |
| +@coverage internal/edge 0602d9dd2d176f1cdae32e0780768c84322f173929344ffa79bae849b26a0ff9 |
| +@coverage internal/host fd2b445e4d22da9609cd089451992353d4a34d7ead27211b4129c7bbbc4bb870 |
| +@coverage internal/lease 8f86fe32a2dead1e40c5137ffbeb122b0e9c4178a79c85d1907f8f9fd40404f6 |
| +@coverage internal/termfence 7a07efdde97fd45351ba0692da510752b14a6f142efaa1f3061635eacd27aec9 |