HeadlinesBriefing favicon HeadlinesBriefing.com

AI-Built PHP Engine in Rust Achieves 17% Test Pass Rate

Hacker News •
×

Phargo, an AI-generated PHP interpreter written in Rust, has reached a 17.4% pass rate on PHP’s 22,037-unit test suite. This engine, developed without prior Rust or lexer expertise, interprets PHP code from scratch. The project’s uniqueness lies in its reliance on an unbiased oracle: PHP’s official test suite, written by core developers over decades, evaluates every edge case from date math to var_dump() quirks. The human role is reduced to oversight: the AI identifies failing test clusters, implements fixes, and reruns the suite. A key breakthrough came when normalizing line endings matched PHP’s test runner, flipping hundreds of tests from red to green. The engine’s progress, though slow, demonstrates AI’s potential to audit complex codebases autonomously.

The 22,000 tests act as a stress test for Phargo, exposing both technical and conceptual flaws. Early failures included Palmtrees’ clone function returning NULL and Date Time immutables breaking due to unhandled operations. The team added safeguards like a 6GiB memory cap and step limits to prevent crashes from pathological tests. One notable issue arose from test harness misalignment: the scoreboard initially failed multi-line tests due to mismatched CRLF line endings. Fixing this required mirroring PHP’s normalization logic. The engine’s ability to parse and execute WordPress code—including gotos and regex edge cases—highlights its evolving capability. However, performance lags at ~55x slower than native PHP remain a hurdle.

Rendering a WordPress front page marked a milestone. The engine successfully booted wp-load.php, populated a database, and displayed posts without critical errors. While the REST API remains untested, the demo proved PHP’s idiosyncrasies—like by-reference str_replace parameters—could be navigated. This experiment challenges assumptions about AI-generated code reliability. By outsourcing quality assurance to an unbiased test suite, Phargo proves that human intuition isn’t always necessary for catching subtle bugs. The project’s transparency—publishing raw test results and failure modes—sets a precedent for verifiable AI-assisted development. The 17% pass rate, while modest, is a quantifiable step toward bridging the gap between AI-generated code and real-world compatibility.