# v227 GDR-8050L Redump media-profile preflight

v227 keeps live iSCSI/auth/media behavior stable and adds a fail-fast media-profile preflight.

## What changed

- Added `hlds_gdr_media_profile_preflight.py`.
- The live start scripts run preflight before starting the iSCSI target.
- `collect_logs` reruns preflight and includes the preflight report in the artifact zip.
- Preflight verifies the corrected XGD1 Redump-style `.media.json` / `.xdvd.json` / ISO / sidecar payload contract.

## Why this exists

The corrected option-1 dumper output uses a reconstructed Redump-style backing ISO, while the emulated GDR8050L still exposes firmware-faithful locked and unlocked host-visible geometries. These coordinate systems must stay separate.

v227 refuses to start the live target if the intended media/profile pairing is missing or inconsistent.

## Preflight checks

The preflight checks include:

- backing ISO exists and byte/sector count matches the media profile;
- `.xdvd.json` exists;
- adjacent `.media.json` exists;
- layout type is `original_xbox_xgd1_redump_style_2048`;
- sector size is 2048;
- reconstructed output sector count is 3,820,880;
- layerbreak metadata is 1,913,776;
- locked view is 6,992 sectors;
- unlocked GDR8050L view is 3,431,264 sectors;
- locked video L0/L1 routing is correct;
- unlocked host LBA to reconstructed ISO LBA routing is correct;
- AD C0 / PFI / DMI sidecars are present and have the expected sizes;
- declared payload hashes are honored when present.

Expected warnings such as `redump_style_padding_zero_filled_pending_hardware_capture` remain warnings, not failures.

## Normal run

```powershell
.\gdr8050l_auth_v227_stateful_relock_keep_loaded_iscsi_start.cmd `
  .\gdr8050l_auth_v227_stateful_relock_keep_loaded_iscsi_config.json `
  "D:\vscode-workspace\xbox-dvd-tools-v2\disc_dumps\Red Faction II[TQ00501A].iso" `
  192.168.0.8 `
  3260
```

## Collect reports

```powershell
.\gdr8050l_auth_v227_dynamic_iscsi_collect_logs.ps1
```

Expected new line:

```text
[MEDIA-PROFILE-PREFLIGHT] mode=redump_profile model_loaded=true media_profile_loaded=true ... failed=0 ok=true
```

## Optional full image hash check

Full ISO hashing is intentionally not part of the normal start/collect path. To run it manually:

```powershell
python .\hlds_gdr_media_profile_preflight.py `
  --config .\gdr8050l_auth_v227_stateful_relock_keep_loaded_iscsi_config.json `
  --iso "D:\vscode-workspace\xbox-dvd-tools-v2\disc_dumps\Red Faction II[TQ00501A].iso" `
  --strict-image `
  --require-media-profile `
  --expect-redump `
  --hash-image `
  --json media_profile_preflight_hash_report.json `
  --md media_profile_preflight_hash_report.md
```
