rehearsal-4: gateway-image build.sh demands HEAD's agent in the registry — resolve the newest PUBLISHED sha instead #654

Closed
opened 2026-08-22 06:23:29 +00:00 by ben · 2 comments
Owner

Found 2026-08-22 preparing the first image build (#646 follow-up, #652 pre-arming item 2).

scripts/gateway-image/build.sh pins the agent for git rev-parse HEAD and dies "publish first" when the Forgejo generic registry lacks that exact sha. But CI's publish guard (9550609, ADR 0185) only publishes when the agent artifact CHANGED, so any docs/STATUS-only commit on top (e.g. dfac837) makes main unbuildable until the next agent-affecting commit. Today's workaround: detached checkout of 8585a95.

Fix direction (two-way door): resolve the pin as the newest registry version that is an ancestor of HEAD (git merge-base --is-ancestor), or accept AGENT_SHA=<full> as an explicit override; name the snapshot after HEAD's short sha still (the image config is HEAD's), and record BOTH shas in agent-pin.json. Keep the dirty-tree refusal. Add an offline test with a fake registry listing (the latest-test.sh shape).

Bonus: build.sh leaves nix/gateway-image/agent-pin.json modified after a run — either commit it as part of the build ritual (documented) or write it to a build dir.

**Found 2026-08-22 preparing the first image build (#646 follow-up, #652 pre-arming item 2).** `scripts/gateway-image/build.sh` pins the agent for `git rev-parse HEAD` and dies "publish first" when the Forgejo generic registry lacks that exact sha. But CI's publish guard (`9550609`, ADR 0185) only publishes when the agent artifact CHANGED, so any docs/STATUS-only commit on top (e.g. `dfac837`) makes `main` unbuildable until the next agent-affecting commit. Today's workaround: detached checkout of `8585a95`. **Fix direction (two-way door):** resolve the pin as the newest registry version that is an ancestor of HEAD (`git merge-base --is-ancestor`), or accept `AGENT_SHA=<full>` as an explicit override; name the snapshot after HEAD's short sha still (the image config is HEAD's), and record BOTH shas in `agent-pin.json`. Keep the dirty-tree refusal. Add an offline test with a fake registry listing (the `latest-test.sh` shape). Bonus: `build.sh` leaves `nix/gateway-image/agent-pin.json` modified after a run — either commit it as part of the build ritual (documented) or write it to a build dir.

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

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

close-report for #654 — status success

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

envelope
{
  "issue": 654,
  "status": "success",
  "commits": [
    "b9f07f76"
  ],
  "changed_files": [
    "scripts/gateway-image/pin-agent.sh",
    "scripts/gateway-image/tests/pin-agent-test.sh",
    "scripts/gateway-image/build.sh",
    "docs/GOTCHAS.md",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash scripts/gateway-image/tests/pin-agent-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/gateway-image/tests/latest-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/gateway-image/pin-agent.sh scripts/gateway-image/build.sh scripts/gateway-image/tests/pin-agent-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "resolve pin as newest registry version that is an ancestor of HEAD (git merge-base --is-ancestor)": "scripts/gateway-image/pin-agent.sh published_versions()+ancestor loop; proven by pin-agent-test.sh case 1 (newest published is non-ancestor, older ancestor resolved)",
    "accept AGENT_SHA=<full> as an explicit override": "pin-agent.sh AGENT_SHA branch; proven by pin-agent-test.sh case 2",
    "name the snapshot after HEAD's short sha still": "build.sh snapname=idss-gateway-$short with short=rev-parse --short=12 HEAD (unchanged)",
    "record BOTH shas in agent-pin.json": "pin-agent.sh writes {sha, hash, image_sha}; pin-agent-test.sh case 1 asserts sha==ancestor and image_sha==HEAD",
    "keep the dirty-tree refusal": "build.sh retains 'working tree dirty — commit first' die before pinning",
    "add an offline test with a fake registry listing (latest-test.sh shape)": "scripts/gateway-image/tests/pin-agent-test.sh — fake curl+nix on PATH, ALL PASS",
    "bonus: build.sh no longer leaves agent-pin.json modified after a run": "build.sh cleanup trap runs 'git checkout -- nix/gateway-image/agent-pin.json' on EXIT; git status clean of agent-pin.json after edits"
  },
  "summary": "gateway-image build.sh now pins the newest published agent that is an ancestor of HEAD (or AGENT_SHA override), records both shas, and restores the pin placeholder on exit — a docs-only commit no longer makes main unbuildable.",
  "reason": "",
  "blockers": []
}
**close-report** for #654 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 654, "status": "success", "commits": [ "b9f07f76" ], "changed_files": [ "scripts/gateway-image/pin-agent.sh", "scripts/gateway-image/tests/pin-agent-test.sh", "scripts/gateway-image/build.sh", "docs/GOTCHAS.md", "STATUS.md" ], "tests": [ { "command": "bash scripts/gateway-image/tests/pin-agent-test.sh", "exit_code": 0 }, { "command": "bash scripts/gateway-image/tests/latest-test.sh", "exit_code": 0 }, { "command": "bash -n scripts/gateway-image/pin-agent.sh scripts/gateway-image/build.sh scripts/gateway-image/tests/pin-agent-test.sh", "exit_code": 0 } ], "criteria": { "resolve pin as newest registry version that is an ancestor of HEAD (git merge-base --is-ancestor)": "scripts/gateway-image/pin-agent.sh published_versions()+ancestor loop; proven by pin-agent-test.sh case 1 (newest published is non-ancestor, older ancestor resolved)", "accept AGENT_SHA=<full> as an explicit override": "pin-agent.sh AGENT_SHA branch; proven by pin-agent-test.sh case 2", "name the snapshot after HEAD's short sha still": "build.sh snapname=idss-gateway-$short with short=rev-parse --short=12 HEAD (unchanged)", "record BOTH shas in agent-pin.json": "pin-agent.sh writes {sha, hash, image_sha}; pin-agent-test.sh case 1 asserts sha==ancestor and image_sha==HEAD", "keep the dirty-tree refusal": "build.sh retains 'working tree dirty — commit first' die before pinning", "add an offline test with a fake registry listing (latest-test.sh shape)": "scripts/gateway-image/tests/pin-agent-test.sh — fake curl+nix on PATH, ALL PASS", "bonus: build.sh no longer leaves agent-pin.json modified after a run": "build.sh cleanup trap runs 'git checkout -- nix/gateway-image/agent-pin.json' on EXIT; git status clean of agent-pin.json after edits" }, "summary": "gateway-image build.sh now pins the newest published agent that is an ancestor of HEAD (or AGENT_SHA override), records both shas, and restores the pin placeholder on exit — a docs-only commit no longer makes main unbuildable.", "reason": "", "blockers": [] } ``` </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#654
No description provided.