Skip to content

fix(qa-channel): preserve conversation kind for implicit actions - #137343

Merged
steipete merged 2 commits into
mainfrom
steipete/vigilant-hellman-255496
Sep 3, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/vigilant-hellman-255496

Conversation

@steipete

@steipete steipete commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #137339

Additional instructions

This same-repository branch remains writable by maintainers.

What Problem This Solves

Fixes an issue where QA-channel replies sent without an explicit destination could appear in a channel conversation instead of the original direct or group conversation, even though the conversation ID, account, text, and reply reference were correct. The same kind loss could make targetless resource actions select a same-ID message from the wrong conversation kind.

Why This Change Was Made

Preserve the conversation kind at QA's threading-context producer by encoding the native/root ID with the existing target builder. The default target remains an unthreaded root, while the full messaging target and thread metadata stay separate. This repairs the input consumed by the shared message-action flow without changing shared target precedence, parser defaults, or authorization.

Globally preferring the messaging target would break native-channel resource actions in transports such as Slack. Copying a threaded target into the default would also defeat explicit root opt-outs. The QA-owned producer is the narrow canonical repair.

Production LOC: +17/-16 (net +1). Consolidating duplicate kind selection makes executable code net -1; two invariant-comment lines explain why the root must remain unthreaded. Tests: +325/-11 (net +314). Documentation: +1.

Maintainer decision on ClawSweeper's remaining merge-risk item: retain the +1 net line. The two comment lines protect the root/thread opt-out invariant, while executable code shrinks. No additional guard, fallback, helper, or public surface is introduced; deleting the invariant explanation just to reduce the raw count would make the repair worse.

User Impact

Repo-local QA runs preserve direct/group/channel identity for implicit replies and keep same-ID foreign-kind messages outside the selected resource-action scope. Explicit destinations and root/thread opt-outs remain intact. The QA channel documentation records the behavior.

No public API, configuration option, schema, persistent representation, dependency, source-custody policy, or native execution-authority change. No claim that real Slack/Discord transports had this QA-specific defect. Pre-existing ordinary QA implicit-thread inheritance remains a separate follow-up.

Evidence

The final ten-case regression fixture fails five cases on the original producer and passes all ten with this repair. Failures are wrong-kind direct/group/source-only replies and incorrectly accepted same-ID foreign-kind reads; explicit DM and root/thread controls remain passing. The original producer was restored only for the negative control, then the identical repair patch was reapplied.

node scripts/run-vitest.mjs test/qa-channel-message-tool-delivery.test.ts

The regression uses actual QA HTTP ingress, account polling, session recording, shared message-tool/action dispatch, and HTTP bus readback. It reuses the real loaded plugin for bootstrap metadata instead of source-JIT loading a second copy; it does not mock target parsing, authorization, or delivery, and does not increase a timeout.

An additional 436 tests across nine focused files passed: QA action/threading contracts, shared normalization/threading, exact-current message-action security, capability expiry/revocation, message-tool source/account/hidden-text guards, agent-runner context, and Slack native/routable target behavior.

node scripts/check-changed.mjs -- docs/channels/qa-channel.md extensions/qa-channel/src/channel.ts extensions/qa-channel/src/channel.threading.test.ts test/qa-channel-message-tool-delivery.test.ts
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build qaRuntime

Changed checks, the private QA runtime build, and git diff --check passed. Fresh isolated Codex autoreview is scoped-clean at its configured P0 priority. Initial fixture placement/type/lint failures were fixed without changing guards, baselines, or tsconfig rules.

The first CI run caught one additional test import-boundary violation: the root fixture used QA Lab's bus-api.js rather than its accepted public api.js barrel. Both already export the same bus implementations. The test now uses api.js; the unchanged boundary guard and all ten delivery cases pass (20 tests total), as do root-test typecheck, targeted lint, and a fresh review of that correction. Production bytes and the real mock-Gateway proof below are unchanged.

node scripts/run-vitest.mjs test/extension-test-boundary.test.ts test/qa-channel-message-tool-delivery.test.ts

Real mock-Gateway behavior proof

An actual built Gateway, the real QA plugin/bus, and a loopback mock OpenAI-compatible provider processed three ordinary inbound turns. The provider saw the real message schema and called message with only action and message—no target or recipient. All three turns produced exactly one visible message with the exact nonce, account, conversation ID/kind, and inbound reply ID; no thread or attachments were introduced.

{
  "status": "pass",
  "proofKind": "real-built-gateway-with-loopback-mock-provider",
  "runtime": "openclaw",
  "buildBase": "01cf9f25bde3e5bc1f377109d6e6c8421e7f3228",
  "candidateQaSourceSha256": "a69a70426953eb94b316c1eaf3ab1a151f9e49d6a75d756984f6c463e0daf07c",
  "tool": "message",
  "argumentKeys": ["action", "message"],
  "cases": [
    {"inboundKind": "direct", "outboundKind": "direct", "visibleResults": 1, "status": "pass"},
    {"inboundKind": "group", "outboundKind": "group", "visibleResults": 1, "status": "pass"},
    {"inboundKind": "channel", "outboundKind": "channel", "visibleResults": 1, "status": "pass"}
  ],
  "account": "default",
  "dmScope": "per-channel-peer",
  "exactNonceAndReplyToId": true,
  "threadsOrAttachments": false,
  "sourceAndBuildCustodyUnchanged": true,
  "cleanup": "gateway, bus, provider stopped; owned ports closed; temporary runtime removed"
}

The build base plus unchanged candidate source/build digests bind this pre-commit run to the repair; this is not a fresh authenticated native Codex/provider run. The selected mock runtime did not expose final, so the provider did not fabricate that argument. Existing boundary coverage separately exercises final: true. The exact upstream Codex 0.152.1 JSON argument-forwarding source was personally inspected during attribution; no Codex-side change is proposed.

Proof used isolated synthetic home/state/workspace and non-default loopback ports, with live auth environment removed. Team, operator gateways/state, and real channel accounts were untouched. Original failures remain recorded as failures; the original observation's unrelated SQL instrumentation was not used as delivery proof.

Keep the QA current target kind-qualified at its context producer while
preserving native/root identity, separate thread metadata, shared target
precedence, and existing authority checks. This prevents targetless direct
and group replies from becoming channel sends and prevents same-ID
foreign-kind resource reads.

Cover the real QA ingress/message-tool/bus boundary, explicit targets,
source-only scope, and root/thread opt-outs. No public or persistent
contract changes.

Fixes #137339
@steipete steipete self-assigned this Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 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 labels Sep 3, 2026
@steipete
steipete marked this pull request as ready for review September 3, 2026 14:24
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Sep 3, 2026
@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 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 3, 2026, 11:45 AM ET / 15:45 UTC.

ClawSweeper review

What this changes

The PR preserves direct, group, and channel identity for targetless QA message actions and adds delivery, scope, and threading regression coverage.

Regression provenance

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

Merge readiness

✅ Ready for maintainer review

Keep this focused QA-channel repair open. Current main has not superseded its four changed paths, and the producer-bound fix preserves typed roots while retaining thread opt-outs; no blocking defect was found.

Priority: P2
Reviewed head: 6b768fbcd76d3ad9ffec0166a92778aad8aed6f8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary fix with credible built-runtime QA proof and no supported blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body supplies an after-fix built-Gateway QA-bus trace for targetless direct, group, and channel sends, with exact outbound-kind and reply-ID readback; the added boundary fixture covers resource-action scoping and thread opt-outs.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies an after-fix built-Gateway QA-bus trace for targetless direct, group, and channel sends, with exact outbound-kind and reply-ID readback; the added boundary fixture covers resource-action scoping and thread opt-outs.
Evidence reviewed 7 items Owner-bound repair: The changed QA threading producer parses the inbound target and emits an unthreaded, kind-qualified current root while retaining the complete messaging target and separate thread metadata.
Target contract: Canonical QA targets encode unthreaded direct/group/channel kinds; threaded direct and group targets are versioned while channel threads retain their canonical channel form, so the producer preserves the appropriate kind without embedding a thread in the implicit root.
Caller and shared consumer: Inbound QA context supplies the canonical reply target and native conversation ID; the shared runner delegates this context to the channel threading adapter before the message tool consumes the resulting current-channel identifier.
Findings None None.
Security None None.

How this fits together

The QA channel is OpenClaw’s synthetic HTTP transport for testing inbound messages and outbound delivery. Its threading context feeds the shared message tool, which selects a conversation before the QA bus records the action.

flowchart LR
  A[QA inbound message] --> B[Inbound context]
  B --> C[QA threading context]
  C --> D[Shared message tool]
  D --> E[QA action handler]
  E --> F[QA outbound bus]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +1, Tests +314, Docs +1. Total +316 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 17 16 +1
Tests 2 325 11 +314
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 343 27 +316

Review metrics

Metric Value Why it matters
Production vs test delta production +1 (executable −1), tests +314, docs +1 The sole production growth is the two-line root/thread invariant comment; the executable producer logic is net smaller.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137339
Summary: This PR is the concrete candidate repair for the linked QA implicit-target bug report.

Members:

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

Technical review

Best possible solution:

Merge the QA-owned typed-root repair once normal exact-head CI completion permits it, keeping shared target selection and native transport behavior unchanged.

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

Yes—high-confidence source reproduction is defined by the new QA ingress-to-bus fixture, and the supplied before/after evidence reports the pre-fix wrong-kind cases.

Is this the best way to solve the issue?

Yes—the QA threading-context producer owns the lost kind, while the shared message tool and Slack’s distinct native-target handling remain unchanged.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs bounded message-routing and resource-action scoping in the repository-local QA transport.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies an after-fix built-Gateway QA-bus trace for targetless direct, group, and channel sends, with exact outbound-kind and reply-ID readback; the added boundary fixture covers resource-action scoping and thread opt-outs.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies an after-fix built-Gateway QA-bus trace for targetless direct, group, and channel sends, with exact outbound-kind and reply-ID readback; the added boundary fixture covers resource-action scoping and thread opt-outs.

Evidence

What I checked:

  • Owner-bound repair: The changed QA threading producer parses the inbound target and emits an unthreaded, kind-qualified current root while retaining the complete messaging target and separate thread metadata. (extensions/qa-channel/src/channel.ts:245, 6b768fbcd76d)
  • Target contract: Canonical QA targets encode unthreaded direct/group/channel kinds; threaded direct and group targets are versioned while channel threads retain their canonical channel form, so the producer preserves the appropriate kind without embedding a thread in the implicit root. (src/plugin-sdk/qa-channel-protocol.ts:20, 6b768fbcd76d)
  • Caller and shared consumer: Inbound QA context supplies the canonical reply target and native conversation ID; the shared runner delegates this context to the channel threading adapter before the message tool consumes the resulting current-channel identifier. (extensions/qa-channel/src/inbound.ts:408, 6b768fbcd76d)
  • Boundary regression coverage: The new fixture sends targetless direct, group, and channel messages through QA ingress, shared message-tool dispatch, and HTTP-bus readback; it also checks foreign-kind resource actions and root/thread opt-outs. (test/qa-channel-message-tool-delivery.test.ts:174, 6b768fbcd76d)
  • Current-main check: The pinned PR base is an ancestor of fetched main, and no commits from that base through fetched main touch any of the four introduced paths; the raw comparison still shows the branch’s QA source, tests, and documentation changes. (aa78c175b966)
  • Feature-history routing: Earlier merged QA message-action work changed the QA channel, action handler, target protocol, and outbound paths, making its author a relevant review-routing candidate. (extensions/qa-channel/src/channel.ts:245, 2cc04c205f3d)

Likely related people:

  • Peter Steinberger: 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)

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 (1 earlier review cycle)
  • reviewed 2026-09-03T14:33:12.984Z sha 3a58ffd :: blocked before merge. :: none

Import the existing QA Lab public barrel so the real-bus regression obeys
the root test boundary. Keep the guard and production repair unchanged.
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Sep 3, 2026
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready verification for head 6b768fbcd76d3ad9ffec0166a92778aad8aed6f8:

  • CI run 33773544918 completed successfully: 88 passed, 16 skipped, zero failures, including build-artifacts and required openclaw/ci-gate. GitHub reports MERGEABLE/CLEAN.
  • The first run correctly caught a test import-boundary violation. The regression now uses QA Lab's existing public api.js barrel; neither the guard nor production code changed. The boundary suite and all ten QA delivery cases pass (20 tests), along with root-test typecheck, targeted lint, formatting, and fresh isolated Codex autoreview at configured P0 priority.
  • Retained real built-Gateway + QA HTTP bus + loopback mock-provider proof passes direct/group/channel targetless sends, with exactly one correctly kinded message, exact nonce/account/reply ID, and no thread/attachments. This is mock-provider Gateway proof, not a new authenticated native Codex run. The production source hash is unchanged by the CI-only correction.
  • Latest ClawSweeper review covers this head and lists no before-merge items. Maintainer decision: retain the two root/thread invariant comment lines; executable code shrinks by one line, and no extra guard/fallback/API is introduced.

Focused CI-repair command:

node scripts/run-vitest.mjs test/extension-test-boundary.test.ts test/qa-channel-message-tool-delivery.test.ts

Previously completed owner/sibling proof: 436 tests across QA/shared/Slack/authority surfaces; full changed checks; private QA runtime build. The original-producer negative control still records five expected failures against five passing controls. No public/persistent contract or authority change, and no operator Gateway/state was used. Ordinary implicit QA thread inheritance remains the separately scoped follow-up.

Proceeding through native review artifact validation, OPENCLAW_TESTBOX=1 scripts/pr prepare-run, and scripts/pr merge-run; no CI or review gate is bypassed.

@steipete
steipete merged commit 8e78378 into main Sep 3, 2026
154 of 156 checks passed
@steipete
steipete deleted the steipete/vigilant-hellman-255496 branch September 3, 2026 15:59
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 3, 2026
* refs/remotes/origin/main:
  fix(plugins): reject unverifiable pinned npm installs (#136725)
  improve(ui): lift sidebar section headers on hover and mark online owners (#136985)
  test(cron): reuse isolated run suite hooks (#137341)
  test(channels): reuse shared indexed call guards (#137350)
  fix(ui): sidebar header controls read misaligned after the + button lost its border (#137317)
  fix(qa-channel): preserve conversation kind for implicit actions (#137343)
  fix: target the source checkout in Control UI repair commands (#137354)
  chore: reduce CI job count and database test overhead (#137352)
  fix(ios): preserve chat live edge across keyboard transitions (#136660)
  refactor(control-ui): consolidate mention inbox requests (#137375)
  fix(openai): preserve ChatGPT HTTP status for retry pacing (#137146)
  fix(mcp): hide policy-denied plugin tools from ACP sessions [AI] (#136546)
  test(queue): reuse shared deferred fixtures (#137338)
  fix(gateway): repair the Gateway E2E shard (browser suite project, skill resource argv, Codex diagnostic) (#137358)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…nclaw#137343)

* fix(qa-channel): preserve conversation kind for implicit actions

Keep the QA current target kind-qualified at its context producer while
preserving native/root identity, separate thread metadata, shared target
precedence, and existing authority checks. This prevents targetless direct
and group replies from becoming channel sends and prevents same-ID
foreign-kind resource reads.

Cover the real QA ingress/message-tool/bus boundary, explicit targets,
source-only scope, and root/thread opt-outs. No public or persistent
contract changes.

Fixes openclaw#137339

* test(qa-channel): use public QA Lab API for delivery proof

Import the existing QA Lab public barrel so the real-bus regression obeys
the root test boundary. Keep the guard and production repair unchanged.
steipete added a commit that referenced this pull request Sep 4, 2026
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.
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: 🐚 platinum hermit Good normal PR readiness with ordinary 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 implicit message targets lose conversation kind

1 participant