IACV is located _under_ the upper intake, so way out of position for those connectors. Haven't been clear headed enough to research the possibilities.
Tried to find the wires in my own engine compartment and failed mine are all sheathed wires rather then split loom like that to the ends.
Connectors clip into the brackets on the valve cover.
Appears to be quite a bit of aftermarket wiring in your engine compartment namely that red wire that is in all the pictures. Especially, that last photo which makes the red wire appear as though it was spliced or something or is that the aftermarket O2 sensor.
IMO the codes you have are all related except the IACV.
Knock sensor code= because the engine was actually knocking do to a misfire.
Misfire code= likely the engine misfired
IACV= I'm not real sure on that one its just a valve that meters the throttle body air bypass to adjust idle if its cold it will bump the idle up to warm up faster. Odd that it would be tied to the rest of the codes.
Have you done a tune up on the ignition yet? plugs, wires, cap and rotor would be a good place to start. The early X's are known for distributor failure.
Has the engine been idling or running rough?
IACV is a pain in the but.. I replaced mine..
You will need a new intake gasket, and since you are that deep you should replace your Valve cover gaskets too.
I will still randomly get a p505 when I use my front defroster..
It can cause problems. That particular one went to the exhaust to help provide ground for the O2 sensors. If you have some spare 18 awg wire, just run a new one.