  We show that the spectral action, when perturbed by a gauge potential, can be
written as a series of Chern--Simons actions and Yang--Mills actions of all
orders. In the odd orders, generalized Chern--Simons forms are integrated
against an odd $(b,B)$-cocycle, whereas, in the even orders, powers of the
curvature are integrated against $(b,B)$-cocycles that are Hochschild cocycles
as well. In both cases, the Hochschild cochains are derived from the Taylor
series expansion of the spectral action Tr$(f(D+V))$ in powers of $V=\pi_D(A)$,
but unlike the Taylor expansion we expand in increasing order of the forms in
$A$. This extends [Connes--Chamseddine 2006], which computes only the
scale-invariant part of the spectral action, works in dimension at most 4, and
assumes the vanishing tadpole hypothesis. In our situation, we obtain a truly
infinite odd $(b,B)$-cocycle. The analysis involved draws from recent results
in multiple operator integration, which also allows us to give conditions under
which this cocycle is entire, and under which our expansion is absolutely
convergent. As a consequence of our expansion and of the gauge invariance of
the spectral action, we show that the odd $(b,B)$-cocycle pairs trivially with
$K_1$.
