pilotphp / runtime-roadrunner
RoadRunner HTTP and gRPC worker adapter for the PilotPHP Agent-First framework.
Requires
- php: ^8.5
- google/common-protos: ^3.1 || ^4.0
- google/protobuf: ^3.7 || ^4.0 || ^5.0
- pilotphp/contracts: ^0.1.2
- pilotphp/grpc: ^0.1.4
- pilotphp/http: ^0.1.4
- pilotphp/runtime: ^0.1.2
- psr/http-factory: ^1.1
- psr/http-message: ^2.0
- psr/log: ^3.0
- spiral/roadrunner-grpc: ^3.6
- spiral/roadrunner-http: ^4.1
- spiral/roadrunner-worker: ^3.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.88
- nyholm/psr7: ^1.8
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^11.5
README
RoadRunner worker adapter for the PilotPHP Agent-First framework.
pilotphp/runtime-roadrunner connects long-lived RoadRunner HTTP and gRPC
worker processes to PilotPHP transport applications (HttpApplication,
GrpcApplication). It owns the receive/respond loop, process boot/shutdown
gate, transport ports, and worker error/recycle policy. It does not compile
artifacts, assemble the application container, or dispatch operations directly.
Requirements
- PHP 8.5+
pilotphp/contracts^0.1.2pilotphp/runtime^0.1.2pilotphp/http^0.1.4pilotphp/grpc^0.1.4- Spiral RoadRunner worker packages (
spiral/roadrunner-http,spiral/roadrunner-grpc,spiral/roadrunner-worker)
Install
composer require pilotphp/runtime-roadrunner
Discovery uses the fixed path pilot/package.json inside the Composer package
root. This package does not publish extra.pilotphp.manifest.
Note: pilotphp/http and pilotphp/grpc may not yet be on Packagist.
See docs/blockers.md for local development workarounds.
Modes
| Mode | Worker loop | Transport application | Reset owner |
|---|---|---|---|
| HTTP | RoadRunnerHttpWorkerLoop | HttpApplication | HttpApplication |
| gRPC | RoadRunnerGrpcWorkerLoop | GrpcApplication | HostRequestCycle + InvokeTrackingKernel |
Each mode uses a separate RoadRunner worker entry script and .rr.yaml plugin
section. See examples/ and docs/rr-configuration.md.
Bootstrap sketch
Build and artifact loading happen outside this package. The application owns composition; the worker only loads finalized bytes and runs the loop.
# Build time (CI / deploy, NOT in worker)
php bin/pilot build
→ finalized artifacts (http/route-map.json, grpc/method-map.json, container, …)
# Worker boot (application bootstrap)
require vendor/autoload.php
→ App\RuntimeAssembler loads artifact bytes
→ constructs ContainerInterface, KernelInterface, transport apps
→ wraps kernel with InvokeTrackingKernel (gRPC only)
→ RoadRunnerHttpWorkerLoop or RoadRunnerGrpcWorkerLoop::run()
Who does what:
| Concern | Owner |
|---|---|
Build (php bin/pilot build) | Application / pilotphp/build |
| Load artifact bytes | Application bootstrap |
Assemble RuntimeKernel, container, dispatch graph | Application / RuntimeAssembler |
| Boot / shutdown | WorkerLifecycle via WorkerProcessGate |
| Per-request reset (HTTP) | HttpApplication |
| Per-request reset (gRPC) | HostRequestCycle + InvokeTrackingKernel |
| Receive/respond loop | This package |
Non-goals
- Running
pilotphp/buildor any build stage inside a worker - Depending on
pilotphp/operation,pilotphp/container, orpilotphp/app - Registering compile-time metadata (
register()is intentionally empty) - Publishing a
BuildStageor finalized artifact schema - Replacing
HttpApplication/GrpcApplicationrouting or mapping logic - Using
Spiral\RoadRunner\GRPC\Serverreflection-based service registration
Public API (summary)
| Type | Role |
|---|---|
RoadRunnerRuntimePackage | Package identity; empty register() |
RoadRunnerHttpWorkerLoop | HTTP wait → handle → respond loop |
RoadRunnerGrpcWorkerLoop | gRPC wait → decode → handle → respond loop |
RoadRunnerHttpWorkerPort | Production HTTP transport port |
RoadRunnerGrpcWorkerPort | Production gRPC payload port (no Server::registerService) |
WorkerProcessGate | Boot once, job counting, recycle, shutdown |
HostRequestCycle | gRPC per-job scope + reset (HTTP must not use this) |
InvokeTrackingKernel | Required gRPC kernel decorator |
RoadRunnerWorkerOptions | Adapter recycle and error policy |
WorkerExitCode | Process exit outcome enum |
Documentation
- docs/architecture.md
- docs/dependency-boundaries.md
- docs/lifecycle.md
- docs/http-worker.md
- docs/grpc-worker.md
- docs/error-policy.md
- docs/reset-and-request-scope.md
- docs/deployment.md
- docs/rr-configuration.md
- docs/observability.md
- docs/security.md
- docs/testing.md
- docs/blockers.md
- AGENTS.md
Examples
Illustrative worker entry scripts and minimal RoadRunner configs:
Examples are not executable application skeletons — they show bootstrap
shape with placeholder App\RuntimeAssembler comments.
License
MIT