ed89028b1d
Машина 3-D «Движок роутера» собрана (TDD): router-engine.mjs (detectHighRisk 6.1 детерминированный / validateLevelSkip 6.2 / cheaperOf / validateTrace 5.1 / groundTrace ОВ-Д2 / buildRouterPrompt+parse+runRouter, llmCall мокается как router-classifier) + step-pointer.mjs (дерево-указатель волн D6/OQ1, стендово). 35 новых тестов, регрессия tools-only 2193 GREEN. K4-поправка к стене + live-wiring + перенос волн в живой main — ОТЛОЖЕНО до Машины 4 (журнал вопросов).
32 lines
1.9 KiB
JavaScript
32 lines
1.9 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { loadRegistry, clearCache } from './registry-load.mjs';
|
|
import { buildNodeGraph } from './node-graph.mjs';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { dirname, join } from 'node:path';
|
|
import { runRouter, buildRouterPrompt, detectHighRisk } from './router-engine.mjs';
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const registryPath = join(here, '..', 'docs', 'registry', 'nodes.yaml');
|
|
|
|
describe('Машина 3-D — движок на реальном графе узлов', () => {
|
|
it('выбор реального узла проходит, выдуманный отклоняется (на реальном графе)', async () => {
|
|
clearCache();
|
|
const graph = buildNodeGraph(loadRegistry({ registryPath, useCache: false }));
|
|
const real = await runRouter({ prompt: 'нужна архитектурная диаграмма', graph,
|
|
llmCall: async () => ({ candidates: ['mermaid'], chosen: 'mermaid', why_chosen: 'диаграмма', twins_considered: 'нет', confidence: 0.9 }) });
|
|
expect(real.ok).toBe(true);
|
|
const fake = await runRouter({ prompt: 'x', graph,
|
|
llmCall: async () => ({ candidates: ['totally-invented'], chosen: 'totally-invented', why_chosen: 'y', twins_considered: 'z', confidence: 0.9 }) });
|
|
expect(fake.ok).toBe(false);
|
|
});
|
|
it('промпт несёт каталог реальных узлов', () => {
|
|
clearCache();
|
|
const graph = buildNodeGraph(loadRegistry({ registryPath, useCache: false }));
|
|
const { system } = buildRouterPrompt({ prompt: 'x', graph });
|
|
expect(system).toMatch(/mermaid|adr-kit|writing-plans/);
|
|
});
|
|
it('детерминированный риск на прод-выкате не зависит от мнения модели', () => {
|
|
expect(detectHighRisk({ op: 'Bash', command: 'php artisan migrate', prodDeploy: true }).high).toBe(true);
|
|
});
|
|
});
|