Mission controlweb-69465de5-6600-42b8-96ec-8fb49fe24c72
Proof bundle

PATCH VERIFICATION MISSION

average calculation returns incorrect results

Bug description

The average utility returns incorrect results for non-empty arrays. It should return the arithmetic mean of the provided numbers while preserving the existing behavior of returning 0 for an empty array.

Reproduction

Run:

npm test
Execution status
COMPLETED
Base commit
9be58de11c552b8011426896393210014956ee04
Changed files
1file
Investigation
5iterations
MISSION RECORDREASONING / EVIDENCE / VERDICT

Flight Recorder

15 events / UTC
  1. BASELINERunning reproduction test before patch
  2. BASELINEReported bug reproduced
  3. INVESTIGATINGAI investigation started
  4. INVESTIGATINGAI investigation completed
  5. PATCHINGAI patch phase started
  6. PATCHINGCandidate patch applied
  7. PATCHINGGit captured 1 changed file(s)
  8. PATCHINGGit diff captured
  9. PATCHINGVerification integrity preserved
  10. VERIFYINGRunning reproduction test after patch
  11. VERIFYINGReproduction test passes after patch
  12. VERIFYINGRunning full test suite
  13. VERIFYINGFull test suite passes
  14. VERDICTCalculating deterministic verdict
  15. COMPLETEDMission completed with verdict VERIFIED

Proof Chain

RECORDED CHECKS
Evidence requirements6 passed
  1. Configured failure reproducedPassed · Baseline · exit 1
    01
  2. Candidate patch appliedPassed · 1 file changed
    02
  3. Git diff capturedPassed · Against 9be58de
    03
  4. Integrity checksPassed · No recognized integrity concerns detected
    04
  5. Reproduction passes after patchPassed · Configured reproduction · exit 0
    05
  6. Repository test script passesPassed · Repository tests · exit 0
    06
REPAIR VERDICTVERIFIED
RECORDED VERDICT

Repair verdicts apply to the recorded requirements and execution.
Integrity checks detect recognized risks; they do not guarantee correctness.

Git evidence

Candidate patch

The candidate change captured from the sandbox working tree.

src/average.js
+1−2
diff --git a/src/average.js b/src/average.js
index 4e195e0..d6cf89e 100644
--- a/src/average.js
+++ b/src/average.js
@@ -5,6 +5,5 @@ export function average(numbers) {
55
66 const sum = numbers.reduce((total, number) => total + number, 0);
77
8− // BUG
9− return sum + numbers.length;
8+ return sum / numbers.length;
109 }

AI investigation report

AI REASONING

PROPOSED DIAGNOSIS

Investigation Report

Investigated src/average.js. The implementation incorrectly computes sum + numbers.length instead of sum / numbers.length, which causes all three non-empty-array tests to fail. The empty array case correctly returns 0. The fix requires changing the arithmetic operator in the return statement from addition to division.

Patch target
src/average.js
Test file
src/average.test.js
Reproduction command
npm test
Execution evidence

Verification evidence

Recorded command results. Expand a run to inspect its output.

Baseline reproduction

npm test
1.12sexit 1FAILURE REPRODUCED

stdout


> patchverdict-simple-bug@1.0.0 test
> vitest run


 RUN  v3.2.4 /tmp/patchverdict

 ❯ src/average.test.js (4 tests | 3 failed) 8ms
   × average > calculates the average of multiple numbers 6ms
     → expected 63 to be 20 // Object.is equality
   × average > calculates the average of one number 1ms
     → expected 101 to be 100 // Object.is equality
   ✓ average > returns zero for an empty array 0ms
   × average > supports negative numbers 1ms
     → expected 3 to be +0 // Object.is equality

 Test Files  1 failed (1)
      Tests  3 failed | 1 passed (4)
   Start at  10:08:56
   Duration  275ms (transform 57ms, setup 0ms, collect 25ms, tests 8ms, environment 0ms, prepare 102ms)

stderr


⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/average.test.js > average > calculates the average of multiple numbers
AssertionError: expected 63 to be 20 // Object.is equality

- Expected
+ Received

- 20
+ 63

 ❯ src/average.test.js:6:35
      4| describe("average", () => {
      5|   it("calculates the average of multiple numbers", () => {
      6|     expect(average([10, 20, 30])).toBe(20);
       |                                   ^
      7|   });
      8| 

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/3]⎯

 FAIL  src/average.test.js > average > calculates the average of one number
AssertionError: expected 101 to be 100 // Object.is equality

- Expected
+ Received

- 100
+ 101

 ❯ src/average.test.js:10:28
      8| 
      9|   it("calculates the average of one number", () => {
     10|     expect(average([100])).toBe(100);
       |                            ^
     11|   });
     12| 

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/3]⎯

 FAIL  src/average.test.js > average > supports negative numbers
AssertionError: expected 3 to be +0 // Object.is equality

- Expected
+ Received

- 0
+ 3

 ❯ src/average.test.js:18:35
     16| 
     17|   it("supports negative numbers", () => {
     18|     expect(average([-10, 0, 10])).toBe(0);
       |                                   ^
     19|   });
     20| });

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/3]⎯

Post-patch reproduction

npm test
1.08sexit 0PASS

stdout


> patchverdict-simple-bug@1.0.0 test
> vitest run


 RUN  v3.2.4 /tmp/patchverdict

 ✓ src/average.test.js (4 tests) 2ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  10:09:22
   Duration  253ms (transform 38ms, setup 0ms, collect 27ms, tests 2ms, environment 0ms, prepare 86ms)

stderr

(no output)

Repository test script

npm test
1.06sexit 0PASS

stdout


> patchverdict-simple-bug@1.0.0 test
> vitest run


 RUN  v3.2.4 /tmp/patchverdict

 ✓ src/average.test.js (4 tests) 2ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  10:09:23
   Duration  223ms (transform 31ms, setup 0ms, collect 26ms, tests 2ms, environment 0ms, prepare 81ms)

stderr

(no output)