Skip to content

Dispatch workspace: plan a day, publish routes, move orders between routes - #439

Merged
roncodes merged 3 commits into
feature/map-canvasfrom
feature/confident-ritchie-f0b22c
Dec 3, 2026
Merged

roncodes merged 3 commits into
feature/map-canvasfrom
feature/confident-ritchie-f0b22c

Conversation

@roncodes

@roncodes roncodes commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What changes

  1. Commit takes a date. orchestrator/commit accepts scheduled_date. Manifests are dated by it, and each order's scheduled_at moves to that day: its time of day is kept, an order with no time takes its planned arrival, and failing that the start of the day. The commit also accepts plan_run_id, publish and publish_at.
  2. Plan scope. orchestrator/run plans the orders in order_ids, or the orders scheduled on scheduled_date. Sending neither is a 422; a run no longer plans every unassigned order on every date. order_statuses is now honoured (any of created / dispatched / started).
  3. Unassigned reasons. Each run is stored in a new orchestration_runs table with the reason each unplaced order was left out. The run returns unassigned_reasons, keyed by order id, and a plan_run_id. Engines that give no reason get that engine's usual cause. The driver-assignment engine now reports orders instead of vehicle ids.
  4. Manifest lifecycle. Manifests go draft → published → active → in_progress → completed (active/in_progress are main's opened/started statuses), with published_at and a booked publish_at that a queued PublishScheduledManifest job carries out. New endpoints: POST manifests/{id}/publish and POST manifests/publish (by ids, or every draft of a day). Driver endpoints return only manifests that were published, so a draft is a 404. Publishing records a status history row (so main's manifest.changed goes out), sends the driver a manifest_published push, and queues the per-order notices older Navigator builds rely on. Routes main's ManifestBuilder makes from a driver's own assignments start published; the migration publishes existing auto-built drafts, and Orchestrator drafts stay drafts (drivers stop seeing them until a dispatcher publishes them).
  5. One reassignment service (Support\Dispatch\RouteReassignment), built on main's ManifestBuilder. It moves the order's stops between routes, updates its driver, vehicle and manifest_uuid, follows a new day, and can position the order on a chosen route. orders/bulk-assign-driver and orders/schedule (Scheduler drag), which bypassed main's manifest observer, now go through it. Order detail (PUT) and the orchestrator commit use main's observer and commit.
  6. Insert into a route. POST manifests/{id}/orders puts an order on a route at a position among the stops still to do (main's convention; main owns manifests/{id}/stops for stops of no order). Without a position it goes to its best fit, never ahead of stops done or locked. GET manifests/best-fit returns the cheapest insertion per driver, priced with main's road-matrix ManifestStops::fit.
  7. Import results. orchestrator/import-orders returns an outcome for every row (created / failed with a reason and per-field errors). validate_only re-checks edited rows without creating anything, and import_batch_id lets fixed rows join the earlier batch. Created orders carry meta.imported_via_orchestrator and meta.import_batch_id.

Frontend: one forced change. The current workbench sends publish: true on commit, so its routes still reach drivers now that drafts are hidden from them.

Behaviour changes to know about

  • Bulk assign now saves each order through the model instead of one UPDATE. That gives correct routes and notices, at the cost of one save per order.
  • A row with drop-off coordinates but no street now gets its drop-off; the old import dropped it without saying so.
  • The public v1 order update does not move routes yet. Only the console entry points listed above do.

Tests

  • New Feature/Http/Internal/DispatchWorkspaceTest.php (SQLite, real models and controllers):
    • plans tomorrow (an order on another day and a canceled order are left out), stores the run with its reasons, commits dated tomorrow, keeps the draft hidden from the driver API, publishes it once, and marks the route active on the first stop
    • commit with publish / publish_at; a re-plan takes the order off its old route
    • a booked publish runs on time, and a stale booking does nothing
    • bulk publish of a day
    • reassignment through bulk assign, the Scheduler (same day and a new day), the order form PUT and unassign, a re-sequence within one route, finished stops staying put, and draft-to-draft moves
    • insert into an active route at its best fit, and a position before a finished stop moving to just after it
  • New unit tests for the reasons map, strict dates, the broadcast and push, the insertion estimator's edge cases and the publisher's refusals. The existing orchestrator, import, manifest, order-controller and engine tests were updated to the new contract.
  • Line coverage of every new and changed file is 100%, except lines that were already uncovered before this change.
  • Full per-file run: 528 files, 10 failing. All 10 fail the same way on the untouched base c4d0af3d, mostly in code from c929bdd7 (driver duty periods, fuel reports, issues, navigator links). They are not touched here.

Merged with feature/map-canvas (main through v0.7.4)

Conflicts resolved in Manifest, ManifestStop, the driver and internal ManifestControllers, OrchestrationController, OrderController, the service provider and the orchestrator contracts test; D1 was reworked to sit on main's route optimisation (see the merge commit message and the doc). Main's manifest tests were updated where they asserted that drafts are driver-visible.

…tween routes

- Orchestrator run plans the posted order ids or the orders scheduled for a posted date, and no longer falls back to every unassigned order on every date; order_statuses is honoured
- Every run is stored with the reason each order was left out, returned as unassigned_reasons keyed by order id with a plan_run_id; the driver-assignment engine now reports the orders it could not place, not vehicle ids
- Commit dates manifests and their orders by scheduled_date, creates drafts without telling drivers, takes re-planned orders off their old route, and can publish now or at a booked time
- Manifests go draft, published, active, completed, with published_at and a queued scheduled publish; driver endpoints only return routes that were published. Existing drafts stay drafts
- One reassignment service moves an order's unfinished stops between routes, re-sequences both, updates the order's driver, vehicle and manifest and tells both drivers; order detail, bulk assign, the Scheduler and commit all use it
- Insert an order into a route at a position, and a best-fit query that returns the cheapest insertion per driver
- Order import returns an outcome per row, can re-validate edited rows without creating anything, and marks created orders with imported_via_orchestrator and an import batch id
- The Orchestrator workbench publishes on commit, so its routes still reach drivers
- API changes are listed in docs/DISPATCH_WORKSPACE_API.md

Co-Authored-By: Claude <noreply@anthropic.com>
@roncodes roncodes changed the title Dispatch workspace D1: plan a day, publish routes, move orders between routes Dispatch workspace: plan a day, publish routes, move orders between routes Nov 27, 2026
feature/map-canvas now carries main through v0.7.4, including route optimisation
(ManifestBuilder, sequencing, locks, dispatch stop edits, manifest.changed). D1 is
reworked to sit on it rather than beside it:

- One lifecycle: draft (unpublished Orchestrator plan) -> published -> active (opened)
  -> in_progress (a stop worked) -> completed. ManifestBuilder's own routes start
  published; drivers never see, open or start a draft. The migration publishes
  existing auto-built drafts and leaves Orchestrator drafts as drafts.
- Commit is main's (one manifest per driver-day, one stop per order point) plus the
  date checks, order dating, quiet drafts, publish / publish_at and plan runs.
- RouteReassignment now drives ManifestBuilder: bulk assign and the Scheduler (which
  bypassed the manifest observer) go through it; it moves the vehicle, a new day's
  stops and orders.manifest_uuid, and positions an order on a chosen route. The
  order form's PUT is left to main's observer.
- The order insert endpoint moves to POST manifests/{id}/orders (main owns
  manifests/{id}/stops) with main's position convention; best-fit uses main's
  road-matrix ManifestStops::fit.
- manifest.updated is dropped for main's manifest.changed; a draft's goes to the
  company channel only.

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3f3b4b8) to head (93776dc).
⚠️ Report is 1 commits behind head on feature/map-canvas.

Additional details and impacted files
@@                   Coverage Diff                   @@
##             feature/map-canvas      #439    +/-   ##
=======================================================
  Coverage                100.00%   100.00%            
- Complexity                20500     20747   +247     
=======================================================
  Files                       787       794     +7     
  Lines                     65151     65726   +575     
=======================================================
+ Hits                      65151     65726   +575     
Flag Coverage Δ
backend 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…n's key

The /v1 manifest endpoints serve both Navigator (a driver's own token) and the
organisation's API key. Only the driver should be kept from drafts; the key that
committed a draft through /v1/orchestrator/commit reads, sequences and edits it.
This is what the Postman contract's manifest requests do.

Co-Authored-By: Claude <noreply@anthropic.com>
@roncodes
roncodes merged commit fbc524e into feature/map-canvas Dec 3, 2026
8 checks passed
@roncodes
roncodes deleted the feature/confident-ritchie-f0b22c branch December 3, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant