Skip to content

Unify owned services with branded interfaces - #8153

Closed
tim-smart wants to merge 3 commits into
mainfrom
agent/bob/9e3ebedbad8e
Closed

tim-smart wants to merge 3 commits into
mainfrom
agent/bob/9e3ebedbad8e

Conversation

@tim-smart

@tim-smart tim-smart commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Migrates 124 owned service declarations to same-name interfaces and Context.Service values with TypeIds, making the implementation type directly nameable. For migrated exports, use Foo instead of Foo["Service"] or typeof Foo.Service; module constructors supply the marker, and manual implementations must include it.

Preserves runtime service-key strings, static helpers, and both class and const forms of the Context.Service API. Updates constructors, implementation annotations, usage examples, migration guidance, and a changeset. AI config markers are stripped before provider request serialization.

Test follow-up is complete: mocks carry the required markers, implementation type projections use the service interfaces, and the Fixtures and Configuration assertions expect the markers. The follow-up commit changes only 40 test/helper files. Existing class services and dedicated const-support cases are preserved.

The 53 retained declarations below still need acceptance or resolution before merge.

Validation

  • Full pnpm check and pnpm lint-fix passed.
  • Affected runtime tests, including Context/Layer and MCP helper consumers: 1,329 passed, 44 skipped across 43 files.
  • Context type tests passed under TypeScript 5.9.3 and 6.0.3 (4 tests, 6 assertions).
  • PostgreSQL persistence and cluster integration tests were attempted with their enable flags, but global setup could not find a working container runtime. These require a container-enabled runner.
  • Prior implementation validation: production/example project type-check, public JSDoc checks, and all 637 executable snippets passed.
  • Migration reference regenerated against committed implementation 64d1ca5. Its check still fails on 14 API groups with TODOs already present in the base document; no new TODOs remain from this migration.
53 retained declarations requiring review

Retained declarations requiring scope/design review

These declarations still use class syntax. Primitive and union values cannot be directly represented by branded interfaces without changing their shape. Adding markers to borrowed native objects, callbacks, schemas, and metadata requires a policy for identity, frozen values, and serialization. The generic HttpApiMiddleware.Service implementation is constructor API machinery and remains unchanged. Do not merge this as a claim that the full repository-wide scope is complete until these exceptions are accepted or resolved.

  • ai-docs/src/51_http-server/fixtures/api/Authorization.ts:5: CurrentUser stores User.
  • packages/opentelemetry/src/OtelTracer.ts:46: OtelTracer stores Otel.Tracer.
  • packages/opentelemetry/src/OtelTracer.ts:57: OtelTracerProvider stores Otel.TracerProvider.
  • packages/opentelemetry/src/OtelTracer.ts:68: OtelTraceFlags stores Otel.TraceFlags.
  • packages/opentelemetry/src/OtelTracer.ts:79: OtelTraceState stores Otel.TraceState.
  • packages/opentelemetry/src/OtelTracer.ts:517: OtelParentSpanContext stores Otel.SpanContext.
  • packages/opentelemetry/src/OtelLogger.ts:36: OtelLoggerProvider stores Otel.LoggerProvider.
  • packages/opentelemetry/src/Resource.ts:34: Resource stores Resources.Resource.
  • packages/platform/browser/src/IndexedDbQueryBuilder.ts:730: IndexedDbTransaction stores globalThis.IDBTransaction.
  • packages/platform/browser/src/BrowserHttpClient.ts:119: XMLHttpRequest stores LazyArg<globalThis.XMLHttpRequest>.
  • packages/platform/node-shared/src/NodeSocketServer.ts:56: IncomingMessage stores Http.IncomingMessage.
  • packages/platform/node-shared/src/NodeSocket.ts:43: NetSocket stores Net.Socket.
  • packages/platform/deno/src/DenoSocket.ts:51: Conn stores Deno.Conn.
  • packages/platform/node/src/NodeHttpClient.ts:89: Dispatcher stores Undici.Dispatcher.
  • packages/effect/src/unstable/httpapi/HttpApiMiddleware.ts:363: Service stores any.
  • packages/effect/src/unstable/httpapi/HttpApi.ts:335: AdditionalSchemas stores ReadonlyArray<Schema.Constraint>.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:41: Identifier stores string.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:49: Title stores string.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:57: Version stores string.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:65: Description stores string.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:73: License stores OpenAPISpecLicense.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:81: ExternalDocs stores OpenAPISpecExternalDocs.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:91: Servers stores ReadonlyArray<OpenAPISpecServer>.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:101: Format stores string.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:109: Summary stores string.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:117: Deprecated stores boolean.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:125: Override stores Record<string, unknown>.
  • packages/effect/src/unstable/httpapi/OpenApi.ts:154: Transform stores (openApiSpec: Record<string, any>) => Record<string, any>.
  • packages/effect/src/unstable/ai/McpSchema.ts:3036: EnabledWhen stores Predicate.Predicate<typeof Initialize.payloadSchema.Type>.
  • packages/effect/src/unstable/ai/Telemetry.ts:540: CurrentSpanTransformer stores SpanTransformer.
  • packages/effect/src/unstable/cluster/EntityResource.ts:72: CloseScope stores Scope.Scope.
  • packages/effect/src/unstable/cluster/K8sHttpClient.ts:30: K8sHttpClient stores HttpClient.HttpClient.
  • packages/effect/src/unstable/cluster/Entity.ts:475: CurrentAddress stores EntityAddress.
  • packages/effect/src/unstable/cluster/Entity.ts:491: CurrentRunnerAddress stores RunnerAddress.
  • packages/effect/src/unstable/cluster/Entity.ts:783: KeepAliveLatch stores Latch.Latch.
  • packages/effect/src/unstable/cluster/ClusterSchema.ts:23: Abandon stores true.
  • packages/effect/src/Cause.ts:1815: StackTrace stores StackFrame.
  • packages/effect/src/Cause.ts:1837: InterruptorStackTrace stores StackFrame.
  • packages/effect/src/Tracer.ts:171: ParentSpan stores AnySpan.
  • packages/effect/src/DateTime.ts:1857: CurrentTimeZone stores TimeZone.
  • packages/effect/src/unstable/socket/Socket.ts:770: WebSocket stores WebSocketLike.
  • packages/effect/src/unstable/socket/Socket.ts:781: WebSocketConstructor stores (url: string, options?: WebSocketConstructorOptions | undefined) => WebSocketLike.
  • packages/effect/src/unstable/ai/EmbeddingModel.ts:63: Dimensions stores number.
  • packages/effect/src/unstable/ai/Tool.ts:1714: Title stores string.
  • packages/effect/src/unstable/ai/Tool.ts:1733: Meta stores Record<string, unknown>.
  • packages/effect/src/unstable/ai/Model.ts:66: ProviderName stores string.
  • packages/effect/src/unstable/ai/Model.ts:82: ModelName stores string.
  • packages/effect/src/Layer.ts:608: CurrentMemoMap stores MemoMap.
  • packages/effect/src/unstable/rpc/RpcSchema.ts:92: ClientAbort stores true.
  • packages/effect/src/unstable/rpc/RpcWorker.ts:27: InitialMessage stores Effect.Effect< readonly [ data: unknown, transfers: ReadonlyArray<Transferable> ] >.
  • packages/effect/src/unstable/http/FetchHttpClient.ts:49: RequestInit stores globalThis.RequestInit.
  • packages/effect/src/unstable/http/HttpServerError.ts:255: ClientAbort stores true.
  • packages/effect/src/unstable/http/HttpServerRequest.ts:132: ParsedSearchParams stores ReadonlyRecord<string, string | Array<string>>.

