Skip to content

chore(agent-actions): update_branch silently omits expected_head_sha with no fallback when the pin is absent #2424

Description

@JSONbored

Parent: #1936

Problem

performAction's "update_branch" case (src/services/agent-action-executor.ts) passes action.expectedHeadSha directly into updatePullRequestBranch with no ?? ctx.headSha fallback (unlike approve/merge). updatePullRequestBranch (src/github/pr-actions.ts) spreads it in conditionally: ...(expectedHeadSha ? { expected_head_sha: expectedHeadSha } : {}). When expectedHeadSha is absent, the param is simply OMITTED from the PUT .../update-branch call — GitHub then applies the update against whatever the live head happens to be, with zero server-side staleness comparison at all (not even a tautological one).

This is lower severity than the approve/merge cases (#2377, #2422) since rebasing a PR onto its current base is generally idempotent/safe regardless of exactly which head it's applied against — it doesn't itself ratify or merge unreviewed code, just brings the branch up to date. Flagged for completeness/consistency by the same adversarial review pass that found the approve and merge gaps, not because it's an equivalent-severity finding.

Requirements

  • Decide whether update_branch needs any pinning enforcement, or whether its current "GitHub applies the update against whatever's current" behavior is acceptable given the operation's low-risk nature.

Deliverables

Acceptance criteria

  • A documented, deliberate decision exists for update_branch's pinning behavior, rather than an unexamined asymmetry with approve/merge.

Expected outcome

Either explicit documentation that this is safe-by-design, or parity with the approve/merge fixes if a real risk is found.

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions