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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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/);
|
|
|
|
|
assert.match(config, /project: orbit-relationship-verification/);
|
|
|
|
|
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/,
|
|
|
|
|
);
|
|
|
|
|
assert.match(config, /readonly: true/);
|
|
|
|
|
assert.match(config, /llm_proposals: false/);
|
|
|
|
|
assert.match(config, /validation_required_for_manifest: true/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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/);
|
|
|
|
|
assert.match(examples, /pg_stat_statements/);
|
|
|
|
|
assert.match(readme, /--enable-historic-sql/);
|
|
|
|
|
assert.match(readme, /--historic-sql-min-calls 2/);
|
2026-05-10 23:51:24 +02:00
|
|
|
assert.match(readme, /ktx dev doctor --project-dir/);
|
2026-05-10 23:12:26 +02:00
|
|
|
assert.match(readme, /Postgres Historic SQL/);
|
|
|
|
|
assert.match(readme, /dev ingest run/);
|
|
|
|
|
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/);
|
|
|
|
|
assert.match(smoke, /pg_stat_statements_reset/);
|
|
|
|
|
assert.match(smoke, /assert_manifest "\$FIRST_MANIFEST" true/);
|
|
|
|
|
assert.match(smoke, /assert_manifest "\$SECOND_MANIFEST" false/);
|
|
|
|
|
assert.match(smoke, /assert_manifest "\$RESET_MANIFEST" true/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('lists every published TypeScript package in the package root README', async () => {
|
|
|
|
|
const rootReadme = await readText('README.md');
|
|
|
|
|
|
|
|
|
|
assert.match(rootReadme, /`packages\/context`/);
|
|
|
|
|
assert.match(rootReadme, /`packages\/cli`/);
|
|
|
|
|
assert.match(rootReadme, /`packages\/connector-bigquery`/);
|
|
|
|
|
assert.match(rootReadme, /`packages\/connector-clickhouse`/);
|
|
|
|
|
assert.match(rootReadme, /`packages\/connector-mysql`/);
|
|
|
|
|
assert.match(rootReadme, /`packages\/connector-postgres`/);
|
|
|
|
|
assert.match(rootReadme, /`packages\/connector-posthog`/);
|
|
|
|
|
assert.match(rootReadme, /`packages\/connector-snowflake`/);
|
|
|
|
|
assert.match(rootReadme, /`packages\/connector-sqlite`/);
|
|
|
|
|
assert.match(rootReadme, /`packages\/connector-sqlserver`/);
|
2026-05-10 23:51:24 +02:00
|
|
|
assert.match(rootReadme, /`python\/ktx-sl`/);
|
|
|
|
|
assert.match(rootReadme, /`python\/ktx-daemon`/);
|
2026-05-10 23:12:26 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('documents every standalone MCP tool that the CLI server exposes', async () => {
|
|
|
|
|
const rootReadme = await readText('README.md');
|
|
|
|
|
|
|
|
|
|
assert.match(rootReadme, /`connection_list`/);
|
|
|
|
|
assert.match(rootReadme, /`knowledge_search`/);
|
|
|
|
|
assert.match(rootReadme, /`knowledge_read`/);
|
|
|
|
|
assert.match(rootReadme, /`knowledge_write`/);
|
|
|
|
|
assert.match(rootReadme, /`sl_list_sources`/);
|
|
|
|
|
assert.match(rootReadme, /`sl_read_source`/);
|
|
|
|
|
assert.match(rootReadme, /`sl_write_source`/);
|
|
|
|
|
assert.match(rootReadme, /`sl_validate`/);
|
|
|
|
|
assert.match(rootReadme, /`sl_query`/);
|
|
|
|
|
assert.match(rootReadme, /`ingest_trigger`/);
|
|
|
|
|
assert.match(rootReadme, /`ingest_status`/);
|
|
|
|
|
assert.match(rootReadme, /`ingest_report`/);
|
|
|
|
|
assert.match(rootReadme, /`ingest_replay`/);
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-10 23:51:24 +02:00
|
|
|
it('walks through ktx connection list and ktx connection test in the README quickstart', async () => {
|
2026-05-10 23:12:26 +02:00
|
|
|
const rootReadme = await readText('README.md');
|
|
|
|
|
|
|
|
|
|
assert.match(rootReadme, /connection list --project-dir/);
|
|
|
|
|
assert.match(rootReadme, /connection test warehouse --project-dir/);
|
|
|
|
|
assert.match(rootReadme, /Driver: sqlite/);
|
|
|
|
|
assert.match(rootReadme, /Tables: 1/);
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-10 23:51:24 +02:00
|
|
|
it('replaces the fake-ingest smoke with a ktx scan walkthrough in the README', async () => {
|
2026-05-10 23:12:26 +02:00
|
|
|
const rootReadme = await readText('README.md');
|
|
|
|
|
|
|
|
|
|
assert.match(rootReadme, /### Scan the demo warehouse/);
|
|
|
|
|
assert.match(rootReadme, /scan warehouse --project-dir/);
|
|
|
|
|
assert.match(rootReadme, /scan status --project-dir/);
|
|
|
|
|
assert.match(rootReadme, /scan report --project-dir/);
|
|
|
|
|
assert.match(rootReadme, /raw-sources\/warehouse\/live-database/);
|
|
|
|
|
assert.doesNotMatch(rootReadme, /Run a local ingest smoke test/);
|
2026-05-10 23:51:24 +02:00
|
|
|
assert.doesNotMatch(rootReadme, /ktx dev ingest run --project-dir/);
|
|
|
|
|
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'));
|
|
|
|
|
|
|
|
|
|
assert.match(packageJson.scripts.smoke, /src\/standalone-smoke\.test\.ts/);
|
|
|
|
|
assert.match(packageJson.scripts.smoke, /src\/example-smoke\.test\.ts/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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/);
|
|
|
|
|
});
|
|
|
|
|
});
|