Note · budding
Which truck gets the dock
- Stage
- budding
- Links
- 1 out, 1 in
The dock scheduler in Inbound Outbound has two jobs: say which waiting truck is called next, and say which dock it goes to. Both are pure functions in shared/engine.ts. The routes load rows, call the engine and store the answer, so the rules run in tests with no database.
A dock either fits or it does not
fit is a hard gate. It returns one message per mismatch, and an empty list means a fit. A dock fails a truck in any of these cases:
- The dock is blocked.
- The dock does not list the truck’s direction, load class (ambient, chilled, frozen, dangerous goods) or truck class.
- The truck is taller, or has more cargo volume, than the dock allows. A value equal to the limit fits.
- A tail-lift truck needs a ground-level bay and the dock has none.
Everything else is points
A waiting truck gets a score from the site’s weights. The defaults:
| Reason | Points |
|---|---|
| Each minute waited | +0.6 |
| Arrived within 15 minutes of its slot | +15 |
| No booking | -20 |
| Frozen, chilled or dangerous goods | +40, +30, +25 |
| Tier 1 or tier 2 carrier | +10, +5 |
| Marked urgent | +25 |
| Waited past the 45 minute target | +20 |
| Each penalty point | -5 |
The dock board shows the parts. A chilled load from a tier 1 carrier that arrived on its slot and has waited 10 minutes scores 30 + 15 + 10 + 6 = 61. A tie goes to the earlier arrival, then to the lower visit id, so the order never depends on the order of the input.
Where it goes
The forecast walks the queue in rank order. Each truck takes the dock that frees up soonest. On a tie it takes the least flexible dock: 2 points per direction, 2 per load class, 1 per truck class and 1 per equipment item. A dock that takes everything stays free for the truck that has nowhere else to go.
What the tests check
- No two bookings on one dock overlap. Seeded random sequences of slot picks and moves (mulberry32, fixed seeds) run over three days and two time zones, and the check runs after every step.
- A booking that starts when another ends does not collide.
- The booking write repeats the overlap check inside the INSERT, so two simultaneous requests cannot both win.
- A site in Australia/Sydney has 46 half-hour slots on the 23 hour day in October and 48 on the 25 hour day in April.
The rules page is docs-src/developer/scheduling-invariants.md in the repository.
Projects
- Inbound OutboundA multi-tenant SaaS for booking vehicles into a warehouse and calling them to a dock, built on Cloudflare in three days as a test of building real full-stack cloud applications.
Projects
- Inbound OutboundA multi-tenant SaaS for booking vehicles into a warehouse and calling them to a dock, built on Cloudflare in three days as a test of building real full-stack cloud applications.