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/tests/canonical_abi_tests.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 / tests / canonical_abi_tests.rs` 128 lines ยท 4541 bytes Raw Blame History 1 use aegis::{ 2 ActionId, AegisEvent, AgentEvent, AgentId, AgentState, ApprovalId, Digest32, EventId, 3 ProtocolVersion, RunId, Session, SessionId, 4 }; 5 6 #[test] 7 fn test_aegis_ids_bidirectional_conversion_with_protocol_types() { 8 let sess_id = SessionId::new(); 9 let canon_sess: aien_protocol_types::SessionId = sess_id.clone().into(); 10 let back_sess: SessionId = canon_sess.into(); 11 assert!(back_sess.as_str().starts_with("sess_")); 12 13 let run_id = RunId::new(); 14 let canon_run: aien_protocol_types::RunId = run_id.clone().into(); 15 let back_run: RunId = canon_run.into(); 16 assert!(back_run.as_str().starts_with("run_")); 17 18 let act_id = ActionId::new(); 19 let canon_act: aien_protocol_types::ActionId = act_id.clone().into(); 20 let back_act: ActionId = canon_act.into(); 21 assert!(back_act.as_str().starts_with("act_")); 22 23 let appr_id = ApprovalId::new(); 24 let canon_appr: aien_protocol_types::ApprovalId = appr_id.clone().into(); 25 let back_appr: ApprovalId = canon_appr.into(); 26 assert!(back_appr.as_str().starts_with("appr_")); 27 28 let evt_id = EventId::new(); 29 let canon_evt: aien_protocol_types::EventId = evt_id.clone().into(); 30 let back_evt: EventId = canon_evt.into(); 31 assert!(back_evt.as_str().starts_with("evt_")); 32 } 33 34 #[test] 35 fn test_aegis_session_to_canonical_agent_state_and_digest() { 36 let mut session = Session::new(Some("Audit and verify canonical ABI migration".to_string())); 37 session.budget.max_total_tokens = 8192; 38 39 let agent_id = AgentId::new_v4(); 40 let state: AgentState = session.to_agent_state(&agent_id, "GB10-local-Qwen"); 41 42 assert_eq!(state.abi_version, ProtocolVersion::new(1, 0)); 43 assert_eq!(state.agent.agent_id, agent_id); 44 assert_eq!(state.agent.model_profile, "GB10-local-Qwen"); 45 assert_eq!(state.session.session_id, session.id.clone().into()); 46 assert_eq!( 47 state.objective.as_ref().unwrap().description, 48 "Audit and verify canonical ABI migration" 49 ); 50 assert_eq!(state.budget.max_tokens, Some(8192)); 51 assert!(state.parent.is_none()); 52 53 let digest1 = state 54 .compute_digest() 55 .expect("must compute deterministic digest"); 56 let digest2 = state 57 .compute_digest() 58 .expect("must compute deterministic digest"); 59 assert_eq!(digest1, digest2); 60 assert_ne!(digest1, Digest32::ZERO); 61 } 62 63 #[test] 64 fn test_canonical_agent_state_branching_lineage() { 65 let parent = Session::new(Some("Parent primary execution context".to_string())); 66 let child = parent.branch(); 67 68 let agent_id = AgentId::new_v4(); 69 let parent_state = parent.to_agent_state(&agent_id, "GB10-local-Qwen"); 70 let child_state = child.to_agent_state(&agent_id, "GB10-local-Qwen"); 71 72 assert!(parent_state.parent.is_none()); 73 assert!(child_state.parent.is_some()); 74 75 let parent_canon_id: aien_protocol_types::SessionId = parent.id.into(); 76 assert_eq!( 77 child_state.parent.as_ref().unwrap().state_id, 78 parent_canon_id.0 79 ); 80 } 81 82 #[test] 83 fn test_aegis_event_to_canonical_agent_event_mapping() { 84 let created = AegisEvent::SessionCreated { 85 session_id: "sess_test1".to_string(), 86 objective: Some("Objective".to_string()), 87 }; 88 assert_eq!( 89 created.to_canonical_agent_event(), 90 Some(AgentEvent::SessionCreated) 91 ); 92 93 let closed = AegisEvent::SessionClosed { 94 session_id: "sess_test1".to_string(), 95 }; 96 assert_eq!( 97 closed.to_canonical_agent_event(), 98 Some(AgentEvent::SessionClosed) 99 ); 100 101 let branched = AegisEvent::SessionBranched { 102 session_id: "sess_child".to_string(), 103 parent_session_id: "sess_parent".to_string(), 104 }; 105 match branched.to_canonical_agent_event() { 106 Some(AgentEvent::ContextBranched(_)) => {} 107 other => panic!("Expected ContextBranched, got {:?}", other), 108 } 109 110 let run_started = AegisEvent::RunStarted { 111 run_id: "run_alpha".to_string(), 112 session_id: "sess_alpha".to_string(), 113 trigger: "UserMessage".to_string(), 114 }; 115 match run_started.to_canonical_agent_event() { 116 Some(AgentEvent::RunStarted(_)) => {} 117 other => panic!("Expected RunStarted, got {:?}", other), 118 } 119 120 let act_req = AegisEvent::ActionRequested { 121 action_id: "act_101".to_string(), 122 capability: "shell.execute".to_string(), 123 }; 124 match act_req.to_canonical_agent_event() { 125 Some(AgentEvent::ActionRequested(_)) => {} 126 other => panic!("Expected ActionRequested, got {:?}", other), 127 } 128 }