Skip to content

Dataset executor: query_dataset accepts measures and dimensions the dataset does not declare (raw fields cited as metrics) #33745

Closed

Description

@objectstack-fleet

repo:cloud#5 · hotlong · session_01Q4EjjPP1zuWBNq3nBXVei9

Found by the seat's contract review on objectstack-ai/cloud PR #4557 (card cloud#4551, epic cloud#3825), hold 1. Measured at pin 181ad7d on the showcase kernel.

What happens

query_dataset accepts members the dataset does not declare: measures: ['amount'], ['count'], or an undeclared dimension. Field-level permissions still apply, so nothing leaks. But the provenance then cites an ad-hoc aggregate as a governed metric, and the answer reads 「来源:指标 amount · 数据集 …」.

ADR-0149 makes the dataset the one declared definition. An undeclared member is outside it.

Change

The executor refuses measures and dimensions the dataset does not declare. The error names the declared members, so the model can pick one or fall back to the record tools (the D3 fallback). Add tests.

Consumer: cloud's ask agent (PR #4557) labels a fallback as 非指标口径.

Activity

  1. added
    bug
    priority:p2
    on Nov 15, 2026
  2. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: first touch → domain:server · lease:A3 · p2 · 2026-11-15T09:46Z

    ⛔ Not a claim.

    query_dataset accepts measures and dimensions the dataset does not declare, so raw fields come back cited as metrics, which defeats dataset curation (cloud#4551). p2 (pre-graded). If an undeclared field also escapes field-level security, report it per security-findings.md, not on this card. A3 (analytics).

  3. added
    domain:server
    pm:queue
    on Nov 15, 2026
  4. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh

    Claim: PM loop round 1 (area S2 re-sit, #33751 §2; handover 6895263530)
    Session: session_01QsR2jUg7BKfRBcTPyMxbLh
    Account: zhuangjianguo
    Branch: claude/area-A3-33745
    Worktree: /home/claude/wt/area-A3-33745
    Domain: domain:server
    Seat: domain:server#5
    File surface: packages/services/service-analytics/src/dataset-tools.ts (query_dataset executor) and the dataset member resolution it calls · packages/rest/src/analytics-dataset-admission-order.ts / analytics-routes.ts only if the same executor answers there · tests beside them · .changeset/** — not service-analytics/src/strategies/** (open PR #33652) (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: TIER_DEFAULT (dispatch-gates --tier: no path-derived mandate), effort: high
    Clause-②: no (narrowing) — query_dataset stops accepting measures and dimensions the dataset does not declare; one CONTRACT_REVIEW_TIER review owed before the queue
    Metadata-protocol: none
    Responsibility: objectstack (service-analytics dataset executor, this repo) produces the risk · no platform path refuses an undeclared member today · reached by cloud's ask agent (cloud PR #4557) and any MCP/REST query_dataset caller
    Thread-read: 6892534979
    Premise: holds (measured by the reporter at 181ad7d; the dev re-measures on origin/main before the fix)
    Serial constraints cleared: #33652 (strategies/cross-object-where.ts, objectql-strategy.ts) not touched; no other open claim on dataset-tools.ts known

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 15, 2026
  6. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh

    Pre-claim check (seat rule of 13:55Z, applied after the claim 6895299179)
    Pre-claim lane: domain:server A3 because the executor is packages/services/service-analytics/src/dataset-tools.ts (query_dataset); the refusal reuses an existing error code (a new spec error code would be spec-lane work and the dev stops and reports)
    Pre-claim deps: none (#33652 touches service-analytics/src/strategies/** only, out of this surface)
    Prior rulings read: ADR-0021 ("a declarative, closed surface … declared dimensions and measures") and ADR-0149 (selection rule: no matching member → the object-query fallback, with provenance saying no governed metric) both support refusing an undeclared member; no ⛔ line or test allowing undeclared members found in docs/adr/0149, 0021; the change is served→refused on query_dataset, within the card's own Change section: Clause-② no (narrowing), BREAKING banner + ADR-0087 disposition in the changeset if the declaration self-check says so, one CONTRACT_REVIEW_TIER review before the queue

  7. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh
    os-dev-report

    {
      "issue": 33745,
      "status": "done",
      "branch": "claude/area-A3-33745",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/33958",
      "head_sha": "a711894f6c030e88c8a8d23db674ad578f881080",
      "session": "session_01QsR2jUg7BKfRBcTPyMxbLh",
      "premise_still_valid": true,
      "summary": "query_dataset's one executor (createDatasetTools in @objectstack/service-analytics, behind the chat registry face and the MCP tool on the HTTP and stdio bridges) now judges selection.measures, selection.dimensions and each timeDimensions[].dimension against the resolved dataset's own measures[].name / dimensions[].name, after the dataset resolves and before anything is read. An undeclared member (raw field, the ad-hoc count, an amount_sum suffix spelling, a dataset-qualified spelling) is refused 400 INVALID_FIELD via the existing invalidMemberError (member / param / cube), and the message names only the measures and dimensions THIS caller may use (list_datasets' admission; never a withheld or internal-field member) plus the D3 fallback (object query tools, 非指标口径). Declared-but-unreadable members still reach the service's own 403; missing/hidden dataset is still 404 first. The tool description states the rule; changeset is patch + BREAKING banner + ADR-0087 not-required (no-migration-prescription).",
      "hypotheses": "H1 held: on origin/main the executor served measures ['amount'], ['count'], dimensions ['amount'], 'pipeline.revenue', 'pipeline.stage' with provenance citing the raw names (probe run, 200 each). H2 held for MCP + chat (one executor; runtime/src/domains/mcp.ts and mcp/src/stdio-data-bridge.ts both bind service.datasetTools); FALSE for REST: POST /analytics/dataset/query calls AnalyticsService.queryDataset directly, not this executor, and is left unchanged (it serves dashboards/reports/ad-hoc selections; changing it is a different, wider narrowing, not the same refusal). H3: no implicit count; the dataset schema declares none and count is minted by the service's inferMeasure, so it is refused. H4 held: INVALID_FIELD / 400 (ADR-0149 D2 lists it; the tool invents no code); no spec change. H5 Prior rulings read: grep of docs/adr/0149 for undeclared/ad-hoc/declared member: no line allows undeclared members; D2 says refusals use the door's existing codes (NOT_FOUND, PERMISSION_DENIED, INVALID_FIELD, DATASET_INVALID); no test pinned the opposite (all query_dataset callers in rest/mcp/runtime/dogfood tests use declared members).",
      "tests": "Red first on the origin/main executor: dataset-tools.test.ts 7 failed / 35 passed. Green at a711894f: 43/43. service-analytics full suite at c8edb64f (fix + changeset, before the merge of main and the describe move): Test Files 215 passed, Tests 5227 passed | 335 skipped; typecheck exit 0 (tsconfig includes src tests); lock VERDICT command-exit 0. Dependents (built closures of rest, runtime, mcp): rest analytics-dataset-ai-tools-parity + keyword-field-name + lookup-dimension-labels + analytics-routes 4 files / 110 passed; runtime mcp-dataset-tools-bridge 6 passed; mcp mcp-dataset-tools + skill-md-surface-guard 24 passed; VERDICT command-exit 0. Ablation 1 (scripts/ablation-replace.mjs, call to assertDeclaredMembers replaced, anchor 1 -> 0, blob 310aa0a7 -> 80f26a1e): 8 failed / 35 passed; restored blob == HEAD, git diff HEAD empty. Ablation 2 (caller-visible filter widened to every declared member): 1 failed, AssertionError expected 'The dataset \"pipeline\" does not decla…' not to contain 'margin_total'; restored the same way. No build/dist leg needed: the suite imports ../dataset-tools.js from src. eslint --no-inline-config on the two touched source files: exit 0.",
      "gates": "dispatch-gates --commands --repo objectstack-ai/objectstack: 63 families derived (3 paths). 61 run at c8edb64f, every one exit 0 (check-plugin-teardown-shape --self-test first exit 3 PREREQUISITE, cleared with git fetch --depth=1 origin 621a4876..., rerun exit 0). Ratchet + changeset families rerun at final head a711894f: type-check-coverage, undeclared-dep-imports, engine-double-contract, keyed-text-bounds, cross-package-test-inputs, test-source-alias, nul-bytes, issue-citations, check-adr-0087-registration, check-changeset-no-major, check-empty-changeset, doc-authoring all exit 0; derived list at the final head identical. --ran reconciliation: exit 0, '63 derived, 61 run, 2 NOT-MEASURED, 0 UNRUN' (NOT-MEASURED check:dual-build-cjs-loads :: left to CI; check:type-check-debt :: lock held by another agent). PR body gates before pr_create (GITHUB_EVENT_PATH): check-changeset-no-major 0, check-closing-keyword-parity 0, check-adr-0087-registration 0 (notice: ADR-0087 exemption no-migration-prescription), check-partof-closing-keyword 0. CI at a711894f: Lint & Repo Gates success (Lint · ESLint success, Lint · PM dispatch-gates success), TypeScript Type Check success (Type Check · debt ledger success), Test Core success (1-8/8), Build Core success, Governed Surface Queue Guard success, Check Changeset success, PR-body guards success, Dogfood Regression Gate success (shards skipped on PR; they run in the queue), Live E2E UI success, Test UI success; Lint UI / Type Check UI / Build & E2E UI skipped (no ui path). merge-tree --write-tree --name-only HEAD origin/main: clean (3650ce6e), no conflicted paths; open PRs sharing a file: none (59 open PRs, files listed per PR, none touches dataset-tools.ts, its test or the changeset).",
      "dogfood_battery": "NOT MEASURED at a711894f, reason: os-verify-lock queue — five attempts under the kept slot area-A3-33745 each ended VERDICT queue-timeout (exit 99), never acquired, about 45 min queued; holder pid 13306 (scratchpad/issue-33791/suites2.sh, a sibling agent's metadata-protocol + runtime + objectql + cli suites) alive and held 2316s at the last reading. The battery does not exercise the refusal: the only dogfood query_dataset calls (dataset-package-scoped-readers.dogfood.test.ts) select declared measures (row_count, task_count). CI's Dogfood Regression Gate runs the shards in the merge queue.",
      "line_budget": "189 changed lines (+183 / -6, 3 files) vs the 3000 human-merge threshold: under. No skills/** touched.",
      "files_changed": [
        "packages/services/service-analytics/src/dataset-tools.ts",
        "packages/services/service-analytics/src/__tests__/dataset-tools.test.ts",
        ".changeset/33745-query-dataset-declared-members.md"
      ],
      "writes": "git push x5 to claude/area-A3-33745 (empty probe, fix, changeset, merge of origin/main, describe move); pr_create x1 via fleet-write relay (request fw-20261115T145630Z-fcd35b, run 43727082520 success, PR #33958, 6366 bytes sent = stored, draft true, no assignees, no labels); os-dev-report comment x1 via post-stamped on #33745.",
      "mcp_calls": "0",
      "api_writes": "2 — POST repository_dispatch through the fleet-write relay (pr_create -> POST /repos/objectstack-ai/objectstack/pulls), and POST /repos/objectstack-ai/objectstack/issues/33745/comments through post-stamped (this report).",
      "deviations": "(1) PM rule of 14:45Z 'new tests in a NEW file named by the card' conflicts with AGENTS.md (ruling record 6583487846: a new pin for a component with a shared harness file goes into that file as a top-level describe, not a new file). AGENTS.md outranks the dispatch, so the pins are one top-level describe ('query_dataset refuses a member the dataset does not declare') in dataset-tools.test.ts, reusing its bootWired harness; flagged here, not silently chosen. (2) The PR body ends with the dispatch's footer line; durable session attribution is in the Verification prose (session URL), not a second footer line. (3) pnpm lint repo-wide not run locally (CI-owned per os-dev.md; CI Lint · ESLint success at head); eslint on touched files exit 0. (4) Full rest/runtime/mcp suites not run locally: the dataset-tool files of each were run; CI Test Core 8/8 success at head. (5) A dataset-qualified spelling of a DECLARED member (pipeline.revenue) is refused too, a judgment beyond the card's examples: it is not a name list_datasets lists and its provenance carried no label; called out in Acceptance notes in case a consumer relies on it. (6) PM addendum on contract declaration: Clause-② no (narrowing) is BREAKING per AGENTS.md Post-Task Checklist 3, so the changeset carries a BREAKING banner, the PR title and changeset subject carry '!', and the ADR-0087 marker is not-required (no-migration-prescription): no metadata key, value or stored row moves, so os migrate meta has nothing to rewrite; level patch because Metadata-protocol: none (a non-protocol breaking change ships patch per AGENTS.md; minor beside none is refused by check-changeset-no-major). dispatch-gates --tier: no path-derived mandate; narrowing owes one CONTRACT_REVIEW_TIER review before the queue. A dogfood TEST covering the refusal would live in packages/qa/dogfood, outside the claim's file surface, so none was added; the unit pins cover both executor faces.",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted, not filed — REST POST /analytics/dataset/query with a saved datasetName still answers undeclared measures/dimensions (minted by AnalyticsService) by design for dashboards/reports; it has no provenance block, so no metric is mis-cited there. If the maintainer wants the same closed-member rule on the REST door that is a separate, wider narrowing (Console widgets may send minted measures). Dedupe words: dataset query undeclared measure REST door, ad-hoc count dataset selection, closed member set dataset"
      ]
    }
  8. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh

    Landed: PR #33958 merged; Fixes closed this card.

    reading value
    PR #33958 head at landing 3f717733 · 37 success / 18 skipped / 0 failure · ACCEPT 6897548976
    merge b4ce310b88e902c3844f0a709ceb2e277939dc31 at 2026-11-15T16:44Z; card closed (completed) by it

    State change: pm:dispatched and lease:A3 removed, assignee cleared. Left over: the REST dataset door and the ADR-0149 D2 line → #34005 (needs-user-decision).

  9. removed
    pm:dispatched
    on Nov 15, 2026
  10. added a commit that references this issue on Nov 16, 2026
    b4ce310
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdomain:serverpriority:p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions