Skip to content

opencode-route-proxy: window times are never range-checked — parseHHMM accepts 24:60 and 99:99, so a typo'd window silently becomes always-on, always-off, or end-less #4259

Closed

Description

@dezren39

Summary

bin/opencode-route-proxy.mjs's window-time parser accepts out-of-range times and silently reinterprets them: parseHHMM (bin/opencode-route-proxy.mjs:398-401) only checks the shape ^([0-9]{1,2}):([0-9]{2})$ and returns hour * 60 + minute with no range check, so 24:60 parses to 1500 and 99:99 to 6039. Nothing else validates the windows either — normalizeWindowGate (:372-377) only extracts the gate name/invert flag, and the window definitions come straight from config (model_route_windows, :175).

Verified behavior (this run)

Probe on the laptop (~/git/fleet/probe-2026-11-02-laneB-routewindow/) extracted parseHHMM + windowActive verbatim from the real file @ 6cdfaee (md5 c7ad071278474a5b4bfe0a181714cc0e) and ran them:

  • parseHHMM('09:30') = 570 (control, correct); parseHHMM('24:60') = 1500; parseHHMM('99:99') = 6039 — all accepted.
  • Window 99:99–99:98 (a wrapping window) is active at Mon 12:00 UTC: the wrap branch (mins < end, :443-447) is true for every real wall minute (max 1439 < 6038), so a nonsense window is effectively always-on — and with invert: true on the gate, always-off.
  • Window 25:00–26:00 is never active (no wall minute reaches 1500 in the non-wrapping branch) — a typo'd window silently kills the route target, or, inverted, makes it permanently eligible.
  • Window 09:00–24:60 behaves as if it had no end (active at 23:30), silently extending a curfew-style gate past its intent.

Why it matters

Window gates decide which model routes are eligible at which times (quota windows, overnight routes). A single typo in a window definition does not fail at startup or log anything — it silently flips a gate to always-on, always-off, or end-less, which misroutes traffic in exactly the hours the window exists to control. The fleet already treats this shape as a bug in the sibling surface: aggregator mergeQuiet accepting 99:99/24:60 is filed as #3686. This is the same class in the route proxy, which has never had the range check.

Acceptance criteria

  • parseHHMM (or window loading, one place) rejects hour > 23 and minute > 59 — a window with an out-of-range start or end is not silently reinterpreted.
  • The failure mode is visible: an invalid window definition is refused/logged by name at config load (consistent with how this proxy surfaces other config errors), rather than the gate quietly evaluating as always-on/always-off.
  • Regression tests in bin/opencode-route-proxy.test.mjs: 24:00, 24:60, 99:99, 25:00 as start and as end are rejected/refused; valid boundary windows 00:00, 23:59, and the route-proxy: overnight window gates check daysOfWeek against the wrong day — the after-midnight leg follows the calendar day, not the day the window opened #3874 wrapping-window cases still evaluate as before.
  • Existing route-proxy tests pass (node --test bin/opencode-route-proxy.test.mjs).

Dedup / related

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    on Nov 2, 2026
  2. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    agent: new-issue-creator-code-b
    state: filed
    issue: 4259

    Filed this run after verification on current main (6cdfaee). Found via: read of bin/opencode-route-proxy.mjs (parseHHMM :398-401 has shape-only validation; normalizeWindowGate :372-377 and the config load at :175 add no range check) plus a laptop probe (~/git/fleet/probe-2026-11-02-laneB-routewindow/, verbatim extraction from the real file, md5 c7ad071278474a5b4bfe0a181714cc0e): parseHHMM('24:60')=1500 and parseHHMM('99:99')=6039 are accepted; the wrapping window 99:99-99:98 evaluates active at Mon 12:00 UTC (always-on in practice), 25:00-26:00 never evaluates active, and 09:00-24:60 stays active at 23:30 (end-less).

    Dedup: #3686 is the aggregator mergeQuiet parser (different surface); #3874 fixed this function's wrap-day attribution, not ranges; #3225 introduced the gates. Labels: kind/bug, queue/queued, source/creator, task/triage, status/needs-triage, priority/normal, app/opencode-route-proxy, effort/s. A repo-task/v1 triage packet is enqueued to repo-health-code-pilot in the same run. Filed-only (not self-solved): the fix involves a config-load failure-mode choice that triage should settle.

  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 2, 2026
  4. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

    • Agent: queue worker (repo-worker-code), lane C shift
    • Session / ID: task 6132 (triage)
    • Found via: queue claim
    • Task: Confirm the missing parseHHMM range check on current main and route the fix.
    • Expectation: effort s; done = probe reproduced/refuted against current main, triage ruling posted here, and a fix task enqueued with the acceptance criteria from the packet.
    • Links: task 6132
  5. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (triage)

    • Agent: queue worker (repo-worker-code), lane C shift
    • Session / ID: task 6132 (triage) → follow-up task 6133 (small_fix)
    • Found via: queue claim
    • Task: Triage ruling — CONFIRMED on current main.
    • Expectation: Triage complete. Evidence, on main 06ea8c8328a0757fd1ab98378357a4048679c4f3 with parseHHMM/windowActive extracted verbatim from bin/opencode-route-proxy.mjs and probed on the laptop: parseHHMM("24:60")=1500, parseHHMM("99:99")=6039, parseHHMM("24:00")=1440 — all accepted; window 99:99-99:98 is active Mon 12:00 UTC (always-on wrap), 25:00-26:00 never active, 09:00-24:60 still active at 23:30 (end-less); control 09:00-17:00 correct. Ruling: fix at one place — range-check inside parseHHMM (return null for hour>23/minute>59; windowActive at :410-414 already fails closed on null) — plus a config-load validation pass over model_route_windows (:175) that names the offending window, so a typo is loud instead of silently evaluated. Regression tests per the acceptance list (24:00/24:60/99:99/25:00 refused as start and end; 00:00/23:59 and the route-proxy: overnight window gates check daysOfWeek against the wrong day — the after-midnight leg follows the calendar day, not the day the window opened #3874 wrap cases unchanged). Routed as task 6133.
    • Links: task 6132, task 6133
  6. added and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 2, 2026
  7. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    6133 progress: fix pushed on branch queue/6133-4259-proxy-window-times, PR #4410.

  8. added 2 commits that reference this issue on Nov 2, 2026
    594b7f6
    850916f
  9. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Conductor binding · manual dispatch wave (Drew-ordered queue unblock) 2026-11-02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/opencode-route-proxybin/opencode-route-proxy.mjs fleet proxyeffort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions