A judge cleared the path for mass layoffs of federal workers by ruling against a National Treasury Employees Union lawsuit.