Repository navigation
refactor(server): compose managed provider policy outside the adapters - #475
Merged
Merged
Conversation
The MCP session now carries one composed orchestration policy (instruction sections, model roles, native-subagent switch). Codex and Claude only translate it. The managed role comes from IssueEligibility, the propose_issue_change handler moves to RepositoryOrchestrationMcp, and ManagedIssueDelegation takes its thread loader once. The tool description now points at the issue panel instead of the Issues page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tannerpolley
marked this pull request as ready for review
November 18, 2026 02:16
tannerpolley
deleted the
issue-436-418-step-4-isolate-provider-and-mcp
branch
November 18, 2026 02:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Step 4 of #418. The Codex and Claude adapters still made managed-issue decisions themselves: they read the raw
managedIssuerole andmodelRolesoff the MCP session, chose the managed instructions, and decided that a"worker"loses native subagents. The MCP service also carried thepropose_issue_changehandler and three copies of the same thread-row loader.The #469 Checker also noted that
propose_issue_changetold models approvals wait "on the Issues page". The fork's page is the Roadmap (/roadmap) and upstream's is/issues.Fix
McpProviderSessionConfignow carriesorchestration: { sections, modelRoles, nativeSubagents }instead of the rawmanagedIssueandmodelRoles. It is composed outside the adapters byt3OrchestrationPolicy, which is the only place a managed role decides instructions and native subagents. The role itself comes fromIssueEligibility.managedIssueRole.additionalContextentries andnativeSubagents: falseto itsmulti_agentfeature flags. Claude maps them to its system-prompt append anddisallowedTools.propose_issue_changemoves intoRepositoryOrchestrationMcpand reuses itsassertCurrentRepositoryCaller;delegate_taskuses that same check;ManagedIssueDelegationtakes its thread loader once at construction, so the three inline copies of the loader are gone.propose_issue_changenow says approvals wait "in the issue panel". That panel holds the approval card on the Roadmap, on upstream's Issues page and in a thread's issue panel. The new wording is the same length, so the agent-context budget is unchanged.…</pull_request_linking>Keep issues current…). Rendering from the sections gives it the same blank line every other block has. Ordinary sessions' text is byte-identical; the budget test, which measures them, is unchanged.Native execution fixes are untouched. Writer routing is also untouched: Writers have no
linkedIssue, so they get no managed policy, as before. No schema, event or outbox change, and nothing in issue links or backfill (#455).Closes #436. Part of #418 (step 4 of 4).
Evidence
Tests changed or added (no new files):
provider/ManagedIssueDelegation.test.tsAgent/Task/TeamCreateand puts the managed block in its own paragraph. This fails on main, where the block was glued on.ProviderSessionManager.fork.test.tsOrchestratorMcpService.fork.test.tspropose_issue_changerefuses an outside client ("Issue proposals require a managed thread.") and a retired root's subtree, and never reaches the proposal service.CodexAdapterV2.fork.test.ts,CodexDeveloperInstructions.fork.test.ts,orchestrationInstructions.fork.test.tsRegistration and outside clients.
propose_issue_changekeepsMcpSchema.EnabledWhen = hiddenFromOutsideClients, and its declaration is unchanged apart from the description.McpToolAccess.toLayerrefuses to build a thread-bound tool without it. The toolkit layer builds inAgentContextBudget.test.ts,toolkits/core.test.tsandMcpHttpServer.test.ts, all of which pass. The existing outside-client cases inMcpToolAccess.test.tspass.Result-read acknowledgement. The read path (
pageIncludesTerminalTaskResult) is untouched. Its truncated-read and direct-read acknowledgement cases inOrchestratorMcpToolkit.integration.fork.test.tsand the base integration test pass. No new case was added, because nothing in that path changed.Runs (
agent-heavy, Node from vite-plus fallback-bin):toolkits/core, McpToolAccess, McpHttpServer, IssueEligibility.delegate_taskto Codex's direct-only tools.vp run check:changed:apps/mobile(ComposerCommandPopover.tsx,projectIcon.ts,asset-url-state.ts). That predates this branch: mobile does not import provider-core, and this PR changes nothing in mobile, contracts or client-runtime.apps/serverandprovider-coretypecheck clean.mcp-tool-use --context: 104 tools, tool descriptions 28473 chars, unchanged because the new wording is the same length;--dry-run --cases mcp-tool-use/cases/issue-blockers.ndjson: all 4 requests built;AgentContextBudgetpasses against the committed budget with no change.Integration pass. Isolated dev server in this worktree's
.t3with seeding off, using the free Replay provider and the in-app browser. The browser tab was hidden, so it produced no screenshot frames; I read state from the page DOM and thet3 thread showCLI instead.thread starton Replay; the turn completes and renders.delivery: "queued"and ran after it.questionreplay waited (--waitexit 2). Answered "Strict schemas" in the UI; the turn completed with the answer shown.interrupted.completed.DelegatedCompletionDelivery.fork.test.ts.The dev server was stopped by its PIDs at the end, and the browser tab was closed.
Footprint
Whole-file numstat against the plan pin
7d32075e37(fork totals, not issue-only counts):a93975b795) +/−Adapters/CodexAdapterV2.tsAdapters/ClaudeAdapterV2.tsmcp/OrchestratorMcpService.tsorchestration-v2/Orchestrator.tsEffectWorker.tsProjectionStore.tsAgainst the newest sync base
b387e3a179: Codex 477/124 → 471/124, Claude 365/44 → 363/44, MCP 373/203 → 333/203; the others are unchanged.Residual-hunk ledger
Codex adapter. Managed-policy hunks left, all protocol translation of the composed policy:
buildCodexTurnStartParamstakesorchestrationand passes it tobuildCodexAdditionalContext;codexThreadRuntimeParamsmapsnativeSubagents: falsetofeatures.multi_agent{,_v2}: false;startNativeTurnforwardssession.orchestration.Its other fork hunks are not managed policy and stay: approval prompts, plan artifacts, native-child metadata, command output, stop/release handling, Cyber Access and usage-limit failure mapping.
Claude adapter. Managed-policy hunks left, all protocol translation:
makeClaudeQueryOptionstakesorchestrationand renders it witht3OrchestrationText;claudeMcpQueryOverridesmapsnativeSubagents: falsetodisallowedTools;disallowedToolsand the policy's sections;Its other fork hunks stay: native and background ownership, output paths, question, cancellation and wake attachment, monitors and goals.
OrchestratorMcpService. Issue hunks indelegate_taskare one-line calls intoManagedIssueDelegation:resolveIssue,startWorker,linkUnmanagedandwithQueueNote;assertCurrentRepositoryCaller;linkedIssuegates: the workspace is chosen by issue work, the command carriesissue, and the workspace-preparation listener is skipped.The repository methods arrive as
...repositoryMcp.methods. Its remaining fork hunks are not issue policy and stay:delegateTaskTargetpolicy);repositoryTarget.Orchestrator.ts,EffectWorker.ts,ProjectionStore.ts. Unchanged by this step. What remains is listed in the step 1 to 3 ledgers: the cohort-owner accessor and the null-parentRunIdbranches, the typed issue-effect hooks, and the issue reads.Outside the six tracked files:
ProviderSessionManager.syncModelRolescomposes the session policy (span name kept);IssueEligibility.managedIssueRoleowns the role decision;provider-core/orchestrationInstructionsowns the composer and the text.Merge Danger
Door: two-way. No migration and no persisted-format change. The MCP session config is in-memory and rebuilt on each prepare.
Blast radius:
propose_issue_changerouting.Live userdata was not read or copied. The dev server ran on this worktree's own state and was stopped.
Implemented with Claude Opus 5.5 through the Claude Code harness in T3 Code.
🤖 Generated with Claude Code