15. Contract corrections from the 2026-10-05 docs audit
Status
Accepted (2026-10-06). Additive to ADR 0001
and ADR 0014; amends
neither. No existing field, status code, event type or dataschema is
removed or changes meaning.
Context
The 2026-10-05 DDD documentation refresh compared the published contracts and the code and found drift in both directions:
apis/openapi.yamldid not describeGET /capability-offersorPOST /network-orders/{networkRef}/shipment-confirmation, both registered ininternal/adapters/inbound/http/server.go.POST .../shipment-confirmationon an order that is notACKNOWLEDGEDreturned500 internal-error:statusFor/problemForhad no case fornetworkorder.ErrConfirmBeforeAcknowledge, so a caller-fixable business rule was reported as a server bug (the same defect class the existingerrors_test.goguard exists to prevent).- CORS allowed only
GET/OPTIONS, so a browser could not call thatPOSTcross-origin. PostgresProjection.ApplyNetworkOrderRejectedhad no counter for reasonSUBMISSION_FAILED(a submitted acknowledgement that reconciliation found the network refused). The event was claimed and then contributed to no column, so these rejections vanished from the acknowledgement report.apis/asyncapi.yamlomittedAcknowledgementDeadlineAtRiskfrom the analytics channel although the composition root's fan-out publishes every event to both topics, and described four events where the code has five.
Decision
ErrConfirmBeforeAcknowledgemaps to409 Conflict, problem typehttps://errors.network-fulfillment.warehouse-systems.dev/confirm-before-acknowledge, in bothstatusForandproblemFor. 409 because the request is well formed and the order exists, but its current lifecycle state conflicts with it. Callers that previously saw a 500 for this case now see a 409; no caller can reasonably depend on the former 500.- CORS allows
POST(GET, POST, OPTIONS) so the one ADR-0014 write endpoint is callable from the browser console. No new write endpoint is added; Hard rule 9 stands. - The acknowledgement report row gains
ordersRejectedSubmissionFailed(RESTGET /reports/acknowledgement, the MCP report view, andreport.Row.OrdersRejectedSubmissionFailed). It is backed by a new additive analytics migration (migrations/analytics/0002_...:ADD COLUMN orders_rejected_submission_failed BIGINT NOT NULL DEFAULT 0). Existing columns, JSON fields and their meaning are unchanged; consumers that ignore unknown fields keep working. History is not back-filled: rows aggregated before this change read 0, and the claimed event ids inanalytics_processed_eventsare not replayed. Rebuilding by replaying the analytics topic into an empty read model would populate it. - The OpenAPI and AsyncAPI documents are corrected to match the code:
the two missing routes (with
CapabilityOfferschema, 204/404/409/422/500 for the POST), the analytics-channelAcknowledgementDeadlineAtRiskmessage, the five-event description, the IQVO contact URL, and the real timing ofNetworkOrderAcknowledged(below). The AsyncAPI changes are documentation only; no eventtype,dataschemaor payload changes, so the CloudEvents type catalogue (ADR 0008) is unaffected.
Not decided here (design notes the audit raised)
These were reported to the product owner rather than changed, because neither ADR 0001 nor ADR 0009 specifies the behaviour:
NetworkOrderAcknowledgedtiming. The event is published when the order becomesSUBMITTED, beforeReconcileSubmittedOrderssettles it, andSUBMITTED -> ACKNOWLEDGEDraises no event. ADR 0001 §5 requires the submitted-but-unreconciled state to be visible and AGENTS.md rule 8 requires work to be released only after reconciliation; neither says when the integration event fires. The AsyncAPI now documents the true timing so consumers are not misled. Moving the event, or addingNetworkOrderSubmitted/ a settled event, is an event-contract change that needs its own decision (see the audit report for the options).contract.EligiblePath.CycleTimeP95is cached but unused byRecomputeCapabilityOffers.throughputFeasible. ADR 0001 listscycleTimeP95 + CPTScheduleas inputs tothroughputFeasibleBeforebut does not specify how cycle time combines with remaining capacity, so no rule is invented here.
Consequences
Easier: the published REST and event contracts describe what the service actually does; confirm-before-acknowledge is a diagnosable 409; operators see network-refused submissions in the acknowledgement report; the browser console can call the shipment-confirmation endpoint.
Harder / to watch: the new report counter starts at 0 for history that predates the migration. The two design notes remain open and the AsyncAPI text now states them plainly, so changing either later is visibly a contract change.