Skip to content

fix(logging): report dropped file log records - #132672

Merged
obviyus merged 5 commits into
openclaw:mainfrom
Alix-007:alix/report-log-append-failures-v2
Aug 30, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
Alix-007:alix/report-log-append-failures-v2

Conversation

@Alix-007

@Alix-007 Alix-007 commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

File-log append failures dropped records while flushLogger() still resolved. Operators received no warning that the configured log was incomplete.

This PR is AI-assisted. The implementation and proof were reviewed by maintainers.

Root Cause

The file transport caught and discarded errors from both the asynchronous appender and the forced-exit synchronous appender. Only this transport can observe whether the real append succeeded.

Fix

The file transport now writes a direct stderr warning for the first dropped record in each file's continuous failure streak. It clears only that file's warning state after a successful append. It also bounds retained failure paths and emits one saturation warning when the bound is reached. Forced-exit drains use a synchronous stderr write so piped diagnostics survive process.exit().

The direct stderr sink avoids console.warn() recursion into the same failed file transport. If stderr itself throws, the transport continues and retries the warning after the next dropped record. The warning tells the operator to check that the target is a writable regular file.

Queue ordering, retry policy, flush settlement, and process-exit rescue behavior are unchanged.

Production Shape

  • Owner: src/logging/logger-file-transport.ts.
  • Modes: append success persists and rearms that file; first failure warns; repeated same-streak failures use the prior warning; another file has independent state; saturation is bounded.
  • Production delta: +58/-9, net +49.
  • Test delta: +138/-6, net +132.
  • The positive production delta is the bounded per-file owner state and the shared non-recursive warning sink used by both append paths.

Evidence

The same production entry was run with a real directory as the invalid log target and a real file as the control target.

Exact current main c5c6199bc8592c988738480164a2950b920f6b39:

{"failedTargetType":"directory","failedRecordPersisted":false,"flushResolved":true,"appendFailureDiagnostic":false,"warningCount":0,"controlPersisted":true}

Exact repaired head 2a69e5853dffc46c7642fd8c10ffa73fc4094ebf:

{"failedTargetType":"directory","failedRecordPersisted":false,"flushResolved":true,"appendFailureDiagnostic":true,"warningCount":1,"pathSecretRedacted":true,"controlPersisted":true}

Observed warning:

[openclaw] log file append failed; record dropped; check that the path is a writable regular file

Exact repaired-head forced-exit trace with piped stderr and a deferred stream write:

{"sha":"2a69e5853dffc46c7642fd8c10ffa73fc4094ebf","exitStatus":0,"stderrPiped":true,"streamWriteDeferredPastExit":true,"appendFailureDiagnostic":true,"pathSecretRedacted":true,"warningCount":1}

Validation

  • Final warning regressions on exact current-main production: 5 expected failures because no warning was emitted.
  • Piped-exit regression on the prior asynchronous-warning head: 1 expected failure because stderr was empty.
  • Logger owner and sibling tests: 46 passed.
  • oxfmt --check and type-aware oxlint: passed.
  • git diff --check: passed.

Integration Checks

  • Current main and the pre-rebase main have identical file-transport and logger owner blobs.
  • The branch was rebased after current main repaired an unrelated missing export.
  • @openclaw/fs-safe 0.5.6 propagates non-file and append errors to the transport catch.
  • No equivalent open repair was found.
  • The prior ClawSweeper request for current-main and dependency-source evidence is satisfied above.

ClawSweeper

  • Exact-head review: patch correct, zero findings, security cleared, zero rank-up moves.
  • Production growth decision: accept net +49 lines. The file transport needs bounded per-target state, one redacted non-recursive sink, and synchronous exit output. Removing any part restores silent loss, unbounded retention, recursion, or dropped exit diagnostics.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. 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. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 3:44 AM ET / 07:44 UTC.

ClawSweeper review

What this changes

