Skip to content

fix(backup): escape terminal controls in Git backup reports - #181586

Merged
steipete merged 3 commits into
openclaw:mainfrom
Alix-007:fix/alix-backup-git-terminal-20261023
Oct 25, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
Alix-007:fix/alix-backup-git-terminal-20261023

Conversation

@Alix-007

@Alix-007 Alix-007 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Git backup reports that emit terminal controls from repository paths, commit subjects, restore metadata, or diagnostics.

User Impact

Human-readable reports preserve printable Unicode and deliberate tab/newline separators while escaping control-bearing fields. Git operations, JSON values, returned results, and recorded diagnostics remain unchanged.

Why This Change Was Made

Apply the canonical sanitizeTerminalText at each terminal report boundary. The shared backup-outcome helper also sanitizes its ledger-failure warning once, covering the same path for Git and archive backups. The snapshot mock now preserves real exports; the owning generator removes its obsolete baseline exemption.

Thanks @Alix-007 for the fix, regression tests, and original real-CLI proof.

Evidence

  • Both new command regressions fail on unchanged main production code (2 failed, 17 skipped; 224.27s runner duration): raw repository and restore paths reach terminal output. All 19 command tests pass with the fix (222.97s runner duration).
  • Regressions preserve raw JSON, result identities, Unicode, and report separators. The existing push-diagnostic test checks safe terminal output alongside unchanged credential-redacted persistence. The existing archive-failure regression now uses a control-bearing ledger error.
  • Targeted typed oxlint, oxfmt, and git diff --check pass. The focused snapshot diagnostic/persistence test passes (1/1), all archive tests pass (3/3), and the existing corrupt-SQLite outcome-warning test passes (1/1). Independent Codex review through P2 is scoped-clean. After integrating current main, all 22 command/archive tests pass (255.26s runner duration), the snapshot diagnostic/persistence test passes (1/1), and the corrupt-SQLite outcome-warning test passes (1/1). Integrated typed lint, formatting, diff checks, and the generated mock-export baseline check pass.
  • Against main: production +27/−11 (net +16), tests +63/−9 (net +54), docs +2/−0, generated baseline −1. The production growth is direct escaping at distinct output sites; no new helper, state, or alternate policy was added, and no safe nearby deletion offsets it.
  • A fresh standalone CLI live replay was not repeated on this source-only, heavily loaded Mac. Inspected prior contributor built Linux CLI traces exercise actual backup git init/log, Git repository/commit readback, and raw JSON: controls changed from 1 to 0 for init, empty history, and populated history. No remote push, restore, or production data was used. That evidence predates the current integration; it is not an exact-head live claim. The nearby ledger-warning path is covered by the command regression rather than a standalone CLI replay.
Prior contributor CLI traces (original base and contributor head)

Temporary fixture roots are replaced with $FIXTURE; host IPs and incidental toolchain paths are redacted. JSON escaping makes terminal-control bytes inspectable without executing them.

{
  "phase": "red",
  "head": "7a1d72c44102a24843c602c6559aa72fec3f49a5",
  "time": "2026-10-23T10:54:52.478Z",
  "runs": [
    {
      "label": "init",
      "args": [
        "backup",
        "git",
        "init",
        "--repository",
        "$FIXTURE/café\^[[31m\noperator-forged"
      ],
      "code": 0,
      "stdout": "Git backup repository ready: $FIXTURE/café\^[[31m\noperator-forged\n",
      "stderr": ""
    },
    {
      "label": "log",
      "args": [
        "backup",
        "git",
        "log",
        "--repository",
        "$FIXTURE/café\^[[31m\noperator-forged"
      ],
      "code": 0,
      "stdout": "No Git backup commits in $FIXTURE/café\^[[31m\noperator-forged.\n",
      "stderr": ""
    },
    {
      "label": "json-control",
      "args": [
        "backup",
        "git",
        "log",
        "--repository",
        "$FIXTURE/café\^[[31m\noperator-forged",
        "--json"
      ],
      "code": 0,
      "stdout": "{\n  \"repositoryPath\": \"$FIXTURE/café\\^[[31m\\noperator-forged\",\n  \"entries\": []\n}\n",
      "stderr": ""
    },
    {
      "label": "populated-log",
      "args": [
        "backup",
        "git",
        "log",
        "--repository",
        "$FIXTURE/café\^[[31m\noperator-forged"
      ],
      "code": 0,
      "stdout": "7c4f292d49254fd7afb7a34c0fb79106e53083fd\t2026-10-23T10:55:01+00:00\tcafé\^[[31m operator-forged\n",
      "stderr": ""
    },
    {
      "label": "populated-json-control",
      "args": [
        "backup",
        "git",
        "log",
        "--repository",
        "$FIXTURE/café\^[[31m\noperator-forged",
        "--json"
      ],
      "code": 0,
      "stdout": "{\n  \"repositoryPath\": \"$FIXTURE/café\\^[[31m\\noperator-forged\",\n  \"entries\": [\n    {\n      \"commit\": \"7c4f292d49254fd7afb7a34c0fb79106e53083fd\",\n      \"date\": \"2026-10-23T10:55:01+00:00\",\n      \"message\": \"café\\^[[31m operator-forged\"\n    }\n  ]\n}\n",
      "stderr": ""
    }
  ],
  "observations": [
    {
      "label": "init",
      "controls": 1,
      "escapedNewline": false,
      "unicode": true
    },
    {
      "label": "log",
      "controls": 1,
      "escapedNewline": false,
      "unicode": true
    },
    {
      "label": "populated-log",
      "controls": 1,
      "jsonRetainsOriginalCommitSubject": true
    },
    {
      "actualGitRepositoryReadback": true,
      "rawRepositoryPreservedInJson": true,
      "remotePushRestoreAndProductionData": "not used"
    }
  ]
}
{
  "phase": "green",
  "head": "776488f32b14856357c4bc2aec2a7aefeb232833",
  "time": "2026-10-23T15:23:38.771Z",
  "runs": [
    {
      "label": "init",
      "args": [
        "backup",
        "git",
        "init",
        "--repository",
        "$FIXTURE/café\^[[31m\noperator-forged"
      ],
      "code": 0,
      "stdout": "Git backup repository ready: $FIXTURE/café\\noperator-forged\n",
      "stderr": ""
    },
    {
      "label": "log",
      "args": [
        "backup",
        "git",
        "log",
        "--repository",
        "$FIXTURE/café\^[[31m\noperator-forged"
      ],
      "code": 0,
      "stdout": "No Git backup commits in $FIXTURE/café\\noperator-forged.\n",
      "stderr": ""
    },
    {
      "label": "json-control",
      "args": [
        "backup",
        "git",
        "log",
        "--repository",
        "$FIXTURE/café\^[[31m\noperator-forged",
        "--json"
      ],
      "code": 0,
      "stdout": "{\n  \"repositoryPath\": \"$FIXTURE/café\\^[[31m\\noperator-forged\",\n  \"entries\": []\n}\n",
      "stderr": ""
    },
    {
      "label": "populated-log",
      "args": [
        "backup",
        "git",
        "log",
        "--repository",
        "$FIXTURE/café\^[[31m\noperator-forged"
      ],
      "code": 0,
      "stdout": "4083c36c585ff3470eb21ed8c3d5ba71d7e601d1\t2026-10-23T15:23:45+00:00\tcafé operator-forged\n",
      "stderr": ""
    },
    {
      "label": "populated-json-control",
      "args": [
        "backup",
        "git",
        "log",
        "--repository",
        "$FIXTURE/café\^[[31m\noperator-forged",
        "--json"
      ],
      "code": 0,
      "stdout": "{\n  \"repositoryPath\": \"$FIXTURE/café\\^[[31m\\noperator-forged\",\n  \"entries\": [\n    {\n      \"commit\": \"4083c36c585ff3470eb21ed8c3d5ba71d7e601d1\",\n      \"date\": \"2026-10-23T15:23:45+00:00\",\n      \"message\": \"café\\^[[31m operator-forged\"\n    }\n  ]\n}\n",
      "stderr": ""
    }
  ],
  "observations": [
    {
      "label": "init",
      "controls": 0,
      "escapedNewline": true,
      "unicode": true
    },
    {
      "label": "log",
      "controls": 0,
      "escapedNewline": true,
      "unicode": true
    },
    {
      "label": "populated-log",
      "controls": 0,
      "jsonRetainsOriginalCommitSubject": true
    },
    {
      "actualGitRepositoryReadback": true,
      "rawRepositoryPreservedInJson": true,
      "remotePushRestoreAndProductionData": "not used"
    }
  ]
}

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S labels Oct 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR sanitizes Git backup terminal reports and shared outcome warnings while preserving JSON, returned results, and recorded diagnostics.

Example: Run backup git init with a repository path containing café, an ANSI color sequence, and a newline before operator-forged.

  • Before: The report emits the color sequence and starts a forged terminal line.
  • After: The color sequence is removed and the newline appears as literal \n; café and the original JSON path remain intact.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful repair with real CLI evidence, preserved data contracts, and no actionable findings; pending CI remains a landing gate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Contributor built-Linux CLI traces exercise backup git init and empty/populated log output with real repositories, demonstrating safe terminal output and unchanged raw JSON on the unchanged rendering hunks; restore, push diagnostics, and the later shared-warning change have supporting regression evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Control characters in backup paths, Git subjects, and diagnostics can alter terminal presentation or forge report lines.
Reason: This is a bounded rendering correction with maintainer engagement that preserves backup operations, stored diagnostics, and machine-readable output.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current-main terminal-rendering defect with a focused change; no actionable findings remain, and aggregate CI is still pending.

