# Slow Query Detail Forward Retry

## Summary

- Save this plan under `docs/plans/2026-07-09-slowquery-detail-forward-retry.md`.
- Only change the file-backed `slowQuery.Detail` lookup path.
- Keep the exact detail match unchanged: timestamp, connection ID, and digest must still match.
- Keep the initial lookup at `timestamp +/- 4 minutes`.
- If the initial lookup cannot find the slow log, move the search center forward by 4 minutes per retry, up to 8 forward retries.
- Use key de-duplication so overlapping windows do not reread the same object.

## Implementation

- Add configurable constants in `pkg/ngm/slowquery/slowquery.go`:
  - `detailLookupForwardRetryStep = objectsTimeRangeGap`
  - `detailLookupMaxForwardRetries = 8`
- Add `detailLookupSearchTimes(timestamp float64) []int`.
- Refactor `slowQuery.Detail` to:
  - Iterate search center times from `timestamp` through `timestamp + 8*4min`.
  - Use `findKeysWithinRange` for each center time.
  - Scan only keys not seen in earlier attempts.
  - Retry only when the scan result is `log for detail not found`.
  - Return storage or reader errors immediately.
- Keep intermediate retry logs lightweight and keep the heavy not-found diagnostic log for the final exhausted attempt.

## Tests

- Cover success when the target object key is outside the initial window but inside a later forward retry window.
- Cover not found when the target object key is beyond the retry limit.
- Cover key de-duplication across overlapping retry windows.
- Cover immediate return for non-not-found scan errors.

## Assumptions

- "Add 8 times at most" means the initial lookup plus 8 forward retries, for 9 total search centers.
- The retry changes only object-key discovery; it does not relax the slow-log detail match.
