Skip to content
Spacefolder Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Intervene at checkout

Navigation quality, TypeScript SDK example and recorded choice for the checkout benchmark.

KPI · Expected dollars per checkout ($30 per timely payment, minus $180 per reported fraud and $0/$0.50/$3 for continue/verify/review).

Navigation score by prior navigations per World.

After 1,000 navigations per World

Spacefolder chose the highest-value action on 96 of 96 held-out navigations.

Approach Expected utility Score / 100
Spacefolder 12.978 100.00
Vector search + SQL for matching situations¹ 12.978 100.00
SQL for all situations¹ 10.434 82.81
First listed action 7.352 52.08
Ground truth 12.978 100.00

¹ Stack analogies. The replay averaged each action’s outcomes in memory, grouping by exact situation for the first baseline and pooling all situations for the second.

TypeScript SDK example

TypeScript SDK · Navigate API

import { SpacefolderClient } from "@spacefolder/sdk";

const sf = new SpacefolderClient();
const navigation = await sf.navigate({
  nav_id: crypto.randomUUID(),
  world_id: "checkout_example",
  entity_type: "shopping_order",
  entity_id: "shopper-trip:checkout-verification",
  context: { scene: "Returning customer on a recognized device" },
  actions: {
    continue_checkout: {"name": "checkout.payment_submitted", "data": {"provider": "stripe"}},
    request_verification: {"name": "checkout.verification_requested", "data": {"method": "existing_account_auth"}},
    pause_review: {"name": "checkout.review_requested", "data": {"queue": "merchant"}},
  },
  predictions: {
    paid: {"event": "payment_intent.succeeded", "horizon": "5m"},
    fraud_reported: {"event": "checkout.fraud_reported", "horizon": "120d"},
  },
});

const cost = { continue_checkout: 0, request_verification: 0.50, pause_review: 3 };
let chosen: string | undefined;
let best = -Infinity;
for (const action of ["continue_checkout", "request_verification", "pause_review"] as const) {
  const paid = navigation.actions?.[action]?.predictions.paid;
  if (!paid || !("probability" in paid) || typeof paid.probability !== "number") continue;
  const fraud_reported = navigation.actions?.[action]?.predictions.fraud_reported;
  if (!fraud_reported || !("probability" in fraud_reported) || typeof fraud_reported.probability !== "number") continue;
  const utility = 30 * paid.probability - 180 * fraud_reported.probability - cost[action];
  if (utility > best) {
    best = utility;
    chosen = action;
  }
}
console.log(JSON.stringify({ chosen }, null, 2));

Example output

Returning customer on a recognized device

{
  "chosen": "continue_checkout"
}

Submit the selected checkout intervention once. Observe five-minute payment completion and allow 120 days for fraud reports before closing the trial.