More importantly it’s not a law at all. It’s as you say a doctrine established by the courts. If congress wanted to improve civil protections from the police, they would clarify the law and end qualified immunity as a doctrine. It’s absurd this stems from the courts.