Skip to content

Document (and optionally ship) an event-sourced SessionStore: which aggregate fields must round-trip for a host whose event log is the system of record #115

Closed

Description

@JAORMX

Sibling of #113. This is the single biggest semantic impedance for a host like Atrium whose durable system of record is an append-only event log, not a session snapshot.

The mismatch

mecatl's SessionStore is snapshot-based:

// engine/port/store.go
type SessionStore interface {
    Save(ctx context.Context, s *session.Session) error
    Load(ctx context.Context, id session.SessionID) (*session.Session, error)
}

Engine.Run calls Save(sess) with the whole aggregate at every turn boundary and terminal, and rehydrates via Load returning the whole aggregate. The separate EventLog port (Append/Read) is, by its own doc, write-only from the loop's view — "the loop is storage-agnostic (it only emits), and the persistence happens at the server relay" — so it is not how the engine reconstructs state.

A host whose source of truth is its event log (Atrium replays its log to rebuild history — its "Live ≡ Replay" invariant) must therefore implement SessionStore.Load by folding its event stream back into a *session.Session. That's well-defined only if the exact set of fields the engine relies on across turns is documented and stable.

What I verified (please confirm + pin as contract)

Everything the loop carries across turns appears to live inside the Session aggregate, mutated only through its methods — nothing hidden in Engine/Run that isn't either persisted or safe-to-lose:

  • Must round-trip: Conversation (full message history), Counters (Turns / ToolCalls / ConsecutiveFailures), Usage (cumulative — the run-token budget survives reopen via this), State, pending *PendingAsk (the awaiting-approval handshake), Mode, Limits, Workspace, Profile, ProviderID, ModelID, CreatedAt.
  • Deliberately run-scoped, safe to lose: Run.seq / Run.serial, the in-memory askRegistry, childAskRouter, and the two PendingAsk fields documented as "purely run-scoped state — never serialized ... an old snapshot deserializing false is harmless."

Ask

  1. Document the reconstruction contract: enumerate, as a stable list, exactly which session.Session fields a SessionStore.Load implementation must populate for a correct resume/continue, and which are run-scoped and may be zero. A consumer building Load from a projection needs this to be a contract, not an archaeology exercise against session.go.
  2. Optionally ship a reference event-sourced SessionStore (or an EventLog→Session fold helper) in the importable tree, so the "event log is the system of record" deployment is first-class rather than per-consumer. This also de-risks the determinism question: confirm a Load-rebuilt session replays to byte-identical engine behaviour (no reliance on un-persisted ordering).

Relates to the cloud-native arc (#60 leasing, the durable event-log work) — those assume snapshot rehydration; this asks for the event-sourced rehydration path to be a documented, supported shape.

Activity

  1. added
    documentation
    enhancement
    atrium-convergence
    on Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    atrium-convergencedocumentationenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions