gateway-image staleness is keyed on COMMITS TOUCHING internal/, not on whether the baked agent actually changed — every render-only commit costs the next drive a ~60-minute rebuild (measured), and a busy day starves the drive #1096

Closed
opened 2026-09-01 02:56:12 +00:00 by ben · 2 comments
Owner

The cost, measured

scripts/gateway-image/build.sh advertises "~10 min, pre-legs" (scripts/lib/gateway-image-rebuild-lib.sh:181). Measured from DO's own action log — build-droplet create → destroy — on 2026-08-31/09-01:

build droplet created destroyed wall
596695124 19:30:02 20:19:25 49 min
596705145 20:21:36 21:23:22 62 min
596736081 23:12:01 00:10:17 58 min
596753325 00:51:44 01:51:55 60 min

Four rebuilds in the 6.5 hours from 19:30 to 02:00 — ~3.8 h of a 6.5 h window spent rebuilding the snapshot, in a window that fired only three drives. The log carries 29 snapshot advanced lines across the arc. The advertised figure is out by 5–6×, which is its own small bug (the message sets the operator's expectation for how long a park is normal).

Why it fires so often

oc_gateway_image_staleness (scripts/lib/gateway-image-staleness-lib.sh:56-63) declares the snapshot stale when any commit since the snapshot's sha touches OC_BOOTSTRAP_AGENT_PATHS = agent/ go.mod go.sum internal/:

behind="$("${git[@]}" rev-list --count "${snap}..${base}" -- "${OC_BOOTSTRAP_AGENT_PATHS[@]}")"
if (( behind > 0 )); then … return 1

internal/ is the whole product. Tonight's IDIP-credentials arc (#1080–#1087) and the healer landed a dozen commits into internal/, and the drive lane paid a full rebuild for each batch — including for commits like a control-panel render or a Nix-string change that cannot alter the baked agent binary.

What the snapshot actually bakes is (a) the agent binary and (b) the installer-base closure (#1048). Note the asymmetry already in the file: the installer-base axis (#1050, _oc_gwimage_probe, lines 117-133) compares out paths and explicitly refuses to "churn a warm snapshot on a key we cannot read". The agent axis compares commit counts. The right discriminator already exists in the same function, one axis over.

What plugging it needs

Key the agent axis on the built artifact, not on commit touch: compare the agent's derivation/out path at snap vs at base (the oc_gwimage_installer_base_marker shape), and treat an unknowable marker as "keep the current verdict", exactly as the installer-base axis does. A render-only internal/ commit then leaves a warm snapshot warm; a commit that genuinely moves the agent still rebuilds.

Worth confirming while in there whether the ~60 min is irreducible or itself has a warm-cache axis — the installer-base bake inside it re-runs each time and reports 1355 store paths identically every run, including the runs where the marker was unchanged.

Also fix the "~10 min" string to match measurement.

Acceptance: a commit touching only internal/clan render text (no change to the agent's out path) leaves the snapshot fresh and fires the drive with no rebuild; a commit that moves the agent's out path still rebuilds; the unknowable-marker case never churns. Offline-provable against a fixture repo the way gateway-image-staleness is already tested.

Filed by the watching session from the #854 drive arc (ADR 0174). Not blocking #854 — it costs wall-clock and DO spend, not correctness.

## The cost, measured `scripts/gateway-image/build.sh` advertises "~10 min, pre-legs" (`scripts/lib/gateway-image-rebuild-lib.sh:181`). Measured from DO's own action log — build-droplet `create` → `destroy` — on 2026-08-31/09-01: | build droplet | created | destroyed | wall | |---|---|---|---| | 596695124 | 19:30:02 | 20:19:25 | **49 min** | | 596705145 | 20:21:36 | 21:23:22 | **62 min** | | 596736081 | 23:12:01 | 00:10:17 | **58 min** | | 596753325 | 00:51:44 | 01:51:55 | **60 min** | Four rebuilds in the 6.5 hours from 19:30 to 02:00 — **~3.8 h of a 6.5 h window spent rebuilding the snapshot**, in a window that fired only three drives. The log carries 29 `snapshot advanced` lines across the arc. The advertised figure is out by 5–6×, which is its own small bug (the message sets the operator's expectation for how long a park is normal). ## Why it fires so often `oc_gateway_image_staleness` (`scripts/lib/gateway-image-staleness-lib.sh:56-63`) declares the snapshot stale when **any commit** since the snapshot's sha touches `OC_BOOTSTRAP_AGENT_PATHS` = `agent/ go.mod go.sum internal/`: ```sh behind="$("${git[@]}" rev-list --count "${snap}..${base}" -- "${OC_BOOTSTRAP_AGENT_PATHS[@]}")" if (( behind > 0 )); then … return 1 ``` `internal/` is the whole product. Tonight's IDIP-credentials arc (#1080–#1087) and the healer landed a dozen commits into `internal/`, and the drive lane paid a full rebuild for each batch — including for commits like a control-panel render or a Nix-string change that **cannot** alter the baked agent binary. What the snapshot actually bakes is (a) the agent binary and (b) the installer-base closure (#1048). Note the asymmetry already in the file: the installer-base axis (#1050, `_oc_gwimage_probe`, lines 117-133) compares **out paths** and explicitly refuses to "churn a warm snapshot on a key we cannot read". The agent axis compares **commit counts**. The right discriminator already exists in the same function, one axis over. ## What plugging it needs Key the agent axis on the built artifact, not on commit touch: compare the agent's derivation/out path at `snap` vs at `base` (the `oc_gwimage_installer_base_marker` shape), and treat an unknowable marker as "keep the current verdict", exactly as the installer-base axis does. A render-only `internal/` commit then leaves a warm snapshot warm; a commit that genuinely moves the agent still rebuilds. Worth confirming while in there whether the ~60 min is irreducible or itself has a warm-cache axis — the installer-base bake inside it re-runs each time and reports `1355 store paths` identically every run, including the runs where the marker was unchanged. Also fix the "~10 min" string to match measurement. **Acceptance:** a commit touching only `internal/clan` render text (no change to the agent's out path) leaves the snapshot fresh and fires the drive with no rebuild; a commit that moves the agent's out path still rebuilds; the unknowable-marker case never churns. Offline-provable against a fixture repo the way `gateway-image-staleness` is already tested. Filed by the watching session from the #854 drive arc (ADR 0174). Not blocking #854 — it costs wall-clock and DO spend, not correctness.

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

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

close-report for #1096 — status success

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

envelope
{
  "issue": 1096,
  "status": "success",
  "commits": [
    "764b9351908682fd1672b74191e08e71936248ca"
  ],
  "changed_files": [
    "scripts/lib/gateway-image-staleness-lib.sh",
    "scripts/lib/gateway-image-rebuild-lib.sh",
    "scripts/gateway-image/tests/gateway-image-staleness-test.sh",
    "scripts/tests/gateway-image-rebuild-test.sh"
  ],
  "tests": [
    {
      "command": "bash scripts/gateway-image/tests/gateway-image-staleness-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/gateway-image-rebuild-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/gateway-image/tests/gateway-image-generic-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/installer-base-staleness-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "a commit touching only internal/clan render text (no change to the agent's out path) leaves the snapshot fresh and fires the drive with no rebuild": "oc_gateway_image_staleness now keys behind>0 on the resolved agent PIN (oc_gwimage_agent_pin_at_ref); a render-only internal/ commit publishes no new registry agent (ADR 0185) so pin(snap)==pin(base) -> rc=0 fresh. Proven offline: gateway-image-staleness-test.sh case 2 (snapshot at c_agent2 behind only render commit c_render2 -> fresh, verdict 'none moved the baked agent').",
    "a commit that moves the agent's out path still rebuilds": "When the pin differs (a new agent was published between snap and base), the gate returns rc=1 stale. Proven offline: gateway-image-staleness-test.sh case 3 (snapshot at c_agent1, c_agent2 published after -> stale, names both pins + rebuild recipe).",
    "the unknowable-marker case never churns": "An empty published-agent list (registry unreadable / no published ancestor) keeps the commit-count verdict. behind==0 is a cheap fast path that never consults the registry, so a warm snapshot is never flipped stale. Proven offline: gateway-image-staleness-test.sh case 4 (unresolvable pin keeps the STALE verdict for a genuinely-behind snapshot) and case 4b (unresolvable registry on a behind==0 snapshot stays fresh).",
    "Offline-provable against a fixture repo the way gateway-image-staleness is already tested": "The whole gate runs offline: the one network I/O boundary (oc_gwimage_published_agents) is overridden with a fixed newest-first list in the fixture-repo test; no DO account, no registry call. gateway-image-staleness-test.sh: 11 checks passed.",
    "Also fix the ~10 min string to match measurement": "scripts/lib/gateway-image-rebuild-lib.sh: the operator-facing rebuild message and the three header-comment references changed from ~10 min to the measured ~60 min (#1096)."
  },
  "summary": "gateway-image staleness now keys the agent axis on the baked published-agent PIN (snap vs base) instead of commit-touch, so a render-only internal/ commit no longer costs the next rented drive a ~60-min snapshot rebuild.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #1096 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1096, "status": "success", "commits": [ "764b9351908682fd1672b74191e08e71936248ca" ], "changed_files": [ "scripts/lib/gateway-image-staleness-lib.sh", "scripts/lib/gateway-image-rebuild-lib.sh", "scripts/gateway-image/tests/gateway-image-staleness-test.sh", "scripts/tests/gateway-image-rebuild-test.sh" ], "tests": [ { "command": "bash scripts/gateway-image/tests/gateway-image-staleness-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/gateway-image-rebuild-test.sh", "exit_code": 0 }, { "command": "bash scripts/gateway-image/tests/gateway-image-generic-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/installer-base-staleness-test.sh", "exit_code": 0 } ], "criteria": { "a commit touching only internal/clan render text (no change to the agent's out path) leaves the snapshot fresh and fires the drive with no rebuild": "oc_gateway_image_staleness now keys behind>0 on the resolved agent PIN (oc_gwimage_agent_pin_at_ref); a render-only internal/ commit publishes no new registry agent (ADR 0185) so pin(snap)==pin(base) -> rc=0 fresh. Proven offline: gateway-image-staleness-test.sh case 2 (snapshot at c_agent2 behind only render commit c_render2 -> fresh, verdict 'none moved the baked agent').", "a commit that moves the agent's out path still rebuilds": "When the pin differs (a new agent was published between snap and base), the gate returns rc=1 stale. Proven offline: gateway-image-staleness-test.sh case 3 (snapshot at c_agent1, c_agent2 published after -> stale, names both pins + rebuild recipe).", "the unknowable-marker case never churns": "An empty published-agent list (registry unreadable / no published ancestor) keeps the commit-count verdict. behind==0 is a cheap fast path that never consults the registry, so a warm snapshot is never flipped stale. Proven offline: gateway-image-staleness-test.sh case 4 (unresolvable pin keeps the STALE verdict for a genuinely-behind snapshot) and case 4b (unresolvable registry on a behind==0 snapshot stays fresh).", "Offline-provable against a fixture repo the way gateway-image-staleness is already tested": "The whole gate runs offline: the one network I/O boundary (oc_gwimage_published_agents) is overridden with a fixed newest-first list in the fixture-repo test; no DO account, no registry call. gateway-image-staleness-test.sh: 11 checks passed.", "Also fix the ~10 min string to match measurement": "scripts/lib/gateway-image-rebuild-lib.sh: the operator-facing rebuild message and the three header-comment references changed from ~10 min to the measured ~60 min (#1096)." }, "summary": "gateway-image staleness now keys the agent axis on the baked published-agent PIN (snap vs base) instead of commit-touch, so a render-only internal/ commit no longer costs the next rented drive a ~60-min snapshot rebuild.", "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#1096
No description provided.