Skip to main content

PackRuntime

Struct PackRuntime 

Source
pub struct PackRuntime { /* private fields */ }

Implementations§

Source§

impl PackRuntime

Source

pub fn contains_component(&self, component_ref: &str) -> bool

Source

pub fn state_store_handle(&self) -> Option<Arc<dyn StateStore>>

Returns a clonable handle to the pack’s state store, when one is configured. Used by the flow engine’s built-in state.get/state.set operators which call into the same store that WASM components read through their state.read/state.write host imports.

Source

pub async fn load( path: impl AsRef<Path>, config: Arc<HostConfig>, mocks: Option<Arc<MockLayer>>, archive_source: Option<&Path>, session_store: Option<Arc<dyn SessionStore>>, state_store: Option<Arc<dyn StateStore>>, wasi_policy: Arc<RunnerWasiPolicy>, secrets: Arc<dyn SecretsManager>, oauth_config: Option<OAuthBrokerConfig>, verify_archive: bool, component_resolution: ComponentResolution, ) -> Result<PackRuntime, Error>

Source

pub fn set_runtime_config_non_secret( &mut self, map: Option<Arc<BTreeMap<String, Value>>>, )

Inject the pack-config.v1.non_secret map for this pack. Called by the producer (greentic-start, C4.3) after loading the deployed PackConfig. Passing None clears any previously-set map.

Source

pub fn runtime_config_non_secret(&self) -> Option<&Arc<BTreeMap<String, Value>>>

Read-only accessor for the injected pack-config.v1.non_secret map. Used by the revision loader’s tests to assert producer plumbing.

Source

pub fn set_runtime_refs(&mut self, injection: Option<RuntimeRefsInjection>)

Inject the pack-config.v1.runtime_refs channel (C5): per-pack key → URI bindings plus the env-shared resolver. Called by greentic-start after loading the deployed PackConfig. Passing None clears any previously-set injection.

Source

pub fn runtime_refs(&self) -> Option<&RuntimeRefsInjection>

Read-only accessor for the injected runtime-refs channel. Used by the revision loader’s tests to assert producer plumbing.

Source

pub async fn list_flows(&self) -> Result<Vec<FlowDescriptor>, Error>

Source

pub async fn run_flow( &self, flow_id: &str, input: Value, ) -> Result<Value, Error>

Source

pub async fn invoke_component( &self, component_ref: &str, ctx: ExecCtx, operation: &str, config_json: Option<String>, input_json: String, ) -> Result<Value, Error>

Source

pub fn resolve_provider( &self, provider_id: Option<&str>, provider_type: Option<&str>, ) -> Result<ProviderBinding, Error>

Source

pub async fn invoke_provider( &self, binding: &ProviderBinding, ctx: ExecCtx, op: &str, input_json: Vec<u8>, ) -> Result<Value, Error>

Source

pub async fn invoke_identify_instance( &self, binding: &ProviderBinding, payload: Vec<u8>, ) -> Result<IdentifyOutcome, Error>

Call the provider component’s identify-instance export (greentic:provider-instance-identity@0.1.0) with the inbound payload bytes. Returns an IdentifyOutcome — see the variant docs for the per-case contract.

§Payload shape (M1 IID.4d wrapper)

payload is forwarded opaque to the component. The shape is set by the caller; the M1 IID.4d wrapper convention from greentic-start is {headers: [{name,value}], body: <parsed-or-null>} so providers whose discriminator lives in HTTP headers (Telegram via x-telegram-bot-api-secret-token) can identify the instance the same call shape that body-based providers (Teams, Slack, Webex, etc.) use. See the docstring on greentic:provider-instance-identity/instance-identity-api.identify-instance for the full contract; this host method does not parse or validate the bytes.

§Host authority on identity probes

The linker registers the full host import surface (Wasmtime validates all imports eagerly at instantiate_pre, not just those reachable from the invoked export). The WASI sandbox is locked down: no preopens, no env, no stdio. Deny-shim linker handlers (trap on call, satisfy at link time) are a follow-up in greentic-interfaces-wasmtime. See register_identity_probe.

Source

pub async fn invoke_describe_identify_instance( &self, binding: &ProviderBinding, ) -> Result<Option<IdentifyInstanceHint>, Error>

Call the provider component’s describe-identify-instance export (greentic:provider-instance-identity/instance-identity-describe@0.1.0) and parse the returned JSON into an IdentifyInstanceHint.

Returns Ok(None) for every “no hint available” case: the component does not export the describe world, the export returned none, the returned bytes are not valid JSON, or the version gate failed. The two malformed cases are warn-logged so a typo’d hint surfaces in operator logs without blocking ingest. Component traps and other infrastructure errors propagate as Err.

This is the uncached probe — see resolve_identify_hint for the cached wrapper that callers SHOULD use on the inbound hot path.

Source

pub async fn resolve_identify_hint( &self, binding: &ProviderBinding, ) -> Option<IdentifyInstanceHint>

Cached wrapper around invoke_describe_identify_instance. The hint for a given binding.component_ref is invariant across inbound requests within a revision (it is a function of the component itself, not of the payload), so we probe lazily on first ask and reuse thereafter. ArcSwap-driven revision swaps allocate a fresh PackRuntime, naturally invalidating the cache.

Returns None when the component does not export the describe world, when the probe returns no hint, or when the probe fails (trap, timeout, instantiation error). Failures are warn-logged and cached — the same trap is logged once per revision per component, not per request.

Source

pub async fn describe_identify_hints_by_provider_type( &self, provider_types: &[&str], ) -> Result<HashMap<String, Option<IdentifyInstanceHint>>, Error>

Fan out resolve_identify_hint over each requested provider_type. Result map is keyed by provider_type; None value means the pack has no binding for that type OR the binding’s component does not export the describe world (unhinted — caller forwards input headers unfiltered for back-compat).

provider_id-collision errors from ProviderRegistry::resolve against a provider_type query are propagated (M1.1 invariant violation, malformed pack).

Fan out resolve_identify_hint across requested types. None value means the pack has no binding for that type OR the binding’s component does not export the describe world.

The per-binding loop is inlined (rather than factored into a shared AsyncFnMut-based helper) deliberately: routing through an AsyncFnMut closure destabilises HRTB Send inference for the returned future, which propagates up to host-level fan-out APIs and from there to downstream spawned-service consumers. See the regression test identify_futures_are_send on the host.

Source

pub async fn identify_endpoints_by_provider_type( &self, provider_types: &[&str], payload: &[u8], ) -> Result<HashMap<String, IdentifyOutcome>, Error>

Unscoped legacy API: fan out invoke_identify_instance with the caller-supplied opaque payload bytes forwarded verbatim. No describe-identify-instance hint lookup, no per-provider header scoping. New callers should use the _scoped sibling for per-provider header allowlist scoping (Phase D).

Loop inlined for the same reason as describe_identify_hints_by_provider_type.

Source

pub async fn identify_endpoints_by_provider_type_scoped( &self, provider_types: &[&str], headers: &[(String, String)], body: &Value, ) -> Result<HashMap<String, IdentifyOutcome>, Error>

Per-provider scoped variant of identify_endpoints_by_provider_type.

The wrapper payload is built per-binding from (headers, body) and the component’s cached identify-instance hint (see resolve_identify_hint): hinted providers see only the headers their hint declares; unhinted providers see every header passed in. Result-map semantics match the unscoped variant.

Loop inlined for the same reason as describe_identify_hints_by_provider_type.

Source

pub fn load_flow(&self, flow_id: &str) -> Result<Flow, Error>

Source

pub fn metadata(&self) -> &PackMetadata

Source

pub fn read_asset(&self, asset_path: &str) -> Result<Vec<u8>, Error>

Read an asset file from the pack’s assets directory.

Accepts paths like assets/cards/card-a.json or cards/card-a.json (the assets/ prefix is stripped automatically).

Source

pub fn component_manifest( &self, component_ref: &str, ) -> Option<&ComponentManifest>

Source

pub fn describe_component_contract_v0_6( &self, component_ref: &str, ) -> Result<Option<Value>, Error>

Source

pub fn load_schema_json(&self, schema_ref: &str) -> Result<Option<Value>, Error>

Source

pub fn required_secrets(&self) -> &[SecretRequirement]

Source

pub fn missing_secrets(&self, tenant_ctx: &TenantCtx) -> Vec<SecretRequirement>

Source

pub fn for_component_test( components: Vec<(String, PathBuf)>, flows: HashMap<String, FlowIR>, pack_id: &str, config: Arc<HostConfig>, ) -> Result<PackRuntime, Error>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more