63316c74a8
_dedupe_display_generations chose the right representative row per logical message but sorted the survivors by that representative's id. A protected-tail copy written into a newer compaction generation has a higher id than messages emitted after the original, so include_compacted reads came back as C, A, B. Anchor the sort on the logical message's first-ever row id instead. Salvaged from #93869 (the tui_gateway half of that PR is superseded by #100504 and #104137); the code moved from hermes_state.py to hermes_state_messages.py since, so the change is re-applied to its new home with the PR's regression test verbatim.