Skip to content

Commit ceb5cdf

Browse files
docs(skills): teach the two existing ways to make an ambiguous dataset word ask back (#38342)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu4BDY5KrntKbjvrr3aMjZ7V)_ Fixes #38263 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:给应用配置问数指标的人和 AI,现在能从技能和文档里学到怎样让有歧义的业务词(比如「逾期」「最大客户」)被反问,而不是被平台猜一个;平台行为不变。 - 为什么做:你对「给指标加一个声明歧义的新配置项」那张卡的决定是先不加,先把现有的两种办法写进说明,这是那一步。 - 出错会怎样:最坏是说明里某句话和平台实际做法对不上,作者照着配了却没有被反问;只改文字,可以直接撤回。 - 要你做什么:技能文件改动需要你批准合并。 ## What changes Text only. No key, schema, ADR or behaviour changes. This carries out ruling record 7237969082 on #38079 (no new key; the two existing ways go into the author guidance, only the first taught as guaranteed). - `skills/objectstack-ui/rules/dashboards.md`, the vocabulary comment of the dataset example (where an authoring agent picks `synonyms` and `description`): a word with two readings that the AI must ask about is a synonym of a measure in each of two datasets, asked whenever the asker can read both. Inside one dataset a repeated synonym is refused, so the word goes inside each reading's label or synonym (`overdue invoices`, `overdue tasks`); it then equals neither and the platform MAY offer both as candidates to ask about. "Not guaranteed: an exact match on a readable member suppresses them." - `content/docs/data-modeling/analytics.mdx`: a new section "A word with two readings" after "Key rules", with a two-row table, a type-checked two-dataset example, and the limits of the one-dataset way (an exact match anywhere wins; which members are near is the platform's rule and the list is capped; candidates that are all dimensions are not asked about; a longer phrase or Chinese text without word breaks reaches the readings as candidates, not as a match). The "Give every member its vocabulary" rule gains a pointer to it. - `.changeset/38263-ambiguous-word-ask-back.md`: `@objectstack/skills` patch. No package ships `content/docs`. **Token ratchet** (`scripts/check-skills-token-ratchet.mjs`): not edited. `dashboards.md` sat at its ceiling with zero headroom (25092 bytes, 6273 tokens) and is 25092 bytes after. The 477 added bytes are paid by cuts in the same file: - the sentence after "can a dataset express this?" that restated it and the table under it ("The shape is already fixed (always a dataset), so what you decide is whether the data need fits the dataset envelope, and if not, which lower layer to escalate to."); - the date-granularity "Rule of thumb" bullet (general advice, no platform fact); - three asides in the drilldown bullets ("(no label→id guessing)", "completing the group → records → record chain", "The in-place drawer is the default (peek without losing the dashboard)."). ### Skills readings (lines / bytes / tokens) | | before | after | |:-|:-|:-| | `skills/objectstack-ui/rules/dashboards.md` | 474 / 25092 / 6273 | 476 / 25092 / 6273 | | all `skills/*/SKILL.md` | 4956 / 263327 | 4956 / 263327 | | all of `skills/**` | 23318 / 1228412 | 23320 / 1228412 | ## Tests No runtime code changes, so no test file is added. Each taught behaviour was read in the landed code and then measured with a scratch vitest file (not committed) against `packages/services/service-analytics/src/dataset-term-matcher.ts` and `DatasetSchema`, on `objectstack-ai/objectstack` at 75bb971 (its `packages/**` are `main` 4ebe9a1): 7 of 7 cases pass. <details><summary>What the probe measured</summary> 1. The same synonym (`overdue`) on a measure of each of two datasets: `matchDatasetTerms` answers two measure hits and `findDatasetTermCandidates` answers none. Two measures for one word is the `several_measures` decision in `dataset-next-step.ts` (the question). 2. A reader admitted to only one of the two datasets: one hit. 3. A longer phrase (`overdue deliverables`) or unsegmented Chinese (`逾期的交付物`) against those two datasets: no hit, both measures offered as candidates. 4. One dataset whose two measures are labelled `Overdue invoices` and `Overdue tasks` (synonyms `逾期发票`, `逾期任务`): `overdue` and `逾期` hit nothing and both measures are offered as candidates (`candidates_only`). 5. The same, plus another listed member named exactly `overdue` (a measure, then a dimension): no candidates at all. 6. The exact longer wording (`overdue invoices`): one hit, nothing to ask. 7. `DatasetSchema` refuses the same synonym on two members of one dataset ("Within one dataset a word answers to one member"). </details> ## Acceptance notes - Branch `claude/project-thread-5pi6i5` is assigned by the harness, not the repo's `claude/issue-N-…` convention. - "Asked" means the platform's answer tells the model to ask: `list_datasets` reports two measures for the word and its `nextStep` sentence asks. How often a model then asks is what the cloud ask eval on #38079 measures, not this PR. - The skill sentence stays inside what the probe shows: with two datasets, a phrase containing the word still reaches both readings (case 3), unless some readable member equals the phrase exactly. - `skills/objectstack-ask/SKILL.md` is unchanged. It is the answering side, and its step 2 table already states both cases ("One word matches several measures, in one dataset or in two" and "A word with a measure among its `candidates`"). - `content/docs/ai/connect-mcp.mdx` already describes the selection rule for an MCP client and is outside the claim's file surface; unchanged. - No eval case is added: `skills/objectstack-ui/evals/**` is outside the claim's file surface. A case in `analytics-inline-vs-dataset.json` (two readings of one word, expect the synonym on a measure in each of two datasets) would exercise the new sentence; left to the seat. - The docs page says the candidate list "is capped for each word" without the number, so the page does not go stale when the cap moves. ## Verification Two-minute check: `node scripts/check-skills-token-ratchet.mjs`, expect exit 0 with `skills/objectstack-ui/rules/dashboards.md` 6273 / 6273. Read first, by risk: `skills/objectstack-ui/rules/dashboards.md` (the seven added comment lines, then the four cuts), `content/docs/data-modeling/analytics.mdx` (the section "A word with two readings"). <details><summary>Local gates at 75bb971</summary> `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran FILE` with each command recorded as `CMD :: exit N`: **71 derived, 70 run, 1 NOT-MEASURED, 0 UNRUN**; every run family exit 0, among them `check-skills-token-ratchet.mjs` (and `--self-test`), `check:doc-authoring`, `check:corpus-claim-drift`, `check:doc-anchors`, spec `check:docs` / `check:skill-examples` (352 marked examples type-check, the new docs block among them) / `check:liveness`, `check-empty-changeset.mjs`, `check-adr-0087-registration.mjs --base origin/main`. - `check:skill-examples` first answered exit 3 (its client-react build closure was missing); after `pnpm --filter '@objectstack/client-react...' build` it was re-run alone, exit 0. - NOT MEASURED: `check:dual-build-cjs-loads`, exit 3 (prerequisite not met: it reads every package's `dist/`, and only the spec, service-analytics and client-react closures were built). The diff publishes skills text only. - `scripts/pm/overlap-check.mjs --pr=38284,38224,38329`: clean against `origin/main` and the three heads. The head of the #34770 resume branch carries no change under `skills/objectstack-ui/` or to `analytics.mdx`. - CI at 75bb971 when this was written: 29 success, 15 expected skip, 0 failed, 2 pending. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgWDE5EEgGsQJDWe9dJ <!-- signed: repo:objectstack#2 · os-sales · session_01L6bhgWDE5EEgGsQJDWe9dJ --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent ed70d23 commit ceb5cdf

3 files changed

Lines changed: 110 additions & 10 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the dataset authoring rule teaches the two existing ways to make an ambiguous business word ask back
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`skills/objectstack-ui/rules/dashboards.md`, the dataset example's vocabulary comment: a word with two readings (`overdue`) that the AI must ask about is written as a synonym of a measure in each of two datasets, and is then asked about whenever the asker can read both. Inside one dataset a repeated synonym is refused, so the word goes inside each reading's own label or synonym (`overdue invoices`, `overdue tasks`): it then equals neither, and the platform may offer both as candidates to ask about. That second way is taught as not guaranteed, because an exact match on any readable member suppresses the candidates.
11+
12+
No key, schema or behaviour changes: the text describes what `list_datasets` already does (ADR-0149 D1 and D3).
13+
14+
No token ceiling moved: the addition is paid by deletions in the same file (a restated sentence above the dataset envelope table, the date-granularity rule of thumb, three asides in the drilldown bullets).

‎content/docs/data-modeling/analytics.mdx‎

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ export default defineStack({
111111
`derived` measure.
112112
- **Give every member its vocabulary.** `synonyms` are the words a person
113113
types, in their own language (a flat list, matched and never translated; one
114-
word names one member), and `description` is a one-sentence business
114+
word names one member; for a word with two readings see
115+
[below](#a-word-with-two-readings)), and `description` is a one-sentence business
115116
definition. A measure or dimension with neither answers only to its own name
116117
and label, so a question asked in a user's own words misses the governed
117118
metric; validation and publish warn with `dataset-member-no-vocabulary`.
@@ -123,6 +124,89 @@ export default defineStack({
123124
- **RLS / tenant scoping is enforced by the runtime**, per joined object — never
124125
declared in the dataset. There is one place to reason about access.
125126

127+
### A word with two readings
128+
129+
Some business words mean two things in one app: "overdue" can be overdue
130+
invoices or overdue tasks, and "biggest client" can be by revenue or by number
131+
of orders. When a person asks the AI about such a word, it should ask which
132+
one they mean, not pick one. No key declares this. Where you put the word in
133+
the members' vocabulary decides it, in one of two ways:
134+
135+
| Where the word is | What happens when someone asks about it |
136+
|:--|:--|
137+
| A synonym of a measure in each of **two datasets** | The AI asks which one is meant, and picks neither. |
138+
| Inside a longer label or synonym of each reading, in **one dataset** | The platform may offer those measures as possible readings, and the AI then asks. Not guaranteed. |
139+
140+
**Two datasets: the question is asked.** The same word may name a measure in
141+
two different datasets. A word that equals more than one measure is never
142+
answered by picking one: the AI lists each measure's label, its dataset's label
143+
and its `description`, and asks.
144+
145+
{/* os:check */}
146+
```ts
147+
import { defineDataset } from '@objectstack/spec/ui';
148+
149+
export const InvoiceMetrics = defineDataset({
150+
name: 'invoice_metrics',
151+
label: 'Invoices',
152+
object: 'invoice',
153+
dimensions: [{ name: 'status', field: 'status', type: 'string' }],
154+
measures: [
155+
{
156+
name: 'overdue_invoice_count', label: 'Overdue invoices',
157+
aggregate: 'count', filter: { status: 'overdue' },
158+
synonyms: ['overdue', '逾期'],
159+
description: 'Invoices past their due date and not yet paid.',
160+
},
161+
],
162+
});
163+
164+
export const TaskMetrics = defineDataset({
165+
name: 'task_metrics',
166+
label: 'Tasks',
167+
object: 'task',
168+
dimensions: [{ name: 'status', field: 'status', type: 'string' }],
169+
measures: [
170+
{
171+
name: 'overdue_task_count', label: 'Overdue tasks',
172+
aggregate: 'count', filter: { status: 'overdue' },
173+
synonyms: ['overdue', '逾期'],
174+
description: 'Tasks past their due date and not done.',
175+
},
176+
],
177+
});
178+
```
179+
180+
Write a `description` on each reading: the question shows it, and it is what
181+
lets the person choose. A person who may read only one of the two datasets is
182+
not asked, because for them the word has one reading.
183+
184+
**One dataset: the question may be asked.** Inside one dataset a word names one
185+
member, so the same synonym on two measures is refused (`DATASET_INVALID`).
186+
When both readings belong in one dataset, put the word inside each reading's
187+
own label or synonym, such as `overdue invoices` and `overdue tasks`, and give
188+
the bare word to neither. The bare word then equals no member. The platform
189+
may list the members whose name, label or synonym contains it as candidates,
190+
and with a measure among them the AI asks which is meant. Treat this as likely,
191+
not certain:
192+
193+
- A candidate is offered only for a word that equals nothing. If any member the
194+
person can read, in any dataset, has the bare word as its name, label or
195+
synonym, that member is the match and no candidates are listed.
196+
- Which members are near enough to offer is the platform's own rule, and the
197+
list is capped for each word.
198+
- A word whose candidates are all dimensions is read as a possible grouping,
199+
and is not asked about.
200+
201+
The AI chooses which words of a question to look up. When it looks up a longer
202+
phrase ("overdue deliverables") or Chinese text without word breaks
203+
(「逾期的交付物」) in place of the word itself, the phrase equals no synonym.
204+
The readings then reach it as candidates in the same way, the two-dataset ones
205+
included, and the same limits apply.
206+
207+
When the word must be asked about, use two datasets: there the question is the
208+
rule each time the word itself is looked up.
209+
126210
### Duration measures
127211

128212
A measure can aggregate the time between two `datetime` fields of the same

‎skills/objectstack-ui/rules/dashboards.md‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ const widget: DashboardWidget = {
6060
```
6161

6262
**The real decision is not "inline vs dataset" — it is "can a dataset express
63-
this?"** The shape is already fixed (always a dataset), so what you decide is
64-
whether the *data need fits the dataset envelope*, and if not, which lower layer to
65-
escalate to. Decide on **expressibility**; reuse/governance is Level B.
63+
this?"** Decide on **expressibility**; reuse/governance is Level B.
6664

6765
**Level A — the dataset envelope:**
6866

@@ -300,6 +298,13 @@ defineDataset({
300298
// language (matched, never translated; one word names one member), and a
301299
// one-sentence business `description`, never a prompt. Neither warns:
302300
// `dataset-member-no-vocabulary`.
301+
// A word with two readings (`overdue`) the AI must ask about, not pick:
302+
// make it a synonym of a measure in EACH of two datasets (asked whenever
303+
// the asker can read both). In one dataset a repeated synonym is refused:
304+
// put the word inside each reading's label or synonym (`overdue invoices`,
305+
// `overdue tasks`); it then equals neither and the platform MAY offer both
306+
// as candidates to ask about. Not guaranteed: an exact match on a
307+
// readable member suppresses them.
303308
// A money measure may set `currency` (ISO 4217, e.g. `'USD'`). Chain:
304309
// measure `currency` → the field's `defaultCurrency` (`fixed` only) →
305310
// tenant `localization.currency`; omit it for counts. A
@@ -334,8 +339,6 @@ const signedByMonth: DashboardWidget = { id: 'signed_by_month', type: 'line',
334339
"spent_sum / 616000".
335340
* **Combines with `compareTo`** — the comparison query is issued with the same
336341
granularity, so the muted overlay aligns bucket-for-bucket.
337-
* **Rule of thumb** — `day` for ≤30d windows, `week` for ~90d, `month` for
338-
6–12 months, `quarter` for multi-year, `year` for retention / compliance.
339342

340343
### Widget `options` — the five declared keys
341344

@@ -368,13 +371,12 @@ behind it; **drill-to-record** opens one record.
368371
* **`table` / `pivot` widgets drill through.** Clicking an aggregated table row
369372
or pivot cell opens a side drawer listing the underlying records. The dataset
370373
preserves each grouped row's raw group keys, so the drawer filters to the
371-
*exact* records (no label→id guessing). Automatic — no per-widget config.
374+
*exact* records. Automatic — no per-widget config.
372375
* **The drilled record list drills to record.** Any row in that drawer opens the
373-
single record's detail, completing the **group → records → record** chain.
376+
single record's detail.
374377
* **Escape hatch — "Open in list →".** The drawer header offers a link to the
375378
object's *full* list page (sort / bulk-select / export / shareable URL),
376-
scoped by the same drill filter. The in-place drawer is the default (peek
377-
without losing the dashboard). Today a relationship-path dimension
379+
scoped by the same drill filter. Today a relationship-path dimension
378380
(`account.industry`) gets the drawer only, no link.
379381
* **`metric` / `chart` widgets are not click-drillable** in the dataset form
380382
(they render the aggregate only; `compareTo` still applies). Surface the detail

0 commit comments

Comments
 (0)