Skip to content

Commit 367e324

Browse files
docs(skills): a zoned date bucket stays in memory only where the driver cannot bucket that zone (#35012)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ Fixes #34597 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:查询技能 `aggregation.md` 里一句话,原来说「非 UTC 时区的日期分桶会让整次聚合在内存里算」,现在改成:声明了 `supports.zonedDateBucketing` 的驱动(目前只有 driver-sql 的 PostgreSQL)在时区能解析成地区/城市名时直接在库里分桶;其它驱动、以及 `+08:00`、`EST5EDT` 这类解析不出地区的时区,仍整次在内存里算。另加一条 eval。 - 为什么改:#33697 合并后 PostgreSQL 已经在库里算带时区的分桶,旧句子对 PG 是错的,AI 读技能会对性能和 `aggregationFilter` 行为做出错误判断。 - 风险与回滚:只改对外发布的技能文字和 eval,不动代码;回滚就是还原这一个 PR。 - 先看:`skills/objectstack-query/rules/aggregation.md` 第 127–131 行(新句子),`skills/objectstack-query/evals/filters-pagination-search.json` 的 eval 9,`.changeset/34597-skills-zoned-date-bucket.md`。 - 两分钟验证:`node scripts/check-skills-token-ratchet.mjs`,预期看到 `aggregation.md is 2346 tokens (ceiling 2357; headroom 11)` 且整体通过。 - 需要你做的:无,席位落地(`skills/**` 属受治理面,按其档位记录落地)。 ## What changes `skills/objectstack-query/rules/aggregation.md`, section "Filtered Aggregation (FILTER WHERE)": the parenthetical that said a date bucket under a non-UTC `timezone` keeps the whole call in memory now matches the merged engine. - Old: "(a date bucket under a non-UTC `timezone`, or one the driver does not bucket natively, keeps the whole call in memory)" - New: "(a date bucket the driver does not bucket natively keeps the whole call in memory; so does one under a non-UTC `timezone`, unless the driver declares `supports.zonedDateBucketing` — PostgreSQL via `driver-sql` — and the zone resolves to an area/location: `Asia/Taipei` buckets in the database, `+08:00` or `EST5EDT` never)" Sources, read at `origin/main` 4443014: `packages/objectql/src/engine-delete-and-aggregate.ts` lines 1435–1459 (`judgeBucketZone`, `zoneNative`, `tzRequiresInMemory`, which gates `nativeAggregate` at line 1488) and `packages/drivers/driver-sql/src/sql-driver.ts` line 409 (`zonedDateBucketing: this.isPostgres`). `skills/objectstack-query/evals/filters-pagination-search.json`: new eval case 9 (monthly revenue on Taipei calendar months with a filtered count; PostgreSQL vs SQLite vs `+08:00`). No earlier case exercised the sentence. `.changeset/34597-skills-zoned-date-bucket.md`: `@objectstack/skills` patch, the same shape as the earlier skills-text notes. ## Why #33697 (ADR-0053 Phase 2 D2 as amended, maintainer ruling 「PG 在库里算,修订 ADR」) made PostgreSQL bucket a zoned date in the database. The skill still told authors and agents the whole call runs in memory, which is false on PostgreSQL for an area/location zone. ## Tests No code changed, so there is no unit test or ablation. Eval check by script at head 2555c75: case ids 1–9 distinct; every `must_contain` of every case appears in its `expected_output`; no `must_not_contain` appears in it (0 violations). Skills readings (lines): `aggregation.md` 272 → 275; eval file 85 → 95 (unpriced, population 1b); sum of all `SKILL.md` 4730 → 4730 (unchanged); all `skills/**/*.md` 18128 → 18131. Tokens: `aggregation.md` 2292 → 2346 against ceiling 2357 (headroom 11), paid from existing headroom; no ceiling row moved. ## Acceptance notes - `dispatch-gates --tier` derives a mandatory contract-review authoring tier for `skills/**`. The claim's `Container & model` line records `TIER_DEFAULT`, and this run was served at that tier, so this body carries no `Served-tier: CONTRACT_REVIEW_TIER` line. The seat decides the review route. - Grepped `skills/objectstack-query/**` (SKILL.md, rules, references) for the same claim: no other sentence says a zoned bucket always stays in memory. `rules/aggregation.md` § Date-Bucketed Grouping does not mention `timezone` at all; it is not the same false claim and is left as is. - Observation, not filed: `content/docs/data-modeling/queries.mdx` (Date-bucketed grouping callout) says the SQL driver ignores a structured `groupBy` `alias`, while the skill says results are correct either way "including the column keys". Not measured on a public door; outside this card's file surface. ## Verification Local targeted gates at head 2555c75: 46 derived by `node scripts/pm/dispatch-gates.mjs --commands`, plus `check:skill-examples`, `check:skill-docs`, `check:skill-refs` (the `os:check` and skill-doc gates). `dispatch-gates --ran`: 46 accounted — 45 run, 1 NOT MEASURED. <details><summary>Gate readings</summary> - 48 commands exit 0, including `node scripts/check-skills-token-ratchet.mjs` (and `--self-test`), `pnpm check:skill-links`, `pnpm check:skill-identifier-liveness`, `pnpm check:skill-compatibility`, `pnpm check:skill-frame-sync`, `pnpm check:doc-authoring`, `pnpm check:nul-bytes`, `pnpm check:published-files`, `node scripts/check-empty-changeset.mjs --base origin/main`, `node scripts/check-changeset-no-major.mjs --base origin/main`, `node scripts/check-adr-0087-registration.mjs --base origin/main`, `pnpm --filter @objectstack/spec check:skill-examples`, `check:skill-docs`, `check:skill-refs`. - `pnpm check:dual-build-cjs-loads`: exit 3, PREREQUISITE NOT MET (needs a full build). NOT MEASURED locally; CI runs it. - `node scripts/pm/overlap-check.mjs --branch=claude/issue-34597-aggregation-zoned-bucket`: `VERDICT clean exit 0` (merges cleanly into origin/main; no PR head collides). - Builds under the verify lock: `@objectstack/lint...` and `@objectstack/client-react...`, both `VERDICT command-exit 0`. </details> ## Fix round 2 (seat contract review 6963664711) - S1 (should-fix): eval case 9's `must_not_contain` held `timezone: '+08:00'`. The case's own prompt asks about passing `+08:00`, and the grader matches substrings, so a correct answer restating it as code would fail. Dropped that one token; `must_not_contain` is now `["date_trunc"]`. `must_contain` (`timezone: 'Asia/Taipei'`, `in memory`, the rest) and N1/N2 are unchanged; `aggregation.md` is unchanged. - Head 6465f93. Eval script check: ids 1-9 distinct, 0 violations. `check-skills-token-ratchet` (+`--self-test`), `check:nul-bytes`, `check:skill-links`, `check:skill-identifier-liveness`, `check:skill-compatibility`, `check:skill-frame-sync`, `check:doc-authoring`, `check:published-files`, `check:corpus-claim-drift`, `check:role-word`, `check:pm-skill-id-lint`: all exit 0. `overlap-check`: VERDICT clean exit 0. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. (no code changed; the repo-wide lint run is CI's) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9089728 commit 367e324

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the query skill says where a zoned date bucket is computed
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
objectstack-query's `rules/aggregation.md` no longer says a date bucket under a non-UTC `timezone` always keeps the whole aggregate call in memory. A driver that declares `supports.zonedDateBucketing` (PostgreSQL via `driver-sql`) buckets the date in the database when the zone resolves to an area/location (`Asia/Taipei`); on every other driver, and for a zone that resolves to none (`+08:00`, `EST5EDT`), the whole call still runs in memory. One eval case covers the sentence.

‎skills/objectstack-query/evals/filters-pagination-search.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@
8080
"must_contain": ["filter", "$or", "$lte: 0", "$null: true"],
8181
"must_not_contain": []
8282
}
83+
},
84+
{
85+
"id": 9,
86+
"prompt": "Monthly deal revenue on Taipei calendar months, plus a count of won deals per month, in one aggregate call. Does the database do the bucketing, on PostgreSQL and on SQLite? What changes if I pass the zone as `+08:00`?",
87+
"expected_output": "`engine.aggregate('deal', { groupBy: [{ field: 'closed_at', dateGranularity: 'month' }], aggregations: [{ function: 'sum', field: 'amount', alias: 'revenue' }, { function: 'count', alias: 'won', filter: { stage: 'closed_won' } }], timezone: 'Asia/Taipei' })`. On PostgreSQL the driver declares `supports.zonedDateBucketing`, and `Asia/Taipei` resolves to an area/location, so the zoned bucket and the filtered count run in the database. SQLite declares no zoned bucketing, so the whole call runs in memory there. `+08:00` resolves to no area/location, so it keeps the whole call in memory on every driver, PostgreSQL included; pass the IANA name.",
88+
"files": [],
89+
"assertions": {
90+
"must_contain": ["timezone: 'Asia/Taipei'", "dateGranularity: 'month'", "zonedDateBucketing", "in memory", "in the database"],
91+
"must_not_contain": ["date_trunc"]
92+
}
8393
}
8494
]
8595
}

‎skills/objectstack-query/rules/aggregation.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ use `where` to shrink the scan, `having` to threshold the aggregates. `avg` /
124124
> total and a conditional count share ONE call. A driver that declares
125125
> `supports.aggregationFilter` (`driver-sql`; `driver-turso` outside remote
126126
> mode) runs it in the database whenever the aggregate itself is pushed down
127-
> (a date bucket under a non-UTC `timezone`, or one the driver does not bucket
128-
> natively, keeps the whole call in memory), compiled as that datasource's
127+
> (a date bucket the driver does not bucket natively keeps the whole call in
128+
> memory; so does one under a non-UTC `timezone`, unless the driver declares
129+
> `supports.zonedDateBucketing` — PostgreSQL via `driver-sql` — and the zone
130+
> resolves to an area/location: `Asia/Taipei` buckets in the database,
131+
> `+08:00` or `EST5EDT` never), compiled as that datasource's
129132
> `where` is: it answers what the same condition answers there (text by the
130133
> database collation) and is refused where it is — a `{ $field }` comparison on
131134
> a column the object does not declare, `INVALID_FILTER` / 400. On any other driver the

0 commit comments

Comments
 (0)