Skip to content

GH#3030: Fix high-severity quality-debt in batch-strategy-helper.sh#3034

Closed
marcusquinn wants to merge 1 commit intomainfrom
fix/batch-strategy-quality-debt
Closed

GH#3030: Fix high-severity quality-debt in batch-strategy-helper.sh#3034
marcusquinn wants to merge 1 commit intomainfrom
fix/batch-strategy-quality-debt

Conversation

@marcusquinn
Copy link
Owner

Summary

Addresses all 5 findings from PR #3000 Gemini code review on .agents/scripts/batch-strategy-helper.sh.

Closes #3030

Changes

HIGH severity (2 findings)

  • Refactored get_dispatchable_tasks — replaced O(n*m) shell-loop calling is_task_unblocked (which itself looped jq calls) with a single jq pass using a status lookup map. Removed the now-unused is_task_unblocked function.
  • Refactored order_depth_first — replaced shell loop that appended to JSON arrays via repeated jq invocations with a single jq pass that iterates sorted branches and chunks task IDs.

MEDIUM severity (3 findings)

  • Fixed grep injection vulnerabilities — eliminated all grep -qx "$variable" calls (vulnerable to regex and argument injection) by moving the validation logic entirely into jq. No grep calls remain in the file.
  • Fixed circular dependency detection — the previous DFS was fundamentally flawed: it produced false positives on diamond-shaped graphs (shared visited set across branches) and false negatives on multi-branch cycles (inner loop overwrote current). Replaced with a proper DFS using an explicit stack with path tracking, implemented entirely in jq.
  • Fixed 2>/dev/null error suppression — replaced with >/dev/null on the jq validation call to preserve stderr for debugging.

Verification

  • ShellCheck: zero violations (only SC1091 for external source, already annotated)
  • All functions have explicit return statements and local variable declarations
  • Tested with: valid graph, circular dependency, missing blocker reference, diamond graph (no false positive), empty tasks, depth-first ordering, breadth-first ordering, next-batch with blockers
  • Net reduction: 99 insertions, 171 deletions (72 lines removed)

Closes #3030

Address all 5 findings from PR #3000 Gemini review:

HIGH: Refactor get_dispatchable_tasks to single jq pass, eliminating
O(n*m) shell-loop jq invocations. Remove now-unused is_task_unblocked
function.

HIGH: Refactor order_depth_first to single jq pass, replacing the
inefficient pattern of appending to JSON arrays in a shell loop.

MEDIUM: Fix grep injection vulnerabilities — replaced all bare
grep -qx with proper jq-based validation (grep calls eliminated
entirely by moving validation logic into jq).

MEDIUM: Fix flawed circular dependency detection that produced false
positives on diamond graphs and false negatives on multi-branch
cycles. Replaced with proper DFS using explicit stack and path
tracking, implemented entirely in jq.

MEDIUM: Replace 2>/dev/null with >/dev/null on jq validation call
to preserve stderr for debugging while still suppressing stdout.
@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 Mar 7, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2db0f833-f64a-4af0-9d62-898f016d2744

📥 Commits

Reviewing files that changed from the base of the PR and between 75b90ad and e3d5d3a.

📒 Files selected for processing (1)
  • .agents/scripts/batch-strategy-helper.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/batch-strategy-quality-debt

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

github-actions bot commented Mar 7, 2026

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Mar 7 02:58:20 UTC 2026: Code review monitoring started
Sat Mar 7 02:58:21 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 108

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 108
  • VULNERABILITIES: 0

Generated on: Sat Mar 7 02:58:24 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 7, 2026

@marcusquinn
Copy link
Owner Author

Closing as duplicate — PR #3033 addressed the same issue (#3030) and was merged with CodeRabbit approval. This PR was created in parallel and targets the same changes.

@marcusquinn marcusquinn closed this Mar 7, 2026
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.

quality-debt: .agents/scripts/batch-strategy-helper.sh — PR #3000 review feedback (high)

1 participant