# Iteration 7 — Phase 6 (implementation)

Single fork commit landed 2026-05-13. Build + install + Phase 7 verify pending fresnel uptime (offline at commit-push time).

## Commit

| SHA | Files | LOC | Summary |
|---|---|---|---|
| `c106d95` | `src/request.c` | +165 / -57 | Refactor `find_video_node_via_topology` → `find_decoder_video_node_via_topology` (entity-function discrimination + link-graph walk). Two-pass `find_codec_device` for rkvdec preference. |

Fork tip post-iter7-Phase-6: `c106d95` (was `70196f8` at iter5b-β/iter6 close).

## Phase 5 amendments incorporated

| ID | Amendment | Where landed |
|---|---|---|
| CRIT-1 | MEDIA_LNK_FL_INTERFACE_LINK link discrimination | `find_decoder_video_node_via_topology` data-link vs interface-link checks |
| CRIT-2 | Check both source_id AND sink_id of each link | Both inner loops check both endpoints |
| IMP-1 | Decoder-proc / encoder-proc distinction (algorithm safe by construction) | Confirmed correct; no additional code |
| IMP-2 | MEDIA_ENT_F_PROC_VIDEO_DECODER set by rkvdec.c + hantro_drv.c | Confirmed at code level on boltzmann |
| IMP-3 | 2-call MEDIA_IOC_G_TOPOLOGY pattern | Replaces 3-call pattern in old `find_video_node_via_topology` |
| IMP-4 | Two-pass fd open/close | `for (pass = 0; pass < 2; pass++)` outer loop |
| MIN-1 | `media_out` from `path` preserved | Unchanged |
| MIN-2 | Single-bit flag test for interface links | `flags & MEDIA_LNK_FL_INTERFACE_LINK` |
| MIN-3 | Phase 7 MPEG-2/VP8 env-override mandatory | Phase 7 doc will enforce |

All amendments mechanical; no structural plan changes.

## Status

- Fork commit `c106d95` on noether + gitea. Pushed via `claude-noether` SSH per `feedback_gitea_as_claude_noether.md`.
- Fresnel offline at commit time. Cannot syntax-check on noether (no va-api dev headers locally). Build error risk exists but is small — diff is mechanically derived from working code.
- Backend installed SHA on fresnel: unchanged from iter5b-β/iter6 close (`2c6ff82c…`). Will update post-build.

## Phase 7 plan (pending fresnel uptime)

When fresnel returns:

1. Pull on fresnel: `cd ~/src/libva-v4l2-request-fourier && git pull --ff-only origin master`.
2. Build: `ninja -C build`. If syntax fails, report errors; fix via amend or new commit.
3. Install: `sudo install -m 644 build/src/v4l2_request_drv_video.so /usr/lib/dri/v4l2_request_drv_video.so`.
4. Capture new SHA256.
5. Phase 7 verification matrix:
   - **C5 item 1**: `vainfo` (no env override) lists H.264/HEVC/VP9 profiles (rkvdec).
   - **C5 item 2**: ffmpeg-vaapi HEVC fixture engages decoder (strace shows /dev/video<rkvdec> opened).
   - **C5 item 3** (mandatory per Phase 5 MIN-3): MPEG-2/VP8 with explicit env override still decode correctly.
   - **C5 item 4**: VP9 still PASS direct, MPEG-2 still PASS, no regression on Bugs 4/5/6 partial states.
   - **C5 item 5**: reboot fresnel; re-run vainfo + ffmpeg. Verify auto-detect repeats.
6. If 5 of 5 PASS: write Phase 7 verification doc; proceed to Phase 8 close.
7. If any fail: Phase 7 → Phase 4 loopback.

## Risk register update

| Risk | Status |
|---|---|
| Syntax/compile error from Edit-based refactor | UNTESTED — fresnel offline |
| Algorithm bug in link traversal | Mechanically verified against Phase 5 reviewer pseudocode |
| `MEDIA_ENT_F_PROC_VIDEO_DECODER` not set in kernel | Verified at code level (rkvdec.c:1382, hantro_drv.c) |
| Two-pass changes behavior on rkvdec-only systems | Same as single-pass (pass 1 picks rkvdec, pass 2 never fires) |
| Two-pass on hantro-only systems | Pass 1 finds nothing; pass 2 picks hantro-decoder (works) |
| Encoder mis-detection | Eliminated by construction (entity-function check excludes encoder-only paths) |

## Substrate state at Phase 6 close

- Fork tip `c106d95` (iter7 Phase 6 commit).
- Backend installed: still iter5b-β/iter6 SHA `2c6ff82c…`. To be updated when fresnel returns.
- Kernel `linux-fresnel-fourier 7.0-1`.
- Test fixtures unchanged.
- Phase 7 ready to execute once fresnel + build cycle complete.
