Documentation Docs version: dev (Pre-release: Gitoodo has not been released yet)
GitHub Get notified

For developers · Orchestrator

Queue order and slot share

On this page
  1. 1. Which issues may start
  2. Readiness
  3. 2. The order inside a repository
  4. The score
  5. The release bonus and the due date (#1850)
  6. Worked example: four issues of one repository
  7. Worked example: the same issue at other due dates
  8. 3. Sharing the worker slots between repositories
  9. Slots and the equal share
  10. The deadline of a release (#1850)
  11. The order of starts
  12. Worked example: ten slots, eight repositories
  13. Worked example: a release behind its date
  14. 4. Where to change it and where the app explains it

This page explains, end to end, which issue the autopilot starts next: which issues may start at all, how the issues of one repository are ordered (the score), and how the worker slots are shared between repositories (the fair share). Every number below is the default of the code; the worked examples are checked by tests (named at each example), so this page and the code cannot drift apart silently.

In short: inside a repository the next release goes first, then the highest score. Between repositories every repository with work gets an equal share of the slots; an urgent issue, then a release due soon goes first, then the rotation. A release that cannot make its date at the equal share may take more slots, but every other repository keeps at least one.

1. Which issues may start#

The dispatcher only looks at repositories whose Autopilot is on (state "active"). Of their open issues, one may start when all of this holds:

ConditionWhat it means
ReadyThe read model's readiness is ready: the ready label (or a legacy alias), or a trusted author and a complete description. See Readiness below.
Inside the release focusWith a release focus (the default: the next release), only issues of that release and the issues it depends on start (release.md, "Release focus"). When nothing in the focus is ready, the focus steps aside and the rest starts.
Dependencies doneEvery issue it depends on (Depends on #N / Blocked by #N, also in other watched repositories) is closed. A cycle needs a person (needs-clarification).
Nobody else holds itNo lease of a run that has not ended yet, no "Solve with an agent" session on it, no running branch of the same repository changing the same files (the overlap wait, at most 30 minutes), no open part of a split issue.
A machine can take itSome machine fits its os:, host: and tool: labels and has a free slot, memory, disk and agent usage left (dispatcher.md, "Workers per machine"; satellites.md). An issue no machine takes waits with the reason on the board; the next issue may go.

Readiness#

Readiness is computed from the labels in this order; the first match wins (read_model::readiness):

Labels / stateReadinessStarts?
in-progressin progressno
in-reviewin reviewno
needs-humanneeds a personno
stalledstalledno
dependency cycleneeds clarificationno
an open dependency, or blockedblockedno
prd or externheldno
ready, or a trusted authorreadyyes
anything elseneeds approvalno

A trusted author's issue without the ready label also needs a complete enough description, else it reads "needs clarification"; in a repository that only handles new issues, the backlog from before it was switched on needs the ready label (dispatcher.md, "Readiness").

2. The order inside a repository#

The issues that may start are ordered in two groups:

  1. First group: the issues of the next release and boosted issues (read_model::goes_first). The next release is
    • every issue with release:next,
    • every open issue of the next release milestone (the open milestone with a version title that is due first, else the lowest version, see release.md), and
    • every issue those depend on.

    Only with release planning on for the repository; with it off, only boosted issues form the first group.

  1. Everything else.

Inside each group the score decides, highest first. Ties go to the older issue, then to the lower number. The dispatcher and the app's queue use the same order (#962).

The score#

score = priority weight
      + age_per_hour × full hours since the issue was opened
      + boost                (when the boost label is on the issue)
      + release bonus        (when the issue is in the next release, see below)
TermKeyDefaultRangeRule
Priority p0p010000–10000priority:p0 (legacy prio:0)
Priority p1p13000–10000priority:p1; also a bug without a priority label (bug, typ:bug, type:bug, kind/bug, …)
Priority p2p21000–10000priority:p2; also every other issue without a priority label
Priority p3p3300–10000priority:p3 and anything lower (p4, p5, …)
Ageage_per_hour10–1000Per full hour since the issue was opened; nothing waits forever.
Boostboost5000–10000The issue carries the boost label (boost_label, default boost, compared ignoring case).
Release bonusrelease_bonus2000–10000The issue is in the next release; scaled by the release's due date, see below.
Windowrelease_due_days141–365Days before the due date at which the bonus starts to grow; also the window of the deadline rule in the slot share.
Far sharerelease_far_percent250–100Percent of release_bonus for a release due release_due_days or more away.

Several priority labels: the best one counts. A priority label always beats what the type implies.

The release bonus and the due date (#1850)#

The release bonus grows as the next release's due date comes closer. With d the whole days from today (this machine's calendar day) to the due date, B = release_bonus, W = release_due_days and F = B × release_far_percent / 100 (rounded down):

Due dateBonus
none set (also release:next without milestone)B (the bonus as before)
overdue, today or tomorrow (d ≤ 1)B
1 < d < WF + (B − F) × (W − d) / (W − 1), rounded down
d ≥ WF

With the defaults (B = 200, W = 14, F = 50):

Due innone30 days14 days13 days7 days2 days1 daytodayoverdue
Bonus200505061130188200200200

Why this curve: a worker run, its checks and the review take hours, so today and tomorrow are the same urgency and get the full bonus. Two weeks is a common release rhythm; further away the date says little about today's order, but a release still keeps a quarter of its bonus. A straight line in between means every day closer adds the same number of points and a nearer date never scores lower than a later one. A release without a due date keeps the bonus it always had, so repositories that do not set dates see no change.

Inside one repository all issues of the next release share its due date, so the bonus mostly orders them against boosted issues (both are in the first group) and raises the repository's best score, which the slot share uses for repositories that have not started yet.

Worked example: four issues of one repository#

Defaults; the repository's next release v2.0 is due tomorrow. Test: read_model::tests::docs_queue_order_score_examples.

IssueLabelsOpenedPriorityAgeBoostRelease bonusScore
#101typ:feature72 hnone, feature → p2 = 10072 × 1 = 720not in the release: 0172
#102typ:bug2 hnone, bug → p1 = 3002 × 1 = 200302
#103priority:p2, in v2.030 hp2 = 10030 × 1 = 300due in 1 day: 200330
#104priority:p3, boost10 hp3 = 3010 × 1 = 105000540

Order: the first group (#104 boosted, #103 in the next release) by score, then the rest by score: #104 (540), #103 (330), #102 (302), #101 (172). #103 would go before #102 even with a lower score, because the next release goes first.

Worked example: the same issue at other due dates#

#103 again (p2, 30 hours old), with v2.0 due at other dates. Score = 100 + 30 + bonus:

v2.0 dueBonus calculationBonusScore
no datefull bonus200330
in 30 daysd ≥ 14: 200 × 25 / 10050180
in 13 days50 + 150 × (14 − 13) / 13 = 50 + 1161191
in 7 days50 + 150 × (14 − 7) / 13 = 50 + 80130260
in 2 days50 + 150 × (14 − 2) / 13 = 50 + 138188318
tomorrowd ≤ 1: full bonus200330
todayfull bonus200330
2 days agooverdue: full bonus200330

(150 × 7 / 13 = 80.8, rounded down to 80; 150 × 12 / 13 = 138.5, rounded down to 138.)

3. Sharing the worker slots between repositories#

Each push tick (every 5 s) the dispatcher asks the pure planner dispatch::fair::plan which repository starts next; inside that repository the first issue of the order above that a machine takes starts. The planner sees per repository: running workers (here and on worker machines), ready issues, ready priority:p0 issues, the best ready score and, new with #1850, the next release's deadline.

Slots and the equal share#

  • Slots: dispatch.max_workers, or fewer when the machines' own maximums add up to less (dispatcher.md, "Workers per machine"). Waiting resolver runs take their system slots first; the planner shares the rest.
  • Active repositories: Autopilot on and ready issues or running workers.
  • Equal share: floor(slots / active), at least 1. Example: 8 slots and 3 active repositories give 2 each; 10 slots and 8 repositories give 1 each.

The deadline of a release (#1850)#

A repository's next release weighs in when it has a due date at most release_due_days (default 14) days away, or is overdue, and has ready issues. Two numbers come from it (fair::Deadline):

  • Pressure = open release issues ÷ days left, where days left = days until due + 1 (today counts). Overdue is the highest pressure. Open means open or being worked on, in this repository; done (merged or closed) issues do not count.
  • Need = the slots the release needs to make its date if every slot finishes one issue a day (ISSUES_PER_SLOT_DAY = 1): open issues ÷ days left, rounded up; overdue: all open issues. One issue a day is cautious on purpose: run, checks, review and merge, with the questions in between, often take most of a day.

A release whose need is above the equal share is pressed: its repository may hold up to its need, but never more than slots − (active − 1), so one slot stays for every other active repository. The extra slots only go to release issues: once the release has no ready issue left, the repository is back to the equal share.

The order of starts#

For each free slot, the planner picks among the repositories with ready issues:

Without a pressed release:

  1. repositories below their share before those at or above it (who only get leftover slots);
  2. inside each of the two: an urgent issue (priority:p0) first;
  3. then a release due soon: highest pressure first, then the earlier due date;
  4. then the rotation: a repository that never started first, then the one whose last start is the longest ago (a start moves the repository to the end; kept in memory, reset on restart);
  5. then the best ready score, then the repository's name.

With at least one pressed release, step 1 has four levels instead of two:

  1. every repository with no running worker gets its first slot;
  2. pressed repositories fill up to their need (within the bound above);
  3. the others fill up to the equal share;
  4. leftover slots.

Steps 2–5 order each level as before. Without any release due within its window, nothing of this changes the order of #959 (tested: fair::tests::a_release_not_behind_keeps_the_equal_share and the earlier fair-share tests, unchanged).

No slot stays free while anything is ready: slots no repository below its share can use go to the others. The global limit and every machine limit always hold.

Worked example: ten slots, eight repositories#

Test: fair::tests::docs_queue_order_slot_example. Ten free slots, eight active repositories (app, api, cli, docs, lib, ops, site, web), each with 3 or more ready issues, none running yet:

  • app: release v2.0 due tomorrow, 6 open issues, all ready. Days left 2, pressure 6 ÷ 2 = 3.000, need ⌈6 ÷ 2⌉ = 3.
  • api: release v0.9 due in 6 days, 4 open issues. Days left 7, pressure 4 ÷ 7 = 0.571, need ⌈4 ÷ 7⌉ = 1.
  • cli: one ready priority:p0 issue.
  • Equal share: ⌊10 ÷ 8⌋ = 1. Bound for a pressed release: 10 − 7 = 3.
  • app needs 3 > 1: pressed, limit 3. api needs 1: not pressed, but due soon.
StartRepositoryWhy
1clifirst slots; urgent issue first
2appfirst slots; release due soon, pressure 3.000
3apifirst slots; release due soon, pressure 0.571
4–8docs, lib, ops, site, webfirst slots; rotation (none started yet, same score: by name)
9apppressed, 1 of 3
10apppressed, 2 of 3

Result: app 3 workers, every other repository 1. Without the due dates the two leftover slots would have gone by the rotation to cli and api.

Later ticks, one slot freeing at a time:

  • A worker of docs ends: docs has none running, so it gets the slot back first.
  • A worker of app ends: app is below its need of 3, so the slot stays with app.
  • Once app has no ready release issue left, it is held to the equal share again: a slot freeing at ops goes back to ops.

Worked example: a release behind its date#

Test: fair::tests::docs_queue_order_held_example. Eight slots, four repositories with plenty of ready issues; app's release v2.0 is overdue with 9 open issues. Share ⌊8 ÷ 4⌋ = 2, need 9 (all, overdue), bound 8 − 3 = 5. Result: app 5, docs, lib and web 1 each. The three wait below their equal share for app's release; their ready issues show "Waits for a free slot: release v2.0 of owner/app is due on (its date) and gets more slots." app itself waits at its bound with the plain "Waits for a free slot of this repository."

4. Where to change it and where the app explains it#

  • Weights: globally in orchestration.json under score (all keys of the table above), per repository under repos[].score; a repository without own weights uses the global ones. In the app: the repository's settings, section "Order", switch "Own weights", one field per weight with its range; a value outside the range is refused and the old value stays. The core refuses an out-of-range value in the file the same way (ScoreWeights::validate).
  • Slots: dispatch.max_workers and each machine's own maximum (dispatcher.md). The deadline rule has no switch of its own: set release_due_days to 1 to make it apply only to releases due today, tomorrow or overdue.
  • Why an issue waits: a ready issue held by the share shows on the board and in the sidebar as "Waits for a free slot of this repository." (repo_share in host-wait.json); when a pressed release takes the slot, the text names it: "Waits for a free slot: release {version} of {repository} is due on {date} and gets more slots." (in all six languages). A machine reason (offline, full, a missing tool) wins over the share.
  • Order in the app: the release view sorts by the dispatcher's order (#1716), and the queue beside the sessions lists the issues in the order above.
  • Logs: dispatch.release_pressed (debug) names the pressed repositories of a tick; dispatch.host_wait logs each wait reason once per change.
Edit on GitHubDocs version: dev