The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(state): never open+close an existing state.db inode while tightening modes
teknium1e16f686706b1
diff --git a/hermes_state.py b/hermes_state.pyindex 154c269dae5..31cd1521e35 100644--- a/hermes_state.py+++ b/hermes_state.py@@ -239,20 +239,22 @@ def _secure_state_db_files(db_path: Path, *, create_main: bool = False) -> None:main_path = db_pathif create_main:- flags = os.O_WRONLY | os.O_CREAT+ # O_EXCL: only a brand-new inode gets a descriptor. Opening an existing+ # file here and closing it would drop this process's POSIX locks on it.+ flags = os.O_WRONLY | os.O_CREAT | os.O_EXCLif hasattr(os, "O_NOFOLLOW"):flags |= os.O_NOFOLLOWif hasattr(os, "O_CLOEXEC"):flags |= os.O_CLOEXECtry:fd = os.open(main_path, flags, 0o600)+ except FileExistsError:+ passexcept IsADirectoryError:# Not a database file at all; sqlite3.connect() raises the# canonical error for this, and a directory leaks no row data.return- try:- os.fchmod(fd, 0o600)- finally:+ else:os.close(fd)for path in (