fix(gitstate): fetch fresh and retry so a rejected push can't silently lose a baseline#19
Merged
Merged
Conversation
…y lose a baseline WriteBaseline staged its commit on the local origin/bulwark-state tracking ref, which is as stale as the job's checkout — wardnet's scan runs for ~8 minutes between the two, and any concurrent run that lands a baseline in that window advances the remote. The resulting non-fast-forward push was rejected AND swallowed (return nil), so the record-on-main path printed "recorded coverage baseline" while the baseline was in fact lost, and every PR against that main commit re-hit a cache miss (wardnet/wardnet#888). Each attempt now fetches the fresh remote ref immediately before staging, retries a rejected push (up to 3 attempts), treats already-identical remote content as success, and returns an error when the push never lands so the caller reports "failed to record" instead of "recorded". The new stale-ref test also surfaced a latent data race under -race: executil wired stdout and stderr into the same capture buffer from two os/exec copy goroutines. The shared buffer is now mutex-guarded. Claude-Session: https://claude.ai/code/session_01WE4fbpPvaMDfXeQW2zoBzh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Despite #18 (record the baseline when running on main), wardnet PRs still hit coverage cache misses — see wardnet/wardnet#888. The main-push run for merge-base
9f10325fdid measure and commit a baseline, but the push was rejected and silently discarded:WriteBaselinestaged its commit on the localorigin/bulwark-statetracking ref, last updated by the job's checkout ~8 minutes earlier. wardnet's CI is busy enough that a concurrent run advances the remote branch inside that window, so the push is non-fast-forward — and the rejection was swallowed (return nil), a "best-effort" policy written for the PR-side cache-miss path but fatal to the record-on-main path, where the push is the point. inforge never hits this because itsbulwark-statesees far less concurrent traffic.Fix
{}entry) still overwrites.cmd/bulwark/coverage.goalready downgrades it to afailed to recordwarning, so the misleading "recorded" line disappears without failing the build.The new stale-ref test also surfaced a latent data race under
-race:executilwired the child's stdout and stderr into the same capture buffer from twoos/execcopy goroutines. The shared buffer is now mutex-guarded, with its own regression test.Testing
TDD: both gitstate tests reproduced the exact failures RED first (stale-ref push silently lost; rejected push returning nil), confirmed RED again with the fix reverted, then GREEN.
go build ./...,go test -race ./..., andgolangci-lint run ./...all clean.Merge Commit Message
fix(gitstate): fetch fresh and retry so a rejected baseline push can't be silently lost; sync executil's shared capture buffer
https://claude.ai/code/session_01WE4fbpPvaMDfXeQW2zoBzh