feat: Bridge 타깃 토글 + /research 제거 + 환각·오염 방지 강화 (v2.2.205)
- Datacollect Bridge 로컬/NAS 타깃 토글(Settings 패널) + NAS URL/x-bridge-token. 기본 local = 현행 동작 유지. (백엔드 NAS 분리 준비) - /research(NotebookLM) 제거 — 로컬 Datacollect 앱 전용으로 분리. - 에러로그 오염 차단: STT/스택트레이스/에러덤프를 장기기억 채굴 제외 + 자동 추출 항목 14일 TTL(참조 시 슬라이딩 연장). 기존·수동 항목 무영향. - 컨텍스트 [주제] 태깅 + 교차오염 방지 경계 지침. - "확인 불가" 사실 날조 금지 규칙(R7과 구분). - /meet STT 오타 보정: 철자 정규화 허용하되 사실 날조는 차단. 타입체크 + 407 테스트 통과. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -169,6 +169,12 @@ export class LongTermMemory {
|
||||
.slice(0, 5);
|
||||
if (alwaysInclude.length === 0) return null;
|
||||
|
||||
// 표시되는(=사용되는) 자동 추출 항목의 만료를 연장.
|
||||
const refreshAt = Date.now() + LongTermMemory.AUTO_EXTRACT_TTL_MS;
|
||||
for (const e of alwaysInclude) {
|
||||
if (e.expiresAt) { e.expiresAt = refreshAt; this.dirty = true; }
|
||||
}
|
||||
|
||||
const content = alwaysInclude
|
||||
.map((e) => `- [${e.category}] ${e.content}`)
|
||||
.join('\n');
|
||||
@@ -181,10 +187,13 @@ export class LongTermMemory {
|
||||
};
|
||||
}
|
||||
|
||||
// Mark as referenced
|
||||
// Mark as referenced — 자동 추출(만료 있음) 항목은 참조 시 만료를 슬라이딩 연장해
|
||||
// '쓰면 살아남고, 안 쓰면 TTL 뒤 소멸'. 영속(수동) 항목은 expiresAt 이 없어 무영향.
|
||||
const refreshAt = Date.now() + LongTermMemory.AUTO_EXTRACT_TTL_MS;
|
||||
for (const { entry } of relevant) {
|
||||
entry.lastReferencedAt = Date.now();
|
||||
entry.referenceCount++;
|
||||
if (entry.expiresAt) entry.expiresAt = refreshAt;
|
||||
}
|
||||
this.dirty = true;
|
||||
|
||||
@@ -202,6 +211,34 @@ export class LongTermMemory {
|
||||
|
||||
// ─── Extraction Helpers ───
|
||||
|
||||
/** 자동 추출 장기기억 기본 TTL (14일). 참조될 때마다 슬라이딩 연장된다. */
|
||||
public static readonly AUTO_EXTRACT_TTL_MS = 14 * 24 * 60 * 60 * 1000;
|
||||
|
||||
/** 짧은 후보 문자열에 박힌 구체적 에러 시그니처(예외명/에러코드/스택 조각) 탐지. */
|
||||
private static readonly ERROR_NOISE = /\b(?:TypeError|ReferenceError|SyntaxError|RangeError|KeyError|ValueError|Exception|Traceback|ECONNREFUSED|ETIMEDOUT|ENOENT|EACCES|ECONNRESET|errno|npm ERR!)\b|error\s+TS\d|:\d+:\d+\)|File ".+", line \d/i;
|
||||
|
||||
/**
|
||||
* 붙여넣은 에러 로그·스택 트레이스·실패 출력처럼 보이는 텍스트인지 *보수적으로* 추정.
|
||||
* 이런 입력은 '분석 대상'(휘발)이지 '지식'(영속)이 아니므로 장기 기억 채굴에서 제외한다.
|
||||
* 일반 산문이 'error' 를 한 번 언급한 정도로는 걸리지 않게 강한/약한 신호를 구분한다.
|
||||
*/
|
||||
public static looksLikeErrorLog(text: string): boolean {
|
||||
if (!text) return false;
|
||||
const strong = [
|
||||
/Traceback \(most recent call last\)/,
|
||||
/^\s*at\s+.+\(.+:\d+:\d+\)/m, // JS 스택 프레임
|
||||
/\bFile ".+", line \d+/, // Python 프레임
|
||||
/npm ERR!/,
|
||||
/\b(?:TypeError|ReferenceError|SyntaxError|RangeError|KeyError|ValueError)\b/,
|
||||
/\b(?:ECONNREFUSED|ETIMEDOUT|ENOENT|EACCES|ECONNRESET)\b/,
|
||||
/error\s+TS\d{3,}/i, // tsc 에러
|
||||
];
|
||||
if (strong.some((re) => re.test(text))) return true;
|
||||
const weak = (text.match(/\b(?:error|errors|exception|failed|failure|stacktrace|errno|fatal|panic|assertion)\b/gi) || []).length
|
||||
+ (text.match(/\[(?:error|warn|fatal)\]/gi) || []).length;
|
||||
return weak >= 3 && text.split('\n').length >= 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 대화 메시지에서 장기 기억 후보를 패턴 매칭으로 추출합니다.
|
||||
* LLM 호출 없이 동작합니다.
|
||||
@@ -235,6 +272,8 @@ export class LongTermMemory {
|
||||
for (const msg of messages) {
|
||||
if (msg.role !== 'user') continue;
|
||||
const text = msg.content;
|
||||
// 에러 로그/스택 트레이스 덤프는 '분석 대상'(휘발)이므로 통째로 채굴 제외.
|
||||
if (LongTermMemory.looksLikeErrorLog(text)) continue;
|
||||
|
||||
for (const pattern of rulePatterns) {
|
||||
pattern.lastIndex = 0;
|
||||
@@ -269,9 +308,11 @@ export class LongTermMemory {
|
||||
}
|
||||
}
|
||||
|
||||
// Deduplicate by content
|
||||
// Deduplicate by content + 에러 시그니처가 박힌 후보 제거
|
||||
// ('goal: fix ECONNREFUSED ...' 같은 에러 내용이 지식으로 흡수되는 오염 방지).
|
||||
const seen = new Set<string>();
|
||||
return candidates.filter((c) => {
|
||||
if (LongTermMemory.ERROR_NOISE.test(c.content)) return false;
|
||||
const key = c.content.toLowerCase();
|
||||
if (seen.has(key)) return false;
|
||||
seen.add(key);
|
||||
|
||||
Reference in New Issue
Block a user