|
| 1 | +# WP1b — types.ts type-cluster split (stacked PR 2, layer 2 of the stack) |
| 2 | + |
| 3 | +Stack (DEV-STACK-01/03): layer 1 = #2019 (codex/split-wp1-types, value leaves). |
| 4 | +This layer: codex/split-wp1b-type-clusters, base = codex/split-wp1-types. |
| 5 | +Thesis: src/types.ts becomes a pure barrel; all type clusters move to leaves. |
| 6 | +Class: C2 pure-move, type-only (zero runtime code moves in this layer). |
| 7 | + |
| 8 | +## Loop spec |
| 9 | + |
| 10 | +- Archetype: pure-move refactor, zero behavior change (type-only). |
| 11 | +- Verifier: bun run typecheck + full bun run test on lidge (remote contract). |
| 12 | +- Stop: green + PR opened with base codex/split-wp1-types + stack map in body. |
| 13 | + |
| 14 | +## Measured dependency structure (one-way, no cycles) |
| 15 | + |
| 16 | +- request cluster (lines 6-368): needs KiroOAuthMetadata (oauth/types), |
| 17 | + OcxTool + OcxToolChoice (types/tools). Nothing else external. |
| 18 | +- config cluster (370-1180): needs OcxProviderConfig only (provider cluster). |
| 19 | +- provider cluster (1183-1698): needs UpstreamHttpVersion x2, |
| 20 | + ReasoningSummaryDelivery x3, CodexAccountMode x2 (types/wire). |
| 21 | +- accounts cluster (1700-1729): self-contained. |
| 22 | + |
| 23 | +## File change map |
| 24 | + |
| 25 | +- ADD src/types/request.ts <- lines 6-368 + import type {KiroOAuthMetadata} |
| 26 | + from ../oauth/types, import type {OcxTool, OcxToolChoice} from ./tools |
| 27 | +- ADD src/types/config.ts <- lines 370-1180 + import type |
| 28 | + {OcxProviderConfig} from ./provider |
| 29 | +- ADD src/types/provider.ts <- lines 1183-1698 + import type {...} from ./wire |
| 30 | +- ADD src/types/accounts.ts <- lines 1700-1729, no imports |
| 31 | +- EDIT src/types.ts -> pure barrel (~30 lines): export type blocks for the 4 |
| 32 | + new leaves + existing tools/wire re-exports (values stay `export {}`, |
| 33 | + types stay `export type {}`). KiroOAuthMetadata import dropped from barrel. |
| 34 | + |
| 35 | +## Accept criteria |
| 36 | + |
| 37 | +1. typecheck exit 0. 2. lidge full suite 0 fail (>= 13201 pass baseline). |
| 38 | +3. core-lab-boundary green (barrel value re-exports still walked; type-only |
| 39 | + leaves are erased so runtime graph SHRINKS, never grows). |
| 40 | +4. Source diff: exactly 5 files under src/ (4 adds + barrel). |
| 41 | +5. Public surface byte-compatible: src/index.ts exports (OcxConfig, OcxContext, |
| 42 | + OcxMessage, OcxParsedRequest, OcxProviderConfig, OcxRequestOptions, OcxTool, |
| 43 | + AdapterEvent) all still resolve from ./types. |
| 44 | + |
| 45 | +## Risks |
| 46 | + |
| 47 | +- `export type ... from` binds nothing locally (WP1 lesson) — but the new |
| 48 | + barrel needs NO local bindings once all interfaces leave; only the 4 |
| 49 | + import-type lines vanish too. Residual: none expected. |
| 50 | +- interface merging/declaration duplication: each name must exist in exactly |
| 51 | + one leaf; grep-verify no name appears in two files. |
| 52 | +- Tests importing `import * as types from ../src/types` (namespace): type-only |
| 53 | + namespaces erased; runtime namespace keeps the same value exports via |
| 54 | + tools/wire re-exports. No test currently reads a VALUE that moves (nothing |
| 55 | + moves at runtime this layer). |
| 56 | + |
| 57 | + |
| 58 | +## Audit amendments round 2 (grok-4.6 NEAR-PASS / sol FAIL -> both fixed) |
| 59 | + |
| 60 | +CORRECTED extract ranges (file is 1727 lines): |
| 61 | + |
| 62 | +- request.ts: lines 5-211 (incl. leading JSDoc) + 224-364 |
| 63 | + + import type { KiroOAuthMetadata } from ../oauth/types |
| 64 | + + import type { OcxTool, OcxToolChoice } from ./tools |
| 65 | + + import type { TierDecision, TierObservationContext } from ./provider |
| 66 | + (OcxRequestOptions.tierDecision:235 / tierObservation:237 — missed edge) |
| 67 | +- config.ts: lines 366-1181 (incl. closing brace 1181) MINUS the |
| 68 | + RefreshPolicy block (1074-1080, moves to provider — see below) |
| 69 | + + import type { OcxProviderConfig, RefreshPolicy } is WRONG — instead: |
| 70 | + + import type { OcxProviderConfig } from ./provider (604) |
| 71 | + + import type { CodexAccount } from ./accounts (874 — missed edge) |
| 72 | +- provider.ts: lines 1183-1687 + RefreshPolicy block (1074-1080; sole |
| 73 | + consumer is OcxProviderConfig.refreshPolicy:1484 — relocation keeps the |
| 74 | + graph one-way, avoids the config<->provider cycle) |
| 75 | + + import type { UpstreamHttpVersion, ReasoningSummaryDelivery, |
| 76 | + CodexAccountMode } from ./wire |
| 77 | + + REWRITE 2 inline type-query paths (1659, 1665): |
| 78 | + import("./adapters/cursor/...") -> import("../adapters/cursor/...") |
| 79 | +- accounts.ts: lines 1700-1727, no imports |
| 80 | +- BARREL KEEPS lines 213-222 (tools value re-exports) and 1689-1698 (wire |
| 81 | + value re-exports): RUNTIME blocks, must NOT enter type-only leaves. |
| 82 | + Final barrel = 2 value blocks + 4 export type blocks, named re-exports |
| 83 | + only, NO export * (would duplicate runtime names). |
| 84 | +- The 3 import type lines at 1-3 vanish with their consumers. |
| 85 | +- Barrel needs RefreshPolicy re-exported from ./provider (was ./config). |
| 86 | + |
| 87 | +Corrected one-way graph: request -> {oauth, tools, provider}; |
| 88 | +config -> {provider, accounts}; provider -> wire; accounts -> none. |
| 89 | + |
| 90 | +Both auditors confirmed: no namespace imports, no runtime dynamic import of |
| 91 | +types.ts (all import("...types").X hits are erased type queries), no textual |
| 92 | +test pins, lab walker unaffected while value blocks stay in barrel, |
| 93 | +src/index.ts keeps resolving. AC4 corrected: 5 files under src. |
| 94 | + |
0 commit comments