  We provide a unified operational framework for the study of causality,
non-locality and contextuality, in a fully device-independent and
theory-independent setting. Our work has its roots in the sheaf-theoretic
framework for contextuality by Abramsky and Brandenburger, which it extends to
include arbitrary causal orders (be they definite, dynamical or indefinite). We
define a notion of causal function for arbitrary spaces of input histories, and
we show that the explicit imposition of causal constraints on joint outputs is
equivalent to the free assignment of local outputs to the tip events of input
histories. We prove factorisation results for causal functions over parallel,
sequential, and conditional sequential compositions of the underlying spaces.
  We prove that causality is equivalent to continuity with respect to the
lowerset topology on the underlying spaces, and we show that partial causal
functions defined on open sub-spaces can be bundled into a presheaf. In a
striking departure from the Abramsky-Brandenburger setting, however, we show
that causal functions fail, under certain circumstances, to form a sheaf. We
define empirical models as compatible families in the presheaf of probability
distributions on causal functions, for arbitrary open covers of the underlying
space of input histories. We show the existence of causally-induced
contextuality, a phenomenon arising when the causal constraints themselves
become context-dependent, and we prove a no-go result for non-locality on total
orders, both static and dynamical.
