Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aegis-runtime-mv/blob/main/src/defense/approval.rs # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aegis-runtime-mv / src / defense / approval.rs` 67 lines ยท 1731 bytes Raw Blame History 1 use crate::sessions::id::{ActionId, ApprovalId, RunId, SessionId}; 2 use serde::{Deserialize, Serialize}; 3 4 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] 5 #[serde(rename_all = "snake_case")] 6 pub enum ApprovalStatus { 7 Pending, 8 Approved, 9 Rejected, 10 Expired, 11 } 12 13 impl ApprovalStatus { 14 pub fn as_str(&self) -> &'static str { 15 match self { 16 Self::Pending => "pending", 17 Self::Approved => "approved", 18 Self::Rejected => "rejected", 19 Self::Expired => "expired", 20 } 21 } 22 23 #[allow(clippy::should_implement_trait)] 24 pub fn from_str(s: &str) -> Option { 25 match s { 26 "pending" => Some(Self::Pending), 27 "approved" => Some(Self::Approved), 28 "rejected" => Some(Self::Rejected), 29 "expired" => Some(Self::Expired), 30 _ => None, 31 } 32 } 33 } 34 35 #[derive(Debug, Clone, Serialize, Deserialize)] 36 pub struct Approval { 37 pub id: ApprovalId, 38 pub action_id: ActionId, 39 pub run_id: RunId, 40 pub session_id: SessionId, 41 pub prompt: String, 42 pub status: ApprovalStatus, 43 pub requested_at: i64, 44 pub decided_at: Option, 45 pub decided_by: Option, 46 } 47 48 impl Approval { 49 pub fn new( 50 action_id: ActionId, 51 run_id: RunId, 52 session_id: SessionId, 53 prompt: impl Into, 54 ) -> Self { 55 Self { 56 id: ApprovalId::new(), 57 action_id, 58 run_id, 59 session_id, 60 prompt: prompt.into(), 61 status: ApprovalStatus::Pending, 62 requested_at: chrono::Utc::now().timestamp(), 63 decided_at: None, 64 decided_by: None, 65 } 66 } 67 }