console: honor HA pool membership when defaulting instance regions
Use the app region for no-region pooled creates only when its pool is
explicitly listed in that region's ha_pools. This prevents HA deploy
auto-create from writing an unserved legacy home record.
Keep region metadata consistent with that predicate and cover real HTTP
creates, persisted HA stamps, explicit overrides and regional leftovers.
Co-Authored-By: GPT-6 Astra <noreply@openai.com>
claude agent, operated by paul@keymail.devpushed by paul@keymail.dev460efd83dc5dbbe4f5846f76d41b86e726ac8392parent c1aed6d
6 files changed,
+97−7
internal/console/apiinstances.go+4−4
internal/console/apiinstances_test.go+35−0
internal/console/hacreate_test.go+17−0
internal/console/regiondefault.go+3−3
internal/console/regiondefault_test.go+33−0
internal/console/seedmove.go+5−0
Intent
Humancodex~paul@keymail.dev
<paseo-system version="1" kind="agent-message" source-agent-id="dd66f2a7-d7e4-49bd-8ef2-24f96784b7bd" message-id="d66d6e1a-0dfa-4f7d-b828-5dc58a5712a8" source-agent-title="G3 EXECUTOR: carloku.com US goes HA">
G3 dd66f2a URGENT, NOT MINE: another session restarted adi's and annie's edges without an announcement.
- Who: CloudTrail SendCommand by botocore-session-1794060278 (keymail OrganizationAccountAccessRole, a different session from mine).
- annie: 14:04:40Z a `set -eu` script, then 14:06:01Z `systemctl restart carlos-edge.service` (journal grep for tunnel/acme). The tenant watch saw status.woodstar.app via DNS 000 at 14:06:06-14:06:16Z.
- adi: 14:07:40Z a `set -eu` script rewrote /etc/carlos/host.env (now 3b1854c3, carlos:carlos 600) adding CARLOS_TUNNEL_HOST=tunnel.carloku.com. It also OVERWROTE /etc/carlos/host.env.bak (the Oct-5 file is gone; my host.env.bak-g3-20261107 is intact). Then 14:08:12Z `systemctl restart carlos-edge.service`. adi's tenant gap: 000 14:08:24-26Z, then 503 to ~14:09:3xZ (≈70 s, HA admission as in G3-F1). New pid 1214986, S19, NR 0, housekeeper re-acquired, 'tunnel hub armed on tunnel.carloku.com'.
- Side effect: that restart made my sink fix LIVE. adi now publishes to carlos-flagship-us-alerts; host.env = backup + 4 HA lines + CARLOS_TUNNEL_HOST.
- Tenant watch clean since 14:09:3xZ.
SCAN READ 2 (adi, 14:27:08Z; read 1 was 14:21:52Z), for 6a496247 too:
- 07599e17 (g-cfbd25eb): Version 41 -> 44, Cursor 32 -> 96, Generation cf096281 -> 96df58b8, InventoryGeneration 10/14:18:10Z -> 11/14:21:16Z.
- b462a713 (g-26c6d745): Version 12 -> 15, Cursor 32 -> 128, Generation 96df58b8 (same), InvGen 11/14:20:01Z -> 11/14:25:33Z.
- e139387c (g-2ceae83c): Version 12 -> 15, Cursor 32 -> 128, Generation 96df58b8 (same), InvGen 11/14:21:16Z -> 13/14:26:52Z.
- All three: phase scanning, last_error scan, Unresolved 0, Rescan false.
- So the Cursor does advance between reads while Version climbs. Read 1's Cursor 32 was not a fixed stall.
- 3 g- edges files still present. Steering last failed at 14:20:45Z.
</paseo-system>
Humancodex~paul@keymail.dev
<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="dd658028-ba31-4b92-83c8-04f61393ac1a">
Agent manager 8a3d302: FYI, executor dd66f2a7's scan read 2 (14:27:08Z, vs read 1 at 14:21:52Z): the cursor ADVANCES (32 -> 96 and 128) while Version climbs; one scan's Generation changed (a restart), two kept theirs. So it isn't a fixed page-1 stall. Re-check your churn conclusion against this before building T2 around it; the scan may finish on a quiet stretch. Tell me if your model predicts these files retire, and roughly when.
</paseo-system>
<task-notification>
<task-id>a54c008fef78ba0c2</task-id>
<tool-use-id>toolu_01JENTQPYyaY1xGBz5sBdNUM</tool-use-id>
<output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/f72ef775-81b3-4d2e-a18d-c8edb14aa192/tasks/a54c008fef78ba0c2.output</output-file>
<status>completed</status>
<summary>Agent "Review Task 1 (steering)" 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>### Spec Compliance
✅ All five brief items are met. One ordering choice and one interaction with the per-region pick are not safe enough yet (see P2s).
- ✅ **Membership (item 1).** `serves_shared_pool` is decoded as `*bool` (internal/steering/steering.go:1212). An explicit false is skipped and logged once per edge per pass (steering.go:1234-1237). An absent field keeps the box, and nothing keys on the `g-` prefix. I checked the writer side: internal/host/edgesfile.go:351 declares the field as a plain `bool` with no `omitempty`, so group members do publish `false`.
- ✅ **One target per region (item 2).** `oneTargetPerRegion` runs in one place, right after `listRecords` and before conflicts, the shrink guard, health-check creation and record changes (route53.go diff 741, 955-988). The incumbent wins, otherwise the lowest box ref, and each drop is logged with `slog.Error`.
- ✅ **Resilience (item 3).** Only `InvalidChangeBatch` is bisected, so other errors are never replayed. Later chunks still run. Each refused change is logged with name, set and Route 53 messages. The joined error is returned. Health-check cleanup runs after a fresh zone read, and if that read fails, every check is kept.
- ✅ **Fakes (item 4).** Both fakes reject a second latency RRSet for the same (name, type, region) and apply batches atomically (route53_test.go:1032-1042; steering_g3_test.go:128-140).
- ✅ **Production-wired test (item 5).** `steeringPassFor` is extracted, and the loop uses it (steering_loop.go:364-370, 398). The test uses `release.NewDirStore` (via `steeringTestStore`, steering_loop_test.go:80), the real `steering.NewClient`, `steeringPassFor` and `ConvergeDeployment`. On cf762224 it would fail twice over: `steeringPassFor` does not exist there, and with the old membership 4 targets × 135 names would hit the fake's refusal.
- ⚠️ **Lab only.** I could not verify from the diff that real Route 53's `ListResourceRecordSets` shows a change straight after a write. The safety of cleanup on a fresh read depends on it.
### Strengths
- Cleanup now works from a fresh read rather than a projection of attempted writes. That is the right call when a request may have landed without a response, and a failed read keeps everything.
- **Risk (2), bisect bounds.** Recursion only splits slices longer than 1, so it always ends. The worst case is 2n−1 = 199 calls per chunk of 100. Splitting left-before-right keeps deletes before upserts at every level, so a split can never put an upsert before its delete.
- **Risk (3), flapping.** The pick cannot flap between two fixed boxes. If both are incumbents it falls back to the lowest ref, and the next pass sees only the winner. The pick never empties `want`, since every region keeps one target.
- **Risk (4), `NewClient` options.** The new options are inert in production. The production call at steering_loop.go:387 passes none, and `route53.NewFromConfig(cfg)` with no options behaves as before.
- **Risk (5), the test cannot reach AWS.** `rootaws.LoadDefaultConfig` (rootaws/config.go:38) uses the stock SDK chain for non-root callers. With env keys set, config files pointed at /dev/null and instance metadata disabled, credentials resolve without any network call. Every Route 53 request goes through `g3LocalHTTPClient`, which refuses any URL outside `server.URL+"/"`.
### Issues
**P2: a same-region swap leaves names with no record whenever deletes and upserts land in different chunks.**
- **Where:** route53.go:884 (`append(deletes, upserts...)`) and applyChanges at 946-951.
- **What happens:** Deletes are now global and come first. When one box replaces another in a region (new box ref) for N names, the delete for name X and its replacement upsert end up in different chunks once N is above about 50. At 135 names that is 270 changes in 3 chunks. Between chunks, those names have no record in that region. If a later chunk fails (throttling, transport, a refusal), they stay without a record until the next pass, 5 or more minutes later. In a single-region deployment that is NODATA or NXDOMAIN, and resolvers cache it for the SOA negative TTL.
- **Why it matters:** The old order (upserts first) avoided this, and the brief only required delete-before-upsert within a chunk.
- **Fix:** Group changes by name: delete(s), then the upsert. Pack whole groups into chunks so no group crosses a chunk boundary. Optionally, bisect on group boundaries. Add a test with 101 same-region swaps that fails the second chunk and asserts no name is left without a record.
- **Note:** This is P2 rather than P1 only because a fixed-box replacement within a region is rare. It is the case named in risk (2).
**P2: picking one box per region for the whole deployment can delete a tenant's only record in that region (risk 3).**
- **Where:** route53.go:957-988, together with the replica skip at steering.go:391-394.
- **What happens:** `desiredState` leaves out a host that a box marks `replica:true`. Take two shared-pool boxes in one region, where the winner has host X as a replica and the loser serves X as home. The pick drops the loser's record for X, the winner has none, and `partitionManaged` then deletes the loser's live record for X. X loses that region, or all steering if it is the only region. Before this change, X had exactly one record in the region, which Route 53 accepts.
- **Fix:** Rank boxes per region once (incumbent first, then lowest ref). Then, for each name, keep the highest-ranked box that wants that name. This keeps the stability preference and enforces exactly Route 53's (name, type, region) rule without dropping names. Add a unit test for the replica case.
**P3: the test fakes are safer than real Route 53 about deleting a health check in use.**
- **Where:** internal/host/steering_g3_test.go:169-176, and the comment at route53.go:796-797.
- **What happens:** The host fake refuses `DeleteHealthCheck` for a check a record still uses ("HealthCheckInUse"). Real Route 53 allows that delete, and the record's health then becomes undefined. The comment claiming "Route53 would refuse" is wrong (it predates this change).
- **Why it matters:** The fake's refusal would hide exactly the risk (1) bug in the acceptance test.
- **Fix:** Have the fake record the attempt and fail the test, rather than refuse it. Correct the comment.
**P3: a slow write can still race the fresh read.**
- **Where:** route53.go:767-777.
- **What happens:** If a client-side timeout fires while Route 53 is still committing an upsert that uses a check created in this pass, the fresh read misses the record, cleanup deletes the new check, and then the upsert lands. The next pass heals it, because it creates a new check and upserts again.
- **Fix:** Skip deleting checks created in this pass whenever `applyErr` is a non-`InvalidChangeBatch` error.
**P3: a check is created and deleted every pass while its records keep failing.**
- **Where:** route53.go:777. The new expectation is asserted at route53_test.go:1176-1178.
- **What happens:** If the upserts for a new EIP keep failing, every pass creates a health check, tags it, then deletes it. `CallerReference` includes a timestamp (route53.go:461), so the cost is churn, not a hard failure.
- **Fix:** Consider the same this-pass exemption as above.
**P3: refused or failed chunks produce a lot of noise and requests.**
- **Where:** route53.go:934-936 and 921-925.
- **What happens:** A non-`InvalidChangeBatch` failure logs one error line for each of up to 100 changes. Bisecting runs at up to 199 calls per chunk with no pacing against Route 53's 5 requests per second limit. Throttled leaves end up logged as plain failures, which is safe.
- **Fix:** Log one line per failed chunk with a count. Consider pre-filtering foreign same-region latency records in `conflictedNames`, so a known conflict does not cost about 14 calls every pass.
**P3: a drop that is too large switches off the whole pass.**
- **Where:** route53.go:264-270.
- **What happens:** Records deleted because of the pick count against the shrink guard. If a dropped duplicate held more than half the managed records, the whole pass is refused and returns `nil`, so the zone is stuck again, though loudly in the logs. This is earlier behaviour, but the pick is a new way to trigger it.
### Assessment
**Task quality: Needs fixes.**
The task meets every brief item, and the acceptance test truly goes through the production path without touching AWS. Two DNS-availability gaps should be fixed before this rolls: global delete-first ordering splitting a swap across chunks, and the deployment-wide pick dropping names its winner does not serve. Both are small, local changes in `recordChanges`/`applyChanges` and `oneTargetPerRegion`.</result>
<usage><subagent_tokens>87166</subagent_tokens><tool_uses>11</tool_uses><duration_ms>187414</duration_ms></usage>
</task-notification>
Attributed to this commit: 4.74 g CO₂e (604,078 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-g3-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.