Skip to content

feat: queue priority - fresh tasks before retries (t313)#1213

Merged
marcusquinn merged 1 commit intomainfrom
feature/t313
Feb 12, 2026
Merged

feat: queue priority - fresh tasks before retries (t313)#1213
marcusquinn merged 1 commit intomainfrom
feature/t313

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 12, 2026

Summary

  • Modifies cmd_next() dispatch ordering to sort by retries ASC first, ensuring fresh tasks (retries=0) always dispatch before retried tasks
  • Only 2 queries changed — both in cmd_next() (batch dispatch and global dispatch)
  • Informational queries (status, dashboard, release) left unchanged — retry ordering is irrelevant there

Problem

When failed tasks get reset and re-queued, they could consume all dispatch slots, blocking fresh tasks that have a better chance of succeeding. This wastes worker tokens on tasks that already failed once.

Changes

Location Before After
cmd_next() batch query (L3693) ORDER BY bt.position ORDER BY t.retries ASC, bt.position
cmd_next() global query (L3702) ORDER BY created_at ASC ORDER BY retries ASC, created_at ASC

Testing

  • bash -n syntax check: PASS
  • ShellCheck: no new warnings
  • Diff is exactly 2 insertions, 2 deletions

Closes #313

Summary by CodeRabbit

  • Bug Fixes
    • Refined task dispatch logic to prioritize task execution based on retry history. Tasks with fewer previous retry attempts are now processed earlier in both batch and standalone task queues, improving overall dispatch efficiency.

Previous commit changed ORDER BY in 7 queries including informational ones
(check_batch_completion, cmd_status, run_session_review, cmd_release).
Only the 2 dispatch queries in cmd_next() need retry-aware ordering.
Reset and re-apply to just those 2 locations.
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Walkthrough

Modified SQL ordering logic in supervisor-helper.sh to prioritize tasks with fewer retries when selecting tasks for batch processing and standalone queued task selection, altering the sort sequence to prefer fresh tasks before fallback ordering criteria.

Changes

Cohort / File(s) Summary
Task Selection Ordering
.agents/scripts/supervisor-helper.sh
Modified cmd_next SQL ORDER BY clauses: batch task selection now sorts by t.retries ASC, bt.position; standalone queued task selection sorts by retries ASC, created_at ASC. Prioritizes tasks with lower retry counts within each selection pathway.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Poem

🔄 Fresh tasks dance to the front of the queue,
Retries bow down to the ones that are new,
With retries ASC, we sort with care—
Lower counts first, a burden less rare! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 3
❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title describes queue priority sorting changes, but the actual changes implement a command injection security fix in credential-helper.sh with security slash commands. Update the title to reflect the actual security fix: 'fix(security): prevent command injection in credential-helper.sh' or include both the security fix and queue priority changes if both are in scope.
Linked Issues check ⚠️ Warning The PR changes focus on queue sorting logic in supervisor-helper.sh, but linked issue #313 requires fixing a command injection vulnerability in credential-helper.sh and adding security slash commands. Ensure the code changes address the credential-helper.sh vulnerability and implement printf %q escaping, plus add the required security slash commands (/security-analysis, /security-scan, /security-deps, /security-history).
Out of Scope Changes check ⚠️ Warning The PR modifies SQL ordering in supervisor-helper.sh for queue priority, but the linked issue #313 scope is exclusively a security fix for credential-helper.sh and slash command additions, making these changes out of scope. Separate concerns: either move queue priority changes to a new PR or refocus this PR entirely on the credential-helper.sh security vulnerability fix specified in issue #313.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t313

No actionable comments were generated in the recent review. 🎉


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.

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 15 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Feb 12 03:41:28 UTC 2026: Code review monitoring started
Thu Feb 12 03:41:28 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 15

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 15
  • VULNERABILITIES: 0

Generated on: Thu Feb 12 03:41:31 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@marcusquinn marcusquinn merged commit 6948d71 into main Feb 12, 2026
9 of 11 checks passed
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