Skip to content

[Feature]: keep Responses fetch helpers on a transport-only import boundary #2434

Closed

Description

@Ingwannu

Area

Proxy and routing

What are you trying to accomplish?

Keep src/server/responses/fetch-helpers.ts as a true transport leaf so ordinary Responses, compact, and native-chat imports load only the code required for request pacing, upstream HTTP-version policy, and the optional Codex WebSocket transport.

What prevents this today?

The original responses.ts split in commit e7f24b952 copied the monolith import header into fetch-helpers.ts. The file now has 39 distinct runtime import specifiers even though its exports use only the WebSocket transport, request pacing, upstream HTTP-version helper, and type-only server/config declarations.

Because ESM evaluates static imports, importing safeHostLabel, providerFetch, or fetchWithHeaderTimeout currently reaches a 326-module transitive graph including bridge, config, parser, compaction, routing, combos, OAuth, web-search, vision, Codex auth/routing, retries, sidecars, logging, and relay modules. A static walk of the imports actually used by the helper reduces that graph to six modules.

This is an ownership and startup-isolation defect, not a request-behaviour feature: src/server/chat-native.ts should not pull the full routed Responses/sidecar graph merely to call a transport helper.

What should OpenCodex do?

Preserve every public helper and wire behaviour while removing stale runtime imports from fetch-helpers.ts. Add a repository regression that locks the module to a small explicit runtime-import allowlist and ignores type-only edges. Document why the helper must remain transport-only so a future mechanical extraction or copy does not recreate the eager graph.

The change must not move request logic, change pacing, alter HTTP/WebSocket selection, or modify authentication, credentials, provider routing, retries, response parsing, or sidecar behaviour.

Example usage or interface

No CLI or config change is expected. The maintained invariant should be equivalent to:

src/server/responses/fetch-helpers.ts
  runtime imports:
    ./ws-upstream
    ../../providers/request-pacing
    ../../lib/upstream-http-version
  type-only imports:
    bun
    ../../types
    ../ws-bridge

Importing safeHostLabel from src/server/chat-native.ts must continue to behave identically without eagerly evaluating unrelated Responses, combo, OAuth, web-search, or vision modules.

Alternatives or workarounds

Leaving the stale imports in place is functionally tolerated today because most imported modules avoid harmful top-level side effects, but it makes startup/import ownership depend on that accidental property and increases the surface loaded by every consumer.

Moving the helpers again would add churn without fixing the root cause. The smallest durable change is to prune the copied imports and pin the leaf boundary with a focused source-graph test.

Additional context

Checks

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.

