Resolve conflicts by preferring remote changes

This commit is contained in:
g1nation
2026-05-14 21:58:59 +09:00
parent 0004853fcf
commit 05d05a392c
12 changed files with 1237 additions and 837 deletions
+27 -1
View File
@@ -4,10 +4,12 @@ import * as path from 'path';
import { createHash } from 'crypto';
import { lockManager } from '../core/lock';
import { actionQueue } from '../core/queue';
import { logInfo, logError } from '../utils';
import { logInfo, logError, getActiveBrainProfile } from '../utils';
import { AgentDataValidator, PerformanceProfiler, CognitionAudit } from './diagnostics';
import { WikiFormatter } from './formatter';
import { ErrorType, RecoveryRule } from '../types/interfaces';
import { getConfig } from '../config';
import { persistReflectionAsLesson } from '../agents/reflectionPersister';
export { ErrorType, RecoveryRule };
// ─────────────────────────────────────────────
@@ -557,6 +559,30 @@ export class AgentEngine {
logError(`[AgentEngine] Reflector soft-fail — Writer 계속 진행: ${reflErr?.message || reflErr}`);
reflection = '';
}
// [Self-Reflection → Knowledge] Reflector가 의미 있는 critique을 내놓았으면
// brain에 lesson 카드로 영속화한다. 다음 미션의 Planner/Researcher/Writer는
// 기존 lesson retrieval 경로를 통해 이 카드를 자동으로 inject받는다.
// 동일 패턴 재발 시 카드를 새로 만들지 않고 occurrences를 증가시키며 severity를
// low→medium→high로 가중. fire-and-forget으로 미션 흐름을 막지 않는다.
if (reflection && getConfig().autoLessonFromReflection !== false) {
try {
const brainDir = getActiveBrainProfile()?.localBrainPath;
if (brainDir) {
const result = persistReflectionAsLesson({
reflection,
originalPrompt: prompt,
brainDir,
});
if (result) {
logInfo(`[AgentEngine] Reflector critique → lesson (${result.bumped ? 'bumped' : 'new'}, severity=${result.severity}, occ=${result.occurrences}).`);
}
}
} catch (persistErr: any) {
// Lesson 영속화 실패는 미션 결과에 영향 없음 — 로그만 남기고 계속 진행.
logError(`[AgentEngine] lesson 영속화 실패 (무시): ${persistErr?.message || persistErr}`);
}
}
}
// --- Phase 4: Writer ---