Skip to content

The agent that grows with you

fix: restore logging startup and desktop response handling

ethernet5aff1bf7938a
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index e630e95176a..19d1b5c4d2b 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -293,6 +293,7 @@ import { loadNativeTokenSet, type NativeTokenStoreIo, persistNativeTokenSet } fr
import { registerNativeNotifications } from './notification-ipc'
import { serializeJsonBody, setJsonRequestHeaders } from './oauth-net-request'
import { LEGACY_OAUTH_PARTITION, resolveOauthPartition } from './oauth-partition'
+import { wireOauthSessionResponse } from './oauth-session-response'
import { listWindowsProcesses, reapPackageRootedProcesses } from './package-process-reap'
import { createParentStartMarkerResolver, parentWatchdogEnv } from './parent-process-identity'
import { bundledPayload, installIdForRoot } from './payload-backend'
@@ -431,6 +432,7 @@ import {
} from './updater/checkout'
import { readSourceUpdate, type SourceUpdate } from './updater/checkout-source'
import { ExternalStrategy } from './updater/external'
+import { readUpdatesFeedBaseFromConfig } from './updater/feed-config'
import { createMacStrategy } from './updater/mac-client'
import { type ConsumedRelaunch, consumePendingRelaunch, registerUpdateRelaunch, type RelaunchRegistration } from './updater/relaunch'
import { startRelaunchWaiter } from './updater/relaunch-waiter'
@@ -3150,34 +3152,16 @@ function resolveCheckoutUpdateStrategy(): UpdaterStrategy {
* Windows' registered App Installer source when no override is set.
*/
function resolveDesktopFeedBaseUrl(): string {
- const configured = readUpdatesFeedBaseFromConfig()
+ const configured: string = readUpdatesFeedBaseFromConfig(path.join(HERMES_HOME, 'config.yaml'))
if (configured) {return configured}
- const env = process.env.HERMES_DESKTOP_FEED_BASE_URL
+ const env: string | undefined = process.env.HERMES_DESKTOP_FEED_BASE_URL
if (env) {return env}
return ''
}
-/** Read `updates.desktop_feed_base_url` from the user's config.yaml. */
-function readUpdatesFeedBaseFromConfig(): string {
- try {
- const configPath = path.join(HERMES_HOME, 'config.yaml')
-
- if (!fileExists(configPath)) {return ''}
- const raw = fs.readFileSync(configPath, 'utf8')
- const match = raw.match(/^\s*desktop_feed_base_url\s*:\s*(.+)\s*$/m)
-
- if (!match) {return ''}
- const value = match[1].trim().replace(/^['"]|['"]$/g, '')
-
- return value
- } catch {
- return ''
- }
-}
-
/** The updater channel from the baked install stamp ('canary' vs 'stable'). */
function resolveUpdaterChannelFromStamp(): 'stable' | 'canary' {
return packagedReleaseChannel(INSTALL_STAMP) ?? 'stable'
@@ -7026,46 +7010,13 @@ function fetchJsonViaOauthSession(url, options: any = {}) {
reject(new Error(`Timed out connecting to Hermes backend after ${timeoutMs}ms`))
}, timeoutMs)
- request.on('response', res => {
- const chunks = []
- res.on('data', chunk => chunks.push(Buffer.from(chunk)))
- res.on('end', () => {
- if (timedOut) {
- return
- }
-
- clearTimeout(timer)
- const text = Buffer.concat(chunks).toString('utf8')
- const statusCode = res.statusCode || 500
-
- if (statusCode >= 400) {
- const err = new Error(`${statusCode}: ${text || ''}`) as any
- err.statusCode = statusCode
- reject(err)
-
- return
- }
-
- if (!text) {
- resolve(null)
-
- return
- }
-
- const looksHtml = /^\s*<(?:!doctype|html)/i.test(text)
- const contentType = String(res.headers['content-type'] || res.headers['Content-Type'] || '')
-
- if (looksHtml || contentType.includes('text/html')) {
- reject(new Error(`Expected JSON from ${url} but got HTML (status ${statusCode}).`))
-
- return
- }
-
- try {
- resolve(JSON.parse(text))
- } catch {
- reject(new Error(`Invalid JSON from ${url} (status ${statusCode}): ${text.slice(0, 200)}`))
- }
+ request.on('response', (res: Electron.IncomingMessage): void => {
+ wireOauthSessionResponse(res, {
+ url,
+ isTimedOut: (): boolean => timedOut,
+ clearTimer: (): void => clearTimeout(timer),
+ resolve,
+ reject
})
})
request.on('error', error => {
diff --git a/apps/desktop/electron/updater/feed-config.test.ts b/apps/desktop/electron/updater/feed-config.test.ts
new file mode 100644
index 00000000000..ea71227af9d
--- /dev/null
+++ b/apps/desktop/electron/updater/feed-config.test.ts
@@ -0,0 +1,54 @@
+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+
+import { expect, it } from 'vitest'
+
+import { readUpdatesFeedBaseFromConfig } from './feed-config'
+
+it('reads only the updates feed across equivalent YAML representations', (): void => {
+ const home: string = mkdtempSync(join(tmpdir(), 'hermes-feed-config-'))
+ const config: string = join(home, 'config.yaml')
+ const expected: string = 'https://mirror.example/updates'
+
+ const documents: string[] = [
+ `updates:\n desktop_feed_base_url: ${expected} # mirror\n`,
+ `updates: {desktop_feed_base_url: '${expected}'}\n`,
+ `other:\n desktop_feed_base_url: https://other.example\nupdates:\n desktop_feed_base_url: "${expected}"\n`,
+ `updates:\n desktop_feed_base_url: >-\n ${expected}\n`,
+ `\uFEFFupdates:\n desktop_feed_base_url: ${expected}\n`
+ ]
+
+ try {
+ for (const document of documents) {
+ writeFileSync(config, document)
+ expect(readUpdatesFeedBaseFromConfig(config)).toBe(expected)
+ }
+ } finally {
+ rmSync(home, { recursive: true, force: true })
+ }
+})
+
+it('leaves fallback selection available for missing, invalid or non-string config', (): void => {
+ const home: string = mkdtempSync(join(tmpdir(), 'hermes-feed-config-'))
+ const config: string = join(home, 'config.yaml')
+
+ const documents: string[] = [
+ '', 'updates: [', 'null', 'updates: null', 'updates: []',
+ 'other: {desktop_feed_base_url: https://other.example}',
+ 'updates: {desktop_feed_base_url: false}',
+ 'updates: {desktop_feed_base_url: 123}',
+ 'updates: {desktop_feed_base_url: [https://mirror.example]}'
+ ]
+
+ try {
+ expect(readUpdatesFeedBaseFromConfig(config)).toBe('')
+
+ for (const document of documents) {
+ writeFileSync(config, document)
+ expect(readUpdatesFeedBaseFromConfig(config)).toBe('')
+ }
+ } finally {
+ rmSync(home, { recursive: true, force: true })
+ }
+})
diff --git a/apps/desktop/electron/updater/feed-config.ts b/apps/desktop/electron/updater/feed-config.ts
new file mode 100644
index 00000000000..6b10e423da4
--- /dev/null
+++ b/apps/desktop/electron/updater/feed-config.ts
@@ -0,0 +1,23 @@
+import { readFileSync } from 'node:fs'
+
+import { load } from 'js-yaml'
+
+export function readUpdatesFeedBaseFromConfig(configPath: string): string {
+ try {
+ // YAML permits scalar and sequence roots; validate the nested string at this I/O boundary.
+ const config: unknown = load(readFileSync(configPath, 'utf8'))
+
+ if (!config || typeof config !== 'object' || !('updates' in config)) {return ''}
+
+ const updates: unknown = config.updates
+
+ if (!updates || typeof updates !== 'object' || !('desktop_feed_base_url' in updates)) {return ''}
+
+ const value: unknown = updates.desktop_feed_base_url
+
+ return typeof value === 'string' ? value.trim() : ''
+ } catch {
+ // An absent/unreadable override leaves environment and registered feeds eligible.
+ return ''
+ }
+}
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 06d3b8d678b..310bf17cc6b 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -168,6 +168,7 @@
"@types/babel__core": "7.20.5",
"@types/d3-force": "3.0.10",
"@types/hast": "3.0.5",
+ "@types/js-yaml": "4.0.9",
"@types/node": "22.20.1",
"@types/qrcode": "1.5.6",
"@types/react": "19.2.17",
diff --git a/hermes_logging.py b/hermes_logging.py
index 5fcad8b700d..ffe7e8b1b14 100644
--- a/hermes_logging.py
+++ b/hermes_logging.py
@@ -18,35 +18,6 @@ from logging.handlers import QueueHandler, QueueListener
from pathlib import Path
from typing import Optional, Sequence
-# Windows-ONLY swap (#44873): stdlib ``RotatingFileHandler.doRollover()`` calls
-# ``os.rename()``, which fails with ``PermissionError [WinError 32]`` whenever
-# another process holds an append handle on ``agent.log`` — essentially always
-# in Hermes (TUI, gateway, hy_memory, MCP servers, CLI commands all log) —
-# pinning the file at the size threshold and spamming stderr on every emit.
-# ``concurrent-log-handler`` serializes rollover with a cross-process lock.
-# POSIX keeps stdlib: renames of open files work, and managed mode (NixOS)
-# relies on stdlib's exact ``_open()``/``doRollover()`` lifecycle for the
-# 0660 chmod and eager file creation; CLH opens lazily and rotates differently.
-if sys.platform == "win32":
- if _portalocker_probe():
- from concurrent_log_handler import ( # noqa: E402
- ConcurrentRotatingFileHandler as RotatingFileHandler,
- )
- else:
- # portalocker cannot take a lock on this box (typical cause: a sealed
- # bundle whose venv never processed pywin32.pth, so `import pywintypes`
- # fails and portalocker's Win32Locker has no msvcrt fallback). CLH
- # would silently drop every record through the suppressed lock-timeout
- # below; fall back to stdlib rotation instead. Rollover is disabled in
- # the fallback: multi-process appends make Windows renames fail with
- # WinError 32, the exact #44873 trap CLH exists to avoid.
- from logging.handlers import RotatingFileHandler # noqa: E402
-
- _WINDOWS_CLH_FALLBACK = True
-else:
- from logging.handlers import RotatingFileHandler # noqa: E402
-
-
from hermes_constants import get_config_path, get_hermes_home, mkdir_under_hermes_home
# setup_logging() is idempotent: a second call is a no-op unless ``force=True``.
@@ -83,7 +54,7 @@ def _portalocker_probe() -> bool:
return False
fd, path = tempfile.mkstemp(prefix="hermes-portalocker-")
try:
- with os.fdopen(fd, "r+") as stream:
+ with os.fdopen(fd, "r+b") as stream:
portalocker.lock(stream, portalocker.LOCK_EX)
portalocker.unlock(stream)
except Exception as exc:
@@ -96,6 +67,35 @@ def _portalocker_probe() -> bool:
pass
return True
+
+# Windows-ONLY swap (#44873): stdlib ``RotatingFileHandler.doRollover()`` calls
+# ``os.rename()``, which fails with ``PermissionError [WinError 32]`` whenever
+# another process holds an append handle on ``agent.log`` — essentially always
+# in Hermes (TUI, gateway, hy_memory, MCP servers, CLI commands all log) —
+# pinning the file at the size threshold and spamming stderr on every emit.
+# ``concurrent-log-handler`` serializes rollover with a cross-process lock.
+# POSIX keeps stdlib: renames of open files work, and managed mode (NixOS)
+# relies on stdlib's exact ``_open()``/``doRollover()`` lifecycle for the
+# 0660 chmod and eager file creation; CLH opens lazily and rotates differently.
+if sys.platform == "win32":
+ if _portalocker_probe():
+ from concurrent_log_handler import ( # noqa: E402
+ ConcurrentRotatingFileHandler as RotatingFileHandler,
+ )
+ else:
+ # portalocker cannot take a lock on this box (typical cause: a sealed
+ # bundle whose venv never processed pywin32.pth, so `import pywintypes`
+ # fails and portalocker's Win32Locker has no msvcrt fallback). CLH
+ # would silently drop every record through the suppressed lock-timeout
+ # below; fall back to stdlib rotation instead. Rollover is disabled in
+ # the fallback: multi-process appends make Windows renames fail with
+ # WinError 32, the exact #44873 trap CLH exists to avoid.
+ from logging.handlers import RotatingFileHandler # noqa: E402
+
+ _WINDOWS_CLH_FALLBACK = True
+else:
+ from logging.handlers import RotatingFileHandler # noqa: E402
+
# Thread-local per-conversation session context.
_session_context = threading.local()
@@ -716,7 +716,7 @@ def _read_logging_config():
config_path = get_config_path()
cfg = {}
if config_path.exists():
- with open(config_path, "r", encoding="utf-8") as f:
+ with open(config_path, "r", encoding="utf-8-sig") as f:
cfg = fast_safe_load(f) or {}
if not cfg:
return (None, None, None)
diff --git a/package-lock.json b/package-lock.json
index 85c06169b2e..35399cc3d87 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -156,6 +156,7 @@
"@types/babel__core": "7.20.5",
"@types/d3-force": "3.0.10",
"@types/hast": "3.0.5",
+ "@types/js-yaml": "4.0.9",
"@types/node": "22.20.1",
"@types/qrcode": "1.5.6",
"@types/react": "19.2.17",
@@ -6567,6 +6568,13 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@types/js-yaml": {
+ "version": "4.0.9",
+ "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz",
+ "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@types/jsesc": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@types/jsesc/-/jsesc-2.5.1.tgz",
diff --git a/tests/test_hermes_logging.py b/tests/test_hermes_logging.py
index 3f0c469634a..a49215ed4fc 100644
--- a/tests/test_hermes_logging.py
+++ b/tests/test_hermes_logging.py
@@ -1,4 +1,5 @@
"""Tests for hermes_logging — centralized logging setup."""
+import importlib.util
import io
import logging
import os
@@ -113,7 +114,7 @@ class TestSetupLogging:
agent_log = hermes_home / "logs" / "agent.log"
assert agent_log.exists()
- content = agent_log.read_text()
+ content = agent_log.read_text(encoding="utf-8-sig")
assert "test message for agent.log" in content
def test_profile_routing_follows_context_home(self, hermes_home, tmp_path):
@@ -137,9 +138,9 @@ class TestSetupLogging:
assert "profile-routed cron record" in (
profile_home / "logs" / "agent.log"
- ).read_text()
+ ).read_text(encoding="utf-8-sig")
default_log = hermes_home / "logs" / "agent.log"
- assert not default_log.exists() or "profile-routed cron record" not in default_log.read_text()
+ assert not default_log.exists() or "profile-routed cron record" not in default_log.read_text(encoding="utf-8-sig")
@@ -148,7 +149,7 @@ class TestSetupLogging:
"""Explicit function params take precedence over config.yaml."""
import hermes_yaml as yaml
config = {"logging": {"level": "DEBUG"}}
- (hermes_home / "config.yaml").write_text(yaml.safe_dump(config))
+ (hermes_home / "config.yaml").write_text(yaml.safe_dump(config), encoding="utf-8")
hermes_logging.setup_logging(hermes_home=hermes_home, log_level="WARNING")
@@ -200,7 +201,7 @@ class TestGatewayMode:
gw_log = hermes_home / "logs" / "gateway.log"
assert gw_log.exists()
- assert "telegram connected" in gw_log.read_text()
+ assert "telegram connected" in gw_log.read_text(encoding="utf-8-sig")
def test_gateway_log_rejects_non_gateway_records(self, hermes_home):
"""gateway.log does NOT capture records from tools.*, agent.*, etc."""
@@ -216,7 +217,7 @@ class TestGatewayMode:
gw_log = hermes_home / "logs" / "gateway.log"
if gw_log.exists():
- content = gw_log.read_text()
+ content = gw_log.read_text(encoding="utf-8-sig")
assert "running command" not in content
assert "compressing context" not in content
@@ -248,7 +249,7 @@ class TestGuiMode:
gui_log = hermes_home / "logs" / "gui.log"
assert gui_log.exists()
- content = gui_log.read_text()
+ content = gui_log.read_text(encoding="utf-8-sig")
assert "dashboard online" in content
assert "ws connected" in content
assert "gateway event" not in content
@@ -268,7 +269,7 @@ class TestSessionContext:
hermes_logging.flush_log_queue()
agent_log = hermes_home / "logs" / "agent.log"
- content = agent_log.read_text()
+ content = agent_log.read_text(encoding="utf-8-sig")
assert "[abc123]" in content
assert "tagged message" in content
@@ -366,7 +367,7 @@ class TestAddRotatingHandler:
hermes_logging.set_session_context("factory_test")
logger.info("test msg")
hermes_logging.flush_log_queue()
- content = log_path.read_text()
+ content = log_path.read_text(encoding="utf-8-sig")
assert "[factory_test]" in content
# Clean up
@@ -501,43 +502,74 @@ class TestWindowsConcurrentLogLockTimeout:
assert len(warnings) == 1
assert "concurrent-log-handler" in warnings[0].getMessage()
- def test_portalocker_probe_false_when_lock_raises(self, monkeypatch):
- """The import-time probe catches a dead portalocker (the sealed-bundle
- pywintypes failure) instead of letting CLH drop records silently."""
-
- class FakePortalocker:
- LOCK_EX = 2
-
- @staticmethod
- def lock(f, flags):
- raise ImportError("pywintypes is required for Win32Locker but not found")
-
- @staticmethod
- def unlock(f):
- return None
-
- monkeypatch.setitem(sys.modules, "portalocker", FakePortalocker)
- monkeypatch.setattr(sys, "platform", "win32")
- assert hermes_logging._portalocker_probe() is False
- assert "pywintypes" in hermes_logging._WINDOWS_CLH_FALLBACK_REASON
-
- def test_portalocker_probe_true_off_windows(self):
- # Off Windows the probe is a no-op: stdlib rotation is already in use.
- assert hermes_logging._portalocker_probe() is True
-
- def test_fallback_handler_disables_rollover(self, tmp_path, monkeypatch):
- """The stdlib fallback must not roll over: multi-process append
- handles make Windows renames fail with WinError 32, pinning the file
- and spamming stderr on every emit (#44873)."""
- monkeypatch.setattr(hermes_logging, "_WINDOWS_CLH_FALLBACK", True)
- handler = hermes_logging._new_file_handler(
- tmp_path / "agent.log", level=logging.INFO,
- max_bytes=5 * 1024 * 1024, backup_count=3,
+ @pytest.fixture
+ def fresh_logging(self):
+ def load():
+ spec = importlib.util.spec_from_file_location(
+ "_hermes_logging_import_test", hermes_logging.__file__,
+ )
+ assert spec is not None and spec.loader is not None
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+ return module
+ return load
+
+ @pytest.mark.platforms("windows")
+ def test_fresh_import_selects_working_concurrent_handler(self, tmp_path, fresh_logging):
+ """Native locking must work at import, before the handler class is defined."""
+ from concurrent_log_handler import ConcurrentRotatingFileHandler
+
+ module = fresh_logging()
+ assert module.RotatingFileHandler is ConcurrentRotatingFileHandler
+ assert module._WINDOWS_CLH_FALLBACK is False
+ assert module._WINDOWS_CLH_FALLBACK_REASON == ""
+
+ log_path = tmp_path / "agent.log"
+ handler = module._new_file_handler(
+ log_path, level=logging.INFO, max_bytes=1, backup_count=1,
+ formatter=logging.Formatter("%(message)s"),
+ )
+ try:
+ for message in ("before rollover", "after rollover"):
+ handler.handle(logging.LogRecord("test", logging.INFO, "", 0, message, (), None))
+ handler.flush()
+ assert log_path.read_text(encoding="utf-8-sig").splitlines() == ["after rollover"]
+ assert (tmp_path / "agent.log.1").read_text(encoding="utf-8-sig").splitlines() == ["before rollover"]
+ finally:
+ handler.close()
+
+ @pytest.mark.platforms("windows")
+ def test_fresh_import_retains_lock_failure_and_writes_without_rollover(
+ self, tmp_path, monkeypatch, fresh_logging,
+ ):
+ """A post-import platform fake misses both handler selection and fallback resets."""
+ import portalocker
+ from logging.handlers import RotatingFileHandler as StdlibRotatingFileHandler
+
+ failure = ImportError("pywintypes is required for Win32Locker but not found")
+
+ def fail_lock(stream, flags):
+ raise failure
+
+ monkeypatch.setattr(portalocker, "lock", fail_lock)
+ module = fresh_logging()
+ assert module.RotatingFileHandler is StdlibRotatingFileHandler
+ assert module._WINDOWS_CLH_FALLBACK is True
+ assert module._WINDOWS_CLH_FALLBACK_REASON == repr(failure)
+
+ log_path = tmp_path / "agent.log"
+ handler = module._new_file_handler(
+ log_path, level=logging.INFO, max_bytes=1, backup_count=1,
formatter=logging.Formatter("%(message)s"),
)
try:
assert handler.maxBytes == 0
assert handler.backupCount == 0
+ for message in ("first message", "second message"):
+ handler.handle(logging.LogRecord("test", logging.INFO, "", 0, message, (), None))
+ handler.flush()
+ assert log_path.read_text(encoding="utf-8-sig").splitlines() == ["first message", "second message"]
+ assert not list(tmp_path.glob("agent.log.*"))
finally:
handler.close()
@@ -555,7 +587,7 @@ class TestReadLoggingConfig:
def test_reads_logging_section(self, hermes_home):
import hermes_yaml as yaml
config = {"logging": {"level": "DEBUG", "max_size_mb": 10, "backup_count": 5}}
- (hermes_home / "config.yaml").write_text(yaml.safe_dump(config))
+ (hermes_home / "config.yaml").write_text(yaml.safe_dump(config), encoding="utf-8")
level, max_size, backup = hermes_logging._read_logging_config()
assert level == "DEBUG"
@@ -606,7 +638,7 @@ class TestExternalRotationRecovery:
handler = self._make_handler(log_path)
try:
self._emit(handler, "before rotation")
- assert log_path.read_text() == "before rotation\n"
+ assert log_path.read_text(encoding="utf-8-sig") == "before rotation\n"
# External rotation (NOT via handler.doRollover()).
os.rename(log_path, rotated)
@@ -617,8 +649,8 @@ class TestExternalRotationRecovery:
# The new write should land in a freshly recreated gateway.log,
# not appended to the rotated backup.
assert log_path.exists(), "handler did not recreate gateway.log"
- assert log_path.read_text() == "after rotation\n"
- assert rotated.read_text() == "before rotation\n"
+ assert log_path.read_text(encoding="utf-8-sig") == "after rotation\n"
+ assert rotated.read_text(encoding="utf-8-sig") == "before rotation\n"
finally:
handler.close()
@@ -638,12 +670,12 @@ class TestExternalRotationRecovery:
self._emit(handler, "AAAA" * 32)
assert log_path.stat().st_size > 0
- with open(log_path, "w"):
+ with open(log_path, "w", encoding="utf-8"):
pass # truncate to zero
assert log_path.stat().st_size == 0
self._emit(handler, "after truncate")
- assert log_path.read_text() == "after truncate\n"
+ assert log_path.read_text(encoding="utf-8-sig") == "after truncate\n"
finally:
handler.close()
@@ -665,7 +697,7 @@ class TestExternalRotationRecovery:
logging.getLogger("gateway.run").info("line BEFORE rotation")
hermes_logging.flush_log_queue()
- assert "BEFORE rotation" in gw_path.read_text()
+ assert "BEFORE rotation" in gw_path.read_text(encoding="utf-8-sig")
# External actor renames the file out from under us.
os.rename(gw_path, rotated)
@@ -683,8 +715,8 @@ class TestExternalRotationRecovery:
# backup. Allen's logs had everything past the rotation point
# going into agent.log only, never gateway.log.
assert gw_path.exists(), "gateway.log was never recreated"
- assert "AFTER rotation" in gw_path.read_text()
- assert "AFTER rotation" not in rotated.read_text()
+ assert "AFTER rotation" in gw_path.read_text(encoding="utf-8-sig")
+ assert "AFTER rotation" not in rotated.read_text(encoding="utf-8-sig")
class TestSafeStderr: