feat(session-persistence): readFrom(seq) primitive for watermark tail reads

SessionPersistence grows readFrom(id, fromSeq, signal?): the non-mutating
read-from-seq primitive for checkpoint consumers (the persisted projection
cache folds only the tail past its watermark). Coordinator owns validation,
per-id serialization, and the sequential fallback (loadStored + forward
skip); SQLite implements the optional seek-capable loadStoredFrom hook
(WHERE seq >= ?), JSONL stays sequential by contract. Contract suite covers
suffix exactness, empty-tail, non-mutation, and cancellation; seam README
(both languages) documents the method and the hook.
This commit is contained in:
imccyu
2026-07-28 00:41:58 +08:00
parent 29f76080a2
commit a79de44c3b
14 changed files with 196 additions and 8 deletions

View File

@@ -149,6 +149,11 @@ class TestPersistence extends SessionPersistence {
return structuredClone(entry)
}
async readFrom(id: SessionIdType, fromSeq: number, signal?: AbortSignal): Promise<{ meta: SessionHeader; events: SessionEvent[] }> {
const whole = await this.inspect(id, signal)
return { meta: whole.meta, events: whole.events.filter(event => event.seq >= fromSeq) }
}
async list(): Promise<SessionHeader[]> {
TestPersistence.listStarted?.()
await TestPersistence.listGate