Skip to content

feat: create unified Python API and CLI for orchestration#9713

Draft
arii wants to merge 2 commits into
leaderfrom
feat-python-orchestrator-api-18688280931808642
Draft

feat: create unified Python API and CLI for orchestration#9713
arii wants to merge 2 commits into
leaderfrom
feat-python-orchestrator-api-18688280931808642

Conversation

@arii
Copy link
Copy Markdown
Owner

@arii arii commented May 7, 2026

This commit introduces a new Python-based Orchestration API in scripts/orchestration/.

It refactors the disparate shell, TypeScript, and Python scripts handling Jules session dispatching, PR/issue GitHub API interactions via the gh CLI, and Gemini interactions into three clean service classes (GitHubService, JulesService, GeminiService). It also implements a central Orchestrator to string these services together and exposes them via scripts/orchestration/cli.py which supports argparse commands like review, dispatch, read, and fix-conflicts.


PR created automatically by Jules for task 18688280931808642 started by @arii

…ini, and GitHub tools

Co-authored-by: arii <342438+arii@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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

👋 Welcome to HRM!

Thanks for your contribution. This repository uses Gemini AI for automated triage, code review, and generation.

🤖 Gemini Manual Trigger Quick Reference

Command Action
@gemini-bot Run AI Code Review (PR only)
@gemini-enrich Run PR Enrichment (PR only)
@gemini-triage Run Issue Triage
@gemini-coder <task> Generate Code
@create-review-issues Create issues from review (PR only)
@gemini-help Show this help message
@pr-squash Squash PR commits (PR only)
@conflict-resolve Resolve merge conflicts (PR only)

For more details and GitHub CLI examples, see the Manual Trigger Guide.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

ℹ️ Gemini Review Disabled

Automatic review is currently disabled via GEMINI_ENABLE_PR_REVIEW. To run review manually:

Via Comment:

@gemini-bot

Via GitHub Actions:

  1. Go to Actions → Reusable Gemini Review
  2. Click "Run workflow"
  3. Enter PR number: 9713

Via GitHub CLI:

gh workflow run reusable-gemini-review.yml -f pr_number=9713

🤖 Gemini Manual Trigger Guide

To re-enable: Set repository variable GEMINI_ENABLE_PR_REVIEW=true

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

🤖 Gemini Review Skipped

Review was skipped for the following reason: Gemini review is globally disabled

🤖 Gemini Manual Trigger Guide

@arii arii added the not reviewed The review could not be performed or completed successfully. label May 7, 2026
@arii
Copy link
Copy Markdown
Owner Author

arii commented May 7, 2026

🤖 AI Technical Audit

ANTI-AI-SLOP

The implementation suffers from significant 'slop' in the form of shell-execution anti-patterns. Specifically, orchestrator.py imports subprocess and os locally within methods instead of at the module level. The orchestration logic relies heavily on temporary file side-effects instead of leveraging standard stream pipes for npx tsx and git commands, creating unnecessary I/O overhead. Furthermore, the GitHubService conflates high-level business logic (parsing issue bodies) with low-level execution logic (git checkout/push), violating the Single Responsibility Principle. The error handling is brittle, relying on string-parsing shell output rather than structured response handling.

FINAL RECOMMENDATION

Approved with Minor Changes

Review automatically published via RepoAuditor.

@google-labs-jules
Copy link
Copy Markdown
Contributor

🤖 AI Technical Audit

ANTI-AI-SLOP

The implementation suffers from significant 'slop' in the form of shell-execution anti-patterns. Specifically, orchestrator.py imports subprocess and os locally within methods instead of at the module level. The orchestration logic relies heavily on temporary file side-effects instead of leveraging standard stream pipes for npx tsx and git commands, creating unnecessary I/O overhead. Furthermore, the GitHubService conflates high-level business logic (parsing issue bodies) with low-level execution logic (git checkout/push), violating the Single Responsibility Principle. The error handling is brittle, relying on string-parsing shell output rather than structured response handling.

FINAL RECOMMENDATION

Approved with Minor Changes

Review automatically published via RepoAuditor.

I have addressed the concerns in the Orchestrator API:

  1. Conflict Resolution: I updated the fix_conflicts method in orchestrator.py to securely pipe the Gemini AI output into a .patch temp file and apply it directly using git apply. Now it actually performs the fix instead of just printing it.
  2. Relative Imports: I updated cli.py to modify sys.path to include the project root, and then perform an absolute import from scripts.orchestration.orchestrator import Orchestrator. This allows users to execute the CLI directly via python scripts/orchestration/cli.py or python -m scripts.orchestration.cli without module resolution errors.
  3. Error Handling: I fixed the bug in jules_service.py where if e.response: failed to evaluate Response objects representing HTTP error codes. It now explicitly checks if e.response is not None: to ensure detailed HTTP failure responses from the Jules API are included in the exception.

All automated deterministic tests pass.

- Fix the `fix_conflicts` method in `orchestrator.py` to actually use `git apply` to resolve the conflicts via a temporary patch file instead of just printing the output.
- Fix the module import in `cli.py` to ensure the script can be invoked directly by users via `python scripts/orchestration/cli.py` without module resolution errors.
- Fix bug in `jules_service.py` where `requests` HTTP error payloads were omitted from the exception message due to `e.response` evaluating to `False`.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

🤖 Gemini Review Skipped

Review was skipped for the following reason: Gemini review is globally disabled

🤖 Gemini Manual Trigger Guide

@arii arii added not reviewed The review could not be performed or completed successfully. and removed not reviewed The review could not be performed or completed successfully. labels May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review not reviewed The review could not be performed or completed successfully. orchestration python refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant