I've seen quite a few times where a region or duchy swaps allegiance and the various nobles and regions move right back.
Yes, so have I, and this is the intended behavior as far as I can tell. But in this case, it's not my duke that changed my allegiance, it's my ruler. Whatever code supercedes the restriction for the former does not seem functionnal for the latter.
If this could be fixed this turn, it'd be much appreciated.