One-form symmetry action in 4d Maxwell - closed or not? Note: I had an overlong post which I was advised to break into pieces - here is my first, most basic question. Next question is here.
I'm trying to understand how the electric one-form symmetry acts in 4d Maxwell theory on a manifold without boundary, and then what it means to try to gauge it. SE answers I've already read include 1, 3, 4 and 5, but I wasn't able to get a complete picture.
What is the precise action of the global one-form symmetry on the operators, vs a possibly gauged version?
Here is my current understanding.
The Maxwell action is
$$
S_0 = \int \frac{1}{2g^2} F\wedge \star F
$$
with $F = dA$ (locally).
We can see that this action is totally invariant under $A \rightarrow A + \lambda$, if $d \lambda = 0$. $\lambda = d\omega$ is of course the 0-form gauge symmetry.
While $S_0$ is invariant, the shift in $A$ will be detected by Wilson lines
$$
W_n[C] = e^{i n \oint A} \rightarrow e^{in \oint \lambda} W_n[C].
$$
This SE answer shows that the phase picked up is topological in the sense that it depends only on the homology class of $C$, since if $C \sqcup (-C') = \partial \Sigma$ then
$$
\int_C \lambda - \int_{C'} \lambda  = \int_{\Sigma} d\lambda = 0.
$$
Just as global 0-form symmetries involve shifting a field by a constant, i.e a 0-dimensional operator which doesn't change when you move around the connected manifold, so does a 1-form global symmetry involve shifting a field by a 1-dimensional operator that doesn't depend on how you smoothly deform it. Crucially this requires $d\lambda=0$.
On the other hand, consider shifting by some $\lambda$ such that $d\lambda \neq 0$. Then
$$
\Delta S_0 = \frac{1}{g^2} \int \star F \wedge d \lambda = \frac{1}{g^2} \int d\star F \wedge \lambda = 0 
$$
by virtue of the equation of motion for $A$. (This is up to some $d\lambda \wedge \star d\lambda$ term we are allowed to absorb.).
Elsewhere $\lambda$ is referred to as a flat connection, but a field is still said to shift by $d\lambda$.
$\color{orange}{\textbf{THE QUESTION}}$
Does the global symmetry action have $d\lambda = 0$ (as is held to be the case in this answer) or not? If not, what equations does $\lambda$ have to obey, and what changes about these equations when we consider trying to gauge the symmetry?
Compare this to the 0-form case where we start with a shift by a constant $\alpha$, then, when we gauge, consider the more general $\alpha(x)$.
 A: The answer is essentially what @ACuriousMind pointed out in a comment (which I will quote here, because comments are intended to be temporary)

if you use the equations of motion you're not demonstrating a symmetry. $δS=0$ under all possible infinitesimal variations is the definition of a solution of the equations of motion, so if you have to use the equation of motions to arrive at $δS=0$, you're not showing anything interesting - symmetries have to be off-shell, see also this.

Another way to see this, which is inherently a QFT statement is through the path integral. $\newcommand{\d}{\mathrm{d}}\newcommand{\D}{\mathrm{D}}$Namely, the gauge fields are dummy integration variables, i.e.
$$\int\D a \exp(-S[a]) = \int\D a' \exp(-S[a']).\tag{1}$$
But now, take $S[a]$ to be the Maxwell action$1$
$$S[a]=\frac{1}{2g^2}\Vert f\Vert^2,$$
and take $a' = a+\lambda$, where $\lambda$ is allowed to have some curvature.  You can most easily see that $\D a' = \D a$ and
$$S[a'] = \frac{1}{2g^2}\left(\Vert f\Vert^2 + 2\left<f,\d \lambda\right> + \Vert\d \lambda\Vert^2\right)$$
Then (1) says that
$$\int\D a \exp(-S[a]) = \int\D a \exp\!\left(-S[a]+\frac{1}{g^2}\left<f,\d \lambda\right> + \frac{1}{2g^2}\Vert\d \lambda\Vert^2\right),$$
which is true if and only if $\d\lambda = 0$.
Therefore only shifts by flat connections give a symmetry of Maxwell theory.

1 where $\Vert\bullet\Vert^2$ comes from the usual inner-product $\left<\bullet,\circ\right>:=\int \bullet\wedge\star\circ$
