Skip to content

Add a Y2038 suite and move the existing 2038-limit tests into it - #224

Merged
mnot merged 5 commits into
mainfrom
claude/y2038-cache-test-coverage-fa29bd
Nov 17, 2026
Merged

mnot merged 5 commits into
mainfrom
claude/y2038-cache-test-coverage-fa29bd

Conversation

@mnot

@mnot mnot commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a y2038 suite that probes how caches cope with the Year 2038 problem (time held in a signed 32-bit integer), and moves the existing tests at that limit into it.

Most 2038 behaviour can be tested now, because the origin controls every header it sends: far-future dates and large delta-seconds exercise the same arithmetic. A cache that rejects, caps or wraps a value looks the same on the wire (a miss), so each series steps through values and the first failing one shows where behaviour changes.

Migration

7 tests move into the new suite with their ids and definitions unchanged: max-age and Age at 2147483647, 2147483648 and 2147483649 (the 32-bit signed limit), and the Expires of Tue, 19 Jan 2038 03:14:08 GMT. Large-value tests that aren't tied to that limit stay where they were: max-age=99999999999, the Expires in 2286, and the two CDN-Cache-Control tests. I exported the full suite before and after: all 371 existing definitions are identical, and the other suites keep their remaining tests in the same order. The moved tests keep their existing depends_on; several still point at freshness-none rather than a stronger control, which I left alone to keep the move pure.

New tests

109 tests: 85 in y2038 (ids prefixed y2038-) and 24 in the suites they belong to. The 32-bit limit tests go in the new suite; large values that aren't tied to it (99999999999, 2^63 and 2^64, a 100-digit number, a 10-year max-age, and the dates in 2262 and 9999) go with the existing tests for the same header:

  • cc-freshness: max-age and s-maxage at those values, and a Date in 9999 with max-age=2.
  • age-parse: Age at those values.
  • stale: stale-while-revalidate and stale-if-error at 99999999999.
  • expires-parse: Expires in 2262 and 9999, in both IMF-fixdate and asctime.
  • other: Expires and Last-Modified preserved on a stored response.
  • conditional-lm: If-Modified-Since echoed exactly on revalidation.

What y2038 covers:

  • Delta-seconds overflow: max-age, s-maxage, stale-while-revalidate, stale-if-error and Age at 2^31 and 2^32 (which wraps to zero). Also Age generation near 2^31.
  • Expires and Date: boundary dates from 1901 to 2106, max-age winning over a past Expires, and a far-future Date with max-age=2 going stale.
  • Last-Modified: after Date, and at the epoch, 1969 and 1901, for heuristic freshness.
  • Validators: If-Modified-Since echoed exactly on revalidation, If-Modified-Since in the far future and past, and If-Unmodified-Since/If-Range forwarded unchanged.
  • Preservation: Expires and Last-Modified unchanged on a stored response.
  • Formats: asctime at the boundary dates, and RFC 850 dates inside and outside the 50-year window (computed relative to now so they stay valid).

Tests where a wrong answer means serving a stale response as fresh are required (Age overflow, far-future Date with max-age=2, past Expires, the RFC 850 window). Hit-expecting tests are optimal, since a cache may cap lifetimes by policy. Informational tests are check.

Every new test depends on an existing control in its own suite or a related one. If-Unmodified-Since and If-Range have none, so y2038 adds an ordinary-date control for each.

Not covered

  • A response with no Date: Node always adds one, so the engine would need an option to suppress it.
  • The rollover itself: it needs a cache with a controllable clock (libfaketime or a VM).

Verification

  • standard and schema validation pass, and every depends_on resolves.
  • I ran all 480 tests against the origin directly (no cache). There were no harness failures, and every failure was the expected "response not from cache". The traces and the wire show the intended date formats.
  • Not run against any real cache, so the expected outcomes for caches are untested. The weekday-sensitive parsing and the exact-echo If-Modified-Since tests are the ones I'd check first.

Test plan and code were drafted by Claude (Sonnet 5.5) from a plan the author supplied, with the author setting the approach (migrate the existing tests, keep their ids, depend on non-Y2038 controls). The author has not reviewed the individual test definitions line by line.

🤖 Generated with Claude Code

mnot and others added 3 commits November 17, 2026 08:07
Most 2038 behaviour can be probed today with far-future dates and large
durations, so the new `y2038` suite steps through values at the 32-bit
signed and unsigned limits (and wider) for each time-bearing carrier.
A cache that rejects, caps or wraps a value looks the same on the wire,
so the first failing value in each series shows where behaviour changes.

Moved, with ids and definitions unchanged (checked by diffing the
exported suite before and after): the `max-age`, `Age`, `Expires` and
`CDN-Cache-Control` large-value tests that previously lived in
cc-freshness, age-parse, expires-parse and cdn-cache-control.

New tests, all prefixed `y2038-`:

- delta-seconds overflow for `max-age`, `s-maxage`, `stale-while-revalidate`,
  `stale-if-error` and `Age`, including 2^32 and 2^64 (which wrap to zero),
  and `Age` generation near 2^31
