erlang_adk_session (erlang_adk v0.7.0)

View Source

erlang_adk_session - ETS-backed implementation of adk_session_service.

Summary

Functions

Atomically append Event only while Key still has Expected. This is the compare-and-append primitive used for non-terminal long-running tool progress, so a racing terminal resume either happens wholly before or after the progress event.

Remove invocation-scoped temp: state after an invocation has completed.

Atomically replace an exact chronological event prefix with a durable compaction summary. Events appended concurrently after the prefix survive.

Initialize the session storage.

Atomically read and remove one state value. Missing sessions and missing keys both return {error, not_found}.

Functions

add_event(AppName, UserId, SessionId, Event)

add_event_if_state(AppName, UserId, SessionId, Key, Expected, Event)

Atomically append Event only while Key still has Expected. This is the compare-and-append primitive used for non-terminal long-running tool progress, so a racing terminal resume either happens wholly before or after the progress event.

clear_temp_state(AppName, UserId, SessionId)

Remove invocation-scoped temp: state after an invocation has completed.

compact_events(AppName, UserId, SessionId, ExpectedIds, SummaryEvent)

Atomically replace an exact chronological event prefix with a durable compaction summary. Events appended concurrently after the prefix survive.

create_session(AppName, UserId, Opts)

delete(SessionId)

delete_session(AppName, UserId, SessionId)

get_session(AppName, UserId, SessionId)

init()

Initialize the session storage.

list_sessions(AppName, UserId)

load(SessionId)

save(SessionId, Memory)

take_state(AppName, UserId, SessionId, Key)

Atomically read and remove one state value. Missing sessions and missing keys both return {error, not_found}.

update_state(AppName, UserId, SessionId, StateDelta)