adapter.go — SendResult struct (success, message_id, error, retryable, retry_after, continuation_message_ids, error_kind), ChatInfo struct (name, type, chat_id, thread_id), BasePlatformAdapter interface (Connect, Disconnect, Send, ChatInfo). session.go — SessionSource (platform, chat_id/name/type, user_id/name, thread_id, guild_id, scope_id, profile, is_bot, metadata) with Key() for deterministic session key. SessionContext wrapping source with connected_platforms, home_channels, session_key/id, timestamps. session_store.go — SessionStore interface (GetOrCreate, Get, Reset, List, GetByChannel, Touch, Delete, Close) + nellSessionStore backed by nell.DocDB with mutex-guarded Save/Delete for race safety. Verification: 4 findings fixed (gofmt alignment, race on mutex, != true anti-pattern, missing zero-value assertions). 58 tests pass (incl -race), go vet + gofmt + golangci-lint clean. Closes: archie-core-abg.16.3, 16.5, 16.9, 16.10, 16.11
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package gateway
|
|
|
|
import "time"
|
|
|
|
// SessionSource identifies the platform, bot identity, and conversation a
|
|
// gateway session belongs to. It is the composite natural key for session
|
|
// lookup.
|
|
type SessionSource struct {
|
|
// Platform is the adapter name ("telegram", "discord", "web").
|
|
Platform string `json:"platform"`
|
|
|
|
// BotUser is the bot identity serving this session (e.g. "archie",
|
|
// "winter"). Distinct bot identities on the same platform and channel
|
|
// produce distinct sessions.
|
|
BotUser string `json:"bot_user"`
|
|
|
|
// ChannelID is the platform conversation identifier (chat ID, channel
|
|
// name, DM thread).
|
|
ChannelID string `json:"channel_id"`
|
|
}
|
|
|
|
// SessionContext holds the full metadata for an active gateway session.
|
|
// SessionStore is the persistence layer; callers treat SessionContext as
|
|
// a value object.
|
|
type SessionContext struct {
|
|
// SessionID is the unique session identifier (UUID).
|
|
SessionID string `json:"session_id"`
|
|
|
|
// Source identifies the platform, bot, and conversation.
|
|
Source SessionSource `json:"source"`
|
|
|
|
// CreatedAt is when the session was first established.
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
// LastActiveAt is the timestamp of the most recent message or event
|
|
// on this session. Updated by Touch.
|
|
LastActiveAt time.Time `json:"last_active_at"`
|
|
}
|