Skip to content

fix(evals): Start every eval test at the same clock time - #2111

Merged
dcramer merged 8 commits into
mainfrom
fix/evals-pinned-clock
Oct 14, 2026
Merged

dcramer merged 8 commits into
mainfrom
fix/evals-pinned-clock

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Google Calendar evals miss their recordings a few hours after a recording run. In run 38460591425, the replayed first tool call had a timeMax that the model worked out on Oct 9. By the time of the replay, that timeMax was in the past, so findMeetingTimes returned timeMax must be after timeMin and now. The next slot labels, such as Tue, Oct 13, 14:30 – 15:00 PDT, change every hour.

values patterns cannot fix this. They only rewrite times that also appear in the request. Times that the model works out from "now" stay as they were recorded, and tools compare them with the real clock. Any eval with "tomorrow" or "next week" and a tool that takes exact times can fail the same way.

This change replaces Date in eval workers with a clock that starts every test at the same instant (EVAL_START_MS, Monday 2026-10-12 09:00 PT). The clock moves forward in real time, so waits and deadlines still work. Timers and performance.now() stay real.

Sandbox egress needs the same clock in both processes:

  • The worker makes egress tokens, leases, and fixture credentials with the eval clock, and the main process checks them. The worker now sends its time in the body of each fixture reset (src/setup.ts → eval-egress.ts → global-setup.ts), and the main process sets its own eval clock from it.
  • The main process checks real Vercel OIDC tokens. verifyVercelSandboxOidcToken takes an optional currentDate, and the egress handler passes through verifyOidc. Eval global setup checks OIDC with realNow(). Production behavior does not change.
  • EVAL_START_MS is in the past on purpose. Real tokens that the worker reads, such as VERCEL_OIDC_TOKEN, are then not expired by the eval clock.
  • Snapshot warmup in global setup runs before the first reset, so it still uses the real time.

Checks

  • pnpm --filter @sentry/junior-evals typecheck and pnpm --filter @sentry/junior typecheck pass.
  • pnpm --filter @sentry/junior lint and pnpm test-architecture:check pass.
  • A tsx smoke script checked the clock: Date.now(), new Date(), Date(), instanceof Date, subclasses, new Date(value), Date.parse/UTC, forward movement, and realNow().
  • Not run: the eval harness tests and any evals. They need Postgres and live credentials. Look closely at the CI result for the coding (sandbox) and Google suites. This PR stays a draft until those pass in strict replay.

The Google recordings will record again on this branch. After that, the Google evals should replay on any later day.

via David Cramer.

--

View Junior Session [Sentry]

Recordings keep times that the model calculates from now, such as the end
of a search window. Tools then compared them with the real clock, so
Google Calendar evals missed their recordings a few hours after a
recording run.

Replace Date in the eval worker with a clock that starts each test at a
fixed instant and moves forward in real time. The main process uses the
same clock for sandbox egress, and the worker sends its time with each
fixture reset. Vercel OIDC checks keep the real time.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Oct 14, 2026 2:10am UTC

Request Review

@sentry-evals

sentry-evals Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Sentry Evals

junior-behavioral

Run Status Passed Failed Errored Cost Tokens Duration
Head Complete 68 6 0 $1.05 0 217.48s

Base commit 4f8d0fa has no eval run to compare against.

junior-guardian

Run Status Passed Failed Errored Cost Tokens Duration
Head Complete 53 0 5 $0.01 0 0.93s

Base commit 4f8d0fa has no eval run to compare against.

junior-integration

Run Status Passed Failed Errored Cost Tokens Duration
Head Complete 96 0 0 $0.79 0 145.32s

Base commit 4f8d0fa has no eval run to compare against.

junior-router

Run Status Passed Failed Errored Cost Tokens Duration
Head Complete 12 0 0 $0.00 0 0.19s

Base commit 4f8d0fa has no eval run to compare against.

The behavioral evals recorded these model responses in https://github.com/getsentry/junior/actions/runs/38472434649.
The evals of this commit replay them in strict mode.

