Skip to content

fix(cron): preserve the final reply after automation self-removal - #138231

Merged
steipete merged 2 commits into
mainfrom
codex/qa-cron-self-removal-v2-20260904
Sep 4, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa-cron-self-removal-v2-20260904

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor
Additional instructions

Maintainers can update this branch through normal repository access; it is in the main repository.

What Problem This Solves

An isolated agent automation that removed its own schedule was canceled before it could return its final result. This contradicted the documented self-cleanup flow and left a failed run in Automations history.

Why This Change Was Made

Bind the existing mutation commit guard to the exact admitted operational instance and active marker. After deletion persists, only that registered, still-live owner may continue; operator removal, expired authority, closed or replaced admissions, copied guards, and replacement markers still cancel. The active marker remains until execution settles, preserving terminal history and deferred session cleanup. No public cancellation option, schema, stored format, configuration, protocol, or migration changes.

The removal owner previously treated every deletion as an operator cancellation. The completion owner now shares its deferred interruption handling, failure projection, empty-webhook outcome, and detached-run abort diagnostics. This change is based on the already-merged timed/unlimited runner refactor and does not duplicate or count that upstream deletion. Production delta: 174 added / 176 deleted (net −2); regression tests: 233 added.

User Impact

Agent automations can remove their completed schedule and still deliver their final result. Removing a running automation as an operator continues to cancel it. The active run retains its normal completion history and cleanup ownership.

Evidence

Validation: four real service/RPC self-removal cases fail on the unchanged base (manual and scheduled runs, with and without a timeout). The corrected change passes 400 focused tests covering admission ownership, operator cancellation, timeout/watchdog behavior, settled webhook delivery, retained history and deferred cleanup; scoped formatting and lint and the complete canonical core/coreTests changed gate also pass. The first broad gate found two test-fixture type errors; the corrected fixture still fails all four original cases on the exact unchanged base and passes against the fix. A normal isolated Gateway using its real built-in agent runtime and a local synthetic HTTP model verifies manual and naturally scheduled self-removal reaches its final result, while a separate operator deletion still aborts. Browser proof uses the actual source Control UI, documented development connection, normal browser device pairing and Gateway RPC; selected screenshots contain only synthetic run data. Original videos remain local because a later sidebar paint includes a host-derived owner display name.

Independent managed review completed in two batches with no accepted actionable P0–P2 findings across their union. The first report was explicitly batch-limited, so it is not presented as a standalone full-diff verdict. The managed scanner withheld one unchanged sensitive-filename validator dataset; its decision was preserved, and the maintainer separately inspected that validator directly. No review scanner or sandbox bypass was used.

A separate script/condition issue was recorded for independent repair: protected own-job tool calls fail before execution because that producer never creates canonical run admission. This change repairs the existing isolated-agent completion owner.

Release-note context: restore documented agent-automation self-cleanup without interrupting the run’s final reply; preserve cancellation when an operator removes a running automation.

The full changed gate passed all 29 checks in 432.74 seconds with unchanged source hashes. Hosted CI on the published commit is required before landing.

Before:

Before: self-removal records an interrupted automation

After:

After: self-removal retains the successful final result

Current head: c3953d899e8fe1f125a4a950b97b8e6b1605b297. The latest ClawSweeper finding and rank-up request are addressed: both ownership associations now live in the existing process-global active-job state, alongside the markers they describe. Reloads before and after guard creation retain the exact owner; closed, aborted, replaced, copied and different-instance paths still reject. Two reload cases failed before the correction while 42 controls passed; the corrected owner and manual-run suites pass all 50 tests.

The final correction was independently reviewed in two complete managed batches with no actionable findings. The final changed gate passed all checks in 590.53 seconds with unchanged source hashes; this supplements the original complete seven-file gate. Five fresh normal-Gateway scenarios pass with eight local synthetic HTTP model requests: manual self-removal, ordinary/status controls, naturally scheduled self-removal and operator cancellation. Both Gateway/provider pairs shut down cleanly. Cross-module reload itself is proved by owner-boundary tests; the normal Gateway proof does not claim a forced runtime hot reload or an external model service.

The maintainer accepts this bounded continuation repair under the requested autonomous QA/landing scope. It preserves the existing authorization predicate, changes no stored format or policy, and keeps operator cancellation intact. Required CI must be green on this exact head before merge.

Current-main review disposition: the latest ClawSweeper review confirms the reload finding is resolved and has no actionable code or security findings. Its current-main request was checked directly: main 068ef71bd20e0b22f92c26364b758551aa13363b composes cleanly with c3953d899e8fe1f125a4a950b97b8e6b1605b297 (tree b67061986bf43f8038ebe4e588b1fd6560195a77), and all seven candidate files remain byte-identical. Eight changed/causal files have no source drift from the original main baseline. A rebase is therefore skipped under the repository's advisory-drift policy; no overlapping cron change was found in this comparison. Required exact-head CI still gates landing. The four incomplete jobs in attempt 1 had no runner execution; the inspected check-dependencies annotation reports that no self-hosted runner acquired the job. The same-source retry is running. No source, assertion, timeout or CI policy was weakened.

Final CI: run 33877721716, attempt 2 passed on c3953d899e8fe1f125a4a950b97b8e6b1605b297. The final PR check rollup is 132 passed and 43 skipped, with zero pending or failing checks. The retry completed the four jobs that had failed to acquire runners; no source change was needed.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 4, 2026

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good boundary. Self-removal is tied to the exact admitted instance and active marker, while operator removal still cancels. The ownership matrix covers the important replacement/expiry cases.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 9:51 AM ET / 13:51 UTC.

ClawSweeper review

What this changes

