Now that you have given us the name of "the book" discussed in your post I have obtained a copy and had the opportunity to review the relevant material (Chapter 7, Sec 1). Seeing the full context of the material, for the benefit of others who have not read the authors's analysis, I will summarize my understanding of it below which includes equations not provided in your post.
- Referring to FIGURE 7-1, the authors apply the first law to the “combined system” obtaining
$$\delta W_{C}=\delta Q_{R}-dE_{C}\tag{1}$$
Where $dE_{C}$ and is a differential change in internal energy of the combined system and
$$\delta W_{C}=\delta W_{rev}+\delta W_{sys}\tag{2}$$
- The authors state that considering that the cyclic device is a reversible one, the following relationship applies
$$\frac{\delta Q_{R}}{T_{R}}=\frac{Q}{T}\tag{3}$$
Where $T$ is the temperature at the boundary between the reversible cyclic device and piston/cylinder system. Note this is equivalent to a single Carnot cycle operating between temperatures $T_R$ and $T$ (more on this below).
- The authors combine equations (1) and (3) to obtain
$$\delta W_{C}=T_{R}\frac{\delta Q}{T}-dE_C\tag{4}$$
- The authors then ask us to consider the situation where the system (piston/cylinder device) undergoes a cycle while the reversible cyclic device undergoes an integral number of cycles. Under these conditions, since both devices return to their original states there would be no change in internal energy (as state function) for the combined system, i.e., $dE=0$. Thus equation (4) becomes
$$\delta W_{C}=T_{R}\frac{\delta Q}{T}\tag{5}$$
Then integrating for the combined system gives
$$W_{C}=T_{R}\oint\frac{\delta Q}{T}\tag{6}$$
- Finally, the authors point out that since the Kelvin-Planck statement of the second law prohibits a system from producing a net amount of postive work while operating in a cycle and exchanging heat with a single thermal reservoir (in this case, $T_R$), it follows that $W_{C}$ cannot be a positive quantity. Or, given $T_R$ is a positive quantity, they state
$$\oint\frac{\delta Q}{T}\le 0\tag{7}$$
Which is the Clausius inequality, with the equal sign applicable if both devices in the combined system are reversible.
YOUR QUESTIONS/COMMENTS:
Given the above, the following is in response to your specific questions and comments on the authors' analysis.
Applying the first law of thermodynamics yields
$$ \delta Q_{R} - dE_{C}=\delta W_{C}$$
Where $\delta W_{C}$ is the total work produced by the system.
Presumably, you meant "the combined system" as the authors stated, and not the "system" which they label as the piston/cylinder component of the combined system.
Why does the book consider the cyclic device as reversible when we are
rejecting heat to the piston cylinder (system), which is not a thermal
reservoir since its temperature is varying?
There is no requirement that a reversible cycle can only exchange heat with fixed thermal reservoirs. The temperatures of the heat source and sink can vary, as long as they vary in such a way that the difference in temperature between the cyclic device and the heat sink/source continues to be infinitesimal. Under such conditions heat is reversible.
An example is the reversible otto cycle where temperature of the heat sink and source varies during the reversible constant volume heat addition and heat rejection processes.
To continuously reject heat to the system, the systems temperature
must always be less than or equal to the temperature of the cyclic
device during the heat rejection process.
If the cyclic device is operating as a reversible heat engine, then the temperature $T$ in Fig 7-1 must always be infinitesimally less than or equal to the temperature at which heat is rejected from the cyclic device. But if the cyclic device is operating as a reversible refrigerator/heat pump, the temperature $T$ need only be infinitesimally greater than the temperature at the input of the cyclic device.
If we follow the book's assumption that all of the heat rejected by
the cyclic device to the system is converted to work during
(isothermal expansion I think), then the internal energy of the system
will not change.
To be clear, as stated in my point 4 above, the book's assumption is the internal energy (a state property) of the combined system will not change if the the system undergoes a cycle (returning its properties to their original state) and the reversible cyclic device undergoes an integral number of cycles (returning its properties to their original state).
If we let the system undergo a cycle, we recover the work produced by
the system from the surroundings and convert it to heat for the cyclic
heat engine. How can heat be transferred from the cyclic device to the
system and from the system to the cyclic device?
Heat can be transferred from the system to the cyclic device as an input to the cyclic device if the cyclic device is now operated as a refrigerator or heat pump. The system temperature $T$ is infinitesimally greater than the temperature at the input to the cyclic device, resulting in the cyclic device operating as a refrigerator/heat pump as a discussed above. The cyclic device then rejects heat $Q_R$ to the thermal reservoir $T_R$.
But to do so there is now required to be a net positive input work, $W_C$, originating from outside the combined system so that the Clausius statement of the second law is not violated, which is: No refrigeration or heat pump cycle can operate without a net work input. Then, for energy conservation, $\delta Q_{R}= \delta Q + \delta W_C$
I'm unable to understand the final paragraph of your post to be able to comment at this time. Given the above, perhaps you can clarify it further.
Hope this helps.