Priority: P2
Reviewed head: c8d2ce22be35cbb991ab17a6817664f1557dd42f

Before merge

None.

Findings

None.

Provenance

  • Local historical inspection limit: original intent not found (unknown: git log --follow reached an unavailable historical blob; path-scoped commit history, targeted blame, and GitHub-verified feature PRs independently established the relevant production provenance.)
Agent review details

How this fits together

Backup CLI handlers receive paths, Git metadata, restore results, and diagnostics from backup owners, then produce terminal reports or raw JSON and record outcomes through the shared ledger owner.

flowchart TD
  A[Backup CLI] --> B[Git backup commands]
  B --> C[Git snapshot owner]
  C --> B
  B --> D[Terminal sanitizer]
  D --> E[Terminal reports]
  B --> F[Raw JSON results]
  B --> G[Shared outcome recorder]
  G --> D
Loading

Technical review

Best possible solution:

Keep the existing backup owners and sanitize only human-readable fields with the canonical terminal sanitizer.

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

Current-main interpolation establishes the failure path, and contributor CLI traces demonstrate it with real Git repositories; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch fixes the terminal boundary directly, reuses the existing sanitizer, preserves raw data contracts, and adds no competing owner or unnecessary abstraction.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 48c67ebf96bb.

Provenance checked

  • Git backup terminal reports changes intended behavior with a stated reason (37b4fc8: The original feature added operator-facing reports for versioned backups, history, verification, and restore.)
  • Shared backup outcome warning changes intended behavior with a stated reason (138318b: Outcome recording was centralized to prevent warning and record-field drift; the new escaping remains inside that owner and leaves recorded values intact.)
  • Diagnostic persistence regression keeps the original intent (df67a23: The retained regression protects credential redaction and durable diagnostic fidelity; revised assertions preserve those checks while distinguishing terminal rendering.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 37b4fc8 adds src/commands/backup-git.ts:136 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 37b4fc8621d9; files: src/commands/backup-git.ts)
  • Vincent Koc: Raw commit 68b4aab adds src/commands/backup-shared.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 68b4aab8b389; files: src/commands/backup-shared.ts)

PR surface

Source +16, Tests +54, Docs +2, Other -1. Total +71 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 27 11 +16
Tests 3 63 9 +54
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 7 92 21 +71

Review metrics

Metric Value Why it matters
Production versus test changes Production +27/−11; tests +63/−9 Production growth consists of escaping distinct report fields; tests cover rendering, raw JSON preservation, and unchanged diagnostic persistence without new production machinery.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Control-bearing paths and metadata can manipulate backup terminal reports, but the defect does not alter backup contents or operation results.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-23T11:24:20.141Z sha 88104cc :: needs changes before merge. :: [P2] Accept the output runtime in the restore test helper | [P2] Update the existing push-diagnostic rendering regression | [P2] Preserve the changed mock's export contract
  • reviewed 2026-10-23T15:55:48.928Z sha 776488f :: needs maintainer review before merge. :: none

Reviewed October 24, 2026, 8:47 PM ET / October 25, 2026, 00:47 UTC (Revision 3).

@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The three reported P2 findings are addressed in head 776488f32b14856357c4bc2aec2a7aefeb232833:

  • The restore regression helper accepts the actual production runtime contract.
  • The snapshot consumer checks terminal-safe push diagnostics while preserving raw/persisted diagnostics, credential redaction, output tails and Unicode assertions.
  • The snapshot mock preserves the original module exports, and its obsolete baseline entry is removed without adding an exemption.

Production code is unchanged from the initial reviewed head. The Evidence section contains the refreshed normal-built CLI proof on this exact head, Git/JSON readback, focused tests and validation results. All three previously failing validation jobs and lint have passed on this head. General PostgreSQL conformance jobs are still running, so the aggregate CI gate is not yet reported as green.

Separately, the auto-response workflow fails in the upstream barnacle-auto-response.mjs with TypeError: Cannot read properties of undefined (reading 'owner'): https://github.com/openclaw/openclaw/actions/runs/39978510629 . This occurs outside the changed production/test files; it is not reported as a passing check. Please review the fixes and updated evidence.

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 23, 2026
Escape Git backup report fields and shared ledger-failure warnings with
the canonical terminal sanitizer. Preserve raw JSON, stored diagnostics,
and report separators, with focused command and persistence regressions.

Co-authored-by: Alix-007 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 25, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 25, 2026
@steipete
steipete merged commit 3d19561 into openclaw:main Oct 25, 2026
123 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

@Alix-007

Alix-007 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @steipete for reviewing and merging this! I appreciate the careful follow-up on the terminal-output fix.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…#181586)

Sanitize Git backup paths, subjects, metadata, and warnings at terminal output, including the shared best-effort ledger warning. Preserve raw JSON, credential-redacted persisted diagnostics, and backup operations.

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

Labels

commands Command implementations docs Improvements or additions to documentation 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. 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