import type { ReactNode } from "react"; const sourceInputs = [ { name: "Warehouse schema", detail: "tables, columns, types, constraints, row counts", signal: "grounds definitions in live database structure", accent: "border-fd-primary", }, { name: "Metabase and query history", detail: "historic SQL, questions, dashboards, usage patterns", signal: "extracts joins, filters, grain, and trusted examples", accent: "border-orange-500", }, { name: "dbt, MetricFlow, LookML", detail: "models, metrics, dimensions, explores, joins", signal: "maps existing modeling logic into semantic entities", accent: "border-amber-500", }, { name: "Company documentation", detail: "Notion pages, policies, caveats, analyst notes", signal: "links business language back to semantic references", accent: "border-slate-500 dark:border-cyan-200", }, ]; 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 (

Product mechanics

A semantic compiler for analytics agents

KTX builds typed semantic files, links wiki context back to those entities, validates the model against database evidence, then compiles agent requests into executable SQL.

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

{source.name}

{source.detail}

{source.signal}

))}
KTX builds the model

Ingest pipeline

    {ingestSteps.map((step, index) => ( ))}
{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 CodeBox({ children }: { children: ReactNode }) { return (
    {children}
    ); }