Commit Graph
4 Commits
Author SHA1 Message Date
sam 7c8f625f0e feat(gateway): flip channel boundary onto messaging.Message
Replaced gateway.Message as the currency at the channel-facing boundary
with the canonical internal/domain/messaging.Message. Channel adapters
now build the record directly (RoleUser, ConversationID, Sender) and the
Router hands it back unchanged, so nothing converts between two shapes in
process. gateway.Message is deleted; the dashboard route that had no home
in the record lives in a new Inbound envelope (Message + transport-only
Page), which reaches the system prompt and is never persisted.

Role is now set at construction instead of derived at the store boundary,
and the assistant reply is a direct messaging.Message (RoleAssistant,
Sender=botUser). The gRPC proto is unchanged: pb.Message still carries no
role, and both sides keep deriving it from the owning session's bot
identity via gateway.RoleForSender (ToStoredMessage/FromStoredMessage are
deleted).

Adds tests that the old shape could not express: Page reaches the system
prompt but not the persisted record, and a channel-built Inbound round-trips
with the Role the channel set.

Refs: archie-core-9g5e
2026-09-09 01:05:36 +10:00
sam 571323138d feat(messaging): migrate gateway session persistence onto domain types
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
2026-09-08 21:28:19 +10:00
sam 61b4b7b0cf refactor(store): replace legacy persistence with SQLite
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.
2026-08-09 22:27:25 +10:00
sam dbacb96994 fix(gateway): stop /compress destroying history it should have kept
Two defects, both confirmed on the NellDB and SQLite backends.

IDENTITY. applyCompress rebuilt the protected head and tail as bare
Message{From, Text}, so every message that survived a compression was
deleted and re-inserted with a fresh canonical MessageID, no SourceID
and a timestamp of now. A rebuilt message is a different message: after
one compression, redelivery deduplication was broken for the rest of the
session's life, so a Telegram backlog replay after a restart appended
every surviving message a second time -- 24 became 25 on a redelivery
that was a correct no-op beforehand. That made the dedup guarantee
survive only until the first /compress, and violated
messaging-and-work-intake.md:88-90 and 112-114.

CompressHistory now reports which input messages it protected and the
write-back carries those originals through untouched, so only the
summary is a new record. The summary is attributed to the bot rather
than falling through to "user": CompressHistory emits it with role
"system", which has no representation in the store, so the model was
replaying "[Earlier conversation has been summarised...]" as if the
human had typed it.

DISPATCH. Three ways to rewrite a history the operator did not ask to
rewrite, or to fail to rewrite one they did:

- Bare /compress took the preview branch, and the preview closes with
  "Run /compress to apply" -- the documented way to compress could never
  compress, and the failure-safe path was unreachable.
- /compress focus <topic> discarded the topic and ran a full default
  compression. Nothing implements focused summarisation; it now says so
  instead of doing something else irreversibly.
- /compress here (no count) and any typo fell through to a full
  compression. Both now print usage.

compressPreview also read a fixed 200-message window while reporting the
real count, so the two numbers in one sentence described different
conversations and it advised against compressions that were needed.

Refs archie-core-cz8, archie-core-8k8, archie-core-le6
2026-08-04 22:11:53 +10:00