100K Lines of Rust with AI: Contracts, Spec-Driven Dev, and Performance

Cheng Huang spent ~6 weeks building a Rust-based multi-Paxos consensus engine designed to modernize Azure's Replicated State Library (RSL). The project involved over 130K lines of Rust code (~100K written in 4 weeks by AI agents, plus 3 weeks of optimization) and achieved a throughput jump from 23K to 300K operations per second.
Huang used multiple AI coding agents: GitHub Copilot, Claude Code, Codex CLI, Augment Code, Kiro, and Trae. His primary setup now is Claude Code + Codex CLI from the terminal, with VS Code only for diffs and minor edits. He maintains two ChatGPT subscriptions to handle rate limits (one Mon-Wed, one Thu-Sun).
Code Contracts — Written by AI
The core correctness strategy: AI-generated code contracts that specify preconditions, postconditions, and invariants for critical functions, converted into runtime asserts during testing. Huang found GPT-5 High writes excellent contracts; Opus 4.1 is good but requires more review. For example, the process_2a method (handling Paxos phase 2a messages) has 16 contracts. Contracts are then used to generate targeted test cases and property-based tests that explore randomized inputs — one contract caught a subtle Paxos safety violation that could have caused replication consistency issues.
Lightweight Spec-Driven Development
Huang initially tried a rigid spec-driven approach: requirement markdown → design markdown → task list markdown. He found it too inflexible for iterative changes. He now uses a lighter-touch SDD: start with a concise spec, let AI generate code, then refine contracts and tests iteratively. The full system includes 1,300+ tests spanning unit, integration, and multi-replica failure injection tests.
Performance Optimization
The optimization phase (3 weeks) boosted throughput from 23K to 300K ops/sec. Key architectural changes: added pipelining (requests no longer wait for in-flight votes), support for non-volatile memory (NVM) to reduce commit time, and RDMA awareness for modern Azure datacenter hardware.
What's Next
Huang wishes for better AI support for property-based test generation from contracts and more seamless handling of breaking changes in codebases above 100K lines.
📖 Read the full source: HN AI Agents
👀 See Also

OpenClaw LLM Timeout Fix for Cold Model Loading
A Reddit user identified and fixed a specific timeout issue in OpenClaw where cold-loaded local LLMs would fail after about 60 seconds, even with higher general timeouts set. The solution involves adjusting the embedded-runner LLM idle timeout configuration.

Using a GAN-style prompt to improve Claude's critical thinking
A Reddit user shares a specific sentence to prompt Claude to adopt a GAN-style thinking framework, forcing it to critique and pressure-test ideas instead of providing agreeable surface-level responses.

Optimizing CLAUDE.md to Reduce Context Anxiety in Claude AI
A Reddit discussion highlights practical strategies for improving CLAUDE.md effectiveness, including keeping files under 200 lines, using specific verifiable instructions, and leveraging Claude's auto-memory features to prevent token-wasting correction loops.

Running a Fully Local AI Agent on a 6GB VRAM Laptop: A Step-by-Step Guide for Students
Explore how students can leverage 6GB VRAM laptops to run AI agents locally, without relying on costly APIs. Our guide breaks down essential steps and tools.