The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(recovery): record the runtime-authority columns in the sessions schema history
Teknium494a89fca4cd
diff --git a/hermes_cli/session_schema_history.py b/hermes_cli/session_schema_history.pyindex 477b645abf3..f899ffbafd5 100644--- a/hermes_cli/session_schema_history.py+++ b/hermes_cli/session_schema_history.py@@ -203,6 +203,10 @@ SCHEMA_HISTORY: dict[str, _TableHistory] = {('+', 'compression_recovery_deadline', 'compression_ineffective_count'),)),('26 2026-09-02T14:22Z 8e4366d358', (('+', 'tool_names', 'last_read_at'),)),+ ('27 2026-09-08T18:45Z 0695b12b4c', (+ ('+', 'runtime_revision', 'id'),+ ('+', 'runtime_generation', 'runtime_revision'),+ )),),),"messages": _TableHistory(diff --git a/tests/hermes_cli/test_session_recovery_lost_and_found.py b/tests/hermes_cli/test_session_recovery_lost_and_found.pyindex 3418e6c2e7b..49623f05015 100644--- a/tests/hermes_cli/test_session_recovery_lost_and_found.py+++ b/tests/hermes_cli/test_session_recovery_lost_and_found.py@@ -473,6 +473,41 @@ def test_classify_lost_and_found_row_sentinels() -> None:assert classify_lost_and_found_row(0, ()) is None+def test_store_created_at_runtime_schema_maps_source_by_name(tmp_path: Path) -> None:+ """A store CREATED at the runtime-authority schema carries runtime_revision /+ runtime_generation right after ``id`` (declared order), so its source cell sits+ at index 3, not 1. The classifier must still see a sessions record and the+ mapper must land ``source`` by name rather than reject the population."""+ output = tmp_path / "mapped.db"+ SessionDB(db_path=output).close()+ dest = sqlite3.connect(str(output), isolation_level=None)+ lf = sqlite3.connect(":memory:", isolation_level=None)+ try:+ columns = [str(r[1]) for r in dest.execute("PRAGMA table_info(sessions)")]+ assert columns[:4] == ["id", "runtime_revision", "runtime_generation", "source"]+ row = {"id": "20260909_090909_fff006", "runtime_revision": 0, "runtime_generation": 0,+ "source": "telegram", "started_at": 1_754_000_000.0, "title": "fresh runtime store"}+ cells = tuple(row.get(c) for c in columns)+ assert classify_lost_and_found_row(len(cells), cells) == "sessions"+ lf.execute(+ "CREATE TABLE lost_and_found (rootpgno INTEGER, pgno INTEGER, nfield INTEGER, id INTEGER, "+ + ", ".join(f"c{i}" for i in range(len(cells))) + ")"+ )+ lf.execute(+ f"INSERT INTO lost_and_found VALUES ({', '.join('?' for _ in range(4 + len(cells)))})",+ [2, 5, len(cells), 1, *cells],+ )+ dest.execute("PRAGMA foreign_keys=OFF")+ report = map_lost_and_found_rows(lf, dest)+ assert report["mapped"]["sessions"] == 1+ assert report["unrecognized_layout_rows"] == 0+ assert dest.execute("SELECT source, title FROM sessions WHERE id = ?", (row["id"],)).fetchone() == (+ "telegram", "fresh runtime store")+ finally:+ lf.close()+ dest.close()++def test_mapper_rebuilds_sessiondb_from_synthetic_lost_and_found(tmp_path: Path,) -> None: