My solution (of course Im no expert) would be a fighting force minimally supported by the US-one that fights the way arabs do-meaning like how assad and saddam and Iran fight-without the PC rules of engagement of western nations. This is proven effective against terrorists, and we dont take the casualties or headlines of bombing an entire city block. The us presence would be behind this force, mainly to provide intelligence and air cover, and for maintaining a presence AFTER areas are cleared by the Iraqi military. We should dissolve shia militias, which would diminish fears of reprisal by sunni civilians while minimizing Iran's presence. If Iran wants to fight, let them do it through Syria. Our timelines should be based on outcomes, not a calendar. And frankly, I think we should do the same in Afghanistan.
None of this is easy. None of this will be entirely safe for anyone, including us. None of this is politically popular (until the next attack here in the US). But we need to be up front and clear in our goals and own it-because this problem is enveloping the world and WILL get worse. Id rather fight them there, where they are attracted like bugs to light, than here. This war wont end like WW2, it wont have a clear ending, and it will be with us for decades to come, frankly.