mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-10 08:05:14 +02:00
* 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.
158 lines
5.2 KiB
TypeScript
158 lines
5.2 KiB
TypeScript
import { MANAGED_SENTENCE_TRANSFORMERS_BASE_URL } from '@ktx/context';
|
|
import type {
|
|
KtxProjectConfig,
|
|
KtxProjectConnectionConfig,
|
|
KtxProjectEmbeddingConfig,
|
|
} from '@ktx/context/project';
|
|
import type { KtxRuntimeFeature } from './managed-python-runtime.js';
|
|
import type { KtxPublicIngestPlan } from './public-ingest.js';
|
|
|
|
type KtxRuntimeRequirementReason =
|
|
| 'query-history'
|
|
| 'looker-source'
|
|
| 'database-introspection'
|
|
| 'local-embeddings';
|
|
|
|
interface KtxRuntimeRequirement {
|
|
feature: KtxRuntimeFeature;
|
|
reason: KtxRuntimeRequirementReason;
|
|
detail: string;
|
|
}
|
|
|
|
export interface KtxRuntimeRequirements {
|
|
features: KtxRuntimeFeature[];
|
|
requirements: KtxRuntimeRequirement[];
|
|
}
|
|
|
|
export interface KtxProjectRuntimeRequirementOptions {
|
|
databaseIntrospectionFallback?: boolean;
|
|
env?: NodeJS.ProcessEnv | Record<string, string | undefined>;
|
|
}
|
|
|
|
export interface KtxPublicIngestRuntimeRequirementOptions {
|
|
env?: NodeJS.ProcessEnv | Record<string, string | undefined>;
|
|
}
|
|
|
|
function normalizeDriver(driver: unknown): string {
|
|
return String(driver ?? '').trim().toLowerCase();
|
|
}
|
|
|
|
function recordValue(value: unknown): Record<string, unknown> {
|
|
return typeof value === 'object' && value !== null ? (value as Record<string, unknown>) : {};
|
|
}
|
|
|
|
function hasEnabledQueryHistory(connection: KtxProjectConnectionConfig): boolean {
|
|
const context = recordValue(recordValue(connection).context);
|
|
const queryHistory = recordValue(context.queryHistory);
|
|
return queryHistory.enabled === true;
|
|
}
|
|
|
|
function hasDaemonOverride(env: NodeJS.ProcessEnv | Record<string, string | undefined>): boolean {
|
|
return typeof env.KTX_DAEMON_URL === 'string' && env.KTX_DAEMON_URL.trim().length > 0;
|
|
}
|
|
|
|
function hasSqlAnalysisOverride(env: NodeJS.ProcessEnv | Record<string, string | undefined>): boolean {
|
|
return (
|
|
(typeof env.KTX_SQL_ANALYSIS_URL === 'string' && env.KTX_SQL_ANALYSIS_URL.trim().length > 0) ||
|
|
hasDaemonOverride(env)
|
|
);
|
|
}
|
|
|
|
function requiresManagedLocalEmbeddings(embeddings: KtxProjectEmbeddingConfig): boolean {
|
|
if (embeddings.backend !== 'sentence-transformers') {
|
|
return false;
|
|
}
|
|
const baseUrl = embeddings.sentenceTransformers?.base_url;
|
|
return baseUrl === undefined || baseUrl === '' || baseUrl === MANAGED_SENTENCE_TRANSFORMERS_BASE_URL;
|
|
}
|
|
|
|
function uniqueRequirements(requirements: KtxRuntimeRequirement[]): KtxRuntimeRequirements {
|
|
const seen = new Set<string>();
|
|
const deduped: KtxRuntimeRequirement[] = [];
|
|
for (const requirement of requirements) {
|
|
const key = `${requirement.feature}:${requirement.reason}:${requirement.detail}`;
|
|
if (seen.has(key)) {
|
|
continue;
|
|
}
|
|
seen.add(key);
|
|
deduped.push(requirement);
|
|
}
|
|
const features = [...new Set(deduped.map((requirement) => requirement.feature))].sort((left, right) =>
|
|
left.localeCompare(right),
|
|
);
|
|
return { features, requirements: deduped };
|
|
}
|
|
|
|
export function resolveProjectRuntimeRequirements(
|
|
config: KtxProjectConfig,
|
|
options: KtxProjectRuntimeRequirementOptions = {},
|
|
): KtxRuntimeRequirements {
|
|
const env = options.env ?? process.env;
|
|
const requirements: KtxRuntimeRequirement[] = [];
|
|
|
|
if (options.databaseIntrospectionFallback === true && !hasDaemonOverride(env)) {
|
|
requirements.push({
|
|
feature: 'core',
|
|
reason: 'database-introspection',
|
|
detail: 'Database introspection fallback uses the KTX daemon.',
|
|
});
|
|
}
|
|
|
|
for (const [connectionId, connection] of Object.entries(config.connections)) {
|
|
const driver = normalizeDriver(connection.driver);
|
|
if ((driver === 'looker' || driver === 'local_looker') && !hasDaemonOverride(env)) {
|
|
requirements.push({
|
|
feature: 'core',
|
|
reason: 'looker-source',
|
|
detail: `${connectionId} uses Looker identifier parsing.`,
|
|
});
|
|
}
|
|
|
|
if (hasEnabledQueryHistory(connection) && !hasSqlAnalysisOverride(env)) {
|
|
requirements.push({
|
|
feature: 'core',
|
|
reason: 'query-history',
|
|
detail: `${connectionId} has query history enabled.`,
|
|
});
|
|
}
|
|
}
|
|
|
|
if (requiresManagedLocalEmbeddings(config.ingest.embeddings)) {
|
|
requirements.push({
|
|
feature: 'local-embeddings',
|
|
reason: 'local-embeddings',
|
|
detail: 'Local sentence-transformers embeddings use the managed Python runtime.',
|
|
});
|
|
}
|
|
|
|
return uniqueRequirements(requirements);
|
|
}
|
|
|
|
export function resolvePublicIngestRuntimeRequirements(
|
|
plan: KtxPublicIngestPlan,
|
|
options: KtxPublicIngestRuntimeRequirementOptions = {},
|
|
): KtxRuntimeRequirements {
|
|
const env = options.env ?? process.env;
|
|
const requirements: KtxRuntimeRequirement[] = [];
|
|
|
|
for (const target of plan.targets) {
|
|
const driver = normalizeDriver(target.driver);
|
|
const adapter = normalizeDriver(target.adapter);
|
|
if (target.queryHistory?.enabled === true && !hasSqlAnalysisOverride(env)) {
|
|
requirements.push({
|
|
feature: 'core',
|
|
reason: 'query-history',
|
|
detail: `${target.connectionId} query-history ingest uses SQL analysis.`,
|
|
});
|
|
}
|
|
if ((driver === 'looker' || driver === 'local_looker' || adapter === 'looker') && !hasDaemonOverride(env)) {
|
|
requirements.push({
|
|
feature: 'core',
|
|
reason: 'looker-source',
|
|
detail: `${target.connectionId} uses Looker identifier parsing.`,
|
|
});
|
|
}
|
|
}
|
|
|
|
return uniqueRequirements(requirements);
|
|
}
|