The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(state): join short adjacent string literals (AST-neutral)
Teknium18946a781f21
diff --git a/hermes_state_common.py b/hermes_state_common.pyindex 721878920a8..0cd448fc06b 100644--- a/hermes_state_common.py+++ b/hermes_state_common.py@@ -313,7 +313,6 @@ _FTS_TRIGGERS = ("messages_fts_trigram_insert", "messages_fts_trigram_delete", "messages_fts_trigram_update",)-SCHEMA_SQL = """CREATE TABLE IF NOT EXISTS schema_version (version INTEGER NOT NULL@@ -700,7 +699,6 @@ BEGINEND;"""-_FTS_CJK_TRIGGERS = ("messages_fts_cjk_insert", "messages_fts_cjk_delete", "messages_fts_cjk_update",)@@ -753,7 +751,6 @@ AFTER UPDATE OF content, tool_name, tool_calls ON messages BEGINEND;"""-LEGACY_FTS_TRIGRAM_SQL = """CREATE VIRTUAL TABLE IF NOT EXISTS messages_fts_trigram USING fts5(content,diff --git a/hermes_state_schema.py b/hermes_state_schema.pyindex b2c21529448..1e1f7193b8e 100644--- a/hermes_state_schema.py+++ b/hermes_state_schema.py@@ -53,9 +53,7 @@ _FTS_TRIGRAM_TRIGGERS = tuple(n for n in _FTS_TRIGGERS if "_trigram_" in n)_FTS_BASE_TRIGGERS = tuple(n for n in _FTS_TRIGGERS if n not in _FTS_TRIGRAM_TRIGGERS)_LEGACY_INLINE_CONCAT_SQL = (- "COALESCE(content, '') || ' ' || "- "COALESCE(tool_name, '') || ' ' || "- "COALESCE(tool_calls, '') "+ "COALESCE(content, '') || ' ' || COALESCE(tool_name, '') || ' ' || COALESCE(tool_calls, '') ")_SESSION_MODEL_USAGE_INDEX_SQL = ("CREATE INDEX IF NOT EXISTS idx_session_model_usage_session ON session_model_usage(session_id)",@@ -167,8 +165,7 @@ class SessionSchemaMixin:"""try:rows = cursor.execute(- "SELECT id, system_prompt FROM sessions "- "WHERE system_prompt IS NOT NULL"+ "SELECT id, system_prompt FROM sessions WHERE system_prompt IS NOT NULL").fetchall()except sqlite3.OperationalError:return@@ -176,9 +173,7 @@ class SessionSchemaMixin:try:prompt_hash = self._store_system_prompt(cursor, prompt)cursor.execute(- "UPDATE sessions "- "SET system_prompt_hash = ?, system_prompt = NULL "- "WHERE id = ?",+ "UPDATE sessions SET system_prompt_hash = ?, system_prompt = NULL WHERE id = ?",(prompt_hash, session_id),)except sqlite3.OperationalError as exc:@@ -293,8 +288,7 @@ class SessionSchemaMixin:def _cjk_update_trigger_is_narrowed(self, cursor: sqlite3.Cursor) -> bool:"""True when messages_fts_cjk_update exists with AFTER UPDATE OF."""row = cursor.execute(- "SELECT sql FROM sqlite_master "- "WHERE type = 'trigger' AND name = ?",+ "SELECT sql FROM sqlite_master WHERE type = 'trigger' AND name = ?",("messages_fts_cjk_update",),).fetchone()return bool(row) and not self._fts_update_trigger_needs_narrowing(row[0])@@ -323,8 +317,7 @@ class SessionSchemaMixin:if include_trigram:cursor.execute("INSERT INTO messages_fts_trigram(messages_fts_trigram) VALUES('rebuild')")cursor.execute(- "DELETE FROM state_meta WHERE key IN "- "('fts_rebuild_high_water', 'fts_rebuild_progress')"+ "DELETE FROM state_meta WHERE key IN ('fts_rebuild_high_water', 'fts_rebuild_progress')")@staticmethod@@ -593,8 +586,7 @@ class SessionSchemaMixin:self._fts_enabled = Trueself._trigram_available = include_trigramlogger.warning(- "Rebuilt stale state.db FTS indexes from canonical messages and "- "restored sync triggers."+ "Rebuilt stale state.db FTS indexes from canonical messages and restored sync triggers.")return True@@ -637,8 +629,7 @@ class SessionSchemaMixin:ref.executescript(schema_sql)table_columns: Dict[str, Dict[str, str]] = {}for (tbl,) in ref.execute(- "SELECT name FROM sqlite_master "- "WHERE type='table' AND name NOT LIKE 'sqlite_%'"+ "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'").fetchall():cols: Dict[str, str] = {}for _cid, col_name, col_type, notnull, default, pk in ref.execute(@@ -990,8 +981,7 @@ class SessionSchemaMixin:fts5_availableand not self._db_has_legacy_inline_fts(cursor)and cursor.execute(- "SELECT 1 FROM state_meta "- "WHERE key = 'fts_rebuild_high_water' LIMIT 1"+ "SELECT 1 FROM state_meta WHERE key = 'fts_rebuild_high_water' LIMIT 1").fetchone() is Noneand not self._has_fts_trash(cursor)and not self._fts_external_index_empty_with_messages(cursor)