Scheduling boards
A scheduling board puts work on the people and equipment that will do it, over a window of days. Rows are resources, such as technicians, and blocks are tasks, such as work orders. A planner moves blocks in a draft of their own, rule functions check every move as it is made, and one submit applies the whole plan through an ordinary action, so the action's permissions, conditions, log and writeback all still apply
In the platform today
- Scheduling boards run in the platform service, defined under
schedules:inontology.yamlwithrows,tasks,window,save,rules,suggest,search,metricsandsolver - Rule, suggest, search and metric functions are Python functions in
functions.pythat take the board - Drafts are stored by the platform, so they survive a restart and work across copies of the service
- The routes are under
/api/v2/schedules, and the Scheduling board screen in the app uses them when connected to the platform service, as a timeline at desktop width and a list per row on a phone
- The demo airline's board puts open Halifax work orders on the technicians who will do them
- A row object type and a task object type, with a start, a duration or an end, and a property on the task that names its row
- An action type that saves one move, taking the task, the row and the start as parameters
- Rule functions in
functions.pyfor what must hold, such as no double booking or a rating on the aircraft type - Permission to run the save action, for anyone who submits a plan
Define a board
The demo airline's hangar board, shortened
schedules:
hangar-technicians:
name: Halifax hangar technicians
rows: { objectType: technician, where: { station: YHZ },
label: name, detail: shiftPattern, orderBy: [name] }
tasks:
objectType: work-order
where: { station: YHZ, status: { $in: [Planned, Open, Awaiting parts] } }
start: plannedStart
duration: { property: plannedHours, unit: h } # or end: plannedEnd
row: assignedTechnicianId
due: dueAt
label: workOrderId
detail: title
priority: { property: priority, order: [AOG, Critical, Routine] }
window: { days: 7, step: 30m } # starts at local midnight today
save: { action: schedule-work-order,
parameters: { workOrder: task, technician: row, plannedStart: start } }
rules:
- { id: overlap, name: Not double booked, function: schedule_overlap, severity: hard }
- { id: qualified, name: Rated and authorised, function: schedule_qualified,
severity: hard, cacheBy: row }
- { id: parts, name: Parts on hand, function: schedule_parts_ready, severity: soft }
suggest: { function: schedule_free_slots }
search: [ { id: work-for-technician, name: Work this technician can take,
from: row, function: schedule_work_for_row, limit: 10 } ]
metrics: [ { id: utilization, name: Utilization, per: row, bucket: day,
function: schedule_utilization, unit: "%" } ]
solver: { timeLimitMs: 8000, maxEvaluations: 200000, softWeight: 10, lateWeight: 1 }
| Key | Meaning |
|---|---|
rows | The resources: an object type, an optional where filter, the label and detail shown on each row, and orderBy |
tasks | The work: an object type and filter, start, duration or end, the property naming the row, due, label, detail and a priority order. A task is placed when it has a row on the board and a start inside the window; the rest wait to be placed |
window | How many days the board shows and the step blocks snap to |
save | The action that applies one move, and which of its parameters take the task, the row and the start |
rules | Rule functions with an id, a name, severity hard or soft, and cacheBy: row when the answer depends only on the task and its row |
suggest | A function that offers candidate slots for a task; without it, every step of every row is a candidate |
search | Named searches from a task (good slots for it) or from a row (work it can take), with a limit |
metrics | Values per row or for the whole board, per hour, day or week, such as utilization |
solver | The solver's budget and weights |
Rows and tasks are read as the person viewing the board reads them: row policies, access labels and hidden properties apply, so two planners at different stations see different boards from one definition
Board functions
Each function takes ctx, as any function does, and the board: rows, tasks (each with key, row, start, end, hours, due, placed and object), on_row(row), placed() and memo(name, fn) for reads cached for the request. They run only from the board, never through the function invoke endpoint
| Kind | Signature | Returns |
|---|---|---|
| Rule | fn(ctx, board, tasks) | [{task, result, reason, related}] with result pass, fail or notApplicable. A task left out passes |
| Suggest | fn(ctx, board, task) | Candidate [{row, start}]; the engine keeps those that pass every hard rule |
| Search | fn(ctx, board, task=None, row=None) | Candidates, which the engine checks and ranks |
| Metric | fn(ctx, board, buckets, per) | [{row, bucket, value}], row left out for a board-wide value |
@function(description='Board rule: a technician has one work order at a time')
def schedule_overlap(ctx, board, tasks):
out = []
for t in tasks:
clash = [o for o in board.on_row(t['row']) if o['key'] != t['key']
and o['start'] < t['end'] and t['start'] < o['end']]
if clash:
out.append({'task': t['key'], 'result': 'fail',
'related': [o['key'] for o in clash],
'reason': f'Overlaps {", ".join(o["key"] for o in clash)}'})
return out
A function that raises, or returns a result other than the three allowed, fails the request with FUNCTION_FAILED and reason SCHEDULE_FUNCTION_FAILED, naming the function
Drafts and moves
A draft is one person's sandbox for a board. It holds one move per task, the latest winning, and each move remembers where the task was. Nothing in it changes an object until it is submitted
- Open a draft.
POST /api/v2/schedules/{id}/draftsreturns the caller's open draft, made when there is none - Stage a move.
POST /api/v2/schedules/{id}/drafts/{draftId}/moveswith{task, row, start}. The rules run again over the moved task, the tasks on its old and new rows, and every task a rule related to it before or after the move, and the answer carries their results - Find a slot.
POST /api/v2/schedules/{id}:suggestwith{task, draft}returns the slots that pass every hard rule. A search runs withPOST /api/v2/schedules/{id}/search/{searchId}:runand{task}or{row} - Change your mind.
DELETE …/moves/{moveId}takes one move out;:undosteps back through the last 50 changes, a stage, a removal, a solve or a clear;:clearempties the draft and:discardcloses it - Submit.
POST …/drafts/{draftId}:submitapplies the plan, as described below
Submit
Submit rebuilds the board from the data as it is now, with the moves laid over it. It refuses with 409 SCHEDULE_RULES_FAILED, applying nothing, when a moved task breaks a hard rule, when a hard failure names a moved task, or when a task changed since its move was staged; the error's errors list each problem. Otherwise each move runs the save action as the person submitting, so the action's own permissions and conditions are checked again just before the commit, and each move is logged, written back and audited like any action
- A move refused with
CONDITION_FAILEDis tried again after the others, because a swap needs one task out of the way first - When a move still fails, the moves already applied are reverted through the action log, newest first, and the answer lists every move with its result, its log id and whether it was put back. The draft stays open to fix and submit again
- On success the draft is marked submitted
Solver
POST …/drafts/{draftId}:solve stages a plan for the work that is not placed and the tasks breaking a hard rule, or for the task keys given. It puts each task at a slot where it and every task it affects pass every hard rule, weighing soft failures by softWeight and lateness by lateWeight, and improves the plan within its budget
- The solver is deterministic for the same data while it finishes inside
maxEvaluations;timeLimitMsis a guard - It stages its plan as one undo step and never applies anything; a person reviews and submits it
- Tasks it can't place are listed with the reason
API
| Endpoint | Does |
|---|---|
GET /api/v2/schedules | The boards whose row and task types the caller can see |
GET /api/v2/schedules/{id}?draft=&from=&to= | Rows, tasks, rule results, metrics and the staged moves of a draft, for a window |
POST /api/v2/schedules/{id}:suggest | The valid slots for one task |
POST /api/v2/schedules/{id}/search/{searchId}:run | Ranked candidate slots or tasks |
POST /api/v2/schedules/{id}/drafts, GET …/drafts/{draftId} | Open or read the caller's draft |
POST and DELETE …/drafts/{draftId}/moves[/{moveId}] | Stage a move or take one out |
POST …/drafts/{draftId}:undo, :clear, :discard, :solve, :submit | Undo, empty, close, solve or apply the draft |
Limitations
- Two requests changing one draft at the same moment are taken one after the other, so neither is lost; the second works on the draft as the first left it
- The solver makes no swaps or chains of moves, so it can miss a placement that needs another task to move first
- One task per row at a time is a rule, as
schedule_overlapis; a board without such a rule allows overlaps - A draft is not a data branch: its moves are an overlay held in the draft, and the objects change only on submit