Files
connectai/tests/featureInventory.test.ts
koriweb b03a49bfc3 feat(growth): 자기 지식 자동화 + 회귀 경보 + 충돌 스캔 + Critic 게이트 확장 (v2.2.225)
[근본 수정 — 자가검증 구식 정보 버그]
ASTRA 자기 지식이 사람이 쓴 스냅샷(selfIdentity 블록·아키텍처 위키 문서)에
의존해 릴리스마다 구식이 됐고, 자기 개선 제안에서 이미 있는 기능을 신규
제안하는 오류가 반복됨. 수정:
- featureInventory.ts: 활성화 시 package.json(contributes.commands/configuration)
  + POST_ANSWER_HOOKS 레지스트리에서 "ASTRA 기능 인벤토리" 문서를 두뇌에
  기계 생성 (버전 변경 시 자동 재생성 — 사람이 갱신을 잊을 수 없는 구조).
- selfIdentity: "자기 기능 평가·제안 전 인벤토리와 대조, 기억 의존 서술 금지" 규칙.

[검증-피드백-재설계 파이프라인 보강 — 의견 검토 후 역제안 3건]
- A-1 골든셋 회귀 경보: 주간 사이클이 metrics-history.jsonl 적립 + 직전 대비
  recall@1 -10%p 또는 MRR -0.08 하락 시 ⚠️ + 그 기간 추가된 문서를 용의자로
  제시(regression-alert.md). 자동 롤백 없음 — 판단은 사람.
- A-2 신규 지식 충돌 스캔(conflictScan.ts): 일일(사전 소화와 같은 슬롯) 신규/변경
  문서를 기존 유사 top-2와 LLM 모순 비교 → 충돌 시 conflict-report.md +
  "기존 A vs 신규 B" 알림. 쓰기 주체(Datacollect/수동/Research) 무관 포착.
  런당 비교 ≤5건·최초 실행 24h 한정 (폭주 방지).
- A-3 criticLoop 게이트 확장: 업무 turn 외에도 "근거 약함(top<0.25) + 단정
  표현(수치·날짜·확언)" 트리거 추가. 전 답변 강제 2-pass 는 기각 — intrinsic
  self-correction 은 외부 신호 없이 효과 없음(arXiv 2310.01798).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 11:44:58 +09:00

59 lines
2.6 KiB
TypeScript

/**
* 기능 인벤토리 자동 생성 + 충돌 스캔 대상 필터 — 순수 로직 테스트.
* (자기 지식 구식화 버그의 근본 수정: 인벤토리가 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));
});