Search ARuntime.com

Find runtime definitions and implementation guidance

Search page titles, summaries, headings, glossary terms, use cases, and runtime-directory entries.

Enter at least two characters.

ARuntime Reference

AI Runtime Examples

Runnable PHP reference examples demonstrate request validation, model routing, tool authorization, approval, idempotency, evidence creation, recovery, and trace correlation.

Audience: Technical readers Reading time: 2 minutes Status: Developer reference Last reviewed:

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.

Scope: educational reference, not a production SDK or model client.

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.

Tool permission check

The tool ID must appear in the request allowlist and resolve to a registered contract. The example refuses unlisted tools and does not interpret model prose as permission.

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”]

Maintenance record

Found an error, outdated capability, or unclear category boundary? Submit a correction with a supporting source.