I'm not sure there is a full answer to the "General" question, at least, within the $D$-module setting. I'll leave some remarks about non-flatness partially answering the question, and perhaps someone will tune in and complete this to a proper answer.

First off, to understand how one can lift flatness we have to know where and how it is being encoded on each side of the correspondence:

-on the **$D$-module side** it comes straight from the tangent sheaf $\Theta_X$ being a *Lie subalgebra* of the algebra of differential operators $D_X$. It is, thus, how $\Theta_X$ sits inside $D_X$ that determines the flatness of the underlying connection;

(**Aside:** We may consider deformations of the algebra $\Theta_X$ where we still preserve the Lie algebra structure, generally leading to twisted $D$-modules. These seem to correspond to connections with fixed scalar curvature (mathoverflow), which under the correspondence give constructible sheaves on a gerbe over the base (mathoverflow). $D$-module theory proper doesn't seem to be the natural ground to explore generic non-flat vector bundles and, therefore, below we will make do with the subset of $O_X$-coherent $D$-modules, i.e. plain vector bundles with flat connection.)

-on the **local systems side**, the understanding of flatness comes from viewing them as representations of the fundamental groupoid. The fundamental groupoid encodes the notion of paths up to homotopy, which then assembles to a connection where any curvature is washed out. So, it is homotopy invariance that kills curvature. There's still holonomy in the form of monodromy, which is discrete due to flatness. Thus, if we want to lift flatness we need a weaker notion of homotopy invariance.

Let us summarize the web of correspondences at play:

vector bundles with flat connection

local systems

representation of the fundamental groupoid

We go from 1. to 2. via the parallel sections functor $\ker\nabla$, with flatness translating into Frobenius integrability condition on the *existence* of (unique local) solutions to the first-order ODEs $\ker\nabla$ given arbitrary initial data. These are finite-dimensional vector spaces. The correspondence 2. to 3. arises via standard results from covering spaces (already mentioned above; see mathoverflow). We may go directly from 1. to 3. by calculating the parallel transport of the (flat) connection, which descends to a representation of the fundamental group as result of flatness (equivalently, it is the monodromy of the solutions to $\ker\nabla$). The inverse direction goes via the associated bundle construction.

Hence, there are two places where one may explore "non-flatness": the $\ker\nabla$-functor and the parallel transport functor.

### $\ker\nabla$-functor

I've partially addressed this recently here Kernel of a non-integrable connection, but let me go over it again for the sake of completeness.

For not necessarily flat connections, $\ker\nabla$ is still a well-defined subsheaf of the sheaf of sections of the vector bundle. In particular, it is a sheaf of finite-dimensional vector spaces with the stalk-rank $\dim(\ker\nabla)_x$ bounded by the vector bundle rank. However, $\ker\nabla$ is no longer a local system if $\nabla$ is not flat. That happens if and only if
$$
x\mapsto \dim(\ker\nabla)_x
$$
is a locally constant function on $X$ (see Lemma 1.6 Conrad). Furthermore, given the stratification of $X$ by stalk-dimension
$$
X^{\leq d}:=\{x\in X | \dim(\ker\nabla)_x\leq d\}\,,
$$
we have that the restriction of $\ker\nabla$ to the subsets $X^{\leq d}-X^{\leq d-1}$ is locally constant for all $d$. Hence, cleary $\ker\nabla$ is a *constructible sheaf*.

This map from vector bundles with connection to constructible sheaves is certainly not invertible. As already mentioned by @user40276 the exit-path category is relevant here. In fact, a theorem due to MacPherson says that the category of constructible sheaves on $X$ is equivalent to the category of representations of the exit-path category (see Treumann). The exit-path category encodes the notion of exit-paths again *up to homotopy*. Therefore, on each stratum the curvature of the connection is being killed again, and what we are able to recover is a constructible vector bundle with *flat* connection (see this thesis of a Block's student; and also mathoverflow). Basically, it is a flat vector bundle on each stratum.

The question remains on how to better characterize the image of $\ker\nabla$ such that we recover a correspondence. See related questions mathoverflow, math.stackexchange.

### Parallel transport functor

In the smooth setting, the parallel transport of a connection can be assembled into a functor $\text{tra}$ by sending each point $x\in X$ to the vector space $E_x$, the fiber of $E$ over $x$, and a path $\gamma: x\to y$ to the parallel transport map $\text{tra}(\gamma):E_x\to E_y$. This notion is invariant under thin-homotopy, thus defining a functor from the *path-groupoid* of $X$ to $\text{Vect}$. Thin-homotopy is indeed the proper refinement of full homotopy to be able to accommodate (non-zero) curvature. In fact, as shown by (Schreiber & Waldorf), and also by (Berwick-Evans & Pavlov), the category of vector bundles with (not necessarily flat) connection is equivalent to the category of representations of the path-groupoid.

**Remark:** Notice that there's a canonical functor from the path-groupoid to the fundamental groupoid, by sending thin-homotopies to full homotopies. Therefore, a vector bundle with connection is flat if, as a representation of the path-groupoid, it factors through the fundamental groupoid.

Therefore, to close this to a circle of correspondences, as in 1.-2.-3.-1. above, and answer the question being asked we would need a sheaf-theoretic characterization of the category of representations of the path-groupoid. That is, the generalization of local systems (or constructible sheaves) for the non-flat/thin-homotopy case. I've asked about this here Category of representations of the path-groupoid.

vector bundlesand Einstein-Hermitianvector bundles. $\endgroup$