English | 中文
The persisted projection cache (ctx.sessionProjectionCache): durable checkpoints of every projection unit's state, one projection_cache.json per session under the cache's own storage root (<root>/<session-id>/projection_cache.json). The cache owns its directory tree and never consults the persistence layer. Design authority: the session-projection RFC (persisted projection cache section).
A stored row (key → {ver, seq, val}) is a fold shortcut, never an authority: possibly stale (seq says exactly how stale) but never wrong. Consequences the implementation commits to:
ver mismatch against the live unit's stateVersion discards, never migrates. A unit bump invalidates its rows at read time; the key refolds from the log.stateSchema. A malformed file reads as "no cache row", so the cold path refolds from the log.createdAt, cwd) it was folded from; every read validates it (the live header is the witness) before accepting a record, so a deleted-then-recreated id cannot let an old record seed state folded from an unrelated log.0o700/0o600). The cache does not depend on which persistence backend is mounted — no locate, no per-session-dir probing.Two mandatory points, throttled in between:
| Trigger | Nature |
|---|---|
turn/end |
Mandatory — the turn-final value is what listing reads want. |
| Session disposal (detach) | Mandatory — the live-to-cold moment; after it the cache serves this session's final cut. |
writeEveryEvents committed events |
Config throttle (count). |
writeIntervalMs since the first dirty event |
Config throttle (interval). |
root and both throttle triggers are required Config fields (no defaults): the cache root and flush cadence are deployment choices stated in cordis.yml.
cachedSnapshot(meta))One file read per session: client values viewed straight from the identity-matching stored record (version- and state-schema-matching keys only), returned as a {asOfSeq, values} cut — asOfSeq is the lowest served-row watermark, so a client seeding its per-session value store under higher-seq-wins can never let a stale list block overwrite a newer push frame. Host-only rows are never returned. undefined when no usable client row exists (unknown id, unrelated lifecycle, missing or malformed file, or no usable rows); the api-proxy list carrier turns that into an absent column.
write(session) is the synchronous-cut checkpoint both mandatory points use; carriers may call it directly (not fail-soft — the fail-soft wrappers own containment).
- id: session-projection-cache
name: '@deepseek-ai/dsh-session-projection-cache'
config:
root: !!js dshHomePath('projections')
writeEveryEvents: 200
writeIntervalMs: 5000
Injects sessionProjections, sessions. Without this row the projection system runs live-only (watermark cache; cold reads fall back to full log loads wherever a carrier implements them).
None, as the cache only persists host-side read models of already-logged session state and touches no prompt, message, schema, stream, or tool result.
None; the cache never assembles or sends provider requests.