refactor(host_primitives): single home for the Turnkey wire envelope - #446
Draft
pepe-anchor wants to merge 1 commit into
Draft
refactor(host_primitives): single home for the Turnkey wire envelope#446pepe-anchor wants to merge 1 commit into
pepe-anchor wants to merge 1 commit into
Conversation
parser_gateway kept the Turnkey request/response types inline while the x402 branch had grown its own copy in host_primitives::turnkey. Two definitions of one wire contract means every envelope change (bootProof in #337, intermediateOutput in #414) has to be made twice and kept in sync by hand. Move them to host_primitives::turnkey as the union of both, and make bootProof an injected value instead of a hardcoded mock, so the enclave pivot can supply a real one while the gateway keeps its local-dev mock. No wire change: the gateway still emits the same mock constants, and the wire-shape tests move with the types. Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Aug 6, 2026
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.
Why
PRS-581 switches the parse path onto the enclave-side HTTP pivot. Two features have to be added to the response envelope on the way (
bootProoffrom #337,intermediateOutputfrom #414), and today that envelope is defined twice: inline inparser_gateway, and again on the unmerged x402 branch inhost_primitives::turnkey. Two definitions of one wire contract means every change gets made twice and kept in sync by hand, and the pivot would have made it three.This is the refactor that makes the rest of the stack cheap. It also shrinks the PR #304 rebase from "reconcile two envelope definitions" to "add a module".
What
host_primitives::turnkeybecomes the single home for the Turnkey request/response envelope, as the union of both existing definitions.bootProofis now an injected value rather than a hardcoded mock:error_response(msg, boot_proof).parser_gatewaykeeps its stable local-dev mock through a local shim; the enclave pivot will supply a real attested one.parser_gatewayimports the shared types and keeps the fourMOCK_BOOT_PROOF_*constants and their wire-shape tests.No wire change. The gateway's JSON output is byte-identical.
Test evidence
The two regression tests that matter both still pass and their constant values are unchanged:
mock_boot_proof_matches_production_wire_shape,error_response_carries_mock_boot_proof.One trap worth recording: the x402 branch's
TurnkeyResponseWrapperhad norename_all = "camelCase", which the gateway's inline struct did have. Addingboot_proofwithout it would have serialized asboot_proofinstead ofbootProofand silently broken the wallet contract. The six-key wire-shape test catches it.Rollback
Revert the commit. No deploy, no migration, no wire change, so a revert restores the previous state exactly.
Linear
PRS-581
Stack position: base of the PRS-581 stack. #337, #414.
🤖 Generated with Claude Code