---
title: Recover a failed migration
description: Navigation quality, TypeScript SDK example and recorded choice for the coding benchmark.
sidebar:
  label: Coding
---

**KPI** · Probability of completing the task within five minutes.

![Navigation score by prior navigations per World.](/docs/benchmarks/industry-coding.png)

## 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 | 0.609 | 100.00 |
| Vector search + SQL for matching situations¹ | 0.609 | 100.00 |
| SQL for all situations¹ | 0.506 | 61.18 |
| First listed action | 0.370 | 48.96 |
| Ground truth | 0.609 | 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](/docs/reference/sdks#typescript-and-javascript) · [Navigate API](/docs/reference/api/navigate/navigate)

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

const sf = new SpacefolderClient();
const navigation = await sf.navigate({
  nav_id: crypto.randomUUID(),
  world_id: "coding_example",
  entity_type: "task_revision",
  entity_id: "migration-schema",
  context: { scene: "Transient database connection failure" },
  actions: {
    retry: {"name": "agent.retry", "data": {"scope": "migration"}},
    search: {"name": "agent.search", "data": {"scope": "migration_and_schema"}},
    replan: {"name": "agent.replan", "data": {"strategy": "inspect_schema_then_patch"}},
  },
  predictions: {
    success_rate: {"event": "task.completed", "horizon": "5m"},
  },
});

let chosen: string | undefined;
let best = -Infinity;
for (const action of ["retry", "search", "replan"] as const) {
  const success_rate = navigation.actions?.[action]?.predictions.success_rate;
  if (!success_rate || !("probability" in success_rate) || typeof success_rate.probability !== "number") continue;
  const utility = success_rate.probability;
  if (utility > best) {
    best = utility;
    chosen = action;
  }
}
console.log(JSON.stringify({ chosen }, null, 2));
```

## Example output

**Transient database connection failure**

```json
{
  "chosen": "retry"
}
```

Run the selected retry, schema search or replan on the failed revision. Record task completion against that revision before the five-minute deadline.
