Skip to content

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

Merged
drknowhow merged 4 commits into
mainfrom
feat/scheduled-tasks-oracle
Oct 13, 2026
Merged

drknowhow merged 4 commits into
mainfrom
feat/scheduled-tasks-oracle

Conversation

@drknowhow

Copy link
Copy Markdown
Owner

Replaces #217, which GitHub closed when its base branch was deleted on the merge of #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.

https://claude.ai/code/session_01JUcvmQq81aLo9ewD9Xc4qY

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
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
@groyep

groyep Bot commented Oct 13, 2026

Copy link
Copy Markdown

Gro could not finish this review.

@drknowhow
drknowhow merged commit ead8432 into main Oct 13, 2026
12 checks passed
@drknowhow
drknowhow deleted the feat/scheduled-tasks-oracle branch October 13, 2026 15:01
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