Where to measure equivalence when porting a coding agent

Porting an open-source coding agent to a constrained platform: where to measure equivalence, why the original should generate the expected outputs, and why a findings ledger beats a parity score.

October 20264 min readPortingVerificationPlatformsPorting a production coding agent

Wet teal green and saffron curves blend at left, stubby plum strokes press together with chalk flickers at right, and warm grey is scrubbed down the centre.
On this page
  1. Reuse before new platform capabilities
  2. Accounting for every upstream file
  3. Measuring equivalence at observable boundaries
  4. A findings ledger instead of a parity percentage

A port that compiles cleanly and passes its unit tests is easy to declare complete, even when nobody can say what it does if a user steers an active turn mid-tool-call or a worker restarts between a side effect and its publication. Translating module by module against local tests is reasonable for stateless libraries, where types and return values capture most of the contract. For a persistent coding agent, the behavior that matters spans long-running sessions, mid-turn steering, generated code execution, conversation forks, recovery, and multi-provider state, none of which module-level tests reliably exercise.

That makes a coding agent close to the hardest tenant for a constrained platform. Ferrite, the constrained Rust cloud platform I have been building, gives applications a single SDK dependency, signed source packages, and a hard-capped AI gateway while offering no shell, local filesystem, or raw sockets. To test whether serious software can run on those primitives alone, I ported Pi, an open-source persistent coding agent written in TypeScript by its maintainers and contributors, into roughly 175,000 lines of application Rust. Rather than judging the port through code review and handwritten tests, I used differential verification at the boundaries where a divergence becomes externally visible or a side effect can execute twice, letting a pinned version of Pi generate the expected outputs.

In the Rust port, the session journal, scheduler, context assembly, tool dispatch, and provider adapters run natively. Agent-generated JavaScript executes inside QuickJS, an embeddable JavaScript engine, on a WebAssembly interpreter scoped to the conversation’s capability grants, and every model call passes through Ferrite’s AI gateway. Getting the port this far in four days in November 2026 showed that the verification method transfers cleanly when the language and runtime change.

Reuse before new platform capabilities

Porting a complex system onto a constrained platform invites a predictable failure mode: widening the platform whenever the port hits friction until you have quietly built a bespoke runtime for one application. To keep the port a test of Ferrite rather than a fork of it, every requirement from Pi was first checked against what the platform already provided. Sandboxed code execution, durable publication, the AI gateway, MCP, and the Agent Client Protocol (ACP) were all mapped to existing primitives and signed packages. The operating rule stayed simple: a missing method in one SDK surface is not evidence that Ferrite has no solution.

Accounting for every upstream file

Differential checks only cover the paths you execute against them, so verification starts with a complete inventory of the upstream codebase. Every one of Pi’s roughly 4,700 files was audited by independent reviewers owning disjoint areas, working in batches of six files or fewer. Each file path received an explicit disposition backed by evidence from both codebases, with no paths left pending. That pass produced a ledger of about 1,000 findings to which subsequent fixes attach directly.

Measuring equivalence at observable boundaries

Having a reviewer read a port and write assertions from the translated code lets the same omissions slip into both the implementation and the test suite. Running a pinned commit of Pi as the oracle removes interpretation from the expected outputs and anchors verification to actual upstream behavior.

Equivalence is checked at five boundaries where a difference alters external state or risks double execution: the request bytes sent to a provider, the ordering of emitted events, tool results, the moment an effect commits, and recovery after interruption. Timestamps and generated identifiers are normalized only where identity relationships and ordering constraints survive.

One verified journey exercises steering, side effects, and spend controls together. The session owner sends a prompt, then a steer while the first gateway response is held open; a write tool commits to the conversation’s isolated workspace, and the second provider request carries the real tool result ahead of the steer. The sponsoring account is debited once, a replay adds no charge, and the next request stops at the daily cap without a third provider call. Recovery is tested under deployment conditions as well: on a hosted instance, a completed turn survived scaling the application to zero replicas and back up with the conversation intact.

A findings ledger instead of a parity percentage

Once a findings ledger and a replay suite exist, the usual shortcut is to divide passing checks by total items and publish a parity percentage. That arithmetic breaks down because a single finding can span several independently testable behaviors while another covers a narrow edge case; a test count or a linked finding does not give a percentage of equivalence, only false precision over an arbitrary denominator.

An explicit ledger also separates unfinished porting work from structural platform boundaries. About 35 findings in this port depend on process execution, a PTY, or stdio transport, capabilities Ferrite deliberately omits from its application surface. Instead of weakening the isolation model or working around them in application code, those gaps stay recorded in the ledger and go into platform proposals.

Chris Chabot, October 2026