Skip to content

fix(cron): release admission before continuation cleanup - #135155

Merged
obviyus merged 3 commits into
openclaw:mainfrom
brettdaman:fix/release-cron-admission-before-cleanup
Sep 1, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
brettdaman:fix/release-cron-admission-before-cleanup

Conversation

@brettdaman

@brettdaman brettdaman commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Isolated cron runs could finish successfully while retaining an otherwise unused exact-run continuation session. The Gateway logged Cannot delete session while competing work is in flight because cleanup treated the completed run's own admission as competing work.

Why This Change Was Made

The isolated-run finalizer now disposes the runtime and releases session-work admission before it starts exact-run alias deletion. Browser cleanup remains guaranteed by the outer finalizer.

User Impact

Successful isolated cron jobs no longer retain idle continuation aliases or emit the competing-work cleanup warning.

Evidence

  • Exact current main 2cedaddb5e23848d4358faddcd609afb6570fa94: two real cron add + cron run --wait flows completed successfully, each logged the competing-work warning, and SQLite retained two distinct ready, basePersisted=true exact-run rows.
  • Pre-fix regression: node scripts/run-vitest.mjs src/cron/isolated-agent/run.session-lifecycle.test.ts failed only the cleanup-order assertion (admissionActive=true; 18 passed, 1 failed).
  • Exact head 86a9ec8437a7194c13e7261aa6201f3e55b29365: the same two real Gateway cron flows completed successfully, SQLite retained zero exact-run rows, and the Gateway logged no cleanup warning.
  • Focused head tests: 36 passed across the cron finalizer, run-session identity, and continuation cleanup owners. Targeted Oxlint and git diff --check passed.
  • Production delta: net 0 lines. Tests and test support: +48 lines.

Worked on by

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 8:58 AM ET / 12:58 UTC.

ClawSweeper review

What this changes

The PR releases an isolated cron run’s session-work admission before deleting its idle exact-run continuation alias, and adds regression coverage for that ordering.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open. It fixes a source-proven isolated-cron cleanup ordering bug, and the earlier regression and real-behavior-proof gaps are now addressed; normal exact-head CI remains.

Priority: P2
Reviewed head: 28374ac7e122894da4abb0e7d44a57d1bbee35c0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with a credible red/green ordering regression and corroborating packaged-run evidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The changed production owner is the isolated-cron finalizer in src/cron/isolated-agent/run.ts. The contributor’s redacted packaged-run receipt shows two successful patched runs, zero exact-run alias rows, and zero competing-work warnings, matching the added ordering regression.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The changed production owner is the isolated-cron finalizer in src/cron/isolated-agent/run.ts. The contributor’s redacted packaged-run receipt shows two successful patched runs, zero exact-run alias rows, and zero competing-work warnings, matching the added ordering regression.
Evidence reviewed 7 items Current-main defect: Current main still calls continuation-alias cleanup before releasing the session-work admission, so this PR remains necessary.
Introduced repair: The exact PR patch moves alias removal after release and retains browser cleanup in an outer finally block.
Deletion invariant: The lifecycle deletion owner rejects an active admission not present in the current admission context; the finalizer runs after the execution admission scope, so its own still-active lease is competing work on current main.
Findings None None.
Security None None.

How this fits together

Isolated cron runs hold a session-work admission while executing, then finalize their runtime and session state. The finalizer removes an idle run-scoped continuation alias only after ownership is released, while preserving browser cleanup afterward.

flowchart LR
  A[Cron job] --> B[Isolated run setup]
  B --> C[Session-work admission]
  C --> D[Agent execution]
  D --> E[Finalize runtime]
  E --> F[Release admission]
  F --> G[Remove idle run alias]
  G --> H[Browser cleanup]
Loading

Before merge

  • Complete next step (P2) - The earlier requested regression and real packaged-run proof are present; this PR now needs only normal exact-head CI and maintainer handling.
Agent review details

Security

None.

PR surface

Source +3, Tests +54. Total +57 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 23 20 +3
Tests 2 54 0 +54
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 77 20 +57

Review metrics

Metric Value Why it matters
Production vs test delta production +3, tests/test support +54 The small production increase is necessary finally-block structure to preserve browser cleanup after relocating alias deletion; the rest is focused ordering coverage.

Technical review

Best possible solution:

Merge the owner-boundary ordering repair after exact-head CI passes: release the admission before alias deletion, while retaining the cleaner’s existing media, delivery, and compare-and-set safeguards.

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

Yes in source. Current main keeps the run admission active until after alias cleanup, while the deletion owner treats that lease as competing work; the contributor also supplied matching packaged-run receipts.

Is this the best way to solve the issue?

Yes. The finalizer owns both release and cleanup, and moving release before deletion fixes the conflict without weakening the cleaner’s pending-work or row-identity guards.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 45f155d88a9b.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the isolated-cron finalizer in src/cron/isolated-agent/run.ts. The contributor’s redacted packaged-run receipt shows two successful patched runs, zero exact-run alias rows, and zero competing-work warnings, matching the added ordering regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The changed production owner is the isolated-cron finalizer in src/cron/isolated-agent/run.ts. The contributor’s redacted packaged-run receipt shows two successful patched runs, zero exact-run alias rows, and zero competing-work warnings, matching the added ordering regression.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 session-state: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The PR repairs retained run-scoped continuation aliases and recurring cleanup warnings in isolated cron jobs.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The changed production owner is the isolated-cron finalizer in src/cron/isolated-agent/run.ts. The contributor’s redacted packaged-run receipt shows two successful patched runs, zero exact-run alias rows, and zero competing-work warnings, matching the added ordering regression.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the isolated-cron finalizer in src/cron/isolated-agent/run.ts. The contributor’s redacted packaged-run receipt shows two successful patched runs, zero exact-run alias rows, and zero competing-work warnings, matching the added ordering regression.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vito Cappello: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: 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-01T11:52:37.892Z sha 870ca67 :: needs real behavior proof before merge. :: [P2] Cover exact-run alias cleanup after releasing admission

@brettdaman

Copy link
Copy Markdown
Contributor Author

Redacted packaged-run proof — isolated cron continuation cleanup

Captured on 2026-09-01 from the patched OpenClaw 2026.8.1 package running on the
operator gateway. Private job IDs, session UUIDs, host paths, and infrastructure
identifiers are omitted. The checks were read-only after each run.

Manual run receipts

job=service-uptime
completionStatus=succeeded
durationMs=18794
sessionWindow.status=done
exactRunAliasRows=0

job=homelab-health
completionStatus=succeeded
durationMs=29094
sessionWindow.status=done
exactRunAliasRows=0

exactRunAliasRows counts session_nodes rows whose session_key equals the
exact run key returned by the automation receipt (agent:<redacted>:cron:<redacted>:run:<redacted>).
The stable cron job row is intentionally excluded from that count.

Cleanup-warning check

The gateway journal was searched across the interval containing both manual runs:

window=2026-09-01T11:22:00Z..2026-09-01T11:26:00Z
pattern=Cannot delete session while competing work is in flight
matchCount=0

Direct regression provenance

The focused lifecycle regression supplies a deletable exact-run continuation,
observes admission ownership at alias removal, and records the row as removed only
when the admission is inactive.

patched ordering: PASS — admissionActiveDuringRemoval=false; continuationRowExists=false
old ordering mutation: FAIL — expected admissionActiveDuringRemoval=false, received true

This red/green mutation proves the regression would fail if alias cleanup moved
back ahead of admission release.

@brettdaman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 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 proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 1, 2026
@obviyus

obviyus commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Maintainer verification is complete on 86a9ec8437a7194c13e7261aa6201f3e55b29365.

  • Exact current main 2cedaddb5e23848d4358faddcd609afb6570fa94: two real isolated cron add + cron run --wait flows succeeded but logged the competing-work cleanup error and retained two exact-run SQLite rows.
  • Exact head: the same two flows succeeded with zero exact-run rows and no cleanup warning.
  • Regression: the cleanup-order test failed on exact main (18 passed, 1 failed) and passed on exact head.
  • Local: node scripts/run-vitest.mjs src/cron/isolated-agent/run.session-lifecycle.test.ts src/cron/isolated-agent/run.session-key-isolation.test.ts src/tasks/cron-run-continuation-cleanup.test.ts passed 36 tests; targeted Oxlint and git diff --check passed.
  • Gates: exact-head CI run 33528583428 is green; P0 Autoreview passed with no accepted finding. Local build was not run because this host forbids OpenClaw builds; CI supplied type and build checks.

Production delta is net 0 lines. Tests and test support add 48 lines. The latest ClawSweeper rank-up move required normal exact-head CI, which is complete.

@obviyus
obviyus merged commit 1e93009 into openclaw:main Sep 1, 2026
297 of 298 checks passed
@obviyus

obviyus commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks @brettdaman!

Proof: Two real isolated cron jobs completed through the Gateway on current main and exact head. Before the fix, both retained exact-run rows and logged the competing-work cleanup error. After the fix, both left zero exact-run rows and logged no cleanup warning.

  • Bug: A completed cron run tried to delete its continuation alias while it still held session-work admission.
  • Fix: The cron finalizer now releases admission before exact-run alias deletion while preserving browser cleanup.
Before After
Successful runs retained idle aliases and logged a cleanup warning. Successful runs remove idle aliases without the warning.

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

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

2 participants