\section{Certificate Preservation}\label{sec:preservation}

The correspondence in Section~\ref{sec:correspondence} would be merely descriptive if structural guarantees could not survive compilation. This section specifies the preservation checks used by the implementation.

\subsection{Compiler Functors}

A \textbf{compiler functor} $F: \mathrm{Arch}(\text{Source}) \to \mathrm{Arch}(\text{Target})$ maps one architecture to another. In our implementation, each compiler produces a serializable configuration dict for a specific orchestration framework:

\begin{itemize}[leftmargin=*]
\item \texttt{organism\_to\_swarms}: Operon $\to$ Swarms graph workflow
\item \texttt{organism\_to\_deerflow}: Operon $\to$ DeerFlow LangGraph session
\item \texttt{organism\_to\_ralph}: Operon $\to$ Ralph hat configuration
\item \texttt{organism\_to\_scion}: Operon $\to$ Scion grove deployment
\item \texttt{organism\_to\_langgraph}: Operon $\to$ LangGraph StateGraph
\end{itemize}

Each compiler is wrapped in a \texttt{CompilerFunctor} class that automatically extracts source and target architectures, verifies the functor laws, and produces a \texttt{PreservationResult} with three checks:

\begin{enumerate}[leftmargin=*]
\item \textbf{Graph preservation}: source stage names $\subseteq$ target stage names, source edges $\subseteq$ target edges.
\item \textbf{Certificate replay invariant}: source certificate theorems $\subseteq$ target certificate theorems, source parameters/evidence are preserved, and all certificates \texttt{verify()} $\to$ \texttt{holds=True}.
\item \textbf{Deployment-map preservation}: source stage names present in target (mode mapping may differ).
\end{enumerate}

\subsection{The LangGraph Compiler}

The LangGraph compiler \texttt{organism\_to\_langgraph()} creates one LangGraph node per organism stage. Each node calls \texttt{organism.run\_single\_stage()}---the same per-stage method that \texttt{organism.run()} uses internally. Conditional edges route based on the return value: \texttt{"continue"} proceeds to the next stage, \texttt{"halt"} or \texttt{"blocked"} routes to the graph's terminal node.

This design avoids the reimplementation trap: an earlier attempt that encoded component logic directly as LangGraph nodes required 10 rounds of code review to achieve behavioral parity with \texttt{organism.run()}.  By extracting \texttt{run\_single\_stage()} from the run loop and calling it from both paths, the LangGraph graph uses the \emph{same code path} as the native runtime---zero reimplementation.

\paragraph{Implementation invariant (per-stage certificate replay).}
The LangGraph compiler preserves certificate replay for organisms whose certificates use the supported component hooks (CertificateGate, VerifierComponent, WatcherComponent). Such certificates verify after compilation because each stage node executes with those hooks intact, and interventions (RETRY, ESCALATE, HALT) are handled within the node before routing.

The per-stage graph also provides LangGraph-native observability: each stage appears as a visible node in LangGraph Studio, enabling inspection of individual stage execution, timing, and intervention decisions.  The tested certificates hold because \texttt{run\_single\_stage()} preserves the hooks and parameters they replay, not because they are independent of every possible graph topology.

\paragraph{Parallel stage groups.}
Organisms with parallel stage groups compile to a fork/join topology using LangGraph's native \texttt{Send} API.  Each parallel group generates three types of infrastructure nodes: a \emph{fork} node that snapshots state and dispatches isolated copies to each stage via \texttt{Send}, the individual \emph{stage} nodes (one per parallel stage, calling \texttt{run\_single\_stage()} as usual), and a \emph{join} node that merges results using the same conflict-detecting merge logic as the native runtime.  Sequential organisms are unchanged---each stage maps to a single node as before.

Certificate replay holds for the supported certificates in parallel groups because each stage node still calls \texttt{run\_single\_stage()} with full component hooks.  The fork/join infrastructure is purely topological---it manages state isolation and result aggregation, not structural guarantees.

\subsection{Empirical Verification}

We verify the implementation invariant across the five compiler targets, with LangGraph checked through per-stage execution rather than the configuration-dict path:

\begin{center}
\small
\begin{tabular}{@{}lccc@{}}
\toprule
\textbf{Compiler} & \textbf{Graph} & \textbf{Certificates} & \textbf{Interface} \\
\midrule
Swarms & $\checkmark$ (1:1) & $\checkmark$ (100\%) & $\checkmark$ \\
DeerFlow & $\times$ (hub-spoke) & $\checkmark$ (100\%) & $\checkmark$ \\
Ralph & $\times$ (hats) & $\checkmark$ (100\%) & $\checkmark$ \\
Scion & $\checkmark$ (+watcher) & $\checkmark$ (100\%) & $\checkmark$ \\
LangGraph & $\checkmark$ (per-stage) & $\checkmark$ (100\%) & $\checkmark$ \\
\bottomrule
\end{tabular}
\end{center}

Across the five compiler targets tested, the three supported certificate types preserve identity and verify. Swarms and LangGraph preserve per-stage structure. DeerFlow reshapes to hub-and-spoke. Ralph converts to hat patterns. Scion adds a watcher agent. In these tests, the structural guarantees survive because they are $\mathrm{Know}$-level replay artifacts whose hooks and parameters are preserved; the tested certificates do not depend on exact graph topology beyond those hooks and parameters.
