Skip to content

fix(scan): align preview selection with scan execution - #1041

Open
Wsp030914 wants to merge 2 commits into
alibaba:mainfrom
Wsp030914:fix/scan-preview-selection
Open

fix(scan): align preview selection with scan execution#1041
Wsp030914 wants to merge 2 commits into
alibaba:mainfrom
Wsp030914:fix/scan-preview-selection

Conversation

@Wsp030914

@Wsp030914 Wsp030914 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Description

ocr scan --preview applied only static file filters, while a real scan also dropped files exceeding 80% of the resolved max_tokens value. This could make preview report a file as reviewable even though execution would skip it.

This change:

  • resolves preview max_tokens using the same precedence as a real scan:
    CLI > saved config > template default;
  • avoids initializing an LLM endpoint, preserving API-key-free preview;
  • makes preview and execution consume the same scan-selection decisions;
  • adds the stable too_large exclusion reason;
  • preserves the real scan's existing skip logs and token-limit boundary.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • Manual testing

Additional verification:

  • make check
  • make coverage — 91.0%
  • make build
  • ocr review --audience agent — 0 findings across 5 selected production files
  • integration coverage proving saved max_tokens affects scan preview
  • token-limit boundary and no-limit unit tests

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally
  • Documentation is unchanged because the existing CLI reference already states that scan preview reports per-file exclusion reasons
  • I have signed the CLA

Scope

This PR only aligns deterministic scan file selection.

It does not attempt to predict:

  • aggregate --max-tokens-budget exhaustion;
  • resume reuse;
  • LLM failures;
  • other execution-dependent outcomes.

Related Issues

Closes #1040.

Related: #782 and #801 cover the corresponding diff-review preview behavior.

AI/LLM Disclosure

OpenAI Codex (GPT-5) assisted with implementation, test refinement, and drafting this PR description. OpenCodeReview using DeepSeek deepseek-v4-pro performed the final automated review. I manually reviewed and understand the complete final diff and take responsibility for the submitted changes.

Preview skipped the runtime token-limit check, so it could report oversized files as reviewable.\n\nRefs alibaba#1040
@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview: Review complete: 0 finding(s) across 5 selected item(s).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(scan): --preview reports oversized files as reviewable

1 participant