Cattle For Developers : Cattle Agent Communication

I want to contribute to cattle but the code base is really huge. Lack of comments is making it difficult to understand certain parts of project.

I have several questions regarding cattle agent communication. To begin with here are few:

  1. Cattle uses ping to send triggers which activate agent to request via GET/POST. While it is a good hack I wonder if it can be improved.
  2. When and how does cattle decides to send compute.instance.inspect/pull/activate/deactivate/remove etc. ? I am seeing a lot of logs in agent container. It is filled with inspect(/and ofcourse ping). Can anyone associate relevant classes with it (or perhaps a diagram could help)?