/** * 기능 인벤토리 자동 생성 + 충돌 스캔 대상 필터 — 순수 로직 테스트. * (자기 지식 구식화 버그의 근본 수정: 인벤토리가 package.json 에서 기계 생성되는지) */ import { buildInventoryMarkdown } from '../src/extension/featureInventory'; import { isScanTarget } from '../src/features/growth/conflictScan'; describe('buildInventoryMarkdown — package.json 이 소스 오브 트루스', () => { const pkg = { version: '9.9.9', contributes: { commands: [ { command: 'g1nation.a', title: 'Astra: 기능 A' }, { command: 'g1nation.b', title: 'Astra: 기능 B (**굵게**)' }, ], configuration: { properties: { 'g1nation.x.enabled': { type: 'boolean', markdownDescription: '**X 자동화** — 매일 실행합니다. 두 번째 문장.' }, 'g1nation.y': { type: 'string', description: 'Y 설정.' }, }, }, }, }; test('버전·명령·설정·훅이 모두 들어간다', () => { const md = buildInventoryMarkdown(pkg, '2026-06-12T00:00:00Z'); expect(md).toContain('v9.9.9'); expect(md).toContain('사용자 명령 (2개)'); expect(md).toContain('Astra: 기능 A'); expect(md).toContain('기능 B (굵게)'); // 마크다운 장식 제거 expect(md).toContain('`x.enabled`'); expect(md).toContain('답변 후 자동 검증 훅'); expect(md).toContain('`critic-loop`'); // 레지스트리에서 직접 — 코드가 곧 문서 expect(md).toContain('수동 편집 금지'); }); test('레지스트리의 모든 훅 id 가 노출된다 (침묵 누락 방지)', () => { const md = buildInventoryMarkdown(pkg, '2026-06-12T00:00:00Z'); for (const id of ['devil-rebuttal', 'self-check', 'term-validator', 'requirement-coverage', 'confidence-escalation', 'critic-loop']) { expect(md).toContain(`\`${id}\``); } }); }); describe('isScanTarget — 충돌 스캔 제외 규칙', () => { test.each([ 'Topics_Rag/새문서.md', 'AI_and_ML/RAG.md', ])('지식 본문은 대상: %s', (p) => expect(isScanTarget(p)).toBe(true)); test.each([ 'Digests/Topics_Rag.md', 'lessons/2026-06-12-correction-x.md', 'playbooks/p.md', 'ASTRA 기능 인벤토리.md', 'Topics_Rag/이미지.png', ])('소화 노트·레슨·인벤토리·비-md 제외: %s', (p) => expect(isScanTarget(p)).toBe(false)); });