Ensure proper semantics when replacing all tasks in a goal.

Testing Done:
ci in flight.

Reviewed at https://rbcommons.com/s/twitter/r/1220/
Sync of https://github.com/pantsbuild/pants/commit/6c3b24f7bee87aeedbfc3d4eb2640f3148f7d0b8