For a closed system at constant temperature and volume, the criterion for spontaneity is $dA < 0$. However, for a system at constant composition, the total differential of $A$ is given by $$dA = -PdV -SdT.$$ This seems to imply that $dA = 0$ for a system at constant volume, temperature, and composition. The Wikipedia page for Helmholtz Free Energy claims that this relationship holds even for non-spontaneous processes. The derivation of $A$ as criterion for spontaneity at constant volume and temperature is $$dA = dU - TdS - SdT = \delta q - TdS + \delta w - SdT.$$ If we consider only $PdV$ work, we obtain $$dA = \delta q - TdS - PdV - SdT$$ and at constant $T$ and $V$, we get $$dA = \delta q -TdS.$$ The criterion $dA <0$ for spontaneous processes then follows from the Clausius inequality. These two equations seem to be contradictory, so I was hoping someone could explain how this can be reconciled. Thank you so much!
Clarification: The way I derived the $dA = -PdV - SdT$ for an arbitrary process is as follows:
For a function $f(x_1,\dots,x_n)$, the complete differential of $f$ is $$df = f_1 dx_1 + f_2 dx_2 + \dots + f_n dx_n$$ where $$f_i = \left(\frac{\partial f}{\partial x_i}\right)_{x_j \: j\neq i}.$$ Consider the function $$g = f - f_1 x_1.$$ The differential of $g$ is $$dg = df - f_1 dx_1 -x_1df_1$$ so that $$dg = -x_1 df_1 + f_2 dx_2 + \dots + f_n dx_n.$$ Now, applying this to the special case of internal energy $U(S,V)$, if we define $$A = U - \left(\frac{\partial U}{\partial S}\right)_{V} S = U - TS$$ then the above implies that $$dA = -SdT - PdV$$ since $$dU = TdS - PdV.$$