FactoryReset Loop

Try the latest master branch. It should resolve this issue (for the most part). Let me explain:

The issue here seems to be that the CPE is disconnecting after the FactoryReset command and before the TR-069 session is considered to be successfully terminated. Hence the session eventually times out and Genie simply forgets all updates that took place during the session. That is why you get repeating factory reset commands. The latest patches address this by committing the session state even if the session does not terminate successfully.

I would argue that this is a CPE bug as well. While the ACS should tolerate unsuccessful session termination, the client should not exploit measures that are clearly meant for handling exceptional cases in its normal operation. But regardless, as per the spec:

The CPE MUST initiate the factory reset procedure only after successful completion of the Session.

Although I hate to rely on a strict literal interpretation of the spec to get the point across. The spec does seem to be vague and potentially even contradictory at times when it comes to the behavior around successful vs unsuccessful sessions.

Unfortunately that may not be possible. What if there are other tasks in the queue? And what about the presets that it still needs to process after competing the tasks?