Skip to main content

MEP-55 research bundle: Mochi to PHP 8.4 transpiler

Author: research pass for MEP-55 (Mochi-to-PHP 8.4 transpiler). Date: 2026-05-29 15:00 (GMT+7).

This bundle contains the thirteen research notes that informed MEP-55, the Mochi-to-PHP 8.4 transpiler. The notes are informative; the normative spec is in the MEP body.

#TitleTopic
01Language surfaceMochi language surface mapped onto PHP 8.4 lowering obligations: scalars, collections, records, sum types, closures, match, loops, query DSL, phase corpus
02Design philosophyWhy PHP, why PHP 8.4 floor, why declare(strict_types=1), why sync wrappers not Amp/Revolt, why final readonly class for records, why abstract readonly class bases, why DJB2/GMP, why Phar over box
03Prior art: transpilersSurvey of source-to-PHP tools (Hack/HHVM, Haxe PHP target, Dart2PHP); PHP version history; why 8.4 is the minimum; why a direct aotir→ptree→emit approach
04RuntimeThe mochi/runtime Composer package: directory structure, IO class, @api annotation, devDependencies (Psalm 6, PHPStan 1.12, php-cs-fixer), zero runtime deps, required extensions
05Codegen designaotir → ptree → emit pipeline: ptree node types, runtimeFlags struct, mochi__ prefix, emit pass, pipeline wiring in Driver.Build
06Type loweringPer-Mochi-type lowering rules for every type: int, float, bool, string, list, map, set, record, sum type, closures, function types, Result, panic
07PHP target portabilityPHP ecosystem portability: CI matrix (8.4.0 / 8.4 / 8.5 allow_failure), phar.readonly=0, FrankenPHP vs RoadRunner, Composer 2, Packagist, server-model implications
08Dataset pipelineQuery DSL lowering (from/where/select/order-by/skip/take onto PHP arrays + usort), Phase 8 Datalog compile-time semi-naive evaluation, static array literal output
09Agents and streamsPhase 9 agents (mutable PHP class), Phase 10 streams (MochiStream/MochiSub fan-out, backpressure), Phase 11 async coloring (all-Blue, sync wrappers)
10Build systemDriver.Build pipeline, resolvePhp, effectiveCacheDir + cacheKey (reserved), Phase 17 packaging (emitPharStager, EmitFrankenPHPBundle, EmitRoadRunnerBundle), CI workflow
11Testing gatesPer-phase test structure, runPhpFixture, TestPhaseNEmitFragments, TestPhase13DJB2HashMatchesCassetteFilenames, runPhpLLMFixture, runPharFixture, TestPhase17AllTargetsTogether, two-tier strategy
12Risks and alternativesRisk register: PHP scheduling, PHP_INT_MAX DJB2 overflow, Psalm 5 vs 6, abstract readonly inheritance, phar.readonly, amphp/revolt removal, live LLM deferral, PHP 8.5 allow_failure

Cross-references