Add features needed for resilience of tasks delegated to the proxy
The middleware piggybacks on the action it is attached to. On first
run it sets up the clock for the action to receive a special event and
passes the execution to the action. On subsequent runs the middleware
checks if the received event is the one set earlier in which case it
does the polling, sets the clock again and suspends the
action. Otherwise it just passes the event to the action.
High level overview of polling could be summarized as follows. The
middleware retrieves a list of attached action's sub-plans and selects
actions which were delegated to smart proxies. The delegated actions
are grouped by a smart proxy and the smart proxies are queried about
the tasks' states. The actions are notified if either their proxy
tasks went missing or are stopped.