| new file mode 100644 |
| index 000000000..34c3ab253 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/2026-11-05-region-ha-p3b2-standby-witness.md |
| @@ -0,0 +1,371 @@ |
| +# 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. |
| +Keep actual deployment values and evidence in that card. Examples here use |
| +`<group>`, `<iid-a>`, `<iid-b>` and `<fixture-host>`. |
| + |
| +The pass is one member rolled and returned with the same instance ID, plus |
| +proof that a restarted unready member survives an extended shared-dependency |
| +outage in Standby. It is not a warm drain or seamless-roll claim. Record request |
| +outages and the remaining lease wait separately from replacement time. |
| + |
| +Follow the [operator instructions](2026-11-05-region-ha-p3b2-operator.md). |
| +The sources are the [P3b plan, rev 3](../plans/2026-11-04-region-ha-p3b-group.md), |
| +Tasks 7 and 8, and the [HA spec, rev 6.2](../specs/2026-10-26-region-ha-without-claims-design.md), |
| +sections 9.5 and 12.1. The controller's build rulings put the operator in |
| +`scripts/region-group-roll.py` and keep the dated deployment card private. |
| +Plan review is closed: R1 NOT READY; R2 READY AFTER FIXES, 0 P1. This design |
| +does not start another review round. |
| + |
| +## Before the window |
| + |
| +The card must pin the platform release and module revision containing the |
| +SSM-agent installation, root maintenance verbs and current operator fixes. |
| +Record both members' actual binary digests and the architecture-specific signed |
| +target digest. A missing `release_tag` is allowed. Record the verified |
| +`names-2` reader floor, capable artifact digests, all publishing and nonpublishing |
| +readers, and the console's deployed version. Do not downgrade an active or |
| +retained group namespace to an incompatible reader. |
| + |
| +Require two already-admitted disposable members, a healthy peer throughout |
| +maintenance, min=desired=max=2, an immutable numeric launch-template version, |
| +the exact 900-second initial hook, both target groups and preserved local |
| +host.env/certificates. If the SSM-capable revision is not already deployed, |
| +its provisioning needs a separate scoped step. Do not install software as |
| +part of the first Enter/Exit probe. |
| + |
| +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. |
| + |
| +Check SNS email confirmation before faults. P3b-1 did not establish it. |
| +Record confirmed subscription status and an actually received test notification |
| +using the card's separately scoped alarm authority. Missing delivery is a |
| +refusal. Check retained-edges alert routing against its current prose subject, |
| +and preserve N-HA17's per-departure unsupported-host pages. Those pages must |
| +not become consumer-start failures. |
| + |
| +`plan` itself requires a completed no-hook observation, so a clean plan cannot |
| +be a prerequisite to the first probe. Before Step 0, inventory its other |
| +checks explicitly and record the expected missing-observation refusal. After |
| +Step 0, install the evidence record and require clean `plan` output before any |
| +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. |
| + |
| +1. Read back the exact member set, min/desired/max, hook, pinned template, |
| + scaling activities and both target groups. Confirm both members are |
| + SSM-online, admitted and healthy with successful role publication. Record |
| + iid, boot ID, edge PID/start identity, artifact digest and UTC timestamps. |
| +2. Lower only minimum from 2 to 1. Enter Standby for `<iid-a>` with |
| + decrement=true. Read back `<iid-a>` in Standby, min=desired=1, max=2, |
| + unchanged membership and both target registrations absent/unused. A draining |
| + target is not yet deregistered. Do not stop, repoint, install or refresh |
| + anything on the member. |
| +3. Read fresh root status, published edges and root status again. Require |
| + unchanged edge identity, health 200, admission and serve-role publication. |
| + Record readiness and return intent durably; the observation must be at most |
| + five seconds old immediately before ExitStandby. Exit once, then describe |
| + the actual member lifecycle, activity and target states through InService. |
| +4. Require the same iid and process, unchanged artifact and member set, desired |
| + 2 and both target groups healthy. Restore minimum to 2 only then. Record |
| + zero return lifecycle completions and no observed return hook. |
| + |
| +Pass only with the documented no-return-hook behavior. AWS explicitly excludes |
| +Standby transitions from lifecycle-hook availability: |
| +[https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html](https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html). |
| +An activity labelled PreInService is not an instance Pending:Wait observation |
| +or proof of InService. Capture both API objects, not just activity text. |
| + |
| +If a return hook appears, stop the probe as a roll blocker. While freshly |
| +admitted, the serialized probe owner must handle any pending CONTINUE safely, |
| +verify same-iid InService, then EnterStandby with decrement=true and verify both |
| +deregistrations. Retain min=desired=1, max=2, the probe record and the same iid |
| +in Standby until the controller resolves the contract. Never pretend an iid |
| +in Pending:Wait is still in Standby. If readiness/API access drops, follow the |
| +failed-probe row below. Do not send ABANDON or invent a heartbeat extension. |
| + |
| +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. |
| + |
| +## 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, |
| +exit status and remote uid without recording session tokens or credentials. |
| + |
| +| Check | Pass | Failure action | |
| +| --- | --- | --- | |
| +| StartSession without `--document-name` | Access denied; no usable default-shell session. | Stop before any roll. | |
| +| StartSession naming another document | Access denied, including an unapproved account-owned document. | Stop; do not add broad permissions to make the test run. | |
| +| Approved document, real role/SSO identity | Data channel opens, uid is 0 and framed root status succeeds. | Stop on access, elevation or transport failure. | |
| +| `ssm:SessionDocumentAccessCheck` | Live allowed/denied cases agree with the policy's `BoolIfExists` plus exact-document grant. | Keep the IAM evaluation unresolved until evidence explains it. | |
| +| Member reachability | Both members report SSM Online and root identity matches the card. | Refuse before AWS group writes. | |
| + |
| +Mocks pin policy shape but cannot settle these checks. Retain the effective |
| +policy and authorization/audit evidence under the card's observation authority. |
| +The maintenance identity itself has no general IAM or alarm-inspection grant. |
| + |
| +Verify effective `carlos-system-update.path` and service masks, group |
| +`Restart=no`, package/needrestart policy and absence of automatic SSM-agent, |
| +patch or reboot associations. Check that unit repair preserves these settings. |
| +Run `plan`; require exit 0 and no refusals. Record its inspection log and the |
| +full starting member/activity/target baseline. |
| + |
| +## Step 2. Show a group member serving the fixture |
| + |
| +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 |
| +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 |
| +has been released. Require a legally free lease, or wait its remaining expiry |
| +under the normal acquisition rules, before the next cold wake. |
| + |
| +The alternative is the fixed holder's own attended restart window. It affects |
| +more tenants and a short restart may leave the same clean-release preference, |
| +so the card must prove the holder remains legitimately out for the wake. |
| +Paul's card chooses and scopes the method. Do not delete lease, clean-release, |
| +identity or debt records, falsify death, or change the placement chooser. |
| +If neither method can establish eligibility and lease release, record 7(b) |
| +as blocked instead of forcing placement. |
| + |
| +Cold-wake `<fixture-host>` and record request ID, response serving iid/box |
| +reference, app version and corresponding server log. Correlate the serving |
| +`g-` reference to the group's described iid, root status and published edges. |
| +Read the lock holder, generation, last renewal and expiry. Pass only if the |
| +fixture is actually served by a group member with the matching lock holder |
| +and one writer. A forwarding fixed edge or version header alone is insufficient. |
| +Record any remaining lease wait separately. Restore the original scope during |
| +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: |
| +[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. |
| + |
| +## Step 4. Roll and hold through the outage |
| + |
| +Before starting `roll`, attempt the unattended update path and an invalid |
| +permit under the card's negative-test scope. Use a wrong iid/boot ID or expired |
| +permit through the permit verb, never a direct file replacement. Require |
| +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, |
| +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. |
| + |
| +Require min=desired=1, max=2, unchanged member set and both target groups |
| +fully deregistered before the tool installs the valid permit. The preloaded |
| +harness then blocks S3+SSM at the guarded restart boundary. Collect local |
| +root-owned evidence independently of the SSM connection. The pass needs an |
| +actual new edge process under the block with tenant admission closed. If the |
| +cut session prevents that restart, record the interrupted-action result; |
| +it is not a passing restarted-outage witness and must not be bypassed. |
| + |
| +Keep the member unready in Standby for more than 15 minutes. Continue the |
| +bounded hold beyond 25 minutes to exercise alarm delivery. Record any |
| +15-minute operator alert and retain the journal, permit and same iid. Losing |
| +the operator connection must not cause an Exit, stop, replacement or termination. |
| +Retain lock ownership while the operator lives; if it dies, only the same |
| +journal may be resumed. A second operator must refuse the held group lock. |
| + |
| +Exercise direct HTTP, signed hop/backhaul, authenticated doors, tunnel delivery, |
| +timers, workers, co-spawn, sessions and duty import using the card's supported |
| +fixtures and network paths. For each, record request/job ID, destination iid, |
| +refusal or deferred-start result, and absence of tenant process creation. |
| +A namespace advertisement or an NLB probe does not establish admission; NLB |
| +can route to unhealthy targets. Retain ordinary lease, local-copy and duty |
| +rules. Missing fixtures mean NOT RUN, not a pass for the entire gate. |
| + |
| +Pass the hold only with the same iid and total member set, zero extra launches, |
| +replacements or terminations, zero lifecycle completions while unready in |
| +Standby, 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 |
| +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. |
| + |
| +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, |
| +artifact and PID/start identity. If completion is uncertain, retain Standby |
| +and investigate. A consumed incomplete action is not replayable. Test an |
| +explicit mid-apply Session Manager cut in a separately bounded repetition |
| +under the same card; require the same status-first behavior and no spontaneous |
| +return. Record the session ID, timing, remote timeout/TERM/KILL outcome and |
| +whether apply completed. A disconnect test is not proof that apply survived it. |
| + |
| +For a completed action, wait for fresh local health, admission and serve-role |
| +publication. Compare root status before and after the edges read. Require the |
| +same identity, expected digest and edges generation at least two seconds after |
| +`edge.started_at`, which is a lower bound. Measure the time from the first |
| +status response through the second status, journal fsync and Exit dispatch. |
| +The observation must still be at most five seconds old. The code permits |
| +60 seconds for ordinary readiness, but Exit/CONTINUE require five. Slow real |
| +session startup is a refusal, not permission to widen that bound. |
| + |
| +Use the tool's `return --transaction '<transaction>'` only when that state is |
| +established; `resume` may already complete return if readiness is restored. |
| +The single return controller handles these cases: |
| + |
| +| Observation | Required action and evidence | |
| +| --- | --- | |
| +| Standby, unready or stale/wrong-process evidence | No Exit or completion. Retain the member and transaction; alert after the bounded wait. | |
| +| Standby, freshly admitted | Persist current transaction/iid/boot/process/publication and intent, then Exit with observation age at most five seconds. | |
| +| Lost Exit response | Describe group, exact member, targets and activity before any write. Retry only from observed Standby with fresh evidence. Never blindly restore desired. | |
| +| Pending or PreInService | Observe transition; do not send another Exit or call it InService. | |
| +| Pending:Wait | Record provider divergence immediately. Only the serialized operator may send CONTINUE for this iid/hook after rechecking current-process admission. Journal transaction+iid+boot+process+Exit activity, each intent/outcome and at most four attempts with 1/2/4-second backoffs and two-second calls. Describe after an ambiguous response. The original launch receipt cannot suppress this action. | |
| +| Pending:Proceed | Observe; do not complete again. | |
| +| Admission/API access lost after a return hook | Record FAIL and alert immediately before the 900-second hook deadline. Send neither CONTINUE nor ABANDON. Restore reversible probe faults, stop all rolls and retain exact iid/hook/transaction/deadline. Default ABANDON may still terminate the disposable member; record that loss and replacement as a failed probe. Never use the ordinary 15-minute Standby wait here. | |
| +| InService, same iid, unchanged members, desired 2, both target groups healthy | On documented no-hook return, restore minimum 2, revoke permit last and verify absence. Zero return completions. On unexpected hook return, enter Standby again with decrement=true, verify deregistration, retain permit/record and block further rolls. | |
| + |
| +A divergent hook is always a failed provider-contract observation, even if |
| +CONTINUE safely preserves the iid. The synthetic Pending:Wait tests remain |
| +required offline; do not deliberately manufacture a live hook. Never interpret |
| +a lost session, elapsed time or old launch receipt as fresh admission. |
| + |
| +## Step 6. Exercise rollback and genuine local failure |
| + |
| +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 |
| +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 |
| +safe refusal when the existing guard cannot recover the action. |
| + |
| +Only after all maintenance faults are removed and both members are healthy |
| +may the card inject a genuine local hang outside maintenance. This has a |
| +separate fault scope and an expected replacement, unlike the Standby witness. |
| +Record exact process/iid, fault time, target exclusion, replacement launch, |
| +confirmed termination, queue evidence, lease expiry, boot/admission and first |
| +successful fixture response. Use Task 8's hang limits: exclusion within 30s, |
| +replacement launch within 180s, first200 within remaining lease plus 180s. |
| +No takeover before confirmed death and expiry. Restore a reversible hang only |
| +on the exact still-live process if the fault is aborted before termination. |
| +Do not use this step to terminate a box merely because S3 or SSM is unavailable. |
| + |
| +## Alarms, cleanup and evidence |
| + |
| +Keep alarm delivery enabled throughout. A Standby interval over 25 minutes is |
| +expected to trip HealthyHostCount. Annotate and acknowledge it with transaction |
| +ID and UTC window. Record SNS receipt, threshold/healthy readback and recovery. |
| +Do not lower thresholds or change the ASG deficit alarm to hide maintenance. |
| +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. |
| +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, |
| +record its exact state, retained resources and named owner instead of declaring |
| +cleanup complete or forcing return. |
| + |
| +Restore fixed scope and verified fixture service before any group teardown. |
| +Sleep fixtures through the supported API and check marker/debt state. Unclear |
| +state means retain resources and alert. Teardown requires the card's explicit |
| +resource list and cleanup plan; preserve shared ingress/EIPs, buckets and |
| +immutable fixed identity records. No reader downgrade until zero active group |
| +publishers and zero retained group namespace are proven. A silent peer is not |
| +retirement evidence. |
| + |
| +Retain the following on the private card: |
| + |
| +- Approved scope, UTC window, operator/cleanup owners, effective IAM and session |
| + document, release/module/script commits and artifact hashes. |
| +- Probe and transaction journals, member IDs, group UUID/template/hook, capacity, |
| + target states, activity IDs/counters and every API intent/outcome or lost reply. |
| +- Root status before/after, boot/process identity, local configuration hashes, |
| + permit/action/consumption, published generation and measured pre-Exit age. |
| +- Fault recipe/hash, timer and table readbacks/counters, session IDs and reconnect |
| + counts, local outage timeline, all entry-path results and request outages. |
| +- 7(b) response identity and lock proof, remaining lease wait, genuine-hang phases, |
| + termination/replacement and data-loss observations where exercised. |
| +- Alarm confirmation/delivery/acknowledgment/recovery, cleanup readback and every |
| + PASS, FAIL, BLOCKED or NOT RUN result. Preserve failed probes as failures. |
| + |
| +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 |
| +approved budget before execution. This witness alone does not establish full |
| +G2, duties drained, or any producer-dependent checks that remain unrun. |