feat(wire): mirror constructors for primeFold projections (Phase 2) - #114
Merged
Conversation
Move the three hand-rolled wire mirrors out of the omp plugin (wire-fold.ts) into the kernel, next to the codecs that define their identity space. Protocol knowledge stops being scattered: one place fixed no longer breaks another (issue #64 class). - MirrorMessage/MirrorBlock: neutral view, caller pre-normalizes text (ref-tag stripping stays a host-app concern) - mirrorOpenaiMessages / mirrorAnthropicMessages / mirrorResponsesInput: host-encoder wire rules per protocol family (thinking placement, whitespace handling, tool shapes) - mirrorOpenaiToCore / mirrorAnthropicToCore / mirrorResponsesToCore: fold through the matching codec - parity tests: mirror ids == live reasoning_content wire == live inline-<think> wire (issues #103, #64 and its demoted + responses variants)
Merged
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.
What
Phase 2 of the protocol consolidation (#112 follow-up, plan in issue #64 discussion): the kernel now owns the wire mirror constructors — the "what will the host put on the wire after a restart" projections that primeFold needs to land a resumed session's preview in the same ref/fingerprint space as the live request.
Until now these were three hand-rolled builders inside the omp plugin (
wire-fold.ts): exactly the scattered-protocol-knowledge pattern that produced the issue-#64 class of restart divergences (fix one place, break another).New module
src/wire/mirror.tsMirrorMessage/MirrorBlockmirrorOpenaiMessages(view, systemText)reasoning_contentfield, tool_calls JSONmirrorAnthropicMessages(view)mirrorResponsesInput(view)/v1/responseslayout:inputitem array, assistant blocks in content order, reasoning itemsmirrorOpenaiToCore/mirrorAnthropicToCore/mirrorResponsesToCoreBiliMessage[]Byte-level wire rules are ported verbatim from the omp builders (whitespace-only text kept on openai, dropped on anthropic/responses; empty turns dropped; tool argument JSON shapes), so existing omp behavior is preserved exactly when it switches over.
Parity tests (
tests/wire-mirror.test.ts, 9 tests)reasoning_contentwire (issue compress: break identical-rejection retry death-loops #103)<think>wire (issue release v0.0.21: fix over-limit nudge spam + voice (review MAJOR-1/2) #64 demoted — relies on fix(wire): normalize inline demoted thinking into one identity space (issue #64) #112 normalization)Full suite: 413 pass, 0 fail (was 404).
tsc --noEmitclean.Follow-ups (separate PRs)
acp-kernel@0.0.35mirror constructors and deletes its three hand-rolled builders (~170 lines).