Skip to content

Append-only Event Log + /v1/events #41

Description

@valiantone

Summary

Introduce an append-only event log — an immutable stream of memory lifecycle events enabling replay, recovery, synchronization, and deterministic reconstruction.

Scope

  • Event vocabulary: MemoryAdded, MemoryUpdated, MemoryMerged, MemoryArchived, SnapshotCreated, PromotionRequested.
  • Each event: id, type, timestamp, target memory id(s), before/after payloads as needed, sequence number.
  • Storage: append-only (SQLite table or JSONL log file under the mount) with monotonically increasing sequence; no in-place updates/deletes.
  • Replay API: reconstruct memory state from the event stream (deterministic; used for recovery/sync, not the hot read path).
  • GET /v1/events with cursor + limit (tail-style), for consumers/sync.
  • Emit events from existing write paths (add/update) without changing their external behavior.

Out of scope: distributed sync protocol, cross-instance replication (EMOS-side).

Acceptance Criteria

  • Every add/update/merge/archive/snapshot/promotion-request emits exactly one event
  • Events are append-only; sequence numbers are monotonic and gap-free per emitter
  • Replay from an empty state reconstructs current memory state deterministically
  • GET /v1/events supports cursor + limit pagination
  • Event emission does not alter existing /v1/add//v1/search behavior or latency materially
  • Event log survives restart (durable under the mount)

Migration

Additive. Event log starts empty; existing memories are unaffected (a baseline snapshot can seed the log on first vNext boot, documented in the RFC).

Testing

  • Unit: each lifecycle path emits the correct event type + payload.
  • Unit: replay reconstruction matches direct DB state for a fixture workload.
  • Unit: append-only guarantee (no update/delete of log rows); monotonic sequence.
  • Unit: /v1/events pagination returns contiguous, ordered results.

Depends on

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:eventsAppend-only event log and /v1/eventsv0.2.0HotMem v0.2.0: file-native memory sidecar

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions