Let $(X,\mathscr T)$ be a paracompact Hausdorff space, $R$ some fixed ring, for each $k\in \mathbb Z$ $\mathcal F^k\in\mathsf{Mod}_R(X)$ a sheaf (with values in $R$-modules) on $X$ and $d:\mathcal F^k\rightarrow\mathcal F^{k+1}$ a differential such that $(\mathcal F^\bullet,d)$ is a sheaf cochain complex.
Let $\mathscr P\subseteq\mathscr T$ be a subset of the topology with the assumption that each point $x\in X$ has an open neighborhood $U\subseteq X$ such that $U\in\mathscr P$.
Let us further assume that for each $\mathscr P$-set $U\subseteq\mathscr P$, there is a homotopy operator $h:\mathcal F^k(U)\rightarrow\mathcal F^{k-1}(U)$ such that $\mathrm{id}=h\circ d+d\circ h$. This of course means that the complex $(\mathcal F^\bullet(U),d)$ is exact on any $\mathscr P$-set, and that the sheaf complex $(\mathcal F^\bullet, d)$ is exact.
Suppose furthermore that $f\in \mathcal F^k(X)$ is a fixed global section, it is closed ($df=0$), and we somehow know that the cohomology class $[f]\in H^k(\mathcal F^\bullet(X),d)$ vanishes. Thus there is a global section $g\in\mathcal F^{k-1}(X)$ with $f=dg$.
By our assumptions, there is an open cover $\{U_\alpha\}_{\alpha\in\mathbb A}$ such that each $U_\alpha\in\mathscr P$ is a $\mathscr P$-set, so we can construct $g_\alpha\in\mathcal{F}^{k-1}(U_\alpha)$ by $g_\alpha=h_\alpha f$ (here $h_\alpha$ is the homotopy operator on the $\mathscr P$-set $U_\alpha$), then $f|U_\alpha=dg_\alpha$, however the $\{g_\alpha\}$ do not in general fit together to construct a global section $g\in \mathcal F^{k-1}(X)$, and in general such a global section doesn't even exist. But in the particular case we are considering, a global primitive $g$ does exist by assumption.
So then my question is the following. Is there any more or less constructive procedure which allows for one to "collate" the local primitives $g_\alpha=h_\alpha f\in\mathcal F^{k-1}(U_\alpha)$ into a global element $g\in\mathcal{F}^{k-1}(X)$ with $f=dg$?
A particular example would be the case when $X$ is a smooth manifold, $\mathscr P$ is the collection of smoothly contractible open sets in $X$, the ring is $R=\mathbb R$, $\mathcal F^k=\Omega^k_X$ is the $k$th de Rham sheaf for $k\ge 0$ with $\mathcal{F}^{-1}=\mathbb R_X$ the constant sheaf (i.e. we are considering the "augmented" de Rham complex), and $h:\mathcal \Omega^k_X(U)\rightarrow\Omega^{k-1}_X(U)$ is the usual de Rham homotopy operator associated to any smooth contraction of the set $U$.
If under the assumptions in the question, such procedure doesn't exist, then what are a minimal set of assumptions we need to add for such a construction to exist? A possible example I can imagine is that we need to assume that there is a "good $\mathscr P$-cover of $X$", meaning that there is an open cover by $\mathscr P$-sets such that each finite intersection of members of the covers are also $\mathscr P$-sets (when the $\mathscr P$-sets are contractible open sets, then this is equivalent to the statement that good covers exist, which is true for smooth manifolds).