# Migrating to Activix v6 — root `outer` / `inner`

## Summary

- **Removed** the nested **`structure`** object. **`outer`** and optional **`inner`** live at the **document root** next to **`runContext`**, **`status`**, etc.
- **Removed** collection option **`structureField`**.
- **`inner`** tier keys are now **`request`**, **`response`**, **`metadata`** (not `input` / `output`).
- **Phased writes:** you may omit **`outer.output`** and **`inner.response`** on early payloads; they are normalized to **`null`**. Later updates can set **`inner.response`**, **`outer.output`**, or both (see [activity-structure.md](./activity-structure.md#phased-writes-typical-order)).

## Before (v5)

```typescript
await ax.startRecord({
  runContext: { sessionId: 's1' },
  structure: activixStructure(
    activixTier({ prompt: 'hi' }, null, { model: 'gpt-4o' }),
    activixTier(rawReq, null, {})
  ),
});
await ax.completeRecord(id, {
  structure: { outer: { output: { text: 'hello' } } },
});
```

## After (v6)

```typescript
import { activixActivityIo, activixInnerTier, activixOuterTier } from '@x12i/activix';

await ax.startRecord({
  runContext: { sessionId: 's1' },
  ...activixActivityIo(
    activixOuterTier({ prompt: 'hi' }, null, { model: 'gpt-4o' }),
    activixInnerTier(rawReq, null, {})
  ),
});
await ax.completeRecord(id, { outer: { output: { text: 'hello' } } });
```

## API renames (helpers)

| v5 | v6 |
|----|-----|
| `activixTier` | `activixOuterTier` (or keep using deprecated `activixTier` alias) |
| `activixStructure(outer, inner?)` | `activixActivityIo(outer, inner?)` (or deprecated `activixStructure`) |
| `mergeActivityStructureField` | `mergeActivixActivityIo` (deprecated alias still exported) |
| `validateActivityStructure(doc, 'structure')` | `validateActivityStructure(doc)` |

## Queries and indexes

Replace paths such as **`structure.outer.input`** with **`outer.input`**. Optional **`inner`** fields: **`inner.request`**, **`inner.response`**.

## Persistence diagnostics

`resolveActivixPersistenceTarget` no longer returns **`structureField`**. `summarizeActivixActivityForDiagnostics` no longer accepts **`structureField`**; it reads **root `outer`**, with a **read-only** fallback to **`structure.outer`** for legacy documents.
