Skip to content

feat(service-analytics): query_dataset says how many groups existed before the limit cut (totalGroups) - #35201

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-35194-query-dataset-total-groups
Nov 18, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-35194-query-dataset-total-groups

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Fixes #35194

Clause-②: yes (widening: QueryDatasetOutputSchema gains totalGroups)
Metadata-protocol: added
Skills-docs: follow-up #35203

维护者速读

  • 改了什么:问数工具 query_dataset 在结果被截断时返回 totalGroups(截断前一共有多少组,与 aggregate_records 同名同义)。本轮按修订后的席位答复(路线 B)补上常见情形:工具默认按全部维度升序排序,只要按下拉选项或关联字段分组(阶段、负责人、客户),窗口就在内存里截取;现在对这份内存里的完整分组表直接数行数作为总数。上一轮在这些情形下一律不返回该字段。
  • 为什么改:合同评审 S1 指出,“每个阶段多少单”这类最常见的问题恰好走内存截取,总数缺失,违背了卡片的完成条件(未截断时 totalGroups 等于 rowCount)。
  • 风险与回滚:不新增任何查询,计数来自本来就已取回的分组;只有当构成这份表的每一次读取都由内置策略确认“没有被任何上限截断”(策略亲自应答且应答的组数与返回行数一致)时才计数,任何一次读取被截断或无法确认就不返回该字段,绝不拿被截断的表凑数。只有 AI 工具请求计数,REST 数据集接口、仪表盘、报表执行的语句不变。回滚即 revert 本 PR;字段本就是可选的。
  • 先看:packages/services/service-analytics/src/dataset-executor.ts(wholeness 账本与 applyWindow 之前那一行计数)、packages/services/service-analytics/src/dataset-group-count.ts(noteWholeRead 的“应答且行数相符”判定)、packages/spec/src/ai/dataset-tools.zod.ts(totalGroups 的 describe 是否如实写清两种来源与全部缺失情形)。
  • 两分钟验证:pnpm --filter @objectstack/service-analytics exec vitest run src/__tests__/dataset-tools.test.ts -t totalGroups,预期 SQLite 一组 11 条全绿(PostgreSQL 一组未设 OS_TEST_POSTGRES_URL 时为具名跳过)。
  • 需要你做的:无,席位落地。

What changes

