The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(recovery): share the synthesised-row title prefix between producer and verifier
kshitijk4poor88736f6b0286
diff --git a/hermes_cli/session_lost_and_found.py b/hermes_cli/session_lost_and_found.pyindex b1fadcafe7a..96c4d203c29 100644--- a/hermes_cli/session_lost_and_found.py+++ b/hermes_cli/session_lost_and_found.py@@ -55,6 +55,11 @@ SESSION_MODEL_USAGE_NFIELD = 18_EPOCH_LOW = 1_000_000_000.0 # 2001_EPOCH_HIGH = 4_000_000_000.0 # 2096+# Title prefix of every session row this lane synthesises (legacy-layout rows+# and stubbed parents). The recovery verifier keys on it to tell synthesised+# rows from positionally mapped ones.+STUB_TITLE_PREFIX = "[best-effort recovered"+SQLITE3_CLI_GUIDANCE = ("A last-resort page-level salvage is available when a `.recover`-capable ""`sqlite3` command-line shell is installed: its `.recover` command can "@@ -456,7 +461,7 @@ def map_lost_and_found_rows(cells[1] if _looks_like_source(cells[1])else "recovered",_heuristic_started_at(cells),- "[best-effort recovered] legacy session "+ f"{STUB_TITLE_PREFIX}] legacy session ""row (layout unknown)",),).rowcount@@ -525,7 +530,7 @@ def stub_missing_parent_sessions(dest: sqlite3.Connection) -> dict[str, Any]:for session_id, info in sorted(orphan_ids.items()):while True:title = (- f"[best-effort recovered {sequence}] session metadata "+ f"{STUB_TITLE_PREFIX} {sequence}] session metadata ""was unreadable")sequence += 1diff --git a/hermes_cli/session_recovery.py b/hermes_cli/session_recovery.pyindex be6afb0b7e7..c5228e2cf38 100644--- a/hermes_cli/session_recovery.py+++ b/hermes_cli/session_recovery.py@@ -1448,11 +1448,11 @@ def _lost_and_found_plausibility_errors(``started_at = 0.0`` when no timestamped message survived, so they areexcluded from the denominator."""- from hermes_cli.session_lost_and_found import _EPOCH_LOW+ from hermes_cli.session_lost_and_found import _EPOCH_LOW, STUB_TITLE_PREFIXerrors: list[str] = []checks = (- ("sessions", "started_at", "WHERE COALESCE(title, '') NOT LIKE '[best-effort recovered%'"),+ ("sessions", "started_at", f"WHERE COALESCE(title, '') NOT LIKE '{STUB_TITLE_PREFIX}%'"),("messages", "timestamp", ""),)for table, column, mapped_filter in checks:diff --git a/tests/hermes_cli/test_session_recovery_lost_and_found.py b/tests/hermes_cli/test_session_recovery_lost_and_found.pyindex b2823d3e299..5831bbd6026 100644--- a/tests/hermes_cli/test_session_recovery_lost_and_found.py+++ b/tests/hermes_cli/test_session_recovery_lost_and_found.py@@ -17,6 +17,7 @@ import pytestfrom hermes_state import SessionDBfrom hermes_cli import session_recoveryfrom hermes_cli.session_lost_and_found import (+ STUB_TITLE_PREFIX,classify_lost_and_found_row,map_lost_and_found_rows,rebuild_fts_indexes,@@ -817,7 +818,7 @@ def test_lost_and_found_lane_refuses_to_verify_a_physically_shifted_source(# The mis-mapping the gate caught: every mapped (non-stub) session got# the NOT NULL substitute where its real start time should be.mapped = out.execute(- "SELECT started_at FROM sessions WHERE COALESCE(title, '') NOT LIKE '[best-effort recovered%'"+ f"SELECT started_at FROM sessions WHERE COALESCE(title, '') NOT LIKE '{STUB_TITLE_PREFIX}%'").fetchall()assert mapped and all(row[0] == 0.0 for row in mapped)finally: