Folds task writes into a result dict and aggregates multiple writes to the same channel.
If the channel contains a single write, we record the write in the result dict as {channel: write}
If the channel contains multiple writes, we record the writes in the result dict as {channel: {'$writes': [write1, write2, ...]}}