Skip to content

refactor(providers): isolate OpenAI destination classification (split S02 L1/4) - #3566

Closed
lidge-jun wants to merge 2 commits into
devfrom
codex/split-providers-openai-tiers
Closed

refactor(providers): isolate OpenAI destination classification (split S02 L1/4)#3566
lidge-jun wants to merge 2 commits into
devfrom
codex/split-providers-openai-tiers

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Pure move: OpenAI destination identity and classification (provider-id constants, CODEX_FORWARD_BASE_URL, isCanonicalOpenAiForwardProvider, supportsNativeResponsesCompactEndpoint, isOpenAiOperatedResponsesDestination, destinationDecodesNativeCompactionBlob and their private helpers — src/providers/openai-tiers.ts:6–11, 23–114) moves verbatim to src/providers/openai-tiers-destination.ts (102 lines). openai-tiers.ts keeps the tier-migration projection (319 lines) and re-exports all nine moved names, so every existing import path keeps working.
  • Why: 416-line file over the 400-line module limit; destination classification and legacy-tier migration are separate concerns. Zero behavior change.
  • Plan and evidence: devlog/_plan/260905_now_split_train/040_providers_openai_tiers.md; rules 003_parent_decisions.md (PURE-MOVE-SIZE-01).

Stack (S02 providers; merge bottom-up):

# PR Branch Base Review focus
4 TBD codex/split-providers-registry-c codex/split-providers-registry-b registry entries (c)
3 TBD codex/split-providers-registry-b codex/split-providers-registry-a registry contracts + entries (b)
2 TBD codex/split-providers-registry-a dev registry model tables (a)
1 this PR codex/split-providers-openai-tiers ← you are here dev destination predicates

Base: dev. Review this PR's diff only (3 files, +117/−99; non-move diff: 2 leaf imports, 1 local import, 1 re-export line, 13 test lines). Move-aware view: git diff --color-moved=dimmed-zebra dev...HEAD.

Verification

  • bun run typecheck → exit 0
  • Focused: openai-provider-option{,-migration,-startup}, codex-convergence-account-selectors, responses-compaction{,-routing}, responses-inbound-store-default → 179 pass / 0 fail
  • tests/lab/core-lab-boundary.test.ts → 17 pass / 0 fail
  • Red-drives, then restored: accepting key auth in isCanonicalOpenAiForwardProvider fails openai-provider-option.test.ts:37; inverting supportsNativeResponsesCompactEndpoint fails responses-compaction-routing.test.ts:154/167.
  • bun run privacy:scan → passed
  • New test: leaf bindings are identical (toBe) to the facade re-exports; the leaf does not import the facade.
  • Full suite on the remote CI host (lidge) at this exact SHA: recorded in the devlog doc.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (devlog unit records the layer; no user-facing change).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults (auth-mode predicate moved byte-for-byte; guard driven red once).

Summary by CodeRabbit

  • Refactor

    • Consolidated OpenAI destination classification and endpoint compatibility logic into a dedicated provider module.
    • Preserved existing public exports while improving internal organization.
  • Tests

    • Added coverage confirming that destination classification and provider identifiers remain consistent across supported interfaces.

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 5, 2026 00:53
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 0d9a3f2d-9e82-4e5c-be78-cca283c7632f

📥 Commits

Reviewing files that changed from the base of the PR and between 4dde2db and 58dba9e.

📒 Files selected for processing (3)
  • src/providers/openai-tiers-destination.ts
  • src/providers/openai-tiers.ts
  • tests/adapters/openai/openai-provider-option.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The change extracts OpenAI destination constants and classification helpers into a new leaf module. The existing provider facade re-exports them. Tests verify export parity and prevent the leaf module from importing the facade.

Changes

OpenAI destination classification

Layer / File(s) Summary
Destination constants and classification helpers
src/providers/openai-tiers-destination.ts
Adds provider identifiers, canonical URL constants, URL normalization, Responses endpoint resolution, native compact endpoint detection, OpenAI-operated destination detection, and native compaction blob decoding.
Facade exports and boundary validation
src/providers/openai-tiers.ts, tests/adapters/openai/openai-provider-option.test.ts
Moves the implementations behind facade re-exports. Tests verify that the leaf module matches the facade and does not import ./openai-tiers.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 58dba

OpenAI destination classification was moved into a leaf module while preserving existing facade imports and behavior. No current merge-blocking risk is established.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: isolating OpenAI destination-classification logic into a separate provider module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/split-providers-openai-tiers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Sep 5, 2026
@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 72 / 80

이 PR은 providers 스플릿 트레인 S02의 첫 칸입니다. 지금 devsrc/providers/openai-tiers.ts는 416줄로 모듈 한도(400)를 넘고, OpenAI destination 분류(상수·isCanonicalOpenAiForwardProvider·compact/operated/blob 디코드 판정)와 legacy tier migration이 한 파일에 있습니다. 이 변경은 destination 쪽을 src/providers/openai-tiers-destination.ts(102줄)로 그대로 옮기고, openai-tiers.ts는 migration을 남긴 뒤 아홉 이름을 re-export해서 기존 import 경로를 깨지 않습니다. 동작 변경 없음이 목표이고, base가 dev 직접이라 스택 아래층 없이 머지 가능한 층입니다. 포커스 테스트·layout guard GREEN 주장이 본문에 있습니다. 비이동 diff는 leaf import·re-export·테스트 보강 정도로 작습니다.

src/providers/openai-tiers.ts - destination 이동 후에도 import { openaiResponsesUrl } from "../adapters/openai-responses-url" 한 줄이 남아 있다. 사용처는 destination 파일로 같이 옮겨서 미사용 import다. 제거해야 lint/경계 규칙에 안 걸린다.

src/providers/openai-tiers.ts re-export 줄 - 기존 소비자가 openai-tiers에서 이름을 가져가던 경로를 유지하는 목적이 분명하다. 스플릿 후속(L2+)이 직접 destination을 import하도록 유도할지는 트레인 계획에 맡긴다.

src/providers/openai-tiers-destination.ts - 내용이 verbatim move로 보이고, resolvedResponsesEndpoint / lookalike 호스트 배제 주석도 그대로다. 행동 변경 없이 파일만 갈라진 상태면 PURE-MOVE-SIZE-01에 맞다.

tests/adapters/openai/openai-provider-option.test.ts - red-drive로 destination 판정을 고정한 보강이면 좋다. import가 어느 모듈을 가리키는지만 diff에서 확인하면 된다.

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

  • 미사용 openaiResponsesUrl import를 이 PR에서 바로 지울지(권장) vs 후속 청소
  • S02 다음 registry 스플릿(PR TBD)과 머지 간격을 둘지
  • re-export를 얼마나 오래 유지할지

너의 추천
미사용 import 한 줄 지운 뒤(또는 follow-up 초소형 커밋) 그대로 dev에 머지해도 되는 층이다. 아래 스택(#3561…)과 무관. types/config 스플릿 캠페인과 충돌하지 않는 providers 모듈 분리로 보이며, close-don't-rebase 대상 아님.

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

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on exact head 58dba9e0b2209bd9f76c4d5fb4943df0d6ab710b. The destination constants and predicates are a behavior-preserving extraction, the existing openai-tiers facade keeps all prior bindings, the leaf does not import the facade, and no state owner is duplicated. Independent isolated verification passed 91/91 across the destination and compaction boundaries; exact-head cross-platform CI and CodeRabbit are green with no unresolved thread.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Landed via #3668 at 6585e6a

@lidge-jun

Copy link
Copy Markdown
Owner Author

Superseded by aggregate PR #3668, admin-merged into dev as 6585e6a after exact-head CI and tested-tree verification. This original PR was not individually merged; its rebased content and historical records were consolidated in #3668. The original branch is preserved. Further unimplemented debt layers remain deferred.

@lidge-jun lidge-jun closed this Sep 5, 2026
@lidge-jun lidge-jun added the landed-via-maintainer Original PR closed after landing via a maintainer merge train label Sep 5, 2026
@lidge-jun
lidge-jun deleted the codex/split-providers-openai-tiers branch September 6, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). landed-via-maintainer Original PR closed after landing via a maintainer merge train

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants