block / block/buzz

workflow_sink's @-mention parser is a third divergent implementation — workflow-emitted **@Name** emits zero p tags

Open
#2,686 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
32.7k
Forks
4.3k
Avg merge
1d 13h
Merged PRs (30d)
253

Description

Split out of #2526 — noted by @SeanGearin while reviewing #2547.

## Problem

#2526 identified two divergent @-mention parsers (Rust `buzz-sdk/src/mentions.rs` and TS `desktop/src/features/messages/lib/hasMention.ts`). There is a **third**: `resolve_mention_pubkeys` in `crates/buzz-relay/src/workflow_sink.rs`, whose doc comment says it "defines the matching contract" for workflow-emitted kind:9 `p` tags.

Its left-boundary check accepts only start-of-string, whitespace, or `(`:

```rust
let is_left_boundary = |i: usize| i == 0 || chars[i - 1].is_whitespace() || chars[i - 1] == '(';
```

So a workflow-generated `**@Robby**` emits zero `p` tags. Those `p` tags gate ACP agent wake (`event_mentions_agent`, `crates/buzz-acp/src/lib.rs`), which reproduces the exact stalled-handoff failure mode from #2526 on a surface where the text is machine-generated — an agent or template emitting emphasis around a mention is not a user typo, it's routine markdown.

The right side of this parser is already emphasis-tolerant (it rejects only name-continuation chars, `alphanumeric | _`), so only the left boundary needs widening. Note the `_` wrinkle: a trailing `_` after a name is a name-continuation char here, so `_@robby_` has a second, smaller divergence too.

## Suggested direction

After #2547 lands, `buzz-sdk::mentions::is_mention_lead` is the shared definition of "what may precede an `@`" (whitespace, `(`, `*`, `_`, `|`, start). `buzz-relay` already depends on `buzz-sdk`, so `workflow_sink.rs` can call it directly instead of keeping a private boundary rule — that would take the parser count needing manual sync from three to two.

Longer term (already noted in #2526): the Rust and TS implementations should be one contract with shared test vectors, or this class of drift recurs.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.