Skip to content

refactor(translate): clarify assistant-turn replay ownership - #710

Merged
Menci merged 7 commits into
mainfrom
refactor/translate-replay
Nov 12, 2026
Merged

Menci merged 7 commits into
mainfrom
refactor/translate-replay

Conversation

@Menci

@Menci Menci commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

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.

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.
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
Menci marked this pull request as ready for review November 12, 2026 13:59
@Menci
Menci merged commit b4615af into main Nov 12, 2026
21 checks passed
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