fix: fresh install archives stale state of a previous installation; a fatal Agent loop error stops the service instead of leaving a dead 'Running' one; 1.2.3

Found by uninstall + fresh install on the clean Windows Sandbox: the old agent_state.sqlite identity conflicted with the new enrollment and the service sat idle.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
gti
2026-09-25 12:25:53 -03:00
co-authored by Claude Sonnet 5
parent 2e5598ce9c
commit 6f0f072d84
23 changed files with 81 additions and 25 deletions
+7
View File
@@ -56,3 +56,10 @@ def test_main_preserves_pywin32_cli_commands(monkeypatch):
service.main()
assert called == [service.GTIFiscalAgentService]
def test_a_fatal_error_in_the_agent_loop_stops_the_service_instead_of_leaving_a_dead_one_running():
text = SERVICE_WRAPPER.read_text(encoding="utf-8")
body = text.split("agent_service.run(config, os.environ, stopper=self.stop_flag)", 1)[1].split("def main", 1)[0]
assert "except BaseException" in body and "logger" not in body.split("except BaseException")[0][-40:] # wrapped in try/except
assert "LogErrorMsg" in body and "self.stop_flag.stop = True" in body and "win32event.SetEvent(self.stop_event)" in body