osp-provider-runtime
Thin, boring runtime harness for OSP providers.
This package handles RabbitMQ message plumbing so provider implementations can focus on business logic.
What it does
- Parses a versioned request envelope.
- Builds provider
RequestContext/ProviderRequestand callsexecute(...). - Dispatches optional read-only provider assessment RPCs without task execution.
- Emits canonical asynchronous task updates and synchronous control-RPC replies.
- Applies explicit ack/requeue/dead-letter decisions.
- Emits structured logs for delivery decisions.
- Supports explicit runtime knobs for prefetch/concurrency/retries/transport timeouts/DLQ.
- Accepts wire-version-4 request envelopes with task identity and cleared Gate keys separated from provider action payload.
- Provides
ProviderIdentityso providers derive the same RabbitMQ queue/binding, routing prefix, and lane name fromPROVIDER,PROVIDER_INSTANCE, and optionalPROVIDER_INSTANCE_ID.
Provider identity
Use a provider family for permissions and API requests, then add an instance only when you need a separate runtime lane:
from osp_provider_runtime import ProviderIdentity
identity = ProviderIdentity(
provider="nrec",
instance="pr",
instance_id=37,
)
identity.routing_prefix # "nrec.pr.37"
identity.request_queue # "provider.nrec.pr.37"
identity.request_binding # "nrec.pr.37.#"
identity.provider_lane # "nrec_pr"
The common case stays small: ProviderIdentity("vmware", "dev") gives the
vmware.dev routing prefix and vmware_dev lane name. Instance IDs refine
routing within a lane without changing its attribution name.
Result payload conventions
Provider results should keep ProviderResult.data focused on the resolved
values for the task. The runtime builds the full update payload envelope:
success: provider outcome flag;falsestill represents a completed no-op or degraded outcomeresolved: yourProviderResult.data(after runtime normalization)provenance: optional; extracted fromProviderResult.data["provenance"]produced_resources: typed provider-native references produced by the operation
Raise a ProviderError when the task should enter a failed lifecycle state.
ProviderResult(success=False) does not turn a completed outcome into a task
failure.
Special keys in ProviderResult.data:
progress_events(list): lifted into the update payload and removed fromresolvedto avoid duplicate TaskEvent rows.provenance(dict): lifted into the top-levelprovenancefield.
Providers may opt into live updates by accepting a keyword-only progress
argument on execute. Use ProgressReporter so the same action also works
without live delivery:
from osp_provider_contracts import ProducedResource, ProviderResult
from osp_provider_runtime import ProgressReporter
def execute(self, request, context, *, progress=None):
reporter = ProgressReporter(progress)
reporter.report("Creating virtual machine", {"stage": "openstack_create"})
vm = create_virtual_machine(request)
return ProviderResult(
success=True,
message="Virtual machine created",
produced_resources=(ProducedResource(kind="vm", ref=vm.id),),
data={"progress_events": reporter.events},
)
With a callback, the event is published live and reporter.events stays
empty. Without one, the event is returned through progress_events and the
runtime expands it from the terminal update. This keeps each event on one
delivery path. The callback is best-effort and transport-owned. request.action
is the sole action source.
Active task cancellation
The .cancellation.rpc control binding invokes the optional provider-owned
task_cancellation(task_ref) and cancel_task(task_ref) hooks on the separate
control executor. Providers report current backend capability and perform the
actual stop. A successful RPC only records the request; it emits no terminal
task update. The execution must finish with TaskCancelled(ProviderResult(...))
after confirmed termination, retaining any surviving resource references.
Providers without those hooks report unsupported cancellation.
Task logging
The runtime binds the task context once around execute() and emits one
task.summary event when the delivery finishes. Provider log sinks must use
JSON serialization so these fields are retained:
task_ref: stable provider execution UUIDdispatch_id: one delivery attemptproviderandtask_typestep,outcome, andduration_mserror.type,error.message, anderror.codewhen applicable
Use task_step("external.operation") around meaningful external operations.
It records the step in the summary trail and logs a full traceback before
re-raising failures. Task code must not bind correlation fields itself.
from osp_provider_runtime import task_step
with task_step("openstack.create"):
server = openstack.create_server(...)
Provider data is preserved inside result.resolved; its keys cannot override
the shared result fields. Runtime extracts the existing progress_events and
provenance metadata into their dedicated result fields.
The orchestrator already owns the original task request. Provider updates do not echo it; HTTP and CLI read models compose request and result when needed.
What it does not do
- No provider framework.
- No plugin system.
- No workflow orchestration.
Install
pip install osp-provider-runtime
Development
env -u VIRTUAL_ENV uv sync --extra dev
hatch shell
hatch run dev:check
hatch run dev:build
hatch run dev:verify
Runtime Knobs
Set these via RuntimeConfig in your provider runtime_app.py:
prefetch_count(default1)concurrency(default1)max_attempts(default5)idempotency_cache_max_entries(default1024)dead_letter_exchange(optional)dead_letter_routing_key(optional)heartbeat_seconds(default60)blocked_connection_timeout_seconds(default30)
Update Emission
Use TaskReporter for provider task lifecycle updates. The runtime keeps
transport details compatible with orchestrator consumers.
Docs:
docs/runtime-contract.mddocs/provider-updates.mddocs/migration-task-reporter.mddocs/runtime-upgrade-checklist.mddocs/release-notes-task-reporter.md
Tag and push:
git tag v0.2.0
git push origin v0.2.0
Release files for osp-provider-runtime 0.6.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| osp_provider_runtime-0.6.3.tar.gz | 66.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| osp_provider_runtime-0.6.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 114.9 kB
Release files / osp_provider_runtime-0.6.3.tar.gz
| Download URL | osp_provider_runtime-0.6.3.tar.gz |
|---|---|
| Size | 66.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cdd97b364649f9edd81cba049ce3d0d8099fdad6809d6e659bffc5572579c42d
|
|
BLAKE2b-256 checksum How to use checksums |
04ddba24d97933aaddcbbb89bda030af6c50893dadaee89bca3edcad54fe8b1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / osp_provider_runtime-0.6.3-py3-none-any.whl
| Download URL | osp_provider_runtime-0.6.3-py3-none-any.whl |
|---|---|
| Size | 48.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a6ac53bbdc3a46254f47ee0e9ae9395c39516259f2a4599539c4990a97dec67
|
|
BLAKE2b-256 checksum How to use checksums |
820af6c60c047feb33371c389a6bc207202800ffdabfdb09ea15556503ff60dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|