gateway: flip Router and ChatContract inbound signatures onto domain/messaging.Message #1203

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

Flip the gateway's channel-facing inbound signatures from gateway.Message to
domain/messaging.Message, so the canonical type reaches the channel boundary and
gateway.Message can eventually be deleted per the TARGET block in
internal/gateway/messaging_convert.go:17-21.

This is the single shared choke-point every channel feeds. It must land alone,
before any per-channel work, because all three messaging-migration beads
(4hof, h3w2, o4e4) converge on these same symbols and would collide on identical
diff hunks if run in parallel.

Symbols to change:

  • Router.Route internal/gateway/gateway.go:329
  • Router.RouteStream internal/gateway/gateway.go:512
  • Router.ResolveSessionKey internal/gateway/session_commands.go:270
  • ChatContract.RecentMessages/Route/Stream internal/gateway/chat_contract.go:14,16,19
  • messageProto/messageValue wire conversion internal/infrastructure/gatewayrpc/values.go:27,46

Measured state at 1a0be64: no package under internal/channels/ or internal/webui/
imports domain/messaging at all (0 references). The channels build gateway.Message
at 8 construction sites and hand it to the Router, which converts at the store
boundary. So there is no channel-local migration to do until this flip lands.

Construction sites that follow this change:

  • internal/channels/telegram/telegram.go:472,494,609; dangerous.go:428; model.go:214
  • internal/channels/email/email.go:204
  • internal/channels/webhook/webhook.go:172
  • internal/webui/api_chat.go:229

Also amend the messaging_convert.go TARGET block and migration-decisions.md
section 2 so the register and the code agree on whether gateway.Message survives.
1a0be64's commit message says it "remains the channel-facing transport", which is
true of that commit's scope but reads as contradicting the TARGET block.

Acceptance criteria

Router.Route, RouteStream and ResolveSessionKey take messaging.Message. ChatContract's three methods take/return messaging.Message. gatewayrpc wire conversion updated. All existing gateway tests pass unchanged in behaviour. Lands as one commit touching no channel package.

Close reason

Implemented in 7e1f44b, merged as 23e29b0. gateway.Message deleted; the channel boundary now speaks messaging.Message via a new gateway.Inbound{Message messaging.Message, Page string} envelope (Page reaches the system prompt, never persisted). Role set at construction; RoleForSender survives for the RPC boundary's per-side derivation. Proto unchanged. Added inbound_test.go (Page reaches prompt not record; channel Inbound round-trips with its Role). task check green on main.


Imported from beads archie-core-9g5e · GitHub #780 · type task · priority P2 · created 2026-09-08 · closed 2026-09-08

Flip the gateway's channel-facing inbound signatures from gateway.Message to domain/messaging.Message, so the canonical type reaches the channel boundary and gateway.Message can eventually be deleted per the TARGET block in internal/gateway/messaging_convert.go:17-21. This is the single shared choke-point every channel feeds. It must land alone, before any per-channel work, because all three messaging-migration beads (4hof, h3w2, o4e4) converge on these same symbols and would collide on identical diff hunks if run in parallel. Symbols to change: - Router.Route internal/gateway/gateway.go:329 - Router.RouteStream internal/gateway/gateway.go:512 - Router.ResolveSessionKey internal/gateway/session_commands.go:270 - ChatContract.RecentMessages/Route/Stream internal/gateway/chat_contract.go:14,16,19 - messageProto/messageValue wire conversion internal/infrastructure/gatewayrpc/values.go:27,46 Measured state at 1a0be64: no package under internal/channels/ or internal/webui/ imports domain/messaging at all (0 references). The channels build gateway.Message at 8 construction sites and hand it to the Router, which converts at the store boundary. So there is no channel-local migration to do until this flip lands. Construction sites that follow this change: - internal/channels/telegram/telegram.go:472,494,609; dangerous.go:428; model.go:214 - internal/channels/email/email.go:204 - internal/channels/webhook/webhook.go:172 - internal/webui/api_chat.go:229 Also amend the messaging_convert.go TARGET block and migration-decisions.md section 2 so the register and the code agree on whether gateway.Message survives. 1a0be64's commit message says it "remains the channel-facing transport", which is true of that commit's scope but reads as contradicting the TARGET block. ### Acceptance criteria Router.Route, RouteStream and ResolveSessionKey take messaging.Message. ChatContract's three methods take/return messaging.Message. gatewayrpc wire conversion updated. All existing gateway tests pass unchanged in behaviour. Lands as one commit touching no channel package. ### Close reason Implemented in 7e1f44b, merged as 23e29b0. gateway.Message deleted; the channel boundary now speaks messaging.Message via a new gateway.Inbound{Message messaging.Message, Page string} envelope (Page reaches the system prompt, never persisted). Role set at construction; RoleForSender survives for the RPC boundary's per-side derivation. Proto unchanged. Added inbound_test.go (Page reaches prompt not record; channel Inbound round-trips with its Role). task check green on main. --- _Imported from beads `archie-core-9g5e` · GitHub #780 · type task · priority P2 · created 2026-09-08 · closed 2026-09-08_
sam added the mediumtask labels 2026-10-27 13:39:26 +00:00
sam self-assigned this 2026-10-27 13:39:26 +00:00
sam closed this issue 2026-10-27 13:39:26 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#1203