push-mode close-report refetches the live main head before gate 1 (#244) #271

Closed
matou-build-agent wants to merge 1 commit from agent/issue-244 into main

closes #244

What

In push mode, close-report.sh resolved gate 1's landing head to
${CR_MAIN_HEAD:-origin/main} and only refetched when HEAD was a
sandcastle/worker/* branch (#193). For any other checkout it compared claimed
commits against the checkout's origin/main tracking ref as it stood at run
start
— never a git fetch origin main beforehand — so a commit that landed
on main during the run was a descendant of a head the gate never refreshed,
and gate 1 refused it as "not reachable … (not landed)". Setting
CR_MAIN_HEAD=origin/main could not rescue it, because origin/main was itself
the unrefreshed ref. This is the #237 stall: 53793ce landed on main, four
close-report runs refused it, and #238/#239/#241 sat blocked ~22h.

Fix

  • When CR_MAIN_HEAD is unpinned and HEAD is not a sandcastle/worker/*
    branch, close-report.sh now runs git fetch --quiet origin main in the
    same checkout gate 1 evaluates and gates against the just-fetched
    FETCH_HEAD sha (deterministic — no reliance on an opportunistic
    tracking-ref update). On a fetch failure (no origin / offline) gate_head
    stays origin/main — the existing safe refusal, never a false close. An
    explicit CR_MAIN_HEAD still wins (the test seam).
  • The gate-1 refusal message (close-report-lib.sh) now names the head it
    compared against and when that head was fetched (CR_HEAD_FETCHED_AT).

Acceptance

  • Push mode fetches the live remote main head before gate 1 and gates
    against it.
  • The gate-1 refusal message names the compared head and its fetch time.
  • An explicit CR_MAIN_HEAD still overrides the refresh (test seam).
  • tests/close-report-test.sh gains the H0→H1-during-run scenario (ST-1),
    which passes with no manual CR_MAIN_HEAD.
  • The offline suite is green (pre-existing, unrelated
    tests/rehearsal-heal-lib-test.sh red noted below); lib + test in the same
    commit.

Tests

tests/close-report-test.sh +3 → 135 (red-first; verified ST-1 reds without
the fetch). GOTCHAS 75 + docs/journal/2026-10-16-244.md + STATUS.md header.

Root close-report.sh/close-report-lib.sh only — INERT in the running
.sandcastle/ self-copy and every consumer until a human re-vendors + bumps
FACTORY_REF (GOTCHAS 4).

Out of scope per the ticket: the pr-mode landing-head path (unchanged), the
#193 host-lands redesign, and the landing-reconcile sweep (a consider, left
for a follow-up). Pre-existing unrelated red: tests/rehearsal-heal-lib-test.sh
(Factory-Account trailer, #231/#223 area) fails on a clean tree — not this slice.

Screenshots: none — a harness close-report gate fix (shell libs + offline
tests + docs); no visible/UI surface to capture. Evidence is the red-first
tests/close-report-test.sh scenarios ST-1/ST-2.

closes #244 ## What In push mode, `close-report.sh` resolved gate 1's landing head to `${CR_MAIN_HEAD:-origin/main}` and only refetched when `HEAD` was a `sandcastle/worker/*` branch (#193). For any other checkout it compared claimed commits against the checkout's `origin/main` tracking ref **as it stood at run start** — never a `git fetch origin main` beforehand — so a commit that landed on `main` *during* the run was a descendant of a head the gate never refreshed, and gate 1 refused it as "not reachable … (not landed)". Setting `CR_MAIN_HEAD=origin/main` could not rescue it, because `origin/main` was itself the unrefreshed ref. This is the #237 stall: `53793ce` landed on `main`, four close-report runs refused it, and #238/#239/#241 sat blocked ~22h. ## Fix - When `CR_MAIN_HEAD` is unpinned and `HEAD` is not a `sandcastle/worker/*` branch, `close-report.sh` now runs `git fetch --quiet origin main` in the **same checkout gate 1 evaluates** and gates against the just-fetched `FETCH_HEAD` sha (deterministic — no reliance on an opportunistic tracking-ref update). On a fetch failure (no origin / offline) `gate_head` stays `origin/main` — the existing safe refusal, never a false close. An explicit `CR_MAIN_HEAD` still wins (the test seam). - The gate-1 refusal message (`close-report-lib.sh`) now names the head it compared against **and** when that head was fetched (`CR_HEAD_FETCHED_AT`). ## Acceptance - [x] Push mode fetches the live remote `main` head before gate 1 and gates against it. - [x] The gate-1 refusal message names the compared head and its fetch time. - [x] An explicit `CR_MAIN_HEAD` still overrides the refresh (test seam). - [x] `tests/close-report-test.sh` gains the H0→H1-during-run scenario (ST-1), which passes with no manual `CR_MAIN_HEAD`. - [x] The offline suite is green (pre-existing, unrelated `tests/rehearsal-heal-lib-test.sh` red noted below); lib + test in the same commit. ## Tests `tests/close-report-test.sh` +3 → 135 (red-first; verified ST-1 reds without the fetch). GOTCHAS 75 + `docs/journal/2026-10-16-244.md` + STATUS.md header. Root `close-report.sh`/`close-report-lib.sh` only — INERT in the running `.sandcastle/` self-copy and every consumer until a human re-vendors + bumps `FACTORY_REF` (GOTCHAS 4). Out of scope per the ticket: the pr-mode landing-head path (unchanged), the #193 host-lands redesign, and the landing-reconcile sweep (a *consider*, left for a follow-up). Pre-existing unrelated red: `tests/rehearsal-heal-lib-test.sh` (Factory-Account trailer, #231/#223 area) fails on a clean tree — not this slice. **Screenshots:** none — a harness close-report gate fix (shell libs + offline tests + docs); no visible/UI surface to capture. Evidence is the red-first `tests/close-report-test.sh` scenarios ST-1/ST-2.
sandcastle: #244 — push-mode close-report refetches the live main head before gate 1
All checks were successful
ci / test (pull_request) Successful in 10m11s
ci / static (pull_request) Successful in 2m14s
ba80432ad8
In push mode close-report resolved gate 1's landing head to
${CR_MAIN_HEAD:-origin/main} and only refetched when HEAD was a
sandcastle/worker/* branch (#193). For any other checkout it compared
claimed commits against the checkout's origin/main tracking ref AS IT STOOD
AT RUN START — no `git fetch origin main` beforehand — so a commit pushed to
main DURING the run was a descendant of a head the gate never refreshed and
gate 1 refused it as "not reachable … (not landed)". CR_MAIN_HEAD=origin/main
could not rescue it because origin/main was itself unrefreshed. The #237
stall: 53793ce landed, every close refused, #238/#239/#241 blocked ~22h.

Fix (root close-report.sh / close-report-lib.sh, INERT until re-vendor):
- When CR_MAIN_HEAD is unpinned and HEAD is not a sandcastle/worker/* branch,
  `git fetch --quiet origin main` in the SAME checkout gate 1 evaluates and
  gate against the just-fetched FETCH_HEAD sha (deterministic). On a fetch
  failure gate_head stays origin/main — the existing safe refusal, never a
  false close. An explicit CR_MAIN_HEAD still wins (the test seam).
- The gate-1 refusal message now names the head it compared against AND when
  that head was fetched (CR_HEAD_FETCHED_AT).

Tests (red-first, same commit; tests/close-report-test.sh +3 -> 135):
- ST-1: a commit on the live remote main but NOT on the stale local
  origin/main closes after the refetch with no manual CR_MAIN_HEAD.
- ST-2: an unlanded side commit is still refused and the refusal names the
  fetched live head + time.

Docs: GOTCHAS 75 (body + index row), docs/journal/2026-10-16-244.md, STATUS.md
header. Out of scope per the ticket: the pr-mode landing-head path (unchanged),
the #193 host-lands redesign, and the landing-reconcile sweep (a *consider*,
left for a follow-up). Pre-existing unrelated red: tests/rehearsal-heal-lib-test.sh
(Factory-Account trailer, #231/#223 area) fails on a clean tree — not this slice.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Factory-Account: d631bd58e1e9
Author
Member
close-report gates passed for #244 — every claim verified; this PR is cleared for merge.
<!-- close-report: gates-passed --> close-report gates passed for #244 — every claim verified; this PR is cleared for merge.
Owner

Superseded, closed unmerged (Ben, 2026-10-17): this PR's ba80432 was rebased onto main and fast-forwarded as 6b2062f (its gotcha renumbered 75 → 77 to avoid the clash with #280's). #244 is closed with the verification. Nothing left to merge.

Superseded, closed unmerged (Ben, 2026-10-17): this PR's `ba80432` was rebased onto `main` and fast-forwarded as `6b2062f` (its gotcha renumbered 75 → 77 to avoid the clash with #280's). #244 is closed with the verification. Nothing left to merge.
ben closed this pull request 2026-10-17 19:40:51 +00:00
All checks were successful
ci / test (pull_request) Successful in 10m11s
ci / static (pull_request) Successful in 2m14s

Pull request closed

Sign in to join this conversation.
No reviewers
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/dev-factory!271
No description provided.