Files
brain/tools/m3e-card-coverage-invariants.test.mjs
T

35 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, it, expect } from 'vitest';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
import { loadRegistry as loadNodes, clearCache } from './registry-load.mjs';
import { loadRegistry as loadContracts } from './skill-contract-registry.mjs';
import { buildNodeGraph } from './node-graph.mjs';
import { missingContracts, emptyCards, unresolvedConflicts, asymmetricConflicts } from './card-coverage.mjs';
const here = dirname(fileURLToPath(import.meta.url));
const registryPath = join(here, '..', 'docs', 'registry', 'nodes.yaml');
const contractsDir = join(here, '..', 'docs', 'registry', 'contracts');
describe('Машина 3-E — покрытие реестра карточками (живой инвариант H)', () => {
it('у каждого узла nodes.yaml есть карточка с skill===slug', () => {
clearCache();
const nodes = loadNodes({ registryPath, useCache: false }).nodes;
const { contracts } = loadContracts({ dir: contractsDir });
expect(missingContracts(nodes, contracts)).toEqual([]);
});
it('нет пустых карточек (needs∪produces непусто)', () => {
const { contracts } = loadContracts({ dir: contractsDir });
expect(emptyCards(contracts)).toEqual([]);
});
it('конфликт-рёбра резолвятся и симметричны', () => {
clearCache();
const g = buildNodeGraph(loadNodes({ registryPath, useCache: false }));
expect(unresolvedConflicts(g)).toEqual([]);
expect(asymmetricConflicts(g)).toEqual([]);
});
it('реестр контрактов собирается без формальных ошибок и дублей', () => {
const { errors } = loadContracts({ dir: contractsDir });
expect(errors).toEqual([]);
});
});