LAYER 04 · Understand safety and durability

Persistence, projections, and queries

Writes preserve the full log; reads use folds, checkpoints, watermarks, and indexes instead of replaying everything

22 min3 source anchorsupstream@47f9438
durable log + projection checkpoints + query seam
The question this chapter resolves

Why should a session list not load the complete event log for every row?

Build intuition

A bank preserves the ledger but does not recompute every balance from account opening. It reads a trusted checkpoint and replays only the tail.

MECHANISM

Mechanism

The session-persistence seam owns durable backends such as JSONL or SQLite and explicit flush. checkpoint-policy establishes durability boundaries at requests, turn ends, and detach points.

session-projection registers domain fold units, while projection-cache stores state and watermarks. Cold reads use cached row plus durable tail replay. session-query provides exact reads, filtering, traces, and full-text search.

Step 1 of 6

Append in memory

Session first commits the authoritative event.

INVARIANTS

What extensions must preserve

  • Durable writes preserve event seq and JSON fidelity
  • Caches are reconstructable accelerators, not truth
  • List reads should not require full-log loading
FAILURE MODES

The tempting wrong turns

  • ×Assuming turn/end implies a completed flush
  • ×Treating projection cache as irreplaceable state
  • ×Letting search results bypass workspace authorization
VERIFY IN SOURCE

Do not trust the conclusion—verify it

These anchors are pinned to official deepseek-harness@47f9438; account for later breaking changes when reading current upstream.

KNOWLEDGE CHECK

Pause for ten seconds before revealing

Why must a projection checkpoint include a watermark?

Why the next chapter follows

A durable system still needs explicit failure semantics. Next we unify cancellation, timeouts, structured errors, and quiescence invariants.

Learn DeepSeek Harness

An independent learning project. Explanations derive from source; upstream remains authoritative.