fix(scheduler): wire timer→executor bridge so scheduled jobs run (#347)#372
Open
gnanirahulnutakki wants to merge 1 commit into
Open
fix(scheduler): wire timer→executor bridge so scheduled jobs run (#347)#372gnanirahulnutakki wants to merge 1 commit into
gnanirahulnutakki wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Unattended scheduling was inert end-to-end: `ardur schedule create` persisted a job, but nothing ran it. Three disjoint schedule stores existed with no timer→executor bridge — `ardur schedule fire` printed "execution engine not yet wired", and `ProactiveAutomationLoop` (the real, tested executor) had zero callers. Root cause (verified in-tree): - crates/cron `CronScheduler` marks job lifecycle but never reads `job.command` — a lifecycle marker, not an executor. - crates/automation `ProactiveAutomationLoop::fire_due` executes fully (cap-token → FusedRuntime::submit_with_provisioning → deliver → record) but nothing drove it on a clock. - crates/cli `ardur schedule fire` was a dry-run over a store no executor read. Fix (reconcile onto the automation executor; the CLI `<state>/schedules` directory becomes the single durable store that feeds it): - ardur-automation: add `ScheduleDriver` — the missing timer→executor bridge. Ticks `fire_due(Utc::now())` on an interval; `run_bounded` for one-shot/bounded runs, `start`/`stop` for a background driver. - ardur-cli: add `CliScheduleStore`, adapting `<state>/schedules/*.json` to the `ScheduleStore` contract by materializing each record into an executable `AutomationSchedule` at fire time — per-fire it mints a fresh, short-lived, attenuated cap-token and budget top-up (a token minted at create time would expire before a daily job fires) and persists `last_fire_at`/`fire_count` back. Fires run the ordinary fused pipeline and append to the same signed receipt chain a chat turn would. - ardur-cli: `ardur schedule fire <id>` now executes end-to-end; new `ardur schedule run [--interval-secs N] [--max-ticks N]` drives due schedules via `ScheduleDriver`. `ScheduleRecord` moved to the lib with additive serde-defaulted fire-state fields (pre-#347 records load unchanged). Verification: - ardur-automation driver unit tests: a bounded tick and a background start/stop each fire a due schedule. - ardur-cli: schedule_exec unit tests + updated schedule_commands integration test asserting a fire mints exactly one receipt. - New e2e scenario_scheduled_job_execution: a due schedule driven through ScheduleDriver over the real fused runtime mints a signed receipt that verifies under the publishing JWKS. - Live smoke reproduced the issue's exact repro: fire now mints a receipt and bumps fire_count instead of printing "not yet wired". - Affected crates + `cargo test -p ardur-e2e-tests` + fmt + clippy (-D warnings) all green. Checkpoint: architect/sessions/issue-347-scheduler-executor/journal.md Signed-off-by: GR <gnanirn@gmail.com>
gnanirahulnutakki
force-pushed
the
worktree-fix-347-scheduler-executor
branch
from
July 23, 2026 18:29
7f12240 to
f0c79aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #347.
Root cause (verified in-tree, not assumed)
The unattended-execution path was never wired end-to-end. A user could create a schedule and it persisted, but no runtime component ever executed it — three disjoint stores with no timer→executor bridge:
crates/cron/src/scheduler.rs—CronSchedulerspawns a real ticker that flips job statusPending→Running→Completedbut never readsjob.command; it's a lifecycle marker, not an executor, and is instantiated nowhere outside its own crate.crates/automation/src/proactive.rs—ProactiveAutomationLoop::fire_due/fire_scheduleis a complete, tested executor (validate →FusedRuntime::submit_with_provisioning→ deliver → record fire), but had zero callers outside an in-crate test. Nothing drove it on a clock.crates/cli/src/main.rs—ardur schedule firewas an explicit dry-run printingexecution engine not yet wired, over a<state>/schedules/*.jsonstore no executor read.Reproduced live:
ardur schedule create … "every 5 minutes"thenardur schedule fire <id>→note: execution engine not yet wired; no receipt, no run.Fix
Reconcile everything onto the automation executor, and make the CLI
<state>/schedulesdirectory the single durable store that feeds it.crates/automation—ScheduleDriver(newdriver.rs): the missing timer→executor bridge. Owns aProactiveAutomationLoopand ticksfire_due(Utc::now())on a fixed interval.run_bounded(Some(n))for bounded/one-shot inline runs (CLI--max-ticks, tests);start/stop/is_runningfor an always-on background driver. MirrorsCronScheduler's shape but calls the real executor.crates/cli—CliScheduleStore(newschedule_exec.rs): adapts<state>/schedules/*.jsonto theScheduleStorecontract by materializing each persisted record into an executableAutomationScheduleat fire time. Per fire it mints a fresh, short-lived, attenuated cap-token and a per-fire budget top-up (a token minted at create time would have expired by the time a daily job fires days later — so per-fire minting is the only correct design for a durable scheduler), and persistslast_fire_at/fire_countback to the record. Fires run the ordinary fused ten-stage pipeline (cap-token → Cedar → cost admission → provider → signed receipt → journal) and append to the same signed receipt chain a chat turn would. Runtime wiring mirrorsFusedEngine(provider selection + offline stub fallback + persistent keys/policies + file-backed receipt log).ardur schedule fire <id>now executes end-to-end; newardur schedule run [--interval-secs N] [--max-ticks N]drives every due schedule viaScheduleDriver.ScheduleRecordmoved to the lib with additive serde-defaulted fire-state fields, so pre-[Critical] Unattended-execution gap: scheduled jobs are persisted but never run #347 records load unchanged.Security posture preserved: unattended fires require an attenuated cap-token (
validate_schedule); Cedar still governs (a fire under a deny-all policy is denied, exactly like a chat turn); per-fire cap-tokens are 300s and tool-scoped tochat.submit+ memory read/write; the CLI store id is path-traversal-checked.CronScheduleris intentionally left as a lifecycle marker — the automation loop is the single executor. A server-boot adoption ofScheduleDriver::start(sharing the server'sFusedRuntime) is the natural follow-up, deferred to keep this PR scoped to the CLI repro + the reusable bridge.Verification
ardur-automationdriver unit tests — a bounded tick and a background start/stop each fire a due schedule through the executor.ardur-cli—schedule_execunit tests + updatedschedule_commandsintegration test asserting a fire mints exactly one receipt.scenario_scheduled_job_execution— a dueAutomationScheduledriven throughScheduleDriverover the real fused runtime (stub provider) delivers the response, bumpsfire_count, and mints a signed receipt on the on-disk chain that verifies under the publishing JWKS. This is the regression guard: if any half regresses to "persist but never run", it fails.schedule firenow mints a receipt and bumpsfire_count/last_fire_atinstead of printing "not yet wired";schedule run --max-ticks 1fires an always-due schedule and mints a receipt, and correctly does not fire a not-yet-due minute (dedup honored).cargo test -p ardur-automation -p ardur-cligreen;cargo test -p ardur-e2e-testsall binaries green, 0 failures;cargo fmt --checkclean;cargo clippy -p ardur-automation -p ardur-cli --all-targets --all-features -- -D warningsclean.Do not merge — for peer review.