fix(logs): preserve log tails across short reads#105066
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 12, 2026, 6:26 AM ET / 10:26 UTC. Summary PR surface: Source +21, Tests +32. Total +53 across 2 files. Reproducibility: yes. Current main performs one positional read, while the exact-head real-file proof forces repeated four-byte reads and demonstrates complete output from the shared reader, Gateway handler, and diagnostic export after the fix. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Next step before merge
Security Review detailsBest possible solution: Merge the exact-head shared-reader loop and real-file regression test after routine maintainer review; no alternate implementation, migration, or repair branch is needed. Do we have a high-confidence way to reproduce the issue? Yes. Current main performs one positional read, while the exact-head real-file proof forces repeated four-byte reads and demonstrates complete output from the shared reader, Gateway handler, and diagnostic export after the fix. Is this the best way to solve the issue? Yes. Accumulating reads in the shared bounded reader is the narrowest owner-aligned fix, matches Node's EOF contract and existing repository helpers, and avoids duplicating behavior in each consumer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0350b87f069b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +21, Tests +32. Total +53 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (3 earlier review cycles) |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Land-ready maintainer proof for exact head
Known proof gaps: none for this bounded reliability fix. |
|
Merged via squash.
|
* fix(logs): preserve log tails across short reads * test(logging): track log-tail temp files --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where users reading OpenClaw logs through the CLI, Gateway logs method, or diagnostic support export could receive an incomplete log tail when the filesystem returns a short positional read for the bounded tail window.
Why This Change Was Made
The shared log-tail reader now fills the requested bounded read window before decoding and splitting lines, matching the existing gateway diagnostic tail-reader invariant. This stays local to log-tail read completeness and does not change cursor, reset, truncation, schema, CLI, or UI behavior.
User Impact
Log views and support bundles now preserve the recent log lines available within the configured byte budget even when the underlying file read completes in smaller chunks.
Evidence
024c90fd60070ba0cf2ecef21c1b9d0e07c43c63:readConfiguredLogTail, Gatewaylogs.tail, and diagnostic support export preserve the complete tail while the underlying real log-file reads repeatedly return only four bytes.node --import tsx --input-type=module -wrote a real temporary JSONL log file, wrappedfs.promises.openonly for that file to force four-byte positional reads, imported the current branch modules, calledreadConfiguredLogTail, called GatewaylogsHandlers["logs.tail"], wrote a diagnostic support zip withwriteDiagnosticSupportExport, and inspectedlogs/openclaw-sanitized.jsonlfrom the zip withjszip.{ "head": "024c90fd60070ba0cf2ecef21c1b9d0e07c43c63", "fileBytes": 254, "readStats": { "totalReads": 192, "shortReads": 189, "examples": [ { "requested": 254, "actual": 4, "position": 0 }, { "requested": 250, "actual": 4, "position": 4 }, { "requested": 246, "actual": 4, "position": 8 } ] }, "readConfiguredLogTail": { "lineCount": 4, "cursor": 254, "size": 254, "completeTail": true }, "gatewayLogsTail": { "ok": true, "lineCount": 4, "cursor": 254, "size": 254, "completeTail": true }, "diagnosticSupportExport": { "files": [ "diagnostics.json", "logs/openclaw-sanitized.jsonl", "manifest.json", "summary.md" ], "sanitizedLogMessages": [ { "omitted": "unparsed", "bytes": 11 }, "proof-short-read-one", "proof-short-read-two", "proof-short-read-three" ], "completeTail": true } }node scripts/run-vitest.mjs src/logging/log-tail.test.tspassed with 1 file and 2 tests.git diff --check upstream/main...HEADpassed.src/logging/log-tail.tsandsrc/logging/log-tail.test.ts.AI-assisted: yes. I reviewed the shared reader, Gateway logs handler, diagnostic support export path, focused test, current-head proof, and diff hygiene before refreshing this PR.