| index db53755a..5b57bc59 100644 |
| --- a/docs/superpowers/plans/2026-12-01-hosted-2-dev-live-plan.md |
| +++ b/docs/superpowers/plans/2026-12-01-hosted-2-dev-live-plan.md |
| @@ -1,6 +1,7 @@ |
| # Hosted runners slice 2, Task 34: the dev drill in `kass` (for Paul's GO) |
| |
| -**Revision:** 3 (2026-12-02), after Astra's round 2 (`.superpowers/sdd/2026-11-30-hosted-runners-slice-2/p34-r2.md`), |
| +**Revision:** 3.1 (2026-12-02), after Astra's round 3 (`p34-r3.md`, its after-cap fixes, with the |
| +kit's `5b65ec54`); revision 3 came after Astra's round 2 (`.superpowers/sdd/2026-11-30-hosted-runners-slice-2/p34-r2.md`), |
| with the coordinator's revision 3 rulings (`task-34-rev3-brief.md`), the run kit's round 2 |
| (`dc868b1c`, `0acdeea7`; `kit-p34-report.md`, "Round 2") and the headless round 2 (`4efc4956`). |
| Revision 2 answered Astra's round 1 with rulings R1 to R10 (`task-34-rev2-brief.md`), the kit of |
| @@ -12,6 +13,33 @@ everything else, a ledger, systemd user units, teardown verified by direct reads |
| through `equipo-hosted-ops` (slice 2 Task 33), so this drill is that tool's first real run, ahead of |
| the production bring-up (`2026-11-30-hosted-prod-account-plan.md`, "the account plan"). |
| |
| +## Revision 3.1 (after Astra's last round) |
| + |
| +Astra's round 3 (`p34-r3.md`) found findings 1, 2 and 10 still open and two new defects (14, 15). |
| +With the kit's after-cap commit `5b65ec54` (`kit-p34-report.md`, "After cap"): |
| + |
| +1. **Teardown steps had no deadline** (finding 1). Every step in `teardown.sh` is now |
| + `ops block <id> --teardown --optional --max <D> -- bash "$P/teardown.sh" step <id>` (kit K12): past its deadline the block kills the |
| + step's process group, journals `DEADLINE`, reconciles any root it cut short and exits 1, which |
| + takes the step's one retry where it has one, and otherwise stops the script (`escalate`). 8.3 is |
| + split: 8.3a (terminate and unfence, no retry) and 8.3b (the services destroy, one retry). Every |
| + hand-run unit has `ops unit start <id> --max <bound> -- bash "$P/blocks/<id>.sh"`, so systemd ends it at its bound. 8.0's sum |
| + with every retry is 21 h 28 min, inside the 23 hours with 92 minutes to spare; from the deadlines, |
| + the hosts are gone within **432 minutes (7 h 12 min) of a trigger, about $0.44**, or the script |
| + has stopped and asked Paul. |
| +2. **`vms adopt` classified late** (finding 2). The strike classifies `vms adopt` before it starts |
| + `vms scan`. |
| +10. **The reboot's timing** (finding 10). The strike passes `--not-after <strike_before>` (kit K13), |
| + so the command itself refuses to send a late reboot (`REBOOT-LATE`, exit 1, no reboot); the |
| + watcher judges by `REBOOT-SENT`'s `at=` time, the provider's answer. `REBOOT-LATE`, or a |
| + `REBOOT-SENT` after `strike_before`, is a missed window, not judged. |
| +14. **The tab** (finding 14). A journal line is `<stamp><TAB><VERB> <text>`; the unknown-ID check |
| + is now `controller_vm` in `run.env`, which splits the fields with `awk -F'\t'` and matches the |
| + verb field `VM <id> source=controller ... attempt=`. |
| +15. **Suites after a refused reservation** (finding 15). The `suite` helper does nothing once |
| + `skipped` reports a reason, and every suite step says to start it only while `skipped` prints |
| + nothing; 6.2a's and 7.0's refusals go straight to teardown. |
| + |
| ## Revision 3: each open finding of Astra's round 2 and its fix |
| |
| 1. **Unattended recovery left spend unbounded** (finding 1). Section 8 is one script, |
| @@ -161,9 +189,9 @@ back to Paul. |
| |
| **Spend** (section 9): the bill is expected at about **$1.80**, at most about $5. The run's own |
| estimate, which charges every admitted VM at four times the Large rate for 90 minutes, ends near |
| -**$26.68** to plan, with a proven worst case of **$32.66**. Self-stop **$40**; ceiling **$50**. |
| -After a safe stop the armed teardown runs unattended: the hosts are gone within about 6 hours of |
| -the trigger, at most about **$0.33** more. |
| +**$26.68** to plan, with a proven worst case of **$32.77**. Self-stop **$40**; ceiling **$50**. |
| +After a safe stop the armed teardown runs unattended: from its steps' deadlines the hosts are gone |
| +within 7 h 12 min of the trigger, at most about **$0.44** more, or it stops and asks Paul. |
| |
| **Paul's own steps:** confirm the dev alert subscription (2.4, any time before 7.4); sign the |
| certificate (5.4, bounded 12 hours); confirm the test alert arrived (7.4, bounded 2 hours). Past the |
| @@ -232,7 +260,8 @@ Staging is fixed: app `equipo-staging`, account `bds`, console `https://console. |
| and a timeout of the block's bound plus 40 minutes (a 10-minute bound unless stated, so 50 |
| minutes): on any non-zero exit `ops block` asks for recovery and waits for it, up to 35 minutes 45 |
| seconds (`kit-p34-report.md`, "Bounds"). |
| -- **Long blocks** run as units: `ops unit start <id> -- bash "$P/blocks/<id>.sh"`. The agent then |
| +- **Long blocks** run as units: `ops unit start <id> --max <bound> -- bash "$P/blocks/<id>.sh"`, so |
| + systemd itself ends a unit at its bound (`RuntimeMaxSec`, kit K12). The agent then |
| polls in short foreground calls, sandbox off, each at most 8 minutes and never a stop: |
| `bash -c '. "<P>/run.env"; upoll <id> <bound minutes>'`. `upoll` reads `ops unit status <id>` every |
| 30 seconds and prints one word: `running` (call again), `done <result> <status>`, `over` (the bound |
| @@ -247,7 +276,7 @@ Staging is fixed: app `equipo-staging`, account `bds`, console `https://console. |
| 1.2 runs outside `ops block` with a 50-minute timeout. OpenTofu has no time bound of its own; the |
| unit's bound is its limit. |
| - **Retries.** A replayable unit that ended `done failed 1` (an ordinary failure) is started again |
| - once as `ops unit start <id>.retry1 -- bash "$P/blocks/<id>.sh"` and polled the same way; its own |
| + once as `ops unit start <id>.retry1 --max <bound> -- bash "$P/blocks/<id>.sh"` and polled the same way; its own |
| end goes to `ops unit wait <id>.retry1 --max <bound>`. Replayable: 2.3, 2.4, 4.1 (an apply plans |
| creates and no-ops), 4.2, 5.1. Not replayable, because they create, strike or tear down: 2.5, 3.3, |
| 5.2, the watchers, `8`; their expected failures are handled inside. Section 8 retries its own steps |
| @@ -263,7 +292,7 @@ Staging is fixed: app `equipo-staging`, account `bds`, console `https://console. |
| failure came first (kit K9); the agent then polls it (`upoll teardown 1380`) and never starts |
| section 8 beside it. Before 2.2b nothing is armed and the agent runs section 8 by hand. |
| - **Section 8 by hand.** When the drill reaches section 8 with no stop, or a stop came before 2.2b: |
| - `ops continuation disarm` (from 2.2b on), then `ops unit start 8 -- bash "$P/teardown.sh"`, polled |
| + `ops continuation disarm` (from 2.2b on), then `ops unit start 8 --max 23h -- bash "$P/teardown.sh"`, polled |
| with `upoll 8 1380`. If the journal shows `CONTINUATION started`, the continuation is running it |
| already: poll `ops unit status teardown` instead. |
| - **Fatal checks are `ops assert`, observations `ops fact`, findings `ops finding`.** |
| @@ -356,13 +385,16 @@ live() { jq -e '(.proxies | length) == 2 and all(.proxies[]; .fed and .last_feed |
| status_live() { local end=$(( $(date +%s) + 900 )); while [ "$(date +%s)" -lt "$end" ]; do rm -f "$P/status.json"; "${OPSB[@]}" status > /dev/null 2>&1 || true; if [ -s "$P/status.json" ] && live; then return 0; fi; sleep 30; done; return 1; } |
| images() { awk -F'\t' '{print $2}' "$P/journal.tsv" | awk '$1 == "REC" && $2 == "microvm-image" {print $3}' | sort -u; } |
| upoll() { local b=$1 max=$2 end=$(( $(date +%s) + 480 )) fails=0 s; while [ "$(date +%s)" -lt "$end" ]; do if s=$("${OPSB[@]}" unit status "$b" 2>/dev/null); then fails=0; if [ "$(jq -r .state <<<"$s")" = done ]; then echo "done $(jq -r '.result' <<<"$s") $(jq -r '.status' <<<"$s")"; return 0; fi; if [ "$(jq -r .elapsed_seconds <<<"$s")" -ge $(( max * 60 )) ]; then echo over; return 0; fi; else fails=$(( fails + 1 )); if [ "$fails" -ge 3 ]; then echo unreadable; return 0; fi; fi; sleep 30; done; echo running; } |
| -suite() { (cd "$P/repo" && EQUIPO_STAGING_HOSTED_PROJECT="$HOSTED_PROJECT" python3 scripts/staging-thin.py suite "$@"); } |
| +suite() { if skipped; then return 0; fi; (cd "$P/repo" && EQUIPO_STAGING_HOSTED_PROJECT="$HOSTED_PROJECT" python3 scripts/staging-thin.py suite "$@"); } |
| pline() { grep "^$1 run=$2 " "$PROG" 2>/dev/null | tail -n 1 || true; } |
| field() { sed -n "s/.* $1=\([^ ]*\).*/\1/p" <<<"$2"; } |
| result_field() { sed -n 's/.* result=//p' <<<"$1"; } |
| jtime() { awk -F'\t' -v v="$1" 'index($2, v " ") == 1 {t = $1} END {print t}' "$P/journal.tsv"; } |
| settle_step() { "${OPSB[@]}" vms settle --step "$1" ${2:+--ended-at "$2"} --image "$3" --max 10m; } |
| -bg_reboot() { "${OPSB[@]}" controller reboot --enabled 1 --max 10m > "$P/reboot.out" 2>&1 & } |
| +bg_reboot() { "${OPSB[@]}" controller reboot --enabled 1 --max 10m --not-after "$1" > "$P/reboot.out" 2>&1 & } |
| +controller_vm() { awk -F'\t' -v id="$1" 'index($2, "VM " id " source=controller ") == 1 && $2 ~ / attempt=/ {f = 1} END {exit !f}' "$P/journal.tsv"; } |
| +sent_time() { awk -F'\t' 'index($2, "REBOOT-SENT ") == 1 {t = $2} END {print t}' "$P/journal.tsv" | sed -n 's/.* at=\([^ ]*\).*/\1/p'; } |
| +rebooted_late() { awk -F'\t' 'index($2, "REBOOT-LATE ") == 1 {f = 1} END {exit !f}' "$P/journal.tsv"; } |
| EOF |
| "$P/bin/equipo-hosted-ops" -dir "$P" -run "$RUN" ledger init |
| "$P/bin/equipo-hosted-ops" -dir "$P" -run "$RUN" unit probe |
| @@ -1051,7 +1083,8 @@ ordinary "$rc" |
| if [ "$rc" = 1 ]; then skip_to_teardown "the checks VMs were not admitted"; exit 0; fi |
| ``` |
| |
| -Six: three steps, each with one retry. Codes: 1 skips, 99 goes to recovery. |
| +Six: three steps, each with one retry. Codes: 1 goes straight to section 8 and no suite starts |
| +(finding 15); 99 goes to recovery. |
| |
| **The scenario watcher, `watch.sh`.** The agent writes it once, exactly as printed, to |
| `$P/blocks/watch.sh`. It runs as a unit beside each suite run, with the scenario and the mode as its |
| @@ -1094,7 +1127,6 @@ and the end (2): 102, so **105 minutes**. 7.1 adds the reboot's status (`status_ |
| set -euo pipefail; P='<P printed by 0.1>'; . "$P/run.env" |
| NAME=$1; MODE=$2 |
| if skipped; then exit 0; fi |
| -if [ "$MODE" != plain ] && [ -e "$P/drills-skipped" ]; then exit 0; fi |
| IMAGE_ARN=$(jq -er .ImageArn "$P/image.json") |
| CTL="https://$(tfo services controller_public_ip)"; PIN_HEX=$(cat "$P/controller.pin") |
| case "$NAME/$MODE" in |
| @@ -1164,20 +1196,23 @@ strike() { |
| set +e |
| ops vms adopt |
| a=$? |
| + set -e |
| + ordinary "$a" |
| + set +e |
| SCAN=$(ops vms scan --image "$IMAGE_ARN" --max 2m | tail -n 1) |
| rc=$? |
| set -e |
| - ordinary "$a"; ordinary "$rc" |
| + ordinary "$rc" |
| LIVE=$(jq -r '[.[] | select(.State != "TERMINATED") | .ID] | join(" ")' <<<"$SCAN" 2>/dev/null || true) |
| ok=no |
| if [ "$rc" = 0 ] && [ "$VM" != unknown ] && grep -qw -- "$VM" <<<"$LIVE"; then ok=yes; fi |
| - if [ "$rc" = 0 ] && [ "$VM" = unknown ] && [ "$(wc -w <<<"$LIVE")" = 1 ] && grep -q " VM $LIVE source=controller .*attempt=" "$P/journal.tsv"; then ok=yes; fi |
| + if [ "$rc" = 0 ] && [ "$VM" = unknown ] && [ "$(wc -w <<<"$LIVE")" = 1 ] && controller_vm "$LIVE"; then ok=yes; fi |
| if [ "$ok" != yes ]; then ops finding "$STEP: missed window, vm=$VM live=${LIVE:-none}"; return 0; fi |
| if [ $(( $(date +%s) + 60 )) -gt "$before" ]; then ops finding "$STEP: missed window, too little time left before $(field strike_before "$B")"; return 0; fi |
| case "$MODE" in |
| controller-reboot) |
| ops ledger note strike "controller-reboot started at $(date -u +%FT%TZ) vm=$LIVE" |
| - bg_reboot |
| + bg_reboot "$(field strike_before "$B")" |
| RB=$! |
| struck=pending;; |
| withdraw-cert) |
| @@ -1233,11 +1268,17 @@ if [ -n "$RB" ]; then |
| rb=$? |
| set -e |
| cat "$P/reboot.out" |
| - if [ "$rb" != 0 ]; then echo "the controller reboot failed (exit $rb) with a VM running"; exit 99; fi |
| - RT=$(jtime REBOOT) |
| - if [ -n "$RT" ] && [ "$(date -d "$RT" +%s)" -le "$before" ]; then struck=yes; else ops finding "$STEP: missed window (late), the reboot was journalled at ${RT:-never}, after strike_before"; struck=late; fi |
| - if ! status_live; then echo "the controller and proxies were not live within 15 minutes of the reboot"; exit 99; fi |
| - ops assert status |
| + if rebooted_late; then |
| + ops finding "$STEP: missed window, the reboot command refused to send it after strike_before (REBOOT-LATE)" |
| + struck=late |
| + elif [ "$rb" != 0 ]; then |
| + echo "the controller reboot failed (exit $rb) with a VM running"; exit 99 |
| + else |
| + ST=$(sent_time) |
| + if [ -n "$ST" ] && [ "$(date -d "$ST" +%s)" -le "$before" ]; then struck=yes; else ops finding "$STEP: missed window (late), REBOOT-SENT at ${ST:-never}, after strike_before"; struck=late; fi |
| + if ! status_live; then echo "the controller and proxies were not live within 15 minutes of the reboot"; exit 99; fi |
| + ops assert status |
| + fi |
| fi |
| if [ "$uploaded" = yes ] && [ "$reloaded" = yes ]; then put_back reload; elif [ "$uploaded" = yes ]; then put_back none; fi |
| SU=$(pline HOSTED-SUITE "$RUNID"); END=$(pline HOSTED-END "$RUNID") |
| @@ -1253,11 +1294,12 @@ ops fact "$STEP" "$GOT" "$WANT" |
| |
| **For each scenario in turn, `hosted-pass`, then `hosted-fail`, then `hosted-new-module`:** |
| |
| -1. start its suite in the agent's shell (sandbox off, background, 60 minutes): |
| +1. only while `bash -c '. "<P>/run.env"; skipped'` prints nothing (the `suite` helper refuses |
| + too), start its suite in the agent's shell (sandbox off, background, 60 minutes): |
| `bash -c '. "<P>/run.env"; suite hosted-pass'` (then `hosted-fail`, `hosted-new-module`); |
| -2. start its watcher: `ops unit start 6.2.pass -- bash "$P/blocks/watch.sh" hosted-pass plain` |
| - (then `ops unit start 6.2.fail -- bash "$P/blocks/watch.sh" hosted-fail plain` and |
| - `ops unit start 6.2.newmod -- bash "$P/blocks/watch.sh" hosted-new-module plain`), polled with |
| +2. start its watcher: `ops unit start 6.2.pass --max 105m -- bash "$P/blocks/watch.sh" hosted-pass plain` |
| + (then `ops unit start 6.2.fail --max 105m -- bash "$P/blocks/watch.sh" hosted-fail plain` and |
| + `ops unit start 6.2.newmod --max 105m -- bash "$P/blocks/watch.sh" hosted-new-module plain`), polled with |
| `upoll` (105 minutes); |
| 3. start the next scenario only when the watcher's `ops unit wait` has returned 0. |
| |
| @@ -1281,17 +1323,17 @@ ops reserve vm 4 |
| rc=$? |
| set -e |
| ordinary "$rc" |
| -if [ "$rc" = 1 ]; then ops finding "the drill VMs were not admitted, the drills are skipped"; touch "$P/drills-skipped"; fi |
| +if [ "$rc" = 1 ]; then skip_to_teardown "the drill VMs were not admitted"; exit 0; fi |
| ``` |
| |
| -Four: two drills, each with one retry. Codes: 1 skips both drills (7.4 still runs), 99 goes to |
| -recovery. Then, for 7.1 and 7.2 in turn, unless `$P/drills-skipped` exists: |
| +Four: two drills, each with one retry. Codes: 1 goes straight to section 8 and no suite starts |
| +(finding 15); 99 goes to recovery. Then, for 7.1 and 7.2 in turn, while `skipped` prints nothing: |
| |
| 1. the suite in the agent's shell (background, 60 minutes): |
| `bash -c '. "<P>/run.env"; suite hosted-slow mode=controller-reboot'` (7.1) or |
| `bash -c '. "<P>/run.env"; suite hosted-slow mode=withdraw-cert'` (7.2); |
| -2. the watcher: `ops unit start 7.1 -- bash "$P/blocks/watch.sh" hosted-slow controller-reboot` |
| - (135 minutes) or `ops unit start 7.2 -- bash "$P/blocks/watch.sh" hosted-slow withdraw-cert` |
| +2. the watcher: `ops unit start 7.1 --max 135m -- bash "$P/blocks/watch.sh" hosted-slow controller-reboot` |
| + (135 minutes) or `ops unit start 7.2 --max 110m -- bash "$P/blocks/watch.sh" hosted-slow withdraw-cert` |
| (110 minutes), polled with `upoll`. |
| |
| **The strike, in the watcher.** On `HOSTED-BARRIER run=<id>`: |
| @@ -1304,12 +1346,14 @@ recovery. Then, for 7.1 and 7.2 in turn, unless `$P/drills-skipped` exists: |
| must own it (its `VM ... source=controller ... attempt=` line). Otherwise: FINDING "missed window". |
| - Immediately before the mutation it checks the deadline, keeping 60 seconds for the call: now plus |
| 60 seconds must not pass `strike_before`, or "missed window". |
| -- 7.1's mutation is `ops controller reboot --enabled 1 --max 10m`, started in the background inside |
| - the watcher (so the step's settle is not held up behind it); its time is the journal's `REBOOT` |
| - line, written just before the reboot call, after the guard and the policy read. 7.2's mutation is |
| +- 7.1's mutation is `ops controller reboot --enabled 1 --max 10m --not-after 2026-12-02T10:03:20Z` |
| + (the barrier's `strike_before`), started in the background inside the watcher (so the step's settle |
| + is not held up behind it). The command checks the deadline itself, after its guard and reads and |
| + immediately before the reboot call: late, it sends nothing and journals `REBOOT-LATE`. Its time is |
| + `REBOOT-SENT`'s `at=`, when the provider accepted the reboot. 7.2's mutation is |
| `cert reload`; its time is when the reload answered `"certificates": 0`. |
| -- After the mutation, that time is compared with `strike_before`: later is "missed window (late)", |
| - and the drill is not judged. |
| +- After the mutation, that time is compared with `strike_before`: later, or `REBOOT-LATE`, is |
| + "missed window", and the drill is not judged. |
| - If 7.2 uploaded the empty set but never reloaded, it puts the real set back with no reload (the |
| controller never read the empty one). |
| |
| @@ -1365,42 +1409,59 @@ section S and the armed continuation runs section 8; the record shows the alert |
| ## 8. Teardown and verification |
| |
| Section 8 is one script, `$P/teardown.sh` (8.0), written and armed at 2.2b. It runs: |
| -- **unattended**, as the armed continuation `hdev-<RUN>-teardown`, which the recovery unit starts |
| - after any safe stop but a guard failure (or a failed credential check). If the agent is attending |
| - it polls it (`upoll teardown 1380`) and never starts section 8 beside it; |
| +- **unattended**, as the armed continuation `hdev-<RUN>-teardown` (its `RuntimeMaxSec` is the 23 |
| + hours it was armed with), which the recovery unit starts after any safe stop but a guard failure |
| + (or a failed credential check). If the agent is attending it polls it (`upoll teardown 1380`) and |
| + never starts section 8 beside it; |
| - **by hand**, when the drill reaches here with no stop (or a stop came before 2.2b): |
| - `ops continuation disarm`, then `ops unit start 8 -- bash "$P/teardown.sh"`, polled with |
| + `ops continuation disarm`, then `ops unit start 8 --max 23h -- bash "$P/teardown.sh"`, polled with |
| `upoll 8 1380`. |
| |
| -Inside, every step is `ops block <id> --teardown -- bash "$P/teardown.sh" step <id>` (the guard and the ledger's ownership run, the spend |
| -gate does not, and any create refuses with 99). Order (R5): staging off, fence and settle, terminate, |
| -unfence and the services destroy, then the images, the connector, the buckets and the other roots, |
| -then verification. A step that may be retried runs `--optional` first; on exit 1 it runs once more as |
| -`<id>.retry1`, required; 99 always stops. A required step that fails asks for recovery, which spares |
| -the continuation and does not start it again; the block exits 99, the script ends (`set -e`), and |
| -the run reports what still exists and its daily cost (`ops report --stopped`) and asks Paul. That |
| -spend is not bounded until he answers. |
| +Inside, every step is `ops block <id> --teardown --optional --max <D> -- bash "$P/teardown.sh" step <id>` |
| +(revision 3.1, kit K12): the guard and the ledger's ownership run, the spend gate does not, any create |
| +refuses with 99, and **the step has a deadline**. Past it, the block stops the step's whole process |
| +group (TERM, KILL 30 seconds later; OpenTofu inside gets TERM at the deadline), journals `DEADLINE`, |
| +reconciles any root whose apply or destroy it cut short (`tf reconcile`, up to 15 minutes) and exits |
| +1. A killed step is not a resource gone: the reconcile records what state says, and `verify-gone` |
| +judges at the end. So each step ends within its `--max` plus 30 seconds, plus 15 minutes if it cut a |
| +root short, plus the guard. Exit 1 (an ordinary failure or the deadline) takes the step's one retry |
| +where it has one (`<id>.retry1`, same deadline); a second 1, or a 1 from a step with no retry, stops |
| +the script (`escalate`: a FINDING, `ops report --stopped`, exit 99). 99 always stops: the block asks |
| +for recovery, which spares the continuation and does not start it again. Either way the run reports |
| +what still exists and its daily cost and asks Paul; that spend is not bounded until he answers. |
| |
| ### 8.0 The script, and its bound |
| |
| -| Step | One attempt (from the kit's bounds) | Attempts | Budget | |
| -| --- | --- | --- | --- | |
| -| `ops unit stop --all` and 8.1, staging off: five `carlos` calls, the guard, up to four units stopped at 90 s each | 20 m | 1 | 20 m | |
| -| 8.2: `ops fence` (guard 2, attach and read 2, host stop 10), `vms reconcile` (5), each image's settle with its repeat (15 + 10 + 15 and a guard: 41; two images 82), `ledger reconcile` (5) | 108 m, so 110 | 1 (fence and settle have no ordinary class; reconcile's 1 is a FINDING inside) | 110 m | |
| -| 8.3: `controller terminate` (12), `unfence` (5), its one repeat (fence 14, settles 82, unfence 5), the services destroy (30), `tf reconcile` (10), the destroy again (30) | 188 m, so 190 | 1 (its repeats are inside) | 190 m | |
| -| 8.4.1, 8.4.2: one image delete each (`-timeout 15m`, plus guard, STS and reads: 20) | 20 m | 2 each (`.retry1` on exit 1) | 80 m | |
| -| 8.5: `connector delete` (its 120-minute budget, then reads) | 130 m | 2 (`8.5.retry1` on exit 1) | 260 m | |
| -| 8.6: three bucket empties (7 each), the config destroy, `tf reconcile` and destroy again (70), the network the same (70) | 161 m, so 165 | 2 (`8.6.retry1` on exit 1; buckets resumable) | 330 m | |
| -| 8.7: `verify-gone` (about 90 direct reads at up to 60 s: 90), once more on exit 1 (90), the state bucket's empty and delete (10), `verify-gone --all` (90), `estimate` (5) | 285 m | 1 | 285 m | |
| -| One recovery, when a required step fails | 36 m | 1 | 36 m | |
| -| **Sum** | | | **1311 m = 21 h 51 min** | |
| - |
| -`--max 23h` (1380 minutes) leaves 69 minutes' margin, under the kit's 24-hour cap. From a trigger (a |
| -watchdog's deadline or a failed block), the continuation starts within about 31 minutes plus 90 |
| -seconds per running unit (at most four here: about 37 minutes) and runs at most 23 hours plus a |
| -5-minute stop: **about 23 h 42 min end to end**. The hosts are gone when 8.3 ends, at most |
| -37 + 20 + 110 + 190 = 357 minutes after the trigger: **6 host-hours, about $0.33**. Image storage is |
| -already charged at its one-week minimum; the buckets, the connector and the topic cost pennies. |
| +Each attempt's wall time is its `--max`, plus 30 seconds (TERM to KILL), plus 15 minutes for the |
| +reconcile where the step runs OpenTofu (8.3b, 8.6), plus 2 for the guard. |
| + |
| +| Step | What it runs (from the kit's bounds) | `--max` | Wall per attempt | Attempts | Budget | |
| +| --- | --- | --- | --- | --- | --- | |
| +| `ops unit stop --all`, then 8.1 | staging off: five `carlos` calls, up to four units stopped at 90 s each | 20m | 22.5 m | 2 | 45 m | |
| +| 8.2 | `ops fence` (guard 2, attach and read 2, host stop 10), `vms reconcile` (5), each image's settle with its repeat (41; two images 82), `ledger reconcile` (5): 108 | 110m | 112.5 m | 1 | 112.5 m | |
| +| 8.3a | `controller terminate` (12), `unfence` (5), its one repeat (fence 14, settles 82, unfence 5): 118 | 120m | 122.5 m | 1 | 122.5 m | |
| +| 8.3b | the services destroy (30), `tf reconcile` on its failure (10): 40 | 40m | 57.5 m | 2 | 115 m | |
| +| 8.4.1, 8.4.2 | one image delete each (`-timeout 15m`, plus guard, STS and reads: 20) | 20m | 22.5 m | 2 each | 90 m | |
| +| 8.5 | `connector delete` (its 120-minute budget, then reads) | 130m | 132.5 m | 2 | 265 m | |
| +| 8.6 | three bucket empties (7 each), the config destroy (30) and its reconcile on failure (10), the network the same (40): 101 | 105m | 122.5 m | 2 | 245 m | |
| +| 8.7 | `verify-gone` (about 90 direct reads at up to 60 s: 90), once more on exit 1 (90), the state bucket's empty and delete (10), `verify-gone --all` (90), `estimate` (5) | 285m | 287.5 m | 1 | 287.5 m | |
| +| `escalate` | a FINDING and `ops report --stopped` | | | 1 | 5 m | |
| +| **Sum** | | | | | **1287.5 m = 21 h 28 min** | |
| + |
| +`--max 23h` (1380 minutes) leaves **92 minutes** for cleanup and slack, under the kit's 24-hour cap; |
| +every step's deadline is enforced, so the script cannot run into `RuntimeMaxSec` with a step still |
| +inside a stalled call. From a trigger (a watchdog's deadline or a failed block), the continuation |
| +starts within about 31 minutes plus 90 seconds per running unit (at most four here: about 37), and |
| +ends within 23 hours plus a 5-minute stop: **about 23 h 42 min end to end**. |
| + |
| +**When the hosts are gone, from the deadlines.** The controller is terminated in 8.3a and the proxies |
| +in 8.3b's destroy. So the hosts are gone, at the latest, 37 + 45 (8.1, two attempts) + 112.5 (8.2) + |
| +122.5 (8.3a) + 115 (8.3b, two attempts) = **432 minutes, 7 h 12 min after the trigger**, or the |
| +script has stopped and asked Paul: 8.2 or 8.3a past its deadline, or 8.3b failing twice. Bounded, |
| +that is at most **8 host-hours in the estimate, about $0.44**. Image storage is already charged at |
| +its one-week minimum; the buckets, the connector and the topic cost pennies. After an escalation |
| +before 8.3b finishes, the proxies, the addresses and the volumes stay (about $0.80 a day, the |
| +controller already stopped by the fence) until Paul answers. |
| |
| ```sh |
| set -euo pipefail; P='<P printed by 0.1>'; . "$P/run.env" |
| @@ -1429,7 +1490,7 @@ if [ "${1:-}" = step ]; then |
| done |
| ops ledger reconcile |
| ;; |
| - 8.3) |
| + 8.3a) |
| ops controller terminate |
| set +e |
| ops unfence |
| @@ -1443,17 +1504,15 @@ if [ "${1:-}" = step ]; then |
| done |
| ops unfence |
| fi |
| + ;; |
| + 8.3b) |
| if grep -q 'TF-APPLY services start' "$P/journal.tsv"; then |
| set +e |
| ops tf services destroy-dev-services |
| rc=$? |
| set -e |
| ordinary "$rc" |
| - if [ "$rc" = 1 ]; then |
| - ops finding "services destroy failed (exit 1), reconciling and destroying once more" |
| - ops tf reconcile services |
| - ops tf services destroy-dev-services |
| - fi |
| + if [ "$rc" = 1 ]; then ops finding "services destroy failed (exit 1), reconciling before the retry"; ops tf reconcile services; exit 1; fi |
| fi |
| ;; |
| 8.4) |
| @@ -1478,11 +1537,7 @@ if [ "${1:-}" = step ]; then |
| rc=$? |
| set -e |
| ordinary "$rc" |
| - if [ "$rc" = 1 ]; then |
| - ops finding "config destroy failed (exit 1), reconciling and destroying once more" |
| - ops tf reconcile config |
| - ops tf config destroy-dev-config |
| - fi |
| + if [ "$rc" = 1 ]; then ops finding "config destroy failed (exit 1), reconciling before the retry"; ops tf reconcile config; exit 1; fi |
| fi |
| if grep -q 'TF-APPLY network start' "$P/journal.tsv"; then |
| set +e |
| @@ -1490,11 +1545,7 @@ if [ "${1:-}" = step ]; then |
| rc=$? |
| set -e |
| ordinary "$rc" |
| - if [ "$rc" = 1 ]; then |
| - ops finding "network destroy failed (exit 1), reconciling and destroying once more" |
| - ops tf reconcile network |
| - ops tf network destroy-dev-network |
| - fi |
| + if [ "$rc" = 1 ]; then ops finding "network destroy failed (exit 1), reconciling before the retry"; ops tf reconcile network; exit 1; fi |
| fi |
| ;; |
| 8.7) |
| @@ -1513,66 +1564,135 @@ if [ "${1:-}" = step ]; then |
| esac |
| exit 0 |
| fi |
| +escalate() { ops finding "teardown stopped: $1"; ops report --stopped --out "$P/report-stopped.md"; exit 99; } |
| ops unit stop --all |
| -ops block 8.1 --teardown -- bash "$P/teardown.sh" step 8.1 |
| -ops block 8.2 --teardown -- bash "$P/teardown.sh" step 8.2 |
| -ops block 8.3 --teardown -- bash "$P/teardown.sh" step 8.3 |
| +set +e |
| +ops block 8.1 --teardown --optional --max 20m -- bash "$P/teardown.sh" step 8.1 |
| +rc=$? |
| +set -e |
| +ordinary "$rc" |
| +if [ "$rc" = 1 ]; then |
| + set +e |
| + ops block 8.1.retry1 --teardown --optional --max 20m -- bash "$P/teardown.sh" step 8.1 |
| + rc=$? |
| + set -e |
| + ordinary "$rc" |
| + if [ "$rc" = 1 ]; then escalate "8.1 failed twice"; fi |
| +fi |
| +set +e |
| +ops block 8.2 --teardown --optional --max 110m -- bash "$P/teardown.sh" step 8.2 |
| +rc=$? |
| +set -e |
| +ordinary "$rc" |
| +if [ "$rc" = 1 ]; then escalate "8.2 did not finish within its deadline"; fi |
| +set +e |
| +ops block 8.3a --teardown --optional --max 120m -- bash "$P/teardown.sh" step 8.3a |
| +rc=$? |
| +set -e |
| +ordinary "$rc" |
| +if [ "$rc" = 1 ]; then escalate "8.3a did not finish within its deadline"; fi |
| +set +e |
| +ops block 8.3b --teardown --optional --max 40m -- bash "$P/teardown.sh" step 8.3b |
| +rc=$? |
| +set -e |
| +ordinary "$rc" |
| +if [ "$rc" = 1 ]; then |
| + set +e |
| + ops block 8.3b.retry1 --teardown --optional --max 40m -- bash "$P/teardown.sh" step 8.3b |
| + rc=$? |
| + set -e |
| + ordinary "$rc" |
| + if [ "$rc" = 1 ]; then escalate "the services destroy failed twice"; fi |
| +fi |
| I1=$(images | sed -n 1p); I2=$(images | sed -n 2p) |
| if [ -n "$I1" ]; then |
| set +e |
| - ops block 8.4.1 --teardown --optional -- bash "$P/teardown.sh" step 8.4 "$I1" |
| + ops block 8.4.1 --teardown --optional --max 20m -- bash "$P/teardown.sh" step 8.4 "$I1" |
| rc=$? |
| set -e |
| ordinary "$rc" |
| - if [ "$rc" = 1 ]; then ops block 8.4.1.retry1 --teardown -- bash "$P/teardown.sh" step 8.4 "$I1"; fi |
| + if [ "$rc" = 1 ]; then |
| + set +e |
| + ops block 8.4.1.retry1 --teardown --optional --max 20m -- bash "$P/teardown.sh" step 8.4 "$I1" |
| + rc=$? |
| + set -e |
| + ordinary "$rc" |
| + if [ "$rc" = 1 ]; then escalate "the first image's delete failed twice"; fi |
| + fi |
| fi |
| if [ -n "$I2" ]; then |
| set +e |
| - ops block 8.4.2 --teardown --optional -- bash "$P/teardown.sh" step 8.4 "$I2" |
| + ops block 8.4.2 --teardown --optional --max 20m -- bash "$P/teardown.sh" step 8.4 "$I2" |
| + rc=$? |
| + set -e |
| + ordinary "$rc" |
| + if [ "$rc" = 1 ]; then |
| + set +e |
| + ops block 8.4.2.retry1 --teardown --optional --max 20m -- bash "$P/teardown.sh" step 8.4 "$I2" |
| + rc=$? |
| + set -e |
| + ordinary "$rc" |
| + if [ "$rc" = 1 ]; then escalate "the second image's delete failed twice"; fi |
| + fi |
| +fi |
| +set +e |
| +ops block 8.5 --teardown --optional --max 130m -- bash "$P/teardown.sh" step 8.5 |
| +rc=$? |
| +set -e |
| +ordinary "$rc" |
| +if [ "$rc" = 1 ]; then |
| + set +e |
| + ops block 8.5.retry1 --teardown --optional --max 130m -- bash "$P/teardown.sh" step 8.5 |
| rc=$? |
| set -e |
| ordinary "$rc" |
| - if [ "$rc" = 1 ]; then ops block 8.4.2.retry1 --teardown -- bash "$P/teardown.sh" step 8.4 "$I2"; fi |
| + if [ "$rc" = 1 ]; then escalate "the connector delete failed twice"; fi |
| fi |
| set +e |
| -ops block 8.5 --teardown --optional -- bash "$P/teardown.sh" step 8.5 |
| +ops block 8.6 --teardown --optional --max 105m -- bash "$P/teardown.sh" step 8.6 |
| rc=$? |
| set -e |
| ordinary "$rc" |
| -if [ "$rc" = 1 ]; then ops block 8.5.retry1 --teardown -- bash "$P/teardown.sh" step 8.5; fi |
| +if [ "$rc" = 1 ]; then |
| + set +e |
| + ops block 8.6.retry1 --teardown --optional --max 105m -- bash "$P/teardown.sh" step 8.6 |
| + rc=$? |
| + set -e |
| + ordinary "$rc" |
| + if [ "$rc" = 1 ]; then escalate "the buckets or a destroy failed twice"; fi |
| +fi |
| set +e |
| -ops block 8.6 --teardown --optional -- bash "$P/teardown.sh" step 8.6 |
| +ops block 8.7 --teardown --optional --max 285m -- bash "$P/teardown.sh" step 8.7 |
| rc=$? |
| set -e |
| ordinary "$rc" |
| -if [ "$rc" = 1 ]; then ops block 8.6.retry1 --teardown -- bash "$P/teardown.sh" step 8.6; fi |
| -ops block 8.7 --teardown -- bash "$P/teardown.sh" step 8.7 |
| +if [ "$rc" = 1 ]; then escalate "8.7 did not finish within its deadline"; fi |
| echo "section 8 done; 8.8 is the agent's" |
| ``` |
| |
| **What each step does.** 8.1 turns hosted work off on staging (an unset of a variable never set is a |
| FINDING; 1.2 showed what it does). 8.2's fence attaches `deny_launches` and stops the controller |
| host; each settle terminates every known VM, proves the image clear by three scans and a direct read |
| -of each known ID, and repeats after 10 minutes; a VM live past a bound stops. 8.3: `controller |
| -terminate` reads every controller host back `terminated`; `unfence` detaches `deny_launches` only |
| -with that proof and every image settled with its repeat after the last fence, and reads the detach |
| -back. Unfence has no ordinary class (99 only): its one pre-approved repeat is the one exception to |
| -"99 goes to recovery" (the coordinator's explicit exception), and a second refusal |
| -stops with the policy attached; the images still exist, so the repeat's settles can scan them. The |
| -services destroy: 1 is reconciled and destroyed once more, 99 (plan-check, the fence attached, an |
| -unresolved intent) stops. 8.4: `img delete` with `-ledger` deletes only a recorded image and takes |
| -one already gone as done, so each `.retry1` is safe; 4 stops. 8.5 is the connector's first real |
| -interface cleanup: on `DELETE_FAILED`, one retry with the managed-operator condition dropped; |
| -interfaces left after the delete are waited for within the same 120-minute budget and never deleted |
| -by hand; 1 (while the connector is still recorded) is retried as `8.5.retry1`, 99 (interfaces not |
| -proved gone after the delete) stops. 8.6 empties the buckets by their fixed names: a recorded bucket |
| -a direct read shows gone is done (`DELETED ... read-gone`, kit K11), so `8.6.retry1` after a partial |
| -config destroy goes on to the destroy (finding 13); another owner stops. 8.7: `verify-gone` reads |
| -every recorded resource directly and every tagged ARN of the run; one the ledger does not hold must |
| -be proved absent, or it stops (99). **If it stops on such a resource** (R9; a type with no direct |
| -read, or a root volume the provider tagged), everything the ledger holds is already torn down: the |
| -run reports the resource with `verify-gone`'s lines and asks Paul; the state bucket stays (pennies) |
| -until he answers. |
| +of each known ID, and repeats after 10 minutes; a VM live past a bound stops (99). 8.3a: |
| +`controller terminate` reads every controller host back `terminated`; `unfence` detaches |
| +`deny_launches` only with that proof and every image settled with its repeat after the last fence, |
| +and reads the detach back. Unfence has no ordinary class (99 only): its one pre-approved repeat is the |
| +one exception to "99 goes to recovery" (the coordinator's explicit exception), and a second refusal |
| +stops with the policy attached; the images still exist, so the repeat's settles can scan them. 8.3b, |
| +the services destroy: 1 is reconciled inside the step, then the step's retry runs the destroy again; |
| +99 (plan-check, the fence attached, an unresolved intent) stops. 8.4: `img delete` with `-ledger` |
| +deletes only a recorded image and takes one already gone as done, so each `.retry1` is safe; 4 stops. |
| +8.5 is the connector's first real interface cleanup: on `DELETE_FAILED`, one retry with the |
| +managed-operator condition dropped; interfaces left after the delete are waited for within the same |
| +120-minute budget and never deleted by hand; 1 (while the connector is still recorded, or the |
| +deadline) is retried as `8.5.retry1`, 99 (interfaces not proved gone after the delete) stops. 8.6 |
| +empties the buckets by their fixed names: a recorded bucket a direct read shows gone is done |
| +(`DELETED ... read-gone`, kit K11), so `8.6.retry1` after a partial config destroy goes on to the |
| +destroy (finding 13); another owner stops. 8.7: `verify-gone` reads every recorded resource directly |
| +and every tagged ARN of the run; one the ledger does not hold must be proved absent, or it stops |
| +(99). **If it stops on such a resource** (R9; a type with no direct read, or a root volume the |
| +provider tagged), everything the ledger holds is already torn down: the run reports the resource |
| +with `verify-gone`'s lines and asks Paul; the state bucket stays (pennies) until he answers. |
| |
| ### 8.8 Records and docs-t1 (agent's shell) |
| |
| @@ -1632,30 +1752,30 @@ Builds: one, plus one only if the step-down runs. |
| |
| | | Expected (to plan) | Worst case | |
| | --- | --- | --- | |
| -| Hosts | 9 h × $0.054692 = $0.49 | 32 h × $0.054692 = $1.75 | |
| +| Hosts | 9 h × $0.054692 = $0.49 | 34 h × $0.054692 = $1.86 | |
| | VMs and VM reservations | 12 × $1.86 = $22.32 | 13 × $1.86 = $24.18 (a late VM found by a settle repeat) | |
| | Image builds | 1 × $1 = $1.00 | 2 × $1 = $2.00 (the step-down) | |
| | Image storage | 1 × $1.87 | 2 × $1.87 = $3.73 (the step-down image) | |
| | S3, SNS, alarms | $1.00 | $1.00 | |
| -| **Estimate** | **$26.68** | **$32.66** | |
| +| **Estimate** | **$26.68** | **$32.77** | |
| |
| Host hours, from the services apply to the hosts' termination. Expected: up and status 0.75, |
| certification 1, signing 2, wiring 0.25, three scenarios 1.5, two drills 1.5, the alert 0.5, |
| teardown to termination 1.25: 8.75, rounded up to 9. Worst, every step at its bound: up and status |
| 0.85 (4.2 25 minutes, 4.3 25), certification 1.1 (5.1 25, 5.2 40), the signing bound 12, wiring |
| 0.25, three watchers 5.25 (105 minutes each), 7.0 and two drills 4.4 (10, 135, 110), the alert bound |
| -2, then the alert watchdog's trigger and the continuation to 8.3's end, 6 (8.0): 31.85, rounded up |
| -to 32. |
| +2, then the alert watchdog's trigger and the continuation to 8.3b's end, 7.2 (8.0): 33.05, rounded |
| +up to 34. |
| |
| **After a trigger** (a watchdog's expiry or a failed block, from 2.2b on): the continuation ends |
| -the hosts within 357 minutes, at most **6 host-hours, about $0.33**, added to the estimate at the |
| +the hosts within 432 minutes (from the steps' deadlines), at most **8 host-hours, about $0.44**, added to the estimate at the |
| trigger; nothing else grows (no VM runs after S.4, and image storage is already charged at its |
| minimum). The worst case above already contains the latest trigger. The continuation itself ends |
| within about 23 h 42 min. The exceptions are a guard failure, a failed credential check at the |
| trigger (2.2b's known limit) and a teardown step that stops: then about $1.15 a day on the bill until |
| Paul answers. |
| |
| -**Self-stop $40** leaves $7.34 over the worst case: three unplanned VMs. **Ceiling $50**: the stop is |
| +**Self-stop $40** leaves $7.23 over the worst case: three unplanned VMs. **Ceiling $50**: the stop is |
| checked only when a block or reservation starts, and the estimate leaves out the connector, the |
| state bucket and data transfer. Teardown is never refused on spend. |
| |
| @@ -1684,14 +1804,15 @@ bills its full week. |
| | the pin, and proxies booting with `controller.json` late | 4.2, 4.3 | wait 1: skip; each put classified before the next; not live in 15 minutes: skip; assert: stop | |
| | the estimate's scan retry | every block | an incomplete scan past 3 minutes: stop | |
| | Litestream install and restore check | 3.1, 4.3 | install 1: skip, 99: stop; check 1: FINDING | |
| -| `ops controller reboot`, waiting for the host to go away | 5.1, 7.1 | 5.1: puts first, each classified; 1 skip, 99 stop; 7.1: any failure stops | |
| +| `ops controller reboot`, waiting for the host to go away | 5.1, 7.1 | 5.1: puts first, each classified; 1 skip, 99 stop; 7.1: `--not-after strike_before`, judged by `REBOOT-SENT`; `REBOOT-LATE` or a late send is a missed window; any other failure stops | |
| | `vms scan` against the controller's table | 6, 7, the signing wait | 99 (unexplained VM): stop; 1: FINDING | |
| | `vms settle --step --ended-at` at each `HOSTED-CHECKS-END` | 6.2, 7 (the watcher) | 99: stop; 1 (clock skew): FINDING and settle from now | |
| | the run id and the checks-started window | 6.2, 7 (the watcher) | no new run, a missing line: FINDING; missed or late: FINDING, not judged | |
| | `cert bundle` (with and without `-empty`) and `cert reload` | 5.4b, 7.2 | skip, FINDING; a withdrawal not acknowledged in the window is not judged | |
| | the dev alert subscription and a real alert email | 2.4, 7.4 | FINDING; PASSED needs it | |
| -| `ops fence`, `ops controller terminate`, `ops unfence` | 8.2, 8.3 | unfence: one repeat of fence and settle; then stop | |
| -| `tf` destroys | 8.3, 8.6 | 1: one reconcile and one re-destroy; 99: stop | |
| +| `ops fence`, `ops controller terminate`, `ops unfence` | 8.2, 8.3a | unfence: one repeat of fence and settle; then stop | |
| +| teardown step deadlines (`--max` on each teardown block) | 8.0 | `DEADLINE`: the step killed, reconciled, exit 1; its one retry where it has one, else `escalate` | |
| +| `tf` destroys | 8.3b, 8.6 | 1: reconciled in the step, then the step's retry; 99: stop | |
| | `img delete` with `-ledger`, one block per image | 8.4.1, 8.4.2 | ordinary: `.retry1` once; 4: stop | |
| | the connector's interface cleanup | 8.5 | 1: `8.5.retry1`; 99: stop | |
| | resumable bucket teardown | 8.6, 8.7 | a recorded bucket already gone is done; another owner: stop | |