import type { ReactNode } from "react"; type SourceInput = { name: string; sources: string[]; detail: string; signal: string; accent: string; }; const sourceInputs = [ { name: "Database structure", sources: [ "Postgres", "Snowflake", "BigQuery", "and many others", ], detail: "tables, columns, types, constraints, row counts", signal: "grounds definitions in live database structure", accent: "border-fd-primary", }, { name: "BI and usage evidence", sources: ["Metabase", "Looker"], detail: "historic SQL, questions, dashboards, usage patterns", signal: "extracts joins, filters, grain, and trusted examples", accent: "border-orange-500", }, { name: "Semantic modeling", sources: ["dbt", "MetricFlow", "LookML"], detail: "models, metrics, dimensions, explores, joins", signal: "maps existing modeling logic into semantic entities", accent: "border-amber-500", }, { name: "Company documentation", sources: ["Notion"], detail: "Notion pages, policies, caveats", signal: "links business language back to semantic references", accent: "border-slate-500 dark:border-cyan-200", }, ] satisfies SourceInput[]; const ingestSteps = [ { title: "extract evidence", body: "Pull structured facts from schemas, SQL, BI metadata, and docs.", }, { title: "reconcile entities", body: "Merge names, measures, joins, and caveats into one project model.", }, { title: "validate references", body: "Check semantic fields and joins against database context before agents use them.", }, ]; const artifacts = [ { path: "semantic-layer/*.yaml", title: "Typed query model", body: "sources, grain, joins, dimensions, measures, filters, segments", }, { path: "wiki/*.md", title: "Business context", body: "rules and caveats with sl_refs back to semantic-layer entities", }, { path: "raw-sources/", title: "Evidence trail", body: "scan artifacts, extracted metadata, relationship evidence", }, { path: ".ktx/", title: "Local indexes", body: "embeddings and search indexes, not the source of truth", }, ]; const runtimeSteps = [ { title: "Search wiki", body: "Find business rules, caveats, synonyms, and sl_refs.", }, { title: "Resolve semantic refs", body: "Map measure and dimension names to approved entities.", }, { title: "Validate fields", body: "Check source, columns, joins, grain, filters, and segments.", }, { title: "Build query plan", body: "Create a semantic query plan before SQL is generated.", }, { title: "Compile dialect SQL", body: "Generate warehouse-shaped SQL instead of copying examples.", }, { title: "Execute with bounds", body: "Optionally run with bounded rows and return provenance.", }, ]; export function ProductMechanics() { return (

How KTX works

KTX reads source evidence, writes local context files, and gives agents semantic search, validation, SQL, and provenance.

); } function IngestionDiagram() { return (
Inputs KTX reads
{sourceInputs.map((source) => (

{source.name}

{source.detail}

{source.signal}

))}
KTX transforms evidence

KTX builds the model

    {ingestSteps.map((step, index) => ( ))}

Outputs KTX writes

{artifacts.map((artifact) => ( ))}
); } function RuntimeDiagram() { return (
Agent sends
connection: warehouse
measure: orders.total_revenue
dimension: customers.segment
filter: orders.created_date >= '2024-01-01'

This is the API surface agents should use: compact semantic intent, not hand-written warehouse SQL.

KTX planning and execution
    {runtimeSteps.map((step, index) => ( ))}
Semantic query plan

source:{" "} orders joined to customers as many_to_one

measure:{" "} total_revenue = sum(amount) with refund filter

grain: segment group-by with date predicate

result: dialect SQL, bounded rows, and provenance

KTX returns
select
customers.segment,
sum(orders.amount) as total_revenue
from analytics.orders
join analytics.customers
on orders.customer_id = customers.id
where orders.status != 'refunded'
and orders.created_date >= '2024-01-01'
group by 1

The output can be SQL-only or executed results with provenance, so the agent can show where the answer came from.

); } function DiagramHeader({ body, eyebrow, id, title, }: { body: string; eyebrow: string; id: string; title: string; }) { return (

{eyebrow}

{title}

{body}

); } function Artifact({ body, path, title, }: { body: string; path: string; title: string; }) { return (

{path}

{title}

{body}

); } function PipelineStep({ body, dark = false, index, title, }: { body: string; dark?: boolean; index: number; title: string; }) { return (
  • {index} {title} {body}
  • ); } function ColumnLabel({ children }: { children: ReactNode }) { return (

    {children}

    ); } function SourceList({ sources, }: { sources: string[]; }) { return (

    Sources

    {sources.map((source) => source === "and many others" ? ( {source} ) : ( {source} ), )}
    ); } function CodeBox({ children }: { children: ReactNode }) { return (
    {children}
    ); }