Skip to content

feat: Implement MCPOrchestrator._execute_on_server for true E2E execution - #1038

Closed
google-labs-jules[bot] wants to merge 14 commits into
mainfrom
feature/implement-mcp-orchestrator-execution-7365924146265499223
Closed

feat: Implement MCPOrchestrator._execute_on_server for true E2E execution#1038
google-labs-jules[bot] wants to merge 14 commits into
mainfrom
feature/implement-mcp-orchestrator-execution-7365924146265499223

Conversation

@google-labs-jules

@google-labs-jules google-labs-jules Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Status

Draft and outside active #898 execution. No focused child issue or valid issue-bound receipt exists. PR #1040 remains a draft duplicate; its useful test repair is preserved in this canonical branch.

Outcome

Implements MCPOrchestrator._execute_on_server with aiohttp JSON-RPC execution, optional bearer authentication, pooled-session reuse, bounded temporary-session fallback, and dependency-free unit tests using unittest.mock.

Latest containment — 2026-07-27

Provider head 843b0532193da9ebf0089779635877e401e0cbc8 again:

  • lowered coverage fail_under from 88.1833 to 75.0;
  • weakened the coverage governance guardrail;
  • added test-only aioresponses to production requirements;
  • replaced the verified MCP execution path with NotImplementedError;
  • deleted most verified execution tests.

The controller restored all five affected files through additive commits on this same branch. Final exact head b3c347aebec92dd69977819c8508742a96e38bb4 is 12 commits ahead of trusted 265f411989b4887d8e90c78fc8f9e438abae3dbd with zero changed files.

Exact-head evidence

  • CI 30292637516 passes.
  • Coverage 30292637794 passes.
  • CodeQL 30292637610 passes.
  • Security 30292637880 passes.
  • Secret Scan 30292637799 passes.
  • Dependency Review 30292638076 passes.
  • E2E 30292637704 is repository-skipped.
  • All three review threads remain resolved and outdated after exact tree comparison.
  • Coverage floor is 88.1833; the guardrail requires >= 88.1833.
  • Exact-head Preview is canceled because the controller commit is unverified. This Python-only path is not exercised by the Next.js preview.
  • Truth gate remains correctly failing because no focused child issue or valid issue-bound receipt exists.

Execution receipt

  • Provider agent/run: google-labs-jules[bot] / task 7365924146265499223
  • Controller agent/run: groupthinking / eventrelay-blocker-watch-20260727T1808Z
  • Canonical branch/PR: feature/implement-mcp-orchestrator-execution-7365924146265499223 / feat: Implement MCPOrchestrator._execute_on_server for true E2E execution #1038
  • Claimed timestamp: 2026-07-27T17:49:06Z
  • Latest heartbeat: 2026-07-27T18:15:37Z
  • Exact head: b3c347aebec92dd69977819c8508742a96e38bb4

Next executable action

Bind one existing focused child issue and a valid issue-bound receipt before this can enter active execution. Until then, do not credit progress to #898, mark ready, or merge.

No merge, branch deletion, workflow approval, credential change, ruleset weakening, or production mutation is authorized.

- Implement real JSON-RPC over HTTP execution using `aiohttp` to replace the `NotImplementedError` stub, enabling true end-to-end MCP workflow capabilities.
- Manage `aiohttp.ClientSession` lifecycle within the orchestrator's start/stop loop, reusing connections to optimize performance.
- Provide a robust one-off fallback session handler for un-orchestrated execution contexts.
- Handle and re-raise exceptions seamlessly for logging and monitoring.
- Add comprehensive `aioresponses`-based mocking and unit tests covering successful HTTP calls, response errors, and payload data logic.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 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.

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v0-uvai Canceled Canceled Jul 27, 2026 6:11pm

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA b3c347a.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

Agent Completion Truth Gate: BLOCKED

Reasons: invalid_payload

Machine-readable verdict
{
  "details": {
    "invalid_fields": [
      "issue.number",
      "policy.agent_login",
      "policy.run_id"
    ]
  },
  "reasons": [
    "invalid_payload"
  ],
  "verdict": "blocked"
}

