Skip to main content

reports

Read-only analytics reports (ADR 0012), served by cmd/st-reports from the separate analytical database the projector feeds from this context's own events. Days are UTC calendar days; from and to are inclusive dates.

📄️Introduction

REST contract of the shipping-and-tracking bounded context of the retail network, derived from retail-network-docs model/model.yaml (contexts[shipping-and-tracking].rest, .aggregates, .publishes, conventions.errors) and the orchestrator's contracts-delta (G2, G3, G11, G18). It issues shipping labels and owns each package's journey. No schema of this contract carries a ship-to address or any part of it: the address is read from customer-ordering at issue time (GetShipTo), kept only as an encrypted snapshot (purged 30 days after the journey closes) and never returned (ADR RN-0006, ADR 0002 A9). vendor-connectivity calls POST /labels in-organization; the other routes are read by shoppers, customer-ordering and operations tooling. No authentication, consistent with the fleet. Errors are RFC 9457 problem details. The shared problem types are not-found (404), illegal-transition (409), concurrent-update (409) and validation-failed (422), plus one slug per model Err name. The read-only analytics reports (tag reports, ADR 0012) are served by cmd/st-reports on its own port (per-path server) from the separate analytical database.

📄️Delivery outcomes and first-attempt success, per day

Per UTC day of the outcome instant (deliveredAt, returnedAt, declaredAt): packages delivered, delivered at the first attempt (no DELIVERY_FAILED scan), returned to the sender and lost. firstAttemptSuccessRate = firstAttemptDelivered / (packagesDelivered + packagesReturnedToSender + packagesLost); lostRate and returnToSenderRate share that denominator; meanAttemptsPerDeliveredPackage = (packagesDelivered + DELIVERY_FAILED scans of the delivered packages) / packagesDelivered, null on a day without deliveries. Days without an outcome are omitted.

📄️Issue a shipping label for one package (IssueLabel)

In-org route called by vendor-connectivity (contracts-delta E2). Reads the ship-to from customer-ordering (GET /orders/{orderId}/ship-to) BEFORE the transaction opens, stores it encrypted, starts the package journey (LABELLED) and publishes LabelIssued. The response never contains the address. A replay of the same Idempotency-Key returns the first response when that response is final for the request: a success and a refusal that is stored (see the Idempotency-Key parameter). A refusal that follows state which can change is not stored, and a retry under the same key executes again. An order collected at a pickup point (ADR 0016) has no address to read: the label's destination prefix is the point's own, taken from this context's local view of node-topology's pickup points, and the point must be ACTIVE in that view.

📄️Issue the reverse label of one package of a return (IssueReturnLabel)

In-org route called by customer-returns (ADR 0017, ADR 0018), the reverse twin of POST /labels. Reads the ship-to of orderId from customer-ordering BEFORE the transaction opens and derives the stopKey exactly like the outbound label of the same order (same secret over the same normalized address), so a return pickup stop groups with the outbound delivery stop by construction. The RETURN DESTINATION is named in exactly one of two ways. destinationNodeId names the returns node, and this context derives the label's destination prefix itself, from its own view of node-topology's registered nodes (ADR 0018): the caller holds no address data. destinationPostalPrefix, deprecated, is a prefix the caller supplies. Sending both, or neither, is validation-failed. A destinationNodeId this context holds no usable prefix for (the node's registration has not been consumed yet, or its registered postal code has no letter or digit from A-Z 0-9) is refused with 409 destination-prefix-unavailable and no label is stored, nor is the refusal kept under the Idempotency-Key, so the same request with the same key is executed again and served once the node is known; this context does not judge whether the node is the right one or whether it is active. The label rides the ground carrier (RN-GROUND), starts NO package journey and seals NO ship-to snapshot; scans of the reverse package are counted-and-acknowledged unknowns, and shopper-facing return tracking is customer-returns' authorization view. The response is a ReturnLabel: no poNumber, no assignmentId, purpose RETURN and the returnAuthorizationId. One label per (returnAuthorizationId, packageNo). A replay of the same Idempotency-Key returns the first response when that response is final for the request: a success and a refusal that is stored (see the Idempotency-Key parameter). A refusal that follows state which can change is not stored, and a retry under the same key executes again.

📄️Record one scan on a package journey (RecordScan)

RecordScan over REST. Scans apply in time order; an older scan is stored but does not move the state (409 scan-out-of-order, the scan is kept with applied=false). A scan whose scanType has no edge from the current state is stored with applied=false and answers 409 illegal-transition. A known scanId answers 409 duplicate-scan and stores nothing. A closed journey answers 409 journey-closed. The two refusals that keep the scan (scan-out-of-order, illegal-transition) are stored under the Idempotency-Key together with the scan, so a retry under the same key replays the refusal and never answers duplicate-scan.

📄️Report one external carrier event (ReportCarrierEvent, ADR 0015)

The carrier webhook of CARRIER_HANDOFF service areas. Unauthenticated by the standing fleet decision, exactly like POST /journeys/{trackingNumber}/scans (the per-carrier token scheme is a recorded follow-up). Each report becomes one scan with scanId '<carrierId>:<carrierEventId>', so a re-sent report answers 409 duplicate-scan. PICKED_UP is the handoff at the journey's handoff node (a journey already WITH_CARRIER is a no-op that answers 200); OUT_FOR_DELIVERY, DELIVERED and DELIVERY_FAILED become their scans; IN_TRANSIT is accepted and counted without a scan. A refusal that keeps the scan (scan-out-of-order, illegal-transition) is stored under the Idempotency-Key together with the scan and replayed on a retry.