The PR adds bounded, per-file redacted stderr warnings when file-log records are dropped, including synchronous diagnostics while pending records are drained during process exit.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

The patch addresses a real silent logging failure at the file-transport owner and the supplied real-path traces cover both normal append failure and forced exit. No introduced correctness defect was found; retain this PR for normal exact-head CI and maintainer merge review.

Priority: P2
Reviewed head: 2a69e5853dffc46c7642fd8c10ffa73fc4094ebf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, behaviorally proven on its two changed paths, and backed by targeted owner-boundary regressions.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed production owner is the file transport’s append catch and forced-exit drain; the reviewed exact-head terminal traces use a real directory target and a piped stderr path, showing the new warning appears, the dropped record remains absent, the control file persists, and the target-path secret is redacted.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed production owner is the file transport’s append catch and forced-exit drain; the reviewed exact-head terminal traces use a real directory target and a piped stderr path, showing the new warning appears, the dropped record remains absent, the control file persists, and the target-path secret is redacted.
Evidence reviewed 6 items Failure owner and caller: The logger serializes and redacts a record, then passes its resolved file target to the file transport; the transport is therefore the boundary that can observe an append result.
Current-main baseline: The PR base caught append errors in both async and synchronous drains without a diagnostic, while continuing later entries; the introduced catch now calls the warning owner.
Bounded redacted warning path: The introduced helper redacts the complete diagnostic before formatting, tracks one warning per failing file, and shares the sink across async and exit-time drains.
Findings None None.
Security None None.

How this fits together

OpenClaw’s logger serializes application records into a bounded file queue. The file transport appends those records to the configured log target and now reports append failures to stderr without recursively using the failed file transport.

flowchart LR
  A[Application log record] --> B[Logger transport callback]
  B --> C[Bounded file queue]
  C --> D[File append]
  D -->|success| E[Configured log file]
  D -->|failure| F[Per-file failure state]
  F --> G[Redacted stderr diagnostic]
  G --> H[Operator action]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by 49 net lines for a bug fix. The shared warning sink and bounded per-file state serve both append paths; no smaller net-neutral form was evident without duplicating the sink or dropping bounded failure tracking.
Agent review details

Security

None.

PR surface

Source +49, Tests +132. Total +181 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 58 9 +49
Tests 1 138 6 +132
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 196 15 +181

Review metrics

Metric Value Why it matters
Production versus test delta production +49 net; tests +132 net The added production state and shared diagnostic sink cover both runtime append paths, while the tests exercise recovery, target isolation, redaction, saturation, and forced exit.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the warning state at the file-transport owner, with one redacted sink shared by asynchronous writes and forced-exit draining; the bounded state and shared sink justify the added production code.
  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 warning state at the file-transport owner, with one redacted sink shared by asynchronous writes and forced-exit draining; the bounded state and shared sink justify the added production code.

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

Yes. The reviewed exact-base and exact-head directory-target traces exercise the production logger path: the baseline drops the record with no warning, while the head emits one redacted warning and preserves a control-file write.

Is this the best way to solve the issue?

Yes. The file transport is the sole owner that knows whether the real append succeeded, so recording the failure streak there avoids downstream inference and prevents recursive logging through the failed target.

AGENTS.md: found and applied where relevant.

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

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 changed production owner is the file transport’s append catch and forced-exit drain; the reviewed exact-head terminal traces use a real directory target and a piped stderr path, showing the new warning appears, the dropped record remains absent, the control file persists, and the target-path secret is redacted.
  • 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.
  • remove merge-risk: 🚨 other: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This repairs operator visibility when a configured file log silently drops records, with a limited logging-surface blast radius.
  • 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 changed production owner is the file transport’s append catch and forced-exit drain; the reviewed exact-head terminal traces use a real directory target and a piped stderr path, showing the new warning appears, the dropped record remains absent, the control file persists, and the target-path secret is redacted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the file transport’s append catch and forced-exit drain; the reviewed exact-head terminal traces use a real directory target and a piped stderr path, showing the new warning appears, the dropped record remains absent, the control file persists, and the target-path secret is redacted.