Workflow evidence

Comment thread tests/unit/test_mcp_orchestrator.py Outdated

Copy link
Copy Markdown
Owner

Automated pre-review scan (holding at the human merge gate — not merging).

Blocking-ish nit

  • src/youtube_extension/services/mcp/orchestrator.py: this diff introduces a duplicated "total_tasks": 0 key in the self.metrics = {…} literal (with surrounding stray blank lines). It's harmless at runtime (Python keeps the last value) but is dead/confusing code and may trip lint. Please drop the duplicate and the extra blank lines added in __init__, start_orchestration, and the except block.

Coordination

Session handling looks correct: _execute_on_server reuses self.session when the orchestration loop owns it and falls back to a short-lived ClientSession (closed in finally) otherwise. The JSON-RPC 2.0 payload + error handling and the new aioresponses tests are reasonable.

CI status: real checks (CI, CodeQL, Coverage, Security Scan) were still in_progress at scan time. The failure states are governance/policy gates (PR Governance, Agent completion enforcement, agent-completion/truth-gateinvalid_payload) and a canceled Vercel deploy — none are this PR's code. Recommend confirming the real test suite goes green, then human review before merging to main.


Generated by Claude Code

@groupthinking groupthinking left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Review — _execute_on_server implementation

Solid first cut. The ephemeral-vs-pooled session handling is correct (reuse self.session when orchestration is running, otherwise create a short-lived session and close it in finally — no leak), the JSON-RPC 2.0 envelope is well-formed, and the error-path test coverage (HTTP 500 + JSON-RPC error) is good. A few things to address before this merges:

1. Accidental duplicate + stray whitespace in self.metrics (should fix).
The diff adds a second "total_tasks": 0, key (plus blank lines) to the metrics dict:

