refactor(relay): purge platform-specific scope terminology from the relay adapter (D-Q2.5c) - #109
Merged
Conversation
…elay adapter (D-Q2.5c)
|
Review Complete Risk: 🟢 Low (15/100) — no findings · 145 LOC across 10 files PR replaces guild_id with scope_id throughout the gateway relay layer, updating the transport protocol, adapter, tests, and connector contract docs. No regressions or security issues introduced. Files Reviewed (10 files) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The gateway half of D-Q2.5c (connector half: NousResearch/gateway-gateway#92). The D-Q2.5 wire migration renamed the relay scope discriminator
guild_id→scope_idbehind a dual-read/dual-write overlap. Prod + staging are now onscope_id, so this removes the legacy alias — and, per the ask, purges all platform-specific (Discord "guild") scope terminology within the relay adapter.Hard scope boundary
Every change is inside
gateway/relay/, its tests, or the relay contract doc.session.pyand all native platform adapters are untouched.SessionSource.guild_idis an agent-wide field (native Discord/Matrix/Teams/qqbot adapters populate it; thediscord-tools prompt reads it) — it is not relay-only, so it stays. The relay wire path never callssession.py.to_dict(); it builds/reads frames directly ingateway/relay/, so the relay wire is fully migratable in isolation.Changes (relay adapter only)
ws_transport._event_from_wire— readscope_idonly (drop the?? guild_idfallback).adapter._with_scope— emitscope_idonly on outbound metadata (drop theguild_iddual-write); docstring "GUILD reply" → "SCOPED reply".adapter._capture_scope— readsource.scope_idonly; rename localguildvar →scope; genericize the_scope_by_chat/_dm_user_by_chatfield comments (guild_id (Discord)→scope_id (server/workspace scope)).__init__.relay_route_keysdocstring —guild_ids→scope_ids.guild_idkept: the raw inbound interaction payload read (payload.get("guild_id")), which is Discord's own wire field, mapped straight into the genericscope_idslot.Contract doc
Reframed the
guild_idrow as a legacy alias the connector no longer reads —session.py's agent-wideto_dict()still emits it (mirrored toscope_id) for non-relay session persistence, so it stays documented + wire-present but ignored. This is accurate and keeps theto_dict()-vs-doc conformance test green.Gate (all green)
ruffclean.origin/main(still dual-reads) ✅Paired PR
🤖 Solo relay lane (D-Q2.5c). Relay paths touch no manifest → not Teknium-gated.
Mirror-of: NousResearch#56016
NousResearch#56016