ktx/python/ktx-daemon
Andrey Avtomonov b0dd13ce7c
feat(telemetry): anonymous posthog usage telemetry across node cli and python daemon (#205)
* feat: add telemetry phase 1

* feat: add node telemetry event catalog

* feat: add telemetry event helpers

* feat: emit setup and connection telemetry

* feat: emit connection and stack telemetry

* feat: emit ingest and scan telemetry

* feat: emit query telemetry

* feat: emit sampled mcp telemetry

* docs: expand telemetry event catalog

* feat: add telemetry schema sync artifact

* feat: pass telemetry project id to semantic daemon

* feat: add daemon telemetry foundation

* feat: emit semantic daemon telemetry

* feat: emit daemon lifecycle telemetry

* docs: document full telemetry event catalog

* feat(telemetry): dim first-run notice

* feat(telemetry): show first-run notice before command output

* feat(telemetry): wire ktx PostHog project for live ingestion

* docs(telemetry): drop posthog project name and host from storage section

* docs(telemetry): trim to general overview and disclaimer

* docs(agents): add short telemetry guidelines

* feat(telemetry): enable posthog geoip enrichment

* docs(telemetry): drop ip-geoip note from public overview

* refactor(telemetry): drop no-op groupIdentify, rely on capture groups field

* fix(telemetry): respect CI kill switch in python daemon identity

* fix(sql): route table-count analysis to existing analyze-batch endpoint

* fix(telemetry): emit install_first_run from notice path and derive flagsPresent from commander

* fix(telemetry): read package info via getKtxCliPackageInfo to satisfy boundary check

* fix(telemetry): make python identity env={} bypass os.environ and unset CI in tests

* fix(telemetry): unset CI kill switch in cli-program-telemetry tests
2026-05-22 18:18:47 +02:00
..
src/ktx_daemon feat(telemetry): anonymous posthog usage telemetry across node cli and python daemon (#205) 2026-05-22 18:18:47 +02:00
tests feat(telemetry): anonymous posthog usage telemetry across node cli and python daemon (#205) 2026-05-22 18:18:47 +02:00
pyproject.toml feat(telemetry): anonymous posthog usage telemetry across node cli and python daemon (#205) 2026-05-22 18:18:47 +02:00
README.md chore(workspace): gate dead-code with knip production mode (#196) 2026-05-21 15:28:58 +02:00

ktx-daemon

ktx-daemon is the portable Python compute package for KTX.

It supports portable compute in two modes:

  • One-shot commands, used by default by the @kaelio/ktx CLI.
  • An explicit HTTP server for long-running local MCP sessions.

One-shot semantic query

printf '%s\n' '{"sources":[],"query":{"measures":[],"dimensions":[]},"dialect":"postgres"}' \
  | ktx-daemon semantic-query

One-shot source generation

Generate semantic-layer sources from schema scan data:

printf '%s\n' '{"tables":[{"name":"orders","db":"public","columns":[{"name":"id","type":"integer","primary_key":true}]}],"links":[],"dialect":"postgres"}' \
  | ktx-daemon semantic-generate-sources

One-shot database introspection

Introspect a Postgres database schema:

printf '%s\n' '{"connection_id":"warehouse","driver":"postgres","url":"postgresql://readonly@example.test/warehouse","schemas":["public"]}' \
  | ktx-daemon database-introspect

One-shot LookML parsing

Parse LookML projects into resolved, KSL-ready structures:

printf '%s\n' '{"files":[{"path":"views/orders.view.lkml","content":"view: orders { sql_table_name: public.orders ;; measure: order_count { type: count } }"}],"dialect":"postgres"}' \
  | ktx-daemon lookml-parse

One-shot embeddings

Compute text embeddings locally:

printf '%s\n' '{"text":"hello"}' \
  | ktx-daemon embedding-compute

Compute text embeddings locally in bulk:

printf '%s\n' '{"texts":["hello","world"]}' \
  | ktx-daemon embedding-compute-bulk

One-shot code execution

Execute Python code with the current in-process boundary:

printf '%s\n' '{"code":"result = 1 + 2"}' \
  | ktx-daemon code-execute

HTTP compute server

Start the HTTP compute server with code execution disabled:

ktx-daemon serve-http --host 127.0.0.1 --port 8765

Enable HTTP code execution explicitly:

ktx-daemon serve-http --host 127.0.0.1 --port 8765 --enable-code-execution

Available HTTP endpoints:

  • GET /health
  • POST /database/introspect
  • POST /embeddings/compute
  • POST /embeddings/compute-bulk
  • POST /lookml/parse
  • POST /semantic-layer/generate-sources
  • POST /semantic-layer/query
  • POST /semantic-layer/validate
  • POST /code/execute when --enable-code-execution is passed

The HTTP server exposes Postgres database introspection, LookML parsing, local embedding compute, and semantic-layer compute for source generation, query compilation, and validation. Code execution is off by default. When enabled, it runs Python exec in the daemon process with the same in-process boundary as the one-shot code-execute command and does not provide OS-level sandboxing.

HTTP code execution uses the standalone KTX boundary. It does not forward caller authorization headers to a host app and does not connect scratchpad or visualization helpers to host application APIs.