Skip to content

refactor(types): extract value clusters into types/tools and types/wire leaves - #2019

Merged
lidge-jun merged 2 commits into
devfrom
codex/split-wp1-types
Aug 19, 2026
Merged

refactor(types): extract value clusters into types/tools and types/wire leaves#2019
lidge-jun merged 2 commits into
devfrom
codex/split-wp1-types

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

First stacked PR of the mega-file split program (devlog/_plan/260818_megafile_split_program, risk basis in 000_risk_assessment.md). Pure move, zero behavior change: the two runtime value clusters leave src/types.ts (1867 -> 1729 lines) into leaf modules, with src/types.ts keeping every current export as a barrel re-export so no consumer or test import changes.

  • src/types/tools.ts — OcxTool, OcxToolChoice, namespacedToolName, toolChoiceAliases, toolAllowedByChoice, resolveToolChoiceWireName, modelInList, isAllowedToolChoice, toolChoiceToolPredicate. Zero imports; OcxTool travels with the cluster so the leaf never imports back through its own barrel (audit finding).
  • src/types/wire.ts — UPSTREAM_HTTP_VERSION_VALUES, REASONING_SUMMARY_DELIVERY_VALUES, OPENAI_PROVIDER_TIER_VERSION, MODEL_ADAPTER_OVERRIDE_ALLOWED, ANTHROPIC_WIRE_MODELS internals, captureWireAdapterHardPins, isWirePinnedModel, pinnedWireAdapter, UpstreamHttpVersion, ReasoningSummaryDelivery, CodexAccountMode. Zero imports.
  • src/types.ts — moved bodies deleted; top-of-file import type lines bind the aliases the remaining interfaces still reference (export type ... from does not bind locally — audit finding); in-place export/export type blocks keep the public surface byte-compatible. Extensionless specifiers so the lab-boundary walker follows the new edges.

Value identity is preserved by ESM re-export semantics: one declaration site per const, so MODEL_ADAPTER_OVERRIDE_ALLOWED stays a single ReadonlySet instance. The plan was audited by two independent reviewers (grok-4.6 NEAR-PASS, gpt-5.6-sol FAIL on a barrel-cycle recipe defect) and amended before implementation; both blockers were plan-recipe issues, fixed as described above.

Next in the stack: type-cluster split (request/config/provider/accounts) on this branch's head.

Verification

At head 194f9f2 on remote validation host (Linux):

  • bun run test: 13,201 pass / 15 skip / 0 fail across 840 files (482.9s)
  • tests/core-lab-boundary.test.ts: 13 pass standalone (new static edges types.ts -> types/tools.ts, types/wire.ts are walked and stay off src/lab/)
  • bun run privacy:scan: passed
  • bun run typecheck: exit 0
  • Source diff scope: exactly 3 files under src/ (git diff --stat dev..HEAD -- src)

Checklist

  • Targets dev
  • Focused tests cover the changed subsystem (full suite green — shared runtime file)
  • No user-facing behavior change, so no docs-site update needed
  • privacy:scan green

Summary by CodeRabbit

  • New Features

    • Added expanded tool metadata and tool-choice support, including namespaced tools, aliases, validation, and policy matching.
    • Added configuration options for upstream HTTP versions, reasoning-summary delivery, account modes, provider tiers, and model adapter overrides.
    • Added automatic handling for provider- and model-specific wire adapter requirements.
  • Refactor

    • Reorganized tool and wire-related functionality while preserving existing public exports and integrations.

@github-actions github-actions Bot added the intake: hygiene-blocked Deterministic PR hygiene checks failed label Aug 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deterministic hygiene checks failed.

  • missing_regression_test — Behavior changed under src/ or gui/src/ without a test change. Add focused coverage or obtain test-exception-approved.

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

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • hygiene: missing_regression_test.

What to do

  • Fix missing_regression_test — Behavior changed under src/ or gui/src/ without a test change. Add focused coverage or obtain test-exception-approved.

Automatic draft conversion failed (token cannot change draft status). Please convert this pull request to a draft manually. The required enforce-target check will keep failing until every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 18, 2026 11:07
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a1aaff37-1cba-4c61-a9b9-f1191c7fbf0e

📥 Commits

Reviewing files that changed from the base of the PR and between 194f9f2 and 3ddae40.

📒 Files selected for processing (2)
  • src/types.ts
  • src/types/tools.ts

📝 Walkthrough

Walkthrough

The PR moves tool utilities and wire-policy logic from src/types.ts into src/types/tools.ts and src/types/wire.ts. src/types.ts preserves the existing public exports through imports and re-exports. The WP1 plan documents scope and verification criteria.

Changes

Types value-leaf extraction

Layer / File(s) Summary
Tool metadata and choice utilities
src/types/tools.ts
Adds OcxTool, OcxToolChoice, tool-name aliasing, model matching, allowed-tool validation, and tool-choice predicates.
Wire policy declarations and resolution
src/types/wire.ts
Adds shared wire-policy types and constants, plus provider/model adapter pinning helpers.
Barrel re-exports and extraction plan
src/types.ts, devlog/_plan/260818_megafile_split_program/010_wp1_types_value_leaves.md
Moves local declarations out of src/types.ts, re-exports the extracted bindings, and documents scope, verification, and import-graph constraints.

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

Suggested reviewers: ingwannu, wibias

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. 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 refactor: extracting value clusters from types.ts into types/tools and types/wire.
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 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-wp1-types

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.

