There is no "the attacker".
Here are some generally correct statements about "the attacker".
- The attacker's action is used to make the attack.
- The attacker's attack bonus is added to the attack roll.
- The attacker's weapon die and ability modifier are used to roll for damage.
- The attacker needs to be within reach of the target.
- The attacker gets hit with damage if the target uses hellish rebuke.
- If the attacker can't see the target, the attack roll has disadvantage.
- If the target can't see the attacker, the attack roll has advantage.
Usually, the "attacker" in all of these is the same creature, but spiritual weapon bends that a little: the caster uses their bonus action and attack bonus, but the spell effect has to be within reach of the target. (Note that this is a melee attack with 5-foot reach, despite the caster potentially being much further away.) The concept of "attacker" is split between two entities depending on why we need to know.
So, the "attacker" in #1 and #2 is the caster. In #4 the attacker is the spell effect. (I'm not going to worry about #3: damage is based on the spell effect, not the weapon, but that's perfectly normal for spells that inflict damage.)
Consider #5. Does hellish rebuke even apply here? It strikes the creature that damaged you, and in this case you weren't damaged by a creature but by a freestanding magical effect. On the other hand that effect was directed at you by a creature. The rules don't strictly define what it means to be "damaged" by another creature, so there is no right answer. Make a ruling.
Consider #6. Well, the spell effect can't see anything; it's just a spell effect. So that leaves the caster as the "attacker" for this purpose. The caster is clearly exerting some control--they must use their bonus action to command the weapon, and they choose the target.
How about #7? This is different: the spell effect can't see but it can be seen, so it could be the "attacker" for this purpose. I argue that it is, because what the unseen-attacker rule is trying to represent is the difficulty in defending against an attack you can't see, and the attack in this case takes the form of a big glowy weapon swinging at your head. Being able to see the caster is not necessary; the attack is happening at your location, not theirs. But again, the rules don't answer this. Make a ruling.
The point is that the answer to "What is the attacker?" depends on why you are asking.