#1096's pin axis fires exactly as often as the commit-count axis it replaced: the publish rail mints a new agent version on the same path-touch, so a render-only commit still costs the drive a ~60-minute rebuild #1100

Closed
opened 2026-09-01 05:26:51 +00:00 by ben · 3 comments
Owner

Follow-up to #1096 (landed 764b9351). The mechanism is right and the code works — but the key it compares moves on the same trigger as the axis it replaced, so the saving is ~zero. Measured on the live host tonight, not reasoned from the diff.

The premise that does not hold

#1096's reasoning: "build.sh bakes the newest PUBLISHED registry agent … and CI publishes only when the agent artifact actually CHANGED (ADR 0185). So the true 'did the baked agent move' key is the RESOLVED PIN."

The publish rail does not gate on the artifact changing. scripts/bootstrap-reseed/publish.sh:64-67:

if ! oc_reseed_agent_affected "$base" "$sha" "$root"; then
  echo "publish: … does not touch the agent-affecting set (${OC_BOOTSTRAP_AGENT_PATHS[*]}) — nothing to publish"
  exit 0
fi

That is OC_BOOTSTRAP_AGENT_PATHS — the same agent/ go.mod go.sum internal/ set the old commit-count axis used. It then builds, computes sha256sum, and publishes a version keyed on the git sha:

sum="$(cd "$work" && sha256sum "agent-$arch" | awk '{print $1}')"
…
put "$bin" "agent-$arch"
put "$work/agent-$arch.sha256" "agent-$arch.sha256"

The checksum is recorded and uploaded, never compared with the previous version. So every internal/-touching commit mints a new registry version, the resolved pin moves, and the pin axis returns STALE exactly when the commit-count axis would have.

Measured on elitebook-03, 05:20Z

$ oc_gwimage_published_agents | head -5
8277dc0a…   b63b3851…   9d414e84…   0b5cbad5…   bea1b3e4…

$ oc_gwimage_agent_pin_at_ref . 87971b7f581c   ->  bea1b3e4…
$ oc_gwimage_agent_pin_at_ref . origin/main    ->  8277dc0a…

