cfbfd9c6b4
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
40 lines
1.8 KiB
JavaScript
40 lines
1.8 KiB
JavaScript
// tools/door-coverage.test.mjs
|
|
import { describe, it, expect } from 'vitest';
|
|
import { auditDoors } from './door-coverage.mjs';
|
|
import { auditExempt } from './door-coverage.mjs';
|
|
|
|
describe('auditDoors (P15-b)', () => {
|
|
it('flags a tool not covered by the supreme matcher', () => {
|
|
const r = auditDoors({ tools: ['Write', 'Bash', 'WebFetch'], matcher: ['Write', 'Bash'], seeds: ['AskUserQuestion'] });
|
|
expect(r.uncovered).toEqual(['WebFetch']);
|
|
expect(r.ok).toBe(false);
|
|
});
|
|
it('star matcher covers everything → ok', () => {
|
|
const r = auditDoors({ tools: ['Write', 'Bash', 'WebFetch'], matcher: ['*'], seeds: [] });
|
|
expect(r.uncovered).toEqual([]);
|
|
expect(r.ok).toBe(true);
|
|
});
|
|
it('seeds are not counted as uncovered', () => {
|
|
const r = auditDoors({ tools: ['AskUserQuestion', 'Write'], matcher: ['Write'], seeds: ['AskUserQuestion'] });
|
|
expect(r.uncovered).toEqual([]);
|
|
expect(r.ok).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('auditExempt (страховка зелёного прохода, F)', () => {
|
|
// классификатор мутации инъектируется (в проде — общий с supreme-gate)
|
|
const SAFE = new Set(['Read', 'Grep', 'Glob', 'LS', 'AskUserQuestion', 'EnterPlanMode']);
|
|
const isMutating = (t) => !SAFE.has(t) && !String(t).startsWith('Skill:');
|
|
|
|
it('мутирующий инструмент в зелёном проходе → флаг', () => {
|
|
const r = auditExempt({ exempt: ['Read', 'Bash'], isMutating });
|
|
expect(r.ok).toBe(false);
|
|
expect(r.flagged).toEqual(['Bash']);
|
|
});
|
|
it('только-смотрящие + семена в зелёном проходе → ok', () => {
|
|
const r = auditExempt({ exempt: ['Read', 'Grep', 'AskUserQuestion'], isMutating });
|
|
expect(r.ok).toBe(true);
|
|
expect(r.flagged).toEqual([]);
|
|
});
|
|
});
|