@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 38 / 80

dev 기준 이 PR은 src/types.ts에 있던 런타임 값 클러스터를 src/types/tools.tssrc/types/wire.ts로 옮기고, 기존 public surface는 barrel re-export로 유지하는 순수 이동입니다. OcxTool/OcxToolChoice/namespacedToolName/toolChoiceAliases/toolAllowedByChoice/resolveToolChoiceWireName/modelInList/isAllowedToolChoice/toolChoiceToolPredicate가 tools leaf로 가고, UPSTREAM_HTTP_VERSION_VALUES/REASONING_SUMMARY_DELIVERY_VALUES/OPENAI_PROVIDER_TIER_VERSION/MODEL_ADAPTER_OVERRIDE_ALLOWEDcaptureWireAdapterHardPins/isWirePinnedModel/pinnedWireAdapter가 wire leaf로 갑니다. 두 leaf 모두 import가 없고, types.ts./types/tools./types/wire를 바라보므로 런타임 사이클은 열리지 않습니다. 다만 Draft이고 intake: hygiene-blocked가 붙어 있어, 코드 구조와 별개로 merge 우선순위는 낮게 잡았습니다.

barrel 쪽은 감사에서 지적된 바를 실제로 반영했습니다. export type { OcxTool } from "./types/tools"만으로는 types.ts 본문에서 OcxTool을 로컬 바인딩으로 쓸 수 없으므로, 파일 상단에 import type { OcxTool, OcxToolChoice } from "./types/tools"import type { UpstreamHttpVersion, ReasoningSummaryDelivery, CodexAccountMode } from "./types/wire"를 두고, 이동한 자리에는 export type/export { ... } from 블록을 남겼습니다. 확장자 없는 specifier(./types/tools, ./types/wire)도 lab-boundary walker가 ${base}.ts로 따라가도록 맞춘 선택입니다. MODEL_ADAPTER_OVERRIDE_ALLOWED는 leaf에서 한 번만 new Set(...)로 선언되고 barrel은 re-export만 하므로 ReadonlySet 인스턴스 동일성도 유지됩니다.

구현과 플랜 문서가 어긋난 지점이 있습니다. devlog/_plan/260818_megafile_split_program/010_wp1_types_value_leaves.md의 Scope(IN)은 여전히 tools.tsimport type { OcxTool } from "../types"를 필요로 한다고 적혀 있습니다. 실제 코드와 Audit amendments 1번은 그 반대입니다. OcxTool은 tools leaf로 같이 옮겨졌고 tools.ts는 ../types를 다시 보지 않습니다. 감사에서 막힌 barrel-cycle recipe를 코드로는 고쳤지만, 같은 파일의 앞부분 스펙이 옛 recipe를 그대로 들고 있어 다음 stacked PR이 이 문서를 진실로 읽으면 다시 사이클을 열 수 있습니다.

클러스터 경계도 조금 느슨합니다. modelInList는 tool-choice가 아니라 provider classification list 매칭 헬퍼인데 tools.ts에 같이 실렸습니다. 이번 PR의 “원래 붙어 있던 값 묶음을 통째로 옮긴다”는 범위에는 맞지만, 다음 type-cluster 분할에서 tools leaf를 “도구 정책 전용”으로 읽으면 잘못된 의존이 생깁니다. ANTHROPIC_WIRE_MODELS/anthropicWireModelsForProvider는 wire.ts 내부로 잘 남았고, pinnedWireAdapterisWirePinnedModel에만 기대는 순수 함수 구조도 그대로입니다. 동작 변경은 diff상 보이지 않습니다.

해결방안: (1) hygiene-blocked를 재실행해 통과시키고 Draft를 Ready로 올린 뒤에만 merge 후보로 보십시오. (2) 010_wp1_types_value_leaves.md Scope(IN)에서 import type { OcxTool } from "../types" 문장을 삭제하고, 구현과 같이 “OcxTool은 tools.ts에 공존, tools.ts는 types.ts를 import하지 않음”으로 고치십시오. (3) modelInList를 tools 클러스터에 둘지 다음 WP에서 분리할지 한 줄을 플랜에 명시하십시오. (4) merge 전 git diff --stat dev...HEAD -- src가 설명대로 types.ts/types/tools.ts/types/wire.ts 세 파일인지, bun run typechecktests/core-lab-boundary.test.ts가 새 static edge를 보는지 한 번 더 확인하면 됩니다.

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

@lidge-jun lidge-jun mentioned this pull request Aug 19, 2026
7 tasks
@lidge-jun
lidge-jun force-pushed the codex/split-wp1-types branch from 35990f6 to a2eb3c3 Compare August 19, 2026 13:16
@lidge-jun
lidge-jun force-pushed the codex/split-wp1-types branch from a2eb3c3 to 3ddae40 Compare August 19, 2026 13:22
@lidge-jun lidge-jun added the test-exception-approved Maintainer approved a non-automated regression-test exception label Aug 19, 2026
@github-actions github-actions Bot removed the test-exception-approved Maintainer approved a non-automated regression-test exception label Aug 19, 2026
@lidge-jun
lidge-jun marked this pull request as ready for review August 19, 2026 13:22
@lidge-jun
lidge-jun merged commit da86a83 into dev Aug 19, 2026
4 of 9 checks passed
@lidge-jun
lidge-jun deleted the codex/split-wp1-types branch August 20, 2026 13:30
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). intake: hygiene-blocked Deterministic PR hygiene checks failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant