dosi-semantic-authoring
GitHub指导使用Dosi原生OSI数据集、关系、指标和结构化窗口的YAML语义建模规范。涵盖模型复用语义、键值声明、关系定义及DATUS扩展配置,确保语义模型的准确性和可验证性。
Trigger Scenarios
Install
npx skills add Datus-ai/Datus-agent --skill dosi-semantic-authoring -g -y
SKILL.md
Frontmatter
{
"name": "dosi-semantic-authoring",
"tags": [
"semantic-model",
"metrics",
"osi",
"dosi"
],
"version": "1.0.0",
"description": "Dosi native OSI dataset, relationship, metric, and structured-window authoring contract",
"allowed_agents": [
"semantic_modeling",
"gen_semantic_model",
"gen_metrics"
],
"user_invocable": false,
"disable_model_invocation": false
}
Dosi Semantic Authoring
Author the active Dosi semantic model as strict OSI core YAML. Use this skill for native document authoring rules; use the active adapter specification and native validation as the exact document and DATUS-extension contract. The node prompt owns target selection, result-set strategy, mutation order, validation, and synchronization.
Model reusable semantics
- Keep one
semantic_modelper file and stablesnake_casenames. Preserve unrelated content; an upsert replaces the complete same-named object. - Bind a dataset to a qualified physical table or a complete reusable SELECT. Declare every referenced physical column as a field with the active OSI dialect.
- Mark time fields with
dimension: {is_time: true}. Keep other fields available as dimensions. - For a dataset bound to a physical table, use
primary_keyto transcribe a source-declared physical primary key, andunique_keysto transcribe source-declared unique constraints and indexes. For a query-backed dataset, a source key holds only if the query preserves it: a one-to-many join repeats it, so validate against the result, not the base table. Declare a key the source does not declare only after full-table validation shows those columns are non-null and duplicate-free; a stated grain, a query pattern, or one partition is not evidence. - Give a field a
labelwhen its column name is not what a reader would call it. - Give a dataset
ai_context.instructionswhen its grain or intended use does not follow from the description, and give a fieldai_context.synonymswhen users ask for it by a name the column does not carry. Leave both out otherwise: restating the description dilutes what a reader can act on. - Define model-level relationships with aligned
from_columnsandto_columns; bind the target columns to one complete verified key.
Author DATUS extensions
Put each Dosi-only key in the owning object's custom_extensions entry. Encode data as one JSON-object string and stamp it with the runtime <datus_extension_version>.
| Carrier | Supported keys |
|---|---|
| Dataset | time_dimension |
| Time field | time_granularity |
| Relationship | join_type |
| Metric | dataset, time_dimension, fill_nulls_with, window, subject_path, unit, format |
- Use
time_dimensionto resolve the business time when inference is ambiguous; qualify metric-level references when field names collide. - Use
time_granularityfor the field's stored grain andjoin_typeforleftorinnerrelationship behavior. - Use metric
datasetto attribute an otherwise unbound aggregate such asCOUNT(*). - Give each business metric a description,
ai_context.instructions, and a three-levelsubject_path.
- name: revenue
description: Total order revenue
ai_context: {instructions: Use order_date as business time.}
expression: {dialects: [{dialect: <osi_dialect>, expression: SUM(orders.amount)}]}
custom_extensions:
- vendor_name: DATUS
data: '{"v":"<datus_extension_version>","time_dimension":"orders.order_date","subject_path":["sales","revenue","total"],"unit":"USD"}'
Author metrics and windows
- Express a base metric with its natural aggregate, ratio, or arithmetic expression. Put a durable metric condition inside its aggregate with
CASE WHEN. - Express each window result as a standalone metric whose OSI expression is one plain aggregate. Put the derivation in one structured
windowobject. - Choose the window form from the intended calculation:
| Intent | Form |
|---|---|
| Period comparison or following-period value | pop or general offset |
| Trailing buckets | rolling |
| Running or period-to-date value | cumulative |
| Explicit aggregate/statistical frame | general frame |
| Ranking or distribution | rank |
| First, last, or nth value | value |
- Derive time, query grain, ordering, partition, and frame from the requested analytic meaning. Treat query grain as a runtime argument.
- Use
order.byvaluestimeorvalue. Use partition modesquery_dimensions,query_dimensions_except,time_bucket, ornone; qualify excluded fields. - Supply
bucketsforntile,nfornth_value, and a second plain aggregate metric for covariance or correlation. - Reuse a window metric only when its base aggregate, time axis, calculation, ordering, partition, and frame all match.
- Preserve meaningful window nulls for missing comparison buckets or incomplete required frames.
Validate the final model with the native Dosi parser/compiler after the last mutation.
Version History
-
71384a0
Current 2026-08-29 00:05
补充了ai_context、label、primary_key/unique_keys的使用条件;明确datatype字段不被支持;细化了键值转录与推断的区别及验证要求。
- 8fb79f6 2026-08-20 12:33


