From c08785a29d41611d0f4561e3dbc3e2ef32ebe845 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 21:05:22 +0000 Subject: [PATCH 01/11] docs(skills): the ask skill asks back only about a word with a measure candidate Step 2 of the ask skill splits its candidates row in the words the list_datasets description and the MCP initialize rule already carry: a word with a measure among its candidates is asked about, and a word whose candidates are all dimensions is at most a possible grouping, never asked about and never a stop for a matched measure. The row pays for itself in the same file: the restated listing and "Do not pick one." (the row above, which "the same way" points at), "A word matches nothing, and" (step 1's candidates bullet) and "on the answer" (the same bullet) are cut. 7507 -> 7508 priced bytes, 1877 tokens against a ceiling of 1877. packages/mcp/src/ask-skill.generated.ts is regenerated from the skill. Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- packages/mcp/src/ask-skill.generated.ts | 5 +++-- skills/objectstack-ask/SKILL.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/mcp/src/ask-skill.generated.ts b/packages/mcp/src/ask-skill.generated.ts index ccd13bcf6b9..8dddd48a2b0 100644 --- a/packages/mcp/src/ask-skill.generated.ts +++ b/packages/mcp/src/ask-skill.generated.ts @@ -29,7 +29,7 @@ export const ASK_SKILL_DATA_LOOP: string = [ ' `term`, the `member` it names (`measures.` or `dimensions.`) 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', @@ -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. |', '', diff --git a/skills/objectstack-ask/SKILL.md b/skills/objectstack-ask/SKILL.md index df335eb27f9..971c735348d 100644 --- a/skills/objectstack-ask/SKILL.md +++ b/skills/objectstack-ask/SKILL.md @@ -44,7 +44,7 @@ wrote its business definition) outranks a number you work out yourself. `term`, the `member` it names (`measures.` or `dimensions.`) 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 @@ -56,8 +56,9 @@ wrote its business definition) outranks a number you work out yourself. |:--|:--| | 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. | From 49ffbcaef07455a2bf9c5533f12da5a9e8df0f7a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 21:07:17 +0000 Subject: [PATCH 02/11] docs(spec): the candidates description scopes the clarifying question, and two ask eval cases ListDatasetsOutputSchema.candidates and the DatasetTermCandidateSchema docblock said every candidate is offered for a clarifying question. Both now say what the list_datasets description says: a term with a measure among its candidates is asked about, and a word whose candidates are all dimensions is at most a possible grouping. No shape changes. skills/objectstack-ask/evals gains two cases: a matched measure beside a word whose candidates are all dimensions (computed, grouped, no question back), and a bare near word with a measure candidate (still asked about). Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- packages/spec/src/ai/dataset-tools.zod.ts | 18 +++++++++++++---- .../evals/metric-selection-fallback.json | 20 +++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/packages/spec/src/ai/dataset-tools.zod.ts b/packages/spec/src/ai/dataset-tools.zod.ts index 01106cca63b..55e38e003fb 100644 --- a/packages/spec/src/ai/dataset-tools.zod.ts +++ b/packages/spec/src/ai/dataset-tools.zod.ts @@ -117,8 +117,16 @@ export const LIST_DATASETS_MAX_CANDIDATES_PER_TERM = 5; * A candidate is NOT a match. A match ({@link DatasetTermMatchSchema}) says * the term equals one of the member's words after normalization, and D3 rule * 2 lets one match win. A candidate says only that the platform offers the - * member for a clarifying question; what counts as a match is unchanged, and - * a term has candidates only when it has no match anywhere in the answer. + * member as a possible reading; what counts as a match is unchanged, and a + * term has candidates only when it has no match anywhere in the answer. + * + * What a term's candidates are offered for is read from all of them together + * (ADR-0149 D3, the second amendment note under its rules). A term with a + * measure among its candidates is offered them for a clarifying question. A + * word whose candidates are all dimensions is at most a possible grouping: + * never ask about it, and it never stops a matched measure. Both are the + * same shape: the kind is the `measures.` or `dimensions.` prefix of + * `member`. * * The entry is a pointer, `{ term, dataset, member }`, and carries no * `matchedOn`: that key states an equality a candidate does not have. It @@ -307,8 +315,10 @@ export const ListDatasetsOutputSchema = lazySchema(() => z.object({ ), warning: z.string().optional().describe('Why the answer is partial; present exactly when `partial` is'), candidates: z.array(DatasetTermCandidateSchema).min(1).optional().describe( - '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 ' + '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 word whose candidates are all ' + + 'dimensions is at most a possible grouping: never ask about it, and it never stops 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 ' diff --git a/skills/objectstack-ask/evals/metric-selection-fallback.json b/skills/objectstack-ask/evals/metric-selection-fallback.json index 6ea85a06672..3b877474f6a 100644 --- a/skills/objectstack-ask/evals/metric-selection-fallback.json +++ b/skills/objectstack-ask/evals/metric-selection-fallback.json @@ -150,6 +150,26 @@ "must_contain": ["240", "partial"], "must_not_contain": ["unknown"] } + }, + { + "id": 16, + "prompt": "用户说:「按行业看销售额」 You called `list_datasets({ terms: ['销售额', '按行业'] })`. The answer lists one dataset, `sales_analysis` (label 销售分析), with `matches: [{ term: '销售额', member: 'measures.sales_amount', matchedOn: 'label' }]`; its dimensions include `industry`, labelled 行业. 「按行业」 matched nothing, and the answer carries `candidates: [{ term: '按行业', dataset: 'sales_analysis', member: 'dimensions.industry' }]`. What do you do next, and how do you write the answer?", + "expected_output": "销售额 matches exactly one measure, so the governed metric answers. 「按行业」 matched nothing and its one candidate is a dimension, so its candidates are all dimensions: it is at most a possible grouping. The user is not asked about it, and it does not stop the matched measure. The question asks for the figure by industry, so the next step is one `query_dataset` call with `datasetName: 'sales_analysis'` and a `selection` whose `measures` is `['sales_amount']` and whose `dimensions` is `['industry']`. The reply carries no question back: it is the answer, written in Chinese, with the figures shown by 行业 label and the source cited from the tool's answer (as in 「指标:销售额(数据集:销售分析)」). The candidate is not treated as a match for any measure, and nothing is computed from the object tools.", + "files": [], + "assertions": { + "must_contain": ["query_dataset", "销售额", "行业"], + "must_not_contain": ["aggregate_records", "非指标口径", "?", "?"] + } + }, + { + "id": 17, + "prompt": "The user asks: \"What are our sales?\" `list_datasets({ terms: ['sales'] })` answers one dataset, `sales_analysis` (label Sales Analysis), with `matches: []`. Its one measure is `sales_amount`, labelled Sales Amount and described as \"Amount of opportunities closed as won\"; its dimensions are `industry`, labelled Industry, and `close_quarter`, labelled Close Quarter. The answer also carries `candidates: [{ term: 'sales', dataset: 'sales_analysis', member: 'measures.sales_amount' }]`. What is your reply?", + "expected_output": "The word matches nothing and a measure is among its candidates, so it is asked about: a near word is still not a match, and only a word whose candidates are all dimensions is spared the question. The reply is a question and nothing else, asking whether that candidate is the one meant, such as \"Do you mean Sales Amount (in Sales Analysis: amount of opportunities closed as won)?\", naming the candidate's label, its dataset's label and its description, not its machine name. It does not pick the candidate, gives no figure, makes no tool call until the user answers, and does not fall back to the object tools either: the fallback is for a word with no candidates.", + "files": [], + "assertions": { + "must_contain": ["Sales Amount", "Sales Analysis", "?"], + "must_not_contain": ["query_dataset", "aggregate_records", "sales_amount"] + } } ] } From ffac85a4dbb36b42d00568bd07f2ddd3dcc4c484 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 21:10:36 +0000 Subject: [PATCH 03/11] docs(references): regenerate the dataset-tools reference page `pnpm --filter @objectstack/spec gen:docs`, after the candidates description changed. One row moves. Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- content/docs/references/ai/dataset-tools.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/references/ai/dataset-tools.mdx b/content/docs/references/ai/dataset-tools.mdx index c4e777c3a6d..10af5363a89 100644 --- a/content/docs/references/ai/dataset-tools.mdx +++ b/content/docs/references/ai/dataset-tools.mdx @@ -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 word whose candidates are all dimensions is at most a possible grouping: never ask about it, and it never stops 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]` From f76de5a821975a67b516e21ca9e9dcecd63f7197 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 21:13:19 +0000 Subject: [PATCH 04/11] docs(adr): ADR-0149 D3 scopes the ask-back to a term with a measure candidate An amendment note after rule 5 records the sentence the list_datasets description and the MCP initialize rule already carry: a word whose candidates are all dimensions is at most a possible grouping, never asked about and never a stop for a matched measure. Two sentences that stated the question for every candidate are amended in place (rule 1's parenthesis, and the third point of the candidates note), and the new note quotes what they first said. No decision beyond the shipped texts. Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- ...uestions-through-the-dataset-semantic-layer.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md b/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md index 9cd17d9add0..de0feec87e7 100644 --- a/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md +++ b/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md @@ -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. @@ -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.** +> 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. +> - **Sentences amended in place, and what they first said.** Rule 1's parenthesis read "(it may be offered in rule 3's question, never acted on)": neither half holds for a dimension offered to such a term, which is put in no question and may be the grouping the question asked for. 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 that name the question in passing stand as written and are read with this scope: the headline of the note above ("offered for a question") 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 three copies to the same sentence: the `candidates` description of `packages/spec/src/ai/dataset-tools.zod.ts#ListDatasetsOutputSchema`, the doc comment of `packages/spec/src/ai/dataset-tools.zod.ts#DatasetTermCandidateSchema`, and step 2 of the published ask skill (`skills/objectstack-ask/SKILL.md`), which `GET /mcp/skill` serves. + ### 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: From ce88a4ea69c8f4cf7885375594c6e7a21f5fe5de Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 21:13:46 +0000 Subject: [PATCH 05/11] chore(changeset): patch for the scoped ask-back in the ask skill, its served page and the spec description Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- .changeset/35158-ask-back-measure-scope.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .changeset/35158-ask-back-measure-scope.md diff --git a/.changeset/35158-ask-back-measure-scope.md b/.changeset/35158-ask-back-measure-scope.md new file mode 100644 index 00000000000..7a29646da64 --- /dev/null +++ b/.changeset/35158-ask-back-measure-scope.md @@ -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. They now carry the same sentence. + +- 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 carries the sentence above for a term whose candidates are all dimensions. 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. From 652c07879188be79a0842abb36311a14cf2c66b3 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 22:56:20 +0000 Subject: [PATCH 06/11] docs(spec): the candidates description states the dimension-only scope declaratively The `candidates` description of ListDatasetsOutputSchema and the doc comment of DatasetTermCandidateSchema carried the executor's instruction sentence whole. AI guidance text does not enter the spec (ADR-0149 M1, ruled A), and the file's header says so. Both now say what a term whose candidates are all dimensions is offered them for, a possible grouping and not a question, in the file's own vocabulary ("term"), and instruct no reader. The doc comment cites the ADR note by its date. No shape changes. Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- packages/spec/src/ai/dataset-tools.zod.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/spec/src/ai/dataset-tools.zod.ts b/packages/spec/src/ai/dataset-tools.zod.ts index 55e38e003fb..a259c2dae37 100644 --- a/packages/spec/src/ai/dataset-tools.zod.ts +++ b/packages/spec/src/ai/dataset-tools.zod.ts @@ -121,12 +121,11 @@ export const LIST_DATASETS_MAX_CANDIDATES_PER_TERM = 5; * term has candidates only when it has no match anywhere in the answer. * * What a term's candidates are offered for is read from all of them together - * (ADR-0149 D3, the second amendment note under its rules). A term with a - * measure among its candidates is offered them for a clarifying question. A - * word whose candidates are all dimensions is at most a possible grouping: - * never ask about it, and it never stops a matched measure. Both are the - * same shape: the kind is the `measures.` or `dimensions.` prefix of - * `member`. + * (ADR-0149 D3, the amendment note of 2026-11-19). A term with a measure + * among its candidates is offered them for a clarifying question. 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. Both are the same + * shape: the kind is the `measures.` or `dimensions.` prefix of `member`. * * The entry is a pointer, `{ term, dataset, member }`, and carries no * `matchedOn`: that key states an equality a candidate does not have. It @@ -316,9 +315,9 @@ export const ListDatasetsOutputSchema = lazySchema(() => z.object({ warning: z.string().optional().describe('Why the answer is partial; present exactly when `partial` is'), candidates: z.array(DatasetTermCandidateSchema).min(1).optional().describe( '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 word whose candidates are all ' - + 'dimensions is at most a possible grouping: never ask about it, and it never stops a matched measure. ' - + 'A candidate is not a match: its term has no entry in any dataset\'s `matches`. The ' + + '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 ' From d93f1cd3eeb3404a90d7b0fb7526247ecb7fa021 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 22:56:21 +0000 Subject: [PATCH 07/11] docs(adr): the ADR-0149 note of 2026-11-19 says what it amends and narrows The note now states plainly that it amends rule 1 in place and narrows the point ruled on fork F1, option B ("offered for a question and never selected") for a dimension offered to a term whose candidates are all dimensions, "never selected" included; every other candidate stays as ruled. Its state line no longer counts the spec among the copies of the door sentence: the spec carries the scope and not the sentence (M1). The authority line is unchanged. Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- ...s-business-questions-through-the-dataset-semantic-layer.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md b/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md index de0feec87e7..d5b092a6ddc 100644 --- a/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md +++ b/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md @@ -185,8 +185,8 @@ Why the platform computes `matches` instead of leaving the whole rule to the mod > - **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. -> - **Sentences amended in place, and what they first said.** Rule 1's parenthesis read "(it may be offered in rule 3's question, never acted on)": neither half holds for a dimension offered to such a term, which is put in no question and may be the grouping the question asked for. 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 that name the question in passing stand as written and are read with this scope: the headline of the note above ("offered for a question") 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 three copies to the same sentence: the `candidates` description of `packages/spec/src/ai/dataset-tools.zod.ts#ListDatasetsOutputSchema`, the doc comment of `packages/spec/src/ai/dataset-tools.zod.ts#DatasetTermCandidateSchema`, and step 2 of the published ask skill (`skills/objectstack-ask/SKILL.md`), which `GET /mcp/skill` serves. +> - **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 From db00b853452981d24c19e5bbf3aad1267634e1a9 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 22:56:21 +0000 Subject: [PATCH 08/11] chore(changeset): the spec description states the scope, not the door sentence Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- .changeset/35158-ask-back-measure-scope.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/35158-ask-back-measure-scope.md b/.changeset/35158-ask-back-measure-scope.md index 7a29646da64..2bdde26689c 100644 --- a/.changeset/35158-ask-back-measure-scope.md +++ b/.changeset/35158-ask-back-measure-scope.md @@ -9,9 +9,9 @@ docs(skills): the `objectstack-ask` skill and the `list_datasets` output schema 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. They now carry the same sentence. +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 carries the sentence above for a term whose candidates are all dimensions. The doc comment of `DatasetTermCandidateSchema` says the same. No shape changes: `candidates` holds the same entries in the same order. +- `@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. From 9f99c3ff2116c2981e716f427711535b48d092ec Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 22:56:21 +0000 Subject: [PATCH 09/11] test(skills): ask eval 16 forbids a question about the term, not any question mark A bare question mark in must_not_contain failed a correct answer that closes with an offer. The case now forbids the ask-back phrasings themselves, in both languages the answer may be written in. Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- skills/objectstack-ask/evals/metric-selection-fallback.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skills/objectstack-ask/evals/metric-selection-fallback.json b/skills/objectstack-ask/evals/metric-selection-fallback.json index 3b877474f6a..d559b258690 100644 --- a/skills/objectstack-ask/evals/metric-selection-fallback.json +++ b/skills/objectstack-ask/evals/metric-selection-fallback.json @@ -158,7 +158,7 @@ "files": [], "assertions": { "must_contain": ["query_dataset", "销售额", "行业"], - "must_not_contain": ["aggregate_records", "非指标口径", "?", "?"] + "must_not_contain": ["aggregate_records", "非指标口径", "您是指", "你是指", "您指的是", "你指的是", "do you mean", "Do you mean"] } }, { From 3f92b1874454ca5b12310755b9cb9d1143e88cd7 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 23:00:29 +0000 Subject: [PATCH 10/11] docs(references): regenerate the dataset-tools reference page `pnpm --filter @objectstack/spec gen:docs`, after the candidates description was respelled. One row moves. Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- content/docs/references/ai/dataset-tools.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/references/ai/dataset-tools.mdx b/content/docs/references/ai/dataset-tools.mdx index 10af5363a89..ed3d7eab128 100644 --- a/content/docs/references/ai/dataset-tools.mdx +++ b/content/docs/references/ai/dataset-tools.mdx @@ -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 when a measure is among the term's candidates. 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 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]` From df2fcffbf383ad9ca0e98def44e652cbdd9dd177 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 23:00:29 +0000 Subject: [PATCH 11/11] docs(adr): the ADR-0149 note of 2026-11-19 cites the maintainer's ruling as its authority The note's authority line now opens with the ruling record for the narrowing: a term whose candidates are all dimensions is not asked about and may be used as the grouping the question asks for; a measure candidate is still asked about and never selected. The card it was first scoped on stays named after it. Claude-Session: https://claude.ai/code/session_016WV4d1Dv2AVwokgRqfdKp2 Co-authored-by: Claude --- ...ers-business-questions-through-the-dataset-semantic-layer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md b/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md index d5b092a6ddc..81044b0ff31 100644 --- a/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md +++ b/docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md @@ -178,7 +178,7 @@ Why the platform computes `matches` instead of leaving the whole rule to the mod > - **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.** -> 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. +> 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.