Five consecutive internal/-touching commits, five published versions, pins differ, verdict STALE → the drive is paying a rebuild right now (gateway-image: rebuilding the snapshot … (~60 min, pre-legs — measured, #1096)).

The counterexample is #1096's own example. 9d414e84 is in that published list. It is #1095's fix: a change to an ownership argument and comments in internal/clan/files_idp_gateway.go — a Nix-string render change, precisely the class #1096's commit message named as "a control-panel render or a Nix-string edit — which CANNOT alter the baked agent binary". It published, moved the pin, and cost a rebuild.

(Whether it truly cannot alter the binary is a second question — internal/ is linked into the agent, so a changed string literal does change the bytes. Either way the pin moves, so the axis cannot discriminate.)

The only case #1096 currently saves is the ~10-minute window where the publish cron has not yet run, so the pins happen to match. That is luck, not a gate.

What plugging it needs

The registry already holds the discriminator: publish.sh uploads agent-$arch.sha256 beside each version. Resolve the pin to that checksum, not the version tag — two versions whose binaries are byte-identical then compare equal and leave a warm snapshot warm, while a genuine agent change still rebuilds. One extra registry GET per side, on the slow path only (behind>0); the behind==0 fast path and the unknowable-marker fallback (keep the commit-count verdict) both stay exactly as #1096 built them.

Optionally also make the pin itself content-addressed by having publish.sh skip minting when the freshly built binary's sha256 equals the newest published one — but that changes pin semantics the reseed rail also consumes, so the staleness-side checksum comparison is the smaller, safer door.

Acceptance: two commits that touch internal/ but build a byte-identical agent leave the snapshot FRESH (no rebuild, drive fires immediately); a commit that changes the agent binary still rebuilds; an unreadable checksum keeps today's verdict. Offline-provable with a stubbed registry, the way gateway-image-staleness-test.sh already stubs.

Filed by the watching session from the #854 arc (ADR 0174) — evidence gathered live, no code change from me. Not blocking #854; it is wall-clock and DO spend, and it is the same class as #740 (a filter that never matched) and #871 (a gate that could not fail): the fix is present, runs, and reports success while changing nothing.

Follow-up to #1096 (landed `764b9351`). The mechanism is right and the code works — but the key it compares moves on the same trigger as the axis it replaced, so the saving is ~zero. Measured on the live host tonight, not reasoned from the diff. ## The premise that does not hold #1096's reasoning: *"build.sh bakes the newest PUBLISHED registry agent … and CI publishes only when the agent artifact actually CHANGED (ADR 0185). So the true 'did the baked agent move' key is the RESOLVED PIN."* The publish rail does **not** gate on the artifact changing. `scripts/bootstrap-reseed/publish.sh:64-67`: ```sh if ! oc_reseed_agent_affected "$base" "$sha" "$root"; then echo "publish: … does not touch the agent-affecting set (${OC_BOOTSTRAP_AGENT_PATHS[*]}) — nothing to publish" exit 0 fi ``` That is `OC_BOOTSTRAP_AGENT_PATHS` — the *same* `agent/ go.mod go.sum internal/` set the old commit-count axis used. It then builds, computes `sha256sum`, and publishes a version keyed on the **git sha**: ```sh sum="$(cd "$work" && sha256sum "agent-$arch" | awk '{print $1}')" … put "$bin" "agent-$arch" put "$work/agent-$arch.sha256" "agent-$arch.sha256" ``` The checksum is *recorded and uploaded*, never compared with the previous version. So every `internal/`-touching commit mints a new registry version, the resolved pin moves, and the pin axis returns STALE exactly when the commit-count axis would have. ## Measured on elitebook-03, 05:20Z ``` $ oc_gwimage_published_agents | head -5 8277dc0a… b63b3851… 9d414e84… 0b5cbad5… bea1b3e4… $ oc_gwimage_agent_pin_at_ref . 87971b7f581c -> bea1b3e4… $ oc_gwimage_agent_pin_at_ref . origin/main -> 8277dc0a… ``` Five consecutive `internal/`-touching commits, five published versions, pins differ, verdict STALE → the drive is paying a rebuild right now (`gateway-image: rebuilding the snapshot … (~60 min, pre-legs — measured, #1096)`). **The counterexample is #1096's own example.** `9d414e84` is in that published list. It is #1095's fix: a change to an ownership argument and comments in `internal/clan/files_idp_gateway.go` — a Nix-string render change, precisely the class #1096's commit message named as *"a control-panel render or a Nix-string edit — which CANNOT alter the baked agent binary"*. It published, moved the pin, and cost a rebuild. (Whether it truly cannot alter the binary is a second question — `internal/` is linked into the agent, so a changed string literal does change the bytes. Either way the pin moves, so the axis cannot discriminate.) The only case #1096 currently saves is the ~10-minute window where the publish cron has not yet run, so the pins happen to match. That is luck, not a gate. ## What plugging it needs The registry **already holds the discriminator**: `publish.sh` uploads `agent-$arch.sha256` beside each version. Resolve the pin to that **checksum**, not the version tag — two versions whose binaries are byte-identical then compare equal and leave a warm snapshot warm, while a genuine agent change still rebuilds. One extra registry GET per side, on the slow path only (`behind>0`); the `behind==0` fast path and the unknowable-marker fallback (keep the commit-count verdict) both stay exactly as #1096 built them. Optionally also make the pin itself content-addressed by having `publish.sh` skip minting when the freshly built binary's sha256 equals the newest published one — but that changes pin semantics the reseed rail also consumes, so the staleness-side checksum comparison is the smaller, safer door. **Acceptance:** two commits that touch `internal/` but build a byte-identical agent leave the snapshot FRESH (no rebuild, drive fires immediately); a commit that changes the agent binary still rebuilds; an unreadable checksum keeps today's verdict. Offline-provable with a stubbed registry, the way `gateway-image-staleness-test.sh` already stubs. Filed by the watching session from the #854 arc (ADR 0174) — evidence gathered live, no code change from me. Not blocking #854; it is wall-clock and DO spend, and it is the same class as #740 (a filter that never matched) and #871 (a gate that could not fail): the fix is present, runs, and reports success while changing nothing.

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

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

close-report for #1100 — status success

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

envelope
{
  "issue": 1100,
  "status": "success",
  "commits": [
    "221ab57ab18a84043cc7e3af407b0b4be489d3c0"
  ],
  "changed_files": [
    "scripts/lib/gateway-image-staleness-lib.sh",
    "scripts/gateway-image/tests/gateway-image-staleness-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
    }
  ],
  "criteria": {
    "two commits that touch internal/ but build a byte-identical agent leave the snapshot FRESH (no rebuild, drive fires immediately)": "Slow path now resolves each pin to its recorded agent-$arch.sha256 (oc_gwimage_agent_checksum) and returns fresh when the checksums are equal even though the version tags differ — staleness-lib.sh; proven by test case 2 (c_agent1 snapshot, base at published render commit c_render_id, byte-identical 'AAAA' -> rc=0, verdict names BYTE-IDENTICAL and both pins)",
    "a commit that changes the agent binary still rebuilds": "Differing checksums fall through to the stale branch (rc=1) — staleness-lib.sh; proven by test case 3 (c_agent1 'AAAA' vs c_agent2 'BBBB' -> rc=1, stale verdict names both pins and the rebuild recipe)",
    "an unreadable checksum keeps today's verdict": "oc_gwimage_agent_checksum returns empty on any failure; empty sum_snap/sum_base skips the fresh branch and keeps the tag-moved => stale verdict — staleness-lib.sh; proven by test case 3b (CHECKSUM_IO=0 on case-2 refs -> rc=1)",
    "Offline-provable with a stubbed registry, the way gateway-image-staleness-test.sh already stubs": "Test overrides both I/O boundaries (oc_gwimage_published_agents via PUB, oc_gwimage_agent_checksum via SUMS/CHECKSUM_IO); 12 checks pass with no network"
  },
  "summary": "gateway-image staleness now compares the baked agent's recorded sha256, not the version tag, so a render-only internal/ commit that publishes a byte-identical binary leaves the rented-drive snapshot warm while a real agent change still rebuilds.",
  "blockers": []
}
**close-report** for #1100 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1100, "status": "success", "commits": [ "221ab57ab18a84043cc7e3af407b0b4be489d3c0" ], "changed_files": [ "scripts/lib/gateway-image-staleness-lib.sh", "scripts/gateway-image/tests/gateway-image-staleness-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 } ], "criteria": { "two commits that touch internal/ but build a byte-identical agent leave the snapshot FRESH (no rebuild, drive fires immediately)": "Slow path now resolves each pin to its recorded agent-$arch.sha256 (oc_gwimage_agent_checksum) and returns fresh when the checksums are equal even though the version tags differ — staleness-lib.sh; proven by test case 2 (c_agent1 snapshot, base at published render commit c_render_id, byte-identical 'AAAA' -> rc=0, verdict names BYTE-IDENTICAL and both pins)", "a commit that changes the agent binary still rebuilds": "Differing checksums fall through to the stale branch (rc=1) — staleness-lib.sh; proven by test case 3 (c_agent1 'AAAA' vs c_agent2 'BBBB' -> rc=1, stale verdict names both pins and the rebuild recipe)", "an unreadable checksum keeps today's verdict": "oc_gwimage_agent_checksum returns empty on any failure; empty sum_snap/sum_base skips the fresh branch and keeps the tag-moved => stale verdict — staleness-lib.sh; proven by test case 3b (CHECKSUM_IO=0 on case-2 refs -> rc=1)", "Offline-provable with a stubbed registry, the way gateway-image-staleness-test.sh already stubs": "Test overrides both I/O boundaries (oc_gwimage_published_agents via PUB, oc_gwimage_agent_checksum via SUMS/CHECKSUM_IO); 12 checks pass with no network" }, "summary": "gateway-image staleness now compares the baked agent's recorded sha256, not the version tag, so a render-only internal/ commit that publishes a byte-identical binary leaves the rented-drive snapshot warm while a real agent change still rebuilds.", "blockers": [] } ``` </details>
Author
Owner

Measured against the live registry after 221ab57a landed — the checksum axis does not fire either. The implementation is correct; the premise underneath both #1096 and #1100 is what is false, and it is worth stopping here rather than trying a third key.

The measurement

The published agent-x86_64.sha256 for the five most recent versions (the same five in #1100's evidence):

published version agent sha256 (first 24)
8277dc0ac6cb 7bbd2ceb9f7bf335c211f851
b63b38513c4c 3f3d5742c4f545cc78cd8fe9
9d414e84fd01 6a20ad7aab48f5307fc81020
0b5cbad59ef7 3f037d9e1e64de2836a858ee
bea1b3e4f3c9 8991cf5e117ff664040a516e

Five for five distinct. Including 0b5cbad5 → 9d414e84, which is the #1095 fix: an ownership argument and comments in internal/clan/files_idp_gateway.go. The binary changed.

Why — the premise both tickets share is wrong

internal/ is linked into the agent, and the Nix module text is Go string literals inside it (renderFilesOIDCSecretGenerator and friends build the config with b.WriteString(...)). A "render-only" edit is a changed string literal in a compiled package, so go build legitimately produces different bytes. There is no key — version tag, content checksum, or otherwise — that can call these two agents the same, because they genuinely are not.

So my own prescription in #1100 was wrong, and I should have tested it before prescribing: I flagged the doubt parenthetically and filed anyway. The parenthesis was the important part.

Where that leaves the ~60 minutes

The gate is now correct and honest: the baked agent really does move on nearly every internal/ commit, so the snapshot really is stale by its own definition, and the rebuild really is required given that definition. The cost is not a gate bug — it is the snapshot contract: the gateway image bakes a specific agent build, so the image's freshness is chained to the whole product's commit rate.

That makes the remaining question a design one, above ADR 0174's two-way-door line, so I am not ruling it:

  • A — stop baking the agent into the image. Let the snapshot carry only the OS/store warmth, and have the drive place the current agent on the gateway after boot (the drive already copies closures). Snapshot rebuilds then key on the base image, not the product. The #656 ghost-red risk moves to "did the drive place the agent", which is checkable in-run.
  • B — keep baking it, and accept the cost knowingly, but make it cheap: the 60 min is dominated by a full nixos build + installer-base bake on a fresh droplet, and the bake reports an identical marker (1355 store paths, same nixos-system-…-kexec path) on every run tonight. A warm build host, or reusing the previous snapshot as the build base, is a much larger saving than any staleness-key change.

Both are worth measuring before either is built. #1096 and #1100 should be considered closed-but-ineffective rather than reverted — the code is strictly better (honest verdicts, the corrected ~60 min string, real fallbacks) and it is the right foundation for A, which needs the same probe machinery.

I would suggest re-labelling this needs-design and putting the A-vs-B choice to Ben rather than having a worker pick. Session evidence only; no code change from me.

Measured against the live registry after `221ab57a` landed — **the checksum axis does not fire either.** The implementation is correct; the premise underneath both #1096 and #1100 is what is false, and it is worth stopping here rather than trying a third key. ## The measurement The published `agent-x86_64.sha256` for the five most recent versions (the same five in #1100's evidence): | published version | agent sha256 (first 24) | |---|---| | `8277dc0ac6cb` | `7bbd2ceb9f7bf335c211f851` | | `b63b38513c4c` | `3f3d5742c4f545cc78cd8fe9` | | `9d414e84fd01` | `6a20ad7aab48f5307fc81020` | | `0b5cbad59ef7` | `3f037d9e1e64de2836a858ee` | | `bea1b3e4f3c9` | `8991cf5e117ff664040a516e` | Five for five distinct. Including `0b5cbad5` → `9d414e84`, which is the #1095 fix: an ownership argument and comments in `internal/clan/files_idp_gateway.go`. The binary changed. ## Why — the premise both tickets share is wrong `internal/` is **linked into the agent**, and the Nix module text is Go string literals inside it (`renderFilesOIDCSecretGenerator` and friends build the config with `b.WriteString(...)`). A "render-only" edit is a changed string literal in a compiled package, so `go build` legitimately produces different bytes. There is no key — version tag, content checksum, or otherwise — that can call these two agents the same, because they genuinely are not. So my own prescription in #1100 was wrong, and I should have tested it before prescribing: I flagged the doubt parenthetically and filed anyway. The parenthesis was the important part. ## Where that leaves the ~60 minutes The gate is now correct and honest: the baked agent really does move on nearly every `internal/` commit, so the snapshot really is stale by its own definition, and the rebuild really is required *given that definition*. The cost is not a gate bug — it is the **snapshot contract**: the gateway image bakes a specific agent build, so the image's freshness is chained to the whole product's commit rate. That makes the remaining question a design one, above ADR 0174's two-way-door line, so I am not ruling it: - **A — stop baking the agent into the image.** Let the snapshot carry only the OS/store warmth, and have the drive place the current agent on the gateway after boot (the drive already copies closures). Snapshot rebuilds then key on the base image, not the product. The #656 ghost-red risk moves to "did the drive place the agent", which is checkable in-run. - **B — keep baking it, and accept the cost knowingly**, but make it cheap: the 60 min is dominated by a full nixos build + installer-base bake on a fresh droplet, and the bake reports an identical marker (`1355 store paths`, same `nixos-system-…-kexec` path) on every run tonight. A warm build host, or reusing the previous snapshot as the build base, is a much larger saving than any staleness-key change. Both are worth measuring before either is built. **#1096 and #1100 should be considered closed-but-ineffective rather than reverted** — the code is strictly better (honest verdicts, the corrected `~60 min` string, real fallbacks) and it is the right foundation for A, which needs the same probe machinery. I would suggest re-labelling this `needs-design` and putting the A-vs-B choice to Ben rather than having a worker pick. Session evidence only; no code change from me.
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#1100
No description provided.