Eval-Suite: behavioral
@dcramer
dcramer marked this pull request as ready for review October 14, 2026 00:46
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 14, 2026
The integration evals recorded these model responses in https://github.com/getsentry/junior/actions/runs/38492991958.
The evals of this commit replay them in strict mode.

Eval-Suite: integration
The behavioral evals recorded these model responses in https://github.com/getsentry/junior/actions/runs/38492991734.
The evals of this commit replay them in strict mode.

Eval-Suite: behavioral
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: medium PR risk score: medium labels Oct 14, 2026
The integration evals recorded these model responses in https://github.com/getsentry/junior/actions/runs/38499033299.
The evals of this commit replay them in strict mode.

Eval-Suite: integration
The behavioral evals recorded these model responses in https://github.com/getsentry/junior/actions/runs/38499033318.
The evals of this commit replay them in strict mode.

Eval-Suite: behavioral
@dcramer
dcramer merged commit 839ffb3 into main Oct 14, 2026
54 of 55 checks passed
@dcramer
dcramer deleted the fix/evals-pinned-clock branch October 14, 2026 03:04
dcramer added a commit that referenced this pull request Nov 16, 2026
In the junior Vitest suite, `Date` now starts each test file and each
test 5 s after the start of the current real minute, and then moves
forward in real time. This is the offset clock the evals already use. It
moves from `junior-evals/src/eval-clock.ts` to
`@sentry/junior-testing/clock`, and the evals import it from there.

## Why

Recent fixes for nondeterministic tests, grouped by mechanism:

| Mechanism | Fix | Suite | Harness default before this PR |
| --- | --- | --- | --- |
| Wall clock | #3265: a run that crossed a minute
boundary left fixture stamps newer than a Turn | junior Vitest |
**None.** The test pinned its own clock. |
| Wall clock | #2111: model-derived times went stale
between recording and replay | evals | Eval clock |
| Shared state | #3355: the Redis user cache outlived
the Postgres reset | evals | Per-test namespace delete |
| Shared state | #1775: module-level mock state leaked
between specs | dashboard e2e | Reset in the page fixture |
| Shared state | #2474: keep-alive connections blocked
server close | dashboard e2e | `closeAllConnections()` |
| Timing | #1925, #3316: one-off races |
junior Vitest, dashboard e2e | Fixed in each fixture or spec |

The only mechanism with no harness default was the wall clock in the
junior Vitest suite, so this PR changes only that.

## What the harness guarantees

- Each test starts at second 5 of a minute. A test that runs for less
than 55 s cannot cross a minute boundary by chance.
#3265 is no longer possible, so `versions.test.ts` drops
its own pin.
- `Date` stays within a minute of real time. Times that JS stamps stay
comparable with Postgres `now()`, `defaultNow()` columns, and real
servers such as S3, so no test needs an opt-out. A fixed calendar
instant would put `Date` weeks away from those clocks.
- The clock keeps millisecond steps and real-time speed. Timers and
`performance.now()` stay real. Sinon's Date-only fake
(`shouldAdvanceTime`) moves in 20 ms steps and does not move during
microtask-only work. Timestamps would then tie and make `ORDER BY
created_at` flaky, so this PR does not use it.
- `vi.useFakeTimers()`, `vi.setSystemTime()`, and `vi.spyOn(Date,
"now")` work on top of the clock.
- A global `afterEach` calls `vi.useRealTimers()`, so fake timers do not
leak into the next test. A test that forgets `vi.useRealTimers()` no
longer shows up as a leak in later tests.

## Left out

- Shared state and timing: each listed fix already lives in its own
harness or was one specific race. The junior Vitest suite already resets
Postgres and the state adapter for each integration test, and I found no
common leak to guard against.
- Calendar-dependent output, such as weekday or month names, still
follows the real date. No listed fix came from that.
- Existing per-test `vi.setSystemTime` pins still work and stay as they
are.

<!-- junior-request-attribution:start -->
via @dcramer.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Ae0825347725c723b07a008a8b27a2961 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Ae0825347725c723b07a008a8b27a2961)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ae0825347725c723b07a008a8b27a2961/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — b6b8ef90 Deployed Oct 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant