feat: v2.2.173-193 — 4인 팀 운영 슬래시 13개 + ASTRA 검증 엔진 6종

4인 팀 운영 슬래시 (v2.2.173~189):
- 일과 리듬: /morning, /evening, /weekly, /standup
- 트래커 (event-sourced .astra/*.jsonl): /runway, /customers, /hire
- 작업·결정: /task, /blocked, /onesie, /decisions
- 외부 출력: /draft, /feedback
- 분석: /cohort (MoM 추세)

ASTRA 추론·검색 엔진 (v2.2.183~192):
- v2.2.183 Conflict Surface — scoring.conflictSeverity 를 [CONFLICT WARNINGS] 블록으로
  서피스 + 교차-문서 발산(Jaccard) 감지
- v2.2.184 Chain-of-Verification — [VERIFICATION CHECKLIST] 답변 작성 전 그라운딩 자기 점검
  (instructional, strictMode 옵션)
- v2.2.185 Actionability Scoring — 최근 슬래시 명령 + 열린 파일 신호로 검색 결과 재가중
- v2.2.186 Temporal Markers + Distillation Loop — LongTerm/Episodic 만료 필터 +
  30일+ stale episode → LongTerm 'episode-digest' 승급 (수동 /memory distill + 세션 종료 자동)
- v2.2.187 Hierarchical Context Window + LLM Semantic Re-rank — 3-level 추상도 매칭
  + 토큰 예산 통과 후 LLM 1회로 의도-부합 재정렬 (opt-in)
- v2.2.190 Intent Clarification + Citation Trace — 모호 차원 감지 시 역질문 우선
  + 답변 끝 사용 출처 한 줄 정리
- v2.2.191 Post-hoc Self-Check — 답변 완료 후 별도 LLM 호출 1회로 답함/그라운딩/모순 평가,
  footer 한 줄로 표시 (opt-in, semantic re-rank 와 같은 안전 fallback 패턴)
- v2.2.192 Terminology Dictionary — .astra/glossary.md 사용자 편집 파일 + Term Check
  지침 통합 + /glossary init/path/reload
- v2.2.193 /help — 카테고리별 명령 목록 + 6종 verification 블록 현재 on/off

신규 모듈:
- src/retrieval/{conflictBlock,coveBlock,actionabilityScoring,hierarchicalLevel,
  semanticRerank,intentClarification,citationTrace,terminologyBlock}.ts
- src/memory/distillation.ts + types.ts 에 expiresAt/promoted/episode-digest 추가
- src/agent/postHocSelfCheck.ts
- src/features/{customers,feedback,hire,runway}/*.ts (event-sourced stores)

ASTRA 검증 5종 자동 주입 (buildAstraModeSystemPrompt, casual 모드 제외):
[INTENT CLARIFICATION GUIDANCE] (답변 시작 전) → [TERMINOLOGY DICTIONARY] +
[CONFLICT WARNINGS] + [VERIFICATION CHECKLIST] (작성 중) → [CITATION TRACE] (끝)
+ 6번째: Post-hoc Self-Check footer (답변 완료 후, opt-in)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-29 16:05:30 +09:00
parent f3439ddad5
commit 990ea0ae5f
46 changed files with 7172 additions and 136 deletions
+77 -1
View File
@@ -164,6 +164,7 @@ import { buildAgentModeSystemPrompt } from './agent/handlePrompt/buildAgentModeS
import { buildAstraModeSystemPrompt } from './agent/handlePrompt/buildAstraModeSystemPrompt';
import { computeBudgetedRequest } from './agent/handlePrompt/computeBudgetedRequest';
import { processFinalAnswer } from './agent/handlePrompt/processFinalAnswer';
import { postHocSelfCheck, formatSelfCheckFooter, DEFAULT_SELF_CHECK_OPTIONS } from './agent/postHocSelfCheck';
import { applyAutoContinuation } from './agent/handlePrompt/applyAutoContinuation';
export interface ChatMessage {
@@ -285,10 +286,28 @@ export class AgentExecutor {
lessons: string[];
/** 이번 turn 에 결정된 Knowledge Mix — scope footer 표시용. */
knowledgeMix: ResolvedKnowledgeMix | null;
/** [CONFLICT WARNINGS] 시스템 프롬프트 블록 — 검색된 출처에서 충돌 신호 감지 시. */
conflictWarnings: string;
/** [VERIFICATION CHECKLIST] Chain-of-Verification 블록 — 그라운딩 자기 검증 지시. */
coveChecklist: string;
/** [INTENT CLARIFICATION GUIDANCE] — 모호 질의 감지 시 역질문 우선 지시. */
intentClarification: string;
/** [CITATION TRACE] — 답변 끝에 사용 출처 한 줄 정리 지시. */
citationTrace: string;
/** Self-check 용 — selected chunks 의 (title, content) 요약. memoryContext 가 채움. */
selfCheckSources: Array<{ title: string; excerpt: string }>;
/** [TERMINOLOGY DICTIONARY] — 사용자 편집 글로서리 + Term Check 지침. */
terminology: string;
} = {
retrieval: null,
lessons: [],
knowledgeMix: null,
conflictWarnings: '',
coveChecklist: '',
intentClarification: '',
citationTrace: '',
selfCheckSources: [],
terminology: '',
};
/** Per-turn state 일괄 정리. turn 시작/abort/load session 시 호출. */
@@ -296,6 +315,12 @@ export class AgentExecutor {
this._turnCtx.retrieval = null;
this._turnCtx.lessons = [];
this._turnCtx.knowledgeMix = null;
this._turnCtx.conflictWarnings = '';
this._turnCtx.coveChecklist = '';
this._turnCtx.intentClarification = '';
this._turnCtx.citationTrace = '';
this._turnCtx.selfCheckSources = [];
this._turnCtx.terminology = '';
}
private readonly options: AgentExecutorOptions;
@@ -647,6 +672,11 @@ export class AgentExecutor {
isCasualConversation,
localPathContext,
knowledgeMix: this._turnCtx.knowledgeMix,
conflictWarningsCtx: this._turnCtx.conflictWarnings,
coveChecklistCtx: this._turnCtx.coveChecklist,
intentClarificationCtx: this._turnCtx.intentClarification,
citationTraceCtx: this._turnCtx.citationTrace,
terminologyCtx: this._turnCtx.terminology,
});
// Context budget computation → src/agent/handlePrompt/computeBudgetedRequest.ts
const imageCount = (reqMessages as any[])
@@ -1200,6 +1230,12 @@ export class AgentExecutor {
contextLength: ctxLimits.contextLength,
engine,
});
// ── Post-hoc Self-Check (v2.2.191) — 별도 LLM 호출 1회로 답변 사후 검증. ──
// 비동기 — Devil 과 동일 패턴. 결과를 footer 한 줄로 append.
void this._maybePostHocSelfCheck({
userPrompt: prompt || '',
assistantAnswer: finalAssistantContent,
});
} else {
this.webview.postMessage({ type: 'streamChunk', value: finalAssistantContent });
}
@@ -1282,10 +1318,18 @@ export class AgentExecutor {
const workspaceFolders = vscode.workspace.workspaceFolders;
const workspacePath = workspaceFolders ? workspaceFolders[0].uri.fsPath : undefined;
const cfgNow = getConfig();
this.memoryManager.onSessionEnd(
this.currentTaskId,
this.chatHistory.filter((m) => !m.internal),
workspacePath
workspacePath,
cfgNow.localBrainPath ? {
enabled: cfgNow.distillationEnabled !== false,
ageThresholdDays: cfgNow.distillationAgeThresholdDays ?? 30,
intervalDays: cfgNow.distillationIntervalDays ?? 7,
archiveMode: (cfgNow.distillationArchiveMode || 'mark-promoted') as any,
brainPath: cfgNow.localBrainPath,
} : undefined,
);
logInfo('Memory extraction completed for session end.', { taskId: this.currentTaskId });
recordTelemetry({
@@ -1366,6 +1410,38 @@ export class AgentExecutor {
}, opts);
}
/**
* Post-hoc Self-Check — 답변 *완료 후* LLM 1회 호출로 3가지 평가
* (사용자 질의 직접 답함 / 출처 그라운딩 / 논리 모순). 비동기 — main turn 에 영향 없음.
* 기본 OFF (g1nation.selfCheckEnabled). 결과는 footer 한 줄로 streamChunk append.
*/
private async _maybePostHocSelfCheck(opts: {
userPrompt: string;
assistantAnswer: string;
}): Promise<void> {
try {
const cfg = getConfig();
if (!cfg.selfCheckEnabled) return;
if (!opts.userPrompt.trim() || !opts.assistantAnswer.trim()) return;
const model = (cfg.selfCheckModel || '').trim() || cfg.defaultModel;
if (!model || !cfg.ollamaUrl) return;
const sources = this._turnCtx.selfCheckSources || [];
const result = await postHocSelfCheck(opts.userPrompt, opts.assistantAnswer, sources, {
ollamaUrl: cfg.ollamaUrl,
model,
timeoutMs: (cfg.selfCheckTimeoutSec ?? 6) * 1000,
excerptLength: DEFAULT_SELF_CHECK_OPTIONS.excerptLength,
maxSources: DEFAULT_SELF_CHECK_OPTIONS.maxSources,
});
// 성공 실패 모두 footer 표시 — 사용자가 self-check 가 *돌고 있는지* 알 수 있게.
// 실패 시 흐릿한 한 줄, 성공 시 평가 한 줄.
const footer = formatSelfCheckFooter(result, model);
this.webview?.postMessage({ type: 'streamChunk', value: footer });
} catch { /* swallow — self-check never breaks the turn */ }
}
private async callNonStreaming(params: {
baseUrl: string;
modelName: string;