Repository navigation
fix: keep older Run Now attempts from clearing newer runs - #2082
shanselman wants to merge 2 commits into
Conversation
Give each Run Now attempt its own token and require matching run identity before a timeout or history entry clears the running state. Avoid timeout-triggered uncorrelated cron refreshes. Co-authored-by: Copilot App <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR gives each Run Now attempt its own token so older callbacks and unrelated history cannot clear a newer run. Example: Job job-1 starts run A at 0 seconds, finishes at 10 seconds, and starts run B at 20 seconds.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this collaborator-authored PR addresses a source-confirmed race still present on main; no introduced correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherCronPage sends manual-run requests through OpenClawGatewayClient and combines acknowledgements, history, job-list updates, and timers to control running indicators and job actions. flowchart TD
A[Run Now button] --> B[CronPage]
B --> C[Gateway client]
C --> D[Gateway cron service]
D --> E[Acknowledgements and history]
E --> B
F[Per-run token and timer] --> B
B --> G[Running indicator and actions]
Technical reviewBest possible solution: Keep per-run identity and completion checks under CronPage's existing UI-thread ownership. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the A-completes/B-starts/A-times-out sequence; no live reproduction was run during this read-only review. Is this the best way to solve the issue? The focused token registry addresses stale callbacks directly, and exact RunId matching prevents timestamp-based miscorrelation; the author explicitly accepts the conservative ID-less fallback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e70292487958. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 8, 2026, 4:59 AM ET / 09:59 UTC. |
|
Hi @karkarl! I'm a Copilot triage bot posting for Scott (I'm not Scott). He asked me to assign this PR to you and see if you'd be up for reviewing it and merging it when you're happy with it. This is one of five small fixes from the state machine audit in #2071 (Fix dangerous implicit state machines (audit lanes)). This one stops an older Run Now timeout or stale history entry from clearing the running indicator for a newer run of the same cron job. CI note: all UI tests passed (653 passed, 7 allowed skips), but the job then failed on an HTTP 504 while downloading a compatibility archive. That looks like a temporary infrastructure hiccup, so a rerun will probably turn it green. No rush at all, and please feel free to ask for changes or push back. Thank you so much! |
PR cleanup reviewReviewed head: Source cleanup review at 079b18d against main e59374c: the per-attempt token and server run-ID checks are not in main and address the stale-callback race without adding timeout polling. The failed CI job reached 653 passing UI cases and 82 passing fixture cases, then failed downloading the stable archive with HTTP 504, so a targeted rerun is justified. The remaining custom-proof gap is an accepted A/B overlap with stale A completion/timeout while B is running; the added native rejection case does not demonstrate that sequence. Action in this cleanup pass: leaving this PR open. No branch changes or runtime-proof waiver. The findings above come from source, discussion and recorded-CI review; Windows validation was not rerun in this pass. |
|
Hi! I'm a Copilot triage agent posting for Scott (I'm not Scott). I was doing a landing pass and checked this PR against current What I found
What I did not verify
Suggestion for the owner (no pressure) This looks superseded by #1893 (feat(automations): native Automations page with web parity). If you agree, this PR and its issue #2076 (Give the cron Run Now safety timer a per-run token; lane 5 of #2071, Fix dangerous implicit state machines (audit lanes)) could be closed as obsolete. If you'd like proof first, one small store test for the old-watcher timeout would settle it. |
Retain the main AutomationsStore owner and its invocation identity guards. Port the distinct ID-less timeout and rejected Run Now regressions to the current test owners instead of restoring deleted CronPage logic. Co-authored-by: bkudiess <[email protected]>
|
Closing this as superseded by #1893 (feat(automations): native Automations page with web parity). The original fix ( After the latest merge from Thanks @shanselman for the original fix and the regression case. Related: #2071. |
Closes #2076
Related: #2071
What Problem This Solves
Fixes: an earlier Run Now timeout or stale run-history entry can clear the running indicator for a later run of the same job.
User Impact
User impact: An earlier run cannot clear the running indicator for a newer Run Now. For a legacy accepted acknowledgement without a RunId, history cannot safely complete the indicator; the page waits for an independent job-list update or the token-owned safety timeout.
Why This Change Was Made
Each Run Now now has a distinct in-memory token. The 90-second continuation dispatches to the UI thread, verifies that its token is still current, and clears only that run. History completion requires an exact RunId match; runAtMs (execution start) and ts (completion/end record) do not identify an invocation. The timeout no longer requests an uncorrelated cron.list or cron.runs refresh. The separate remove/disabled-job behavior in #2032 is untouched.
Evidence
079b18dce43b8fd07d4fffc52913d194a3b84c7cbased one70292487958be9e70170e2f3affe7afc42056e8; the candidate diff SHA-256 before commit was02D60C7D14F095D7A7A6B23D7833A1DCBD0794B3B1BB90B0EA98F876E1DCE095and the source fingerprint was unchanged across final validation.IsCurrentRunto the vulnerable job-only token-presence check, then randotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --filter FullyQualifiedName~CronRunningLatchTests.StaleRunToken_DoesNotMatchNewerRunForSameJob. It failed atCronRunningLatchTests.cs:16:Assert.False()expectedFalse, actualTrue(1 failed, 0 passed). Restored the per-run identity implementation; final focusedCronRunningLatchTestsandCronPageContractTestsrun passed 10/10. This is a pre-fix-equivalent mutation, not a run against the historical base checkout.scoped-clean, no findings. Independent rubber-duck review: no blocking findings; verified the conservative RunId requirement and timestamp limitation.cron.runwithFIXTURE_READ_ONLYand does not implementcron.runs.Change Type
Scope
winnodeRequired proof pools
windows-winui-interactive: the Run Now running-state ownership is user-visible; the fixture test covers rejection only, so current-head interactive A/B timeout/history proof is still required and is not claimed here.Validation
.\build.ps1- passed; all build targets succeeded.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --filter 'FullyQualifiedName~CronRunningLatchTests|FullyQualifiedName~CronPageContractTests'- 10 passed, 0 failed, 10 total.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore- 4,876 passed, 24 skipped, 4,900 total.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore- 5,300 passed, 0 failed, 5,300 total on the final rerun.dotnet test .\tests\OpenClaw.Tray.UITests\OpenClaw.Tray.UITests.csproj -c Debug -r win-x64 -p:Platform=x64 -p:DevBuild=false --no-restore --filter 'FullyQualifiedName~CronRunNow_FixtureRejectionRestoresTheRunAction'- 1 passed, 0 failed, 1 total.ActivationRouterTests.MigrationShutdown_UsesCurrentUserIpcWithoutCreatingADeepLinkRoutetimeout. The exact test rerun passed 1/1, and the final full Tray rerun passed.git diff --check- passed.Real Behavior Proof
079b18dce43b8fd07d4fffc52913d194a3b84c7c; the exact candidate source was validated before commit and its fingerprint remained unchanged.FIXTURE_READ_ONLY, then the test verified the Run Now button was enabled again.Yes/No/N/A):N/Acron.runand does not implementcron.runs, so the live A/B completion/history/timeout sequence cannot run without fixture work outside this issue.Security Impact
Yes/No):NoYes/No):NoYes/No):Yes, the 90-second timeout no longer issues uncorrelatedcron.listorcron.runsrequests.Yes/No):NoYes/No):NoYes, explain the risk and mitigation: The change removes the uncorrelated timeout-triggeredcron.listandcron.runsrequests. It adds no network surface; the UI now clears only for the current per-run token or an exact RunId match, preventing a stale response from clearing a newer run.Compatibility and Migration
Yes/No):Yes, with legacy ID-less history intentionally not used to complete a run.Yes/No):NoYes/No):NoReview Conversations