Skip to content

fix(service-analytics): query_dataset never pairs an empty answer with a group count - #35286

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-35204-objectql-face-group-count
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-35204-objectql-face-group-count

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread
Fixes #35204 — the two contract-review nits (N5, N6). The card's main route (the ObjectQL face handing its cut to the engine's order-and-cut) is closed by seat ruling 6997569008 (route C: the face's in-memory totalGroups is already exact); the database top-N and its ordering question moved to #35287.

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:query_dataset 带 totals 时,若 totals 那次读取遇到「源表不存在」被降级成空结果,不再同时返回主网格的 totalGroups;另在 dataset-group-count.ts 头注释写明「整网格证明」止于策略自己的读取接缝。
  • 为什么改:合约评审 6982207184 的 N6:空答案(rowCount: 0)与已写入的分组数配对,AI 会读到一个从未返回的网格的分组数;N5 是一句说明边界的注释。
  • 风险与回滚:风险低,只改了计数写回调用方槽位的时机(整次调用成功后才写);回滚即 revert 本 PR。
  • 先看:packages/services/service-analytics/src/dataset-executor.ts 的 execute()(counted 局部槽位与末尾写回两处),其次新测试。
  • 两分钟验证:pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2 src/__tests__/dataset-tools.test.ts -t "missing source serves no count",预期 2 passed。
  • 需要你做的:无,席位落地。

What changes

  • N6 (dataset-executor.ts). execute now hands executeSelection a local group-count request and copies its outcome into the caller's slot only after the totals groupings have run. Before, the slot was written while the primary grid was read; a totals read that then threw a missing-source error made answerDataset serve { rows: [] }, and query_dataset answered rowCount: 0 beside the primary grid's totalGroups. Any throw after the count now leaves the slot empty.
  • N5 (dataset-group-count.ts header). One sentence: the whole-grid proof stops at the strategy's own read seam (ctx.executeRawSql, ctx.executeAggregate); a host-supplied bridge or an out-of-repo driver that silently truncates an unwindowed read is counted as whole. No in-repo seam cuts one.
  • Changeset: @objectstack/service-analytics patch.

Tests

New top-level describe in the shared query_dataset harness, src/__tests__/dataset-tools.test.ts: [query_dataset totalGroups] a totals read that meets a missing source serves no count. Real SQLite engine through AnalyticsServicePlugin; the second statement of the call fails as no such table.

  • CONTROL: totals served, { rowCount: 3, truncated: false, totalGroups: 3 }, two statements, the first carrying COUNT(*) OVER ().
  • The fix: totals read fails, the empty answer (rowCount: 0) and no totalGroups; the primary statement still ran and counted.

Acceptance notes

  • The route is not in this PR. Measured on origin/main f4dbcc21: the engine writes the group count to the caller's own request (request.outcome.totalGroups, aggregate-order-cut.ts), but the ObjectQL face's only read seam, ctx.executeAggregate (the spec's StrategyContext and the plugin's auto-bridge), carries no read option, and the engine REFUSES (throws INVALID_QUERY / 400 before reading) wherever it cannot serve the cut rather than declining. Routing the face's cut therefore needs a new consumer-local bridge (plugin.ts, strategies/types.ts, analytics-service.ts, outside this card's file surface) and either a catch around the engine's refusal or an objectql decline mode, and it changes which rows a text-ordered top-N answers (database collation instead of applyOrdering). Returned to the seat as a decision.
  • totalGroups on the ObjectQL face is already the exact count today (the whole grid's length, before the face's own in-memory cut); nothing on that face is approximated.

Verification

Head cd688d97c.

Package: build, typecheck, test (under the shared verify lock)
  • pnpm --filter @objectstack/service-analytics build && … typecheck && … test: VERDICT command-exit 0; Test Files 218 passed (218), Tests 5605 passed | 345 skipped (5950).
Ablation (one-shot, not kept)
  • node scripts/ablation-replace.mjs replaced this.executeSelection(compiled, selection, context, counted); with the pre-fix …, options?.groupCount); (anchor 1 to 0, blob 1e56cd1b5e95 to 9ab686e51c1b). The pin turned red: AssertionError: expected { rows: [], fields: [], …(7) } to not have property "totalGroups", Tests 1 failed | 1 passed. Restore proven: blob equals HEAD, git diff HEAD empty. No dist leg: the suite imports the executor from src.
Derived gate families (dispatch-gates, 66)
  • 64 exit 0. 2 exit 3, NOT MEASURED: check-plugin-teardown-shape.mjs --self-test (shallow clone cannot reach its pinned fixture commit), check:dual-build-cjs-loads (reads every package's built output; only the closure was built). CI runs both.
  • dispatch-gates --ran: 66 derived famil(ies) accounted for — 64 run, 2 NOT-MEASURED.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7

…he whole call answered

The totals reads run after the primary grid is counted; a missing-source
error there is served as an empty answer, which paired rowCount 0 with the
count already written. And name where the wholeness proof stops.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7
…rves no group count

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

⚠️ 1 changed file(s) yielded no anchor (packages/services/service-analytics/src/dataset-group-count.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files. Nothing else in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 1 changed package(s)).

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/services/service-analytics/src/dataset-group-count.ts) — pages documenting those are invisible to this run
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • 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 — 10 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 0c047d0c089ee6415ddf64c00e75ba9e3f7e7957 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 改了什么:query_dataset 带 totals(小计/合计)时,如果合计那次读取遇到「源表不存在」、整个回答被降级成空结果,就不再同时附上主网格的分组总数 totalGroups;另在 dataset-group-count.ts 头注释补一句「整网格证明止于策略自己的读取接缝」。
  • 为什么改:以前空答案(0 行)会和一个从没返回过的网格的分组数一起给出,AI 会被误导。来自 feat(service-analytics): query_dataset says how many groups existed before the limit cut (totalGroups) #35201 契约复审的两条小意见 N5、N6。
  • 风险与回滚:只改分组数写回调用方的时机(整次调用成功后才写),成功路径读数不变。回滚即 revert 本 PR。
  • 先看:dataset-executor.ts 的 execute()(局部 counted 槽位与末尾写回)。
  • 两分钟验证:按 PR 正文跑 dataset-tools.test.ts -t "missing source serves no count",2 个通过。
  • 需要你做的:无,区内落地(非受管面、112 行)。L1 意见:修法比评审建议的位置更稳(覆盖之后任何抛错),钉子与消融齐全,可落。

席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head cd688d97c827f97a8fe61f234b74ebc4185a88ad · 2026-11-19T02:32Z

  • 形态: draft → main, 4 files, +110/−2, 3 commits. Fixes #35204 on the first content line; query_dataset ObjectQL face: push the top-N order-and-cut to the database (SQL-first) instead of fetching every group #35287 is named later in that sentence with no closing keyword before it ("moved to"), so only query_dataset: count totalGroups in the database on the ObjectQL face (date buckets) through aggregate_records' order-and-cut #35204 closes. check-governed-merges --pr 35286: 0 of 4 paths governed, 112 lines ≤ 3000 → ordinary queue landing. Clause-②: no, Metadata-protocol: none.
  • Fixes vs the card: the card's route (the ObjectQL face handing its cut to the engine's order-and-cut) is closed by seat route ruling 6997569008 (route C, the face's totalGroups is already exact as the whole-grid length; A/B and the ordering question moved to query_dataset ObjectQL face: push the top-N order-and-cut to the database (SQL-first) instead of fetching every group #35287), which also says the card closes when this PR merges. So Fixes is right; it delivers the remaining N5/N6 from scope note 6982278668.
  • Changeset: .changeset/35204-query-dataset-group-count-totals-arm.md, patch on @objectstack/service-analytics (published). Sentences read against the diff: "an answer served empty because a read failed carries no totalGroups" = the deferred slot write plus the pin; "the count now reaches the caller only once the whole call has answered" = the copy at the end of execute(); the N5 paragraph quotes the header sentence; "No key, member or export changes" = true (no export, schema or wire key touched).
  • 差异由 L1 读过: execute() hands executeSelection a local counted request (GroupCountRequest has only the outcome slot, so {} drops nothing) and copies counted.outcome into options.groupCount after the totals loop. Any throw after the primary read (a totals read, the DATASET_INVALID grouping check) now leaves the caller's slot empty, and dataset-tools.ts reads an empty slot as "not counted", never zero. Success path unchanged.
  • 接受的偏差: (1) N6 closed at the slot write in dataset-executor.ts instead of clearing it in answerDataset's catch arm, which is in analytics-service.ts, outside the claim's file surface. Same effect for that arm, and it also covers later throws. Accepted, and stronger. (2) The pin goes in the shared dataset-tools.test.ts harness as a top-level describe, not in a new file named for the card, per AGENTS.md (ruling record 6583487846). (3) Model-free trailers.
  • Pins: real SQLite engine through AnalyticsServicePlugin. CONTROL: totals served, { rowCount: 3, truncated: false, totalGroups: 3 }, two statements, the first carrying the count window. Fix: second statement fails as no such table, so rowCount: 0 and no totalGroups, with the primary statement shown to have run and counted. Ablation back to the pre-fix argument: 1 red / 1 green, restored blob == HEAD.
  • 门禁: check-runs on head cd688d97: 39 success, 18 skipped, 0 failure (Lint & Repo Gates and TypeScript Type Check among the successes). Dev local NOT MEASURED ×2 (check-plugin-teardown-shape --self-test, check:dual-build-cjs-loads) are covered by CI's Lint families on this head.
  • 范围外去向: the ObjectQL-face SQL-first top-N gap → query_dataset ObjectQL face: push the top-N order-and-cut to the database (SQL-first) instead of fetching every group #35287 (seat ruling). Nothing else.
  • 落地条款: K = 8 first-parent commits on main since merge base f4dbcc21 (< 15), no locale pack. Non-governed ⇒ ai-1 lands per landing-operations.md (pr_ready + auto-merge) after this ACCEPT; on MERGED, close-out on query_dataset: count totalGroups in the database on the ObjectQL face (date buckets) through aggregate_records' order-and-cut #35204 naming query_dataset ObjectQL face: push the top-N order-and-cut to the database (SQL-first) instead of fetching every group #35287.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CazXu8zyYD5PC6J2u7

Landing · ACCEPT (L1-a) → PR #35286 comment 6997893766 · head cd688d97 · 2026-11-19T02:33Z

Probe Reading
check-governed-merges --pr 35286 0 of 4 paths governed; 112 lines ≤ 3000 → ordinary queue landing
check-runs on cd688d97 39 success, 18 skipped, 0 failure; mergeable_state clean

Area ai-1 landing armed (ready + auto-merge); #35204 close-out on MERGED.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 19, 2026 02:33
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 068a0f9 Nov 19, 2026
58 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35204-objectql-face-group-count branch November 19, 2026 02:57
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 size/m 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.

query_dataset: count totalGroups in the database on the ObjectQL face (date buckets) through aggregate_records' order-and-cut

2 participants