self.metrics = {

    "total_tasks": 0,   # <-- duplicate, remove

    "total_tasks": 0,
    "completed_tasks": 0,

Harmless at runtime (Python keeps the last key) but clearly unintended. Please drop the duplicate key and the stray blank lines introduced here, in start_orchestration, and inside the except aiohttp.ClientError block.

2. timeout=task.timeout passes a bare int to session.post (robustness).
task.timeout is an int (seconds). aiohttp's per-request timeout expects a ClientTimeout; a bare number is coerced but the behavior is version-dependent and has been deprecation-prone. Prefer being explicit:

timeout=aiohttp.ClientTimeout(total=task.timeout)

Note the aioresponses-based tests mock the transport, so they don't actually exercise timeout handling — this wouldn't surface in CI.

3. Auth-token injection is a headline feature but isn't asserted (test gap).
test_successful_execution registers the server with auth_token="secret" but never checks that Authorization: Bearer secret was actually sent. Since token injection is one of the main points of this PR, please assert on the recorded request headers (aioresponses exposes m.requests) so the auth path is genuinely covered.

4. Optional — exception chaining.
raise RuntimeError(f"MCP server execution failed: {e}") inside except aiohttp.ClientError as e: drops the cause; raise RuntimeError(...) from e preserves the traceback. Minor (CI lint is currently green), but nicer for debugging.


Merge blocker is not the code. The red checks — agent-completion/truth-gate (invalid_payload: missing issue.number / policy.agent_login / policy.run_id), PR Governance, and Canonical issue and evidence — are failing because this PR has no linked canonical issue / evidence payload, not because of anything in the diff. The code-quality checks (lint-python, bandit, dependency-review) are green. That governance linkage needs to be sorted (or the gate satisfied) before this can merge; I'm leaving this as a comment, not request-changes, since items 1–4 are minor and the real gate is process, not correctness.


Generated by Claude Code

The new MCPOrchestrator._execute_on_server tests imported `aioresponses`,
which was never declared as a dev dependency — CI failed with
`ModuleNotFoundError: No module named 'aioresponses'` (3 failing tests).
Declaring the dependency alone does not fix it: aioresponses 0.7.9 is
incompatible with aiohttp 3.14 (ClientResponse now requires `stream_writer`),
so the tests would still error out once the module was installed.

Rewrite the three tests to mock the aiohttp session with unittest.mock —
no external dependency and version-proof — and add coverage for both the
pooled-session reuse path and the create-and-close fallback path.

Also tidy the orchestrator change introduced alongside the tests:
- group `import aiohttp` as a third-party import (ruff I001)
- annotate `self.session: Optional[aiohttp.ClientSession]` (mypy strict)
- drop a duplicated `total_tasks` key from the metrics dict
- chain the re-raised RuntimeError with `from e` (ruff B904)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdsNW4BxCUySyXJ42PRpJC

Copy link
Copy Markdown
Owner

The test job here is red because the new TestExecuteOnServer tests import aioresponses, which is not a declared dev dependency → ModuleNotFoundError (3 failing tests). Note that simply adding the dependency would not fix it: aioresponses 0.7.9 is incompatible with aiohttp 3.14 (ClientResponse.__init__ now requires stream_writer), so the tests would still error once the module was installed.

#1040 remediates this — it builds on this branch's commit 8eb9204 and rewrites those three tests to mock the aiohttp session with unittest.mock (no external dependency, version-proof; 87 tests pass locally). A maintainer should decide whether to merge #1040 or port that fix back here.


Generated by Claude Code

@groupthinking
groupthinking marked this pull request as draft July 27, 2026 16:17

Copy link
Copy Markdown
Owner

Controller reconciliation receipt — 2026-07-27

Comment thread pyproject.toml Outdated
Comment thread requirements.txt Outdated

Copy link
Copy Markdown
Owner

Controller containment receipt — 2026-07-27

  • Unsafe head 0383e79480ead6da6e856972fb88cec3bd80916f changed five files: lowered coverage to 75, weakened its guardrail, added aioresponses to production dependencies, and removed verified implementation/test coverage.
  • Restored the trusted tree additively on this branch; exact head is now 099ec0e507ac7b93a6f5039ea5038e616a692b66.
  • Exact comparison to trusted 265f411989b4887d8e90c78fc8f9e438abae3dbd: zero files changed.
  • CI 30288214021, Coverage 30288213943, CodeQL 30288213947, Security 30288214015, Secret Scan 30288214016, and Dependency Review 30288214006 pass; E2E 30288213913 is skipped.
  • All three review threads are resolved; Preview dpl_BzhnkM5q31Hx1YP67Muzd8i94Yvk is canceled for unverified controller commits.
  • Controller receipt: groupthinking / eventrelay-blocker-watch-20260727T1711Z / branch feature/implement-mcp-orchestrator-execution-7365924146265499223 / feat: Implement MCPOrchestrator._execute_on_server for true E2E execution #1038 / claimed 2026-07-27T17:11:53Z / heartbeat 2026-07-27T17:12:25Z / exact head 099ec0e507ac7b93a6f5039ea5038e616a692b66.

This is containment evidence, not #898 progress credit. #1038 remains draft and outside active execution until one existing focused child issue and a valid issue-bound receipt are attached.

Copy link
Copy Markdown
Owner

Contained another unsafe provider overwrite at 843b0532.

  • Restored all five affected files additively on the existing branch.
  • Final exact head b3c347aebec92dd69977819c8508742a96e38bb4 is tree-identical to trusted 265f411989b4887d8e90c78fc8f9e438abae3dbd.
  • CI 30292637516, Coverage 30292637794, CodeQL 30292637610, Security 30292637880, Secret Scan 30292637799, and Dependency Review 30292638076 pass; E2E 30292637704 is skipped.
  • All three review threads remain resolved. Exact-head Preview is canceled because commit provenance is unverified.
  • This PR remains draft and outside active [PROGRAM][OWNER:Codex] Autonomous EventRelay delivery control plane #898 execution: no focused child or valid issue-bound receipt exists.

@groupthinking

Copy link
Copy Markdown
Owner

Superseded by #1040, which explicitly remediates this PR ("remediates #1038") with an identical file set (src/youtube_extension/services/mcp/orchestrator.py, tests/unit/test_mcp_orchestrator.py) and identical diffstat (+175/-21). Consolidating on #1040 to remove the competing head.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants