refreshPullHead in src/core/following.ts writes the new tip to refs/pull/N/head, then awaits carryApproval (and resolveOid on the base), and only after that updates pull.head_oid. If a second refresh runs in that window, it sees the ref already moved, returns undefined, and its caller reads the row, which still holds the old head. That showed up as an intermittent failure in test/crew-proposal.test.ts: a resolve run read the old head and recorded no commit.
Fix: write head_oid right after writeRef, with no await in between. The pull also needs its own test that fails without the fix, meaning two refreshes interleaved at the carryApproval await, with the row checked against the ref.
Split out of #12617 at review: that pull is about the sentinel and should stay single-purpose.
refreshPullHeadinsrc/core/following.tswrites the new tip torefs/pull/N/head, then awaitscarryApproval(andresolveOidon the base), and only after that updatespull.head_oid. If a second refresh runs in that window, it sees the ref already moved, returns undefined, and its caller reads the row, which still holds the old head. That showed up as an intermittent failure intest/crew-proposal.test.ts: a resolve run read the old head and recorded no commit.Fix: write
head_oidright afterwriteRef, with no await in between. The pull also needs its own test that fails without the fix, meaning two refreshes interleaved at thecarryApprovalawait, with the row checked against the ref.Split out of #12617 at review: that pull is about the sentinel and should stay single-purpose.