hermes-agent/gateway
Hill Chitsanupong 784f733cf8 fix(gateway): honor session_reset policy when recovering sessions
Both session recovery paths (the startup stale-entry repoint and the
lazy in-message recovery) rebuilt the routing entry with updated_at=now
and never consulted _should_reset, so an opt-in idle/daily session_reset
policy was silently dead across any gateway restart: a recovered session
always looked freshly active, and since every subsequent message bumps
updated_at, a session recovered stale could then never age out at all.

Fix in three parts:

- _create_entry_from_recovered_row derives updated_at from the durable
  last_activity_at the finder already returns on the row (no extra DB
  round-trip; the original PR added SessionDB.get_last_activity for
  this, unnecessary post-#82633), falling back to created_at. An
  invalid or missing started_at now maps to epoch 0 instead of now — an
  invalid durable timestamp must look old, never freshly active.
  reset_had_activity is set from the row's durable activity/message
  signals so the continuity hint stays accurate.

- _recover_session_from_db evaluates _should_reset on the rebuilt entry:
  an overdue session is durably promoted to a reset boundary
  (promote_to_session_reset, falling back to end_session) and the stale
  mapping is dropped instead of repointed.

- _query_recoverable_session no longer reopens the row; the
  get_or_create_session recovery phase evaluates _should_reset first and
  either feeds the normal auto-reset create path (reset notice,
  prev_session_id continuity, durable promotion) or reopens and
  publishes the recovered entry exactly as before.

Behavior is unchanged under the default session_reset mode "none":
_should_reset returns None there, so recovery still resumes every
recoverable row — only users who opted into idle/daily resets see the
policy actually applied across restarts.

Cherry-picked from #78618 and adapted to the #82633 finder.
(cherry picked from commit 31c71f7629)
2026-08-09 15:02:27 -07:00
..
assets
builtin_hooks
platforms fix: store strong ref to detached fatal handler task to prevent GC 2026-08-09 22:34:28 +05:30
relay fix(gateway): rename a Discord thread once, after the reply lands 2026-08-09 04:33:58 -05:00
__init__.py
agent_cache_pressure.py fix: follow-ups for salvaged PR #80795 2026-08-07 21:02:33 +05:30
authz_mixin.py
cgroup_cleanup.py
channel_directory.py perf(slack): parallelize conversations.info lookups with asyncio.gather 2026-08-07 18:40:33 +05:30
code_skew.py
config.py fix: address self-review findings on the check_fn/ensure_deps_fn split 2026-08-07 13:28:43 +05:30
cwd_placeholder.py
dead_targets.py
delivery.py
delivery_ledger.py
display_config.py
drain_control.py
hooks.py fix: handle replacement transforms after CLI streaming 2026-08-08 14:06:30 +05:30
kanban_watchers.py feat(kanban,mcp): orphaned-card reconciliation + per-server MCP identity header 2026-08-07 08:58:20 -07:00
lifecycle_ledger.py
memory_monitor.py
message_timestamps.py
mirror.py
pairing.py
platform_registry.py fix(gateway): split check_fn (passive probe) from ensure_deps_fn (active installer) 2026-08-07 13:28:43 +05:30
profile_routing.py
readiness.py
response_filters.py
restart.py
restart_loop_guard.py fix(gateway): make the restart-loop breaker see slow crash cycles (#81642) 2026-08-09 21:40:23 +05:30
rich_sent_store.py
run.py fix(gateway): distinguish durable cached transcript rows 2026-08-09 15:02:00 -07:00
runtime_footer.py
scale_to_zero.py
session.py fix(gateway): honor session_reset policy when recovering sessions 2026-08-09 15:02:27 -07:00
session_context.py
session_stall.py
session_state.py
shutdown_flush.py fix(gateway): spool cap-dropped pending transcript messages instead of discarding 2026-08-09 14:08:51 -07:00
shutdown_forensics.py
shutdown_watchdog.py
slash_access.py
slash_commands.py fix(gateway): carry origin_json/display_name into /branch child sessions too 2026-08-09 14:59:59 -07:00
status.py fix(gateway): self-reacquire scoped lock by PID alone 2026-08-08 13:50:08 +05:30
status_phrases.py
sticker_cache.py
stream_consumer.py fix(gateway): cover all finalized stream sends 2026-08-08 16:59:42 -07:00
stream_dispatch.py
stream_events.py
streaming_tts_consumer.py
systemd_notify.py
turn_context.py
turn_lease.py refactor(gateway): drop dead degraded token field; de-churn salvage diff 2026-08-07 18:23:57 +05:30
wake.py
whatsapp_identity.py