Mark's networking code

As cleaned up by @ediosyncratic using git filter-branch (among other dangerous tools).
Includes several fixups from later in the branch, but I may have missed some.
Compiled locally and passes all unit and acceptance tests.  Let's see how it fares more widely ...

I suspect reviewing the gross diff is easiest, as there are (even after squashing out a few) quite a lot of changes of mind along the way.  Also: 106 commits.
@markburgess  so far we've been logging "promise not kept" as error. Frankly I believe this is a good use of LOG_LEVEL_ERR, I don't believe the agent should be silent in that case.

For unrecoverable errors where the agent can't continue and must exit in an ugly manner we use LOG_LEVEL_CRIT to differentiate.