Skip to content

The agent that grows with you

Merge origin/main (ee7fc3bc06a) into feat/unified-gateway-runtime

Teknium1bd27576b3d7
diff --cc hermes_cli/session_lost_and_found.py
index a661f34e1d3,ee2f36cd664..d256ecd5136
--- a/hermes_cli/session_lost_and_found.py
+++ b/hermes_cli/session_lost_and_found.py
@@@ -280,10 -285,9 +296,10 @@@ def classify_lost_and_found_row(nfield
second = cells[1] if len(cells) > 1 else None
if nfield == SESSION_MODEL_USAGE_NFIELD: # session id first, model string second
return "session_model_usage" if isinstance(second, str) and second else None
- # Known sessions layouts, or an unknown historical one (>= 30 fields): session id + source is enough.
- if (
- nfield in SESSIONS_LAYOUT_NFIELDS or nfield == SESSIONS_LEGACY_MINIMAL_NFIELD or nfield >= 30
- ) and _session_source_index(cells) is not None:
- # Any historical sessions width: session id first + recognizable source second (every sessions
- # layout ever shipped has at least the 14 original columns).
- if nfield >= SESSIONS_LEGACY_MINIMAL_NFIELD and _looks_like_source(second):
++ # Any historical sessions width: session id first + recognizable source (every sessions layout ever
++ # shipped has at least the 14 original columns). Stores created at the runtime-authority schema carry
++ # runtime_revision/runtime_generation right after id, so the source cell sits at 3 there (#101409 lane).
++ if nfield >= SESSIONS_LEGACY_MINIMAL_NFIELD and _session_source_index(cells) is not None:
return "sessions"
return None
@@@ -346,15 -663,12 +675,16 @@@ def map_lost_and_found_rows(lf_conn: sq
# Per-kind destination columns + NOT NULL substitutes. Identity fields are never fabricated:
# rows with a NULL session id / role / source were already rejected by classify_lost_and_found_row.
targets: dict[str, tuple[list[str], dict[int, Any]]] = {}
- for kind_name, protected in (("sessions", (0, 1)), ("messages", (1, 2)), ("session_model_usage", (0, 1))):
+ for kind_name, protected in (
+ ("sessions", ("id", "source")), ("messages", ("session_id", "role")),
+ ("session_model_usage", ("session_id", "model")),
+ ):
+ columns = _table_columns(dest, kind_name)
defaults = _notnull_defaults(dest, kind_name)
- for index in protected:
- defaults.pop(index, None)
- targets[kind_name] = (_table_columns(dest, kind_name), defaults)
+ for name in protected:
+ defaults.pop(columns.index(name), None)
+ targets[kind_name] = (columns, defaults)
+ dest_types = {table: _declared_types(dest, table) for table in targets}
lf_tables = [
str(row[0]) for row in
lf_conn.execute("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'lost_and_found%'")