Skip to content

refactor(process): consolidate command diagnostic tails - #134607

Merged
steipete merged 1 commit into
mainfrom
codex/qa-20260831-command-error-tail-owner
Sep 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-20260831-command-error-tail-owner

Conversation

@steipete

@steipete steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Follow-up to #134428, which fixed lost stdout diagnostics when failed commands also wrote stderr. That repair was merged separately and added a second normalization and allocation path in the command-error formatter. This PR consolidates that ownership while retaining both useful diagnostic tails and their shared output budget.

Why This Change Was Made

Reuse formatCommandOutput for terminal sanitation, carriage-return progress frames, line tails, and UTF-16 boundaries, then fit the prepared suffixes within the mixed-stream budget. This removes the parallel formatter and allocation machinery while preserving timeout, output-limit, signal, and buffered-error reasons. Result summaries retain their separate 800-unit per-stream limits.

Production changes are +38/−80 (net −42); tests are +92/−1. Together with the original repair's +42 production lines, the pair is production-neutral. Vincent Koc's diagnostic and sanitation work is preserved and credited. The Git facade changes owned by #132180 remain outside this PR.

User Impact

Failed commands continue to show both stdout and stderr recovery information, including uneven stream lengths, without exceeding the shared diagnostic budget or splitting surrogate pairs. This is a consolidation of the landed behavior, not a claim that the new controls fail on the original repair. No configuration, storage, setup-capacity, or public API change is intended.

Evidence

  • The landed formatter passed all 22 baseline cases before this refactor, including the added behavioral controls.
  • After the refactor, 80 selected cases passed: 22 formatter, 14 real managed-worktree service, 37 Git facade, and 7 Gmail result-consumer cases. The Gmail file's other 24 cases were intentionally unselected.
  • All 29 selected canonical checks passed in the actual check-changed process. Its outer protection check then failed because the unrelated primary checkout's index bytes changed. That failure is retained; a separate audit verified unchanged product, dependencies, hooks, protected checkout semantics, and process closure. No cause is attributed and the gate process was not replayed.
  • An independent full P0–P2 managed review reported no findings. The source bytes remained unchanged through the checks.

Local proof used Node 26.8.1 and pnpm 12.1.0 on macOS. An earlier service attempt failed the real disk-capacity prerequisite; it remains recorded, and the same 14 cases later passed after available space recovered. This follow-up does not claim a new released-package, Windows, live-provider, or native Codex run. The original repair's separate CLI evidence remains historical.

The nearby snapshot/git-backup stderr-or-stdout paths remain a named follow-up: their 500-unit prefix cap, URL-userinfo redaction before slicing, and no-commit semantics need their own repair and proof.

Related: #134427. Thanks @vincentkoc for the original repair and terminal-safety work.

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]>
@steipete steipete self-assigned this Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 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 size: M maintainer Maintainer-authored PR labels Sep 1, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 9:29 PM ET / September 1, 2026, 01:29 UTC.

ClawSweeper review

What this changes

The branch consolidates terminal-output normalization and tail fitting so command errors and result summaries use the same bounded formatter.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No discrete introduced correctness or security defect was found in this focused refactor. It remains open for normal maintainer handling because it is maintainer-owned and carries the protected maintainer label.

Priority: P3
Reviewed head: 1f6ab51602df88cb178ebbc0580f36e43b9fc300

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative formatter consolidation with meaningful behavioral coverage and no identified introduced defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal formatter refactor is exempt from the external-contributor proof gate; its body reports focused after-change checks, which were not rerun in this read-only review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal formatter refactor is exempt from the external-contributor proof gate; its body reports focused after-change checks, which were not rerun in this read-only review.
Evidence reviewed 6 items Introduced formatter change: The verified merge-base-to-head patch changes only the command-error formatter and its colocated behavioral tests; the formatter now normalizes, tails, and budgets output through one path.
Owner and caller path checked: Managed-worktree setup throws this shared command error after a nonzero setup-script result; Git and Gmail callers use the same formatter for bounded recovery diagnostics.
Behavioral coverage checked: The colocated tests cover mixed streams, buffers, control-byte sanitation, Unicode-safe boundaries, budget fitting, termination precedence, and the separate per-stream result cap.
Findings None None.
Security None None.

How this fits together

Process execution captures stdout and stderr, then the command-error formatter turns failed results into safe, bounded diagnostics. Those diagnostics feed managed-worktree setup, Git operations, and Gmail setup errors that tell operators how to recover.

