Skip to content

fix(cron): wait for failed run completion in state regression test - #148749

Merged
vincentkoc merged 1 commit into
mainfrom
fix/cron-error-finalization-barrier-20260915
Sep 15, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/cron-error-finalization-barrier-20260915

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

The Cron regression test for an execution error after a delivery-only failure can inspect the previous completed state after the second runner invocation but before that run is finalized.

User Impact

No user-visible runtime change. The regression test checks the completed execution result while retaining its error-count, status, enabled-state, scheduling, and invocation-count assertions.

Why This Change Was Made

Wait for the existing event helper to observe this job's finished event with status: "error" before reading its state. The scheduler applies the committed result to its resident state before publishing that event. Matching the error status excludes the first delivery-only run's successful completion; the helper also observes matching events that already occurred.

The change adds three test lines. Production code, fake-timer advances, timeouts, and assertions are unchanged.

Evidence

  • The original Cron CI failure observed the previous 0/ok state after the second invocation, where the test expected 1/error. The test's invocation-only wait does not establish result finalization.
  • Complete test/event-helper and result-finalization/state-publication paths reviewed; exact-head P2 review found no actionable P0–P2 defect.
  • git diff --check, scoped formatting, and normal commit hooks passed. The reviewed postimage is unchanged after formatting.
  • Normal CI and Workflow Sanity passed on e28943d1307f7c9c51b7442dd0b416773c07b828. Selected type, lint, dependency, guard, and pinned formatter checks passed; build and platform lanes were not selected.
  • The focused Cron job passed all 27 cases in the complete test file, including the repaired second-error case, with no target skips. Its tested merge f7874aead37d38629e5d29cc1282737033788306 contains exactly the reviewed three-line insertion and unchanged assertions. This is fixture and service runtime proof; no live provider behavior is claimed.

@vincentkoc vincentkoc self-assigned this Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@vincentkoc
vincentkoc marked this pull request as ready for review September 15, 2026 03:54
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 15, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 12:23 AM ET / 04:23 UTC (Revision 2).

ClawSweeper review

What this changes

The Cron regression test now waits for the second run’s error completion event before checking its recorded status and error count.

Merge readiness

✅ Ready for maintainer review

The patch correctly synchronizes the regression test with completed state publication without weakening its assertions. Current main still lacks this wait, and the maintainer-authored PR remains useful. No actionable findings remain.

Priority: P3
Reviewed head: e28943d1307f7c9c51b7442dd0b416773c07b828

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correctly ordered test repair with successful focused CI and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored test-only PR; the focused CI job succeeded, and its fixture results are not presented as live-provider proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored test-only PR; the focused CI job succeeded, and its fixture results are not presented as live-provider proof.
Evidence reviewed 7 items Verified introduced change: The pinned merge-base-to-head diff adds only the completion-event wait; existing timer advances, invocation checks, state assertions, and cleanup remain unchanged. The read-only diff whitespace check passed.
Event selection and missed-event protection: The complete test was inspected. Its existing event helper searches previously captured events before registering a waiter. The first run returns status ok despite delivery failure, so the added error predicate uniquely selects the second completion.
Completion follows resident-state update: Finalization commits runtime rows, applies the committed jobs to resident state at lines 211–216, then emits completion events at lines 237–243. CronService.getJob reads that resident state, establishing the ordering needed by the test.
Findings None None.
Security None None.

How this fits together

OpenClaw’s Cron scheduler runs scheduled jobs, commits their results, and publishes completion events. This test checks the recorded state after a delivery failure followed by an execution error.

flowchart TD
  A[Scheduled test job] --> B[First run has delivery failure]
  B --> C[Second run has execution error]
  C --> D[Commit result and update resident state]
  D --> E[Publish error completion event]
  E --> F[Test checks status and error count]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +3. Total +3 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 3 0 +3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 3 0 +3

Review metrics

None.

Technical review

Best possible solution:

Keep the existing completion-event barrier as the synchronization point while preserving all behavioral assertions and production code.

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

Yes, source establishes the race: the runner invocation precedes asynchronous result finalization, while getJob reads resident state immediately. No tests were executed in this read-only review.

Is this the best way to solve the issue?

Yes. Reusing the existing event helper establishes the required completion ordering without retries, longer timeouts, weaker assertions, or production changes.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 261d5c51fb65.

Labels

Label justifications:

  • P3: This is a focused test-reliability repair with no user-visible runtime change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored test-only PR; the focused CI job succeeded, and its fixture results are not presented as live-provider proof.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • holny: 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 (1 earlier review cycle)
  • reviewed 2026-09-15T04:00:00.509Z sha e28943d :: needs maintainer review before merge. :: none

@holny

holny commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

The flake is real — the second waitFor only proves the runner was invoked, while lastRunStatus: "error" and consecutiveErrors get written during finalization of that run, so the assertions can still see the first run's state. Waiting on the finished event with the status: "error" filter pins the ordering the same way the first run's waitFor already does. Looks right to me.

@vincentkoc
vincentkoc merged commit 20f3cf1 into main Sep 15, 2026
174 checks passed
@vincentkoc
vincentkoc deleted the fix/cron-error-finalization-barrier-20260915 branch September 15, 2026 04:23
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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