Skip to content

fix(cli): render task flow JSON failures - #127080

Merged
steipete merged 4 commits into
mainfrom
codex/autoqa28-flow-show-json
Aug 21, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/autoqa28-flow-show-json

Conversation

@steipete

@steipete steipete commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where openclaw tasks flow show <missing> --json exited with empty stdout and a human-only stderr message, leaving automation without a parseable failure document.

Why This Change Was Made

The TaskFlow lookup owner now follows the existing sibling tasks show contract: JSON mode writes the shared canonical CLI failure envelope before exiting, while human mode retains the same stderr text and exit status.

User Impact

Scripts and agents can reliably parse missing TaskFlow lookups as one JSON document instead of receiving no machine-readable output.

Evidence

  • Pre-fix real-process regression: exit 1, empty stdout, human stderr.
  • Post-fix real-process regression: exit 1, empty stderr, and exactly one { "ok": false, "error": { "type": "cli_error", ... } } document.
  • node scripts/run-vitest.mjs test/cli-json-stdout.e2e.test.ts -t 'renders a missing TaskFlow as one canonical JSON document without stderr' — passed on the final rebased head.
  • node scripts/run-vitest.mjs src/commands/flows.test.ts src/cli/program/register.tasks.test.ts — 70 passed.
  • Proportional changed-file gates passed, including formatting, production/root-test typechecks, core/tooling lint, architecture guards, and import-cycle checks.
  • Fresh final-branch structured autoreview reported no accepted P0/P1 findings.
  • The first exact-head CI run exposed an unrelated shared-shard test-isolation defect: entry.run-main.test.ts installed its console.error spy before the production path could install console capture. The test now establishes that precondition first without weakening its assertions; the refreshed compact shard is green.
  • ClawSweeper found a TTY-only JSON corruption risk: terminal reset bytes could be appended to stdout after the document. Both TaskFlow and direct-task JSON lookup failures now route cleanup to process.stderr, with focused owner-boundary coverage.
  • Production delta: +10/-5, net +5, required to preserve distinct JSON/human output and TTY cleanup contracts. Tests: +46/-0.

AI-assisted: yes. I reviewed the implementation and validation results.

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 21, 2026 07:10
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS maintainer Maintainer-authored PR labels Aug 21, 2026
@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: 🦐 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 Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 4:34 AM ET / 08:34 UTC.

ClawSweeper review

What this changes

This PR makes a missing TaskFlow lookup emit the standard JSON CLI error in JSON mode while preserving human-mode errors and keeping terminal reset bytes off JSON stdout.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. The branch fixes current main’s missing-TaskFlow JSON failure path, and the prior sibling terminal-reset finding is addressed on the latest head; no blocking patch defect was found.

Priority: P1
Reviewed head: 8075dadf57ac0d5b8a3a6755637cbd86390e3f3a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused real-process evidence and owner-boundary coverage support a normal good-quality repair.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body records before-and-after built-CLI output and a passing final-head regression that verifies exit status, JSON stdout, and stderr behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body records before-and-after built-CLI output and a passing final-head regression that verifies exit status, JSON stdout, and stderr behavior.
Evidence reviewed 7 items Current-main defect: Current main always sends a missing TaskFlow lookup through the human error path and exits, regardless of JSON mode.
Owner-boundary repair: The PR changes the TaskFlow lookup owner to use the existing canonical JSON failure formatter only in JSON mode and retains the human error otherwise.
Caller and sibling contract: The command registration passes resolved JSON mode to TaskFlow show, while direct task lookup already uses the same canonical error envelope; the final commit applies the same explicit reset-stream protection there.
Findings None None.
Security None None.

Live Verification

Command: OPENCLAW_STATE_DIR=/tmp/openclaw-cli-json-proof OPENCLAW_CONFIG_PATH=/tmp/openclaw-cli-json-proof.json pnpm openclaw tasks flow show missing-flow --json

Result: PASS (completed)

