mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-16 08:25:14 +02:00
Align the tree with AGENTS.md/CLAUDE.md conventions: - Rewrite user-facing strings, docs, and tests to lowercase `ktx` (no bare uppercase `KTX` tokens remain outside literal identifiers). - Drop the legacy `historicSql` migration path and its now-unused helpers, per the no-backward-compat rule. - Remove `as unknown as` / `any` casts: narrow `BaseTool` generics to `z.ZodObject`, add a typed `createLookerClient`, and delete the dead `getParametersSchema`/`toAnthropicFormat` pre-AI-SDK helpers. - Use `InvalidArgumentError` for Commander parse failures. - Finish the adapter→connector prose conversion in the `ktx.yaml` docs while keeping the literal `adapters` config key.
62 lines
2.7 KiB
TypeScript
62 lines
2.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
deletedRawPathsScenario,
|
|
flaggedFallbackScenario,
|
|
postSaveSecretFailureScenario,
|
|
successfulReplayScenario,
|
|
validationRevertScenario,
|
|
} from './acceptance-fixtures.js';
|
|
import { renderMemoryFlowReplay } from '../../../../src/context/ingest/memory-flow/render.js';
|
|
import { buildMemoryFlowViewModel } from '../../../../src/context/ingest/memory-flow/view-model.js';
|
|
|
|
function renderScenario(input = successfulReplayScenario(), terminalWidth = 140): string {
|
|
return renderMemoryFlowReplay(buildMemoryFlowViewModel(input), { terminalWidth });
|
|
}
|
|
|
|
describe('memory-flow acceptance scenarios', () => {
|
|
it('renders a completed replay with a clear saved-memory completion line', () => {
|
|
const output = renderScenario(successfulReplayScenario());
|
|
|
|
expect(output).toContain('ktx memory flow warehouse/metricflow done');
|
|
expect(output).toContain('Saved 3 memories from 4 raw files: 2 wiki pages, 1 SL updates.');
|
|
expect(output).toContain('Commit: abc12345 Run: run-success Report: ingest-report.json');
|
|
});
|
|
|
|
it('renders deleted raw paths as eviction candidates without listing every raw path by default', () => {
|
|
const output = renderScenario(deletedRawPathsScenario());
|
|
|
|
expect(output).toContain('2 deletions');
|
|
expect(output).toContain('Eviction candidates: 2');
|
|
expect(output).not.toContain('/full/local/path/private/orders-2024.sql');
|
|
});
|
|
|
|
it('renders invalid semantic-layer writes as reverted, not saved', () => {
|
|
const output = renderScenario(validationRevertScenario());
|
|
|
|
expect(output).toContain('orders reverted: semantic-layer validation failed for warehouse.orders');
|
|
expect(output).toContain('Invalid semantic-layer writes were not saved.');
|
|
expect(output).not.toContain('Saved 1 memories');
|
|
});
|
|
|
|
it('renders flagged fallbacks in gates details', () => {
|
|
const output = renderScenario(flaggedFallbackScenario());
|
|
|
|
expect(output).toContain('0 conflict, 1 fallback');
|
|
expect(output).toContain('Flagged fallbacks: 1');
|
|
});
|
|
|
|
it('renders no ANSI color codes in the text fallback for terminals without color support', () => {
|
|
const output = renderScenario(successfulReplayScenario(), 80);
|
|
|
|
expect(output).toContain('ktx memory flow warehouse/metricflow done');
|
|
expect(output).not.toMatch(/\u001b\[[0-9;]*m/);
|
|
});
|
|
|
|
it('redacts secrets in visible post-save failure text', () => {
|
|
const output = renderScenario(postSaveSecretFailureScenario());
|
|
|
|
expect(output).toContain('Post-save error: index refresh failed https://[redacted] token=[redacted]');
|
|
expect(output).not.toContain('abc123');
|
|
expect(output).not.toContain('https://example.com/private');
|
|
});
|
|
});
|