Bug Description

What seems to happen is that apt vengefully removes ALL of the items associated with one task, including several base dependencies of other tasks (e.g. ubuntu-desktop)

One illustrative example is the openssh-server task:
This one includes the packages openssh-server, tcpd and libwrap0.
From a normal ubuntu-desktop (e.g. ~liveCD) both tcpd and libwrap0 are already installed, and the task-install pulls in only openssh-server.
However when the task is removed, all these three packages (openssh-server, tcpd and libwrap0) are forcefully removed.
Since libwrap0 is a core dependency of gnome, a large part of gnome will be removed alongside the removal of the task.

I can confirm this bug on Ubuntu 10.04 Desktop i386, 2.6.32-22-generic-pae.
After first running the command "sudo tasksel install openssh-server" and then running the command "sudo tasksel remove openssh-server" packages from two meta packages got affected.
Several packages from both the ubuntu-desktop and the ubuntu-restricted-extras meta packages were removed.
I fixed it by running the command "sudo tasksel install ubuntu-desktop" and then reinstalling some packages that had been removed from the ubuntu-restricted-extras meta package.

I've tested this on current Debian testing, and the problem exists, but is less problematic, since there seems to be much less overlap in the Debian tasks.

However one example is if the tasks: ~t^desktop. ~t^gnome-desktop and ~t^laptop, are installed and then the ~t^laptop task is removed. This will result in the removal of e.g. wpasupplicant, network-manager and network-manager-gnome, all of which are also a part of the ~t^gnome-desktop task.
I will take this upstream to Debian.

I've been told that the package sets are indeed defined by tasksel, hence the apt task would be invalid.

ola:
Please do not assign yourself to the bug unless you are working on it, thanks.

eMcE:
Yes, that might work in some cases.
It would be advisable though, to first do the grepping and then review the result before trying to reinstall everything from it, I have a feeling things could go even worse if one is not being careful there...

Also worth noting is that any automatically-installed states will have been lost, so that's something to keep in mind as well...