PATCH VERIFICATION MISSION
range includes the end boundary
Bug description
The range utility returns one extra value at the end of the generated sequence. It should include values from the start up to, but not including, the end boundary while preserving normal range behavior.
Reproduction
Run:
npm test- Execution status
- COMPLETED
- Base commit
e2fc49af003df0234fdeb126fcb5b84eae5a532b- Changed files
- 1file
- Investigation
- 6iterations
Flight Recorder
- BASELINE
- BASELINE
- INVESTIGATING
- INVESTIGATING
- PATCHING
- PATCHING
- PATCHING
- PATCHING
- PATCHING
- VERDICT
- COMPLETED
Proof Chain
- Configured failure reproducedPassed · Baseline · exit 101
- Candidate patch appliedPassed · 1 file changed02
- Git diff capturedPassed · Against e2fc49a03
- Integrity checksPassed · No recognized integrity concerns detected04
- Reproduction passes after patchPassed · Configured reproduction · exit 005
- Repository test script passesPassed · Repository tests · exit 006
Repair verdicts apply to the recorded requirements and execution.
Integrity checks detect recognized risks; they do not guarantee correctness.
Candidate patch
The candidate change captured from the sandbox working tree.
diff --git a/src/range.js b/src/range.js | |||
index 2eac330..e3ebcf2 100644 | |||
--- a/src/range.js | |||
+++ b/src/range.js | |||
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | export function range(start, end) { | |
| 2 | 2 | const values = []; | |
| 3 | 3 | | |
| 4 | − | for (let value = start; value <= end; value++) { | |
| 4 | + | for (let value = start; value < end; value++) { | |
| 5 | 5 | values.push(value); | |
| 6 | 6 | } |
AI investigation report
PROPOSED DIAGNOSIS
Investigation Report
Inspected src/range.js and src/range.test.js. The implementation uses value <= end in the loop condition, causing the end boundary to be included in the result. All three tests fail because the expected behavior is a half-open interval [start, end) where end is excluded. The root cause is clearly identified: the loop condition should use < instead of <=.
- Patch target
src/range.js- Test file
src/range.test.js- Reproduction command
npm test
Verification evidence
Recorded command results. Expand a run to inspect its output.
Baseline reproduction
npm test
Baseline reproduction
npm teststdout
> patchverdict-off-by-one@1.0.0 test
> vitest run
RUN v3.2.4 /tmp/patchverdict
❯ src/range.test.js (3 tests | 3 failed) 15ms
× range > includes the start and excludes the end 11ms
→ expected [ 1, 2, 3, 4 ] to deeply equal [ 1, 2, 3 ]
× range > returns an empty array when start equals end 2ms
→ expected [ 5 ] to deeply equal []
× range > supports negative values 1ms
→ expected [ -2, -1, +0, 1 ] to deeply equal [ -2, -1, +0 ]
Test Files 1 failed (1)
Tests 3 failed (3)
Start at 10:06:16
Duration 322ms (transform 52ms, setup 0ms, collect 36ms, tests 15ms, environment 0ms, prepare 119ms)
stderr
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯
FAIL src/range.test.js > range > includes the start and excludes the end
AssertionError: expected [ 1, 2, 3, 4 ] to deeply equal [ 1, 2, 3 ]
[32m- Expected[39m
[31m+ Received[39m
[2m [[22m
[2m 1,[22m
[2m 2,[22m
[2m 3,[22m
[31m+ 4,[39m
[2m ][22m
❯ src/range.test.js:6:25
4| describe("range", () => {
5| it("includes the start and excludes the end", () => {
6| expect(range(1, 4)).toEqual([1, 2, 3]);
| ^
7| });
8|
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/3]⎯
FAIL src/range.test.js > range > returns an empty array when start equals end
AssertionError: expected [ 5 ] to deeply equal []
[32m- Expected[39m
[31m+ Received[39m
[32m- [][39m
[31m+ [[39m
[31m+ 5,[39m
[31m+ ][39m
❯ src/range.test.js:10:25
8|
9| it("returns an empty array when start equals end", () => {
10| expect(range(5, 5)).toEqual([]);
| ^
11| });
12|
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/3]⎯
FAIL src/range.test.js > range > supports negative values
AssertionError: expected [ -2, -1, +0, 1 ] to deeply equal [ -2, -1, +0 ]
[32m- Expected[39m
[31m+ Received[39m
[2m [[22m
[2m -2,[22m
[2m -1,[22m
[2m 0,[22m
[31m+ 1,[39m
[2m ][22m
❯ src/range.test.js:14:26
12|
13| it("supports negative values", () => {
14| expect(range(-2, 1)).toEqual([-2, -1, 0]);
| ^
15| });
16| });
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/3]⎯
Post-patch reproduction
npm test
Post-patch reproduction
npm teststdout
> patchverdict-off-by-one@1.0.0 test
> vitest run
RUN v3.2.4 /tmp/patchverdict
✓ src/range.test.js (3 tests) 3ms
Test Files 1 passed (1)
Tests 3 passed (3)
Start at 10:06:45
Duration 323ms (transform 50ms, setup 0ms, collect 29ms, tests 3ms, environment 0ms, prepare 98ms)
stderr
(no output)Repository test script
npm test
Repository test script
npm teststdout
> patchverdict-off-by-one@1.0.0 test
> vitest run
RUN v3.2.4 /tmp/patchverdict
✓ src/range.test.js (3 tests) 3ms
Test Files 1 passed (1)
Tests 3 passed (3)
Start at 10:06:46
Duration 277ms (transform 45ms, setup 0ms, collect 27ms, tests 3ms, environment 0ms, prepare 100ms)
stderr
(no output)