Skip to content

refactor(server): import Effect services as namespaces - #14385

Merged
juliusmarminge merged 6 commits into
t3code/codex-turn-mappingfrom
v2/ns-imports-server
Sep 30, 2026
Merged

juliusmarminge merged 6 commits into
t3code/codex-turn-mappingfrom
v2/ns-imports-server

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Local Effect service modules are imported as namespaces (import * as ProjectService from "./ProjectService.ts", then ProjectService.ProjectService / ProjectService.layer / ProjectService.make), never as named or aliased tags and layers. This PR applies that rule to apps/server outside src/orchestration-v2/: provider, mcp, project, persistence, pullRequest, scheduledTasks, device, scheduling, relay, git, the src/ root (ws.ts, server.ts, …), integration/, scripts/, and the other src/ directories that took ServerConfig/ServerSettingsService tags by name.

The change covers imports and call sites only, with no behavior change. It was done with a TypeScript-checker codemod, so every rewritten reference resolves to the same symbol. When a file needed the tag and also a helper, error or type from the same module, everything now goes through the one namespace, so no module is imported both ways. config.ts becomes ServerConfig and serverSettings.ts becomes ServerSettings. Three files already bind ServerSettings to the contracts schema, so they use Settings, which follows the existing precedent in storageCleanup.ts. The deprecated static ServerConfig.layerTest / ServerSettingsService.layerTest accessors are replaced with the module-level layerTest in files this PR already touches.

Audit counts (ns-audit.py, apps/server minus src/orchestration-v2/)

files imports
before (base 8297ccf85d) 135 322
after 5 8

The 5 remaining files are left alone on purpose, because open PRs are changing them:

  • src/provider/Drivers/OpenCodeDriver.ts: { ServerConfig }, { ServerSettingsService }, { OpenCodeRuntime }
  • src/provider/Drivers/CodexManagedProvider.ts: { ServerSettingsService }
  • src/provider/Layers/OpenCodeProvider.ts: { OpenCodeRuntime }
  • src/provider/ModelManifest.ts: { ServerConfig }
  • src/provider/Layers/OpenCodeProvider.test.ts: { ServerConfig }, { OpenCodeRuntime }. This file is not on the protected list, but the OpenCode 2 stack (feat(server): detect OpenCode 1.x or 2.x per instance and route by it #14239 and above) edits its import block.

A grep for layer as , make as and Live as in this area now finds nothing. The remaining named imports from service modules are pure helpers (for example makeLinuxCgroupController from AcpSessionRuntime.ts, and makeClaudeQueryOptions in a script), which the convention allows.

Follow-ups (not in this PR)

Non-canonical export names are still referenced through namespaces here. Renaming any of them touches files in open PRs (#5589, #9376, #9635 for the Cursor/Codex/Antigravity ones), so they are left for later:

  • provider/Layers/CursorSdkCatalog.ts: CursorSdkCatalogLive, makeCursorSdkCatalog, makeCursorSdkCatalogTestLayer (should be layer / make / a test layer)
  • provider/CodexInstallation.ts, provider/AntigravityInstallation.ts: makeCodexInstallation, makeAntigravityInstallation, and the layer exposed only as a static Tag.layer with no module-level layer, so call sites read CodexInstallation.CodexInstallation.layer
  • provider/acp/AcpRegistryRuntimeCoordinator.ts: the layer is module-private and exposed only through static get layer()
  • provider/acp/AcpRegistrySupport.ts: makeAcpRegistryCatalog. The AcpRegistryCatalog tag lives in a support module and is not named for it.
  • provider/opencodeRuntime.ts (protected): OpenCodeRuntimeLive
  • persistence/Layers/Sqlite.ts: layerConfig, makeSqlitePersistenceLive, SqlitePersistenceMemory
  • device/DeviceService.ts: makeWithHosts
  • orchestration-v2 exports used from here: claudeAgentSdkQueryRunnerLiveLayer, codexAppServerClientFactoryFromSettingsLayer, cursorAgentSdkRunnerLiveLayer, UsageLimitRecoveryWorker.workerLive, ProviderAdapterRegistry.makeLayer / layerFromProviderInstanceRegistry
  • Layer-only modules that export *Live / *Layer names without a service tag (runtimeLayer.ts, http.ts route layers, ProviderRegistry.ts / ProviderInstanceRegistryHydration.ts / AcpRegistryCatalog.ts under provider/Layers/, MCP toolkit *HandlersLive). The audit doesn't cover these, and they belong with the export-rename follow-up.
  • Structural: provider/Services/* hold the tags while provider/Layers/* hold the implementations, and persistence/Services + persistence/Layers are split the same way. So one service is spread over two modules, against the one-module-per-service convention.
  • Deprecated static layerTest accessors on ServerConfig and ServerSettingsService are still used by files outside this PR (assets, checkpointing, telemetry, textGeneration, workspace tests).

Verification

  • cd apps/server && vp exec tsc --noEmit -p .: exit 0, no error TS / warning TS.
  • vp test run on the tests for every touched file, plus ProviderRegistry.test.ts, ProviderInstanceRegistryLive.test.ts, all src/mcp/** tests, ws.test.ts, cli/project.test.ts, and the serverRuntimeStartup/serverLifecycleEvents/serverRuntimeState/serverSettings tests: 103 files, 1359 tests passed. No server.test.ts exists on V2. server.ts layer wiring is covered by tsc, since a missing provide fails the requirements type.
  • vp lint on the 139 touched files: exit 0. The warning set is identical to base (16 pre-existing, 0 new).
  • vp run knip:check: exit 0.
  • Not run: repo-wide vp check, -r test/typecheck, live provider tests (*.live.test.ts).

Model: Claude Opus 5.5 (Claude Code)

🤖 Generated with Claude Code


Devin Review

juliusmarminge and others added 6 commits September 30, 2026 00:48
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…t, git, device, scheduling and relay modules

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…and remaining modules

Covers the src/ root (ws.ts, server.ts and others), integration/, scripts/, and the remaining src directories whose only violations were tag imports of ServerConfig and ServerSettingsService.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Sep 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline 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.7 KiB — 4.9 KiB ✅
Codex Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Codex Live turn WebSocket decoded — 20.4 KiB — 29.3 KiB ✅
Codex Live turn messages — 2 — 8 ✅
Claude Total thread wire — 4.9 KiB — 6.8 KiB ✅
Claude Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Claude Live turn WebSocket decoded — 20.8 KiB — 29.3 KiB ✅
Claude Live turn messages — 2 — 8 ✅

Baseline: unavailable · PR result: b55c469 · Source CI: success

Scenario 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: 106.1 KiB
  • Claude decoded thread snapshot: 106.4 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@macroscopeapp

macroscopeapp Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This is a large but predominantly mechanical namespace-import refactor with no intended behavior or default changes. Human review is still required because the diff includes authentication/security-related production files, which are treated as sensitive regardless of the narrowness of the edits.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge
juliusmarminge merged commit 16d72f4 into t3code/codex-turn-mapping Sep 30, 2026
23 of 24 checks passed
@juliusmarminge
juliusmarminge deleted the v2/ns-imports-server branch September 30, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant