aegis-runtime-mv
Native Rust agent runtime: Axum WebSocket/SSE/REST gateway, heartbeat scheduler, dependency-aware task workflow, SQLite storage. Attachment of AienOS. Pre-alpha.
Brought by drakestapleton
aegis-runtime-mv / src / sessions / store.rs
| 1 | use super::id::{ActionId, ApprovalId, MessageId, RunId, SessionId}; |
| 2 | use super::message::Message; |
| 3 | use super::session::Session; |
| 4 | use crate::defense::Approval; |
| 5 | use crate::execution::Action; |
| 6 | use crate::orchestration::Run; |
| 7 | use crate::persistence::PersistenceError; |
| 8 | use async_trait::async_trait; |
| 9 | |
| 10 | #[async_trait] |
| 11 | pub trait SessionStore: Send + Sync { |
| 12 | async fn create(&self, session: &Session) -> Result<(), PersistenceError>; |
| 13 | async fn get(&self, id: &SessionId) -> Result<Option<Session>, PersistenceError>; |
| 14 | async fn update(&self, session: &Session) -> Result<(), PersistenceError>; |
| 15 | async fn list(&self, limit: usize, offset: usize) -> Result<Vec<Session>, PersistenceError>; |
| 16 | } |
| 17 | |
| 18 | #[async_trait] |
| 19 | pub trait MessageStore: Send + Sync { |
| 20 | async fn append( |
| 21 | &self, |
| 22 | session_id: &SessionId, |
| 23 | message: &Message, |
| 24 | ) -> Result<(), PersistenceError>; |
| 25 | async fn list(&self, session_id: &SessionId) -> Result<Vec<Message>, PersistenceError>; |
| 26 | async fn get(&self, message_id: &MessageId) -> Result<Option<Message>, PersistenceError>; |
| 27 | } |
| 28 | |
| 29 | #[async_trait] |
| 30 | pub trait RunStore: Send + Sync { |
| 31 | async fn create(&self, run: &Run) -> Result<(), PersistenceError>; |
| 32 | async fn get(&self, id: &RunId) -> Result<Option<Run>, PersistenceError>; |
| 33 | async fn update(&self, run: &Run) -> Result<(), PersistenceError>; |
| 34 | async fn list_by_session(&self, session_id: &SessionId) -> Result<Vec<Run>, PersistenceError>; |
| 35 | async fn get_active_run(&self, session_id: &SessionId) |
| 36 | -> Result<Option<Run>, PersistenceError>; |
| 37 | } |
| 38 | |
| 39 | #[async_trait] |
| 40 | pub trait ActionStore: Send + Sync { |
| 41 | async fn create(&self, action: &Action) -> Result<(), PersistenceError>; |
| 42 | async fn get(&self, id: &ActionId) -> Result<Option<Action>, PersistenceError>; |
| 43 | async fn update(&self, action: &Action) -> Result<(), PersistenceError>; |
| 44 | async fn list_by_run(&self, run_id: &RunId) -> Result<Vec<Action>, PersistenceError>; |
| 45 | } |
| 46 | |
| 47 | #[async_trait] |
| 48 | pub trait ApprovalStore: Send + Sync { |
| 49 | async fn create(&self, approval: &Approval) -> Result<(), PersistenceError>; |
| 50 | async fn get(&self, id: &ApprovalId) -> Result<Option<Approval>, PersistenceError>; |
| 51 | async fn update(&self, approval: &Approval) -> Result<(), PersistenceError>; |
| 52 | async fn list_pending(&self) -> Result<Vec<Approval>, PersistenceError>; |
| 53 | } |