clawsweeper icon indicating copy to clipboard operation
clawsweeper copied to clipboard

Fast ack can queue inline @clawsweeper mentions that the router cannot parse

Open brokemac79 opened this issue 6 months ago • 3 comments

Summary

A GitHub issue comment can receive the ClawSweeper fast-ack response even when the command router later cannot parse the comment as a command. This leaves a stale bot comment saying the command was queued, but no review/action run is started and the ack comment is never updated.

This is confusing for maintainers/trial maintainers because it looks like a permissions problem or a missing Actions run, when the actual issue is a parser mismatch.

Example

On openclaw/openclaw#87801, this comment was posted by brokemac79:

the closed PR 87835 was closed as already implemented by PR 87890 @clawsweeper re-review and if necessary close this issue

ClawSweeper replied:

ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

But the matching repair comment router run did not see a routable command:

  • source comment: 4583610644
  • status/ack comment: 4583610747
  • router run: https://github.com/openclaw/clawsweeper/actions/runs/26690832809
  • router args included --item-numbers 87801 --comment-ids 4583610644 --status-comment-id 4583610747 --execute
  • report showed scanned_comments: 1, commands_seen: 0, actionable: 0

Likely cause

The fast-ack/webhook side uses a loose pattern that detects @clawsweeper anywhere after whitespace:

/(^|[ \t\r\n])@(?:clawsweeper|openclaw-clawsweeper)\b.../

The actual router parser is stricter. parseCommand() only accepts commands where the line itself is a command, for example:

@clawsweeper re-review

or:

/clawsweeper re-review

It does not parse prose with an inline mention in the middle of the sentence.

That means the webhook can fast-ack a comment that the router will later ignore.

Expected behavior

Either of these would be OK, but the two layers should agree:

  1. The fast-ack path should only ack comments that the router parser will accept, or
  2. The router parser should support the same inline command shape that the fast-ack path accepts.

Given the risk of accidental inline mentions, option 1 seems safer: require command-like comments or command-like lines before posting the “queued” ack.

Suggested fix

  • In src/repair/comment-webhook.ts, reject issue comments when parseCommand(body) returns null, even if COMMAND_PATTERN matched.
  • In dashboard/worker.ts, align the Cloudflare/dashboard fast-ack command detection with the router grammar as well, or factor the shared command-line detection so it cannot drift.
  • Add tests for:
    • @clawsweeper re-review on its own line gets fast-acked and routed.
    • prose with inline @clawsweeper re-review does not get a queued ack unless the router will also route it.
    • a fast-ack comment is not left permanently saying “queued” for a non-routable command.

Workaround

Use a command on its own line, for example:

The closed PR 87835 was closed as already implemented by PR 87890.

@clawsweeper re-review

Any extra instruction/context should be placed after the command on following lines if the command supports it.

Non-goals

This should not change repair, merge, or close permissions. It is only about making the fast-ack layer and command-router layer agree on what is actually routable.

brokemac79 avatar May 30 '26 18:05 brokemac79

I can pick this up and put together a small fix PR for it.

Plan is to keep it narrow: make the fast-ack path and command-router parser agree on what counts as a routable command, with tests covering the inline-mention false positive and the valid own-line command shape.

brokemac79 avatar May 30 '26 18:05 brokemac79

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed May 30, 2026, 2:14 PM ET / 18:14 UTC.

Summary Keep this issue open: current main still has a source-visible fast-ack/router mismatch, because the fast-ack gates can match inline prose mentions while the router parser only accepts command-shaped lines.

Reproducibility: yes. from current source inspection: the reported inline prose body matches the fast-ack regex but not the router's whole-line command grammar. I did not run the live webhook server, so this is source-reproducible rather than a full live reproduction.

Next step Queue a focused repair because current main still accepts non-routable inline mentions in fast-ack paths, and the affected files and tests are clear.

Review details

Best possible solution:

Use one parser-safe command predicate, or equivalent shared logic, so every fast-ack path only posts a queued ack for comments the repair router will actually parse.

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

Yes from current source inspection: the reported inline prose body matches the fast-ack regex but not the router's whole-line command grammar. I did not run the live webhook server, so this is source-reproducible rather than a full live reproduction.

Is this the best way to solve the issue?

Yes; rejecting null parseCommand() results before posting a queued ack is the narrowest fix and avoids broadening inline command support accidentally.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • The hosted dashboard worker duplicates command detection separately from comment-webhook.ts; fixing only one path would leave a second fast-ack surface with the same false-positive behavior.

Codex review notes: model gpt-5.5, reasoning high; reviewed against e9cd92cdd73e.

Label changes

Label changes:

  • add P2: This is a bounded automation bug that misleads maintainers and can drop an expected routed command without breaking the core runtime.
  • add impact:message-loss: The issue is about an acknowledged GitHub command comment not being routed into the command workflow.
  • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
  • add clawsweeper:source-repro: Current issue advisory state selects this label.
  • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
  • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

Label justifications:

  • P2: This is a bounded automation bug that misleads maintainers and can drop an expected routed command without breaking the core runtime.
  • impact:message-loss: The issue is about an acknowledged GitHub command comment not being routed into the command workflow.
Evidence reviewed

Acceptance criteria:

  • pnpm run test:unit
  • pnpm run check

What I checked:

  • Router grammar requires command-shaped lines: parseCommand() scans line by line and only matches slash or mention commands when the line itself satisfies the command regex, so inline prose with a middle-of-sentence mention is not routable. (src/repair/comment-router-core.ts:1025, e9cd92cdd73e)
  • Standalone webhook still accepts loose mentions: COMMAND_PATTERN accepts @clawsweeper after whitespace anywhere in the body, and the computed parsedCommand is not used to reject a null parse for OWNER/MEMBER/COLLABORATOR comments before the queued ack path. (src/repair/comment-webhook.ts:11, e9cd92cdd73e)
  • Hosted dashboard webhook has the same loose gate: The Cloudflare dashboard worker uses CLAWSWEEPER_COMMAND_PATTERN before fast ack and does not call the router parser in classifyGithubIssueCommentWebhook. (dashboard/worker.ts:26, e9cd92cdd73e)
  • Current source reproduces the mismatch shape: A local read-only regex check against the reported inline prose body returned { fastAck: true, routerParseShape: false }, matching the issue report's failure mode. (e9cd92cdd73e)
  • History ties the current fast-ack/parser surface to recent repair work: Blame shows the loose fast-ack patterns and parser were introduced in 68065f81, while 9b0b0b39 added the current parsedCommand use in the webhook without making it a null-parse gate. (src/repair/comment-webhook.ts:177, 9b0b0b391733)
  • No VISION.md was present: A repository VISION.md fit pass could not use a target VISION.md because none was found in the checkout. (e9cd92cdd73e)

Likely related people:

  • brokemac79: Blame shows 68065f81 introduced the current fast-ack regexes, dashboard worker gate, and router parser surface; later commits also changed nearby command parsing and fast-ack convergence tests. (role: introduced behavior and recent area contributor; confidence: high; commits: 68065f816acf, 485f71abc664, 556268dff3d9; files: src/repair/comment-webhook.ts, dashboard/worker.ts, src/repair/comment-router-core.ts)
  • Tak Hoffman: Recent commits changed the repair command parser/webhook path, including adding parsedCommand use in the webhook for stale closed PR command handling. (role: recent repair-command contributor; confidence: medium; commits: 9b0b0b391733, c0146987, 8db024ba; files: src/repair/comment-webhook.ts, src/repair/comment-router-core.ts, test/repair/comment-webhook.test.ts)
  • Dallin Romney: Recent dashboard worker commits touched the hosted workflow/repair intake surface that would need to stay aligned with the standalone webhook fix. (role: adjacent dashboard worker contributor; confidence: medium; commits: 50ca51d8, 87e6a26e, 2c19284d; files: dashboard/worker.ts, test/dashboard-worker.test.ts)
How this review workflow works
  • 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.

clawsweeper[bot] avatar May 30 '26 18:05 clawsweeper[bot]

I’ll include the remaining risk from ClawSweeper’s review in the fix rather than leaving it as a follow-up.

So the PR will cover both fast-ack surfaces:

  • src/repair/comment-webhook.ts
  • dashboard/worker.ts

The intent is: no queued fast-ack unless the same comment is actually routable by the command parser.

brokemac79 avatar May 30 '26 18:05 brokemac79