2026-05-10 23:12:26 +02:00
|
|
|
import assert from 'node:assert/strict';
|
|
|
|
|
import { readFile } from 'node:fs/promises';
|
|
|
|
|
import { describe, it } from 'node:test';
|
|
|
|
|
|
|
|
|
|
async function readText(relativePath) {
|
|
|
|
|
return readFile(new URL(`../${relativePath}`, import.meta.url), 'utf8');
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-11 15:50:34 +02:00
|
|
|
function publicNpmPackageName() {
|
|
|
|
|
return `@${['kae', 'lio'].join('')}/ktx`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function runtimeWheelPackageName() {
|
|
|
|
|
return `${['kae', 'lio'].join('')}-ktx`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function escapeRegExp(value) {
|
|
|
|
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function publicPackagePattern(text) {
|
|
|
|
|
return new RegExp(text.replaceAll('{package}', escapeRegExp(publicNpmPackageName())));
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-10 23:12:26 +02:00
|
|
|
describe('standalone example docs', () => {
|
|
|
|
|
it('documents the local warehouse example from the examples index', async () => {
|
|
|
|
|
const examples = await readText('examples/README.md');
|
|
|
|
|
|
|
|
|
|
assert.match(examples, /local-warehouse/);
|
|
|
|
|
assert.match(examples, /fake ingest adapter/);
|
|
|
|
|
assert.doesNotMatch(examples, /will contain standalone examples/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('documents the Orbit relationship verification example project', async () => {
|
|
|
|
|
const examples = await readText('examples/README.md');
|
|
|
|
|
const readme = await readText('examples/orbit-relationship-verification/README.md');
|
2026-05-10 23:51:24 +02:00
|
|
|
const config = await readText('examples/orbit-relationship-verification/ktx.yaml');
|
2026-05-10 23:12:26 +02:00
|
|
|
|
|
|
|
|
assert.match(examples, /orbit-relationship-verification/);
|
|
|
|
|
assert.match(examples, /relationships:verify-orbit/);
|
|
|
|
|
assert.match(readme, /Orbit-style relationship discovery verification/);
|
|
|
|
|
assert.match(readme, /pnpm run relationships:verify-orbit/);
|
|
|
|
|
assert.match(readme, /Accepted: 9/);
|
|
|
|
|
assert.match(readme, /Review: 0/);
|
|
|
|
|
assert.match(readme, /Rejected: 0/);
|
2026-05-14 17:39:31 +02:00
|
|
|
assert.doesNotMatch(config, /^project:/m);
|
2026-05-10 23:12:26 +02:00
|
|
|
assert.match(config, /orbit:/);
|
|
|
|
|
assert.match(config, /driver: sqlite/);
|
|
|
|
|
assert.match(
|
|
|
|
|
config,
|
|
|
|
|
/path: \.\.\/\.\.\/packages\/context\/test\/fixtures\/relationship-benchmarks\/orbit_style_product_no_declared_constraints\/data\.sqlite/,
|
|
|
|
|
);
|
2026-05-14 15:36:35 +02:00
|
|
|
assert.match(config, /llmProposals: false/);
|
|
|
|
|
assert.match(config, /validationRequiredForManifest: true/);
|
2026-05-10 23:12:26 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('documents the Postgres historic SQL smoke example', async () => {
|
|
|
|
|
const examples = await readText('examples/README.md');
|
|
|
|
|
const readme = await readText('examples/postgres-historic/README.md');
|
|
|
|
|
const compose = await readText('examples/postgres-historic/docker-compose.yml');
|
|
|
|
|
const initSql = await readText('examples/postgres-historic/init/001-schema.sql');
|
|
|
|
|
const workload = await readText('examples/postgres-historic/scripts/generate-workload.sh');
|
|
|
|
|
const smoke = await readText('examples/postgres-historic/scripts/smoke.sh');
|
|
|
|
|
|
|
|
|
|
assert.match(examples, /postgres-historic/);
|
2026-05-14 01:43:06 +02:00
|
|
|
assert.doesNotMatch(examples, /Historic SQL/);
|
|
|
|
|
assert.doesNotMatch(examples, /historic-SQL/);
|
|
|
|
|
assert.match(examples, /query-history ingest via `pg_stat_statements`/);
|
|
|
|
|
assert.doesNotMatch(readme, new RegExp(['--enable-historic', 'sql'].join('-')));
|
|
|
|
|
assert.doesNotMatch(readme, new RegExp(['--historic', 'sql-min-executions'].join('-')));
|
|
|
|
|
assert.doesNotMatch(readme, /ktx ingest run --project-dir/);
|
|
|
|
|
assert.doesNotMatch(readme, /--adapter historic-sql/);
|
|
|
|
|
assert.match(readme, /--enable-query-history/);
|
|
|
|
|
assert.match(readme, /--query-history-min-executions 2/);
|
2026-05-12 23:51:46 +02:00
|
|
|
assert.match(readme, /ktx status --project-dir/);
|
2026-05-14 01:43:06 +02:00
|
|
|
assert.match(readme, /Postgres query history/);
|
2026-05-11 19:39:21 +02:00
|
|
|
assert.match(readme, /manifest\.json/);
|
|
|
|
|
assert.match(readme, /tables\/\*\.json/);
|
|
|
|
|
assert.match(readme, /patterns-input\.json/);
|
2026-05-11 20:30:14 +02:00
|
|
|
assert.match(readme, /patterns-input\/part-\*\.json/);
|
|
|
|
|
assert.match(readme, /full audit input/);
|
|
|
|
|
assert.match(readme, /bounded pattern WorkUnit shards/);
|
2026-05-11 19:39:21 +02:00
|
|
|
assert.match(readme, /workUnitCount: 0/);
|
2026-05-10 23:12:26 +02:00
|
|
|
assert.match(compose, /postgres:14/);
|
|
|
|
|
assert.match(compose, /shared_preload_libraries=pg_stat_statements/);
|
|
|
|
|
assert.match(compose, /pg_stat_statements.track=top/);
|
|
|
|
|
assert.match(initSql, /CREATE EXTENSION IF NOT EXISTS pg_stat_statements/);
|
2026-05-10 23:51:24 +02:00
|
|
|
assert.match(initSql, /GRANT pg_read_all_stats TO ktx_reader/);
|
2026-05-10 23:12:26 +02:00
|
|
|
assert.match(workload, /JOIN customers/);
|
|
|
|
|
assert.match(workload, /app_user/);
|
|
|
|
|
assert.match(workload, /etl_user/);
|
2026-05-11 19:39:21 +02:00
|
|
|
assert.match(smoke, /assert_unified_snapshot/);
|
|
|
|
|
assert.match(smoke, /assert_stage_record "\$UNCHANGED_RECORD" unchanged zero/);
|
2026-05-11 20:30:14 +02:00
|
|
|
assert.match(smoke, /assertPatternShards/);
|
|
|
|
|
assert.match(smoke, /historic-sql-patterns-part-/);
|
|
|
|
|
assert.match(smoke, /patterns-input\/part-/);
|
2026-05-11 20:32:32 +02:00
|
|
|
assert.doesNotMatch(smoke, new RegExp(["unitKey === 'historic", 'sql', "patterns'"].join('-')));
|
2026-05-14 01:43:06 +02:00
|
|
|
assert.match(smoke, /--query-history-min-executions 2/);
|
2026-05-11 15:50:34 +02:00
|
|
|
assert.match(smoke, /KTX_RUNTIME_ROOT/);
|
|
|
|
|
assert.match(smoke, /managedDaemon/);
|
|
|
|
|
assert.match(smoke, /installPolicy: 'auto'/);
|
|
|
|
|
assert.match(smoke, /getKtxCliPackageInfo/);
|
|
|
|
|
assert.doesNotMatch(smoke, /python-service/);
|
|
|
|
|
assert.doesNotMatch(smoke, /PYTHON_SERVICE/);
|
|
|
|
|
assert.doesNotMatch(smoke, /uvicorn app\.main:app/);
|
|
|
|
|
assert.doesNotMatch(smoke, /export KTX_SQL_ANALYSIS_URL/);
|
2026-05-11 19:42:51 +02:00
|
|
|
assert.doesNotMatch(
|
|
|
|
|
smoke,
|
|
|
|
|
new RegExp(
|
|
|
|
|
[
|
|
|
|
|
['baseline', 'FirstRun'],
|
|
|
|
|
['de', 'graded'],
|
|
|
|
|
['stats', 'ResetAt'],
|
|
|
|
|
['assert', '_manifest'],
|
|
|
|
|
]
|
|
|
|
|
.map((parts) => parts.join(''))
|
|
|
|
|
.join('|'),
|
|
|
|
|
),
|
|
|
|
|
);
|
2026-05-11 15:50:34 +02:00
|
|
|
assert.doesNotMatch(readme, /python-service/);
|
|
|
|
|
assert.doesNotMatch(readme, /KTX_SQL_ANALYSIS_URL/);
|
2026-05-11 19:42:51 +02:00
|
|
|
assert.doesNotMatch(
|
|
|
|
|
readme,
|
|
|
|
|
new RegExp(
|
|
|
|
|
[
|
|
|
|
|
['baseline', 'FirstRun'],
|
|
|
|
|
['de', 'graded: true'],
|
|
|
|
|
['stats', 'ResetAt'],
|
|
|
|
|
['fresh PGSS', ' baseline'],
|
|
|
|
|
['delta', '-only'],
|
|
|
|
|
]
|
|
|
|
|
.map((parts) => parts.join(''))
|
|
|
|
|
.join('|'),
|
|
|
|
|
),
|
|
|
|
|
);
|
2026-05-10 23:12:26 +02:00
|
|
|
});
|
|
|
|
|
|
2026-05-14 01:43:06 +02:00
|
|
|
it('checked-in example configs do not include public database adapters', async () => {
|
|
|
|
|
const localWarehouseConfig = await readFile('examples/local-warehouse/ktx.yaml', 'utf8');
|
|
|
|
|
const orbitConfig = await readFile('examples/orbit-relationship-verification/ktx.yaml', 'utf8');
|
|
|
|
|
const legacyPublicAdapter = new RegExp(['live', 'database'].join('-'));
|
|
|
|
|
|
|
|
|
|
assert.doesNotMatch(localWarehouseConfig, legacyPublicAdapter);
|
|
|
|
|
assert.doesNotMatch(orbitConfig, legacyPublicAdapter);
|
|
|
|
|
});
|
|
|
|
|
|
chore(workspace): gate dead-code with knip production mode (#196)
* refactor(workspace): relocate @ktx/llm source into packages/cli/src/llm
* refactor(workspace): rewrite @ktx/llm imports to relative paths
* refactor(workspace): fold internal packages into cli
* chore(workspace): gate dead-code with knip production mode
Turn on production-mode knip plus an autofix run in pre-commit and the
`pnpm dead-code` script, document the `/** @internal */` convention for
test-only exports in AGENTS.md, annotate test-only exports across the
CLI with that JSDoc, and drop dead exports/wrappers the new gate
surfaced (e.g. `cli-project.ts`, `lookerRuntimeSourceToFileAdapterSource`,
`createLocalScanEnrichmentProvidersFromConfig`,
`PGLITE_OWNER_PROCESS_BACKEND_CAPABILITIES`, stale type re-exports).
Replace the loose `ignoreIssues` allowlist in `knip.json` with explicit
production entries so cross-package barrel leaks are caught.
* refactor(cli): delete internal barrel index.ts files
The 34 `index.ts` re-export barrels inside `packages/cli/src/` were
holdovers from the pre-fold multi-workspace structure. Post-fold-in they
served no production purpose: external consumers go through the single
package main entry, and in-repo callers mostly imported through them
only because the path was short. Internally, knip flagged most barrel
re-exports as production-dead (only reached via tests).
This change:
- Deletes every internal barrel except `packages/cli/src/index.ts`
(the published package entry).
- Rewrites ~270 source/test files to import each name directly from
the file that defines it.
- Moves `tools/warehouse-verification/index.ts` to
`create-warehouse-verification-tools.ts` (the function it defined
locally) and updates its single consumer.
- Renames `search/backend-conformance.ts` → `.test-utils.ts` to match
the existing test-helper file convention.
- Deletes 13 dead test-only chains (dbt-descriptions/*,
live-database/extracted-schema, live-database/structural-sync,
relationship-* feedback/review chain) plus their tests and a
cascading orphan integration test.
- Updates test mocks that pointed at deleted barrel paths
(notion-client, connector barrels in scan/local-scan-connectors
tests) to mock the source files instead.
- Points the maintainer benchmark script
(`scripts/relationship-benchmark-report.mjs`) at source files
instead of `dist/context/scan/index.js`.
- Drops the barrel `!` entries from `knip.json`; adds explicit
production entries only for the benchmark code reached via dist by
the maintainer script.
Net: 413 files changed, ~1.2k insertions, ~9.4k deletions.
`pnpm run dead-code` (Biome + knip default + knip production) and
`pnpm run type-check` are clean; 2277 tests pass.
* refactor(workspace): rename @ktx/cli to @kaelio/ktx and pack it directly
Promote the CLI workspace package to the public name `@kaelio/ktx` and
drop the separate `scripts/build-public-npm-package.mjs` wrapper. The
CLI package is now publishable in place (`publishConfig.access: public`,
`provenance: true`), so artifact packing uses `pnpm pack` against
`packages/cli/` instead of assembling a parallel package tree.
Updates all workspace filter invocations, docs, tests, and release
readiness checks to reference the new package name, and folds the
tarball-name helper into `scripts/public-npm-release-metadata.mjs`.
* docs: align "agent clients" and "data agents" terminology
Replace "client agents" with "agent clients" and "database agents" with
"data agents" across AGENTS.md, README.md, the docs-site copy, and the
matching setup-agents test description, matching the canonical
vocabulary in docs/terminology.md.
Also moves packages/cli/tsconfig.json's tsBuildInfoFile from
node_modules/.cache/ to dist/.tsbuildinfo so incremental builds survive
node_modules reinstalls.
* refactor(release): single source of truth for package version
Make packages/cli/package.json the single source of truth for the
@kaelio/ktx version. publicNpmPackageVersion() now reads it directly,
so artifact filenames, release-readiness checks, and the Python wheel
version all derive from one field. The duplicate
release-policy.json.publicNpmPackageVersion is removed.
Previously the two fields could drift: tarballs were named
kaelio-ktx-0.4.1.tgz while internally containing
@kaelio/ktx@0.0.0-private.
- update-public-release-version.mjs rewrites both Python pyproject.toml
files (ktx-daemon, ktx-sl) alongside the npm package.jsons,
normalizing the version for PEP 440 (e.g. 0.1.0-rc.2 -> 0.1.0rc2).
- semantic-release-config.cjs adds the two pyproject.toml files to
@semantic-release/git assets so the release commit back to main
carries every version source in lockstep.
- The six "?? '0.0.0-private'" fallback literals across the CLI are
replaced with "?? getKtxCliPackageInfo().version", and
createDefaultKtxMcpServer makes its version arg required.
- docs/release.md describes the actual commit-back model: the dev tree
always reflects the most recent release; no sentinel pin to
maintain.
Verified: pnpm run artifacts:build now produces
kaelio-ktx-0.4.1.tgz and kaelio_ktx-0.4.1-py3-none-any.whl with
@kaelio/ktx@0.4.1 inside. Full type-check, dead-code, and
2287 vitests + 173 script tests pass.
* refactor(cli): inject embedding provider resolution and detect sentence-transformers runtime
Make resolveProjectEmbeddingProvider and runtimeIo injectable in ingest and
scan command entrypoints so tests can stub them, and teach
resolvePublicIngestRuntimeRequirements to flag the local-embeddings runtime
feature when ktx.yaml selects sentence-transformers.
* chore(cli): mark buildLocalStatsStatus and LocalStatsStatus as @internal
Both symbols are consumed only by status-project.test.ts. Annotating with
/** @internal */ keeps knip's production-mode check clean without changing
runtime behavior.
* fix(cli): use real package metadata in print-command-tree
The stubbed package name embedded a forbidden product identifier that
tripped the boundary check in CI. Read the metadata from package.json
instead — keeps the rendered tree unchanged and removes a duplicate
source of truth.
* feat(cli): show embedding coverage in `ktx status`, drop duplicate disk counts
Inline `(N embedded)` next to the Wiki scope counts and Semantic-layer
source counts, computed with `SUM(embedding_json IS NOT NULL)` over
`knowledge_pages` and `local_sl_sources`. Rename the "Knowledge" label to
"Wiki" (canonical per `docs/terminology.md`) and rename the matching
`localStats.knowledgePages` field to `localStats.wikiPages`.
Drop `wiki=N md` and `semantic-layer=N yaml` from the Disk row — those
duplicated the per-surface rows above. Disk now reports only actual byte
usage (db, cache, raw-sources). The unused `wikiGlobalMarkdownCount` /
`semanticLayerYamlCount` fields, the `isMarkdownEntry` / `isYamlEntry`
helpers, and the `filter` arg on `summarizeDir` are removed.
2026-05-21 15:28:58 +02:00
|
|
|
it('lists the consolidated workspace layout in the contributor docs', async () => {
|
2026-05-12 12:02:26 +02:00
|
|
|
const contributing = await readText('docs-site/content/docs/community/contributing.mdx');
|
2026-05-10 23:12:26 +02:00
|
|
|
|
chore(workspace): gate dead-code with knip production mode (#196)
* refactor(workspace): relocate @ktx/llm source into packages/cli/src/llm
* refactor(workspace): rewrite @ktx/llm imports to relative paths
* refactor(workspace): fold internal packages into cli
* chore(workspace): gate dead-code with knip production mode
Turn on production-mode knip plus an autofix run in pre-commit and the
`pnpm dead-code` script, document the `/** @internal */` convention for
test-only exports in AGENTS.md, annotate test-only exports across the
CLI with that JSDoc, and drop dead exports/wrappers the new gate
surfaced (e.g. `cli-project.ts`, `lookerRuntimeSourceToFileAdapterSource`,
`createLocalScanEnrichmentProvidersFromConfig`,
`PGLITE_OWNER_PROCESS_BACKEND_CAPABILITIES`, stale type re-exports).
Replace the loose `ignoreIssues` allowlist in `knip.json` with explicit
production entries so cross-package barrel leaks are caught.
* refactor(cli): delete internal barrel index.ts files
The 34 `index.ts` re-export barrels inside `packages/cli/src/` were
holdovers from the pre-fold multi-workspace structure. Post-fold-in they
served no production purpose: external consumers go through the single
package main entry, and in-repo callers mostly imported through them
only because the path was short. Internally, knip flagged most barrel
re-exports as production-dead (only reached via tests).
This change:
- Deletes every internal barrel except `packages/cli/src/index.ts`
(the published package entry).
- Rewrites ~270 source/test files to import each name directly from
the file that defines it.
- Moves `tools/warehouse-verification/index.ts` to
`create-warehouse-verification-tools.ts` (the function it defined
locally) and updates its single consumer.
- Renames `search/backend-conformance.ts` → `.test-utils.ts` to match
the existing test-helper file convention.
- Deletes 13 dead test-only chains (dbt-descriptions/*,
live-database/extracted-schema, live-database/structural-sync,
relationship-* feedback/review chain) plus their tests and a
cascading orphan integration test.
- Updates test mocks that pointed at deleted barrel paths
(notion-client, connector barrels in scan/local-scan-connectors
tests) to mock the source files instead.
- Points the maintainer benchmark script
(`scripts/relationship-benchmark-report.mjs`) at source files
instead of `dist/context/scan/index.js`.
- Drops the barrel `!` entries from `knip.json`; adds explicit
production entries only for the benchmark code reached via dist by
the maintainer script.
Net: 413 files changed, ~1.2k insertions, ~9.4k deletions.
`pnpm run dead-code` (Biome + knip default + knip production) and
`pnpm run type-check` are clean; 2277 tests pass.
* refactor(workspace): rename @ktx/cli to @kaelio/ktx and pack it directly
Promote the CLI workspace package to the public name `@kaelio/ktx` and
drop the separate `scripts/build-public-npm-package.mjs` wrapper. The
CLI package is now publishable in place (`publishConfig.access: public`,
`provenance: true`), so artifact packing uses `pnpm pack` against
`packages/cli/` instead of assembling a parallel package tree.
Updates all workspace filter invocations, docs, tests, and release
readiness checks to reference the new package name, and folds the
tarball-name helper into `scripts/public-npm-release-metadata.mjs`.
* docs: align "agent clients" and "data agents" terminology
Replace "client agents" with "agent clients" and "database agents" with
"data agents" across AGENTS.md, README.md, the docs-site copy, and the
matching setup-agents test description, matching the canonical
vocabulary in docs/terminology.md.
Also moves packages/cli/tsconfig.json's tsBuildInfoFile from
node_modules/.cache/ to dist/.tsbuildinfo so incremental builds survive
node_modules reinstalls.
* refactor(release): single source of truth for package version
Make packages/cli/package.json the single source of truth for the
@kaelio/ktx version. publicNpmPackageVersion() now reads it directly,
so artifact filenames, release-readiness checks, and the Python wheel
version all derive from one field. The duplicate
release-policy.json.publicNpmPackageVersion is removed.
Previously the two fields could drift: tarballs were named
kaelio-ktx-0.4.1.tgz while internally containing
@kaelio/ktx@0.0.0-private.
- update-public-release-version.mjs rewrites both Python pyproject.toml
files (ktx-daemon, ktx-sl) alongside the npm package.jsons,
normalizing the version for PEP 440 (e.g. 0.1.0-rc.2 -> 0.1.0rc2).
- semantic-release-config.cjs adds the two pyproject.toml files to
@semantic-release/git assets so the release commit back to main
carries every version source in lockstep.
- The six "?? '0.0.0-private'" fallback literals across the CLI are
replaced with "?? getKtxCliPackageInfo().version", and
createDefaultKtxMcpServer makes its version arg required.
- docs/release.md describes the actual commit-back model: the dev tree
always reflects the most recent release; no sentinel pin to
maintain.
Verified: pnpm run artifacts:build now produces
kaelio-ktx-0.4.1.tgz and kaelio_ktx-0.4.1-py3-none-any.whl with
@kaelio/ktx@0.4.1 inside. Full type-check, dead-code, and
2287 vitests + 173 script tests pass.
* refactor(cli): inject embedding provider resolution and detect sentence-transformers runtime
Make resolveProjectEmbeddingProvider and runtimeIo injectable in ingest and
scan command entrypoints so tests can stub them, and teach
resolvePublicIngestRuntimeRequirements to flag the local-embeddings runtime
feature when ktx.yaml selects sentence-transformers.
* chore(cli): mark buildLocalStatsStatus and LocalStatsStatus as @internal
Both symbols are consumed only by status-project.test.ts. Annotating with
/** @internal */ keeps knip's production-mode check clean without changing
runtime behavior.
* fix(cli): use real package metadata in print-command-tree
The stubbed package name embedded a forbidden product identifier that
tripped the boundary check in CI. Read the metadata from package.json
instead — keeps the rendered tree unchanged and removes a duplicate
source of truth.
* feat(cli): show embedding coverage in `ktx status`, drop duplicate disk counts
Inline `(N embedded)` next to the Wiki scope counts and Semantic-layer
source counts, computed with `SUM(embedding_json IS NOT NULL)` over
`knowledge_pages` and `local_sl_sources`. Rename the "Knowledge" label to
"Wiki" (canonical per `docs/terminology.md`) and rename the matching
`localStats.knowledgePages` field to `localStats.wikiPages`.
Drop `wiki=N md` and `semantic-layer=N yaml` from the Disk row — those
duplicated the per-surface rows above. Disk now reports only actual byte
usage (db, cache, raw-sources). The unused `wikiGlobalMarkdownCount` /
`semanticLayerYamlCount` fields, the `isMarkdownEntry` / `isYamlEntry`
helpers, and the `filter` arg on `summarizeDir` are removed.
2026-05-21 15:28:58 +02:00
|
|
|
assert.match(contributing, /cli\/\s+# CLI package and published npm package source/);
|
|
|
|
|
assert.match(contributing, /src\/context\/\s+# Core context engine/);
|
|
|
|
|
assert.match(contributing, /src\/llm\/\s+# LLM client abstraction/);
|
|
|
|
|
assert.match(contributing, /src\/connectors\/\s+# Database connectors/);
|
2026-05-12 12:02:26 +02:00
|
|
|
assert.match(contributing, /ktx-sl\/\s+# Semantic layer/);
|
|
|
|
|
assert.match(contributing, /ktx-daemon\/\s+# Daemon/);
|
2026-05-10 23:12:26 +02:00
|
|
|
});
|
|
|
|
|
|
2026-05-12 23:51:46 +02:00
|
|
|
it('documents agent-facing CLI commands', async () => {
|
2026-05-12 12:02:26 +02:00
|
|
|
const servingAgents = await readText('docs-site/content/docs/guides/serving-agents.mdx');
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-12 23:51:46 +02:00
|
|
|
for (const command of [
|
2026-05-13 13:01:56 +02:00
|
|
|
'ktx status --json',
|
2026-05-20 01:52:37 +02:00
|
|
|
'ktx sl --json',
|
|
|
|
|
'ktx sl "revenue" --json',
|
fix(context): merge overlay columns onto manifest columns by name (#94)
* fix(context): merge overlay columns onto manifest columns by name
composeOverlay was appending overlay columns to the manifest column list,
producing duplicate entries when dbt/metabase overlays declared a column
just to attach descriptions. The duplicates carried no `type`, so the
pydantic SourceDefinition rejected them at semantic-query time and broke
`ktx sl query` for every overlay-backed measure. Now overlay columns
match base columns by name (case-insensitive): same-name entries merge
onto the manifest (overlay fields win, type/role fall back to the base,
descriptions merge per source key) and only new names append.
* refactor(sl): split overlay columns from column_overrides and enforce TS/Python wire contract
Overlay sources now have two distinct collections: `columns:` for computed
columns (requiring `expr` + `type`) and `column_overrides:` for metadata
patches to inherited manifest columns. Composing or loading an overlay that
mixes the two — or references an unknown column — fails with a typed error.
Introduce `ResolvedSemanticLayerSource` / `resolvedSourceSchema` /
`toResolvedWire` as the strict shape sent to the Python engine, and add a
schema contract test that diffs Zod against the Pydantic JSON schema dumped
by `python -m semantic_layer dump-schema`. `SourceDefinition` is now
`extra="forbid"` on the Python side.
`loadAllSources` surfaces per-file load errors instead of swallowing them,
so validation/query paths can report manifest shard parse failures.
* fix(context): make scan description generation resilient and quiet
A transient sampleTable failure during ingest used to take out every
table in a connection: generateTableDescription returned a hardcoded
'Table not found' string into descriptions.ai, and KtxDescriptionGenerator
was constructed without a logger, so the failure left no trail anywhere.
- sampleTable / sampleColumn calls retry 3x with 200/400/800ms backoff,
honouring KtxScanContext.signal via a new KtxAbortedError.
- On retry exhaustion or missing capability, table generation falls back
to a metadata-only prompt built from column name / native type / comment
/ rawDescriptions. The column path follows the same rule -- call the
LLM when any of samples or rawDescriptions are available; skip only
when both are absent.
- Logger is now threaded from KtxScanContext into the generator. Failures
emit structured KtxScanWarning entries (new description_fallback_used
code, plus existing sampling_failed / enrichment_failed /
connector_capability_missing). ktx scan groups warnings by code so a
batch of identical failures collapses to one summary line plus sample.
- Returns null on failure instead of the 'Table not found' sentinel; the
manifest writer's existing guard already skips empty descriptions, so
schema YAML no longer carries misleading text. SCAN_MANAGED_DESCRIPTION_KEYS
already strips stale 'ai' on merge, so existing YAML clears on next run.
Also suppress AI SDK v6 'system in messages' warning: pull system messages
out of KtxMessageBuilder.wrapSimple's output via a new splitKtxSystemMessages
helper and pass them top-level to generateText (preserves cacheControl
providerOptions on the SystemModelMessage). Agent-runner's local
splitSystemPromptMessages dedupes onto the shared helper.
* test(docs): align examples-docs assertions with revamped docs
PR #103 (setup/guide doc revamp) reworded several CLI examples and
connection labels; the assertions in scripts/examples-docs.test.mjs
still referenced the pre-revamp wording and were failing in CI on main.
Update the regexes to match the post-revamp content:
- drop the `--json` flag from the sl-query example expectation
- move the `Driver:` / `Status: ok` probe to the connection reference,
which is where that output now lives (driver id is lowercase
`postgres`, not the display name `PostgreSQL`)
- drop the obsolete `Install \`uv\`...` troubleshooting line
- accept `<connectionId>` everywhere; the docs no longer use the
hyphenated `<connection-id>` form
- match the `warehouse` connection id used in the quickstart instead of
the `postgres-warehouse` id only used in the README and setup ref
* fix(sl): skip TS/Python schema contract test when uv is unavailable
The TypeScript checks CI job does not install uv or Python, so the
module-level `execFileSync('uv', ...)` in schemas.contract.test.ts threw
ENOENT and failed the suite. Wrap the schema dump in a try/catch and
guard the describe block with `describe.skipIf` so the test skips in
environments without uv. Local dev and any CI job that has uv on PATH
still runs the cross-language contract assertion.
2026-05-15 02:11:04 +02:00
|
|
|
'ktx sl query',
|
2026-05-20 01:52:37 +02:00
|
|
|
'ktx wiki "revenue recognition" --json',
|
2026-05-12 12:02:26 +02:00
|
|
|
]) {
|
2026-05-12 23:51:46 +02:00
|
|
|
assert.match(servingAgents, new RegExp(command.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
|
2026-05-12 12:02:26 +02:00
|
|
|
}
|
2026-05-10 23:12:26 +02:00
|
|
|
});
|
|
|
|
|
|
2026-05-12 12:02:26 +02:00
|
|
|
it('walks through connection testing in the quickstart and CLI reference', async () => {
|
|
|
|
|
const quickstart = await readText('docs-site/content/docs/getting-started/quickstart.mdx');
|
|
|
|
|
const connectionReference = await readText('docs-site/content/docs/cli-reference/ktx-connection.mdx');
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-12 12:02:26 +02:00
|
|
|
assert.match(connectionReference, /ktx connection list/);
|
|
|
|
|
assert.match(connectionReference, /ktx connection test my-warehouse/);
|
2026-05-14 12:53:55 -04:00
|
|
|
assert.match(connectionReference, /ktx connection test --all/);
|
2026-05-12 12:02:26 +02:00
|
|
|
assert.match(quickstart, /Connection test passed/);
|
fix(context): merge overlay columns onto manifest columns by name (#94)
* fix(context): merge overlay columns onto manifest columns by name
composeOverlay was appending overlay columns to the manifest column list,
producing duplicate entries when dbt/metabase overlays declared a column
just to attach descriptions. The duplicates carried no `type`, so the
pydantic SourceDefinition rejected them at semantic-query time and broke
`ktx sl query` for every overlay-backed measure. Now overlay columns
match base columns by name (case-insensitive): same-name entries merge
onto the manifest (overlay fields win, type/role fall back to the base,
descriptions merge per source key) and only new names append.
* refactor(sl): split overlay columns from column_overrides and enforce TS/Python wire contract
Overlay sources now have two distinct collections: `columns:` for computed
columns (requiring `expr` + `type`) and `column_overrides:` for metadata
patches to inherited manifest columns. Composing or loading an overlay that
mixes the two — or references an unknown column — fails with a typed error.
Introduce `ResolvedSemanticLayerSource` / `resolvedSourceSchema` /
`toResolvedWire` as the strict shape sent to the Python engine, and add a
schema contract test that diffs Zod against the Pydantic JSON schema dumped
by `python -m semantic_layer dump-schema`. `SourceDefinition` is now
`extra="forbid"` on the Python side.
`loadAllSources` surfaces per-file load errors instead of swallowing them,
so validation/query paths can report manifest shard parse failures.
* fix(context): make scan description generation resilient and quiet
A transient sampleTable failure during ingest used to take out every
table in a connection: generateTableDescription returned a hardcoded
'Table not found' string into descriptions.ai, and KtxDescriptionGenerator
was constructed without a logger, so the failure left no trail anywhere.
- sampleTable / sampleColumn calls retry 3x with 200/400/800ms backoff,
honouring KtxScanContext.signal via a new KtxAbortedError.
- On retry exhaustion or missing capability, table generation falls back
to a metadata-only prompt built from column name / native type / comment
/ rawDescriptions. The column path follows the same rule -- call the
LLM when any of samples or rawDescriptions are available; skip only
when both are absent.
- Logger is now threaded from KtxScanContext into the generator. Failures
emit structured KtxScanWarning entries (new description_fallback_used
code, plus existing sampling_failed / enrichment_failed /
connector_capability_missing). ktx scan groups warnings by code so a
batch of identical failures collapses to one summary line plus sample.
- Returns null on failure instead of the 'Table not found' sentinel; the
manifest writer's existing guard already skips empty descriptions, so
schema YAML no longer carries misleading text. SCAN_MANAGED_DESCRIPTION_KEYS
already strips stale 'ai' on merge, so existing YAML clears on next run.
Also suppress AI SDK v6 'system in messages' warning: pull system messages
out of KtxMessageBuilder.wrapSimple's output via a new splitKtxSystemMessages
helper and pass them top-level to generateText (preserves cacheControl
providerOptions on the SystemModelMessage). Agent-runner's local
splitSystemPromptMessages dedupes onto the shared helper.
* test(docs): align examples-docs assertions with revamped docs
PR #103 (setup/guide doc revamp) reworded several CLI examples and
connection labels; the assertions in scripts/examples-docs.test.mjs
still referenced the pre-revamp wording and were failing in CI on main.
Update the regexes to match the post-revamp content:
- drop the `--json` flag from the sl-query example expectation
- move the `Driver:` / `Status: ok` probe to the connection reference,
which is where that output now lives (driver id is lowercase
`postgres`, not the display name `PostgreSQL`)
- drop the obsolete `Install \`uv\`...` troubleshooting line
- accept `<connectionId>` everywhere; the docs no longer use the
hyphenated `<connection-id>` form
- match the `warehouse` connection id used in the quickstart instead of
the `postgres-warehouse` id only used in the README and setup ref
* fix(sl): skip TS/Python schema contract test when uv is unavailable
The TypeScript checks CI job does not install uv or Python, so the
module-level `execFileSync('uv', ...)` in schemas.contract.test.ts threw
ENOENT and failed the suite. Wrap the schema dump in a try/catch and
guard the describe block with `describe.skipIf` so the test skips in
environments without uv. Local dev and any CI job that has uv on PATH
still runs the cross-language contract assertion.
2026-05-15 02:11:04 +02:00
|
|
|
assert.match(connectionReference, /Driver: postgres/);
|
|
|
|
|
assert.match(connectionReference, /Status: ok/);
|
2026-05-10 23:12:26 +02:00
|
|
|
});
|
|
|
|
|
|
2026-05-12 12:02:26 +02:00
|
|
|
it('documents public npm and managed runtime usage', async () => {
|
2026-05-11 15:50:34 +02:00
|
|
|
const rootReadme = await readText('README.md');
|
2026-05-12 12:02:26 +02:00
|
|
|
const quickstart = await readText('docs-site/content/docs/getting-started/quickstart.mdx');
|
|
|
|
|
const packageArtifacts = await readText('examples/package-artifacts/README.md');
|
2026-05-11 15:50:34 +02:00
|
|
|
|
2026-05-19 16:41:01 +02:00
|
|
|
assert.match(rootReadme, publicPackagePattern('npm install -g {package}'));
|
2026-05-12 12:02:26 +02:00
|
|
|
assert.match(quickstart, publicPackagePattern('npm install -g {package}'));
|
2026-05-20 01:36:54 +02:00
|
|
|
assert.match(quickstart, /ktx admin runtime install --feature local-embeddings --yes/);
|
|
|
|
|
assert.match(quickstart, /ktx admin runtime start --feature local-embeddings/);
|
2026-05-12 12:02:26 +02:00
|
|
|
assert.match(packageArtifacts, /requires `uv` on `PATH`/);
|
2026-05-20 01:36:54 +02:00
|
|
|
assert.match(packageArtifacts, /ktx admin runtime status/);
|
|
|
|
|
assert.match(packageArtifacts, /ktx admin runtime status/);
|
|
|
|
|
assert.doesNotMatch(packageArtifacts, /ktx admin runtime prune/);
|
2026-05-11 15:50:34 +02:00
|
|
|
assert.match(
|
2026-05-12 12:02:26 +02:00
|
|
|
packageArtifacts,
|
|
|
|
|
new RegExp(
|
|
|
|
|
`artifact manifest contains the public \`${escapeRegExp(publicNpmPackageName())}\` npm tarball and the\\s+bundled \`${escapeRegExp(
|
|
|
|
|
runtimeWheelPackageName(),
|
|
|
|
|
)}\` runtime wheel`,
|
2026-05-11 15:50:34 +02:00
|
|
|
),
|
|
|
|
|
);
|
2026-05-12 23:51:46 +02:00
|
|
|
assert.doesNotMatch(rootReadme, /ktx serve --mcp stdio/);
|
2026-05-11 15:50:34 +02:00
|
|
|
assert.doesNotMatch(rootReadme, /uv run ktx-daemon serve-http/);
|
|
|
|
|
assert.doesNotMatch(rootReadme, /--semantic-compute-url http:\/\/127\.0\.0\.1:8765/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('documents the public package artifact smoke shape', async () => {
|
|
|
|
|
const readme = await readText('examples/package-artifacts/README.md');
|
|
|
|
|
|
|
|
|
|
assert.match(readme, publicPackagePattern('{package}'));
|
|
|
|
|
assert.match(readme, /managed Python runtime/);
|
|
|
|
|
assert.match(
|
|
|
|
|
readme,
|
|
|
|
|
new RegExp(
|
|
|
|
|
`public \`${escapeRegExp(publicNpmPackageName())}\` npm tarball and the\\s+bundled \`${escapeRegExp(
|
|
|
|
|
runtimeWheelPackageName(),
|
|
|
|
|
)}\`\\s+runtime wheel`,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
assert.match(readme, /does not install standalone\s+Python packages directly/);
|
|
|
|
|
assert.doesNotMatch(readme, /standalone Python distributions/);
|
|
|
|
|
assert.doesNotMatch(readme, /installs the Python artifacts directly/);
|
|
|
|
|
assert.match(readme, /requires `uv` on `PATH`/);
|
2026-05-20 01:36:54 +02:00
|
|
|
assert.match(readme, /ktx admin runtime status/);
|
|
|
|
|
assert.match(readme, /ktx admin runtime status/);
|
|
|
|
|
assert.doesNotMatch(readme, /ktx admin runtime prune/);
|
2026-05-11 15:50:34 +02:00
|
|
|
assert.doesNotMatch(readme, /@ktx\/context/);
|
|
|
|
|
assert.doesNotMatch(readme, /@ktx\/cli/);
|
|
|
|
|
assert.doesNotMatch(readme, /python -m ktx_daemon semantic-validate/);
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-14 01:43:06 +02:00
|
|
|
it('documents unified public ingest workflows in the docs site', async () => {
|
2026-05-10 23:12:26 +02:00
|
|
|
const rootReadme = await readText('README.md');
|
2026-05-14 01:43:06 +02:00
|
|
|
const cliMeta = await readText('docs-site/content/docs/cli-reference/meta.json');
|
|
|
|
|
const ingestReference = await readText('docs-site/content/docs/cli-reference/ktx-ingest.mdx');
|
2026-05-20 01:36:54 +02:00
|
|
|
const adminReference = await readText('docs-site/content/docs/cli-reference/ktx-admin.mdx');
|
2026-05-14 01:43:06 +02:00
|
|
|
const setupReference = await readText('docs-site/content/docs/cli-reference/ktx-setup.mdx');
|
2026-05-12 12:02:26 +02:00
|
|
|
const buildingContext = await readText('docs-site/content/docs/guides/building-context.mdx');
|
2026-05-14 01:43:06 +02:00
|
|
|
const contextSources = await readText('docs-site/content/docs/integrations/context-sources.mdx');
|
2026-05-21 15:42:50 +02:00
|
|
|
const reviewingContext = await readText('docs-site/content/docs/guides/reviewing-context.mdx');
|
2026-05-14 01:43:06 +02:00
|
|
|
const quickstart = await readText('docs-site/content/docs/getting-started/quickstart.mdx');
|
|
|
|
|
const primarySources = await readText('docs-site/content/docs/integrations/primary-sources.mdx');
|
|
|
|
|
const examplesIndex = await readText('examples/README.md');
|
|
|
|
|
const localWarehouseReadme = await readText('examples/local-warehouse/README.md');
|
|
|
|
|
|
|
|
|
|
assert.match(ingestReference, /ktx ingest <connectionId>/);
|
2026-05-20 01:52:37 +02:00
|
|
|
assert.match(ingestReference, /Build every configured connection/);
|
2026-05-14 01:43:06 +02:00
|
|
|
assert.match(ingestReference, /--query-history-window-days <days>/);
|
fix(context): merge overlay columns onto manifest columns by name (#94)
* fix(context): merge overlay columns onto manifest columns by name
composeOverlay was appending overlay columns to the manifest column list,
producing duplicate entries when dbt/metabase overlays declared a column
just to attach descriptions. The duplicates carried no `type`, so the
pydantic SourceDefinition rejected them at semantic-query time and broke
`ktx sl query` for every overlay-backed measure. Now overlay columns
match base columns by name (case-insensitive): same-name entries merge
onto the manifest (overlay fields win, type/role fall back to the base,
descriptions merge per source key) and only new names append.
* refactor(sl): split overlay columns from column_overrides and enforce TS/Python wire contract
Overlay sources now have two distinct collections: `columns:` for computed
columns (requiring `expr` + `type`) and `column_overrides:` for metadata
patches to inherited manifest columns. Composing or loading an overlay that
mixes the two — or references an unknown column — fails with a typed error.
Introduce `ResolvedSemanticLayerSource` / `resolvedSourceSchema` /
`toResolvedWire` as the strict shape sent to the Python engine, and add a
schema contract test that diffs Zod against the Pydantic JSON schema dumped
by `python -m semantic_layer dump-schema`. `SourceDefinition` is now
`extra="forbid"` on the Python side.
`loadAllSources` surfaces per-file load errors instead of swallowing them,
so validation/query paths can report manifest shard parse failures.
* fix(context): make scan description generation resilient and quiet
A transient sampleTable failure during ingest used to take out every
table in a connection: generateTableDescription returned a hardcoded
'Table not found' string into descriptions.ai, and KtxDescriptionGenerator
was constructed without a logger, so the failure left no trail anywhere.
- sampleTable / sampleColumn calls retry 3x with 200/400/800ms backoff,
honouring KtxScanContext.signal via a new KtxAbortedError.
- On retry exhaustion or missing capability, table generation falls back
to a metadata-only prompt built from column name / native type / comment
/ rawDescriptions. The column path follows the same rule -- call the
LLM when any of samples or rawDescriptions are available; skip only
when both are absent.
- Logger is now threaded from KtxScanContext into the generator. Failures
emit structured KtxScanWarning entries (new description_fallback_used
code, plus existing sampling_failed / enrichment_failed /
connector_capability_missing). ktx scan groups warnings by code so a
batch of identical failures collapses to one summary line plus sample.
- Returns null on failure instead of the 'Table not found' sentinel; the
manifest writer's existing guard already skips empty descriptions, so
schema YAML no longer carries misleading text. SCAN_MANAGED_DESCRIPTION_KEYS
already strips stale 'ai' on merge, so existing YAML clears on next run.
Also suppress AI SDK v6 'system in messages' warning: pull system messages
out of KtxMessageBuilder.wrapSimple's output via a new splitKtxSystemMessages
helper and pass them top-level to generateText (preserves cacheControl
providerOptions on the SystemModelMessage). Agent-runner's local
splitSystemPromptMessages dedupes onto the shared helper.
* test(docs): align examples-docs assertions with revamped docs
PR #103 (setup/guide doc revamp) reworded several CLI examples and
connection labels; the assertions in scripts/examples-docs.test.mjs
still referenced the pre-revamp wording and were failing in CI on main.
Update the regexes to match the post-revamp content:
- drop the `--json` flag from the sl-query example expectation
- move the `Driver:` / `Status: ok` probe to the connection reference,
which is where that output now lives (driver id is lowercase
`postgres`, not the display name `PostgreSQL`)
- drop the obsolete `Install \`uv\`...` troubleshooting line
- accept `<connectionId>` everywhere; the docs no longer use the
hyphenated `<connection-id>` form
- match the `warehouse` connection id used in the quickstart instead of
the `postgres-warehouse` id only used in the README and setup ref
* fix(sl): skip TS/Python schema contract test when uv is unavailable
The TypeScript checks CI job does not install uv or Python, so the
module-level `execFileSync('uv', ...)` in schemas.contract.test.ts threw
ENOENT and failed the suite. Wrap the schema dump in a try/catch and
guard the describe block with `describe.skipIf` so the test skips in
environments without uv. Local dev and any CI job that has uv on PATH
still runs the cross-language contract assertion.
2026-05-15 02:11:04 +02:00
|
|
|
assert.match(buildingContext, /ktx ingest <connectionId>/);
|
2026-05-14 01:43:06 +02:00
|
|
|
assert.match(buildingContext, /ktx ingest --all/);
|
|
|
|
|
assert.match(contextSources, /ktx ingest <connectionId>/);
|
2026-05-21 15:42:50 +02:00
|
|
|
assert.match(reviewingContext, /ktx ingest --all --no-input/);
|
2026-05-14 01:43:06 +02:00
|
|
|
assert.match(quickstart, /schema context/);
|
|
|
|
|
assert.match(primarySources, /context:\n queryHistory:/);
|
2026-05-26 23:03:47 +02:00
|
|
|
assert.match(rootReadme, /`ktx ingest` \| Build context for every configured connection/);
|
|
|
|
|
assert.doesNotMatch(rootReadme, /`ktx ingest <id>`/);
|
2026-05-29 17:27:32 +02:00
|
|
|
assert.match(quickstart, /Databases:\n warehouse: database context complete/);
|
fix(context): merge overlay columns onto manifest columns by name (#94)
* fix(context): merge overlay columns onto manifest columns by name
composeOverlay was appending overlay columns to the manifest column list,
producing duplicate entries when dbt/metabase overlays declared a column
just to attach descriptions. The duplicates carried no `type`, so the
pydantic SourceDefinition rejected them at semantic-query time and broke
`ktx sl query` for every overlay-backed measure. Now overlay columns
match base columns by name (case-insensitive): same-name entries merge
onto the manifest (overlay fields win, type/role fall back to the base,
descriptions merge per source key) and only new names append.
* refactor(sl): split overlay columns from column_overrides and enforce TS/Python wire contract
Overlay sources now have two distinct collections: `columns:` for computed
columns (requiring `expr` + `type`) and `column_overrides:` for metadata
patches to inherited manifest columns. Composing or loading an overlay that
mixes the two — or references an unknown column — fails with a typed error.
Introduce `ResolvedSemanticLayerSource` / `resolvedSourceSchema` /
`toResolvedWire` as the strict shape sent to the Python engine, and add a
schema contract test that diffs Zod against the Pydantic JSON schema dumped
by `python -m semantic_layer dump-schema`. `SourceDefinition` is now
`extra="forbid"` on the Python side.
`loadAllSources` surfaces per-file load errors instead of swallowing them,
so validation/query paths can report manifest shard parse failures.
* fix(context): make scan description generation resilient and quiet
A transient sampleTable failure during ingest used to take out every
table in a connection: generateTableDescription returned a hardcoded
'Table not found' string into descriptions.ai, and KtxDescriptionGenerator
was constructed without a logger, so the failure left no trail anywhere.
- sampleTable / sampleColumn calls retry 3x with 200/400/800ms backoff,
honouring KtxScanContext.signal via a new KtxAbortedError.
- On retry exhaustion or missing capability, table generation falls back
to a metadata-only prompt built from column name / native type / comment
/ rawDescriptions. The column path follows the same rule -- call the
LLM when any of samples or rawDescriptions are available; skip only
when both are absent.
- Logger is now threaded from KtxScanContext into the generator. Failures
emit structured KtxScanWarning entries (new description_fallback_used
code, plus existing sampling_failed / enrichment_failed /
connector_capability_missing). ktx scan groups warnings by code so a
batch of identical failures collapses to one summary line plus sample.
- Returns null on failure instead of the 'Table not found' sentinel; the
manifest writer's existing guard already skips empty descriptions, so
schema YAML no longer carries misleading text. SCAN_MANAGED_DESCRIPTION_KEYS
already strips stale 'ai' on merge, so existing YAML clears on next run.
Also suppress AI SDK v6 'system in messages' warning: pull system messages
out of KtxMessageBuilder.wrapSimple's output via a new splitKtxSystemMessages
helper and pass them top-level to generateText (preserves cacheControl
providerOptions on the SystemModelMessage). Agent-runner's local
splitSystemPromptMessages dedupes onto the shared helper.
* test(docs): align examples-docs assertions with revamped docs
PR #103 (setup/guide doc revamp) reworded several CLI examples and
connection labels; the assertions in scripts/examples-docs.test.mjs
still referenced the pre-revamp wording and were failing in CI on main.
Update the regexes to match the post-revamp content:
- drop the `--json` flag from the sl-query example expectation
- move the `Driver:` / `Status: ok` probe to the connection reference,
which is where that output now lives (driver id is lowercase
`postgres`, not the display name `PostgreSQL`)
- drop the obsolete `Install \`uv\`...` troubleshooting line
- accept `<connectionId>` everywhere; the docs no longer use the
hyphenated `<connection-id>` form
- match the `warehouse` connection id used in the quickstart instead of
the `postgres-warehouse` id only used in the README and setup ref
* fix(sl): skip TS/Python schema contract test when uv is unavailable
The TypeScript checks CI job does not install uv or Python, so the
module-level `execFileSync('uv', ...)` in schemas.contract.test.ts threw
ENOENT and failed the suite. Wrap the schema dump in a try/catch and
guard the describe block with `describe.skipIf` so the test skips in
environments without uv. Local dev and any CI job that has uv on PATH
still runs the cross-language contract assertion.
2026-05-15 02:11:04 +02:00
|
|
|
assert.match(quickstart, /Databases configured: yes \(warehouse\)/);
|
2026-05-14 01:43:06 +02:00
|
|
|
assert.match(setupReference, /Databases configured: yes \(postgres-warehouse\)/);
|
|
|
|
|
assert.doesNotMatch(rootReadme, new RegExp(['Primary sources', 'configured'].join(' ')));
|
|
|
|
|
assert.doesNotMatch(quickstart, new RegExp(['Primary', 'sources'].join(' ')));
|
|
|
|
|
assert.doesNotMatch(setupReference, new RegExp(['Primary sources', 'configured'].join(' ')));
|
|
|
|
|
|
|
|
|
|
assert.doesNotMatch(cliMeta, /ktx-scan/);
|
|
|
|
|
assert.doesNotMatch(ingestReference, /ktx ingest run/);
|
|
|
|
|
assert.doesNotMatch(ingestReference, /ktx ingest status/);
|
|
|
|
|
assert.doesNotMatch(ingestReference, /ktx ingest replay/);
|
|
|
|
|
assert.doesNotMatch(ingestReference, /--adapter/);
|
|
|
|
|
assert.doesNotMatch(ingestReference, /ktx ingest watch/);
|
|
|
|
|
assert.doesNotMatch(ingestReference, /live-database/);
|
2026-05-20 01:36:54 +02:00
|
|
|
assert.doesNotMatch(adminReference, /ktx scan/);
|
2026-05-14 01:43:06 +02:00
|
|
|
assert.doesNotMatch(buildingContext, /ktx ingest watch/);
|
|
|
|
|
assert.doesNotMatch(buildingContext, /ktx ingest status/);
|
|
|
|
|
assert.doesNotMatch(buildingContext, /ktx ingest replay/);
|
|
|
|
|
assert.doesNotMatch(buildingContext, /historic-sql/);
|
|
|
|
|
assert.doesNotMatch(buildingContext, /live-database/);
|
|
|
|
|
assert.doesNotMatch(contextSources, /ktx ingest run --connection-id/);
|
|
|
|
|
assert.doesNotMatch(contextSources, /--adapter <adapter>/);
|
2026-05-21 15:42:50 +02:00
|
|
|
assert.doesNotMatch(reviewingContext, /ktx ingest run --connection-id/);
|
2026-05-14 01:43:06 +02:00
|
|
|
assert.doesNotMatch(quickstart, /Historic SQL/);
|
|
|
|
|
assert.doesNotMatch(quickstart, /--enable-historic-sql/);
|
|
|
|
|
assert.doesNotMatch(quickstart, /press <kbd>d<\/kbd> to detach/);
|
|
|
|
|
assert.doesNotMatch(primarySources, /historicSql/);
|
|
|
|
|
assert.doesNotMatch(primarySources, /Historic SQL/);
|
|
|
|
|
assert.doesNotMatch(examplesIndex, /ktx ingest run --project-dir/);
|
|
|
|
|
assert.doesNotMatch(localWarehouseReadme, /ktx ingest run --project-dir/);
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-12 12:02:26 +02:00
|
|
|
assert.match(rootReadme, /raw-sources\//);
|
2026-05-14 01:43:06 +02:00
|
|
|
assert.doesNotMatch(rootReadme, new RegExp(`${['live', 'database'].join('-')}/`));
|
|
|
|
|
assert.doesNotMatch(rootReadme, /ktx scan/);
|
2026-05-10 23:12:26 +02:00
|
|
|
assert.doesNotMatch(rootReadme, /Run a local ingest smoke test/);
|
2026-05-13 12:00:08 +02:00
|
|
|
assert.doesNotMatch(rootReadme, /ktx ingest run --project-dir/);
|
2026-05-10 23:51:24 +02:00
|
|
|
assert.doesNotMatch(rootReadme, /ktx ingest status --project-dir/);
|
2026-05-10 23:12:26 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('documents pnpm setup as a prerequisite when optional dev linking fails', async () => {
|
|
|
|
|
const rootReadme = await readText('README.md');
|
|
|
|
|
|
|
|
|
|
assert.match(rootReadme, /pnpm run link:dev/);
|
2026-05-10 23:51:24 +02:00
|
|
|
assert.match(rootReadme, /ktx-dev --help/);
|
2026-05-10 23:12:26 +02:00
|
|
|
assert.doesNotMatch(
|
|
|
|
|
rootReadme,
|
|
|
|
|
/If the setup command reports that pnpm's global bin directory is not on your\n`PATH`, add the printed directory to your shell profile/,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('runs the example smoke in the cli smoke script', async () => {
|
|
|
|
|
const packageJson = JSON.parse(await readText('packages/cli/package.json'));
|
|
|
|
|
|
test: split cli tests from source tree (#216)
* feat(cli): define full warehouse dialect contract
* test(cli): keep dialect edge tests focused
* fix(cli): stabilize dialect contract foundation
* refactor(connectors): own read-only query preparation
* refactor(connectors): resolve dialects through registry
* refactor(connectors): keep concrete dialect classes internal
* chore(workspace): enforce dialect import boundary
* refactor(cli): resolve relationship dialect at scan boundary
* refactor(cli): use dialect display parsing for entity details
* refactor(cli): use dialect display parsing for warehouse catalog
* refactor(cli): use dialect SQL in relationship workflows
* test(cli): verify solid dialect scan workflow closure
* test: split cli tests from source tree
* refactor(cli): standardize BigQuery scope listing
* feat(sqlite): implement connector scope listing
* test(connectors): cover required table listing
* feat(cli): add warehouse driver registry
* refactor(setup): route scope discovery through driver registry
* refactor(cli): route local query execution through driver registry
* refactor(historic-sql): route dialect support through driver registry
* refactor(cli): test warehouse connections through driver registry
* fix(cli): close driver registry type export gaps
* Improve setup daemon diagnostics
* refactor(setup): centralize rail-prefixed diagnostics + query-history fallback
Extract errorMessage, writePrefixedLines, and flushPrefixedBufferedCommandOutput
into clack.ts so the setup wizard, managed daemons, and embedding/agent steps
share one rail-formatted writer. setup-databases.ts also adds a
"disable query history and retry" option when the schema-context build fails
and query history is the likely culprit, surfaced via a new
failed-query-history-unavailable status.
* fix(cli): carry catalog through the picker so BigQuery/Snowflake/SQL Server scope filters match
The setup picker's KtxTableListEntry was a 2-level { schema, name }, so
qualifiedTableId always wrote db.name into enabled_tables. When BigQuery,
Snowflake, or SQL Server later ran fast ingest, their introspect step filtered
the scope set with scopedTableNames(scope, { catalog: projectId|database, db })
— catalog was non-null on the introspect side but null in the scope refs, so
every entry was rejected, the live-database adapter staged zero table files,
and detect() failed with 'Adapter "live-database" did not recognize fetched
source output'.
Align the picker boundary with the canonical 3-level KtxTableRef:
- Add catalog: string | null to KtxTableListEntry.
- BigQuery/Snowflake/SQL Server listTables populate catalog from the
resolved projectId / database; Postgres/MySQL/ClickHouse/SQLite set null.
- qualifiedTableId emits catalog.schema.name when catalog is non-null
(resolveEnabledTables already accepts the 3-part shape) and
schemasFromEnabledTables now goes through parseDottedTableEntry so it
recovers the schema correctly from both 2-part and 3-part entries.
- Export parseDottedTableEntry from enabled-tables.ts (@internal) for picker
reuse.
Update listTables expectations in all seven connector tests and the setup /
picker test fixtures. Add a picker regression test that covers the
catalog-bearing round-trip (save + refine).
* fix(cli): allow debug telemetry under opt-out env
2026-05-26 08:49:05 +02:00
|
|
|
assert.match(packageJson.scripts.smoke, /test\/standalone-smoke\.test\.ts/);
|
|
|
|
|
assert.match(packageJson.scripts.smoke, /test\/example-smoke\.test\.ts/);
|
|
|
|
|
assert.match(packageJson.scripts.test, /--exclude test\/standalone-smoke\.test\.ts/);
|
|
|
|
|
assert.match(packageJson.scripts.test, /--exclude test\/example-smoke\.test\.ts/);
|
2026-05-10 23:12:26 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('documents daemon HTTP database, source generation, LookML, embedding, and code execution support', async () => {
|
2026-05-10 23:51:24 +02:00
|
|
|
const readme = await readText('python/ktx-daemon/README.md');
|
2026-05-10 23:12:26 +02:00
|
|
|
|
|
|
|
|
assert.match(readme, /semantic-generate-sources/);
|
|
|
|
|
assert.match(readme, /database-introspect/);
|
|
|
|
|
assert.match(readme, /POST \/database\/introspect/);
|
|
|
|
|
assert.match(readme, /Introspect a Postgres database schema/);
|
|
|
|
|
assert.match(readme, /lookml-parse/);
|
|
|
|
|
assert.match(readme, /embedding-compute/);
|
|
|
|
|
assert.match(readme, /embedding-compute-bulk/);
|
|
|
|
|
assert.match(readme, /code-execute/);
|
|
|
|
|
assert.match(readme, /--enable-code-execution/);
|
|
|
|
|
assert.match(readme, /POST \/semantic-layer\/generate-sources/);
|
|
|
|
|
assert.match(readme, /POST \/lookml\/parse/);
|
|
|
|
|
assert.match(readme, /POST \/embeddings\/compute/);
|
|
|
|
|
assert.match(readme, /POST \/embeddings\/compute-bulk/);
|
|
|
|
|
assert.match(readme, /POST \/code\/execute/);
|
|
|
|
|
assert.match(readme, /Generate semantic-layer sources from schema scan data/);
|
|
|
|
|
assert.match(readme, /Parse LookML projects into resolved, KSL-ready structures/);
|
|
|
|
|
assert.match(readme, /Compute text embeddings locally/);
|
|
|
|
|
assert.match(readme, /Execute Python code with the current in-process boundary/);
|
|
|
|
|
assert.match(readme, /Code execution is off by default/);
|
|
|
|
|
assert.match(readme, /does not provide OS-level sandboxing/);
|
|
|
|
|
assert.doesNotMatch(readme, /source generation are not exposed through this/);
|
|
|
|
|
assert.doesNotMatch(readme, /LookML parsing are not exposed through this/);
|
|
|
|
|
assert.doesNotMatch(readme, /embeddings are not exposed through this server mode/);
|
|
|
|
|
assert.doesNotMatch(readme, /Code execution is not exposed through this server mode/);
|
|
|
|
|
});
|
|
|
|
|
});
|