Repository navigation
feat(spec,service-analytics): a dataset answer says which records each measure counted, so a drill lists what the number counted - #30596
Conversation
Claude-Session: https://claude.ai/code/session_01L6bhgXexAhb1ogpnymn5Jb Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6bhgXexAhb1ogpnymn5Jb Co-authored-by: Claude <noreply@anthropic.com>
…passed through by the adapter The response schema and the AnalyticsResult contract carry `drillScopes` (measure name -> FilterCondition on the answer's object); the spec pins accept every scope verbatim and refuse a non-condition value. The data-objectstack adapter hand-picks the keys it returns, so it now lists `drillScopes` too, typed as the spec slot. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgXexAhb1ogpnymn5Jb
`pnpm --filter @objectstack/spec gen:docs`, the one artifact `check:generated` proved stale. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgXexAhb1ogpnymn5Jb
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgXexAhb1ogpnymn5Jb
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgXexAhb1ogpnymn5Jb
📓 Docs Drift CheckThis PR changes 2 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 170 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 e9cbbb8b926f68aeabf7ef81c789daae730d0b21 && git checkout e9cbbb8b926f68aeabf7ef81c789daae730d0b21
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 739c972735d6feb9d1eea7be5d943cf340486fed ba62840b7d742525f60c41a225359ea3887b3a72 && git checkout -B drift-repro 739c972735d6feb9d1eea7be5d943cf340486fed && git merge --no-ff ba62840b7d742525f60c41a225359ea3887b3a72
node scripts/docs-audit/affected-docs.mjs --json 739c972735d6feb9d1eea7be5d943cf340486fed
|
|
domain:spec#2 · os-sales · session_01L6bhgVugtCCwBs98FeR27P Contract reviewServed-tier: Inputs read: card #30526 body and all five comments (triage 6661303021, claim 6662301380, amendments 6662348690 / 6662348741, os-dev-report 6664363611); PR #30596 body, its 13-file list, and the net diff ① Derived judgments
② Semver levelChangeset ③ Boundary flagsEach flag from the os-dev-report (6664363611) and the PR body's Acceptance notes:
④ Design judgment
should-fix —
should-fix — Implemented-by: VERDICT: PASS Generated by Claude Code |
|
domain:spec#2 · os-sales · session_01L6bhgVugtCCwBs98FeR27P 维护者速读
席位核对ACCEPT · head
Generated by Claude Code |
Requested by Sales · project thread
domain:spec#2 · os-sales · session_01L6bhgXexAhb1ogpnymn5Jb
Fixes #30526
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
drillScopes,按度量说明“这个数字统计的是哪些记录”:数据集自己的筛选,加上度量自己的筛选,再加上被汇总的字段有值。packages/services/service-analytics/src/drill-scope.ts(什么算范围、什么时候不给);②packages/services/service-analytics/src/analytics-service.ts里提前解析占位符和写result.drillScopes的两处;③packages/spec/src/api/analytics.zod.ts的字段说明。pnpm --filter @objectstack/service-analytics exec vitest run src/__tests__/dataset-drill-scopes.test.ts,预期 20 个测试全部通过,其中标着 CONTROL 的一条表明:不带范围时列出 4 条记录,而数字是 2。What changes
The precedent is
drillRanges(#27074), and before itdimensionFields/drillRawRows(#20700). Those keys bound the clicked bucket. This PR adds the fifth drill sidecar, which bounds the clicked measure. It sits on the same answer and follows the same rule (ADR-0021 D2: the server states the drill bounds, and the client never restates dataset semantics).@objectstack/spec:AnalyticsResult.drillScopes, optional, a map from measure name toFilterCondition, declared on theAnalyticsResultResponsewire schema too. Each selected measure name maps to the list filter on the answer'sobjectthat selects the records the measure aggregates. The filter is built from three parts:filter;filter;{ field: { $null: false } }, or both instants for a duration measure.Tokens are resolved as the query resolved them. The value is
{}when no part applies. A measure is left out when no list filter can select its records, and a measure left out offers no drill (the [Decision] Dashboard numbers cannot be opened: should a tile lead to the records behind it? #30080 ruling, option A). That happens in three cases:account.regionas a key, or a dotted$field);A
__comparecolumn has no entry.drillScopesis set on every dataset answer that has rows. It is absent on a cube query answer and on a draft-preview answer.@objectstack/service-analytics:queryDatasetcomputes the scope indrill-scope.ts(measureDrillScopes, a pure function). It takes the token-resolved filters from before the dataset door's field binding, because the binding's minted member names are request-local and no record list knows them.resolveSelectionTokensis now exported and called once inanswerDataset. The executor and the scope read the same resolved trees, and the executor's own call is then the identity.datasetMeasureSourcefinds what a measure aggregates the same way the queries did:CUBE.-qualified;durationMeasureIn;scopedMeasureKey;mintCallerMeasures.@object-ui/data-objectstack:queryDatasethand-picks the keys it returns, so it dropped any sidecar it did not list. This was measured before the change: the key never reached a widget. It now passesdrillScopesthrough, typed as the spec slot.Generated:
content/docs/references/api/analytics.mdx(gen:docs, the one artifactcheck:generatedproved stale). Ledger:packages/spec/dropped-refinements.baseline.jsongains one site; see the Acceptance notes.What each consumer must compose (not in this PR: #30080 and the ui card the seat files at landing)
A drill of a clicked number on measure
Mlists{ $and: [bucket, widgetFilter, drillScopes[M]] }onobject, leaving out any part that is absent:bucketwidgetFilterplugin-reportdataset renderer)buildDatasetDrillFilteroverdimensionFields+drillRawRows[i]+drillRanges[i](a totals row:drillRawTotals[i][j])runtimeFilterdrillScopes[M]plugin-dashboardDatasetWidget)runtimeFilterdrillScopes[M]of the clicked seriesruntimeFilterdrillScopes[M]If
drillScopeshas no entry forM, the consumer offers no click.{}means "drillable, nothing to add", which is a different thing from a missing entry.Why
A dataset number is computed under the dataset's
filter, the measure'sfilterand the widget'sruntimeFilter. A host that drills the number holds only the last one, and it has no read of the dataset definition. So every drill of a filtered measure listed a superset of what the number counted. On the showcase shape, the bucket listed 4 invoices behindpaid_count2. #30080 (the dashboard tile click, ruled option A) waits on this answer.Tests
packages/services/service-analytics/src/__tests__/dataset-drill-scopes.test.ts(new, 20 tests):examples/app-showcaserevenue-pulse:paid_count= count withfilter: { status: 'paid' }, andpaid_ratederived). Pins:$fieldkept;JSON.stringify, parsed byAnalyticsResultResponseSchema, keeps every scope.SqlDriveron SQLite, both faces, with and without a widget filter). Every count's composed drill (bucket ∧ widget ∧ scope) lists as many records as the number, and the sum adds up. Further pins:paid_count2;engine.findrefuses the dotted key withINVALID_FIELD.packages/spec/src/api/analytics.test.ts: the response schema keeps each scope verbatim. It refuses these malformed values atdata.drillScopes:$andgiven an object;packages/spec/src/contracts/analytics-service.test.ts: a typeddrillScopesread on the contract, plus a@ts-expect-erroron a string scope.ui/packages/data-objectstack/src/queryDataset.test.ts:{}included;undefined;nullis dropped;AnalyticsResult['drillScopes'].Acceptance notes
COUNT(field), Measure definitions are not fully compiled:aggregate: 'count'ignoresfield, and/api/v1/analytics/querydrops every per-measurefilter— the SQL isCOUNT(*)for all of them #10298), so without the leg,count of totalwould list rows whosetotalis empty.{}for a measure with nothing to add, so that "absent" keeps one meaning: no drill.{ account: { tier: 'gold' } }) is kept, because the record list serves it. A dotted path is left out, because the list refuses a dotted filter key. A later change could lower a one-hop dotted path to the nested form; this PR does not.dropped-refinements.baseline.jsongainsapi/AnalyticsResultResponse→data.drillScopes.valueType.lazy. This is the sameFilterConditionSchemalazy refinement already admitted atapi/AnalyticsQueryRequest→where.lazy, and the spec build prints this entry. Header totals move 251 → 252 schemas and 1019 → 1020 sites.filter("the nested-relation form, which the engine serves in 'where' only"). So a dataset measure whosefilteris{ account: { tier: 'gold' } }fails the whole answer, even though the dataset schema accepts it. This was measured at the service on SQLite, not at the HTTP door.data-objectstackalso dropsdrillRawTotals. No ui code reads it today, so the gap is not felt.claude/project-thread-mg9ioh, notclaude/issue-30526-*, as amended on the claim.data-objectstackadds 1 + 3no-explicit-anywarnings. These are(data as any)and testas anycasts in the files' existing pattern; there are 0 errors.Verification
Head
ba62840b(branch basec23eafa8,origin/mainf5aaa0bcmerged in), underos-verify-lock,NODE_OPTIONS=--max-old-space-size=8192. Every count below is a VERDICTcommand-exit 0unless it says otherwise. Every suite below ran twice, once at25fc5696before the merge and once atba62840bafter it, with the same counts both times.pnpm --filter @objectstack/spec build && pnpm --filter @objectstack/spec check:generated: 14 of 14 artifacts up to date, aftergen:docs, which was the one artifact it proved stale. At the default 4096 MB heap,check:test-typecheckstops with "tsc failed without diagnostics", an out-of-memory error and not a verdict. At 8192 MB it passes: 52 files, 240 errors, all 131 pinned signatures held.pnpm --filter @objectstack/spec test: Test Files 815 passed (815), Tests 25648 passed, 1 todo.pnpm --filter @objectstack/spec typecheck: exit 0.@objectstack/service-analytics:testgives Test Files 211 passed (211), Tests 4996 passed, 300 skipped.typecheck: exit 0.@object-ui/data-objectstack:testgives Test Files 115 passed (115), Tests 1319 passed.type-check: exit 0.git grep drillRangeslists:@object-ui/core233 files passed (4376 tests),@object-ui/plugin-dashboard202 files passed (1932 tests),@object-ui/plugin-report33 files passed (307 tests).Ablation of the serving half (scripts/ablation-replace.mjs, restored to the HEAD blob bca6a0582f42)
result.drillScopes = measureDrillScopes({becamevoid measureDrillScopes({inanalytics-service.ts. The anchor count went 1 → 0, and the blob wentbca6a0582f42→98dc47836851.dataset-drill-scopes.test.ts: 17 failed | 3 passed (20).engine.findrefuses a dotted key), none of which goes through the service.git diff HEADis empty. The test imports the service fromsrc, so no rebuild was needed.Gates: dispatch-gates --commands, 110 derived at ba62840, 110 run, 0 NOT-MEASURED
node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran ran.listprinted "110 derived famil(ies) accounted for — 110 run, 0 NOT-MEASURED (a DERIVED zero — all 110 recorded an exit code and none of them is 3)" and exited 0. Every line isexit 0.check:skill-exampleslacked theclient-reactdist.check:dual-build-cjs-loadslacked the dists of account, setup, studio, client-react, cloud-connection, connector-imap and connector-mcp.turbo run buildof those 7 packages, both exit 0.check-plugin-teardown-shape --self-testneeded its pinned fixture commit621a4876fetched into the shallow clone first. The longest runs:check:type-check-debt277 s,check:query-options-erasure201 s,uivitest run scripts/192 s.!in the title and no(narrowing)arm, so there was no full dogfood run. CI owns the rest of the farm.Human Minimum
packages/specholds no runtime logic (one optional field and its describe; the scope is computed inservice-analytics).pnpm lintis the CI run).main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed.content/docs/references/(regenerated bygen:docs),packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01L6bhgXexAhb1ogpnymn5Jb