feat(cron): auto-disable usercron jobs on success#818
Conversation
99e406d to
f8d3d16
Compare
OpenAB PR ScreeningThis is auto-generated by the OpenAB project-screening flow for context collection and reviewer handoff.
Screening report## IntentPR #818 tries to let The operator-visible problem: today, a goal-oriented scheduled job can keep running even after it has succeeded, causing repeated agent runs, noise, wasted compute, and possible repeated Discord/thread activity. This PR adds a completion check so a job can prove success and then persist FeatFeature. Behaviorally, It also persists Who It ServesPrimary beneficiary: agent runtime operators and deployers running goal-driven scheduled jobs. Secondary beneficiaries: maintainers and reviewers, because completed recurring work becomes explicit state instead of ambient scheduler behavior. Rewritten PromptImplement goal-completion auto-disable for Add optional disable_on_success = "command"
disable_on_success_match = "required output marker"
disable_on_success_timeout_secs = 120
disable_on_success_working_dir = "/path"Before running the normal cron prompt, execute the completion command when configured. Treat the goal as complete only if the command exits Persist scheduler writebacks atomically where possible, avoid affecting non-usercron config, and add focused tests for success, missing marker, nonzero exit, timeout, missing Merge PitchThis is worth advancing because it closes a real scheduler lifecycle gap: goal-driven jobs need a first-class way to stop themselves after success. Risk profile is moderate. The behavior touches scheduler execution and config persistence, so reviewer concern will likely center on writeback safety, race conditions, TOML preservation, and whether shell-command success checks are too footgun-prone. The PR is directionally useful, but the large Best-Practice ComparisonOpenClaw principles that apply:
Hermes Agent principles that apply:
Implementation OptionsConservative option: merge only the config fields, completion check, and skip behavior, but do not write back Balanced option: keep the PR’s core behavior, but harden writeback. Require stable Ambitious option: introduce a durable scheduler state layer separate from the user-authored TOML. Store job completion, thread routing, run history, retry state, and disable reasons in a scheduler-owned state file or database. This aligns better with OpenClaw/Hermes long-term patterns but is larger than this PR. Comparison Table
RecommendationAdvance the balanced path. The feature solves a concrete lifecycle problem and matches the direction of gateway-owned scheduling, but merge discussion should focus on making persistence boring: stable If the current PR does not already guarantee safe writeback semantics, split that hardening into the required follow-up before merge rather than treating it as optional polish. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
chaodu-agent
left a comment
There was a problem hiding this comment.
Blocking note before merge: the timeout path around disable_on_success does not actually guarantee the spawned command is terminated. Tokio process handles continue running after drop unless kill_on_drop is enabled or the child is explicitly killed/reaped. In check_disable_on_success, timeout(child.output()) drops the output future on timeout and returns NotAchieved, but a long-running command may keep executing in the background. That violates the documented runaway-command mitigation and can leave repeated goal checks piling up. Please switch to explicit spawn + timeout around wait/output with kill/reap on timeout, or set kill_on_drop(true) before output and add a regression test using a long sleep.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
f1ea0fd to
7848a92
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
- update_usercron_job: write to .toml.tmp then rename (atomic on POSIX) - check_disable_on_success: use spawn() + wait_with_output() to retain child handle; explicitly kill on timeout to prevent orphan processes - Add disable_on_success_kills_child_on_timeout test (sleep 999 + 1s timeout)
7848a92 to
0d0959e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
CHANGES REQUESTED 🔴 CI fails due to unused import. Two NITs on correctness. 🔴 SUGGESTED CHANGES1. Unused import breaks CI (clippy -D warnings)
-use tokio::time::timeout;This is the sole cause of the CI 🟡 NIT2. Inaccurate error reason in When -return DisableOnSuccessResult::NotAchieved("command failed to start");
+return DisableOnSuccessResult::NotAchieved("command wait failed");3.
Suggested fix: wrap file I/O in a 🟢 INFO — What works well
Baseline Check
Consolidated review: 超渡法師 + 普渡法師 |
Summary
disable_on_successcompletion checks requiring both exit code 0 anddisable_on_success_matchin output$HOME/.openab/cronjob.tomlby stableid(enabled = falseon success,thread_idafter thread creation)Behavior
[[jobs]]entries in usercron may define:A goal is complete only if the command exits
0and stdout/stderr contains the configured marker. Plain exit0without the marker continues the normal cron prompt.Tests
git diff --checkcargo test cron --lib(cargois not installed in this environment)Discord thread: https://discord.com/channels/1491295327620169908/1504239931940409587