From 40861e1f387c0e2303b1f57b02daff05e43da944 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 11 Sep 2026 07:23:02 +0000 Subject: [PATCH 1/2] wip(spec): correct the date-macros header to ADR-0053 D-D Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01MkQhmuuJAVDjmeWNixwDDH --- packages/spec/src/data/date-macros.zod.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/spec/src/data/date-macros.zod.ts b/packages/spec/src/data/date-macros.zod.ts index 81c3e173d81..f5f5df3795a 100644 --- a/packages/spec/src/data/date-macros.zod.ts +++ b/packages/spec/src/data/date-macros.zod.ts @@ -68,9 +68,18 @@ import { z } from 'zod'; * calendars) are defined by the resolver implementation; spec only * freezes the **vocabulary**. 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}`. + * last calendar DAY (`{current_year_end}` → `2026-12-31`). What a + * bare day then DENOTES on each side of an operator is not this + * file's rule and is deliberately not restated here — it is the + * platform-wide rule in `./calendar-day.ts` (ADR-0053 D-D): as an + * upper bound (`$lte`, a `$between` max, a `dateRange` end) a bare + * day means the WHOLE day, compiled half-open to the next calendar + * day, so `<= {current_year_end}` reaches the final instant of Dec + * 31; as `$gte` / `$gt` / `$lt` it means that day's `00:00:00.000`. + * ⛔ Do NOT hand-write a half-open detour (`< {next_year_start}`) + * to cover the last day of a period on a `datetime` column: every + * backend already applies that widening, and `./temporal-conformance.ts` + * pins it cross-driver. */ /** Single-point tokens — moments in time. */ From 9f2225f55b91b48ca99774cd6926a3e68f5e037b Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 11 Sep 2026 07:25:39 +0000 Subject: [PATCH 2/2] docs(spec): state the ADR-0053 D-D upper-bound rule in the date-macros header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Out of scope" block still carried the pre-ADR-0053 reading — that on a `datetime` column `<= {current_year_end}` stops at midnight on the 31st, with the half-open `< {next_year_start}` prescribed as the correction. Since #3777 a bare `YYYY-MM-DD` used as an upper bound denotes the WHOLE day, compiled half-open to the next calendar day; the rule is stated once in `packages/spec/src/data/calendar-day.ts` (ADR-0053 D-D) and pinned cross-driver by `packages/spec/src/data/temporal-conformance.ts`. The header now keeps its load-bearing first clause — a `*_end` token is the period's last calendar DAY — and cites `calendar-day.ts` for what that bare day denotes on each side of an operator, rather than restating it, so the two cannot drift apart again. Comment lines only; no schema behaviour changes. The generated reference page `content/docs/references/data/date-macros.mdx` is regenerated from the header with the repo's own generator. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01MkQhmuuJAVDjmeWNixwDDH --- .../17333-date-macros-header-adr-0053.md | 49 +++++++++++++++++++ content/docs/references/data/date-macros.mdx | 17 +++++-- packages/spec/src/data/date-macros.zod.ts | 22 +++++---- 3 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 .changeset/17333-date-macros-header-adr-0053.md diff --git a/.changeset/17333-date-macros-header-adr-0053.md b/.changeset/17333-date-macros-header-adr-0053.md new file mode 100644 index 00000000000..741f288f466 --- /dev/null +++ b/.changeset/17333-date-macros-header-adr-0053.md @@ -0,0 +1,49 @@ +--- +'@objectstack/spec': patch +--- + +`date-macros.zod.ts`'s module header states the ADR-0053 D-D upper-bound rule the platform implements, instead of the rule it replaced + +The header's "Out of scope" block told an author that on a `datetime` column +`<= {current_year_end}` **stops at midnight on the 31st**, and prescribed the +half-open `< {next_year_start}` as the fix. That is the pre-ADR-0053 reading. +The platform rule has been the opposite since #3777: a bare `YYYY-MM-DD` used +as an upper bound denotes the WHOLE day, compiled half-open to the next +calendar day. It is stated once, in +`packages/spec/src/data/calendar-day.ts` (ADR-0053 D-D), whose own operator +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 → compile `< nextUtcCalendarDay(day)` | + +and which `packages/spec/src/data/temporal-conformance.ts` pins cross-driver: +the case *"datetime: bare-day `$lte` keeps the whole final day"* expects +`d_mid` (09:15 on the boundary day) and `e_late` (21:40 on it) as members. + +**Why this header and not a note.** It is the doc comment on the vocabulary an +AI author reaches for, and it is the one place in the tree that says what a +`*_end` token does on the right-hand side of an operator. Both the old +prescription and the correct spelling parse, run and return rows, so nothing +downstream reports the mismatch — the author simply carries the wrong model +into every later filter. + +**What the correction does.** The load-bearing first clause is kept verbatim: a +`*_end` token IS the period's last calendar DAY. What follows now **cites** +`calendar-day.ts` rather than restating the rule, so the two statements cannot +drift apart again, and the half-open detour is refused by name for the reason +it is now wrong — the widening is already applied. + +⛔ No behaviour changes. The diff is comment lines only; no schema, accept set, +authorable key or published payload moves. + +**This is shipped, which is why it carries a changeset rather than +`skip-changeset`.** `@objectstack/spec`'s published `files[]` lists +`src/**/*.zod.ts`, so this file ships verbatim as source, and the header is the +first thing in it. + +The generated reference page `content/docs/references/data/date-macros.mdx` +carried the same sentence — it is rendered from this header and is marked +AUTO-GENERATED — and is regenerated here with +`pnpm --filter @objectstack/spec gen:schema && … gen:docs`. diff --git a/content/docs/references/data/date-macros.mdx b/content/docs/references/data/date-macros.mdx index 4776613267e..126720846b2 100644 --- a/content/docs/references/data/date-macros.mdx +++ b/content/docs/references/data/date-macros.mdx @@ -72,9 +72,20 @@ inside any single UI implementation. calendars) are defined by the resolver implementation; spec only freezes the **vocabulary**. 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}`. + last calendar DAY (`{current_year_end}` → `2026-12-31`). What a + bare day DENOTES once it lands on one side of an operator is a + separate contract, stated once in + `packages/spec/src/data/calendar-day.ts` (ADR-0053 D-D) and + deliberately not restated here: as an upper bound (`$lte`, a + `$between` max, a `dateRange` end) a bare day means the WHOLE + day, compiled half-open to the next calendar day, so + `<= {current_year_end}` reaches the final instant of Dec 31; as + `$gte` / `$gt` / `$lt` it means that day's `00:00:00.000`. + ⛔ Do NOT hand-write a half-open detour (`< {next_year_start}`) + to cover a period's last day on a `datetime` column: every + backend already applies the widening, and + `packages/spec/src/data/temporal-conformance.ts` pins it + cross-driver. **Source:** `packages/spec/src/data/date-macros.zod.ts` diff --git a/packages/spec/src/data/date-macros.zod.ts b/packages/spec/src/data/date-macros.zod.ts index f5f5df3795a..1977eb204e4 100644 --- a/packages/spec/src/data/date-macros.zod.ts +++ b/packages/spec/src/data/date-macros.zod.ts @@ -69,17 +69,19 @@ import { z } from 'zod'; * freezes the **vocabulary**. 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`). What a - * bare day then DENOTES on each side of an operator is not this - * file's rule and is deliberately not restated here — it is the - * platform-wide rule in `./calendar-day.ts` (ADR-0053 D-D): as an - * upper bound (`$lte`, a `$between` max, a `dateRange` end) a bare - * day means the WHOLE day, compiled half-open to the next calendar - * day, so `<= {current_year_end}` reaches the final instant of Dec - * 31; as `$gte` / `$gt` / `$lt` it means that day's `00:00:00.000`. + * bare day DENOTES once it lands on one side of an operator is a + * separate contract, stated once in + * `packages/spec/src/data/calendar-day.ts` (ADR-0053 D-D) and + * deliberately not restated here: as an upper bound (`$lte`, a + * `$between` max, a `dateRange` end) a bare day means the WHOLE + * day, compiled half-open to the next calendar day, so + * `<= {current_year_end}` reaches the final instant of Dec 31; as + * `$gte` / `$gt` / `$lt` it means that day's `00:00:00.000`. * ⛔ Do NOT hand-write a half-open detour (`< {next_year_start}`) - * to cover the last day of a period on a `datetime` column: every - * backend already applies that widening, and `./temporal-conformance.ts` - * pins it cross-driver. + * to cover a period's last day on a `datetime` column: every + * backend already applies the widening, and + * `packages/spec/src/data/temporal-conformance.ts` pins it + * cross-driver. */ /** Single-point tokens — moments in time. */