Evidence

What I checked:

  • Failure owner and caller: The logger serializes and redacts a record, then passes its resolved file target to the file transport; the transport is therefore the boundary that can observe an append result. (src/logging/logger.ts:641, 2a69e5853dff)
  • Current-main baseline: The PR base caught append errors in both async and synchronous drains without a diagnostic, while continuing later entries; the introduced catch now calls the warning owner. (src/logging/logger-file-transport.ts:214, f1d2c5b91f80)
  • Bounded redacted warning path: The introduced helper redacts the complete diagnostic before formatting, tracks one warning per failing file, and shares the sink across async and exit-time drains. (src/logging/logger-file-transport.ts:110, 2a69e5853dff)
  • Regression coverage: The changed tests cover a recovered failure streak, independent file targets, redaction, stderr-write rejection, saturation release, and a piped forced-exit case with deferred stream writes. (src/logging/logger-file-transport.test.ts:117, 2a69e5853dff)
  • Real behavior evidence: The reviewed PR body records an exact-head directory-target run where the record remains absent, flush resolves, one append-failure warning is observed, the configured path secret is redacted, and a control file persists; it also records a piped forced-exit trace with the warning present after a deferred stderr-stream write. (2a69e5853dff)
  • Feature history: Local history identifies the existing asynchronous file-transport work and its exit-listener follow-up. Promisor history could not retrieve older objects after the available local records, so this is routing evidence rather than verified line-introduction attribution. (src/logging/logger-file-transport.ts:188, 1cbbda18c390)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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 (5 earlier review cycles)
  • reviewed 2026-08-29T15:34:26.442Z sha f07f42433ffb1379a7fd3cb404464e2b849b3ad1 :: needs changes before merge. :: [P2] Track append-failure streaks per file target
  • reviewed 2026-08-29T16:52:05.137Z sha d71b7a57c21f92f3a0ab16c8d147eeab4128a052 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T07:05:32.435Z sha a3bbddf3fd2c6e9042fda27a316f31d9a82f307b :: needs changes before merge. :: [P2] Write forced-exit diagnostics synchronously
  • reviewed 2026-08-30T07:16:09.180Z sha 9524c65f34c78f6123c628ed2fe90f77b470ff72 :: needs real behavior proof before merge. :: [P2] Write forced-exit diagnostics synchronously
  • reviewed 2026-08-30T07:27:26.095Z sha 813ed5ec0818a86c808542c1383c533a3557755b :: needs real behavior proof before merge. :: [P2] Preserve async append warnings across immediate exit

@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 29, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 30, 2026
@clawsweeper clawsweeper Bot added 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. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 30, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 30, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 30, 2026
@clawsweeper clawsweeper Bot removed the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Aug 30, 2026
@obviyus
obviyus force-pushed the alix/report-log-append-failures-v2 branch from 813ed5e to 2a69e58 Compare August 30, 2026 07:37
@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. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 30, 2026
@obviyus
obviyus merged commit 4b65ebd into openclaw:main Aug 30, 2026
274 checks passed
@obviyus

obviyus commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Alix-007!

Proof: A real directory log target dropped its record on current main without a warning. The repaired exact head emitted one redacted warning, preserved the valid control record, and kept the warning visible through piped stderr during forced process exit.

  • Bug: File append errors were swallowed while flushLogger() still resolved, so operators could trust an incomplete log.
  • Fix: The file transport now emits bounded, redacted warnings and uses synchronous stderr output during forced exit.

Example

Before After
Record dropped; flush resolved; no warning Record dropped; flush resolved; one actionable redacted warning

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
Report dropped file-log records at the transport owner so append failures no longer disappear silently.

- Bound and isolate warning state per log target.
- Redact configured paths before direct stderr output.
- Write forced-exit warnings synchronously so piped diagnostics survive.

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

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

2 participants