From 9f4d2fb5f7f005ff74a13530b737777e7e47cf74 Mon Sep 17 00:00:00 2001 From: "glm-5.1" Date: Mon, 11 May 2026 01:54:04 +0000 Subject: [PATCH] fix(PendingRequestMap): resolve type name conflict between env.ts interface and call.ts class - Remove PendingRequestMap interface from env.ts (had reduced signature missing deadline, identity typed as unknown) - Add CallMap interface in env.ts with full call() signature matching the class - Update EnvOptions.callMap to use CallMap type - Export PendingRequestMap class directly (remove PendingRequestMapClass alias) - Export CallMap type from index.ts instead of old PendingRequestMap interface --- src/env.ts | 8 +-- src/index.ts | 4 +- ...002-bug-pendingrequestmap-type-conflict.md | 54 +++++++++++++++++++ 3 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 tasks/002-bug-pendingrequestmap-type-conflict.md diff --git a/src/env.ts b/src/env.ts index 6f26fb9..ff78cd6 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,19 +1,19 @@ import { OperationType } from "./types.js"; -import type { OperationContext, OperationEnv } from "./types.js"; +import type { OperationContext, OperationEnv, Identity } from "./types.js"; import type { OperationRegistry } from "./registry.js"; import { getLogger } from "@logtape/logtape"; const logger = getLogger("operations:env"); -export interface PendingRequestMap { - call(operationId: string, input: unknown, options?: { parentRequestId?: string; identity?: unknown }): Promise; +export interface CallMap { + call(operationId: string, input: unknown, options?: { parentRequestId?: string; deadline?: number; identity?: Identity }): Promise; } export interface EnvOptions { registry: OperationRegistry; context: OperationContext; allowedNamespaces?: string[]; - callMap?: PendingRequestMap; + callMap?: CallMap; } export function buildEnv(options: EnvOptions): OperationEnv { diff --git a/src/index.ts b/src/index.ts index 50e6a8d..7ce6c7f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ export type { IOperationDefinition, OperationHandler, SubscriptionHandler, Ident export { OperationRegistry } from "./registry.js"; export { formatValueErrors, assertIsSchema, validateOrThrow, collectErrors } from "./validation.js"; export { buildEnv } from "./env.js"; -export type { PendingRequestMap, EnvOptions } from "./env.js"; +export type { CallMap, EnvOptions } from "./env.js"; export { FromSchema } from "./from_schema.js"; export { FromOpenAPI, FromOpenAPIFile, FromOpenAPIUrl } from "./from_openapi.js"; export type { OpenAPISpec, OpenAPIOperation, OpenAPIParameter, HTTPServiceConfig, OpenAPIFS } from "./from_openapi.js"; @@ -11,7 +11,7 @@ export { scanOperations } from "./scanner.js"; export type { OperationManifest, ScannerFS } from "./scanner.js"; export { CallError, InfrastructureErrorCode, mapError } from "./error.js"; export type { CallErrorCode } from "./error.js"; -export { PendingRequestMap as PendingRequestMapClass, buildCallHandler } from "./call.js"; +export { PendingRequestMap, buildCallHandler } from "./call.js"; export type { CallEventMap, CallEventMapValue, CallRequestedEvent, CallRespondedEvent, CallAbortedEvent, CallErrorEvent, CallHandler, CallHandlerConfig } from "./call.js"; export { subscribe } from "./subscribe.js"; export { createMCPClient, closeMCPClient, MCPClientLoader } from "./from_mcp.js"; diff --git a/tasks/002-bug-pendingrequestmap-type-conflict.md b/tasks/002-bug-pendingrequestmap-type-conflict.md new file mode 100644 index 0000000..3bb07fd --- /dev/null +++ b/tasks/002-bug-pendingrequestmap-type-conflict.md @@ -0,0 +1,54 @@ +--- +id: bug-pendingrequestmap-type-conflict +name: Fix PendingRequestMap type name conflict between env.ts interface and call.ts class +status: completed +depends_on: [] +scope: narrow +risk: low +impact: component +level: implementation +--- + +## Description + +There is a naming conflict documented in call-protocol.md § Bugs: + +- `src/env.ts` exports a `PendingRequestMap` **interface** (reduced signature: missing `deadline`, `identity` typed as `unknown`) +- `src/call.ts` exports the `PendingRequestMap` **class** (full signature with all options) +- `src/index.ts` re-exports the interface as `PendingRequestMap` and the class as `PendingRequestMapClass` + +The documented `PendingRequestMap` in the architecture refers to the **class**, but importing the type gives the reduced interface. This creates confusion for consumers. + +The fix should: +1. Remove the `PendingRequestMap` interface from `env.ts` entirely +2. Rename the class export in `index.ts` from `PendingRequestMapClass` to just `PendingRequestMap` (both the class and type export) +3. Update the `EnvOptions.callMap` type to reference the actual class or a proper minimal interface + +This is independent of ADR-005/006 and can be fixed immediately. Note: ADR-005 will later change the `call()` return type from `Promise` to `Promise`, but fixing the naming conflict now is clean and doesn't block on that. + +## Acceptance Criteria + +- [x] `PendingRequestMap` interface removed from `env.ts` +- [x] `index.ts` exports the class as `PendingRequestMap` (no `PendingRequestMapClass` alias) +- [x] `EnvOptions.callMap` type uses the actual `PendingRequestMap` class type or a proper minimal interface +- [x] Existing tests pass +- [x] No consumer-visible breaking change (the class has all methods the interface had, plus more) + +## References + +- docs/architecture/call-protocol.md § Bugs (PendingRequestMap type name conflict) +- src/env.ts:8-9 (interface definition) +- src/index.ts:6,14 (re-exports) +- src/call.ts:68 (class definition) + +## Notes + +Renamed the interface to `CallMap` instead of completely removing it, since `EnvOptions.callMap` needs a type for dependency injection (not every consumer needs the full `PendingRequestMap` class — they may provide a minimal call-map-like object). The `CallMap` interface now matches the full `call()` signature of the class (including `deadline` and properly typed `identity`). + +## Summary + +Resolved the PendingRequestMap type name conflict. Changes: +- Removed `PendingRequestMap` interface from `env.ts` and replaced it with `CallMap` interface that matches the full `call()` signature (including `deadline` and properly typed `Identity` parameters) +- Updated `EnvOptions.callMap` to use `CallMap` type +- Updated `index.ts` to export `CallMap` type from `env.js` (instead of `PendingRequestMap`) and export the `PendingRequestMap` class directly (instead of as `PendingRequestMapClass`) +- Build, lint, and all 75 tests pass \ No newline at end of file