Shouldn’t David have seen this coming? Did David see this coming?
When Joab slew Abner there were little to no repurcussions. The two obvious reasons why this may be: 1) David was indifferent or pleased, but in order to consolidate his interest, he needs to distance himself from the act as much as possible: i.e., he had no real beef with Joab; or 2) Joab was legitimately too powerful, and had enough interest in the people that it would be legitimately dangerous to David’s reign if he executed justice on him.
The second seems more plausible. If David’s mindset here was mercenary and pragmatic, he would realize that in order to properly distance himself from the act, he would have to punish the offender. Upon that occasion he reflects that “the sons of Zeruiah are too heavy for me.” Too big to do justice upon.
A refrain of David’s during Absalom’s rebellion: “what have I to do with you, sons of Zeruiah?” This almost sounds like he just wants them to leave him alone; “this is a business relationship and I’ll tell you if I need anything from you.” So relations certainly seem a bit strained.
Joab proceeds to provoke David by killing Absalom and then absolutely lights into him when he’s behaving untowardly in his grief. He speaks with contempt and even leaves with a warning shot. (It should be noted that Joab often responds more pragmatically than David to matters. E.g. he initially opposed the census.) Therefore it seems reasonable that David in a passion, changes his policy and cashiers Joab—something he should have done long ago—or demotes him in favor of Amasa. But he failed to exercise prudence in considering how this would play out.
Amasa was a traitor with less experience and less success than Joab (as the issue of the late battle abundantly proved). Maybe David meant well, but the consequences of this policy may have been predicted. Joab was a man who assiduously protected his high station and was not afraid to kill treacherously to do so. This was known.
David more or less gives Amasa a death sentence.