Skip to content

feat(objectql,driver-sql): PostgreSQL buckets a non-UTC reference timezone in the database (ADR-0053 D2 as amended) - #34530

Merged
os-zhuang merged 14 commits into
mainfrom
claude/project-thread-tf8gon
Nov 17, 2026
Merged

os-zhuang merged 14 commits into
mainfrom
claude/project-thread-tf8gon

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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.

维护者速读

  • 改了什么:PostgreSQL 上按非 UTC 时区(如 Asia/Taipei、Europe/Berlin)的日/周/月/季/年分组,改为在数据库里用 AT TIME ZONE 分桶,不再把整批行拉进应用内存;SQLite、MySQL 等其余驱动照旧走内存分桶。
  • 为什么改:执行维护者裁决「PG 在库里算,修订 ADR」(ADR-0053 D2 修订已合);多数用户不在 UTC,他们的每个日报/月报此前都走慢路径。
  • 风险与回滚:只改分桶表达式,权限范围与租户墙仍在同一条 WHERE;库内结果与内存结果逐桶对等(PG 16 实测,含柏林两次夏令时切换);回滚即撤本 PR,引擎自动回到内存路径。
  • 先看: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(新契约类型)。
  • 两分钟验证:起一个 PG(服务器时区 Asia/Shanghai),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 type DriverAggregateQuery = DriverQuery plus timezone, which IDataDriver.aggregate now receives. Kept off DriverQuery on purpose: find() / count() take that type and would silently drop a zone. Review item (c): the IDataDriver.aggregate jsdoc ("a driver never sees" a non-UTC zone) and the timezone jsdoc in data-engine.zod.ts are rewritten; DriverOptions.timezone (the execution-context zone, read for autonumber) is left untouched as the carrier it is.
  • @objectstack/objectql: engine.aggregate judges the request's timezone through the runtime (judgeBucketZone: the resolvedOptions().timeZone of an Intl.DateTimeFormat). Resolves to UTC (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+5 as itself) when the driver declares the bit and has aggregate(). 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; TursoDriver is SQLite and inherits false). buildDateBucketExpr takes the zone: to_char((col)::timestamptz AT TIME ZONE ?, fmt) with the zone bound; a Field.date keeps its calendar-day arm under every zone; every other dialect answers null for 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 / $2 and refuses with 42803 (measured, ablation A1 below). A direct aggregate() call carrying a zone is judged before anything compiles: a dialect without the bit refuses NOT_IMPLEMENTED/501, and a zone string that is not its own resolved area/location name refuses INVALID_QUERY/400 — never read as UTC. dateBucketSql takes the zone too, for the echo.
  • @objectstack/service-analytics (review item c, the dry run and dateBucketSql): ObjectQLStrategy.generateSql reads the zone the way the engine does (echoBucketZone) and asks the dateBucketSql hook 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.dateBucketSql and AnalyticsServiceConfig.dateBucketSql gain the optional timezone argument.

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

  • New packages/drivers/driver-sql/src/sql-driver-33697-zoned-date-bucket.test.ts (dialect matrix): on live PostgreSQL, every bucket aggregate() answers equals the in-memory label (bucketDateKey, @objectstack/core; Field.date with no zone, as bucketCalendarDay does) for Europe/Berlin across both 2026 DST changes, Asia/Taipei, America/New_York (west of UTC, the Field.date axis), America/Chicago and Etc/GMT+5, at all five granularities, on both column types; the bucket after a plain key, aliased, under a where with bindings; refusals with code + status for CST, 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/Zone in memory; no bit or false in memory; no zone for a query without a date bucket).
  • Tests changed because the behaviour they pinned changed by the ruling, each named:
    • packages/spec/src/data/driver.test.ts — the audited capability shape is 7 live bits + 31 tombstones (5 before this PR; lockRows from fix(spec, objectql, driver-sql): a predicate delete with a cascade locks the rows it walks #34517 is the other new bit, merged in from main); 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 / EST5EDT refusing and Etc/UTC / GMT printing the UTC expression.
    • packages/services/service-analytics/src/__tests__/objectql-echo-bucket-enumeration.test.ts — Etc/UTC moves to the UTC class and GMT joins 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

Verification

All local, on PostgreSQL 16.15 with the server at Asia/Shanghai and the process at TZ=America/New_York. The counts below were read on head 03414032; the counts at the final head (after the merge of main carrying #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-sql test (with the live PostgreSQL cell): 267 files passed, 4 skipped; 5513 tests passed, 128 skipped (MySQL / SQL Server cells unprovisioned). typecheck exit 0.
  • @objectstack/objectql test: green; typecheck exit 0. engine-aggregate-timezone.test.ts 17/17.
  • @objectstack/service-analytics test (live PostgreSQL cell included): 218 files, 5835 passed, 34 skipped. typecheck exit 0.
  • @objectstack/driver-turso test: 100 files passed, 1 skipped; typecheck exit 0.
  • @objectstack/spec test: the two red cases before the pin update were the audited capability shape (driver.test.ts), now 60/60; typecheck exit 0. check:generated --fix regenerated api-surface/contracts.json, export-origins/contracts.json and the three content/docs/references/data/driver*.mdx pages.
  • New zoned-bucket matrix: 61 passed, 1 skipped (live MySQL).
Ablations (each restored, `git diff HEAD` empty after all four)
  • A1 driver, review item (a): the GROUP BY spells the zoned bucket again (groupByRaw(bucket.sql, bucket.bindings)) → 26 failed / 35 passed; PostgreSQL answers 42803 "must appear in the GROUP BY clause".
  • A2 driver: the zone binding replaced by 'UTC' → 16 failed / 45 passed (every Field.datetime zone cell whose labels differ from UTC; the Field.date cells stay green, as they must).
  • A3 engine: the capability bit not read → 5 failed / 12 passed (every pushdown case).
  • A4 engine, review item (d): the resolved-UTC arm deleted → 3 failed / 14 passed (Etc/UTC, GMT, Zulu).
Derived gates

node scripts/pm/dispatch-gates.mjs --commands on head 03414032: 128 commands, each run with stdin from /dev/null, all exit 0; --ran reconciliation: 128 derived, 128 run, 0 NOT-MEASURED, 0 UNRUN.


Generated by Claude Code

…zoned bucket takes (#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>
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation protocol:data tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 4 package(s): @objectstack/driver-sql, @objectstack/objectql, @objectstack/service-analytics, @objectstack/spec, touching 45 documentable anchor(s). ⚠️ 3 changed file(s) yielded no anchor (packages/spec/api-surface/contracts.json, packages/spec/authorable-surface/data.json, packages/spec/export-origins/contracts.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

14 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/data-modeling/drivers.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/data-modeling/external-datasources.mdx (via remoteColumn (literal, a string literal in aggregate))
  • content/docs/data-modeling/index.mdx (via IDataDriver (symbol, a top-level interface), SqlDriver (symbol, a top-level class))
  • content/docs/data-modeling/queries.mdx (via IDataDriver (symbol, a top-level interface), SqlDriver (symbol, a top-level class), applyTenantScope (literal, a string literal in aggregate))
  • content/docs/data-modeling/virtual-objects.mdx (via IDataDriver (symbol, a top-level interface))
  • content/docs/kernel/contracts/data-engine.mdx (via EngineAggregateOptionsSchema (symbol, a top-level const), IDataDriver (symbol, a top-level interface))
  • content/docs/kernel/contracts/index.mdx (via IDataDriver (symbol, a top-level interface))
  • content/docs/kernel/services.mdx (via IDataDriver (symbol, a top-level interface))
  • content/docs/permissions/tenant-audit-census.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/plugins/packages.mdx (via AnalyticsServicePlugin (symbol, a top-level class), SqlDriver (symbol, a top-level class))
  • content/docs/protocol/kernel/index.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/protocol/kernel/lifecycle.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/protocol/objectql/query-syntax.mdx (via IDataDriver (symbol, a top-level interface), SqlDriver (symbol, a top-level class))
  • content/docs/protocol/objectql/types.mdx (via SqlDriver (symbol, a top-level class))

⛔ 8 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v14.mdx (via generateSql (symbol, a method of class ObjectQLStrategy))
  • content/docs/releases/v17/17-0.mdx (via ObjectQLStrategy (symbol, a top-level class), SqlDriver (symbol, a top-level class))
  • content/docs/releases/v17/17-1.mdx (via applyTenantScope (literal, a string literal in aggregate))
  • content/docs/releases/v17/17-3.mdx (via IDataDriver (symbol, a top-level interface))
  • content/docs/releases/v17/17-5.mdx (via IDataDriver (symbol, a top-level interface), SqlDriver (symbol, a top-level class), generateSql (symbol, a method of class ObjectQLStrategy))
  • content/docs/releases/v17/17-6.mdx (via AnalyticsServicePlugin (symbol, a top-level class), SqlDriver (symbol, a top-level class))
  • content/docs/releases/v18/18-1.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/releases/v18/18-5.mdx (via SqlDriver (symbol, a top-level class))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 3 changed file(s) yielded no anchor (packages/spec/api-surface/contracts.json, packages/spec/authorable-surface/data.json, packages/spec/export-origins/contracts.json) — pages documenting those are invisible to this run
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 176 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 144cdc254e44ecd77f9d011714afaefdb2eecc32 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from b4bcee2bf151868c14aed89298cd35f3bfd04312 — the merge of head f9fa972988f4479ec681d3d56650ff957d73a428 into base 144cdc254e44ecd77f9d011714afaefdb2eecc32, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 144cdc254e44ecd77f9d011714afaefdb2eecc32 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W

席位核对

L1 first review · REWORK (1 item) · head 03414032f18a089c3b5759f627724f9511d36b22 · card #33697 · read 2026-11-17T00:14Z

Code read in parallel with CI, as the seat asked. At the reading this head had 13 success, 9 skipped, 22 in_progress and 1 failure: Check Changeset, which is item 1 below.

REWORK

  1. Metadata-protocol: none is wrong for this diff; the changeset level follows it. packages/spec/authorable-surface/data.json gains data/DriverCapabilities:zonedDateBucketing, a new authorable key, and AGENTS.md (Post-Task Checklist step 3) reads a new key as added, which takes at least minor on the package that carries it. Check Changeset (job 133712448234) refuses this head for exactly that: "it moves a metadata-protocol baseline the ratchets record … Declare Metadata-protocol: added … and grade the package at least minor". The sibling bit had the same shape: aggregationFilter (aggregate: a per-measure filter compiles to a conditional aggregate in the GROUP BY instead of the in-memory aggregate (epic #33631 R1) #33698, .changeset/33698-measure-filter-pushdown.md) shipped @objectstack/spec: minor with a non-none kind. Fix, in one commit:
    • PR body and changeset body: Metadata-protocol: added (keep Clause-②: yes (widening)).
    • .changeset/33697-pg-zoned-date-bucketing.md: '@objectstack/spec': minor.
    • PR body: the third line a non-none kind owes, Skills-docs: updated here | follow-up owed — FILES | follow-up #N | none — REASON. This is not a domain:skills PR, so updated here is not available; the area picks between follow-up #N and none — REASON (for example, if no skill teaches driver capability bits), and the seat files the card if it is a follow-up.
    • ⛔ No baseline edit to quiet the gate; the shard is right as generated.

Checklist (read on GitHub at this head, not from the report)

  • Shape: draft, base main, attribution header then Fixes #33697. Closing-keyword scan of the whole body: one hit, #33697 (PR docs(adr): ADR-0053 Phase 2 D2 amendment — a driver declaring zone-aware bucketing buckets a non-UTC timezone in the database #33774 is named without a keyword).
  • File surface: 25 files from get_files. All inside claim 6931083810 plus amendment 6933427092 (the extra driver-sql helpers, driver.zod.ts and driver.test.ts, the three service-analytics files), the generated spec artefacts (api-surface/contracts.json, export-origins/contracts.json, authorable-surface/data.json) and the three generated content/docs/references/data/driver*.mdx rows. No content/docs/releases/, no unrelated file. Merge commit f24d2262 brings main in; the three-dot diff holds only these 25.
  • Contract read (for the L1 side; the L2 judges it): DriverAggregateQuery is kept off DriverQuery, so find() / count() gain no key they would drop. The bit is ANDed with method presence in the engine (zoneNative reads drv?.supports?.zonedDateBucketing === true; ablation A3). The raw request string never reaches a driver: withBucketZone sends only judgeBucketZone's resolved area name.
  • Driver read: the zone is a bound value (AT TIME ZONE ?, bindings [field, timezone]); a Field.date keeps its calendar-day arm; every non-PostgreSQL dialect answers null for a zone. The GROUP BY names the select position when zoned (groupByRaw(String(selectPosition))); ablation A1 records PostgreSQL's 42803 when the expression is spelled twice. A direct aggregate() with a zone is judged before compiling: 501 on a dialect without the bit, 400 on a zone that is not its own resolved area name.
  • Behaviour moves that were in-memory before: Etc/UTC, GMT, Zulu, and any spelling that resolves to UTC, now take the native UTC path (ablation A4). Same buckets by construction; the enumeration pin moves them to the UTC class and says why.
  • Rejection assertions: the zoned matrix refuses CST, US/Eastern, +08:00, EST5EDT, Bogus/Zone and the SQLite dialect case with code and status (sql-driver-33697-zoned-date-bucket.test.ts:130-131, :205-206); the engine describe pins each spelling's dispatch.
  • Tests and controls: four ablations, each with what went red (A1 26, A2 16, A3 5, A4 3), plus a fixture-sensitivity pin keeping the parity non-vacuous. Live PostgreSQL 16 cell run locally (server Asia/Shanghai, process TZ=America/New_York). The three forced test changes are named in the body with the ruling they follow.
  • Changeset and docs sentences, checked against the diff: "SQLite (no tz database), MySQL, SQL Server and Oracle keep the in-memory path" (zonedDateBucketing: this.isPostgres; buildDateBucketExpr returns null for a zone off PostgreSQL); "refused NOT_IMPLEMENTED/501 … INVALID_QUERY/400" (refuseZonedDateBucket(…, 'dialect' | 'unresolved', …) in aggregate); "CST resolves to America/Chicago" (judgeBucketZone); the generated driver*.mdx rows carry the schema's .describe() string verbatim. Only the level and the kind in the changeset are wrong (item 1).
  • Landing tier: node scripts/pm/check-governed-merges.mjs --pr 34530: 0 of 25 paths governed, 967 changed lines (+860 / −107) ≤ 3000 ⇒ ordinary queue landing by the area after L1 ACCEPT and L2 PASS on the same green head.

Owed after this

  • L2: owed, CONTRACT_REVIEW_TIER. packages/spec/src/contracts/data-driver.ts, packages/spec/src/data/driver.zod.ts and packages/spec/src/data/data-engine.zod.ts are non-test packages/spec/src/**, plus Clause-②: yes (widening). The area reports it already sent to the review seat; the record has to name the head that lands, and item 1 moves the head.

Out of scope, for the area to place before ACCEPT (one line each: filed #N or dropped — reason)

  • Acceptance note 1: SQLite fixed-offset pushdown (the amendment's optional arm) not taken; "a follow-up card can measure it".
  • Acceptance note 2: the zone-resolution rule is written three times (judgeBucketZone in objectql, resolvedAreaZone in driver-sql, echoBucketZone in service-analytics); the body names @objectstack/core as its home, outside this card's surface. The engine and the echo are held together by the enumeration pin; the driver copy is not.

Next

L1 reads the delta only, on a head whose CI is green and announced final in a PR comment.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 03414032f18a089c3b5759f627724f9511d36b22
Local-runs: none
Scope: packages/spec/src/contracts/data-driver.ts, packages/spec/src/data/data-engine.zod.ts, packages/spec/src/data/driver.zod.ts + packages/objectql/src/engine-delete-and-aggregate.ts, packages/drivers/driver-sql/src/sql-driver-aggregation.ts, packages/drivers/driver-sql/src/sql-driver-date-bucket.ts, packages/drivers/driver-sql/src/sql-driver-top-level.ts, packages/drivers/driver-sql/src/sql-driver-class-head.ts, packages/drivers/driver-sql/src/sql-driver.ts, packages/services/service-analytics/src/strategies/objectql-strategy.ts, packages/services/service-analytics/src/plugin.ts, packages/services/service-analytics/src/strategies/types.ts, packages/services/service-analytics/src/analytics-service.ts

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): Check Changeset concluded FAILURE. Success: Governed Surface Queue Guard, Spec property liveness, PR-body guards, Lint PM dispatch-gates, Lint scoped tooling self-tests, Check Documentation Links, Flag docs affected, Check PR Size, Auto Label, filter, the two shard planners, Dogfood Regression Gate. Skipped: Temporal Conformance (live PG + MySQL), the dogfood shards, Dogfood Verify CLI, UI Published Artifacts, the queue verdicts, the opt-in harnesses. PENDING (in progress when read, no verdict): Test Core 1/8 to 8/8, Build Core, Build UI Deps, Build Docs, Live E2E UI, every Type Check job, Lint ESLint, Lint repo and tooling gates, Lint CI release and engine gates, Lint docs and code guards, both remaining scoped lints.

① Derived judgments

  • New public type DriverAggregateQuery (a DriverQuery plus optional timezone) exported from @objectstack/spec/contracts; api-surface and export-origins carry it. Right: additive, one export added, none removed.
  • IDataDriver.aggregate second parameter moves from DriverQuery to DriverAggregateQuery. Right as a widening: the new type is a subtype of the old, so an existing implementer declared with DriverQuery stays assignable and an existing caller passing a DriverQuery still compiles. The type-level proof is the Type Check jobs, PENDING on this head.
  • New accepted key supports.zonedDateBucketing (optional boolean) on DriverCapabilitiesSchema; the accept set widens by one key, the non-boolean value is refused, absence means false. Right, and it arrives with its engine reader in the same change, the bar the schema docblock and the amendment set for a new bit.
  • The authorable-surface baseline moves: packages/spec/authorable-surface/data.json gains data/DriverCapabilities:zonedDateBucketing. This is a key added to what an author can write. The PR declares Metadata-protocol: none over it. WRONG, see M1 in ②.
  • EngineAggregateOptions.timezone: schema unchanged (free string, optional), jsdoc only. Right. The dispatch behind it changes with no change to the answer contract: a name the runtime resolves to UTC now takes the native path (it took the in-memory path, same buckets), and an area/location zone goes to a declaring driver.
  • driver-sql aggregate() now refuses two inputs it used to answer as a UTC bucket: a zoned call on a dialect without the bit (501) and a zone string that is not its own resolved area/location name on PostgreSQL (400). Right: no engine path sent a timezone key to a driver before this change (the engine builds the AST key by key and never copied it), so no served request is narrowed; the refusal replaces a silent wrong answer for a direct caller only.
  • dateBucketSql gains an optional fourth argument on SqlDriver, the analytics plugin bridge, DatasetScopedStrategyContext and AnalyticsServiceConfig. Right: additive, not an IDataDriver member.

② Semver level

Clause-②: 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 Metadata-protocol: line do not match what the diff publishes. The changeset and the PR body both declare Metadata-protocol: none and grade every package patch, while the diff moves packages/spec/authorable-surface/data.json (a new key). AGENTS.md states a new key is added and that a kind takes at least minor on a package the diff moves; check-changeset-no-major.mjs states that a declared none may not move an authorable-surface/ baseline. The check-run Check Changeset on this head concluded FAILURE, which is that gate's verdict; I name the cause from the gate's written rule and the diff, the job log was not read. Precedent on main for the same shape: .changeset/33698-measure-filter-pushdown.md (the aggregationFilter bit) declares a kind and grades @objectstack/spec minor. Fix: Metadata-protocol: added in the changeset body and the PR body, and '@objectstack/spec': minor. The dev report's "128 derived gates, all exit 0" does not cover this: that axis is PR-scoped and has no input in a local run.

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

  • open_questions 1 (public names): answered, option A, keep zonedDateBucketing and DriverAggregateQuery. The bit name sits beside aggregationFilter and says what the driver does; the separate type is the sounder carrier, because find() and count() take DriverQuery and would declare a key they drop. DriverOptions.timezone is rightly left alone, it is the execution-context zone.
  • open_questions 2 (route to contract review): answered by this record.
  • Deviation, widened file surface: covered by the claim amendment 6933427092; every added file is in the claimed packages and no governed path is in the diff (Governed Surface Queue Guard: success).
  • Deviation, check-platform-checklist not run: accepted, one export added and none renamed or removed.
  • Review items (a) to (e) from the card: (a) held, see ④; (b) answered by not taking the optional SQLite arm, which the amendment permits ("may"); (c) held on all four named places; (d) held, both the engine and the echo compare the resolved name; (e) pinned in the new matrix and the engine dispatch test by the PR's account, test files being the lane's ACCEPT.
  • SQL push-down (standing check): no new id materialisation and no in-app join. The change moves work into SQL. The read scope and the tenant wall are untouched: both drv.aggregate call sites pass the same composed AST and the same aggregateOptions as before, and the zone is the only added key.
  • Security: the zone reaches the statement as a bound value in aggregate(); the raw request string never reaches a driver. security_findings: none is consistent with what I read.
  • out_of_scope finding, the resolution rule stated three times (engine, driver, echo): accepted as a deviation for this card; it has no carrier and should get a follow-up card, since only the engine and the echo are pinned together.
  • Card line "Before/after on the M0 bench": the PR carries no bench reading on this head; the figures in the card body are the M0 measurement. For the lane seat's ACCEPT, not graded here.

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:

  • What CI ran or will run on the head touches no PostgreSQL server. The Temporal Conformance job is skipped on every pull_request and merge_group event by its own condition, so the skip is by design, not a fault; it runs on push to main, on schedule and on workflow_dispatch. The PostgreSQL cells of the new matrix and the live analytics cell are opt-in on OS_TEST_POSTGRES_URL and skip in Test Core. So the pins that do run in PR CI are the SQLite cells (no bit, 501, UTC served), the engine dispatch pins against a stub driver, and string pins of the rendered expression. None executes the zoned statement.
  • The two facts the contract rests on are exactly the ones only a live server answers: that PostgreSQL accepts the zone as an untyped bound parameter in AT TIME ZONE with the bucket grouped by select-list position, and that its labels equal bucketDateKey across both Berlin DST changes, Taipei, and a Field.date under New_York. The amendment makes that parity the acceptance rule, "a test that fails".
  • The dev's local reading (PostgreSQL 16.15, server Asia/Shanghai, process America/New_York, 61 passed and 1 skipped, ablations A1 and A2 red) is the same environment the skipped job provisions, and by reading the SQL I find no reason to doubt it: the expression is the existing UTC arm with the zone in place of the literal, and ordinal GROUP BY is valid there. But it is a dev self-report, and the first witnessed execution would otherwise be the push run on main, where a red is a main red.
  • Reading owed: one witnessed run on the landing head of what the skipped job would have run, namely the driver-sql suite and the service-analytics suite with OS_TEST_POSTGRES_URL set against PostgreSQL 16 at Asia/Shanghai with TZ=America/New_York. Either a workflow_dispatch of ci.yml on the branch (the job's condition admits it) or the seat's own run, with the command and the counts recorded on the card, naming the head. It needs no code change; the delta record closes it on that reading.

④ Design judgment

packages/spec/src/contracts/data-driver.ts — holds against the amendment and its first consumer.

  • "The engine sets it only on a driver that declares the bit": true. withBucketZone adds the key only for kind area, and both call sites sit under nativeAggregate, which requires typeof drv.aggregate === 'function' and !tzRequiresInMemory; with kind area that is true only when supports.zonedDateBucketing === true. The relation-group-join statement takes the same wrapper.
  • "only the resolved name, never the raw string, never UTC": true. judgeBucketZone returns the resolvedOptions().timeZone value, maps a resolved UTC to the native path with no key, and the aggregate AST is built key by key, so the request's own timezone cannot ride it.
  • "refuses a zone it cannot bucket rather than reading it as UTC": true for driver-sql, judged before anything compiles.
  • The aggregate jsdoc sentence that replaced "a driver never sees it" agrees with the engine fork.

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 applyInMemoryAggregation; Field.date is never zone-shifted (calendarDay wins over the zone in the PostgreSQL arm); the zone is a bound value; SqlDriver declares it as this.isPostgres, so SQLite, MySQL, SQL Server, Oracle and TursoDriver read false. The "why a bit" paragraph matches the amendment's own reason.

packages/spec/src/data/data-engine.zod.ts — holds. The rewritten timezone jsdoc states the three-way reading the engine implements and the amendment's test (throws or no / stays in memory; otherwise push down the resolved name).

Attempts to break the design, each read in the head tree:

  • Review item (a), one binding: the zoned bucket is selected once and grouped by selectPosition. The counter increments exactly for the items that add a select column, in the same loop, before any aggregation or relation-join column is selected, and getBuilder pre-selects nothing, so the ordinal is the bucket's column also after a plain key, with an alias equal to the field name, with two buckets, and in the relation-join statement. The ordinal arm is reachable on PostgreSQL only, since every other dialect refuses a zone first. No ORDER BY or second spelling of the bucket exists in this door.
  • Cast direction: (col)::timestamptz AT TIME ZONE ? is the amendment's rule verbatim, with the cast.
  • Engine and driver disagreeing on a name: both resolve through the same runtime in the same process and resolution is idempotent, so a name the engine sends always passes the driver's own check. A runtime that canonicalises differently changes which of the three roads a spelling takes, not the buckets: each road answers the zone's own calendar.
  • A direct caller around the engine: empty string, Etc/UTC, an abbreviation, an offset and an unresolvable name are all refused 400 on PostgreSQL; any zone is refused 501 elsewhere; UTC and a query with no date bucket are served as before.
  • The dry run: echoBucketZone is the same predicate as the engine's; a UTC alias asks the hook with no zone, an area zone asks with the resolved name, and a driver that answers nothing for it yields the zone refusal. The printed statement renders the zone as an escaped literal and so groups by identical text.
  • Security: same AST, same options, same WHERE on both roads.
  • Residual, recorded by the amendment and not a finding: a resolved name that the server's tz database lacks (two copies of tz data) is a query the database rejects rather than one bucketed in memory.

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:

  • N1 — the DriverAggregateQuery jsdoc obliges "a driver that reads it" to refuse; it is silent on a non-declaring driver handed a zone by a direct caller. driver-sql refuses; no other driver is touched by this diff. One sentence, or a follow-up card.
  • N2 — EST5EDT, GMT and Zulu are stated flatly as examples in the two schema docblocks; which spelling resolves to what is the runtime's tz data (the amendment says "measured on Node 22"). The rule itself is runtime-relative and stays correct.
  • N3 — dateBucketSql is asked with a fourth argument; a structural implementer that ignores it would answer its UTC expression for a zoned ask. Both in-repo implementers answer null. The hook's jsdoc could say an implementer must answer nothing for a zone it does not bucket.

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: claude/project-thread-tf8gon
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmQAXHSQEgnYyx9tstb

Final head for review: 6784558d43e1b4495dc39fb877f066f9e4018a42 — CI complete, 0 failed. Since 03414032: changeset Metadata-protocol: added / @objectstack/spec minor (L2 M1, L1 item 1), the L2 nits N1–N3 (jsdoc), and a merge of origin/main carrying #34517 (lockRows): both bits coexist, the audit pin reads 7 live bits + 31 tombstones, generated files regenerated. Live PostgreSQL witness at this head (L2 S1): card #33697 comment 6935873746.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 6784558 · 2026-11-17T02:44Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W

席位核对

L1 delta · ACCEPT · head 6784558d43e1b4495dc39fb877f066f9e4018a42 (delta over 03414032, my REWORK 6933484440's head) · card #33697 · read 2026-11-17T02:45Z

Delta read (03414032..6784558d: 3 commits and a merge of main)

  • REWORK item 1, closed.
    • 9f3caa4e / 2b76c7f4: the changeset grades @objectstack/spec minor and reads Metadata-protocol: added. It names the key (supports.zonedDateBucketing) and the shard that records it.
    • The PR body opens with the attribution lines, then Fixes #33697, Clause-②: yes (widening), Metadata-protocol: added, and Skills-docs: none — no skill under skills/** teaches driver capability bits …. That reason holds: the bit is read by the engine, and an app author writes the same timezone as before.
    • Check Changeset and Spec property liveness are success at this head. No baseline was hand-edited; the shard moves only by regeneration.
  • Out-of-scope dispositions, both placed in the body:
    • SQLite fixed-offset pushdown: dropped. The reason is stated: no measured pull, only Etc/GMT±N zones are fixed over all history, and the in-memory path stays correct.
    • The zone-resolution rule in three copies: filed #34544 (open).
  • a7761658, L2 nits N1–N3, docblocks only. The sentences, checked against the code:
    • data-driver.ts: "a driver that does NOT declare the bit … handed one by a direct caller, refuses the zone the same way (driver-sql: NOT_IMPLEMENTED / 501)". This matches aggregate()'s refuseZonedDateBucket(…, 'dialect', …) on a non-PostgreSQL dialect, read at the first review.
    • driver.zod.ts and data-engine.zod.ts: the spellings are examples as Node 22 resolves them, and the rule is the runtime's resolution. This matches judgeBucketZone, which resolves through the runtime and keeps no list.
    • service-analytics types.ts: an implementer that does not bucket the asked zone answers undefined, never its UTC expression. This is a duty on implementers and moves no code.
    • No executable line moves in these three commits.
  • The merge of main (6784558d, brings fix(spec, objectql, driver-sql): a predicate delete with a cascade locks the rows it walks #34517 lockRows). I compared it against its main parent b0190483:
    • The diff is the same 25 files at +869 / −107 that get_files lists, and it moves no lockRows line in driver.zod.ts, sql-driver.ts or engine-delete-and-aggregate.ts.
    • sql-driver.ts declares aggregationFilter: true, lockRows: true and zonedDateBucketing: this.isPostgres side by side.
    • The audit pin reads 7 live bits + 31 tombstones, with lockRows sixth and zonedDateBucketing seventh. Both bits keep their absent-key and non-boolean pins.
    • The three generated driver*.mdx files carry both rows, and Build Docs is success.
    • This settles the serial order my fix(spec, objectql, driver-sql): a predicate delete with a cascade locks the rows it walks #34517 review (6934544391) set: this PR is the second to land, and it merged, regenerated and moved the pin as required.
  • Live PostgreSQL witness (L2 S1): card comment 6935873746, at this head. PostgreSQL 16.15, server Asia/Shanghai, process TZ=America/New_York, run under the verify lock; the area reports driver-sql 5520 and service-analytics 5835 passed. This is a local reading. No check-run on a pull request runs the live cells (Temporal Conformance is skipped on PRs), and the comment says so.
  • Gates at this head: check-runs on 6784558d…: 68 runs, 58 success, 10 skipped, 0 failed. Lint & Repo Gates, TypeScript Type Check, Dogfood Regression Gate, Check Changeset, Spec property liveness and Build Docs are all success. The final head is announced in 6936386105. GitHub reads the PR mergeable: clean.

The first-review checklist (6933484440) stands for everything outside this delta.

Owed after this

  • L2: owed on this head, CONTRACT_REVIEW_TIER (non-test packages/spec/src/**, plus Clause-②: yes). The merge moved driver.zod.ts, driver.test.ts, sql-driver.ts and the generated docs, so this head is not a clean merge and the record must name it. The area reports it went to the review seat; the seat routes it.
  • Landing tier: node scripts/pm/check-governed-merges.mjs --pr 34530: 0 of 25 paths governed, 976 changed lines (+869 / −107) ≤ 3000. This is an ordinary queue landing by the area, once the L2 PASS names this head.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 6784558d43e1b4495dc39fb877f066f9e4018a42
Local-runs: none
Scope: packages/spec/src/contracts/data-driver.ts, packages/spec/src/data/data-engine.zod.ts, packages/spec/src/data/driver.zod.ts + packages/objectql/src/engine-delete-and-aggregate.ts, packages/drivers/driver-sql/src/sql-driver-aggregation.ts, packages/drivers/driver-sql/src/sql-driver-date-bucket.ts, packages/drivers/driver-sql/src/sql-driver-top-level.ts, packages/drivers/driver-sql/src/sql-driver-class-head.ts, packages/drivers/driver-sql/src/sql-driver.ts, packages/services/service-analytics/src/strategies/objectql-strategy.ts, packages/services/service-analytics/src/plugin.ts, packages/services/service-analytics/src/strategies/types.ts, packages/services/service-analytics/src/analytics-service.ts

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, lockRows) meets those files.

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, driver.zod.ts, driver.test.ts, data-driver.ts, the supports getter in sql-driver.ts, the three generated driver*.mdx pages, authorable-surface/data.json, the api-surface and export-origins shards; for the merge, each conflict-prone file compared four ways (main to head, previous tip to head, and each side against the merge base); the aggregate() doors of driver-mongodb, driver-memory and driver-turso; skills/objectstack-query/rules/aggregation.md; the Temporal Conformance job condition in .github/workflows/ci.yml. Commits since the old head: 9f3caa4, 2b76c7f, a776165 and the merge 6784558 (parents a776165 and main at b019048).

Check-runs on this head (68, all completed): 0 failure, 0 pending, 10 skipped, 58 success. Check Changeset: success. Also success: Test Core 1/8 to 8/8 and its roll-up, every Type Check job, Build Core, Build Docs, Build UI Deps, every Lint job, Spec property liveness, Governed Surface Queue Guard, PR-body guards, Live E2E UI, Test UI 1/16 to 16/16. Skipped: Temporal Conformance (live PG + MySQL), Lint UI, UI Published Artifacts, the dogfood shards, Dogfood Verify CLI, the two queue verdicts, the schedule gate, the two opt-in harnesses.

① Derived judgments

  • Nothing in the published shape of this PR moved between the heads. DriverAggregateQuery, IDataDriver.aggregate's parameter, supports.zonedDateBucketing and the dateBucketSql fourth argument are as the previous record judged them; the delta in the three scope files is jsdoc (N1 to N3) plus main's lockRows text arriving by the merge. The Type Check jobs, pending last time, concluded success, which is the type-level proof the widening of aggregate's parameter was waiting on.
  • The merge with fix(spec, objectql, driver-sql): a predicate delete with a cascade locks the rows it walks #34517, read file by file. For driver.zod.ts, sql-driver.ts, engine-delete-and-aggregate.ts, authorable-surface/data.json and driver.mdx, the main-to-head change has exactly the size of this PR's own side and the previous-tip-to-head change has exactly the size of main's side: neither side lost or gained a line in the resolution. driver.test.ts differs by one line on each comparison, and that line is the count itself (see next item). Right.
  • Both bits are present exactly once where each must be: one schema key each in DriverCapabilitiesSchema (lockRows then zonedDateBucketing, after aggregationFilter), one bullet each in the surviving-contract docblock, one entry each in LIVE_BITS, one line each in SqlDriver.supports (lockRows: true, zonedDateBucketing: this.isPostgres), one row each per capability table in the three generated pages (two tables in driver.mdx), and one data/DriverCapabilities: line each in the authorable surface. DriverOptions.lockRows (main's) is also present once in the schema, the surface and the DriverOptions table. Right.
  • The count 7 is consistent: the schema declares seven live boolean-or-record keys (queryDateGranularity, autonumber, batchSchemaSync, transactionsUnsupported, aggregationFilter, lockRows, zonedDateBucketing); LIVE_BITS lists the same seven; the audit pin's title reads 7 live bits + 31 tombstones; the tsc-channel comment reads 7; the list comment calls lockRows the sixth and zonedDateBucketing the seventh. The pin compares the walked key set to the two lists, so a duplicate or a dropped key would be a red Test Core, and Test Core is green on this head.
  • Generated faces agree with the source at this head: the zonedDateBucketing and lockRows rows carry the schema's describe strings verbatim and in schema order; the authorable surface gains exactly data/DriverCapabilities:zonedDateBucketing against main; api-surface and export-origins still carry DriverAggregateQuery and were not moved by the merge.

② Semver level

Clause-②: yes (widening) — unchanged and still right.

M1: closed — the changeset front matter now grades @objectstack/spec minor and the other three packages patch; its line-initial Metadata-protocol: line reads added and names the key and the baseline file; the PR body's Clause-②: and Metadata-protocol: lines agree with it; the claim was corrected on the card (6933531393); Check Changeset concluded success on this head. The level matches what the diff publishes: one authorable key added, one exported type added, nothing narrowed.

S2 (should-fix) — the Skills-docs: line is not true of the tree. The PR body and the changeset both read Skills-docs: none, with the reason that no skill under skills/** teaches driver capability bits or where a zoned date bucket runs. skills/objectstack-query/rules/aggregation.md (the Filtered Aggregation note, lines 122 to 126 at this head) does both: it names supports.aggregationFilter and which drivers declare it, and it states that a date bucket under a non-UTC timezone keeps the whole call in memory. This PR makes that sentence false on PostgreSQL: with an area/location zone and the bit declared, nativeAggregate is true and the call, filtered measures included, goes to the database. The dispatch rule requires the line to be present and true, and gives a non-skills PR the follow-up #N form for exactly this. Fix: file the follow-up card for that skill file and write Skills-docs: follow-up #N in the PR body and in the changeset body, so the released note does not carry the untrue reason. No code moves. If the changeset edit is the only change, the witness on this head carries to the new head, since no file a test reads would differ.

③ Boundary flags

S1: 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 TZ=America/New_York, OS_TEST_POSTGRES_URL set; the driver-sql suite exit 0 with 5520 passed and 129 skipped, in which the #33697 matrix is 62 tests, 61 passed, 1 skipped; the service-analytics suite exit 0 with 5835 passed and 34 skipped, the live PostgreSQL echo cell among them. For MySQL it says plainly what ran: nothing live (not provisioned, the one skip), and the SQLite cells that pin the same no-bit refusal ran; SQL Server and Oracle likewise unmeasured. The matrix count is itself evidence the PostgreSQL cells ran: without the URL that describe is a named skip and the file could not show 61 passes. Neither test file moved between the heads, so the cells are the ones the previous record described.

  • What this can and cannot establish: it is a statement by the implementing card thread, not a CI verdict and not an independent run. Temporal Conformance did not run on this head; it is skipped on pull requests by its own condition, as before. The statement is specific, internally consistent, on the landing head, and matches the SQL as read; that is the reading S1 named as sufficient, so S1 closes on it.

  • Landing note that follows from the limit: the first CI execution of the zoned statement is the Temporal Conformance run on the push to main. The seat that lands this reads that run's conclusion.

  • The merge brings main's lockRows hunk into engine-delete-and-aggregate.ts. It sits in the predicate-delete path and shares no line with this PR's aggregate fork; the read scope, the tenant wall and the options passed to drv.aggregate are as judged before.

  • SQL push-down (standing check): nothing in the delta adds an id materialisation or an in-app join.

  • Follow-up for the resolution rule stated three times: now carried, aggregate timezone: the zone resolution rule is written three times (engine, driver-sql, analytics echo) and only two are pinned together #34544, named in the PR body. Accepted.

  • The SQLite fixed-offset arm: disposition recorded in the PR body as dropped with its reason. Accepted, the amendment makes the arm optional.

④ Design judgment

Short, because the design did not move: between the heads the three scope files changed only in jsdoc and in main's own lockRows text, and the implementing files changed only by main's hunk. The previous record's ④ stands for this head; what follows judges each new sentence against the code.

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: withBucketZone adds the key only under zoneNative, which requires the bit. The second half is true of driver-sql on every non-PostgreSQL dialect (501, judged before anything compiles) and of driver-turso through it, and moot for driver-memory, whose aggregate buckets no dates. It is not true of driver-mongodb: that driver publishes queryDateGranularity, lowers a date bucket in UTC, and reads no timezone, so a direct caller that hands it a zone gets the UTC bucket. No engine path reaches this. See N1 below.

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: judgeBucketZone, resolvedAreaZone and echoBucketZone all decide on resolvedOptions().timeZone, and no list of spellings exists in the code. The merged lockRows docblocks are main's text, unaltered by the resolution.

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 undefined, never its UTC expression. True of both in-repo implementers: the plugin bridge passes the zone through and turns any non-string answer into undefined, and SqlDriver.dateBucketSql answers nothing for a zone off PostgreSQL.

④ adds no graded finding. The one graded finding on this head is S2 (②).

Nits, no effect on correctness or the contract:

  • N1 — carried in a narrower form. The added sentence is written as a fact about every non-declaring driver and holds for driver-sql only; driver-mongodb answers the UTC bucket to a direct caller that passes a zone. Either word it as what such a driver owes, naming driver-sql as the one that does it today, or file a card for driver-mongodb to refuse. The docblock above supports in mongodb-driver.ts also still says the engine keeps every non-UTC zone in memory and that the AST carries no timezone at all; true for that driver, no longer true as a general statement. Outside this PR's files.
  • N2: closed.
  • N3: closed.
  • N4 — the PR body's Tests section still says the audited shape is 6 live bits (was 5); at this head it is 7. Its Verification section gives the old head's counts and names head 0341403 for the derived gates; the witness on the card holds the counts for this head. Prose only.

Implemented-by: claude/project-thread-tf8gon
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head f9fa972 · 2026-11-17T02:56Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: f9fa972988f4479ec681d3d56650ff957d73a428
Local-runs: none
Scope: packages/spec/src/contracts/data-driver.ts, packages/spec/src/data/data-engine.zod.ts, packages/spec/src/data/driver.zod.ts + packages/objectql/src/engine-delete-and-aggregate.ts, packages/drivers/driver-sql/src/sql-driver-aggregation.ts, packages/drivers/driver-sql/src/sql-driver-date-bucket.ts, packages/drivers/driver-sql/src/sql-driver-top-level.ts, packages/drivers/driver-sql/src/sql-driver-class-head.ts, packages/drivers/driver-sql/src/sql-driver.ts, packages/services/service-analytics/src/strategies/objectql-strategy.ts, packages/services/service-analytics/src/plugin.ts, packages/services/service-analytics/src/strategies/types.ts, packages/services/service-analytics/src/analytics-service.ts

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; skills/objectstack-query/rules/aggregation.md at this head (the Filtered Aggregation note); PR #34530 body, its 9 comments and its check-runs on this head; card #33697 and its 10 comments, the witness 6935873746 among them; cards #34597 and #34598, body and triage comment each; the tests in the tree that name .changeset.

The delta, from the tree: one commit, f9fa972, one file, .changeset/33697-pg-zoned-date-bucketing.md, one line removed and one added. The Skills-docs: line goes from none with its reason to Skills-docs: follow-up #34597. The front matter, the Clause-②: and Metadata-protocol: lines and the release prose are byte-identical. No file in Scope moved, no test file moved, no generated baseline moved. The PR is still 25 files against its merge base b019048, which is also the base the PR names.

Check-runs on this head (37 listed at the reading): 0 failure, 10 success, 9 skipped, 18 pending. Pending is not a verdict. Pending: Check Changeset, Build Core, Build Docs, Build UI Deps, Plan Test Core shards, Plan Test UI shards, Live E2E UI, the four Type Check jobs (workspace, source gates, consumer gates, debt ledger), and seven Lint jobs (ESLint, repo and tooling gates, docs and code guards, CI release and engine gates, PM dispatch-gates, scoped slot lookup and corpus, scoped query-options erasure). The Test Core and Test UI shards are not listed yet; they are created after the two plan jobs. Success: PR-body guards, Spec property liveness, Governed Surface Queue Guard, Dogfood Regression Gate, Lint scoped tooling self-tests, Check Documentation Links, Check PR Size, Flag docs affected by code changes, Auto Label, filter. Skipped: Temporal Conformance (live PG + MySQL), UI Published Artifacts, the dogfood matrix shard, Dogfood Verify CLI, the two queue verdicts, the schedule gate, the two opt-in harnesses.

① Derived judgments

  • Nothing derived moved, because nothing a derivation reads moved. The exported types, the capability schema, the generated reference pages, the authorable surface, the api-surface and export-origins shards are the bytes the previous record judged; its ① stands for this head unchanged.
  • The one consequence of the changed line is the declaration itself, judged under ②.

② Semver level

Clause-②: yes (widening) — unchanged and still right. The changeset still grades @objectstack/spec minor and the other three packages patch, and Metadata-protocol: added still names the key and the baseline file. The delta publishes nothing new.

S2: closed — read against the tree and the cards, not the account.

③ Boundary flags

  • The witness carries. The reading on the card (6935873746) names head 6784558; the only bytes that differ at this head are one line of a changeset. The two suites it ran, driver-sql and service-analytics, hold no test that reads .changeset. The tests elsewhere that walk the tree either do not reach that directory (the retirement walks cover packages, examples, skills, content and scripts) or exclude it by name, and the new text adds a card number and no identifier any pin searches for. So every test that was green on the previous head reads the same inputs here. The limit the previous record stated still holds: the witness is a statement by the implementing thread, and Temporal Conformance is skipped on pull requests.
  • The one gate whose input did move is Check Changeset, and it is pending. It concluded success on the previous head with the same front matter; the edit is in the body. The seat that lands this reads its conclusion on this head, with the other 17 pending runs and the Test Core roll-up once created.
  • Landing note carried from the previous record: the first CI execution of the zoned statement is the Temporal Conformance run on the push to main; the landing seat reads it.
  • SQL push-down (standing check): no code moved; nothing adds an id materialisation or an in-app join.

④ Design judgment

Short, 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.

  • N1: closed by carrier, driver-mongodb: a direct call with a non-UTC timezone buckets dates in UTC with no refusal, and the docblock says otherwise #34598. Its body carries both halves: a direct caller that hands driver-mongodb a timezone gets UTC buckets with no refusal, and the docblock in packages/drivers/driver-mongodb/src/mongodb-driver.ts is out of date. Its Change section also takes the data-driver.ts sentence, either by making the driver refuse or bucket, or by correcting the sentence. It says the engine path is unaffected, which is right. Open, Blocked-by: #33697, graded p3 by triage with the reason given; the PR body names it under Acceptance notes.
  • N4: closed. The PR body's Tests section now reads 7 live bits + 31 tombstones, 5 before this PR, with lockRows named as the other new one; that matches the schema and the pin. Its Verification section labels the old counts as read on head 0341403 and points to card comment 6935873746 for the counts after the merge of main. That comment names head 6784558, one changeset line behind this head, which is the carry judged in ③.

Nits, no effect on correctness or the contract:

No must-fix, no should-fix.

Implemented-by: claude/project-thread-tf8gon
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W

席位核对

L1 delta · ACCEPT · head f9fa972988f4479ec681d3d56650ff957d73a428 (delta over 6784558d, my ACCEPT 6936419294, which this replaces for the landing head) · card #33697 · read 2026-11-17T03:25Z

Correction to my earlier reading

In 6936419294 (and in my first review, 6933484440) I accepted Skills-docs: none and its stated reason. That was wrong. As the L2 delta record 6936523534 (S2) found, skills/objectstack-query/rules/aggregation.md › Filtered Aggregation teaches where a zoned date bucket runs. It says a date bucket under a non-UTC timezone keeps the whole call in memory, and this PR makes that false on PostgreSQL.

Delta read (git diff 6784558d f9fa9729: 1 commit, 1 file, +1 / −1)

The first-review checklist (6933484440) and the delta read 6936419294 stand for everything outside this delta, except the Skills-docs acceptance corrected above.

Owed after this

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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 packages/spec data-driver contract (packages/spec/src/contracts/data-driver.ts, driver.zod.ts, data-engine.zod.ts), and spec contracts go to a human approver even though the register finds no governed path.

维护者速读

  • 改了什么:PostgreSQL 上按非 UTC 时区(比如 Asia/Taipei、Europe/Berlin)做日、周、月、季、年分组,现在在数据库里用 AT TIME ZONE 分桶,不再把整批行拉进应用内存。SQLite、MySQL 等其余驱动照旧在内存分桶。驱动通过新的能力位 supports.zonedDateBucketing 声明自己会不会这样做。
  • 为什么改:执行你的裁决「PG 在库里算,修订 ADR」(ADR-0053 D2 的修订已合)。多数用户不在 UTC,他们的日报、月报以前都走慢路径。
  • 风险与回滚:只改分桶表达式,权限范围和租户墙仍在同一条 WHERE 里。库内结果和内存结果逐桶对等(PG 16 实测,含柏林两次夏令时切换)。回滚即 revert,引擎自动回到内存路径。
  • 先看:packages/spec/src/contracts/data-driver.ts(新契约类型)、packages/drivers/driver-sql/src/sql-driver-aggregation.ts(时区只绑定一次)、packages/objectql/src/engine-delete-and-aggregate.ts(按解析后的时区名分派)。
  • 两分钟验证:起一个 PG(服务器时区 Asia/Shanghai),跑 OS_TEST_POSTGRES_URL=… pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-33697-zoned-date-bucket.test.ts,预期 61 过、1 跳过(没配 MySQL)。
  • 需要你做的:审读并批准这次契约放宽。契约审核 PASS 是 6936695062,Head-sha f9fa972988f4479ec681d3d56650ff957d73a428。

席位意见:同意合并。这是执行你已下的裁决,结果和内存路径逐桶对等,不支持的驱动行为不变。

席位核对

  1. 形态:25 个文件,+869/−107,Fixes #33697;Clause-②: yes (widening),Metadata-protocol: added,Skills-docs: follow-up #34597。
  2. 前提实测:dev 在 PG 16 上实测库内与内存逐桶对等,含夏令时切换;MySQL 未配,所以跳过。
  3. 门禁 check-runs:head f9fa9729 上 68 条,58 绿、10 跳、0 红;mergeable_state clean(席位 03:26Z 实读)。和 fix(spec, objectql, driver-sql): a predicate delete with a cascade locks the rows it walks #34517 的能力位冲突已按约定处理:本 PR 后落,已合 main、重新生成,钉子改为 7 位。
  4. 接受的偏差:无。L1-b delta ACCEPT 6937168520 和契约审核 delta PASS 6936695062 都在本 head;L1-b 早先放行 Skills-docs: none 有误,已在 6937168520 里更正。
  5. 范围外去向:技能文档改写是 skills/objectstack-query aggregation.md: a zoned date bucket no longer always stays in memory once PostgreSQL buckets it in the database (#33697) #34597;MongoDB 驱动被直接调用时忽略时区是 driver-mongodb: a direct call with a non-UTC timezone buckets dates in UTC with no refusal, and the docblock says otherwise #34598。
  6. 落地条款:授权批准在案后,席位翻 ready,经合并队列落地;合并后区 o2-F 清 aggregate: PostgreSQL buckets a non-UTC timezone in the database (amend ADR-0053 D2; SQLite keeps DST zones in memory) — epic #33631 R6 #33697 上的 pm 状态,skills/objectstack-query aggregation.md: a zoned date bucket no longer always stays in memory once PostgreSQL buckets it in the database (#33697) #34597、driver-mongodb: a direct call with a non-UTC timezone buckets dates in UTC with no refusal, and the docblock says otherwise #34598 由分诊放回。feat(objectql): refuse a nested-relation condition and a lookup dimension up front on a driver without the readableIdsLeaf capability #34565(readableIdsLeaf,能力位第 8 位)在本 PR 之后落,要合 main 并重新生成。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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 f9fa9729. pm:awaiting-merge is added in this stroke, and the reviewers are requested in the same round.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 17, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 17, 2026 04:29
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit d635555 Nov 17, 2026
74 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-tf8gon branch November 17, 2026 04:59
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:data size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aggregate: PostgreSQL buckets a non-UTC timezone in the database (amend ADR-0053 D2; SQLite keeps DST zones in memory) — epic #33631 R6

3 participants