rehearsal: coalesce #661 auto-rebuilds — pushes during a rebuild fold into one follow-up at latest HEAD #1140

Closed
opened 2026-09-02 05:59:27 +00:00 by ben · 2 comments
Owner

Why (from the #854 phase-5 retrospective)

The #661 auto-rebuild fires per push: the arc saw 112 rebuilds for 87 arc-relevant commits. No staleness key can help — internal/ is linked into the agent as Go string literals, so nearly every commit changes the bytes honestly (measured on #1100: 5/5 published agent hashes distinct). The fix is fewer triggers, not a third key (#1096/#1100 closed on exactly this finding).

What

Coalesce, don't retrigger. While a rebuild is running, further pushes do not queue further rebuilds — they mark the running rebuild's result stale-on-arrival. When a rebuild finishes and the marker is set, exactly one follow-up rebuild fires at the then-current HEAD (latest wins). A drive that launches between rebuilds uses the newest completed snapshot, as today.

Deliberately NOT chosen: moving the trigger to drive-launch — that serializes the (now ~15 min) rebuild into drive latency and lets the snapshot go cold between sparse drives.

Acceptance

  • Push N while rebuild for push N-1 runs → no second concurrent rebuild; one follow-up rebuild at HEAD(N…latest) after the first completes.
  • A burst of K pushes during one rebuild produces exactly 2 rebuilds total, the second at the newest HEAD.
  • Existing behaviour unchanged when pushes are sparse (one push → one rebuild).
  • Coalescing state survives an executor restart (marker file, not memory).

Evidence: phase-5 report — 112 rebuilds / ~95 h background compute.

## Why (from the #854 phase-5 retrospective) The #661 auto-rebuild fires per push: the arc saw **112 rebuilds for 87 arc-relevant commits**. No staleness key can help — `internal/` is linked into the agent as Go string literals, so nearly every commit changes the bytes honestly (measured on #1100: 5/5 published agent hashes distinct). The fix is fewer triggers, not a third key (#1096/#1100 closed on exactly this finding). ## What **Coalesce, don't retrigger.** While a rebuild is running, further pushes do not queue further rebuilds — they mark the running rebuild's result stale-on-arrival. When a rebuild finishes and the marker is set, exactly one follow-up rebuild fires at the then-current HEAD (latest wins). A drive that launches between rebuilds uses the newest completed snapshot, as today. Deliberately NOT chosen: moving the trigger to drive-launch — that serializes the (now ~15 min) rebuild into drive latency and lets the snapshot go cold between sparse drives. ## Acceptance - Push N while rebuild for push N-1 runs → no second concurrent rebuild; one follow-up rebuild at HEAD(N…latest) after the first completes. - A burst of K pushes during one rebuild produces exactly 2 rebuilds total, the second at the newest HEAD. - Existing behaviour unchanged when pushes are sparse (one push → one rebuild). - Coalescing state survives an executor restart (marker file, not memory). Evidence: phase-5 report — 112 rebuilds / ~95 h background compute.

swarm-claim host=elitebook-distributed-server-03 run=16332
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=16332 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #1140 — status success

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

envelope
{
  "issue": 1140,
  "status": "success",
  "commits": [
    "878743b3"
  ],
  "changed_files": [
    "scripts/lib/gateway-image-rebuild-lib.sh",
    "scripts/tests/gateway-image-rebuild-test.sh"
  ],
  "tests": [
    {
      "command": "bash scripts/tests/gateway-image-rebuild-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/rehearsal-sync-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/gateway-image/tests/gateway-image-staleness-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/rehearsal-cycle.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Push N while rebuild for push N-1 runs -> no second concurrent rebuild; one follow-up rebuild at HEAD(N..latest)": "flock -n loser records HEAD in the marker and returns (exit 3 -> return 0) without building (test 6, no concurrent build + marker written); the in-flight builder drains the marker and fires exactly one follow-up (gwimage_coalesce_followup, test 13)",
    "A burst of K pushes during one rebuild produces exactly 2 rebuilds total, the second at the newest HEAD": "test 13 (clause 2): a mid-build mark of a newer HEAD -> exactly TWO builds (buildcount=2), marker drained; only one follow-up (plain if, never a loop)",
    "Existing behaviour unchanged when pushes are sparse (one push -> one rebuild)": "test 14 (clause 3): head_start==pending -> no follow-up -> exactly ONE rebuild; existing tests 1-5,9-11 unchanged",
    "Coalescing state survives an executor restart (marker file, not memory)": "OC_GWIMAGE_COALESCE_MARKER is an absolute on-disk file; test 15 proves a marked value is readable by a fresh process (not shell memory); test 6 reads the mark after the call returns"
  },
  "summary": "The #661 gateway-image auto-rebuild now coalesces: a stale tick that meets an in-flight rebuild records HEAD in a marker file instead of queuing a concurrent build, and the builder fires exactly one follow-up at the latest HEAD.",
  "blockers": []
}
**close-report** for #1140 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1140, "status": "success", "commits": [ "878743b3" ], "changed_files": [ "scripts/lib/gateway-image-rebuild-lib.sh", "scripts/tests/gateway-image-rebuild-test.sh" ], "tests": [ { "command": "bash scripts/tests/gateway-image-rebuild-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/rehearsal-sync-test.sh", "exit_code": 0 }, { "command": "bash scripts/gateway-image/tests/gateway-image-staleness-test.sh", "exit_code": 0 }, { "command": "bash -n scripts/rehearsal-cycle.sh", "exit_code": 0 } ], "criteria": { "Push N while rebuild for push N-1 runs -> no second concurrent rebuild; one follow-up rebuild at HEAD(N..latest)": "flock -n loser records HEAD in the marker and returns (exit 3 -> return 0) without building (test 6, no concurrent build + marker written); the in-flight builder drains the marker and fires exactly one follow-up (gwimage_coalesce_followup, test 13)", "A burst of K pushes during one rebuild produces exactly 2 rebuilds total, the second at the newest HEAD": "test 13 (clause 2): a mid-build mark of a newer HEAD -> exactly TWO builds (buildcount=2), marker drained; only one follow-up (plain if, never a loop)", "Existing behaviour unchanged when pushes are sparse (one push -> one rebuild)": "test 14 (clause 3): head_start==pending -> no follow-up -> exactly ONE rebuild; existing tests 1-5,9-11 unchanged", "Coalescing state survives an executor restart (marker file, not memory)": "OC_GWIMAGE_COALESCE_MARKER is an absolute on-disk file; test 15 proves a marked value is readable by a fresh process (not shell memory); test 6 reads the mark after the call returns" }, "summary": "The #661 gateway-image auto-rebuild now coalesces: a stale tick that meets an in-flight rebuild records HEAD in a marker file instead of queuing a concurrent build, and the builder fires exactly one follow-up at the latest HEAD.", "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#1140
No description provided.