# Product Implementation Completeness Gate — Cycle 2

**Date**: 2026-05-20
**Scope**: 6 product tasks completed in cycle 2 — AZ-697, AZ-702, AZ-698, AZ-699, AZ-700, AZ-701 (epic AZ-696 "operator-side replay tooling")
**Gate verdict**: **PASS** — all 6 tasks classified PASS, 0 BLOCKED, 0 FAIL
**Final test run handoff**: Step 11 (Run Tests) on the Jetson harness — see Notes

## Per-task Classification

| Task | Component | Status | Production code | Named runtime deps integrated | AC coverage |
|------|-----------|--------|-----------------|-------------------------------|-------------|
| AZ-697 | replay_input + helpers | **PASS** | `replay_input/tlog_ground_truth.py`, `helpers/gps_compare.py` (`GroundTruthRow`, `l2_horizontal_m`, `match_percentage`) | `pymavlink.mavutil` (binary tlog reader) | 5/5 ACs |
| AZ-702 | _docs/input_data | **PASS** | `_docs/00_problem/input_data/flight_derkachi/khp20s30_factory.json` + `tests/e2e/replay/conftest.py::_calibration_path()` | n/a (static factory-sheet JSON) | 4/4 ACs |
| AZ-698 | replay_input + cli + runtime_root | **PASS** | `replay_input/auto_sync.py` + `replay_input/interface.AlignedWindow` + `--auto-trim` flag in `cli/replay.py` + `c8_fc_adapter/tlog_replay_adapter.py` (`tlog_start_ns` skip) + composition-root plumbing | OpenCV optical-flow, numpy NCC | 7/7 ACs (incl. AC-9 frame-window-match validator) |
| AZ-699 | helpers + tests/e2e/replay | **PASS** | `helpers/gps_compare.HorizontalErrorDistribution` + `helpers/accuracy_report.py` (promoted in AZ-701) + `tests/e2e/replay/test_derkachi_real_tlog.py` | real `gps-denied-replay --auto-trim` subprocess (AZ-402 + AZ-698) | All ACs; PASS/FAIL test gated on Jetson e2e |
| AZ-700 | cli + helpers | **PASS** | `cli/render_map.py` (`gps-denied-render-map` console-script) | folium / Leaflet (gated under `[operator-tools]` extra; airborne cold-start untouched) | 14/14 unit tests |
| AZ-701 | replay_api + cli + helpers | **PASS** | `replay_api/{__init__,errors,interface,storage,jobs,handlers,app}.py` + `cli/replay_api_entrypoint.py` + `helpers/accuracy_report.py` + Docker image | FastAPI/uvicorn/python-multipart (operator-only); real subprocess to `gps-denied-replay` + `gps-denied-render-map` | 7 ACs (AC-1, AC-2, AC-3, AC-5, AC-6, AC-8, AC-9) all covered by 18 unit tests |

## Evidence Checked

### Unresolved-placeholder scan (markers: `TODO`, `FIXME`, `XXX`, `HACK`, `NotImplemented`, `placeholder`, `scaffold`, `stub`, `deterministic fallback`, `fake runner`, `native bridge`)

- `src/gps_denied_onboard/replay_api/*` — 1 hit in `__init__.py:14` ("a fake runner") inside a module docstring describing the unit-test DI pattern. Not a code stub. ✅
- `src/gps_denied_onboard/replay_input/*` — 0 hits. ✅
- `src/gps_denied_onboard/helpers/gps_compare.py` — 0 hits. ✅
- `src/gps_denied_onboard/helpers/accuracy_report.py` — 2 hits at lines 56 / 90, both docstrings describing the `calibration_method` STRING FIELD which can take value `"factory-sheet"` (AZ-702 path) or `"placeholder"` (legacy adti26 fallback label). Not unimplemented code. ✅
- `src/gps_denied_onboard/cli/render_map.py` — 0 hits. ✅
- `src/gps_denied_onboard/cli/replay_api_entrypoint.py` — 0 hits. ✅

No unresolved placeholder / stub / scaffold / native-bridge markers in any cycle-2 production module.

### Named-runtime-dependency integration

| Task | Promised dependency | Where integrated | Adapter or real call? |
|------|---------------------|------------------|-----------------------|
| AZ-697 | `pymavlink.mavutil` binary tlog reader | `replay_input/tlog_ground_truth.py::_load_with_mavutil` (lazy import → `mavutil.mavlink_connection`) | Real call; missing `pymavlink` raises `ReplayInputAdapterError` |
| AZ-698 | OpenCV optical flow, numpy NCC | `replay_input/auto_sync.py::_compute_video_onset_from_samples` (cv2 pyramidal Lucas-Kanade) + `_frame_window_match` | Real calls; lazy import gated on env |
| AZ-699 | end-to-end `gps-denied-replay --auto-trim` invocation | `tests/e2e/replay/test_derkachi_real_tlog.py::test_az699_real_derkachi_flight_passes_ac3` shells out via `subprocess.run([…, "--auto-trim"])` | Real subprocess against the production console script |
| AZ-700 | `folium` HTML map rendering | `cli/render_map.py::render_map_html` constructs `folium.Map` + adds `folium.PolyLine`, `folium.Marker`, `folium.Circle` layers | Real folium calls |
| AZ-701 | FastAPI/uvicorn HTTP, real pipeline subprocess | `replay_api/app.py::SubprocessReplayRunner.run` calls `subprocess.run([self._replay_binary, …, "--auto-trim"], …)` with argv list (no `shell=True`); then `_maybe_render_map` invokes `gps-denied-render-map` likewise | Real subprocess; tests inject a fake `ReplayRunner` via the Protocol DI seam |
| AZ-702 | Topotek KHP20S30 factory-sheet intrinsics | JSON committed to `_docs/00_problem/input_data/flight_derkachi/khp20s30_factory.json`; `_calibration_path()` in `conftest.py` prefers it when present | Real data; assumptions documented in `camera_info.md` |

Every named dependency is integrated as production behaviour. No deterministic fallbacks substituted for promised runtime calls, no empty `native/` packages, no Protocol-only surfaces shipped without implementation.

### End-to-end production pipeline (Step 7 of gate)

The cycle-2 architecture promise — *"operator uploads (tlog + video [+ calibration]); receives back GPS-fix JSONL + accuracy report + HTML map"* — has an executable production path wired through:

1. `POST /replay` → `replay_api.app` route handler
2. `replay_api.handlers.validate_*` magic-byte checks + bearer-token extraction
3. `replay_api.storage.StorageRoot.allocate_job` per-job temp dir
4. `replay_api.jobs.JobRegistry.submit` queues to `ThreadPoolExecutor`
5. `replay_api.app.SubprocessReplayRunner.run` shells out to **`gps-denied-replay --auto-trim`** (AZ-402 + AZ-698)
6. `emissions.jsonl` written to the per-job dir
7. `SubprocessReplayRunner._maybe_render_report` loads ground truth via `replay_input.load_tlog_ground_truth` (AZ-697), computes `helpers.gps_compare.horizontal_error_distribution` (AZ-697/699), and renders `helpers.accuracy_report.render_report` (AZ-699/701)
8. `SubprocessReplayRunner._maybe_render_map` invokes **`gps-denied-render-map`** (AZ-700)
9. Job state transitions to `DONE`; static endpoints serve the three artefacts under stable URLs (`/jobs/{id}/result`, `/jobs/{id}/report`, `/jobs/{id}/map`)

Each step is real code calling real dependencies, not a stub or harness-only orchestration.

### Internal vs external prerequisites (Step 5 of gate)

All cycle-2 work is operator-side (no airborne path touched). The only external prerequisite for any task is the **real Derkachi flight artefacts** (`derkachi.tlog`, `flight_derkachi.mp4`, `khp20s30_factory.json`) — and that prerequisite is satisfied within the repo (`_docs/00_problem/input_data/flight_derkachi/`). AZ-699's e2e test gates with explicit `RUN_REPLAY_E2E=1` env + minimum video size + console-script presence (skip-with-reason, not `@xfail` / silent-skip), which matches the gate rule: "Environment-gated tests may skip only with an explicit prerequisite reason; they do not make missing production code complete."

No BLOCKED classifications — every task has its production code complete.

## Cross-Cutting Findings (none block this gate)

- **F1 from cumulative review** (`module-layout.md` is stale for the 6 new artefacts): an Architecture documentation gap, not a production-code gap. Production code respects the layering; the doc has not caught up. Owned by Step 13 (Update Docs).
- **F2 from cumulative review** (inline imports in `replay_api/app.py:_maybe_render_report`): style nit, Low severity.

Neither finding is a Completeness Gate FAIL trigger.

## Verdict

**PASS** — all 6 cycle-2 product tasks are classified PASS. The implement skill may write the final implementation report and hand off to Step 11 (Run Tests) for the e2e Jetson reality-gate execution.

## Notes

- **Reality-gate signal still owed**: this gate verifies production code shape, not end-to-end runtime behaviour. The first actual end-to-end exercise of cycle-2 production code (real Derkachi tlog + real video + factory calibration through `replay_api` → `gps-denied-replay` → `gps-denied-render-map` → accuracy report) is owned by Step 11 on the Jetson harness. The completeness gate does not pre-emptively grant Step 11 a PASS.
- **No remediation tasks created**: the gate's only outputs are the F1 doc-drift and F2 style nit, both handled within existing cycle-2 steps (Step 13 Update Docs + retrospective). No `remediate_*.md` files added to `_docs/02_tasks/todo/`.