The PR lets an isolated cron automation delete its own schedule without cancelling its final reply, while retaining cancellation for operator-initiated deletion.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open. The earlier reload-stability finding is addressed, and the patch places the continuation decision at the active-run owner boundary; current main still unconditionally cancels a removed active job. This maintainer-owned, protected PR needs a refreshed merge candidate and green exact-head checks before landing.

Priority: P1
Reviewed head: c3953d899e8fe1f125a4a950b97b8e6b1605b297

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch addresses the prior reload finding with focused boundary coverage and no blocking correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied Gateway and focused regression evidence remains useful supporting material.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied Gateway and focused regression evidence remains useful supporting material.
Evidence reviewed 6 items Current main still has the reported behavior: Current main marks the active job removed and immediately requests cancellation, so it does not yet distinguish self-removal from operator removal.
Continuation is bound to the active admission: The introduced guard matches the exact operational instance, then revalidates caller liveness, admitted-run liveness, current marker, and binding identity before suppressing cancellation.
Gateway entry point supplies the guard only for the current job: The deletion handler installs the self-removal guard only when the caller scope names the job being removed, while the existing commit guard remains the persistence-time authorization check.
Findings None None.
Security None None.

How this fits together

Cron tracks each executing automation with an active marker while the Gateway processes deletion requests. The changed decision determines whether a persisted deletion cancels the run or permits its still-authorized owner to finish delivery and cleanup.

flowchart LR
  A[Isolated cron run] --> B[Active job marker]
  B --> C[Gateway deletion request]
  C --> D[Admission ownership check]
  D --> E[Finish final reply]
  D --> F[Cancel operator removal]
  E --> G[History and cleanup]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - Current main has independently changed overlapping cron paths and the supplied GitHub test merge is stale; refresh the actual merge candidate and require green exact-head checks before merge.
  • Complete next step (P2) - Refresh the merge candidate against current main and obtain green required checks on c3953d8 before merge.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
Agent review details

Security

None.

PR surface

Source -2, Tests +233. Total +231 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 174 176 -2
Tests 2 233 0 +233
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 407 176 +231

Review metrics

Metric Value Why it matters
Production versus regression coverage production +174/-176 (net -2); tests +233/-0 The bug repair is net-negative in production code while adding focused owner-boundary and Gateway execution coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the owner-bound continuation only after the current-main merge candidate proves that authorized self-removal completes while operator deletion still cancels the active run.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the owner-bound continuation only after the current-main merge candidate proves that authorized self-removal completes while operator deletion still cancels the active run.

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

Yes, from source: current main unconditionally cancels the active marker after durable deletion, and the added focused service/RPC cases exercise that exact self-removal path. I did not execute the test suite in this read-only review.

Is this the best way to solve the issue?

Yes. The patch changes the deletion owner’s cancellation decision and revalidates the exact live admission, rather than adding a downstream delivery exception that could weaken operator cancellation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 068ef71bd20e.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied Gateway and focused regression evidence remains useful supporting material.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Cron automations can otherwise lose their final result when removing their own schedule.
  • 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 repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied Gateway and focused regression evidence remains useful supporting material.

Evidence

What I checked:

  • Current main still has the reported behavior: Current main marks the active job removed and immediately requests cancellation, so it does not yet distinguish self-removal from operator removal. (src/cron/active-jobs.ts:167, 068ef71bd20e)
  • Continuation is bound to the active admission: The introduced guard matches the exact operational instance, then revalidates caller liveness, admitted-run liveness, current marker, and binding identity before suppressing cancellation. (src/cron/active-jobs.ts:37, c3953d899e8f)
  • Gateway entry point supplies the guard only for the current job: The deletion handler installs the self-removal guard only when the caller scope names the job being removed, while the existing commit guard remains the persistence-time authorization check. (src/gateway/server-methods/cron.ts:1230, c3953d899e8f)
  • Regression coverage spans manual and scheduled execution: The added service/RPC coverage exercises both run modes with timed and unlimited jobs, asserting successful completion, no abort after self-removal, retained marker until settlement, and deletion of the job. (src/gateway/server-methods/cron.self-removal.test.ts:18, c3953d899e8f)
  • Prior review finding is addressed: The prior finding required reload-stable ownership associations; the exact head stores both WeakMaps in the existing process-global active-job state and adds reload-before/reload-after cases. (src/cron/active-jobs.test.ts:65, c3953d899e8f)
  • Relevant prior cron history: The earlier merged cron cancellation change is attributable to the same area contributor; it is useful routing context, not an asserted causal regression provenance. (src/cron/active-jobs.ts:167, c4dae391833a)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the merge candidate against current main and complete required checks on c3953d8.

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 (3 earlier review cycles)
  • reviewed 2026-09-04T11:55:39.475Z sha 086616c32207ae9418c794a730da635074287093 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-04T12:13:57.734Z sha 086616c32207ae9418c794a730da635074287093 :: blocked before merge. :: [P2] Keep self-removal ownership across module reloads
  • reviewed 2026-09-04T12:36:04.934Z sha f3cbf32 :: blocked before merge. :: [P2] Keep self-removal ownership across module reloads

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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. and removed 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 4, 2026
@steipete
steipete force-pushed the codex/qa-cron-self-removal-v2-20260904 branch from 086616c to f3cbf32 Compare September 4, 2026 12:26
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Sep 4, 2026
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@steipete
steipete merged commit 4a4b397 into main Sep 4, 2026
320 of 325 checks passed
@steipete
steipete deleted the codex/qa-cron-self-removal-v2-20260904 branch September 4, 2026 14:06
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…enclaw#138231)

* fix(cron): let admitted runs finish after self-removal

* fix(cron): retain self-removal owners across module copies
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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