Towards quantum gravity: a framework for probabilistic theories with non-fixed causal structure