I just had an issue like this on my 04 sti. It turned out to be the connector to the MAF had broken. I went to my local junkyard and pulled the connector and MAF off of an old Impreza and cut the wires to the old one, spliced the ‘new’ connector wires to the old wires. Reset my ECU learning and was all good. Maybe it can be that easy for you?