Skip to content

test(core): route-tuning note 'reset at ...Z' parsed in local time — normalization test fails outside UTC #29

Closed

Description

@dezren39

Problem

packages/core/test/config/normalization.test.ts → "notes survive normalization and reach the tuner as match and text" fails on unmodified main when the process timezone is not UTC.

Reproduced 2026-10-17 (Bun 1.4.2):

  • TZ=America/Chicago bun run script/test.ts test/config/normalization.test.ts → 42 pass, 1 fail
  • TZ=UTC bun run script/test.ts test/config/normalization.test.ts → 43 pass, 0 fail

The note anthropic/claude-opus-5: promo credits, reset at 2026-01-04T00:00:00Z should produce a skip adjustment with until = Date.parse("2026-01-04T00:00:00Z") (1767484800000). Under America/Chicago the tuner returns until = 1767506400000 — exactly +6h, i.e. the Z-suffixed timestamp is being interpreted as local midnight instead of UTC.

Impact

If the parsing path is shared with production (not just the test), a user outside UTC gets route-tuning notes that expire hours early/late. Either way the test suite is red for every non-UTC contributor.

Suggested fix

Parse the note timestamp as UTC when it carries a Z (or normalize through Date.parse on the full ISO string rather than reconstructing a local date), and/or pin the tuner's parsing to UTC. Add a non-UTC regression run for this test.

Found by the issue sweep while verifying #14; unrelated to that change (fails identically on clean main).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions