Skip to content

Commit 92a5cac

Browse files
feat(spec): the dataset tools' output declares nextStep on list_datasets and sourceLine on query_dataset (ADR-0149 M1) (#34982)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ Fixes #34918 Clause-②: yes (widening: two optional output members on published schemas) Metadata-protocol: added Skills-docs: follow-up owed — skills/objectstack-ask/SKILL.md (follows `nextStep` and cites `sourceLine` once the executor fills them) ## 维护者速读 - 改了什么:两个问数工具的返回结构各加一个可选成员。`list_datasets` 加 `nextStep`:平台按 D3 选数规则读用户的词,读到的是四种情况里的哪一种(命中一个度量、命中多个度量、只有候选、没有度量),说的是哪些词,外加一句成文的话。`query_dataset` 加 `sourceLine`:答案出处的一句成文的话。ADR-0149 M1 末尾加一段只增不改的修订说明。本 PR 只声明形状,不改执行器。 - 为什么改:#34894 的裁决(选 A,记录 6953671481,原话「两件都同意:构建提交进仓库,#34894 选 A」):下一步和出处这两句话由平台执行器写进工具返回,产品自己的 AI 和 MCP 客户端读到的是同一份;规范只声明形状,句子的文字不进规范,M1 不变。 - 风险与回滚:只加两个可选输出成员,不带它们的返回解析结果与之前相同。执行器在 #34919 填充,它落地前没有返回会带这两个成员,但 MCP 客户端读到的 `outputSchema` 从本 PR 起就多出这两项。`decision` 的四个取值发布后即对外契约,之后改名是破坏性变更。回滚即 revert 本 PR。 - 先看:① `packages/spec/src/ai/dataset-tools.zod.ts` 里 `DatasetNextStepDecision` 的四个取值和 `decision` 的 `.describe()` 文字:取值写的是「平台查到了什么」,不是「接下来该怎么做」;② 同一文件里 `nextStep.terms`:它按词指向同一份返回里的 `matches` 与 `candidates`,自己不再列成员,理由在下面 Schema decisions;③ `docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md` M1 末尾的修订说明,看它是否如实转述裁决。 - 两分钟验证:`pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/ai/dataset-tools.test.ts`,预期 `Tests 44 passed (44)`。 - 需要你做的:席位 L2 复核后,亲手合并本 PR(Tier H:`docs/adr/**` 与 `packages/spec/**`)。 ## What changes - **`packages/spec/src/ai/dataset-tools.zod.ts`** (100 lines added, 2 removed; the two removed lines are module doc block lines, rewritten to name the two members): - `ListDatasetsOutputSchema` gains one optional member, `nextStep`, a `DatasetNextStepSchema`. - `DatasetNextStepSchema` (type `DatasetNextStep`): `{ decision, terms, note }`, all three required. `decision` is `DatasetNextStepDecision`; `terms` is a list of strings with at least one entry; `note` is a non-empty string. - `DatasetNextStepDecision`: a closed enum, `one_measure`, `several_measures`, `candidates_only`, `no_measure`. - `QueryDatasetOutputSchema` gains one optional member, `sourceLine`, a non-empty string, declared in the tool's own `.extend()` beside `provenance`. - `candidates`, `matches`, `provenance`, `AnalyticsResultResponseSchema` and every other declaration are untouched. - **`packages/spec/src/ai/dataset-tools.test.ts`**: eleven new cases (44 run in the file now). Seven in a new `list_datasets nextStep` block, two in the `query_dataset output` block, two in the JSON Schema projection block. - **`packages/spec/src/type-alias-convention.pin.test.ts`**: two pin rows for the two new aliases and the pinned count 858 to 860. `check:spec-parsed-alias` (ADR-0122) refuses a new bare input alias with no pin. - **Generated, by the generators only** (`check:generated --fix`): `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 total 1670 to 1672, AI 82 to 84), `docs/audits/2026-07-unknown-key-strictness-ledger.counts/ai.md` (97 to 98 object sites). `authorable-surface.base.json` did not move. - **`docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md`**: an amendment note at the end of M1, in the form of the note under D3. 11 lines added, 0 removed or changed. - **`.changeset/34918-dataset-next-step-source-line.md`**: `@objectstack/spec` at `minor`. - Nothing under `packages/services/**`, `packages/mcp/**` or `skills/**`. ## Why Ruled by the maintainer on #34894, option A, verbatim 「两件都同意:构建提交进仓库,#34894 选 A」 (ruling record `6953671481`). The record states what was ruled: the framework's executor returns `nextStep` (a closed decision, the candidates, a sentence) on `list_datasets` and `sourceLine` on `query_dataset`; the spec declares the shapes; the sentence's text is the executor's and does not enter the spec, so ADR-0149 M1 (ruled A) stands. Today a client that asks through MCP is handed `matches` and `candidates` and works out what they mean, and what to cite, by itself. With the two members every client that made the call reads the same conclusion and the same source line from the result. This PR is the spec half: the shapes, and the record. The executor that fills both members is #34919. ## Schema decisions | Point | Card or ruling | Settled here | Why | |:--|:--|:--|:--| | `decision` values | a closed enum covering one metric matches, several match, near candidates only, nothing | `one_measure`, `several_measures`, `candidates_only`, `no_measure` | Lowercase `snake_case`, the casing AGENTS.md gives data values (Prime Directive 3). The cases are counted in measures because D3 selects a measure. The set is the four cases the card names and no more. | | What a value names | not stated | what the platform found, not what a reader then does | M1 A keeps guidance out of the spec, so no value is an instruction (`ask`, `use`, `fallback`). What follows from each case is D3's to say. M2 (the fallback posture) names its own revisits: a re-ruling of what to do in a case leaves the four findings as they are. | | A term that equals only a dimension | not stated | `no_measure`; no fifth value | D3 rule 5: a dimension alone is not an answer. The term keeps its entry in the dataset's `matches`, and the `decision` description says a dimension is not counted. | | The reference to the candidates | "the candidates it rests on", without declaring #34761's list twice | `terms`: the caller's terms the decision is about. `nextStep` holds no member list | **Differs in form from the ruling record's "the candidates".** Every entry of `matches` and of `candidates` already carries the caller's `term`, so the terms are the join key: the members are read under them from the same answer. No `{ dataset, member }` pointer is declared a second time, so there is no second list that could disagree with the first. | | `note` | a string slot whose text is the executor's | required inside `nextStep`, non-empty | A `nextStep` without its sentence would not be the ruled result. The spec fixes no wording, no template and no language. | | One `nextStep` or one per term | "a closed decision" | one object per answer | When the caller's terms are in different cases, which case the answer reports is the executor's rule (#34919). `terms` says which terms the reported case is about. Raised in the dev report as an open question for #34919. | | Presence of `nextStep` | optional | `.optional()`; described as present only when `terms` were sent | An answer without the key parses to the same value as before. A schema cannot tie an output member to the input; holding it is the executor's. | | `sourceLine` | optional string | `z.string().min(1).optional()` | "No source line" has one spelling, the key's absence. An empty string does not parse. | | Where `sourceLine` is declared | on the `query_dataset` output, without widening the shared response | in `QueryDatasetOutputSchema`'s own `.extend()`, beside `provenance` | The schema is already `AnalyticsResultResponseSchema.shape.data` with `sql` omitted and the tool's members added. Adding one more there leaves `AnalyticsResultResponseSchema` unedited; a test pins that the REST door's `data` shape has no `sourceLine`. | | Description text | says what the member is for; no guidance | facts only | Each description says what the member is, who composes it and what it is composed from. None says what a model should do with it. | The two new type aliases are bare input aliases with pins, not aliases paired with a `Parsed` twin: neither schema has a default or a transform, so input and output types are the same (ADR-0122). ## Known overlaps `node scripts/pm/overlap-check.mjs` exits 1 against two open PRs. The dispatching seat (area o3-E) read both overlaps and ordered the push. | Open PR (head) | File | Where the two sides meet | |:--|:--|:--| | #34925 (`8f6048c352`), #34719 (`5a05e4f2f4`) | `packages/spec/src/type-alias-convention.pin.test.ts` | the pinned isomorphic-alias count (858 to 860 here): the header line, the case title, and the history comment with `toHaveLength`. The pin rows themselves merge | | #34925 (`8f6048c352`), #34719 (`5a05e4f2f4`) | `content/docs/references/index.mdx` (generated) | the generated totals. The frontmatter description count and the Total row conflict (1672 here, 1671 there), in one hunk with the UI row (177 to 178 there). The AI row (82 to 84 here) moves beside them and merges | Remedy for whichever lands second: merge `main`, re-run `gen:docs`, re-sum the pin count. No other file conflicts (`git merge-tree` against each fetched head, read hunk by hunk). #34928 (`3d92094558`) shares the ADR-0149 file, with a note under D3, and merges cleanly. This PR touches none of those PRs nor their branches. ## Outside the claimed surface None. All 13 changed paths are in the claim's File surface (claim comment `6959561891`), the pin test and the two generated totals files included. ## Prior rulings read The claim names these. None is crossed. - **#34894 A** (`6953671481`): built as ruled. "The candidates" is carried by reference (card scope: one shape with #34761's `candidates`, not the same list twice). - **ADR-0149 M1 A** (guidance text out of the spec): no sentence of guidance is added. The note under M1 changes no word of M1. - **ADR-0149 D2** (two tools, one definition, one executor, two transports): each tool's one definition gains one optional member. No second definition, no executor and no transport changes. - **ADR-0149 D3 and its amendment note**: what counts as a hit, the five rules and the candidates rule are untouched. `nextStep.decision` names which of those cases an answer is in. - **#34691 F1 B** (the server returns candidates at zero match): `candidates` is unchanged and stays the one list. - **ADR-0149 D6** (every key names its reader in its first implementation card): the note's "State on `main`" bullet names #34919 as the card that fills both members. ## Tests Readings are on head `d10ea09296` with a clean working tree. | 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 47 passed (47)`; lock line `VERDICT command-exit 0` | | `pnpm --filter @objectstack/spec typecheck` (verify lock) | `check:test-typecheck: OK`; `VERDICT command-exit 0` | | `pnpm --filter @objectstack/spec test` (verify lock) | `Test Files 849 passed (849)`; `Tests 27213 passed \| 1 todo (27214)`; `VERDICT command-exit 0` | | `pnpm --filter @objectstack/service-analytics test` and `pnpm --filter @objectstack/mcp test` (verify lock) | service-analytics `Test Files 218 passed (218)`, `Tests 5560 passed \| 335 skipped (5895)`; mcp `Test Files 71 passed (71)`, `Tests 1252 passed (1252)`; `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 members: the built `getDatasetToolJsonSchemas()` answers `nextStep` as `type: object`, `required: ["decision","terms","note"]`, `additionalProperties: false`, with the four-value enum, and `sourceLine` as `type: string`, `minLength: 1`, neither in its output's `required` list. <details><summary>What the new cases pin</summary> - `decision` takes each of the four values and refuses any other, at path `nextStep.decision`: an action word (`ask`), a near spelling (`one_match`), another casing (`ONE_MEASURE`), the empty string, a number and `null`. - An answer with `nextStep` beside `candidates` parses and keeps both. An answer without the key parses to the same value as before. - `decision`, `terms` and `note` are each required. An empty `terms` list and an empty `note` are refused. - `nextStep` has exactly those three keys. A `{ dataset, member }` pointer in `terms` is refused at `terms.0`. - One list of candidates: `ListDatasetsOutputSchema`'s `candidates` element is `DatasetTermCandidateSchema` itself, and a `candidates` or `matches` list written inside `nextStep` is not part of the shape (the parsed value does not carry it). - The reference is by term: the members a decision rests on are found by filtering the same answer's `matches` and `candidates` on `nextStep.terms`. - `sourceLine` is optional and non-empty; an empty string, a number, `null` and a list are refused at path `sourceLine`. An answer without it parses to the same value as before. - `AnalyticsResultResponseSchema`'s `data` shape has no `sourceLine`, and a `sourceLine` sent to the door's `data` is not kept by its parse. - The projected `list_datasets` `outputSchema`: `nextStep` is not in `required`; it is an object requiring `decision`, `note` and `terms`, with `additionalProperties: false`; `decision` is an enum of the four values; `terms` is an array of strings with `minItems` 1; `note` has `minLength` 1. - The projected `query_dataset` `outputSchema`: `sourceLine` is a string with `minLength` 1 and is not in `required`. </details> <details><summary>Ablations (three, each restored)</summary> Each mutation went through `scripts/ablation-replace.mjs` on `dataset-tools.zod.ts`; each anchor hit exactly once and the blob changed; each restore ended with "ok restored: blob == HEAD (332deaf) and `git diff HEAD` is empty". The command under each mutation was the two-minute one above, under the verify lock. The suite imports the schema by relative path from `src/`, so there is no `dist/` leg. | Mutation | Reading | |:--|:--| | a fifth value, `ask`, added to `DatasetNextStepDecision` (the enum no longer closed on the four) | `Tests 2 failed \| 42 passed (44)`: the four-cases case and the `list_datasets` projection case | | `.optional()` dropped from `nextStep` | `Tests 6 failed \| 38 passed (44)`: the `nextStep` "without the key" case, the `nextStep` projection case, and four earlier cases (three whose answers carry no `nextStep`, one that reads the output's `required` list) | | `.optional()` dropped from `sourceLine` | `Tests 4 failed \| 40 passed (44)`: the `sourceLine` case, its projection case, and two earlier `query_dataset` cases whose answers carry no `sourceLine` | After the last restore the two files ran green again: `Test Files 2 passed (2)`, `Tests 47 passed (47)`. </details> ## Acceptance notes - **The members are declared and nothing fills them yet.** Until #34919 lands no answer carries `nextStep` or `sourceLine`. Each tool's `outputSchema` lists its optional member from this PR on. The ADR note says so in its last bullet. - **What the schema cannot refuse is the executor's to hold** (#34919): that `decision` is the case the named terms are in, that every term in `nextStep.terms` was sent, and that `nextStep` is present only when `terms` were sent. The TSDoc on `DatasetNextStepSchema` says so. - **Terms in different cases.** One answer reports one case. Which case wins when the caller's terms are in several is not ruled and not in the spec; it is raised for #34919 in the dev report. - **The hosted wrapper the card cites was not read.** The card's evidence names a wrapper in the hosted product as prior art (a closed decision, the candidates, a finished sentence). That repository is not readable from this session, so its value names were not compared: NOT MEASURED. The four values here come from the card, the ruling record, D3 and the executor on `main` (`findDatasetTermCandidates`, the `listDatasets` fill). - **The `Skills-docs:` line.** `skills/objectstack-ask/SKILL.md` is on `main`; it follows `nextStep` and cites `sourceLine` only once #34919 fills them, so the edit is owed after that card. - **Plain `z.object`, as the sibling output schemas.** The strictness count for `ai/` moves 97 to 98 object sites; `ai/` is an untriaged directory in that ledger. - **Body layout.** The two HTML comments (first and last line) and the footer are the dispatching seat's ordered layout for the relay. - **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` (no paths) at `d10ea09296` derives 109 commands. `--ran` answers: "109 derived famil(ies) accounted for — 109 run, 0 NOT-MEASURED", exit 0. - **First pass.** 103 exited 0. Six exited 3 (PREREQUISITE NOT MET), all for one cause, a package not built in this worktree: the two `@objectstack/lint` doc gates, `check:skill-examples`, `check:docs-transcript-drift`, `check:dual-build-cjs-loads`, `check:lean-entry-closure`. `pnpm check:type-check-debt`, itself a derived gate, runs a `turbo run build` over the packages under the verify lock (exit 0, "0 ledger entr(ies) re-measured"); after it all six exited 0 on a re-run. - **Generators.** `pnpm --filter @objectstack/spec run check:generated` exit 0, "All 14 generated artifacts are up to date". The artefacts were written by `check:generated --fix` only. - **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 confirms the claim's provisional `added`, with `minor`. - **Review tier.** `node scripts/pm/dispatch-gates.mjs --tier`: MANDATORY contract tier for `docs/adr/**`; 388 changed lines (372 added, 16 removed). `node scripts/pm/check-governed-merges.mjs --branch claude/issue-34918-dataset-next-step-source-line`: exit 3, GOVERNED, landing tier H, 1 of 13 paths governed (`docs/adr/**`), size 388 under the 3000 threshold. - **Overlap.** `node scripts/pm/overlap-check.mjs` at `d10ea09296` against `origin/main` `2ce9c7f990`: `origin/main` merges cleanly; #34928 shares the ADR file and merges cleanly; #34925 and #34719 conflict in the two files under *Known overlaps*; "VERDICT overlap exit 1". - **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. 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. `check-platform-checklist --changed-from` is not owed: no exported symbol is renamed or removed. - The branch is 4 commits behind `origin/main` (`2ce9c7f990`); none of the four touches a file of this PR. <details><summary>Selected verdict lines</summary> | Gate | Line | |:--|:--| | `check:generated` | "All 14 generated artifacts are up to date" | | `check:spec-parsed-alias` | "1594 bare z.input aliases, 860 pinned isomorphic, 734 paired with an XParsed. OK" | | `check:api-surface` | "public API surface + factory signatures unchanged" (against the regenerated baseline) | | `check:export-origins` | "6228 exports across 19 entry points resolve exactly as recorded" | | `check:docs` | "248 generated files in sync with packages/spec" | | `check:strictness-ledger` | "docs/audits/2026-07-unknown-key-strictness-ledger.counts/ is current — 14 shard(s)" | | `check:adr-symbol-anchors` | "3738 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-adr-0087-registration` | "this PR adds no declared-breaking changeset (1 non-breaking changeset(s) seen)" | | `check:nul-bytes` | "no raw ASCII control bytes" | </details> ## Human Minimum Each item is one rule from [CONTRIBUTING.md › Human Minimum](https://github.com/objectstack-ai/objectstack/blob/main/CONTRIBUTING.md#human-minimum), which links the AGENTS.md text that states it. - [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: exit 0, no finding). - [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 65ec3c5 commit 92a5cac

13 files changed

Lines changed: 375 additions & 16 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/spec': minor
3+
---
4+
5+
feat(spec): the dataset tools' output declares `nextStep` on `list_datasets` and `sourceLine` on `query_dataset` (ADR-0149 M1)
6+
7+
Clause-②: yes (widening: two optional output members on published schemas)
8+
Metadata-protocol: added
9+
Skills-docs: follow-up owed — skills/objectstack-ask/SKILL.md (follows `nextStep` and cites `sourceLine` once the executor fills them)
10+
11+
`ListDatasetsOutputSchema` (`@objectstack/spec/ai`) gains one optional member, `nextStep`, with its schema `DatasetNextStepSchema` (type `DatasetNextStep`) and the closed enum `DatasetNextStepDecision`. `QueryDatasetOutputSchema` gains one optional member, `sourceLine`. Nothing is removed or renamed, and an answer without either member parses as it did.
12+
13+
- **`nextStep`: what it is.** The platform's reading of the caller's `terms` under the ADR-0149 D3 selection rule, as three members: `decision`, `terms` and `note`.
14+
- **`decision` is a closed enum of four cases.** `one_measure` (the term equals exactly one measure), `several_measures` (it equals more than one, in one dataset or in several), `candidates_only` (it matched no member and has entries in `candidates`), `no_measure` (it equals no measure and has no candidate). A dimension the term equals is not counted: the rule selects a measure. Any other value does not parse. The values name what the platform found, not what a reader then does.
15+
- **`terms` is the reference to the members, and there is one list of candidates.** `nextStep` holds no member list. It names the caller's terms the decision is about, and the members are read under those terms from the same answer: a dataset's `matches` for `one_measure` and `several_measures`, `candidates` for `candidates_only`. No `{ dataset, member }` pointer is declared twice.
16+
- **`note` and `sourceLine` are string slots.** `note` is the decision in words; `sourceLine` is a `query_dataset` answer's source as one finished line, the same source `provenance` carries as structure. Each is a non-empty string, and the spec declares no wording for either: the text is the executor's (ADR-0149 M1).
17+
- **`sourceLine` is the tool's member only.** It is declared on `QueryDatasetOutputSchema`; `AnalyticsResultResponseSchema`, the REST door's answer, is not changed.
18+
- **When they are present.** Both are optional. `nextStep` is present only when `terms` were sent. No `sourceLine` is the key's absence: an empty string does not parse.
19+
- **Who fills them.** This change declares the shapes only, and each tool's `outputSchema` (`getDatasetToolJsonSchemas()`) lists its member from it. Filling them is the dataset tools' executor's change in `@objectstack/service-analytics`, which ships under its own entry; an answer carries `nextStep` or `sourceLine` only from a release that has both.
20+
21+
ADR-0149 M1 gains an add-only amendment note recording the ruling: M1 is unchanged, the spec gains two string slots and one closed enum and no sentence, and the two sentences are written by the executor.
22+
23+
Level: `minor` for `@objectstack/spec`, the level `Metadata-protocol: added` takes. The `authorable-surface/ai.json` baseline records the new keys: `ai/ListDatasetsOutput:nextStep`, the three `ai/DatasetNextStep` members and `ai/QueryDatasetOutput:sourceLine`.

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

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ 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
1515
business vocabulary, which of the caller's words matched which member, and,
16-
for a word that matched nothing, the members offered as `candidates`),
16+
for a word that matched nothing, the members offered as `candidates`; with
17+
them `nextStep`, which case of the selection rule those words are in),
1718
and `query_dataset` runs a `DatasetSelection` against one saved dataset and
1819
answers rows plus a `provenance` block naming the dataset and the measures
19-
used. The shapes are declared here once and projected to the JSON Schema an
20+
used, with `sourceLine`, that source as one finished line. The shapes are
21+
declared here once and projected to the JSON Schema an
2022
`AIToolDefinition` carries (`getDatasetToolJsonSchemas`), so the MCP
2123
registration and the product AI's registration read one definition.
2224

@@ -35,6 +37,9 @@ zero-match term's candidates and the row cap
3537
`data:read` to `@objectstack/mcp` (card #31590). The tool descriptions, which
3638
carry the ADR-0149 D3 selection rule to the model, are written by the
3739
executor: AI guidance text does not enter the spec (ADR-0149 M1, ruled A).
40+
The two sentences an answer carries, `nextStep.note` and `sourceLine`, are
41+
the executor's in the same way (card #34919): the spec declares a string
42+
slot for each and fixes no wording (the amendment note under M1).
3843

3944
<Callout type="info">
4045
**Source:** `packages/spec/src/ai/dataset-tools.zod.ts`
@@ -43,13 +48,38 @@ executor: AI guidance text does not enter the spec (ADR-0149 M1, ruled A).
4348
## TypeScript Usage
4449

4550
```typescript
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';
51+
import { DatasetNextStepSchema, DatasetNextStepDecision, DatasetProvenanceSchema, DatasetTermCandidateSchema, DatasetTermMatchSchema, DatasetTermMatchedOn, DatasetToolCatalogDimensionSchema, DatasetToolCatalogEntrySchema, DatasetToolCatalogMeasureSchema, ListDatasetsInputSchema, ListDatasetsOutputSchema, QueryDatasetInputSchema, QueryDatasetOutputSchema } from '@objectstack/spec/ai';
52+
import type { DatasetNextStep, DatasetNextStepDecision, DatasetProvenance, DatasetTermCandidate, DatasetTermMatch, DatasetTermMatchedOn, DatasetToolCatalogDimension, DatasetToolCatalogEntry, DatasetToolCatalogMeasure, ListDatasetsInput, ListDatasetsOutput, QueryDatasetInput, QueryDatasetOutput } from '@objectstack/spec/ai';
4853

4954
// Validate data
50-
const result = DatasetProvenanceSchema.parse(data);
55+
const result = DatasetNextStepSchema.parse(data);
5156
```
5257

58+
---
59+
60+
## DatasetNextStep
61+
62+
### Properties
63+
64+
| Property | Type | Required | Description |
65+
| :--- | :--- | :--- | :--- |
66+
| **decision** | `Enum<'one_measure' \| 'several_measures' \| 'candidates_only' \| 'no_measure'>` | ✅ | Which case of the ADR-0149 D3 selection rule each term in `terms` is in, computed by the platform from this answer's `matches` and `candidates`. `one_measure`: the term equals exactly one measure. `several_measures`: it equals more than one measure, in one dataset or in several. `candidates_only`: it matched no member and has entries in `candidates`. `no_measure`: it equals no measure and has no entry in `candidates`. A dimension the term equals is not counted |
67+
| **terms** | `string[]` | ✅ | The caller's terms the decision is about, each as sent in the tool's `terms` input. This is the reference to the members the decision rests on, which `nextStep` does not list: they are the entries carrying one of these terms in the same answer, in a dataset's `matches` (those whose `member` is a measure) for `one_measure` and `several_measures`, and in `candidates` for `candidates_only`. `no_measure` rests on no member |
68+
| **note** | `string` | ✅ | The decision in words: finished text in the caller's locale, composed by the tool from this answer and never typed by the model. The wording is the executor's; the schema declares the slot and fixes no text (ADR-0149 M1) |
69+
70+
71+
---
72+
73+
## DatasetNextStepDecision
74+
75+
### Allowed Values
76+
77+
* `one_measure`
78+
* `several_measures`
79+
* `candidates_only`
80+
* `no_measure`
81+
82+
5383
---
5484

5585
## DatasetProvenance
@@ -227,6 +257,7 @@ const result = DatasetProvenanceSchema.parse(data);
227257
| **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 |
228258
| **warning** | `string` | optional | Why the answer is partial; present exactly when `partial` is |
229259
| **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 |
260+
| **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 |
230261

231262
### Nested Shape: `ListDatasetsOutput.datasets[number]`
232263

@@ -249,6 +280,14 @@ const result = DatasetProvenanceSchema.parse(data);
249280
| **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` |
250281
| **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 |
251282

283+
### Nested Shape: `ListDatasetsOutput.nextStep`
284+
285+
| Property | Type | Required | Description |
286+
| :--- | :--- | :--- | :--- |
287+
| **decision** | `Enum<'one_measure' \| 'several_measures' \| 'candidates_only' \| 'no_measure'>` | ✅ | Which case of the ADR-0149 D3 selection rule each term in `terms` is in, computed by the platform from this answer's `matches` and `candidates`. `one_measure`: the term equals exactly one measure. `several_measures`: it equals more than one measure, in one dataset or in several. `candidates_only`: it matched no member and has entries in `candidates`. `no_measure`: it equals no measure and has no entry in `candidates`. A dimension the term equals is not counted |
288+
| **terms** | `string[]` | ✅ | The caller's terms the decision is about, each as sent in the tool's `terms` input. This is the reference to the members the decision rests on, which `nextStep` does not list: they are the entries carrying one of these terms in the same answer, in a dataset's `matches` (those whose `member` is a measure) for `one_measure` and `several_measures`, and in `candidates` for `candidates_only`. `no_measure` rests on no member |
289+
| **note** | `string` | ✅ | The decision in words: finished text in the caller's locale, composed by the tool from this answer and never typed by the model. The wording is the executor's; the schema declares the slot and fixes no text (ADR-0149 M1) |
290+
252291

253292
---
254293

@@ -296,6 +335,7 @@ const result = DatasetProvenanceSchema.parse(data);
296335
| **drillRanges** | `Record<string, { field: string; gte: string; lt: string }>[]` | optional | Drill-through sidecar for date ranges, aligned to `rows` by index: date dimension name to the half-open range `[gte, lt)` that row's records fall in on that dimension's field. A time bucket gets the span it covers; a `timeDimensions[].dateRange` window gets the window the query filtered by on every row, or narrows the bucket entry on the same field to the part inside the window. Bounds are `YYYY-MM-DD` calendar days, or ISO-8601 instants when the source field is `datetime` (a bucket's at midnight in the reference timezone); a row whose bucket value is null gets no bucket entry, and a window whose end is an instant or the last supported day gets none. Set only on a dataset answer that has rows and groups by at least one `type: 'date'` dimension with a `field` and a granularity, or carries a `dateRange` on a dimension with a `field`; independent of `dimensionFields`. Absent on a cube query answer. |
297336
| **drillScopes** | `Record<string, any>` | optional | Drill-through sidecar per measure: each selected measure name to the list filter, on the answer's `object`, that selects the records that measure aggregates: the dataset's own `filter`, AND the measure's own `filter`, AND, for a measure over a `field`, that field holding a value (`{ "$null": false }`; both instants for a duration measure), with each `{token}` resolved as the query resolved it; `{}` when none of these applies. A drill lists the clicked bucket (`dimensionFields` / `drillRawRows` / `drillRawTotals`, `drillRanges`) AND the widget's own filter AND this scope. A measure is left out when no list filter on `object` selects its records (a derived measure; a scope that names a relationship path such as `account.region`, as a key or as a `$field` reference), and a measure left out offers no drill. Keyed by measure name: a `__compare` column has no entry. Set on every dataset answer (`POST /analytics/dataset/query`) that has rows; absent on a cube query answer and on a draft-preview answer. |
298337
| **provenance** | `{ kind: 'dataset'; dataset: object; measures: object[]; dimensions: object[]; … }` | ✅ | The dataset and members the answer was computed from |
338+
| **sourceLine** | `string` | optional | The answer's source as one finished line, in the caller's locale: composed by the tool from `provenance` after the query ran, never typed by the model. `provenance` stays the structured source and this is the same source in words. The wording is the executor's; the schema declares the slot and fixes no text (ADR-0149 M1). Absent when the tool composed none, never an empty string |
299339
| **rowCount** | `integer` | ✅ | How many rows `rows` holds |
300340
| **truncated** | `boolean` | ✅ | `true` when more rows existed past the row cap the tool applied and were not returned |
301341
| **delegationNarrowed** | `true` | optional | Present, and `true`, when the caller acts as an agent whose authority narrows what it may read on the dataset's object; `warning` states the narrowing (ADR-0090 D10) |

‎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 — 1671 schemas across 14 protocol modules
4+
description: Every schema published by @objectstack/spec — 1673 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 | 82 | Agents, tools, skills, RAG and knowledge sources, model registry, conversations. |
23+
| [AI Protocol](/docs/references/ai) | 14 | 84 | 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 | 178 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. |
37-
| **Total** | **218** | **1671** | 14 protocol modules |
37+
| **Total** | **218** | **1673** | 14 protocol modules |
3838

3939
---
4040

4141
## AI Protocol
4242

43-
**Source:** `packages/spec/src/ai/` · **Import:** `@objectstack/spec/ai` · **14 pages, 82 schemas**
43+
**Source:** `packages/spec/src/ai/` · **Import:** `@objectstack/spec/ai` · **14 pages, 84 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`, `DatasetTermCandidate`, `DatasetTermMatch`, `DatasetTermMatchedOn`, `DatasetToolCatalogDimension`, `DatasetToolCatalogEntry`, `DatasetToolCatalogMeasure`, `ListDatasetsInput`, `ListDatasetsOutput`, `QueryDatasetInput`, `QueryDatasetOutput` |
52+
| [`dataset-tools.zod.ts`](/docs/references/ai/dataset-tools) | `DatasetNextStep`, `DatasetNextStepDecision`, `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` |

0 commit comments

Comments
 (0)