Repository navigation
feat(service-analytics): query_dataset says how many groups existed before the limit cut (totalGroups) - #35201
Conversation
…y the statement that grouped the answer Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt Co-authored-by: Claude <noreply@anthropic.com>
…alGroups Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt Co-authored-by: Claude <noreply@anthropic.com>
… correctly Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 6 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 173 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 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
|
…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
|
repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt Contract-review-claim: session_01JQwxbXGvw43spR79ztEvWt · head Contract review ( |
|
repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt Contract reviewServed-tier: 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 ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
S1 (should-fix) — the describe does not tell the caller that the tool's own default order removes the count. 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.
N2 (nit) — two of the four dialects in
N3 (nit) — the file header says N4 (nit) —
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: VERDICT: PASS |
…n memory (red on the previous head) Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt Co-authored-by: Claude <noreply@anthropic.com>
…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>
|
repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt Contract-review-claim: session_01JQwxbXGvw43spR79ztEvWt · head Delta contract review ( |
|
repo:objectstack#1 · os-warren · session_01JQwxbXKtHccbeakAgquNs9 L1 review (#35194) · 2026-11-18T14:50ZL1: ACCEPT Fixes vs Part of. The PR body's first line is Claim file surface. All 11 paths are inside the claim.
Amendment 6980156495 sets Source 1: the pushed-down window (read at 5911cff, unchanged in substance).
Source 2: the in-memory window, the delta (revised answer, route B).
Each changeset sentence against the diff. The changeset is new and is not on
The Tests and ablations.
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. CI at this head, from check-runs: 62 success and 12 skipped, with none failed or in progress. The PR is mergeable Must-fixNone. Should-fixNone. Notes
|
|
repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt Contract reviewServed-tier: Delta review of 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 ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentS1: closed. No must-fix, no should-fix.
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.
N6 (nit) — the slot is written before
Pins (lane seat's ACCEPT; read for (d) only)
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: VERDICT: PASS |
|
repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt Landing · 2026-11-18T14:56Z · head
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. |
…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>
Fixes #35194
Clause-②: yes (widening: QueryDatasetOutputSchema gains totalGroups)
Metadata-protocol: added
Skills-docs: follow-up #35203
维护者速读
query_dataset在结果被截断时返回totalGroups(截断前一共有多少组,与aggregate_records同名同义)。本轮按修订后的席位答复(路线 B)补上常见情形:工具默认按全部维度升序排序,只要按下拉选项或关联字段分组(阶段、负责人、客户),窗口就在内存里截取;现在对这份内存里的完整分组表直接数行数作为总数。上一轮在这些情形下一律不返回该字段。totalGroups等于rowCount)。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.
totalGroupsis either (1) the database'sCOUNT(*) 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 (canPushDownWindowfalse: 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 rowsengine.aggregateanswers whole (a date bucket, a field-to-field filter, an external object, a driver with no raw SQL, and other routes to that face).compareTopass) carries its ownGroupCountRequest. A strategy answers it only for an answer it read with no window and no cap:NativeSQLStrategyfor a statement with noLIMIT/OFFSET(answerWholeGrid, no window function added there), the ObjectQL face for the engine's answer before its ownorderAndWindow.noteWholeReadkeeps 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 beforeapplyWindow; a grid the empty time-bucket fill grew is not counted (not reachable from the tool, which always sends a limit).LIMIT, and the raw-SQL bridge (plugin.tstoengine.executetodriver-sql's raw execution) applies no row limit. The tool'scap + 1probe andmaxQueryLimitare the selection's ownlimit, applied byapplyWindowafter the count.OS_DATA_*read limits judge only the selection's window atqueryDataset(the tool always names a limit, so no default-page probe), and the executor's sub-queries go throughqueryIn, which plans no window. Assembled grids:mergeByDimensionsappends and never drops; the derived pass and the empty-group fill keep the row count. ObjectQL face:engine.aggregatetakes no order or window, nativedriver.aggregateand thefindplus in-memory fallback read with no limit (the OData driver followsnextLinkto 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.gen:schema,gen:docs;check:generatedall 14 up to date);authorable-surface/ai.jsondid not move.dataset-group-count.tsheader no longer saysaggregate_recordscounts "with the same window": on main it answersrows.length, the length of the rowsengine.aggregateanswered before that tool's cap, which is the same reading as Source 2.Tests
packages/services/service-analytics/src/__tests__/dataset-tools.test.ts, inside the existing real-engine describe (ObjectQL+SqlDriver, SQLite always, PostgreSQL whereOS_TEST_POSTGRES_URLis set), every read of the object counted. The fixture gainsphase, aselectfield with options whose labels sort in another order than their values, so the plugin'slabelResolvermakes the dimension label-bearing in the real wiring.phase:totalGroups === rowCount === 3, one statement, no window function and noLIMITin it, no engine aggregate.maxQueryLimit: 2):truncated: true,totalGroups3, rows in label order; an empty page past the grid (offset: 10) still answers 3, since the in-memory window knows the whole grid.totalGroups5 with no window function in any statement; the date bucket and the ObjectQL face answer 3 and 5, and the ObjectQL face withphaseanswers 3, one engine aggregate each.NativeSQLStrategyand keeps two rows; the grid it cut answers nototalGroups.Red on the previous head, green, one ablation of the count, one mutation of the cap arm
Tests 4 failed | 7 passed | 89 skipped (100). The four failures are the label-bearing pair, the assembled grid and the engine-aggregate pin, eachexpected … to match object { rowCount: …, truncated: …, totalGroups: … }. The cap-arm pin passes there, as absence was that head's behaviour. Restored withgit checkout HEAD,git diff HEADempty.Tests 11 passed | 89 skipped (100).dataset-executor.ts, the line beforeapplyWindow, throughscripts/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 HEADempty.noteWholeReadstops 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 HEADempty.dist/was in the path and no dist preflight applies.Acceptance notes
GROUP_COUNT_DIALECTSare claimed by reading, not measured: MySQL and SQL Server (no server here). The gate is the dialect name, not the server version, so amysqlserver older than 8.0 would fail to parse the pushed-down statement; the repo assumes MySQL 8 elsewhere. The in-memory source needs no window function and is dialect-free. A follow-up card for the two unmeasured cells is the remedy.takeGroupCounttrusts the first row; feat(mcp): aggregate_records orders, cuts and counts groups in the database #35193'stakeAggregateGroupCountchecks that every row agrees and that the count is not below the rows returned. Not a correctness gap on the four dialects; worth closing when query_dataset: count totalGroups in the database on the ObjectQL face (date buckets) through aggregate_records' order-and-cut #35204 joins the two readers.engine.aggregatean order-and-cut, the count must come from the engine's statement; the ObjectQL strategy's comment says so at the count).skills/objectstack-ask/SKILL.mdteachestruncatedand could teachtotalGroups, including the S1 sentence; that isskills/**and follow-up objectstack-ask skill: teach query_dataset's totalGroups next to truncated #35203.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.tsis 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 typecheckthenvitest run:Test Files 944 passed (944),Tests 28892 passed | 1 todo (28893), VERDICT command-exit 0.pnpm --filter @objectstack/spec check:generatedafterbuild,gen:schema,gen:docs:All 14 generated artifacts are up to date. Its first run, before the regeneration, also reportedcheck:test-typecheckwithtsc … failed without diagnosticson 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;--ranwith the:: exit Nrecord:118 derived famil(ies) accounted for — 116 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3).check:skill-examplesandcheck: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 0against origin/main 1caee8c, 0 open PR heads sharing a 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, 10skipped, 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). Alsosuccess:Check Changeset,Spec property liveness,PR-body guards,Check PR Size,Build Docs.Temporal Conformance (live PG + MySQL)isskipped(opt-in). Whether a Test Core shard setsOS_TEST_POSTGRES_URLfor the PostgreSQL cell is not read here.Earlier rounds
Check Changesetfix,Metadata-protocol: addedand@objectstack/specminordeclared;check-changeset-no-majorexit 0 with that body and exit 1 with the previous one as control.check:generatedup to date, 118 derived families run,check:skill-examplesandcheck:dual-build-cjs-loadsNOT MEASURED (exit 3, need a whole-workspace build; CI runs both).Generated by Claude Code