Closes EFF-1329

@changeset-bot

changeset-bot Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 58ceb71

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@effect/ai-anthropic Patch
@effect/ai-openai Patch
@effect/ai-openai-compat Patch
@effect/ai-openrouter Patch
@effect/docgen Patch
@effect/openapi-generator Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node Patch
@effect/platform-node-shared Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/doctest Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tim-smart tim-smart closed this Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 34.16 KB 34.16 KB 0.00 KB (0.00%)
basic.ts 6.87 KB 6.87 KB 0.00 KB (0.00%)
batching.ts 9.95 KB 9.95 KB 0.00 KB (0.00%)
brand.ts 6.45 KB 6.45 KB 0.00 KB (0.00%)
cache.ts 10.77 KB 10.77 KB 0.00 KB (0.00%)
config.ts 21.43 KB 21.43 KB 0.00 KB (0.00%)
differ.ts 20.23 KB 20.23 KB 0.00 KB (0.00%)
http-client.ts 21.93 KB 21.93 KB 0.00 KB (0.00%)
http-router.ts 33.39 KB 33.39 KB +0.00 KB (+0.01%)
logger.ts 10.88 KB 10.88 KB 0.00 KB (0.00%)
metric.ts 9.02 KB 9.02 KB 0.00 KB (0.00%)
optic.ts 6.70 KB 6.70 KB 0.00 KB (0.00%)
pubsub.ts 15.10 KB 15.10 KB 0.00 KB (0.00%)
queue.ts 11.85 KB 11.85 KB 0.00 KB (0.00%)
schedule.ts 10.96 KB 10.96 KB 0.00 KB (0.00%)
schema-binary.ts 39.42 KB 39.42 KB 0.00 KB (0.00%)
schema-class.ts 19.98 KB 19.98 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.47 KB 30.47 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 26.25 KB 26.25 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.60 KB 13.60 KB 0.00 KB (0.00%)
schema-string.ts 11.08 KB 11.08 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.36 KB 15.36 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 33.70 KB 33.70 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.51 KB 24.51 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.18 KB 19.18 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 19.32 KB 19.32 KB 0.00 KB (0.00%)
schema-toFormatter.ts 19.43 KB 19.43 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 23.69 KB 23.69 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.48 KB 19.48 KB 0.00 KB (0.00%)
schema.ts 19.18 KB 19.18 KB 0.00 KB (0.00%)
stm.ts 12.80 KB 12.80 KB +0.01 KB (+0.04%)
stream.ts 9.83 KB 9.83 KB 0.00 KB (0.00%)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant