| index b493856e4..aefada81b 100644 |
| --- a/docs/superpowers/notes/2026-11-05-region-ha-p3b2-standby-witness.md |
| +++ b/docs/superpowers/notes/2026-11-05-region-ha-p3b2-standby-witness.md |
| @@ -1,9 +1,9 @@ |
| # P3b-2 Standby witness design |
| |
| -Use this design to prepare the later dated private dev card. No live step has |
| -run for this note, and this note grants no infrastructure or fault permission. |
| -Paul's dated, scoped go must name the operator, account, region, domains, |
| -resources, IAM changes, traffic effects, cost cap, UTC window and cleanup owner. |
| +Use this runbook with the dated private dev card. This note grants no |
| +infrastructure or fault permission. The card records the applicable scoped |
| +approval, operator, account, region, domains, resources, IAM changes, traffic |
| +effects, cost, UTC window and cleanup owner, including any standing approval. |
| Keep actual deployment values and evidence in that card. Examples here use |
| `<group>`, `<iid-a>`, `<iid-b>` and `<fixture-host>`. |
| |
| @@ -23,7 +23,7 @@ does not start another review round. |
| ## Before the window |
| |
| The card must freeze changes to the region-host module and group while any |
| -roll transaction is unfinished or `provider-divergence.json` exists: no |
| +probe or roll transaction is unfinished or `provider-divergence.json` exists: no |
| `tofu apply` or other change may run. OpenTofu owns `min_size` and |
| `desired_capacity` in `infra/modules/region-host/group.tf`, with no |
| `ignore_changes`, so an apply resets both to N. AWS then launches an extra |
| @@ -48,8 +48,9 @@ Use the real operator role/SSO identity with only `group_operator_policy_json` |
| attached, accounting for inherited grants. Pin the approved session document |
| and its content/version on the card. Keep the member role's |
| `AmazonSSMManagedInstanceCore` and parameter Denies. All operators use one |
| -root-owned state directory and one group lock. No instance, service or cron |
| -may run the operator. |
| +root-owned state directory and one group lock. An approved disposable operator |
| +host may run it attended. No service, timer, cron or unattended instance may |
| +run it; never use a member's credentials. |
| |
| Check SNS email confirmation before faults. P3b-1 did not establish it. |
| Record confirmed subscription status and an actually received test notification |
| @@ -67,12 +68,38 @@ software roll. Never fabricate the record to make this ordering work. |
| ## Step 0. Observe the unchanged member first |
| |
| The first live maintenance action is one disposable, unchanged-member |
| -Enter/ExitStandby probe. Hold the exclusive group lock on the shared operator |
| -host for the entire probe, with a durable probe record. The current tool has |
| -no probe subcommand and requires a changed artifact for `roll`; do not use |
| -`roll` or `return` to simulate this observation. The card must specify the |
| -serialized probe driver, its journal and recovery actions before approval. |
| -It must preserve the return invariant below with the unchanged process. |
| +Enter/ExitStandby probe. Copy `scripts/region-group-probe.py` and |
| +`scripts/region-group-roll.py` from the same pinned commit to the shared |
| +operator host and verify their SHA256 digests. An older roll tool may not |
| +recognize a probe journal. Use the same root-owned configuration and state |
| +directory for both tools. Do not use `roll` or `return` to simulate the probe. |
| + |
| +```sh |
| +python3 scripts/region-group-probe.py --config '<config.json>' \ |
| + --attended-by '<operator>' probe --member '<iid-a>' |
| +python3 scripts/region-group-probe.py --config '<config.json>' \ |
| + --attended-by '<operator>' status --transaction '<probe-id>' |
| +python3 scripts/region-group-probe.py --config '<config.json>' \ |
| + --attended-by '<operator>' resume --transaction '<probe-id>' |
| +python3 scripts/region-group-probe.py --config '<config.json>' \ |
| + --attended-by '<operator>' abandon --transaction '<probe-id>' |
| +``` |
| + |
| +The driver holds `group.lock` throughout each live invocation. It registers |
| +`probe-<32hex>.jsonl` in `active.json`, with a probe-kind header and a |
| +hash-chained 0600 journal. It records API intents and replies, raw group and |
| +member lifecycle objects, activities, both target groups, root status, |
| +published edges and measured Exit observation age. Its only box verb is |
| +`status`; it never prepares, permits or applies software. An unfinished probe |
| +blocks plan/roll, even after its process exits and releases the lock. |
| + |
| +`status` reads saved evidence only. `resume` takes the lock and observes before |
| +continuing the same probe. `abandon` closes a probe only before any group |
| +write intent or Exit intent, including an intent whose outcome is unknown. |
| +It makes no provider call and is unrelated to AWS lifecycle ABANDON. A probe |
| +refused for hook evidence or a divergence flag at final verification stays |
| +active until the controller resolves divergence. Do not remove its journal |
| +or active marker to unblock a roll. |
| |
| 1. Read back the exact member set, min/desired/max, hook, pinned template, |
| scaling activities and both target groups. Confirm both members are |
| @@ -108,16 +135,28 @@ and verify both deregistrations. Retain min=desired=1, max=2, the probe record |
| and the same iid until the controller resolves the contract. Pending:Wait |
| has no Standby protection; elapsed time cannot make this probe a pass. |
| |
| -Only after a pass may the controller write root-owned 0600 |
| -`provider-observation.json` with the exact fields in the operator instructions. |
| -Keep the raw observations alongside it. A new group UUID, hook or template |
| -requires matching evidence. Refuse all software rolls while divergence remains. |
| +On pass, the driver journals `probe-pass` and prints a candidate record with |
| +`v: 1`, `group_arn`, `hook`, the exact `template` and |
| +`documented_no_hook: true`. Its zero return-completion count and false |
| +return-hook observation are derived from the journal. It does not install |
| +the record. Only after checking the pass may the controller write that |
| +candidate as root-owned 0600 `provider-observation.json` in the group state |
| +directory. Keep the raw observations alongside it. A new group UUID, hook or |
| +template requires matching evidence. Refuse all software rolls while divergence remains. |
| |
| ## Step 1. Verify the real maintenance channel |
| |
| -Use the card's exact operator identity and approved document on the unchanged |
| -members. Record request IDs, principal/session identity, document identity, |
| +Use the card's exact operator identity and the approved document from |
| +`infra/modules/region-group-operator-document` on the unchanged members. |
| +Record request IDs, principal/session identity, document content/hash/version, |
| exit status and remote uid without recording session tokens or credentials. |
| +The document runs noninteractive commands as root. Branch T admits only the |
| +framed maintenance verbs and is sufficient for probes and ordinary rolls. |
| +Branch H admits the pinned fault bundle and fixed harness verbs. Enable H |
| +only for the fault window with `harness_bundle_sha256`; set it back to `null` |
| +and deploy a new T-only document version during cleanup. Verify the version |
| +actually selected by StartSession. Never broaden the command pattern to |
| +obtain a shell. |
| |
| | Check | Pass | Failure action | |
| | --- | --- | --- | |
| @@ -143,12 +182,14 @@ P3b-1's 7(b) check was blocked because a fixed holder kept the fixture's |
| clean-release marker and won cold wakes. A Network Load Balancer (NLB) response alone cannot show |
| which box actually served the app. |
| |
| -Recommend temporarily withdrawing only the fixed holder's hapair scope under |
| -the dated card. First sleep the approved born-HA fixture through the supported |
| -API, verify its writer is stopped, inspect lease/clean-release/debt state, then |
| +Temporarily withdraw the fixture pool from every fixed box that could win its |
| +cold wake, as listed on the dated card. Withdrawing only the current holder |
| +may leave another fixed box preferred over the group. First sleep the approved |
| +born-HA fixture through the supported API, verify its writer is stopped, |
| +inspect lease/clean-release/debt state, then |
| apply the supported scope change and observe its reconciliation. Keep the |
| fixed targets registered and serving their other scopes. Scope withdrawal |
| -must actually make the fixed holder ineligible; it is not proof that a lease |
| +must actually make those fixed boxes ineligible; it is not proof that a lease |
| has been released. Require a legally free lease, or wait its remaining expiry |
| under the normal acquisition rules, before the next cold wake. |
| |
| @@ -171,51 +212,91 @@ cleanup and verify service before removing group capacity. |
| |
| ## Step 3. Prepare a bounded one-member fault |
| |
| -The card must include an exact, rehearsed root-owned local fault recipe before |
| -approval. Deliver it over the same approved Session Manager channel while that |
| -channel still works. Blocking SSM also removes operator access: there can be no |
| -plan to reconnect through the black-hole to remove it. Session Manager uses |
| -HTTPS to `ssm`, `ssmmessages` and `ec2messages` regional endpoints: |
| +Use `scripts/region-group-fault/` from the pinned platform commit. Its |
| +[README](../../../scripts/region-group-fault/README.md) describes the client, |
| +local files and controller rehearsal. Build the deterministic bundle, record |
| +its SHA256 and pin that digest in the approved document's Branch H: |
| + |
| +```sh |
| +python3 scripts/region-group-fault/bundle.py --output '<evidence-dir>/bundle.tar' |
| +python3 scripts/region-group-fault/client.py --profile '<profile>' \ |
| + --region '<aws-region>' --document '<document>' --target '<iid-a>' install |
| +python3 scripts/region-group-fault/client.py --profile '<profile>' \ |
| + --region '<aws-region>' --document '<document>' --target '<iid-a>' status |
| +``` |
| + |
| +`install` builds and delivers the bundle through the approved Session Manager |
| +channel, then checks its pinned hash before unpacking. Compare `status` hashes |
| +with the bundle sources. Delivery must finish while the channel still works: |
| +blocking SSM removes operator access until local expiry. SSM uses HTTPS to |
| +`ssm`, `ssmmessages` and `ec2messages` regional endpoints: |
| [https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-prerequisites.html](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-prerequisites.html). |
| |
| -Use a uniquely named nftables table on `<iid-a>` only, with root-owned code |
| -and state. The card must enumerate the actual S3 and SSM destination paths, |
| -including private endpoints, DNS changes, IPv4/IPv6 and existing connections. |
| -An IP list resolved once is not proof of a continuing black-hole. Prefer a |
| -short-lived outbound TCP/UDP 443 drop for new service connections when the |
| -card can explicitly account for its wider HTTPS impact; otherwise pin and |
| -verify complete endpoint sets. Ensure existing S3/SSM flows are also dropped. |
| -Keep loopback, inbound probe responses, peer/backhaul traffic, DNS, clock and |
| -metadata available as required for this isolated fault. Check counters and |
| -failed requests to prove the block, and verify `<iid-b>` remains unaffected. |
| -Do not flush shared tables or alter security groups, routes or IAM to inject it. |
| - |
| -Before enabling the drop, arm and verify a root systemd timer that removes only |
| -this fault table after the card's bounded duration, recommended 35 minutes. |
| -Its service must work entirely from local files, independently of the session, |
| -edge process and network. Record timer/unit names, ownership, hashes, activation |
| -and expiry times, cleanup result and removal readback. Rehearse expiry before |
| -the disruptive run. If timer installation or verification fails, do not inject. |
| -Do not reboot during this witness. Never restart or terminate a member on expiry. |
| - |
| -`roll` has no pause-before-apply flag. Receive its apply command while SSM is |
| -reachable. Apply still verifies the signed pointer through S3, even after |
| -preparation; blocking S3 before that verification may refuse before restart. |
| -The card therefore needs a reviewed, pre-delivered root fault harness that |
| -activates after apply's cloud verification and before the new edge can admit. |
| -One design is a one-shot root systemd dependency at edge pre-start, bound to |
| -this iid/boot/transaction and the recorded Standby/deregistration evidence. |
| -It arms and verifies cleanup before enabling the drop, then permits that one |
| -already-requested guarded start. It must never initiate a restart itself. |
| - |
| -Rehearse the exact unit ordering, privileges and survival across unit repair |
| -with the pinned build before the card is approved. Keep the production apply |
| -command, framing, timeouts, masks and guard intact. No timer may start a second |
| -apply or make an ASG call. Record the harness, units and approved document as |
| -test apparatus, including hashes and removal. This note supplies the design |
| -requirements, not an executable harness or authority to install one. If this |
| -boundary cannot be enforced, stop before the fault; do not substitute a manual |
| -stop/restart, weaken a guard or invent a tool flag. |
| +The harness creates only `inet carlos_p3b2_fault` on the selected member. |
| +It drops TCP/UDP destination port 443 and source-port 443 replies, including |
| +existing flows. IPv4 excludes the VPC CIDRs read from IMDS, loopback and |
| +link-local addresses. IPv6 excludes loopback and link-local addresses. You |
| +must still enumerate the real S3/SSM paths, private endpoints, DNS changes |
| +and both address families. A private endpoint inside an excluded CIDR escapes |
| +the fault; a private IPv6 peer using HTTPS may be affected. Stop if these |
| +rules cannot cover the approved paths without disrupting required traffic. |
| + |
| +Verify loopback, inbound probe responses, peer/backhaul traffic, DNS, clock |
| +and metadata remain available. Account for other public HTTPS calls cut by |
| +the fault. Prove the block with counters and failed S3/SSM requests, and prove |
| +`<iid-b>` is unaffected. Never flush shared tables or change security groups, |
| +routes or IAM to inject the fault. |
| + |
| +The root worker arms and verifies `carlos-p3b2-fault-expire.timer` before |
| +adding any drop rule. Its local service removes only this table after the |
| +card's duration, normally 35 minutes. Kernel set timeouts provide a second |
| +expiry path; unsupported interval timeouts cause an explicit timer-only |
| +fallback. That fallback fails the kernel-expiry rehearsal and needs controller |
| +resolution before the window. Record unit names, ownership, hashes, activation, |
| +expiry and removal readbacks. Rehearse expiry before the disruptive roll. |
| +The service needs no network, session or edge process; it never restarts or |
| +terminates a member. Do not reboot during this witness. |
| + |
| +Arm the one-shot with `arm-fault` before the attended roll, using the selected |
| +iid, boot ID and the exact roll transaction: |
| + |
| +```sh |
| +python3 scripts/region-group-fault/client.py --profile '<profile>' \ |
| + --region '<aws-region>' --document '<document>' --target '<iid-a>' arm-fault \ |
| + --iid '<iid-a>' --boot '<boot-id>' --transaction '<transaction>' --minutes 35 |
| +``` |
| + |
| +The current interfaces leave this ordering blocked: `roll` generates its |
| +transaction internally and immediately continues, while the harness needs |
| +that ID before the roll. Neither a caller-selected roll ID nor a preparation |
| +pause is exposed. The controller must resolve and rehearse this connection |
| +before the fault roll or Step 6; do not guess an ID, race the journal, edit a |
| +permit or weaken the match. The command above describes the required binding, |
| +not a claim that the current CLI can supply it in that order. |
| + |
| +`arm-fault` writes a root-only marker and `90-p3b2-fault.conf`; it does not |
| +inject or restart. At edge pre-start, after apply's S3 verification, the worker |
| +checks iid, boot, marker age within 60 minutes and the permit's transaction. |
| +It consumes the marker before installing the timer and drop rules. The |
| +pre-start wrapper always returns zero, including on refusal, so a successful |
| +edge start alone proves nothing about injection. The harness checks the |
| +transaction match; the roll guard and your readbacks establish valid action, |
| +Standby, both deregistrations and the healthy peer. Keep the production apply |
| +command, framing, timeouts, masks and restart guard intact. |
| + |
| +REHEARSAL: <controller fills> |
| + |
| +Accept only the controller's recorded results for the pinned build and bundle. |
| +The root-runner driver exercises pre-start expiry, consumed-marker refusal, |
| +kernel expiry, root-versus-carlos pause isolation and file survival across |
| +unit rewrite and daemon-reload. It installs the pinned hairpin reset hooks and |
| +IMDS rules and records effective pre-start ordering. It has no signed group |
| +marker or protected address snapshot: signed hairpin installation, its sysctl |
| +setup and the guarded `requireGroupMaintenance("repair")` path are not proved. |
| +A no-op hairpin reset is possible. The runner's stub permit and deliberate |
| +restart also do not prove real apply completion, transaction binding, admission, |
| +provider behavior or live IAM/document enforcement. Keep those member checks. |
| +No timer may initiate another apply or make an ASG call. |
| |
| ## Step 4. Roll and hold through the outage |
| |
| @@ -226,7 +307,9 @@ refusal and zero edge stops, restarts, binary changes or symlink repoints. |
| Compare process identity, binary/symlink state and service journal across each |
| attempt. Do not unmask the update units to make the attempt run. |
| |
| -Start `roll` with `<iid-a>` and the pinned new digest. Record the old artifact, |
| +After resolving the Step 3 transaction-binding gap, read harness `status`, |
| +arm `arm-fault` for that transaction and verify the marker before starting |
| +`roll` with `<iid-a>` and the pinned new digest. Record the old artifact, |
| process identity, member set and activity counters. Require signed preparation |
| and preserved host.env/certificate checks before minimum drops. Record only |
| hashes/metadata for secret-bearing files, never their contents. |
| @@ -258,17 +341,28 @@ Pass the hold only with the same iid and total member set, zero extra launches, |
| replacements or terminations, zero operator lifecycle completions, closed |
| tenant starts and the healthy peer unaffected. Separately show |
| that shared dependency loss on an already-admitted live process leaves its |
| -health/startup latch intact until local shutdown. Use a separate short bounded |
| -fault before the roll, restore access before |
| -apply's cloud verification, and distinguish its timestamps from the restarted |
| +health/startup latch intact until local shutdown. Use `fault-now` for a separate |
| +short bounded fault before the roll, with |
| +`--iid`, `--boot`, a distinct evidence label in `--transaction`, and the card's |
| +short `--minutes` duration. This live-process verb needs no maintenance permit |
| +and cuts its own SSM session. An END frame means only "not proven injected": |
| +refusals also return zero. After expiry, use `status` and the local log to prove |
| +the drop occurred, health stayed latched and access returned. Run `remove` to |
| +clear a leftover timer before arming again. Restore access before apply's |
| +cloud verification and keep these timestamps separate from the restarted |
| closed-admission phase. |
| |
| ## Step 5. Restore access and return |
| |
| -Wait for the local fault timer to remove the block. Verify S3 and all SSM paths, |
| -read the root log and nftables counters, and confirm the table is gone. Restore |
| -operator access through the approved document. Do not refetch SSM parameters |
| -for restart; use preserved local configuration, certificates and binary. |
| +Wait for local expiry, then restore access through the approved document. |
| +Read harness `status`, the root log and nftables counters. Verify S3 and every |
| +SSM path works, the table is gone and the expiry timer is inactive or unloaded. |
| +After every roll attempt, including failure, read `status` and run `disarm` |
| +through the same client. This removes the pending marker and pre-start drop-in |
| +and reloads systemd; it leaves an active table and its expiry timer alone. |
| +Use `remove` for an early approved removal or a leftover timer, then verify |
| +absence before rearming. Never stop the timer while a drop remains. Do not |
| +refetch SSM parameters for restart; use preserved local configuration, certificates and binary. |
| |
| For a lost or cut apply session, run saved `status` and resume the same journal. |
| The first remote operation must read root status. Record consumed state, |
| @@ -314,12 +408,20 @@ a lost session, elapsed time or old launch receipt as fresh admission. |
| |
| In a separately recorded roll that has completed apply but remains in Standby |
| before any Exit intent, use `rollback` with the same member and transaction. |
| -The card's harness must make this boundary observable without a second writer; |
| -the tool otherwise proceeds directly to return. Require revoke of the apply |
| +After resolving Step 3's transaction-binding gap, use the same client and |
| +identity arguments with `arm-pause` before this roll. Pause mode blocks public |
| +HTTPS only for user `carlos`, preserving root's SSM rollback channel. Confirm |
| +connection mark `0xc350b205` is unused by other policy; marks can outlive table |
| +removal. Verify the new process has closed admission and no Exit intent, then |
| +let the roll invocation stop and release its lock before running rollback on |
| +the same journal. The pause has a bounded expiry, so act before it expires. |
| +The tool otherwise proceeds directly to return. Require revoke of the apply |
| permit, an explicit rollback permit for the same old/new pair, restoration of |
| the old local artifact, a new edge process and fresh admission. Verify return, |
| -min=desired=max=2 and revocation through the same guard. Never clear consumption |
| -markers or use bare system apply to recover a failed/partial action. Record |
| +min=desired=max=2 and revocation through the same guard. Keep the pause until |
| +rollback has restored the old artifact, then `remove` it to observe fresh |
| +readiness and guarded return. Read `status` and `disarm` after this attempt too. |
| +Never clear consumption markers or use bare system apply to recover a failed/partial action. Record |
| safe refusal when the existing guard cannot recover the action. |
| |
| Only after all maintenance faults are removed and both members are healthy |
| @@ -343,8 +445,15 @@ For shared fixed-plus-group ingress, expected targets are 2 before, 4 during |
| and 2 after group removal; withdrawing hapair scope does not deregister the |
| fixed targets. A separately approved dedicated group ingress has 2 during. |
| |
| -Remove faults first. Verify removal of the exact nftables table, timer/service, |
| -fault harness and temporary document changes, and close task-owned sessions. |
| +Remove faults first. Export `/var/lib/carlos-p3b2-fault/log.jsonl` before |
| +`uninstall`, which deletes it. Branch H has no full-log export command; the |
| +card must name its separately authorized read-only collection path. `status` |
| +returns only recent log lines. Run `uninstall` through the harness client and |
| +retain its cleanup response. Verify absence of the table, pending marker, |
| +pre-start drop-in, expiry timer/service, installed library and harness state. |
| +After uninstall the client cannot run harness `status`; use the cleanup |
| +response and the card's read-only checks. Unset the bundle digest, deploy and |
| +verify a T-only document version, then close task-owned sessions. |
| Keep durable operator journals, probe records and consumed-action evidence. |
| Verify same-member return, min=desired=max=2, target health and permit absence |
| before declaring maintenance complete. If a member is held for investigation, |
| @@ -376,7 +485,9 @@ Retain the following on the private card: |
| |
| Charge all operator calls and Session Manager connections, including plan, |
| probe, refusals and resume. The current transport starts a new session for each |
| -box operation; do not claim the plan's original shared-stream connection budget |
| -from these tests. Have the controller reconcile actual counts with the card's |
| +box operation. Each probe describe tick makes about five AWS requests |
| +(group, two targets, instance and activities), about 60 requests per minute |
| +at five-second polling, before status/edges/SSM traffic. Do not claim the |
| +plan's original shared-stream connection budget from these tests. Have the controller reconcile actual counts with the card's |
| approved budget before execution. This witness alone does not establish full |
| G2, duties drained, or any producer-dependent checks that remain unrun. |