Skip to content

fix(process): preserve safe mixed-stream command diagnostics - #134428

Merged
vincentkoc merged 2 commits into
mainfrom
codex/qa-20260831-command-error-streams
Aug 31, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
codex/qa-20260831-command-error-streams

Conversation

@steipete

@steipete steipete commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #134427

What Problem This Solves

Fixes an issue where users creating a managed worktree could lose the setup script's recovery instruction when the script also wrote a warning to stderr. The first repair retained both streams, but still truncated uneven output despite unused space and allowed terminal control bytes into the diagnostic.

Why This Change Was Made

The shared command-error owner now normalizes each stream once, labels mixed output, and allocates the existing 2,000-character detail budget dynamically. Short streams keep only what they need; remaining capacity goes to the longer stream, with omission markers counted inside the budget and UTF-16-safe tail slicing.

ANSI and carriage-return redraws are normalized before each logical line is sanitized. Newlines remain real line boundaries, tabs render visibly, and executable C0/C1/DEL controls are removed. Single-stream output, termination reasons, suffix tails, Buffer/string handling, and the separate 800-character result formatter remain unchanged.

The unrelated git-exec consolidation was removed completely because #132180 already owns that work.

User Impact

Failed commands now retain both warnings and recovery instructions when the combined useful output fits the established budget. Oversized output remains bounded and safe to render in terminals and logs. Worktree failure cleanup behavior is unchanged.

Production: 51 lines added, 9 removed, net +42. Tests: 138 lines added.

Evidence

Before the follow-up, two focused regressions failed:

  • a short stderr plus roughly 1,200 characters of stdout was truncated by the fixed 50/50 split;
  • TAB, BEL, DEL, and C1 controls remained executable in mixed-stream output.

After the repair:

  • 132 focused tests passed across command-error, Git diagnostics, managed-worktree cleanup, and Gmail command-result consumers;
  • the real managed-worktree setup failure retained both streams and verified checkout, branch, and registry cleanup;
  • pnpm check:changed passed all selected core/core-test types, lint, schema, database, sidecar, import-cycle, webhook, and pairing guards;
  • pnpm tsgo:test:src, pnpm check:import-cycles, formatting, and git diff --check passed;
  • src/infra/git-exec.ts and src/infra/git-exec.test.ts are byte-identical to the PR base.

A visible stderr warning hid actionable stdout in failed command errors.
Normalize each stream once and retain independent recent tails within the
existing error detail budget. Preserve termination reasons, single-stream
result caps, progress redraw handling, and UTF-16 boundaries.

Reuse the raw Git command owner for trimmed output to remove duplicated
execution and failure handling. Keep worktree cleanup and command capture
unchanged.
@steipete steipete self-assigned this Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 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 agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 31, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 4:50 PM ET / 20:50 UTC.

ClawSweeper review

What this changes

The PR preserves and safely renders both stderr and stdout in failed-command diagnostics within a shared 2,000-character budget, with regression coverage for managed-worktree cleanup.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No introduced correctness or security defect was found. Current main and the latest release still discard stdout when stderr is nonempty, so this member-authored, maintainer-labeled PR remains necessary; exact-head CI must complete before merge readiness is established.

Priority: P2
Reviewed head: b308420f5c5214c6dd4a0e4b4b9c99eaa505d737

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary repair with credible behavior-level coverage and no actionable defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied evidence and added boundary test nevertheless exercise the real setup subprocess, shared formatter, and rollback path.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied evidence and added boundary test nevertheless exercise the real setup subprocess, shared formatter, and rollback path.
Evidence reviewed 7 items Current main still has the reported loss: Current main short-circuits from stderr to stdout, so any visible stderr hides recovery text from stdout.
Introduced repair owns mixed-stream rendering: The PR normalizes each stream, reserves label and omission-marker space, and renders both tails from the shared formatter.
Caller and boundary behavior: A failing worktree setup calls the shared error formatter after command capture; the added boundary test uses a real setup subprocess and verifies worktree, branch, and registry rollback.
Findings None None.
Security None None.

How this fits together

Managed worktree setup runs a repository setup command and turns a nonzero result into an operator-facing failure. The shared formatter also supplies diagnostics for Git and Gmail command callers.

flowchart LR
  A[Setup command] --> B[Command output capture]
  B --> C[Shared diagnostic formatter]
  C --> D[Failed worktree cleanup]
  C --> E[Operator error message]
  D --> F[Registry and Git state removed]
Loading

Before merge

  • Resolve merge risk (P1) - This bug fix adds 42 net production lines in a central formatter. The normalizer, tail renderer, and shared-budget allocator have distinct responsibilities, and no net-neutral absorbing refactor was evident, but the added surface merits maintainer visibility.
  • Complete next step (P2) - No repair job is needed: the exact-head patch has no actionable review finding, while final merge remains gated by normal exact-head CI and maintainer handling.
Agent review details

Security

None.

PR surface

Source +42, Tests +138. Total +180 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 51 9 +42
Tests 2 138 0 +138
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 189 9 +180

Review metrics

Metric Value Why it matters
Production versus test delta production +51/-9 (net +42); tests +138/-0 The central diagnostic owner grows to add one normalizer, tail renderer, and mixed-stream allocator; test growth covers the new boundary behavior.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #134427
Summary: This PR explicitly targets the same mixed-stream worktree diagnostic loss described by the open issue.

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
    Land the centralized formatter after exact-head CI is green; retain the separate normalizer, tail renderer, and allocator as the canonical implementation for safe mixed-stream diagnostics.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the centralized formatter after exact-head CI is green; retain the separate normalizer, tail renderer, and allocator as the canonical implementation for safe mixed-stream diagnostics.

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

Yes, source-reproducible: current main’s stderr-or-stdout selection at src/process/command-error.ts:44-45 directly loses stdout whenever stderr is visible, and the added worktree boundary test exercises that path. This read-only review did not execute the reproduction.

Is this the best way to solve the issue?

Yes. Repairing the shared command-error owner fixes managed worktrees while preserving the separate 800-character formatter used by Git and Gmail callers; no duplicate implementation path was found.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

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

Label justifications:

  • P2: The PR repairs actionable failed-command diagnostics and worktree recovery guidance without changing execution, authorization, or stored state.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied evidence and added boundary test nevertheless exercise the real setup subprocess, shared formatter, and rollback path.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: 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 (2 earlier review cycles)
  • reviewed 2026-08-31T19:43:44.799Z sha b053fa9 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T20:28:39.010Z sha b053fa9 :: needs maintainer review before merge. :: none

@vincentkoc vincentkoc changed the title fix: retain recovery details when failed commands write to both streams fix(process): preserve safe mixed-stream command diagnostics Aug 31, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

The head now fixes the dynamic shared-budget and terminal-control findings, removes the unrelated git-exec overlap, and updates the PR evidence.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 31, 2026
@vincentkoc
vincentkoc merged commit 2ea15ee into main Aug 31, 2026
466 of 468 checks passed
@vincentkoc
vincentkoc deleted the codex/qa-20260831-command-error-streams branch August 31, 2026 21:11
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
…w#134428)

* fix(process): retain both streams in command failure details

A visible stderr warning hid actionable stdout in failed command errors.
Normalize each stream once and retain independent recent tails within the
existing error detail budget. Preserve termination reasons, single-stream
result caps, progress redraw handling, and UTF-16 boundaries.

Reuse the raw Git command owner for trimmed output to remove duplicated
execution and failure handling. Keep worktree cleanup and command capture
unchanged.

* fix(process): preserve safe mixed-stream diagnostics

---------

Co-authored-by: Vincent Koc <[email protected]>
steipete added a commit that referenced this pull request Sep 1, 2026
Reuse the canonical output normalizer and suffix fitter for mixed-stream
command errors, preserving terminal sanitation, shared budgets, Unicode
boundaries, termination reasons, and independent result-output limits.

Follow up on #134428 without reintroducing the Git facade consolidation
owned by #132180. Production shrinks by 42 lines, offsetting the original
repair's 42-line increase. Add focused behavioral controls; the landed
original already passes the 22-case formatter baseline.

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
)

Reuse the canonical output normalizer and suffix fitter for mixed-stream
command errors, preserving terminal sanitation, shared budgets, Unicode
boundaries, termination reasons, and independent result-output limits.

Follow up on openclaw#134428 without reintroducing the Git facade consolidation
owned by openclaw#132180. Production shrinks by 42 lines, offsetting the original
repair's 42-line increase. Add focused behavioral controls; the landed
original already passes the 22-case formatter baseline.

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

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

Failed worktree setup hides stdout recovery instructions when stderr has a warning

2 participants