Schedules

A schedule runs one skill on a clock: a digest every morning, a dependency review every Monday. This page covers where schedules are defined, the cron syntax kōjō accepts, exactly when a schedule fires, and how a scheduled run differs from one a person triggered.

A wall clock with orange hands, wired to a small machine under a conveyor. A wall clock with orange hands, wired to a small machine under a conveyor.
A schedule starts a skill on the clock, with nobody asking.

Where schedules live

A schedule belongs to a scope, and there are two kinds:

Scope Defined in Runs on
A repository .factory/schedules.yaml on that repository’s default branch That repository.
The org The dashboard, a chat approval, or kojo config apply Every enabled repository, or the ones listed in repos.

Both end up as the same runtime config object, schedules, which the scheduler reads. See Schedules as runtime config.

No schedule exists on a new install. The org’s list is seeded empty.

schedules.yaml

.factory/schedules.yaml holds a repository’s recurring jobs.

schedules:
  - name: daily-digest
    cron: "0 8 * * 1-5"
    timezone: Europe/Madrid
    skill: daily-digest
    notify: C0123456789
  - name: weekly-dependency-review
    cron: "0 9 * * 1"
    timezone: Europe/Madrid
    skill: dependency-review
    prompt: Apply patch and minor upgrades only.
  - name: flaky-tests
    cron: "@weekly"
    skill: flaky-test-hunt
    enabled: false
Key Type Required Default Meaning
name string yes Identifies the schedule within its scope. Must be unique in the file.
cron string yes When to run. See Cron syntax.
timezone string no UTC An IANA zone name such as Europe/Madrid. See Time zones.
skill string yes The skill to run.
prompt string no Scheduled run of <skill>. Extra instruction for each run. It is the text of the request.
repos list of strings no every enabled repository The repositories an org-level schedule runs on, as forge/owner/name. Ignored in a repository’s own file.
notify string no The chat channel that gets the result: a channel ID, or surface:channel (mattermost:town-square, discord:<channel id>, teams:<conversation id>) when more than one chat surface is configured. A bare ID goes to the only configured surface.
enabled boolean no true false keeps the schedule defined but stops it from firing.

The JSON Schema is schedules.schema.json; kojo schema schedules prints it. It checks keys and types, not cron expressions. No CLI command validates this file; kōjō validates it when it reads it.

Rules the loader applies:

  • The document is a schedules: list. Unknown keys are rejected. A bare top-level list of schedules is also accepted.
  • name, skill and cron are required, names must be unique, and cron and timezone must parse.
  • Whether skill exists is not checked when the file is read. A schedule that names a skill the repository cannot resolve fires a session that fails with skill "<name>" is not available.

kōjō reads the file from the default branch on a push webhook for that branch and before a session of that repository starts. It copies the content into the repository’s config scope as a new revision, authored git:<commit>. From then on the file is the owner of that scope’s schedules: each sync replaces what the scope holds with what the file says. A file that was pushed before the repository was enabled is picked up at the next push to the default branch or the next session on the repository.

Removing the file stops the schedules that came from it. Breaking it does not: a schedules.yaml that does not parse or validate changes nothing, and the schedules of the last good version keep running. The error is reported as the problem repo/schedules.yaml in kojo skills list --repo <id>.

Cron syntax

cron is a five-field expression or a descriptor. The parser is robfig/cron with exactly these parts enabled: minute, hour, day of month, month, day of week, descriptors.

┌───────── minute        0-59
│ ┌─────── hour          0-23
│ │ ┌───── day of month  1-31
│ │ │ ┌─── month         1-12 or JAN-DEC
│ │ │ │ ┌─ day of week   0-6 or SUN-SAT, 0 is Sunday
│ │ │ │ │
0 9 * * 1
Form Example Meaning
* * * * * * Every value. ? means the same.
List 0 9 * * 1,3,5 Monday, Wednesday and Friday at 09:00.
Range 0 8 * * 1-5 Weekdays at 08:00.
Step */15 * * * * Every 15 minutes.
Names 0 9 1 JAN * 1 January at 09:00. Names are not case-sensitive.
@hourly Minute 0 of every hour.
@daily, @midnight Every day at 00:00.
@weekly Sundays at 00:00.
@monthly The 1st of every month at 00:00.
@yearly, @annually 1 January at 00:00.
@every <duration> @every 6h A fixed interval after the last run, in Go duration syntax.

What is not accepted:

  • A seconds field. Six fields are an error.
  • 7 for Sunday. Use 0 or SUN.

When both day of month and day of week are restricted, the schedule fires when either matches.

Time zones

Set timezone to an IANA name. The name is loaded from the time zone database available to the kōjō process, and an unknown name fails validation.

Without timezone, the expression is evaluated in UTC, whatever zone the server runs in.

A CRON_TZ=<zone> or TZ=<zone> prefix inside cron is accepted too; when it is present, timezone is ignored.

When a schedule fires

The scheduler runs inside kojo serve. This is what the code does.

One tick, for one schedule:

flowchart TD
    A["Tick: at start, then every 30 seconds"] --> L{"This replica gets the Postgres lock?"}
    L -- no --> Z["Nothing this tick: another replica fires"]
    L -- yes --> E{"Schedule enabled?"}
    E -- no --> S["Skipped, nothing recorded"]
    E -- yes --> K{"A last run on record?"}
    K -- no --> N["Now is recorded as the last run, nothing fires"]
    K -- yes --> D{"First cron time after the last run has come?"}
    D -- no --> W["Not due yet"]
    D -- yes --> Q["One session queued per enabled target repository"]
    Q --> R["Now is recorded as the last run"]
  • Tick. The scheduler looks at every enabled schedule when the server starts and every 30 seconds after that. A run can start up to 30 seconds after its cron time, plus the time it waits for a free worker.
  • Due. kōjō stores the time of each schedule’s last run, by scope and name. A schedule is due when the first cron time after that last run is not in the future.
  • A new schedule starts from now. The first time the scheduler sees a schedule it only records the current time. It does not fire for times before the schedule existed.
  • Missed times collapse into one. If kōjō was down, or the schedule’s time passed several times since its last run, it fires once, not once per missed time.
  • Disabled schedules keep their place. While enabled is false nothing is recorded. If a cron time passed while the schedule was disabled, it fires at the first tick after you enable it again.
  • Editing. Changing cron or timezone keeps the last-run time; the next time is computed from it with the new expression. Renaming a schedule makes it a new schedule that starts from now.
  • One session per repository. A fire enqueues one session for each target repository. Repositories that are not enabled are skipped.
  • No overlap check. The scheduler does not look at whether the previous run of a schedule is still going. If a run takes longer than the interval, the next one is enqueued anyway and both run.
  • Several replicas. Every replica runs the loop. At each tick a replica tries to take a lock in Postgres; only the one that gets it fires, and it releases the lock when the tick ends. Each enqueued request also carries a key made of the schedule, the repository and the cron time, and the store refuses a second request with the same key. A schedule therefore fires once per cron time, however many replicas run.

The last run, the session it started and the next run of every schedule are shown on the dashboard’s Schedules page.

Schedules as runtime config

Schedules are runtime configuration: they are stored in Postgres as revisions, not in kojo.yaml, and changing them needs no restart.

Property Value
Config object schedules
Scopes org, and repo:<forge/owner/name> for each repository with a schedules.yaml
Content {"schedules": [...]} with the keys of schedules.yaml
Role to change it operator
Takes effect At the scheduler’s next tick, on every replica

Every change is a new revision with an author and a message, and an earlier revision can be activated again. kojo config export includes the schedules of every scope, and kojo config apply loads them:

version: 1
objects:
  - scope: org
    object: schedules
    content:
      schedules:
        - name: weekly-dependency-review
          cron: "0 9 * * 1"
          timezone: Europe/Madrid
          skill: dependency-review
          repos: [github/acme/api]

Edit org-level schedules in the dashboard, or through kojo config apply, which needs the admin role. A repository with a schedules.yaml keeps its schedules there: an edit of its scope in kōjō opens a pull request that changes the file, and applies once it is merged (Editing a setting that lives in git). Revisions, rollback and roles are described in Managing kōjō.

Create a schedule in words

You can describe a schedule in natural language in chat or in the dashboard. In both places a model turns the sentence into a schedule, a person sees the result, and nothing is stored until that person confirms.

In chat

  1. Mention kōjō in a channel, or send it a direct message, with the request: “review the dependencies of github/acme/api every Monday at 9”.
  2. The message becomes a session. When the sender has the operator or admin role in kōjō, the orchestrator can propose a schedule with a name, a cron expression, a skill, an optional prompt and an optional repository.
  3. kōjō validates the proposal: the cron expression must parse and the skill must exist. Then it posts a message in the thread titled “Create this schedule?” with the name, the cron expression, the skill, the target and Approve and Deny buttons.
  4. Someone with the operator or admin role clicks a button. A click from anyone else changes nothing and the buttons stay. The first decision stands.
  5. On Approve the schedule is added to the org’s schedules as a new revision, authored by the person who approved. If the org already has a schedule with that name, the message says so and nothing is added.

What a proposal in chat cannot set: timezone and notify. A schedule created this way is evaluated in UTC and reports only to the dashboard until you edit it there. Without a repository in the request it runs on every enabled repository.

This works the same in Slack, Mattermost, Discord and Microsoft Teams. Setting each one up is on its page under Surfaces, and who may talk to kōjō is on Who may trigger what.

In the dashboard

The Schedules page has a “Describe it in words” box for people with the operator role.

  1. Type the request and submit it. The server asks the fast model tier to convert it into a name, a cron expression, a skill, a prompt, and a time zone if you named one.
  2. The server validates the result and returns it as a proposal. Nothing is stored at this point.
  3. The page opens the schedule form filled with the proposal, and with the validation error if there is one. Check each field, choose repositories and a notify channel if you want them, and confirm.
  4. Confirming saves the org’s schedules as a new revision.

The same page adds schedules by hand and edits, disables, enables and deletes them, and shows the history of the org’s list with rollback. A schedule created on this page always belongs to the org; a repository’s own schedules come from its schedules.yaml, and editing, disabling or deleting one of them here opens a pull request that changes the file.

The Schedules page of the dashboard: a Describe it in words box with a Propose a schedule button, two schedules with their cron expression, time zone, skill, repositories, last run and next run, and the history of the org's schedule list.
The words box at the top is step 1 above; the history below it is where a change to the org's list is rolled back.

Built-in jobs

kōjō ships skills written to run on a schedule, and no schedules. Nothing recurring happens until you create a schedule.

Skill What a run does
daily-digest Summarises the last 24 hours of issues and pull requests.
dependency-review Applies safe dependency upgrades and reports the rest.
stale-issue-triage Gives a verdict on up to 20 open issues not updated in 60 days.
flaky-test-hunt Runs the test suite repeatedly and reports tests that fail intermittently.
release-watch Reports new upstream releases worth acting on, and remembers what it reported.

Any other skill can be scheduled too, for example security-audit. Each skill is described on the Built-in skills page.

A schedules.yaml that turns all five on for one repository:

schedules:
  - name: daily-digest
    cron: "0 8 * * 1-5"
    timezone: Europe/Madrid
    skill: daily-digest
    notify: C0123456789
  - name: dependency-review
    cron: "0 9 * * 1"
    timezone: Europe/Madrid
    skill: dependency-review
  - name: stale-issues
    cron: "0 10 1 * *"
    timezone: Europe/Madrid
    skill: stale-issue-triage
    notify: C0123456789
  - name: flaky-tests
    cron: "0 2 * * 6"
    timezone: Europe/Madrid
    skill: flaky-test-hunt
    notify: C0123456789
  - name: release-watch
    cron: "0 9 * * 3"
    timezone: Europe/Madrid
    skill: release-watch
    notify: C0123456789

The times are examples. Replace the channel ID with one of yours.

How a scheduled run differs

A scheduled run is an ordinary session. These are the differences from a session someone triggered with a mention, a chat message or kojo run.

Scheduled run Triggered run
Surface and kind schedule The forge, a chat surface (slack, mattermost, discord, teams), cli, dashboard or mcp.
Runs as schedule:<scope>/<name> The person who asked.
May write Always. Only when that person has the permission or role for it.
Chooses skills No. Exactly the schedule’s skill runs, once. The orchestrator chooses, unless a skill was named.
Issue or pull request None. The one the request is about, if any.

Who it runs as. There is no person behind a scheduled run, so no forge permission is checked when it fires. The run is trusted to write because of who can create schedules: someone with the operator role for the org’s list, or someone who can get a commit onto the default branch for a repository’s schedules.yaml. Treat changes to that file as changes to what kōjō may do unattended.

No orchestrator. The skill runs directly with the schedule’s prompt as its task, and its result goes to the goal critic as usual. A scheduled fix-bug, for example, gets no reproduce-bug step before it.

No issue to comment on. The comment tool returns an error in a scheduled run, because the session is not about an issue or pull request. A skill’s final report is its result.

Where the result goes. With notify, the result is posted to that channel as a new message. Without it, the result is only on the session: open it on the dashboard’s Sessions page, filtered by the surface schedule, or with kojo sessions show.

Budgets. There is no separate budget for schedules. Each scheduled session has the same per-session cap as any other and counts toward the same daily cap. An org-level schedule without repos starts one session per enabled repository at the same moment; size the daily cap with that in mind. While the daily cap is spent, a scheduled session that has not started waits in the queue and is looked at again every 10 minutes; the cap is a sum over the last 24 hours, so it runs once enough earlier spend has aged out. See Models.

Merge policy. A scheduled run that changes code goes through the repository’s merge policy like any other change, and the pull request it opens is titled Scheduled: <name>. What differs is whether there is somewhere to ask a human:

Policy mode With notify Without notify
draft_only Draft pull request. Draft pull request.
ask Approval buttons are posted in the notify channel. Draft pull request, because there is no thread to ask in.
auto_merge, low risk Merges once required checks are green. The same.
auto_merge, medium risk Asks in the notify channel before merging. A pull request ready for review, not merged.
auto_merge, high risk Draft pull request. Draft pull request.

The auto_merge rows apply when an admin allowed auto-merge for the repository and its base branch is protected with required checks. Without the first, the mode is treated as ask; without the second, the change is a draft pull request.

A result the goal critic rejected is always published as a draft with its report. The modes and the risk score are explained on the Merge policy page.

Scroll to move. + - zoom, 0 fit, Esc close.100%