Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/35158-ask-back-measure-scope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@objectstack/skills': patch
'@objectstack/mcp': patch
'@objectstack/spec': patch
---

docs(skills): the `objectstack-ask` skill and the `list_datasets` output schema ask back only about a word with a measure among its `candidates`

Clause-②: no
Metadata-protocol: none

The `list_datasets` tool description and the MCP `initialize` selection rule already scope the ask-back: "A word whose candidates are all dimensions is at most a possible grouping: never ask about it, and it never stops a matched measure." Two texts a connected client also reads still said to ask about every word with candidates. The skill now carries the same sentence, and the schema description states the same scope in its own words.

- The `objectstack-ask` skill, and the page at `GET /mcp/skill` that is generated from it. Step 2's `candidates` row is now two rows. A word with a measure among its `candidates` is asked about the same way as a word that matches several measures; with one candidate, the client asks whether it is the one meant. A word whose `candidates` are all dimensions is at most a possible grouping: the client never asks about it, and it never stops a matched measure. So 「按行业看销售额」, where 销售额 matches a measure and 「按行业」 is only near a 行业 dimension, is computed and grouped with no question back.
- `@objectstack/spec`: the description of `ListDatasetsOutputSchema.candidates`, which `list_datasets` serves in its `outputSchema`. It said every candidate is offered for a clarifying question. It now says the clarifying question is for a term with a measure among its candidates, and that a term whose candidates are all dimensions is offered them as a possible grouping, not for a question, and does not stop a matched measure. It states what the candidates are offered for and does not carry the sentence above: the instruction stays in the tool description and the skill. The doc comment of `DatasetTermCandidateSchema` says the same. No shape changes: `candidates` holds the same entries in the same order.

The new skill row is paid for inside the same file, by removing text that restated another line of it: the `candidates` row's own listing instruction and "Do not pick one." (the row above states both, and the row now says "Ask the same way"), "A word matches nothing, and" in its left cell (step 1 says a word that matched nothing may have `candidates`), and "on the answer" in that step 1 bullet. `packages/mcp/src/ask-skill.generated.ts` is regenerated from the skill and `content/docs/references/ai/dataset-tools.mdx` from the spec; no code path changes.
2 changes: 1 addition & 1 deletion content/docs/references/ai/dataset-tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const result = DatasetNextStepSchema.parse(data);
| **datasets** | `{ name: string; label: string; description?: string; object: string; … }[]` | ✅ | The datasets this caller may query. A dataset the caller may not query is absent, the same answer as one that does not exist |
| **partial** | `true` | optional | Present, and `true`, when the dataset read was degraded and `datasets` may be incomplete; `warning` says why. Absent on a complete answer |
| **warning** | `string` | optional | Why the answer is partial; present exactly when `partial` is |
| **candidates** | `{ term: string; dataset: string; member: string }[]` | optional | Members offered as possible readings of a term that matched no member of any listed dataset, for a clarifying question. A candidate is not a match: its term has no entry in any dataset's `matches`. The platform selects none: the list carries no score, and its order is the listing order stated here, not a ranking. Every candidate is a member this caller may read, listed in `datasets`. Terms in the order sent; for one term, datasets in the order listed, and each dataset's measures before its dimensions, as its entry lists them; at most 5 per term, the first in that order. Present only when `terms` were sent and a term that matched nothing has a candidate; absent otherwise, never an empty list. A term with a match has no candidate |
| **candidates** | `{ term: string; dataset: string; member: string }[]` | optional | Members offered as possible readings of a term that matched no member of any listed dataset: for a clarifying question when a measure is among the term's candidates. A term whose candidates are all dimensions is offered them as a possible grouping, not for a question, and does not stop a matched measure. A candidate is not a match: its term has no entry in any dataset's `matches`. The platform selects none: the list carries no score, and its order is the listing order stated here, not a ranking. Every candidate is a member this caller may read, listed in `datasets`. Terms in the order sent; for one term, datasets in the order listed, and each dataset's measures before its dimensions, as its entry lists them; at most 5 per term, the first in that order. Present only when `terms` were sent and a term that matched nothing has a candidate; absent otherwise, never an empty list. A term with a match has no candidate |
| **nextStep** | `{ decision: Enum<'one_measure' \| 'several_measures' \| 'candidates_only' \| 'no_measure'>; terms: string[]; note: string }` | optional | Which case of the ADR-0149 D3 selection rule the caller's `terms` are in, as the platform computed it from this answer's own `matches` and `candidates`: the case, the terms it is about and the case in words. It adds no match and no candidate and lists no member: the members it rests on are read from `matches` and `candidates` under its `terms`. Present only when `terms` were sent |

