@runcontext/core 0.1.1 → 0.2.1
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/LICENSE +21 -0
- package/dist/index.cjs +1702 -887
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2581 -730
- package/dist/index.d.ts +2581 -730
- package/dist/index.mjs +1723 -908
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -8
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/erickittelson/Desktop/ContextKit/packages/core/dist/index.cjs","../src/schema/concept.ts","../src/schema/product.ts","../src/schema/policy.ts","../src/schema/entity.ts","../src/schema/term.ts","../src/schema/owner.ts","../src/config/defaults.ts","../src/config/loader.ts","../src/parser/discover.ts","../src/parser/parse.ts","../src/graph/builder.ts","../src/compiler/validate.ts","../src/compiler/normalize.ts","../src/compiler/pipeline.ts","../src/compiler/emit.ts","../src/linter/engine.ts","../src/linter/rules/schema-valid-yaml.ts","../src/linter/rules/naming-id-kebab-case.ts","../src/linter/rules/ownership-required.ts","../src/linter/rules/descriptions-required.ts","../src/linter/rules/references-resolvable.ts","../src/linter/rules/glossary-no-duplicate-terms.ts","../src/linter/rules/concepts-certified-requires-evidence.ts","../src/linter/rules/policies-unknown-subject.ts","../src/linter/rules/policies-deny-overrides-allow.ts","../src/linter/rules/docs-examples-required.ts","../src/linter/rules/deprecation-require-sunset.ts","../src/linter/rules/packaging-no-secrets.ts","../src/linter/rules/index.ts","../src/fixer/apply.ts"],"names":["z","readFileSync","parseYaml","toKebabCase"],"mappings":"AAAA;ACAA,0BAAkB;AAEX,IAAM,eAAA,EAAiB,MAAA,CAAE,MAAA,CAAO,EAAE,IAAA,EAAM,MAAA,CAAE,MAAA,CAAO,CAAA,EAAG,GAAA,EAAK,MAAA,CAAE,MAAA,CAAO,EAAE,CAAC,CAAA;AACrE,IAAM,cAAA,EAAgB,MAAA,CAAE,MAAA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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erickittelson/Desktop/ContextKit/packages/core/dist/index.cjs","sourcesContent":[null,"import { z } from 'zod';\n\nexport const evidenceSchema = z.object({ type: z.string(), ref: z.string() });\nexport const exampleSchema = z.object({ label: z.string(), content: z.string(), kind: z.enum(['do', 'dont']) });\n\nexport const conceptFileSchema = z.object({\n id: z.string(),\n name: z.string().optional(),\n domain: z.string().optional(),\n product_id: z.string().optional(),\n definition: z.string(),\n owner: z.string().optional(),\n status: z.enum(['draft', 'certified', 'deprecated']).optional(),\n certified: z.boolean().optional(),\n tags: z.array(z.string()).optional(),\n evidence: z.array(evidenceSchema).optional(),\n depends_on: z.array(z.string()).optional(),\n examples: z.array(exampleSchema).optional(),\n description: z.string().optional(),\n});\n","import { z } from 'zod';\n\nexport const productFileSchema = z.object({\n id: z.string(),\n name: z.string().optional(),\n description: z.string(),\n owner: z.string().optional(),\n tags: z.array(z.string()).optional(),\n status: z.enum(['draft', 'certified', 'deprecated']).optional(),\n});\n","import { z } from 'zod';\n\nexport const policyWhenSchema = z.object({\n tags_any: z.array(z.string()).optional(),\n concept_ids: z.array(z.string()).optional(),\n status: z.enum(['draft', 'certified', 'deprecated']).optional(),\n}).passthrough();\n\nexport const policyThenSchema = z.object({\n require_role: z.string().optional(),\n deny: z.boolean().optional(),\n warn: z.string().optional(),\n}).passthrough();\n\nexport const policyRuleSchema = z.object({\n priority: z.number(),\n when: policyWhenSchema,\n then: policyThenSchema,\n});\n\nexport const policyFileSchema = z.object({\n id: z.string(),\n name: z.string().optional(),\n description: z.string(),\n owner: z.string().optional(),\n tags: z.array(z.string()).optional(),\n status: z.enum(['draft', 'certified', 'deprecated']).optional(),\n rules: z.array(policyRuleSchema),\n});\n","import { z } from 'zod';\n\nexport const entityFieldSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n type: z.string().optional(),\n});\n\nexport const entityFileSchema = z.object({\n id: z.string(),\n name: z.string().optional(),\n definition: z.string().optional(),\n description: z.string().optional(),\n owner: z.string().optional(),\n tags: z.array(z.string()).optional(),\n status: z.enum(['draft', 'certified', 'deprecated']).optional(),\n fields: z.array(entityFieldSchema).optional(),\n});\n","import { z } from 'zod';\n\nexport const termFileSchema = z.object({\n id: z.string(),\n term: z.string().optional(),\n definition: z.string(),\n synonyms: z.array(z.string()).optional(),\n maps_to: z.array(z.string()).optional(),\n owner: z.string().optional(),\n tags: z.array(z.string()).optional(),\n});\n","import { z } from 'zod';\n\nexport const ownerFileSchema = z.object({\n id: z.string(),\n display_name: z.string(),\n email: z.string().optional(),\n team: z.string().optional(),\n tags: z.array(z.string()).optional(),\n});\n","import type { ContextKitConfig } from '../types/index.js';\n\nexport const DEFAULT_CONFIG: ContextKitConfig = {\n project: { id: 'my-context', displayName: 'My Context', version: '0.1.0' },\n paths: {\n rootDir: '.',\n contextDir: './context',\n distDir: './dist',\n cacheDir: './.contextkit-cache',\n },\n site: { enabled: true, title: 'Context Site', basePath: '/' },\n lint: { defaultSeverity: 'warning', rules: {} },\n mcp: {\n enabled: true,\n transport: ['stdio'],\n http: { port: 7331, host: '127.0.0.1' },\n },\n plugins: [],\n};\n","import { readFileSync, existsSync } from 'node:fs';\nimport { resolve, join } from 'node:path';\nimport { parse as parseYaml } from 'yaml';\nimport type { ContextKitConfig } from '../types/index.js';\nimport { DEFAULT_CONFIG } from './defaults.js';\n\n/**\n * Deep-merge a partial config with another object (typically defaults).\n * Arrays are replaced, not merged. Nested objects are recursively merged.\n */\nfunction deepMerge<T extends Record<string, unknown>>(\n base: T,\n override: Record<string, unknown>,\n): T {\n const result = { ...base } as Record<string, unknown>;\n\n for (const key of Object.keys(override)) {\n const baseVal = result[key];\n const overrideVal = override[key];\n\n if (\n overrideVal !== null &&\n typeof overrideVal === 'object' &&\n !Array.isArray(overrideVal) &&\n baseVal !== null &&\n typeof baseVal === 'object' &&\n !Array.isArray(baseVal)\n ) {\n result[key] = deepMerge(\n baseVal as Record<string, unknown>,\n overrideVal as Record<string, unknown>,\n );\n } else {\n result[key] = overrideVal;\n }\n }\n\n return result as T;\n}\n\n/**\n * Merge a partial user config with the defaults, returning a complete config.\n * Nested objects are deep-merged; arrays and primitives are overwritten.\n */\nexport function resolveConfig(\n partial: Partial<ContextKitConfig>,\n): ContextKitConfig {\n return deepMerge(\n DEFAULT_CONFIG as unknown as Record<string, unknown>,\n partial as unknown as Record<string, unknown>,\n ) as unknown as ContextKitConfig;\n}\n\n/** Config file names tried in order of priority. */\nconst CONFIG_FILENAMES = [\n 'contextkit.config.ts',\n 'contextkit.config.js',\n 'contextkit.config.yaml',\n 'contextkit.config.yml',\n] as const;\n\n/**\n * Load a ContextKit config from the given root directory.\n *\n * Searches for config files in this order:\n * 1. contextkit.config.ts\n * 2. contextkit.config.js\n * 3. contextkit.config.yaml\n * 4. contextkit.config.yml\n *\n * Falls back to DEFAULT_CONFIG if no config file is found.\n */\nexport async function loadConfig(\n rootDir: string = '.',\n): Promise<ContextKitConfig> {\n const absRoot = resolve(rootDir);\n\n for (const filename of CONFIG_FILENAMES) {\n const filepath = join(absRoot, filename);\n\n if (!existsSync(filepath)) {\n continue;\n }\n\n if (filename.endsWith('.yaml') || filename.endsWith('.yml')) {\n const raw = readFileSync(filepath, 'utf-8');\n const parsed = parseYaml(raw) as Partial<ContextKitConfig>;\n return resolveConfig(parsed ?? {});\n }\n\n // TS / JS config — use dynamic import\n if (filename.endsWith('.ts') || filename.endsWith('.js')) {\n const mod = (await import(filepath)) as {\n default?: Partial<ContextKitConfig>;\n };\n const partial = mod.default ?? (mod as unknown as Partial<ContextKitConfig>);\n return resolveConfig(partial);\n }\n }\n\n // No config file found — return defaults\n return { ...DEFAULT_CONFIG };\n}\n","import { glob } from 'glob';\n\nconst CONTEXT_PATTERNS = [\n '**/*.ctx.yaml', '**/*.ctx.yml',\n '**/*.policy.yaml', '**/*.policy.yml',\n '**/*.owner.yaml', '**/*.owner.yml',\n '**/*.term.yaml', '**/*.term.yml',\n '**/*.entity.yaml', '**/*.entity.yml',\n];\n\nexport async function discoverFiles(contextDir: string): Promise<string[]> {\n const files = await glob(CONTEXT_PATTERNS, { cwd: contextDir, absolute: true, nodir: true });\n return files.sort();\n}\n","import { readFileSync } from 'node:fs';\nimport { parse as parseYaml } from 'yaml';\nimport { basename } from 'node:path';\n\nexport type FileType = 'concept' | 'product' | 'entity' | 'policy' | 'term' | 'owner';\n\nexport interface ParsedFile {\n filePath: string;\n fileType: FileType;\n data: Record<string, unknown>;\n}\n\nfunction inferFileType(filePath: string): FileType {\n const name = basename(filePath);\n if (name.endsWith('.policy.yaml') || name.endsWith('.policy.yml')) return 'policy';\n if (name.endsWith('.owner.yaml') || name.endsWith('.owner.yml')) return 'owner';\n if (name.endsWith('.term.yaml') || name.endsWith('.term.yml')) return 'term';\n if (name.endsWith('.entity.yaml') || name.endsWith('.entity.yml')) return 'entity';\n // For .ctx.yaml, infer from directory\n if (filePath.includes('/products/')) return 'product';\n if (filePath.includes('/entities/')) return 'entity';\n if (filePath.includes('/glossary/')) return 'term';\n return 'concept'; // default\n}\n\nexport async function parseFile(filePath: string): Promise<ParsedFile> {\n const content = readFileSync(filePath, 'utf-8');\n const data = parseYaml(content);\n if (typeof data !== 'object' || data === null) {\n throw new Error(`Invalid YAML in ${filePath}: expected an object`);\n }\n return { filePath, fileType: inferFileType(filePath), data: data as Record<string, unknown> };\n}\n","import type {\n ContextGraph,\n ContextNode,\n Edge,\n NodeKind,\n Concept,\n Term,\n} from '../types/index.js';\n\n/**\n * Create an empty ContextGraph with initialized (but empty) collections.\n */\nexport function createEmptyGraph(): ContextGraph {\n return {\n nodes: new Map<string, ContextNode>(),\n edges: [],\n indexes: {\n byKind: new Map<NodeKind, string[]>(),\n byOwner: new Map<string, string[]>(),\n byTag: new Map<string, string[]>(),\n byStatus: new Map<string, string[]>(),\n dependents: new Map<string, string[]>(),\n },\n };\n}\n\n/**\n * Build a full ContextGraph from an array of ContextNodes.\n *\n * Populates:\n * - nodes Map (keyed by id)\n * - indexes: byKind, byOwner, byTag, byStatus, dependents\n * - edges: depends_on, belongs_to, owned_by, maps_to\n */\nexport function buildGraph(nodes: ContextNode[]): ContextGraph {\n const graph = createEmptyGraph();\n\n // ---- 1. Add all nodes to the Map ----\n for (const node of nodes) {\n graph.nodes.set(node.id, node);\n }\n\n // ---- 2. Build indexes ----\n for (const node of nodes) {\n // byKind\n appendIndex(graph.indexes.byKind, node.kind, node.id);\n\n // byOwner\n if (node.owner) {\n appendIndex(graph.indexes.byOwner, node.owner, node.id);\n }\n\n // byTag\n if (node.tags) {\n for (const tag of node.tags) {\n appendIndex(graph.indexes.byTag, tag, node.id);\n }\n }\n\n // byStatus\n if (node.status) {\n appendIndex(graph.indexes.byStatus, node.status, node.id);\n }\n }\n\n // ---- 3. Create edges ----\n for (const node of nodes) {\n // owned_by edges\n if (node.owner) {\n graph.edges.push({ from: node.id, to: node.owner, type: 'owned_by' });\n }\n\n if (node.kind === 'concept') {\n const concept = node as Concept;\n\n // depends_on edges + populate dependents index\n if (concept.dependsOn) {\n for (const dep of concept.dependsOn) {\n graph.edges.push({ from: concept.id, to: dep, type: 'depends_on' });\n appendIndex(graph.indexes.dependents, dep, concept.id);\n }\n }\n\n // belongs_to edge (concept → product)\n if (concept.productId) {\n graph.edges.push({ from: concept.id, to: concept.productId, type: 'belongs_to' });\n }\n }\n\n if (node.kind === 'term') {\n const term = node as Term;\n\n // maps_to edges\n if (term.mapsTo) {\n for (const target of term.mapsTo) {\n graph.edges.push({ from: term.id, to: target, type: 'maps_to' });\n }\n }\n }\n }\n\n return graph;\n}\n\n// ---- Helpers ----\n\nfunction appendIndex<K>(map: Map<K, string[]>, key: K, value: string): void {\n const existing = map.get(key);\n if (existing) {\n existing.push(value);\n } else {\n map.set(key, [value]);\n }\n}\n","import type { ContextNode, Diagnostic, PolicyRule } from '../types/index.js';\nimport type { ParsedFile } from '../parser/index.js';\nimport {\n conceptFileSchema,\n productFileSchema,\n policyFileSchema,\n entityFileSchema,\n termFileSchema,\n ownerFileSchema,\n} from '../schema/index.js';\n\nexport interface ValidateResult {\n node?: ContextNode;\n diagnostics: Diagnostic[];\n}\n\n/**\n * Map from YAML file types to the corresponding Zod schemas.\n */\nconst SCHEMAS = {\n concept: conceptFileSchema,\n product: productFileSchema,\n policy: policyFileSchema,\n entity: entityFileSchema,\n term: termFileSchema,\n owner: ownerFileSchema,\n} as const;\n\n/**\n * Validate a ParsedFile using the appropriate Zod schema and convert\n * the raw snake_case YAML data into a typed camelCase ContextNode.\n */\nexport function validateFile(parsed: ParsedFile): ValidateResult {\n const schema = SCHEMAS[parsed.fileType];\n const result = schema.safeParse(parsed.data);\n\n if (!result.success) {\n const diagnostics: Diagnostic[] = result.error.issues.map((issue) => ({\n ruleId: 'schema/invalid',\n severity: 'error' as const,\n message: `${issue.path.join('.')}: ${issue.message}`,\n source: { file: parsed.filePath, line: 1, col: 1 },\n fixable: false,\n }));\n return { diagnostics };\n }\n\n const data = result.data;\n const source = { file: parsed.filePath, line: 1, col: 1 };\n\n let node: ContextNode;\n\n switch (parsed.fileType) {\n case 'concept': {\n const d = data as typeof conceptFileSchema._output;\n node = {\n id: d.id,\n kind: 'concept',\n source,\n definition: d.definition,\n owner: d.owner,\n tags: d.tags,\n status: d.status,\n certified: d.certified,\n productId: d.product_id,\n dependsOn: d.depends_on,\n evidence: d.evidence,\n examples: d.examples,\n description: d.description,\n };\n break;\n }\n case 'product': {\n const d = data as typeof productFileSchema._output;\n node = {\n id: d.id,\n kind: 'product',\n source,\n description: d.description,\n owner: d.owner,\n tags: d.tags,\n status: d.status,\n };\n break;\n }\n case 'policy': {\n const d = data as typeof policyFileSchema._output;\n node = {\n id: d.id,\n kind: 'policy',\n source,\n description: d.description,\n owner: d.owner,\n tags: d.tags,\n status: d.status,\n rules: d.rules.map((r): PolicyRule => ({\n priority: r.priority,\n when: {\n tagsAny: r.when.tags_any,\n conceptIds: r.when.concept_ids,\n status: r.when.status,\n },\n then: {\n requireRole: r.then.require_role,\n deny: r.then.deny,\n warn: r.then.warn,\n },\n })),\n };\n break;\n }\n case 'entity': {\n const d = data as typeof entityFileSchema._output;\n node = {\n id: d.id,\n kind: 'entity',\n source,\n definition: d.definition,\n owner: d.owner,\n tags: d.tags,\n status: d.status,\n fields: d.fields,\n description: d.description,\n };\n break;\n }\n case 'term': {\n const d = data as typeof termFileSchema._output;\n node = {\n id: d.id,\n kind: 'term',\n source,\n definition: d.definition,\n owner: d.owner,\n tags: d.tags,\n synonyms: d.synonyms,\n mapsTo: d.maps_to,\n };\n break;\n }\n case 'owner': {\n const d = data as typeof ownerFileSchema._output;\n node = {\n id: d.id,\n kind: 'owner',\n source,\n displayName: d.display_name,\n email: d.email,\n team: d.team,\n tags: d.tags,\n };\n break;\n }\n }\n\n return { node, diagnostics: [] };\n}\n","import type { ContextNode } from '../types/index.js';\n\n/**\n * Convert a string to kebab-case.\n * Handles camelCase, PascalCase, snake_case, spaces, and mixed inputs.\n */\nfunction toKebabCase(input: string): string {\n return input\n // Insert hyphen before uppercase letters that follow lowercase letters\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n // Replace underscores and spaces with hyphens\n .replace(/[_\\s]+/g, '-')\n // Collapse multiple hyphens\n .replace(/-+/g, '-')\n .toLowerCase();\n}\n\n/**\n * Normalize a ContextNode:\n * - Convert ID to kebab-case\n * - Lowercase all tags\n */\nexport function normalizeNode(node: ContextNode): ContextNode {\n const normalized = { ...node, id: toKebabCase(node.id) };\n\n if (normalized.tags) {\n normalized.tags = normalized.tags.map((t) => t.toLowerCase());\n }\n\n return normalized as ContextNode;\n}\n","import type { ContextGraph, ContextKitConfig, ContextNode, Diagnostic } from '../types/index.js';\nimport { discoverFiles, parseFile } from '../parser/index.js';\nimport { validateFile } from './validate.js';\nimport { normalizeNode } from './normalize.js';\nimport { buildGraph } from '../graph/index.js';\n\nexport interface CompileOptions {\n contextDir: string;\n config: Partial<ContextKitConfig>;\n}\n\nexport interface CompileResult {\n graph: ContextGraph;\n diagnostics: Diagnostic[];\n}\n\n/**\n * Run the full compiler pipeline:\n * 1. Discover context files\n * 2. Parse each YAML file\n * 3. Validate (Zod schema) -> typed ContextNode\n * 4. Normalize (kebab-case IDs, lowercase tags)\n * 5. Build graph\n */\nexport async function compile(options: CompileOptions): Promise<CompileResult> {\n const diagnostics: Diagnostic[] = [];\n const nodes: ContextNode[] = [];\n\n // 1. Discover files\n const files = await discoverFiles(options.contextDir);\n\n // 2-4. Parse, validate, normalize each file\n for (const filePath of files) {\n // 2. Parse\n const parsed = await parseFile(filePath);\n\n // 3. Validate\n const { node, diagnostics: fileDiags } = validateFile(parsed);\n diagnostics.push(...fileDiags);\n\n if (!node) {\n continue;\n }\n\n // 4. Normalize\n const normalized = normalizeNode(node);\n nodes.push(normalized);\n }\n\n // 5. Build graph\n const graph = buildGraph(nodes);\n\n return { graph, diagnostics };\n}\n","import { execFileSync } from 'node:child_process';\nimport type {\n ContextGraph,\n ContextKitConfig,\n Manifest,\n ManifestConcept,\n ManifestProduct,\n ManifestPolicy,\n ManifestEntity,\n ManifestTerm,\n ManifestOwner,\n Concept,\n Product,\n Policy,\n Entity,\n Term,\n Owner,\n} from '../types/index.js';\n\n/**\n * Get the short git HEAD revision, or 'unknown' if not in a git repo.\n */\nfunction getGitRevision(): string {\n try {\n return execFileSync('git', ['rev-parse', '--short', 'HEAD'], {\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n } catch {\n return 'unknown';\n }\n}\n\n/**\n * Serialize a ContextGraph into the Manifest JSON format.\n */\nexport function emitManifest(graph: ContextGraph, config: ContextKitConfig): Manifest {\n const concepts: ManifestConcept[] = [];\n const products: ManifestProduct[] = [];\n const policies: ManifestPolicy[] = [];\n const entities: ManifestEntity[] = [];\n const terms: ManifestTerm[] = [];\n const owners: ManifestOwner[] = [];\n\n const byId: Record<string, { kind: string; index: number }> = {};\n\n for (const node of graph.nodes.values()) {\n switch (node.kind) {\n case 'concept': {\n const c = node as Concept;\n byId[c.id] = { kind: 'concept', index: concepts.length };\n concepts.push({\n id: c.id,\n definition: c.definition,\n productId: c.productId,\n certified: c.certified,\n owner: c.owner,\n tags: c.tags,\n dependsOn: c.dependsOn,\n });\n break;\n }\n case 'product': {\n const p = node as Product;\n byId[p.id] = { kind: 'product', index: products.length };\n products.push({\n id: p.id,\n description: p.description,\n owner: p.owner,\n tags: p.tags,\n });\n break;\n }\n case 'policy': {\n const p = node as Policy;\n byId[p.id] = { kind: 'policy', index: policies.length };\n policies.push({\n id: p.id,\n description: p.description,\n rules: p.rules,\n owner: p.owner,\n tags: p.tags,\n });\n break;\n }\n case 'entity': {\n const e = node as Entity;\n byId[e.id] = { kind: 'entity', index: entities.length };\n entities.push({\n id: e.id,\n definition: e.definition,\n fields: e.fields,\n owner: e.owner,\n tags: e.tags,\n });\n break;\n }\n case 'term': {\n const t = node as Term;\n byId[t.id] = { kind: 'term', index: terms.length };\n terms.push({\n id: t.id,\n definition: t.definition,\n synonyms: t.synonyms,\n mapsTo: t.mapsTo,\n owner: t.owner,\n tags: t.tags,\n });\n break;\n }\n case 'owner': {\n const o = node as Owner;\n byId[o.id] = { kind: 'owner', index: owners.length };\n owners.push({\n id: o.id,\n displayName: o.displayName,\n email: o.email,\n team: o.team,\n });\n break;\n }\n }\n }\n\n return {\n schemaVersion: '1.0.0',\n project: {\n id: config.project.id,\n displayName: config.project.displayName,\n version: config.project.version,\n },\n build: {\n timestamp: new Date().toISOString(),\n version: getGitRevision(),\n nodeCount: graph.nodes.size,\n },\n concepts,\n products,\n policies,\n entities,\n terms,\n owners,\n indexes: { byId },\n };\n}\n","import type { Severity, ContextGraph, Diagnostic } from '../types/index.js';\nimport type { LintRule } from './rule.js';\n\n/**\n * ESLint-inspired lint engine that runs registered rules against a ContextGraph.\n *\n * Supports severity overrides from config:\n * - `'off'` disables a rule entirely\n * - `'error'` / `'warning'` overrides the rule's default severity\n */\nexport class LintEngine {\n private rules: LintRule[] = [];\n private overrides: Record<string, Severity | 'off'>;\n\n constructor(overrides?: Record<string, Severity | 'off'>) {\n this.overrides = overrides ?? {};\n }\n\n /** Register a lint rule with the engine. */\n register(rule: LintRule): void {\n this.rules.push(rule);\n }\n\n /**\n * Run all enabled rules against the graph and return sorted diagnostics.\n *\n * Diagnostics are sorted by source file (ascending) then line (ascending).\n */\n run(graph: ContextGraph): Diagnostic[] {\n const allDiagnostics: Diagnostic[] = [];\n\n for (const rule of this.rules) {\n const override = this.overrides[rule.id];\n\n // Skip disabled rules\n if (override === 'off') {\n continue;\n }\n\n const diagnostics = rule.run(graph);\n\n // Apply severity override if present\n const severity = (override as Severity | undefined) ?? rule.defaultSeverity;\n for (const diag of diagnostics) {\n allDiagnostics.push({ ...diag, severity });\n }\n }\n\n // Sort by file ascending, then line ascending\n allDiagnostics.sort((a, b) => {\n const fileCmp = a.source.file.localeCompare(b.source.file);\n if (fileCmp !== 0) return fileCmp;\n return a.source.line - b.source.line;\n });\n\n return allDiagnostics;\n }\n}\n","import type { LintRule } from '../rule.js';\n\n/**\n * Placeholder rule for YAML schema validation.\n *\n * Schema validation diagnostics are produced during the compile phase\n * (Zod parsing). This rule exists so that users can see and configure\n * it in their lint config, but it never produces diagnostics itself.\n */\nexport const schemaValidYaml: LintRule = {\n id: 'schema/valid-yaml',\n defaultSeverity: 'error',\n fixable: false,\n description: 'Validates YAML against Zod schemas',\n\n run() {\n return [];\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nconst KEBAB_RE = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;\n\n/**\n * Convert an arbitrary string to kebab-case.\n *\n * Handles camelCase, PascalCase, snake_case, and mixed formats.\n */\nfunction toKebabCase(input: string): string {\n return input\n // Insert hyphen before uppercase letters that follow lowercase/digits\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n // Insert hyphen before uppercase runs followed by lowercase\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n // Replace underscores and spaces with hyphens\n .replace(/[_\\s]+/g, '-')\n // Collapse multiple hyphens\n .replace(/-+/g, '-')\n // Lowercase\n .toLowerCase()\n // Remove leading/trailing hyphens\n .replace(/^-+|-+$/g, '');\n}\n\n/**\n * IDs must be kebab-case.\n *\n * Checks every node's `id` against the pattern `/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/`.\n * Provides an auto-fix that converts the ID to kebab-case.\n */\nexport const namingIdKebabCase: LintRule = {\n id: 'naming/id-kebab-case',\n defaultSeverity: 'error',\n fixable: true,\n description: 'IDs must be kebab-case',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [, node] of graph.nodes) {\n if (!KEBAB_RE.test(node.id)) {\n const suggested = toKebabCase(node.id);\n diagnostics.push({\n ruleId: 'naming/id-kebab-case',\n severity: 'error',\n message: `ID \"${node.id}\" is not kebab-case`,\n source: node.source,\n fixable: true,\n fix: {\n description: `Rename to \"${suggested}\"`,\n edits: [\n {\n file: node.source.file,\n range: {\n startLine: node.source.line,\n startCol: node.source.col,\n endLine: node.source.line,\n endCol: node.source.col,\n },\n newText: suggested,\n },\n ],\n },\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic, NodeKind } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/** Node kinds that require an owner. */\nconst REQUIRES_OWNER: ReadonlySet<NodeKind> = new Set(['concept', 'product', 'entity']);\n\n/**\n * Concepts, products, and entities require an owner.\n *\n * Checks that nodes of the above kinds have a non-empty `owner` field.\n * Provides a stub fix that adds `owner: TODO`.\n */\nexport const ownershipRequired: LintRule = {\n id: 'ownership/required',\n defaultSeverity: 'error',\n fixable: true,\n description: 'Concepts, products, and entities require an owner',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [, node] of graph.nodes) {\n if (!REQUIRES_OWNER.has(node.kind)) continue;\n\n if (!node.owner) {\n diagnostics.push({\n ruleId: 'ownership/required',\n severity: 'error',\n message: `${node.kind} \"${node.id}\" is missing a required owner`,\n source: node.source,\n fixable: true,\n fix: {\n description: 'Add owner field',\n edits: [\n {\n file: node.source.file,\n range: {\n startLine: node.source.line,\n startCol: node.source.col,\n endLine: node.source.line,\n endCol: node.source.col,\n },\n newText: 'owner: TODO\\n',\n },\n ],\n },\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Check whether a node has a description or definition.\n *\n * Nodes that carry `definition` (concepts, terms, possibly entities)\n * satisfy the requirement through that field. All other nodes must\n * have a non-empty `description`.\n */\nfunction hasDescriptionOrDefinition(node: Record<string, unknown>): boolean {\n if (typeof node.description === 'string' && node.description.length > 0) {\n return true;\n }\n if (typeof node.definition === 'string' && node.definition.length > 0) {\n return true;\n }\n return false;\n}\n\n/**\n * All nodes should have a description or definition.\n *\n * Provides a stub fix that adds a description placeholder.\n */\nexport const descriptionsRequired: LintRule = {\n id: 'descriptions/required',\n defaultSeverity: 'warning',\n fixable: true,\n description: 'All nodes should have a description or definition',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [, node] of graph.nodes) {\n if (!hasDescriptionOrDefinition(node as unknown as Record<string, unknown>)) {\n diagnostics.push({\n ruleId: 'descriptions/required',\n severity: 'warning',\n message: `${node.kind} \"${node.id}\" is missing a description or definition`,\n source: node.source,\n fixable: true,\n fix: {\n description: 'Add description field',\n edits: [\n {\n file: node.source.file,\n range: {\n startLine: node.source.line,\n startCol: node.source.col,\n endLine: node.source.line,\n endCol: node.source.col,\n },\n newText: 'description: TODO\\n',\n },\n ],\n },\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic, Concept, Term } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Verify that all cross-node references resolve to existing nodes.\n *\n * Checks:\n * - Concept: `dependsOn`, `productId`, `owner`\n * - Term: `mapsTo`\n * - Product / Entity: `owner`\n * - Policy / Owner: no reference checks\n */\nexport const referencesResolvable: LintRule = {\n id: 'references/resolvable',\n defaultSeverity: 'error',\n fixable: false,\n description: 'All cross-node references must resolve to existing nodes',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [, node] of graph.nodes) {\n // Skip kinds that don't have outbound references to check\n if (node.kind === 'policy' || node.kind === 'owner') continue;\n\n // Check owner reference (concepts, products, entities, terms)\n if (node.owner && !graph.nodes.has(node.owner)) {\n diagnostics.push({\n ruleId: 'references/resolvable',\n severity: 'error',\n message: `${node.kind} \"${node.id}\" references owner \"${node.owner}\" which does not exist`,\n source: node.source,\n fixable: false,\n });\n }\n\n if (node.kind === 'concept') {\n const concept = node as Concept;\n\n // Check dependsOn\n if (concept.dependsOn) {\n for (const dep of concept.dependsOn) {\n if (!graph.nodes.has(dep)) {\n diagnostics.push({\n ruleId: 'references/resolvable',\n severity: 'error',\n message: `concept \"${concept.id}\" depends on \"${dep}\" which does not exist`,\n source: concept.source,\n fixable: false,\n });\n }\n }\n }\n\n // Check productId\n if (concept.productId && !graph.nodes.has(concept.productId)) {\n diagnostics.push({\n ruleId: 'references/resolvable',\n severity: 'error',\n message: `concept \"${concept.id}\" references product \"${concept.productId}\" which does not exist`,\n source: concept.source,\n fixable: false,\n });\n }\n }\n\n if (node.kind === 'term') {\n const term = node as Term;\n\n // Check mapsTo\n if (term.mapsTo) {\n for (const target of term.mapsTo) {\n if (!graph.nodes.has(target)) {\n diagnostics.push({\n ruleId: 'references/resolvable',\n severity: 'error',\n message: `term \"${term.id}\" maps to \"${target}\" which does not exist`,\n source: term.source,\n fixable: false,\n });\n }\n }\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic, Term } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Detect terms with identical definitions.\n *\n * Since the graph uses a Map keyed by ID, true duplicate IDs cannot exist.\n * Instead, this rule flags term nodes whose `definition` text matches\n * another term's definition (case-insensitive, trimmed). The second\n * occurrence is flagged.\n */\nexport const glossaryNoDuplicateTerms: LintRule = {\n id: 'glossary/no-duplicate-terms',\n defaultSeverity: 'warning',\n fixable: false,\n description: 'Term definitions must be unique across the glossary',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n // Collect all term nodes\n const termIds = graph.indexes.byKind.get('term') ?? [];\n const seen = new Map<string, string>(); // normalized definition -> first term ID\n\n for (const termId of termIds) {\n const node = graph.nodes.get(termId);\n if (!node || node.kind !== 'term') continue;\n const term = node as Term;\n\n const normalized = term.definition.trim().toLowerCase();\n const firstId = seen.get(normalized);\n\n if (firstId !== undefined) {\n diagnostics.push({\n ruleId: 'glossary/no-duplicate-terms',\n severity: 'warning',\n message: `term \"${term.id}\" has the same definition as term \"${firstId}\"`,\n source: term.source,\n fixable: false,\n });\n } else {\n seen.set(normalized, term.id);\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic, Concept } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Certified concepts must have at least one evidence entry.\n *\n * Checks every concept where `certified: true` and verifies the\n * `evidence` array is present and non-empty.\n */\nexport const conceptsCertifiedRequiresEvidence: LintRule = {\n id: 'concepts/certified-requires-evidence',\n defaultSeverity: 'error',\n fixable: false,\n description: 'Certified concepts must include at least one evidence entry',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n const conceptIds = graph.indexes.byKind.get('concept') ?? [];\n\n for (const id of conceptIds) {\n const node = graph.nodes.get(id);\n if (!node || node.kind !== 'concept') continue;\n const concept = node as Concept;\n\n if (concept.certified && (!concept.evidence || concept.evidence.length === 0)) {\n diagnostics.push({\n ruleId: 'concepts/certified-requires-evidence',\n severity: 'error',\n message: `concept \"${concept.id}\" is certified but has no evidence`,\n source: concept.source,\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic, Policy } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Policy selectors must reference known concepts and tags.\n *\n * For each policy rule's `when` block:\n * - `conceptIds` entries must exist as concept nodes in the graph\n * - `tagsAny` entries must be used by at least one node (present in byTag index)\n */\nexport const policiesUnknownSubject: LintRule = {\n id: 'policies/unknown-subject',\n defaultSeverity: 'warning',\n fixable: false,\n description: 'Policy selectors must reference known concepts and tags',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n const policyIds = graph.indexes.byKind.get('policy') ?? [];\n\n for (const policyId of policyIds) {\n const node = graph.nodes.get(policyId);\n if (!node || node.kind !== 'policy') continue;\n const policy = node as Policy;\n\n for (const rule of policy.rules) {\n // Check conceptIds\n if (rule.when.conceptIds) {\n for (const conceptId of rule.when.conceptIds) {\n const target = graph.nodes.get(conceptId);\n if (!target || target.kind !== 'concept') {\n diagnostics.push({\n ruleId: 'policies/unknown-subject',\n severity: 'warning',\n message: `policy \"${policy.id}\" references unknown concept \"${conceptId}\"`,\n source: policy.source,\n fixable: false,\n });\n }\n }\n }\n\n // Check tagsAny\n if (rule.when.tagsAny) {\n for (const tag of rule.when.tagsAny) {\n if (!graph.indexes.byTag.has(tag)) {\n diagnostics.push({\n ruleId: 'policies/unknown-subject',\n severity: 'warning',\n message: `policy \"${policy.id}\" references unknown tag \"${tag}\"`,\n source: policy.source,\n fixable: false,\n });\n }\n }\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic, Policy } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Deny rules should have higher priority than allow rules.\n *\n * Within each policy, if any rule has `then.deny: true`, its priority\n * should be numerically greater than every non-deny rule in the same\n * policy. Emits a diagnostic if a deny rule has lower priority than\n * a non-deny rule.\n */\nexport const policiesDenyOverridesAllow: LintRule = {\n id: 'policies/deny-overrides-allow',\n defaultSeverity: 'warning',\n fixable: false,\n description: 'Deny rules should have higher priority than allow rules',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n const policyIds = graph.indexes.byKind.get('policy') ?? [];\n\n for (const policyId of policyIds) {\n const node = graph.nodes.get(policyId);\n if (!node || node.kind !== 'policy') continue;\n const policy = node as Policy;\n\n // Find the max priority among non-deny rules\n let maxAllowPriority = -Infinity;\n for (const rule of policy.rules) {\n if (!rule.then.deny) {\n maxAllowPriority = Math.max(maxAllowPriority, rule.priority);\n }\n }\n\n // Check that every deny rule has higher priority than all allow rules\n for (const rule of policy.rules) {\n if (rule.then.deny && maxAllowPriority > -Infinity && rule.priority <= maxAllowPriority) {\n diagnostics.push({\n ruleId: 'policies/deny-overrides-allow',\n severity: 'warning',\n message: `policy \"${policy.id}\" has a deny rule with priority ${rule.priority} that does not override allow rules (max allow priority: ${maxAllowPriority})`,\n source: policy.source,\n fixable: false,\n });\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic, Concept } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Certified concepts should include at least one example.\n *\n * Checks every concept with `certified: true` and verifies the\n * `examples` array is present and non-empty.\n */\nexport const docsExamplesRequired: LintRule = {\n id: 'docs/examples-required',\n defaultSeverity: 'warning',\n fixable: false,\n description: 'Certified concepts should include at least one example',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n const conceptIds = graph.indexes.byKind.get('concept') ?? [];\n\n for (const id of conceptIds) {\n const node = graph.nodes.get(id);\n if (!node || node.kind !== 'concept') continue;\n const concept = node as Concept;\n\n if (concept.certified && (!concept.examples || concept.examples.length === 0)) {\n diagnostics.push({\n ruleId: 'docs/examples-required',\n severity: 'warning',\n message: `concept \"${concept.id}\" is certified but has no examples`,\n source: concept.source,\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Deprecated nodes must include a sunset date tag.\n *\n * Checks every node with `status: 'deprecated'` for a tag matching\n * the `sunset:*` pattern (e.g., `sunset:2026-06-01`).\n */\nexport const deprecationRequireSunset: LintRule = {\n id: 'deprecation/require-sunset',\n defaultSeverity: 'warning',\n fixable: false,\n description: 'Deprecated nodes must include a sunset date tag',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n const deprecatedIds = graph.indexes.byStatus.get('deprecated') ?? [];\n\n for (const id of deprecatedIds) {\n const node = graph.nodes.get(id);\n if (!node) continue;\n\n const hasSunset = node.tags?.some(tag => tag.startsWith('sunset:')) ?? false;\n\n if (!hasSunset) {\n diagnostics.push({\n ruleId: 'deprecation/require-sunset',\n severity: 'warning',\n message: `${node.kind} \"${node.id}\" is deprecated but has no sunset:* tag`,\n source: node.source,\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic, Concept } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Secret patterns to scan for in text content.\n *\n * Kept intentionally narrow to avoid false positives on normal prose.\n */\nconst SECRET_PATTERNS: { label: string; re: RegExp }[] = [\n { label: 'AWS access key', re: /AKIA[0-9A-Z]{16}/ },\n { label: 'password assignment', re: /password\\s*[:=]\\s*\\S+/i },\n { label: 'secret assignment', re: /secret\\s*[:=]\\s*\\S+/i },\n { label: 'token assignment', re: /token\\s*[:=]\\s*\\S+/i },\n { label: 'API key (long hex/alnum)', re: /(?:api[_-]?key|apikey)\\s*[:=]\\s*[A-Za-z0-9]{16,}/ },\n];\n\n/**\n * Test a string against all secret patterns.\n * Returns the label of the first match, or undefined.\n */\nfunction detectSecret(text: string): string | undefined {\n for (const { label, re } of SECRET_PATTERNS) {\n if (re.test(text)) return label;\n }\n return undefined;\n}\n\n/**\n * Scan all string fields in every node for secret patterns.\n *\n * Checks `description`, `definition`, and example `content` fields.\n */\nexport const packagingNoSecrets: LintRule = {\n id: 'packaging/no-secrets',\n defaultSeverity: 'error',\n fixable: false,\n description: 'Node content must not contain secret patterns (API keys, passwords, tokens)',\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [, node] of graph.nodes) {\n // Check description\n if (node.description) {\n const match = detectSecret(node.description);\n if (match) {\n diagnostics.push({\n ruleId: 'packaging/no-secrets',\n severity: 'error',\n message: `${node.kind} \"${node.id}\" description contains a potential ${match}`,\n source: node.source,\n fixable: false,\n });\n }\n }\n\n // Check definition (concepts, terms, entities)\n const asRecord = node as unknown as Record<string, unknown>;\n if (typeof asRecord.definition === 'string') {\n const match = detectSecret(asRecord.definition);\n if (match) {\n diagnostics.push({\n ruleId: 'packaging/no-secrets',\n severity: 'error',\n message: `${node.kind} \"${node.id}\" definition contains a potential ${match}`,\n source: node.source,\n fixable: false,\n });\n }\n }\n\n // Check examples (concepts)\n if (node.kind === 'concept') {\n const concept = node as Concept;\n if (concept.examples) {\n for (const example of concept.examples) {\n const match = detectSecret(example.content);\n if (match) {\n diagnostics.push({\n ruleId: 'packaging/no-secrets',\n severity: 'error',\n message: `concept \"${concept.id}\" example \"${example.label}\" contains a potential ${match}`,\n source: concept.source,\n fixable: false,\n });\n }\n }\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { LintRule } from '../rule.js';\n\nimport { schemaValidYaml } from './schema-valid-yaml.js';\nimport { namingIdKebabCase } from './naming-id-kebab-case.js';\nimport { ownershipRequired } from './ownership-required.js';\nimport { descriptionsRequired } from './descriptions-required.js';\nimport { referencesResolvable } from './references-resolvable.js';\nimport { glossaryNoDuplicateTerms } from './glossary-no-duplicate-terms.js';\nimport { conceptsCertifiedRequiresEvidence } from './concepts-certified-requires-evidence.js';\nimport { policiesUnknownSubject } from './policies-unknown-subject.js';\nimport { policiesDenyOverridesAllow } from './policies-deny-overrides-allow.js';\nimport { docsExamplesRequired } from './docs-examples-required.js';\nimport { deprecationRequireSunset } from './deprecation-require-sunset.js';\nimport { packagingNoSecrets } from './packaging-no-secrets.js';\n\n/**\n * All built-in lint rules, in a convenient array for bulk registration.\n */\nexport const ALL_RULES: LintRule[] = [\n schemaValidYaml,\n namingIdKebabCase,\n ownershipRequired,\n descriptionsRequired,\n referencesResolvable,\n glossaryNoDuplicateTerms,\n conceptsCertifiedRequiresEvidence,\n policiesUnknownSubject,\n policiesDenyOverridesAllow,\n docsExamplesRequired,\n deprecationRequireSunset,\n packagingNoSecrets,\n];\n\n// Re-export individual rules\nexport { schemaValidYaml } from './schema-valid-yaml.js';\nexport { namingIdKebabCase } from './naming-id-kebab-case.js';\nexport { ownershipRequired } from './ownership-required.js';\nexport { descriptionsRequired } from './descriptions-required.js';\nexport { referencesResolvable } from './references-resolvable.js';\nexport { glossaryNoDuplicateTerms } from './glossary-no-duplicate-terms.js';\nexport { conceptsCertifiedRequiresEvidence } from './concepts-certified-requires-evidence.js';\nexport { policiesUnknownSubject } from './policies-unknown-subject.js';\nexport { policiesDenyOverridesAllow } from './policies-deny-overrides-allow.js';\nexport { docsExamplesRequired } from './docs-examples-required.js';\nexport { deprecationRequireSunset } from './deprecation-require-sunset.js';\nexport { packagingNoSecrets } from './packaging-no-secrets.js';\n","import fs from 'node:fs';\nimport type { Diagnostic, TextEdit } from '../types/index.js';\n\nexport interface ApplyResult {\n file: string;\n editsApplied: number;\n newContent: string;\n}\n\n/**\n * Apply fixable diagnostics to produce new file contents.\n *\n * Filters diagnostics to those with `fixable: true` and a `fix` property,\n * groups their edits by file, then applies edits in reverse line order\n * (bottom-to-top) to avoid offset corruption.\n *\n * Currently handles insertion edits where startLine === endLine and\n * startCol === endCol.\n */\nexport function applyFixes(diagnostics: Diagnostic[]): ApplyResult[] {\n // 1. Collect all edits from fixable diagnostics, grouped by file\n const editsByFile = new Map<string, TextEdit[]>();\n\n for (const diag of diagnostics) {\n if (!diag.fixable || !diag.fix) continue;\n\n for (const edit of diag.fix.edits) {\n const existing = editsByFile.get(edit.file);\n if (existing) {\n existing.push(edit);\n } else {\n editsByFile.set(edit.file, [edit]);\n }\n }\n }\n\n // 2. For each file, read content, apply edits in reverse order, produce result\n const results: ApplyResult[] = [];\n\n for (const [file, edits] of editsByFile) {\n // Sort edits in reverse order (bottom-to-top by startLine, then startCol)\n const sorted = [...edits].sort((a, b) => {\n if (b.range.startLine !== a.range.startLine) {\n return b.range.startLine - a.range.startLine;\n }\n return b.range.startCol - a.range.startCol;\n });\n\n let content: string;\n try {\n content = fs.readFileSync(file, 'utf-8');\n } catch {\n // File not readable — skip\n continue;\n }\n\n const lines = content.split('\\n');\n\n for (const edit of sorted) {\n const { startLine, startCol, endLine, endCol } = edit.range;\n\n if (startLine === endLine && startCol === endCol) {\n // Insertion edit: insert newText at the given position\n // Lines are 1-indexed in diagnostics\n const lineIdx = startLine - 1;\n if (lineIdx >= 0 && lineIdx <= lines.length) {\n if (lineIdx === lines.length) {\n // Insert at the end of the file\n lines.push(edit.newText.replace(/\\n$/, ''));\n } else {\n const line = lines[lineIdx] ?? '';\n const colIdx = startCol - 1;\n const before = line.slice(0, colIdx);\n const after = line.slice(colIdx);\n // newText may contain newlines — split and splice\n const insertLines = (before + edit.newText + after).split('\\n');\n lines.splice(lineIdx, 1, ...insertLines);\n }\n }\n } else {\n // Range replacement edit\n const startLineIdx = startLine - 1;\n const endLineIdx = endLine - 1;\n if (startLineIdx >= 0 && endLineIdx < lines.length) {\n const beforeText = (lines[startLineIdx] ?? '').slice(0, startCol - 1);\n const afterText = (lines[endLineIdx] ?? '').slice(endCol - 1);\n const replacementLines = (beforeText + edit.newText + afterText).split('\\n');\n lines.splice(startLineIdx, endLineIdx - startLineIdx + 1, ...replacementLines);\n }\n }\n }\n\n results.push({\n file,\n editsApplied: edits.length,\n newContent: lines.join('\\n'),\n });\n }\n\n return results;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/erickittelson/Desktop/ContextKit/packages/core/dist/index.cjs","../src/schema/osi.ts","../src/schema/governance.ts","../src/schema/rules.ts","../src/schema/lineage.ts","../src/schema/term.ts","../src/schema/owner.ts","../src/schema/config.ts","../src/parser/discover.ts","../src/parser/parse.ts","../src/compiler/validate.ts","../src/compiler/resolve.ts","../src/compiler/graph.ts","../src/tier/checks.ts","../src/tier/compute.ts","../src/compiler/pipeline.ts","../src/compiler/emit.ts","../src/linter/engine.ts","../src/linter/rules/naming-id-kebab-case.ts","../src/linter/rules/descriptions-required.ts","../src/linter/rules/ownership-required.ts","../src/linter/rules/references-resolvable.ts","../src/linter/rules/glossary-no-duplicate-terms.ts","../src/linter/rules/no-secrets.ts","../src/linter/rules/osi-valid-schema.ts","../src/linter/rules/governance-model-exists.ts","../src/linter/rules/governance-datasets-exist.ts","../src/linter/rules/governance-fields-exist.ts","../src/linter/rules/governance-grain-required.ts","../src/linter/rules/governance-security-required.ts","../src/linter/rules/governance-trust-required.ts","../src/linter/rules/governance-refresh-required.ts","../src/linter/rules/lineage-upstream-required.ts","../src/linter/rules/governance-semantic-role-required.ts","../src/linter/rules/governance-aggregation-required.ts","../src/linter/rules/governance-additive-required.ts","../src/linter/rules/rules-golden-queries-minimum.ts","../src/linter/rules/rules-business-rules-exist.ts","../src/linter/rules/rules-guardrails-exist.ts","../src/linter/rules/rules-hierarchies-exist.ts","../src/linter/rules/tier-bronze.ts","../src/linter/rules/tier-silver.ts","../src/linter/rules/tier-gold.ts","../src/linter/rules/index.ts","../src/config/defaults.ts","../src/config/loader.ts","../src/fixer/apply.ts"],"names":["z","diag"],"mappings":"AAAA;ACAA,0BAAkB;AAEX,IAAM,YAAA,EAAc,MAAA,CAAE,IAAA,CAAK,CAAC,UAAA,EAAY,WAAA,EAAa,KAAA,EAAO,SAAA,EAAW,YAAY,CAAC,CAAA;AAEpF,IAAM,WAAA,EAAa,MAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,WAAA,EAAa,YAAA,EAAc,KAAA,EAAO,YAAY,CAAC,CAAA;AAEpF,IAAM,sBAAA,EAAwB,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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erickittelson/Desktop/ContextKit/packages/core/dist/index.cjs","sourcesContent":[null,"import { z } from 'zod';\n\nexport const dialectEnum = z.enum(['ANSI_SQL', 'SNOWFLAKE', 'MDX', 'TABLEAU', 'DATABRICKS']);\n\nexport const vendorEnum = z.enum(['COMMON', 'SNOWFLAKE', 'SALESFORCE', 'DBT', 'DATABRICKS']);\n\nexport const aiContextObjectSchema = z.object({\n instructions: z.string().optional(),\n synonyms: z.array(z.string()).optional(),\n examples: z.array(z.string()).optional(),\n});\n\nexport const aiContextSchema = z.union([z.string(), aiContextObjectSchema]);\n\nexport const customExtensionSchema = z.object({\n vendor_name: vendorEnum,\n data: z.string(),\n});\n\nexport const dialectExpressionSchema = z.object({\n dialect: dialectEnum,\n expression: z.string(),\n});\n\nexport const expressionSchema = z.object({\n dialects: z.array(dialectExpressionSchema),\n});\n\nexport const dimensionSchema = z.object({\n is_time: z.boolean().optional(),\n});\n\nexport const osiFieldSchema = z.object({\n name: z.string(),\n expression: expressionSchema,\n dimension: dimensionSchema.optional(),\n label: z.string().optional(),\n description: z.string().optional(),\n ai_context: aiContextSchema.optional(),\n custom_extensions: z.array(customExtensionSchema).optional(),\n});\n\nexport const osiDatasetSchema = z.object({\n name: z.string(),\n source: z.string(),\n primary_key: z.array(z.string()).optional(),\n unique_keys: z.array(z.array(z.string())).optional(),\n description: z.string().optional(),\n ai_context: aiContextSchema.optional(),\n fields: z.array(osiFieldSchema).optional(),\n custom_extensions: z.array(customExtensionSchema).optional(),\n});\n\nexport const osiRelationshipSchema = z.object({\n name: z.string(),\n from: z.string(),\n to: z.string(),\n from_columns: z.array(z.string()),\n to_columns: z.array(z.string()),\n ai_context: aiContextSchema.optional(),\n custom_extensions: z.array(customExtensionSchema).optional(),\n});\n\nexport const osiMetricSchema = z.object({\n name: z.string(),\n expression: expressionSchema,\n description: z.string().optional(),\n ai_context: aiContextSchema.optional(),\n custom_extensions: z.array(customExtensionSchema).optional(),\n});\n\nexport const osiSemanticModelSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n ai_context: aiContextSchema.optional(),\n datasets: z.array(osiDatasetSchema),\n relationships: z.array(osiRelationshipSchema).optional(),\n metrics: z.array(osiMetricSchema).optional(),\n custom_extensions: z.array(customExtensionSchema).optional(),\n});\n\nexport const osiDocumentSchema = z.object({\n version: z.literal('1.0'),\n semantic_model: z.array(osiSemanticModelSchema),\n});\n","import { z } from 'zod';\n\nexport const trustStatusEnum = z.enum(['endorsed', 'warning', 'deprecated']);\nexport const securityClassificationEnum = z.enum(['public', 'internal', 'confidential', 'secret']);\nexport const tableTypeEnum = z.enum(['fact', 'dimension', 'bridge', 'snapshot', 'event', 'aggregate', 'view']);\nexport const semanticRoleEnum = z.enum(['metric', 'dimension', 'identifier', 'date']);\nexport const defaultAggregationEnum = z.enum(['SUM', 'AVG', 'COUNT', 'COUNT_DISTINCT', 'MIN', 'MAX']);\n\nexport const datasetGovernanceSchema = z.object({\n grain: z.string(),\n refresh: z.string().optional(),\n table_type: tableTypeEnum,\n security: securityClassificationEnum.optional(),\n});\n\nexport const fieldGovernanceSchema = z.object({\n semantic_role: semanticRoleEnum,\n default_aggregation: defaultAggregationEnum.optional(),\n additive: z.boolean().optional(),\n default_filter: z.string().optional(),\n sample_values: z.array(z.string()).optional(),\n});\n\n/** Validates that all keys in a fields record use \"dataset.field\" dot notation. */\nconst dottedFieldsRecord = z.record(z.string(), fieldGovernanceSchema).refine(\n (rec) => Object.keys(rec).every((key) => /^[^.]+\\.[^.]+$/.test(key)),\n { message: 'Field keys must use \"dataset.field\" dot notation (e.g., \"orders.amount\")' },\n);\n\nexport const governanceFileSchema = z.object({\n model: z.string(),\n owner: z.string(),\n trust: trustStatusEnum.optional(),\n security: securityClassificationEnum.optional(),\n tags: z.array(z.string()).optional(),\n datasets: z.record(z.string(), datasetGovernanceSchema).optional(),\n fields: dottedFieldsRecord.optional(),\n});\n","import { z } from 'zod';\n\nexport const goldenQuerySchema = z.object({\n question: z.string(),\n sql: z.string(),\n dialect: z.string().optional(),\n tags: z.array(z.string()).optional(),\n});\n\nexport const businessRuleSchema = z.object({\n name: z.string(),\n definition: z.string(),\n enforcement: z.array(z.string()).optional(),\n avoid: z.array(z.string()).optional(),\n tables: z.array(z.string()).optional(),\n applied_always: z.boolean().optional(),\n});\n\nexport const guardrailFilterSchema = z.object({\n name: z.string(),\n filter: z.string(),\n tables: z.array(z.string()).optional(),\n reason: z.string(),\n});\n\nexport const hierarchySchema = z.object({\n name: z.string(),\n levels: z.array(z.string()),\n dataset: z.string(),\n field: z.string().optional(),\n});\n\nexport const rulesFileSchema = z.object({\n model: z.string(),\n golden_queries: z.array(goldenQuerySchema).optional(),\n business_rules: z.array(businessRuleSchema).optional(),\n guardrail_filters: z.array(guardrailFilterSchema).optional(),\n hierarchies: z.array(hierarchySchema).optional(),\n});\n","import { z } from 'zod';\n\nexport const lineageTypeEnum = z.enum(['pipeline', 'dashboard', 'ml_model', 'api', 'manual']);\n\nexport const upstreamEntrySchema = z.object({\n source: z.string(),\n type: lineageTypeEnum,\n pipeline: z.string().optional(),\n tool: z.string().optional(),\n refresh: z.string().optional(),\n notes: z.string().optional(),\n});\n\nexport const downstreamEntrySchema = z.object({\n target: z.string(),\n type: lineageTypeEnum,\n tool: z.string().optional(),\n notes: z.string().optional(),\n});\n\nexport const lineageFileSchema = z.object({\n model: z.string(),\n upstream: z.array(upstreamEntrySchema).optional(),\n downstream: z.array(downstreamEntrySchema).optional(),\n});\n","import { z } from 'zod';\n\nexport const termFileSchema = z.object({\n id: z.string(),\n definition: z.string(),\n synonyms: z.array(z.string()).optional(),\n maps_to: z.array(z.string()).optional(),\n owner: z.string().optional(),\n tags: z.array(z.string()).optional(),\n});\n","import { z } from 'zod';\n\nexport const ownerFileSchema = z.object({\n id: z.string(),\n display_name: z.string(),\n email: z.string().optional(),\n team: z.string().optional(),\n description: z.string().optional(),\n});\n","import { z } from 'zod';\n\nexport const metadataTierEnum = z.enum(['none', 'bronze', 'silver', 'gold']);\nexport const severityEnum = z.enum(['error', 'warning']);\nexport const severityOrOffEnum = z.union([severityEnum, z.literal('off')]);\n\nexport const lintConfigSchema = z.object({\n severity_overrides: z.record(z.string(), severityOrOffEnum).optional(),\n});\n\nexport const siteConfigSchema = z.object({\n title: z.string().optional(),\n base_path: z.string().optional(),\n});\n\nexport const mcpConfigSchema = z.object({\n transport: z.enum(['stdio', 'http']).optional(),\n port: z.number().optional(),\n});\n\nexport const contextKitConfigSchema = z.object({\n context_dir: z.string().default('context'),\n output_dir: z.string().default('dist'),\n minimum_tier: metadataTierEnum.optional(),\n lint: lintConfigSchema.optional(),\n site: siteConfigSchema.optional(),\n mcp: mcpConfigSchema.optional(),\n});\n","import { glob } from 'glob';\nimport path from 'node:path';\n\nexport type FileKind = 'model' | 'governance' | 'rules' | 'lineage' | 'term' | 'owner';\n\nexport interface DiscoveredFile {\n path: string;\n kind: FileKind;\n}\n\nconst PATTERNS: Record<FileKind, string> = {\n model: '**/*.osi.yaml',\n governance: '**/*.governance.yaml',\n rules: '**/*.rules.yaml',\n lineage: '**/*.lineage.yaml',\n term: '**/*.term.yaml',\n owner: '**/*.owner.yaml',\n};\n\nexport async function discoverFiles(contextDir: string): Promise<DiscoveredFile[]> {\n const files: DiscoveredFile[] = [];\n for (const [kind, pattern] of Object.entries(PATTERNS)) {\n const matches = await glob(pattern, { cwd: contextDir, absolute: true });\n for (const match of matches) {\n files.push({ path: match, kind: kind as FileKind });\n }\n }\n return files.sort((a, b) => a.path.localeCompare(b.path));\n}\n","import { readFile } from 'node:fs/promises';\nimport { parse as parseYaml } from 'yaml';\nimport type { FileKind } from './discover.js';\n\nexport interface ParsedFile {\n kind: FileKind;\n data: unknown;\n source: { file: string; line: number; column: number };\n}\n\nexport async function parseFile(filePath: string, kind: FileKind): Promise<ParsedFile> {\n const content = await readFile(filePath, 'utf-8');\n const data = parseYaml(content);\n return {\n kind,\n data,\n source: { file: filePath, line: 1, column: 1 },\n };\n}\n","import { ZodError, type ZodSchema } from 'zod';\nimport type { FileKind, ParsedFile } from '../parser/index.js';\nimport type { Diagnostic } from '../types/index.js';\nimport {\n osiDocumentSchema,\n governanceFileSchema,\n rulesFileSchema,\n lineageFileSchema,\n termFileSchema,\n ownerFileSchema,\n} from '../schema/index.js';\n\nexport interface ValidateResult {\n kind: FileKind;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- validated data varies by FileKind\n data?: any;\n diagnostics: Diagnostic[];\n}\n\nconst SCHEMA_MAP: Record<FileKind, ZodSchema> = {\n model: osiDocumentSchema,\n governance: governanceFileSchema,\n rules: rulesFileSchema,\n lineage: lineageFileSchema,\n term: termFileSchema,\n owner: ownerFileSchema,\n};\n\nfunction zodErrorToDiagnostics(err: ZodError, source: ParsedFile['source']): Diagnostic[] {\n return err.issues.map((issue) => ({\n ruleId: 'schema/invalid',\n severity: 'error' as const,\n message: `${issue.path.join('.')}: ${issue.message}`,\n location: { file: source.file, line: source.line, column: source.column },\n fixable: false,\n }));\n}\n\nexport function validate(parsed: ParsedFile): ValidateResult {\n const schema = SCHEMA_MAP[parsed.kind];\n const parseResult = schema.safeParse(parsed.data);\n\n if (!parseResult.success) {\n return {\n kind: parsed.kind,\n data: undefined,\n diagnostics: zodErrorToDiagnostics(parseResult.error, parsed.source),\n };\n }\n\n let data = parseResult.data;\n\n // For model kind, extract the first semantic_model entry\n if (parsed.kind === 'model') {\n const doc = data as { semantic_model: unknown[] };\n data = doc.semantic_model[0];\n }\n\n return {\n kind: parsed.kind,\n data,\n diagnostics: [],\n };\n}\n","import type { ContextGraph, Diagnostic, OsiSemanticModel } from '../types/index.js';\n\nfunction diag(\n ruleId: string,\n message: string,\n file: string,\n): Diagnostic {\n return {\n ruleId,\n severity: 'error',\n message,\n location: { file, line: 1, column: 1 },\n fixable: false,\n };\n}\n\n/** Get the set of dataset names from a model. */\nfunction datasetNames(model: OsiSemanticModel): Set<string> {\n return new Set(model.datasets.map((d) => d.name));\n}\n\n/** Get the set of field names in a dataset, formatted as-is (just the field name). */\nfunction fieldNamesInDataset(model: OsiSemanticModel, datasetName: string): Set<string> {\n const dataset = model.datasets.find((d) => d.name === datasetName);\n if (!dataset?.fields) return new Set();\n return new Set(dataset.fields.map((f) => f.name));\n}\n\nexport function resolveReferences(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n // --- Governance references ---\n for (const [key, gov] of graph.governance) {\n const file = `governance:${key}`;\n\n // governance.model must exist in graph.models\n if (!graph.models.has(gov.model)) {\n diagnostics.push(\n diag('references/model-exists', `Governance references model \"${gov.model}\" which does not exist`, file),\n );\n }\n\n // governance.owner must exist in graph.owners\n if (!graph.owners.has(gov.owner)) {\n diagnostics.push(\n diag('references/owner-exists', `Governance references owner \"${gov.owner}\" which does not exist`, file),\n );\n }\n\n // governance.datasets keys must match dataset names in the referenced model\n if (gov.datasets) {\n const model = graph.models.get(gov.model);\n const validDatasets = model ? datasetNames(model) : new Set<string>();\n for (const dsName of Object.keys(gov.datasets)) {\n if (!validDatasets.has(dsName)) {\n diagnostics.push(\n diag('references/dataset-exists', `Governance references dataset \"${dsName}\" which does not exist in model \"${gov.model}\"`, file),\n );\n }\n }\n }\n\n // governance.fields keys: \"dataset.field\" format\n if (gov.fields) {\n const model = graph.models.get(gov.model);\n for (const fieldKey of Object.keys(gov.fields)) {\n const parts = fieldKey.split('.');\n if (parts.length !== 2) continue; // schema validation already handles format\n const [dsName, fieldName] = parts as [string, string];\n const validDatasets = model ? datasetNames(model) : new Set<string>();\n if (!validDatasets.has(dsName)) {\n diagnostics.push(\n diag('references/dataset-exists', `Governance field key \"${fieldKey}\" references dataset \"${dsName}\" which does not exist in model \"${gov.model}\"`, file),\n );\n } else if (model) {\n const validFields = fieldNamesInDataset(model, dsName);\n if (!validFields.has(fieldName)) {\n diagnostics.push(\n diag('references/field-exists', `Governance field key \"${fieldKey}\" references field \"${fieldName}\" which does not exist in dataset \"${dsName}\"`, file),\n );\n }\n }\n }\n }\n }\n\n // --- Rules references ---\n for (const [key, rules] of graph.rules) {\n const file = `rules:${key}`;\n\n // rules.model must exist in graph.models\n if (!graph.models.has(rules.model)) {\n diagnostics.push(\n diag('references/model-exists', `Rules file references model \"${rules.model}\" which does not exist`, file),\n );\n }\n\n const model = graph.models.get(rules.model);\n const validDatasets = model ? datasetNames(model) : new Set<string>();\n\n // rules.business_rules[].tables must match dataset names\n if (rules.business_rules) {\n for (const rule of rules.business_rules) {\n if (rule.tables) {\n for (const table of rule.tables) {\n if (!validDatasets.has(table)) {\n diagnostics.push(\n diag('references/table-exists', `Business rule \"${rule.name}\" references table \"${table}\" which does not exist in model \"${rules.model}\"`, file),\n );\n }\n }\n }\n }\n }\n\n // rules.guardrail_filters[].tables must match dataset names\n if (rules.guardrail_filters) {\n for (const filter of rules.guardrail_filters) {\n if (filter.tables) {\n for (const table of filter.tables) {\n if (!validDatasets.has(table)) {\n diagnostics.push(\n diag('references/table-exists', `Guardrail filter \"${filter.name}\" references table \"${table}\" which does not exist in model \"${rules.model}\"`, file),\n );\n }\n }\n }\n }\n }\n\n // rules.hierarchies[].dataset must match dataset name\n if (rules.hierarchies) {\n for (const hierarchy of rules.hierarchies) {\n if (!validDatasets.has(hierarchy.dataset)) {\n diagnostics.push(\n diag('references/table-exists', `Hierarchy \"${hierarchy.name}\" references dataset \"${hierarchy.dataset}\" which does not exist in model \"${rules.model}\"`, file),\n );\n }\n }\n }\n }\n\n // --- Lineage references ---\n for (const [key, lineage] of graph.lineage) {\n const file = `lineage:${key}`;\n\n // lineage.model must exist in graph.models\n if (!graph.models.has(lineage.model)) {\n diagnostics.push(\n diag('references/model-exists', `Lineage file references model \"${lineage.model}\" which does not exist`, file),\n );\n }\n }\n\n // --- Term references ---\n for (const [key, term] of graph.terms) {\n const file = `term:${key}`;\n\n // term.owner must exist in graph.owners\n if (term.owner && !graph.owners.has(term.owner)) {\n diagnostics.push(\n diag('references/owner-exists', `Term \"${term.id}\" references owner \"${term.owner}\" which does not exist`, file),\n );\n }\n\n // term.maps_to must match other term IDs\n if (term.maps_to) {\n for (const targetId of term.maps_to) {\n if (!graph.terms.has(targetId)) {\n diagnostics.push(\n diag('references/term-exists', `Term \"${term.id}\" maps_to term \"${targetId}\" which does not exist`, file),\n );\n }\n }\n }\n }\n\n return diagnostics;\n}\n","import type {\n ContextGraph,\n OsiSemanticModel,\n GovernanceFile,\n RulesFile,\n LineageFile,\n TermFile,\n OwnerFile,\n TierScore,\n} from '../types/index.js';\nimport type { ValidateResult } from './validate.js';\n\nexport function createEmptyGraph(): ContextGraph {\n return {\n models: new Map<string, OsiSemanticModel>(),\n governance: new Map<string, GovernanceFile>(),\n rules: new Map<string, RulesFile>(),\n lineage: new Map<string, LineageFile>(),\n terms: new Map<string, TermFile>(),\n owners: new Map<string, OwnerFile>(),\n tiers: new Map<string, TierScore>(),\n indexes: {\n byOwner: new Map<string, string[]>(),\n byTag: new Map<string, string[]>(),\n byTrust: new Map<string, string[]>(),\n modelToGovernance: new Map<string, string>(),\n modelToRules: new Map<string, string>(),\n modelToLineage: new Map<string, string>(),\n },\n };\n}\n\n/** Helper to push a value to a map of arrays. */\nfunction pushToIndex(map: Map<string, string[]>, key: string, value: string): void {\n const existing = map.get(key);\n if (existing) {\n existing.push(value);\n } else {\n map.set(key, [value]);\n }\n}\n\nexport function buildGraph(results: ValidateResult[]): ContextGraph {\n const graph = createEmptyGraph();\n\n for (const result of results) {\n // Skip entries with errors or no data\n const hasErrors = result.diagnostics.some((d) => d.severity === 'error');\n if (hasErrors || result.data == null) continue;\n\n switch (result.kind) {\n case 'model': {\n const model = result.data as OsiSemanticModel;\n graph.models.set(model.name, model);\n break;\n }\n case 'governance': {\n const gov = result.data as GovernanceFile;\n graph.governance.set(gov.model, gov);\n break;\n }\n case 'rules': {\n const rules = result.data as RulesFile;\n graph.rules.set(rules.model, rules);\n break;\n }\n case 'lineage': {\n const lineage = result.data as LineageFile;\n graph.lineage.set(lineage.model, lineage);\n break;\n }\n case 'term': {\n const term = result.data as TermFile;\n graph.terms.set(term.id, term);\n break;\n }\n case 'owner': {\n const owner = result.data as OwnerFile;\n graph.owners.set(owner.id, owner);\n break;\n }\n }\n }\n\n // Populate indexes from governance entries\n for (const [govKey, gov] of graph.governance) {\n // byOwner\n pushToIndex(graph.indexes.byOwner, gov.owner, govKey);\n\n // byTag\n if (gov.tags) {\n for (const tag of gov.tags) {\n pushToIndex(graph.indexes.byTag, tag, govKey);\n }\n }\n\n // byTrust\n if (gov.trust) {\n pushToIndex(graph.indexes.byTrust, gov.trust, govKey);\n }\n\n // modelToGovernance\n graph.indexes.modelToGovernance.set(gov.model, govKey);\n }\n\n // modelToRules\n for (const [rulesKey, rules] of graph.rules) {\n graph.indexes.modelToRules.set(rules.model, rulesKey);\n }\n\n // modelToLineage\n for (const [lineageKey, lineage] of graph.lineage) {\n graph.indexes.modelToLineage.set(lineage.model, lineageKey);\n }\n\n return graph;\n}\n","import type { ContextGraph, TierCheckResult, OsiSemanticModel } from '../types/index.js';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/** Collect all fully-qualified field names from a model: \"dataset.field\" */\nfunction allFieldKeys(model: OsiSemanticModel): string[] {\n const keys: string[] = [];\n for (const ds of model.datasets) {\n for (const f of ds.fields ?? []) {\n keys.push(`${ds.name}.${f.name}`);\n }\n }\n return keys;\n}\n\nfunction pass(id: string, label: string): TierCheckResult {\n return { id, label, passed: true };\n}\n\nfunction fail(id: string, label: string, detail?: string): TierCheckResult {\n return { id, label, passed: false, detail };\n}\n\n// ---------------------------------------------------------------------------\n// Bronze checks (7)\n// ---------------------------------------------------------------------------\n\nexport function checkBronze(modelName: string, graph: ContextGraph): TierCheckResult[] {\n const results: TierCheckResult[] = [];\n const model = graph.models.get(modelName);\n const gov = graph.governance.get(modelName);\n\n // 1. Model has name and description\n {\n const id = 'bronze/model-description';\n const label = 'Model has name and description';\n if (model && model.name && model.description) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, 'Model is missing name or description'));\n }\n }\n\n // 2. All datasets have descriptions\n {\n const id = 'bronze/dataset-descriptions';\n const label = 'All datasets have descriptions';\n if (!model || model.datasets.length === 0) {\n results.push(fail(id, label, 'No model or datasets found'));\n } else {\n const missing = model.datasets.filter((ds) => !ds.description);\n if (missing.length === 0) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Missing descriptions: ${missing.map((d) => d.name).join(', ')}`));\n }\n }\n }\n\n // 3. All fields have descriptions\n {\n const id = 'bronze/field-descriptions';\n const label = 'All fields have descriptions';\n if (!model) {\n results.push(fail(id, label, 'No model found'));\n } else {\n const allFields = model.datasets.flatMap((ds) => ds.fields ?? []);\n if (allFields.length === 0) {\n results.push(fail(id, label, 'No fields defined across any dataset'));\n } else {\n const missing: string[] = [];\n for (const ds of model.datasets) {\n for (const f of ds.fields ?? []) {\n if (!f.description) {\n missing.push(`${ds.name}.${f.name}`);\n }\n }\n }\n if (missing.length === 0) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Missing descriptions: ${missing.join(', ')}`));\n }\n }\n }\n }\n\n // 4. Owner assigned and resolvable\n {\n const id = 'bronze/owner-resolvable';\n const label = 'Owner assigned and resolvable';\n if (gov && gov.owner && graph.owners.has(gov.owner)) {\n results.push(pass(id, label));\n } else if (gov && gov.owner) {\n results.push(fail(id, label, `Owner '${gov.owner}' not found in owners`));\n } else {\n results.push(fail(id, label, 'No governance or owner assigned'));\n }\n }\n\n // 5. Security classification set\n {\n const id = 'bronze/security-classification';\n const label = 'Security classification set';\n if (gov && gov.security) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, 'No security classification in governance'));\n }\n }\n\n // 6. All datasets have grain statements\n {\n const id = 'bronze/dataset-grain';\n const label = 'All datasets have grain statements';\n if (!gov || !gov.datasets) {\n results.push(fail(id, label, 'No governance datasets'));\n } else if (!model) {\n results.push(fail(id, label, 'No model found'));\n } else {\n const missing: string[] = [];\n for (const ds of model.datasets) {\n const dsGov = gov.datasets[ds.name];\n if (!dsGov || !dsGov.grain) {\n missing.push(ds.name);\n }\n }\n if (missing.length === 0) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Missing grain: ${missing.join(', ')}`));\n }\n }\n }\n\n // 7. All datasets have table_type\n {\n const id = 'bronze/dataset-table-type';\n const label = 'All datasets have table_type';\n if (!gov || !gov.datasets) {\n results.push(fail(id, label, 'No governance datasets'));\n } else if (!model) {\n results.push(fail(id, label, 'No model found'));\n } else {\n const missing: string[] = [];\n for (const ds of model.datasets) {\n const dsGov = gov.datasets[ds.name];\n if (!dsGov || !dsGov.table_type) {\n missing.push(ds.name);\n }\n }\n if (missing.length === 0) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Missing table_type: ${missing.join(', ')}`));\n }\n }\n }\n\n return results;\n}\n\n// ---------------------------------------------------------------------------\n// Silver checks (6)\n// ---------------------------------------------------------------------------\n\nexport function checkSilver(modelName: string, graph: ContextGraph): TierCheckResult[] {\n const results: TierCheckResult[] = [];\n const model = graph.models.get(modelName);\n const gov = graph.governance.get(modelName);\n const lineageKey = graph.indexes.modelToLineage.get(modelName);\n const lineage = lineageKey ? graph.lineage.get(lineageKey) : undefined;\n\n // 1. Trust status is set\n {\n const id = 'silver/trust-status';\n const label = 'Trust status is set';\n if (gov && gov.trust) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, 'No trust status in governance'));\n }\n }\n\n // 2. At least 2 tags\n {\n const id = 'silver/min-tags';\n const label = 'At least 2 tags';\n if (gov && gov.tags && gov.tags.length >= 2) {\n results.push(pass(id, label));\n } else {\n const count = gov?.tags?.length ?? 0;\n results.push(fail(id, label, `Found ${count} tag(s), need at least 2`));\n }\n }\n\n // 3. Glossary term linked (tags overlap or owner overlap)\n {\n const id = 'silver/glossary-linked';\n const label = 'Glossary term linked';\n let linked = false;\n const govTags = new Set(gov?.tags ?? []);\n const govOwner = gov?.owner;\n\n for (const [, term] of graph.terms) {\n // Check tag overlap\n if (term.tags) {\n for (const tag of term.tags) {\n if (govTags.has(tag)) {\n linked = true;\n break;\n }\n }\n }\n // Check owner overlap\n if (term.owner && term.owner === govOwner) {\n linked = true;\n }\n if (linked) break;\n }\n\n if (graph.terms.size === 0) {\n results.push(fail(id, label, 'No glossary terms defined'));\n } else if (linked) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, 'No glossary term shares tags or owner with this model'));\n }\n }\n\n // 4. Upstream lineage exists\n {\n const id = 'silver/upstream-lineage';\n const label = 'Upstream lineage exists';\n if (lineage && lineage.upstream && lineage.upstream.length > 0) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, 'No upstream lineage defined'));\n }\n }\n\n // 5. All datasets have refresh cadence\n {\n const id = 'silver/dataset-refresh';\n const label = 'All datasets have refresh cadence';\n if (!gov || !gov.datasets || !model) {\n results.push(fail(id, label, 'No governance datasets or model'));\n } else {\n const missing: string[] = [];\n for (const ds of model.datasets) {\n const dsGov = gov.datasets[ds.name];\n if (!dsGov || !dsGov.refresh) {\n missing.push(ds.name);\n }\n }\n if (missing.length === 0) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Missing refresh: ${missing.join(', ')}`));\n }\n }\n }\n\n // 6. At least 2 fields have sample_values\n {\n const id = 'silver/sample-values';\n const label = 'At least 2 fields have sample_values';\n let count = 0;\n if (gov && gov.fields) {\n for (const [, fg] of Object.entries(gov.fields)) {\n if (fg.sample_values && fg.sample_values.length > 0) {\n count++;\n }\n }\n }\n if (count >= 2) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Found ${count} field(s) with sample_values, need at least 2`));\n }\n }\n\n return results;\n}\n\n// ---------------------------------------------------------------------------\n// Gold checks (10)\n// ---------------------------------------------------------------------------\n\nexport function checkGold(modelName: string, graph: ContextGraph): TierCheckResult[] {\n const results: TierCheckResult[] = [];\n const model = graph.models.get(modelName);\n const gov = graph.governance.get(modelName);\n const rulesKey = graph.indexes.modelToRules.get(modelName);\n const rules = rulesKey ? graph.rules.get(rulesKey) : undefined;\n\n const fieldKeys = model ? allFieldKeys(model) : [];\n\n // 1. Every field has semantic_role\n {\n const id = 'gold/field-semantic-role';\n const label = 'Every field has semantic_role';\n if (!gov || !gov.fields) {\n results.push(fail(id, label, 'No governance fields'));\n } else if (fieldKeys.length === 0) {\n results.push(fail(id, label, 'Model has no fields to verify'));\n } else {\n const missing = fieldKeys.filter((k) => !gov.fields![k]?.semantic_role);\n if (missing.length === 0) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Missing semantic_role: ${missing.join(', ')}`));\n }\n }\n }\n\n // 2. Every metric field has default_aggregation\n {\n const id = 'gold/metric-aggregation';\n const label = 'Every metric field has default_aggregation';\n if (!gov || !gov.fields) {\n results.push(fail(id, label, 'No governance fields'));\n } else {\n const metricFields = Object.entries(gov.fields).filter(([, fg]) => fg.semantic_role === 'metric');\n if (metricFields.length === 0) {\n results.push(fail(id, label, 'No metric fields found'));\n } else {\n const missing = metricFields.filter(([, fg]) => !fg.default_aggregation);\n if (missing.length === 0) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Missing default_aggregation: ${missing.map(([k]) => k).join(', ')}`));\n }\n }\n }\n }\n\n // 3. Every metric field has additive flag\n {\n const id = 'gold/metric-additive';\n const label = 'Every metric field has additive flag';\n if (!gov || !gov.fields) {\n results.push(fail(id, label, 'No governance fields'));\n } else {\n const metricFields = Object.entries(gov.fields).filter(([, fg]) => fg.semantic_role === 'metric');\n if (metricFields.length === 0) {\n results.push(fail(id, label, 'No metric fields found'));\n } else {\n const missing = metricFields.filter(([, fg]) => fg.additive === undefined);\n if (missing.length === 0) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Missing additive flag: ${missing.map(([k]) => k).join(', ')}`));\n }\n }\n }\n }\n\n // 4. At least 1 guardrail_filter exists\n {\n const id = 'gold/guardrail-filter';\n const label = 'At least 1 guardrail_filter exists';\n if (rules && rules.guardrail_filters && rules.guardrail_filters.length >= 1) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, 'No guardrail filters found'));\n }\n }\n\n // 5. At least 3 golden_queries exist\n {\n const id = 'gold/golden-queries';\n const label = 'At least 3 golden_queries exist';\n const count = rules?.golden_queries?.length ?? 0;\n if (count >= 3) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Found ${count} golden queries, need at least 3`));\n }\n }\n\n // 6. At least 1 business_rule exists\n {\n const id = 'gold/business-rule';\n const label = 'At least 1 business_rule exists';\n if (rules && rules.business_rules && rules.business_rules.length >= 1) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, 'No business rules found'));\n }\n }\n\n // 7. At least 1 hierarchy exists\n {\n const id = 'gold/hierarchy';\n const label = 'At least 1 hierarchy exists';\n if (rules && rules.hierarchies && rules.hierarchies.length >= 1) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, 'No hierarchies found'));\n }\n }\n\n // 8. At least 1 field has default_filter\n {\n const id = 'gold/default-filter';\n const label = 'At least 1 field has default_filter';\n let found = false;\n if (gov && gov.fields) {\n for (const [, fg] of Object.entries(gov.fields)) {\n if (fg.default_filter) {\n found = true;\n break;\n }\n }\n }\n if (found) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, 'No fields have default_filter'));\n }\n }\n\n // 9. Trust is endorsed\n {\n const id = 'gold/trust-endorsed';\n const label = 'Trust is endorsed';\n if (gov && gov.trust === 'endorsed') {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, `Trust is '${gov?.trust ?? 'unset'}', not 'endorsed'`));\n }\n }\n\n // 10. Security controls adequate (security classification set at model or dataset level)\n {\n const id = 'gold/security-controls';\n const label = 'Security controls adequate';\n const hasModelSecurity = !!(gov && gov.security);\n let hasDatasetSecurity = false;\n if (gov && gov.datasets) {\n for (const [, dsGov] of Object.entries(gov.datasets)) {\n if (dsGov.security) {\n hasDatasetSecurity = true;\n break;\n }\n }\n }\n if (hasModelSecurity || hasDatasetSecurity) {\n results.push(pass(id, label));\n } else {\n results.push(fail(id, label, 'No security classification at model or dataset level'));\n }\n }\n\n return results;\n}\n","import type { ContextGraph, TierScore, MetadataTier } from '../types/index.js';\nimport { checkBronze, checkSilver, checkGold } from './checks.js';\n\n/**\n * Compute the tier score for a single model.\n *\n * The tier is determined hierarchically:\n * - Gold: all Bronze + Silver + Gold checks pass\n * - Silver: all Bronze + Silver checks pass\n * - Bronze: all Bronze checks pass\n * - None: some Bronze checks fail\n */\nexport function computeTier(modelName: string, graph: ContextGraph): TierScore {\n const bronzeChecks = checkBronze(modelName, graph);\n const silverChecks = checkSilver(modelName, graph);\n const goldChecks = checkGold(modelName, graph);\n\n const bronzePassed = bronzeChecks.every((c) => c.passed);\n const silverPassed = silverChecks.every((c) => c.passed);\n const goldPassed = goldChecks.every((c) => c.passed);\n\n let tier: MetadataTier;\n if (bronzePassed && silverPassed && goldPassed) {\n tier = 'gold';\n } else if (bronzePassed && silverPassed) {\n tier = 'silver';\n } else if (bronzePassed) {\n tier = 'bronze';\n } else {\n tier = 'none';\n }\n\n return {\n model: modelName,\n tier,\n bronze: { passed: bronzePassed, checks: bronzeChecks },\n silver: { passed: silverPassed, checks: silverChecks },\n gold: { passed: goldPassed, checks: goldChecks },\n };\n}\n\n/**\n * Compute tiers for every model in the graph and populate `graph.tiers`.\n */\nexport function computeAllTiers(graph: ContextGraph): void {\n for (const modelName of graph.models.keys()) {\n const score = computeTier(modelName, graph);\n graph.tiers.set(modelName, score);\n }\n}\n","import type { ContextGraph, ContextKitConfig, Diagnostic } from '../types/index.js';\nimport { discoverFiles } from '../parser/discover.js';\nimport { parseFile } from '../parser/parse.js';\nimport { validate } from './validate.js';\nimport { buildGraph } from './graph.js';\nimport { resolveReferences } from './resolve.js';\nimport { computeAllTiers } from '../tier/compute.js';\n\nexport interface CompileResult {\n graph: ContextGraph;\n diagnostics: Diagnostic[];\n}\n\nexport async function compile(options: {\n contextDir: string;\n config?: Partial<ContextKitConfig>;\n}): Promise<CompileResult> {\n const allDiagnostics: Diagnostic[] = [];\n\n // 1. Discover all files\n const discovered = await discoverFiles(options.contextDir);\n\n // 2. Parse each file\n const parsed = await Promise.all(\n discovered.map((f) => parseFile(f.path, f.kind)),\n );\n\n // 3. Validate each parsed file\n const validated = parsed.map(validate);\n\n // Collect validation diagnostics\n for (const result of validated) {\n allDiagnostics.push(...result.diagnostics);\n }\n\n // 4. Build graph from successful validations\n const graph = buildGraph(validated);\n\n // 5. Resolve references\n const refDiagnostics = resolveReferences(graph);\n allDiagnostics.push(...refDiagnostics);\n\n // 6. Compute tier scores\n computeAllTiers(graph);\n\n // 7. Return graph + all diagnostics\n return { graph, diagnostics: allDiagnostics };\n}\n","import type { ContextGraph } from '../types/graph.js';\nimport type { ContextKitConfig } from '../types/config.js';\nimport type { TierScore } from '../types/tier.js';\nimport type { OsiSemanticModel } from '../types/osi.js';\nimport type { GovernanceFile } from '../types/governance.js';\nimport type { RulesFile } from '../types/rules.js';\nimport type { LineageFile } from '../types/lineage.js';\nimport type { TermFile } from '../types/term.js';\nimport type { OwnerFile } from '../types/owner.js';\n\nexport interface Manifest {\n version: string;\n generatedAt: string;\n models: Record<string, OsiSemanticModel>;\n governance: Record<string, GovernanceFile>;\n rules: Record<string, RulesFile>;\n lineage: Record<string, LineageFile>;\n terms: Record<string, TermFile>;\n owners: Record<string, OwnerFile>;\n tiers: Record<string, TierScore>;\n}\n\n/** Convert a Map to a plain Record for JSON serialization. */\nfunction mapToRecord<V>(map: Map<string, V>): Record<string, V> {\n const record: Record<string, V> = {};\n for (const [key, value] of map) {\n record[key] = value;\n }\n return record;\n}\n\n/**\n * Emit a compiled ContextGraph as a JSON-serializable Manifest object.\n *\n * Converts all internal Maps to plain Records suitable for `JSON.stringify`.\n */\nexport function emitManifest(graph: ContextGraph, _config: ContextKitConfig): Manifest {\n return {\n version: '0.2.0',\n generatedAt: new Date().toISOString(),\n models: mapToRecord(graph.models),\n governance: mapToRecord(graph.governance),\n rules: mapToRecord(graph.rules),\n lineage: mapToRecord(graph.lineage),\n terms: mapToRecord(graph.terms),\n owners: mapToRecord(graph.owners),\n tiers: mapToRecord(graph.tiers),\n };\n}\n","import type { ContextGraph, Diagnostic, Severity } from '../types/index.js';\nimport type { LintRule } from './rule.js';\n\nexport class LintEngine {\n private rules: LintRule[] = [];\n private overrides: Record<string, Severity | 'off'> = {};\n\n constructor(overrides?: Record<string, Severity | 'off'>) {\n if (overrides) this.overrides = overrides;\n }\n\n register(rule: LintRule): void {\n this.rules.push(rule);\n }\n\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n for (const rule of this.rules) {\n const override = this.overrides[rule.id];\n if (override === 'off') continue;\n const results = rule.run(graph);\n for (const d of results) {\n diagnostics.push({\n ...d,\n severity: override ?? rule.defaultSeverity,\n });\n }\n }\n return diagnostics.sort(\n (a, b) =>\n a.location.file.localeCompare(b.location.file) ||\n a.location.line - b.location.line,\n );\n }\n}\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nconst KEBAB_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;\n\nexport const namingIdKebabCase: LintRule = {\n id: 'naming/id-kebab-case',\n defaultSeverity: 'warning',\n description: 'Owner and term IDs must be kebab-case',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, owner] of graph.owners) {\n if (!KEBAB_RE.test(owner.id)) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Owner ID \"${owner.id}\" is not kebab-case`,\n location: { file: `owner:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n for (const [key, term] of graph.terms) {\n if (!KEBAB_RE.test(term.id)) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Term ID \"${term.id}\" is not kebab-case`,\n location: { file: `term:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const descriptionsRequired: LintRule = {\n id: 'osi/descriptions-required',\n defaultSeverity: 'warning',\n description: 'OSI models, datasets, and fields must have descriptions',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, model] of graph.models) {\n const file = `model:${key}`;\n\n if (!model.description) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Model \"${model.name}\" is missing a description`,\n location: { file, line: 1, column: 1 },\n fixable: false,\n });\n }\n\n for (const dataset of model.datasets) {\n if (!dataset.description) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Dataset \"${dataset.name}\" in model \"${model.name}\" is missing a description`,\n location: { file, line: 1, column: 1 },\n fixable: false,\n });\n }\n\n if (dataset.fields) {\n for (const field of dataset.fields) {\n if (!field.description) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Field \"${field.name}\" in dataset \"${dataset.name}\" of model \"${model.name}\" is missing a description`,\n location: { file, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const ownershipRequired: LintRule = {\n id: 'governance/ownership-required',\n defaultSeverity: 'error',\n description: 'Every governance file must have an owner field set',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, gov] of graph.governance) {\n if (!gov.owner) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Governance for model \"${gov.model}\" is missing an owner`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\nimport { resolveReferences } from '../../compiler/resolve.js';\n\nexport const referencesResolvable: LintRule = {\n id: 'references/resolvable',\n defaultSeverity: 'error',\n description: 'All cross-file references must resolve to existing entities',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n return resolveReferences(graph);\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const glossaryNoDuplicateTerms: LintRule = {\n id: 'glossary/no-duplicate-synonyms',\n defaultSeverity: 'warning',\n description: 'No two terms should share the same synonym string',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n const seen = new Map<string, string>(); // synonym -> first term id\n\n for (const [key, term] of graph.terms) {\n if (!term.synonyms) continue;\n for (const synonym of term.synonyms) {\n const lower = synonym.toLowerCase();\n const existing = seen.get(lower);\n if (existing && existing !== term.id) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Synonym \"${synonym}\" is used by both term \"${existing}\" and term \"${term.id}\"`,\n location: { file: `term:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n } else {\n seen.set(lower, term.id);\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nconst SECRET_PATTERNS = [\n /password\\s*[=:]\\s*\\S+/i,\n /api[_-]?key\\s*[=:]\\s*\\S+/i,\n /secret\\s*[=:]\\s*\\S+/i,\n /token\\s*[=:]\\s*\\S+/i,\n /\\bsk-[a-zA-Z0-9]{10,}\\b/,\n /\\bAKIA[A-Z0-9]{16}\\b/, // AWS access key\n];\n\nfunction checkString(\n value: string | undefined,\n context: string,\n file: string,\n diagnostics: Diagnostic[],\n ruleId: string,\n severity: 'error' | 'warning',\n): void {\n if (!value) return;\n for (const pattern of SECRET_PATTERNS) {\n if (pattern.test(value)) {\n diagnostics.push({\n ruleId,\n severity,\n message: `Potential secret detected in ${context}: matches pattern ${pattern.source}`,\n location: { file, line: 1, column: 1 },\n fixable: false,\n });\n return; // one hit per string is enough\n }\n }\n}\n\nfunction aiContextToString(\n ctx: string | { instructions?: string; synonyms?: string[]; examples?: string[] } | undefined,\n): string | undefined {\n if (!ctx) return undefined;\n if (typeof ctx === 'string') return ctx;\n const parts: string[] = [];\n if (ctx.instructions) parts.push(ctx.instructions);\n if (ctx.synonyms) parts.push(ctx.synonyms.join(' '));\n if (ctx.examples) parts.push(ctx.examples.join(' '));\n return parts.join(' ') || undefined;\n}\n\nexport const noSecrets: LintRule = {\n id: 'security/no-secrets',\n defaultSeverity: 'error',\n description: 'Scan string values for patterns that look like secrets',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, model] of graph.models) {\n const file = `model:${key}`;\n checkString(model.description, `model \"${model.name}\" description`, file, diagnostics, this.id, this.defaultSeverity);\n checkString(aiContextToString(model.ai_context), `model \"${model.name}\" ai_context`, file, diagnostics, this.id, this.defaultSeverity);\n\n for (const ds of model.datasets) {\n checkString(ds.description, `dataset \"${ds.name}\" description`, file, diagnostics, this.id, this.defaultSeverity);\n checkString(aiContextToString(ds.ai_context), `dataset \"${ds.name}\" ai_context`, file, diagnostics, this.id, this.defaultSeverity);\n if (ds.fields) {\n for (const f of ds.fields) {\n checkString(f.description, `field \"${f.name}\" description`, file, diagnostics, this.id, this.defaultSeverity);\n checkString(aiContextToString(f.ai_context), `field \"${f.name}\" ai_context`, file, diagnostics, this.id, this.defaultSeverity);\n }\n }\n }\n }\n\n // Check governance string fields\n for (const [key, gov] of graph.governance) {\n const file = `governance:${key}`;\n if (gov.datasets) {\n for (const [dsName, ds] of Object.entries(gov.datasets)) {\n checkString(ds.grain, `dataset \"${dsName}\" grain`, file, diagnostics, this.id, this.defaultSeverity);\n }\n }\n }\n\n // Check rules string fields\n for (const [key, rules] of graph.rules) {\n const file = `rules:${key}`;\n if (rules.business_rules) {\n for (const br of rules.business_rules) {\n checkString(br.definition, `business rule \"${br.name}\" definition`, file, diagnostics, this.id, this.defaultSeverity);\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const osiValidSchema: LintRule = {\n id: 'osi/valid-schema',\n defaultSeverity: 'error',\n description: 'OSI models must have at least one dataset',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, model] of graph.models) {\n if (!model.datasets || model.datasets.length === 0) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Model \"${model.name}\" has no datasets`,\n location: { file: `model:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const governanceModelExists: LintRule = {\n id: 'governance/model-exists',\n defaultSeverity: 'error',\n description: 'Every governance file must reference a model that exists in the graph',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, gov] of graph.governance) {\n if (!graph.models.has(gov.model)) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Governance references model \"${gov.model}\" which does not exist`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const governanceDatasetsExist: LintRule = {\n id: 'governance/datasets-exist',\n defaultSeverity: 'error',\n description: 'Every dataset key in governance must exist as a dataset in the referenced OSI model',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, gov] of graph.governance) {\n if (!gov.datasets) continue;\n\n const model = graph.models.get(gov.model);\n if (!model) continue; // governance-model-exists handles this\n\n const validDatasets = new Set(model.datasets.map((d) => d.name));\n\n for (const dsName of Object.keys(gov.datasets)) {\n if (!validDatasets.has(dsName)) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Governance dataset \"${dsName}\" does not exist in model \"${gov.model}\"`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const governanceFieldsExist: LintRule = {\n id: 'governance/fields-exist',\n defaultSeverity: 'error',\n description: 'Every field key in governance must exist as a field in the referenced OSI model dataset',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, gov] of graph.governance) {\n if (!gov.fields) continue;\n\n const model = graph.models.get(gov.model);\n if (!model) continue; // governance-model-exists handles this\n\n for (const fieldKey of Object.keys(gov.fields)) {\n const parts = fieldKey.split('.');\n if (parts.length !== 2) continue;\n const [dsName, fieldName] = parts as [string, string];\n\n const dataset = model.datasets.find((d) => d.name === dsName);\n if (!dataset) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Governance field \"${fieldKey}\" references dataset \"${dsName}\" which does not exist in model \"${gov.model}\"`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n continue;\n }\n\n const validFields = new Set(dataset.fields?.map((f) => f.name) ?? []);\n if (!validFields.has(fieldName)) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Governance field \"${fieldKey}\" references field \"${fieldName}\" which does not exist in dataset \"${dsName}\"`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const governanceGrainRequired: LintRule = {\n id: 'governance/grain-required',\n defaultSeverity: 'warning',\n description: 'Every dataset in governance must have a grain statement',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, gov] of graph.governance) {\n if (!gov.datasets) continue;\n\n for (const [dsName, ds] of Object.entries(gov.datasets)) {\n if (!ds.grain) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Dataset \"${dsName}\" in governance for model \"${gov.model}\" is missing a grain statement`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const governanceSecurityRequired: LintRule = {\n id: 'governance/security-required',\n defaultSeverity: 'warning',\n description: 'Every governance file must have a security classification',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, gov] of graph.governance) {\n if (!gov.security) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Governance for model \"${gov.model}\" is missing a security classification`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const governanceTrustRequired: LintRule = {\n id: 'governance/trust-required',\n defaultSeverity: 'warning',\n description: 'Governance files must have a trust status set (endorsed/warning/deprecated)',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, gov] of graph.governance) {\n if (!gov.trust) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Governance for model \"${gov.model}\" is missing a trust status (endorsed/warning/deprecated)`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const governanceRefreshRequired: LintRule = {\n id: 'governance/refresh-required',\n defaultSeverity: 'warning',\n description: 'All governed datasets must have a refresh cadence set',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, gov] of graph.governance) {\n if (!gov.datasets) continue;\n\n for (const [dsName, ds] of Object.entries(gov.datasets)) {\n if (!ds.refresh) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Dataset \"${dsName}\" in governance for model \"${gov.model}\" is missing a refresh cadence`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const lineageUpstreamRequired: LintRule = {\n id: 'lineage/upstream-required',\n defaultSeverity: 'warning',\n description: 'Every governed model should have a lineage file with at least one upstream entry',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [modelName] of graph.governance) {\n // Only check models that have governance\n const lineage = graph.lineage.get(modelName);\n if (!lineage || !lineage.upstream || lineage.upstream.length === 0) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Governed model \"${modelName}\" is missing lineage with at least one upstream entry`,\n location: { file: `governance:${modelName}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const governanceSemanticRoleRequired: LintRule = {\n id: 'governance/semantic-role-required',\n defaultSeverity: 'warning',\n description: 'Every field in every dataset of a governed model must have a governance entry with semantic_role',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [modelName, model] of graph.models) {\n // Only check models that have governance\n const gov = graph.governance.get(modelName);\n if (!gov) continue;\n\n const govFields = gov.fields ?? {};\n\n for (const dataset of model.datasets) {\n if (!dataset.fields) continue;\n\n for (const field of dataset.fields) {\n const fieldKey = `${dataset.name}.${field.name}`;\n const govField = govFields[fieldKey];\n\n if (!govField || !govField.semantic_role) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Field \"${fieldKey}\" in model \"${modelName}\" is missing a semantic_role in governance`,\n location: { file: `governance:${modelName}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const governanceAggregationRequired: LintRule = {\n id: 'governance/aggregation-required',\n defaultSeverity: 'warning',\n description: 'Every field with semantic_role \"metric\" must have default_aggregation set',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, gov] of graph.governance) {\n if (!gov.fields) continue;\n\n for (const [fieldName, field] of Object.entries(gov.fields)) {\n if (field.semantic_role === 'metric' && !field.default_aggregation) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Metric field \"${fieldName}\" in governance for model \"${gov.model}\" is missing default_aggregation`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const governanceAdditiveRequired: LintRule = {\n id: 'governance/additive-required',\n defaultSeverity: 'warning',\n description: 'Every field with semantic_role \"metric\" must have additive flag set',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, gov] of graph.governance) {\n if (!gov.fields) continue;\n\n for (const [fieldName, field] of Object.entries(gov.fields)) {\n if (field.semantic_role === 'metric' && field.additive == null) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Metric field \"${fieldName}\" in governance for model \"${gov.model}\" is missing additive flag`,\n location: { file: `governance:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const rulesGoldenQueriesMinimum: LintRule = {\n id: 'rules/golden-queries-minimum',\n defaultSeverity: 'warning',\n description: 'Models with a rules file must have at least 3 golden queries',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, rules] of graph.rules) {\n const count = rules.golden_queries?.length ?? 0;\n if (count < 3) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Rules for model \"${rules.model}\" has ${count} golden queries (minimum 3 required)`,\n location: { file: `rules:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const rulesBusinessRulesExist: LintRule = {\n id: 'rules/business-rules-exist',\n defaultSeverity: 'warning',\n description: 'Models with a rules file must have at least 1 business rule',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, rules] of graph.rules) {\n const count = rules.business_rules?.length ?? 0;\n if (count < 1) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Rules for model \"${rules.model}\" has no business rules (at least 1 required)`,\n location: { file: `rules:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const rulesGuardrailsExist: LintRule = {\n id: 'rules/guardrails-exist',\n defaultSeverity: 'warning',\n description: 'Models with a rules file must have at least 1 guardrail filter',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, rules] of graph.rules) {\n const count = rules.guardrail_filters?.length ?? 0;\n if (count < 1) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Rules for model \"${rules.model}\" has no guardrail filters (at least 1 required)`,\n location: { file: `rules:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\nexport const rulesHierarchiesExist: LintRule = {\n id: 'rules/hierarchies-exist',\n defaultSeverity: 'warning',\n description: 'Models with a rules file must have at least 1 hierarchy',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [key, rules] of graph.rules) {\n const count = rules.hierarchies?.length ?? 0;\n if (count < 1) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Rules for model \"${rules.model}\" has no hierarchies (at least 1 required)`,\n location: { file: `rules:${key}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Composite Bronze tier check.\n *\n * Bronze requirements per model:\n * - Model has description\n * - All datasets have descriptions\n * - All fields have descriptions\n * - Governance exists with owner\n * - Security classification set\n * - All datasets have grain\n * - All datasets have table_type\n */\nexport const tierBronze: LintRule = {\n id: 'tier/bronze-requirements',\n defaultSeverity: 'warning',\n description: 'Checks all Bronze tier requirements as a composite',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [modelName, model] of graph.models) {\n const missing: string[] = [];\n\n // Model description\n if (!model.description) {\n missing.push('model description');\n }\n\n // Dataset descriptions\n for (const dataset of model.datasets) {\n if (!dataset.description) {\n missing.push(`dataset \"${dataset.name}\" description`);\n }\n\n // Field descriptions\n if (dataset.fields) {\n for (const field of dataset.fields) {\n if (!field.description) {\n missing.push(`field \"${dataset.name}.${field.name}\" description`);\n }\n }\n }\n }\n\n // Governance existence with owner\n const gov = graph.governance.get(modelName);\n if (!gov) {\n missing.push('governance file');\n } else {\n if (!gov.owner) {\n missing.push('governance owner');\n }\n\n // Security classification\n if (!gov.security) {\n missing.push('security classification');\n }\n\n // Datasets in governance: grain and table_type\n if (gov.datasets) {\n for (const [dsName, ds] of Object.entries(gov.datasets)) {\n if (!ds.grain) {\n missing.push(`dataset \"${dsName}\" grain`);\n }\n if (!ds.table_type) {\n missing.push(`dataset \"${dsName}\" table_type`);\n }\n }\n } else {\n // If no datasets in governance at all, check if model has datasets\n if (model.datasets.length > 0) {\n missing.push('governance datasets');\n }\n }\n }\n\n if (missing.length > 0) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Model \"${modelName}\" is missing Bronze requirements: ${missing.join(', ')}`,\n location: { file: `model:${modelName}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Composite Silver tier check (beyond Bronze).\n *\n * Silver requirements per governed model:\n * - Trust status set\n * - Tags (>=2)\n * - Glossary linked (at least 1 term referencing the owner)\n * - Upstream lineage exists\n * - Refresh cadence on all datasets\n * - Sample values on >=2 fields\n */\nexport const tierSilver: LintRule = {\n id: 'tier/silver-requirements',\n defaultSeverity: 'warning',\n description: 'Checks all Silver tier requirements (beyond Bronze) as a composite',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [modelName, gov] of graph.governance) {\n const missing: string[] = [];\n\n // Trust status\n if (!gov.trust) {\n missing.push('trust status');\n }\n\n // Tags (>=2)\n if (!gov.tags || gov.tags.length < 2) {\n missing.push(`tags (need >=2, have ${gov.tags?.length ?? 0})`);\n }\n\n // Glossary linked: at least 1 term exists that references the same owner\n const hasGlossaryLink = Array.from(graph.terms.values()).some(\n (term) => term.owner === gov.owner,\n );\n if (!hasGlossaryLink) {\n missing.push('glossary linked');\n }\n\n // Upstream lineage\n const lineage = graph.lineage.get(modelName);\n if (!lineage || !lineage.upstream || lineage.upstream.length === 0) {\n missing.push('upstream lineage');\n }\n\n // Refresh cadence on all datasets\n if (gov.datasets) {\n for (const [dsName, ds] of Object.entries(gov.datasets)) {\n if (!ds.refresh) {\n missing.push(`refresh cadence on dataset \"${dsName}\"`);\n }\n }\n }\n\n // Sample values on >=2 fields\n let sampleValuesCount = 0;\n if (gov.fields) {\n for (const field of Object.values(gov.fields)) {\n if (field.sample_values && field.sample_values.length > 0) {\n sampleValuesCount++;\n }\n }\n }\n if (sampleValuesCount < 2) {\n missing.push(`sample values on >=2 fields (have ${sampleValuesCount})`);\n }\n\n if (missing.length > 0) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Model \"${modelName}\" is missing Silver requirements: ${missing.join(', ')}`,\n location: { file: `governance:${modelName}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { ContextGraph, Diagnostic } from '../../types/index.js';\nimport type { LintRule } from '../rule.js';\n\n/**\n * Composite Gold tier check (beyond Silver).\n *\n * Gold requirements per governed model:\n * - Every field has semantic_role\n * - Metrics have aggregation\n * - Metrics have additive\n * - Guardrails exist\n * - >=3 golden queries\n * - Business rules exist\n * - Hierarchies exist\n * - Default filters exist (at least one field with default_filter)\n * - Trust is endorsed\n */\nexport const tierGold: LintRule = {\n id: 'tier/gold-requirements',\n defaultSeverity: 'warning',\n description: 'Checks all Gold tier requirements (beyond Silver) as a composite',\n fixable: false,\n run(graph: ContextGraph): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n for (const [modelName, gov] of graph.governance) {\n const missing: string[] = [];\n const model = graph.models.get(modelName);\n\n // Trust is endorsed\n if (gov.trust !== 'endorsed') {\n missing.push('trust must be endorsed');\n }\n\n // Every field has semantic_role\n if (model) {\n const govFields = gov.fields ?? {};\n for (const dataset of model.datasets) {\n if (!dataset.fields) continue;\n for (const field of dataset.fields) {\n const fieldKey = `${dataset.name}.${field.name}`;\n const govField = govFields[fieldKey];\n if (!govField || !govField.semantic_role) {\n missing.push(`semantic_role for \"${fieldKey}\"`);\n }\n }\n }\n }\n\n // Metrics have aggregation and additive\n if (gov.fields) {\n for (const [fieldName, field] of Object.entries(gov.fields)) {\n if (field.semantic_role === 'metric') {\n if (!field.default_aggregation) {\n missing.push(`aggregation for metric \"${fieldName}\"`);\n }\n if (field.additive == null) {\n missing.push(`additive for metric \"${fieldName}\"`);\n }\n }\n }\n }\n\n // Default filters exist (at least one field with default_filter)\n let hasDefaultFilter = false;\n if (gov.fields) {\n for (const field of Object.values(gov.fields)) {\n if (field.default_filter) {\n hasDefaultFilter = true;\n break;\n }\n }\n }\n if (!hasDefaultFilter) {\n missing.push('default filters');\n }\n\n // Rules file checks\n const rules = graph.rules.get(modelName);\n if (!rules) {\n missing.push('rules file (golden queries, business rules, guardrails, hierarchies)');\n } else {\n // >=3 golden queries\n const goldenCount = rules.golden_queries?.length ?? 0;\n if (goldenCount < 3) {\n missing.push(`>=3 golden queries (have ${goldenCount})`);\n }\n\n // Business rules exist\n const bizCount = rules.business_rules?.length ?? 0;\n if (bizCount < 1) {\n missing.push('business rules');\n }\n\n // Guardrails exist\n const guardCount = rules.guardrail_filters?.length ?? 0;\n if (guardCount < 1) {\n missing.push('guardrail filters');\n }\n\n // Hierarchies exist\n const hierCount = rules.hierarchies?.length ?? 0;\n if (hierCount < 1) {\n missing.push('hierarchies');\n }\n }\n\n if (missing.length > 0) {\n diagnostics.push({\n ruleId: this.id,\n severity: this.defaultSeverity,\n message: `Model \"${modelName}\" is missing Gold requirements: ${missing.join(', ')}`,\n location: { file: `governance:${modelName}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n\n return diagnostics;\n },\n};\n","import type { LintRule } from '../rule.js';\n\n// Bronze rules\nimport { namingIdKebabCase } from './naming-id-kebab-case.js';\nimport { descriptionsRequired } from './descriptions-required.js';\nimport { ownershipRequired } from './ownership-required.js';\nimport { referencesResolvable } from './references-resolvable.js';\nimport { glossaryNoDuplicateTerms } from './glossary-no-duplicate-terms.js';\nimport { noSecrets } from './no-secrets.js';\nimport { osiValidSchema } from './osi-valid-schema.js';\nimport { governanceModelExists } from './governance-model-exists.js';\nimport { governanceDatasetsExist } from './governance-datasets-exist.js';\nimport { governanceFieldsExist } from './governance-fields-exist.js';\nimport { governanceGrainRequired } from './governance-grain-required.js';\nimport { governanceSecurityRequired } from './governance-security-required.js';\n\n// Silver rules\nimport { governanceTrustRequired } from './governance-trust-required.js';\nimport { governanceRefreshRequired } from './governance-refresh-required.js';\nimport { lineageUpstreamRequired } from './lineage-upstream-required.js';\n\n// Gold rules\nimport { governanceSemanticRoleRequired } from './governance-semantic-role-required.js';\nimport { governanceAggregationRequired } from './governance-aggregation-required.js';\nimport { governanceAdditiveRequired } from './governance-additive-required.js';\nimport { rulesGoldenQueriesMinimum } from './rules-golden-queries-minimum.js';\nimport { rulesBusinessRulesExist } from './rules-business-rules-exist.js';\nimport { rulesGuardrailsExist } from './rules-guardrails-exist.js';\nimport { rulesHierarchiesExist } from './rules-hierarchies-exist.js';\n\n// Composite tier rules\nimport { tierBronze } from './tier-bronze.js';\nimport { tierSilver } from './tier-silver.js';\nimport { tierGold } from './tier-gold.js';\n\nexport {\n // Bronze\n namingIdKebabCase,\n descriptionsRequired,\n ownershipRequired,\n referencesResolvable,\n glossaryNoDuplicateTerms,\n noSecrets,\n osiValidSchema,\n governanceModelExists,\n governanceDatasetsExist,\n governanceFieldsExist,\n governanceGrainRequired,\n governanceSecurityRequired,\n // Silver\n governanceTrustRequired,\n governanceRefreshRequired,\n lineageUpstreamRequired,\n // Gold\n governanceSemanticRoleRequired,\n governanceAggregationRequired,\n governanceAdditiveRequired,\n rulesGoldenQueriesMinimum,\n rulesBusinessRulesExist,\n rulesGuardrailsExist,\n rulesHierarchiesExist,\n // Composite tier\n tierBronze,\n tierSilver,\n tierGold,\n};\n\nexport const ALL_RULES: LintRule[] = [\n // Bronze (12)\n namingIdKebabCase,\n descriptionsRequired,\n ownershipRequired,\n referencesResolvable,\n glossaryNoDuplicateTerms,\n noSecrets,\n osiValidSchema,\n governanceModelExists,\n governanceDatasetsExist,\n governanceFieldsExist,\n governanceGrainRequired,\n governanceSecurityRequired,\n // Silver (3)\n governanceTrustRequired,\n governanceRefreshRequired,\n lineageUpstreamRequired,\n // Gold (7)\n governanceSemanticRoleRequired,\n governanceAggregationRequired,\n governanceAdditiveRequired,\n rulesGoldenQueriesMinimum,\n rulesBusinessRulesExist,\n rulesGuardrailsExist,\n rulesHierarchiesExist,\n // Composite tier (3)\n tierBronze,\n tierSilver,\n tierGold,\n];\n","import type { ContextKitConfig } from '../types/config.js';\n\nexport const DEFAULT_CONFIG: ContextKitConfig = {\n context_dir: 'context',\n output_dir: 'dist',\n};\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as yaml from 'yaml';\nimport { contextKitConfigSchema } from '../schema/config.js';\nimport type { ContextKitConfig } from '../types/config.js';\nimport { DEFAULT_CONFIG } from './defaults.js';\n\nconst CONFIG_FILENAME = 'contextkit.config.yaml';\n\n/**\n * Load the ContextKit configuration from a root directory.\n *\n * Reads `contextkit.config.yaml` from `rootDir`, parses YAML, validates via\n * the Zod config schema, and merges with defaults. Returns `DEFAULT_CONFIG`\n * when no config file is found.\n */\nexport function loadConfig(rootDir: string): ContextKitConfig {\n const configPath = path.join(rootDir, CONFIG_FILENAME);\n\n if (!fs.existsSync(configPath)) {\n return { ...DEFAULT_CONFIG };\n }\n\n const raw = fs.readFileSync(configPath, 'utf-8');\n const parsed = yaml.parse(raw);\n\n // Empty file or YAML that parses to null/undefined\n if (parsed == null) {\n return { ...DEFAULT_CONFIG };\n }\n\n // Validate with Zod — .parse() will throw on invalid data.\n // The schema has .default() on context_dir and output_dir, so\n // partial configs get those filled in automatically.\n const validated = contextKitConfigSchema.parse(parsed);\n\n return validated as ContextKitConfig;\n}\n","import type { Diagnostic, TextEdit } from '../types/index.js';\n\n/**\n * Apply auto-fixes from diagnostics, returning a map of file path to new content.\n *\n * Edits are grouped by file, sorted in reverse order (bottom-to-top, right-to-left),\n * and applied sequentially so that earlier positions remain stable.\n */\nexport function applyFixes(\n diagnostics: Diagnostic[],\n readFile: (path: string) => string,\n): Map<string, string> {\n // Collect all edits grouped by file\n const editsByFile = new Map<string, TextEdit[]>();\n\n for (const diag of diagnostics) {\n if (!diag.fixable || !diag.fix) continue;\n\n const file = diag.location.file;\n if (!editsByFile.has(file)) {\n editsByFile.set(file, []);\n }\n const fileEdits = editsByFile.get(file)!;\n for (const edit of diag.fix.edits) {\n fileEdits.push(edit);\n }\n }\n\n // Apply edits per file\n const result = new Map<string, string>();\n\n for (const [file, edits] of editsByFile) {\n // Sort edits in reverse order: by startLine descending, then startCol descending.\n // This ensures bottom-to-top, right-to-left application so earlier positions stay valid.\n edits.sort((a, b) => {\n if (a.startLine !== b.startLine) return b.startLine - a.startLine;\n return b.startCol - a.startCol;\n });\n\n const content = readFile(file);\n const lines = content.split('\\n');\n\n for (const edit of edits) {\n applyEdit(lines, edit);\n }\n\n result.set(file, lines.join('\\n'));\n }\n\n return result;\n}\n\n/**\n * Apply a single TextEdit to an array of lines (mutates in place).\n * Lines and columns are 1-indexed.\n */\nfunction applyEdit(lines: string[], edit: TextEdit): void {\n const { startLine, startCol, endLine, endCol, newText } = edit;\n\n // Convert to 0-indexed\n const sl = startLine - 1;\n const el = endLine - 1;\n\n // Build the new content: prefix of start line + newText + suffix of end line\n const prefix = lines[sl]!.slice(0, startCol - 1);\n const suffix = lines[el]!.slice(endCol - 1);\n const replacement = prefix + newText + suffix;\n\n // Replace the affected line range with the replacement (which may contain newlines)\n const newLines = replacement.split('\\n');\n lines.splice(sl, el - sl + 1, ...newLines);\n}\n"]}
|