Skip to content

feat(memory): 임계 망각 logic — cost 무한 도달 시 strength-weighted forget #29

Description

@luke-n-alpha

Why

사용자 directive (2026-05-08):

"cost 무한은 여기 걸리면 그때 최적화와 우선순위 삭제 (망각) 동작"
"보수적 삭제" + "보존 우선"

기본 = 모든 fact 영구 보존. 임계 도달 시 만 망각 발동. 사람 뇌의
"오래된 + 안 쓰는 것 자연 잊음" 모델 정합 (synaptic pruning + Ebbinghaus).

Design — 임계 정의

3 단계 임계 (cascading):

단계 임계 동작
1차 (soft) hot store fact 갯수 > N (default 10,000) cold-spill — archived fact 를 별 file 로 분리. 데이터 보존, 메모리만 분리
2차 (medium) total fact (hot + cold) > M (default 100,000) 또는 disk size > X GB strength-weighted forget — 가장 약한 strength × 안 recall × archived 만 splice
3차 (explicit) 사용자 explicit GC trigger 사용자 의도 명시 후 만 hard delete

자동 발동은 1차 + 2차만. 3차는 사용자 의도.

Forget candidate 선정 (2차)

선정 score = strength × recallRecency × (active ? 2 : 1) — 낮을수록 forget candidate.

  • strength < 0.05 (Ebbinghaus 매우 약함)
  • recallRecency = 마지막 recall 후 일수 (오래된 음수)
  • archived status — active fact 는 우선순위 ↓
  • supersededBy chain 의 oldest predecessor 우선 (chain head 보존)

API

```ts
interface MemorySystemOptions {
forgetThresholdCount?: number; // default 10000 (1차 임계)
forgetThresholdTotal?: number; // default 100000 (2차 임계)
forgetThresholdDiskGB?: number; // default 2 (2차 임계)
forgetEnabled?: boolean; // default true (false = 영구 보존, cost ↑)
}

await memory.forgetSweep({ dryRun: true }); // 사용자 explicit
```

변경 양 (~200 LOC)

단계 LOC
Threshold detector (cycle 마다 check) ~30
Cold spill mechanism (별 file 분리) ~80
Strength-weighted candidate scorer ~50
forgetSweep API + dryRun ~40

벤치마크

  • 시뮬레이션 — 100K fact insert 후 forget 발동, recall 정확도 변화 측정
  • 1차 (cold-spill) 후 hot store 의 recall latency 단축 확인
  • 2차 (forget) 후 user-perceived 회상 정확도 체크 (forget 된 fact 중 important 가 잘못 망각 됐는지)

테스트

  • Unit: threshold detector, cold spill round-trip, candidate scorer
  • Integration: 1만 fact 시 1차 발동, 10만 시 2차 발동
  • Regression: forget OFF 시 기존 동작 변경 X

우선순위

P3-low. 임계 도달 자체가 수개월 daily 사용 후. 지금은 design 만 명시.

관련

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2개선·측정·후순위

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions