Skip to content

fix(cron): show skipped automation tasks as failed - #123787

Merged
steipete merged 3 commits into
mainfrom
fix/autoqa-refill-scheduler-outcomes
Aug 14, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/autoqa-refill-scheduler-outcomes

Conversation

@steipete

@steipete steipete commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #123784

Additional instructions

Allow edits from maintainers is enabled. This PR is AI-assisted; the maintainer has reviewed and understands the change.

What Problem This Solves

Fixes an issue where operators inspecting a skipped automation run in Tasks or the Control UI would see it reported as a successful green Completed task, even though cron.runs correctly recorded that the action was skipped with a reason.

Why This Change Was Made

The cron-owned task projector now maps only cron ok to generic task success. Cron skipped maps to the existing failed task state with its authoritative reason, while cron history preserves skipped; the no-history finalizer reuses the same projector instead of maintaining duplicate policy. Timeout classification remains limited to real cron error outcomes, and cancellation and quiet-trigger semantics are unchanged. There are no protocol, schema, config, or storage changes.

User Impact

Skipped automations no longer look successfully completed in task lists, status summaries, or the Control UI. Operators see an unsuccessful task with the actual skip reason and can still inspect the cron-specific skipped outcome in automation history.

Production LOC: +8/-11 (net -3) | Tests: +78/-7

Evidence

  • Regression-first owner proof on the pre-fix implementation failed exactly two assertions: the task rows were succeeded while their cron detail/history was skipped.
  • Review follow-up red proof confirmed two more owner assertions failed because a skipped outcome carrying watchdog-timeout-shaped text projected as timed_out; after the one-line status-precedence repair, the same 24-test owner file passed.
  • Exact-head owner/history proof: node scripts/run-vitest.mjs src/cron/task-run-history.test.ts src/cron/service/task-runs.test.ts — 41/41 passed.
  • Exact-head sibling proof: owner/history plus src/cron/service/ops.test.ts and src/cron/service/timer.regression.test.ts — 176/176 passed, including true watchdog timeouts, one-shot recovery, and removed-job skip outcomes.
  • Isolated Gateway RPC proof: node scripts/run-vitest.mjs src/gateway/server.cron.test.ts -t 'reports skipped isolated cron runs as failed tasks' — the same run reports cron.runs: skipped and tasks.list: failed with model endpoint unavailable. The complete Gateway cron suite also passed 25/25.
  • Real-runtime proof: an isolated process used the actual Gateway cron service and actual isolated-agent model preflight against a closed localhost Ollama port. No runner mock, model request, external channel send, or operator state was involved. The run completed with the same authoritative preflight reason on both surfaces:
{
  "source": "real Gateway cron service + real isolated-agent preflight",
  "runResult": { "ok": true, "ran": true },
  "cronRuns": {
    "status": "skipped",
    "error": "local provider preflight failed ... ECONNREFUSED"
  },
  "tasksList": {
    "runtime": "cron",
    "status": "failed",
    "error": "local provider preflight failed ... ECONNREFUSED"
  }
}
  • Control UI browser proof (mocked Gateway with the real public task shape), captured in one session:

Before — the skipped automation is incorrectly green Completed:

Before: skipped automation shown as Completed

After — the same automation is red Failed with its preflight reason:

After: skipped automation shown as Failed with reason

  • Rebased onto fresh origin/main 3289e08c3005515fb8e49379fd18951ef2530507; targeted formatting and git diff --check passed across the exact six-file patch.
  • Fresh Codex autoreview on exact head 272a6ef1ce79c230f1aab9f95ac34b8b414327d3: clean, no accepted/actionable findings, confidence 0.99.
  • Local check:changed reaches the repository environment-variable ratchet and stops on an inherited current-main baseline (OPENCLAW_* count 504 exceeds budget 502). This PR changes no environment/config surface. Exact-head hosted CI remains the landing authority.

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 14, 2026 18:08
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 3:14 PM ET / 19:14 UTC.

ClawSweeper review

What this changes

The PR changes cron-to-task projection so skipped automations appear as failed generic tasks with their reason while cron history remains skipped.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: current main still marks skipped cron outcomes as successful tasks, while this head repairs both projection paths and resolves the prior timeout-precedence finding. No blocking patch defect was found.

Priority: P2
Reviewed head: 272a6ef1ce79c230f1aab9f95ac34b8b414327d3
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong real-runtime proof and focused owner-boundary coverage support a small, coherent repair.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body includes redacted after-fix terminal output from the actual Gateway cron service and isolated-agent preflight, showing cron.runs: skipped alongside tasks.list: failed with the same reason.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body includes redacted after-fix terminal output from the actual Gateway cron service and isolated-agent preflight, showing cron.runs: skipped alongside tasks.list: failed with the same reason.
Evidence reviewed 6 items Current-main defect: Current main maps both ok and skipped cron outcomes to succeeded, which the task API exposes as completed.
Canonical repair: The PR maps only ok to success; a timeout is retained only for an error outcome with recognized watchdog timeout text, so skipped timeout-shaped reasons remain failed.
Sibling finalization path: The no-history finalizer now preserves non-OK reasons and calls the shared projector, eliminating the duplicate status policy that had also reported skipped work as successful.
Findings None None.
Security None None.

How this fits together

Cron records a terminal outcome in cron history and projects the same run into the generic Tasks ledger. Gateway and the Control UI consume that task record to show operators a completed, failed, or timed-out automation.

flowchart LR
  A[Cron automation] --> B[Terminal cron outcome]
  B --> C[Cron run history]
  B --> D[Shared task projection]
  D --> E[Tasks ledger]
  E --> F[Gateway task API]
  F --> G[Control UI task list]
Loading

Decision needed

Question Recommendation
After exact-head checks complete, should this maintainer-authored cron task-status correction be landed? Land after exact-head checks: Merge the focused owner-boundary fix once required checks are green.

Why: The protected maintainer context requires an explicit human landing decision even though the code review found no remaining repairable blocker.

Before merge

None.

Agent review details

Security

None.

PR surface

Source -3, Tests +71. Total +68 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 8 11 -3
Tests 4 78 7 +71
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 86 18 +68

Review metrics

Metric Value Why it matters
Production versus test LOC production +8/-11 (net -3); tests +78/-7 The bug fix removes duplicate production status policy while adding focused owner, recovery, and Gateway regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #123784
Summary: This PR is the concrete candidate fix for the canonical report about skipped cron runs appearing as completed tasks.

Members:

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

Technical review

Best possible solution:

Land the shared cron-to-task mapping after exact-head CI, preserving cron-specific skipped history while the generic task surface consistently reports the unsuccessful outcome.

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

Yes—on current main, a cron terminal entry with status: "skipped" deterministically projects to internal succeeded, which Gateway exposes as completed. The supplied PR evidence additionally records the failing owner assertions before the repair.

Is this the best way to solve the issue?

Yes—the shared projector is the right owner because normal history, terminal-only, recovery, and migration paths already use it; the PR also removes the duplicate no-history mapping.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This corrects an operator-visible automation status error with limited blast radius and no evidence of data loss, security exposure, or outage.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes redacted after-fix terminal output from the actual Gateway cron service and isolated-agent preflight, showing cron.runs: skipped alongside tasks.list: failed with the same reason.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted after-fix terminal output from the actual Gateway cron service and isolated-agent preflight, showing cron.runs: skipped alongside tasks.list: failed with the same reason.

Evidence

What I checked:

  • Current-main defect: Current main maps both ok and skipped cron outcomes to succeeded, which the task API exposes as completed. (src/cron/task-run-detail.ts:267, 3289e08c3005)
  • Canonical repair: The PR maps only ok to success; a timeout is retained only for an error outcome with recognized watchdog timeout text, so skipped timeout-shaped reasons remain failed. (src/cron/task-run-detail.ts:264, 272a6ef1ce79)
  • Sibling finalization path: The no-history finalizer now preserves non-OK reasons and calls the shared projector, eliminating the duplicate status policy that had also reported skipped work as successful. (src/cron/service/task-runs.ts:323, 272a6ef1ce79)
  • Gateway and UI contract: Gateway maps internal failed to public failed, and the Control UI renders that state as a danger chip while showing its error text. (src/gateway/server-methods/task-summary.ts:18, 272a6ef1ce79)
  • Focused regression coverage: The PR adds an isolated Gateway test that observes the same run as skipped in cron history and failed in tasks.list; owner tests also cover the timeout-shaped skipped reason. (src/gateway/server.cron.test.ts:1635, 272a6ef1ce79)
  • Feature-history provenance: The current-main line blame attributes the original task-projection mapping to the commit that added this cron task-ledger owner; the current contributor also authored that main-history change. (src/cron/task-run-detail.ts:267, f65a6f81de6d)

Likely related people:

  • steipete: Current-main blame attributes the original cron task projection to this author, who also authored the focused repair commits. (role: original task-ledger contributor and recent area contributor; confidence: high; commits: f65a6f81de6d, 709411902b35, 272a6ef1ce79; files: src/cron/task-run-detail.ts, src/cron/service/task-runs.ts)

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 (4 earlier review cycles)
  • reviewed 2026-08-14T18:14:06.983Z sha 77b1d7c37b636b8d5b9f129d30b2267a2839b5c2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-14T18:26:37.081Z sha 77b1d7c37b636b8d5b9f129d30b2267a2839b5c2 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T18:34:49.734Z sha ea34e060f869eb575802e846a3661c5fec580b90 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T18:49:14.904Z sha ea34e060f869eb575802e846a3661c5fec580b90 :: needs changes before merge. :: [P2] Classify skipped before timeout text

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now includes redacted after-fix terminal output from a real Gateway cron service run using the actual isolated-agent local-provider preflight. The run made no model request or external send and proves cron.runs: skipped alongside tasks.list: failed with the same reason.

@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 14, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now includes the requested sanitized Control UI before/after capture. The same Automation card changes from green Completed to red Failed while retaining the local-provider preflight reason. It also retains the real Gateway cron service terminal proof showing cron.runs: skipped alongside tasks.list: failed.

@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
@steipete
steipete force-pushed the fix/autoqa-refill-scheduler-outcomes branch from ea34e06 to 272a6ef Compare August 14, 2026 19:08
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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 14, 2026
@steipete
steipete merged commit 80e046d into main Aug 14, 2026
183 of 184 checks passed
@steipete
steipete deleted the fix/autoqa-refill-scheduler-outcomes branch August 14, 2026 19:42
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
* fix(cron): report skipped runs as failed tasks

* test(cron): align skipped task expectations

* fix(cron): keep skipped tasks failed
tzy-17 added a commit to tzy-17/openclaw that referenced this pull request Sep 14, 2026
…kips

ClawSweeper findings on the prior unconditional skipped->cancelled mapping:

P1: Not every skipped outcome is an intentional no-op. Failed model/cron
preflights, unmet trigger conditions, and released reservations also report
skipped and are real failures; mapping all of them to cancelled reversed the
failed-task reporting contract from openclaw#123787 (the Gateway test 'reports
skipped isolated cron runs as failed tasks' asserts model endpoint
unavailability stays failed). Only a heartbeat no-op skip (error prefixed
'heartbeat skipped:', e.g. empty-heartbeat-file or no-pending-event) maps to
cancelled.

P2: A late skipped outcome must not overwrite an existing operator
cancellation reason. The runner can settle cancelled while the task was
operator-cancelled; the skipped->cancelled mapping then made the finalize a
cancelled-to-cancelled update that the registry accepts, and the skip error
replaced 'Cancelled by operator.'. Finalization now checks the existing
task's cancellation state and keeps the operator reason; the skip reason
still lives in cron history detail.

Tests: heartbeat skip stays cancelled; preflight/trigger failures stay
failed (both verified to fail on the prior mapping); late skipped outcome
preserves the operator cancellation reason (verified to fail on the prior
condition). Full cron suites 128/128 + gateway cron 29/29.
tzy-17 added a commit to tzy-17/openclaw that referenced this pull request Sep 14, 2026
…reasons

Only an empty heartbeat file or a stale wake with no pending events is an
intentional non-execution and maps to a cancelled task. A globally disabled
heartbeat remains a failed task so failure monitors still see it, matching
the existing heartbeat payload contract and the unsuccessful-skip reporting
contract (openclaw#123787).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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.

[Bug]: Skipped automation runs appear as completed tasks

1 participant