Repository navigation
[Feature]: keep Responses fetch helpers on a transport-only import boundary #2434
Description
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
- Current
dev:4f41a8e936141af7ee828e335da314b9dc1ef761 - Original split:
e7f24b952 - Current file: 232 lines, seven public declarations/exports, 39 distinct runtime import specifiers
- Static runtime graph: 326 modules currently; six modules with only the imports used by the helper
- Existing modularization work [Feature]: extract proxy process-state ownership from config persistence #2378, [Feature]: extract provider validation from config persistence #2379, and [Refactor]: centralize Codex auth-context error mapping across Responses and compact #2392 covers config/process/auth-error ownership and does not overlap this transport leaf.
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
Ingwannu commentedon Aug 23, 2026
Implementation is available in PR #2435 at exact head
6b197942c8354ccf0d54c341764c0b03f767ba9a, rebased ontodev@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:
git diff --check: passed;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.lidge-jun commentedon Aug 23, 2026
리뷰 · 우선순위 40 / 80
설명: 이 이슈는 응답 가져오기 도우미 파일이 전송만 맡는 잎이어야 하는데, 예전 큰 파일에서 복사한 import 때문에 네이티브 채팅이 도우미 하나만 불러도 응답 전체 그래프를 연다고 한다. 지금 CURRENT
devHEAD 는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 로 닫는다. 공개 도우미와 요청 동작은 그대로 둔다. 복사한 런타임 import 만 걷어 낸다. 2426 과 2431 과 2210 은 닫지 않는다. 호출 길을 넓히지 말 것. 라벨은 그대로 둔다. 프리뷰 배포가 아니다.
이 댓글은 grok-bot이 작성했습니다
Ingwannu commentedon Aug 23, 2026
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.
Ingwannu commentedon Aug 23, 2026
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.
lidge-jun commentedon Aug 23, 2026
Closed by #2435, squash-merged to
devas 4fb0fbe.src/server/responses/fetch-helpers.tsnow carries only transport-level imports, and the regression attests/responses-fetch-helpers-boundary.test.ts:43pins 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.lidge-jun commentedon Aug 23, 2026
Landed via #2435 at 4fb0fbe