Skip to main content

lenso_contracts/
runtime.rs

1//! Pure-data runtime declarations for module manifests.
2//!
3//! These declarations describe runtime behavior a module can provide without
4//! carrying executable handlers. Loading sources decide how to bind them later.
5
6use serde::{Deserialize, Serialize};
7use utoipa::ToSchema;
8
9#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
10pub struct RuntimeSurface {
11    #[serde(default)]
12    pub functions: Vec<RuntimeFunctionDeclaration>,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
16pub struct RuntimeFunctionDeclaration {
17    /// Stable function name used by `runtime.function_runs`.
18    pub name: String,
19    /// Version for the declared function contract.
20    pub version: u16,
21    /// Queue name the host should use when registering the function.
22    pub queue: String,
23    /// Optional schema identifier for the function input payload.
24    #[serde(default, skip_serializing_if = "Option::is_none")]
25    pub input_schema: Option<String>,
26    /// Optional retry policy requested by the module. The host still owns
27    /// enforcement and may clamp values when behavior registration is added.
28    #[serde(default, skip_serializing_if = "Option::is_none")]
29    pub retry_policy: Option<RuntimeRetryPolicyDeclaration>,
30}
31
32#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
33pub struct RuntimeRetryPolicyDeclaration {
34    pub max_attempts: u32,
35    pub initial_delay_ms: u64,
36}