1. Principal & Merchant of Record versus marketplace introductions
Buying one-off operational jobs — collecting an unboxed machine from a collection-only seller, printing an obsolete bracket, translating a notarised corporate extract, sourcing a European OEM salvage module or migrating off a legacy SaaS tool over a weekend — normally forces a business to vet an unfamiliar subcontractor, pay upfront on bank transfer and chase refunds alone if a deadline slips.
Across all eight Group B managed services (/services#managed), we sell the complete service directly to you as principal and merchant of record at a locked quote or fixed price (Stripe Checkout or PayPal, zero surcharges). Behind the scenes, our orchestrator dispatches execution to vetted carriers, print bureaux, translators, equipment suppliers or migration specialists while keeping supplier settlement locked behind an internal payout-hold state machine (packages/payments/src/escrow.ts).
2. The six-state hold machine and crash-safe idempotency
Financial state machines fail in production when network timeouts occur mid-transfer or retry workers pay a supplier twice. Our escrow_holds implementation enforces four strict database and code invariants:
- Invariant 1 — Capture before hold:
openHold()verifiesorder.paidAtinside a row-locked transaction and refuses any hold wherepayout.amountMinor >= order.priceMinoror currencies mismatch. - Invariant 2 — Unique per order: A unique index on
escrow_holds.order_idmakes it impossible to open two supplier payout records for the same customer order. - Invariant 3 — Two-phase pending settlement: Recording the gate decision (
release_pendingorrefund_pending) commits to PostgreSQL before any external transfer or refund call runs, keyed byescrow-release-${holdId}orescrow-refund-${holdId}. - Invariant 4 — Dispute freeze: Once
flagDisputed()setsstatus = "disputed", automated sweepers cannot release supplier funds; only an operator review can return the hold toheldor triggerrefund_pending.
// Allowed state transitions (enforced by assertTransition + SELECT ... FOR UPDATE row lock):
// held ──(release gate passes)──────────▶ release_pending ──(transfer confirmed)──▶ released
// ├───(gate rejects / deadline passes)▶ refund_pending ──(refund confirmed)────▶ refunded
// └───(buyer reports issue)───────────▶ disputed ──(operator decision)───▶ held | refund_pending
const releaseIdempotencyKey = (holdId: string) => `escrow-release-${holdId}`;
const refundIdempotencyKey = (holdId: string) => `escrow-refund-${holdId}`;
// Step 1 (DB transaction): recordDecision() moves held -> release_pending or refund_pending. Zero money moves here.
// Step 2 (Provider call): settlePending() calls transfer() or refund() with the deterministic idempotency key.
// If a worker crashes between Step 1 and Step 2, the sweeper replays the exact idempotent call safely.3. What counts as objective completion proof per Group B service
Each Group B pipeline defines proofRequired at hold creation and merges partner webhooks or verification artefacts via attachProof() before running its release gate: