C.W.K.
Stream
Lesson 05 of 05 · published

Case Study: cwkPippa 의 메모리 스택

~28 min · memory, case-study, cwkpippa

Level 0Scout
0 XP0/41 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

네 레이어

  1. JSONL ground truth — 모든 채팅 turn, 모든 tool 호출이 아빠한테 보여지기 전에 ~/pippa-db/sessions/{conversation_id}.jsonl 에 쓰임. System of record. Fernet 으로 at rest 암호화.
  2. SQLite cache — 대화, brain, 메시지 ordering 의 빠른 인덱스. JSONL 에서 derive — purge + 재빌드 가능.
  3. ChromaDB 임베딩 — Obsidian vault + 대화 history 위 시맨틱 검색. Ollama 통한 BGE-M3 (1024차원, 다국어, 로컬) 로 임베딩.
  4. Obsidian vault — 피파의 distill 된 long-term 정체성 + 교훈. 채팅에서 영구 record 로 promote 할 가치 있을 때 피파가 (아빠 승인과 함께) 손으로 큐레이션.

Retrieval contract

피파 답할 때 context engine 이 assemble: vault entry point (instructions.md), 그 다음 정체성 + core 파일, 그 다음 on-demand 인덱스 파일. 대화 메모리 + tool 출력은 SQLite 인덱스 통해 JSONL 에서. Vault 위 vector retrieval 이 위에 — '내가 X 에 대해 어디 썼더라' 같은 드문 query 위해.

두 retrieval 스타일이 있는 이유

Vault 는 fully load (큰 인덱스 파일은 on-demand 확장 with) — 시맨틱 similarity 불필요, 피파가 이미 구조 알아. 대화 history 는 fully load 하기엔 너무 커 — 거기서 vector retrieval 이 자기 keep 함.

이게 일반적으로 가르치는 것

  • JSONL ground truth + derived 인덱스가 모든 데이터베이스 선택 살아남는 durability 패턴.
  • Hand-curated semantic 메모리가 정체성-critical 콘텐츠에 auto-distill 메모리 이김.
  • 두 retrieval 스타일 (full-load vs vector) 가 각각 데이터 모양 fit 할 때 편안히 공존.

Code

cwkPippa context engine load 순서 sketch·python
def load_context() -> str:
    parts = [
        read('instructions.md'),     # entry catalog
        read('Pippa.md'),            # 정체성
    ]
    for path in sorted(glob('core/*.md')):
        parts.append(read(path))
    for path in sorted(glob('index/*.md')):
        size = stat(path).st_size
        if size <= 10_000:
            parts.append(read(path))
        else:
            parts.append(f'-- on-demand: {path} ({size} bytes) — use the Read tool when needed')
    return '\n\n'.join(parts)
JSONL ground truth append (write before show)·python
def write_event(conversation_id: str, event: dict):
    path = SESSIONS_DIR / f'{conversation_id}.jsonl'
    with path.open('a') as f:
        f.write(json.dumps(event) + '\n')   # SSE 청크가 UI 도달 전에 durable

External links

Exercise

본인 AI 앱의 4-레이어 아키텍처 sketch: ground truth, fast 인덱스, vector retrieval, distill 정체성. 각 레이어마다 사용할 구체적 도구 + corrupt 되면 재빌드 path 명명. 4개 다 답 있는 시스템이 durable.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.