Risk decisioning: end-to-end implementation in Quarreh
A risk decision is more than a score. In Quarreh we are building it as a traceable workflow: request, evidence, policy, outcome and review.
Risk decisioning is often described as a model that returns a number. In a live commerce and delivery platform, the model is only one input. The harder engineering is the path around it: how a decision is requested, what evidence it can see, which policy is in force, what happens when the answer is “review”, and how the decision can be explained afterwards.
What the decision has to answer
For Quarreh, a risk decision answers a narrow operational question: should this order or payment proceed, should it wait for a person, or should it be stopped? The answer needs to be consistent, timely and attributable to a policy version that was in force at the time.
That framing matters. A decision engine that returns a score without recording the request, the evidence and the policy is difficult to operate and almost impossible to audit. We treat the decision as a record, not just a response.
Where decisioning sits
Decisioning is a boundary, not a step buried inside the order service. Order and payment flows call a decision service with a stable request shape. The service evaluates policy, records the outcome and returns an action. It does not create the order, assign a courier or move money.
type DecisionRequest = {
idempotencyKey: string;
subject: {type: "order" | "payment"; id: string};
context: {
amountMinor: number;
currency: "GMD";
channel: "app" | "counter";
merchantId: string;
};
signals: Record<string, unknown>;
};
type Decision = {
outcome: "allow" | "review" | "decline";
reasons: Array<{code: string; message: string}>;
policyVersion: string;
};Evidence before evaluation
A decision without its evidence is not reproducible. The request carries signals already known to the platform, and the decision service snapshots the exact values used, including their source and the time they were read.
Signals include order value, channel, delivery destination, merchant history and account age. We treat them as facts with provenance, not as a single blended score that cannot be inspected later.
Signals are data, not destiny
A signal can be missing, delayed or wrong. The service records whether a signal was present, inferred or unavailable so that the eventual outcome can be read in context rather than as an unexplained verdict.
Rules first, models where they earn their place
Deterministic rules are the backbone: amount thresholds, blocked destinations, velocity limits and review triggers. A model can add a signal, but it does not silently become the policy. Each model output is named, versioned and reported alongside the rule outcome.
This keeps the first version operable: when a decision is challenged, the team can point to the rule or signal that drove it. Models are introduced only where they improve a decision we can already evaluate.
A decision should be explainable without the person who made it in the room.
The decision record
Every decision produces an immutable record. The record contains the subject, the outcome, the reasons, the evidence snapshot, the policy version and the time of evaluation. That record is the source of truth for review, reconciliation and later analysis.
create table risk_decision (
id text primary key,
subject_type text not null,
subject_id text not null,
outcome text not null check (outcome in ('allow', 'review', 'decline')),
policy_version text not null,
reasons jsonb not null,
evidence jsonb not null,
created_at timestamptz not null default now()
);Holding for review
A review outcome is a first-class result, not an error. It routes the transaction to an operations queue with the reasons and evidence attached. A person can approve, decline or ask for more information. The override, the reviewer and the reason are recorded with the same care as the automated decision.
Human review is deliberately part of the loop. Risk decisions can have real consequences for a customer or a business, and the platform is designed so that a person can see why the system hesitated.
Failure behavior
Timeouts, duplicate requests and partial data are expected. Requests carry idempotency keys, and retries return the original decision rather than evaluating twice. Each decision type declares whether it fails open or closed: a missing non-critical enrichment may allow a low-risk action to continue, while a missing payment-boundary decision blocks the action.
What we measure
We care about decision latency, the share of transactions sent to review, override rates, reason-code distributions and the frequency of missing evidence. Those numbers describe how the workflow behaves in practice; a single model metric does not.
Pre-launch
This is the implementation we are building for Quarreh, which remains in pre-launch preparation. We are not presenting a launched risk engine or production outcomes. Human-defined policy and human review stay part of the loop, and the system is designed to make both explainable.

