Repository navigation
feat(objectql,driver-sql): PostgreSQL buckets a non-UTC reference timezone in the database (ADR-0053 D2 as amended) - #34530
Conversation
Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
…ls (#33697) Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
…zoned bucket takes (#33697) Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
…s; changeset (#33697) Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
…ve bit (#33697) Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
… engine does and prints PostgreSQL's zoned bucket (#33697) Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
… argument (#33697) Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
…#33697) Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 4 package(s): 14 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 8 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 176 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b4bcee2bf151868c14aed89298cd35f3bfd04312 && git checkout b4bcee2bf151868c14aed89298cd35f3bfd04312
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 144cdc254e44ecd77f9d011714afaefdb2eecc32 f9fa972988f4479ec681d3d56650ff957d73a428 && git checkout -B drift-repro 144cdc254e44ecd77f9d011714afaefdb2eecc32 && git merge --no-ff f9fa972988f4479ec681d3d56650ff957d73a428
node scripts/docs-audit/affected-docs.mjs --json 144cdc254e44ecd77f9d011714afaefdb2eecc32
|
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 0341403 · 2026-11-17T00:13Z |
…ack/spec minor The new DriverCapabilities key zonedDateBucketing moves the authorable-surface data shard, which the Check Changeset ratchet reads as a key added. Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
…dded Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W 席位核对L1 first review · REWORK (1 item) · head Code read in parallel with CI, as the seat asked. At the reading this head had 13 REWORK
Checklist (read on GitHub at this head, not from the report)
Owed after this
Out of scope, for the area to place before ACCEPT (one line each:
|
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract reviewServed-tier: Inputs read: card #33697 body and all 8 comments; PR #34530 body and file list (25 files); the net diff against main (merge base bdd5176, equal to origin/main); the check-runs on the head; ADR-0053 Phase 2 D2 with its amendment note on main; the gate source scripts/check-changeset-no-major.mjs and the Temporal Conformance job in .github/workflows/ci.yml, read only. Check-runs on the head (45): ① Derived judgments
② Semver levelClause-②: yes (widening) — the declaration is right as to the arm: one optional capability key and one exported type are added, nothing is narrowed at any published accept set. M1 (must-fix) — the level and the The package list is otherwise right: spec, objectql, driver-sql and service-analytics are the packages whose published source moves; driver-turso is not moved. ③ Boundary flags
S1 (should-fix) — the live PostgreSQL parity reading is owed on the landing head before landing. Asked explicitly by the lane. The evidence on the head is not enough for the contract by itself:
④ Design judgmentpackages/spec/src/contracts/data-driver.ts — holds against the amendment and its first consumer.
packages/spec/src/data/driver.zod.ts — holds. Each sentence of the new docblock was checked against the code: resolve first; UTC takes the UTC path; an area/location name goes down with the resolved name when the bit is true and the method exists; every other case stays in packages/spec/src/data/data-engine.zod.ts — holds. The rewritten Attempts to break the design, each read in the head tree:
No must-fix, no should-fix in ④. The graded findings on this head are M1 (②) and S1 (③). Nits, no effect on correctness or the contract:
Landing note for the seat: besides M1 and S1, most check-runs were still PENDING when read; the landing check reads them all green on the landing head. Implemented-by: VERDICT: FAIL |
…l, the runtime-relative spellings and the hook's no-UTC answer Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
Keeps both DriverCapabilities bits beside aggregationFilter (lockRows from main, zonedDateBucketing here); the audited capability shape is 7 live bits. Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-steve · session_01ADHkmQAXHSQEgnYyx9tstb Final head for review: |
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 6784558 · 2026-11-17T02:44Z |
|
repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W 席位核对L1 delta · ACCEPT · head Delta read (
|
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract reviewServed-tier: Delta review. The previous record at this tier is comment 6933599747 (FAIL on head 0341403: M1, S1, N1 to N3). This record judges the change from that head to this one, restricted to the PR's 25 files (12 of them moved, +133/-10), and the places where the merge of main (#34517, Inputs read: the previous record in full; PR #34530 body, its 6 comments and its check-runs on this head; card #33697, all 10 comments, including the claim correction 6933531393 and the witness 6935873746; the restricted diff between the two heads; whole files at this head for the changeset, Check-runs on this head (68, all completed): 0 failure, 0 pending, 10 skipped, 58 success. ① Derived judgments
② Semver levelClause-②: yes (widening) — unchanged and still right. M1: closed — the changeset front matter now grades S2 (should-fix) — the ③ Boundary flagsS1: closed — the reading the previous record asked for is on the card (6935873746) and names this head by its full sha. What it states: PostgreSQL 16.15, server zone Asia/Shanghai read before and after the run, process
④ Design judgmentShort, because the design did not move: between the heads the three scope files changed only in jsdoc and in main's own packages/spec/src/contracts/data-driver.ts (N1) — the new sentence says a driver that does not declare the bit is never sent the key by the engine, and that, handed one by a direct caller, it refuses the zone the same way rather than answering the UTC bucket. The first half is true: packages/spec/src/data/driver.zod.ts and packages/spec/src/data/data-engine.zod.ts (N2) — both docblocks now say the spellings are examples as Node 22 resolves them and that the rule is the runtime's resolution. True: packages/services/service-analytics/src/strategies/types.ts (N3) — the hook's jsdoc now says an implementer that does not bucket the zone it is asked for answers ④ adds no graded finding. The one graded finding on this head is S2 (②). Nits, no effect on correctness or the contract:
Implemented-by: VERDICT: PASS |
Claude-Session: https://claude.ai/code/session_01ADHkmPeEPFrWJ9cBKVtYb6 Co-authored-by: Claude <noreply@anthropic.com>
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head f9fa972 · 2026-11-17T02:56Z |
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract reviewServed-tier: Delta review. The previous record at this tier is comment 6936523534 (PASS on head 6784558; M1 and S1 closed, S2 open, nits N1 and N4 open). This record judges the change from that head to this one. Inputs read: the previous record in full; the diff between the two heads; the changeset whole at this head; The delta, from the tree: one commit, f9fa972, one file, Check-runs on this head (37 listed at the reading): 0 failure, 10 success, 9 skipped, 18 pending. Pending is not a verdict. Pending: ① Derived judgments
② Semver levelClause-②: yes (widening) — unchanged and still right. The changeset still grades S2: closed — read against the tree and the cards, not the account.
③ Boundary flags
④ Design judgmentShort, because no line of design, code or jsdoc moved between the heads: the previous record's ④ stands for this head word for word. What changed is where two of its remarks are carried.
Nits, no effect on correctness or the contract:
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W 席位核对L1 delta · ACCEPT · head Correction to my earlier readingIn 6936419294 (and in my first review, 6933484440) I accepted Delta read (
|
|
repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA Seat record · 2026-11-17T03:26Z · Head-sha: f9fa972 The PR body's 速读 says "需要你做的:无,席位落地". This record replaces that line. The PR adds to the 维护者速读
席位意见:同意合并。这是执行你已下的裁决,结果和内存路径逐桶对等,不支持的驱动行为不变。 席位核对
|
|
repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA Tier H hand-off, written at 2026-11-17T03:26Z. This is a spec contract widening, so it goes to a human approver. The seat record is pinned to head |
Requested by Steve · project thread
Fixes #33697
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up #34597 —
skills/objectstack-query/rules/aggregation.md(the Filtered Aggregation note) says a date bucket in a non-UTC timezone keeps the whole call in memory; on PostgreSQL that stops being true here, and #34597 rewrites the note.维护者速读
AT TIME ZONE分桶,不再把整批行拉进应用内存;SQLite、MySQL 等其余驱动照旧走内存分桶。packages/drivers/driver-sql/src/sql-driver-aggregation.ts(时区只绑定一次、GROUP BY 按序号)、packages/objectql/src/engine-delete-and-aggregate.ts(按运行时解析后的时区名分派)、packages/spec/src/contracts/data-driver.ts(新契约类型)。OS_TEST_POSTGRES_URL=… pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-33697-zoned-date-bucket.test.ts,预期 61 过 1 跳过(MySQL 未配)。What changes
ADR-0053 Phase 2 D2, as amended for this card (PR #33774), executed:
@objectstack/spec: a new live driver capability bit,supports.zonedDateBucketing(DriverCapabilitiesSchema, with its reader in the same change, per the schema docblock's bar for a new bit), and a new contract typeDriverAggregateQuery=DriverQueryplustimezone, whichIDataDriver.aggregatenow receives. Kept offDriverQueryon purpose:find()/count()take that type and would silently drop a zone. Review item (c): theIDataDriver.aggregatejsdoc ("a driver never sees" a non-UTC zone) and thetimezonejsdoc indata-engine.zod.tsare rewritten;DriverOptions.timezone(the execution-context zone, read for autonumber) is left untouched as the carrier it is.@objectstack/objectql:engine.aggregatejudges the request'stimezonethrough the runtime (judgeBucketZone: theresolvedOptions().timeZoneof anIntl.DateTimeFormat). Resolves toUTC(Etc/UTC,GMT,Zulu) → the native UTC path (review item d). Resolves to an area/location name → pushed down AS the resolved name (CST→America/Chicago,US/Eastern→America/New_York,Etc/GMT+5as itself) when the driver declares the bit and hasaggregate(). Anything else (EST5EDT,+08:00, an unresolvable string), or a driver without the bit → the in-memory path, unchanged (review item e). The raw string never reaches a driver. The relation-group-join statement gets the zone the same way.@objectstack/driver-sql: declares the bit on PostgreSQL only (zonedDateBucketing: this.isPostgres;TursoDriveris SQLite and inheritsfalse).buildDateBucketExprtakes the zone:to_char((col)::timestamptz AT TIME ZONE ?, fmt)with the zone bound; aField.datekeeps its calendar-day arm under every zone; every other dialect answersnullfor a zone. Review item (a): the zoned bucket is stated once, in the select list, and the GROUP BY names its select-list position — spelled twice, PostgreSQL numbers the two?as$1/$2and refuses with 42803 (measured, ablation A1 below). A directaggregate()call carrying a zone is judged before anything compiles: a dialect without the bit refusesNOT_IMPLEMENTED/501, and a zone string that is not its own resolved area/location name refusesINVALID_QUERY/400 — never read as UTC.dateBucketSqltakes the zone too, for the echo.@objectstack/service-analytics(review item c, the dry run anddateBucketSql):ObjectQLStrategy.generateSqlreads the zone the way the engine does (echoBucketZone) and asks thedateBucketSqlhook with the resolved zone; PostgreSQL answers the zoned expression the database groups by and the dry run prints it (and it runs); every driver that buckets the zone in memory answers nothing and the dry run refuses as before. The plugin bridge,DatasetScopedStrategyContext.dateBucketSqlandAnalyticsServiceConfig.dateBucketSqlgain the optionaltimezoneargument.Review item (b), SQLite: it does not declare the bit, so every non-UTC zone stays in memory there. The amendment allows a fixed-offset zone to be bucketed in SQL; this PR does not take that option (see Acceptance notes).
Tests
packages/drivers/driver-sql/src/sql-driver-33697-zoned-date-bucket.test.ts(dialect matrix): on live PostgreSQL, every bucketaggregate()answers equals the in-memory label (bucketDateKey,@objectstack/core;Field.datewith no zone, asbucketCalendarDaydoes) for Europe/Berlin across both 2026 DST changes, Asia/Taipei, America/New_York (west of UTC, theField.dateaxis), America/Chicago and Etc/GMT+5, at all five granularities, on both column types; the bucket after a plain key, aliased, under awherewith bindings; refusals withcode+statusforCST,US/Eastern,+08:00,EST5EDT,Bogus/Zone. On SQLite (and MySQL where provisioned): no bit, 501 refusal, UTC and a no-bucket query served. A fixture-sensitivity pin keeps the parity non-vacuous.packages/objectql/src/engine-aggregate-timezone.test.ts: a new describe pins the dispatch spelling by spelling (resolved names sent; UTC aliases native with no zone;EST5EDT/+08:00/Bogus/Zonein memory; no bit orfalsein memory; no zone for a query without a date bucket).packages/spec/src/data/driver.test.ts— the audited capability shape is 7 live bits + 31 tombstones (5 before this PR;lockRowsfrom fix(spec, objectql, driver-sql): a predicate delete with a cascade locks the rows it walks #34517 is the other new bit, merged in frommain); absence and a non-boolean value pinned for the new bit.packages/services/service-analytics/src/__tests__/objectql-echo-date-bucket.test.ts— the live PostgreSQL cell now pins the zoned pushdown (the driver groups once, the rows equal the zone's calendar, the dry run prints the zoned expression and it runs) instead of the refusal; SQLite keeps the refusal; the per-dialect block's hook passes the zone, PostgreSQL prints the zoned expression, and new cases pin+08:00/EST5EDTrefusing andEtc/UTC/GMTprinting the UTC expression.packages/services/service-analytics/src/__tests__/objectql-echo-bucket-enumeration.test.ts—Etc/UTCmoves to the UTC class andGMTjoins it (it was pinned in the in-memory class because the engine compared the raw string); the "any other zone" class becomes "an area/location zone" (pushed down on a driver declaring the bit, asserted per face) plus a new "no area/location name" class; the driver surface takes the zone argument.Acceptance notes
judgeBucketZone), the driver (resolvedAreaZone) and the analytics echo (echoBucketZone) each state the same resolution rule;@objectstack/coreis the natural shared home, outside this card's file surface. The analytics enumeration pin holds the engine and the echo together; the driver's copy only refuses. Disposition: filed aggregate timezone: the zone resolution rule is written three times (engine, driver-sql, analytics echo) and only two are pinned together #34544 (one shared resolution rule; Blocked-by aggregate: PostgreSQL buckets a non-UTC timezone in the database (amend ADR-0053 D2; SQLite keeps DST zones in memory) — epic #33631 R6 #33697).driver-mongodbdeclares nozonedDateBucketingbit, so the engine never pushes a zoned bucket to it; a caller that hands it a zone directly still gets UTC buckets, and its docblock predates the bit (L2 N1). Outside this card's file surface. Disposition: filed driver-mongodb: a direct call with a non-UTC timezone buckets dates in UTC with no refusal, and the docblock says otherwise #34598.Verification
All local, on PostgreSQL 16.15 with the server at
Asia/Shanghaiand the process atTZ=America/New_York. The counts below were read on head03414032; the counts at the final head (after the merge ofmaincarrying #34517) are on card #33697 comment 6935873746: driver-sql 5520 passed / 129 skipped, the zoned-bucket matrix 61 passed / 1 skipped, service-analytics 5835 passed / 34 skipped.Packages: test + typecheck
@objectstack/driver-sqltest (with the live PostgreSQL cell): 267 files passed, 4 skipped; 5513 tests passed, 128 skipped (MySQL / SQL Server cells unprovisioned). typecheck exit 0.@objectstack/objectqltest: green; typecheck exit 0.engine-aggregate-timezone.test.ts17/17.@objectstack/service-analyticstest (live PostgreSQL cell included): 218 files, 5835 passed, 34 skipped. typecheck exit 0.@objectstack/driver-tursotest: 100 files passed, 1 skipped; typecheck exit 0.@objectstack/spectest: the two red cases before the pin update were the audited capability shape (driver.test.ts), now 60/60; typecheck exit 0.check:generated --fixregeneratedapi-surface/contracts.json,export-origins/contracts.jsonand the threecontent/docs/references/data/driver*.mdxpages.Ablations (each restored, `git diff HEAD` empty after all four)
groupByRaw(bucket.sql, bucket.bindings)) → 26 failed / 35 passed; PostgreSQL answers 42803 "must appear in the GROUP BY clause".'UTC'→ 16 failed / 45 passed (everyField.datetimezone cell whose labels differ from UTC; theField.datecells stay green, as they must).UTCarm deleted → 3 failed / 14 passed (Etc/UTC,GMT,Zulu).Derived gates
node scripts/pm/dispatch-gates.mjs --commandson head03414032: 128 commands, each run with stdin from /dev/null, all exit 0;--ranreconciliation: 128 derived, 128 run, 0 NOT-MEASURED, 0 UNRUN.Generated by Claude Code