Skip to main content
Version: 0.4.x(Latest)

Overview​

Runtime() is a capability exclusive to dynamic plugins. Dynamic plugins run within the WASM guest boundary and cannot directly access host-process logging, time, node identity, or local state implementations. They therefore need to call host-provided runtime primitives through service: runtime.

Source plugins already run inside the host process and typically use native host logging, request context, and injected domain services directly, so they do not need the Runtime() wrapper.

Capability Phase: Runtime

Supported Types: Dynamic plugins

Design Philosophy​

Dynamic Plugin Exclusive Entry Point​

Runtime() lives in pluginbridge.Services and does not belong to the capability.Services standard domain capability directory. It serves the dynamic plugin bridge runtime environment rather than business domain data access.

Boundary with Infra()​

Runtime() reads dynamic plugin runtime primitives; Infra() reads infrastructure component state. The two are not interchangeable:

CapabilityBoundaryPrimary Responsibility
Runtime()Dynamic plugin exclusiveLogging, plugin state, time, UUID, and node identity
Infra()Shared between source and dynamic pluginsInfrastructure component state views

If a dynamic plugin needs to check whether an infrastructure component is available, it should declare service: infra rather than treating runtime.info.* as a component status capability.

Core Capabilities​

Dynamic MethodDynamic SDK MethodDescription
log.writeRuntime().LogWrites a structured runtime log entry
state.getRuntime().StateGet, Runtime().StateGetIntReads plugin-scoped runtime state
state.setRuntime().StateSet, Runtime().StateSetIntWrites plugin-scoped runtime state
state.deleteRuntime().StateDeleteDeletes plugin-scoped runtime state
info.nowRuntime().NowReads the host time string
info.uuidRuntime().UUIDGenerates a host-side unique identifier
info.nodeRuntime().NodeReads the current host node identity

runtime is a none resource type and does not declare paths, tables, keys, or resources. Authorization boundaries are controlled by service + method.

Usage​

Dynamic plugins declare the runtime service in plugin.yaml:

hostServices:
- service: runtime
methods:
- log.write
- state.get
- state.set
- state.delete
- info.now
- info.uuid
- info.node

Call through pluginbridge.Default().Runtime() on the dynamic plugin side:

runtime := pluginbridge.Default().Runtime()

err := runtime.Log(protocol.LogLevelInfo, "export started", map[string]string{
"taskID": taskID,
})
if err != nil {
return err
}

now, err := runtime.Now()
if err != nil {
return err
}

err = runtime.StateSet("last_export_time", now)
if err != nil {
return err
}

lastExport, found, err := runtime.StateGet("last_export_time")
if err != nil {
return err
}

id, err := runtime.UUID()
if err != nil {
return err
}

node, err := runtime.Node()

Design Constraints​

  • Dynamic plugin exclusive. Runtime() only exists in the pluginbridge dynamic SDK and does not enter the source plugin capability.Services directory.
  • Runtime state is not a cache substitute. runtime.state.* is suitable for storing small amounts of plugin-scoped state. Cross-plugin sharing, counters, and expiration policies should use the Cache capability.
  • Log fields should be short and stable. Dynamic plugins should not put large bodies, secrets, tokens, or personally identifiable information into log fields.
  • Info reads are not health checks. info.now, info.uuid, and info.node only provide basic runtime information and do not express component availability.
  • Infrastructure state goes through Infra(). Component state reads should use the Infra capability and service: infra.