rehearsal-4: executor rebuilds the gateway snapshot itself when #656 says stale — the ADR 0185 reseed loop for images, no hands #661

Closed
opened 2026-08-22 12:03:52 +00:00 by ben · 3 comments
Owner

Seen 2026-08-22 12:1xZ on elitebook-03, tick 3 of the armed #652: PREFLIGHT: gateway image stale: built at 8585a9546dd3, agent changed in 91685055dd5b (4 agent-commit(s) since) — rebuild with scripts/gateway-image/build.sh (#656). The gate is RIGHT — the registry published 4 new idss-agent artifacts since the snapshot (the publish guard diffs bytes; internal/ is statically linked into the agent). But the remedy is a human running build.sh (~10 min, full DO token) after nearly every landed commit — the same hands-in-the-loop stall ADR 0185 retired for get.idss.nz (#601).

Ask: when the staleness gate parks a rented drive, the executor rebuilds the snapshot itself and then drives, on the same tick or the next:

  • scripts/rehearsal-cycle.sh (rented target only): on gateway-image-stale, run scripts/gateway-image/build.sh (it already resolves the newest PUBLISHED ancestor, #654) under a host-wide build lock (/tmp/idss-gateway-image-build.lock, flock) so two executors never build the same snapshot; log the new snapshot id into the drive dir; re-run the staleness check; proceed.
  • The executor host already carries DIGITALOCEAN_ACCESS_TOKEN (full account — rehearsal-env.sh) and nix; build.sh needs nothing else. Budget: the build's ~10 min counts toward the drive's wall clock but NOT toward any leg ceiling (it runs pre-legs.json).
  • Reap old snapshots: keep the newest 3 idss-gateway-*; doctl compute snapshot delete the rest after a successful build (DO bills snapshots per GB).
  • Offline test (fake doctl + fake build.sh): stale → build invoked once → fresh → drive proceeds; build failure → drive parks by name (never a stale-image drive); lock held → waits, does not double-build.
  • #652 comment on each auto-rebuild ("snapshot advanced 8585a95 → by elitebook-03") — the reseed-pin comment precedent.

Non-goal: CI-built images (ADR 0185's revisit stands; this keeps the build on the executor host that already has the credential).

**Seen 2026-08-22 12:1xZ on elitebook-03, tick 3 of the armed #652:** `PREFLIGHT: gateway image stale: built at 8585a9546dd3, agent changed in 91685055dd5b (4 agent-commit(s) since) — rebuild with scripts/gateway-image/build.sh (#656)`. The gate is RIGHT — the registry published 4 new `idss-agent` artifacts since the snapshot (the publish guard diffs bytes; `internal/` is statically linked into the agent). But the remedy is a human running `build.sh` (~10 min, full DO token) after nearly every landed commit — the same hands-in-the-loop stall ADR 0185 retired for `get.idss.nz` (#601). **Ask:** when the staleness gate parks a rented drive, the executor rebuilds the snapshot itself and then drives, on the same tick or the next: - `scripts/rehearsal-cycle.sh` (rented target only): on `gateway-image-stale`, run `scripts/gateway-image/build.sh` (it already resolves the newest PUBLISHED ancestor, #654) under a host-wide build lock (`/tmp/idss-gateway-image-build.lock`, flock) so two executors never build the same snapshot; log the new snapshot id into the drive dir; re-run the staleness check; proceed. - The executor host already carries `DIGITALOCEAN_ACCESS_TOKEN` (full account — `rehearsal-env.sh`) and nix; `build.sh` needs nothing else. Budget: the build's ~10 min counts toward the drive's wall clock but NOT toward any leg ceiling (it runs pre-`legs.json`). - Reap old snapshots: keep the newest 3 `idss-gateway-*`; `doctl compute snapshot delete` the rest after a successful build (DO bills snapshots per GB). - Offline test (fake `doctl` + fake `build.sh`): stale → build invoked once → fresh → drive proceeds; build failure → drive parks by name (never a stale-image drive); lock held → waits, does not double-build. - #652 comment on each auto-rebuild ("snapshot advanced 8585a95 → <sha> by elitebook-03") — the reseed-pin comment precedent. Non-goal: CI-built images (ADR 0185's revisit stands; this keeps the build on the executor host that already has the credential).

swarm-claim host=matou-dev-server-01 run=8796
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=8796 (automated multi-host claim — lowest live claim id works this ticket)

Ruled by agent under ADR 0174 — veto anytime.

Decision: implement the auto-rebuild + old-snapshot reaping exactly as this ticket specifies, without asking a human first.

Why it is a two-way door:

  • The rebuild spend is routine, not new. build.sh rents one throwaway droplet for ~10 min on the SAME DIGITALOCEAN_ACCESS_TOKEN the executor host already carries (rehearsal-env.sh), and tears it down on any exit (trap, ADR 0047). It is the identical spend a human already runs today when the #656 gate parks — this only moves the hand off the button.
  • Reaping idss-gateway-* snapshots is not data destruction. These are GENERIC, regenerable golden build artifacts (no secret/slug/brand — ADR 0048); build.sh recreates any of them from git. Keeping the newest 3 preserves rollback headroom; the rest are pure DO GB-billing. No member data, no community state.
  • Fully revertible: a later commit can drop the loop and return to the #656 park-for-a-human behavior with no residue.

What proves it: scripts/gateway-image/tests/gateway-image-rebuild-test.sh (offline, fake doctl + fake build.sh) proves stale→build-once→proceed, build-failure→park-by-name (never a stale-image drive), peer-holds-lock→no-double-build, and reap-keeps-newest-3-sparing-non-idss-gateway. Non-one-way-door: no personal credential, no security-posture widening, no member-facing trust accept, no member data destruction, no non-routine spend.

Ruled by agent under ADR 0174 — veto anytime. **Decision:** implement the auto-rebuild + old-snapshot reaping exactly as this ticket specifies, without asking a human first. **Why it is a two-way door:** - **The rebuild spend is routine, not new.** `build.sh` rents one throwaway droplet for ~10 min on the SAME `DIGITALOCEAN_ACCESS_TOKEN` the executor host already carries (`rehearsal-env.sh`), and tears it down on any exit (trap, ADR 0047). It is the identical spend a human already runs today when the #656 gate parks — this only moves the hand off the button. - **Reaping `idss-gateway-*` snapshots is not data destruction.** These are GENERIC, regenerable golden build artifacts (no secret/slug/brand — ADR 0048); `build.sh` recreates any of them from git. Keeping the newest 3 preserves rollback headroom; the rest are pure DO GB-billing. No member data, no community state. - **Fully revertible:** a later commit can drop the loop and return to the #656 park-for-a-human behavior with no residue. **What proves it:** `scripts/gateway-image/tests/gateway-image-rebuild-test.sh` (offline, fake doctl + fake build.sh) proves stale→build-once→proceed, build-failure→park-by-name (never a stale-image drive), peer-holds-lock→no-double-build, and reap-keeps-newest-3-sparing-non-idss-gateway. Non-one-way-door: no personal credential, no security-posture widening, no member-facing trust accept, no member data destruction, no non-routine spend.

close-report for #661 — status success

✅ close-report gates passed — every claim verified against main; closing.

envelope
{
  "issue": 661,
  "status": "success",
  "commits": [
    "83192f99212fa6411c9ed49ccafc5897097f4770"
  ],
  "changed_files": [
    "STATUS.md",
    "scripts/lib/gateway-image-rebuild-lib.sh",
    "scripts/rehearsal-cycle.sh",
    "scripts/tests/gateway-image-rebuild-test.sh"
  ],
  "tests": [
    {
      "command": "bash scripts/tests/gateway-image-rebuild-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/gateway-image/tests/gateway-image-staleness-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/rehearsal-rented-target-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/lib/gateway-image-rebuild-lib.sh scripts/rehearsal-cycle.sh scripts/tests/gateway-image-rebuild-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "on gateway-image-stale, rehearsal-cycle.sh (rented only) runs build.sh under a host-wide flock, logs the new snapshot id, re-runs the staleness check, proceeds": "scripts/lib/gateway-image-rebuild-lib.sh oc_gateway_image_ensure_fresh (flock on OC_GWIMAGE_BUILD_LOCK=/tmp/idss-gateway-image-build.lock, re-probe under lock, oc_gwimage_build, log into <logdir>/gateway-image-rebuild.log); wired in scripts/rehearsal-cycle.sh guarded to target==rented; test check 2 (stale->build once->fresh->proceed)",
    "build runs pre-legs.json (counts toward wall clock, not a leg ceiling)": "the ensure_fresh call in rehearsal-cycle.sh runs before the 'nix develop .#e2e -c scripts/smoke-private-path.sh' drive invocation",
    "reap old snapshots: keep the newest 3, doctl compute snapshot delete the rest after a successful build": "oc_gwimage_reap (OC_GWIMAGE_REAP_KEEP default 3, sort -r newest-first, delete NR>keep) called after a successful build; test check 8 (real reap keeps newest 3, deletes the two oldest)",
    "offline test: stale->build once->fresh->proceed; build failure->park by name; lock held->waits, does not double-build": "scripts/tests/gateway-image-rebuild-test.sh 8 checks incl. stale->build once, build failure->returns 1 (drive parks at #656 gate), sibling-already-fresh->re-probe skips build, lock held->waits then no double-build",
    "#652 comment on each auto-rebuild (snapshot advanced X -> Y by host)": "oc_gwimage_announce POSTs the advance comment to the drive issue; test check 2 asserts the announce payload (652 <old> <new> <host>)"
  },
  "summary": "The rented rehearsal executor now auto-rebuilds a stale gateway snapshot itself (ADR 0185 reseed loop for images) under a host-wide build lock, pre-drive, with reap + drive-dir log + #652 comment; a build failure falls through to #656's park-by-name gate.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #661 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 661, "status": "success", "commits": [ "83192f99212fa6411c9ed49ccafc5897097f4770" ], "changed_files": [ "STATUS.md", "scripts/lib/gateway-image-rebuild-lib.sh", "scripts/rehearsal-cycle.sh", "scripts/tests/gateway-image-rebuild-test.sh" ], "tests": [ { "command": "bash scripts/tests/gateway-image-rebuild-test.sh", "exit_code": 0 }, { "command": "bash scripts/gateway-image/tests/gateway-image-staleness-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/rehearsal-rented-target-test.sh", "exit_code": 0 }, { "command": "bash -n scripts/lib/gateway-image-rebuild-lib.sh scripts/rehearsal-cycle.sh scripts/tests/gateway-image-rebuild-test.sh", "exit_code": 0 } ], "criteria": { "on gateway-image-stale, rehearsal-cycle.sh (rented only) runs build.sh under a host-wide flock, logs the new snapshot id, re-runs the staleness check, proceeds": "scripts/lib/gateway-image-rebuild-lib.sh oc_gateway_image_ensure_fresh (flock on OC_GWIMAGE_BUILD_LOCK=/tmp/idss-gateway-image-build.lock, re-probe under lock, oc_gwimage_build, log into <logdir>/gateway-image-rebuild.log); wired in scripts/rehearsal-cycle.sh guarded to target==rented; test check 2 (stale->build once->fresh->proceed)", "build runs pre-legs.json (counts toward wall clock, not a leg ceiling)": "the ensure_fresh call in rehearsal-cycle.sh runs before the 'nix develop .#e2e -c scripts/smoke-private-path.sh' drive invocation", "reap old snapshots: keep the newest 3, doctl compute snapshot delete the rest after a successful build": "oc_gwimage_reap (OC_GWIMAGE_REAP_KEEP default 3, sort -r newest-first, delete NR>keep) called after a successful build; test check 8 (real reap keeps newest 3, deletes the two oldest)", "offline test: stale->build once->fresh->proceed; build failure->park by name; lock held->waits, does not double-build": "scripts/tests/gateway-image-rebuild-test.sh 8 checks incl. stale->build once, build failure->returns 1 (drive parks at #656 gate), sibling-already-fresh->re-probe skips build, lock held->waits then no double-build", "#652 comment on each auto-rebuild (snapshot advanced X -> Y by host)": "oc_gwimage_announce POSTs the advance comment to the drive issue; test check 2 asserts the announce payload (652 <old> <new> <host>)" }, "summary": "The rented rehearsal executor now auto-rebuilds a stale gateway snapshot itself (ADR 0185 reseed loop for images) under a host-wide build lock, pre-drive, with reap + drive-dir log + #652 comment; a build failure falls through to #656's park-by-name gate.", "reason": "", "blockers": [], "no_code_change": "" } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#661
No description provided.