Skip to content

Create signed PR branches at the first commit, not the base SHA - #77555

Merged
pelikhan merged 5 commits into
mainfrom
copilot/create-pull-request
Nov 14, 2026
Merged

pelikhan merged 5 commits into
mainfrom
copilot/create-pull-request

Conversation

@pelikhan

@pelikhan pelikhan commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Signed PR creation initially points the head branch at the base SHA, triggering external CI builds whose skipped or cancelled statuses can overwrite the base commit’s passing status.

  • Branch initialization: Create the first tree and commit through REST, require a verified signature, then publish the ref at that commit. Continue subsequent commits through GraphQL.
  • Claim delivery: Independently verify staged commits, trees, and blobs against the PR history so the new REST writes remain accounted for.
  • Regression coverage: Cover publication order, commit chaining, concurrent creation, payload preservation, signature rejection, and claim settlement.

pelikhan and others added 2 commits November 13, 2026 21:06
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@pelikhan pelikhan changed the title [WIP] Fix head branch creation for signed commits Create signed PR branches at the first commit, not the base SHA Nov 13, 2026
@pelikhan
pelikhan marked this pull request as ready for review November 13, 2026 22:32
Copilot AI adaptive review requested due to automatic review settings November 13, 2026 22:32
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: sonnet55 high · ~5 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 8.6K · ◷

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by PR Specification Reviewer for #77555 · copilot · gpt56 · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~5 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.5K · ◷

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K · ◷

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by Ponytail Reviewer for #77555 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 182 · ◷

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (spec-review-history)
{"id":"ldg-aa520bb9-c478-4e73-9d67-078e932d9859","parents":[],"payload":{"id":"ldg-f90a9761-c3cf-4b4b-a097-4f9d97e4d1ae","operation":"append","value":{"finding_count":0,"head_sha":"9a4fb7531d2f99fad914839b4fbfc389f4d8a0c9","outcome":"aligned"}},"sha":"sha256:61915d0b165c86a37a6b64a1755d72709db4320f8aba70df97b6fef123e9f48e","timestamp":"2026-11-13T22:43:52.595Z","type":"ledger_append","version":1}
History

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-13T22:36:43Z
review_event: REQUEST_CHANGES
top_themes: [concurrent signed-commit race, large-tree delivery verification, unaccounted foreign Git effects]
files_reviewed: [actions/setup/js/push_signed_commits.cjs, actions/setup/js/work_queue_native_creation_delivery.cjs, actions/setup/js/work_queue_git_effects.cjs]
comment_count: 3
History

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~5 AIC · ⌖ ~1 AIC · ⊞ 1.5K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found three blocking correctness issues in signed-PR claim delivery.

Highlights
  • Concurrent branch creation can leave a staged REST commit orphaned, causing successful delivery to remain unverified.
  • Recursive tree verification permanently rejects large/truncated repositories.
  • Foreign-repository Git effects are silently discarded instead of rejected.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~5 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again

throw new Error(`${ERR_API}: Could not resolve remote branch OID for ${branch} after concurrent creation`);
}
expectedHeadOid = refreshedOid;
if (refreshedOid === firstOid) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the ref creation races and the refreshed head is not firstOid, this code falls through to GraphQL and replays the change, leaving the REST-created commit orphaned and recorded as a successful claim effect even though it is not an ancestor of the final PR head.

💡 Reconcile the race before replaying

The delivery verifier now requires every staged git_commit to be on the final history, so a concurrent branch created at the base (or another head) makes the otherwise successful PR delivery remain unverified. Either fail/retry the operation before recording the orphan, or explicitly discard/reconcile the staged REST objects and verify only the commit actually published. Add an end-to-end race test through claim settlement.

const stagedBlobs = new Set();
if (staged.some(effect => effect.kind === "git_blob")) {
for (const treeSha of stagedTrees) {
const { data: tree } = await github.rest.git.getTree({ owner: headOwner, repo: headRepo, tree_sha: treeSha, recursive: "1" });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This verifier recursively downloads the entire tree for each staged commit and rejects any response with truncated !== false, so signed PR deliveries in sufficiently large repositories can never settle as verified even when the changed objects are valid.

💡 Verify bounded changed-path evidence

The recursive Git tree endpoint is explicitly truncatable for large repositories; treating truncation as an object mismatch leaves the work barrier pending after a successful PR. Verify only the staged paths (or walk trees non-recursively with bounded requests), and add coverage for a large/truncated repository without weakening the object-integrity checks.

const authority = await resolveParentResourceTarget(github, { repository: receipt.repository, kind: "pull_request", number: receipt.number }, data);
const head = await resolveRepositoryTarget(github, { repository: receipt.headRepository, repository_id: nativeDecimalIdentity(data.head.repo.id), ref: `refs/heads/${receipt.branch}` });
const effects = [];
const staged = (options.effects || []).filter(effect => receiptMatchesClaim(effect, claim) && effect.outcome === "succeeded" && effect.repository === receipt.headRepository && ["git_blob", "git_tree", "git_commit"].includes(effect.kind));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effects for successful Git writes in any repository other than receipt.headRepository are silently filtered out, so a foreign-repository blob/tree/commit write is not rejected and is omitted from the delivery proof.

💡 Fail closed on unexpected staged Git effects

The new claim accounting is intended to ensure every REST-created object is tied to the PR history. Filtering the effect away lets the verifier return verified: true while the claim contains an unaccounted Git write, and the added foreign_repository test case should expose this behavior. Reject claim-matching Git object effects whose repository is not the expected head repository instead of dropping them.

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (review-history)
{"id":"ldg-5e9aa174-864c-4c43-ae45-dd667af35aa4","parents":[],"payload":{"id":"ldg-b82655a2-e375-4568-af64-46f81f5d7119","operation":"append","value":{"finding_count":3,"head_sha":"9a4fb7531d2f99fad914839b4fbfc389f4d8a0c9","outcome":"findings"}},"sha":"sha256:698a8f3149119e7c1be69803df54f60a2b23b95375080e8c783bc49e2135c78d","timestamp":"2026-11-13T22:47:27.243Z","type":"ledger_append","version":1}
History

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd to the REST-first first-commit path. Posting observations only: two inline comments on a possible settlement failure after a lost race and a coverage gap for a failing createRef.

📋 Key Themes & Highlights

Key Themes

  • Race-path verification: a concurrent initial-head 422 leaves the REST-created commit unreferenced. Verification may still stage it as a succeeded git_commit effect. This is not confirmed by a test.
  • Failure coverage: the createBlob/createTree/createCommit failure test does not cover a failing createRef.

Positive Highlights

  • ✅ Publishing the signed first commit before createRef avoids a branch pointing at the base commit.
  • ✅ Unverified signatures are refused via PushSignedCommitsPolicyViolation, which skips the unsigned git push fallback.
  • ✅ The 422 fallthrough remains guarded by the existing requireBaseRefMatch check, which is pre-existing behaviour.

Limitations

Test execution was blocked: npm ci fails on a self-signed certificate from the package proxy. I did not run the targeted vitest suites, so the findings are from static reading only.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again

const staged = (options.effects || []).filter(effect => receiptMatchesClaim(effect, claim) && effect.outcome === "succeeded" && effect.repository === receipt.headRepository && ["git_blob", "git_tree", "git_commit"].includes(effect.kind));
const stagedTrees = new Set();
const [headOwner, headRepo] = receipt.headRepository.split("/");
for (const effect of staged.filter(effect => effect.kind === "git_commit")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnosing-bugs] A lost-race orphan can block settlement. When createRef returns 422 and the refreshed remote head is a third commit, the REST-created firstOid is never referenced, but its git_commit, git_blob and git_tree effects appear to stay recorded as succeeded. This loop then requires every staged commit to be an ancestor of receipt.commit, so delivery fails closed with pull_request.effect_commit_mismatch.

💡 Suggested fix

On the 422 path where refreshedOid !== firstOid, exclude the orphaned REST objects from the staged effects (or do not record them as succeeded). Add a regression test in work_queue_native_creation_delivery.test.cjs that settles a PR after the concurrent initial-head race. The existing initial concurrency test in push_signed_commits.test.cjs covers only the push step, not verification.

@copilot please address this.

expect(mockCore.warning).not.toHaveBeenCalledWith(expect.stringContaining("falling back to git push"));
});

it.each(["createBlob", "createTree", "createCommit"])("does not create a ref when initial %s fails", async method => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] No test covers a non-422 createRef failure after a verified createCommit. This block only makes createBlob, createTree and createCommit fail. Add createRef to the it.each list. Its assertions must change, because createRef is the rejected call, so not.toHaveBeenCalled() would not hold. The test should confirm the failure is surfaced and no unsigned git push fallback runs.

💡 Suggested test shape

Keep allowGitPushFallback: false and assert rejects.toThrow plus that graphql is never called. This guards against a regression where a REST error silently publishes an unsigned branch.

@copilot please address this.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new REST initialization path relies on commit auto-signing unavailable with supported personal access tokens, breaking new-branch PR creation while also disabling fallback.

