Skip to content

Commit b633afe

Browse files
feat(spec): the list_datasets output declares candidates for a term that matched nothing (ADR-0149 D3) (#34828)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ repo:objectstack#3 · os-support-ai · session_01WGufzfR33NbV51QQU6R6bm Fixes #34761 Clause-②: yes (widening — an optional output field on a published schema) Metadata-protocol: added Skills-docs: follow-up owed — skills/objectstack-ask/SKILL.md (zero-match row reads candidates once #34763 lands) Served-tier: CONTRACT_REVIEW_TIER ## 维护者速读 - 改了什么:`list_datasets` 的返回结构新增可选成员 `candidates`。用户的词在所有列出的数据集里一个成员都没精确命中时,平台列出可供反问的候选成员,每项指向同一份返回里的「数据集 + 成员」,每个词最多 5 个。ADR-0149 D3 末尾加一段只增不改的修订说明。本 PR 只声明形状,不改执行器。 - 为什么改:#34691 F1 的裁决(选 B,记录 6943126855):零命中时由服务器返回候选,任何客户端都读得到,不靠技能或工具描述的措辞。「什么算命中」不变,平台永不替用户选。 - 风险与回滚:只加一个可选输出字段,不带该字段的返回解析结果与之前相同。服务器填充在 #34763,它落地前没有返回会带这个字段,但 MCP 客户端读到的 `outputSchema` 现在就多出这一项。回滚即 revert 本 PR。 - 先看:① `packages/spec/src/ai/dataset-tools.zod.ts` 里 `candidates` 的 `.describe()` 文字,它是对外契约,也是 MCP 客户端读到的说明;② `docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md` D3 末尾的修订说明,看它是否如实转述裁决;③ 同一文件里 `DatasetTermCandidateSchema` 不带 `matchedOn`,与卡片提案不同,理由在下面 Schema decisions。 - 两分钟验证:`pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/ai/dataset-tools.test.ts`,预期 `Tests 33 passed (33)`。 - 需要你做的:席位 L2 复核后,亲手合并本 PR(Tier H:`docs/adr/**` 与 `packages/spec/**`)。 ## What changes - **`packages/spec/src/ai/dataset-tools.zod.ts`** (62 lines added, 2 removed; the two removed lines are module doc block lines, rewritten to name `candidates`): - `ListDatasetsOutputSchema` gains one optional member, `candidates`: a list of `DatasetTermCandidateSchema` with at least one entry. - `DatasetTermCandidateSchema` (type `DatasetTermCandidate`): `{ term, dataset, member }`, all three required. `member` is `DatasetTermMatchSchema`'s `member` by reference, under its own description, so the member-reference format (`measures.NAME` or `dimensions.NAME`) is declared once. - `LIST_DATASETS_MAX_CANDIDATES_PER_TERM = 5`, exported. - `matches`, `DatasetTermMatchSchema`, `DatasetTermMatchedOn` and every other declaration in the file are untouched. - **`packages/spec/src/ai/dataset-tools.test.ts`**: seven new cases (33 run in the file now). Six in a new `list_datasets candidates` block, one in the JSON Schema projection block. - **`packages/spec/src/type-alias-convention.pin.test.ts`**: one pin row for the new alias and the pinned count 857 to 858. `check:spec-parsed-alias` (ADR-0122) refuses a new bare input alias with no pin. See *File surface* below. - **Generated, by the generators only**: `packages/spec/{api-surface,authorable-surface,declaration-map,export-origins,json-schema.manifest}/ai.json`, `content/docs/references/ai/dataset-tools.mdx`, `content/docs/references/index.mdx` (schema totals 1669 to 1670, AI 81 to 82), `docs/audits/2026-07-unknown-key-strictness-ledger.counts/ai.md` (96 to 97 object sites). - **`docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md`**: an amendment note at the end of D3, in ADR-0011's `> **Amendment note**` form. 11 lines added, 0 removed or changed. - **`.changeset/34761-list-datasets-candidates.md`**: `@objectstack/spec` at `minor`. - Nothing under `packages/services/service-analytics/**`, `packages/mcp/**` or `skills/**`. ## Why Ruled by the maintainer on #34691, fork F1, option B, option text verbatim 「B 零命中返回候选」 — 「现在就改服务器,list_datasets 零命中时返回候选数据集。专题席的新推荐。」 (ruling record `6943126855`, relayed to #34659 as `6943149235`). It re-rules point E2 of #34659's record `6940528935` to that point's option A. With `terms`, `list_datasets` answers the whole admitted catalogue, and a term with no match gets no pointer to the near members (the card's reading of `packages/services/service-analytics/src/dataset-tools.ts`), so what to do next is left to each client. A tool result is read by every client that made the call; a tool description is read only after the client picked the tool, and a skill only when it is installed and triggered. This PR is the spec half: the shape, and the record. The executor that fills the list and the tool descriptions are #34763. ## Schema decisions The card's proposal was a starting point ("the PR settles it and says why if it differs"). One point differs. | Point | Card's proposal | Settled here | Why | |:--|:--|:--|:--| | Entry shape | `{ term, dataset, member, matchedOn }` | `{ term, dataset, member }` | **Differs.** `matchedOn` says which of the member's words the term equals after normalization. A candidate has no such equality, so the key would state something false. There is no "near which word" key either: D3 rule 1 names an embedding neighbour among the non-hits that may be offered, and an embedding neighbour is near no single word. Such a key would presume a substring or stem rule, and the rule is the executor's. | | What the question lists | not stated | read from `datasets` | D3 rule 3 lists label, dataset label and description. Each candidate points at a member listed in the same answer, so the client reads those from that `datasets` entry. The entry repeats none of them. | | Presence | only when `terms` were sent and a term matched no member of any listed dataset | as proposed, as `.min(1).optional()` | "No candidates" has one spelling, the key's absence. An empty list does not parse. An answer without the key parses to the same value as before. | | Order | terms as sent, datasets as listed, measures before dimensions, no score | as proposed | Stated in the member's description. It is a listing order and the description says it is not a ranking. A schema cannot enforce an order; holding it is the executor's (#34763). | | Cap | an exported per-term constant, proposed 5 | `LIST_DATASETS_MAX_CANDIDATES_PER_TERM = 5` | The description states the cap from the constant. The list is flat (one list for all terms), so the schema carries no per-term `maxItems`: nothing in this PR refuses a sixth entry for one term. | | Description text | not a match, for a clarifying question, never selected, only members this caller may read | as proposed, as facts | ADR-0149 M1 A keeps AI guidance out of the spec. The description says what a candidate is. How to ask stays in the tool description (#34763). | | Near-match rule | the server sibling's | not in the spec | The spec and the ADR note say what a candidate is, not how one is found. | The new type alias is a bare input alias with a pin, not an alias paired with a `Parsed` twin: the schema has no default and no transform, so input and output types are the same (ADR-0122). ## Prior rulings read The claim names four. None is crossed. - **ADR-0078, the hit labelled "Decision §8"**: the text is its section 5, "Ratchet, not retrofit", where "candidates" means audit findings. It rules nothing about a tool output. - **ADR-0110 D2**: handler-key candidates derived from an action declaration. Unrelated. - **ADR-0149 D2** (two tools, one definition, one executor, two transports): this PR adds one optional member to the one definition. No second definition, no executor and no transport changes. The output members D2 lists stand as written, and the D3 note names the added one. - **ADR-0149 D6** (every key names its reader in its first implementation card): the note's "State on `main`" bullet names #34763 as the card that fills the list and carries the branch to the model. The spec liveness ledger classifies authorable metadata keys and has no row for the dataset-tool output schemas; `check:liveness` exits 0 and asked for no row. ## Tests Readings are on head `666309be` with a clean working tree, unless a row says otherwise. | Command | Result | |:--|:--| | `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/ai/dataset-tools.test.ts src/type-alias-convention.pin.test.ts` (verify lock) | `Test Files 2 passed (2)`, `Tests 36 passed (36)`; lock line `VERDICT command-exit 0` | | `pnpm --filter @objectstack/spec typecheck` then `test` (verify lock), on `a23b07c9` | `check:test-typecheck: OK`; `Test Files 847 passed \| 1 skipped (848)`; `Tests 27175 passed \| 1 skipped \| 1 todo (27177)`; `VERDICT command-exit 0`. The one later commit, `666309be`, changes one sentence of the ADR note. | | `pnpm --filter @objectstack/service-analytics test` and `pnpm --filter @objectstack/mcp test` (verify lock) | service-analytics `Test Files 218 passed (218)`, `Tests 5548 passed \| 335 skipped (5883)`; mcp `Test Files 66 passed (66)`, `Tests 1226 passed (1226)`; `VERDICT command-exit 0` | | `pnpm exec eslint --no-inline-config` on the three changed TypeScript files | exit 0, no finding | The two downstream packages are the ones outside spec that import the dataset-tool schemas (direction: consumers of spec). They ran against a spec `dist/` that carries the new export. <details><summary>What the new cases pin</summary> - An answer with `candidates` parses, and the parsed value keeps the list. - An answer without the key parses to the same value as before. - An empty `candidates` list is refused, at path `candidates`. - An entry's keys are exactly `dataset`, `member`, `term`, each required, and there is no `matchedOn`. - `member` takes what a match's `member` takes and refuses what it refuses. - The cap constant is 5. - The projected `list_datasets` `outputSchema` has `candidates` as an array with `minItems` 1 whose items require `term`, `dataset` and `member`, and `candidates` is not in the output's `required` list. The built `dist/` answers the same: `required` is `["datasets"]`; `candidates` is `type: array`, `minItems: 1`; its items are `type: object`, `required: ["term","dataset","member"]`, `additionalProperties: false`. </details> <details><summary>Ablations (three, each restored)</summary> Each mutation went through `scripts/ablation-replace.mjs` on `dataset-tools.zod.ts`, and each restore ended with "ok restored: blob == HEAD (bbb4dce) and `git diff HEAD` is empty". The suite imports the schema by relative path from `src/`, so there is no `dist/` leg. | Mutation | Reading | |:--|:--| | `.min(1)` to `.min(0)` on `candidates` | `Tests 2 failed \| 31 passed (33)`: the empty-list case and the projection case | | the key `candidates` renamed | `Tests 3 failed \| 30 passed (33)`: the keep-the-list case, the empty-list case, the projection case | | `member` to a plain string | `Tests 1 failed \| 32 passed (33)`: the member-format case | The first attempt at the first ablation did not run. The tool refused it (the replacement text was a substring of the anchor, so the count moved 18 to 18) and restored the file. The row above is the second attempt with a narrower anchor. </details> ## Acceptance notes - **The key is declared and nothing fills it yet.** Until #34763 lands no answer carries `candidates`. The tool's `outputSchema` lists the optional member from this PR on. The ADR note says so in its last bullet. - **File surface.** Three files are beyond the list in the claim. `content/docs/references/index.mdx` and `docs/audits/2026-07-unknown-key-strictness-ledger.counts/ai.md` are generator output (`gen:docs`, `gen:strictness-ledger`). `packages/spec/src/type-alias-convention.pin.test.ts` is a hand edit that `check:spec-parsed-alias` demands for any new bare input alias. - **Overlap with open PR #34719.** `node scripts/pm/overlap-check.mjs` exits 1: both PRs move the totals in `content/docs/references/index.mdx` and the pinned count in `type-alias-convention.pin.test.ts`. `origin/main` merges cleanly. Whichever lands second merges `main`, re-runs `gen:docs` and sets the count to the sum. - **Pending: the #34720 qualifier.** As the seat relayed it to this dev, #34720 is ruled (record `6946563869`; not read here) and rule 1 of D3 will need a qualifier for it. Card #34761 does not carry that amendment (body and both comments re-read after the last commit; the card was last updated 2026-11-17T10:53:47Z), so this note does not write it. The note is one self-contained block and changes no existing D3 sentence, so a later sentence can be added to it. - **The ruling record's "note that several readings may exist".** Record `6943126855` describes candidates as "near matches, with a note that several readings may exist". This PR carries that as the member's description ("possible readings of a term ... for a clarifying question"), not as a text field in the result. A result field for it would be a second, per-answer copy of guidance text, which M1 A keeps out of the spec. Raised in the dev report as an open question. - **No second pointer under D2.** D2's "Output" sentence is unchanged (the note is add-only), and the D3 note names D2. - **The entry is a plain `z.object`.** The strictness count for `ai/` moves 96 to 97 object sites; `ai/` is an untriaged directory in that ledger. - **The skill file in the `Skills-docs:` line** arrives with PR #34792 and is not on `main` yet. - **Shallow clone.** This checkout is shallow. No claim here rests on history dates or ancestry. ## Verification - **Derived gates.** `node scripts/pm/dispatch-gates.mjs --commands` at `666309be` derives 109 commands. `--ran` answers: "109 derived famil(ies) accounted for — 109 run, 0 NOT-MEASURED", exit 0. - **First pass.** 96 exited 0. 11 exited 3 (PREREQUISITE NOT MET) and `check:generated` exited 1, all twelve for one cause: `dist/` older than the sources after the pin edit, or a package not built. `check:type-check-debt` hit my runner's 300 s cap. After `pnpm --workspace-concurrency=2 --filter '@objectstack/lint...' build`, and after `pnpm check:type-check-debt` run to its end (exit 0, "0 ledger entr(ies) re-measured"; that run does a `turbo run build` over the packages under the verify lock), all thirteen exited 0 on a re-run. - **Changeset level.** `node scripts/check-changeset-no-major.mjs --base origin/main` with a `pull_request` event carrying this title and body: exit 0, "LEVEL AXIS: this PR declares clause-② `yes (widening)` and metadata-protocol `added`, and no package whose published source ... it moves is graded `patch`". Control: the same event with `Metadata-protocol: none` exits 1, "metadata-protocol declares `none` while an authorable-surface or authorable-defaults baseline moved" (`packages/spec/authorable-surface/ai.json`). That is why the claim's provisional `none` is `added` here, with `minor`. - **Local-state gates.** `pnpm check:skill-frame-freshness` exit 0. `pnpm check:dev-prereqs` exit 1: "34 of 107 workspace packages declare an entry point under dist/ that is not on disk" in this worktree (the three it names are under `ui/`; the gates above needed none of them). That is this machine's state, not a reading of the diff. - **Not run locally, CI's.** `test:repo`, the repo-wide `pnpm lint` and the rest of the farm. No full dogfood run: the title has no `!` and the declaration has no `(narrowing)` arm. - The branch merged `origin/main` at `3bbda33b` through `scripts/pm/os-regen-merge.sh`. <details><summary>Selected verdict lines</summary> | Gate | Line | |:--|:--| | `check:generated` | "All 14 generated artifacts are up to date" | | `check:spec-parsed-alias` | "1592 bare z.input aliases, 858 pinned isomorphic, 734 paired with an XParsed. OK" | | `check:api-surface` | "public API surface + factory signatures unchanged" (against the regenerated baseline) | | `check:export-origins` | "6223 exports across 19 entry points resolve exactly as recorded" | | `check:docs` | "248 generated files in sync with packages/spec" | | `check:adr-symbol-anchors` | "3734 anchors across 158 records resolve" | | `check-adr-links` | "1150 relative link destination(s) under docs/adr/ resolve" | | `check:adr-index` | "docs/adr/README.md is current, every record parsed" | | `check-empty-changeset` | "No empty-frontmatter changeset introduced by this diff (1 declaring changeset(s) added)" | | `check:nul-bytes` | "no raw ASCII control bytes" | </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; the repo-wide `pnpm lint` is left to CI (the three changed TypeScript files lint clean). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English (the 维护者速读 block is Chinese by the dev agent's rule). - [x] The *Before Submitting* list in CONTRIBUTING.md is done, with the repo-wide runs left to CI as stated above. --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzfR33NbV51QQU6R6bm --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6320abb commit b633afe

13 files changed

Lines changed: 227 additions & 15 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/spec': minor
3+
---
4+
5+
feat(spec): the `list_datasets` output declares `candidates`, the members offered for a clarifying question when a term matched nothing (ADR-0149 D3)
6+
7+
Clause-②: yes (widening — an optional output field on a published schema)
8+
Metadata-protocol: added
9+
Skills-docs: follow-up owed — skills/objectstack-ask/SKILL.md (zero-match row reads candidates once #34763 lands)
10+
11+
`ListDatasetsOutputSchema` (`@objectstack/spec/ai`) gains one optional member, `candidates`, with its entry schema `DatasetTermCandidateSchema` (type `DatasetTermCandidate`) and the per-term cap `LIST_DATASETS_MAX_CANDIDATES_PER_TERM` (5). Nothing is removed or renamed, and an answer without the key parses as it did.
12+
13+
- **What it is.** For a term the caller sent that matched no member of any listed dataset, the members the platform offers as possible readings. Each entry is a pointer `{ term, dataset, member }` to a member listed in the same answer: `dataset` is a `datasets[].name`, `member` is `measures.<name>` or `dimensions.<name>`. Only members the caller may read are offered. The label, dataset label and description a clarifying question lists are read from that `datasets` entry.
14+
- **What it is not.** A candidate is not a match. `matches`, and what counts as a match (equality after normalization, ADR-0149 D3 rule 1), are unchanged, and an entry carries no `matchedOn`. The platform selects none of them. The list carries no score, and its order is the listing order: terms as sent, datasets as listed, a dataset's measures before its dimensions, at most five per term.
15+
- **When it is present.** Only when `terms` were sent and a term that matched nothing has a candidate. No candidates is the key's absence: an empty list does not parse. A term with a match has none.
16+
- **Who fills it.** This change declares the shape only, and the tool's `outputSchema` (`getDatasetToolJsonSchemas().list_datasets.outputSchema`) lists the member from it. Filling the list is the `list_datasets` executor's change in `@objectstack/service-analytics`, which ships under its own entry; an answer carries `candidates` only from a release that has both.
17+
18+
ADR-0149 D3 gains an add-only amendment note recording the ruling: a term with no match and with candidates is asked about in rule 3's form and none is acted on; with no candidate, rule 4's fallback is unchanged.
19+
20+
Level: `minor` for `@objectstack/spec`, the level `Metadata-protocol: added` takes. The `authorable-surface/ai.json` baseline records the new keys: `ai/ListDatasetsOutput:candidates` and the three `ai/DatasetTermCandidate` members.

‎content/docs/references/ai/dataset-tools.mdx‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Dataset AI tools — the inputs and outputs of `list_datasets` and
1212
The two tools give an AI the business semantic layer a person already reads
1313
through dashboards and reports: `list_datasets` returns the catalogue (the
1414
datasets the caller may query, their dimensions and measures, each member's
15-
business vocabulary, and which of the caller's words matched which member),
15+
business vocabulary, which of the caller's words matched which member, and,
16+
for a word that matched nothing, the members offered as `candidates`),
1617
and `query_dataset` runs a `DatasetSelection` against one saved dataset and
1718
answers rows plus a `provenance` block naming the dataset and the measures
1819
used. The shapes are declared here once and projected to the JSON Schema an
@@ -27,7 +28,8 @@ inline `dataset` and no `previewDrafts` on this tool, because an AI that could
2728
author a dataset inline could author its own 口径.
2829

2930
Only the shapes are spec. The executor, the catalogue builder with its
30-
admission and member withholding, the term matcher and the row cap
31+
admission and member withholding, the term matcher, the rule that finds a
32+
zero-match term's candidates and the row cap
3133
(`selection.limit` held to the bridge's `maxQueryLimit`) belong to
3234
`@objectstack/service-analytics` (card #31589); the MCP registration under
3335
`data:read` to `@objectstack/mcp` (card #31590). The tool descriptions, which
@@ -41,8 +43,8 @@ executor: AI guidance text does not enter the spec (ADR-0149 M1, ruled A).
4143
## TypeScript Usage
4244

4345
```typescript
44-
import { DatasetProvenanceSchema, DatasetTermMatchSchema, DatasetTermMatchedOn, DatasetToolCatalogDimensionSchema, DatasetToolCatalogEntrySchema, DatasetToolCatalogMeasureSchema, ListDatasetsInputSchema, ListDatasetsOutputSchema, QueryDatasetInputSchema, QueryDatasetOutputSchema } from '@objectstack/spec/ai';
45-
import type { DatasetProvenance, DatasetTermMatch, DatasetTermMatchedOn, DatasetToolCatalogDimension, DatasetToolCatalogEntry, DatasetToolCatalogMeasure, ListDatasetsInput, ListDatasetsOutput, QueryDatasetInput, QueryDatasetOutput } from '@objectstack/spec/ai';
46+
import { DatasetProvenanceSchema, DatasetTermCandidateSchema, DatasetTermMatchSchema, DatasetTermMatchedOn, DatasetToolCatalogDimensionSchema, DatasetToolCatalogEntrySchema, DatasetToolCatalogMeasureSchema, ListDatasetsInputSchema, ListDatasetsOutputSchema, QueryDatasetInputSchema, QueryDatasetOutputSchema } from '@objectstack/spec/ai';
47+
import type { DatasetProvenance, DatasetTermCandidate, DatasetTermMatch, DatasetTermMatchedOn, DatasetToolCatalogDimension, DatasetToolCatalogEntry, DatasetToolCatalogMeasure, ListDatasetsInput, ListDatasetsOutput, QueryDatasetInput, QueryDatasetOutput } from '@objectstack/spec/ai';
4648

4749
// Validate data
4850
const result = DatasetProvenanceSchema.parse(data);
@@ -85,6 +87,19 @@ const result = DatasetProvenanceSchema.parse(data);
8587
| **label** | `string` | ✅ | Dimension label at the caller's locale |
8688

8789

90+
---
91+
92+
## DatasetTermCandidate
93+
94+
### Properties
95+
96+
| Property | Type | Required | Description |
97+
| :--- | :--- | :--- | :--- |
98+
| **term** | `string` | ✅ | The caller's term, as sent in `terms`: one that matched no member of any listed dataset |
99+
| **dataset** | `string` | ✅ | The dataset the offered member belongs to, by name: an entry of `datasets` in the same answer, and what `query_dataset` takes as `datasetName` |
100+
| **member** | `string` | ✅ | The member offered, as `measures.<name>` or `dimensions.<name>`: a member that dataset's entry lists. The term does not equal any of its words after normalization |
101+
102+
88103
---
89104

90105
## DatasetTermMatch
@@ -211,6 +226,7 @@ const result = DatasetProvenanceSchema.parse(data);
211226
| **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 |
212227
| **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 |
213228
| **warning** | `string` | optional | Why the answer is partial; present exactly when `partial` is |
229+
| **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 |
214230

215231
### Nested Shape: `ListDatasetsOutput.datasets[number]`
216232

@@ -225,6 +241,14 @@ const result = DatasetProvenanceSchema.parse(data);
225241
| **measures** | `{ name: string; label: string; description?: string; aggregate?: Enum<'count' \| 'sum' \| 'avg' \| 'min' \| 'max' \| 'count_distinct'>; … }[]` | ✅ | The measures this caller may read |
226242
| **matches** | `{ term: string; member: string; matchedOn: Enum<'name' \| 'label' \| 'synonym'> }[]` | optional | Each of the caller's `terms` that matched a member of this dataset, computed by the platform under the same normalization the dataset's own validation uses. Absent when no `terms` were sent |
227243

244+
### Nested Shape: `ListDatasetsOutput.candidates[number]`
245+
246+
| Property | Type | Required | Description |
247+
| :--- | :--- | :--- | :--- |
248+
| **term** | `string` | ✅ | The caller's term, as sent in `terms`: one that matched no member of any listed dataset |
249+
| **dataset** | `string` | ✅ | The dataset the offered member belongs to, by name: an entry of `datasets` in the same answer, and what `query_dataset` takes as `datasetName` |
250+
| **member** | `string` | ✅ | The member offered, as `measures.<name>` or `dimensions.<name>`: a member that dataset's entry lists. The term does not equal any of its words after normalization |
251+
228252

229253
---
230254

‎content/docs/references/index.mdx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Protocol reference — every schema by module
33
navTitle: Protocol Reference
4-
description: Every schema published by @objectstack/spec — 1669 schemas across 14 protocol modules
4+
description: Every schema published by @objectstack/spec — 1670 schemas across 14 protocol modules
55
---
66

77
{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}
@@ -20,7 +20,7 @@ counts are sums of the rows they head. Regenerate with
2020

2121
| Module | Pages | Schemas | Description |
2222
| :--- | ---: | ---: | :--- |
23-
| [AI Protocol](/docs/references/ai) | 14 | 81 | Agents, tools, skills, RAG and knowledge sources, model registry, conversations. |
23+
| [AI Protocol](/docs/references/ai) | 14 | 82 | Agents, tools, skills, RAG and knowledge sources, model registry, conversations. |
2424
| [API Protocol](/docs/references/api) | 36 | 496 | REST contracts, endpoints, routing, realtime, batch, discovery. |
2525
| [Automation Protocol](/docs/references/automation) | 16 | 82 | Flows and their nodes, approvals, ETL pipelines, webhooks, state machines, execution records. |
2626
| [Data Protocol](/docs/references/data) | 35 | 188 | Objects, fields, queries, filters, datasources and drivers — the ObjectQL layer. |
@@ -34,13 +34,13 @@ counts are sums of the rows they head. Regenerate with
3434
| [Studio Protocol](/docs/references/studio) | 3 | 35 | Studio designer metadata — the authoring surfaces for the protocols above. |
3535
| [System Protocol](/docs/references/system) | 40 | 297 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. |
3636
| [UI Protocol](/docs/references/ui) | 16 | 177 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. |
37-
| **Total** | **218** | **1669** | 14 protocol modules |
37+
| **Total** | **218** | **1670** | 14 protocol modules |
3838

3939
---
4040

4141
## AI Protocol
4242

43-
**Source:** `packages/spec/src/ai/` · **Import:** `@objectstack/spec/ai` · **14 pages, 81 schemas**
43+
**Source:** `packages/spec/src/ai/` · **Import:** `@objectstack/spec/ai` · **14 pages, 82 schemas**
4444

4545
Agents, tools, skills, RAG and knowledge sources, model registry, conversations.
4646

@@ -49,7 +49,7 @@ Agents, tools, skills, RAG and knowledge sources, model registry, conversations.
4949
| [`agent.zod.ts`](/docs/references/ai/agent) | `AIModelConfig`, `Agent`, `StructuredOutputConfig`, `StructuredOutputFormat`, `TransformPipelineStep` |
5050
| [`build-progress.zod.ts`](/docs/references/ai/build-progress) | `BuildProgressFrame`, `BuildProgressPhase` |
5151
| [`conversation.zod.ts`](/docs/references/ai/conversation) | `CodeContent`, `ConversationAnalytics`, `ConversationContext`, `ConversationMessage`, `ConversationSession`, `ConversationSummary`, `FileContent`, `FunctionCall`, `ImageContent`, `MessageContent`, `MessageContentType`, `MessagePruningEvent`, `MessageRole`, `TextContent`, `TokenBudgetConfig`, `TokenBudgetStrategy`, `TokenUsageStats`, `ToolCall` |
52-
| [`dataset-tools.zod.ts`](/docs/references/ai/dataset-tools) | `DatasetProvenance`, `DatasetTermMatch`, `DatasetTermMatchedOn`, `DatasetToolCatalogDimension`, `DatasetToolCatalogEntry`, `DatasetToolCatalogMeasure`, `ListDatasetsInput`, `ListDatasetsOutput`, `QueryDatasetInput`, `QueryDatasetOutput` |
52+
| [`dataset-tools.zod.ts`](/docs/references/ai/dataset-tools) | `DatasetProvenance`, `DatasetTermCandidate`, `DatasetTermMatch`, `DatasetTermMatchedOn`, `DatasetToolCatalogDimension`, `DatasetToolCatalogEntry`, `DatasetToolCatalogMeasure`, `ListDatasetsInput`, `ListDatasetsOutput`, `QueryDatasetInput`, `QueryDatasetOutput` |
5353
| [`embedding.zod.ts`](/docs/references/ai/embedding) | `EmbeddingModel`, `VectorStore`, `VectorStoreProvider` |
5454
| [`knowledge-document.zod.ts`](/docs/references/ai/knowledge-document) | `KnowledgeChunk`, `KnowledgeDocument`, `KnowledgeHit` |
5555
| [`knowledge-source.zod.ts`](/docs/references/ai/knowledge-source) | `FileKnowledgeSource`, `HttpKnowledgeSource`, `KnowledgeRefreshPolicy`, `KnowledgeSource`, `KnowledgeSourceKind`, `ObjectKnowledgeSource` |

‎docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ The rule is stated once here and carried in three places: the tool descriptions
156156

157157
Why the platform computes `matches` instead of leaving the whole rule to the model: 防 AI 犯错. The model still decides what the question's terms are; whether a term equals a synonym is a string comparison, and a string comparison belongs where it can be unit-tested and where every consumer gets the same answer.
158158

159+
> **Amendment note (2026-11-17, [#34761](https://github.com/objectstack-ai/objectstack/issues/34761) — this PR): a term with no hit is answered with `candidates`, offered for a question and never selected.**
160+
> Ruled by the maintainer on [#34691](https://github.com/objectstack-ai/objectstack/issues/34691), fork F1, option B, option text verbatim 「B 零命中返回候选」 — 「现在就改服务器,list_datasets 零命中时返回候选数据集。专题席的新推荐。」 (ruling record [`6943126855`](https://github.com/objectstack-ai/objectstack/issues/34691#issuecomment-6943126855), relayed to #34659 as `6943149235`). It re-rules point E2 of #34659's record `6940528935`, where `list_datasets` stayed exact-match with no candidates list on a named premise, to that point's option A. The contract is `packages/spec/src/ai/dataset-tools.zod.ts#ListDatasetsOutputSchema` (its `candidates` member) with `packages/spec/src/ai/dataset-tools.zod.ts#DatasetTermCandidateSchema`; this note points at it without restating every case.
161+
>
162+
> - **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.
163+
> - **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.
164+
> - **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.
165+
> - **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.
166+
> - **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.
167+
> - **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.
168+
> - **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.
169+
159170
### D4 — Permissions: the tools add no gate and bypass none
160171

161172
Measured in [Context](#the-executor-and-its-gate-chain-measured-on-originmain). The binding statements:

‎docs/audits/2026-07-unknown-key-strictness-ledger.counts/ai.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ hand-patch a number here** — fix the code or the verdict and regenerate.
1919

2020
| Dir | Sites |
2121
|---|---|
22-
| `ai/` | 96 |
22+
| `ai/` | 97 |

‎packages/spec/api-surface/ai.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
"ConversationSummarySchema (const)",
5959
"DatasetProvenance (type)",
6060
"DatasetProvenanceSchema (const)",
61+
"DatasetTermCandidate (type)",
62+
"DatasetTermCandidateSchema (const)",
6163
"DatasetTermMatch (type)",
6264
"DatasetTermMatchSchema (const)",
6365
"DatasetTermMatchedOn (const)",
@@ -95,6 +97,7 @@
9597
"KnowledgeSourceKindSchema (const)",
9698
"KnowledgeSourceParsed (type)",
9799
"KnowledgeSourceSchema (const)",
100+
"LIST_DATASETS_MAX_CANDIDATES_PER_TERM (const)",
98101
"LIST_DATASETS_TOOL_NAME (const)",
99102
"ListDatasetsInput (type)",
100103
"ListDatasetsInputSchema (const)",

‎packages/spec/authorable-surface/ai.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@
163163
"ai/DatasetProvenance:kind",
164164
"ai/DatasetProvenance:measures",
165165
"ai/DatasetProvenance:runtimeFilter",
166+
"ai/DatasetTermCandidate:dataset",
167+
"ai/DatasetTermCandidate:member",
168+
"ai/DatasetTermCandidate:term",
166169
"ai/DatasetTermMatch:matchedOn",
167170
"ai/DatasetTermMatch:member",
168171
"ai/DatasetTermMatch:term",
@@ -242,6 +245,7 @@
242245
"ai/KnowledgeSource:source",
243246
"ai/KnowledgeSource:vectorStore",
244247
"ai/ListDatasetsInput:terms",
248+
"ai/ListDatasetsOutput:candidates",
245249
"ai/ListDatasetsOutput:datasets",
246250
"ai/ListDatasetsOutput:partial",
247251
"ai/ListDatasetsOutput:warning",

‎packages/spec/declaration-map/ai.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
"ConversationSummarySchema": "ai/ConversationSummary",
4545
"DatasetProvenance": "ai/DatasetProvenance",
4646
"DatasetProvenanceSchema": "ai/DatasetProvenance",
47+
"DatasetTermCandidate": "ai/DatasetTermCandidate",
48+
"DatasetTermCandidateSchema": "ai/DatasetTermCandidate",
4749
"DatasetTermMatch": "ai/DatasetTermMatch",
4850
"DatasetTermMatchSchema": "ai/DatasetTermMatch",
4951
"DatasetTermMatchedOn": "ai/DatasetTermMatchedOn",

0 commit comments

Comments
 (0)