Skip to content

feat: implement issue #382 — Enhance dev-lead and pr-review engines for Gemini 3.5 models - #580

Merged
don-petry merged 49 commits into
mainfrom
dev-lead/issue-382-20260611-2227
Jun 15, 2026
Merged

feat: implement issue #382 — Enhance dev-lead and pr-review engines for Gemini 3.5 models#580
don-petry merged 49 commits into
mainfrom
dev-lead/issue-382-20260611-2227

Conversation

@don-petry

@don-petry don-petry commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Closes #382

Implemented by dev-lead agent. Please review.

Summary by CodeRabbit

Release Notes

  • Updates

    • Upgraded Gemini models to versions 3.5-flash and 3.5-pro
    • Enhanced model routing for different analysis types
    • "Rubber duck" debugging now routes to Claude
  • New Features

    • Automatic fallback to alternative Gemini models when rate limits are encountered
  • Tests

    • Added comprehensive test coverage for model selection and fallback chain behavior

@don-petry
don-petry requested a review from a team as a code owner June 11, 2026 22:50
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@don-petry, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 33 minutes and 58 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5a96a3b4-67b4-492b-bdb5-ea342e8ac43f

📥 Commits

Reviewing files that changed from the base of the PR and between e072fda and d3a9c5f.

📒 Files selected for processing (2)
  • scripts/engine.sh
  • tests/dev-lead/unit/test_engine_chain.bats
📝 Walkthrough

Walkthrough

This PR upgrades engine configuration to support Gemini 3.5 models with per-tier fallback chains that automatically retry rate-limited requests using configured model fallbacks. It integrates chain-aware invocation across all tier execution paths, adds comprehensive test coverage with per-model test fixture overrides, and updates the billing validation probe.

Changes

Gemini 3.5 Model Support with Chain Fallback

Layer / File(s) Summary
Gemini 3.5 configuration and chain setup
scripts/engine.sh (lines 79–101, 125, 146)
Configures default Gemini 3.5 models (flash for action/triage, pro for quality tiers) with environment override support, establishes per-tier fallback chains (GEMINI_FLASH_MODEL_CHAIN, GEMINI_PRO_MODEL_CHAIN), updates copilot duck routing to gemini-3.5-flash, and exports chain variables for downstream callers.
Chain invocation with rate-limit fallback
scripts/engine.sh (lines 410–517)
Implements _gemini_chain_invoke helper that iterates a comma-separated model chain, captures output and error to temp files, detects rate-limit responses and skips to the next model, propagates non-rate-limit failures immediately, returns exit code 2 when all models rate-limit with parsed reset time, and tracks the successful model in _GEMINI_CHAIN_MODEL_USED.
Tier execution integration with chain invoke
scripts/engine.sh (lines 746–751, 765–772, 851–871, 892–893, 1128–1137, 1162–1163)
Updates run_triage, run_agentic, and run_writer to use _gemini_chain_invoke instead of single-model invocation: triage uses flash chain, agentic selects chain by tier (pro for deep/audit/single, flash for others) with explicit model pin support, writer uses flash chain with pin support, and all functions record the used model from _GEMINI_CHAIN_MODEL_USED for observability.
Test fixture for per-model configuration
tests/dev-lead/fixtures/engines/stub-gemini (lines 4–10, 29–45, 67–77)
Updates stub-gemini test fixture to support per-model response and exit-code overrides via STUB_ENGINE_RESPONSE_BY_MODEL and STUB_ENGINE_EXIT_BY_MODEL (pipe-delimited format) with fallback to defaults, and adds optional model recording via STUB_ENGINE_RECORD_MODELS for test observability.
Comprehensive Gemini 3.5 unit tests
tests/dev-lead/unit/test_engine_gemini_35.bats (290 lines)
Adds new test suite covering: default tier-to-model assignments, fallback chain validation, environment override behavior, intent-to-model dispatch, _gemini_chain_invoke semantics (success without fallback, rate-limit fallthrough, all-rate-limited exit code 2, immediate non-rate-limit failure, invalid chain error), end-to-end writer fallback, and regression checks for non-Gemini engines.
Existing test update for Gemini routing
tests/dev-lead/unit/test_engine_chain.bats (lines 190–200)
Adds test case verifying that writer execution with Gemini engine invokes only Gemini models and does not route through Claude fallback.
Validation probe update
scripts/validate-engines.sh (line 43)
Updates Gemini billing probe to use gemini-3.5-flash:generateContent endpoint instead of gemini-2.0-flash.

Sequence Diagram

sequenceDiagram
    participant TierExec as Tier Executor<br/>(run_triage/agentic/writer)
    participant ChainInvoke as _gemini_chain_invoke
    participant GeminiInvoke as _gemini_invoke
    participant RateCheck as is_rate_limited_files
    TierExec->>ChainInvoke: invoke chain (e.g., flash,flash-backup)
    loop For each model in chain
        ChainInvoke->>GeminiInvoke: invoke model, capture stdout/stderr
        GeminiInvoke-->>ChainInvoke: model response or error
        ChainInvoke->>RateCheck: check temp files for rate-limit
        alt Rate-limited
            ChainInvoke->>ChainInvoke: warn, try next model
        else Non-rate-limit error
            ChainInvoke-->>TierExec: return error code (immediate)
        else Success
            ChainInvoke->>ChainInvoke: set _GEMINI_CHAIN_MODEL_USED
            ChainInvoke-->>TierExec: return success
        end
    end
    alt All models rate-limited
        ChainInvoke->>ChainInvoke: parse reset time from output
        ChainInvoke-->>TierExec: return exit code 2 (all-rate-limited)
    end
    TierExec->>TierExec: record _GEMINI_CHAIN_MODEL_USED for logging
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • petry-projects/.github-private#460: Modifies the same tier execution functions (run_triage, run_agentic, run_writer) to add per-invocation token-usage exports alongside chain invocation changes.
  • petry-projects/.github-private#334: Updates the same tier paths for token JSONL logging via temp-file plumbing, overlapping with this PR's chain fallback handling logic.
  • petry-projects/.github-private#371: Modifies run_writer() to persist session output to /tmp/dev-lead-session-output.txt, affecting the same function updated here for Gemini chain integration.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: implementation of Gemini 3.5 model support for dev-lead and pr-review engines, directly matching the PR's core objective.
Linked Issues check ✅ Passed The PR implements Gemini 3.5 support with configurable model selection, per-tier routing, chain fallback logic, and observability tracking in engine.sh; validates model endpoints in validate-engines.sh; extends test fixtures and adds comprehensive test coverage for chain behavior and model tier mapping.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #382: engine config updates, fallback chain implementation, test fixtures for per-model overrides, and test coverage for Gemini 3.5 tier mapping and chain invocation logic.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-382-20260611-2227

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.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) June 11, 2026 22:52

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces Gemini model fallback chains and updates default Gemini models to Gemini 3.5 Flash, adding the _gemini_chain_invoke helper to handle rate-limiting and graceful degradation. Feedback on the changes includes ensuring REVIEW_ENGINE is checked before attributing the triage model to prevent incorrect attribution from dirty environment variables, mapping each agentic tier to its specific default model to avoid disabling fallback chains on custom configurations, and declaring the models array as local in _gemini_chain_invoke to prevent global scope pollution.

Comment thread scripts/engine.sh
Comment thread scripts/engine.sh
Comment thread scripts/engine.sh
@don-petry
don-petry disabled auto-merge June 11, 2026 22:53
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 11, 2026
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-reviews (applied)

Changes committed and pushed.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #580
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-06-11T23:38:15Z

@don-petry

Copy link
Copy Markdown
Collaborator Author

Note

@don-petry I reviewed this PR and no code changes were needed, but it still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews), so I cannot mark it done yet. I'll re-check automatically.
Next attempt after: 2026-06-11T23:38:15Z

