Skip to content

fix(cron): preserve action-critical command output#96358

Closed
Pluviobyte wants to merge 1 commit into
openclaw:mainfrom
Pluviobyte:codex/daily-openclaw-scan-20260624
Closed

fix(cron): preserve action-critical command output#96358
Pluviobyte wants to merge 1 commit into
openclaw:mainfrom
Pluviobyte:codex/daily-openclaw-scan-20260624

Conversation

@Pluviobyte

Copy link
Copy Markdown
Contributor

Closes #96346

Draft safety note: this should stay draft until #95809, or an equivalent cron announce/webhook redaction change, lands. This PR preserves action-critical command output in the stored/interactive summary; current main still sends command summaries to non-interactive delivery paths.

What Problem This Solves

Fixes an issue where users waiting on cron command results could lose one-time setup or authentication instructions when outputMaxBytes tail truncation drops early stdout/stderr lines.

That made device-code flows unactionable: the result could keep filler output while omitting the short code or next-action line needed to complete auth.

Why This Change Was Made

The command runner now uses a small action-critical output classifier for device-login URLs, local callback URLs, setup codes, and explicit next-action instructions. runCommandWithTimeout keeps its existing bounded tail behavior by default, but accepts an explicit bounded preserveOutputLine hook so cron command summaries can include matched earlier lines, the tail, and a run-history recovery hint.

This does not duplicate the non-interactive redaction work in #95809. The PR is intentionally draft until that boundary is covered.

User Impact

Users who run a cron command and wait for the result can still see short auth/setup lines even when later output is large enough to trigger truncation. Output capture remains bounded for ordinary command output.

Evidence

  • Duplicate checks before implementation and again before opening this PR searched open and closed PRs for #96346, the final title, src/cron/action-critical-output.ts, src/process/exec.ts preserveOutputLine, src/cron/command-runner.ts, login.microsoft.com/device, and the recovery wording. No overlapping PR was found; fix(cron): redact command output in delivery #95809 remains adjacent redaction-only work.
  • node scripts/run-vitest.mjs src/cron/command-runner.test.ts src/process/exec.no-output-timer.test.ts
  • node scripts/run-vitest.mjs src/process/exec.test.ts src/cron/run-diagnostics.test.ts src/gateway/server-cron.test.ts
  • node_modules/.bin/oxfmt --check --threads=1 src/cron/action-critical-output.ts src/process/exec.ts src/cron/command-runner.ts src/process/exec.no-output-timer.test.ts src/cron/command-runner.test.ts
  • git diff --check

Known proof gap: no live cron service restart/run was performed in this local environment. The regression coverage uses synthetic device-code output and validates the affected command runner/process capture boundaries.

@clawsweeper

clawsweeper Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 24, 2026, 6:03 AM ET / 10:03 UTC.

Summary
The PR adds cron action-critical output classification, extends runCommandWithTimeout with bounded preserved-line metadata, and formats truncated cron command summaries with preserved lines plus a recovery hint.

PR surface: Source +220, Tests +57. Total +277 across 5 files.

Reproducibility: yes. by source inspection: current main tail-truncates command output before building cron summaries, and the wait/delivery paths consume that summary. I did not run a live cron job because this review is read-only.

Review metrics: 1 noteworthy metric.

  • Outbound delivery sinks: 2 existing unsanitized paths. Cron announce and completion webhook delivery both consume the summary field that this PR would newly enrich with action-critical auth/setup lines.

Stored data model
Persistent data-model change detected: serialized state: src/cron/command-runner.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #96346
Summary: This PR is one candidate fix for the canonical interactive cron command-output preservation issue; related redaction work covers the opposite delivery context and another open PR proposes an alternate implementation path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Land or inline cron announce/webhook redaction before preserving auth/setup lines in summaries.
  • [P1] Add terminal output, logs, or a recording from an actual cron run using fake device-code data, with private details redacted.
  • Update the PR body after adding proof so ClawSweeper can re-review the current head.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists synthetic Vitest and formatting checks and explicitly says no live cron service restart/run was performed, so after-fix real cron behavior proof is still needed with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Merging this branch before cron announce/webhook redaction lands can expose preserved device-code or setup lines to non-interactive recipients that currently receive summary unchanged.
  • [P1] The branch is draft and has overlapping open fix candidates, so maintainers need to choose the canonical shape or sequence before landing.
  • [P1] The contributor supplied synthetic unit/format proof only and explicitly noted no live cron service restart/run was performed.

Maintainer options:

  1. Land delivery redaction first (recommended)
    Merge the related cron announce/webhook sanitizer or inline an equivalent sanitizer before enabling preserved auth/setup lines in cron summaries.
  2. Keep preservation authorized-only
    Change the branch so preserved lines are visible only in authorized run-history or wait output until non-interactive delivery paths are sanitized.
  3. Keep the draft paused
    Leave this PR draft until the redaction boundary and real cron proof exist, or close it if a cleaner canonical PR lands first.

Next step before merge

  • [P1] Maintainer coordination is needed because the safe path depends on sequencing this draft with the redaction PR or choosing the alternate canonical fix, plus contributor real-proof follow-up.

Security
Needs attention: The diff can newly expose preserved auth/setup output through existing unsanitized cron delivery paths.

Review findings

  • [P1] Sanitize delivery before preserving auth lines — src/cron/command-runner.ts:193
Review details

Best possible solution:

Land a combined or sequenced fix that preserves action-critical lines only after cron announce/webhook delivery sanitizes them, with focused tests and one real cron proof.

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

Yes by source inspection: current main tail-truncates command output before building cron summaries, and the wait/delivery paths consume that summary. I did not run a live cron job because this review is read-only.

Is this the best way to solve the issue?

No, not as currently mergeable: preserving action-critical lines is the right repair direction, but this branch must also sanitize or avoid non-interactive delivery before those lines are added to summaries.

Full review comments:

  • [P1] Sanitize delivery before preserving auth lines — src/cron/command-runner.ts:193
    This adds preserved device-code/setup lines to the cron command summary, but current main still sends that same summary to cron announce delivery and completion webhooks without redaction. Please land or inline the delivery sanitizer first, or keep preserved lines out of non-interactive delivery until that boundary is safe.
    Confidence: 0.89

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: The PR addresses a broken cron auth/setup workflow but can leak recovered auth output if merged before delivery redaction.
  • merge-risk: 🚨 security-boundary: The patch can move device-code or setup-token output into unredacted non-interactive cron delivery paths.
  • merge-risk: 🚨 message-delivery: Cron announce and webhook recipients may receive sensitive lines that were previously truncated away.
  • merge-risk: 🚨 compatibility: Existing cron delivery consumers can receive different command-summary content after upgrade, including preserved earlier lines and new recovery text.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists synthetic Vitest and formatting checks and explicitly says no live cron service restart/run was performed, so after-fix real cron behavior proof is still needed with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +220, Tests +57. Total +277 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 229 9 +220
Tests 2 57 0 +57
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 286 9 +277

Security concerns:

  • [high] Preserved auth lines can reach unsanitized delivery — src/cron/command-runner.ts:193
    Device-code/setup lines preserved into summary can be sent through current cron announce and completion webhook paths before the redaction PR lands, widening sensitive-output exposure.
    Confidence: 0.88

What I checked:

  • PR preservation hook: The PR enables preserveOutputLine for every cron command job, so matched device-code/setup lines can be carried into the returned command result. (src/cron/command-runner.ts:193, e996553449a1)
  • PR summary formatting: The PR formats preserved stdout/stderr lines into summary whenever truncation happened, which is the field later used by delivery paths. (src/cron/command-runner.ts:204, e996553449a1)
  • Current announce delivery sink: Current main takes result.summary as message and sends it through sendCronAnnouncePayloadStrict with no sanitizer in this path. (src/gateway/server-cron.ts:457, 8242923fe393)
  • Current webhook delivery sink: Current main posts the finished cron event payload when evt.summary exists, so preserved summary text can leave through completion webhooks. (src/gateway/server-cron-notifications.ts:262, 8242923fe393)
  • Current truncation behavior: Current main keeps only the newest captured bytes once maxOutputBytes is exceeded, which makes the linked issue source-reproducible without the PR. (src/process/exec.ts:255, 8242923fe393)
  • Related canonical issue: The linked issue is open, source-backed, and explicitly describes interactive preservation as the complement to cron broadcast/webhook redaction.

Likely related people:

  • mbelinky: GitHub path history shows feat(cron): support command jobs introduced command-backed cron summaries and process execution integration. (role: introduced behavior; confidence: high; commits: b8adc11977ab; files: src/cron/command-runner.ts, src/process/exec.ts, src/gateway/server-cron.ts)
  • vincentkoc: Local blame attributes the current central cron/process/delivery lines to a recent commit, and GitHub path history shows recent process timeout and cron notification work in the same area. (role: recent area contributor; confidence: medium; commits: 28a90b0e8257, 66b94ba577b8, 28b374a8a7f6; files: src/process/exec.ts, src/cron/command-runner.ts, src/gateway/server-cron.ts)
  • steipete: GitHub path history shows repeated cron gateway routing, notification, and persistence refactors that own the delivery surfaces affected by this PR. (role: adjacent owner by history; confidence: medium; commits: 85148f3b2099, 2bd07eead7e7; files: src/gateway/server-cron.ts, src/gateway/server-cron-notifications.ts)
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-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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 24, 2026
@obviyus

obviyus commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for the fix candidate. We landed the canonical repair in #96393, which preserves bounded action-required cron command output for operator recovery and redacts that material on external delivery paths.

Closing this PR as superseded by #96393 / fc5ba0e.

@obviyus obviyus closed this Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async/cron command results can drop action-critical auth/setup prompt lines during output truncation

2 participants