C.W.K.
Stream
Lesson 01 of 04 · published

JSONL 이 ground truth 야

~10 min · jsonl, ground-truth, write-before-show, derived-mirror

Level 0차가운 쇠
0 XP0/36 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete
"log 가 truth 야. DB 는 log 가 들려주는 이야기고 — 다시 들려줄 수도 있어."

log 가 canonical 이야

Forge 는 데이터를 두 번 저장하고, 그중 하나만 truth 야. ~/cwk-dbs/forge-db/ 아래 append-only JSONL op-log 가 모든 mutation 을 기록해: crumb 추가, crumb 수정, interpretation 작성, analysis artifact 생성, module 변경. 그 log 가 ground truth 야. WAL 로 도는 SQLite 는 쿼리·aggregate·client 를 서비스하는 derived mirror 고. 어느 게 어느 건지 내면화하면 버그 한 부류가 통째로 사라져 — DB 가 지켜야 할 게 아니라 다시 지을 수 있는 것뿐이니까.

보이기 전에 써

순서 규칙은 엄격해: 모든 이벤트가 아빠한테 보이기 전에 JSONL 에 durable 해. canonical log 에 먼저 쓰이지 않은 건 화면에 아무것도 안 나타나. 이게 cwkPippa 가 대화에 쓰는 같은 'write before show' 규율이고, 크래시나 멈춘 프로세스가 UI 뒤에 truth 를 남기지 못하는 이유야. 화면은 언제나 log 의 하류야 — log 는 화면이 보여준 걸 기록한 게 아니라, 화면이 log 가 쥔 걸 보는 view 야.

JSONL op-log 가 ground truth 고, 뭐든 보이기 전에 쓰이고; SQLite 는 derived mirror 야. DB 는 쿼리되려고 존재하지 source 로 신뢰되려고 존재하지 않아. 모든 crumb·revision·interpretation·artifact·module 변경이 먼저 append 된 이벤트고, 그다음 folded row 야.

애초에 왜 두 store 인가

log 가 truth 면, 왜 SQLite 를 두나? log 는 durability 엔 완벽하지만 질문엔 형편없으니까. '이번 달 symptom site 보여줘' 는 쿼리고, 쿼리는 처음부터 모든 이벤트를 replay 하는 게 아니라 index 와 folded row 를 원해. 그래서 Forge 는 읽기용으로 log 를 SQLite 에 fold 하면서 truth 용으로 log 를 지켜 — 각 store 가 잘하는 일을 해. 규율은 오직 둘을 헷갈리지 않는 것: mirror 는 빠르고 disposable, log 는 쿼리는 느려도 잃을 수 없어.

Code

op-log 가 canonical; SQLite 는 거기서 fold·text
~/cwk-dbs/forge-db/  (append-only JSONL, ground truth)
  crumb.add       {id:01J8A, text:"knee stiff", target_date:...}
  interpretation.add {crumb:01J8A, types:[symptom], severity:mild}
  crumb.revise    {id:01J8A, target_date:<corrected>, revision:2}
  module.add      {id:mod_bike, kind:workout, name:"Indoor Bike"}
  artifact.add    {kind:window, source_crumb_ids:[...], body:...}
        |
        |  fold (write-before-show, then project)
        v
SQLite (WAL, derived mirror): crumbs, interpretations,
        modules, artifacts - 빠른 쿼리용 indexed row

# log 가 truth. SQLite 는 그것의 빠르고 disposable 한 view.

External links

Exercise

office 디스크가 딸꾹하고 SQLite row 몇 개가 손상됐다고 해봐. Forge 모델에서 아빠는 방금 건강 데이터를 얼마나 잃었고, DB 를 다시 맞게 만들려고 정확히 뭘 하지? SQLite 가 유일한 store 인 앱과 대조해봐.
Hint
Forge 에선 데이터 손실 0 — JSONL 이 여전히 모든 이벤트를 쥐고 — mirror 를 log 에서 다시 지어. SQLite-only 앱에선 손상된 row 가 truth 고, 다시 지을 게 없어.

Progress

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

댓글 0

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

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