### Nested Shape: `ListDatasetsOutput.datasets[number]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Both `DatasetMeasureSchema` and `DatasetDimensionSchema` gain two optional keys.

The rule is stated once here and carried in three places: the tool descriptions (for MCP clients), cloud's planner (the product's enforcement), and the D5 evaluation (the measurement).

1. **Normalize** the question's candidate terms and every match target the same way: NFKC, case-fold, trim, collapse whitespace, fold `_` and `-` to a space. Match targets are a member's `name`, its `label` in every locale, and each `synonym`. Equality after normalization is a **hit**; a substring, a stem or an embedding neighbour is **not** a hit (it may be offered in rule 3's question, never acted on).
1. **Normalize** the question's candidate terms and every match target the same way: NFKC, case-fold, trim, collapse whitespace, fold `_` and `-` to a space. Match targets are a member's `name`, its `label` in every locale, and each `synonym`. Equality after normalization is a **hit**; a substring, a stem or an embedding neighbour is **not** a hit (it may be offered in rule 3's question, never acted on; scoped by the amendment note of 2026-11-19 after rule 5: a word whose candidates are all dimensions is at most a possible grouping, never asked about).

> **Amendment note (2026-11-17, [#34870](https://github.com/objectstack-ai/objectstack/issues/34870) — PR #34928): "its `label` in every locale" means every locale of an inline label map, plus the one translation-bundle label resolved for the caller's locale; a word in another language hits only as an authored `synonym`.**
> Ruled by the maintainer on [#34720](https://github.com/objectstack-ai/objectstack/issues/34720), option text verbatim 「A+C 本语言标签+同义词」 (ruling record [`6946563869`](https://github.com/objectstack-ai/objectstack/issues/34720#issuecomment-6946563869)). This note qualifies the label target and changes no other word of rule 1: the normalization, equality as the only hit, and the `name` and `synonym` targets stand as written.
Expand All @@ -171,12 +171,23 @@ Why the platform computes `matches` instead of leaving the whole rule to the mod
>
> - **What counts as a hit does not change.** This note changes no word of rule 1: equality after normalization is a hit, and a substring, a stem or an embedding neighbour is not. `matches` is computed as before, and rules 2, 3 and 5 read it as before.
> - **A term with no hit in any listed dataset gets `candidates`.** The `list_datasets` output of [D2](#d2--two-tools-one-definition-one-executor-two-transports) gains one optional member beside the ones D2 lists, which stand as written. For such a term it names the members the platform offers as possible readings, each a pointer `{ term, dataset, member }` to a member listed in the same answer, so only a member this caller may read is ever offered. This is rule 1's parenthesis as a platform answer: a non-hit "may be offered in rule 3's question, never acted on". The list carries no score. Its order is the listing order: terms as sent, datasets as listed, a dataset's measures before its dimensions (rule 5: a dimension alone is not an answer), held to `LIST_DATASETS_MAX_CANDIDATES_PER_TERM` per term. A term with a hit has no candidates and an answer with none to offer carries no `candidates` key, so an answer in which every term sent has a hit, like an answer to a call that sent no `terms`, is what it was. Which members are near enough to offer is the executor's rule; this record and the spec say what a candidate is, not how it is found.
> - **With candidates, the AI asks in rule 3's form and acts on none.** The question lists each candidate's label, dataset label and description, as rule 3 lists several hits. The AI does not pick one, does not prefer the first, and does not treat a candidate as a hit under rule 2: the choice is the person's.
> - **With a measure among a term's candidates, the AI asks in rule 3's form and acts on none.** The question lists each candidate's label, dataset label and description, as rule 3 lists several hits. The AI does not pick one, does not prefer the first, and does not treat a candidate as a hit under rule 2: the choice is the person's. A term whose candidates are all dimensions gets no question: it is at most a possible grouping, under the amendment note of 2026-11-19 below, which scoped this point.
> - **With no candidate, rule 4 is unchanged.** No hit and nothing offered is the labelled fallback to the object query, as written; [M2](#m2--what-the-ai-does-when-no-dataset-covers-the-question) stays ruled A.
> - **Rule 4 is named here because its path changes and its matching does not.** A term with no hit used to go straight to the fallback; a clarifying question may now come first. The term still has no hit, so rule 4 still governs it when the question settles nothing.
> - **Why the platform offers them, and not only the client's wording.** A tool result is read by every client that made the call; a tool description is read only after the client chose the tool, and a skill only when it is installed and triggered (the grounds of fork F1 on #34691). It is the reason given above for `matches`: every consumer gets the same answer.
> - **State on `main`.** This PR declares the shape and changes no executor. The executor that fills `candidates`, and the tool descriptions that carry this branch to the model, land with [#34763](https://github.com/objectstack-ai/objectstack/issues/34763); until then no answer carries the key. In [D6](#d6--enforce-or-remove-every-key-names-its-reader-in-its-first-implementation-card)'s terms the pending half is named here, by card, and not hidden.

> **Amendment note (2026-11-19, [#35158](https://github.com/objectstack-ai/objectstack/issues/35158) — this PR): the question of the note above is owed only for a term with a measure among its candidates; a term whose candidates are all dimensions is at most a possible grouping.**
> Approved by the maintainer on PR #35662, verbatim 「不再反问」 (ruling record 7024577075): a term whose candidates are all dimensions is not asked about and may be used as the grouping the question asks for, which narrows #34691 F1 = B for dimension candidates only; a measure candidate is still asked about and never selected. Scoped on [#35005](https://github.com/objectstack-ai/objectstack/issues/35005), a card filed on the maintainer's word, verbatim 「立卡」; the card's scope reads "a candidate on a dimension or time word never blocks a matched measure, and is at most offered as a grouping". The executor and the two texts that carry the rule to a model apply it on `main` since PR #35156 (commit `7ed18b50e1`, contract review record [`6973927307`](https://github.com/objectstack-ai/objectstack/pull/35156#issuecomment-6973927307)). This note brings the record to the sentence those texts share and decides nothing they do not already say.
>
> - **The sentence.** `list_datasets`' description (`packages/services/service-analytics/src/dataset-tools.ts#LIST_DATASETS_DESCRIPTION`) and the MCP `initialize` rule (`packages/mcp/src/mcp-server-runtime.ts#DATASET_SELECTION_RULE`) both read: "A word whose candidates are all dimensions is at most a possible grouping: never ask about it, and it never stops a matched measure." A test holds the two to that one sentence (`packages/mcp/src/initialize-selection-rule-34686.test.ts`).
> - **A term with a measure among its candidates keeps the note above.** The AI asks in rule 3's form, lists that term's candidates and acts on none of them. A measure hit on another term is still answered under rule 2, beside the question; with no measure hit, nothing is computed until the person answers.
> - **A term whose candidates are all dimensions is a possible grouping, not a question.** It is the ordinary shape of a grouping or time word: 「按行业」 near a dimension labelled 行业, "this quarter" near one named `quarter`. Asked 「按行业看销售额」, a person whose measure word had its hit was still asked about the grouping word. The AI now asks nothing about such a term, answers the measure hit as rule 2 says, and groups the answer only as the question asks.
> - **Rule 5 still holds for it.** A possible grouping is not a number. Without a measure hit the AI still needs one, or asks which number is meant: a question about the missing measure, not about the term.
> - **What does not change.** What counts as a hit (rule 1), and `matches`. The `candidates` list: it names both kinds as before, a dataset's measures before its dimensions, and no candidate becomes a hit. The four `nextStep.decision` values: a term whose candidates are all dimensions is still in `candidates_only`, and only the sentence the executor writes for it differs (`packages/services/service-analytics/src/dataset-next-step.ts#composeDatasetNextStep`). Rule 4, for a term with no hit and no candidate.
> - **What this note amends, and what the amended sentences first said.** This note amends rule 1 in place, and it narrows the point ruled on #34691, fork F1, option B, which the note above records as "offered for a question and never selected". The narrowing is for a dimension offered to a term whose candidates are all dimensions: it is put in no question, and it may be used as the grouping the question asked for with no choice put to the person first. Both halves of that point are narrowed for it, "never selected" included. A measure candidate, and every candidate of a term with a measure among its candidates, stays as ruled: offered for a question and never selected. Rule 1's parenthesis read "(it may be offered in rule 3's question, never acted on)": neither half holds for such a dimension. The third point of the note above opened "With candidates, the AI asks in rule 3's form and acts on none." and ended at "the choice is the person's." Two sentences stand as written and are read with this scope: the headline of the note above ("offered for a question and never selected") and the option C point of the note under rule 1 ("offer such a word for a question").
> - **State on `main`.** The executor and both texts landed with PR #35156. This PR changes no executor and no shape. It brings one more text to the same sentence: step 2 of the published ask skill (`skills/objectstack-ask/SKILL.md`), which `GET /mcp/skill` serves. The spec carries the scope and not the sentence: the `candidates` description of `packages/spec/src/ai/dataset-tools.zod.ts#ListDatasetsOutputSchema` and the doc comment of `packages/spec/src/ai/dataset-tools.zod.ts#DatasetTermCandidateSchema` say what such a term's candidates are offered for, a possible grouping and not a question, and give the reader no instruction, because AI guidance text does not enter the spec ([M1](#m1--where-the-ai-facing-text-of-a-measure-or-dimension-lives), ruled A).

### D4 — Permissions: the tools add no gate and bypass none

Measured in [Context](#the-executor-and-its-gate-chain-measured-on-originmain). The binding statements:
Expand Down
5 changes: 3 additions & 2 deletions packages/mcp/src/ask-skill.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const ASK_SKILL_DATA_LOOP: string = [
' `term`, the `member` it names (`measures.<name>` or `dimensions.<name>`) and',
' `matchedOn`. A word matches only when it equals a member\'s name, label or',
' synonym (case, spacing, `_` and `-` aside), never by similarity.',
'- A word that matched nothing may have `candidates` on the answer: members',
'- A word that matched nothing may have `candidates`: members',
' offered as possible readings, each a `{ term, dataset, member }` pointer to a',
' member the same answer lists. A candidate is not a match.',
'- No `list_datasets` among your tools: this environment serves you no governed',
Expand All @@ -41,8 +41,9 @@ export const ASK_SKILL_DATA_LOOP: string = [
'|:--|:--|',
'| Each word for a thing measured matches exactly one measure | Compute: step 3. Two words with one measure each ("营收和赢单率") are two metrics, not a choice: compute both, with one `query_dataset` per dataset. |',
'| One word matches several measures, in one dataset or in two | Ask the user which one they mean. List each candidate\'s label, its dataset\'s label and its description. Do not pick one. |',
'| A word with a measure among its `candidates` | Ask the same way; with one candidate, ask whether it is the one meant. |',
'| A word whose `candidates` are all dimensions | At most a possible grouping: never ask about it, and it never stops a matched measure. |',
'| Only a dimension matches | That is a grouping ("by stage"), not a number. You still need a measure match; without one, ask which number is meant. |',
'| A word matches nothing, and `candidates` lists members for it | Ask the user which one they mean, listing each candidate\'s label, its dataset\'s label and its description; with one candidate, ask whether it is the one meant. Do not pick one. |',
'| No match and no candidates for the word for a thing measured | Step 4. |',
'| `membersWithheld: true` on a dataset | Say that it has members (measures or groupings) you may not read; the metric asked for may be among them. Do not say the metric does not exist. |',
'',
Expand Down
Loading
Loading