Skip to content

Commit 8343b8d

Browse files
committed
M3.16: read substrate_actor_template from public-API annotations path
The driver's template_name_from_spec previously only checked platform_config["substrate_actor_template"] at the top level. That key is reachable from in-process callers (and tests/live.rs), but the public OpenShell.v1.OpenShell.CreateSandbox path has no surface for it: the gateway's build_platform_config (compute/mod.rs:1333) maps SandboxTemplate.annotations into platform_config["annotations"] (a nested Struct), runtime_class_name into a top-level key, volume_claim_templates into another, etc. — none of which leave room to inject a substrate-specific opaque value at the top. This makes the driver's pre-provisioned-template path inaccessible to gateway-shaped clients, which is exactly the path the helpdesk demo needs (the synthesis path hardcodes a sleep loop as the child workload, incompatible with running a Python helpdesk agent). Extend template_name_from_spec to also look at platform_config["annotations"]["substrate_actor_template"] so public-API callers can request a pre-provisioned template via: SandboxTemplate.annotations["substrate_actor_template"] = "helpdesk-agent" The top-level key remains the primary path (driver-internal callers preserve compatibility); the annotation fallback is checked only when the top-level key is absent. Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>
1 parent 917e969 commit 8343b8d

1 file changed

Lines changed: 34 additions & 8 deletions

File tree

  • crates/openshell-driver-substrate/src

crates/openshell-driver-substrate/src/lib.rs

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -666,18 +666,44 @@ fn require_sandbox_id(sandbox_id: &str, sandbox_name: &str) -> Result<String, St
666666
}
667667

668668
/// Extract the Substrate ActorTemplate name from the sandbox's
669-
/// driver-specific configuration. The gateway carries this through
670-
/// `spec.template.platform_config` as a `google.protobuf.Struct`; we
671-
/// look for the well-known key `substrate_actor_template`. Returns
672-
/// `None` if either the path is missing or the value is not a string.
669+
/// driver-specific configuration. Two paths are checked, in order:
670+
///
671+
/// 1. Top-level `platform_config["substrate_actor_template"]`. Used by
672+
/// in-process callers that build a `DriverSandbox` directly (and
673+
/// by the live integration test).
674+
/// 2. `platform_config["annotations"]["substrate_actor_template"]`.
675+
/// The gateway's `build_platform_config` (compute/mod.rs:1333)
676+
/// nests `SandboxTemplate.annotations` under this key, so public
677+
/// OpenShell API callers can request a pre-provisioned template
678+
/// by setting `SandboxTemplate.annotations["substrate_actor_template"]`
679+
/// in their `CreateSandbox` request.
680+
///
681+
/// Returns `None` if neither path is present or the value is not a
682+
/// non-empty string.
673683
fn template_name_from_spec(sandbox: &DriverSandbox) -> Option<String> {
674684
use prost_types::value::Kind;
675685
let cfg = sandbox.spec.as_ref()?.template.as_ref()?.platform_config.as_ref()?;
676-
let value = cfg.fields.get("substrate_actor_template")?;
677-
match &value.kind {
678-
Some(Kind::StringValue(s)) if !s.is_empty() => Some(s.clone()),
679-
_ => None,
686+
// 1. Top-level key (driver-internal callers).
687+
if let Some(val) = cfg.fields.get("substrate_actor_template") {
688+
if let Some(Kind::StringValue(s)) = &val.kind {
689+
if !s.is_empty() {
690+
return Some(s.clone());
691+
}
692+
}
693+
}
694+
// 2. Nested under `annotations` (public-API gateway-translated path).
695+
if let Some(annotations_val) = cfg.fields.get("annotations") {
696+
if let Some(Kind::StructValue(annotations)) = &annotations_val.kind {
697+
if let Some(val) = annotations.fields.get("substrate_actor_template") {
698+
if let Some(Kind::StringValue(s)) = &val.kind {
699+
if !s.is_empty() {
700+
return Some(s.clone());
701+
}
702+
}
703+
}
704+
}
680705
}
706+
None
681707
}
682708

683709
/// Capability set the OpenShell supervisor needs to run in its full

0 commit comments

Comments
 (0)