RFC-0004: Runtime APIs and Event Contract¶
Status: Draft Date: 2026-05-26 Depends on: docs/rfcs/RFC-0001-ORCA-RUNTIME-BLUEPRINT.md
1. Scope¶
Define stable runtime surface contracts for:
- Python API.
- HTTP API.
- Event streaming contract.
2. Python API Target¶
runtime = OrcaRuntime.from_paths(
skills_path="skills/",
bindings_path="bindings/",
services_path="services/",
)
result = runtime.run("decision.make", inputs={...}, options={...})
result = await runtime.arun("decision.make", inputs={...}, options={...})
runtime.resume(run_id="run_...")
runtime.replay(run_id="run_...", from_step="score_options")
runtime.fork(run_id="run_...", from_checkpoint="chk_004")
runtime.approve(run_id="run_...", step_id="send_email", approver="alice")
runtime.deny(run_id="run_...", step_id="send_email", reason="wrong recipient")
async for event in runtime.astream(run_id="run_..."):
...
3. HTTP API Target¶
3.1 Run lifecycle¶
- POST /v1/runs
- GET /v1/runs/{run_id}
- POST /v1/runs/{run_id}/resume
- POST /v1/runs/{run_id}/replay
- POST /v1/runs/{run_id}/fork
- POST /v1/runs/{run_id}/cancel
3.2 Human-in-the-loop¶
- POST /v1/runs/{run_id}/approve
- POST /v1/runs/{run_id}/deny
3.3 Trace/checkpoint/events¶
- GET /v1/runs/{run_id}/trace
- GET /v1/runs/{run_id}/events
- GET /v1/runs/{run_id}/checkpoints
- GET /v1/runs/{run_id}/stream
4. Event Contract¶
Mandatory fields:
- event_id
- event_version
- event_type
- occurred_at
- run_id
- trace_id
- payload
Example:
{
"event_id": "evt_01J...",
"event_version": "1.0",
"event_type": "step.completed",
"occurred_at": "2026-05-26T12:00:05Z",
"run_id": "run_01J...",
"trace_id": "trc_...",
"payload": {
"step_id": "score_options",
"duration_ms": 842,
"checkpoint_id": "chk_004"
}
}
5. Event Types (v1)¶
- run.started
- run.resumed
- run.waiting_for_human
- run.completed
- run.failed
- step.started
- step.completed
- capability.selected
- binding.attempted
- side_effect.recorded
- side_effect.reused
- checkpoint.saved
6. Compatibility Rules¶
- EventStore contract is canonical source of runtime truth.
- Existing log event names remain as projection during migration.
- Existing HTTP routes remain available during migration window.
- New routes are additive now and become preferred contract immediately.
- Legacy routes/payload shapes are retired according to RFC-0006.
7. Collision Notes and Decision Proposals¶
-
Current /v1/runs payload is minimal and async-poll oriented. Decision: extend payload with additive fields (status detail, checkpoint_head, waiting context) while preserving existing fields during migration.
-
Current streaming exists for execute/stream callbacks but not canonical run event streams. Decision: preserve execute/stream temporarily and add run-scoped stream endpoint as canonical streaming surface.