All MicroEvals
t3-review-01-repair-priority-fix-review
Create MicroEval
Header image for t3-review-01-repair-priority-fix-review

t3-review-01-repair-priority-fix-review

T3

Prompt

You are reviewing a proposed code fix before it merges. A teammate reported that FleetDispatcher.SelectNextDroneForRepair was picking the wrong drone: it compared absolute Energy instead of energy percentage (Energy / MaxEnergy), so a large, mostly-full drone could be prioritized over a small, nearly-drained one. A teammate has opened a diff proposing a fix and asked for review before merge. Original (buggy) code public static Drone SelectNextDroneForRepair(IReadOnlyList<Drone> drones) { if (drones.Count == 0) { throw new ArgumentException("Fleet has no drones to select from.", nameof(drones)); } var mostUrgent = drones[0]; foreach (var drone in drones) { if (drone.Energy < mostUrgent.Energy) { mostUrgent = drone; } } return mostUrgent; } Proposed fix public static Drone SelectNextDroneForRepair(IReadOnlyList<Drone> drones) { if (drones.Count == 0) { throw new ArgumentException("Fleet has no drones to select from.", nameof(drones)); } var mostUrgent = drones[0]; var mostUrgentPercentage = mostUrgent.Energy / mostUrgent.MaxEnergy; foreach (var drone in drones) { var percentage = drone.Energy / drone.MaxEnergy; if (percentage < mostUrgentPercentage) { mostUrgent = drone; mostUrgentPercentage = percentage; } } return mostUrgent; } Drone.MaxEnergy is a plain double property with no validation elsewhere in the codebase - nothing currently prevents a Drone from being constructed with MaxEnergy = 0 (e.g. a drone that hasn't finished provisioning yet, or a data error from the fleet-import pipeline). Your task Review the proposed fix. Does it correctly solve the reported problem (percentage vs. absolute comparison)? Are there any remaining bugs, regressions, or edge cases it does not handle? Be specific - name the exact input that triggers any problem you find and describe the resulting behavior.