Refactor IMAP sync.

Summary:
This commit restructures the IMAP sync engine logic to use a more
object-oriented design, favoring implementation inheritance over explicit
state-and-implementation passing.

The primary motivation for this is that I was finding it really challenging to
do surgery on the mailsync code, for two reasons. First, passing functions
around made it very difficult to see where any given function is being invoked,
because you have to know that create_gmail_message(...) may actually be called
as msg_create_fn(...), etc. Second, it's really hard to modify the state
that's being passed around, because you have to change like seven levels of
function parameters. This pattern was leading us to do weird stuff like reading the
account_id from the crispin_client, or repeatedly query for things we already in
principle know, like the active Namespace instance.
This carries a significant performance cost when aggregated over the lifetime
of a sync.

So this commit is essentially preparation for making targeted changes
to address both performance and correctness. Concretely, it does the following:
* Implement most logic in methods of the FolderSyncEngine class, which runs the
  sync state machine. Implement derived classes CondstoreFolderSyncEngine and
  GmailFolderSyncEngine, which override specific functionality for condstore
  sync and Gmail sync.

* Move the SyncMonitor logic (the thing that gets instantiated from the
  SyncService and starts the individual folder syncs) into its own module
  backends.imap.monitor. The SyncService actually instantiates lightweight
  derived classes GmailSyncMonitor, GenericSyncMonitor, etc. depending on
  provider, but the only difference among them is which type of
  FolderSyncEngine gets instantiated.

Smaller associated changes:
* Rename backends.imap.account to backends.imap.common, to prevent confusion
  over whether 'account' is an Account instance or a module.
* Use structlog's greenlet-local context facility to bind context to the logger
  on a per-greenlet basis. This means that we can just do log = get_logger() in
  in a greenlet and have it come with the right bound attributes, instead of
  needing to pass around a log object.
* Define 'mailsync_session_scope' as an alias for
  'session_scope(ignore_soft_deletes=False)'
* Remove some unused code.
* Clean up some parameter mismatches in condstore code.

This is obviously a pretty gnarly patch, but I think if we eat our wheaties now
it will pay off later.

Test Plan:
Working on it. Probably going to do a 'sync-diff' for various
providers, by running a sync with and without this change, and checking that
the results are the same.

Reviewers: khamidou, spang

Reviewed By: khamidou, spang

Subscribers: kav-ya, charles

Differential Revision: https://review.inboxapp.com/D378