Skip to content

fix(qa-channel): keep implicit messages in their source thread - #137964

Merged
steipete merged 1 commit into
mainfrom
steipete/reverent-chandrasekhar-48272d
Sep 4, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/reverent-chandrasekhar-48272d

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #137929 (QA message-tool replies leave the current thread).
Related: #137343 (QA implicit conversation-kind preservation).

What Problem This Solves

Fixes an issue where QA-channel replies sent through the message tool leave the source thread when the tool omits its target and thread. Direct, group, and channel conversations retain their kind and account but incorrectly receive a root-level message.

Why This Change Was Made

QA already publishes the current thread, but did not implement the existing automatic-thread hook consumed by the shared action runner. The plugin now uses one native-first target matcher for both thread and reply scope, replacing the old dual-root matcher. Typed root identity remains separate from the full messaging target and thread metadata; global implicit target selection and Slack native resource IDs are unchanged.

User Impact

Implicit sends and sends to the same explicit root stay in the current QA thread. Explicit thread targets, thread fields, and reply IDs remain authoritative. topLevel: true and threadId: null suppress implicit thread and reply inheritance. Foreign providers, conversation kinds/roots/threads, and accounts do not inherit source authority; bare message-action targets keep their existing channel meaning.

This is a repair to the source-only synthetic QA plugin, with no new configuration, persistence, or public API contract.

Evidence

Before production edits, the desired-behavior HTTP regressions failed in six threaded cases while seven existing controls passed: the received thread was absent instead of topic. The owner-level hook reproduction also failed. Original introduction is unknown; this defect was kept separate from the already-landed conversation-kind repair.

The approved patch passed 143 focused tests on base cd8c74889d21ddcc9f3a2d47fe868224a0e44acb: 23 HTTP/native message-tool tests, 91 QA plugin tests, 21 shared threading tests, six Slack tests, and two Telegram tests. This includes the 63-send thread/opt-out matrix plus direct/group/channel × root/thread × default/secondary resource ownership checks for read/react/edit, legacy target aliases, and immutable foreign message rejection.

node scripts/run-vitest.mjs test/qa-channel-message-tool-delivery.test.ts extensions/qa-channel src/infra/outbound/message-action-runner.threading.test.ts extensions/slack/src/action-threading.test.ts extensions/telegram/src/action-threading.test.ts --reporter=verbose
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build qaRuntime
node scripts/check-changed.mjs -- docs/channels/qa-channel.md extensions/qa-channel/src/channel.threading.test.ts extensions/qa-channel/src/channel.ts test/qa-channel-message-tool-delivery.test.ts

The exact patch passed fresh independent autoreview at the configured P0 threshold with no findings; that review did not execute tests. Rebase preserved the approved patch bytes. Production LOC: +31/-22 (net +9); tests: +328/-43 (net +285); docs: +1. The small production growth supplies the missing typed hook and provider/target scope while sharing the matcher and deleting the old dual-root path.

Earlier local diagnostic attempts included an overbroad mixed test selection that stalled in collection and was interrupted, and corrected test-oracle/lint mistakes. They are not passing evidence and were not CI failures; the focused 143-test run above is the completed result.

The private QA build passed on f742aed9178da6b631f2c25773dcdddff44560a5. A real isolated loopback Gateway with mock-openai passed the stock group-visible-reply-tool scenario and the existing programmatic round-trip probe for each threaded conversation kind. The mock supplied only action and message. The parent driver and each child had separate synthetic state; all suite/lab cleanup completed. No live provider or external channel was contacted.

node --import ./scripts/tsx.mjs scripts/lib/openclaw-test-state.mts shell --label qa-thread-gateway --scenario minimal
node .artifacts/qa-thread-inheritance/real-gateway-proof.mjs

The generated shell setup was redirected to a private task file and sourced only inside a disposable env -i subshell before invoking the driver. The ignored driver used the public built dist/extensions/qa-lab/api.js exports. Its fixture explicitly adds message through existing tools.alsoAllow, because the QA coding profile otherwise omits it for direct turns. The first rig attempt passed the stock group scenario but failed that direct probe without the tool; it is retained as failed evidence.

Sanitized observed placement verdict:

{
  "verdict": "PASS",
  "sourceHead": "f742aed9178da6b631f2c25773dcdddff44560a5",
  "provider": "mock-openai",
  "suppliedToolArguments": [
    "action",
    "message"
  ],
  "observations": [
    {
      "kind": "direct",
      "conversationId": "qa-implicit-direct",
      "accountId": "default",
      "threadId": "qa-topic-direct",
      "replyMatchesInbound": true,
      "outboundCount": 1,
      "verdict": "PASS"
    },
    {
      "kind": "group",
      "conversationId": "qa-implicit-group",
      "accountId": "default",
      "threadId": "qa-topic-group",
      "replyMatchesInbound": true,
      "outboundCount": 1,
      "verdict": "PASS"
    },
    {
      "kind": "channel",
      "conversationId": "qa-implicit-channel",
      "accountId": "default",
      "threadId": "qa-topic-channel",
      "replyMatchesInbound": true,
      "outboundCount": 1,
      "verdict": "PASS"
    }
  ]
}

