Skip to content

fix(mentions): match typed group mentions when the agent identity name is decorated - #115278

Merged
obviyus merged 38 commits into
openclaw:mainfrom
edenfunf:fix/mentions-decorated-identity-names
Aug 16, 2026
Merged

obviyus merged 38 commits into
openclaw:mainfrom
edenfunf:fix/mentions-decorated-identity-names

Conversation

@edenfunf

@edenfunf edenfunf commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #115276

What Problem This Solves

In requireMention groups, fallback mention patterns treated the full identity.name as one literal. A displayed name such as 小蝶🦋 therefore ignored the natural typed form 小蝶 with no reply or error. The shared fallback affects every channel that derives mention patterns from the resolved agent identity.

Root cause

The mention owner had no domain model for identity-bearing graphemes, optional decoration, and literal separators. Normalized matching also removes ZWJ/ZWNJ while raw stripping retains them, so one literal could not serve both paths safely.

The submitted decorated-name encoder then placed overlapping unbounded joiner/spacing repetitions at edge seams. Raw stripMentions rejection became quadratic: Bot followed by 32,768 ZWJs and a foreign word took 3.55 seconds on the submitted head.

QA Lab also collapsed scenario startup config into one merge patch. Later null deletions were lost before Gateway startup, so a scenario could not remove the lane's pinned mention pattern and exercise the identity-derived path.

Fix

  • Parse identity names by Unicode grapheme into three units: identity token, literal separator, or optional decoration.
  • Keep punctuation and required whitespace literal. Allow only the decoration actually present in the configured identity to be omitted or spaced.
  • Encode raw joiner runs as one exact optional spelling. No generic unbounded joiner repetition sits beside an edge-spacing repetition.
  • Use the same derived pattern for normalized mention matching and raw mention stripping.
  • Replay QA scenario Gateway patches in order. The resolved run context now carries a non-null plural gatewayConfigPatches array.

No configured-pattern, native-mention, or identity.emoji policy changes. The owner remains src/auto-reply/reply/mentions.ts; channels continue consuming the shared result.

Evidence

Head: 8569841f4b593670d8a0937ac6b092d997fa2a0b

  • Regression-first: adding only the adversarial stripping test to submitted head fa5ccda20a218f7952ae5bd4c180adb314b4bacc failed at 3552.07 ms against a 500 ms bound.
  • Repaired head benchmark, same rejected shape: 32,768 joiners in 0.289 ms after trailing decoration and 0.117 ms before leading decoration. Doubling input remains linear.
  • Focused tests from a fresh detached worktree: 214 passed — src/auto-reply/reply/mentions.test.ts (88) plus five affected QA Lab suites (126).
  • oxfmt and git diff --check: pass.
  • Targeted type-aware oxlint --deny-warnings across all 11 repair files: pass.
  • Production types: tsconfig.core.json, tsconfig.extensions.json: pass.
  • Test types: core src shards, tsconfig.extensions.test.json, tsconfig.test.root.json: pass.
  • Telegram userbot, exact head: a real QA user sent bare 小蝶 (message 48824) in a group with requireMention: true and agent identity 小蝶🦋. The provider request recorded was_mentioned: true, explicitly_mentioned_bot: false, and mention_source: "mention_pattern"; one mock-provider request crossed the Gateway boundary. The SUT returned OPENCLAW_E2E_OK as message 48825 after 3.087 seconds. Recorded evidence: events.ndjson, summary.json, gateway.log, and mock-openai-requests.ndjson.

The committed mock-Gateway scenarios remain the channel-boundary proof: channel-mention-decorated-identity gates unrelated text, then accepts bare 小蝶 for identity 小蝶🦋; channel-mention-separator-literal proves punctuation stays required. The prior public harness run passed both scenarios and is retained for reproducibility: run 31890054287, artifact 9248328353.

Review resolution

The reported emoji-only variation-selector bypass is fixed at the parser boundary: selector/keycap graphemes are decoration, never standalone identity tokens. Cross-emoji and cross-keycap match/strip negatives remain green. GitHub has no unresolved review threads.

Change surface

  • Production: +266/-29 (net +237), including the shared Unicode derivation and ordered QA startup-patch owner.
  • Tests: +681/-11 (net +670).
  • QA scenarios: +192/-0.

The production growth is the new shared capability, not a fallback path: one grapheme parser replaces the submitted code-point state machine, and callers use one ordered patch contract.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 10:55 AM ET / 14:55 UTC.

ClawSweeper review

What this changes

The PR makes shared identity-derived group mentions accept omitted decorative Unicode and adds QA scenarios for mention gating and literal separators.

Merge readiness

⚠️ Needs maintainer review before merge - 4 items remain

This PR remains necessary: current main still treats a decorated identity name as one literal mention pattern, so bare typed names are gated. The supplied exact-head Gateway proof is credible; the remaining blocker is an exact-current-head review after its behind-main refresh.

Priority: P1
Reviewed head: fa5ccda20a218f7952ae5bd4c180adb314b4bacc

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The proof is solid for the channel-flow contract, while the behind-main branch still needs a direct exact-head review.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body provides exact-head mock-Gateway evidence with a real ephemeral Gateway, mock transport, and observable after-fix group-gate outcomes.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body provides exact-head mock-Gateway evidence with a real ephemeral Gateway, mock transport, and observable after-fix group-gate outcomes.
Evidence reviewed 8 items Current-main defect: Main escapes the full identity name as one literal, so decoration remains mandatory and the requested bare-name form cannot match.
Owner boundary and caller: QA Channel sends the shared regex result into group mention facts, which controls the ingress dispatch decision.
Existing contract: Current documentation says identity name and emoji derive fallback patterns when no configured mention patterns exist.
Findings None None.
Security None None.

How this fits together

Group-message admission combines native mention facts with patterns derived from an agent identity before deciding whether to dispatch an agent turn. The changed fallback is shared by channel plugins, while QA Lab starts an ephemeral Gateway to exercise that dispatch-or-gate result.

flowchart LR
A[Group message] --> B[Mention admission]
B --> C[Native mention facts]
B --> D[Identity-derived pattern]
D --> E[Unicode boundary decision]
C --> F[Dispatch or intentional gate]
E --> F
Loading

Before merge

  • Resolve merge risk (P1) - Merging broadens shared name-derived triggers across group channels; a boundary mistake can create unsolicited replies or silently gate real mentions.
  • Resolve merge risk (P1) - The branch is behind current main, so its merge result and latest ClawSweeper rank-up moves need an exact-head refresh.
  • Resolve merge risk (P2) - Production code grows by 267 net lines for Unicode parsing and QA patch replay; the behavior needs to remain one canonical derivation rather than accumulate fallback variants.
  • Complete next step (P2) - The open contributor PR already owns the repair; the maintainer action is to obtain an exact-current-head review rather than create a competing fix PR.
Agent review details

Security

None.

PR surface

Source +267, Tests +664, Other +192. Total +1123 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 6 289 22 +267
Tests 4 672 8 +664
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 192 0 +192
Total 12 1153 30 +1123

Review metrics

Metric Value Why it matters
Production versus test delta production +289/-22; tests +672/-8; QA scenario support +192/-0 The fix adds a substantial shared Unicode parser and QA startup-patch behavior, so exact-current-head review matters before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #115276
Summary: This PR is the open candidate fix for the documented decorated-identity mention-gating defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Mantis proof suggestion

A redacted Telegram group transcript would independently demonstrate the visible typed-mention outcome on one affected channel. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram live proof: verify that a bare typed decorated agent name triggers one group reply while unrelated text remains gated.

Merge-risk options

Maintainer options:

  1. Rebase and refresh proof (recommended)
    Rebase onto current main, inspect the resulting shared mention behavior, and rerun the exact-head Gateway scenarios before merge.
  2. Pause for current-head review
    Keep the PR open until its latest diff, proof artifact, and ClawSweeper rank-up moves can be reviewed directly.

Technical review

Best possible solution:

Keep one shared identity-pattern derivation, preserve literal separators and false-positive boundaries, and rebase with refreshed exact-head Gateway proof before landing.

Do we have a high-confidence way to reproduce the issue?

Yes: current main literal-escapes the whole identity name, which source-proves that omitting embedded decoration cannot match.

Is this the best way to solve the issue?

Unclear: the shared derivation is the correct owner boundary and the supplied proof is targeted, but the full current branch and merge result were unavailable for direct inspection.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b365f7ec891f.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head mock-Gateway evidence with a real ephemeral Gateway, mock transport, and observable after-fix group-gate outcomes.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body provides exact-head mock-Gateway evidence with a real ephemeral Gateway, mock transport, and observable after-fix group-gate outcomes.
  • remove merge-risk: 🚨 automation: Current PR review merge-risk labels are merge-risk: 🚨 compatibility, merge-risk: 🚨 message-delivery.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Mention gating determines whether real group messages reach an agent, and missed matches produce silent no-reply behavior.
  • merge-risk: 🚨 compatibility: The shared fallback changes how existing identity names map to mention triggers.
  • merge-risk: 🚨 message-delivery: The changed pattern determines whether a group message is dispatched or intentionally gated.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body provides exact-head mock-Gateway evidence with a real ephemeral Gateway, mock transport, and observable after-fix group-gate outcomes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head mock-Gateway evidence with a real ephemeral Gateway, mock transport, and observable after-fix group-gate outcomes.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. Telegram group-message handling consumes the shared identity-derived fallback, and the dispatch-or-gate change is visible in a short chat transcript.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the available mention implementation snapshot to Peter Steinberger; shallow history limits stronger attribution. (role: recent area contributor; confidence: medium; commits: ee6556141033; files: src/auto-reply/reply/mentions.ts, extensions/qa-channel/src/inbound.ts)
  • dwc1997: Merged PR 89864 established the current Unicode-aware mention-boundary behavior that this PR extends. (role: prior Unicode mention contributor; confidence: medium; commits: 021d2526f061; files: src/auto-reply/reply/mentions.ts, src/auto-reply/reply/mentions.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and rerun the two Gateway scenarios on the new head.
  • Verify the latest ClawSweeper rank-up moves before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (43 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-12T07:01:21.413Z sha f9ef3df :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-12T07:21:13.676Z sha f9ef3df :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-12T08:07:20.240Z sha f9ef3df :: needs real behavior proof before merge. :: [P1] Reject a word before leading decoration
  • reviewed 2026-08-12T09:06:05.956Z sha 2fd6456 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-12T11:19:21.885Z sha 2fd6456 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-15T10:42:08.407Z sha 2fbde79 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-15T10:56:23.374Z sha 2fbde79 :: needs changes before merge. :: [P1] Keep keycap digits as foreign word characters
  • reviewed 2026-08-15T14:35:55.973Z sha fa5ccda :: needs real behavior proof before merge. :: none

@edenfunf
edenfunf force-pushed the fix/mentions-decorated-identity-names branch from 883b90a to e87cf3f Compare July 28, 2026 16:18
@edenfunf
edenfunf force-pushed the fix/mentions-decorated-identity-names branch from 6d74c35 to 206811a Compare July 29, 2026 03:44
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 29, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 31, 2026
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

There is an additional requireMention bypass beyond the edge-backtracking issue: an emoji-only identity such as ❤️ tokenizes variation selector U+FE0F as its sole word token, so unrelated ☀️ or ⚠️ also match and can trigger or strip commands; please add cross-emoji match/strip negatives and exclude standalone variation selectors from identity tokens.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. and removed P2 Normal backlog priority with limited blast radius. labels Aug 2, 2026
A derived name token has to carry an identity character. A run of bare
marks is presentation, not identity: the variation selector in an emoji
identity name, or an enclosing keycap, was derived as the only required
token, so any unrelated emoji carrying the same mark satisfied the
shared mention gate and was stripped from the message text.

Non-selector combining marks stay part of the token they attach to.
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. label Aug 11, 2026
A tag-sequence flag spells its region with U+E0020-U+E007F. Those tags are
invisible on their own and no character class here admitted them, so the gap
around them stayed a required separator and an identity ending in such a flag
rejected the bare name.

Keep the QA collector's id-keyed array composition too: merging two patch
documents replaced the array wholesale, so two scenarios patching the same
entry lost the earlier one's fields before the gateway started.
Composing every scenario patch into one merge-patch document cannot express
"delete this parent, then recreate part of it": a scenario's deletion merged
with a later scenario's object left the baseline siblings the first scenario
removed. Startup now replays the resolved patches in scenario order against
the real config, which is the semantics a scenario author writes, and the
document merger this PR added is gone with it.
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

A numeric keycap spells its base with an identity character, so the token
split absorbed the digit and the marks that follow, and the keycap never
reached the decoration classifier: "Bot1" typed against "Bot1️⃣" stayed
gated while "Bot#️⃣" already worked. The digit heading a keycap now stays
out of the token, and the boundary assertions stop reading it as the first
letter of a foreign word so the typed keycap still matches. A bare digit is
unchanged: "Bot1" keeps requiring its 1.
@edenfunf

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@edenfunf

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper-recovery-stuck rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 15, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Aug 15, 2026
@obviyus

obviyus commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Landing note for the latest hosted ClawSweeper Rank-up moves:

  • Rebase onto current main: skipped. The head is conflict-free and MERGEABLE; OpenClaw fast-lane policy treats BEHIND drift as advisory and rebases only for a conflict or material stale-base risk. Exact-head CI is green.
  • Verify the latest Rank-up moves: complete. Local ClawSweeper reviewed exact head 8569841f4b593670d8a0937ac6b092d997fa2a0b and passed with zero findings, security concerns, maintainer decisions, or Rank-up moves. The queued hosted publisher refresh is not a landing blocker under the same policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: qa-lab mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

3 participants