Skip to content

feat(scheduler): add github scheduling backend - #1056

Merged
edenreich merged 3 commits into
mainfrom
feat/github-scheduler-backend
Aug 12, 2026
Merged

edenreich merged 3 commits into
mainfrom
feat/github-scheduler-backend

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Summary

Adds a github scheduling backend (closes #1055): schedules materialize as GitHub Actions scheduled workflows in a repository the user configures — cloud scheduling with zero user-owned infrastructure.

scheduler:
  backend: github
  github:
    repository: ""        # "" => <login>/.routines, created private on first save
    pull_requests: false  # true => deploy via PR instead of pushing to main
    artifacts:
      enabled: true
      poll_interval: 10m
      initial_delay: 1m
      max_attempts: 3
      rate_limit_backoff: 1h

How it works

  • Decorator store (internal/services/githubscheduler.Store): wraps the local ScheduledJobStorage; reads stay local, writes render the job's workflow (.github/workflows/<job-id>.yml) and deploy it — pushed straight to the default branch by default, or via a branch + PR when pull_requests: true. A failed GitHub sync aborts the local save (no phantom jobs).
  • Repo auto-creation: gh repo create <owner>/.routines --private --add-readme on first save when missing. All GitHub access goes through the gh CLI (reusing the githubsetup runner seam).
  • Bot identity: the rendered workflow mints an installation token with actions/create-github-app-token (APP_CLIENT_ID / APP_PRIVATE_KEY secrets, same convention as opentask) and runs inference-gateway/infer-action with github-token + github-app-slug from the step outputs, using the job's prompt as direct-prompt.
  • Cron translation: descriptors are translated to GitHub's 5-field UTC syntax (@daily → 0 0 * * *, @every 10m → */10 * * * *, …); inexpressible ones (@every 7m, * * * * *, sub-5-minute steps) are rejected at save time with a clear error.
  • run_once: renders a final step that disables the workflow after its first fire (App needs Actions read & write).
  • Conversation pull-back: the workflow uploads ~/.infer/conversations/*.jsonl as an infer-conversations-<run_id> artifact; a daemon-hosted poller (mirrors the heartbeat service) downloads new artifacts into local conversation storage — configurable interval (10m), max 3 attempts per artifact, 1h backoff after a rate-limited API call (rate-limited attempts don't consume attempts). Jsonl storage backend only.
  • Daemon: with backend: github the local cron scheduler is skipped; the artifact poller starts instead.
  • The schedule tool surfaces the PR URL (pull_requests: true) and notes that GitHub schedules fire in UTC.

Out of scope (per issue)

Channel delivery of GitHub-backed job output, syncing runs into RunRecords, other cloud backends.

Testing

  • cron_test.go: full translation matrix (descriptors, @every, rejections).
  • workflow_test.go: YAML round-trip with multiline/colon prompts, pins, app-token/upload/self-disable steps.
  • store_test.go: scripted fake runner — exact gh/git sequences for direct-push vs PR mode, repo auto-create, default-repo resolution, cron rejected before any subprocess, gh failure leaves local store unchanged.
  • artifacts_test.go: zip extraction + idempotence, state persistence across restarts, retry-then-give-up, rate-limit backoff semantics.
  • task precommit:run green; full go test ./... green.

Docs

  • docs/scheduling.md: new GitHub backend section (setup, secrets, save-to-deploy flow, artifact pull-back).
  • docs/configuration-reference.md: INFER_SCHEDULER_* env vars.

Schedules materialize as GitHub Actions scheduled workflows in a
configurable repository (default <login>/.routines, auto-created
private). Saves push directly to the default branch, or open a PR when
scheduler.github.pull_requests is enabled. Workflows run the job prompt
via inference-gateway/infer-action under the infer GitHub App bot
identity (APP_CLIENT_ID / APP_PRIVATE_KEY secrets) and upload the run's
conversation jsonl as an artifact; the daemon polls artifacts (default
10m, 3 attempts per artifact, 1h rate-limit backoff, all configurable)
into local conversation storage. Cron descriptors are translated to
GitHub's 5-field UTC syntax or rejected at save time; run_once jobs
disable their own workflow after the first fire.

Closes #1055
@edenreich
edenreich requested a review from a team as a code owner August 12, 2026 18:25
Comment thread cmd/daemon.go Resolved
@edenreich
edenreich merged commit 967d9e2 into main Aug 12, 2026
1 check passed
@edenreich
edenreich deleted the feat/github-scheduler-backend branch August 12, 2026 18:49
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.168.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add "github" scheduling backend - schedules as Actions workflows in a .routines repo

2 participants