feat: Self-Evolving Digital Employee OS P0~P6 + 캘린더 충돌 게이트
신뢰성 코어 (P1~P2): - Requirement Graph: 업무 유형(회의록/시장조사/업무조사/일정) 필수 요소 주입 + 커버리지 hook - Confidence Engine(0~100 결정론적) / Escalation Engine(검토 요청) / Epistemic Guard(모름·추정·확실 3분류) - Provenance: citationTrace 에 출처 수정일·오래됨 경고 - Critic Loop: 문제 신호 turn 만 LLM 검수 1회 + 보완 카드 성장 루프 (P3): - Gap Detector(Requirement-Knowledge) / Need Engine(30/25/20/15/10 공식) / Knowledge Inventory - Learning Queue(proposed 전용 병합 — 승인은 사람만) / Decision Journal / Reflection 기록 - 반복 누락 요소(3회+)는 다음 turn 체크리스트에 자동 강조 (T5 루프) 지식 운영 (P4) + 기억 (P5) + 학습 실행 (P6): - Knowledge Validation + Belief Revision(중복 reject·충돌 시 update/add 권고) - Knowledge Decay(분야별 반감기 감사) / Knowledge Debt(blocked x impact) - Organizational Memory(.astra/organization.md 상시 주입) - Research Agent(approved 큐 -> 조사 브리프+추정 라벨 초안+Validation 게이트 -> proposals/) - Skill Score(전/후반 추세) + Success Pattern DB(전요소충족+확신도90+ 자동 적재) 병렬 트랙: - 캘린더 충돌 게이트: conflictCheck + 구조화 이벤트 캐시 + create_calendar_event 차단(force 는 사용자 승인 후) - Task Eval Harness: 회의록 골든셋 자동 채점 명령 + 성장 리포트/학습 큐/노후 점검 명령 신규 모듈 17종(src/intelligence/), VS Code 명령 5종, 설정 11종, 테스트 +89건(전체 508 통과). 설계 문서: docs/SELF_EVOLVING_OS_MASTER_PLAN.md Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,11 @@ import { semanticRerank, DEFAULT_SEMANTIC_RERANK_OPTIONS } from '../../retrieval
|
||||
import { detectAmbiguity, buildIntentClarificationBlock, IntentStrictness } from '../../retrieval/intentClarification';
|
||||
import { buildCitationTraceBlock } from '../../retrieval/citationTrace';
|
||||
import { buildTerminologyBlock } from '../../retrieval/terminologyBlock';
|
||||
import { buildRequirementGraphBlock, detectTaskType } from '../../intelligence/requirementGraph';
|
||||
import { buildEpistemicGuardBlock } from '../../intelligence/epistemicGuardBlock';
|
||||
import { loadReflections, recurrentMisses } from '../../intelligence/reflectionStore';
|
||||
import { buildOrgMemoryBlock } from '../../intelligence/orgMemoryBlock';
|
||||
import type { RetrievalConfidenceSignals } from '../../intelligence/confidenceEngine';
|
||||
|
||||
/**
|
||||
* 한 turn 의 RAG / 5-layer memory 컨텍스트 빌드.
|
||||
@@ -73,6 +78,8 @@ export interface TurnContextSink {
|
||||
dynamicBlocks: Map<string, string>;
|
||||
/** Post-hoc Self-Check 용 — selected chunks 의 (title, excerpt) 요약. */
|
||||
selfCheckSources: Array<{ title: string; excerpt: string }>;
|
||||
/** Confidence Engine 용 검색 신호 (Phase 2 / Track 1-1). memoryContext 가 채움. */
|
||||
confidenceSignals: RetrievalConfidenceSignals | null;
|
||||
}
|
||||
|
||||
export interface MemoryContextDeps {
|
||||
@@ -281,12 +288,55 @@ export async function buildMemoryContext(deps: MemoryContextDeps): Promise<strin
|
||||
const blocks = deps.turnCtx.dynamicBlocks;
|
||||
|
||||
// Intent Clarification — 답변보다 *역질문 우선*. 모호 아닐 때 빈 문자열 → join 시 자동 제외.
|
||||
// ambiguity 결과는 Confidence Engine 신호로도 재사용 (아래 confidenceSignals).
|
||||
const strict = (config.intentClarificationStrictness || 'medium') as IntentStrictness;
|
||||
const ambig = detectAmbiguity(deps.currentPrompt, strict);
|
||||
if (config.intentClarificationEnabled !== false) {
|
||||
const strict = (config.intentClarificationStrictness || 'medium') as IntentStrictness;
|
||||
const ambig = detectAmbiguity(deps.currentPrompt, strict);
|
||||
blocks.set('intent-clarification', buildIntentClarificationBlock(ambig));
|
||||
}
|
||||
|
||||
// Confidence Engine 검색 신호 (Phase 2 / Track 1-1) — post-answer hook 이 확신도
|
||||
// 산출에 사용. brain-trace 는 trace 표시용이라 제외.
|
||||
const groundingChunks = result.selectedChunks.filter((c) => c.source !== 'brain-trace');
|
||||
deps.turnCtx.confidenceSignals = {
|
||||
chunkCount: groundingChunks.length,
|
||||
topScore: groundingChunks.reduce((m, c) => Math.max(m, c.score), 0),
|
||||
conflictCount: groundingChunks.filter(
|
||||
(c) => c.metadata?.conflictSeverity && c.metadata.conflictSeverity !== 'NONE',
|
||||
).length,
|
||||
ambiguityDetected: ambig.ambiguous === true,
|
||||
};
|
||||
|
||||
// Epistemic Guard — 모름/추정/확실 3분류 강제. 검색 근거 없는 turn 일수록 강한 지시
|
||||
// (근거 0건 + 업무 요청이면 원자료 역질문 우선). (Phase 2 / Track 1-3)
|
||||
if (config.epistemicGuardEnabled !== false) {
|
||||
blocks.set('epistemic-guard', buildEpistemicGuardBlock({
|
||||
chunkCount: groundingChunks.length,
|
||||
taskDetected: detectTaskType(deps.currentPrompt) !== null,
|
||||
}));
|
||||
}
|
||||
|
||||
// Requirement Graph — 업무 유형(회의록/시장조사/업무조사/일정) 감지 시 필수 요소
|
||||
// 체크리스트 주입. 미감지 시 빈 문자열 → join 시 자동 제외. (Self-Evolving OS P1)
|
||||
// Reflection 기록에서 *반복 누락 요소* 를 찾아 강조 — T5 "같은 실수 반복 금지" 루프.
|
||||
if (config.requirementGraphEnabled !== false) {
|
||||
let emphasize: string[] = [];
|
||||
const detectedTask = detectTaskType(deps.currentPrompt);
|
||||
if (detectedTask && config.reflectionEnabled !== false) {
|
||||
try {
|
||||
const recent = loadReflections(deps.activeBrain.localBrainPath, 200);
|
||||
emphasize = recurrentMisses(recent, detectedTask.id, 3);
|
||||
} catch { /* 회고 로드 실패가 turn 을 막지 않음 */ }
|
||||
}
|
||||
blocks.set('requirement-graph', buildRequirementGraphBlock(deps.currentPrompt, undefined, emphasize));
|
||||
}
|
||||
|
||||
// Organizational Memory — <brain>/.astra/organization.md 의 조직 규칙·업무 방식을
|
||||
// 항상 주입. 파일 없으면 no-op. (Self-Evolving OS P5 / Track 5-2)
|
||||
if (config.orgMemoryEnabled !== false) {
|
||||
blocks.set('org-memory', buildOrgMemoryBlock(deps.activeBrain.localBrainPath));
|
||||
}
|
||||
|
||||
// Terminology Dictionary — 사용자 편집 글로서리. 파일 없으면 빈 문자열.
|
||||
if (config.glossaryEnabled !== false) {
|
||||
blocks.set('terminology', buildTerminologyBlock({
|
||||
|
||||
Reference in New Issue
Block a user