Skip to content

Providers phase 5b (engine slice 1): route switchProvider through the neutral hub - #409

Merged
Juliusolsson05 merged 1 commit into
mainfrom
refactor/providers-phase5b-switch-hub
Jul 6, 2026
Merged

Juliusolsson05 merged 1 commit into
mainfrom
refactor/providers-phase5b-switch-hub

Conversation

@Juliusolsson05

Copy link
Copy Markdown
Owner

What

Routes switchProvider's translation through the neutral-hub codec seam instead of calling the pairwise converters directly:

toClaude(codexLines, opts)   -> translateToClaude(CodexCodec.decode(codexLines), opts).lines
toCodex(claudeEntries, opts) -> translateToCodex(ClaudeCodec.decode(claudeEntries), opts).lines

Byte-identical to the old direct calls: codec decode wraps every source record in the lossless passthrough region, translateTo* reconstructs that exact source array and runs the same legacy converter with the same options. Pinned by atp's testing/translate-equivalence.ts (ClaudeCodec.encode(CodexCodec.decode(x)) ≡ toClaude(x) and the symmetric case), which I ran green against the pinned atp commit b50d73f.

Why a byte-identical refactor

switchProvider becomes the first production consumer of the neutral hub. When the atp engine migrates to true per-entry neutral translation (a later slice, verified against the same corpus), provider switching inherits it with zero further edits — and a third provider's codec makes its switch pairs work here for free.

This deliberately isolates the safe seam swap from the more delicate work: the resume sanitizers (claudeResumeSanitizer/codexResumeSanitizer) and id/file-layout policy stay app-side. Absorbing them into the codecs is the separate, riskier slice (#394 phase 5b) that this one de-risks by landing the seam first. duplicateSession/rewindSession follow the same pattern and are follow-ups.

Verification

  • verify:neutral-translate (atp, at pinned commit) → all codex↔claude equivalences hold, fidelity + lossy
  • tsc -p tsconfig.node.json → 0 · tsc --noEmit -p tsconfig.web.json → 0
  • electron-vite build ✓ · npm test → 170/170 (1 pre-existing voice-dictation "No test suite found" quirk)

🤖 Generated with Claude Code

…e neutral hub

Replace the direct toClaude/toCodex calls in switchProvider with the
neutral-hub translate seam:

  toClaude(codexLines, opts)   -> translateToClaude(CodexCodec.decode(codexLines), opts).lines
  toCodex(claudeEntries, opts) -> translateToCodex(ClaudeCodec.decode(claudeEntries), opts).lines

This is BYTE-IDENTICAL to the old direct calls — the codec decode wraps
every source record in the passthrough region losslessly, translateTo*
reconstructs that exact source array and runs the same legacy converter
with the same options. The equivalence is pinned by atp's
testing/translate-equivalence.ts (verify:neutral-translate), which I ran
against the pinned atp commit (b50d73f): all codex↔claude equivalences
hold in both fidelity and lossy modes.

WHY do a byte-identical refactor: switchProvider becomes the FIRST
production consumer of the neutral hub, so when the atp engine migrates
to true per-entry neutral translation (a later slice, verified against
the same corpus), provider switching inherits it with zero further edits
— and a third provider's codec makes its switch pairs work here for free.

Deliberately isolated from the more delicate work: the resume sanitizers
(claudeResumeSanitizer/codexResumeSanitizer) and id/file-layout policy
stay app-side; absorbing them into the codecs is the separate slice this
one de-risks by landing the safe seam swap first.

Verification: verify:neutral-translate green; tsc node+web 0 errors;
electron-vite build ok; 170/170 unit tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Juliusolsson05
Juliusolsson05 merged commit b54d18f into main Jul 6, 2026
@Juliusolsson05
Juliusolsson05 deleted the refactor/providers-phase5b-switch-hub branch July 6, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant