22 * SPDX-License-Identifier: MIT
33 * Copyright (c) "2025" . The DeepCausality Authors and Contributors. All Rights Reserved.
44 */
5-
65use crate :: types:: csm_types:: csm:: csm_utils_test;
76use deep_causality:: * ;
87
@@ -22,15 +21,15 @@ fn test_new_csm_with_unverified_ethos_panics() {
2221}
2322
2423#[ test]
25- fn test_eval_single_state_with_ethos_impermissible_verdict ( ) {
24+ fn test_eval_single_state_with_ethos_permitted_verdict ( ) {
2625 let state = CausalState :: new (
2726 1 ,
2827 1 ,
2928 PropagatingEffect :: None ,
3029 csm_utils_test:: get_test_causaloid ( true ) ,
3130 ) ;
3231 let action = csm_utils_test:: get_test_action_with_tracker ( ) ;
33- let ethos = csm_utils_test:: get_effect_ethos ( true , true ) ; // Verified, Impermissible
32+ let ethos = csm_utils_test:: get_effect_ethos ( true , false ) ; // Verified, Impermissible
3433
3534 let csm = CSM :: new ( & [ ( & state, & action) ] , Some ( ( ethos, & [ "test_tag" ] ) ) ) ;
3635 let res = csm. eval_single_state ( 1 , & PropagatingEffect :: Deterministic ( true ) ) ;
@@ -47,16 +46,39 @@ fn test_eval_single_state_with_ethos_permissible_verdict() {
4746 PropagatingEffect :: None ,
4847 csm_utils_test:: get_test_causaloid ( true ) ,
4948 ) ;
49+ let impermissible = false ;
5050 let action = csm_utils_test:: get_test_action_with_tracker ( ) ;
51- let ethos = csm_utils_test:: get_effect_ethos ( true , false ) ; // Verified, Permissible
51+ let ethos = csm_utils_test:: get_effect_ethos ( true , impermissible ) ; // Verified, Permissible
5252
5353 let csm = CSM :: new ( & [ ( & state, & action) ] , Some ( ( ethos, & [ "test_tag" ] ) ) ) ;
5454 // we have to use Deterministic(false) b/c the causaloid inverts it to true, then the CSM evaluation starts.
5555 let res = csm. eval_single_state ( 1 , & PropagatingEffect :: Deterministic ( false ) ) ;
56- // dbg!(&res);
56+ dbg ! ( & res) ;
5757 assert ! ( res. is_ok( ) ) ;
5858}
5959
60+ #[ test]
61+ fn test_eval_single_state_with_ethos_impermissible_verdict ( ) {
62+ let state = CausalState :: new (
63+ 1 ,
64+ 1 ,
65+ PropagatingEffect :: None ,
66+ csm_utils_test:: get_test_causaloid ( true ) ,
67+ ) ;
68+
69+ let impermissible = true ;
70+ let action = csm_utils_test:: get_test_action_with_tracker ( ) ;
71+ let ethos = csm_utils_test:: get_effect_ethos ( true , impermissible) ; // Verified, Permissible
72+
73+ let csm = CSM :: new ( & [ ( & state, & action) ] , Some ( ( ethos, & [ "test_tag" ] ) ) ) ;
74+ // we have to use Deterministic(false) b/c the causaloid inverts it to true, then the CSM evaluation starts.
75+ let res = csm. eval_single_state ( 1 , & PropagatingEffect :: Deterministic ( false ) ) ;
76+ dbg ! ( & res) ;
77+ assert ! ( res. is_err( ) ) ;
78+ let err = res. unwrap_err ( ) . to_string ( ) ;
79+ assert ! ( err. contains( "Impermissible" ) ) ;
80+ }
81+
6082#[ test]
6183fn test_eval_single_state_with_ethos_missing_context_errs ( ) {
6284 let state = CausalState :: new (
@@ -108,15 +130,39 @@ fn test_eval_all_state_with_ethos_permissible_verdict() {
108130 PropagatingEffect :: Deterministic ( false ) ,
109131 csm_utils_test:: get_test_causaloid ( true ) ,
110132 ) ;
133+
134+ let impermissible = false ;
111135 let action = csm_utils_test:: get_test_action_with_tracker ( ) ;
112- let ethos = csm_utils_test:: get_effect_ethos ( true , false ) ; // Verified, Permissible
136+ let ethos = csm_utils_test:: get_effect_ethos ( true , impermissible ) ; // Verified, Permissible
113137
114138 let csm = CSM :: new ( & [ ( & state, & action) ] , Some ( ( ethos, & [ "test_tag" ] ) ) ) ;
115139 let res = csm. eval_all_states ( ) ;
116140 // dbg!(&res);
117141 assert ! ( res. is_ok( ) ) ;
118142}
119143
144+ #[ test]
145+ fn test_eval_all_state_with_ethos_impermissible_verdict ( ) {
146+ let state = CausalState :: new (
147+ 1 ,
148+ 1 ,
149+ // we have to use Deterministic(false) b/c the causaloid inverts it to true, then the CSM evaluation starts.
150+ PropagatingEffect :: Deterministic ( false ) ,
151+ csm_utils_test:: get_test_causaloid ( true ) ,
152+ ) ;
153+
154+ let impermissible = true ;
155+ let action = csm_utils_test:: get_test_action_with_tracker ( ) ;
156+ let ethos = csm_utils_test:: get_effect_ethos ( true , impermissible) ; // Verified, Permissible
157+
158+ let csm = CSM :: new ( & [ ( & state, & action) ] , Some ( ( ethos, & [ "test_tag" ] ) ) ) ;
159+ let res = csm. eval_all_states ( ) ;
160+ // dbg!(&res);
161+ assert ! ( res. is_err( ) ) ;
162+ let e = res. unwrap_err ( ) ;
163+ assert ! ( e. to_string( ) . contains( "Impermissible" ) ) ;
164+ }
165+
120166#[ test]
121167fn test_eval_all_states_non_deterministic_error ( ) {
122168 // State 1: OK
0 commit comments