The reference implementation is a standalone, non-destructive PHP 8.1+ program. It validates a request, selects a permitted model route, authorizes a local demonstration tool, writes an idempotent artifact, and returns minimized evidence.
Setup
unzip aruntime-reference-implementation-php.zip
cd php-reference
php runtime_reference.php runtime-request-minimal.json
The example writes only to a private temporary directory and makes no network requests.
Request validation
The program checks required fields, supported contract version, UTC timestamps, allowed trace behavior, and structured values. Production code should validate the complete JSON Schema and resolve identity from the authenticated transport.
Model routing decision
The example deterministically selects the first allowed route. A production router evaluates capability, deployment health, region, provider, privacy, latency, cost, and fallback constraints and records the reason.
Approval gate
If policy requires approval, the program stops rather than fabricating it. A durable production runtime persists the wait, releases compute, validates a real approver, and resumes only before expiry.
Idempotent tool call
The operation key maps to a deterministic temporary artifact. A duplicate call returns the existing result. Production tools should persist idempotency in the system that owns the side effect.
Evidence-record creation
The example emits request/correlation/trace identifiers, route, tool, result reuse, artifact hash, and redaction state without raw input. Production evidence follows the complete schema and retention policy.
Failure recovery
All exceptions become structured failure output and a non-zero process exit. Production recovery distinguishes parse, authorization, transient dependency, unknown-commit, compensation, and evidence failures.
Expected output and download
{
"status": "completed",
"route": "local.reference",
"authorization": {"decision": "allow"},
"evidence": {"eventType": "tool.completed", "redaction": {"rawInputsPersisted": false}}
}
[ar_downloads file=”aruntime-reference-implementation-php.zip”]
