Skip to content

feat(schedule): Oracle scheduler loop, approval inbox and /api/schedules - #217

Closed
drknowhow wants to merge 4 commits into
feat/scheduled-tasks-runnerfrom
feat/scheduled-tasks-oracle
Closed

drknowhow wants to merge 4 commits into
feat/scheduled-tasks-runnerfrom
feat/scheduled-tasks-oracle

Conversation

@drknowhow

Copy link
Copy Markdown
Owner

Stacked on #216. Third of the Scheduled Tasks series; after this the Oracle actually fires schedules.

  • services/schedule_approvals.py: pending approvals for autonomy: approval runs. One pending row per schedule, human-only decide, TTL sweep, kind=schedule notifications so the Desk and phone feeds wake.
  • oracle/services/scheduler.py: the tick. Lapse approvals → fold finished jobs → claim_due → misfire window / overlap rule / check_command / autonomy gate → dispatch detached jobs → dispatch approved runs → sweep. Never waits on a job. Takes scheduler.lock; a second Oracle stays in standby.
  • oracle/oracle_server.py builds the stores, starts the scheduler with the Oracle and registers oracle/services/schedule_api.py (/api/schedules/*: CRUD with expected_rev, run now, enable/disable, runs, approvals decide with 409 once lapsed, preview, status, kick).
  • services/shell_jobs.py: JobStore.find(job_id).
  • docs/scheduled-tasks.md.

Two commits: the stores and loop, then the Oracle wiring and routes. 32 tests.

https://claude.ai/code/session_01JUcvmQq81aLo9ewD9Xc4qY

@groyep

groyep Bot commented Oct 13, 2026

Copy link
Copy Markdown

Gro could not finish this review.

services/schedule_approvals.py holds pending approvals for approval-mode
runs (one pending row per schedule, human-only decide, TTL sweep, kind=
schedule notifications). oracle/services/scheduler.py is the tick: lapse
approvals, fold finished jobs (JobStore.find), claim_due, then route each run
through the misfire window, overlap rule, check_command and autonomy gate,
dispatching as detached jobs so the tick never blocks. A kernel-held
scheduler.lock keeps a second Oracle in standby. Not started anywhere yet.
Verified: 21 tests incl. non-blocking dispatch and two-instance standby.

Claude-Session: https://claude.ai/code/session_01JUcvmQq81aLo9ewD9Xc4qY
The Oracle builds the schedule, approval and job stores in _init_services,
starts the Scheduler beside the review agent when scheduler_enabled, and
registers oracle/services/schedule_api.py: CRUD with expected_rev, run now,
enable/disable, runs, approvals decide (409 once lapsed), preview, status,
kick. GETs stay open on loopback like the rest of the local API; mutations sit
behind _local_write_guard. The blueprint's plain functions are what the mobile
gateway and the Hub will call next. docs/scheduled-tasks.md describes the
model and loop. Verified: 11 Flask tests against the real app.

Claude-Session: https://claude.ai/code/session_01JUcvmQq81aLo9ewD9Xc4qY
@drknowhow
drknowhow force-pushed the feat/scheduled-tasks-runner branch from bae6372 to 60bc78c Compare October 13, 2026 14:02
@drknowhow
drknowhow force-pushed the feat/scheduled-tasks-oracle branch from 1186c70 to f328295 Compare October 13, 2026 14:02
Set at import, the key outlived the module and made every later
test_oracle_discovery_api call answer 401.

Claude-Session: https://claude.ai/code/session_01JUcvmQq81aLo9ewD9Xc4qY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant