rehearsal: executor re-checks HEAD parity at fire time so drives never race a push #1141

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

Why (from the #854 phase-5 retrospective)

Two drives (#1129, #1133) red on bugs already fixed at HEAD because the drive launched against a checkout that a push had just overtaken — a full drive slot (40–90 min) plus a reporter run spent re-discovering a landed fix. The reporter now self-detects "already repaired at HEAD — re-drive" (keep that as the backstop); this ticket stops the waste upstream.

What

At fire time (after preflight, immediately before the playwright launch), the executor re-checks git ls-remote origin main against the staged payload commit. If origin has advanced: re-sync, re-stage the payload, and re-run the cheap preflight checks once, then fire. One retry; if origin advances again during that window, fire anyway (the backstop catches the rare loser) — never spin.

Acceptance

  • A push landing between preflight and fire causes one re-sync + re-stage, and the drive runs at the new HEAD (verifiable in the drive's host-facts commit field).
  • No push → no extra network call beyond the single ls-remote.
  • A second push during the retry does not loop the executor; the drive fires after at most one re-stage.

Evidence: phase-5 report — HEAD-race reds #1129/#1133; reporter "already repaired at HEAD" comments on #854.

## Why (from the #854 phase-5 retrospective) Two drives (`#1129`, `#1133`) red on bugs **already fixed at HEAD** because the drive launched against a checkout that a push had just overtaken — a full drive slot (40–90 min) plus a reporter run spent re-discovering a landed fix. The reporter now self-detects "already repaired at HEAD — re-drive" (keep that as the backstop); this ticket stops the waste upstream. ## What At **fire time** (after preflight, immediately before the playwright launch), the executor re-checks `git ls-remote origin main` against the staged payload commit. If origin has advanced: re-sync, re-stage the payload, and re-run the cheap preflight checks once, then fire. One retry; if origin advances *again* during that window, fire anyway (the backstop catches the rare loser) — never spin. ## Acceptance - A push landing between preflight and fire causes one re-sync + re-stage, and the drive runs at the new HEAD (verifiable in the drive's host-facts commit field). - No push → no extra network call beyond the single `ls-remote`. - A second push during the retry does not loop the executor; the drive fires after at most one re-stage. Evidence: phase-5 report — HEAD-race reds #1129/#1133; reporter "already repaired at HEAD" comments on #854.

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 #1141 — status success

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

envelope
{
  "issue": 1141,
  "status": "success",
  "commits": [
    "9841c770"
  ],
  "changed_files": [
    "scripts/lib/rehearsal-sync-lib.sh",
    "scripts/rehearsal-cycle.sh",
    "scripts/tests/rehearsal-sync-test.sh"
  ],
  "tests": [
    {
      "command": "bash scripts/tests/rehearsal-sync-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/rehearsal-cycle.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/lib/rehearsal-sync-lib.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A push landing between preflight and fire causes one re-sync + re-stage, and the drive runs at the new HEAD (verifiable in the drive's host-facts commit field)": "scripts/rehearsal-cycle.sh fire-time-head-recheck block (commit 9841c770): on rehearsal_head_raced it runs `git pull --ff-only origin main` (re-sync) + a single `stage_and_preflight` (re-stage), advancing HEAD to the new commit; app/tests/e2e/fixtures/legs.ts driveCommit() reads `git rev-parse HEAD` at drive start into verdict.json's host-facts commit field, so the drive records the post-pull HEAD. Proven real-git: after ff-only pull, HEAD == remote.",
    "No push -> no extra network call beyond the single ls-remote": "The block does exactly one `git ls-remote origin main`; when rehearsal_head_raced is false (staged==remote) it only logs and fires — no pull, no second fetch, no re-stage. rehearsal-sync-test.sh check 14 proves equal SHAs fire as-is.",
    "A second push during the retry does not loop the executor; the drive fires after at most one re-stage": "The re-check is a plain `if` (not a loop): after the single stage_and_preflight it falls through to the drive with no re-check, so a second push rides the reporter's already-repaired-at-HEAD backstop. rehearsal-sync-test.sh check 20 asserts no while/until/for inside the sentinel-delimited fire-time block."
  },
  "summary": "Executor re-checks HEAD parity at fire time via one `git ls-remote`, re-syncing and re-staging exactly once at the new HEAD before the drive fires so a push landing during staging/preflight never reds a bug already fixed at HEAD.",
  "blockers": []
}
**close-report** for #1141 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1141, "status": "success", "commits": [ "9841c770" ], "changed_files": [ "scripts/lib/rehearsal-sync-lib.sh", "scripts/rehearsal-cycle.sh", "scripts/tests/rehearsal-sync-test.sh" ], "tests": [ { "command": "bash scripts/tests/rehearsal-sync-test.sh", "exit_code": 0 }, { "command": "bash -n scripts/rehearsal-cycle.sh", "exit_code": 0 }, { "command": "bash -n scripts/lib/rehearsal-sync-lib.sh", "exit_code": 0 } ], "criteria": { "A push landing between preflight and fire causes one re-sync + re-stage, and the drive runs at the new HEAD (verifiable in the drive's host-facts commit field)": "scripts/rehearsal-cycle.sh fire-time-head-recheck block (commit 9841c770): on rehearsal_head_raced it runs `git pull --ff-only origin main` (re-sync) + a single `stage_and_preflight` (re-stage), advancing HEAD to the new commit; app/tests/e2e/fixtures/legs.ts driveCommit() reads `git rev-parse HEAD` at drive start into verdict.json's host-facts commit field, so the drive records the post-pull HEAD. Proven real-git: after ff-only pull, HEAD == remote.", "No push -> no extra network call beyond the single ls-remote": "The block does exactly one `git ls-remote origin main`; when rehearsal_head_raced is false (staged==remote) it only logs and fires — no pull, no second fetch, no re-stage. rehearsal-sync-test.sh check 14 proves equal SHAs fire as-is.", "A second push during the retry does not loop the executor; the drive fires after at most one re-stage": "The re-check is a plain `if` (not a loop): after the single stage_and_preflight it falls through to the drive with no re-check, so a second push rides the reporter's already-repaired-at-HEAD backstop. rehearsal-sync-test.sh check 20 asserts no while/until/for inside the sentinel-delimited fire-time block." }, "summary": "Executor re-checks HEAD parity at fire time via one `git ls-remote`, re-syncing and re-staging exactly once at the new HEAD before the drive fires so a push landing during staging/preflight never reds a bug already fixed at 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#1141
No description provided.