# Provenance of every input to the FlyLab command-driven flight policy (track C)

Rule: no GPL-3.0+ figshare artifact is read, downloaded, or used in any way. That covers the trained
policies (`trained-fly-policies.zip`), the flight dataset (`flight-dataset_saccade-evasion_augmented.hdf5`),
**`wing_pattern_fmech.npy`**, and the controller-reuse checkpoints. None of them is used as data,
initialisation, teacher, reference trajectory, wing pattern or reward target.
The scripts here never open `tools/flight-policy/pol/` or `tools/flight-policy/flightds/`.
The integration test (`policy-test.mjs` group `own`) compares the own policy only with the Python env it was trained in;
it never compares with, or uses as a target, the GPL policy or dataset (those groups of the same file are separate).
`flyenv.py` always passes its own pattern path to the WBPG.

| Input | Where it comes from | Licence | How it is used |
|---|---|---|---|
| Fly model XML + meshes | `vendor/flybody/flybody/fruitfly/assets/` (byte-identical to `web/public/model/fruitfly.xml` except `meshdir`; `build_model.py:check_xml()` asserts this and records `xml_identical_to_flylab: true`) | Apache-2.0 (flybody repo `LICENSE`) | Compiled into `~/.cache/flylab-train/flight.mjb` |
| Flight model edits | `flybody/tasks/base.py:271-365` (`Flying`) + `tasks/constants.py:15-31` (wing gain 18, damping, stiffness, fluidcoef, 218 Hz, ±5 % frequency range) | Apache-2.0 | Called as code by `build_model.py` |
| Walker / action layout / sensors | `flybody/fruitfly/fruitfly.py` | Apache-2.0 | Called as code (action spec, sensor sites) |
| Wingbeat pattern generator class | `flybody/tasks/pattern_generators.py:8-207` | Apache-2.0 | Imported; fed **our** pattern file |
| Seed of the wing pattern | Built-in "simple approximation" in `pattern_generators.py:53-59` (analytic sines, no data) | Apache-2.0 | Starting point of the CMA-ES trim only |
| **Our wing base pattern** `pattern.npy` | `trim_pattern.py`: physics-only optimisation so that cycle-mean lift = weight and thrust/torques ≈ 0, with the body fixed at 47.5° | ours | WBPG base pattern |
| Residual-on-pattern action scheme | Design idea from `flight_imitation.py:146-168` (re-implemented in `flyenv.py`) | Apache-2.0 | Env action mapping |
| Network architecture | `flybody/agents/network_factory.py:66-103` (layer sizes and activations only, no weights) | Apache-2.0 | Re-implemented in PyTorch; weights are random-initialised |
| Body pitch 47.5° | `tasks/constants.py:18`, citing Muijres et al. 2014, *Science* 344:172 (published fact) | fact | Initial pose |
| Wingbeat base frequency 218 Hz (*D. melanogaster*) | `tasks/constants.py:24`; Vaxenburg et al. 2025 (*Nature*, doi:10.1038/s41586-025-09029-4) text | fact | WBPG base frequency |
| Stroke amplitude ≲ 160° (bound) | Published kinematics (e.g. Fry, Sayaman & Dickinson 2003, *Science* 300:495; Muijres et al. 2014) | fact | Upper bound on `A_y` in the trim; the result is 152° |
| Saccade envelope 30–120° in 50–100 ms (stage 3, not run yet) | Published saccade statistics (Muijres et al. 2014/2015 report median ≈ 88° with peak rates ~1,900–3,900 °/s; quoted in `docs/flight-policy-feasibility.md`) | fact | Ranges of the procedural command generator only (no trajectories) |
| Terminal height 0.2 cm | `tasks/constants.py:19` | Apache-2.0 | Ground-contact proxy in the termination check |
| PPO algorithm | Schulman et al. 2017; CleanRL-style implementation written here | — | `train_ppo.py` |
| Python deps | mujoco 3.14 / mujoco-mjx / mujoco-warp (Apache-2.0), dm_control (Apache-2.0), PyTorch (BSD), NumPy, matplotlib, JAX (Apache-2.0), warp-lang (Apache-2.0) | permissive | Tooling only; nothing is shipped |
| Fly–fly contacts off in training (v2+) | Mirrors FlyLab's own flight mode (`web/src/plugins/fly/flight.ts` `applyParams`: fly geoms contype 0); flybody's flight model keeps femur–abdomen and labrum contacts | FlyLab code (own) | `flyenv.py` sets fly geoms' contype/conaffinity to 0; a model setting, no data |
| Python→JS parity dump `parity_dump.json` | Written by `export_flylab.py` from **our** env and **our** policy (states, observations, actions) | ours | Test fixture for `web/src/plugins/fly/policy-test.mjs` group `own`; never a training target |
| Turn commands (stage 2) | Procedural constant yaw-rate segments, \|rate\| ≤ 500 °/s in the turn stage (`flyenv.Commands`, `--yaw_max_dps`), no trajectories | ours | Command generator only |
| Compute | Local Apple M2 Pro (12 cores), ≤ 6 rollout processes + 4 learner threads (v2: 5 + 4) | — | — |

**Outputs:** `flight_cmd_w.{json,f32}` and `flight_cmd_pattern.f32` are trained or optimised from
scratch using only the inputs above.

**Licence:** they are FlyLab-owned and can be released under any licence the owner chooses.
Attribution to flybody (Apache-2.0) is required only if flybody code is redistributed. Crediting flybody for the model and environment is still good practice.
