feat: add sanitized diagnostics log bundle
Summary
- Add a sanitized diagnostics bundle export flow for the WinUI tray app, including generated debug summary, connection event timeline, tray log tails, structured diagnostics JSONL, crash log, and setup log tails.
- Shift the privacy boundary toward source-side sanitization before logs/diagnostics are written or recorded, with
DiagnosticsExportRedactorkept as defense-in-depth for older/raw export text. - Refactor export redaction away from a broad regex-only approach: parser-style handling now covers private keys, signed handshakes, DPAPI blobs, agent session keys, command-line secret options, sensitive key/value pairs, GUID-like IDs, and common URL/path/token cleanup.
- Improve diagnostics preview/copy readability by decoding common JSON escape sequences like
\u0022and escaped CRLFs before final redaction, while keeping plain Windows paths stable and guarding control/backslash unicode escapes. - Add fail-closed sanitizer-timeout handling for log-tail section sanitization and final full-bundle sanitization so a timeout produces
[REDACTED_SANITIZER_TIMEOUT]instead of aborting export. - Preserve the preview-before-copy/save full diagnostics flow and native Win32 Save dialog for the self-hosted WinUI app.
- Add regression coverage for redaction safety, readability, timeout behavior, split-line/nested secrets, missing files, and diagnostics page copy/preview contracts.
Validation
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter FullyQualifiedName~DiagnosticsExportRedactorTestsdotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --filter "FullyQualifiedName~DiagnosticsBundleBuilderTests|FullyQualifiedName~DiagnosticsPageContractTests".\build.ps1dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restoregit diff --check- Hanselman-style adversarial review completed with Opus + Codex; follow-up fixes added for nested/double-escaped JSON secrets, conservative escape decoding for Windows paths, unicode control/backslash guards, deterministic escaped-CRLF decoding, and additional timeout/readability regression tests.
Codex review: needs real behavior proof before merge. Reviewed June 22, 2026, 3:04 PM ET / 19:04 UTC.
Summary The PR adds a WinUI diagnostics bundle preview/save flow with expanded log tails, log-time sanitization, persisted diagnostics normalization, native Save dialog support, localization updates, and regression tests.
Reproducibility: yes. for the review findings: PR-head source shows raw persisted tail inclusion, silent file rewrites, and unguarded setup-log enumeration, and the PR test asserts a split token remains in the bundle. I did not run tests because this was a read-only review.
Review metrics: 3 noteworthy metrics.
- Changed surface: 27 files, +2102/-192. The PR spans shared sanitization, setup logging, tray UI, Win32 save plumbing, diagnostics services, localization, and tests.
- Included diagnostics sources: 6 source groups. Generated summaries, connection events, tray logs, JSONL, crash logs, and setup logs each need matching redaction guarantees.
- Persisted rewrite entry points: 3 areas. Startup normalization, bundle-build normalization, and chat metadata constructor rewrites all affect upgrade safety before merge.
Merge readiness Overall: π§ unranked krab Proof: π¦ͺ silver shellfish Patch quality: π§ unranked krab Result: blocked until stronger real behavior proof is added.
Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.
Rank-up moves:
- Protect or fail-close legacy persisted tails without mutating user log files.
- Guard setup-log enumeration and remove unapproved startup/cache rewrites or document/test them as a migration.
- Post current-head proof showing seeded fake secrets absent from both preview and saved diagnostics output.
Proof guidance:
- [P1] Needs stronger real behavior proof before merge: Screenshots show the preview/save UI, but they do not prove current-head seeded fake secrets are absent from both the preview and saved diagnostics output; redact private details and update the PR body so ClawSweeper can re-review automatically, or ask a maintainer to comment
@clawsweeper re-reviewif it does not run.
Mantis proof suggestion A desktop proof run would materially help verify the WinUI diagnostics preview/save flow and redaction boundary on current head. A maintainer can ask Mantis to capture proof by posting this exact PR comment:
@openclaw-mantis visual task: verify diagnostics bundle preview and saved file omit seeded fake tokens, setup codes, user paths, IPs, and raw settings.
Risk before merge
- [P1] The shareable preview/save bundle can include raw legacy or multi-line persisted secrets because tails are appended without export-time protection.
- [P1] The PR rewrites existing tray, JSONL, crash, setup, auxiliary log, and chat metadata files during startup/export/cache construction without an explicit migration decision or upgrade proof.
- [P1] Setup-log enumeration can still throw during startup normalization or bundle preview, turning diagnostics collection into an availability problem.
- [P1] The screenshots are insufficient and partly stale relative to current head; they do not prove seeded fake secrets are absent from both preview and saved file output.
- [P1] GitHub reports the PR as draft and conflicting, so final review needs a refreshed mergeable head.
Maintainer options:
- Keep Existing Files Read-Only (recommended)
Preserve source-side sanitization for new writes, but build the shareable bundle from sanitized export copies or fail-closed legacy sections instead of rewriting persisted user files. - Approve A Real Migration
Maintainers could accept persisted-file rewrites only with an explicit migration decision, upgrade tests, and proof that support evidence is not destructively changed. - Pause Until Refreshed And Proven
Because the PR is draft and conflicting, maintainers can leave it paused until the branch is mergeable and the contributor posts current-head seeded-secret proof.
Next step before merge
- [P1] Manual review is needed because the remaining blockers combine privacy-boundary policy, persisted-file migration approval, contributor proof, and a draft/conflicting branch rather than one safe automation repair.
Security Needs attention: The patch introduces a shareable diagnostics bundle path that can still include raw legacy persisted log text without export-time protection.
Review findings
- [P1] Protect persisted tails before sharing β
src/OpenClaw.Tray.WinUI/Services/DiagnosticsLogTailReader.cs:42 - [P1] Keep diagnostics export from rewriting user logs β
src/OpenClaw.Tray.WinUI/Services/DiagnosticsBundleBuilder.cs:291 - [P2] Guard setup-log enumeration failures β
src/OpenClaw.Tray.WinUI/Services/DiagnosticsBundleBuilder.cs:150-154
Review details
Best possible solution:
Land a refreshed branch that keeps log-time sanitization for new writes, protects legacy persisted tails in read-only export copies or fails closed, avoids unapproved local file rewrites, guards enumeration failures, and includes current-head redaction proof.
Do we have a high-confidence way to reproduce the issue?
Yes for the review findings: PR-head source shows raw persisted tail inclusion, silent file rewrites, and unguarded setup-log enumeration, and the PR test asserts a split token remains in the bundle. I did not run tests because this was a read-only review.
Is this the best way to solve the issue?
No; the feature direction is useful, but the current implementation mixes shareable log export with silent persisted-file mutation. The safer path is log-time sanitization plus read-only export protection or an explicit maintainer-approved migration.
Full review comments:
- [P1] Protect persisted tails before sharing β
src/OpenClaw.Tray.WinUI/Services/DiagnosticsLogTailReader.cs:42BuildSectionappends persisted log lines after truncation only, while the bundle manifest says there is no export-time sanitization and the added split-secret test assertssplit-token-secretremains in output. Keep log-time sanitization, but add read-only export protection or fail-closed handling for legacy and multi-line tails before copy/save. Confidence: 0.95 - [P1] Keep diagnostics export from rewriting user logs β
src/OpenClaw.Tray.WinUI/Services/DiagnosticsBundleBuilder.cs:291NormalizePersistedLogFilewrites modified content back to existing tray/JSONL/crash logs, and startup calls the same normalization path. That silently mutates local support evidence during upgrade, so normalize an export copy or make this an explicit maintainer-approved migration with upgrade proof. Confidence: 0.9 - [P2] Guard setup-log enumeration failures β
src/OpenClaw.Tray.WinUI/Services/DiagnosticsBundleBuilder.cs:150-154AppendLatestSetupLogsandNormalizeLatestSetupLogsenumerate setup logs after anExistscheck without catching enumeration failures. If the directory becomes inaccessible, startup normalization or bundle preview can throw instead of reporting a failed diagnostics section. Confidence: 0.86 - [P2] Avoid constructor cache rewrites without migration proof β
src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs:195-198The chat data provider constructor rewrites tool and attachment metadata caches when legacy escaping is detected. Existing chat metadata should stay read-only on load, or this needs an approved migration with upgrade tests. Confidence: 0.78
Overall correctness: patch is incorrect Overall confidence: 0.9
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning high; reviewed against f057db768192.
Label changes
Label justifications:
P2: This is a normal-priority diagnostics export feature with limited blast radius, but it needs privacy, compatibility, availability, and proof fixes before merge.merge-risk: π¨ compatibility: The PR can silently rewrite existing persisted diagnostics logs and metadata caches during startup/export instead of treating existing user files as read-only.merge-risk: π¨ security-boundary: The PR changes how sensitive local diagnostics and persisted logs become a user-shareable bundle, and current head can include raw legacy tails.merge-risk: π¨ availability: The startup/export normalization path can throw on setup-log directory enumeration and block launch or diagnostics preview.rating: π§ unranked krab: Overall readiness is π§ unranked krab; proof is π¦ͺ silver shellfish and patch quality is π§ unranked krab.status: π£ needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Screenshots show the preview/save UI, but they do not prove current-head seeded fake secrets are absent from both the preview and saved diagnostics output; redact private details and update the PR body so ClawSweeper can re-review automatically, or ask a maintainer to comment@clawsweeper re-reviewif it does not run.proof: πΈ screenshot: Contributor real behavior proof includes screenshot evidence. Screenshots show the preview/save UI, but they do not prove current-head seeded fake secrets are absent from both the preview and saved diagnostics output; redact private details and update the PR body so ClawSweeper can re-review automatically, or ask a maintainer to comment@clawsweeper re-reviewif it does not run.
Evidence reviewed
Security concerns:
- [high] Raw persisted tails can leak secrets β
src/OpenClaw.Tray.WinUI/Services/DiagnosticsLogTailReader.cs:42DiagnosticsLogTailReader writes tail lines verbatim, and the branch test asserts split-token legacy text remains in the bundle, so the new sharing flow can expose sensitive data from pre-sanitization logs. Confidence: 0.95
What I checked:
- Repository policy read: AGENTS.md was read fully; its validation guidance was considered, but this review stayed read-only and did not run artifact-producing build/test commands. (
AGENTS.md:1, f057db768192) - Current main does not already implement the richer bundle: Current main's Create diagnostics bundle action still builds CommandCenterTextHelper.BuildDebugBundle, so the PR is not obsolete on main. (
src/OpenClaw.Tray.WinUI/Pages/DebugPage.xaml.cs:459, f057db768192) - Current main redacts existing tray-log bundle lines: Current main redacts tray log lines before placing them in the existing debug bundle, which is the safer existing behavior the PR changes for additional tails. (
src/OpenClaw.Tray.WinUI/Helpers/CommandCenterTextHelper.cs:375, f057db768192) - PR declares source-only export boundary: The PR manifest says the diagnostics bundle includes persisted log text as-is and does not perform export-time sanitization. (
src/OpenClaw.Tray.WinUI/Services/DiagnosticsBundleBuilder.cs:72, 31294a504e74) - Raw persisted tails are appended: DiagnosticsLogTailReader truncates each line and appends it directly, so copied/saved output depends entirely on earlier persistence-time sanitization. (
src/OpenClaw.Tray.WinUI/Services/DiagnosticsLogTailReader.cs:42, 31294a504e74) - PR test confirms a split secret remains: The added test writes a split token into a persisted log and asserts the bundle still contains split-token-secret. (
tests/OpenClaw.Tray.Tests/DiagnosticsBundleBuilderTests.cs:132, 31294a504e74)
Likely related people:
- ranjeshj: Git blame/log ties DebugPage diagnostics wiring, BuildDebugBundle, and chat metadata cache history to commits authored by Ranjesh. (role: introduced current diagnostics/debug bundle structure and recent tray contributor; confidence: high; commits: 9a3a7a6131a8, 429be9ba9368; files:
src/OpenClaw.Tray.WinUI/Pages/DebugPage.xaml.cs,src/OpenClaw.Tray.WinUI/Helpers/CommandCenterTextHelper.cs,src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs) - RBrid: Git blame/log ties TokenSanitizer and current tray-log/diagnostics redaction behavior to recent logging sanitizer work. (role: recent logging sanitizer contributor; confidence: high; commits: 753828f63e96; files:
src/OpenClaw.Shared/TokenSanitizer.cs,src/OpenClaw.Tray.WinUI/Helpers/CommandCenterTextHelper.cs,src/OpenClaw.Tray.WinUI/Services/DiagnosticsJsonlService.cs) - kmahone: A collaborator review comment specifically directed the PR toward log-time sanitization, which is central to the remaining legacy-tail and migration question. (role: current PR reviewer with privacy-boundary direction; confidence: medium; files:
src/OpenClaw.Tray.WinUI/Services/DiagnosticsBundleBuilder.cs,src/OpenClaw.Tray.WinUI/Services/DiagnosticsLogTailReader.cs) - shanselman: The PR discussion raises sanitizer reliability/performance concerns, and current-main history includes nearby hardening work. (role: reviewer and adjacent hardening contributor; confidence: medium; commits: d23f8ca50013; files:
src/OpenClaw.Shared/TokenSanitizer.cs,src/OpenClaw.Tray.WinUI/Services/Logger.cs)
What the crustacean ranks mean
- π¦ challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
- π¦ diamond lobster: very strong readiness with only minor maintainer review expected.
- π platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
- π¦ gold shrimp: useful signal, but proof or patch confidence is still limited.
- π¦ͺ silver shellfish: thin signal; proof, validation, or implementation needs work.
- π§ unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
- π off-meta tidepool: rating does not apply to this item.
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.
How this review workflow works
- 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-reviewcomments, 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-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto 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 explainto ask for more context, or@clawsweeper stopto stop active automation.
ClawSweeper PR egg
π₯ Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress.
Hatch command
Comment @clawsweeper hatch when this PR is hatchable.
Hatchability rules:
- Merged PRs are hatchable.
- Open PRs are hatchable when they are
status: π ready for maintainer look,status: π automerge armed, or labeledclawsweeper:automerge. - Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.
What is this egg doing here?
- Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
- The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
- Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
- The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
- Rarity is just collectible sparkle: π₯ common, π± uncommon, π rare, β¨ glimmer, and π legendary.
Real behavior proof for diagnostics bundle privacy boundary:
- βCreate diagnostics bundleβ opens a preview before log-tail diagnostics can be copied or saved.
- Preview shows sanitized diagnostics/log content with useful context preserved.
- βSave to fileβ opens the native Windows Save dialog.
- Direct βCopy summary debug bundleβ is summary-only and explicitly excludes log tails; log-tail diagnostics require the preview flow.
This direction makes sense for a shareable diagnostics bundle, but the redactor is carrying a lot of regex responsibility in one place. I would not block solely because it uses regex β conservative over-redaction is probably right here β but I think it needs a maintainability/perf pass before merge: group the rules by threat class, consider source-generated regexes or clearly named rule objects, and add a worst-case/perf regression test so a long log line or malformed URL/token cannot cause pathological backtracking. The current test coverage for common secret shapes is good; my concern is mostly long-term maintainability and worst-case behavior.
I took a closer pass on the redaction implementation. The feature is valuable and regex is not inherently the wrong tool for free-form diagnostics, but I think this needs a small reliability/perf cleanup before merge.
Concrete concerns:
-
RegexMatchTimeoutExceptioncan abort the whole export.DiagnosticsLogTailReader.BuildSection()callsDiagnosticsExportRedactor.Sanitize(...), but its catch filter only handles IO/unauthorized/not-supported exceptions. If a regex hits the 100ms timeout on a long/malformed log line, the timeout escapes and the diagnostics export fails. Please catchRegexMatchTimeoutExceptionthere and around the final full-bundleSanitize(builder.ToString())pass inDiagnosticsBundleBuilder.Build()so the bundle can include a sanitization-timeout sentinel instead of failing. -
SlackSigningSecretPatternlooks redundant/dead. It matches exactly 32 hex chars, butHexTokenPatternruns earlier and matches 32+ hex chars, so it should already replace every value that SlackSigningSecretPattern could see. Iβd remove the Slack-specific regex and document/test thatHexTokenPatterncovers that shape. -
KeyValueSecretPatternhas unbounded key-prefix scans before a large alternation. WithMaxLineChars = 8000, a long non-matching key can burn work until the timeout. Consider bounding the key prefix/suffix length, or using a small rule pipeline that parses the key and then checks sensitive-key words outside regex. -
Please add tests for the scary cases: timeout does not abort bundle export, redaction is idempotent, JSON non-string secret values are handled or explicitly documented as a known gap, version strings/IP false positives are documented, and one max-size/perf smoke proves the redactor budget stays reasonable.
Longer-term, because this is net10.0, source-generated regexes ([GeneratedRegex]) or named redaction-rule objects would make this much easier to audit than a flat list of compiled regex fields. I would not block on βregex existsβ, but I would block on timeout handling and at least one worst-case/perf regression guard.
π¦π§Ή ClawSweeper re-review requested.
I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.
Re-review progress:
- State: Complete
- Detail: The targeted re-review finished, the durable review comment was updated, and the synced verdict was routed.
- Run: https://github.com/openclaw/clawsweeper/actions/runs/27370565497
- Updated: 2026-06-11T19:05:01.181Z
@clawsweeper re-review
@christineyan4, take a look at Scott's feedback so that the sanitization is happening at log time instead of cleaning the log at export time.