Skip to content

fix(cron): surface skipped on-exit payloads when jobs are busy - #139987

Merged
steipete merged 1 commit into
mainfrom
codex/qa30-12-cron-exit-admission-20260905
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa30-12-cron-exit-admission-20260905

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where operators watching a command with an on-exit automation could lose the completion payload without a recorded explanation when another invocation of the same job was still running. A manual main-session run could subsequently finish successfully, leaving no indication that the watched command's completion payload was refused.

Why This Change Was Made

The exit handoff discarded the cron service's non-run result and treated a fulfilled callback as an admitted run. It now consumes the typed disposition and passes refusals to the watcher's existing warning path, while preparing the payload and terminal summary in one place instead of using object identity to detect an override.

User Impact

Gateway logs identify the refused on-exit attempt with its admission reason, watched command exit code and termination reason, and a bounded command-output summary. The one-shot stays disabled, and refused work is not queued for replay. Successful firing, normal manual-run admission, existing cancellation and suspension behavior, and run-history semantics stay unchanged.

Evidence

  • Reproduced against b6a2e5b4eff71070a02e755d55aea0dd53904a20: start and hold a manual invocation, let the watched command finish, then release the manual invocation. The actual service returned already-running, the watcher retired, and the manual heartbeat completed successfully without a separate refusal record.
  • All four new regressions failed before the runtime change: real service/watcher cases for active main and isolated runs lacked the warning, and already-running/stopped callback cases incorrectly fulfilled.
  • OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/gateway/server-cron.test.ts src/gateway/cron-exit-watchers.test.ts passed all 145 tests on Node 24.19.0. The suite includes normal payload firing, refusal, drain fencing, explicit disable, handoff/replacement, cancellation, and one-shot restart coverage.
  • An isolated macOS process proof used the real cron service, exit watcher, supervised shell child, and Gateway file logger with a controlled heartbeat dependency. A command exiting with code 3 and watched-done output produced the refusal below; it remained recorded after the manual heartbeat finished successfully. The owned child settled and all temporary state was removed. This was scheduler/process/logger boundary proof, not a live provider or full HTTP/WebSocket Gateway test.
  • Managed independent autoreview returned scoped-clean through P2 with no findings. Formatting and git diff --check passed. Exact-head CI attempt 2 completed successfully, including the retried test shard and openclaw/ci-gate.
cron-exit: fireOnExit after exit failed
Error: cron on-exit run was not admitted: already-running

Watched command finished.
Exit code: 3
Reason: exit

Output:
watched-done

Production changes are +18/-14 (net +4); tests are +103/-4. The four additional production lines provide the typed refusal check and bounded diagnostic evidence after removing the single-use payload helper and its identity sentinel. No queue, retry, configuration, schema, or persistent-state design is added.

The first CI attempt hit a 60-second child-process timeout in the unchanged managed-update handoff test. On the exact CI merge checkout, a private frozen install and the targeted test-runtime build supported the original isolated case: it passed in 2.27 seconds on macOS with the same timeout and journal/tree assertions. One authorized unchanged-head retry then passed in Linux CI. The initial timeout is retained as a historical failure; its Linux/load cause is not claimed fixed. No additional code change or timeout increase was made.

@clawsweeper

clawsweeper Bot commented Sep 6, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 09:34
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 5:39 AM ET / 09:39 UTC.

ClawSweeper review

What this changes

Records a warning with bounded command-completion details when an on-exit automation cannot run, and adds regression coverage for busy and stopped jobs.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary: inspected current main still ignores refused on-exit admission. The patch addresses that gap narrowly, and the supplied process/logger proof supports the intended behavior. No blocking defect was found.

Priority: P2
Reviewed head: 348b948a08dfd8120e894b5e9b7a117ff71e1243

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with relevant process proof and regression coverage; no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): The supplied process proof exercises the real scheduler, exit watcher, supervised shell child, and file logger while a heartbeat is held; the recorded refusal includes exit details and survives heartbeat completion. This directly covers the changed handoff boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The supplied process proof exercises the real scheduler, exit watcher, supervised shell child, and file logger while a heartbeat is held; the recorded refusal includes exit details and survives heartbeat completion. This directly covers the changed handoff boundary.
Evidence reviewed 8 items Current main retains the defect: The fetched main implementation awaits the run callback without inspecting its result, allowing refused admission to appear successful.
Introduced repair: The pinned introduced delta consumes the typed run result and throws a bounded diagnostic on refusal; successful payload preparation remains equivalent.
Refusal and lifecycle ownership: Manual-run preflight returns already-running for an active job. The watcher already catches callback errors, logs the job identity, and releases completion ownership without replaying the command.
Findings None None.
Security None None.

How this fits together

The Gateway watches commands and forwards their completion payloads to the automation scheduler. When admission is refused, this change sends the outcome to the existing Gateway warning log while preserving one-shot retirement.

flowchart TD
  A[Watched command exits] --> B[Watcher retires one-shot]
  B --> C[Scheduler receives completion payload]
  C --> D{Run admitted?}
  D -->|Yes| E[Normal execution and history]
  D -->|No| F[Bounded warning with exit details]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +4, Tests +99. Total +103 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 18 14 +4
Tests 1 103 4 +99
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 121 18 +103

Review metrics

None.

Technical review

Best possible solution:

Preserve scheduler admission and one-shot semantics while recording refused completion handoffs through the existing bounded warning path.

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

Yes, from source: hold a manual job invocation and let its watched command exit; admission returns already-running, which current main discards. The supplied proof exercises this sequence, but this review did not execute it.

Is this the best way to solve the issue?

Yes. Inspecting the existing admission result at the handoff boundary fixes the missing explanation without adding replay, a competing scheduler path, or persistent-state changes.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a bounded automation diagnostic gap when command completion overlaps an active invocation of the same job.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied process proof exercises the real scheduler, exit watcher, supervised shell child, and file logger while a heartbeat is held; the recorded refusal includes exit details and survives heartbeat completion. This directly covers the changed handoff boundary.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 supplied process proof exercises the real scheduler, exit watcher, supervised shell child, and file logger while a heartbeat is held; the recorded refusal includes exit details and survives heartbeat completion. This directly covers the changed handoff boundary.

Label justifications:

  • P2: This repairs a bounded automation diagnostic gap when command completion overlaps an active invocation of the same job.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 supplied process proof exercises the real scheduler, exit watcher, supervised shell child, and file logger while a heartbeat is held; the recorded refusal includes exit details and survives heartbeat completion. This directly covers the changed handoff boundary.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied process proof exercises the real scheduler, exit watcher, supervised shell child, and file logger while a heartbeat is held; the recorded refusal includes exit details and survives heartbeat completion. This directly covers the changed handoff boundary.

Evidence

What I checked:

  • Current main retains the defect: The fetched main implementation awaits the run callback without inspecting its result, allowing refused admission to appear successful. (src/gateway/server-cron.ts:188, f66dc27b5bf7)
  • Introduced repair: The pinned introduced delta consumes the typed run result and throws a bounded diagnostic on refusal; successful payload preparation remains equivalent. (src/gateway/server-cron.ts:195, 348b948a08df)
  • Refusal and lifecycle ownership: Manual-run preflight returns already-running for an active job. The watcher already catches callback errors, logs the job identity, and releases completion ownership without replaying the command. (src/gateway/cron-exit-watchers.ts:297, 348b948a08df)
  • Behavioral regression coverage: The new service/watcher cases hold an active main or isolated run, resolve the watched exit, and verify the warning survives predecessor completion without a second payload invocation; focused callback cases cover already-running and stopped. (src/gateway/server-cron.test.ts:1184, 348b948a08df)
  • Supplied real process proof: The captured PR body, sourceRevision 874a87431beeb1a4af22a257c803692b6deb491f897158baeb74ebc820919862, describes the real cron service, exit watcher, supervised shell child, and file logger with a controlled heartbeat. Its after-fix output records already-running, exit code 3, and watched-done, remaining present after heartbeat completion. It separately reports 145 focused tests passing; these were not rerun during this read-only review. (348b948a08df)
  • Existing logging safeguards: The warning uses the existing child logger; file transport applies structured secret redaction and text redaction before enqueueing the serialized record. The patch bounds terminal evidence to 2,000 UTF-16 units. (src/logging/logger.ts:637, 348b948a08df)

Likely related people:

  • Peter Steinberger: 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.

@steipete
steipete merged commit 8029fcc into main Sep 6, 2026
376 of 378 checks passed
@steipete
steipete deleted the codex/qa30-12-cron-exit-admission-20260905 branch September 6, 2026 11:02
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to ylcn91/openclaw that referenced this pull request Sep 6, 2026
* origin/main: (47 commits)
  ci: record CPU time for Node test jobs (openclaw#140054)
  test(crabbox): consolidate wrapper boundary coverage (openclaw#140058)
  fix(test): keep native filesystem access checks portable (openclaw#140047)
  fix: preserve models when OAuth preparation fails (openclaw#139951)
  feat(update): recover failed updates with bounded repair (openclaw#139495)
  refactor(plugins): share managed npm package traversal (openclaw#140040)
  chore(ui): refresh control ui locales (openclaw#140059)
  refactor(auth): share profile failure state reset (openclaw#140049)
  fix(cron): surface skipped on-exit payloads when jobs are busy (openclaw#139987)
  fix(codex): preserve exec-server WebSocket backpressure under Bun (openclaw#140048)
  fix(agents): ground exec approvals in tool results (openclaw#140043)
  refactor(policy): reuse authored policy value helpers (openclaw#140019)
  docs: keep ClawSweeper status inspection read-only (openclaw#139958)
  fix: reduce task maintenance stalls with large histories (openclaw#140038)
  fix(code-mode): identify unawaited promise output (openclaw#140028)
  fix(test): release memory search fixtures after failed phases (openclaw#140013)
  test(gateway): isolate Serve hello lifecycle fixtures (openclaw#140044)
  fix(microsoft-foundry): bound Entra token retention across accounts (openclaw#127216)
  fix(process): preserve the cause of cleanup observation failures (openclaw#140015)
  fix: clear Side chat when its parent conversation is deleted (openclaw#139974)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
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: 🐚 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.

1 participant