Causal Blankets: Theory and Algorithmic Framework