Fix references to agent_process_id, fix buildbot

This patch removes references to agent_process_id, which is an incorrect (and unreliable source) for the running agent's process ID.

This patch adds AgentProcessStateGate, a thin wrapper around ProcessStateGate that accepts a resource ID.  This saves code lines and unnecessary resource registry find ops.