mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
* fix(ci): publish the pre-built tarball instead of re-packing
The release workflow built the tarball twice — once via pnpm pack in
artifacts:check (leaving it at dist/artifacts/npm/) and again inside
@semantic-release/npm's prepare step, which then tried to fs-extra
move npm pack's output into the same directory and crashed with
"dest already exists". On top of being a publish blocker, that meant
the published tarball was different from the one smoke-tested in
artifacts:check.
Drop @semantic-release/npm and publish the exact tarball that
artifacts:check verified via an exec publishCmd:
npm publish dist/artifacts/npm/kaelio-ktx-<v>.tgz \
--tag <next|latest> --access public --provenance
Auth uses OIDC trusted publishing — the workflow already grants
id-token: write and setup-node configures the registry, and
release-workflow.test.mjs asserts NODE_AUTH_TOKEN is not set.
* fix(ci): allow @kaelio/ktx tarball name in semantic-release config
The new publishCmd added in the previous commit hardcodes the
dist/artifacts/npm/kaelio-ktx-<v>.tgz path, which trips the boundary
check that forbids the literal product name outside release-machinery
files. The release config is exactly such a release-machinery file —
its job is to bridge the generic ktx project to the @kaelio/ktx npm
package — so add it to identifierAllowPatterns alongside the existing
build-public-npm-package and public-npm-release-metadata entries.
167 lines
6.6 KiB
JavaScript
167 lines
6.6 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { describe, it } from 'node:test';
|
|
|
|
import { scanFileContent } from './check-boundaries.mjs';
|
|
|
|
function productName() {
|
|
return ['Kae', 'lio'].join('');
|
|
}
|
|
|
|
function lowerProductName() {
|
|
return ['kae', 'lio'].join('');
|
|
}
|
|
|
|
describe('scanFileContent', () => {
|
|
it('rejects source imports from application directories', () => {
|
|
const serverAlias = '@' + 'server/contracts';
|
|
const pythonAppPath = `${['python', 'service'].join('-')}/app/api/endpoints/semantic_layer.py`;
|
|
|
|
const violations = [
|
|
...scanFileContent('packages/context/src/index.ts', `import { orpc } from '${serverAlias}';`),
|
|
...scanFileContent('packages/context/src/index.ts', `import "${pythonAppPath}";`),
|
|
];
|
|
|
|
assert.deepEqual(
|
|
violations.map((violation) => violation.kind),
|
|
['app-import', 'app-import'],
|
|
);
|
|
});
|
|
|
|
it('rejects forbidden product identifiers in code source files', () => {
|
|
const violations = scanFileContent('packages/context/src/index.ts', `export const owner = '${lowerProductName()}';`);
|
|
|
|
assert.equal(violations.length, 1);
|
|
assert.equal(violations[0]?.kind, 'identifier');
|
|
});
|
|
|
|
it('rejects forbidden product identifiers in shipped runtime prompt assets', () => {
|
|
const violations = scanFileContent(
|
|
'packages/context/prompts/memory_agent_bundle_ingest_work_unit.md',
|
|
`Write output for ${productName()}.`,
|
|
);
|
|
|
|
assert.equal(violations.length, 1);
|
|
assert.equal(violations[0]?.kind, 'identifier');
|
|
assert.equal(violations[0]?.file, 'packages/context/prompts/memory_agent_bundle_ingest_work_unit.md');
|
|
});
|
|
|
|
it('rejects forbidden product identifiers in shipped runtime skill assets', () => {
|
|
const violations = scanFileContent(
|
|
'packages/context/skills/metabase_ingest/SKILL.md',
|
|
`Use ${productName()} project conventions.`,
|
|
);
|
|
|
|
assert.equal(violations.length, 1);
|
|
assert.equal(violations[0]?.kind, 'identifier');
|
|
assert.equal(violations[0]?.file, 'packages/context/skills/metabase_ingest/SKILL.md');
|
|
});
|
|
|
|
it('allows product identifiers in docs, examples, and transition metadata', () => {
|
|
const name = productName();
|
|
|
|
assert.equal(scanFileContent('docs/transition.md', name).length, 0);
|
|
assert.equal(scanFileContent('examples/transition.md', name).length, 0);
|
|
assert.equal(scanFileContent('python/ktx-sl/plans/brainstorm.md', name).length, 0);
|
|
assert.equal(scanFileContent('python/ktx-sl/openspec/specs/semantic-layer/spec.md', name).length, 0);
|
|
});
|
|
|
|
it('allows product identifiers in test fixtures', () => {
|
|
const name = lowerProductName();
|
|
|
|
assert.equal(scanFileContent('packages/cli/src/setup.test.ts', `project: ${name}-dev`).length, 0);
|
|
assert.equal(scanFileContent('packages/context/src/ingest/importer.test.ts', `email: system@${name}.dev`).length, 0);
|
|
assert.equal(scanFileContent('python/ktx-daemon/tests/test_package.py', `${name}-ktx`).length, 0);
|
|
});
|
|
|
|
it('allows public package identifiers in release packaging and managed runtime source', () => {
|
|
const name = lowerProductName();
|
|
|
|
assert.equal(scanFileContent('scripts/local-embeddings-runtime-smoke.mjs', `@${name}/ktx`).length, 0);
|
|
assert.equal(scanFileContent('scripts/package-artifacts.test.mjs', `${name}-ktx`).length, 0);
|
|
assert.equal(scanFileContent('scripts/public-npm-release-metadata.mjs', `@${name}/ktx`).length, 0);
|
|
assert.equal(scanFileContent('scripts/semantic-release-config.cjs', `${name}-ktx-`).length, 0);
|
|
assert.equal(scanFileContent('packages/cli/src/release-version.ts', `@${name}/ktx`).length, 0);
|
|
assert.equal(scanFileContent('packages/cli/src/managed-python-runtime.ts', `${name}_ktx`).length, 0);
|
|
assert.equal(scanFileContent('python/ktx-daemon/src/ktx_daemon/__init__.py', `${name}-ktx`).length, 0);
|
|
});
|
|
|
|
it('allows clean source files and clean runtime prompt assets', () => {
|
|
assert.deepEqual(
|
|
scanFileContent('packages/context/src/index.ts', "export const packageName = '@ktx/context';"),
|
|
[],
|
|
);
|
|
assert.deepEqual(
|
|
scanFileContent('packages/context/prompts/memory_agent_bundle_ingest_work_unit.md', 'Write output for KTX.'),
|
|
[],
|
|
);
|
|
});
|
|
|
|
it('rejects context-owned LLM provider construction outside @ktx/llm', () => {
|
|
const violations = [
|
|
...scanFileContent(
|
|
'packages/context/src/agent/local-llm-provider.ts',
|
|
"import { createAnthropic } from '@ai-sdk/anthropic';",
|
|
),
|
|
...scanFileContent('packages/context/src/scan/local-ai-gateway-enrichment.ts', "import { createGateway } from 'ai';"),
|
|
...scanFileContent('packages/context/src/core/local-embedding-provider.ts', "import { embedMany } from 'ai';"),
|
|
];
|
|
|
|
assert.deepEqual(
|
|
violations.map((violation) => violation.kind),
|
|
['llm-boundary', 'llm-boundary', 'llm-boundary'],
|
|
);
|
|
});
|
|
|
|
it('rejects old KTX LLM port declarations in context', () => {
|
|
const violations = [
|
|
...scanFileContent('packages/context/src/agent/agent-runner.service.ts', 'export interface LlmProviderPort {}'),
|
|
...scanFileContent('packages/context/src/scan/types.ts', 'export interface KtxScanLlmPort {}'),
|
|
...scanFileContent('packages/context/src/agent/gateway-llm-provider.ts', 'export function createGatewayLlmProvider() {}'),
|
|
];
|
|
|
|
assert.deepEqual(
|
|
violations.map((violation) => violation.kind),
|
|
['llm-boundary', 'llm-boundary', 'llm-boundary'],
|
|
);
|
|
});
|
|
|
|
it('rejects getModelByName calls in context production source', () => {
|
|
const violations = scanFileContent(
|
|
'packages/context/src/ingest/page-triage/page-triage.service.ts',
|
|
"const model = this.deps.llmProvider.getModelByName('claude-sonnet-4-6');",
|
|
);
|
|
|
|
assert.equal(violations.length, 1);
|
|
assert.equal(violations[0]?.kind, 'llm-boundary');
|
|
assert.equal(
|
|
violations[0]?.message,
|
|
'Forbidden context getModelByName call; use getModel(role) inside @ktx/context',
|
|
);
|
|
});
|
|
|
|
it('allows role-driven getModel calls, test calls, and provider shape declarations', () => {
|
|
assert.deepEqual(
|
|
scanFileContent(
|
|
'packages/context/src/ingest/page-triage/page-triage.service.ts',
|
|
"const model = this.deps.llmProvider.getModel('triage');",
|
|
),
|
|
[],
|
|
);
|
|
|
|
assert.deepEqual(
|
|
scanFileContent(
|
|
'packages/context/src/ingest/page-triage/page-triage.service.test.ts',
|
|
"const model = this.deps.llmProvider.getModelByName('test-model');",
|
|
),
|
|
[],
|
|
);
|
|
|
|
assert.deepEqual(
|
|
scanFileContent(
|
|
'packages/context/src/scan/local-enrichment.ts',
|
|
'return { getModel() { return model; }, getModelByName() { return model; } };',
|
|
),
|
|
[],
|
|
);
|
|
});
|
|
});
|