bench

tests · Bug Fix

Fix date range overlap bug

Can it fix a reported bug without breaking anything?

Post on X
v1authored Sep 6, 202640 turns · $5 budget · 20m timebox
gateshidden tests

Prompt

# Fix the reported date range bug

`ISSUE.md` in this directory describes a bug reported against this library, with a symptom,
a minimal repro, and the expected behavior. Read it, then fix the bug.

## Requirements

- Fix the root cause of the behavior described in `ISSUE.md`. Do not special-case the exact
  repro; fix the underlying logic so every equivalent input behaves correctly.
- Keep every existing test in `test/` passing.
- Add at least one new test that reproduces the reported bug and would fail against the old
  code, alongside the existing tests.

## Constraints

- Do not change the public API of `src/index.ts` (function names, parameter order, or
  return shapes) unless the bug cannot be fixed without it; if you do, update every caller
  in this fixture.
- Do not add a third-party date library; this project has none as a dependency and should
  keep it that way.

Work only within this fixture directory.

Fixture

11 paths under fixture/, copied into a fresh run dir for every attempt.

.gitignore
ISSUE.md
package.json
src/
src/dateRange.ts
src/index.ts
src/recurrence.ts
test/
test/dateRange.test.ts
test/recurrence.test.ts
tsconfig.json

ISSUE.md

# Back-to-back bookings don't combine, and times shift after the clock-change weekend

I'm using this library to manage a small equipment rental calendar. Customers can book
back-to-back days, and when two bookings are exactly adjacent (one ends the moment the next
one starts) I expect `mergeRanges` to show them as a single continuous booking. That works
most of the time, but I ran into a case where it doesn't.

## Repro

```ts
import { createRange, mergeRanges } from "./src";

const morning = createRange(
  new Date(2026, 2, 8, 9, 0, 0), // Mar 8, 2026, 09:00
  new Date(2026, 2, 8, 13, 0, 0), // Mar 8, 2026, 13:00
);
const afternoon = createRange(
  new Date(2026, 2, 8, 13, 0, 0), // Mar 8, 2026, 13:00 - exactly when `morning` ends
  new Date(2026, 2, 8, 17, 0, 0), // Mar 8, 2026, 17:00
);

console.log(mergeRanges([morning, afternoon]));
```

I expected a single range from 09:00 to 17:00. Instead I get the two ranges back
unchanged, as if they never touched at all.

## A related problem I noticed on the same day

While tracking this down I also generated a multi-day booking with `expandDailyRecurrence`
for the week of March 7-11, 2026 (the weekend the clocks changed here). The booking is
supposed to run 09:00-17:00 every day, but every day from March 8th onward shows up starting
at 10:00 instead of 09:00, and only lasts 7 hours instead of 8. Bookings for weeks before or
after that one don't have this problem, so it seems tied to that specific weekend.

## What I expected

- Two ranges that touch at exactly the same instant should merge into one continuous range.
- A recurring 09:00-17:00 booking should start at 09:00 and run 8 hours on every day it
  covers, no matter which week it falls in.

How it is scored

Gates, run in order

  1. installRuns `bun install` and must exit 0.
  2. existing-testsRuns `bun test test/` and must exit 0.

Objective layer

10 hidden test cases the agent never saw, run against its own code.

Results across releases

v2026.09-smoke · Sep 6, 2026

AgentObjectiveSubjectiveCombinedRun
grok · grok-4.6#1
claude · haiku · low
100.0 (100.0100.0, n=1)
100.0 (100.0100.0, n=1)
#1
codex · gpt-5.6-sol · low
100.0 (100.0100.0, n=1)
100.0 (100.0100.0, n=1)
#1