Root/null opt-outs, explicit-target precedence, secondary-account rejection, and resource ownership are covered by the source/HTTP integration tests; the stock mock does not emit those controls. The focused tests used the approved patch before rebase; affected QA and shared threading sources were unchanged by the rebase. The final four-file changed gate passed on f742aed, including all selected formatting, typecheck, lint, boundary, dead-export, import-cycle checks and five doctor-contract tests.

Maintainer disposition of the latest ClawSweeper review: accept the net +9 production lines in the approved patch. The existing typed automatic-thread hook is the missing capability; sharing its native-first matcher with reply scoping removes the old dual-root path. Further shrinking by moving the policy into core or dropping provider/kind/root/thread checks would weaken the owner boundary. ClawSweeper found no actionable correctness or security defect and identifies this same QA-local implementation as the best solution. This resolves its sole “Before merge” risk item; no additional rank-up moves were listed.

Exact-head pull-request CI passed: run 33843013729, head f742aed9178da6b631f2c25773dcdddff44560a5. The repository CI watcher completed GREEN.

Reuse the QA native target matcher for automatic thread and reply scope. Preserve explicit targets, account boundaries, top-level opt-outs, and the shared selector behavior.

Closes #137929. Related: #137343.
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: qa-channel Channel integration: qa-channel extensions: qa-lab size: M maintainer Maintainer-authored PR labels Sep 4, 2026
@steipete
steipete marked this pull request as ready for review September 4, 2026 06:06
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 2:16 AM ET / 06:16 UTC.

ClawSweeper review

What this changes

The PR makes implicit QA-channel message-tool sends inherit the inbound thread when sent to the same source conversation, while retaining explicit-thread and top-level opt-out behavior.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this maintainer-authored, maintainer-labeled PR open for normal landing review. The QA-local hook repairs a current gap without an introduced correctness or security defect.

Priority: P2
Reviewed head: f742aed9178da6b631f2c25773dcdddff44560a5

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-local repair with extensive boundary coverage and directly relevant after-fix Gateway/QA-bus evidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The changed owner is the QA threading adapter, exercised through an isolated built Gateway and real QA bus with a loopback provider; the source-head-bound trace records correct thread and reply placement for direct, group, and channel inbound conversations.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed owner is the QA threading adapter, exercised through an isolated built Gateway and real QA bus with a loopback provider; the source-head-bound trace records correct thread and reply placement for direct, group, and channel inbound conversations.
Evidence reviewed 7 items Changed QA owner: The new native-first matcher and automatic-thread hook only apply the inbound thread to matching QA conversation targets, while rejecting explicit thread targets from implicit inheritance.
Shared caller and invariant: The shared send path resolves implicit reply metadata, then invokes the channel threading adapter; its helper already suppresses automatic inheritance for topLevel and threadId:null and preserves explicit thread IDs.
Behavior-boundary coverage: The integration matrix uses actual QA HTTP ingress, the shared message tool, and QA bus readback for direct, group, and channel threads, including explicit targets, opt-outs, accounts, and foreign resource rejection.
Findings None None.
Security None None.

How this fits together

QA Channel is OpenClaw’s synthetic HTTP-backed chat transport for deterministic QA. Inbound thread metadata flows through the shared message tool into outbound QA bus messages and scoped resource actions.

flowchart LR
  A[Inbound QA message] --> B[QA threading context]
  B --> C[Shared message tool]
  C --> D[QA target and thread matching]
  D --> E[Outbound QA bus message]
  C --> F[Scoped resource actions]
Loading

Before merge

  • Resolve merge risk (P1) - Production code is net +9 lines in a bug fix; the added typed hook is justified because one native-first matcher now serves both existing reply scoping and thread inheritance, replacing the old dual-root matcher.
Agent review details

Security

None.

PR surface

Source +9, Tests +285, Docs +1. Total +295 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 31 22 +9
Tests 2 328 43 +285
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 360 65 +295

Review metrics

Metric Value Why it matters
Production vs test delta production +31/-22 (net +9); tests +328/-43 (net +285); docs +1 The small production increase supplies the missing QA threading hook while consolidating the prior matcher; the larger test change exercises the delivery and authorization boundary.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137929
Summary: This PR is the focused candidate fix for the open QA wrong-thread delivery report; the prior conversation-kind repair is adjacent but distinct.

Members:

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the QA-local native-first matcher and automatic-thread hook, with the existing boundary tests, so shared message-action policy stays unchanged and source-thread inheritance is owned by the QA plugin.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the QA-local native-first matcher and automatic-thread hook, with the existing boundary tests, so shared message-action policy stays unchanged and source-thread inheritance is owned by the QA plugin.

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

Yes. Current main retains the same pre-fix QA threading owner, and the supplied focused QA HTTP-bus scenario directly exercises the missing hook; it was not re-executed here because this review checkout is read-only.

Is this the best way to solve the issue?

