> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withmithras.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Instagram Live Validation

> Final checks required before running Instagram capabilities unattended.

# Instagram Live Validation

Instagram support uses the same process-first API as TikTok, but live execution stays manual-only until the OnePlus controlled validation artifact is green. Do not use Motorola evidence for Instagram parity.

## Required Order

1. Apply and verify the Instagram platform migration.
2. Add controlled fixture values to ignored `.env.local` or a local fixture file.
3. Run login + health readiness on the OnePlus.
4. Run login + health live validation for the controlled actor.
5. Run the no-side-effect full readiness check.
6. Run the controlled live parity validator.

## Database Migration

Root `migrations/*.sql` files are not Supabase CLI migration files. Apply migration 015 explicitly:

```bash theme={null}
export PGPASSWORD="<Phonefarm Supabase database password>"
python3 -m scripts.db.instagram_platform_migration --apply --json
```

Verify without applying:

```bash theme={null}
python3 -m scripts.db.instagram_platform_migration --json
```

The verifier checks `capability_requests.platform`, `queue_items.platform`, platform-aware idempotency indexes, and platform-scoped target-control-plane uniqueness.

## Controlled Fixtures

Prefer ignored env values for credentials:

```bash theme={null}
PHONEFARM_INSTAGRAM_LOGIN_IDENTIFIER=controlled-alias@example.com
PHONEFARM_INSTAGRAM_LOGIN_PASSWORD=replace_with_controlled_password
PHONEFARM_INSTAGRAM_EXPECTED_USERNAME=controlled_username
```

To create the missing ignored keys without printing values, run:

```bash theme={null}
python3 -m scripts.validation.instagram_env_bootstrap \
  --checks login,health \
  --include-optional \
  --json
```

To set a specific key, pass `--set NAME=VALUE`; existing non-empty values are preserved unless `--force` is also passed. For real secrets, prefer `--from-stdin-json` so values do not land in shell history. The command output reports key names only, not secret values.

You can also copy the tracked example into the ignored local file:

```bash theme={null}
cp planning/instagram_live_fixtures.example.json planning/instagram_live_fixtures.json
```

Fill it with controlled actor and target values only. The local file is gitignored because it can contain credentials, target handles, captions, and media paths.

Required fixture groups:

* `account_create`: `email_alias`, `password`
* `login`: `login_identifier`, `password`
* `health`: optional `expected_username` to prove the controlled actor on the profile surface
* `profile`: at least one of `display_name`, `bio`, or `username`
* `post`: `video`, `caption`, `allow_unfenced_post: true`
* `story`: `media`, `allow_unfenced_share: true`
* `comment`: `target_video_url`, `text`, `dedupe_key`
* `warmup`: `allow_live_warmup: true`
* `dm`: `target_handle`, `message_text`

When `--fixtures-env` is used, the readiness JSON includes `missing_by_check` and `missing_env_vars_by_check` for any selected checks that still need local env values.

## Login + Health First

Run this before full parity. It only requires the controlled login env keys and optional expected username:

```bash theme={null}
python3 -m scripts.validation.instagram_live_readiness \
  --phone phone_01 \
  --actor-account account_instagram_actor \
  --target-account account_instagram_target \
  --fixtures-env \
  --checks login,health \
  --check-device \
  --prepare-device \
  --require-db \
  --output state/validation/instagram_full_parity/readiness_login_health_latest.json
```

Then run the login + health validator:

```bash theme={null}
python3 -m scripts.validation.instagram_full_parity_validation \
  --phone phone_01 \
  --actor-account account_instagram_actor \
  --target-account account_instagram_target \
  --execute \
  --controlled-only \
  --fixtures-env \
  --checks login,health \
  --output state/validation/instagram_full_parity/phone_01_account_instagram_actor_login_health_latest.json
```

If `PHONEFARM_INSTAGRAM_EXPECTED_USERNAME` is set, health must verify that handle on the profile tab before reporting `healthy`.

## Full Readiness Check

Run this before any live Instagram validation:

```bash theme={null}
python3 -m scripts.validation.instagram_live_readiness \
  --phone phone_01 \
  --actor-account account_instagram_actor \
  --target-account account_instagram_target \
  --fixtures-env \
  --check-device \
  --prepare-device \
  --require-db \
  --output state/validation/instagram_full_parity/readiness_latest.json
```

The readiness check has no social side effects. It validates the OnePlus-only policy, fixture completeness, route planning, optional DB migration status, and current OnePlus Instagram login state.

## Controlled Live Run

After readiness is `ready`, run the live validator:

```bash theme={null}
python3 -m scripts.validation.instagram_full_parity_validation \
  --phone phone_01 \
  --actor-account account_instagram_actor \
  --target-account account_instagram_target \
  --execute \
  --controlled-only \
  --fixtures-env \
  --output state/validation/instagram_full_parity/phone_01_account_instagram_actor_latest.json
```

Instagram parity is not live-verified until that artifact shows every required check as `success`.
