Repository navigation
fix(service-analytics)!: query_dataset refuses a selection that names no measure, as the REST dataset door does - #33141
Conversation
…no measure, as the REST dataset door does Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvxW3CnsR8FmFCXFQn
…ive one answer to a selection naming no measure Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvxW3CnsR8FmFCXFQn
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvxW3CnsR8FmFCXFQn
📓 Docs Drift Check2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. 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): 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 a975c8990947158dfc1e743764b7325cb5177707 && git checkout a975c8990947158dfc1e743764b7325cb5177707
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a83c366702b26d653a975d533dde4dabb30030e1 4beb312f7d335907a8c875904b53a73b1def6165 && git checkout -B drift-repro a83c366702b26d653a975d533dde4dabb30030e1 && git merge --no-ff 4beb312f7d335907a8c875904b53a73b1def6165
node scripts/docs-audit/affected-docs.mjs --json a83c366702b26d653a975d533dde4dabb30030e1 |
|
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx Contract reviewServed-tier: ① Derived judgmentsAccept-set changes, all on
② Semver level
③ Boundary flags
④ Design judgment
Attempts to break it, none of which landed: Findings:
No must-fix, no should-fix. Final round for this head; the nits are accepted deviations or follow-up material. Check-runs read on this head (49 total): success 15, skipped 16, in_progress 18, failed 0.
Implemented-by: VERDICT: PASS |
|
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx 维护者速读 · PR #33141 @
|
Requested by Tesla · project thread
Fixes #33028
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill under
skills/**teachesquery_datasetselections; the only page naming the tool is the generatedcontent/docs/references/ai/dataset-tools.mdx, whose input shape is unchanged维护者速读
query_dataset(MCP 工具和产品内 AI 对话工具都走同一个执行器)时,如果selection.measures是空数组,现在在读任何数据之前直接拒绝,返回 400VALIDATION_FAILED,错误文案与 REST 接口POST /api/v1/analytics/dataset/query对同一请求的回答一字不差。DATABASE_ERROR和驱动原文;带维度时则返回没有任何度量的分组行。REST 那边早就拒绝了,两扇门对同一个请求给出不同答案。packages/services/service-analytics/src/dataset-tools.ts的queryDataset新增的一行判断与上方的文案常量;packages/qa/dogfood/test/dataset-package-scoped-readers.dogfood.test.ts新增的 REST 与 MCP 同答案用例。pnpm --filter @objectstack/service-analytics exec vitest run src/__tests__/dataset-tools.test.ts,预期 28/28 通过,其中两条refuses measures: []用例为绿。BREAKING for a caller that sent
query_dataseta selection withmeasures: [].500 DATABASE_ERRORwith its own statement error (near "FROM": syntax error), and withdimensionsthe tool served group rows carrying no measure.400 VALIDATION_FAILED,body.selection.measures must be a non-empty array of measure names., before the dataset is resolved or any row is read: the answerPOST /api/v1/analytics/dataset/querygives the same selection. The fix for a caller: name at least one measure from the dataset, aslist_datasetslists them.What changes
@objectstack/service-analytics—createDatasetTools(...).queryDatasetrefuses a selection whosemeasuresis empty, right after the input parse and before the dataset read, with codeVALIDATION_FAILED, status 400 and the REST door's sentence. The check runs before resolution, as the REST door's does (answerDatasetQueryjudges the measure list before it resolves the dataset), so a missing dataset with no measure gets the same 400 on both doors rather than a 404 on one of them.query_datasettool (packages/runtime/src/domains/mcp.ts,buildMcpBridge) and the product AI's chat tool (execute, the registry face). The chat face had the same gap at the same seam; it is fixed here as an adjacent same-class fix, per claim amendment 6858058804. Evidence: the new unit pin drives both the direct member andexecute, and both answered rows atorigin/main(below).errorResultWithCoderelays a thrown refusal'scode,statusandmessagewhole (thrownRefusalEnvelope), so the MCP tool answers exactly what the executor throws. The dogfood pin proves it over the live/api/v1/mcptransport.packages/specchange.DatasetSelectionSchemastill acceptsmeasures: []; the rule is enforced at the two doors, not moved into the shared schema.@objectstack/rest(the REST door) and@objectstack/service-analytics/@objectstack/mcpshare no runtime dependency, so neither can import the other's check. The dogfood suite, which boots both doors in one stack, holds them to one answer for one caller: the new case sends the same selection to both and asserts equal code, status and message.Tests
packages/services/service-analytics/src/__tests__/dataset-tools.test.ts(+3):measures: []without and with dimensions is refused 400VALIDATION_FAILEDwith the REST sentence on the direct member AND throughexecute,service.queryDatasetis never called and nothing is read; CONTROL: a selection naming a measure, with dimensions, is served on both faces as before.packages/qa/dogfood/test/dataset-package-scoped-readers.dogfood.test.ts(+2, the agreement pin): on the booted showcase,measures: []without and with dimensions answers400 VALIDATION_FAILEDwith the sentence onPOST /analytics/dataset/query, and MCPquery_datasetanswers an error whose code, status and message equal the REST answer's.Acceptance notes
service.queryDataset(,datasetTools(): the REST single and batch doors go throughanswerDatasetQuery, which already refuses; the MCP tool and the chat tool go throughdataset-tools.ts, fixed here. No other door reachesAnalyticsService.queryDatasetwith a caller's selection.body.selection.measures; the tools now answer the same words, by the order's parity rule, though a tool input has nobody. Rewording it would mean changing both doors together.ruling|Ruling-ref|maintainer|⛔):dataset-tools.tsL295 and its test L472/L513 cite the admission-first ruling 6766102988 (only holders the caller may query are candidates; a hidden holder is never named). The new refusal is consistent with it: it is judged on the caller's own input before any dataset is read, and names no dataset or holder. The dogfood file has no hit.Verification
All readings at head
4beb312f(base7c36f524,origin/mainmerged once at4beb312f; the merge brought onlypackages/lintchanges) unless named.Measured at origin/main first (the premise holds)
dataset-tools.test.tswith the new pins over the unfixed executor (7c36f524): 2 failed | 26 passed (28). Bothmeasures: []cases were SERVED instead of refused: the direct member returned an answer object (rows,rowCount: 1,provenance, …), not aVALIDATION_FAILEDthrow./api/v1/mcpwith the guard ablated indist/(below): MCPquery_datasetwithmeasures: []answered{ code: 'DATABASE_ERROR', … }(server log:[sql-driver] DATABASE_ERROR … near "FROM": syntax error), and withdimensions: ['status']it answeredisError: falsewith rows: the card's two observations, reproduced.Package tests and typecheck (service-analytics)
pnpm --filter @objectstack/service-analytics test— Test Files 215 passed (215), Tests 5187 passed | 332 skipped (5519)pnpm --filter @objectstack/service-analytics typecheck— exit 0;tsc --listFilesincludessrc/__tests__/dataset-tools.test.ts(1 hit)dataset-tools.test.ts— Tests 28 passed (28)dataset-package-scoped-readers.dogfood.test.ts— Tests 18 passed (18)Ablations of the guard (both red, both restored)
scripts/ablation-replace.mjsondataset-tools.ts, anchorif (raw.selection.measures.length === 0) throwx1 -> x0, replacementif (false) throwx0 -> x1, blob788afd5b->c09a6df0.dataset-tools.test.ts: 2 failed | 26 passed (28), the tworefuses measures: []cases. Restored: blob == HEAD (788afd5b),git diff HEADempty. The test imports the source, so nodist/leg.dist/): same anchor, replacementif (raw.selection.measures.length === -7) throw, blob788afd5b->befa3942;pnpm --filter @objectstack/service-analytics build;ablation-dist-preflight.mjs @objectstack/service-analytics 'length === -7'exit 0.dataset-package-scoped-readers.dogfood.test.ts: 2 failed | 16 passed (18), the two new cases (DATABASE_ERRORwhereVALIDATION_FAILEDwas expected;isErrorfalse with dimensions). Restored: blob == HEAD,git diff HEADempty; rebuilt;ablation-dist-preflight.mjs … --absentexit 0 (marker absent from all 6 built files, tree clean).Full dogfood battery (Clause-② narrowing arm)
pnpm --filter @objectstack/dogfood testunder the verify lock at4beb312f: Test Files 460 passed | 3 skipped (463), Tests 3876 passed | 42 skipped (3918),VERDICT command-exit 0.Derived gates and lint
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackat4beb312f: 66 families, each run with stdin closed and its exit code recorded before any pipe.--ranreconciles 66 accounted, 65 run, 1 NOT MEASURED:pnpm check:dual-build-cjs-loads— exit 3, PREREQUISITE NOT MET: its self-test passed (93 cases), the scan needsdist/of packages outside this diff's closure (studio, client-react, scenarios, embedder-openai, knowledge-*). NOT MEASURED; CI runs it.All other 65 exit 0,
check:nul-bytes,check:engine-double-contract,check:test-source-alias,check:cross-package-test-inputsandcheck:adr-0087-registrationamong them.node scripts/check-plugin-teardown-shape.mjs --self-testfirst exited 3 (its pinned positive control was not in the shallow clone); aftergit fetch origin 621a4876, exit 0, 48 cases.pnpm lint— exit 0. No export was renamed or removed, socheck-platform-checklist.mjsis not owed.Generated by Claude Code