Repository navigation
fix(cron): preserve complete JSON when run output is piped - #133661
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 1:46 AM ET / 05:46 UTC. ClawSweeper reviewWhat this changesThe branch defers cron CLI termination to the shared output finalizer so complete JSON reaches piped consumers, and adds process-level regression coverage plus related test updates. Merge readinessNo blocking correctness findings. This PR remains necessary because fetched current main still exits immediately after cron JSON output; the protected maintainer label and incomplete exact-head CI keep it open for normal maintainer handling. Priority: P1 Review scores
Verification
How this fits togetherThe cron CLI calls the Gateway, optionally polls the durable run record, and writes machine-readable results. The top-level CLI finalizer then drains stdout and stderr before terminating the process. flowchart LR
Script[Operator script] --> Cron[Cron CLI]
Cron --> Gateway[Gateway request]
Gateway --> RunLog[Durable run record]
RunLog --> Result[Completed run result]
Result --> Json[JSON output]
Json --> Finalizer[Shared output finalizer]
Finalizer --> Reader[Piped JSON reader]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +135, Docs 0. Total +135 across 14 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge this net-neutral cron owner-boundary repair once the exact PR head has completed its required checks. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main calls synchronous process exit immediately after cron JSON output, and the added process test constructs the reported large OS-pipe case. This review did not execute the test because the checkout is read-only. Is this the best way to solve the issue? Yes. Reusing the established top-level finalizer keeps stream draining and exit ownership in one canonical place; local cron-specific draining would duplicate that lifecycle responsibility. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ffa83609c8cd. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
Merged via squash.
|
…133661) * fix(cron): drain one-shot output before exiting * test(cron): assert deferred validation exit signals * test(tooling): retain heap workloads and reuse PID checks
Related: #133259
What Problem This Solves
Operators piping
openclaw cron run <id> --waitto another process could receive truncated, invalid JSON despite the correct success or failure exit code. A valid 128 KiB run summary reproduced a 65,536-byte cutoff for successful and failed waited runs.Why This Change Was Made
Cron now uses the existing one-shot output finalizer before terminating, including non-waited outcomes and human-error exits. Its error handler preserves
ExitErrorso cleanup and stdout/stderr draining finish without replacing the outcome's diagnostic or exit code. This follows the same output-drain ownership used by Doctor in #133259.The canonical run-log type replaces a redundant partial type. Scheduling, Gateway responses, summary generation, stores, configuration and shared finalizer deadlines remain unchanged. Production is +12/−12 (net zero); tests/support are +283/−148 (net +135) and docs +1/−1.
User Impact
Scripts receive complete waited-run JSON with the original exit status: success remains
0, failure remains1. Queued/not-due outcomes, run history and missing-job diagnostics retain their behavior.Evidence
78851fe3found no actionable findings. Fresh hosted CI for that commit remains pending.Named follow-up: the benchmark's final cleanup wait result is ignored. The diagnostic did not exercise a live group remaining after that wait, and this PR does not change that production owner.
An earlier coordinator Git metadata scan required a 20-to-60-second allowance after Trace2 showed filesystem traversal latency. Product/check deadlines stayed unchanged. A prior gate's separate temporary-cache cleanup was reconciled without repeating the successful checks. Those original failure receipts remain preserved.