Gateway wire contract carries no channel dimension, so per-user identity never resolves #1255
Notifications
Due Date
No due date set.
Depends on
Reference: sam/archie#1255
Reference in new issue
Block a user
Found while implementing archie-core-ga6i/oyna. ga6i landed on main as
28f7d2a0, with the identical patch to the lane commit 56fc7231 this issue originally cited. oyna was subsequently closed by a different route (1fe4691b) which did NOT need this issue; see consequence 2.EVIDENCE (re-verified on main)
CONSEQUENCES
The per-user identity allowlist is real code that no production call site reaches with a real channel name.
This issue does NOT block archie-core-oyna, and oyna is closed. oyna's recorded fix direction needed this issue, but that direction was abandoned: the route path no longer enters SenderID at all, so no channel dimension is needed to stop it becoming a user identity (
1fe4691b). This issue therefore stands on its own remaining scope only -- consequences 1, 3, 4 and 5.The session-memory curator's criterion 4 (a pass writes a record a later turn reads) does not hold end to end for any channel: the curator writes agent-user memory addressed to a real sender id, while the turn reads with UserID always empty, so the read names agent and global scopes only (domain/memory.Subject.Scopes).
SessionSource.Platform is the FIRST COMPONENT OF THE SESSION NATURAL KEY: sessionStore.GetByChannel filters WHERE platform = ? AND channel_id = ?, and sessionTracker.resolve matches on BotUser/ChannelID/ThreadID for the rows it returns. It is a constant today, so nothing separates channels at the key level. The field's own documentation calls it "the adapter name (telegram, discord, web)" (internal/domain/messaging/session_store.go) and it is false for every non-web channel. Two costs follow for any fix: a collision needs a Telegram numeric chat id to equal an email recipient or a route path, so that is latent rather than live; and stamping the truthful platform changes live session lookup, because Save upserts excluded.platform. A chat with no /new re-resolves onto the same deterministic id and heals silently, but a chat whose active session came from /new or /branch falls back to the deterministic session once, orphaning that session's history until the operator picks it from /sessions.
Two further call sites hard-code r.gatewayName in that same lookup and would silently stop finding their own sessions if only the session-creation path were fixed: internal/gateway/session_commands.go's topic list and topic-switch handlers, both of which take a messaging.Message rather than an Inbound. session_tools.go has four more, and already takes platform as a parameter.
A green test asserts unreachable policy: internal/app/archied/chat_identity_test.go covers userIdentityResolver("webhook")/("telegram")/("email") for channels the sole production call site never passes. The wiring -- the Gateway's TurnRunnerConfig.UserIdentity is built from the real channel of the session it serves -- has no test and cannot pass today.
FIX DIRECTION
Thread the channel through RouteRequest/Inbound/SessionSource, following the precedent pb.Message.page sets for transport-only inbound context, and decide whether a turn runner is per-channel or per-message. A per-channel Router is not available -- there is exactly one Gateway process -- so the live choice is per-message vs a per-channel runner cache.
Then either accept the session-key change in consequence 4 and document the one-time active-session reset, or carry the channel in a new field and leave SessionSource.Platform as the gateway name, in which case Platform's own documentation has to stop claiming it names the adapter. That is a wire-contract decision for the maintainer, not a mechanical seam.
Close reason
Fixed in
3cdaba25(2026-09-22): pb.Message.platform carries the channel (telegram/email/webhook set it), Router.sessionPlatform stamps SessionSource.Platform from it for every session lookup including the topic handlers and session tools, and userIdentityResolver reads the platform per inbound. The one-time active-session re-resolve was accepted.Imported from beads
archie-core-c1qx· GitHub #1045 · type bug · priority P1 · created 2026-09-21 · closed 2026-09-26