# Post-Recording Reconciliation

This is the important step between recording and editing.

Before recording, Slate's script annotations often describe intended B-roll: what the creator should capture. After recording, those annotations are stale unless they are replaced with the actual clips that were recorded and analyzed.

## Agent Procedure

1. Sync and wait for media analysis:

```sh
slate sync media --yes --wait --json
```

If this fails before syncing files, read `message` and `safeNextAction` from the JSON output and stop there. The correct user explanation is about the workflow blocker ("media processing needs to be running") rather than the implementation detail ("queue request failed").

2. Inspect the completed linked media and verify clip categories:

```sh
slate clips list --scope linked --processing-phase completed --limit 100 --json
```

Before creating the A-roll cut, confirm that `a_roll` clips look like the primary narration/talking-head footage and that `b_roll` clips look like supplemental visuals. Use titles, descriptions, transcript availability, filenames, duration, and the local folder layout together.

If a clip was classified incorrectly, correct it before continuing:

```sh
slate clips set-type <clip-id> a_roll --yes --json
slate clips set-type <clip-id> b_roll --yes --json
```

Tell the user what changed in workflow language, e.g. "This clip is the main talking-head recording, so I marked it as A-roll."

3. Inspect script blocks and placeholder annotations:

```sh
slate scripts blocks list --json
```

4. Retrieve embedding-assisted candidates:

```sh
slate scripts annotations candidates --limit 5 --json
```

This command is the canonical recorded-footage reconciliation surface. It emits one candidate set per placeholder annotation. Each search query is built from that placeholder's label/description, not from the whole script block, and results are scoped to the linked media folder inferred from `.slate/link.json`.

Also keep a compact inventory of completed linked B-roll nearby:

```sh
slate clips list --scope linked --processing-phase completed --type b_roll --limit 100 --json
```

Use broad `slate clips search` only when the user explicitly asks to source clips outside the recorded folder.

5. Use LLM judgment to decide which real clips match each placeholder. Do not let code choose this mapping deterministically.

6. Write an explicit replacement file:

```json
{
  "updates": [
    {
      "blockId": "33333333-3333-3333-3333-333333333333",
      "removals": ["placeholder-assignment-id"],
      "additions": [
        {
          "category": "b-roll-library",
          "clipId": "55555555-5555-4555-8555-555555555555",
          "relevanceReason": "The analyzed clip shows the dashboard close-up requested by the placeholder."
        }
      ]
    }
  ]
}
```

7. Ask the user to confirm before applying.

Use this wording:

```text
I’m about to update your Slate project by replacing placeholder B-roll notes with the actual footage clips. This is what lets Slate generate the edit timeline accurately. Should I apply these replacements?
```

Do not run the apply command until the user confirms.

8. Apply it:

```sh
slate scripts annotations apply --file .slate/annotation-replacements.json --yes --json
```

9. Verify:

```sh
slate scripts blocks list --json
```

Only then continue:

```sh
slate sync b-roll --mode reference --yes --json
# if reference mode reports external clips and the user approves:
slate sync b-roll --mode download --yes --json
slate sync script --yes --wait --json
slate edit hydrate
```

Run `sync b-roll --mode reference` first. If it reports any items, ask the user before downloading external/reused library footage into `External Media`. Do not remove missing-media overlays from the local sequence as a workaround.

## Rules

- Preserve script text unless the user asks to rewrite it.
- Replace placeholder `b-roll` or `stock-footage` annotations with `b-roll-library` additions that reference real `clipId` values.
- Use `removals: ["*"]` only when replacing all annotations on a block.
- If the match is uncertain, leave the placeholder and report the uncertainty instead of inventing a clip assignment.
