Skip to content

feat(discord): add everyone_mentions_bot so @everyone/@here can count as a bot mention - #1551

Closed
Reese-max wants to merge 4 commits into
openabdev:mainfrom
Reese-max:devin/issue-1538
Closed

Reese-max wants to merge 4 commits into
openabdev:mainfrom
Reese-max:devin/issue-1538

Conversation

@Reese-max

Copy link
Copy Markdown

Refs #1538

Summary

  • New [discord] config bool everyone_mentions_bot (default false — existing behavior unchanged). When true, a message with mention_everyone set (@everyone/@here mass ping) counts as a mention of this bot.
  • Motivation: Discord mass pings set mention_everyone instead of populating mentions[], so with allow_user_messages = "mentions" a bare @everyone summon was silently dropped — making "summon all agents" impossible in multi-bot deployments.
  • The inline mention check in EventHandler::message is extracted into a pure is_bot_mentioned() helper (same convention as detect_thread), so the behavior is unit-testable without constructing serenity Message values. The single is_mentioned value continues to drive user-message gating, the trusted-bot admission override, ambient-mode routing, and the bot-message early gate — mass pings now flow through all of them consistently when the flag is on.
  • Enabler commits (required for cargo fmt/clippy --all-targets/test to pass under the current stable toolchain, per AGENTS.md): style: rustfmt 1.98 normalization sweep, test: fixes for pre-existing clippy --all-targets test-code lints, test: de-flake of hooks::tests::run_inline_script_timeout (transient spawn errors under parallel load → bounded retry).

Review Contract

Goal

Let an opt-in [discord] flag make @everyone/@here mass pings count as a bot mention, so allow_user_messages = "mentions" deployments (and multi-bot threads) can use mass pings to wake bots, without changing default behavior.

Non-goals

  • No change to default mention semantics or any other gating dimension (channel/user allowlists, DM policy, bot-turn caps all unchanged).
  • No Discord API changes; mention_everyone already arrives on the gateway payload.
  • The style:/test: normalization commits are mechanical enablers only — no attempt to refactor or redesign touched code.

Accepted Residual Risks

  • With the flag on, a trusted bot's mass ping bypasses allow_bot_messages mode (consistent with "mass ping = real mention"); mitigated by trusted_bot_ids scoping and the max_bot_turns cap. Documented in docs/discord.md.
  • With the flag on, a mass ping in ambient context forces dispatch after discard — opt-in, documented.
  • hooks test retry could theoretically mask a regression where the timeout arm is never reached; bounded to 3 attempts and still fails if no attempt produces "timed out".

Acceptance Criteria

  • everyone_mentions_bot = false (default or absent): byte-identical gating to before this PR; verified by tests and by is_bot_mentioned reproducing the original expression.
  • everyone_mentions_bot = true: msg.mention_everyone counts as mention for user gating, trusted-bot admission, and ambient handling.
  • Direct <@bot_id> mention, raw content fallback, and role mentions unaffected.
  • cargo fmt --all -- --check, cargo test --workspace, cargo clippy --workspace --all-targets -- -D warnings all green.

Follow-ups

  • CI could pin a rustfmt version or add a fmt job to prevent future style drift.
  • A release.yml/upstream sync may be needed since this PR originates from a fork.

Generated with Devin

Fixes pre-existing test-code lints that `cargo clippy --workspace
--all-targets -- -D warnings` reports on current stable: literal-bool
assert_eq, manual str::repeat, unwrap_or on literal Some/None,
get().is_some()/is_none() on maps, an unused cfg(test) helper, and one
intentional ENV_LOCK hold across .await (env-serialization in tests).
The tree has drifted from `cargo fmt --all -- --check` under current
stable rustfmt (no CI job enforces it). Mechanical `cargo fmt --all`
run plus one manual removal of a whitespace-only line in acp_mcp.rs
that tripped rustfmt's internal "left behind trailing whitespace"
check. No behavior changes.
…a mention (openabdev#1538)

With allow_user_messages = "mentions" (or multi-bot threads under
multibot-mentions), a message containing only @everyone/@here was
silently dropped: is_mentioned only consulted msg.mentions_user_id(),
and Discord mass pings populate mention_everyone instead of mentions[].
That made "summon all agents" impossible in multi-bot deployments.

New [discord] everyone_mentions_bot bool (default false — unchanged
behavior). When true, msg.mention_everyone counts as a mention anywhere
a direct @mention is checked: user-message gating, the trusted-bot
admission override, ambient-mode mention routing, and the bot-message
early gate.

The inline mention check is extracted into is_bot_mentioned() (same
primitive-parameter convention as detect_thread) and covered by
integration tests in crates/openab-core/tests/ — serenity Message
values cannot be constructed in unit tests.
Under heavy parallel load (e.g. full workspace `cargo test` on a busy
box), child spawn/wait can transiently fail with a non-timeout error
before the 1s timeout path is reached — the previous exact-message
assertion then flaked (observed in a detached replay run). Retry up to
3 attempts and require at least one to hit the timeout path; a real
regression that never reaches the timeout arm still fails.
@openab-app openab-app Bot added the closing-soon PR missing Discord Discussion URL — will auto-close in 24 hours. label Sep 30, 2026
@openab-app

openab-app Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Caution

This PR is missing a Discord Discussion URL in the body.
This PR will be automatically closed in 24 hours if the link is not added.

All PRs must reference a prior Discord discussion to ensure community alignment before implementation.

Please edit the PR description to include a link like:

Discord Discussion URL: https://discord.com/channels/...

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

🔒 Auto-closing: this PR has had the closing-soon label for more than 1 days without activity from the author.

If you'd like to continue working on this, please submit a new PR and link to this one if necessary.

@github-actions github-actions Bot closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closing-soon PR missing Discord Discussion URL — will auto-close in 24 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant