clawsweeper icon indicating copy to clipboard operation
clawsweeper copied to clipboard

PR merge-risk review treats clean behind-branch diff as deleting main-only changes

Open stainlu opened this issue 6 months ago • 1 comments

Problem

On https://github.com/openclaw/openclaw/pull/83367, ClawSweeper reviewed head 79a255ba3343414054f6ab7a3d6ce93946f021df against main a7ab09fa4e79fdbaa6359d2b05e8038db810cf47 and labeled the PR:

  • rating: 🧂 unranked krab
  • status: 📣 needs proof
  • merge-risk: 🚨 compatibility
  • merge-risk: 🚨 session-state

The durable review said the PR was "based behind current main and would drop current-main Codex code-mode and mobile pairing metadata fixes" and cited files added by later main commits.

Why This Is Misleading

At the same time, GitHub reported the PR merge state as clean/mergeable. The scary labels were caused by comparing current main..head and interpreting main-only commits as deletions from the PR head. That is useful as a "branch is behind current main" signal, but it is not the same as the merge result. A clean GitHub merge/squash merge applies the PR changes onto the current base; it does not replace main with the PR head and delete unrelated main-only changes.

In this case the maintainer-facing labels made the PR look much riskier than the actual branch state. Rebasing the PR cleared the condition, but the review wording and labels were still misleading while the branch was only behind current main.

Suggested Fix

For stale/behind PRs, ClawSweeper should distinguish:

  • real merge-result regressions, computed from a merge tree / GitHub merge ref / equivalent three-way merge result
  • normal behind-main drift, where main..head shows main-only files but the PR is still cleanly mergeable

If the only issue is behind-main drift, prefer a softer status such as "needs rebase / review stale" rather than patch is incorrect, needs proof, or compatibility wording that says the PR would remove main-only changes.

Evidence

  • OpenClaw PR: https://github.com/openclaw/openclaw/pull/83367
  • ClawSweeper review comment: https://github.com/openclaw/openclaw/pull/83367#issuecomment-4473386499
  • ClawSweeper state record for the problematic review recorded:
    • pull_head_sha: 79a255ba3343414054f6ab7a3d6ce93946f021df
    • main_sha: a7ab09fa4e79fdbaa6359d2b05e8038db810cf47
    • merge_risk_labels: ["merge-risk: 🚨 compatibility", "merge-risk: 🚨 session-state"]
    • finding text: "Rebase without dropping Codex code-mode support" and "Preserve mobile OS metadata refresh on reconnect"

stainlu avatar May 18 '26 12:05 stainlu

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary Keep open: current main still lacks an explicit merge-result versus behind-branch drift guard for PR review, and the reported false merge-risk review is concrete enough to treat as a valid automation bug.

Reproducibility: yes. source-reproducible with medium confidence: the issue provides a concrete historical bad review, and current main still lacks merge-result context or explicit behind-branch safeguards in the review path. I did not replay the exact historical Codex review against the old OpenClaw head/main pair.

Next step This is a narrow review-automation repair candidate, but the worker should prefer deterministic context/tests over relying on reviewer wording alone.

Review details

Best possible solution:

Add deterministic PR review context and prompt/test coverage so clean behind branches are treated as stale or needing rebase, while merge-risk labels are reserved for real merge-result regressions.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible with medium confidence: the issue provides a concrete historical bad review, and current main still lacks merge-result context or explicit behind-branch safeguards in the review path. I did not replay the exact historical Codex review against the old OpenClaw head/main pair.

Is this the best way to solve the issue?

Yes, the requested direction is the right fix boundary: compare or expose the actual merge result before making deletion-style merge-risk findings. The most maintainable path is to add explicit merge-state context plus regression tests, not only softer wording after a bad review happens.

Label changes:

  • add P2: This is a valid ClawSweeper review automation bug with misleading maintainer-facing PR labels, but it has limited blast radius and no evidence of data loss or runtime outage.
  • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
  • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.

Label justifications:

  • P2: This is a valid ClawSweeper review automation bug with misleading maintainer-facing PR labels, but it has limited blast radius and no evidence of data loss or runtime outage.

Acceptance criteria:

  • pnpm run test:unit
  • pnpm run check

What I checked:

  • reported false merge-risk review: The issue body links https://github.com/openclaw/openclaw/pull/83367 and records that ClawSweeper reviewed head 79a255ba3343414054f6ab7a3d6ce93946f021df against main a7ab09fa4e79fdbaa6359d2b05e8038db810cf47, applied compatibility/session-state merge-risk labels, and cited main-only files as dropped.
  • PR context lacks merge-result detail: The compact PR context includes head/base SHAs and a mergeable boolean, but it does not pass through REST mergeable_state, GraphQL mergeStateStatus, a merge ref, or a merge-tree result that would distinguish clean behind-branch drift from actual merge-result deletion. (src/clawsweeper.ts:2438, 3f1affe587c6)
  • prompt lacks behind-branch guard: The PR merge-risk prompt says labels should reflect what could go wrong because the PR is merged, but current main has no explicit instruction to avoid raw main..head deletion findings for clean behind branches; searches found no merge-tree, behind-main, current-main-only, or main..head guard in the review prompt. (prompts/review-item.md:107, 3f1affe587c6)
  • review prompt assembly only injects compact context: buildReviewPrompt renders the static review prompt plus compact GitHub context JSON; there is no generated merge-result artifact supplied to the reviewer before Codex makes merge-risk findings. (src/clawsweeper.ts:4710, 3f1affe587c6)
  • history for affected review context: git blame attributes the compact PR context shape, including the current mergeable-only field, to commit 4d7c16693ef626ea51470a2821e60b568f24a61a. (src/clawsweeper.ts:2438, 4d7c16693ef6)
  • canonical search: Searches did not find an open or merged ClawSweeper PR already tied to this issue or the same current-main-only/behind-branch wording, so there is no obvious canonical fix item to defer to.

Likely related people:

  • Tak Hoffman: Blame attributes the compact PR context and baseline merge-risk prompt sections to 4d7c1669, and recent review-prompt changes for compatibility risk also came through 390e5211. (role: introduced review prompt and PR context behavior; confidence: high; commits: 4d7c16693ef6, 390e5211aa5a; files: src/clawsweeper.ts, prompts/review-item.md, test/clawsweeper.test.ts)

Remaining risk / open question:

  • A prompt-only repair could reduce misleading reviews but still leave stochastic reviewer behavior; deterministic merge-result context or explicit merge-state data would make the fix stronger.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 3f1affe587c6.

clawsweeper[bot] avatar May 21 '26 16:05 clawsweeper[bot]