4 open issues
What changed in this PR

Updates gh-aw’s signed PR creation to publish new branches at the first verified commit rather than the base SHA, preventing branch-triggered CI from overwriting the base commit’s status (#76888).

Changes:

  • Creates the initial Git objects through REST, verifies the commit signature, then publishes the branch; subsequent commits continue through GraphQL.
  • Tracks staged Git writes and verifies their membership in the PR history during Claim settlement.
  • Expands regression coverage for publication order, commit chaining, concurrent creation, payload preservation, and delivery verification.
File Description
actions/​setup/​js/​work_queue_native_creation_delivery.test.cjs Tests staged-object settlement and rejection of mismatched evidence.
actions/​setup/​js/​work_queue_native_creation_delivery.cjs Verifies staged commits, trees, and blobs against PR history.
actions/​setup/​js/​work_queue_git_effects.cjs Extends Claim authorization to REST Git-object creation.
actions/​setup/​js/​push_signed_commits.test.cjs Covers REST-first initialization, races, payloads, and signature rejection.
actions/​setup/​js/​push_signed_commits.cjs Creates and verifies the first commit before publishing a new branch ref.

Review effort: Max (dynamic)

}
core.info(`pushSignedCommits: creating remote branch ${branch} at parent OID ${expectedHeadOid}`);
assertTransportUnchanged?.();
const parent = await githubClient.rest.git.getCommit({ owner, repo, commit_sha: expectedHeadOid });
Comment on lines +878 to +879
const createdCommit = await withGitClaimEffects({ github: githubClient, repository: `${owner}/${repo}`, branch, paths }, () =>
githubClient.rest.git.createCommit({ owner, repo, message, tree: treeOid, parents: [expectedHeadOid] })
Comment on lines +867 to +869
const blob = await withGitClaimEffects({ github: githubClient, repository: `${owner}/${repo}`, branch, paths: [addition.path] }, () =>
githubClient.rest.git.createBlob({ owner, repo, content: addition.contents, encoding: "base64" })
);
Comment on lines +325 to +326
const { data: tree } = await github.rest.git.getTree({ owner: headOwner, repo: headRepo, tree_sha: treeSha, recursive: "1" });
if (tree?.sha !== treeSha || tree.truncated !== false || !Array.isArray(tree.tree)) return { verified: false, diagnostics: { event: "pull_request.effect_tree_mismatch" } };
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/push_signed_commits.cjs:917): address unresolved feedback - Review comment
  3. Review (actions/setup/js/work_queue_native_creation_delivery.cjs:325): address unresolved feedback - Review comment
  4. Review (actions/setup/js/work_queue_native_creation_delivery.cjs:308): address unresolved feedback - Review comment
  5. Review (actions/setup/js/work_queue_native_creation_delivery.cjs:311): address unresolved feedback - Review comment
  6. Review (actions/setup/js/push_signed_commits.test.cjs:1149): address unresolved feedback - Review comment
  7. Fix failing check JS Tests (shard 7/8) (FAILURE): Check run.
  8. Fix failing check JS Tests (shard 7/8) (FAILURE): Check run.

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "9a4fb7531d2f99fad914839b4fbfc389f4d8a0c9",
  "kind": "requested",
  "schema_version": "1",
  "state": "f25d6df93f118d0f1a2041b27837da1252141f271d07efaeac598cb20cc8c332",
  "work": [
    "436325f3d1eca6811ec6f0e88fe4b789d163a653339dfdf26ce9f05dce8f0e16",
    "47f188a12b316525c2202f4f75b82185d76be0a140c0f99eae185cf2b7d8acb1",
    "6243e35aa69af0fe1d9c5aca45d23257eb8dc461352cfd05599d53ae6ed1dd80",
    "80f56838c00914f5d7aacb5f538360624b10c6267ec76d6505ea156f29fee1d2",
    "be35bd345309ca69b7da73301b250a16ab2531e7fdbc6d01a8864b77b07ae2e0",
    "cca9ffe2f4d1628d7775ce695c6e8a8e3d7d12e753f4fb3b3b07574affef9c0f"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~4 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

gh-aw-bot and others added 2 commits November 13, 2026 23:25
…equest

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Copilot AI requested a review from gh-aw-bot November 14, 2026 00:18
@pelikhan
pelikhan merged commit f5e144b into main Nov 14, 2026
34 checks passed
@pelikhan
pelikhan deleted the copilot/create-pull-request branch November 14, 2026 02:55
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create-pull-request (signed commits) creates the head branch at the base SHA

4 participants