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
22 changes: 22 additions & 0 deletions .changeset/34718-dataset-member-vocabulary-advisory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
'@objectstack/lint': patch
'@objectstack/cli': patch
'@objectstack/skills': patch
---

feat(lint): a dataset measure or dimension that declares neither `synonyms` nor a `description` is advised

Clause-②: yes (widening) — @objectstack/lint gains three exports on its "." entry: validateDatasetMemberVocabulary, DATASET_MEMBER_NO_VOCABULARY and the DatasetMemberVocabularyFinding type; nothing accepted before is refused
Metadata-protocol: none

A dataset member answers a business question through its vocabulary (ADR-0149 D1): `synonyms`, the words a person types for it, and `description`, a short business definition. Both keys are optional, so a dataset that declares neither on a member passes every check, and that member then answers only to its own name and label. A person who asks in other words, or in another language, matches nothing and gets a number from a plain object query instead of the governed metric.

`@objectstack/lint` adds one advisory rule, `dataset-member-no-vocabulary` (`warning`). It reports once per measure or dimension that has no non-blank `synonyms` entry and no non-blank `description`, names the dataset and the member, and says what is lost. One of the two keys is enough to silence it. It runs at `os validate`, `os build` and `os lint`, and at the metadata publish door for a `dataset` write, where it is an advisory on the save response. Nothing is refused: a dataset that only feeds charts loses nothing by leaving both keys out. `os explain dataset-member-no-vocabulary` prints the full reasoning.

The author-time rule count the CLI prints (`Running author-time rules (N)`) rises by one, to 70 for `os validate` and `os build`.

`@objectstack/lint` exports `validateDatasetMemberVocabulary`, `DATASET_MEMBER_NO_VOCABULARY` and the `DatasetMemberVocabularyFinding` type.

`@objectstack/cli`: `os generate dataset` now writes one `synonyms` entry on each member it scaffolds, seeded from a label the stack already declares (the title field's label on the dimension, the object's plural label on the record count), in whatever language that label is written in, under a comment that says to replace the seed with the words your users type and to add a `description`. A fresh scaffold therefore draws no finding. When a seed would answer to two members (a title field labelled like the object), the scaffold picks the next candidate, so the dataset it writes always parses.

