SessionStore message history now stores/loads domain/messaging.Message:
sender attribution, derived role, and conversation address are canonical
record fields. SQLite gains a role column with open-time backfill for
pre-migration databases. gateway.Message remains the channel-facing
transport; conversion lives in one boundary module. ChatContract,
gatewayrpc proto, and dashboard JSON are unchanged; the RPC client
splits into ChatContract (Client) and SessionStore (StoreClient) views.
Sessions stay SessionContext: UUID keys and platform/bot/title/branch
metadata have no lossless home in Conversation; keyed migration tracked
separately once Agent/user/binding ownership settles.
Refs: archie-core-d9dv
Task and event persistence now uses a dedicated SQLite sidecar derived from the configured state prefix, matching the independently persisted conversation store. The configured path now means a state-path prefix rather than a database file so fresh SQLite state never attempts to interpret the previous storage format.
Remove the retired implementation and dependency completely, strengthen SQLite migrations and concurrency behavior, restore backend-neutral coverage, and align configuration, operational guidance, UI labels, and deployment documentation with the new storage and host-daemon topology.
SQLite ordered List and GetByChannel by created_at while NellDB reversed
document order, i.e. by session ID. Both documented "newest first", both
passed the shared suite, and neither meant recency -- so a cutover
between backends could change which session a restart resumes, and
Touch, the live path that makes a session the newest one, changed
nothing on either.
Recency is now LastActiveAt when set and CreatedAt otherwise, on both
sides, with an index matching the SQLite expression.
The conformance suite gains the case that would have caught this: three
sessions whose creation order, ID order and use order all disagree, plus
a Touch, asserted against List and GetByChannel on both backends.
Refs archie-core-8u8.2
applyCompress reads the history, computes a summary, then replaces it.
ReplaceMessages removed everything outside the replacement set, so a
chat turn saved in that window was deleted without ever having been
read, let alone summarised. Confirmed on both backends. It is
unrecoverable loss, and it sits outside the write-then-delete guarantee
because the window is in the caller, not the store.
ReplaceMessages now takes the messages the caller is superseding instead
of inferring them from the complement of the replacement. A caller
computes a replacement from a history it read; anything that arrives
afterwards is not part of that, and is now left alone. IDs in both lists
are still kept, so read-modify-write callers are unaffected.
The test fake's ReplaceMessages was a slice assignment, which could not
observe ordering or identity at all -- it now mirrors the real stores.
Refs archie-core-6e0
Three defects shared one root cause -- messages had no identity of their
own, so the store could not tell a redelivery from a new message:
- SaveMessages destroyed history. Writing a batch replaced records that
a concurrent write had already stored, and earlier messages vanished.
- A redelivered channel message overwrote the stored one, contradicting
the append-only sequence in docs/architecture/messaging-and-work-intake
.md:112-114.
- /compress stranded whatever exceeded one page: deleting 1200 reported
1000 deleted and left 200 behind.
Messages now carry an application-generated MessageID, derived from
(session, source id) so a redelivery lands on the same record, and
stored records are immutable -- a repeat write is a no-op rather than an
overwrite. SourceID keeps the channel-native id for correlation without
being load-bearing. _ts is written as Unix milliseconds and clamped
monotonic per session: Telegram dates are whole seconds, so replies
arriving inside the same second would otherwise order arbitrarily.
Deletes page with a cursor instead of assuming one page holds everything.
Adds a SQLite session store behind the same interface, per
docs/architecture/messaging-and-work-intake.md:107. A shared conformance
suite runs all 19 groups against both implementations, so the two cannot
drift while the NellDB path is still the one wired up.