MutaFix run: sortedcontainers-001

ranker nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B · patcher nvidia/nemotron-3-super-120b-a12b · via Nebius Token Factory

fixedoutcome
8swall time
2model calls
$0.0005API cost
Benchmark ground truth (hidden from the agent)
src/sortedcontainers/sortedlist.py:317 · operator NEGCOND · function src/sortedcontainers/sortedlist.py::SortedList.__contains__
- if not (not _maxes):   (injected bug)+ if not _maxes:   (original)
retriever rank 1 of 20 · ranker position 1 · patched the right function yes · exact restore yes

Trace

reproduce
+1.98s
2 failing test(s) · 2 failed, 297 passed · 1.98s
failing tests and errors
tests/test_coverage_sortedlist.py::test_contains
tests/test_stress_sortedlist.py::test_stress
tests/test_coverage_sortedlist.py::test_contains
E   assert 0 in SortedList([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, ...980, 9981, 9982, 9983, 9984, 9985, 9986, 9987, 9988, 9989, 9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999])
tests/test_stress_sortedlist.py::test_stress
E   assert 0.3663326084320272 in SortedList([0.010499992612454268, 0.01136869279981445, 0.01177038701662747, 0.01177038701662747, 0.01271581094480112, ....9850577188087127, 0.9882832016928882, 0.9886336872382965, 0.9912626799153788, 0.9921660154449652, 0.9940917797710432])
trace
+2.48s
re-ran 2 test file(s) with the trace plugin: 2 failing and 57 passing tests, 32 library functions ran in a failing test · 0.47s
tests/test_coverage_sortedlist.py, tests/test_stress_sortedlist.py
retrieve
+2.48s
129 functions indexed, 62 reachable from tests/test_coverage_sortedlist.py::test_contains in the static call graph. Kept 20 candidates, ranked by spectrum score (Ochiai), call graph and BM25 break ties.
candidates in retriever order
  1. src/sortedcontainers/sortedlist.py::SortedList.__contains__ call depth 1 · Ochiai 1.00 (failing 2, passing 0)
  2. src/sortedcontainers/sortedlist.py::SortedList.__repr__ call depth 1 · Ochiai 0.63 (failing 2, passing 3)
  3. src/sortedcontainers/sortedlist.py::SortedList.__imul__ call depth 1 · Ochiai 0.50 (failing 1, passing 1)
  4. src/sortedcontainers/sortedlist.py::SortedList.__reversed__ call depth 1 · Ochiai 0.50 (failing 1, passing 1)
  5. src/sortedcontainers/sortedlist.py::SortedList.bisect_left call depth 2 · Ochiai 0.50 (failing 1, passing 1)
  6. src/sortedcontainers/sortedlist.py::SortedList.irange call depth - · Ochiai 0.50 (failing 1, passing 1)
  7. src/sortedcontainers/sortedlist.py::SortedList.count call depth - · Ochiai 0.50 (failing 1, passing 1)
  8. src/sortedcontainers/sortedlist.py::SortedList.islice call depth - · Ochiai 0.50 (failing 1, passing 1)
  9. src/sortedcontainers/sortedlist.py::SortedList.__delitem__ call depth 1 · Ochiai 0.41 (failing 1, passing 2)
  10. src/sortedcontainers/sortedlist.py::SortedList.__mul__ call depth 1 · Ochiai 0.41 (failing 1, passing 2)
  11. src/sortedcontainers/sortedlist.py::SortedList._islice call depth - · Ochiai 0.41 (failing 1, passing 2)
  12. src/sortedcontainers/sortedlist.py::SortedList.discard call depth - · Ochiai 0.41 (failing 1, passing 2)
  13. src/sortedcontainers/sortedlist.py::SortedList.__len__ call depth 1 · Ochiai 0.35 (failing 2, passing 14)
  14. src/sortedcontainers/sortedlist.py::SortedList.bisect_right call depth 3 · Ochiai 0.32 (failing 1, passing 4)
  15. src/sortedcontainers/sortedlist.py::SortedList.pop call depth - · Ochiai 0.32 (failing 1, passing 4)
  16. src/sortedcontainers/sortedlist.py::SortedList.__iter__ call depth 1 · Ochiai 0.30 (failing 2, passing 20)
  17. src/sortedcontainers/sortedlist.py::SortedList.remove call depth - · Ochiai 0.29 (failing 1, passing 5)
  18. src/sortedcontainers/sortedlist.py::SortedList._delete call depth 2 · Ochiai 0.27 (failing 1, passing 6)
  19. src/sortedcontainers/sortedlist.py::SortedList._loc call depth 3 · Ochiai 0.27 (failing 1, passing 6)
  20. src/sortedcontainers/sortedlist.py::SortedList.__getitem__ call depth 1 · Ochiai 0.24 (failing 1, passing 8)
rank
+2.48s
spectrum order kept (no model call)
  1. src/sortedcontainers/sortedlist.py::SortedList.__contains__
  2. src/sortedcontainers/sortedlist.py::SortedList.__repr__
  3. src/sortedcontainers/sortedlist.py::SortedList.__imul__
  4. src/sortedcontainers/sortedlist.py::SortedList.__reversed__
  5. src/sortedcontainers/sortedlist.py::SortedList.bisect_left
read
+3.99s
turn 1 · NVIDIA-Nemotron-3-Nano-30B-A3B · 3058 in / 127 out · 1.51s · $0.00021

read src/sortedcontainers/sortedlist.py::SortedList.__contains__

The failing test checks membership (`in`) of values in a SortedList, and the only candidate that directly implements `__contains__` is ranked highest for failing tests. The logic in `__contains__` uses `_maxes` to determine early exit, but the condition `not _maxes` is inverted—it should check `not _maxes` to return False only when `_maxes` is empty, but the current code returns False when `_maxes` is non-empty, causing incorrect containment checks.

patch
+8.37s
turn 2 · NVIDIA-Nemotron-3-Nano-30B-A3B · 3619 in / 136 out · 0.99s · $0.00025

The condition `if not (not _maxes)` is equivalent to `if _maxes`, which incorrectly returns False when the list is non-empty. It should simply check `if not _maxes` to return False when the list is empty. This bug causes the containment check to fail for all non-empty lists, as seen in the test where values like 0 are incorrectly reported as not present.

--- a/src/sortedcontainers/sortedlist.py+++ b/src/sortedcontainers/sortedlist.py@@ -315,5 +315,5 @@         _maxes = self._maxes -        if not (not _maxes):+        if not _maxes:             return False 

tests: all tests pass 299 passed

Final patch

--- a/src/sortedcontainers/sortedlist.py+++ b/src/sortedcontainers/sortedlist.py@@ -315,5 +315,5 @@         _maxes = self._maxes -        if not (not _maxes):+        if not _maxes:             return False