You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7ed18b5
Browse filesBrowse the repository at this point in the historyBrowse files
fix(analytics): a grouping or time word with only a near dimension does not stop a matched measure (#35156)
Part of #35005
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:`list_datasets` 的 `nextStep.note` 不再为「候选全是维度」的词追问。「按行业看销售额」里
销售额 精确命中、「按行业」只靠近维度 行业,现在 note 直接让模型计算 销售额,并把 行业
作为「可能的分组」点名,明确说不要就它追问;候选里有指标的词(如单独的「销售」)照旧追问、不计算。`list_datasets` 工具说明和
MCP `initialize` 规则用同一句话写明这条限定。
- **为什么改**:#35005 卡面
p1。普通问法(按行业看销售额、本季度营收)因为分组词/时间词碰巧靠近某个维度,被反问一句,用户体验差;只有被度量的那个词才值得追问。
- **风险与回滚**:只改 note 文案与两处说明文字。`decision`、`terms`、`matches`、`candidates`
对任何输入都与改前一致(规范对 `candidates_only` 的定义不动)。回滚即 revert 本 PR。
-
**先看**:`packages/services/service-analytics/src/dataset-next-step.ts`(`readTerm`
的 `groupingOnly` 与 `candidates_only`
分支);`packages/services/service-analytics/src/dataset-tools.ts`(说明文字);`packages/mcp/src/mcp-server-runtime.ts`(`DATASET_SELECTION_RULE`)。
- **两分钟验证**:`pnpm --filter @objectstack/service-analytics exec vitest
run src/__tests__/dataset-tools.test.ts`,预期 79 个测试全过,其中 `[#35005]` 一组 7
个覆盖「按行业+销售额 不追问」与「单独 销售 仍追问」。
- **需要你做的**:无,席位落地;ADR-0149 D3 修订注与 `skills/objectstack-ask` 的对应句子由单独的
`domain:skills` 卡改(治理面,不在本 PR)。
## What changes
- `dataset-next-step.ts`: `readTerm` keeps the candidate kind (it was
already on the member `memberOf` returns; the type dropped it) and marks
a `candidates_only` reading whose candidates are all dimensions as
`groupingOnly`. The note offers such a word as a possible grouping
(`groupingCandidateHit` + `groupingCandidateTail`, four locales) and
never emits the ask-first sentence for it, under `one_measure` (left-out
words) and under `candidates_only` (reported words). A word with a
measure among its candidates is unchanged: asked about beside a matched
measure, and `candidates_only` with compute-nothing when nothing
matched. When every reported `candidates_only` word is grouping-only (a
lone "this quarter"), the note offers the grouping and adds the existing
`groupingTail` (ask which number is meant), as for a word that equals a
dimension.
- Decision values, `terms`, `matches` and `candidates` are unchanged for
every input. The spec defines `candidates_only` as "matched no member
and has entries in `candidates`", so a lone grouping-only word stays
`candidates_only` (see Acceptance notes).
- `LIST_DATASETS_DESCRIPTION` and `DATASET_SELECTION_RULE` both now
carry the identical sentence "A word whose candidates are all dimensions
is at most a possible grouping: never ask about it, and it never stops a
matched measure.", and scope the ask-back to "a word with a measure
among its candidates".
- One `patch` changeset for `@objectstack/service-analytics` and
`@objectstack/mcp`.
## Tests
- `service-analytics` `dataset-tools.test.ts`: a new `[#35005]` describe
over a dataset with one 销售额 / Revenue measure, a Churn Rate measure, and
Industry (行业) / Quarter (季度) dimensions. Pins: 「按行业」+销售额 is
`one_measure`, no ask-first sentence, grouping offered, `candidates`
still lists `dimensions.industry` (four locales); "this
quarter"+"revenue" and 本季度+销售额 likewise; bare 销售 still `candidates_only`
with compute-nothing (four locales); revenue+churn still asks about
churn (four locales); a word near both a measure and a dimension keeps
the question; both kinds at once; a lone "this quarter" keeps
`candidates_only`, offers the grouping and asks which number. Plus a
description pin for the scoped sentence.
- `mcp` `initialize-selection-rule-34686.test.ts`: the `initialize` rule
and the real `list_datasets` description (from
`getDatasetToolDefinitions`) both contain the scoped sentence, and the
unscoped form is gone from both.
- Ablation (one-time, not kept): the kind check `const groupingOnly =
decision === 'candidates_only' && offered.every((m) => m.kind ===
'dimensions');` replaced by `const groupingOnly = false;` via
`scripts/ablation-replace.mjs` (anchor 1 to 0, blob bfd1844 to
df278719790e): 4 of the 7 new pins red (the grouping ones); the
bare-measure, churn and mixed-kind controls stayed green as they should.
Restored: blob equals HEAD, `git diff HEAD` empty. The suite imports the
executor by relative path, so no dist is involved.
## Acceptance notes
- Open sub-part, not taken: reading a lone grouping-only word as
`no_measure` instead of `candidates_only`. The spec's
`DatasetNextStepDecision` describes `no_measure` as "has no entry in
`candidates`", so that relabel would change the published meaning of a
decision value. This PR keeps the decision and scopes only the note;
whether to relabel is a question for the seat.
- The ADR-0149 D3 amendment note still says "With candidates, the AI
asks in rule 3's form and acts on none", and
`skills/objectstack-ask/SKILL.md` step 2 still asks for every word with
candidates. Both are governed surfaces left to the follow-up
`domain:skills` card named in the claim.
- No dataset eval set exists in `service-analytics`. The scenario cards
(`docs/qa/scenarios/*.json`) belong to the eval seat and are not touched
here.
## Verification
<details><summary>Local runs at 9c885eb</summary>
- `pnpm --filter '@objectstack/mcp^...' build`: VERDICT command-exit 0.
- `pnpm --filter @objectstack/service-analytics test`: Test Files 218
passed (218), Tests 5592 passed, 335 skipped.
- `pnpm --filter @objectstack/mcp test`: Test Files 71 passed (71),
Tests 1267 passed (1267).
- `pnpm --filter @objectstack/service-analytics typecheck` and `pnpm
--filter @objectstack/mcp typecheck` (which includes
`check:test-typecheck`): exit 0. Both edited test files are in their
package's tsc program (`--listFiles`).
- `dispatch-gates --commands` derived 70 families; all 70 run, `--ran`
reconciliation: 69 exit 0, 1 NOT MEASURED (`check:dual-build-cjs-loads`,
PREREQUISITE NOT MET: it reads every package's dist and only the mcp
closure was built). CI runs it.
- `overlap-check --branch=HEAD`: VERDICT clean exit 0 (origin/main and
#35103 merge cleanly).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbWDsbbJizuYnDwBxT8)_
<!-- signed: repo:objectstack#1 · os-warren ·
session_01JQwxbWDsbbJizuYnDwBxT8 -->
Co-authored-by: Claude <noreply@anthropic.com>
fix(analytics): a grouping or time word with only a near dimension no longer stops a matched measure with a question
7
+
8
+
Clause-②: no
9
+
Metadata-protocol: none
10
+
11
+
A question like 「按行业看销售额」 or "revenue this quarter" sends `list_datasets` a measure word with an exact match (销售额, revenue) and a grouping or time word that matches nothing exactly but is near a dimension (「按行业」 contains 行业, "this quarter" contains `quarter`). The `nextStep` note used to tell the model to ask the user about that word before using it, so an ordinary question got a clarifying question back. Now a word whose candidates are all dimensions is offered as a possible grouping: the note says not to ask about it and that it does not stop the matched measure, which is computed. A word with a measure among its candidates still asks, as before: a bare near-miss measure word (销售 near 销售额) is still `candidates_only` and computes nothing until the user answers, and beside a matched measure it is still asked about.
12
+
13
+
What changes is the note only. `decision`, `terms`, `matches` and `candidates` are the same as before for every input: a word with only dimension candidates is still `candidates_only` when it is the reported case, and its candidates are still listed. When such a word is the only word sent, the note offers the grouping and asks which number is meant, as it does for a word that equals a dimension.
14
+
15
+
The `list_datasets` tool description and the MCP `initialize` selection rule now state the scoped rule in the same words: "A word whose candidates are all dimensions is at most a possible grouping: never ask about it, and it never stops a matched measure."
0 commit comments