carlos / platform Public

plan: region HA G2-rerun fixes W1-W4 and investigation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude pushed by paul@keymail.dev 15118be9af4ebfe4c2f40fb812e01f4ccfc561a6 parent 98c43ee
2 files changed, +252 −0
  • docs/superpowers/notes/2026-11-06-region-ha-g2r-investigation.md +97 −0
  • docs/superpowers/plans/2026-11-06-region-ha-g2r-fixes.md +155 −0

Intent

Human

<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="03d778a3-8dbb-4564-8222-240631f233f4"> Agent manager 8a3d302: add W4 to your W3 scope (same forwarding area). Through dennis (cross-region backhaul), every request for 3 freshly woken pool hosts got 503 &apos;instance is waking elsewhere; retry shortly&apos; (Retry-After 1, X-Carlos-Holder g-bd63c445) for 10+ min, and dennis never dialled the holder, while the holder answered directly. Suspect a stale &apos;waking&apos; holder-cache entry from the cold wake (1 h TTL). Evidence in ~/.cache/region-ha-next/g2-rerun-log.md and g2r-ev/ (19:56-20:06Z). A forwarder must revalidate a &apos;waking&apos; entry quickly, not trust it for an hour. </paseo-system>

Human

<task-notification> <task-id>a2ed5f69e14f94fe7</task-id> <tool-use-id>toolu_018QNeguQqgLZ2QyR737AL4j</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/87a21814-5655-4016-9e7e-41935ee8e96e/tasks/a2ed5f69e14f94fe7.output</output-file> <status>completed</status> <summary>Agent "Investigate G2R W1-W4 root causes" 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>I couldn't write `/home/paulca/.cache/tmp/claude-1001/g2rfix/INVESTIGATION.md` because this session is read-only and may not create files. The full findings are below, after the 10-line summary you asked for. **Summary (10 lines)** 1. **W2a:** `newWildcardFromEnv` returns nil when there is no DNS provider (`internal/edge/wildcard.go:877-881`), even though only `obtain` (`:624-760`) needs one. Fix: a serve-only manager on gated boxes, with an explicit `dns == nil` stand-down in `passWithClock`. 2. **W2b:** group members contend for the housekeeper lease, the single election that also gates issuance (`internal/host/housekeeper.go:181-202`). Fix: `groupReferenced(getenv)` → `housekeeperNever`. This changes spec §7.2 and §17 ("unchanged"), so it needs a ruling. 3. **W2c:** don't derive the wildcard domains. `PLATFORM_APPS_DOMAIN` is not allowed in group env and nothing in the bucket lists the static parents safely. Document `CARLOS_WILDCARD_DOMAINS` as required group SSM and add a boot warning. Deriving them from edges files (the #305 pattern) needs a ruling. 4. **W4 is not a stale holder-cache entry.** The 503 with Retry-After 1 and `X-Carlos-Holder` comes from an IE box that received dennis's hop (`internal/activator/haforward.go:313-324`). The cross-region backhaul (`internal/edge/edge.go:4201-4228`) never follows that header, so spec §6.5's one retry to the named holder is missing on this path. 5. **W3 and W4 share a cause.** For a pool host, dennis picks whichever region box's edges file sorts first (`homemap.go:862`, `edgesfile/dial.go:24-40`): no holder awareness, no liveness check, no second candidate. That predicts both observations: g-134f46a4, then g-6ce4ffb7 (which held hapair-a1, so only hapair-a1 worked). 6. **W3 forwarding fix:** on a connect failure (no request bytes sent), try the next eligible box once and mark the failed box suspect for about 60 s. **W4 fix:** for GET/HEAD, follow the named holder once after checking it is in the region's view, and remember it. 7. **W3 retirement (leading hypothesis):** the departure scan waits for `inv.FreshAfter(ObservedAt)` (`hadepartures_scan.go:138`, `:435`). `SourceReadStartedAt` only moves on a full record-view rebuild (`recordview.go:261`): at boot or every 27-33 min, not on incremental refresh. Fix: one forced rebuild per departure. 8. **W1 is mostly the withdrawal backoff, not instance-control's probe cache.** The first proof ran at restart+4 s, before admission opened. Its `cgroup` result was reported on the next pass and armed a flat 5-minute backoff (`provision/poolwithdrawal.go:155`, `:238`), and the cause is thrown away (`activator/poolwithdrawal.go:170-171`). 9. **Overlap:** W1 is in the F-B withdrawal family (follow-ups items 3, 4, 12); W3 retirement is in the departure family (I3); W3/W4 forwarding sits next to F-A item 6 but on a different path; W2 is new. 10. **Tasks in order:** T1 W2a, T2 W2b (ruling), T3 W2c docs, T4 W4 holder-follow, T5 W3 connect fallback, T6 W3 departure nudge, T7 W1 backoff and logging, T8 notes. Only T2 changes a spec ruling or cuts capability. --- ## W2 — group members cannot serve a mirrored wildcard (G3 blocker) ### (a) Serving should not need a DNS provider **Root cause.** - `internal/edge/wildcard.go:877-881` returns nil when `dnsProviderFromEnv` (`internal/edge/dns.go`) finds no provider, so the edge never wraps `getCert` with the wildcard (`internal/edge/edge.go:4719-4731`). - Inside the manager, `dns` is used only in `obtain` (`:633` zone check, `:733` `w.dns.present`). Loading and serving are provider-free: `refresh`, `loadCached` (`:358`), `certFor` (`:314`), and `pass`, which loads the cache before the issuer gate (`:515-530`). The comment there says "reading a cert someone else issued … is SERVING, and every edge serves". - `run()` loops `pass()`. A non-issuer stands down after loading and comes back hourly (`:560-569`). So a manager with `dns == nil` already works if it never reaches `obtain`. Today it would reach `obtain` and panic when the gate is open (ungated box, or a box that wins the lease). **Spec.** `certsync.go` header: "Serving is never gated: an edge serves from its local cache and from the mirror." `wildcard.go:105-111`: "Loading and serving a cert some other box obtained is never gated — that is the whole point of the shared cache." Region-HA spec §17: "The housekeeper election and certificates: unchanged (S2 §6)." **Smallest fix.** 1. In `newWildcardFromEnv`, when `dns == nil` and the box is gated (`e.issuer != nil`, meaning a store and mirror exist; `armCertIssuance` clears `issuer` otherwise), build the manager with `dns` nil and log "wildcard certs on (serve only: no DNS provider …)". Keep returning nil for ungated boxes, which preserves today's single-box behaviour. 2. In `passWithClock`, before `w.issuerGate()`: `if w.dns == nil { serveOnly++; continue }`, with a rate-limited line in the style of `logStandDown`. Also warn if the gate is held but there is no provider: an issuer that cannot renew wildcards. 3. `devbox.go:190-195` must keep refusing: change its check to `w == nil || w.dns == nil`. **Tests (production-wired).** - Edge with a real `staticStore` (dir store), an issuer gate returning false, no DNS env, and a wildcard PEM in the mirror/cache. Use the real `RunWithActivator` TLS chain, or `edge.go`'s chain via `wrapGetCertificate` plus the mirror, and handshake SNI `x.&lt;parent&gt;`. Expect CN `*.&lt;parent&gt;`. This fails today. - `pass()` with `dns` nil and the gate returning true: `obtain` is never called, no panic, the line is logged. - Ungated with no DNS: still nil. - Devbox with no provider: still refuses. **Risks.** None for single-writer. Security posture is unchanged from fixed boxes: the documented "unknown one-label host completes the handshake" property now also applies on members, as it already does on leo. ### (b) Group members must never be housekeeper or issuer candidates **Where the election lives.** `internal/host/housekeeper.go:181-202` (`newHousekeeper`): any box with `CARLOS_DEPLOYMENT_BUCKET` is `housekeeperElect`. It is wired into the edge as `edge.WithIssuerGate(housekeeperGate)` and `WithIssuerContender(housekeeperContends)` at `internal/host/agent.go:1134-1139`. The same lease gates retention prune (`agent.go:4455`), domains/health duties (`:4255`), steering (`steering_loop.go:250`) and the mesh key mint (`housekeeper.go:487`). **How a box knows it is a group member.** `groupReferenced(getenv)` is `CARLOS_BOX_REFERENCE=group` (`internal/host/boxreference.go:34`). `hostenv.AssembleGroup` always sets it and strips any supplied value (`internal/hostenv/group.go`, `env[BoxReference] = GroupReference`), and `loadGroupConfigurationAt` refuses a referenced box without the signed marker. It is the authoritative signal; don't use the hostname or `CARLOS_GROUP_ADMISSION`. **Spec.** §7.2 table: "Static sites and housekeeper duties | Every box, and one election. | Unchanged." §17: "The housekeeper election and certificates: unchanged (S2 §6)." S2 §6 L293: "If the housekeeper's box dies, issuance pauses for up to the lease TTL." **Smallest fix.** In `newHousekeeper`, add a case before the bucket case: `groupReferenced(getenv)` → `housekeeperNever`, reason "group member — deployment-global duties stay on fixed boxes". This must be an election-level exclusion. Gating only issuance would let a member hold the lease while nobody issues. **Tests.** - `newHousekeeper` with `CARLOS_BOX_REFERENCE=group` plus a bucket gives `housekeeperNever`. - `housekeeperContends()` is false. The agent wiring gives the edge an issuer gate that is never held, so `certMirror.mayBackfill` is false. - A real `lease.Acquire` dir fake shows the member never writes `control/housekeeper-lease/lock.json`. **Risks (flag).** - This amends §7.2 and §17, so it needs Paul's ruling (8a3d302 has already asked for it). - A deployment then needs at least one fixed contender. The platform box is always fixed (§12.5), but state it as a precondition and alarm if no housekeeper is held for more than 15 minutes. - It is a latent defect today regardless: the group role has no Route53 or steering grant (`infra/modules/region-host/main.tf:276-310` is count-gated on `route53_zone_ids`), so a member that wins the lease fails wildcard renewals and steering. - After rollout, `/carlos/dev/ie/CARLOS_DNS_PROVIDER=route53` is unnecessary. Remove it. ### (c) Can members get the wildcard domains without hand-set SSM? Recommendation: document, don't derive (for now) **Sources examined.** - `PLATFORM_APPS_DOMAIN`, which drives the dynamic per-account parents, is not in `hostenv.Optional` (`internal/hostenv/hostenv.go:75-112`), so members cannot derive `bab.dev.oncarlos.com` the way fixed boxes can. - The home map's `WildcardParents` (`homemap.go:708-725`) only carries *delegated customer* parents (#305), not static ones. - Edges files carry no static-parent field. - Mirrored `control/certs/wildcard-*.pem` lists every parent ever minted, including detached delegated ones. The deliberate "current set" bound (`certsync.go` backfill comment around `:1208`, `ownsCertName` `:1344`) would be bypassed. - The group module (`infra/modules/region-host/group.tf:26-53`) does not write `/carlos/&lt;env&gt;/&lt;region&gt;/*`. Those parameters are hand-seeded. `hostenv.Seed` (`hostenv.go:404-440`) refuses any non-allowed key, so seeding from a fixed box's full `host.env` is impossible and executors hand-pick. **Recommendation.** Document `CARLOS_WILDCARD_DOMAINS` as a required group regional parameter: the same value as the region's fixed boxes. Add it to `docs/region-ha-runbook.md` and the G3 card. Add one journal line on a group box whose wildcard parent set is empty. Reasons: - Deriving needs either a new edges-file wire field, whose trust question is "another box can make me load or order parents" (the #305 precedent), or weakening the current-set bound. - The hostenv rule says "Adding a variable is a code change, reviewed." - Making tofu own one regional SSM parameter mixes ownership with the hand-seeded set. A derived source can be a follow-up that needs a ruling. --- ## W4 — dennis gets 503 "waking elsewhere" for 10+ minutes **This is not a stale "waking" holder-cache entry.** - The activator's holder cache (`internal/activator/hacache.go`) has no "waking" state, has a 1 h positive TTL (`:32`), and serves only *local* routes in the box's own region. - The observed answer (Retry-After **1** plus `X-Carlos-Holder`) is written only by `answerForwarded` (`internal/activator/haforward.go:313-324`), on the box that *received a verified hop*. Dennis's own unreachable answer is Retry-After 10 (`internal/edge/forwardha.go:376-380`). **Root cause.** - For an IE pool host, dennis uses `backhaul` → `homes.Home` → `backhaulTo` (`edge.go:4183-4228`). `Home` resolves the name over every IE box advertising it (`foldHomes`, `homemap.go:855-925`; `ResolveNameAuthority`, `edgesfile/nameauthority.go:117-146`). - With equal stamps and pairs, `DialBeats` returns false (`edgesfile/dial.go:39`), so the **first file in sorted key order wins** (`homemap.go:862`). That is always g-6ce4ffb7, because "6" sorts before "b". - g-6ce4ffb7 holds hapair-a1, so hapair-a1 works. For the g2 hosts, held by g-bd63c445, it answers 503 RA1 holder=g-bd63c445. - `backhaulTo` relays that answer as-is. It has no `onResponse` handling and no holder memory, and dennis has no local route, so no `HAForwarder` is consulted. It would persist for as long as the holders differ. **Spec.** - §6.5: "On that 503, the box that first received the request may forward once more, to the named holder, when the holder is in view(H's region) and the request is a GET or HEAD with no body, or an upgrade that has not switched protocols." - §4.3: "A box validates a holder named for a host in region r against view(r), for its own region and for cross-region callers alike (astra-1.10)." - §6.6 (holder cache rules). So this is a conformance gap, not a spec change. **Smallest fix (`internal/edge/edge.go` backhaul path).** 1. For GET/HEAD with no body, or an upgrade that has not switched, give `hopTo` an `onResponse` that sees a 503 with `X-Carlos-Holder` = ref (not "none", not the dialed box). It returns a sentinel error from `ModifyResponse`; ReverseProxy closes the body and calls `ErrorHandler`, which re-hops once to the holder via `hopTo`. 2. The holder must pass a new `homeMap.boxInRegionView(ref, region)`: the holder's file has the same Region, Placement and DataBucket as the dialed box's file, is `HomeEligible()`, and is fresh (15 min). `boxInView` (`holderview.go:33-59`) only accepts the caller's own region. 3. Keep a small bounded per-host memory on the cross-region side: host → holder, a short TTL such as 10 min, dropped on dial failure, on a 503 naming someone else or "none", or when the holder leaves the view. Later requests, POST included, go straight to the holder. 4. Never a third hop. **Tests (real edges both ends; far end answering through the real `answerForwarded`).** - GET: one follow to the holder, which serves (200). - POST: not followed, but the next POST goes to the remembered holder. - A holder outside the region view, or "none": no follow. - The holder's own 503 is relayed with no third hop. - An app-set `X-Carlos-Holder` is stripped (`stripAppHolder`), so it cannot steer the hop. **Risks.** Single-writer is unaffected: only the lease holder serves, and every receiver re-checks the lease. The holder ref is validated against signed or authorized edges files, so the header cannot point at an arbitrary address. --- ## W3 — dead member stays admitted about 10 minutes; dennis dials it ### Forwarding **Root cause.** The same sorted-first choice as W4 (g-134f46a4 sorts first), with no liveness filter and no second candidate. The dial timeout is `backhaulDialTimeout` = 5 s (`edge.go`, matching "502 after 5 s"). The default error handler gives 502. **Spec.** §9.1: "Suspicion. A forward to a holder fails to connect within 2 seconds …" This is own-region only. Dennis's departure controller is scoped to its own region (`hadepartures.go` `enqueue` checks `bound.Box.Scope == c.cfg.Self.Scope`). **Fix.** - In `backhaulTo`, use a `DialTLSContext` that marks connect errors (like `forwardConnectError`, `forwardha.go`). On a connect failure, before any request byte, try once the next eligible serving claim for the same name, excluding the failed box. Safe even for POST. - Mark the failed box suspect in the home map for about 60 s so selection skips it while another eligible claim exists. - Do not retry after connect. **Tests.** Backhaul e2e with two far boxes advertising the same HA host, the first refusing or blackholing via a dial seam: GET and POST are served by the second, and a failure after connect gives 502 with no retry. **Risks.** This keeps "one hop ever": the first attempt never connected. Do not apply it to non-HA single-home hosts unless a second eligible claim exists. ### Retirement promptness **Cadence.** - `Controller.work` runs a 30 s step (`hadepartures.go:291-316`). - `ScanPass` handles one departure per step (`hadepartures_scan.go:77-95`) and does an adoption pass followed by a full independent rescan before `complete` deletes the edges file on its ETag (`:408-510`). - Both the scan and `complete` require `inv.FreshAfter(d.ObservedAt)` (`:138`, `:435`; `provision/departure_inventory.go:25-27`), which needs `SourceReadStartedAt` after the evidence. - `SourceReadStartedAt` is set only in `rebuildLocked` (`provision/recordview.go:261`). Incremental `Refresh` (`:128-186`) clones the old timestamp (`recordview_store.go:129`). Rebuilds happen at boot or on the backstop, 30 min ± 10% (`host/changeindex.go:168-183`, `release/changewatch.go:17`). - The code already tolerates waiting a full backstop: it pages only after 1.1 × backstop (`hadepartures_scan.go:139`). **Consistent with the log.** - The first two dead members retired right after sophie and leo restarted (boot rebuilds at 19:14 and 19:22). - 19:49:31 falls in leo's backstop window (19:22:22 + 27-33 min). - **Verify from journals or registry:** look for `ha_departures.last_error = 'inventory'` and the `record view backstop` timing. **Spec.** §9.3: "only then deletes the dead box's edges file … every box drops the dead box from its views within about 30 seconds." §9.8 implies minutes, not up to 33. **Termination proof that exists.** EC2 `terminated` via EventBridge → SQS (`main.tf:865-905`) and `DescribeInstances` through `termfence` (§9.2). The ASG has only a *launch* lifecycle hook, no termination hook. **Fix.** - Give the controller a `RequestInventory` hook, set in `armHADepartures`. When `!FreshAfter`, it triggers one `recordViewBackstop`-style `Rebuild` plus `backstopFullDue`, at most once per departure per about 60 s. - The digest is record-based (`:542-547`), so a rebuild does not invalidate completed lock reads. - Optionally run `ScanPass` until there is no progress, rather than one departure per step. - The alternative, advancing `SourceReadStartedAt` on a fully applied incremental poll, changes the change-index contract and needs that design owner's ruling. **Tests.** A production `Controller` with a real registry and real `RecordView` over a dir store, the change index quiet, and a departure enrolled after the last rebuild: assert the edges file is deleted within about 2 steps after the nudge. Today it waits for the backstop. Extend `internal/sim/regionha/duties_model_test.go`, which already models `SourceReadStartedAt`. **Risks.** Each departure costs one extra full walk; note it under the §18 request budget. I3 is preserved, because the scan still needs a full walk after the evidence. --- ## W1 — withdrawal proof `code=cgroup` for about 6 minutes after a restart (small) **Root cause, from the timeline.** - 19:14:30 (restart+4 s): `PreparePoolWithdrawal` starts the proof and returns "stopping", which arms no backoff. - The proof fails at `haContained` → `nestedReady` → `tenantStartRefusal`/`NestedOK` (`activator/poolwithdrawal.go:169-172`; `hawake.go:150-165`; `backend_exec.go:3027-3040`; `group_admission.go:29-34`). Admission opened at 19:14:56. - 19:15:26: the stored error is reported once (`poolwithdrawal.go` `old.reported`), and `provision/poolwithdrawal.go:155` puts "cgroup" in the backoff list. `pending` sets a flat **5 min** (`:238`). - 19:20:39: retry, success. Instance-control's `ProbeEvery` (`instancectl/server.go:298`, 5 min; `probeLoop` `:1344`) is a possible contributor only through `NestedOK`. Instance-control had been running since 18:37, so the admission-before-open order is the likelier cause. The underlying error is discarded (`return pending("cgroup")`), so `proof_finish` cannot say which. **Fix.** 1. Give `poolWithdrawalPendingError` an optional wrapped cause and log `cause=%v` at `proof_finish` (`activator/poolwithdrawal.go:94-95`). Keep the codes unchanged. 2. Back off 30 s first, doubling to 5 min, keyed per host in `PoolWithdrawalBackoff`, instead of a flat 5 min. Alternatively, don't start a proof before group admission opens. 3. Separately, follow-up 12: re-probe promptly after a failed first probe (short backoff in `probeLoop`). **Tests.** Through `reconcileSerializedAuth` with a real `activator.Service`, with `TenantStartAllowed` false then true: withdrawal finishes within about 1 min, and the journal names the cause. **Risks.** F-B family. The follow-ups note's seeded-escalation clause may require extending `internal/sim/regionha` for the pool/wake/withdrawal family. Single-writer is unchanged, because the proof's conditions are untouched. --- ## Overlap with known fault families | Item | Family | |---|---| | W1 | F-B withdrawal (follow-ups items 3, 4, 12) | | W3 retirement | Departure / I3 duty coverage (no note item) | | W3/W4 forwarding | Next to F-A item 6 (same-region hung holder), but a different code path (cross-region backhaul) | | W2 | New (certs and group config) | ## Proposed task order | Task | Item | Files | Spec impact | |---|---|---|---| | T1 | W2a serve-only wildcard | `internal/edge/wildcard.go`, `internal/edge/devbox.go` | None | | T2 | W2b group members `housekeeperNever` | `internal/host/housekeeper.go`; spec §7.2/§17 amendment | **Needs ruling; capability change** | | T3 | W2c docs | `docs/region-ha-runbook.md`, G3 card (group SSM needs `CARLOS_WILDCARD_DOMAINS`; drop `CARLOS_DNS_PROVIDER` after T1/T2), optional boot warning | None | | T4 | W4 §6.5 cross-region holder follow and memory | `internal/edge/edge.go` (`backhaulTo`/`hopTo`), `internal/edge/holderview.go` | Conformance only | | T5 | W3 connect-failure fallback and suspect | `internal/edge/edge.go`, `internal/edge/homemap.go` | New behaviour, within one-hop | | T6 | W3 departure inventory nudge | `internal/host/hadepartures_scan.go`, `internal/host/hadepartures_wiring.go`, `internal/host/changeindex.go` | Request-budget note | | T7 | W1 logging and backoff | `internal/activator/poolwithdrawal.go`, `internal/provision/poolwithdrawal.go`, optionally `internal/instancectl/server.go` | None | | T8 | Notes | `docs/superpowers/notes/2026-11-06-region-ha-g2-follow-ups.md` | None | ### Critical Files for Implementation - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/g2r-fixes/internal/edge/wildcard.go - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/g2r-fixes/internal/host/housekeeper.go - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/g2r-fixes/internal/edge/edge.go - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/g2r-fixes/internal/host/hadepartures_scan.go - /home/paulca/amadan.net/carlos/platform/.claude/worktrees/g2r-fixes/internal/provision/poolwithdrawal.go</result> <usage><subagent_tokens>252450</subagent_tokens><tool_uses>80</tool_uses><duration_ms>679433</duration_ms></usage> </task-notification>

Human

<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="d350bce7-1990-4941-9f28-f57b0e5cd5f7"> Agent manager 8a3d302: FYI, a new finding W5 for awareness only (don&apos;t build it unless it falls out naturally): since 98c43eea, an S3 blip of about 30 s or more that overlaps a lease renewal latches lease loss. The holder releases unclean and re-acquires on the same box, so 20-40 s of 503s per host with zero data loss. A design question for later: one missed renewal well inside the TTL arguably shouldn&apos;t latch. </paseo-system>

Human

<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="070ca59e-b64e-48fd-ab73-6064701b9c8e"> Agent manager 8a3d302: W2b is with Paul and he hasn&apos;t answered yet. Don&apos;t sit idle: build and review W2a (mirrored-wildcard serving without a DNS provider), W3 and W4 now, and keep W2b as a separate final commit or task once he rules. If W2a/W3/W4 are ready before the ruling, merge them on their own. </paseo-system>

Attributed to this commit: 24.2 g CO₂e (1,616,575 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-g2r-fixes, 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/2026-11-06-region-ha-g2r-investigation.md b/docs/superpowers/notes/2026-11-06-region-ha-g2r-investigation.md
new file mode 100644
index 000000000..03e1acfce
--- /dev/null
+++ b/docs/superpowers/notes/2026-11-06-region-ha-g2r-investigation.md
@@ -0,0 +1,97 @@
+# Region HA G2 rerun: W1-W4 investigation (2026-11-06)
+
+Read-only investigation against 98c43eea. Line numbers are as of that commit.
+
+## W2: group members cannot serve a mirrored wildcard
+
+(a) `internal/edge/wildcard.go:877-881` returns nil when
+`dnsProviderFromEnv` (`internal/edge/dns.go`) finds no provider, so the edge
+never wraps `getCert` (`internal/edge/edge.go:4719-4731`). Inside the
+manager, `dns` is used only in `obtain` (`:633` zone check, `:733`
+`w.dns.present`). `refresh`, `loadCached` (`:358`), `certFor` (`:314`) and
+`pass` (cache load before the issuer gate, `:515-530`) are provider-free.
+`run()` loops `pass()`; a non-issuer stands down after loading
+(`:560-569`). A `dns == nil` manager works if it never reaches `obtain`.
+Spec: certsync.go header "Serving is never gated"; wildcard.go:105-111;
+§17 "The housekeeper election and certificates: unchanged (S2 §6)".
+`devbox.go:190-195` must keep refusing without a provider.
+
+(b) `internal/host/housekeeper.go:181-202` (`newHousekeeper`): any box with
+`CARLOS_DEPLOYMENT_BUCKET` is `housekeeperElect`; wired as
+`edge.WithIssuerGate`/`WithIssuerContender` at `internal/host/agent.go:1134-1139`.
+The same lease gates retention prune (`agent.go:4455`), domains/health
+(`:4255`), steering (`steering_loop.go:250`), mesh key mint
+(`housekeeper.go:487`). Group signal: `groupReferenced(getenv)`
+(`CARLOS_BOX_REFERENCE=group`, `internal/host/boxreference.go:34`; always set by
+`hostenv.AssembleGroup`). Group role has no Route53/steering grant
+(`infra/modules/region-host/main.tf:276-310`). Fix amends §7.2/§17: ruling
+pending.
+
+(c) Not derived: `PLATFORM_APPS_DOMAIN` is not in `hostenv.Optional`
+(`internal/hostenv/hostenv.go:75-112`); home map `WildcardParents`
+(`homemap.go:708-725`) carries only delegated parents; edges files carry no
+static parents; mirrored `control/certs/wildcard-*.pem` includes detached
+parents and would bypass the current-set bound (certsync.go ~`:1208`,
+`ownsCertName` `:1344`); the group module (`region-host/group.tf:26-53`)
+does not write `/carlos/<env>/<region>/*`. Document
+`CARLOS_WILDCARD_DOMAINS` as a required group parameter.
+
+## W4: cross-region 503 "waking elsewhere" for 10+ min
+
+Not the activator holder cache (`internal/activator/hacache.go`: no
+"waking" state; local routes only). Retry-After 1 + `X-Carlos-Holder` is
+written only by `answerForwarded` (`internal/activator/haforward.go:313-324`)
+on a box that received a verified hop; dennis's own unreachable answer is
+Retry-After 10 (`internal/edge/forwardha.go:376-380`).
+
+Dennis: `backhaul` -> `homes.Home` -> `backhaulTo` (`edge.go:4183-4228`).
+`Home` resolves over every region box advertising the name (`foldHomes`,
+`homemap.go:855-925`; `ResolveNameAuthority`,
+`edgesfile/nameauthority.go:117-146`). Equal stamps: `DialBeats` false
+(`edgesfile/dial.go:39`), so the first file in sorted key order wins
+(`homemap.go:862`): g-6ce4ffb7, holder of hapair-a1 only. `backhaulTo`
+relays the 503 verbatim, no holder follow.
+
+Spec §6.5: "On that 503, the box that first received the request may
+forward once more, to the named holder, when the holder is in view(H's
+region) and the request is a GET or HEAD with no body, or an upgrade that
+has not switched protocols." §4.3: validate a named holder against
+view(r) for cross-region callers too. Conformance gap.
+
+## W3: dead member admitted ~10 min; dennis dials it
+
+Forwarding: same sorted-first choice; no liveness filter, no second
+candidate; `backhaulDialTimeout` 5 s -> 502. §9.1 suspicion is own-region
+only.
+
+Retirement: departure controller 30 s step (`hadepartures.go:291-316`);
+`ScanPass` one departure per step (`hadepartures_scan.go:77-95`); scan and
+`complete` require `inv.FreshAfter(d.ObservedAt)` (`:138`, `:435`;
+`provision/departure_inventory.go:25-27`). `SourceReadStartedAt` set only in
+`rebuildLocked` (`provision/recordview.go:261`); incremental `Refresh`
+(`:128-186`) clones it (`recordview_store.go:129`). Rebuilds: boot or
+backstop 30 min +-10% (`host/changeindex.go:168-183`,
+`release/changewatch.go:17`). Pages only after 1.1 x backstop
+(`hadepartures_scan.go:139`). Matches the log: first two dead members
+retired at sophie/leo restarts (boot rebuilds), 19:49:31 in leo's backstop
+window. Spec §9.3 "every box drops the dead box from its views within
+about 30 seconds". Digest is record-based (`:542-547`): a rebuild does not
+invalidate completed lock reads.
+
+## W1: withdrawal proof `code=cgroup` ~6 min after restart
+
+19:14:30 proof starts (restart+4 s) and fails at `haContained` ->
+`nestedReady` -> `tenantStartRefusal`/`NestedOK`
+(`activator/poolwithdrawal.go:169-172`; `hawake.go:150-165`;
+`backend_exec.go:3027-3040`; `group_admission.go:29-34`); admission opened
+19:14:56. 19:15:26 stored error reported (`old.reported`);
+`provision/poolwithdrawal.go:155` lists "cgroup" for backoff; `pending`
+sets a flat 5 min (`:238`). 19:20:39 success. The underlying error is
+discarded (`return pending("cgroup")`). Instance-control `ProbeEvery`
+(`instancectl/server.go:298`; `probeLoop` `:1344`) is a possible
+contributor via `NestedOK` (follow-up 12).
+
+## Families
+
+W1: F-B withdrawal (follow-ups 3, 4, 12). W3 retirement: departure / I3.
+W3/W4 forwarding: next to F-A item 6, different path. W2: new.
diff --git a/docs/superpowers/plans/2026-11-06-region-ha-g2r-fixes.md b/docs/superpowers/plans/2026-11-06-region-ha-g2r-fixes.md
new file mode 100644
index 000000000..111abcb1d
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-06-region-ha-g2r-fixes.md
@@ -0,0 +1,155 @@
+# Region HA G2-rerun fixes (W1-W4; W2b pending ruling)
+
+Branch `region-ha-g2r-fixes` from origin/main 98c43eea. Spec:
+`docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md`.
+Evidence: G2 rerun log (agent manager 8a3d302's cache, lines 33-58).
+Investigation (file:line evidence for every task):
+`docs/superpowers/notes/2026-11-06-region-ha-g2r-investigation.md`.
+
+## Global constraints
+
+- Single writer: only the lease holder serves an HA instance; every
+ receiver re-checks the lease. Nothing here changes placement or the
+ proof conditions.
+- One forwarded hop ever, except the spec §6.5 single follow to a named
+ holder. A connect failure (no request byte written) is not a hop.
+- A holder named in `X-Carlos-Holder` is trusted only after validating it
+ against the region's view (§4.3); an app-set header is already stripped
+ (`stripAppHolder`) and must stay stripped.
+- Serving a cert is never gated; ordering is (certsync.go header,
+ wildcard.go:105-111).
+- No new per-box S3 polling. One extra full record walk per departure is
+ allowed; note it.
+- Production-wired tests: real edges/registry/RecordView over a dir store,
+ not mocks of the code under test. Local runs: touched packages with -run.
+- Log lines are diagnostics (no copy review); docs prose gets the copy pass.
+- No spec ruling changes in T1-T6.
+
+## Task 1: W2a: serve a mirrored wildcard without a DNS provider
+
+Files: `internal/edge/wildcard.go`, `internal/edge/devbox.go`, tests.
+
+- `newWildcardFromEnv` (wildcard.go ~877): when `dnsProviderFromEnv`
+ returns nil AND the box is gated (`e.issuer != nil`; `armCertIssuance`
+ clears it when there is no store/mirror), build the manager with
+ `dns == nil` and log `edge: wildcard certs on, serve only (<reason>);
+ this box cannot order wildcards`. Ungated boxes keep returning nil
+ (today's single-box behaviour).
+- `passWithClock`: before `w.issuerGate()`, a `dns == nil` manager loads
+ and serves but never reaches `obtain`; it stands down with a
+ rate-limited line in the style of `logStandDown`. If the gate IS held
+ and dns is nil, log once per pass window a warning that this box holds
+ the issuer lease but cannot renew wildcards.
+- `devbox.go:190-195`: keep refusing when no provider: `w == nil || w.dns == nil`.
+- Tests: (1) production-wired: edge with real dir store, issuer gate false,
+ no DNS env, wildcard PEM in the mirror/cache; real TLS chain
+ (`wrapGetCertificate` + mirror); handshake SNI `x.<parent>` gets CN
+ `*.<parent>`. Must fail on 98c43eea. (2) gate true + dns nil: `obtain`
+ never called, no panic, warning logged. (3) ungated + no DNS: nil.
+ (4) devbox with no provider still refuses.
+
+## Task 2: W4: cross-region backhaul follows the named holder once (§6.5)
+
+Files: `internal/edge/edge.go` (`backhaul`/`backhaulTo`/`hopTo`),
+`internal/edge/holderview.go` and/or `homemap.go`, tests.
+
+Root cause: dennis backhauls a pool host to the first region box in
+sorted edges-file order (`homemap.go:862`, `edgesfile/dial.go:24-40`);
+that box answers `answerForwarded` 503 Retry-After 1 `X-Carlos-Holder`
+(`activator/haforward.go:313-324`) and `backhaulTo` relays it verbatim.
+
+- For GET/HEAD with no body, or an upgrade that has not switched: on a
+ 503 carrying `X-Carlos-Holder` = ref (not `none`, not the dialed box),
+ re-hop once to that holder. Implement via `ModifyResponse` returning a
+ sentinel error and the `ErrorHandler` re-hopping (ReverseProxy closes
+ the first body), or an equivalent that never writes the first 503 to
+ the client.
+- The holder must pass a new region-view check (e.g.
+ `homeMap.boxInRegionView(ref, region)`): holder file has the same
+ Region, Placement and DataBucket as the dialed box's file, is
+ `HomeEligible()`, and is fresh (same freshness bound the home map uses).
+ `boxInView` (holderview.go:33-59) only accepts the caller's own region;
+ do not loosen it, add the cross-region variant.
+- Bounded per-host memory on the backhauling side: host -> holder ref,
+ TTL 10 min, bounded size; dropped on dial failure to it, on a 503
+ naming someone else or `none`, or when the holder leaves the view.
+ Later requests for the host (POST included) dial the remembered holder
+ first.
+- Never a third hop: the holder's own 503 is relayed.
+- Tests (real edges both ends, far end answering through the real
+ `answerForwarded`): GET followed once -> 200 from holder; POST not
+ followed but the next POST goes to the remembered holder; holder
+ outside region view or `none` -> no follow; holder's own 503 relayed,
+ no third hop; app-set `X-Carlos-Holder` cannot steer the hop.
+
+## Task 3: W3: backhaul tries another candidate on connect failure
+
+Files: `internal/edge/edge.go`, `internal/edge/homemap.go`, tests.
+
+- In `backhaulTo`, the dialer marks connect errors (as
+ `forwardConnectError` does in forwardha.go). On a connect failure (no
+ request byte written), try once the next eligible box for the same name
+ (another serving claim / home candidate in the same region view),
+ excluding the failed one. Safe for any method because nothing was sent.
+- Mark the failed box suspect in the home map for 60 s so selection
+ prefers another eligible claim meanwhile (never drops the only claim).
+- No retry after connect. Non-HA single-home hosts with no second
+ eligible claim behave as today.
+- Interplay with Task 2: a remembered holder that fails to connect is
+ dropped and selection falls back to the normal choice (one fallback).
+- Tests: two far boxes advertising the same HA host, first one
+ blackholed via a dial seam: GET and POST served by the second; a
+ failure after connect gives 502 with no retry; suspect expires.
+
+## Task 4: W3: departure scan gets a fresh inventory promptly
+
+Files: `internal/host/hadepartures_scan.go`, `internal/host/hadepartures_wiring.go`
+(or where `armHADepartures` lives), `internal/host/changeindex.go`, tests;
+optionally `internal/sim/regionha/duties_model_test.go`.
+
+Root cause: scan and `complete` need `inv.FreshAfter(d.ObservedAt)`
+(`hadepartures_scan.go:138`, `:435`); `SourceReadStartedAt` moves only on
+a full RecordView rebuild (`provision/recordview.go:261`): boot or the
+30 min +-10% backstop. Dead members' edges files stayed up to ~33 min
+(observed 10 min).
+
+- Give the controller a `RequestInventory` hook set in `armHADepartures`.
+ When a departure is blocked only on `!FreshAfter`, trigger one full
+ rebuild (the existing backstop path), at most once per departure per
+ 60 s. I3 unchanged: the scan still needs a full walk after the evidence.
+- Do not change the incremental Refresh contract.
+- Tests: production `Controller` with real registry and real RecordView
+ over a dir store, change index quiet, departure enrolled after the last
+ rebuild: edges file deleted within ~2 steps after the nudge (fails on
+ base: waits for backstop); rate limit holds.
+
+## Task 5: W1: withdrawal proof logs its cause and retries promptly
+
+Files: `internal/activator/poolwithdrawal.go`,
+`internal/provision/poolwithdrawal.go`, tests; optionally
+`internal/instancectl/server.go` (follow-up 12).
+
+- `poolWithdrawalPendingError` gains an optional wrapped cause; log
+ `cause=%v` at `proof_finish`. Codes unchanged.
+- Backoff for a pending code: 30 s first, doubling to the current 5 min
+ cap, per host, reset on success.
+- Follow-up 12 (only if small): instancectl `probeLoop` re-probes after a
+ failed probe on a short backoff (e.g. 15 s doubling to `ProbeEvery`).
+- Tests: through the real reconcile path with `TenantStartAllowed`
+ false then true: withdrawal finishes within ~1 min and the log names
+ the cause.
+
+## Task 6: docs
+
+- `docs/region-ha-runbook.md` group section: required regional SSM
+ parameter `CARLOS_WILDCARD_DOMAINS` (same value as the region's fixed
+ boxes), why it is not derived, and that `CARLOS_DNS_PROVIDER` is not
+ needed on members after Task 1.
+- Follow-ups note: add W1-W5 entries with status; W5 (lease-renew blip
+ latches loss) recorded for later design, not built.
+
+## Task 7: W2b (WAITING on Paul's ruling, separate final commit)
+
+Group members (`groupReferenced`) never contend for the housekeeper
+lease (`housekeeper.go:181-202` -> `housekeeperNever`). Amends spec §7.2,
+§17. Build only after the ruling.