refactor(provider-core): follow the Effect service conventions throughout #17427
t3/provider-model-catalog fromrefs/pull/17427/head·merged by juliusmarminge View on GitHubThe first part of a full audit of the provider packages against docs/internals/effect-services.md. This PR covers provider-core and the places that consume it.
Shape interfaces
IdAllocatorV2,ProviderAdapterV2, andProviderHostnow define their interface inline. Consumers useX["Service"], about 90 references across the packages and the server.IdAllocatorV2's sub-records are renamedIdAllocatorV2AllocateandIdAllocatorV2Derive.
Module names and keys
continuationRequestsbecomesProviderContinuationRequests, since it defines aContext.Reference. Its key changes to match.ProviderAuthFlowbecomesproviderAuthFlow, since it defines no service.
Namespace imports
- Every import from a provider-core service module is now a namespace import. That covers
IdAllocator,ProviderAdapter,ProviderHost,ProviderEventLoggers,ProviderContinuationRequests, andModelCatalog. - This PR only touches imports of these provider-core modules. Imports between server modules are left alone.
Services come from the environment
makeProviderSnapshotSettingsSourcenow yieldsProviderHostinstead of takinghost.settings. Its 8 driver call sites are updated.IdAllocator.deriveis now a top-level pure export that the layer reuses. The failure and retry turn-item helpers use it and drop theiridAllocatorparameter.
No re-export shims
- The server's
ProviderEventLoggers.tsre-exported the core tag next to its own layer. The module is gone:server.tsbuilds the layer inline (its only consumer), and everything else imports the tag from provider-core.
Not in this PR: the per-package findings and the module-level state, such as the MCP session map, the version cache, Cursor's SDK guard and keychain singleton, and the OpenCode message-id counter. Those come next as their own layers.
Verification: typecheck is clean across provider-core, all eight provider packages, and the server. 1280 tests pass across the provider packages, provider drivers and registry, session manager, and orchestrator replay fixtures. knip and lint pass.
Done by Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
juliusmarminge added labelsmacroscope-review
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
ℹ️ No successful
mainbaseline artifact is available yet. This run establishes the initial measurement.Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire — 4.9 KiB — 6.8 KiB ✅ Codex Thread snapshot wire — 3.8 KiB — 4.9 KiB ✅ Codex Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅ Codex Live turn WebSocket decoded — 20.8 KiB — 29.3 KiB ✅ Codex Live turn messages — 1 — 8 ✅ Claude Total thread wire — 5.0 KiB — 6.8 KiB ✅ Claude Thread snapshot wire — 3.8 KiB — 4.9 KiB ✅ Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅ Claude Live turn WebSocket decoded — 21.2 KiB — 29.3 KiB ✅ Claude Live turn messages — 2 — 8 ✅ Baseline: unavailable · PR result:
ffd407b· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
0bf15e23-ab97-46d8-b0cc-453194c85972
📥 Commits
Reviewing files that changed from the base of the PR and between 3c9e8320dc0498619ada4b85bb69d0d4aff83f8c and 7e295976b4799781036472d9821256b94f4af2c6.
📒 Files selected for processing (107)
apps/server/scripts/record-claude-agent-sdk-replay-fixture.tsapps/server/scripts/record-grok-acp-replay-fixture.tsapps/server/src/mcp/McpToolAccess.race.test.tsapps/server/src/mcp/OrchestratorMcpService.test.tsapps/server/src/mcp/OrchestratorMcpToolkit.integration.test.tsapps/server/src/mcpApps/McpAppRequests.test.tsapps/server/src/mcpApps/McpAppRequests.tsapps/server/src/orchestration-v2/AcpRegistryOrchestratorV2.live.test.tsapps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.tsapps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/CodexAdapterV2.testkit.tsapps/server/src/orchestration-v2/Adapters/CodexAdapterV2.tsapps/server/src/orchestration-v2/Adapters/CursorAdapterV2.testkit.tsapps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.tsapps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.tsapps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/OpenCodeAdapterV2.testkit.tsapps/server/src/orchestration-v2/BackgroundWorkStop.integration.test.tsapps/server/src/orchestration-v2/CheckpointCaptureService.tsapps/server/src/orchestration-v2/CheckpointRollbackService.test.tsapps/server/src/orchestration-v2/CheckpointRollbackService.tsapps/server/src/orchestration-v2/CheckpointService.tsapps/server/src/orchestration-v2/ContextHandoffBudget.test.tsapps/server/src/orchestration-v2/ContextHandoffDelivery.tsapps/server/src/orchestration-v2/CursorOrchestratorV2.live.test.tsapps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.tsapps/server/src/orchestration-v2/DispatchModeLimit.test.tsapps/server/src/orchestration-v2/GrokOrchestratorV2.live.test.tsapps/server/src/orchestration-v2/OpenCode2OrchestratorV2.live.test.tsapps/server/src/orchestration-v2/Orchestrator.control-reads.test.tsapps/server/src/orchestration-v2/Orchestrator.tsapps/server/src/orchestration-v2/ProviderAdapterRegistry.test.tsapps/server/src/orchestration-v2/ProviderAdapterRegistry.tsapps/server/src/orchestration-v2/ProviderContinuationService.test.tsapps/server/src/orchestration-v2/ProviderContinuationService.tsapps/server/src/orchestration-v2/ProviderEventIngestor.tsapps/server/src/orchestration-v2/ProviderSessionManager.test.tsapps/server/src/orchestration-v2/ProviderSessionManager.tsapps/server/src/orchestration-v2/ProviderSwitchService.test.tsapps/server/src/orchestration-v2/ProviderTurnControlService.test.tsapps/server/src/orchestration-v2/ProviderTurnStartService.test.tsapps/server/src/orchestration-v2/ProviderTurnStartService.tsapps/server/src/orchestration-v2/RunExecutionService.test.tsapps/server/src/orchestration-v2/RunExecutionService.tsapps/server/src/orchestration-v2/RuntimePolicy.tsapps/server/src/orchestration-v2/RuntimeRequestService.test.tsapps/server/src/orchestration-v2/SelectionRestart.integration.test.tsapps/server/src/orchestration-v2/SteeringCompletion.integration.test.tsapps/server/src/orchestration-v2/ThreadDeletion.tsapps/server/src/orchestration-v2/ThreadFork.execution.test.tsapps/server/src/orchestration-v2/ThreadLaunchService.test.tsapps/server/src/orchestration-v2/ThreadStop.test.tsapps/server/src/orchestration-v2/ThreadTitleRegenerationService.test.tsapps/server/src/orchestration-v2/assistantStreaming.test.tsapps/server/src/orchestration-v2/assistantStreaming.tsapps/server/src/orchestration-v2/legacy/LegacyV1Cutover.integration.test.tsapps/server/src/orchestration-v2/runtimeLayer.test.tsapps/server/src/orchestration-v2/runtimeLayer.tsapps/server/src/orchestration-v2/testkit/ProviderReplayHarness.tsapps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.tsapps/server/src/provider/CodexChatGptAuth.tsapps/server/src/provider/Drivers/AntigravityDriver.test.tsapps/server/src/provider/Drivers/AntigravityDriver.tsapps/server/src/provider/Drivers/ClaudeDriver.tsapps/server/src/provider/Drivers/CodexDriver.test.tsapps/server/src/provider/Drivers/CodexDriver.tsapps/server/src/provider/Drivers/CodexManagedProvider.tsapps/server/src/provider/EventNdjsonLogger.tsapps/server/src/provider/ProviderEventLoggersLive.tsapps/server/src/provider/ProviderHostLive.tsapps/server/src/provider/ProviderInstanceRegistry.test.tsapps/server/src/provider/ProviderInstanceRegistryHydration.tsapps/server/src/provider/ProviderOrchestrationAdapterInfrastructure.tsapps/server/src/provider/ProviderRegistry.test.tsapps/server/src/server.tspackages/provider-acp-registry/src/server/auth.tspackages/provider-acp-registry/src/server/driver.tspackages/provider-acp/src/server/adapter.tspackages/provider-core/package.jsonpackages/provider-core/src/server/IdAllocator.tspackages/provider-core/src/server/ProviderAdapter.tspackages/provider-core/src/server/ProviderContinuationRequests.tspackages/provider-core/src/server/ProviderHost.tspackages/provider-core/src/server/adapterDriver.tspackages/provider-core/src/server/driver.tspackages/provider-core/src/server/failure.tspackages/provider-core/src/server/providerAuthFlow.test.tspackages/provider-core/src/server/providerAuthFlow.tspackages/provider-core/src/server/snapshotSettings.tspackages/provider-cursor/src/server/adapter.tspackages/provider-cursor/src/server/driver.tspackages/provider-grok/src/server/adapter.tspackages/provider-grok/src/server/driver.tspackages/provider-muse/src/server/adapter.test.tspackages/provider-muse/src/server/adapter.tspackages/provider-muse/src/server/driver.tspackages/provider-opencode/src/server/adapter.tspackages/provider-opencode/src/server/driver.tspackages/provider-opencode/src/server/v2/adapter.tspackages/provider-pi/src/server/adapter.test.tspackages/provider-pi/src/server/adapter.tspackages/provider-pi/src/server/driver.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough#
This pull request aligns provider-core service types and package entry points across server and provider packages. It updates snapshot-settings access and failure-item ID allocation. Adapter behavior and test scenarios are otherwise unchanged.
Changes#
Provider-core API alignment
Layer / File(s) Summary Service contracts and provider-core exports
packages/provider-core/src/server/IdAllocator.ts,packages/provider-core/src/server/ProviderAdapter.ts,packages/provider-core/src/server/ProviderHost.ts,packages/provider-core/src/server/adapterDriver.ts,packages/provider-core/src/server/driver.ts,packages/provider-core/package.jsonService shapes are now declared through their service types. The ProviderAdapterV2Shapeand allocator shape aliases were removed. Provider-core exports now use theProviderContinuationRequestsand lowercaseproviderAuthFlowentry points.Snapshot settings and failure-item ID allocation
packages/provider-core/src/server/snapshotSettings.ts,packages/provider-core/src/server/failure.ts,apps/server/src/provider/Drivers/*,packages/provider-*/src/server/driver.ts,apps/server/src/orchestration-v2/Adapters/*Snapshot settings are now provided by an Effect that reads settings from ProviderHost. Failure and retry turn-item helpers now derive IDs throughIdAllocatorand no longer accept an allocator input. Related callers were updated.Server and provider API migration
apps/server/src/orchestration-v2/*,apps/server/src/mcp/*,apps/server/src/mcpApps/*,apps/server/src/provider/*,packages/provider-*/src/server/*,apps/server/scripts/*Provider adapter, allocator, event-logger, host, and continuation-request references now use the provider-core namespaces and service types. Tests and recording scripts use the updated references; their scenarios and assertions remain unchanged. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Refactor
Merge Risk: ⚪ Minimal · up to
7e295No concrete issue remains that would prevent merging after normal checks.
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Description check The description explains the changes, out-of-scope work, verification results, and agent usage. It does not provide the required Problem and Scope and approval sections, and it does not include an iss… Add the required Problem, Change, Scope and approval, and Verification headings. Describe the underlying problem and expected behavior. Provide the triaged issue or explicit maintainer approval with its approval comment, or explain why this… ✅ Passed checks (3 passed)
Check name Status Explanation Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Title check The title clearly and concisely describes the provider-core refactor and follows conventional commit style.
Full details: Description check
Explanation
The description explains the changes, out-of-scope work, verification results, and agent usage. It does not provide the required Problem and Scope and approval sections, and it does not include an issue link, maintainer approval, or a focused-fix exemption rationale.
Resolution
Add the required Problem, Change, Scope and approval, and Verification headings. Describe the underlying problem and expected behavior. Provide the triaged issue or explicit maintainer approval with its approval comment, or explain why this focused change qualifies for an exemption.
- Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.juliusmarminge merged thisb66dd40
juliusmarminge closed this
Sign in to join this conversation.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This is a broad provider-core and server-wide refactor that changes shared Effect service abstractions, module/service identities, dependency acquisition, and production logger wiring across 107 files. Although the underlying logging and ID algorithms appear preserved and no product defaults or schemas change, the shared-infrastructure scope warrants human review.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).