Files
papers/lp-201-zap-universal-wire/paper.tex
zeekay 010d5ad016 papers: LP-201 ZAP as Universal Wire + Tier-1 status reflecting current session
Inventory captures stack-wide ZAP coverage; rows updated to reflect this
session's landings:
  - lux/utxo: linearcodec rip closed (commit luxfi/utxo@559e482) — Tier 5 DONE
  - hanzo/agent: cross-process ZAP wire shipped (commit hanzoai/agent@ecf7ff6) —
    Tier 5 DONE via HANZO_AGENT_WIRE=zap feature flag, default JSON path
    preserved for OpenAI compat
  - hanzo/mcp: MCP<->browser ZAP path shipped (zap-server.ts wired into
    both index.ts and cli.ts) — MCP<->MCP federation client-side is the
    remaining gap

Paper body: threat-equivalent inventory + bench claims (7.50x parse geomean
LP-023 measured, 7.4-8.6x compounded stack-wide, 24x alloc reduction,
14x fewer GC runs) + Tier 1 URGENT list. Risks section flags Tier 4
external-boundary services (binance/coinbase/stripe/plivo/openai/anthropic)
as DO-NOT-MIGRATE.
2026-06-10 22:35:37 -07:00

130 lines
5.0 KiB
TeX

% LP-201 -- ZAP as Universal Wire
% Build with: make (uses tectonic; fall back to make pdflatex)
\documentclass[11pt,a4paper]{article}
\usepackage{../shared/luxcover}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amssymb,amsfonts,bm}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{float}
\usepackage{enumitem}
\usepackage{array}
\usepackage{multirow}
\usepackage{tabularx}
\hypersetup{colorlinks=true,linkcolor=black,citecolor=blue,urlcolor=blue}
\lstset{
basicstyle=\ttfamily\scriptsize,
breaklines=true,
frame=single,
numbers=left,
numberstyle=\tiny\color{gray},
showstringspaces=false,
}
\title{LP-201 --- ZAP as Universal Wire: A Cross-Stack Audit and
Migration Plan for the Hanzo, Lux, and Liquidity Surfaces}
\author{Lux Industries}
\date{June 2026}
\begin{document}
\luxcoverpage
\maketitle
\begin{abstract}
ZAP is the canonical zero-copy wire protocol in the Lux substrate
(\texttt{luxfi/zap}), specced as ZAP-PQ-v1 with X25519$+$ML-KEM-768
hybrid handshake and ML-DSA-65 identity~\cite{zappqspec}. Today ZAP is
shipped end-to-end across (a)~Lux consensus and chain VMs
(\texttt{node/vms/proposervm}, \texttt{node/vms/evm},
\texttt{node/vms/platformvm/warp}, \texttt{chains/*/wire}), (b)~the
Hanzo control plane (\texttt{hanzo/kms},
\texttt{hanzo/datastore/cmd/zap-bridge}, \texttt{hanzo/gateway},
\texttt{hanzo/iam}, \texttt{hanzo/base}, and the TypeScript encoder
\texttt{hanzo/zap-es}), and (c)~Liquidity's regulated ATS/BD/TA stack
(\texttt{liquidity/ats}, \texttt{liquidity/bd}, and the Rust port at
\texttt{liquidity/operator/src/zapclient.rs}). It is \emph{not} yet
shipped on three high-frequency AI surfaces: the Hanzo agent
control-plane (JSON-RPC + HTTP + gRPC), the MCP server (JSON-RPC over
stdio), or the Jin multimodal model server (JSON manifests + pickle/pt
tensor blobs); these three are the largest open migration delta in the
workspace. Independent benchmarks against MCP JSON-RPC report
$17\times$ serialisation speedup, $345\times$ parse speedup, $91.2\%$
memory-allocation reduction and $96.7\%$ allocation-count
reduction~\cite{zapreadme}; LP-023 measured $7.50\times$ Parse geomean
on \texttt{vms/platformvm/txs/zap\_native} relative to
\texttt{linearcodec}~\cite{lp023zapnative}. This paper inventories the
state of ZAP coverage across the three stacks
($\sim$$15$ Lux services, $\sim$$10$ Hanzo services,
$\sim$$8$ Liquidity services), classifies each surface in a 5-tier
model, and proposes a phased rollout that closes the open delta
without introducing backwards-compat shims. Projected stack-wide
end-to-end speedup on the AI/ML/blockchain hot path is
$\bm{7.4}$--$\bm{8.6\times}$ with a $\bm{24\times}$ allocation
reduction, compounding LP-023 against the ZAP-vs-JSON-RPC ratio.
\end{abstract}
\tableofcontents
\vspace{1em}
\section{Introduction}
\label{sec:intro}
The Hanzo/Lux/Liquidity workspace runs three nominally distinct
products~--- an AI platform (Hanzo), a blockchain platform (Lux), and
a US-regulated securities ATS$/$BD$/$TA (Liquidity)~--- on a shared
substrate. Every inter-process call in that substrate has historically
chosen a wire format independently: \texttt{linearcodec} on the chain,
JSON-RPC across the agent/MCP layer, \texttt{protobuf} for some gRPC
shims, vendor JSON over HTTP at the external boundary. The resulting
heterogeneity has two costs:
\begin{enumerate}[leftmargin=*]
\item \textbf{Performance.} Every wire boundary pays an encode and a
decode tax. JSON-RPC parse on a $20$-tool MCP orchestrator round
is measured at $109{,}175$~ns/op with $54{,}292$~B and $1{,}060$
allocations~\cite{zapreadme}. At the fleet-wide call rate this is
a dominant component of CPU and GC pressure.
\item \textbf{Composability.} Heterogeneous wires defeat
re-composition: a service speaking JSON cannot be wrapped by a
service expecting protobuf without an adapter, and adapters
accumulate at every layer boundary.
\end{enumerate}
ZAP is the workspace's answer to both costs. It is a zero-copy
segment-pointer wire (single allocation per parse, fixed-stride field
access, no reflect, no schema lookup at decode), specced once and
implemented in Go (\texttt{luxfi/zap}), Rust
(\texttt{liquidity/operator/src/zapclient.rs}, verbatim wire-compatible
per its module header), and TypeScript
(\texttt{hanzo/zap-es} npm package). The handshake layer is ZAP-PQ-v1,
a Noise-style hybrid post-quantum transport replacing any TLS/Noise
layer underneath the data plane~\cite{zappqspec}.
This paper is the audit step. It answers three questions:
\begin{itemize}[leftmargin=*]
\item Which surfaces \emph{already} run ZAP today? (Tier 5)
\item Which surfaces should run ZAP and currently don't? (Tier 1--3)
\item Which surfaces are out of scope because they talk to external
parties? (Tier 4)
\end{itemize}
\input{sections/inventory}
\input{sections/proposal}
\input{sections/bench}
\input{sections/risks}
\bibliographystyle{plain}
\bibliography{references}
\end{document}