Conversation
…ment resolve_mention_pubkeys in workflow_sink.rs scanned raw workflow text for @name mentions, so a mention inside an inline code span or fenced block became a real p tag and gated ACP agent wake. Workflow text is machine-rendered markdown and agents emit code constantly - a name inside a code region is documentation, not an address. The CLI compose path already masks code regions before mention extraction (buzz-cli messages.rs); this gives the relay workflow sink the same treatment by running buzz_sdk::mentions::strip_code_regions over the text before scanning, reusing the shared SDK helper instead of a relay-local mask. strip_code_regions is not length-preserving, so the scan operates on the masked copy; positions never map back to the original string (only pubkeys, in first-appearance order, escape) and the comment in resolve_mention_pubkeys pins that invariant for future refactors. Fixes block#7660 Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
🔐 Codex Security Review
|
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.
A workflow that renders an agent's name inside a code block or inline code span still woke that agent. Workflow text is machine-generated markdown, and agents emit code constantly — a code sample naming a colleague is documentation, not an address.
What happens
resolve_mention_pubkeysincrates/buzz-relay/src/workflow_sink.rsscanned the raw workflow text for@namematches, with no awareness of code regions. A mention inside an inline code span or fenced block therefore produced a realptag on the emitted kind 9 message, and thoseptags gate ACP agent wake (event_mentions_agent), so the agent was pinged for something it was only mentioned in as example code.The CLI compose path already strips code regions before extracting
@namementions (crates/buzz-cli/src/commands/messages.rs, viabuzz_sdk::mentions::strip_code_regions). The relay workflow sink never got the equivalent.The change
Mask code regions with the existing
buzz_sdk::mentions::strip_code_regionsbefore scanning, on both the rendered output and the owner's authored template. The helper is already public in the SDK andbuzz-relayalready depends onbuzz-sdk, so this adds no new dependency and no second masking implementation to keep in step.One invariant worth calling out:
strip_code_regionsis not length-preserving, so nothing downstream may map positions from the masked copy back onto the original text.resolve_mention_pubkeysis safe today because only pubkeys (in first-appearance order) escape the function, and the code comment now pins that invariant for future refactors.Tests
Four new cases in the
workflow_sinktest module:seeping @robbyfor syntax— inline code span mention wakes no oneping @Robby— wakes no one`code` then @Robby please— masking must not swallow surrounding prose; the prose mention still wakesstrip_code_regions; that behavior is pinned so a future SDK change that masks it is a visible decisionVerification
cargo test -p buzz-relayon this branch: all 25workflow_sinktests pass (21 prior, 4 new). The full package suite runs 1144 tests with 6 pre-existingapi::mediafailures that require a live Postgres pool (Sqlx(PoolTimedOut)); verified identical on pristinemainat213092074with the fix stashed, so they are unrelated to this change.cargo clippy -p buzz-relay --all-targetsandcargo fmt -- --checkare clean.Fixes #7660