Session curator turns a channel-native SenderID into a user identity, so a webhook route path becomes one #1497
Notifications
Due Date
No due date set.
Blocks
Depends on
Reference: sam/archie#1497
Reference in new issue
Block a user
Live on main after memory unification slices 2-5, and now UNMASKED: archie-core-ga6i landed as
28f7d2a0(identical patch to the lane commit 56fc7231), which is precisely what makes this write succeed instead of failing outright. The curator derives its participant from raw SenderID while the turn path resolves identity per channel, so the ratified rule "a webhook route path never becomes a user identity" (docs/prds/memory-engine-unification.md criterion 7, section 3) holds on the turn path and not on the curator path.BLOCKED BY archie-core-c1qx. The preferred fix direction recorded in earlier revisions -- "keyed on the session's platform" -- cannot be implemented as written and would be WORSE than the bug. See "Why the recorded fix direction cannot land yet". Do not implement this issue before c1qx.
EVIDENCE CHAIN (re-verified on main
a0170df7)CORRECTION to the earlier claim that Platform is only knowable at the composition: the adapter ALREADY holds a gateway.SessionStore whose List() returns full SessionContexts including Source.Platform (internal/gateway/session_store_sqlite.go:671). The platform is reachable from the adapter today with no wire change -- which is exactly why reading it now is unsafe.
CONSEQUENCE
A webhook session with exactly one distinct sender (its own route path) and >=1 extracted fact writes agent-user memory addressed to User: "/hooks/...". Nothing reads it, and every pass adds more: the facts are identical strings with no dedup, so growth is unbounded. Acceptance criterion 7 fails.
Webhook is the only channel that produces this. A dashboard session sends an empty SenderID, so sessionParticipant skips it as "unidentified" (internal/webui/api_chat.go:252-260). Telegram and email senders are real people, so their writes are addressed to a real identity -- unreadable today for the same reason c1qx gives, but at least semantically sound.
WHY THE RECORDED FIX DIRECTION CANNOT LAND YET
"Session platform" is not a channel name today. gateway.NewRouter(b.stateStore, nil, "web") (internal/app/archied/gateway_runtime.go:112) is the sole production Router; every session write stamps Platform from r.gatewayName (internal/gateway/session_commands.go:110, fed by the r.gatewayName argument at :275, plus :299 and :548); and every channel reaches that one Gateway over gRPC (internal/infrastructure/gatewayrpc/client.go:60, dialled at internal/app/archiemessaging/run.go:26). So a webhook session's recorded platform is "web", and userIdentityResolver("web") is noUserIdentity: failing closed on it would skip EVERY session with any sender -- i.e. every session -- and stop curator writes entirely. That is archie-core-c1qx, and it is why this issue must wait for it.
Do NOT substitute a "SenderID == SessionSource.ChannelID" heuristic for detecting webhook sessions: in a Telegram DM the chat id and the user id are the same value, so it would classify real people as route paths.
Do NOT empty webhook Inbound.SenderID at the producer: internal/gateway/gateway.go:247-249 keys the rate limiter on SenderID, and an empty one exempts the message from rate limiting.
Do NOT put a platform allowlist inside the curator package: channel policy belongs to the composition/infrastructure, per the same reasoning as the UserIdentity resolver.
FIX DIRECTION (intent unchanged, sequenced after c1qx)
Give the curator the same channel-aware identity policy the turn path already uses (userIdentityResolver), keyed on the channel the session record carries once c1qx makes that truthful, and supply it from the composition rather than deriving it in the adapter.
Test: a webhook session (platform webhook, one user-role message whose SenderID is a route path) must yield ActionSkipped and no write. Written against the adapter, that test cannot fail honestly until c1qx lands, because nothing in production produces a webhook-platform session to feed it.
Notes
CORRECTION to the close reason above: the per-route budget for webhooks is not 'config.RateLimitConfig'. That type is the shape of the Channel settings control-plane resource (kind channel-settings, internal/app/controlplane), which the Web UI owns and edits (restart-required); [chat.rate_limit] in the file is only that resource's seed, and boot.startRateLimiter reads the value boot.loadRuntimeConfig layers. The behaviour described above is unchanged -- a webhook is budgeted by its route path either way -- but the commit message for
1fe4691bcarries the same pre-migration framing, corrected in0ca733f7.Close reason
Fixed at the producer, not by the channel-attested policy this issue originally recorded. The webhook no longer puts its route path in SenderID at all (internal/channels/webhook/webhook.go leaves it empty and carries the route in the new transport-only Inbound.BudgetKey), so criterion 7 now holds structurally: no consumer, present or future, can read a route path as a user identity. Commit
1fe4691b.The recorded direction (supply the curator the channel-aware policy, keyed on the session's platform) was abandoned because its premise collapsed: c1qx showed SessionSource.Platform is not a channel name in production -- gateway.NewRouter(..., "web") is the sole Router and every channel reaches it over gRPC, so a webhook session records platform "web". Keying a fail-closed policy on that would have skipped every session with any sender, i.e. every session, stopping curator writes entirely. Making the platform truthful needs the Gateway wire contract changed and changes the session natural key (GetByChannel filters WHERE platform = ?), resetting the active session of any chat whose session came from /new or /branch on the first message after upgrade. That cost was not worth paying for this issue, so it stays with c1qx as separate, scoped work.
Rate limiting is preserved, which was the reason emptying SenderID had been prohibited: the route still keys the inbound limiter (config.RateLimitConfig documents per-route budgets for webhooks), now sourced from Inbound.BudgetKey rather than borrowed from the identity field. Verified by TestRouteBudgetKeyLimitsWithoutSenderID and TestWebhookHandlerRoute.
No curator change was needed: an empty SenderID already fails closed as an unidentified user message (sessionParticipant), which is the path a dashboard session takes.
Gate: task check exit 0, including the regenerated pb.Message.budget_key contract.
Imported from beads
archie-core-oyna· GitHub #903 · type bug · priority P1 · created 2026-09-19 · closed 2026-09-21