- far-future and past `Expires`, and far-future and past `Date`
- `Last-Modified` after `Date` and at the epoch, 1969 and 1901
- `If-Modified-Since` echoed on revalidation, `If-Modified-Since` in the
  far future and past, and `If-Unmodified-Since`/`If-Range` forwarded
  unchanged
- `Expires` and `Last-Modified` preserved on a stored response
- boundary dates in asctime, and RFC 850 dates inside and outside the
  50-year window (computed relative to now)

Each test depends on an existing non-Y2038 control. `If-Unmodified-Since`
and `If-Range` have no such control, so the suite adds an ordinary-date
one for each.

Not covered: a response with no `Date` (Node always adds one, so the
engine would need an option to suppress it), and the clock rollover
itself, which needs a cache with a controllable clock.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The first pass moved every existing large-value test. The ones that
aren't tied to the 32-bit signed limit go back to where they were,
byte for byte: `max-age=99999999999`, the `Expires` in 2286, and the
two `CDN-Cache-Control` tests.

Still moved: `max-age` and `Age` at 2147483647 to 2147483649, and the
`Expires` of 19 Jan 2038 03:14:08. Test ids and definitions are
unchanged throughout.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@mnot mnot changed the title Add a Y2038 suite and move the existing overflow tests into it Add a Y2038 suite and move the existing 2038-limit tests into it Nov 17, 2026
The y2038 suite keeps what sits on or near the 32-bit limits. Values
that aren't tied to them now live with the existing tests for the same
header:

- `max-age` and `s-maxage` of 315360000, 99999999999, 2^63-1, 2^64 and
  a 100-digit number, and a `Date` in 9999 with `max-age=2`
  (cc-freshness)
- `Age` at the same large values (age-parse)
- `stale-while-revalidate` and `stale-if-error` of 99999999999 (stale)
- `Expires` in 2262 and 9999, in IMF-fixdate and asctime
  (expires-parse)
- `Expires` and `Last-Modified` preserved on a stored response, for
  2262 and 9999 (other)
- `If-Modified-Since` echoed exactly on revalidation, for 2262 and
  9999 (conditional-lm)

Also reduce the y2038 description to its first sentence.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@mnot

mnot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Review of the current head (863976e). I found no blocking defects. I didn't run any of the new tests against a cache, so the cache-side expectations are as untested as the PR description says.

Checked

  • npm run lint and npm run validate pass.
  • I loaded tests/index.mjs on main and on this branch and compared them:
    • All 371 existing definitions are identical.
    • The remaining tests keep their order within each suite.
    • There are no duplicate ids. The one duplicate name (vary-syntax-star and vary-star) is in files this PR doesn't touch.
    • Seven tests change suites, which matches the description.
    • The new count is 109: 85 in y2038 and 24 in the other suites.
  • The hard-coded dates are right (Fri, 11 Apr 2262 23:47:16 GMT, Fri, 31 Dec 9999 23:59:59 GMT, and the asctime forms), and the three 100-digit strings are exactly 100 digits.
  • I read the engine to confirm the tests do what they claim:
    • rfc850date is applied to integer offsets.
    • ['Age', '>', n] works.
    • The origin only returns a 304 when If-Modified-Since matches the stored Last-Modified exactly, which the lm_validated tests rely on.
    • expected_request_headers works on a single request with no expected_type.
  • Every spec_anchors entry exists in the bundled RFC 9110/9111 XML.
  • The required (default-kind) tests have a basis in the specs: the delta-seconds overflow rule for Age, the RFC 9110 rule for RFC 850 dates more than 50 years ahead, and ordinary staleness rules for a past Expires, a far-future Date with max-age=2, and If-Modified-Since earlier than Last-Modified.

Minor points

  1. imsInThePast in tests/y2038.mjs sets setup_tests: ['expected_type'] but has no expected_type, so it does nothing. Drop it.
  2. The 44-year RFC 850 test only catches a fixed two-digit pivot because of today's date. An expiry in 2069 or later fails a POSIX-style pivot (69-99 read as 19xx), and that's been the case since 2025. It keeps working because the offset is relative to now, but the name's parenthetical will go stale.
  3. Some required tests depend on optional controls (imsInThePast on conditional-lm-fresh-earlier, the 60-year RFC 850 test on freshness-expires-rfc850). A cache that fails the optional control (say, one that never generates a 304) has the required test skipped. That seems right here, since it couldn't fail the test anyway.

The first test to run against real caches should be the exact-echo If-Modified-Since tests and the weekday-sensitive parsing ones; the docker/ harness has nginx, Apache, Caddy and others.


This review was generated by Claude (Sonnet 5.5) at the PR author's request and posted with their go-ahead. It's a static read of the diff and the engine code plus the comparison scripts above; no human has checked the individual findings line by line.

🤖 Generated with Claude Code

It named expected_type, which those requests don't set.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@mnot
mnot merged commit 5f1e155 into main Nov 17, 2026
2 checks passed
@mnot
mnot deleted the claude/y2038-cache-test-coverage-fa29bd branch November 17, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant