Skip to content

fix(cli): preserve structured core send failures - #129728

Merged
obviyus merged 1 commit into
openclaw:mainfrom
Leon-SK668:leon/cli-core-send-failure-outcome-20260826
Aug 28, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
Leon-SK668:leon/cli-core-send-failure-outcome-20260826

Conversation

@Leon-SK668

@Leon-SK668 Leon-SK668 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Follow-up to #129202.

The CLI lost durable failed and partial_failed core-send results because the sender threw before JSON formatting could read them. Operators saw only a generic error and lost the delivery status, partial-send marker, and successful message ID.

Why This Change Was Made

The durable sender remains the terminal outcome owner. It returns structured terminal failures only when the explicit caller identity is the CLI. Non-CLI callers keep the existing throwing contract. Queue, retry, recovery, batch-stop, and best-effort policies do not change.

User Impact

openclaw message send --json now exits 1 and returns the structured delivery failure. A partial send also reports sentBeforeError: true and the successful message ID.

Evidence

  • Exact current-main RED (8d51e415d6a): a real Discord CLI send with a synthetic invalid token reached Discord and received 401. The CLI exited 1 without structured JSON.
  • Exact current-main RED (8d51e415d6a): a real Discord CLI media send posted its randomized caption, then rejected a blocked video URL. The CLI exited 1 without partial_failed, sentBeforeError, or the successful message ID.
  • Patch-identical live GREEN (456838db637), retained for final head 64e00b7f1fa: the same cases exited 1 with structured failed and partial_failed JSON. The partial result included sentBeforeError: true and the successful message ID.
  • Anti-cheat and cleanup: the partial case found the randomized caption through Discord after the media failure and deleted it after each run.
  • Regression proof: the two new CLI cases fail on current main and pass on the repaired head. The non-CLI throw case passes on both.
  • Focused validation: 88 owner/caller tests and 121 queue, retry, recovery, and sibling-policy tests passed. Formatting, focused lint, production type-check, build, and diff checks passed.
  • Exact-head gates: CI run 33153895617 passed after one infrastructure-only package-boundary timeout retry. Local ClawSweeper passed on 64e00b7f1fa with no findings, security concerns, maintainer decisions, or rank-up moves.
  • Production delta: +4/-1. The repair uses the existing explicit CLI identity at the durable-result owner and removes the incoming cross-layer policy flag.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 3:01 AM ET / 07:01 UTC.

ClawSweeper review

What this changes

The PR preserves failed and partially failed core message-delivery outcomes for CLI text and JSON presentation while retaining throws for non-CLI callers.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

The PR remains necessary: current main still throws direct core failures before the CLI formatter can preserve their durable outcome. The patch is a focused owner-boundary repair with no blocking correctness finding; it needs a rebase and exact-head checks before merge.

Priority: P1
Reviewed head: 6b99c9179c80f2012700b95fd3f1571b759aa3d3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary patch with meaningful live terminal evidence and regression coverage; exact-head rebase validation remains before merge.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body provides exact-head terminal evidence from a real Discord HTTPS failure using synthetic credentials, showing the changed CLI path now returns structured failure data and exits nonzero.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides exact-head terminal evidence from a real Discord HTTPS failure using synthetic credentials, showing the changed CLI path now returns structured failure data and exits nonzero.
Evidence reviewed 8 items Current-main failure point: Current main throws failed and partially failed direct-core outcomes before constructing the MessageSendResult that the CLI formatter reads, so the reported structured fields remain unreachable.
CLI presentation contract: The CLI already derives JSON failure fields from a returned sendResult and explicitly marks this execution as a CLI client, making the proposed return mode narrowly scoped to the presentation owner.
Proposed owner-boundary repair: The changed action path enables structured failure return only for the canonical CLI identity, and the outbound service forwards that internal mode into the durable sender.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/infra/outbound/message-action-send.core.test.ts

Result: PASS (completed)

[test] starting test/vitest/vitest.infra.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129728-T3hgPU/target

 ✓  infra  src/infra/outbound/message-action-send.core.test.ts (17 tests) 735ms

 Test Files  1 passed (1)
      Tests  17 passed (17)
   Start at  07:02:15
   Duration  11.83s (transform 8.93s, setup 1.14s, import 9.85s, tests 735ms, environment 0ms)

[test] passed 1 Vitest shard in 17.72s
[test] starting test/vitest/vitest.infra.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129728-T3hgPU/target

 ✓  infra  src/infra/outbound/message-action-send.core.test.ts (17 tests) 705ms

 Test Files  1 passed (1)
      Tests  17 passed (17)
   Start at  07:02:34
   Duration  5.64s (transform 2.86s, setup 506ms, import 4.31s, tests 705ms, environment 0ms)

[test] passed 1 Vitest shard in 11.45s

Assertions:

  • NOT OBSERVED expect_output: returns structured failed core delivery outcomes to CLI callers — command exited successfully; expected output was not observed in the captured pane

How this fits together

The message CLI invokes the message-action layer, which selects plugin or core delivery. Core delivery records a durable terminal outcome, and the CLI formatter converts that outcome into operator-visible text, JSON, and exit status.

flowchart LR
  A[CLI message command] --> B[Message action]
  B --> C[Outbound send service]
  C --> D[Core channel delivery]
  D --> E[Durable delivery outcome]
  E --> F[CLI JSON text and exit status]
Loading

Before merge

  • Resolve merge risk (P1) - CLI JSON failure output is a compatibility surface: callers that previously saw only a generic exception will now receive durable failed or partially failed fields.
  • Resolve merge risk (P1) - The branch is behind current main and its recorded aggregate gate is red from an unrelated file already repaired on main; rebase and verify exact-head checks before merge.
  • Complete next step (P2) - No repair lane is needed: the patch has no actionable code defect; the remaining work is a routine rebase and exact-head validation.
Agent review details

Security

None.

PR surface

Source +13, Tests +103. Total +116 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 14 1 +13
Tests 1 103 0 +103
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 117 1 +116

Review metrics

Metric Value Why it matters
Production versus regression coverage production +14, tests +103 The production growth is the narrow CLI-only result-return path; the tests cover both terminal failure shapes and the preserved non-CLI throw contract.

Root-cause cluster

Relationship: canonical
Canonical: #129728
Summary: This PR is the focused remaining repair after the merged adjacent CLI outcome work.

Members:

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

Merge-risk options

Maintainer options:

  1. Rebase and verify the failure envelope (recommended)
    Rebase onto current main, then confirm exact-head checks and the failed/partial CLI JSON contract before merging.
  2. Accept the intentional CLI failure-shape change
    Maintainers may accept the compatibility change only if existing automation is expected to consume the documented structured error envelope.

Technical review

Best possible solution:

Keep the durable sender as the terminal-outcome owner, expose that result only to CLI presentation, then rebase onto current main and validate the documented JSON failure envelope on the exact head.

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

Yes—source reproducible: current main throws at src/infra/outbound/message.ts:479 before the existing CLI formatter can inspect deliveryStatus; the PR body also supplies an exact-head real CLI failure run.

Is this the best way to solve the issue?

Yes—the durable sender remains the owner of terminal delivery facts, while the CLI alone receives them for presentation; changing formatter logic without preserving that result would leave the failure unreachable.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head terminal evidence from a real Discord HTTPS failure using synthetic credentials, showing the changed CLI path now returns structured failure data and exits nonzero.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides exact-head terminal evidence from a real Discord HTTPS failure using synthetic credentials, showing the changed CLI path now returns structured failure data and exits nonzero.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: This repairs incorrect CLI reporting for real message-delivery failures, which can cause operator automation to lose durable failure details.
  • merge-risk: 🚨 compatibility: The PR intentionally changes the machine-readable CLI failure result seen by existing scripts and operators.
  • 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 (terminal): The PR body provides exact-head terminal evidence from a real Discord HTTPS failure using synthetic credentials, showing the changed CLI path now returns structured failure data and exits nonzero.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head terminal evidence from a real Discord HTTPS failure using synthetic credentials, showing the changed CLI path now returns structured failure data and exits nonzero.

Evidence

What I checked:

  • Current-main failure point: Current main throws failed and partially failed direct-core outcomes before constructing the MessageSendResult that the CLI formatter reads, so the reported structured fields remain unreachable. (src/infra/outbound/message.ts:479, 636e21b19855)
  • CLI presentation contract: The CLI already derives JSON failure fields from a returned sendResult and explicitly marks this execution as a CLI client, making the proposed return mode narrowly scoped to the presentation owner. (src/commands/message.ts:53, 6b99c9179c80)
  • Proposed owner-boundary repair: The changed action path enables structured failure return only for the canonical CLI identity, and the outbound service forwards that internal mode into the durable sender. (src/infra/outbound/message-action-send.ts:595, 6b99c9179c80)
  • Preserved non-CLI contract: The sender still throws terminal failures by default; only returnFailureResult bypasses that throw, retaining existing behavior for non-CLI callers. (src/infra/outbound/message.ts:481, 6b99c9179c80)
  • Focused regression coverage: The new table-driven test covers failed and partial_failed CLI outcomes, including a partial message ID, and separately asserts that a non-CLI caller still rejects. (src/infra/outbound/message-action-send.core.test.ts:86, 6b99c9179c80)
  • Gateway identity contract: The patch directly imports the repository-local gateway client identity contract; it defines CLI as a canonical client ID and documents that these values cross the gateway handshake boundary. (packages/gateway-protocol/src/client-info.ts:3, 6b99c9179c80)

Likely related people:

  • steipete: The merged predecessor established the CLI failure-result and formatter behavior that this focused follow-up completes at the core-delivery boundary. (role: merged adjacent CLI outcome repair author; confidence: medium; commits: 452e73402221; files: src/commands/message.ts, src/infra/outbound/message.ts)

Rank-up moves

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

  • Rebase onto current main and show the required checks green on the rebased head.

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 (2 earlier review cycles)
  • reviewed 2026-08-26T01:46:50.628Z sha 6b99c9179c80f2012700b95fd3f1571b759aa3d3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-26T02:28:48.761Z sha 6b99c9179c80f2012700b95fd3f1571b759aa3d3 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🦪 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 26, 2026
@obviyus
obviyus force-pushed the leon/cli-core-send-failure-outcome-20260826 branch from 6b99c91 to 456838d Compare August 28, 2026 07:51
@obviyus
obviyus force-pushed the leon/cli-core-send-failure-outcome-20260826 branch from 456838d to 64e00b7 Compare August 28, 2026 08:04
@obviyus

obviyus commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Leon-SK668!

Proof: On exact head 64e00b7f1fa, CI run 33153895617 passed and local ClawSweeper passed with no findings. The real openclaw message send --channel discord ... --json CLI returned structured failed JSON after a Discord 401 and structured partial_failed JSON after Discord accepted a caption before media rejection. Both commands kept exit code 1, and the partial result preserved sentBeforeError plus the successful message ID.

  • Bug: Core delivery threw durable failures before the CLI could print their structured status and partial-send details.
  • Fix: The durable-result owner now returns terminal failures only to the explicitly identified CLI while non-CLI, queue, retry, recovery, and best-effort behavior stays unchanged.

Example

Before After
message send --json printed only a generic error. It prints deliveryStatus: "failed" and the owner error.
A caption sent before media failure lost its message ID. It prints deliveryStatus: "partial_failed", sentBeforeError: true, and the successful message ID.

@obviyus
obviyus merged commit 1dba34b into openclaw:main Aug 28, 2026
459 of 461 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
Keep durable delivery outcomes available to CLI JSON formatting while preserving the throwing contract for non-CLI callers and leaving delivery policy unchanged.

Co-authored-by: Leon-SK668 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

2 participants