Remediation Experience
Designing an agent that
developers actually merge

Rodolfo Biazi  ·  Product Designer, Sonar

This starts as a backlog issue

IssueReduce Cognitive Complexity in PricingService.priceFor()PricingService.java:42
java:S3776 Refactor this method to reduce its Cognitive Complexity from 19 to the 15 allowed.
Rule
Cognitive Complexity of methods should not be too high
Attribute
Adaptability · Focused
Quality
Maintainability · severity High
Effort
~10 min
Age
introduced 14 months ago, never touched since

This starts as a backlog issue, then the agent writes a correct fix

OpenReduce Cognitive Complexity in PricingService.priceFor()#3312
src/main/java/com/acme/pricing/PricingService.java
@@ -42,11 +42,9 @@ private BigDecimal priceFor(Order order) {
Customer customer = order.customer();
- if (customer != null) {
- if (customer.isActive()) {
- return calculate(order, customer);
- }
- }
- return ZERO;
+ if (customer == null || !customer.isActive()) {
+ return ZERO;
+ }
+ return calculate(order, customer);

This starts as a backlog issue, then the agent writes a correct fix, and the maintainer rejects it

ClosedReduce Cognitive Complexity in PricingService.priceFor()#3312
src/main/java/com/acme/pricing/PricingService.java
@@ -42,11 +42,9 @@ private BigDecimal priceFor(Order order) {
Customer customer = order.customer();
- if (customer != null) {
- if (customer.isActive()) {
- return calculate(order, customer);
- }
- }
- return ZERO;
+ if (customer == null || !customer.isActive()) {
+ return ZERO;
+ }
+ return calculate(order, customer);

“Sorry, not merging this. It’s correct, I’m just not touching the pricing path for now. I’d have to re-read every branch to be sure and it’s not worth the afternoon.”

This starts as a backlog issue, then the agent writes a correct fix, and the maintainer rejects it

ClosedReduce Cognitive Complexity in PricingService.priceFor()#3312
src/main/java/com/acme/pricing/PricingService.java
@@ -42,11 +42,9 @@ private BigDecimal priceFor(Order order) {
Customer customer = order.customer();
- if (customer != null) {
- if (customer.isActive()) {
- return calculate(order, customer);
- }
- }
- return ZERO;
+ if (customer == null || !customer.isActive()) {
+ return ZERO;
+ }
+ return calculate(order, customer);

“Sorry, not merging this. It’s correct, I’m just not touching the pricing path for now. I’d have to re-read every branch to be sure and it’s not worth the afternoon.”

Oracle says
  • Issue resolvedjava:S3776 gone
  • Buildpassed · 4m 12s
  • Tests1,284 passed · 0 failed
  • CI/CD pipeline7 of 7 green
  • Blast radius1 file · 1 method
Benchmark says
  • Counted as a successpass@1
  • Behaviour preservedno regression
  • Applies cleanlyno conflicts
The repository says
  • Closedpatch rejected

Nothing changed. No value was delivered.

Fixing an issue needs a solution. Shipping it needs a pre- and post-patch approach.

BEFORE A PATCH EXISTS AFTER A PATCH EXISTS AutoCodeRoverlocalize ยท generate ยท validateAUTOMATED PROGRAM REPAIRDeveloper triggers a fixmanualDeveloper triggers a fixmanualBacklog SchedulerscheduledBacklog SchedulerscheduledWhich issuesare worth fixing?prioritizationWhich issuesare worth fixing?prioritizationHow is itpackaged?batchingHow is itpackaged?batchingHow is itexplained?rationale ยท evidenceHow is itexplained?rationale ยท evidenceWho reviewsand merges it?routing ยท trustWho reviewsand merges it?routing ยท trust

Remediation experience is the end-to-end workflow, from selecting an issue to reviewing and merging the patch.

REMEDIATION EXPERIENCE AutoCodeRoverlocalize ยท generate ยท validateAUTOMATED PROGRAM REPAIRDeveloper triggers a fixmanualBacklog SchedulerscheduledWhich issuesare worth fixing?prioritizationHow is itpackaged?batchingHow is itexplained?rationale ยท evidenceWho reviewsand merges it?routing ยท trust

Where the remediation breaks and how we improve it

0+projects0+pull requests opened0+issues fixed
AutoCodeRoverlocalize ยท generate ยท validateAUTOMATED PROGRAM REPAIRDeveloper triggers a fixmanualBacklog SchedulerscheduledWhich issuesare worth fixing?prioritizationHow is itpackaged?batchingHow is itexplained?rationale ยท evidenceWho reviewsand merges it?routing ยท trust 01Adapting to the developer’s workflow 02Discoverability 03Reviewability 05Mergeability 04Evolvability

CHALLENGE 01

Adapting to the developer’s workflow

workflow

Developers declare intent, one issue at a time, until the backlog outgrows them.

Issues · acme-shop5 of 12
Review this hard-coded credentialjava:S2068 · AuthConfig.javaAssign to agentAssigned ✓
Refactor this method to reduce its Cognitive Complexity from 22 to 15java:S3776 · PricingService.javaAssign to agentAssigned ✓
Replace this use of System.out by a loggerjava:S106 · ReportJob.javaAssign to agentAssigned ✓
Remove this unused private fieldjava:S1068 · LegacyMode.javaAssign to agentAssigned ✓
Make this anonymous inner class a lambdajava:S1604 · EventBus.javaAssign to agentAssigned ✓
OPEN ISSUES12
OpenReduce Cognitive Complexity in PricingService.priceFor()
Opened by

remediation-agent · on request of @you

Changes

+4 −7 · 1 file

The scheduler flips the direction: from pull to push

BACKLOG 1,846 open issues · · · Backlog Scheduler every Tue · Thu PULLdeveloper → agent PUSHagent → developer MONTUEOPENPR · k fixesneeds reviewWEDTHUOPENPR · k fixesneeds reviewFRI ? Which issues should go in?

Severity alone does not tell us which issues developers care about

BLOCKERCRITICALMAJORMINORINFOBugVulnerabilityCode SmellSecurity Hotspot infinite loopunclosed streamalways-true conditionself-assignmentSQL injectionhard-coded secretweak cipherverbose error pagegod classcognitive complexity 22duplicated blockunused importTODO commentpermissive CORSweak hashingdebug flag enabled always-true conditioncognitive complexity 22? verbose error pagepermissive CORS?

Developer time is scarce, so the rule is only one signal

Recency

How recent is it?

nobody remembers fresh context 14 mo agotoday
Scope

Does it belong with the others?

acme/ ├ pricing/ │ ├ PricingService.java │ └ DiscountRules.java └ billing/   └ InvoiceExporter.java 1 PR
Location

Where does it live?

business logic tests configuration generated

Smart prioritization beat random selection by +8.4 pp

Random selection SECRET SAUCE +8.4 pp Smart Prioritization 0
+0.0pp
merge rate, smart prioritization vs. random
+0.0%
relative improvement
χ² = 4.21 · p = 0.040

CHALLENGE 02

Discoverability

A pull request nobody opens is indistinguishable, from the repository’s point of view, from a patch that was never generated.

reviewer

Assigning a reviewer gives every PR an accountable owner with context

Without a reviewer
OpenFix 5 issues in pricing/
ReviewersNo reviews requested
whoever happens to scroll past
With a reviewer
OpenFix 5 issues in pricing/
Reviewers@rodolfo review requested
1Accountable: the PR is someone’s job.
2Has context: knows this code, fresh in memory.

Picking the reviewer requires recency × ownership ×
secret sauce

SECRET SAUCE · TWO INGREDIENTS ON THE HOUSE 060120180 days since they last touched these files 100500 changed lines they own
Recencywhen they last touched these files
Ownershiphow much of the changed code they wrote
@rodolfotouched pricing/ 5 days ago.owns 94% of the changed lines.
review requested

Assigning a reviewer increased merge rate by +17.0 pp

no reviewerreviewer assigned 0% 20% 40% 60% 80% 100% PRs with interaction 57.6% 73.7%+16.1 pp Merge rate 61.1% 78.1%+17.0 pp

No reviewer: a random developer with no context sees it, maybe.

Assigned: someone has to make a decision.

CHALLENGE 03

Reviewability

The agent read the code to write the fix.
The reviewer should not have to read it all again to trust it.

batching · description

Up to five issues per PR balances noise against review cost

1 5 50 issues per pull request → spams the repo#3471#3470#3469#3468#3467#3466#3465#3464#3463#3462 never gets reviewed OPEN Fix 50 issues 31 files · +2,341 −1,877 hard to reviewone bad fix blocks the restconflicts, goes stale fast ≤ 5 issues per PRTHE BALANCE WE FOUND OPEN Fix 5 issues pricing/ · 3 files +38 −52 one sitting to review

The reviewer brings context. The PR has to bring the rest.

The right reviewerknows this code, touched it recently
+
The PR description
  • why these issues, together
  • what each issue is
  • how the changes interact
  • each issue and its fix, explained
=
A review in one sitting
context the reviewer needs
in their head
on the page
enough

The description carries the context the reviewer lacksExplaining each hunk lets reviewers verify one piece at a time

Remove unnecessary SQLException declaration and unused import from Order #263
Opensonarqube[bot]rodolfo review requested
This PR was automatically created by the Remediation Agent.

Removed SQLException from the throws clause of processOrders, since it can never be thrown there, plus the now-unused import.

PR #263 › Fixed issues
▶java:S1130Remove the thrown exception ‘SQLException’MINOR
LocationOrderService.java:8
Why is this an issue?Superfluous exceptions in throws clauses hurt readability and maintainability.
What changedRemoves the now-unused import. SQLException already left the throws clause and the catch block in other hunks, so nothing needs it anymore.
@@ -4,1 +3,0 @@ import java.io.IOException;
-import java.sql.SQLException;

SonarQube Remediation Agent uses AI. Check for mistakes.

  1. 1
    Titlenatural, in the repo’s own conventions
  2. 2
    Reviewera named person with context
  3. 3
    Disclosuremade by an agent, so check it
  4. 4
    Summarywhat changed and why, in plain words
  5. 5
    Fixed issueswhat each issue is, how severe
  1. 1
    Locationstraight to the line
  2. 2
    Why is this an issue?the rule’s rationale, no lookup
  3. 3
    What changedeach change, and how it ties to the others
  4. 4
    The hunkthe diff, one explained piece at a time

CHALLENGE 04

Evolvability

A fix is not a one-off. Every merge, rejection and comment is a signal the next fix should learn from.

the loop back

Developers meet a stream of fixes, and every reaction is a signal

THE USUAL VIEW issue agent patch one isolated unit WHAT ACTUALLY HAPPENS AgentPR #301PR #308PR #315PR #322PR #329Developer their feedback should teach the next fix

We turned rejected PRs into hints for the agent

REJECTED PRS, PER RULE, ACROSS SONAR CLOSEDjava:S109“keep 8 * 1024, it reads as bytes”CLOSEDjava:S109“one big literal hides the units”CLOSEDjava:S109“split it into named factors” MANUALINFERENCE HINT · java:S109 · magic numbers Keep composed constants readable: name each factor instead of one opaque literal. Agent AT GENERATION TIME

The hint steers the search toward the patch developers prefer

ALL POSSIBLEPATCHES CORRECT PATCHES Dev ADev BDev C CORRECTcompilestests passissue gone PREFERREDstylereadabilitydomain knowledge hint

Many fixes are correct, and the hint picks the one developers want

BEFORE · java:S109 magic number
long bufferBytes = blocks * 8 * 1024;
FIX A · ONE CONSTANT
private static final int BUFFER_SIZE = 8192;

long bufferBytes = blocks * BUFFER_SIZE;
resolves the issue
?8192 of what?
HINT · keep composed constantsFIX B · COMPOSED CONSTANTS
private static final int BLOCK_KB = 8;
private static final int BYTES_PER_KB = 1024;
long bufferBytes = blocks * BLOCK_KB * BYTES_PER_KB;
resolves the issue
reads the way the team thinks

Hints raised merge rate by 22% on the rules they covered

+22%merge rate
Whererules that had hints
Whenacross all runs
Howa customized experience at patch generation

The same loop can tune every layer of the experience

Patch generationWIPPR titleSOONPR descriptionSOONBranch namingSOONEvidence in the descriptionSOONPrioritizationSOON DeveloperExperience

CHALLENGE 05

Mergeability

Correctness is the property we can compute.
Mergeability is the property that provides value.

review & merge

Correctness is a property of the patch.

Mergeability is a property of the patch, the codebase, and the person.

Benchmarks report the first bar, value only arrives at the last

Correct patch generated100%← the only bar we publishPull request createdOpened by a human← discoverabilityActually reviewed← reviewabilityMerged← the only bar that provides value

Correct patches get closed for reasons no oracle can see

Not worth fixing.

The finding is real, but the team decided it doesn’t matter here.

01 workflow
This code is going away.

Being deleted or rewritten. Correct about a file with no future.

01 workflow
Wrong person.

It landed on someone with no authority over that module.

02 discoverability
No time to be sure.

Review cost exceeded the perceived benefit.

03 reviewability
Not how we’d write it.

Correct, and foreign to the codebase’s conventions.

04 evolvability
Too late.

It sat long enough to conflict. Mergeability decays, correctness doesn’t.

05 mergeability
Not one of these is a defect in the patch. Every one is a defect in the remediation experience, and every one is scored as a success by a correctness oracle.

Benchmarks never penalize a wrong guess, production always does

WHAT BENCHMARKS REWARD
No pull request0
Wrong pull request0
Attempt everything — a miss costs nothing.
vs
WHAT PRODUCTION CHARGES
No pull request0
Wrong pull request−1 review cycle
the next 20 PRs open with less patience
A bad PR is worse than no PR.
Trust is shared across every PR created.

So the question stops being “can we fix this issue?”
and becomes “should we spend a developer’s attention on this issue?”

They were not rejecting AI.

They were rejecting anything they could not reason about.

Activation moved from automatic to a deliberate choice

65%merged, up from 1%
Beforeit ran on its own, and 1% of what it produced was merged
Aftersomeone switches it on and sets the scope themselves
Modelnever touched. Same agent, same patches

A patch delivers no value until a person merges it.

So, the experience of getting it merged is not around the problem. It is the problem.

Speaker notes
← →O overviewF fullH hide this