Skip to content

MCP query_dataset returns one more drillRawRows entry than rows when it truncates at the caller limit #32944

Closed

Description

@objectstack-fleet

domain:devx#1 · os-elon-musk · session_016WV4czj9tecb4nj5MfUyYk

QA-source: #32940 · ai.mcp-dataset-tools · observed beside the clauses

Found by an off-clause probe of the 18.4.0 release acceptance (wave anchor #32908) at main @ 5fb79bc0. Full evidence chain: QA run #32940, P-1, and its R4 comment.

What happens

When MCP query_dataset truncates its answer at the caller's limit, drillRawRows carries one more entry than rows, so the index-aligned drill sidecar no longer lines up with the rows a client shows.

Reproduction

MCP query_dataset {datasetName: "showcase_invoice_metrics", selection: {measures: ["invoice_count"], dimensions: ["status"], limit: 1}} on a stock showcase boot, as admin:

  • Expected rows 1, drillRawRows 1, truncated: true.
  • Actual rows 1, drillRawRows 2 ([{status: draft}, {status: paid}]), truncated: true.
  • With limit: 2: rows 2, drillRawRows 3.

Reproduced twice. Not a disclosure: the caller may query that group anyway.

Mechanism (read at 5fb79bc)

packages/services/service-analytics/src/dataset-tools.ts: the tool asks the service for cap + 1 rows so truncated is a fact, slices rows to cap, then spreads ...rest from the answer untrimmed. Every index-aligned sidecar in rest (drillRawRows, and any sibling the answer carries) keeps the probe row.

Activity

  1. added
    bug
    on Nov 13, 2026
  2. objectstack-fleet commented on Nov 13, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: first touch → domain:server · p1 · pm:queue · 2026-11-13T00:47Z

    ⛔ Not a claim.


    Generated by Claude Code

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

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: regrade p1 → p2 under the adopted grading rules (#32997) · 2026-11-13T03:03Z

    ⛔ Not a claim; the card's claim and state are unchanged.


    Generated by Claude Code
    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: regrade p2 → The trailing drillRawRows entry is one extra probe row past the cap, and the first rows stay index-aligned, so an agent does not get a wrong answer for the rows it shows. Base p3 (a client-visible inconsistency with a workaround). Rule 8's focus raise does not apply. One raise for "a real user can hit" (a default config, documented tool) gives p2. under the adopted grading rules (#32997) · 2026-11-13T03:03Z

    ⛔ Not a claim; the card's claim and state are unchanged.


    Generated by Claude Code

  5. added
    priority:p2
    and removed
    priority:p1
    on Nov 13, 2026
  6. objectstack-fleet commented on Nov 13, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

    Claim: PM loop round 6, card thread · 2026-11-13T18:57Z · MCP p2 under the maintainer's 「mcp 相关 p2 任务也可以派发处理」 (2026-11-13T15:50:52Z)
    Session: session_01L9qibxxaZKwWGECdLG6N1s
    Account: os-tesla
    Branch: claude/project-thread-ek0gcw
    Worktree: objectstack-issue-32944
    Domain: domain:server
    Seat: domain:server#7
    File surface: packages/services/service-analytics/src/dataset-tools.ts (queryDataset truncation), its tests, packages/rest/src/analytics-routes.ts only if it shares the code path, one root changeset. Stop on breach.
    Container & model: S, mode:thread, model: default (dispatch-gates --tier: no path-derived mandate; PM default), effort: medium
    Clause-②: no — the answer's index-aligned sidecars are trimmed with its rows; nothing is newly accepted or refused
    Metadata-protocol: none
    Responsibility: the untrimmed sidecar comes from queryDataset in service-analytics dataset-tools.ts (objectstack) | the rows slice beside it already trims the probe row | every MCP or chat client drilling a truncated dataset answer reaches it today
    Thread-read: 6842554470
    Premise: re-measure — reproduced twice by devx#1 at 5fb79bc0; PR #33141 changed queryDataset since, so the dev reproduces at origin/main first
    Serial constraints cleared: dataset-tools.ts was last changed by PR #33141 (merged); no open seat-7 PR touches it

  7. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 13, 2026
  8. objectstack-fleet commented on Nov 13, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#7 · os-tesla · session_01L9qibxxaZKwWGECdLG6N1s
    os-dev-report

    {
     "issue": 32944,
     "status": "done",
     "branch": "claude/project-thread-ek0gcw",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/33146",
     "session": "session_01L9qibxxaZKwWGECdLG6N1s",
     "premise_still_valid": true,
     "summary": "query_dataset (createDatasetTools in service-analytics, serving the MCP tool and the chat tool) now trims the answer's row-aligned members to the served row count when it truncates. Enumerated from AnalyticsResult: row-aligned and trimmed = drillRawRows, drillRanges; not row-indexed and served as answered = fields, totals, drillRawTotals (aligned to totals), dimensionFields, drillScopes (keyed by name), object; sql still stripped. The REST door (analytics-routes.ts) passes the caller's selection to the service unchanged and does not truncate, so it has no over-read and is not touched. Changeset .changeset/32944-query-dataset-drill-rows-truncation.md, patch.",
     "tests": "Measured at origin/main bf02d33b: new pins 3 failed | 1 passed (limit 1: drillRawRows length 3 expected 1; limit 2: length 3 expected 2; sidecar case: drillRawRows kept 3 entries). At head bbc366d8: dataset-tools.test.ts 32/32; pnpm --filter @objectstack/service-analytics test: Test Files 215 passed (215), Tests 5199 passed | 332 skipped; typecheck exit 0, tsc --listFiles includes dataset-tools.test.ts (1). Ablations via scripts/ablation-replace.mjs (source import, no dist leg): (1) trim disabled (if (truncated) -> if (false as boolean)), blob b32f38f4 -> a31b8c2b: 3 failed | 1 passed; (2) drillRanges dropped from ROW_ALIGNED_ANSWER_MEMBERS, blob b32f38f4 -> e1acd138: 1 failed | 3 passed (drillRanges kept 3 entries, expected 2). Both restored: blob == HEAD b32f38f4, git diff HEAD empty.",
     "gates": "dispatch-gates --commands at bbc366d8: 62 families, stdin closed, exit codes captured before any pipe; --ran reconciles 62 accounted, 61 run, 1 NOT MEASURED (pnpm check:dual-build-cjs-loads exit 3 PREREQUISITE NOT MET: self-test 93 cases passed, scan needs dist of packages outside the closure; CI runs it). check-plugin-teardown-shape --self-test first exit 3 (pinned fixture 621a4876 not in clone), exit 0 after git fetch, 48 cases. pnpm lint exit 0. Record: /mnt/project-files/server-seat-7/r2026-11-13/out/32944-gates-ran-bbc366d8.list. CI check-runs: in_progress at report time.",
     "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
     "mcp_calls": "3 — reads only: issue_read get #32944, issue_read get_comments #32944, pull_request_read get #33141; 0 writes",
     "api_writes": "2 — fleet-write relay pr_create (#33146, assignees os-tesla, read back identical 7884 bytes); post-stamped comment on #32944 (this report)",
     "open_questions": [],
     "security_findings": "none",
     "out_of_scope_findings": [
      "carrier: none · noted, not filed — a limit: 0 call serves no rows yet keeps dimensionFields and drillScopes, whose contract says they are set only on an answer with rows (read-only inference, no reported caller); in the PR's Acceptance notes"
     ]
    }

    Generated by Claude Code

  9. removed
    pm:dispatched
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugdomain:serverpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions