Core and App Integration
Core and App integrations should generate types from the same production OpenAPI revision. Do not maintain handwritten event unions or public transport route mappings.
Generate the contract
bashcurl -fsS https://api.artery.questflow.ai/docs-json -o artery-openapi.jsonThe create and edit APIs use subscriptions[]. The sample-payload response is
a discriminated union over CloudEvents type, with event-specific exact
data schemas.
For account events, consume the generated market snapshot directly. App and
Core must not perform a second Gamma lookup or join by title. Prefer
market.title plus market.outcome.label; use a shortened
market.providerMarketId or market.symbol only when display metadata is
null. Persist the whole snapshot with the consumed event so historical UI does
not change after catalog refreshes.
The Activity response uses type as its wire discriminator and activityType
as its user-facing category. In particular, type=trade with
activityType=liquidation must render as Liquidated/ADL, while
type=settlement must render its action and result instead of Bought/Sold.
Receiver order of operations
- Read the raw request bytes and verify
X-Artery-Signatureusing the timestamped algorithm in Payload Shapes. - Parse JSON only after signature verification succeeds.
- Select the generated event type using CloudEvent
type. - Reject unsupported major versions into a visible dead-letter path.
- Atomically persist the event
idbefore returning2xx. - Apply revisions in
qfrevisionorder withinqfcorrelationid. - Preserve financial decimals as strings or arbitrary-precision values.
tsswitch (event.type) {
case 'com.questflow.broker.trade.executed.v1':
await acceptBrokerTrade(event);
break;
case 'com.questflow.broker.funding.updated.v1':
await acceptBrokerFunding(event);
break;
case 'com.questflow.broker.position.liquidated.v1':
await acceptBrokerLiquidation(event);
break;
default:
await deadLetterUnsupportedVersion(event);
}Release checklist
- Pin the OpenAPI artifact or its checksum in both Core and App.
- Validate every consumed fixture against the generated schema.
- Test valid, invalid, stale, and tampered signatures.
- Deliver the same
idrepeatedly and confirm idempotency. - Test two revisions under one correlation ID.
- Verify unknown versions are observable and replayable.
- Run create → list → edit → test → delivery history → delete before enabling production traffic.
- Verify Order, Trade, Redeem/Settlement, and Liquidation fixtures render
market.titleandmarket.outcome.label, with an abbreviated ID fallback. - Verify
activityTypekeeps normal losing trades, settlement Loss, and liquidation/ADL visually distinct and non-duplicated.