create-contextkit 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -122,7 +122,93 @@ When you discover data quality issues (null values, broken joins, missing data),
|
|
|
122
122
|
|
|
123
123
|
**Bronze (7):** descriptions, owner, security, grain, table_type
|
|
124
124
|
**Silver (+6):** trust, 2+ tags, glossary linked, lineage, refresh, 2+ sample_values
|
|
125
|
-
**Gold (+
|
|
125
|
+
**Gold (+24):** semantic_role on ALL fields, metric aggregation/additive, 1+ guardrail, 3+ golden queries, 1+ business rule, 1+ hierarchy, 1+ default_filter, trust=endorsed, contactable owner, 1+ relationship, description >=50 chars, ai_context (no TODO), 1+ business_context, version, field descriptions not lazy, glossary definitions substantive, lineage references real sources, grain statements specific, ai_context filled in, 3+ relationships (models with 3+ datasets), 1+ computed metric, 3+ glossary terms (models with 5+ datasets)
|
|
126
|
+
|
|
127
|
+
## How to Reach Gold: Curation Recipes
|
|
128
|
+
|
|
129
|
+
### Metrics (gold/metrics-defined)
|
|
130
|
+
|
|
131
|
+
Inspect computed views in the database. Any calculated column is a candidate metric.
|
|
132
|
+
|
|
133
|
+
```sql
|
|
134
|
+
-- Find computed columns in views
|
|
135
|
+
SELECT column_name, data_type
|
|
136
|
+
FROM information_schema.columns
|
|
137
|
+
WHERE table_name LIKE 'vw_%' AND data_type IN ('DOUBLE', 'FLOAT', 'INTEGER', 'BIGINT', 'DECIMAL');
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
For each computed column (e.g., `opportunity_score`, `shops_per_10k`, `demand_signal_pct`):
|
|
141
|
+
1. Query it to understand what it measures
|
|
142
|
+
2. Add it to the model's `metrics[]` array in the OSI YAML
|
|
143
|
+
3. Include the SQL expression, aggregation type (SUM/AVG), and a human description
|
|
144
|
+
4. Mark whether it's additive (can be summed across dimensions)
|
|
145
|
+
|
|
146
|
+
Example:
|
|
147
|
+
```yaml
|
|
148
|
+
metrics:
|
|
149
|
+
- name: opportunity_score
|
|
150
|
+
expression:
|
|
151
|
+
dialects:
|
|
152
|
+
- dialect: DuckDB
|
|
153
|
+
expression: "(population/10000)*2 + (income/50000)*2 + (10-shops_per_10k)*3 + transit*1.5 + demand*0.5"
|
|
154
|
+
description: Composite score ranking census tracts for coffee shop viability
|
|
155
|
+
aggregation: AVG
|
|
156
|
+
additive: false
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Glossary Terms (gold/glossary-coverage)
|
|
160
|
+
|
|
161
|
+
For each key business concept your model measures, create a glossary term file.
|
|
162
|
+
|
|
163
|
+
Think about the terms a new analyst would need defined:
|
|
164
|
+
- What is "supply saturation"? (> 5.0 shops per 10k people)
|
|
165
|
+
- What is a "demand signal"? (review mentioning wait/line/crowded/busy)
|
|
166
|
+
- What is "opportunity score"? (composite ranking formula)
|
|
167
|
+
|
|
168
|
+
For each term, create `context/glossary/<term-name>.term.yaml`:
|
|
169
|
+
```yaml
|
|
170
|
+
term: supply-saturation
|
|
171
|
+
definition: >
|
|
172
|
+
A measure of coffee shop density per census tract. Calculated as
|
|
173
|
+
shops per 10,000 residents. Tracts with > 5.0 are considered saturated.
|
|
174
|
+
owner: analytics-team
|
|
175
|
+
tags: [coffee-analytics]
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Models with 5+ datasets need at least 3 glossary terms linked by shared tags or owner.
|
|
179
|
+
|
|
180
|
+
### Relationships (gold/relationships-coverage)
|
|
181
|
+
|
|
182
|
+
For each join in the SQL views, define a relationship in the OSI model.
|
|
183
|
+
|
|
184
|
+
```sql
|
|
185
|
+
-- Find joins by examining view definitions
|
|
186
|
+
-- Look for patterns: ON table_a.col = table_b.col
|
|
187
|
+
-- Or spatial joins: ABS(a.lat - b.lat) < threshold
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
For each join:
|
|
191
|
+
```yaml
|
|
192
|
+
relationships:
|
|
193
|
+
- name: business-to-tract
|
|
194
|
+
left_dataset: yelp_business
|
|
195
|
+
right_dataset: census_tract
|
|
196
|
+
join_type: spatial
|
|
197
|
+
cardinality: many-to-one
|
|
198
|
+
description: Businesses assigned to nearest census tract within 0.02 degrees (~1 mile)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Models with 3+ datasets need at least 3 relationships.
|
|
202
|
+
|
|
203
|
+
### Golden Queries
|
|
204
|
+
|
|
205
|
+
Write 3-5 SQL queries answering common business questions. **Test each query first!**
|
|
206
|
+
|
|
207
|
+
```sql
|
|
208
|
+
-- Run the query, verify it returns sensible results, then document:
|
|
209
|
+
SELECT geoid, tract_name, opportunity_score
|
|
210
|
+
FROM vw_candidate_zones ORDER BY opportunity_score DESC LIMIT 10;
|
|
211
|
+
```
|
|
126
212
|
|
|
127
213
|
## YAML Formats
|
|
128
214
|
|