Session journal, context, and compaction contracts
Source:R/api-compaction.R
rho_compaction_contracts.RdA SessionJournal is the consumer-defined structural interface for committed
session compare-and-append and snapshots. rho_memory_session_journal() is
the process-local implementation. rho_agent() receives a journal
explicitly; rho_sync_session() asynchronously projects an existing
snapshot into an idle agent. Assistant streaming state remains in
RhoAssistantTurn and only its terminal message is committed.
Details
The journal is append-only. Compare-and-append rejects a stale committed
position before mutation. Message entries retain the complete interaction,
reset entries begin a new active context without erasing history, and
rho_build_agent_context() projects through the latest compaction entry and
any explicit exclusions.
rho_compact() prepares a stable cut point, runs an asynchronous compactor,
appends a semantic checkpoint, and invokes before/after policy methods.
Automatic threshold compaction and one bounded provider-input recovery use the
same protocol. Applications can supply another RhoCompactor class or
specialize the public generics without replacing the agent loop.