`@objectstack/skills`: the `objectstack-ui` dashboards rule now says, for every dataset member, to write `synonyms` as the words a person types, in the language of the brief, and a one-sentence business `description`; that one word names one member; and that a member with neither draws the new warning. Its dataset example gives the dimension a synonym too, and the skill's evals gain a case for a dataset authored from a Chinese brief.
43 changes: 35 additions & 8 deletions content/docs/data-modeling/analytics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,42 @@ export const SalesDataset = defineDataset({
filter: { is_deleted: { $ne: true } },

// Groupable axes — a base field, or a `relationship.field` path.
// `synonyms` are the words a person types when asking for this member.
dimensions: [
{ name: 'stage', field: 'stage', type: 'string' },
{ name: 'region', field: 'account.region', type: 'string' },
{ name: 'close_date', field: 'close_date', type: 'date', dateGranularity: 'month' },
{ name: 'stage', field: 'stage', type: 'string', synonyms: ['pipeline stage', 'phase'] },
{ name: 'region', field: 'account.region', type: 'string', synonyms: ['territory', 'area'] },
{
name: 'close_date', field: 'close_date', type: 'date', dateGranularity: 'month',
synonyms: ['close month', 'closing date'],
},
],

// Aggregatable values — defined ONCE here; referenced everywhere by name.
measures: [
{ name: 'opp_count', aggregate: 'count' },
{ name: 'revenue', aggregate: 'sum', field: 'amount', format: '$0,0' },
{ name: 'won_amount', aggregate: 'sum', field: 'amount', filter: { stage: 'closed_won' } },
{ name: 'opp_count', aggregate: 'count', synonyms: ['deals', 'opportunities', 'number of deals'] },
{
name: 'revenue', aggregate: 'sum', field: 'amount', format: '$0,0',
synonyms: ['sales', 'pipeline value'],
description: 'The total amount of every opportunity, open or closed.',
},
{
name: 'won_amount', aggregate: 'sum', field: 'amount', filter: { stage: 'closed_won' },
synonyms: ['won revenue', 'bookings'],
description: 'The total amount of the opportunities that closed won.',
},
// Derived measure — references OTHER measures by name only (no raw fields/SQL).
{ name: 'win_rate', derived: { op: 'ratio', of: ['won_amount', 'revenue'] }, format: '0.0%' },
{
name: 'win_rate', derived: { op: 'ratio', of: ['won_amount', 'revenue'] }, format: '0.0%',
synonyms: ['close rate', 'conversion rate'],
description: 'Won amount as a share of the total opportunity amount.',
},
// Duration measure — the time between two datetime fields of each record.
{ name: 'avg_days_to_close', aggregate: 'avg', duration: { from: 'created_at', to: 'closed_at', unit: 'days' } },
{
name: 'avg_days_to_close', aggregate: 'avg',
duration: { from: 'created_at', to: 'closed_at', unit: 'days' },
synonyms: ['sales cycle', 'time to close'],
description: 'The average number of days from creating an opportunity to closing it.',
},
],
});
```
Expand All @@ -88,6 +109,12 @@ export default defineStack({
be omitted) for a count. A SQL expression there is refused at parse: a
conditional count or sum is a measure with its own `filter`, and a ratio is a
`derived` measure.
- **Give every member its vocabulary.** `synonyms` are the words a person
types, in their own language (a flat list, matched and never translated; one
word names one member), and `description` is a one-sentence business
definition. A measure or dimension with neither answers only to its own name
and label, so a question asked in a user's own words misses the governed
metric; validation and publish warn with `dataset-member-no-vocabulary`.
- **Metric certification** — a `certified` flag that marks a measure as a
human-blessed governance checkpoint — is a design goal of ADR-0021 but is **not
yet implemented**; `DatasetMeasureSchema` has no `certified` field today.
Expand Down
2 changes: 1 addition & 1 deletion content/docs/deployment/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ os compile --json # JSON output for CI pipelines
→ Normalizing stack definition...
→ Lowering inline handlers...
→ Validating protocol compliance...
→ Running author-time rules (69)...
→ Running author-time rules (70)...
→ Checking that every required capability has a provider installable in this edition...
→ Collecting package docs (ADR-0046)... 0 collected
→ Writing artifact...
Expand Down
2 changes: 1 addition & 1 deletion content/docs/deployment/validating-metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ A clean run walks the registry and reports timing:
Config: /path/to/support-desk/objectstack.config.ts
Load time: 21ms
→ Validating against ObjectStack Protocol...
→ Running author-time rules (69)...
→ Running author-time rules (70)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...

Expand Down
2 changes: 1 addition & 1 deletion content/docs/getting-started/build-with-claude-code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ visible: 'status != "resolved"'
◆ Validate
────────────────────────────────────────
→ Validating against ObjectStack Protocol...
→ Running author-time rules (69)...
→ Running author-time rules (70)...

✗ Author-time rules failed (1 issue)
• stack · action 'resolve_ticket' visible: bare reference `status` — a
Expand Down
36 changes: 26 additions & 10 deletions content/docs/ui/dashboards.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,19 @@ export const salesDataset = defineDataset({
object: 'opportunity',
include: ['account'],
dimensions: [
{ name: 'region', field: 'account.region', type: 'string' },
{ name: 'close_month', field: 'close_date', type: 'date', dateGranularity: 'month' },
{ name: 'region', field: 'account.region', type: 'string', synonyms: ['territory', 'area'] },
{
name: 'close_month', field: 'close_date', type: 'date', dateGranularity: 'month',
synonyms: ['closing month', 'month closed'],
},
],
measures: [
{ name: 'revenue', field: 'amount', aggregate: 'sum' },
{ name: 'deal_count', aggregate: 'count' },
{
name: 'revenue', field: 'amount', aggregate: 'sum',
synonyms: ['sales', 'pipeline value'],
description: 'The total amount of every opportunity, open or closed.',
},
{ name: 'deal_count', aggregate: 'count', synonyms: ['deals', 'number of deals'] },
],
});

Expand Down Expand Up @@ -696,14 +703,23 @@ export const projectTasksDataset = defineDataset({
label: 'Project Tasks',
object: 'project_task',
dimensions: [
{ name: 'status', field: 'status', type: 'string' },
{ name: 'priority', field: 'priority', type: 'string' },
{ name: 'completed_month', field: 'completed_at', type: 'date', dateGranularity: 'month' },
{ name: 'status', field: 'status', type: 'string', synonyms: ['state', 'progress'] },
{ name: 'priority', field: 'priority', type: 'string', synonyms: ['urgency', 'importance'] },
{
name: 'completed_month', field: 'completed_at', type: 'date', dateGranularity: 'month',
synonyms: ['month completed', 'finish month'],
},
],
measures: [
{ name: 'open_count', aggregate: 'count', filter: { status: { $ne: 'done' } } },
{ name: 'done_count', aggregate: 'count', filter: { status: 'done' } },
{ name: 'task_count', aggregate: 'count' },
{
name: 'open_count', aggregate: 'count', filter: { status: { $ne: 'done' } },
synonyms: ['open tasks', 'unfinished tasks'],
},
{
name: 'done_count', aggregate: 'count', filter: { status: 'done' },
synonyms: ['done tasks', 'completed tasks'],
},
{ name: 'task_count', aggregate: 'count', synonyms: ['tasks', 'number of tasks'] },
],
});
```
Expand Down
2 changes: 1 addition & 1 deletion content/docs/ui/react-pages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ objectstack validate
────────────────────────────────────────
→ Loading configuration...
→ Validating against ObjectStack Protocol...
→ Running author-time rules (69)...
→ Running author-time rules (70)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...

Expand Down
62 changes: 47 additions & 15 deletions examples/app-showcase/src/ui/datasets/chart-gallery.dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,51 @@ export const ShowcaseTaskDataset = defineDataset({
name: 'showcase_task_metrics',
label: 'Task Metrics',
object: 'showcase_task',
// Every member carries `synonyms` (ADR-0149 D1): the words a person types in
// a question, every language in the one list; matched, never translated.
dimensions: [
{ name: 'status', label: 'Status', field: 'status', type: 'string' },
{ name: 'priority', label: 'Priority', field: 'priority', type: 'string' },
{ name: 'progress', label: 'Progress', field: 'progress', type: 'number' },
{ name: 'created_at', label: 'Created', field: 'created_at', type: 'date', dateGranularity: 'month' },
{ name: 'status', label: 'Status', field: 'status', type: 'string', synonyms: ['task status', '任务状态'] },
{ name: 'priority', label: 'Priority', field: 'priority', type: 'string', synonyms: ['urgency', '优先级'] },
{
name: 'progress', label: 'Progress', field: 'progress', type: 'number',
synonyms: ['percent complete', 'completion percentage', '进度'],
},
{
name: 'created_at', label: 'Created', field: 'created_at', type: 'date', dateGranularity: 'month',
synonyms: ['created date', 'creation month', '创建时间', '创建月份'],
},
],
measures: [
{ name: 'task_count', label: 'Tasks', aggregate: 'count' },
{ name: 'est_hours', label: 'Estimated Hours', aggregate: 'sum', field: 'estimate_hours', format: '0.0' },
{ name: 'avg_estimate', label: 'Avg Estimate', aggregate: 'avg', field: 'estimate_hours', format: '0.0' },
{ name: 'avg_progress', label: 'Avg Progress', aggregate: 'avg', field: 'progress', format: '0.0' },
{ name: 'task_count', label: 'Tasks', aggregate: 'count', synonyms: ['number of tasks', '任务数', '任务数量'] },
{
name: 'est_hours', label: 'Estimated Hours', aggregate: 'sum', field: 'estimate_hours', format: '0.0',
synonyms: ['planned hours', 'estimated effort', '预估工时'],
},
{
name: 'avg_estimate', label: 'Avg Estimate', aggregate: 'avg', field: 'estimate_hours', format: '0.0',
synonyms: ['average estimate', 'average estimated hours', '平均预估工时'],
},
{
name: 'avg_progress', label: 'Avg Progress', aggregate: 'avg', field: 'progress', format: '0.0',
synonyms: ['average progress', 'average completion', '平均进度'],
},
// The done rate, moved here from the `showcase_delivery` cube (#20943): a
// cube member's `sql` is a column reference, and this is the declared
// form of what its CASE expression computed — a count scoped by its own
// structured filter, over the unfiltered count. `ratio` yields a 0–1
// fraction (the cube's expression multiplied by 100), which the `%`
// pattern displays as a percentage; the server annotates the column's
// scale from the operator, as it does for `paid_rate`.
{ name: 'done_count', label: 'Done Tasks', aggregate: 'count', filter: { status: 'done' } },
{
name: 'done_count', label: 'Done Tasks', aggregate: 'count', filter: { status: 'done' },
synonyms: ['completed tasks', 'finished tasks', '已完成任务数'],
},
{
name: 'done_rate',
label: 'Done Rate',
derived: { op: 'ratio', of: ['done_count', 'task_count'] },
format: '0.0%',
synonyms: ['completion rate', 'percent done', '完成率'],
},
],
});
Expand All @@ -46,15 +67,20 @@ export const ShowcaseProjectDataset = defineDataset({
name: 'showcase_project_metrics',
label: 'Project Metrics',
object: 'showcase_project',
// Every member carries `synonyms` (ADR-0149 D1): the words a person types in
// a question, every language in the one list; matched, never translated.
dimensions: [
{ name: 'account', label: 'Account', field: 'account', type: 'lookup' },
{ name: 'account', label: 'Account', field: 'account', type: 'lookup', synonyms: ['customer', 'client', '客户'] },
// status / health added for the Operations dashboard — power the
// "by health" chart and the filtered KPI tiles (active / at-risk).
{ name: 'status', label: 'Status', field: 'status', type: 'string' },
{ name: 'health', label: 'Health', field: 'health', type: 'string' },
{ name: 'status', label: 'Status', field: 'status', type: 'string', synonyms: ['project status', '项目状态'] },
{ name: 'health', label: 'Health', field: 'health', type: 'string', synonyms: ['project health', '项目健康度'] },
],
measures: [
{ name: 'project_count', label: 'Projects', aggregate: 'count' },
{
name: 'project_count', label: 'Projects', aggregate: 'count',
synonyms: ['number of projects', '项目数', '项目数量'],
},
// `budget`/`spent` are currency fields with a FIXED currency
// (`currencyConfig: { currencyMode: 'fixed', defaultCurrency: 'USD' }`).
// The column's currency resolves through the measure's own `currency` →
Expand All @@ -65,7 +91,13 @@ export const ShowcaseProjectDataset = defineDataset({
// an amount, with two decimals. The Command Center's `cc_k6` tile, which
// aggregates `budget` without this dataset, declares the same pattern and
// currency, so both dashboards read one total budget alike.
{ name: 'budget_sum', label: 'Total Budget', aggregate: 'sum', field: 'budget', format: '0,0.00' },
{ name: 'spent_sum', label: 'Total Spent', aggregate: 'sum', field: 'spent', format: '0,0.00' },
{
name: 'budget_sum', label: 'Total Budget', aggregate: 'sum', field: 'budget', format: '0,0.00',
synonyms: ['budget', 'planned budget', '预算', '总预算'],
},
{
name: 'spent_sum', label: 'Total Spent', aggregate: 'sum', field: 'spent', format: '0,0.00',
synonyms: ['spend', 'actual spend', '支出', '已花费'],
},
],
});
Loading
Loading