carlos / platform Public

region HA G2 prep: build plan (Tasks 1-8)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 81324281dff4b69173cc5a6f51514de89643fd03 parent 0641fd8
1 file changed, +528 −0
  • docs/superpowers/plans/2026-11-05-region-ha-g2-prep.md +528 −0

Intent

Human

<task-notification> <task-id>b2yogjele</task-id> <tool-use-id>toolu_01XWXBNrfnfQ6UuxqBvxgcHF</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/dc71bafb-7376-4e4b-a855-4d32f1eed771/tasks/b2yogjele.output</output-file> <status>completed</status> <summary>Background command "Wait for T8 branch CI verdict" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>bl23amb9o</task-id> <tool-use-id>toolu_01Xbo5VZC4hvXQEjgQYqVZqc</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/dc71bafb-7376-4e4b-a855-4d32f1eed771/tasks/bl23amb9o.output</output-file> <status>completed</status> <summary>Background command "Push and wait for CI on both branches" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 42.3 g CO₂e (4,866,233 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-g2-prep, 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/plans/2026-11-05-region-ha-g2-prep.md b/docs/superpowers/plans/2026-11-05-region-ha-g2-prep.md
new file mode 100644
index 000000000..c8aebd189
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-05-region-ha-g2-prep.md
@@ -0,0 +1,528 @@
+# Region HA G2 prep: build plan
+
+Controller plan for the G2/G3 prep build (branch `region-ha-g2-prep`, from
+origin/main e129f535). Sources: `~/.cache/region-ha-next/G2-CARD.md`
+(blockers T1-T10), `G3-CARD.md`, the addendum on branch
+`region-ha-g2-addendum` (762ae83c), spec
+`docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md`
+(rev 6.2: §9.7 clock, §13 precondition 3, §20 suspect holders).
+
+Rulings that bind this plan (Paul via agent manager 8a3d302, 2026-11-05):
+- G2 acceptance = the four I4 drills plus the riding rows; drain, role and
+ readiness carry to G3/P6/G5.
+- T8 first, merged before the v0.34.6 cut. T3 aims for the same cut.
+- G3 code only: chrony in host-init and the group boot template; a diagnostic
+ readiness check for §13 precondition 3 over a named pool's hosts.
+- Operator tools T1, T2, T4, T6 as reviewed, dev-only scripts that touch
+ nothing at build time.
+
+## Global Constraints
+
+- Go: run only touched packages' tests with `-run`. Never `go test ./...`.
+ Leave GOCACHE at its default. Socket-binding packages (activator, edge,
+ host) need `TMPDIR=/tmp/g` (mkdir it) and run outside the sandbox.
+- The build must still cross-compile for darwin and windows
+ (`GOOS=darwin go build ./...` and `GOOS=windows go build ./...` on the
+ packages touched); linux-only code goes behind build tags.
+- No cloud reads or writes, no AWS calls, no releases, applies or drills at
+ build time. Scripts are written and tested offline only.
+- No tenant or customer names in code, docs or tests: use neutral examples.
+- User-facing strings (log lines an operator reads, page subjects, CLI
+ output) follow house voice: no em dashes; full stops.
+- Commit subjects under 80 characters.
+
+## Task 1: T8, names-2 release pin for fixed-box updates
+
+**Why.** `internal/host/systemleg.go:329-362`: while any group (`g-`) edges
+namespace exists, a fixed box's automatic system update proceeds only when the
+target artifact's SHA-256 is in `firstNames2Release.Digests[platform]` and the
+version is at or above `FirstRelease`. `firstNames2Release` is empty today, so
+fixed boxes refuse EVERY update while a group lives. A digest list alone cannot
+name future releases, so a box would still refuse every later release.
+
+**Ruling (8a3d302 for Paul, 2026-11-05): digests plus release tags.**
+
+1. Pin v0.34.5 as the first names-2 release with its verified digests:
+
+ ```go
+ var firstNames2Release = namesReleasePin{
+ FirstRelease: "v0.34.5",
+ Digests: map[string][]string{
+ "linux-arm64": {"310ab5b97a52fa0d4c033393c3d2649adeda2c53e842fff81cd0c7ef57e16cd4"},
+ "linux-amd64": {"400d62739efe8994f93d0ca96dc3a6d0d499e6f4ea53db64069177dea8360176"},
+ },
+ }
+ ```
+
+ These match the public release's SHA256SUMS.txt
+ (github.com/carlosframework/releases v0.34.5), the release build's local
+ dist, and (linux-arm64) the dev stable pointer. Keep the comment above it
+ true: say what was pinned, from where, and how a later local build is
+ added.
+
+2. ALSO accept a target whose signed pointer release says it came from the
+ console's public-release ingest: `SystemRelease.Source == "release:" +
+ SystemRelease.Version`, where Version matches `^v[0-9]+\.[0-9]+\.[0-9]+$`
+ exactly (reuse `publicrelease.TagRe` if the import is clean, otherwise an
+ equal local regexp) AND parses at or above `FirstRelease`. The console sets
+ that Source only after it fetched the public release and checked its
+ checksums (`internal/console/apisystemupdate.go:536-560`); the pointer is
+ ed25519-signed. Verified 2026-11-05 on the real dev and flagship
+ `control/system/router/stable.json`: every current and history release
+ has `source: "release:<version>"` and no `release_tag`.
+3. Refusals that must hold: a pre-release or otherwise unparseable version
+ (`v0.35.0-rc1`, `0.35.0`, `v0.35`) never passes by Source; a Source of
+ `"file"` (local upload), empty, or a mismatched tag (`release:v0.35.0`
+ on Version `v0.36.0`) needs a pinned digest; a release-sourced version
+ below `FirstRelease` refuses; an empty `FirstRelease` refuses everything
+ (unchanged). The freshness, `groupObserved` and `hasGroup` rules above
+ the version check stay exactly as they are.
+4. Carry the Source into `systemPending` at observe
+ (`systemleg.go:161`) and in the attended group prepare path
+ (`internal/host/group_maintenance_prepare.go:183`), so both callers see
+ the same evidence. Do not change any other caller.
+5. Tests in `internal/host/systemleg_test.go` (extend
+ `TestSystemLegGroupReaderRollback` or add `TestSystemLegNames2ReleasePin`),
+ driving the real observe → tick path with a signed pointer as the
+ existing tests do:
+ - the production `firstNames2Release` value: v0.34.5 linux-arm64 digest
+ passes with a live group namespace;
+ - a release-sourced v0.34.6 with an unknown digest passes;
+ - a release-sourced v0.34.4 refuses; `file` source v0.34.9 with an
+ unknown digest refuses; `file` source with the pinned digest passes;
+ mismatched Source tag refuses; pre-release and unparseable versions
+ refuse by Source;
+ - refusals mean zero artifact fetches, request writes and marker touches
+ (use the existing counters).
+ Watch each new refusal test fail first against a mutation (for example,
+ drop the Source tag equality) and record it in the report.
+6. Run: `TMPDIR=/tmp/g go test ./internal/host -run 'TestSystemLeg|TestGroupReadersReady|TestGroupMaintenance' -count=1`
+ plus `GOOS=darwin go build ./internal/host/ ./cmd/...` and the same for
+ windows. If `internal/host` census tests exist for `systemleg.go`
+ (`git grep -n systemleg internal/provision/*census*`), run them too and
+ report whether the root-read census changed.
+
+## Task 2: T3a, suspect-holder tracking and page (spec §20)
+
+**Controller ruling (2026-11-05):** page visitor refusals and refused same-box recoveries only; refusals that never reach a proof (legacy lock, owner without an instance id) are reported by Task 5, not paged. Final copy for T3-L1..T3-P4 and T3-R1 is in `.superpowers/sdd/2026-11-05-region-ha-g2-prep/copy-t3.md` once the copy pass lands; until then use the draft text below.
+
+**Why.** Spec §20 says: "Suspect holders: any host refused for over 10 minutes for a lease whose owner is not confirmed dead, including a refused same-box recovery (§9.6). The runbook says terminate that box in its group (§9.5)." §9.5 says the alarm "fires after 10 minutes".
+
+What exists today:
+- **Visitor refusals.** A refused takeover is logged at most once a minute per host. `reportTakeover` calls `takeover.alarm` (`internal/activator/hatakeover.go:41-65`, `:87-102`).
+- **Finalizer refusals.** Only `departure-finalize` refusals page, hourly per host (`hatakeover.go:52-64`, `claimPage` at `:108-119`).
+- **Same-box refusals.** These log only (`internal/activator/hasamebox.go:68-77`, `alarm` at `:152-166`).
+- **Duration.** Nothing measures how long a host has been refused.
+
+Where refusals happen:
+- **Visitor path.** Every refused HA acquire of another box's expired lock reaches `reportTakeover`. This happens either through the `ownerTerminated` wrapper (`hatakeover.go:30-39`) or through `TerminationProofAdapter.Observe`, which is deferred so it always runs (`internal/lease/termination_proof.go:39-44`). Both are wired at `internal/activator/hawake.go:384-391` and `internal/activator/haadopt.go:300-304`.
+- **Same-box path.** A refused same-box recovery reaches `sameBox.alarm` (`hasamebox.go:71`).
+- **Clearing.** Every successful acquire passes `markAcquiredHere` (`internal/activator/backend_exec.go:825-827`).
+
+Visitor and duty wakes already pay one lock GET each, so tracking rides existing reads and adds no S3, EC2 or SQS request.
+
+**What to build.** New file `internal/activator/hasuspectholder.go`. Do not reuse the name `hasuspect`: `hasuspect_test.go` is the forward-dial "holder suspect" concept, which is a different thing.
+
+1. Add `suspectHolders` state on `ExecBackend`, beside `takeover` and `sameBox` (`backend_exec.go:398-401`). Keep it per host: first refusal, last refusal and owner instance id. Add a `now func() time.Time` test seam (nil means `time.Now`).
+2. Add `note(host, ownerIID string, sameBox bool, now)`:
+ - start the clock on the first refusal;
+ - restart it if the owner instance id changes, or if no refusal was seen for 30 minutes (2 × `lease.LeaseTTL`);
+ - when `now - first >= 10*time.Minute`, log once per crossing and try to page.
+3. Paging: at most once per owner instance per hour per box. Key the page on the owner instance id (self for same-box), not on the host, because the runbook action is per box. The body lists up to 10 hosts refused for that owner, sorted, then "and N more". Send through `b.Page` with `alerting.LevelWarning`, on a fresh 5 s context, as `hatakeover.go:59-63` does. If `b.Page` is nil, log only.
+4. Call `note` from:
+ - `reportTakeover`'s refused branch (`hatakeover.go:47`), **only when `cause == "visitor"`**. Finalizer refusals already page at `:52`; do not page them twice;
+ - `sameBoxEmpty`'s refusal branch (`hasamebox.go:70-72`), with the owner being this box's own instance id from `lease.CurrentSelf().IID`.
+5. Clear a host's entry:
+ - in `markAcquiredHere` (`hasamebox.go:170`), on any successful acquire;
+ - in `reportTakeover` when `gone && err == nil`.
+6. Export `func (b *ExecBackend) SuspectHolderHosts(now time.Time) int`. It counts hosts whose first refusal is at least 10 minutes old and whose last refusal is under 5 minutes old. Task 3 reads it. It must be safe to call concurrently and must hold no lock across I/O.
+7. Wiring: `b.Page` is set only by `armHADepartures` (`internal/host/hadepartures_wiring.go:169`). Also set `eb.Page = PageOperator` in `runAgent` beside `eb.OwnerTerminated` (`internal/host/agent.go:547-549`), so a box whose departure controller failed to arm still pages. Finalizer paging does not change, because finalizers only exist when departures are armed.
+8. Runbook: add a section "A box is holding hosts it does not serve (ha_suspect_holder)" to `docs/region-ha-runbook.md`, with the steps for a group member and for a fixed box (copy below).
+
+**Refusals that must hold.**
+- No page before 10 minutes of refusals, and none for a host whose acquire succeeded in between.
+- No page for `departure-finalize` refusals: they keep their existing immediate hourly page.
+- No new S3, EC2 or SQS call anywhere in the change. `sameBoxEmpty` stays S3-free (`hasamebox.go:66-67`).
+- The tracker never changes a decision. Lock writes on refused wakes stay zero (`TestTakeoverDescribeFailureKeepsHostDown` asserts `lockWrites == 0`).
+- The existing log lines at `hatakeover.go:100-101` and `hasamebox.go:165` stay byte-identical. Grep-based tooling reads them.
+- Pages are never sent on a context the scan may already have spent.
+
+**User-facing strings (one copy pass, house voice: no em dashes, full stops).**
+
+| id | where | text |
+|---|---|---|
+| T3-L1 | log, first crossing per host | `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)` |
+| T3-L2 | log, same box | `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)` |
+| T3-P1 | page subject | `Instance %s is holding hosts it does not serve` |
+| T3-P2 | page body | `Instance %s let its leases expire and is not confirmed terminated. These hosts have been down for over 10 minutes: %s. If the instance is in an Auto Scaling group, terminate it in its group. The hosts then move to a surviving box. If it is a fixed box, check its storage access and its agent first. This page repeats every hour while the hosts stay down. (ha_suspect_holder)` |
+| T3-P3 | page subject, same box | `Box %s cannot recover hosts after a restart` |
+| T3-P4 | page body, same box | `This box could not prove that its earlier processes for these hosts have stopped: %s. No other box may take them, so they have been down for over 10 minutes. If the 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 the hosts stay down. (ha_suspect_holder_same_box)` |
+| T3-R1 | runbook heading and body | heading as in step 8, plus a three-step body: confirm in EC2, terminate a group member with `--no-should-decrement-desired-capacity`, never terminate a fixed box without a separate decision. |
+
+**Tests.** New file `internal/activator/hasuspectholder_test.go`, driving the production `Acquire` through `takeoverBackend` (`hatakeover_test.go:51-63`) with a `terminatedOracle` that answers "not terminated", and a fake clock on the tracker:
+- 9m59s of refusals: zero pages. 10m: exactly one page, whose subject names the owner instance. Further refusals within the hour: no page. At +1h: one more page.
+- Two hosts with the same owner: one page listing both. A different owner: a separate page.
+- The oracle flips to terminated and the acquire succeeds: the entry is cleared. A later refusal for a new owner starts again at zero, with no page before 10 minutes.
+- `cause == "departure-finalize"` (context `adoptionCauseKey{}`): no suspect page. `TestTakeoverPageHourlyPerHost` and `TestTakeoverPageSurvivesSpentScanContext` (`hatakeover_page_test.go`) are unchanged and still pass.
+- Same box: drive `sameBoxEmpty` refusals (the `hasamebox_test.go:41` setup) to 10 minutes. Expect one T3-P3 page.
+- `SuspectHolderHosts`: 0 before 10 minutes; 1 after; 0 again 5 minutes after the last refusal.
+- `lockWrites == 0` throughout. The page receives a context with a deadline.
+- A concurrency test: 20 goroutines refusing the same host at the crossing produce one page (the pattern of `hatakeover_page_test.go:13-38`).
+
+Failing first: run the suite against two mutations and record both in the report:
+- remove the `>= 10*time.Minute` check: the 9m59s test must fail;
+- remove the clear in `markAcquiredHere`: the recovery test must fail.
+
+**Run.**
+```
+mkdir -p /tmp/g
+TMPDIR=/tmp/g go test ./internal/activator -run 'TestSuspectHolder|TestTakeover|TestSameBox|TestNoTakeover|TestAcquireMarks|TestRestartedAgent|TestAbandonedAgent' -count=1
+TMPDIR=/tmp/g go test ./internal/host -run 'TestArmHADepartures|TestAgent' -count=1
+GOOS=darwin go build ./internal/activator/ ./internal/host/ ./cmd/...
+GOOS=windows go build ./internal/activator/ ./internal/host/ ./cmd/...
+go test ./internal/provision -run 'TestPlan14RootReadCensus$' -count=1
+```
+**Census: touched.** Expect `ExecBackend.reportTakeover` and `ExecBackend.sameBoxEmpty` sites and body (+registry:Host). Expect the `runAgent` body, and envelope re-pins for `internal/activator` and `internal/host`. Run `make census-card`, write a CLAIMS file ("no new read; reads only the existing route Host and the classified owner instance id; pages through the existing sink"), then `make census-propose NAME=region-ha-g2-t3a CLAIMS=<file>`. An Astra reviewer approves on #280.
+
+---
+
+## Task 3: T3b, the suspect-holder metric and group alarm
+
+**Ruling (8a3d302 for Paul, 2026-11-05):** fold the alarm into G0. Expected G0 counts are now 1 to add, 2 to change, 0 to destroy; the gate allow-list gains the alarm (this task). The G2 card is already updated.
+
+**Why.** The Task 2 page goes through `PageOperator`, which uses `alerting.Page` (`internal/host/alertsink.go:137-139`, `internal/alerting/alerting.go:191-196`). Group members have no sink:
+- `group-init.sh.tftpl` writes no `CARLOS_ALERT_SNS_TOPIC_ARN` or `CARLOS_ALERT_WEBHOOK`;
+- `group_iam.tf` grants no `sns:Publish`;
+- so `Sinks.Page` logs "no sink configured" and returns nil (`alerting.go:118-123`).
+
+In G2 the fixed boxes withdraw `hapair` (card G1.3), so only members see the refusals. A page from Task 2 alone reaches nobody.
+
+The group's established path is a datum in the existing one-per-minute `PutMetricData` batch, plus a CloudWatch alarm to the group topic. Examples are the clock samples (`internal/host/group_metrics.go:159-182`, appended at `internal/host/memwatch.go:157-165`) and the `group_clock` alarm (`infra/modules/region-host/group_alarms.tf:92-108`). This adds no API call. It adds one custom series (about $0.30 a month) and one alarm ($0.10 a month).
+
+**What to build.**
+1. Add `SuspectHolderHosts int` to `groupadmission.Observation` (`internal/groupadmission/observation.go`). Fill it in `admissionMetrics.observe` (`group_metrics.go:50-60`) from a new `suspects func(time.Time) int` field. Nil means 0. Wire it in `memwatch.go:128` from the agent's `*activator.ExecBackend` (Task 2's `SuspectHolderHosts`) through a package-level `atomic.Pointer` set in `runAgent`. This follows the `processAlertCounters` seam pattern (`alertsink.go:69-72`).
+2. In `groupMetricData` (`group_metrics.go:159`), append `datum("SuspectHolderHosts", n, Count, dims)` with the group dimension only. Do not change the fixed-box `admissionMetricData` (`group_metrics.go:63-74`): fixed boxes page through their own sinks.
+3. Add the alarm `aws_cloudwatch_metric_alarm.group_suspect_holder` in `group_alarms.tf`:
+ - count `var.mode == "group" ? 1 : 0`;
+ - `Carlos/Host`, `SuspectHolderHosts`, `Maximum`, period 60, 1 of 1, threshold 0, `GreaterThanThreshold`;
+ - **`treat_missing_data = "notBreaching"`**;
+ - actions `local.group_alarm_actions` (`:31`);
+ - dimensions `AutoScalingGroupName`.
+4. Add `('aws_cloudwatch_metric_alarm', 'group_suspect_holder')` to `GROUP_DISPOSABLE` in `scripts/check-region-group-plan.py:47-66`.
+
+**Refusals that must hold.**
+- Existing datums stay byte-identical, including the InstanceId-only memory and PSI datums. The existing pins in `group_metrics_test.go` stay green.
+- Switch-off and flagship boxes publish exactly the same `PutMetricData` input as before.
+- Missing data never alarms (members of an older release).
+- No second metrics loop and no per-box S3 object.
+- A gate plan naming any other new resource still refuses.
+
+**User-facing string.**
+
+| id | where | text |
+|---|---|---|
+| T3-A1 | `alarm_description` | `A group member has refused a host for over 10 minutes because its lease belongs to an instance that is not confirmed terminated. Read the members' ha_suspect_holder lines, then terminate that instance in its group.` |
+
+**Tests.**
+- `internal/host/group_metrics_test.go`: a group observation with `SuspectHolderHosts = 2` emits exactly one extra datum (name, unit, group dimension, value 2). A fixed admitted box's datums are unchanged. Nil `suspects` gives 0.
+- `infra/modules/region-host/tests/group_alarms.tftest.hcl`:
+ - extend the count-zero condition at `:65`;
+ - extend the action and missing-data check at `:219` with an explicit `notBreaching` case for the new alarm;
+ - extend the shape check at `:231-235`.
+- `scripts/check_region_group_plan_test.py`: a cleanup manifest naming `group_suspect_holder` inside a proven group module passes. One naming an unknown alarm still refuses.
+
+Failing first:
+- set `treat_missing_data = "breaching"`: the tftest must fail;
+- drop the datum: the Go test must fail.
+
+**Run.**
+```
+TMPDIR=/tmp/g go test ./internal/host -run 'TestGroupMetric|TestAdmission|TestMemwatch' -count=1
+go test ./internal/groupadmission -count=1
+(cd infra/modules/region-host && tofu init -backend=false && tofu test -filter=tests/group_alarms.tftest.hcl)
+python3 -m unittest scripts/check_region_group_plan_test.py scripts/group_alarm_plan_test.py
+GOOS=darwin go build ./internal/host/ ./cmd/... && GOOS=windows go build ./internal/host/ ./cmd/...
+```
+No applies. `tofu test` uses the mock providers already in those files. **Census: touched.** `infra/` is in scope whole-file, as are `internal/host` and `internal/groupadmission`. Use NAME `region-ha-g2-t3b`.
+
+**Controller note.** The alarm only exists after a targeted apply. If ruling 1 folds it into G0, update the card's expected counts to **1 to add, 2 to change, 0 to destroy**.
+
+---
+
+## Task 4: Chrony on fixed boxes (spec §9.7, G3 decision 5)
+
+**Ruling (8a3d302 for Paul, 2026-11-05):** converge script plus a written host-init diff for both infra repos (new boxes only). Never re-run user_data on a live box.
+
+**Why.** §9.7: "chrony (Amazon Time Sync) is required on every box ... each box publishes its chrony offset, and an alarm fires above 1 s".
+
+**Group boxes are already done.** No code change is needed for them:
+- `group-init.sh.tftpl:99` installs `chrony`;
+- `:151-170` writes `server 169.254.169.123 prefer iburst minpoll 4 maxpoll 4` to `/etc/chrony/conf.d/carlos-group.conf`, enables and restarts `chrony.service`, waits for a `^*`/`^+` source on 169.254.169.123, and runs `chronyc waitsync 20 2`;
+- this is pinned by `internal/host/group_boot_test.go:111`, `:221-222`, `:316` and `scripts/region_group_ssm_boot_test.py:18`.
+
+**The publisher exists.** It runs `/usr/bin/chronyc -c tracking` with a 4 KiB limit and a strict chrony 4.4 parse (`internal/host/group_metrics.go:76-145`), only where `CARLOS_GROUP_ADMISSION=1` (`:26-28`). The edge unit allows `AF_INET` (`internal/host/units/carlos-edge.service:51`), so UDP 127.0.0.1:323 works as `User=carlos` (P3 plan, P3-8).
+
+**Fixed boxes have no chrony.** Their first-boot script is the consumer's `var.user_data` (`infra/modules/region-host/main.tf:566-567`), kept in other repos: platform-infrastructure `dev/host-init.sh` and `.tftpl`, which install only `unattended-upgrades curl awscli` and zram, and the flagship carloku-infrastructure root. user_data never re-runs on a live box. On flagship a user_data diff stops and starts the box (G3 card, standing hazards). **So this repo cannot deliver "chrony in host-init". That is a capability cut.** What it can deliver is a reviewed root converge script that does exactly what the group template does, run by SSM on a named fixed box in an attended window.
+
+**What to build.**
+1. `scripts/region-ha-g3/chrony-fixed-box.sh` (bash, root, idempotent):
+ - refuse unless uid is 0 and `/etc/carlos` exists;
+ - `apt-get -y -q install chrony` with `NEEDRESTART_MODE=l` (this removes systemd-timesyncd through Debian's time-daemon conflict; print both packages' states before and after);
+ - write the same one-line conf to `/etc/chrony/conf.d/carlos-fixed.conf` through a staging file and `install -o root -g root -m 0644`;
+ - `systemctl enable chrony.service`, `systemctl restart chrony.service`;
+ - the same 20-try source wait and `chronyc waitsync 20 2`;
+ - then the sandbox witness: `systemd-run --wait --pipe --quiet -p User=carlos -p NoNewPrivileges=yes -p ProtectSystem=strict -p RestrictAddressFamilies='AF_INET AF_INET6 AF_UNIX' -p SystemCallFilter=@system-service /usr/bin/chronyc -c tracking`, printing its CSV.
+ It never restarts `carlos-edge`, never edits `host.env` and never reboots.
+2. Add a `--check` mode that reads only (package state, conf, sources, sandbox witness) and changes nothing.
+3. Runbook: add "Install chrony on a fixed box" to `docs/region-ha-runbook.md`, saying when to run it (before G3 step 4, G3 card) and what passing output looks like.
+4. Controller hand-off, written in the task report and **not built here**: the matching host-init diff for platform-infrastructure `dev/host-init.sh` and `.tftpl`, for new boxes only, with "do not apply to running boxes".
+
+**Refusals that must hold.**
+- Not root, or no `/etc/carlos`: exit non-zero before any change.
+- A conf path that is a symlink: refuse.
+- No source within 20 s: exit non-zero and say so. Leave chrony installed, which is safe, and print the rollback (`apt-get install systemd-timesyncd`).
+- The script contains no `systemctl restart carlos`, `reboot`, `kill`, or any host.env write. A test greps for these.
+
+**User-facing strings.** These are the script's output lines, kept in a list at the top of the script for one copy pass: pass, the three failure lines and the rollback hint.
+
+**Tests (offline).** `scripts/region_ha_g3_chrony_test.py` (unittest) runs the script under `bash` with a temporary `PATH` of shims for `apt-get`, `systemctl`, `chronyc`, `systemd-run`, `install` and `id`, which record their argv:
+- the happy path calls the exact sequence in order;
+- `--check` calls only read commands;
+- a non-root `id` refuses before any shim;
+- a never-synchronising `chronyc` exits non-zero after 20 tries with no further steps;
+- the forbidden-command grep;
+- the conf line equals the one in `group-init.sh.tftpl` (the test reads the template).
+
+Failing first: change the conf line in the script; the template-equality test must fail.
+
+**Run.**
+```
+bash -n scripts/region-ha-g3/chrony-fixed-box.sh
+python3 -m unittest scripts/region_ha_g3_chrony_test.py
+TMPDIR=/tmp/g go test ./internal/host -run 'TestGroupBoot|TestGroupMetric' -count=1
+```
+shellcheck is not installed here. Say so in the report. **Census:** `scripts/` is out of scope. `docs/region-ha-runbook.md` is Markdown and outside `infra/`, so it is not in scope.
+
+---
+
+## Task 5: §13 precondition 3, a read-only readiness check over a named pool
+
+**Controller rulings (2026-11-05):** `files_published_at` does not exist in code; use a clean marker plus a complete files manifest as its proxy, and name the proxy in the output. A never-woken born-HA host (no replica) is not ready, as the spec says.
+
+**Why.** §13 precondition 3 wants, from `carlos system region readiness <region>`:
+- every instance has a replica, a complete `files_published_at` and no unclean last marker;
+- no old-format lock;
+- no non-hibernating socket instance.
+
+G3 decision 3 narrows this to the HA pool's hosts. P2b-2's door (`2026-11-04-region-ha-p2b-console.md:215-231`, slot 2026-11-11) reports **box** eligibility and roles, and says "Full readiness: Not yet reported" (R21). It has no executable plan and no branch beyond `region-ha-p2b-build` (P2b-1). This task supplies the **host** facts P2b-2 does not cover. It is a diagnostic, never a gate.
+
+**Where it lives: `scripts/region-ha-g3/pool-readiness.py`. Not a CLI verb, because:**
+- a verb is root-binary surface, so it needs a census and a release;
+- it would sit beside, and duplicate, P2b-2's `carlos system region readiness` (copy R03);
+- a script is operator-run and out of the census (AGENTS.md "What is in scope"), and is absorbed later by porting its five checks into P2b-2's console observation, using the same reason codes.
+
+**What to build.**
+- Arguments, all required except `--prefix`:
+ - `--profile`, `--region`;
+ - `--deployment-bucket` (records: `apps/<sqid>/<app>/instances/<host>.json`, `internal/provision/provision.go:38`, `internal/release/release.go:356`);
+ - `--data-bucket` (hibernate prefix `instances/<host>`, `internal/activator/activator.go:164-166`);
+ - `--pool`, and `--account <sqid>` (repeatable);
+ - `--prefix` (default `instances`).
+ It calls `aws s3api` through one runner function (the pattern of `scripts/region-group-roll.py:606`), so tests inject a fake.
+- Enumeration. Pool membership is console database state, so the output says that only the named accounts were read:
+ - per account, list `apps/<sqid>/` with delimiter `/`;
+ - per app, list `apps/<sqid>/<app>/instances/`;
+ - GET each record and keep those with `ha: true`, `pool == --pool`, and the right region.
+- Checks per kept host:
+ 1. **socket.** `kind` defaults to instance, no `addrs`/`addr`, empty `runtime`, and `hibernate` false, explicit or defaulted. This is the create door's own rule (`internal/console/hacreate.go:20`; defaults at `provision.go:480-548`).
+ 2. **lock.** GET `<prefix>/<host>/lock.json`, classified the way `hafresh` does:
+ - `absent`: never woken;
+ - not HA-format (`hafresh.View.HAOn`, `internal/hafresh/lock.go:94-104`): `lock_old_format`;
+ - a marker with `clean: false`: `marker_unclean`;
+ - a clean marker: ok;
+ - HA owner unexpired: `awake`, verdict `unknown`, re-run when asleep;
+ - HA owner expired: `lock_expired_unreleased`, an unpaid release or a suspect holder (§5.2, §9.4);
+ - HA owner with no `iid=` (`hafresh/owner.go` `ParseOwner`): `lock_old_format`.
+ 3. **replica.** `list-objects-v2 --prefix <prefix>/<host>/ltx/ --max-keys 1` (layout per `internal/activator/rootfsmarker.go:63`; confirm against litestream's s3 path helper before coding). No key: `no_replica`.
+ 4. **files.** GET `<prefix>/<host>/files/0/manifest.json` (`internal/activator/hawake.go:656-658`, `hostfiles.ManifestKey` at `internal/hostfiles/manifest.go:83`). Missing, `v != 2`, or any entry or platform item with `torn` or a non-empty `skipped`: `files_incomplete`. **`files_published_at` does not exist in code (no grep hit).** The proxy is a clean marker (complete final publish, §5.2) plus this check. Ruling 3.
+- Output: one JSON line per host:
+ `{"host","account","app","pool","verdict":"ready|not_ready|unknown","reasons":[...],"lock":{...},"reads":{"list":n,"get":n}}`
+ then one summary line with totals and the request count. Exit code 0 always: it is a diagnostic. `--strict` returns 1 when not ready, for the operator's own use only.
+
+**S3 cost (operator-run only).** At most (A + P + H) LISTs plus (R + 2H) GETs, plus one LIST per extra 1,000 keys. A is accounts, P is apps, R is records read, H is pool hosts. For A=2, P=4, R=20, H=10 that is 16 LISTs and 40 GETs, about $0.0001. No loop, no timer, no box-side call.
+
+**Refusals that must hold.**
+- No write, PUT, DELETE, `--recursive` or `s3 cp` to S3. The runner refuses any `s3api` verb outside `list-objects-v2` and `get-object`.
+- A record that fails to parse, or whose body disagrees with its key, is `unknown` with a reason, never ready.
+- Never-woken hosts are `not_ready` (`no_replica`) unless ruling 3 says otherwise.
+- `awake` is never `ready`.
+- No account named: refuse to run.
+
+**User-facing strings.** The reason-code descriptions (one sentence each), the summary line and the "only the named accounts were read" line. One copy pass, listed at the top of the script.
+
+**Tests (offline).** `scripts/region_ha_g3_pool_readiness_test.py` with a fake runner over fixture objects:
+- every lock class in the shared `scripts/testdata/region-ha-locks.json` (absent, legacy `host:pid`, marker clean, marker unclean, held, expired, no-iid HA owner) maps to its code;
+- a socket record is flagged; a rootfs resident is not (the `hacreate.go:20` exemption);
+- a manifest with `torn: true`, `skipped: "x"` or `v: 1` gives `files_incomplete`;
+- read counts match the formula;
+- the runner refuses `put-object`;
+- no `--account` refuses.
+
+Failing first: treat an unexpired HA owner as `ready`; the awake test must fail.
+
+**Run.** `python3 -m unittest scripts/region_ha_g3_pool_readiness_test.py`. **Census:** out of scope (`scripts/`).
+
+---
+
+## Task 6: T1, the drill probe `scripts/region-ha-g2/g2-probe.py`
+
+**Why.** The G2 card's T1 row asks for, per second per fixture:
+- a GET through each NLB address and through the backhaul box, sent with `--resolve` from outside the VPC;
+- an `X-Request-Id` per request;
+- status, serving box and latency;
+- a lock reader every 5 s per fixture;
+- JSONL output, with a budget.
+
+The addendum §5 T1 is the public contract. The earlier windows used ad hoc `curl` loops.
+
+**What to build.**
+- Arguments, nothing hard-coded:
+ - `--fixture HOST` (repeatable), `--entry NAME=IP` (repeatable, for example `nlb-a=192.0.2.10`);
+ - `--write-entry NAME` (the entry used for one `POST /write?n=<seq>` per second per fixture);
+ - `--bucket`, `--prefix` (default `instances`), `--profile`, `--region`;
+ - `--lock-every 5`, `--max-lock-gets 20000`, `--duration`, `--out FILE`.
+- One thread per (fixture, entry). Each second it runs `curl -sS -o - -w <json> --resolve HOST:443:IP --max-time 5 -H "X-Request-Id: <uuid4>" https://HOST/`. It parses `box=`, `hits=` and `rid=` from the Task 7 body.
+- Each record: `{"t","kind":"get|write|lock","fixture","entry","rid","rid_echo","status","box","hits","max","ms","err"}`.
+- The lock reader runs `aws s3 cp s3://<bucket>/<prefix>/<host>/lock.json -` every `--lock-every` seconds and records generation, `expires_at`, the owner's iid and ref, and marker clean or absent. It uses the shared lock fixtures' classifier.
+- Budget: count lock GETs, refuse to start if `fixtures × duration / lock-every > max-lock-gets`, and stop the lock reader (not the HTTP probes) when the cap is reached, with one line saying so.
+- At exit, print a summary per fixture and entry: counts by status and by serving box, the longest run of non-200s, and for writes the acknowledged `n` set saved to `--out.acks`. `--compare RANGES_FILE` computes lost acknowledged writes against Task 7's `GET /ranges`.
+
+**Refusals that must hold.**
+- No fixture or no entry: refuse.
+- An entry whose IP is not a literal IPv4 or IPv6 address: refuse.
+- No `aws` verb other than `s3 cp ... -`, read-only to stdout. The runner enforces it.
+- No retries hide failures: each request is one record.
+- The output file is opened with `O_EXCL` (never overwrites an earlier run's evidence).
+
+**User-facing strings.** The summary headings, the budget refusal and the "lock reader stopped at the cap" line.
+
+**Tests (offline).** `scripts/region_ha_g2_probe_test.py`, loading the hyphenated module with importlib as `scripts/region_group_roll_test.py:20-23` does, with a fake curl and aws runner and a fake clock:
+- the JSONL schema per kind;
+- `rid_echo` true and false;
+- body parse with a missing field gives `null`, not 0;
+- the budget refusal at start and the stop at the cap;
+- `--compare` finds exactly the missing acknowledged `n`;
+- a non-literal entry refuses;
+- a non-`cp` aws verb refuses.
+
+Failing first: count a timeout as status 200; the schema test must fail.
+
+**Run.** `python3 -m unittest scripts/region_ha_g2_probe_test.py`. The card's 5-minute dry run against an existing fixture is window work, not build work.
+
+---
+
+## Task 7: T2 and T6, the numbered-write fixture app (with `/fetch`)
+
+**Why.** The G2 card's T2 and T6 rows ask for:
+- three born-HA fixtures in the test pool, one per replication class, each acknowledging a numbered write and reporting its box and row count;
+- a hairpin fixture with `GET /fetch` that calls its own hostname through an NLB address.
+
+The base is the `hacheck` app used for the existing pool fixture. Its source is at `~/.cache/release-v0.28.25/hacheck/main.go`, not in this repo, and the README's wakecheck source is not on disk. It takes `--socket` and `--db` as the activator passes them (`internal/activator/backend_exec.go:2530`). Its stdout reaches the `carlos-edge` journal through the agent's log listener (`internal/activator/loglistener.go:71-80`). The replication classes are `stream`, `batched` and `daily` (`internal/registry/registry.go:565-577`).
+
+**What to build.** `scripts/region-ha-g2/fixture/main.go`: `package main` in the main module, as `scripts/witness-pointer/` is. It uses the existing `modernc.org/sqlite` (`go.mod:32`) and adds no dependency.
+- Flags `--socket`, `--db`. Use WAL, `busy_timeout`, and a table `w(n INTEGER PRIMARY KEY, box TEXT, at TEXT)`.
+- `POST /write?n=<int>`: `INSERT OR IGNORE`. Reply only after the commit returns. Body: `g2fixture box=<hostname> hits=<count> max=<max n> rid=<X-Request-Id or ->`.
+- `GET /`: the same body without writing.
+- `GET /ranges`: the stored `n` as compressed ranges `1-120,125-300`.
+- `GET /fetch` (T6): read `G2_HAIRPIN_ADDR` (`host:port`; unset gives 503 `hairpin address not configured.`). Do an HTTPS GET of `https://<r.Host>/` dialled to that address with SNI `r.Host` and a 5 s timeout. Reply `fetch status=<code> ms=<n>` or `fetch error=<class>`.
+- After writing each response, log exactly `g2fixture status=<code> host=<r.Host> path=<path> rid=<rid>`. This line is the T4 interface; keep it as an exported constant tested on both sides.
+- `scripts/region-ha-g2/FIXTURES.md`, the creation steps for the window (no account or host names; placeholders):
+ - `carlos apps create`, `carlos instances enable`;
+ - build with `GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build`;
+ - `carlos deploy --app <app> --version <v> --channel edge <binary>`;
+ - `carlos instances create --host <label>.<domain>` for `g2-stream`, `g2-batched`, `g2-daily` and `g2-hairpin`;
+ - read back `ha: true` and the pool;
+ - `carlos env set G2_HAIRPIN_ADDR=<nlb-ip>:443` for the hairpin app;
+ - then `carlos route --host <h> --replication <class>` **on every serving box over SSM, and again on every replacement before each drill**. That command edits only the box it runs on (`cli.go:793-825`, "ON THIS BOX"), and records do not carry the class. Read it back in the `REPLICATION` column.
+
+**Refusals that must hold.**
+- `n` not a positive integer: 400. An acknowledgement is never sent before the commit. A failed insert: 500 with no `hits=`.
+- `/fetch` never follows redirects and never dials an address other than `G2_HAIRPIN_ADDR`.
+- No tenant names in code or docs.
+
+**User-facing strings.** The body formats, the two `/fetch` errors and the `FIXTURES.md` prose. One copy pass, with the body formats frozen because Task 6 parses them.
+
+**Tests.** `scripts/region-ha-g2/fixture/main_test.go`, through `httptest` against a temporary database:
+- write then read gives `hits` and `max`;
+- a duplicate `n` is ignored;
+- `/ranges` compresses gaps;
+- an acknowledgement after a forced commit failure is absent (inject a closed database);
+- `/fetch` against a local TLS `httptest` server reached through `G2_HAIRPIN_ADDR` with an SNI check;
+- the log-line constant format.
+
+Failing first: write the response before `Exec`; the commit-failure test must fail.
+
+**Run.**
+```
+go test ./scripts/region-ha-g2/fixture -count=1
+GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o /dev/null ./scripts/region-ha-g2/fixture
+GOOS=darwin go build -o /dev/null ./scripts/region-ha-g2/fixture
+GOOS=windows go build -o /dev/null ./scripts/region-ha-g2/fixture
+```
+**Census:** out of scope (`scripts/`). `TestCensusScopeIsTheRootBinary` must still pass, which confirms the fixture is not a root dependency.
+
+---
+
+## Task 8: T4, `scripts/region-ha-g2/g2-firstserve-stop.sh`
+
+**Why.** The G2 card's T4 row and drill 3 need the hang within about a second of the replacement's first backhauled 200. An SSM round trip is too slow (addendum §5 T4). Facts this relies on:
+- the agent and edge are one process, `ExecStart=/opt/carlos/carlos agent` (`internal/host/units/carlos-edge.service:19`);
+- app stdout reaches that unit's journal (`loglistener.go:76`).
+
+**What to build.** A root bash one-shot: `--fixture HOST [--stamp /run/g2-firstserve.stamp] [--timeout 3600]`.
+1. Start-up refusals: refuse unless uid is 0, `carlos-edge` is active, and the stamp file does not exist.
+2. Follow `journalctl -u carlos-edge -f -n0 -o cat` and match the fixed string `g2fixture status=200 host=<HOST> ` (Task 7's constant) with `grep -F --line-buffered -m1`.
+3. On the first match:
+ - read `MainPID` with `systemctl show -p MainPID --value carlos-edge`;
+ - refuse if it is 0 or 1, or if `/proc/<pid>/exe` is not `/opt/carlos/` plus something;
+ - `kill -STOP <pid>`;
+ - write the UTC time (`date -u +%FT%T.%NZ`) and the pid to the stamp with `set -o noclobber`.
+4. Then poll `/proc/<pid>/stat` once a second until the state is no longer `T` or the pid is gone. Then exit.
+5. `trap` on EXIT, INT and TERM: kill the `journalctl` child and `rm -f -- "$0"`. On timeout without a match, exit, remove itself and write no stamp.
+6. In the header, the delivery: `systemd-run --unit=g2-firstserve --collect /run/g2-firstserve.sh --fixture <host>`, so it outlives the SSM session. Record the sha256 in the window log.
+
+**Refusals that must hold.**
+- It never restarts, kills or terminates anything. The only signal it sends is `-STOP`, once, to the verified `carlos-edge` MainPID.
+- No `systemctl restart`, `stop` or `kill`; no `kill -9`, `-KILL` or `-TERM` (aside from its own `journalctl` child); no `aws`, `CompleteLifecycleAction` or `ABANDON`.
+- A second run while the stamp exists refuses.
+
+**User-facing strings.** The start line, the match line, the refusal lines and the exit line. One copy pass.
+
+**Tests (offline).** `scripts/region_ha_g2_firstserve_test.py` runs the script with a shim `PATH`:
+- `journalctl` emits lines from a file;
+- `systemctl` returns a fake pid, which points at a stub process the test starts;
+- `kill` is a shim that records its arguments.
+
+The stub process path replaces `/proc` through a `PROC_ROOT` variable that defaults to `/proc`. Root is faked through an overridable `ID_CMD`.
+
+Cases:
+- a non-matching host's 200 and a matching host's 503 do not trigger;
+- a matching 200 sends exactly `-STOP <pid>` once and writes the stamp;
+- the state leaving `T` exits and removes the script copy;
+- a timeout gives no stamp and the script removed;
+- an existing stamp refuses;
+- MainPID 0 refuses;
+- the forbidden-command grep over the script text;
+- the match string equals Task 7's constant (read from `main.go`).
+
+Failing first: match `status=200` without the host; the non-matching-host test must fail.
+
+**Run.**
+```
+bash -n scripts/region-ha-g2/g2-firstserve-stop.sh
+python3 -m unittest scripts/region_ha_g2_firstserve_test.py
+```
+shellcheck is not installed. Report it. Rehearsing once on the root runner is window work, not build work.
+
+---
+