Yes. The patch fills the existing channel threading seam in the QA owner and reuses one matcher for reply scope and automatic thread inheritance, avoiding a shared-policy change.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This fixes incorrect thread placement in the repository’s synthetic QA channel, with bounded impact and no evidence of an outage in shipped transports.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed owner is the QA threading adapter, exercised through an isolated built Gateway and real QA bus with a loopback provider; the source-head-bound trace records correct thread and reply placement for direct, group, and channel inbound conversations.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed owner is the QA threading adapter, exercised through an isolated built Gateway and real QA bus with a loopback provider; the source-head-bound trace records correct thread and reply placement for direct, group, and channel inbound conversations.

Label justifications:

  • P2: This fixes incorrect thread placement in the repository’s synthetic QA channel, with bounded impact and no evidence of an outage in shipped transports.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed owner is the QA threading adapter, exercised through an isolated built Gateway and real QA bus with a loopback provider; the source-head-bound trace records correct thread and reply placement for direct, group, and channel inbound conversations.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed owner is the QA threading adapter, exercised through an isolated built Gateway and real QA bus with a loopback provider; the source-head-bound trace records correct thread and reply placement for direct, group, and channel inbound conversations.

Evidence

What I checked:

  • Changed QA owner: The new native-first matcher and automatic-thread hook only apply the inbound thread to matching QA conversation targets, while rejecting explicit thread targets from implicit inheritance. (extensions/qa-channel/src/channel.ts:148, f742aed9178d)
  • Shared caller and invariant: The shared send path resolves implicit reply metadata, then invokes the channel threading adapter; its helper already suppresses automatic inheritance for topLevel and threadId:null and preserves explicit thread IDs. (src/infra/outbound/message-action-threading.ts:21, f742aed9178d)
  • Behavior-boundary coverage: The integration matrix uses actual QA HTTP ingress, the shared message tool, and QA bus readback for direct, group, and channel threads, including explicit targets, opt-outs, accounts, and foreign resource rejection. (test/qa-channel-message-tool-delivery.test.ts:340, f742aed9178d)
  • Current main remains unfixed: Fetched main retains the old QA threading registration with no resolveAutoThreadId hook, so the central repair is not already implemented. (extensions/qa-channel/src/channel.ts:222, ec87f919535c)
  • Sibling threading contracts: Slack and Telegram have analogous channel-local automatic-thread adapters; QA’s distinct target grammar supports keeping this repair in the QA plugin rather than altering shared policy. (extensions/slack/src/channel.ts:866, f742aed9178d)
  • History and introduced ownership: The head commit has the verified merge-base as its sole parent, and its parent-relative diff introduces the matcher and hook. Prior merged QA conversation-kind work remains a separate, already-landed repair. (extensions/qa-channel/src/channel.ts:148, f742aed9178d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Avant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • chelsealong: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for f742aed9178da6b631f2c25773dcdddff44560a5: the approved patch is unchanged, the private QA build and final changed-file gate passed, and exact-head CI 33843013729 succeeded (native watcher: GREEN).

Commands run:

node scripts/run-vitest.mjs test/qa-channel-message-tool-delivery.test.ts extensions/qa-channel src/infra/outbound/message-action-runner.threading.test.ts extensions/slack/src/action-threading.test.ts extensions/telegram/src/action-threading.test.ts --reporter=verbose
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build qaRuntime
node .artifacts/qa-thread-inheritance/real-gateway-proof.mjs
node scripts/check-changed.mjs -- docs/channels/qa-channel.md extensions/qa-channel/src/channel.threading.test.ts extensions/qa-channel/src/channel.ts test/qa-channel-message-tool-delivery.test.ts
node scripts/watch-pr-ci.mjs 137964 f742aed9178da6b631f2c25773dcdddff44560a5

Focused tests: 143 passed on the approved pre-rebase patch; affected QA/shared threading source stayed identical through rebase. Build, Gateway, and changed gate used the linked head. The isolated real Gateway + mock-openai + QA HTTP bus passed direct/group/channel threaded sources: exact account/kind/root/thread/reply and one visible outbound each, with only action and message supplied by the mock. Cleanup completed. Root/null and account controls remain covered by source/HTTP tests; no external-channel proof is claimed. The initial driver profile omission was corrected only in ignored fixture configuration before the passing run.

Latest ClawSweeper review: no correctness/security findings; proof sufficient. Its sole production-LOC risk is accepted under the exact-patch landing approval: net +9 supplies the existing typed hook while reusing the native-first matcher and removing duplicate matching. The PR body records this disposition; no other rank-up moves or inline threads remain. Native review artifacts validated with zero findings. Proceeding through native prepare/merge and server enforcement.

@steipete
steipete merged commit fae213c into main Sep 4, 2026
225 checks passed
@steipete
steipete deleted the steipete/reverent-chandrasekhar-48272d branch September 4, 2026 06:26
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…law#137964)

Reuse the QA native target matcher for automatic thread and reply scope. Preserve explicit targets, account boundaries, top-level opt-outs, and the shared selector behavior.

Closes openclaw#137929. Related: openclaw#137343.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: qa-channel Channel integration: qa-channel docs Improvements or additions to documentation extensions: qa-lab maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: QA message-tool replies leave the current thread

1 participant