← All work

Local-first design · routing heuristics · natural language

A scheduler that answers one question: which day costs the least driving

One operator, one vehicle, recurring customers spread across a region. Given a job that needs scheduling, route-book ranks the candidate days by what adding that job actually costs — and says why, in a sentence, so the answer can be argued with.

The failure mode of a solo trade is not a bad route. It is a bad week.

The problem

A solo mobile service is a one-vehicle routing problem with human constraints. The operator already knows what has to be done. The expensive question is when — and more precisely, which day each job lands on, because that decision is what decides the driving.

Three customers in three towns on three different days is six crossings of the region. The same three on one day is one loop. The operator can feel this and cannot compute it, because the inputs are a dozen addresses, a fortnight of recurrences, and a mental map of the roads in between.

So the tool has exactly one job worth having: given a job that needs scheduling, say which day costs the least travel while still being a reasonable day to work. Everything else — the customer list, the calendar, the confirmations — is infrastructure for that decision.

How it works

A sentence goes in. One day comes out, with its reasoning attached. The model in the middle is doing the smallest job on the page.

From a spoken sentence to a scored day: parse, resolve, filter, score, explain A sentence is parsed into a structured intent, where the date expression is kept verbatim and the model is never asked what day it is. The customer name is resolved to a local identifier before any model call. Every working day in the window becomes a candidate; days that fail the timeline inequality are discarded. The survivors are scored on weighted terms, led by marginal insertion cost, and the answer is returned with its reasoning and slack. A booking is written only if it was asked for. What you say “…, next Thursday, 3 hrs” “best day for this in 2 weeks” Parsed to an intent verb · client · when · duration “next Thursday” kept verbatim Resolved locally a name becomes an id the list never leaves Candidate days every working day already has its own jobs The filter, first can this day be driven? if not, it is not a candidate Then scored insertion 0.45 · anchor .15 cluster .15 · slack .10 … One day, and the reason for it “40 min of slack, and 15 min early to the first job” a booking is written only if one was asked for
The model parses; the code decides. Date arithmetic, distances and scores are computed in Python, because a model asked to reason about a routing problem will produce a fluent, confident, wrong answer — and an operator listening on a phone has no way to tell. Asking it to extract when: “next Thursday” is the job it is reliably good at, and the result is checkable at a glance.

The number the whole thing turns on is not how far is this customer but what does adding this job to this day cost:

insertion_cost(day, job) = travel(prev → job)
                         + travel(job → next)
                         − travel(prev → next)
Marginal insertion cost: a distant customer can cost almost nothing Top row: a day already holds two jobs, and the drive between them is 25 minutes. Bottom row: a third job is added between the two; the drive from the first to it is 12 minutes and from it to the second is 16 minutes. The insertion cost is 12 plus 16 minus 25, which is 3 minutes, even though the customer's own driveway is 40 minutes from home. The day as it stands job A job B 25 min — you drive it anyway And now one job is added job A the new job job B 12 min 16 min insertion cost = 12 + 16 − 25 = 3 min, for a customer 40 min from home
Distance from home is the wrong measure. A customer forty minutes away can cost three minutes of driving if the day already passes their door. A customer ten minutes away can be expensive if they would sit alone on a day that otherwise ended early. Marginal cost is the honest number, and it is the one the recommendation shows.

Two consequences of taking that seriously. A day is treated as a timeline, not a list of jobs — so changeover is modelled (packing up, locking up, loading, and the two minutes of conversation at the door that every real job ends with), a mid-day break is placed in the first feasible gap, and there are two day ceilings rather than one, because nine elapsed hours and seven hands-on hours are different numbers. And feasibility is a filter, never a score term: a day that fails the timeline inequality is discarded before scoring. A cheap day you cannot physically drive is not a low-scoring day; it is not a candidate.

What made it interesting: two decisions, and only one of them is automatic

A scheduler can be locally optimal and globally myopic. Add-one-job-at-a-time never reconsiders a job already placed, so a week can settle into a shape that is twenty minutes worse than necessary and stay there — and the standard fix, a true solver, is a heavy dependency for a problem this size: a few dozen customers with strong geographic clustering, which is exactly the regime where cheapest-insertion plus 2-opt lands within a few percent of optimal.

The interesting part is not the algorithm. It is that the gap is made visible instead of hidden, and split along the line where a human actually wants control.

The small decision is automatic; the large one is advice On the left, a booking: greedy marginal insertion places one job on one day, answers immediately, and gives the same answer for the same input. On the right, the shape of the week: a 2-opt rebalance reports what it could improve, bounded in how many appointments it may suggest moving, and changes nothing on its own. Automatic — one job, one day Greedy marginal insertion answers now, in O(days) the same input gives the same answer it cannot see a better arrangement and does not pretend to Advice — the shape of the week 2-opt rebalance, on demand “you could save ~40 min by moving the Tuesday job to Thursday” bounded — it will not propose reshuffling your customers' routines a scheduler that silently reorganises a week to save 40 minutes gets switched off within a month so the operator decides, and the tool says what it thinks the week is worth
Automatic on the small decision, advisory on the large one. The weekly view reports the total drive time and the best improvement it can find, as a suggestion. Nothing moves because the optimiser wants it to. The same instinct runs through the rest of the tool: a recommendation carries its reasoning, a spoken booking is read back before it is written, and an estimate that came from a fallback is labelled as approximate rather than presented as a measurement.

That last one is a design rule rather than a feature. If the routing service is unreachable, the tool falls back to straight-line distance times a road factor — and says so on the answer, because a number that looks measured and isn't is worse than an admitted estimate. The operator disagrees with rankings sometimes; they should be able to read why in one sentence and change a weight.

What it saves

The saving is driving, and driving is the one cost in a solo trade that is purely a function of scheduling. Cleaning a house has to be done; crossing the region twice does not.

So the saving scales with two things, and both are facts about a working week rather than about the software — how many jobs there are, and how much driving each one gives back when it lands on the day that already works its area. The arithmetic is trivial, which is rather the point:

Hours of driving recovered per month — by jobs a week, and by the driving each correctly-placed job gives back.
jobs / week 5 min each 10 min each 15 min each 25 min each
5 1.8 3.6 5.4 9.0
10 3.6 7.2 10.8 18.1
15 5.4 10.8 16.2 27.1
20 7.2 14.4 21.7 36.1

Hours, not a measurement. Pick the row and column that match reality.

Ten jobs a week at ten minutes each is most of a working day recovered every month, in the seat of a van rather than at a desk. The second-order saving is the one that matters more and counts worse: the decision itself stops being a guess, so it stops being re-made. The schedule lands in the calendar the operator already reads, over a standard feed they subscribe to once — no second app to check, and nothing to remember.

There is no headline number here, deliberately. Nobody wrote down what this week's driving cost before the tool existed, and a figure I invented would be worth less than no figure at all. That is why the table is a table of inputs: the mechanism is real, the multiplication takes seconds, and the two numbers belong to whoever runs the week.

What it does not do

The boundary is a feature, so it is worth stating plainly. It is not an invoicing system — it emits hours and does not chase payment. It is not a customer-facing booking portal, and not multi-worker: the data model leaves room, the optimiser assumes one vehicle. It is not live-traffic aware; travel times are free-flow, and the tool says so rather than pretending to a precision it cannot have. It is not a customer relationship manager, and it is not a calendar application — no month grid, no competition with the one you already use.

The privacy boundary is part of the same list, and it is where the tool holds other people's data:

Facts, in a form you can check

Language & licencePython, standard library only — no third-party dependencies · MIT
SurfaceA Hermes Agent plugin: 14 tools, a slash command, a CLI subcommand, and a bundled agent skill
Answer pathThe model parses the sentence; every date, distance, filter and score is computed in code
Without a modelA deterministic parser handles the whole surface, and doubles as the test oracle
FeasibilityCandidate days that fail the timeline inequality are discarded before scoring, never penalised
StorageLocal SQLite in the plugin's own data directory · export to CSV and JSON on one command
CalendarA subscribable .ics feed — Apple, Google, Fastmail, Nextcloud, Outlook. No account, no API key
VoiceTwo Siri Shortcuts; a spoken booking is read back aloud and confirmed before it is written
Tests226 tests across nine modules, offline and deterministic
DistributionOpen source on GitHub, MIT — hermes plugins install aclayton/route-book