OPENCLAW_STATE_DIR=/tmp/openclaw-cli-json-proof OPENCLAW_CONFIG_PATH=/tmp/openclaw-cli-json-proof.json pnpm openclaw tasks flow show missing-flow --json
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127080-fnVAhT/target$ OPENCLAW_STATE_DIR=/tmp/openclaw-cli-json-proof OPENCLAW_CONFIG_PATH=/tmp/openclaw-cli-js
on-proof.json pnpm openclaw tasks flow show missing-flow --json
$ node scripts/run-node.mjs tasks flow show missing-flow --json
OPENCLAW_STATE_DIR=/tmp/openclaw-cli-json-proof OPENCLAW_CONFIG_PATH=/tmp/openclaw-cli-json-proof.json pnpm openclaw tasks flow show missing-flow --json
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 100.42 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 13.7s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4212ms (slowest: built plugin control-plane loads 3341ms)
{
  "ok": false,
  "error": {
    "type": "cli_error",
    "me
… output truncated …

Assertions:

  • PASS expect_output: "type": "cli_error"

How this fits together

The task CLI resolves task or TaskFlow lookups and formats results for either people or automation. Lookup failures pass through the runtime exit path, whose terminal cleanup must not corrupt JSON written to stdout.

flowchart LR
A[CLI lookup request] --> B[Task or TaskFlow command]
B --> C{Lookup found?}
C -->|Yes| D[Render command result]
C -->|No| E[Canonical CLI failure]
E --> F[JSON stdout or human stderr]
F --> G[Terminal cleanup]
G --> H[Exit status]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows net +5 for a bug fix; this appears justified because the TaskFlow owner lacked the required JSON-versus-human output branch and reuses the existing formatter rather than adding a new abstraction.
  • Complete next step (P2) - This maintainer-authored PR has a complete focused repair path; it needs ordinary exact-head CI completion rather than an automated replacement repair.
Agent review details

Security

None.

PR surface

Source +5, Tests +46. Total +51 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 10 5 +5
Tests 4 46 0 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 56 5 +51

Review metrics

Metric Value Why it matters
Production vs test LOC production net +5 (+10/-5); tests +46/-0 The added production branch is the missing JSON/human failure distinction; the larger test delta covers owner behavior and a real built-CLI path.

Stored data model

Persistent data-model change detected: serialized state: test/cli-json-stdout.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm the exact-head CLI contract (recommended)
    Merge after exact-head checks remain green and the focused built-CLI JSON failure regression continues to prove one parseable stdout document.

Technical review

Best possible solution:

Keep the lookup-owner split: reuse the canonical failure formatter for JSON mode, retain human stderr otherwise, and preserve the focused built-CLI regression as the durable contract.

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

Yes. Current main’s TaskFlow lookup branch ignores JSON mode, and the added built-CLI case provides a deterministic missing-lookup command; it was not executed during this read-only review.

Is this the best way to solve the issue?

Yes. The repair belongs in the TaskFlow lookup owner and reuses the direct-task canonical failure formatter; changing generic runtime exit behavior would incorrectly make command-output policy global.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 records before-and-after built-CLI output and a passing final-head regression that verifies exit status, JSON stdout, and stderr behavior.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Missing TaskFlow lookups currently leave scripts and agents without a parseable machine-readable failure.
  • merge-risk: 🚨 compatibility: The PR changes the established JSON stdout, stderr, and exit behavior consumed by automation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 records before-and-after built-CLI output and a passing final-head regression that verifies exit status, JSON stdout, and stderr behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records before-and-after built-CLI output and a passing final-head regression that verifies exit status, JSON stdout, and stderr behavior.

Evidence

What I checked:

  • Current-main defect: Current main always sends a missing TaskFlow lookup through the human error path and exits, regardless of JSON mode. (src/commands/flows.ts:214, 627f862e8e64)
  • Owner-boundary repair: The PR changes the TaskFlow lookup owner to use the existing canonical JSON failure formatter only in JSON mode and retains the human error otherwise. (src/commands/flows.ts:216, 8075dadf57ac)
  • Caller and sibling contract: The command registration passes resolved JSON mode to TaskFlow show, while direct task lookup already uses the same canonical error envelope; the final commit applies the same explicit reset-stream protection there. (src/cli/program/register.tasks.ts:277, 8075dadf57ac)
  • Terminal-stream contract: Terminal restoration defaults ANSI reset output to stdout, while the runtime supports an explicit reset stream; the changed failure paths select stderr for structured output. (packages/terminal-core/src/restore.ts:23, 8075dadf57ac)
  • Behavior coverage: The added built-CLI regression checks exit 1, parseable canonical JSON on stdout, and empty stderr for a missing TaskFlow; focused owner tests cover the JSON/reset call boundary. (test/cli-json-stdout.e2e.test.ts:298, 8075dadf57ac)
  • Feature provenance: Blame ties the current TaskFlow lookup implementation, including its prior human-only failure branch, to the TaskFlow command introduction commit. (src/commands/flows.ts:214, 6f52e9fc2f0c)

Likely related people:

  • steipete: The current TaskFlow command and its lookup branch trace to this author’s commit, and the PR continues work in that owner boundary. (role: introduced current TaskFlow command behavior; confidence: high; commits: 6f52e9fc2f0c, 8075dadf57ac; files: src/commands/flows.ts, src/commands/tasks.ts, src/cli/program/register.tasks.ts)

Rank-up moves

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

  • Let the remaining exact-head CI checks complete green before merging.

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 (3 earlier review cycles)
  • reviewed 2026-08-21T07:17:24.860Z sha 27eabbf :: needs changes before merge. :: [P1] Keep terminal cleanup off JSON stdout
  • reviewed 2026-08-21T07:40:42.672Z sha 4f0b369 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T08:04:04.726Z sha e8c70d1 :: needs changes before merge. :: [P2] Repair the sibling JSON lookup reset path

@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 Aug 21, 2026
@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 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 Aug 21, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready review complete.

The final branch repairs the full task-family invariant: missing TaskFlow and direct-task lookups emit canonical JSON failures, exit 1, and route terminal reset bytes to stderr in JSON mode. Human-mode stderr and cleanup behavior remain unchanged. Production delta is +10/-5 (net +5); tests are +46/-0.

Proof:

  • Pre-fix TaskFlow real-process regression — exit 1, empty stdout, human stderr.
  • Final TaskFlow real-process regression — exit 1, empty stderr, one canonical JSON document.
  • Task, flow, registration, and entry focused suites — 100 passed after sibling repair.
  • Owner tests assert canonical payloads and resetStream: process.stderr for both JSON lookup misses.
  • Fresh complete-branch structured autoreview — no accepted P0/P1 findings.
  • Final exact-head CI run 32463357909 on 8075dadf57ac0d5b8a3a6755637cbd86390e3f3a — green.
  • Native review-init, review-artifacts-init, and review-validate-artifacts — passed with READY FOR /prepare-pr.

ClawSweeper findings addressed:

  • TTY terminal reset could corrupt TaskFlow JSON stdout — fixed and covered.
  • Direct tasks show shared the same reset-stream defect — fixed and covered.
  • The earlier compact-shard entry test failure was a shared-worker console-capture precondition bug; the test now establishes that precondition before spying, and refreshed exact-head compact shards are green.

The exact-head ClawSweeper re-review is still publishing. Per repository policy, a late re-review does not block landing once all prior actionable findings are addressed and exact-head CI is green.

@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 Aug 21, 2026
@steipete
steipete merged commit 32fb2fc into main Aug 21, 2026
177 checks passed
@steipete
steipete deleted the codex/autoqa28-flow-show-json branch August 21, 2026 08:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
* fix(cli): render task flow JSON failures

* test(cli): stabilize entry console capture

* fix(cli): keep JSON terminal resets off stdout

* fix(cli): keep task JSON resets off stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR 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.

1 participant