The "Magic Cube Lemma" is a surprising (to me) relationship between (homotopy) pushouts and (homotopy) pullbacks of spaces:

Consider a cubical diagram $I^3\to \mathcal{S}$ in the $\infty$-category of spaces/homotopy types (where $I=\Delta^1=\mathrm{N}\{0\to 1\}$):

$\require{AMScd}$ \begin{CD} A @>>> @>>> B @. \\ @VVV @. @VVV @.\\ @. A' @>>> @>>> B'\\ @VVV @VVV @VVV @VVV\\ C @>>> @>>> D @. \\ @. @VVV @. @VVV\\ @. C' @>>> @>>> D'\\ \end{CD}

where there are supposed to be arrows connecting the back layer ($A,B,C,D$) to the front layer ($A',B',C',D'$). (Maybe a kind soul can explain how I draw actual cubical diagrams with AMScd)

Assume the following:

- The back and front layers are pushout squares
- The top layer ($A,B,A',B'$) and the left layer ($A,C,A',C'$) are pullback squares

Then the lemma asserts that also the right layer ($B,D,B',D'$) and the bottom layer ($C,D,C',D'$) are pullback squares.

A different way of stating the same lemma is as follows:

Let $I^2\to \mathrm{Fun}(I,\mathcal S)$ be a square of arrows in spaces.

\begin{CD} a @>f>> b\\ @VgVV (*) @VVg'V\\ c @>>f'> d\\ \end{CD} where $a\colon A\to A'$, etc. From this perspective, $f$,$f'$,$g$ and $g'$ are natural transformations of diagrams $I\to\mathcal S$.

Then the lemma can be restated as follows:

Assume that the square $(\ast)$ is a pushout and that the natural transformations $f$ and $g$ are Cartesian. Then also $f'$ and $g'$ are Cartesian.

More generally, the following also holds (essentially by the fact that every colimit can be built from coproducts and pushouts):

Let $U\colon K^\triangleright\to\mathrm{Fun}(I,\mathcal S)$ be a colimit diagram of arrows. If for every edge $e\colon I\to K$ the natural transformation $U\circ e\colon I\to\mathrm{Fun}(I,\mathcal S)$ is Cartesian, then the same is true for every edge $e\colon I\to K^\triangleright$.

(Here $K^\triangleright = K\star [0]$ denotes the right cone on the category/simplicial set $K$)

I am interested in the following higher dimensional version:

Call a natural transformation $f\colon a\to b$ between cubical diagrams $a,b\colon I^n\to\mathcal S$ *relatively Cartesian*,
if it is a Cartesian (i.e.\ a limit diagram) when viewed as a diagram $I^{n+1}=I\times I^n\to\mathcal S$.

(Equivalently: $f$ is a $p$-Cartesian edge for the canonical Cartesian fibration $p\colon\mathrm{Fun}(I^n,\mathcal S)\to \mathrm{Fun}(I^n_\star,\mathcal S)$, where $I^n_\star$ denotes the punctured cube obtained by removing the initial vertex $(0,\dots,0)$).

Let \begin{CD} a @>f>> b\\ @VgVV (**) @VVg'V\\ c @>>f'> d\\ \end{CD} be a square $I^2\to \mathrm{Fun}(I^n,\mathcal S)$ of $n$-dimensional cubical diagrams.

Is it true that: if $(\ast\ast)$ is a pushout, and $f$ and $g$ are relatively Cartesian, then $f'$ and $g'$ are also relatively Cartesian?

Or more generally:

Given a colimit diagram $K^\triangleright\to \mathrm{Fun}(I^n,\mathcal{S})$ such that every edge in $K$ is sent to a relatively Cartesian transformation, is the same true for all edges of $K^\triangleright$?

If it is true: can one deduce it formally from the original magic cube lemma (I tried, but failed) or does one maybe need an additional input about the $\infty$-category $\mathcal S$? If it holds for $\mathcal S$, does it also hold in any $\infty$-topos?