fix(discord): extend channel-name matching to slash-command auth; clamp flush deadline to disconnect budget

Follow-up to the salvaged #8008 fix:
- Sibling-site fix: _evaluate_slash_authorization gated DISCORD_ALLOWED_CHANNELS /
  DISCORD_IGNORED_CHANNELS on numeric IDs only, so name/#name config that now works
  for on_message still silently failed for slash-command interactions. Refactor the
  channel-key helper to _discord_channel_keys_from_channel(channel, parent) and reuse
  it at the interaction gate. Fail-closed on missing channel id is preserved.
- The contributor's hardcoded 8s flush deadline could be hard-cancelled mid-flush:
  _teardown_adapter already wraps cancel_background_tasks() in the per-adapter
  disconnect budget (HERMES_GATEWAY_ADAPTER_DISCONNECT_TIMEOUT, default 5s). The flush
  deadline now derives from that budget with headroom so it always completes inside it.
- AUTHOR_MAP: map cypher@augmentl.com -> Nickperillo for CI.
- Tests: slash-auth name/#name allow + name ignore matching.
This commit is contained in:
teknium1 2026-06-30 01:26:10 -07:00 committed by Teknium
parent cb9308f0a6
commit b6045170bb
3 changed files with 43 additions and 4 deletions

View file

@ -1331,9 +1331,13 @@ class DiscordAdapter(BasePlatformAdapter):
budget = parsed
except ValueError:
pass
# Leave ~20% headroom (min 0.5s) so the outer wait_for can't pre-empt our
# own straggler cancellation, and never go below 1s for the happy path.
return max(1.0, budget - max(0.5, budget * 0.2))
# Stay strictly below the budget so the gateway's outer wait_for can't
# pre-empt our own straggler cancellation. Reserve ~20% (min 0.5s) of
# headroom, and never let the floor push us back up to/over the budget
# on tiny budgets — cap at 90% of the budget as a hard ceiling.
headroom = max(0.5, budget * 0.2)
deadline = max(1.0, budget - headroom)
return min(deadline, budget * 0.9)
async def disconnect(self) -> None:
"""Disconnect from Discord."""