Repository navigation
fix(service-analytics): query_dataset never pairs an empty answer with a group count - #35286
Conversation
…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
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7
📓 Docs Drift Check
What this run could not see
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head
|
|
repo:objectstack#5 · os-bill · session_01Utp6CazXu8zyYD5PC6J2u7 Landing · ACCEPT (L1-a) → PR #35286 comment 6997893766 · head
Area ai-1 landing armed (ready + auto-merge); #35204 close-out on MERGED. |
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
totalGroupsis 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头注释写明「整网格证明」止于策略自己的读取接缝。rowCount: 0)与已写入的分组数配对,AI 会读到一个从未返回的网格的分组数;N5 是一句说明边界的注释。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
dataset-executor.ts).executenow handsexecuteSelectiona local group-count request and copies its outcome into the caller's slot only after thetotalsgroupings have run. Before, the slot was written while the primary grid was read; atotalsread that then threw a missing-source error madeanswerDatasetserve{ rows: [] }, andquery_datasetansweredrowCount: 0beside the primary grid'stotalGroups. Any throw after the count now leaves the slot empty.dataset-group-count.tsheader). 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.@objectstack/service-analyticspatch.Tests
New top-level describe in the shared
query_datasetharness,src/__tests__/dataset-tools.test.ts:[query_dataset totalGroups] a totals read that meets a missing source serves no count. Real SQLite engine throughAnalyticsServicePlugin; the second statement of the call fails asno such table.{ rowCount: 3, truncated: false, totalGroups: 3 }, two statements, the first carryingCOUNT(*) OVER ().rowCount: 0) and nototalGroups; the primary statement still ran and counted.Acceptance notes
origin/mainf4dbcc21: 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'sStrategyContextand the plugin's auto-bridge), carries no read option, and the engine REFUSES (throwsINVALID_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 ofapplyOrdering). Returned to the seat as a decision.totalGroupson 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.mjsreplacedthis.executeSelection(compiled, selection, context, counted);with the pre-fix…, options?.groupCount);(anchor 1 to 0, blob1e56cd1b5e95to9ab686e51c1b). 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 HEADempty. No dist leg: the suite imports the executor fromsrc.Derived gate families (dispatch-gates, 66)
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