Activity

  1. added
    enhancementNew feature or request
    proxyHTTP proxy, routing, reverse-proxy / management auth
    on Aug 23, 2026
  2. added
    account-poolOAuth, credentials, Codex pool, quota, failover, plans
    streamingSSE, WebSocket, terminal stream frames
    toolstool_calls, MCP, web-search / sidecar tools
    on Aug 23, 2026
  3. Ingwannu commented on Aug 23, 2026

    @Ingwannu
    OwnerAuthor

    Implementation is available in PR #2435 at exact head 6b197942c8354ccf0d54c341764c0b03f767ba9a, rebased onto dev@43b2e26ee.

    The change removes the stale monolith imports while preserving all public helpers, adds a strict runtime-import boundary regression, and records the transport-leaf ownership decision in structure/04_transports-and-sidecars.md.

    Verification on the exact head:

    • focused transport/timeout/pacing/HTTP-version/WebSocket suite: 58 passed, 1 skipped, 0 failed;
    • typecheck and git diff --check: passed;
    • static runtime graph: 326 modules before, 6 after;
    • repository CI: all required Linux shards, macOS, storage/API/gates, keyring, and npm-global jobs passed or were intentionally skipped.

    The PR is now ready and assigned to @lidge-jun for non-author maintainer review. I will not self-approve or self-merge it. This issue remains open until the PR lands on dev.

  4. lidge-jun commented on Aug 23, 2026

    @lidge-jun
    Owner

    리뷰 · 우선순위 40 / 80

    설명: 이 이슈는 응답 가져오기 도우미 파일이 전송만 맡는 잎이어야 하는데, 예전 큰 파일에서 복사한 import 때문에 네이티브 채팅이 도우미 하나만 불러도 응답 전체 그래프를 연다고 한다. 지금 CURRENT dev HEAD 는 43b2e26ee 이다. 이번 시간에 origin/dev 는 4f41a8e93 에서 한 칸 왔다. 새 머지는 2422 엑스에이아이 웹검색 칸 유지다. package.json 은 2.27.0 이다. src/config.ts 는 3975줄이다. src/runtime 폴더는 지금 HEAD 에 없다. 작성자가 적은 커밋 4f41a8e93 은 바로 전 HEAD 다. 2422 는 가져오기 도우미를 안 만졌다. 내가 지금 HEAD 를 열어 보니 그 복사 import 가 그대로다.

    지금 HEAD 의 src/server/responses/fetch-helpers.ts 는 232줄이다. 실제로 쓰는 런타임 의존은 웹소켓 전송, 제공자 속도 조절, 업스트림 에이치티티피 버전 세 칸이다. 그런데 8줄부터 브리지, 설정, 파서, 압축, 라우터, 콤보, 오오스, 웹검색, 비전, 사이드카, 로그, 릴레이를 런타임으로 불러온다. 런타임 import 칸은 39개다. 타입만 필요한 칸도 값 import 로 적혀 있다. 이 파일의 공개 함수는 타임아웃 끄기, 호스트 라벨, 출처 라벨, 제공자 가져오기, 헤더 타임아웃 가져오기다. 그 함수 몸은 라우팅이나 콤보를 안 부른다. src/server/chat-native.ts 34줄은 그 라벨과 가져오기만 쓴다. 그래도 모듈을 여는 순간 복사된 import 가 먼저 실행된다.

    작성자는 지금 그래프가 326 모듈이고, 쓰는 import 만 남기면 6 모듈이라고 적었다. 나는 326 을 다시 세지는 않았다. 지금 HEAD 헤더가 전송이 안 쓰는 모듈을 불러오는 것은 확인했다. 원래 쪼개기 커밋이 큰 파일 헤더를 이 잎에 그대로 복사했다고 한다. 그래서 네이티브 채팅과 압축 경로가 전송 도우미만 필요해도 응답 라우팅 그래프를 같이 연다. 대부분은 맨 위 부수 효과가 약해서 지금은 참아지고 있다. 그래도 시작 소유가 우연에 기대게 된다.

    이건 요청 동작을 바꾸라는 이슈가 아니다. 인증, 자격 증명, 제공자 고르기, 재시도, 본문 파싱, 사이드카는 손대지 말라고 적혀 있다. 2378 2379 2392 는 설정과 프로세스와 인증 에러 소유라서 이 전송 잎과 겹치지 않는다. 고치는 풀 리퀘스트 2435 가 준비 상태로 올라왔다. 두 번째 커밋 5abf0d6fe 가 경계 시험을 더 굳혔다. 착지 전에는 이 이슈를 닫지 않는다. 2426 은 코덱스 웹소켓 나가는 크기 가드다. 이 이슈만으로 닫지 않는다. 2431 의 빈 에스에스와 410 구멍도 다른 길이다. 2433 은 그 콤보 구멍을 고치는 준비된 풀 리퀘스트인데 이번 시간에 착지하지 않았다.

    사용자 길이로는 네이티브 채팅이 전송 도우미만 쓰려고도 응답 전체 그래프를 불러오는 소유 구멍이라서 40. 카탈로그 팁은 Ox Alpha x-preview-f-free + deepseek-v4-flash-vision-exp. Cursor 정적 카탈로그는 opus-4-8-fast / opus-5-fast. 2334 CursorCredentialRouter 는 여전히 src/providers/cursor-pool.ts 모듈+테스트만 있고 어댑터에 연결되지 않았다. 2332 H2 는 discovery 전용. 2320 overflow + 2342 는 이미 dev. 2188 사이드카는 이미 dev. 2382 데스크톱 앱 재시작은 이미 dev. 2292 는 아직 연다.

    src/server/responses/fetch-helpers.ts 라인 8 - 지금 HEAD 는 브리지 모듈을 런타임으로 연다. 공개 도우미는 브리지를 안 쓴다
    src/server/responses/fetch-helpers.ts 라인 18 - routeModel 도 불러온다. 전송 도우미는 라우팅을 안 쓴다
    src/server/responses/fetch-helpers.ts 라인 105 - 실제로 쓰는 런타임은 속도 조절과 에이치티티피 버전과 웹소켓 전송이다
    src/server/chat-native.ts 라인 34 - 네이티브 채팅이 호스트 라벨과 가져오기만 쓰려고도 이 파일을 연다
    src/server/responses/ws-upstream.ts 라인 82 - 2426 나가는 크기 가드는 이 이슈 범위가 아니다. 지금 HEAD 에도 그대로다
    PR 2435 - 고치는 준비된 풀 리퀘스트다. 착지 전에는 이 이슈를 닫지 않는다
    이슈 2378 2379 2392 - 설정과 프로세스와 인증 에러 소유다. 이 이슈만으로 닫지 않는다

    메인테이너의 판단이 필요한 지점

    • 2435 가 착지하면 이 이슈를 그 PR 로 닫을지. 지금은 열어 두는 편이 맞다
    • 소스 스캐너 경계 시험만으로 잎을 잠글지, 실제 모듈 그래프 시험이 필요할지
    • 2426 웹소켓 크기 가드를 이 잎 정리에 섞지 말 것. 길이 다르다
    • 2431 콤보 빈 에스에스와 410 도 이 이슈로 묶지 말 것

    너의 추천
    이슈는 열어 둔다. 2435 가 착지하면 그 PR 로 닫는다. 공개 도우미와 요청 동작은 그대로 둔다. 복사한 런타임 import 만 걷어 낸다. 2426 과 2431 과 2210 은 닫지 않는다. 호출 길을 넓히지 말 것. 라벨은 그대로 둔다. 프리뷰 배포가 아니다.

    이 댓글은 grok-bot이 작성했습니다

  5. Ingwannu commented on Aug 23, 2026

    @Ingwannu
    OwnerAuthor

    Implementation PR #2435 is now rebased onto current dev at exact head c64431f. The transport-only import boundary remains behavior-preserving and documented with a Decision Log. Pinned Bun 1.4.0 focused verification is 58 passed / 1 skipped / 0 failed; typecheck and diff check pass. Fresh exact-head CI is running, and the issue will stay open until independent review and landing.

  6. Ingwannu commented on Aug 23, 2026

    @Ingwannu
    OwnerAuthor

    Final exact-head CI completed successfully for PR #2435 at be6ea98 after the last rebase onto dev@bf8bcfd3c.

    All Linux shards, macOS, storage/API/gates, keyring, npm-global, hygiene, target, and aggregate CI checks passed or were intentionally skipped. Local pinned Bun 1.4.0 verification remains 58 passed / 1 skipped / 0 failed, with typecheck and diff check passing.

    The issue remains open and the PR remains unmerged until independent maintainer approval.

  7. lidge-jun commented on Aug 23, 2026

    @lidge-jun
    Owner

    Closed by #2435, squash-merged to dev as 4fb0fbe.

    src/server/responses/fetch-helpers.ts now carries only transport-level imports, and the regression at tests/responses-fetch-helpers-boundary.test.ts:43 pins the three permitted runtime edges while rejecting computed dynamic-import bypasses. Independent review confirmed the export surface is complete and the helper bodies are byte-identical, with no cycle and no change to routing, logging, or credential handling. Six focused suites ran 71 pass / 1 skip / 0 fail, and exact-head CI was green.

    Closing by hand because PRs here target dev.

  8. lidge-jun commented on Aug 23, 2026

    @lidge-jun
    Owner

    Landed via #2435 at 4fb0fbe

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    account-poolOAuth, credentials, Codex pool, quota, failover, plansenhancementNew feature or requestlanded-via-maintainerOriginal PR closed after landing via a maintainer merge trainproxyHTTP proxy, routing, reverse-proxy / management authstreamingSSE, WebSocket, terminal stream framestoolstool_calls, MCP, web-search / sidecar tools

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions