fix(gateway): chronological message ordering — _ts + per-session collections #870

Closed
opened 2026-10-27 13:38:05 +00:00 by sam · 0 comments
Owner

SaveMessages keys from i=0 and overwrites the first N messages of any non-empty session (verified: m0/m1 destroyed by a bulk save). SaveMessage derives seq from len(rows) so deletes cause key reuse. The 'at' timestamp is written and never read; ordering is by insertion counter, not time.

Fix: add Message.At, write nell.TimestampField (_ts), give each session its own NellDB collection (a room IS a collection), key messages by time-ordered unique IDs, and order/page via sdk.ScanSince. Clean break on existing data (carina is a testing ground).


Imported from beads archie-core-1786637498694-337-f829f27b · GitHub #358 · type task · priority P2 · created 2026-08-08 · closed 2026-08-08

SaveMessages keys from i=0 and overwrites the first N messages of any non-empty session (verified: m0/m1 destroyed by a bulk save). SaveMessage derives seq from len(rows) so deletes cause key reuse. The 'at' timestamp is written and never read; ordering is by insertion counter, not time. Fix: add Message.At, write nell.TimestampField (_ts), give each session its own NellDB collection (a room IS a collection), key messages by time-ordered unique IDs, and order/page via sdk.ScanSince. Clean break on existing data (carina is a testing ground). --- _Imported from beads `archie-core-1786637498694-337-f829f27b` · GitHub #358 · type task · priority P2 · created 2026-08-08 · closed 2026-08-08_
sam added the mediumtask labels 2026-10-27 13:38:05 +00:00
sam self-assigned this 2026-10-27 13:38:05 +00:00
sam closed this issue 2026-10-27 13:38:05 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#870