For $H \hookrightarrow G$ an inclusion of Lie groups, with $\mathfrak{h} \hookrightarrow \mathfrak{g}$ the corresponding inclusion of Lie algebras, an $(H\hookrightarrow G)$-Cartan connection on a smooth manifold $X$ is a $G$-principal connection $\nabla$ on $X$ equipped with a reduction of its structure group to $H$ and such that at each point $x \in X$ the composite (for any local trivialization)

$$ \phi_x : T_x X \stackrel{\nabla}{\longrightarrow} \mathfrak{g} \longrightarrow \mathfrak{g}/\mathfrak{h} $$

is a linear isomorphism.

Now suppose that the inclusion is normal so that $\mathfrak{k} := \mathfrak{g}/\mathfrak{h}$ is a Lie algebra. Then for $\mu \in \mathrm{CE}^{n+1}(\mathfrak{k})$ an $H$-invariant Lie algebra $(n+1)$-cocycle on $\mathfrak{k}$ (hence an $L_\infty$-map $\mu : \mathfrak{k} \to \mathbb{R}[n]$), pullback of $\mu$ along $\phi$ produces a differential $(n+1)$-form $\phi^\ast \mu \in \Omega^{n+1}(X)$.

In the special case that $X = G/H$ and $\nabla$ is the Maurer-Cartan form, then this differential form is just the left-invariant extension of the cocycle over the Lie group, and is closed.

For general $X$ the form $\phi^\ast \mu$ is not in general closed. Asking it to be closed is akin to famous integrability conditions for differential form data, say in the definition of $G_2$-manifolds.

I would like to know if this concept of pulling back Lie algebra cocycles along Cartan connections this way and asking the result to be closed has been considered in generality, and under which name.

Moreover, what I am really interested in is the generalization of this condition to the case that $\mathfrak{g}$ is an $L_\infty$-algebra, $\nabla$ a higher principal connection and $X$ a suitable smooth higher (derived) stack. For this case, has anything vaguely similar to the above general condition been considered and given a name?