|
| 1 | +# WP1 — types.ts value-leaf extraction (stacked PR 1 of the split program) |
| 2 | + |
| 3 | +Unit: devlog/_plan/260818_megafile_split_program. Risk basis: 000_risk_assessment.md. |
| 4 | +Branch: codex/split-wp1-types on dev @ b04cd26e7 (post FastWire B0/B1 merge). |
| 5 | +Class: C2 (mechanical move, shared-runtime file, full-suite gate). |
| 6 | + |
| 7 | +## Loop spec |
| 8 | + |
| 9 | +- Archetype: pure-move refactor, zero behavior change. |
| 10 | +- Trigger: split program WP1, lowest-risk opener. |
| 11 | +- Goal: src/types.ts stops carrying runtime value code; values live in leaves; |
| 12 | + every existing import keeps working via re-export. |
| 13 | +- Non-goals: NO type-cluster split yet (OcxConfig/OcxProviderConfig stay), |
| 14 | + NO consumer retargeting to leaf paths, NO behavior or signature change. |
| 15 | +- Verifier: bun run typecheck && bun run test (full — shared runtime file). |
| 16 | +- Stop: both green + core-lab-boundary green; PR opened against dev. |
| 17 | +- Memory artifact: this doc + ledger attests. |
| 18 | + |
| 19 | +## Scope (IN) |
| 20 | + |
| 21 | +Extract the two VALUE clusters from src/types.ts (1867 lines) into leaves: |
| 22 | + |
| 23 | +1. src/types/tools.ts — lines ~236-292: |
| 24 | + namespacedToolName, toolChoiceAliases, toolAllowedByChoice, |
| 25 | + resolveToolChoiceWireName, modelInList, OcxToolChoice (type), |
| 26 | + isAllowedToolChoice, toolChoiceToolPredicate. |
| 27 | + Needs `import type { OcxTool } from "../types"` — type-only, erased at |
| 28 | + runtime, so the types.ts -> tools.ts re-export is NOT a runtime cycle. |
| 29 | +2. src/types/wire.ts — lines ~1760-1839: |
| 30 | + UPSTREAM_HTTP_VERSION_VALUES, UpstreamHttpVersion, |
| 31 | + REASONING_SUMMARY_DELIVERY_VALUES, ReasoningSummaryDelivery, |
| 32 | + CodexAccountMode, OPENAI_PROVIDER_TIER_VERSION, |
| 33 | + MODEL_ADAPTER_OVERRIDE_ALLOWED, ANTHROPIC_WIRE_MODELS (internal), |
| 34 | + anthropicWireModelsForProvider (internal), captureWireAdapterHardPins, |
| 35 | + isWirePinnedModel, pinnedWireAdapter. Self-contained, no imports. |
| 36 | + |
| 37 | +src/types.ts keeps every current export via `export ... from "./types/..."`; |
| 38 | +type-only names re-exported with `export type`. |
| 39 | + |
| 40 | +## Scope (OUT) |
| 41 | + |
| 42 | +- All interface/type clusters stay in types.ts this PR. |
| 43 | +- No import-path changes anywhere else in src/ or tests/. |
| 44 | +- No lab imports anywhere new (types is on the protected graph as a value |
| 45 | + import from responses/core.ts: modelInList, namespacedToolName). |
| 46 | + |
| 47 | +## File change map |
| 48 | + |
| 49 | +- ADD src/types/tools.ts (~60 lines incl. docs) |
| 50 | +- ADD src/types/wire.ts (~85 lines incl. docs) |
| 51 | +- EDIT src/types.ts: delete moved bodies, add two re-export blocks at the |
| 52 | + same positions; net -120 lines. |
| 53 | + |
| 54 | +## Accept criteria |
| 55 | + |
| 56 | +1. bun run typecheck exit 0. |
| 57 | +2. bun run test full suite: same pass count as base (13k+), 0 fail. |
| 58 | +3. tests/core-lab-boundary.test.ts green (covers the new static edges |
| 59 | + types.ts -> types/tools.ts, types/wire.ts on the protected walk). |
| 60 | +4. rg confirms no consumer file changed: git diff --stat touches exactly 3 |
| 61 | + files. |
| 62 | +5. Value identity preserved: MODEL_ADAPTER_OVERRIDE_ALLOWED still a single |
| 63 | + ReadonlySet instance (only one declaration site, re-export not re-create). |
| 64 | + |
| 65 | +Activation grounding: criterion 3's scenario is the existing boundary test |
| 66 | +run; criterion 5's scenario is the full suite (service-tier tests compare |
| 67 | +set membership through both import paths). |
| 68 | + |
| 69 | +## Verifier reality (PLAN-VERIFIER-REAL-01) |
| 70 | + |
| 71 | +- bun run typecheck: exists in package.json, reads src/ via tsconfig |
| 72 | + include ["src"] — observes both new files. To be run in C. |
| 73 | +- bun run test: tests/ suite imports ../src/types in 400 files — observes |
| 74 | + the barrel; core-lab-boundary walks the import graph from the three |
| 75 | + protected roots which reach types.ts — observes the new edges. |
| 76 | + |
| 77 | +## Stacked-PR plan (DEV-STACK-01) |
| 78 | + |
| 79 | +PR 1 (this): value leaves + barrel. Target: dev. |
| 80 | +PR 2 (next cycle): type-cluster split (request/config/provider/accounts) |
| 81 | +stacked on PR 1's head branch. |
| 82 | +Later cycles per 000_risk_assessment.md order (config leaves, registry, ...). |
| 83 | + |
| 84 | +## Audit amendments (A-phase, 2 auditors: grok-4.6 NEAR-PASS / gpt-5.6-sol FAIL->fixed) |
| 85 | + |
| 86 | +1. CYCLE FIX (sol blocker): OcxTool (lines 211-232) moves INTO types/tools.ts. |
| 87 | + tools.ts imports NOTHING from ../types — dependency is strictly one-way |
| 88 | + (types.ts -> types/tools.ts). types.ts re-exports OcxTool as a type. |
| 89 | +2. RECIPE FIX (grok finding 7): `export type { X } from` does not BIND X in |
| 90 | + the barrel. types.ts still uses OcxTool (line 106), OcxToolChoice (299), |
| 91 | + UpstreamHttpVersion (1455), CodexAccountMode (1470), |
| 92 | + ReasoningSummaryDelivery (1574) — so the barrel adds a local |
| 93 | + `import type { OcxTool, OcxToolChoice } from "./types/tools"` and |
| 94 | + `import type { UpstreamHttpVersion, ReasoningSummaryDelivery, |
| 95 | + CodexAccountMode } from "./types/wire"` next to the Kiro import. |
| 96 | +3. OcxToolChoice + its guards travel with tools.ts (they are one cluster). |
| 97 | +4. Extensionless specifiers only (lab walker resolves `${base}.ts`). |
| 98 | +5. AC4 corrected: scope proof = `git diff --stat <base>..HEAD -- src tests` |
| 99 | + showing exactly 3 src files; devlog/plan files are committed separately. |
| 100 | +6. AC5 proof corrected: identity is preserved by ESM re-export semantics |
| 101 | + (single declaration site); drop the false 'both import paths' claim. |
| 102 | +7. Protected-roots note corrected: PROTECTED has 4 files; only |
| 103 | + responses/core.ts puts types.ts on the runtime graph (core.ts:63). |
| 104 | + |
0 commit comments