flowchart LR
  A[Command execution] --> B[Captured stdout and stderr]
  B --> C[Command diagnostic formatter]
  C --> D[Bounded safe tails]
  D --> E[Worktree and Git failures]
  D --> F[Gmail setup failures]
  E --> G[Operator recovery guidance]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - The fetched current-main source blob and two filtered PR-comment bodies were unavailable to this read-only review; refresh those contexts before a final merge decision rather than treating this as a contributor defect.
  • Complete next step (P2) - No actionable repair is indicated; remaining work is normal protected maintainer review.
Agent review details

Security

None.

PR surface

Source -42, Tests +91. Total +49 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 38 80 -42
Tests 1 92 1 +91
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 130 81 +49

Review metrics

Metric Value Why it matters
Production versus tests production −42 net; tests +91 net The consolidation removes duplicate production formatting logic while adding focused behavioral controls.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the single shared formatter and land this refactor only after the normal maintainer review refresh confirms it remains equivalent on current main.
  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 single shared formatter and land this refactor only after the normal maintainer review refresh confirms it remains equivalent on current main.

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

Not applicable: this PR is a behavior-preserving refactor, and no local execution was performed in the read-only review environment.

Is this the best way to solve the issue?

Yes for the reviewed branch: placing normalization and tail fitting in the shared formatter removes the parallel path while preserving the caller-facing diagnostic contract; current-main equivalence still needs refresh.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded internal diagnostics refactor with no identified user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal formatter refactor is exempt from the external-contributor proof gate; its body reports focused after-change checks, which were not rerun in this read-only review.

Evidence

What I checked:

  • Introduced formatter change: The verified merge-base-to-head patch changes only the command-error formatter and its colocated behavioral tests; the formatter now normalizes, tails, and budgets output through one path. (src/process/command-error.ts:7, 1f6ab51602df)
  • Owner and caller path checked: Managed-worktree setup throws this shared command error after a nonzero setup-script result; Git and Gmail callers use the same formatter for bounded recovery diagnostics. (src/agents/worktrees/service.ts:398, 1f6ab51602df)
  • Behavioral coverage checked: The colocated tests cover mixed streams, buffers, control-byte sanitation, Unicode-safe boundaries, budget fitting, termination precedence, and the separate per-stream result cap. (src/process/command-error.test.ts:39, 1f6ab51602df)
  • Shared helper contract checked: The formatter uses the repository UTF-16-safe suffix slicer, whose implementation adjusts both slice edges away from dangling surrogate halves. (packages/normalization-core/src/utf16-slice.ts:29, 1f6ab51602df)
  • Feature history: History identifies this branch as a follow-up to the merged mixed-stream repair; the earlier repair is commit 2ea15ee and the current refactor has one direct parent at the verified merge base. (src/process/command-error.ts:7, 2ea15eee1a5c)
  • Current-main limitation: The fetched-main formatter blob could not be loaded because this partial checkout attempted a promisor fetch and DNS resolution for GitHub failed; this review therefore does not claim current-main equivalence or release inclusion. (src/process/command-error.ts, 3b758df6cb30)

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)

Rank-up moves

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

  • Refresh the unavailable current-main source and the omitted comment context 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 (1 earlier review cycle)
  • reviewed 2026-09-01T01:20:27.485Z sha 1f6ab51 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 1, 2026 01:24
@steipete
steipete merged commit 8655892 into main Sep 1, 2026
327 checks passed
@steipete
steipete deleted the codex/qa-20260831-command-error-tail-owner branch September 1, 2026 08:54
@steipete

steipete commented Sep 1, 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 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]>
obviyus added a commit that referenced this pull request Sep 2, 2026
Related: #134607

## What Problem This Solves

Git snapshot backup failures lost useful operator diagnostics.

- Failed push kept stderr or stdout, but not both.
- Failed history exposed raw Git errors.
- Empty history depended on one English Git message.
- Persisted diagnostics could split a UTF-16 surrogate pair.

## Why This Change Was Made

The Git snapshot owner now formats every failed Git result through one bounded path.

That path redacts each output line before it reserves space for both streams. This keeps multi-line URL query credentials from consuming later diagnostics.

Unborn repositories are detected from symbolic `HEAD` and exact branch-ref state. Corrupt refs and missing non-branch refs remain visible failures.

The generic process formatter is unchanged. The backup record keeps the same 1,200 UTF-16-unit storage contract.

## User Impact

Operators keep recent stderr and stdout details after a failed push or history read.

Diagnostics remain bounded and remove URL user information and sensitive query values.

Empty repositories still show an empty history. Successful create, push, history, and restore behavior is unchanged.

## Evidence

- Current main `4fc24e6e0f81121cef0fb4395db29fb87700e7f6`: real `openclaw backup git create --push` lost stdout, and corrupt `backup git log` returned raw repeated Git errors.
- Repaired tree: a real rejected `git push` retained both stream tails and persisted exactly 1,200 UTF-16 units with all synthetic URL credentials removed.
- Repaired tree: real unborn history returned no commits; corrupt history returned a structured redacted error; successful push, log, and restore passed against a local bare remote.
- Focused tests: 59 passed across process, snapshot, state, and command owners.
- Final test-audit run: 28 snapshot and persistence tests passed with an emoji placed on the actual formatter cut boundary.
- Packaged CLI E2E test: real init, failed push, unborn history, and corrupt history passed through `openclaw.mjs`.
- Formatting and `git diff --check` passed.

### Redacted exact-head terminal trace

```text
Git backup committed: <backup-commit>
Warning: Git backup committed, but push failed: git push failed (code=1, termination=exit)
stderr: …
stderr-old-89 https://***:***@example.invalid/backup.git?access_token=***
stderr-tail-🦞 https://***:***@example.invalid/backup.git?access_token=***
error: failed to push some refs to '<temp>/remote.git'
stdout: …
stdout-old-89 https://***:***@example.invalid/backup.git?access_token=***
stdout-tail-🐚 https://***:***@example.invalid/backup.git?access_token=***
PASS failed-push persisted warning length=1200 UTF-16 units
TRACE freshness equals create warning: true
```

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
Related: openclaw#134607

## What Problem This Solves

Git snapshot backup failures lost useful operator diagnostics.

- Failed push kept stderr or stdout, but not both.
- Failed history exposed raw Git errors.
- Empty history depended on one English Git message.
- Persisted diagnostics could split a UTF-16 surrogate pair.

## Why This Change Was Made

The Git snapshot owner now formats every failed Git result through one bounded path.

That path redacts each output line before it reserves space for both streams. This keeps multi-line URL query credentials from consuming later diagnostics.

Unborn repositories are detected from symbolic `HEAD` and exact branch-ref state. Corrupt refs and missing non-branch refs remain visible failures.

The generic process formatter is unchanged. The backup record keeps the same 1,200 UTF-16-unit storage contract.

## User Impact

Operators keep recent stderr and stdout details after a failed push or history read.

Diagnostics remain bounded and remove URL user information and sensitive query values.

Empty repositories still show an empty history. Successful create, push, history, and restore behavior is unchanged.

## Evidence

- Current main `6c0543988388bb12f47c3aedbb10e6342dbc4f6f`: real `openclaw backup git create --push` lost stdout, and corrupt `backup git log` returned raw repeated Git errors.
- Repaired tree: a real rejected `git push` retained both stream tails and persisted exactly 1,200 UTF-16 units with all synthetic URL credentials removed.
- Repaired tree: real unborn history returned no commits; corrupt history returned a structured redacted error; successful push, log, and restore passed against a local bare remote.
- Focused tests: 59 passed across process, snapshot, state, and command owners.
- Final test-audit run: 28 snapshot and persistence tests passed with an emoji placed on the actual formatter cut boundary.
- Packaged CLI E2E test: real init, failed push, unborn history, and corrupt history passed through `openclaw.mjs`.
- Formatting and `git diff --check` passed.

### Redacted exact-head terminal trace

```text
Git backup committed: <backup-commit>
Warning: Git backup committed, but push failed: git push failed (code=1, termination=exit)
stderr: …
stderr-old-89 https://***:***@example.invalid/backup.git?access_token=***
stderr-tail-🦞 https://***:***@example.invalid/backup.git?access_token=***
error: failed to push some refs to '<temp>/remote.git'
stdout: …
stdout-old-89 https://***:***@example.invalid/backup.git?access_token=***
stdout-tail-🐚 https://***:***@example.invalid/backup.git?access_token=***
PASS failed-push persisted warning length=1200 UTF-16 units
TRACE freshness equals create warning: true
```

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

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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.

1 participant