Skip to content

feat(chronicle): recap result caching #176

@fagemx

Description

@fagemx

Context

#173 拆出。第一版 recap 每次都呼叫 LLM。快取是 Phase 1 mobile (#174) 的前置需求 — mobile app 讀快取,不需要每次觸發 LLM。

Parent epic: #172
Related: #173 (recap pipeline), #174 (mobile delivery)


目標

Recap 結果快取,避免同一 anchor 重複呼叫 LLM。

快取結構

~/.edda/chronicle/cache/
├── <hash>.json          # hash = anchor params 的 deterministic hash
└── index.json           # { hash → { created, anchor_desc, ttl } }

行為

  • 同一 anchor + 同一時間範圍 → 直接回傳快取(不重新呼叫 LLM)
  • TTL: 預設 4h
  • Invalidation: 有新 session 進來(新的 digest timestamp > cache created)→ invalidate
  • --fresh flag → 忽略快取,強制重新生成
  • Phase 1 (feat(chronicle): Phase 1 — LLM cognitive recap + mobile briefing #174) 的 /api/recap/cached endpoint 直接讀這個快取

架構

edda-chronicle/src/
  cache.rs
    ├── get_cached(anchor_hash) → Option<RecapResult>
    ├── store_result(anchor_hash, result, ttl)
    ├── invalidate_stale()       # 比對 latest session timestamp
    └── cache_key(anchor) → hash # deterministic hash of anchor params

驗收標準

  • 同一 anchor 第二次呼叫直接回傳快取
  • TTL 過期後自動重新生成
  • 新 session 進來自動 invalidate 相關快取
  • --fresh 忽略快取
  • 快取檔案大小合理(< 10KB per recap)
  • Phase 1 的 REST API 可直接讀取快取

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions