Skip to content

refactor(relay): purge platform-specific scope terminology from the relay adapter (D-Q2.5c) - #109

Merged
hashbender merged 1 commit into
mainfrom
mirror/pr-56016
Jul 1, 2026
Merged

refactor(relay): purge platform-specific scope terminology from the relay adapter (D-Q2.5c)#109
hashbender merged 1 commit into
mainfrom
mirror/pr-56016

Conversation

@hashbender

Copy link
Copy Markdown
Owner

relay adapter terminology purge

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_idscope_id behind a dual-read/dual-write overlap. Prod + staging are now on scope_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.py and all native platform adapters are untouched.

SessionSource.guild_id is an agent-wide field (native Discord/Matrix/Teams/qqbot adapters populate it; the discord-tools prompt reads it) — it is not relay-only, so it stays. The relay wire path never calls session.py.to_dict(); it builds/reads frames directly in gateway/relay/, so the relay wire is fully migratable in isolation.

Changes (relay adapter only)

  • ws_transport._event_from_wire — read scope_id only (drop the ?? guild_id fallback).
  • adapter._with_scope — emit scope_id only on outbound metadata (drop the guild_id dual-write); docstring "GUILD reply" → "SCOPED reply".
  • adapter._capture_scope — read source.scope_id only; rename local guild var → scope; genericize the _scope_by_chat / _dm_user_by_chat field comments (guild_id (Discord)scope_id (server/workspace scope)).
  • __init__.relay_route_keys docstring — guild_idsscope_ids.
  • One real Discord guild_id kept: the raw inbound interaction payload read (payload.get("guild_id")), which is Discord's own wire field, mapped straight into the generic scope_id slot.

Contract doc

Reframed the guild_id row as a legacy alias the connector no longer readssession.py's agent-wide to_dict() still emits it (mirrored to scope_id) for non-relay session persistence, so it stays documented + wire-present but ignored. This is accurate and keeps the to_dict()-vs-doc conformance test green.

Gate (all green)

Paired PR

  • NousResearch/gateway-gateway#92 — the connector half.

🤖 Solo relay lane (D-Q2.5c). Relay paths touch no manifest → not Teknium-gated.


Mirror-of: NousResearch#56016
NousResearch#56016

@tenki-reviewer

tenki-reviewer Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Complete
No issues found!

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)
docs/relay-connector-contract.md
gateway/relay/__init__.py
gateway/relay/adapter.py
gateway/relay/ws_transport.py
tests/gateway/relay/test_relay_adapter.py
tests/gateway/relay/test_relay_multiplatform.py
tests/gateway/relay/test_relay_passthrough.py
tests/gateway/relay/test_relay_roundtrip.py
tests/gateway/relay/test_relay_roundtrip_telegram.py
tests/gateway/relay/test_ws_transport.py

@hashbender
hashbender merged commit 5a0b716 into main Jul 1, 2026
26 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant