Skip to content

[bug] Existing integration branches are reused without proving the recorded base #19

@coygeek

Description

@coygeek

[bug] Existing integration branches are reused without proving the recorded base

Summary

When DeployBot creates a cumulative integration PR, it creates refs/heads/{integration branch} at the current base SHA. If GitHub reports that the reference already exists, DeployBot silently continues and merges the frozen source heads into whatever commit that existing branch currently points to.

The integration marker then records the current base_sha, even though the actual integration branch may have been created from an older base or contain stale partial merges from a prior attempt.

Evidence

Impact

An integration PR can stop being a faithful cumulative test of "these frozen heads merged onto this frozen base":

  • If the branch exists from an earlier base, the integration marker can claim a newer base_sha that is not actually an ancestor of the integration branch.
  • If a previous attempt partially merged some heads, a rerun may merge the remaining heads onto stale partial state and report an inaccurate merged_heads list.
  • If the base branch moved, DeployBot may omit the latest base changes from the cumulative validation PR while still presenting the PR as the current batch.

That undermines the purpose of integration mode: proving that a frozen batch works together on the intended base.

Proposed fix

  • On Reference already exists, read the branch ref before continuing.
  • Require one of these safe states:
    • the existing branch has a valid DeployBot integration marker for the same active batch_id, same base_sha, and same expected source heads, or
    • the branch is reset/updated back to the freshly computed base_sha before replaying merges.
  • Make replay idempotent by treating already-contained source heads as merged only after proving ancestry, rather than relying on a fresh API merge call.
  • Add regression tests for:
    • existing integration branch on an older base is rejected or reset.
    • existing integration branch with mismatched marker is rejected.
    • rerun with same branch/base/heads is idempotent and does not lie in the marker.

Verification

  • python3 -m pytest tests/test_cli.py -q
  • python3 -m pytest -q

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions