Skip to main content

ExtensionManager

Struct ExtensionManager 

Source
pub struct ExtensionManager { /* private fields */ }
Expand description

Extension manager for handling loaded extensions.

Implementations§

Source§

impl ExtensionManager

Source

pub const DEFAULT_CLEANUP_BUDGET: Duration

Default cleanup budget for extension shutdown.

Source

pub fn new() -> Self

Create a new extension manager.

Loads persisted permission decisions from disk (if any) and seeds the in-memory policy prompt cache so that “Allow Always” / “Deny Always” choices survive across sessions.

Source

pub fn with_budget(budget: Budget) -> Self

Create a new extension manager with a specific operation budget.

Source

pub fn snapshot_version(&self) -> u64

Current snapshot version (seqlock counter).

Cheap atomic load — useful for staleness checks without cloning.

Source

pub fn set_budget(&self, budget: Budget)

Set the budget for extension operations.

Source

pub fn budget(&self) -> Budget

Get the current extension operation budget.

Source

pub fn extension_cx(&self) -> Cx

Create a Cx for extension operations using the configured budget.

If a budget with constraints is set, returns a budget-constrained Cx. Otherwise returns a standard request-scoped Cx.

Source

pub fn set_runtime_risk_config(&self, config: RuntimeRiskConfig)

Source

pub fn runtime_risk_config(&self) -> RuntimeRiskConfig

Source

pub fn rollout_phase(&self) -> RolloutPhase

Get the current rollout phase.

Source

pub fn set_rollout_phase(&self, phase: RolloutPhase)

Set the rollout phase explicitly (operator override).

Source

pub fn advance_rollout(&self) -> bool

Advance the rollout to the next phase. Returns true if changed.

Source

pub fn record_rollout_decision( &self, latency_ms: u64, was_error: bool, was_false_positive: bool, ) -> bool

Record a risk decision for rollback trigger evaluation. Returns true if a rollback was triggered.

Source

pub fn set_rollback_trigger(&self, trigger: &RollbackTrigger)

Configure the rollback trigger thresholds.

Source

pub fn rollout_state(&self) -> RolloutState

Get a snapshot of the current rollout state for operator inspection.

Source

pub fn record_subprocess_spawn(&self, extension_id: &str)

Record subprocess spawn (increments active subprocess counter).

Source

pub fn record_subprocess_exit(&self, extension_id: &str)

Record subprocess exit (decrements active subprocess counter).

Source

pub fn record_write_bytes(&self, extension_id: &str, bytes: u64)

Record bytes written by an extension (for write quota tracking).

Source

pub fn quota_state(&self, extension_id: &str) -> Option<(u64, u32, u64, u64)>

Get the current quota state for an extension (for telemetry/inspection).

Source

pub fn set_budget_controller_config( &self, config: ExtensionBudgetControllerConfig, )

Update the budget-controller configuration.

Source

pub fn budget_controller_config(&self) -> ExtensionBudgetControllerConfig

Snapshot the budget-controller configuration.

Source

pub fn regime_shift_snapshot( &self, extension_id: &str, ) -> Option<RegimeShiftSnapshot>

Snapshot the regime-shift detector state for an extension.

Source

pub fn any_safety_envelope_vetoing(&self) -> bool

Check if any extension has an active safety envelope veto.

When any extension is in a vetoed state, aggressive optimization (e.g. AMAC interleaving) should be disabled to remain conservative.

Source

pub fn safety_envelope_snapshot( &self, extension_id: &str, ) -> Option<SafetyEnvelopeSnapshot>

Snapshot the safety envelope state for an extension.

Source

pub fn oco_tuner_snapshot(&self, extension_id: &str) -> Option<OcoTunerSnapshot>

Snapshot OCO tuner state for an extension.

Source

pub fn set_quota_config(&self, config: ExtensionQuotaConfig)

Update the global quota configuration.

Source

pub fn drain_quota_breach_events(&self) -> Vec<QuotaBreachEvent>

Drain and return all quota breach telemetry events.

Source

pub fn quota_breach_count(&self) -> usize

Get the count of recorded quota breach events (for inspection).

Source

pub fn reset_quota_state(&self, extension_id: &str)

Reset quota counters for a specific extension (e.g. on extension reload). The sliding window timestamps and monotonic counters are cleared.

Source

pub fn enable_replay(&self, config: ReplayLaneConfig)

Enable replay trace recording with the given budget/config.

Source

pub fn disable_replay(&self)

Disable replay trace recording.

Source

pub fn store_replay_bundle(&self, bundle: ReplayTraceBundle)

Store a completed replay trace bundle from a dispatch cycle.

Source

pub fn drain_replay_bundles(&self) -> Vec<ReplayTraceBundle>

Drain and return all stored replay trace bundles.

Source

pub fn replay_config(&self) -> Option<ReplayLaneConfig>

Get the current replay lane config (if enabled).

Source

pub fn runtime_risk_ledger_artifact(&self) -> RuntimeRiskLedgerArtifact

Source

pub fn runtime_hostcall_telemetry_artifact( &self, ) -> RuntimeHostcallTelemetryArtifact

Source

pub fn runtime_risk_verify_ledger(&self) -> RuntimeRiskLedgerVerificationReport

Source

pub fn runtime_risk_replay_ledger(&self) -> Result<RuntimeRiskReplayArtifact>

Source

pub fn runtime_risk_calibrate_ledger( &self, config: &RuntimeRiskCalibrationConfig, ) -> Result<RuntimeRiskCalibrationReport>

Source

pub fn build_baseline( &self, extension_id: &str, ) -> Result<RuntimeRiskBaselineModel>

Build a baseline model for the given extension from the current ledger.

Source

pub fn record_exec_mediation(&self, entry: ExecMediationLedgerEntry)

Record an exec mediation decision into the SEC-4.3 ledger.

Source

pub fn record_secret_broker(&self, entry: SecretBrokerLedgerEntry)

Record a secret broker decision into the SEC-4.3 ledger.

Source

pub fn exec_mediation_artifact(&self) -> ExecMediationArtifact

Export the exec mediation ledger as a structured artifact.

Source

pub fn secret_broker_artifact(&self) -> SecretBrokerArtifact

Export the secret broker ledger as a structured artifact.

Source

pub fn record_security_alert(&self, alert: SecurityAlert)

Record a security alert into the SEC-5.1 alert stream.

Source

pub fn security_alert_artifact(&self) -> SecurityAlertArtifact

Export the security alert stream as a structured artifact.

Source

pub fn security_alert_count(&self) -> usize

Return the current count of recorded security alerts.

Source

pub fn set_hostcall_compat_kill_switch_global(&self, enabled: bool)

Enable or disable the global hostcall compatibility-lane kill-switch.

When enabled, all hostcalls that would normally use the fast lane are deterministically routed through the compatibility lane.

Source

pub fn set_hostcall_compat_kill_switch_for_extension( &self, extension_id: &str, enabled: bool, )

Enable or disable per-extension hostcall compatibility-lane kill-switch.

When enabled for extension_id, fast-lane-eligible hostcalls from that extension are routed through the compatibility lane.

Source

pub fn hostcall_compat_kill_switch_global(&self) -> bool

Source

pub fn hostcall_compat_kill_switch_for_extension( &self, extension_id: &str, ) -> bool

Source

pub fn enable_hostcall_reactor(&self, config: HostcallReactorConfig)

Enable the hostcall reactor mesh with the given configuration.

Fast-lane opcodes will be routed through per-shard SPSC lanes for reduced cross-core contention.

Source

pub fn disable_hostcall_reactor(&self)

Disable the hostcall reactor mesh.

Source

pub fn hostcall_reactor_enabled(&self) -> bool

Check if the reactor mesh is enabled.

Source

pub fn reactor_drain_shard( &self, shard_id: usize, budget: usize, ) -> Vec<HostcallReactorRequest>

Drain pending requests from a specific reactor shard.

Source

pub fn reactor_drain_global(&self, budget: usize) -> Vec<HostcallReactorRequest>

Drain pending requests in deterministic global sequence order.

Source

pub fn reactor_telemetry(&self) -> Option<HostcallReactorTelemetry>

Get reactor mesh telemetry snapshot.

Source

pub fn kill_switch( &self, extension_id: &str, reason: &str, operator: &str, ) -> KillSwitchResult

Activate the kill-switch for an extension.

Immediately sets the extension’s trust state to Killed and quarantines it in the runtime risk controller so all future hostcalls are rejected. Emits a Critical security alert and records an audit entry.

Source

pub fn lift_kill_switch( &self, extension_id: &str, reason: &str, operator: &str, ) -> KillSwitchResult

Lift the kill-switch for an extension.

Requires explicit acknowledgment. Moves the trust state back to Acknowledged and clears the quarantine flag. Records an audit entry and emits an Info-level security alert.

Source

pub fn is_killed(&self, extension_id: &str) -> bool

Check whether an extension is currently killed.

Source

pub fn trust_state(&self, extension_id: &str) -> ExtensionTrustState

Get the trust state for an extension.

Source

pub fn record_trust_onboarding( &self, extension_id: &str, risk_level: &str, accepted: bool, operator: &str, ) -> ExtensionTrustState

Record a trust onboarding decision.

If accepted is true, the extension moves to Acknowledged. If accepted is false, the extension is killed (rejected).

Source

pub fn promote_trust(&self, extension_id: &str) -> ExtensionTrustState

Promote an extension to Trusted state.

Only extensions currently in Acknowledged state can be promoted.

Source

pub fn kill_switch_audit_log(&self) -> Vec<KillSwitchAuditEntry>

Return the kill-switch audit trail.

Source

pub fn trust_onboarding_decisions(&self) -> Vec<TrustOnboardingDecision>

Return the trust onboarding decision log.

Source

pub fn export_incident_bundle( &self, filter: &IncidentBundleFilter, redaction: &IncidentBundleRedactionPolicy, ) -> IncidentEvidenceBundle

Export a complete incident evidence bundle combining all security artifacts with optional filtering and redaction.

Delegates to build_incident_evidence_bundle after collecting all sub-artifacts from the manager.

Source

pub async fn shutdown(&self, budget: Duration) -> bool

Shut down the extension runtime with a cleanup budget.

Sends a graceful shutdown to the configured extension runtime thread and waits up to budget for it to exit. Returns true if the runtime exited cleanly within the budget.

Source

pub fn set_ui_sender(&self, sender: Sender<ExtensionUiRequest>)

Source

pub fn clear_ui_sender(&self)

Source

pub fn set_runtime(&self, runtime: ExtensionRuntimeHandle)

Source

pub fn set_js_runtime(&self, runtime: JsExtensionRuntimeHandle)

Source

pub fn set_native_runtime(&self, runtime: NativeRustExtensionRuntimeHandle)

Source

pub fn set_cwd(&self, cwd: String)

Source

pub fn set_model_registry_values(&self, values: HashMap<String, String>)

Source

pub fn set_host_actions(&self, actions: Arc<dyn ExtensionHostActions>)

Source

pub fn runtime(&self) -> Option<ExtensionRuntimeHandle>

Source

pub fn js_runtime(&self) -> Option<JsExtensionRuntimeHandle>

Source

pub fn native_runtime(&self) -> Option<NativeRustExtensionRuntimeHandle>

Source

pub fn cached_policy_prompt_decision( &self, extension_id: &str, capability: &str, ) -> Option<bool>

Source

pub fn cache_policy_prompt_decision( &self, extension_id: &str, capability: &str, allow: bool, )

Source

pub fn revoke_extension_permissions(&self, extension_id: &str)

Revoke all persisted permission decisions for an extension.

Source

pub fn reset_all_permissions(&self)

Reset all persisted permission decisions.

Source

pub fn list_permissions( &self, ) -> HashMap<String, HashMap<String, PersistedDecision>>

List all persisted permission decisions.

Source

pub fn active_tools(&self) -> Option<Vec<String>>

Lock-free: reads from the RCU snapshot.

Source

pub async fn load_js_extensions( &self, specs: Vec<JsExtensionLoadSpec>, ) -> Result<()>

Source

pub async fn load_native_extensions( &self, specs: Vec<NativeRustExtensionLoadSpec>, ) -> Result<()>

Source

pub async fn load_wasm_extensions( &self, host: &WasmExtensionHost, specs: Vec<WasmExtensionLoadSpec>, tools: Arc<ToolRegistry>, ) -> Result<()>

Source

pub fn wasm_extensions(&self) -> Vec<WasmExtensionHandle>

Source

pub fn set_session(&self, session: Arc<dyn ExtensionSession>)

Source

pub fn session_handle(&self) -> Option<Arc<dyn ExtensionSession>>

Lock-free: reads from the RCU snapshot.

Source

pub fn set_active_tools(&self, tools: Vec<String>)

Source

pub fn current_model(&self) -> (Option<String>, Option<String>)

Lock-free: reads from the RCU snapshot.

Source

pub fn set_current_model( &self, provider: Option<String>, model_id: Option<String>, )

Source

pub fn current_thinking_level(&self) -> Option<String>

Lock-free: reads from the RCU snapshot.

Source

pub fn set_current_thinking_level(&self, level: Option<String>)

Source

pub fn extension_tool_defs(&self) -> Vec<Value>

Collect tool definitions from all registered extensions.

Uses the pre-computed snapshot (RCU) instead of locking the mutex.

Source

pub fn register(&self, payload: RegisterPayload)

Source

pub fn has_command(&self, name: &str) -> bool

Source

pub fn register_command(&self, name: &str, description: Option<&str>)

Dynamically register a slash command at runtime (from a hostcall).

Source

pub fn register_provider(&self, payload: Value)

Dynamically register a provider at runtime (from a hostcall).

Source

pub fn register_flag(&self, spec: Value)

Dynamically register a flag at runtime (from a hostcall).

Source

pub async fn execute_command( &self, command_name: &str, args: &str, timeout_ms: u64, ) -> Result<Value>

Execute an extension slash command via the JS runtime.

Source

pub fn extension_providers(&self) -> Vec<Value>

Return extension-registered providers as raw JSON specs.

Uses the pre-computed snapshot (RCU) instead of locking the mutex.

Source

pub fn provider_has_stream_simple(&self, provider_id: &str) -> bool

Return true if an extension provider is backed by a JS streamSimple handler.

Source

pub fn extension_model_entries(&self) -> Vec<ModelEntry>

Convert extension-registered providers into model entries suitable for merging into the ModelRegistry.

Source

pub fn list_commands(&self) -> Vec<Value>

Source

pub fn has_shortcut(&self, key_id: &str) -> bool

Source

pub fn list_shortcuts(&self) -> Vec<Value>

Source

pub fn list_flags(&self) -> Vec<Value>

Source

pub fn list_event_hooks(&self) -> Vec<String>

List all event hook names registered by all loaded extensions.

Source

pub async fn execute_shortcut( &self, key_id: &str, ctx_payload: Value, timeout_ms: u64, ) -> Result<Value>

Execute an extension shortcut via the JS runtime.

Source

pub async fn set_flag_value( &self, extension_id: &str, flag_name: &str, value: Value, ) -> Result<()>

Set a flag value in the JS runtime for a specific extension.

Source

pub async fn request_ui( &self, request: ExtensionUiRequest, ) -> Result<Option<ExtensionUiResponse>>

Source

pub fn respond_ui(&self, response: ExtensionUiResponse) -> bool

Source

pub async fn dispatch_event( &self, event: ExtensionEventName, data: Option<Value>, ) -> Result<()>

Dispatch an event to all registered extensions.

Source

pub async fn dispatch_event_with_response( &self, event: ExtensionEventName, data: Option<Value>, timeout_ms: u64, ) -> Result<Option<Value>>

Dispatch an event to all registered extensions and return the raw response (if any).

Source

pub async fn dispatch_cancellable_event( &self, event: ExtensionEventName, data: Option<Value>, timeout_ms: u64, ) -> Result<bool>

Dispatch a cancellable event to all registered extensions.

Source

pub async fn dispatch_event_batch( &self, events: Vec<(ExtensionEventName, Option<Value>)>, ) -> Result<()>

Dispatch multiple fire-and-forget events in a single JS bridge call.

Events that have no registered hooks are filtered out before crossing the bridge. Returns Ok(()) — individual per-event errors are logged but do not fail the batch.

Source

pub async fn dispatch_tool_call( &self, tool_call: &ToolCall, timeout_ms: u64, ) -> Result<Option<ToolCallEventResult>>

Dispatch a tool_call event to registered extensions and return the first blocking response (if any).

Source

pub async fn dispatch_tool_result( &self, tool_call: &ToolCall, output: &ToolOutput, is_error: bool, timeout_ms: u64, ) -> Result<Option<ToolResultEventResult>>

Dispatch a tool_result event to registered extensions and return the last handler response (if any).

Source

pub fn invalidate_ctx_cache(&self)

Invalidate the context cache, forcing the next dispatch to rebuild it.

Call this when session content changes outside the normal setter flow (e.g. after appending messages to a session).

Source

pub fn has_hook_for(&self, event_name: &str) -> bool

Check whether any extension has registered a hook for the given event name. O(1) lookup via pre-computed bitmap.

Lock-free: reads from the RCU snapshot.

Source

pub fn has_any_event_hooks(&self) -> bool

Returns true if at least one event hook is registered across all extensions. Use this as a fast-path gate to skip event serialization entirely when no hooks are present.

Lock-free: reads from the RCU snapshot.

Trait Implementations§

Source§

impl Clone for ExtensionManager

Source§

fn clone(&self) -> ExtensionManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExtensionManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ExtensionManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
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> 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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<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
Source§

impl<T> ParallelSend for T

Source§

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

Source§

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