@don-petry
don-petry enabled auto-merge (squash) June 11, 2026 23:08
@don-petry
don-petry disabled auto-merge June 11, 2026 23:52
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) June 11, 2026 23:57
@don-petry
don-petry disabled auto-merge June 12, 2026 00:06
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) June 12, 2026 00:06
@don-petry
don-petry disabled auto-merge June 12, 2026 00:42
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) June 12, 2026 00:45
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
Issues addressed: 0
Files changed: none
Status: Quality Gate Passed — no actionable findings
```
No changes are needed. The SonarCloud quality gate passed, and there are no blocking issues to address.

@sonarqubecloud

Copy link
Copy Markdown

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
Issues addressed: 0
- SonarCloud Quality Gate Passed with 0 new issues
- All code quality checks passed (CodeQL, ShellCheck, Lint, etc.)
- No reviews with CHANGES_REQUESTED state
Files changed: None required
Skipped: N/A
```
The PR is **clean from a code quality perspective**. SonarCloud reports 0 issues, all quality gates pass, and there are no blocking review comments. The two cancelled `dev-lead` orchestration checks are expected behavior (dispatcher logic, not code issues). The PR is ready for reviewer approval.

@donpetry-bot donpetry-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: d3a9c5f49bbd20497cb7cceb43206601da62408e
Review mode: triage-approved (single reviewer)

Summary

Wires gemini-3.5-flash into the speed tiers (triage + action) and keeps gemini-2.5-pro on the quality tiers (deep/audit/single) for the gemini engine, adds in-engine rate-limit fallback chains (_gemini_chain_invoke) mirroring the existing _claude_chain_invoke semantics, env-overridable model + chain config, a provisional pricing row, and an updated copilot duck model. Backed by a new 290-line bats suite plus an updated stub-gemini fixture. 506/-25 across 6 files, all non-test changes confined to engine config/orchestration.

Linked issue analysis

Closes #382. The issue is broad (configurable registry, capability-aware routing, SDK modernization, observability metrics, staged rollout flags). This PR delivers the core, testable subset: configurable per-tier models with env overrides (GEMINI_FLASH_MODEL / GEMINI_PRO_MODEL), capability-aware chain selection (flash chain for speed tiers, pro chain for quality tiers), explicit + tested fallback behavior, and pricing. The pr-review output contract is untouched, so no schema regression. Softer deliverables (Google GenAI SDK migration, per-agent observability metrics, phased rollout flags) are not in this PR but the acceptance criteria around configurable model selection and explicit, controllable fallback are met. Reasonable incremental scope.

Findings

All three prior gemini-code-assist advisory comments (dated 2026-06-11, against the initial commit) are already resolved in the reviewed head d3a9c5f:

  • HIGH (engine.sh:882) — run_triage now guards on REVIEW_ENGINE before reading _CLAUDE_CHAIN_MODEL_USED, with a parallel _GEMINI_CHAIN_MODEL_USED branch; correct attribution.
  • MEDIUM (engine.sh:977) — run_agentic maps each tier to its own default (ENGINE_DEEP/AUDIT/SINGLE_MODEL) rather than reusing ENGINE_DEEP_MODEL, so the explicit-pin check no longer mis-fires.
  • LOW (engine.sh:510) — models array is declared 'local -a' with saved/restored IFS.
    Pricing: the new 'gemini-3.5-flash*' row is self-flagged provisional (VERIFY); lookup in model-pricing.sh selects the most-specific glob by literal length (16 vs 11 for 'geminiflash*'), so it prices correctly regardless of row order. _gemini_chain_invoke handling of mktemp failure, all-rate-limited (rc=2), and non-rate-limit fast-fail is covered by tests. No blocking issues.

CI status

Green. unit-tests, bats, shellcheck/ShellCheck/Lint, validate-fixtures, validate-agent-profiles, CodeQL (actions+python), SonarCloud (quality gate passed, 0 new issues), agent-shield, gitleaks, and all permission/structure gates pass. Two CANCELLED checks (dev-lead / dispatch, dev-lead / ci-relay) are concurrency cancellations, treated as non-blocking per the recently merged #609 fix — not real failures. Codex review comment is a usage-limit notice, not a finding.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

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.

Enhance dev-lead and pr-review engines for Gemini 3.5 models

2 participants