The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: warn about existing WAL on cross-VM fs on the vulnerable-SQLite path too
teknium12034126e0d1f
diff --git a/hermes_state_wal.py b/hermes_state_wal.pyindex 72eb500ebff..50ecc793e66 100644--- a/hermes_state_wal.py+++ b/hermes_state_wal.py@@ -285,11 +285,7 @@ def apply_wal_with_fallback(conn: sqlite3.Connection, *, db_label: str = "state.if configured == "delete":# Never-live-downgrade keeps WAL; tell the operator their delete did not apply._log_configured_delete_overridden_once(db_label)- # #110848: the fresh-DB refusal below never sees a DB that was already WAL before the cross-VM check- # existed (or was created on a native volume and then moved). Keeping WAL is right; staying silent is not.- db_file = _connection_db_file(conn)- if db_file and _path_on_cross_vm_fs(db_file):- _log_once("cross_vm_fs_existing_wal", db_label)+ _warn_existing_wal_on_cross_vm_fs(conn)_apply_wal_companions(conn)return "wal"@@ -418,6 +414,16 @@ def _set_journal_mode_no_wait(conn: sqlite3.Connection, mode: str) -> str:conn.execute(f"PRAGMA busy_timeout={previous_timeout}")+def _warn_existing_wal_on_cross_vm_fs(conn: sqlite3.Connection) -> None:+ """#110848: the fresh-DB cross-VM refusal never sees a DB that was already WAL before the check existed (or was+ created on a native volume and then moved). Keeping WAL is right (never live-downgrade); staying silent is not.+ Both the vulnerable-SQLite and the regular already-WAL paths return early, so both must call this."""+ db_file = _connection_db_file(conn)+ if db_file and _path_on_cross_vm_fs(db_file):+ # Keyed (and labelled) by path, not db_label: a gateway serving several profiles must hear about each one.+ _log_once("cross_vm_fs_existing_wal", db_file)++def _apply_delete_for_wal_reset_bug(conn: sqlite3.Connection, *, db_label: str, require_delete: bool = False) -> str:"""Avoid enabling WAL when the linked SQLite has the WAL-reset bug.@@ -431,6 +437,7 @@ def _apply_delete_for_wal_reset_bug(conn: sqlite3.Connection, *, db_label: str,if require_delete:# Upgrading SQLite doesn't help here; emit the actionable message last._log_configured_delete_overridden_once(db_label)+ _warn_existing_wal_on_cross_vm_fs(conn)_apply_wal_companions(conn)return "wal"if current is None:diff --git a/tests/hermes_state/test_cross_vm_fs_wal_refusal.py b/tests/hermes_state/test_cross_vm_fs_wal_refusal.pyindex 94279125547..995f95eb219 100644--- a/tests/hermes_state/test_cross_vm_fs_wal_refusal.py+++ b/tests/hermes_state/test_cross_vm_fs_wal_refusal.py@@ -97,9 +97,13 @@ class TestWalRefusalOnCrossVmFs:assert apply_wal_with_fallback(conn, db_label=str(db)) == "wal"conn.close()- def test_existing_wal_db_on_cross_vm_fs_warns_operator_once(self, tmp_path, monkeypatch, caplog):+ @pytest.mark.parametrize("wal_reset_vulnerable", [False, True])+ def test_existing_wal_db_on_cross_vm_fs_warns_operator_once(self, tmp_path, monkeypatch, caplog,+ wal_reset_vulnerable):# #110848: the fresh-DB refusal cannot help a database that is already WAL, and staying silent left the# reporter with a corrupting state.db and no signal. Keep WAL (never live-downgrade) but say so, once.+ # The WAL-reset-vulnerable SQLite path (Debian/Ubuntu system Pythons) returns early too and must not be silent.+ monkeypatch.setattr(hermes_state_wal, "is_sqlite_wal_reset_vulnerable", lambda *a, **k: wal_reset_vulnerable)db = tmp_path / "already-wal.db"seed = sqlite3.connect(str(db))if str(seed.execute("PRAGMA journal_mode=WAL").fetchone()[0]).lower() != "wal":diff --git a/website/docs/user-guide/docker.md b/website/docs/user-guide/docker.mdindex e8fe60a261a..827b94d9c39 100644--- a/website/docs/user-guide/docker.md+++ b/website/docs/user-guide/docker.md@@ -203,7 +203,7 @@ What Hermes does about it (since v2026.9.14):- A **fresh** database whose directory is on a virtiofs/9p mount is created in rollback (`DELETE`) journal mode and a one-time warning is logged. Nothing to do.- An **existing** WAL database on such a mount is never live-downgraded — other Hermes processes may hold it open, and a live switch destroys their uncheckpointed commits. Instead, every process logs a one-time error at startup and `hermes doctor` flags the database. Fix it one of two ways:- 1. Stop every Hermes process that uses the database, then run a one-time offline conversion: `sqlite3 /opt/data/state.db 'PRAGMA journal_mode=DELETE'`. Set `database.journal_mode: delete` in `config.yaml` so a later open does not switch it back to WAL.+ 1. Stop every Hermes process that uses the database, then run a one-time offline conversion with the Python that ships in the image (it has no `sqlite3` shell): `docker exec hermes python3 -c "import sqlite3; print(sqlite3.connect('/opt/data/state.db').execute('PRAGMA journal_mode=DELETE').fetchone()[0])"`. Set `database.journal_mode: delete` in `config.yaml` so a later open does not switch it back to WAL.2. Move the data directory onto a native volume — a named Docker volume (`-v hermes-data:/opt/data`) lives on the VM's own ext4 filesystem and supports WAL normally.Detection reads `/proc/self/mountinfo` inside the container, so it works regardless of the host operating system. It does not classify NFS, SMB, or generic FUSE mounts; on those, set `database.journal_mode: delete` explicitly. Hermes does not offer SQLite's `locking_mode=EXCLUSIVE` as an alternative because the gateway, cron, and worker processes open the database concurrently.