Skip to content

spec: date-macros.zod.ts's header still states the pre-ADR-0053 upper-bound rule, so it tells an author a *_end token stops at midnight #17333

Description

@os-bill

Found while correcting the yesterday / today entries of DATE_RANGE_PRESET_MACRO_WINDOWS (#17014), out of that card's scope: it is a different file, a different contract statement, and correcting a module header on a file of Zod schemas pulls in the check:docs / gen:schema regeneration surface that card does not otherwise touch.

The contradiction

packages/spec/src/data/calendar-day.ts states the platform rule (ADR-0053 D-D), and its own table reads:

Operator A bare YYYY-MM-DD on a datetime column means
$gte / $gt / $lt that day's 00:00:00.000 — already correct as written
$lte, a $between max, a dateRange end the WHOLE day, compiled half-open to the next calendar day

packages/spec/src/data/date-macros.zod.ts's module header, in its "Out of scope" block, still states the behaviour that rule replaced:

One property is worth stating here because it is authored against: a *_end token is the period's last calendar DAY ({current_year_end} -> 2026-12-31), so on a datetime column <= {current_year_end} stops at midnight on the 31st. Filter a timestamp with the half-open < {next_year_start}.

The first clause is correct and load-bearing — a *_end token IS the period's last calendar day. The rest is the pre-fix reading. On a datetime column today, <= {current_year_end} does not stop at midnight on the 31st: the bare-day upper bound is widened to the whole of Dec 31 by every backend, which is exactly what that widening exists to do. The advice that follows ("filter a timestamp with the half-open ...") is therefore no longer a correction of anything; it prescribes a detour around a rule that was already applied.

Why it is worth a card rather than a note

This header is the doc-comment on the vocabulary an AI author reaches for. It is the one place in the tree that tells an author what a *_end token does when it lands on the right-hand side of an operator, and it currently tells them the opposite of what the platform does. Both spellings run and return rows, so nothing downstream reports the mismatch — the author simply carries a wrong model of the operator into every subsequent filter.

Measurement

  • The rule is live at origin/main 47863f4fb: the widening is implemented in driver-memory, in the SQL emitters, in formula's matchesFilterCondition, and in service-analytics's preview evaluator, and packages/spec/src/data/temporal-conformance.ts pins it cross-driver (d_mid and e_late, both stamped after midnight on the boundary day, are expected members of a bare-day $lte window).
  • No open card covers it: read over all 104 open domain:spec issues, the terms date-macros, current_year_end, stops at midnight and upper bound each match 0. Controls on the same population: half-open, 3777 and date-range each match exactly 1 — spec: the yesterday entry of DATE_RANGE_PRESET_MACRO_WINDOWS prescribes a TWO-day window, so the refusal an author is handed selects today as well #17014 itself — and a fabricated control term matches 0.

Suggested shape

Correct the sentence to state the rule as calendar-day.ts states it, and cite that file rather than restating it, so the two cannot drift again. The *_end-is-the-last-day half stays as it is.

Generated by Claude Code


Generated by Claude Code

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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions