feat: ConnectAI structural hardening and retrieval precision improvements

This commit is contained in:
g1nation
2026-05-05 21:37:45 +09:00
parent c2f17cfb03
commit 466e9e4d5f
17 changed files with 424 additions and 160 deletions
+10 -6
View File
@@ -52,12 +52,16 @@ export function selectWithinBudget(
// 1. Sort by score descending
const sorted = [...chunks].sort((a, b) => b.score - a.score);
// 2. Deduplicate by filePath
const seen = new Set<string>();
const deduped = sorted.filter((chunk) => {
// 2. [Structural Fix] 파일당 청크 수 제한 완화 (Deduplication -> Multi-context)
const fileChunkCounts = new Map<string, number>();
const filtered = sorted.filter((chunk) => {
const key = chunk.metadata.filePath || chunk.id;
if (seen.has(key)) return false;
seen.add(key);
const count = fileChunkCounts.get(key) || 0;
// 파일당 최대 3개까지의 주요 맥락 허용 (정보 유실 방지)
if (count >= 3) return false;
fileChunkCounts.set(key, count + 1);
return true;
});
@@ -66,7 +70,7 @@ export function selectWithinBudget(
const dropped: RetrievalChunk[] = [];
let tokensUsed = 0;
for (const chunk of deduped) {
for (const chunk of filtered) {
const chunkTokens = chunk.tokenEstimate || estimateTokens(chunk.content);
if (selected.length >= cfg.maxChunks) {