Repository navigation
Description
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-memoryaskRegistry,childAskRouter, and the twoPendingAskfields documented as "purely run-scoped state — never serialized ... an old snapshot deserializing false is harmless."
Ask
- Document the reconstruction contract: enumerate, as a stable list, exactly which
session.Sessionfields aSessionStore.Loadimplementation must populate for a correct resume/continue, and which are run-scoped and may be zero. A consumer buildingLoadfrom a projection needs this to be a contract, not an archaeology exercise againstsession.go. - Optionally ship a reference event-sourced
SessionStore(or anEventLog→Sessionfold 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 aLoad-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