feat: express-batch dispatch — manual trigger for the AI agent
Adds the backend half of the ExpressDispatchAgent flow. Express orders can now be created batch by batch (bulk create only accumulates them, unassigned), then an operator hits one endpoint to hand the whole pending set to the agent for tenant-scoped assignment + road sequencing. The normal B2C flow is untouched. - POST /admin/expressbooking/dispatch: manual trigger. Console-auth, tenant- scoped; gathers the tenant's pending unassigned express orders (or a chosen subset) and publishes express.dispatch_requested. - internal API for the agent: GET /internal/express/riders (tenant's available riders), GET /internal/express/bookings, POST /internal/express/assign (writes the agent's decided assignments with their sequence; re-checks the already- assigned guard so the agent can't double-assign). - booking_assignment_service.go: extracted a behavior-preserving assignMilerTx core; AssignMilerToBooking is unchanged in behavior. assignExpressStops writes a batch, one FCM per rider instead of one per stop. - EXPRESS JetStream stream / express.dispatch_requested subject. - Gated behind EXPRESS_AGENT_ENABLED (default off): deploying this changes nothing until the agent is confirmed running and the flag is flipped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,14 @@ var streamSubjects = map[string][]string{
|
||||
// missing from the stream, bookings are never assigned at all.
|
||||
"booking.assignment_requested",
|
||||
},
|
||||
"EXPRESS": {
|
||||
// The console's manual "dispatch" action publishes this; the
|
||||
// ExpressDispatchAgent (logistics-ai) consumes it to run tenant-scoped
|
||||
// batch assignment + route sequencing over the pending orders. Missing
|
||||
// subject → the dispatch is never handed off and bookings sit unassigned
|
||||
// until someone assigns them by hand.
|
||||
"express.dispatch_requested",
|
||||
},
|
||||
"STATUS": {
|
||||
"booking.status.updated",
|
||||
"booking.cancelled",
|
||||
|
||||
Reference in New Issue
Block a user