Skip to content

The agent that grows with you

test(state): cover Windows sidecars and force fence

JoaoMarcos44e31d2dc48819
diff --git a/tests/hermes_cli/test_sessions_set_journal_mode.py b/tests/hermes_cli/test_sessions_set_journal_mode.py
index 2e23264d9e5..dd13c446cc1 100644
--- a/tests/hermes_cli/test_sessions_set_journal_mode.py
+++ b/tests/hermes_cli/test_sessions_set_journal_mode.py
@@ -45,7 +45,10 @@ def test_set_journal_mode_converts_wal_store_offline(tmp_path, monkeypatch, caps
assert "wal → delete" in capsys.readouterr().out
-def test_set_journal_mode_refuses_while_another_process_holds_the_store(tmp_path, monkeypatch, capsys):
[email protected]("force", [False, True], ids=["normal", "deprecated-force"])
+def test_set_journal_mode_refuses_while_another_process_holds_the_store(
+ force, tmp_path, monkeypatch, capsys
+):
db = tmp_path / "state.db"
_wal_store(db)
monkeypatch.setattr("hermes_state.DEFAULT_DB_PATH", db)
@@ -58,7 +61,8 @@ def test_set_journal_mode_refuses_while_another_process_holds_the_store(tmp_path
deadline = time.monotonic() + 10
while time.monotonic() < deadline and not (tmp_path / "state.db-shm").exists():
time.sleep(0.05)
- assert cmd_sessions(_args("delete", force=False)) == 1
+ # --force is compatibility syntax, never a holder-verification bypass.
+ assert cmd_sessions(_args("delete", force=force)) == 1
finally:
holder.kill()
holder.wait()
diff --git a/tests/hermes_state/test_state_db_holders_windows_live.py b/tests/hermes_state/test_state_db_holders_windows_live.py
index 5c4697d3f49..b03817c97a8 100644
--- a/tests/hermes_state/test_state_db_holders_windows_live.py
+++ b/tests/hermes_state/test_state_db_holders_windows_live.py
@@ -49,3 +49,41 @@ def test_restart_manager_finds_real_foreign_state_db_holder(tmp_path):
holder.wait(timeout=30)
assert foreign_state_db_holders(db) == []
+
[email protected]("suffix", ["-wal", "-shm"])
+def test_restart_manager_finds_foreign_sqlite_sidecar_holder(tmp_path, suffix):
+ """A foreign sidecar-only handle is still a holder of this SQLite resource family."""
+ db = tmp_path / "state.db"
+ db.touch()
+ sidecar = tmp_path / f"state.db{suffix}"
+ sidecar.write_bytes(b"sidecar sentinel")
+
+ holder = subprocess.Popen(
+ [
+ sys.executable,
+ "-c",
+ (
+ "import os,sys; "
+ "f=open(sys.argv[1], 'rb'); "
+ "print(f'held:{os.getpid()}', flush=True); sys.stdin.readline()"
+ ),
+ str(sidecar),
+ ],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ text=True,
+ )
+ try:
+ marker, pid_text = holder.stdout.readline().strip().split(":", 1)
+ assert marker == "held"
+ holder_pid = int(pid_text)
+
+ holders = foreign_state_db_holders(db)
+ assert any(pid == holder_pid for pid, _ in holders), holders
+ finally:
+ holder.stdin.write("\n")
+ holder.stdin.flush()
+ holder.wait(timeout=30)
+
+ assert foreign_state_db_holders(db) == []
+