ktxby Kaelio
Docs
Concepts

Context as Code

Treat analytics context like code - version it, review it, merge it.

The idea

dbt moved analytics transformations into git. ktx applies the same pattern to analytics context: metric definitions, joins, business rules, wiki pages, and ingest decisions become files that can be reviewed, merged, and audited.

BeforeWith ktx
Context scattered across BI tools, chats, docs, and analyst memoryContext lives in YAML and Markdown
Agent changes are hard to inspectAgent changes are git diffs
Imports overwrite local judgmentIngest reconciles with existing files
History depends on tool logsHistory lives in commits and transcripts

Auto-ingestion

Most context already exists in dbt manifests, LookML, MetricFlow, Metabase, Notion, warehouse metadata, and analyst notes. ktx reads those inputs through connectors, then reconciles them into local files.

output
context sources -> connectors -> reconciliation agent -> YAML + Markdown diffs
StepWhat happensOutput
ExtractConnectors read models, metrics, questions, schemas, and docsStructured metadata
ReconcileThe agent compares incoming facts with existing contextCreate, update, skip, or flag
Writektx saves changed semantic sources and wiki pagesReviewable project files

Reconciliation is the key difference from a sync. ktx preserves accepted local edits, fills gaps, and surfaces conflicts instead of blindly overwriting files.

The git workflow

Run ingestion on a branch, review the changed YAML and Markdown, then merge the accepted context the same way you merge dbt or application code.

output
dbt / BI / docs / warehouse
          |
          v
   ktx ingest --all
          |
          v
 branch: ingest/nightly
          |
          v
   semantic diff in PR
          |
          v
 approve and merge
          |
          v
 agents read updated files

Typical review checklist:

  • new sources match the warehouse and source-tool evidence;
  • joins have the right relationship direction;
  • generated measures match business definitions;
  • wiki pages capture caveats without duplicating YAML;
  • .ktx/ runtime state stays out of git unless your team intentionally reviews a report or transcript.

Teams often run ingestion on demand during setup, then schedule ktx ingest --all --no-input on an ingest branch once the source is stable.

Feedback loops

Context improves when human corrections and agent signals flow back into the same reviewed files.

SignalExampleWhere it lands
Analyst correctionA measure excludes test accountssemantic-layer/**/*.yaml
Business clarificationARR changed definition this quarterwiki/**/*.md
Agent query issueA filter returns no rows unexpectedlyWiki caveat or tighter source filter
Join problemA path duplicates order-level measuresRelationship metadata or grain fix

Accepted corrections become input to the next ingest run. That makes the context layer converge toward the team's current source of truth.

Deterministic replay

Every ingestion session records the connector inputs, tool calls, LLM responses, write decisions, and reasoning behind each change.

Use caseWhat replay gives you
DebuggingTrace a bad source, join, or measure back to the input that produced it
TrustShow where a definition came from and who reviewed the resulting diff
ReproducibilityCompare old and new ingest behavior after config or model changes

Commit the YAML and Markdown changes. Commit reports or transcripts only when they are part of your team's review workflow.

Agent usage notes

Use this page when an agent needs to explain review workflows, ingestion diffs, replayability, or why ktx writes YAML and Markdown instead of hiding context in a hosted service.

Agent taskRelevant sectionNext page
Explain how generated context should be reviewedThe git workflowBuilding Context
Diagnose why ingestion changed a semantic sourceAuto-ingestion / Deterministic replayktx ingest
Explain how context improves over timeFeedback loopsBuilding Context
Tell a user what to commitThe git workflowWriting Context