gitbutler icon indicating copy to clipboard operation
gitbutler copied to clipboard

Skill: `(merged upstream)` is not a safe signal to `but pull`; confirm with `but pull --check` → `[integrated]`

Open mattspruiell opened this issue 2 months ago • 0 comments

What is the improvement or update you wish to see?

The agent skill tells agents that (merged upstream) in but status means a branch has landed and but pull will remove it (crates/but/skill/SKILL.md:58). I have seen but status show that marker while but pull --check reported the branch as [ok], not [integrated]. Following the skill's instruction in that state rebased the branch instead of removing it, and left its commits applied as (no changes), some of them {conflicted}.

Two lines in the skill combine to send an agent down this path. Line 58 treats (merged upstream) as the signal to pull. Lines 101-103 tell the agent not to run but pull --check as a routine preflight, which is the one command that showed the disagreement.

Suggested changes:

  1. At line 58, say that (merged upstream) alone does not mean but pull will retire the branch. Tell the agent to confirm with but pull --check that the branch reads [integrated] first.
  2. Treat a just-merged branch as a case where but pull --check is expected, alongside the ones lines 101-103 already list.
  3. Mention that the CLI reports a landed branch as integrated ([integrated] from --check, "has been integrated upstream and removed locally" from but pull). The skill uses only the phrase merged upstream, so an agent searching the skill for the word the CLI prints finds nothing.
  4. For a branch left applied after its content has landed, recommend but unapply <branch> before but discard. It clears the lane without destroying anything, and but apply undoes it.

Is there any context that might help us understand?

Observed on but 0.22.3 with GitHub squash merges. Three cases from the same repository:

  • In one case, but pull --check reported [integrated] and but pull removed the branch cleanly. The skill's instruction worked.
  • In another, run right after the merge, but status showed (merged upstream) and but pull --check showed [ok]. The branch's forge_reviews row in but.sqlite had an empty merged_at, an empty integration_commit_shas, and a last_sync_at older than the merge. Pulling anyway stranded the commits as described above. git diff --quiet origin/main confirmed that their content was already on the target.
  • In a third, the review row was fully synced: merged_at was set, integration_commit_shas held the squash commit, and virtual_branches.toml carried the pr_number. but pull --check still reported [ok], and but pull rebased the branch rather than removing it. I don't know the cause. The one difference I noticed is that the workspace held an uncommitted edit to a file those commits touched. I have not run a controlled repeat to test it.

So (merged upstream) and [integrated] can disagree. I can't tell from outside how but status reaches its answer. [integrated] was the reliable signal in every case, although in the third case neither was sufficient.

Related: #15127 describes the engine side, where merged commits stay applied as (no changes) and can come back {conflicted}. This issue is only about the skill's guidance, which leads agents into that state.

Does the docs page already exist? If so, please link to it.

https://github.com/gitbutlerapp/gitbutler/blob/master/crates/but/skill/SKILL.md

mattspruiell avatar Sep 24 '26 20:09 mattspruiell