strict 한 순서의 pipeline
- JSONL append (eager write) — durability. commit 지점.
- SQLite update — convenience / queryable state.
- ChromaDB update (async) — semantic search index.
- SSE yield to frontend — presentation. 아빠가 봄.
invariant
아빠는 JSONL 에 이미 있지 않은 걸 절대 안 봐.
step 4 가 step 1 전에 못 일어나. step 1 fail 시 bail — yield X, 깨진 chat X. 에러가 적절한 error state 로 surface, 정직. step 2 또는 3 fail 시 아빠 여전히 yield 봄 (데이터가 이미 JSONL 에 durable 이라), drifted mirror 는 나중에 purge-and-replay 로 재구축.
fsync — eager append + 주기적 fsync
per-token fsync 는 prohibitively 비싸. 모델: 모든 event 마다 eager file.write() + newline, structural event (tool_use, tool_result, done, usage, session, emotion, error) 와 long text run 동안 짧은 ~250ms timer 에 주기적 fsync.
eager append 가 데이터를 즉시 kernel page cache 에 — 프로세스 crash, abort-induced quirk 살아남기 충분. 주기적 fsync 가 의미 있는 checkpoint 에서 disk-level durability. hardware 정전 worst case: 마지막 fsync 이후 ~250ms 의 delta 손실. 수용 가능.