@@ -435,11 +435,10 @@ export abstract class Reactor extends Component {
435435 if ( src instanceof CallerPort && dst instanceof CalleePort ) {
436436 this . reactor . _connectCall ( src , dst ) ;
437437 } else if ( src instanceof IOPort && dst instanceof IOPort ) {
438- try {
439- this . reactor . _connect ( src , dst ) ;
440- } catch ( error ) {
441- console . log ( `[DEBUG] MutationSandbox.connect: Regular connect failed: ${ ( error as Error ) . message } }, trying elevated connect` ) ;
438+ if ( this . reactor . canConnect ( src , dst ) === 2 ) {
442439 this . reactor . _elevatedConnect ( src , dst ) ;
440+ } else {
441+ this . reactor . _connect ( src , dst ) ;
443442 }
444443 } else {
445444 // ERROR
@@ -1096,7 +1095,7 @@ export abstract class Reactor extends Component {
10961095 * @param src The start point of a new connection.
10971096 * @param dst The end point of a new connection.
10981097 */
1099- public canConnect < R , S extends R > ( src : IOPort < S > , dst : IOPort < R > ) : boolean {
1098+ public canConnect < R , S extends R > ( src : IOPort < S > , dst : IOPort < R > ) : boolean | number /* dirty hack here */ {
11001099 // Immediate rule out trivial self loops.
11011100 if ( src === dst ) {
11021101 throw Error ( "Source port and destination port are the same." ) ;
@@ -1110,6 +1109,11 @@ export abstract class Reactor extends Component {
11101109 throw Error ( "Destination port is already occupied." ) ;
11111110 }
11121111
1112+ if ( ! ( src . checkKey ( this . _key ) && dst . checkKey ( this . _key ) ) ) {
1113+ console . log ( "[debug] Scoping issue. Does not possess valid key for src/dst." )
1114+ return 2 ;
1115+ }
1116+
11131117 if ( ! this . _runtime . isRunning ( ) ) {
11141118 // console.log("Connecting before running")
11151119 // Validate connections between callers and callees.
0 commit comments