This round answers contract review 6980602474 (S1, N1, N3) under the revised seat answer on #35194 (comment 6980624450, route B: count the complete in-memory grid) and the filing seat's confirmation that a grid any cap cut answers no count.

  • Two sources, never a read. totalGroups is either (1) the database's COUNT(*) OVER () in the one statement that grouped and cut the answer, where the window is pushed down (unchanged), or (2) the length of the grid before the window, where the window is applied in memory. Source 2 covers the executor's in-memory window (canPushDownWindow false: a label-bearing order key, which the tool's default order brings in for any select or reference dimension; a measure with its own filter; a derived measure; compareTo) and the ObjectQL face's own window over the rows engine.aggregate answers whole (a date bucket, a field-to-field filter, an external object, a driver with no raw SQL, and other routes to that face).
  • Whole is vouched, never assumed. In the executor's in-memory path every read that builds the grid (the primary query, each measure-filter supplementary query, the compareTo pass) carries its own GroupCountRequest. A strategy answers it only for an answer it read with no window and no cap: NativeSQLStrategy for a statement with no LIMIT/OFFSET (answerWholeGrid, no window function added there), the ObjectQL face for the engine's answer before its own orderAndWindow. noteWholeRead keeps the grid whole only while every read was answered AND its answered count equals the rows it handed back, so a read a cap or row guard cut after the strategy counted is caught by the mismatch, and a read no built-in strategy served (a host-added strategy, a fallback service that does not answer) is caught by the missing answer. The count is written before applyWindow; a grid the empty time-bucket fill grew is not counted (not reachable from the tool, which always sends a limit).
  • Completeness trace (no cap cuts the grid before the window). Native-SQL in-memory path: the executor hands no window, the statement carries no LIMIT, and the raw-SQL bridge (plugin.ts to engine.execute to driver-sql's raw execution) applies no row limit. The tool's cap + 1 probe and maxQueryLimit are the selection's own limit, applied by applyWindow after the count. OS_DATA_* read limits judge only the selection's window at queryDataset (the tool always names a limit, so no default-page probe), and the executor's sub-queries go through queryIn, which plans no window. Assembled grids: mergeByDimensions appends and never drops; the derived pass and the empty-group fill keep the row count. ObjectQL face: engine.aggregate takes no order or window, native driver.aggregate and the find plus in-memory fallback read with no limit (the OData driver follows nextLink to the end), and the engine's relation and nested-relation caps refuse rather than truncate. Where completeness cannot be shown (a strategy outside the two built-ins) the member stays absent, by construction rather than by trace.
  • Spec describe (S1, N1). States both sources, that the tool's own order (used when none is sent) sorts every selected dimension so a select or reference dimension brings in the in-memory window while an order by measures alone does not, the whole-grid rule with the cap arm, and every remaining absence case; the engine-aggregate list now reads "such as". Old and new text are in the report on query_dataset: say how many groups existed before the limit cut (totalGroups), as aggregate_records does #35194. References regenerated (gen:schema, gen:docs; check:generated all 14 up to date); authorable-surface/ai.json did not move.
  • N3. The dataset-group-count.ts header no longer says aggregate_records counts "with the same window": on main it answers rows.length, the length of the rows engine.aggregate answered before that tool's cap, which is the same reading as Source 2.
  • Changeset prose restated for the two sources and the remaining absences; level and declaration lines unchanged.
  • No file draft feat(mcp): aggregate_records orders, cuts and counts groups in the database #35193 touches is edited.

Tests

packages/services/service-analytics/src/__tests__/dataset-tools.test.ts, inside the existing real-engine describe (ObjectQL + SqlDriver, SQLite always, PostgreSQL where OS_TEST_POSTGRES_URL is set), every read of the object counted. The fixture gains phase, a select field with options whose labels sort in another order than their values, so the plugin's labelResolver makes the dimension label-bearing in the real wiring.

  • New: default order, no cut, on phase: totalGroups === rowCount === 3, one statement, no window function and no LIMIT in it, no engine aggregate.
  • New: default order with a cut (maxQueryLimit: 2): truncated: true, totalGroups 3, rows in label order; an empty page past the grid (offset: 10) still answers 3, since the in-memory window knows the whole grid.
  • Rewritten from "absent" to "present": the assembled grid (a measure with its own filter: two statements; a derived measure: one) answers totalGroups 5 with no window function in any statement; the date bucket and the ObjectQL face answer 3 and 5, and the ObjectQL face with phase answers 3, one engine aggregate each.
  • New absence arm: a host strategy ahead of the built-ins serves each query through NativeSQLStrategy and keeps two rows; the grid it cut answers no totalGroups.
  • Kept: every pushed-down pin, the empty page after an offset on a pushed-down window (absent), the unknown dialect (absent).
Red on the previous head, green, one ablation of the count, one mutation of the cap arm
  • Red: the six analytics sources restored from 5911cff (the previous head), the new pins kept: Tests 4 failed | 7 passed | 89 skipped (100). The four failures are the label-bearing pair, the assembled grid and the engine-aggregate pin, each expected … to match object { rowCount: …, truncated: …, totalGroups: … }. The cap-arm pin passes there, as absence was that head's behaviour. Restored with git checkout HEAD, git diff HEAD empty.
  • Green at efd8097: Tests 11 passed | 89 skipped (100).
  • Ablation of the grid-length count (dataset-executor.ts, the line before applyWindow, through scripts/ablation-replace.mjs: anchor 1 to 0, blob ad6ee88d3bc6 to 790809994577): Tests 4 failed | 7 passed, the same four. Restored: blob equals HEAD, git diff HEAD empty.
  • Mutation of the cap arm (noteWholeRead stops comparing the answered count with the rows: blob 4f5686ab70b7 to 57f707b58e33): Tests 1 failed | 10 passed, the host row-guard pin. Restored: blob equals HEAD, git diff HEAD empty.
  • The suite imports the package's sources by relative path, so no dist/ was in the path and no dist preflight applies.

Acceptance notes

Verification

Local runs at head a2abbca (this round's final commit; base c787255, the branch point; every exit captured before any pipe)
  • pnpm --filter @objectstack/service-analytics typecheck: exit 0 (dataset-tools.test.ts is in the program, --listFiles: 1).
  • pnpm --filter @objectstack/service-analytics exec vitest run: Test Files 218 passed (218), Tests 5603 passed | 345 skipped (5948), VERDICT command-exit 0.
  • pnpm --filter @objectstack/spec typecheck then vitest run: Test Files 944 passed (944), Tests 28892 passed | 1 todo (28893), VERDICT command-exit 0.
  • pnpm --filter @objectstack/spec check:generated after build, gen:schema, gen:docs: All 14 generated artifacts are up to date. Its first run, before the regeneration, also reported check:test-typecheck with tsc … failed without diagnostics on a loaded box; the rerun was green with no change to the spec tests.
  • node scripts/pm/dispatch-gates.mjs --commands: 118 families, each run with its exit captured; --ran with the :: exit N record: 118 derived famil(ies) accounted for — 116 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3).
  • NOT MEASURED: check:skill-examples and check:dual-build-cjs-loads, both exit 3 (they need the whole workspace built, Run pnpm build first. This is NOT a pass). Neither reads a file this diff changes; CI's lint and type-check lanes carry them.
  • node scripts/pm/overlap-check.mjs: VERDICT clean exit 0 against origin/main 1caee8c, 0 open PR heads sharing a file.
  • The derivation printed a stale-tree note (origin/main 3 commits ahead, one changed file scripts/check-skills-token-ratchet.mjs, not a derived family here).
CI on a2abbca, read when this body was written

70 check-runs: 60 success, 10 skipped, none failed or pending. Among the required contexts: Lint & Repo Gates, TypeScript Type Check, Test Core (all 10 shards), Build Core, Governed Surface Queue Guard, Type Check UI, Test UI (all 16 shards), Build & E2E UI, Live E2E UI, Dogfood Regression Gate: success; Lint UI: skipped (path-filtered). Also success: Check Changeset, Spec property liveness, PR-body guards, Check PR Size, Build Docs. Temporal Conformance (live PG + MySQL) is skipped (opt-in). Whether a Test Core shard sets OS_TEST_POSTGRES_URL for the PostgreSQL cell is not read here.

Earlier rounds
  • Round 2 (5911cff): Check Changeset fix, Metadata-protocol: added and @objectstack/spec minor declared; check-changeset-no-major exit 0 with that body and exit 1 with the previous one as control.
  • Round 1 (ed57ac3): package typecheck and tests green, check:generated up to date, 118 derived families run, check:skill-examples and check:dual-build-cjs-loads NOT MEASURED (exit 3, need a whole-workspace build; CI runs both).

Generated by Claude Code

…y the statement that grouped the answer

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

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/service-analytics, @objectstack/spec, touching 28 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/spec/authorable-surface/ai.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

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

  • content/docs/frontend/plugins/plugin-dashboard.mdx (via queryDataset (symbol, a method of class AnalyticsService), /api/v1/analytics/dataset/query (route, the route ledger binds it to client method analytics.queryDataset))

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

  • content/docs/releases/v16.mdx (via queryDataset (symbol, a method of class AnalyticsService))
  • content/docs/releases/v17/17-5.mdx (via AnalyticsService (symbol, a top-level class))
  • content/docs/releases/v17/17-6.mdx (via AnalyticsService (symbol, a top-level class), /api/v1/analytics/dataset/query (route, the route ledger binds it to client method analytics.queryDataset))
  • content/docs/releases/v17/17-7.mdx (via AnalyticsService (symbol, a top-level class))
  • content/docs/releases/v18/18-5.mdx (via /api/v1/analytics/dataset/query (route, the route ledger binds it to client method analytics.queryDataset))
  • content/docs/releases/v9.mdx (via queryDataset (symbol, a method of class AnalyticsService))

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
  • 1 changed file(s) yielded no anchor (packages/spec/authorable-surface/ai.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 — 173 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 1caee8cbd363e06692317cabd3c5746ba0b976be → packageMentionDocs.

Which tree this was computed on

This run read content/docs from c88c0b1eac9a2965076c14c1daa0c1207e7d7fe3 — the merge of head a2abbca805336f896e7595da4b6c857783085c9a into base 1caee8cbd363e06692317cabd3c5746ba0b976be, 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 c88c0b1eac9a2965076c14c1daa0c1207e7d7fe3 && git checkout c88c0b1eac9a2965076c14c1daa0c1207e7d7fe3
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1caee8cbd363e06692317cabd3c5746ba0b976be a2abbca805336f896e7595da4b6c857783085c9a && git checkout -B drift-repro 1caee8cbd363e06692317cabd3c5746ba0b976be && git merge --no-ff a2abbca805336f896e7595da4b6c857783085c9a

node scripts/docs-audit/affected-docs.mjs --json 1caee8cbd363e06692317cabd3c5746ba0b976be

⚠️ 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 1caee8cbd363e06692317cabd3c5746ba0b976be → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…l added, spec minor

The diff moves packages/spec/authorable-surface/ai.json (ai/QueryDatasetOutput:totalGroups
entered), a metadata-protocol change, so the level follows it: @objectstack/spec minor,
Metadata-protocol added, and the Skills-docs follow-up line the PR body names.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt

Contract-review-claim: session_01JQwxbXGvw43spR79ztEvWt · head 5911cff2e88897190d29dc53810530c7af3508fb · 2026-11-18T13:45Z

Contract review (CONTRACT_REVIEW_TIER) of the spec widening: QueryDatasetOutputSchema gains totalGroups. The declarations are Clause-②: yes (widening), Metadata-protocol: added and Skills-docs: follow-up #35203, per claim amendment 6980156495. Dev reports: 6980036117 and 6980388644.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 5911cff2e88897190d29dc53810530c7af3508fb
Local-runs: none
Scope: packages/spec/src/ai/dataset-tools.zod.ts + packages/services/service-analytics/src/dataset-group-count.ts, packages/services/service-analytics/src/strategies/native-sql-strategy.ts, packages/services/service-analytics/src/dataset-executor.ts, packages/services/service-analytics/src/analytics-service.ts, packages/services/service-analytics/src/dataset-tools.ts

Read: card #35194 (body and all six comments: claim 6978120534, triage 6978963311, dev reports 6980036117 and 6980388644, seat answer 6980116336, claim amendment 6980156495), the PR body, the net diff against merge base c787255a49 (10 files), and the check-runs on the head. Cited code read in the tree at the head, never reviewed: resolveOrdering and canPushDownWindow (dataset-executor.ts), canHandle and assembleStatement (native-sql-strategy.ts), queryIn (analytics-service.ts), plugin.ts (label resolver wiring), text-match-sql.ts (dialect names), aggregate_records on main (packages/mcp/src/mcp-http-tools.ts, totalGroups: rows.length) and on draft #35193 (aggregate-order-cut.ts, takeAggregateGroupCount). The remainder (the test file, the changeset prose, content/docs/references/ai/dataset-tools.mdx, authorable-surface/ai.json) is the lane seat's ACCEPT.

① Derived judgments

  • QueryDatasetOutputSchema accept set: one optional member totalGroups, z.number().int().nonnegative().optional(). An answer without it parses as before. Widening only. Right.
  • Authorable surface: ai/QueryDatasetOutput:totalGroups enters packages/spec/authorable-surface/ai.json, the same row shape sourceLine took. Spec property liveness is success on the head. Right, and consistent with the liveness row.
  • Public TypeScript surface of @objectstack/service-analytics: AnalyticsService.queryDataset and DatasetExecutor.execute each gain one optional option, groupCount. IAnalyticsService in @objectstack/spec/contracts is unchanged, and the tool reaches the class, not the contract. Additive. Right.
  • AnalyticsQuery and DatasetSelection vocabularies: unchanged. The request rides a Symbol.for('objectstack.analytics.groupCount') key, which no JSON body can carry. Right.
  • Statement shape for callers that do not ask: countedGroupsSql returns the projection as compiled when the query carries no request, and only dataset-tools.ts passes groupCount. The REST dataset door, dashboards and reports get the statement they got before. Right.
  • Both MCP doors serialise the executor's answer whole; no door file is in the diff. Not re-measured here; the dev's one-off door check is the only evidence and is recorded as such.

② Semver level

  • @objectstack/spec: minor with Metadata-protocol: added: matches the diff (a new authorable-surface row) and the amendment 6980156495. Check Changeset is success on the head in both runs (134844199321, 134844636924).
  • @objectstack/service-analytics: patch: the gate does not refuse it, and the package publishes two optional options and one optional output member. Accepted.
  • Clause-②: yes (widening: QueryDatasetOutputSchema gains totalGroups): right. Nothing is narrowed or removed.
  • Skills-docs: follow-up #35203: right. skills/objectstack-ask/SKILL.md teaches truncated and is untouched here; the claim put that line on a follow-up card before dispatch.
  • Not reviewed, noted for the lane seat: the changeset's absence list is shorter than the describe's (it omits the member named __os_group_count, the empty page after an offset, and the missing object).

③ Boundary flags

  • Dev open question (in-memory grid length, options A/B/C): answered by the seat in 6980116336. A is built; C is query_dataset: count totalGroups in the database on the ObjectQL face (date buckets) through aggregate_records' order-and-cut #35204. The tree agrees: no path counts rows already fetched.
  • Dev out-of-scope findings (ask skill line; ObjectQL face through feat(mcp): aggregate_records orders, cuts and counts groups in the database #35193's order-and-cut): carried on objectstack-ask skill: teach query_dataset's totalGroups next to truncated #35203 and query_dataset: count totalGroups in the database on the ObjectQL face (date buckets) through aggregate_records' order-and-cut #35204.
  • Dev NOT MEASURED gates (check:skill-examples, check:dual-build-cjs-loads): CI's to answer. At read time no check-run on the head had failed.
  • Dev flag "MySQL cell not measured": stands, and SQL Server is not measured either, which the PR body does not say (N2).
  • SQL push-down: no new id materialisation, no in-app join, no in-app count. The count is one window in the statement that already ran. takeGroupCount reads one cell off the first row; the zero it writes for an empty answer with no offset is an inference from the statement, not a count of rows. No finding.
  • Check-runs on the head at read time. success: Check Changeset (both), Spec property liveness, Governed Surface Queue Guard, PR-body guards (both), Lint · ESLint, Lint · repo & tooling gates, Lint · CI, release & engine gates, Lint · docs & code guards, Lint · PM dispatch-gates, Lint · scoped · tooling self-tests, Lint · scoped · query-options erasure, Type Check · source gates, Build Docs, Build UI Deps, Check Documentation Links, Flag docs affected by code changes, Check PR Size, Dogfood Regression Gate. Still in_progress, so NOT read as green: Type Check · workspace, Type Check · consumer gates, Type Check · debt ledger, Lint · scoped · slot lookup & corpus, Build Core, Test Core 1 to 10, Test UI 1 to 16, Type Check UI, Build & E2E UI, Live E2E UI. skipped: Temporal Conformance (live PG + MySQL) and the opt-in jobs. None failed. The seat reads the pending ones before it adopts this record.

④ Design judgment

packages/spec/src/ai/dataset-tools.zod.ts against the card, the seat answer and its first consumer (dataset-tools.ts).

  • Name and meaning against aggregate_records: holds. On main totalGroups is rows.length before the tool's cap; on feat(mcp): aggregate_records orders, cuts and counts groups in the database #35193 it is the groups the statement formed before its cut. Both count groups, not source rows, and a call with no group key answers 1. query_dataset with no dimension answers 1 too (pinned). aggregate_records has no offset; "before offset and limit" here extends the same meaning and does not contradict it.
  • "Equals rowCount when the answer was not cut": holds, reading "cut" as the first sentence defines it (offset or limit).
  • Empty page after an offset is absent: right. No row carries the window, so the statement answered nothing about the groups, and a number there would need a second read, which the card rules out. An empty answer with no offset is 0, which is exact.
  • The other absence cases agree with the code: singleQuery (measure filter, derived, compareTo), unknown dialect, a member named __os_group_count, the missing-object answer.

S1 (should-fix) — the describe does not tell the caller that the tool's own default order removes the count. query_dataset always sets limit: cap + 1 (dataset-tools.ts), so with no caller order resolveOrdering makes the effective order "every selected dimension, ascending". AnalyticsServicePlugin always wires labelResolver (plugin.ts), so any selected dimension over a select field with options or over a lookup, master-detail, user or tree field is label-bearing, labelOrderKeys is non-empty, canPushDownWindow is false, and totalGroups is absent. So on both MCP doors a grouping by a select or reference dimension (stage, owner, account) answers totalGroups only when the caller sends an order that names measures alone. The describe says "ordered by a display label", which is true of the result but reads as something the caller asked for; a caller that sent no order cannot see why the member is missing, and the card's "a call that isn't cut answers totalGroups equal to rowCount" does not hold for these dimensions. No pin covers it: the fixture's dimensions are text fields, so the label path never runs. Owed: the describe states that the order includes the dimension order the tool applies when none is given, and that an order by measures alone keeps the count; the reference page regenerated; a pin over a select or lookup dimension is the lane's call. #35203 needs the same sentence for the skill.

N1 (nit) — "the query ran through the engine's aggregate instead (a date bucket, a field-to-field filter, an external object, a driver with no raw SQL)" reads as a full list and is not. NativeSQLStrategy.canHandle also declines an uninterpretable temporal comparand, a nested relation condition, a JSON construct or a duration measure on an unknown dialect, an object with engine middleware, a read scope carrying readable ids, and a group by a virtual field. The leading clause covers them all, so the contract is true; the parenthesis wants "such as". Ride S1's edit, or leave it to #35204, which rewrites this clause.

packages/services/service-analytics/src/strategies/native-sql-strategy.ts

  • Placement: the window is a projection of the grouped statement, so it is evaluated after GROUP BY and before ORDER BY, LIMIT/OFFSET and SQL Server's TOP (n). It counts groups, not source rows. Holds on SQLite, PostgreSQL, MySQL 8 and SQL Server by the standard evaluation order.
  • No HAVING, no SELECT DISTINCT, no ROLLUP exists in assembleStatement, so none can change what the window counts. Totals run as separate unwindowed selections through executeSelection with no request, so they carry no window.
  • No dimension: an aggregate with no GROUP BY is one group and the window answers 1. The tool refuses an empty measures, so a projection of the window alone (which would count source rows) is not reachable.
  • The cap + 1 probe: the window ignores the limit, so truncated and totalGroups are independent facts of one statement.
  • Stripping: takeGroupCount deletes the column from every row before buildFieldMeta, and runs only when the statement text carries the window. A member named __os_group_count suppresses the window, so its own column is neither shadowed nor deleted. Holds.
  • Fallback: a RAW_SQL_UNSUPPORTED throw leaves the slot empty and the ObjectQL strategy ignores the key. Holds.

N2 (nit) — two of the four dialects in GROUP_COUNT_DIALECTS are claimed by reading, not measured: MySQL (the PR body says so) and SQL Server (it does not). The PostgreSQL cell runs only where OS_TEST_POSTGRES_URL is set, and Test Core was still running at read time. Separately, the gate is the dialect name, not the server version: a mysql server older than 8.0 would fail to parse the statement where the tool answered before, instead of leaving the member out. The repo already assumes MySQL 8 elsewhere, so this is an accepted deviation; a follow-up card for the two unmeasured cells is the remedy, not a change on this head.

packages/services/service-analytics/src/dataset-group-count.ts

  • The slot, the symbol key and takeGroupCount agree with the describe sentence by sentence: bigint and text counts are read, a value that is not a whole count leaves the slot empty, an empty page after an offset or with limit: 0 leaves it empty.

N3 (nit) — the file header says aggregate_records counts "with the same window over its grouped statement". That is draft #35193, not main, where the count is rows.length. It becomes true when #35193 lands; if #35193 changes shape, this sentence is stale.

N4 (nit) — takeGroupCount trusts the first row. #35193's takeAggregateGroupCount checks every row agrees and that the count is not below the rows returned, and refuses otherwise. Not a correctness gap on the four dialects; a difference between two readers of the same window worth closing when #35204 joins them.

packages/services/service-analytics/src/dataset-executor.ts

  • The request is handed on only when canPushDownWindow holds, in a fresh inner slot, and copied out only when the grid was not grown by the empty-bucket fill. Compare, measure-filter and totals passes never carry it. Agrees with the contract. (The bucket-fill guard cannot fire from the tool, which always sets a limit; it protects other callers of the option.)

packages/services/service-analytics/src/analytics-service.ts

  • queryDataset forwards the option to the executor only on the live path. The draft-preview read and the missing-object answer leave the slot empty, as the jsdoc says. queryIn keeps the symbol through its copies (pinned end to end on a real engine). No leak to query() or generateSql() callers: neither mints the key.

packages/services/service-analytics/src/dataset-tools.ts

  • One fresh slot per call, the member spread only when the slot was written. Agrees with the schema.

One should-fix (S1), four nits (N1 to N4), no must-fix. S1 is open on this head and earns a delta review of its fix.

Implemented-by: claude/issue-35194-query-dataset-total-groups
Reviewed-by: session_01JQwxbXGvw43spR79ztEvWt

VERDICT: PASS

…n memory (red on the previous head)

Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l and removed size/m labels Nov 18, 2026
…memory

Where the window is applied in memory (a label-bearing order, which the
tool's default order brings in; an assembled grid; the ObjectQL face), the
grid before the window is every group, so its length is the count. Each
read that built it is vouched whole by the strategy that served it, and a
read cut by a cap leaves the count out. No read is added.

Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt
Co-authored-by: Claude <noreply@anthropic.com>
…he in-memory totalGroups count

Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt

Contract-review-claim: session_01JQwxbXGvw43spR79ztEvWt · head a2abbca805336f896e7595da4b6c857783085c9a · 2026-11-18T14:47Z

Delta contract review (CONTRACT_REVIEW_TIER) 5911cff2..a2abbca8, closing S1 (and nits N1, N3) of 6980602474. It follows revised seat answer 6980624450 (route B: the grid's length before the in-memory window, only when every read came back whole; a capped grid answers no count). Dev report 6981921680.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbXKtHccbeakAgquNs9

L1 review (#35194) · 2026-11-18T14:50Z

L1: ACCEPT
Head-sha: a2abbca
Read: this is the first L1 verdict on this PR. I read the full diff at 5911cff, which I held and did not post at the area's request after contract review 6980602474 raised S1. I then read the delta 5911cff → a2abbca: three commits of the PR's own, no main merge. The other inputs were claim 6978120534, seat answers 6980116336 and 6980624450 (revised: A plus B where the grid is whole), claim amendment 6980156495, and os-dev reports 6980036117, 6980388644 and 6981921680. The PR is 11 files, +636/−19.

Fixes vs Part of. The PR body's first line is Fixes #35194. Under the revised seat answer the card's Done-when holds: an answer that is not cut answers totalGroups equal to rowCount, now including the label-bearing default order. The remaining cases are #35204, and the ask-skill line is #35203. So Fixes is right.

Claim file surface. All 11 paths are inside the claim.

  • dataset-tools.zod.ts, plus what it regenerates: the references/ai/dataset-tools.mdx row and the authorable-surface/ai.json entry.
  • service-analytics/src/**: dataset-tools.ts, dataset-executor.ts, analytics-service.ts, the new dataset-group-count.ts, strategies/native-sql-strategy.ts, and, new in the delta, strategies/objectql-strategy.ts.
  • The test file and one changeset.

Amendment 6980156495 sets Metadata-protocol: added, with spec at minor, and Skills-docs: follow-up #35203. The body and the changeset carry the same three lines.

Source 1: the pushed-down window (read at 5911cff, unchanged in substance).

  • countedGroupsSql appends COUNT(*) OVER () to the one statement that groups, orders and cuts. It now does so only when that statement has a window (hasWindow), only on GROUP_COUNT_DIALECTS, and never under a member of the same name.
  • takeGroupCount takes the column off every row after the number presenter and before buildFieldMeta. It reads a bigint or text, accepts only a safe non-negative integer, and leaves an empty page after an offset (or with limit: 0) unanswered.

Source 2: the in-memory window, the delta (revised answer, route B).

  • Where canPushDownWindow is false, the executor keeps a WholeGridProof ledger. Every read it issues carries its own request: the primary read, each measure-scoped sub-read, and the compareTo pass through runMeasurePass. noteWholeRead keeps the ledger whole only when the serving strategy answered the request and the count equals the rows it handed back.
  • NativeSQLStrategy answers a statement that has no LIMIT or OFFSET from its rows (answerWholeGrid). The ObjectQL face answers in orderAndWindow from the rows engine.aggregate returned, which is handed no order and no window, before its own cut. So the date bucket and the face itself now count both ways: in the pushed-down case through the face's own count, and in memory through the ledger.
  • The count is the grid's length after ordering and before applyWindow. It is skipped when the time-bucket fill grew the grid.
  • A strategy that does not answer, such as a host-added one, leaves the count out. So does a guard that cut rows after the strategy counted, through the mismatch. The host-row-guard pin and the mutation recorded in 6981921680 prove that arm.
  • No read is added on any path.

Each changeset sentence against the diff. The changeset is new and is not on main. @objectstack/spec is minor and @objectstack/service-analytics is patch.

  • "Never costs a read": both sources read only what the selection already read.
  • The in-memory list: the label-bearing order (with the default-order mechanism stated), the assembled grid and the engine-aggregate face match canPushDownWindow and the two answering strategies.
  • "Counted only when every read … came back whole": noteWholeRead.
  • The absent list: an unknown dialect, the __os_group_count name, an empty page after an offset, an unvouched strategy or a cap under it, and the missing-object answer. Each matches a code path.
  • "Only the AI tool asks": groupCount is passed only by dataset-tools.ts, and the symbol key rides no wire request.

The QueryDatasetOutputSchema describe and the regenerated reference row say the same. The describe also lists the time-bucket fill in the module doc. The changeset's absent list omits it, but the fill applies only to date buckets, which the face counts before the fill, so the outcome is still absent there.

Tests and ablations.

  • New cases in the delta: a label-bearing dimension in default order, not cut (totalGroups equals rowCount) and cut (truncated with the full count); an assembled grid counted with no extra read; the engine-aggregate face for a date bucket and the face itself; and the host row-guard arm, where the count is absent.
  • They fail first on 5911cff (4 failed).
  • One ablation of the grid-length line turns the same four red, and the cap-arm mutation turns its pin red. Both were restored to the HEAD blob (6981921680).
  • The Source 1 pins and their three ablations from round 1 stand (6980036117).

Clause-②: yes (widening). A published output schema gains an optional member. The contract review's S1 is answered by this delta, and its fable delta runs in parallel (claim 6981990176). That delta is owed after this L1.

Governance. check-governed-merges.mjs --pr 35201: NOT governed, 655 changed lines.

CI at this head, from check-runs: 62 success and 12 skipped, with none failed or in progress. The PR is mergeable clean.

Must-fix

None.

Should-fix

None.

Notes

  • N1, dialect coverage, carried as the area accepted it. Source 1 is measured on SQLite. The PostgreSQL cell runs only with OS_TEST_POSTGRES_URL, and MySQL 8 and SQL Server have no pin.
  • N2, the wholeness proof's boundary. noteWholeRead catches a cut made after the strategy answered. It cannot catch a silent clamp below the strategy, inside executeRawSql or engine.aggregate. Today none exists: the data door's read limits refuse rather than clamp, and the face hands the engine no window. The orderAndWindow comment says that a read which ever hands the engine a window must take the count from the engine. I add no ask.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: a2abbca805336f896e7595da4b6c857783085c9a
Local-runs: none
Scope: packages/spec/src/ai/dataset-tools.zod.ts + packages/services/service-analytics/src/dataset-group-count.ts, packages/services/service-analytics/src/dataset-executor.ts, packages/services/service-analytics/src/strategies/native-sql-strategy.ts, packages/services/service-analytics/src/strategies/objectql-strategy.ts, packages/services/service-analytics/src/analytics-service.ts, packages/services/service-analytics/src/dataset-tools.ts

Delta review of 5911cff2e88897190d29dc53810530c7af3508fb..a2abbca805336f896e7595da4b6c857783085c9a (three commits, ten files). The previous record is PR #35201 comment 6980602474 (PASS on 5911cff2, S1 open, nits N1 to N4).

Read: card #35194 (body and all eight comments, including the revised seat answer 6980624450 and the dev report 6981921680, read as an account to check), the PR body as stored, the delta diff, the net file list against merge base c787255a49 (11 files), and the check-runs on the head. Cited code read in the tree at the head, never reviewed: resolveOrdering, timeBucketFillPlan, buildQuery, mergeByDimensions, evaluateDerivedMeasures (dataset-executor.ts); query, queryIn, scopedService, queryDataset, answerDataset (analytics-service.ts); windowClauseSql, countedGroupsSql, execute (native-sql-strategy.ts); the direct and cross-object paths of ObjectQLStrategy; the raw-SQL auto-bridge (plugin.ts); engine.execute (engine-execute-transactions.ts); engine.aggregate (engine-delete-and-aggregate.ts); query-read-limits.ts; external-driver-errors.ts; dimension-labels.ts; aggregate_records on origin/main at 084156de5e (mcp-http-tools.ts, totalGroups: rows.length). The remainder (the test file, the changeset prose, content/docs/references/ai/dataset-tools.mdx) is the lane seat's ACCEPT; it was read only to answer the questions put on the pins and the prose.

① Derived judgments

  • QueryDatasetOutputSchema accept set: unchanged in this delta. totalGroups stays z.number().int().nonnegative().optional(); only its describe and the schema's jsdoc moved. Right.
  • Authorable surface: packages/spec/authorable-surface/ai.json did not move in the delta. The one row the PR adds (ai/QueryDatasetOutput:totalGroups) stands. Right.
  • Public surface of @objectstack/service-analytics: unchanged in the delta. dataset-group-count.ts is not re-exported from the package index, so answerWholeGrid, hasWindow, noteWholeRead and WholeGridProof are internal. IAnalyticsService, AnalyticsQuery and DatasetSelection are untouched. Right.
  • Answer set of the tool: totalGroups is now present where it was absent (a label-bearing order, an assembled grid, the ObjectQL face). The member was optional and stays optional; a reader that handled its absence handles its presence. Widening of behaviour, no narrowing. Right.
  • Statements for callers that do not ask: unchanged. countedGroupsSql now also requires a window on the query, so an unwindowed statement never carries the window function, asked or not. Only dataset-tools.ts mints a request. Right.

② Semver level

  • @objectstack/spec: minor, @objectstack/service-analytics: patch: the changeset header is byte-identical to the previous head. Still matches what the diff publishes.
  • Clause-②: yes (widening: QueryDatasetOutputSchema gains totalGroups), Metadata-protocol: added, Skills-docs: follow-up #35203: unchanged on the changeset and on the PR body, and still right.
  • Check Changeset is success on the head in both runs (134860684711, 134884769754).
  • Changeset prose, read for agreement only: it now states both sources, the whole-grid rule and the same absence list as the describe. The gap the previous record noted for the lane seat (a shorter absence list) is gone.

③ Boundary flags

  • Route: the revised seat answer 6980624450 (A plus B where the grid is complete) is on the card. The filing seat's confirmation and its condition are cited by the dev report and the PR body but are not a comment on query_dataset: say how many groups existed before the limit cut (totalGroups), as aggregate_records does #35194 or feat(service-analytics): query_dataset says how many groups existed before the limit cut (totalGroups) #35201. The tree meets the condition as this round's order quotes it, so nothing in the verdict turns on it; the seat links the confirmation on the card.
  • Dev open question (who patches the PR body): answered by the tree of record. The stored PR body carries this round's text, including the N2 and N4 acceptance notes. Seat process, not a contract point.
  • Dev out-of-scope findings: query_dataset: count totalGroups in the database on the ObjectQL face (date buckets) through aggregate_records' order-and-cut #35204 (an ObjectQL-face window the engine itself cuts), objectstack-ask skill: teach query_dataset's totalGroups next to truncated #35203 (the skill sentence), the N2 follow-up for the two unmeasured dialect cells. All carried; none is owed on this head.
  • Dev NOT MEASURED gates (check:skill-examples, check:dual-build-cjs-loads): CI's to answer; the lint and type-check lanes are success on the head.
  • SQL push-down: the delta adds no read, no id materialisation and no in-app join. Source 2 is the length of a grid already fetched, whose groups the database (or engine.aggregate) formed. The window in memory was there before this PR. No finding.
  • Check-runs on the head, 74 listed: none failed, none pending. success: Check Changeset (both), Spec property liveness, Governed Surface Queue Guard, PR-body guards (both), Lint & Repo Gates and its seven Lint lanes, TypeScript Type Check and its four Type Check lanes, Build Core, Test Core and all 10 shards, Build UI Deps, Type Check UI, Test UI and all 16 shards, Build & E2E UI, Live E2E UI, Build Docs, Check Documentation Links, Flag docs affected by code changes, Dogfood Regression Gate, Check PR Size. skipped: Lint UI (path filter), Temporal Conformance (live PG + MySQL), the opt-in jobs, the queue verdicts, and the second run's Check PR Size and Auto Label. Whether a Test Core shard set OS_TEST_POSTGRES_URL is not read here.

④ Design judgment

S1: closed.
N1: closed.
N3: closed.
N2: accepted deviation, recorded in the PR body's Acceptance notes.
N4: accepted deviation, recorded in the PR body's Acceptance notes.

No must-fix, no should-fix.

packages/spec/src/ai/dataset-tools.zod.ts against the revised seat answer and the code.

  • Sentence by sentence, for every answer the tool can give:
    • "Never paid for with a read": holds (see (b) below).
    • Pushed-down source: holds. counted is minted only when canPushDownWindow, and the native strategy appends the window only on a known dialect with a window on the query.
    • In-memory source, three cases: holds. A label-bearing order key, a measure with its own filter, a derived measure and compareTo all make canPushDownWindow false, and the count is written on the line before applyWindow. A query the ObjectQL face serves is answered in orderAndWindow before its own cut, whether the executor pushed the window down or not.
    • The default-order clause: holds. resolveOrdering returns every selected dimension ascending when a limit is set and no order is sent, the tool always sets limit: cap + 1, and isLabelBearing is true for a field with options or a reference field with a target. A caller order is returned verbatim, so measures alone add no dimension key.
    • "Equals rowCount when the answer was not cut": holds on both sources.
    • The absence list: each case agrees with the code. Unknown dialect, a member named __os_group_count and an empty page after an offset are scoped to the SQL push-down, which is right: the in-memory window answers a page past the grid with the full count. An unvouching strategy and a cut read are the two ways noteWholeRead turns the ledger false (and the one way a pushed-down request stays unanswered). The missing-object answer never reaches a count.
    • The list is complete for the tool. The three cases the code header names and the describe does not (a grid grown by the time-bucket fill, the draft-preview read, limit: 0) are not reachable from query_dataset: it always sets a limit of at least 1, which disables the fill, and it never passes previewDrafts.
  • Same meaning as aggregate_records: holds, and more plainly than before. On origin/main that tool answers rows.length of what engine.aggregate returned, before its own cap. Source 2 is that same reading; Source 1 is the same number counted by the statement.
  • N1's "such as" is in.

N5 (nit) — "a grid that any cap or row guard cut before the window answers no count" is true of every cut the executor can see, and is trust below that. noteWholeRead catches a cut between a strategy's answer and the executor (the pinned host row guard) and a strategy that does not answer. It cannot see a cut inside the strategy's own read seam: NativeSQLStrategy counts the rows ctx.executeRawSql handed back, and ObjectQLStrategy the rows ctx.executeAggregate handed back. I found no in-repo path that cuts there: the unwindowed statement carries no LIMIT, the auto-bridge, engine.execute and driver-sql's raw execution apply none, engine.aggregate takes no window, its find fallback names no limit and no built-in driver adds a default one, the OS_DATA_* limits are planned only at the two public doors and refuse rather than clamp, and the external row cap refuses with EXTERNAL_ROW_CAP_EXCEEDED. The residue is a host-supplied executeRawSql or executeAggregate option, or an out-of-repo driver, that silently truncates an unwindowed read. Such a host already serves wrong measures and truncated: false on every dataset door, and totalGroups would agree with that answer's own rowCount, as aggregate_records' does. No effect on correctness in the tree. Accepted deviation, or one sentence on #35204 saying where the proof stops; not a change on this head.

packages/services/service-analytics/src/dataset-group-count.ts

  • The header's two sources, the vouching rule and the absence list agree with the code line by line. N3's sentence now says what origin/main does (rows.length, before that tool's cap).
  • noteWholeRead: a read is whole only when the request was answered and the answered count equals rows.length. An unanswered request has outcome undefined, which is never equal to a length, so one predicate covers both arms. The ledger only ever moves to false.

packages/services/service-analytics/src/dataset-executor.ts

  • (a) Tried to break the proof; it holds on every path I could construct.
    • counted and wholeness are mutually exclusive, so a read carries exactly one request.
    • Every read that builds an in-memory grid is noted: the primary query, each measure-filter sub-query, and the compareTo pass (which reuses runMeasurePass with the same ledger). A pass with no primary query issues no unnoted read.
    • buildQuery puts a limit or offset on a query only from opts.window, which is undefined on this path, so each read is unwindowed and the native strategy answers from rows.length with no window function.
    • mergeByDimensions writes onto a matching row or appends; fillEmptyGroups and evaluateDerivedMeasures keep the length. Nothing between the reads and the count drops a row.
    • The count is taken before applyWindow, after the label sort, and not for a bucket-filled grid.
    • The tool's cap + 1 and any maxQueryLimit are the selection's own limit, applied by applyWindow after the count. The executor reaches the service through scopedService, that is queryIn, which plans no read window.
    • A host strategy: one that ignores the symbol leaves the request unanswered; one that wraps a built-in and cuts its rows is caught by the mismatch; one that adds a limit to the query before the native strategy makes that strategy answer the database's count, which no longer equals the rows. In all three the member is absent.
    • On the pushed-down path the count is the database's window or the ObjectQL face's pre-cut length, both taken before any later cut, so a guard there cannot lower it.
  • (b) No read is added. On the in-memory path the statement set is the one the executor issued before; the request rides on those same queries. The pins count statements and engine aggregates and assert no COUNT(*) OVER () and no LIMIT in the unwindowed statement.

N6 (nit) — the slot is written before execute runs the totals groupings. If a totals read then throws a missing-source error, answerDataset serves the empty answer and the tool would pair rowCount: 0 with the count already written. It needs the object to vanish between two statements of one call, and the pushed-down path had the same order on the previous head. A follow-up could clear the slot in that catch arm; nothing owed here.

packages/services/service-analytics/src/strategies/native-sql-strategy.ts

  • The two arms are exclusive and exhaustive of what may be vouched: a statement that carries the window is read by takeGroupCount; a query with no limit and no offset is answered from its rows; a windowed query on an unknown dialect, or under a member named __os_group_count, is left unanswered. windowClauseSql and windowTopSql emit nothing when both keys are unset, so "no window on the query" is "no cut in the statement".

packages/services/service-analytics/src/strategies/objectql-strategy.ts

packages/services/service-analytics/src/analytics-service.ts and dataset-tools.ts

  • Comments only in this delta, and both now say what the code does. The tool still mints one fresh slot per call and never passes previewDrafts.

Pins (lane seat's ACCEPT; read for (d) only)

  • phase is a select field with options on the registered object, and the services are built by AnalyticsServicePlugin.init, so the label resolver is the plugin's own wiring, not a double. The uncut pin asserts totalGroups === rowCount === 3, one statement, no window function and no LIMIT; the cut pin asserts truncated: true, totalGroups: 3 and rows in label order ([3, 2], which the stored values would not give), so the label path is proven to have run.
  • The cap-arm pin bites by construction: the guard slices after the native strategy answered 3, so removing the equality in noteWholeRead would count the cut grid of 2 and fail not.toHaveProperty('totalGroups'). The dev's mutation result is consistent with that; it was not re-run here.

No must-fix, no should-fix. S1, N1 and N3 are closed on this head; N2 and N4 are accepted in the PR body; N5 and N6 are new nits and end the round.

Implemented-by: claude/issue-35194-query-dataset-total-groups
Reviewed-by: session_01JQwxbXGvw43spR79ztEvWt

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt

Landing · 2026-11-18T14:56Z · head a2abbca805336f896e7595da4b6c857783085c9a

Probe Reading
L1 L1-a ACCEPT 6982054904 on this head: a full read at 5911cff2 plus the S1 delta. No must-fix and no should-fix. N1 (MySQL and MSSQL unpinned) was already accepted. N2 (a silent clamp below the strategy) has no in-repo path today.
Contract review CONTRACT_REVIEW_TIER delta PASS 6982207184 on this head, closing S1, N1 and N3 of 6980602474. N2 and N4 are accepted in the PR body. N5 and N6 are new nits, carried as a note on #35204. Tier verified on the reviewing transcript.
CI check-expected-skips --pr 35201 exits 0 with the roster pinned to main's tip: 74 check-runs, 62 success, 12 expected skips, 0 other.
Governed check-governed-merges --pr 35201 reads NOT governed. The PR changes 655 lines (+636/−19), under the 3,000-line threshold.
Base drift K = 6 first-parent commits from base c787255a to main, under 15.
Declarations @objectstack/spec minor, @objectstack/service-analytics patch. Clause-②: yes (widening), Metadata-protocol: added, Skills-docs: follow-up #35203.

Route: the revised seat answer 6980624450 is A plus B. Where the window is pushed down, the statement counts the groups. Where the window runs in memory, the grid's length is counted only when every read vouches that it is whole. A capped grid answers no count.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 18, 2026 14:57
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit b863d2b Nov 18, 2026
75 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35194-query-dataset-total-groups branch November 18, 2026 15:27
os-warren pushed a commit that referenced this pull request Nov 18, 2026
…totalGroups, #35179 withheld fields) into the aggregate order and cut

Three adjacent-insertion conflicts, each resolved keeping both sides: the
McpDataBridge members aggregateGroups and #35198's userTextLocales (the
interface in mcp-http-tools.ts and the runtime HTTP bridge in
domains/mcp.ts), and both members in the write-response tripwire roster.
#35179's withheld-field naming applies to query_records and get_record
only and merged without conflict; #35201 touches service-analytics only.

Claude-Session: https://claude.ai/code/session_01JQwxbWDsbbJizuYnDwBxT8
Co-authored-by: Claude <noreply@anthropic.com>
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:ai 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.

query_dataset: say how many groups existed before the limit cut (totalGroups), as aggregate_records does

2 participants