Skip to content

spec: perf: async-find query-refinement fast-path#12192

Open
oz-for-oss[bot] wants to merge 1 commit into
masterfrom
oz-agent/spec-issue-12037
Open

spec: perf: async-find query-refinement fast-path#12192
oz-for-oss[bot] wants to merge 1 commit into
masterfrom
oz-agent/spec-issue-12037

Conversation

@oz-for-oss
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot commented Jun 4, 2026

Summary

  • Adds product and technical specs for the async-find query-refinement fast path.
  • Defines the user-visible behavior for skipping no-match blocks on literal prefix refinements while preserving final match parity.
  • Recommends a safe first implementation scoped to filter_results_for_refinement: fast-path only from completed prior scans, enqueue only previously result-bearing blocks/views, and complete immediately for completed zero-match prior queries.
  • Documents validation coverage, risks, and row-level candidate scanning as a follow-up unless profiling shows it is necessary.

Validation

  • Spec-only change; reviewed generated markdown for consistency and workflow requirements.

Related issue: #12037

Co-Authored-By: Varoon Kodithala <116049637+vkodithala@users.noreply.github.com>
@oz-for-oss
Copy link
Copy Markdown
Contributor Author

oz-for-oss Bot commented Jun 4, 2026

@oz-for-oss[bot]

I'm starting a first review of this spec-only pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor Author

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR adds product and technical specs for an async-find query-refinement fast path that reuses completed broader-query results to scan only candidate blocks/views. The specs cover the main behavior, validation plan, risks, and non-goals, and the security pass found no additional design-level security concerns for this local terminal-find optimization.

Concerns

  • The technical refinement predicate omits selected-block scope equality even though the product spec says selected-block scope changes are not refinements; scope changes plus a query extension could reuse the wrong candidate set and miss matches.
  • The technical spec does not account for the current start_find cancellation ordering before checking prior status; the proposed status == Complete gate needs a pre-cancel snapshot or moved cancellation, or the fast path can be skipped every time.
  • Focus preservation should define surviving occurrence identity by block/grid and position rather than exact old span equality, since a strict refinement changes the match span.

Verdict

Found: 0 critical, 2 important, 1 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread specs/GH12037/tech.md
## Proposed changes

### 1. Replace the full refinement restart with a candidate-block restart
Keep the existing refinement predicate in `start_find`: regex disabled, same case-sensitivity, and `new_query` is a strict string prefix extension of the old query. Inside `filter_results_for_refinement`, build the new `AsyncFindConfig` first and return through `clear_results` for empty/whitespace queries exactly as today.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] The refinement predicate also needs to require unchanged blocks_to_include or force a normal search on scope changes; otherwise a selected-block scope change plus a strict query extension can intersect against the old candidate set and miss matches, contradicting the product spec's non-refinement behavior.

Comment thread specs/GH12037/tech.md
### 1. Replace the full refinement restart with a candidate-block restart
Keep the existing refinement predicate in `start_find`: regex disabled, same case-sensitivity, and `new_query` is a strict string prefix extension of the old query. Inside `filter_results_for_refinement`, build the new `AsyncFindConfig` first and return through `clear_results` for empty/whitespace queries exactly as today.

Only take the candidate fast path when the previous broader run has reached `AsyncFindStatus::Complete`. If the broader run is still `Scanning` or has been cancelled back to `Idle`, fall back to the current full refined async search path so the refined query cannot miss blocks that the broader query had not scanned yet.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] This needs to account for the current start_find calling cancel_current_find() before filter_results_for_refinement; require moving cancellation after the pre-cancel status/candidate snapshot or passing the prior status in, or the status == Complete gate will see Idle and the fast path will never run.

Comment thread specs/GH12037/tech.md

1. Snapshot the old focused match identity before clearing results.
2. After each result batch, existing auto-focus/clamp behavior remains valid.
3. After scan completion, if the old focused span survived, set `focused_match_index` to its new index and update the cache.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 [SUGGESTION] Define focus preservation by stable occurrence identity such as block/grid plus start position or containment, not exact old span survival; refining foo to foobar changes the end position even when the same visible occurrence remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant