# Vendored ammunition data (iOS)

Independent copies of the ScopeDOPE built-in ammunition data, vendored into `iOS/` so the
iOS app has **no external reliance** on `scopedope-shared-main/` or `scopedope-android-main/`.
These were copied byte-for-byte (SHA-256 verified) and are now maintained here on their own.

## Contents

| File | Role |
|---|---|
| `databases/ammo_builtin.db` | **The bundled artifact.** Read-only SQLite shipped in the app; opened with GRDB. 130 loads / 28 calibers. |
| `ammo_builtin.csv` | **Source of truth** for built-in ammo content (edit this, then regenerate the DB). |
| `build-ammo-db.py` | Regenerates `ammo_builtin.db` from the CSV. Never edit the `.db` directly. |
| `schema/BuiltinAmmoDatabase_v4.json` | Reference schema (Room v4) the GRDB table must mirror exactly. |

## Table schema (`ammo`, v4)

Columns: `id`, `caliber`, `name`, `velocity_fps`, `bc_g1`, `bc_g7`, `is_user_defined`,
`bullet_weight_gr`, `mv_sensitivity_fps_per_f`, `mv_reference_temp_f`, `form_factor`,
`bullet_diameter_mm`, `bullet_length_mm`.

- Indexes: non-unique on `caliber`; **unique** composite on `(caliber, name)`.
- 4DOF columns (`form_factor`, `bullet_diameter_mm`, `bullet_length_mm`) exist in the
  schema but are unpopulated in built-in entries (default `0.0`) — 4DOF engine is a future
  version (SPEC §5.1).
- Both `bc_g1` and `bc_g7` are stored; `0.0` means unavailable for that model.

## iOS usage (Phase 1 of the build plan)

1. Bundle `databases/ammo_builtin.db` in the app target; open **read-only** via GRDB.
2. Create a **separate writable** `ammo_user.db` for user-defined entries — same `ammo`
   schema plus `is_user_defined = 1`. Mandatory migrations, **never** destructive fallback
   (SPEC §5.2 / §16).
3. To change built-in content: edit `ammo_builtin.csv`, run `build-ammo-db.py`, re-bundle.

## Provenance

- DB / CSV / build script: `ScopeDOPE/scopedope-shared-main/assets/` (read-only reference).
- Schema JSON: `scopedope-android-main/app/schemas/...BuiltinAmmoDatabase/4.json`
  (Room-generated; `version: 4`, `identityHash: 36564dfb487097577ad0c53262df5d73`).

Originals were not modified.

---
© 2026 Cold Bore Ballistics LLC. Proprietary and Confidential.
