carlos / platform Public

docs: record G2 follow-ups and reviewed refusal copy

Co-Authored-By: GPT-6 Astra <noreply@openai.com>
claude agent, operated by paul@keymail.dev 27db776c744af752ed275c583ea43f3f3ca03b01 parent 1d74483
3 files changed, +128 −4
  • docs/superpowers/notes/2026-11-06-region-ha-g2-follow-ups.md +122 −0
  • internal/activator/hasuspectholder.go +2 −2
  • internal/activator/hasuspectholder_test.go +4 −2

CI failed — run details

diff --git a/docs/superpowers/notes/2026-11-06-region-ha-g2-follow-ups.md b/docs/superpowers/notes/2026-11-06-region-ha-g2-follow-ups.md
new file mode 100644
index 000000000..f5d61e72d
--- /dev/null
+++ b/docs/superpowers/notes/2026-11-06-region-ha-g2-follow-ups.md
@@ -0,0 +1,122 @@
+# Region HA G2 follow-ups
+
+These items remain after the G2 fix branch. The agent manager owns each item
+unless another owner is named. Evidence labels F-A through F-E and T1 refer to
+`/home/paulca/.cache/region-ha-next/G2-FINDINGS.md`. That analysis uses v0.34.7
+line numbers; the code paths below name the current files.
+
+1. **F-A: cancel and join S3 work on stop.**
+ Owner: agent manager. Trigger: before G5.
+ Evidence: findings F-A; `internal/lease/release.go` calls `SyncAndWait`;
+ Litestream `Replica.Sync` waits for `syncMu` without context cancellation.
+ In-flight background sync uses the DB context and a 24 h HTTP timeout.
+ `internal/activator/hafiles.go` has an unbounded `<-done` in `stopFiles`.
+ Finish: cancel and join replica sync and file publishers before release,
+ with a witness for blocked work. Never abandon publishers.
+
+2. **F-E: recover drill access and retain journals.**
+ Owner: agent manager. Trigger: the next partition drill.
+ Evidence: findings F-E and the lost holder journal in drill 4.
+ Finish: the harness restarts `amazon-ssm-agent` at fault expiry. Ship the
+ `carlos-edge` journal off-box during drills through the CloudWatch agent,
+ or copy it to S3 before termination. Verify access recovery and journal
+ retention after the fault and termination.
+
+3. **F-B: withdrawal shapes left pending by design.**
+ Owner: agent manager. Trigger: a request to support these shapes.
+ Evidence: `internal/activator/poolwithdrawal.go` and
+ `internal/provision/poolwithdrawal.go`. Pending cases include any HA row
+ with timer or duty state, a successor that consumed the marker before
+ observation with no local clean record, missing or deleted instance
+ records, unsupported owners, and a static-only box without an activator.
+ There is no live-box duty transfer. The operator path today is to leave
+ the host fenced: it no longer serves or advertises.
+ Finish: a live-box duty transfer design and evidence that each supported
+ shape can complete withdrawal without losing duties or dropping an
+ unfinished stop/release handle.
+
+4. **F-B: crash recovery on an ineligible holder (review P3-3).**
+ Owner: agent manager. Trigger: the card/runbook update before another
+ drill with a previously ineligible holder.
+ Evidence: findings F-B, leo's generation 207, and dispatch review P3-3.
+ An ineligible box that crashes while holding an HA lease has no automatic
+ recovery. It may not re-take the lease. Eligible peers need EC2 termination
+ proof while that box is still live.
+ Finish: the card/runbook tells the operator to restart it cleanly for a
+ clean release, or terminate it. Neither route relaxes pool eligibility.
+
+5. **T1: instrument termination before changing shutdown.**
+ Owner: agent manager. Trigger: before changing stop order or
+ `TimeoutStopSec`; resolve before G5.
+ Evidence: findings T1; `internal/host/units/carlos-instance-gen@.service`
+ has `After=carlos-edge.service`. The drill 1 and 2 journals were lost.
+ Finish: run an instrumented terminate drill with retained journals, then
+ use that evidence to decide any ordering or timeout change.
+
+6. **F-A: an unexpired lease still permits forwarding to a hung holder.**
+ Owner: agent manager. Trigger: a later forwarding-latency investigation.
+ Evidence: `internal/activator/hacache.go`,
+ `internal/activator/haleaseloss.go`, `internal/edge/forwardha.go`, and the
+ F-A controller ruling in the Task 12 dispatch.
+ Silence suspicion no longer refuses a same-holder unexpired lease. A
+ truly hung holder with a valid lease can still hang forwarded clients
+ until expiry, as before this branch. The holder-side lost-lease 503
+ covers the drill-4 case.
+ Finish: measure the remaining hang and decide whether to measure the
+ three seconds from `GotConn` instead of dispatch. Preserve the rule
+ against replaying uncertain requests.
+
+7. **Copy: revisit C1 in the next copy round.**
+ Owner: agent manager. Trigger: the next shared refusal-copy review.
+ Evidence: `/home/paulca/.cache/region-ha-next/g2fix/luna-result.md`, C1.
+ Luna suggested: "This service is temporarily unavailable. Please try
+ again shortly." The controller retained the existing approved C1.
+ Finish: review the suggestion across existing pages before changing the
+ shared `internal/edge/haingress.go` constant.
+
+8. **Deferred minor: forwarding checks take the activator lock.**
+ Owner: agent manager. Trigger: a routing-performance investigation.
+ Evidence: `forwardTarget` in `internal/activator/haforward.go` takes
+ `a.mu` and scans startup obligations on every edge decision, including
+ non-HA routes.
+ Finish: measure the cost and, if needed, reduce it while preserving
+ startup and lease-loss refusals.
+
+9. **Tooling: establish a usable OpenTofu gate.**
+ Owner: agent manager. Trigger: the next infrastructure test-tooling pass.
+ Evidence: `scripts/region_group_contract_test.py` fails with
+ "fixed resource attributes changed from Task 2 base" under OpenTofu
+ 1.13.9 and AWS provider 6.57.1 on main `25ca6faf` too. This is pre-existing.
+ Module mock tests need OpenTofu >= 1.13; 1.12.5 rejects indexed mocks.
+ CI has no OpenTofu.
+ Finish: resolve the baseline failure and provide a pinned, compatible
+ toolchain with a recorded contract and module-mock test result.
+
+10. **F-C: write fencing remains outside this branch.**
+ Owner: agent manager. Trigger: before G5.
+ Evidence: `G2-FINDINGS.md`, F-C, at the path above.
+ Finish: complete the write-fence work and spec text required there.
+ No new design is proposed here. The 300 s promise text is unchanged.
+
+11. **G3 card: authorize and verify both US page sinks.**
+ Owner: G3 card owner. Trigger: before G3, under its separately approved
+ scope. Evidence: findings F-D and the Task 12 dispatch.
+ Copy this card item verbatim:
+
+ > Before G3, grant sns:Publish on the US group alerts topic arn:aws:sns:us-east-1:271376211898:carlos-flagship-us-ha-alerts to the US group role carlos-flagship-us-ha and adi-knitting's fixed role carlos-flagship-host-us. Configure and verify both page sinks against that same topic. Record the two identity-policy grants, preserve the CloudWatch/EventBridge topic statements, and verify page delivery under the separately approved G3 scope. Target the suspect log/page at L+10 under continuous probes and the alarm at L+12. Do not add ha to adi's CARLOS_POOLS.
+
+ The IE dev grants are in pinfra PR #72, not merged or applied. Fixed
+ boxes' sinks must be set to the group topic and read back.
+ Finish: record the grants, sink readbacks and page-delivery evidence on
+ the G3 card. L is the observed lease expiry.
+
+## Seeded escalation locations
+
+If stopping rule 2 selects simulation, extend
+`internal/sim/regionha/invariants_test.go` and `actions_test.go` for the
+pool/wake/withdrawal family. Call the real predicate, acquire and placement
+decisions. Use `internal/activator/hasuspect_test.go` for cache epoch
+sequences, `internal/lease/renew_attempt_test.go` for renew/pause/late-ack
+order, and `internal/activator/hasuspectholder_test.go` for expiry, owner and
+generation sequences. Require fixed seeds and a failing mutation. A new
+simulation does not reopen a closed review round.
diff --git a/internal/activator/hasuspectholder.go b/internal/activator/hasuspectholder.go
index 1beaba249..473ecdba6 100644
--- a/internal/activator/hasuspectholder.go
+++ b/internal/activator/hasuspectholder.go
@@ -168,6 +168,6 @@ func (b *ExecBackend) SuspectHolderHosts(now time.Time) int {
const suspectHolderLog = "activator: ALERT %s: the host has been refused for over 10 minutes. Its lease belongs to instance %s, which is not confirmed terminated. (ha_suspect_holder)"
const suspectHolderSameBoxLog = "activator: ALERT %s: the host has been refused for over 10 minutes. This box could not prove its earlier processes for it have stopped. (ha_suspect_holder_same_box)"
const suspectHolderSubject = "Instance %s is holding hosts it does not serve."
-const suspectHolderBody = "Instance %s has an expired lease and is not confirmed terminated. These hosts have leases that expired at least 10 minutes ago: %s. If the instance is in an Auto Scaling group, terminate it in its group. If it is a fixed box, check its storage access and agent first. This page repeats every hour while the hosts remain refused. (ha_suspect_holder)"
+const suspectHolderBody = "Instance %s has an expired lease. EC2 has not confirmed that this instance terminated. The leases for these hosts expired at least 10 minutes ago: %s. If the instance is in an Auto Scaling group, terminate it in that group. If it is a fixed box, check its access to S3 and its agent first. This page repeats every hour while takeover remains refused. (ha_suspect_holder)"
const suspectHolderSameBoxSubject = "Box %s cannot recover hosts after a restart."
-const suspectHolderSameBoxBody = "This box could not prove that its earlier processes for these hosts have stopped: %s. Their leases expired at least 10 minutes ago. No other box may take them without proof. If this box is in an Auto Scaling group, terminate it in its group. If it is a fixed box, check the agent's startup sweep and cgroup delegation. This page repeats every hour while recovery remains refused. (ha_suspect_holder_same_box)"
+const suspectHolderSameBoxBody = "This box could not prove that its earlier processes for these hosts have stopped: %s. Their leases expired at least 10 minutes ago. No other box may take them without proof. If this box is in an Auto Scaling group, terminate it in that group. If it is a fixed box, check the agent's startup sweep and cgroup delegation. This page repeats every hour while takeover remains refused. (ha_suspect_holder_same_box)"
diff --git a/internal/activator/hasuspectholder_test.go b/internal/activator/hasuspectholder_test.go
index 5f20c21b3..d9d1108bb 100644
--- a/internal/activator/hasuspectholder_test.go
+++ b/internal/activator/hasuspectholder_test.go
@@ -79,7 +79,8 @@ func TestSuspectHolderThresholdAndHourly(t *testing.T) {
}
now = start.Add(10 * time.Minute)
suspectRefuse(t, b, rt)
- if got := pages.snapshot(); len(got) != 1 || got[0].subject != "Instance i-b is holding hosts it does not serve." {
+ wantBody := fmt.Sprintf("Instance %s has an expired lease. EC2 has not confirmed that this instance terminated. The leases for these hosts expired at least 10 minutes ago: %s. If the instance is in an Auto Scaling group, terminate it in that group. If it is a fixed box, check its access to S3 and its agent first. This page repeats every hour while takeover remains refused. (ha_suspect_holder)", "i-b", rt.Host)
+ if got := pages.snapshot(); len(got) != 1 || got[0].subject != "Instance i-b is holding hosts it does not serve." || got[0].body != wantBody {
t.Fatalf("crossing pages=%+v", got)
}
if n := b.SuspectHolderHosts(now); n != 1 {
@@ -259,7 +260,8 @@ func TestSuspectHolderSameBox(t *testing.T) {
now = now.Add(d)
suspectRefuse(t, b, rt)
}
- if got := pages.snapshot(); len(got) != 1 || got[0].subject != "Box i-a cannot recover hosts after a restart." || !strings.Contains(got[0].body, "ha_suspect_holder_same_box") {
+ wantBody := fmt.Sprintf("This box could not prove that its earlier processes for these hosts have stopped: %s. Their leases expired at least 10 minutes ago. No other box may take them without proof. If this box is in an Auto Scaling group, terminate it in that group. If it is a fixed box, check the agent's startup sweep and cgroup delegation. This page repeats every hour while takeover remains refused. (ha_suspect_holder_same_box)", rt.Host)
+ if got := pages.snapshot(); len(got) != 1 || got[0].subject != "Box i-a cannot recover hosts after a restart." || got[0].body != wantBody {
t.Fatalf("same-box pages=%+v", got)
}
if len(haFixOf(b).fx.Requests()) != before+2 || lockWrites(t, b, rt) != 0 {