2026-05-11 15:50:34 +02:00
|
|
|
import assert from 'node:assert/strict';
|
|
|
|
|
import { readFile } from 'node:fs/promises';
|
|
|
|
|
import { describe, it } from 'node:test';
|
|
|
|
|
|
docs(concepts): add Wiki retrieval pillar page (#191)
* docs(concepts): add Wiki retrieval pillar page
Adds a dedicated concept page covering the wiki side of the context
layer: the page contract, the hybrid retrieval pipeline (lexical,
semantic, token lanes fused by RRF), the refs/sl_refs/[[wikilink]]
graph, validation that keeps edges live, and where ingest sources
pages. Wired into concepts nav and cross-linked from the-context-layer
to mirror the existing Semantic querying link.
* test: derive release versions in tests instead of hardcoding 0.1.0-rc.1
After @semantic-release/git started committing version bumps back to the
branch, the 0.4.0 release rewrote package.json, packages/cli/package.json,
and release-policy.json — but the script and CLI tests still pinned the
pre-bump strings (0.0.0-private, 0.1.0-rc.1, 0.1.0rc1), so every new
branch off main failed TypeScript checks and Coverage.
Drive the version off the existing source of truth instead: read
@ktx/cli/package.json via createRequire in the CLI tests, and reuse the
already-imported PUBLIC_NPM_PACKAGE_VERSION / RUNTIME_WHEEL_PACKAGE_VERSION
constants in the script tests. The two assertions that pinned those
constants to specific values become semver shape checks.
2026-05-21 01:26:58 +02:00
|
|
|
import { PUBLIC_NPM_PACKAGE_VERSION } from './build-public-npm-package.mjs';
|
2026-05-11 15:50:34 +02:00
|
|
|
import {
|
|
|
|
|
buildLocalEmbeddingsSmokeEnv,
|
|
|
|
|
expectedPublicKtxVersionPattern,
|
|
|
|
|
localEmbeddingsSmokeCommands,
|
|
|
|
|
localEmbeddingsSmokeOptIn,
|
|
|
|
|
parseDaemonBaseUrl,
|
|
|
|
|
publicKtxTarballName,
|
|
|
|
|
validateEmbeddingResponse,
|
|
|
|
|
} from './local-embeddings-runtime-smoke.mjs';
|
docs(concepts): add Wiki retrieval pillar page (#191)
* docs(concepts): add Wiki retrieval pillar page
Adds a dedicated concept page covering the wiki side of the context
layer: the page contract, the hybrid retrieval pipeline (lexical,
semantic, token lanes fused by RRF), the refs/sl_refs/[[wikilink]]
graph, validation that keeps edges live, and where ingest sources
pages. Wired into concepts nav and cross-linked from the-context-layer
to mirror the existing Semantic querying link.
* test: derive release versions in tests instead of hardcoding 0.1.0-rc.1
After @semantic-release/git started committing version bumps back to the
branch, the 0.4.0 release rewrote package.json, packages/cli/package.json,
and release-policy.json — but the script and CLI tests still pinned the
pre-bump strings (0.0.0-private, 0.1.0-rc.1, 0.1.0rc1), so every new
branch off main failed TypeScript checks and Coverage.
Drive the version off the existing source of truth instead: read
@ktx/cli/package.json via createRequire in the CLI tests, and reuse the
already-imported PUBLIC_NPM_PACKAGE_VERSION / RUNTIME_WHEEL_PACKAGE_VERSION
constants in the script tests. The two assertions that pinned those
constants to specific values become semver shape checks.
2026-05-21 01:26:58 +02:00
|
|
|
const PUBLIC_TARBALL_NAME = `kaelio-ktx-${PUBLIC_NPM_PACKAGE_VERSION}.tgz`;
|
|
|
|
|
const OTHER_PUBLIC_TARBALL_NAME = 'kaelio-ktx-9.9.9.tgz';
|
|
|
|
|
|
2026-05-11 15:50:34 +02:00
|
|
|
describe('localEmbeddingsSmokeOptIn', () => {
|
|
|
|
|
it('skips unless the smoke is explicitly enabled', () => {
|
|
|
|
|
assert.deepEqual(localEmbeddingsSmokeOptIn({}, []), {
|
|
|
|
|
run: false,
|
|
|
|
|
message: 'Set KTX_RUN_LOCAL_EMBEDDINGS_SMOKE=1 or pass --force to run the local embeddings smoke.',
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('runs when the environment opt-in is set', () => {
|
|
|
|
|
assert.deepEqual(localEmbeddingsSmokeOptIn({ KTX_RUN_LOCAL_EMBEDDINGS_SMOKE: '1' }, []), {
|
|
|
|
|
run: true,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('runs when --force is present', () => {
|
|
|
|
|
assert.deepEqual(localEmbeddingsSmokeOptIn({}, ['--force']), {
|
|
|
|
|
run: true,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('publicKtxTarballName', () => {
|
|
|
|
|
it('selects the public @kaelio/ktx tarball name', () => {
|
docs(concepts): add Wiki retrieval pillar page (#191)
* docs(concepts): add Wiki retrieval pillar page
Adds a dedicated concept page covering the wiki side of the context
layer: the page contract, the hybrid retrieval pipeline (lexical,
semantic, token lanes fused by RRF), the refs/sl_refs/[[wikilink]]
graph, validation that keeps edges live, and where ingest sources
pages. Wired into concepts nav and cross-linked from the-context-layer
to mirror the existing Semantic querying link.
* test: derive release versions in tests instead of hardcoding 0.1.0-rc.1
After @semantic-release/git started committing version bumps back to the
branch, the 0.4.0 release rewrote package.json, packages/cli/package.json,
and release-policy.json — but the script and CLI tests still pinned the
pre-bump strings (0.0.0-private, 0.1.0-rc.1, 0.1.0rc1), so every new
branch off main failed TypeScript checks and Coverage.
Drive the version off the existing source of truth instead: read
@ktx/cli/package.json via createRequire in the CLI tests, and reuse the
already-imported PUBLIC_NPM_PACKAGE_VERSION / RUNTIME_WHEEL_PACKAGE_VERSION
constants in the script tests. The two assertions that pinned those
constants to specific values become semver shape checks.
2026-05-21 01:26:58 +02:00
|
|
|
assert.equal(publicKtxTarballName([PUBLIC_TARBALL_NAME, 'ignore-me.tgz']), PUBLIC_TARBALL_NAME);
|
2026-05-11 15:50:34 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('fails when the public package tarball is missing', () => {
|
|
|
|
|
assert.throws(
|
|
|
|
|
() => publicKtxTarballName(['ktx-cli-0.0.0-private.tgz']),
|
|
|
|
|
/Expected exactly one @kaelio\/ktx tarball/,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('fails when multiple public package tarballs are present', () => {
|
|
|
|
|
assert.throws(
|
docs(concepts): add Wiki retrieval pillar page (#191)
* docs(concepts): add Wiki retrieval pillar page
Adds a dedicated concept page covering the wiki side of the context
layer: the page contract, the hybrid retrieval pipeline (lexical,
semantic, token lanes fused by RRF), the refs/sl_refs/[[wikilink]]
graph, validation that keeps edges live, and where ingest sources
pages. Wired into concepts nav and cross-linked from the-context-layer
to mirror the existing Semantic querying link.
* test: derive release versions in tests instead of hardcoding 0.1.0-rc.1
After @semantic-release/git started committing version bumps back to the
branch, the 0.4.0 release rewrote package.json, packages/cli/package.json,
and release-policy.json — but the script and CLI tests still pinned the
pre-bump strings (0.0.0-private, 0.1.0-rc.1, 0.1.0rc1), so every new
branch off main failed TypeScript checks and Coverage.
Drive the version off the existing source of truth instead: read
@ktx/cli/package.json via createRequire in the CLI tests, and reuse the
already-imported PUBLIC_NPM_PACKAGE_VERSION / RUNTIME_WHEEL_PACKAGE_VERSION
constants in the script tests. The two assertions that pinned those
constants to specific values become semver shape checks.
2026-05-21 01:26:58 +02:00
|
|
|
() => publicKtxTarballName([PUBLIC_TARBALL_NAME, OTHER_PUBLIC_TARBALL_NAME]),
|
2026-05-11 15:50:34 +02:00
|
|
|
/Expected exactly one @kaelio\/ktx tarball/,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('expectedPublicKtxVersionPattern', () => {
|
|
|
|
|
it('matches the public package version and rejects the private workspace version', () => {
|
|
|
|
|
const pattern = expectedPublicKtxVersionPattern();
|
|
|
|
|
|
docs(concepts): add Wiki retrieval pillar page (#191)
* docs(concepts): add Wiki retrieval pillar page
Adds a dedicated concept page covering the wiki side of the context
layer: the page contract, the hybrid retrieval pipeline (lexical,
semantic, token lanes fused by RRF), the refs/sl_refs/[[wikilink]]
graph, validation that keeps edges live, and where ingest sources
pages. Wired into concepts nav and cross-linked from the-context-layer
to mirror the existing Semantic querying link.
* test: derive release versions in tests instead of hardcoding 0.1.0-rc.1
After @semantic-release/git started committing version bumps back to the
branch, the 0.4.0 release rewrote package.json, packages/cli/package.json,
and release-policy.json — but the script and CLI tests still pinned the
pre-bump strings (0.0.0-private, 0.1.0-rc.1, 0.1.0rc1), so every new
branch off main failed TypeScript checks and Coverage.
Drive the version off the existing source of truth instead: read
@ktx/cli/package.json via createRequire in the CLI tests, and reuse the
already-imported PUBLIC_NPM_PACKAGE_VERSION / RUNTIME_WHEEL_PACKAGE_VERSION
constants in the script tests. The two assertions that pinned those
constants to specific values become semver shape checks.
2026-05-21 01:26:58 +02:00
|
|
|
assert.match(`@kaelio/ktx ${PUBLIC_NPM_PACKAGE_VERSION}\n`, pattern);
|
2026-05-11 15:50:34 +02:00
|
|
|
assert.doesNotMatch('@kaelio/ktx 0.0.0-private\n', pattern);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('buildLocalEmbeddingsSmokeEnv', () => {
|
|
|
|
|
it('isolates the runtime root and model caches inside the smoke root', () => {
|
|
|
|
|
const env = buildLocalEmbeddingsSmokeEnv('/tmp/ktx-local-embedding-smoke', {
|
|
|
|
|
PATH: '/usr/bin',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
assert.equal(env.PATH, '/usr/bin');
|
|
|
|
|
assert.equal(env.KTX_RUN_LOCAL_EMBEDDINGS_SMOKE, '1');
|
|
|
|
|
assert.equal(env.KTX_RUNTIME_ROOT, '/tmp/ktx-local-embedding-smoke/managed-runtime');
|
|
|
|
|
assert.equal(env.HF_HOME, '/tmp/ktx-local-embedding-smoke/hf-home');
|
|
|
|
|
assert.equal(env.TRANSFORMERS_CACHE, '/tmp/ktx-local-embedding-smoke/transformers-cache');
|
|
|
|
|
assert.equal(env.SENTENCE_TRANSFORMERS_HOME, '/tmp/ktx-local-embedding-smoke/sentence-transformers-home');
|
|
|
|
|
assert.equal(env.TORCH_HOME, '/tmp/ktx-local-embedding-smoke/torch-home');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('localEmbeddingsSmokeCommands', () => {
|
|
|
|
|
it('describes the installed-package commands needed for the smoke', () => {
|
|
|
|
|
const commands = localEmbeddingsSmokeCommands({
|
|
|
|
|
projectDir: '/tmp/ktx-local-embedding-smoke/project',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
assert.deepEqual(commands.map((command) => command.label), [
|
|
|
|
|
'ktx public package version',
|
2026-05-20 01:36:54 +02:00
|
|
|
'ktx admin runtime status missing',
|
|
|
|
|
'ktx admin runtime install local embeddings',
|
|
|
|
|
'ktx admin runtime status local embeddings ready',
|
|
|
|
|
'ktx admin runtime start local embeddings',
|
2026-05-11 15:50:34 +02:00
|
|
|
'ktx setup local embeddings',
|
2026-05-20 01:36:54 +02:00
|
|
|
'ktx admin runtime stop local embeddings',
|
2026-05-11 15:50:34 +02:00
|
|
|
]);
|
|
|
|
|
assert.deepEqual(commands[2], {
|
2026-05-20 01:36:54 +02:00
|
|
|
label: 'ktx admin runtime install local embeddings',
|
2026-05-11 15:50:34 +02:00
|
|
|
command: 'pnpm',
|
2026-05-20 01:36:54 +02:00
|
|
|
args: ['exec', 'ktx', 'admin', 'runtime', 'install', '--feature', 'local-embeddings', '--yes'],
|
2026-05-11 15:50:34 +02:00
|
|
|
timeoutMs: 1_200_000,
|
|
|
|
|
});
|
|
|
|
|
assert.deepEqual(commands[4], {
|
2026-05-20 01:36:54 +02:00
|
|
|
label: 'ktx admin runtime start local embeddings',
|
2026-05-11 15:50:34 +02:00
|
|
|
command: 'pnpm',
|
2026-05-20 01:36:54 +02:00
|
|
|
args: ['exec', 'ktx', 'admin', 'runtime', 'start', '--feature', 'local-embeddings'],
|
2026-05-11 15:50:34 +02:00
|
|
|
timeoutMs: 300_000,
|
|
|
|
|
});
|
|
|
|
|
assert.deepEqual(commands[5].args, [
|
|
|
|
|
'exec',
|
|
|
|
|
'ktx',
|
|
|
|
|
'setup',
|
|
|
|
|
'--project-dir',
|
|
|
|
|
'/tmp/ktx-local-embedding-smoke/project',
|
|
|
|
|
'--no-input',
|
|
|
|
|
'--yes',
|
|
|
|
|
'--skip-llm',
|
|
|
|
|
'--embedding-backend',
|
|
|
|
|
'sentence-transformers',
|
|
|
|
|
'--skip-databases',
|
|
|
|
|
'--skip-sources',
|
|
|
|
|
'--skip-agents',
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('parseDaemonBaseUrl', () => {
|
|
|
|
|
it('extracts the daemon URL from runtime start output', () => {
|
|
|
|
|
assert.equal(
|
refactor(release): drop release-policy.json runtime dep and next branch (#180)
* chore: standardize daemon naming on "KTX daemon"
Replace inconsistent names ("KTX Python daemon", "KTX local embeddings
daemon", "KTX managed daemon", "Python daemon") with the single name
"KTX daemon" in CLI output, errors, command descriptions, test
assertions, smoke scripts, docs, AGENTS.md, issue templates, and
codecov flags. The daemon is a portable compute server with endpoints
for SQL analysis, semantic layer, LookML, database introspection, and
embeddings; the previous labels misrepresented it as embeddings-only or
exposed implementation details ("Python", "managed").
The "KTX Python runtime" concept (installed interpreter + packages) is
deliberately left as-is — it is a separate concept from the daemon
process.
* refactor(release): drop release-policy.json runtime dep and next branch
Strips the release-policy.json fallback from release-version.ts so the CLI
reads its version straight from packages/cli/package.json. dev → 0.0.0-private,
installed @kaelio/ktx → the real semver baked into the published package.json.
KtxCliPackageInfo collapses to { name, version, contextPackageName }; /health
no longer depends on version files surviving past a CI run.
Replaces the dual-branch (main + next) semantic-release model with a single-
branch model on main. rcs and stables interleave on the same branch via
{ name: 'main', prerelease: 'rc', channel: 'next' } / ['main']. Drops
@semantic-release/git and @semantic-release/changelog (nothing is committed
back to the repo on any channel) and the workflow's "Prepare next prerelease
branch" step plus the KTX_PRERELEASE_BRANCH plumbing. The git tag plus the
published npm artifact carry the version forward.
Updates docs/release.md, removes the two now-unused devDeps, regenerates
pnpm-lock.yaml. 611/611 @ktx/cli tests, 173/173 script tests, type-check,
biome, knip all clean.
* fix(release): don't throw on non-main branches at config-load time
knip loads .releaserc.cjs on every PR run, where GITHUB_REF_NAME is the
merge ref (e.g. 180/merge). The previous version of releaseBranches threw
immediately when the branch wasn't main, which made knip fail to evaluate
the config and then mis-flag @semantic-release/exec as an unused dep.
semantic-release already refuses to publish when the current branch doesn't
match a configured release branch, so the explicit throw was redundant.
Drop it (and the unused currentBranch helper) and replace the
"rejects releases from non-main" assertion with one that exercises a CI-
shaped GITHUB_REF_NAME and confirms the config loads.
2026-05-20 13:53:14 +02:00
|
|
|
parseDaemonBaseUrl('Started KTX daemon\nurl: http://127.0.0.1:61234\nfeatures: local-embeddings\n'),
|
2026-05-11 15:50:34 +02:00
|
|
|
'http://127.0.0.1:61234',
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('rejects output without a daemon URL', () => {
|
refactor(release): drop release-policy.json runtime dep and next branch (#180)
* chore: standardize daemon naming on "KTX daemon"
Replace inconsistent names ("KTX Python daemon", "KTX local embeddings
daemon", "KTX managed daemon", "Python daemon") with the single name
"KTX daemon" in CLI output, errors, command descriptions, test
assertions, smoke scripts, docs, AGENTS.md, issue templates, and
codecov flags. The daemon is a portable compute server with endpoints
for SQL analysis, semantic layer, LookML, database introspection, and
embeddings; the previous labels misrepresented it as embeddings-only or
exposed implementation details ("Python", "managed").
The "KTX Python runtime" concept (installed interpreter + packages) is
deliberately left as-is — it is a separate concept from the daemon
process.
* refactor(release): drop release-policy.json runtime dep and next branch
Strips the release-policy.json fallback from release-version.ts so the CLI
reads its version straight from packages/cli/package.json. dev → 0.0.0-private,
installed @kaelio/ktx → the real semver baked into the published package.json.
KtxCliPackageInfo collapses to { name, version, contextPackageName }; /health
no longer depends on version files surviving past a CI run.
Replaces the dual-branch (main + next) semantic-release model with a single-
branch model on main. rcs and stables interleave on the same branch via
{ name: 'main', prerelease: 'rc', channel: 'next' } / ['main']. Drops
@semantic-release/git and @semantic-release/changelog (nothing is committed
back to the repo on any channel) and the workflow's "Prepare next prerelease
branch" step plus the KTX_PRERELEASE_BRANCH plumbing. The git tag plus the
published npm artifact carry the version forward.
Updates docs/release.md, removes the two now-unused devDeps, regenerates
pnpm-lock.yaml. 611/611 @ktx/cli tests, 173/173 script tests, type-check,
biome, knip all clean.
* fix(release): don't throw on non-main branches at config-load time
knip loads .releaserc.cjs on every PR run, where GITHUB_REF_NAME is the
merge ref (e.g. 180/merge). The previous version of releaseBranches threw
immediately when the branch wasn't main, which made knip fail to evaluate
the config and then mis-flag @semantic-release/exec as an unused dep.
semantic-release already refuses to publish when the current branch doesn't
match a configured release branch, so the explicit throw was redundant.
Drop it (and the unused currentBranch helper) and replace the
"rejects releases from non-main" assertion with one that exercises a CI-
shaped GITHUB_REF_NAME and confirms the config loads.
2026-05-20 13:53:14 +02:00
|
|
|
assert.throws(() => parseDaemonBaseUrl('Started KTX daemon\n'), /Daemon URL was not printed/);
|
2026-05-11 15:50:34 +02:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('validateEmbeddingResponse', () => {
|
|
|
|
|
it('accepts a finite embedding vector with the expected dimensions', () => {
|
|
|
|
|
validateEmbeddingResponse({ embedding: [0.1, -0.2, 0.3] }, 3);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('rejects a vector with the wrong dimensions', () => {
|
|
|
|
|
assert.throws(
|
|
|
|
|
() => validateEmbeddingResponse({ embedding: [0.1, 0.2] }, 3),
|
|
|
|
|
/Expected embedding dimension 3, got 2/,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('rejects non-finite embedding values', () => {
|
|
|
|
|
assert.throws(
|
|
|
|
|
() => validateEmbeddingResponse({ embedding: [0.1, Number.NaN, 0.3] }, 3),
|
|
|
|
|
/Embedding value at index 1 is not a finite number/,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('package script', () => {
|
|
|
|
|
it('registers the opt-in local embeddings smoke command', async () => {
|
|
|
|
|
const packageJson = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
|
|
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
|
packageJson.scripts['release:local-embeddings-smoke'],
|
|
|
|
|
'node scripts/local-embeddings-runtime-smoke.mjs --require-opt-in',
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|