fix(workspace): fetch PR refs from upstream and pin applied commit (audit #3) - #257
fix(workspace): fetch PR refs from upstream and pin applied commit (audit #3)#257sbalabanov wants to merge 2 commits into
Conversation
…udit #3) Two coordinated defects in the native PR-application path: (a) Workers cloned with --local have their "origin" pointing at the pool's local directory, which lacks pull/* refs. gitRequest.Apply now fetches PR refs from the real upstream remote URL, threaded through from the orchestrator via NewRequest/NewGitRequest. (b) Apply previously diffed against the floating PR head, so the same (URL, commit) cache key could materialize different trees as the PR advanced. Apply now diffs against the pinned commit instead. The ancestor check is retained as a sanity guard. Commit is now required at validation (mapper.ProtoToBuildDescription) since it forms cache identity. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
|
…f unconditional fetch Replace the unconditional bare-SHA fetch with a RevParse-based local object-presence check. The pinned commit is almost always already in the local odb because it must be an ancestor of the PR head we just fetched. A bare-SHA fetch is only attempted as a best-effort fallback when the object is missing locally, avoiding hard failures against git servers that refuse bare-SHA fetches (no uploadpack.allowAnySHA1InWant). Add real-git test proving Apply succeeds without bare-SHA fetch when the commit is reachable from the fetched PR head. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sbalabanov
left a comment
There was a problem hiding this comment.
Github pull request which comes from upstream is supposed to be immutable - i.e. not only it contains a traditional Github URL in a form of #257, but also a commit hash of the head of the request, so advancement in a PR causes a request to be revalidated. Analyze the fix in the light of that, specifically analyze how the request URL is parsed. Is the fix needed?
Reply to this comment, keep the PR in draft mode.
|
Thanks for calling this out. I traced the request construction and application path against the immutable
The commit therefore has to provide the immutable content identity. Before this PR, The upstream-fetch part is also needed independently: worker clones have No additional code change was needed from this analysis; the reviewed implementation remains at [addressed by agent] |
|
closing in favor of #264 and subsequent implementations |
Summary
Workers cloned with
--localhad theiroriginpointing at the pool's local directory (nopull/*refs), and Apply diffed against the floating PR head instead of the pinned commit -- allowing cache key collisions when the PR advanced.gitRequest.Applyso PR refs are fetched from the real remote, not the worker's localoriginbaseRef...commitinstead ofbaseRef...pull/<id>/head; retain the ancestor check as a sanity guardcommitrequired at validation (mapper.ProtoToBuildDescription) since it forms cache identityTest plan
go build ./...andgo test ./...pass (excluding env-gated integration tests)make gazelleregenerated BUILD files🤖 Generated with Claude Code