Skip to content

⚡ Bolt: Hoist Regexes and Constants in ATS Generator#331

Open
anchapin wants to merge 1 commit into
mainfrom
bolt-hoist-ats-generator-12542494540557262951
Open

⚡ Bolt: Hoist Regexes and Constants in ATS Generator#331
anchapin wants to merge 1 commit into
mainfrom
bolt-hoist-ats-generator-12542494540557262951

Conversation

@anchapin
Copy link
Copy Markdown
Owner

@anchapin anchapin commented May 31, 2026

💡 What: Hoisted frequently used regular expressions to pre-compiled module constants, and converted the dynamically generated action_verbs list to a module-level tuple. Also refactored _check_readability and _get_all_text to execute .lower() only when needed rather than mapping the entire string.
🎯 Why: _check_readability and other scoring functions inside ATSGenerator are on a hot path during parsing. Constantly recompiling regexes, reallocating lists, and executing .lower() on very large strings is costly. Furthermore, lowercasing the string before applying the acronym matching regex (\b[A-Z]{2,4}\b) masked a bug where it would falsely never find any matches.
📊 Impact: Reduces execution time overhead when repeatedly calling generate_report by avoiding unnecessary object creation, compilation time, and large string manipulation inside scoring functions.
🔬 Measurement: Observe generate_report runtime or verify via the test suite passing successfully with the original acronym cases restored.


PR created automatically by Jules for task 12542494540557262951 started by @anchapin

Summary by Sourcery

Optimize ATS generator text analysis by hoisting regexes and constants and avoiding unnecessary lowercasing of aggregated text.

Enhancements:

  • Pre-compile frequently used regex patterns and reuse them across ATS generator checks to reduce overhead and fix acronym detection behavior.
  • Hoist the action verbs collection to a module-level tuple to avoid repeated list allocations in readability scoring.
  • Adjust text aggregation to preserve original casing and apply lowercasing only where needed, improving performance and correctness of mixed-case pattern checks.
  • Update internal engineering notes to document lessons on regex pre-compilation, hoisting constants, and selective lowercasing in hot paths.

Tests:

  • Update ATS generator tests to verify that aggregated text preserves original casing rather than being globally lowercased.

Co-authored-by: anchapin <6326294+anchapin@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 31, 2026

Reviewer's Guide

Hoists frequently used regexes and the action verbs collection in ATS resume parsing to module-level constants and refactors readability helpers to avoid unnecessary lowercasing, improving performance and fixing acronym detection while updating tests and internal documentation accordingly.

File-Level Changes

Change Details Files
Pre-compile and hoist regex patterns used in ATSGenerator scoring paths to module-level constants for reuse and clearer semantics.
  • Introduce module-level compiled regex constants for table detection, special characters, email, phone, quantifiable achievements, and acronyms
  • Replace inline calls to re.search and re.findall with the corresponding pre-compiled pattern.search / pattern.findall calls in formatting, contact info, and readability checks
cli/generators/ats_generator.py
Hoist the action verbs collection and streamline lowercasing behavior in text aggregation and readability scoring for performance and correctness.
  • Define a module-level _ACTION_VERBS tuple instead of recreating a list inside _check_readability
  • Adjust _check_readability to compute a single lowercased copy of all_text when needed instead of repeatedly calling .lower()
  • Change _get_all_text to return the original-cased text and let callers perform lowercasing selectively, ensuring acronym regexes still see uppercase content
cli/generators/ats_generator.py
Update tests and internal Bolt documentation to reflect the new casing behavior and performance guidelines.
  • Modify test expectations so _get_all_text preserves original casing in nested resume data
  • Extend .jules/bolt.md with a new learning note about regex pre-compilation, hoisting static collections, and avoiding unnecessary global lowercasing
tests/test_ats_generator.py
.jules/bolt.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="cli/generators/ats_generator.py" line_range="479" />
<code_context>

         extract_value(resume_data)
-        return " ".join(text_parts).lower()
+        return " ".join(text_parts)

     def _extract_job_keywords(self, job_description: str) -> List[str]:
</code_context>
<issue_to_address>
**issue (bug_risk):** Changing _get_all_text to return non-lowercased text may impact other callers that relied on lowercase

This now returns original casing instead of lowercase. While `_check_readability` was updated to lowercase locally, other callers may still rely on a lowercased result (e.g., for case-insensitive matching). Please review other call sites and add explicit `.lower()` where needed to avoid subtle behavior changes.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


extract_value(resume_data)
return " ".join(text_parts).lower()
return " ".join(text_parts)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Changing _get_all_text to return non-lowercased text may impact other callers that relied on lowercase

This now returns original casing instead of lowercase. While _check_readability was updated to lowercase locally, other callers may still rely on a lowercased result (e.g., for case-insensitive matching). Please review other call sites and add explicit .lower() where needed to avoid subtle behavior changes.

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.

1 participant