cursor / composer-2.5 / Composer 2.5 default / unknown effort preferred over deepseek / deepseek-flash / none / unknown effort · clear win.
Primary judge: Sol 6.1, requested Low. Effective provider effort and internal attempts were not verified. A close win is still a scored preference; it does not establish a material defect.
Reviewed public evidence
Task goal
Audit [REDACTED: private project name]'s lazy-video saved-position restore and editor-return seek lifecycle. Trace cold resume, target outside new native duration, metadata/seek stalls, unmount/inspection switch, and editor cancellation; identify only reproducible correctness defects, specify the smallest safe implementation and 0-3 targeted regression tests, preserving server watched-proof/certification boundaries.
cursor / composer-2.5 / Composer 2.5 default / unknown effort answer
## Evidence packet: lazy-video resume & editor-return seek audit
### 1. Conclusions (source-grounded)
**Cold resume lifecycle** — `begin()` sets `pendingRef`, stores `requestRef` `{ inspectionId, targetS, startedAt }`, pauses, `prepareVideo()`, `seek(targetS)`, and shows “Returning…”. The 100ms interval (lines 44–68, `useReviewResumePlayback.ts`) only completes when: same `inspectionId`, not `shouldCancel()`, metadata valid (`readyState >= 1`, finite `duration > 0`), video paused, not `seeking`, `|video.currentTime - targetS| ≤ 0.1`, then `|currentTime (React) - targetS| ≤ 0.1` and `canResume()`. Then it clears pending, clears request, clears message, calls `onReady()`. Test lines 23–47 confirm native seek + React `currentTime` are both required; `onReady` waits until `<Harness time={1026.793} />`.
**Metadata / seek stalls** — Missing metadata loops at line 55 until valid or 15s. After 15s (lines 50–53): `pause()`, error message, **does not** clear `pendingRef` or `requestRef`. Test lines 48–54 expect `pendingRef === true`, `onReady` never called. Same inspection: interval only hits timeout branch (no further seeks). **By design in tests**, not a defect vs. supplied tests.
**Inspection switch / unmount** — `useEffect` deps `[inspectionId]` (lines 41–70): on change, clears `pendingRef` and `requestRef` before new interval; cleanup does the same. Render-time `notice.inspectionId !== options.inspectionId` → `setNotice(null)` (lines 21–23). Tests 48–57, 74–85: switch to inspection 2 clears pending/message/`getTarget()`; A→B→A does not revive notice or `onReady`.
**Editor cancellation** — Interval checks `shouldCancel?.()` → `pause()`, `cancel()` (lines 47–48). Test 60–71: `editing` clears pending; later metadata + `time=900` does **not** call `onReady`.
**Editor-return seek** — `useReviewReturnSeek.ts`: reads `seek_s`, `resume_scan`; skips if `parseCoverageRecoveryParams(searchParams) != null` or `resume && !ready` (line 20). One-shot via `consumedRef` key `inspectionId:pendingSeekS:resume` before `setSearchParams` strip (lines 21–31). `resume` → `beginResume(time)`; else `pauseManualReview()` + `seek(time)`. Test 88–110: repeated renders with same params → single navigate/prepare/seek; fresh params after clear → second consume.
**Server watched-proof / certification** — Packet is client hooks + tests only. No API, proof, or certification logic. Safe fixes stay in these hooks (clamp/timeout UX); do not move resume proof to server based on this evidence.
---
### Reproducible correctness defect (high confidence)
**Saved target beyond native `duration` after lazy load**
When metadata is valid but `targetS > video.duration`, browsers typically clamp `video.currentTime` to `duration`, so `|video.currentTime - targetS| > 0.1` stays true (lines 58–60). The hook calls `seek(targetS)` every 100ms while not `seeking`, until the 15s timeout, then shows “Could not restore…” with `pendingRef` still true (same as metadata stall). No branch clamps or compares `targetS` to `duration`.
- **Repro**: `begin(T)` with `T` > eventual `video.duration` after `prepareVideo` / replacement media.
- **Impact**: Seek thrashing until timeout; misleading “could not restore” vs. “bookmark past end of video”; user blocked with `pendingRef === true` until inspection change or external cancel (if any—consumers not in packet).
- **Confidence**: High on loop + timeout; medium on product severity (shorter re-encoded asset is plausible).
**Smallest safe implementation** (client-only, `useReviewResumePlayback.ts` interval, after line 55):
- Compute `boundedTarget = Math.min(request.targetS, Math.max(0, video.duration - ε))` (small ε, e.g. 0.05).
- Use `boundedTarget` for `seek` and both time comparisons (lines 58–63).
- Optionally: if `request.targetS > video.duration + 0.1`, set a one-shot notice (“Saved position was past the end of this video; resumed at end.”) without touching server proof.
Preserves: dual gate (native + React `currentTime`), `shouldCancel`, inspection discard, 15s metadata timeout semantics, return-seek consumption unchanged.
---
### Alternatives / discarded / false positives
| Hypothesis | Verdict |
|------------|---------|
| Timeout should clear `pendingRef` | **Discarded** — test lines 52–53 require `pendingRef === true` after timeout. |
| `useReviewReturnSeek` double-consume on stale route | **Discarded** — `consumedRef` + test 88–110. |
| Render-phase `setNotice` on inspection change is a resume bug | **Low** — matches “discard notice” comment; tests 74–80. |
| Non-`resume_scan` return doesn’t call `prepareVideo` | **Uncertain** — line 35 only `pause` + `seek`; lazy-load gap possible, not covered by tests. |
| Invalid `seek_s` after consume | **Minor** — lines 32–33: URL stripped, `consumedRef` set, no `beginResume`; silent no-op (no test). |
---
### 2. Targeted regression tests (0–3)
1. **Duration shorter than bookmark** — `begin(1500)`; set `duration=900`, `readyState≥2`, `currentTime=900`, `seeking=false`; drive React `currentTime` to 900; expect `seek` last called with clamped end (e.g. ≤900), `onReady` once, `pendingRef` false (no 15s error).
2. **Editor cancel invariant (optional)** — Already covered by test 60–71; only extend if clamp logic could call `onReady` after cancel.
3. **Invalid `seek_s` (optional)** — If product wants visibility: `seek_s=abc` → params cleared, `beginResume`/`seek` not called; document expected UX.
---
### 3. Missing evidence / consequences
- **`coverageRecovery.js` / `parseCoverageRecoveryParams`** — Return seek deferred when non-null (line 20). Cannot audit interaction with coverage recovery or duplicate seek.
- **Callers of `pendingRef`, `canResume`, `prepareVideo`, certification** — Cannot confirm global playback/certification gating or watched-proof boundaries beyond “don’t change server.”
- **Real browser seek clamping** — Clamp values (ε, behavior at exact `duration`) may need one manual/browser check.
---
### 4. Next useful action
Implement **duration-bounded target** in the resume interval (single site, ~5–10 lines), add **test (1)** above, run existing `useReviewResumePlayback.test.tsx` suite. If coverage recovery is in scope, admit `coverageRecovery.js` and trace `resume_scan` + recovery params together.
**Uncertainty summary**: One high-confidence client defect (bookmark past native duration). Timeout/`pendingRef` behavior is test-specified, not a defect relative to the packet. Return-seek one-shot consumption appears correct per tests.deepseek / deepseek-flash / none / unknown effort answer
I'll analyze the supplied evidence directly (no team tools needed — this is a read-only independent assessment lane).
## Conclusion
The lazy-video resume/return-seek lifecycle has **three reproducible correctness defects** in the supplied hooks. All three are visible purely from the snapshot; there is also one dependency-level uncertainty (the omitted `coverageRecovery.js`) that is relevant to the return-seek path.
---
### Defect 1 — Timeout path leaves a live request, so it can fire after "Could not restore"
`useReviewResumePlayback.ts:50-54`:
```ts
if (Date.now() - request.startedAt > 15000) {
current.pause()
setMessage('Could not restore the review position. Select Resume to try again.')
return
}
```
The timeout branch does **not** clear `pendingRef.current` or `requestRef.current`. Compare the success branch (`:64-65`), which clears both, and `cancel()` (`:27-31`), which clears both.
Implications:
- `pendingRef.current` stays `true` at timeout. The test at `useReviewResumePlayback.test.tsx:48-53` **asserts this as correct** (`expect(result.pendingRef.current).toBe(true)` after 15.1s) — so the test codifies the behavior rather than catching it. That means the "bug" is at least intentional-looking in the test, but the *downstream* consequence is still a defect.
- Because `requestRef.current` is still set, the 100 ms interval keeps running. Once metadata arrives (after the notice is shown), the loop proceeds to `:55-67` and can call `current.onReady()` — i.e. the video can resume **after** the user was told restoration failed, with no `begin()` retry. The only guards are the target/duration comparison and `currentTime` convergence; a late-arriving metadata event satisfies both.
- Cold-resume trace: `begin()` → seek issued → no metadata → 15 s timeout → notice shown → metadata finally loads → seek converges → `onReady()` fires → scanner/playback takes ownership although the notice still says "Could not restore."
Smallest safe fix: in the timeout branch, clear both refs before/after setting the message:
```ts
if (Date.now() - request.startedAt > 15000) {
pendingRef.current = false
requestRef.current = null
current.pause()
setMessage('Could not restore the review position. Select Resume to try again.')
return
}
```
This also means the existing assertion at test line 53 should be inverted. Confidence: **high** (control flow is fully contained in the snapshot).
---
### Defect 2 — Inspection-change reset wipes state but does not pause the video
`useReviewResumePlayback.ts:41-43` (effect body, re-run on `options.inspectionId` change per `:70`):
```ts
pendingRef.current = false
requestRef.current = null
```
and the render-phase notice reset at `:21-23`:
```ts
if (notice.inspectionId !== options.inspectionId) {
setNotice({ inspectionId: options.inspectionId, text: null })
}
```
Neither calls `current.pause()`. The `shouldCancel` branch (`:48`) **does** call `current.pause()` before cancelling, showing pause is the intended teardown action.
Implications:
- When the user switches inspection (A→B) mid-resume, the pending request is discarded and the notice cleared, but if the video element was (or becomes) playing — e.g. the earlier `begin()` issued `prepareVideo()`/`seek()` and the native `seek` completed just as the switch happened — the newly selected inspection inherits a potentially unpaused, mid-seek video. The test at `:48-58` covers the metadata-missing switch and only checks `pendingRef`/`message`, not `paused`, so this is unverified.
- The A→B→A trace (`:74-86`) is also only checked for `message`/`pendingRef`/`getTarget`; no pause assertion.
Smallest safe fix: on the inspection-change effect, call `latest.current.pause()` (or `cancel()`, which now also clears the refs and message) when the previous request was live. Using `cancel()` reuses the existing teardown and avoids divergence. Confidence: **medium-high** — the code shape is clear, but whether an unpaused video is reachable depends on `prepareVideo()`/`seek()` semantics outside the packet (see uncertainty below).
---
### Defect 3 — `useReviewReturnSeek` marks consumed before validating the time, permanently losing a malformed-seek retry
`useReviewReturnSeek.ts:25-35`:
```ts
consumedRef.current = key
setSearchParams(...) // strips seek_s / resume_scan
const time = Number(pendingSeekS)
if (!Number.isFinite(time) || time < 0) return
if (resume) beginResume(time)
else { pauseManualReview(); seek(time) }
```
The effect marks the param consumed and strips it from the URL **before** validating `time`. If `seek_s` is non-numeric or negative, the params are removed and no seek happens. The consumed key is now fixed, and the URL no longer carries the seek, so the intent is silently and irrecoverably dropped. Note `pendingSeekS === ''` is handled at `:19`, but `seek_s=abc` or `seek_s=-5` is not.
Also, because `pendingSeekS`/`resume` are read during render (`:16-17`) and included in the dep array (`:36`), after `setSearchParams` strips them the effect re-runs with `pendingSeekS == null` and resets `consumedRef.current = null` (`:19`). That is *intended* for the "later genuine edit returns to the same bookmark" case (test `:105-109`), but it also means the consumed guard is only as durable as the URL and cannot be used to force a retry.
Smallest safe fix: validate before mutating:
```ts
const time = Number(pendingSeekS)
if (!Number.isFinite(time) || time < 0) {
consumedRef.current = null
return
}
consumedRef.current = key
setSearchParams(...)
...
```
Confidence: **high** for the malformed-input loss; **medium** that a producer ever emits malformed `seek_s` (no evidence in the packet about the writer).
---
### What is correct (discarded hypotheses)
- **Guided-return one-shot consumption** (`:22` guard + mark-before-navigate, `:23-31`) correctly survives the deferred route commit and repeated renders with stale params. Test `:88-110` verifies exactly this, including the legitimate second return. No defect.
- **"React cursor must catch up" gate** (`:63`) is a deliberate, correct guard: native `seek` completion alone does not settle the scanner. Test `:36-45` exercises it.
- **Competing initial-zone writPrimary judge's stated reason
B is the more reliable actionable audit: it avoids A's impossible post-timeout execution trace and supplies a focused remedy and test for a specifically requested lifecycle case. This is a supported material correctness advantage, not merely a forced stylistic preference; B's exact end-of-video policy still needs validation.
This reason is the judge's assessment. No independent factual-defect finding is asserted by this record.
Battle wave: e8b943ba-5475-4c9f-82d2-c82f9157debd. Pair: brp1_e35b3edf52e5404c133d733dbf6738fd750d3517b1cd49fcdcd3f5013f1433f5. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.