b0cd18d797
Квирк 2: новый stripQuotedSpans делает детектор stdout/stderr-редиректа кавычко-осознанным — `>` / `2>` ВНУТРИ кавыченного аргумента (текст коммита с <email>, "2>1") больше не ложно-блокируется; настоящие редиректы (оператор вне кавычек) блокируются как прежде. RED→GREEN, существующие redirect/cd-app кейсы целы. 1A: убрана реклама мёртвых override-фраз (findOverride — заглушка v4, фразы не работают): баннер enforce-prompt-injection (каждый UserPromptSubmit) + block-сообщения enforce-verify-before-push / coverage-verify / memory-coverage / tdd-gate (×3). Каждый фикс залочен негативным тестом. Сознательно НЕ делали: калибровку 6 судьи (читать чат-контекст) и ослабление exact-match approve (квирк 3) — это рубежи защиты, их трогать нельзя. Регрессия vitest tools-only: 1989 passed | 2 skipped (verify через npx vitest run --root app --config vitest.config.tools.mjs). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
78 lines
2.8 KiB
JavaScript
78 lines
2.8 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { decide } from './enforce-coverage-verify.mjs';
|
|
|
|
describe('enforce-coverage-verify / decide', () => {
|
|
it('allows turn with no mutating tools (pure conversational)', () => {
|
|
const r = decide({ toolUses: [{ name: 'Read', input: {} }], assistantText: 'just talking' });
|
|
expect(r.block).toBe(false);
|
|
});
|
|
|
|
it('blocks mutating turn with no coverage line', () => {
|
|
const r = decide({
|
|
toolUses: [{ name: 'Edit', input: { file_path: 'foo.mjs' } }],
|
|
assistantText: 'just did some work',
|
|
});
|
|
expect(r.block).toBe(true);
|
|
expect(r.message).toMatch(/no.*coverage/);
|
|
// 1A (2026-05-31): не рекламировать мёртвые override-фразы (findOverride — заглушка v4).
|
|
expect(r.message).not.toMatch(/Override:/);
|
|
expect(r.message).not.toMatch(/без скилов|direct ok/);
|
|
});
|
|
|
|
it('blocks when coverage says skill but Skill tool not invoked', () => {
|
|
const r = decide({
|
|
toolUses: [{ name: 'Edit', input: { file_path: 'foo.mjs' } }],
|
|
assistantText: 'coverage: skill:superpowers:test-driven-development\nдалее…',
|
|
});
|
|
expect(r.block).toBe(true);
|
|
expect(r.message).toMatch(/Skill tool was never invoked/);
|
|
});
|
|
|
|
it('allows when coverage says skill and Skill tool invoked with matching name', () => {
|
|
const r = decide({
|
|
toolUses: [
|
|
{ name: 'Skill', input: { skill: 'superpowers:test-driven-development' } },
|
|
{ name: 'Edit', input: { file_path: 'foo.mjs' } },
|
|
],
|
|
assistantText: 'coverage: skill:superpowers:test-driven-development\nок',
|
|
});
|
|
expect(r.block).toBe(false);
|
|
});
|
|
|
|
it('allows when coverage matches without superpowers: prefix in tool input', () => {
|
|
const r = decide({
|
|
toolUses: [
|
|
{ name: 'Skill', input: { skill: 'test-driven-development' } },
|
|
{ name: 'Edit', input: { file_path: 'foo.mjs' } },
|
|
],
|
|
assistantText: 'coverage: skill:superpowers:test-driven-development',
|
|
});
|
|
expect(r.block).toBe(false);
|
|
});
|
|
|
|
it('allows direct coverage', () => {
|
|
const r = decide({
|
|
toolUses: [{ name: 'Edit', input: { file_path: 'memory/foo.md' } }],
|
|
assistantText: 'coverage: direct:memory-sync',
|
|
});
|
|
expect(r.block).toBe(false);
|
|
});
|
|
|
|
it('allows node coverage', () => {
|
|
const r = decide({
|
|
toolUses: [{ name: 'Edit', input: { file_path: 'foo.vue' } }],
|
|
assistantText: 'coverage: node:#19',
|
|
});
|
|
expect(r.block).toBe(false);
|
|
});
|
|
|
|
it('allows when override phrase present', () => {
|
|
const r = decide({
|
|
toolUses: [{ name: 'Edit', input: { file_path: 'foo.mjs' } }],
|
|
assistantText: 'no coverage',
|
|
override: { phrase: 'без скилов', suppresses: ['coverage-skill-match'] },
|
|
});
|
|
expect(r.block).toBe(false);
|
|
});
|
|
});
|