Files
papers/lp-201-zap-universal-wire/sections/proposal.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

108 lines
5.3 KiB
TeX

% sections/proposal.tex -- ZAP-everywhere migration proposal
\section{Proposal: ZAP everywhere}
\label{sec:proposal}
\subsection{Tier model}
Each non-ZAP surface is classified by frequency on the call graph, not by
team or repository:
\begin{description}[leftmargin=0pt,style=nextline]
\item[Tier~1 (Hot path).] High-frequency wire: per-block, per-tx,
per-RPC, per-tool-call. Cost of a non-ZAP byte is paid in CPU,
allocations, GC pressure, and tail latency on every transaction.
\emph{Action: URGENT migrate.}
\item[Tier~2 (Warm path).] Per-session, per-handshake, per-page-load.
Cost is paid once per user session but compounds at fleet scale.
\emph{Action: SCHEDULED migrate.}
\item[Tier~3 (Cold path).] Boot, config, admin, one-shot CLI. Cost is
negligible per call but format heterogeneity is a maintenance tax.
\emph{Action: OPPORTUNISTIC migrate.}
\item[Tier~4 (External boundary).] Talks to third parties whose wire
we do not own (Binance, Stripe, OpenAI, Plivo). \emph{Action: keep
external format; tunnel internal hops in ZAP only.}
\item[Tier~5 (Already ZAP).] Verified zap-native today.
\end{description}
\subsection{Top-5 URGENT Tier-1 targets}
The following surfaces are simultaneously (a)~highest-frequency wire on
the call graph and (b)~currently zero-ZAP. They unlock the largest
absolute bench delta per engineering hour invested.
\begin{enumerate}[leftmargin=*]
\item \textbf{P-Chain blocks + tx codec.}
\texttt{lux/protocol/p/\{txs,block,warp,state\}/*.go} plus the
\texttt{vms/platformvm} composition root. LP-023 already measured
$7.50\times$ Parse geomean on the zap\_native subtree
benchmarks~\cite{lp023zapnative}. Blocked on \texttt{lux/utxo}
completing its ZAP migration so the cross-chain UTXO wire
stabilises.
\item \textbf{X-Chain UTXO wire.}
\texttt{lux/protocol/x/txs/*.go}~--- identical shape to the
P-Chain migration; same $7.50\times$ Parse projection applies. Can
be migrated in parallel with~(1) since the codec is structurally
isomorphic.
\item \textbf{Hanzo Agent control-plane.}
\texttt{hanzo/agent/control-plane/internal/\{handlers, services,
cli, mcp, infrastructure/communication\}}. Currently
JSON-RPC$+$HTTP$+$gRPC heterogeneous mix on every agent-to-agent
tool call. ZAP/MCP-bridge bench shows $17\times$ serialisation,
$345\times$ parse, $91\%$ memory reduction
(\texttt{zap/README.md}~\cite{zapreadme}); apply that ratio to the
$\sim$$140{,}000$ calls/sec baseline measured in
\texttt{BenchmarkMCPOrchestrator20Tools}.
\item \textbf{Hanzo MCP server.}
\texttt{hanzo/mcp/go/*.go} plus \texttt{rust/}, \texttt{src/}. The
canonical MCP wire is JSON-RPC over stdio; a ZAP transport variant
(the \texttt{luxfi/zap/mcp} bridge) already exists. The migration
is a transport swap, not a protocol change~--- tool authors keep
writing the same MCP schemas; only the bytes on the wire change.
\item \textbf{Hanzo Jin tensor wire.}
\texttt{hanzo/jin/jepa/} multimodal model server uses
framework-native serialisation (JSON manifests + pickle/pt tensor
blobs). A ZAP tensor schema (typed fixed-stride leaves over the
ZAP segment) replaces both manifest and blob with a single
zero-copy frame. The bench delta is not yet measured but the
structural argument is identical to the
\texttt{BenchmarkZAPOrchestrator20Tools} result:
deserialise-by-pointer instead of allocate-and-decode.
\end{enumerate}
\subsection{Phased rollout, by dependency}
\begin{description}[leftmargin=0pt,style=nextline]
\item[Phase~A~--- consensus completion.] Finish what LP-023 and the
\texttt{utxo} ZAP migration started: empty the
\texttt{FINAL\_CODEC\_RIP} ledger, delete \texttt{luxfi/codec} from
the production tree, and rip the duplicate \texttt{lux/proto/}
snapshot.
\item[Phase~B~--- AI/ML hot wire.] Agent, MCP, Jin migrations in
parallel. These have no inter-dependency on Phase~A; gating only
requires the canonical \texttt{luxfi/zap} reference
(\texttt{zap-es} for TS clients) which is already shipped.
\item[Phase~C~--- gateway internal tunnels.] \texttt{zen/gateway}
keeps OpenAI/Anthropic/Together JSON outbound (Tier~4) but
Hanzo$\to$Hanzo back-plane traffic moves to ZAP-tunnelled hops.
\item[Phase~D~--- legacy cleanup.] Delete \texttt{lux/proto/} (Tier~3
duplicate). Re-verify zero \texttt{luxfi/codec} imports across the
entire workspace.
\end{description}
\subsection{Constraints and external boundaries}
\begin{itemize}[leftmargin=*]
\item Tier~4 boundaries (market data, payments, third-party LLM
inference) are kept on their vendor formats. The ``ZAP everywhere''
claim is bounded by what Hanzo, Lux, and Liquidity \emph{own}.
\item The Quasar activation at unix~$1766708400$
(2025-12-25T16:20:00-08:00) is the cut-over point: every L1 EVM
boots from canonical genesis with ZAP-only wire from block zero
forward (memory \texttt{network\_activation\_2025\_12\_25}).
Pre-activation P/X blocks remain decodable via the v0 legacy
decoder retained in \texttt{node/vms/platformvm/block/v0}.
\item No backwards-compat shim is introduced. Following the
workspace rule ``forwards perfection only,'' migrated code paths
have one wire (ZAP) and one composition root.
\end{itemize}