fix(scm-github): avoid conflict misclassification for draft/blocking states
Summary
- compute
noConflictsfrom explicitmergeable === CONFLICTINGonly - prevent blocked/draft/unknown GitHub merge states from being interpreted as merge conflicts
- add regression assertions for
BLOCKEDandUNKNOWNmergeability outcomes
Root cause
getMergeability() set noConflicts to true only for MERGEABLE. For draft or branch-protection-blocked PRs, GitHub can return non-MERGEABLE values without actual conflicts, which caused conflict-based reactions to trigger via !noConflicts.
What changed
- updated conflict derivation to treat only
CONFLICTINGas a conflict signal - updated tests to assert non-conflicting behavior for
BLOCKED/UNKNOWNstates
Why this approach
It matches GitHub semantics more closely and keeps conflict reactions tied to explicit conflict data, while preserving existing blockers for review/branch-protection/draft conditions.
Testing
pnpm --filter @aoagents/ao-plugin-scm-github test -- test/index.test.tspnpm --filter @aoagents/ao-core test -- src/__tests__/lifecycle-manager.test.ts --testNamePattern "merge conflict"
Closes #1314.
Review
Overview
Two-line behavior fix in getMergeability() (packages/plugins/scm-github/src/index.ts:1000): noConflicts flips from "true only when mergeable === MERGEABLE" to "true unless mergeable === CONFLICTING". This stops the lifecycle conflict reaction (lifecycle-manager.ts:1117) from firing on draft / BLOCKED / UNKNOWN PRs that have no real conflict. Closes #1314.
Correctness — looks right
- Aligns with the batch path.
graphql-batch.ts:791already computeshasConflicts = mergeable === "CONFLICTING". Before this PR, the individual-call fallback inlifecycle-manager.ts:1113-1120used stricter semantics than the batch, so behavior flipped depending on whether batch enrichment was cached. The two paths now agree — a real latent correctness win beyond the visible bug. - Downstream consumers are safe.
SessionCard.tsx:759,SessionDetail.tsx:689,web/src/lib/types.ts:188,249only readnoConflictsto gate conflict UI / attention-level. Broadening it totruefor BLOCKED/UNKNOWN won't falsely mark a PR as mergeable, becausemergeable = blockers.length === 0still includes the "Merge status unknown" / "Merge is blocked" / "PR is still a draft" blockers. - Empty-string branch.
(data.mergeable ?? "").toUpperCase()→""now yieldsnoConflicts = true, consistent with UNKNOWN handling.
Test coverage — one gap
- Good: renamed UNKNOWN test and the new
noConflicts === trueassertion on theREVIEW_REQUIRED + BLOCKEDcase. - Missing the literal #1314 repro: a draft PR (
isDraft: true) withmergeStateStatus: "BLOCKED"andmergeable: "MERGEABLE"(orUNKNOWN) assertingnoConflicts === true. The existingreports draft status as blockertest (line 1226) doesn't assert onnoConflicts. One line there (or a dedicated test) would cement the regression guard. - The PR description advertises a
BLOCKEDregression test, but what's added is really theREVIEW_REQUIREDcase that happens to have a BLOCKED merge state.
Style / minor
- A one-line comment on the
noConflictsline explaining why the negation form was chosen (matchesgraphql-batch.tssemantics; avoids false-positive conflict reactions on draft/BLOCKED) would help the next reader. Optional. - The semantic of
noConflictsdrifted from "known clean" to "not explicitly conflicting." Not worth renaming — just noting.
Risks
- Low. The only way this regresses is if a caller treats
noConflicts === trueas "safe to merge" without also checkingmergeable/blockers. None of the current callers do. - The behavioral flip on
UNKNOWNis intentional and correct: old code could spam rebase-and-resolve prompts while GitHub was still computing; new code waits for an explicitCONFLICTINGsignal.mergeable: falsestill holds via the "Merge status unknown" blocker.
Verdict
Approve with a small request: add one draft-PR regression test (isDraft: true, mergeable: "MERGEABLE", mergeStateStatus: "BLOCKED" → noConflicts: true) matching the exact #1314 scenario. Everything else is clean.
@harsh-batheja, I have fixed the issues; please review
Greptile Summary
This PR fixes a bug where GitHub's BLOCKED, UNKNOWN, or empty mergeable states were incorrectly interpreted as merge conflicts by lifecycle conflict reactions, because noConflicts was derived positively (=== "MERGEABLE") rather than negatively (!== "CONFLICTING").
index.ts: One-line change frommergeable === "MERGEABLE"tomergeable !== "CONFLICTING", so only explicit conflict data setsnoConflicts = false; all other states (UNKNOWN, empty, BLOCKED) no longer masquerade as conflicts.index.test.ts: Flips the UNKNOWN assertion fromfalsetotrue, renames the corresponding test, addsnoConflictscoverage to the review-required case, and adds a dedicated regression test for draft + UNKNOWN + BLOCKED that demonstrates the pre-fix failure scenario.
Confidence Score: 5/5
Safe to merge — the change is a minimal, targeted one-line fix with correct semantics and full test coverage for the regression scenario.
The fix correctly narrows the conflict signal to CONFLICTING only, preserving all other blockers through the existing blockers array. The regression test (draft + UNKNOWN + BLOCKED) now exercises exactly the scenario described in the bug report and would have failed against the old code. No other logic paths are touched.
No files require special attention.
Important Files Changed
| Filename | Overview |
|---|---|
| packages/plugins/scm-github/src/index.ts | Single-line logic fix: noConflicts now derives from mergeable !== "CONFLICTING" instead of mergeable === "MERGEABLE", correctly isolating conflict detection from draft/BLOCKED/UNKNOWN GitHub states. |
| packages/plugins/scm-github/test/index.test.ts | Test updates flip the UNKNOWN assertion from false→true, rename the test to reflect new semantics, add a noConflicts assertion to the review-required case, and add a proper regression test for draft+UNKNOWN+BLOCKED that would have failed under old logic. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[getMergeability called] --> B[Fetch PR data from GitHub]
B --> C{mergeable value}
C -->|CONFLICTING| D["blockers: 'Merge conflicts'\nnoConflicts = false"]
C -->|UNKNOWN or empty| E["blockers: 'Merge status unknown'\nnoConflicts = true ✅"]
C -->|MERGEABLE| F[noConflicts = true]
D --> G{mergeStateStatus}
E --> G
F --> G
G -->|BLOCKED| H["blockers: 'Merge is blocked by branch protection'"]
G -->|BEHIND| I["blockers: 'Branch is behind base branch'"]
G -->|UNSTABLE| J["blockers: 'Required checks are failing'"]
G -->|other| K[no additional blocker]
H --> L{isDraft?}
I --> L
J --> L
K --> L
L -->|true| M["blockers: 'PR is still a draft'"]
L -->|false| N[return result]
M --> N
N --> O{blockers.length === 0?}
O -->|yes| P[mergeable: true]
O -->|no| Q[mergeable: false]
style E fill:#d4edda,stroke:#28a745
style D fill:#f8d7da,stroke:#dc3545
Reviews (2): Last reviewed commit: "test(scm-github): cover unknown draft me..." | Re-trigger Greptile
Closing as part of a backlog sweep: Agent Orchestrator was rewritten from the ground up (Go backend + Electron/React frontend), and this PR's changes target files from the pre-rewrite TypeScript codebase that no longer exist in the current tree, so it cannot be rebased onto main. If the underlying change still makes sense for the current app, please open a fresh PR against the new codebase. Thanks for the contribution!