Repository navigation
Description
Bug
windowActive in bin/opencode-route-proxy.mjs (lines 406–431) checks daysOfWeek against the current calendar day before it ever looks at the time range, so an overnight window (end ≤ start, e.g. Fri 22:00 → Sat 02:00) attributes its after-midnight leg to the wrong day:
- The day filter runs first (lines 425–428): the weekday of
nowmust be indaysOfWeek. - Only then does the wrap branch run (line 431):
mins >= start || mins < end.
For a window { daysOfWeek: ["fri"], start: "22:00", end: "02:00", timezone: "UTC" }:
- Sat 01:00 is reported inactive, although it is inside the window that opened Fri 22:00 — the gate drops the target for the last two hours of its own window.
- Fri 01:00 is reported active, although that after-midnight leg belongs to a window that would have opened Thu 22:00, and Thursday is not in
daysOfWeek— the gate admits the target on a day the operator never listed.
Inverted gates (window: { name, invert: true }, targetEligible lines 433–437) inherit both errors flipped.
Evidence (verified this run)
Probe on the laptop (~/git/fleet/probe-2026-11-01-laneB-windowwrap/): parseHHMM + windowActive extracted verbatim (lines 398–432) from bin/opencode-route-proxy.mjs at main 064ce9e5 (file sha256 prefix 6269e7bf933138a0), driven with the Fri 22:00→02:00 UTC window above:
- FAIL Sat 01:00 — got
false, wanttrue(after-midnight leg of the Friday window) - FAIL Fri 01:00 — got
true, wantfalse(after-midnight leg belongs to Thursday) - PASS Thu 23:00
false, Fri 21:59false, Fri 23:00true, Sat 02:00false, Sat 23:00false - Controls pass: the existing non-wrapping fixture shape (Fri 01:00–04:00) gives Fri 02:30
true, Sat 02:30false.
The existing tests (bin/opencode-route-proxy.test.mjs, window-gate tests from #3225) only exercise a non-wrapping window (peak, Mon–Fri 01:00–04:00), so the wrap/day interaction is untested. Related: #3225 (window gates), #3256 (provider routes in the same file).
Why it matters
Window gates exist to route traffic to specific providers at specific times (peak/off-peak pools). An overnight window silently loses its last hours and gains hours on an unlisted day — the route sends traffic to the wrong pool with no error anywhere; the only symptom is cost/quota behaviour nobody can explain from the config.
Acceptance criteria
- For a wrapping window (end ≤ start): the evening leg (
mins >= start) is active iff the current day is indaysOfWeek; the after-midnight leg (mins < end) is active iff the previous day is indaysOfWeek. With nodaysOfWeek(or an empty list), both legs stay governed by the time range alone, as today. - Non-wrapping windows behave exactly as today; unknown windows still fail closed; inverted gates invert the corrected result.
- New tests in
bin/opencode-route-proxy.test.mjscover at least: Fri-only 22:00–02:00 window active at Sat 01:00, inactive at Fri 01:00, active Fri 23:00, inactive Sat 23:00 — plus the existing window-gate tests still passing.
Activity
dezren39 commentedon Nov 1, 2026
🤖 Agent note · filed
windowActive(bin/opencode-route-proxy.mjs:406-431) checks daysOfWeek against the calendar day ofnow, so a wrapping window's after-midnight leg follows the wrong day. Verified by a verbatim-extract probe on the laptop (~/git/fleet/probe-2026-11-01-laneB-windowwrap/, lines 398-432 @064ce9e5, sha256 prefix 6269e7bf933138a0): Sat 01:00 got false want true, Fri 01:00 got true want false for a Fri-only 22:00-02:00 UTC window; controls pass.dezren39 commentedon Nov 1, 2026
🤖 Agent note · picked up
Merge pull request #3876 from developing-today/creator-b/3874-windoww…
dezren39 commentedon Nov 1, 2026
🤖 Agent note · done