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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .changeset/34918-dataset-next-step-source-line.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@objectstack/spec': minor
---

feat(spec): the dataset tools' output declares `nextStep` on `list_datasets` and `sourceLine` on `query_dataset` (ADR-0149 M1)

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)

`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.

- **`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`.
- **`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.
- **`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.
- **`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).
- **`sourceLine` is the tool's member only.** It is declared on `QueryDatasetOutputSchema`; `AnalyticsResultResponseSchema`, the REST door's answer, is not changed.
- **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.
- **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.

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.

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`.
50 changes: 45 additions & 5 deletions content/docs/references/ai/dataset-tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ The two tools give an AI the business semantic layer a person already reads
through dashboards and reports: `list_datasets` returns the catalogue (the
datasets the caller may query, their dimensions and measures, each member's
business vocabulary, which of the caller's words matched which member, and,
for a word that matched nothing, the members offered as `candidates`),
for a word that matched nothing, the members offered as `candidates`; with
them `nextStep`, which case of the selection rule those words are in),
and `query_dataset` runs a `DatasetSelection` against one saved dataset and
answers rows plus a `provenance` block naming the dataset and the measures
used. The shapes are declared here once and projected to the JSON Schema an
used, with `sourceLine`, that source as one finished line. The shapes are
declared here once and projected to the JSON Schema an
`AIToolDefinition` carries (`getDatasetToolJsonSchemas`), so the MCP
registration and the product AI's registration read one definition.

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

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

```typescript
import { DatasetProvenanceSchema, DatasetTermCandidateSchema, DatasetTermMatchSchema, DatasetTermMatchedOn, DatasetToolCatalogDimensionSchema, DatasetToolCatalogEntrySchema, DatasetToolCatalogMeasureSchema, ListDatasetsInputSchema, ListDatasetsOutputSchema, QueryDatasetInputSchema, QueryDatasetOutputSchema } from '@objectstack/spec/ai';
import type { DatasetProvenance, DatasetTermCandidate, DatasetTermMatch, DatasetTermMatchedOn, DatasetToolCatalogDimension, DatasetToolCatalogEntry, DatasetToolCatalogMeasure, ListDatasetsInput, ListDatasetsOutput, QueryDatasetInput, QueryDatasetOutput } from '@objectstack/spec/ai';
import { DatasetNextStepSchema, DatasetNextStepDecision, DatasetProvenanceSchema, DatasetTermCandidateSchema, DatasetTermMatchSchema, DatasetTermMatchedOn, DatasetToolCatalogDimensionSchema, DatasetToolCatalogEntrySchema, DatasetToolCatalogMeasureSchema, ListDatasetsInputSchema, ListDatasetsOutputSchema, QueryDatasetInputSchema, QueryDatasetOutputSchema } from '@objectstack/spec/ai';
import type { DatasetNextStep, DatasetNextStepDecision, DatasetProvenance, DatasetTermCandidate, DatasetTermMatch, DatasetTermMatchedOn, DatasetToolCatalogDimension, DatasetToolCatalogEntry, DatasetToolCatalogMeasure, ListDatasetsInput, ListDatasetsOutput, QueryDatasetInput, QueryDatasetOutput } from '@objectstack/spec/ai';

// Validate data
const result = DatasetProvenanceSchema.parse(data);
const result = DatasetNextStepSchema.parse(data);
```

---

## DatasetNextStep

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **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 |
| **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 |
| **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) |


---

## DatasetNextStepDecision

### Allowed Values

* `one_measure`
* `several_measures`
* `candidates_only`
* `no_measure`


---

## DatasetProvenance
Expand Down Expand Up @@ -227,6 +257,7 @@ const result = DatasetProvenanceSchema.parse(data);
| **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 |
| **nextStep** | `{ decision: Enum<'one_measure' \| 'several_measures' \| 'candidates_only' \| 'no_measure'>; terms: string[]; note: string }` | optional | Which case of the ADR-0149 D3 selection rule the caller's `terms` are in, as the platform computed it from this answer's own `matches` and `candidates`: the case, the terms it is about and the case in words. It adds no match and no candidate and lists no member: the members it rests on are read from `matches` and `candidates` under its `terms`. Present only when `terms` were sent |

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

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

### Nested Shape: `ListDatasetsOutput.nextStep`

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **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 |
| **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 |
| **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) |


---

Expand Down Expand Up @@ -296,6 +335,7 @@ const result = DatasetProvenanceSchema.parse(data);
| **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. |
| **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. |
| **provenance** | `{ kind: 'dataset'; dataset: object; measures: object[]; dimensions: object[]; … }` | ✅ | The dataset and members the answer was computed from |
| **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 |
| **rowCount** | `integer` | ✅ | How many rows `rows` holds |
| **truncated** | `boolean` | ✅ | `true` when more rows existed past the row cap the tool applied and were not returned |
| **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) |
Expand Down
10 changes: 5 additions & 5 deletions content/docs/references/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Protocol reference — every schema by module
navTitle: Protocol Reference
description: Every schema published by @objectstack/spec — 1671 schemas across 14 protocol modules
description: Every schema published by @objectstack/spec — 1673 schemas across 14 protocol modules
---

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

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

---

## AI Protocol

**Source:** `packages/spec/src/ai/` · **Import:** `@objectstack/spec/ai` · **14 pages, 82 schemas**
**Source:** `packages/spec/src/ai/` · **Import:** `@objectstack/spec/ai` · **14 pages, 84 schemas**

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

Expand All @@ -49,7 +49,7 @@ Agents, tools, skills, RAG and knowledge sources, model registry, conversations.
| [`agent.zod.ts`](/docs/references/ai/agent) | `AIModelConfig`, `Agent`, `StructuredOutputConfig`, `StructuredOutputFormat`, `TransformPipelineStep` |
| [`build-progress.zod.ts`](/docs/references/ai/build-progress) | `BuildProgressFrame`, `BuildProgressPhase` |
| [`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` |
| [`dataset-tools.zod.ts`](/docs/references/ai/dataset-tools) | `DatasetProvenance`, `DatasetTermCandidate`, `DatasetTermMatch`, `DatasetTermMatchedOn`, `DatasetToolCatalogDimension`, `DatasetToolCatalogEntry`, `DatasetToolCatalogMeasure`, `ListDatasetsInput`, `ListDatasetsOutput`, `QueryDatasetInput`, `QueryDatasetOutput` |
| [`dataset-tools.zod.ts`](/docs/references/ai/dataset-tools) | `DatasetNextStep`, `DatasetNextStepDecision`, `DatasetProvenance`, `DatasetTermCandidate`, `DatasetTermMatch`, `DatasetTermMatchedOn`, `DatasetToolCatalogDimension`, `DatasetToolCatalogEntry`, `DatasetToolCatalogMeasure`, `ListDatasetsInput`, `ListDatasetsOutput`, `QueryDatasetInput`, `QueryDatasetOutput` |
| [`embedding.zod.ts`](/docs/references/ai/embedding) | `EmbeddingModel`, `VectorStore`, `VectorStoreProvider` |
| [`knowledge-document.zod.ts`](/docs/references/ai/knowledge-document) | `KnowledgeChunk`, `KnowledgeDocument`, `KnowledgeHit` |
| [`knowledge-source.zod.ts`](/docs/references/ai/knowledge-source) | `FileKnowledgeSource`, `HttpKnowledgeSource`, `KnowledgeRefreshPolicy`, `KnowledgeSource`, `KnowledgeSourceKind`, `ObjectKnowledgeSource` |
Expand Down
Loading
Loading