Repository navigation
refactor(translate): clarify assistant-turn replay ownership - #710
Merged
Merged
Conversation
Split native replay coordination into reader, writer, and coordinator owners. Distinguish native input turns, read and emitted reference states, text fragments, content-reference tags, and the transport codec without changing replay wire behavior. Preserve the pairwise request replay signature and reasoning warnings. Keep native output-to-input normalization and Gemini target slots, and move converter assertions to their protocol owners. Validated 38 named test files (307 tests), translate typecheck, and touched-file ESLint. Production HMAC/CBOR sidecar bytes, digests, selected references, restored turns, and native converter outputs match the main baseline for literal, astral, and unpaired-surrogate fixtures.
Unify recursive and assistant-turn restoration through RestoreResult.value while retaining the pairwise request boundary's native turn wrapper. Centralize the four protocols' existing digest material projection and version dispatch in shared digest factories. Preserve synchronous projector failures and skip projection for unsupported versions. Validated 38 named test files (309 tests), translate typecheck, and 14 touched-file lint targets. Production HMAC/CBOR bytes and restored native values match main; all four protocol digest projections and version behavior also match main.
Apply the accepted reader/writer, digest material ownership, and text placement comments at their replay owners. Verify unchanged compiler-token and directive streams for all four files, scoped lint, translate typecheck, named replay tests, and production byte and source digest invariance.
2 tasks done
Move Chat audio replay and Responses output-to-input normalization into protocol APIs. Keep only reference-state alignment in translate, and move native payload tests to their protocol owners.
…play # Conflicts: # packages/protocols/src/openai-responses/index.ts # packages/translate/AGENTS.md # packages/translate/__tests__/ir/helpers.ts # packages/translate/__tests__/protocols/anthropic-messages/as-source/events_test.ts # packages/translate/__tests__/protocols/anthropic-messages/as-target/events_test.ts # packages/translate/__tests__/protocols/chat-legacy-round-trip_test.ts # packages/translate/__tests__/protocols/chat-reasoning-round-trip_test.ts # packages/translate/__tests__/protocols/fixtures.ts # packages/translate/__tests__/protocols/gemini-generate-content/as-source/events_test.ts # packages/translate/__tests__/protocols/openai-chat-completions/as-source/events_test.ts # packages/translate/__tests__/protocols/openai-chat-completions/as-target/events_test.ts # packages/translate/__tests__/protocols/openai-responses/as-source/events_test.ts # packages/translate/__tests__/protocols/openai-responses/as-target/events_test.ts # packages/translate/__tests__/round-trip/reference/reference-builder_test.ts # packages/translate/src/index.ts # packages/translate/src/ir/output/builder.ts # packages/translate/src/protocols/anthropic-messages/as-source/events.ts # packages/translate/src/protocols/anthropic-messages/as-source/round-trip.ts # packages/translate/src/protocols/anthropic-messages/as-target/assistant-turn.ts # packages/translate/src/protocols/anthropic-messages/as-target/events.ts # packages/translate/src/protocols/anthropic-messages/via-openai-chat-completions/events.ts # packages/translate/src/protocols/anthropic-messages/via-openai-chat-completions/request.ts # packages/translate/src/protocols/anthropic-messages/via-openai-responses/events.ts # packages/translate/src/protocols/anthropic-messages/via-openai-responses/request.ts # packages/translate/src/protocols/gemini-generate-content/as-source/events.ts # packages/translate/src/protocols/gemini-generate-content/as-source/round-trip.ts # packages/translate/src/protocols/gemini-generate-content/via-anthropic-messages/events.ts # packages/translate/src/protocols/gemini-generate-content/via-anthropic-messages/request.ts # packages/translate/src/protocols/gemini-generate-content/via-openai-chat-completions/events.ts # packages/translate/src/protocols/gemini-generate-content/via-openai-chat-completions/request.ts # packages/translate/src/protocols/gemini-generate-content/via-openai-responses/events.ts # packages/translate/src/protocols/gemini-generate-content/via-openai-responses/request.ts # packages/translate/src/protocols/openai-chat-completions/as-source/events.ts # packages/translate/src/protocols/openai-chat-completions/as-source/round-trip.ts # packages/translate/src/protocols/openai-chat-completions/as-target/events.ts # packages/translate/src/protocols/openai-chat-completions/via-anthropic-messages/events.ts # packages/translate/src/protocols/openai-chat-completions/via-anthropic-messages/request.ts # packages/translate/src/protocols/openai-chat-completions/via-openai-responses/events.ts # packages/translate/src/protocols/openai-chat-completions/via-openai-responses/request.ts # packages/translate/src/protocols/openai-responses/as-source/events.ts # packages/translate/src/protocols/openai-responses/as-source/round-trip.ts # packages/translate/src/protocols/openai-responses/as-target/events.ts # packages/translate/src/protocols/openai-responses/via-anthropic-messages/events.ts # packages/translate/src/protocols/openai-responses/via-anthropic-messages/request.ts # packages/translate/src/protocols/openai-responses/via-openai-chat-completions/events.ts # packages/translate/src/protocols/openai-responses/via-openai-chat-completions/request.ts # packages/translate/src/round-trip/reference/reference-builder.ts # packages/translate/src/round-trip/reference/reference-selection.ts # packages/translate/src/round-trip/reference/types.ts # packages/translate/src/round-trip/stream.ts # packages/translate/src/round-trip/turn-digest.ts # packages/translate/src/shared/event-writer-options.ts
Align the current-main replay integration with repository import ordering and coalesce the Responses test import. Preserve the resolved replay behavior.
Order the remaining replay codec imports after integrating current main. The complete 92-file TypeScript diff now passes scoped ESLint.
Menci
marked this pull request as ready for review
November 12, 2026 13:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Give replay coordination, native turn/state contracts, codec tags, content references, provenance and hashing explicit owners and names. Preserve sidecar encoding, signatures, reference selection, restoration and native residual fields.
Validated with 38 named files (307 tests), scoped lint/typecheck and byte-identical production HMAC/CBOR fixtures covering literal, astral and unpaired-surrogate text. Independent prerequisite for #673.
Protocol package ownership:
Native Chat audio replay and Responses output-to-input normalization now live in the owning protocol modules. Translation retains reference-state alignment. Native payload tests follow the protocol ownership; sidecar encoding, signatures and native residuals remain unchanged.