Skip to content

Fix PriorityEngine categorization sorting, access to calculate_urgency, and delete scratchpad files#805

Open
RohanExploit wants to merge 4 commits into
mainfrom
fix-priority-engine-sorting-10392451821970527148
Open

Fix PriorityEngine categorization sorting, access to calculate_urgency, and delete scratchpad files#805
RohanExploit wants to merge 4 commits into
mainfrom
fix-priority-engine-sorting-10392451821970527148

Conversation

@RohanExploit
Copy link
Copy Markdown
Owner

@RohanExploit RohanExploit commented May 26, 2026

This commit addresses logical issues in the AI priority engine. It removes a flawed micro-optimization that prematurely capped category keyword matching, which previously broke the sorting logic. It also exposes calculate_urgency publicly to fix integration issues. Finally, several scratchpad and debugging scripts were removed to adhere to the repository's clean-up policies.


PR created automatically by Jules for task 10392451821970527148 started by @RohanExploit


Summary by cubic

Fixes broken category sorting in the priority engine and restores public access to urgency calculation. Cleans up scratch/debug files and updates CI to use supported actions.

  • Bug Fixes

    • Removed early-exit cap in _detect_categories so sorting uses full keyword counts.
    • Exposed calculate_urgency (renamed from _calculate_urgency) and updated internal calls.
  • Dependencies

    • Pinned actions/github-script to v7 (reverted from v7.0.1) to avoid download failures.
    • Replaced codelytv/pr-size-labeler@v1 with pascalgn/size-label-action@v0.5.0 and configured IGNORED lockfiles.

Written for commit ebcfdc5. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • Refactor

    • Adjusted urgency/priority calculation flow and exposed the helper for reuse.
    • Category detection now accumulates keyword matches without an early cap, affecting category ranking behavior.
  • Chores

    • Removed several internal development, debugging, and benchmark scripts.
    • Pinned CI workflow action versions for more stable automation.

Review Change Stack

- Removed flawed early-exit logic (`if count >= 5: break`) in `_detect_categories` that broke category sorting when multiple categories had many keyword matches.
- Renamed `_calculate_urgency` to `calculate_urgency` to make it accessible to external dependencies, fixing test failures.
- Deleted leftover scratchpad and debug files to clean up the repository.
Copilot AI review requested due to automatic review settings May 26, 2026 10:54
@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.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 26, 2026

Deploy Preview for fixmybharat canceled.

Name Link
🔨 Latest commit ebcfdc5
🔍 Latest deploy log https://app.netlify.com/projects/fixmybharat/deploys/6a159662b1052e0008025a61

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

This PR renames the urgency helper from _calculate_urgency to public calculate_urgency and updates analyze() to call it; it also removes an early-exit cap in category keyword counting. Separately, several GitHub Actions steps are pinned and the PR size-label action is replaced.

Changes

Priority Engine Refactoring

Layer / File(s) Summary
Urgency method public API
backend/priority_engine.py
Method _calculate_urgency renamed to calculate_urgency; analyze() now calls self.calculate_urgency(...) with the same parameters.
Uncapped keyword matching in category detection
backend/priority_engine.py
Removed the early-exit cap in the per-category keyword matching loop within _detect_categories, allowing counts to accumulate fully before ranking.

Workflow and CI updates

Layer / File(s) Summary
Assign PR author workflow pin
.github/workflows/assign-pr-author-on-merge.yml
Pin actions/github-script to v7.0.1 in the assign-pr-author step.
Auto-close & greetings workflow pins
.github/workflows/auto-close-mentioned-issues.yml, .github/workflows/greetings.yml
Pin actions/github-script to v7.0.1 in auto-close and greeting steps.
PR/issue bot: size-label and script pins
.github/workflows/pr-issue-bot.yml
Replace codelytv/pr-size-labeler with pascalgn/size-label-action@v0.5.0; pin actions/github-script usages to v7.0.1 in related jobs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

size/m

Poem

🐰 A quiet helper hops into view,
No longer hidden, its logic stays true.
Keywords now tally without hitting the brakes,
Workflows pinned neatly for safer updates.
Hooray — the rabbit says, "Careful, small stakes!"

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description lacks critical sections from the repository template including unchecked Type of Change checkbox, missing Related Issue link, unchecked Testing Done checkboxes, and incomplete Checklist items. Complete the description template by selecting appropriate Type of Change options, linking the issue with 'Closes #', checking Testing Done items, and verifying the Checklist requirements were met.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects all main changes: fixing PriorityEngine categorization sorting, making calculate_urgency public, and removing scratchpad files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-priority-engine-sorting-10392451821970527148

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-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.

No issues found across 8 files

Re-trigger cubic

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

- The previous CI run failed due to a rate limit issue with the Copilot PR Reviewer ("You've hit the rate limit for this model.").
- Triggering a new run by pushing an empty commit or just resubmitting.
- Updated `actions/github-script` to `v7.0.1` to ensure compatibility and resolve action download failures.
- Replaced the deprecated `codelytv/pr-size-labeler@v1` with `pascalgn/size-label-action@v0.5.0` and correctly configured it using environment variables.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/assign-pr-author-on-merge.yml:
- Line 17: Replace the mutable tag usage actions/github-script@v7.0.1 with the
corresponding immutable commit SHA for actions/github-script (i.e., change the
uses entry in the workflow from actions/github-script@v7.0.1 to
actions/github-script@<commit-sha>) so the job definition uses a pinned SHA;
locate the uses line referencing actions/github-script and update it to the
exact commit SHA from the repository to eliminate tag mutability risk.

In @.github/workflows/auto-close-mentioned-issues.yml:
- Line 18: Replace the unpinned action reference "actions/github-script@v7.0.1"
with an immutable commit SHA or digest (e.g.,
"actions/github-script@<commit-sha>" or "@<digest>") so the workflow cannot
change unexpectedly; update the same pattern in the other workflows mentioned
(pr-issue-bot.yml, assign-pr-author-on-merge.yml, greetings.yml) by locating
their "uses: actions/github-script@v7.0.1" lines and swapping the tag for the
corresponding pinned commit SHA/digest from the actions/github-script repository
release you intend to lock to.

In @.github/workflows/greetings.yml:
- Line 18: The workflow is using the mutable tag "uses:
actions/github-script@v7.0.1"; replace that tag with the corresponding immutable
40-character commit SHA for actions/github-script (update the "uses:
actions/github-script@v7.0.1" entry to "uses:
actions/github-script@<commit-sha>") and apply the same SHA pin to any other
workflows using the same tag to prevent future changes; ensure the chosen SHA
corresponds to the v7.0.1 release to preserve behavior.

In @.github/workflows/pr-issue-bot.yml:
- Line 19: Workflow uses mutable tag pins for third-party actions
(pascalgn/size-label-action@v0.5.0 and actions/github-script@v7.0.1); replace
those tag references with immutable commit SHAs. Locate the two usages of
actions/github-script@v7.0.1 and the single usage of
pascalgn/size-label-action@v0.5.0 in the workflow, look up the corresponding
commit SHA on each action's GitHub repo, and replace the `@vX.Y.Z` tag with the
exact commit SHA (e.g., @<full-commit-sha>) so the workflow is pinned to a
specific commit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1e8a028e-1edd-4bf8-b4ab-eb584a9720d9

📥 Commits

Reviewing files that changed from the base of the PR and between 0087d72 and e099e0e.

📒 Files selected for processing (4)
  • .github/workflows/assign-pr-author-on-merge.yml
  • .github/workflows/auto-close-mentioned-issues.yml
  • .github/workflows/greetings.yml
  • .github/workflows/pr-issue-bot.yml

steps:
- name: Assign PR to its author
uses: actions/github-script@v7
uses: actions/github-script@v7.0.1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the relevant workflow file with line numbers
FILE=".github/workflows/assign-pr-author-on-merge.yml"
echo "== File: $FILE =="
if [ -f "$FILE" ]; then
  nl -ba "$FILE" | sed -n '1,120p'
else
  echo "File not found: $FILE" >&2
fi

# Find all usages of actions/github-script in workflows
echo
echo "== usages of actions/github-script@ in .github/workflows =="
rg -n "actions/github-script@" .github/workflows || true

# Look for any actions pinned to full 40-char SHAs in workflows (security pattern)
echo
echo "== workflows using pinned 40-char SHAs for uses: =="
rg -n --glob ".github/workflows/*" "uses: .*@[0-9a-f]{40}" .github/workflows || true

# Search for any repo guidance/policy about pinning actions
echo
echo "== search for pinning guidance keywords =="
rg -n --hidden --glob "!**/node_modules/**" "hash pin|pin(ning)? .*SHA|immutable commit SHA|actions are pinned|dependabot.*pin|workflow.*pin" .github README* SECURITY* . || true

Repository: RohanExploit/VishwaGuru

Length of output: 188


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE=".github/workflows/assign-pr-author-on-merge.yml"
echo "== File: $FILE =="
if [ -f "$FILE" ]; then
  # line-number output without `nl`
  cat -n "$FILE" | sed -n '1,140p'
else
  echo "File not found: $FILE" >&2
fi

echo
echo "== usages of actions/github-script@ in .github/workflows =="
rg -n "actions/github-script@" .github/workflows || true

echo
echo "== workflows using pinned 40-char SHAs for uses: =="
rg -n "uses: .*@[0-9a-f]{40}" .github/workflows || true

echo
echo "== repo guidance keywords for pinning actions =="
# Search common files; tolerate missing globs
rg -n --hidden --glob "!**/node_modules/**" \
  "hash pin|immutable commit SHA|pin(ning)? (actions|workflows)|actions are pinned|dependabot.*pin|workflow.*pin" \
  .github README* SECURITY* . 2>/dev/null || true

Repository: RohanExploit/VishwaGuru

Length of output: 1849


Pin actions/github-script to an immutable commit SHA.

This workflow uses the tag actions/github-script@v7.0.1; tags are mutable and can be retargeted, so SHA pinning reduces supply-chain risk.

Suggested change
-        uses: actions/github-script@v7.0.1
+        uses: actions/github-script@<40-char-commit-sha> # v7.0.1
🧰 Tools
🪛 zizmor (1.25.2)

[error] 17-17: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/assign-pr-author-on-merge.yml at line 17, Replace the
mutable tag usage actions/github-script@v7.0.1 with the corresponding immutable
commit SHA for actions/github-script (i.e., change the uses entry in the
workflow from actions/github-script@v7.0.1 to
actions/github-script@<commit-sha>) so the job definition uses a pinned SHA;
locate the uses line referencing actions/github-script and update it to the
exact commit SHA from the repository to eliminate tag mutability risk.

steps:
- name: Auto-close referenced issues
uses: actions/github-script@v7
uses: actions/github-script@v7.0.1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the referenced workflow with line numbers
echo "=== auto-close-mentioned-issues.yml (lines 1-80) ==="
nl -ba .github/workflows/auto-close-mentioned-issues.yml | sed -n '1,80p'

# Confirm whether github-script is used anywhere else in workflows
echo
echo "=== Search for actions/github-script@ in workflows ==="
rg -n "uses:\s*actions/github-script@" .github/workflows || true

Repository: RohanExploit/VishwaGuru

Length of output: 181


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=".github/workflows/auto-close-mentioned-issues.yml"

echo "=== $file (lines 1-120) ==="
if [ -f "$file" ]; then
  awk 'NR>=1 && NR<=120 {printf "%4d\t%s\n", NR, $0}' "$file"
else
  echo "Missing: $file"
fi

echo
echo "=== Search for github-script usages in .github/workflows ==="
rg -n "uses:\s*actions/github-script@" .github/workflows || true

echo
echo "=== Search for all uses of actions/* in this workflow ==="
rg -n "uses:\s*actions/" "$file" || true

Repository: RohanExploit/VishwaGuru

Length of output: 2783


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Show lines around github-script uses in all workflows ==="
for f in .github/workflows/*.yml; do
  echo
  echo "---- $f ----"
  # print the line and a few surrounding lines
  rg -n --no-heading "uses:\s*actions/github-script@v7\.0\.1" "$f" || true
  rg -n --context 2 --no-heading "uses:\s*actions/github-script@" "$f" || true
done

echo
echo "=== Check whether any uses of actions/* in workflows are pinned to commit SHA/digest ==="
# This is heuristic: look for @<hex40> or `@sha256`: patterns
rg -n --no-heading "uses:\s*actions/[^@]+@([0-9a-fA-F]{40}|sha256:[0-9a-fA-F]{64})" .github/workflows/*.yml || true

Repository: RohanExploit/VishwaGuru

Length of output: 1773


Pin actions/github-script to an immutable commit SHA (or digest), not v7.0.1.

.github/workflows/auto-close-mentioned-issues.yml uses actions/github-script@v7.0.1, which is an unpinned tag; the same pattern appears in other workflows (pr-issue-bot.yml, assign-pr-author-on-merge.yml, greetings.yml).

Suggested change
-        uses: actions/github-script@v7.0.1
+        uses: actions/github-script@<40-char-commit-sha> # v7.0.1
🧰 Tools
🪛 zizmor (1.25.2)

[error] 18-18: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/auto-close-mentioned-issues.yml at line 18, Replace the
unpinned action reference "actions/github-script@v7.0.1" with an immutable
commit SHA or digest (e.g., "actions/github-script@<commit-sha>" or "@<digest>")
so the workflow cannot change unexpectedly; update the same pattern in the other
workflows mentioned (pr-issue-bot.yml, assign-pr-author-on-merge.yml,
greetings.yml) by locating their "uses: actions/github-script@v7.0.1" lines and
swapping the tag for the corresponding pinned commit SHA/digest from the
actions/github-script repository release you intend to lock to.

Comment thread .github/workflows/greetings.yml Outdated
steps:
- name: Greet New Contributors
uses: actions/github-script@v7
uses: actions/github-script@v7.0.1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the workflow section around the referenced line
sed -n '1,120p' .github/workflows/greetings.yml

# Confirm whether the action reference exists anywhere else in the repo (for consistency/policy)
rg -n "uses:\s*actions/github-script@" -S .github/workflows || true
rg -n "actions/github-script@" -S . || true

Repository: RohanExploit/VishwaGuru

Length of output: 4054


Pin actions/github-script to an immutable commit SHA

.github/workflows/greetings.yml uses the mutable tag actions/github-script@v7.0.1 (also used in other workflows). Pin to the 40-char commit SHA instead of the tag.

Suggested change
-        uses: actions/github-script@v7.0.1
+        uses: actions/github-script@<40-char-commit-sha> # v7.0.1
🧰 Tools
🪛 zizmor (1.25.2)

[error] 18-18: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/greetings.yml at line 18, The workflow is using the
mutable tag "uses: actions/github-script@v7.0.1"; replace that tag with the
corresponding immutable 40-character commit SHA for actions/github-script
(update the "uses: actions/github-script@v7.0.1" entry to "uses:
actions/github-script@<commit-sha>") and apply the same SHA pin to any other
workflows using the same tag to prevent future changes; ensure the chosen SHA
corresponds to the v7.0.1 release to preserve behavior.

l_max_size: '1000'
xl_label: 'size/xl'
fail_if_xl: 'false'
uses: pascalgn/size-label-action@v0.5.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE=".github/workflows/pr-issue-bot.yml"

echo "== File =="
ls -la "$FILE"

echo
echo "== Lines 1-160 =="
nl -ba "$FILE" | sed -n '1,160p'

Repository: RohanExploit/VishwaGuru

Length of output: 243


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE=".github/workflows/pr-issue-bot.yml"

echo "== Lines 1-160 =="
awk '{printf "%4d:%s\n", NR, $0}' "$FILE" | sed -n '1,160p'

echo
echo "== Matching uses: `@v`* (unpinned) =="
rg -n --no-heading 'uses:\s*[^@]+@v[0-9]+' "$FILE" || true

echo
echo "== Matching uses: (all) =="
rg -n --no-heading '^\s*uses:\s*' "$FILE" || true

Repository: RohanExploit/VishwaGuru

Length of output: 6615


Pin workflow actions to commit SHAs to avoid mutable @v* references

The workflow still uses tag-based actions:

  • pascalgn/size-label-action@v0.5.0 (line 19)
  • actions/github-script@v7.0.1 (lines 30, 73, 116)
Suggested change
-        uses: pascalgn/size-label-action@v0.5.0
+        uses: pascalgn/size-label-action@<40-char-commit-sha> # v0.5.0
...
-        uses: actions/github-script@v7.0.1
+        uses: actions/github-script@<40-char-commit-sha> # v7.0.1
...
-        uses: actions/github-script@v7.0.1
+        uses: actions/github-script@<40-char-commit-sha> # v7.0.1
...
-        uses: actions/github-script@v7.0.1
+        uses: actions/github-script@<40-char-commit-sha> # v7.0.1
🧰 Tools
🪛 zizmor (1.25.2)

[error] 19-19: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/pr-issue-bot.yml at line 19, Workflow uses mutable tag
pins for third-party actions (pascalgn/size-label-action@v0.5.0 and
actions/github-script@v7.0.1); replace those tag references with immutable
commit SHAs. Locate the two usages of actions/github-script@v7.0.1 and the
single usage of pascalgn/size-label-action@v0.5.0 in the workflow, look up the
corresponding commit SHA on each action's GitHub repo, and replace the `@vX.Y.Z`
tag with the exact commit SHA (e.g., @<full-commit-sha>) so the workflow is
pinned to a specific commit.

- The previous commit upgraded `actions/github-script` to `v7.0.1`, which caused a 404 download failure because the release tarball cannot be resolved by GitHub Actions in this environment. Reverting back to `v7` to trigger a re-run.
@github-actions
Copy link
Copy Markdown

🔍 Quality Reminder

Thanks for the updates! Please ensure:
- Your changes don't break existing functionality
- All tests still pass
- Code quality standards are maintained

*The maintainers will verify that the overall project flow remains intact.*

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants